@osfactory/otel-hook 0.11.0 → 0.13.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 +32 -5
- package/dist/{adapter-DiLknaTF.d.ts → adapter-DyCb7y1N.d.ts} +2 -2
- package/dist/cli.js +507 -108
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +3 -3
- package/dist/config.js +16 -3
- package/dist/config.js.map +1 -1
- package/dist/{destinations-BIl3gGzx.d.ts → destinations-DvqsPulb.d.ts} +1 -1
- package/dist/{events-CSD_YiJ2.d.ts → events-fcomX6d5.d.ts} +22 -0
- package/dist/{export-destinations-QWKGGEjk.d.ts → export-destinations-Bey2djRk.d.ts} +11 -6
- package/dist/{filesystem-store-D3SCNmbX.d.ts → filesystem-store-B3CpiIRl.d.ts} +1 -1
- package/dist/{hook-BOecWGSz.d.ts → hook-D5imE0Qc.d.ts} +11 -5
- package/dist/index.d.ts +14 -14
- package/dist/index.js +525 -143
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +4 -4
- package/dist/install.js +19 -2
- package/dist/install.js.map +1 -1
- package/dist/integration.d.ts +16 -10
- package/dist/integration.js +447 -111
- package/dist/integration.js.map +1 -1
- package/dist/lifecycle.d.ts +3 -3
- package/dist/lifecycle.js +10 -2
- package/dist/lifecycle.js.map +1 -1
- package/dist/{memory-Cs51jyRk.d.ts → memory-B3r6sZtC.d.ts} +2 -2
- package/dist/{metric-model-DDnWxL9d.d.ts → metric-model-CFIeUwqd.d.ts} +6 -2
- package/dist/model.d.ts +1 -1
- package/dist/model.js +9 -1
- package/dist/model.js.map +1 -1
- package/dist/{payload-ChtrEX6A.d.ts → payload-CdDKeRpH.d.ts} +1 -1
- package/dist/{ports-CeqLq31i.d.ts → ports-DhpSDIkp.d.ts} +41 -3
- package/dist/providers.d.ts +30 -14
- package/dist/providers.js +131 -42
- package/dist/providers.js.map +1 -1
- package/dist/{registry-CcJNF3WY.d.ts → registry-BKQhhIO3.d.ts} +2 -2
- package/dist/runtime.d.ts +97 -9
- package/dist/runtime.js +269 -26
- package/dist/runtime.js.map +1 -1
- package/dist/{schema-DMnoU1V_.d.ts → schema-SpFM6YQY.d.ts} +24 -1
- package/dist/state.d.ts +4 -4
- package/dist/state.js +9 -1
- package/dist/state.js.map +1 -1
- package/dist/telemetry.d.ts +6 -6
- package/dist/telemetry.js +80 -22
- package/dist/telemetry.js.map +1 -1
- package/dist/testing.d.ts +10 -8
- package/dist/testing.js +161 -30
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/testing.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { O as OtelHookConfig, i as OtelHookConfigPatch } from './schema-
|
|
2
|
-
import { b as CanonicalEvent } from './events-
|
|
1
|
+
import { O as OtelHookConfig, i as OtelHookConfigPatch } from './schema-SpFM6YQY.js';
|
|
2
|
+
import { b as CanonicalEvent } from './events-fcomX6d5.js';
|
|
3
3
|
import { I as IdentityClaim, d as InvocationIdentity, S as SourceProvenance } from './identity-BrVBs901.js';
|
|
4
4
|
import { P as PrivacyService } from './service-CbI9CObT.js';
|
|
5
|
-
import { d as ProviderCapabilities, h as ProviderDetection, i as ProviderDetectionInput, e as ProviderContext, l as ProviderIdentityInput, f as ProviderDeliveryClaim, k as ProviderHookResponseInput, j as ProviderHookResponse, P as ProviderAdapter } from './adapter-
|
|
6
|
-
import { P as ProviderRegistry } from './registry-
|
|
7
|
-
import { I as IdGenerator, W as WorktreeLocator, P as PayloadEnricher } from './ports-
|
|
8
|
-
import { c as RecordingTelemetrySink, I as InMemoryStateStore, F as FixedClock, R as RecordingLogger } from './memory-
|
|
9
|
-
export { e as createDeterministicIdGenerator, f as createFixedClock, g as createInMemoryStateStore, j as createRecordingLogger, k as createRecordingTelemetrySink } from './memory-
|
|
10
|
-
import { O as OtelHook } from './hook-
|
|
5
|
+
import { d as ProviderCapabilities, h as ProviderDetection, i as ProviderDetectionInput, e as ProviderContext, l as ProviderIdentityInput, f as ProviderDeliveryClaim, k as ProviderHookResponseInput, j as ProviderHookResponse, P as ProviderAdapter } from './adapter-DyCb7y1N.js';
|
|
6
|
+
import { P as ProviderRegistry } from './registry-BKQhhIO3.js';
|
|
7
|
+
import { I as IdGenerator, W as WorktreeLocator, P as PayloadEnricher, S as SessionContextReader } from './ports-DhpSDIkp.js';
|
|
8
|
+
import { c as RecordingTelemetrySink, I as InMemoryStateStore, F as FixedClock, R as RecordingLogger } from './memory-B3r6sZtC.js';
|
|
9
|
+
export { e as createDeterministicIdGenerator, f as createFixedClock, g as createInMemoryStateStore, j as createRecordingLogger, k as createRecordingTelemetrySink } from './memory-B3r6sZtC.js';
|
|
10
|
+
import { O as OtelHook } from './hook-D5imE0Qc.js';
|
|
11
11
|
import { z } from 'zod';
|
|
12
12
|
import { a as ContentDisclosure, b as ContentFact } from './content-M9xIKG7h.js';
|
|
13
13
|
import './primitives-CJ8-rn-f.js';
|
|
@@ -146,6 +146,8 @@ type TestHarnessOptions = {
|
|
|
146
146
|
readonly targetResolutionBudgetMillis?: number;
|
|
147
147
|
/** Payload enrichers, as a host would configure them (none by default). */
|
|
148
148
|
readonly payloadEnrichers?: readonly PayloadEnricher[];
|
|
149
|
+
/** Session context reader (none by default), e.g. a fake or the directory reader. */
|
|
150
|
+
readonly sessionContext?: SessionContextReader;
|
|
149
151
|
};
|
|
150
152
|
type TestHarness = {
|
|
151
153
|
readonly hook: OtelHook;
|
package/dist/testing.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/config/schema.ts
|
|
2
|
+
import { isAbsolute } from "path";
|
|
2
3
|
import { z as z5 } from "zod";
|
|
3
4
|
|
|
4
5
|
// src/model/primitives.ts
|
|
@@ -416,13 +417,19 @@ var providersPolicySchema = z5.strictObject({
|
|
|
416
417
|
readTranscriptUsage: z5.boolean()
|
|
417
418
|
}).optional()
|
|
418
419
|
});
|
|
420
|
+
var sessionContextPolicySchema = z5.strictObject({
|
|
421
|
+
/** Absolute path of the context directory. */
|
|
422
|
+
dir: z5.string().min(1).max(4096).refine((value) => isAbsolute(value), { message: "must be an absolute path" })
|
|
423
|
+
});
|
|
419
424
|
var otelHookConfigSchema = z5.strictObject({
|
|
420
425
|
exporter: exporterPolicySchema,
|
|
421
426
|
privacy: privacyPolicySchema,
|
|
422
427
|
detection: detectionPolicySchema,
|
|
423
428
|
diagnostics: diagnosticsPolicySchema,
|
|
424
429
|
/** Optional so a hand-built configuration from before it existed stays valid. */
|
|
425
|
-
providers: providersPolicySchema.optional()
|
|
430
|
+
providers: providersPolicySchema.optional(),
|
|
431
|
+
/** Optional: absent means no session context is read. */
|
|
432
|
+
sessionContext: sessionContextPolicySchema.optional()
|
|
426
433
|
});
|
|
427
434
|
var otelHookConfigPatchSchema = z5.strictObject({
|
|
428
435
|
// `logs` is unwrapped and re-partialled for the same reason `privacy.limits` is:
|
|
@@ -438,7 +445,8 @@ var otelHookConfigPatchSchema = z5.strictObject({
|
|
|
438
445
|
diagnostics: diagnosticsPolicySchema.partial().optional(),
|
|
439
446
|
providers: z5.strictObject({
|
|
440
447
|
claudeCode: z5.strictObject({ readTranscriptUsage: z5.boolean() }).partial().optional()
|
|
441
|
-
}).partial().optional()
|
|
448
|
+
}).partial().optional(),
|
|
449
|
+
sessionContext: sessionContextPolicySchema.partial().optional()
|
|
442
450
|
});
|
|
443
451
|
var DEFAULT_EXPORTER_POLICY = Object.freeze({
|
|
444
452
|
enabled: true,
|
|
@@ -915,11 +923,11 @@ var createPrivacyService = (policyInput) => {
|
|
|
915
923
|
};
|
|
916
924
|
const flattenToAttributes = (value, prefix) => {
|
|
917
925
|
const attributes = {};
|
|
918
|
-
const walk = (current,
|
|
926
|
+
const walk = (current, path4) => {
|
|
919
927
|
if (typeof current === "string" || typeof current === "number" || typeof current === "boolean") {
|
|
920
928
|
const primitive = toAttributePrimitive(current);
|
|
921
929
|
if (primitive !== void 0) {
|
|
922
|
-
attributes[
|
|
930
|
+
attributes[path4] = primitive;
|
|
923
931
|
}
|
|
924
932
|
return;
|
|
925
933
|
}
|
|
@@ -938,16 +946,16 @@ var createPrivacyService = (policyInput) => {
|
|
|
938
946
|
primitives.push(entryPrimitive);
|
|
939
947
|
}
|
|
940
948
|
if (uniform) {
|
|
941
|
-
attributes[
|
|
949
|
+
attributes[path4] = primitives.slice(0, MAX_ATTRIBUTE_ARRAY_LENGTH);
|
|
942
950
|
return;
|
|
943
951
|
}
|
|
944
952
|
for (const [index, entry] of current.entries()) {
|
|
945
|
-
walk(entry, `${
|
|
953
|
+
walk(entry, `${path4}.${index}`);
|
|
946
954
|
}
|
|
947
955
|
return;
|
|
948
956
|
}
|
|
949
957
|
for (const [key, entry] of Object.entries(current)) {
|
|
950
|
-
walk(entry,
|
|
958
|
+
walk(entry, path4 === "" ? key : `${path4}.${key}`);
|
|
951
959
|
}
|
|
952
960
|
};
|
|
953
961
|
walk(value, prefix);
|
|
@@ -1580,7 +1588,15 @@ var baseEventFields = {
|
|
|
1580
1588
|
* factory, never by hand.
|
|
1581
1589
|
*/
|
|
1582
1590
|
subagentId: subagentIdSchema.optional(),
|
|
1583
|
-
extensions: extensionsSchema.default(emptyExtensions)
|
|
1591
|
+
extensions: extensionsSchema.default(emptyExtensions),
|
|
1592
|
+
/**
|
|
1593
|
+
* Attributes of the session context segment in force when the event
|
|
1594
|
+
* occurred (`docs/session-context.md`), stamped by the core from a file a
|
|
1595
|
+
* harness wrote. Exported on every record of the event, over the same keys
|
|
1596
|
+
* from the Resource. Absent when no context applies. Set by the core only,
|
|
1597
|
+
* never by an adapter.
|
|
1598
|
+
*/
|
|
1599
|
+
contextAttributes: z13.record(z13.string().min(1).max(255), z13.union([z13.string(), z13.number(), z13.boolean()])).optional()
|
|
1584
1600
|
};
|
|
1585
1601
|
var event = (shape) => z13.strictObject({ ...baseEventFields, ...shape });
|
|
1586
1602
|
var sessionStartEventSchema = event({
|
|
@@ -1931,6 +1947,7 @@ var createEventFactory = (input) => {
|
|
|
1931
1947
|
const rest = { ...drafted };
|
|
1932
1948
|
delete rest.target;
|
|
1933
1949
|
delete rest.subagentId;
|
|
1950
|
+
delete rest.contextAttributes;
|
|
1934
1951
|
const sanitized = extensions === void 0 ? { extensions: {}, droppedKeys: [] } : context.privacy.sanitizeExtensions(extensions);
|
|
1935
1952
|
dropped.push(...sanitized.droppedKeys);
|
|
1936
1953
|
const currentSequence = sequence;
|
|
@@ -2239,7 +2256,16 @@ var subagentStopPayloadSchema = z16.object({
|
|
|
2239
2256
|
last_assistant_message: z16.string().optional(),
|
|
2240
2257
|
/** True when this stop fired because a hook continued the subagent's turn. */
|
|
2241
2258
|
stop_hook_active: z16.boolean().optional(),
|
|
2242
|
-
|
|
2259
|
+
/**
|
|
2260
|
+
* The subagent run's tokens since its previous stop — harness- or
|
|
2261
|
+
* enricher-supplied, never upstream. Reported on the subagent's own
|
|
2262
|
+
* generation, never on the parent turn (issue #68).
|
|
2263
|
+
*/
|
|
2264
|
+
usage: claudeUsageSchema.optional(),
|
|
2265
|
+
/** Harness-supplied, never upstream: the subagent's model, from its transcript. */
|
|
2266
|
+
model: z16.string().min(1).max(256).optional().catch(void 0),
|
|
2267
|
+
/** Harness-supplied, never upstream: see `stopPayloadSchema.usage_partial`. */
|
|
2268
|
+
usage_partial: z16.boolean().optional().catch(void 0)
|
|
2243
2269
|
});
|
|
2244
2270
|
var preCompactPayloadSchema = z16.object({
|
|
2245
2271
|
...commonFields,
|
|
@@ -2884,6 +2910,8 @@ var BUILT_IN_TOOL_KIND = Object.freeze({
|
|
|
2884
2910
|
WebFetch: "network",
|
|
2885
2911
|
WebSearch: "network",
|
|
2886
2912
|
Task: "delegate",
|
|
2913
|
+
// Current Claude Code releases (observed on 2.1.332) name the subagent tool `Agent`.
|
|
2914
|
+
Agent: "delegate",
|
|
2887
2915
|
TodoWrite: "other",
|
|
2888
2916
|
ExitPlanMode: "other",
|
|
2889
2917
|
AskUserQuestion: "other",
|
|
@@ -3057,14 +3085,39 @@ var parseClaudeCode = (input, context) => {
|
|
|
3057
3085
|
delegationDepth: 1
|
|
3058
3086
|
});
|
|
3059
3087
|
break;
|
|
3060
|
-
case "SubagentStop":
|
|
3088
|
+
case "SubagentStop": {
|
|
3089
|
+
const usage = withPartialUsage(extractedUsage ?? payload.usage, payload.usage_partial);
|
|
3090
|
+
if (usage.usage !== void 0 || payload.model !== void 0) {
|
|
3091
|
+
const generationId = context.ids.newOpaqueId([
|
|
3092
|
+
"claude-subagent-generation",
|
|
3093
|
+
payload.session_id,
|
|
3094
|
+
payload.agent_id,
|
|
3095
|
+
...payload.stop_hook_active === true ? [String(input.sequenceBase)] : []
|
|
3096
|
+
]);
|
|
3097
|
+
const models = generationModels(payload.model, void 0);
|
|
3098
|
+
factory.build({ type: "generation.start", generationId, model: models.request });
|
|
3099
|
+
factory.build({
|
|
3100
|
+
type: "generation.end",
|
|
3101
|
+
generationId,
|
|
3102
|
+
model: models.response,
|
|
3103
|
+
outcome: "ok",
|
|
3104
|
+
outputContent: [
|
|
3105
|
+
payload.last_assistant_message === void 0 ? context.privacy.describeUnavailableContent({ kind: "response", role: "assistant" }) : context.privacy.describeContent({
|
|
3106
|
+
kind: "response",
|
|
3107
|
+
role: "assistant",
|
|
3108
|
+
text: payload.last_assistant_message
|
|
3109
|
+
})
|
|
3110
|
+
],
|
|
3111
|
+
...usage
|
|
3112
|
+
});
|
|
3113
|
+
}
|
|
3061
3114
|
factory.build({
|
|
3062
3115
|
type: "subagent.end",
|
|
3063
3116
|
subagentInvocationId: subagentInvocationIdFor(context, payload.session_id, payload.agent_id),
|
|
3064
|
-
outcome: "ok"
|
|
3065
|
-
...withUsage(payload.usage)
|
|
3117
|
+
outcome: "ok"
|
|
3066
3118
|
});
|
|
3067
3119
|
break;
|
|
3120
|
+
}
|
|
3068
3121
|
case "PreCompact":
|
|
3069
3122
|
return {
|
|
3070
3123
|
status: "ignored",
|
|
@@ -5781,7 +5834,7 @@ var createFixedClock = (options = {}) => {
|
|
|
5781
5834
|
};
|
|
5782
5835
|
|
|
5783
5836
|
// src/runtime/hook.ts
|
|
5784
|
-
import { z as
|
|
5837
|
+
import { z as z23 } from "zod";
|
|
5785
5838
|
|
|
5786
5839
|
// src/runtime/delivery.ts
|
|
5787
5840
|
var PROVIDER_SCOPE_PREFIX = "provider-session";
|
|
@@ -6056,8 +6109,64 @@ var withOptionalSessionLock = async (store, sessionId, fn, options) => {
|
|
|
6056
6109
|
return fn();
|
|
6057
6110
|
};
|
|
6058
6111
|
|
|
6112
|
+
// src/runtime/session-context.ts
|
|
6113
|
+
import { open as open2 } from "fs/promises";
|
|
6114
|
+
import * as path3 from "path";
|
|
6115
|
+
import { z as z22 } from "zod";
|
|
6116
|
+
var SESSION_CONTEXT_FILE_VERSION = 1;
|
|
6117
|
+
var DEFAULT_SESSION_CONTEXT_MAX_BYTES = 256 * 1024;
|
|
6118
|
+
var MAX_SESSION_CONTEXT_SEGMENTS = 1024;
|
|
6119
|
+
var SESSION_CONTEXT_AGENT_TOOLS = Object.freeze({
|
|
6120
|
+
"claude-code": "claude_code",
|
|
6121
|
+
codex: "codex",
|
|
6122
|
+
cursor: "cursor",
|
|
6123
|
+
"gemini-cli": "gemini_cli",
|
|
6124
|
+
antigravity: "antigravity"
|
|
6125
|
+
});
|
|
6126
|
+
var RESERVED_CONTEXT_PREFIXES = Object.freeze(["factory.local.", "otelhook."]);
|
|
6127
|
+
var ISO_INSTANT_PATTERN = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2})$/;
|
|
6128
|
+
var isoInstantSchema = z22.string().max(64).regex(ISO_INSTANT_PATTERN).transform((value, ctx) => {
|
|
6129
|
+
const millis = Date.parse(value);
|
|
6130
|
+
if (!Number.isFinite(millis)) {
|
|
6131
|
+
ctx.issues.push({ code: "custom", input: value, message: "not a valid instant" });
|
|
6132
|
+
return z22.NEVER;
|
|
6133
|
+
}
|
|
6134
|
+
return millis;
|
|
6135
|
+
});
|
|
6136
|
+
var segmentSchema = z22.object({
|
|
6137
|
+
from: isoInstantSchema,
|
|
6138
|
+
to: isoInstantSchema.nullable(),
|
|
6139
|
+
reason: z22.string().max(256).optional(),
|
|
6140
|
+
attributes: z22.record(z22.string(), z22.unknown())
|
|
6141
|
+
});
|
|
6142
|
+
var sessionContextFileSchema = z22.object({
|
|
6143
|
+
version: z22.literal(SESSION_CONTEXT_FILE_VERSION),
|
|
6144
|
+
agentTool: z22.string().max(64).optional(),
|
|
6145
|
+
sessionId: z22.string().max(256).optional(),
|
|
6146
|
+
segments: z22.array(segmentSchema).max(MAX_SESSION_CONTEXT_SEGMENTS)
|
|
6147
|
+
});
|
|
6148
|
+
var segmentInForce = (segments, at) => {
|
|
6149
|
+
let best;
|
|
6150
|
+
for (const segment of segments) {
|
|
6151
|
+
if (segment.from <= at && (segment.to === null || at < segment.to)) {
|
|
6152
|
+
if (best === void 0 || segment.from >= best.from) {
|
|
6153
|
+
best = segment;
|
|
6154
|
+
}
|
|
6155
|
+
}
|
|
6156
|
+
}
|
|
6157
|
+
return best;
|
|
6158
|
+
};
|
|
6159
|
+
var stampSessionContext = (events, segments) => events.map((event3) => {
|
|
6160
|
+
const { contextAttributes: _discarded, ...rest } = event3;
|
|
6161
|
+
const segment = segments === void 0 ? void 0 : segmentInForce(segments, event3.occurredAt);
|
|
6162
|
+
if (segment === void 0 || Object.keys(segment.attributes).length === 0) {
|
|
6163
|
+
return _discarded === void 0 ? event3 : rest;
|
|
6164
|
+
}
|
|
6165
|
+
return { ...rest, contextAttributes: { ...segment.attributes } };
|
|
6166
|
+
});
|
|
6167
|
+
|
|
6059
6168
|
// src/runtime/hook.ts
|
|
6060
|
-
var usageScopeSchema =
|
|
6169
|
+
var usageScopeSchema = z23.enum(["session", "generation", "subagent"]);
|
|
6061
6170
|
var classifyDurability = (input) => {
|
|
6062
6171
|
if (!input.attempted) {
|
|
6063
6172
|
return "nothing-to-deliver";
|
|
@@ -6115,7 +6224,7 @@ var usageScopeOf = (event3) => {
|
|
|
6115
6224
|
};
|
|
6116
6225
|
var sequenceKey = (sessionId) => `sequence:${sessionId}`;
|
|
6117
6226
|
var sessionModelKey = (sessionId) => `model:${sessionId}`;
|
|
6118
|
-
var readCursorKey = (enricherId, sessionId) => `cursor:${enricherId}:${sessionId}`;
|
|
6227
|
+
var readCursorKey = (enricherId, sessionId, scope) => scope === void 0 ? `cursor:${enricherId}:${sessionId}` : `cursor:${enricherId}:${sessionId}:${scope}`;
|
|
6119
6228
|
var UNKNOWN_MODEL_ID = "unknown";
|
|
6120
6229
|
var latestSessionModel = (events) => {
|
|
6121
6230
|
let latest;
|
|
@@ -6183,7 +6292,17 @@ var createOtelHook = (deps) => {
|
|
|
6183
6292
|
if (enricher.providerId !== providerId) {
|
|
6184
6293
|
continue;
|
|
6185
6294
|
}
|
|
6186
|
-
|
|
6295
|
+
let scope;
|
|
6296
|
+
try {
|
|
6297
|
+
scope = enricher.cursorScope?.(current);
|
|
6298
|
+
} catch (thrown) {
|
|
6299
|
+
logger.warn("payload enricher failed; parsing the payload as delivered", {
|
|
6300
|
+
"enricher.id": enricher.id,
|
|
6301
|
+
"error.name": thrown instanceof Error ? thrown.name : typeof thrown
|
|
6302
|
+
});
|
|
6303
|
+
continue;
|
|
6304
|
+
}
|
|
6305
|
+
const key = readCursorKey(enricher.id, sessionId, scope);
|
|
6187
6306
|
let cursor;
|
|
6188
6307
|
try {
|
|
6189
6308
|
const record = await deps.stateStore.read(key);
|
|
@@ -6765,6 +6884,10 @@ var createOtelHook = (deps) => {
|
|
|
6765
6884
|
});
|
|
6766
6885
|
}
|
|
6767
6886
|
}
|
|
6887
|
+
batch = stampSessionContext(
|
|
6888
|
+
batch,
|
|
6889
|
+
!suppress && batch.length > 0 && deps.sessionContext !== void 0 ? await readSessionContext(deps.sessionContext, detection.providerId, identity.sessionId) : void 0
|
|
6890
|
+
);
|
|
6768
6891
|
let emitted = 0;
|
|
6769
6892
|
let exportRejected = 0;
|
|
6770
6893
|
if (!suppress && batch.length > 0) {
|
|
@@ -6880,6 +7003,13 @@ var createOtelHook = (deps) => {
|
|
|
6880
7003
|
};
|
|
6881
7004
|
return { resolveDelivery, ingest, flush, shutdown, config };
|
|
6882
7005
|
};
|
|
7006
|
+
var readSessionContext = async (reader, providerId, sessionId) => {
|
|
7007
|
+
try {
|
|
7008
|
+
return await reader.read({ providerId, sessionId });
|
|
7009
|
+
} catch {
|
|
7010
|
+
return void 0;
|
|
7011
|
+
}
|
|
7012
|
+
};
|
|
6883
7013
|
var buildErrorEvents = (diagnostics, identity, sequenceBase, ids, privacy) => {
|
|
6884
7014
|
const events = [];
|
|
6885
7015
|
for (const [index, info] of diagnostics.slice(0, MAX_ERROR_EVENTS).entries()) {
|
|
@@ -7032,11 +7162,11 @@ var createRecordingLogger = (level = "debug") => {
|
|
|
7032
7162
|
};
|
|
7033
7163
|
|
|
7034
7164
|
// src/testing/fixture-adapter.ts
|
|
7035
|
-
import { z as
|
|
7036
|
-
var syntheticPayloadSchema =
|
|
7037
|
-
provider:
|
|
7038
|
-
sessionId:
|
|
7039
|
-
event:
|
|
7165
|
+
import { z as z24 } from "zod";
|
|
7166
|
+
var syntheticPayloadSchema = z24.object({
|
|
7167
|
+
provider: z24.string().min(1),
|
|
7168
|
+
sessionId: z24.string().min(1),
|
|
7169
|
+
event: z24.enum([
|
|
7040
7170
|
"session.start",
|
|
7041
7171
|
"prompt",
|
|
7042
7172
|
"generation",
|
|
@@ -7046,15 +7176,15 @@ var syntheticPayloadSchema = z23.object({
|
|
|
7046
7176
|
"session.end",
|
|
7047
7177
|
"noop"
|
|
7048
7178
|
]),
|
|
7049
|
-
requestId:
|
|
7050
|
-
model:
|
|
7051
|
-
promptText:
|
|
7052
|
-
toolName:
|
|
7053
|
-
toolInput:
|
|
7054
|
-
workspaceKey:
|
|
7055
|
-
occurredAt:
|
|
7179
|
+
requestId: z24.string().min(1).optional(),
|
|
7180
|
+
model: z24.string().min(1).optional(),
|
|
7181
|
+
promptText: z24.string().optional(),
|
|
7182
|
+
toolName: z24.string().min(1).optional(),
|
|
7183
|
+
toolInput: z24.unknown().optional(),
|
|
7184
|
+
workspaceKey: z24.string().min(1).optional(),
|
|
7185
|
+
occurredAt: z24.number().int().min(0).optional(),
|
|
7056
7186
|
usage: usageReportSchema.optional(),
|
|
7057
|
-
agentVersion:
|
|
7187
|
+
agentVersion: z24.string().min(1).optional()
|
|
7058
7188
|
});
|
|
7059
7189
|
var SYNTHETIC_PROVIDER_ID = "fixture";
|
|
7060
7190
|
var DEFAULT_FIXTURE_CAPABILITIES = Object.freeze({
|
|
@@ -7459,7 +7589,8 @@ var createTestHook = (options = {}) => {
|
|
|
7459
7589
|
logger,
|
|
7460
7590
|
...options.worktreeLocator === void 0 ? {} : { worktreeLocator: options.worktreeLocator },
|
|
7461
7591
|
...options.targetResolutionBudgetMillis === void 0 ? {} : { targetResolutionBudgetMillis: options.targetResolutionBudgetMillis },
|
|
7462
|
-
...options.payloadEnrichers === void 0 ? {} : { payloadEnrichers: options.payloadEnrichers }
|
|
7592
|
+
...options.payloadEnrichers === void 0 ? {} : { payloadEnrichers: options.payloadEnrichers },
|
|
7593
|
+
...options.sessionContext === void 0 ? {} : { sessionContext: options.sessionContext }
|
|
7463
7594
|
});
|
|
7464
7595
|
return { hook, sink, stateStore, clock, ids, privacy, logger, registry, config };
|
|
7465
7596
|
};
|