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

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 (164) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +9 -10
  3. package/contracts/engine-api.json +2921 -0
  4. package/contracts/public-api.json +267 -1
  5. package/contracts/stable-api-signatures.json +43 -43
  6. package/dist/acp-cli.js +137 -15002
  7. package/dist/approvals/approval-history.d.ts +22 -0
  8. package/dist/approvals/explicit-review.d.ts +24 -0
  9. package/dist/approvals/host-policy-identity.d.ts +3 -0
  10. package/dist/cli/arguments.d.ts +6 -2
  11. package/dist/cli/checkpoints.d.ts +230 -0
  12. package/dist/cli/cli-options.d.ts +2 -41
  13. package/dist/cli/cli-profiles.d.ts +4 -2
  14. package/dist/cli/cli-stream.d.ts +2 -167
  15. package/dist/cli/governance-report.d.ts +5 -0
  16. package/dist/cli/policy-decisions.d.ts +9 -0
  17. package/dist/cli/policy.d.ts +5 -0
  18. package/dist/cli/presentation.d.ts +3 -1
  19. package/dist/cli/run-document.d.ts +2 -91
  20. package/dist/cli/terminal/terminal-continuation.d.ts +2 -3
  21. package/dist/cli/terminal/terminal-ui.d.ts +4 -0
  22. package/dist/{cli-entry-c2f58zj2.js → cli-entry-ae7x44d4.js} +14969 -10731
  23. package/dist/{cli-entry-427869g9.js → cli-entry-d5788aay.js} +388 -47
  24. package/dist/cli-entry-ev76ezcd.js +656 -0
  25. package/dist/{cli-3jmy4h5h.js → cli-t7hrhayq.js} +918 -2223
  26. package/dist/cli.js +3 -5
  27. package/dist/client/acp-mcp-admission.d.ts +32 -0
  28. package/dist/client/acp-mcp-host.d.ts +19 -0
  29. package/dist/client/acp-mcp-session.d.ts +14 -0
  30. package/dist/client/acp-stdio.d.ts +2 -0
  31. package/dist/client/acp.d.ts +4 -1
  32. package/dist/client/adapter.d.ts +13 -1
  33. package/dist/client/continuation.d.ts +3 -0
  34. package/dist/client/json-contracts.d.ts +107 -4
  35. package/dist/client/local-service.d.ts +2 -0
  36. package/dist/client/protocol.d.ts +127 -1
  37. package/dist/client/run-document.d.ts +91 -0
  38. package/dist/client/service-events.d.ts +4 -0
  39. package/dist/client/stream.d.ts +167 -0
  40. package/dist/compat/cli-options.d.ts +53 -0
  41. package/dist/compat/code-support.d.ts +22 -0
  42. package/dist/compat/code-support.js +74 -0
  43. package/dist/{config-1k9t4jhh.js → config-c002f06f.js} +1 -1
  44. package/dist/config-j3jga5wh.js +61 -0
  45. package/dist/context/adaptive-compaction.d.ts +1 -0
  46. package/dist/context/compaction.d.ts +1 -1
  47. package/dist/context/request-measurements.d.ts +17 -0
  48. package/dist/context/request-projection.d.ts +10 -0
  49. package/dist/context/task-memory.d.ts +1 -0
  50. package/dist/engine/acp.d.ts +6 -0
  51. package/dist/engine/acp.js +205 -0
  52. package/dist/engine/client.d.ts +6 -0
  53. package/dist/engine/client.js +28 -0
  54. package/dist/engine/desktop-providers-v1.d.ts +4 -0
  55. package/dist/engine/desktop-providers-v1.js +18 -0
  56. package/dist/engine/desktop-state-v1.d.ts +10 -0
  57. package/dist/engine/desktop-state-v1.js +168 -0
  58. package/dist/engine/index.d.ts +73 -0
  59. package/dist/engine/index.js +977 -0
  60. package/dist/engine/mcp-stdio-v1.d.ts +11 -0
  61. package/dist/engine/mcp-stdio-v1.js +108 -0
  62. package/dist/engine/models.d.ts +3 -0
  63. package/dist/engine/models.js +894 -0
  64. package/dist/engine/protocol.d.ts +7 -0
  65. package/dist/engine/protocol.js +182 -0
  66. package/dist/engine/service.d.ts +5 -0
  67. package/dist/engine/service.js +28 -0
  68. package/dist/execution/acceptance-snapshot.d.ts +2 -0
  69. package/dist/execution/execution-environment.d.ts +10 -0
  70. package/dist/execution/mcp-oci-channel.d.ts +11 -0
  71. package/dist/execution/mcp-oci-server.d.ts +38 -0
  72. package/dist/execution/mcp-oci-workspace.d.ts +23 -0
  73. package/dist/execution/mcp-resource-recovery.d.ts +19 -0
  74. package/dist/execution/mcp-workspace-snapshot.d.ts +20 -0
  75. package/dist/hostile-repository-demo.js +3368 -1304
  76. package/dist/index-1bx83sw4.js +4 -0
  77. package/dist/index-2gz7jv7g.js +549 -0
  78. package/dist/{cli-entry-b1mfvmxe.js → index-2jrdcj6b.js} +72 -115
  79. package/dist/index-3ah1f369.js +356 -0
  80. package/dist/index-42gp2hy8.js +1555 -0
  81. package/dist/index-4jw3tvy8.js +301 -0
  82. package/dist/index-8705zxpr.js +145 -0
  83. package/dist/index-8vm2m34s.js +2080 -0
  84. package/dist/index-8zzhggxv.js +477 -0
  85. package/dist/index-a97bezbz.js +1073 -0
  86. package/dist/index-gq9xagx2.js +1343 -0
  87. package/dist/index-h0mqx2ed.js +1373 -0
  88. package/dist/index-jgrx804e.js +5589 -0
  89. package/dist/index-qfpz5y2v.js +174 -0
  90. package/dist/index-t60rva31.js +1004 -0
  91. package/dist/index-wg1sd3at.js +80 -0
  92. package/dist/index-xqxeypt5.js +888 -0
  93. package/dist/index-yb239ghk.js +961 -0
  94. package/dist/index-z0qxmkm2.js +3389 -0
  95. package/dist/index-z4e8d0ph.js +1768 -0
  96. package/dist/index.js +251 -18649
  97. package/dist/integrations/mcp-host-session.d.ts +26 -0
  98. package/dist/integrations/mcp-stdio-admission.d.ts +54 -0
  99. package/dist/integrations/mcp-stdio-client.d.ts +44 -0
  100. package/dist/integrations/mcp-stdio-framing.d.ts +18 -0
  101. package/dist/integrations/mcp-stdio-launch.d.ts +20 -0
  102. package/dist/integrations/mcp-stdio-session.d.ts +7 -0
  103. package/dist/integrations/mcp-stdio-tools.d.ts +12 -0
  104. package/dist/internal/desktop/catalog.d.ts +2 -0
  105. package/dist/internal/desktop/persistence.d.ts +2 -3
  106. package/dist/internal/desktop/providers.d.ts +1 -0
  107. package/dist/models/catalog.d.ts +2 -0
  108. package/dist/persistence/governance-context.d.ts +126 -0
  109. package/dist/persistence/governance-report.d.ts +299 -0
  110. package/dist/persistence/host-database-backup.d.ts +28 -0
  111. package/dist/persistence/mcp-execution-journal.d.ts +19 -0
  112. package/dist/persistence/mcp-reconciliation.d.ts +33 -0
  113. package/dist/persistence/mcp-resource-journal.d.ts +54 -0
  114. package/dist/persistence/workspace-checkpoints.d.ts +138 -0
  115. package/dist/providers/anthropic-continuation.d.ts +5 -0
  116. package/dist/providers/providers.d.ts +1 -1
  117. package/dist/providers/vertex-auth.d.ts +27 -0
  118. package/dist/runtime/delegation-contracts.d.ts +9 -0
  119. package/dist/runtime/delegation-correction.d.ts +9 -0
  120. package/dist/runtime/delegation-result.d.ts +73 -0
  121. package/dist/runtime/error-diagnostics.d.ts +86 -0
  122. package/dist/runtime/harness.d.ts +11 -1
  123. package/dist/runtime/policy-decisions.d.ts +66 -0
  124. package/dist/runtime/policy-inspection.d.ts +52 -0
  125. package/dist/runtime/provider-diagnostics.d.ts +1 -0
  126. package/dist/runtime/runtime-instructions.d.ts +8 -0
  127. package/dist/runtime/task-acceptance-checks.d.ts +103 -0
  128. package/dist/runtime/task-acceptance-delivery.d.ts +107 -0
  129. package/dist/runtime/task-acceptance-host.d.ts +20 -0
  130. package/dist/runtime/task-acceptance-record.d.ts +107 -0
  131. package/dist/runtime/task-acceptance-validation.d.ts +25 -0
  132. package/dist/runtime/task-acceptance.d.ts +47 -0
  133. package/dist/runtime/time-to-safe-fix.d.ts +83 -0
  134. package/dist/runtime/tool-policy-file.d.ts +23 -0
  135. package/dist/runtime/tool-policy-paths.d.ts +5 -0
  136. package/dist/runtime/tool-policy.d.ts +6 -0
  137. package/dist/service-cli.js +19 -14504
  138. package/dist/{service-client-cli-yx56n0hc.js → service-client-cli-kns4mf57.js} +307 -248
  139. package/dist/verify-historical-migrations.js +3314 -1251
  140. package/dist/workspace/path-policy.d.ts +4 -0
  141. package/dist/zhx.js +3 -5
  142. package/docs/ACP.md +14 -2
  143. package/docs/ANTHROPIC.md +33 -0
  144. package/docs/CLI.md +132 -0
  145. package/docs/CLIENT_PROTOCOL.md +45 -0
  146. package/docs/CODE_RELEASE.md +93 -0
  147. package/docs/ENGINE_API.md +319 -0
  148. package/docs/EXTENSIBILITY.md +46 -3
  149. package/docs/FIRST_USE.md +6 -6
  150. package/docs/LOCAL_SERVICE.md +13 -0
  151. package/docs/MCP_STDIO.md +20 -0
  152. package/docs/README.md +6 -0
  153. package/docs/STABILITY.md +9 -1
  154. package/docs/SUPPORT_MATRIX.md +1 -1
  155. package/docs/TOOL_POLICY.md +81 -0
  156. package/docs/VERTEX.md +50 -0
  157. package/docs/adr/0002-isolated-mcp-stdio.md +135 -0
  158. package/docs/fixtures/mcp-stdio-contract-v1.json +189 -0
  159. package/docs/support-matrix.json +2 -0
  160. package/evaluations/representative-assembly-matrix.json +64 -1
  161. package/evaluations/task-acceptance-routes.json +7 -0
  162. package/examples/README.md +1 -1
  163. package/package.json +74 -12
  164. package/dist/cli-entry-64pdp3k5.js +0 -17
package/dist/cli.js CHANGED
@@ -1,10 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ HARNESS_VERSION,
3
4
  shortCliHelp
4
- } from "./cli-entry-b1mfvmxe.js";
5
- import {
6
- HARNESS_VERSION
7
- } from "./cli-entry-64pdp3k5.js";
5
+ } from "./cli-entry-ev76ezcd.js";
8
6
  import {
9
7
  __require
10
8
  } from "./cli-entry-1bx83sw4.js";
@@ -18,6 +16,6 @@ if (argv.length === 1 && ["--version", "-v", "version"].includes(argv[0])) {
18
16
  process.stdout.write(`${shortCliHelp(HARNESS_VERSION)}
19
17
  `);
20
18
  } else {
21
- const { runCli } = await import("./cli-3jmy4h5h.js");
19
+ const { runCli } = await import("./cli-t7hrhayq.js");
22
20
  await runCli(argv);
23
21
  }
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+ import type { McpStdioLaunchProposal } from '../integrations/mcp-stdio-admission.js';
3
+ declare const descriptor: z.ZodObject<{
4
+ name: z.ZodString;
5
+ command: z.ZodString;
6
+ args: z.ZodArray<z.ZodString>;
7
+ env: z.ZodArray<z.ZodObject<{
8
+ name: z.ZodString;
9
+ value: z.ZodString;
10
+ }, z.core.$strict>>;
11
+ }, z.core.$strict>;
12
+ export type AcpMcpStdioDescriptor = z.infer<typeof descriptor>;
13
+ /** ACP v1 request data, never executable host configuration. */
14
+ export declare function parseAcpMcpDescriptors(input: unknown): readonly AcpMcpStdioDescriptor[];
15
+ export interface AcpMcpHostRule {
16
+ /** Exact client command/argv mapped to a host-provisioned immutable image. */
17
+ clientCommand: string;
18
+ clientArgs: readonly string[];
19
+ clientName: string;
20
+ proposal: Omit<McpStdioLaunchProposal, 'scope' | 'snapshotDigest'>;
21
+ /** Explicit client env -> admitted ZHIVEX_MCP_* name translation. */
22
+ environmentBindings: Readonly<Record<string, string>>;
23
+ }
24
+ /** Pure translation. It cannot authorize, spawn, read secrets or choose a snapshot.
25
+ * The returned proposals must still cross the host's MCP admission authority.
26
+ */
27
+ export declare function proposeAcpMcpLaunches(input: unknown, options: {
28
+ rules: readonly AcpMcpHostRule[];
29
+ scope: McpStdioLaunchProposal['scope'];
30
+ snapshotDigest: string;
31
+ }): readonly McpStdioLaunchProposal[];
32
+ export {};
@@ -0,0 +1,19 @@
1
+ import { type CreateHarnessOptions } from '../runtime/harness.js';
2
+ import type { HarnessClientAdapter } from './protocol.js';
3
+ import { type AcpMcpHostRule } from './acp-mcp-admission.js';
4
+ import { launchDockerMcpTools } from '../execution/mcp-oci-server.js';
5
+ /** Trusted host composition. Client descriptors never become process arguments
6
+ * without an exact host rule, immutable snapshot and fresh admission receipt. */
7
+ export declare function createAcpMcpHost(options: {
8
+ harness: CreateHarnessOptions;
9
+ rules: readonly AcpMcpHostRule[];
10
+ authority: Parameters<typeof launchDockerMcpTools>[0]['authority'];
11
+ provisionerImageId: string;
12
+ hostId: string;
13
+ resolveSecret: Parameters<typeof launchDockerMcpTools>[0]['resolveSecret'];
14
+ }): Promise<Readonly<{
15
+ adapter: HarnessClientAdapter;
16
+ workspace: string;
17
+ mcpSessionProvider: Readonly<Record<never, never>>;
18
+ close(): Promise<void>;
19
+ }>>;
@@ -0,0 +1,14 @@
1
+ import type { HarnessClientAdapter } from './protocol.js';
2
+ import type { AcpMcpStdioDescriptor } from './acp-mcp-admission.js';
3
+ export type AcpMcpSessionProvider = Readonly<Record<never, never>>;
4
+ /** Internal issuer. Only the wired host factory exports a provider capability. */
5
+ export declare function issueAcpMcpSessionProvider(provider: {
6
+ adapter: HarnessClientAdapter;
7
+ parse(input: unknown): readonly AcpMcpStdioDescriptor[];
8
+ bind(sessionId: string, servers: readonly AcpMcpStdioDescriptor[]): void;
9
+ }): AcpMcpSessionProvider;
10
+ export declare function resolveAcpMcpSessionProvider(token: AcpMcpSessionProvider, adapter: HarnessClientAdapter): {
11
+ adapter: HarnessClientAdapter;
12
+ parse(input: unknown): readonly AcpMcpStdioDescriptor[];
13
+ bind(sessionId: string, servers: readonly AcpMcpStdioDescriptor[]): void;
14
+ };
@@ -1,8 +1,10 @@
1
1
  import type { Readable, Writable } from "node:stream";
2
+ import { type AcpConnectionOptions } from "./acp.js";
2
3
  import type { HarnessClientAdapter } from "./protocol.js";
3
4
  /** JSON-lines transport. Bounded frames and pending requests; stdout contains JSON-RPC only. */
4
5
  export declare const serveAcpStdio: (adapter: HarnessClientAdapter, options: {
5
6
  workspace: string;
7
+ mcpSessionProvider?: AcpConnectionOptions['mcpSessionProvider'];
6
8
  input: Readable;
7
9
  output: Writable;
8
10
  permissionTimeoutMs?: number;
@@ -1,7 +1,10 @@
1
+ import { type AcpMcpSessionProvider } from './acp-mcp-session.js';
1
2
  import type { HarnessClientAdapter } from "./protocol.js";
2
3
  export interface AcpConnectionOptions {
3
4
  /** Fixed host-owned workspace. Client requests cannot change it. */
4
5
  workspace: string;
6
+ /** Opaque capability returned by the isolated MCP host factory. */
7
+ mcpSessionProvider?: AcpMcpSessionProvider;
5
8
  notify(message: {
6
9
  jsonrpc: "2.0";
7
10
  method: "session/update";
@@ -10,7 +13,7 @@ export interface AcpConnectionOptions {
10
13
  requestPermission(params: Record<string, unknown>, signal?: AbortSignal): Promise<unknown>;
11
14
  }
12
15
  /** Embedding adapter for ACP v1 text sessions, not a complete ACP implementation.
13
- * No transport, session loading, client filesystem/terminal, or client-supplied MCP.
16
+ * No transport, session loading or client filesystem/terminal. Client MCP requires a host capability.
14
17
  * Every approval remains bound to the existing adapter's revision/digest checks. */
15
18
  export declare const createAcpConnection: (adapter: HarnessClientAdapter, options: AcpConnectionOptions) => {
16
19
  cancelActive(): Promise<void>;
@@ -1,4 +1,16 @@
1
1
  import { type ZhivexHarness } from "../runtime/harness.js";
2
2
  import { type HarnessClientAdapter, type HarnessClientAdapterOptions } from "./protocol.js";
3
+ /** Trusted host lifecycle hook; never accepted from a protocol request. */
4
+ export interface HarnessClientRunRuntimeOptions {
5
+ prepareRun?(context: {
6
+ sessionId: string;
7
+ runId: string;
8
+ resuming: boolean;
9
+ signal: AbortSignal;
10
+ }): Promise<{
11
+ harness: ZhivexHarness;
12
+ release(): Promise<void>;
13
+ }>;
14
+ }
3
15
  /** One trusted host, one workspace/scope, one connection epoch; no multi-writer guarantee. */
4
- export declare const createHarnessClientAdapter: (harness: ZhivexHarness, options?: HarnessClientAdapterOptions) => Promise<HarnessClientAdapter>;
16
+ export declare const createHarnessClientAdapter: (harness: ZhivexHarness, options?: HarnessClientAdapterOptions & HarnessClientRunRuntimeOptions) => Promise<HarnessClientAdapter>;
@@ -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[];
@@ -215,10 +215,12 @@ export declare const cliInitDocumentSchema: z.ZodObject<{
215
215
  path: z.ZodString;
216
216
  schemaVersion: z.ZodNumber;
217
217
  provider: z.ZodEnum<{
218
+ anthropic: "anthropic";
218
219
  gemini: "gemini";
219
220
  meta: "meta";
220
221
  openai: "openai";
221
222
  qwen: "qwen";
223
+ vertex: "vertex";
222
224
  }>;
223
225
  model: z.ZodString;
224
226
  reasoningEffort: z.ZodOptional<z.ZodEnum<{
@@ -701,11 +703,48 @@ export declare const cliErrorDocumentSchema: z.ZodObject<{
701
703
  retryable: z.ZodBoolean;
702
704
  }, z.core.$loose>;
703
705
  }, z.core.$loose>;
704
- /**
705
- * Stable parser for final structured output. Observational documents retain
706
- * additive fields; the digest-bound change envelope remains strict.
707
- */
708
706
  export declare const cliJsonDocumentSchema: z.ZodUnion<readonly [z.ZodObject<{
707
+ schemaVersion: z.ZodLiteral<1>;
708
+ kind: z.ZodLiteral<"policy-inspection">;
709
+ digest: z.ZodNullable<z.ZodString>;
710
+ source: z.ZodEnum<{
711
+ application: "application";
712
+ baseline: "baseline";
713
+ "operator-file": "operator-file";
714
+ }>;
715
+ explicitReviewRequired: z.ZodBoolean;
716
+ tools: z.ZodArray<z.ZodObject<{
717
+ name: z.ZodString;
718
+ requiresApproval: z.ZodBoolean;
719
+ }, z.core.$loose>>;
720
+ restrictions: z.ZodArray<z.ZodObject<{
721
+ ruleId: z.ZodString;
722
+ tools: z.ZodArray<z.ZodString>;
723
+ decision: z.ZodEnum<{
724
+ allow: "allow";
725
+ ask_user: "ask_user";
726
+ deny: "deny";
727
+ }>;
728
+ reason: z.ZodString;
729
+ pathCount: z.ZodNumber;
730
+ }, z.core.$loose>>;
731
+ execution: z.ZodObject<{
732
+ configuredBackend: z.ZodEnum<{
733
+ none: "none";
734
+ oci: "oci";
735
+ }>;
736
+ activeBackend: z.ZodEnum<{
737
+ none: "none";
738
+ oci: "oci";
739
+ }>;
740
+ evidence: z.ZodLiteral<"configuration-only">;
741
+ }, z.core.$loose>;
742
+ limits: z.ZodObject<{
743
+ maxSteps: z.ZodNumber;
744
+ timeoutMs: z.ZodNumber;
745
+ budget: z.ZodObject<{}, z.core.$loose>;
746
+ }, z.core.$loose>;
747
+ }, z.core.$loose>, z.ZodObject<{
709
748
  schemaVersion: z.ZodLiteral<1>;
710
749
  runId: z.ZodString;
711
750
  status: z.ZodString;
@@ -891,10 +930,12 @@ export declare const cliJsonDocumentSchema: z.ZodUnion<readonly [z.ZodObject<{
891
930
  path: z.ZodString;
892
931
  schemaVersion: z.ZodNumber;
893
932
  provider: z.ZodEnum<{
933
+ anthropic: "anthropic";
894
934
  gemini: "gemini";
895
935
  meta: "meta";
896
936
  openai: "openai";
897
937
  qwen: "qwen";
938
+ vertex: "vertex";
898
939
  }>;
899
940
  model: z.ZodString;
900
941
  reasoningEffort: z.ZodOptional<z.ZodEnum<{
@@ -1449,6 +1490,37 @@ export declare const cliJsonDocumentSchema: z.ZodUnion<readonly [z.ZodObject<{
1449
1490
  }, z.core.$strict>>>;
1450
1491
  }, z.core.$strict>]>;
1451
1492
  export declare const cliRunEventDocumentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1493
+ schemaVersion: z.ZodLiteral<1>;
1494
+ sequence: z.ZodNumber;
1495
+ kind: z.ZodLiteral<"run-event">;
1496
+ type: z.ZodLiteral<"policy-decision">;
1497
+ phase: z.ZodEnum<{
1498
+ "approval-request": "approval-request";
1499
+ "tool-entry": "tool-entry";
1500
+ }>;
1501
+ toolName: z.ZodString;
1502
+ decision: z.ZodEnum<{
1503
+ allow: "allow";
1504
+ ask_user: "ask_user";
1505
+ deny: "deny";
1506
+ }>;
1507
+ ruleIds: z.ZodArray<z.ZodString>;
1508
+ reason: z.ZodString;
1509
+ reasonTruncated: z.ZodBoolean;
1510
+ policyDigest: z.ZodNullable<z.ZodString>;
1511
+ source: z.ZodEnum<{
1512
+ application: "application";
1513
+ baseline: "baseline";
1514
+ "operator-file": "operator-file";
1515
+ }>;
1516
+ approvalRequired: z.ZodBoolean;
1517
+ explicitReviewRequired: z.ZodBoolean;
1518
+ executionBackend: z.ZodEnum<{
1519
+ none: "none";
1520
+ oci: "oci";
1521
+ }>;
1522
+ evidence: z.ZodLiteral<"policy-evaluation">;
1523
+ }, z.core.$loose>, z.ZodObject<{
1452
1524
  schemaVersion: z.ZodLiteral<1>;
1453
1525
  sequence: z.ZodNumber;
1454
1526
  kind: z.ZodLiteral<"run-event">;
@@ -1610,6 +1682,37 @@ export declare const cliStreamErrorDocumentSchema: z.ZodObject<{
1610
1682
  }, z.core.$loose>;
1611
1683
  /** Stable parser for one JSONL record. Every record kind is unambiguous. */
1612
1684
  export declare const cliJsonLineDocumentSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
1685
+ schemaVersion: z.ZodLiteral<1>;
1686
+ sequence: z.ZodNumber;
1687
+ kind: z.ZodLiteral<"run-event">;
1688
+ type: z.ZodLiteral<"policy-decision">;
1689
+ phase: z.ZodEnum<{
1690
+ "approval-request": "approval-request";
1691
+ "tool-entry": "tool-entry";
1692
+ }>;
1693
+ toolName: z.ZodString;
1694
+ decision: z.ZodEnum<{
1695
+ allow: "allow";
1696
+ ask_user: "ask_user";
1697
+ deny: "deny";
1698
+ }>;
1699
+ ruleIds: z.ZodArray<z.ZodString>;
1700
+ reason: z.ZodString;
1701
+ reasonTruncated: z.ZodBoolean;
1702
+ policyDigest: z.ZodNullable<z.ZodString>;
1703
+ source: z.ZodEnum<{
1704
+ application: "application";
1705
+ baseline: "baseline";
1706
+ "operator-file": "operator-file";
1707
+ }>;
1708
+ approvalRequired: z.ZodBoolean;
1709
+ explicitReviewRequired: z.ZodBoolean;
1710
+ executionBackend: z.ZodEnum<{
1711
+ none: "none";
1712
+ oci: "oci";
1713
+ }>;
1714
+ evidence: z.ZodLiteral<"policy-evaluation">;
1715
+ }, z.core.$loose>, z.ZodObject<{
1613
1716
  schemaVersion: z.ZodLiteral<1>;
1614
1717
  sequence: z.ZodNumber;
1615
1718
  kind: z.ZodLiteral<"run-event">;
@@ -10,6 +10,8 @@ export interface HarnessLocalService {
10
10
  resumeAdmission(): void;
11
11
  /** Requests cancellation of this host's active invocation; never force-finalizes it. */
12
12
  cancelActive(): Promise<void>;
13
+ /** Trusted host channel after full review; never exposed by the HTTP router. */
14
+ dispatchReviewed(request: unknown): Promise<HarnessClientResponse>;
13
15
  /** Stops admission, drains accepted commands, closes adapter and host runtime. */
14
16
  close(): Promise<void>;
15
17
  }
@@ -1,13 +1,20 @@
1
+ import type { HarnessPolicyDecisionEvent } from "../runtime/policy-decisions.js";
2
+ import type { HarnessPolicyInspection } from "../runtime/policy-inspection.js";
1
3
  import { type ApprovalDecisionView } from "../approvals/approval-history.js";
2
4
  import { type ApprovalFilePreview } from "../approvals/approval-preview.js";
3
5
  import { z } from "zod";
4
6
  import type { AgentStreamEvent } from "@zhivex-ai/agents";
5
7
  import { type CliSession } from "../persistence/sessions.js";
6
8
  export declare const HARNESS_CLIENT_PROTOCOL_VERSION: 1;
9
+ type CheckpointStore = Awaited<ReturnType<typeof import('../persistence/workspace-checkpoints.js').openWorkspaceCheckpointStore>>;
10
+ type RestoreSummary = ReturnType<CheckpointStore['listRestores']>[number];
7
11
  /** Strict command union; configuration, credentials and filesystem paths are host-owned. */
8
12
  export declare const harnessClientCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
9
13
  projectId: z.ZodString;
10
14
  method: z.ZodLiteral<"project.get">;
15
+ }, z.core.$strict>, z.ZodObject<{
16
+ projectId: z.ZodString;
17
+ method: z.ZodLiteral<"policy.get">;
11
18
  }, z.core.$strict>, z.ZodObject<{
12
19
  projectId: z.ZodString;
13
20
  method: z.ZodLiteral<"session.list">;
@@ -28,6 +35,52 @@ export declare const harnessClientCommandSchema: z.ZodDiscriminatedUnion<[z.ZodO
28
35
  method: z.ZodLiteral<"session.rename">;
29
36
  expectedRevision: z.ZodNumber;
30
37
  title: z.ZodString;
38
+ }, z.core.$strict>, z.ZodObject<{
39
+ projectId: z.ZodString;
40
+ sessionId: z.ZodString;
41
+ method: z.ZodLiteral<"checkpoint.list">;
42
+ }, z.core.$strict>, z.ZodObject<{
43
+ projectId: z.ZodString;
44
+ sessionId: z.ZodString;
45
+ checkpointId: z.ZodString;
46
+ method: z.ZodLiteral<"checkpoint.inspect">;
47
+ }, z.core.$strict>, z.ZodObject<{
48
+ projectId: z.ZodString;
49
+ sessionId: z.ZodString;
50
+ idempotencyKey: z.ZodString;
51
+ method: z.ZodLiteral<"checkpoint.capture">;
52
+ expectedRevision: z.ZodNumber;
53
+ turnId: z.ZodString;
54
+ paths: z.ZodArray<z.ZodString>;
55
+ }, z.core.$strict>, z.ZodObject<{
56
+ projectId: z.ZodString;
57
+ sessionId: z.ZodString;
58
+ idempotencyKey: z.ZodString;
59
+ checkpointId: z.ZodString;
60
+ method: z.ZodLiteral<"restore.prepare">;
61
+ expectedRevision: z.ZodNumber;
62
+ expected: z.ZodRecord<z.ZodString, z.ZodString>;
63
+ }, z.core.$strict>, z.ZodObject<{
64
+ projectId: z.ZodString;
65
+ sessionId: z.ZodString;
66
+ operationId: z.ZodString;
67
+ method: z.ZodLiteral<"restore.get">;
68
+ }, z.core.$strict>, z.ZodObject<{
69
+ projectId: z.ZodString;
70
+ sessionId: z.ZodString;
71
+ idempotencyKey: z.ZodString;
72
+ operationId: z.ZodString;
73
+ method: z.ZodLiteral<"restore.apply">;
74
+ expectedRevision: z.ZodNumber;
75
+ reviewedProposalId: z.ZodString;
76
+ }, z.core.$strict>, z.ZodObject<{
77
+ projectId: z.ZodString;
78
+ sessionId: z.ZodString;
79
+ idempotencyKey: z.ZodString;
80
+ operationId: z.ZodString;
81
+ method: z.ZodLiteral<"restore.recoverFork">;
82
+ expectedRevision: z.ZodNumber;
83
+ forkSessionId: z.ZodString;
31
84
  }, z.core.$strict>, z.ZodObject<{
32
85
  projectId: z.ZodString;
33
86
  sessionId: z.ZodString;
@@ -70,6 +123,9 @@ export declare const harnessClientRequestSchema: z.ZodObject<{
70
123
  command: z.ZodDiscriminatedUnion<[z.ZodObject<{
71
124
  projectId: z.ZodString;
72
125
  method: z.ZodLiteral<"project.get">;
126
+ }, z.core.$strict>, z.ZodObject<{
127
+ projectId: z.ZodString;
128
+ method: z.ZodLiteral<"policy.get">;
73
129
  }, z.core.$strict>, z.ZodObject<{
74
130
  projectId: z.ZodString;
75
131
  method: z.ZodLiteral<"session.list">;
@@ -90,6 +146,52 @@ export declare const harnessClientRequestSchema: z.ZodObject<{
90
146
  method: z.ZodLiteral<"session.rename">;
91
147
  expectedRevision: z.ZodNumber;
92
148
  title: z.ZodString;
149
+ }, z.core.$strict>, z.ZodObject<{
150
+ projectId: z.ZodString;
151
+ sessionId: z.ZodString;
152
+ method: z.ZodLiteral<"checkpoint.list">;
153
+ }, z.core.$strict>, z.ZodObject<{
154
+ projectId: z.ZodString;
155
+ sessionId: z.ZodString;
156
+ checkpointId: z.ZodString;
157
+ method: z.ZodLiteral<"checkpoint.inspect">;
158
+ }, z.core.$strict>, z.ZodObject<{
159
+ projectId: z.ZodString;
160
+ sessionId: z.ZodString;
161
+ idempotencyKey: z.ZodString;
162
+ method: z.ZodLiteral<"checkpoint.capture">;
163
+ expectedRevision: z.ZodNumber;
164
+ turnId: z.ZodString;
165
+ paths: z.ZodArray<z.ZodString>;
166
+ }, z.core.$strict>, z.ZodObject<{
167
+ projectId: z.ZodString;
168
+ sessionId: z.ZodString;
169
+ idempotencyKey: z.ZodString;
170
+ checkpointId: z.ZodString;
171
+ method: z.ZodLiteral<"restore.prepare">;
172
+ expectedRevision: z.ZodNumber;
173
+ expected: z.ZodRecord<z.ZodString, z.ZodString>;
174
+ }, z.core.$strict>, z.ZodObject<{
175
+ projectId: z.ZodString;
176
+ sessionId: z.ZodString;
177
+ operationId: z.ZodString;
178
+ method: z.ZodLiteral<"restore.get">;
179
+ }, z.core.$strict>, z.ZodObject<{
180
+ projectId: z.ZodString;
181
+ sessionId: z.ZodString;
182
+ idempotencyKey: z.ZodString;
183
+ operationId: z.ZodString;
184
+ method: z.ZodLiteral<"restore.apply">;
185
+ expectedRevision: z.ZodNumber;
186
+ reviewedProposalId: z.ZodString;
187
+ }, z.core.$strict>, z.ZodObject<{
188
+ projectId: z.ZodString;
189
+ sessionId: z.ZodString;
190
+ idempotencyKey: z.ZodString;
191
+ operationId: z.ZodString;
192
+ method: z.ZodLiteral<"restore.recoverFork">;
193
+ expectedRevision: z.ZodNumber;
194
+ forkSessionId: z.ZodString;
93
195
  }, z.core.$strict>, z.ZodObject<{
94
196
  projectId: z.ZodString;
95
197
  sessionId: z.ZodString;
@@ -128,7 +230,7 @@ export declare const harnessClientRequestSchema: z.ZodObject<{
128
230
  }, z.core.$strict>;
129
231
  export type HarnessClientCommand = z.infer<typeof harnessClientCommandSchema>;
130
232
  export type HarnessClientRequest = z.infer<typeof harnessClientRequestSchema>;
131
- export type HarnessClientErrorCode = "INVALID_REQUEST" | "VERSION_UNSUPPORTED" | "CONNECTION_EXPIRED" | "NOT_FOUND" | "REVISION_CONFLICT" | "IDEMPOTENCY_CONFLICT" | "CAPACITY_EXCEEDED" | "APPROVAL_MISMATCH" | "INVALID_STATE" | "BUSY" | "EXECUTION_FAILED";
233
+ export type HarnessClientErrorCode = "INVALID_REQUEST" | "VERSION_UNSUPPORTED" | "CONNECTION_EXPIRED" | "NOT_FOUND" | "REVISION_CONFLICT" | "IDEMPOTENCY_CONFLICT" | "CAPACITY_EXCEEDED" | "APPROVAL_MISMATCH" | "EXPLICIT_REVIEW_REQUIRED" | "INVALID_STATE" | "BUSY" | "EXECUTION_FAILED";
132
234
  export interface HarnessClientSession extends CliSession {
133
235
  }
134
236
  export interface HarnessClientRun {
@@ -153,12 +255,32 @@ export interface HarnessClientRun {
153
255
  export type HarnessClientData = {
154
256
  kind: "project";
155
257
  projectId: string;
258
+ } | {
259
+ kind: "policy";
260
+ policy: HarnessPolicyInspection;
156
261
  } | {
157
262
  kind: "session";
158
263
  session: HarnessClientSession;
159
264
  } | {
160
265
  kind: "sessions";
161
266
  sessions: HarnessClientSession[];
267
+ } | {
268
+ kind: "checkpoints";
269
+ checkpoints: ReturnType<CheckpointStore['listCheckpoints']>;
270
+ restores: ReturnType<CheckpointStore['listRestores']>;
271
+ } | {
272
+ kind: "checkpoint";
273
+ inspection: Awaited<ReturnType<CheckpointStore['inspectCheckpoint']>>;
274
+ } | {
275
+ kind: "restore";
276
+ operation: RestoreSummary;
277
+ preview: {
278
+ status: "available";
279
+ diff: Awaited<ReturnType<CheckpointStore['previewRestore']>>;
280
+ } | {
281
+ status: "unavailable";
282
+ };
283
+ session?: HarnessClientSession;
162
284
  } | {
163
285
  kind: "run";
164
286
  session: HarnessClientSession;
@@ -191,6 +313,7 @@ export type HarnessClientNegotiation = {
191
313
  export interface HarnessClientAdapterOptions {
192
314
  approvalMaxAgeMs?: number;
193
315
  now?: () => number;
316
+ onPolicyDecision?: (sessionId: string, runId: string, event: HarnessPolicyDecisionEvent) => void | Promise<void>;
194
317
  onPrompt?: (sessionId: string, runId: string, prompt: string) => void | Promise<void>;
195
318
  onEvent?: (sessionId: string, runId: string, event: AgentStreamEvent) => void | Promise<void>;
196
319
  onCheckpoint?: (sessionId: string, runId: string, status: string) => void | Promise<void>;
@@ -198,8 +321,11 @@ export interface HarnessClientAdapterOptions {
198
321
  export interface HarnessClientAdapter {
199
322
  negotiate(versions: readonly number[]): HarnessClientNegotiation;
200
323
  dispatch(request: unknown): Promise<HarnessClientResponse>;
324
+ /** Trusted in-process host only, after complete interactive review. Not a transport command. */
325
+ dispatchReviewed?(request: unknown): Promise<HarnessClientResponse>;
201
326
  /** Trusted host shutdown control; requests cancellation without finalizing effects. */
202
327
  cancelActive(): Promise<void>;
203
328
  /** Closes this connection and its session index, not the host-owned harness. */
204
329
  close(): void;
205
330
  }
331
+ export {};
@@ -0,0 +1,91 @@
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,3 +1,4 @@
1
+ import { type HarnessPolicyDecisionEvent } from "../runtime/policy-decisions.js";
1
2
  import { type AgentStreamEvent } from "@zhivex-ai/agents";
2
3
  import type { HarnessConfig } from "../runtime/config.js";
3
4
  export interface HarnessActivityEvent {
@@ -30,11 +31,14 @@ export interface HarnessActivitySnapshot {
30
31
  export interface HarnessActivityPage {
31
32
  schemaVersion: 1;
32
33
  cursorExpired: boolean;
34
+ hasMore?: boolean;
35
+ policyEvidenceIncomplete?: boolean;
33
36
  nextCursor: number;
34
37
  events: HarnessActivityEvent[];
35
38
  snapshot?: HarnessActivitySnapshot;
36
39
  }
37
40
  export interface HarnessActivityStore {
41
+ policyDecision(sessionId: string, runId: string, event: HarnessPolicyDecisionEvent): void;
38
42
  prompt(sessionId: string, runId: string, prompt: string): void;
39
43
  append(sessionId: string, runId: string, event: AgentStreamEvent): void;
40
44
  checkpoint(sessionId: string, runId: string, status: string): void;