@pellux/goodvibes-transport-core 0.18.3 → 0.30.1

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/README.md CHANGED
@@ -1,18 +1,14 @@
1
1
  # @pellux/goodvibes-transport-core
2
2
 
3
- Shared client transport and event-feed primitives used by the GoodVibes SDK packages.
3
+ Internal workspace package backing `@pellux/goodvibes-sdk/transport-core`.
4
4
 
5
- Install:
5
+ Consumers should install `@pellux/goodvibes-sdk` and import this surface from the umbrella package.
6
6
 
7
- ```bash
8
- npm install @pellux/goodvibes-transport-core
9
- ```
10
-
11
- Use this package only when you are composing your own transport/client abstraction.
7
+ Use this surface only when you are composing your own transport/client abstraction.
12
8
 
13
9
  Exports include:
14
10
  - event envelope helpers
15
11
  - runtime event feed primitives
16
12
  - generic client transport helpers
17
13
 
18
- Most consumers should use `@pellux/goodvibes-sdk`, `@pellux/goodvibes-operator-sdk`, or `@pellux/goodvibes-peer-sdk` instead.
14
+ Most consumers should use `@pellux/goodvibes-sdk`, `@pellux/goodvibes-sdk/operator`, or `@pellux/goodvibes-sdk/peer` instead.
@@ -1 +1 @@
1
- {"version":3,"file":"client-transport.d.ts","sourceRoot":"","sources":["../src/client-transport.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,eAAe,CAAC,KAAK,SAAS,MAAM,EAAE,SAAS,EAAE,KAAK;IACrE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,iBAAiB,IAAI,SAAS,CAAC;IAC/B,aAAa,IAAI,KAAK,CAAC;CACxB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,MAAM,EAAE,SAAS,EAAE,KAAK,EAC1E,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,SAAS,EACnB,IAAI,EAAE,KAAK,GACV,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,CAY1C"}
1
+ {"version":3,"file":"client-transport.d.ts","sourceRoot":"","sources":["../src/client-transport.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe,CAAC,KAAK,SAAS,MAAM,EAAE,SAAS,EAAE,KAAK;IACrE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,iBAAiB,IAAI,SAAS,CAAC;IAC/B,aAAa,IAAI,KAAK,CAAC;CACxB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,MAAM,EAAE,SAAS,EAAE,KAAK,EAC1E,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,SAAS,EACnB,IAAI,EAAE,KAAK,GACV,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,CAY1C"}
@@ -0,0 +1,4 @@
1
+ import { type ClientTransport } from './client-transport.js';
2
+ export type DirectClientTransport<TOperator, TPeer> = ClientTransport<'direct', TOperator, TPeer>;
3
+ export declare function createDirectClientTransport<TOperator, TPeer>(operator: TOperator, peer: TPeer): DirectClientTransport<TOperator, TPeer>;
4
+ //# sourceMappingURL=direct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"direct.d.ts","sourceRoot":"","sources":["../src/direct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEpF,MAAM,MAAM,qBAAqB,CAAC,SAAS,EAAE,KAAK,IAAI,eAAe,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;AAElG,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,KAAK,EAC1D,QAAQ,EAAE,SAAS,EACnB,IAAI,EAAE,KAAK,GACV,qBAAqB,CAAC,SAAS,EAAE,KAAK,CAAC,CAEzC"}
package/dist/direct.js ADDED
@@ -0,0 +1,4 @@
1
+ import { createClientTransport } from './client-transport.js';
2
+ export function createDirectClientTransport(operator, peer) {
3
+ return createClientTransport('direct', operator, peer);
4
+ }
@@ -0,0 +1,4 @@
1
+ export declare function isAbortError(error: unknown): boolean;
2
+ export declare function describeUnknownTransportError(error: unknown): string;
3
+ export declare function transportErrorFromUnknown(error: unknown, context: string): Error;
4
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAOpD;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CA2BpE;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAOhF"}
package/dist/errors.js ADDED
@@ -0,0 +1,45 @@
1
+ import { GoodVibesSdkError } from '@pellux/goodvibes-errors';
2
+ export function isAbortError(error) {
3
+ return Boolean(error
4
+ && typeof error === 'object'
5
+ && 'name' in error
6
+ && error.name === 'AbortError');
7
+ }
8
+ export function describeUnknownTransportError(error) {
9
+ if (typeof error === 'string')
10
+ return error;
11
+ if (typeof error === 'number' || typeof error === 'boolean' || error === null || error === undefined) {
12
+ return String(error);
13
+ }
14
+ if (typeof error !== 'object')
15
+ return String(error);
16
+ const record = error;
17
+ const nested = record.error;
18
+ const nestedMessage = nested instanceof Error
19
+ ? nested.message
20
+ : nested && typeof nested === 'object' && typeof nested.message === 'string'
21
+ ? nested.message
22
+ : undefined;
23
+ const target = record.target && typeof record.target === 'object'
24
+ ? `[target:${record.target.constructor?.name ?? 'object'}]`
25
+ : undefined;
26
+ const fields = [
27
+ typeof record.name === 'string' ? `name=${record.name}` : undefined,
28
+ typeof record.type === 'string' ? `type=${record.type}` : undefined,
29
+ typeof record.message === 'string' ? `message=${record.message}` : undefined,
30
+ typeof record.reason === 'string' ? `reason=${record.reason}` : undefined,
31
+ typeof record.code === 'number' ? `code=${record.code}` : undefined,
32
+ nestedMessage ? `error=${nestedMessage}` : undefined,
33
+ target,
34
+ ].filter(Boolean);
35
+ return fields.length > 0 ? fields.join(' ') : Object.prototype.toString.call(error);
36
+ }
37
+ export function transportErrorFromUnknown(error, context) {
38
+ if (error instanceof Error)
39
+ return error;
40
+ return new GoodVibesSdkError(`${context}: ${describeUnknownTransportError(error)}`, {
41
+ category: 'network',
42
+ source: 'transport',
43
+ recoverable: true,
44
+ });
45
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"event-envelope.d.ts","sourceRoot":"","sources":["../src/event-envelope.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,aAAa,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ;IAC3D,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAA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,EAAE,QAAQ,CAAC,CAYhC"}
@@ -1,11 +1,9 @@
1
- function generateTraceId() {
2
- return crypto.randomUUID();
3
- }
1
+ import { createUuidV4 } from './uuid.js';
4
2
  export function createEventEnvelope(type, payload, context) {
5
3
  return Object.freeze({
6
4
  type,
7
5
  ts: Date.now(),
8
- traceId: context.traceId ?? generateTraceId(),
6
+ traceId: context.traceId ?? createUuidV4(),
9
7
  sessionId: context.sessionId,
10
8
  turnId: context.turnId,
11
9
  agentId: context.agentId,
@@ -1 +1 @@
1
- {"version":3,"file":"event-feeds.d.ts","sourceRoot":"","sources":["../src/event-feeds.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,KAAK,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3C,KAAK,YAAY,CACf,MAAM,SAAS,SAAS,EACxB,KAAK,SAAS,MAAM,CAAC,MAAM,CAAC,IAC1B,OAAO,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC;AAErC,MAAM,WAAW,gBAAgB,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS;IACpE,EAAE,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,CAAC,EAC7B,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,IAAI,GACvD,MAAM,IAAI,CAAC;IACd,UAAU,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,CAAC,EACrC,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC,KAAK,EAAE,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,KAAK,IAAI,GAC9E,MAAM,IAAI,CAAC;CACf;AAED,MAAM,MAAM,iBAAiB,CAC3B,OAAO,SAAS,MAAM,EACtB,MAAM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AuB,CACrC,OAAO,SAAS,MAAM,EACtB,MAAM,SAAS,SAAS,EAExB,OAAO,EAAE,SAAS,OAAO,EAAE,EAC3B,UAAU,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,gBAAgB,CAAC,MAAM,CAAC,GACxD,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAYpC"}
package/dist/index.d.ts CHANGED
@@ -4,4 +4,13 @@ export type { RuntimeEventFeed, RuntimeEventFeeds, EnvelopeSubscriber } from './
4
4
  export { createRuntimeEventFeed, createRuntimeEventFeeds } from './event-feeds.js';
5
5
  export type { ClientTransport } from './client-transport.js';
6
6
  export { createClientTransport } from './client-transport.js';
7
+ export type { DirectClientTransport } from './direct.js';
8
+ export { createDirectClientTransport } from './direct.js';
9
+ export type { TransportObserver, TransportActivityInfo } from './observer.js';
10
+ export { invokeTransportObserver } from './observer.js';
11
+ export type { TransportContext, TransportMiddleware } from './middleware.js';
12
+ export { composeMiddleware } from './middleware.js';
13
+ export { injectTraceparent, injectTraceparentAsync } from './otel.js';
14
+ export { createUuidV4 } from './uuid.js';
15
+ export { describeUnknownTransportError, isAbortError, transportErrorFromUnknown } from './errors.js';
7
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AACnF,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AACnF,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC1D,YAAY,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,9 @@
1
1
  export { createEventEnvelope } from './event-envelope.js';
2
2
  export { createRuntimeEventFeed, createRuntimeEventFeeds } from './event-feeds.js';
3
3
  export { createClientTransport } from './client-transport.js';
4
+ export { createDirectClientTransport } from './direct.js';
5
+ export { invokeTransportObserver } from './observer.js';
6
+ export { composeMiddleware } from './middleware.js';
7
+ export { injectTraceparent, injectTraceparentAsync } from './otel.js';
8
+ export { createUuidV4 } from './uuid.js';
9
+ export { describeUnknownTransportError, isAbortError, transportErrorFromUnknown } from './errors.js';
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Transport middleware (Koa-style) for the HTTP transport layer.
3
+ *
4
+ * Middleware functions wrap the real fetch call and receive a mutable context
5
+ * object. Calling `next()` executes the next middleware in the chain (or the
6
+ * real fetch at the end). After `await next()` returns, `ctx.response` and
7
+ * `ctx.durationMs` are populated; `ctx.error` is set if the fetch threw.
8
+ *
9
+ * @example
10
+ * sdk.use(async (ctx, next) => {
11
+ * console.log('->', ctx.method, ctx.url);
12
+ * await next();
13
+ * console.log('<-', ctx.response?.status, ctx.durationMs, 'ms');
14
+ * });
15
+ */
16
+ /**
17
+ * Mutable context object passed through the middleware chain.
18
+ * Fields are populated progressively: request fields are set before the chain
19
+ * runs; response fields are set after the real fetch resolves.
20
+ */
21
+ export interface TransportContext {
22
+ /** HTTP method (uppercased). */
23
+ method: string;
24
+ /** Fully-qualified request URL. */
25
+ url: string;
26
+ /** Request headers (mutable — middleware may add/override). */
27
+ headers: Record<string, string>;
28
+ /** Request body (undefined for GET/HEAD). */
29
+ body: unknown;
30
+ /** Per-request options forwarded from the caller. */
31
+ options: {
32
+ readonly signal?: AbortSignal;
33
+ readonly retry?: unknown;
34
+ [key: string]: unknown;
35
+ };
36
+ /** AbortSignal for the request. Propagated from caller options. */
37
+ signal?: AbortSignal;
38
+ /** The HTTP response object — set after `next()` resolves successfully. */
39
+ response?: Response;
40
+ /** Round-trip duration in milliseconds — set after `next()` resolves. */
41
+ durationMs?: number;
42
+ /** Error thrown by the fetch or a downstream middleware — set on failure. */
43
+ error?: unknown;
44
+ /**
45
+ * Set to `true` when the error originated from within the middleware chain
46
+ * (as opposed to from the real fetch). Used by the transport to wrap
47
+ * middleware errors as `SDKError{kind:'unknown'}`.
48
+ */
49
+ middlewareError?: boolean;
50
+ /**
51
+ * Name (or index) of the middleware that was active when the error occurred.
52
+ * Set alongside `middlewareError` for error identity in cause objects.
53
+ */
54
+ activeMiddlewareName?: string;
55
+ }
56
+ /**
57
+ * A transport middleware function.
58
+ *
59
+ * @param ctx - Shared mutable context for the request/response cycle.
60
+ * @param next - Calls the next middleware (or the real fetch at the end).
61
+ */
62
+ export type TransportMiddleware = (ctx: TransportContext, next: () => Promise<void>) => Promise<void>;
63
+ /**
64
+ * Build a composed middleware executor from an ordered array of middleware.
65
+ * The last item in the chain calls the real fetch via `innerFetch`.
66
+ *
67
+ * Returns a function that:
68
+ * 1. Mutates `ctx.headers` with any header overrides from middleware.
69
+ * 2. Calls through the chain.
70
+ * 3. Sets `ctx.response`, `ctx.durationMs`, or `ctx.error` on the context.
71
+ *
72
+ * @param middleware - Ordered list of middleware functions.
73
+ * @param innerFetch - The real fetch call wrapped at the end of the chain.
74
+ */
75
+ export declare function composeMiddleware(middleware: readonly TransportMiddleware[], innerFetch: (ctx: TransportContext) => Promise<Response>): (ctx: TransportContext) => Promise<void>;
76
+ //# sourceMappingURL=middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,6CAA6C;IAC7C,IAAI,EAAE,OAAO,CAAC;IACd,qDAAqD;IACrD,OAAO,EAAE;QACP,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;QAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QACzB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,mEAAmE;IACnE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAChC,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KACtB,OAAO,CAAC,IAAI,CAAC,CAAC;AAInB;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,SAAS,mBAAmB,EAAE,EAC1C,UAAU,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,OAAO,CAAC,QAAQ,CAAC,GACvD,CAAC,GAAG,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAwD1C"}
@@ -0,0 +1,71 @@
1
+ import { GoodVibesSdkError } from '@pellux/goodvibes-errors';
2
+ const MAX_MIDDLEWARE_DEPTH = 128;
3
+ /**
4
+ * Build a composed middleware executor from an ordered array of middleware.
5
+ * The last item in the chain calls the real fetch via `innerFetch`.
6
+ *
7
+ * Returns a function that:
8
+ * 1. Mutates `ctx.headers` with any header overrides from middleware.
9
+ * 2. Calls through the chain.
10
+ * 3. Sets `ctx.response`, `ctx.durationMs`, or `ctx.error` on the context.
11
+ *
12
+ * @param middleware - Ordered list of middleware functions.
13
+ * @param innerFetch - The real fetch call wrapped at the end of the chain.
14
+ */
15
+ export function composeMiddleware(middleware, innerFetch) {
16
+ if (middleware.length > MAX_MIDDLEWARE_DEPTH) {
17
+ throw new GoodVibesSdkError(`Transport middleware chain exceeds the maximum depth of ${MAX_MIDDLEWARE_DEPTH}.`, {
18
+ category: 'config',
19
+ source: 'transport',
20
+ recoverable: false,
21
+ });
22
+ }
23
+ return async (ctx) => {
24
+ let index = -1;
25
+ const dispatch = async (i) => {
26
+ if (i > MAX_MIDDLEWARE_DEPTH) {
27
+ throw new GoodVibesSdkError(`Transport middleware recursion exceeded the maximum depth of ${MAX_MIDDLEWARE_DEPTH}.`, {
28
+ category: 'internal',
29
+ source: 'transport',
30
+ recoverable: false,
31
+ });
32
+ }
33
+ if (i <= index) {
34
+ throw new GoodVibesSdkError('next() called multiple times in transport middleware', {
35
+ category: 'protocol',
36
+ source: 'transport',
37
+ recoverable: false,
38
+ });
39
+ }
40
+ index = i;
41
+ if (i < middleware.length) {
42
+ const mw = middleware[i];
43
+ const mwName = mw.name || String(i);
44
+ ctx.activeMiddlewareName = mwName;
45
+ try {
46
+ await mw(ctx, () => dispatch(i + 1));
47
+ }
48
+ catch (err) {
49
+ // Mark that the error originated from this middleware (not the real fetch).
50
+ ctx.middlewareError = true;
51
+ ctx.activeMiddlewareName = mwName;
52
+ throw err;
53
+ }
54
+ }
55
+ else {
56
+ // End of chain — execute the real fetch.
57
+ const sendAt = Date.now();
58
+ try {
59
+ ctx.response = await innerFetch(ctx);
60
+ ctx.durationMs = Date.now() - sendAt;
61
+ }
62
+ catch (err) {
63
+ ctx.error = err;
64
+ ctx.durationMs = Date.now() - sendAt;
65
+ throw err;
66
+ }
67
+ }
68
+ };
69
+ await dispatch(0);
70
+ };
71
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * TransportObserver — first-class observability interface at the transport layer.
3
+ *
4
+ * Defined here (transport-core) so that HTTP and realtime sibling transports can
5
+ * accept it through their shared options types without depending on the SDK layer.
6
+ * `SDKObserver` in `@pellux/goodvibes-sdk` extends this interface and adds
7
+ * SDK-level callbacks (`onEvent`, `onAuthTransition`).
8
+ *
9
+ * All methods are optional. Observer exceptions are always swallowed via
10
+ * `invokeObserver` — they must never propagate into transport control flow.
11
+ */
12
+ /**
13
+ * Transport activity metadata surfaced at request/response boundaries.
14
+ */
15
+ export interface TransportActivityInfo {
16
+ /** Direction: `'send'` before the request, `'recv'` after a response. */
17
+ readonly direction: 'send' | 'recv';
18
+ /** The full URL of the request. */
19
+ readonly url: string;
20
+ /** HTTP response status code (only present on `'recv'`). */
21
+ readonly status?: number;
22
+ /** Round-trip duration in milliseconds (only present on `'recv'`). */
23
+ readonly durationMs?: number;
24
+ /** Transport kind. */
25
+ readonly kind?: 'http' | 'sse' | 'ws';
26
+ }
27
+ /**
28
+ * Minimal observer interface at the transport layer.
29
+ *
30
+ * Implement any subset; the SDK works identically whether an observer is
31
+ * present or not. All call sites are wrapped in a silent try/catch.
32
+ */
33
+ export interface TransportObserver {
34
+ /**
35
+ * Called when the SDK catches and is about to rethrow a transport error.
36
+ * The error is still rethrown; this is notification only.
37
+ */
38
+ onError?(err: Error): void;
39
+ /**
40
+ * Called at HTTP/SSE/WebSocket transport boundaries.
41
+ * - `'send'` fires before the request is dispatched.
42
+ * - `'recv'` fires after a response is received (status + duration included).
43
+ */
44
+ onTransportActivity?(activity: TransportActivityInfo): void;
45
+ }
46
+ /**
47
+ * Safely invoke an observer method. Observer errors are swallowed so they
48
+ * never disrupt transport control flow.
49
+ *
50
+ * @param fn - Zero-argument thunk wrapping the observer call.
51
+ */
52
+ export declare function invokeTransportObserver(fn: () => void): void;
53
+ //# sourceMappingURL=observer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observer.d.ts","sourceRoot":"","sources":["../src/observer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,yEAAyE;IACzE,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC,mCAAmC;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,sEAAsE;IACtE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,sBAAsB;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;CACvC;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,CAAC;IAE3B;;;;OAIG;IACH,mBAAmB,CAAC,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI,CAAC;CAC7D;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAO5D"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * TransportObserver — first-class observability interface at the transport layer.
3
+ *
4
+ * Defined here (transport-core) so that HTTP and realtime sibling transports can
5
+ * accept it through their shared options types without depending on the SDK layer.
6
+ * `SDKObserver` in `@pellux/goodvibes-sdk` extends this interface and adds
7
+ * SDK-level callbacks (`onEvent`, `onAuthTransition`).
8
+ *
9
+ * All methods are optional. Observer exceptions are always swallowed via
10
+ * `invokeObserver` — they must never propagate into transport control flow.
11
+ */
12
+ /**
13
+ * Safely invoke an observer method. Observer errors are swallowed so they
14
+ * never disrupt transport control flow.
15
+ *
16
+ * @param fn - Zero-argument thunk wrapping the observer call.
17
+ */
18
+ export function invokeTransportObserver(fn) {
19
+ try {
20
+ fn();
21
+ }
22
+ catch (error) {
23
+ void error;
24
+ // Observer errors must not propagate into transport logic.
25
+ }
26
+ }
package/dist/otel.d.ts ADDED
@@ -0,0 +1,64 @@
1
+ /**
2
+ * OpenTelemetry traceparent/tracestate propagation helper.
3
+ *
4
+ * Zero-dependency: detects `@opentelemetry/api` at runtime.
5
+ * If OTel is absent, all functions are no-ops.
6
+ *
7
+ * Dynamic detection uses an indirect import pattern to prevent bundlers
8
+ * (esbuild, Rollup, Miniflare/workerd) from flagging the import as an
9
+ * unresolvable dynamic specifier. The module name is never a literal in
10
+ * any import() call that the bundler sees.
11
+ *
12
+ * W3C Trace Context spec: https://www.w3.org/TR/trace-context/
13
+ */
14
+ interface SpanContext {
15
+ traceId: string;
16
+ spanId: string;
17
+ traceFlags: number;
18
+ traceState?: {
19
+ serialize(): string;
20
+ } | null;
21
+ }
22
+ interface Span {
23
+ spanContext(): SpanContext;
24
+ }
25
+ interface OtelApi {
26
+ trace: {
27
+ getActiveSpan(): Span | undefined;
28
+ };
29
+ }
30
+ /**
31
+ * Set the OTel module override for testing. Pass `undefined` to clear.
32
+ * Calling this bypasses dynamic import and require-based detection.
33
+ *
34
+ * @internal — for testing only, do NOT use in production code.
35
+ */
36
+ export declare function setOtelModuleOverride(api: OtelApi | null | undefined): void;
37
+ /**
38
+ * Get the current OTel module override (for test inspection).
39
+ * @internal
40
+ */
41
+ export declare function getOtelModuleOverride(): OtelApi | null | undefined;
42
+ /**
43
+ * Reset both the module-level cache and the test injection seam.
44
+ * Call this in `afterEach` when using `setOtelModuleOverride` in tests.
45
+ *
46
+ * @internal — for testing only.
47
+ */
48
+ export declare function __resetOtelCache(): void;
49
+ /**
50
+ * Inject W3C Trace Context headers (`traceparent`, `tracestate`) if an active
51
+ * OTel span is available. Synchronous; uses require-based detection.
52
+ *
53
+ * @param headers - Mutable header record to augment in-place.
54
+ */
55
+ export declare function injectTraceparent(headers: Record<string, string>): void;
56
+ /**
57
+ * Async variant — probes OTel via dynamic import on first call, then caches.
58
+ * Use for SSE/WS connection setup where async is acceptable.
59
+ *
60
+ * @param headers - Mutable header record to augment in-place.
61
+ */
62
+ export declare function injectTraceparentAsync(headers: Record<string, string>): Promise<void>;
63
+ export {};
64
+ //# sourceMappingURL=otel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../src/otel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,UAAU,WAAW;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE;QAAE,SAAS,IAAI,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAC7C;AAED,UAAU,IAAI;IACZ,WAAW,IAAI,WAAW,CAAC;CAC5B;AAED,UAAU,OAAO;IACf,KAAK,EAAE;QACL,aAAa,IAAI,IAAI,GAAG,SAAS,CAAC;KACnC,CAAC;CACH;AAQD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAE3E;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,GAAG,IAAI,GAAG,SAAS,CAElE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC;AAoDD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAiBvE;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB3F"}
package/dist/otel.js ADDED
@@ -0,0 +1,152 @@
1
+ /**
2
+ * OpenTelemetry traceparent/tracestate propagation helper.
3
+ *
4
+ * Zero-dependency: detects `@opentelemetry/api` at runtime.
5
+ * If OTel is absent, all functions are no-ops.
6
+ *
7
+ * Dynamic detection uses an indirect import pattern to prevent bundlers
8
+ * (esbuild, Rollup, Miniflare/workerd) from flagging the import as an
9
+ * unresolvable dynamic specifier. The module name is never a literal in
10
+ * any import() call that the bundler sees.
11
+ *
12
+ * W3C Trace Context spec: https://www.w3.org/TR/trace-context/
13
+ */
14
+ /** Cached result of OTel detection. `null` = not available. `undefined` = not yet probed. */
15
+ let otelApi = undefined;
16
+ /** Internal override value for the test injection seam. */
17
+ let _otelModuleOverride = undefined;
18
+ /**
19
+ * Set the OTel module override for testing. Pass `undefined` to clear.
20
+ * Calling this bypasses dynamic import and require-based detection.
21
+ *
22
+ * @internal — for testing only, do NOT use in production code.
23
+ */
24
+ export function setOtelModuleOverride(api) {
25
+ _otelModuleOverride = api;
26
+ }
27
+ /**
28
+ * Get the current OTel module override (for test inspection).
29
+ * @internal
30
+ */
31
+ export function getOtelModuleOverride() {
32
+ return _otelModuleOverride;
33
+ }
34
+ /**
35
+ * Reset both the module-level cache and the test injection seam.
36
+ * Call this in `afterEach` when using `setOtelModuleOverride` in tests.
37
+ *
38
+ * @internal — for testing only.
39
+ */
40
+ export function __resetOtelCache() {
41
+ otelApi = undefined;
42
+ _otelModuleOverride = undefined;
43
+ }
44
+ /**
45
+ * Dynamic import that is opaque to bundlers.
46
+ * `new Function(...)` is not statically analysed for import() specifiers.
47
+ */
48
+ function dynamicImport(moduleName) {
49
+ // Using Function constructor prevents bundler static analysis of import().
50
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
51
+ return new Function('m', 'return import(m)')(moduleName);
52
+ }
53
+ async function probeOtel() {
54
+ // Test injection seam takes highest priority.
55
+ if (_otelModuleOverride !== undefined)
56
+ return _otelModuleOverride;
57
+ if (otelApi !== undefined)
58
+ return otelApi;
59
+ try {
60
+ const mod = await dynamicImport('@opentelemetry/api');
61
+ otelApi = mod;
62
+ }
63
+ catch (error) {
64
+ void error;
65
+ otelApi = null;
66
+ }
67
+ return otelApi;
68
+ }
69
+ function probeOtelSync() {
70
+ // Test injection seam takes highest priority.
71
+ if (_otelModuleOverride !== undefined)
72
+ return _otelModuleOverride;
73
+ if (otelApi !== undefined)
74
+ return otelApi;
75
+ try {
76
+ // Use globalThis.require via indirect reference to avoid bundler module resolution.
77
+ const nodeRequire = typeof globalThis !== 'undefined'
78
+ ? globalThis.require
79
+ : undefined;
80
+ if (typeof nodeRequire === 'function') {
81
+ otelApi = nodeRequire('@opentelemetry/api');
82
+ }
83
+ else {
84
+ otelApi = null;
85
+ }
86
+ }
87
+ catch (error) {
88
+ void error;
89
+ otelApi = null;
90
+ }
91
+ return otelApi;
92
+ }
93
+ function buildTraceparent(ctx) {
94
+ const flags = (ctx.traceFlags & 0xff).toString(16).padStart(2, '0');
95
+ return `00-${ctx.traceId}-${ctx.spanId}-${flags}`;
96
+ }
97
+ /**
98
+ * Inject W3C Trace Context headers (`traceparent`, `tracestate`) if an active
99
+ * OTel span is available. Synchronous; uses require-based detection.
100
+ *
101
+ * @param headers - Mutable header record to augment in-place.
102
+ */
103
+ export function injectTraceparent(headers) {
104
+ const api = probeOtelSync();
105
+ if (!api)
106
+ return;
107
+ try {
108
+ const span = api.trace.getActiveSpan();
109
+ if (!span)
110
+ return;
111
+ const ctx = span.spanContext();
112
+ if (!ctx.traceId || !ctx.spanId)
113
+ return;
114
+ headers['traceparent'] = buildTraceparent(ctx);
115
+ const traceState = ctx.traceState?.serialize();
116
+ if (traceState) {
117
+ headers['tracestate'] = traceState;
118
+ }
119
+ }
120
+ catch (error) {
121
+ void error;
122
+ // Never let OTel errors propagate into transport logic.
123
+ }
124
+ }
125
+ /**
126
+ * Async variant — probes OTel via dynamic import on first call, then caches.
127
+ * Use for SSE/WS connection setup where async is acceptable.
128
+ *
129
+ * @param headers - Mutable header record to augment in-place.
130
+ */
131
+ export async function injectTraceparentAsync(headers) {
132
+ const api = await probeOtel();
133
+ if (!api)
134
+ return;
135
+ try {
136
+ const span = api.trace.getActiveSpan();
137
+ if (!span)
138
+ return;
139
+ const ctx = span.spanContext();
140
+ if (!ctx.traceId || !ctx.spanId)
141
+ return;
142
+ headers['traceparent'] = buildTraceparent(ctx);
143
+ const traceState = ctx.traceState?.serialize();
144
+ if (traceState) {
145
+ headers['tracestate'] = traceState;
146
+ }
147
+ }
148
+ catch (error) {
149
+ void error;
150
+ // Never let OTel errors propagate into transport logic.
151
+ }
152
+ }
package/dist/uuid.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function createUuidV4(): string;
2
+ //# sourceMappingURL=uuid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../src/uuid.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,IAAI,MAAM,CAmBrC"}
package/dist/uuid.js ADDED
@@ -0,0 +1,22 @@
1
+ import { GoodVibesSdkError } from '@pellux/goodvibes-errors';
2
+ export function createUuidV4() {
3
+ if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
4
+ return crypto.randomUUID();
5
+ }
6
+ const bytes = new Uint8Array(16);
7
+ if (typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function') {
8
+ crypto.getRandomValues(bytes);
9
+ }
10
+ else {
11
+ throw new GoodVibesSdkError('Secure random UUID generation is unavailable in this runtime.', {
12
+ category: 'config',
13
+ source: 'transport',
14
+ recoverable: false,
15
+ hint: 'Run GoodVibes in a runtime with crypto.randomUUID() or crypto.getRandomValues().',
16
+ });
17
+ }
18
+ bytes[6] = (bytes[6] & 0x0f) | 0x40;
19
+ bytes[8] = (bytes[8] & 0x3f) | 0x80;
20
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');
21
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
22
+ }
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@pellux/goodvibes-transport-core",
3
- "version": "0.18.3",
3
+ "version": "0.30.1",
4
+ "engines": {
5
+ "node": ">=20.0.0"
6
+ },
4
7
  "description": "Shared GoodVibes client transport primitives for direct, HTTP, and realtime integrations.",
5
8
  "type": "module",
6
9
  "main": "./dist/index.js",
@@ -10,12 +13,43 @@
10
13
  "types": "./dist/index.d.ts",
11
14
  "import": "./dist/index.js"
12
15
  },
16
+ "./client-transport": {
17
+ "types": "./dist/client-transport.d.ts",
18
+ "import": "./dist/client-transport.js"
19
+ },
20
+ "./event-envelope": {
21
+ "types": "./dist/event-envelope.d.ts",
22
+ "import": "./dist/event-envelope.js"
23
+ },
24
+ "./event-feeds": {
25
+ "types": "./dist/event-feeds.d.ts",
26
+ "import": "./dist/event-feeds.js"
27
+ },
28
+ "./middleware": {
29
+ "types": "./dist/middleware.d.ts",
30
+ "import": "./dist/middleware.js"
31
+ },
32
+ "./observer": {
33
+ "types": "./dist/observer.d.ts",
34
+ "import": "./dist/observer.js"
35
+ },
36
+ "./otel": {
37
+ "types": "./dist/otel.d.ts",
38
+ "import": "./dist/otel.js"
39
+ },
40
+ "./uuid": {
41
+ "types": "./dist/uuid.d.ts",
42
+ "import": "./dist/uuid.js"
43
+ },
13
44
  "./package.json": "./package.json"
14
45
  },
15
46
  "files": [
16
47
  "dist"
17
48
  ],
18
49
  "sideEffects": false,
50
+ "dependencies": {
51
+ "@pellux/goodvibes-errors": "0.30.1"
52
+ },
19
53
  "license": "MIT",
20
54
  "repository": {
21
55
  "type": "git",