@staix/agent-hub 0.46.1 → 0.48.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.
- package/CHANGELOG.md +85 -0
- package/README.md +12 -6
- package/docs/adding-an-ai-tool.md +20 -4
- package/docs/agent-notes/adapters.md +3 -3
- package/docs/agent-notes/benchmarks.md +7 -1
- package/docs/agent-notes/daemon.md +5 -4
- package/docs/agent-notes/tasks.md +4 -2
- package/docs/agent-notes/tests.md +3 -0
- package/docs/contracts/companion-cli-v1.json +3 -0
- package/docs/data-policy.md +9 -0
- package/docs/design/adapters.md +14 -0
- package/docs/design/cli-output-inventory.md +362 -0
- package/docs/design/cli-output.md +42 -1
- package/docs/design/execution-reference.md +5 -2
- package/docs/design/guidance-probes.md +14 -2
- package/docs/design/refusal-inventory.md +26 -0
- package/docs/design/roadmap.md +4 -0
- package/docs/design/task-board.md +17 -1
- package/docs/dogfood.md +27 -11
- package/docs/events.md +9 -0
- package/docs/friction.md +46 -0
- package/docs/memory.md +35 -3
- package/docs/operations.md +95 -16
- package/docs/profiles.md +1 -0
- package/docs/quickstart.md +14 -2
- package/docs/roles.md +6 -0
- package/docs/sdlc.md +44 -1
- package/docs/security.md +29 -12
- package/docs/specs/2026-09-19-agent-hub-design.md +17 -0
- package/docs/specs/2026-09-19-multi-project-design.md +7 -1
- package/docs/verification/2026-11-25-agy-1.5.16.md +31 -0
- package/docs/verification/2026-11-25-claude-implementer-2.1.332.md +47 -0
- package/docs/verification/2026-11-25-codex-0172-reviewer-isolation.md +47 -0
- package/docs/verification/2026-11-25-kimi-272-reviewer-compat.md +38 -0
- package/docs/verification/2026-11-25-kimi-tui-272.md +14 -0
- package/docs/verification/2026-11-25-pi-160-compat.md +40 -0
- package/docs/verification/2026-11-26-0.47.0.md +43 -0
- package/docs/verification/2026-11-26-0.48.0.md +45 -0
- package/docs/verification/2026-11-26-codex-0172-reviewer-tool-call.md +29 -0
- package/docs/verification/dogfood/2026-11-24.md +2829 -0
- package/docs/verification/pi-160-model-free.ts +57 -0
- package/docs/verification/pi-160-native.mjs +21 -0
- package/docs/verified.json +44 -32
- package/package.json +2 -2
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +598 -131
- package/plugins/agent-hub/server.js +687 -143
- package/src/adapters/acp.ts +5 -0
- package/src/adapters/channel-peer.ts +7 -0
- package/src/adapters/claude-print-child.ts +27 -5
- package/src/adapters/codex-appserver.ts +9 -0
- package/src/adapters/compat.ts +12 -11
- package/src/adapters/configured-acp.ts +45 -2
- package/src/adapters/configured-print.ts +163 -0
- package/src/adapters/conformance/index.ts +1 -0
- package/src/adapters/conformance/print.ts +57 -0
- package/src/adapters/definitions/native-activity.ts +57 -0
- package/src/adapters/definitions/native-factories.ts +4 -2
- package/src/adapters/jcode.ts +10 -2
- package/src/adapters/local-probe.ts +59 -14
- package/src/adapters/local-worker.ts +20 -6
- package/src/adapters/registry-types.ts +5 -3
- package/src/adapters/role-eligibility.ts +5 -0
- package/src/cli/bench.ts +2 -1
- package/src/cli/broker.ts +2 -1
- package/src/cli/capabilities-output.ts +10 -14
- package/src/cli/configured-acp-entry.ts +10 -2
- package/src/cli/console-state.ts +25 -5
- package/src/cli/error-format.ts +2 -0
- package/src/cli/guidance.ts +1 -1
- package/src/cli/handoff-output.ts +20 -17
- package/src/cli/help.ts +79 -41
- package/src/cli/init-settings.ts +15 -0
- package/src/cli/intake-output.ts +13 -13
- package/src/cli/launch.ts +3 -2
- package/src/cli/learn-output.ts +40 -21
- package/src/cli/main.ts +150 -79
- package/src/cli/memory.ts +47 -2
- package/src/cli/output.ts +54 -31
- package/src/cli/roadmap.ts +2 -2
- package/src/cli/room-output.ts +71 -0
- package/src/cli/room.ts +19 -33
- package/src/cli/schedule-output.ts +20 -19
- package/src/cli/sdlc-output.ts +188 -170
- package/src/cli/source-output.ts +17 -14
- package/src/cli/specs.ts +13 -13
- package/src/cli/study-output.ts +66 -69
- package/src/cli/task-output.ts +106 -158
- package/src/cli/terminal-recovery.ts +2 -1
- package/src/cli/upgrade-runtime.ts +2 -1
- package/src/cli/warn-line.ts +18 -0
- package/src/cli/worktrees-output.ts +25 -23
- package/src/hub/audit-source.ts +45 -0
- package/src/hub/board.ts +141 -5
- package/src/hub/bus.ts +13 -2
- package/src/hub/config-apply.ts +14 -1
- package/src/hub/config-trust.ts +1 -0
- package/src/hub/control-client.ts +1 -1
- package/src/hub/daemon.ts +390 -47
- package/src/hub/guidance-probe-store.ts +51 -10
- package/src/hub/guidance-probes.ts +25 -7
- package/src/hub/handoff.ts +5 -1
- package/src/hub/hub-tools.ts +23 -5
- package/src/hub/instance-config.ts +3 -3
- package/src/hub/learn-followup.ts +103 -0
- package/src/hub/learning.ts +63 -1
- package/src/hub/manager.ts +15 -1
- package/src/hub/memory-policy.ts +2 -1
- package/src/hub/memory-review.ts +217 -0
- package/src/hub/peer-activity.ts +37 -0
- package/src/hub/peers.ts +3 -0
- package/src/hub/project-move.ts +258 -0
- package/src/hub/registry.ts +16 -5
- package/src/hub/restart.ts +7 -0
- package/src/hub/review-brief.ts +8 -4
- package/src/hub/review-checkout.ts +26 -0
- package/src/hub/review-findings.ts +6 -3
- package/src/hub/risk-tier.ts +129 -0
- package/src/hub/roadmap-check.ts +1 -0
- package/src/hub/routing.ts +3 -1
- package/src/hub/sdlc-merge.ts +9 -0
- package/src/hub/sdlc-metrics.ts +24 -1
- package/src/hub/sdlc-queue.ts +1 -1
- package/src/hub/sdlc.ts +15 -6
- package/src/hub/settings.ts +2 -0
- package/src/hub/spec-readback.ts +136 -0
- package/src/hub/specs.ts +1 -1
- package/src/hub/task-list-page.ts +1 -1
- package/src/hub/tasks.ts +586 -80
- package/src/hub/ui.ts +4 -2
- package/src/local/probe-types.ts +1 -0
- package/src/local/probe-workspace.ts +49 -0
- package/src/omniroute/client.ts +19 -3
- package/src/ui/guidance-panel.ts +2 -2
- package/src/ui/guidance-view.ts +4 -2
- package/src/ui/index.html +26 -2
- package/src/ui/overview-model.ts +138 -0
- package/src/ui/plugin.ts +30 -4
- package/templates/roles/ops/project-manager.md +1 -1
package/src/adapters/jcode.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ActivityTable } from "./definitions/native-activity.ts";
|
|
1
2
|
import { spawn, spawnSync, type ChildProcess } from "node:child_process";
|
|
2
3
|
import { assessVersion, COMPAT, type CompatVerdict } from "./compat.ts";
|
|
3
4
|
import { createConnection } from "node:net";
|
|
@@ -95,6 +96,13 @@ export class JcodeTuiRefusal extends Error {
|
|
|
95
96
|
}
|
|
96
97
|
/** #1085: said by `ahub status` while a recovered headless Jcode has not yet opened its TUI, and by the launcher when `ahub jcode` finds it running headless. */
|
|
97
98
|
export const JCODE_HEADLESS_AFTER_RECOVERY = "jcode is running headless after recovery; run ahub stop jcode, then ahub jcode to get its TUI back";
|
|
99
|
+
/**
|
|
100
|
+
* #1668: what `ahub status` says while a rostered Jcode peer's socket is served by a server the hub did not start, handed to the daemon by the hello that
|
|
101
|
+
* admission refused. It names the cause class and the launch that puts the peer back under the hub, and carries no launch id, socket or path.
|
|
102
|
+
*/
|
|
103
|
+
export function jcodeDetachedNotice(peer: string): { cause: string; command: string } {
|
|
104
|
+
return { cause: "a Jcode server the hub did not start is serving this peer's socket, so its work continues outside the hub", command: peer === "jcode" ? "ahub jcode" : `ahub jcode --as ${peer}` };
|
|
105
|
+
}
|
|
98
106
|
const JCODE_OWNED_ENV = { JCODE_DISABLE_CLAUDE_MCP: "1", JCODE_NO_TELEMETRY: "1" } as const;
|
|
99
107
|
/** #691: the verdict lives in `src/adapters/compat.ts` (line, verified versions, the person's trust); never pin here. */
|
|
100
108
|
export const jcodeVersionSupported = (version: unknown): boolean => assessVersion("jcode", version).ok;
|
|
@@ -219,7 +227,7 @@ export class JcodePeer extends AcpPeer {
|
|
|
219
227
|
/** #1085: a ready TUI launch was served for this owned launch, so the person is on the way to its TUI. */
|
|
220
228
|
private tuiServed = false;
|
|
221
229
|
|
|
222
|
-
constructor(private readonly jcode: JcodeOptions) {
|
|
230
|
+
constructor(private readonly jcode: JcodeOptions, activityKinds?: ActivityTable) {
|
|
223
231
|
if (!isAbsolute(jcode.home)) throw new Error("jcode_home must be an absolute native data path");
|
|
224
232
|
const peer = jcode.peer ?? "jcode";
|
|
225
233
|
jcodeCommand(jcode.command, "acp", "preview", jcode.cwd);
|
|
@@ -229,7 +237,7 @@ export class JcodePeer extends AcpPeer {
|
|
|
229
237
|
const launchId = crypto.randomUUID();
|
|
230
238
|
// The ACP child gets peerChildEnv(this.id): the instance id, so its hub tools act as this peer and never as the base Jcode. The launch id
|
|
231
239
|
// goes with it: the daemon admits a hub-tools hello for this peer only when it carries the id of this peer's current owned launch (#368).
|
|
232
|
-
super(peer, { ...jcode, cmd, env: { ...jcode.env, JCODE_HOME: jcode.home, JCODE_SOCKET: socket, AGENTHUB_LAUNCH_ID: launchId, ...JCODE_OWNED_ENV }, mcpServers: [], preamble: jcodePreamble(jcode.preamble), requireLoadSessionEcho: true, expectedAgent: { name: "jcode", version: jcodeVersionSupported } });
|
|
240
|
+
super(peer, { ...jcode, cmd, env: { ...jcode.env, JCODE_HOME: jcode.home, JCODE_SOCKET: socket, AGENTHUB_LAUNCH_ID: launchId, ...JCODE_OWNED_ENV }, mcpServers: [], preamble: jcodePreamble(jcode.preamble), requireLoadSessionEcho: true, expectedAgent: { name: "jcode", version: jcodeVersionSupported } }, activityKinds);
|
|
233
241
|
this.root = root; this.socket = socket; this.launchId = launchId;
|
|
234
242
|
}
|
|
235
243
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
+
import { hubGitSync } from "../hub/git.ts";
|
|
2
3
|
import { LocalPeer, localProbeFingerprints, prepareLocalProbeInput } from "./local-worker.ts";
|
|
3
|
-
import { GUIDANCE_PROBE_LIMITS, GUIDANCE_PROBE_MODEL, guidanceProbeCanonical, guidanceProbeManifestKey, probeHash,
|
|
4
|
+
import { GUIDANCE_PROBE_LIMITS, GUIDANCE_PROBE_LIVE_LIMITS, GUIDANCE_PROBE_MODEL, guidanceProbeCanonical, guidanceProbeManifestKey, probeHash,
|
|
4
5
|
type ProbeFakeLaunch, type ProbeFakeObservation, type ProbeMeasuredSession, type ProbeReceiptLimit, type ProbeReservation, type ProbeRetainedRecord, type ProbeResourceCharges, type ProbeSlot, type ProbeStoredState } from "../hub/guidance-probes.ts";
|
|
5
|
-
import { collectProbeOutput, materializeProbeWorkspace, probeWorkspaceCurrent, PROBE_WORKSPACE_LIMITS, removeRetained, retainProbeOutput,
|
|
6
|
+
import { collectProbeOutput, materializeProbeWorkspace, probeWorkspaceCurrent, PROBE_WORKSPACE_LIMITS, releaseEmptyProbeWorkspace, removeRetained, retainProbeOutput,
|
|
6
7
|
type ProbeWorkspace } from "../local/probe-workspace.ts";
|
|
7
8
|
import { ProbeConfinementError, requireProbeConfinement, verifyProbeConfinement, type ProbeConfinement } from "../local/probe-sandbox.ts";
|
|
8
9
|
import { ProbeLocalError, probeLocalEffect, type ProbeLocalAdapter, type ProbeLocalAdapterOptions, type ProbeLocalEffectScope,
|
|
@@ -25,6 +26,9 @@ interface Owned {
|
|
|
25
26
|
closeUnknown?: () => Promise<void>;
|
|
26
27
|
closed: boolean;
|
|
27
28
|
closeFailed?: boolean;
|
|
29
|
+
timedOut?: boolean;
|
|
30
|
+
releaseAttempted?: boolean;
|
|
31
|
+
releaseFailed?: boolean;
|
|
28
32
|
/** Output collected and retained once, after the stop reported quiescence and before the host releases the workspace. */
|
|
29
33
|
harvest?: { output: ProbeMeasuredSession["output"]; scratchBytes: number; limits: ProbeReceiptLimit[]; retained?: ProbeMeasuredSession["retained"] };
|
|
30
34
|
}
|
|
@@ -36,8 +40,32 @@ function freeze<T>(value: T): T {
|
|
|
36
40
|
return value;
|
|
37
41
|
}
|
|
38
42
|
|
|
39
|
-
|
|
43
|
+
const LIVE_GUIDANCE_PROBE_CONFIG = Object.freeze({ maxSteps: GUIDANCE_PROBE_LIVE_LIMITS.modelCalls, maxOutputTokens: GUIDANCE_PROBE_LIVE_LIMITS.maxOutputTokens, tokenUpperBound: GUIDANCE_PROBE_LIVE_LIMITS.tokens });
|
|
44
|
+
|
|
45
|
+
/** The initial live leg materializes only the empty tree and no admitted files. */
|
|
46
|
+
export function createLiveGuidanceProbeLocalAdapter(
|
|
47
|
+
options: Omit<ProbeLocalAdapterOptions, "fixture" | "config" | "resolveInput"> & { cwd: string },
|
|
48
|
+
): ProbeLocalAdapter {
|
|
49
|
+
return createLocalAdapter({ ...options, config: LIVE_GUIDANCE_PROBE_CONFIG,
|
|
50
|
+
resolveInput(state, slot) {
|
|
51
|
+
const { manifest, snapshots } = state.registration;
|
|
52
|
+
const { objectFormat, oid } = manifest.inputs.codeTree;
|
|
53
|
+
if (slot.role !== "worker" || snapshots.dataPolicy.admittedData.length || snapshots.dataPolicy.roles.worker.dataIds.length
|
|
54
|
+
|| oid !== createHash(objectFormat).update("tree 0").update(Buffer.alloc(1)).digest("hex")) throw new ProbeLocalError("invalid");
|
|
55
|
+
const format = hubGitSync(["-C", options.cwd, "rev-parse", "--show-object-format"], { encoding: "utf8", timeout: 5000, maxBuffer: 1024 });
|
|
56
|
+
if (format.error || format.status !== 0 || format.stdout.trim() !== objectFormat) throw new ProbeLocalError("drift");
|
|
57
|
+
return { files: [], verifySource: () => { throw new ProbeLocalError("invalid"); } };
|
|
58
|
+
},
|
|
59
|
+
}, true);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Constructor-only fixture adapter. */
|
|
40
63
|
export function createGuidanceProbeLocalAdapter(options: ProbeLocalAdapterOptions): ProbeLocalAdapter {
|
|
64
|
+
return createLocalAdapter(options, false);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function createLocalAdapter(options: ProbeLocalAdapterOptions, live: boolean): ProbeLocalAdapter {
|
|
68
|
+
if (live && options.fixture) throw new ProbeLocalError("invalid");
|
|
41
69
|
if (options.fixture && options.fixture.evidence !== "fixture_only") throw new ProbeLocalError("invalid");
|
|
42
70
|
const current = options.current.bind(options), resolveInput = options.resolveInput.bind(options), permit = options.permit.bind(options), omni = options.omni;
|
|
43
71
|
const workspaceOwned = options.workspaceOwned?.bind(options);
|
|
@@ -127,20 +155,30 @@ export function createGuidanceProbeLocalAdapter(options: ProbeLocalAdapterOption
|
|
|
127
155
|
};
|
|
128
156
|
const measuredSession = (entry: Owned, servedModel: string | null, flags: { unavailable: boolean }): Omit<ProbeMeasuredSession, "startedAt"> => ({
|
|
129
157
|
servedModel, workerEffectiveInputSha256: null, nonGuidanceInputSha256: null, runtime: hostRuntime(),
|
|
130
|
-
teardownVerified: entry.closed && !entry.closeFailed, cancelled: entry.controller.signal.aborted
|
|
158
|
+
teardownVerified: entry.closed && !entry.closeFailed && !entry.releaseFailed, cancelled: entry.controller.signal.aborted && !entry.timedOut,
|
|
159
|
+
timedOut: entry.timedOut === true, unavailable: flags.unavailable,
|
|
131
160
|
limits: entry.harvest?.limits ?? [], scratchBytes: entry.harvest?.scratchBytes ?? 0,
|
|
132
161
|
output: entry.harvest?.output ?? { v: 1, entries: [], excluded: [], totalBytes: 0 }, ...(entry.harvest?.retained ? { retained: entry.harvest.retained } : {}),
|
|
133
162
|
});
|
|
163
|
+
const release = (entry: Owned): void => {
|
|
164
|
+
if (!live || !entry.workspace || !entry.closed || entry.releaseAttempted) return;
|
|
165
|
+
entry.releaseAttempted = true;
|
|
166
|
+
try { releaseEmptyProbeWorkspace(entry.workspace); }
|
|
167
|
+
catch { entry.releaseFailed = true; }
|
|
168
|
+
};
|
|
134
169
|
const observation = (input: ProbeFakeLaunch, ready: Prepared, servedModel: string | null, outcome: ProbeFakeObservation["outcome"], usage: ProbeFakeObservation["usage"],
|
|
135
|
-
entry?: Owned, unavailable = false): ProbeFakeObservation =>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
170
|
+
entry?: Owned, unavailable = false): ProbeFakeObservation => {
|
|
171
|
+
const delivered = input.slot.role === "worker" && (!live || entry?.peer?.probeObservation().providerResponded);
|
|
172
|
+
return {
|
|
173
|
+
reservation: input.reservation, outcome, servedModel, inputFrameHash: ready.input.inputSha256,
|
|
174
|
+
workerEffectiveInputHash: input.slot.role === "worker" ? ready.input.inputSha256 : null,
|
|
175
|
+
nonGuidanceInputSha256: input.slot.role === "worker" ? ready.input.nonGuidanceInputSha256 : null,
|
|
176
|
+
candidateArtifactSha256: null, usage,
|
|
177
|
+
...(entry ? { measured: { ...measuredSession(entry, servedModel, { unavailable }),
|
|
178
|
+
workerEffectiveInputSha256: delivered ? ready.input.inputSha256 : null,
|
|
179
|
+
nonGuidanceInputSha256: delivered ? ready.input.nonGuidanceInputSha256 : null } } : {}),
|
|
180
|
+
};
|
|
181
|
+
};
|
|
144
182
|
return {
|
|
145
183
|
prepareWorkerFrame: async (state, slot, guidance) => {
|
|
146
184
|
const record = await prepare(state, slot, guidance);
|
|
@@ -159,6 +197,8 @@ export function createGuidanceProbeLocalAdapter(options: ProbeLocalAdapterOption
|
|
|
159
197
|
const entry: Owned = { reservation: input.reservation, controller: new AbortController(), closed: false };
|
|
160
198
|
owned.set(id, entry);
|
|
161
199
|
const abort = () => entry.controller.abort(); signal.addEventListener("abort", abort, { once: true });
|
|
200
|
+
const timeout = live ? setTimeout(() => { entry.timedOut = true; abort(); }, GUIDANCE_PROBE_LIVE_LIMITS.elapsedMs) : undefined;
|
|
201
|
+
timeout?.unref?.();
|
|
162
202
|
let sequence = 0;
|
|
163
203
|
const sourceCurrent = () => {
|
|
164
204
|
if (signal.aborted || entry.controller.signal.aborted || entry.closed) throw new ProbeLocalError("interrupted");
|
|
@@ -191,11 +231,14 @@ export function createGuidanceProbeLocalAdapter(options: ProbeLocalAdapterOption
|
|
|
191
231
|
entry.confinement = await (fixture ? fixture.confine(entry.workspace) : verifyProbeConfinement(entry.workspace, entry.controller.signal));
|
|
192
232
|
if (entry.confinement.workspace !== entry.workspace) throw new ProbeLocalError("drift");
|
|
193
233
|
accounting.current();
|
|
234
|
+
const chat = live ? await omni.pinCampusChat(GUIDANCE_PROBE_MODEL) : undefined;
|
|
235
|
+
accounting.current();
|
|
194
236
|
entry.peer = new LocalPeer("local", { cwd: entry.workspace.root, omni, fixedModel: GUIDANCE_PROBE_MODEL,
|
|
195
237
|
maxSteps: config.maxSteps, tools: { deny: [], permit } }, entry.confinement, fixture ? "fixture_only" : undefined);
|
|
196
238
|
const result = await entry.peer.runProbe({ purpose: "guidance_probe", prepared: ready.input, workspace: entry.workspace,
|
|
197
|
-
confinement: entry.confinement, config, accounting, reserve }, entry.controller.signal);
|
|
239
|
+
confinement: entry.confinement, config, accounting, reserve, ...(chat ? { pinnedChat: chat } : {}) }, entry.controller.signal);
|
|
198
240
|
accounting.current(); await close(entry); harvestOutput(entry, ready);
|
|
241
|
+
release(entry);
|
|
199
242
|
effects.current(); current();
|
|
200
243
|
return observation(input, ready, result.servedModel, result.complete ? "closed_fixture" : "failed_known", result.usageKnown ? "known_fixture" : "unknown", entry);
|
|
201
244
|
}).catch(async error => {
|
|
@@ -204,9 +247,11 @@ export function createGuidanceProbeLocalAdapter(options: ProbeLocalAdapterOption
|
|
|
204
247
|
catch { throw new ProbeLocalError("interrupted"); }
|
|
205
248
|
// Only after the stop confirmed quiescence, and only while the workspace is still ours: a drifted workspace is read by identity or not at all.
|
|
206
249
|
harvestOutput(entry, ready);
|
|
250
|
+
release(entry);
|
|
207
251
|
// `unavailable` means the session could not start: a confinement error before any peer existed. Once a peer ran, the Store treats it as unknown or failed.
|
|
208
252
|
return observation(input, ready, entry.peer?.probeObservation().servedModel ?? null, "unknown", "unknown", entry, error instanceof ProbeConfinementError && !entry.peer);
|
|
209
253
|
}).finally(() => {
|
|
254
|
+
clearTimeout(timeout);
|
|
210
255
|
signal.removeEventListener("abort", abort);
|
|
211
256
|
if (entry.closed) { completed.add(entry.reservation); owned.delete(id); }
|
|
212
257
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LOCAL_ACTIVITY, nativeActivity } from "./definitions/native-activity.ts";
|
|
1
2
|
import type { ModelOverrideSelection } from "./registry-types.ts";
|
|
2
3
|
import { isNativeModelToken } from "./model-token.ts";
|
|
3
4
|
import { isReviewObserverExcluded, reviewCaptureExcluded } from "../hub/memory-policy.ts";
|
|
@@ -231,6 +232,7 @@ export class LocalPeer extends BasePeer {
|
|
|
231
232
|
private probeCalls = 0;
|
|
232
233
|
private probeServedModel: string | null = null;
|
|
233
234
|
private probeServedExact = false;
|
|
235
|
+
private probeProviderResponded = false;
|
|
234
236
|
private probeUsageKnown = true;
|
|
235
237
|
private probeToolPlan: ProbeToolResourcePlan | undefined;
|
|
236
238
|
private readonly probePermits = new Set<Promise<unknown>>();
|
|
@@ -347,8 +349,9 @@ export class LocalPeer extends BasePeer {
|
|
|
347
349
|
}
|
|
348
350
|
|
|
349
351
|
/** Private adapter bookkeeping, not an ordinary usage/status observer. */
|
|
350
|
-
probeObservation(): Pick<ProbeLocalResult, "servedModel" | "servedModelExact" | "usageKnown"> {
|
|
351
|
-
return { servedModel: this.probeServedModel, servedModelExact: this.probeServedExact, usageKnown: this.probeUsageKnown
|
|
352
|
+
probeObservation(): Pick<ProbeLocalResult, "servedModel" | "servedModelExact" | "usageKnown"> & { providerResponded: boolean } {
|
|
353
|
+
return { servedModel: this.probeServedModel, servedModelExact: this.probeServedExact, usageKnown: this.probeUsageKnown,
|
|
354
|
+
providerResponded: this.probeProviderResponded };
|
|
352
355
|
}
|
|
353
356
|
|
|
354
357
|
/** Resolves once the turn is claimed; a turn that cannot reach any model hands the envelopes back through onFailed. */
|
|
@@ -511,6 +514,7 @@ export class LocalPeer extends BasePeer {
|
|
|
511
514
|
// A tool has its own timeout (bash up to 600 s) and an approval can take 120 s: neither is the model going silent.
|
|
512
515
|
const alive = this.probeConfinement ? undefined : setInterval(() => this.state === "busy" && turn === this.turn && this.touch(), 30_000);
|
|
513
516
|
const name = call.function.name;
|
|
517
|
+
if (!this.probeConfinement) this.onActivity?.(nativeActivity(LOCAL_ACTIVITY, name, TASK_TOOL_NAMES.has(name) || CONDUCTOR_TOOL_NAMES.has(name) ? "hub" : "unknown"));
|
|
514
518
|
try {
|
|
515
519
|
await this.requireBudget(envs, "tool_calls");
|
|
516
520
|
if (turnSignal.aborted) throw new ExecutionBudgetStop(this.budgetStopReason || "turn cancelled before tool execution");
|
|
@@ -706,15 +710,25 @@ export class LocalPeer extends BasePeer {
|
|
|
706
710
|
const upper = probe.config.tokenUpperBound, inputBytes = Buffer.byteLength(frame, "utf8");
|
|
707
711
|
if (upper !== undefined && (probe.config.maxOutputTokens > upper || inputBytes > upper - probe.config.maxOutputTokens))
|
|
708
712
|
throw new ProbeToolRefusal("token_ceiling");
|
|
713
|
+
const reservedTokens = probe.pinnedChat ? inputBytes + probe.config.maxOutputTokens : upper;
|
|
709
714
|
const result = await probeLocalEffect(probe.accounting, "model_calls", frame, first ? undefined : { inputBytes },
|
|
710
|
-
|
|
715
|
+
reservedTokens, async signal => {
|
|
711
716
|
if (signal.aborted || this.abort?.signal.aborted) throw new ProbeLocalError("interrupted");
|
|
712
|
-
const value =
|
|
717
|
+
const value = probe.pinnedChat
|
|
718
|
+
? await probe.pinnedChat(body, this.abort!.signal)
|
|
719
|
+
: await this.opts.omni.chat(body, { signal: this.abort!.signal });
|
|
720
|
+
if (probe.pinnedChat) {
|
|
721
|
+
this.probeProviderResponded = true;
|
|
722
|
+
this.probeServedExact = value.servedModelExact === true;
|
|
723
|
+
this.probeServedModel = value.servedModel === GUIDANCE_PROBE_MODEL && !this.probeServedExact ? null : value.servedModel ?? null;
|
|
724
|
+
}
|
|
713
725
|
return { value, usage: probeObservedTokens(value) };
|
|
714
726
|
});
|
|
715
727
|
this.probeCalls++;
|
|
716
|
-
|
|
717
|
-
|
|
728
|
+
if (!probe.pinnedChat) {
|
|
729
|
+
this.probeServedModel = result.servedModel ?? null;
|
|
730
|
+
this.probeServedExact = result.servedModelExact === true;
|
|
731
|
+
}
|
|
718
732
|
this.probeUsageKnown = this.probeUsageKnown && probeObservedTokens(result) !== null;
|
|
719
733
|
if (!this.probeUsageKnown) throw new ProbeLocalError("usage");
|
|
720
734
|
if (result.servedModel !== GUIDANCE_PROBE_MODEL || result.servedModelExact !== true) throw new ProbeLocalError("model");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ConfiguredPrintOptions } from "./configured-print.ts";
|
|
1
2
|
/** One host-latched runtime choice; applied binds the captured revision and boundary, never a later value. */
|
|
2
3
|
export interface ModelOverrideSelection {
|
|
3
4
|
readonly model: string | undefined;
|
|
@@ -32,7 +33,7 @@ import type { BuiltinCliEntry } from "./definitions/native-cli-entry-types.ts";
|
|
|
32
33
|
import type { NativePreviewBuilder } from "./definitions/native-cli-preview-common.ts";
|
|
33
34
|
|
|
34
35
|
export type StartForm = "tui" | "headless";
|
|
35
|
-
export type DaemonEngine = "codex-appserver" | "acp" | "qwen-dual" | "owned-acp" | "pi-rpc" | "local-worker" | "claude-print" | "reviewer-print" | "claude-implementer";
|
|
36
|
+
export type DaemonEngine = "codex-appserver" | "acp" | "qwen-dual" | "owned-acp" | "pi-rpc" | "local-worker" | "claude-print" | "reviewer-print" | "claude-implementer" | "configured-print";
|
|
36
37
|
|
|
37
38
|
/** Existing buildLaunch inputs plus the startup-bound instance and project identity. */
|
|
38
39
|
export interface LaunchContext {
|
|
@@ -76,7 +77,8 @@ export type DaemonPorts =
|
|
|
76
77
|
| { local: LocalOptions }
|
|
77
78
|
| { claudePrint: ClaudePrintOptions }
|
|
78
79
|
| { reviewerPrint: ReviewerPrintOptions }
|
|
79
|
-
| { claudeImplementer: ClaudeImplementerOptions }
|
|
80
|
+
| { claudeImplementer: ClaudeImplementerOptions }
|
|
81
|
+
| { configuredPrint: Omit<ConfiguredPrintOptions, "declaration"> };
|
|
80
82
|
|
|
81
83
|
export interface CreateContext<Ports extends DaemonPorts = DaemonPorts> {
|
|
82
84
|
instance: string;
|
|
@@ -239,7 +241,7 @@ export interface AdapterDefinition {
|
|
|
239
241
|
ownedFlags: readonly string[];
|
|
240
242
|
conductorStartArgs?(args: string[]): { mode?: StartForm } | Error;
|
|
241
243
|
};
|
|
242
|
-
identity: { mcp: "acp-session" | "project-file" | "env" | "channel-plugin"; currentChild?: true };
|
|
244
|
+
identity: { mcp: "acp-session" | "project-file" | "env" | "channel-plugin" | "none"; currentChild?: true };
|
|
243
245
|
/** Who owns the session title; only hub-owned slots receive hub_set_title. */
|
|
244
246
|
title?: "native" | "hub";
|
|
245
247
|
/** Fixed builtins only: the title slot survives native-session restoration. Absent means ephemeral. */
|
|
@@ -38,6 +38,7 @@ export function roleEligibility(peer: string, role: EligibleRole, startMode?: St
|
|
|
38
38
|
*/
|
|
39
39
|
export function adapterCeiling(peer: string, declared: readonly string[], catalog?: ProjectAdapterCatalog): string[] {
|
|
40
40
|
const definition = lookup(peer, catalog), ceiling = definition?.routing?.allowedRoles;
|
|
41
|
+
if (definition?.start.daemonPort === "configured-print") return declared.filter(role => role === "advisor" || role === "reviewer");
|
|
41
42
|
return declared.filter(role => (!ceiling || ceiling.includes(role)) && (role !== "planner" || !definition || definition.projection?.plannerEligible === true));
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -47,6 +48,10 @@ export function adapterCeiling(peer: string, declared: readonly string[], catalo
|
|
|
47
48
|
*/
|
|
48
49
|
export function applyRoleCeiling(peer: string, declared: readonly string[], startMode: StartMode | undefined, catalog?: ProjectAdapterCatalog): { roles: string[]; notices: string[] } {
|
|
49
50
|
const definition = lookup(peer, catalog), ceiling = definition?.routing?.allowedRoles;
|
|
51
|
+
if (definition?.start.daemonPort === "configured-print") {
|
|
52
|
+
const roles = adapterCeiling(peer, declared, catalog);
|
|
53
|
+
return { roles, notices: roles.length === declared.length ? [] : [`roles.${peer}: configured print keeps advisory roles only`] };
|
|
54
|
+
}
|
|
50
55
|
const notices: string[] = [];
|
|
51
56
|
const roles = declared.filter(role => {
|
|
52
57
|
if (ceiling && !ceiling.includes(role)) return false;
|
package/src/cli/bench.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { processSignature } from "../pi/process-signature.ts";
|
|
|
13
13
|
import { loadConfig } from "../hub/daemon.ts";
|
|
14
14
|
import { addonState, detectTooling, type Addon, type AddonName } from "../hub/tooling.ts";
|
|
15
15
|
import { VERSION } from "../version.ts";
|
|
16
|
+
import { warnLine } from "./warn-line.ts";
|
|
16
17
|
|
|
17
18
|
/** What the runner needs from the world, so tests can drive it without a terminal. */
|
|
18
19
|
export interface BenchIo {
|
|
@@ -65,7 +66,7 @@ export const defaultIo = (stateDir: string, cwd: string, peer?: string): BenchIo
|
|
|
65
66
|
// ours) is the group killed outright; any other refusal (not provably ours, an unreadable process table) leaves
|
|
66
67
|
// it alone and says so. A leader start-time record at spawn would let stopOwnedProcess sweep it itself.
|
|
67
68
|
if (/still has members \(/.test(error.message)) try { process.kill(-p.pid!, "SIGKILL"); } catch { /* gone */ }
|
|
68
|
-
else
|
|
69
|
+
else warnLine(`bench: a command's process group could not be stopped and may still run in the tree: ${error.message}`);
|
|
69
70
|
});
|
|
70
71
|
return { code: timedOut || interrupted ? null : code ?? null, timedOut, interrupted };
|
|
71
72
|
},
|
package/src/cli/broker.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { join, resolve } from "node:path";
|
|
|
3
3
|
import { BrokerStore, BrokerStoreError } from "../broker/store.ts";
|
|
4
4
|
import { decodeBase64url, RoomCryptoError } from "../rooms/crypto.ts";
|
|
5
5
|
import { startBroker, BrokerServerError, type BrokerOptions } from "../broker/server.ts";
|
|
6
|
+
import { warnLine } from "./warn-line.ts";
|
|
6
7
|
|
|
7
8
|
export const BROKER_USAGE = "usage: ahub broker serve [--hostname <host>] [--port <0..65535>] [--public-url <ws[s]://host/>] [--owner <fingerprint>]... [--state-dir <dir>] | broker room drop <room> --yes [--state-dir <dir>]";
|
|
8
9
|
export function brokerOptions(args: readonly string[], stateDir: string): BrokerOptions {
|
|
@@ -45,7 +46,7 @@ export async function runBrokerCommand(args: readonly string[], stateDir: string
|
|
|
45
46
|
const options = brokerOptions(args, stateDir);
|
|
46
47
|
const broker = await startBroker(options);
|
|
47
48
|
console.log(`broker listening at ${broker.publicUrl} (ciphertext relay; application delivery is not acknowledged here)`);
|
|
48
|
-
const stop = () => { void broker.stop().catch(() => { process.exitCode = 1;
|
|
49
|
+
const stop = () => { void broker.stop().catch(() => { process.exitCode = 1; warnLine("broker: stop failed"); }); };
|
|
49
50
|
process.once("SIGINT", stop); process.once("SIGTERM", stop);
|
|
50
51
|
try { await broker.closed; }
|
|
51
52
|
finally { process.off("SIGINT", stop); process.off("SIGTERM", stop); }
|
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
// Human output for `ahub capabilities` (#445 C1). Pure: parsed hub-tool JSON in, spans out, no I/O. `--json` is the caller's branch and prints the same text.
|
|
2
2
|
// A description is another agent's words: the daemon has already sanitized it, and it is shown here as data on its own row, never as part of a command line.
|
|
3
|
-
import {
|
|
4
|
-
import type
|
|
3
|
+
import { grid, s } from "./sdlc-output.ts";
|
|
4
|
+
import { Report, plural, type Span } from "./console-state.ts";
|
|
5
5
|
|
|
6
6
|
const list = (value: unknown): any[] => Array.isArray(value) ? value : [];
|
|
7
7
|
const dash = (value: unknown) => value === undefined || value === null || value === "" ? "-" : String(value);
|
|
8
8
|
const STATE_TONE: Record<string, "attention" | "muted" | undefined> = { listed: undefined, "digest-changed": "attention", unshared: "muted" };
|
|
9
9
|
|
|
10
10
|
/** `ahub capabilities`: per peer, each capability the hub can see, whether you share it, and the class that would apply to a call. */
|
|
11
|
-
export function renderCapabilities(result: unknown, columns?: number): Span[][] {
|
|
11
|
+
export function renderCapabilities(result: unknown, columns?: number, _now = Date.now(), ascii = false): Span[][] {
|
|
12
12
|
const peers = list((result as { peers?: unknown } | null)?.peers);
|
|
13
|
-
const out
|
|
14
|
-
if (!peers.length)
|
|
15
|
-
out.push(blank, [s("no peer lists a capability: an agent must be attached, on a version the hub has probed, and offer a skill or command", "muted")]);
|
|
16
|
-
return out;
|
|
17
|
-
}
|
|
13
|
+
const out = new Report(columns, ascii).titled("ahub", `Capabilities: ${plural(peers.length, "peer")} listing`);
|
|
14
|
+
if (!peers.length) return out.note("no peer lists a capability: an agent must be attached, on a version the hub has probed, and offer a skill or command").lines();
|
|
18
15
|
for (const peer of peers) {
|
|
19
16
|
const entries = list(peer.entries);
|
|
20
17
|
const shared = entries.filter(entry => entry.state === "listed").length;
|
|
21
|
-
out.
|
|
22
|
-
out.
|
|
18
|
+
out.section(dash(peer.peer), String(entries.length)).kv([["found", String(entries.length)], ["shared", String(shared)], ["mode", dash(peer.permission_mode)]]);
|
|
19
|
+
if (entries.length) out.append(grid(["ID", "STATE", "CLASS", "SOURCE", "DIGEST"], entries.map((entry: any) => [
|
|
23
20
|
s(dash(entry.id)), s(dash(entry.state), STATE_TONE[String(entry.state)]), s(dash(entry.class), entry.class === "destructive" ? "attention" : undefined), s(`${dash(entry.source)}/${dash(entry.invoke)}`), s(dash(entry.digest)),
|
|
24
21
|
]), columns));
|
|
25
|
-
const
|
|
26
|
-
for (const entry of stale) out.push(...pair("changed", `${dash(entry.id)} no longer matches its pinned digest and is unlisted until you pin the new one`, columns, 8, "attention"));
|
|
22
|
+
for (const entry of entries.filter(item => item.state === "digest-changed")) out.bullet("warn", `changed: ${dash(entry.id)} no longer matches its pinned digest and is unlisted until you pin the new one`);
|
|
27
23
|
}
|
|
28
|
-
out.
|
|
29
|
-
return out;
|
|
24
|
+
out.note("Share an entry by adding its digest under invocation.share.<peer> in .agenthub/config.local.json (this machine only). A class you set can only raise the one the source declared. An entry with no class anywhere counts as destructive and is refused.");
|
|
25
|
+
return out.lines();
|
|
30
26
|
}
|
|
@@ -8,7 +8,8 @@ import { configuredAcpPreview } from "./preview.ts";
|
|
|
8
8
|
export interface ConfiguredAcpSelection { peer: string; mode: "headless"; sessionId?: string; preview: boolean }
|
|
9
9
|
export function parseConfiguredAcpArguments(kind: string, raw: readonly string[], catalog: ProjectAdapterCatalog, instances?: InstancesConfig, declaredExternalInstances: readonly DeclaredExternalInstance[] = []): ConfiguredAcpSelection {
|
|
10
10
|
const definition = catalog.definitionOf(kind);
|
|
11
|
-
|
|
11
|
+
const print = definition?.start.daemonPort === "configured-print";
|
|
12
|
+
if (!print && !definition?.permission.genericAcp && !declaredExternalInstances.some(row => row.kind === kind)) throw new Error("unknown configured ACP kind");
|
|
12
13
|
const values = new Map<string, string>();
|
|
13
14
|
let preview = false;
|
|
14
15
|
for (let index = 0; index < raw.length; index++) {
|
|
@@ -20,6 +21,7 @@ export function parseConfiguredAcpArguments(kind: string, raw: readonly string[]
|
|
|
20
21
|
if (!value || value.startsWith("--") || Buffer.byteLength(value) > 4096 || /[\p{Cc}\p{Cf}]/u.test(value)) throw new Error(`${flag} needs a bounded control-free value`);
|
|
21
22
|
values.set(flag, value);
|
|
22
23
|
}
|
|
24
|
+
if (print && (values.has("--session-id") || values.has("--as"))) throw new Error("configured print accepts only headless mode and preview; it has no instances or sessions");
|
|
23
25
|
if (values.has("--mode") && values.get("--mode") !== "headless") throw new Error("configured ACP supports headless only");
|
|
24
26
|
const peer = values.get("--as") ?? kind;
|
|
25
27
|
const executable = !!instances && Object.hasOwn(instances, peer) && instances[peer]?.kind === kind && !!catalog.definitionOf(peer, instances);
|
|
@@ -64,12 +66,18 @@ export async function runConfiguredAcpEntry(context: {
|
|
|
64
66
|
connect(): Promise<ConfiguredAcpControl>; print(text: string): void; operationId?: string;
|
|
65
67
|
}): Promise<void> {
|
|
66
68
|
const selected = parseConfiguredAcpArguments(context.kind, context.raw, context.catalog, context.instances, context.declaredExternalInstances);
|
|
67
|
-
|
|
69
|
+
const print = context.catalog.definitionOf(context.kind)?.start.daemonPort === "configured-print";
|
|
70
|
+
if (selected.preview) {
|
|
71
|
+
const preview = configuredAcpPreview(context.kind, selected.peer, selected.sessionId !== undefined);
|
|
72
|
+
context.print(JSON.stringify(print ? { ...preview, needs: ["A trusted config.local.json declaration and a running hub with configured_print support."] } : preview, null, 2));
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
68
75
|
const hub = await context.connect();
|
|
69
76
|
try {
|
|
70
77
|
const external = selected.peer !== context.kind && (context.declaredExternalInstances?.some(row => row.id === selected.peer && row.kind === context.kind)
|
|
71
78
|
|| context.catalog.externalDefinitions.some(definition => definition.kind === context.kind));
|
|
72
79
|
if (external && !context.projectRoot) throw new Error("external instance start requires the canonical project root");
|
|
80
|
+
if (print && !hub.features.includes("configured_print")) throw new Error("running hub lacks configured_print; upgrade and restart it first");
|
|
73
81
|
await requireActiveConfiguredAcp(hub, context.kind, selected.peer, context.print, external ? { projectRoot: context.projectRoot! } : undefined);
|
|
74
82
|
const reply = await hub.request({ t: "start", peer: selected.peer, args: { mode: "headless", ...(selected.sessionId ? { sessionId: selected.sessionId } : {}) }, ...(context.operationId ? { operationId: context.operationId } : {}) }, 70_000);
|
|
75
83
|
if (!reply.ok) throw new Error(typeof reply.error === "string" ? reply.error : "configured ACP start refused");
|
package/src/cli/console-state.ts
CHANGED
|
@@ -256,6 +256,19 @@ export class Report {
|
|
|
256
256
|
this.out.push(...new SharedReport(this.columns, this.ascii).header(tool, name, context).lines());
|
|
257
257
|
return this;
|
|
258
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* #1654 AC3: the one header-fit rule. The header line does not wrap, so a name that fits the terminal stays in it and a longer
|
|
261
|
+
* one moves to a wrapped line under a short header. `context` follows the name after two spaces in `hint`; with `inline` it
|
|
262
|
+
* joins the name by one space (`Merge queue owner/repo`) and moves in `value`. A name too wide for any header keeps its first
|
|
263
|
+
* word there and repeats in full on the wrapped line. No wrap width means no moving.
|
|
264
|
+
*/
|
|
265
|
+
titled(tool: string, name: string, context?: string, inline = false): this {
|
|
266
|
+
const fits = (text: string) => this.columns === undefined || cellWidth(` ${tool} ${text}`) <= this.columns;
|
|
267
|
+
const joined = !context ? name : inline ? `${name} ${context}` : `${name} ${context}`;
|
|
268
|
+
if (fits(joined)) return inline && context ? this.header(tool, joined) : this.header(tool, name, context || undefined);
|
|
269
|
+
if (context && fits(name)) return this.header(tool, name).note(context, inline ? "value" : "hint");
|
|
270
|
+
return this.header(tool, name.split(" ")[0]!).note(joined, "value");
|
|
271
|
+
}
|
|
259
272
|
/** One blank line, then `▸ <Name>` (ASCII `> <Name>`) in `section`, with an optional count in `hint`. */
|
|
260
273
|
section(name: string, count?: string): this {
|
|
261
274
|
if (this.out.length && this.out.at(-1)!.length) this.push([]);
|
|
@@ -266,16 +279,23 @@ export class Report {
|
|
|
266
279
|
* Key/value rows of one section: two-space indent, `Key:` padded to the widest key, two spaces, value. A key wider than 28 cells
|
|
267
280
|
* puts its value on the next line at a four-space indent. An empty value is `(unset)` in `hint`.
|
|
268
281
|
*/
|
|
269
|
-
kv(rows: readonly (readonly [string, unknown])[], indent = 2): this {
|
|
270
|
-
const
|
|
282
|
+
kv(rows: readonly (readonly [string, unknown])[], indent = 2, options: { colon?: boolean } = {}): this {
|
|
283
|
+
const suffix = options.colon === false ? "" : ":";
|
|
284
|
+
const keys = rows.map(([key]) => cellWidth(`${terminalText(key)}${suffix}`));
|
|
271
285
|
const pad = Math.max(0, ...keys.filter(width => width <= 28));
|
|
272
286
|
for (const [index, [key, raw]] of rows.entries()) {
|
|
273
|
-
const label = `${terminalText(key)}
|
|
287
|
+
const label = `${terminalText(key)}${suffix}`, text = terminalText(raw ?? "").trim();
|
|
274
288
|
const value = (line: string): Span => text ? { text: line, role: "value" } : { text: "(unset)", role: "hint" };
|
|
275
289
|
const lead = " ".repeat(indent);
|
|
276
|
-
|
|
290
|
+
// a terminal too narrow to leave 10 cells beside the label stacks the value under its key, like a key wider than 28
|
|
291
|
+
// stacked when fewer than 10 cells remain beside the label, or when the value's longest word does not fit there
|
|
292
|
+
const longest = Math.max(0, ...text.split(/\s+/).map(word => cellWidth(word)));
|
|
293
|
+
const narrow = keys[index]! <= 28 && this.columns !== undefined && (indent + pad + 2 + 10 > this.columns || longest > this.columns - indent - pad - 2 && longest <= this.columns - indent);
|
|
294
|
+
if (keys[index]! > 28 || narrow) {
|
|
295
|
+
// a terminal too narrow for the label column keeps the value at the key's own indent, so a long word is not broken by the hang
|
|
296
|
+
const hang = narrow ? 0 : 2;
|
|
277
297
|
this.push([{ text: `${lead}${label}`, role: "key" }]);
|
|
278
|
-
for (const line of text ? this.fit(text, (this.columns ?? 0) - indent -
|
|
298
|
+
for (const line of text ? this.fit(text, (this.columns ?? 0) - indent - hang) : [""]) this.push([{ text: `${lead}${" ".repeat(hang)}` }, value(line)]);
|
|
279
299
|
continue;
|
|
280
300
|
}
|
|
281
301
|
const gap = " ".repeat(pad - keys[index]! + 2), room = (this.columns ?? 0) - indent - pad - 2;
|
package/src/cli/error-format.ts
CHANGED
|
@@ -17,3 +17,5 @@ export function errorLines(message: string, next: string | undefined, terminal:
|
|
|
17
17
|
const first = terminal ? `${MARKERS.fail[ascii ? "ascii" : "glyph"]} ${line}` : line;
|
|
18
18
|
return next ? [first, ` ${MARKERS.next[ascii ? "ascii" : "glyph"]} ${terminalText(next)}`] : [first];
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
export { warningLines } from "./warn-line.ts";
|
package/src/cli/guidance.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { GUIDANCE_HASH_HEX_LENGTH, GUIDANCE_CURSOR_MAX_BYTES, parseGuidanceWrite
|
|
|
3
3
|
import { guidanceLines, guidanceReceiptLines } from "../ui/guidance-view.ts";
|
|
4
4
|
import { terminalText } from "./console-state.ts";
|
|
5
5
|
|
|
6
|
-
export const GUIDANCE_USAGE = "usage: ahub guidance create --file
|
|
6
|
+
export const GUIDANCE_USAGE = "usage: ahub guidance create --file <file> [--json] | list --task <n> --task-created <ms> [--cursor <token>] [--json] | show --task <n> --task-created <ms> --id <hash> [--json] | withdraw --task <n> --task-created <ms> --revision <r> --id <hash> [--json]";
|
|
7
7
|
type Create = { op: "create"; json: boolean; file: string };
|
|
8
8
|
type List = { op: "list"; json: boolean; taskId: number; taskCreated: number; cursor?: string };
|
|
9
9
|
type Show = { op: "show"; json: boolean; taskId: number; taskCreated: number; id: string };
|
|
@@ -1,38 +1,41 @@
|
|
|
1
1
|
// Human output for `ahub task handoff` and `ahub board --handoffs` (#604, agent-hub#1030). Pure: the hub's parsed JSON in, spans out, no I/O. `--json` is the caller's branch and prints the same text.
|
|
2
2
|
// Only ids, states and counts are shown: the title of a handed-off task is the caller's own and was bounded and sanitized by the hub.
|
|
3
|
-
import {
|
|
4
|
-
import type
|
|
3
|
+
import { grid, s } from "./sdlc-output.ts";
|
|
4
|
+
import { Report, type Span, type Tone } from "./console-state.ts";
|
|
5
5
|
|
|
6
6
|
const STATE_TONE: Record<string, Tone | undefined> = { approved: undefined, cancelled: "muted", declined: "attention", proposed: "attention" };
|
|
7
7
|
const num = (value: unknown): string => typeof value === "number" && Number.isSafeInteger(value) ? String(value) : "-";
|
|
8
8
|
|
|
9
9
|
/** The receipt of one handoff: where the task now lives and what to run to follow it. */
|
|
10
|
-
export function renderHandoffReceipt(receipt: unknown, columns?: number): Span[][] {
|
|
10
|
+
export function renderHandoffReceipt(receipt: unknown, columns?: number, _now = Date.now(), ascii = false): Span[][] {
|
|
11
11
|
const r = receipt as any;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const out = new Report(columns, ascii).titled("ahub", "Handed off to project", String(r?.project ?? "?"), true);
|
|
13
|
+
out.section("Receipt").kv([["task", `#${num(r?.task)} (${r?.state ?? "proposed"})`]]);
|
|
14
|
+
out.note("it is on that project's board as an ownerless proposal; its own roles plan, implement and review it, and you are told when it changes state");
|
|
15
|
+
out.note("ahub board --handoffs shows the last state it reported");
|
|
16
|
+
return out.lines();
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
/** What this project handed to others, with the last state each target reported. */
|
|
19
|
-
export function renderHandoffs(data: unknown, columns?: number): Span[][] {
|
|
20
|
+
export function renderHandoffs(data: unknown, columns?: number, _now = Date.now(), ascii = false): Span[][] {
|
|
20
21
|
const rows: any[] = Array.isArray((data as any)?.handoffs) ? (data as any).handoffs : [];
|
|
21
22
|
if (!rows.length) return [[s("no handoffs: hand work that belongs to another project with `ahub task handoff --project <root|id> <title...>`", "muted")]];
|
|
23
|
+
const out = new Report(columns, ascii).titled("ahub", `Handoffs (${rows.length})`);
|
|
22
24
|
// #734: a row from a hub that has no age or reach (an older daemon) shows "-" for both, never a guess.
|
|
23
|
-
const reach = (row: any):
|
|
25
|
+
const reach = (row: any): ReturnType<typeof s> => {
|
|
24
26
|
const word = row.reach === "reachable" || row.reach === "unreachable" || row.reach === "moved" ? row.reach : undefined;
|
|
25
27
|
if (word === undefined) return s("-", "muted");
|
|
26
|
-
return s(word
|
|
28
|
+
return s(word, word === "reachable" ? "success" : "attention");
|
|
27
29
|
};
|
|
28
30
|
const down = rows.filter(row => row.reach === "unreachable" || row.reach === "moved" ? typeof row.cause === "string" : false);
|
|
29
|
-
|
|
31
|
+
out.section("Handed off", String(rows.length)).append(grid(["PROJECT", "TASK", "STATE", "AGE", "REACH", "PR", "BY", "TITLE"], rows.map(row => [
|
|
30
32
|
s(String(row.remoteProject ?? "?").slice(0, 24), "issueRef"), s(`#${num(row.remoteTask)}`, "taskRef"), s(String(row.state ?? "?"), STATE_TONE[row.state]),
|
|
31
33
|
s(typeof row.age === "string" ? row.age : "-", "muted"), reach(row),
|
|
32
|
-
s(typeof row.pr === "number" ? `#${row.pr}` : "-"), s(String(row.originPeer ?? "?")), s(String(row.title ?? ""))]), columns)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
s(typeof row.pr === "number" ? `#${row.pr}` : "-"), s(String(row.originPeer ?? "?")), s(String(row.title ?? ""))]), columns));
|
|
35
|
+
// The cause of each unreachable or moved target, once per target and with its next step, so the column stays narrow and the person still learns what to run.
|
|
36
|
+
for (const [project, cause] of new Map(down.map(row => [String(row.remoteProject), String(row.cause)])).entries()) out.bullet("warn", `${String(project).slice(0, 24)}: ${cause.slice(0, 200)}`);
|
|
37
|
+
// A sync that did not finish in time: the pass keeps running, so the list above is the state so far and the person is told what to run to read the rest.
|
|
38
|
+
if (typeof (data as any)?.cause === "string" && (data as any)?.synced === false) out.bullet("warn", String((data as any).cause));
|
|
39
|
+
if ((data as any)?.syncing === true) out.bullet("warn", `catch-up still running for ${num((data as any).pending)} target${(data as any).pending === 1 ? "" : "s"}: run \`ahub task handoff --list\` in a minute`);
|
|
40
|
+
return out.lines();
|
|
38
41
|
}
|