@zhivex-ai/harness 1.2.0-rc.8 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +7 -7
  3. package/contracts/public-api.json +5 -0
  4. package/contracts/stable-api-signatures.json +28 -28
  5. package/dist/acp-cli.js +1096 -609
  6. package/dist/cli/arguments.d.ts +2 -0
  7. package/dist/cli/cli-credentials.d.ts +1 -1
  8. package/dist/cli/cli-options.d.ts +1 -1
  9. package/dist/cli/cli-profiles.d.ts +15 -0
  10. package/dist/cli/cli-stream.d.ts +3 -3
  11. package/dist/cli/console/console-commands.d.ts +3 -3
  12. package/dist/cli/console/console-input.d.ts +22 -3
  13. package/dist/cli/console/console-navigation.d.ts +3 -0
  14. package/dist/cli/console/console-presentation.d.ts +8 -2
  15. package/dist/cli/console/console-reasoning.d.ts +3 -0
  16. package/dist/cli/presentation.d.ts +3 -0
  17. package/dist/cli/run-document.d.ts +4 -4
  18. package/dist/cli/terminal/activity-history.d.ts +15 -0
  19. package/dist/cli/terminal/tool-activity.d.ts +11 -1
  20. package/dist/{cli-7nj89dq0.js → cli-3jmy4h5h.js} +385 -217
  21. package/dist/{cli-entry-t3bay5k5.js → cli-entry-427869g9.js} +287 -180
  22. package/dist/{cli-entry-0mhbpe8j.js → cli-entry-b1mfvmxe.js} +2 -1
  23. package/dist/{cli-entry-hkxakkng.js → cli-entry-c2f58zj2.js} +998 -210
  24. package/dist/cli.js +2 -2
  25. package/dist/client/json-contracts.d.ts +20 -0
  26. package/dist/{config-w1npe8mp.js → config-1k9t4jhh.js} +1 -1
  27. package/dist/context/compaction.d.ts +1 -1
  28. package/dist/context/semantic-compaction.d.ts +1 -1
  29. package/dist/context/task-memory.d.ts +2 -2
  30. package/dist/hostile-repository-demo.js +950 -509
  31. package/dist/index.js +1803 -1132
  32. package/dist/persistence/operations.d.ts +5 -1
  33. package/dist/persistence/state-backup-stream.d.ts +4 -0
  34. package/dist/providers/meta-replay.d.ts +1 -1
  35. package/dist/providers/qwen-context.d.ts +2 -0
  36. package/dist/providers/qwen-hosted-policy.d.ts +5 -0
  37. package/dist/providers/reasoning.d.ts +18 -0
  38. package/dist/runtime/config.d.ts +3 -0
  39. package/dist/runtime/error-diagnostics.d.ts +2 -0
  40. package/dist/runtime/harness.d.ts +1 -1
  41. package/dist/runtime/model-edit-references.d.ts +4 -2
  42. package/dist/runtime/progress-monitor.d.ts +6 -2
  43. package/dist/runtime/runtime-policy.d.ts +5 -4
  44. package/dist/runtime/time-to-safe-fix.d.ts +6 -1
  45. package/dist/service-cli.js +1112 -639
  46. package/dist/{service-client-cli-s3ee2hrj.js → service-client-cli-yx56n0hc.js} +66 -8
  47. package/dist/tools/dependency-read.d.ts +51 -4
  48. package/dist/tools/execution.d.ts +8 -8
  49. package/dist/tools/workspace.d.ts +27 -16
  50. package/dist/verify-historical-migrations.js +1122 -638
  51. package/dist/workspace/file-security.d.ts +6 -0
  52. package/dist/zhx.js +2 -2
  53. package/docs/CLI.md +75 -23
  54. package/docs/CONTEXT_ENGINEERING.md +25 -5
  55. package/docs/DURABLE_OPERATIONS.md +8 -0
  56. package/docs/EXTENSIBILITY.md +1 -1
  57. package/docs/FIRST_USE.md +6 -6
  58. package/docs/MODEL_CATALOG.md +28 -1
  59. package/evaluations/representative-assembly-matrix.json +55 -1
  60. package/evaluations/representative-repositories-v2.jsonl +7 -0
  61. package/examples/README.md +4 -4
  62. package/package.json +7 -7
@@ -1,126 +1,39 @@
1
- // src/runtime/config.ts
2
- import { createHash as createHash2 } from "node:crypto";
3
- import { realpathSync } from "node:fs";
4
- import path from "node:path";
1
+ // src/providers/reasoning.ts
2
+ import { z as z2 } from "zod";
3
+ import { wrapLanguageModel as wrapLanguageModel4 } from "@zhivex-ai/core";
5
4
 
6
- // src/runtime/errors.ts
7
- var HARNESS_ERROR_CODES = [
8
- "CONFIG_INVALID",
9
- "CLI_USAGE_INVALID",
10
- "WORKSPACE_UNSAFE",
11
- "STATE_CONFLICT",
12
- "PROVIDER_UNAVAILABLE",
13
- "APPROVAL_REQUIRED",
14
- "EXECUTION_FAILED"
15
- ];
16
- var HARNESS_ERROR_SCHEMA_VERSION = 1;
17
-
18
- class HarnessError extends Error {
19
- code;
20
- category;
21
- retryable;
22
- constructor(message, options) {
23
- super(message, options.cause === undefined ? undefined : { cause: options.cause });
24
- this.name = "HarnessError";
25
- this.code = options.code;
26
- this.category = options.category;
27
- this.retryable = options.retryable ?? false;
28
- }
29
- }
30
-
31
- class HarnessConfigError extends HarnessError {
32
- constructor(message, options = {}) {
33
- super(message, {
34
- code: "CONFIG_INVALID",
35
- category: "configuration",
36
- ...options.cause === undefined ? {} : { cause: options.cause }
37
- });
38
- this.name = "HarnessConfigError";
39
- }
40
- }
41
-
42
- class HarnessWorkspaceError extends HarnessError {
43
- constructor(message, options = {}) {
44
- super(message, {
45
- code: "WORKSPACE_UNSAFE",
46
- category: "workspace",
47
- ...options.cause === undefined ? {} : { cause: options.cause }
48
- });
49
- this.name = "HarnessWorkspaceError";
50
- }
51
- }
52
-
53
- class HarnessStateConflictError extends HarnessError {
54
- constructor(message, options = {}) {
55
- super(message, {
56
- code: "STATE_CONFLICT",
57
- category: "state",
58
- retryable: options.retryable ?? false,
59
- ...options.cause === undefined ? {} : { cause: options.cause }
60
- });
61
- this.name = "HarnessStateConflictError";
62
- }
63
- }
64
-
65
- class HarnessProviderError extends HarnessError {
66
- constructor(message, options = {}) {
67
- super(message, {
68
- code: "PROVIDER_UNAVAILABLE",
69
- category: "provider",
70
- retryable: options.retryable ?? true,
71
- ...options.cause === undefined ? {} : { cause: options.cause }
72
- });
73
- this.name = "HarnessProviderError";
74
- }
75
- }
76
- class HarnessExecutionError extends HarnessError {
77
- constructor(message, options = {}) {
78
- super(message, {
79
- code: "EXECUTION_FAILED",
80
- category: "execution",
81
- retryable: options.retryable ?? false,
82
- ...options.cause === undefined ? {} : { cause: options.cause }
83
- });
84
- this.name = "HarnessExecutionError";
85
- }
86
- }
87
- var harnessErrorDocument = (error) => {
88
- const normalized = normalizeHarnessError(error);
89
- return {
90
- schemaVersion: HARNESS_ERROR_SCHEMA_VERSION,
91
- kind: "error",
92
- error: {
93
- code: normalized.code,
94
- category: normalized.category,
95
- retryable: normalized.retryable
5
+ // src/providers/qwen-hosted-policy.ts
6
+ import { wrapLanguageModel } from "@zhivex-ai/core";
7
+ function withQwenHostedPolicy(model) {
8
+ if (model.modelId !== "kimi-k3")
9
+ return model;
10
+ const prepare = (input) => {
11
+ const options = input.providerOptions ?? {};
12
+ if (options.apiMode && !["auto", "chat"].includes(String(options.apiMode)))
13
+ throw new Error("Kimi K3 on Model Studio requires Chat Completions.");
14
+ if (input.reasoning?.effort !== undefined || input.reasoning?.budgetTokens !== undefined || options.reasoning_effort !== undefined || options.thinking_budget !== undefined || options.enable_thinking === false) {
15
+ throw new Error("Kimi K3 on Model Studio currently supports default thinking only.");
96
16
  }
17
+ input.providerOptions = { ...options, apiMode: "chat", enable_thinking: true };
97
18
  };
98
- };
99
- var numericStatuses = (error) => {
100
- if (!error || typeof error !== "object")
101
- return;
102
- const record = error;
103
- const values = [record.status, record.statusCode].filter((value) => typeof value === "number" && Number.isSafeInteger(value));
104
- return values.length > 0 ? values : undefined;
105
- };
106
- var normalizeHarnessError = (error) => {
107
- if (error instanceof HarnessError)
108
- return error;
109
- const message = error instanceof Error ? error.message : "Harness execution failed.";
110
- const statuses = numericStatuses(error) ?? [];
111
- if (statuses.some((status) => status === 429 || status >= 500 && status <= 599)) {
112
- return new HarnessProviderError(message, { cause: error, retryable: true });
113
- }
114
- const name = error && typeof error === "object" && typeof error.name === "string" ? error.name : "";
115
- const code = error && typeof error === "object" && typeof error.code === "string" ? error.code : "";
116
- if (name === "ConflictError" || code === "SQLITE_BUSY" || code === "SQLITE_LOCKED") {
117
- return new HarnessStateConflictError(message, {
118
- cause: error,
119
- retryable: code === "SQLITE_BUSY" || code === "SQLITE_LOCKED"
120
- });
121
- }
122
- return new HarnessExecutionError(message, { cause: error });
123
- };
19
+ const wrapped = wrapLanguageModel(model, [{
20
+ name: "harness-kimi-k3-chat-thinking-v1",
21
+ async wrapGenerate(context, next) {
22
+ prepare(context.input);
23
+ return next();
24
+ },
25
+ async wrapStream(context, next) {
26
+ prepare(context.input);
27
+ return next();
28
+ }
29
+ }]);
30
+ return { ...wrapped, capabilities: {
31
+ ...wrapped.capabilities,
32
+ reasoningEfforts: [],
33
+ webSearch: false,
34
+ ...wrapped.capabilities.agentCapabilities ? { agentCapabilities: { ...wrapped.capabilities.agentCapabilities, hostedWebSearch: false, codeExecution: false, webExtraction: false } } : {}
35
+ } };
36
+ }
124
37
 
125
38
  // src/providers/meta-continuation.ts
126
39
  import { setTimeout as delay } from "node:timers/promises";
@@ -185,7 +98,7 @@ var createMetaContinuationFetch = (fetcher = fetch, backoff = [1000, 2000]) => {
185
98
  };
186
99
 
187
100
  // src/providers/meta-replay.ts
188
- import { wrapLanguageModel } from "@zhivex-ai/core";
101
+ import { wrapLanguageModel as wrapLanguageModel2 } from "@zhivex-ai/core";
189
102
  import { createMeta } from "@zhivex-ai/meta";
190
103
  var replayPlan = (messages) => {
191
104
  let offset = 0;
@@ -251,7 +164,7 @@ var createMetaReplayModel = (options, modelId) => {
251
164
  } }
252
165
  };
253
166
  };
254
- return wrapLanguageModel(createMeta(options)(modelId), [{
167
+ return wrapLanguageModel2(createMeta(options)(modelId), [{
255
168
  name: "harness-meta-stateless-replay-v1",
256
169
  async wrapGenerate({ input }) {
257
170
  const prepared = prepare(input);
@@ -296,7 +209,7 @@ import { z } from "zod";
296
209
  // src/models/catalog.json
297
210
  var catalog_default = {
298
211
  schemaVersion: 1,
299
- revision: "2026-09-24.1",
212
+ revision: "2026-09-26-frontier",
300
213
  providers: [
301
214
  {
302
215
  id: "openai",
@@ -430,7 +343,7 @@ var catalog_default = {
430
343
  {
431
344
  id: "gpt-5.6-sol",
432
345
  name: "gpt-5.6-sol",
433
- group: "primary",
346
+ group: "other",
434
347
  order: 3,
435
348
  lifecycle: "unknown",
436
349
  validation: "unverified",
@@ -442,7 +355,7 @@ var catalog_default = {
442
355
  {
443
356
  id: "gpt-5.6-terra",
444
357
  name: "gpt-5.6-terra",
445
- group: "primary",
358
+ group: "other",
446
359
  order: 4,
447
360
  lifecycle: "unknown",
448
361
  validation: "unverified",
@@ -454,7 +367,7 @@ var catalog_default = {
454
367
  {
455
368
  id: "gpt-5.6-luna",
456
369
  name: "gpt-5.6-luna",
457
- group: "primary",
370
+ group: "other",
458
371
  order: 5,
459
372
  lifecycle: "unknown",
460
373
  validation: "unverified",
@@ -550,34 +463,10 @@ var catalog_default = {
550
463
  defaultModel: "qwen3.8-max",
551
464
  models: [
552
465
  {
553
- id: "qwen3.8-omni-flash",
554
- name: "qwen3.8-omni-flash",
555
- group: "other",
556
- order: 0,
557
- lifecycle: "unknown",
558
- validation: "unverified",
559
- capabilities: [
560
- "chat",
561
- "tools"
562
- ]
563
- },
564
- {
565
- id: "qwen3.8-max-0902",
566
- name: "qwen3.8-max-0902",
567
- group: "other",
568
- order: 1,
569
- lifecycle: "unknown",
570
- validation: "unverified",
571
- capabilities: [
572
- "chat",
573
- "tools"
574
- ]
575
- },
576
- {
577
- id: "qwen3.8-max",
578
- name: "qwen3.8-max",
466
+ id: "qwen3.8-flash",
467
+ name: "qwen3.8-flash",
579
468
  group: "primary",
580
- order: 2,
469
+ order: 0,
581
470
  lifecycle: "unknown",
582
471
  validation: "unverified",
583
472
  capabilities: [
@@ -590,7 +479,7 @@ var catalog_default = {
590
479
  maxOutputTokens: 131072,
591
480
  maxInputTokens: 983616,
592
481
  evidence: {
593
- sourceUrl: "https://www.alibabacloud.com/help/en/model-studio/qwen3-8-max",
482
+ sourceUrl: "https://www.alibabacloud.com/help/en/model-studio/qwen3-8-flash",
594
483
  checkedAt: "2026-09-24"
595
484
  }
596
485
  },
@@ -598,16 +487,16 @@ var catalog_default = {
598
487
  suitability: "candidate",
599
488
  reason: "Editorial candidate based on documented text generation. Conservative thinking-mode input limit; summary fidelity has not been benchmarked.",
600
489
  evidence: {
601
- sourceUrl: "https://www.alibabacloud.com/help/en/model-studio/qwen3-8-max",
490
+ sourceUrl: "https://www.alibabacloud.com/help/en/model-studio/qwen3-8-flash",
602
491
  checkedAt: "2026-09-24"
603
492
  }
604
493
  }
605
494
  },
606
495
  {
607
- id: "qwen3.8-flash",
608
- name: "qwen3.8-flash",
609
- group: "other",
610
- order: 3,
496
+ id: "qwen3.8-max",
497
+ name: "qwen3.8-max",
498
+ group: "primary",
499
+ order: 1,
611
500
  lifecycle: "unknown",
612
501
  validation: "unverified",
613
502
  capabilities: [
@@ -620,7 +509,7 @@ var catalog_default = {
620
509
  maxOutputTokens: 131072,
621
510
  maxInputTokens: 983616,
622
511
  evidence: {
623
- sourceUrl: "https://www.alibabacloud.com/help/en/model-studio/qwen3-8-flash",
512
+ sourceUrl: "https://www.alibabacloud.com/help/en/model-studio/qwen3-8-max",
624
513
  checkedAt: "2026-09-24"
625
514
  }
626
515
  },
@@ -628,16 +517,57 @@ var catalog_default = {
628
517
  suitability: "candidate",
629
518
  reason: "Editorial candidate based on documented text generation. Conservative thinking-mode input limit; summary fidelity has not been benchmarked.",
630
519
  evidence: {
631
- sourceUrl: "https://www.alibabacloud.com/help/en/model-studio/qwen3-8-flash",
520
+ sourceUrl: "https://www.alibabacloud.com/help/en/model-studio/qwen3-8-max",
632
521
  checkedAt: "2026-09-24"
633
522
  }
634
523
  }
635
524
  },
636
525
  {
637
- id: "qwen3.8-max-preview",
638
- name: "qwen3.8-max-preview",
639
- group: "other",
526
+ id: "glm-5.3",
527
+ name: "GLM 5.3",
528
+ group: "primary",
529
+ order: 2,
530
+ lifecycle: "active",
531
+ validation: "unverified",
532
+ capabilities: [
533
+ "chat",
534
+ "tools"
535
+ ],
536
+ reason: "Zhipu model served by Alibaba Model Studio; region and account access vary"
537
+ },
538
+ {
539
+ id: "deepseek-v4.1-flash",
540
+ name: "DeepSeek V4.1 Flash",
541
+ group: "primary",
542
+ order: 3,
543
+ lifecycle: "active",
544
+ validation: "unverified",
545
+ capabilities: [
546
+ "chat",
547
+ "tools",
548
+ "vision"
549
+ ],
550
+ reason: "DeepSeek model served by Alibaba Model Studio; region and account access vary"
551
+ },
552
+ {
553
+ id: "kimi-k3",
554
+ name: "Kimi K3",
555
+ group: "primary",
640
556
  order: 4,
557
+ lifecycle: "active",
558
+ validation: "unverified",
559
+ capabilities: [
560
+ "chat",
561
+ "tools",
562
+ "vision"
563
+ ],
564
+ reason: "Moonshot model served by Alibaba Model Studio; region and account access vary"
565
+ },
566
+ {
567
+ id: "qwen3.7-plus",
568
+ name: "qwen3.7-plus",
569
+ group: "primary",
570
+ order: 5,
641
571
  lifecycle: "unknown",
642
572
  validation: "unverified",
643
573
  capabilities: [
@@ -646,10 +576,10 @@ var catalog_default = {
646
576
  ]
647
577
  },
648
578
  {
649
- id: "qwen3.7-max",
650
- name: "qwen3.7-max",
579
+ id: "qwen3.8-omni-flash",
580
+ name: "qwen3.8-omni-flash",
651
581
  group: "other",
652
- order: 5,
582
+ order: 6,
653
583
  lifecycle: "unknown",
654
584
  validation: "unverified",
655
585
  capabilities: [
@@ -658,10 +588,34 @@ var catalog_default = {
658
588
  ]
659
589
  },
660
590
  {
661
- id: "qwen3.7-plus",
662
- name: "qwen3.7-plus",
591
+ id: "qwen3.8-max-0902",
592
+ name: "qwen3.8-max-0902",
663
593
  group: "other",
664
- order: 6,
594
+ order: 7,
595
+ lifecycle: "unknown",
596
+ validation: "unverified",
597
+ capabilities: [
598
+ "chat",
599
+ "tools"
600
+ ]
601
+ },
602
+ {
603
+ id: "qwen3.8-max-preview",
604
+ name: "qwen3.8-max-preview",
605
+ group: "other",
606
+ order: 8,
607
+ lifecycle: "unknown",
608
+ validation: "unverified",
609
+ capabilities: [
610
+ "chat",
611
+ "tools"
612
+ ]
613
+ },
614
+ {
615
+ id: "qwen3.7-max",
616
+ name: "qwen3.7-max",
617
+ group: "other",
618
+ order: 9,
665
619
  lifecycle: "unknown",
666
620
  validation: "unverified",
667
621
  capabilities: [
@@ -673,7 +627,7 @@ var catalog_default = {
673
627
  id: "qwen3.6-flash",
674
628
  name: "qwen3.6-flash",
675
629
  group: "other",
676
- order: 7,
630
+ order: 10,
677
631
  lifecycle: "unknown",
678
632
  validation: "unverified",
679
633
  capabilities: [
@@ -685,7 +639,7 @@ var catalog_default = {
685
639
  id: "qwen3.5-omni-plus",
686
640
  name: "qwen3.5-omni-plus",
687
641
  group: "other",
688
- order: 8,
642
+ order: 11,
689
643
  lifecycle: "unknown",
690
644
  validation: "unverified",
691
645
  capabilities: [
@@ -697,7 +651,7 @@ var catalog_default = {
697
651
  id: "qwen-plus",
698
652
  name: "qwen-plus",
699
653
  group: "other",
700
- order: 9,
654
+ order: 12,
701
655
  lifecycle: "unknown",
702
656
  validation: "unverified",
703
657
  capabilities: [
@@ -1073,7 +1027,7 @@ function modelDescription(model) {
1073
1027
  // src/providers/providers.ts
1074
1028
  import { createHash } from "node:crypto";
1075
1029
  import {
1076
- wrapLanguageModel as wrapLanguageModel2
1030
+ wrapLanguageModel as wrapLanguageModel3
1077
1031
  } from "@zhivex-ai/core";
1078
1032
  import { createGemini } from "@zhivex-ai/gemini";
1079
1033
  import { createOpenAI } from "@zhivex-ai/openai";
@@ -1397,12 +1351,12 @@ var normalizeStreamToolCallIds = async function* (model, input, events) {
1397
1351
  };
1398
1352
  }
1399
1353
  };
1400
- var withQwenDurableToolCallIds = (model) => wrapLanguageModel2(model, [{
1354
+ var withQwenDurableToolCallIds = (model) => wrapLanguageModel3(model, [{
1401
1355
  name: "harness-qwen-durable-tool-call-ids",
1402
1356
  wrapGenerate: async ({ input }, next) => normalizeGenerateToolCallIds(model, input, await next()),
1403
1357
  wrapStream: async ({ input }, next) => normalizeStreamToolCallIds(model, input, await next())
1404
1358
  }]);
1405
- var withOpenAIToolResultEnvelopes = (model) => wrapLanguageModel2(model, [{
1359
+ var withOpenAIToolResultEnvelopes = (model) => wrapLanguageModel3(model, [{
1406
1360
  name: "harness-openai-tool-result-envelopes-v1",
1407
1361
  async wrapGenerate({ input }, next) {
1408
1362
  input.toolResultFormat = "envelope";
@@ -1413,7 +1367,7 @@ var withOpenAIToolResultEnvelopes = (model) => wrapLanguageModel2(model, [{
1413
1367
  return next();
1414
1368
  }
1415
1369
  }]);
1416
- var withMetaResponses = (model) => wrapLanguageModel2(model, [{
1370
+ var withMetaResponses = (model) => wrapLanguageModel3(model, [{
1417
1371
  name: "harness-meta-responses-v1",
1418
1372
  async wrapGenerate({ input }, next) {
1419
1373
  input.providerOptions = { ...input.providerOptions, apiMode: "responses" };
@@ -1474,12 +1428,12 @@ var BUILTIN_PROVIDER_REGISTRATIONS = Object.freeze([
1474
1428
  const baseURL = env.QWEN_BASE_URL?.trim();
1475
1429
  const workspaceId = env.QWEN_WORKSPACE_ID?.trim();
1476
1430
  const region = optionalQwenRegion(env.QWEN_REGION?.trim());
1477
- return withQwenDurableToolCallIds(createQwen({
1431
+ return withQwenHostedPolicy(withQwenDurableToolCallIds(createQwen({
1478
1432
  apiKey: credentials.require(),
1479
1433
  ...baseURL ? { baseURL } : {},
1480
1434
  ...workspaceId ? { workspaceId } : {},
1481
1435
  ...region ? { region } : {}
1482
- })(model));
1436
+ })(model)));
1483
1437
  }
1484
1438
  },
1485
1439
  {
@@ -1522,6 +1476,158 @@ var BUILTIN_PROVIDER_REGISTRATIONS = Object.freeze([
1522
1476
  var DEFAULT_PROVIDER_REGISTRY = createProviderRegistry(BUILTIN_PROVIDER_REGISTRATIONS);
1523
1477
  var PROVIDER_DESCRIPTORS = DEFAULT_PROVIDER_REGISTRY.descriptors;
1524
1478
 
1479
+ // src/providers/reasoning.ts
1480
+ var reasoningEffortSchema = z2.enum(["default", "none", "minimal", "low", "medium", "high", "xhigh", "max"]);
1481
+ var supportedReasoningEfforts = (capabilities) => ["default", ...capabilities.reasoning ? capabilities.reasoningEfforts ?? [] : []];
1482
+ function modelReasoningEfforts(provider, model) {
1483
+ if (!DEFAULT_PROVIDER_REGISTRY.has(provider))
1484
+ return ["default"];
1485
+ const descriptor = DEFAULT_PROVIDER_REGISTRY.descriptor(provider);
1486
+ const env = Object.fromEntries(descriptor.credentialNames.map((name) => [name, "capability-inspection-only"]));
1487
+ return supportedReasoningEfforts(DEFAULT_PROVIDER_REGISTRY.createModel({ provider, model }, env).capabilities);
1488
+ }
1489
+ function withReasoningEffort(model, value) {
1490
+ if (!value || value === "default")
1491
+ return model;
1492
+ if (!supportedReasoningEfforts(model.capabilities).includes(value))
1493
+ throw new Error(`Reasoning effort ${value} is not declared for ${model.provider}/${model.modelId}. Use default or a supported level.`);
1494
+ return wrapLanguageModel4(model, [{
1495
+ name: `harness-reasoning-${value}`,
1496
+ async wrapGenerate(context, next) {
1497
+ context.input.reasoning = { ...context.input.reasoning, effort: value };
1498
+ return next();
1499
+ },
1500
+ async wrapStream(context, next) {
1501
+ context.input.reasoning = { ...context.input.reasoning, effort: value };
1502
+ return next();
1503
+ }
1504
+ }]);
1505
+ }
1506
+
1507
+ // src/runtime/config.ts
1508
+ import { createHash as createHash2 } from "node:crypto";
1509
+ import { realpathSync } from "node:fs";
1510
+ import path from "node:path";
1511
+
1512
+ // src/runtime/errors.ts
1513
+ var HARNESS_ERROR_CODES = [
1514
+ "CONFIG_INVALID",
1515
+ "CLI_USAGE_INVALID",
1516
+ "WORKSPACE_UNSAFE",
1517
+ "STATE_CONFLICT",
1518
+ "PROVIDER_UNAVAILABLE",
1519
+ "APPROVAL_REQUIRED",
1520
+ "EXECUTION_FAILED"
1521
+ ];
1522
+ var HARNESS_ERROR_SCHEMA_VERSION = 1;
1523
+
1524
+ class HarnessError extends Error {
1525
+ code;
1526
+ category;
1527
+ retryable;
1528
+ constructor(message, options) {
1529
+ super(message, options.cause === undefined ? undefined : { cause: options.cause });
1530
+ this.name = "HarnessError";
1531
+ this.code = options.code;
1532
+ this.category = options.category;
1533
+ this.retryable = options.retryable ?? false;
1534
+ }
1535
+ }
1536
+
1537
+ class HarnessConfigError extends HarnessError {
1538
+ constructor(message, options = {}) {
1539
+ super(message, {
1540
+ code: "CONFIG_INVALID",
1541
+ category: "configuration",
1542
+ ...options.cause === undefined ? {} : { cause: options.cause }
1543
+ });
1544
+ this.name = "HarnessConfigError";
1545
+ }
1546
+ }
1547
+
1548
+ class HarnessWorkspaceError extends HarnessError {
1549
+ constructor(message, options = {}) {
1550
+ super(message, {
1551
+ code: "WORKSPACE_UNSAFE",
1552
+ category: "workspace",
1553
+ ...options.cause === undefined ? {} : { cause: options.cause }
1554
+ });
1555
+ this.name = "HarnessWorkspaceError";
1556
+ }
1557
+ }
1558
+
1559
+ class HarnessStateConflictError extends HarnessError {
1560
+ constructor(message, options = {}) {
1561
+ super(message, {
1562
+ code: "STATE_CONFLICT",
1563
+ category: "state",
1564
+ retryable: options.retryable ?? false,
1565
+ ...options.cause === undefined ? {} : { cause: options.cause }
1566
+ });
1567
+ this.name = "HarnessStateConflictError";
1568
+ }
1569
+ }
1570
+
1571
+ class HarnessProviderError extends HarnessError {
1572
+ constructor(message, options = {}) {
1573
+ super(message, {
1574
+ code: "PROVIDER_UNAVAILABLE",
1575
+ category: "provider",
1576
+ retryable: options.retryable ?? true,
1577
+ ...options.cause === undefined ? {} : { cause: options.cause }
1578
+ });
1579
+ this.name = "HarnessProviderError";
1580
+ }
1581
+ }
1582
+ class HarnessExecutionError extends HarnessError {
1583
+ constructor(message, options = {}) {
1584
+ super(message, {
1585
+ code: "EXECUTION_FAILED",
1586
+ category: "execution",
1587
+ retryable: options.retryable ?? false,
1588
+ ...options.cause === undefined ? {} : { cause: options.cause }
1589
+ });
1590
+ this.name = "HarnessExecutionError";
1591
+ }
1592
+ }
1593
+ var harnessErrorDocument = (error) => {
1594
+ const normalized = normalizeHarnessError(error);
1595
+ return {
1596
+ schemaVersion: HARNESS_ERROR_SCHEMA_VERSION,
1597
+ kind: "error",
1598
+ error: {
1599
+ code: normalized.code,
1600
+ category: normalized.category,
1601
+ retryable: normalized.retryable
1602
+ }
1603
+ };
1604
+ };
1605
+ var numericStatuses = (error) => {
1606
+ if (!error || typeof error !== "object")
1607
+ return;
1608
+ const record = error;
1609
+ const values = [record.status, record.statusCode].filter((value) => typeof value === "number" && Number.isSafeInteger(value));
1610
+ return values.length > 0 ? values : undefined;
1611
+ };
1612
+ var normalizeHarnessError = (error) => {
1613
+ if (error instanceof HarnessError)
1614
+ return error;
1615
+ const message = error instanceof Error ? error.message : "Harness execution failed.";
1616
+ const statuses = numericStatuses(error) ?? [];
1617
+ if (statuses.some((status) => status === 429 || status >= 500 && status <= 599)) {
1618
+ return new HarnessProviderError(message, { cause: error, retryable: true });
1619
+ }
1620
+ const name = error && typeof error === "object" && typeof error.name === "string" ? error.name : "";
1621
+ const code = error && typeof error === "object" && typeof error.code === "string" ? error.code : "";
1622
+ if (name === "ConflictError" || code === "SQLITE_BUSY" || code === "SQLITE_LOCKED") {
1623
+ return new HarnessStateConflictError(message, {
1624
+ cause: error,
1625
+ retryable: code === "SQLITE_BUSY" || code === "SQLITE_LOCKED"
1626
+ });
1627
+ }
1628
+ return new HarnessExecutionError(message, { cause: error });
1629
+ };
1630
+
1525
1631
  // src/runtime/config.ts
1526
1632
  var DEFAULT_ALLOWED_CHECKS = ["test", "typecheck", "lint", "build"];
1527
1633
  var HARNESS_CONFIG_SCHEMA_VERSION = 5;
@@ -1857,6 +1963,7 @@ var resolveHarnessConfig = (input = {}, registry = DEFAULT_PROVIDER_REGISTRY) =>
1857
1963
  schemaVersion: HARNESS_CONFIG_SCHEMA_VERSION,
1858
1964
  provider,
1859
1965
  model: input.model ?? process.env.ZHIVEX_HARNESS_MODEL ?? descriptor.defaultModel,
1966
+ ...input.reasoningEffort === undefined || input.reasoningEffort === "default" ? {} : { reasoningEffort: reasoningEffortSchema.parse(input.reasoningEffort) },
1860
1967
  workspace,
1861
1968
  stateDirectory: canonicalStateDirectory(requestedWorkspace, workspace, input.stateDirectory),
1862
1969
  storeBackend,
@@ -1899,4 +2006,4 @@ var createProviderModel = (config, env = process.env, registry = DEFAULT_PROVIDE
1899
2006
  }
1900
2007
  };
1901
2008
  var providerAvailability = (env = process.env, registry = DEFAULT_PROVIDER_REGISTRY) => registry.availability(env);
1902
- export { HARNESS_ERROR_CODES, HARNESS_ERROR_SCHEMA_VERSION, HarnessError, HarnessConfigError, HarnessWorkspaceError, HarnessStateConflictError, HarnessProviderError, HarnessExecutionError, harnessErrorDocument, normalizeHarnessError, modelCatalogSchema, bundledModelCatalog, catalogModels, modelDescription, PROVIDERS, createProviderRegistry, BUILTIN_PROVIDER_REGISTRATIONS, DEFAULT_PROVIDER_REGISTRY, PROVIDER_DESCRIPTORS, DEFAULT_ALLOWED_CHECKS, HARNESS_CONFIG_SCHEMA_VERSION, HARNESS_CONFIG_MIGRATABLE_SCHEMA_VERSIONS, HARNESS_STORE_BACKENDS, HARNESS_EXECUTION_BACKENDS, HARNESS_OCI_RUNTIMES, HARNESS_OCI_SHELL_MODES, HARNESS_EXECUTION_POLICY_VERSION, DEFAULT_OCI_EXECUTION, HARNESS_REQUIRED_CAPABILITIES, HARNESS_SUBAGENT_PROFILES, DEFAULT_HARNESS_MAX_STEPS, DEFAULT_HARNESS_BUDGET, DEFAULT_HARNESS_COMPACTION, DEFAULT_SUBAGENT_BUDGET, migrateHarnessConfigInput, defaultHarnessNamespace, parseProvider, providerDescriptor, resolveHarnessConfig, createProviderModel, providerAvailability };
2009
+ export { HARNESS_ERROR_CODES, HARNESS_ERROR_SCHEMA_VERSION, HarnessError, HarnessConfigError, HarnessWorkspaceError, HarnessStateConflictError, HarnessProviderError, HarnessExecutionError, harnessErrorDocument, normalizeHarnessError, modelCatalogSchema, bundledModelCatalog, catalogModels, modelDescription, PROVIDERS, createProviderRegistry, BUILTIN_PROVIDER_REGISTRATIONS, DEFAULT_PROVIDER_REGISTRY, PROVIDER_DESCRIPTORS, reasoningEffortSchema, modelReasoningEfforts, withReasoningEffort, DEFAULT_ALLOWED_CHECKS, HARNESS_CONFIG_SCHEMA_VERSION, HARNESS_CONFIG_MIGRATABLE_SCHEMA_VERSIONS, HARNESS_STORE_BACKENDS, HARNESS_EXECUTION_BACKENDS, HARNESS_OCI_RUNTIMES, HARNESS_OCI_SHELL_MODES, HARNESS_EXECUTION_POLICY_VERSION, DEFAULT_OCI_EXECUTION, HARNESS_REQUIRED_CAPABILITIES, HARNESS_SUBAGENT_PROFILES, DEFAULT_HARNESS_MAX_STEPS, DEFAULT_HARNESS_BUDGET, DEFAULT_HARNESS_COMPACTION, DEFAULT_SUBAGENT_BUDGET, migrateHarnessConfigInput, defaultHarnessNamespace, parseProvider, providerDescriptor, resolveHarnessConfig, createProviderModel, providerAvailability };
@@ -29,6 +29,7 @@ var CLI_OPTION_NAMES = [
29
29
  "--compaction-provider",
30
30
  "--provider",
31
31
  "--model",
32
+ "--reasoning",
32
33
  "--profile",
33
34
  "--route",
34
35
  "--workspace",
@@ -112,7 +113,7 @@ var CLI_OPTION_DEFINITIONS = Object.fromEntries(CLI_OPTION_NAMES.map((name) => [
112
113
  conflictsWith: conflicts[name] ?? []
113
114
  }]));
114
115
  var locator = ["--workspace", "--state-dir", "--store", "--tenant", "--user", "--namespace"];
115
- var provider = ["--provider", "--model"];
116
+ var provider = ["--provider", "--model", "--reasoning"];
116
117
  var profile = ["--profile"];
117
118
  var project = ["--mcp-config", "--context-config", "--no-project-context"];
118
119
  var execution = [