super-dsh 0.1.6 → 0.1.10-e
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/README.md +25 -3
- package/agent-agy/cordis.patch.yml +7 -4
- package/agent-agy/dist/agent.d.ts +12 -11
- package/agent-agy/dist/agy-auth-gateway.d.ts +124 -0
- package/agent-agy/dist/agy-auth-gateway.js +233 -0
- package/agent-agy/dist/agy-auth.d.ts +153 -0
- package/agent-agy/dist/agy-auth.js +179 -0
- package/agent-agy/dist/agy-cli-client.d.ts +39 -9
- package/agent-agy/dist/agy-cli-client.js +82 -18
- package/agent-agy/dist/agy-store.d.ts +8 -0
- package/agent-agy/dist/index.d.ts +46 -16
- package/agent-agy/dist/index.js +82 -56
- package/agent-agy/dist/models.d.ts +70 -0
- package/agent-agy/dist/models.js +102 -3
- package/agent-agy/package.json +7 -5
- package/agent-agy-sdk/cordis.patch.yml +58 -0
- package/agent-agy-sdk/dist/adapter.d.ts +15 -0
- package/agent-agy-sdk/dist/adapter.js +42 -0
- package/agent-agy-sdk/dist/agent-preset-agy.d.ts +27 -0
- package/agent-agy-sdk/dist/agent-preset-agy.js +32 -0
- package/agent-agy-sdk/dist/agent.d.ts +138 -0
- package/agent-agy-sdk/dist/agent.js +494 -0
- package/{agent-agy → agent-agy-sdk}/dist/agy-client.d.ts +26 -6
- package/{agent-agy → agent-agy-sdk}/dist/agy-client.js +43 -25
- package/agent-agy-sdk/dist/agy-sessions.d.ts +25 -0
- package/agent-agy-sdk/dist/agy-sessions.js +107 -0
- package/agent-agy-sdk/dist/agy-store.d.ts +39 -0
- package/agent-agy-sdk/dist/agy-store.js +83 -0
- package/agent-agy-sdk/dist/inbox.d.ts +26 -0
- package/agent-agy-sdk/dist/inbox.js +53 -0
- package/agent-agy-sdk/dist/index.d.ts +93 -0
- package/agent-agy-sdk/dist/index.js +476 -0
- package/agent-agy-sdk/dist/models.d.ts +41 -0
- package/agent-agy-sdk/dist/models.js +74 -0
- package/agent-agy-sdk/dist/sdk-venv.d.ts +76 -0
- package/agent-agy-sdk/dist/sdk-venv.js +173 -0
- package/agent-agy-sdk/dist/world-plugin.d.ts +10 -0
- package/agent-agy-sdk/dist/world-plugin.js +82 -0
- package/agent-agy-sdk/package.json +64 -0
- package/agent-claude/dist/adapter.js +106 -31
- package/agent-claude/dist/agent.js +154 -17
- package/agent-claude/dist/claude-client.js +84 -43
- package/agent-claude/dist/claude-launch.js +101 -0
- package/agent-claude/dist/claude-native-config.js +169 -0
- package/agent-claude/dist/claude-provider-gateway.js +340 -0
- package/agent-claude/dist/claude-providers.js +391 -0
- package/agent-claude/dist/claude-route.js +152 -0
- package/agent-claude/dist/index.js +214 -37
- package/agent-claude/dist/models.js +14 -0
- package/agent-claude/dist/sdk-runtime.js +320 -0
- package/agent-claude/package.json +6 -4
- package/agent-codex/README.md +141 -36
- package/agent-codex/cordis.patch.yml +14 -10
- package/agent-codex/dist/adapter.js +64 -28
- package/agent-codex/dist/agent.js +255 -81
- package/agent-codex/dist/app-server-approvals.js +165 -0
- package/agent-codex/dist/app-server-client.js +723 -0
- package/agent-codex/dist/app-server-events.js +432 -0
- package/agent-codex/dist/app-server-protocol.js +95 -0
- package/agent-codex/dist/app-server-wire.js +299 -0
- package/agent-codex/dist/codex-launch.js +78 -0
- package/agent-codex/dist/codex-native-config.js +392 -0
- package/agent-codex/dist/codex-provider-gateway.js +402 -0
- package/agent-codex/dist/codex-providers.js +376 -0
- package/agent-codex/dist/codex-route.js +86 -0
- package/agent-codex/dist/index.js +256 -115
- package/agent-codex/dist/permission.js +75 -1
- package/agent-codex/package.json +1 -2
- package/agent-codex-sdk/README.md +79 -0
- package/agent-codex-sdk/cordis.patch.yml +81 -0
- package/agent-codex-sdk/dist/adapter.js +91 -0
- package/agent-codex-sdk/dist/agent-preset-codex.js +32 -0
- package/agent-codex-sdk/dist/agent.js +1085 -0
- package/agent-codex-sdk/dist/codex-native-config.js +392 -0
- package/agent-codex-sdk/dist/codex-provider-gateway.js +402 -0
- package/agent-codex-sdk/dist/codex-providers.js +376 -0
- package/agent-codex-sdk/dist/codex-route.js +86 -0
- package/{agent-codex/dist/codex-client.js → agent-codex-sdk/dist/codex-sdk-client.js} +253 -32
- package/agent-codex-sdk/dist/codex-sdk-launch.js +92 -0
- package/agent-codex-sdk/dist/codex-store.js +180 -0
- package/agent-codex-sdk/dist/inbox.js +53 -0
- package/agent-codex-sdk/dist/index.js +739 -0
- package/agent-codex-sdk/dist/permission.js +71 -0
- package/agent-codex-sdk/dist/sdk-runtime.js +307 -0
- package/agent-codex-sdk/dist/session-map.js +167 -0
- package/agent-codex-sdk/dist/world-plugin.js +93 -0
- package/agent-codex-sdk/package.json +79 -0
- package/agent-codex-sdk/scripts/fetch-sdk-runtime.mjs +57 -0
- package/agent-omp/README.md +72 -55
- package/agent-omp/dist/agent.js +36 -11
- package/agent-omp/dist/index.js +92 -52
- package/agent-omp/dist/lazy-rpc.js +11 -4
- package/agent-omp/dist/omp-cli.js +114 -97
- package/agent-omp/dist/omp-store.js +12 -4
- package/agent-omp/dist/permission.js +70 -5
- package/agent-omp/dist/rpc-client.js +409 -0
- package/agent-omp/dist/world-plugin.js +36 -3
- package/agent-omp/package.json +2 -6
- package/agent-omp-sdk/README.md +103 -0
- package/agent-omp-sdk/cordis.patch.yml +108 -0
- package/agent-omp-sdk/dist/adapter.d.ts +21 -0
- package/agent-omp-sdk/dist/adapter.js +36 -0
- package/agent-omp-sdk/dist/agent-preset-omp.d.ts +31 -0
- package/agent-omp-sdk/dist/agent-preset-omp.js +32 -0
- package/agent-omp-sdk/dist/agent.d.ts +64 -0
- package/agent-omp-sdk/dist/agent.js +1178 -0
- package/agent-omp-sdk/dist/discovery.d.ts +57 -0
- package/agent-omp-sdk/dist/discovery.js +116 -0
- package/agent-omp-sdk/dist/inbox.d.ts +28 -0
- package/agent-omp-sdk/dist/inbox.js +53 -0
- package/agent-omp-sdk/dist/index.d.ts +60 -0
- package/agent-omp-sdk/dist/index.js +632 -0
- package/agent-omp-sdk/dist/knobs.d.ts +34 -0
- package/agent-omp-sdk/dist/knobs.js +50 -0
- package/agent-omp-sdk/dist/lazy-rpc.d.ts +98 -0
- package/agent-omp-sdk/dist/lazy-rpc.js +178 -0
- package/agent-omp-sdk/dist/mobile/zoom-guard.d.ts +187 -0
- package/agent-omp-sdk/dist/mobile/zoom-guard.js +294 -0
- package/agent-omp-sdk/dist/mobile-boot.d.ts +49 -0
- package/agent-omp-sdk/dist/mobile-boot.js +38 -0
- package/agent-omp-sdk/dist/models.d.ts +39 -0
- package/agent-omp-sdk/dist/models.js +299 -0
- package/agent-omp-sdk/dist/omp-cli.d.ts +67 -0
- package/agent-omp-sdk/dist/omp-cli.js +164 -0
- package/agent-omp-sdk/dist/omp-disk-discovery.d.ts +27 -0
- package/agent-omp-sdk/dist/omp-disk-discovery.js +178 -0
- package/agent-omp-sdk/dist/omp-executable.d.ts +2 -0
- package/agent-omp-sdk/dist/omp-executable.js +30 -0
- package/agent-omp-sdk/dist/omp-store.d.ts +134 -0
- package/agent-omp-sdk/dist/omp-store.js +526 -0
- package/agent-omp-sdk/dist/pairing.d.ts +7 -0
- package/agent-omp-sdk/dist/pairing.js +45 -0
- package/agent-omp-sdk/dist/permission.d.ts +138 -0
- package/agent-omp-sdk/dist/permission.js +161 -0
- package/agent-omp-sdk/dist/protocol.d.ts +189 -0
- package/agent-omp-sdk/dist/rpc-types.d.ts +77 -0
- package/agent-omp-sdk/dist/rpc-types.js +1 -0
- package/agent-omp-sdk/dist/sdk-client.d.ts +160 -0
- package/{agent-omp → agent-omp-sdk}/dist/sdk-client.js +108 -56
- package/agent-omp-sdk/dist/sdk-runtime.d.ts +211 -0
- package/agent-omp-sdk/dist/sdk-runtime.js +418 -0
- package/agent-omp-sdk/dist/sidecar-client.d.ts +87 -0
- package/agent-omp-sdk/dist/sidecar-client.js +197 -0
- package/agent-omp-sdk/dist/store/adapter.d.ts +17 -0
- package/agent-omp-sdk/dist/store/adapter.js +47 -0
- package/agent-omp-sdk/dist/store/db.d.ts +70 -0
- package/agent-omp-sdk/dist/store/db.js +210 -0
- package/agent-omp-sdk/dist/store/index.d.ts +23 -0
- package/agent-omp-sdk/dist/store/index.js +59 -0
- package/agent-omp-sdk/dist/store/reconcile.d.ts +15 -0
- package/agent-omp-sdk/dist/store/reconcile.js +51 -0
- package/agent-omp-sdk/dist/store/schema.d.ts +8 -0
- package/agent-omp-sdk/dist/store/schema.js +40 -0
- package/agent-omp-sdk/dist/transport.d.ts +49 -0
- package/agent-omp-sdk/dist/transport.js +35 -0
- package/agent-omp-sdk/dist/world-home.d.ts +4 -0
- package/agent-omp-sdk/dist/world-home.js +23 -0
- package/agent-omp-sdk/dist/world-plugin.d.ts +10 -0
- package/agent-omp-sdk/dist/world-plugin.js +137 -0
- package/agent-omp-sdk/package.json +87 -0
- package/client/index.js +1883 -287
- package/cordis.patch.yml +80 -0
- package/package.json +23 -9
- package/superd-hub/dist/a2a-delivery.d.ts +189 -0
- package/superd-hub/dist/a2a-delivery.js +240 -0
- package/superd-hub/dist/a2a-host.d.ts +76 -0
- package/superd-hub/dist/a2a-host.js +145 -0
- package/superd-hub/dist/a2a-ingest.d.ts +31 -0
- package/superd-hub/dist/a2a-ingest.js +636 -0
- package/superd-hub/dist/a2a-log.d.ts +17 -0
- package/superd-hub/dist/a2a-log.js +42 -0
- package/superd-hub/dist/a2a-row.d.ts +65 -0
- package/superd-hub/dist/a2a-row.js +162 -0
- package/superd-hub/dist/a2a-service.d.ts +357 -0
- package/superd-hub/dist/a2a-service.js +980 -0
- package/superd-hub/dist/a2a-wire.d.ts +220 -0
- package/superd-hub/dist/a2a-wire.js +305 -0
- package/superd-hub/dist/agent-ids.d.ts +10 -0
- package/superd-hub/dist/agent-ids.js +68 -0
- package/superd-hub/dist/agent-roster.d.ts +29 -18
- package/superd-hub/dist/agent-roster.js +54 -15
- package/superd-hub/dist/agent-status.d.ts +119 -0
- package/superd-hub/dist/agent-status.js +386 -0
- package/superd-hub/dist/client/agent-settings.d.ts +210 -0
- package/superd-hub/dist/client/agent-settings.js +300 -0
- package/superd-hub/dist/client/mesh-api.d.ts +134 -0
- package/superd-hub/dist/client/mesh-api.js +219 -0
- package/superd-hub/dist/client/mesh-groups.d.ts +63 -0
- package/superd-hub/dist/client/mesh-groups.js +66 -0
- package/superd-hub/dist/client/roster.d.ts +48 -0
- package/superd-hub/dist/client/roster.js +102 -0
- package/superd-hub/dist/client/runtime-settings-api.d.ts +76 -0
- package/superd-hub/dist/client/runtime-settings-api.js +137 -0
- package/superd-hub/dist/client/switch.d.ts +165 -0
- package/superd-hub/dist/client/switch.js +295 -0
- package/superd-hub/dist/exec-pty-channel.d.ts +58 -0
- package/superd-hub/dist/exec-pty-channel.js +162 -0
- package/superd-hub/dist/exec-pty-framing.d.ts +32 -0
- package/superd-hub/dist/exec-pty-framing.js +81 -0
- package/superd-hub/dist/exec-pty-rpc.d.ts +21 -0
- package/superd-hub/dist/exec-pty-rpc.js +128 -0
- package/superd-hub/dist/exec-pty-session.d.ts +76 -0
- package/superd-hub/dist/exec-pty-session.js +234 -0
- package/superd-hub/dist/exec.d.ts +56 -0
- package/superd-hub/dist/exec.js +225 -0
- package/superd-hub/dist/gateway.d.ts +39 -2
- package/superd-hub/dist/gateway.js +62 -3
- package/superd-hub/dist/hub-tool.d.ts +174 -0
- package/superd-hub/dist/hub-tool.js +464 -0
- package/superd-hub/dist/index.d.ts +15 -1
- package/superd-hub/dist/index.js +16 -0
- package/superd-hub/dist/machines.d.ts +45 -0
- package/superd-hub/dist/machines.js +125 -0
- package/superd-hub/dist/mesh-federate.d.ts +138 -0
- package/superd-hub/dist/mesh-federate.js +223 -0
- package/superd-hub/dist/mesh-gateway.d.ts +67 -0
- package/superd-hub/dist/mesh-gateway.js +408 -0
- package/superd-hub/dist/mesh-link.d.ts +274 -0
- package/superd-hub/dist/mesh-link.js +441 -0
- package/superd-hub/dist/mesh-rpc.d.ts +123 -0
- package/superd-hub/dist/mesh-rpc.js +250 -0
- package/superd-hub/dist/mux-client.d.ts +71 -0
- package/superd-hub/dist/mux-client.js +281 -0
- package/superd-hub/dist/pack-version.d.ts +2 -0
- package/superd-hub/dist/pack-version.js +30 -0
- package/superd-hub/dist/roster.d.ts +6 -0
- package/superd-hub/dist/rpc.d.ts +18 -2
- package/superd-hub/dist/rpc.js +34 -4
- package/superd-hub/dist/spawn-world.js +3 -1
- package/superd-hub/dist/switch-core.d.ts +62 -25
- package/superd-hub/dist/switch-core.js +53 -30
- package/superd-hub/dist/system-head.d.ts +22 -12
- package/superd-hub/dist/system-head.js +100 -84
- package/superd-hub/dist/wire-endpoints.d.ts +264 -0
- package/superd-hub/dist/wire-endpoints.js +180 -0
- package/superd-hub/lib/client/index.js +1883 -287
- package/superd-hub/package.json +11 -2
- package/agent-agy/dist/agent-preset-projection.d.ts +0 -31
- package/agent-agy/dist/agent-preset-projection.js +0 -33
- package/agent-claude/dist/agent-preset-projection.js +0 -30
- package/agent-codex/dist/agent-preset-projection.js +0 -37
- package/agent-codex/dist/app-home.js +0 -65
- package/agent-codex/dist/models.js +0 -152
- package/agent-codex/dist/spike.js +0 -46
- package/agent-hermes/dist/agent-preset-projection.js +0 -34
- package/agent-omp/dist/agent-preset-projection.js +0 -36
- package/agent-omp/dist/app-home.js +0 -86
- package/agent-omp/dist/sidecar-client.js +0 -195
- package/agent-pi/dist/agent-preset-projection.js +0 -29
- package/superd-hub/dist/client-shim.d.ts +0 -28
- package/superd-hub/dist/client-shim.js +0 -251
- package/superd-hub/dist/index-pass.d.ts +0 -22
- package/superd-hub/dist/index-pass.js +0 -47
- package/superd-hub/dist/labels.d.ts +0 -45
- package/superd-hub/dist/labels.js +0 -83
- /package/{agent-agy → agent-agy-sdk}/bridge/agy_bridge.py +0 -0
- /package/{agent-agy → agent-agy-sdk}/bridge/gemini_openai_server.mjs +0 -0
- /package/{agent-codex/dist/codex-events.js → agent-codex-sdk/dist/codex-sdk-events.js} +0 -0
- /package/{agent-omp → agent-omp-sdk}/dist/protocol.js +0 -0
- /package/{agent-omp → agent-omp-sdk}/sidecar/main.ts +0 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mesh link (mesh P1, spec §4/§6.3): remote connection management —
|
|
3
|
+
* token-URL parsing, cookie mint, roster probe, and the pairing /
|
|
4
|
+
* reprobe orchestration that adopts the remote machine id (D4) into
|
|
5
|
+
* the machine registry from `./machines.js`.
|
|
6
|
+
*
|
|
7
|
+
* Pure module — no cordis dependencies. Outbound calls use the global
|
|
8
|
+
* fetch (injectable via `fetchImpl` / `deps.fetchImpl` for tests) with
|
|
9
|
+
* a 10s AbortSignal timeout. The minted cookie is persisted on the machine
|
|
10
|
+
* row (`MachineRow.cookie`, D1 sensitivity, §3.3/§4) so hub restarts keep the
|
|
11
|
+
* remote's 30-day session; an in-process jar fronts the row as a write-through
|
|
12
|
+
* cache of the same value. Probe outcomes land
|
|
13
|
+
* in the module-level status table exported read-only via
|
|
14
|
+
* `machineStatus()` (mesh API consumes; `resetMachineStatus()` is the
|
|
15
|
+
* test hook). P1 was probe-on-demand only; the mesh P3 Task 5a user
|
|
16
|
+
* mandate ("状态更新走单向 API + 5 分钟周期轮询") adds the PERIODIC sweep
|
|
17
|
+
* (`startReprobeSweep`) — a timer-discipline layer over the same
|
|
18
|
+
* `reprobeMachine`, never a second probing path. I2 also lands here: every
|
|
19
|
+
* successful probe compares the peer's `hub.version` against ours and
|
|
20
|
+
* records a `versionWarning` on the status entry (diff major/minor or
|
|
21
|
+
* unparsable → warn; patch-only drift → clean).
|
|
22
|
+
*/
|
|
23
|
+
import { type MachineRow, loadMachines, saveMachines } from './machines.js';
|
|
24
|
+
/** One roster agent as seen through a successful probe (§6.2 additive fields). */
|
|
25
|
+
export interface ProbeAgent {
|
|
26
|
+
id: string;
|
|
27
|
+
key: string;
|
|
28
|
+
label: string;
|
|
29
|
+
ready: boolean;
|
|
30
|
+
failed: boolean;
|
|
31
|
+
/** Row machine as the peer reported it: `'local'` = self-hosted on the responder; an m4 = a THIRD-party machine the responder federated — never adopted (self-description discipline, 2026-09-28 user ruling). */
|
|
32
|
+
machine: string;
|
|
33
|
+
}
|
|
34
|
+
/** Roster probe outcome: 200+hub → ok with adopted machineId; 401 → auth-expired; network/peer-shape errors → unreachable. */
|
|
35
|
+
export type ProbeResult = {
|
|
36
|
+
ok: true;
|
|
37
|
+
machineId: string;
|
|
38
|
+
version?: string;
|
|
39
|
+
agents: ProbeAgent[];
|
|
40
|
+
} | {
|
|
41
|
+
ok: false;
|
|
42
|
+
status: 'unreachable' | 'auth-expired';
|
|
43
|
+
error: string;
|
|
44
|
+
};
|
|
45
|
+
/** Result of a full pairing: the adopted id, the persisted row, and the probe that vouched for it. */
|
|
46
|
+
export interface PairOutcome {
|
|
47
|
+
machineId: string;
|
|
48
|
+
row: MachineRow;
|
|
49
|
+
probe: ProbeResult;
|
|
50
|
+
}
|
|
51
|
+
/** Test injection seam: fetch + registry load/save overrides. */
|
|
52
|
+
export interface LinkDeps {
|
|
53
|
+
fetchImpl?: typeof fetch;
|
|
54
|
+
load?: typeof loadMachines;
|
|
55
|
+
save?: typeof saveMachines;
|
|
56
|
+
}
|
|
57
|
+
/** Machine health entry in the module-level status table. */
|
|
58
|
+
export interface MachineStatusEntry {
|
|
59
|
+
status: string;
|
|
60
|
+
lastProbeAt: number;
|
|
61
|
+
error?: string;
|
|
62
|
+
/** I2 version-mismatch warning (mesh P3 Task 5a): present when the peer's
|
|
63
|
+
* superd version differs from ours by more than patch, or is
|
|
64
|
+
* unparsable/absent — recomputed on every successful probe, so a peer
|
|
65
|
+
* converging back onto our major/minor clears it on the next probe. */
|
|
66
|
+
versionWarning?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The `ours` side of the I2 comparison — the super-dsh PACK version (D6: the
|
|
70
|
+
* hub subpackage's constant 0.1.0 made the comparator dead; the pack number
|
|
71
|
+
* is what `dsh plugin add` versions and the only one that moves). Exported so
|
|
72
|
+
* tests can pin the comparator's production input to the real pack manifest.
|
|
73
|
+
*/
|
|
74
|
+
export declare const OWN_VERSION: string;
|
|
75
|
+
/**
|
|
76
|
+
* The I2 comparator: when to warn about a peer's superd version.
|
|
77
|
+
* - different major OR minor → a warning naming both versions;
|
|
78
|
+
* - same major+minor (patch-only drift) → `undefined` (clean);
|
|
79
|
+
* - unparsable or missing on EITHER side → a warning carrying 'unknown'
|
|
80
|
+
* (an unreadable peer version is itself a compatibility fact).
|
|
81
|
+
* Pure and exported for direct unit testing; the pair/reprobe paths feed it
|
|
82
|
+
* `probe.version` and the module's {@link OWN_VERSION}.
|
|
83
|
+
*/
|
|
84
|
+
export declare function versionWarningFor(peer: string | undefined, ours: string): string | undefined;
|
|
85
|
+
/** Validate a pasted token URL: absolute http(s) origin + non-empty `?token=`.
|
|
86
|
+
* Error copy never echoes the raw input — a typo'd paste may still carry a live
|
|
87
|
+
* token, so messages carry at most the (userinfo-free) origin. */
|
|
88
|
+
export declare function parseTokenUrl(tokenUrl: string): {
|
|
89
|
+
origin: string;
|
|
90
|
+
token: string;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Mint a request cookie from a launch token: `GET <origin>/?token=<t>` with
|
|
94
|
+
* `redirect: 'manual'`, taking the first `dsh-auth-*` name=value pair from
|
|
95
|
+
* Set-Cookie. Non-303/2xx, a missing cookie, or a network failure throws
|
|
96
|
+
* with the status/cause attached.
|
|
97
|
+
*/
|
|
98
|
+
export declare function mintCookie(origin: string, token: string, fetchImpl?: typeof fetch): Promise<string>;
|
|
99
|
+
/**
|
|
100
|
+
* Probe a remote hub's roster: `GET <origin>/api/agent-runtime` with the
|
|
101
|
+
* cookie riding along. 401 → `auth-expired`; network error → `unreachable`;
|
|
102
|
+
* 200 without a `hub.machineId` block is a non-superdsh 0.1.6+ peer →
|
|
103
|
+
* `unreachable` with `peer roster has no hub block`.
|
|
104
|
+
*/
|
|
105
|
+
export declare function probeMachine(origin: string, cookie: string, fetchImpl?: typeof fetch): Promise<ProbeResult>;
|
|
106
|
+
/** Read-only snapshot copy of the status table — callers can hold/mutate it freely. */
|
|
107
|
+
export declare function machineStatus(): Map<string, MachineStatusEntry>;
|
|
108
|
+
/** Test hook: drop all status entries. */
|
|
109
|
+
export declare function resetMachineStatus(): void;
|
|
110
|
+
/**
|
|
111
|
+
* Federation lifecycle event (mesh P2 Task 3) — emitted HERE, at the machine
|
|
112
|
+
* orchestration points, so the federation registrar (mesh-federate.ts) can
|
|
113
|
+
* react WITHOUT mesh-link ever importing it (the import direction is frozen:
|
|
114
|
+
* mesh-federate → mesh-link, never the reverse; the seam is this bus):
|
|
115
|
+
*
|
|
116
|
+
* - `federated` — a probe SUCCEEDED (pairMachine or reprobeMachine): the
|
|
117
|
+
* machine identity (m4 + name), its origin, and the adopted agent list
|
|
118
|
+
* (each row carrying its remote a6 `id`, the remote RUNTIME key `key` —
|
|
119
|
+
* the wire `?agent=` demux key at the peer — label, ready, failed). The
|
|
120
|
+
* consumer converges its registries onto this snapshot and defederates
|
|
121
|
+
* rows whose a6s no longer appear (roster convergence).
|
|
122
|
+
* - `degraded` — a probe FAILED after the machine was already probed at
|
|
123
|
+
* least once (unreachable peer or auth-expired cookie). Degrade semantics:
|
|
124
|
+
* federated rows are KEPT with `ready` flipped false — visible but not
|
|
125
|
+
* servable (orchestra downgrade, never a silent vanish).
|
|
126
|
+
* - `defederated` — the machine row was removed (mesh-rpc DELETE →
|
|
127
|
+
* {@link emitMachineRemoved}); the consumer drops every row of the machine.
|
|
128
|
+
*/
|
|
129
|
+
export type MeshFederationEvent = {
|
|
130
|
+
type: 'federated';
|
|
131
|
+
machineId: string;
|
|
132
|
+
machineName: string;
|
|
133
|
+
origin: string;
|
|
134
|
+
agents: ProbeAgent[];
|
|
135
|
+
} | {
|
|
136
|
+
type: 'degraded';
|
|
137
|
+
machineId: string;
|
|
138
|
+
reason: 'unreachable' | 'auth-expired';
|
|
139
|
+
error: string;
|
|
140
|
+
} | {
|
|
141
|
+
type: 'defederated';
|
|
142
|
+
machineId: string;
|
|
143
|
+
};
|
|
144
|
+
/** Subscribe to federation lifecycle events; returns an unsubscribe function. */
|
|
145
|
+
export declare function onMeshFederationEvent(fn: (event: MeshFederationEvent) => void): () => void;
|
|
146
|
+
/**
|
|
147
|
+
* Announce a machine removal on the federation bus (`{type: 'defederated'}`).
|
|
148
|
+
* Called by mesh-rpc's DELETE path AFTER a successful `removeRemote` — the
|
|
149
|
+
* route module stays free of federation logic (one-way imports: mesh-rpc →
|
|
150
|
+
* mesh-link, the registrar subscribes at wiring time).
|
|
151
|
+
*/
|
|
152
|
+
export declare function emitMachineRemoved(machineId: string): void;
|
|
153
|
+
/**
|
|
154
|
+
* The machine's CURRENT pairing cookie: the in-process jar first (warm after
|
|
155
|
+
* every mint this process — pair and reprobe both write it before any
|
|
156
|
+
* federation event fires), then the persisted `MachineRow.cookie` (only when
|
|
157
|
+
* `home` is given; the defensive cold path for gateways built without a probe
|
|
158
|
+
* in this process), else `''` (wire calls then simply omit the Cookie header).
|
|
159
|
+
*/
|
|
160
|
+
export declare function cookieOf(machineId: string, home?: string): string;
|
|
161
|
+
/**
|
|
162
|
+
* Full pairing: parse the pasted token URL → mint a cookie → probe the roster
|
|
163
|
+
* → adopt the remote machine id (fail-loud on collision with self or an
|
|
164
|
+
* existing remote) → persist the row with the retained token and minted
|
|
165
|
+
* cookie → jar the cookie and mark the machine reachable. A failed mint/probe throws before
|
|
166
|
+
* anything is persisted.
|
|
167
|
+
*/
|
|
168
|
+
export declare function pairMachine(home: string, input: {
|
|
169
|
+
name: string;
|
|
170
|
+
label?: string;
|
|
171
|
+
tokenUrl: string;
|
|
172
|
+
}, deps?: LinkDeps): Promise<PairOutcome>;
|
|
173
|
+
/**
|
|
174
|
+
* Re-probe a paired machine: the jar's cookie, falling back to the cookie
|
|
175
|
+
* persisted on the row (cold jar after a hub restart), rides the probe. On
|
|
176
|
+
* `auth-expired`, if the row retains a token, re-mint once and probe again; a
|
|
177
|
+
* successful re-mint writes the new cookie back into the jar AND the row. Every
|
|
178
|
+
* outcome lands in the status table
|
|
179
|
+
* (`reachable` / `auth-expired` / `unreachable`, the latter two with the error).
|
|
180
|
+
*/
|
|
181
|
+
export declare function reprobeMachine(home: string, id: string, deps?: LinkDeps): Promise<ProbeResult>;
|
|
182
|
+
/** Default sweep period — the user mandate's 5 minutes (5a I1-a). */
|
|
183
|
+
export declare const REPROBE_SWEEP_DEFAULT_SEC = 300;
|
|
184
|
+
/** Floor for any sweep period: below this a reprobe loop is a self-inflicted storm. */
|
|
185
|
+
export declare const REPROBE_SWEEP_MIN_SEC = 60;
|
|
186
|
+
/** Structural interval-timer handle: Node's Timeout (with `unref`), faked in tests. */
|
|
187
|
+
interface SweepTimerHandle {
|
|
188
|
+
unref?(): void;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* R5 SWEEP COLLECTORS — the dual-responsibility legs (outbox pull +
|
|
192
|
+
* session-list collection) ride THIS sweep; there is no second timer and no
|
|
193
|
+
* new probing path. Two injection routes, deps-win: (a) `collectors` on the
|
|
194
|
+
* deps (tests, hermetic); (b) the process-level registry below (the a2a row
|
|
195
|
+
* registers its assembly's legs — the sweep site in gateway.ts stays
|
|
196
|
+
* unchanged). Every collector rejection is swallowed HERE: a leg failure
|
|
197
|
+
* degrades (log, keep sweeping) and never breaks probe accounting.
|
|
198
|
+
*/
|
|
199
|
+
export interface SweepCollectors {
|
|
200
|
+
/** Once per sweep, before the remote loop: collect the LOCAL machine's agents. */
|
|
201
|
+
onLocalCollect?(): Promise<void> | void;
|
|
202
|
+
/** After each SUCCESSFUL reprobe: pull the outbox + collect that machine's session lists. */
|
|
203
|
+
onRemoteProbed?(info: {
|
|
204
|
+
remote: MachineRow;
|
|
205
|
+
probe: ProbeResult;
|
|
206
|
+
}): Promise<void> | void;
|
|
207
|
+
}
|
|
208
|
+
/** Register/unregister the process-level collectors (the a2a row's assembly; set-once semantics, ctx0 only). */
|
|
209
|
+
export declare function setSweepCollectors(collectors: SweepCollectors | undefined): void;
|
|
210
|
+
/** One full sweep — the timer's entire payload. Reads the registry FRESH at
|
|
211
|
+
* start (rows paired/removed since the last tick are honored), probes every
|
|
212
|
+
* ENABLED remote through the real {@link reprobeMachine} (success converges
|
|
213
|
+
* federation via the existing event hook; failure degrades — no second
|
|
214
|
+
* probing path), and swallows every per-machine rejection so one dead peer
|
|
215
|
+
* (or a row deleted mid-sweep → unknown-id throw) never rejects the sweep.
|
|
216
|
+
* Since R5 the collectors run inside the same swallow discipline.
|
|
217
|
+
* `localCollect: false` (O1b, 0.1.8-e) skips ONLY the local leg: the boot tick
|
|
218
|
+
* uses it because the local session plane is not mounted yet the moment the
|
|
219
|
+
* hub's rows come up — sampling there yields an all-error collection that
|
|
220
|
+
* would then read as a fresh, empty window (see `startReprobeSweep`). */
|
|
221
|
+
export declare function runReprobeSweep(deps: {
|
|
222
|
+
home: string;
|
|
223
|
+
fetchImpl?: typeof fetch;
|
|
224
|
+
collectors?: SweepCollectors;
|
|
225
|
+
localCollect?: boolean;
|
|
226
|
+
}): Promise<void>;
|
|
227
|
+
/** Timer-discipline seams: production passes nothing (the platform
|
|
228
|
+
* setInterval/clearInterval); tests inject a fake clock and drive ticks by hand. */
|
|
229
|
+
export interface ReprobeSweepDeps {
|
|
230
|
+
home: string;
|
|
231
|
+
/** Sweep period in seconds; default 300, floored at 60 (config knob: the
|
|
232
|
+
* superd-hub row's `reprobeIntervalSec`, gateway.ts Config). */
|
|
233
|
+
intervalSec?: number;
|
|
234
|
+
fetchImpl?: typeof fetch;
|
|
235
|
+
/** R5: the dual-responsibility legs; defaults to the process-level registry (see setSweepCollectors). */
|
|
236
|
+
collectors?: SweepCollectors;
|
|
237
|
+
/**
|
|
238
|
+
* O1b (0.1.8-e): run the R5 LOCAL collector on this tick (default true).
|
|
239
|
+
* The BOOT tick passes false — the local session plane is not mounted yet
|
|
240
|
+
* when the hub's rows come up, so an early sample is an all-error
|
|
241
|
+
* collection, not a fact. Remotes are untouched (a probe is a direct HTTP
|
|
242
|
+
* call that needs no local plane); the local leg simply waits for the first
|
|
243
|
+
* regular tick.
|
|
244
|
+
*/
|
|
245
|
+
localCollect?: boolean;
|
|
246
|
+
setIntervalFn?: (fn: () => void, ms: number) => SweepTimerHandle;
|
|
247
|
+
clearIntervalFn?: (handle: SweepTimerHandle) => void;
|
|
248
|
+
/**
|
|
249
|
+
* O1 (0.1.8-c): run ONE sweep immediately at startup, then on the interval.
|
|
250
|
+
* Without it the first tick is a full period away, so after a hub restart the
|
|
251
|
+
* roster is empty and `/api/superd/machines` reads "pending" for up to
|
|
252
|
+
* `intervalSec` — even though the peers are reachable (a direct one-shot
|
|
253
|
+
* `exec` proves it). The probe is per-machine and cheap; opt-in so timer
|
|
254
|
+
* tests keep their deterministic tick-only clock.
|
|
255
|
+
* The boot tick runs WITHOUT the local collector (O1b, 0.1.8-e): the local
|
|
256
|
+
* plane is still mounting at that instant, and caching that failure would
|
|
257
|
+
* cost a whole interval of truthful-looking emptiness.
|
|
258
|
+
*/
|
|
259
|
+
immediate?: boolean;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Start the periodic reprobe sweep (I1-a). Discipline, all of it load-bearing:
|
|
263
|
+
* - the interval handle is `unref()`d — a freshness sweep never holds the
|
|
264
|
+
* hub process (or a test runner) open;
|
|
265
|
+
* - a tick while the previous sweep is still in flight is SKIPPED (no
|
|
266
|
+
* overlap: a slow peer slows the cadence, it never stacks sweeps);
|
|
267
|
+
* - the returned disposer clears the timer AND kills any late tick — the
|
|
268
|
+
* hub host wiring registers it as a ctx effect, so the sweep dies with
|
|
269
|
+
* the row (dispose-clean); the disposer is idempotent.
|
|
270
|
+
* The first sweep runs after one full period, except when `immediate` asks
|
|
271
|
+
* for one at boot (the mesh UI's own reprobe stays available too).
|
|
272
|
+
*/
|
|
273
|
+
export declare function startReprobeSweep(deps: ReprobeSweepDeps): () => void;
|
|
274
|
+
export {};
|