@adea-ai/runtime-sdk 1.10.3 → 1.11.1

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/dist/adapter.d.ts CHANGED
@@ -38,30 +38,30 @@ export declare const RuntimeAdapterInspectionSchema: z.ZodObject<{
38
38
  }>;
39
39
  capabilities: z.ZodArray<z.ZodObject<{
40
40
  name: z.ZodEnum<{
41
- "stream.output": "stream.output";
42
- "stream.events": "stream.events";
43
- "tool.call": "tool.call";
44
- "tool.parallel": "tool.parallel";
45
- "output.structured": "output.structured";
41
+ "execution.cancel": "execution.cancel";
42
+ "execution.child": "execution.child";
46
43
  "filesystem.read": "filesystem.read";
47
44
  "filesystem.write": "filesystem.write";
45
+ "interaction.approval": "interaction.approval";
46
+ "interaction.user-input": "interaction.user-input";
47
+ "model.select": "model.select";
48
+ "output.structured": "output.structured";
48
49
  "project.read": "project.read";
49
50
  "project.write": "project.write";
50
- "execution.cancel": "execution.cancel";
51
- "interaction.user-input": "interaction.user-input";
52
- "interaction.approval": "interaction.approval";
53
- "session.create": "session.create";
54
- "session.list": "session.list";
55
- "session.resume": "session.resume";
56
51
  "session.close": "session.close";
52
+ "session.create": "session.create";
57
53
  "session.history": "session.history";
54
+ "session.list": "session.list";
58
55
  "session.load": "session.load";
59
- "model.select": "model.select";
60
- "execution.child": "execution.child";
56
+ "session.resume": "session.resume";
57
+ "stream.events": "stream.events";
58
+ "stream.output": "stream.output";
59
+ "tool.call": "tool.call";
60
+ "tool.parallel": "tool.parallel";
61
61
  }>;
62
62
  support: z.ZodEnum<{
63
- supported: "supported";
64
63
  degraded: "degraded";
64
+ supported: "supported";
65
65
  unsupported: "unsupported";
66
66
  }>;
67
67
  limitations: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -71,9 +71,9 @@ export declare const RuntimeAdapterInspectionSchema: z.ZodObject<{
71
71
  versions: z.ZodArray<z.ZodString>;
72
72
  skills: z.ZodBoolean;
73
73
  mcpTransports: z.ZodArray<z.ZodEnum<{
74
+ sse: "sse";
74
75
  stdio: "stdio";
75
76
  "streamable-http": "streamable-http";
76
- sse: "sse";
77
77
  }>>;
78
78
  }, z.core.$strict>>;
79
79
  observedAt: z.ZodISODateTime;
@@ -85,92 +85,92 @@ export declare const RuntimeAdapterInspectionSchema: z.ZodObject<{
85
85
  ineligible: "ineligible";
86
86
  }>;
87
87
  missingRequired: z.ZodArray<z.ZodEnum<{
88
- "stream.output": "stream.output";
89
- "stream.events": "stream.events";
90
- "tool.call": "tool.call";
91
- "tool.parallel": "tool.parallel";
92
- "output.structured": "output.structured";
88
+ "execution.cancel": "execution.cancel";
89
+ "execution.child": "execution.child";
93
90
  "filesystem.read": "filesystem.read";
94
91
  "filesystem.write": "filesystem.write";
92
+ "interaction.approval": "interaction.approval";
93
+ "interaction.user-input": "interaction.user-input";
94
+ "model.select": "model.select";
95
+ "output.structured": "output.structured";
95
96
  "project.read": "project.read";
96
97
  "project.write": "project.write";
97
- "execution.cancel": "execution.cancel";
98
- "interaction.user-input": "interaction.user-input";
99
- "interaction.approval": "interaction.approval";
100
- "session.create": "session.create";
101
- "session.list": "session.list";
102
- "session.resume": "session.resume";
103
98
  "session.close": "session.close";
99
+ "session.create": "session.create";
104
100
  "session.history": "session.history";
101
+ "session.list": "session.list";
105
102
  "session.load": "session.load";
106
- "model.select": "model.select";
107
- "execution.child": "execution.child";
108
- }>>;
109
- insufficientRequired: z.ZodArray<z.ZodEnum<{
110
- "stream.output": "stream.output";
103
+ "session.resume": "session.resume";
111
104
  "stream.events": "stream.events";
105
+ "stream.output": "stream.output";
112
106
  "tool.call": "tool.call";
113
107
  "tool.parallel": "tool.parallel";
114
- "output.structured": "output.structured";
108
+ }>>;
109
+ insufficientRequired: z.ZodArray<z.ZodEnum<{
110
+ "execution.cancel": "execution.cancel";
111
+ "execution.child": "execution.child";
115
112
  "filesystem.read": "filesystem.read";
116
113
  "filesystem.write": "filesystem.write";
114
+ "interaction.approval": "interaction.approval";
115
+ "interaction.user-input": "interaction.user-input";
116
+ "model.select": "model.select";
117
+ "output.structured": "output.structured";
117
118
  "project.read": "project.read";
118
119
  "project.write": "project.write";
119
- "execution.cancel": "execution.cancel";
120
- "interaction.user-input": "interaction.user-input";
121
- "interaction.approval": "interaction.approval";
122
- "session.create": "session.create";
123
- "session.list": "session.list";
124
- "session.resume": "session.resume";
125
120
  "session.close": "session.close";
121
+ "session.create": "session.create";
126
122
  "session.history": "session.history";
123
+ "session.list": "session.list";
127
124
  "session.load": "session.load";
128
- "model.select": "model.select";
129
- "execution.child": "execution.child";
130
- }>>;
131
- missingOptional: z.ZodArray<z.ZodEnum<{
132
- "stream.output": "stream.output";
125
+ "session.resume": "session.resume";
133
126
  "stream.events": "stream.events";
127
+ "stream.output": "stream.output";
134
128
  "tool.call": "tool.call";
135
129
  "tool.parallel": "tool.parallel";
136
- "output.structured": "output.structured";
130
+ }>>;
131
+ missingOptional: z.ZodArray<z.ZodEnum<{
132
+ "execution.cancel": "execution.cancel";
133
+ "execution.child": "execution.child";
137
134
  "filesystem.read": "filesystem.read";
138
135
  "filesystem.write": "filesystem.write";
136
+ "interaction.approval": "interaction.approval";
137
+ "interaction.user-input": "interaction.user-input";
138
+ "model.select": "model.select";
139
+ "output.structured": "output.structured";
139
140
  "project.read": "project.read";
140
141
  "project.write": "project.write";
141
- "execution.cancel": "execution.cancel";
142
- "interaction.user-input": "interaction.user-input";
143
- "interaction.approval": "interaction.approval";
144
- "session.create": "session.create";
145
- "session.list": "session.list";
146
- "session.resume": "session.resume";
147
142
  "session.close": "session.close";
143
+ "session.create": "session.create";
148
144
  "session.history": "session.history";
145
+ "session.list": "session.list";
149
146
  "session.load": "session.load";
150
- "model.select": "model.select";
151
- "execution.child": "execution.child";
152
- }>>;
153
- degradedOptional: z.ZodArray<z.ZodEnum<{
154
- "stream.output": "stream.output";
147
+ "session.resume": "session.resume";
155
148
  "stream.events": "stream.events";
149
+ "stream.output": "stream.output";
156
150
  "tool.call": "tool.call";
157
151
  "tool.parallel": "tool.parallel";
158
- "output.structured": "output.structured";
152
+ }>>;
153
+ degradedOptional: z.ZodArray<z.ZodEnum<{
154
+ "execution.cancel": "execution.cancel";
155
+ "execution.child": "execution.child";
159
156
  "filesystem.read": "filesystem.read";
160
157
  "filesystem.write": "filesystem.write";
158
+ "interaction.approval": "interaction.approval";
159
+ "interaction.user-input": "interaction.user-input";
160
+ "model.select": "model.select";
161
+ "output.structured": "output.structured";
161
162
  "project.read": "project.read";
162
163
  "project.write": "project.write";
163
- "execution.cancel": "execution.cancel";
164
- "interaction.user-input": "interaction.user-input";
165
- "interaction.approval": "interaction.approval";
166
- "session.create": "session.create";
167
- "session.list": "session.list";
168
- "session.resume": "session.resume";
169
164
  "session.close": "session.close";
165
+ "session.create": "session.create";
170
166
  "session.history": "session.history";
167
+ "session.list": "session.list";
171
168
  "session.load": "session.load";
172
- "model.select": "model.select";
173
- "execution.child": "execution.child";
169
+ "session.resume": "session.resume";
170
+ "stream.events": "stream.events";
171
+ "stream.output": "stream.output";
172
+ "tool.call": "tool.call";
173
+ "tool.parallel": "tool.parallel";
174
174
  }>>;
175
175
  }, z.core.$strict>>;
176
176
  }, z.core.$strict>;
@@ -180,6 +180,22 @@ export declare const RuntimeExecutionHandleSchema: z.ZodObject<{
180
180
  externalSessionId: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"external-session ID">, string>>>;
181
181
  startedAt: z.ZodISODateTime;
182
182
  }, z.core.$strict>;
183
+ /**
184
+ * Reported runtime accounting provenance, not funding authorization. Consumers
185
+ * must verify `sourceId` against a trusted authority before charging.
186
+ */
187
+ export declare const RuntimeUsageAccountingSchema: z.ZodObject<{
188
+ schemaVersion: z.ZodLiteral<1>;
189
+ sourceId: z.ZodString;
190
+ fundingSource: z.ZodEnum<{
191
+ external_subscription: "external_subscription";
192
+ hq_managed: "hq_managed";
193
+ }>;
194
+ currency: z.ZodLiteral<"USD">;
195
+ chargedMicrounits: z.ZodNumber;
196
+ costExact: z.ZodLiteral<true>;
197
+ }, z.core.$strict>;
198
+ export type RuntimeUsageAccounting = z.output<typeof RuntimeUsageAccountingSchema>;
183
199
  export declare const RuntimeUsageSchema: z.ZodObject<{
184
200
  inputTokens: z.ZodNumber;
185
201
  outputTokens: z.ZodNumber;
@@ -188,7 +204,19 @@ export declare const RuntimeUsageSchema: z.ZodObject<{
188
204
  amount: z.ZodString;
189
205
  currency: z.ZodString;
190
206
  }, z.core.$strict>>;
207
+ accounting: z.ZodOptional<z.ZodObject<{
208
+ schemaVersion: z.ZodLiteral<1>;
209
+ sourceId: z.ZodString;
210
+ fundingSource: z.ZodEnum<{
211
+ external_subscription: "external_subscription";
212
+ hq_managed: "hq_managed";
213
+ }>;
214
+ currency: z.ZodLiteral<"USD">;
215
+ chargedMicrounits: z.ZodNumber;
216
+ costExact: z.ZodLiteral<true>;
217
+ }, z.core.$strict>>;
191
218
  }, z.core.$strict>;
219
+ export type RuntimeUsage = z.output<typeof RuntimeUsageSchema>;
192
220
  export declare const RuntimeArtifactReferenceSchema: z.ZodObject<{
193
221
  artifactId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"Artifact reference ID">, string>>;
194
222
  version: z.ZodNumber;
@@ -208,6 +236,17 @@ export declare const RuntimeExecutionResultSchema: z.ZodObject<{
208
236
  amount: z.ZodString;
209
237
  currency: z.ZodString;
210
238
  }, z.core.$strict>>;
239
+ accounting: z.ZodOptional<z.ZodObject<{
240
+ schemaVersion: z.ZodLiteral<1>;
241
+ sourceId: z.ZodString;
242
+ fundingSource: z.ZodEnum<{
243
+ external_subscription: "external_subscription";
244
+ hq_managed: "hq_managed";
245
+ }>;
246
+ currency: z.ZodLiteral<"USD">;
247
+ chargedMicrounits: z.ZodNumber;
248
+ costExact: z.ZodLiteral<true>;
249
+ }, z.core.$strict>>;
211
250
  }, z.core.$strict>;
212
251
  artifacts: z.ZodArray<z.ZodObject<{
213
252
  artifactId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"Artifact reference ID">, string>>;
@@ -221,30 +260,30 @@ export declare const RuntimeExecutionResultSchema: z.ZodObject<{
221
260
  export declare const RuntimeErrorSchema: z.ZodObject<{
222
261
  code: z.ZodString;
223
262
  classification: z.ZodEnum<{
224
- unsupported: "unsupported";
225
- unknown: "unknown";
226
- unavailable: "unavailable";
227
- validation: "validation";
228
- conflict: "conflict";
229
- timeout: "timeout";
230
263
  cancelled: "cancelled";
231
- runtime: "runtime";
264
+ conflict: "conflict";
232
265
  infrastructure: "infrastructure";
266
+ runtime: "runtime";
267
+ timeout: "timeout";
268
+ unavailable: "unavailable";
269
+ unknown: "unknown";
270
+ unsupported: "unsupported";
271
+ validation: "validation";
233
272
  }>;
234
273
  message: z.ZodString;
235
274
  retryable: z.ZodBoolean;
236
275
  details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
237
276
  }, z.core.$strict>;
238
277
  export declare const RuntimeExecutionStateSchema: z.ZodEnum<{
239
- unknown: "unknown";
240
- completed: "completed";
241
- cancelled: "cancelled";
242
- starting: "starting";
243
- running: "running";
244
278
  awaiting_input: "awaiting_input";
279
+ cancelled: "cancelled";
245
280
  cancelling: "cancelling";
281
+ completed: "completed";
246
282
  failed: "failed";
283
+ running: "running";
284
+ starting: "starting";
247
285
  timed_out: "timed_out";
286
+ unknown: "unknown";
248
287
  }>;
249
288
  export declare const RuntimeExecutionStatusSchema: z.ZodObject<{
250
289
  handle: z.ZodObject<{
@@ -254,15 +293,15 @@ export declare const RuntimeExecutionStatusSchema: z.ZodObject<{
254
293
  startedAt: z.ZodISODateTime;
255
294
  }, z.core.$strict>;
256
295
  state: z.ZodEnum<{
257
- unknown: "unknown";
258
- completed: "completed";
259
- cancelled: "cancelled";
260
- starting: "starting";
261
- running: "running";
262
296
  awaiting_input: "awaiting_input";
297
+ cancelled: "cancelled";
263
298
  cancelling: "cancelling";
299
+ completed: "completed";
264
300
  failed: "failed";
301
+ running: "running";
302
+ starting: "starting";
265
303
  timed_out: "timed_out";
304
+ unknown: "unknown";
266
305
  }>;
267
306
  observedAt: z.ZodISODateTime;
268
307
  result: z.ZodOptional<z.ZodObject<{
@@ -276,6 +315,17 @@ export declare const RuntimeExecutionStatusSchema: z.ZodObject<{
276
315
  amount: z.ZodString;
277
316
  currency: z.ZodString;
278
317
  }, z.core.$strict>>;
318
+ accounting: z.ZodOptional<z.ZodObject<{
319
+ schemaVersion: z.ZodLiteral<1>;
320
+ sourceId: z.ZodString;
321
+ fundingSource: z.ZodEnum<{
322
+ external_subscription: "external_subscription";
323
+ hq_managed: "hq_managed";
324
+ }>;
325
+ currency: z.ZodLiteral<"USD">;
326
+ chargedMicrounits: z.ZodNumber;
327
+ costExact: z.ZodLiteral<true>;
328
+ }, z.core.$strict>>;
279
329
  }, z.core.$strict>;
280
330
  artifacts: z.ZodArray<z.ZodObject<{
281
331
  artifactId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"Artifact reference ID">, string>>;
@@ -294,19 +344,30 @@ export declare const RuntimeExecutionStatusSchema: z.ZodObject<{
294
344
  amount: z.ZodString;
295
345
  currency: z.ZodString;
296
346
  }, z.core.$strict>>;
347
+ accounting: z.ZodOptional<z.ZodObject<{
348
+ schemaVersion: z.ZodLiteral<1>;
349
+ sourceId: z.ZodString;
350
+ fundingSource: z.ZodEnum<{
351
+ external_subscription: "external_subscription";
352
+ hq_managed: "hq_managed";
353
+ }>;
354
+ currency: z.ZodLiteral<"USD">;
355
+ chargedMicrounits: z.ZodNumber;
356
+ costExact: z.ZodLiteral<true>;
357
+ }, z.core.$strict>>;
297
358
  }, z.core.$strict>>;
298
359
  error: z.ZodOptional<z.ZodObject<{
299
360
  code: z.ZodString;
300
361
  classification: z.ZodEnum<{
301
- unsupported: "unsupported";
302
- unknown: "unknown";
303
- unavailable: "unavailable";
304
- validation: "validation";
305
- conflict: "conflict";
306
- timeout: "timeout";
307
362
  cancelled: "cancelled";
308
- runtime: "runtime";
363
+ conflict: "conflict";
309
364
  infrastructure: "infrastructure";
365
+ runtime: "runtime";
366
+ timeout: "timeout";
367
+ unavailable: "unavailable";
368
+ unknown: "unknown";
369
+ unsupported: "unsupported";
370
+ validation: "validation";
310
371
  }>;
311
372
  message: z.ZodString;
312
373
  retryable: z.ZodBoolean;
@@ -318,11 +379,11 @@ export declare const RuntimeExecutionProgressSchema: z.ZodObject<{
318
379
  sequence: z.ZodNumber;
319
380
  occurredAt: z.ZodISODateTime;
320
381
  type: z.ZodEnum<{
382
+ artifact: "artifact";
383
+ interaction: "interaction";
321
384
  output: "output";
322
- usage: "usage";
323
385
  status: "status";
324
- interaction: "interaction";
325
- artifact: "artifact";
386
+ usage: "usage";
326
387
  }>;
327
388
  data: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
328
389
  }, z.core.$strict>;
@@ -332,34 +393,34 @@ export declare const RuntimeExecutionPlanSnapshotSchema: z.ZodObject<{
332
393
  contentDigest: z.ZodString;
333
394
  runtimeRequirements: z.ZodArray<z.ZodObject<{
334
395
  capability: z.ZodEnum<{
335
- "stream.output": "stream.output";
336
- "stream.events": "stream.events";
337
- "tool.call": "tool.call";
338
- "tool.parallel": "tool.parallel";
339
- "output.structured": "output.structured";
396
+ "execution.cancel": "execution.cancel";
397
+ "execution.child": "execution.child";
340
398
  "filesystem.read": "filesystem.read";
341
399
  "filesystem.write": "filesystem.write";
400
+ "interaction.approval": "interaction.approval";
401
+ "interaction.user-input": "interaction.user-input";
402
+ "model.select": "model.select";
403
+ "output.structured": "output.structured";
342
404
  "project.read": "project.read";
343
405
  "project.write": "project.write";
344
- "execution.cancel": "execution.cancel";
345
- "interaction.user-input": "interaction.user-input";
346
- "interaction.approval": "interaction.approval";
347
- "session.create": "session.create";
348
- "session.list": "session.list";
349
- "session.resume": "session.resume";
350
406
  "session.close": "session.close";
407
+ "session.create": "session.create";
351
408
  "session.history": "session.history";
409
+ "session.list": "session.list";
352
410
  "session.load": "session.load";
353
- "model.select": "model.select";
354
- "execution.child": "execution.child";
411
+ "session.resume": "session.resume";
412
+ "stream.events": "stream.events";
413
+ "stream.output": "stream.output";
414
+ "tool.call": "tool.call";
415
+ "tool.parallel": "tool.parallel";
355
416
  }>;
356
417
  necessity: z.ZodEnum<{
357
418
  optional: "optional";
358
419
  required: "required";
359
420
  }>;
360
421
  minimumSupport: z.ZodDefault<z.ZodEnum<{
361
- supported: "supported";
362
422
  degraded: "degraded";
423
+ supported: "supported";
363
424
  }>>;
364
425
  }, z.core.$strip>>;
365
426
  }, z.core.$catchall<z.ZodUnknown>>;
@@ -372,34 +433,34 @@ export declare const RuntimeStartRequestSchema: z.ZodObject<{
372
433
  contentDigest: z.ZodString;
373
434
  runtimeRequirements: z.ZodArray<z.ZodObject<{
374
435
  capability: z.ZodEnum<{
375
- "stream.output": "stream.output";
376
- "stream.events": "stream.events";
377
- "tool.call": "tool.call";
378
- "tool.parallel": "tool.parallel";
379
- "output.structured": "output.structured";
436
+ "execution.cancel": "execution.cancel";
437
+ "execution.child": "execution.child";
380
438
  "filesystem.read": "filesystem.read";
381
439
  "filesystem.write": "filesystem.write";
440
+ "interaction.approval": "interaction.approval";
441
+ "interaction.user-input": "interaction.user-input";
442
+ "model.select": "model.select";
443
+ "output.structured": "output.structured";
382
444
  "project.read": "project.read";
383
445
  "project.write": "project.write";
384
- "execution.cancel": "execution.cancel";
385
- "interaction.user-input": "interaction.user-input";
386
- "interaction.approval": "interaction.approval";
387
- "session.create": "session.create";
388
- "session.list": "session.list";
389
- "session.resume": "session.resume";
390
446
  "session.close": "session.close";
447
+ "session.create": "session.create";
391
448
  "session.history": "session.history";
449
+ "session.list": "session.list";
392
450
  "session.load": "session.load";
393
- "model.select": "model.select";
394
- "execution.child": "execution.child";
451
+ "session.resume": "session.resume";
452
+ "stream.events": "stream.events";
453
+ "stream.output": "stream.output";
454
+ "tool.call": "tool.call";
455
+ "tool.parallel": "tool.parallel";
395
456
  }>;
396
457
  necessity: z.ZodEnum<{
397
458
  optional: "optional";
398
459
  required: "required";
399
460
  }>;
400
461
  minimumSupport: z.ZodDefault<z.ZodEnum<{
401
- supported: "supported";
402
462
  degraded: "degraded";
463
+ supported: "supported";
403
464
  }>>;
404
465
  }, z.core.$strip>>;
405
466
  }, z.core.$catchall<z.ZodUnknown>>;
@@ -429,9 +490,9 @@ export declare const RuntimeSessionOperationSchema: z.ZodDiscriminatedUnion<[z.Z
429
490
  operation: z.ZodLiteral<"list">;
430
491
  }, z.core.$strict>, z.ZodObject<{
431
492
  operation: z.ZodEnum<{
432
- resume: "resume";
433
- load: "load";
434
493
  close: "close";
494
+ load: "load";
495
+ resume: "resume";
435
496
  }>;
436
497
  sessionId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"external-session ID">, string>>;
437
498
  idempotencyKey: z.ZodOptional<z.ZodString>;
@@ -442,10 +503,10 @@ export declare const RuntimeSessionOperationSchema: z.ZodDiscriminatedUnion<[z.Z
442
503
  }, z.core.$strict>], "operation">;
443
504
  export declare const RuntimeSessionResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
444
505
  operation: z.ZodEnum<{
506
+ close: "close";
445
507
  create: "create";
446
- resume: "resume";
447
508
  load: "load";
448
- close: "close";
509
+ resume: "resume";
449
510
  }>;
450
511
  session: z.ZodObject<{
451
512
  sessionId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@adea-ai/contracts").OpaqueIdentifier<"external-session ID">, string>>;
@@ -476,9 +537,9 @@ export declare const RuntimeSessionResultSchema: z.ZodDiscriminatedUnion<[z.ZodO
476
537
  observedAt: z.ZodISODateTime;
477
538
  }, z.core.$strict>;
478
539
  completeness: z.ZodEnum<{
479
- unavailable: "unavailable";
480
540
  complete: "complete";
481
541
  partial: "partial";
542
+ unavailable: "unavailable";
482
543
  }>;
483
544
  limitations: z.ZodArray<z.ZodString>;
484
545
  entries: z.Zod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,CAAC,IAAI,CAAC,CAAA;CACvD;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAA;IACvD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAA;IAE5D,YAAY,UAAU,EAAE,YAAY,EAQnC;IAED,MAAM,IAAI,YAAY,CAQrB;CACF;AAED,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,wBAAwB,CAAC,cAAc,CAAC,EACtD,YAAY,EAAE,SAAS,qBAAqB,EAAE,GAC7C,oBAAoB,CAEtB"}
package/dist/adapter.js CHANGED
@@ -56,11 +56,45 @@ export const RuntimeExecutionHandleSchema = z
56
56
  startedAt: TimestampSchema,
57
57
  })
58
58
  .strict();
59
+ /**
60
+ * Reported runtime accounting provenance, not funding authorization. Consumers
61
+ * must verify `sourceId` against a trusted authority before charging.
62
+ */
63
+ export const RuntimeUsageAccountingSchema = z
64
+ .object({
65
+ schemaVersion: z.literal(1),
66
+ sourceId: z.string().min(1).max(256),
67
+ fundingSource: z.enum(['hq_managed', 'external_subscription']),
68
+ currency: z.literal('USD'),
69
+ chargedMicrounits: z
70
+ .number()
71
+ .int()
72
+ .nonnegative()
73
+ .refine(Number.isSafeInteger, 'Expected a safe integer'),
74
+ costExact: z.literal(true),
75
+ })
76
+ .strict()
77
+ .superRefine((accounting, context) => {
78
+ if (accounting.fundingSource === 'external_subscription' &&
79
+ accounting.chargedMicrounits !== 0) {
80
+ context.addIssue({
81
+ code: 'custom',
82
+ path: ['chargedMicrounits'],
83
+ message: 'External subscriptions cannot report an HQ charge',
84
+ });
85
+ }
86
+ })
87
+ .describe('Reported accounting metadata only; consumers must verify source authority before charging.');
88
+ const SafeNonnegativeIntegerSchema = z
89
+ .number()
90
+ .int()
91
+ .nonnegative()
92
+ .refine(Number.isSafeInteger, 'Expected a safe integer');
59
93
  export const RuntimeUsageSchema = z
60
94
  .object({
61
- inputTokens: z.number().int().nonnegative(),
62
- outputTokens: z.number().int().nonnegative(),
63
- durationMs: z.number().int().nonnegative(),
95
+ inputTokens: SafeNonnegativeIntegerSchema,
96
+ outputTokens: SafeNonnegativeIntegerSchema,
97
+ durationMs: SafeNonnegativeIntegerSchema,
64
98
  cost: z
65
99
  .object({
66
100
  amount: z.string().regex(/^\d+(?:\.\d+)?$/),
@@ -68,8 +102,40 @@ export const RuntimeUsageSchema = z
68
102
  })
69
103
  .strict()
70
104
  .optional(),
105
+ accounting: RuntimeUsageAccountingSchema.optional(),
71
106
  })
72
- .strict();
107
+ .strict()
108
+ .superRefine((usage, context) => {
109
+ if (usage.inputTokens > Number.MAX_SAFE_INTEGER - usage.outputTokens) {
110
+ context.addIssue({
111
+ code: 'custom',
112
+ path: ['outputTokens'],
113
+ message: 'Combined token usage must be a safe integer',
114
+ });
115
+ }
116
+ if (usage.accounting?.fundingSource === 'hq_managed' && usage.cost !== undefined) {
117
+ if (usage.cost.currency !== 'USD' ||
118
+ exactCostMicrounits(usage.cost.amount) !== BigInt(usage.accounting.chargedMicrounits)) {
119
+ context.addIssue({
120
+ code: 'custom',
121
+ path: ['cost'],
122
+ message: 'HQ-reported cost must exactly match charged USD microunits',
123
+ });
124
+ }
125
+ }
126
+ });
127
+ function exactCostMicrounits(amount) {
128
+ if (amount.length > 64)
129
+ return undefined;
130
+ const [wholePart = '0', fractionPart = ''] = amount.split('.');
131
+ const whole = wholePart.replace(/^0+(?=\d)/, '');
132
+ if (whole.length > 10)
133
+ return undefined;
134
+ if (fractionPart.length > 6 && /[1-9]/.test(fractionPart.slice(6)))
135
+ return undefined;
136
+ const microunits = BigInt(whole) * 1000000n + BigInt(fractionPart.slice(0, 6).padEnd(6, '0') || '0');
137
+ return microunits <= BigInt(Number.MAX_SAFE_INTEGER) ? microunits : undefined;
138
+ }
73
139
  export const RuntimeArtifactReferenceSchema = ArtifactReferenceSchema.omit({
74
140
  contractVersion: true,
75
141
  });