agents-city 0.4.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/README.es.md +240 -11
- package/README.md +238 -11
- package/benchmarks/latency/fake-claude-cli.mjs +2 -1
- package/benchmarks/reception/README.md +16 -0
- package/benchmarks/reception/run.mjs +84 -0
- package/bin/agents-city.js +1 -0
- package/bin/connect +5 -0
- package/bin/hall.html +117 -18
- package/bin/navegador.mjs +170 -1
- package/bin/serve.py +201 -101
- package/bin/test +15 -3
- package/bin/test-arnes.py +192 -0
- package/bin/test-cage.py +9 -0
- package/bin/test-channel.py +178 -12
- package/bin/test-claude-runtime.py +132 -4
- package/bin/test-connect-client.mjs +609 -0
- package/bin/test-connect.py +52 -0
- package/bin/test-contracts.py +214 -0
- package/bin/test-diario.py +185 -0
- package/bin/test-doctor.py +31 -0
- package/bin/test-i18n.py +189 -0
- package/bin/test-navegador.py +61 -0
- package/bin/test-seat.py +78 -20
- package/bin/test-security.py +2 -0
- package/bin/test-serve.py +366 -0
- package/city/web/dist-hall/hall.js +789 -214
- package/city/web/src/bienvenida.ts +14 -13
- package/city/web/src/casa.ts +143 -56
- package/city/web/src/demo.ts +61 -31
- package/city/web/src/es.ts +187 -27
- package/city/web/src/explorador.ts +70 -43
- package/city/web/src/hall.ts +520 -103
- package/city/web/src/idioma.ts +21 -1
- package/city/web/src/motores.ts +48 -1
- package/city/web/src/vista.ts +58 -0
- package/demo/graba.py +5 -10
- package/docs/managed-connect.md +237 -0
- package/docs/security.md +41 -2
- package/package.json +8 -4
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/channel/adapter-prompts.ts +10 -0
- package/plugin/channel/adapter.js +78 -31
- package/plugin/channel/agents_city_hybrid_crypto_bg.wasm +0 -0
- package/plugin/channel/bus.js +109 -65
- package/plugin/channel/bus.ts +11 -1
- package/plugin/channel/client.js +67 -30
- package/plugin/channel/delivery-queue.ts +160 -21
- package/plugin/channel/hub/remote-roads.ts +32 -1
- package/plugin/channel/hub/road-controller.ts +116 -16
- package/plugin/channel/kinsh_vodozemac_wasm_bg.wasm +0 -0
- package/plugin/channel/licenses/CONNECT_CLIENT_THIRD_PARTY_NOTICES.md +21 -0
- package/plugin/channel/licenses/HYBRID_CRYPTO_THIRD_PARTY_NOTICES.md +12 -0
- package/plugin/channel/licenses/hybrid-crypto-Apache-2.0.txt +201 -0
- package/plugin/channel/licenses/keyring-MIT.txt +21 -0
- package/plugin/channel/licenses/vodozemac-Apache-2.0.txt +201 -0
- package/plugin/channel/local-hub.js +2080 -97
- package/plugin/channel/local-hub.ts +5 -4
- package/plugin/channel/managed-connect/bridge.ts +208 -0
- package/plugin/channel/managed-connect/cli.ts +416 -0
- package/plugin/channel/managed-connect/device.ts +15 -0
- package/plugin/channel/managed-connect/local-cities.ts +94 -0
- package/plugin/channel/managed-connect/person-message.ts +74 -0
- package/plugin/channel/managed-connect/reception-bridge.ts +341 -0
- package/plugin/channel/managed-connect/relay-session.ts +7 -0
- package/plugin/channel/managed-connect/storage.ts +653 -0
- package/plugin/channel/managed-connect/transport.ts +87 -0
- package/plugin/channel/managed-connect-cli.js +4777 -0
- package/plugin/channel/managed-connect-cli.ts +7 -0
- package/plugin/channel/managed-connect-client.d.ts +261 -0
- package/plugin/channel/managed-connect-client.js +6572 -0
- package/plugin/channel/managed-connect-client.manifest.json +38 -0
- package/plugin/channel/package-lock.json +123 -105
- package/plugin/channel/package.json +4 -4
- package/plugin/channel/protocol.ts +4 -0
- package/plugin/channel/reception.ts +896 -0
- package/plugin/channel/road-cli.ts +1 -1
- package/plugin/channel/runtime/arnes.json +189 -0
- package/plugin/channel/runtime/arnes.ts +47 -0
- package/plugin/channel/runtime/claude.ts +18 -0
- package/plugin/channel/runtime/codex-config.ts +51 -1
- package/plugin/channel/runtime/codex.ts +31 -11
- package/plugin/channel/runtime/kimi.ts +6 -4
- package/plugin/channel/runtime-files.ts +39 -5
- package/plugin/channel/runtime-gateway.js +426 -100
- package/plugin/channel/runtime-gateway.ts +12 -0
- package/plugin/channel/trust/agents-city-sandbox-roots.json +66 -0
- package/plugin/scripts/arnes.py +271 -0
- package/plugin/scripts/busca.py +46 -10
- package/plugin/scripts/cage.py +5 -0
- package/plugin/scripts/city-session.sh +144 -28
- package/plugin/scripts/crecimiento.py +4 -1
- package/plugin/scripts/demos.py +58 -43
- package/plugin/scripts/desinstala.py +36 -21
- package/plugin/scripts/diario.py +119 -0
- package/plugin/scripts/doctor.py +90 -15
- package/plugin/scripts/read-card.py +48 -8
- package/plugin/scripts/reception.py +665 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import WebSocket, { type RawData } from 'ws';
|
|
2
|
+
import {
|
|
3
|
+
ManagedRelaySession,
|
|
4
|
+
initializeHybridCrypto,
|
|
5
|
+
signedRelayHeaders,
|
|
6
|
+
type DeviceIdentity,
|
|
7
|
+
type RelaySessionOptions,
|
|
8
|
+
type RelayTransport,
|
|
9
|
+
} from '../managed-connect-client.js';
|
|
10
|
+
|
|
11
|
+
const CITY_ADDRESS_RE = /^[a-z0-9][a-z0-9_-]{0,31}\/[a-z0-9][a-z0-9_-]{0,31}$/;
|
|
12
|
+
const MAX_SERVER_FRAME_BYTES = 262_144;
|
|
13
|
+
|
|
14
|
+
export type OpenManagedSession = {
|
|
15
|
+
session: ManagedRelaySession;
|
|
16
|
+
socket: WebSocket;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export async function openManagedRelaySession(
|
|
20
|
+
identity: DeviceIdentity,
|
|
21
|
+
city: string,
|
|
22
|
+
options: RelaySessionOptions,
|
|
23
|
+
): Promise<OpenManagedSession> {
|
|
24
|
+
if (!CITY_ADDRESS_RE.test(city)) throw new Error('invalid_city_address');
|
|
25
|
+
if (!options.keyTransparency) throw new Error('key_transparency_required');
|
|
26
|
+
await initializeHybridCrypto();
|
|
27
|
+
const headers = await signedRelayHeaders(identity, city);
|
|
28
|
+
const url = new URL(identity.relayUrl);
|
|
29
|
+
const local = ['127.0.0.1', 'localhost', '[::1]', '::1'].includes(url.hostname);
|
|
30
|
+
if (
|
|
31
|
+
(url.protocol !== 'wss:' && !(local && url.protocol === 'ws:')) ||
|
|
32
|
+
url.pathname !== '/v1/connect' ||
|
|
33
|
+
url.username ||
|
|
34
|
+
url.password ||
|
|
35
|
+
url.search ||
|
|
36
|
+
url.hash
|
|
37
|
+
)
|
|
38
|
+
throw new Error('invalid_relay_url');
|
|
39
|
+
url.searchParams.set('city', city);
|
|
40
|
+
const socket = new WebSocket(url, {
|
|
41
|
+
headers,
|
|
42
|
+
handshakeTimeout: 10_000,
|
|
43
|
+
maxPayload: MAX_SERVER_FRAME_BYTES,
|
|
44
|
+
perMessageDeflate: false,
|
|
45
|
+
followRedirects: false,
|
|
46
|
+
});
|
|
47
|
+
socket.on('error', () => {});
|
|
48
|
+
const transport: RelayTransport = {
|
|
49
|
+
send: (raw) => {
|
|
50
|
+
if (socket.readyState !== WebSocket.OPEN) throw new Error('relay_connection_closed');
|
|
51
|
+
socket.send(raw);
|
|
52
|
+
},
|
|
53
|
+
close: (code, reason) => socket.close(code, reason),
|
|
54
|
+
onMessage: (handler) => {
|
|
55
|
+
socket.on('message', (raw: RawData, isBinary: boolean) => {
|
|
56
|
+
handler(isBinary ? '' : String(raw));
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
onClose: (handler) => {
|
|
60
|
+
socket.on('close', handler);
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
const session = new ManagedRelaySession(identity, city, transport, {
|
|
64
|
+
...options,
|
|
65
|
+
sealedSender: options.sealedSender ?? {},
|
|
66
|
+
});
|
|
67
|
+
try {
|
|
68
|
+
await new Promise<void>((resolve, reject) => {
|
|
69
|
+
const timer = setTimeout(() => reject(new Error('relay_connection_timeout')), 10_000);
|
|
70
|
+
socket.once('open', () => {
|
|
71
|
+
clearTimeout(timer);
|
|
72
|
+
resolve();
|
|
73
|
+
});
|
|
74
|
+
socket.once('error', () => {
|
|
75
|
+
clearTimeout(timer);
|
|
76
|
+
reject(new Error('relay_connection_failed'));
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
await session.ready();
|
|
80
|
+
return { session, socket };
|
|
81
|
+
} catch (error) {
|
|
82
|
+
try {
|
|
83
|
+
socket.close(1000, 'connection failed');
|
|
84
|
+
} catch {}
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
}
|