@zhivex-ai/harness 1.2.0 → 1.3.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +7 -8
- package/contracts/engine-api.json +2587 -0
- package/dist/acp-cli.js +95 -14996
- package/dist/cli/cli-options.d.ts +2 -41
- package/dist/cli/cli-stream.d.ts +2 -167
- package/dist/cli/run-document.d.ts +2 -91
- package/dist/cli/terminal/terminal-continuation.d.ts +2 -3
- package/dist/{cli-entry-427869g9.js → cli-entry-0mmeag20.js} +49 -1
- package/dist/{cli-entry-b1mfvmxe.js → cli-entry-7h9savv5.js} +1 -2
- package/dist/{cli-entry-c2f58zj2.js → cli-entry-xmf48p6a.js} +27 -18
- package/dist/{cli-3jmy4h5h.js → cli-qgwvtk0w.js} +5 -6
- package/dist/cli.js +2 -2
- package/dist/client/continuation.d.ts +3 -0
- package/dist/client/run-document.d.ts +91 -0
- package/dist/client/stream.d.ts +167 -0
- package/dist/compat/cli-options.d.ts +41 -0
- package/dist/compat/code-support.d.ts +22 -0
- package/dist/compat/code-support.js +138 -0
- package/dist/config-6gtpxvjv.js +59 -0
- package/dist/{config-1k9t4jhh.js → config-q32jm1e6.js} +1 -1
- package/dist/engine/acp.d.ts +4 -0
- package/dist/engine/acp.js +9 -0
- package/dist/engine/client.d.ts +6 -0
- package/dist/engine/client.js +21 -0
- package/dist/engine/index.d.ts +61 -0
- package/dist/engine/index.js +477 -0
- package/dist/engine/protocol.d.ts +6 -0
- package/dist/engine/protocol.js +158 -0
- package/dist/engine/service.d.ts +5 -0
- package/dist/engine/service.js +21 -0
- package/dist/hostile-repository-demo.js +59 -1
- package/dist/index-1bx83sw4.js +4 -0
- package/dist/index-2aymdsqc.js +150 -0
- package/dist/index-41fkzt91.js +293 -0
- package/dist/index-5wjwe91x.js +9434 -0
- package/dist/index-77h9qr5h.js +326 -0
- package/dist/index-d0wrghff.js +3271 -0
- package/dist/index-f4sb0e2q.js +318 -0
- package/dist/index-fvca1xea.js +2069 -0
- package/dist/index-kfgt9yqq.js +526 -0
- package/dist/index-pgqz45fj.js +2449 -0
- package/dist/index.js +238 -18649
- package/dist/service-cli.js +10 -14502
- package/dist/{service-client-cli-yx56n0hc.js → service-client-cli-gs78wrxe.js} +2 -2
- package/dist/verify-historical-migrations.js +59 -1
- package/dist/zhx.js +2 -2
- package/docs/CODE_RELEASE.md +93 -0
- package/docs/ENGINE_API.md +111 -0
- package/docs/FIRST_USE.md +6 -6
- package/docs/README.md +5 -0
- package/docs/STABILITY.md +6 -0
- package/evaluations/representative-assembly-matrix.json +28 -1
- package/examples/README.md +1 -1
- package/package.json +35 -4
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_PROVIDER_REGISTRY,
|
|
3
|
+
HARNESS_SUBAGENT_PROFILES
|
|
4
|
+
} from "./index-fvca1xea.js";
|
|
5
|
+
|
|
6
|
+
// src/providers/routing.ts
|
|
7
|
+
var routeError = (value) => new Error(`Invalid route: ${value}. Use <profile>=<provider>[:<model>].`);
|
|
8
|
+
var parseHarnessModelRoute = (value, registry = DEFAULT_PROVIDER_REGISTRY) => {
|
|
9
|
+
const separator = value.indexOf("=");
|
|
10
|
+
if (separator <= 0 || separator === value.length - 1) {
|
|
11
|
+
throw routeError(value);
|
|
12
|
+
}
|
|
13
|
+
const profile = value.slice(0, separator).trim().toLowerCase();
|
|
14
|
+
if (!HARNESS_SUBAGENT_PROFILES.includes(profile)) {
|
|
15
|
+
throw routeError(value);
|
|
16
|
+
}
|
|
17
|
+
const target = value.slice(separator + 1).trim();
|
|
18
|
+
const modelSeparator = target.indexOf(":");
|
|
19
|
+
const providerInput = (modelSeparator === -1 ? target : target.slice(0, modelSeparator)).trim();
|
|
20
|
+
const provider = registry.parse(providerInput);
|
|
21
|
+
const configuredModel = modelSeparator === -1 ? "" : target.slice(modelSeparator + 1).trim();
|
|
22
|
+
if (modelSeparator !== -1 && !configuredModel) {
|
|
23
|
+
throw routeError(value);
|
|
24
|
+
}
|
|
25
|
+
const model = configuredModel || registry.descriptor(provider).defaultModel;
|
|
26
|
+
if (/[\u0000-\u001f\u007f]/.test(model) || model.length > 256) {
|
|
27
|
+
throw routeError(value);
|
|
28
|
+
}
|
|
29
|
+
return Object.freeze({
|
|
30
|
+
profile,
|
|
31
|
+
provider,
|
|
32
|
+
model
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
var resolveHarnessModelRoutes = (values = [], registry = DEFAULT_PROVIDER_REGISTRY) => {
|
|
36
|
+
const routes = new Map;
|
|
37
|
+
for (const value of values) {
|
|
38
|
+
const route = parseHarnessModelRoute(value, registry);
|
|
39
|
+
if (routes.has(route.profile)) {
|
|
40
|
+
throw new Error(`Duplicate model route for ${route.profile}.`);
|
|
41
|
+
}
|
|
42
|
+
routes.set(route.profile, route);
|
|
43
|
+
}
|
|
44
|
+
return routes;
|
|
45
|
+
};
|
|
46
|
+
var createHarnessRouteModels = (routes, env = process.env, registry = DEFAULT_PROVIDER_REGISTRY) => Object.fromEntries([...routes].map(([profile, route]) => [
|
|
47
|
+
profile,
|
|
48
|
+
registry.createModel(route, env)
|
|
49
|
+
]));
|
|
50
|
+
var serializeHarnessModelRoutes = (routes) => Object.fromEntries([...routes].map(([profile, route]) => [
|
|
51
|
+
profile,
|
|
52
|
+
{ provider: route.provider, model: route.model }
|
|
53
|
+
]));
|
|
54
|
+
|
|
55
|
+
// src/compat/cli-options.ts
|
|
56
|
+
var repeatableOptions = new Set([
|
|
57
|
+
"--route",
|
|
58
|
+
"--oci-allow-command",
|
|
59
|
+
"--allow-check",
|
|
60
|
+
"--require-capability",
|
|
61
|
+
"--subagent",
|
|
62
|
+
"--reviewer",
|
|
63
|
+
"--status"
|
|
64
|
+
]);
|
|
65
|
+
var conflicts = {
|
|
66
|
+
"--approval-mode": ["--yes"],
|
|
67
|
+
"--yes": ["--approval-mode"],
|
|
68
|
+
"--token-budget": ["--no-token-budget"],
|
|
69
|
+
"--no-token-budget": ["--token-budget"],
|
|
70
|
+
"--usage-limit-usd": ["--max-cost-usd", "--input-cost-per-million", "--output-cost-per-million"],
|
|
71
|
+
"--max-cost-usd": ["--usage-limit-usd"],
|
|
72
|
+
"--input-cost-per-million": ["--usage-limit-usd"],
|
|
73
|
+
"--output-cost-per-million": ["--usage-limit-usd"],
|
|
74
|
+
"--json": ["--jsonl"],
|
|
75
|
+
"--jsonl": ["--json"],
|
|
76
|
+
"--session": ["--continue"],
|
|
77
|
+
"--continue": ["--session"],
|
|
78
|
+
"--approve": ["--deny"],
|
|
79
|
+
"--deny": ["--approve"]
|
|
80
|
+
};
|
|
81
|
+
var CLI_OPTION_NAMES = [
|
|
82
|
+
"--compaction-model",
|
|
83
|
+
"--compaction-provider",
|
|
84
|
+
"--provider",
|
|
85
|
+
"--model",
|
|
86
|
+
"--reasoning",
|
|
87
|
+
"--profile",
|
|
88
|
+
"--route",
|
|
89
|
+
"--workspace",
|
|
90
|
+
"--state-dir",
|
|
91
|
+
"--mcp-config",
|
|
92
|
+
"--context-config",
|
|
93
|
+
"--no-project-context",
|
|
94
|
+
"--patch",
|
|
95
|
+
"--preconditions",
|
|
96
|
+
"--now",
|
|
97
|
+
"--require-verified-delivery",
|
|
98
|
+
"--execution",
|
|
99
|
+
"--oci-runtime",
|
|
100
|
+
"--oci-image",
|
|
101
|
+
"--oci-allow-command",
|
|
102
|
+
"--oci-shell",
|
|
103
|
+
"--oci-max-process-runtime-ms",
|
|
104
|
+
"--oci-max-process-output-bytes",
|
|
105
|
+
"--oci-max-memory-mb",
|
|
106
|
+
"--oci-max-pids",
|
|
107
|
+
"--oci-max-cpus",
|
|
108
|
+
"--oci-max-workspace-bytes",
|
|
109
|
+
"--oci-max-file-write-bytes",
|
|
110
|
+
"--oci-tmpfs-mb",
|
|
111
|
+
"--store",
|
|
112
|
+
"--tenant",
|
|
113
|
+
"--user",
|
|
114
|
+
"--namespace",
|
|
115
|
+
"--idempotency-key",
|
|
116
|
+
"--token-budget",
|
|
117
|
+
"--context-tokens",
|
|
118
|
+
"--no-token-budget",
|
|
119
|
+
"--max-steps",
|
|
120
|
+
"--timeout-ms",
|
|
121
|
+
"--max-tool-calls",
|
|
122
|
+
"--max-tool-errors",
|
|
123
|
+
"--max-input-tokens",
|
|
124
|
+
"--max-output-tokens",
|
|
125
|
+
"--max-total-tokens",
|
|
126
|
+
"--subagent-max-steps",
|
|
127
|
+
"--subagent-max-tool-calls",
|
|
128
|
+
"--subagent-max-tool-errors",
|
|
129
|
+
"--subagent-max-input-tokens",
|
|
130
|
+
"--subagent-max-output-tokens",
|
|
131
|
+
"--subagent-max-total-tokens",
|
|
132
|
+
"--subagent-timeout-ms",
|
|
133
|
+
"--max-parallel-reviews",
|
|
134
|
+
"--max-cost-usd",
|
|
135
|
+
"--input-cost-per-million",
|
|
136
|
+
"--output-cost-per-million",
|
|
137
|
+
"--allow-check",
|
|
138
|
+
"--require-capability",
|
|
139
|
+
"--subagent",
|
|
140
|
+
"--reviewer",
|
|
141
|
+
"--approval-mode",
|
|
142
|
+
"--yes",
|
|
143
|
+
"--approve",
|
|
144
|
+
"--deny",
|
|
145
|
+
"--json",
|
|
146
|
+
"--jsonl",
|
|
147
|
+
"--session",
|
|
148
|
+
"--continue",
|
|
149
|
+
"--update",
|
|
150
|
+
"--status",
|
|
151
|
+
"--limit",
|
|
152
|
+
"--cursor",
|
|
153
|
+
"--before",
|
|
154
|
+
"--reason",
|
|
155
|
+
"--cascade",
|
|
156
|
+
"--final",
|
|
157
|
+
"--service",
|
|
158
|
+
"--apply",
|
|
159
|
+
"--help",
|
|
160
|
+
"--version",
|
|
161
|
+
"--search",
|
|
162
|
+
"--pricing-file",
|
|
163
|
+
"--usage-limit-usd"
|
|
164
|
+
];
|
|
165
|
+
var CLI_OPTION_DEFINITIONS = Object.fromEntries(CLI_OPTION_NAMES.map((name) => [name, {
|
|
166
|
+
repeatable: repeatableOptions.has(name),
|
|
167
|
+
conflictsWith: conflicts[name] ?? []
|
|
168
|
+
}]));
|
|
169
|
+
var locator = ["--workspace", "--state-dir", "--store", "--tenant", "--user", "--namespace"];
|
|
170
|
+
var provider = ["--provider", "--model", "--reasoning"];
|
|
171
|
+
var profile = ["--profile"];
|
|
172
|
+
var project = ["--mcp-config", "--context-config", "--no-project-context"];
|
|
173
|
+
var execution = [
|
|
174
|
+
"--require-verified-delivery",
|
|
175
|
+
"--execution",
|
|
176
|
+
"--oci-runtime",
|
|
177
|
+
"--oci-image",
|
|
178
|
+
"--oci-allow-command",
|
|
179
|
+
"--oci-shell",
|
|
180
|
+
"--oci-max-process-runtime-ms",
|
|
181
|
+
"--oci-max-process-output-bytes",
|
|
182
|
+
"--oci-max-memory-mb",
|
|
183
|
+
"--oci-max-pids",
|
|
184
|
+
"--oci-max-cpus",
|
|
185
|
+
"--oci-max-workspace-bytes",
|
|
186
|
+
"--oci-max-file-write-bytes",
|
|
187
|
+
"--oci-tmpfs-mb"
|
|
188
|
+
];
|
|
189
|
+
var budgets = [
|
|
190
|
+
"--token-budget",
|
|
191
|
+
"--context-tokens",
|
|
192
|
+
"--no-token-budget",
|
|
193
|
+
"--max-steps",
|
|
194
|
+
"--timeout-ms",
|
|
195
|
+
"--max-tool-calls",
|
|
196
|
+
"--max-tool-errors",
|
|
197
|
+
"--max-input-tokens",
|
|
198
|
+
"--max-output-tokens",
|
|
199
|
+
"--max-total-tokens",
|
|
200
|
+
"--max-cost-usd",
|
|
201
|
+
"--input-cost-per-million",
|
|
202
|
+
"--output-cost-per-million",
|
|
203
|
+
"--subagent-max-steps",
|
|
204
|
+
"--subagent-max-tool-calls",
|
|
205
|
+
"--subagent-max-tool-errors",
|
|
206
|
+
"--subagent-max-input-tokens",
|
|
207
|
+
"--subagent-max-output-tokens",
|
|
208
|
+
"--subagent-max-total-tokens",
|
|
209
|
+
"--subagent-timeout-ms"
|
|
210
|
+
];
|
|
211
|
+
var childBudgets = [
|
|
212
|
+
"--no-token-budget",
|
|
213
|
+
"--subagent-max-steps",
|
|
214
|
+
"--subagent-max-tool-calls",
|
|
215
|
+
"--subagent-max-tool-errors",
|
|
216
|
+
"--subagent-max-input-tokens",
|
|
217
|
+
"--subagent-max-output-tokens",
|
|
218
|
+
"--subagent-max-total-tokens",
|
|
219
|
+
"--subagent-timeout-ms"
|
|
220
|
+
];
|
|
221
|
+
var agent = [
|
|
222
|
+
"--compaction-model",
|
|
223
|
+
"--compaction-provider",
|
|
224
|
+
"--pricing-file",
|
|
225
|
+
"--usage-limit-usd",
|
|
226
|
+
...provider,
|
|
227
|
+
...profile,
|
|
228
|
+
"--route",
|
|
229
|
+
...locator,
|
|
230
|
+
...project,
|
|
231
|
+
...execution,
|
|
232
|
+
...budgets,
|
|
233
|
+
"--allow-check",
|
|
234
|
+
"--require-capability",
|
|
235
|
+
"--subagent"
|
|
236
|
+
];
|
|
237
|
+
var contract = (allowed, required = []) => {
|
|
238
|
+
const allowedSet = new Set(allowed);
|
|
239
|
+
return {
|
|
240
|
+
allowed,
|
|
241
|
+
required,
|
|
242
|
+
repeatable: allowed.filter((name) => repeatableOptions.has(name)),
|
|
243
|
+
conflicts: Object.fromEntries(allowed.flatMap((name) => {
|
|
244
|
+
const relevant = conflicts[name]?.filter((other) => allowedSet.has(other)) ?? [];
|
|
245
|
+
return relevant.length > 0 ? [[name, relevant]] : [];
|
|
246
|
+
}))
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
var CLI_COMMAND_OPTION_CONTRACTS = {
|
|
250
|
+
init: contract([...provider, ...profile, "--update", "--json"]),
|
|
251
|
+
run: contract(["--service", "--session", ...agent, "--idempotency-key", "--approval-mode", "--yes", "--json", "--jsonl"]),
|
|
252
|
+
review: contract([
|
|
253
|
+
"--pricing-file",
|
|
254
|
+
"--usage-limit-usd",
|
|
255
|
+
...provider,
|
|
256
|
+
...profile,
|
|
257
|
+
"--route",
|
|
258
|
+
...locator,
|
|
259
|
+
"--context-config",
|
|
260
|
+
"--no-project-context",
|
|
261
|
+
...childBudgets,
|
|
262
|
+
"--max-parallel-reviews",
|
|
263
|
+
"--require-capability",
|
|
264
|
+
"--reviewer",
|
|
265
|
+
"--json"
|
|
266
|
+
]),
|
|
267
|
+
chat: contract(["--service", ...agent, "--approval-mode", "--yes", "--session", "--continue"]),
|
|
268
|
+
providers: contract(["--json"]),
|
|
269
|
+
doctor: contract([...provider, ...profile, ...locator, ...project, ...execution, ...budgets, "--allow-check", "--require-capability", "--subagent", "--json"]),
|
|
270
|
+
resume: contract(["--service", "--session", ...locator, "--approve", "--deny", "--json", "--jsonl"], [["--approve", "--deny"]]),
|
|
271
|
+
"runs:list": contract([...locator, "--status", "--limit", "--cursor", "--json"]),
|
|
272
|
+
"runs:inspect": contract([...locator, "--json"]),
|
|
273
|
+
"runs:cancel": contract([...locator, "--reason", "--cascade", "--final", "--json"]),
|
|
274
|
+
"runs:cleanup": contract([...locator, "--before", "--status", "--limit", "--json"], ["--before"]),
|
|
275
|
+
"runs:export": contract([...locator, "--json"]),
|
|
276
|
+
"sessions:list": contract(["--service", ...locator, "--limit", "--json", "--search"]),
|
|
277
|
+
"sessions:inspect": contract(["--service", ...locator, "--json"]),
|
|
278
|
+
"sessions:rename": contract(["--service", ...locator, "--json"]),
|
|
279
|
+
"sessions:fork": contract([...locator, "--json"]),
|
|
280
|
+
"sessions:archive": contract([...locator, "--json"]),
|
|
281
|
+
"changes:create": contract(["--patch"], ["--patch"]),
|
|
282
|
+
"changes:verify": contract(["--patch", "--preconditions", "--now"], ["--patch"]),
|
|
283
|
+
"state:status": contract([...locator, "--json"]),
|
|
284
|
+
"state:export": contract([...locator, "--json"]),
|
|
285
|
+
"state:import": contract([...locator, "--apply", "--json"]),
|
|
286
|
+
help: contract(["--help"]),
|
|
287
|
+
version: contract(["--version"])
|
|
288
|
+
};
|
|
289
|
+
var validateCliCommandOptions = (commandKey, counts) => {
|
|
290
|
+
const commandContract = CLI_COMMAND_OPTION_CONTRACTS[commandKey];
|
|
291
|
+
const allowed = new Set(commandContract.allowed);
|
|
292
|
+
for (const [name, count] of counts) {
|
|
293
|
+
if (!allowed.has(name)) {
|
|
294
|
+
throw new Error(`${name} is not supported by ${commandKey.replace(":", " ")}.`);
|
|
295
|
+
}
|
|
296
|
+
if (count > 1 && !commandContract.repeatable.includes(name)) {
|
|
297
|
+
throw new Error(`${name} cannot be repeated for ${commandKey.replace(":", " ")}.`);
|
|
298
|
+
}
|
|
299
|
+
for (const conflicting of commandContract.conflicts[name] ?? []) {
|
|
300
|
+
if (counts.has(conflicting)) {
|
|
301
|
+
throw new Error(`${name} cannot be combined with ${conflicting}.`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
for (const requirement of commandContract.required) {
|
|
306
|
+
if (typeof requirement === "string") {
|
|
307
|
+
if (!counts.has(requirement)) {
|
|
308
|
+
throw new Error(`${requirement} is required by ${commandKey.replace(":", " ")}.`);
|
|
309
|
+
}
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
if (!requirement.some((name) => counts.has(name))) {
|
|
313
|
+
throw new Error(`${requirement.join(" or ")} is required by ${commandKey.replace(":", " ")}.`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export { parseHarnessModelRoute, resolveHarnessModelRoutes, createHarnessRouteModels, serializeHarnessModelRoutes, CLI_OPTION_NAMES, CLI_OPTION_DEFINITIONS, CLI_COMMAND_OPTION_CONTRACTS, validateCliCommandOptions };
|