@narumitw/pi-otel 0.54.3 → 0.55.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/CHANGELOG.md +8 -0
- package/README.md +5 -2
- package/dist/chunks/{chunk-DSQBXICE.ts → chunk-IXR5MVGN.ts} +12 -6
- package/dist/chunks/chunk-IXR5MVGN.ts.map +7 -0
- package/dist/chunks/{runtime-X3YFJUNH.ts → runtime-KWIFBNQ2.ts} +2 -2
- package/dist/durable.js +1 -1
- package/dist/index.js +11 -7
- package/dist/index.js.map +2 -2
- package/dist/index.ts +12 -8
- package/dist/index.ts.map +2 -2
- package/dist/library-chunks/{chunk-7JGM5RS3.js → chunk-ROM6FIM7.js} +12 -6
- package/dist/library-chunks/chunk-ROM6FIM7.js.map +7 -0
- package/dist/library-chunks/{chunk-7DN64UHE.js → chunk-ZCEZBO2T.js} +3 -3
- package/dist/library-chunks/{runtime-554E6FVF.js → runtime-7TSAKORH.js} +2 -2
- package/dist/otlp-settings.d.ts +1 -0
- package/dist/tracing.d.ts +1 -0
- package/docs/durable.md +1 -1
- package/package.json +1 -1
- package/src/otlp-settings.ts +13 -5
- package/src/tracing.ts +10 -4
- package/dist/chunks/chunk-DSQBXICE.ts.map +0 -7
- package/dist/library-chunks/chunk-7JGM5RS3.js.map +0 -7
- /package/dist/chunks/{runtime-X3YFJUNH.ts.map → runtime-KWIFBNQ2.ts.map} +0 -0
- /package/dist/library-chunks/{chunk-7DN64UHE.js.map → chunk-ZCEZBO2T.js.map} +0 -0
- /package/dist/library-chunks/{runtime-554E6FVF.js.map → runtime-7TSAKORH.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Versions through 0.54.3 were released as `@narumitw/pi-langfuse`.
|
|
4
4
|
|
|
5
|
+
## 0.55.0
|
|
6
|
+
|
|
7
|
+
### Minor Changes
|
|
8
|
+
|
|
9
|
+
- 350ac5c: Rename the tracing extension to `pi-otel` and add OTLP/HTTP protobuf export to custom collectors. Generic export keeps prompts, model replies, tool content, and free-form provider errors local by default. OTLP custom headers require HTTPS or a loopback IP. Existing Langfuse settings and trace attributes remain supported.
|
|
10
|
+
|
|
11
|
+
Use `/otel` for all tracing controls, including Langfuse setup. `/langfuse` is deprecated and warns users to switch to `/otel` while still opening the same menu. Uninstall the old `pi-langfuse` package before loading `pi-otel` to avoid duplicate tracing.
|
|
12
|
+
|
|
5
13
|
## 0.54.3
|
|
6
14
|
|
|
7
15
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ The durable adapter targets experimental Pi durable APIs within the peer ranges
|
|
|
44
44
|
Pi extensions run with your user permissions. Review the [data-export behavior](#-security-and-privacy) before enabling tracing.
|
|
45
45
|
|
|
46
46
|
If you already use `pi-langfuse`, uninstall it before loading `pi-otel` to avoid duplicate tracing and slash commands.
|
|
47
|
-
Existing Langfuse settings still work; see [Settings](
|
|
47
|
+
Existing Langfuse settings still work; see [Settings](#settings). Host applications can change their import paths to `@narumitw/pi-otel` or `@narumitw/pi-otel/durable` without renaming their Langfuse factories.
|
|
48
48
|
|
|
49
49
|
## 🚀 Quick start
|
|
50
50
|
|
|
@@ -171,6 +171,8 @@ Tracing never resumes paused recovery or controls execution, and capture bounds
|
|
|
171
171
|
See the installed [durable API guide](./docs/durable.md) for the compatibility matrix, ownership, per-request correlation, privacy projections, recovery semantics and limitations.
|
|
172
172
|
The host remains responsible for authorization, storage, execution cancellation/recovery, callback-owned work and shared-runtime shutdown.
|
|
173
173
|
|
|
174
|
+
<a id="settings"></a>
|
|
175
|
+
|
|
174
176
|
## ⚙️ Settings
|
|
175
177
|
|
|
176
178
|
Settings apply to the Pi agent directory, not a project or an individual conversation. Edit `<getAgentDir()>/pi-otel.json` (normally `~/.pi/agent/pi-otel.json`).
|
|
@@ -188,6 +190,7 @@ Use `"backend": "otlp"` with the full HTTP or HTTPS traces URL, including the re
|
|
|
188
190
|
The exporter sends OTLP/HTTP protobuf, not gRPC. The URL must not contain credentials, a query, or a fragment.
|
|
189
191
|
Optional `serviceName` defaults to `pi`. Optional `headers` is an object of literal header names and values, for example `{"Authorization": "Bearer YOUR_TOKEN"}`.
|
|
190
192
|
Header names are case-insensitive and cannot be duplicated or override transport headers such as `Content-Type`.
|
|
193
|
+
Custom headers require HTTPS, except over HTTP to a loopback IP such as `127.0.0.1` or `[::1]`. Use a loopback IP instead of `localhost` if a local HTTP collector needs headers.
|
|
191
194
|
The exporter does not inherit ambient `OTEL_EXPORTER_OTLP_*` connection settings. `captureContent` defaults to `false`.
|
|
192
195
|
|
|
193
196
|
### Langfuse
|
|
@@ -335,7 +338,7 @@ A `userId` can identify you if you set it to an email address or real name.
|
|
|
335
338
|
Choose a pseudonymous value when that matters, or leave `userId` unset to export no user at all.
|
|
336
339
|
|
|
337
340
|
The built-in mask protects configured export credentials but is not a general secret scanner.
|
|
338
|
-
Set `"captureContent": false` when prompts, provider-request snapshots, responses,
|
|
341
|
+
Set `"captureContent": false` when prompts, provider-request snapshots, responses, tool content, and free-form provider error messages must stay local. Traces still record the error status and a generic message. Turn it on only for trusted receivers.
|
|
339
342
|
Compaction summaries, tool partial results, opaque continuation signatures, authorization headers, cookies, and unapproved response headers are never exported in either mode.
|
|
340
343
|
|
|
341
344
|
## 🗂️ Package layout
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
// src/otlp-settings.ts
|
|
5
5
|
import { validateHeaderName, validateHeaderValue } from "node:http";
|
|
6
|
+
import { isIP } from "node:net";
|
|
6
7
|
var RESERVED_HEADERS = /* @__PURE__ */ new Set([
|
|
7
8
|
"__proto__",
|
|
8
9
|
"connection",
|
|
@@ -14,22 +15,27 @@ var RESERVED_HEADERS = /* @__PURE__ */ new Set([
|
|
|
14
15
|
"user-agent"
|
|
15
16
|
]);
|
|
16
17
|
function normalizeOtlpConnection(input) {
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
18
|
+
const url = parseHttpUrl(input.endpoint);
|
|
19
|
+
if (!url) {
|
|
19
20
|
throw new Error("OTLP endpoint must be a full HTTP or HTTPS URL without credentials, a query, or a fragment.");
|
|
20
21
|
}
|
|
21
22
|
const serviceName = input.serviceName === void 0 ? "pi" : input.serviceName;
|
|
22
23
|
if (typeof serviceName !== "string" || !serviceName.trim()) {
|
|
23
24
|
throw new Error("OTLP serviceName must be a non-empty string.");
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
const headers = normalizeHeaders(input.headers);
|
|
27
|
+
const loopback = url.hostname.startsWith("127.") && isIP(url.hostname) === 4 || url.hostname === "[::1]";
|
|
28
|
+
if (Object.keys(headers).length > 0 && url.protocol === "http:" && !loopback) {
|
|
29
|
+
throw new Error("OTLP headers require HTTPS unless the endpoint uses a loopback IP (127.0.0.0/8 or [::1]).");
|
|
30
|
+
}
|
|
31
|
+
return { endpoint: url.href, headers, serviceName: serviceName.trim() };
|
|
26
32
|
}
|
|
27
|
-
function
|
|
33
|
+
function parseHttpUrl(value) {
|
|
28
34
|
if (typeof value !== "string" || !/^https?:\/\//iu.test(value.trim()) || /[?#]/u.test(value)) return void 0;
|
|
29
35
|
try {
|
|
30
36
|
const url = new URL(value.trim());
|
|
31
37
|
if (url.username || url.password) return void 0;
|
|
32
|
-
return url
|
|
38
|
+
return url;
|
|
33
39
|
} catch {
|
|
34
40
|
return void 0;
|
|
35
41
|
}
|
|
@@ -147,4 +153,4 @@ export {
|
|
|
147
153
|
getLangfuseRuntimeInternal,
|
|
148
154
|
createLangfuseRuntimeFromBackend
|
|
149
155
|
};
|
|
150
|
-
//# sourceMappingURL=chunk-
|
|
156
|
+
//# sourceMappingURL=chunk-IXR5MVGN.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/otlp-settings.ts", "../../src/runtime-defaults.ts", "../../src/runtime-core.ts"],
|
|
4
|
+
"sourcesContent": ["import { validateHeaderName, validateHeaderValue } from \"node:http\";\nimport { isIP } from \"node:net\";\n\nexport interface OtlpRuntimeConfig {\n endpoint: string;\n /** Requires HTTPS unless the endpoint uses a loopback IP. */\n headers?: Readonly<Record<string, string>>;\n serviceName?: string;\n}\n\nexport type OtlpConnection = Required<OtlpRuntimeConfig>;\n\nconst RESERVED_HEADERS = new Set([\n \"__proto__\",\n \"connection\",\n \"content-encoding\",\n \"content-length\",\n \"content-type\",\n \"host\",\n \"transfer-encoding\",\n \"user-agent\",\n]);\n\nexport function normalizeOtlpConnection(input: Readonly<Record<string, unknown>>): OtlpConnection {\n const url = parseHttpUrl(input.endpoint);\n if (!url) {\n throw new Error(\"OTLP endpoint must be a full HTTP or HTTPS URL without credentials, a query, or a fragment.\");\n }\n const serviceName = input.serviceName === undefined ? \"pi\" : input.serviceName;\n if (typeof serviceName !== \"string\" || !serviceName.trim()) {\n throw new Error(\"OTLP serviceName must be a non-empty string.\");\n }\n const headers = normalizeHeaders(input.headers);\n // URL canonicalizes numeric IPs. Do not trust DNS or hosts-file aliases with cleartext credentials.\n const loopback = (url.hostname.startsWith(\"127.\") && isIP(url.hostname) === 4) || url.hostname === \"[::1]\";\n if (Object.keys(headers).length > 0 && url.protocol === \"http:\" && !loopback) {\n throw new Error(\"OTLP headers require HTTPS unless the endpoint uses a loopback IP (127.0.0.0/8 or [::1]).\");\n }\n return { endpoint: url.href, headers, serviceName: serviceName.trim() };\n}\n\nfunction parseHttpUrl(value: unknown): URL | undefined {\n if (typeof value !== \"string\" || !/^https?:\\/\\//iu.test(value.trim()) || /[?#]/u.test(value)) return undefined;\n try {\n const url = new URL(value.trim());\n if (url.username || url.password) return undefined;\n return url;\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeHeaders(input: unknown): Record<string, string> {\n if (input === undefined) return {};\n if (input === null || typeof input !== \"object\" || Array.isArray(input)) {\n throw new Error(\"OTLP headers must be an object of literal HTTP header names and values.\");\n }\n const entries = new Map<string, string>();\n for (const [name, value] of Object.entries(input)) {\n const key = name.toLowerCase();\n try {\n validateHeaderName(name);\n if (typeof value !== \"string\" || !value.trim() || RESERVED_HEADERS.has(key) || entries.has(key)) {\n throw new Error(\"Invalid header\");\n }\n validateHeaderValue(name, value);\n entries.set(key, value.trim());\n } catch {\n // Neither the header name nor its value is safe to include in a diagnostic.\n throw new Error(\"OTLP headers contain an invalid, reserved, empty, or duplicate HTTP header.\");\n }\n }\n return Object.fromEntries([...entries].sort(([left], [right]) => left.localeCompare(right)));\n}\n\nexport function otlpSecrets(headers: Readonly<Record<string, string>>): string[] {\n const auth = headers.authorization;\n const token = auth?.match(/^\\S+\\s+(.+)$/u)?.[1];\n return [...new Set([...Object.values(headers), ...(token ? [token] : [])])].sort((a, b) => b.length - a.length);\n}\n", "export const DEFAULT_BASE_URL = \"https://us.cloud.langfuse.com\";\n", "import type { TraceBackend } from \"./tracing.js\";\n\nexport interface LangfuseRuntimeConfig {\n publicKey?: string;\n secretKey?: string;\n baseUrl?: string;\n environment?: string;\n release?: string;\n}\n\nexport interface CreateLangfuseRuntimeOptions {\n config?: LangfuseRuntimeConfig;\n env?: NodeJS.ProcessEnv | false;\n}\n\nexport interface LangfuseRuntime {\n readonly closed: boolean;\n flush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\ntype RuntimeSessionDisposer = (statusMessage: string) => void | Promise<void>;\n\nexport interface LangfuseRuntimeInternal extends LangfuseRuntime {\n readonly backend: TraceBackend;\n registerSession(disposer: RuntimeSessionDisposer): () => void;\n}\n\nconst RUNTIME_INTERNAL_KEY = Symbol.for(\"@narumitw/pi-langfuse/runtime-internal/v2\");\n\nclass ManagedLangfuseRuntime implements LangfuseRuntimeInternal {\n private state: \"open\" | \"closing\" | \"closed\" = \"open\";\n private readonly sessionDisposers = new Set<RuntimeSessionDisposer>();\n private flushQueue = Promise.resolve();\n private shutdownPromise: Promise<void> | undefined;\n\n constructor(readonly backend: TraceBackend) {}\n\n get closed(): boolean {\n return this.state !== \"open\";\n }\n\n registerSession(disposer: RuntimeSessionDisposer): () => void {\n if (this.state !== \"open\") throw new Error(\"Langfuse runtime is shutting down or already closed.\");\n this.sessionDisposers.add(disposer);\n return () => this.sessionDisposers.delete(disposer);\n }\n\n flush(): Promise<void> {\n if (this.state !== \"open\") {\n return Promise.reject(new Error(\"Langfuse runtime is shutting down or already closed.\"));\n }\n const operation = this.flushQueue.then(() => this.backend.forceFlush());\n this.flushQueue = operation.then(\n () => undefined,\n () => undefined,\n );\n return operation;\n }\n\n shutdown(): Promise<void> {\n if (this.shutdownPromise) return this.shutdownPromise;\n this.state = \"closing\";\n // Publish the promise before invoking controller callbacks, which can reenter shutdown().\n this.shutdownPromise = Promise.resolve().then(() => this.shutdownNow());\n return this.shutdownPromise;\n }\n\n private async shutdownNow(): Promise<void> {\n const errors: unknown[] = [];\n for (const dispose of [...this.sessionDisposers]) {\n try {\n await dispose(\"Langfuse runtime shut down before the Pi session was disposed.\");\n } catch (error) {\n errors.push(error);\n }\n }\n this.sessionDisposers.clear();\n\n await this.flushQueue;\n try {\n await this.backend.forceFlush();\n } catch (error) {\n errors.push(error);\n }\n try {\n await this.backend.shutdown();\n } catch (error) {\n errors.push(error);\n } finally {\n this.state = \"closed\";\n }\n\n if (errors.length === 1) throw errors[0];\n if (errors.length > 1) throw new AggregateError(errors, \"Langfuse runtime shutdown failed.\");\n }\n}\n\nexport function getLangfuseRuntimeInternal(runtime: LangfuseRuntime): LangfuseRuntimeInternal {\n const internal = (runtime as LangfuseRuntime & { [key: symbol]: LangfuseRuntimeInternal | undefined })[\n RUNTIME_INTERNAL_KEY\n ];\n if (!internal) throw new Error(\"The tracing runtime was not created by this package.\");\n return internal;\n}\n\nexport function createLangfuseRuntimeFromBackend(backend: TraceBackend): LangfuseRuntime {\n return registerLangfuseRuntime(new ManagedLangfuseRuntime(backend));\n}\n\nexport function registerLangfuseRuntime(runtime: LangfuseRuntimeInternal): LangfuseRuntimeInternal {\n Object.defineProperty(runtime, RUNTIME_INTERNAL_KEY, { value: runtime });\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,OAAM,IAAI,eAAe,QAAQ,mCAAmC;AAAA,EAC7F;AACF;AAEO,SAAS,2BAA2B,SAAmD;AAC5F,QAAM,WAAY,QAChB,oBACF;AACA,MAAI,CAAC,SAAU,OAAM,IAAI,MAAM,sDAAsD;AACrF,SAAO;AACT;AAEO,SAAS,iCAAiC,SAAwC;AACvF,SAAO,wBAAwB,IAAI,uBAAuB,OAAO,CAAC;AACpE;AAEO,SAAS,wBAAwB,SAA2D;AACjG,SAAO,eAAe,SAAS,sBAAsB,EAAE,OAAO,QAAQ,CAAC;AACvE,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
getLangfuseRuntimeInternal,
|
|
7
7
|
normalizeOtlpConnection,
|
|
8
8
|
otlpSecrets
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-IXR5MVGN.ts";
|
|
10
10
|
|
|
11
11
|
// src/runtime.ts
|
|
12
12
|
import { Buffer } from "node:buffer";
|
|
@@ -401,4 +401,4 @@ export {
|
|
|
401
401
|
maskSecrets,
|
|
402
402
|
resolveLangfuseRuntimeConfig
|
|
403
403
|
};
|
|
404
|
-
//# sourceMappingURL=runtime-
|
|
404
|
+
//# sourceMappingURL=runtime-KWIFBNQ2.ts.map
|
package/dist/durable.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
createLangfuseRuntime,
|
|
5
5
|
createOtelRuntime,
|
|
6
6
|
sanitizeTraceValue
|
|
7
|
-
} from "./library-chunks/chunk-
|
|
7
|
+
} from "./library-chunks/chunk-ZCEZBO2T.js";
|
|
8
8
|
import {
|
|
9
9
|
DEFAULT_BASE_URL,
|
|
10
10
|
normalizeOtlpConnection,
|
|
11
11
|
otlpSecrets
|
|
12
|
-
} from "./library-chunks/chunk-
|
|
12
|
+
} from "./library-chunks/chunk-ROM6FIM7.js";
|
|
13
13
|
import {
|
|
14
14
|
createLangfuseRuntimeFromBackend,
|
|
15
15
|
getLangfuseRuntimeInternal
|
|
@@ -499,7 +499,7 @@ var TraceRecorder = class {
|
|
|
499
499
|
...mismatched && outcome === "success" ? {
|
|
500
500
|
level: "WARNING",
|
|
501
501
|
statusMessage: `Turn ${turnIndex} ended while turn ${this.turnIndex} was active.`
|
|
502
|
-
} : severityForOutcome(outcome, result.message.errorMessage)
|
|
502
|
+
} : severityForOutcome(outcome, this.captureErrorMessage(result.message.errorMessage))
|
|
503
503
|
});
|
|
504
504
|
this.turn.end();
|
|
505
505
|
this.turn = void 0;
|
|
@@ -597,7 +597,7 @@ var TraceRecorder = class {
|
|
|
597
597
|
...finiteNumber(message.usage?.reasoning) ? { "pi.usage.reasoning_tokens": message.usage.reasoning } : {},
|
|
598
598
|
...finiteNumber(message.usage?.cacheWrite1h) ? { "pi.usage.cache_write_1h_tokens": message.usage.cacheWrite1h } : {}
|
|
599
599
|
},
|
|
600
|
-
...severityForOutcome(outcome, message.errorMessage)
|
|
600
|
+
...severityForOutcome(outcome, this.captureErrorMessage(message.errorMessage))
|
|
601
601
|
});
|
|
602
602
|
state.observation.end(state.endTime);
|
|
603
603
|
this.generation = void 0;
|
|
@@ -753,7 +753,7 @@ var TraceRecorder = class {
|
|
|
753
753
|
const finalAttributes = {
|
|
754
754
|
...this.lastOutput !== void 0 ? { output: this.lastOutput } : {},
|
|
755
755
|
metadata: finalMetadata,
|
|
756
|
-
...severityForOutcome(baseOutcome, statusMessage ?? this.lastAssistant?.errorMessage)
|
|
756
|
+
...severityForOutcome(baseOutcome, statusMessage ?? this.captureErrorMessage(this.lastAssistant?.errorMessage))
|
|
757
757
|
};
|
|
758
758
|
this.root.update(finalAttributes);
|
|
759
759
|
this.root.updateTrace?.({
|
|
@@ -783,7 +783,7 @@ var TraceRecorder = class {
|
|
|
783
783
|
"pi.attempt.outcome": outcome,
|
|
784
784
|
...message?.stopReason ? { "pi.attempt.stop_reason": message.stopReason } : {}
|
|
785
785
|
},
|
|
786
|
-
...severityForOutcome(outcome, statusMessage ?? message?.errorMessage)
|
|
786
|
+
...severityForOutcome(outcome, statusMessage ?? this.captureErrorMessage(message?.errorMessage))
|
|
787
787
|
});
|
|
788
788
|
this.attempt.end();
|
|
789
789
|
this.attempt = void 0;
|
|
@@ -845,6 +845,10 @@ var TraceRecorder = class {
|
|
|
845
845
|
this.compaction.observation.end();
|
|
846
846
|
this.compaction = void 0;
|
|
847
847
|
}
|
|
848
|
+
captureErrorMessage(message) {
|
|
849
|
+
if (!this.context.captureContent || typeof message !== "string") return void 0;
|
|
850
|
+
return String(sanitizeTraceValue(message));
|
|
851
|
+
}
|
|
848
852
|
capture(value) {
|
|
849
853
|
return this.context.captureContent ? sanitizeTraceValue(value) : CONTENT_DISABLED;
|
|
850
854
|
}
|
|
@@ -1462,7 +1466,7 @@ function createOtelExtension(dependencies = {}) {
|
|
|
1462
1466
|
if (createBackend) {
|
|
1463
1467
|
runtime = createLangfuseRuntimeFromBackend(await createBackend(config));
|
|
1464
1468
|
} else {
|
|
1465
|
-
const { createLangfuseRuntime: createLangfuseRuntime2, createOtelRuntime: createOtelRuntime2 } = await import("./library-chunks/runtime-
|
|
1469
|
+
const { createLangfuseRuntime: createLangfuseRuntime2, createOtelRuntime: createOtelRuntime2 } = await import("./library-chunks/runtime-7TSAKORH.js");
|
|
1466
1470
|
if (!isCurrent()) return void 0;
|
|
1467
1471
|
runtime = await (config.backend === "otlp" ? createOtelRuntime2(config) : createLangfuseRuntime2({ config, env: false }));
|
|
1468
1472
|
}
|