@armoriq/sdk-dev 0.8.0 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/_build_env.d.ts +2 -1
  2. package/dist/_build_env.d.ts.map +1 -1
  3. package/dist/_build_env.js +4 -0
  4. package/dist/_build_env.js.map +1 -1
  5. package/dist/_version.d.ts +1 -1
  6. package/dist/_version.js +1 -1
  7. package/dist/cli/commands/auth.d.ts.map +1 -1
  8. package/dist/cli/commands/auth.js +68 -38
  9. package/dist/cli/commands/auth.js.map +1 -1
  10. package/dist/cli/commands/orgs.js +1 -1
  11. package/dist/cli/commands/orgs.js.map +1 -1
  12. package/dist/cli/commands/status.d.ts.map +1 -1
  13. package/dist/cli/commands/status.js +4 -3
  14. package/dist/cli/commands/status.js.map +1 -1
  15. package/dist/cli/index.d.ts.map +1 -1
  16. package/dist/cli/index.js +6 -0
  17. package/dist/cli/index.js.map +1 -1
  18. package/dist/cli/state.d.ts +3 -3
  19. package/dist/cli/state.d.ts.map +1 -1
  20. package/dist/cli/state.js +24 -12
  21. package/dist/cli/state.js.map +1 -1
  22. package/dist/client.d.ts +3 -0
  23. package/dist/client.d.ts.map +1 -1
  24. package/dist/client.js +26 -6
  25. package/dist/client.js.map +1 -1
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +2 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/token_usage.d.ts +23 -0
  31. package/dist/token_usage.d.ts.map +1 -1
  32. package/dist/token_usage.js +107 -26
  33. package/dist/token_usage.js.map +1 -1
  34. package/package.json +1 -1
  35. package/dist/observability/handle.d.ts +0 -41
  36. package/dist/observability/handle.d.ts.map +0 -1
  37. package/dist/observability/handle.js +0 -54
  38. package/dist/observability/handle.js.map +0 -1
  39. package/dist/observability/recorder.d.ts +0 -245
  40. package/dist/observability/recorder.d.ts.map +0 -1
  41. package/dist/observability/recorder.js +0 -475
  42. package/dist/observability/recorder.js.map +0 -1
  43. package/dist/observability/schema.d.ts +0 -163
  44. package/dist/observability/schema.d.ts.map +0 -1
  45. package/dist/observability/schema.js +0 -291
  46. package/dist/observability/schema.js.map +0 -1
  47. package/dist/observability/shipper.d.ts +0 -84
  48. package/dist/observability/shipper.d.ts.map +0 -1
  49. package/dist/observability/shipper.js +0 -206
  50. package/dist/observability/shipper.js.map +0 -1
  51. package/dist/observability/trace-summary.d.ts +0 -34
  52. package/dist/observability/trace-summary.d.ts.map +0 -1
  53. package/dist/observability/trace-summary.js +0 -108
  54. package/dist/observability/trace-summary.js.map +0 -1
@@ -1,475 +0,0 @@
1
- "use strict";
2
- /**
3
- * ObservabilityRecorder — in-memory ring buffer for traces + spans.
4
- *
5
- * The recorder is the only place in the SDK that mints trace/span IDs. The
6
- * session chokepoints (peer subagent's wrap) call `startTrace` /
7
- * `recordPolicyCall` / `endTrace` and the recorder takes care of:
8
- * 1. Validating each emit (cheap shape checks; bad data is logged + dropped,
9
- * never thrown into the SDK consumer).
10
- * 2. Minting IDs and computing endTime/durationMs.
11
- * 3. Holding the in-memory ring buffer (default 1000 traces). On overflow,
12
- * the oldest trace AND all its spans are dropped (we never want a partial
13
- * trace at the backend).
14
- * 4. Pushing ended traces onto the shipper's queue.
15
- * 5. Forwarding every emit to the test sink (if set) so tests can assert
16
- * on the exact lifecycle.
17
- *
18
- * Per plan §9 Q3: in-memory only. `durable: true` is parsed and stored but
19
- * does nothing in v1 — a one-time warning is logged the first time a
20
- * consumer opts in.
21
- */
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.ObservabilityRecorder = void 0;
24
- exports.__setObservabilitySinkForTests = __setObservabilitySinkForTests;
25
- const shipper_1 = require("./shipper");
26
- const schema_1 = require("./schema");
27
- const model_prices_1 = require("./model-prices");
28
- const trace_summary_1 = require("./trace-summary");
29
- const DEFAULT_MAX_BUFFER = 1000;
30
- const DEFAULT_FLUSH_INTERVAL_MS = 5000;
31
- const DEFAULT_BATCH_SIZE = 100;
32
- let currentSink = null;
33
- function __setObservabilitySinkForTests(sink) {
34
- currentSink = sink;
35
- }
36
- function notifySink(event) {
37
- if (currentSink) {
38
- try {
39
- currentSink(event);
40
- }
41
- catch (e) {
42
- // A throwing sink is a test bug. Log and continue — never let test
43
- // plumbing break the SDK consumer.
44
- // eslint-disable-next-line no-console
45
- console.warn(`[observability] test sink threw: ${e?.message ?? e}`);
46
- }
47
- }
48
- }
49
- let durableWarned = false;
50
- // ─── Recorder ─────────────────────────────────────────────────────────────
51
- class ObservabilityRecorder {
52
- enabled;
53
- product;
54
- userId;
55
- agentId;
56
- defaultSessionId;
57
- maxBufferSize;
58
- onSpan;
59
- buffer = [];
60
- bufferIndex = new Map();
61
- shipper;
62
- warnedDurable = false;
63
- constructor(config) {
64
- this.enabled = config.enabled !== false;
65
- this.product = config.product;
66
- this.userId = config.userId ?? null;
67
- this.agentId = config.agentId ?? null;
68
- this.defaultSessionId = config.sessionId ?? null;
69
- this.maxBufferSize = config.maxBufferSize ?? DEFAULT_MAX_BUFFER;
70
- this.onSpan = config.onSpan;
71
- if (config.durable && !durableWarned) {
72
- durableWarned = true;
73
- this.warnedDurable = true;
74
- // eslint-disable-next-line no-console
75
- console.warn('[observability] durable=true is parsed but not implemented in v1; ' +
76
- 'spans are held in memory only and lost on process exit');
77
- }
78
- this.shipper = new shipper_1.ObservabilityShipper({
79
- endpoint: config.endpoint,
80
- apiKey: config.apiKey,
81
- product: this.product,
82
- sessionId: this.defaultSessionId,
83
- batchSize: config.batchSize ?? DEFAULT_BATCH_SIZE,
84
- flushIntervalMs: config.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS,
85
- httpClient: config.httpClient,
86
- });
87
- if (this.enabled) {
88
- this.shipper.start();
89
- }
90
- }
91
- /** Internal accessor for tests; not part of the public API. */
92
- get __shipper() {
93
- return this.shipper;
94
- }
95
- /** True when the consumer passed `enabled: true` (the default). */
96
- get isEnabled() {
97
- return this.enabled;
98
- }
99
- // ─── Trace lifecycle ──────────────────────────────────────────────────
100
- /**
101
- * Mint a new trace and return its context. The trace is added to the
102
- * in-memory buffer (dropping the oldest if at capacity) and the context
103
- * is passed to subsequent `recordSpan` / `endTrace` calls.
104
- */
105
- startTrace(name, attributes, sessionId) {
106
- // Explicit `sessionId` (even explicit `null`) wins; otherwise fall back
107
- // to the recorder's default (the owning ArmorIQSession's stable UUID
108
- // session id). This is the single chokepoint that stamps sessionId onto
109
- // every trace uniformly, including callers (e.g. summarizeTranscriptUsage)
110
- // that don't pass one at all.
111
- const resolvedSessionId = sessionId !== undefined ? sessionId : this.defaultSessionId;
112
- if (!this.enabled) {
113
- // Return a no-op context. recordSpan/endTrace will be no-ops.
114
- return {
115
- traceId: (0, schema_1.mintId)(),
116
- sessionId: resolvedSessionId,
117
- name,
118
- startTimeMs: Date.now(),
119
- attributes: attributes ?? {},
120
- };
121
- }
122
- const traceId = (0, schema_1.mintId)();
123
- const startTimeMs = Date.now();
124
- const trace = {
125
- id: traceId,
126
- sessionId: resolvedSessionId,
127
- name,
128
- startTime: new Date(startTimeMs).toISOString(),
129
- endTime: null,
130
- durationMs: null,
131
- status: 'ok',
132
- userId: this.userId,
133
- agentId: this.agentId,
134
- attributes: attributes ?? {},
135
- tags: [],
136
- };
137
- this.appendToBuffer({ trace, spans: [] });
138
- notifySink({ kind: 'trace_started', trace, sessionId: trace.sessionId });
139
- return {
140
- traceId,
141
- sessionId: trace.sessionId,
142
- name,
143
- startTimeMs,
144
- attributes: trace.attributes,
145
- };
146
- }
147
- /**
148
- * Append a span to an existing trace. The span is validated against the
149
- * wire schema; an invalid span is logged and dropped (never thrown).
150
- */
151
- recordSpan(ctx, span) {
152
- if (!this.enabled)
153
- return;
154
- if (!(0, schema_1.isValidSpanRecord)(span)) {
155
- const spanAny = span;
156
- const kindLabel = spanAny?.kind ?? 'unknown';
157
- // eslint-disable-next-line no-console
158
- console.warn(`[observability] dropping invalid span (kind=${String(kindLabel)}, trace=${ctx.traceId})`);
159
- return;
160
- }
161
- const entry = this.bufferIndex.get(ctx.traceId);
162
- if (!entry) {
163
- // eslint-disable-next-line no-console
164
- console.warn(`[observability] recordSpan called for unknown traceId=${ctx.traceId}; dropping span`);
165
- return;
166
- }
167
- entry.spans.push(span);
168
- if (this.onSpan) {
169
- try {
170
- this.onSpan(span);
171
- }
172
- catch (e) {
173
- // eslint-disable-next-line no-console
174
- console.warn(`[observability] onSpan hook threw: ${e?.message ?? e}`);
175
- }
176
- }
177
- notifySink({
178
- kind: 'span_recorded',
179
- traceId: ctx.traceId,
180
- traceSessionId: entry.trace.sessionId,
181
- span,
182
- });
183
- }
184
- /**
185
- * Construct a `kind: 'policy_call'` span from the supplied fields and
186
- * record it under the given trace. Returns the constructed span (useful
187
- * for tests); otherwise the return value can be ignored.
188
- */
189
- recordPolicyCall(ctx, attrs, parentSpanId) {
190
- const span = {
191
- id: (0, schema_1.mintId)(),
192
- parentSpanId: parentSpanId ?? null,
193
- sessionId: ctx.sessionId,
194
- kind: 'policy_call',
195
- name: `${attrs.policyName ?? attrs.policyId ?? 'policy'}.${attrs.decision}`,
196
- startTime: new Date().toISOString(),
197
- endTime: new Date().toISOString(),
198
- durationMs: attrs.durationMs != null && Number.isFinite(attrs.durationMs)
199
- ? Math.round(attrs.durationMs)
200
- : 0,
201
- status: attrs.decision === 'allow' ? 'ok' : 'denied',
202
- attributes: {
203
- kind: 'policy_call',
204
- policyId: attrs.policyId,
205
- policyName: attrs.policyName,
206
- policyHash: attrs.policyHash ?? null,
207
- policyVersion: attrs.policyVersion ?? null,
208
- decision: attrs.decision,
209
- matchedRuleId: attrs.matchedRuleId ?? null,
210
- dataClasses: attrs.dataClasses ?? [],
211
- reason: attrs.reason,
212
- input: attrs.input,
213
- output: attrs.output,
214
- source: attrs.source,
215
- enforcementAction: attrs.enforcementAction ?? null,
216
- obligations: attrs.obligations ?? null,
217
- delegationId: attrs.delegationId ?? null,
218
- },
219
- };
220
- this.recordSpan(ctx, span);
221
- return span;
222
- }
223
- /**
224
- * Construct a `kind: 'generation'` span from the supplied fields,
225
- * compute `costUsd` from the static price table, and record it.
226
- * Unknown models yield costUsd=0 (the span is still recorded).
227
- * Pass `costUsd` to override the computed value (e.g. when the caller
228
- * already has a precomputed cost from a third-party billing system).
229
- */
230
- recordGeneration(ctx, attrs, parentSpanId) {
231
- const cost = attrs.costUsd ??
232
- (0, model_prices_1.computeCostUsd)(attrs.model, attrs.inputTokens, attrs.outputTokens, attrs.cacheReadTokens ?? 0, attrs.cacheWriteTokens ?? 0);
233
- const span = {
234
- id: (0, schema_1.mintId)(),
235
- parentSpanId: parentSpanId ?? null,
236
- sessionId: ctx.sessionId,
237
- kind: 'generation',
238
- name: `generation.${attrs.model}`,
239
- startTime: new Date().toISOString(),
240
- endTime: new Date().toISOString(),
241
- durationMs: 0,
242
- status: 'ok',
243
- attributes: {
244
- kind: 'generation',
245
- model: attrs.model,
246
- inputTokens: attrs.inputTokens,
247
- outputTokens: attrs.outputTokens,
248
- cacheReadTokens: attrs.cacheReadTokens ?? null,
249
- cacheWriteTokens: attrs.cacheWriteTokens ?? null,
250
- costUsd: cost,
251
- prompt: attrs.prompt ?? null,
252
- completion: attrs.completion ?? null,
253
- finishReason: attrs.finishReason ?? null,
254
- },
255
- };
256
- this.recordSpan(ctx, span);
257
- return span;
258
- }
259
- /**
260
- * Record a `kind: 'event'` span — a point-in-time annotation (e.g.
261
- * "plan growth", "approval polled"). Use sparingly; events are cheap
262
- * but they still count toward the ring buffer.
263
- */
264
- recordEvent(ctx, attrs, parentSpanId) {
265
- const span = {
266
- id: (0, schema_1.mintId)(),
267
- parentSpanId: parentSpanId ?? null,
268
- sessionId: ctx.sessionId,
269
- kind: 'event',
270
- name: attrs.message.slice(0, 120),
271
- startTime: new Date().toISOString(),
272
- endTime: new Date().toISOString(),
273
- durationMs: 0,
274
- status: 'ok',
275
- attributes: {
276
- kind: 'event',
277
- message: attrs.message,
278
- level: attrs.level ?? 'info',
279
- },
280
- };
281
- this.recordSpan(ctx, span);
282
- return span;
283
- }
284
- /**
285
- * Mint + record a `kind: 'span'` CONTAINER span — a nesting point that
286
- * groups the child spans emitted by one chokepoint (e.g. `iap.enforce.local`)
287
- * under the session's single active plan trace (Model A: trace-per-plan).
288
- *
289
- * The container starts open (`status: 'ok'`, `endTime: null`,
290
- * `durationMs: null`) and MUST be finalized with `closeSpan()` once the
291
- * chokepoint's work completes (success or error). A container span with a
292
- * null `endTime` is intentionally valid mid-flight — see
293
- * `isValidGenericSpanAttributes`/`isValidSpanRecord`, which permit a
294
- * null `endTime`/`durationMs` for exactly this reason (Task 1 risk #1).
295
- *
296
- * Returns the minted span id — even when the recorder is disabled, so
297
- * call sites can pass it along unconditionally as a `parentSpanId` to
298
- * `recordPolicyCall`/`recordGeneration`/`recordEvent` without special-casing
299
- * the disabled path.
300
- */
301
- openSpan(ctx, opts) {
302
- const id = (0, schema_1.mintId)();
303
- if (!this.enabled)
304
- return id;
305
- const span = {
306
- id,
307
- parentSpanId: opts.parentSpanId ?? null,
308
- sessionId: ctx.sessionId,
309
- kind: 'span',
310
- name: opts.name,
311
- startTime: new Date().toISOString(),
312
- endTime: null,
313
- durationMs: null,
314
- status: 'ok',
315
- attributes: { kind: 'span', ...(opts.attributes ?? {}) },
316
- };
317
- this.recordSpan(ctx, span);
318
- return id;
319
- }
320
- /**
321
- * Finalize a container span previously opened with `openSpan()`: sets
322
- * `endTime`, optionally `durationMs`/`status`/`attributes.errorMessage`.
323
- * No-op (never throws) when the recorder is disabled, the trace is
324
- * unknown, or the spanId doesn't match a buffered span (e.g. it already
325
- * shipped) — mirrors `endTrace`'s defensive lookup.
326
- */
327
- closeSpan(ctx, spanId, opts) {
328
- if (!this.enabled)
329
- return;
330
- const entry = this.bufferIndex.get(ctx.traceId);
331
- if (!entry)
332
- return;
333
- const span = entry.spans.find((s) => s.id === spanId);
334
- if (!span)
335
- return;
336
- span.endTime = new Date().toISOString();
337
- if (opts?.durationMs != null && Number.isFinite(opts.durationMs)) {
338
- span.durationMs = Math.round(opts.durationMs);
339
- }
340
- if (opts?.status)
341
- span.status = opts.status;
342
- if (opts?.errorMessage !== undefined) {
343
- span.attributes = { ...span.attributes, errorMessage: opts.errorMessage };
344
- }
345
- }
346
- /**
347
- * Finalize a trace: set endTime, compute durationMs, apply optional
348
- * status / errorMessage. Pushes the (trace, spans) batch to the
349
- * shipper's queue, then REMOVES the entry from the in-memory ring buffer
350
- * — once a trace has been handed to the shipper, the shipper's own queue
351
- * is the durable record; keeping a second copy in the ring buffer would
352
- * let ended/shipped traces occupy buffer slots until overflow/flush,
353
- * needlessly evicting still-in-flight traces sooner. No-op when disabled
354
- * or when the trace is unknown.
355
- */
356
- endTrace(ctx, opts) {
357
- if (!this.enabled)
358
- return;
359
- const entry = this.bufferIndex.get(ctx.traceId);
360
- if (!entry) {
361
- // eslint-disable-next-line no-console
362
- console.warn(`[observability] endTrace called for unknown traceId=${ctx.traceId}; dropping`);
363
- return;
364
- }
365
- const endMs = Date.now();
366
- const durationMs = endMs - ctx.startTimeMs;
367
- const finalStatus = opts?.status ?? 'ok';
368
- const attributesWithError = opts?.errorMessage !== undefined
369
- ? { ...entry.trace.attributes, errorMessage: opts.errorMessage }
370
- : entry.trace.attributes;
371
- // Derive dashboard tags + an output summary from the trace's own spans
372
- // (policy_call decisions, tool names) — this is the one place every
373
- // trace passes through before shipping, so it's the natural chokepoint
374
- // to fill in `tags`/`attributes.output` for callers that never set them
375
- // explicitly. A caller-supplied non-empty `tags` array or an explicit
376
- // `attributes.output` always wins; this only fills genuine gaps.
377
- const summary = (0, trace_summary_1.deriveTraceSummary)(entry.spans, this.product);
378
- const updated = {
379
- ...entry.trace,
380
- endTime: new Date(endMs).toISOString(),
381
- durationMs,
382
- status: finalStatus,
383
- tags: entry.trace.tags.length > 0 ? entry.trace.tags : summary.tags,
384
- attributes: attributesWithError.output !== undefined || summary.output === null
385
- ? attributesWithError
386
- : { ...attributesWithError, output: summary.output },
387
- };
388
- // Enqueue the ended batch on the shipper — this is now the durable
389
- // record of the trace.
390
- this.shipper.enqueue({
391
- trace: updated,
392
- spans: entry.spans.slice(),
393
- });
394
- // Remove the entry from the ring buffer; it no longer needs to occupy a
395
- // buffer slot now that the shipper owns it.
396
- const idx = this.buffer.indexOf(entry);
397
- if (idx >= 0)
398
- this.buffer.splice(idx, 1);
399
- this.bufferIndex.delete(ctx.traceId);
400
- notifySink({
401
- kind: 'trace_ended',
402
- trace: updated,
403
- spans: entry.spans.slice(),
404
- });
405
- }
406
- // ─── Buffer management ────────────────────────────────────────────────
407
- /**
408
- * Drain the in-memory buffer. Returns a readonly array of the current
409
- * (trace, spans) pairs. The buffer is NOT cleared by this call — that
410
- * is `flush()`'s job. `drain()` is for inspection (tests, debugging).
411
- *
412
- * Note: since `endTrace()` removes entries once they're handed to the
413
- * shipper (see #8), `drain()` only ever reflects traces that are still
414
- * in-flight (started but not yet ended).
415
- */
416
- drain() {
417
- return this.buffer.map((e) => ({ trace: e.trace, spans: e.spans.slice() }));
418
- }
419
- /**
420
- * POST any queued (ended) batches via the shipper. Returns the shipper's
421
- * accepted/rejected counts. NEVER throws — observability failures must
422
- * not break the SDK consumer.
423
- *
424
- * Only ended traces (`trace.endTime !== null`) are ever handed to the
425
- * shipper (see `endTrace()`); in-flight (un-ended) traces stay in the
426
- * in-memory ring buffer untouched — flushing must never drop a trace
427
- * that's still being built. As an extra safety net (in case some future
428
- * caller enqueues directly), any buffer entries whose trace happens to
429
- * already carry an `endTime` are also handed to the shipper and removed
430
- * here; anything without an `endTime` is left alone and a warning is
431
- * logged with the retained count.
432
- */
433
- async flush() {
434
- if (!this.enabled)
435
- return { accepted: 0, rejected: 0 };
436
- const ended = this.buffer.filter((e) => e.trace.endTime !== null);
437
- if (ended.length > 0) {
438
- for (const entry of ended) {
439
- this.shipper.enqueue({ trace: entry.trace, spans: entry.spans.slice() });
440
- const idx = this.buffer.indexOf(entry);
441
- if (idx >= 0)
442
- this.buffer.splice(idx, 1);
443
- this.bufferIndex.delete(entry.trace.id);
444
- }
445
- }
446
- const inFlightCount = this.buffer.length;
447
- if (inFlightCount > 0) {
448
- // eslint-disable-next-line no-console
449
- console.warn(`[observability] flush() retained ${inFlightCount} in-flight (un-ended) trace(s) in the buffer`);
450
- }
451
- return this.shipper.flush();
452
- }
453
- /**
454
- * Stop the underlying shipper (clears the periodic interval + final
455
- * flush). Call on session close. Safe to call multiple times.
456
- */
457
- async stop() {
458
- await this.shipper.stop();
459
- }
460
- // ─── Internals ────────────────────────────────────────────────────────
461
- appendToBuffer(entry) {
462
- this.buffer.push(entry);
463
- this.bufferIndex.set(entry.trace.id, entry);
464
- if (this.buffer.length > this.maxBufferSize) {
465
- const dropped = this.buffer.shift();
466
- if (dropped) {
467
- this.bufferIndex.delete(dropped.trace.id);
468
- // eslint-disable-next-line no-console
469
- console.warn(`[observability] ring buffer full (max=${this.maxBufferSize}); dropped trace=${dropped.trace.id}`);
470
- }
471
- }
472
- }
473
- }
474
- exports.ObservabilityRecorder = ObservabilityRecorder;
475
- //# sourceMappingURL=recorder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"recorder.js","sourceRoot":"","sources":["../../src/observability/recorder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AA2FH,wEAIC;AA5FD,uCAAiD;AACjD,qCAUkB;AAClB,iDAAgD;AAChD,mDAAqD;AA+CrD,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AACvC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAwB/B,IAAI,WAAW,GAA6B,IAAI,CAAC;AAEjD,SAAgB,8BAA8B,CAC5C,IAA8B;IAE9B,WAAW,GAAG,IAAI,CAAC;AACrB,CAAC;AAED,SAAS,UAAU,CAAC,KAAgB;IAClC,IAAI,WAAW,EAAE,CAAC;QAChB,IAAI,CAAC;YACH,WAAW,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,C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3
- *
4
- * The contract mirrors `conmap-auto/src/observability/schema.ts` (zod on the
5
- * backend). The SDK cannot use zod (per plan §9 Q1) — adding it would balloon
6
- * the bundle for a small, stable shape. The backend's zod parser is the
7
- * safety net at the ingest boundary; if the wire shape ever drifts, the
8
- * backend rejects the bad batch and the SDK's no-throw invariant swallows
9
- * the warning.
10
- *
11
- * The validators below are deliberately cheap (typeof, structural) — they
12
- * run on every emitted span and must not become a hot-path cost.
13
- */
14
- export type SpanStatus = 'ok' | 'error' | 'denied';
15
- export type SpanKind = 'span' | 'policy_call' | 'generation' | 'event';
16
- export type PolicyDecision = 'allow' | 'deny' | 'hold' | 'ask';
17
- export type PolicySource = 'native' | 'sdk-local' | 'sdk' | 'proxy' | 'opa' | 'opa_fallback';
18
- export type PolicyEnforcementAction = 'allow' | 'allow_log' | 'hold' | 'block';
19
- /** Short alias for consumers who don't need the Policy prefix. */
20
- export type EnforcementAction = PolicyEnforcementAction;
21
- export type EventLevel = 'info' | 'warn' | 'error';
22
- /**
23
- * Each attribute shape permits an open index signature so SDK callers can
24
- * attach side-channel metadata (e.g. trustId, delegationId) without
25
- * re-shaping the wire contract. The runtime validator only enforces the
26
- * documented fields; extras are passed through and the backend's strict
27
- * zod is the ultimate gatekeeper at the ingest boundary.
28
- */
29
- /** kind: 'span' — generic sub-operation (tool execution, delegation, etc.) */
30
- export interface GenericSpanAttributes {
31
- kind: 'span';
32
- toolName?: string;
33
- toolInput?: unknown;
34
- toolOutput?: unknown;
35
- errorMessage?: string;
36
- [key: string]: unknown;
37
- }
38
- /** kind: 'policy_call' — a policy evaluation result */
39
- export interface PolicyCallAttributes {
40
- kind: 'policy_call';
41
- policyId: string | null;
42
- policyName: string | null;
43
- policyHash: string | null;
44
- policyVersion: string | null;
45
- decision: PolicyDecision;
46
- matchedRuleId: string | null;
47
- dataClasses: string[];
48
- reason: string | null;
49
- input: unknown;
50
- output: unknown;
51
- source: PolicySource;
52
- enforcementAction: PolicyEnforcementAction | null;
53
- obligations: unknown;
54
- delegationId: string | null;
55
- [key: string]: unknown;
56
- }
57
- /** kind: 'generation' — an LLM call (records token usage + cost) */
58
- export interface GenerationAttributes {
59
- kind: 'generation';
60
- model: string;
61
- inputTokens: number;
62
- outputTokens: number;
63
- cacheReadTokens: number | null;
64
- cacheWriteTokens: number | null;
65
- costUsd: number;
66
- prompt: string | null;
67
- completion: string | null;
68
- finishReason: string | null;
69
- [key: string]: unknown;
70
- }
71
- /** kind: 'event' — a point-in-time annotation */
72
- export interface EventAttributes {
73
- kind: 'event';
74
- message: string;
75
- level: EventLevel;
76
- [key: string]: unknown;
77
- }
78
- export type SpanAttributes = GenericSpanAttributes | PolicyCallAttributes | GenerationAttributes | EventAttributes;
79
- /** A Trace = the top-level observation of a logical unit of work. */
80
- export interface TraceRecord {
81
- id: string;
82
- sessionId: string | null;
83
- name: string;
84
- startTime: string;
85
- endTime: string | null;
86
- durationMs: number | null;
87
- status: SpanStatus;
88
- userId: string | null;
89
- agentId: string | null;
90
- attributes: Record<string, unknown>;
91
- tags: string[];
92
- }
93
- /** A Span = a child of a trace, with a kind-discriminated attributes shape. */
94
- export interface SpanRecord {
95
- id: string;
96
- parentSpanId: string | null;
97
- sessionId: string | null;
98
- kind: SpanKind;
99
- name: string;
100
- startTime: string;
101
- endTime: string | null;
102
- durationMs: number | null;
103
- status: SpanStatus;
104
- attributes: SpanAttributes;
105
- }
106
- /**
107
- * A Session is the parent grouping (one IAP plan). Backend returns this
108
- * shape from its read API — FLAT token fields, not nested. Mirrors
109
- * `conmap-auto/src/observability/schema.ts` `SessionRecord`
110
- * (totalInputTokens/totalOutputTokens/totalCacheReadTokens/totalCacheWriteTokens).
111
- */
112
- export interface SessionRecord {
113
- id: string;
114
- orgId: string;
115
- userId: string | null;
116
- agentId: string | null;
117
- product: string | null;
118
- startedAt: string;
119
- lastActivityAt: string;
120
- traceCount: number;
121
- totalInputTokens: number;
122
- totalOutputTokens: number;
123
- totalCacheReadTokens: number;
124
- totalCacheWriteTokens: number;
125
- totalCostUsd: number;
126
- status: 'active' | 'completed' | 'expired' | 'error';
127
- }
128
- /** One trace + its child spans, packaged for ingest. */
129
- export interface IngestBatch {
130
- trace: TraceRecord;
131
- spans: SpanRecord[];
132
- }
133
- /** Top-level ingest body. orgId is resolved by the backend from the API key. */
134
- export interface IngestPayload {
135
- product: string;
136
- sessionId: string | null;
137
- batches: IngestBatch[];
138
- }
139
- export interface TraceContext {
140
- traceId: string;
141
- sessionId: string | null;
142
- name: string;
143
- startTimeMs: number;
144
- attributes: Record<string, unknown>;
145
- }
146
- export declare function isValidSpanStatus(x: unknown): x is SpanStatus;
147
- export declare function isValidSpanKind(x: unknown): x is SpanKind;
148
- export declare function isValidPolicyDecision(x: unknown): x is PolicyDecision;
149
- export declare function isValidPolicySource(x: unknown): x is PolicySource;
150
- export declare function isValidPolicyEnforcementAction(x: unknown): x is PolicyEnforcementAction;
151
- export declare function isValidEventLevel(x: unknown): x is EventLevel;
152
- export declare function isValidGenericSpanAttributes(x: unknown): x is GenericSpanAttributes;
153
- export declare function isValidPolicyCallAttributes(x: unknown): x is PolicyCallAttributes;
154
- export declare function isValidGenerationAttributes(x: unknown): x is GenerationAttributes;
155
- export declare function isValidEventAttributes(x: unknown): x is EventAttributes;
156
- export declare function isValidSpanAttributes(x: unknown): x is SpanAttributes;
157
- export declare function isValidTraceRecord(x: unknown): x is TraceRecord;
158
- export declare function isValidSpanRecord(x: unknown): x is SpanRecord;
159
- export declare function isValidIngestBatch(x: unknown): x is IngestBatch;
160
- export declare function isValidIngestPayload(x: unknown): x is IngestPayload;
161
- export declare function mintId(): string;
162
- export declare function isValidUuid(x: unknown): x is string;
163
- //# sourceMappingURL=schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/observability/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,OAAO,GAAG,QAAQ,CAAC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