@zhivex-ai/harness 1.4.0-rc.6 → 1.4.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.
- package/CHANGELOG.md +31 -0
- package/README.md +124 -71
- package/SECURITY.md +1 -1
- package/SUPPORT.md +2 -2
- package/contracts/engine-api.json +55 -0
- package/contracts/stable-api-signatures.json +33 -33
- package/dist/acp-cli.js +18 -15
- package/dist/cli/arguments.d.ts +3 -0
- package/dist/cli/console/console-budget.d.ts +8 -2
- package/dist/{cli-s1rs15vv.js → cli-2h37qyvg.js} +34 -15
- package/dist/{cli-entry-d5788aay.js → cli-entry-20w6nh0k.js} +359 -21
- package/dist/{cli-entry-9c2k0zwz.js → cli-entry-4ngptr62.js} +2902 -1482
- package/dist/{cli-entry-4k1cf0m3.js → cli-entry-w0hterjs.js} +8 -5
- package/dist/cli.js +2 -2
- package/dist/client/json-contracts.d.ts +95 -2
- package/dist/client/local-service.d.ts +2 -2
- package/dist/client/protocol.d.ts +3 -0
- package/dist/client/stream.d.ts +2 -1
- package/dist/compat/code-support.d.ts +6 -0
- package/dist/compat/code-support.js +29 -6
- package/dist/{config-c002f06f.js → config-j9624t6t.js} +1 -1
- package/dist/{config-j3jga5wh.js → config-qt69hkqj.js} +4 -2
- package/dist/engine/acp.js +14 -12
- package/dist/engine/client.js +11 -10
- package/dist/engine/desktop-providers-v1.js +2 -1
- package/dist/engine/desktop-state-v1.js +9 -9
- package/dist/engine/index.js +48 -46
- package/dist/engine/mcp-stdio-v1.js +7 -6
- package/dist/engine/protocol.js +30 -2
- package/dist/engine/service.js +12 -11
- package/dist/hostile-repository-demo.js +4773 -3027
- package/dist/{index-49ys3s4q.js → index-5jhgatga.js} +35 -16
- package/dist/{index-wq2tax80.js → index-61gthdz6.js} +1 -1
- package/dist/index-6dft2vev.js +343 -0
- package/dist/{index-gq9xagx2.js → index-8zjmnyw5.js} +25 -138
- package/dist/index-937cb7y8.js +705 -0
- package/dist/index-bpc596v3.js +154 -0
- package/dist/index-fm84men1.js +239 -0
- package/dist/{index-e6r04a18.js → index-m34q25jj.js} +1127 -170
- package/dist/index-m49jx72n.js +220 -0
- package/dist/{index-dj5z774k.js → index-m82cfspw.js} +35 -16
- package/dist/{index-qfpz5y2v.js → index-nmjdwd4p.js} +8 -2
- package/dist/{index-0g939pfs.js → index-pdmevfxv.js} +10 -7
- package/dist/{index-4j1h4j8c.js → index-pp474137.js} +1598 -973
- package/dist/{index-2tgb2b4e.js → index-rkbf7dqg.js} +3 -5
- package/dist/index-s2k2edts.js +3778 -0
- package/dist/{index-z6br6qdn.js → index-tfzta544.js} +28 -11
- package/dist/index.js +44 -42
- package/dist/persistence/operations.d.ts +3 -0
- package/dist/providers/vertex-auth.d.ts +5 -1
- package/dist/runtime/config.d.ts +8 -0
- package/dist/runtime/context-runtime.d.ts +1 -0
- package/dist/runtime/error-diagnostics.d.ts +8 -0
- package/dist/runtime/errors.d.ts +10 -0
- package/dist/runtime/harness.d.ts +9 -0
- package/dist/runtime/policy-inspection.d.ts +1 -0
- package/dist/runtime/provider-transient.d.ts +33 -0
- package/dist/runtime/runtime-diagnostics.d.ts +3 -0
- package/dist/runtime/runtime-policy.d.ts +8 -10
- package/dist/runtime/task-acceptance-host.d.ts +1 -1
- package/dist/runtime/task-budget-host.d.ts +217 -0
- package/dist/runtime/task-budget.d.ts +147 -0
- package/dist/runtime/task-continuity.d.ts +434 -0
- package/dist/runtime/task-telemetry.d.ts +63 -0
- package/dist/runtime/task-transport.d.ts +3 -0
- package/dist/runtime/task-usage-context.d.ts +13 -0
- package/dist/runtime/time-to-safe-fix.d.ts +8 -0
- package/dist/runtime/usage-ledger.d.ts +17 -0
- package/dist/service-cli.js +12 -11
- package/dist/{service-client-cli-b52c67hx.js → service-client-cli-fn54ev6w.js} +18 -7
- package/dist/verify-historical-migrations.js +2426 -652
- package/dist/zhx.js +2 -2
- package/docs/CLI.md +38 -8
- package/docs/CLIENT_PROTOCOL.md +9 -1
- package/docs/CODE_RELEASE.md +118 -1
- package/docs/DURABLE_OPERATIONS.md +1 -1
- package/docs/EXTENSIBILITY.md +1 -1
- package/docs/FIRST_USE.md +6 -6
- package/docs/MINIMUM_OFFLINE_EVALS.md +31 -0
- package/docs/MINIMUM_TASK_AUTHORITY.md +395 -0
- package/docs/PROJECT_MEMORY.md +1 -1
- package/docs/README.md +2 -0
- package/docs/STABILITY.md +1 -1
- package/docs/WEB_LIMITS.md +117 -0
- package/evaluations/representative-assembly-matrix.json +28 -1
- package/examples/README.md +5 -5
- package/package.json +8 -5
- package/dist/index-8705zxpr.js +0 -145
- package/dist/index-a1q355va.js +0 -600
- package/dist/index-r0tdj04h.js +0 -976
- package/dist/index-rd0s3gqj.js +0 -1669
- package/dist/index-vtqfjnab.js +0 -1626
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import type { ZhivexHarness } from './harness.js';
|
|
2
|
+
/** Internal read set, checked again inside task invocation admission. No new store or recovery credit. */
|
|
3
|
+
export declare function readTaskContinuity(host: ZhivexHarness, taskId: string): Promise<{
|
|
4
|
+
report: {
|
|
5
|
+
schemaVersion: 1;
|
|
6
|
+
taskId: string;
|
|
7
|
+
budget: {
|
|
8
|
+
schemaVersion: 1;
|
|
9
|
+
taskId: string;
|
|
10
|
+
accountRunId: string;
|
|
11
|
+
revision: number;
|
|
12
|
+
limits: {
|
|
13
|
+
inputTokens: number;
|
|
14
|
+
outputTokens: number;
|
|
15
|
+
totalTokens: number;
|
|
16
|
+
};
|
|
17
|
+
confirmed: {
|
|
18
|
+
inputTokens: number;
|
|
19
|
+
outputTokens: number;
|
|
20
|
+
totalTokens: number;
|
|
21
|
+
};
|
|
22
|
+
reserved: {
|
|
23
|
+
inputTokens: number;
|
|
24
|
+
outputTokens: number;
|
|
25
|
+
totalTokens: number;
|
|
26
|
+
};
|
|
27
|
+
unknown: {
|
|
28
|
+
inputTokens: number;
|
|
29
|
+
outputTokens: number;
|
|
30
|
+
totalTokens: number;
|
|
31
|
+
};
|
|
32
|
+
remaining: {
|
|
33
|
+
inputTokens: number;
|
|
34
|
+
outputTokens: number;
|
|
35
|
+
totalTokens: number;
|
|
36
|
+
};
|
|
37
|
+
usageComplete: boolean;
|
|
38
|
+
admissionsClosed: boolean;
|
|
39
|
+
invocationPending: boolean;
|
|
40
|
+
activeRunId: string | null;
|
|
41
|
+
runs: string[];
|
|
42
|
+
coordinatorId: string;
|
|
43
|
+
cancellations: {
|
|
44
|
+
runId: string;
|
|
45
|
+
requestedAt: number;
|
|
46
|
+
origin: "abort" | "lease_lost" | "operator" | "timeout";
|
|
47
|
+
localToolsDrainedAt?: number | undefined;
|
|
48
|
+
localExecution: "native_tools_drained" | "unconfirmed";
|
|
49
|
+
remoteExecution: 'unconfirmed';
|
|
50
|
+
}[];
|
|
51
|
+
monetary: {
|
|
52
|
+
schemaVersion: number;
|
|
53
|
+
runId: string;
|
|
54
|
+
calls: number;
|
|
55
|
+
routes: {
|
|
56
|
+
provider: string;
|
|
57
|
+
model: string;
|
|
58
|
+
calls: number;
|
|
59
|
+
inputTokens: number;
|
|
60
|
+
outputTokens: number;
|
|
61
|
+
unknownCalls: number;
|
|
62
|
+
estimatedUsd: number | null;
|
|
63
|
+
priceStatuses: string[];
|
|
64
|
+
}[];
|
|
65
|
+
inputTokens: number;
|
|
66
|
+
outputTokens: number;
|
|
67
|
+
historicalUsageUnknown: boolean;
|
|
68
|
+
usageComplete: boolean;
|
|
69
|
+
estimatedUsd: number | null;
|
|
70
|
+
limitUsd: number | null;
|
|
71
|
+
costKind: "estimate-not-invoice";
|
|
72
|
+
};
|
|
73
|
+
monetaryDetails: {
|
|
74
|
+
schemaVersion: 1;
|
|
75
|
+
confirmedCalls: number;
|
|
76
|
+
reservedCalls: number;
|
|
77
|
+
unknownCalls: number;
|
|
78
|
+
lateCalls: number;
|
|
79
|
+
estimatedConfirmedUsd: number | null;
|
|
80
|
+
reservedUsd: number | null;
|
|
81
|
+
unknownHeldUsd: number | null;
|
|
82
|
+
remainingUsd: number | null;
|
|
83
|
+
costComplete: boolean;
|
|
84
|
+
categories: string[];
|
|
85
|
+
costKind: "estimate-not-invoice";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
runs: {
|
|
89
|
+
runId: string;
|
|
90
|
+
revision: number | undefined;
|
|
91
|
+
status: import("@zhivex-ai/core").AgentStatus;
|
|
92
|
+
ledger: {
|
|
93
|
+
schemaVersion: 1;
|
|
94
|
+
revisions: {
|
|
95
|
+
revision: number;
|
|
96
|
+
digest: string;
|
|
97
|
+
previousDigest: string | null;
|
|
98
|
+
contract: {
|
|
99
|
+
schemaVersion: 1;
|
|
100
|
+
taskId: string;
|
|
101
|
+
allowedWritePaths: string[];
|
|
102
|
+
protectedFiles: string[];
|
|
103
|
+
requiredChecks: ({
|
|
104
|
+
id: string;
|
|
105
|
+
command: string;
|
|
106
|
+
args: string[];
|
|
107
|
+
purpose: string;
|
|
108
|
+
kind: "package-script";
|
|
109
|
+
script: string;
|
|
110
|
+
expectedScript: string;
|
|
111
|
+
execution: {
|
|
112
|
+
backend: "none" | "oci";
|
|
113
|
+
approval: "required";
|
|
114
|
+
};
|
|
115
|
+
} | {
|
|
116
|
+
id: string;
|
|
117
|
+
command: string;
|
|
118
|
+
args: string[];
|
|
119
|
+
purpose: string;
|
|
120
|
+
kind: "argv";
|
|
121
|
+
execution: {
|
|
122
|
+
backend: "oci";
|
|
123
|
+
approval: "required";
|
|
124
|
+
network: "none";
|
|
125
|
+
};
|
|
126
|
+
})[];
|
|
127
|
+
humanReview: {
|
|
128
|
+
id: string;
|
|
129
|
+
requirement: string;
|
|
130
|
+
status: "pending";
|
|
131
|
+
}[];
|
|
132
|
+
};
|
|
133
|
+
}[];
|
|
134
|
+
};
|
|
135
|
+
sources: {
|
|
136
|
+
id: string;
|
|
137
|
+
text: string;
|
|
138
|
+
original?: true;
|
|
139
|
+
}[];
|
|
140
|
+
decisions: import("../approvals/approval-history.js").ApprovalDecisionView[];
|
|
141
|
+
decisionsAvailability: string;
|
|
142
|
+
briefStatus: string;
|
|
143
|
+
objective: string | null;
|
|
144
|
+
constraints: string[];
|
|
145
|
+
hostPolicyCompatible: boolean;
|
|
146
|
+
assistantResponses: {
|
|
147
|
+
id: string;
|
|
148
|
+
text: string;
|
|
149
|
+
truncated: boolean;
|
|
150
|
+
untrusted: boolean;
|
|
151
|
+
verified: boolean;
|
|
152
|
+
}[];
|
|
153
|
+
effects: {
|
|
154
|
+
id: string;
|
|
155
|
+
tool: string;
|
|
156
|
+
revision: number;
|
|
157
|
+
status: string;
|
|
158
|
+
retry: string;
|
|
159
|
+
}[];
|
|
160
|
+
checks: {
|
|
161
|
+
id: string;
|
|
162
|
+
status: string;
|
|
163
|
+
}[];
|
|
164
|
+
snapshot: import("./task-acceptance-checks.js").TaskCheckBinding | null;
|
|
165
|
+
delivery: {} | null;
|
|
166
|
+
humanReview: {
|
|
167
|
+
id: string;
|
|
168
|
+
requirement: string;
|
|
169
|
+
status: "pending";
|
|
170
|
+
}[];
|
|
171
|
+
fingerprint: import("@zhivex-ai/core").AgentHarnessBinding | null;
|
|
172
|
+
}[];
|
|
173
|
+
currentContract: {
|
|
174
|
+
revision: number;
|
|
175
|
+
digest: string;
|
|
176
|
+
previousDigest: string | null;
|
|
177
|
+
contract: {
|
|
178
|
+
schemaVersion: 1;
|
|
179
|
+
taskId: string;
|
|
180
|
+
allowedWritePaths: string[];
|
|
181
|
+
protectedFiles: string[];
|
|
182
|
+
requiredChecks: ({
|
|
183
|
+
id: string;
|
|
184
|
+
command: string;
|
|
185
|
+
args: string[];
|
|
186
|
+
purpose: string;
|
|
187
|
+
kind: "package-script";
|
|
188
|
+
script: string;
|
|
189
|
+
expectedScript: string;
|
|
190
|
+
execution: {
|
|
191
|
+
backend: "none" | "oci";
|
|
192
|
+
approval: "required";
|
|
193
|
+
};
|
|
194
|
+
} | {
|
|
195
|
+
id: string;
|
|
196
|
+
command: string;
|
|
197
|
+
args: string[];
|
|
198
|
+
purpose: string;
|
|
199
|
+
kind: "argv";
|
|
200
|
+
execution: {
|
|
201
|
+
backend: "oci";
|
|
202
|
+
approval: "required";
|
|
203
|
+
network: "none";
|
|
204
|
+
};
|
|
205
|
+
})[];
|
|
206
|
+
humanReview: {
|
|
207
|
+
id: string;
|
|
208
|
+
requirement: string;
|
|
209
|
+
status: "pending";
|
|
210
|
+
}[];
|
|
211
|
+
};
|
|
212
|
+
} | null;
|
|
213
|
+
reasons: string[];
|
|
214
|
+
nextAction: string;
|
|
215
|
+
authorization: 'none';
|
|
216
|
+
automaticEffectReplay: false;
|
|
217
|
+
};
|
|
218
|
+
verify: () => Promise<void>;
|
|
219
|
+
}>;
|
|
220
|
+
/** Host-only Experimental inspection; no model, writes, approval, cancellation revival or replay. */
|
|
221
|
+
export declare function inspectHarnessTaskContinuity(host: ZhivexHarness, taskId: string): Promise<{
|
|
222
|
+
schemaVersion: 1;
|
|
223
|
+
taskId: string;
|
|
224
|
+
budget: {
|
|
225
|
+
schemaVersion: 1;
|
|
226
|
+
taskId: string;
|
|
227
|
+
accountRunId: string;
|
|
228
|
+
revision: number;
|
|
229
|
+
limits: {
|
|
230
|
+
inputTokens: number;
|
|
231
|
+
outputTokens: number;
|
|
232
|
+
totalTokens: number;
|
|
233
|
+
};
|
|
234
|
+
confirmed: {
|
|
235
|
+
inputTokens: number;
|
|
236
|
+
outputTokens: number;
|
|
237
|
+
totalTokens: number;
|
|
238
|
+
};
|
|
239
|
+
reserved: {
|
|
240
|
+
inputTokens: number;
|
|
241
|
+
outputTokens: number;
|
|
242
|
+
totalTokens: number;
|
|
243
|
+
};
|
|
244
|
+
unknown: {
|
|
245
|
+
inputTokens: number;
|
|
246
|
+
outputTokens: number;
|
|
247
|
+
totalTokens: number;
|
|
248
|
+
};
|
|
249
|
+
remaining: {
|
|
250
|
+
inputTokens: number;
|
|
251
|
+
outputTokens: number;
|
|
252
|
+
totalTokens: number;
|
|
253
|
+
};
|
|
254
|
+
usageComplete: boolean;
|
|
255
|
+
admissionsClosed: boolean;
|
|
256
|
+
invocationPending: boolean;
|
|
257
|
+
activeRunId: string | null;
|
|
258
|
+
runs: string[];
|
|
259
|
+
coordinatorId: string;
|
|
260
|
+
cancellations: {
|
|
261
|
+
runId: string;
|
|
262
|
+
requestedAt: number;
|
|
263
|
+
origin: "abort" | "lease_lost" | "operator" | "timeout";
|
|
264
|
+
localToolsDrainedAt?: number | undefined;
|
|
265
|
+
localExecution: "native_tools_drained" | "unconfirmed";
|
|
266
|
+
remoteExecution: 'unconfirmed';
|
|
267
|
+
}[];
|
|
268
|
+
monetary: {
|
|
269
|
+
schemaVersion: number;
|
|
270
|
+
runId: string;
|
|
271
|
+
calls: number;
|
|
272
|
+
routes: {
|
|
273
|
+
provider: string;
|
|
274
|
+
model: string;
|
|
275
|
+
calls: number;
|
|
276
|
+
inputTokens: number;
|
|
277
|
+
outputTokens: number;
|
|
278
|
+
unknownCalls: number;
|
|
279
|
+
estimatedUsd: number | null;
|
|
280
|
+
priceStatuses: string[];
|
|
281
|
+
}[];
|
|
282
|
+
inputTokens: number;
|
|
283
|
+
outputTokens: number;
|
|
284
|
+
historicalUsageUnknown: boolean;
|
|
285
|
+
usageComplete: boolean;
|
|
286
|
+
estimatedUsd: number | null;
|
|
287
|
+
limitUsd: number | null;
|
|
288
|
+
costKind: "estimate-not-invoice";
|
|
289
|
+
};
|
|
290
|
+
monetaryDetails: {
|
|
291
|
+
schemaVersion: 1;
|
|
292
|
+
confirmedCalls: number;
|
|
293
|
+
reservedCalls: number;
|
|
294
|
+
unknownCalls: number;
|
|
295
|
+
lateCalls: number;
|
|
296
|
+
estimatedConfirmedUsd: number | null;
|
|
297
|
+
reservedUsd: number | null;
|
|
298
|
+
unknownHeldUsd: number | null;
|
|
299
|
+
remainingUsd: number | null;
|
|
300
|
+
costComplete: boolean;
|
|
301
|
+
categories: string[];
|
|
302
|
+
costKind: "estimate-not-invoice";
|
|
303
|
+
};
|
|
304
|
+
};
|
|
305
|
+
runs: {
|
|
306
|
+
runId: string;
|
|
307
|
+
revision: number | undefined;
|
|
308
|
+
status: import("@zhivex-ai/core").AgentStatus;
|
|
309
|
+
ledger: {
|
|
310
|
+
schemaVersion: 1;
|
|
311
|
+
revisions: {
|
|
312
|
+
revision: number;
|
|
313
|
+
digest: string;
|
|
314
|
+
previousDigest: string | null;
|
|
315
|
+
contract: {
|
|
316
|
+
schemaVersion: 1;
|
|
317
|
+
taskId: string;
|
|
318
|
+
allowedWritePaths: string[];
|
|
319
|
+
protectedFiles: string[];
|
|
320
|
+
requiredChecks: ({
|
|
321
|
+
id: string;
|
|
322
|
+
command: string;
|
|
323
|
+
args: string[];
|
|
324
|
+
purpose: string;
|
|
325
|
+
kind: "package-script";
|
|
326
|
+
script: string;
|
|
327
|
+
expectedScript: string;
|
|
328
|
+
execution: {
|
|
329
|
+
backend: "none" | "oci";
|
|
330
|
+
approval: "required";
|
|
331
|
+
};
|
|
332
|
+
} | {
|
|
333
|
+
id: string;
|
|
334
|
+
command: string;
|
|
335
|
+
args: string[];
|
|
336
|
+
purpose: string;
|
|
337
|
+
kind: "argv";
|
|
338
|
+
execution: {
|
|
339
|
+
backend: "oci";
|
|
340
|
+
approval: "required";
|
|
341
|
+
network: "none";
|
|
342
|
+
};
|
|
343
|
+
})[];
|
|
344
|
+
humanReview: {
|
|
345
|
+
id: string;
|
|
346
|
+
requirement: string;
|
|
347
|
+
status: "pending";
|
|
348
|
+
}[];
|
|
349
|
+
};
|
|
350
|
+
}[];
|
|
351
|
+
};
|
|
352
|
+
sources: {
|
|
353
|
+
id: string;
|
|
354
|
+
text: string;
|
|
355
|
+
original?: true;
|
|
356
|
+
}[];
|
|
357
|
+
decisions: import("../approvals/approval-history.js").ApprovalDecisionView[];
|
|
358
|
+
decisionsAvailability: string;
|
|
359
|
+
briefStatus: string;
|
|
360
|
+
objective: string | null;
|
|
361
|
+
constraints: string[];
|
|
362
|
+
hostPolicyCompatible: boolean;
|
|
363
|
+
assistantResponses: {
|
|
364
|
+
id: string;
|
|
365
|
+
text: string;
|
|
366
|
+
truncated: boolean;
|
|
367
|
+
untrusted: boolean;
|
|
368
|
+
verified: boolean;
|
|
369
|
+
}[];
|
|
370
|
+
effects: {
|
|
371
|
+
id: string;
|
|
372
|
+
tool: string;
|
|
373
|
+
revision: number;
|
|
374
|
+
status: string;
|
|
375
|
+
retry: string;
|
|
376
|
+
}[];
|
|
377
|
+
checks: {
|
|
378
|
+
id: string;
|
|
379
|
+
status: string;
|
|
380
|
+
}[];
|
|
381
|
+
snapshot: import("./task-acceptance-checks.js").TaskCheckBinding | null;
|
|
382
|
+
delivery: {} | null;
|
|
383
|
+
humanReview: {
|
|
384
|
+
id: string;
|
|
385
|
+
requirement: string;
|
|
386
|
+
status: "pending";
|
|
387
|
+
}[];
|
|
388
|
+
fingerprint: import("@zhivex-ai/core").AgentHarnessBinding | null;
|
|
389
|
+
}[];
|
|
390
|
+
currentContract: {
|
|
391
|
+
revision: number;
|
|
392
|
+
digest: string;
|
|
393
|
+
previousDigest: string | null;
|
|
394
|
+
contract: {
|
|
395
|
+
schemaVersion: 1;
|
|
396
|
+
taskId: string;
|
|
397
|
+
allowedWritePaths: string[];
|
|
398
|
+
protectedFiles: string[];
|
|
399
|
+
requiredChecks: ({
|
|
400
|
+
id: string;
|
|
401
|
+
command: string;
|
|
402
|
+
args: string[];
|
|
403
|
+
purpose: string;
|
|
404
|
+
kind: "package-script";
|
|
405
|
+
script: string;
|
|
406
|
+
expectedScript: string;
|
|
407
|
+
execution: {
|
|
408
|
+
backend: "none" | "oci";
|
|
409
|
+
approval: "required";
|
|
410
|
+
};
|
|
411
|
+
} | {
|
|
412
|
+
id: string;
|
|
413
|
+
command: string;
|
|
414
|
+
args: string[];
|
|
415
|
+
purpose: string;
|
|
416
|
+
kind: "argv";
|
|
417
|
+
execution: {
|
|
418
|
+
backend: "oci";
|
|
419
|
+
approval: "required";
|
|
420
|
+
network: "none";
|
|
421
|
+
};
|
|
422
|
+
})[];
|
|
423
|
+
humanReview: {
|
|
424
|
+
id: string;
|
|
425
|
+
requirement: string;
|
|
426
|
+
status: "pending";
|
|
427
|
+
}[];
|
|
428
|
+
};
|
|
429
|
+
} | null;
|
|
430
|
+
reasons: string[];
|
|
431
|
+
nextAction: string;
|
|
432
|
+
authorization: 'none';
|
|
433
|
+
automaticEffectReplay: false;
|
|
434
|
+
}>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { AgentStreamEvent } from '@zhivex-ai/agents';
|
|
2
|
+
import type { AgentRunStore } from '@zhivex-ai/agents/ops';
|
|
3
|
+
import type { LanguageModelMiddleware, ToolSet } from '@zhivex-ai/core';
|
|
4
|
+
export type TaskTelemetryKind = 'prepare' | 'context' | 'model' | 'compaction' | 'tool' | 'persistence' | 'render';
|
|
5
|
+
export type TaskTelemetryMilestone = 'prepare-start' | 'prepare-end' | 'first-event' | 'first-model-event' | 'first-text-event' | 'first-visible-text' | 'cancel-requested' | 'cancel-settled' | 'render-start' | 'render-end';
|
|
6
|
+
export type TaskTelemetryOutcome = 'completed' | 'error' | 'incomplete';
|
|
7
|
+
export interface TaskTelemetrySpan {
|
|
8
|
+
kind: TaskTelemetryKind;
|
|
9
|
+
startMs: number;
|
|
10
|
+
durationMs: number;
|
|
11
|
+
outcome: TaskTelemetryOutcome;
|
|
12
|
+
}
|
|
13
|
+
export type TaskTelemetryEvent = {
|
|
14
|
+
type: 'milestone';
|
|
15
|
+
milestone: TaskTelemetryMilestone;
|
|
16
|
+
elapsedMs: number;
|
|
17
|
+
} | {
|
|
18
|
+
type: 'span';
|
|
19
|
+
span: TaskTelemetrySpan;
|
|
20
|
+
};
|
|
21
|
+
export interface TaskTelemetrySnapshot {
|
|
22
|
+
schemaVersion: 1;
|
|
23
|
+
scope: 'invocation';
|
|
24
|
+
clock: 'monotonic';
|
|
25
|
+
temperature: 'cold' | 'warm' | 'unknown';
|
|
26
|
+
wallMs: number;
|
|
27
|
+
finished: boolean;
|
|
28
|
+
milestones: Partial<Record<TaskTelemetryMilestone, number>>;
|
|
29
|
+
spans: TaskTelemetrySpan[];
|
|
30
|
+
omittedSpans: number;
|
|
31
|
+
activeSpans: number;
|
|
32
|
+
observerErrors: number;
|
|
33
|
+
clockErrors: number;
|
|
34
|
+
/** Operation time can overlap; these totals must never be added to infer wall time. */
|
|
35
|
+
operationTotals: Record<TaskTelemetryKind, {
|
|
36
|
+
count: number;
|
|
37
|
+
durationMs: number;
|
|
38
|
+
errors: number;
|
|
39
|
+
incomplete: number;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
/** Numeric, bounded diagnostics. It records no prompts, output, tool arguments, errors, or identifiers.
|
|
43
|
+
* Model middleware measures transport consumption, including failed and abandoned streams.
|
|
44
|
+
* first-text-event is delivery to a host; only the renderer may mark first-visible-text.
|
|
45
|
+
* This observer is supplemental and never replaces mandatory audit or checkpoint writes.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createTaskTelemetry(options?: {
|
|
48
|
+
temperature?: TaskTelemetrySnapshot['temperature'];
|
|
49
|
+
maxSpans?: number;
|
|
50
|
+
now?: () => number;
|
|
51
|
+
observer?: (event: TaskTelemetryEvent) => void | Promise<void>;
|
|
52
|
+
}): {
|
|
53
|
+
middleware: LanguageModelMiddleware<import("@zhivex-ai/core").ProviderOptions>;
|
|
54
|
+
modelMiddleware: (kind?: 'model' | 'compaction') => LanguageModelMiddleware;
|
|
55
|
+
mark: (milestone: TaskTelemetryMilestone) => void;
|
|
56
|
+
begin: (kind: TaskTelemetryKind) => (_outcome?: TaskTelemetryOutcome) => void;
|
|
57
|
+
measure: <T>(kind: TaskTelemetryKind, work: () => T) => T;
|
|
58
|
+
observeEvent(event: AgentStreamEvent): void;
|
|
59
|
+
store(store: AgentRunStore): AgentRunStore;
|
|
60
|
+
tools(tools: ToolSet): ToolSet;
|
|
61
|
+
finish(): void;
|
|
62
|
+
snapshot(): TaskTelemetrySnapshot;
|
|
63
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
/** Internal, non-serializable admission context. Only the task owner supplies it. */
|
|
3
|
+
export interface TaskUsageAdmission {
|
|
4
|
+
accountRunId: string;
|
|
5
|
+
operationId: string;
|
|
6
|
+
category: 'execution' | 'compaction' | 'closure';
|
|
7
|
+
closureReserve: number;
|
|
8
|
+
inputCeiling: number;
|
|
9
|
+
monetaryRefused: boolean;
|
|
10
|
+
/** Final synchronous gate after intervening asynchronous host middleware. */
|
|
11
|
+
assertActive(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare const taskUsageAdmission: AsyncLocalStorage<TaskUsageAdmission>;
|
|
@@ -471,6 +471,14 @@ export declare const timeToSafeFixDriverResultSchema: z.ZodObject<{
|
|
|
471
471
|
unavailable: "unavailable";
|
|
472
472
|
}>;
|
|
473
473
|
}, z.core.$strict>>;
|
|
474
|
+
providerStatus: z.ZodOptional<z.ZodEnum<{
|
|
475
|
+
ABORTED: "ABORTED";
|
|
476
|
+
DEADLINE_EXCEEDED: "DEADLINE_EXCEEDED";
|
|
477
|
+
INTERNAL: "INTERNAL";
|
|
478
|
+
RESOURCE_EXHAUSTED: "RESOURCE_EXHAUSTED";
|
|
479
|
+
STREAM_RESET: "STREAM_RESET";
|
|
480
|
+
UNAVAILABLE: "UNAVAILABLE";
|
|
481
|
+
}>>;
|
|
474
482
|
status: z.ZodOptional<z.ZodNumber>;
|
|
475
483
|
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
476
484
|
acceptanceReason: z.ZodOptional<z.ZodEnum<{
|
|
@@ -44,6 +44,8 @@ export declare const inspectUsageLedger: (value: unknown) => {
|
|
|
44
44
|
}[];
|
|
45
45
|
} | null;
|
|
46
46
|
export declare const formatUsageLedger: (value: unknown) => string;
|
|
47
|
+
/** Internal task admission supplies its frozen policy without widening UsageLedger's public API. */
|
|
48
|
+
export declare const runUsageLedgerWithPolicy: <T>(ledger: UsageLedger, runId: string, operation: () => Promise<T>, historicalUsageUnknown?: boolean, initialPolicy?: UsageAccountingOptions) => Promise<T>;
|
|
47
49
|
/** A separate append-only transport ledger. SDK rollups are never added to these calls. */
|
|
48
50
|
export declare class UsageLedger {
|
|
49
51
|
private readonly database;
|
|
@@ -83,3 +85,18 @@ export declare class UsageLedger {
|
|
|
83
85
|
model(model: LanguageModel): LanguageModel;
|
|
84
86
|
store(store: AgentRunStore): AgentRunStore;
|
|
85
87
|
}
|
|
88
|
+
export declare const inspectTaskMonetaryUsage: (ledger: UsageLedger, runId: string) => {
|
|
89
|
+
schemaVersion: 1;
|
|
90
|
+
confirmedCalls: number;
|
|
91
|
+
reservedCalls: number;
|
|
92
|
+
unknownCalls: number;
|
|
93
|
+
lateCalls: number;
|
|
94
|
+
estimatedConfirmedUsd: number | null;
|
|
95
|
+
reservedUsd: number | null;
|
|
96
|
+
unknownHeldUsd: number | null;
|
|
97
|
+
remainingUsd: number | null;
|
|
98
|
+
costComplete: boolean;
|
|
99
|
+
categories: string[];
|
|
100
|
+
costKind: "estimate-not-invoice";
|
|
101
|
+
};
|
|
102
|
+
export declare const assertTaskMonetaryReceipts: (ledger: UsageLedger, runId: string, expected: readonly string[], allocations: readonly string[]) => void;
|
package/dist/service-cli.js
CHANGED
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
import {
|
|
3
3
|
recoverHarnessLocalService,
|
|
4
4
|
startHarnessLocalService
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-5jhgatga.js";
|
|
6
|
+
import"./index-937cb7y8.js";
|
|
7
|
+
import"./index-6dft2vev.js";
|
|
6
8
|
import {
|
|
7
9
|
createHarness
|
|
8
|
-
} from "./index-
|
|
9
|
-
import"./index-
|
|
10
|
-
import"./index-
|
|
11
|
-
import"./index-
|
|
12
|
-
import"./index-
|
|
13
|
-
import"./index-
|
|
14
|
-
import"./index-r0tdj04h.js";
|
|
15
|
-
import"./index-gq9xagx2.js";
|
|
16
|
-
import"./index-8705zxpr.js";
|
|
10
|
+
} from "./index-pp474137.js";
|
|
11
|
+
import"./index-s2k2edts.js";
|
|
12
|
+
import"./index-pdmevfxv.js";
|
|
13
|
+
import"./index-m34q25jj.js";
|
|
14
|
+
import"./index-8zjmnyw5.js";
|
|
15
|
+
import"./index-m49jx72n.js";
|
|
17
16
|
import"./index-xqxeypt5.js";
|
|
18
|
-
import"./index-
|
|
17
|
+
import"./index-nmjdwd4p.js";
|
|
18
|
+
import"./index-bpc596v3.js";
|
|
19
|
+
import"./index-fm84men1.js";
|
|
19
20
|
import"./index-1bx83sw4.js";
|
|
20
21
|
|
|
21
22
|
// src/service-cli.ts
|
|
@@ -14,10 +14,10 @@ import {
|
|
|
14
14
|
printPolicyInspection,
|
|
15
15
|
sanitizeTerminalText,
|
|
16
16
|
serializeStreamResult
|
|
17
|
-
} from "./cli-entry-
|
|
17
|
+
} from "./cli-entry-4ngptr62.js";
|
|
18
18
|
import {
|
|
19
19
|
HARNESS_VERSION
|
|
20
|
-
} from "./cli-entry-
|
|
20
|
+
} from "./cli-entry-w0hterjs.js";
|
|
21
21
|
import {
|
|
22
22
|
HARNESS_ERROR_CODES,
|
|
23
23
|
HARNESS_ERROR_SCHEMA_VERSION,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
HarnessStateConflictError,
|
|
26
26
|
PROVIDERS,
|
|
27
27
|
reasoningEffortSchema
|
|
28
|
-
} from "./cli-entry-
|
|
28
|
+
} from "./cli-entry-20w6nh0k.js";
|
|
29
29
|
import {
|
|
30
30
|
__require
|
|
31
31
|
} from "./cli-entry-1bx83sw4.js";
|
|
@@ -226,6 +226,8 @@ var tokenUsageSchema = observationalDocument({
|
|
|
226
226
|
});
|
|
227
227
|
var budgetConfigSchema = observationalDocument({
|
|
228
228
|
unlimitedTokens: z5.boolean().optional(),
|
|
229
|
+
unlimitedSteps: z5.boolean().optional(),
|
|
230
|
+
unlimitedToolCalls: z5.boolean().optional(),
|
|
229
231
|
maxSteps: nonnegativeInteger,
|
|
230
232
|
maxToolCalls: nonnegativeInteger,
|
|
231
233
|
maxToolErrors: nonnegativeInteger,
|
|
@@ -399,6 +401,7 @@ var doctorConfigurationSchema = observationalDocument({
|
|
|
399
401
|
scope: scopeSchema,
|
|
400
402
|
maxSteps: nonnegativeInteger,
|
|
401
403
|
timeoutMs: nonnegativeInteger,
|
|
404
|
+
unlimitedDuration: z5.boolean().optional(),
|
|
402
405
|
budget: budgetConfigSchema,
|
|
403
406
|
costBudget: observationalDocument({
|
|
404
407
|
maxCostUsd: z5.number().nonnegative(),
|
|
@@ -605,6 +608,13 @@ var cliStateImportDocumentSchema = observationalDocument({
|
|
|
605
608
|
inserted: z5.record(z5.string(), nonnegativeInteger),
|
|
606
609
|
identical: nonnegativeInteger
|
|
607
610
|
});
|
|
611
|
+
var providerStreamDiagnosticSchema = z5.strictObject({
|
|
612
|
+
provider: z5.literal("qwen"),
|
|
613
|
+
transport: z5.enum(["chat", "responses"]),
|
|
614
|
+
diagnosticCode: z5.literal("QWEN_SSE_EVENT_INVALID"),
|
|
615
|
+
reason: z5.enum(["invalid_json", "invalid_event"]),
|
|
616
|
+
retryable: z5.literal(false)
|
|
617
|
+
});
|
|
608
618
|
var cliErrorDocumentSchema = observationalDocument({
|
|
609
619
|
schemaVersion: z5.literal(HARNESS_ERROR_SCHEMA_VERSION),
|
|
610
620
|
kind: z5.literal("error"),
|
|
@@ -619,7 +629,8 @@ var cliErrorDocumentSchema = observationalDocument({
|
|
|
619
629
|
"approval",
|
|
620
630
|
"execution"
|
|
621
631
|
]),
|
|
622
|
-
retryable: z5.boolean()
|
|
632
|
+
retryable: z5.boolean(),
|
|
633
|
+
providerDiagnostic: providerStreamDiagnosticSchema.optional()
|
|
623
634
|
})
|
|
624
635
|
});
|
|
625
636
|
var cliPolicyInspectionSchema = observationalDocument({
|
|
@@ -631,7 +642,7 @@ var cliPolicyInspectionSchema = observationalDocument({
|
|
|
631
642
|
tools: z5.array(observationalDocument({ name: z5.string(), requiresApproval: z5.boolean() })),
|
|
632
643
|
restrictions: z5.array(observationalDocument({ ruleId: z5.string(), tools: z5.array(z5.string()), decision: z5.enum(["allow", "ask_user", "deny"]), reason: z5.string(), pathCount: nonnegativeInteger })),
|
|
633
644
|
execution: observationalDocument({ configuredBackend: z5.enum(["none", "oci"]), activeBackend: z5.enum(["none", "oci"]), evidence: z5.literal("configuration-only") }),
|
|
634
|
-
limits: observationalDocument({ maxSteps: nonnegativeInteger, timeoutMs: nonnegativeInteger, budget: jsonObjectSchema })
|
|
645
|
+
limits: observationalDocument({ maxSteps: nonnegativeInteger, timeoutMs: nonnegativeInteger, unlimitedDuration: z5.boolean().optional(), budget: jsonObjectSchema })
|
|
635
646
|
});
|
|
636
647
|
var cliJsonDocumentSchema = z5.union([
|
|
637
648
|
cliPolicyInspectionSchema,
|
|
@@ -710,10 +721,10 @@ var cliRunEventDocumentSchema = z5.discriminatedUnion("type", [
|
|
|
710
721
|
finishReason: z5.string().min(1).optional(),
|
|
711
722
|
usage: jsonObjectSchema.optional()
|
|
712
723
|
}),
|
|
713
|
-
runEvent("error", { error: z5.literal("Provider stream failed.") }),
|
|
724
|
+
runEvent("error", { error: z5.literal("Provider stream failed."), providerDiagnostic: providerStreamDiagnosticSchema.optional() }),
|
|
714
725
|
runEvent("agent-run-start", {
|
|
715
726
|
currentStep: nonnegativeInteger,
|
|
716
|
-
maxSteps: nonnegativeInteger
|
|
727
|
+
maxSteps: z5.union([nonnegativeInteger, z5.literal("unlimited")])
|
|
717
728
|
}),
|
|
718
729
|
runEvent("agent-step-start", { stepIndex: nonnegativeInteger }),
|
|
719
730
|
runEvent("agent-step-finish", {
|