@workglow/util 0.0.115 → 0.0.116

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.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { ISpan, ITelemetryProvider, SpanOptions } from "./ITelemetryProvider";
7
+ /**
8
+ * Lightweight telemetry provider that prints span summaries to console.
9
+ * Useful for local development without requiring a full OpenTelemetry stack.
10
+ */
11
+ export declare class ConsoleTelemetryProvider implements ITelemetryProvider {
12
+ readonly isEnabled = true;
13
+ startSpan(name: string, options?: SpanOptions): ISpan;
14
+ }
15
+ //# sourceMappingURL=ConsoleTelemetryProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConsoleTelemetryProvider.d.ts","sourceRoot":"","sources":["../../src/telemetry/ConsoleTelemetryProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAkB,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAwEnG;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,kBAAkB;IACjE,QAAQ,CAAC,SAAS,QAAQ;IAE1B,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,KAAK;CAGtD"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Attributes that can be attached to a span.
8
+ * Values follow OpenTelemetry attribute value conventions.
9
+ */
10
+ export type SpanAttributes = Record<string, string | number | boolean | undefined>;
11
+ /**
12
+ * Status codes for a span, matching OpenTelemetry conventions.
13
+ */
14
+ export declare const SpanStatusCode: {
15
+ readonly UNSET: 0;
16
+ readonly OK: 1;
17
+ readonly ERROR: 2;
18
+ };
19
+ export type SpanStatusCode = (typeof SpanStatusCode)[keyof typeof SpanStatusCode];
20
+ /**
21
+ * A handle to an active span. Call `end()` when the operation completes.
22
+ */
23
+ export interface ISpan {
24
+ /** Record key-value attributes on the span. */
25
+ setAttributes(attributes: SpanAttributes): void;
26
+ /** Record a timestamped event (log) on the span. */
27
+ addEvent(name: string, attributes?: SpanAttributes): void;
28
+ /** Mark the span with a status code and optional message. */
29
+ setStatus(code: SpanStatusCode, message?: string): void;
30
+ /** End the span. Must be called exactly once. */
31
+ end(): void;
32
+ }
33
+ /**
34
+ * Options for starting a new span.
35
+ */
36
+ export interface SpanOptions {
37
+ /** Attributes to set on the span at creation. */
38
+ attributes?: SpanAttributes;
39
+ }
40
+ /**
41
+ * Provider interface for telemetry instrumentation.
42
+ * Implementations bridge to OpenTelemetry, Datadog, or any APM backend.
43
+ *
44
+ * Register a provider via {@link setTelemetryProvider} to enable tracing
45
+ * across task-graph, job-queue, and ai-provider packages.
46
+ */
47
+ export interface ITelemetryProvider {
48
+ /**
49
+ * Start a new span for the given operation.
50
+ *
51
+ * @param name - Dot-separated operation name, e.g. `"workglow.task.run"`
52
+ * @param options - Optional span configuration
53
+ * @returns A handle to the active span
54
+ */
55
+ startSpan(name: string, options?: SpanOptions): ISpan;
56
+ /**
57
+ * Whether the provider is actively collecting traces.
58
+ * When false, callers may skip expensive attribute computation.
59
+ */
60
+ readonly isEnabled: boolean;
61
+ }
62
+ //# sourceMappingURL=ITelemetryProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ITelemetryProvider.d.ts","sourceRoot":"","sources":["../../src/telemetry/ITelemetryProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;AAEnF;;GAEG;AACH,eAAO,MAAM,cAAc;;;;CAIjB,CAAC;AACX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAElF;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,+CAA+C;IAC/C,aAAa,CAAC,UAAU,EAAE,cAAc,GAAG,IAAI,CAAC;IAChD,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAC1D,6DAA6D;IAC7D,SAAS,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxD,iDAAiD;IACjD,GAAG,IAAI,IAAI,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,iDAAiD;IACjD,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;IAEtD;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { ISpan, ITelemetryProvider, SpanOptions } from "./ITelemetryProvider";
7
+ /**
8
+ * Default no-op telemetry provider. All methods are zero-cost stubs.
9
+ * This is the default provider when no telemetry backend is configured.
10
+ */
11
+ export declare class NoopTelemetryProvider implements ITelemetryProvider {
12
+ readonly isEnabled = false;
13
+ startSpan(_name: string, _options?: SpanOptions): ISpan;
14
+ }
15
+ //# sourceMappingURL=NoopTelemetryProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NoopTelemetryProvider.d.ts","sourceRoot":"","sources":["../../src/telemetry/NoopTelemetryProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAkB,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAanG;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,kBAAkB;IAC9D,QAAQ,CAAC,SAAS,SAAS;IAE3B,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,KAAK;CAGxD"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { ISpan, ITelemetryProvider, SpanOptions } from "./ITelemetryProvider";
7
+ /**
8
+ * Minimal subset of the OpenTelemetry `Tracer` interface that we depend on.
9
+ * This avoids a hard dependency on `@opentelemetry/api` while still being
10
+ * fully compatible with `trace.getTracer()`.
11
+ */
12
+ export interface OTelTracer {
13
+ startSpan(name: string, options?: any, context?: any): OTelSpan;
14
+ }
15
+ /**
16
+ * Minimal subset of the OpenTelemetry `Span` interface.
17
+ */
18
+ export interface OTelSpan {
19
+ setAttribute(key: string, value: string | number | boolean): any;
20
+ addEvent(name: string, attributes?: Record<string, any>): any;
21
+ setStatus(status: {
22
+ code: number;
23
+ message?: string;
24
+ }): any;
25
+ end(): void;
26
+ }
27
+ /**
28
+ * Telemetry provider backed by a real OpenTelemetry tracer.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * import { trace } from "@opentelemetry/api";
33
+ * import { OTelTelemetryProvider, setTelemetryProvider } from "@workglow/util";
34
+ *
35
+ * const tracer = trace.getTracer("my-app", "1.0.0");
36
+ * setTelemetryProvider(new OTelTelemetryProvider(tracer));
37
+ * ```
38
+ */
39
+ export declare class OTelTelemetryProvider implements ITelemetryProvider {
40
+ private readonly tracer;
41
+ readonly isEnabled = true;
42
+ constructor(tracer: OTelTracer);
43
+ startSpan(name: string, options?: SpanOptions): ISpan;
44
+ }
45
+ //# sourceMappingURL=OTelTelemetryProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OTelTelemetryProvider.d.ts","sourceRoot":"","sources":["../../src/telemetry/OTelTelemetryProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAkB,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnG;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,QAAQ,CAAC;CACjE;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,GAAG,CAAC;IACjE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;IAC9D,SAAS,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,GAAG,CAAC;IAC3D,GAAG,IAAI,IAAI,CAAC;CACb;AAuCD;;;;;;;;;;;GAWG;AACH,qBAAa,qBAAsB,YAAW,kBAAkB;IAGlD,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,QAAQ,CAAC,SAAS,QAAQ;gBAEG,MAAM,EAAE,UAAU;IAE/C,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,KAAK;CAUtD"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { ITelemetryProvider } from "./ITelemetryProvider";
7
+ /**
8
+ * Service token for the global telemetry provider instance.
9
+ */
10
+ export declare const TELEMETRY_PROVIDER: import("../di").ServiceToken<ITelemetryProvider>;
11
+ /**
12
+ * Returns the current global telemetry provider.
13
+ */
14
+ export declare function getTelemetryProvider(): ITelemetryProvider;
15
+ /**
16
+ * Replaces the global telemetry provider instance.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { OTelTelemetryProvider } from "@workglow/util";
21
+ * import { trace } from "@opentelemetry/api";
22
+ *
23
+ * setTelemetryProvider(new OTelTelemetryProvider(trace.getTracer("my-app")));
24
+ * ```
25
+ */
26
+ export declare function setTelemetryProvider(provider: ITelemetryProvider): void;
27
+ //# sourceMappingURL=TelemetryRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TelemetryRegistry.d.ts","sourceRoot":"","sources":["../../src/telemetry/TelemetryRegistry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D;;GAEG;AACH,eAAO,MAAM,kBAAkB,kDAAsD,CAAC;AA4BtF;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,kBAAkB,CAEzD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAEvE"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export * from "./ConsoleTelemetryProvider";
7
+ export * from "./ITelemetryProvider";
8
+ export * from "./NoopTelemetryProvider";
9
+ export * from "./OTelTelemetryProvider";
10
+ export * from "./TelemetryRegistry";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@workglow/util",
3
3
  "type": "module",
4
- "version": "0.0.115",
4
+ "version": "0.0.116",
5
5
  "description": "Utility functions and shared types for Workglow, providing common functionality across all packages.",
6
6
  "scripts": {
7
7
  "watch": "concurrently -c 'auto' 'bun:watch-*'",