@zhivex-ai/harness 1.2.0 → 1.3.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +7 -8
  3. package/contracts/engine-api.json +2587 -0
  4. package/dist/acp-cli.js +95 -14996
  5. package/dist/cli/cli-options.d.ts +2 -41
  6. package/dist/cli/cli-stream.d.ts +2 -167
  7. package/dist/cli/run-document.d.ts +2 -91
  8. package/dist/cli/terminal/terminal-continuation.d.ts +2 -3
  9. package/dist/{cli-entry-427869g9.js → cli-entry-0mmeag20.js} +49 -1
  10. package/dist/{cli-entry-b1mfvmxe.js → cli-entry-7h9savv5.js} +1 -2
  11. package/dist/{cli-entry-c2f58zj2.js → cli-entry-xmf48p6a.js} +27 -18
  12. package/dist/{cli-3jmy4h5h.js → cli-qgwvtk0w.js} +5 -6
  13. package/dist/cli.js +2 -2
  14. package/dist/client/continuation.d.ts +3 -0
  15. package/dist/client/run-document.d.ts +91 -0
  16. package/dist/client/stream.d.ts +167 -0
  17. package/dist/compat/cli-options.d.ts +41 -0
  18. package/dist/compat/code-support.d.ts +22 -0
  19. package/dist/compat/code-support.js +138 -0
  20. package/dist/config-6gtpxvjv.js +59 -0
  21. package/dist/{config-1k9t4jhh.js → config-q32jm1e6.js} +1 -1
  22. package/dist/engine/acp.d.ts +4 -0
  23. package/dist/engine/acp.js +9 -0
  24. package/dist/engine/client.d.ts +6 -0
  25. package/dist/engine/client.js +21 -0
  26. package/dist/engine/index.d.ts +61 -0
  27. package/dist/engine/index.js +477 -0
  28. package/dist/engine/protocol.d.ts +6 -0
  29. package/dist/engine/protocol.js +158 -0
  30. package/dist/engine/service.d.ts +5 -0
  31. package/dist/engine/service.js +21 -0
  32. package/dist/hostile-repository-demo.js +59 -1
  33. package/dist/index-1bx83sw4.js +4 -0
  34. package/dist/index-2aymdsqc.js +150 -0
  35. package/dist/index-41fkzt91.js +293 -0
  36. package/dist/index-5wjwe91x.js +9434 -0
  37. package/dist/index-77h9qr5h.js +326 -0
  38. package/dist/index-d0wrghff.js +3271 -0
  39. package/dist/index-f4sb0e2q.js +318 -0
  40. package/dist/index-fvca1xea.js +2069 -0
  41. package/dist/index-kfgt9yqq.js +526 -0
  42. package/dist/index-pgqz45fj.js +2449 -0
  43. package/dist/index.js +238 -18649
  44. package/dist/service-cli.js +10 -14502
  45. package/dist/{service-client-cli-yx56n0hc.js → service-client-cli-gs78wrxe.js} +2 -2
  46. package/dist/verify-historical-migrations.js +59 -1
  47. package/dist/zhx.js +2 -2
  48. package/docs/CODE_RELEASE.md +93 -0
  49. package/docs/ENGINE_API.md +111 -0
  50. package/docs/FIRST_USE.md +6 -6
  51. package/docs/README.md +5 -0
  52. package/docs/STABILITY.md +6 -0
  53. package/evaluations/representative-assembly-matrix.json +28 -1
  54. package/examples/README.md +1 -1
  55. package/package.json +35 -4
@@ -1,41 +1,2 @@
1
- export interface CliOptionDefinition {
2
- repeatable: boolean;
3
- conflictsWith: readonly string[];
4
- }
5
- export interface CliCommandOptionContract {
6
- allowed: readonly string[];
7
- required: readonly (string | readonly string[])[];
8
- repeatable: readonly string[];
9
- conflicts: Readonly<Record<string, readonly string[]>>;
10
- }
11
- export declare const CLI_OPTION_NAMES: readonly ["--compaction-model", "--compaction-provider", "--provider", "--model", "--reasoning", "--profile", "--route", "--workspace", "--state-dir", "--mcp-config", "--context-config", "--no-project-context", "--patch", "--preconditions", "--now", "--require-verified-delivery", "--execution", "--oci-runtime", "--oci-image", "--oci-allow-command", "--oci-shell", "--oci-max-process-runtime-ms", "--oci-max-process-output-bytes", "--oci-max-memory-mb", "--oci-max-pids", "--oci-max-cpus", "--oci-max-workspace-bytes", "--oci-max-file-write-bytes", "--oci-tmpfs-mb", "--store", "--tenant", "--user", "--namespace", "--idempotency-key", "--token-budget", "--context-tokens", "--no-token-budget", "--max-steps", "--timeout-ms", "--max-tool-calls", "--max-tool-errors", "--max-input-tokens", "--max-output-tokens", "--max-total-tokens", "--subagent-max-steps", "--subagent-max-tool-calls", "--subagent-max-tool-errors", "--subagent-max-input-tokens", "--subagent-max-output-tokens", "--subagent-max-total-tokens", "--subagent-timeout-ms", "--max-parallel-reviews", "--max-cost-usd", "--input-cost-per-million", "--output-cost-per-million", "--allow-check", "--require-capability", "--subagent", "--reviewer", "--approval-mode", "--yes", "--approve", "--deny", "--json", "--jsonl", "--session", "--continue", "--update", "--status", "--limit", "--cursor", "--before", "--reason", "--cascade", "--final", "--service", "--apply", "--help", "--version", "--search", "--pricing-file", "--usage-limit-usd"];
12
- export type CliOptionName = (typeof CLI_OPTION_NAMES)[number];
13
- export declare const CLI_OPTION_DEFINITIONS: Readonly<Record<CliOptionName, CliOptionDefinition>>;
14
- export declare const CLI_COMMAND_OPTION_CONTRACTS: {
15
- readonly init: CliCommandOptionContract;
16
- readonly run: CliCommandOptionContract;
17
- readonly review: CliCommandOptionContract;
18
- readonly chat: CliCommandOptionContract;
19
- readonly providers: CliCommandOptionContract;
20
- readonly doctor: CliCommandOptionContract;
21
- readonly resume: CliCommandOptionContract;
22
- readonly "runs:list": CliCommandOptionContract;
23
- readonly "runs:inspect": CliCommandOptionContract;
24
- readonly "runs:cancel": CliCommandOptionContract;
25
- readonly "runs:cleanup": CliCommandOptionContract;
26
- readonly "runs:export": CliCommandOptionContract;
27
- readonly "sessions:list": CliCommandOptionContract;
28
- readonly "sessions:inspect": CliCommandOptionContract;
29
- readonly "sessions:rename": CliCommandOptionContract;
30
- readonly "sessions:fork": CliCommandOptionContract;
31
- readonly "sessions:archive": CliCommandOptionContract;
32
- readonly "changes:create": CliCommandOptionContract;
33
- readonly "changes:verify": CliCommandOptionContract;
34
- readonly "state:status": CliCommandOptionContract;
35
- readonly "state:export": CliCommandOptionContract;
36
- readonly "state:import": CliCommandOptionContract;
37
- readonly help: CliCommandOptionContract;
38
- readonly version: CliCommandOptionContract;
39
- };
40
- export type CliCommandOptionContractKey = keyof typeof CLI_COMMAND_OPTION_CONTRACTS;
41
- export declare const validateCliCommandOptions: (commandKey: CliCommandOptionContractKey, counts: ReadonlyMap<string, number>) => void;
1
+ /** Harness 1.x compatibility bridge; implementation belongs to the engine. */
2
+ export * from "../compat/cli-options.js";
@@ -1,167 +1,2 @@
1
- import type { AgentStreamEvent } from "@zhivex-ai/agents";
2
- export declare const CLI_JSON_SCHEMA_VERSION: 1;
3
- export declare const CLI_EVENT_SCHEMA_VERSION: 1;
4
- export interface StreamRunResultSource {
5
- runId: string;
6
- status: string;
7
- provider: string;
8
- model: string;
9
- steps: number;
10
- toolCalls: number;
11
- pendingApprovals?: readonly ({
12
- id: string;
13
- kind: string;
14
- name: string;
15
- childRunId?: string;
16
- childAgentId?: string;
17
- [key: string]: unknown;
18
- })[];
19
- children?: readonly ({
20
- runId: string;
21
- status: string;
22
- [key: string]: unknown;
23
- })[];
24
- [key: string]: unknown;
25
- }
26
- /**
27
- * Convert runtime events into a stable, line-oriented CLI contract.
28
- *
29
- * Tool inputs, tool outputs, provider payloads, model messages, and error text
30
- * are deliberately omitted: they can contain repository content or secrets.
31
- */
32
- export declare const streamEventDocument: (event: AgentStreamEvent, sequence?: number) => {
33
- schemaVersion: 1;
34
- kind: "run-event";
35
- sequence: number;
36
- type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
37
- textDelta: string;
38
- } | {
39
- schemaVersion: 1;
40
- kind: "run-event";
41
- sequence: number;
42
- type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
43
- toolCallId: string;
44
- toolName: string;
45
- } | {
46
- schemaVersion: 1;
47
- kind: "run-event";
48
- sequence: number;
49
- type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
50
- toolCallId: string;
51
- toolName: string;
52
- isError: boolean;
53
- } | {
54
- schemaVersion: 1;
55
- kind: "run-event";
56
- sequence: number;
57
- type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
58
- approvalRequestId: string;
59
- approvalKind: "local-tool" | "provider" | "subagent";
60
- toolName: string;
61
- } | {
62
- schemaVersion: 1;
63
- kind: "run-event";
64
- sequence: number;
65
- type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
66
- approvalRequestId: string;
67
- approved: boolean;
68
- } | {
69
- schemaVersion: 1;
70
- kind: "run-event";
71
- sequence: number;
72
- type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
73
- provider: string;
74
- } | {
75
- schemaVersion: 1;
76
- kind: "run-event";
77
- sequence: number;
78
- type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
79
- provider: string;
80
- partial: boolean;
81
- id?: string;
82
- index?: number;
83
- } | {
84
- schemaVersion: 1;
85
- kind: "run-event";
86
- sequence: number;
87
- type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
88
- finishReason?: import("@zhivex-ai/core").FinishReason;
89
- usage?: import("@zhivex-ai/core").TokenUsage;
90
- } | {
91
- schemaVersion: 1;
92
- kind: "run-event";
93
- sequence: number;
94
- type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
95
- error: string;
96
- } | {
97
- schemaVersion: 1;
98
- kind: "run-event";
99
- sequence: number;
100
- type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
101
- currentStep: number;
102
- maxSteps: number;
103
- } | {
104
- schemaVersion: 1;
105
- kind: "run-event";
106
- sequence: number;
107
- type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
108
- stepIndex: number;
109
- } | {
110
- schemaVersion: 1;
111
- kind: "run-event";
112
- sequence: number;
113
- type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
114
- stepIndex: number;
115
- status: import("@zhivex-ai/core").AgentStepStatus;
116
- toolCalls: number;
117
- } | {
118
- schemaVersion: 1;
119
- kind: "run-event";
120
- sequence: number;
121
- type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
122
- compactionId: string;
123
- reasons: import("@zhivex-ai/core").AgentCompactionReason[];
124
- messageCountBefore: number;
125
- messageCountAfter: number;
126
- } | {
127
- schemaVersion: 1;
128
- kind: "run-event";
129
- sequence: number;
130
- type: "agent-approval-request" | "agent-approval-resolved" | "agent-compaction" | "agent-run-finish" | "agent-run-start" | "agent-run-update" | "agent-step-finish" | "agent-step-start" | "error" | "finish" | "image-generation" | "provider-data" | "text-delta" | "tool-approval-request" | "tool-call" | "tool-result";
131
- runId: string;
132
- status: import("@zhivex-ai/core").AgentStatus;
133
- provider: string;
134
- model: string;
135
- } | undefined;
136
- export declare const serializeStreamEvent: (event: AgentStreamEvent, sequence?: number) => string;
137
- /**
138
- * Project the rich final JSON document onto the redacted JSONL contract.
139
- *
140
- * This is deliberately a whitelist. Output text, mutations, approval
141
- * arguments, scope, paths, provider payloads, and configuration bindings can
142
- * contain repository or operator data and must remain exclusive to the
143
- * separate final-document contract.
144
- */
145
- export declare const streamResultDocument: (result: StreamRunResultSource, sequence?: number) => {
146
- schemaVersion: 1;
147
- kind: "run-stream-result";
148
- sequence: number;
149
- runId: string;
150
- status: string;
151
- provider: string;
152
- model: string;
153
- steps: number;
154
- toolCalls: number;
155
- pendingApprovals: {
156
- id: string;
157
- kind: string;
158
- name: string;
159
- childRunId?: string;
160
- childAgentId?: string;
161
- }[];
162
- children: {
163
- runId: string;
164
- status: string;
165
- }[];
166
- };
167
- export declare const serializeStreamResult: (result: StreamRunResultSource, sequence?: number) => string;
1
+ /** Harness 1.x compatibility bridge; implementation belongs to the engine. */
2
+ export * from "../client/stream.js";
@@ -1,91 +1,2 @@
1
- import { type AgentRunOutput } from "@zhivex-ai/agents";
2
- import type { ZhivexHarness } from "../runtime/harness.js";
3
- export declare const runResultDocument: (result: AgentRunOutput, harness: ZhivexHarness) => {
4
- schemaVersion: 1;
5
- kind: "run-result";
6
- runId: string;
7
- status: import("@zhivex-ai/core").AgentStatus;
8
- provider: string;
9
- model: string;
10
- output: string;
11
- steps: number;
12
- toolCalls: number;
13
- mutations: readonly {
14
- id: string;
15
- operation: "create" | "move" | "quarantine" | "restore" | "update";
16
- path: string;
17
- destination?: string | undefined;
18
- beforeDigest?: string | undefined;
19
- afterDigest?: string | undefined;
20
- timestamp: string;
21
- quarantineId?: string | undefined;
22
- }[];
23
- pendingApprovals: {
24
- id: string;
25
- kind: "local-tool" | "provider" | "subagent";
26
- name: string;
27
- arguments: string;
28
- childRunId?: string;
29
- childAgentId?: string;
30
- }[];
31
- children: {
32
- runId: string;
33
- agentId: string | undefined;
34
- toolName: string | undefined;
35
- status: import("@zhivex-ai/core").AgentStatus;
36
- steps: number;
37
- toolCalls: number;
38
- toolErrors: number;
39
- usage: import("@zhivex-ai/core").TokenUsage | undefined;
40
- }[];
41
- usage: import("@zhivex-ai/core").TokenUsage | undefined;
42
- usageLedger?: {
43
- calls: number;
44
- inputTokens: number;
45
- outputTokens: number;
46
- usageComplete: boolean;
47
- estimatedUsd: number | null;
48
- limitUsd: number | null;
49
- schemaVersion: 1;
50
- runId: string;
51
- historicalUsageUnknown?: boolean | undefined;
52
- costKind: "estimate-not-invoice";
53
- routes: {
54
- provider: string;
55
- model: string;
56
- calls: number;
57
- inputTokens: number;
58
- outputTokens: number;
59
- unknownCalls: number;
60
- estimatedUsd: number | null;
61
- priceStatuses: ("estimate" | "missing" | "stale")[];
62
- }[];
63
- } | null;
64
- budget: import("@zhivex-ai/core").AgentBudgetStatus;
65
- costBudget?: {
66
- limitUsd: number;
67
- estimate: import("@zhivex-ai/core").CostEstimate;
68
- };
69
- scope: import("@zhivex-ai/core").AgentStoreScope | undefined;
70
- capabilities: import("../index.js").HarnessModelCapabilityReport;
71
- orchestration: {
72
- profiles: readonly ("explorer" | "implementer" | "reviewer" | "tester")[];
73
- childBudget: import("../index.js").HarnessBudget;
74
- mcpServers: string[];
75
- };
76
- execution: {
77
- backend: "oci";
78
- binding: import("@zhivex-ai/core").AgentExecutionEnvironmentBinding | undefined;
79
- image: import("../index.js").OciImageInspection;
80
- } | {
81
- binding?: never;
82
- image?: never;
83
- backend: "none";
84
- };
85
- store: {
86
- backend: "file" | "sqlite";
87
- stateDirectory: string;
88
- migration: import("../index.js").HarnessMigrationResult | undefined;
89
- };
90
- stateDirectory: string;
91
- };
1
+ /** Harness 1.x compatibility bridge; implementation belongs to the engine. */
2
+ export * from "../client/run-document.js";
@@ -1,3 +1,2 @@
1
- import type { ModelMessage } from "@zhivex-ai/core";
2
- /** Close transcript gaps from a terminal run; never replay an unrecorded tool effect. */
3
- export declare function terminalContinuationMessages(messages: readonly ModelMessage[]): ModelMessage[];
1
+ /** Harness 1.x compatibility bridge; implementation belongs to the engine. */
2
+ export * from "../../client/continuation.js";
@@ -99,6 +99,7 @@ var createMetaContinuationFetch = (fetcher = fetch, backoff = [1000, 2000]) => {
99
99
 
100
100
  // src/providers/meta-replay.ts
101
101
  import { wrapLanguageModel as wrapLanguageModel2 } from "@zhivex-ai/core";
102
+ import { withTimeoutSignal } from "@zhivex-ai/core/provider";
102
103
  import { createMeta } from "@zhivex-ai/meta";
103
104
  var replayPlan = (messages) => {
104
105
  let offset = 0;
@@ -172,7 +173,54 @@ var createMetaReplayModel = (options, modelId) => {
172
173
  },
173
174
  async wrapStream({ input }) {
174
175
  const prepared = prepare(input);
175
- return prepared.model.stream(prepared.input);
176
+ const lifetime = withTimeoutSignal(prepared.input);
177
+ const { timeoutMs: _timeout, ...request } = prepared.input;
178
+ try {
179
+ const stream = await prepared.model.stream({ ...request, abortSignal: lifetime.signal });
180
+ const iterator = stream[Symbol.asyncIterator]();
181
+ const owned = {
182
+ [Symbol.asyncIterator]() {
183
+ return owned;
184
+ },
185
+ async next() {
186
+ try {
187
+ const result = await iterator.next();
188
+ if (result.done)
189
+ lifetime.cleanup();
190
+ return result;
191
+ } catch (error) {
192
+ lifetime.cleanup();
193
+ throw error;
194
+ }
195
+ },
196
+ async return() {
197
+ try {
198
+ return await iterator.return?.() ?? { done: true, value: undefined };
199
+ } finally {
200
+ lifetime.cleanup();
201
+ }
202
+ },
203
+ async throw(error) {
204
+ try {
205
+ if (iterator.throw) {
206
+ const result = await iterator.throw(error);
207
+ if (result.done)
208
+ lifetime.cleanup();
209
+ return result;
210
+ }
211
+ await iterator.return?.();
212
+ throw error;
213
+ } catch (failure) {
214
+ lifetime.cleanup();
215
+ throw failure;
216
+ }
217
+ }
218
+ };
219
+ return owned;
220
+ } catch (error) {
221
+ lifetime.cleanup();
222
+ throw error;
223
+ }
176
224
  }
177
225
  }]);
178
226
  };
@@ -1,4 +1,4 @@
1
- // src/cli/cli-options.ts
1
+ // src/compat/cli-options.ts
2
2
  var repeatableOptions = new Set([
3
3
  "--route",
4
4
  "--oci-allow-command",
@@ -260,7 +260,6 @@ var validateCliCommandOptions = (commandKey, counts) => {
260
260
  }
261
261
  }
262
262
  };
263
-
264
263
  // src/cli/cli-help.ts
265
264
  var usage = {
266
265
  init: "zhx init [--provider <id>] [--model <id>] [--profile <name>] [--update]",
@@ -21,7 +21,7 @@ import {
21
21
  normalizeHarnessError,
22
22
  resolveHarnessConfig,
23
23
  withReasoningEffort
24
- } from "./cli-entry-427869g9.js";
24
+ } from "./cli-entry-0mmeag20.js";
25
25
 
26
26
  // src/cli/terminal/tool-activity.ts
27
27
  var labels = {
@@ -161,7 +161,7 @@ var compactToolResult = (result) => {
161
161
  return `✗ ${operation} · ${reason}${editLabels[result.toolName] && error.code === "TOOL_INPUT_VALIDATION_ERROR" ? " · edits not applied" : ""}`;
162
162
  };
163
163
 
164
- // src/cli/cli-stream.ts
164
+ // src/client/stream.ts
165
165
  var CLI_JSON_SCHEMA_VERSION = 1;
166
166
  var CLI_EVENT_SCHEMA_VERSION = 1;
167
167
  var streamEventDocument = (event, sequence = 0) => {
@@ -277,7 +277,7 @@ var streamResultDocument = (result, sequence = 0) => {
277
277
  };
278
278
  var serializeStreamResult = (result, sequence = 0) => JSON.stringify(streamResultDocument(result, sequence));
279
279
 
280
- // src/cli/run-document.ts
280
+ // src/client/run-document.ts
281
281
  import { getAgentBudgetStatus } from "@zhivex-ai/agents";
282
282
  import { estimateAgentRunCost } from "@zhivex-ai/agents/ops";
283
283
 
@@ -1774,7 +1774,7 @@ class UsageLedger {
1774
1774
  }
1775
1775
  }
1776
1776
 
1777
- // src/cli/run-document.ts
1777
+ // src/client/run-document.ts
1778
1778
  var costPricing = (harness) => harness.config.costBudget ? {
1779
1779
  inputCostPer1kTokens: harness.config.costBudget.inputCostPer1kTokens,
1780
1780
  outputCostPer1kTokens: harness.config.costBudget.outputCostPer1kTokens,
@@ -2133,7 +2133,6 @@ var formatTerminalEvent = (event, options = {}) => {
2133
2133
  return `${paint(event.status === "completed" ? "✓" : "●", event.status === "completed" ? 32 : 33, color)} ` + `run · ${sanitizeTerminalText(event.status)} · ` + `${sanitizeTerminalText(event.state.provider)}/${sanitizeTerminalText(event.state.modelId)}`;
2134
2134
  }
2135
2135
  };
2136
-
2137
2136
  // src/cli/console/console-commands.ts
2138
2137
  var CONSOLE_COMMAND_CATALOG = [
2139
2138
  ["/menu", "Open navigation menu", true],
@@ -4612,6 +4611,16 @@ var editProposalSchema = z6.strictObject({
4612
4611
  var applyEditProposalInputSchema = z6.strictObject({
4613
4612
  proposalId: fileDigestSchema,
4614
4613
  changes: editChangesSchema
4614
+ }).superRefine((input, context) => {
4615
+ if (!editProposalInputSchema.safeParse({ changes: input.changes }).success)
4616
+ return;
4617
+ if (createEditProposal({ changes: input.changes }).proposalId !== input.proposalId) {
4618
+ context.addIssue({
4619
+ code: "custom",
4620
+ path: ["proposalId"],
4621
+ message: "proposalId does not match the supplied paths, preconditions, and content. Read proposalId from the matching propose_edits result; do not invent it."
4622
+ });
4623
+ }
4615
4624
  });
4616
4625
  var moveFileInputSchema = z6.strictObject({
4617
4626
  source: workspaceFilePathSchema,
@@ -6229,10 +6238,10 @@ var spawnBounded2 = async (command, options) => {
6229
6238
  } else {
6230
6239
  options.abortSignal?.addEventListener("abort", onAbort, { once: true });
6231
6240
  }
6232
- const consume = async (stream) => {
6241
+ const consume = async (stream2) => {
6233
6242
  const chunks = [];
6234
6243
  let omittedBytes = 0;
6235
- for await (const value of stream) {
6244
+ for await (const value of stream2) {
6236
6245
  const chunk = Buffer.isBuffer(value) ? value : Buffer.from(value);
6237
6246
  totalOutputBytes += chunk.byteLength;
6238
6247
  if (retainedOutputBytes < options.maxOutputBytes) {
@@ -8308,7 +8317,7 @@ var harnessToolExecution = {
8308
8317
  unknownToolMode: "tool-result"
8309
8318
  };
8310
8319
 
8311
- // src/cli/terminal/terminal-continuation.ts
8320
+ // src/client/continuation.ts
8312
8321
  function terminalContinuationMessages(messages) {
8313
8322
  const recorded = new Set(messages.flatMap((message) => message.parts.flatMap((part) => part.type === "tool-result" ? [part.toolResult.toolCallId] : [])));
8314
8323
  return messages.flatMap((message) => {
@@ -8510,10 +8519,10 @@ var createCheckpointTokenCap = (limits, usage, transportTokens = true, options =
8510
8519
  },
8511
8520
  async wrapStream(context, next) {
8512
8521
  await cap(context.input);
8513
- const stream = await next();
8522
+ const stream2 = await next();
8514
8523
  return async function* () {
8515
8524
  let recorded = false;
8516
- for await (const event of stream) {
8525
+ for await (const event of stream2) {
8517
8526
  if (event.type === "finish" && !recorded) {
8518
8527
  record(event.usage);
8519
8528
  recorded = true;
@@ -8959,11 +8968,11 @@ Use read_task for complete constraints if the excerpt is incomplete. A candidate
8959
8968
  async wrapStream(context, next) {
8960
8969
  const call = prepare(context.input, context.model.provider);
8961
8970
  if (!call) {
8962
- const stream = await next();
8971
+ const stream2 = await next();
8963
8972
  return async function* () {
8964
8973
  let sawTool = false;
8965
8974
  let finish;
8966
- for await (const event of stream) {
8975
+ for await (const event of stream2) {
8967
8976
  if (["tool-call", "tool-result", "tool-approval-request", "error"].includes(event.type))
8968
8977
  sawTool = true;
8969
8978
  if (event.type === "finish") {
@@ -9641,9 +9650,9 @@ var createModelEditReferences = (registered, failedCalls = []) => {
9641
9650
  name: "harness-model-edit-references-v2",
9642
9651
  async wrapStream(context, next) {
9643
9652
  const bind = prepare(context.input);
9644
- const stream = await next();
9653
+ const stream2 = await next();
9645
9654
  return async function* () {
9646
- for await (const event of stream)
9655
+ for await (const event of stream2)
9647
9656
  yield event.type === "tool-call" ? { ...event, toolCall: bind(event.toolCall) } : event;
9648
9657
  }();
9649
9658
  },
@@ -10034,11 +10043,11 @@ var createOciDelivery = (pending, metadata, reset = false, descendantsPending) =
10034
10043
  async wrapStream(context, next) {
10035
10044
  if (reminders && !declined)
10036
10045
  context.input.messages = [...context.input.messages, { role: "system", parts: [{ type: "text", text: reminderText }] }];
10037
- const stream = await next();
10046
+ const stream2 = await next();
10038
10047
  return async function* () {
10039
10048
  let sawTool = false;
10040
10049
  let finish;
10041
- for await (const event of stream) {
10050
+ for await (const event of stream2) {
10042
10051
  if (["tool-call", "tool-result", "tool-approval-request", "error"].includes(event.type))
10043
10052
  sawTool = true;
10044
10053
  if (event.type === "finish") {
@@ -11134,11 +11143,11 @@ async function createContextRuntime(workspace, metadata, enabled, options = {})
11134
11143
  },
11135
11144
  async wrapStream(context, next) {
11136
11145
  await prepare(context.input);
11137
- const stream = await next();
11146
+ const stream2 = await next();
11138
11147
  return async function* () {
11139
11148
  let text = "";
11140
11149
  let toolCalled = false;
11141
- for await (const event of stream) {
11150
+ for await (const event of stream2) {
11142
11151
  if (event.type === "text-delta")
11143
11152
  text = (text + event.textDelta).slice(-8000);
11144
11153
  if (event.type === "tool-call")
@@ -5,7 +5,7 @@ import {
5
5
  resolveHelpTopic,
6
6
  shortCliHelp,
7
7
  validateCliCommandOptions
8
- } from "./cli-entry-b1mfvmxe.js";
8
+ } from "./cli-entry-7h9savv5.js";
9
9
  import {
10
10
  ActivityHistory,
11
11
  CLI_JSON_SCHEMA_VERSION,
@@ -77,7 +77,7 @@ import {
77
77
  validateStateDirectory,
78
78
  verifyChangeEnvelope,
79
79
  workspaceFilePathSchema
80
- } from "./cli-entry-c2f58zj2.js";
80
+ } from "./cli-entry-xmf48p6a.js";
81
81
  import {
82
82
  BUN_ENGINE_RANGE,
83
83
  HARNESS_VERSION,
@@ -102,7 +102,7 @@ import {
102
102
  providerDescriptor,
103
103
  reasoningEffortSchema,
104
104
  resolveHarnessConfig
105
- } from "./cli-entry-427869g9.js";
105
+ } from "./cli-entry-0mmeag20.js";
106
106
  import {
107
107
  __require
108
108
  } from "./cli-entry-1bx83sw4.js";
@@ -1032,7 +1032,6 @@ var parseCliArgs = (argv) => {
1032
1032
  }
1033
1033
  return options;
1034
1034
  };
1035
-
1036
1035
  // src/cli/terminal/terminal-table.ts
1037
1036
  var segments = new Intl.Segmenter(undefined, { granularity: "grapheme" });
1038
1037
  var graphemes = (value) => [...segments.segment(value)].map((item) => item.segment);
@@ -2227,7 +2226,7 @@ This connection will replace Qwen environment settings for this CLI session.
2227
2226
  }
2228
2227
  }
2229
2228
  async function credentialModel(config, env, modelFactory) {
2230
- const { createProviderModel: createProviderModel2 } = await import("./config-1k9t4jhh.js");
2229
+ const { createProviderModel: createProviderModel2 } = await import("./config-q32jm1e6.js");
2231
2230
  const { wrapLanguageModel } = await import("@zhivex-ai/core");
2232
2231
  const secrets = providerDescriptor(config.provider).credentialNames.map((name) => env[name]).filter((value) => !!value);
2233
2232
  const safeError = (error) => {
@@ -5674,7 +5673,7 @@ var main = async (argv = process.argv.slice(2)) => {
5674
5673
  parsedOptions = { ...parsedOptions, prompt: await readStdinTask() };
5675
5674
  }
5676
5675
  if (parsedOptions.serviceFile) {
5677
- const { runServiceCli } = await import("./service-client-cli-yx56n0hc.js");
5676
+ const { runServiceCli } = await import("./service-client-cli-gs78wrxe.js");
5678
5677
  await runServiceCli(parsedOptions, annotateCliStreamError);
5679
5678
  return;
5680
5679
  }
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  shortCliHelp
4
- } from "./cli-entry-b1mfvmxe.js";
4
+ } from "./cli-entry-7h9savv5.js";
5
5
  import {
6
6
  HARNESS_VERSION
7
7
  } from "./cli-entry-64pdp3k5.js";
@@ -18,6 +18,6 @@ if (argv.length === 1 && ["--version", "-v", "version"].includes(argv[0])) {
18
18
  process.stdout.write(`${shortCliHelp(HARNESS_VERSION)}
19
19
  `);
20
20
  } else {
21
- const { runCli } = await import("./cli-3jmy4h5h.js");
21
+ const { runCli } = await import("./cli-qgwvtk0w.js");
22
22
  await runCli(argv);
23
23
  }
@@ -0,0 +1,3 @@
1
+ import type { ModelMessage } from "@zhivex-ai/core";
2
+ /** Close transcript gaps from a terminal run; never replay an unrecorded tool effect. */
3
+ export declare function terminalContinuationMessages(messages: readonly ModelMessage[]): ModelMessage[];