stitchkit 0.39.0 → 0.41.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.
@@ -61,9 +61,14 @@ type PrefixKeys<C> = C extends {
61
61
  type ClientForContract<C, Configs> = C extends ContractDef<infer E, infer S> ? S extends keyof Configs ? ScopedHttpClient<E, ScopedKeys<PrefixKeys<Configs[S]>>> : never : never;
62
62
  type UnionToIntersection<U> = (U extends unknown ? (value: U) => void : never) extends (value: infer I) => void ? I : never;
63
63
  type ScopedNamespace<R, Configs> = UnionToIntersection<ClientForContract<RegistryContract<R>, Configs>>;
64
+ type UrlBuilderForContract<C, Configs> = C extends ContractDef<infer E, infer S> ? S extends keyof Configs ? ScopedUrlBuilder<E, ScopedKeys<PrefixKeys<Configs[S]>>> : never : never;
65
+ type ScopedUrlNamespace<R, Configs> = UnionToIntersection<UrlBuilderForContract<RegistryContract<R>, Configs>>;
64
66
  export type ScopedClientRegistry<T extends Record<string, ClientRegistryValue>, Configs> = {
65
67
  [P in keyof T]: ScopedNamespace<T[P], Configs>;
66
68
  };
69
+ export type ScopedUrlBuilderRegistry<T extends Record<string, ClientRegistryValue>, Configs> = {
70
+ [P in keyof T]: ScopedUrlNamespace<T[P], Configs>;
71
+ };
67
72
  /** Build one client registry routed by contract scope; arrays compose a namespace. */
68
73
  export declare function createScopedClients<const T extends Record<string, ClientRegistryValue>, const Configs extends ScopeClientConfigs<RegistryScope<T[keyof T]>>>(contracts: T, configOrClient: ClientConfig | HttpAdapter, scopeConfigs: Configs): ScopedClientRegistry<T, Configs>;
69
74
  /** Base URL source for synchronous contract URL builders. */
@@ -74,5 +79,7 @@ export declare function createUrlBuilder<T extends Record<string, EndpointDef>,
74
79
  export declare function createUrlBuilders<T extends Record<string, ContractDef<Record<string, EndpointDef>, string>>, const K extends string = never>(contracts: T, source: UrlBuilderConfig, contractConfig?: ContractClientConfig<K>): {
75
80
  [P in keyof T]: ScopedUrlBuilder<T[P]['endpoints'], ScopedKeys<K>>;
76
81
  };
82
+ /** Build one URL registry routed by contract scope; arrays compose a namespace. */
83
+ export declare function createScopedUrlBuilders<const T extends Record<string, ClientRegistryValue>, const Configs extends ScopeClientConfigs<RegistryScope<T[keyof T]>>>(contracts: T, source: UrlBuilderConfig, scopeConfigs: Configs): ScopedUrlBuilderRegistry<T, Configs>;
77
84
  export {};
78
85
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/browser/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAGjB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAEL,KAAK,UAAU,IAAI,WAAW,EAG9B,KAAK,mBAAmB,EACzB,MAAM,QAAQ,CAAC;AA+BhB,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClE,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACnD;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAC1D,OAAO,GACP;KAAG,CAAC,IAAI,CAAC,GAAG,MAAM;CAAE,CAAC;AAEzB,qEAAqE;AACrE,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,IAAI;KAAG,CAAC,IAAI,CAAC,GAAG,MAAM;CAAE,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,MAAM,GAAG,KAA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AAK,CAAC,OAAO,SAAS,kBAAkB,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAEnE,SAAS,EAAE,CAAC,EACZ,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,OAAO,GACpB,wBAAwB,CAAC,CAAC,EAAE,OAAO,CAAC,CAOtC"}
@@ -69,7 +69,7 @@ export interface RequestOptions {
69
69
  * caller still gets `.blob()` / `.body`, plus the headers where
70
70
  * `Content-Disposition` (the download filename) lives.
71
71
  */
72
- responseType?: 'json' | 'blob' | 'response';
72
+ responseType?: 'json' | 'blob' | 'response' | 'void';
73
73
  }
74
74
  /** The HTTP transport adapter `createClient` builds typed methods on. */
75
75
  export interface HttpClient {
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/browser/http.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,MAAM,MAAM,QAAQ,GAChB;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,GACxB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEvB,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;AAEzD,sEAAsE;AACtE,MAAM,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;AAEhE,qBAAa,QAAS,SAAQ,KAAK;aAEf,IAAI,EAAE,MAAM;aACZ,MAAM,EAAE,MAAM;aACd,OAAO,CAAC,EAAE,OAAO;aAEjB,IAAI,CAAC,EAAE,MAAM;IAL/B,YACkB,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,MAAU,EAClB,OAAO,CAAC,EAAE,OAAO,EACjC,OAAO,CAAC,EAAE,MAAM,EACA,IAAI,CAAC,EAAE,MAAM,YAAA,EAI9B;IAED,MAAM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AAE,OAAO,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3E,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1E,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5E,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC7D,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,SAAS,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,IAAI,CAAC;IAClD,gFAAgF;IAChF,MAAM,IAAI,IAAI,CAAC;IACf,oEAAoE;IACpE,gBAAgB,IAAI,IAAI,CAAC;CAC1B;AAED,gFAAgF;AAChF,MAAM,WAAW,oBAAqB,SAAQ,UAAU;IACtD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,oBAAoB,CAmL/E"}
package/dist/cli.js CHANGED
@@ -4,10 +4,10 @@ import {
4
4
  emitResult,
5
5
  parseCliArgs,
6
6
  pollUntilDone
7
- } from "./index-y5scd1cr.js";
7
+ } from "./index-ncqqn1bc.js";
8
8
  import"./index-frfyw9fa.js";
9
9
  import"./index-x3fcszf8.js";
10
- import"./index-fyfk537k.js";
10
+ import"./index-sc67e454.js";
11
11
  export {
12
12
  pollUntilDone,
13
13
  parseCliArgs,
@@ -22,11 +22,11 @@
22
22
  */
23
23
  import type { ContractDef, EndpointDef } from './define';
24
24
  /** A `defineContract` whose `scope` is required and typed to `TScope`. */
25
- export type ScopedDefineContract<TScope extends string> = <const T extends Record<string, EndpointDef>>(meta: {
25
+ export type ScopedDefineContract<TScope extends string> = <const TContractScope extends TScope, const T extends Record<string, EndpointDef>>(meta: {
26
26
  prefix: string;
27
- scope: TScope;
27
+ scope: TContractScope;
28
28
  meta?: Record<string, unknown>;
29
- }, endpoints: T) => ContractDef<T, TScope>;
29
+ }, endpoints: T) => ContractDef<T, TContractScope>;
30
30
  /**
31
31
  * Build a `defineContract` that requires a `scope` from the application's own
32
32
  * union. Call once per app and re-export the returned `defineContract`.
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/contract/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGzD,0EAA0E;AAC1E,MAAM,MAAM,oBAAoB,CAAC,MAAM,SAAS,MAAM,IAAI,CACxD,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAE3C,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,EACvE,SAAS,EAAE,CAAC,KACT,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAE5B;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,SAAS,MAAM,KAAK;IAC9D,cAAc,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC;CAC9C,CAiBA"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/contract/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGzD,0EAA0E;AAC1E,MAAM,MAAM,oBAAoB,CAAC,MAAM,SAAS,MAAM,IAAI,CACxD,KAAK,CAAC,cAAc,SAAS,MAAM,EACnC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAE3C,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,cAAc,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,EAC/E,SAAS,EAAE,CAAC,KACT,WAAW,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;AAEpC;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,SAAS,MAAM,KAAK;IAC9D,cAAc,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC;CAC9C,CAiBA"}
@@ -27,8 +27,8 @@ import {
27
27
  setRequestEndpoint,
28
28
  setRequestError,
29
29
  typedEntries,
30
- validateHandlerOutput
31
- } from "./index-fyfk537k.js";
30
+ validateDeclaredOutput
31
+ } from "./index-sc67e454.js";
32
32
 
33
33
  // src/server/multipart.ts
34
34
  var DEFAULT_MAX_UPLOAD_BYTES = 25 * 1024 * 1024;
@@ -879,25 +879,20 @@ function createHandler(config) {
879
879
  if (result instanceof Response) {
880
880
  throw new AppError("INTERNAL_SERVER_ERROR", `${method.serviceName}.${method.key} produced a Response on the data path — only a \`rawResponse: true\` endpoint may return one (an afterHandle hook must return data)`, 500);
881
881
  }
882
- if (method.outputSchema) {
883
- const checked = validateHandlerOutput(method.outputSchema, result, config.warnOnOutputStrip ? (paths) => {
884
- warn(`[stitchkit] output strip ${method.serviceName}.${method.key}: ${paths.join(", ")}`);
885
- } : undefined);
886
- if (!checked.ok) {
887
- throw new AppError("INTERNAL_SERVER_ERROR", checked.message, 500);
888
- }
889
- result = checked.data;
882
+ const checked = validateDeclaredOutput(method.outputSchema, result, config.warnOnOutputStrip && method.outputSchema ? (paths) => {
883
+ warn(`[stitchkit] output strip ${method.serviceName}.${method.key}: ${paths.join(", ")}`);
884
+ } : undefined);
885
+ if (!checked.ok) {
886
+ throw new AppError("INTERNAL_SERVER_ERROR", checked.message, 500);
890
887
  }
891
- const responseStatus = method.responseMeta?.status ?? (result === undefined || result === null ? 204 : 200);
888
+ result = checked.data;
889
+ const responseStatus = method.responseMeta?.status ?? (method.outputSchema ? 200 : 204);
892
890
  if (method.outputSchema && (responseStatus === 204 || responseStatus === 205)) {
893
891
  throw new AppError("INTERNAL_SERVER_ERROR", `${method.serviceName}.${method.key} cannot combine output with bodyless status ${responseStatus}`, 500);
894
892
  }
895
- if (result !== undefined && result !== null && (responseStatus === 204 || responseStatus === 205)) {
896
- throw new AppError("INTERNAL_SERVER_ERROR", `${method.serviceName}.${method.key} produced data for bodyless status ${responseStatus}`, 500);
897
- }
898
893
  const responseHeaders = new Headers(corsHeaders2(cors, req));
899
894
  applyResponseMetadata(responseHeaders, responseMetadata, `${method.serviceName}.${method.key}`);
900
- if (result === undefined || result === null) {
895
+ if (!method.outputSchema) {
901
896
  const empty = new Response(null, { status: responseStatus, headers: responseHeaders });
902
897
  logDone(responseStatus);
903
898
  return empty;
@@ -6,7 +6,7 @@ import {
6
6
  isUnsafeKey,
7
7
  safeJsonParse,
8
8
  unauthorized
9
- } from "./index-fyfk537k.js";
9
+ } from "./index-sc67e454.js";
10
10
 
11
11
  // src/server/middleware/cookies.ts
12
12
  function parseCookies(header) {
@@ -6,15 +6,18 @@ import {
6
6
  isWithinDir
7
7
  } from "./index-x3fcszf8.js";
8
8
  import {
9
+ AppError,
10
+ STITCH_ERROR_STATUS,
9
11
  formatZodError,
10
12
  getRequestContext,
11
13
  isRecord,
14
+ isStitchErrorCode,
12
15
  isUnsafeKey,
13
16
  normalizeError,
14
17
  runWithRequestContext,
15
18
  safeJsonParse,
16
- validateHandlerOutput
17
- } from "./index-fyfk537k.js";
19
+ validateDeclaredOutput
20
+ } from "./index-sc67e454.js";
18
21
 
19
22
  // src/tools/coerce.ts
20
23
  import { z } from "zod";
@@ -449,14 +452,26 @@ function mergeSchemas(paramsSchema, inputSchema) {
449
452
  }
450
453
 
451
454
  // src/tools/execute.ts
455
+ var normalizedToolErrors = new WeakMap;
452
456
  function toolResultFromError(err) {
453
457
  const appErr = normalizeError(err);
454
- return {
458
+ const result = {
455
459
  ok: false,
456
460
  code: appErr.code,
457
461
  details: appErr.details ?? { message: appErr.message },
458
462
  ...appErr.hint && { hint: appErr.hint }
459
463
  };
464
+ normalizedToolErrors.set(result, appErr);
465
+ return result;
466
+ }
467
+ function toolErrorFromResult(result) {
468
+ const retained = normalizedToolErrors.get(result);
469
+ if (retained)
470
+ return retained;
471
+ const details = isRecord(result.details) ? result.details : undefined;
472
+ const message = typeof details?.message === "string" ? details.message : result.code;
473
+ const status = isStitchErrorCode(result.code) ? STITCH_ERROR_STATUS[result.code] : 500;
474
+ return new AppError(result.code, message, status, details, result.hint);
460
475
  }
461
476
  async function executeToolMethod(method, toolName, rawArgs, context, hooks, lifecycle, coerceJson = false, onOutputStrip, extension) {
462
477
  return inToolCallContext({ source: context.source, toolName, method }, () => runToolMethod(method, toolName, rawArgs, context, hooks, lifecycle, coerceJson, onOutputStrip, extension));
@@ -625,17 +640,15 @@ async function runToolMethod(method, toolName, rawArgs, context, hooks, lifecycl
625
640
  if (transformed !== undefined)
626
641
  data = transformed;
627
642
  }
628
- if (method.outputSchema) {
629
- const checked = validateHandlerOutput(method.outputSchema, data, onOutputStrip);
630
- if (!checked.ok) {
631
- return finish({
632
- ok: false,
633
- code: "INTERNAL_SERVER_ERROR",
634
- details: { message: checked.message }
635
- });
636
- }
637
- data = checked.data;
643
+ const checked = validateDeclaredOutput(method.outputSchema, data, onOutputStrip);
644
+ if (!checked.ok) {
645
+ return finish({
646
+ ok: false,
647
+ code: "INTERNAL_SERVER_ERROR",
648
+ details: { message: checked.message }
649
+ });
638
650
  }
651
+ data = checked.data;
639
652
  const output = (data === undefined || data === null) && !method.outputSchema ? { status: "ok" } : data;
640
653
  return finish({ ok: true, data: output });
641
654
  } catch (err) {
@@ -1594,4 +1607,4 @@ function safeInputSchema(tool) {
1594
1607
  return tool.presentationSchema;
1595
1608
  }
1596
1609
 
1597
- export { coerceJsonArgs, toolResultFromError, executeToolMethod, assertToolName, assertUniqueToolName, flattenToolJsonSchema, buildToolPresentationSchema, isObjectPresentationSchema, presentationMetadata, collectTools, createToolRunner, formatToolError, fetchGuarded, readCapped, writeDownload, parseCliArgs, DEFAULT_EXIT_CODES, emitResult, pollUntil, pollUntilDone, createCli };
1610
+ export { coerceJsonArgs, toolResultFromError, toolErrorFromResult, executeToolMethod, assertToolName, assertUniqueToolName, flattenToolJsonSchema, buildToolPresentationSchema, isObjectPresentationSchema, presentationMetadata, collectTools, createToolRunner, formatToolError, fetchGuarded, readCapped, writeDownload, parseCliArgs, DEFAULT_EXIT_CODES, emitResult, pollUntil, pollUntilDone, createCli };
@@ -228,6 +228,23 @@ function validateHandlerOutput(schema, data, onStripped) {
228
228
  message: `Handler output does not match the contract: ${formatZodError(parsed.error)}`
229
229
  };
230
230
  }
231
+ function validateDeclaredOutput(schema, data, onStripped) {
232
+ if (!schema) {
233
+ if (data === undefined || data === null)
234
+ return { ok: true, data };
235
+ return {
236
+ ok: false,
237
+ message: "Handler returned data but the contract declares no output"
238
+ };
239
+ }
240
+ if (data === undefined) {
241
+ return {
242
+ ok: false,
243
+ message: "Handler returned undefined but the contract declares an output"
244
+ };
245
+ }
246
+ return validateHandlerOutput(schema, data, onStripped);
247
+ }
231
248
 
232
249
  // src/internal/safe-json.ts
233
250
  function isUnsafeKey(key) {
@@ -382,4 +399,4 @@ function wrapInRequestContext(handler, options = {}) {
382
399
  };
383
400
  }
384
401
 
385
- export { __require, parseTrailingWildcard, mergeMeta, AppError, notFound, badRequest, unauthorized, forbidden, conflict, rateLimited, STITCH_ERROR_STATUS, isStitchErrorCode, appError, typedEntries, isRecord, bytesToBase64Url, base64UrlToBytes, formatZodError, zodIssues, errorCode, recordedErrorMessage, normalizeError, validateHandlerOutput, isUnsafeKey, safeJsonParse, generateTraceId, resolveTraceId, resolveSocketIp, extractIp, getClientInfo, parseQueryParams, createTraceContext, parseTraceparent, formatTraceparent, resolveTraceContext, childSpan, runWithRequestContext, getRequestContext, getTraceId, getUserId, setRequestUser, setRequestEndpoint, setRequestDimensions, setRequestError, wrapInRequestContext };
402
+ export { __require, parseTrailingWildcard, mergeMeta, AppError, notFound, badRequest, unauthorized, forbidden, conflict, rateLimited, STITCH_ERROR_STATUS, isStitchErrorCode, appError, typedEntries, isRecord, bytesToBase64Url, base64UrlToBytes, formatZodError, zodIssues, errorCode, recordedErrorMessage, normalizeError, validateDeclaredOutput, isUnsafeKey, safeJsonParse, generateTraceId, resolveTraceId, resolveSocketIp, extractIp, getClientInfo, parseQueryParams, createTraceContext, parseTraceparent, formatTraceparent, resolveTraceContext, childSpan, runWithRequestContext, getRequestContext, getTraceId, getUserId, setRequestUser, setRequestEndpoint, setRequestDimensions, setRequestError, wrapInRequestContext };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { type ClientConfig, type ClientContract, type ClientRegistryValue, type ContractClientConfig, contractEndpointMatchers, createClient, createClients, createScopedClients, createUrlBuilder, createUrlBuilders, type PathPrefixArgs, type RegistryScope, type ScopeClientConfigs, type ScopedClientRegistry, type UrlBuilderConfig, } from './browser/client';
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';
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 { SocketEventMap, SocketIOClient, SocketIOClientConfig, } from './browser/socket-io';
4
4
  export { 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,EACxB,KAAK,oBAAoB,EACzB,wBAAwB,EACxB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,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,cAAc,EACd,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,eAAe,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClE,cAAc,YAAY,CAAC;AAG3B,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,YAAY,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC"}
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,EACxB,KAAK,oBAAoB,EACzB,wBAAwB,EACxB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,uBAAuB,EACvB,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,cAAc,EACd,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,eAAe,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClE,cAAc,YAAY,CAAC;AAG3B,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,YAAY,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -371,7 +371,13 @@ function createHttpClient(config) {
371
371
  return await client[method](url, kyOptions);
372
372
  }
373
373
  const response = await client[method](url, kyOptions);
374
- if (response.status === 204 || response.headers.get("content-length") === "0") {
374
+ if (options.responseType === "void") {
375
+ const text = await response.text();
376
+ if (text.length > 0) {
377
+ throw new Error("Server returned data for an endpoint with no output contract");
378
+ }
379
+ }
380
+ if (options.responseType === "void" || response.status === 204 || response.headers.get("content-length") === "0") {
375
381
  return;
376
382
  }
377
383
  return response.json();
@@ -414,7 +420,7 @@ function createHttpClient(config) {
414
420
 
415
421
  // src/browser/client.ts
416
422
  function withTimeout(options, endpoint) {
417
- const responseType = endpoint.rawResponse ? "response" : undefined;
423
+ const responseType = endpoint.rawResponse ? "response" : endpoint.output ? undefined : "void";
418
424
  if (endpoint.timeout === undefined && responseType === undefined)
419
425
  return options;
420
426
  return {
@@ -424,10 +430,20 @@ function withTimeout(options, endpoint) {
424
430
  };
425
431
  }
426
432
  function withOutput(endpoint, result) {
427
- const schema = endpoint.output;
428
- if (!schema)
433
+ if (endpoint.rawResponse)
429
434
  return result;
430
- return result.then((value) => value === undefined ? undefined : schema.parse(value));
435
+ const schema = endpoint.output;
436
+ return result.then((value) => {
437
+ if (!schema) {
438
+ if (value === undefined || value === null)
439
+ return;
440
+ throw new Error("Server returned data for an endpoint with no output contract");
441
+ }
442
+ if (value === undefined) {
443
+ throw new Error("Server returned no body for an endpoint with an output contract");
444
+ }
445
+ return schema.parse(value);
446
+ });
431
447
  }
432
448
  function contractEndpointMatchers(contract, endpointNames, contractConfig) {
433
449
  const selected = endpointNames ? new Set(endpointNames) : null;
@@ -461,32 +477,34 @@ function createClient(contract, configOrClient, contractConfig) {
461
477
  function createClients(contracts, configOrClient, contractConfig) {
462
478
  return mapObject(contracts, (_key, contract) => createClient(contract, configOrClient, contractConfig));
463
479
  }
464
- function createScopedClients(contracts, configOrClient, scopeConfigs) {
480
+ function buildScopedRegistry(contracts, scopeConfigs, surfaceName, build) {
465
481
  const registry = {};
466
482
  for (const [namespace, value] of Object.entries(contracts)) {
467
483
  const list = Array.isArray(value) ? value : [value];
468
- const client = {};
484
+ const surface = {};
469
485
  for (const contract of list) {
470
486
  const scope = contract.meta.scope;
471
487
  if (!scope) {
472
- throw new Error(`Contract in client namespace "${namespace}" has no scope`);
488
+ throw new Error(`Contract in ${surfaceName} namespace "${namespace}" has no scope`);
473
489
  }
474
- const scopeConfig = Object.entries(scopeConfigs).find(([configuredScope]) => configuredScope === scope)?.[1];
490
+ const scopeConfig = scopeConfigs[scope];
475
491
  if (!scopeConfig) {
476
- throw new Error(`Missing client config for scope: ${scope}`);
492
+ throw new Error(`Missing ${surfaceName} config for scope: ${scope}`);
477
493
  }
478
- const scoped = createClient(contract, configOrClient, scopeConfig);
479
- for (const [methodName, method] of Object.entries(scoped)) {
480
- if (Object.hasOwn(client, methodName)) {
481
- throw new Error(`Client namespace "${namespace}" has duplicate method: ${methodName}`);
494
+ for (const [methodName, method] of Object.entries(build(contract, scopeConfig))) {
495
+ if (Object.hasOwn(surface, methodName)) {
496
+ throw new Error(`${surfaceName[0]?.toUpperCase()}${surfaceName.slice(1)} namespace "${namespace}" has duplicate method: ${methodName}`);
482
497
  }
483
- client[methodName] = method;
498
+ surface[methodName] = method;
484
499
  }
485
500
  }
486
- registry[namespace] = client;
501
+ registry[namespace] = surface;
487
502
  }
488
503
  return registry;
489
504
  }
505
+ function createScopedClients(contracts, configOrClient, scopeConfigs) {
506
+ return buildScopedRegistry(contracts, scopeConfigs, "client", (contract, config) => createClient(contract, configOrClient, config));
507
+ }
490
508
  function isHttpAdapter(value) {
491
509
  return typeof value === "object" && "get" in value && typeof value.get === "function";
492
510
  }
@@ -552,10 +570,14 @@ function createFetchMethod(endpoint, prefix, config, contractConfig) {
552
570
  }
553
571
  if (endpoint.rawResponse)
554
572
  return res2;
555
- if (res2.status === 204)
573
+ if (!endpoint.output) {
574
+ const text = await res2.text();
575
+ if (text.length > 0) {
576
+ throw new Error("Server returned data for an endpoint with no output contract");
577
+ }
556
578
  return;
557
- const json2 = await res2.json();
558
- return endpoint.output ? endpoint.output.parse(json2) : json2;
579
+ }
580
+ return endpoint.output.parse(await res2.json());
559
581
  }
560
582
  const res = await fetch(url, {
561
583
  method: endpoint.method,
@@ -571,10 +593,14 @@ function createFetchMethod(endpoint, prefix, config, contractConfig) {
571
593
  }
572
594
  if (endpoint.rawResponse)
573
595
  return res;
574
- if (res.status === 204)
596
+ if (!endpoint.output) {
597
+ const text = await res.text();
598
+ if (text.length > 0) {
599
+ throw new Error("Server returned data for an endpoint with no output contract");
600
+ }
575
601
  return;
576
- const json = await res.json();
577
- return endpoint.output ? endpoint.output.parse(json) : json;
602
+ }
603
+ return endpoint.output.parse(await res.json());
578
604
  };
579
605
  }
580
606
  async function throwForErrorResponse(res, config, fallbackBody) {
@@ -605,6 +631,9 @@ function createUrlBuilder(contract, source, contractConfig) {
605
631
  function createUrlBuilders(contracts, source, contractConfig) {
606
632
  return mapObject(contracts, (_key, contract) => createUrlBuilder(contract, source, contractConfig));
607
633
  }
634
+ function createScopedUrlBuilders(contracts, source, scopeConfigs) {
635
+ return buildScopedRegistry(contracts, scopeConfigs, "URL builder", (contract, config) => createUrlBuilder(contract, source, config));
636
+ }
608
637
  // src/retained.ts
609
638
  function createRetainedTopics() {
610
639
  const last = {};
@@ -815,6 +844,7 @@ export {
815
844
  createUrlBuilder,
816
845
  createTraceContext,
817
846
  createSocketIOClient,
847
+ createScopedUrlBuilders,
818
848
  createScopedClients,
819
849
  createRetainedTopics,
820
850
  createHttpClient,
@@ -57,4 +57,17 @@ export declare function validateHandlerOutput(schema: ZodType, data: unknown, on
57
57
  ok: false;
58
58
  message: string;
59
59
  };
60
+ /**
61
+ * Enforce the presence or absence of a contract output before a transport
62
+ * presents it. `null` is JSON data when a schema accepts it; `undefined` never
63
+ * is. Without a schema, nullish returns mean "no result" and any other value is
64
+ * an undeclared response.
65
+ */
66
+ export declare function validateDeclaredOutput(schema: ZodType | undefined, data: unknown, onStripped?: (paths: string[]) => void): {
67
+ ok: true;
68
+ data: unknown;
69
+ } | {
70
+ ok: false;
71
+ message: string;
72
+ };
60
73
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/internal/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQvC,wBAAgB,cAAc,CAAC,KAAK,EAAE,CAAC,C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Implement,
4
4
  createSocketIOServer,
5
5
  implement
6
- } from "./index-7rbzbnnf.js";
6
+ } from "./index-4e1c0hsw.js";
7
7
  import"./index-6jypn22c.js";
8
8
  import"./index-x3fcszf8.js";
9
9
  import {
@@ -15,7 +15,7 @@ import {
15
15
  notFound,
16
16
  rateLimited,
17
17
  unauthorized
18
- } from "./index-fyfk537k.js";
18
+ } from "./index-sc67e454.js";
19
19
  // src/server/node.ts
20
20
  import { serve } from "srvx";
21
21
  async function serveNode(config) {
@@ -16,7 +16,7 @@ import {
16
16
  setRequestError,
17
17
  setRequestUser,
18
18
  wrapInRequestContext
19
- } from "../index-fyfk537k.js";
19
+ } from "../index-sc67e454.js";
20
20
 
21
21
  // src/observability/sanitize.ts
22
22
  var DEFAULT_SENSITIVE_KEYS = /(password|passwd|pwd|secret|token|apikey|api[-_ ]?key|auth|authorization|bearer|session|cookie|init[-_ ]?data|credential|private[-_ ]?key)/i;
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/server/create.ts"],"names":[],"mappings":"AA8CA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAA2B,MAAM,SAAS,CAAC;AAEpF,wBAAgB,aAAa,CAAC,OAAO,GAAG,OAAO,EAC7C,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,GAC7B,YAAY,CAAC,OAAO,CAAC,CAmdvB"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/server/create.ts"],"names":[],"mappings":"AA8CA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAA2B,MAAM,SAAS,CAAC;AAEpF,wBAAgB,aAAa,CAAC,OAAO,GAAG,OAAO,EAC7C,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,GAC7B,YAAY,CAAC,OAAO,CAAC,CAocvB"}
@@ -9,7 +9,7 @@ import {
9
9
  socketIoLane,
10
10
  staticRoute,
11
11
  webSocketLane
12
- } from "../index-7rbzbnnf.js";
12
+ } from "../index-4e1c0hsw.js";
13
13
  import {
14
14
  createAuthHook,
15
15
  createBearerResolver,
@@ -22,7 +22,7 @@ import {
22
22
  signJwt,
23
23
  verifyJwt,
24
24
  verifyPkce
25
- } from "../index-92gs1m5b.js";
25
+ } from "../index-dnkefke9.js";
26
26
  import {
27
27
  DEFAULT_CORS_ALLOW_HEADERS,
28
28
  DEFAULT_CORS_EXPOSE_HEADERS,
@@ -59,7 +59,7 @@ import {
59
59
  resolveTraceId,
60
60
  unauthorized,
61
61
  zodIssues
62
- } from "../index-fyfk537k.js";
62
+ } from "../index-sc67e454.js";
63
63
  // src/server/bun.ts
64
64
  function createServer(config) {
65
65
  const { routes, websocket, development, bun: bunExtra, port = 3000, hostname } = config;
@@ -1,5 +1,5 @@
1
1
  import type { ZodType, z } from 'zod';
2
- import type { RuntimeContext, TransportSource } from '../contract';
2
+ import { AppError, type RuntimeContext, type TransportSource } from '../contract';
3
3
  import type { OperationIdentity } from '../server/types';
4
4
  export type ToolResult = {
5
5
  ok: true;
@@ -10,6 +10,9 @@ export type ToolResult = {
10
10
  details?: unknown;
11
11
  hint?: string;
12
12
  };
13
+ type ToolFailure = Extract<ToolResult, {
14
+ ok: false;
15
+ }>;
13
16
  export interface ToolCallContext {
14
17
  source: TransportSource;
15
18
  [key: string]: unknown;
@@ -114,9 +117,9 @@ export interface ToolArgumentExtension {
114
117
  * `AppError` becomes a tool error. Shared by `executeToolMethod` and both
115
118
  * transport mounts so every tool error has one shape.
116
119
  */
117
- export declare function toolResultFromError(err: unknown): Extract<ToolResult, {
118
- ok: false;
119
- }>;
120
+ export declare function toolResultFromError(err: unknown): ToolFailure;
121
+ /** Recover the normalized AppError behind one canonical failed tool result. */
122
+ export declare function toolErrorFromResult(result: ToolFailure): AppError;
120
123
  export declare function executeToolMethod(method: ToolOperation, toolName: string, rawArgs: Record<string, unknown>, context: ToolCallContext, hooks?: ToolCallHooks, lifecycle?: ToolLifecycle, coerceJson?: boolean, onOutputStrip?: (paths: string[]) => void, extension?: ToolArgumentExtension): Promise<ToolResult>;
121
124
  /**
122
125
  * Run `body` in a request context forked for one tool call — the shared rule,
@@ -133,4 +136,5 @@ export declare function inToolCallContext<T>(call: {
133
136
  toolName: string;
134
137
  method: OperationIdentity;
135
138
  }, body: () => Promise<T>): Promise<T>;
139
+ export {};
136
140
  //# sourceMappingURL=execute.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/tools/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIzD,MAAM,MAAM,UAAU,GAClB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC3B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAElE,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,eAAe,CAAC;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,EAAE,eAAe,CAAC;IACzB,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB;IACjE,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;I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AIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,CAU7D;AAED,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,QAAQ,CAQjE;AAED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,EAAE,eAAe,EACxB,KAAK,CAAC,EAAE,aAAa,EACrB,SAAS,CAAC,EAAE,aAAa,EACzB,UAAU,UAAQ,EAClB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,EACzC,SAAS,CAAC,EAAE,qBAAqB,GAChC,OAAO,CAAC,UAAU,CAAC,CAyBrB;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,IAAI,EAAE;IACJ,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,iBAAiB,CAAC;CAC3B,EACD,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,CAAC,CAAC,CAuBZ"}
@@ -1,29 +1,33 @@
1
1
  import { type Transport, type TransportSource } from '../contract';
2
2
  import type { ServiceDef } from '../server/types';
3
- import type { ToolCallContext, ToolCallHooks, ToolLifecycle, ToolResult } from './execute';
3
+ import { type ToolCallContext, type ToolCallHooks, type ToolLifecycle, type ToolResult } from './execute';
4
4
  import { type ToolExtend } from './mount';
5
5
  export type ToolInvokerTransport = Exclude<Transport, 'HTTP'>;
6
6
  /** Configuration for a compiled in-process contract-tool dispatcher. */
7
7
  export interface ToolInvokerConfig {
8
8
  /** Existing exposure policy to honour. Required: there is no bypass-all mode. */
9
9
  transport: ToolInvokerTransport;
10
- /** Actual call source written to handler context and audit. Default: `internal`. */
11
- source?: TransportSource;
12
- context?: Omit<ToolCallContext, 'source'>;
13
- hooks?: ToolCallHooks;
14
- lifecycle?: ToolLifecycle;
15
10
  extend?: ToolExtend;
16
11
  /** Compiles the same presentation surface as the chosen mount. */
17
12
  flattenUnionInput?: boolean;
18
13
  /** Coerce JSON-stringified arrays/objects in tool arguments. Default: true. */
19
14
  coerceJsonArgs?: boolean;
15
+ }
16
+ /** Runtime state for one in-process invocation; never retained by the registry. */
17
+ export interface ToolInvocationOptions {
18
+ /** Actual call source written to handler context and audit. Default: `internal`. */
19
+ source?: TransportSource;
20
+ context?: Omit<ToolCallContext, 'source'>;
21
+ hooks?: ToolCallHooks;
22
+ lifecycle?: ToolLifecycle;
20
23
  /** Report output keys removed by contract validation. */
21
24
  onOutputStrip?: (toolName: string, paths: string[]) => void;
22
25
  }
23
26
  /** A name-indexed dispatcher compiled once and executed by the shared tool runner. */
24
27
  export interface ToolInvoker {
25
28
  readonly names: readonly string[];
26
- invoke(name: string, args: Record<string, unknown>): Promise<ToolResult>;
29
+ invoke(name: string, args: Record<string, unknown>, options?: ToolInvocationOptions): Promise<ToolResult>;
30
+ invokeOrThrow(name: string, args: Record<string, unknown>, options?: ToolInvocationOptions): Promise<unknown>;
27
31
  }
28
32
  /**
29
33
  * Compile contract tools into an in-process invoker without mounting an SDK.
@@ -1 +1 @@
1
- {"version":3,"file":"invoker.d.ts","sourceRoot":"","sources":["../../src/tools/invoker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAsD,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAG9F,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AAE9D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B,GACxB,WAAW,CA2Db"}
@@ -17,7 +17,7 @@ export type RuntimeToolHandlerContext<TInput extends ZodObject> = RuntimeContext
17
17
  params: undefined;
18
18
  input: z.output<TInput>;
19
19
  };
20
- export type RuntimeToolOutput<TOutput extends ZodType | undefined> = TOutput extends ZodType ? z.output<TOutput> : unknown;
20
+ export type RuntimeToolOutput<TOutput extends ZodType | undefined> = TOutput extends ZodType ? z.output<TOutput> : undefined;
21
21
  /** MCP-owned fields; validation and error state are always supplied by Stitchkit. */
22
22
  export type RuntimeMcpPresentation = Omit<CallToolResult, 'structuredContent' | 'isError'> & {
23
23
  structuredContent?: never;
@@ -45,7 +45,7 @@ export interface RuntimeToolDefinitionWithOutput<TInput extends ZodObject, TOutp
45
45
  }
46
46
  export interface RuntimeToolDefinitionWithoutOutput<TInput extends ZodObject> extends RuntimeToolDefinitionBase<TInput> {
47
47
  output?: never;
48
- handler: (context: RuntimeToolHandlerContext<TInput>) => unknown | Promise<unknown>;
48
+ handler: (context: RuntimeToolHandlerContext<TInput>) => void | Promise<void>;
49
49
  present?: never;
50
50
  }
51
51
  export type RuntimeToolDefinition = RuntimeToolDefinitionWithOutput<ZodObject, ZodType> | RuntimeToolDefinitionWithoutOutput<ZodObject>;
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-tool.d.ts","sourceRoot":"","sources":["../../src/tools/runtime-tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACjD,OAAO,KAAK,EACV,uBAAuB,EACvB,cAAc,EACd,UAAU,EACV,cAAc,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EAAE,aAAa,E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AqB,GAAG,iBAAiB,CAYxF;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,qBAAqB,GAAG,aAAa,CAkBrF"}
package/dist/tools.d.ts CHANGED
@@ -7,7 +7,7 @@ export type { CliWaitConfig } from './tools/cli-wait';
7
7
  export { coerceJsonArgs } from './tools/coerce';
8
8
  export type { AfterToolCallOptions, BeforeToolCallOptions, ErrorHintFn, ToolCallContext, ToolCallHooks, ToolErrorOptions, ToolLifecycle, ToolOperation, ToolResult, } from './tools/execute';
9
9
  export { flattenToolJsonSchema, type ToolPresentationSchema, } from './tools/flatten';
10
- export { createToolInvoker, type ToolInvoker, type ToolInvokerConfig, type ToolInvokerTransport, } from './tools/invoker';
10
+ export { createToolInvoker, type ToolInvocationOptions, type ToolInvoker, type ToolInvokerConfig, type ToolInvokerTransport, } from './tools/invoker';
11
11
  export { listToolNames, type ToolNameEntry } from './tools/list-names';
12
12
  export { buildToolManifest, type ToolManifestEntry } from './tools/manifest';
13
13
  export { buildMcpServer, type IncompatibleSchemaPolicy, type McpMountConfig, type McpSchemaValidationConfig, type McpServerBuildConfig, mountMcp, mountMcpResource, type ValidateMcpSchemasConfig, validateMcpSchemas, } from './tools/mcp';
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAA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yB,EAC9B,KAAK,+BAA+B,EACpC,KAAK,kCAAkC,EACvC,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EACL,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,aAAa,EACb,YAAY,EACZ,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAC"}
package/dist/tools.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  inputIsQuery,
3
3
  signJwt,
4
4
  verifyPkce
5
- } from "./index-92gs1m5b.js";
5
+ } from "./index-dnkefke9.js";
6
6
  import {
7
7
  DEFAULT_CORS_ALLOW_HEADERS
8
8
  } from "./index-6jypn22c.js";
@@ -22,9 +22,10 @@ import {
22
22
  pollUntil,
23
23
  presentationMetadata,
24
24
  readCapped,
25
+ toolErrorFromResult,
25
26
  toolResultFromError,
26
27
  writeDownload
27
- } from "./index-y5scd1cr.js";
28
+ } from "./index-ncqqn1bc.js";
28
29
  import {
29
30
  toJsonSchema
30
31
  } from "./index-frfyw9fa.js";
@@ -38,7 +39,7 @@ import {
38
39
  mergeMeta,
39
40
  parseTrailingWildcard,
40
41
  typedEntries
41
- } from "./index-fyfk537k.js";
42
+ } from "./index-sc67e454.js";
42
43
 
43
44
  // src/tools/agent.ts
44
45
  import { jsonSchema, tool } from "ai";
@@ -188,25 +189,36 @@ function createToolInvoker(services, config) {
188
189
  }
189
190
  }
190
191
  const names = Object.freeze([...tools.keys()].sort());
191
- const runTool = createToolRunner({
192
- source: config.source ?? "internal",
193
- context: config.context,
194
- hooks: config.hooks,
195
- lifecycle: config.lifecycle,
196
- extend: config.extend,
197
- coerceJsonArgs: config.coerceJsonArgs,
198
- onOutputStrip: config.onOutputStrip
199
- });
192
+ const operation = (name) => {
193
+ const tool2 = tools.get(name);
194
+ if (tool2)
195
+ return tool2;
196
+ throw new AppError("NOT_FOUND", `Unknown tool: ${name}`, 404, {
197
+ available: names
198
+ });
199
+ };
200
+ const run = (name, args, options = {}) => {
201
+ const runTool = createToolRunner({
202
+ source: options.source ?? "internal",
203
+ context: options.context,
204
+ hooks: options.hooks,
205
+ lifecycle: options.lifecycle,
206
+ extend: config.extend,
207
+ coerceJsonArgs: config.coerceJsonArgs,
208
+ onOutputStrip: options.onOutputStrip
209
+ });
210
+ return runTool(operation(name), args);
211
+ };
200
212
  return Object.freeze({
201
213
  names,
202
- invoke(name, args) {
203
- const tool2 = tools.get(name);
204
- if (!tool2) {
205
- throw new AppError("NOT_FOUND", `Unknown tool: ${name}`, 404, {
206
- available: names
207
- });
208
- }
209
- return runTool(tool2, args);
214
+ invoke(name, args, options) {
215
+ return run(name, args, options);
216
+ },
217
+ async invokeOrThrow(name, args, options) {
218
+ const result = await run(name, args, options);
219
+ if (!result.ok)
220
+ throw toolErrorFromResult(result);
221
+ return result.data;
210
222
  }
211
223
  });
212
224
  }
@@ -1478,7 +1490,7 @@ function parseApiErrorBody(body) {
1478
1490
 
1479
1491
  // src/browser/client.ts
1480
1492
  function withTimeout(options, endpoint) {
1481
- const responseType = endpoint.rawResponse ? "response" : undefined;
1493
+ const responseType = endpoint.rawResponse ? "response" : endpoint.output ? undefined : "void";
1482
1494
  if (endpoint.timeout === undefined && responseType === undefined)
1483
1495
  return options;
1484
1496
  return {
@@ -1488,10 +1500,20 @@ function withTimeout(options, endpoint) {
1488
1500
  };
1489
1501
  }
1490
1502
  function withOutput(endpoint, result) {
1491
- const schema = endpoint.output;
1492
- if (!schema)
1503
+ if (endpoint.rawResponse)
1493
1504
  return result;
1494
- return result.then((value) => value === undefined ? undefined : schema.parse(value));
1505
+ const schema = endpoint.output;
1506
+ return result.then((value) => {
1507
+ if (!schema) {
1508
+ if (value === undefined || value === null)
1509
+ return;
1510
+ throw new Error("Server returned data for an endpoint with no output contract");
1511
+ }
1512
+ if (value === undefined) {
1513
+ throw new Error("Server returned no body for an endpoint with an output contract");
1514
+ }
1515
+ return schema.parse(value);
1516
+ });
1495
1517
  }
1496
1518
  function createClient(contract, configOrClient, contractConfig) {
1497
1519
  const client = {};
@@ -1568,10 +1590,14 @@ function createFetchMethod(endpoint, prefix, config, contractConfig) {
1568
1590
  }
1569
1591
  if (endpoint.rawResponse)
1570
1592
  return res2;
1571
- if (res2.status === 204)
1593
+ if (!endpoint.output) {
1594
+ const text = await res2.text();
1595
+ if (text.length > 0) {
1596
+ throw new Error("Server returned data for an endpoint with no output contract");
1597
+ }
1572
1598
  return;
1573
- const json3 = await res2.json();
1574
- return endpoint.output ? endpoint.output.parse(json3) : json3;
1599
+ }
1600
+ return endpoint.output.parse(await res2.json());
1575
1601
  }
1576
1602
  const res = await fetch(url, {
1577
1603
  method: endpoint.method,
@@ -1587,10 +1613,14 @@ function createFetchMethod(endpoint, prefix, config, contractConfig) {
1587
1613
  }
1588
1614
  if (endpoint.rawResponse)
1589
1615
  return res;
1590
- if (res.status === 204)
1616
+ if (!endpoint.output) {
1617
+ const text = await res.text();
1618
+ if (text.length > 0) {
1619
+ throw new Error("Server returned data for an endpoint with no output contract");
1620
+ }
1591
1621
  return;
1592
- const json2 = await res.json();
1593
- return endpoint.output ? endpoint.output.parse(json2) : json2;
1622
+ }
1623
+ return endpoint.output.parse(await res.json());
1594
1624
  };
1595
1625
  }
1596
1626
  async function throwForErrorResponse(res, config, fallbackBody) {
package/llms-full.txt CHANGED
@@ -234,7 +234,7 @@ export const users = defineContract({ prefix: 'users' }, {
234
234
  | `desc` | yes | human description — also the MCP / agent tool description |
235
235
  | `params` | no | Zod schema for **path params** (`:id`, …) |
236
236
  | `input` | no | Zod schema for the **request body** (or query, for GET/DELETE) |
237
- | `output` | no | Zod schema for the **response body** |
237
+ | `output` | no | Zod schema for the **response body**; its presence declares a JSON result (`null` is data, `undefined` is not) |
238
238
  | `scope` | no | access scope for this endpoint — see [Auth & errors](./auth-and-errors.md) |
239
239
  | `expose` | no | which transports carry this endpoint — see [below](#transports) |
240
240
  | `toolName` | no | explicit MCP / agent tool name (default: a verb-aware derivation, see below — not a literal `prefix_key`) |
@@ -256,6 +256,13 @@ headers, while Stitchkit guarantees an empty wire body even if the returned
256
256
 
257
257
  ## `params` vs `input` vs `output`
258
258
 
259
+ `output` owns response presence across HTTP and tool transports. With a schema,
260
+ the handler must return a value that validates and can be represented as JSON;
261
+ a nullable schema may return `null`, but `undefined` is always a contract
262
+ violation. Without `output`, the handler is empty (`undefined`/`null`) and may
263
+ not return undeclared data. On HTTP this means a default `200` JSON response
264
+ with output and a default bodyless `204` without it.
265
+
259
266
  The three schemas are distinct on purpose:
260
267
 
261
268
  - **`params`** — values in the URL path. `path: '/:id'` ⇒
@@ -531,11 +538,13 @@ the endpoint is public (fail-open). If every contract in your app must be scoped
531
538
  // app: one line, once
532
539
  export const { defineContract } = createContractFactory<'public' | 'user' | 'admin'>()
533
540
 
534
- // scope is now mandatory and checked against the union
541
+ // scope is mandatory, checked against the union and retained as the 'user' literal
535
542
  export const users = defineContract({ prefix: 'users', scope: 'user' }, { … })
536
543
  ```
537
544
 
538
- The vocabulary is yours; the returned contracts are ordinary `ContractDef`s.
545
+ The vocabulary is yours; each returned `ContractDef` retains its concrete scope
546
+ literal, so scope-aware registries select the exact config without another
547
+ wrapper.
539
548
 
540
549
  ## One source of truth
541
550
 
@@ -908,9 +917,13 @@ HTTP-only, but its typed client method still resolves to `AuthUser` — not
908
917
  declared `output` schema exactly once.
909
918
 
910
919
  `responseMeta.status` is static contract metadata and OpenAPI publishes the same
911
- 2xx code. Without it, data keeps status `200` and no-data keeps `204`. Bodyless
912
- `204`/`205` cannot be combined with `output`. Redirects, streams, files and
913
- handler-owned status/body logic remain [`rawResponse: true`](#raw-response-endpoints).
920
+ 2xx code. Without it, an endpoint with `output` uses `200`; an endpoint without
921
+ `output` uses `204`. A nullable output returns JSON `null` with status `200` —
922
+ the runtime value never turns a declared response body into no content.
923
+ `undefined` violates a declared output, while returning non-null data without an
924
+ output schema is also a server fault. Bodyless `204`/`205` cannot be combined
925
+ with `output`. Redirects, streams, files and handler-owned status/body logic
926
+ remain [`rawResponse: true`](#raw-response-endpoints).
914
927
 
915
928
  Collected headers are merged only after the complete success pipeline. A
916
929
  handler, hook or output-validation failure discards them. `Content-Type`,
@@ -1350,6 +1363,13 @@ await api.update({ id: '1', name: 'M' }) // PUT /users/1 body: { name }
1350
1363
  await api.delete({ id: '1' }) // DELETE /users/1
1351
1364
  ```
1352
1365
 
1366
+ The client follows response presence from the contract, not from the HTTP
1367
+ status or a truthy runtime value. An endpoint with nullable `output` resolves
1368
+ JSON `null` as `null`; an endpoint without `output` resolves `undefined`,
1369
+ including an explicitly declared empty `200` or `205`. A missing body for a
1370
+ declared output, or a body for an endpoint with no output, fails loudly instead
1371
+ of changing the typed result.
1372
+
1353
1373
  An explicit contract `HEAD` operation is exposed like any other typed method.
1354
1374
  Because HEAD endpoints are `rawResponse`, it resolves to the untouched
1355
1375
  `Response`, giving the caller direct access to status and headers without JSON
@@ -1432,7 +1452,7 @@ URL, not a fetched response. `createUrlBuilder` derives those URLs from the same
1432
1452
  contract path planner used by both typed-client transports:
1433
1453
 
1434
1454
  ```ts
1435
- import { createUrlBuilder, createUrlBuilders } from 'stitchkit'
1455
+ import { createScopedUrlBuilders, createUrlBuilder, createUrlBuilders } from 'stitchkit'
1436
1456
 
1437
1457
  const mediaUrls = createUrlBuilder(media, http, {
1438
1458
  stripPrefixKeys: ['tenantId'],
@@ -1453,6 +1473,33 @@ const beaconUrl = mediaUrls.track({ tenantId: 't_123' })
1453
1473
  const urls = createUrlBuilders({ media, exports }, http)
1454
1474
  ```
1455
1475
 
1476
+ When contracts use different dynamic prefixes, route the registry by the same
1477
+ literal `contract.meta.scope` model as `createScopedClients`:
1478
+
1479
+ ```ts
1480
+ const urls = createScopedUrlBuilders(
1481
+ {
1482
+ assets: publicAssets,
1483
+ media: [tenantFiles, tenantMetadata], // one composed namespace
1484
+ },
1485
+ http,
1486
+ {
1487
+ public: {},
1488
+ tenant: {
1489
+ stripPrefixKeys: ['tenantId'],
1490
+ pathPrefix: ({ tenantId }) => `tenants/${tenantId}`,
1491
+ },
1492
+ },
1493
+ )
1494
+
1495
+ urls.assets.logo()
1496
+ urls.media.file({ tenantId: 't1', fileId: 'f' })
1497
+ ```
1498
+
1499
+ Every reachable scope needs a config. A missing config or duplicate method in a
1500
+ composed namespace fails while the registry is built; URL generation itself
1501
+ continues to use the same request planner as `createClient`.
1502
+
1456
1503
  Every HTTP-exposed endpoint appears on a URL builder, including body, multipart
1457
1504
  and raw-response operations. Path and scoped-prefix keys are consumed by the
1458
1505
  path. `GET` and `DELETE` input becomes the query string, including repeated keys
@@ -1693,26 +1740,39 @@ import { createToolInvoker } from 'stitchkit/tools'
1693
1740
 
1694
1741
  const invoker = createToolInvoker(services, {
1695
1742
  transport: 'AGENT', // required exposure policy
1743
+ })
1744
+
1745
+ const result = await invoker.invoke('update_entity', args, {
1696
1746
  source: 'internal', // default; audit names the real call source
1697
1747
  context: { identity },
1698
1748
  lifecycle,
1699
1749
  hooks,
1700
1750
  })
1701
1751
 
1702
- const result = await invoker.invoke('update_entity', args)
1703
- if (!result.ok) throw new AppError(result.code, 'Nested tool call failed')
1752
+ // Composition path: validated data or the exact normalized AppError.
1753
+ const data = await invoker.invokeOrThrow('update_entity', args, {
1754
+ context: { identity },
1755
+ lifecycle,
1756
+ hooks,
1757
+ })
1704
1758
  ```
1705
1759
 
1706
1760
  `transport` is required and uses the exact existing `MCP`, `AGENT` or `CLI`
1707
1761
  exposure rules; there is no internal bypass mode. The immutable name lookup is
1708
- compiled once. Every invocation—including parallel and recursive calls—gets a
1709
- fresh tool-call context and runs the same extension resolution, input/output
1762
+ compiled once. Call-specific identity, context, lifecycle and hooks are passed
1763
+ to `invoke` / `invokeOrThrow`, so one registry can safely serve parallel and
1764
+ recursive calls without retaining request state. Every invocation gets a fresh
1765
+ tool-call context and runs the same extension resolution, input/output
1710
1766
  validation, lifecycle, hooks and output-strip reporter as mounted tools.
1711
1767
 
1712
1768
  `invoke` returns the canonical discriminated `ToolResult`, not an AI SDK or MCP
1713
- presentation envelope. An unknown name throws `AppError('NOT_FOUND')` before
1714
- the runner because there is no operation identity against which hooks could run.
1715
- Duplicate and provider-invalid names fail when the invoker is created.
1769
+ presentation envelope. `invokeOrThrow` returns validated data and throws the
1770
+ runner's normalized `AppError` on failure, preserving an application error's
1771
+ code, status, message, details and hint without reconstructing it from the
1772
+ model-safe envelope. Unexpected throws remain scrubbed. An unknown name throws
1773
+ `AppError('NOT_FOUND')` before the runner because there is no operation identity
1774
+ against which hooks could run. Duplicate and provider-invalid names fail when
1775
+ the invoker is created.
1716
1776
 
1717
1777
  ## MCP — `createMcpHandler`
1718
1778
 
@@ -4059,6 +4119,54 @@ current one *up to* your target, and apply each snippet.
4059
4119
 
4060
4120
  ## Unreleased breaking migrations
4061
4121
 
4122
+ Contract success bodies are now determined by the presence of `output`, not by
4123
+ the handler's runtime value. A nullable output returns JSON `null` with status
4124
+ `200`; `undefined` with a declared output and non-null data without an output
4125
+ schema are contract violations:
4126
+
4127
+ ```ts
4128
+ // nullable JSON data: 200 with body `null`
4129
+ session: {
4130
+ method: 'GET', path: '/session', desc: 'Current session',
4131
+ output: SessionSchema.nullable(),
4132
+ }
4133
+
4134
+ // bodyless operation: 204 with no body
4135
+ logout: {
4136
+ method: 'POST', path: '/logout', desc: 'End the session',
4137
+ }
4138
+ ```
4139
+
4140
+ Add an output schema to every handler that returns data. Omit `output` and
4141
+ return nothing for bodyless operations; runtime tools follow the same rule and
4142
+ type no-output handlers as `void`.
4143
+
4144
+ `createToolInvoker` now separates immutable registry preparation from per-call
4145
+ runtime state. Move source/context/lifecycle/hooks/output-strip reporting from
4146
+ the factory config to the third invocation argument. Use `invokeOrThrow` when a
4147
+ nested operation should preserve the normalized `AppError` instead of returning
4148
+ a model-facing failure envelope:
4149
+
4150
+ ```ts
4151
+ // before
4152
+ const invoker = createToolInvoker(services, {
4153
+ transport: 'AGENT', context: { identity }, lifecycle, hooks,
4154
+ })
4155
+ const result = await invoker.invoke(name, args)
4156
+
4157
+ // after
4158
+ const invoker = createToolInvoker(services, { transport: 'AGENT' })
4159
+ const result = await invoker.invoke(name, args, {
4160
+ context: { identity }, lifecycle, hooks,
4161
+ })
4162
+ const data = await invoker.invokeOrThrow(name, args, {
4163
+ context: { identity }, lifecycle, hooks,
4164
+ })
4165
+ ```
4166
+
4167
+ There is no static runtime-config overload: request identity must not be retained
4168
+ by a reusable compiled registry.
4169
+
4062
4170
  Entity cache handlers now require the cached list shape and CRUD policies. Move
4063
4171
  `listKey` under `list`, make detail keys event-aware, and state the list-item
4064
4172
  identity/projection explicitly:
@@ -4356,8 +4464,10 @@ The browser-and-server entrypoint. Re-exports everything from
4356
4464
  | `createClient` | function | build a typed client from a contract — [guide](../guide/client.md#createclient) |
4357
4465
  | `createClients` | function | build one exact typed client per contract from a registry; accepts the same scoped config and transports as `createClient` |
4358
4466
  | `createScopedClients` | function | build one registry routed by contract scope; arrays compose contracts into one namespace |
4359
- | `ScopeClientConfigs` | _type_ | per-scope client routing configuration consumed by `createScopedClients` |
4467
+ | `createScopedUrlBuilders` | function | build one URL registry routed by contract scope; arrays compose contracts into one namespace |
4468
+ | `ScopeClientConfigs` | _type_ | per-scope routing configuration consumed by scoped clients and URL builders |
4360
4469
  | `ScopedClientRegistry` | _type_ | exact composed registry returned by `createScopedClients` |
4470
+ | `ScopedUrlBuilderRegistry` | _type_ | exact composed registry returned by `createScopedUrlBuilders` |
4361
4471
  | `ClientRegistryValue` | _type_ | one contract or a contract array composing one client namespace |
4362
4472
  | `ClientContract` | _type_ | HTTP-client-compatible contract value used by scoped registries |
4363
4473
  | `RegistryScope` | _type_ | contract-scope union inferred from a scoped client registry value |
@@ -4418,12 +4528,12 @@ from the root `stitchkit`.
4418
4528
  | Export | Kind | Summary |
4419
4529
  |--------|------|---------|
4420
4530
  | `defineContract` | function | declare a contract — [guide](../guide/contracts.md#definecontract) |
4421
- | `createContractFactory` | function | a `defineContract` with a required, typed `scope` — [guide](../guide/contracts.md#scope) |
4531
+ | `createContractFactory` | function | a `defineContract` with a required allowed scope that retains each concrete literal — [guide](../guide/contracts.md#scope) |
4422
4532
  | `ScopedDefineContract` | _type_ | the `defineContract` `createContractFactory` returns |
4423
4533
  | `ALL_TRANSPORTS` | constant | `['HTTP', 'MCP', 'AGENT', 'CLI']` |
4424
4534
  | `ContractDef` | _type_ | a defined contract |
4425
4535
  | `ContractMeta` | _type_ | a contract's `prefix` + optional `scope` and `meta` (a default every endpoint shallow-merges over) |
4426
- | `EndpointDef` | _type_ | a single endpoint definition |
4536
+ | `EndpointDef` | _type_ | a single endpoint definition; `output` declares JSON response presence (`null` is data, `undefined` is invalid) |
4427
4537
  | `HeadEndpointDef` | _type_ | explicit HTTP-only, bodyless `HEAD` endpoint definition |
4428
4538
  | `EndpointResponseMeta` | _type_ | static success metadata declared by an HTTP-only typed-data endpoint |
4429
4539
  | `ResponseMetadata` | _type_ | per-request outbound collector exposed as `ctx.response` only for a `responseMeta` endpoint |
@@ -4704,7 +4814,7 @@ Server-only. Turns contracts into MCP and AI-agent tools. Needs the
4704
4814
  | `RuntimeToolDefinition` | _type_ | transport-neutral pathless operation with identity, schemas, handler and optional presenters |
4705
4815
  | `RuntimeToolDefinitionBase` | _type_ | common name, identity, input, exposure and MCP metadata fields |
4706
4816
  | `RuntimeToolDefinitionWithOutput` | _type_ | runtime definition whose handler and presenters share a validated output type |
4707
- | `RuntimeToolDefinitionWithoutOutput` | _type_ | runtime definition without output validation or presentation callbacks |
4817
+ | `RuntimeToolDefinitionWithoutOutput` | _type_ | runtime definition with a void handler and no presentation callbacks |
4708
4818
  | `RuntimeToolIdentity` | _type_ | `{ serviceName, action, scope?, method, meta? }` for runtime lifecycle/audit |
4709
4819
  | `RuntimeToolHandlerContext` | _type_ | runtime context with the definition's parsed input |
4710
4820
  | `RuntimeToolOutput` | _type_ | output inferred from a runtime tool's optional Zod schema |
@@ -4727,8 +4837,9 @@ Server-only. Turns contracts into MCP and AI-agent tools. Needs the
4727
4837
  | `ToolErrorOptions` | _type_ | `{ toolName, error, context, endpoint }` for a thrown handler-path value |
4728
4838
  | `ErrorHintFn` | _type_ | `(toolName, errorCode) => string \| null` — a per-tool recovery hint, shared by every mount |
4729
4839
  | `ToolResult` | _type_ | the result of one tool call |
4730
- | `ToolInvoker` | _type_ | immutable compiled dispatcher (`names` + `invoke`) |
4731
- | `ToolInvokerConfig` | _type_ | exposure policy, context, lifecycle, hooks and runner options |
4840
+ | `ToolInvoker` | _type_ | immutable compiled dispatcher (`names`, envelope `invoke`, throwing `invokeOrThrow`) |
4841
+ | `ToolInvokerConfig` | _type_ | compile-time exposure, extension and presentation options |
4842
+ | `ToolInvocationOptions` | _type_ | per-call source, context, lifecycle, hooks and output-strip reporter |
4732
4843
  | `ToolInvokerTransport` | _type_ | invoker exposure policy: `MCP \| AGENT \| CLI` |
4733
4844
  | `ToolCallContext` | _type_ | the context every tool hook receives — `{ source }` plus whatever the mount's `context` added |
4734
4845
  | `ViewFileOptions` | _type_ | options for `mountViewFile` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitchkit",
3
- "version": "0.39.0",
3
+ "version": "0.41.0",
4
4
  "description": "Contract-first backend framework — one defineContract() into an HTTP API, MCP tools, AI-agent tools and a typed client. Bun and Node.",
5
5
  "keywords": [
6
6
  "bun",