stitchkit 0.122.2 → 0.123.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.
Files changed (194) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/dist/browser/client.d.ts.map +1 -1
  3. package/dist/browser/contract-identity.d.ts +21 -0
  4. package/dist/browser/contract-identity.d.ts.map +1 -0
  5. package/dist/browser/unknown-operation.d.ts +3 -0
  6. package/dist/browser/unknown-operation.d.ts.map +1 -0
  7. package/dist/contract/define.d.ts +6 -2
  8. package/dist/contract/define.d.ts.map +1 -1
  9. package/dist/contract/endpoint-capabilities.d.ts.map +1 -1
  10. package/dist/contract/errors.d.ts +4 -0
  11. package/dist/contract/errors.d.ts.map +1 -1
  12. package/dist/contract/fingerprint.d.ts +51 -0
  13. package/dist/contract/fingerprint.d.ts.map +1 -0
  14. package/dist/contract/identity.d.ts +21 -0
  15. package/dist/contract/identity.d.ts.map +1 -0
  16. package/dist/contract/stream.d.ts +32 -0
  17. package/dist/contract/stream.d.ts.map +1 -1
  18. package/dist/entrypoints/agent-runtime/browser.js +2 -2
  19. package/dist/entrypoints/agent-runtime/coding-tools.js +11 -11
  20. package/dist/entrypoints/agent-runtime/harness.js +12 -12
  21. package/dist/entrypoints/agent-runtime/openrouter.js +1 -1
  22. package/dist/entrypoints/agent-runtime/realtime.js +2 -2
  23. package/dist/entrypoints/agent-runtime/sandbox.js +11 -11
  24. package/dist/entrypoints/agent-runtime/sqlite/bun.js +15 -15
  25. package/dist/entrypoints/agent-runtime/sqlite/node.js +15 -15
  26. package/dist/entrypoints/agent-runtime/testing.js +15 -15
  27. package/dist/entrypoints/agent-runtime.js +22 -22
  28. package/dist/entrypoints/application/diagnostic-journal.js +5 -5
  29. package/dist/entrypoints/application/directory-inbox.js +5 -5
  30. package/dist/entrypoints/application/grammy.js +1 -1
  31. package/dist/entrypoints/application.js +7 -7
  32. package/dist/entrypoints/cli/publish.js +5 -5
  33. package/dist/entrypoints/cli.d.ts +1 -1
  34. package/dist/entrypoints/cli.d.ts.map +1 -1
  35. package/dist/entrypoints/cli.js +20 -17
  36. package/dist/entrypoints/contract.d.ts +2 -0
  37. package/dist/entrypoints/contract.d.ts.map +1 -1
  38. package/dist/entrypoints/contract.js +11 -5
  39. package/dist/entrypoints/files/packaging.d.ts +1 -0
  40. package/dist/entrypoints/files/packaging.d.ts.map +1 -1
  41. package/dist/entrypoints/files/packaging.js +230 -61
  42. package/dist/entrypoints/files.js +5 -5
  43. package/dist/entrypoints/geo.js +3 -3
  44. package/dist/entrypoints/http.js +3 -3
  45. package/dist/entrypoints/index.d.ts +1 -0
  46. package/dist/entrypoints/index.d.ts.map +1 -1
  47. package/dist/entrypoints/index.js +45 -24
  48. package/dist/entrypoints/live.js +2 -2
  49. package/dist/entrypoints/node.js +11 -11
  50. package/dist/entrypoints/observability.js +4 -4
  51. package/dist/entrypoints/primitives.js +1 -1
  52. package/dist/entrypoints/process/owner-loss.js +2 -2
  53. package/dist/entrypoints/process.d.ts +6 -1
  54. package/dist/entrypoints/process.d.ts.map +1 -1
  55. package/dist/entrypoints/process.js +370 -9
  56. package/dist/entrypoints/react.js +2 -2
  57. package/dist/entrypoints/realtime.js +3 -3
  58. package/dist/entrypoints/remote.js +20 -10
  59. package/dist/entrypoints/server.d.ts +1 -0
  60. package/dist/entrypoints/server.d.ts.map +1 -1
  61. package/dist/entrypoints/server.js +56 -20
  62. package/dist/entrypoints/telegram/screens.js +4 -4
  63. package/dist/entrypoints/telegram.js +6 -6
  64. package/dist/entrypoints/testing.js +10 -10
  65. package/dist/entrypoints/tools/agent.js +9 -9
  66. package/dist/entrypoints/tools/connections.js +7 -7
  67. package/dist/entrypoints/tools/contract.js +1 -1
  68. package/dist/entrypoints/tools/invoker.js +7 -7
  69. package/dist/entrypoints/tools/mcp.js +9 -9
  70. package/dist/entrypoints/tools/toolkit.js +15 -14
  71. package/dist/entrypoints/tools.js +17 -17
  72. package/dist/entrypoints/tracking/contract.js +2 -2
  73. package/dist/entrypoints/tracking.js +1 -1
  74. package/dist/files/client-artifact.d.ts +75 -0
  75. package/dist/files/client-artifact.d.ts.map +1 -0
  76. package/dist/{index-am1h8c9v.js → index-0d3sm0m9.js} +5 -5
  77. package/dist/{index-72xtvcvr.js → index-0ndz5r8z.js} +1 -1
  78. package/dist/index-0v9xb8pz.js +66 -0
  79. package/dist/{index-qcn84byh.js → index-0w0hxp7n.js} +4 -0
  80. package/dist/{index-3za04re9.js → index-1c945ten.js} +1 -1
  81. package/dist/{index-r6v4mc67.js → index-1d7s7da0.js} +1 -1
  82. package/dist/{index-zsvzhjtk.js → index-20hn8pbh.js} +1 -1
  83. package/dist/{index-f6pw75e1.js → index-2x2ch0bt.js} +2 -2
  84. package/dist/{index-61hve0ez.js → index-303qne11.js} +1 -1
  85. package/dist/{index-g149e9pk.js → index-3bzk2645.js} +1 -1
  86. package/dist/index-45dyex0j.js +119 -0
  87. package/dist/{index-nwm3ww60.js → index-64b2dxqz.js} +1 -1
  88. package/dist/{index-aqwg2dm5.js → index-6k47xdtt.js} +2 -2
  89. package/dist/index-7q05ag0z.js +10 -0
  90. package/dist/{index-kz9734jc.js → index-96yjwwgf.js} +6 -5
  91. package/dist/{index-ff39f9dr.js → index-993vtv1w.js} +3 -3
  92. package/dist/{index-4jpykzvw.js → index-99nnsz39.js} +2 -2
  93. package/dist/{index-pfvde2fz.js → index-9ypczvpj.js} +1 -1
  94. package/dist/{index-qch1vcaa.js → index-a7ebd769.js} +2 -2
  95. package/dist/{index-98hv3sba.js → index-aw6kx2e6.js} +1 -1
  96. package/dist/{index-yj6saztf.js → index-bz9cmnqq.js} +96 -14
  97. package/dist/{index-mtwh9hyp.js → index-cjzaj7ev.js} +1 -1
  98. package/dist/{index-gtx3eknx.js → index-dv7pa9w6.js} +2 -2
  99. package/dist/{index-sa99p98w.js → index-eabx6qjh.js} +3 -3
  100. package/dist/{index-8yxgcyt6.js → index-egg0yp2j.js} +1 -1
  101. package/dist/{index-h1j71dr1.js → index-enkc9pem.js} +1 -1
  102. package/dist/{index-aqmadanx.js → index-fa53vygr.js} +2 -2
  103. package/dist/{index-e6c2spsd.js → index-fpwbskp2.js} +1 -1
  104. package/dist/{index-m8a44e64.js → index-ftk3838x.js} +1 -1
  105. package/dist/{index-j95jp7ee.js → index-gdqawggb.js} +1 -1
  106. package/dist/{index-9dyd8xzf.js → index-hkw233vx.js} +2 -2
  107. package/dist/{index-9jfdm5tg.js → index-hkxgennw.js} +7 -1
  108. package/dist/{index-qaqxdbxf.js → index-j8rda9n6.js} +7 -7
  109. package/dist/{index-4tyt1qya.js → index-jc5xgkpk.js} +2 -2
  110. package/dist/{index-s9a0fjh3.js → index-kffm4r8w.js} +1 -1
  111. package/dist/{index-5w6t91ze.js → index-m8ddk770.js} +1 -1
  112. package/dist/{index-2fc1k9k2.js → index-mdyhr36s.js} +32 -122
  113. package/dist/{index-r7a7r7ha.js → index-mfntvj58.js} +6 -3
  114. package/dist/{index-gq3fnq3f.js → index-n90tkkcv.js} +2 -2
  115. package/dist/{index-k42ckyzx.js → index-ndjzbt2v.js} +2 -2
  116. package/dist/{index-ycqhyars.js → index-qc7tq0za.js} +3 -3
  117. package/dist/{index-9frf01t9.js → index-r0xr7y4m.js} +1 -1
  118. package/dist/{index-s3yxw6kt.js → index-s512scra.js} +9 -7
  119. package/dist/{index-1h2zv8rx.js → index-sqc6ezrb.js} +41 -1
  120. package/dist/{index-2bqf0a74.js → index-sqkttz7z.js} +1 -1
  121. package/dist/{index-rbzq0q16.js → index-t8jz0e20.js} +1 -1
  122. package/dist/{index-8ryydawp.js → index-tt3ej8r3.js} +1 -1
  123. package/dist/{index-x4p3kw1p.js → index-tynna0n4.js} +6 -6
  124. package/dist/{index-72r9k0av.js → index-v62cpkx3.js} +1 -1
  125. package/dist/{index-10rg78vf.js → index-v8xm2s9v.js} +2 -2
  126. package/dist/{index-y6ye582c.js → index-w0wy05gr.js} +10 -10
  127. package/dist/{index-kw1ws0cs.js → index-w3nv6kr8.js} +1 -1
  128. package/dist/{index-eeahxwvg.js → index-ww3gss55.js} +1 -1
  129. package/dist/{index-6j15ktag.js → index-wzqd6pen.js} +1 -1
  130. package/dist/{index-aswegq1r.js → index-xjb131sc.js} +367 -131
  131. package/dist/{index-1fyea34p.js → index-yebkpytc.js} +5 -5
  132. package/dist/{index-bgcwxhxh.js → index-yfpt7sxr.js} +24 -46
  133. package/dist/{index-69t14s4a.js → index-yt1gg11x.js} +3 -2
  134. package/dist/{index-jk29rwkr.js → index-zfncctjp.js} +1 -1
  135. package/dist/internal/stable-digest.d.ts +5 -0
  136. package/dist/internal/stable-digest.d.ts.map +1 -1
  137. package/dist/internal/typed.d.ts +2 -0
  138. package/dist/internal/typed.d.ts.map +1 -1
  139. package/dist/process/operation-child.d.ts +38 -0
  140. package/dist/process/operation-child.d.ts.map +1 -0
  141. package/dist/process/operation-wire.d.ts +68 -0
  142. package/dist/process/operation-wire.d.ts.map +1 -0
  143. package/dist/process/operation.d.ts +74 -0
  144. package/dist/process/operation.d.ts.map +1 -0
  145. package/dist/server/contract-identity.d.ts +10 -0
  146. package/dist/server/contract-identity.d.ts.map +1 -0
  147. package/dist/server/contract-stream.d.ts.map +1 -1
  148. package/dist/server/endpoint-response.d.ts.map +1 -1
  149. package/dist/server/error-hook.d.ts +1 -0
  150. package/dist/server/error-hook.d.ts.map +1 -1
  151. package/dist/tools/cli/args-route.d.ts.map +1 -1
  152. package/dist/tools/cli/args-tokens.d.ts.map +1 -1
  153. package/dist/tools/cli/command.d.ts +39 -18
  154. package/dist/tools/cli/command.d.ts.map +1 -1
  155. package/dist/tools/cli/format.d.ts.map +1 -1
  156. package/dist/tools/cli/help.d.ts.map +1 -1
  157. package/dist/tools/cli/invoke.d.ts +3 -1
  158. package/dist/tools/cli/invoke.d.ts.map +1 -1
  159. package/dist/tools/cli/io.d.ts +6 -0
  160. package/dist/tools/cli/io.d.ts.map +1 -1
  161. package/dist/tools/cli/managed-surface.d.ts +2 -0
  162. package/dist/tools/cli/managed-surface.d.ts.map +1 -1
  163. package/dist/tools/cli/policy.d.ts +14 -0
  164. package/dist/tools/cli/policy.d.ts.map +1 -1
  165. package/dist/tools/cli/run-managed.d.ts.map +1 -1
  166. package/dist/tools/cli/run-native.d.ts.map +1 -1
  167. package/dist/tools/cli/run-stream.d.ts +23 -0
  168. package/dist/tools/cli/run-stream.d.ts.map +1 -0
  169. package/dist/tools/cli/session.d.ts +8 -0
  170. package/dist/tools/cli/session.d.ts.map +1 -1
  171. package/dist/tools/cli/stream-surface.d.ts +17 -0
  172. package/dist/tools/cli/stream-surface.d.ts.map +1 -0
  173. package/dist/tools/execute.d.ts +7 -1
  174. package/dist/tools/execute.d.ts.map +1 -1
  175. package/dist/tools/invoker.d.ts.map +1 -1
  176. package/dist/tools/remote.d.ts.map +1 -1
  177. package/llms/cli.2.txt +56 -1
  178. package/llms/cli.txt +68 -1
  179. package/llms/contract.txt +4 -1
  180. package/llms/files-packaging.txt +10 -0
  181. package/llms/process.2.txt +75 -1
  182. package/llms/process.txt +59 -25
  183. package/llms/server.4.txt +8 -4
  184. package/llms/server.5.txt +1 -0
  185. package/llms/stitchkit.2.txt +74 -0
  186. package/llms/stitchkit.txt +5 -5
  187. package/llms/tools.txt +1 -1
  188. package/llms/{upgrading-0.106.0-0.122.0.txt → upgrading-0.106.0-0.123.0.txt} +50 -3
  189. package/llms/upgrading.txt +1 -1
  190. package/llms-full.txt +379 -13
  191. package/llms.txt +7 -7
  192. package/package.json +1 -1
  193. package/dist/index-h2fhjqy7.js +0 -19
  194. package/dist/index-m5m9rmvt.js +0 -44
@@ -2,11 +2,11 @@ import {
2
2
  toolResultFromError,
3
3
  toolCauseFromResult,
4
4
  isToolExecutionControlError2
5
- } from "./index-s3yxw6kt.js";
5
+ } from "./index-s512scra.js";
6
6
  import {
7
7
  createToolRunner,
8
8
  formatToolError
9
- } from "./index-ycqhyars.js";
9
+ } from "./index-qc7tq0za.js";
10
10
  import {
11
11
  resolveRuntimeToolCall
12
12
  } from "./index-eh71zr32.js";
@@ -15,13 +15,13 @@ import {
15
15
  } from "./index-1psbyyhj.js";
16
16
  import {
17
17
  collectToolSurface
18
- } from "./index-ff39f9dr.js";
18
+ } from "./index-993vtv1w.js";
19
19
  import {
20
20
  agentPresenterOf
21
- } from "./index-aqwg2dm5.js";
21
+ } from "./index-6k47xdtt.js";
22
22
  import {
23
23
  isRecord
24
- } from "./index-9jfdm5tg.js";
24
+ } from "./index-hkxgennw.js";
25
25
 
26
26
  // src/tools/agent.ts
27
27
  import { jsonSchema, tool } from "ai";
@@ -3,10 +3,12 @@ import {
3
3
  recordedErrorMessage,
4
4
  normalizeError2,
5
5
  validateDeclaredOutput
6
- } from "./index-k42ckyzx.js";
6
+ } from "./index-ndjzbt2v.js";
7
7
  import {
8
- DEFAULT_CONTRACT_STREAM_FRAME_BYTES2
9
- } from "./index-h2fhjqy7.js";
8
+ DEFAULT_CONTRACT_STREAM_FRAME_BYTES2,
9
+ readContractStreamItems,
10
+ contractStreamLifetimeExceeded
11
+ } from "./index-0v9xb8pz.js";
10
12
  import {
11
13
  joinRoutePath,
12
14
  parseTrailingWildcard
@@ -32,7 +34,7 @@ import {
32
34
  import {
33
35
  bindContract,
34
36
  mediaTypeEssence
35
- } from "./index-sa99p98w.js";
37
+ } from "./index-eabx6qjh.js";
36
38
  import {
37
39
  assertCorsConfig,
38
40
  isOriginAllowed,
@@ -45,14 +47,14 @@ import {
45
47
  getRequestContext2,
46
48
  setRequestEndpoint2,
47
49
  setRequestError2
48
- } from "./index-r6v4mc67.js";
50
+ } from "./index-1d7s7da0.js";
49
51
  import {
50
52
  resolveTraceId2,
51
53
  resolveSocketIp2,
52
54
  extractIp2,
53
55
  getClientInfo2,
54
56
  parseQueryParams
55
- } from "./index-kw1ws0cs.js";
57
+ } from "./index-w3nv6kr8.js";
56
58
  import {
57
59
  isUnsafeKey,
58
60
  safeJsonParse
@@ -66,21 +68,21 @@ import {
66
68
  assertPositiveSafeInteger
67
69
  } from "./index-0s4xebbg.js";
68
70
  import {
69
- abortReason,
70
- untilAborted
71
+ abortReason
71
72
  } from "./index-a5qr2rj6.js";
72
73
  import {
73
74
  AppError2,
74
75
  badRequest2,
75
76
  forbidden2
76
- } from "./index-qcn84byh.js";
77
+ } from "./index-0w0hxp7n.js";
77
78
  import {
78
79
  resolveTraceContext2
79
80
  } from "./index-yex7eg1v.js";
80
81
  import {
81
82
  isRecord,
83
+ isAsyncIterable,
82
84
  transportResult
83
- } from "./index-9jfdm5tg.js";
85
+ } from "./index-hkxgennw.js";
84
86
 
85
87
  // src/server/context-contribution.ts
86
88
  var RUNTIME_CONTEXT_RESERVED_KEYS = new Set([
@@ -1042,25 +1044,11 @@ function contractStreamResponse(request, context, source, descriptor, operationA
1042
1044
  const frames = async function* () {
1043
1045
  if (closing)
1044
1046
  return;
1045
- let terminalSeen = descriptor.terminal === undefined;
1046
1047
  try {
1047
- for (;; ) {
1048
- pendingNext = Promise.resolve(iterator.next());
1049
- const next = await untilAborted(pendingNext, operationAbort.signal);
1050
- if (next.done)
1051
- break;
1052
- const parsed = descriptor.item.safeParse(next.value);
1053
- if (!parsed.success) {
1054
- console.error("[stitchkit] contract stream item failed validation:", parsed.error);
1055
- throw new AppError2("STREAM_ITEM_INVALID", {
1056
- message: "Stream item did not match its contract",
1057
- status: 500
1058
- });
1059
- }
1060
- const item = parsed.data;
1061
- const terminal = descriptor.terminal?.safeParse(item).success ?? false;
1062
- if (terminal)
1063
- terminalSeen = true;
1048
+ const items = readContractStreamItems(iterator, descriptor, operationAbort.signal, (pending) => {
1049
+ pendingNext = pending;
1050
+ });
1051
+ for await (const { item, terminal } of items) {
1064
1052
  const frame = descriptor.framing === "item" ? item : { type: "data", data: item };
1065
1053
  if (encodedBytes(frame, format) > maxFrameBytes) {
1066
1054
  console.error(`[stitchkit] contract stream frame exceeded its ${maxFrameBytes} byte limit`);
@@ -1073,12 +1061,6 @@ function contractStreamResponse(request, context, source, descriptor, operationA
1073
1061
  if (terminal && descriptor.completion === "terminal")
1074
1062
  return;
1075
1063
  }
1076
- if (!terminalSeen) {
1077
- throw new AppError2("STREAM_TERMINAL_MISSING", {
1078
- message: "Stream completed before its declared terminal item",
1079
- status: 500
1080
- });
1081
- }
1082
1064
  if (descriptor.framing !== "item")
1083
1065
  yield { type: "end" };
1084
1066
  } catch (error) {
@@ -1089,10 +1071,7 @@ function contractStreamResponse(request, context, source, descriptor, operationA
1089
1071
  return;
1090
1072
  yield {
1091
1073
  type: "error",
1092
- error: new AppError2("STREAM_LIFETIME_EXCEEDED", {
1093
- message: "Stream exceeded its declared lifetime",
1094
- status: 408
1095
- }).toJSON().error
1074
+ error: contractStreamLifetimeExceeded().toJSON().error
1096
1075
  };
1097
1076
  return;
1098
1077
  }
@@ -1152,12 +1131,6 @@ function applyResponseMetadata(target, metadata, endpointIdentity) {
1152
1131
  }
1153
1132
 
1154
1133
  // src/server/endpoint-response.ts
1155
- function isAsyncIterable(value) {
1156
- if (typeof value !== "object" && typeof value !== "function" || value === null) {
1157
- return false;
1158
- }
1159
- return typeof Reflect.get(value, Symbol.asyncIterator) === "function";
1160
- }
1161
1134
  async function endpointResponse(state, request, outcome) {
1162
1135
  const { method } = outcome.match;
1163
1136
  if (method.rawResponse)
@@ -2127,12 +2100,17 @@ async function dispatch(state, req, url, traceId, server, clientIp, startedAt) {
2127
2100
  if (allow.length > 0) {
2128
2101
  const res = await respondError(new AppError2("METHOD_NOT_ALLOWED", {
2129
2102
  message: `Method ${req.method} not allowed`,
2130
- status: 405
2103
+ status: 405,
2104
+ details: { method: req.method, path: url.pathname, allow }
2131
2105
  }));
2132
2106
  res.headers.set("Allow", allow.join(", "));
2133
2107
  return res;
2134
2108
  }
2135
- return respondError(new AppError2("NOT_FOUND", { message: "Not found", status: 404 }));
2109
+ return respondError(new AppError2("UNKNOWN_OPERATION", {
2110
+ message: `No operation at ${req.method} ${url.pathname}`,
2111
+ status: 404,
2112
+ details: { method: req.method, path: url.pathname }
2113
+ }));
2136
2114
  }
2137
2115
  return dispatchEndpoint(state, request, match);
2138
2116
  }
@@ -29,9 +29,10 @@ function assertEndpointExposure(prefix, key, endpoint) {
29
29
  throw new Error(`${where} expose must be an array of distinct transports: ${ALL_TRANSPORTS2.join(" / ")}`);
30
30
  }
31
31
  if (isHttpOnlyEndpoint(endpoint)) {
32
- const unsupported = exposure.data.filter((transport) => transport !== "HTTP");
32
+ const carriers = "stream" in endpoint && endpoint.stream ? ["HTTP", "CLI"] : ["HTTP"];
33
+ const unsupported = exposure.data.filter((transport) => !carriers.includes(transport));
33
34
  if (unsupported.length > 0) {
34
- throw new Error(`${where} is HTTP-only — remove ${unsupported.join(", ")} from expose`);
35
+ throw new Error(carriers.length > 1 ? `${where} is a stream, carried by ${carriers.join(" and ")} only — remove ${unsupported.join(", ")} from expose` : `${where} is HTTP-only — remove ${unsupported.join(", ")} from expose`);
35
36
  }
36
37
  }
37
38
  }
@@ -2,7 +2,7 @@ import {
2
2
  parseRealtimeRequestArguments,
3
3
  parseRealtimeRequestAcknowledgement,
4
4
  createValidatedRealtimeSocket
5
- } from "./index-3za04re9.js";
5
+ } from "./index-1c945ten.js";
6
6
  import {
7
7
  randomHex
8
8
  } from "./index-c9d05kvt.js";
@@ -12,4 +12,9 @@
12
12
  * construction; a caller digesting something else has to say what it means.
13
13
  */
14
14
  export declare function argumentsDigest(args: Record<string, unknown>): string;
15
+ /**
16
+ * The same 128-bit identity over any JSON value — a schema, a set of
17
+ * operations — for callers whose subject is not a call's arguments.
18
+ */
19
+ export declare function canonicalDigest(value: unknown): string;
15
20
  //# sourceMappingURL=stable-digest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stable-digest.d.ts","sourceRoot":"","sources":["../../src/internal/stable-digest.ts"],"names":[],"mappings":"AA6EA;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAGrE"}
1
+ {"version":3,"file":"stable-digest.d.ts","sourceRoot":"","sources":["../../src/internal/stable-digest.ts"],"names":[],"mappings":"AA6EA;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAErE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAGtD"}
@@ -3,6 +3,8 @@ export declare function typedEntries<T extends object>(value: T): Array<{
3
3
  }[keyof T]>;
4
4
  /** Narrow an unknown value to a plain object — not `null`, not an array. */
5
5
  export declare function isRecord(value: unknown): value is Record<string, unknown>;
6
+ /** Whether a value can be read with `for await` — an async generator, a stream, any async iterable. */
7
+ export declare function isAsyncIterable(value: unknown): value is AsyncIterable<unknown>;
6
8
  /** Invoke a runtime-discovered handler after a fail-first function check. */
7
9
  export declare function callRuntimeHandler(handler: unknown, context: unknown): unknown;
8
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"typed.d.ts","sourceRoot":"","sources":["../../src/internal/typed.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAC3C,KAAK,EAAE,CAAC,GACP,KAAK,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAE/C;AAED,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAK9E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAEpD;AAED,wBAAgB,SAAS,CACvB,OAAO,SAA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CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAEpD;AAED,wBAAgB,SAAS,CACvB,OAAO,SAAS,MAAM,EACtB,OAAO,SAAS;KAAG,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,EAAE,OAAO;CAAE,EAElD,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,CAAC,CAAC,SAAS,MAAM,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,GACrF,OAAO,CAOT;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,SAAS,MAAM,EACtB,OAAO,SAAS;KAAG,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,EAAE,OAAO;CAAE,EAElD,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,OAAO,CAAC,KAAK,OAAO,GACrE,OAAO,CAKT"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * What `runOperationProcess` reads of a service: `implement(contract, handlers)` fits. Stated
3
+ * structurally because this part stands below the server part and cannot name its `ServiceDef`.
4
+ */
5
+ export interface OperationProcessService {
6
+ methods: Record<string, {
7
+ serviceName: string;
8
+ key: string;
9
+ handler(context: {
10
+ params: unknown;
11
+ input: unknown;
12
+ source: string;
13
+ signal: AbortSignal;
14
+ }): unknown;
15
+ }>;
16
+ }
17
+ /** Where `runOperationProcess` reads its call, writes its answer and learns it must stop. */
18
+ export interface OperationProcessIo {
19
+ /** The call. Default: all of `process.stdin`. */
20
+ readCall?: () => Promise<string>;
21
+ /** Default: `process.stdout`, awaited so a slow reader slows the handler. */
22
+ write?: (text: string) => Promise<void>;
23
+ /** Aborted when the server stops this process. Default: `SIGTERM` and `SIGINT`. */
24
+ signal?: AbortSignal;
25
+ }
26
+ /**
27
+ * The child side: read one call from stdin, run it against `services`, write
28
+ * the answer. Returns the process exit code — `0` whenever an answer was
29
+ * written, a refusal included, because a refusal is an answer.
30
+ *
31
+ * The call arrives already validated: the server parsed `params` and `input`
32
+ * through the operation's schemas before it started this process, and it
33
+ * validates the answer against the output schema after. Both cross the process
34
+ * boundary as JSON, so a schema whose parsed value JSON cannot carry — a
35
+ * `Date`, a `Map`, a `bigint` — cannot be an input or an output here.
36
+ */
37
+ export declare function runOperationProcess(services: readonly OperationProcessService[], io?: OperationProcessIo): Promise<number>;
38
+ //# sourceMappingURL=operation-child.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-child.d.ts","sourceRoot":"","sources":["../../src/process/operation-child.ts"],"names":[],"mappings":"AAeA;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CACb,MAAM,EACN;QACE,WAAW,EAAE,MAAM,CAAC;QACpB,GAAG,EAAE,MAAM,CAAC;QACZ,OAAO,CAAC,OAAO,EAAE;YACf,MAAM,EAAE,OAAO,CAAC;YAChB,KAAK,EAAE,OAAO,CAAC;YACf,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,EAAE,WAAW,CAAC;SACrB,GAAG,OAAO,CAAC;KACb,CACF,CAAC;CACH;AAED,6FAA6F;AAC7F,MAAM,WAAW,kBAAkB;IACjC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,6EAA6E;IAC7E,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,mFAAmF;IACnF,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAoCD;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,SAAS,uBAAuB,EAAE,EAC5C,EAAE,GAAE,kBAAuB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAuDjB"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * What crosses between a server and the process that runs one of its
3
+ * operations: one call on stdin, one answer — or a line per stream frame — on
4
+ * stdout. Both sides parse with these schemas, so neither can drift alone.
5
+ */
6
+ import { z } from 'zod';
7
+ /**
8
+ * The most one call may weigh. The server refuses to send more and the child
9
+ * refuses to read more: a call is a request, and the bytes an operation works
10
+ * on belong in a file it is told the path of.
11
+ */
12
+ export declare const MAX_CALL_BYTES: number;
13
+ /** The call one child process receives on stdin. */
14
+ export declare const OperationCallSchema: z.ZodObject<{
15
+ operation: z.ZodString;
16
+ kind: z.ZodEnum<{
17
+ stream: "stream";
18
+ unary: "unary";
19
+ }>;
20
+ params: z.ZodOptional<z.ZodUnknown>;
21
+ input: z.ZodOptional<z.ZodUnknown>;
22
+ }, z.core.$strict>;
23
+ /**
24
+ * A refusal as it crosses the process boundary: the stream error envelope every
25
+ * contract stream already speaks, plus the HTTP status the envelope leaves to
26
+ * the response line — here there is no response line to carry it.
27
+ */
28
+ export declare const OperationErrorSchema: z.ZodObject<{
29
+ code: z.ZodString;
30
+ message: z.ZodOptional<z.ZodString>;
31
+ details: z.ZodOptional<z.ZodUnknown>;
32
+ hint: z.ZodOptional<z.ZodString>;
33
+ retryable: z.ZodOptional<z.ZodBoolean>;
34
+ status: z.ZodOptional<z.ZodNumber>;
35
+ }, z.core.$strict>;
36
+ /** One line of a streamed answer: a contract stream frame whose error keeps its status. */
37
+ export declare const OperationFrameSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
38
+ type: z.ZodLiteral<"data">;
39
+ data: z.ZodUnknown;
40
+ }, z.core.$strict>, z.ZodObject<{
41
+ type: z.ZodLiteral<"error">;
42
+ error: z.ZodObject<{
43
+ code: z.ZodString;
44
+ message: z.ZodOptional<z.ZodString>;
45
+ details: z.ZodOptional<z.ZodUnknown>;
46
+ hint: z.ZodOptional<z.ZodString>;
47
+ retryable: z.ZodOptional<z.ZodBoolean>;
48
+ status: z.ZodOptional<z.ZodNumber>;
49
+ }, z.core.$strict>;
50
+ }, z.core.$strict>, z.ZodObject<{
51
+ type: z.ZodLiteral<"end">;
52
+ }, z.core.$strict>], "type">;
53
+ /** The single answer of a unary operation, one JSON document on stdout. */
54
+ export declare const OperationAnswerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
55
+ ok: z.ZodLiteral<true>;
56
+ data: z.ZodOptional<z.ZodUnknown>;
57
+ }, z.core.$strict>, z.ZodObject<{
58
+ ok: z.ZodLiteral<false>;
59
+ error: z.ZodObject<{
60
+ code: z.ZodString;
61
+ message: z.ZodOptional<z.ZodString>;
62
+ details: z.ZodOptional<z.ZodUnknown>;
63
+ hint: z.ZodOptional<z.ZodString>;
64
+ retryable: z.ZodOptional<z.ZodBoolean>;
65
+ status: z.ZodOptional<z.ZodNumber>;
66
+ }, z.core.$strict>;
67
+ }, z.core.$strict>], "ok">;
68
+ //# sourceMappingURL=operation-wire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-wire.d.ts","sourceRoot":"","sources":["../../src/process/operation-wire.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAmB,CAAC;AAE/C,oDAAoD;AACpD,eAAO,MAAM,mBAAmB;;;;;;;;kBAK9B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;kBAE/B,CAAC;AAEH,2FAA2F;AAC3F,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;4BAI/B,CAAC;AAEH,2EAA2E;AAC3E,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;0BAGhC,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * A contract operation executed in a process of its own.
3
+ *
4
+ * A handler that reads gigabytes holds the server's event loop for as long as
5
+ * it reads, and every cheap operation on that server waits behind it. Moving
6
+ * the work to a child process keeps the loop free, and the mechanics around the
7
+ * child are the same for every application: hand the validated call over, bound
8
+ * what comes back, end the process when the caller leaves or the deadline
9
+ * passes, and refuse — not queue — a call the machine has no room for.
10
+ *
11
+ * The server side is `createOperationProcesses`: its `unary` and `stream`
12
+ * return ordinary contract handlers, so the operation is implemented, routed,
13
+ * gated and validated exactly like one that runs in process. The child side is
14
+ * `runOperationProcess`, fed the same `implement(contract, handlers)` services.
15
+ */
16
+ import type { z } from 'zod';
17
+ import type { ContractDef, EndpointDef } from '../contract/define.js';
18
+ import { type NativeCommandOptions } from './contract.js';
19
+ /** The child command of `createOperationProcesses` and the three bounds every call runs under. */
20
+ export interface OperationProcessesConfig {
21
+ /**
22
+ * The command that runs `runOperationProcess` — typically this application's
23
+ * own executable with a private argument. One process is started per call.
24
+ */
25
+ command: Pick<NativeCommandOptions, 'executable' | 'args' | 'cwd' | 'env' | 'envPolicy' | 'ownerLoss' | 'stop'>;
26
+ /** Calls running at once. A call beyond it is refused with `OPERATION_BUSY`, never queued. */
27
+ maxConcurrent: number;
28
+ /**
29
+ * Bytes one answer may take: the whole answer of a unary operation, one item
30
+ * of a stream. More is refused with `OPERATION_RESPONSE_TOO_LARGE`.
31
+ */
32
+ maxResponseBytes: number;
33
+ /** Deadline of one unary call, from process start. A stream lives until it ends or is cancelled. */
34
+ timeoutMs: number;
35
+ }
36
+ /** What a handler built by `createOperationProcesses` reads of its call. */
37
+ export interface OperationCallContext {
38
+ params?: unknown;
39
+ input?: unknown;
40
+ signal?: AbortSignal;
41
+ }
42
+ type OperationOutput<E> = E extends {
43
+ output: z.ZodType<infer O>;
44
+ } ? O : undefined;
45
+ type OperationItem<E> = E extends {
46
+ stream: {
47
+ item: z.ZodType<infer I>;
48
+ };
49
+ } ? I : never;
50
+ type StreamOperationKeys<T> = {
51
+ [K in keyof T]: T[K] extends {
52
+ stream: object;
53
+ } ? K : never;
54
+ }[keyof T];
55
+ type UnaryOperationKeys<T> = Exclude<keyof T, StreamOperationKeys<T>>;
56
+ /** The handlers `createOperationProcesses` builds, and how many calls run now. */
57
+ export interface OperationProcesses {
58
+ /** The handler of one unary operation, executed in a process of its own. */
59
+ unary<T extends Record<string, EndpointDef>, K extends UnaryOperationKeys<T> & string>(contract: ContractDef<T, string>, key: K): (context: OperationCallContext) => Promise<OperationOutput<T[K]>>;
60
+ /** The handler of one streaming operation: items arrive as the process produces them. */
61
+ stream<T extends Record<string, EndpointDef>, K extends StreamOperationKeys<T> & string>(contract: ContractDef<T, string>, key: K): (context: OperationCallContext) => AsyncIterable<OperationItem<T[K]>>;
62
+ /** Calls running now. */
63
+ readonly active: number;
64
+ }
65
+ /**
66
+ * A pool of one-call processes for contract operations.
67
+ *
68
+ * It holds no process between calls: a call starts one, and the call's end —
69
+ * its answer, its failure, the caller's abort, the deadline — ends that
70
+ * process and its group. The pool is the count that bounds them.
71
+ */
72
+ export declare function createOperationProcesses(config: OperationProcessesConfig): OperationProcesses;
73
+ export {};
74
+ //# sourceMappingURL=operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../src/process/operation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOnE,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAU3E,kGAAkG;AAClG,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,OAAO,EAAE,IAAI,CACX,oBAAoB,EACpB,YAAY,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,WAAW,GAAG,WAAW,GAAG,MAAM,CAC3E,CAAC;IACF,8FAA8F;IAC9F,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,oGAAoG;IACpG,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,4EAA4E;AAC5E,MAAM,WAAW,oBAAoB;IACn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CAAC,GAAG,MAAM,EACrF,QAAQ,EAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,EAChC,GAAG,EAAE,CAAC,GACL,CAAC,OAAO,EAAE,oBAAoB,KAAK,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzE,yBAAyB;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AA0ED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,wBAAwB,GAC/B,kBAAkB,CAyJpB"}
@@ -0,0 +1,10 @@
1
+ import type { ServiceDef } from './types.js';
2
+ /**
3
+ * `services` plus the service that answers `contractIdentityContract` with their
4
+ * fingerprint — the same digest `contractFingerprint` gives a client holding
5
+ * the same contracts. It returns the whole list to mount, so the identity
6
+ * cannot describe a different set of services than the server answers. The
7
+ * identity operation is not part of its own answer.
8
+ */
9
+ export declare function withContractIdentity(services: readonly ServiceDef[]): ServiceDef[];
10
+ //# sourceMappingURL=contract-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-identity.d.ts","sourceRoot":"","sources":["../../src/server/contract-identity.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAqB1C;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,EAAE,CAWlF"}
@@ -1 +1 @@
1
- {"version":3,"file":"contract-stream.d.ts","sourceRoot":"","sources":["../../src/server/contract-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAWnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAS/C,gEAAgE;AAChE,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAC9B,UAAU,EAAE,wBAAwB,EACpC,cAAc,EAAE,eAAe,GAC9B,OAAO,CAAC,QAAQ,CAAC,CA+GnB"}
1
+ {"version":3,"file":"contract-stream.d.ts","sourceRoot":"","sources":["../../src/server/contract-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAcnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAS/C,gEAAgE;AAChE,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAC9B,UAAU,EAAE,wBAAwB,EACpC,cAAc,EAAE,eAAe,GAC9B,OAAO,CAAC,QAAQ,CAAC,CAgGnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"endpoint-response.d.ts","sourceRoot":"","sources":["../../src/server/endpoint-response.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGlE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,qFAAqF;AACrF,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,cAAc,CAAC;IACpB,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAC/C,WAAW,EAAE,eAAe,GAAG,SAAS,CAAC;CAC1C;AASD,wBAAsB,gBAAgB,CAAC,OAAO,EAC5C,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,EAC5B,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,EAC9B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,QAAQ,CAAC,CAgBnB"}
1
+ {"version":3,"file":"endpoint-response.d.ts","sourceRoot":"","sources":["../../src/server/endpoint-response.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAGlE,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGlE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,qFAAqF;AACrF,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,cAAc,CAAC;IACpB,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAC/C,WAAW,EAAE,eAAe,GAAG,SAAS,CAAC;CAC1C;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAC5C,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,EAC5B,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,EAC9B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,QAAQ,CAAC,CAgBnB"}
@@ -23,6 +23,7 @@
23
23
  * BAD_REQUEST: 'bad_request', VALIDATION_ERROR: 'bad_request',
24
24
  * UNAUTHORIZED: 'unauthenticated', FORBIDDEN: 'forbidden',
25
25
  * NOT_FOUND: 'not_found', METHOD_NOT_ALLOWED: 'not_found',
26
+ * UNKNOWN_OPERATION: 'not_found',
26
27
  * CONFLICT: 'conflict', RATE_LIMITED: 'rate_limited',
27
28
  * INTERNAL_SERVER_ERROR: 'internal',
28
29
  * },
@@ -1 +1 @@
1
- {"version":3,"file":"error-hook.d.ts","sourceRoot":"","sources":["../../src/server/error-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;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EAAE,SAAS,MAAM,EAAE,EACvB,MAAM,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,EAC/C,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,iBAAiB,GACxB,SAAS,CAuKX"}
@@ -1,7 +1,7 @@
1
1
  import type { ZodObject, ZodType, z } from 'zod';
2
- import { type ToolFailure, type ToolResult } from '../execute-result.js';
2
+ import { type ToolResult } from '../execute-result.js';
3
3
  import type { CliRunOptions } from './args.js';
4
- import type { CliWriters } from './format.js';
4
+ import { type CliWriters, type EmitOptions } from './format.js';
5
5
  export interface CliCommandContext<TInput extends ZodObject> extends CliWriters {
6
6
  input: z.output<TInput>;
7
7
  options: Readonly<CliRunOptions>;
@@ -18,16 +18,33 @@ export interface CliCommandDefinitionBase<TInput extends ZodObject> {
18
18
  description: string;
19
19
  input: TInput;
20
20
  }
21
- export interface CliCommandDefinitionWithOutput<TInput extends ZodObject, TOutput extends ZodType> extends CliCommandDefinitionBase<TInput> {
22
- output: TOutput;
23
- handler: (context: CliCommandContext<TInput>) => z.output<TOutput> | Promise<z.output<TOutput>>;
21
+ /**
22
+ * How a successfully validated result leaves the process: its stdout bytes and
23
+ * its exit code. One shape for a native command (`defineCliCommand`) and for a
24
+ * managed command (`CliConfig.results`), so a result is printed and exit-coded
25
+ * by one rule whichever way the command was declared.
26
+ */
27
+ export interface CliResultPolicy<TResult> {
24
28
  /** Pure post-validation stdout presentation; returned bytes are written verbatim once. */
25
- present?: (context: {
26
- result: z.output<TOutput>;
29
+ present?(context: {
30
+ result: TResult;
27
31
  options: Readonly<CliRunOptions>;
28
- }) => string;
32
+ }): string;
29
33
  /** Process exit code for a successfully validated result. */
30
- exitCode?: (result: z.output<TOutput>) => number;
34
+ exitCode?(result: TResult): number;
35
+ /** The schema the policy is typed against; a managed command checks it is its own. */
36
+ output?: ZodType;
37
+ }
38
+ /**
39
+ * Type a managed command's result policy against the schema its operation
40
+ * returns. Pass the very schema the contract declares: the CLI refuses at
41
+ * startup a policy whose schema is not the one its command answers with, so a
42
+ * policy cannot be mounted on a command whose result it does not describe.
43
+ */
44
+ export declare function defineCliResult<TOutput extends ZodType>(output: TOutput, policy: Pick<CliResultPolicy<z.output<TOutput>>, 'present' | 'exitCode'>): CliResultPolicy<z.output<TOutput>>;
45
+ export interface CliCommandDefinitionWithOutput<TInput extends ZodObject, TOutput extends ZodType> extends CliCommandDefinitionBase<TInput>, CliResultPolicy<z.output<TOutput>> {
46
+ output: TOutput;
47
+ handler: (context: CliCommandContext<TInput>) => z.output<TOutput> | Promise<z.output<TOutput>>;
31
48
  }
32
49
  export interface CliCommandDefinitionWithoutOutput<TInput extends ZodObject> extends CliCommandDefinitionBase<TInput> {
33
50
  output?: never;
@@ -39,12 +56,6 @@ export type CliCommandDefinition = CliCommandDefinitionWithOutput<ZodObject, Zod
39
56
  /** Typed identity helper for one transport-local executable command. */
40
57
  export declare function defineCliCommand<TInput extends ZodObject, TOutput extends ZodType>(definition: CliCommandDefinitionWithOutput<TInput, TOutput>): CliCommandDefinitionWithOutput<TInput, TOutput>;
41
58
  export declare function defineCliCommand<TInput extends ZodObject>(definition: CliCommandDefinitionWithoutOutput<TInput>): CliCommandDefinitionWithoutOutput<TInput>;
42
- export interface PreparedCliCommandEmission {
43
- result: ToolResult;
44
- presentation?: string;
45
- presentationFailure?: ToolFailure;
46
- successExitCode: number;
47
- }
48
59
  /**
49
60
  * Whether a native command yields a value at all.
50
61
  *
@@ -62,9 +73,19 @@ export declare function cliCommandReturnsResult(definition: CliCommandDefinition
62
73
  * same command typed at a prompt; two copies of this rule would eventually
63
74
  * disagree and the divergence would show up as a script that branches wrong.
64
75
  */
65
- export declare function cliCommandSuccessExitCode(definition: CliCommandDefinition, data: unknown): number;
66
- /** Apply native-only presentation policy after canonical output validation. */
67
- export declare function prepareCliCommandEmission(definition: CliCommandDefinition, result: ToolResult, options: Readonly<CliRunOptions>): PreparedCliCommandEmission;
76
+ export declare function cliCommandSuccessExitCode(policy: CliResultPolicy<unknown> | undefined, data: unknown): number;
77
+ /** The result policy a native command declares; a printing command has none. */
78
+ export declare function cliCommandResultPolicy(definition: CliCommandDefinition): CliResultPolicy<unknown> | undefined;
79
+ /**
80
+ * Print one result under its command's policy and return the process exit code.
81
+ *
82
+ * The single place a policy meets the terminal: a native command and a managed
83
+ * one answer through it, so `present`, `exitCode` and a failed presentation
84
+ * behave identically on both.
85
+ */
86
+ export declare function emitCliCommandResult(policy: CliResultPolicy<unknown> | undefined, result: ToolResult, options: Readonly<CliRunOptions>, writers: CliWriters, emit: EmitOptions & {
87
+ repeatable: boolean;
88
+ }): number;
68
89
  export declare function cliCommandPresentationSchema(definition: CliCommandDefinition): Record<string, unknown>;
69
90
  /** Execute a CLI-only definition without inventing a tool operation identity. */
70
91
  export declare function executeCliCommand(definition: CliCommandDefinition, rawArgs: Record<string, unknown>, options: CliRunOptions, writers: CliWriters, coerceJson: boolean, globals?: Readonly<Record<string, unknown>>): Promise<ToolResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGjD,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAuB,MAAM,mBAAmB,CAAC;AAG3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,iBAAiB,CAAC,MAAM,SAAS,SAAS,CAAE,SAAQ,UAAU;IAC7E,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IACjC;;;;;OAKG;IACH,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CA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