harnery 0.34.1 → 0.35.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/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +2 -0
- package/dist/commands/agents.d.ts +15 -4
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +89 -175
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +26 -2
- package/dist/commands/decision.d.ts.map +1 -1
- package/dist/commands/decision.js +2 -2
- package/dist/commands/events.d.ts.map +1 -1
- package/dist/commands/events.js +18 -1
- package/dist/commands/presence.d.ts.map +1 -1
- package/dist/commands/presence.js +2 -2
- package/dist/commands/semantic.d.ts +4 -0
- package/dist/commands/semantic.d.ts.map +1 -0
- package/dist/commands/semantic.js +147 -0
- package/dist/commands/web.d.ts.map +1 -1
- package/dist/commands/web.js +17 -0
- package/dist/core/agents/canonical-emit.d.ts +3 -0
- package/dist/core/agents/canonical-emit.d.ts.map +1 -1
- package/dist/core/agents/canonical-emit.js +12 -0
- package/dist/core/agents/claim-path.d.ts +11 -0
- package/dist/core/agents/claim-path.d.ts.map +1 -0
- package/dist/core/agents/claim-path.js +22 -0
- package/dist/core/agents/coord-client.d.ts +29 -3
- package/dist/core/agents/coord-client.d.ts.map +1 -1
- package/dist/core/agents/coord-client.js +88 -9
- package/dist/core/agents/live-authority-v3.d.ts.map +1 -1
- package/dist/core/agents/live-authority-v3.js +1 -3
- package/dist/core/agents/live-lifecycle-v3.js +3 -3
- package/dist/core/agents/live-observation-v3.d.ts.map +1 -1
- package/dist/core/agents/live-observation-v3.js +2 -2
- package/dist/core/agents/render/prompt-context.js +12 -10
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
- package/dist/core/agents/rules/stop-hook.js +23 -11
- package/dist/core/agents/session-name-display.d.ts +1 -0
- package/dist/core/agents/session-name-display.d.ts.map +1 -1
- package/dist/core/agents/session-name-display.js +8 -1
- package/dist/core/agents/state/heartbeat-reader.d.ts +46 -0
- package/dist/core/agents/state/heartbeat-reader.d.ts.map +1 -0
- package/dist/core/agents/state/heartbeat-reader.js +25 -0
- package/dist/core/agents/state/heartbeat-writer.d.ts +3 -48
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +16 -34
- package/dist/core/agents/state/live-coordination-view.d.ts +1 -1
- package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-view.js +25 -1
- package/dist/core/agents/state/names.d.ts +9 -1
- package/dist/core/agents/state/names.d.ts.map +1 -1
- package/dist/core/agents/state/names.js +190 -182
- package/dist/core/agents/state/stale-sweep.d.ts.map +1 -1
- package/dist/core/agents/state/stale-sweep.js +23 -5
- package/dist/core/artifacts/constants.d.ts +5 -0
- package/dist/core/artifacts/constants.d.ts.map +1 -0
- package/dist/core/artifacts/constants.js +4 -0
- package/dist/core/artifacts/index.d.ts +3 -3
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +50 -7
- package/dist/core/events/v3/base-contract.d.ts +795 -0
- package/dist/core/events/v3/base-contract.d.ts.map +1 -1
- package/dist/core/events/v3/base-contract.js +33 -0
- package/dist/core/events/v3/capabilities.d.ts +11 -0
- package/dist/core/events/v3/capabilities.d.ts.map +1 -1
- package/dist/core/events/v3/capabilities.js +23 -0
- package/dist/core/events/v3/generated.d.ts +1 -1
- package/dist/core/events/v3/generated.js +1 -1
- package/dist/core/events/v3/index.d.ts +4 -3
- package/dist/core/events/v3/index.d.ts.map +1 -1
- package/dist/core/events/v3/index.js +4 -3
- package/dist/core/events/v3/latency.d.ts +31 -1
- package/dist/core/events/v3/latency.d.ts.map +1 -1
- package/dist/core/events/v3/latency.js +127 -3
- package/dist/core/events/v3/live-routing.d.ts +30 -0
- package/dist/core/events/v3/live-routing.d.ts.map +1 -1
- package/dist/core/events/v3/live-routing.js +109 -1
- package/dist/core/events/v3/producers/command-recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/command-recorder.js +10 -1
- package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/coordination-recorder.js +14 -3
- package/dist/core/events/v3/producers/hook-base.d.ts +17 -1
- package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -1
- package/dist/core/events/v3/producers/hook-base.js +82 -1
- package/dist/core/events/v3/producers/intake.d.ts +6 -0
- package/dist/core/events/v3/producers/intake.d.ts.map +1 -1
- package/dist/core/events/v3/producers/intake.js +11 -0
- package/dist/core/events/v3/producers/recorder.d.ts +62 -0
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/recorder.js +654 -18
- package/dist/core/events/v3/runtime-telemetry-capabilities.d.ts +51 -0
- package/dist/core/events/v3/runtime-telemetry-capabilities.d.ts.map +1 -0
- package/dist/core/events/v3/runtime-telemetry-capabilities.js +54 -0
- package/dist/core/events/v3/turn-telemetry.d.ts +9 -0
- package/dist/core/events/v3/turn-telemetry.d.ts.map +1 -1
- package/dist/core/hooks/adapter/parse.d.ts +3 -0
- package/dist/core/hooks/adapter/parse.d.ts.map +1 -1
- package/dist/core/hooks/adapter/parse.js +14 -0
- package/dist/core/hooks/adapter/runtime-telemetry.d.ts +119 -0
- package/dist/core/hooks/adapter/runtime-telemetry.d.ts.map +1 -0
- package/dist/core/hooks/adapter/runtime-telemetry.js +568 -0
- package/dist/core/hooks/cli.js +111 -36
- package/dist/core/hooks/remediation-cap.d.ts +34 -0
- package/dist/core/hooks/remediation-cap.d.ts.map +1 -0
- package/dist/core/hooks/remediation-cap.js +71 -0
- package/dist/core/hooks/resolve/transcript.d.ts +25 -9
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
- package/dist/core/hooks/resolve/transcript.js +22 -10
- package/dist/core/semantic/adapters.d.ts +34 -0
- package/dist/core/semantic/adapters.d.ts.map +1 -0
- package/dist/core/semantic/adapters.js +222 -0
- package/dist/core/semantic/contract.d.ts +588 -0
- package/dist/core/semantic/contract.d.ts.map +1 -0
- package/dist/core/semantic/contract.js +230 -0
- package/dist/core/semantic/evidence.d.ts +11 -0
- package/dist/core/semantic/evidence.d.ts.map +1 -0
- package/dist/core/semantic/evidence.js +262 -0
- package/dist/core/semantic/index.d.ts +10 -0
- package/dist/core/semantic/index.d.ts.map +1 -0
- package/dist/core/semantic/index.js +9 -0
- package/dist/core/semantic/once.d.ts +33 -0
- package/dist/core/semantic/once.d.ts.map +1 -0
- package/dist/core/semantic/once.js +293 -0
- package/dist/core/semantic/prompt.d.ts +12 -0
- package/dist/core/semantic/prompt.d.ts.map +1 -0
- package/dist/core/semantic/prompt.js +70 -0
- package/dist/core/semantic/scheduler.d.ts +16 -0
- package/dist/core/semantic/scheduler.d.ts.map +1 -0
- package/dist/core/semantic/scheduler.js +67 -0
- package/dist/core/semantic/service-status.d.ts +31 -0
- package/dist/core/semantic/service-status.d.ts.map +1 -0
- package/dist/core/semantic/service-status.js +84 -0
- package/dist/core/semantic/service.d.ts +51 -0
- package/dist/core/semantic/service.d.ts.map +1 -0
- package/dist/core/semantic/service.js +470 -0
- package/dist/core/semantic/storage.d.ts +71 -0
- package/dist/core/semantic/storage.d.ts.map +1 -0
- package/dist/core/semantic/storage.js +179 -0
- package/dist/core/semantic/validate.d.ts +16 -0
- package/dist/core/semantic/validate.d.ts.map +1 -0
- package/dist/core/semantic/validate.js +174 -0
- package/dist/lib/browser/client.d.ts +11 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +13 -0
- package/dist/lib/browser/index.d.ts +1 -0
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/standalone-html.d.ts +25 -0
- package/dist/lib/browser/standalone-html.d.ts.map +1 -0
- package/dist/lib/browser/standalone-html.js +284 -0
- package/dist/lib/instructions/apply.d.ts.map +1 -1
- package/dist/lib/instructions/apply.js +1 -0
- package/dist/lib/instructions/templates.d.ts +2 -0
- package/dist/lib/instructions/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +144 -4
- package/package.json +6 -1
- package/schemas/event-v3.schema.json +2758 -478
- package/src/commander.ts +2 -0
- package/src/commands/agents.ts +102 -167
- package/src/commands/browse.ts +25 -2
- package/src/commands/decision.ts +8 -2
- package/src/commands/events.ts +21 -1
- package/src/commands/presence.ts +7 -2
- package/src/commands/semantic.ts +179 -0
- package/src/commands/web.ts +15 -0
- package/src/core/agents/canonical-emit.ts +15 -0
- package/src/core/agents/claim-path.ts +23 -0
- package/src/core/agents/coord-client.ts +92 -8
- package/src/core/agents/live-authority-v3.ts +1 -4
- package/src/core/agents/live-lifecycle-v3.ts +8 -3
- package/src/core/agents/live-observation-v3.ts +7 -2
- package/src/core/agents/render/prompt-context.ts +13 -10
- package/src/core/agents/rules/stop-hook.ts +24 -11
- package/src/core/agents/session-name-display.ts +9 -1
- package/src/core/agents/state/heartbeat-reader.ts +69 -0
- package/src/core/agents/state/heartbeat-writer.ts +20 -84
- package/src/core/agents/state/live-coordination-view.ts +26 -1
- package/src/core/agents/state/names.ts +190 -182
- package/src/core/agents/state/stale-sweep.ts +25 -5
- package/src/core/artifacts/constants.ts +4 -0
- package/src/core/artifacts/index.ts +49 -7
- package/src/core/events/v3/base-contract.ts +39 -0
- package/src/core/events/v3/capabilities.ts +34 -0
- package/src/core/events/v3/generated.ts +1 -1
- package/src/core/events/v3/index.ts +21 -0
- package/src/core/events/v3/latency.ts +213 -2
- package/src/core/events/v3/live-routing.ts +120 -1
- package/src/core/events/v3/producers/command-recorder.ts +10 -1
- package/src/core/events/v3/producers/coordination-recorder.ts +17 -5
- package/src/core/events/v3/producers/hook-base.ts +115 -1
- package/src/core/events/v3/producers/intake.ts +18 -0
- package/src/core/events/v3/producers/recorder.ts +856 -21
- package/src/core/events/v3/runtime-telemetry-capabilities.ts +137 -0
- package/src/core/events/v3/turn-telemetry.ts +10 -0
- package/src/core/hooks/adapter/parse.ts +16 -0
- package/src/core/hooks/adapter/runtime-telemetry.ts +805 -0
- package/src/core/hooks/cli.ts +123 -39
- package/src/core/hooks/remediation-cap.ts +77 -0
- package/src/core/hooks/resolve/transcript.ts +37 -11
- package/src/core/semantic/adapters.ts +293 -0
- package/src/core/semantic/contract.ts +298 -0
- package/src/core/semantic/evidence.ts +336 -0
- package/src/core/semantic/index.ts +127 -0
- package/src/core/semantic/once.ts +410 -0
- package/src/core/semantic/prompt.ts +84 -0
- package/src/core/semantic/scheduler.ts +107 -0
- package/src/core/semantic/service-status.ts +118 -0
- package/src/core/semantic/service.ts +580 -0
- package/src/core/semantic/storage.ts +286 -0
- package/src/core/semantic/validate.ts +212 -0
- package/src/lib/browser/client.ts +21 -0
- package/src/lib/browser/index.ts +4 -0
- package/src/lib/browser/standalone-html.ts +312 -0
- package/src/lib/instructions/apply.ts +1 -0
- package/src/lib/instructions/templates.ts +149 -4
package/dist/commander.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commander.d.ts","sourceRoot":"","sources":["../src/commander.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"commander.d.ts","sourceRoot":"","sources":["../src/commander.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6CpC,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAEhC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED,8CAA8C;AAC9C,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,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AAM,EAAE,CAAC;IACtC;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;CACjE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,IAAI,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACxC,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC;IAC5C,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC3D,KAAK,CAAC,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,KAAK,GAAG,OAAO,GAAG,IAAI,CAAC;IACrF,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;IACpE,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,eAAO,MAAM,WAAW,EAAE,WAkCzB,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,IAAI,GAAE,kBAAuB,GAAG,OAAO,CA0D3E"}
|
package/dist/commander.js
CHANGED
|
@@ -52,6 +52,7 @@ import { registerPolicyCommand } from "./commands/policy.js";
|
|
|
52
52
|
import { registerPresenceCommand } from "./commands/presence.js";
|
|
53
53
|
import { registerReadCommand } from "./commands/read.js";
|
|
54
54
|
import { registerRelayCommand } from "./commands/relay.js";
|
|
55
|
+
import { registerSemanticCommand } from "./commands/semantic.js";
|
|
55
56
|
import { registerSyncCommand } from "./commands/sync.js";
|
|
56
57
|
import { registerSectionCommand, registerTocCommand } from "./commands/toc.js";
|
|
57
58
|
import { registerTokensCommand } from "./commands/tokens.js";
|
|
@@ -127,6 +128,7 @@ export function createHarneryProgram(opts = {}) {
|
|
|
127
128
|
registerCheckpointCommand(program, emit, opts.context);
|
|
128
129
|
registerJournalCommand(program, emit);
|
|
129
130
|
registerLedgerV3Command(program, emit, opts.context);
|
|
131
|
+
registerSemanticCommand(program, emit, opts.context);
|
|
130
132
|
registerEventsCommand(program, emit, opts.context);
|
|
131
133
|
registerArtifactsCommand(program, emit, opts.context);
|
|
132
134
|
registerDecisionCommand(program, emit);
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import type { Command } from "commander";
|
|
16
16
|
import type { EmitContext, HarneryProgramContext } from "../commander.js";
|
|
17
|
+
import { nativeSessionIdentity } from "../core/agents/index.js";
|
|
17
18
|
import { type SessionFinalizationRequestV3 } from "../core/agents/session-finalizer-v3.js";
|
|
18
|
-
import { type Heartbeat } from "../core/agents/state/heartbeat-writer.js";
|
|
19
19
|
import type { EventTypeV3 } from "../core/events/v3/contract.js";
|
|
20
20
|
/**
|
|
21
21
|
* Spawn options for agent-coord child processes: pin the coord root the
|
|
@@ -32,8 +32,7 @@ export declare function coordHelperOpts(root: string): {
|
|
|
32
32
|
cwd: string;
|
|
33
33
|
env: NodeJS.ProcessEnv;
|
|
34
34
|
};
|
|
35
|
-
|
|
36
|
-
export declare function nativeSessionIdentity(row: Pick<Heartbeat, "native_session_id" | "session_id"> | null | undefined, fallback: string): string;
|
|
35
|
+
export { nativeSessionIdentity };
|
|
37
36
|
export declare function registerAgentsCommand(program: Command, emitParam: EmitContext, programContext?: HarneryProgramContext): void;
|
|
38
37
|
export declare function registerCouncilCommands(parent: Command): void;
|
|
39
38
|
type StatusPeerHeartbeat = {
|
|
@@ -126,6 +125,19 @@ export type EventLedgerHealthV3 = {
|
|
|
126
125
|
* that fails to read lands in `collection_errors` instead of aborting the rest.
|
|
127
126
|
*/
|
|
128
127
|
export declare function collectEventLedgerHealthV3(root: string, nowMs?: number): EventLedgerHealthV3;
|
|
128
|
+
/**
|
|
129
|
+
* Tally stop-hook remediation-cap exhaustions in the window from
|
|
130
|
+
* `.harnery/debug/agent-hook.ndjson` (rows with
|
|
131
|
+
* `skipped: "stop-remediation-cap-exhausted"`). Each one is a session whose
|
|
132
|
+
* end-of-turn evidence never landed, so the Stop hook gave up bouncing it and
|
|
133
|
+
* let the turn end unenforced — a compliance gap an operator should see
|
|
134
|
+
* without grepping the debug ledger.
|
|
135
|
+
*/
|
|
136
|
+
export declare function readStopRemediationExhaustions(root: string, cutoffMs: number): {
|
|
137
|
+
total: number;
|
|
138
|
+
latestAt: string | null;
|
|
139
|
+
sessions: string[];
|
|
140
|
+
};
|
|
129
141
|
/** Tally agent-hook failures (.harnery/debug/agent-hook.errors.ndjson) in the
|
|
130
142
|
* window by exact error and phase, while separating current-hour failures from
|
|
131
143
|
* historical rows. Each line is {ts, error, phase, ...}. */
|
|
@@ -173,5 +185,4 @@ export interface ActiveAgentHealthSummary {
|
|
|
173
185
|
* V3 generations, not disposable heartbeat caches, are the active-agent authority.
|
|
174
186
|
*/
|
|
175
187
|
export declare function collectActiveAgentHealth(root: string, nowMs?: number): ActiveAgentHealthSummary;
|
|
176
|
-
export {};
|
|
177
188
|
//# sourceMappingURL=agents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/commands/agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/commands/agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAcH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAA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D;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,KAAK,SAAa,GACjB,wBAAwB,CA0C1B"}
|
package/dist/commands/agents.js
CHANGED
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
* harn agents health --since 7d --json
|
|
14
14
|
*/
|
|
15
15
|
import { spawnSync } from "node:child_process";
|
|
16
|
-
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync,
|
|
16
|
+
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync, } from "node:fs";
|
|
17
17
|
import { homedir, tmpdir } from "node:os";
|
|
18
18
|
import { basename, join, resolve } from "node:path";
|
|
19
19
|
import { coordBinPath } from "../core/agents/coord-bin.js";
|
|
20
20
|
import { checkGitFinalization, formatGitFinalizationFailure, readSessionWriteClaims, } from "../core/agents/finalization.js";
|
|
21
|
-
import { emitEventV3, monorepoRoot, normalizeAdapter, resolveOwner, resolveOwnerBySessionEnv, resolveOwnerWithSource, sessionIdentityFromEnv, } from "../core/agents/index.js";
|
|
21
|
+
import { emitEventV3, monorepoRoot, nativeSessionIdentity, normalizeAdapter, resolveOwner, resolveOwnerBySessionEnv, resolveOwnerWithSource, sessionIdentityFromEnv, } from "../core/agents/index.js";
|
|
22
22
|
import { reopenLiveCoordinationGenerationV3 } from "../core/agents/live-authority-v3.js";
|
|
23
23
|
import { listSessionFinalizationRequestsV3, observeHostDisappearedV3, reconcileSessionFinalizationV3, requestSessionEndExplicitV3, } from "../core/agents/session-finalizer-v3.js";
|
|
24
|
-
import { SESSION_NAME_DISPLAY_NOTE } from "../core/agents/session-name-display.js";
|
|
24
|
+
import { SESSION_NAME_DISPLAY_NOTE, sessionNameDisplayPending, } from "../core/agents/session-name-display.js";
|
|
25
25
|
import { buildLifecycleSuggestedName, buildSuggestedName, readHeartbeat as readHeartbeatCache, } from "../core/agents/state/heartbeat-writer.js";
|
|
26
26
|
import { readLiveCoordinationRow, readLiveCoordinationRows, } from "../core/agents/state/live-coordination-view.js";
|
|
27
27
|
import { foldSessionState, } from "../core/agents/state/session-state.js";
|
|
@@ -34,6 +34,7 @@ import { listHookProducerStateRecordsV3, readHookProducerStateV3, } from "../cor
|
|
|
34
34
|
import { readLedgerV3 } from "../core/events/v3/reader.js";
|
|
35
35
|
import { EVENT_V3_LEDGER_RELATIVE_ROOT } from "../core/events/v3/writer.js";
|
|
36
36
|
import { evaluateRunQualityIfDue } from "../core/guard/index.js";
|
|
37
|
+
import { readRuntimeContextUsage } from "../core/hooks/adapter/runtime-telemetry.js";
|
|
37
38
|
import { readRemoteMachines } from "../core/presence/index.js";
|
|
38
39
|
import { registerContextCommand } from "./context.js";
|
|
39
40
|
function readCurrentCoordinationRow(instanceId) {
|
|
@@ -57,9 +58,8 @@ import { displayName as displayAgentName, ensureIdentity, listIdentities, lookup
|
|
|
57
58
|
function freshnessCutoffSecs() {
|
|
58
59
|
return coordFreshnessSeconds();
|
|
59
60
|
}
|
|
60
|
-
const SUBAGENT_NOTE = "
|
|
61
|
-
"
|
|
62
|
-
"bridge (per-shell marker file at .harnery/shells/<pid>) is out of scope.";
|
|
61
|
+
const SUBAGENT_NOTE = "Native adapter subagents resolve to their own child generation after the hook bridge " +
|
|
62
|
+
"observes delegation. An unbridged subprocess shell still resolves through its parent.";
|
|
63
63
|
/**
|
|
64
64
|
* Spawn options for agent-coord child processes: pin the coord root the
|
|
65
65
|
* command already resolved (git-superproject-aware via `monorepoRoot()`), so
|
|
@@ -122,18 +122,7 @@ function activityOf(hb) {
|
|
|
122
122
|
function taskStateOf(hb) {
|
|
123
123
|
return hb.task_state ?? "active";
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
export function nativeSessionIdentity(row, fallback) {
|
|
127
|
-
if (row?.native_session_id)
|
|
128
|
-
return row.native_session_id;
|
|
129
|
-
// A projection-only row carries the privacy-safe canonical session
|
|
130
|
-
// fingerprint, not the adapter's native session ID needed to join the hook
|
|
131
|
-
// producer. Until a disposable cache exists, the resolved owner is the only
|
|
132
|
-
// native identity available to command surfaces such as `agents status`.
|
|
133
|
-
if (row?.session_id && !/^sid_[a-f0-9]{64}$/.test(row.session_id))
|
|
134
|
-
return row.session_id;
|
|
135
|
-
return fallback;
|
|
136
|
-
}
|
|
125
|
+
export { nativeSessionIdentity };
|
|
137
126
|
function lifecycleLabel(hb) {
|
|
138
127
|
const state = taskStateOf(hb);
|
|
139
128
|
return state === "blocked" && hb.task_state_reason ? `${state}: ${hb.task_state_reason}` : state;
|
|
@@ -176,9 +165,9 @@ export function registerAgentsCommand(program, emitParam, programContext) {
|
|
|
176
165
|
cmd
|
|
177
166
|
.command("suggest-name [description...]")
|
|
178
167
|
.description('Reprint a session name ("Agent <you> - <description>") for the operator to set as their ' +
|
|
179
|
-
"adapter tab title. With no arg, derives
|
|
168
|
+
"adapter tab title. With no arg, prefers the exact pending name, then derives from your current task. The primary naming path " +
|
|
180
169
|
"is set-task (it suggests a name on the first focus declaration); reach for this to reprint " +
|
|
181
|
-
"or
|
|
170
|
+
"or to create an explicit pending-display retry with --json. Read-only.")
|
|
182
171
|
.option("--json", "JSON output instead of the bare name")
|
|
183
172
|
.option("--session-id <id>", "Lookup the V3 generation by session_id directly, bypassing the ppid walk.")
|
|
184
173
|
.action((description, opts) => {
|
|
@@ -1378,24 +1367,17 @@ function runSetTask(task, opts) {
|
|
|
1378
1367
|
// the first time. `first_of_session: true` means exactly "this call produced
|
|
1379
1368
|
// the session name" — it is never true with a null name (an empty first
|
|
1380
1369
|
// declaration or a `--session-id` relay both keep the window open instead).
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
//
|
|
1387
|
-
//
|
|
1388
|
-
//
|
|
1389
|
-
|
|
1390
|
-
const retriedSuggestedName = !firstSuggestedName &&
|
|
1391
|
-
priorHb?.suggested_session_name &&
|
|
1392
|
-
priorHb.session_name_seen_for !== priorHb.suggested_session_name &&
|
|
1393
|
-
hb?.suggested_session_name === priorHb.suggested_session_name
|
|
1394
|
-
? hb.suggested_session_name
|
|
1395
|
-
: null;
|
|
1396
|
-
const suggestedName = firstSuggestedName ?? retriedSuggestedName;
|
|
1370
|
+
// A native generation restart may rebuild the current cache during the
|
|
1371
|
+
// mutation and carry an already-seen suggestion from the prior generation.
|
|
1372
|
+
// That title is continuity evidence, not a new display request.
|
|
1373
|
+
const pendingName = sessionNameDisplayPending(hb);
|
|
1374
|
+
const firstSuggestedName = !priorHb?.suggested_session_name && pendingName ? pendingName : null;
|
|
1375
|
+
// Routine focus declarations stay title-silent. A pending display no longer
|
|
1376
|
+
// turns every repeated set-task into a fresh name instruction; explicit
|
|
1377
|
+
// recovery belongs to `agents suggest-name --json`.
|
|
1378
|
+
const suggestedName = firstSuggestedName;
|
|
1397
1379
|
const firstOfSession = firstSuggestedName !== null;
|
|
1398
|
-
const sessionNameRetry =
|
|
1380
|
+
const sessionNameRetry = false;
|
|
1399
1381
|
emit.data({
|
|
1400
1382
|
instance_id: myOwner,
|
|
1401
1383
|
name: hb?.name ?? null,
|
|
@@ -1610,12 +1592,15 @@ function runSuggestName(descriptionParts, opts) {
|
|
|
1610
1592
|
}
|
|
1611
1593
|
const hb = readCurrentCoordinationRow(myOwner);
|
|
1612
1594
|
const agentName = hb?.name || "unknown";
|
|
1613
|
-
//
|
|
1614
|
-
//
|
|
1615
|
-
//
|
|
1616
|
-
//
|
|
1595
|
+
// A bare suggest-name must prefer the exact pending suggestion over rebuilding
|
|
1596
|
+
// from the current task. The task may have changed since the title was minted;
|
|
1597
|
+
// reconstructing it would produce a block the display latch can never accept.
|
|
1598
|
+
// An explicit description keeps the read-only re-suggest behavior.
|
|
1599
|
+
const pendingName = sessionNameDisplayPending(hb);
|
|
1617
1600
|
const parts = descriptionParts.length > 0 ? descriptionParts : hb?.task ? [hb.task] : [];
|
|
1618
|
-
const built =
|
|
1601
|
+
const built = descriptionParts.length === 0 && pendingName
|
|
1602
|
+
? { suggestedName: pendingName, description: hb?.task ?? pendingName }
|
|
1603
|
+
: buildSuggestedName(agentName, parts);
|
|
1619
1604
|
if (!built) {
|
|
1620
1605
|
emit.error({
|
|
1621
1606
|
code: "no_description",
|
|
@@ -1630,6 +1615,7 @@ function runSuggestName(descriptionParts, opts) {
|
|
|
1630
1615
|
emit.data({
|
|
1631
1616
|
name: displayName,
|
|
1632
1617
|
suggested_session_name: suggestedName,
|
|
1618
|
+
session_name_retry: pendingName === suggestedName,
|
|
1633
1619
|
agent_name: agentName,
|
|
1634
1620
|
description,
|
|
1635
1621
|
});
|
|
@@ -1978,10 +1964,10 @@ function readContextUsage(sessionId, platform) {
|
|
|
1978
1964
|
// store `contextUsagePercent` per composer in workspaceStorage's state.vscdb;
|
|
1979
1965
|
// readCursorContextUsage reads that via bun:sqlite (percent-only).
|
|
1980
1966
|
if (platform === "codex")
|
|
1981
|
-
return
|
|
1967
|
+
return readRuntimeContextUsage("codex", sessionId);
|
|
1982
1968
|
if (platform === "cursor")
|
|
1983
1969
|
return readCursorContextUsage(sessionId);
|
|
1984
|
-
return
|
|
1970
|
+
return readRuntimeContextUsage("claude-code", sessionId);
|
|
1985
1971
|
}
|
|
1986
1972
|
function readCursorContextUsage(sessionId) {
|
|
1987
1973
|
// Cursor stores per-chat (composer) context usage as a percent in each
|
|
@@ -2054,137 +2040,6 @@ function readCursorContextUsage(sessionId) {
|
|
|
2054
2040
|
}
|
|
2055
2041
|
return null;
|
|
2056
2042
|
}
|
|
2057
|
-
function readClaudeContextUsage(sessionId) {
|
|
2058
|
-
const root = monorepoRoot();
|
|
2059
|
-
if (!root)
|
|
2060
|
-
return null;
|
|
2061
|
-
// Claude Code's project dir scheme: prepend "-", replace "/" → "-".
|
|
2062
|
-
const encoded = `-${root.replace(/^\//, "").replace(/\//g, "-")}`;
|
|
2063
|
-
const transcriptPath = resolve(homedir(), ".claude", "projects", encoded, `${sessionId}.jsonl`);
|
|
2064
|
-
if (!existsSync(transcriptPath))
|
|
2065
|
-
return null;
|
|
2066
|
-
let raw;
|
|
2067
|
-
try {
|
|
2068
|
-
raw = readFileSync(transcriptPath, "utf8");
|
|
2069
|
-
}
|
|
2070
|
-
catch {
|
|
2071
|
-
return null;
|
|
2072
|
-
}
|
|
2073
|
-
const lines = raw.split("\n");
|
|
2074
|
-
for (let i = lines.length - 1; i >= 0; i--) {
|
|
2075
|
-
const line = lines[i].trim();
|
|
2076
|
-
if (!line)
|
|
2077
|
-
continue;
|
|
2078
|
-
try {
|
|
2079
|
-
const entry = JSON.parse(line);
|
|
2080
|
-
const usage = entry?.message?.usage;
|
|
2081
|
-
if (entry?.type === "assistant" && usage) {
|
|
2082
|
-
const used = (usage.input_tokens ?? 0) +
|
|
2083
|
-
(usage.cache_creation_input_tokens ?? 0) +
|
|
2084
|
-
(usage.cache_read_input_tokens ?? 0);
|
|
2085
|
-
// Window: hardcode 1M for Opus 4.7 1M (current default). Refine to
|
|
2086
|
-
// model-aware lookup when other models become routine.
|
|
2087
|
-
return { used, window: 1000000 };
|
|
2088
|
-
}
|
|
2089
|
-
}
|
|
2090
|
-
catch {
|
|
2091
|
-
// skip malformed line
|
|
2092
|
-
}
|
|
2093
|
-
}
|
|
2094
|
-
return null;
|
|
2095
|
-
}
|
|
2096
|
-
function readCodexContextUsage(sessionId) {
|
|
2097
|
-
// Codex transcripts: ~/.codex/sessions/YYYY/MM/DD/rollout-<TS>-<sessionId>.jsonl
|
|
2098
|
-
// On WSL the active install often lives on the Windows side under
|
|
2099
|
-
// /mnt/c/Users/<user>/.codex/sessions/; both are searched.
|
|
2100
|
-
const path = findCodexTranscript(sessionId);
|
|
2101
|
-
if (!path)
|
|
2102
|
-
return null;
|
|
2103
|
-
let raw;
|
|
2104
|
-
try {
|
|
2105
|
-
raw = readFileSync(path, "utf8");
|
|
2106
|
-
}
|
|
2107
|
-
catch {
|
|
2108
|
-
return null;
|
|
2109
|
-
}
|
|
2110
|
-
const lines = raw.split("\n");
|
|
2111
|
-
// Walk backwards: most recent token_count event wins.
|
|
2112
|
-
for (let i = lines.length - 1; i >= 0; i--) {
|
|
2113
|
-
const line = lines[i].trim();
|
|
2114
|
-
if (!line)
|
|
2115
|
-
continue;
|
|
2116
|
-
try {
|
|
2117
|
-
const entry = JSON.parse(line);
|
|
2118
|
-
if (entry?.type === "event_msg" && entry?.payload?.type === "token_count") {
|
|
2119
|
-
const info = entry.payload.info;
|
|
2120
|
-
const used = info?.last_token_usage?.input_tokens;
|
|
2121
|
-
const window = info?.model_context_window;
|
|
2122
|
-
if (typeof used === "number" && typeof window === "number" && window > 0) {
|
|
2123
|
-
return { used, window };
|
|
2124
|
-
}
|
|
2125
|
-
}
|
|
2126
|
-
}
|
|
2127
|
-
catch {
|
|
2128
|
-
// skip malformed line
|
|
2129
|
-
}
|
|
2130
|
-
}
|
|
2131
|
-
return null;
|
|
2132
|
-
}
|
|
2133
|
-
function findCodexTranscript(sessionId) {
|
|
2134
|
-
// Candidate roots in priority order.
|
|
2135
|
-
const homeRoot = resolve(homedir(), ".codex", "sessions");
|
|
2136
|
-
const wslRoots = [];
|
|
2137
|
-
try {
|
|
2138
|
-
if (existsSync("/mnt/c/Users")) {
|
|
2139
|
-
for (const entry of readdirSync("/mnt/c/Users")) {
|
|
2140
|
-
wslRoots.push(`/mnt/c/Users/${entry}/.codex/sessions`);
|
|
2141
|
-
}
|
|
2142
|
-
}
|
|
2143
|
-
}
|
|
2144
|
-
catch {
|
|
2145
|
-
// ignore
|
|
2146
|
-
}
|
|
2147
|
-
const roots = [homeRoot, ...wslRoots];
|
|
2148
|
-
const suffix = `-${sessionId}.jsonl`;
|
|
2149
|
-
for (const root of roots) {
|
|
2150
|
-
if (!existsSync(root))
|
|
2151
|
-
continue;
|
|
2152
|
-
try {
|
|
2153
|
-
// Recursive scan: sessions are partitioned by YYYY/MM/DD/, so depth
|
|
2154
|
-
// is bounded at 3 + one file per session. Cheap enough at status time.
|
|
2155
|
-
const stack = [root];
|
|
2156
|
-
while (stack.length) {
|
|
2157
|
-
const dir = stack.pop();
|
|
2158
|
-
let entries;
|
|
2159
|
-
try {
|
|
2160
|
-
entries = readdirSync(dir);
|
|
2161
|
-
}
|
|
2162
|
-
catch {
|
|
2163
|
-
continue;
|
|
2164
|
-
}
|
|
2165
|
-
for (const name of entries) {
|
|
2166
|
-
const full = `${dir}/${name}`;
|
|
2167
|
-
try {
|
|
2168
|
-
const stat = statSync(full);
|
|
2169
|
-
if (stat.isDirectory()) {
|
|
2170
|
-
stack.push(full);
|
|
2171
|
-
}
|
|
2172
|
-
else if (name.endsWith(suffix)) {
|
|
2173
|
-
return full;
|
|
2174
|
-
}
|
|
2175
|
-
}
|
|
2176
|
-
catch {
|
|
2177
|
-
// ignore
|
|
2178
|
-
}
|
|
2179
|
-
}
|
|
2180
|
-
}
|
|
2181
|
-
}
|
|
2182
|
-
catch {
|
|
2183
|
-
// ignore root scan failures
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2186
|
-
return null;
|
|
2187
|
-
}
|
|
2188
2043
|
function formatLocalTime(d) {
|
|
2189
2044
|
// "Sat, May 9, 2026, 3:48 AM CDT", rendered in the Chicago timezone.
|
|
2190
2045
|
return new Intl.DateTimeFormat("en-US", {
|
|
@@ -2643,6 +2498,53 @@ export function collectEventLedgerHealthV3(root, nowMs = Date.now()) {
|
|
|
2643
2498
|
collection_errors: collectionErrors,
|
|
2644
2499
|
};
|
|
2645
2500
|
}
|
|
2501
|
+
/**
|
|
2502
|
+
* Tally stop-hook remediation-cap exhaustions in the window from
|
|
2503
|
+
* `.harnery/debug/agent-hook.ndjson` (rows with
|
|
2504
|
+
* `skipped: "stop-remediation-cap-exhausted"`). Each one is a session whose
|
|
2505
|
+
* end-of-turn evidence never landed, so the Stop hook gave up bouncing it and
|
|
2506
|
+
* let the turn end unenforced — a compliance gap an operator should see
|
|
2507
|
+
* without grepping the debug ledger.
|
|
2508
|
+
*/
|
|
2509
|
+
export function readStopRemediationExhaustions(root, cutoffMs) {
|
|
2510
|
+
const p = resolve(root, ".harnery", "debug", "agent-hook.ndjson");
|
|
2511
|
+
if (!existsSync(p))
|
|
2512
|
+
return { total: 0, latestAt: null, sessions: [] };
|
|
2513
|
+
let raw;
|
|
2514
|
+
try {
|
|
2515
|
+
raw = readFileSync(p, "utf8");
|
|
2516
|
+
}
|
|
2517
|
+
catch {
|
|
2518
|
+
return { total: 0, latestAt: null, sessions: [] };
|
|
2519
|
+
}
|
|
2520
|
+
let total = 0;
|
|
2521
|
+
let latestMs = Number.NEGATIVE_INFINITY;
|
|
2522
|
+
const sessions = new Set();
|
|
2523
|
+
for (const line of raw.split("\n")) {
|
|
2524
|
+
if (!line.includes("stop-remediation-cap-exhausted"))
|
|
2525
|
+
continue;
|
|
2526
|
+
try {
|
|
2527
|
+
const e = JSON.parse(line);
|
|
2528
|
+
if (e.skipped !== "stop-remediation-cap-exhausted")
|
|
2529
|
+
continue;
|
|
2530
|
+
const tsMs = e.ts ? Date.parse(e.ts) : Number.NaN;
|
|
2531
|
+
if (!Number.isFinite(tsMs) || tsMs < cutoffMs)
|
|
2532
|
+
continue;
|
|
2533
|
+
total++;
|
|
2534
|
+
latestMs = Math.max(latestMs, tsMs);
|
|
2535
|
+
if (e.session_id && sessions.size < 5)
|
|
2536
|
+
sessions.add(e.session_id);
|
|
2537
|
+
}
|
|
2538
|
+
catch {
|
|
2539
|
+
/* skip malformed */
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
return {
|
|
2543
|
+
total,
|
|
2544
|
+
latestAt: Number.isFinite(latestMs) ? new Date(latestMs).toISOString() : null,
|
|
2545
|
+
sessions: [...sessions],
|
|
2546
|
+
};
|
|
2547
|
+
}
|
|
2646
2548
|
/** Tally agent-hook failures (.harnery/debug/agent-hook.errors.ndjson) in the
|
|
2647
2549
|
* window by exact error and phase, while separating current-hour failures from
|
|
2648
2550
|
* historical rows. Each line is {ts, error, phase, ...}. */
|
|
@@ -3144,6 +3046,7 @@ function runHealth(opts) {
|
|
|
3144
3046
|
}
|
|
3145
3047
|
}
|
|
3146
3048
|
const hookErrors = readHookErrors(root, cutoffMs, nowMs);
|
|
3049
|
+
const stopRemediation = readStopRemediationExhaustions(root, cutoffMs);
|
|
3147
3050
|
const stream = readStreamStats(root);
|
|
3148
3051
|
const eventLedger = collectEventLedgerHealthV3(root);
|
|
3149
3052
|
// Canonical health.* events carry the full instance_id, already resolved to
|
|
@@ -3248,6 +3151,12 @@ function runHealth(opts) {
|
|
|
3248
3151
|
if (zombieCount > 0) {
|
|
3249
3152
|
anomalies.push(`${zombieCount} zombie heartbeat(s) in active/ (${zombieSamples.join(", ")}); broken files the sweep isn't reaping`);
|
|
3250
3153
|
}
|
|
3154
|
+
if (stopRemediation.total > 0) {
|
|
3155
|
+
const who = stopRemediation.sessions.length > 0
|
|
3156
|
+
? ` (sessions: ${stopRemediation.sessions.map((s) => s.slice(0, 8)).join(", ")})`
|
|
3157
|
+
: "";
|
|
3158
|
+
anomalies.push(`stop-hook remediation cap exhausted ${stopRemediation.total}x in ${opts.since}${who}; these sessions ended turns without the end-of-turn ritual — check why their evidence never lands`);
|
|
3159
|
+
}
|
|
3251
3160
|
if (eventLedger.state === "live") {
|
|
3252
3161
|
// Open spans whose generation has no open turn: the turn ended without its
|
|
3253
3162
|
// tool spans closing, so an explicit end can only queue, never finalize.
|
|
@@ -3306,6 +3215,11 @@ function runHealth(opts) {
|
|
|
3306
3215
|
stream,
|
|
3307
3216
|
zombies: { count: zombieCount, samples: zombieSamples },
|
|
3308
3217
|
event_ledger: eventLedger,
|
|
3218
|
+
stop_remediation: {
|
|
3219
|
+
total: stopRemediation.total,
|
|
3220
|
+
latest_at: stopRemediation.latestAt,
|
|
3221
|
+
sessions: stopRemediation.sessions,
|
|
3222
|
+
},
|
|
3309
3223
|
anomalies,
|
|
3310
3224
|
};
|
|
3311
3225
|
if (opts.json) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browse.d.ts","sourceRoot":"","sources":["../../src/commands/browse.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"browse.d.ts","sourceRoot":"","sources":["../../src/commands/browse.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAgO1E,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,WAAW,EACtB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,IAAI,CA+cN"}
|
package/dist/commands/browse.js
CHANGED
|
@@ -920,9 +920,24 @@ async function runTrioMode(browser, navResult, opts, evalResult, visibility, wid
|
|
|
920
920
|
else if (opts.captureEvaluate) {
|
|
921
921
|
throw new Error("--capture-evaluate requires a screenshot; remove --no-screenshot.");
|
|
922
922
|
}
|
|
923
|
+
// A trio `.html` is opened in a browser later — from the files origin, from
|
|
924
|
+
// another machine, from disk — so it has to carry its own CSS and media. A
|
|
925
|
+
// selector capture is a DOM fragment, not a document, and stays raw.
|
|
923
926
|
const htmlPath = `${prefix}.html`;
|
|
924
|
-
|
|
925
|
-
|
|
927
|
+
let snapshot;
|
|
928
|
+
if (opts.selector) {
|
|
929
|
+
writeFileSync(htmlPath, await browser.htmlContent(opts.selector));
|
|
930
|
+
}
|
|
931
|
+
else {
|
|
932
|
+
try {
|
|
933
|
+
snapshot = await browser.standaloneHtml();
|
|
934
|
+
writeFileSync(htmlPath, snapshot.html);
|
|
935
|
+
}
|
|
936
|
+
catch {
|
|
937
|
+
// Inlining is best-effort; a raw serialization beats no snapshot at all.
|
|
938
|
+
writeFileSync(htmlPath, await browser.htmlContent());
|
|
939
|
+
}
|
|
940
|
+
}
|
|
926
941
|
written.push(htmlPath);
|
|
927
942
|
const diag = browser.diagnostics();
|
|
928
943
|
const jsonPath = `${prefix}.json`;
|
|
@@ -939,6 +954,15 @@ async function runTrioMode(browser, navResult, opts, evalResult, visibility, wid
|
|
|
939
954
|
};
|
|
940
955
|
if (pngBytes !== undefined)
|
|
941
956
|
envelope.screenshotBytes = pngBytes;
|
|
957
|
+
if (snapshot) {
|
|
958
|
+
envelope.htmlSnapshot = {
|
|
959
|
+
stylesheetsInlined: snapshot.stylesheetsInlined,
|
|
960
|
+
stylesheetsLinked: snapshot.stylesheetsLinked,
|
|
961
|
+
resourcesInlined: snapshot.resourcesInlined,
|
|
962
|
+
resourcesLinked: snapshot.resourcesLinked,
|
|
963
|
+
inlinedBytes: snapshot.inlinedBytes,
|
|
964
|
+
};
|
|
965
|
+
}
|
|
942
966
|
if (opts.evaluate)
|
|
943
967
|
envelope.eval = evalResult;
|
|
944
968
|
if (opts.captureEvaluate) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decision.d.ts","sourceRoot":"","sources":["../../src/commands/decision.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"decision.d.ts","sourceRoot":"","sources":["../../src/commands/decision.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA8CnD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,GAAG,IAAI,CAgStF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { emitEventV3, monorepoRoot, normalizeAdapter, resolveOwner } from "../core/agents/index.js";
|
|
2
|
+
import { emitEventV3, monorepoRoot, nativeSessionIdentity, normalizeAdapter, resolveOwner, } from "../core/agents/index.js";
|
|
3
3
|
import { readLiveCoordinationRow } from "../core/agents/state/live-coordination-view.js";
|
|
4
4
|
import { resolveBinName } from "../core/config.js";
|
|
5
5
|
import { archiveDecision, claimDecision, DECISION_STAKES, fileDecision, isStakes, isStatus, isTier, isVerdict, listDecisions, reopenDecision, resolveDecision, reviewDecision, searchDecisions, showDecision, supersedeDecision, triageDecision, wontfixDecision, } from "../lib/decision/index.js";
|
|
@@ -349,7 +349,7 @@ function emitDecisionEvent(newState, manifest, priorState) {
|
|
|
349
349
|
const hb = root ? readLiveCoordinationRow(root, owner) : null;
|
|
350
350
|
emitEventV3({
|
|
351
351
|
owner,
|
|
352
|
-
session: hb
|
|
352
|
+
session: nativeSessionIdentity(hb, owner),
|
|
353
353
|
adapter: normalizeAdapter(hb?.platform),
|
|
354
354
|
observation: {
|
|
355
355
|
event_type: "decision.state_changed",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/commands/events.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/commands/events.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAmC1E,uEAAuE;AACvE,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,WAAW,EACjB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,IAAI,CA+CN"}
|
package/dist/commands/events.js
CHANGED
|
@@ -72,6 +72,7 @@ function summarizeByGeneration(turns) {
|
|
|
72
72
|
tool_ms: sumMetrics(group.map(({ tool_ms }) => tool_ms)),
|
|
73
73
|
command_ms: sumMetrics(group.map(({ command_exclusive_ms }) => command_exclusive_ms)),
|
|
74
74
|
wait_ms: sumMetrics(group.map(({ wait_ms }) => wait_ms)),
|
|
75
|
+
agent_action_ms: sumMetrics(group.map(({ response_latency }) => response_latency.agent_action_ms)),
|
|
75
76
|
inference_ms: sumMetrics(group.map(({ inference_ms }) => inference_ms)),
|
|
76
77
|
harness_ms: sumMetrics(group.map(({ harness_ms }) => harness_ms)),
|
|
77
78
|
residual_ms: sumMetrics(group.map(({ residual_ms }) => residual_ms)),
|
|
@@ -129,6 +130,8 @@ function renderTurns(turns) {
|
|
|
129
130
|
"TOOL",
|
|
130
131
|
"COMMAND",
|
|
131
132
|
"WAIT",
|
|
133
|
+
"ACTION",
|
|
134
|
+
"POST-TOOL",
|
|
132
135
|
"INFERENCE",
|
|
133
136
|
"HARNESS",
|
|
134
137
|
"RESIDUAL",
|
|
@@ -140,6 +143,8 @@ function renderTurns(turns) {
|
|
|
140
143
|
formatMetric(turn.tool_ms),
|
|
141
144
|
formatMetric(turn.command_exclusive_ms),
|
|
142
145
|
formatMetric(turn.wait_ms),
|
|
146
|
+
formatMetric(turn.response_latency.agent_action_ms),
|
|
147
|
+
formatMetric(turn.response_latency.post_tool_response_ms),
|
|
143
148
|
formatMetric(turn.inference_ms),
|
|
144
149
|
formatMetric(turn.harness_ms),
|
|
145
150
|
formatMetric(turn.residual_ms),
|
|
@@ -147,13 +152,25 @@ function renderTurns(turns) {
|
|
|
147
152
|
]));
|
|
148
153
|
}
|
|
149
154
|
function renderGenerations(rows) {
|
|
150
|
-
return renderTable([
|
|
155
|
+
return renderTable([
|
|
156
|
+
"GENERATION",
|
|
157
|
+
"TURNS",
|
|
158
|
+
"WALL",
|
|
159
|
+
"TOOL",
|
|
160
|
+
"COMMAND",
|
|
161
|
+
"WAIT",
|
|
162
|
+
"ACTION",
|
|
163
|
+
"INFERENCE",
|
|
164
|
+
"HARNESS",
|
|
165
|
+
"RESIDUAL",
|
|
166
|
+
], rows.map((row) => [
|
|
151
167
|
row.generation_id,
|
|
152
168
|
String(row.turns),
|
|
153
169
|
formatMetric(row.wall_ms),
|
|
154
170
|
formatMetric(row.tool_ms),
|
|
155
171
|
formatMetric(row.command_ms),
|
|
156
172
|
formatMetric(row.wait_ms),
|
|
173
|
+
formatMetric(row.agent_action_ms),
|
|
157
174
|
formatMetric(row.inference_ms),
|
|
158
175
|
formatMetric(row.harness_ms),
|
|
159
176
|
formatMetric(row.residual_ms),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../../src/commands/presence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../../src/commands/presence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA2BnD;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CA8KjF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { monorepoRoot } from "../core/agents/coord-client.js";
|
|
2
|
-
import { emitEventV3, normalizeAdapter, resolveOwner } from "../core/agents/index.js";
|
|
2
|
+
import { emitEventV3, nativeSessionIdentity, normalizeAdapter, resolveOwner, } from "../core/agents/index.js";
|
|
3
3
|
import { readLiveCoordinationRow } from "../core/agents/state/live-coordination-view.js";
|
|
4
4
|
import { fetchPresence, publishPresence, readRemoteMachines, relayDaemonStatus, runRelayDaemon, } from "../core/presence/index.js";
|
|
5
5
|
import { ageSeconds, applyDetection, clearPresence, formatAge, presenceFilePath, readPresence, writePresence, } from "../lib/presence.js";
|
|
@@ -203,7 +203,7 @@ function emitPresenceChange(from, to, source) {
|
|
|
203
203
|
const hb = root ? readLiveCoordinationRow(root, owner) : null;
|
|
204
204
|
emitEventV3({
|
|
205
205
|
owner,
|
|
206
|
-
session: hb
|
|
206
|
+
session: nativeSessionIdentity(hb, owner),
|
|
207
207
|
adapter: normalizeAdapter(hb?.platform),
|
|
208
208
|
observation: {
|
|
209
209
|
event_type: "coord.presence_changed",
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { EmitContext, HarneryProgramContext } from "../commander.js";
|
|
3
|
+
export declare function registerSemanticCommand(program: Command, emit: EmitContext, context?: HarneryProgramContext): void;
|
|
4
|
+
//# sourceMappingURL=semantic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic.d.ts","sourceRoot":"","sources":["../../src/commands/semantic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAc1E,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,WAAW,EACjB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,IAAI,CAiIN"}
|