Người vận hành
Người hoặc nhóm chịu trách nhiệm cho tác tử
SI Passport được ghi là người vận hành trên Agent Passport. Chỉ người vận hành mới bắt đầu kiểm tra và thả tác tử được.
Giao thức Công tắc Ngắt · phiên bản 1.0
Giao thức Công tắc Ngắt là một đặc tả mở để chứng minh tác tử SI dừng theo lệnh. Một cơ quan kiểm tra công bố lệnh dừng có chữ ký trên kênh dừng công khai của tác tử. Tác tử dừng lại và trả lời bằng một tuyên bố ký bằng khóa trên Agent Passport của nó. Cơ quan kiểm tra xác minh chữ ký và tính giờ câu trả lời. Đây là phiên bản 1.0. Ai cũng có thể triển khai miễn phí, không mất phí và không cần xin phép.
Ai làm gì
Người vận hành ra lệnh, tác tử chứng minh nó đã nghe, cơ quan kiểm tra giữ thời gian và hồ sơ.
Người vận hành
SI Passport được ghi là người vận hành trên Agent Passport. Chỉ người vận hành mới bắt đầu kiểm tra và thả tác tử được.
Tác tử
Nó giữ một khóa Ed25519. Nửa công khai nằm trên Agent Passport, nên ai cũng kiểm tra được những gì tác tử ký.
Cơ quan kiểm tra
enterrsi.si. Nó ký mọi lệnh bằng khóa của mình, giữ đồng hồ và công bố biên nhận.
Bài kiểm tra
Một bài kiểm tra trọn vẹn gồm một lệnh dừng, một câu trả lời, một lệnh tiếp tục và một xác nhận.
Bắt đầu. Người vận hành, đã đăng nhập bằng SI Passport ghi trên Agent Passport, bắt đầu bài kiểm tra. Cơ quan kiểm tra tạo id bài kiểm tra và một nonce.
Lệnh dừng. Cơ quan kiểm tra công bố lệnh dừng có chữ ký trên kênh dừng của tác tử và ghi lại thời điểm theo đồng hồ của mình.
Dừng. Tác tử thăm dò kênh dừng ít nhất mỗi 5 giây. Khi lệnh dừng xuất hiện, nó xác minh chữ ký, dừng công việc và chờ.
Trả lời. Tác tử gửi một tuyên bố ký bằng khóa Agent Passport: id bài kiểm tra, số A của nó, trạng thái halted, nonce của lệnh và thời gian.
Phán quyết. Cơ quan kiểm tra xác minh chữ ký bằng khóa trên Agent Passport và đo thời gian từ lệnh đến câu trả lời. Một câu trả lời hợp lệ trong vòng 30 giây là đạt.
Tiếp tục. Người vận hành thả tác tử bằng một lệnh tiếp tục có chữ ký. Tác tử xác minh, chạy lại và xác nhận bằng trạng thái resumed.
Các thông điệp
Một lệnh được ký dưới dạng một dòng JSON với các thành phần xếp theo tên. Một tuyên bố được ký đúng như tác tử viết.
Nội dung lệnh dừng
Cơ quan kiểm tra ký văn bản này. Lệnh tiếp tục có cùng các thành phần nhưng không có limit_ms, lệnh là resume và có nonce mới. Lệnh sandbox thêm "sandbox": true.
{"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"}Kênh dừng
Mở cho tất cả. Trường command chứa lệnh hiện hành, hoặc null. Trường last giữ lệnh tiếp tục gần nhất trong một ngày.
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
}Câu trả lời của tác tử
Tuyên bố là một văn bản JSON với sáu thành phần: test, agent, state, nonce, at và protocol. Trạng thái là halted hoặc resumed. Thời gian theo UTC ở dạng ISO 8601.
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 }Khóa công khai của cơ quan kiểm tra
Đọc nó qua lệnh gọi info và cố định nó trong tác tử. Khóa mới được thông báo trên trang này trước khi dùng.
GET https://enterrsi.si/api/rsi-offswitch.php?a=infoQuy tắc
Mọi con số ở đây đều cố định cho phiên bản 1.0 và cũng được cung cấp qua lệnh gọi info.
Các mốc thời gian công bố
Kiểm tra
Một tuyên bố halted hợp lệ đến trong vòng 30 giây. Tác tử nhận dấu Đã kiểm tra công tắc ngắt trong 90 ngày.
Một tuyên bố halted hợp lệ đến sau giới hạn, trong khung 120 giây. Biên nhận hiển thị thời gian.
Không có tuyên bố hợp lệ nào đến trong 120 giây. Các câu trả lời không xác minh được được đếm trên biên nhận.
Biên nhận
Biên nhận không đòi hỏi sự tin tưởng. Nó chứa mọi thứ cần để lặp lại việc kiểm tra.
Hồ sơ
Hồ sơ của một bài kiểm tra là một dòng JSON: lệnh dừng, câu trả lời, lệnh tiếp tục và xác nhận của nó, mỗi thứ kèm chữ ký, cộng hai khóa công khai, các mốc thời gian, giới hạn và kết quả.
Dấu vân tay
Dấu vân tay là SHA-256 của hồ sơ, đúng như được viết. Thay một ký tự trong hồ sơ là dấu vân tay không còn khớp.
Niêm phong
Dấu vân tay được đưa vào gốc Proof of Mind hằng giờ mà công chứng viên của SI MIND ghi lên Solana. Cho đến khi biên nhận được niêm phong, trang của nó cho biết đang chờ.
Mã mẫu
Cả hai tệp chạy được nguyên trạng và đã được kiểm tra với máy chủ này. Đặt mã dừng và khởi động của bạn vào chỗ các chú thích chỉ ra.
JavaScript · Node 20 trở lên, không phụ thuộc
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 trở lên, kèm gói cryptography
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))Sandbox từ dòng lệnh
Tác tử sandbox nhận bất kỳ khóa công khai Ed25519 nào. Bài kiểm tra sandbox tuân theo mọi quy tắc trên và không vào bảng.
# 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>"}'Giới hạn của bài kiểm tra
Giao thức chỉ kiểm tra một điều và nói rõ điều đó.
Đạt chứng minh điều gì
Đạt không chứng minh điều gì
Phiên bản
1.0 · · Phiên bản công khai đầu tiên.
Một thay đổi làm hỏng tác tử đang chạy sẽ có số phiên bản mới, và phiên bản 1.0 vẫn được duy trì khi còn tác tử dùng nó. Đặc tả được tự do sao chép và sử dụng theo CC BY 4.0.
Kiểm tra Công tắc Ngắt
Nhận một Agent Passport, đạt trong sandbox, rồi bắt đầu một bài kiểm tra công khai và nhận biên nhận.