@zhivex-ai/harness 1.1.1 → 1.2.0-rc.13

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 (119) hide show
  1. package/CHANGELOG.md +160 -0
  2. package/README.md +14 -7
  3. package/SECURITY.md +1 -1
  4. package/SUPPORT.md +3 -3
  5. package/benchmarks/README.md +17 -0
  6. package/contracts/public-api.json +95 -5
  7. package/contracts/stable-api-signatures.json +38 -38
  8. package/dist/acp-cli.d.ts +2 -0
  9. package/dist/acp-cli.js +15938 -0
  10. package/dist/cli/arguments.d.ts +7 -1
  11. package/dist/cli/cli-credentials.d.ts +6 -1
  12. package/dist/cli/cli-options.d.ts +1 -1
  13. package/dist/cli/cli-profiles.d.ts +15 -0
  14. package/dist/cli/cli-stream.d.ts +3 -3
  15. package/dist/cli/console/console-budget.d.ts +9 -0
  16. package/dist/cli/console/console-commands.d.ts +3 -3
  17. package/dist/cli/console/console-compaction.d.ts +18 -0
  18. package/dist/cli/console/console-input.d.ts +22 -3
  19. package/dist/cli/console/console-navigation.d.ts +3 -0
  20. package/dist/cli/console/console-presentation.d.ts +9 -2
  21. package/dist/cli/console/console-progress.d.ts +6 -0
  22. package/dist/cli/console/console-reasoning.d.ts +3 -0
  23. package/dist/cli/doctor.d.ts +2 -2
  24. package/dist/cli/presentation.d.ts +8 -1
  25. package/dist/cli/qwen-connection.d.ts +23 -0
  26. package/dist/cli/run-document.d.ts +4 -4
  27. package/dist/cli/terminal/activity-history.d.ts +15 -0
  28. package/dist/cli/terminal/session-grants.d.ts +4 -0
  29. package/dist/cli/terminal/terminal-markdown.d.ts +7 -4
  30. package/dist/cli/terminal/terminal-table.d.ts +6 -0
  31. package/dist/cli/terminal/terminal-ui.d.ts +3 -0
  32. package/dist/cli/terminal/tool-activity.d.ts +21 -10
  33. package/dist/cli/tool-execution.d.ts +1 -0
  34. package/dist/cli-3jmy4h5h.js +5798 -0
  35. package/dist/cli-entry-1bx83sw4.js +4 -0
  36. package/dist/cli-entry-427869g9.js +2009 -0
  37. package/dist/cli-entry-64pdp3k5.js +17 -0
  38. package/dist/cli-entry-b1mfvmxe.js +376 -0
  39. package/dist/cli-entry-c2f58zj2.js +13602 -0
  40. package/dist/cli-entry.d.ts +2 -0
  41. package/dist/cli.d.ts +1 -0
  42. package/dist/cli.js +15 -19168
  43. package/dist/client/acp-stdio.d.ts +9 -0
  44. package/dist/client/acp.d.ts +18 -0
  45. package/dist/client/index.d.ts +2 -0
  46. package/dist/client/json-contracts.d.ts +22 -8
  47. package/dist/config-1k9t4jhh.js +59 -0
  48. package/dist/context/adaptive-compaction.d.ts +2 -0
  49. package/dist/context/compaction.d.ts +3 -1
  50. package/dist/context/qwen-reasoning.d.ts +5 -0
  51. package/dist/context/scoped-context.d.ts +61 -0
  52. package/dist/context/semantic-compaction.d.ts +21 -0
  53. package/dist/context/task-memory.d.ts +13 -8
  54. package/dist/execution/execution-environment.d.ts +5 -0
  55. package/dist/execution/oci-observability.d.ts +2 -0
  56. package/dist/execution/patch-diagnostics.d.ts +6 -0
  57. package/dist/hostile-repository-demo.js +4614 -1930
  58. package/dist/index.d.ts +13 -1
  59. package/dist/index.js +16435 -12486
  60. package/dist/integrations/mcp.d.ts +23 -3
  61. package/dist/models/catalog.d.ts +76 -0
  62. package/dist/models/compaction-recommendations.d.ts +28 -0
  63. package/dist/models/sdk-catalog-adapter.d.ts +7 -0
  64. package/dist/persistence/operations.d.ts +10 -6
  65. package/dist/persistence/state-backup-stream.d.ts +4 -0
  66. package/dist/persistence/state-backup.d.ts +52 -0
  67. package/dist/persistence/state-gitignore.d.ts +2 -0
  68. package/dist/persistence/workspace-checkpoints.d.ts +149 -0
  69. package/dist/providers/meta-continuation.d.ts +1 -1
  70. package/dist/providers/meta-errors.d.ts +2 -0
  71. package/dist/providers/meta-replay.d.ts +2 -0
  72. package/dist/providers/qwen-context.d.ts +2 -0
  73. package/dist/providers/qwen-hosted-policy.d.ts +5 -0
  74. package/dist/providers/reasoning.d.ts +18 -0
  75. package/dist/runtime/config.d.ts +12 -3
  76. package/dist/runtime/context-runtime.d.ts +12 -0
  77. package/dist/runtime/error-diagnostics.d.ts +641 -0
  78. package/dist/runtime/harness.d.ts +13 -4
  79. package/dist/runtime/model-edit-references.d.ts +8 -0
  80. package/dist/runtime/oci-delivery.d.ts +17 -0
  81. package/dist/runtime/progress-monitor.d.ts +33 -0
  82. package/dist/runtime/provider-diagnostics.d.ts +35 -0
  83. package/dist/runtime/runtime-checkpoints.d.ts +3 -0
  84. package/dist/runtime/runtime-diagnostics.d.ts +5 -5
  85. package/dist/runtime/runtime-policy.d.ts +14 -6
  86. package/dist/runtime/time-to-safe-fix.d.ts +308 -1
  87. package/dist/runtime/tool-execution.d.ts +11 -0
  88. package/dist/runtime/tool-policy.d.ts +55 -0
  89. package/dist/runtime/tool-scheduling.d.ts +5 -0
  90. package/dist/runtime/usage-ledger.d.ts +1 -0
  91. package/dist/service-cli.js +9422 -6622
  92. package/dist/service-client-cli-yx56n0hc.js +1086 -0
  93. package/dist/tools/dependency-read.d.ts +63 -0
  94. package/dist/tools/execution.d.ts +8 -8
  95. package/dist/tools/workspace.d.ts +31 -15
  96. package/dist/verify-historical-migrations.js +5272 -2437
  97. package/dist/workspace/file-security.d.ts +6 -0
  98. package/dist/zhx.js +15 -19168
  99. package/docs/ACP.md +55 -0
  100. package/docs/CLI.md +292 -29
  101. package/docs/CONTEXT_ENGINEERING.md +184 -20
  102. package/docs/CREDENTIALS.md +38 -6
  103. package/docs/DURABLE_OPERATIONS.md +10 -0
  104. package/docs/EXTENSIBILITY.md +101 -4
  105. package/docs/FIRST_USE.md +7 -5
  106. package/docs/MODEL_CATALOG.md +52 -1
  107. package/docs/README.md +1 -0
  108. package/docs/REPOSITORY_EDITING.md +42 -0
  109. package/docs/STABILITY.md +2 -0
  110. package/docs/SUPPORT_MATRIX_1_1.md +17 -0
  111. package/docs/USAGE.md +9 -0
  112. package/docs/WORKSPACE_CHECKPOINTS.md +27 -0
  113. package/docs/images/cli-conversation.png +0 -0
  114. package/docs/support-matrix-1.1.json +29 -0
  115. package/evaluations/golden-expectations.json +5 -0
  116. package/evaluations/representative-assembly-matrix.json +145 -1
  117. package/evaluations/representative-repositories-v2.jsonl +7 -0
  118. package/examples/README.md +2 -2
  119. package/package.json +19 -13
@@ -85,23 +85,42 @@ identifies the last returned line so ordinary reads can continue from the next l
85
85
  not treat that clipped text as the entire source line. Search an exact file to locate
86
86
  relevant short excerpts instead of repeatedly reading a large file.
87
87
 
88
- Conversation compaction uses `bounded-evidence-v5`. It retains a redacted excerpt of
89
- the initial user objective, recent conversation excerpts, bounded local-tool path
88
+ Conversation compaction uses `bounded-evidence-v8`. It retains a redacted excerpt of
89
+ the latest user direction as `objective`, the earlier task as `historicalObjective`
90
+ when it changes, chronological steering, recent conversation excerpts, bounded local-tool path
90
91
  and digest evidence, and a separate short history of check exit codes, timeouts,
91
92
  and tool failures. These are recollections, not approvals or verification receipts.
92
93
  The latest four check/error records are kept independently of ordinary file-read
93
- noise. The latest three subsequent user excerpts are retained separately from
94
+ noise. Up to ten distinct subsequent user excerpts are retained separately from
94
95
  assistant chatter, redacted and bounded to 512 characters each. They share the
95
96
  existing total summary budget and remain untrusted context. Interactive summaries
96
- can carry this structure across subsequent compactions.
97
+ can carry this structure across subsequent compactions. Older summaries migrate
98
+ their most recent steering into the current objective. A follow-up question does
99
+ not erase the earlier task: it remains historical context and steering, and
100
+ assistant narration cannot supersede user direction.
97
101
 
98
102
  The latest successful `repair_plan` is retained separately from assistant chatter,
99
103
  with bounded hypothesis, expected behavior, next check, and safe relative paths.
100
104
  It remains model-authored recollection, never authorization or a verification receipt.
101
- Older v1-v4 summaries remain readable. Original requests remain recoverable with
105
+ Older v1-v6 summaries remain readable. Original requests remain recoverable with
102
106
  `read_task`; a summary is not a replacement for full acceptance criteria.
103
107
 
104
- Automatic compaction uses `adaptive-tokens-v1`. The configured recent-message count
108
+ Context is useful working memory, not a proof system. Conceptual discussion,
109
+ decisions, hypotheses and unresolved questions remain available without a
110
+ `repair_plan` or verification receipt. Up to three redacted local diagnostic
111
+ excerpts (640 characters each) are retained as `unverified` observations, separate
112
+ from typed check records. These may include command stdout/stderr, SDK tool-error
113
+ messages and terminal-verifier diagnostics. They share the summary's total bound;
114
+ file bodies and external-tool payloads are not copied into these observations.
115
+ Repeated identical excerpts do not evict distinct decisions. A summary neither
116
+ authorizes an effect nor proves that a check passed.
117
+
118
+ Repeated hybrid compaction preserves the deterministic JSON and the model's
119
+ recollection separately. Recollection stays untrusted conversational material,
120
+ including when another model summarizes it. No additional provider or paid call
121
+ is selected automatically; `/compaction provider:model` selects that route.
122
+
123
+ Automatic compaction uses `adaptive-tokens-v2`. The configured recent-message count
105
124
  is an upper target: the runtime selects a smaller complete tail when its estimated
106
125
  size exceeds the token target. Calls/results and provider approval groups remain
107
126
  correlated; pending approvals and durable compaction records remain SDK-owned.
@@ -110,11 +129,28 @@ the summary. A protected newest group that cannot fit still fails closed.
110
129
 
111
130
  Compaction and transport budgets share the same character-based estimator
112
131
  (characters / 3 plus envelope allowance), not a provider tokenizer. Tool schemas
113
- are measured separately from the configured message ceiling. Repair runs reduce
114
- the trigger as remaining cumulative input allowance shrinks, aiming to leave room
115
- for three requests; this does not increase budget ceilings. Unlimited-token mode
132
+ are measured separately from the configured message ceiling. Runs reduce the
133
+ trigger as remaining cumulative input allowance shrinks, aiming to leave room
134
+ for three requests. That heuristic reserves enough space for the newest indivisible
135
+ call/result group, system instructions and summary rather than rejecting a prompt
136
+ that still fits the actual allowance. The configured context threshold and transport
137
+ token ceilings remain authoritative. Unlimited-token mode
116
138
  keeps the configured context thresholds. Explicit per-run compaction overrides
117
139
  and `compaction: false` remain honored. No model context-window size is inferred.
140
+
141
+ For single-agent runs, the remaining balance updates after each provider response,
142
+ including within the same invocation. Before sending another request, the harness
143
+ checks estimated input against the remaining input and total budgets. Estimates
144
+ are heuristic; reported usage remains authoritative and can still exceed a limit.
145
+ Failed checkpoints include that reported usage even when the response's tools
146
+ were rejected.
147
+
148
+ In ordinary runs, requests approaching the last 30% of the token budget
149
+ switch to a final answer with no new tools. The answer must distinguish collected
150
+ evidence from unfinished work. This is a best-effort closure reserve, not a
151
+ guarantee that every task completes within its budget. Runs with required verified
152
+ delivery use their verification controller instead. Unlimited-token mode disables these token
153
+ stops and closure transitions.
118
154
  Schema serialization is cached by schema identity; messages and tool descriptions
119
155
  are measured anew. Transport accounting reuses its measurement for diagnostics.
120
156
 
@@ -149,13 +185,41 @@ artifact; they cannot silently resume under the changed context behavior.
149
185
  Run `bun run evaluate:continuity` for deterministic retention, redaction, and agent
150
186
  loop regressions. These checks do not measure model coding capability.
151
187
 
188
+ The live follow-up exposed an older objective competing with a newer user correction.
189
+ The v7 policy protects recent user steering and describes its precedence explicitly.
190
+ This follows the approach of retaining recent user messages independently of a summary
191
+ in [Codex's compactor](https://github.com/openai/codex/blob/main/codex-rs/core/src/compact.rs);
192
+ it does not adopt Codex's token budget or imply equivalent model performance.
193
+
194
+ Repair transport budgeting also avoids an implicit 2,048-token response cap. Reasoning
195
+ and visible output can share the provider's output allowance, as explained in
196
+ [OpenAI's reasoning guide](https://developers.openai.com/api/docs/guides/reasoning).
197
+ Explicit caller limits and the remaining cumulative budget still apply where the
198
+ selected transport supports a request cap. A completed change needs relevant checks
199
+ and review, not repeated audits without new evidence; this is consistent with
200
+ [Claude Code's guidance on scoped review](https://code.claude.com/docs/en/best-practices#add-an-adversarial-review-step).
201
+ These are product choices supported by those sources, not a universal harness standard.
202
+
152
203
  ## Task continuity and repair policy (audit remediation)
153
204
 
154
- The `bounded-evidence-v5` summary remains lossy and bounded. Original operator
155
- requests are stored separately in run metadata (`zhivexTaskSources`), redacted,
156
- deduplicated by digest and limited to 64 requests / 256000 UTF-8 bytes. Exceeding
157
- that bound is an explicit error. `read_task` reads 4000 characters at an offset
158
- and lists source IDs; summaries do not replace the original acceptance criteria.
205
+ The `bounded-evidence-v8` summary remains lossy and bounded. It keeps up to ten
206
+ distinct user steering messages within the same 4,000-character limit. The initial
207
+ request is historical context; `objective` holds the latest direction. Later
208
+ user corrections take precedence, the
209
+ latest user message overrides the summary, and recalled assistant text cannot
210
+ redefine user facts. This prevents repetitive narration from giving old values
211
+ priority over later corrections; it does not make summaries authoritative.
212
+ Original operator
213
+ requests are stored separately in run metadata (`zhivexTaskSources`), redacted
214
+ and deduplicated by digest, ordered by the latest occurrence of each request.
215
+ Repeating an earlier request makes it current without duplicating its stored text;
216
+ an explicit original-source marker preserves `firstSourceId`. Durable history is retained beyond 64 requests and
217
+ 256000 UTF-8 bytes instead of aborting the conversation or discarding requirements.
218
+ `read_task` reads 4000 characters at an offset and projects at most 64 source IDs.
219
+ The default ID page contains the latest requests; `sourceOffset` pages older IDs
220
+ and `firstSourceId` addresses the original request directly. Stored metadata grows
221
+ with operator history, while model-facing pages remain bounded. Summaries do not
222
+ replace the original acceptance criteria.
159
223
  Interactive sessions retain this metadata across turns and durable resumes.
160
224
  Manual compaction keeps a bounded summary in the prompt and retains redacted
161
225
  operator sources separately. The CLI persists them in session/run metadata.
@@ -167,8 +231,8 @@ and the next check in the durable tool journal. Its optional `verifier` records
167
231
  exact `command`, `args` and a bounded `purpose`. Neither tool creates approval
168
232
  or proof that a task is solved.
169
233
 
170
- The optional `repair` runtime profile is shared by CLI, library and external
171
- benchmark. Before each actual provider request it predicts the full message and
234
+ The optional `requireVerifiedDelivery` completion contract is shared by CLI, library
235
+ and external benchmark. Before each actual provider request it predicts the full message and
172
236
  tool-schema context, reserves 30% of input/output allowance for closure, and caps
173
237
  requested output to the current phase allowance. The predictor uses serialized
174
238
  characters, not the provider tokenizer: actual billing can exceed a prediction.
@@ -190,7 +254,7 @@ not independently establish that the chosen check covers the user's requirement.
190
254
  Host-mode edits require an approved `run_check` before completion.
191
255
 
192
256
  Applications that require an actual repair can set `requireVerifiedDelivery: true`
193
- when creating a Harness with `agentProfile: "repair"`. This creates a durable
257
+ when creating a Harness, without choosing a runtime profile. This creates a durable
194
258
  completion obligation before exploration starts; a final answer without a
195
259
  verified delivery is failed in both the result and saved checkpoint. The option
196
260
  is bound to the run fingerprint and cannot be removed by restoring the controller
@@ -239,6 +303,12 @@ four further read calls and three command calls remain. Every `read_files` path
239
303
  is checked against the normalized plan scope. Approved verification remains
240
304
  subject to the run deadline, lease and tool budgets.
241
305
 
306
+ A rejected plan leaves the previous accepted plan intact. An out-of-scope read
307
+ does not consume the closure read allowance, though it still consumes the ordinary
308
+ tool-error budget. Correcting or replacing a plan does not replenish allowances.
309
+ If an operation fails after changing a previously delivered candidate, the new
310
+ candidate remains pending verification across resume.
311
+
242
312
  Primary and child definitions share the durable policy factory. Their manifests
243
313
  identify the role, catalogue, budget and whether the primary closure controller
244
314
  is installed. Read-only review groups and SDK-managed delegated runs do not gain
@@ -251,14 +321,108 @@ search evidence and fully overlapping read slices are suppressed on their third
251
321
  observation; real reads still validate current bytes. Possible mutation/command
252
322
  effects reset those hashes. Closure counters, known paths and bounded evidence
253
323
  hashes survive SDK checkpoints in `zhivexRepairProgress`. Runtime read output is
254
- limited to 32000 serialized characters per model step in this profile.
324
+ limited to 32000 serialized characters per model step when verified delivery is required.
255
325
 
256
- Changing the compaction strategy or runtime profile changes the harness binding.
326
+ Changing the compaction strategy or delivery requirement changes the harness binding.
257
327
  Paused runs from an older binding must be completed/denied with their original
258
328
  artifact; these changes deliberately do not reinterpret an old approval.
259
329
 
260
- Repair mode returns an unknown tool selection to the model as `TOOL_NOT_REGISTERED`, just as invalid arguments receive structured feedback. It never resolves aliases or executes an unregistered tool. Existing tool-error, step and token limits bound recovery; callers can override `unknownToolMode` to `throw` or use `stopOnError`. Strict mode retains its fail-fast behavior, and subsequent mutations still require approval.
330
+ The shared execution loop returns unknown tool selections as `TOOL_NOT_REGISTERED`
331
+ and invalid arguments as structured error feedback. This general-purpose recovery
332
+ is separate from the optional verified-delivery controller: ordinary runs keep
333
+ ordinary model-driven task completion without imposing a verifier plan. No
334
+ unregistered tool or invalid arguments are executed. Existing tool-error, step,
335
+ token and time limits bound recovery; callers can select `stopOnError: true`,
336
+ `validationErrorMode: "throw"` and `unknownToolMode: "throw"` explicitly. Delegated
337
+ runs use the same recovery defaults with sequential execution and their existing
338
+ child budgets. Subsequent mutations still require approval.
261
339
 
262
340
  For required-delivery OCI runs, reaching the predicted work-budget boundary without a verifier transitions into the same durable two-attempt planning path before rejecting another exploration request. That request exposes only `repair_plan` and `read_task`. The estimate includes the working-state message and current tool catalogue; the budget gate recalculates after narrowing. This spends only the existing closure reserve, keeps total input/output ceilings, and neither executes nor approves a repair. Optional inspection runs do not gain access to the reserve.
263
341
 
264
342
  Closure-reserve eligibility from this boundary is durable across checkpoints and remains active after recording the verifier, so planning can lead to an edit. A repair with an existing verifier can enter the same reserve. This does not replenish tokens, grant tool approval, or establish that a candidate satisfies the task.
343
+
344
+ ### Qwen reasoning fragments
345
+
346
+ The harness losslessly joins adjacent plain Qwen `reasoning_content` fragments
347
+ before estimating saved histories and when collecting new model streams. This
348
+ removes repeated JSON envelopes without truncating reasoning text, tool calls,
349
+ or results. Signed or unknown provider data forms a boundary and is preserved
350
+ unchanged. Streaming aggregation flushes at 16 KiB of characters or the next
351
+ non-reasoning event. Oversized irreducible groups still fail closed; the CLI
352
+ identifies this as a context-compaction failure rather than an unknown cause.
353
+ ## Hierarchical context and hybrid compaction
354
+
355
+ The pinned Zhivex SDK owns paid-compaction admission and durable attempt receipts. Harness supplies an explicit route fingerprint and reserves 32,000 input tokens plus 1,024 output tokens before the callback runs. The serialized utility input is capped below 31,000 UTF-8 bytes, leaving framing allowance; this conservative bound can reject a call when a tight budget cannot reserve it. Small sources use deterministic evidence and a zero-usage receipt. Confirmed usage survives summary rejection; interrupted or unknown attempts block paid retries. The separate Harness ledger remains responsible for per-route monetary limits and partial provider usage.
356
+
357
+ The SDK shared budget coordinator is available to library callers through an explicit run policy; it is not enabled automatically. Harness persistence supports its reserved namespace without widening tenant/user access. Portable backups include linked coordinator ledgers and reject unresolved reservations or unknown compaction attempts, so restoring a backup cannot silently reset the shared consumption. Backups created before these optional records remain readable.
358
+
359
+ Successful `read_file` and `read_files` calls discover ancestor `AGENTS.md` files
360
+ inside the workspace, excluding the already loaded root. Discovery is bounded,
361
+ rejects links/protected paths, and records both present and absent file identities
362
+ in SDK-owned checkpoints. Applicable guidance is supplied on subsequent requests,
363
+ with its scope and provenance; it cannot change permissions or verification.
364
+ The number of previously visited directories or small instruction files does not
365
+ exhaust a lifetime quota. Content remains bounded by per-file and aggregate byte
366
+ limits, and each discovery request retains its target/ancestor bound.
367
+ The runtime refreshes these discovered scopes before model requests, including
368
+ normal edits, deletion and creation at a previously absent instruction path.
369
+ Updated guidance replaces the previous scoped context; it cannot authorize an
370
+ effect. Unsafe links, protected paths, invalid text and exceeded limits still
371
+ fail before that guidance reaches the model. The strict
372
+ `validateHarnessScopedContext` library function remains available for callers
373
+ that explicitly require fixed instruction identities. The root context bundle
374
+ and execution/approval fingerprints keep their existing binding rules.
375
+ Project context can still be disabled with `--no-project-context`.
376
+
377
+ Primary runs now monitor repeated tool-result cycles and long repeated text across
378
+ compaction and resume. Three unchanged cycles request a new hypothesis; five stop
379
+ before the next model call. Changed results break repetition. Bounded persisted
380
+ hashes contain no source text. Changing narration around identical tools does
381
+ not count as progress. Text-only repetition remains monitored independently of
382
+ tool turns. A genuine new user request resets that history, including when the
383
+ user deliberately asks to reread an unchanged file. Approval resumes, summarized
384
+ history and assistant/tool-only continuations retain it, so continuation cannot
385
+ erase a loop within the same turn. Reads are not replaced with cached evidence.
386
+ A separate durable counter requests a decision after eight exploratory operations
387
+ without a successful edit or check, even when every read/search differs. This
388
+ advisory asks for the smallest justified implementation, a synthesis for read-only
389
+ work, a specific missing fact, or an explicit blocker. It never forces a tool call
390
+ or adds a hard stop to legitimate exploration. New user requests and successful
391
+ edits/checks reset it; approval resumes and compaction preserve it.
392
+ Trusted independent local reads use up to four SDK workers; writes, checks,
393
+ approvals, MCP and delegation remain barriers. This is not a latency benchmark.
394
+
395
+ Optional semantic compaction supplements deterministic evidence with an untrusted
396
+ recollection from an explicitly chosen model. Selection, credentials and usage are
397
+ separate from the primary model. It can summarize bounded, redacted local code
398
+ from authenticated builtin read/search results as well as conversational decisions and diagnostics;
399
+ the model is no longer limited to typed operational evidence. These excerpts
400
+ share one input allowance and never include arbitrary external-tool/provider
401
+ payloads. Source authentication uses a bounded process-local hash registry issued
402
+ by actual builtin executions and bound to run ID, tool-call ID, tool name and
403
+ complete output. Caller history, custom tools with builtin names and persisted
404
+ metadata cannot issue this proof. Unauthenticated tool output, extra error fields
405
+ and tool-call arguments are excluded before constructing either utility summaries
406
+ or excerpts. Previously compacted envelopes without matching process-local proof
407
+ retain only user objectives and steering; their markers alone grant no provenance
408
+ for tool observations, paths, plans or recollections. Malformed envelopes are
409
+ omitted. After restarting or evicting a proof, source excerpts become eligible
410
+ again after new builtin reads.
411
+ The semantic strategy is `hybrid-context-v3-attested-sources`, which changes the
412
+ durable runtime fingerprint. See [CLI](CLI.md#configurable-model-assisted-compaction)
413
+ and [model catalog](MODEL_CATALOG.md). Tool metadata, approval state and verification
414
+ receipts remain outside the summarizer's authority. These runtime strategy changes
415
+ alter durable fingerprints: finish old paused runs with their original artifact.
416
+ Every run returns the matching persisted revision, including refreshed
417
+ context and accounting metadata, rather than an older in-memory SDK projection.
418
+ Named child agents keep their existing bounded runtime; these new primary-run
419
+ context/progress/compaction integrations do not claim a child-runtime migration.
420
+
421
+ ### Correcting malformed read calls
422
+
423
+ Provider-facing tool errors explain the difference between `read_file` (one
424
+ string `path`) and `read_files` (an actual array of slice objects), and clarify
425
+ that `endLine` is an absolute line number, not a count. The runtime does not
426
+ execute, rename or silently repair malformed calls. Durable error receipts stay
427
+ unchanged; the model must issue a corrected request, and edits still require
428
+ current read evidence and approval.
@@ -40,7 +40,7 @@ outside the CLI support contract; adding this binding does not certify Windows.
40
40
 
41
41
  Environment keys take precedence over saved and temporary keys, including provider
42
42
  aliases. The CLI reports that precedence when managing a key while an environment
43
- key exists. Changing the saved key does not override the launching shell.
43
+ key exists. For Qwen, explicitly configuring a connection selects its managed credential for the current CLI session, overriding Qwen shell settings. On a new launch, environment keys take precedence again.
44
44
 
45
45
  One-shot commands (`run`, `review`, `resume`), `providers`, and service connections
46
46
  retain their existing environment/host-owned behavior: they never prompt for keys
@@ -62,8 +62,40 @@ Keys are kept outside profiles, repositories, run metadata and chat history. Man
62
62
  keys are passed only to provider model clients, not to `process.env`, MCP or command
63
63
  execution environments. Do not paste a key into a normal conversation.
64
64
 
65
- Managed keys require default provider endpoints. Shell-defined base URL or Qwen
66
- region/workspace overrides are rejected before reading the keychain. To intentionally
67
- use a custom endpoint, supply its credential explicitly through the environment.
68
- Credential storage is separate from live provider validation; the first model
69
- request checks account access and may be billable.
65
+ Managed keys for other providers require default endpoints. Qwen keys are bound to
66
+ an explicitly selected service and region. When shell endpoint settings conflict,
67
+ the console offers to use the saved destination for this session or cancel. It never
68
+ sends a managed key to an arbitrary shell-defined endpoint. Custom endpoints still
69
+ require explicit environment credentials.
70
+
71
+ ## Qwen interactive setup
72
+
73
+ Open `/credentials` → Qwen → save or temporary → Standard API or QwenCloud Token
74
+ Plan. Standard API asks for region and, where needed, a workspace ID. Then enter
75
+ the hidden key. Service/region/workspace and key are stored together in the system
76
+ keychain (or only in memory for temporary use); no key enters the profile.
77
+ Existing raw Qwen keychain entries retain the historical Singapore API destination.
78
+ Changing service requires entering the matching key; the CLI does not infer it
79
+ from a key prefix. Cancellation preserves the previous connection.
80
+
81
+ Select the model with `/model`, then use `/connection` for an optional small,
82
+ potentially billable request. It sends no repository content or tools, allows 16
83
+ output tokens, disables retries, and times out after 15 seconds. A successful test
84
+ only verifies access to that model. Setup itself does not validate account access.
85
+ Regional destinations follow the [official Model Studio region documentation](https://www.alibabacloud.com/help/en/model-studio/regions).
86
+
87
+ ## QwenCloud Token Plan
88
+
89
+ Harness includes `@zhivex-ai/qwen` 0.15.2. For an interactive Token Plan session,
90
+ set `QWEN_BASE_URL=https://token-plan.maas.qwencloudapi.com/compatible-mode/v1`
91
+ and supply your dedicated Token Plan key through `DASHSCOPE_API_KEY` (or
92
+ `QWEN_API_KEY`). Start `zhx chat --provider qwen --model qwen3.8-max`, or select
93
+ `qwen3.8-flash`. Enter/export credentials privately; never paste them into chat
94
+ or commit them. Leave `QWEN_WORKSPACE_ID` unset for this endpoint.
95
+
96
+ The endpoint is explicit: Harness does not infer billing mode from a key prefix.
97
+ The interactive setup also supports this fixed Token Plan endpoint with managed keys. Arbitrary custom endpoints require environment credentials.
98
+ Use standard pay-as-you-go credentials for backend/scheduled workloads. See the
99
+ [official Token Plan quickstart](https://docs.qwencloud.com/token-plan/personal/token-plan-personal-quickstart)
100
+ for matching key types and endpoints. Account entitlements are provider-controlled;
101
+ local transport tests do not certify access to a paid plan.
@@ -2,6 +2,8 @@
2
2
 
3
3
  Zhivex Harness durable operations make local runs inspectable and recoverable across process restarts. The default store is runtime-portable SQLite at `<workspace>/.zhivex-harness/runs/operations.sqlite`, backed by `node:sqlite`; `--store file` remains a migration fallback. The `0.10.x` runtime change does not alter the SQLite file or table format.
4
4
 
5
+ Before creating session or run state, Harness writes a local `.gitignore` that excludes all contents of `.zhivex-harness/` (or the configured custom state directory), including SQLite journals and file-store records. This protects untracked files from ordinary `git add`; it cannot override `git add --force` or untrack files already committed. If state was previously tracked, add `.zhivex-harness/` to the repository's root `.gitignore` and use `git rm --cached` on the tracked state files to keep local data while removing it from future commits. Existing Git history is unchanged and must be assessed separately.
6
+
5
7
  ## Scope and identity
6
8
 
7
9
  Every durable key is isolated by:
@@ -62,6 +64,14 @@ zhx sessions archive <sessionId>
62
64
 
63
65
  The store uses SQLite WAL transactions, optimistic revisions, workspace/scope hashes, owner-only permissions, soft deletion/retention, and bounded session/run/metadata/index sizes. It rejects a new run while the latest session run is active or waiting for approval. Fork and archive operations also require a terminal branch point.
64
66
 
67
+ SQLite runs store steps, tool results and compaction records separately from the active checkpoint. Large repeated text is retained in per-run content-addressed artifacts. Checkpoint and history changes commit in the same transaction; unchanged historical records are not rewritten. The 4 MiB state limit applies to the active checkpoint, including current messages, approvals, metadata and counters. Conversation compaction still controls model input size independently.
68
+
69
+ Loading a run reconstructs its complete state for compatibility with approvals, recovery and verification. Programmatic history inspection can use `store.loadHistory(runId, { field: "toolResults", offset: 0, limit: 50 }, scope)` to read a page. Full hydrated states and total disk usage can grow with the run; run retention remains necessary. File and in-memory stores retain the full-state size limit.
70
+
71
+ Logical backups contain hydrated history rather than database references, so restoration does not require the original artifact tables. Exports up to 64 MiB retain the legacy JSON format; larger exports use the versioned `ZHIVEX-STATE-SEGMENTS-1` transport with bounded frames, including split strings. RC13 reads both formats and verifies the same logical checksum before import. Older versions cannot read segmented exports. File I/O and checksum serialization are incremental; the public backup/import APIs still hydrate the complete logical bundle in memory. Segmented files have no aggregate 64 MiB ceiling. A state-limit failure records a bounded terminal diagnostic on the last durable checkpoint; the unsaved payload is not claimed as preserved. Use `/status` to inspect the failed run before `/continue`. Recovery retains tool journal receipts and never re-executes an operation itself.
72
+
73
+ Incremental SQLite history uses the published Core 1.26.0 and Agents 1.10.1 packages. No local dependency patch is required. Install this checkout with `bun install --frozen-lockfile`.
74
+
65
75
  ## Provider handoff safety
66
76
 
67
77
  Every console turn preallocates a new run ID and binds it permanently to one provider/model. Provider or model changes take effect only on the next run and are blocked while an approval is pending. Before transferring context to another provider/model, the console creates a bounded deterministic redacted summary: text is truncated and common credentials are removed, while tool inputs, outputs, and provider payloads are replaced by tool/type names.
@@ -8,12 +8,28 @@ Built-in registrations are Meta, Qwen, OpenAI, and Gemini. Each registration own
8
8
 
9
9
  Library callers can use `DEFAULT_PROVIDER_REGISTRY`, `BUILTIN_PROVIDER_REGISTRATIONS`, `createProviderRegistry`, or `DEFAULT_PROVIDER_REGISTRY.extend(...)`, then pass the registry to `resolveHarnessConfig`, `createProviderModel`, provider diagnostics, or `createHarness({ providerRegistry })`. Registration IDs, environment-variable names, defaults, diagnostics, and factories are validated before they become selectable.
10
10
 
11
- The coordinated SDK batch pins `@zhivex-ai/agents@1.9.0`, `@zhivex-ai/core@1.23.0`, `@zhivex-ai/meta@0.2.7`, `@zhivex-ai/qwen@0.15.1`, `@zhivex-ai/openai@0.13.5`, and `@zhivex-ai/gemini@0.12.2`. Qwen `0.11.x` normalizes missing, placeholder, and continuation tool-call identifiers inside the adapter; Harness retains its deterministic provider-boundary normalizer as defense in depth until the exact candidate passes the complete release-bound representative matrix. A Core override keeps one runtime contract identity across every adapter, while Core `1.13.0` corrects compaction usage accounting and interaction-group retention. OpenAI `0.11.2` preserves synthetic assistant history in Responses, so the harness no longer requires its compaction transport or accounting workarounds.
11
+ The coordinated stable SDK batch pins `@zhivex-ai/agents@1.10.1`, `@zhivex-ai/core@1.26.0`, `@zhivex-ai/meta@0.2.8`, `@zhivex-ai/qwen@0.16.2`, `@zhivex-ai/openai@0.13.6`, and `@zhivex-ai/gemini@0.12.3`. Qwen 0.16.2 types malformed Responses tool arguments and malformed SSE events; Core 1.26.0 satisfies its published dependency range. These exact versions are pinned in the lockfile. Stable SDK publication does not replace Harness release-bound certification. Qwen `0.11.x` normalizes missing, placeholder, and continuation tool-call identifiers inside the adapter; Harness retains its deterministic provider-boundary normalizer as defense in depth until the exact candidate passes the complete release-bound representative matrix. A Core override keeps one runtime contract identity across every adapter, while Core `1.13.0` corrects compaction usage accounting and interaction-group retention. OpenAI `0.11.2` preserves synthetic assistant history in Responses, so the harness no longer requires its compaction transport or accounting workarounds.
12
12
 
13
13
  OpenAI is based on the GPT-5.6 family: `gpt-5.6-luna` is the default, with `gpt-5.6-terra` and `gpt-5.6-sol` available through `--model`. Availability remains organization-dependent while the upstream family is in limited preview, and the adapter uses the Responses API by default.
14
14
 
15
15
  Gemini still defaults to `gemini-3.6-flash`, uses `GEMINI_API_KEY` or `GOOGLE_GENERATIVE_AI_API_KEY`, and accepts optional `GEMINI_BASE_URL`. Adapter `0.11.0` adds modeled Gemini 3.7 and media/realtime surfaces, but the default and support level do not change implicitly. Gemini remains provisional until proposal/approval/restart, delegation, mixed routing, and OCI execution pass the credentialed Harness live matrix; adapter-level evidence alone does not make the Harness integration certified.
16
16
 
17
+ ### Meta conversation continuity
18
+
19
+ The built-in Meta route uses Responses with `store: false` and `include: ["reasoning.encrypted_content"]`. It sends retained messages, tool calls, receipts, and opaque encrypted reasoning on every turn. It does not depend on server-side response IDs. A narrow compatibility layer inserts reasoning items omitted by the pinned Meta SDK serializer; the SDK still owns ordinary serialization, streaming, and HTTP handling. Serializer-layout mismatches fail explicitly.
20
+
21
+ Existing sessions retain visible history and tool receipts; reasoning from old turns that never requested encrypted content cannot be recovered. New encrypted items stay intact in the local checkpoint and are replayed only with retained turns. Model instances do not share replay buffers. No completed host tool is rerun to restore context.
22
+
23
+ The legacy receipt-only recovery helper permits two backoffs, 1s then 2s, when Meta rejects a just-completed response ID. It never retries arbitrary invalid input or hosted-tool requests. The built-in stateless route does not need this recovery path.
24
+
25
+ For a bounded live check of both generate and streaming replay, including a new model instance and JSON-restored history:
26
+
27
+ ```bash
28
+ ZHIVEX_HARNESS_LIVE=1 bun --env-file=.env scripts/meta-replay-live-smoke.ts
29
+ ```
30
+
31
+ The check makes four requests and reports only assertions; it does not print response IDs or encrypted content. It validates source behavior, not a newly published release artifact.
32
+
17
33
  ## Capability gate
18
34
 
19
35
  Every run requires streaming and callable-tool support by default. Add explicit requirements with repeatable CLI flags:
@@ -57,9 +73,9 @@ The schema is versioned independently:
57
73
  }
58
74
  ```
59
75
 
60
- Every server requires a non-empty tool allowlist and permission set. Tool discovery is paginated and bounded. Tool names are prefixed with `<server>_` unless an explicit safe prefix is supplied. Configuration contains environment-variable names rather than credential values; diagnostics and fingerprints never include resolved header values. Credential variables must use the dedicated `ZHIVEX_MCP_*` namespace, and HTTP authentication is limited to the canonical `authorization` and `x-api-key` headers so a workspace file cannot select unrelated process credentials or arbitrary outbound headers.
76
+ Every server requires a non-empty tool or exact-resource allowlist and permission set. Tool discovery is paginated and bounded. Tool names are prefixed with `<server>_` unless an explicit safe prefix is supplied. Configuration contains environment-variable names rather than credential values; diagnostics and fingerprints never include resolved header values. Credential variables must use the dedicated `ZHIVEX_MCP_*` namespace, and HTTP authentication is limited to the canonical `authorization` and `x-api-key` headers so a workspace file cannot select unrelated process credentials or arbitrary outbound headers.
61
77
 
62
- The built-in transport supports HTTPS and loopback HTTP. Redirects, URL credentials, unsafe configurable headers, oversized configuration, symlinked configuration, and configuration outside the workspace are rejected. `stdio` is intentionally unavailable because spawning an MCP server is process execution; it remains deferred until the enforced execution environment in `0.6.x`.
78
+ The legacy built-in transport supports HTTPS and loopback HTTP; the opt-in SDK transport requires HTTPS. Redirects, URL credentials, unsafe configurable headers, oversized configuration, symlinked configuration, and configuration outside the workspace are rejected. `stdio` is intentionally unavailable because spawning an MCP server is process execution; it remains deferred until the enforced execution environment in `0.6.x`.
63
79
 
64
80
  Library callers can inject a custom `McpClient`. Trusted read-only annotations are accepted only for an explicitly injected custom transport whose sole declared permission is `read`. HTTP always declares `network` and therefore always pauses for operator approval, even when a server claims a tool is read-only.
65
81
 
@@ -221,9 +237,90 @@ Human terminal mode reports child start and finish telemetry. `run-result` JSON
221
237
 
222
238
  ## Known limits
223
239
 
224
- - The built-in MCP transport implements bounded JSON-RPC over Streamable HTTP response forms; it does not support OAuth discovery, server-initiated sampling, roots, subscriptions, elicitation, or arbitrary SSE reconnection.
240
+ - The legacy MCP transport implements bounded JSON-RPC over Streamable HTTP response forms; it does not support OAuth discovery, server-initiated sampling, roots, subscriptions, elicitation, or arbitrary SSE reconnection.
225
241
  - MCP prompt-injection detection is a safety filter, not a proof that remote content is trustworthy.
226
242
  - Parallel review groups have a durable shared parent identifier, but the group itself is not a standalone persisted agent state.
227
243
  - With `execution=none`, subagents share the host process and workspace and are policy boundaries rather than OS isolation. With `execution=oci`, they inherit the same acquired snapshot and environment authorization; this does not turn the local container runtime into a VM.
228
244
  - Generic host shell, `stdio` MCP, network-enabled OCI policies, and remote workers remain unavailable. The `0.6.x` OCI policy rejects all MCP before discovery rather than executing an undeclared client outside the acquired boundary.
229
245
  - Provider-specific orchestration behavior requires date-bound live certification and is separate from deterministic implementation evidence.
246
+
247
+ ## Allowlisted MCP text resources
248
+
249
+ MCP servers may expose text resources as well as tools. Add `includeResources` with exact URIs to the existing MCP server configuration:
250
+
251
+ ```json
252
+ {
253
+ "schemaVersion": 1,
254
+ "servers": [{
255
+ "name": "docs",
256
+ "transport": "http",
257
+ "url": "https://mcp.example.com/rpc",
258
+ "includeResources": ["docs://project/architecture"],
259
+ "permissions": ["read", "network"]
260
+ }]
261
+ }
262
+ ```
263
+
264
+ `includeTools` may be omitted or empty only when resources are explicitly allowlisted. Tool-only configurations keep their previous normalization and fingerprint. Discovery uses MCP `resources/list`; a server must list every requested URI within the configured `maxListPages`, `maxListedTools` (also the resource item cap), `listToolsTimeoutMs`, and per-response `maxOutputBytes` bounds. HTTP servers must declare the `resources` capability during initialization. Existing HTTPS/loopback restrictions, credential-header allowlist, no-redirect behavior, session negotiation and JSON-RPC response matching apply unchanged.
265
+
266
+ The harness exposes `<toolNamePrefix>read_resource`, accepting exactly one allowlisted URI. Every read requires approval, including a custom read-only server with trusted tool annotations. Resource metadata carries the MCP origin and read/network permissions, so the scheduler cannot treat these calls as trusted workspace reads. Contents are fetched only after approval, limited by `callToolTimeoutMs` and `maxOutputBytes`, and returned as untrusted evidence. The reader rejects substituted URIs, probable prompt injection, binary blobs and malformed content. URI templates, wildcard grants, subscriptions and automatic context injection are not supported. `file:` URIs are sent to the MCP server; the harness does not open them as local files.
267
+
268
+ Injected clients can implement the optional `listResources` and `readResource` methods on `HarnessMcpResourceClient`; existing tools-only `McpClient` implementations remain compatible. Custom operations receive abort signals and are bounded even when they ignore cancellation. Applications remain responsible for stopping any background work in their injected implementation after cancellation. The existing prohibition on host MCP clients under OCI execution also covers resource servers.
269
+
270
+ Protocol reference: [MCP resources, 2025-06-18](https://modelcontextprotocol.io/specification/2025-06-18/server/resources). The resource tools do not expose resource templates, prompts, or binary resource rendering. OAuth is available only through the explicitly selected SDK transport and a trusted host provider, described below.
271
+ ## Application tool policies (Experimental)
272
+
273
+ `createHarness({ toolPolicy })` accepts trusted application-owned declarative rules
274
+ with stable IDs, exact tool names, optional exact paths, reasons and `allow`,
275
+ `ask_user` or `deny`. The most restrictive matching decision wins. An allow rule
276
+ cannot remove existing approval requirements, enable a missing tool or weaken
277
+ filesystem/OCI policy. The policy also wraps tools supplied to named child profiles.
278
+
279
+ Path rules require a trusted `toolPolicyPaths(toolName, input)` resolver plus a
280
+ stable `toolPolicyPathsVersion`. Its version and the policy digest bind durable
281
+ resume. SDK approval flags are static, so a path-scoped ask rule conservatively
282
+ requires approval for the entire named tool. Such tools are never parallel reads.
283
+ `onToolPolicyDecision` receives the applied rule IDs and reason. Repository manifests
284
+ cannot register these callbacks. Existing lifecycle hooks remain available.
285
+
286
+ ```ts
287
+ const harness = await createHarness({
288
+ toolPolicy: { schemaVersion: 1, rules: [{
289
+ id: "review-deletes", tools: ["quarantine_file"], decision: "deny",
290
+ reason: "This application does not permit removing files."
291
+ }] }
292
+ });
293
+ ```
294
+
295
+ See [ACP](ACP.md) for the experimental text-session client adapter and
296
+ [workspace checkpoints](WORKSPACE_CHECKPOINTS.md) for reviewed restoration and
297
+ recovery. OAuth credential UI and process-based MCP remain unavailable. The
298
+ explicit SDK HTTP path below supports host-owned OAuth providers.
299
+
300
+
301
+ ## SDK HTTP transport and host-owned OAuth (experimental)
302
+
303
+ Existing configurations keep the MCP `2025-06-18` HTTP transport, including loopback HTTP. Opt into the SDK's reusable Streamable HTTP client with `protocolVersion: "2025-11-25"` on an HTTPS server. The version is included in the durable configuration fingerprint; there is no automatic downgrade or retry after a potentially effectful call.
304
+
305
+ ```json
306
+ {
307
+ "schemaVersion": 1,
308
+ "servers": [{
309
+ "name": "docs",
310
+ "transport": "http",
311
+ "protocolVersion": "2025-11-25",
312
+ "url": "https://mcp.example.com/rpc",
313
+ "includeTools": ["lookup"],
314
+ "includeResources": ["docs://project/architecture"],
315
+ "permissions": ["read", "network"]
316
+ }]
317
+ }
318
+ ```
319
+
320
+ The selected SDK client handles session negotiation, capability checks, bounded JSON/SSE responses, protocol validation and typed resource requests. The harness retains exact tool/resource allowlists, text-only resource validation, untrusted-content handling, interrupt approvals and OCI restrictions. Every destination is pinned to the configured endpoint and redirects are prohibited. A host `destinationPolicy` can further restrict DNS/IP/tenant access; it cannot permit another server. DNS resolution enforcement remains the host deployment's responsibility. The harness propagates its per-operation deadline into the SDK's initialization fetch and host credential provider as well as the caller-facing operation.
321
+
322
+ For OAuth, construct `createMcpOAuthProvider` from `@zhivex-ai/core/mcp-http` in trusted host code. The SDK implements PKCE, resource/issuer binding and token refresh. The host supplies the issuer/client ID, approved endpoints, token store and authorization callback flow. Workspace JSON cannot define an OAuth issuer, token store, browser action or raw credential.
323
+
324
+ Pass that SDK provider to `createHarness` as `mcpHttpOptions: { docs: { auth: oauthProvider, destinationPolicy } }`, or directly to `createHarnessMcpTools(config, { httpOptions: { docs: { auth: oauthProvider, destinationPolicy } } })`. An existing host can instead inject `createHttpMcpClient(server, env, fetch, { auth: oauthProvider })` through `mcpClients`. The provider object and tokens are never added to persisted configuration. An OAuth provider cannot be combined with a static `authorization` header; the dedicated `x-api-key` environment header remains available where required.
325
+
326
+ Authentication failures are surfaced with sanitized SDK error codes. The harness does not automatically launch login, select an issuer from untrusted metadata, or retry `tools/call`. An `INDETERMINATE` result means an external effect may have happened: reconcile it before retrying. Host OAuth injection is unavailable on the legacy protocol path. The SDK supports additional prompt/template APIs, but this harness deliberately exposes only its configured tools and exact text resources.
package/docs/FIRST_USE.md CHANGED
@@ -1,11 +1,13 @@
1
1
  # First use
2
2
 
3
+ This guide targets the unpublished `1.2.0-rc.13` candidate. Installation commands become available after protected publication to npm `next`; stable users can install `@zhivex-ai/harness@latest`.
4
+
3
5
  ## Install and start
4
6
 
5
7
  Install Node.js 22.13.0 or newer and Git. Then:
6
8
 
7
9
  ```sh
8
- npm install -g @zhivex-ai/harness@1.1.1
10
+ npm install -g @zhivex-ai/harness@1.2.0-rc.13
9
11
  cd /path/to/your/project
10
12
  zhx
11
13
  ```
@@ -80,16 +82,16 @@ For command execution, configure [OCI isolation](EXECUTION_ENVIRONMENTS.md).
80
82
  With Bun 1.4.0 or newer and a supported Node runtime:
81
83
 
82
84
  ```sh
83
- bun add --global @zhivex-ai/harness@1.1.1
85
+ bun add --global @zhivex-ai/harness@1.2.0-rc.13
84
86
  zhx
85
87
  ```
86
88
 
87
89
  For a disposable version/help/environment check without a global installation:
88
90
 
89
91
  ```sh
90
- bunx @zhivex-ai/harness@1.1.1 --version
91
- bunx @zhivex-ai/harness@1.1.1 --help
92
- bunx @zhivex-ai/harness@1.1.1 doctor
92
+ bunx @zhivex-ai/harness@1.2.0-rc.13 --version
93
+ bunx @zhivex-ai/harness@1.2.0-rc.13 --help
94
+ bunx @zhivex-ai/harness@1.2.0-rc.13 doctor
93
95
  ```
94
96
 
95
97
  For source development, use the [contributor guide](https://github.com/Zhivex/zhivex-harness/blob/main/CONTRIBUTING.md).
@@ -31,7 +31,7 @@ To roll back, republish the earlier valid manifest at the same URL; clients acce
31
31
 
32
32
  ## Selection behavior
33
33
 
34
- Both selectors expose Primary models, Other models, and a custom ID option. Desktop searches across names, IDs and providers, expanding Other models for search results. Deprecation details and replacements accompany model choices.
34
+ The CLI exposes Featured models, Other models, and a custom ID option; Desktop uses Primary models. Desktop searches across names, IDs and providers, expanding Other models for search results. Deprecation details and replacements accompany model choices.
35
35
 
36
36
  Catalog refresh never writes project or conversation selections and never silently migrates a selected model. A current ID missing from the catalog stays visible. Retirement is metadata, not proof of account access or an execution block; the provider decides whether a request is accepted. Remote defaults guide explicit choices in the selector. Runtime startup defaults remain the bundled defaults, preserving startup behavior without requiring networking.
37
37
 
@@ -46,3 +46,54 @@ The official [model catalog](https://developers.openai.com/api/docs/models), [GP
46
46
  ## Qwen default — 2026-09-22
47
47
 
48
48
  Revision `2026-09-23.2` restores `qwen3.8-max` as the bundled Qwen default for CLI, Desktop and RC.10 live certification. Max is Primary; `qwen3.8-flash` remains available under Other models. Existing profiles and conversation model selections are preserved. Max remains `unverified` for this candidate until its exact release-bound route passes certification.
49
+
50
+ ## Context limits and compaction advice
51
+
52
+ Revision `2026-09-24.1` adds optional metadata without invalidating older schema-version-1 manifests. Older clients with a strict parser reject enriched manifests and fall back to their cache/bundle; upgrade clients before publishing the enriched manifest remotely.
53
+
54
+ - `limits` records `contextWindowTokens`, `contextWindowType` (`combined` input plus output, or independently documented `input`), `maxOutputTokens`, and optional conservative `maxInputTokens`. Never infer limits from a name or another model version.
55
+ - `pricing` records USD per million input/output tokens, optional cached-input price, a `scope` explaining the applicable tier and exclusions, and optional `maxInputTokens` above which the recorded rates must not be extrapolated. These are estimates, not billing guarantees. Regional or subscription pricing may differ.
56
+ - `compaction.suitability` is `candidate`, `evaluated`, `unsuitable`, or `unknown`. Candidate is an editorial inference from documented text capabilities. Evaluated requires a summary-fidelity evaluation with a referenced report, not just provider marketing or a successful generation.
57
+ - Each metadata group requires HTTPS `evidence.sourceUrl` and `evidence.checkedAt` (`YYYY-MM-DD`). Missing metadata means unknown, not zero or unlimited. Source links are evidence only and are never fetched automatically by recommendations.
58
+
59
+ The first curated limits cover GPT-6 Astra/Sol/Luna, GPT-4o Mini, Qwen 3.8 Max/Flash, and Gemini 3.5 Flash-Lite/3.6 Flash/3.7 Flash/3.8 Flash. Values were checked against each model's official page on 2026-09-24; exact links and dates are embedded in the JSON. Qwen uses the lower documented thinking-mode input ceiling. Initial pricing covers those four OpenAI models and Gemini 3.5 Flash-Lite; other prices remain unknown rather than assuming a region. Other existing model IDs remain available, with unknown limits. No entry is promoted to Zhivex `verified` by adding provider documentation.
60
+
61
+ `recommendCompactionModels(catalog, request)` is a pure advisory function. Its request includes a provider, estimated full input tokens (including instructions and wrappers), reserved output tokens, an optional allowlist of available models, and an optional clock/evidence age (90 days by default). It never changes the configured model, credentials, provider, or catalog defaults. It excludes unknown/stale limits, missing suitability, retired/deprecated models, and insufficient input/output capacity. Results expose exclusion reasons, route/quality warnings, and scoped cost estimates where known. Future-dated evidence is not considered fresh.
62
+
63
+ Ranking prefers known estimated cost, then catalog order and ID. Unknown prices sort behind known prices; this does not claim that an unpriced model costs more. Legacy `evaluated` labels without an evaluation artifact are treated as candidates and reported with `compaction_evaluation_evidence_missing`; a label alone does not earn a quality preference. Pricing above an undocumented tier produces a warning and no estimate. Supply `availableModels` when account availability is known. An explicitly configured model remains the user's choice, including a custom ID; recommendations are never an automatic cross-provider fallback. Runtime token guards and actual usage accounting remain authoritative.
64
+
65
+
66
+ ## Shared SDK recommendation engine
67
+
68
+ The harness uses `@zhivex-ai/core` 1.24.0 `createModelCatalog` and `recommendAuxiliaryModel` for limit validation, per-datum evidence freshness and cost estimates. `src/models/sdk-catalog-adapter.ts` adapts the existing version-1 manifest into that contract, converting USD per million tokens into the SDK's per-thousand units. It retains missing values, provider/model identities and exact source dates. Pricing above a locally recorded tier ceiling is omitted rather than extrapolated. Combined windows reject output limits larger than the window; separately published input windows allow independent output limits.
69
+
70
+ The harness retains its curated inventory, defaults, chooser ordering, lifecycle policy and route validation labels. The core package's `defaultModelCatalog` is an explicitly frozen compatibility inventory, so it is not used to replace the current manifest. Release-managed upstream inventory lives in `@zhivex-ai/sdk`; `models:import` remains an explicit curation workflow. This integration removes duplicate recommendation calculations, without introducing an automatic inventory migration or depending on an unpublished checkout.
71
+
72
+ The SDK requires an evaluation artifact with source, fixture, version, date and pass result for evaluated compaction quality. The current manifest's `evaluated` label has only generic evidence, so the adapter conservatively emits a candidate plus a warning instead of inventing an evaluation. Host lifecycle restrictions and compaction curation freshness remain additional harness checks; public recommendation arguments, return shape and existing reason codes are preserved. Recommendations remain advisory and never authorize credentials or automatically switch providers.
73
+
74
+ ## Featured choices, 2026-09-26
75
+
76
+ Revision `2026-09-26-frontier` puts Qwen 3.8 Flash and Max on the first CLI page,
77
+ followed by GLM 5.3, DeepSeek V4.1 Flash, Kimi K3 and Qwen 3.7 Plus. Third-party
78
+ entries identify the model author separately from Alibaba Model Studio, the API
79
+ provider. GPT-6 Astra, Sol and Luna appear before older GPT generations. The current
80
+ model is labelled but does not displace featured models; saved selections and
81
+ provider defaults do not change. Other models contains older generations and snapshots.
82
+
83
+ The installed Qwen adapter declares these hosted model IDs and model-specific
84
+ reasoning levels. Availability still depends on account, region and endpoint. No new
85
+ entry is certified by listing it. Reviewed primary sources:
86
+
87
+ - [Qwen 3.8 Flash release](https://www.alibabacloud.com/en/news/product/qwen38-flash-released-noi).
88
+ - [GLM on Model Studio](https://help.aliyun.com/en/model-studio/glm): `glm-5.3`; Responses availability depends on region.
89
+ - [DeepSeek V4.1 Flash on Alibaba](https://www.alibabacloud.com/blog/603550): `deepseek-v4.1-flash`; Token Plan uses a distinct endpoint and credential.
90
+ - [Kimi on Model Studio](https://help.aliyun.com/en/model-studio/kimi-api): `kimi-k3`.
91
+
92
+ Unknown context/output limits and prices for new entries remain unset; the selector
93
+ does not infer them from model age or the provider default.
94
+
95
+ Kimi K3 has an application-side compatibility restriction: current official Model
96
+ Studio documentation requires Chat Completions and thinking-only mode. The harness
97
+ uses that transport and offers only default reasoning for this entry, rather than
98
+ exposing the broader levels/Responses route in the installed SDK snapshot. Explicit
99
+ incompatible overrides fail before sending a request.
package/docs/README.md CHANGED
@@ -20,6 +20,7 @@ Start with [First use](FIRST_USE.md). You only need `zhx` for everyday conversat
20
20
  - [Extensibility](EXTENSIBILITY.md): providers, MCP, routing and subagents.
21
21
  - [API stability](STABILITY.md) and [deprecations](DEPRECATIONS.md).
22
22
  - [Local service](LOCAL_SERVICE.md) and [client protocol](CLIENT_PROTOCOL.md).
23
+ - [Experimental ACP text sessions](ACP.md) and [workspace checkpoint restoration](WORKSPACE_CHECKPOINTS.md).
23
24
  - [Durable operations](DURABLE_OPERATIONS.md), [repository editing](REPOSITORY_EDITING.md) and [change envelopes](CHANGE_ENVELOPES.md).
24
25
  - [Threat model](THREAT_MODEL.md) and [public repository security](PUBLIC_SECURITY.md).
25
26