@osfactory/otel-hook 0.8.0 → 0.10.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/README.md +159 -2
- package/dist/{adapter-BJiz6lqM.d.ts → adapter-B9RwW6TO.d.ts} +14 -2
- package/dist/cli.js +2514 -1238
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +5 -2
- package/dist/config.js +479 -169
- package/dist/config.js.map +1 -1
- package/dist/destinations-DWOkVxV1.d.ts +169 -0
- package/dist/diagnostics.d.ts +8 -0
- package/dist/diagnostics.js +2 -1
- package/dist/diagnostics.js.map +1 -1
- package/dist/{events-B3MHoJTD.d.ts → events-CSD_YiJ2.d.ts} +2 -0
- package/dist/{otlp-log-sink-zuHojHSP.d.ts → export-destinations-lORbe25J.d.ts} +241 -9
- package/dist/{filesystem-store-r-nNA3BA.d.ts → filesystem-store-DX3dGIgu.d.ts} +1 -1
- package/dist/{hook-Dh8OO4Wa.d.ts → hook-BAxXoKsp.d.ts} +10 -5
- package/dist/index.d.ts +15 -14
- package/dist/index.js +1936 -730
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +4 -4
- package/dist/install.js +31 -2
- package/dist/install.js.map +1 -1
- package/dist/integration.d.ts +37 -12
- package/dist/integration.js +1942 -617
- package/dist/integration.js.map +1 -1
- package/dist/lifecycle.d.ts +3 -3
- package/dist/lifecycle.js +8 -1
- package/dist/lifecycle.js.map +1 -1
- package/dist/{memory-Bl9ANVff.d.ts → memory-aJilVG4R.d.ts} +2 -2
- package/dist/model.d.ts +1 -1
- package/dist/model.js +7 -0
- package/dist/model.js.map +1 -1
- package/dist/{payload-Ci8_ERm6.d.ts → payload-D7gc0-WQ.d.ts} +41 -2
- package/dist/{ports-n7KFOpKo.d.ts → ports-plO5MKrY.d.ts} +63 -2
- package/dist/providers.d.ts +146 -10
- package/dist/providers.js +397 -13
- package/dist/providers.js.map +1 -1
- package/dist/{registry-CIVvRlVK.d.ts → registry-C7XO4DzD.d.ts} +2 -2
- package/dist/runtime.d.ts +8 -8
- package/dist/runtime.js +1426 -1163
- package/dist/runtime.js.map +1 -1
- package/dist/{schema-Cn0-xz8L.d.ts → schema-CHb3GU1r.d.ts} +98 -3
- package/dist/{semconv-fPRb-dpU.d.ts → semconv-Dw7gcQcg.d.ts} +1 -1
- package/dist/state.d.ts +4 -4
- package/dist/state.js +607 -39
- package/dist/state.js.map +1 -1
- package/dist/telemetry.d.ts +23 -66
- package/dist/telemetry.js +637 -34
- package/dist/telemetry.js.map +1 -1
- package/dist/testing.d.ts +10 -8
- package/dist/testing.js +868 -560
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/config/schema.ts
|
|
2
|
-
import { z as
|
|
2
|
+
import { z as z5 } from "zod";
|
|
3
3
|
|
|
4
4
|
// src/model/primitives.ts
|
|
5
5
|
import { z } from "zod";
|
|
@@ -135,8 +135,112 @@ var resolvePrivacyPolicy = (policy) => {
|
|
|
135
135
|
return { policy: parsed, notes: [] };
|
|
136
136
|
};
|
|
137
137
|
|
|
138
|
-
// src/config/
|
|
138
|
+
// src/config/destinations.ts
|
|
139
139
|
import { z as z3 } from "zod";
|
|
140
|
+
|
|
141
|
+
// src/config/header-value.ts
|
|
142
|
+
var isUnsafeHeaderValue = (value) => [...value].some((char) => {
|
|
143
|
+
const code = char.codePointAt(0) ?? 0;
|
|
144
|
+
return code < 32 && code !== 9 || code === 127 || code > 255;
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// src/config/otlp-headers.ts
|
|
148
|
+
var MAX_OTLP_HEADERS = 32;
|
|
149
|
+
var OTLP_HEADER_VARIABLES = Object.freeze({
|
|
150
|
+
generic: "OTEL_EXPORTER_OTLP_HEADERS",
|
|
151
|
+
traces: "OTEL_EXPORTER_OTLP_TRACES_HEADERS",
|
|
152
|
+
logs: "OTEL_EXPORTER_OTLP_LOGS_HEADERS"
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// src/config/destinations.ts
|
|
156
|
+
var DEFAULT_DESTINATION_NAME = "default";
|
|
157
|
+
var DESTINATION_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]{0,62}$/;
|
|
158
|
+
var MAX_EXPORT_DESTINATIONS = 16;
|
|
159
|
+
var MAX_DESTINATION_HEADERS = MAX_OTLP_HEADERS;
|
|
160
|
+
var HEADER_ENV_REFERENCE_PREFIX = "env:";
|
|
161
|
+
var HEADER_NAME_PATTERN = /^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$/;
|
|
162
|
+
var ENV_VARIABLE_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
163
|
+
var MAX_HEADER_VALUE_LENGTH = 8192;
|
|
164
|
+
var exportSignalSchema = z3.enum(["traces", "logs"]);
|
|
165
|
+
var headerValueSchema = z3.string().min(1).max(MAX_HEADER_VALUE_LENGTH).refine(
|
|
166
|
+
(value) => !isUnsafeHeaderValue(value),
|
|
167
|
+
"header values may not contain line breaks, control characters, or characters beyond Latin-1"
|
|
168
|
+
).refine(
|
|
169
|
+
(value) => !value.startsWith(HEADER_ENV_REFERENCE_PREFIX) || ENV_VARIABLE_NAME_PATTERN.test(value.slice(HEADER_ENV_REFERENCE_PREFIX.length)),
|
|
170
|
+
"an env: header reference must name an environment variable, e.g. env:COLLECTOR_TOKEN"
|
|
171
|
+
);
|
|
172
|
+
var endpointSchema = z3.string().url().max(2048);
|
|
173
|
+
var exportDestinationSchema = z3.strictObject({
|
|
174
|
+
/** Unique, lowercase, filesystem-safe. `default` is reserved for the single-endpoint settings. */
|
|
175
|
+
name: z3.string().regex(DESTINATION_NAME_PATTERN, "destination names are lowercase letters, digits, _ and -"),
|
|
176
|
+
/** Default true. A disabled destination is neither sent to nor drained. */
|
|
177
|
+
enabled: z3.boolean().optional(),
|
|
178
|
+
/**
|
|
179
|
+
* Traces URL, with the same meaning as `exporter.endpoint`: the logs URL is
|
|
180
|
+
* derived from it (`/v1/traces` becomes `/v1/logs`) unless `logsEndpoint` is set.
|
|
181
|
+
*/
|
|
182
|
+
endpoint: endpointSchema.optional(),
|
|
183
|
+
/** Per-signal override of `endpoint` for traces. */
|
|
184
|
+
tracesEndpoint: endpointSchema.optional(),
|
|
185
|
+
/** Per-signal override of the derived logs URL. */
|
|
186
|
+
logsEndpoint: endpointSchema.optional(),
|
|
187
|
+
/** Defaults to `exporter.protocol`. */
|
|
188
|
+
protocol: z3.enum(["http/protobuf", "http/json", "none"]).optional(),
|
|
189
|
+
/**
|
|
190
|
+
* Header name to value. A value of the form `env:NAME` is read from that
|
|
191
|
+
* environment variable at send time, so a credential never has to be written
|
|
192
|
+
* into the file. Values never appear in a snapshot, a diagnostic, or `doctor`.
|
|
193
|
+
*/
|
|
194
|
+
headers: z3.record(z3.string().regex(HEADER_NAME_PATTERN, "not a valid header name"), headerValueSchema).refine(
|
|
195
|
+
(headers) => Object.keys(headers).length <= MAX_DESTINATION_HEADERS,
|
|
196
|
+
`at most ${String(MAX_DESTINATION_HEADERS)} headers per destination`
|
|
197
|
+
).optional(),
|
|
198
|
+
/**
|
|
199
|
+
* Which signals this destination receives. Default: both. The logs signal is
|
|
200
|
+
* still governed by `exporter.logs.enabled`, which stays the one opt-in for a
|
|
201
|
+
* second stream leaving the host.
|
|
202
|
+
*/
|
|
203
|
+
signals: z3.array(exportSignalSchema).min(1).max(2).readonly().optional()
|
|
204
|
+
}).refine(
|
|
205
|
+
(destination) => destination.endpoint !== void 0 || destination.tracesEndpoint !== void 0 || destination.logsEndpoint !== void 0,
|
|
206
|
+
"a destination needs an endpoint, or a tracesEndpoint / logsEndpoint"
|
|
207
|
+
);
|
|
208
|
+
var exportDestinationsSchema = z3.array(exportDestinationSchema).max(MAX_EXPORT_DESTINATIONS).readonly().superRefine((destinations, context) => {
|
|
209
|
+
const seen = /* @__PURE__ */ new Set();
|
|
210
|
+
destinations.forEach((destination, index) => {
|
|
211
|
+
if (destination.name === DEFAULT_DESTINATION_NAME) {
|
|
212
|
+
context.addIssue({
|
|
213
|
+
code: "custom",
|
|
214
|
+
path: [index, "name"],
|
|
215
|
+
message: 'the name "default" is reserved for exporter.endpoint and the OTEL_EXPORTER_OTLP_* variables'
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
if (seen.has(destination.name)) {
|
|
219
|
+
context.addIssue({
|
|
220
|
+
code: "custom",
|
|
221
|
+
path: [index, "name"],
|
|
222
|
+
message: `duplicate destination name "${destination.name}"`
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
seen.add(destination.name);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
var spoolPolicySchema = z3.strictObject({
|
|
229
|
+
/** Total bytes of queued batches. Default 16 MiB. */
|
|
230
|
+
maxBytes: z3.number().int().min(1024).max(1073741824),
|
|
231
|
+
/** A batch older than this is dropped instead of sent. Default 72 hours. */
|
|
232
|
+
maxAgeMillis: z3.number().int().min(1e3).max(30 * 24 * 60 * 60 * 1e3),
|
|
233
|
+
/** Number of queued batches. Default 500. */
|
|
234
|
+
maxBatches: z3.number().int().min(1).max(65536)
|
|
235
|
+
});
|
|
236
|
+
var DEFAULT_SPOOL_POLICY = Object.freeze({
|
|
237
|
+
maxBytes: 16 * 1024 * 1024,
|
|
238
|
+
maxAgeMillis: 72 * 60 * 60 * 1e3,
|
|
239
|
+
maxBatches: 500
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
// src/config/resource-attributes.ts
|
|
243
|
+
import { z as z4 } from "zod";
|
|
140
244
|
var MAX_RESOURCE_ATTRIBUTES = 64;
|
|
141
245
|
var MAX_RESOURCE_ATTRIBUTE_KEY_LENGTH = 255;
|
|
142
246
|
var MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH = 2048;
|
|
@@ -181,12 +285,12 @@ var checkResourceAttributeKey = (key) => {
|
|
|
181
285
|
}
|
|
182
286
|
return void 0;
|
|
183
287
|
};
|
|
184
|
-
var resourceAttributeValueSchema =
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
288
|
+
var resourceAttributeValueSchema = z4.union([
|
|
289
|
+
z4.string().max(MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH),
|
|
290
|
+
z4.number().finite(),
|
|
291
|
+
z4.boolean()
|
|
188
292
|
]);
|
|
189
|
-
var resourceAttributesSchema =
|
|
293
|
+
var resourceAttributesSchema = z4.record(z4.string(), resourceAttributeValueSchema).superRefine((value, ctx) => {
|
|
190
294
|
const keys = Object.keys(value);
|
|
191
295
|
if (keys.length > MAX_RESOURCE_ATTRIBUTES) {
|
|
192
296
|
ctx.addIssue({
|
|
@@ -208,36 +312,36 @@ var resourceAttributesSchema = z3.record(z3.string(), resourceAttributeValueSche
|
|
|
208
312
|
var EMPTY_RESOURCE_ATTRIBUTES = Object.freeze({});
|
|
209
313
|
|
|
210
314
|
// src/config/schema.ts
|
|
211
|
-
var logsPolicySchema =
|
|
212
|
-
enabled:
|
|
315
|
+
var logsPolicySchema = z5.strictObject({
|
|
316
|
+
enabled: z5.boolean(),
|
|
213
317
|
/**
|
|
214
318
|
* Full URL for the logs signal.
|
|
215
319
|
*
|
|
216
320
|
* Absent, it is derived from `endpoint`: a trailing `/v1/traces` becomes
|
|
217
321
|
* `/v1/logs`, and an endpoint with no signal path has `/v1/logs` appended.
|
|
218
322
|
*/
|
|
219
|
-
endpoint:
|
|
220
|
-
includeContent:
|
|
221
|
-
maxBatchSize:
|
|
323
|
+
endpoint: z5.string().url().max(2048).optional(),
|
|
324
|
+
includeContent: z5.boolean(),
|
|
325
|
+
maxBatchSize: z5.number().int().min(1).max(4096)
|
|
222
326
|
});
|
|
223
327
|
var DEFAULT_LOGS_POLICY = Object.freeze({
|
|
224
328
|
enabled: false,
|
|
225
329
|
includeContent: false,
|
|
226
330
|
maxBatchSize: 128
|
|
227
331
|
});
|
|
228
|
-
var exporterPolicySchema =
|
|
229
|
-
enabled:
|
|
230
|
-
protocol:
|
|
231
|
-
endpoint:
|
|
332
|
+
var exporterPolicySchema = z5.strictObject({
|
|
333
|
+
enabled: z5.boolean(),
|
|
334
|
+
protocol: z5.enum(["http/protobuf", "http/json", "none"]),
|
|
335
|
+
endpoint: z5.string().url().max(2048).optional(),
|
|
232
336
|
/**
|
|
233
337
|
* Header names only. Values are supplied separately at construction time and
|
|
234
338
|
* are never part of a resolved-config snapshot, which is logged and exported.
|
|
235
339
|
*/
|
|
236
|
-
headerNames:
|
|
237
|
-
timeoutMillis:
|
|
238
|
-
maxBatchSize:
|
|
239
|
-
maxQueueSize:
|
|
240
|
-
maxRetryAttempts:
|
|
340
|
+
headerNames: z5.array(nonEmptyStringSchema).max(32).readonly(),
|
|
341
|
+
timeoutMillis: z5.number().int().min(1).max(6e5),
|
|
342
|
+
maxBatchSize: z5.number().int().min(1).max(4096),
|
|
343
|
+
maxQueueSize: z5.number().int().min(1).max(65536),
|
|
344
|
+
maxRetryAttempts: z5.number().int().min(0).max(10),
|
|
241
345
|
serviceName: nonEmptyStringSchema,
|
|
242
346
|
serviceNamespace: nonEmptyStringSchema.optional(),
|
|
243
347
|
/**
|
|
@@ -254,35 +358,65 @@ var exporterPolicySchema = z4.strictObject({
|
|
|
254
358
|
* headers, timeout, protocol, service identity, and resource attributes above —
|
|
255
359
|
* a second top-level section would invite two of each to drift apart.
|
|
256
360
|
*/
|
|
257
|
-
logs: logsPolicySchema
|
|
361
|
+
logs: logsPolicySchema,
|
|
362
|
+
/**
|
|
363
|
+
* Additional OTLP destinations, each sent every batch in parallel.
|
|
364
|
+
*
|
|
365
|
+
* Absent (the default), the exporter has exactly one destination — the
|
|
366
|
+
* single-endpoint settings above, named `default` — and behaves exactly as it
|
|
367
|
+
* did before this list existed. See `destinations.ts`.
|
|
368
|
+
*
|
|
369
|
+
* Merged as one leaf: a higher layer that sets the list replaces it whole,
|
|
370
|
+
* because "the union of two partial lists" has no answer an operator could
|
|
371
|
+
* predict.
|
|
372
|
+
*/
|
|
373
|
+
destinations: exportDestinationsSchema.optional(),
|
|
374
|
+
/**
|
|
375
|
+
* Per-destination retry spool bounds, each optional and merged per leaf; any
|
|
376
|
+
* bound left unset takes its value from `DEFAULT_SPOOL_POLICY`.
|
|
377
|
+
*/
|
|
378
|
+
spool: spoolPolicySchema.partial().optional()
|
|
258
379
|
});
|
|
259
|
-
var detectionPolicySchema =
|
|
380
|
+
var detectionPolicySchema = z5.strictObject({
|
|
260
381
|
/** Detections below this confidence resolve to the unknown provider. */
|
|
261
382
|
minimumConfidence: detectionConfidenceSchema,
|
|
262
383
|
/** When false, an ambiguous detection is an error rather than unknown. */
|
|
263
|
-
allowAmbiguousFallback:
|
|
384
|
+
allowAmbiguousFallback: z5.boolean(),
|
|
264
385
|
/** Optional allow-list of provider ids; empty means "any registered". */
|
|
265
|
-
allowedProviderIds:
|
|
386
|
+
allowedProviderIds: z5.array(nonEmptyStringSchema).max(32).readonly()
|
|
266
387
|
});
|
|
267
|
-
var diagnosticsPolicySchema =
|
|
268
|
-
logLevel:
|
|
388
|
+
var diagnosticsPolicySchema = z5.strictObject({
|
|
389
|
+
logLevel: z5.enum(["silent", "error", "warn", "info", "debug"]),
|
|
269
390
|
/** Emit `error.raised` events for contained failures. */
|
|
270
|
-
emitErrorEvents:
|
|
391
|
+
emitErrorEvents: z5.boolean()
|
|
392
|
+
});
|
|
393
|
+
var providersPolicySchema = z5.strictObject({
|
|
394
|
+
claudeCode: z5.strictObject({
|
|
395
|
+
readTranscriptUsage: z5.boolean()
|
|
396
|
+
}).optional()
|
|
271
397
|
});
|
|
272
|
-
var otelHookConfigSchema =
|
|
398
|
+
var otelHookConfigSchema = z5.strictObject({
|
|
273
399
|
exporter: exporterPolicySchema,
|
|
274
400
|
privacy: privacyPolicySchema,
|
|
275
401
|
detection: detectionPolicySchema,
|
|
276
|
-
diagnostics: diagnosticsPolicySchema
|
|
402
|
+
diagnostics: diagnosticsPolicySchema,
|
|
403
|
+
/** Optional so a hand-built configuration from before it existed stays valid. */
|
|
404
|
+
providers: providersPolicySchema.optional()
|
|
277
405
|
});
|
|
278
|
-
var otelHookConfigPatchSchema =
|
|
406
|
+
var otelHookConfigPatchSchema = z5.strictObject({
|
|
279
407
|
// `logs` is unwrapped and re-partialled for the same reason `privacy.limits` is:
|
|
280
408
|
// merging happens per leaf, so a layer must be able to set `logs.enabled` alone
|
|
281
409
|
// without also restating the endpoint and the batch size.
|
|
282
|
-
exporter: exporterPolicySchema.omit({ logs: true }).partial().extend({
|
|
410
|
+
exporter: exporterPolicySchema.omit({ logs: true, spool: true }).partial().extend({
|
|
411
|
+
logs: logsPolicySchema.partial().optional(),
|
|
412
|
+
spool: spoolPolicySchema.partial().optional()
|
|
413
|
+
}).optional(),
|
|
283
414
|
privacy: privacyPolicySchema.omit({ limits: true }).partial().extend({ limits: privacyPolicySchema.shape.limits.partial().optional() }).optional(),
|
|
284
415
|
detection: detectionPolicySchema.partial().optional(),
|
|
285
|
-
diagnostics: diagnosticsPolicySchema.partial().optional()
|
|
416
|
+
diagnostics: diagnosticsPolicySchema.partial().optional(),
|
|
417
|
+
providers: z5.strictObject({
|
|
418
|
+
claudeCode: z5.strictObject({ readTranscriptUsage: z5.boolean() }).partial().optional()
|
|
419
|
+
}).partial().optional()
|
|
286
420
|
});
|
|
287
421
|
var DEFAULT_EXPORTER_POLICY = Object.freeze({
|
|
288
422
|
enabled: true,
|
|
@@ -305,23 +439,27 @@ var DEFAULT_DIAGNOSTICS_POLICY = Object.freeze({
|
|
|
305
439
|
logLevel: "warn",
|
|
306
440
|
emitErrorEvents: true
|
|
307
441
|
});
|
|
442
|
+
var DEFAULT_PROVIDERS_POLICY = Object.freeze({
|
|
443
|
+
claudeCode: Object.freeze({ readTranscriptUsage: false })
|
|
444
|
+
});
|
|
308
445
|
var DEFAULT_CONFIG = Object.freeze({
|
|
309
446
|
exporter: DEFAULT_EXPORTER_POLICY,
|
|
310
447
|
privacy: DEFAULT_PRIVACY_POLICY,
|
|
311
448
|
detection: DEFAULT_DETECTION_POLICY,
|
|
312
|
-
diagnostics: DEFAULT_DIAGNOSTICS_POLICY
|
|
449
|
+
diagnostics: DEFAULT_DIAGNOSTICS_POLICY,
|
|
450
|
+
providers: DEFAULT_PROVIDERS_POLICY
|
|
313
451
|
});
|
|
314
452
|
|
|
315
453
|
// src/model/identity.ts
|
|
316
|
-
import { z as
|
|
317
|
-
var workspaceKeySourceSchema =
|
|
454
|
+
import { z as z6 } from "zod";
|
|
455
|
+
var workspaceKeySourceSchema = z6.enum([
|
|
318
456
|
"git-remote",
|
|
319
457
|
"git-root",
|
|
320
458
|
"working-directory",
|
|
321
459
|
"explicit",
|
|
322
460
|
"unknown"
|
|
323
461
|
]);
|
|
324
|
-
var workspaceIdentitySchema =
|
|
462
|
+
var workspaceIdentitySchema = z6.strictObject({
|
|
325
463
|
workspaceId: workspaceIdSchema,
|
|
326
464
|
keySource: workspaceKeySourceSchema,
|
|
327
465
|
/** Repository name only; never an owner path or URL with credentials. */
|
|
@@ -335,7 +473,7 @@ var unknownWorkspaceIdentity = () => workspaceIdentitySchema.parse({
|
|
|
335
473
|
workspaceId: UNKNOWN_WORKSPACE_ID,
|
|
336
474
|
keySource: "unknown"
|
|
337
475
|
});
|
|
338
|
-
var sourceProvenanceSchema =
|
|
476
|
+
var sourceProvenanceSchema = z6.strictObject({
|
|
339
477
|
providerId: resolvedProviderIdSchema,
|
|
340
478
|
providerVersion: nonEmptyStringSchema.optional(),
|
|
341
479
|
adapterId: nonEmptyStringSchema,
|
|
@@ -346,7 +484,7 @@ var sourceProvenanceSchema = z5.strictObject({
|
|
|
346
484
|
transport: sourceTransportSchema
|
|
347
485
|
}).readonly();
|
|
348
486
|
var consumerAttributesSchema = attributesSchema.readonly();
|
|
349
|
-
var invocationIdentitySchema =
|
|
487
|
+
var invocationIdentitySchema = z6.strictObject({
|
|
350
488
|
invocationId: invocationIdSchema,
|
|
351
489
|
sessionId: sessionIdSchema,
|
|
352
490
|
/** Set when this invocation runs beneath another agent invocation. */
|
|
@@ -360,7 +498,7 @@ var invocationIdentitySchema = z5.strictObject({
|
|
|
360
498
|
startedAt: epochMillisSchema,
|
|
361
499
|
consumerAttributes: consumerAttributesSchema
|
|
362
500
|
}).readonly();
|
|
363
|
-
var identityClaimFieldsSchema =
|
|
501
|
+
var identityClaimFieldsSchema = z6.strictObject({
|
|
364
502
|
invocationId: invocationIdSchema.optional(),
|
|
365
503
|
sessionId: sessionIdSchema.optional(),
|
|
366
504
|
parentInvocationId: invocationIdSchema.optional(),
|
|
@@ -369,7 +507,7 @@ var identityClaimFieldsSchema = z5.strictObject({
|
|
|
369
507
|
workspace: workspaceIdentitySchema.optional(),
|
|
370
508
|
startedAt: epochMillisSchema.optional()
|
|
371
509
|
});
|
|
372
|
-
var identityClaimSchema =
|
|
510
|
+
var identityClaimSchema = z6.strictObject({
|
|
373
511
|
/** Non-sensitive label, e.g. `adapter:acme-cli` or `env:OTEL_HOOK_SESSION_ID`. */
|
|
374
512
|
source: nonEmptyStringSchema,
|
|
375
513
|
confidence: detectionConfidenceSchema,
|
|
@@ -493,7 +631,7 @@ var resolveInvocationIdentity = (input) => {
|
|
|
493
631
|
import { createHash } from "crypto";
|
|
494
632
|
|
|
495
633
|
// src/model/extensions.ts
|
|
496
|
-
import { z as
|
|
634
|
+
import { z as z7 } from "zod";
|
|
497
635
|
var EXTENSION_KEY_PATTERN = /^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*(?:\.[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*)+$/;
|
|
498
636
|
var RESERVED_EXTENSION_NAMESPACES = Object.freeze([
|
|
499
637
|
"otelhook",
|
|
@@ -504,7 +642,7 @@ var MAX_EXTENSION_ENTRIES = 64;
|
|
|
504
642
|
var extensionKeyNamespace = (key) => key.slice(0, key.indexOf("."));
|
|
505
643
|
var isReservedExtensionNamespace = (key) => RESERVED_EXTENSION_NAMESPACES.includes(extensionKeyNamespace(key));
|
|
506
644
|
var isValidExtensionKey = (key) => EXTENSION_KEY_PATTERN.test(key) && !isReservedExtensionNamespace(key);
|
|
507
|
-
var extensionsSchema =
|
|
645
|
+
var extensionsSchema = z7.record(z7.string(), attributeValueSchema).check((ctx) => {
|
|
508
646
|
const keys = Object.keys(ctx.value);
|
|
509
647
|
if (keys.length > MAX_EXTENSION_ENTRIES) {
|
|
510
648
|
ctx.issues.push({
|
|
@@ -754,11 +892,11 @@ var createPrivacyService = (policyInput) => {
|
|
|
754
892
|
};
|
|
755
893
|
const flattenToAttributes = (value, prefix) => {
|
|
756
894
|
const attributes = {};
|
|
757
|
-
const walk = (current,
|
|
895
|
+
const walk = (current, path3) => {
|
|
758
896
|
if (typeof current === "string" || typeof current === "number" || typeof current === "boolean") {
|
|
759
897
|
const primitive = toAttributePrimitive(current);
|
|
760
898
|
if (primitive !== void 0) {
|
|
761
|
-
attributes[
|
|
899
|
+
attributes[path3] = primitive;
|
|
762
900
|
}
|
|
763
901
|
return;
|
|
764
902
|
}
|
|
@@ -777,16 +915,16 @@ var createPrivacyService = (policyInput) => {
|
|
|
777
915
|
primitives.push(entryPrimitive);
|
|
778
916
|
}
|
|
779
917
|
if (uniform) {
|
|
780
|
-
attributes[
|
|
918
|
+
attributes[path3] = primitives.slice(0, MAX_ATTRIBUTE_ARRAY_LENGTH);
|
|
781
919
|
return;
|
|
782
920
|
}
|
|
783
921
|
for (const [index, entry] of current.entries()) {
|
|
784
|
-
walk(entry, `${
|
|
922
|
+
walk(entry, `${path3}.${index}`);
|
|
785
923
|
}
|
|
786
924
|
return;
|
|
787
925
|
}
|
|
788
926
|
for (const [key, entry] of Object.entries(current)) {
|
|
789
|
-
walk(entry,
|
|
927
|
+
walk(entry, path3 === "" ? key : `${path3}.${key}`);
|
|
790
928
|
}
|
|
791
929
|
};
|
|
792
930
|
walk(value, prefix);
|
|
@@ -879,14 +1017,14 @@ var createPrivacyService = (policyInput) => {
|
|
|
879
1017
|
};
|
|
880
1018
|
|
|
881
1019
|
// src/providers/adapter.ts
|
|
882
|
-
import { z as
|
|
1020
|
+
import { z as z14 } from "zod";
|
|
883
1021
|
|
|
884
1022
|
// src/model/events.ts
|
|
885
|
-
import { z as
|
|
1023
|
+
import { z as z13 } from "zod";
|
|
886
1024
|
|
|
887
1025
|
// src/errors/taxonomy.ts
|
|
888
|
-
import { z as
|
|
889
|
-
var otelHookErrorCodeSchema =
|
|
1026
|
+
import { z as z8 } from "zod";
|
|
1027
|
+
var otelHookErrorCodeSchema = z8.enum([
|
|
890
1028
|
/** Input was not usable at all (empty stdin, unparsable JSON). */
|
|
891
1029
|
"invalid-input",
|
|
892
1030
|
/** Input parsed but failed canonical schema validation. */
|
|
@@ -922,8 +1060,8 @@ var otelHookErrorCodeSchema = z7.enum([
|
|
|
922
1060
|
/** Anything unanticipated. Always reported, never fatal to the host. */
|
|
923
1061
|
"internal-error"
|
|
924
1062
|
]);
|
|
925
|
-
var errorSeveritySchema =
|
|
926
|
-
var errorPhaseSchema =
|
|
1063
|
+
var errorSeveritySchema = z8.enum(["warning", "error"]);
|
|
1064
|
+
var errorPhaseSchema = z8.enum([
|
|
927
1065
|
"configuration",
|
|
928
1066
|
"detection",
|
|
929
1067
|
"identity",
|
|
@@ -934,7 +1072,7 @@ var errorPhaseSchema = z7.enum([
|
|
|
934
1072
|
"export",
|
|
935
1073
|
"shutdown"
|
|
936
1074
|
]);
|
|
937
|
-
var failurePostureSchema =
|
|
1075
|
+
var failurePostureSchema = z8.enum(["fail-open", "fail-closed-attribution"]);
|
|
938
1076
|
var ERROR_TAXONOMY = Object.freeze({
|
|
939
1077
|
"invalid-input": {
|
|
940
1078
|
code: "invalid-input",
|
|
@@ -1059,7 +1197,7 @@ var ERROR_TAXONOMY = Object.freeze({
|
|
|
1059
1197
|
}
|
|
1060
1198
|
});
|
|
1061
1199
|
var describeErrorCode = (code) => ERROR_TAXONOMY[code];
|
|
1062
|
-
var attributionOutcomeSchema =
|
|
1200
|
+
var attributionOutcomeSchema = z8.enum([
|
|
1063
1201
|
/** Identity resolved; events carry provider and session identity. */
|
|
1064
1202
|
"attributed",
|
|
1065
1203
|
/** Identity could not be established safely; nothing was attributed. */
|
|
@@ -1069,7 +1207,7 @@ var attributionOutcomeSchema = z7.enum([
|
|
|
1069
1207
|
/** Input was recognized but intentionally carried no telemetry. */
|
|
1070
1208
|
"not-applicable"
|
|
1071
1209
|
]);
|
|
1072
|
-
var attributionReasonSchema =
|
|
1210
|
+
var attributionReasonSchema = z8.enum([
|
|
1073
1211
|
"provider-unknown",
|
|
1074
1212
|
"provider-detection-ambiguous",
|
|
1075
1213
|
"identity-conflict",
|
|
@@ -1081,8 +1219,8 @@ var attributionReasonSchema = z7.enum([
|
|
|
1081
1219
|
]);
|
|
1082
1220
|
|
|
1083
1221
|
// src/model/content.ts
|
|
1084
|
-
import { z as
|
|
1085
|
-
var contentKindSchema =
|
|
1222
|
+
import { z as z9 } from "zod";
|
|
1223
|
+
var contentKindSchema = z9.enum([
|
|
1086
1224
|
"prompt",
|
|
1087
1225
|
"response",
|
|
1088
1226
|
"reasoning",
|
|
@@ -1092,47 +1230,47 @@ var contentKindSchema = z8.enum([
|
|
|
1092
1230
|
"system-instruction",
|
|
1093
1231
|
"attachment"
|
|
1094
1232
|
]);
|
|
1095
|
-
var contentRoleSchema =
|
|
1096
|
-
var contentDisclosureSchema =
|
|
1233
|
+
var contentRoleSchema = z9.enum(["user", "assistant", "system", "tool", "unknown"]);
|
|
1234
|
+
var contentDisclosureSchema = z9.enum(["omitted", "masked", "redacted", "raw"]);
|
|
1097
1235
|
var CONTENT_HASH_PATTERN = /^sha256:[0-9a-f]{64}$/;
|
|
1098
|
-
var contentFactSchema =
|
|
1236
|
+
var contentFactSchema = z9.strictObject({
|
|
1099
1237
|
kind: contentKindSchema,
|
|
1100
1238
|
role: contentRoleSchema.optional(),
|
|
1101
1239
|
/** Unicode code point count of the original content. */
|
|
1102
|
-
characterLength:
|
|
1240
|
+
characterLength: z9.number().int().min(0),
|
|
1103
1241
|
/** UTF-8 byte length of the original content. */
|
|
1104
|
-
byteLength:
|
|
1242
|
+
byteLength: z9.number().int().min(0),
|
|
1105
1243
|
/** Stable salted digest of the original content. */
|
|
1106
|
-
contentHash:
|
|
1244
|
+
contentHash: z9.string().regex(CONTENT_HASH_PATTERN),
|
|
1107
1245
|
disclosure: contentDisclosureSchema,
|
|
1108
1246
|
/** Disclosed text, bounded by the privacy policy. Absent when omitted. */
|
|
1109
|
-
text:
|
|
1247
|
+
text: z9.string().optional(),
|
|
1110
1248
|
/** True when `text` was cut short by the configured string bound. */
|
|
1111
|
-
truncated:
|
|
1249
|
+
truncated: z9.boolean(),
|
|
1112
1250
|
/** Number of secret-looking spans replaced while producing `text`. */
|
|
1113
|
-
secretsRedacted:
|
|
1251
|
+
secretsRedacted: z9.number().int().min(0),
|
|
1114
1252
|
/** Optional non-sensitive label, e.g. a MIME type or tool name. */
|
|
1115
1253
|
label: nonEmptyStringSchema.optional()
|
|
1116
1254
|
});
|
|
1117
|
-
var contentFactsSchema =
|
|
1255
|
+
var contentFactsSchema = z9.array(contentFactSchema).max(64);
|
|
1118
1256
|
var isContentFactConsistent = (fact) => fact.disclosure === "omitted" ? fact.text === void 0 : fact.text !== void 0;
|
|
1119
1257
|
var isUnavailableContentFact = (fact) => fact.disclosure === "omitted" && fact.text === void 0 && fact.characterLength === 0 && fact.byteLength === 0;
|
|
1120
1258
|
|
|
1121
1259
|
// src/model/target.ts
|
|
1122
|
-
import { z as
|
|
1123
|
-
var targetSourceSchema =
|
|
1260
|
+
import { z as z10 } from "zod";
|
|
1261
|
+
var targetSourceSchema = z10.enum(["tool-path", "shell-cwd", "session-cwd"]);
|
|
1124
1262
|
var MAX_TARGET_HINT_PATHS = 8;
|
|
1125
1263
|
var MAX_TARGET_PATH_LENGTH = 4096;
|
|
1126
|
-
var localPathSchema =
|
|
1127
|
-
var targetHintSchema =
|
|
1264
|
+
var localPathSchema = z10.string().min(1).max(MAX_TARGET_PATH_LENGTH).refine((value) => !value.includes("\0"), "path must not contain NUL");
|
|
1265
|
+
var targetHintSchema = z10.strictObject({
|
|
1128
1266
|
source: targetSourceSchema,
|
|
1129
|
-
paths:
|
|
1267
|
+
paths: z10.array(localPathSchema).min(1).max(MAX_TARGET_HINT_PATHS).readonly(),
|
|
1130
1268
|
/** Absolute directory that relative `paths` resolve against. */
|
|
1131
1269
|
baseDirectory: localPathSchema.optional()
|
|
1132
1270
|
}).readonly();
|
|
1133
1271
|
var sessionCwdHint = (cwd) => cwd === void 0 || cwd.length === 0 ? void 0 : { source: "session-cwd", paths: [cwd] };
|
|
1134
|
-
var worktreeKindSchema =
|
|
1135
|
-
var workspaceTargetSchema =
|
|
1272
|
+
var worktreeKindSchema = z10.enum(["main", "linked"]);
|
|
1273
|
+
var workspaceTargetSchema = z10.strictObject({
|
|
1136
1274
|
workspaceId: workspaceIdSchema,
|
|
1137
1275
|
/** Branch checked out in that worktree; absent on a detached HEAD. */
|
|
1138
1276
|
vcsBranchName: nonEmptyStringSchema.optional(),
|
|
@@ -1142,18 +1280,18 @@ var workspaceTargetSchema = z9.strictObject({
|
|
|
1142
1280
|
worktreeKind: worktreeKindSchema.optional()
|
|
1143
1281
|
}).readonly();
|
|
1144
1282
|
var SUBAGENT_ID_PATTERN = /^[A-Za-z0-9_.:@+=-]{1,256}$/;
|
|
1145
|
-
var subagentIdSchema =
|
|
1283
|
+
var subagentIdSchema = z10.string().regex(SUBAGENT_ID_PATTERN);
|
|
1146
1284
|
|
|
1147
1285
|
// src/model/usage.ts
|
|
1148
|
-
import { z as
|
|
1149
|
-
var usageTemporalitySchema =
|
|
1150
|
-
var cacheCreationAccountingSchema =
|
|
1286
|
+
import { z as z11 } from "zod";
|
|
1287
|
+
var usageTemporalitySchema = z11.enum(["delta", "cumulative"]);
|
|
1288
|
+
var cacheCreationAccountingSchema = z11.enum([
|
|
1151
1289
|
"included-in-input",
|
|
1152
1290
|
"disjoint-from-input",
|
|
1153
1291
|
"not-reported"
|
|
1154
1292
|
]);
|
|
1155
|
-
var providerTotalAgreementSchema =
|
|
1156
|
-
var usageReportSchema =
|
|
1293
|
+
var providerTotalAgreementSchema = z11.enum(["unreported", "agrees", "disagrees"]);
|
|
1294
|
+
var usageReportSchema = z11.strictObject({
|
|
1157
1295
|
temporality: usageTemporalitySchema,
|
|
1158
1296
|
/** Inclusive input tokens. */
|
|
1159
1297
|
inputTokens: tokenCountSchema.optional(),
|
|
@@ -1170,7 +1308,7 @@ var usageReportSchema = z10.strictObject({
|
|
|
1170
1308
|
/** Total exactly as the provider reported it, if it reported one. */
|
|
1171
1309
|
providerTotalTokens: tokenCountSchema.optional()
|
|
1172
1310
|
});
|
|
1173
|
-
var canonicalUsageSchema =
|
|
1311
|
+
var canonicalUsageSchema = z11.strictObject({
|
|
1174
1312
|
temporality: usageTemporalitySchema,
|
|
1175
1313
|
inputTokens: tokenCountSchema,
|
|
1176
1314
|
cachedInputTokens: tokenCountSchema,
|
|
@@ -1371,24 +1509,24 @@ var toReport = (usage) => ({
|
|
|
1371
1509
|
});
|
|
1372
1510
|
|
|
1373
1511
|
// src/model/version.ts
|
|
1374
|
-
import { z as
|
|
1512
|
+
import { z as z12 } from "zod";
|
|
1375
1513
|
var CANONICAL_SCHEMA_VERSION = 1;
|
|
1376
|
-
var canonicalSchemaVersionSchema =
|
|
1514
|
+
var canonicalSchemaVersionSchema = z12.literal(CANONICAL_SCHEMA_VERSION);
|
|
1377
1515
|
|
|
1378
1516
|
// src/model/events.ts
|
|
1379
|
-
var modelDescriptorSchema =
|
|
1517
|
+
var modelDescriptorSchema = z13.strictObject({
|
|
1380
1518
|
modelId: nonEmptyStringSchema,
|
|
1381
1519
|
/** Vendor of the model, e.g. `anthropic`. Distinct from the agent provider. */
|
|
1382
1520
|
vendor: nonEmptyStringSchema.optional(),
|
|
1383
1521
|
family: nonEmptyStringSchema.optional()
|
|
1384
1522
|
});
|
|
1385
|
-
var costFactsSchema =
|
|
1523
|
+
var costFactsSchema = z13.strictObject({
|
|
1386
1524
|
/** ISO 4217 code. */
|
|
1387
|
-
currency:
|
|
1388
|
-
amount:
|
|
1389
|
-
source:
|
|
1525
|
+
currency: z13.string().length(3),
|
|
1526
|
+
amount: z13.number().min(0).finite(),
|
|
1527
|
+
source: z13.enum(["provider-reported", "computed"])
|
|
1390
1528
|
});
|
|
1391
|
-
var canonicalEventTypeSchema =
|
|
1529
|
+
var canonicalEventTypeSchema = z13.enum([
|
|
1392
1530
|
"session.start",
|
|
1393
1531
|
"session.end",
|
|
1394
1532
|
"prompt.submitted",
|
|
@@ -1402,7 +1540,7 @@ var canonicalEventTypeSchema = z12.enum([
|
|
|
1402
1540
|
"error.raised"
|
|
1403
1541
|
]);
|
|
1404
1542
|
var CANONICAL_EVENT_TYPES = canonicalEventTypeSchema.options;
|
|
1405
|
-
var outcomeSchema =
|
|
1543
|
+
var outcomeSchema = z13.enum(["ok", "error", "cancelled", "timeout", "denied", "unknown"]);
|
|
1406
1544
|
var baseEventFields = {
|
|
1407
1545
|
schemaVersion: canonicalSchemaVersionSchema,
|
|
1408
1546
|
eventId: eventIdSchema,
|
|
@@ -1421,10 +1559,10 @@ var baseEventFields = {
|
|
|
1421
1559
|
subagentId: subagentIdSchema.optional(),
|
|
1422
1560
|
extensions: extensionsSchema.default(emptyExtensions)
|
|
1423
1561
|
};
|
|
1424
|
-
var event = (shape) =>
|
|
1562
|
+
var event = (shape) => z13.strictObject({ ...baseEventFields, ...shape });
|
|
1425
1563
|
var sessionStartEventSchema = event({
|
|
1426
|
-
type:
|
|
1427
|
-
sessionKind:
|
|
1564
|
+
type: z13.literal("session.start"),
|
|
1565
|
+
sessionKind: z13.enum(["interactive", "non-interactive", "unknown"]),
|
|
1428
1566
|
agentName: nonEmptyStringSchema.optional(),
|
|
1429
1567
|
agentVersion: nonEmptyStringSchema.optional(),
|
|
1430
1568
|
model: modelDescriptorSchema.optional(),
|
|
@@ -1432,40 +1570,47 @@ var sessionStartEventSchema = event({
|
|
|
1432
1570
|
target: workspaceTargetSchema.optional()
|
|
1433
1571
|
});
|
|
1434
1572
|
var sessionEndEventSchema = event({
|
|
1435
|
-
type:
|
|
1436
|
-
reason:
|
|
1573
|
+
type: z13.literal("session.end"),
|
|
1574
|
+
reason: z13.enum(["completed", "aborted", "error", "timeout", "unknown"]),
|
|
1437
1575
|
durationMillis: durationMillisSchema.optional(),
|
|
1438
1576
|
/** Session totals, typically cumulative. */
|
|
1439
1577
|
usage: canonicalUsageSchema.optional(),
|
|
1440
1578
|
cost: costFactsSchema.optional()
|
|
1441
1579
|
});
|
|
1442
1580
|
var promptSubmittedEventSchema = event({
|
|
1443
|
-
type:
|
|
1444
|
-
promptSource:
|
|
1581
|
+
type: z13.literal("prompt.submitted"),
|
|
1582
|
+
promptSource: z13.enum(["user", "automation", "resumed", "unknown"]),
|
|
1445
1583
|
content: contentFactSchema.optional(),
|
|
1446
|
-
turnIndex:
|
|
1584
|
+
turnIndex: z13.number().int().min(0).optional(),
|
|
1447
1585
|
/** The git worktree the session runs in, resolved by the core (ADR 0008). */
|
|
1448
1586
|
target: workspaceTargetSchema.optional()
|
|
1449
1587
|
});
|
|
1450
1588
|
var generationStartEventSchema = event({
|
|
1451
|
-
type:
|
|
1589
|
+
type: z13.literal("generation.start"),
|
|
1452
1590
|
generationId: nonEmptyStringSchema,
|
|
1453
1591
|
model: modelDescriptorSchema,
|
|
1454
1592
|
requestedMaxOutputTokens: tokenCountSchema.optional(),
|
|
1455
1593
|
inputContent: contentFactsSchema.optional()
|
|
1456
1594
|
});
|
|
1457
1595
|
var generationEndEventSchema = event({
|
|
1458
|
-
type:
|
|
1596
|
+
type: z13.literal("generation.end"),
|
|
1459
1597
|
generationId: nonEmptyStringSchema,
|
|
1460
1598
|
model: modelDescriptorSchema,
|
|
1461
1599
|
outcome: outcomeSchema,
|
|
1462
1600
|
stopReason: nonEmptyStringSchema.optional(),
|
|
1463
1601
|
durationMillis: durationMillisSchema.optional(),
|
|
1464
1602
|
usage: canonicalUsageSchema.optional(),
|
|
1603
|
+
/**
|
|
1604
|
+
* True when `usage` is known to cover only part of the generation (for
|
|
1605
|
+
* example the last model request of a multi-request turn); false when the
|
|
1606
|
+
* provider or harness said it is the whole. Absent: not stated. Meaningless
|
|
1607
|
+
* without `usage`.
|
|
1608
|
+
*/
|
|
1609
|
+
usagePartial: z13.boolean().optional(),
|
|
1465
1610
|
cost: costFactsSchema.optional(),
|
|
1466
1611
|
outputContent: contentFactsSchema.optional()
|
|
1467
1612
|
});
|
|
1468
|
-
var toolKindSchema =
|
|
1613
|
+
var toolKindSchema = z13.enum([
|
|
1469
1614
|
"read",
|
|
1470
1615
|
"write",
|
|
1471
1616
|
"execute",
|
|
@@ -1476,7 +1621,7 @@ var toolKindSchema = z12.enum([
|
|
|
1476
1621
|
"unknown"
|
|
1477
1622
|
]);
|
|
1478
1623
|
var toolStartEventSchema = event({
|
|
1479
|
-
type:
|
|
1624
|
+
type: z13.literal("tool.start"),
|
|
1480
1625
|
toolCallId: nonEmptyStringSchema,
|
|
1481
1626
|
toolName: nonEmptyStringSchema,
|
|
1482
1627
|
toolKind: toolKindSchema,
|
|
@@ -1486,53 +1631,53 @@ var toolStartEventSchema = event({
|
|
|
1486
1631
|
target: workspaceTargetSchema.optional()
|
|
1487
1632
|
});
|
|
1488
1633
|
var toolEndEventSchema = event({
|
|
1489
|
-
type:
|
|
1634
|
+
type: z13.literal("tool.end"),
|
|
1490
1635
|
toolCallId: nonEmptyStringSchema,
|
|
1491
1636
|
toolName: nonEmptyStringSchema,
|
|
1492
1637
|
outcome: outcomeSchema,
|
|
1493
1638
|
durationMillis: durationMillisSchema.optional(),
|
|
1494
1639
|
/** Present when the host asked for or recorded a permission decision. */
|
|
1495
|
-
permissionDecision:
|
|
1640
|
+
permissionDecision: z13.enum(["allowed", "denied", "deferred", "not-required"]).optional(),
|
|
1496
1641
|
output: contentFactSchema.optional(),
|
|
1497
1642
|
/** The git worktree this call targeted, resolved by the core (ADR 0008). */
|
|
1498
1643
|
target: workspaceTargetSchema.optional()
|
|
1499
1644
|
});
|
|
1500
1645
|
var subagentStartEventSchema = event({
|
|
1501
|
-
type:
|
|
1646
|
+
type: z13.literal("subagent.start"),
|
|
1502
1647
|
subagentInvocationId: invocationIdSchema,
|
|
1503
1648
|
subagentType: nonEmptyStringSchema.optional(),
|
|
1504
1649
|
/** 0 for the top-level agent; 1 for its direct children. */
|
|
1505
|
-
delegationDepth:
|
|
1650
|
+
delegationDepth: z13.number().int().min(0).max(64),
|
|
1506
1651
|
model: modelDescriptorSchema.optional()
|
|
1507
1652
|
});
|
|
1508
1653
|
var subagentEndEventSchema = event({
|
|
1509
|
-
type:
|
|
1654
|
+
type: z13.literal("subagent.end"),
|
|
1510
1655
|
subagentInvocationId: invocationIdSchema,
|
|
1511
1656
|
outcome: outcomeSchema,
|
|
1512
1657
|
durationMillis: durationMillisSchema.optional(),
|
|
1513
1658
|
usage: canonicalUsageSchema.optional()
|
|
1514
1659
|
});
|
|
1515
1660
|
var compactionPerformedEventSchema = event({
|
|
1516
|
-
type:
|
|
1517
|
-
trigger:
|
|
1661
|
+
type: z13.literal("compaction.performed"),
|
|
1662
|
+
trigger: z13.enum(["automatic", "manual", "unknown"]),
|
|
1518
1663
|
/** Provider-reported context size before and after compaction, if known. */
|
|
1519
1664
|
contextTokensBefore: tokenCountSchema.optional(),
|
|
1520
1665
|
contextTokensAfter: tokenCountSchema.optional(),
|
|
1521
|
-
droppedMessageCount:
|
|
1666
|
+
droppedMessageCount: z13.number().int().min(0).optional(),
|
|
1522
1667
|
usage: canonicalUsageSchema.optional()
|
|
1523
1668
|
});
|
|
1524
1669
|
var errorRaisedEventSchema = event({
|
|
1525
|
-
type:
|
|
1670
|
+
type: z13.literal("error.raised"),
|
|
1526
1671
|
errorCode: otelHookErrorCodeSchema,
|
|
1527
1672
|
severity: errorSeveritySchema,
|
|
1528
1673
|
phase: errorPhaseSchema,
|
|
1529
|
-
retryable:
|
|
1674
|
+
retryable: z13.boolean(),
|
|
1530
1675
|
/** Error text is content: it is described, never embedded verbatim by default. */
|
|
1531
1676
|
message: contentFactSchema.optional(),
|
|
1532
1677
|
/** Non-sensitive, provider-agnostic short label. */
|
|
1533
1678
|
detail: nonEmptyStringSchema.optional()
|
|
1534
1679
|
});
|
|
1535
|
-
var canonicalEventSchema =
|
|
1680
|
+
var canonicalEventSchema = z13.discriminatedUnion("type", [
|
|
1536
1681
|
sessionStartEventSchema,
|
|
1537
1682
|
sessionEndEventSchema,
|
|
1538
1683
|
promptSubmittedEventSchema,
|
|
@@ -1550,26 +1695,26 @@ var TARGETED = new Set(TARGETED_EVENT_TYPES);
|
|
|
1550
1695
|
var isTargetedEvent = (event3) => TARGETED.has(event3.type);
|
|
1551
1696
|
|
|
1552
1697
|
// src/providers/adapter.ts
|
|
1553
|
-
var providerDetectionSchema =
|
|
1698
|
+
var providerDetectionSchema = z14.strictObject({
|
|
1554
1699
|
providerId: resolvedProviderIdSchema,
|
|
1555
1700
|
confidence: detectionConfidenceSchema,
|
|
1556
1701
|
/**
|
|
1557
1702
|
* Short, non-sensitive justifications, e.g. `"payload.hook_event_name present"`.
|
|
1558
1703
|
* Reasons are exported in diagnostics, so they must not quote payload values.
|
|
1559
1704
|
*/
|
|
1560
|
-
reasons:
|
|
1705
|
+
reasons: z14.array(z14.string().min(1).max(160)).max(8),
|
|
1561
1706
|
providerVersion: nonEmptyStringSchema.optional(),
|
|
1562
1707
|
/** The provider's own name for this event, when the payload states one. */
|
|
1563
1708
|
sourceEventName: nonEmptyStringSchema.optional()
|
|
1564
1709
|
});
|
|
1565
|
-
var deliveryIdentifierSupportSchema =
|
|
1710
|
+
var deliveryIdentifierSupportSchema = z14.enum(["none", "partial", "all"]);
|
|
1566
1711
|
var DELIVERY_COMPONENT_PATTERN = /^[A-Za-z0-9_.:@+=-]{1,256}$/;
|
|
1567
|
-
var deliveryComponentSchema =
|
|
1712
|
+
var deliveryComponentSchema = z14.string().regex(
|
|
1568
1713
|
DELIVERY_COMPONENT_PATTERN,
|
|
1569
1714
|
"delivery component must be identifier-shaped: no whitespace, no path separators"
|
|
1570
1715
|
);
|
|
1571
1716
|
var MAX_DELIVERY_COMPONENTS = 8;
|
|
1572
|
-
var providerDeliveryClaimSchema =
|
|
1717
|
+
var providerDeliveryClaimSchema = z14.strictObject({
|
|
1573
1718
|
/**
|
|
1574
1719
|
* The provider's own session/conversation id. Scopes the callback identity, so
|
|
1575
1720
|
* two sessions reusing one tool-call id never collide.
|
|
@@ -1581,26 +1726,26 @@ var providerDeliveryClaimSchema = z13.strictObject({
|
|
|
1581
1726
|
* Identifier-shaped payload fields that, together with `sourceEventName`,
|
|
1582
1727
|
* name this callback within the session exactly once.
|
|
1583
1728
|
*/
|
|
1584
|
-
components:
|
|
1729
|
+
components: z14.array(deliveryComponentSchema).min(1).max(MAX_DELIVERY_COMPONENTS).readonly(),
|
|
1585
1730
|
/**
|
|
1586
1731
|
* Short, non-sensitive justifications, e.g. `"payload.tool_use_id names one
|
|
1587
1732
|
* tool call"`. Evidence reaches diagnostics, so it must name fields, never
|
|
1588
1733
|
* quote their values.
|
|
1589
1734
|
*/
|
|
1590
|
-
evidence:
|
|
1735
|
+
evidence: z14.array(z14.string().min(1).max(160)).min(1).max(4).readonly()
|
|
1591
1736
|
});
|
|
1592
1737
|
var DELIVERY_GAP_REASON_PATTERN = /^[^\n\r\t\\/]{1,240}$/;
|
|
1593
|
-
var deliveryGapReasonSchema =
|
|
1738
|
+
var deliveryGapReasonSchema = z14.string().regex(
|
|
1594
1739
|
DELIVERY_GAP_REASON_PATTERN,
|
|
1595
1740
|
"delivery gap reason must be one line of prose: no path separators, no control characters"
|
|
1596
1741
|
);
|
|
1597
1742
|
var MAX_DELIVERY_GAPS = 48;
|
|
1598
|
-
var providerDeliveryGapsSchema =
|
|
1743
|
+
var providerDeliveryGapsSchema = z14.record(deliveryComponentSchema, deliveryGapReasonSchema).refine((gaps) => Object.keys(gaps).length <= MAX_DELIVERY_GAPS, {
|
|
1599
1744
|
message: `at most ${String(MAX_DELIVERY_GAPS)} delivery gaps may be declared`
|
|
1600
1745
|
});
|
|
1601
|
-
var providerCapabilitiesSchema =
|
|
1746
|
+
var providerCapabilitiesSchema = z14.strictObject({
|
|
1602
1747
|
/** Event types the adapter can produce. */
|
|
1603
|
-
lifecycleEvents:
|
|
1748
|
+
lifecycleEvents: z14.array(canonicalEventTypeSchema).max(32).readonly(),
|
|
1604
1749
|
usageTemporality: usageTemporalitySchema,
|
|
1605
1750
|
/**
|
|
1606
1751
|
* Which accumulator series a `cumulative` report continues — that is, which
|
|
@@ -1619,32 +1764,32 @@ var providerCapabilitiesSchema = z13.strictObject({
|
|
|
1619
1764
|
* Subagent snapshots keep their own series regardless: a delegated agent's
|
|
1620
1765
|
* counter is not a point on the parent session's curve.
|
|
1621
1766
|
*/
|
|
1622
|
-
cumulativeUsageSeries:
|
|
1623
|
-
reportsCachedInput:
|
|
1624
|
-
reportsCacheCreation:
|
|
1767
|
+
cumulativeUsageSeries: z14.enum(["event-scope", "session-lifetime"]).optional(),
|
|
1768
|
+
reportsCachedInput: z14.boolean(),
|
|
1769
|
+
reportsCacheCreation: z14.boolean(),
|
|
1625
1770
|
cacheCreationAccounting: cacheCreationAccountingSchema,
|
|
1626
|
-
reportsReasoningOutput:
|
|
1627
|
-
reportsProviderTotal:
|
|
1628
|
-
reportsCost:
|
|
1629
|
-
emitsSubagentEvents:
|
|
1630
|
-
emitsCompactionEvents:
|
|
1771
|
+
reportsReasoningOutput: z14.boolean(),
|
|
1772
|
+
reportsProviderTotal: z14.boolean(),
|
|
1773
|
+
reportsCost: z14.boolean(),
|
|
1774
|
+
emitsSubagentEvents: z14.boolean(),
|
|
1775
|
+
emitsCompactionEvents: z14.boolean(),
|
|
1631
1776
|
/** True when the provider reads a structured response from stdout. */
|
|
1632
|
-
requiresHookResponse:
|
|
1777
|
+
requiresHookResponse: z14.boolean(),
|
|
1633
1778
|
/** How much of this provider's hook traffic is replay-identifiable. */
|
|
1634
1779
|
deliveryIdentifier: deliveryIdentifierSupportSchema
|
|
1635
1780
|
});
|
|
1636
|
-
var providerHookResponseSchema =
|
|
1781
|
+
var providerHookResponseSchema = z14.strictObject({
|
|
1637
1782
|
/**
|
|
1638
1783
|
* Always 0. A telemetry hook that can fail the host agent is a liability, so
|
|
1639
1784
|
* the type forbids expressing anything else (ADR 0004).
|
|
1640
1785
|
*/
|
|
1641
|
-
exitCode:
|
|
1786
|
+
exitCode: z14.literal(0),
|
|
1642
1787
|
/** Protocol response text. Omit to write nothing at all. */
|
|
1643
|
-
stdout:
|
|
1788
|
+
stdout: z14.string().max(8192).optional(),
|
|
1644
1789
|
/** Non-sensitive diagnostic text for stderr. */
|
|
1645
|
-
stderr:
|
|
1790
|
+
stderr: z14.string().max(8192).optional(),
|
|
1646
1791
|
/** Declares which of the two stdout contracts this response follows. */
|
|
1647
|
-
contract:
|
|
1792
|
+
contract: z14.enum(["silent", "provider-protocol"])
|
|
1648
1793
|
});
|
|
1649
1794
|
var SILENT_HOOK_RESPONSE = Object.freeze({
|
|
1650
1795
|
exitCode: 0,
|
|
@@ -1689,14 +1834,14 @@ var unknownDetection = (reasons = ["no adapter recognized the input"]) => provid
|
|
|
1689
1834
|
});
|
|
1690
1835
|
|
|
1691
1836
|
// src/errors/index.ts
|
|
1692
|
-
import { z as
|
|
1693
|
-
var otelHookErrorInfoSchema =
|
|
1837
|
+
import { z as z15 } from "zod";
|
|
1838
|
+
var otelHookErrorInfoSchema = z15.strictObject({
|
|
1694
1839
|
code: otelHookErrorCodeSchema,
|
|
1695
1840
|
severity: errorSeveritySchema,
|
|
1696
1841
|
phase: errorPhaseSchema,
|
|
1697
1842
|
posture: failurePostureSchema,
|
|
1698
|
-
retryable:
|
|
1699
|
-
message:
|
|
1843
|
+
retryable: z15.boolean(),
|
|
1844
|
+
message: z15.string().min(1).max(512),
|
|
1700
1845
|
details: attributesSchema.optional(),
|
|
1701
1846
|
occurredAt: epochMillisSchema.optional()
|
|
1702
1847
|
});
|
|
@@ -1966,35 +2111,35 @@ var CLAUDE_CODE_CAPABILITIES = Object.freeze({
|
|
|
1966
2111
|
});
|
|
1967
2112
|
|
|
1968
2113
|
// src/providers/claude/schema.ts
|
|
1969
|
-
import { z as
|
|
2114
|
+
import { z as z16 } from "zod";
|
|
1970
2115
|
var commonFields = {
|
|
1971
|
-
session_id:
|
|
1972
|
-
transcript_path:
|
|
1973
|
-
cwd:
|
|
1974
|
-
permission_mode:
|
|
2116
|
+
session_id: z16.string().min(1),
|
|
2117
|
+
transcript_path: z16.string().min(1).optional(),
|
|
2118
|
+
cwd: z16.string().min(1).optional(),
|
|
2119
|
+
permission_mode: z16.string().min(1).optional(),
|
|
1975
2120
|
/** Correlates a hook firing with the user prompt that triggered it (Claude Code v2.1.196+). */
|
|
1976
|
-
prompt_id:
|
|
2121
|
+
prompt_id: z16.string().min(1).optional(),
|
|
1977
2122
|
/** Present when the hook fired while running inside a subagent. */
|
|
1978
|
-
agent_id:
|
|
1979
|
-
agent_type:
|
|
2123
|
+
agent_id: z16.string().min(1).optional(),
|
|
2124
|
+
agent_type: z16.string().min(1).optional()
|
|
1980
2125
|
};
|
|
1981
|
-
var claudeCacheCreationSchema =
|
|
1982
|
-
ephemeral_5m_input_tokens:
|
|
1983
|
-
ephemeral_1h_input_tokens:
|
|
1984
|
-
});
|
|
1985
|
-
var claudeUsageIterationSchema =
|
|
1986
|
-
input_tokens:
|
|
1987
|
-
output_tokens:
|
|
1988
|
-
cache_creation_input_tokens:
|
|
1989
|
-
cache_read_input_tokens:
|
|
1990
|
-
});
|
|
1991
|
-
var claudeUsageSchema =
|
|
1992
|
-
input_tokens:
|
|
1993
|
-
output_tokens:
|
|
1994
|
-
cache_creation_input_tokens:
|
|
1995
|
-
cache_read_input_tokens:
|
|
2126
|
+
var claudeCacheCreationSchema = z16.object({
|
|
2127
|
+
ephemeral_5m_input_tokens: z16.number().int().min(0).optional(),
|
|
2128
|
+
ephemeral_1h_input_tokens: z16.number().int().min(0).optional()
|
|
2129
|
+
});
|
|
2130
|
+
var claudeUsageIterationSchema = z16.object({
|
|
2131
|
+
input_tokens: z16.number().int().min(0).optional(),
|
|
2132
|
+
output_tokens: z16.number().int().min(0).optional(),
|
|
2133
|
+
cache_creation_input_tokens: z16.number().int().min(0).optional(),
|
|
2134
|
+
cache_read_input_tokens: z16.number().int().min(0).optional()
|
|
2135
|
+
});
|
|
2136
|
+
var claudeUsageSchema = z16.object({
|
|
2137
|
+
input_tokens: z16.number().int().min(0),
|
|
2138
|
+
output_tokens: z16.number().int().min(0),
|
|
2139
|
+
cache_creation_input_tokens: z16.number().int().min(0).optional(),
|
|
2140
|
+
cache_read_input_tokens: z16.number().int().min(0).optional(),
|
|
1996
2141
|
cache_creation: claudeCacheCreationSchema.optional(),
|
|
1997
|
-
iterations:
|
|
2142
|
+
iterations: z16.array(claudeUsageIterationSchema).optional(),
|
|
1998
2143
|
/**
|
|
1999
2144
|
* Counters the canonical model has a home for but Claude Code never reports:
|
|
2000
2145
|
* 0 of 4,999 real usage objects carried either (finding 5).
|
|
@@ -2003,112 +2148,112 @@ var claudeUsageSchema = z15.object({
|
|
|
2003
2148
|
* that a harness attaching one gets told it was excluded, instead of watching
|
|
2004
2149
|
* it vanish. See `CLAUDE_EXCLUDED_USAGE_COUNTERS`.
|
|
2005
2150
|
*/
|
|
2006
|
-
total_tokens:
|
|
2007
|
-
reasoning_output_tokens:
|
|
2151
|
+
total_tokens: z16.number().int().min(0).optional(),
|
|
2152
|
+
reasoning_output_tokens: z16.number().int().min(0).optional()
|
|
2008
2153
|
});
|
|
2009
|
-
var sessionStartPayloadSchema =
|
|
2154
|
+
var sessionStartPayloadSchema = z16.object({
|
|
2010
2155
|
...commonFields,
|
|
2011
|
-
hook_event_name:
|
|
2156
|
+
hook_event_name: z16.literal("SessionStart"),
|
|
2012
2157
|
/** Matcher values: startup | resume | clear | compact | fork. Forward-compatible: any string. */
|
|
2013
|
-
source:
|
|
2014
|
-
model:
|
|
2015
|
-
session_title:
|
|
2158
|
+
source: z16.string().min(1).optional(),
|
|
2159
|
+
model: z16.string().min(1).optional(),
|
|
2160
|
+
session_title: z16.string().min(1).optional()
|
|
2016
2161
|
});
|
|
2017
|
-
var sessionEndPayloadSchema =
|
|
2162
|
+
var sessionEndPayloadSchema = z16.object({
|
|
2018
2163
|
...commonFields,
|
|
2019
|
-
hook_event_name:
|
|
2164
|
+
hook_event_name: z16.literal("SessionEnd"),
|
|
2020
2165
|
/** Current Claude Code field; values include clear, logout, prompt_input_exit, and other. */
|
|
2021
|
-
reason:
|
|
2166
|
+
reason: z16.string().min(1).optional(),
|
|
2022
2167
|
/** Compatibility alias emitted by older wrappers and hook integrations. */
|
|
2023
|
-
end_reason:
|
|
2168
|
+
end_reason: z16.string().min(1).optional()
|
|
2024
2169
|
});
|
|
2025
|
-
var userPromptSubmitPayloadSchema =
|
|
2170
|
+
var userPromptSubmitPayloadSchema = z16.object({
|
|
2026
2171
|
...commonFields,
|
|
2027
|
-
hook_event_name:
|
|
2028
|
-
prompt:
|
|
2172
|
+
hook_event_name: z16.literal("UserPromptSubmit"),
|
|
2173
|
+
prompt: z16.string()
|
|
2029
2174
|
});
|
|
2030
|
-
var preToolUsePayloadSchema =
|
|
2175
|
+
var preToolUsePayloadSchema = z16.object({
|
|
2031
2176
|
...commonFields,
|
|
2032
|
-
hook_event_name:
|
|
2033
|
-
tool_name:
|
|
2034
|
-
tool_input:
|
|
2035
|
-
tool_use_id:
|
|
2177
|
+
hook_event_name: z16.literal("PreToolUse"),
|
|
2178
|
+
tool_name: z16.string().min(1),
|
|
2179
|
+
tool_input: z16.unknown(),
|
|
2180
|
+
tool_use_id: z16.string().min(1)
|
|
2036
2181
|
});
|
|
2037
|
-
var postToolUsePayloadSchema =
|
|
2182
|
+
var postToolUsePayloadSchema = z16.object({
|
|
2038
2183
|
...commonFields,
|
|
2039
|
-
hook_event_name:
|
|
2040
|
-
tool_name:
|
|
2041
|
-
tool_input:
|
|
2042
|
-
tool_response:
|
|
2043
|
-
tool_use_id:
|
|
2184
|
+
hook_event_name: z16.literal("PostToolUse"),
|
|
2185
|
+
tool_name: z16.string().min(1),
|
|
2186
|
+
tool_input: z16.unknown().optional(),
|
|
2187
|
+
tool_response: z16.unknown(),
|
|
2188
|
+
tool_use_id: z16.string().min(1)
|
|
2044
2189
|
});
|
|
2045
|
-
var postToolUseFailurePayloadSchema =
|
|
2190
|
+
var postToolUseFailurePayloadSchema = z16.object({
|
|
2046
2191
|
...commonFields,
|
|
2047
|
-
hook_event_name:
|
|
2048
|
-
tool_name:
|
|
2049
|
-
tool_input:
|
|
2050
|
-
tool_error:
|
|
2051
|
-
tool_use_id:
|
|
2192
|
+
hook_event_name: z16.literal("PostToolUseFailure"),
|
|
2193
|
+
tool_name: z16.string().min(1),
|
|
2194
|
+
tool_input: z16.unknown().optional(),
|
|
2195
|
+
tool_error: z16.unknown(),
|
|
2196
|
+
tool_use_id: z16.string().min(1)
|
|
2052
2197
|
});
|
|
2053
|
-
var permissionRequestPayloadSchema =
|
|
2198
|
+
var permissionRequestPayloadSchema = z16.object({
|
|
2054
2199
|
...commonFields,
|
|
2055
|
-
hook_event_name:
|
|
2056
|
-
tool_name:
|
|
2057
|
-
tool_input:
|
|
2058
|
-
tool_use_id:
|
|
2200
|
+
hook_event_name: z16.literal("PermissionRequest"),
|
|
2201
|
+
tool_name: z16.string().min(1),
|
|
2202
|
+
tool_input: z16.unknown().optional(),
|
|
2203
|
+
tool_use_id: z16.string().min(1)
|
|
2059
2204
|
});
|
|
2060
|
-
var subagentStartPayloadSchema =
|
|
2205
|
+
var subagentStartPayloadSchema = z16.object({
|
|
2061
2206
|
...commonFields,
|
|
2062
|
-
hook_event_name:
|
|
2063
|
-
agent_type:
|
|
2064
|
-
agent_id:
|
|
2207
|
+
hook_event_name: z16.literal("SubagentStart"),
|
|
2208
|
+
agent_type: z16.string().min(1),
|
|
2209
|
+
agent_id: z16.string().min(1)
|
|
2065
2210
|
});
|
|
2066
|
-
var subagentStopPayloadSchema =
|
|
2211
|
+
var subagentStopPayloadSchema = z16.object({
|
|
2067
2212
|
...commonFields,
|
|
2068
|
-
hook_event_name:
|
|
2069
|
-
agent_type:
|
|
2070
|
-
agent_id:
|
|
2071
|
-
last_assistant_message:
|
|
2213
|
+
hook_event_name: z16.literal("SubagentStop"),
|
|
2214
|
+
agent_type: z16.string().min(1),
|
|
2215
|
+
agent_id: z16.string().min(1),
|
|
2216
|
+
last_assistant_message: z16.string().optional(),
|
|
2072
2217
|
/** True when this stop fired because a hook continued the subagent's turn. */
|
|
2073
|
-
stop_hook_active:
|
|
2218
|
+
stop_hook_active: z16.boolean().optional(),
|
|
2074
2219
|
usage: claudeUsageSchema.optional()
|
|
2075
2220
|
});
|
|
2076
|
-
var preCompactPayloadSchema =
|
|
2221
|
+
var preCompactPayloadSchema = z16.object({
|
|
2077
2222
|
...commonFields,
|
|
2078
|
-
hook_event_name:
|
|
2223
|
+
hook_event_name: z16.literal("PreCompact"),
|
|
2079
2224
|
/** Upstream values: manual | auto. Forward-compatible: any string. */
|
|
2080
|
-
trigger:
|
|
2225
|
+
trigger: z16.string().min(1).optional(),
|
|
2081
2226
|
/** Compatibility alias emitted by older wrappers and hook integrations. */
|
|
2082
|
-
compact_trigger:
|
|
2227
|
+
compact_trigger: z16.string().min(1).optional(),
|
|
2083
2228
|
/**
|
|
2084
2229
|
* Harness-supplied, never upstream. Reported as an explicit exclusion rather
|
|
2085
2230
|
* than carried across the process boundary: see `events.ts`.
|
|
2086
2231
|
*/
|
|
2087
|
-
context_tokens_before:
|
|
2088
|
-
estimated_tokens_removed:
|
|
2232
|
+
context_tokens_before: z16.number().int().min(0).optional(),
|
|
2233
|
+
estimated_tokens_removed: z16.number().int().min(0).optional()
|
|
2089
2234
|
});
|
|
2090
|
-
var postCompactPayloadSchema =
|
|
2235
|
+
var postCompactPayloadSchema = z16.object({
|
|
2091
2236
|
...commonFields,
|
|
2092
|
-
hook_event_name:
|
|
2093
|
-
trigger:
|
|
2094
|
-
compact_trigger:
|
|
2237
|
+
hook_event_name: z16.literal("PostCompact"),
|
|
2238
|
+
trigger: z16.string().min(1).optional(),
|
|
2239
|
+
compact_trigger: z16.string().min(1).optional(),
|
|
2095
2240
|
/** Harness-supplied, never upstream; accepted here because one callback carries both. */
|
|
2096
|
-
context_tokens_before:
|
|
2097
|
-
context_tokens_after:
|
|
2098
|
-
dropped_message_count:
|
|
2241
|
+
context_tokens_before: z16.number().int().min(0).optional(),
|
|
2242
|
+
context_tokens_after: z16.number().int().min(0).optional(),
|
|
2243
|
+
dropped_message_count: z16.number().int().min(0).optional(),
|
|
2099
2244
|
usage: claudeUsageSchema.optional()
|
|
2100
2245
|
});
|
|
2101
|
-
var stopPayloadSchema =
|
|
2246
|
+
var stopPayloadSchema = z16.object({
|
|
2102
2247
|
...commonFields,
|
|
2103
|
-
hook_event_name:
|
|
2248
|
+
hook_event_name: z16.literal("Stop"),
|
|
2104
2249
|
/**
|
|
2105
2250
|
* Interactive Stop field (Claude Code ≥ 2.1.47). Print / `-p` / Agent SDK
|
|
2106
2251
|
* result messages use `result` instead; `events.ts` reads both (and camelCase
|
|
2107
2252
|
* `lastAssistantMessage`) through `extractClaudeAssistantText`.
|
|
2108
2253
|
*/
|
|
2109
|
-
last_assistant_message:
|
|
2254
|
+
last_assistant_message: z16.string().optional(),
|
|
2110
2255
|
/** Print / `-p` JSON result field; accepted so a harness can attach it as-is. */
|
|
2111
|
-
result:
|
|
2256
|
+
result: z16.string().optional(),
|
|
2112
2257
|
/**
|
|
2113
2258
|
* True when this stop fired because a hook continued the turn.
|
|
2114
2259
|
*
|
|
@@ -2116,22 +2261,44 @@ var stopPayloadSchema = z15.object({
|
|
|
2116
2261
|
* stop from a continuation stop, which is what lets `delivery.ts` deduplicate
|
|
2117
2262
|
* the former without suppressing the latter.
|
|
2118
2263
|
*/
|
|
2119
|
-
stop_hook_active:
|
|
2120
|
-
usage: claudeUsageSchema.optional()
|
|
2264
|
+
stop_hook_active: z16.boolean().optional(),
|
|
2265
|
+
usage: claudeUsageSchema.optional(),
|
|
2266
|
+
/**
|
|
2267
|
+
* The model that answered this turn — harness-supplied, never upstream.
|
|
2268
|
+
*
|
|
2269
|
+
* Claude Code's `Stop` carries no model id; the per-turn model sits only at
|
|
2270
|
+
* `message.model` in the transcript, beside `message.usage`. A wrapping harness
|
|
2271
|
+
* that read it (for instance with `readClaudeTranscriptTurn`) attaches it here
|
|
2272
|
+
* with `usage`, and it becomes the generation's response model. An unusable
|
|
2273
|
+
* value (empty, over 256 characters, not a string) is dropped rather than
|
|
2274
|
+
* failing the whole payload: the turn is still worth reporting without it.
|
|
2275
|
+
*/
|
|
2276
|
+
model: z16.string().min(1).max(256).optional().catch(void 0),
|
|
2277
|
+
/**
|
|
2278
|
+
* Harness-supplied, never upstream: whether `usage` covers only part of the
|
|
2279
|
+
* turn. `true` when it is the last model request alone (the tail fallback),
|
|
2280
|
+
* `false` when it sums every request since the previous stop. Exported as
|
|
2281
|
+
* `otelhook.usage.partial`; absent means the attacher did not say.
|
|
2282
|
+
*/
|
|
2283
|
+
usage_partial: z16.boolean().optional().catch(void 0)
|
|
2121
2284
|
});
|
|
2122
|
-
var stopFailurePayloadSchema =
|
|
2285
|
+
var stopFailurePayloadSchema = z16.object({
|
|
2123
2286
|
...commonFields,
|
|
2124
|
-
hook_event_name:
|
|
2287
|
+
hook_event_name: z16.literal("StopFailure"),
|
|
2125
2288
|
/**
|
|
2126
2289
|
* Matcher values: rate_limit | overloaded | authentication_failed |
|
|
2127
2290
|
* oauth_org_not_allowed | billing_error | invalid_request | model_not_found
|
|
2128
2291
|
* | server_error | max_output_tokens | unknown.
|
|
2129
2292
|
*/
|
|
2130
|
-
error_type:
|
|
2131
|
-
error_message:
|
|
2132
|
-
usage: claudeUsageSchema.optional()
|
|
2293
|
+
error_type: z16.string().min(1),
|
|
2294
|
+
error_message: z16.string().optional(),
|
|
2295
|
+
usage: claudeUsageSchema.optional(),
|
|
2296
|
+
/** Harness-supplied, never upstream: see `stopPayloadSchema.model`. */
|
|
2297
|
+
model: z16.string().min(1).max(256).optional().catch(void 0),
|
|
2298
|
+
/** Harness-supplied, never upstream: see `stopPayloadSchema.usage_partial`. */
|
|
2299
|
+
usage_partial: z16.boolean().optional().catch(void 0)
|
|
2133
2300
|
});
|
|
2134
|
-
var claudeHookPayloadSchema =
|
|
2301
|
+
var claudeHookPayloadSchema = z16.discriminatedUnion("hook_event_name", [
|
|
2135
2302
|
sessionStartPayloadSchema,
|
|
2136
2303
|
sessionEndPayloadSchema,
|
|
2137
2304
|
userPromptSubmitPayloadSchema,
|
|
@@ -2161,15 +2328,15 @@ var CLAUDE_HOOK_EVENT_NAMES = [
|
|
|
2161
2328
|
"Stop",
|
|
2162
2329
|
"StopFailure"
|
|
2163
2330
|
];
|
|
2164
|
-
var claudeIdentityFieldsSchema =
|
|
2165
|
-
session_id:
|
|
2166
|
-
hook_event_name:
|
|
2167
|
-
cwd:
|
|
2168
|
-
prompt_id:
|
|
2169
|
-
agent_id:
|
|
2170
|
-
tool_use_id:
|
|
2331
|
+
var claudeIdentityFieldsSchema = z16.object({
|
|
2332
|
+
session_id: z16.string().min(1),
|
|
2333
|
+
hook_event_name: z16.string().min(1),
|
|
2334
|
+
cwd: z16.string().min(1).optional(),
|
|
2335
|
+
prompt_id: z16.string().min(1).optional(),
|
|
2336
|
+
agent_id: z16.string().min(1).optional(),
|
|
2337
|
+
tool_use_id: z16.string().min(1).optional(),
|
|
2171
2338
|
/** Read by `delivery.ts` to tell a once-per-prompt stop from a continuation. */
|
|
2172
|
-
stop_hook_active:
|
|
2339
|
+
stop_hook_active: z16.boolean().optional()
|
|
2173
2340
|
});
|
|
2174
2341
|
|
|
2175
2342
|
// src/providers/claude/usage.ts
|
|
@@ -2708,6 +2875,13 @@ var inferToolKind = (toolName) => {
|
|
|
2708
2875
|
|
|
2709
2876
|
// src/providers/claude/events.ts
|
|
2710
2877
|
var UNKNOWN_MODEL = { modelId: "unknown" };
|
|
2878
|
+
var generationModels = (attached, sessionModel) => {
|
|
2879
|
+
const turnModel = attached === void 0 ? void 0 : { modelId: attached };
|
|
2880
|
+
return {
|
|
2881
|
+
request: sessionModel ?? turnModel ?? UNKNOWN_MODEL,
|
|
2882
|
+
response: turnModel ?? sessionModel ?? UNKNOWN_MODEL
|
|
2883
|
+
};
|
|
2884
|
+
};
|
|
2711
2885
|
var SESSION_END_REASON = Object.freeze({
|
|
2712
2886
|
completed: "completed",
|
|
2713
2887
|
aborted: "aborted",
|
|
@@ -2774,6 +2948,10 @@ var parseClaudeCode = (input, context) => {
|
|
|
2774
2948
|
warnings.push(...normalized.warnings);
|
|
2775
2949
|
return applyUsage(normalized);
|
|
2776
2950
|
};
|
|
2951
|
+
const withPartialUsage = (usage, partial) => {
|
|
2952
|
+
const applied = withUsage(usage);
|
|
2953
|
+
return applied.usage === void 0 || partial === void 0 ? applied : { ...applied, usagePartial: partial };
|
|
2954
|
+
};
|
|
2777
2955
|
switch (payload.hook_event_name) {
|
|
2778
2956
|
case "SessionStart":
|
|
2779
2957
|
factory.build({
|
|
@@ -2886,11 +3064,12 @@ var parseClaudeCode = (input, context) => {
|
|
|
2886
3064
|
payload.prompt_id ?? String(input.sequenceBase)
|
|
2887
3065
|
]);
|
|
2888
3066
|
const assistantText = extractClaudeAssistantText(normalizedPayload);
|
|
2889
|
-
|
|
3067
|
+
const models = generationModels(payload.model, input.sessionModel);
|
|
3068
|
+
factory.build({ type: "generation.start", generationId, model: models.request });
|
|
2890
3069
|
factory.build({
|
|
2891
3070
|
type: "generation.end",
|
|
2892
3071
|
generationId,
|
|
2893
|
-
model:
|
|
3072
|
+
model: models.response,
|
|
2894
3073
|
outcome: "ok",
|
|
2895
3074
|
// Always a response fact: a body when Claude sent text, otherwise a
|
|
2896
3075
|
// zero-length omitted fact so the log mapping can emit metadata_only
|
|
@@ -2902,7 +3081,7 @@ var parseClaudeCode = (input, context) => {
|
|
|
2902
3081
|
text: assistantText
|
|
2903
3082
|
})
|
|
2904
3083
|
],
|
|
2905
|
-
...
|
|
3084
|
+
...withPartialUsage(extractedUsage ?? payload.usage, payload.usage_partial)
|
|
2906
3085
|
});
|
|
2907
3086
|
break;
|
|
2908
3087
|
}
|
|
@@ -2913,11 +3092,12 @@ var parseClaudeCode = (input, context) => {
|
|
|
2913
3092
|
payload.prompt_id ?? String(input.sequenceBase)
|
|
2914
3093
|
]);
|
|
2915
3094
|
const assistantText = extractClaudeAssistantText(normalizedPayload);
|
|
2916
|
-
|
|
3095
|
+
const models = generationModels(payload.model, input.sessionModel);
|
|
3096
|
+
factory.build({ type: "generation.start", generationId, model: models.request });
|
|
2917
3097
|
factory.build({
|
|
2918
3098
|
type: "generation.end",
|
|
2919
3099
|
generationId,
|
|
2920
|
-
model:
|
|
3100
|
+
model: models.response,
|
|
2921
3101
|
outcome: mapStopFailureOutcome(payload.error_type),
|
|
2922
3102
|
stopReason: payload.error_type,
|
|
2923
3103
|
...assistantText === void 0 ? {} : {
|
|
@@ -2929,7 +3109,7 @@ var parseClaudeCode = (input, context) => {
|
|
|
2929
3109
|
})
|
|
2930
3110
|
]
|
|
2931
3111
|
},
|
|
2932
|
-
...
|
|
3112
|
+
...withPartialUsage(extractedUsage ?? payload.usage, payload.usage_partial)
|
|
2933
3113
|
});
|
|
2934
3114
|
break;
|
|
2935
3115
|
}
|
|
@@ -2956,8 +3136,13 @@ var createClaudeCodeAdapter = (options = {}) => ({
|
|
|
2956
3136
|
hookResponse: () => SILENT_HOOK_RESPONSE
|
|
2957
3137
|
});
|
|
2958
3138
|
|
|
3139
|
+
// src/providers/claude/transcript.ts
|
|
3140
|
+
import { createHash as createHash2 } from "crypto";
|
|
3141
|
+
import { open, stat } from "fs/promises";
|
|
3142
|
+
import path from "path";
|
|
3143
|
+
|
|
2959
3144
|
// src/providers/cursor/payload.ts
|
|
2960
|
-
import { z as
|
|
3145
|
+
import { z as z17 } from "zod";
|
|
2961
3146
|
var CURSOR_PROVIDER_ID = "cursor";
|
|
2962
3147
|
var CURSOR_HOOK_EVENT_NAMES = [
|
|
2963
3148
|
"sessionStart",
|
|
@@ -2992,23 +3177,23 @@ var CURSOR_DECISION_EVENTS = Object.freeze({
|
|
|
2992
3177
|
subagentStart: "permission",
|
|
2993
3178
|
beforeSubmitPrompt: "continue"
|
|
2994
3179
|
});
|
|
2995
|
-
var modelParamSchema =
|
|
2996
|
-
id:
|
|
2997
|
-
value:
|
|
3180
|
+
var modelParamSchema = z17.object({
|
|
3181
|
+
id: z17.string(),
|
|
3182
|
+
value: z17.string()
|
|
2998
3183
|
});
|
|
2999
|
-
var attachmentSchema =
|
|
3000
|
-
type:
|
|
3001
|
-
file_path:
|
|
3184
|
+
var attachmentSchema = z17.object({
|
|
3185
|
+
type: z17.string().optional(),
|
|
3186
|
+
file_path: z17.string().optional()
|
|
3002
3187
|
});
|
|
3003
|
-
var fileEditSchema =
|
|
3004
|
-
old_string:
|
|
3005
|
-
new_string:
|
|
3188
|
+
var fileEditSchema = z17.object({
|
|
3189
|
+
old_string: z17.string().optional(),
|
|
3190
|
+
new_string: z17.string().optional()
|
|
3006
3191
|
});
|
|
3007
3192
|
var usageFields = {
|
|
3008
|
-
input_tokens:
|
|
3009
|
-
output_tokens:
|
|
3010
|
-
cache_read_tokens:
|
|
3011
|
-
cache_write_tokens:
|
|
3193
|
+
input_tokens: z17.number().int().min(0).optional(),
|
|
3194
|
+
output_tokens: z17.number().int().min(0).optional(),
|
|
3195
|
+
cache_read_tokens: z17.number().int().min(0).optional(),
|
|
3196
|
+
cache_write_tokens: z17.number().int().min(0).optional()
|
|
3012
3197
|
};
|
|
3013
3198
|
var envelopeShape = {
|
|
3014
3199
|
// Not `.min(1)`: see `cursorSessionId`. A payload naming neither
|
|
@@ -3016,136 +3201,136 @@ var envelopeShape = {
|
|
|
3016
3201
|
// `recognizeCursorPayload`'s post-parse check — but rejecting it here would
|
|
3017
3202
|
// fail the whole discriminated union on a field the adapter can source from
|
|
3018
3203
|
// either name.
|
|
3019
|
-
conversation_id:
|
|
3020
|
-
generation_id:
|
|
3021
|
-
session_id:
|
|
3022
|
-
model:
|
|
3023
|
-
model_id:
|
|
3024
|
-
model_params:
|
|
3025
|
-
cursor_version:
|
|
3026
|
-
workspace_roots:
|
|
3027
|
-
cwd:
|
|
3204
|
+
conversation_id: z17.string().optional(),
|
|
3205
|
+
generation_id: z17.string().optional(),
|
|
3206
|
+
session_id: z17.string().optional(),
|
|
3207
|
+
model: z17.string().optional(),
|
|
3208
|
+
model_id: z17.string().optional(),
|
|
3209
|
+
model_params: z17.array(modelParamSchema).max(64).optional(),
|
|
3210
|
+
cursor_version: z17.string().optional(),
|
|
3211
|
+
workspace_roots: z17.array(z17.string()).max(64).optional(),
|
|
3212
|
+
cwd: z17.string().optional(),
|
|
3028
3213
|
/** Never propagated. */
|
|
3029
|
-
user_email:
|
|
3214
|
+
user_email: z17.string().nullish(),
|
|
3030
3215
|
/** Never propagated. */
|
|
3031
|
-
transcript_path:
|
|
3216
|
+
transcript_path: z17.string().nullish()
|
|
3032
3217
|
};
|
|
3033
|
-
var event2 = (name, shape) =>
|
|
3218
|
+
var event2 = (name, shape) => z17.object({ ...envelopeShape, hook_event_name: z17.literal(name), ...shape });
|
|
3034
3219
|
var sessionStartPayloadSchema2 = event2("sessionStart", {
|
|
3035
|
-
is_background_agent:
|
|
3036
|
-
composer_mode:
|
|
3220
|
+
is_background_agent: z17.boolean().optional(),
|
|
3221
|
+
composer_mode: z17.string().optional()
|
|
3037
3222
|
});
|
|
3038
3223
|
var sessionEndPayloadSchema2 = event2("sessionEnd", {
|
|
3039
|
-
reason:
|
|
3040
|
-
duration_ms:
|
|
3041
|
-
is_background_agent:
|
|
3042
|
-
final_status:
|
|
3043
|
-
error_message:
|
|
3224
|
+
reason: z17.string().optional(),
|
|
3225
|
+
duration_ms: z17.number().min(0).optional(),
|
|
3226
|
+
is_background_agent: z17.boolean().optional(),
|
|
3227
|
+
final_status: z17.string().optional(),
|
|
3228
|
+
error_message: z17.string().optional()
|
|
3044
3229
|
});
|
|
3045
3230
|
var beforeSubmitPromptPayloadSchema = event2("beforeSubmitPrompt", {
|
|
3046
|
-
prompt:
|
|
3047
|
-
attachments:
|
|
3048
|
-
composer_mode:
|
|
3231
|
+
prompt: z17.string().optional(),
|
|
3232
|
+
attachments: z17.array(attachmentSchema).max(256).optional(),
|
|
3233
|
+
composer_mode: z17.string().optional()
|
|
3049
3234
|
});
|
|
3050
3235
|
var afterAgentResponsePayloadSchema = event2("afterAgentResponse", {
|
|
3051
|
-
text:
|
|
3236
|
+
text: z17.string().optional(),
|
|
3052
3237
|
...usageFields
|
|
3053
3238
|
});
|
|
3054
3239
|
var afterAgentThoughtPayloadSchema = event2("afterAgentThought", {
|
|
3055
|
-
text:
|
|
3056
|
-
duration_ms:
|
|
3240
|
+
text: z17.string().optional(),
|
|
3241
|
+
duration_ms: z17.number().min(0).optional()
|
|
3057
3242
|
});
|
|
3058
3243
|
var preToolUsePayloadSchema2 = event2("preToolUse", {
|
|
3059
|
-
tool_name:
|
|
3060
|
-
tool_input:
|
|
3061
|
-
tool_use_id:
|
|
3062
|
-
agent_message:
|
|
3244
|
+
tool_name: z17.string().min(1),
|
|
3245
|
+
tool_input: z17.unknown().optional(),
|
|
3246
|
+
tool_use_id: z17.string().optional(),
|
|
3247
|
+
agent_message: z17.string().optional()
|
|
3063
3248
|
});
|
|
3064
3249
|
var postToolUsePayloadSchema2 = event2("postToolUse", {
|
|
3065
|
-
tool_name:
|
|
3066
|
-
tool_input:
|
|
3067
|
-
tool_output:
|
|
3068
|
-
tool_use_id:
|
|
3069
|
-
duration:
|
|
3250
|
+
tool_name: z17.string().min(1),
|
|
3251
|
+
tool_input: z17.unknown().optional(),
|
|
3252
|
+
tool_output: z17.unknown().optional(),
|
|
3253
|
+
tool_use_id: z17.string().optional(),
|
|
3254
|
+
duration: z17.number().min(0).optional()
|
|
3070
3255
|
});
|
|
3071
3256
|
var postToolUseFailurePayloadSchema2 = event2("postToolUseFailure", {
|
|
3072
|
-
tool_name:
|
|
3073
|
-
tool_input:
|
|
3074
|
-
tool_use_id:
|
|
3075
|
-
error_message:
|
|
3076
|
-
failure_type:
|
|
3077
|
-
duration:
|
|
3078
|
-
is_interrupt:
|
|
3257
|
+
tool_name: z17.string().min(1),
|
|
3258
|
+
tool_input: z17.unknown().optional(),
|
|
3259
|
+
tool_use_id: z17.string().optional(),
|
|
3260
|
+
error_message: z17.string().optional(),
|
|
3261
|
+
failure_type: z17.string().optional(),
|
|
3262
|
+
duration: z17.number().min(0).optional(),
|
|
3263
|
+
is_interrupt: z17.boolean().optional()
|
|
3079
3264
|
});
|
|
3080
3265
|
var beforeShellExecutionPayloadSchema = event2("beforeShellExecution", {
|
|
3081
|
-
command:
|
|
3082
|
-
sandbox:
|
|
3266
|
+
command: z17.string(),
|
|
3267
|
+
sandbox: z17.boolean().optional()
|
|
3083
3268
|
});
|
|
3084
3269
|
var afterShellExecutionPayloadSchema = event2("afterShellExecution", {
|
|
3085
|
-
command:
|
|
3086
|
-
output:
|
|
3087
|
-
duration:
|
|
3088
|
-
sandbox:
|
|
3270
|
+
command: z17.string(),
|
|
3271
|
+
output: z17.string().optional(),
|
|
3272
|
+
duration: z17.number().min(0).optional(),
|
|
3273
|
+
sandbox: z17.boolean().optional()
|
|
3089
3274
|
});
|
|
3090
3275
|
var beforeMcpExecutionPayloadSchema = event2("beforeMCPExecution", {
|
|
3091
|
-
tool_name:
|
|
3092
|
-
tool_input:
|
|
3093
|
-
url:
|
|
3094
|
-
command:
|
|
3276
|
+
tool_name: z17.string().min(1),
|
|
3277
|
+
tool_input: z17.unknown().optional(),
|
|
3278
|
+
url: z17.string().optional(),
|
|
3279
|
+
command: z17.string().optional()
|
|
3095
3280
|
});
|
|
3096
3281
|
var afterMcpExecutionPayloadSchema = event2("afterMCPExecution", {
|
|
3097
|
-
tool_name:
|
|
3098
|
-
tool_input:
|
|
3099
|
-
result_json:
|
|
3100
|
-
duration:
|
|
3282
|
+
tool_name: z17.string().min(1),
|
|
3283
|
+
tool_input: z17.unknown().optional(),
|
|
3284
|
+
result_json: z17.string().optional(),
|
|
3285
|
+
duration: z17.number().min(0).optional()
|
|
3101
3286
|
});
|
|
3102
3287
|
var beforeReadFilePayloadSchema = event2("beforeReadFile", {
|
|
3103
|
-
file_path:
|
|
3104
|
-
content:
|
|
3105
|
-
attachments:
|
|
3288
|
+
file_path: z17.string(),
|
|
3289
|
+
content: z17.string().optional(),
|
|
3290
|
+
attachments: z17.array(attachmentSchema).max(256).optional()
|
|
3106
3291
|
});
|
|
3107
3292
|
var afterFileEditPayloadSchema = event2("afterFileEdit", {
|
|
3108
|
-
file_path:
|
|
3109
|
-
edits:
|
|
3293
|
+
file_path: z17.string(),
|
|
3294
|
+
edits: z17.array(fileEditSchema).max(1024).optional()
|
|
3110
3295
|
});
|
|
3111
3296
|
var subagentStartPayloadSchema2 = event2("subagentStart", {
|
|
3112
|
-
subagent_id:
|
|
3113
|
-
subagent_type:
|
|
3114
|
-
task:
|
|
3115
|
-
parent_conversation_id:
|
|
3116
|
-
tool_call_id:
|
|
3117
|
-
subagent_model:
|
|
3118
|
-
is_parallel_worker:
|
|
3119
|
-
git_branch:
|
|
3297
|
+
subagent_id: z17.string().optional(),
|
|
3298
|
+
subagent_type: z17.string().optional(),
|
|
3299
|
+
task: z17.string().optional(),
|
|
3300
|
+
parent_conversation_id: z17.string().optional(),
|
|
3301
|
+
tool_call_id: z17.string().optional(),
|
|
3302
|
+
subagent_model: z17.string().optional(),
|
|
3303
|
+
is_parallel_worker: z17.boolean().optional(),
|
|
3304
|
+
git_branch: z17.string().optional()
|
|
3120
3305
|
});
|
|
3121
3306
|
var subagentStopPayloadSchema2 = event2("subagentStop", {
|
|
3122
|
-
subagent_type:
|
|
3123
|
-
status:
|
|
3124
|
-
task:
|
|
3125
|
-
description:
|
|
3126
|
-
summary:
|
|
3127
|
-
duration_ms:
|
|
3128
|
-
message_count:
|
|
3129
|
-
tool_call_count:
|
|
3130
|
-
loop_count:
|
|
3131
|
-
modified_files:
|
|
3132
|
-
agent_transcript_path:
|
|
3307
|
+
subagent_type: z17.string().optional(),
|
|
3308
|
+
status: z17.string().optional(),
|
|
3309
|
+
task: z17.string().optional(),
|
|
3310
|
+
description: z17.string().optional(),
|
|
3311
|
+
summary: z17.string().optional(),
|
|
3312
|
+
duration_ms: z17.number().min(0).optional(),
|
|
3313
|
+
message_count: z17.number().int().min(0).optional(),
|
|
3314
|
+
tool_call_count: z17.number().int().min(0).optional(),
|
|
3315
|
+
loop_count: z17.number().int().min(0).optional(),
|
|
3316
|
+
modified_files: z17.array(z17.string()).max(1024).optional(),
|
|
3317
|
+
agent_transcript_path: z17.string().nullish()
|
|
3133
3318
|
});
|
|
3134
3319
|
var preCompactPayloadSchema2 = event2("preCompact", {
|
|
3135
|
-
trigger:
|
|
3136
|
-
context_usage_percent:
|
|
3137
|
-
context_tokens:
|
|
3138
|
-
context_window_size:
|
|
3139
|
-
message_count:
|
|
3140
|
-
messages_to_compact:
|
|
3141
|
-
is_first_compaction:
|
|
3320
|
+
trigger: z17.string().optional(),
|
|
3321
|
+
context_usage_percent: z17.number().optional(),
|
|
3322
|
+
context_tokens: z17.number().int().min(0).optional(),
|
|
3323
|
+
context_window_size: z17.number().int().min(0).optional(),
|
|
3324
|
+
message_count: z17.number().int().min(0).optional(),
|
|
3325
|
+
messages_to_compact: z17.number().int().min(0).optional(),
|
|
3326
|
+
is_first_compaction: z17.boolean().optional()
|
|
3142
3327
|
});
|
|
3143
3328
|
var stopPayloadSchema2 = event2("stop", {
|
|
3144
|
-
status:
|
|
3145
|
-
loop_count:
|
|
3329
|
+
status: z17.string().optional(),
|
|
3330
|
+
loop_count: z17.number().int().min(0).optional(),
|
|
3146
3331
|
...usageFields
|
|
3147
3332
|
});
|
|
3148
|
-
var cursorPayloadSchema =
|
|
3333
|
+
var cursorPayloadSchema = z17.discriminatedUnion("hook_event_name", [
|
|
3149
3334
|
sessionStartPayloadSchema2,
|
|
3150
3335
|
sessionEndPayloadSchema2,
|
|
3151
3336
|
beforeSubmitPromptPayloadSchema,
|
|
@@ -3921,105 +4106,105 @@ var createCursorAdapter = (options = {}) => {
|
|
|
3921
4106
|
};
|
|
3922
4107
|
|
|
3923
4108
|
// src/providers/codex/payload.ts
|
|
3924
|
-
import { z as
|
|
3925
|
-
var permissionModeSchema =
|
|
4109
|
+
import { z as z18 } from "zod";
|
|
4110
|
+
var permissionModeSchema = z18.enum([
|
|
3926
4111
|
"default",
|
|
3927
4112
|
"acceptEdits",
|
|
3928
4113
|
"plan",
|
|
3929
4114
|
"dontAsk",
|
|
3930
4115
|
"bypassPermissions"
|
|
3931
4116
|
]);
|
|
3932
|
-
var codexUsageSchema =
|
|
3933
|
-
input_tokens:
|
|
3934
|
-
cached_input_tokens:
|
|
3935
|
-
output_tokens:
|
|
3936
|
-
reasoning_output_tokens:
|
|
3937
|
-
total_tokens:
|
|
4117
|
+
var codexUsageSchema = z18.object({
|
|
4118
|
+
input_tokens: z18.number().int().min(0).optional(),
|
|
4119
|
+
cached_input_tokens: z18.number().int().min(0).optional(),
|
|
4120
|
+
output_tokens: z18.number().int().min(0).optional(),
|
|
4121
|
+
reasoning_output_tokens: z18.number().int().min(0).optional(),
|
|
4122
|
+
total_tokens: z18.number().int().min(0).optional()
|
|
3938
4123
|
});
|
|
3939
4124
|
var baseFields = {
|
|
3940
|
-
session_id:
|
|
3941
|
-
cwd:
|
|
3942
|
-
model:
|
|
4125
|
+
session_id: z18.string().min(1).max(256),
|
|
4126
|
+
cwd: z18.string().min(1).max(4096).optional(),
|
|
4127
|
+
model: z18.string().min(1).max(256).optional(),
|
|
3943
4128
|
permission_mode: permissionModeSchema.optional(),
|
|
3944
|
-
transcript_path:
|
|
3945
|
-
codex_version:
|
|
4129
|
+
transcript_path: z18.string().min(1).max(4096).optional(),
|
|
4130
|
+
codex_version: z18.string().min(1).max(64).optional(),
|
|
3946
4131
|
/** Not part of the documented protocol; lets tests and replay stay deterministic. */
|
|
3947
|
-
occurred_at:
|
|
4132
|
+
occurred_at: z18.number().int().min(0).optional()
|
|
3948
4133
|
};
|
|
3949
|
-
var codexSessionStartPayloadSchema =
|
|
4134
|
+
var codexSessionStartPayloadSchema = z18.object({
|
|
3950
4135
|
...baseFields,
|
|
3951
|
-
hook_event_name:
|
|
3952
|
-
source:
|
|
4136
|
+
hook_event_name: z18.literal("SessionStart"),
|
|
4137
|
+
source: z18.enum(["startup", "resume", "clear", "compact"]).optional()
|
|
3953
4138
|
});
|
|
3954
|
-
var codexUserPromptSubmitPayloadSchema =
|
|
4139
|
+
var codexUserPromptSubmitPayloadSchema = z18.object({
|
|
3955
4140
|
...baseFields,
|
|
3956
|
-
hook_event_name:
|
|
3957
|
-
turn_id:
|
|
3958
|
-
prompt:
|
|
4141
|
+
hook_event_name: z18.literal("UserPromptSubmit"),
|
|
4142
|
+
turn_id: z18.string().min(1).max(256).optional(),
|
|
4143
|
+
prompt: z18.string().max(1e6).optional()
|
|
3959
4144
|
});
|
|
3960
|
-
var codexPreToolUsePayloadSchema =
|
|
4145
|
+
var codexPreToolUsePayloadSchema = z18.object({
|
|
3961
4146
|
...baseFields,
|
|
3962
|
-
hook_event_name:
|
|
3963
|
-
turn_id:
|
|
3964
|
-
tool_name:
|
|
3965
|
-
tool_call_id:
|
|
3966
|
-
tool_input:
|
|
4147
|
+
hook_event_name: z18.literal("PreToolUse"),
|
|
4148
|
+
turn_id: z18.string().min(1).max(256).optional(),
|
|
4149
|
+
tool_name: z18.string().min(1).max(256),
|
|
4150
|
+
tool_call_id: z18.string().min(1).max(256).optional(),
|
|
4151
|
+
tool_input: z18.unknown().optional()
|
|
3967
4152
|
});
|
|
3968
|
-
var codexPermissionRequestPayloadSchema =
|
|
4153
|
+
var codexPermissionRequestPayloadSchema = z18.object({
|
|
3969
4154
|
...baseFields,
|
|
3970
|
-
hook_event_name:
|
|
3971
|
-
turn_id:
|
|
3972
|
-
tool_name:
|
|
3973
|
-
tool_call_id:
|
|
3974
|
-
tool_input:
|
|
4155
|
+
hook_event_name: z18.literal("PermissionRequest"),
|
|
4156
|
+
turn_id: z18.string().min(1).max(256).optional(),
|
|
4157
|
+
tool_name: z18.string().min(1).max(256).optional(),
|
|
4158
|
+
tool_call_id: z18.string().min(1).max(256).optional(),
|
|
4159
|
+
tool_input: z18.unknown().optional()
|
|
3975
4160
|
});
|
|
3976
|
-
var codexPostToolUsePayloadSchema =
|
|
4161
|
+
var codexPostToolUsePayloadSchema = z18.object({
|
|
3977
4162
|
...baseFields,
|
|
3978
|
-
hook_event_name:
|
|
3979
|
-
turn_id:
|
|
3980
|
-
tool_name:
|
|
3981
|
-
tool_call_id:
|
|
3982
|
-
tool_input:
|
|
3983
|
-
tool_response:
|
|
3984
|
-
permission_decision:
|
|
3985
|
-
duration_ms:
|
|
4163
|
+
hook_event_name: z18.literal("PostToolUse"),
|
|
4164
|
+
turn_id: z18.string().min(1).max(256).optional(),
|
|
4165
|
+
tool_name: z18.string().min(1).max(256),
|
|
4166
|
+
tool_call_id: z18.string().min(1).max(256).optional(),
|
|
4167
|
+
tool_input: z18.unknown().optional(),
|
|
4168
|
+
tool_response: z18.unknown().optional(),
|
|
4169
|
+
permission_decision: z18.enum(["allowed", "denied", "deferred"]).optional(),
|
|
4170
|
+
duration_ms: z18.number().min(0).optional()
|
|
3986
4171
|
});
|
|
3987
|
-
var codexPreCompactPayloadSchema =
|
|
4172
|
+
var codexPreCompactPayloadSchema = z18.object({
|
|
3988
4173
|
...baseFields,
|
|
3989
|
-
hook_event_name:
|
|
3990
|
-
trigger:
|
|
3991
|
-
context_tokens_before:
|
|
4174
|
+
hook_event_name: z18.literal("PreCompact"),
|
|
4175
|
+
trigger: z18.enum(["auto", "manual"]).optional(),
|
|
4176
|
+
context_tokens_before: z18.number().int().min(0).optional()
|
|
3992
4177
|
});
|
|
3993
|
-
var codexPostCompactPayloadSchema =
|
|
4178
|
+
var codexPostCompactPayloadSchema = z18.object({
|
|
3994
4179
|
...baseFields,
|
|
3995
|
-
hook_event_name:
|
|
3996
|
-
trigger:
|
|
3997
|
-
context_tokens_after:
|
|
3998
|
-
dropped_message_count:
|
|
4180
|
+
hook_event_name: z18.literal("PostCompact"),
|
|
4181
|
+
trigger: z18.enum(["auto", "manual"]).optional(),
|
|
4182
|
+
context_tokens_after: z18.number().int().min(0).optional(),
|
|
4183
|
+
dropped_message_count: z18.number().int().min(0).optional(),
|
|
3999
4184
|
usage: codexUsageSchema.optional()
|
|
4000
4185
|
});
|
|
4001
|
-
var codexSubagentStartPayloadSchema =
|
|
4186
|
+
var codexSubagentStartPayloadSchema = z18.object({
|
|
4002
4187
|
...baseFields,
|
|
4003
|
-
hook_event_name:
|
|
4004
|
-
turn_id:
|
|
4005
|
-
subagent_id:
|
|
4006
|
-
subagent_type:
|
|
4188
|
+
hook_event_name: z18.literal("SubagentStart"),
|
|
4189
|
+
turn_id: z18.string().min(1).max(256).optional(),
|
|
4190
|
+
subagent_id: z18.string().min(1).max(256),
|
|
4191
|
+
subagent_type: z18.string().min(1).max(256).optional()
|
|
4007
4192
|
});
|
|
4008
|
-
var codexSubagentStopPayloadSchema =
|
|
4193
|
+
var codexSubagentStopPayloadSchema = z18.object({
|
|
4009
4194
|
...baseFields,
|
|
4010
|
-
hook_event_name:
|
|
4011
|
-
turn_id:
|
|
4012
|
-
subagent_id:
|
|
4013
|
-
status:
|
|
4195
|
+
hook_event_name: z18.literal("SubagentStop"),
|
|
4196
|
+
turn_id: z18.string().min(1).max(256).optional(),
|
|
4197
|
+
subagent_id: z18.string().min(1).max(256),
|
|
4198
|
+
status: z18.enum(["completed", "failed", "cancelled"]).optional(),
|
|
4014
4199
|
usage: codexUsageSchema.optional()
|
|
4015
4200
|
});
|
|
4016
|
-
var codexStopPayloadSchema =
|
|
4201
|
+
var codexStopPayloadSchema = z18.object({
|
|
4017
4202
|
...baseFields,
|
|
4018
|
-
hook_event_name:
|
|
4019
|
-
turn_id:
|
|
4020
|
-
stop_reason:
|
|
4203
|
+
hook_event_name: z18.literal("Stop"),
|
|
4204
|
+
turn_id: z18.string().min(1).max(256).optional(),
|
|
4205
|
+
stop_reason: z18.string().min(1).max(256).optional(),
|
|
4021
4206
|
usage: codexUsageSchema.optional(),
|
|
4022
|
-
duration_ms:
|
|
4207
|
+
duration_ms: z18.number().min(0).optional()
|
|
4023
4208
|
});
|
|
4024
4209
|
var CODEX_HOOK_EVENT_NAMES = [
|
|
4025
4210
|
"SessionStart",
|
|
@@ -4033,7 +4218,7 @@ var CODEX_HOOK_EVENT_NAMES = [
|
|
|
4033
4218
|
"SubagentStop",
|
|
4034
4219
|
"Stop"
|
|
4035
4220
|
];
|
|
4036
|
-
var codexHookPayloadSchema =
|
|
4221
|
+
var codexHookPayloadSchema = z18.discriminatedUnion("hook_event_name", [
|
|
4037
4222
|
codexSessionStartPayloadSchema,
|
|
4038
4223
|
codexUserPromptSubmitPayloadSchema,
|
|
4039
4224
|
codexPreToolUsePayloadSchema,
|
|
@@ -4045,9 +4230,9 @@ var codexHookPayloadSchema = z17.discriminatedUnion("hook_event_name", [
|
|
|
4045
4230
|
codexSubagentStopPayloadSchema,
|
|
4046
4231
|
codexStopPayloadSchema
|
|
4047
4232
|
]);
|
|
4048
|
-
var codexHookEnvelopeSchema =
|
|
4049
|
-
session_id:
|
|
4050
|
-
hook_event_name:
|
|
4233
|
+
var codexHookEnvelopeSchema = z18.object({
|
|
4234
|
+
session_id: z18.string().min(1),
|
|
4235
|
+
hook_event_name: z18.enum(CODEX_HOOK_EVENT_NAMES)
|
|
4051
4236
|
});
|
|
4052
4237
|
|
|
4053
4238
|
// src/providers/codex/delivery.ts
|
|
@@ -4666,7 +4851,7 @@ var geminiCorrelationSeed = (input) => {
|
|
|
4666
4851
|
};
|
|
4667
4852
|
|
|
4668
4853
|
// src/providers/gemini/schema.ts
|
|
4669
|
-
import { z as
|
|
4854
|
+
import { z as z19 } from "zod";
|
|
4670
4855
|
var GEMINI_HOOK_EVENT_NAMES = [
|
|
4671
4856
|
"SessionStart",
|
|
4672
4857
|
"SessionEnd",
|
|
@@ -4680,113 +4865,113 @@ var GEMINI_HOOK_EVENT_NAMES = [
|
|
|
4680
4865
|
"PreCompress",
|
|
4681
4866
|
"Notification"
|
|
4682
4867
|
];
|
|
4683
|
-
var baseHookInputSchema =
|
|
4684
|
-
session_id:
|
|
4685
|
-
transcript_path:
|
|
4686
|
-
cwd:
|
|
4687
|
-
timestamp:
|
|
4688
|
-
});
|
|
4689
|
-
var llmMessageSchema =
|
|
4690
|
-
role:
|
|
4691
|
-
content:
|
|
4868
|
+
var baseHookInputSchema = z19.object({
|
|
4869
|
+
session_id: z19.string().min(1),
|
|
4870
|
+
transcript_path: z19.string().optional(),
|
|
4871
|
+
cwd: z19.string().optional(),
|
|
4872
|
+
timestamp: z19.string().min(1).optional()
|
|
4873
|
+
});
|
|
4874
|
+
var llmMessageSchema = z19.object({
|
|
4875
|
+
role: z19.enum(["user", "model", "system"]).optional(),
|
|
4876
|
+
content: z19.union([z19.string(), z19.array(z19.unknown())]).optional()
|
|
4692
4877
|
}).loose();
|
|
4693
|
-
var llmRequestConfigSchema =
|
|
4694
|
-
temperature:
|
|
4695
|
-
maxOutputTokens:
|
|
4878
|
+
var llmRequestConfigSchema = z19.object({
|
|
4879
|
+
temperature: z19.number().optional(),
|
|
4880
|
+
maxOutputTokens: z19.number().int().min(0).optional()
|
|
4696
4881
|
}).loose();
|
|
4697
|
-
var geminiLlmRequestSchema =
|
|
4698
|
-
model:
|
|
4699
|
-
messages:
|
|
4882
|
+
var geminiLlmRequestSchema = z19.object({
|
|
4883
|
+
model: z19.string().min(1).optional(),
|
|
4884
|
+
messages: z19.array(llmMessageSchema).optional(),
|
|
4700
4885
|
config: llmRequestConfigSchema.optional(),
|
|
4701
|
-
toolConfig:
|
|
4886
|
+
toolConfig: z19.unknown().optional()
|
|
4702
4887
|
}).loose();
|
|
4703
|
-
var geminiUsageMetadataSchema =
|
|
4704
|
-
promptTokenCount:
|
|
4705
|
-
cachedContentTokenCount:
|
|
4706
|
-
candidatesTokenCount:
|
|
4707
|
-
thoughtsTokenCount:
|
|
4708
|
-
totalTokenCount:
|
|
4888
|
+
var geminiUsageMetadataSchema = z19.object({
|
|
4889
|
+
promptTokenCount: z19.number().int().min(0).optional(),
|
|
4890
|
+
cachedContentTokenCount: z19.number().int().min(0).optional(),
|
|
4891
|
+
candidatesTokenCount: z19.number().int().min(0).optional(),
|
|
4892
|
+
thoughtsTokenCount: z19.number().int().min(0).optional(),
|
|
4893
|
+
totalTokenCount: z19.number().int().min(0).optional()
|
|
4709
4894
|
}).loose();
|
|
4710
|
-
var geminiCandidateSchema =
|
|
4711
|
-
content:
|
|
4712
|
-
role:
|
|
4713
|
-
parts:
|
|
4895
|
+
var geminiCandidateSchema = z19.object({
|
|
4896
|
+
content: z19.object({
|
|
4897
|
+
role: z19.string().optional(),
|
|
4898
|
+
parts: z19.array(z19.unknown()).optional()
|
|
4714
4899
|
}).loose().optional(),
|
|
4715
|
-
finishReason:
|
|
4716
|
-
index:
|
|
4900
|
+
finishReason: z19.string().optional(),
|
|
4901
|
+
index: z19.number().int().min(0).optional()
|
|
4717
4902
|
}).loose();
|
|
4718
|
-
var geminiLlmResponseSchema =
|
|
4903
|
+
var geminiLlmResponseSchema = z19.object({
|
|
4719
4904
|
/** Whole-response text, set by the translator from `getResponseText`. */
|
|
4720
|
-
text:
|
|
4721
|
-
candidates:
|
|
4905
|
+
text: z19.string().optional(),
|
|
4906
|
+
candidates: z19.array(geminiCandidateSchema).optional(),
|
|
4722
4907
|
usageMetadata: geminiUsageMetadataSchema.optional()
|
|
4723
4908
|
}).loose();
|
|
4724
|
-
var geminiMcpContextSchema =
|
|
4725
|
-
server_name:
|
|
4726
|
-
tool_name:
|
|
4909
|
+
var geminiMcpContextSchema = z19.object({
|
|
4910
|
+
server_name: z19.string().optional(),
|
|
4911
|
+
tool_name: z19.string().optional()
|
|
4727
4912
|
}).loose();
|
|
4728
|
-
var geminiToolResponseSchema =
|
|
4729
|
-
llmContent:
|
|
4730
|
-
returnDisplay:
|
|
4731
|
-
error:
|
|
4913
|
+
var geminiToolResponseSchema = z19.object({
|
|
4914
|
+
llmContent: z19.unknown().optional(),
|
|
4915
|
+
returnDisplay: z19.unknown().optional(),
|
|
4916
|
+
error: z19.unknown().optional()
|
|
4732
4917
|
}).loose();
|
|
4733
4918
|
var sessionStartInputSchema = baseHookInputSchema.extend({
|
|
4734
|
-
hook_event_name:
|
|
4735
|
-
source:
|
|
4919
|
+
hook_event_name: z19.literal("SessionStart"),
|
|
4920
|
+
source: z19.enum(["startup", "resume", "clear"]).optional()
|
|
4736
4921
|
});
|
|
4737
4922
|
var sessionEndInputSchema = baseHookInputSchema.extend({
|
|
4738
|
-
hook_event_name:
|
|
4739
|
-
reason:
|
|
4923
|
+
hook_event_name: z19.literal("SessionEnd"),
|
|
4924
|
+
reason: z19.enum(["exit", "clear", "logout", "prompt_input_exit", "other"]).optional()
|
|
4740
4925
|
});
|
|
4741
4926
|
var beforeAgentInputSchema = baseHookInputSchema.extend({
|
|
4742
|
-
hook_event_name:
|
|
4743
|
-
prompt:
|
|
4927
|
+
hook_event_name: z19.literal("BeforeAgent"),
|
|
4928
|
+
prompt: z19.string().optional()
|
|
4744
4929
|
});
|
|
4745
4930
|
var afterAgentInputSchema = baseHookInputSchema.extend({
|
|
4746
|
-
hook_event_name:
|
|
4747
|
-
prompt:
|
|
4748
|
-
prompt_response:
|
|
4749
|
-
stop_hook_active:
|
|
4931
|
+
hook_event_name: z19.literal("AfterAgent"),
|
|
4932
|
+
prompt: z19.string().optional(),
|
|
4933
|
+
prompt_response: z19.string().optional(),
|
|
4934
|
+
stop_hook_active: z19.boolean().optional()
|
|
4750
4935
|
});
|
|
4751
4936
|
var beforeModelInputSchema = baseHookInputSchema.extend({
|
|
4752
|
-
hook_event_name:
|
|
4937
|
+
hook_event_name: z19.literal("BeforeModel"),
|
|
4753
4938
|
llm_request: geminiLlmRequestSchema
|
|
4754
4939
|
});
|
|
4755
4940
|
var afterModelInputSchema = baseHookInputSchema.extend({
|
|
4756
|
-
hook_event_name:
|
|
4941
|
+
hook_event_name: z19.literal("AfterModel"),
|
|
4757
4942
|
llm_request: geminiLlmRequestSchema,
|
|
4758
4943
|
llm_response: geminiLlmResponseSchema
|
|
4759
4944
|
});
|
|
4760
4945
|
var beforeToolSelectionInputSchema = baseHookInputSchema.extend({
|
|
4761
|
-
hook_event_name:
|
|
4946
|
+
hook_event_name: z19.literal("BeforeToolSelection"),
|
|
4762
4947
|
llm_request: geminiLlmRequestSchema
|
|
4763
4948
|
});
|
|
4764
4949
|
var beforeToolInputSchema = baseHookInputSchema.extend({
|
|
4765
|
-
hook_event_name:
|
|
4766
|
-
tool_name:
|
|
4767
|
-
tool_input:
|
|
4950
|
+
hook_event_name: z19.literal("BeforeTool"),
|
|
4951
|
+
tool_name: z19.string().min(1),
|
|
4952
|
+
tool_input: z19.unknown().optional(),
|
|
4768
4953
|
mcp_context: geminiMcpContextSchema.optional(),
|
|
4769
|
-
original_request_name:
|
|
4954
|
+
original_request_name: z19.string().min(1).optional()
|
|
4770
4955
|
});
|
|
4771
4956
|
var afterToolInputSchema = baseHookInputSchema.extend({
|
|
4772
|
-
hook_event_name:
|
|
4773
|
-
tool_name:
|
|
4774
|
-
tool_input:
|
|
4957
|
+
hook_event_name: z19.literal("AfterTool"),
|
|
4958
|
+
tool_name: z19.string().min(1),
|
|
4959
|
+
tool_input: z19.unknown().optional(),
|
|
4775
4960
|
tool_response: geminiToolResponseSchema.optional(),
|
|
4776
4961
|
mcp_context: geminiMcpContextSchema.optional(),
|
|
4777
|
-
original_request_name:
|
|
4962
|
+
original_request_name: z19.string().min(1).optional()
|
|
4778
4963
|
});
|
|
4779
4964
|
var preCompressInputSchema = baseHookInputSchema.extend({
|
|
4780
|
-
hook_event_name:
|
|
4781
|
-
trigger:
|
|
4965
|
+
hook_event_name: z19.literal("PreCompress"),
|
|
4966
|
+
trigger: z19.enum(["auto", "manual"]).optional()
|
|
4782
4967
|
});
|
|
4783
4968
|
var notificationInputSchema = baseHookInputSchema.extend({
|
|
4784
|
-
hook_event_name:
|
|
4785
|
-
notification_type:
|
|
4786
|
-
message:
|
|
4787
|
-
details:
|
|
4969
|
+
hook_event_name: z19.literal("Notification"),
|
|
4970
|
+
notification_type: z19.string().optional(),
|
|
4971
|
+
message: z19.string().optional(),
|
|
4972
|
+
details: z19.unknown().optional()
|
|
4788
4973
|
});
|
|
4789
|
-
var geminiHookInputSchema =
|
|
4974
|
+
var geminiHookInputSchema = z19.discriminatedUnion("hook_event_name", [
|
|
4790
4975
|
sessionStartInputSchema,
|
|
4791
4976
|
sessionEndInputSchema,
|
|
4792
4977
|
beforeAgentInputSchema,
|
|
@@ -5231,7 +5416,7 @@ var normalizeUsageOrWarn = (usage, warnings) => {
|
|
|
5231
5416
|
};
|
|
5232
5417
|
|
|
5233
5418
|
// src/providers/antigravity/payload.ts
|
|
5234
|
-
import { z as
|
|
5419
|
+
import { z as z20 } from "zod";
|
|
5235
5420
|
var ANTIGRAVITY_HOOK_EVENT_NAMES = [
|
|
5236
5421
|
"PreInvocation",
|
|
5237
5422
|
"PostInvocation",
|
|
@@ -5239,48 +5424,48 @@ var ANTIGRAVITY_HOOK_EVENT_NAMES = [
|
|
|
5239
5424
|
"PostToolUse",
|
|
5240
5425
|
"Stop"
|
|
5241
5426
|
];
|
|
5242
|
-
var hookEventNameSchema =
|
|
5243
|
-
var antigravityWeakShapeSchema =
|
|
5427
|
+
var hookEventNameSchema = z20.enum(ANTIGRAVITY_HOOK_EVENT_NAMES);
|
|
5428
|
+
var antigravityWeakShapeSchema = z20.object({ hookEventName: hookEventNameSchema }).passthrough();
|
|
5244
5429
|
var commonFields2 = {
|
|
5245
|
-
conversationId:
|
|
5246
|
-
workspacePaths:
|
|
5247
|
-
invocationNum:
|
|
5430
|
+
conversationId: z20.string().min(1),
|
|
5431
|
+
workspacePaths: z20.array(z20.string().min(1)).max(64),
|
|
5432
|
+
invocationNum: z20.number().int().min(0),
|
|
5248
5433
|
/** Never disclosed: a real filesystem path. Accepted, never propagated. */
|
|
5249
|
-
transcriptPath:
|
|
5434
|
+
transcriptPath: z20.string().min(1).optional(),
|
|
5250
5435
|
/** Never disclosed: a real filesystem path. Accepted, never propagated. */
|
|
5251
|
-
artifactDirectoryPath:
|
|
5436
|
+
artifactDirectoryPath: z20.string().min(1).optional()
|
|
5252
5437
|
};
|
|
5253
|
-
var preInvocationPayloadSchema =
|
|
5254
|
-
hookEventName:
|
|
5438
|
+
var preInvocationPayloadSchema = z20.object({
|
|
5439
|
+
hookEventName: z20.literal("PreInvocation"),
|
|
5255
5440
|
...commonFields2,
|
|
5256
|
-
agentVersion:
|
|
5441
|
+
agentVersion: z20.string().min(1).optional()
|
|
5257
5442
|
});
|
|
5258
|
-
var postInvocationPayloadSchema =
|
|
5259
|
-
hookEventName:
|
|
5443
|
+
var postInvocationPayloadSchema = z20.object({
|
|
5444
|
+
hookEventName: z20.literal("PostInvocation"),
|
|
5260
5445
|
...commonFields2,
|
|
5261
|
-
agentVersion:
|
|
5446
|
+
agentVersion: z20.string().min(1).optional()
|
|
5262
5447
|
});
|
|
5263
|
-
var preToolUsePayloadSchema3 =
|
|
5264
|
-
hookEventName:
|
|
5448
|
+
var preToolUsePayloadSchema3 = z20.object({
|
|
5449
|
+
hookEventName: z20.literal("PreToolUse"),
|
|
5265
5450
|
...commonFields2,
|
|
5266
|
-
stepIdx:
|
|
5267
|
-
toolName:
|
|
5268
|
-
toolInput:
|
|
5451
|
+
stepIdx: z20.number().int().min(0),
|
|
5452
|
+
toolName: z20.string().min(1),
|
|
5453
|
+
toolInput: z20.unknown().optional()
|
|
5269
5454
|
});
|
|
5270
|
-
var postToolUsePayloadSchema3 =
|
|
5271
|
-
hookEventName:
|
|
5455
|
+
var postToolUsePayloadSchema3 = z20.object({
|
|
5456
|
+
hookEventName: z20.literal("PostToolUse"),
|
|
5272
5457
|
...commonFields2,
|
|
5273
|
-
stepIdx:
|
|
5274
|
-
toolName:
|
|
5275
|
-
toolResponse:
|
|
5276
|
-
isError:
|
|
5458
|
+
stepIdx: z20.number().int().min(0),
|
|
5459
|
+
toolName: z20.string().min(1),
|
|
5460
|
+
toolResponse: z20.unknown().optional(),
|
|
5461
|
+
isError: z20.boolean().optional()
|
|
5277
5462
|
});
|
|
5278
|
-
var stopPayloadSchema3 =
|
|
5279
|
-
hookEventName:
|
|
5463
|
+
var stopPayloadSchema3 = z20.object({
|
|
5464
|
+
hookEventName: z20.literal("Stop"),
|
|
5280
5465
|
...commonFields2,
|
|
5281
|
-
fullyIdle:
|
|
5466
|
+
fullyIdle: z20.boolean()
|
|
5282
5467
|
});
|
|
5283
|
-
var antigravityHookPayloadSchema =
|
|
5468
|
+
var antigravityHookPayloadSchema = z20.discriminatedUnion("hookEventName", [
|
|
5284
5469
|
preInvocationPayloadSchema,
|
|
5285
5470
|
postInvocationPayloadSchema,
|
|
5286
5471
|
preToolUsePayloadSchema3,
|
|
@@ -5573,7 +5758,7 @@ var createFixedClock = (options = {}) => {
|
|
|
5573
5758
|
};
|
|
5574
5759
|
|
|
5575
5760
|
// src/runtime/hook.ts
|
|
5576
|
-
import { z as
|
|
5761
|
+
import { z as z22 } from "zod";
|
|
5577
5762
|
|
|
5578
5763
|
// src/runtime/delivery.ts
|
|
5579
5764
|
var PROVIDER_SCOPE_PREFIX = "provider-session";
|
|
@@ -5599,9 +5784,9 @@ var resolveDeliveryIdentity = (input) => {
|
|
|
5599
5784
|
};
|
|
5600
5785
|
|
|
5601
5786
|
// src/runtime/ids.ts
|
|
5602
|
-
import { createHash as
|
|
5787
|
+
import { createHash as createHash3, randomUUID } from "crypto";
|
|
5603
5788
|
var digest = (namespace, parts) => {
|
|
5604
|
-
const hash =
|
|
5789
|
+
const hash = createHash3("sha256");
|
|
5605
5790
|
hash.update(namespace);
|
|
5606
5791
|
for (const part of parts) {
|
|
5607
5792
|
hash.update("\0");
|
|
@@ -5640,15 +5825,15 @@ var createDeterministicIdGenerator = (options = {}) => {
|
|
|
5640
5825
|
};
|
|
5641
5826
|
|
|
5642
5827
|
// src/runtime/ports.ts
|
|
5643
|
-
import { z as
|
|
5644
|
-
var appliedDeliverySchema =
|
|
5645
|
-
callbackId:
|
|
5828
|
+
import { z as z21 } from "zod";
|
|
5829
|
+
var appliedDeliverySchema = z21.strictObject({
|
|
5830
|
+
callbackId: z21.string().regex(/^[A-Za-z0-9_-]{1,128}$/),
|
|
5646
5831
|
/** How many of that delivery's observations are folded in, counted from one. */
|
|
5647
|
-
applications:
|
|
5832
|
+
applications: z21.number().int().min(1).max(4096)
|
|
5648
5833
|
});
|
|
5649
|
-
var stateValueSchema =
|
|
5650
|
-
|
|
5651
|
-
kind:
|
|
5834
|
+
var stateValueSchema = z21.discriminatedUnion("kind", [
|
|
5835
|
+
z21.strictObject({
|
|
5836
|
+
kind: z21.literal("usage-cumulative"),
|
|
5652
5837
|
usage: canonicalUsageSchema,
|
|
5653
5838
|
/**
|
|
5654
5839
|
* Optional: absent on every record written before this field existed, which
|
|
@@ -5657,22 +5842,42 @@ var stateValueSchema = z20.discriminatedUnion("kind", [
|
|
|
5657
5842
|
*/
|
|
5658
5843
|
appliedDelivery: appliedDeliverySchema.optional()
|
|
5659
5844
|
}),
|
|
5660
|
-
|
|
5661
|
-
kind:
|
|
5845
|
+
z21.strictObject({
|
|
5846
|
+
kind: z21.literal("sequence"),
|
|
5662
5847
|
next: sequenceNumberSchema
|
|
5663
5848
|
}),
|
|
5664
|
-
|
|
5665
|
-
kind:
|
|
5849
|
+
z21.strictObject({
|
|
5850
|
+
kind: z21.literal("attributes"),
|
|
5666
5851
|
attributes: attributesSchema
|
|
5852
|
+
}),
|
|
5853
|
+
/**
|
|
5854
|
+
* The model a session last reported, so a later invocation whose payload names
|
|
5855
|
+
* none (Claude Code's `Stop`) can still say which model it was. A model id is
|
|
5856
|
+
* not sensitive (`modelDescriptorSchema`), and the descriptor is the strict,
|
|
5857
|
+
* bounded canonical shape, never a payload fragment.
|
|
5858
|
+
*/
|
|
5859
|
+
z21.strictObject({
|
|
5860
|
+
kind: z21.literal("session-model"),
|
|
5861
|
+
model: modelDescriptorSchema
|
|
5862
|
+
}),
|
|
5863
|
+
/**
|
|
5864
|
+
* How far a {@link PayloadEnricher} has read a session's append-only source
|
|
5865
|
+
* (Claude Code's transcript), so the next read starts where the last ended.
|
|
5866
|
+
* `source` is an opaque digest of what was read, never a path.
|
|
5867
|
+
*/
|
|
5868
|
+
z21.strictObject({
|
|
5869
|
+
kind: z21.literal("read-cursor"),
|
|
5870
|
+
source: z21.string().regex(/^[A-Za-z0-9_-]{1,128}$/),
|
|
5871
|
+
offset: z21.number().int().min(0).max(Number.MAX_SAFE_INTEGER)
|
|
5667
5872
|
})
|
|
5668
5873
|
]);
|
|
5669
|
-
var stateRecordSchema =
|
|
5874
|
+
var stateRecordSchema = z21.strictObject({
|
|
5670
5875
|
/** Incremented on each write; lets callers detect lost updates. */
|
|
5671
|
-
revision:
|
|
5876
|
+
revision: z21.number().int().min(0),
|
|
5672
5877
|
updatedAt: epochMillisSchema,
|
|
5673
5878
|
value: stateValueSchema
|
|
5674
5879
|
});
|
|
5675
|
-
var logLevelSchema =
|
|
5880
|
+
var logLevelSchema = z21.enum(["silent", "error", "warn", "info", "debug"]);
|
|
5676
5881
|
var LOG_LEVEL_RANK = Object.freeze({
|
|
5677
5882
|
silent: 0,
|
|
5678
5883
|
error: 1,
|
|
@@ -5690,16 +5895,16 @@ var createNullLogger = () => ({
|
|
|
5690
5895
|
});
|
|
5691
5896
|
|
|
5692
5897
|
// src/runtime/target-resolution.ts
|
|
5693
|
-
import * as
|
|
5898
|
+
import * as path2 from "path";
|
|
5694
5899
|
var DEFAULT_TARGET_RESOLUTION_BUDGET_MILLIS = 50;
|
|
5695
5900
|
var absolutePathsOf = (hint) => {
|
|
5696
|
-
const base = hint.baseDirectory !== void 0 &&
|
|
5901
|
+
const base = hint.baseDirectory !== void 0 && path2.isAbsolute(hint.baseDirectory) ? hint.baseDirectory : void 0;
|
|
5697
5902
|
const resolved = [];
|
|
5698
5903
|
for (const candidate of hint.paths) {
|
|
5699
|
-
if (
|
|
5700
|
-
resolved.push(
|
|
5904
|
+
if (path2.isAbsolute(candidate)) {
|
|
5905
|
+
resolved.push(path2.resolve(candidate));
|
|
5701
5906
|
} else if (base !== void 0) {
|
|
5702
|
-
resolved.push(
|
|
5907
|
+
resolved.push(path2.resolve(base, candidate));
|
|
5703
5908
|
} else {
|
|
5704
5909
|
return void 0;
|
|
5705
5910
|
}
|
|
@@ -5806,7 +6011,7 @@ var withOptionalSessionLock = async (store, sessionId, fn, options) => {
|
|
|
5806
6011
|
};
|
|
5807
6012
|
|
|
5808
6013
|
// src/runtime/hook.ts
|
|
5809
|
-
var usageScopeSchema =
|
|
6014
|
+
var usageScopeSchema = z22.enum(["session", "generation", "subagent"]);
|
|
5810
6015
|
var classifyDurability = (input) => {
|
|
5811
6016
|
if (!input.attempted) {
|
|
5812
6017
|
return "nothing-to-deliver";
|
|
@@ -5863,6 +6068,22 @@ var usageScopeOf = (event3) => {
|
|
|
5863
6068
|
}
|
|
5864
6069
|
};
|
|
5865
6070
|
var sequenceKey = (sessionId) => `sequence:${sessionId}`;
|
|
6071
|
+
var sessionModelKey = (sessionId) => `model:${sessionId}`;
|
|
6072
|
+
var readCursorKey = (enricherId, sessionId) => `cursor:${enricherId}:${sessionId}`;
|
|
6073
|
+
var UNKNOWN_MODEL_ID = "unknown";
|
|
6074
|
+
var latestSessionModel = (events) => {
|
|
6075
|
+
let latest;
|
|
6076
|
+
for (const event3 of events) {
|
|
6077
|
+
if (event3.subagentId !== void 0) {
|
|
6078
|
+
continue;
|
|
6079
|
+
}
|
|
6080
|
+
if ((event3.type === "session.start" || event3.type === "generation.start" || event3.type === "generation.end") && event3.model !== void 0 && event3.model.modelId !== UNKNOWN_MODEL_ID) {
|
|
6081
|
+
latest = event3.model;
|
|
6082
|
+
}
|
|
6083
|
+
}
|
|
6084
|
+
return latest;
|
|
6085
|
+
};
|
|
6086
|
+
var sameModel = (left, right) => left !== void 0 && left.modelId === right.modelId && left.vendor === right.vendor && left.family === right.family;
|
|
5866
6087
|
var usageKey = (sessionId, scope, scopeKey) => `usage:${sessionId}:${scope}:${scopeKey}`;
|
|
5867
6088
|
var baselineScopeOf = (scope, scopeKey, sessionId, series) => series === "session-lifetime" && scope === "generation" ? { scope: "session", scopeKey: sessionId } : { scope, scopeKey };
|
|
5868
6089
|
var createOtelHook = (deps) => {
|
|
@@ -5910,6 +6131,66 @@ var createOtelHook = (deps) => {
|
|
|
5910
6131
|
return 0;
|
|
5911
6132
|
}
|
|
5912
6133
|
};
|
|
6134
|
+
const enrichPayload = async (payload, providerId, sessionId, diagnostics) => {
|
|
6135
|
+
let current = payload;
|
|
6136
|
+
for (const enricher of deps.payloadEnrichers ?? []) {
|
|
6137
|
+
if (enricher.providerId !== providerId) {
|
|
6138
|
+
continue;
|
|
6139
|
+
}
|
|
6140
|
+
const key = readCursorKey(enricher.id, sessionId);
|
|
6141
|
+
let cursor;
|
|
6142
|
+
try {
|
|
6143
|
+
const record = await deps.stateStore.read(key);
|
|
6144
|
+
if (record?.value.kind === "read-cursor") {
|
|
6145
|
+
cursor = { source: record.value.source, offset: record.value.offset };
|
|
6146
|
+
}
|
|
6147
|
+
} catch (thrown) {
|
|
6148
|
+
diagnostics.push(
|
|
6149
|
+
errorInfoFromThrown(thrown, { code: "state-store-failure", phase: "state", occurredAt: clock.now() })
|
|
6150
|
+
);
|
|
6151
|
+
continue;
|
|
6152
|
+
}
|
|
6153
|
+
let result;
|
|
6154
|
+
try {
|
|
6155
|
+
result = await enricher.enrich({ payload: current, sessionId, ...cursor === void 0 ? {} : { cursor } });
|
|
6156
|
+
} catch (thrown) {
|
|
6157
|
+
logger.warn("payload enricher failed; parsing the payload as delivered", {
|
|
6158
|
+
"enricher.id": enricher.id,
|
|
6159
|
+
"error.name": thrown instanceof Error ? thrown.name : typeof thrown
|
|
6160
|
+
});
|
|
6161
|
+
continue;
|
|
6162
|
+
}
|
|
6163
|
+
current = result.payload;
|
|
6164
|
+
if (result.notes !== void 0 && result.notes.length > 0) {
|
|
6165
|
+
logger.debug("payload enricher notes", {
|
|
6166
|
+
"enricher.id": enricher.id,
|
|
6167
|
+
"enricher.notes": result.notes.slice(0, 8).map((note) => note.slice(0, 200))
|
|
6168
|
+
});
|
|
6169
|
+
}
|
|
6170
|
+
const next = result.cursor;
|
|
6171
|
+
if (next !== void 0 && (next.source !== cursor?.source || next.offset !== cursor.offset)) {
|
|
6172
|
+
try {
|
|
6173
|
+
await deps.stateStore.write(key, { kind: "read-cursor", source: next.source, offset: next.offset });
|
|
6174
|
+
} catch (thrown) {
|
|
6175
|
+
diagnostics.push(
|
|
6176
|
+
errorInfoFromThrown(thrown, { code: "state-store-failure", phase: "state", occurredAt: clock.now() })
|
|
6177
|
+
);
|
|
6178
|
+
}
|
|
6179
|
+
}
|
|
6180
|
+
}
|
|
6181
|
+
return current;
|
|
6182
|
+
};
|
|
6183
|
+
const readSessionModel = async (sessionId, diagnostics) => {
|
|
6184
|
+
try {
|
|
6185
|
+
const record = await deps.stateStore.read(sessionModelKey(sessionId));
|
|
6186
|
+
return record?.value.kind === "session-model" ? record.value.model : void 0;
|
|
6187
|
+
} catch (thrown) {
|
|
6188
|
+
diagnostics.push(
|
|
6189
|
+
errorInfoFromThrown(thrown, { code: "state-store-failure", phase: "state", occurredAt: clock.now() })
|
|
6190
|
+
);
|
|
6191
|
+
return void 0;
|
|
6192
|
+
}
|
|
6193
|
+
};
|
|
5913
6194
|
const deriveUsage = async (events, diagnostics, suppress, series) => {
|
|
5914
6195
|
const observations = [];
|
|
5915
6196
|
for (const event3 of events) {
|
|
@@ -6230,10 +6511,19 @@ var createOtelHook = (deps) => {
|
|
|
6230
6511
|
const identity = resolution.identity;
|
|
6231
6512
|
const prepare = async () => {
|
|
6232
6513
|
const sequenceBase = await readSequenceBase(identity.sessionId, diagnostics);
|
|
6514
|
+
const sessionModel = await readSessionModel(identity.sessionId, diagnostics);
|
|
6515
|
+
const payload = suppress ? detectionInput.payload : await enrichPayload(detectionInput.payload, detection.providerId, identity.sessionId, diagnostics);
|
|
6233
6516
|
let parsed;
|
|
6234
6517
|
try {
|
|
6235
6518
|
parsed = adapter.parse(
|
|
6236
|
-
{
|
|
6519
|
+
{
|
|
6520
|
+
...detectionInput,
|
|
6521
|
+
payload,
|
|
6522
|
+
detection,
|
|
6523
|
+
identity,
|
|
6524
|
+
sequenceBase,
|
|
6525
|
+
...sessionModel === void 0 ? {} : { sessionModel }
|
|
6526
|
+
},
|
|
6237
6527
|
providerContext
|
|
6238
6528
|
);
|
|
6239
6529
|
} catch (thrown) {
|
|
@@ -6343,6 +6633,23 @@ var createOtelHook = (deps) => {
|
|
|
6343
6633
|
})
|
|
6344
6634
|
);
|
|
6345
6635
|
}
|
|
6636
|
+
const reportedModel = latestSessionModel(screened.kept);
|
|
6637
|
+
if (reportedModel !== void 0 && !sameModel(sessionModel, reportedModel)) {
|
|
6638
|
+
try {
|
|
6639
|
+
await deps.stateStore.write(sessionModelKey(identity.sessionId), {
|
|
6640
|
+
kind: "session-model",
|
|
6641
|
+
model: reportedModel
|
|
6642
|
+
});
|
|
6643
|
+
} catch (thrown) {
|
|
6644
|
+
diagnostics.push(
|
|
6645
|
+
errorInfoFromThrown(thrown, {
|
|
6646
|
+
code: "state-store-failure",
|
|
6647
|
+
phase: "state",
|
|
6648
|
+
occurredAt: clock.now()
|
|
6649
|
+
})
|
|
6650
|
+
);
|
|
6651
|
+
}
|
|
6652
|
+
}
|
|
6346
6653
|
}
|
|
6347
6654
|
return {
|
|
6348
6655
|
kind: "ready",
|
|
@@ -6679,11 +6986,11 @@ var createRecordingLogger = (level = "debug") => {
|
|
|
6679
6986
|
};
|
|
6680
6987
|
|
|
6681
6988
|
// src/testing/fixture-adapter.ts
|
|
6682
|
-
import { z as
|
|
6683
|
-
var syntheticPayloadSchema =
|
|
6684
|
-
provider:
|
|
6685
|
-
sessionId:
|
|
6686
|
-
event:
|
|
6989
|
+
import { z as z23 } from "zod";
|
|
6990
|
+
var syntheticPayloadSchema = z23.object({
|
|
6991
|
+
provider: z23.string().min(1),
|
|
6992
|
+
sessionId: z23.string().min(1),
|
|
6993
|
+
event: z23.enum([
|
|
6687
6994
|
"session.start",
|
|
6688
6995
|
"prompt",
|
|
6689
6996
|
"generation",
|
|
@@ -6693,15 +7000,15 @@ var syntheticPayloadSchema = z22.object({
|
|
|
6693
7000
|
"session.end",
|
|
6694
7001
|
"noop"
|
|
6695
7002
|
]),
|
|
6696
|
-
requestId:
|
|
6697
|
-
model:
|
|
6698
|
-
promptText:
|
|
6699
|
-
toolName:
|
|
6700
|
-
toolInput:
|
|
6701
|
-
workspaceKey:
|
|
6702
|
-
occurredAt:
|
|
7003
|
+
requestId: z23.string().min(1).optional(),
|
|
7004
|
+
model: z23.string().min(1).optional(),
|
|
7005
|
+
promptText: z23.string().optional(),
|
|
7006
|
+
toolName: z23.string().min(1).optional(),
|
|
7007
|
+
toolInput: z23.unknown().optional(),
|
|
7008
|
+
workspaceKey: z23.string().min(1).optional(),
|
|
7009
|
+
occurredAt: z23.number().int().min(0).optional(),
|
|
6703
7010
|
usage: usageReportSchema.optional(),
|
|
6704
|
-
agentVersion:
|
|
7011
|
+
agentVersion: z23.string().min(1).optional()
|
|
6705
7012
|
});
|
|
6706
7013
|
var SYNTHETIC_PROVIDER_ID = "fixture";
|
|
6707
7014
|
var DEFAULT_FIXTURE_CAPABILITIES = Object.freeze({
|
|
@@ -7105,7 +7412,8 @@ var createTestHook = (options = {}) => {
|
|
|
7105
7412
|
privacy,
|
|
7106
7413
|
logger,
|
|
7107
7414
|
...options.worktreeLocator === void 0 ? {} : { worktreeLocator: options.worktreeLocator },
|
|
7108
|
-
...options.targetResolutionBudgetMillis === void 0 ? {} : { targetResolutionBudgetMillis: options.targetResolutionBudgetMillis }
|
|
7415
|
+
...options.targetResolutionBudgetMillis === void 0 ? {} : { targetResolutionBudgetMillis: options.targetResolutionBudgetMillis },
|
|
7416
|
+
...options.payloadEnrichers === void 0 ? {} : { payloadEnrichers: options.payloadEnrichers }
|
|
7109
7417
|
});
|
|
7110
7418
|
return { hook, sink, stateStore, clock, ids, privacy, logger, registry, config };
|
|
7111
7419
|
};
|