@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.
- package/CHANGELOG.md +45 -0
- package/README.md +17 -7
- package/docs/adding-an-ai-tool.md +6 -4
- package/docs/agent-notes/README.md +16 -0
- package/docs/agent-notes/adapters.md +4 -2
- package/docs/agent-notes/budget.md +8 -0
- package/docs/agent-notes/daemon.md +15 -8
- package/docs/agent-notes/local-worker.md +1 -1
- package/docs/agent-notes/security-review.md +55 -0
- package/docs/agent-notes/tasks.md +15 -4
- package/docs/agent-notes/tests.md +3 -2
- package/docs/design/adapters.md +51 -0
- package/docs/design/agent-hub-architecture.md +29 -1
- package/docs/design/task-board.md +151 -5
- package/docs/dogfood.md +20 -6
- package/docs/events.md +3 -3
- package/docs/memory.md +5 -5
- package/docs/operations.md +177 -28
- package/docs/profiles.md +100 -8
- package/docs/quickstart.md +32 -4
- package/docs/research.md +6 -3
- package/docs/roles.md +52 -0
- package/docs/sdlc.md +187 -1
- package/docs/security.md +50 -11
- package/docs/text-projection.md +1 -0
- package/docs/verification/2026-11-13-claude-implementer-2.1.323.md +59 -0
- package/docs/verification/2026-11-13-codex-01672-reviewer-isolation.md +69 -0
- package/docs/verification/2026-11-14-0.39.0.md +51 -0
- package/docs/verified.json +48 -25
- package/package.json +3 -3
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +1953 -460
- package/plugins/agent-hub/server.js +2019 -498
- package/src/adapters/acp-model-policy.ts +1 -1
- package/src/adapters/acp-session-model.ts +35 -0
- package/src/adapters/acp.ts +14 -0
- package/src/adapters/agy/definition.ts +1 -1
- package/src/adapters/agy/hooks.ts +7 -0
- package/src/adapters/claude-channel.ts +1 -1
- package/src/adapters/claude-implementer.ts +8 -0
- package/src/adapters/claude-print-child.ts +26 -2
- package/src/adapters/claude-print.ts +4 -0
- package/src/adapters/codex-appserver.ts +90 -16
- package/src/adapters/codex-review-isolation.ts +2 -0
- package/src/adapters/compat.ts +4 -4
- package/src/adapters/conformance/fakes/acp-server.ts +11 -2
- package/src/adapters/conformance/fakes/app-server.ts +5 -1
- package/src/adapters/conformance/fakes/pi-rpc.ts +1 -1
- package/src/adapters/definitions/builtin-metadata.ts +6 -6
- package/src/adapters/definitions/native-cli-jcode-mcp.ts +18 -3
- package/src/adapters/definitions/native-quota.ts +122 -0
- package/src/adapters/definitions/native-recovery.ts +3 -0
- package/src/adapters/definitions/qwen.ts +1 -1
- package/src/adapters/kimi-review.ts +23 -0
- package/src/adapters/kimi-wire-usage.ts +39 -16
- package/src/adapters/local-worker.ts +6 -3
- package/src/adapters/pi-state-model.ts +12 -0
- package/src/adapters/pi.ts +22 -0
- package/src/adapters/print-result-model.ts +24 -0
- package/src/adapters/registry-types.ts +10 -1
- package/src/adapters/registry.ts +19 -2
- package/src/adapters/reviewer-print.ts +130 -15
- package/src/adapters/role-eligibility.ts +99 -0
- package/src/adapters/same-directory.ts +16 -0
- package/src/cli/agy-mcp.ts +18 -7
- package/src/cli/console-state.ts +3 -1
- package/src/cli/free-text.ts +20 -0
- package/src/cli/handoff-args.ts +1 -1
- package/src/cli/help.ts +61 -6
- package/src/cli/identity.ts +10 -4
- package/src/cli/init-prompt.ts +31 -2
- package/src/cli/init-roles.ts +156 -0
- package/src/cli/init-settings.ts +24 -2
- package/src/cli/init.ts +139 -17
- package/src/cli/main.ts +194 -49
- package/src/cli/model.ts +1 -1
- package/src/cli/output.ts +56 -1
- package/src/cli/preview.ts +1 -1
- package/src/cli/recovery-launch.ts +114 -0
- package/src/cli/recovery-package.ts +14 -7
- package/src/cli/recovery-version-preflight.ts +104 -0
- package/src/cli/role-doctor.ts +39 -0
- package/src/cli/sdlc-output.ts +66 -1
- package/src/cli/study-output.ts +54 -0
- package/src/cli/study.ts +14 -1
- package/src/cli/terminal-recovery.ts +14 -0
- package/src/cli/upgrade-presentation.ts +4 -0
- package/src/cli/upgrade-restore-state.ts +12 -3
- package/src/cli/upgrade-runtime.ts +40 -2
- package/src/cli/upgrade.ts +8 -4
- package/src/hub/advisor-survey.ts +139 -0
- package/src/hub/audit-source.ts +66 -0
- package/src/hub/board.ts +479 -14
- package/src/hub/budget.ts +54 -4
- package/src/hub/conductor.ts +14 -8
- package/src/hub/config-apply.ts +2 -1
- package/src/hub/config-edit-host.ts +77 -5
- package/src/hub/considered-findings.ts +47 -0
- package/src/hub/control-client.ts +1 -1
- package/src/hub/daemon.ts +343 -58
- package/src/hub/deliverable-files.ts +17 -1
- package/src/hub/dogfood-profile.ts +3 -2
- package/src/hub/events.ts +23 -2
- package/src/hub/folder-trigger.ts +11 -4
- package/src/hub/hub-tools.ts +88 -16
- package/src/hub/kimi-usage.ts +34 -2
- package/src/hub/lifecycle-schema.ts +3 -3
- package/src/hub/memory-profile.ts +9 -1
- package/src/hub/memory-sync-state.ts +1 -0
- package/src/hub/model-overrides.ts +2 -1
- package/src/hub/no-writes.ts +2 -0
- package/src/hub/operational-authority.ts +6 -1
- package/src/hub/operational-view.ts +5 -1
- package/src/hub/peers.ts +2 -0
- package/src/hub/plan-conformance.ts +20 -2
- package/src/hub/quota-account.ts +34 -0
- package/src/hub/recovery-policy.ts +18 -4
- package/src/hub/research-evidence.ts +51 -3
- package/src/hub/research.ts +77 -13
- package/src/hub/restart.ts +14 -0
- package/src/hub/review-budget.ts +88 -0
- package/src/hub/review-findings.ts +93 -12
- package/src/hub/reviewer-pool-config.ts +6 -2
- package/src/hub/reviewer-pool.ts +39 -6
- package/src/hub/routing.ts +7 -3
- package/src/hub/sdlc-merge.ts +1 -1
- package/src/hub/sdlc-queue.ts +14 -4
- package/src/hub/sdlc-release.ts +1 -1
- package/src/hub/sdlc.ts +10 -6
- package/src/hub/security-audit.ts +178 -0
- package/src/hub/security-pass.ts +115 -0
- package/src/hub/settings.ts +11 -5
- package/src/hub/source-read.ts +80 -2
- package/src/hub/sources.ts +57 -9
- package/src/hub/startup-event-seeds.ts +5 -3
- package/src/hub/startup-timing.ts +1 -0
- package/src/hub/synthesis-readiness.ts +279 -0
- package/src/hub/tasks.ts +1083 -69
- package/src/hub/text-projection.ts +11 -1
- package/src/memory/capture.ts +2 -1
- package/src/ui/index.html +3 -0
- package/src/ui/office-model.ts +11 -3
- package/src/ui/office-space.ts +50 -30
- package/src/ui/plugin.ts +21 -11
|
@@ -16,7 +16,7 @@ export interface AcpModelAdvertisement {
|
|
|
16
16
|
readonly available: readonly string[];
|
|
17
17
|
readonly wire: Readonly<Record<string, string>>;
|
|
18
18
|
}
|
|
19
|
-
const ACP_MODEL_OPTIONS_MAX = 256;
|
|
19
|
+
export const ACP_MODEL_OPTIONS_MAX = 256;
|
|
20
20
|
/** Person ids retain the native-word grammar; only an exact receipt-owned wire codec may wrap one. */
|
|
21
21
|
export function acpLogicalModelId(policy: AcpModelPolicy, wire: unknown): string | undefined {
|
|
22
22
|
if (policy.idCodec === "qwen-openai") {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { safeModelLabel } from "../omniroute/usage.ts";
|
|
2
|
+
import { ACP_MODEL_OPTIONS_MAX, acpLogicalModelId, type AcpModelPolicy } from "./acp-model-policy.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* #1402 T3: the model id an ACP agent says its session is on, whatever the override policy. Read-only and shape-checked: the three places ACP agents put it are `models.currentModelId` (`session/new`,
|
|
6
|
+
* `session/load`), the `model` select of `configOptions` (`currentValue`) and a model-update payload. A receipt policy that owns an id codec (Qwen's `id(openai)` wire ids) strips it exactly as the
|
|
7
|
+
* override path does; otherwise the id is the wire id through `safeModelLabel`. A value `safeModelLabel` refuses, the placeholder `unknown`, or an absent field names no model, so nothing is guessed.
|
|
8
|
+
*/
|
|
9
|
+
function label(value: unknown, policy: AcpModelPolicy | undefined): string | undefined {
|
|
10
|
+
const id = policy?.idCodec ? acpLogicalModelId(policy, value) : safeModelLabel(value);
|
|
11
|
+
const safe = safeModelLabel(id);
|
|
12
|
+
return safe !== undefined && safe.toLowerCase() !== "unknown" ? safe : undefined;
|
|
13
|
+
}
|
|
14
|
+
const record = (value: unknown): Record<string, unknown> | undefined => value && typeof value === "object" && !Array.isArray(value) ? value as Record<string, unknown> : undefined;
|
|
15
|
+
/** The model in a `session/new` or `session/load` result (or a `configOptions`-only holder). */
|
|
16
|
+
export function sessionModelId(session: unknown, policy?: AcpModelPolicy): string | undefined {
|
|
17
|
+
const holder = record(session);
|
|
18
|
+
if (!holder) return undefined;
|
|
19
|
+
const fromModels = label(record(holder.models)?.currentModelId, policy);
|
|
20
|
+
if (fromModels !== undefined) return fromModels;
|
|
21
|
+
return configModelId(holder.configOptions, policy);
|
|
22
|
+
}
|
|
23
|
+
function configModelId(options: unknown, policy: AcpModelPolicy | undefined): string | undefined {
|
|
24
|
+
if (!Array.isArray(options) || options.length > ACP_MODEL_OPTIONS_MAX) return undefined;
|
|
25
|
+
const models = options.filter(option => record(option)?.id === "model");
|
|
26
|
+
if (models.length !== 1) return undefined;
|
|
27
|
+
const option = record(models[0])!;
|
|
28
|
+
return option.type === "select" ? label(option.currentValue, policy) : undefined;
|
|
29
|
+
}
|
|
30
|
+
/** The model in a model-update notification: `current_model_update` and the Qwen notice carry `currentModelId`, `config_option_update` carries the options. */
|
|
31
|
+
export function updatedModelId(update: unknown, policy?: AcpModelPolicy): string | undefined {
|
|
32
|
+
const value = record(update);
|
|
33
|
+
if (!value) return undefined;
|
|
34
|
+
return value.configOptions !== undefined ? configModelId(value.configOptions, policy) : label(value.currentModelId, policy);
|
|
35
|
+
}
|
package/src/adapters/acp.ts
CHANGED
|
@@ -16,6 +16,8 @@ import type { StartForm, ModelOverrideSelection } from "./registry-types.ts";
|
|
|
16
16
|
import { assessVersion, readTrust } from "./compat.ts";
|
|
17
17
|
import { acpLogicalModelId, acpModelAdvertisement, type AcpModelAdvertisement, type AcpModelPolicy } from "./acp-model-policy.ts";
|
|
18
18
|
import { isNativeModelToken } from "./model-token.ts";
|
|
19
|
+
import { sessionModelId, updatedModelId } from "./acp-session-model.ts";
|
|
20
|
+
import type { ModelObservation } from "../hub/events.ts";
|
|
19
21
|
import type { CapabilityManifest } from "../hub/capabilities.ts";
|
|
20
22
|
import { acpManifest } from "./native-capabilities.ts";
|
|
21
23
|
|
|
@@ -254,6 +256,9 @@ export class AcpPeer extends BasePeer {
|
|
|
254
256
|
private modelBaseline: string | undefined;
|
|
255
257
|
private modelSelected: string | undefined;
|
|
256
258
|
private modelObservation: object = {};
|
|
259
|
+
/** #1402: the model id the session reports now, kept whatever the override policy; `turnModel` is its value when the turn's prompt was sent. Neither is ever invented. */
|
|
260
|
+
private sessionModel: string | undefined;
|
|
261
|
+
private turnModel: string | undefined;
|
|
257
262
|
private modelBinding: { proc: ChildProcessWithoutNullStreams; session: string; proof: AcpOwnedGroup } | undefined;
|
|
258
263
|
private modelTurn: { turn: number; selection: ModelOverrideSelection; target: string; sent: boolean; acknowledged: boolean } | undefined;
|
|
259
264
|
private kimiAgent = false;
|
|
@@ -421,6 +426,7 @@ export class AcpPeer extends BasePeer {
|
|
|
421
426
|
throw new Error("Configured ACP did not provide a valid native session identity");
|
|
422
427
|
}
|
|
423
428
|
this.sessionId = session.sessionId;
|
|
429
|
+
this.sessionModel = sessionModelId(session, this.modelPolicy); this.turnModel = undefined;
|
|
424
430
|
const modelPolicy = this.modelPolicy;
|
|
425
431
|
if (modelPolicy && this.modelAdmitted()) {
|
|
426
432
|
const advertisement = acpModelAdvertisement(modelPolicy, session);
|
|
@@ -504,6 +510,11 @@ export class AcpPeer extends BasePeer {
|
|
|
504
510
|
acceptsModelOverride(model: string): boolean {
|
|
505
511
|
return this.modelOverrideState.available && isNativeModelToken(model) && this.modelAdvertisement!.available.includes(model);
|
|
506
512
|
}
|
|
513
|
+
/** #1402: the model the session was on when the turn that just ended started, read once at its `turn_end` (`session`: the agent's own current model id, not a per-response one). Absent records nothing. */
|
|
514
|
+
observedModel(): ModelObservation | undefined {
|
|
515
|
+
const model = this.turnModel; this.turnModel = undefined;
|
|
516
|
+
return model ? { model, evidence: "session" } : undefined;
|
|
517
|
+
}
|
|
507
518
|
private observeModelId(model: unknown): void {
|
|
508
519
|
this.modelObservation = {};
|
|
509
520
|
const logical = this.modelPolicy && acpLogicalModelId(this.modelPolicy, model);
|
|
@@ -698,6 +709,7 @@ export class AcpPeer extends BasePeer {
|
|
|
698
709
|
if (this.modelTurn?.turn === turn) this.modelTurn.sent = true;
|
|
699
710
|
}
|
|
700
711
|
const fixedPreamble = this.turnRecordPrompt(this.primed ? "" : this.opts.preamble ?? "");
|
|
712
|
+
this.turnModel = this.sessionModel; // the session's model at the turn start
|
|
701
713
|
// session/prompt answers only when the turn ends, so deliver resolves now and failures come back through onFailed.
|
|
702
714
|
const prompt = this.request("session/prompt", { sessionId: this.sessionId, prompt: [{ type: "text", text: fixedPreamble ? `${fixedPreamble}\n\n${renderDigest(envs, this.primed)}` : renderDigest(envs, this.primed) }] });
|
|
703
715
|
const reported = () => { if (this.cancelWait?.turn === turn) this.cancelWait.reported = true; };
|
|
@@ -881,6 +893,7 @@ export class AcpPeer extends BasePeer {
|
|
|
881
893
|
}
|
|
882
894
|
if (this.state === "busy" && !this.cancelWait) { this.lastSignAt = Date.now(); this.touch(); }
|
|
883
895
|
|
|
896
|
+
if (msg.method === "qwen/notify/session/model-update" && msg.params?.v === 1 && msg.params.sessionId === this.sessionId) this.sessionModel = updatedModelId(msg.params, this.modelPolicy) ?? this.sessionModel;
|
|
884
897
|
if (this.modelPolicy && msg.method === "qwen/notify/session/model-update") {
|
|
885
898
|
if (this.modelPolicy.modelUpdate === "qwen/notify/session/model-update" && msg.params?.v === 1 && msg.params.sessionId === this.sessionId) this.observeModelId(msg.params.currentModelId);
|
|
886
899
|
return; // A setter/control notification is never prompt admission.
|
|
@@ -899,6 +912,7 @@ export class AcpPeer extends BasePeer {
|
|
|
899
912
|
}
|
|
900
913
|
if (msg.params?.sessionId && msg.params.sessionId !== this.sessionId) return;
|
|
901
914
|
const u = msg.params?.update;
|
|
915
|
+
if (u?.sessionUpdate === "current_model_update" || u?.sessionUpdate === "config_option_update") this.sessionModel = updatedModelId(u, this.modelPolicy) ?? this.sessionModel;
|
|
902
916
|
// Occupancy is the session's, not the turn's: 2.1.1's source text emits usage_update after the prompt
|
|
903
917
|
// resolves, when the peer may already be idle (read from the source, not observed live; #285). So a
|
|
904
918
|
// context-used update is accepted while idle too, but then it must name the current session; in a turn the
|
|
@@ -16,7 +16,7 @@ function agyLaunch(ctx: LaunchContext): LaunchPlan {
|
|
|
16
16
|
export const AGY_DEFINITION: AdapterDefinition = {
|
|
17
17
|
api: 1,
|
|
18
18
|
kind: "agy",
|
|
19
|
-
projection: { roleRank: 7, helpRank: 4, plannerEligible: false },
|
|
19
|
+
projection: { roleRank: 7, helpRank: 4, plannerEligible: false, conductorEligible: false, reviewerEligible: false },
|
|
20
20
|
displayName: "Antigravity",
|
|
21
21
|
family: "agy",
|
|
22
22
|
transport: "ws-pull",
|
|
@@ -2,12 +2,18 @@ import { closeSync, constants, fstatSync, lstatSync, openSync, readSync } from "
|
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { isAbsolute, join, relative } from "node:path";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
|
+
import { safeModelLabel } from "../../omniroute/usage.ts";
|
|
5
6
|
import type { NativeFactsInput, NativeFactsPort, NativeFactsReadOptions, NativeFactsTranscript } from "../registry-types.ts";
|
|
6
7
|
|
|
7
8
|
const EVENTS = ["SessionStart", "PreInvocation", "PostInvocation", "PreToolUse", "PostToolUse", "Stop"] as const;
|
|
8
9
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
9
10
|
const record = (value: unknown): value is Record<string, unknown> => !!value && typeof value === "object" && !Array.isArray(value);
|
|
10
11
|
|
|
12
|
+
/** #1402: Antigravity names the session's model in every hook payload (`modelName`, verified for 1.4.3 to 1.5.3). A value `safeModelLabel` refuses or the placeholder `unknown` names none; an alias is kept as reported. */
|
|
13
|
+
function agyModel(value: unknown): string | undefined {
|
|
14
|
+
const model = safeModelLabel(value);
|
|
15
|
+
return model !== undefined && model.toLowerCase() !== "unknown" ? model : undefined;
|
|
16
|
+
}
|
|
11
17
|
/** The pinned 1.4.2 envelope has no event name: the managed command supplies it separately. */
|
|
12
18
|
export function decodeAgyHook(event: string, value: unknown): NativeFactsInput | undefined {
|
|
13
19
|
if (!(EVENTS as readonly string[]).includes(event) || !record(value) || typeof value.conversationId !== "string" || !UUID.test(value.conversationId)
|
|
@@ -54,6 +60,7 @@ export function decodeAgyHook(event: string, value: unknown): NativeFactsInput |
|
|
|
54
60
|
workspacePaths: value.workspacePaths as string[], tool, input,
|
|
55
61
|
...(Number.isSafeInteger(value.stepIdx) && (value.stepIdx as number) >= 0 ? { toolUseId: `${value.conversationId}:${value.stepIdx}` } : {}),
|
|
56
62
|
...(Number.isSafeInteger(value.invocationNum) && (value.invocationNum as number) >= 0 ? { invocation: value.invocationNum as number } : {}),
|
|
63
|
+
...(agyModel(value.modelName) ? { model: agyModel(value.modelName)! } : {}),
|
|
57
64
|
...(event === "Stop" ? { fullyIdle: value.fullyIdle as boolean, terminationReason: typeof value.terminationReason === "string" ? value.terminationReason : "" } : {}) };
|
|
58
65
|
}
|
|
59
66
|
|
|
@@ -433,7 +433,7 @@ function toolListFor(lifecycle: Awaited<ReturnType<typeof activeLifecycle>>) {
|
|
|
433
433
|
]
|
|
434
434
|
: []),
|
|
435
435
|
]),
|
|
436
|
-
...profileTaskTools(profile, lifecycle?.stages, lifecycle?.criteria).filter(tool => (lifecycle !== undefined || tool.name !== "hub_sdlc_record") && (!deliveryOnly || tool.name !== "hub_delivery_retry")),
|
|
436
|
+
...profileTaskTools(profile, lifecycle?.stages, lifecycle?.criteria, lifecycle?.audit, lifecycle?.survey).filter(tool => (lifecycle !== undefined || tool.name !== "hub_sdlc_record") && (!deliveryOnly || tool.name !== "hub_delivery_retry")),
|
|
437
437
|
...projectConductorTools(lifecycle?.startPeers),
|
|
438
438
|
], lifecycle?.readOnly).filter(tool => !permissionTool || IMPLEMENTER_HUB_TOOL_NAMES.includes(tool.name)),
|
|
439
439
|
};
|
|
@@ -17,6 +17,7 @@ import { ClaudeTaskSessions } from "./claude-task-sessions.ts";
|
|
|
17
17
|
import { formatClaudeFailure, type ClaudeFailureTrace } from "../hub/claude-failure-stage.ts";
|
|
18
18
|
import type { PermissionMode } from "../hub/permission-mode.ts";
|
|
19
19
|
import type { ReviewerPrintUsage } from "./reviewer-print.ts";
|
|
20
|
+
import { resultModel } from "./print-result-model.ts";
|
|
20
21
|
|
|
21
22
|
const provenVersions = new WeakMap<() => boolean, string>();
|
|
22
23
|
function provenVersion(binding: () => boolean): string | undefined { return provenVersions.get(binding); }
|
|
@@ -99,6 +100,12 @@ export async function proveClaudeImplementer(peer: string, command: readonly str
|
|
|
99
100
|
|
|
100
101
|
/** One owned print child at a time. Idle holds no native process; task continuity is ids-only on disk. */
|
|
101
102
|
export class ClaudeImplementerPeer extends BasePeer {
|
|
103
|
+
/** #1402: the model the last `result` row's modelUsage named; read once at the turn end. */
|
|
104
|
+
private servedModel: string | undefined;
|
|
105
|
+
observedModel(): import("../hub/events.ts").ModelObservation | undefined {
|
|
106
|
+
const model = this.servedModel; this.servedModel = undefined;
|
|
107
|
+
return model ? { model, evidence: "served" } : undefined;
|
|
108
|
+
}
|
|
102
109
|
readonly hubNative = true;
|
|
103
110
|
readonly hubOwned: boolean = true;
|
|
104
111
|
private generation = 0;
|
|
@@ -273,6 +280,7 @@ export class ClaudeImplementerPeer extends BasePeer {
|
|
|
273
280
|
if (row?.type !== "result" || result) return;
|
|
274
281
|
result = true; failed = row.is_error === true || row.subtype !== "success";
|
|
275
282
|
if (row.usage) this.options.onUsage?.(row.usage, group.task);
|
|
283
|
+
{ const model = resultModel(row); if (model) this.servedModel = model; }
|
|
276
284
|
} });
|
|
277
285
|
this.owned = child;
|
|
278
286
|
let code: number | null;
|
|
@@ -29,7 +29,10 @@ export interface OwnedPrintChildOptions {
|
|
|
29
29
|
onLimit?: () => void;
|
|
30
30
|
maxFrameBytes?: number;
|
|
31
31
|
maxOutputBytes?: number;
|
|
32
|
+
/** Opt-in host diagnostic only; raw text is never a frame, activity signal or public log. */
|
|
33
|
+
captureStderr?: true;
|
|
32
34
|
}
|
|
35
|
+
export type OwnedStderrReceipt = { status: "complete"; text: string } | { status: "unknown" };
|
|
33
36
|
|
|
34
37
|
/** Shared owned print transport, independent of reviewer or implementer lifecycle and MCP authority. */
|
|
35
38
|
export class OwnedPrintChild {
|
|
@@ -38,6 +41,17 @@ export class OwnedPrintChild {
|
|
|
38
41
|
readonly done: Promise<number | null>;
|
|
39
42
|
private stopping: Promise<void> | undefined;
|
|
40
43
|
private limited = false;
|
|
44
|
+
private stderrChunks: Buffer[] = [];
|
|
45
|
+
private stderrBytes = 0;
|
|
46
|
+
private stderrEnded = false;
|
|
47
|
+
private stderrUnknown = false;
|
|
48
|
+
private settled = false;
|
|
49
|
+
/** Only the current owned child's complete bounded stream after confirmed group settlement is usable. */
|
|
50
|
+
stderrAfterSettlement(): OwnedStderrReceipt {
|
|
51
|
+
if (!this.options.captureStderr || !this.settled || !this.stderrEnded || this.stderrUnknown || this.options.current?.() === false) return { status: "unknown" };
|
|
52
|
+
try { return { status: "complete", text: new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(this.stderrChunks)) }; }
|
|
53
|
+
catch { return { status: "unknown" }; }
|
|
54
|
+
}
|
|
41
55
|
|
|
42
56
|
constructor(private readonly options: OwnedPrintChildOptions) {
|
|
43
57
|
const [command, ...prefix] = options.command;
|
|
@@ -45,7 +59,7 @@ export class OwnedPrintChild {
|
|
|
45
59
|
const child = this.process = spawn(command, [...prefix, ...options.args], {
|
|
46
60
|
cwd: options.cwd, detached: true,
|
|
47
61
|
env: peerChildEnv(options.peer, options.envMode === "replace" ? options.env : { ...process.env, ...options.env }),
|
|
48
|
-
stdio: ["pipe", "pipe", "ignore"],
|
|
62
|
+
stdio: ["pipe", "pipe", options.captureStderr ? "pipe" : "ignore"],
|
|
49
63
|
});
|
|
50
64
|
// ponytail: 256 KiB per NDJSON frame and 4 MiB stdout by default; raise only with native receipts.
|
|
51
65
|
const frameLimit = options.maxFrameBytes ?? 256 * 1024, outputLimit = options.maxOutputBytes ?? 4 * 1024 * 1024;
|
|
@@ -53,6 +67,16 @@ export class OwnedPrintChild {
|
|
|
53
67
|
let inputFailed = false;
|
|
54
68
|
const current = () => !this.limited && options.current?.() !== false;
|
|
55
69
|
const limit = () => { if (!this.limited) { this.limited = true; options.onLimit?.(); } };
|
|
70
|
+
if (options.captureStderr) {
|
|
71
|
+
child.stderr!.on("data", (chunk: Buffer) => {
|
|
72
|
+
if (this.stderrUnknown) return;
|
|
73
|
+
this.stderrBytes += chunk.length;
|
|
74
|
+
if (options.current?.() === false || this.stderrBytes > 64 * 1024) { this.stderrUnknown = true; this.stderrChunks = []; return; }
|
|
75
|
+
this.stderrChunks.push(Buffer.from(chunk));
|
|
76
|
+
});
|
|
77
|
+
child.stderr!.once("end", () => { this.stderrEnded = true; });
|
|
78
|
+
child.stderr!.once("error", () => { this.stderrUnknown = true; this.stderrChunks = []; });
|
|
79
|
+
}
|
|
56
80
|
this.done = new Promise((resolve, reject) => {
|
|
57
81
|
child.once("error", error => { options.onError?.(error); reject(error); });
|
|
58
82
|
child.stdin!.on("error", () => { inputFailed = true; /* exit, rather than a prompt write, settles the owned child */ });
|
|
@@ -84,7 +108,7 @@ export class OwnedPrintChild {
|
|
|
84
108
|
});
|
|
85
109
|
child.once("exit", code => {
|
|
86
110
|
options.onLeaderExit?.();
|
|
87
|
-
void this.stop().then(() => resolve(code), error => reject(new PrintChildCleanupError((error as Error).message)));
|
|
111
|
+
void this.stop().then(() => { this.settled = true; resolve(code); }, error => reject(new PrintChildCleanupError((error as Error).message)));
|
|
88
112
|
});
|
|
89
113
|
});
|
|
90
114
|
}
|
|
@@ -2,6 +2,8 @@ import { childEnv } from "../hub/child-process.ts";
|
|
|
2
2
|
import { hubGitSync } from "../hub/git.ts";
|
|
3
3
|
import { changedPathGroups } from "../hub/review-brief.ts";
|
|
4
4
|
import { type Envelope } from "../hub/envelope.ts";
|
|
5
|
+
import { resultModel } from "./print-result-model.ts";
|
|
6
|
+
import { claudeReviewerQuota } from "./definitions/native-quota.ts";
|
|
5
7
|
import { ReviewerPrintPeer, type ReviewerBackend, type ReviewerPrintOptions } from "./reviewer-print.ts";
|
|
6
8
|
|
|
7
9
|
export interface ClaudePrintUsage { input_tokens?: number; output_tokens?: number; cache_creation_input_tokens?: number; cache_read_input_tokens?: number }
|
|
@@ -75,6 +77,7 @@ export function reviewDiff(cwd: string, commit: unknown, policy: { privatePath(p
|
|
|
75
77
|
|
|
76
78
|
export const claudeReviewerBackend: ReviewerBackend = {
|
|
77
79
|
id: "claude",
|
|
80
|
+
failure: claudeReviewerQuota,
|
|
78
81
|
prepare: async context => ({ command: context.command ?? ["claude"],
|
|
79
82
|
args: claudePrintArgs(context.sessionId, context.mcpConfig, context.systemPrompt, context.privatePaths),
|
|
80
83
|
isolation: { backend: "claude", version: "existing-223-contract", binary: (context.command ?? ["claude"])[0]!, profile: "strict-mcp-read-grep-glob",
|
|
@@ -83,6 +86,7 @@ export const claudeReviewerBackend: ReviewerBackend = {
|
|
|
83
86
|
const row = event as { type?: string; usage?: ClaudePrintUsage } | null;
|
|
84
87
|
return row?.type === "result" ? row.usage : undefined;
|
|
85
88
|
},
|
|
89
|
+
model: event => (event as { type?: string } | null)?.type === "result" ? resultModel(event) : undefined,
|
|
86
90
|
};
|
|
87
91
|
|
|
88
92
|
/** Compatibility wrapper for the released Claude transport and its existing tests. */
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { codexAccountUsage, codexQuotaWindowInput } from "./definitions/native-quota.ts";
|
|
2
|
+
import type { QuotaAccountUsage } from "../hub/quota-account.ts";
|
|
1
3
|
import type { ModelOverrideSelection } from "./registry-types.ts";
|
|
2
4
|
import { isNativeModelToken } from "./model-token.ts";
|
|
3
5
|
import { spawn, type ChildProcess } from "node:child_process";
|
|
@@ -6,6 +8,7 @@ import { renderDigest, replyAudience, replyParent, type Envelope, type PeerId }
|
|
|
6
8
|
import type { PermissionMode } from "../hub/permission-mode.ts";
|
|
7
9
|
import type { DeliveryFailureCause } from "../hub/delivery-failure.ts";
|
|
8
10
|
import { BasePeer, type FrontendProxyPort } from "../hub/peers.ts";
|
|
11
|
+
import type { ModelObservation } from "../hub/events.ts";
|
|
9
12
|
import { codexContext, type ContextReading } from "../hub/context-window.ts";
|
|
10
13
|
import { peerChildEnv, stopOwnedProcess, trackGroup } from "../hub/child-process.ts";
|
|
11
14
|
import type { ContextReader } from "./registry-types.ts";
|
|
@@ -13,6 +16,9 @@ import type { CapabilityManifest } from "../hub/capabilities.ts";
|
|
|
13
16
|
import { codexSkillsManifest, NATIVE_PINS } from "./native-capabilities.ts";
|
|
14
17
|
import { ACTION_BUDGET_OPTION, type ActionGateVerdict, type PermissionRequest } from "./acp.ts";
|
|
15
18
|
|
|
19
|
+
// ponytail: paused quota reads use a fixed 60s cadence; a validated operational cadence setting is the upgrade path if tuning is needed.
|
|
20
|
+
const PAUSED_USAGE_POLL_MS = 60_000;
|
|
21
|
+
|
|
16
22
|
const UNIDENTIFIED_CANCELLATION_NOTICE = "Codex cancelled turn has no verified native id; reattach the native session before further hub delivery";
|
|
17
23
|
const PLANNER_SANDBOX_REFUSAL = "Codex planner thread requires a confirmed read-only sandbox";
|
|
18
24
|
|
|
@@ -50,8 +56,10 @@ export interface CodexOptions {
|
|
|
50
56
|
extraArgs?: string[];
|
|
51
57
|
/** Appended to the standing instruction of the first delivery (role contract). */
|
|
52
58
|
preamble?: string;
|
|
53
|
-
/**
|
|
54
|
-
onUsage?: (rateLimits: unknown, hard: boolean) => void;
|
|
59
|
+
/** Window-only native fields plus allowlisted account diagnostics; hard means a turn was refused for quota. */
|
|
60
|
+
onUsage?: (rateLimits: unknown, hard: boolean, accountUsage?: QuotaAccountUsage) => void;
|
|
61
|
+
/** Host-only observation of the canonical account pause. It grants no resume authority. */
|
|
62
|
+
usagePause?: { current(): boolean; subscribe(changed: () => void): () => void };
|
|
55
63
|
/** Tokens the thread used since the previous update (see `tokenTotal` for how they are counted). */
|
|
56
64
|
onTokens?: (added: number) => void;
|
|
57
65
|
/**
|
|
@@ -119,6 +127,9 @@ export class CodexPeer extends BasePeer {
|
|
|
119
127
|
private readonly nativeApprovalPolicies = new Map<string, unknown>();
|
|
120
128
|
private readonly overriddenApprovals = new Set<string>();
|
|
121
129
|
private readonly nativeModels = new Map<string, { sequence: number; model?: string }>();
|
|
130
|
+
/** #1402: the model each thread reported (`thread/start`, `thread/resume`) or was started with (an accepted `turn/start`), and the model Codex rerouted the running turn to. Never invented. */
|
|
131
|
+
private readonly threadModels = new Map<string, string>();
|
|
132
|
+
private reroutedModel: string | undefined;
|
|
122
133
|
private modelStartSequence = 0;
|
|
123
134
|
private readonly restoringApprovals = new Map<string | number, string>();
|
|
124
135
|
private proc: ChildProcess | undefined;
|
|
@@ -151,7 +162,11 @@ export class CodexPeer extends BasePeer {
|
|
|
151
162
|
private unboundAccepted = false;
|
|
152
163
|
private nextId = -1;
|
|
153
164
|
private readonly pending = new Map<number, { resolve: (result?: any) => void; reject: (e: Error, failureCause?: DeliveryFailureCause) => void; deliveryId?: string; kind?: "deliver" | "steer"; modelStart?: ModelStartOrder; expectedTurnId?: string; afterTurn?: () => void; invalidate?: (reason: string, failureCause?: DeliveryFailureCause) => void }>();
|
|
154
|
-
private usageTimer: ReturnType<typeof
|
|
165
|
+
private usageTimer: ReturnType<typeof setTimeout> | undefined;
|
|
166
|
+
private usageUnsubscribe: (() => void) | undefined;
|
|
167
|
+
private usageEpoch = 0;
|
|
168
|
+
private usageStopped = false;
|
|
169
|
+
private readonly usageRequests = new Map<number, ReturnType<typeof setTimeout>>();
|
|
155
170
|
private injected: Envelope | undefined; // the hub envelope that started the current turn, if any
|
|
156
171
|
private answering: Envelope[] = []; // everything delivered or steered into the current turn: who its answer is for
|
|
157
172
|
private lastAnswer = "";
|
|
@@ -203,7 +218,8 @@ export class CodexPeer extends BasePeer {
|
|
|
203
218
|
}
|
|
204
219
|
|
|
205
220
|
async start(): Promise<void> {
|
|
206
|
-
this.
|
|
221
|
+
this.usageStopped = false;
|
|
222
|
+
this.nativeModels.clear(); this.threadModels.clear(); this.reroutedModel = undefined; this.modelStartSequence = 0;
|
|
207
223
|
const upstream = this.opts.upstreamUrl ?? (await this.spawnAppServer());
|
|
208
224
|
try {
|
|
209
225
|
this.server = Bun.serve<Link>({
|
|
@@ -249,6 +265,8 @@ export class CodexPeer extends BasePeer {
|
|
|
249
265
|
}
|
|
250
266
|
|
|
251
267
|
async stop(): Promise<void> {
|
|
268
|
+
this.usageStopped = true;
|
|
269
|
+
this.stopUsagePolling();
|
|
252
270
|
this.abortActionWaits();
|
|
253
271
|
this.server?.stop(true);
|
|
254
272
|
this.claimedTui?.tui.close(1001, "hub shutting down");
|
|
@@ -539,7 +557,7 @@ export class CodexPeer extends BasePeer {
|
|
|
539
557
|
link.up.close();
|
|
540
558
|
if (this.claimedTui === link) this.claimedTui = undefined;
|
|
541
559
|
if (this.link !== link) return;
|
|
542
|
-
|
|
560
|
+
this.stopUsagePolling();
|
|
543
561
|
this.link = undefined;
|
|
544
562
|
this.restoringApprovals.clear();
|
|
545
563
|
this.threadId = "";
|
|
@@ -634,11 +652,30 @@ export class CodexPeer extends BasePeer {
|
|
|
634
652
|
if ((this.nativeModels.get(start.thread)?.sequence ?? 0) >= start.sequence) return undefined;
|
|
635
653
|
const actual = model ?? (inherit ? this.nativeModelHint(start.thread) : undefined);
|
|
636
654
|
this.nativeModels.set(start.thread, { sequence: start.sequence, ...(actual === undefined ? {} : { model: actual }) });
|
|
655
|
+
this.rememberThreadModel(start.thread, actual);
|
|
637
656
|
// ponytail: keep at most 128 thread receipts; older defaults are unknown until native model readback is added.
|
|
638
657
|
if (this.nativeModels.size > 128) this.nativeModels.delete(this.nativeModels.keys().next().value!);
|
|
639
658
|
return actual === undefined ? {} : { model: actual };
|
|
640
659
|
}
|
|
641
660
|
|
|
661
|
+
private rememberThreadModel(thread: string, model: unknown): void {
|
|
662
|
+
if (typeof model !== "string" || !model) return;
|
|
663
|
+
this.threadModels.delete(thread); this.threadModels.set(thread, model);
|
|
664
|
+
if (this.threadModels.size > 128) this.threadModels.delete(this.threadModels.keys().next().value!);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* #1402: what the native surface reported for the turn that just ended, read once at its `turn_end`. A `model/rerouted` notification names the model Codex served for the turn (`served`);
|
|
669
|
+
* otherwise the thread's reported or accepted model (`session`). Codex's `thread/start`, `thread/resume` and `turn/start` replies carry no per-response model, so nothing here is `served` unless
|
|
670
|
+
* Codex said so; an absent field records nothing. Verified against the app-server schema of codex-cli 0.167.2.
|
|
671
|
+
*/
|
|
672
|
+
observedModel(): ModelObservation | undefined {
|
|
673
|
+
const served = this.reroutedModel; this.reroutedModel = undefined;
|
|
674
|
+
if (served) return { model: served, evidence: "served" };
|
|
675
|
+
const session = this.threadModels.get(this.threadId);
|
|
676
|
+
return session ? { model: session, evidence: "session" } : undefined;
|
|
677
|
+
}
|
|
678
|
+
|
|
642
679
|
private retireRejectedModelSelection(link: Link): void {
|
|
643
680
|
const candidate = link.rejectedModelSelection;
|
|
644
681
|
if (!candidate || link !== this.link || candidate.epoch !== this.contextEpoch || candidate.thread !== this.threadId ||
|
|
@@ -751,6 +788,7 @@ export class CodexPeer extends BasePeer {
|
|
|
751
788
|
const thread = msg.result.thread.id;
|
|
752
789
|
if (!this.overriddenApprovals.has(thread) && msg.result.approvalPolicy != null) this.nativeApprovalPolicies.set(thread, msg.result.approvalPolicy);
|
|
753
790
|
this.adopt(link, msg.result.thread.id, tracked === "thread/start");
|
|
791
|
+
this.rememberThreadModel(msg.result.thread.id, msg.result.model);
|
|
754
792
|
}
|
|
755
793
|
}
|
|
756
794
|
else if (msg.method) this.onNotification(link, msg.method, msg.params ?? {});
|
|
@@ -861,10 +899,7 @@ export class CodexPeer extends BasePeer {
|
|
|
861
899
|
this.opts.log?.(`[${this.id}] thread ${threadId}`);
|
|
862
900
|
this.opts.onThread?.(threadId, fresh);
|
|
863
901
|
this.setState("idle");
|
|
864
|
-
this.
|
|
865
|
-
clearInterval(this.usageTimer);
|
|
866
|
-
this.usageTimer = setInterval(() => this.readUsage(), this.opts.usagePollMs ?? 600_000);
|
|
867
|
-
this.usageTimer.unref?.();
|
|
902
|
+
this.startUsagePolling(link);
|
|
868
903
|
}
|
|
869
904
|
|
|
870
905
|
/**
|
|
@@ -901,19 +936,55 @@ export class CodexPeer extends BasePeer {
|
|
|
901
936
|
});
|
|
902
937
|
}
|
|
903
938
|
|
|
904
|
-
|
|
939
|
+
private stopUsagePolling(): void {
|
|
940
|
+
this.usageEpoch++;
|
|
941
|
+
clearTimeout(this.usageTimer); this.usageTimer = undefined;
|
|
942
|
+
const unsubscribe = this.usageUnsubscribe; this.usageUnsubscribe = undefined;
|
|
943
|
+
try { unsubscribe?.(); } catch { /* observational subscription only */ }
|
|
944
|
+
for (const [id, timer] of this.usageRequests) { clearTimeout(timer); this.pending.delete(id); }
|
|
945
|
+
this.usageRequests.clear();
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
private startUsagePolling(link: Link): void {
|
|
949
|
+
this.stopUsagePolling();
|
|
950
|
+
if (!this.opts.onUsage || this.usageStopped) return;
|
|
951
|
+
const epoch = this.usageEpoch;
|
|
952
|
+
const current = () => !this.usageStopped && this.usageEpoch === epoch && this.link === link && link.up.readyState === WebSocket.OPEN;
|
|
953
|
+
const schedule = () => {
|
|
954
|
+
if (!current()) return;
|
|
955
|
+
clearTimeout(this.usageTimer); this.usageTimer = undefined;
|
|
956
|
+
let paused: boolean;
|
|
957
|
+
try { paused = this.opts.usagePause?.current() === true; } catch { return; }
|
|
958
|
+
this.usageTimer = setTimeout(() => {
|
|
959
|
+
if (!current()) return;
|
|
960
|
+
this.readUsage(); schedule();
|
|
961
|
+
}, paused ? PAUSED_USAGE_POLL_MS : this.opts.usagePollMs ?? 600_000);
|
|
962
|
+
this.usageTimer.unref?.();
|
|
963
|
+
};
|
|
964
|
+
try { this.usageUnsubscribe = this.opts.usagePause?.subscribe(schedule); } catch { return; }
|
|
965
|
+
this.readUsage(); schedule();
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/** account/rateLimits/read through the TUI's connection; late replies never escape or update a replacement input. */
|
|
905
969
|
private readUsage(): void {
|
|
906
|
-
const link = this.link;
|
|
907
|
-
if (!this.opts.onUsage || !link || link.up.readyState !== WebSocket.OPEN) return;
|
|
970
|
+
const link = this.link, epoch = this.usageEpoch;
|
|
971
|
+
if (this.usageStopped || !this.opts.onUsage || !link || link.up.readyState !== WebSocket.OPEN) return;
|
|
908
972
|
const id = this.nextId--;
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
973
|
+
const finish = () => { clearTimeout(this.usageRequests.get(id)); this.usageRequests.delete(id); };
|
|
974
|
+
const timer = setTimeout(() => { this.pending.delete(id); this.usageRequests.delete(id); }, 30_000);
|
|
975
|
+
timer.unref?.(); this.usageRequests.set(id, timer);
|
|
976
|
+
this.pending.set(id, { resolve: result => {
|
|
977
|
+
finish();
|
|
978
|
+
if (!this.usageStopped && this.link === link && this.usageEpoch === epoch)
|
|
979
|
+
this.opts.onUsage?.(codexQuotaWindowInput(result?.rateLimits), false, codexAccountUsage(result));
|
|
980
|
+
}, reject: finish });
|
|
981
|
+
try { link.up.send(JSON.stringify({ method: "account/rateLimits/read", id })); }
|
|
982
|
+
catch { finish(); this.pending.delete(id); }
|
|
912
983
|
}
|
|
913
984
|
|
|
914
985
|
private onNotification(link: Link, method: string, params: any): void {
|
|
915
986
|
// Account-level notifications carry no threadId.
|
|
916
|
-
if (link === this.link && method === "account/rateLimits/updated") return void this.opts.onUsage?.(params.rateLimits, false);
|
|
987
|
+
if (link === this.link && method === "account/rateLimits/updated") return void this.opts.onUsage?.(codexQuotaWindowInput(params.rateLimits), false);
|
|
917
988
|
if (link === this.link && method === "error" && params.error?.codexErrorInfo === "usageLimitExceeded") {
|
|
918
989
|
this.opts.onUsage?.({ rateLimitReachedType: "usageLimitExceeded" }, true);
|
|
919
990
|
}
|
|
@@ -927,6 +998,8 @@ export class CodexPeer extends BasePeer {
|
|
|
927
998
|
return;
|
|
928
999
|
}
|
|
929
1000
|
if (this.unidentifiedCancellation) return; // native traffic is still forwarded to its TUI; hub attribution is fenced
|
|
1001
|
+
// #1402: a reroute is the model of the turn it names, so it passes both fences above (a retired turn or a fenced cancellation never becomes a later turn's served model).
|
|
1002
|
+
if (method === "model/rerouted") { if (typeof params.toModel === "string" && params.toModel) this.reroutedModel = params.toModel; return; }
|
|
930
1003
|
const unknownTurn = () => [...this.activeTurns].some(id => id.startsWith("unknown:"));
|
|
931
1004
|
if (method === "thread/tokenUsage/updated") {
|
|
932
1005
|
const reader = this.opts.contextReader;
|
|
@@ -946,6 +1019,7 @@ export class CodexPeer extends BasePeer {
|
|
|
946
1019
|
return;
|
|
947
1020
|
}
|
|
948
1021
|
if (method === "turn/started") {
|
|
1022
|
+
this.reroutedModel = undefined; // a reroute whose turn end was never read cannot carry into another turn
|
|
949
1023
|
link.rejectedModelSelection = undefined;
|
|
950
1024
|
// The notification has no request id. Conservatively protect every outstanding capture on
|
|
951
1025
|
// this bound thread rather than retiring a possibly accepted selection on a later RPC error.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isNativeModelToken } from "./model-token.ts";
|
|
2
|
+
import { codexReviewerQuota } from "./definitions/native-quota.ts";
|
|
2
3
|
import { DENY_NAMES, DENY_SEGMENTS } from "@staix/agent-mem/platform";
|
|
3
4
|
import { assessVersion, COMPAT } from "./compat.ts";
|
|
4
5
|
import { createHash } from "node:crypto";
|
|
@@ -304,6 +305,7 @@ async function prepare(ctx: ReviewerPrepareContext): Promise<ReviewerLaunch | {
|
|
|
304
305
|
|
|
305
306
|
export const codexReviewerBackend: ReviewerBackend = {
|
|
306
307
|
id: "codex", prepare,
|
|
308
|
+
failure: codexReviewerQuota,
|
|
307
309
|
toolTrace(event) {
|
|
308
310
|
const row = event as { type?: string; item?: { type?: string; server?: string; tool?: string; error?: { message?: unknown } | string; result?: { isError?: boolean; content?: { type?: string; text?: unknown }[] } } };
|
|
309
311
|
const item = row?.item;
|
package/src/adapters/compat.ts
CHANGED
|
@@ -34,12 +34,12 @@ export const COMPAT = {
|
|
|
34
34
|
parse: out => plain(out.trim()),
|
|
35
35
|
trustNote: "The model-free extension load, RPC session identity and managed tool receipt path were checked on 1.4.0 and 1.5.0. Permissions remain host-owned; account-backed inference and another version's extension contract are unverified.",
|
|
36
36
|
receipt: "docs/verification/2026-11-03-pi-150-compat.md" },
|
|
37
|
-
// Transport receipts: docs/verification/2026-10-23-headless-claude-permissions.md; 2.1.310: docs/verification/2026-10-26-claude-implementer-2.1.310.md; 2.1.314 (transport and wrapper): docs/verification/2026-10-31-claude-implementer-2.1.314.md; 2.1.316: docs/verification/2026-10-31-claude-implementer-2.1.316.md; 2.1.318: docs/verification/2026-11-05-claude-implementer-2.1.318.md; 2.1.319: docs/verification/2026-11-06-claude-implementer-2.1.319.md; 2.1.322: docs/verification/2026-11-10-claude-implementer-2.1.322.md; host-wrapper receipt below repeats with them.
|
|
38
|
-
"claude-implementer": { label: "Claude headless implementer", verified: ["2.1.309", "2.1.310", "2.1.314", "2.1.316", "2.1.318", "2.1.319", "2.1.322"], gate: "contract", probe: ["claude", "--version"],
|
|
37
|
+
// Transport receipts: docs/verification/2026-10-23-headless-claude-permissions.md; 2.1.310: docs/verification/2026-10-26-claude-implementer-2.1.310.md; 2.1.314 (transport and wrapper): docs/verification/2026-10-31-claude-implementer-2.1.314.md; 2.1.316: docs/verification/2026-10-31-claude-implementer-2.1.316.md; 2.1.318: docs/verification/2026-11-05-claude-implementer-2.1.318.md; 2.1.319: docs/verification/2026-11-06-claude-implementer-2.1.319.md; 2.1.322: docs/verification/2026-11-10-claude-implementer-2.1.322.md; 2.1.323: docs/verification/2026-11-13-claude-implementer-2.1.323.md; host-wrapper receipt below repeats with them.
|
|
38
|
+
"claude-implementer": { label: "Claude headless implementer", verified: ["2.1.309", "2.1.310", "2.1.314", "2.1.316", "2.1.318", "2.1.319", "2.1.322", "2.1.323"], gate: "contract", probe: ["claude", "--version"],
|
|
39
39
|
parse: out => plain(out.trim().replace(/ \(Claude Code\)$/, "")),
|
|
40
40
|
trustNote: "The native prompt-tool transport and host-wrapper rewrite, environment isolation and replay contract have isolated receipts. No dontAsk/bypass fallback exists; another version's permission or rewrite behavior is unverified.",
|
|
41
|
-
receipt: "docs/verification/2026-11-
|
|
42
|
-
// 0.163.0 receipt: docs/verification/2026-10-22-codex-reviewer-isolation.md; 0.164.0 receipt: docs/verification/2026-10-24-codex-0164-reviewer-isolation.md; 0.166.0: docs/verification/2026-10-31-codex-0166-reviewer-isolation.md; 0.167.0 model-free only, not verified until its model-backed run: docs/verification/2026-11-06-codex-0167-reviewer-isolation.md
|
|
41
|
+
receipt: "docs/verification/2026-11-13-claude-implementer-2.1.323.md" },
|
|
42
|
+
// 0.163.0 receipt: docs/verification/2026-10-22-codex-reviewer-isolation.md; 0.164.0 receipt: docs/verification/2026-10-24-codex-0164-reviewer-isolation.md; 0.166.0: docs/verification/2026-10-31-codex-0166-reviewer-isolation.md; 0.167.0 model-free only, not verified until its model-backed run: docs/verification/2026-11-06-codex-0167-reviewer-isolation.md; 0.167.2 model-free only, not verified until its model-backed run: docs/verification/2026-11-13-codex-01672-reviewer-isolation.md
|
|
43
43
|
"codex-review": { label: "Codex reviewer (codex-cli)", verified: ["0.146.0", "0.163.0", "0.164.0", "0.166.0"], gate: "isolation", probe: ["codex", "--version"], config: "codex_bin",
|
|
44
44
|
parse: out => plain(out.trim().replace(/^codex-cli /, "")),
|
|
45
45
|
trustNote: "Every launch still proves the MCP inventory, Apps/plugins/hooks disabled, sandbox read/write denial and the binary fence; a failed leg still refuses. Trust covers only the source-level claims those probes cannot see (docs/verification/2026-10-19-reviewer-isolation.md).",
|
|
@@ -8,6 +8,15 @@ import { createInterface } from "node:readline";
|
|
|
8
8
|
import { KIMI_2_1_1_5H_REFUSAL_PREFIX } from "../../acp-quota.ts";
|
|
9
9
|
|
|
10
10
|
const delay = Number(process.env.FAKE_ACP_DELAY_MS ?? 20);
|
|
11
|
+
// #1402: `--model-id <id>` reports a current model in the session result, as `models.currentModelId` (Kimi, Jcode, Qwen) or, with `--model-shape config`, as the `model` select of `configOptions`.
|
|
12
|
+
const argAfter = (flag: string) => { const i = process.argv.indexOf(flag); return i >= 0 ? process.argv[i + 1] : undefined; };
|
|
13
|
+
const sessionModelShape = (): Record<string, unknown> => {
|
|
14
|
+
const id = argAfter("--model-id");
|
|
15
|
+
if (!id) return {};
|
|
16
|
+
return argAfter("--model-shape") === "config"
|
|
17
|
+
? { configOptions: [{ id: "model", type: "select", currentValue: id, options: [{ value: id, name: id }] }] }
|
|
18
|
+
: { models: { currentModelId: id, availableModels: [{ modelId: id, name: id }] } };
|
|
19
|
+
};
|
|
11
20
|
let responseBatch: string[] | undefined;
|
|
12
21
|
const send = (m: unknown) => { const line = `${JSON.stringify(m)}\n`; if (responseBatch) responseBatch.push(line); else process.stdout.write(line); };
|
|
13
22
|
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
|
@@ -223,13 +232,13 @@ createInterface({ input: process.stdin }).on("line", (line) => {
|
|
|
223
232
|
if (record > 0) Bun.write(process.argv[record + 1]!, msg.params.sessionId); // argv, not env: the hub scrubs a child's environment
|
|
224
233
|
// what a real agent does while it loads: replay the history, then answer
|
|
225
234
|
send({ jsonrpc: "2.0", method: "session/update", params: { sessionId: msg.params.sessionId, update: { sessionUpdate: "agent_message_chunk", content: { type: "text", text: "replayed history" } } } });
|
|
226
|
-
send({ jsonrpc: "2.0", id: msg.id, result: { modes } });
|
|
235
|
+
send({ jsonrpc: "2.0", id: msg.id, result: { modes, ...sessionModelShape() } });
|
|
227
236
|
}
|
|
228
237
|
else if (msg.method === "session/new") {
|
|
229
238
|
modes.currentModeId = arg("--new-mode") ?? "default";
|
|
230
239
|
if (process.env.FAKE_ACP_RECORD) Bun.write(process.env.FAKE_ACP_RECORD, JSON.stringify(msg.params));
|
|
231
240
|
if (process.env.FAKE_ACP_ENV_RECORD) Bun.write(process.env.FAKE_ACP_ENV_RECORD, JSON.stringify({ recovery: process.env.AGENTHUB_RECOVERY_OPERATION, codex: process.env.CODEX_HOME, claude: process.env.CLAUDE_CONFIG_DIR, state: process.env.AGENTHUB_STATE_DIR }));
|
|
232
|
-
send({ jsonrpc: "2.0", id: msg.id, result: { sessionId: "s1", modes } });
|
|
241
|
+
send({ jsonrpc: "2.0", id: msg.id, result: { sessionId: "s1", modes, ...sessionModelShape() } });
|
|
233
242
|
}
|
|
234
243
|
else if (msg.method === "session/set_mode") {
|
|
235
244
|
modePending = true;
|
|
@@ -6,6 +6,7 @@ export function startFakeAppServer(
|
|
|
6
6
|
usedPercent = 93,
|
|
7
7
|
reportApprovalPolicy = true,
|
|
8
8
|
onRequest?: (msg: any) => void,
|
|
9
|
+
rateLimitsRead?: () => unknown,
|
|
9
10
|
) {
|
|
10
11
|
let turnSeq = 0;
|
|
11
12
|
let threadTotal = 0; // the thread's running token total, as Codex keeps it
|
|
@@ -36,7 +37,7 @@ export function startFakeAppServer(
|
|
|
36
37
|
reply({ thread: { id: msg.params.threadId }, model: "fake", ...(reportApprovalPolicy ? { approvalPolicy: msg.params.approvalPolicy ?? "untrusted" } : {}) });
|
|
37
38
|
return note("thread/tokenUsage/updated", { threadId: msg.params.threadId, turnId: "old", tokenUsage: { total: usage(threadTotal), last: usage(800) } });
|
|
38
39
|
}
|
|
39
|
-
if (msg.method === "account/rateLimits/read") return reply({ rateLimits: { primary: { usedPercent, windowDurationMins: 300, resetsAt: 1_900_000_000 }, secondary: null } });
|
|
40
|
+
if (msg.method === "account/rateLimits/read") return reply(rateLimitsRead ? rateLimitsRead() : { rateLimits: { primary: { usedPercent, windowDurationMins: 300, resetsAt: 1_900_000_000 }, secondary: null } });
|
|
40
41
|
if (msg.method === "thread/revert") {
|
|
41
42
|
reverted.push(msg.params);
|
|
42
43
|
onRevert?.(msg.params);
|
|
@@ -73,6 +74,9 @@ export function startFakeAppServer(
|
|
|
73
74
|
}
|
|
74
75
|
reply({ turn });
|
|
75
76
|
note("turn/started", { threadId, turn });
|
|
77
|
+
// `REROUTE:<model>` is Codex moving the running turn to another model (schema `model/rerouted`).
|
|
78
|
+
const rerouted = /REROUTE:(\S+)/.exec(text)?.[1];
|
|
79
|
+
if (rerouted) note("model/rerouted", { threadId, turnId: turn.id, fromModel: "fake", toModel: rerouted, reason: "highRiskCyberActivity" });
|
|
76
80
|
await Bun.sleep(delayMs);
|
|
77
81
|
const slow = /SLOW:(\d+)/.exec(text); // a turn that keeps running for this many ms
|
|
78
82
|
if (slow) await Bun.sleep(Number(slow[1]));
|
|
@@ -14,7 +14,7 @@ let messageCount = 0;
|
|
|
14
14
|
const send = (value: unknown) => process.stdout.write(`${JSON.stringify(value)}\n`);
|
|
15
15
|
createInterface({ input: process.stdin }).on("line", (line) => {
|
|
16
16
|
const request = JSON.parse(line) as { id?: string; type?: string };
|
|
17
|
-
if (request.type === "get_state") send({ type: "response", id: request.id, command: "get_state", success: true, data: { isStreaming: false, isCompacting: false, pendingMessageCount: 0, messageCount, sessionId, sessionFile } });
|
|
17
|
+
if (request.type === "get_state") send({ type: "response", id: request.id, command: "get_state", success: true, data: { ...(option("--model-id") ? { model: { id: option("--model-id"), name: option("--model-id"), api: "openai-completions", provider: "agent-hub-local" } } : {}), isStreaming: false, isCompacting: false, pendingMessageCount: 0, messageCount, sessionId, sessionFile } });
|
|
18
18
|
else if (request.type === "set_model") send({ type: "response", id: request.id, command: "set_model", success: true });
|
|
19
19
|
else if (request.type === "prompt" || request.type === "steer") { messageCount++; send({ type: "response", id: request.id, command: request.type, success: true }); }
|
|
20
20
|
});
|