stitchkit 0.47.0 → 0.48.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.
Files changed (44) hide show
  1. package/README.md +9 -0
  2. package/dist/browser/client.d.ts +3 -0
  3. package/dist/browser/client.d.ts.map +1 -1
  4. package/dist/browser/http.d.ts +7 -4
  5. package/dist/browser/http.d.ts.map +1 -1
  6. package/dist/cli.js +3 -2
  7. package/dist/contract/define.d.ts +11 -3
  8. package/dist/contract/define.d.ts.map +1 -1
  9. package/dist/{index-nrytvb30.js → index-03j2t778.js} +5 -8
  10. package/dist/{index-kp8xamqp.js → index-0hj37z43.js} +4 -2
  11. package/dist/index-48ffdxgk.js +6 -0
  12. package/dist/index-h05ygjqx.js +149 -0
  13. package/dist/{index-ee621cmy.js → index-jewp9r0a.js} +5 -139
  14. package/dist/index-p9d4cxt5.js +436 -0
  15. package/dist/{index-44xysy8r.js → index-ts21eyz4.js} +141 -19
  16. package/dist/{index-8ekq6res.js → index-v58mwa19.js} +4 -2
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +40 -27
  20. package/dist/node.d.ts +1 -1
  21. package/dist/node.d.ts.map +1 -1
  22. package/dist/node.js +8 -3
  23. package/dist/observability/audit.d.ts +4 -1
  24. package/dist/observability/audit.d.ts.map +1 -1
  25. package/dist/observability/index.d.ts +1 -0
  26. package/dist/observability/index.d.ts.map +1 -1
  27. package/dist/observability/index.js +150 -16
  28. package/dist/observability/status.d.ts +105 -0
  29. package/dist/observability/status.d.ts.map +1 -0
  30. package/dist/server/implement.d.ts +16 -6
  31. package/dist/server/implement.d.ts.map +1 -1
  32. package/dist/server/index.d.ts +1 -1
  33. package/dist/server/index.d.ts.map +1 -1
  34. package/dist/server/index.js +14 -6
  35. package/dist/server/router.d.ts +4 -1
  36. package/dist/server/router.d.ts.map +1 -1
  37. package/dist/testing.d.ts +34 -0
  38. package/dist/testing.d.ts.map +1 -0
  39. package/dist/testing.js +36 -0
  40. package/dist/tools/mcp.d.ts +1 -0
  41. package/dist/tools/mcp.d.ts.map +1 -1
  42. package/dist/tools.js +21 -430
  43. package/llms-full.txt +177 -22
  44. package/package.json +7 -3
@@ -1,7 +1,9 @@
1
1
  import {
2
- isRecord,
3
2
  isUnsafeKey
4
- } from "./index-ee621cmy.js";
3
+ } from "./index-jewp9r0a.js";
4
+ import {
5
+ isRecord
6
+ } from "./index-h05ygjqx.js";
5
7
 
6
8
  // src/observability/sanitize.ts
7
9
  var SENSITIVE_WORDS = new Set([
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { type ClientConfig, type ClientContract, type ClientRegistryValue, type ContractClientConfig, contractEndpointMatchers, createClient, createClients, createScopedClients, createScopedUrlBuilders, createUrlBuilder, createUrlBuilders, type PathPrefixArgs, type RegistryScope, type ScopeClientConfigs, type ScopedClientRegistry, type ScopedUrlBuilderRegistry, type UrlBuilderConfig, } from './browser/client';
1
+ export { type ClientConfig, type ClientContract, type ClientFetch, type ClientRegistryValue, type ContractClientConfig, contractEndpointMatchers, createClient, createClients, createScopedClients, createScopedUrlBuilders, createUrlBuilder, createUrlBuilders, type PathPrefixArgs, type RegistryScope, type ScopeClientConfigs, type ScopedClientRegistry, type ScopedUrlBuilderRegistry, type UrlBuilderConfig, } from './browser/client';
2
2
  export { ApiError, type ApiEvent, type ApiEventListener, type ConfiguredHttpClient, createHttpClient, type HeaderProvider, type HttpClient, type HttpClientConfig, type RequestOptions, type UnauthorizedMatcher, } from './browser/http';
3
3
  export type { RealtimeClient, RealtimeClientOptions, SocketEventMap, SocketIOClient, SocketIOClientConfig, } from './browser/socket-io';
4
4
  export { createRealtimeClient, createSocketIOClient } from './browser/socket-io';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACx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ACvB,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,QAAQ,EACR,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,KAAK,eAAe,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClE,cAAc,YAAY,CAAC;AAC3B,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG7C,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,YAAY,GAClB,MAAM,uBAAuB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -295,7 +295,11 @@ function joinClientBaseUrl(baseUrl, relativeUrl) {
295
295
  }
296
296
 
297
297
  // src/browser/http.ts
298
- import ky, { isHTTPError } from "ky";
298
+ import ky, {
299
+ isHTTPError,
300
+ isNetworkError,
301
+ isTimeoutError
302
+ } from "ky";
299
303
 
300
304
  // src/observability/trace.ts
301
305
  var TRACEPARENT_RE = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(.*)$/i;
@@ -371,6 +375,15 @@ class ApiError extends Error {
371
375
  return error instanceof ApiError;
372
376
  }
373
377
  }
378
+ function shouldRetryBunNetworkError(error) {
379
+ if (ApiError.is(error) || isHTTPError(error) || isNetworkError(error) || isTimeoutError(error) || error instanceof RequestCancellationError || error instanceof DOMException && (error.name === "AbortError" || error.name === "TimeoutError")) {
380
+ return;
381
+ }
382
+ if (!(error instanceof Error))
383
+ return;
384
+ const code = Object.getOwnPropertyDescriptor(error, "code");
385
+ return code && "value" in code && code.value === "ConnectionRefused" ? true : undefined;
386
+ }
374
387
  function parseApiErrorBody(body) {
375
388
  if (!isRecord(body) || !isRecord(body.error))
376
389
  return null;
@@ -404,7 +417,8 @@ function createHttpClient(config) {
404
417
  retry: {
405
418
  limit: config.retry?.limit ?? 2,
406
419
  methods: config.retry?.methods ?? ["get"],
407
- statusCodes: config.retry?.statusCodes ?? []
420
+ statusCodes: config.retry?.statusCodes ?? [],
421
+ shouldRetry: ({ error }) => shouldRetryBunNetworkError(error)
408
422
  },
409
423
  hooks: {
410
424
  beforeRequest: [
@@ -578,11 +592,11 @@ function contractEndpointMatchers(contract, endpointNames, contractConfig) {
578
592
  }
579
593
  function createClient(contract, configOrClient, contractConfig) {
580
594
  const client = {};
581
- const makeMethod = isHttpAdapter(configOrClient) ? (endpoint) => createHttpMethod(endpoint, contract.meta.prefix, configOrClient, contractConfig) : (endpoint) => createFetchMethod(endpoint, contract.meta.prefix, configOrClient, contractConfig);
595
+ const makeExecutor = isHttpAdapter(configOrClient) ? (endpoint) => createHttpExecutor(endpoint, contract.meta.prefix, configOrClient, contractConfig) : (endpoint) => createFetchExecutor(endpoint, contract.meta.prefix, configOrClient, contractConfig);
582
596
  for (const [key, endpoint] of typedEntries(contract.endpoints)) {
583
597
  if (endpoint.expose && !endpoint.expose.includes("HTTP"))
584
598
  continue;
585
- setClientMethod(client, key, makeMethod(endpoint));
599
+ setClientMethod(client, key, createEndpointMethod(endpoint, makeExecutor(endpoint), contractConfig));
586
600
  }
587
601
  return client;
588
602
  }
@@ -623,11 +637,23 @@ function isHttpAdapter(value) {
623
637
  function setClientMethod(target, key, method) {
624
638
  target[key] = method;
625
639
  }
626
- function createHttpMethod(endpoint, prefix, client, config) {
640
+ function createEndpointMethod(endpoint, execute, contractConfig) {
641
+ const hasScopedArguments = (contractConfig?.stripPrefixKeys?.length ?? 0) > 0;
642
+ if (endpointHasArguments(endpoint) || hasScopedArguments) {
643
+ const method2 = (requestArgs) => execute(readClientRequestArgs(requestArgs), undefined);
644
+ return Object.assign(method2, {
645
+ withOptions: (requestArgs, options) => execute(readClientRequestArgs(requestArgs), readClientRequestOptions(options))
646
+ });
647
+ }
648
+ const method = () => execute({}, undefined);
649
+ return Object.assign(method, {
650
+ withOptions: (options) => execute({}, readClientRequestOptions(options))
651
+ });
652
+ }
653
+ function createHttpExecutor(endpoint, prefix, client, config) {
627
654
  const httpMethod = endpoint.method.toLowerCase();
628
- return (...args) => {
629
- const { requestArgs: firstArg, options } = splitClientCall(endpoint, args, config);
630
- const plan = planClientRequest(endpoint, prefix, firstArg, config);
655
+ return (requestArgs, options) => {
656
+ const plan = planClientRequest(endpoint, prefix, requestArgs, config);
631
657
  if (endpoint.multipart) {
632
658
  if (httpMethod === "get" || httpMethod === "head" || httpMethod === "delete") {
633
659
  throw new Error(`Multipart endpoint ${endpoint.method} ${endpoint.path} must be POST / PUT / PATCH`);
@@ -644,9 +670,9 @@ function createHttpMethod(endpoint, prefix, client, config) {
644
670
  return withOutput(endpoint, client[httpMethod](plan.relativeUrl, Object.keys(plan.remainingArgs).length > 0 ? plan.remainingArgs : undefined, withTimeout(options, endpoint)));
645
671
  };
646
672
  }
647
- function createFetchMethod(endpoint, prefix, config, contractConfig) {
648
- return async (...callArgs) => {
649
- const { requestArgs, options } = splitClientCall(endpoint, callArgs, contractConfig);
673
+ function createFetchExecutor(endpoint, prefix, config, contractConfig) {
674
+ const executeFetch = config.fetch ?? globalThis.fetch;
675
+ return async (requestArgs, options) => {
650
676
  const plan = planClientRequest(endpoint, prefix, requestArgs, contractConfig);
651
677
  const url = joinClientBaseUrl(config.baseUrl, plan.relativeUrl);
652
678
  const headers = {
@@ -660,7 +686,7 @@ function createFetchMethod(endpoint, prefix, config, contractConfig) {
660
686
  try {
661
687
  return await cancellation.run(async (signal) => {
662
688
  const body = endpoint.multipart ? buildMultipartForm(endpoint.multipart, plan.remainingArgs) : hasBody ? JSON.stringify(plan.remainingArgs) : undefined;
663
- const res = await fetch(url, {
689
+ const res = await executeFetch(url, {
664
690
  method: endpoint.method,
665
691
  headers,
666
692
  credentials: config.credentials,
@@ -695,26 +721,13 @@ function createFetchMethod(endpoint, prefix, config, contractConfig) {
695
721
  function endpointHasArguments(endpoint) {
696
722
  return Boolean(endpoint.params || endpoint.input || endpoint.multipart);
697
723
  }
698
- function splitClientCall(endpoint, args, contractConfig) {
699
- const hasScopedArguments = (contractConfig?.stripPrefixKeys?.length ?? 0) > 0;
700
- if (!endpointHasArguments(endpoint) && !hasScopedArguments) {
701
- return {
702
- requestArgs: {},
703
- options: readClientRequestOptions(args[0])
704
- };
705
- }
706
- const requestArgs = args[0];
724
+ function readClientRequestArgs(requestArgs) {
707
725
  if (requestArgs !== undefined && !isRecord(requestArgs)) {
708
726
  throw new TypeError("Endpoint arguments must be an object");
709
727
  }
710
- return {
711
- requestArgs: requestArgs ?? {},
712
- options: readClientRequestOptions(args[1])
713
- };
728
+ return requestArgs ?? {};
714
729
  }
715
730
  function readClientRequestOptions(value) {
716
- if (value === undefined)
717
- return;
718
731
  if (!isRecord(value))
719
732
  throw new TypeError("Client request options must be an object");
720
733
  const signal = value.signal;
package/dist/node.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  */
7
7
  export { AppError, appError, badRequest, conflict, forbidden, notFound, rateLimited, unauthorized, } from './contract';
8
8
  export { createHandler } from './server/create';
9
- export { createImplement, implement } from './server/implement';
9
+ export { createImplement, createImplementRegistry, type ExactRegistryHandlers, type ImplementationRegistry, implement, implementRegistry, type RegistryHandlers, } from './server/implement';
10
10
  export type { LogFormat } from './server/logger';
11
11
  export { type NodeServerConfig, type NodeServerHandle, serveNode } from './server/node';
12
12
  export { bindRealtimeServer, type RealtimeServer, type RealtimeServerConnection, type RealtimeServerHandle, } from './server/realtime';
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EACL,kBAAkB,EAClB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,wBAAwB,IAAI,oBAAoB,EAChD,KAAK,wBAAwB,IAAI,oBAAoB,EACrD,KAAK,oBAAoB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,UAAU,EACV,QAAQ,EACR,eAAe,EACf,UAAU,GACX,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,SAAS,EACT,iBAAiB,EACjB,KAAK,gBAAgB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EACL,kBAAkB,EAClB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,wBAAwB,IAAI,oBAAoB,EAChD,KAAK,wBAAwB,IAAI,oBAAoB,EACrD,KAAK,oBAAoB,GAC1B,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,UAAU,EACV,QAAQ,EACR,eAAe,EACf,UAAU,GACX,MAAM,gBAAgB,CAAC"}
package/dist/node.js CHANGED
@@ -2,9 +2,11 @@ import {
2
2
  bindRealtimeServer,
3
3
  createHandler,
4
4
  createImplement,
5
+ createImplementRegistry,
5
6
  createSocketIOServer,
6
- implement
7
- } from "./index-44xysy8r.js";
7
+ implement,
8
+ implementRegistry
9
+ } from "./index-ts21eyz4.js";
8
10
  import"./index-r1qp4rve.js";
9
11
  import {
10
12
  AppError,
@@ -15,7 +17,8 @@ import {
15
17
  notFound,
16
18
  rateLimited,
17
19
  unauthorized
18
- } from "./index-ee621cmy.js";
20
+ } from "./index-jewp9r0a.js";
21
+ import"./index-h05ygjqx.js";
19
22
  // src/server/node.ts
20
23
  import { serve } from "srvx";
21
24
  async function serveNode(config) {
@@ -49,9 +52,11 @@ export {
49
52
  serveNode,
50
53
  rateLimited,
51
54
  notFound,
55
+ implementRegistry,
52
56
  implement,
53
57
  forbidden,
54
58
  createNodeSocketIOServer as createSocketIOServer,
59
+ createImplementRegistry,
55
60
  createImplement,
56
61
  createHandler,
57
62
  conflict,
@@ -2,6 +2,7 @@ import type { ToolCallHooks } from '../tools/execute';
2
2
  import { type RequestContext } from './context';
3
3
  import type { RequestEvent } from './event';
4
4
  import { type SanitizeOptions } from './sanitize';
5
+ import { type ObservabilityDrainReport, type ObservabilityStatus } from './status';
5
6
  /** One isolated RequestEvent sink and its sanitisation policy. */
6
7
  export interface RequestEventSinkConfig {
7
8
  /**
@@ -56,8 +57,10 @@ export interface Observability {
56
57
  toolCall: ToolCallHooks;
57
58
  /** Wait for events admitted before this call. */
58
59
  flush(): Promise<void>;
60
+ /** Read an immutable snapshot of each enabled sink and their aggregate. */
61
+ getStatus(): ObservabilityStatus;
59
62
  /** Stop admission and drain every previously accepted event. Idempotent. */
60
- close(): Promise<void>;
63
+ close(): Promise<ObservabilityDrainReport>;
61
64
  }
62
65
  export declare function createObservability(config: ObservabilityConfig): Observability;
63
66
  //# sourceMappingURL=audit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/observability/audit.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAe,KAAK,eAAe,EAAmB,MAAM,YAAY,CAAC;AAGhF,kEAAkE;AAClE,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,KAAK,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,iFAAiF;IACjF,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC;IAC1C,yEAAyE;IACzE,QAAQ,CAAC,EAAE,eAAe,CAAC;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AC,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,0BAA2B,SAAQ,sBAAsB;IACxE,2DAA2D;IAC3D,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,0BAA0B,CAAC;IACrC,KAAK,CAAC,EAAE,sBAAsB,CAAC;CAChC;AAED,gEAAgE;AAChE,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5B;AAED,0EAA0E;AAC1E,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,qBAAqB,GAAG,IAAI,CAAC;CACnD;AAED,iFAAiF;AACjF,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,QAAQ,EAAE,aAAa,CAAC;IACxB,iDAAiD;IACjD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,2EAA2E;IAC3E,SAAS,IAAI,mBAAmB,CAAC;IACjC,4EAA4E;IAC5E,KAAK,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAAC;CAC5C;AAkOD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CAyJ9E"}
@@ -10,5 +10,6 @@ export { createObservability, type HttpRequestCompletion, type HttpRequestObserv
10
10
  export { getRequestContext, getTraceId, getUserId, type RequestContext, runWithRequestContext, setRequestDimensions, setRequestEndpoint, setRequestError, setRequestUser, type WrapRequestContextOptions, wrapInRequestContext, } from './context';
11
11
  export type { RequestEvent } from './event';
12
12
  export { type JsonValue, measureSize, redact, type SanitizeOptions, type SizeMeasure, sanitizePayload, truncatePreview, } from './sanitize';
13
+ export { type ObservabilityDrainReport, ObservabilityDrainReportSchema, type ObservabilitySinkStatus, ObservabilitySinkStatusSchema, type ObservabilityStatus, ObservabilityStatusSchema, } from './status';
13
14
  export { childSpan, createTraceContext, formatTraceparent, parseTraceparent, resolvePropagationContext, resolveTraceContext, type TraceContext, } from './trace';
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/observability/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,mBAAmB,EACnB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,SAAS,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,KAAK,cAAc,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,KAAK,yBAAyB,EAC9B,oBAAoB,GACrB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EACL,KAAK,SAAS,EACd,WAAW,EACX,MAAM,EACN,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EACzB,mBAAmB,EACnB,KAAK,YAAY,GAClB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/observability/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,mBAAmB,EACnB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,SAAS,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,KAAK,cAAc,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,KAAK,yBAAyB,EAC9B,oBAAoB,GACrB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EACL,KAAK,SAAS,EACd,WAAW,EACX,MAAM,EACN,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,wBAAwB,EAC7B,8BAA8B,EAC9B,KAAK,uBAAuB,EAC5B,6BAA6B,EAC7B,KAAK,mBAAmB,EACxB,yBAAyB,GAC1B,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EACzB,mBAAmB,EACnB,KAAK,YAAY,GAClB,MAAM,SAAS,CAAC"}
@@ -3,26 +3,85 @@ import {
3
3
  redact,
4
4
  sanitizePayload,
5
5
  truncatePreview
6
- } from "../index-8ekq6res.js";
6
+ } from "../index-v58mwa19.js";
7
7
  import {
8
- childSpan,
9
- createTraceContext,
10
- formatTraceparent,
11
8
  getRequestContext,
12
9
  getTraceId,
13
10
  getUserId,
14
- isRecord,
15
- parseTraceparent,
16
11
  recordedErrorMessage,
17
- resolvePropagationContext,
18
- resolveTraceContext,
19
12
  runWithRequestContext,
20
13
  setRequestDimensions,
21
14
  setRequestEndpoint,
22
15
  setRequestError,
23
16
  setRequestUser,
24
17
  wrapInRequestContext
25
- } from "../index-ee621cmy.js";
18
+ } from "../index-jewp9r0a.js";
19
+ import {
20
+ childSpan,
21
+ createTraceContext,
22
+ formatTraceparent,
23
+ isRecord,
24
+ parseTraceparent,
25
+ resolvePropagationContext,
26
+ resolveTraceContext
27
+ } from "../index-h05ygjqx.js";
28
+
29
+ // src/observability/status.ts
30
+ import { z } from "zod";
31
+ var NonNegativeIntegerSchema = z.number().int().nonnegative();
32
+ var ObservabilitySinkStatusSchema = z.object({
33
+ capacity: NonNegativeIntegerSchema,
34
+ received: NonNegativeIntegerSchema,
35
+ accepted: NonNegativeIntegerSchema,
36
+ filtered: NonNegativeIntegerSchema,
37
+ completed: NonNegativeIntegerSchema,
38
+ dropped: NonNegativeIntegerSchema,
39
+ failed: NonNegativeIntegerSchema,
40
+ preparationFailed: NonNegativeIntegerSchema,
41
+ preparing: NonNegativeIntegerSchema,
42
+ pending: NonNegativeIntegerSchema,
43
+ closed: z.boolean()
44
+ }).readonly();
45
+ var ObservabilityStatusObjectSchema = z.object({
46
+ request: ObservabilitySinkStatusSchema.optional(),
47
+ tools: ObservabilitySinkStatusSchema.optional(),
48
+ total: ObservabilitySinkStatusSchema
49
+ });
50
+ var ObservabilityStatusSchema = ObservabilityStatusObjectSchema.readonly();
51
+ var ObservabilityDrainReportSchema = ObservabilityStatusObjectSchema.extend({
52
+ durationMs: z.number().nonnegative()
53
+ }).readonly();
54
+ var SUMMED_STATUS_KEYS = [
55
+ "capacity",
56
+ "received",
57
+ "accepted",
58
+ "filtered",
59
+ "completed",
60
+ "dropped",
61
+ "failed",
62
+ "preparationFailed",
63
+ "preparing",
64
+ "pending"
65
+ ];
66
+ function aggregateObservabilityStatus(surfaces, closed) {
67
+ const totals = {
68
+ capacity: 0,
69
+ received: 0,
70
+ accepted: 0,
71
+ filtered: 0,
72
+ completed: 0,
73
+ dropped: 0,
74
+ failed: 0,
75
+ preparationFailed: 0,
76
+ preparing: 0,
77
+ pending: 0
78
+ };
79
+ for (const surface of surfaces) {
80
+ for (const key of SUMMED_STATUS_KEYS)
81
+ totals[key] += surface[key];
82
+ }
83
+ return ObservabilitySinkStatusSchema.parse({ ...totals, closed });
84
+ }
26
85
 
27
86
  // src/observability/audit.ts
28
87
  function toolErrorMessage(result) {
@@ -76,6 +135,13 @@ function createSinkManager(config) {
76
135
  }
77
136
  let sequence = 0;
78
137
  let closed = false;
138
+ let received = 0;
139
+ let accepted = 0;
140
+ let filtered = 0;
141
+ let completed = 0;
142
+ let dropped = 0;
143
+ let failed = 0;
144
+ let preparationFailed = 0;
79
145
  let closePromise;
80
146
  const preparing = new Map;
81
147
  const writes = new Map;
@@ -87,17 +153,27 @@ function createSinkManager(config) {
87
153
  };
88
154
  const admit = (id, event) => {
89
155
  try {
90
- if (config.filter && !config.filter(event))
156
+ if (config.filter && !config.filter(event)) {
157
+ filtered += 1;
91
158
  return;
159
+ }
92
160
  } catch (error) {
161
+ preparationFailed += 1;
93
162
  reportError(error, event);
94
163
  return;
95
164
  }
96
165
  if (writes.size >= maxPending) {
166
+ dropped += 1;
97
167
  reportDrop("capacity", event);
98
168
  return;
99
169
  }
100
- const write = Promise.resolve().then(() => config.write(event)).catch((error) => reportError(error, event)).finally(() => writes.delete(id));
170
+ accepted += 1;
171
+ const write = Promise.resolve().then(() => config.write(event)).then(() => {
172
+ completed += 1;
173
+ }).catch((error) => {
174
+ failed += 1;
175
+ reportError(error, event);
176
+ }).finally(() => writes.delete(id));
101
177
  writes.set(id, write);
102
178
  };
103
179
  const awaitGeneration = async (boundary) => {
@@ -107,22 +183,59 @@ function createSinkManager(config) {
107
183
  };
108
184
  return {
109
185
  submit(produce) {
186
+ received += 1;
110
187
  const id = ++sequence;
111
188
  if (closed) {
112
- Promise.resolve().then(produce).then((event) => reportDrop("closed", event)).catch((error) => reportError(error));
189
+ Promise.resolve().then(produce).then((event) => {
190
+ dropped += 1;
191
+ reportDrop("closed", event);
192
+ }).catch((error) => {
193
+ preparationFailed += 1;
194
+ reportError(error);
195
+ });
113
196
  return;
114
197
  }
115
- const preparation = Promise.resolve().then(produce).then((event) => admit(id, event)).catch((error) => reportError(error)).finally(() => preparing.delete(id));
198
+ const preparation = Promise.resolve().then(produce).then((event) => admit(id, event)).catch((error) => {
199
+ preparationFailed += 1;
200
+ reportError(error);
201
+ }).finally(() => preparing.delete(id));
116
202
  preparing.set(id, preparation);
117
203
  },
118
204
  flush() {
119
205
  return awaitGeneration(sequence);
120
206
  },
207
+ getStatus() {
208
+ return ObservabilitySinkStatusSchema.parse({
209
+ capacity: maxPending,
210
+ received,
211
+ accepted,
212
+ filtered,
213
+ completed,
214
+ dropped,
215
+ failed,
216
+ preparationFailed,
217
+ preparing: preparing.size,
218
+ pending: writes.size,
219
+ closed
220
+ });
221
+ },
121
222
  close() {
122
223
  if (closePromise)
123
224
  return closePromise;
124
225
  closed = true;
125
- closePromise = awaitGeneration(sequence);
226
+ closePromise = awaitGeneration(sequence).then(() => ObservabilitySinkStatusSchema.parse({
227
+ capacity: maxPending,
228
+ received,
229
+ accepted,
230
+ filtered,
231
+ completed,
232
+ dropped,
233
+ failed,
234
+ preparationFailed,
235
+ preparing: preparing.size,
236
+ pending: writes.size,
237
+ closed
238
+ }));
126
239
  return closePromise;
127
240
  }
128
241
  };
@@ -130,6 +243,7 @@ function createSinkManager(config) {
130
243
  function createObservability(config) {
131
244
  const requestManager = config.request ? createSinkManager(config.request) : undefined;
132
245
  const toolManager = config.tools ? createSinkManager(config.tools) : undefined;
246
+ let closed = false;
133
247
  let closePromise;
134
248
  const request = config.request ? {
135
249
  includePayload: config.request.includePayload ?? false,
@@ -228,16 +342,33 @@ function createObservability(config) {
228
342
  } catch {}
229
343
  }
230
344
  } : undefined;
345
+ const getStatus = () => {
346
+ const requestStatus = requestManager?.getStatus();
347
+ const toolsStatus = toolManager?.getStatus();
348
+ const surfaces = [requestStatus, toolsStatus].filter((status) => status !== undefined);
349
+ return ObservabilityStatusSchema.parse({
350
+ ...requestStatus && { request: requestStatus },
351
+ ...toolsStatus && { tools: toolsStatus },
352
+ total: aggregateObservabilityStatus(surfaces, closed)
353
+ });
354
+ };
231
355
  return {
232
356
  ...request && { request },
233
357
  toolCall: toolCall ?? {},
234
358
  async flush() {
235
359
  await Promise.all([requestManager?.flush(), toolManager?.flush()]);
236
360
  },
361
+ getStatus,
237
362
  close() {
238
363
  if (!closePromise) {
364
+ closed = true;
365
+ const startedAt = performance.now();
239
366
  closePromise = Promise.all([requestManager?.close(), toolManager?.close()]).then(() => {
240
- return;
367
+ const status = getStatus();
368
+ return ObservabilityDrainReportSchema.parse({
369
+ ...status,
370
+ durationMs: performance.now() - startedAt
371
+ });
241
372
  });
242
373
  }
243
374
  return closePromise;
@@ -264,5 +395,8 @@ export {
264
395
  formatTraceparent,
265
396
  createTraceContext,
266
397
  createObservability,
267
- childSpan
398
+ childSpan,
399
+ ObservabilityStatusSchema,
400
+ ObservabilitySinkStatusSchema,
401
+ ObservabilityDrainReportSchema
268
402
  };
@@ -0,0 +1,105 @@
1
+ import { z } from 'zod';
2
+ /** Immutable operational snapshot for one bounded observability sink. */
3
+ export declare const ObservabilitySinkStatusSchema: z.ZodReadonly<z.ZodObject<{
4
+ capacity: z.ZodNumber;
5
+ received: z.ZodNumber;
6
+ accepted: z.ZodNumber;
7
+ filtered: z.ZodNumber;
8
+ completed: z.ZodNumber;
9
+ dropped: z.ZodNumber;
10
+ failed: z.ZodNumber;
11
+ preparationFailed: z.ZodNumber;
12
+ preparing: z.ZodNumber;
13
+ pending: z.ZodNumber;
14
+ closed: z.ZodBoolean;
15
+ }, z.core.$strip>>;
16
+ export type ObservabilitySinkStatus = z.infer<typeof ObservabilitySinkStatusSchema>;
17
+ export declare const ObservabilityStatusSchema: z.ZodReadonly<z.ZodObject<{
18
+ request: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
19
+ capacity: z.ZodNumber;
20
+ received: z.ZodNumber;
21
+ accepted: z.ZodNumber;
22
+ filtered: z.ZodNumber;
23
+ completed: z.ZodNumber;
24
+ dropped: z.ZodNumber;
25
+ failed: z.ZodNumber;
26
+ preparationFailed: z.ZodNumber;
27
+ preparing: z.ZodNumber;
28
+ pending: z.ZodNumber;
29
+ closed: z.ZodBoolean;
30
+ }, z.core.$strip>>>;
31
+ tools: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
32
+ capacity: z.ZodNumber;
33
+ received: z.ZodNumber;
34
+ accepted: z.ZodNumber;
35
+ filtered: z.ZodNumber;
36
+ completed: z.ZodNumber;
37
+ dropped: z.ZodNumber;
38
+ failed: z.ZodNumber;
39
+ preparationFailed: z.ZodNumber;
40
+ preparing: z.ZodNumber;
41
+ pending: z.ZodNumber;
42
+ closed: z.ZodBoolean;
43
+ }, z.core.$strip>>>;
44
+ total: z.ZodReadonly<z.ZodObject<{
45
+ capacity: z.ZodNumber;
46
+ received: z.ZodNumber;
47
+ accepted: z.ZodNumber;
48
+ filtered: z.ZodNumber;
49
+ completed: z.ZodNumber;
50
+ dropped: z.ZodNumber;
51
+ failed: z.ZodNumber;
52
+ preparationFailed: z.ZodNumber;
53
+ preparing: z.ZodNumber;
54
+ pending: z.ZodNumber;
55
+ closed: z.ZodBoolean;
56
+ }, z.core.$strip>>;
57
+ }, z.core.$strip>>;
58
+ export type ObservabilityStatus = z.infer<typeof ObservabilityStatusSchema>;
59
+ /** Final immutable state returned after observability admission closes and drains. */
60
+ export declare const ObservabilityDrainReportSchema: z.ZodReadonly<z.ZodObject<{
61
+ request: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
62
+ capacity: z.ZodNumber;
63
+ received: z.ZodNumber;
64
+ accepted: z.ZodNumber;
65
+ filtered: z.ZodNumber;
66
+ completed: z.ZodNumber;
67
+ dropped: z.ZodNumber;
68
+ failed: z.ZodNumber;
69
+ preparationFailed: z.ZodNumber;
70
+ preparing: z.ZodNumber;
71
+ pending: z.ZodNumber;
72
+ closed: z.ZodBoolean;
73
+ }, z.core.$strip>>>;
74
+ tools: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
75
+ capacity: z.ZodNumber;
76
+ received: z.ZodNumber;
77
+ accepted: z.ZodNumber;
78
+ filtered: z.ZodNumber;
79
+ completed: z.ZodNumber;
80
+ dropped: z.ZodNumber;
81
+ failed: z.ZodNumber;
82
+ preparationFailed: z.ZodNumber;
83
+ preparing: z.ZodNumber;
84
+ pending: z.ZodNumber;
85
+ closed: z.ZodBoolean;
86
+ }, z.core.$strip>>>;
87
+ total: z.ZodReadonly<z.ZodObject<{
88
+ capacity: z.ZodNumber;
89
+ received: z.ZodNumber;
90
+ accepted: z.ZodNumber;
91
+ filtered: z.ZodNumber;
92
+ completed: z.ZodNumber;
93
+ dropped: z.ZodNumber;
94
+ failed: z.ZodNumber;
95
+ preparationFailed: z.ZodNumber;
96
+ preparing: z.ZodNumber;
97
+ pending: z.ZodNumber;
98
+ closed: z.ZodBoolean;
99
+ }, z.core.$strip>>;
100
+ durationMs: z.ZodNumber;
101
+ }, z.core.$strip>>;
102
+ export type ObservabilityDrainReport = z.infer<typeof ObservabilityDrainReportSchema>;
103
+ /** Build and freeze the aggregate without exposing mutable counters. */
104
+ export declare function aggregateObservabilityStatus(surfaces: readonly ObservabilitySinkStatus[], closed: boolean): ObservabilitySinkStatus;
105
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/observability/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,yEAAyE;AACzE,eAAO,MAAM,6BAA6B;;;;;;;;;;;;kBAc7B,CAAC;AAEd,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AASpF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAA6C,CAAC;AAEpF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,sFAAsF;AACtF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAE9B,CAAC;AAEd,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAiBtF,wEAAwE;AACxE,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,SAAS,uBAAuB,EAAE,EAC5C,MAAM,EAAE,OAAO,GACd,uBAAuB,CAiBzB"}
@@ -30,12 +30,6 @@ export declare function defineMultipartStream<const E extends StreamingEndpoint,
30
30
  files: StreamedFiles<E, R>;
31
31
  }) => StreamingReturn<E>;
32
32
  }): StreamingMultipartImplementation;
33
- /**
34
- * Bind a contract to its typed `handlers`, producing a `ServiceDef` to mount on
35
- * `createServer`. Every handler is type-checked against its endpoint's schemas.
36
- * Pass `TCtx` for a typed handler context — or use `createImplement` to fix it
37
- * once.
38
- */
39
33
  export declare function implement<T extends Record<string, EndpointDef>, TCtx extends RuntimeContext = RuntimeContext>(contract: ContractDef<T, string>, handlers: Handlers<T, TCtx>): ServiceDef;
40
34
  /**
41
35
  * Fix the handler context type once — `const implement =
@@ -43,5 +37,21 @@ export declare function implement<T extends Record<string, EndpointDef>, TCtx ex
43
37
  * the generic. The application declares its context shape in a single place.
44
38
  */
45
39
  export declare function createImplement<TCtx extends RuntimeContext>(): <T extends Record<string, EndpointDef>>(contract: ContractDef<T, string>, handlers: Handlers<T, TCtx>) => ServiceDef;
40
+ export type ImplementationRegistry = Record<string, ContractDef<Record<string, EndpointDef>, string>>;
41
+ /** Exact handlers map derived from a literal contract registry. */
42
+ export type RegistryHandlers<TContracts extends ImplementationRegistry, TCtx extends RuntimeContext = RuntimeContext> = {
43
+ [K in keyof TContracts]: TContracts[K] extends ContractDef<infer TEndpoints, string> ? Handlers<TEndpoints, TCtx> : never;
44
+ };
45
+ export type ExactRegistryHandlers<TContracts extends ImplementationRegistry, THandlers extends RegistryHandlers<TContracts, TCtx>, TCtx extends RuntimeContext> = THandlers & RegistryHandlers<TContracts, TCtx> & Record<Exclude<keyof THandlers, keyof TContracts>, never> & {
46
+ [K in keyof THandlers & keyof TContracts]: THandlers[K] & Record<Exclude<keyof THandlers[K], keyof RegistryHandlers<TContracts, TCtx>[K]>, never>;
47
+ };
48
+ /**
49
+ * Bind an exact `name → contract` registry to its exact handlers map. Missing,
50
+ * extra and endpoint-incompatible implementations fail at compile time; loose
51
+ * JavaScript callers receive the same checks at runtime.
52
+ */
53
+ export declare function implementRegistry<const TContracts extends ImplementationRegistry, const THandlers extends RegistryHandlers<TContracts>>(contracts: TContracts, handlers: ExactRegistryHandlers<TContracts, THandlers, RuntimeContext>): ServiceDef[];
54
+ /** Fix one handler context type for every entry in an implementation registry. */
55
+ export declare function createImplementRegistry<TCtx extends RuntimeContext>(): <const TContracts extends ImplementationRegistry, const THandlers extends RegistryHandlers<TContracts, TCtx>>(contracts: TContracts, handlers: ExactRegistryHandlers<TContracts, THandlers, TCtx>) => ServiceDef[];
46
56
  export {};
47
57
  //# sourceMappingURL=implement.d.ts.map