@zhivex-ai/harness 1.0.0 → 1.1.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 (236) hide show
  1. package/CHANGELOG.md +109 -1
  2. package/README.md +52 -306
  3. package/SECURITY.md +1 -1
  4. package/SUPPORT.md +7 -3
  5. package/benchmarks/README.md +3 -3
  6. package/contracts/client-protocol-v1.schema.json +341 -0
  7. package/contracts/public-api.json +100 -1
  8. package/contracts/stable-api-signatures.json +14 -14
  9. package/dist/approvals/approval-diff.d.ts +45 -0
  10. package/dist/approvals/approval-history.d.ts +38 -0
  11. package/dist/approvals/approval-preview.d.ts +26 -0
  12. package/dist/cli/arguments.d.ts +103 -0
  13. package/dist/cli/changes.d.ts +2 -0
  14. package/dist/cli/cli-credentials.d.ts +38 -0
  15. package/dist/cli/cli-help.d.ts +3 -0
  16. package/dist/{cli-options.d.ts → cli/cli-options.d.ts} +1 -1
  17. package/dist/{cli-profiles.d.ts → cli/cli-profiles.d.ts} +1 -1
  18. package/dist/cli/configured-harness.d.ts +12 -0
  19. package/dist/cli/console/console-commands.d.ts +6 -0
  20. package/dist/{console-context.d.ts → cli/console/console-context.d.ts} +7 -3
  21. package/dist/cli/console/console-input.d.ts +68 -0
  22. package/dist/cli/console/console-model-catalog.d.ts +25 -0
  23. package/dist/cli/console/console-navigation.d.ts +27 -0
  24. package/dist/cli/console/console-presentation.d.ts +18 -0
  25. package/dist/cli/console/console-welcome.d.ts +13 -0
  26. package/dist/cli/console.d.ts +2 -0
  27. package/dist/cli/doctor.d.ts +50 -0
  28. package/dist/cli/errors.d.ts +7 -0
  29. package/dist/cli/help-text.d.ts +2 -0
  30. package/dist/cli/presentation.d.ts +23 -0
  31. package/dist/cli/resume-metadata.d.ts +12 -0
  32. package/dist/cli/routing.d.ts +6 -0
  33. package/dist/cli/run-commands.d.ts +4 -0
  34. package/dist/cli/run-document.d.ts +91 -0
  35. package/dist/cli/run-management.d.ts +2 -0
  36. package/dist/cli/service-client-cli.d.ts +2 -0
  37. package/dist/cli/session-management.d.ts +8 -0
  38. package/dist/cli/setup.d.ts +16 -0
  39. package/dist/cli/state.d.ts +2 -0
  40. package/dist/cli/terminal/terminal-continuation.d.ts +3 -0
  41. package/dist/{terminal-markdown.d.ts → cli/terminal/terminal-markdown.d.ts} +1 -0
  42. package/dist/{terminal-ui.d.ts → cli/terminal/terminal-ui.d.ts} +7 -0
  43. package/dist/cli/terminal/tool-activity.d.ts +19 -0
  44. package/dist/cli.d.ts +33 -238
  45. package/dist/cli.js +16049 -12066
  46. package/dist/client/adapter.d.ts +4 -0
  47. package/dist/client/index.d.ts +15 -0
  48. package/dist/client/local-service.d.ts +34 -0
  49. package/dist/client/protocol.d.ts +205 -0
  50. package/dist/client/service-events.d.ts +50 -0
  51. package/dist/{context-engineering.d.ts → context/context-engineering.d.ts} +2 -2
  52. package/dist/{execution-environment.d.ts → execution/execution-environment.d.ts} +8 -4
  53. package/dist/hostile-repository-demo.js +2025 -897
  54. package/dist/index.d.ts +48 -41
  55. package/dist/index.js +7541 -5906
  56. package/dist/internal/desktop/persistence.d.ts +14 -0
  57. package/dist/internal/desktop/protocol.d.ts +8 -0
  58. package/dist/internal/desktop/providers.d.ts +6 -0
  59. package/dist/internal/desktop/runtime.d.ts +7 -0
  60. package/dist/{operations.d.ts → persistence/operations.d.ts} +24 -2
  61. package/dist/persistence/persistence-secrets.d.ts +2 -0
  62. package/dist/persistence/recorded-workspace.d.ts +4 -0
  63. package/dist/{sessions.d.ts → persistence/sessions.d.ts} +3 -0
  64. package/dist/persistence/sqlite-access.d.ts +26 -0
  65. package/dist/{sqlite-database.d.ts → persistence/sqlite-database.d.ts} +2 -0
  66. package/dist/{state-backup.d.ts → persistence/state-backup.d.ts} +9 -1
  67. package/dist/{capabilities.d.ts → providers/capabilities.d.ts} +1 -1
  68. package/dist/{routing.d.ts → providers/routing.d.ts} +1 -1
  69. package/dist/{config.d.ts → runtime/config.d.ts} +1 -1
  70. package/dist/{harness.d.ts → runtime/harness.d.ts} +12 -135
  71. package/dist/{orchestration.d.ts → runtime/orchestration.d.ts} +3 -0
  72. package/dist/{runtime-policy.d.ts → runtime/runtime-policy.d.ts} +1 -1
  73. package/dist/runtime/usage-ledger.d.ts +84 -0
  74. package/dist/service-cli.d.ts +2 -0
  75. package/dist/service-cli.js +10899 -0
  76. package/dist/tools/execution.d.ts +47 -0
  77. package/dist/tools/shared.d.ts +67 -0
  78. package/dist/tools/workspace.d.ts +85 -0
  79. package/dist/verify-historical-migrations.js +5786 -5265
  80. package/dist/{workspace.d.ts → workspace/workspace.d.ts} +22 -0
  81. package/dist/zhx.js +16049 -12066
  82. package/docs/CLI.md +151 -30
  83. package/docs/CLIENT_PROTOCOL.md +212 -0
  84. package/docs/CREDENTIALS.md +59 -0
  85. package/docs/DURABLE_OPERATIONS.md +2 -2
  86. package/docs/FIRST_USE.md +82 -0
  87. package/docs/FIRST_USE_EXAMPLE.md +40 -0
  88. package/docs/HOSTILE_REPOSITORY_DEMO.md +1 -1
  89. package/docs/LOCAL_SERVICE.md +142 -0
  90. package/docs/README.md +24 -23
  91. package/docs/THREAT_MODEL.md +1 -1
  92. package/docs/TIME_TO_SAFE_FIX.md +2 -2
  93. package/docs/USAGE.md +181 -0
  94. package/evaluations/daily-cli-cohort.json +33 -0
  95. package/evaluations/representative-assembly-matrix.json +28 -1
  96. package/examples/README.md +26 -0
  97. package/examples/first-use/greeting.test.ts +3 -0
  98. package/examples/first-use/greeting.ts +1 -0
  99. package/examples/first-use/package.json +7 -0
  100. package/package.json +39 -11
  101. package/ROADMAP.md +0 -414
  102. package/benchmarks/baselines/context-navigation-2026-09-09.json +0 -94
  103. package/benchmarks/baselines/efficiency-2026-09-08.json +0 -233
  104. package/benchmarks/baselines/external-final-2026-09-08.json +0 -588
  105. package/benchmarks/baselines/external-intermediate-2026-09-08.json +0 -116
  106. package/benchmarks/baselines/external-matched-openai-2026-09-08.json +0 -1922
  107. package/benchmarks/baselines/external-matched-qwen-2026-09-08.json +0 -1706
  108. package/benchmarks/baselines/external-pilot-2026-09-08.json +0 -439
  109. package/benchmarks/baselines/external-qwen-flash-2026-09-08.json +0 -1570
  110. package/benchmarks/baselines/external-qwen-remediation-2026-09-09.json +0 -1509
  111. package/benchmarks/baselines/external-qwen-sdk-114-progress-2026-09-09.json +0 -2509
  112. package/benchmarks/baselines/external-sdk-upgrade-2026-09-08.json +0 -564
  113. package/benchmarks/baselines/external-verifier-recovery-2026-09-09.json +0 -794
  114. package/benchmarks/baselines/full-harness-review-2026-09-10.json +0 -134
  115. package/benchmarks/baselines/harness-audit-2026-09-09.json +0 -136
  116. package/benchmarks/baselines/harness-remediation-2026-09-09.json +0 -160
  117. package/benchmarks/baselines/oci-remediation-2026-09-10.json +0 -535
  118. package/benchmarks/baselines/rc14-holdout-2026-09-10.json +0 -854
  119. package/benchmarks/baselines/repair-architecture-audit-2026-09-09.json +0 -75
  120. package/benchmarks/baselines/time-to-safe-fix-live-expanded-2026-08-21.json +0 -186
  121. package/benchmarks/baselines/time-to-safe-fix-live-smoke-2026-08-21.json +0 -186
  122. package/dist/console-input.d.ts +0 -28
  123. package/docs/GA_READINESS.md +0 -29
  124. package/docs/GEMINI_1_0_DECISION.md +0 -9
  125. package/docs/LIVE_CERTIFICATION.md +0 -107
  126. package/docs/RC13_SECURITY_REVIEW.md +0 -28
  127. package/docs/RC14_DELEGATED_SECURITY_DECISION.md +0 -80
  128. package/docs/RC14_SECURITY_REVIEW.md +0 -40
  129. package/docs/RELEASE.md +0 -96
  130. package/docs/ROLLBACK.md +0 -9
  131. package/docs/SECURITY_REVIEW_EVIDENCE.md +0 -17
  132. package/docs/ga-readiness.json +0 -366
  133. package/docs/reports/EFFICIENCY_REVIEW.md +0 -156
  134. package/docs/reports/EXTERNAL_COMPARISON.md +0 -434
  135. package/docs/reports/FULL_HARNESS_REVIEW_2026-09-10.md +0 -200
  136. package/docs/reports/GA_BUDGET_REMEDIATION_2026-09-19.md +0 -38
  137. package/docs/reports/GA_REPAIR_RECOVERY_2026-09-19.md +0 -700
  138. package/docs/reports/GA_VALIDATION_2026-09-19.md +0 -111
  139. package/docs/reports/HARNESS_ARCHITECTURE_REVIEW_2026-09-09.md +0 -202
  140. package/docs/reports/HARNESS_AUDIT_2026-09-09.md +0 -306
  141. package/docs/reports/HARNESS_REMEDIATION_2026-09-09.md +0 -74
  142. package/docs/reports/HARNESS_REMEDIATION_2026-09-10.md +0 -90
  143. package/docs/reports/MODEL_COMPARISON_2026-09-09.md +0 -184
  144. package/docs/reports/QWEN_REMEDIATION_COMPARISON_2026-09-09.md +0 -142
  145. package/docs/reports/RC14_VALIDATION_2026-09-10.md +0 -45
  146. package/docs/reports/README.md +0 -26
  147. package/docs/reports/evidence/ga-budget-remediation-2026-09-19.json +0 -133
  148. package/docs/reports/evidence/ga-catalog-ablation-2026-09-19.json +0 -699
  149. package/docs/reports/evidence/ga-catalog-ablation-plan-2026-09-19.json +0 -40
  150. package/docs/reports/evidence/ga-catalog-observed-2026-09-19.json +0 -985
  151. package/docs/reports/evidence/ga-catalog-observed-plan-2026-09-19.json +0 -28
  152. package/docs/reports/evidence/ga-catalog-observed-status-2026-09-19.json +0 -15
  153. package/docs/reports/evidence/ga-complete-local-check-2026-09-19.json +0 -47
  154. package/docs/reports/evidence/ga-completion-reminder-2026-09-19.json +0 -22
  155. package/docs/reports/evidence/ga-fresh-cohort-plan-2026-09-19.json +0 -54
  156. package/docs/reports/evidence/ga-fresh-cohort-preparation-2026-09-19.json +0 -242
  157. package/docs/reports/evidence/ga-fresh-cohort-result-2026-09-19.json +0 -4318
  158. package/docs/reports/evidence/ga-local-validation-followup-2026-09-19.json +0 -66
  159. package/docs/reports/evidence/ga-node-consumers-2026-09-19.json +0 -31
  160. package/docs/reports/evidence/ga-package-content-validation-2026-09-19.json +0 -22
  161. package/docs/reports/evidence/ga-plan-completion-2026-09-19.json +0 -39
  162. package/docs/reports/evidence/ga-plan-reserve-2026-09-19.json +0 -573
  163. package/docs/reports/evidence/ga-plan-reserve-plan-2026-09-19.json +0 -24
  164. package/docs/reports/evidence/ga-plan-transition-2026-09-19.json +0 -19
  165. package/docs/reports/evidence/ga-private-verifier-plan-2026-09-19.json +0 -24
  166. package/docs/reports/evidence/ga-private-verifier-root-cause-2026-09-19.json +0 -41
  167. package/docs/reports/evidence/ga-published-sdk-2026-09-19.json +0 -35
  168. package/docs/reports/evidence/ga-python-checkout-imports-2026-09-19.json +0 -95
  169. package/docs/reports/evidence/ga-python-origin-delivery-2026-09-19.json +0 -211
  170. package/docs/reports/evidence/ga-python-origin-delivery-plan-2026-09-19.json +0 -27
  171. package/docs/reports/evidence/ga-qwen-patched-package-2026-09-19.json +0 -1092
  172. package/docs/reports/evidence/ga-qwen-patched-package-plan-2026-09-19.json +0 -18
  173. package/docs/reports/evidence/ga-qwen-published-2026-09-19.json +0 -571
  174. package/docs/reports/evidence/ga-qwen-published-plan-2026-09-19.json +0 -18
  175. package/docs/reports/evidence/ga-qwen-tool-choice-2026-09-19.json +0 -85
  176. package/docs/reports/evidence/ga-qwen-tool-choice-patched-2026-09-19.json +0 -85
  177. package/docs/reports/evidence/ga-recovery-development-2026-09-19.json +0 -1066
  178. package/docs/reports/evidence/ga-recovery-graded-development-2026-09-19.json +0 -1313
  179. package/docs/reports/evidence/ga-recovery-graded-v2-2026-09-19.json +0 -1151
  180. package/docs/reports/evidence/ga-recovery-v3-2026-09-19.json +0 -3943
  181. package/docs/reports/evidence/ga-recovery-v4-2026-09-19.json +0 -1055
  182. package/docs/reports/evidence/ga-recovery-v5-2026-09-19.json +0 -1245
  183. package/docs/reports/evidence/ga-recovery-v6-2026-09-19.json +0 -699
  184. package/docs/reports/evidence/ga-recovery-v7-2026-09-19.json +0 -854
  185. package/docs/reports/evidence/ga-recovery-v8-2026-09-19.json +0 -596
  186. package/docs/reports/evidence/ga-required-delivery-2026-09-19.json +0 -25
  187. package/docs/reports/evidence/ga-required-delivery-live-2026-09-19.json +0 -1337
  188. package/docs/reports/evidence/ga-required-delivery-live-plan-2026-09-19.json +0 -25
  189. package/docs/reports/evidence/ga-retained-candidate-grading-2026-09-19.json +0 -30
  190. package/docs/reports/evidence/ga-tool-selection-live-2026-09-19.json +0 -559
  191. package/docs/reports/evidence/ga-tool-selection-live-plan-2026-09-19.json +0 -28
  192. package/docs/reports/evidence/ga-tool-selection-recovery-2026-09-19.json +0 -27
  193. package/docs/reports/evidence/ga-validation-2026-09-19.json +0 -236
  194. package/docs/reports/evidence/ga-verifier-discovery-live-2026-09-19.json +0 -1369
  195. package/docs/reports/evidence/ga-verifier-discovery-plan-2026-09-19.json +0 -29
  196. package/docs/reports/evidence/ga-verifier-failure-identification-2026-09-19.json +0 -30
  197. package/docs/reports/evidence/ga-verifier-feedback-2026-09-19.json +0 -65
  198. package/docs/reports/evidence/ga-verifier-hints-live-2026-09-19.json +0 -1297
  199. package/docs/reports/evidence/ga-verifier-hints-plan-2026-09-19.json +0 -27
  200. package/docs/reports/evidence/ga-work-boundary-context-analysis-2026-09-19.json +0 -113
  201. package/docs/reports/evidence/ga-work-boundary-live-2026-09-19.json +0 -301
  202. package/docs/reports/evidence/ga-work-boundary-live-plan-2026-09-19.json +0 -84
  203. package/docs/reports/evidence/ga-work-budget-planning-2026-09-19.json +0 -32
  204. package/docs/reports/evidence/ga-working-context-2026-09-19.json +0 -22
  205. package/docs/reports/evidence/rc14-delegated-security-review-2026-09-20.json +0 -81
  206. package/docs/reports/evidence/rc14-ga-gate-2026-09-20.json +0 -18
  207. package/docs/reports/evidence/rc14-representative-2026-09-20.json +0 -509
  208. package/docs/reports/evidence/rc14-security-regressions-2026-09-20.json +0 -64
  209. package/docs/reports/evidence/security-current-2026-09-19.json +0 -91
  210. package/docs/reports/evidence/security-remediation-2026-09-19.json +0 -97
  211. /package/dist/{cli-stream.d.ts → cli/cli-stream.d.ts} +0 -0
  212. /package/dist/{json-contracts.d.ts → client/json-contracts.d.ts} +0 -0
  213. /package/dist/{compaction.d.ts → context/compaction.d.ts} +0 -0
  214. /package/dist/{context-metrics.d.ts → context/context-metrics.d.ts} +0 -0
  215. /package/dist/{task-memory.d.ts → context/task-memory.d.ts} +0 -0
  216. /package/dist/{package-manager.d.ts → execution/package-manager.d.ts} +0 -0
  217. /package/dist/{process-runtime.d.ts → execution/process-runtime.d.ts} +0 -0
  218. /package/dist/{mcp.d.ts → integrations/mcp.d.ts} +0 -0
  219. /package/dist/{state-directory.d.ts → persistence/state-directory.d.ts} +0 -0
  220. /package/dist/{providers.d.ts → providers/providers.d.ts} +0 -0
  221. /package/dist/{errors.d.ts → runtime/errors.d.ts} +0 -0
  222. /package/dist/{model-budget.d.ts → runtime/model-budget.d.ts} +0 -0
  223. /package/dist/{repair-controller.d.ts → runtime/repair-controller.d.ts} +0 -0
  224. /package/dist/{repair-progress.d.ts → runtime/repair-progress.d.ts} +0 -0
  225. /package/dist/{repair-verifier.d.ts → runtime/repair-verifier.d.ts} +0 -0
  226. /package/dist/{run-interruption.d.ts → runtime/run-interruption.d.ts} +0 -0
  227. /package/dist/{runtime-checkpoints.d.ts → runtime/runtime-checkpoints.d.ts} +0 -0
  228. /package/dist/{runtime-diagnostics.d.ts → runtime/runtime-diagnostics.d.ts} +0 -0
  229. /package/dist/{time-to-safe-fix.d.ts → runtime/time-to-safe-fix.d.ts} +0 -0
  230. /package/dist/{tool-registry.d.ts → tools/tool-registry.d.ts} +0 -0
  231. /package/dist/{bounded-reads.d.ts → workspace/bounded-reads.d.ts} +0 -0
  232. /package/dist/{change-envelope.d.ts → workspace/change-envelope.d.ts} +0 -0
  233. /package/dist/{edit-contracts.d.ts → workspace/edit-contracts.d.ts} +0 -0
  234. /package/dist/{file-security.d.ts → workspace/file-security.d.ts} +0 -0
  235. /package/dist/{replacement-edits.d.ts → workspace/replacement-edits.d.ts} +0 -0
  236. /package/dist/{workspace-mutation-lock.d.ts → workspace/workspace-mutation-lock.d.ts} +0 -0
@@ -0,0 +1,4 @@
1
+ import { type ZhivexHarness } from "../runtime/harness.js";
2
+ import { type HarnessClientAdapter, type HarnessClientAdapterOptions } from "./protocol.js";
3
+ /** One trusted host, one workspace/scope, one connection epoch; no multi-writer guarantee. */
4
+ export declare const createHarnessClientAdapter: (harness: ZhivexHarness, options?: HarnessClientAdapterOptions) => Promise<HarnessClientAdapter>;
@@ -0,0 +1,15 @@
1
+ /** Compatibility facade. New internal consumers use the focused modules. */
2
+ export { HARNESS_CLIENT_PROTOCOL_VERSION } from "./protocol.js";
3
+ export { harnessClientCommandSchema } from "./protocol.js";
4
+ export { harnessClientRequestSchema } from "./protocol.js";
5
+ export type { HarnessClientCommand } from "./protocol.js";
6
+ export type { HarnessClientRequest } from "./protocol.js";
7
+ export type { HarnessClientErrorCode } from "./protocol.js";
8
+ export type { HarnessClientSession } from "./protocol.js";
9
+ export type { HarnessClientRun } from "./protocol.js";
10
+ export type { HarnessClientData } from "./protocol.js";
11
+ export type { HarnessClientResponse } from "./protocol.js";
12
+ export type { HarnessClientNegotiation } from "./protocol.js";
13
+ export type { HarnessClientAdapterOptions } from "./protocol.js";
14
+ export type { HarnessClientAdapter } from "./protocol.js";
15
+ export { createHarnessClientAdapter } from "./adapter.js";
@@ -0,0 +1,34 @@
1
+ import { z } from "zod";
2
+ import { type HarnessClientResponse, type HarnessClientNegotiation } from "./protocol.js";
3
+ import { type HarnessActivityPage } from "./service-events.js";
4
+ import type { ZhivexHarness } from "../runtime/harness.js";
5
+ export interface HarnessLocalService {
6
+ readonly socketPath: string;
7
+ readonly credentialsPath: string;
8
+ /** Atomically blocks new mutations, preserving reads and explicit cancellation. Returns whether mutations are still active. */
9
+ pauseAdmission(): boolean;
10
+ resumeAdmission(): void;
11
+ /** Requests cancellation of this host's active invocation; never force-finalizes it. */
12
+ cancelActive(): Promise<void>;
13
+ /** Stops admission, drains accepted commands, closes adapter and host runtime. */
14
+ close(): Promise<void>;
15
+ }
16
+ export interface HarnessLocalServiceOptions {
17
+ directory: string;
18
+ approvalNow?: () => number;
19
+ sensitiveValues?: readonly string[];
20
+ maxEvents?: number;
21
+ retentionMs?: number;
22
+ }
23
+ export declare const harnessLocalCredentialsSchema: z.ZodObject<{
24
+ schemaVersion: z.ZodLiteral<1>;
25
+ socketPath: z.ZodString;
26
+ token: z.ZodString;
27
+ }, z.core.$strict>;
28
+ export type HarnessLocalCredentials = z.infer<typeof harnessLocalCredentialsSchema>;
29
+ export declare const startHarnessLocalService: (harness: ZhivexHarness, options: HarnessLocalServiceOptions) => Promise<HarnessLocalService>;
30
+ /** Read only an owner-private regular credential file; never follow a symlink. */
31
+ export declare const readHarnessLocalCredentials: (filename: string) => Promise<HarnessLocalCredentials>;
32
+ export declare const requestHarnessLocalService: <E extends "hello" | "command" | "events">(credentials: HarnessLocalCredentials, endpoint: E, payload: unknown) => Promise<E extends "hello" ? HarnessClientNegotiation : E extends "command" ? HarnessClientResponse : HarnessActivityPage>;
33
+ /** Explicit dead-owner recovery: preserves runtime DBs and never steals a live lease. */
34
+ export declare const recoverHarnessLocalService: (harness: ZhivexHarness, directory: string) => Promise<void>;
@@ -0,0 +1,205 @@
1
+ import { type ApprovalDecisionView } from "../approvals/approval-history.js";
2
+ import { type ApprovalFilePreview } from "../approvals/approval-preview.js";
3
+ import { z } from "zod";
4
+ import type { AgentStreamEvent } from "@zhivex-ai/agents";
5
+ import { type CliSession } from "../persistence/sessions.js";
6
+ export declare const HARNESS_CLIENT_PROTOCOL_VERSION: 1;
7
+ /** Strict command union; configuration, credentials and filesystem paths are host-owned. */
8
+ export declare const harnessClientCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
9
+ projectId: z.ZodString;
10
+ method: z.ZodLiteral<"project.get">;
11
+ }, z.core.$strict>, z.ZodObject<{
12
+ projectId: z.ZodString;
13
+ method: z.ZodLiteral<"session.list">;
14
+ search: z.ZodOptional<z.ZodString>;
15
+ }, z.core.$strict>, z.ZodObject<{
16
+ projectId: z.ZodString;
17
+ idempotencyKey: z.ZodString;
18
+ method: z.ZodLiteral<"session.create">;
19
+ title: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strict>, z.ZodObject<{
21
+ projectId: z.ZodString;
22
+ sessionId: z.ZodString;
23
+ method: z.ZodLiteral<"session.get">;
24
+ }, z.core.$strict>, z.ZodObject<{
25
+ projectId: z.ZodString;
26
+ sessionId: z.ZodString;
27
+ idempotencyKey: z.ZodString;
28
+ method: z.ZodLiteral<"session.rename">;
29
+ expectedRevision: z.ZodNumber;
30
+ title: z.ZodString;
31
+ }, z.core.$strict>, z.ZodObject<{
32
+ projectId: z.ZodString;
33
+ sessionId: z.ZodString;
34
+ idempotencyKey: z.ZodString;
35
+ method: z.ZodLiteral<"run.start">;
36
+ expectedRevision: z.ZodNumber;
37
+ prompt: z.ZodString;
38
+ }, z.core.$strict>, z.ZodObject<{
39
+ projectId: z.ZodString;
40
+ sessionId: z.ZodString;
41
+ runId: z.ZodString;
42
+ method: z.ZodLiteral<"run.get">;
43
+ includeReview: z.ZodOptional<z.ZodBoolean>;
44
+ includeDiff: z.ZodOptional<z.ZodBoolean>;
45
+ decisionOffset: z.ZodOptional<z.ZodNumber>;
46
+ }, z.core.$strict>, z.ZodObject<{
47
+ projectId: z.ZodString;
48
+ sessionId: z.ZodString;
49
+ runId: z.ZodString;
50
+ idempotencyKey: z.ZodString;
51
+ method: z.ZodLiteral<"approval.resolve">;
52
+ expectedRevision: z.ZodNumber;
53
+ decisions: z.ZodArray<z.ZodObject<{
54
+ approvalId: z.ZodString;
55
+ digest: z.ZodString;
56
+ approve: z.ZodBoolean;
57
+ }, z.core.$strict>>;
58
+ }, z.core.$strict>, z.ZodObject<{
59
+ projectId: z.ZodString;
60
+ sessionId: z.ZodString;
61
+ runId: z.ZodString;
62
+ idempotencyKey: z.ZodString;
63
+ method: z.ZodLiteral<"run.cancel">;
64
+ expectedRevision: z.ZodNumber;
65
+ }, z.core.$strict>], "method">;
66
+ export declare const harnessClientRequestSchema: z.ZodObject<{
67
+ protocolVersion: z.ZodLiteral<1>;
68
+ requestId: z.ZodString;
69
+ connectionId: z.ZodString;
70
+ command: z.ZodDiscriminatedUnion<[z.ZodObject<{
71
+ projectId: z.ZodString;
72
+ method: z.ZodLiteral<"project.get">;
73
+ }, z.core.$strict>, z.ZodObject<{
74
+ projectId: z.ZodString;
75
+ method: z.ZodLiteral<"session.list">;
76
+ search: z.ZodOptional<z.ZodString>;
77
+ }, z.core.$strict>, z.ZodObject<{
78
+ projectId: z.ZodString;
79
+ idempotencyKey: z.ZodString;
80
+ method: z.ZodLiteral<"session.create">;
81
+ title: z.ZodOptional<z.ZodString>;
82
+ }, z.core.$strict>, z.ZodObject<{
83
+ projectId: z.ZodString;
84
+ sessionId: z.ZodString;
85
+ method: z.ZodLiteral<"session.get">;
86
+ }, z.core.$strict>, z.ZodObject<{
87
+ projectId: z.ZodString;
88
+ sessionId: z.ZodString;
89
+ idempotencyKey: z.ZodString;
90
+ method: z.ZodLiteral<"session.rename">;
91
+ expectedRevision: z.ZodNumber;
92
+ title: z.ZodString;
93
+ }, z.core.$strict>, z.ZodObject<{
94
+ projectId: z.ZodString;
95
+ sessionId: z.ZodString;
96
+ idempotencyKey: z.ZodString;
97
+ method: z.ZodLiteral<"run.start">;
98
+ expectedRevision: z.ZodNumber;
99
+ prompt: z.ZodString;
100
+ }, z.core.$strict>, z.ZodObject<{
101
+ projectId: z.ZodString;
102
+ sessionId: z.ZodString;
103
+ runId: z.ZodString;
104
+ method: z.ZodLiteral<"run.get">;
105
+ includeReview: z.ZodOptional<z.ZodBoolean>;
106
+ includeDiff: z.ZodOptional<z.ZodBoolean>;
107
+ decisionOffset: z.ZodOptional<z.ZodNumber>;
108
+ }, z.core.$strict>, z.ZodObject<{
109
+ projectId: z.ZodString;
110
+ sessionId: z.ZodString;
111
+ runId: z.ZodString;
112
+ idempotencyKey: z.ZodString;
113
+ method: z.ZodLiteral<"approval.resolve">;
114
+ expectedRevision: z.ZodNumber;
115
+ decisions: z.ZodArray<z.ZodObject<{
116
+ approvalId: z.ZodString;
117
+ digest: z.ZodString;
118
+ approve: z.ZodBoolean;
119
+ }, z.core.$strict>>;
120
+ }, z.core.$strict>, z.ZodObject<{
121
+ projectId: z.ZodString;
122
+ sessionId: z.ZodString;
123
+ runId: z.ZodString;
124
+ idempotencyKey: z.ZodString;
125
+ method: z.ZodLiteral<"run.cancel">;
126
+ expectedRevision: z.ZodNumber;
127
+ }, z.core.$strict>], "method">;
128
+ }, z.core.$strict>;
129
+ export type HarnessClientCommand = z.infer<typeof harnessClientCommandSchema>;
130
+ 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";
132
+ export interface HarnessClientSession extends CliSession {
133
+ }
134
+ export interface HarnessClientRun {
135
+ runId: string;
136
+ revision: number;
137
+ status: string;
138
+ output: string;
139
+ cliResult?: unknown;
140
+ decisions?: ApprovalDecisionView[];
141
+ decisionTotal?: number;
142
+ decisionNextOffset?: number;
143
+ approvals: {
144
+ approvalId: string;
145
+ digest: string;
146
+ provider: string;
147
+ kind: string;
148
+ action: unknown;
149
+ expiresAt: number;
150
+ filePreview?: ApprovalFilePreview;
151
+ }[];
152
+ }
153
+ export type HarnessClientData = {
154
+ kind: "project";
155
+ projectId: string;
156
+ } | {
157
+ kind: "session";
158
+ session: HarnessClientSession;
159
+ } | {
160
+ kind: "sessions";
161
+ sessions: HarnessClientSession[];
162
+ } | {
163
+ kind: "run";
164
+ session: HarnessClientSession;
165
+ run: HarnessClientRun;
166
+ };
167
+ export type HarnessClientResponse = {
168
+ protocolVersion: 1;
169
+ requestId: string | null;
170
+ } & ({
171
+ ok: true;
172
+ data: HarnessClientData;
173
+ } | {
174
+ ok: false;
175
+ error: {
176
+ code: HarnessClientErrorCode;
177
+ };
178
+ });
179
+ export type HarnessClientNegotiation = {
180
+ ok: true;
181
+ protocolVersion: 1;
182
+ connectionId: string;
183
+ projectId: string;
184
+ capabilities: readonly string[];
185
+ } | {
186
+ ok: false;
187
+ error: {
188
+ code: "VERSION_UNSUPPORTED" | "CONNECTION_EXPIRED";
189
+ };
190
+ };
191
+ export interface HarnessClientAdapterOptions {
192
+ approvalMaxAgeMs?: number;
193
+ now?: () => number;
194
+ onPrompt?: (sessionId: string, runId: string, prompt: string) => void | Promise<void>;
195
+ onEvent?: (sessionId: string, runId: string, event: AgentStreamEvent) => void | Promise<void>;
196
+ onCheckpoint?: (sessionId: string, runId: string, status: string) => void | Promise<void>;
197
+ }
198
+ export interface HarnessClientAdapter {
199
+ negotiate(versions: readonly number[]): HarnessClientNegotiation;
200
+ dispatch(request: unknown): Promise<HarnessClientResponse>;
201
+ /** Trusted host shutdown control; requests cancellation without finalizing effects. */
202
+ cancelActive(): Promise<void>;
203
+ /** Closes this connection and its session index, not the host-owned harness. */
204
+ close(): void;
205
+ }
@@ -0,0 +1,50 @@
1
+ import { type AgentStreamEvent } from "@zhivex-ai/agents";
2
+ import type { HarnessConfig } from "../runtime/config.js";
3
+ export interface HarnessActivityEvent {
4
+ schemaVersion: 1;
5
+ eventId: string;
6
+ sequence: number;
7
+ sessionId: string;
8
+ runId: string;
9
+ at: number;
10
+ activity: Record<string, unknown>;
11
+ }
12
+ export interface HarnessActivityRun {
13
+ text: string;
14
+ status: string;
15
+ truncated: boolean;
16
+ prompt?: string;
17
+ tools?: Record<string, {
18
+ name: string;
19
+ status: string;
20
+ exitCode?: number;
21
+ timedOut?: boolean;
22
+ }>;
23
+ }
24
+ export interface HarnessActivitySnapshot {
25
+ schemaVersion: 1;
26
+ sessionId: string;
27
+ sequence: number;
28
+ runs: Record<string, HarnessActivityRun>;
29
+ }
30
+ export interface HarnessActivityPage {
31
+ schemaVersion: 1;
32
+ cursorExpired: boolean;
33
+ nextCursor: number;
34
+ events: HarnessActivityEvent[];
35
+ snapshot?: HarnessActivitySnapshot;
36
+ }
37
+ export interface HarnessActivityStore {
38
+ prompt(sessionId: string, runId: string, prompt: string): void;
39
+ append(sessionId: string, runId: string, event: AgentStreamEvent): void;
40
+ checkpoint(sessionId: string, runId: string, status: string): void;
41
+ replay(sessionId: string, after?: number): HarnessActivityPage;
42
+ close(): void;
43
+ }
44
+ export interface HarnessActivityOptions {
45
+ maxEvents?: number;
46
+ retentionMs?: number;
47
+ sensitiveValues?: readonly string[];
48
+ now?: () => number;
49
+ }
50
+ export declare const openHarnessActivityStore: (config: HarnessConfig, options?: HarnessActivityOptions) => Promise<HarnessActivityStore>;
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
- import { type FileDigest } from "./edit-contracts.js";
3
- import type { Workspace } from "./workspace.js";
2
+ import { type FileDigest } from "../workspace/edit-contracts.js";
3
+ import type { Workspace } from "../workspace/workspace.js";
4
4
  export declare const HARNESS_CONTEXT_CONFIG_SCHEMA_VERSION: 1;
5
5
  export declare const HARNESS_CONTEXT_BUNDLE_SCHEMA_VERSION: 1;
6
6
  export declare const DEFAULT_HARNESS_CONTEXT_MANIFEST: ".zhivex/harness.json";
@@ -1,7 +1,7 @@
1
1
  import { type AgentExecutionEnvironment, type AgentExecutionEnvironmentAcquireRequest, type AgentExecutionEnvironmentBinding, type AgentExecutionEnvironmentSession, type ToolExecutionContext } from "@zhivex-ai/agents";
2
- import { HARNESS_EXECUTION_POLICY_VERSION, type HarnessConfig, type HarnessExecutionConfig, type HarnessOciRuntime } from "./config.js";
3
- import { type FileDigest, type MutationAuditEntry } from "./edit-contracts.js";
4
- import { Workspace, type CommandResult } from "./workspace.js";
2
+ import { HARNESS_EXECUTION_POLICY_VERSION, type HarnessConfig, type HarnessExecutionConfig, type HarnessOciRuntime } from "../runtime/config.js";
3
+ import { type FileDigest, type MutationAuditEntry } from "../workspace/edit-contracts.js";
4
+ import { Workspace, type CommandResult } from "../workspace/workspace.js";
5
5
  export declare const HARNESS_EXECUTION_ARTIFACT_SCHEMA_VERSION: 1;
6
6
  export declare const HARNESS_OCI_LABEL = "com.zhivex.harness.execution";
7
7
  export declare const HARNESS_OCI_LABEL_VALUE = "v1";
@@ -168,6 +168,10 @@ export interface HarnessExecutionSession extends AgentExecutionEnvironmentSessio
168
168
  export declare const harnessExecutionSession: (context: ToolExecutionContext | undefined) => HarnessExecutionSession | undefined;
169
169
  export interface HarnessOciExecutionEnvironment extends AgentExecutionEnvironment {
170
170
  acquire(request: AgentExecutionEnvironmentAcquireRequest): Promise<HarnessExecutionSession>;
171
+ previewPatch(request: Pick<AgentExecutionEnvironmentAcquireRequest, "runId" | "scope">, expectedPatchId: FileDigest): Promise<{
172
+ patchId: FileDigest;
173
+ entries: EnvironmentPatchEntry[];
174
+ }>;
171
175
  readonly image: OciImageInspection;
172
176
  readonly runtime: HarnessOciRuntimeAdapter;
173
177
  }
@@ -196,7 +200,7 @@ export declare const executionFingerprintInput: (execution: HarnessConfig["execu
196
200
  policyVersion: typeof HARNESS_EXECUTION_POLICY_VERSION;
197
201
  runtime: HarnessOciRuntime;
198
202
  allowedCommands: readonly string[];
199
- shellMode: import("./config.js").HarnessOciShellMode;
203
+ shellMode: import("../index.js").HarnessOciShellMode;
200
204
  maxProcessRuntimeMs: number;
201
205
  maxProcessOutputBytes: number;
202
206
  maxMemoryMb: number;