dsh-observe 0.1.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.
Files changed (92) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +201 -0
  3. package/README.es.md +198 -0
  4. package/README.hi.md +198 -0
  5. package/README.md +198 -0
  6. package/README.pt.md +198 -0
  7. package/README.zh.md +198 -0
  8. package/THIRD_PARTY_NOTICES.md +21 -0
  9. package/cordis.patch.yml +86 -0
  10. package/lib/index.js +1947 -0
  11. package/lib/typert.host.js +109 -0
  12. package/lib/types/backoff.d.ts +17 -0
  13. package/lib/types/backoff.d.ts.map +1 -0
  14. package/lib/types/backoff.js +17 -0
  15. package/lib/types/backoff.js.map +1 -0
  16. package/lib/types/collector.d.ts +83 -0
  17. package/lib/types/collector.d.ts.map +1 -0
  18. package/lib/types/collector.js +506 -0
  19. package/lib/types/collector.js.map +1 -0
  20. package/lib/types/config.d.ts +286 -0
  21. package/lib/types/config.d.ts.map +1 -0
  22. package/lib/types/config.js +312 -0
  23. package/lib/types/config.js.map +1 -0
  24. package/lib/types/ids.d.ts +43 -0
  25. package/lib/types/ids.d.ts.map +1 -0
  26. package/lib/types/ids.js +63 -0
  27. package/lib/types/ids.js.map +1 -0
  28. package/lib/types/index.d.ts +35 -0
  29. package/lib/types/index.d.ts.map +1 -0
  30. package/lib/types/index.js +162 -0
  31. package/lib/types/index.js.map +1 -0
  32. package/lib/types/model.d.ts +89 -0
  33. package/lib/types/model.d.ts.map +1 -0
  34. package/lib/types/model.js +25 -0
  35. package/lib/types/model.js.map +1 -0
  36. package/lib/types/pipeline.d.ts +71 -0
  37. package/lib/types/pipeline.d.ts.map +1 -0
  38. package/lib/types/pipeline.js +193 -0
  39. package/lib/types/pipeline.js.map +1 -0
  40. package/lib/types/pricing.d.ts +34 -0
  41. package/lib/types/pricing.d.ts.map +1 -0
  42. package/lib/types/pricing.js +45 -0
  43. package/lib/types/pricing.js.map +1 -0
  44. package/lib/types/project.d.ts +26 -0
  45. package/lib/types/project.d.ts.map +1 -0
  46. package/lib/types/project.js +52 -0
  47. package/lib/types/project.js.map +1 -0
  48. package/lib/types/remote.d.ts +28 -0
  49. package/lib/types/remote.d.ts.map +1 -0
  50. package/lib/types/remote.js +45 -0
  51. package/lib/types/remote.js.map +1 -0
  52. package/lib/types/sanitize.d.ts +78 -0
  53. package/lib/types/sanitize.d.ts.map +1 -0
  54. package/lib/types/sanitize.js +132 -0
  55. package/lib/types/sanitize.js.map +1 -0
  56. package/lib/types/sinks.d.ts +84 -0
  57. package/lib/types/sinks.d.ts.map +1 -0
  58. package/lib/types/sinks.js +434 -0
  59. package/lib/types/sinks.js.map +1 -0
  60. package/lib/types/spool.d.ts +113 -0
  61. package/lib/types/spool.d.ts.map +1 -0
  62. package/lib/types/spool.js +167 -0
  63. package/lib/types/spool.js.map +1 -0
  64. package/lib/types/typert.host.d.ts +93 -0
  65. package/lib/types/typert.host.d.ts.map +1 -0
  66. package/lib/types/typert.host.js +23 -0
  67. package/lib/types/typert.host.js.map +1 -0
  68. package/lib/types/version.d.ts +10 -0
  69. package/lib/types/version.d.ts.map +1 -0
  70. package/lib/types/version.js +10 -0
  71. package/lib/types/version.js.map +1 -0
  72. package/lib/types/wire.d.ts +206 -0
  73. package/lib/types/wire.d.ts.map +1 -0
  74. package/lib/types/wire.js +71 -0
  75. package/lib/types/wire.js.map +1 -0
  76. package/package.json +147 -0
  77. package/src/backoff.ts +20 -0
  78. package/src/collector.ts +561 -0
  79. package/src/config.ts +604 -0
  80. package/src/ids.ts +68 -0
  81. package/src/index.ts +186 -0
  82. package/src/model.ts +100 -0
  83. package/src/pipeline.ts +205 -0
  84. package/src/pricing.ts +55 -0
  85. package/src/project.ts +55 -0
  86. package/src/remote.ts +56 -0
  87. package/src/sanitize.ts +132 -0
  88. package/src/sinks.ts +471 -0
  89. package/src/spool.ts +196 -0
  90. package/src/typert.host.ts +24 -0
  91. package/src/version.ts +10 -0
  92. package/src/wire.ts +97 -0
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Deterministic span and trace ids. Ids are SHA-256 digests of the session
3
+ * identity plus structural keys, truncated to the widths each backend
4
+ * requires (OTel: 16-byte trace ids / 8-byte span ids; Langfuse: 32-hex
5
+ * observation and trace ids). Determinism is a feature: replaying the same
6
+ * session log produces the same ids, so backends deduplicate re-exports
7
+ * instead of double-counting.
8
+ * @module dsh-observe/ids
9
+ */
10
+ /**
11
+ * Digest joined structural parts to a fixed hex string.
12
+ * @param parts - the structural identity parts.
13
+ * @param bytes - digest length in bytes.
14
+ * @returns lowercase hex, `bytes * 2` characters.
15
+ */
16
+ export declare function digest(parts: readonly (string | number)[], bytes: number): string;
17
+ /**
18
+ * OTel trace id for one session turn (16 bytes, 32 hex chars).
19
+ * @param sessionId - the session identity.
20
+ * @param turn - the turn number.
21
+ * @returns the trace id.
22
+ */
23
+ export declare function otelTraceId(sessionId: string, turn: number): string;
24
+ /**
25
+ * OTel span id for one span (8 bytes, 16 hex chars).
26
+ * @param parts - the span's structural identity.
27
+ * @returns the span id.
28
+ */
29
+ export declare function otelSpanId(...parts: readonly (string | number)[]): string;
30
+ /**
31
+ * Langfuse trace id for one session turn (32 hex chars).
32
+ * @param sessionId - the session identity.
33
+ * @param turn - the turn number.
34
+ * @returns the trace id.
35
+ */
36
+ export declare function langfuseTraceId(sessionId: string, turn: number): string;
37
+ /**
38
+ * Langfuse observation or event id (32 hex chars).
39
+ * @param parts - the observation's structural identity.
40
+ * @returns the id.
41
+ */
42
+ export declare function langfuseId(...parts: readonly (string | number)[]): string;
43
+ //# sourceMappingURL=ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../src/ids.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAWjF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,KAAK,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,MAAM,CAEzE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,KAAK,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,MAAM,CAEzE"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Deterministic span and trace ids. Ids are SHA-256 digests of the session
3
+ * identity plus structural keys, truncated to the widths each backend
4
+ * requires (OTel: 16-byte trace ids / 8-byte span ids; Langfuse: 32-hex
5
+ * observation and trace ids). Determinism is a feature: replaying the same
6
+ * session log produces the same ids, so backends deduplicate re-exports
7
+ * instead of double-counting.
8
+ * @module dsh-observe/ids
9
+ */
10
+ import { createHash } from 'node:crypto';
11
+ /**
12
+ * Digest joined structural parts to a fixed hex string.
13
+ * @param parts - the structural identity parts.
14
+ * @param bytes - digest length in bytes.
15
+ * @returns lowercase hex, `bytes * 2` characters.
16
+ */
17
+ export function digest(parts, bytes) {
18
+ const hash = createHash('sha256');
19
+ for (const part of parts) {
20
+ hash.update('|');
21
+ // The runtime type rides the digest: structural parts `1` (number) and
22
+ // `'1'` (string) must never collide into one id.
23
+ hash.update(typeof part);
24
+ hash.update('=');
25
+ hash.update(String(part));
26
+ }
27
+ return hash.digest('hex').slice(0, bytes * 2);
28
+ }
29
+ /**
30
+ * OTel trace id for one session turn (16 bytes, 32 hex chars).
31
+ * @param sessionId - the session identity.
32
+ * @param turn - the turn number.
33
+ * @returns the trace id.
34
+ */
35
+ export function otelTraceId(sessionId, turn) {
36
+ return digest(['trace', sessionId, turn], 16);
37
+ }
38
+ /**
39
+ * OTel span id for one span (8 bytes, 16 hex chars).
40
+ * @param parts - the span's structural identity.
41
+ * @returns the span id.
42
+ */
43
+ export function otelSpanId(...parts) {
44
+ return digest(['span', ...parts], 8);
45
+ }
46
+ /**
47
+ * Langfuse trace id for one session turn (32 hex chars).
48
+ * @param sessionId - the session identity.
49
+ * @param turn - the turn number.
50
+ * @returns the trace id.
51
+ */
52
+ export function langfuseTraceId(sessionId, turn) {
53
+ return digest(['langfuse-trace', sessionId, turn], 16);
54
+ }
55
+ /**
56
+ * Langfuse observation or event id (32 hex chars).
57
+ * @param parts - the observation's structural identity.
58
+ * @returns the id.
59
+ */
60
+ export function langfuseId(...parts) {
61
+ return digest(['langfuse', ...parts], 16);
62
+ }
63
+ //# sourceMappingURL=ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.js","sourceRoot":"","sources":["../../src/ids.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,KAAmC,EAAE,KAAa;IACvE,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;IACjC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAChB,uEAAuE;QACvE,iDAAiD;QACjD,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,CAAA;QACxB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAChB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IAC3B,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAA;AAC/C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,SAAiB,EAAE,IAAY;IACzD,OAAO,MAAM,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,KAAmC;IAC/D,OAAO,MAAM,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAA;AACtC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,SAAiB,EAAE,IAAY;IAC7D,OAAO,MAAM,CAAC,CAAC,gBAAgB,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,KAAmC;IAC/D,OAAO,MAAM,CAAC,CAAC,UAAU,EAAE,GAAG,KAAK,CAAC,EAAE,EAAE,CAAC,CAAA;AAC3C,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * `dsh-observe` — the observability exporter for DeepSeek Harness: turns
3
+ * the `session/event` stream into OTLP/HTTP traces + metrics and Langfuse
4
+ * observations. Turn/step lifecycle spans, tool-call spans (duration,
5
+ * status, derived retries), LLM generation spans with sanitized
6
+ * prompt/completion, and per-model token and cost metrics; async batching,
7
+ * a bounded durable offline buffer (storage-domain), retry with backoff,
8
+ * and a pre-send sanitization layer. Off by default — `enabled: true` plus
9
+ * at least one backend is an explicit opt-in.
10
+ *
11
+ * Function plugin — no default export (the Loader unwraps
12
+ * `exports.default ?? exports`, and a stray default would discard
13
+ * `name`/`inject`/`Config`/`apply`).
14
+ * @module dsh-observe
15
+ */
16
+ import type { Context } from '@deepseek-ai/cordis';
17
+ import { Config } from './config.ts';
18
+ export declare const name = "observe";
19
+ /** The durable offline buffer needs the host's storage-domain facility. */
20
+ export declare const inject: string[];
21
+ export { Config, resolveConfig } from './config.ts';
22
+ export type { ResolvedConfig, PricingRule, SanitizeConfig, BatchConfig, RetryConfig, OtlpConfig, LangfuseConfig } from './config.ts';
23
+ export { VERSION } from './version.ts';
24
+ export { REDACTED, sanitizeJson, sanitizeJsonText, sanitizeText, truncate } from './sanitize.ts';
25
+ export type { SpanRecord, MetricRecord, ExportRecord, TokenCounts, SpanKind } from './model.ts';
26
+ export type { ObserveStatus, ObserveSetEnabledResult } from './wire.ts';
27
+ /**
28
+ * Mount the exporter. The resolved config is validated first (fail loud);
29
+ * with `enabled: false` the plugin registers nothing and stays inert.
30
+ * @param ctx - the plugin context (host).
31
+ * @param config - raw plugin config.
32
+ * @returns resolution after the offline-buffer domain is open.
33
+ */
34
+ export declare function apply(ctx: Context, config?: Config): Promise<void>;
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,EAAE,MAAM,EAAiB,MAAM,aAAa,CAAA;AAUnD,eAAO,MAAM,IAAI,YAAY,CAAA;AAC7B,2EAA2E;AAC3E,eAAO,MAAM,MAAM,UAAoB,CAAA;AAEvC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACnD,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACpI,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAChG,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC/F,YAAY,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AAEvE;;;;;;GAMG;AACH,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CA2I5E"}
@@ -0,0 +1,162 @@
1
+ /**
2
+ * `dsh-observe` — the observability exporter for DeepSeek Harness: turns
3
+ * the `session/event` stream into OTLP/HTTP traces + metrics and Langfuse
4
+ * observations. Turn/step lifecycle spans, tool-call spans (duration,
5
+ * status, derived retries), LLM generation spans with sanitized
6
+ * prompt/completion, and per-model token and cost metrics; async batching,
7
+ * a bounded durable offline buffer (storage-domain), retry with backoff,
8
+ * and a pre-send sanitization layer. Off by default — `enabled: true` plus
9
+ * at least one backend is an explicit opt-in.
10
+ *
11
+ * Function plugin — no default export (the Loader unwraps
12
+ * `exports.default ?? exports`, and a stray default would discard
13
+ * `name`/`inject`/`Config`/`apply`).
14
+ * @module dsh-observe
15
+ */
16
+ import { resolveConfig } from "./config.js";
17
+ import { observeDomainSpec, openSpool } from "./spool.js";
18
+ import { OtlpSink, LangfuseSink } from "./sinks.js";
19
+ import { Pipeline } from "./pipeline.js";
20
+ import { Collector } from "./collector.js";
21
+ import { observeRemotePlugin } from "./remote.js";
22
+ export const name = 'observe';
23
+ /** The durable offline buffer needs the host's storage-domain facility. */
24
+ export const inject = ['storageDomain'];
25
+ export { Config, resolveConfig } from "./config.js";
26
+ export { VERSION } from "./version.js";
27
+ export { REDACTED, sanitizeJson, sanitizeJsonText, sanitizeText, truncate } from "./sanitize.js";
28
+ /**
29
+ * Mount the exporter. The resolved config is validated first (fail loud);
30
+ * with `enabled: false` the plugin registers nothing and stays inert.
31
+ * @param ctx - the plugin context (host).
32
+ * @param config - raw plugin config.
33
+ * @returns resolution after the offline-buffer domain is open.
34
+ */
35
+ export async function apply(ctx, config = {}) {
36
+ const resolved = resolveConfig(config);
37
+ const logger = ctx.logger('observe');
38
+ if (!resolved.enabled) {
39
+ logger.info('disabled: enabled is false — no session data is captured or exported');
40
+ return;
41
+ }
42
+ // The runtime kill switch, flippable through the optional Typert remote.
43
+ let enabled = true;
44
+ const isEnabled = () => enabled;
45
+ const otlpSink = resolved.otlp === undefined ? undefined : new OtlpSink(resolved.otlp, logger);
46
+ const recordMetric = (metric) => {
47
+ if (isEnabled())
48
+ otlpSink?.recordMetric(metric);
49
+ };
50
+ const domain = await ctx.storageDomain.open(observeDomainSpec);
51
+ const spool = openSpool(domain, resolved.batch.maxBufferRecords, count => recordMetric({
52
+ name: 'observe.dropped',
53
+ kind: 'counter',
54
+ unit: 'records',
55
+ value: count,
56
+ attributes: { reason: 'buffer_overflow' },
57
+ }), count => {
58
+ logger.warn(`spool: ${count} stored record(s) failed validation and were dropped`);
59
+ });
60
+ const pipelines = [];
61
+ if (otlpSink !== undefined) {
62
+ pipelines.push(new Pipeline({
63
+ name: 'otlp',
64
+ sink: otlpSink,
65
+ spool,
66
+ batch: resolved.batch,
67
+ retry: resolved.retry,
68
+ logger,
69
+ isEnabled,
70
+ onMetric: recordMetric,
71
+ }));
72
+ }
73
+ if (resolved.langfuse !== undefined) {
74
+ pipelines.push(new Pipeline({
75
+ name: 'langfuse',
76
+ sink: new LangfuseSink(resolved.langfuse, logger),
77
+ spool,
78
+ batch: resolved.batch,
79
+ retry: resolved.retry,
80
+ logger,
81
+ isEnabled,
82
+ onMetric: recordMetric,
83
+ }));
84
+ }
85
+ const onSpan = (span) => {
86
+ const record = { kind: 'span', span };
87
+ for (const pipeline of pipelines)
88
+ pipeline.push(record);
89
+ };
90
+ const collector = new Collector(resolved, () => ctx.get('tokenMeter'), onSpan, recordMetric, logger);
91
+ // One effect owns every timer and the teardown order: stop the timers,
92
+ // final-flush the pipelines (spilling failures to the durable buffer),
93
+ // then close the domain.
94
+ ctx.effect(() => {
95
+ const timers = [
96
+ setInterval(() => {
97
+ for (const pipeline of pipelines)
98
+ void pipeline.tick();
99
+ }, resolved.batch.flushIntervalMs),
100
+ setInterval(() => {
101
+ for (const pipeline of pipelines)
102
+ void pipeline.drainSpool();
103
+ }, resolved.batch.bufferRetryIntervalMs),
104
+ ...(otlpSink === undefined
105
+ ? []
106
+ : [setInterval(() => { void otlpSink.flushMetrics(); }, resolved.batch.flushIntervalMs)]),
107
+ ];
108
+ return async () => {
109
+ for (const timer of timers)
110
+ clearInterval(timer);
111
+ await Promise.all(pipelines.map(pipeline => pipeline.dispose()));
112
+ await domain.close();
113
+ };
114
+ });
115
+ ctx.on('session/event', (session, event) => {
116
+ try {
117
+ collector.handleEvent(session, event);
118
+ }
119
+ catch (error) {
120
+ logger.warn(`session "${session.id}": event handling failed: ${error instanceof Error ? error.message : String(error)}`);
121
+ }
122
+ });
123
+ // Best-effort kick: the session-flush durability checkpoint must not wait
124
+ // on a remote observability backend, so exports run in the background.
125
+ ctx.on('session/flush', () => {
126
+ for (const pipeline of pipelines)
127
+ pipeline.kick();
128
+ });
129
+ ctx.on('session/disposed', (session) => {
130
+ try {
131
+ collector.handleSessionDisposed(session);
132
+ }
133
+ catch (error) {
134
+ logger.warn(`session "${session.id}": disposal handling failed: ${error instanceof Error ? error.message : String(error)}`);
135
+ }
136
+ for (const pipeline of pipelines)
137
+ pipeline.kick();
138
+ });
139
+ if (resolved.remote) {
140
+ const depthOf = (backend) => pipelines.find(pipeline => pipeline.name === backend)?.depth ?? 0;
141
+ await ctx.plugin(observeRemotePlugin({
142
+ getStatus: () => ({
143
+ enabled,
144
+ backends: {
145
+ otlp: resolved.otlp !== undefined,
146
+ langfuse: resolved.langfuse !== undefined,
147
+ },
148
+ queueDepth: { otlp: depthOf('otlp'), langfuse: depthOf('langfuse') },
149
+ spool: spool.counts(),
150
+ }),
151
+ setEnabled: (value) => {
152
+ enabled = value;
153
+ logger.info(value ? 'exporting re-enabled' : 'exporting disabled (kill switch): new records are dropped until re-enabled');
154
+ if (value) {
155
+ for (const pipeline of pipelines)
156
+ pipeline.kick();
157
+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AAC;AACH,CAAC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Owned JSON record model shared by both export backends. Everything here
3
+ * is plain data, already sanitized, and fully detached from live harness
4
+ * objects — records are the only thing that ever crosses the plugin's
5
+ * process boundary, so no Cordis/Session reference can leak into a payload.
6
+ * @module dsh-observe/model
7
+ */
8
+ /** JSON-scalar attribute values. */
9
+ export type JsonScalar = string | number | boolean;
10
+ /** Normalized token accounting for one LLM call. */
11
+ export interface TokenCounts {
12
+ input: number;
13
+ output: number;
14
+ cacheRead: number;
15
+ cacheWrite: number;
16
+ reasoning: number;
17
+ }
18
+ /** Tool-specific span payload (sanitized at capture). */
19
+ export interface ToolSpanInfo {
20
+ name: string;
21
+ status: 'ok' | 'error';
22
+ errorName?: string;
23
+ errorCode?: string;
24
+ input?: string;
25
+ output?: string;
26
+ /** 1-based occurrence of this exact (name, arguments) pair within the step. */
27
+ attempt: number;
28
+ /** `attempt - 1` — earlier identical calls in the same step are retries. */
29
+ retries: number;
30
+ }
31
+ /** LLM-specific span payload (sanitized at capture). */
32
+ export interface LlmSpanInfo {
33
+ model?: string;
34
+ provider?: string;
35
+ usage?: TokenCounts;
36
+ finishReason?: string;
37
+ ttftMs?: number;
38
+ input?: string;
39
+ output?: string;
40
+ costUsd?: number;
41
+ }
42
+ /** The span families. */
43
+ export type SpanKind = 'turn' | 'step' | 'tool' | 'llm';
44
+ /** One closed span, ready for export. */
45
+ export interface SpanRecord {
46
+ kind: SpanKind;
47
+ sessionId: string;
48
+ turn: number;
49
+ /** Present for step/tool/llm spans; absent for turn spans. */
50
+ step?: number;
51
+ /** The tool call id (tool spans only) — anchors the deterministic span id. */
52
+ callId?: string;
53
+ startUnixNano: number;
54
+ endUnixNano: number;
55
+ attributes: Record<string, JsonScalar>;
56
+ status: 'ok' | 'error';
57
+ tool?: ToolSpanInfo;
58
+ llm?: LlmSpanInfo;
59
+ }
60
+ /**
61
+ * One metric sample. Counters carry deltas (the OTLP sink aggregates them
62
+ * into cumulative sums); gauges carry absolute values (last write wins).
63
+ */
64
+ export interface MetricRecord {
65
+ name: string;
66
+ kind: 'counter' | 'gauge';
67
+ unit: string;
68
+ value: number;
69
+ attributes: Record<string, string>;
70
+ }
71
+ /** The record union that flows through pipelines, spool, and sinks. */
72
+ export type ExportRecord = {
73
+ kind: 'span';
74
+ span: SpanRecord;
75
+ } | {
76
+ kind: 'metric';
77
+ metric: MetricRecord;
78
+ };
79
+ /**
80
+ * Validate a value read back from the durable spool: it must look like an
81
+ * export record. The spool is a durable boundary, so hostile or hand-edited
82
+ * values are rejected here instead of reaching a sink.
83
+ * @param value - the stored value.
84
+ * @returns true when the value is an {@link ExportRecord}.
85
+ */
86
+ export declare function isExportRecord(value: unknown): value is ExportRecord;
87
+ /** The two export backends. */
88
+ export type BackendName = 'otlp' | 'langfuse';
89
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oCAAoC;AACpC,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAElD,oDAAoD;AACpD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,yDAAyD;AACzD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,IAAI,GAAG,OAAO,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAA;IACf,4EAA4E;IAC5E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;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,YAAY,CAAA;CAAE,CAAA;AAE5C;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAMpE;AAED,+BAA+B;AAC/B,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,UAAU,CAAA"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Owned JSON record model shared by both export backends. Everything here
3
+ * is plain data, already sanitized, and fully detached from live harness
4
+ * objects — records are the only thing that ever crosses the plugin's
5
+ * process boundary, so no Cordis/Session reference can leak into a payload.
6
+ * @module dsh-observe/model
7
+ */
8
+ /**
9
+ * Validate a value read back from the durable spool: it must look like an
10
+ * export record. The spool is a durable boundary, so hostile or hand-edited
11
+ * values are rejected here instead of reaching a sink.
12
+ * @param value - the stored value.
13
+ * @returns true when the value is an {@link ExportRecord}.
14
+ */
15
+ export function isExportRecord(value) {
16
+ if (typeof value !== 'object' || value === null)
17
+ return false;
18
+ const record = value;
19
+ if (record.kind === 'span')
20
+ return typeof record.span === 'object' && record.span !== null;
21
+ if (record.kind === 'metric')
22
+ return typeof record.metric === 'object' && record.metric !== null;
23
+ return false;
24
+ }
25
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/model.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA6EH;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAC7D,MAAM,MAAM,GAAG,KAA6D,CAAA;IAC5E,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,CAAA;IAC1F,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,CAAA;IAChG,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The per-backend delivery pipeline: an in-memory queue, periodic and
3
+ * size-triggered flushes, retry with exponential backoff, and spill-over
4
+ * into the durable offline buffer (both when the queue bound is hit and
5
+ * when retries are exhausted). Spool draining runs on its own cycle.
6
+ * @module dsh-observe/pipeline
7
+ */
8
+ import type { ResolvedBatch, ResolvedRetry } from './config.ts';
9
+ import type { BackendName, ExportRecord, MetricRecord } from './model.ts';
10
+ import type { ObserveLogger, SpanSink } from './sinks.ts';
11
+ import type { Spool } from './spool.ts';
12
+ /** Everything one pipeline needs. */
13
+ export interface PipelineOptions {
14
+ name: BackendName;
15
+ sink: SpanSink;
16
+ spool: Spool;
17
+ batch: ResolvedBatch;
18
+ retry: ResolvedRetry;
19
+ logger: ObserveLogger;
20
+ /** The runtime kill switch; when off, pushed records are dropped and counted. */
21
+ isEnabled: () => boolean;
22
+ /** Operational metric sink (OTLP aggregation). */
23
+ onMetric: (metric: MetricRecord) => void;
24
+ }
25
+ /**
26
+ * One backend's delivery pipeline. Push is synchronous (the session event
27
+ * hot path); all network work happens on timers or in the background.
28
+ */
29
+ export declare class Pipeline {
30
+ private readonly options;
31
+ private queue;
32
+ private pending;
33
+ private inFlight;
34
+ private consecutiveFailures;
35
+ private retryTimer;
36
+ private disposed;
37
+ /**
38
+ * @param options - the pipeline options (copied, never mutated).
39
+ */
40
+ constructor(options: PipelineOptions);
41
+ /** Records currently queued or awaiting retry. */
42
+ get depth(): number;
43
+ /** The backend this pipeline delivers to (`otlp` / `langfuse`). */
44
+ get name(): BackendName;
45
+ /**
46
+ * Queue one record. A disabled runtime drops it (counted); a full queue
47
+ * spills it straight into the durable buffer (bounded; oldest records
48
+ * there are evicted first).
49
+ * @param record - the owned, sanitized record.
50
+ */
51
+ push(record: ExportRecord): void;
52
+ /** Start a flush immediately when no flush is already running or scheduled. */
53
+ kick(): void;
54
+ /** The periodic flush entry point. */
55
+ tick(): Promise<void>;
56
+ /** One flush attempt: pending retry batch first, otherwise the queue head. */
57
+ private flushOnce;
58
+ /** Schedule the backoff retry for the pending batch. */
59
+ private scheduleRetry;
60
+ /**
61
+ * Try the oldest buffered batches once. Batches that fail stay in the
62
+ * buffer for the next cycle; success deletes them.
63
+ */
64
+ drainSpool(): Promise<void>;
65
+ /**
66
+ * Final flush on unload: one best-effort export of everything queued;
67
+ * whatever fails goes to the durable buffer for the next process run.
68
+ */
69
+ dispose(): Promise<void>;
70
+ }
71
+ //# sourceMappingURL=pipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAEvC,qCAAqC;AACrC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,CAAA;IACjB,IAAI,EAAE,QAAQ,CAAA;IACd,KAAK,EAAE,KAAK,CAAA;IACZ,KAAK,EAAE,aAAa,CAAA;IACpB,KAAK,EAAE,aAAa,CAAA;IACpB,MAAM,EAAE,aAAa,CAAA;IACrB,iFAAiF;IACjF,SAAS,EAAE,MAAM,OAAO,CAAA;IACxB,kDAAkD;IAClD,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAA;CACzC;AA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