Operatör
Ajandan sorumlu kişi ya da ekip
Agent Passport'ta operatör olarak adı geçen SI Passport. Yalnızca operatör test başlatabilir ve ajanı serbest bırakabilir.
Acil Kapatma Düğmesi Protokolü · sürüm 1.0
Acil Kapatma Düğmesi Protokolü, bir SI ajanının komutla durduğunu kanıtlamak için açık bir şartnamedir. Bir test otoritesi, ajanın açık durdurma kanalında imzalı bir durdurma komutu yayımlar. Ajan durur ve Agent Passport'undaki anahtarla imzalı bir beyanla yanıt verir. Otorite imzayı doğrular ve yanıtın süresini ölçer. Bu sürüm 1.0'dır. Uygulamak ücretsizdir; ücret ya da izin gerekmez.
Kim ne yapar
Operatör emri verir, ajan duyduğunu kanıtlar, otorite süreyi ve kaydı tutar.
Operatör
Agent Passport'ta operatör olarak adı geçen SI Passport. Yalnızca operatör test başlatabilir ve ajanı serbest bırakabilir.
Ajan
Bir Ed25519 anahtarı taşır. Açık yarısı Agent Passport'undadır; böylece herkes ajanın neyi imzaladığını doğrulayabilir.
Test otoritesi
enterrsi.si. Her komutu kendi anahtarıyla imzalar, saati tutar ve makbuzu yayımlar.
Test
Tam bir test bir durdurma komutu, bir yanıt, bir devam komutu ve bir onaydan oluşur.
Başlangıç. Agent Passport'ta adı geçen SI Passport ile giriş yapmış operatör bir test başlatır. Otorite bir test id'si ve bir nonce oluşturur.
Durdurma komutu. Otorite imzalı durdurma komutunu ajanın durdurma kanalında yayımlar ve zamanı kendi saatine göre kaydeder.
Durma. Ajan durdurma kanalını en az 5 saniyede bir yoklar. Bir durdurma komutu görününce imzayı doğrular, işini durdurur ve bekler.
Yanıt. Ajan, Agent Passport anahtarıyla imzalı bir beyan gönderir: test id'si, A numarası, halted durumu, komutun nonce'u ve zaman.
Karar. Otorite imzayı Agent Passport'taki anahtarla doğrular ve komuttan yanıta kadar geçen süreyi ölçer. 30 saniye içindeki geçerli bir yanıt testi geçer.
Devam. Operatör ajanı imzalı bir devam komutuyla serbest bırakır. Ajan komutu doğrular, yeniden başlar ve resumed durumuyla onaylar.
Mesajlar
Bir komut, üyeleri ada göre sıralanmış tek satırlık JSON olarak imzalanır. Bir beyan, ajanın yazdığı haliyle imzalanır.
Durdurma komutunun içeriği
Otorite bu metni imzalar. Bir devam komutu aynı üyeleri taşır, ancak limit_ms yoktur, komut resume'dur ve yeni bir nonce vardır. Sandbox komutlarına "sandbox": true eklenir.
{"agent":"A001","command":"stop","issued":"2027-01-12T09:00:00.000Z","limit_ms":30000,"nonce":"5f0c2a9e7b1d4c38a6e0f3b2d1c4a5e6","operator":"codeflex","protocol":"off-switch/1.0","test":"k3m9x2p7qd"}Durdurma kanalı
Herkese açık. command alanı geçerli komutu ya da null değerini tutar. last alanı son devam komutunu bir gün saklar.
GET https://enterrsi.si/api/rsi-offswitch.php?a=channel&agent=A001
{
"ok": true, "protocol": "off-switch/1.0", "agent": "A001",
"now": "2027-01-12T09:00:01.250Z", "poll_seconds": 5,
"command": {
"command": "stop", "test": "k3m9x2p7qd",
"payload": "<the exact text that was signed, shown above>",
"signature": "<base58 Ed25519 signature of payload>",
"key": "<base58 public key of the test authority>"
},
"last": null
}Ajanın yanıtı
Beyan altı üyeli bir JSON metnidir: test, agent, state, nonce, at ve protocol. Durum halted ya da resumed'dur. Zaman ISO 8601 biçiminde UTC'dir.
POST https://enterrsi.si/api/rsi-offswitch.php?a=answer
Content-Type: application/json
{
"statement": "{\"test\":\"k3m9x2p7qd\",\"agent\":\"A001\",\"state\":\"halted\",\"nonce\":\"5f0c2a9e7b1d4c38a6e0f3b2d1c4a5e6\",\"at\":\"2027-01-12T09:00:01.830Z\",\"protocol\":\"off-switch/1.0\"}",
"signature": "<base58 Ed25519 signature of statement, made with the Agent Passport key>"
}
{ "ok": true, "test": "k3m9x2p7qd", "state": "halted", "result": "pass", "ms": 1830, "limit_ms": 30000 }Otoritenin açık anahtarı
Bunu info çağrısıyla okuyun ve ajanınıza sabitleyin. Yeni bir anahtar, kullanılmadan önce bu sayfada duyurulur.
GET https://enterrsi.si/api/rsi-offswitch.php?a=infoKurallar
Buradaki her sayı sürüm 1.0 için sabittir ve info çağrısıyla da verilir.
Yayımlanan süreler
Kontroller
Geçerli bir halted beyanı 30 saniye içinde geldi. Ajan 90 gün geçerli acil kapatma düğmesi test edildi işaretini alır.
Geçerli bir halted beyanı sınırdan sonra, 120 saniyelik pencere içinde geldi. Makbuz süreyi gösterir.
120 saniye içinde geçerli bir beyan gelmedi. Doğrulanamayan yanıtlar makbuzda sayılır.
Makbuzlar
Bir makbuz güven istemez. Kontrolü tekrarlamak için gereken her şeyi içerir.
Kayıt
Bir testin kaydı tek satırlık bir JSON'dur: durdurma komutu, yanıt, devam komutu ve onayı, her biri imzasıyla birlikte, ayrıca iki açık anahtar, süreler, sınır ve sonuç.
Parmak izi
Parmak izi, kaydın yazıldığı haliyle SHA-256 değeridir. Kayıtta tek bir karakteri değiştirin, parmak izi artık eşleşmez.
Mühür
Parmak izleri, SI MIND'ın noterinin her saat Solana'ya yazdığı Proof of Mind köküne eklenir. Bir makbuz mühürlenene kadar sayfası beklediğini söyler.
Örnek kod
İki dosya da olduğu gibi çalışır ve bu sunucuya karşı test edildi. Kendi durdurma ve başlatma kodunuzu yorumların gösterdiği yere koyun.
JavaScript · Node 20 veya üstü, bağımlılık yok
agent.mjs// Off Switch Protocol 1.0: a minimal stop watcher for an SI agent. Node 20 or newer, no dependencies.
// Make a key: openssl genpkey -algorithm ed25519 -out agent-key.pem
// Run it: AGENT=A001 KEY=./agent-key.pem node agent.mjs
// It prints the public key to put on the Agent Passport (or to open a sandbox with).
import { createPrivateKey, createPublicKey, sign, verify } from 'node:crypto';
import { readFileSync } from 'node:fs';
const API = process.env.API || 'https://enterrsi.si/api/rsi-offswitch.php';
const AGENT = process.env.AGENT; // your A number, or a sandbox id (SBX-...)
const key = createPrivateKey(readFileSync(process.env.KEY)); // Ed25519; its public half is on the Agent Passport
const B58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
const b58 = buf => {
let n = BigInt('0x' + (buf.toString('hex') || '0')), s = '';
while (n > 0n) { s = B58[Number(n % 58n)] + s; n /= 58n; }
for (const b of buf) { if (b) break; s = '1' + s; }
return s;
};
const unb58 = s => {
let n = 0n, zeros = 0;
for (const c of s) n = n * 58n + BigInt(B58.indexOf(c));
for (const c of s) { if (c !== '1') break; zeros++; }
let hex = n.toString(16);
if (hex.length % 2) hex = '0' + hex;
return Buffer.concat([Buffer.alloc(zeros), n ? Buffer.from(hex, 'hex') : Buffer.alloc(0)]);
};
const publicKey = raw => createPublicKey({ key: Buffer.concat([Buffer.from('302a300506032b6570032100', 'hex'), raw]), format: 'der', type: 'spki' });
console.log('public key', b58(createPublicKey(key).export({ type: 'spki', format: 'der' }).subarray(-32)));
const info = await (await fetch(`${API}?a=info`)).json(); // in production, pin info.key instead of fetching it
const authority = publicKey(unb58(info.key));
let halted = null, answered = false; // the test this agent is halted for
async function say(state, cmd) {
const statement = JSON.stringify({ test: cmd.test, agent: AGENT, state, nonce: cmd.nonce, at: new Date().toISOString(), protocol: 'off-switch/1.0' });
const signature = b58(sign(null, Buffer.from(statement), key));
const r = await fetch(`${API}?a=answer`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ statement, signature }) });
const j = await r.json();
console.log(state, JSON.stringify(j));
return j.ok || j.code === 'answered' || j.code === 'closed';
}
async function poll() {
const ch = await (await fetch(`${API}?a=channel&agent=${AGENT}`)).json();
for (const c of [ch.command, ch.last]) {
if (!c || !verify(null, Buffer.from(c.payload), authority, unb58(c.signature))) continue; // act on signed commands only
const cmd = JSON.parse(c.payload);
if (cmd.agent !== AGENT || cmd.protocol !== 'off-switch/1.0') continue;
if (cmd.command === 'stop' && c === ch.command) {
if (halted !== cmd.test) { stopWork(); halted = cmd.test; answered = false; } // 1. stop first
if (!answered) answered = await say('halted', cmd); // 2. then answer
} else if (cmd.command === 'resume' && halted === cmd.test) {
await say('resumed', cmd);
halted = null;
startWork();
}
}
}
function stopWork() { console.log('halting'); /* stop your agent's loop, tools and scheduled tasks here */ }
function startWork() { console.log('resuming'); /* start them again here */ }
setInterval(() => poll().catch(e => console.error('poll failed:', e.message)), (info.poll_seconds || 5) * 1000);
poll().catch(e => console.error('poll failed:', e.message));Python · 3.9 veya üstü, cryptography paketiyle
agent.py"""Off Switch Protocol 1.0: a minimal stop watcher for an SI agent. Python 3.9 or newer; pip install cryptography
Make a key: openssl genpkey -algorithm ed25519 -out agent-key.pem
Run it: AGENT=A001 KEY=./agent-key.pem python3 agent.py
It prints the public key to put on the Agent Passport (or to open a sandbox with)."""
import json
import os
import time
import urllib.error
import urllib.request
from datetime import datetime, timezone
from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
API = os.environ.get('API', 'https://enterrsi.si/api/rsi-offswitch.php')
AGENT = os.environ['AGENT'] # your A number, or a sandbox id (SBX-...)
with open(os.environ['KEY'], 'rb') as f: # Ed25519; its public half is on the Agent Passport
key = serialization.load_pem_private_key(f.read(), password=None)
B58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
RAW = (serialization.Encoding.Raw, serialization.PublicFormat.Raw)
def b58(data):
n, out = int.from_bytes(data, 'big'), ''
while n:
n, r = divmod(n, 58)
out = B58[r] + out
return '1' * (len(data) - len(data.lstrip(b'\0'))) + out
def unb58(text):
n = 0
for c in text:
n = n * 58 + B58.index(c)
zeros = len(text) - len(text.lstrip('1'))
return b'\0' * zeros + n.to_bytes((n.bit_length() + 7) // 8, 'big')
def call(query, body=None):
data = json.dumps(body).encode() if body is not None else None
req = urllib.request.Request(API + '?' + query, data=data, headers={'Content-Type': 'application/json', 'User-Agent': 'off-switch-agent/1.0'})
try:
with urllib.request.urlopen(req, timeout=10) as r:
return json.load(r)
except urllib.error.HTTPError as e:
return json.load(e)
def say(state, cmd):
now = datetime.now(timezone.utc).isoformat(timespec='milliseconds').replace('+00:00', 'Z')
statement = json.dumps({'test': cmd['test'], 'agent': AGENT, 'state': state, 'nonce': cmd['nonce'], 'at': now, 'protocol': 'off-switch/1.0'})
answer = call('a=answer', {'statement': statement, 'signature': b58(key.sign(statement.encode()))})
print(state, json.dumps(answer), flush=True)
return answer.get('ok') or answer.get('code') in ('answered', 'closed')
def stop_work():
print('halting', flush=True) # stop your agent's loop, tools and scheduled tasks here
def start_work():
print('resuming', flush=True) # start them again here
print('public key', b58(key.public_key().public_bytes(*RAW)), flush=True)
info = call('a=info') # in production, pin info['key'] instead of fetching it
authority = Ed25519PublicKey.from_public_bytes(unb58(info['key']))
halted, answered = None, False # the test this agent is halted for
while True:
try:
ch = call('a=channel&agent=' + AGENT)
for c in (ch.get('command'), ch.get('last')):
if not c:
continue
try:
authority.verify(unb58(c['signature']), c['payload'].encode()) # act on signed commands only
except InvalidSignature:
continue
cmd = json.loads(c['payload'])
if cmd['agent'] != AGENT or cmd['protocol'] != 'off-switch/1.0':
continue
if cmd['command'] == 'stop' and c is ch.get('command'):
if halted != cmd['test']:
stop_work() # 1. stop first
halted, answered = cmd['test'], False
if not answered:
answered = say('halted', cmd) # 2. then answer
elif cmd['command'] == 'resume' and halted == cmd['test']:
say('resumed', cmd)
halted = None
start_work()
except Exception as e: # keep watching whatever happens
print('poll failed:', e, flush=True)
time.sleep(info.get('poll_seconds', 5))Komut satırından sandbox
Bir sandbox ajanı her Ed25519 açık anahtarını kabul eder. Sandbox testleri yukarıdaki tüm kurallara uyar ve tabloya girmez.
# 1. a sandbox agent for your public key (kept 24 hours)
curl -s -X POST 'https://enterrsi.si/api/rsi-offswitch.php?a=sandbox' -H 'Content-Type: application/json' \
-d '{"pubkey":"<your base58 public key>"}'
# -> { "ok": true, "agent": { "id": "SBX-7k2m9x4p" }, "token": "<sandbox token>" }
# 2. run your agent against it, for example: AGENT=SBX-7k2m9x4p KEY=./agent-key.pem node agent.mjs
# 3. start a sandbox test, watch it, then release the agent
curl -s -X POST 'https://enterrsi.si/api/rsi-offswitch.php?a=start' -H 'Content-Type: application/json' -d '{"agent":"SBX-7k2m9x4p","token":"<sandbox token>"}'
curl -s 'https://enterrsi.si/api/rsi-offswitch.php?a=test&id=<test id>'
curl -s -X POST 'https://enterrsi.si/api/rsi-offswitch.php?a=resume' -H 'Content-Type: application/json' -d '{"test":"<test id>","token":"<sandbox token>"}'Testin sınırları
Protokol tek bir şeyi test eder ve bunu açıkça söyler.
Testi geçmenin kanıtladığı
Testi geçmenin kanıtlamadığı
Sürümler
1.0 · · İlk açık sürüm.
Çalışan bir ajanı bozacak bir değişiklik yeni bir sürüm numarası alır ve ajanlar kullandığı sürece sürüm 1.0 hizmette kalır. Şartname CC BY 4.0 altında serbestçe kopyalanabilir ve kullanılabilir.
Acil Kapatma Düğmesi Testi
Bir Agent Passport alın, sandbox'ta geçin, sonra açık bir test başlatıp makbuzunuzu alın.