@xandreed/plugin-telemetry 0.3.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Xand Reed
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @xandreed/plugin-telemetry
2
+
3
+ Efferent composable agent framework, 0.3.0. Bun on Linux.
4
+
5
+ Documentation: https://github.com/xandreeddev/efferent
@@ -0,0 +1,2 @@
1
+ export { FileLoggerAddLive, FileLoggerLive, TracingLive } from "./telemetry/telemetry.js";
2
+ export { telemetryPlugin, default } from "./plugin.adapter.js";
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { FileLoggerAddLive, FileLoggerLive, TracingLive } from "./telemetry/telemetry.js";
2
+ export { telemetryPlugin, default } from "./plugin.adapter.js";
@@ -0,0 +1,2 @@
1
+ export declare const telemetryPlugin: import("@xandreed/core").Plugin;
2
+ export default telemetryPlugin;
@@ -0,0 +1,15 @@
1
+ import { Effect, Layer, Schema } from "effect";
2
+ import { definePlugin, TurnHooks } from "@xandreed/core";
3
+ import { TracingLive } from "./telemetry/telemetry.js";
4
+ export const telemetryPlugin = definePlugin({
5
+ id: "@xandreed/plugin-telemetry",
6
+ version: "0.3.0",
7
+ config: Schema.Struct({ enabled: Schema.Boolean, serviceName: Schema.String }),
8
+ defaults: { enabled: !1, serviceName: "efferent" },
9
+ provides: [TurnHooks],
10
+ layer: ({ enabled, serviceName }) => Layer.succeed(TurnHooks, {
11
+ before: (input) => Effect.succeed(input),
12
+ after: (input) => Effect.annotateCurrentSpan({ "session.id": input.session.id, "run.id": input.runId })
13
+ }).pipe(Layer.provide(enabled ? TracingLive(serviceName) : Layer.empty))
14
+ });
15
+ export default telemetryPlugin;
@@ -0,0 +1,21 @@
1
+ import { Layer } from "effect";
2
+ /**
3
+ * The observability edge — two layers every agent main composes:
4
+ *
5
+ * - `TracingLive(serviceName)` exports the spans the kernel already emits
6
+ * (`engine.run` / `engine.turn` / `providers.generate`) over OTLP HTTP to
7
+ * the local stack (`bun run obs:up`, grafana on :3000). The exporter reads
8
+ * the standard `OTEL_EXPORTER_OTLP_ENDPOINT` env itself and defaults to
9
+ * `http://localhost:4318`; when no collector is listening, batch exports
10
+ * fail SILENTLY (no diag logger is registered) — always-on costs nothing.
11
+ *
12
+ * - `FileLoggerLive(path)` routes Effect's logger to an append-only logfmt
13
+ * file. The TUI previously SILENCED all logs (any console write corrupts
14
+ * the alt screen), which meant a mid-run failure left no trace anywhere —
15
+ * a session that "just died" was undiagnosable. Now it's on disk.
16
+ */
17
+ export declare const TracingLive: (serviceName: string) => Layer.Layer<never>;
18
+ export declare const FileLoggerLive: (path: string) => Layer.Layer<never>;
19
+ /** Add the file sink while retaining the driver's console logger (headless
20
+ * mode needs both a live stderr narrative and crash-forensics on disk). */
21
+ export declare const FileLoggerAddLive: (path: string) => Layer.Layer<never>;
@@ -0,0 +1,24 @@
1
+ import { dirname } from "node:path";
2
+ import { NodeSdk } from "@effect/opentelemetry";
3
+ import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
4
+ import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
5
+ import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
6
+ import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
7
+ import { FileSystem, PlatformLogger } from "@effect/platform";
8
+ import { BunFileSystem } from "@effect/platform-bun";
9
+ import { Effect, Layer, Logger } from "effect";
10
+ export const TracingLive = (serviceName) => NodeSdk.layer(() => ({
11
+ resource: { serviceName },
12
+ spanProcessor: [new BatchSpanProcessor(new OTLPTraceExporter)],
13
+ metricReader: new PeriodicExportingMetricReader({
14
+ exporter: new OTLPMetricExporter,
15
+ exportIntervalMillis: 5000
16
+ })
17
+ }));
18
+ const fileLogger = (path) => Effect.gen(function* () {
19
+ yield* (yield* FileSystem.FileSystem).makeDirectory(dirname(path), { recursive: !0 }).pipe(Effect.orElseSucceed(() => {
20
+ return;
21
+ }));
22
+ return yield* PlatformLogger.toFile(Logger.logfmtLogger, path, { flag: "a" });
23
+ }).pipe(Effect.orElseSucceed(() => Logger.none));
24
+ export const FileLoggerLive = (path) => Logger.replaceScoped(Logger.defaultLogger, fileLogger(path)).pipe(Layer.provide(BunFileSystem.layer)), FileLoggerAddLive = (path) => Logger.addScoped(fileLogger(path)).pipe(Layer.provide(BunFileSystem.layer));
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@xandreed/plugin-telemetry",
3
+ "version": "0.3.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ }
11
+ },
12
+ "dependencies": {
13
+ "@xandreed/core": "0.3.0",
14
+ "effect": "3.21.4",
15
+ "@effect/opentelemetry": "^0.63.0",
16
+ "@effect/platform": "0.96.1",
17
+ "@effect/platform-bun": "^0.89.0",
18
+ "@opentelemetry/exporter-metrics-otlp-http": "^0.219.0",
19
+ "@opentelemetry/exporter-trace-otlp-http": "^0.219.0",
20
+ "@opentelemetry/sdk-metrics": "^2.8.0",
21
+ "@opentelemetry/sdk-trace-base": "^2.8.0"
22
+ },
23
+ "private": false,
24
+ "types": "./dist/index.d.ts",
25
+ "files": [
26
+ "dist",
27
+ "skills",
28
+ "profiles",
29
+ "README.md",
30
+ "LICENSE"
31
+ ],
32
+ "engines": {
33
+ "bun": ">=1.3.0"
34
+ },
35
+ "license": "MIT"
36
+ }