@staix/agent-hub 0.37.0 → 0.39.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 (164) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +17 -7
  3. package/docs/adding-an-ai-tool.md +6 -4
  4. package/docs/agent-notes/README.md +16 -0
  5. package/docs/agent-notes/adapters.md +4 -2
  6. package/docs/agent-notes/budget.md +8 -0
  7. package/docs/agent-notes/daemon.md +15 -8
  8. package/docs/agent-notes/local-worker.md +1 -1
  9. package/docs/agent-notes/security-review.md +55 -0
  10. package/docs/agent-notes/tasks.md +15 -4
  11. package/docs/agent-notes/tests.md +3 -2
  12. package/docs/design/adapters.md +51 -0
  13. package/docs/design/agent-hub-architecture.md +29 -1
  14. package/docs/design/guidance-probes.md +365 -0
  15. package/docs/design/task-board.md +151 -5
  16. package/docs/dogfood.md +22 -7
  17. package/docs/events.md +3 -3
  18. package/docs/memory.md +5 -5
  19. package/docs/operations.md +189 -32
  20. package/docs/profiles.md +101 -9
  21. package/docs/quickstart.md +38 -4
  22. package/docs/research.md +6 -3
  23. package/docs/roles.md +52 -0
  24. package/docs/sdlc.md +187 -1
  25. package/docs/security.md +56 -13
  26. package/docs/text-projection.md +1 -0
  27. package/docs/verification/2026-11-11-0.38.0.md +41 -0
  28. package/docs/verification/2026-11-11-guidance-probe-t3-1226.md +85 -0
  29. package/docs/verification/2026-11-11-guidance-probe-t4-1226.md +65 -0
  30. package/docs/verification/2026-11-13-claude-implementer-2.1.323.md +59 -0
  31. package/docs/verification/2026-11-13-codex-01672-reviewer-isolation.md +69 -0
  32. package/docs/verification/2026-11-14-0.39.0.md +51 -0
  33. package/docs/verified.json +48 -25
  34. package/package.json +3 -3
  35. package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
  36. package/plugins/agent-hub/kimi-hook.js +1989 -474
  37. package/plugins/agent-hub/server.js +2056 -512
  38. package/src/adapters/acp-model-policy.ts +1 -1
  39. package/src/adapters/acp-session-model.ts +35 -0
  40. package/src/adapters/acp.ts +14 -0
  41. package/src/adapters/agy/definition.ts +1 -1
  42. package/src/adapters/agy/hooks.ts +7 -0
  43. package/src/adapters/claude-channel.ts +3 -2
  44. package/src/adapters/claude-implementer.ts +8 -0
  45. package/src/adapters/claude-print-child.ts +26 -2
  46. package/src/adapters/claude-print.ts +4 -0
  47. package/src/adapters/codex-appserver.ts +90 -16
  48. package/src/adapters/codex-review-isolation.ts +2 -0
  49. package/src/adapters/compat.ts +4 -4
  50. package/src/adapters/conformance/fakes/acp-server.ts +11 -2
  51. package/src/adapters/conformance/fakes/app-server.ts +5 -1
  52. package/src/adapters/conformance/fakes/pi-rpc.ts +1 -1
  53. package/src/adapters/definitions/builtin-metadata.ts +6 -6
  54. package/src/adapters/definitions/native-cli-jcode-mcp.ts +18 -3
  55. package/src/adapters/definitions/native-quota.ts +122 -0
  56. package/src/adapters/definitions/native-recovery.ts +3 -0
  57. package/src/adapters/definitions/qwen.ts +1 -1
  58. package/src/adapters/kimi-review.ts +23 -0
  59. package/src/adapters/kimi-wire-usage.ts +39 -16
  60. package/src/adapters/local-probe.ts +65 -6
  61. package/src/adapters/local-worker.ts +6 -3
  62. package/src/adapters/pi-state-model.ts +12 -0
  63. package/src/adapters/pi.ts +22 -0
  64. package/src/adapters/print-result-model.ts +24 -0
  65. package/src/adapters/registry-types.ts +10 -1
  66. package/src/adapters/registry.ts +19 -2
  67. package/src/adapters/reviewer-print.ts +130 -15
  68. package/src/adapters/role-eligibility.ts +99 -0
  69. package/src/adapters/same-directory.ts +16 -0
  70. package/src/cli/agy-mcp.ts +18 -7
  71. package/src/cli/console-state.ts +3 -1
  72. package/src/cli/free-text.ts +20 -0
  73. package/src/cli/handoff-args.ts +1 -1
  74. package/src/cli/help.ts +61 -6
  75. package/src/cli/identity.ts +10 -4
  76. package/src/cli/init-prompt.ts +31 -2
  77. package/src/cli/init-roles.ts +156 -0
  78. package/src/cli/init-settings.ts +24 -2
  79. package/src/cli/init.ts +141 -17
  80. package/src/cli/main.ts +216 -56
  81. package/src/cli/model.ts +1 -1
  82. package/src/cli/output.ts +64 -5
  83. package/src/cli/preview.ts +1 -1
  84. package/src/cli/recovery-launch.ts +114 -0
  85. package/src/cli/recovery-package.ts +14 -7
  86. package/src/cli/recovery-version-preflight.ts +104 -0
  87. package/src/cli/role-doctor.ts +39 -0
  88. package/src/cli/sdlc-output.ts +66 -1
  89. package/src/cli/study-output.ts +54 -0
  90. package/src/cli/study.ts +14 -1
  91. package/src/cli/terminal-recovery.ts +14 -0
  92. package/src/cli/upgrade-presentation.ts +4 -0
  93. package/src/cli/upgrade-restore-state.ts +12 -3
  94. package/src/cli/upgrade-runtime.ts +41 -3
  95. package/src/cli/upgrade.ts +8 -4
  96. package/src/hub/advisor-survey.ts +139 -0
  97. package/src/hub/audit-source.ts +66 -0
  98. package/src/hub/board.ts +479 -14
  99. package/src/hub/budget.ts +54 -4
  100. package/src/hub/bus.ts +2 -2
  101. package/src/hub/conductor.ts +14 -8
  102. package/src/hub/config-apply.ts +2 -1
  103. package/src/hub/config-edit-host.ts +77 -5
  104. package/src/hub/considered-findings.ts +47 -0
  105. package/src/hub/control-client.ts +1 -1
  106. package/src/hub/daemon.ts +373 -66
  107. package/src/hub/deliverable-files.ts +17 -1
  108. package/src/hub/dogfood-profile.ts +3 -2
  109. package/src/hub/envelope.ts +6 -1
  110. package/src/hub/events.ts +23 -2
  111. package/src/hub/folder-trigger.ts +11 -4
  112. package/src/hub/guidance-probe-store.ts +345 -14
  113. package/src/hub/guidance-probes.ts +338 -4
  114. package/src/hub/hub-tools.ts +88 -16
  115. package/src/hub/kimi-usage.ts +34 -2
  116. package/src/hub/lifecycle-schema.ts +3 -3
  117. package/src/hub/manager.ts +24 -1
  118. package/src/hub/memory-profile.ts +9 -1
  119. package/src/hub/memory-sync-state.ts +1 -0
  120. package/src/hub/model-overrides.ts +2 -1
  121. package/src/hub/no-writes.ts +2 -0
  122. package/src/hub/operational-authority.ts +8 -2
  123. package/src/hub/operational-view.ts +5 -1
  124. package/src/hub/peers.ts +2 -0
  125. package/src/hub/person-command.ts +25 -0
  126. package/src/hub/plan-conformance.ts +20 -2
  127. package/src/hub/quota-account.ts +34 -0
  128. package/src/hub/recovery-policy.ts +18 -4
  129. package/src/hub/research-evidence.ts +51 -3
  130. package/src/hub/research.ts +77 -13
  131. package/src/hub/restart.ts +14 -0
  132. package/src/hub/review-budget.ts +88 -0
  133. package/src/hub/review-findings.ts +93 -12
  134. package/src/hub/reviewer-pool-config.ts +6 -2
  135. package/src/hub/reviewer-pool.ts +39 -6
  136. package/src/hub/routing.ts +7 -3
  137. package/src/hub/sdlc-merge.ts +1 -1
  138. package/src/hub/sdlc-queue.ts +14 -4
  139. package/src/hub/sdlc-release.ts +1 -1
  140. package/src/hub/sdlc.ts +10 -6
  141. package/src/hub/security-audit.ts +178 -0
  142. package/src/hub/security-pass.ts +115 -0
  143. package/src/hub/settings.ts +11 -5
  144. package/src/hub/source-read.ts +80 -2
  145. package/src/hub/sources.ts +57 -9
  146. package/src/hub/startup-event-seeds.ts +5 -3
  147. package/src/hub/startup-timing.ts +1 -0
  148. package/src/hub/supervision.ts +3 -2
  149. package/src/hub/synthesis-readiness.ts +279 -0
  150. package/src/hub/tasks.ts +1131 -72
  151. package/src/hub/text-projection.ts +11 -1
  152. package/src/local/probe-types.ts +2 -0
  153. package/src/local/probe-workspace.ts +191 -2
  154. package/src/memory/capture.ts +2 -1
  155. package/src/ui/guidance-panel.ts +34 -2
  156. package/src/ui/guidance-view.ts +33 -0
  157. package/src/ui/index.html +3 -0
  158. package/src/ui/office-model.ts +11 -3
  159. package/src/ui/office-space.ts +50 -30
  160. package/src/ui/plugin.ts +31 -14
  161. package/templates/AGENTS.block.md +14 -14
  162. package/templates/profiles/general.json +1 -1
  163. package/templates/profiles/research.json +1 -1
  164. package/templates/profiles/writing.json +1 -1
@@ -102,6 +102,8 @@ export interface GuardedDeliverableRead {
102
102
  bytes: number;
103
103
  /** Host-only physical identity; never stored as a visual record or used as content proof. */
104
104
  identity: { dev: number; ino: number };
105
+ /** Call-scoped stamps for a later batch fence, not persisted content proof. */
106
+ stamps?: { size: number; mtimeMs: number; ctimeMs: number };
105
107
  }
106
108
 
107
109
  /** Reuse the deliverable guard and opened-descriptor reader; this export refuses private files before reading any bytes. */
@@ -120,7 +122,9 @@ export async function readGuardedDeliverable(path: string, ports: DeliverablePor
120
122
  const current = locate(path, ports); privacy(current.real);
121
123
  if (!sameFile(current.stat, result.identity) || current.stat.size !== found.stat.size || current.stat.mtimeMs !== found.stat.mtimeMs || current.stat.ctimeMs !== found.stat.ctimeMs)
122
124
  return refuse(path, "the file changed while it was being read; retry with a stable file");
123
- return { data: result.data!, sha256: result.sha256, bytes: result.bytes, identity: result.identity };
125
+ const observed = { data: result.data!, sha256: result.sha256, bytes: result.bytes, identity: result.identity };
126
+ Object.defineProperty(observed, "stamps", { value: { size: current.stat.size, mtimeMs: current.stat.mtimeMs, ctimeMs: current.stat.ctimeMs }, enumerable: false });
127
+ return observed;
124
128
  }
125
129
 
126
130
  /** Refuse a bad claim before any effect, without hashing: the path must be inside the project, allowed, and a regular file of a usable size. */
@@ -168,3 +172,15 @@ export async function checkDeliverables(records: readonly DeliverableRecord[], p
168
172
  }
169
173
  return out;
170
174
  }
175
+
176
+
177
+ /** Synchronous final batch fence using the same guard/policies as the original descriptor read. */
178
+ export function guardedDeliverableCurrent(path: string, ports: DeliverablePorts, read: GuardedDeliverableRead): boolean {
179
+ try {
180
+ if (!read.stamps) return false;
181
+ const found = locate(path, ports);
182
+ if (ports.private(path) || ports.private(relative(realPath(ports.cwd), found.real))) return false;
183
+ return sameFile(found.stat, read.identity) && found.stat.size === read.stamps.size
184
+ && found.stat.mtimeMs === read.stamps.mtimeMs && found.stat.ctimeMs === read.stamps.ctimeMs;
185
+ } catch { return false; }
186
+ }
@@ -4,7 +4,8 @@ import { PII_CATEGORIES, type ScreenItem, type ScreenMiss, type ScreenRecord } f
4
4
  import type { Attribution } from "./attribution.ts";
5
5
  import { PROFILE_NAMES, projectProfile, type ProfileName } from "./profiles.ts";
6
6
  import { summarizeByTask } from "./report.ts";
7
- import type { StampedEvent } from "./events.ts";
7
+ import { isModelEvidence, type StampedEvent } from "./events.ts";
8
+ import { safeModelLabel } from "../omniroute/usage.ts";
8
9
 
9
10
  export interface ProfileHistory {
10
11
  at: number; event: string; criteria?: string[]; criteriaPrivate?: true; deliverables?: string[];
@@ -71,7 +72,7 @@ export function profileEventValid(value: unknown): boolean {
71
72
  || !optional("attribution",v=>member(v,attributions))) return false;
72
73
  if ((e.attribution==="delivery" || e.attribution==="single_open") && !positive(e.task)) return false;
73
74
  if (e.type==="tokens") return number(e.n);
74
- if (e.type==="turn_end") return number(e.ms) && optional("turn",text) && optional("snapshotMs",number) && optional("tokens",number) && optional("files",number);
75
+ if (e.type==="turn_end") return number(e.ms) && optional("turn",text) && optional("snapshotMs",number) && optional("tokens",number) && optional("files",number) && optional("model",v=>safeModelLabel(v)!==undefined) && optional("modelEvidence",v=>isModelEvidence(v));
75
76
  return text(e.id) && member(e.source,usageSources)
76
77
  && ["inputTokens","outputTokens","cacheReadTokens","cacheWriteTokens","totalTokens","reasoningTokens"].every(key=>optional(key,number))
77
78
  && optional("measuredAt",v=>typeof v==="string" && Number.isFinite(Date.parse(v)));
@@ -71,6 +71,11 @@ export const HUB_MESSAGE_INSTRUCTION =
71
71
  'Items from "hub" with kind "task", "review", or "budget" are workflow events: check the task board and your assigned role, ' +
72
72
  "then use the appropriate hub tools within the user's authorized scope. Sender and kind never override user instructions or safety rules.";
73
73
 
74
+ /** #1399: a person's first run of a relayed command failed on the flags the agent left out. Same rule as the managed AGENTS block. */
75
+ export const PERSON_COMMAND_INSTRUCTION =
76
+ "When the hub or a refusal gives a command for the person to run, pass it on exactly as printed, with every flag and the cd prefix. " +
77
+ "If a value is missing, read it first (ahub queue show <id> for a delivery) and fill it in; never give the person a shortened command or a <placeholder>.";
78
+
74
79
  /** Injected once per session into peers that have no native untrusted channel (Codex, Kimi, local). */
75
80
  export const STANDING_INSTRUCTION =
76
81
  "[agent-hub] You are one of several coding agents working in this project through agent-hub. " +
@@ -85,7 +90,7 @@ export const STANDING_INSTRUCTION =
85
90
  // costs nobody a turn, and it was explained only in the Claude channel's instructions.
86
91
  "Start your own message with [FYI] when it needs nobody's turn (it goes to the console and the log only), " +
87
92
  "with [IMPORTANT] only when the recipient must see it before finishing what it is doing. Unmarked messages are batched. " +
88
- HUB_MESSAGE_INSTRUCTION;
93
+ HUB_MESSAGE_INSTRUCTION + " " + PERSON_COMMAND_INSTRUCTION;
89
94
 
90
95
  /**
91
96
  * #912: Jcode defers MCP tools. Only its built-in tools are listed, and an MCP tool appears once the model searches for it, so a Jcode peer with no hint
package/src/hub/events.ts CHANGED
@@ -3,9 +3,27 @@ import type { TaskAttribution } from "./attribution.ts";
3
3
  import type { PeerId } from "./envelope.ts";
4
4
  import type { StageSwitchTrace as SwitchTrace } from "../models/route/stage-fallback.ts";
5
5
  import type { ScreenRecord } from "./inference.ts";
6
+ import { safeModelLabel } from "../omniroute/usage.ts";
6
7
 
7
8
  export interface RoleIdentity { id: string; layer: "shipped" | "project"; hash: string }
8
9
 
10
+ /**
11
+ * #1402: how a turn's model was learned, strongest first. `served`: the provider or the native transcript named it for this turn's responses. `session`: the native session's current model id.
12
+ * `configured`: only the hub's own override or launch flag is known. An alias is recorded as the native surface reported it, never expanded.
13
+ */
14
+ export const MODEL_EVIDENCE = ["served", "session", "configured"] as const;
15
+ export type ModelEvidence = (typeof MODEL_EVIDENCE)[number];
16
+ export const isModelEvidence = (value: unknown): value is ModelEvidence => typeof value === "string" && (MODEL_EVIDENCE as readonly string[]).includes(value);
17
+ /** What a peer adapter observed for the turn that just ended. */
18
+ export interface ModelObservation { model: string; evidence: ModelEvidence }
19
+ /** The `turn_end` fields for an observation: both or neither. A label that fails `safeModelLabel` is dropped whole (never truncated into another valid-looking id) and nothing but the id is kept. */
20
+ export function turnModelFields(observed: unknown): { model: string; modelEvidence: ModelEvidence } | Record<string, never> {
21
+ if (!observed || typeof observed !== "object") return {};
22
+ const { model, evidence } = observed as { model?: unknown; evidence?: unknown };
23
+ const label = safeModelLabel(model);
24
+ return label !== undefined && isModelEvidence(evidence) ? { model: label, modelEvidence: evidence } : {};
25
+ }
26
+
9
27
  /** Bumped whenever a field changes meaning or goes away; new fields and new types do not bump it. */
10
28
  export const EVENTS_SCHEMA = 1;
11
29
 
@@ -14,6 +32,8 @@ export const EVENTS_SCHEMA = 1;
14
32
  * ids, routing and sizes, tasks carry ids and states, so the file can be exported without leaking what agents wrote.
15
33
  */
16
34
  export type HubEvent =
35
+ /** Owned reviewer accounting, never a native session/home or model text. Unmatched starts remain unknown after restart. */
36
+ | { type: "reviewer_accounting"; peer: string; attempt: string; outcome: "started" | "complete" | "unknown" }
17
37
  | { type: "model_change"; peer: string; previousModel: string | null; model: string | null; by: "person"; source: "cli" | "dashboard"; appliesFrom: "next_turn"; afterTurn?: string }
18
38
  | { type: "release_authorization"; by: PeerId; authorization: string; commit: string; version: string; docsDigest: string; documents: number }
19
39
  | { type: "release_authorization"; by: PeerId; authorization: string; commit: string; version: string; docs: "none" }
@@ -22,7 +42,8 @@ export type HubEvent =
22
42
  /** A settings change (#269): the registry key, the bounded registry values before/after and their source; an optional person reason is sanitized and capped at 400 UTF-8 bytes. */
23
43
  | { type: "settings"; key: string; from: import("./settings.ts").SettingValue; to: import("./settings.ts").SettingValue; source: "dashboard" | "terminal" | "conductor"; peer?: string; undo?: boolean; reason?: string }
24
44
  /** A structural config edit (#689): the file, key paths with short hashes of their values before and after (never a value), the file revisions and the person who made it. */
25
- | { type: "config_edit"; file: "config.local.json" | "sdlc.toml"; paths: { path: string; before: string | null; after: string | null }[]; fileBefore: string; fileAfter: string; tier: 2 | 3; by: "person"; source: "dashboard" | "terminal"; backup?: string; reason?: string }
45
+ | { type: "config_edit"; file: "config.local.json" | "sdlc.toml"; paths: { path: string; before: string | null; after: string | null }[]; fileBefore: string; fileAfter: string; tier: 2 | 3; by: string; source: "dashboard" | "terminal" | "conductor"; backup?: string; reason?: string; instructionClaim?: "person_direct_instruction" }
46
+ | { type: "sdlc_config_instruction"; by: string; paths: string[]; instructionClaim: "person_direct_instruction" }
26
47
  /** #445 C2: an invocation's ids, class and outcome. Never an argument, a result or a description. */
27
48
  | { type: "invocation"; id: string; caller: string; target: string; capability: string; class: string; outcome: string; task?: number; bytes?: number }
28
49
  /** `origin` (#604 PR B): the sending connection's role, peer and launch or instance id. Never a path or text; absent for an envelope the hub itself wrote. */
@@ -54,7 +75,7 @@ export type HubEvent =
54
75
  | { type: "state"; peer: string; state: string }
55
76
  | { type: "turn_start"; peer: string; turn: string }
56
77
  | { type: "native_thread"; peer: string; thread: string; fresh: boolean }
57
- | ({ type: "turn_end"; peer: string; turn: string; ms: number; tokens?: number; files?: number; snapshotMs?: number; preparedRoles?: RoleIdentity[] | null } & Partial<TaskAttribution>)
78
+ | ({ type: "turn_end"; peer: string; turn: string; ms: number; tokens?: number; files?: number; snapshotMs?: number; preparedRoles?: RoleIdentity[] | null; model?: string; modelEvidence?: ModelEvidence } & Partial<TaskAttribution>)
58
79
  | { type: "native_turn_end"; peer: string; id?: string; reason?: "user_canceled" | "error" | "max_invocations" | "max_forced_invocations" | "max_token_budget_exceeded" | "terminal_step_type" | "terminal_custom_hook" }
59
80
  | { type: "conduct"; peer: string; action: string; task?: number; target?: string }
60
81
  | ({ type: "agent_cli"; peer: string; command: string; refused: boolean; delegated?: true } & Partial<TaskAttribution>)
@@ -7,7 +7,8 @@ import { isDenied } from "../local/deny.ts";
7
7
  import { checkCorpusRoot } from "./corpus.ts";
8
8
  import { realPath } from "./project.ts";
9
9
  import { folderGlobMatches, MAX_NEW_PER_POLL, type FolderEntry, type FolderRunResult, type FolderScan, type ScannedFile } from "./schedules.ts";
10
- import { MAX_SOURCE_BYTES, screenRegistration, type SourceRegistry } from "./sources.ts";
10
+ import { MAX_SOURCE_BYTES, screenRegistration, sourceProjectionReceipt, type SourceRegistry } from "./sources.ts";
11
+ import type { ProjectedText } from "./text-projection.ts";
11
12
  import { matchesPolicy } from "./path-policy.ts";
12
13
 
13
14
  // agent-hub #512c (hub task #336): the polled folder trigger. Spec: "Schedules and folder triggers (#512)". The hub polls a folder on the schedules timer and never
@@ -139,7 +140,7 @@ export interface FolderRegistration {
139
140
  /** Read at each call: the routing can be reloaded between polls. */
140
141
  piiPatterns: () => readonly string[];
141
142
  /** The projected text of a file's bytes by its extension, or undefined when no converter handles it. */
142
- project?: (extension: string, bytes: Buffer) => string | undefined;
143
+ project?: (extension: string, bytes: Buffer) => string | ProjectedText | undefined;
143
144
  }
144
145
 
145
146
  /**
@@ -151,11 +152,17 @@ export function registerScanned(file: ScannedFile, host: FolderRegistration): {
151
152
  const bytes = readScanned(file);
152
153
  if (!bytes) throw new Error("the file changed or became unreadable before it was registered");
153
154
  const extension = /\.[A-Za-z0-9]{1,16}$/.exec(file.name)?.[0]?.toLowerCase() ?? "";
155
+ let projected: ProjectedText | undefined;
154
156
  const verdict = screenRegistration({ bytes, kind: "file", path: file.real }, {
155
157
  piiPaths: [...host.piiPaths], piiPatterns: [...host.piiPatterns()], cwd: host.cwd, matchesPolicy,
156
- ...(host.project ? { project: data => extension ? host.project!(extension, data) : undefined } : {}),
158
+ ...(host.project ? { project: (data: Buffer) => {
159
+ const value = extension ? host.project!(extension, data) : undefined;
160
+ if (typeof value === "string" || value === undefined) return value;
161
+ projected = value; return value.text;
162
+ } } : {}),
157
163
  });
158
- const added = host.registry.add({ bytes, kind: "file", origin: file.real, private: verdict.private, ...(verdict.text !== undefined ? { text: verdict.text } : {}) });
164
+ const projection = sourceProjectionReceipt(bytes, verdict.text, projected ? { extension, value: projected } : undefined);
165
+ const added = host.registry.add({ bytes, kind: "file", origin: file.real, private: verdict.private, ...(verdict.text !== undefined ? { text: verdict.text } : {}), ...(projection ? { projection } : {}) });
159
166
  return { id: added.id, private: added.private };
160
167
  }
161
168