@zhivex-ai/harness 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/CHANGELOG.md +32 -10
  2. package/README.md +7 -5
  3. package/SUPPORT.md +2 -2
  4. package/contracts/client-protocol-v1.schema.json +593 -0
  5. package/contracts/engine-api.json +156 -0
  6. package/contracts/public-api.json +12 -0
  7. package/contracts/stable-api-signatures.json +36 -36
  8. package/dist/acp-cli.js +54 -20
  9. package/dist/approvals/approval-diff.d.ts +2 -1
  10. package/dist/approvals/approval-preview.d.ts +1 -1
  11. package/dist/audit/index.d.ts +3 -0
  12. package/dist/audit/index.js +482 -0
  13. package/dist/audit/pack.d.ts +72 -0
  14. package/dist/audit-pack-kvw7ng34.js +532 -0
  15. package/dist/cli/arguments.d.ts +3 -1
  16. package/dist/cli/audit-pack.d.ts +24 -0
  17. package/dist/cli/cli-credentials.d.ts +6 -0
  18. package/dist/cli/cli-profiles.d.ts +4 -2
  19. package/dist/cli/node-engine.d.ts +2 -0
  20. package/dist/cli-entry-75j3r49b.js +484 -0
  21. package/dist/cli-entry-928p8h41.js +10067 -0
  22. package/dist/cli-entry-h2yc9x37.js +10350 -0
  23. package/dist/{cli-entry-20w6nh0k.js → cli-entry-hdtfef27.js} +439 -19
  24. package/dist/{cli-entry-w0hterjs.js → cli-entry-q8bgkn9m.js} +40 -13
  25. package/dist/{cli-2h37qyvg.js → cli-vyrytn3m.js} +253 -644
  26. package/dist/cli.js +27 -2
  27. package/dist/client/json-contracts.d.ts +4 -0
  28. package/dist/client/protocol.d.ts +133 -0
  29. package/dist/client/task-control-host.d.ts +400 -0
  30. package/dist/client/task-projection-host.d.ts +12 -0
  31. package/dist/client/task-projection.d.ts +168 -0
  32. package/dist/compat/code-support.js +28 -22
  33. package/dist/{config-qt69hkqj.js → config-r9fdhce6.js} +3 -3
  34. package/dist/{config-j9624t6t.js → config-vyajmksy.js} +1 -1
  35. package/dist/engine/acp.js +15 -11
  36. package/dist/engine/client.js +14 -10
  37. package/dist/engine/desktop-providers-v1.d.ts +2 -0
  38. package/dist/engine/desktop-providers-v1.js +23 -3
  39. package/dist/engine/desktop-state-v1.js +11 -8
  40. package/dist/engine/index.d.ts +3 -0
  41. package/dist/engine/index.js +101 -554
  42. package/dist/engine/mcp-stdio-v1.js +8 -6
  43. package/dist/engine/models.js +76 -4
  44. package/dist/engine/protocol.d.ts +2 -0
  45. package/dist/engine/protocol.js +110 -0
  46. package/dist/engine/service.js +15 -11
  47. package/dist/hostile-repository-demo.js +1232 -564
  48. package/dist/{index-8zjmnyw5.js → index-1265j7t2.js} +73 -6
  49. package/dist/{index-nmjdwd4p.js → index-4gt045j0.js} +109 -1
  50. package/dist/{index-pdmevfxv.js → index-5zbq9ztj.js} +5 -259
  51. package/dist/{index-6dft2vev.js → index-63gbp0cz.js} +5 -3
  52. package/dist/index-6dxrbnxm.js +719 -0
  53. package/dist/{index-pp474137.js → index-6fp7kdpx.js} +769 -933
  54. package/dist/{index-61gthdz6.js → index-8sm2a1wa.js} +1 -1
  55. package/dist/{index-rkbf7dqg.js → index-96ezrvg2.js} +57 -13
  56. package/dist/index-bt2p8x7r.js +329 -0
  57. package/dist/index-c39197wq.js +552 -0
  58. package/dist/{index-m82cfspw.js → index-eps3c3g6.js} +877 -963
  59. package/dist/{index-s2k2edts.js → index-fqqz1yt8.js} +110 -1544
  60. package/dist/{index-m34q25jj.js → index-ggstwr0v.js} +192 -838
  61. package/dist/index-jpdvn09j.js +490 -0
  62. package/dist/{index-xqxeypt5.js → index-mzydbzp8.js} +76 -4
  63. package/dist/index-pq3kz1r8.js +269 -0
  64. package/dist/{index-wg1sd3at.js → index-qfsrrnz6.js} +1 -1
  65. package/dist/{index-937cb7y8.js → index-vc7yxz50.js} +561 -35
  66. package/dist/{index-5jhgatga.js → index-vvzc5ezz.js} +7 -6
  67. package/dist/index-wwthv10a.js +1507 -0
  68. package/dist/{index-tfzta544.js → index-xfedewpt.js} +17 -9
  69. package/dist/index-yx52bt4a.js +511 -0
  70. package/dist/index.d.ts +3 -0
  71. package/dist/index.js +93 -77
  72. package/dist/integrations/mcp-stdio-tools.d.ts +4 -1
  73. package/dist/internal/desktop/providers.d.ts +2 -0
  74. package/dist/models/catalog.d.ts +2 -0
  75. package/dist/persistence/sqlite-database.d.ts +1 -0
  76. package/dist/providers/azure-openai.d.ts +14 -0
  77. package/dist/providers/bedrock.d.ts +23 -0
  78. package/dist/providers/providers.d.ts +1 -1
  79. package/dist/runtime/budget-ledger-scope.d.ts +14 -0
  80. package/dist/runtime/durable-review-group.d.ts +33 -0
  81. package/dist/runtime/harness.d.ts +11 -0
  82. package/dist/runtime/run-interruption.d.ts +7 -0
  83. package/dist/runtime/shared-budget.d.ts +30 -0
  84. package/dist/runtime/task-continuity.d.ts +300 -77
  85. package/dist/service-cli.js +15 -11
  86. package/dist/{service-client-cli-fn54ev6w.js → service-client-cli-v6qptg9x.js} +400 -305
  87. package/dist/tools/workspace.d.ts +2 -2
  88. package/dist/verify-historical-migrations.js +1237 -566
  89. package/dist/workspace/edit-contracts.d.ts +2 -2
  90. package/dist/workspace/path-policy.d.ts +2 -1
  91. package/dist/workspace/workspace.d.ts +13 -0
  92. package/dist/zhx.js +27 -2
  93. package/docs/AUDIT_PACK.md +99 -0
  94. package/docs/AZURE_OPENAI.md +53 -0
  95. package/docs/BEDROCK.md +56 -0
  96. package/docs/CLI.md +15 -0
  97. package/docs/CLIENT_PROTOCOL.md +178 -0
  98. package/docs/CODE_RELEASE.md +59 -7
  99. package/docs/CODE_WEB_TASKS.md +116 -0
  100. package/docs/CONTEXT_ENGINEERING.md +59 -0
  101. package/docs/CREDENTIALS.md +21 -0
  102. package/docs/DURABLE_OPERATIONS.md +93 -1
  103. package/docs/ENGINE_API.md +5 -2
  104. package/docs/EXTENSIBILITY.md +8 -4
  105. package/docs/FIRST_USE.md +6 -6
  106. package/docs/MINIMUM_TASK_AUTHORITY.md +3 -3
  107. package/docs/PROJECT_MEMORY.md +1 -1
  108. package/docs/PUBLIC_SECURITY.md +14 -1
  109. package/docs/README.md +6 -1
  110. package/docs/REPOSITORY_EDITING.md +1 -1
  111. package/docs/STABILITY.md +3 -1
  112. package/docs/SUPPORT_MATRIX.md +1 -1
  113. package/docs/SUPPORT_MATRIX_1_1.md +1 -1
  114. package/docs/TOOL_POLICY.md +4 -1
  115. package/docs/USAGE.md +3 -1
  116. package/docs/VERTEX.md +2 -2
  117. package/docs/WEB_LIMITS.md +4 -3
  118. package/docs/adr/0002-isolated-mcp-stdio.md +7 -4
  119. package/docs/support-matrix-1.1.json +3 -1
  120. package/docs/support-matrix.json +6 -4
  121. package/evaluations/code-task-ui.json +20 -0
  122. package/evaluations/representative-assembly-matrix.json +19 -1
  123. package/evaluations/task-projection.json +10 -0
  124. package/evaluations/task-recovery-lab.json +60 -0
  125. package/examples/README.md +3 -3
  126. package/package.json +23 -13
  127. package/dist/cli-entry-4ngptr62.js +0 -19900
  128. package/dist/index-m49jx72n.js +0 -220
package/dist/cli.js CHANGED
@@ -1,13 +1,38 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  HARNESS_VERSION,
4
+ NODE_ENGINE_RANGE,
4
5
  shortCliHelp
5
- } from "./cli-entry-w0hterjs.js";
6
+ } from "./cli-entry-q8bgkn9m.js";
6
7
  import {
7
8
  __require
8
9
  } from "./cli-entry-1bx83sw4.js";
9
10
 
11
+ // src/cli/node-engine.ts
12
+ var nodeEngineError = (version, range) => {
13
+ const minimumMatch = /^>=(\d+)\.(\d+)\.(\d+)$/.exec(range.trim());
14
+ const actualMatch = /^(\d+)\.(\d+)\.(\d+)/.exec(version.trim());
15
+ const failure = `Node.js ${version} does not satisfy the package engine requirement (${range}).
16
+ `;
17
+ if (!minimumMatch || !actualMatch)
18
+ return failure;
19
+ for (let index = 1;index <= 3; index += 1) {
20
+ const actual = Number(actualMatch[index]);
21
+ const minimum = Number(minimumMatch[index]);
22
+ if (actual !== minimum)
23
+ return actual > minimum ? undefined : failure;
24
+ }
25
+ return;
26
+ };
27
+
10
28
  // src/cli-entry.ts
29
+ if (!process.versions.bun) {
30
+ const engineError = nodeEngineError(process.versions.node, NODE_ENGINE_RANGE);
31
+ if (engineError) {
32
+ process.stderr.write(engineError);
33
+ process.exit(1);
34
+ }
35
+ }
11
36
  var argv = process.argv.slice(2);
12
37
  if (argv.length === 1 && ["--version", "-v", "version"].includes(argv[0])) {
13
38
  process.stdout.write(`${HARNESS_VERSION}
@@ -16,6 +41,6 @@ if (argv.length === 1 && ["--version", "-v", "version"].includes(argv[0])) {
16
41
  process.stdout.write(`${shortCliHelp(HARNESS_VERSION)}
17
42
  `);
18
43
  } else {
19
- const { runCli } = await import("./cli-2h37qyvg.js");
44
+ const { runCli } = await import("./cli-vyrytn3m.js");
20
45
  await runCli(argv);
21
46
  }
@@ -218,6 +218,8 @@ export declare const cliInitDocumentSchema: z.ZodObject<{
218
218
  schemaVersion: z.ZodNumber;
219
219
  provider: z.ZodEnum<{
220
220
  anthropic: "anthropic";
221
+ "azure-openai": "azure-openai";
222
+ bedrock: "bedrock";
221
223
  gemini: "gemini";
222
224
  meta: "meta";
223
225
  openai: "openai";
@@ -954,6 +956,8 @@ export declare const cliJsonDocumentSchema: z.ZodUnion<readonly [z.ZodObject<{
954
956
  schemaVersion: z.ZodNumber;
955
957
  provider: z.ZodEnum<{
956
958
  anthropic: "anthropic";
959
+ "azure-openai": "azure-openai";
960
+ bedrock: "bedrock";
957
961
  gemini: "gemini";
958
962
  meta: "meta";
959
963
  openai: "openai";
@@ -1,3 +1,4 @@
1
+ import type { HarnessTaskProjection } from './task-projection.js';
1
2
  import type { HarnessErrorDocument, ProviderStreamDiagnostic } from "../runtime/errors.js";
2
3
  import type { HarnessPolicyDecisionEvent } from "../runtime/policy-decisions.js";
3
4
  import type { HarnessPolicyInspection } from "../runtime/policy-inspection.js";
@@ -89,6 +90,57 @@ export declare const harnessClientCommandSchema: z.ZodDiscriminatedUnion<[z.ZodO
89
90
  method: z.ZodLiteral<"run.start">;
90
91
  expectedRevision: z.ZodNumber;
91
92
  prompt: z.ZodString;
93
+ }, z.core.$strict>, z.ZodObject<{
94
+ projectId: z.ZodString;
95
+ sessionId: z.ZodString;
96
+ idempotencyKey: z.ZodString;
97
+ method: z.ZodLiteral<"task.start">;
98
+ expectedRevision: z.ZodNumber;
99
+ brief: z.ZodObject<{
100
+ goal: z.ZodString;
101
+ paths: z.ZodArray<z.ZodString>;
102
+ checks: z.ZodArray<z.ZodString>;
103
+ constraints: z.ZodArray<z.ZodString>;
104
+ budget: z.ZodObject<{
105
+ inputTokens: z.ZodNumber;
106
+ outputTokens: z.ZodNumber;
107
+ totalTokens: z.ZodNumber;
108
+ }, z.core.$strict>;
109
+ }, z.core.$strict>;
110
+ }, z.core.$strict>, z.ZodObject<{
111
+ projectId: z.ZodString;
112
+ sessionId: z.ZodString;
113
+ runId: z.ZodString;
114
+ method: z.ZodLiteral<"task.review">;
115
+ }, z.core.$strict>, z.ZodObject<{
116
+ projectId: z.ZodString;
117
+ sessionId: z.ZodString;
118
+ runId: z.ZodString;
119
+ idempotencyKey: z.ZodString;
120
+ method: z.ZodLiteral<"task.keep">;
121
+ reviewId: z.ZodString;
122
+ }, z.core.$strict>, z.ZodObject<{
123
+ projectId: z.ZodString;
124
+ sessionId: z.ZodString;
125
+ runId: z.ZodString;
126
+ idempotencyKey: z.ZodString;
127
+ method: z.ZodLiteral<"task.revise">;
128
+ reviewId: z.ZodString;
129
+ correction: z.ZodString;
130
+ }, z.core.$strict>, z.ZodObject<{
131
+ projectId: z.ZodString;
132
+ sessionId: z.ZodString;
133
+ runId: z.ZodString;
134
+ idempotencyKey: z.ZodString;
135
+ method: z.ZodLiteral<"task.continue">;
136
+ reviewId: z.ZodString;
137
+ prompt: z.ZodString;
138
+ }, z.core.$strict>, z.ZodObject<{
139
+ projectId: z.ZodString;
140
+ sessionId: z.ZodString;
141
+ runId: z.ZodString;
142
+ method: z.ZodLiteral<"task.get">;
143
+ projectionVersion: z.ZodNumber;
92
144
  }, z.core.$strict>, z.ZodObject<{
93
145
  projectId: z.ZodString;
94
146
  sessionId: z.ZodString;
@@ -200,6 +252,57 @@ export declare const harnessClientRequestSchema: z.ZodObject<{
200
252
  method: z.ZodLiteral<"run.start">;
201
253
  expectedRevision: z.ZodNumber;
202
254
  prompt: z.ZodString;
255
+ }, z.core.$strict>, z.ZodObject<{
256
+ projectId: z.ZodString;
257
+ sessionId: z.ZodString;
258
+ idempotencyKey: z.ZodString;
259
+ method: z.ZodLiteral<"task.start">;
260
+ expectedRevision: z.ZodNumber;
261
+ brief: z.ZodObject<{
262
+ goal: z.ZodString;
263
+ paths: z.ZodArray<z.ZodString>;
264
+ checks: z.ZodArray<z.ZodString>;
265
+ constraints: z.ZodArray<z.ZodString>;
266
+ budget: z.ZodObject<{
267
+ inputTokens: z.ZodNumber;
268
+ outputTokens: z.ZodNumber;
269
+ totalTokens: z.ZodNumber;
270
+ }, z.core.$strict>;
271
+ }, z.core.$strict>;
272
+ }, z.core.$strict>, z.ZodObject<{
273
+ projectId: z.ZodString;
274
+ sessionId: z.ZodString;
275
+ runId: z.ZodString;
276
+ method: z.ZodLiteral<"task.review">;
277
+ }, z.core.$strict>, z.ZodObject<{
278
+ projectId: z.ZodString;
279
+ sessionId: z.ZodString;
280
+ runId: z.ZodString;
281
+ idempotencyKey: z.ZodString;
282
+ method: z.ZodLiteral<"task.keep">;
283
+ reviewId: z.ZodString;
284
+ }, z.core.$strict>, z.ZodObject<{
285
+ projectId: z.ZodString;
286
+ sessionId: z.ZodString;
287
+ runId: z.ZodString;
288
+ idempotencyKey: z.ZodString;
289
+ method: z.ZodLiteral<"task.revise">;
290
+ reviewId: z.ZodString;
291
+ correction: z.ZodString;
292
+ }, z.core.$strict>, z.ZodObject<{
293
+ projectId: z.ZodString;
294
+ sessionId: z.ZodString;
295
+ runId: z.ZodString;
296
+ idempotencyKey: z.ZodString;
297
+ method: z.ZodLiteral<"task.continue">;
298
+ reviewId: z.ZodString;
299
+ prompt: z.ZodString;
300
+ }, z.core.$strict>, z.ZodObject<{
301
+ projectId: z.ZodString;
302
+ sessionId: z.ZodString;
303
+ runId: z.ZodString;
304
+ method: z.ZodLiteral<"task.get">;
305
+ projectionVersion: z.ZodNumber;
203
306
  }, z.core.$strict>, z.ZodObject<{
204
307
  projectId: z.ZodString;
205
308
  sessionId: z.ZodString;
@@ -254,7 +357,30 @@ export interface HarnessClientRun {
254
357
  filePreview?: ApprovalFilePreview;
255
358
  }[];
256
359
  }
360
+ export interface HarnessTaskHumanDecision {
361
+ status: 'not_recorded' | 'current' | 'stale';
362
+ at: number | null;
363
+ provenance: 'explicit_operator_review' | null;
364
+ }
365
+ export interface HarnessTaskReview {
366
+ reviewId: string;
367
+ expiresAt: number;
368
+ projection: HarnessTaskProjection;
369
+ diff: string;
370
+ complete: boolean;
371
+ canKeep: boolean;
372
+ canContinue: boolean;
373
+ canRevise: boolean;
374
+ humanDecision: HarnessTaskHumanDecision;
375
+ }
257
376
  export type HarnessClientData = {
377
+ kind: "task";
378
+ projection: HarnessTaskProjection;
379
+ humanDecision?: HarnessTaskHumanDecision;
380
+ } | {
381
+ kind: "taskReview";
382
+ review: HarnessTaskReview;
383
+ } | {
258
384
  kind: "project";
259
385
  projectId: string;
260
386
  } | {
@@ -299,6 +425,11 @@ export type HarnessClientResponse = {
299
425
  error: {
300
426
  code: HarnessClientErrorCode;
301
427
  providerDiagnostic?: ProviderStreamDiagnostic;
428
+ taskDiagnostic?: {
429
+ cause: "UNSUPPORTED_VERSION" | "UNSUPPORTED_HOST" | "OUT_OF_SCOPE" | "CONTRACT_UNAVAILABLE" | "EVIDENCE_UNAVAILABLE" | "SNAPSHOT_CHANGED" | "PAYLOAD_LIMIT";
430
+ impact: "projection_unavailable";
431
+ safeAction: "retry_read" | "review_configuration" | "reconcile";
432
+ };
302
433
  };
303
434
  });
304
435
  export type HarnessClientNegotiation = {
@@ -314,6 +445,8 @@ export type HarnessClientNegotiation = {
314
445
  };
315
446
  };
316
447
  export interface HarnessClientAdapterOptions {
448
+ /** Host-owned secrets for the bounded task projection. Never supplied by commands. */
449
+ taskProjectionSensitiveValues?: readonly string[];
317
450
  approvalMaxAgeMs?: number;
318
451
  now?: () => number;
319
452
  onPolicyDecision?: (sessionId: string, runId: string, event: HarnessPolicyDecisionEvent) => void | Promise<void>;
@@ -0,0 +1,400 @@
1
+ import type { ZhivexHarness } from '../runtime/harness.js';
2
+ import { compileTaskAcceptanceContract } from '../runtime/task-acceptance.js';
3
+ import type { HarnessTaskProjection } from './task-projection.js';
4
+ import type { AgentRunState } from '@zhivex-ai/core';
5
+ export declare const TASK_HUMAN_DECISION_KEY = "harnessClientHumanDecisionV1";
6
+ export interface TaskBrief {
7
+ goal: string;
8
+ paths: string[];
9
+ checks: string[];
10
+ constraints: string[];
11
+ budget: {
12
+ inputTokens: number;
13
+ outputTokens: number;
14
+ totalTokens: number;
15
+ };
16
+ }
17
+ export declare const taskReviewIdentity: (p: HarnessTaskProjection) => string;
18
+ export declare function taskHumanDecision(host: ZhivexHarness, p: HarnessTaskProjection): Promise<{
19
+ status: 'not_recorded';
20
+ at: null;
21
+ provenance: null;
22
+ } | {
23
+ status: "current" | "stale";
24
+ at: number;
25
+ provenance: 'explicit_operator_review';
26
+ }>;
27
+ export declare function visibleTaskFiles(host: ZhivexHarness, paths: readonly string[]): Promise<void>;
28
+ export declare function taskGitReview(host: ZhivexHarness): Promise<{
29
+ text: string;
30
+ identity: string;
31
+ }>;
32
+ /** Browser supplies a bounded operator brief, never a contract, receipt or execution grant. */
33
+ export declare function prepareClientTask(host: ZhivexHarness, brief: TaskBrief): Promise<{
34
+ schemaVersion: 1;
35
+ budgetVersion: 1;
36
+ goal: string;
37
+ constraints: string[];
38
+ contract: {
39
+ schemaVersion: 1;
40
+ taskId: string;
41
+ allowedWritePaths: string[];
42
+ protectedFiles: string[];
43
+ requiredChecks: ({
44
+ id: string;
45
+ command: string;
46
+ args: string[];
47
+ purpose: string;
48
+ kind: "package-script";
49
+ script: string;
50
+ expectedScript: string;
51
+ execution: {
52
+ backend: "none" | "oci";
53
+ approval: "required";
54
+ };
55
+ } | {
56
+ id: string;
57
+ command: string;
58
+ args: string[];
59
+ purpose: string;
60
+ kind: "argv";
61
+ execution: {
62
+ backend: "oci";
63
+ approval: "required";
64
+ network: "none";
65
+ };
66
+ })[];
67
+ humanReview: {
68
+ id: string;
69
+ requirement: string;
70
+ status: "pending";
71
+ }[];
72
+ };
73
+ baseline: Record<string, string>;
74
+ }>;
75
+ export declare function currentClientTask(host: ZhivexHarness, runId: string, allowedRunIds: readonly string[]): Promise<{
76
+ state: AgentRunState;
77
+ ledger: {
78
+ schemaVersion: 1;
79
+ revisions: {
80
+ revision: number;
81
+ digest: string;
82
+ previousDigest: string | null;
83
+ contract: {
84
+ schemaVersion: 1;
85
+ taskId: string;
86
+ allowedWritePaths: string[];
87
+ protectedFiles: string[];
88
+ requiredChecks: ({
89
+ id: string;
90
+ command: string;
91
+ args: string[];
92
+ purpose: string;
93
+ kind: "package-script";
94
+ script: string;
95
+ expectedScript: string;
96
+ execution: {
97
+ backend: "none" | "oci";
98
+ approval: "required";
99
+ };
100
+ } | {
101
+ id: string;
102
+ command: string;
103
+ args: string[];
104
+ purpose: string;
105
+ kind: "argv";
106
+ execution: {
107
+ backend: "oci";
108
+ approval: "required";
109
+ network: "none";
110
+ };
111
+ })[];
112
+ humanReview: {
113
+ id: string;
114
+ requirement: string;
115
+ status: "pending";
116
+ }[];
117
+ };
118
+ }[];
119
+ };
120
+ evidence: {
121
+ report: {
122
+ schemaVersion: 1;
123
+ taskId: string;
124
+ budget: {
125
+ schemaVersion: 1;
126
+ taskId: string;
127
+ accountRunId: string;
128
+ revision: number;
129
+ limits: {
130
+ inputTokens: number;
131
+ outputTokens: number;
132
+ totalTokens: number;
133
+ };
134
+ confirmed: {
135
+ inputTokens: number;
136
+ outputTokens: number;
137
+ totalTokens: number;
138
+ };
139
+ reserved: {
140
+ inputTokens: number;
141
+ outputTokens: number;
142
+ totalTokens: number;
143
+ };
144
+ unknown: {
145
+ inputTokens: number;
146
+ outputTokens: number;
147
+ totalTokens: number;
148
+ };
149
+ remaining: {
150
+ inputTokens: number;
151
+ outputTokens: number;
152
+ totalTokens: number;
153
+ };
154
+ usageComplete: boolean;
155
+ admissionsClosed: boolean;
156
+ invocationPending: boolean;
157
+ activeRunId: string | null;
158
+ runs: string[];
159
+ coordinatorId: string;
160
+ cancellations: {
161
+ runId: string;
162
+ requestedAt: number;
163
+ origin: "abort" | "lease_lost" | "operator" | "timeout";
164
+ localToolsDrainedAt?: number | undefined;
165
+ localExecution: "native_tools_drained" | "unconfirmed";
166
+ remoteExecution: 'unconfirmed';
167
+ }[];
168
+ monetary: {
169
+ schemaVersion: number;
170
+ runId: string;
171
+ calls: number;
172
+ routes: {
173
+ provider: string;
174
+ model: string;
175
+ calls: number;
176
+ inputTokens: number;
177
+ outputTokens: number;
178
+ unknownCalls: number;
179
+ estimatedUsd: number | null;
180
+ priceStatuses: string[];
181
+ }[];
182
+ inputTokens: number;
183
+ outputTokens: number;
184
+ historicalUsageUnknown: boolean;
185
+ usageComplete: boolean;
186
+ estimatedUsd: number | null;
187
+ limitUsd: number | null;
188
+ costKind: "estimate-not-invoice";
189
+ };
190
+ monetaryDetails: {
191
+ schemaVersion: 1;
192
+ confirmedCalls: number;
193
+ reservedCalls: number;
194
+ unknownCalls: number;
195
+ lateCalls: number;
196
+ estimatedConfirmedUsd: number | null;
197
+ reservedUsd: number | null;
198
+ unknownHeldUsd: number | null;
199
+ remainingUsd: number | null;
200
+ costComplete: boolean;
201
+ categories: string[];
202
+ costKind: "estimate-not-invoice";
203
+ };
204
+ } | null;
205
+ runs: {
206
+ runId: string;
207
+ revision: number | undefined;
208
+ status: import("@zhivex-ai/core").AgentStatus;
209
+ ledger: {
210
+ schemaVersion: 1;
211
+ revisions: {
212
+ revision: number;
213
+ digest: string;
214
+ previousDigest: string | null;
215
+ contract: {
216
+ schemaVersion: 1;
217
+ taskId: string;
218
+ allowedWritePaths: string[];
219
+ protectedFiles: string[];
220
+ requiredChecks: ({
221
+ id: string;
222
+ command: string;
223
+ args: string[];
224
+ purpose: string;
225
+ kind: "package-script";
226
+ script: string;
227
+ expectedScript: string;
228
+ execution: {
229
+ backend: "none" | "oci";
230
+ approval: "required";
231
+ };
232
+ } | {
233
+ id: string;
234
+ command: string;
235
+ args: string[];
236
+ purpose: string;
237
+ kind: "argv";
238
+ execution: {
239
+ backend: "oci";
240
+ approval: "required";
241
+ network: "none";
242
+ };
243
+ })[];
244
+ humanReview: {
245
+ id: string;
246
+ requirement: string;
247
+ status: "pending";
248
+ }[];
249
+ };
250
+ }[];
251
+ };
252
+ sources: {
253
+ id: string;
254
+ text: string;
255
+ original?: true;
256
+ }[];
257
+ decisions: import("../approvals/approval-history.js").ApprovalDecisionView[];
258
+ decisionsAvailability: string;
259
+ briefStatus: string;
260
+ objective: string | null;
261
+ constraints: string[];
262
+ hostPolicyCompatible: boolean;
263
+ assistantResponses: {
264
+ id: string;
265
+ text: string;
266
+ truncated: boolean;
267
+ untrusted: boolean;
268
+ verified: boolean;
269
+ }[];
270
+ effects: {
271
+ id: string;
272
+ tool: string;
273
+ revision: number;
274
+ status: string;
275
+ retry: string;
276
+ }[];
277
+ checks: {
278
+ id: string;
279
+ status: string;
280
+ }[];
281
+ snapshot: import("../runtime/task-acceptance-checks.js").TaskCheckBinding | null;
282
+ delivery: {} | null;
283
+ humanReview: {
284
+ id: string;
285
+ requirement: string;
286
+ status: "pending";
287
+ }[];
288
+ fingerprint: import("@zhivex-ai/core").AgentHarnessBinding | null;
289
+ }[];
290
+ currentContract: {
291
+ revision: number;
292
+ digest: string;
293
+ previousDigest: string | null;
294
+ contract: {
295
+ schemaVersion: 1;
296
+ taskId: string;
297
+ allowedWritePaths: string[];
298
+ protectedFiles: string[];
299
+ requiredChecks: ({
300
+ id: string;
301
+ command: string;
302
+ args: string[];
303
+ purpose: string;
304
+ kind: "package-script";
305
+ script: string;
306
+ expectedScript: string;
307
+ execution: {
308
+ backend: "none" | "oci";
309
+ approval: "required";
310
+ };
311
+ } | {
312
+ id: string;
313
+ command: string;
314
+ args: string[];
315
+ purpose: string;
316
+ kind: "argv";
317
+ execution: {
318
+ backend: "oci";
319
+ approval: "required";
320
+ network: "none";
321
+ };
322
+ })[];
323
+ humanReview: {
324
+ id: string;
325
+ requirement: string;
326
+ status: "pending";
327
+ }[];
328
+ };
329
+ } | null;
330
+ reasons: string[];
331
+ nextAction: string;
332
+ authorization: 'none';
333
+ automaticEffectReplay: false;
334
+ };
335
+ verify: () => Promise<void>;
336
+ verifyAll: () => Promise<void>;
337
+ };
338
+ current: {
339
+ revision: number;
340
+ digest: string;
341
+ previousDigest: string | null;
342
+ contract: {
343
+ schemaVersion: 1;
344
+ taskId: string;
345
+ allowedWritePaths: string[];
346
+ protectedFiles: string[];
347
+ requiredChecks: ({
348
+ id: string;
349
+ command: string;
350
+ args: string[];
351
+ purpose: string;
352
+ kind: "package-script";
353
+ script: string;
354
+ expectedScript: string;
355
+ execution: {
356
+ backend: "none" | "oci";
357
+ approval: "required";
358
+ };
359
+ } | {
360
+ id: string;
361
+ command: string;
362
+ args: string[];
363
+ purpose: string;
364
+ kind: "argv";
365
+ execution: {
366
+ backend: "oci";
367
+ approval: "required";
368
+ network: "none";
369
+ };
370
+ })[];
371
+ humanReview: {
372
+ id: string;
373
+ requirement: string;
374
+ status: "pending";
375
+ }[];
376
+ };
377
+ };
378
+ taskId: string;
379
+ }>;
380
+ /** Record a host preparation failure before any model invocation, retaining the original account.
381
+ * If authority cannot be acquired, the caller must leave the durable draft blocked, never downgrade to chat. */
382
+ export declare function persistClientTaskPreparationFailure(host: ZhivexHarness, state: AgentRunState, contract: ReturnType<typeof compileTaskAcceptanceContract>['contract']): Promise<void>;
383
+ /** Account exclusion is the same exclusion used for task admission; run CAS alone is insufficient. */
384
+ export declare function keepClientTask(host: ZhivexHarness, runId: string, allowedRunIds: readonly string[], expected: {
385
+ runRevision: number;
386
+ contractDigest: string;
387
+ snapshotDigest: string;
388
+ budgetRevision: number;
389
+ gitIdentity: string;
390
+ }): Promise<{
391
+ schemaVersion: number;
392
+ kind: string;
393
+ runId: string;
394
+ contractDigest: string;
395
+ contractRevision: number;
396
+ snapshotDigest: string;
397
+ reviewedRunRevision: number;
398
+ at: number;
399
+ provenance: string;
400
+ }>;
@@ -0,0 +1,12 @@
1
+ import type { ZhivexHarness } from '../runtime/harness.js';
2
+ import { type HarnessTaskProjection, type HarnessTaskProjectionScope } from './task-projection.js';
3
+ export type TaskProjectionCause = 'UNSUPPORTED_VERSION' | 'UNSUPPORTED_HOST' | 'OUT_OF_SCOPE' | 'CONTRACT_UNAVAILABLE' | 'EVIDENCE_UNAVAILABLE' | 'SNAPSHOT_CHANGED' | 'PAYLOAD_LIMIT';
4
+ export declare class TaskProjectionFault extends Error {
5
+ readonly causeCode: TaskProjectionCause;
6
+ constructor(causeCode: TaskProjectionCause);
7
+ }
8
+ export declare function redactTaskDisplayText(host: ZhivexHarness, raw: string, sensitiveValues?: readonly string[]): string;
9
+ /** Derivation only: no session refresh, ledger creation, state save, checks or model calls. */
10
+ export declare function projectHarnessTask(host: ZhivexHarness, request: HarnessTaskProjectionScope & {
11
+ sequence: number;
12
+ }, allowedRunIds: readonly string[], sensitiveValues?: readonly string[]): Promise<HarnessTaskProjection>;