@staix/agent-hub 0.38.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 (144) hide show
  1. package/CHANGELOG.md +45 -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/task-board.md +151 -5
  15. package/docs/dogfood.md +20 -6
  16. package/docs/events.md +3 -3
  17. package/docs/memory.md +5 -5
  18. package/docs/operations.md +177 -28
  19. package/docs/profiles.md +100 -8
  20. package/docs/quickstart.md +32 -4
  21. package/docs/research.md +6 -3
  22. package/docs/roles.md +52 -0
  23. package/docs/sdlc.md +187 -1
  24. package/docs/security.md +50 -11
  25. package/docs/text-projection.md +1 -0
  26. package/docs/verification/2026-11-13-claude-implementer-2.1.323.md +59 -0
  27. package/docs/verification/2026-11-13-codex-01672-reviewer-isolation.md +69 -0
  28. package/docs/verification/2026-11-14-0.39.0.md +51 -0
  29. package/docs/verified.json +48 -25
  30. package/package.json +3 -3
  31. package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
  32. package/plugins/agent-hub/kimi-hook.js +1953 -460
  33. package/plugins/agent-hub/server.js +2019 -498
  34. package/src/adapters/acp-model-policy.ts +1 -1
  35. package/src/adapters/acp-session-model.ts +35 -0
  36. package/src/adapters/acp.ts +14 -0
  37. package/src/adapters/agy/definition.ts +1 -1
  38. package/src/adapters/agy/hooks.ts +7 -0
  39. package/src/adapters/claude-channel.ts +1 -1
  40. package/src/adapters/claude-implementer.ts +8 -0
  41. package/src/adapters/claude-print-child.ts +26 -2
  42. package/src/adapters/claude-print.ts +4 -0
  43. package/src/adapters/codex-appserver.ts +90 -16
  44. package/src/adapters/codex-review-isolation.ts +2 -0
  45. package/src/adapters/compat.ts +4 -4
  46. package/src/adapters/conformance/fakes/acp-server.ts +11 -2
  47. package/src/adapters/conformance/fakes/app-server.ts +5 -1
  48. package/src/adapters/conformance/fakes/pi-rpc.ts +1 -1
  49. package/src/adapters/definitions/builtin-metadata.ts +6 -6
  50. package/src/adapters/definitions/native-cli-jcode-mcp.ts +18 -3
  51. package/src/adapters/definitions/native-quota.ts +122 -0
  52. package/src/adapters/definitions/native-recovery.ts +3 -0
  53. package/src/adapters/definitions/qwen.ts +1 -1
  54. package/src/adapters/kimi-review.ts +23 -0
  55. package/src/adapters/kimi-wire-usage.ts +39 -16
  56. package/src/adapters/local-worker.ts +6 -3
  57. package/src/adapters/pi-state-model.ts +12 -0
  58. package/src/adapters/pi.ts +22 -0
  59. package/src/adapters/print-result-model.ts +24 -0
  60. package/src/adapters/registry-types.ts +10 -1
  61. package/src/adapters/registry.ts +19 -2
  62. package/src/adapters/reviewer-print.ts +130 -15
  63. package/src/adapters/role-eligibility.ts +99 -0
  64. package/src/adapters/same-directory.ts +16 -0
  65. package/src/cli/agy-mcp.ts +18 -7
  66. package/src/cli/console-state.ts +3 -1
  67. package/src/cli/free-text.ts +20 -0
  68. package/src/cli/handoff-args.ts +1 -1
  69. package/src/cli/help.ts +61 -6
  70. package/src/cli/identity.ts +10 -4
  71. package/src/cli/init-prompt.ts +31 -2
  72. package/src/cli/init-roles.ts +156 -0
  73. package/src/cli/init-settings.ts +24 -2
  74. package/src/cli/init.ts +139 -17
  75. package/src/cli/main.ts +194 -49
  76. package/src/cli/model.ts +1 -1
  77. package/src/cli/output.ts +56 -1
  78. package/src/cli/preview.ts +1 -1
  79. package/src/cli/recovery-launch.ts +114 -0
  80. package/src/cli/recovery-package.ts +14 -7
  81. package/src/cli/recovery-version-preflight.ts +104 -0
  82. package/src/cli/role-doctor.ts +39 -0
  83. package/src/cli/sdlc-output.ts +66 -1
  84. package/src/cli/study-output.ts +54 -0
  85. package/src/cli/study.ts +14 -1
  86. package/src/cli/terminal-recovery.ts +14 -0
  87. package/src/cli/upgrade-presentation.ts +4 -0
  88. package/src/cli/upgrade-restore-state.ts +12 -3
  89. package/src/cli/upgrade-runtime.ts +40 -2
  90. package/src/cli/upgrade.ts +8 -4
  91. package/src/hub/advisor-survey.ts +139 -0
  92. package/src/hub/audit-source.ts +66 -0
  93. package/src/hub/board.ts +479 -14
  94. package/src/hub/budget.ts +54 -4
  95. package/src/hub/conductor.ts +14 -8
  96. package/src/hub/config-apply.ts +2 -1
  97. package/src/hub/config-edit-host.ts +77 -5
  98. package/src/hub/considered-findings.ts +47 -0
  99. package/src/hub/control-client.ts +1 -1
  100. package/src/hub/daemon.ts +343 -58
  101. package/src/hub/deliverable-files.ts +17 -1
  102. package/src/hub/dogfood-profile.ts +3 -2
  103. package/src/hub/events.ts +23 -2
  104. package/src/hub/folder-trigger.ts +11 -4
  105. package/src/hub/hub-tools.ts +88 -16
  106. package/src/hub/kimi-usage.ts +34 -2
  107. package/src/hub/lifecycle-schema.ts +3 -3
  108. package/src/hub/memory-profile.ts +9 -1
  109. package/src/hub/memory-sync-state.ts +1 -0
  110. package/src/hub/model-overrides.ts +2 -1
  111. package/src/hub/no-writes.ts +2 -0
  112. package/src/hub/operational-authority.ts +6 -1
  113. package/src/hub/operational-view.ts +5 -1
  114. package/src/hub/peers.ts +2 -0
  115. package/src/hub/plan-conformance.ts +20 -2
  116. package/src/hub/quota-account.ts +34 -0
  117. package/src/hub/recovery-policy.ts +18 -4
  118. package/src/hub/research-evidence.ts +51 -3
  119. package/src/hub/research.ts +77 -13
  120. package/src/hub/restart.ts +14 -0
  121. package/src/hub/review-budget.ts +88 -0
  122. package/src/hub/review-findings.ts +93 -12
  123. package/src/hub/reviewer-pool-config.ts +6 -2
  124. package/src/hub/reviewer-pool.ts +39 -6
  125. package/src/hub/routing.ts +7 -3
  126. package/src/hub/sdlc-merge.ts +1 -1
  127. package/src/hub/sdlc-queue.ts +14 -4
  128. package/src/hub/sdlc-release.ts +1 -1
  129. package/src/hub/sdlc.ts +10 -6
  130. package/src/hub/security-audit.ts +178 -0
  131. package/src/hub/security-pass.ts +115 -0
  132. package/src/hub/settings.ts +11 -5
  133. package/src/hub/source-read.ts +80 -2
  134. package/src/hub/sources.ts +57 -9
  135. package/src/hub/startup-event-seeds.ts +5 -3
  136. package/src/hub/startup-timing.ts +1 -0
  137. package/src/hub/synthesis-readiness.ts +279 -0
  138. package/src/hub/tasks.ts +1083 -69
  139. package/src/hub/text-projection.ts +11 -1
  140. package/src/memory/capture.ts +2 -1
  141. package/src/ui/index.html +3 -0
  142. package/src/ui/office-model.ts +11 -3
  143. package/src/ui/office-space.ts +50 -30
  144. package/src/ui/plugin.ts +21 -11
@@ -10,7 +10,8 @@ import { profile, sandboxAvailable } from "../local/sandbox.ts";
10
10
  export type ProjectionConfig = Record<string, string[]>;
11
11
  const EMPTY_ROOT = "/var/empty";
12
12
  export const MAX_PROJECTION_INPUT = 16 * 1024 * 1024;
13
- const MAX_INPUT = MAX_PROJECTION_INPUT, MAX_TEXT = 256 * 1024;
13
+ export const MAX_PROJECTION_TEXT = 256 * 1024;
14
+ const MAX_INPUT = MAX_PROJECTION_INPUT, MAX_TEXT = MAX_PROJECTION_TEXT;
14
15
  /** Only machine-local config chooses programs; no implicit shell or command-string parsing. */
15
16
  export function projectionConfig(raw: unknown): ProjectionConfig {
16
17
  if (raw === undefined) return {};
@@ -67,6 +68,15 @@ export class TextProjections {
67
68
  }
68
69
  get enabled(): boolean { return Object.keys(this.options.config).length > 0; }
69
70
  handles(file: string): boolean { return !!this.options.config[extname(file).toLowerCase()]; }
71
+ /** Current configured converter identity, without reading a source or running conversion. */
72
+ fingerprint(file: string): string | undefined {
73
+ const argv = this.options.config[extname(file).toLowerCase()];
74
+ if (!argv) return undefined;
75
+ try {
76
+ const commandHash = commandFingerprint(this.options.cwd, argv);
77
+ return this.options.projectRoot === undefined ? commandHash : hash(commandHash + "\nproject-root:" + realPath(this.options.projectRoot));
78
+ } catch { return undefined; }
79
+ }
70
80
  project(file: string): ProjectedText | undefined {
71
81
  const ext = extname(file).toLowerCase(), argv = this.options.config[ext];
72
82
  if (!argv) return undefined;
@@ -40,7 +40,8 @@ export class Capture {
40
40
  }
41
41
 
42
42
  observe(call: { tool: string; args: string; output: string; id: string; paths: string[]; sourceId?: string }): void {
43
- if (!this.sessionId || GUIDANCE_TOOL_NAMES.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || LINEAGE_TOOL_NAMES.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || reviewCaptureExcluded(call.tool, call.args) || ((MEMORY_READ_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || BOUNDED_TASK_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || CAPABILITY_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || STUDY_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || HANDOFF_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, ""))) || call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_memory_correct") || call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_source_read" || call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_set_title" || call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_evidence_record" || this.opts.skip?.includes(call.tool)) return;
43
+ if (call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_survey_report") return;
44
+ if (!this.sessionId || GUIDANCE_TOOL_NAMES.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_audit_report" || LINEAGE_TOOL_NAMES.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || reviewCaptureExcluded(call.tool, call.args) || ((MEMORY_READ_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || BOUNDED_TASK_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || CAPABILITY_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || STUDY_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || HANDOFF_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, ""))) || call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_memory_correct") || call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_source_read" || call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_set_title" || call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_evidence_read" || call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_evidence_record" || this.opts.skip?.includes(call.tool)) return;
44
45
  // #1053: a question and its answer are the person's and the peer's words: never memory evidence, whatever the call's paths say.
45
46
  if (QUESTION_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, ""))) return;
46
47
  // Anything that names a denylisted path is kept out of memory entirely, input and output alike.
package/src/ui/index.html CHANGED
@@ -855,6 +855,9 @@ function settingRow(row, raise) {
855
855
  select.value = current[index] || ''; actions.append(select); return select;
856
856
  });
857
857
  read = () => choices.map(select => select.value).filter(Boolean);
858
+ } else if (row.type === 'number-or-off') {
859
+ const input=el('input');input.type='text';input.id=id;input.name=row.key;input.value=fileValue===null ? '' : String(fileValue);input.placeholder='0..1 or off; empty inherits';input.autocomplete='off';input.autocapitalize='none';input.setAttribute('autocorrect','off');input.spellcheck=false;
860
+ read=()=>{const value=input.value.trim();return value==='' ? null : value==='off' ? 'off' : Number.isFinite(Number(value)) ? Number(value) : value;};actions.append(input);
858
861
  } else if (row.type === 'integer' || row.type === 'number') {
859
862
  const input=el('input');input.type='number';input.id=id;input.step=row.type === 'number' ? 'any' : '1';input.min=String(row.min ?? 0);input.max=String(row.max ?? Number.MAX_SAFE_INTEGER);const current=fileValue;input.value=current===null ? '' : String(current);input.placeholder='Empty inherits';
860
863
  read=()=>input.value==='' ? null : Number(input.value);actions.append(input);
@@ -3,8 +3,8 @@ import { OFFICE_PEER_ORDER } from "../adapters/registry.ts";
3
3
  /**
4
4
  * Pure office scene model for the dashboard (#264, phase 1: the static Flat view).
5
5
  * Self-contained so `src/hub/ui.ts` injects it into the page by toString(), exactly like
6
- * task-progress.ts. Inputs are allowlisted: peer states, queue counts and modes; task ids,
7
- * classes, states, owners, reviewers, deps and public titles; approval counts by peer; budget
6
+ * task-progress.ts. Inputs are allowlisted: peer states, queue counts and modes; a peer's configured roles and the open
7
+ * turn's start; task ids, classes, states, owners, reviewers, deps and public titles; approval counts by peer; budget
8
8
  * pause readings. env.body, task detail, approval titles, paths and symbols never enter;
9
9
  * test/office-model.test.ts pins that with a marker fixture.
10
10
  */
@@ -121,6 +121,10 @@ export interface OfficeDesk {
121
121
  approvals: number;
122
122
  tray: { queued: number; important: number; heldBy: string; needsReview: number };
123
123
  mode: string;
124
+ /** The project's configured `roles` for this peer (#1375), as configured; absent when it has none. */
125
+ roles?: readonly string[];
126
+ /** The open turn's start, in epoch ms (#1375): the one state-change time the model knows. Absent without a reported turn. */
127
+ turnSince?: number;
124
128
  /** "#id class" of the turn's attributed task (phase 3, exact), else of the peer's single in_progress task; empty when unknown. Never guessed. */
125
129
  bubble: string;
126
130
  /** The peer is paused with a turn still open: "finishing a turn" under the Break sign. */
@@ -351,6 +355,7 @@ export function officeModel(snapshot: OfficeSnapshotInput, previous: OfficeScene
351
355
  // The open turn's attributed task names the bubble exactly (phase 3); without it the
352
356
  // single-in_progress-task heuristic applies, and otherwise there is no bubble. Never guessed.
353
357
  const turn = peer.turn && typeof peer.turn === "object" ? peer.turn : undefined;
358
+ const turnSince = turn && typeof turn.since === "number" && Number.isFinite(turn.since) ? turn.since : undefined;
354
359
  const turnTask = turn && typeof turn.task === "number" && Number.isSafeInteger(turn.task) ? turn.task : undefined;
355
360
  const bubble = turnTask !== undefined ? `#${turnTask} ${classById.get(turnTask) ?? "task"}`
356
361
  : !Object.hasOwn(peer, "turn") && current.length === 1 ? `#${current[0]!.id} ${text(current[0]!.class) || "task"}` : "";
@@ -363,7 +368,9 @@ export function officeModel(snapshot: OfficeSnapshotInput, previous: OfficeScene
363
368
  if (finishing) parts.push("finishing a turn");
364
369
  if (condition !== "waiting" && count > 0) parts.push(`${count} approval${count === 1 ? "" : "s"} waiting`);
365
370
  if (!attached) parts.push("disconnected, work retained");
366
- const planner = Array.isArray(snapshot.status?.roleInfo?.[id]?.flowRoles) && snapshot.status!.roleInfo![id]!.flowRoles!.includes("planner");
371
+ const flowRoles = snapshot.status?.roleInfo?.[id]?.flowRoles;
372
+ const roles = Array.isArray(flowRoles) ? flowRoles.filter((role): role is string => typeof role === "string") : [];
373
+ const planner = roles.includes("planner");
367
374
  if (planner) parts.push(`planner, ${unplanned} unplanned backlog cards`);
368
375
  // An over-full desk shows two chips and a "+N more" line in the third slot.
369
376
  const shown = work.length > DESK_CARDS ? work.slice(0, DESK_CARDS - 1) : work;
@@ -373,6 +380,7 @@ export function officeModel(snapshot: OfficeSnapshotInput, previous: OfficeScene
373
380
  dimmed: condition === "offline", attached, approvals: count,
374
381
  tray: { queued: num(peer.queued), important: num(peer.queuedImportant), heldBy: text(peer.heldBy), needsReview: num(peer.needsReview) },
375
382
  mode: text(peer.permissionMode), bubble, breakNote, breakResetsAt,
383
+ ...(roles.length ? { roles } : {}), ...(turnSince !== undefined ? { turnSince } : {}),
376
384
  finishing,
377
385
  cards: shown.map((task, index) => card(task, x + 0.8, y + 8.5 + index * 2.5, DESK_W - 1.6, 2)),
378
386
  extraCards: work.length - shown.length,
@@ -1,24 +1,23 @@
1
1
  /**
2
- * officeModel() -> acon SpaceScene (#1012 Part 2). Pure: no DOM, no I/O, no clock beyond the model's own.
2
+ * officeModel() -> acon SpaceScene (#1012 Part 2, #1375). Pure: no DOM, no I/O, no clock beyond the model's own.
3
3
  *
4
- * Reads only the scene officeModel built, which is allowlisted by #264 (peer states, queue counts and modes; task ids,
5
- * classes, states, owners and public titles; approval counts; link and arc ids). No envelope body, task detail,
6
- * approval title, path or symbol can reach it, and test/acon-plugin.test.ts pins that with the #264 marker fixture.
4
+ * Reads only the scene officeModel built, which is allowlisted by #264 (peer states, queue counts, modes and configured
5
+ * roles; task ids, classes, states, owners and public titles; approval counts; link and arc ids). No envelope body, task
6
+ * detail, approval title, path or symbol can reach it, and test/acon-plugin.test.ts pins that with the #264 marker fixture.
7
+ *
8
+ * The scene type is acon's own, imported type-only from its pinned contract entry rather than hand-copied, so a field or
9
+ * cap drift fails typecheck here instead of at a person's console.
7
10
  */
11
+ import type { SpaceScene, Tone } from "@staix/agent-console/contract";
8
12
  import type { OfficeScene } from "./office-model.ts";
9
13
 
10
- type Tone = "ok" | "warn" | "err" | "neutral";
11
- type ActorState = "idle" | "working" | "waiting" | "blocked" | "away";
12
- type ZoneKind = "queue" | "work" | "review" | "done";
13
- type LinkKind = "message" | "overlap" | "conflict" | "cohort";
14
- interface Link { panel: string; params?: Record<string, string> }
15
- export interface SpaceScene {
16
- actors: { id: string; name: string; state: ActorState; pet?: string; card?: string;
17
- marks?: { kind: "approval" | "inbox" | "paused" | "mode"; text: string }[]; link: Link }[];
18
- zones: { id: string; title: string; kind?: ZoneKind; count: number }[];
19
- cards: { id: string; title: string; zone: string; owner?: string; tone?: Tone; link: Link }[];
20
- links?: { kind: LinkKind; from: string; to: string; label?: string; at?: string }[];
21
- }
14
+ export type { SpaceScene };
15
+
16
+ type ActorState = SpaceScene["actors"][number]["state"];
17
+ type ZoneKind = NonNullable<SpaceScene["zones"][number]["kind"]>;
18
+ type LinkKind = NonNullable<SpaceScene["links"]>[number]["kind"];
19
+ type Link = SpaceScene["actors"][number]["link"];
20
+ type Group = NonNullable<SpaceScene["groups"]>[number];
22
21
 
23
22
  const ZONES: Record<string, { kind: ZoneKind; title: string }> = {
24
23
  backlog: { kind: "queue", title: "Backlog" },
@@ -28,6 +27,10 @@ const ZONES: Record<string, { kind: ZoneKind; title: string }> = {
28
27
  const clip = (text: string, max = 200) => text.length > max ? `${text.slice(0, max - 1)}…` : text;
29
28
  const ID = /[^A-Za-z0-9._:-]/g;
30
29
  const safeId = (text: string) => text.replace(ID, "_").slice(0, 128);
30
+ const ROLE_LIMIT = 4, ROLE_TEXT_LIMIT = 32;
31
+ /** acon's role bounds: at most 4 public role names of at most 32 characters, in the configured order. */
32
+ const rolesOf = (configured: readonly string[] | undefined): string[] =>
33
+ (configured ?? []).filter((role) => typeof role === "string" && role.trim().length > 0 && role.length <= ROLE_TEXT_LIMIT).slice(0, ROLE_LIMIT);
31
34
 
32
35
  /** officeModel desk condition -> SpaceScene actor state (the shell picks pet rows by state). */
33
36
  function actorState(condition: string, attached: boolean, approvals: number, needsReview: number): ActorState {
@@ -40,12 +43,13 @@ function actorState(condition: string, attached: boolean, approvals: number, nee
40
43
  }
41
44
 
42
45
  /**
43
- * Maps one project's office scene. `project.id` prefixes every id so scenes from several projects never collide;
44
- * `project.label` (set when more than one project runs) is prefixed to actor names.
46
+ * Maps one project's office scene. `project.id` prefixes every id so scenes from several projects never collide, and it
47
+ * names the scene's group too (#1375): every actor, zone and card carries that `group`, and actor names stay bare because
48
+ * the console shows the group itself. `project.label` titles the group when the caller has a human name for the project.
45
49
  */
46
50
  export function officeSpace(model: OfficeScene, project: { id: string; label?: string }, now?: number): SpaceScene {
47
51
  const pre = (id: string | number) => safeId(`${project.id}:${id}`);
48
- const name = (peer: string) => clip(project.label ? `${project.label} / ${peer}` : peer, 64);
52
+ const group: Group = { id: safeId(project.id), title: clip((project.label ?? project.id).trim(), 200) || safeId(project.id) };
49
53
  // Links name the owning project so a multi-project console opens the right one (the panel's show() selects it).
50
54
  const board: Link = { panel: "board", params: { project: project.id } }, agents: Link = { panel: "agents", params: { project: project.id } };
51
55
  const actors: SpaceScene["actors"] = model.desks.map((desk) => {
@@ -58,10 +62,14 @@ export function officeSpace(model: OfficeScene, project: { id: string; label?: s
58
62
  // The card is only the bubble's attributed task ("#id ..."): a peer reviewing #2 while owning #1 shows #2, an empty bubble shows none.
59
63
  const attributed = /^#(\d+) /.exec(desk.bubble)?.[1];
60
64
  const card = attributed ? { id: Number(attributed) } : undefined;
61
- return { id: pre(desk.id), name: name(desk.id), state: actorState(desk.condition, desk.attached, desk.approvals, desk.tray.needsReview),
62
- ...(card ? { card: pre(card.id) } : {}), ...(marks.length ? { marks } : {}), link: agents };
65
+ // `since` is only what the model holds: the open turn's start, so it is present while the actor is working and absent
66
+ // for every other state, which has no change time here. Roles are the project's configured ones, bounded by acon.
67
+ const roles = rolesOf(desk.roles);
68
+ const since = desk.condition === "busy" && desk.turnSince !== undefined ? new Date(desk.turnSince).toISOString() : undefined;
69
+ return { id: pre(desk.id), name: clip(desk.id, 64), state: actorState(desk.condition, desk.attached, desk.approvals, desk.tray.needsReview), group: group.id,
70
+ ...(card ? { card: pre(card.id) } : {}), ...(roles.length ? { roles } : {}), ...(since ? { since } : {}), ...(marks.length ? { marks } : {}), link: agents };
63
71
  });
64
- const zones: SpaceScene["zones"] = model.rooms.map((room) => ({ id: pre(room.id), title: ZONES[room.id]?.title ?? clip(room.label, 60), ...(ZONES[room.id] ? { kind: ZONES[room.id]!.kind } : {}), count: Math.max(0, room.count) }));
72
+ const zones: SpaceScene["zones"] = model.rooms.map((room) => ({ id: pre(room.id), title: ZONES[room.id]?.title ?? clip(room.label, 60), ...(ZONES[room.id] ? { kind: ZONES[room.id]!.kind } : {}), count: Math.max(0, room.count), group: group.id }));
65
73
  const zoneOf = (placement: string | undefined): string | undefined => {
66
74
  if (!placement) return undefined;
67
75
  if (placement.startsWith("room:")) return pre(placement.slice(5));
@@ -78,7 +86,7 @@ export function officeSpace(model: OfficeScene, project: { id: string; label?: s
78
86
  if (!zone) continue;
79
87
  const tone: Tone = card.rework ? "err" : card.waiting ? "warn" : card.state === "approved" ? "ok" : "neutral";
80
88
  // label is "#id public title"; the public view already stubs a private task as [pii].
81
- cards.push({ id: pre(card.id), title: clip(card.label), zone, ...(card.owner ? { owner: pre(card.owner) } : {}), tone, link: board });
89
+ cards.push({ id: pre(card.id), title: clip(card.label), zone, ...(card.owner ? { owner: pre(card.owner) } : {}), tone, group: group.id, link: board });
82
90
  }
83
91
  const desks = new Set(model.desks.map((d) => d.id));
84
92
  const links: NonNullable<SpaceScene["links"]> = [];
@@ -100,20 +108,32 @@ export function officeSpace(model: OfficeScene, project: { id: string; label?: s
100
108
  // An attributed task that is not on the floor (not placed) has no card to point at.
101
109
  const placedCards = new Set(cards.map((c) => c.id));
102
110
  for (const actor of actors) if (actor.card && !placedCards.has(actor.card)) delete actor.card;
103
- return { actors, zones, cards, links };
111
+ return { groups: [group], actors, zones, cards, links };
104
112
  }
105
113
 
106
- /** acon's SPACE_CAPS: a scene over them fails conformance, so the plugin trims before sending (newest links kept). */
107
- export const SPACE_CAPS = { actors: 32, cards: 200, links: 64 } as const;
114
+ /** acon's caps: `actors`, `cards` and `links` are its SPACE_CAPS, `groups` its item bound; over them a scene fails conformance. */
115
+ export const SPACE_CAPS = { actors: 96, groups: 200, cards: 200, links: 128 } as const;
108
116
 
109
- /** Joins per-project scenes within acon's caps. */
117
+ /** Joins per-project scenes within acon's caps, keeping every reference inside what was kept. */
110
118
  export function mergeSpaces(scenes: SpaceScene[]): SpaceScene {
119
+ // Declare groups first: a record's `group` must reference one of them, so a scene past the group bound loses the reference
120
+ // (pruned like `owner` and `card` below, never left as a dangling id) instead of the whole scene failing conformance; one
121
+ // group per project, so only 200+ running projects reach that.
122
+ const groups: Group[] = [], declared = new Set<string>();
123
+ for (const group of scenes.flatMap((s) => s.groups ?? [])) {
124
+ if (groups.length >= SPACE_CAPS.groups) break;
125
+ if (declared.has(group.id)) continue;
126
+ declared.add(group.id);
127
+ groups.push({ id: group.id, title: group.title });
128
+ }
129
+ const grouped = <T extends { group?: string }>(row: T): T => row.group === undefined || declared.has(row.group) ? row : (({ group: _group, ...rest }) => rest as T)(row);
111
130
  // Cap actors and cards first, then keep only references inside what was kept, so links to cut actors never crowd out visible ones.
112
- const actors = scenes.flatMap((s) => s.actors).slice(0, SPACE_CAPS.actors);
131
+ const actors = scenes.flatMap((s) => s.actors).slice(0, SPACE_CAPS.actors).map(grouped);
113
132
  const actorIds = new Set(actors.map((a) => a.id));
114
- const cards = scenes.flatMap((s) => s.cards).slice(0, SPACE_CAPS.cards).map((c) => c.owner && !actorIds.has(c.owner) ? (({ owner: _owner, ...rest }) => rest)(c) : c);
133
+ const cards = scenes.flatMap((s) => s.cards).slice(0, SPACE_CAPS.cards).map((c) => c.owner && !actorIds.has(c.owner) ? (({ owner: _owner, ...rest }) => rest)(c) : c).map(grouped);
115
134
  const cardIds = new Set(cards.map((c) => c.id));
116
135
  const kept = actors.map((a) => a.card && !cardIds.has(a.card) ? (({ card: _card, ...rest }) => rest)(a) : a);
136
+ const zones = scenes.flatMap((s) => s.zones).map(grouped);
117
137
  const links = scenes.flatMap((s) => s.links ?? []).filter((l) => actorIds.has(l.from) && actorIds.has(l.to));
118
- return { actors: kept, zones: scenes.flatMap((s) => s.zones), cards, links: links.slice(Math.max(0, links.length - SPACE_CAPS.links)) };
138
+ return { groups, actors: kept, zones, cards, links: links.slice(Math.max(0, links.length - SPACE_CAPS.links)) };
119
139
  }
package/src/ui/plugin.ts CHANGED
@@ -8,9 +8,10 @@ import { guidanceLines, guidanceProbeStatusLines } from "./guidance-view.ts";
8
8
  * no action: every action is checked against the manager's own whitelist, and every view against DASHBOARD_VIEWS.
9
9
  * D2: the panel is the `ahub ui` dashboard itself, built from renderDashboard(), with post() routed to the host.
10
10
  *
11
- * Contract: @staix/agent-console api 1, declared structurally below so agent-hub keeps zero runtime dependencies.
11
+ * Contract: @staix/agent-console api 1. The manifest type is acon's own, imported type-only (#1375); the provider and item
12
+ * shapes below stay structural so agent-hub keeps zero runtime dependencies.
12
13
  */
13
- import type { VisualPayload, VisualSide, ActionMeta } from "@staix/agent-console/contract";
14
+ import type { VisualPayload, VisualSide, ActionMeta, ConsolePanelManifest } from "@staix/agent-console/contract";
14
15
  import { createHash } from "node:crypto";
15
16
  import { join } from "node:path";
16
17
  import { Registry } from "../hub/registry.ts";
@@ -49,11 +50,8 @@ export interface ConsoleProvider {
49
50
  close?(): Promise<void>;
50
51
  }
51
52
  export interface ConsolePlugin {
52
- manifest: {
53
- api: 1; tool: string; version: string; title: string; icon?: string; pollMs?: number;
54
- panels: { id: string; title: string; order?: number }[];
55
- capabilities?: { actions?: string[]; confirm?: boolean; multiProject?: boolean; inbox?: boolean; space?: boolean };
56
- };
53
+ /** acon's own manifest type, imported type-only: a field or bound the console does not know fails typecheck here (#1375). */
54
+ manifest: ConsolePanelManifest;
57
55
  open(ctx: { home: string; log(line: string): void; features?: readonly string[] }): Promise<ConsoleProvider>;
58
56
  }
59
57
 
@@ -414,9 +412,11 @@ export function createProvider(options: { visualPolicy?: (cwd: string) => Promis
414
412
  const cursor = Number.isSafeInteger(snap.cursor) && Number(snap.cursor) >= 0 ? Number(snap.cursor) : 0;
415
413
  next.set(project.id, { instanceId: project.instanceId, cursor, model });
416
414
  cursors.push([project.id, project.instanceId, cursor]);
417
- const label = projects.length > 1 ? (project.root.split("/").filter(Boolean).pop() ?? project.id) : undefined;
415
+ // #1375: the project is the scene's group, always named by its directory, so the console shows the group instead of a
416
+ // name prefix on every actor (a lone project's id is not a human name).
417
+ const label = project.root.split("/").filter(Boolean).pop() ?? project.id;
418
418
  // Keep the wall clock here even when the model is reused: message arcs expire without a daemon event.
419
- scenes.push(officeSpace(model, { id: project.id, ...(label ? { label } : {}) }, Date.now()));
419
+ scenes.push(officeSpace(model, { id: project.id, label }, Date.now()));
420
420
  }
421
421
  const scene = mergeSpaces(scenes);
422
422
  if (generation !== inboxGeneration) return { scene, cursor: 0 };
@@ -643,11 +643,21 @@ export function createProvider(options: { visualPolicy?: (cwd: string) => Promis
643
643
  }
644
644
  }
645
645
 
646
+ /**
647
+ * #1375 (acon#105): how long acon may reuse a snapshot instead of asking again, 0-60000 ms. The inbox provider serves a
648
+ * result under its own `inboxFreshMs` as it is and recomputes past it, so declaring more than that would hand the console a
649
+ * value the provider would already have refreshed, and a person acts on an approval it missed. A Space scene's only
650
+ * time-dependent content is its message arcs, which expire on a 10 s window, so one poll interval of reuse cannot show the
651
+ * page anything older than the poll it would have drawn anyway.
652
+ */
653
+ const POLL_MS = 2_000, INBOX_MAX_AGE_MS = 1_000, SPACE_MAX_AGE_MS = POLL_MS;
654
+
646
655
  const plugin: ConsolePlugin = {
647
656
  manifest: {
648
- api: 1, tool: "ahub", version, title: "agent-hub", icon: "agents", pollMs: 2000,
657
+ api: 1, tool: "ahub", version, title: "agent-hub", icon: "agents", pollMs: POLL_MS,
649
658
  panels: [...DASHBOARD_VIEWS.map((id, order) => ({ id, title: TITLES[id], order })), { id: "guidance", title: "Guidance", order: DASHBOARD_VIEWS.length }],
650
- capabilities: { actions: [...FORWARDED, ...INBOX_VERBS, ...QUESTION_ACTIONS, ...RESULT_ADVERTISED, ...REVIEW_ACTIONS], confirm: true, multiProject: true, inbox: true, space: true },
659
+ capabilities: { actions: [...FORWARDED, ...INBOX_VERBS, ...QUESTION_ACTIONS, ...RESULT_ADVERTISED, ...REVIEW_ACTIONS], confirm: true, multiProject: true,
660
+ inbox: true, inboxMaxAgeMs: INBOX_MAX_AGE_MS, space: true, spaceMaxAgeMs: SPACE_MAX_AGE_MS },
651
661
  },
652
662
  async open(ctx) { return createProvider({ home: ctx.home, log: ctx.log, features: ctx.features }); },
653
663
  };