@staix/agent-hub 0.36.0 → 0.37.0

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.
Files changed (102) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +6 -2
  3. package/THIRD_PARTY_NOTICES.md +0 -18
  4. package/docs/agent-notes/README.md +13 -3
  5. package/docs/agent-notes/daemon.md +4 -4
  6. package/docs/agent-notes/local-worker.md +1 -0
  7. package/docs/agent-notes/models.md +2 -1
  8. package/docs/agent-notes/tasks.md +1 -1
  9. package/docs/agent-notes/tests.md +1 -2
  10. package/docs/contracts/companion-cli-v1.json +70 -0
  11. package/docs/design/adapters.md +43 -2
  12. package/docs/design/agent-hub-architecture.md +9 -1
  13. package/docs/design/guidance-probes.md +802 -0
  14. package/docs/design/model-routes.md +437 -12
  15. package/docs/dogfood.md +11 -13
  16. package/docs/events.md +20 -1
  17. package/docs/memory.md +3 -3
  18. package/docs/operations.md +112 -148
  19. package/docs/quickstart.md +9 -3
  20. package/docs/research.md +1 -1
  21. package/docs/sdlc.md +5 -3
  22. package/docs/security.md +21 -1
  23. package/docs/specs/2026-09-19-agent-hub-design.md +9 -7
  24. package/docs/specs/2026-10-04-switchyard-source-port-design.md +3 -1
  25. package/docs/verification/2026-11-08-qwen-0269-model-setter-1317.md +25 -11
  26. package/docs/verification/2026-11-09-qwen-0270-model-setter-1317.md +21 -6
  27. package/docs/verification/2026-11-11-0.37.0.md +40 -0
  28. package/docs/verification/2026-11-11-guidance-probe-t2-1226.md +153 -0
  29. package/docs/verification/2026-11-11-qwen-setter-suggestions-off.md +167 -0
  30. package/docs/verified.json +24 -24
  31. package/package.json +3 -4
  32. package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
  33. package/plugins/agent-hub/kimi-hook.js +2373 -1436
  34. package/plugins/agent-hub/server.js +2445 -1497
  35. package/src/adapters/channel-peer.ts +7 -1
  36. package/src/adapters/compat.ts +1 -1
  37. package/src/adapters/local-probe.ts +174 -0
  38. package/src/adapters/local-worker.ts +232 -21
  39. package/src/cli/console-state.ts +25 -6
  40. package/src/cli/console-versions.ts +99 -0
  41. package/src/cli/console.ts +13 -1
  42. package/src/cli/help.ts +2 -1
  43. package/src/cli/install-paths.ts +7 -2
  44. package/src/cli/main.ts +60 -4
  45. package/src/cli/runtime-version-warning.ts +2 -2
  46. package/src/cli/sdlc-output.ts +9 -5
  47. package/src/hub/config-apply.ts +4 -2
  48. package/src/hub/config-trust.ts +6 -1
  49. package/src/hub/control-client.ts +5 -2
  50. package/src/hub/daemon.ts +169 -9
  51. package/src/hub/events.ts +3 -2
  52. package/src/hub/guidance-probe-store.ts +713 -0
  53. package/src/hub/guidance-probes.ts +358 -0
  54. package/src/hub/inference.ts +18 -5
  55. package/src/hub/operational-authority.ts +13 -1
  56. package/src/hub/peers.ts +5 -0
  57. package/src/hub/ports.ts +1 -1
  58. package/src/hub/progress.ts +23 -16
  59. package/src/hub/report.ts +2 -0
  60. package/src/hub/research.ts +1 -0
  61. package/src/hub/restart.ts +7 -0
  62. package/src/hub/sdlc-release-authorization.ts +139 -17
  63. package/src/hub/sdlc-release-policy.ts +100 -0
  64. package/src/hub/sdlc-release.ts +59 -7
  65. package/src/hub/tasks.ts +317 -6
  66. package/src/local/probe-errors.ts +28 -0
  67. package/src/local/probe-sandbox.ts +224 -0
  68. package/src/local/probe-types.ts +108 -0
  69. package/src/local/probe-workspace.ts +237 -0
  70. package/src/local/sandbox.ts +71 -2
  71. package/src/local/tools.ts +135 -9
  72. package/src/models/route/advisor-trigger.ts +88 -0
  73. package/src/models/route/config.ts +21 -17
  74. package/src/models/route/conversation-view.ts +179 -0
  75. package/src/models/route/decision-evidence.ts +1 -1
  76. package/src/models/route/decision.ts +114 -19
  77. package/src/models/route/escalation-control.ts +30 -0
  78. package/src/models/route/hub-prompts.ts +97 -0
  79. package/src/models/route/judge-choice.ts +155 -0
  80. package/src/models/route/judge-replies.ts +102 -0
  81. package/src/models/route/labels.ts +14 -70
  82. package/src/models/route/observation-signals.ts +250 -0
  83. package/src/models/route/plan-execute-choice.ts +27 -0
  84. package/src/models/route/relay-selector.ts +2 -2
  85. package/src/models/route/runtime.ts +115 -52
  86. package/src/models/route/turn-state.ts +77 -0
  87. package/src/omniroute/client.ts +3 -0
  88. package/src/ui/plugin.ts +70 -20
  89. package/src/version.ts +4 -0
  90. package/templates/adec/README.md +32 -0
  91. package/templates/adec/ahub.plan-execute.json +23 -0
  92. package/templates/adec/ahub.stage.json +23 -0
  93. package/LICENSES/Apache-2.0.txt +0 -204
  94. package/src/models/route/advisor.ts +0 -102
  95. package/src/models/route/escalation.ts +0 -82
  96. package/src/models/route/judge.ts +0 -23
  97. package/src/models/route/normalize.ts +0 -103
  98. package/src/models/route/plan-execute.ts +0 -52
  99. package/src/models/route/prompts.ts +0 -8
  100. package/src/models/route/signals.ts +0 -247
  101. package/src/models/route/state.ts +0 -54
  102. package/src/models/route/text.ts +0 -61
@@ -7,7 +7,7 @@ import type { ClaudeChannelEvidence } from "./claude-channel-evidence.ts";
7
7
  /** Only the control socket operations the peer owns; authentication remains in the daemon. */
8
8
  export interface ChannelSocket {
9
9
  readyState: number;
10
- data: { launchId?: string; protocol?: number; standbyId?: string; retainStandby?: boolean; clientPid?: number; channel?: boolean; channelEvidence?: ClaudeChannelEvidence; cwd?: string; peerGeneration?: string | number; detachedByPerson?: boolean };
10
+ data: { launchId?: string; protocol?: number; standbyId?: string; retainStandby?: boolean; clientPid?: number; clientVersion?: string; channel?: boolean; channelEvidence?: ClaudeChannelEvidence; cwd?: string; peerGeneration?: string | number; detachedByPerson?: boolean };
11
11
  send(data: string): unknown;
12
12
  close(code?: number, reason?: string): void;
13
13
  }
@@ -137,6 +137,12 @@ export class WsPeer extends BasePeer {
137
137
  },
138
138
  };
139
139
  }
140
+ /** #1385: whether a client is attached and the agent-hub version its hello reported (validated at hello). Display only. */
141
+ get hubClient(): { attached: boolean; version?: string } {
142
+ const sock = this.sock;
143
+ if (!sock || sock.readyState !== WebSocket.OPEN) return { attached: false };
144
+ return sock.data.clientVersion ? { attached: true, version: sock.data.clientVersion } : { attached: true };
145
+ }
140
146
  /** A hello that has not finished its preface yet. The peer reads as offline until then, and a session standing by
141
147
  * for the id must not take it from a claimant that is still arriving. */
142
148
  get claiming(): boolean {
@@ -64,7 +64,7 @@ export const COMPAT = {
64
64
  receipt: "docs/verification/2026-11-08-agy-1.5.3.md" },
65
65
  qwen: { label: "Qwen Code", verified: ["0.25.0", "0.26.0", "0.26.1", "0.26.4", "0.26.5", "0.26.8", "0.26.9", "0.27.0"], gate: "contract", probe: ["qwen", "--version"], config: "qwen_cmd",
66
66
  parse: out => plain(out.trim()),
67
- trustNote: "Native ACP identity, mode ids and permission callbacks were re-checked without inference on 0.26.4, 0.26.5 and 0.26.8 (macOS arm64 and Linux x86_64); exact 0.26.9 and 0.27.0 repeat those account-free probes on macOS arm64. Real model turns and Linux repetition of those versions remain unverified. The independent 0.27.0 live-setter clear failed and stays unavailable. Another version may change those contracts.",
67
+ trustNote: "Native ACP identity, mode ids and permission callbacks were re-checked without inference on 0.26.4, 0.26.5 and 0.26.8 (macOS arm64 and Linux x86_64); exact 0.26.9 and 0.27.0 repeat those account-free probes on macOS arm64. Real model turns and Linux repetition of those versions remain unverified. The historical A/B/B setter result did not identify the third request's purpose. Exact 0.26.9 and 0.27.0 pass isolated suggestions-off A/B/clear/A probes; production live-setter admission stays unavailable pending a separate decision. Another version may change those contracts.",
68
68
  receipt: "docs/verification/2026-11-09-qwen-0270-acp.md" },
69
69
  // Receipt: docs/verification/2026-11-10-qwen-0271-dual-output.md. The dual-output contract (input file, event file, can_use_tool control requests) is its own entry:
70
70
  // the ACP receipts of the headless `qwen` entry say nothing about it, so that entry is not widened and this one carries no `line`.
@@ -0,0 +1,174 @@
1
+ import { createHash } from "node:crypto";
2
+ import { LocalPeer, localProbeFingerprints, prepareLocalProbeInput } from "./local-worker.ts";
3
+ import { GUIDANCE_PROBE_LIMITS, GUIDANCE_PROBE_MODEL, guidanceProbeCanonical, guidanceProbeManifestKey, probeHash,
4
+ type ProbeFakeLaunch, type ProbeFakeObservation, type ProbeReservation, type ProbeResourceCharges, type ProbeSlot, type ProbeStoredState } from "../hub/guidance-probes.ts";
5
+ import { materializeProbeWorkspace, probeWorkspaceCurrent, PROBE_WORKSPACE_LIMITS,
6
+ type ProbeWorkspace } from "../local/probe-workspace.ts";
7
+ import { ProbeConfinementError, requireProbeConfinement, verifyProbeConfinement, type ProbeConfinement } from "../local/probe-sandbox.ts";
8
+ import { ProbeLocalError, probeLocalEffect, type ProbeLocalAdapter, type ProbeLocalAdapterOptions, type ProbeLocalEffectScope,
9
+ type ProbeLocalSource, type ProbePreparedLocalInput } from "../local/probe-types.ts";
10
+
11
+ interface Prepared {
12
+ state: ProbeStoredState;
13
+ slot: ProbeSlot;
14
+ guidance: string;
15
+ source: ProbeLocalSource;
16
+ input: ProbePreparedLocalInput;
17
+ }
18
+ interface Owned {
19
+ reservation: ProbeReservation;
20
+ controller: AbortController;
21
+ promise?: Promise<ProbeFakeObservation>;
22
+ peer?: LocalPeer;
23
+ workspace?: ProbeWorkspace;
24
+ confinement?: ProbeConfinement;
25
+ closeUnknown?: () => Promise<void>;
26
+ closed: boolean;
27
+ closeFailed?: boolean;
28
+ }
29
+ const bytesHash = (bytes: Uint8Array) => createHash("sha256").update(bytes).digest("hex");
30
+ const reservationKey = (reservation: ProbeReservation) => probeHash(guidanceProbeCanonical(reservation));
31
+ const positiveCharge = (charges: ProbeResourceCharges) => Object.values(charges).some(value => typeof value === "number" && value > 0);
32
+ function freeze<T>(value: T): T {
33
+ if (value && typeof value === "object") { for (const child of Object.values(value)) freeze(child); Object.freeze(value); }
34
+ return value;
35
+ }
36
+
37
+ /** Constructor-only host adapter. No runtime, configuration or wire path selects this factory. */
38
+ export function createGuidanceProbeLocalAdapter(options: ProbeLocalAdapterOptions): ProbeLocalAdapter {
39
+ if (options.fixture && options.fixture.evidence !== "fixture_only") throw new ProbeLocalError("invalid");
40
+ const current = options.current.bind(options), resolveInput = options.resolveInput.bind(options), permit = options.permit.bind(options), omni = options.omni;
41
+ const workspaceOwned = options.workspaceOwned?.bind(options);
42
+ const fixture = options.fixture && Object.freeze({ materialize: options.fixture.materialize.bind(options.fixture), confine: options.fixture.confine.bind(options.fixture) });
43
+ const config = Object.freeze({ maxSteps: options.config.maxSteps, maxOutputTokens: options.config.maxOutputTokens,
44
+ ...(options.config.tokenUpperBound === undefined ? {} : { tokenUpperBound: options.config.tokenUpperBound }) });
45
+ const prepared = new Map<string, Prepared>(), owned = new Map<string, Owned>(), completed = new WeakSet<ProbeReservation>();
46
+ const prepare = async (state: ProbeStoredState, slot: ProbeSlot, guidance: string): Promise<Prepared> => {
47
+ current();
48
+ state = freeze(JSON.parse(JSON.stringify(state)) as ProbeStoredState);
49
+ slot = freeze({ ...slot });
50
+ const resolved = await resolveInput(state, slot); current();
51
+ const source: ProbeLocalSource = { files: resolved.files.map(file => ({ dataId: file.dataId, relative: file.relative, sha256: file.sha256, bytes: Buffer.from(file.bytes) })),
52
+ verifySource: resolved.verifySource, ...(resolved.sourceTree ? { sourceTree: { repo: resolved.sourceTree.repo, tree: { ...resolved.sourceTree.tree }, files: resolved.sourceTree.files.map(file => ({ ...file })) } } : {}) };
53
+ const ids = new Set<string>(), policy = state.registration.snapshots.dataPolicy, role = policy.roles[slot.role];
54
+ for (const file of source.files) {
55
+ const declared = policy.admittedData.find(item => item.id === file.dataId);
56
+ if (ids.has(file.dataId) || !role.dataIds.includes(file.dataId) || !declared || declared.sha256 !== file.sha256
57
+ || declared.bytes !== file.bytes.byteLength || bytesHash(file.bytes) !== file.sha256 || file.bytes.byteLength > PROBE_WORKSPACE_LIMITS.fileBytes)
58
+ throw new ProbeLocalError("invalid");
59
+ ids.add(file.dataId);
60
+ }
61
+ if (source.sourceTree && guidanceProbeCanonical(source.sourceTree.tree) !== guidanceProbeCanonical(state.registration.manifest.inputs.codeTree))
62
+ throw new ProbeLocalError("drift");
63
+ const descriptors = source.files.map(file => ({ dataId: file.dataId, relative: file.relative, sha256: file.sha256, bytes: file.bytes.byteLength }));
64
+ const input = freeze(prepareLocalProbeInput(state, slot, guidance, descriptors, config)), record = { state, slot, guidance, source, input };
65
+ if (slot.role === "worker" && slot.arm !== "baseline") {
66
+ const baseline = [...state.sessions].reverse().find(session => session.state === "closed_fixture" && session.coverage.coverageVerified
67
+ && state.registration.manifest.slots.some(item => item.id === session.slotId && item.role === "worker" && item.arm === "baseline"));
68
+ const baselineSlot = baseline && state.registration.manifest.slots.find(item => item.id === baseline.slotId);
69
+ if (!baselineSlot || baseline?.state !== "closed_fixture" || !baseline.coverage.coverageVerified
70
+ || baseline.coverage.inputFrameSha256 !== prepareLocalProbeInput(state, baselineSlot, state.binding.baselineGuidance, descriptors, config).inputSha256)
71
+ throw new ProbeLocalError("drift");
72
+ }
73
+ const key = `${guidanceProbeManifestKey(state.registration.manifest)}:${slot.id}`;
74
+ prepared.delete(key); prepared.set(key, record);
75
+ // Only preparation entries are evicted; no retained execution, budget or experiment is reset.
76
+ while (prepared.size > GUIDANCE_PROBE_LIMITS.slots) prepared.delete(prepared.keys().next().value!);
77
+ return record;
78
+ };
79
+ const close = async (entry: Owned, retry = false): Promise<void> => {
80
+ if (entry.closed) return;
81
+ if (entry.closeFailed && !retry) throw new ProbeLocalError("interrupted");
82
+ try {
83
+ if (entry.peer) await entry.peer.stopProbe();
84
+ else if (entry.confinement) await entry.confinement.stop();
85
+ if (entry.closeUnknown) await entry.closeUnknown();
86
+ entry.closed = true;
87
+ } catch { entry.closeFailed = true; throw new ProbeLocalError("interrupted"); }
88
+ };
89
+ const observation = (input: ProbeFakeLaunch, ready: Prepared, servedModel: string | null, outcome: ProbeFakeObservation["outcome"], usage: ProbeFakeObservation["usage"]): ProbeFakeObservation => ({
90
+ reservation: input.reservation, outcome, servedModel, inputFrameHash: ready.input.inputSha256,
91
+ workerEffectiveInputHash: input.slot.role === "worker" ? ready.input.inputSha256 : null,
92
+ nonGuidanceInputSha256: input.slot.role === "worker" ? ready.input.nonGuidanceInputSha256 : null,
93
+ candidateArtifactSha256: null, usage,
94
+ });
95
+ return {
96
+ prepareWorkerFrame: async (state, slot, guidance) => {
97
+ const record = await prepare(state, slot, guidance);
98
+ return { inputFrame: record.input.inputFrame, nonGuidanceInputSha256: record.input.nonGuidanceInputSha256 };
99
+ },
100
+ prepareEditorFrame: async (state, slot) => (await prepare(state, slot, state.binding.baselineGuidance)).input.inputFrame,
101
+ ports: {
102
+ launch(input, effects, signal) {
103
+ current();
104
+ const key = `${guidanceProbeManifestKey(input.manifest)}:${input.slot.id}`, ready = prepared.get(key), id = reservationKey(input.reservation);
105
+ if (!ready || owned.has(id) || signal.aborted || input.purpose !== "guidance_probe" || ready.input.role !== input.slot.role
106
+ || input.inputFrame !== ready.input.inputFrame || input.inputSha256 !== ready.input.inputSha256
107
+ || input.slot.role === "worker" && input.nonGuidanceInputSha256 !== ready.input.nonGuidanceInputSha256)
108
+ return Promise.reject(new ProbeLocalError("drift"));
109
+ prepared.delete(key);
110
+ const entry: Owned = { reservation: input.reservation, controller: new AbortController(), closed: false };
111
+ owned.set(id, entry);
112
+ const abort = () => entry.controller.abort(); signal.addEventListener("abort", abort, { once: true });
113
+ let sequence = 0;
114
+ const sourceCurrent = () => {
115
+ if (signal.aborted || entry.controller.signal.aborted || entry.closed) throw new ProbeLocalError("interrupted");
116
+ effects.current(); current();
117
+ const actual = localProbeFingerprints(config), expected = input.manifest.runtime;
118
+ if (actual.runtimeSha256 !== expected.runtimeSha256 || actual.toolsetSha256 !== expected.toolsetSha256 || actual.modelConfigSha256 !== expected.modelConfigSha256)
119
+ throw new ProbeLocalError("drift");
120
+ };
121
+ const accounting: ProbeLocalEffectScope = { effects, next: () => sequence++, current: () => {
122
+ sourceCurrent();
123
+ if (entry.workspace && !fixture) {
124
+ if (entry.confinement) requireProbeConfinement(entry.confinement, entry.workspace);
125
+ else probeWorkspaceCurrent(entry.workspace);
126
+ }
127
+ } };
128
+ const reserve = async (charges: ProbeResourceCharges, descriptor: string): Promise<void> => {
129
+ if (!positiveCharge(charges)) return;
130
+ await probeLocalEffect(accounting, "resources", descriptor, charges, undefined, async () => ({ value: undefined, usage: 0 }));
131
+ };
132
+ entry.promise = Promise.resolve().then(async () => {
133
+ accounting.current();
134
+ const workspaceInput = { role: input.slot.role, policy: ready.state.registration.snapshots.dataPolicy, files: ready.source.files,
135
+ ...(ready.source.sourceTree ? { sourceTree: ready.source.sourceTree } : {}), verifySource: ready.source.verifySource,
136
+ reserveStorage: (bytes: number) => reserve({ scratchBytes: bytes }, "probe-workspace-storage"), current: sourceCurrent,
137
+ maxBytes: PROBE_WORKSPACE_LIMITS.workspaceBytes };
138
+ entry.workspace = await (fixture ? fixture.materialize(workspaceInput) : materializeProbeWorkspace(workspaceInput));
139
+ workspaceOwned?.(entry.workspace);
140
+ accounting.current();
141
+ if (entry.workspace.role !== input.slot.role || JSON.stringify(entry.workspace.files) !== JSON.stringify(ready.input.files)) throw new ProbeLocalError("drift");
142
+ entry.confinement = await (fixture ? fixture.confine(entry.workspace) : verifyProbeConfinement(entry.workspace, entry.controller.signal));
143
+ if (entry.confinement.workspace !== entry.workspace) throw new ProbeLocalError("drift");
144
+ accounting.current();
145
+ entry.peer = new LocalPeer("local", { cwd: entry.workspace.root, omni, fixedModel: GUIDANCE_PROBE_MODEL,
146
+ maxSteps: config.maxSteps, tools: { deny: [], permit } }, entry.confinement, fixture ? "fixture_only" : undefined);
147
+ const result = await entry.peer.runProbe({ purpose: "guidance_probe", prepared: ready.input, workspace: entry.workspace,
148
+ confinement: entry.confinement, config, accounting, reserve }, entry.controller.signal);
149
+ accounting.current(); await close(entry);
150
+ effects.current(); current();
151
+ return observation(input, ready, result.servedModel, result.complete ? "closed_fixture" : "failed_known", result.usageKnown ? "known_fixture" : "unknown");
152
+ }).catch(async error => {
153
+ if (error instanceof ProbeConfinementError) entry.closeUnknown = error.stop;
154
+ try { await close(entry); }
155
+ catch { throw new ProbeLocalError("interrupted"); }
156
+ return observation(input, ready, entry.peer?.probeObservation().servedModel ?? null, "unknown", "unknown");
157
+ }).finally(() => {
158
+ signal.removeEventListener("abort", abort);
159
+ if (entry.closed) { completed.add(entry.reservation); owned.delete(id); }
160
+ });
161
+ return entry.promise;
162
+ },
163
+ async stop(input) {
164
+ const entry = owned.get(reservationKey(input.reservation));
165
+ if (!entry) return { reservation: input.reservation, stopped: completed.has(input.reservation) ? "known_fixture" : "unknown" };
166
+ entry.controller.abort();
167
+ await entry.promise?.catch(() => {});
168
+ await close(entry, true);
169
+ completed.add(entry.reservation); owned.delete(reservationKey(entry.reservation));
170
+ return { reservation: input.reservation, stopped: "known_fixture" };
171
+ },
172
+ },
173
+ };
174
+ }