@workerstack/clients 1.0.0-rc.29 → 1.0.0-rc.30

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 (291) hide show
  1. package/README.md +373 -14
  2. package/assets/installers/examples/github.config.ts +17 -19
  3. package/assets/installers/examples/goreleaser.config.ts +16 -18
  4. package/assets/installers/examples/raw.config.ts +13 -15
  5. package/bin/clients.js +87 -66
  6. package/bin/installgen.js +19 -10
  7. package/dist/cli.d.ts +4 -4
  8. package/dist/cli.js +18 -12
  9. package/dist/emit/cli/channels.d.ts +2 -2
  10. package/dist/emit/cli/channels.js +18 -13
  11. package/dist/emit/cli/commands.d.ts +1 -1
  12. package/dist/emit/cli/commands.js +14 -8
  13. package/dist/emit/cli/discovery.d.ts +0 -6
  14. package/dist/emit/cli/discovery.js +9 -7
  15. package/dist/emit/cli/flags.d.ts +1 -3
  16. package/dist/emit/cli/flags.js +11 -5
  17. package/dist/emit/cli/install.d.ts +0 -8
  18. package/dist/emit/cli/install.js +3 -3
  19. package/dist/emit/cli/layout.d.ts +1 -1
  20. package/dist/emit/cli/layout.js +13 -10
  21. package/dist/emit/cli/module.d.ts +6 -6
  22. package/dist/emit/cli/module.js +10 -10
  23. package/dist/emit/cli/release.d.ts +0 -11
  24. package/dist/emit/cli/release.js +4 -4
  25. package/dist/emit/cli/skills.js +3 -3
  26. package/dist/emit/csharp/errors.js +4 -4
  27. package/dist/emit/csharp/json.js +8 -8
  28. package/dist/emit/csharp/realtime.js +3 -3
  29. package/dist/emit/csharp/sdk-answer.js +4 -4
  30. package/dist/emit/csharp/sdk-body.js +8 -6
  31. package/dist/emit/csharp/sdk-client.d.ts +3 -3
  32. package/dist/emit/csharp/sdk-client.js +2 -2
  33. package/dist/emit/csharp/sdk-csproj.d.ts +7 -9
  34. package/dist/emit/csharp/sdk-csproj.js +10 -10
  35. package/dist/emit/csharp/sdk-doc.js +1 -1
  36. package/dist/emit/csharp/sdk-method.d.ts +0 -1
  37. package/dist/emit/csharp/sdk-method.js +10 -6
  38. package/dist/emit/csharp/sdk-plan.js +0 -1
  39. package/dist/emit/csharp/sdk.js +3 -3
  40. package/dist/emit/csharp/sse.d.ts +0 -2
  41. package/dist/emit/csharp/sse.js +7 -7
  42. package/dist/emit/csharp/transport.js +7 -7
  43. package/dist/emit/csharp/types-enum.js +3 -1
  44. package/dist/emit/csharp/types-messages.js +3 -3
  45. package/dist/emit/csharp/types-names.js +10 -12
  46. package/dist/emit/csharp/types-record.js +3 -3
  47. package/dist/emit/csharp/types-union.d.ts +1 -1
  48. package/dist/emit/csharp/types.d.ts +0 -1
  49. package/dist/emit/csharp/types.js +3 -3
  50. package/dist/emit/csharp/ws.js +2 -2
  51. package/dist/emit/go/errors.js +1 -1
  52. package/dist/emit/go/http.js +2 -2
  53. package/dist/emit/go/module-path.js +2 -2
  54. package/dist/emit/go/sdk-answer.js +1 -1
  55. package/dist/emit/go/sdk-body.js +11 -7
  56. package/dist/emit/go/sdk-client.js +1 -1
  57. package/dist/emit/go/sdk-method.js +2 -2
  58. package/dist/emit/go/sdk-mirror.js +2 -2
  59. package/dist/emit/go/sdk-opts.d.ts +0 -2
  60. package/dist/emit/go/sdk-opts.js +3 -3
  61. package/dist/emit/go/sdk.d.ts +1 -1
  62. package/dist/emit/go/sdk.js +9 -9
  63. package/dist/emit/go/sse.js +1 -1
  64. package/dist/emit/go/types-names.js +5 -0
  65. package/dist/emit/go/types-struct.d.ts +2 -1
  66. package/dist/emit/go/types-struct.js +1 -1
  67. package/dist/emit/go/types.js +9 -9
  68. package/dist/emit/go/ws.js +6 -6
  69. package/dist/emit/java/gradle.d.ts +7 -9
  70. package/dist/emit/java/gradle.js +8 -8
  71. package/dist/emit/java/json.js +1 -1
  72. package/dist/emit/java/layout-ast.js +1 -1
  73. package/dist/emit/java/layout-decl.js +5 -4
  74. package/dist/emit/java/layout-doc.js +13 -7
  75. package/dist/emit/java/layout-dot.js +1 -1
  76. package/dist/emit/java/layout-strings.js +4 -5
  77. package/dist/emit/java/layout-types.js +7 -5
  78. package/dist/emit/java/layout-visitor.js +4 -3
  79. package/dist/emit/java/layout.js +5 -4
  80. package/dist/emit/java/models-names.js +5 -4
  81. package/dist/emit/java/models-record.d.ts +0 -1
  82. package/dist/emit/java/models-record.js +3 -3
  83. package/dist/emit/java/models-union.d.ts +1 -1
  84. package/dist/emit/java/models-union.js +1 -1
  85. package/dist/emit/java/models.d.ts +1 -2
  86. package/dist/emit/java/models.js +25 -16
  87. package/dist/emit/java/realtime.d.ts +5 -17
  88. package/dist/emit/java/realtime.js +1 -1
  89. package/dist/emit/java/sdk-client.d.ts +6 -6
  90. package/dist/emit/java/sdk-client.js +1 -1
  91. package/dist/emit/java/sdk-decl.js +2 -2
  92. package/dist/emit/java/sdk-errors.js +1 -1
  93. package/dist/emit/java/sdk-headers.js +2 -2
  94. package/dist/emit/java/sdk-mirror.js +2 -2
  95. package/dist/emit/java/sdk-models.d.ts +1 -1
  96. package/dist/emit/java/sdk-models.js +7 -7
  97. package/dist/emit/java/sdk-op.d.ts +1 -10
  98. package/dist/emit/java/sdk-op.js +8 -8
  99. package/dist/emit/java/sdk-params.d.ts +5 -5
  100. package/dist/emit/java/sdk-params.js +3 -2
  101. package/dist/emit/java/sdk-plan.js +0 -1
  102. package/dist/emit/java/sdk.d.ts +1 -1
  103. package/dist/emit/java/sdk.js +14 -13
  104. package/dist/emit/java/sse.d.ts +2 -4
  105. package/dist/emit/java/sse.js +6 -6
  106. package/dist/emit/java/ws.d.ts +2 -2
  107. package/dist/emit/java/ws.js +3 -4
  108. package/dist/emit/mcp/annotations.js +8 -4
  109. package/dist/emit/mcp/files.js +9 -9
  110. package/dist/emit/mcp/mounted.js +2 -2
  111. package/dist/emit/mcp/output-schema.js +3 -3
  112. package/dist/emit/mcp/registry.d.ts +0 -2
  113. package/dist/emit/mcp/registry.js +5 -4
  114. package/dist/emit/mcp/runtime.js +2 -2
  115. package/dist/emit/mcp/schema.js +22 -11
  116. package/dist/emit/mcp/server.d.ts +7 -7
  117. package/dist/emit/mcp/server.js +7 -6
  118. package/dist/emit/mcp/tools.js +7 -6
  119. package/dist/emit/python/errors.js +3 -3
  120. package/dist/emit/python/realtime.js +2 -2
  121. package/dist/emit/python/sdk-answer.d.ts +3 -7
  122. package/dist/emit/python/sdk-answer.js +2 -2
  123. package/dist/emit/python/sdk-body.js +4 -5
  124. package/dist/emit/python/sdk-client.js +5 -5
  125. package/dist/emit/python/sdk-doc.js +2 -2
  126. package/dist/emit/python/sdk-method.js +5 -5
  127. package/dist/emit/python/sdk-plan.js +0 -1
  128. package/dist/emit/python/sdk-pyproject.d.ts +0 -2
  129. package/dist/emit/python/sdk-pyproject.js +8 -8
  130. package/dist/emit/python/sdk.d.ts +1 -1
  131. package/dist/emit/python/sdk.js +7 -7
  132. package/dist/emit/python/sse.d.ts +0 -2
  133. package/dist/emit/python/sse.js +2 -2
  134. package/dist/emit/python/transport.js +4 -4
  135. package/dist/emit/python/types-dict.d.ts +2 -2
  136. package/dist/emit/python/types-dict.js +1 -1
  137. package/dist/emit/python/types-names.js +2 -2
  138. package/dist/emit/python/types-union.js +1 -1
  139. package/dist/emit/python/types.js +3 -3
  140. package/dist/emit/python/ws.d.ts +2 -5
  141. package/dist/emit/python/ws.js +4 -4
  142. package/dist/emit/rust/errors.js +3 -3
  143. package/dist/emit/rust/http.js +4 -4
  144. package/dist/emit/rust/realtime.js +2 -2
  145. package/dist/emit/rust/sdk-body.js +8 -5
  146. package/dist/emit/rust/sdk-cargo.d.ts +16 -18
  147. package/dist/emit/rust/sdk-cargo.js +12 -12
  148. package/dist/emit/rust/sdk-client.d.ts +1 -1
  149. package/dist/emit/rust/sdk-client.js +3 -3
  150. package/dist/emit/rust/sdk-method.js +2 -2
  151. package/dist/emit/rust/sdk-opts.d.ts +2 -1
  152. package/dist/emit/rust/sdk-opts.js +2 -2
  153. package/dist/emit/rust/sdk-plan.js +0 -1
  154. package/dist/emit/rust/sdk.d.ts +1 -1
  155. package/dist/emit/rust/sdk.js +5 -5
  156. package/dist/emit/rust/sse.d.ts +0 -5
  157. package/dist/emit/rust/sse.js +2 -2
  158. package/dist/emit/rust/types-names.js +3 -3
  159. package/dist/emit/rust/types-struct.js +1 -1
  160. package/dist/emit/rust/types-union.d.ts +1 -1
  161. package/dist/emit/rust/types.js +7 -5
  162. package/dist/emit/rust/ws.d.ts +0 -11
  163. package/dist/emit/rust/ws.js +5 -5
  164. package/dist/emit/shared/escape.js +17 -17
  165. package/dist/emit/shared/format.js +1 -1
  166. package/dist/emit/shared/gofmt.js +1 -1
  167. package/dist/emit/shared/lang.js +10 -10
  168. package/dist/emit/shared/literals.d.ts +5 -0
  169. package/dist/emit/shared/literals.js +8 -0
  170. package/dist/emit/shared/metadata.d.ts +0 -6
  171. package/dist/emit/shared/metadata.js +8 -7
  172. package/dist/emit/shared/ruff.js +1 -1
  173. package/dist/emit/shared/rustfmt.js +1 -1
  174. package/dist/emit/shared/type-emitter.js +37 -20
  175. package/dist/emit/shared/unknown-type.constants.d.ts +2 -0
  176. package/dist/emit/shared/unknown-type.constants.js +2 -0
  177. package/dist/emit/ts/http.d.ts +0 -2
  178. package/dist/emit/ts/http.js +4 -4
  179. package/dist/emit/ts/package.d.ts +14 -12
  180. package/dist/emit/ts/package.js +9 -8
  181. package/dist/emit/ts/route-tree.js +2 -2
  182. package/dist/emit/ts/sdk-types-preamble.d.ts +1 -1
  183. package/dist/emit/ts/sdk-types-preamble.js +2 -2
  184. package/dist/emit/ts/sdk-types.js +11 -11
  185. package/dist/emit/ts/sdk.js +4 -4
  186. package/dist/emit/ts/service-map.d.ts +2 -1
  187. package/dist/emit/ts/tanstack-query.js +6 -6
  188. package/dist/emit/ts/type-gen.js +31 -18
  189. package/dist/emit/ts/webhooks.d.ts +0 -2
  190. package/dist/emit/ts/webhooks.js +3 -3
  191. package/dist/extract/chain.js +5 -4
  192. package/dist/extract/extract.js +5 -5
  193. package/dist/extract/serialize.d.ts +0 -2
  194. package/dist/extract/serialize.js +14 -15
  195. package/dist/extract/walk.js +15 -12
  196. package/dist/gen/args.js +9 -5
  197. package/dist/gen/formatters.js +5 -3
  198. package/dist/gen/shipped.js +2 -2
  199. package/dist/gen/targets.d.ts +2 -4
  200. package/dist/gen/targets.js +8 -4
  201. package/dist/gen/write.js +4 -2
  202. package/dist/index.js +2 -2
  203. package/dist/installers/cli.d.ts +4 -4
  204. package/dist/installers/cli.js +24 -24
  205. package/dist/installers/commands/build.d.ts +4 -4
  206. package/dist/installers/commands/build.js +2 -3
  207. package/dist/installers/commands/check.d.ts +2 -2
  208. package/dist/installers/commands/check.js +11 -10
  209. package/dist/installers/commands/init.d.ts +2 -2
  210. package/dist/installers/commands/init.js +1 -2
  211. package/dist/installers/config/define-config.d.ts +16 -16
  212. package/dist/installers/config/define-config.js +1 -1
  213. package/dist/installers/config/hooks/bun.d.ts +6 -6
  214. package/dist/installers/config/hooks/node.js +1 -1
  215. package/dist/installers/config/load.d.ts +6 -8
  216. package/dist/installers/config/load.js +7 -8
  217. package/dist/installers/config/resolve.d.ts +1 -2
  218. package/dist/installers/config/resolve.js +28 -33
  219. package/dist/installers/config/types.d.ts +6 -6
  220. package/dist/installers/config/types.js +0 -1
  221. package/dist/installers/render/quote.js +3 -5
  222. package/dist/installers/render/render.d.ts +6 -6
  223. package/dist/installers/render/render.js +26 -26
  224. package/dist/installers/ui.d.ts +4 -4
  225. package/dist/installers/ui.js +3 -3
  226. package/dist/ir/build.d.ts +3 -3
  227. package/dist/ir/build.js +8 -5
  228. package/dist/ir/load.js +9 -10
  229. package/dist/ir/model.d.ts +2 -1
  230. package/dist/ir/model.js +0 -1
  231. package/dist/ir/resolve-refs.js +2 -2
  232. package/dist/ir/resource-tree.js +2 -1
  233. package/dist/ir/route-tree-intern.js +1 -1
  234. package/dist/ir/schema.js +3 -3
  235. package/dist/ir/sdk-model.js +3 -3
  236. package/dist/ir/slots.js +13 -8
  237. package/dist/ir/streams.js +1 -1
  238. package/dist/release/bootstrap.d.ts +3 -3
  239. package/dist/release/bootstrap.js +7 -7
  240. package/dist/release/bump-args.js +4 -4
  241. package/dist/release/bump-command.d.ts +1 -1
  242. package/dist/release/bump-command.js +9 -10
  243. package/dist/release/bump.d.ts +5 -4
  244. package/dist/release/bump.js +2 -2
  245. package/dist/release/cli.d.ts +4 -4
  246. package/dist/release/cli.js +4 -4
  247. package/dist/release/codegen.js +1 -1
  248. package/dist/release/digest.js +5 -7
  249. package/dist/release/git.js +5 -8
  250. package/dist/release/load.js +3 -3
  251. package/dist/release/manifest.js +9 -10
  252. package/dist/release/oasdiff.d.ts +10 -15
  253. package/dist/release/oasdiff.js +5 -6
  254. package/dist/release/registries.d.ts +0 -11
  255. package/dist/release/registries.js +17 -17
  256. package/dist/release/release-state.d.ts +16 -13
  257. package/dist/release/release-workflow.js +5 -7
  258. package/dist/release/repo-settings.d.ts +2 -1
  259. package/dist/release/spec-gate.d.ts +0 -2
  260. package/dist/release/spec-gate.js +6 -10
  261. package/dist/release/sync-command.d.ts +2 -2
  262. package/dist/release/sync-command.js +1 -1
  263. package/dist/release/sync-tree.js +9 -13
  264. package/dist/release/sync.d.ts +6 -6
  265. package/dist/release/sync.js +12 -13
  266. package/dist/release/types.d.ts +22 -22
  267. package/dist/release/types.js +0 -1
  268. package/dist/release/version-files.d.ts +3 -4
  269. package/dist/release/version-files.js +4 -5
  270. package/dist/runtime/.oxfmtrc.jsonc +8 -0
  271. package/dist/runtime/mcp/files.ts +1 -1
  272. package/dist/runtime/mcp/http.ts +6 -2
  273. package/dist/runtime/mcp/listen.ts +1 -1
  274. package/dist/runtime/mcp/mount.ts +2 -2
  275. package/dist/runtime/mcp/protocol.ts +1 -1
  276. package/dist/runtime/ts-tanstack-query/query.ts +0 -2
  277. package/package.json +10 -7
  278. package/dist/emit/cli/index.d.ts +0 -1
  279. package/dist/emit/cli/index.js +0 -1
  280. package/dist/emit/csharp/index.d.ts +0 -1
  281. package/dist/emit/csharp/index.js +0 -1
  282. package/dist/emit/go/index.d.ts +0 -1
  283. package/dist/emit/go/index.js +0 -1
  284. package/dist/emit/java/index.d.ts +0 -2
  285. package/dist/emit/java/index.js +0 -2
  286. package/dist/emit/mcp/index.d.ts +0 -3
  287. package/dist/emit/mcp/index.js +0 -3
  288. package/dist/emit/python/index.d.ts +0 -1
  289. package/dist/emit/python/index.js +0 -1
  290. package/dist/emit/rust/index.d.ts +0 -1
  291. package/dist/emit/rust/index.js +0 -1
@@ -1,26 +1,26 @@
1
1
  const STRING = { type: "string" };
2
2
  /** The extension's FileInput, marked: the members it requires, the digest's algorithm SHA-256. */
3
3
  const FILE_INPUT = {
4
- type: "object",
5
- "x-mcp-file": {},
6
4
  properties: {
7
5
  digest: {
8
- type: "object",
9
6
  properties: { algorithm: { const: "sha-256" }, value: STRING },
10
7
  required: ["algorithm", "value"],
8
+ type: "object",
11
9
  },
12
10
  },
13
11
  required: ["id", "mimeType", "size", "digest"],
12
+ type: "object",
13
+ "x-mcp-file": {},
14
14
  };
15
15
  /** A file argument's schema: the extension's FileInput, or a path the server reads. */
16
16
  export const FILE_SCHEMA = {
17
17
  anyOf: [
18
18
  FILE_INPUT,
19
19
  {
20
- type: "object",
21
- properties: { path: { type: "string", description: "A file under the server's file root" } },
22
- required: ["path"],
23
20
  additionalProperties: false,
21
+ properties: { path: { description: "A file under the server's file root", type: "string" } },
22
+ required: ["path"],
23
+ type: "object",
24
24
  },
25
25
  ],
26
26
  };
@@ -33,10 +33,10 @@ export const MOUNTED_FILE_SCHEMA = {
33
33
  anyOf: [
34
34
  FILE_INPUT,
35
35
  {
36
- type: "object",
37
- properties: { url: { type: "string", description: "An https URL the server fetches" } },
38
- required: ["url"],
39
36
  additionalProperties: false,
37
+ properties: { url: { description: "An https URL the server fetches", type: "string" } },
38
+ required: ["url"],
39
+ type: "object",
40
40
  },
41
41
  ],
42
42
  };
@@ -16,11 +16,11 @@ import { MCP_PORTABLE, mcpRuntimeSource } from "./runtime.js";
16
16
  import { resolved } from "./server.js";
17
17
  import { isTool, toolsOf, untoolable } from "./tools.js";
18
18
  const MARKER = "// Code generated by clients. DO NOT EDIT.";
19
- /* a directory name a relative import names */
19
+ // a directory name a relative import names
20
20
  const DIR = /^[A-Za-z0-9_][A-Za-z0-9_.-]*$/;
21
21
  /** `op`'s security requirements: its own, else the document's. */
22
22
  function requirementsOf(spec, op) {
23
- /* a tool's operation is the document's own, at its path and method */
23
+ // a tool's operation is the document's own, at its path and method
24
24
  const paths = spec.paths;
25
25
  const own = paths[op.path][op.method.toLowerCase()];
26
26
  return own.security ?? spec.security ?? [];
@@ -1,5 +1,5 @@
1
- import { sseEvents } from "../../ir/sdk-model.js";
2
1
  import { irResolver } from "../../ir/schema.js";
2
+ import { sseEvents } from "../../ir/sdk-model.js";
3
3
  import { jsonSchemaOf } from "./schema.js";
4
4
  const STRING = { type: "string" };
5
5
  /** An event of a stream that does not name its events: its data as `data` says, its name and id when it has them. */
@@ -66,14 +66,14 @@ export function outputOf(op, ir) {
66
66
  outputSchema: collectedOf(unnamedOf(op.events === undefined ? STRING : jsonSchemaOf(op.events, ir.schemas))),
67
67
  };
68
68
  }
69
- /* the SDK model gives a success its schema only when it is JSON */
69
+ // the SDK model gives a success its schema only when it is JSON
70
70
  if (op.success.schema === undefined)
71
71
  return undefined;
72
72
  const result = jsonSchemaOf(op.success.schema, ir.schemas);
73
73
  const names = [...new Set((op.ir.responses[op.success.status]?.headers ?? []).map(({ name }) => name.toLowerCase()))];
74
74
  if (result.type === "object" && names.length === 0)
75
75
  return { outputSchema: result };
76
- /* null-prototype: a header named __proto__ is a property, never the object's prototype */
76
+ // null-prototype: a header named __proto__ is a property, never the object's prototype
77
77
  const headers = Object.create(null);
78
78
  for (const name of names.sort())
79
79
  headers[name] = { type: "string" };
@@ -8,8 +8,6 @@
8
8
  */
9
9
  import type { IR } from "../../ir/model.ts";
10
10
  import type { Metadata } from "../shared/metadata.ts";
11
- /** The schema the file names, the registry's latest dated one. */
12
- export declare const SERVER_SCHEMA = "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json";
13
11
  /** The server as the registry lists it: its names, the version npm publishes, and what its environment holds. */
14
12
  export type Listing = {
15
13
  readonly name: string;
@@ -1,8 +1,8 @@
1
1
  /** The schema the file names, the registry's latest dated one. */
2
- export const SERVER_SCHEMA = "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json";
3
- /* the registry's cap on a description, in characters */
2
+ const SERVER_SCHEMA = "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json";
3
+ // the registry's cap on a description, in characters
4
4
  const DESCRIPTION_MAX = 100;
5
- /* the forges the registry knows by host: the `source` it validates a repository through */
5
+ // the forges the registry knows by host: the `source` it validates a repository through
6
6
  const SOURCES = { "github.com": "github", "gitlab.com": "gitlab" };
7
7
  /** Every variable the server reads over stdio, as its entry reads them; the HTTP transport's are not the package's. */
8
8
  function variablesOf(listing, ir) {
@@ -50,8 +50,9 @@ function variablesOf(listing, ir) {
50
50
  /** The description the registry shows: the run's, else the package's own, refused past the registry's cap. */
51
51
  function descriptionOf(listing, metadata) {
52
52
  const text = metadata.description ?? `The ${listing.name} API as MCP tools`;
53
- if ([...text].length > DESCRIPTION_MAX)
53
+ if ([...text].length > DESCRIPTION_MAX) {
54
54
  throw new Error(`Invalid metadata.description: ${JSON.stringify(text)}: the MCP registry takes ${DESCRIPTION_MAX} characters at most`);
55
+ }
55
56
  return text;
56
57
  }
57
58
  /** The repository as the registry links it, for a forge it knows; none for another host. */
@@ -35,13 +35,13 @@ export const MCP_STANDALONE = [
35
35
  "reader",
36
36
  "listen",
37
37
  ];
38
- /* an import of a sibling runtime module, on one line or several */
38
+ // an import of a sibling runtime module, on one line or several
39
39
  const SIBLING_IMPORT = /^import\s+(?:type\s+)?\{[^}]*\}\s+from\s+"\.\/[\w-]+\.ts"\n/gm;
40
40
  const MARKER = "// Code generated by clients. DO NOT EDIT.";
41
41
  /** The vendored runtime as one module: `names` (the standalone package's by default) in order, sibling imports dropped. */
42
42
  export function mcpRuntimeSource(names = MCP_STANDALONE) {
43
43
  const modules = names.map((name) => readFileSync(new URL(`../../runtime/mcp/${name}.ts`, import.meta.url), "utf8")
44
- .replace(SIBLING_IMPORT, "")
44
+ .replaceAll(SIBLING_IMPORT, "")
45
45
  .trim());
46
46
  return `${MARKER}\n\n${modules.join("\n\n")}\n`;
47
47
  }
@@ -53,33 +53,44 @@ function convert(schema, walk) {
53
53
  if (++walk.nodes.count > walk.budget)
54
54
  throw new Error(`a schema inlines past ${walk.budget} nodes`);
55
55
  switch (schema.kind) {
56
- case "scalar":
56
+ case "scalar": {
57
57
  return scalarOf(schema);
58
- case "const":
58
+ }
59
+ case "const": {
59
60
  return { const: schema.value };
60
- case "object":
61
+ }
62
+ case "object": {
61
63
  return objectOf(schema.fields, schema.additional, walk);
62
- case "array":
64
+ }
65
+ case "array": {
63
66
  return {
64
67
  type: "array",
65
68
  items: convert(schema.items, walk),
66
69
  ...(schema.minItems === undefined ? {} : { minItems: schema.minItems }),
67
70
  ...(schema.maxItems === undefined ? {} : { maxItems: schema.maxItems }),
68
71
  };
69
- case "tuple":
72
+ }
73
+ case "tuple": {
70
74
  return tupleOf(schema, walk);
71
- case "union":
75
+ }
76
+ case "union": {
72
77
  return { anyOf: schema.variants.map((variant) => convert(variant, walk)) };
73
- case "allOf":
78
+ }
79
+ case "allOf": {
74
80
  return { allOf: schema.parts.map((part) => convert(part, walk)) };
75
- case "ref":
81
+ }
82
+ case "ref": {
76
83
  return inlineRef(schema.name, walk);
77
- case "nullable":
84
+ }
85
+ case "nullable": {
78
86
  return { anyOf: [convert(schema.inner, walk), { type: "null" }] };
79
- case "binary":
87
+ }
88
+ case "binary": {
80
89
  return { type: "string", contentEncoding: "base64" };
81
- case "unknown":
90
+ }
91
+ case "unknown": {
82
92
  return {};
93
+ }
83
94
  }
84
95
  }
85
96
  /** `schema` as a self-contained JSON Schema, every ref into `schemas` inlined, refused past `budget` nodes. */
@@ -1,16 +1,16 @@
1
1
  import { type Metadata, type PackageIdentity } from "../shared/metadata.ts";
2
2
  export type McpServerOptions = {
3
3
  /** the server's name: lowercase words joined by `-`, at most 60 characters; by default the document title's */
4
- readonly name?: string;
4
+ readonly name?: string | undefined;
5
5
  /** the prefix of its environment variables; by default the name's words, uppercased, joined by `_` */
6
- readonly envPrefix?: string;
6
+ readonly envPrefix?: string | undefined;
7
7
  /** the version its server info and package.json carry, one npm accepts; by default the document's */
8
- readonly version?: string;
8
+ readonly version?: string | undefined;
9
9
  /** the npm name it publishes under; `<name>-mcp` by default, the bin's name either way */
10
- readonly packageName?: string;
10
+ readonly packageName?: string | undefined;
11
11
  /** the MCP registry's name for it, `namespace/name` (`io.github.acme/shop`): package.json's `mcpName`, which the
12
12
  * registry checks the npm package by; none by default */
13
- readonly mcpName?: string;
13
+ readonly mcpName?: string | undefined;
14
14
  };
15
15
  export type GeneratedMcpServer = {
16
16
  readonly files: Readonly<Record<string, string>>;
@@ -21,8 +21,8 @@ export type GeneratedMcpServer = {
21
21
  };
22
22
  /** The options with their defaults filled, each refused unless it matches its grammar (F2). */
23
23
  export declare function resolved(options: McpServerOptions, title: string | undefined): {
24
- envPrefix: string;
25
- name: string;
24
+ readonly envPrefix: string;
25
+ readonly name: string;
26
26
  };
27
27
  /** `source` with its types erased, as ES module JavaScript; the entry gets the shebang a bin needs. */
28
28
  export declare function erased(path: string, source: string): string;
@@ -8,18 +8,18 @@
8
8
  */
9
9
  import { toIR } from "../../ir/build.js";
10
10
  import { binaryNameOf } from "../cli/module.js";
11
- import { checked, NPM_NAME, packageOn, SEMVER } from "../shared/metadata.js";
12
11
  import { tsString } from "../shared/escape.js";
12
+ import { checked, NPM_NAME, packageOn, SEMVER } from "../shared/metadata.js";
13
13
  import { compiled, npmFields } from "../ts/package.js";
14
14
  import { generateSdk } from "../ts/sdk.js";
15
15
  import { literal } from "./literal.js";
16
16
  import { serverJson } from "./registry.js";
17
17
  import { mcpRuntimeSource } from "./runtime.js";
18
18
  import { toolsOf, untoolable } from "./tools.js";
19
- /* a name leaves room for the bin's `-mcp`; a prefix is uppercase words joined by `_` */
19
+ // a name leaves room for the bin's `-mcp`; a prefix is uppercase words joined by `_`
20
20
  const NAME = /^(?=.{1,60}$)[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
21
21
  const ENV_PREFIX = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
22
- /* a server name as the MCP registry's server.json schema (2025-12-11) takes it: a reverse-DNS namespace, `/`, a name */
22
+ // a server name as the MCP registry's server.json schema (2025-12-11) takes it: a reverse-DNS namespace, `/`, a name
23
23
  const MCP_NAME = /^(?=.{3,200}$)[a-zA-Z0-9.-]+\/[a-zA-Z0-9._-]+$/;
24
24
  const MARKER = "// Code generated by clients. DO NOT EDIT.";
25
25
  /** The options with their defaults filled, each refused unless it matches its grammar (F2). */
@@ -34,7 +34,7 @@ export function resolved(options, title) {
34
34
  throw new Error(`Invalid version: ${JSON.stringify(options.version)}`);
35
35
  return { envPrefix, name };
36
36
  }
37
- /* a cap in bytes from the environment: a whole number, its default when unset */
37
+ // a cap in bytes from the environment: a whole number, its default when unset
38
38
  const BYTES = `const bytes = (name: string, fallback: string): number => {
39
39
  const text = process.env[name] || fallback
40
40
  if (/^(?:0|[1-9][0-9]{0,14})$/.test(text)) return Number(text)
@@ -215,13 +215,14 @@ export function generateMcpServer(document, options = {}, metadata = {}) {
215
215
  packageName: checked("packageName", options.packageName ?? `${name}-mcp`, NPM_NAME),
216
216
  };
217
217
  const version = options.version ?? ir.info.version ?? "0.0.0";
218
- /* what npm and the registries take: the version when it is semver, else 0.0.0 */
218
+ // what npm and the registries take: the version when it is semver, else 0.0.0
219
219
  const publishable = SEMVER.test(version) ? version : "0.0.0";
220
220
  const specs = toolsOf(ir);
221
- if (specs.length === 0)
221
+ if (specs.length === 0) {
222
222
  throw new Error(ir.operations.some((op) => op.extensions.mcp === true)
223
223
  ? "No operation marked x-mcp is one a tool can call yet: nothing to serve"
224
224
  : "No operation is marked x-mcp: nothing to serve");
225
+ }
225
226
  const files = specs.some((spec) => spec.parts?.some(([, , kind]) => kind !== "text"));
226
227
  const sdk = generateSdk(document, { name: "Api", stem: "api" });
227
228
  const source = {
@@ -44,7 +44,7 @@ export function untoolable(op) {
44
44
  export const isTool = (op) => op.extensions.mcp === true && untoolable(op) === undefined;
45
45
  /** The tool name for `id`, not one `taken` holds: snake case, sanitized, truncated, then suffixed. */
46
46
  export function toolName(id, taken) {
47
- /* snakeWords keeps only letters, digits and inner underscores: nothing is left to sanitize */
47
+ // snakeWords keeps only letters, digits and inner underscores: nothing is left to sanitize
48
48
  const base = (snakeWords(id) || "tool").slice(0, NAME_MAX);
49
49
  let name = base;
50
50
  for (let n = 2; taken.has(name); n++)
@@ -77,7 +77,7 @@ function bodyOf(op, ir, into) {
77
77
  const field = bodyField(op);
78
78
  if (field === undefined || op.body === undefined)
79
79
  return {};
80
- /* a multipart form is never a stream: it has its schema */
80
+ // a multipart form is never a stream: it has its schema
81
81
  if (field === "parts")
82
82
  return { parts: partsOf(op.body.schema, ir, into) };
83
83
  const property = into.scope.claim("body");
@@ -90,7 +90,7 @@ function bodyOf(op, ir, into) {
90
90
  function inputOf(op, ir, file) {
91
91
  const scope = new NameScope();
92
92
  const credentials = new Set([...CREDENTIAL_HEADERS, ir.auth.headerName.toLowerCase()]);
93
- /* null-prototype: a parameter named __proto__ is a property, never the object's prototype */
93
+ // null-prototype: a parameter named __proto__ is a property, never the object's prototype
94
94
  const properties = Object.create(null);
95
95
  const required = [];
96
96
  const args = [];
@@ -99,7 +99,7 @@ function inputOf(op, ir, file) {
99
99
  ["search", op.params.query],
100
100
  ["headers", op.params.header.filter((param) => !credentials.has(param.name.toLowerCase()))],
101
101
  ];
102
- for (const [group, params] of groups)
102
+ for (const [group, params] of groups) {
103
103
  for (const param of params) {
104
104
  const property = scope.claim(param.name);
105
105
  properties[property] = { ...jsonSchemaOf(param.schema, ir.schemas), ...describe(param.description) };
@@ -107,6 +107,7 @@ function inputOf(op, ir, file) {
107
107
  required.push(property);
108
108
  args.push([property, group, param.name]);
109
109
  }
110
+ }
110
111
  const body = bodyOf(op, ir, { file, properties, required, scope });
111
112
  let collect;
112
113
  if (op.extensions.sse === true) {
@@ -134,14 +135,14 @@ export function toolsOf(ir, file = FILE_SCHEMA) {
134
135
  const taken = new Set();
135
136
  return ir.operations.filter(isTool).map((op) => {
136
137
  const { args, body, collect, inputSchema } = inputOf(op, ir, file);
137
- /* the SDK model holds every operation of the IR */
138
+ // the SDK model holds every operation of the IR
138
139
  const sdkOp = model.opsById.get(op.id);
139
140
  const annotations = annotationsOf(sdkOp);
140
141
  return {
141
142
  name: toolName(op.id, taken),
142
143
  ...describe(op.description ?? op.summary),
143
144
  inputSchema,
144
- /* sdkMemberPaths holds every operation of the IR */
145
+ // sdkMemberPaths holds every operation of the IR
145
146
  member: members.get(op.id),
146
147
  args,
147
148
  ...body,
@@ -5,7 +5,7 @@ import { pyTopLevel } from "./types.js";
5
5
  /** The keys an error response's envelope names, over every operation's JSON error statuses (the runtime reads JSON only). */
6
6
  function envelopeKeys(model) {
7
7
  return model.ops.flatMap((op) => op.errorStatuses.flatMap((status) => {
8
- /* an error status is a declared response, and a schema comes with the content type it is under */
8
+ // an error status is a declared response, and a schema comes with the content type it is under
9
9
  const { contentType, schema } = op.ir.responses[String(status)];
10
10
  if (schema === undefined || !isJsonMedia(contentType))
11
11
  return [];
@@ -19,7 +19,7 @@ function envelopeKeys(model) {
19
19
  function declaredKeys(model) {
20
20
  const byId = [...model.ops].sort((a, b) => compareCodeUnits(a.id, b.id));
21
21
  const declared = byId.flatMap((op) => Object.entries(op.ir.extensions.errors ?? {}));
22
- /* a later entry wins: an envelope's key gives way to a declaration, each declaration reversed to its first */
22
+ // a later entry wins: an envelope's key gives way to a declaration, each declaration reversed to its first
23
23
  const keys = new Map([
24
24
  ...envelopeKeys(model).map((key) => [key, undefined]),
25
25
  ...declared.toReversed().map(([key, { schema }]) => [key, schema]),
@@ -50,7 +50,7 @@ export function pythonErrorKeys(model, at) {
50
50
  const members = new NameScope();
51
51
  const keys = declared.map(([wire, schema]) => ({
52
52
  data: bodyType(wire, schema, model, at),
53
- /* an UPPER_SNAKE member never meets a keyword, so the keyword guard's `_` goes */
53
+ // an UPPER_SNAKE member never meets a keyword, so the keyword guard's `_` goes
54
54
  member: members.claim(pyIdentifier(wire).replace(/_$/, "").toUpperCase()),
55
55
  wire,
56
56
  }));
@@ -17,13 +17,13 @@ export const realtimeStream = {
17
17
  answer: (op, env) => socketAnswer(op, env, {
18
18
  base: "ResumableConnection",
19
19
  in: "object",
20
- /* the one event a connection's `on` takes for itself */
20
+ // the one event a connection's `on` takes for itself
21
21
  lifecycle: (out) => [["message", out]],
22
22
  out: () => eventType(op, env, () => pyTypeOf({ kind: "unknown" }, env.at)),
23
23
  run: "realtime",
24
24
  suffix: "Connection",
25
25
  }),
26
- /* the WebSocket and long-poll dials send the cursor as query params, the SSE dial its id as Last-Event-ID */
26
+ // the WebSocket and long-poll dials send the cursor as query params, the SSE dial its id as Last-Event-ID
27
27
  carries: (name, where) => isReconnectToken(name, where) ||
28
28
  (where === "query" && name === "last_event_id") ||
29
29
  isLastEventIdHeader(name, where),
@@ -8,6 +8,7 @@
8
8
  import type { IRParam } from "../../ir/model.ts";
9
9
  import type { SdkOp } from "../../ir/sdk-model.ts";
10
10
  import type { MethodEnv } from "./sdk-method.ts";
11
+ import type { PythonCallPlan } from "./sdk-plan.ts";
11
12
  /** `schema`'s type at `<Op><field>`, written in the client module. */
12
13
  export declare const typeAt: (op: SdkOp, field: string, schema: IRParam["schema"], env: MethodEnv) => string;
13
14
  /** The body parameter's type: its schema's for JSON and a form, `<Op>Body` for multipart, `str` for text, bytes or chunks for binary. */
@@ -43,11 +44,6 @@ export declare function answerOf(op: SdkOp, env: MethodEnv): Answer;
43
44
  export declare function shapeOf(op: SdkOp, env: MethodEnv): string | null;
44
45
  /** `<Op>Headers` (total=False) hoisted beside the types, and how `Operation.headers` reads each; null without any. */
45
46
  export declare function responseHeaders(op: SdkOp, env: MethodEnv): {
46
- plan: {
47
- fields: {
48
- [k: string]: string;
49
- };
50
- type: string;
51
- };
52
- read: string[];
47
+ readonly plan: NonNullable<PythonCallPlan["responseHeaders"]>;
48
+ readonly read: string[];
53
49
  } | null;
@@ -75,14 +75,14 @@ export function responseHeaders(op, env) {
75
75
  const fields = headers.map((header) => {
76
76
  const resolved = env.at.names.resolve(header.schema);
77
77
  const at = { ...env.at, fieldName: header.name, parentName: type, typing };
78
- /* a scalar is read as its kind; any other schema as the header's text, which is what arrives */
78
+ // a scalar is read as its kind; any other schema as the header's text, which is what arrives
79
79
  const read = resolved.kind === "scalar" && resolved.type !== "null"
80
80
  ? { kind: resolved.type, type: pyTypeOf(header.schema, at) }
81
81
  : { kind: "string", type: "str" };
82
82
  return { header: header.name, key: scope.claim(pyIdentifier(header.name)), required: header.required, ...read };
83
83
  });
84
84
  typing.add("TypedDict");
85
- /* every key is an identifier (pyIdentifier), so the class form always spells it */
85
+ // every key is an identifier (pyIdentifier), so the class form always spells it
86
86
  env.at.decls.set(type, [`class ${type}(TypedDict, total=False):`, ...fields.map((f) => ` ${f.key}: ${f.type}`)].join("\n"));
87
87
  const read = fields.map(({ header, key, kind, required }) => `(${pyString(header)}, ${pyString(key)}, ${pyString(kind)}, ${required ? "True" : "False"})`);
88
88
  return { plan: { fields: Object.fromEntries(fields.map((f) => [f.header, f.key])), type }, read };
@@ -3,17 +3,16 @@ import { dictDecl } from "./types-dict.js";
3
3
  import { pyTypeOf } from "./types.js";
4
4
  /** The parts the body schema of `op` requires: none unless it is an object. */
5
5
  function requiredParts(op, env) {
6
- /* a multipart body, with file parts or text parts alone, is declared with its form's schema */
6
+ // a multipart body, with file parts or text parts alone, is declared with its form's schema
7
7
  const form = env.at.names.resolve(op.ir.body.schema);
8
8
  return new Set(form.kind === "object" ? form.fields.flatMap((f) => (f.required ? [f.name] : [])) : []);
9
9
  }
10
10
  /** The type of `part` as a key of `parent`: `FilePart` or its list for a file, its schema's type for text. */
11
11
  function partType(part, parent, env) {
12
- /* the IR gives every part its schema (ir/slots.ts partsOf, ir/sdk-model.ts bodyOf) */
12
+ // the IR gives every part its schema (ir/slots.ts partsOf, ir/sdk-model.ts bodyOf)
13
13
  const schema = part.schema;
14
- if (part.type === "text") {
14
+ if (part.type === "text")
15
15
  return pyTypeOf(schema, { ...env.at, fieldName: part.name, parentName: parent, typing: env.at.declTyping });
16
- }
17
16
  env.typesImports.add("FilePart");
18
17
  return env.at.names.resolve(schema).kind === "array" ? "list[FilePart]" : "FilePart";
19
18
  }
@@ -22,7 +21,7 @@ export function multipartBody(op, parts, env) {
22
21
  const name = env.at.names.hoist(`${op.id}.Body`, `${pyClassName(op.id)}Body`);
23
22
  if (env.at.decls.has(name))
24
23
  return name;
25
- /* claimed before its keys: what a text part hoists in turn comes after it */
24
+ // claimed before its keys: what a text part hoists in turn comes after it
26
25
  env.at.decls.set(name, "");
27
26
  const required = requiredParts(op, env);
28
27
  const keys = [...parts]
@@ -3,7 +3,7 @@ import { pyDocLines, pyString } from "../shared/escape.js";
3
3
  import { compareCodeUnits, NameScope, pyClassName, pyIdentifier } from "../shared/lang.js";
4
4
  import { MIRROR, mirrorNotice } from "../shared/mirror.js";
5
5
  import { BUILTINS, pyMethod } from "./sdk-method.js";
6
- /* the root clients' own members: no namespace or operation takes their names */
6
+ // the root clients' own members: no namespace or operation takes their names
7
7
  const ROOT_NAMES = ["close", "aclose", "is_stale", MIRROR];
8
8
  /**
9
9
  * `ns` at `path`: its children first, so a method never takes an attribute's name. A root member spelled `safe` is
@@ -37,7 +37,7 @@ const below = (node) => node.children.flatMap(({ node: child }) => [...below(chi
37
37
  */
38
38
  function classNames(root, env) {
39
39
  const base = (node) => (node === root ? "SDK" : `${node.path.map(pyClassName).join("")}Resource`);
40
- /* the normal classes first, so a twin never moves the name one of them had */
40
+ // the normal classes first, so a twin never moves the name one of them had
41
41
  const claimed = (nodes, prefix) => new Map(nodes.map((node) => {
42
42
  const sync = node === root || hasSync(node) ? env.at.names.claim(`${prefix}${base(node)}`) : undefined;
43
43
  const async = env.at.names.claim(`Async${prefix}${base(node)}`);
@@ -76,7 +76,7 @@ function methodBlocks(node, side) {
76
76
  }
77
77
  /** The class of `node` on `side`; a safe mirror's methods one line each, with no blank line between them. */
78
78
  function resourceClass(node, side) {
79
- const init = [" def __init__(self, transport: " + side.transport + ") -> None:", " self._t = transport"];
79
+ const init = [` def __init__(self, transport: ${side.transport}) -> None:`, " self._t = transport"];
80
80
  const methods = methodBlocks(node, side);
81
81
  return [
82
82
  `class ${side.name(node)}:`,
@@ -105,7 +105,7 @@ function rootClass(root, side, safe, doc) {
105
105
  [` ${a ? "async " : ""}def ${a}close(self) -> None:`, ` ${aw}self._t.${a}close()`],
106
106
  [` ${a ? "async " : ""}def __${a}enter__(self) -> Self:`, " return self"],
107
107
  [` ${a ? "async " : ""}def __${a}exit__(self, *exc: object) -> None:`, ` ${aw}self.${a}close()`],
108
- /* after the client's own methods: an operation named like a builtin shadows only what follows it */
108
+ // after the client's own methods: an operation named like a builtin shadows only what follows it
109
109
  ...methodBlocks(root, side),
110
110
  ];
111
111
  return [`class ${side.async ? "AsyncSDK" : "SDK"}:`, ` """${doc}"""`, "", ...members(own)];
@@ -153,7 +153,7 @@ export function clientDecls(ir, env) {
153
153
  ...nodes.map((node) => resourceClass(node, async)),
154
154
  rootClass(root, sync, safeSync, clientTitle(ir)),
155
155
  rootClass(root, async, safeAsync, clientTitle(ir)),
156
- /* after the classes they twin: each method line reads its normal class */
156
+ // after the classes they twin: each method line reads its normal class
157
157
  ...nodes.filter((node) => sync.name(node) !== undefined).map((node) => resourceClass(node, safeSync)),
158
158
  ...nodes.map((node) => resourceClass(node, safeAsync)),
159
159
  resourceClass(root, safeSync),
@@ -1,5 +1,5 @@
1
1
  import { pyDocLines } from "../shared/escape.js";
2
- /* the runtime's STATUS_ERRORS (runtime/python/errors.py); any other status raises APIStatusError */
2
+ // the runtime's STATUS_ERRORS (runtime/python/errors.py); any other status raises APIStatusError
3
3
  const STATUS_ERRORS = {
4
4
  400: "BadRequestError",
5
5
  401: "UnauthorizedError",
@@ -25,7 +25,7 @@ export function methodDoc(op, stream) {
25
25
  const lines = parts.flatMap((part, i) => (i === 0 ? part : ["", ...part]));
26
26
  if (lines.length === 0)
27
27
  return [];
28
- /* a docstring that opens on its Raises: block opens on a line of its own, so the block keeps its shape */
28
+ // a docstring that opens on its Raises: block opens on a line of its own, so the block keeps its shape
29
29
  const open = lines[0] === "Raises:" ? ['"""', ...lines] : [`"""${lines[0]}`, ...lines.slice(1)];
30
30
  const body = lines.length === 1 ? [`"""${lines[0]}"""`] : [...open, '"""'];
31
31
  return body.map((line) => (line === "" ? "" : ` ${line}`));
@@ -6,23 +6,23 @@ import { answerOf, bodyType, responseHeaders, shapeOf, typeAt } from "./sdk-answ
6
6
  import { methodDoc } from "./sdk-doc.js";
7
7
  import { sseStream } from "./sse.js";
8
8
  import { wsStream } from "./ws.js";
9
- /* the builtins an annotation may spell that a method may be named: a method so named shadows it below */
9
+ // the builtins an annotation may spell that a method may be named: a method so named shadows it below
10
10
  export const BUILTINS = ["bool", "bytes", "dict", "float", "int", "list", "str", "tuple"];
11
11
  /**
12
12
  * `type` with each builtin `shadowed` names spelled `_builtins.<name>`; strings inside it kept. The module is
13
13
  * aliased because a method may be named `builtins`, and `pyIdentifier` never yields a leading `_`.
14
14
  */
15
15
  function qualified(type, shadowed, env) {
16
- return type.replace(/("(?:[^"\\]|\\.)*")|\b([a-z]+)\b/g, (whole, text, name) => {
16
+ return type.replaceAll(/("(?:[^"\\]|\\.)*")|\b([a-z]+)\b/g, (whole, text, name) => {
17
17
  if (text !== undefined || !shadowed.has(name))
18
18
  return whole;
19
19
  env.imports.add("builtins");
20
20
  return `_builtins.${name}`;
21
21
  });
22
22
  }
23
- /* the method's own names, a stream's fields among them: a parameter that takes one is claimed as `…2` */
23
+ // the method's own names, a stream's fields among them: a parameter that takes one is claimed as `…2`
24
24
  const METHOD_LOCALS = ["self", "body", "options", "idempotency_key", "headers_into"];
25
- /* each stream's answer, its own fields, and the declared params its resume channels carry (Fd3) */
25
+ // each stream's answer, its own fields, and the declared params its resume channels carry (Fd3)
26
26
  const STREAMS = {
27
27
  realtime: realtimeStream,
28
28
  sse: sseStream,
@@ -131,7 +131,7 @@ function methodLines(parts, async, env, shadowed) {
131
131
  const required = op.body?.required === true;
132
132
  const keyed = op.idempotent && op.stream === null;
133
133
  const own = op.stream === null ? [] : STREAMS[op.stream].fields;
134
- /* `name: type`, or `name: type = default`, its type qualified where an earlier method shadows a builtin */
134
+ // `name: type`, or `name: type = default`, its type qualified where an earlier method shadows a builtin
135
135
  const param = (text) => {
136
136
  const [name, rest] = [text.slice(0, text.indexOf(": ")), text.slice(text.indexOf(": ") + 2)];
137
137
  const unset = rest.endsWith(" = None");
@@ -1 +0,0 @@
1
- export {};
@@ -14,8 +14,6 @@ export declare const PYTHON_REQUIRES = ">=3.11";
14
14
  export declare const PYTHON_CLASSIFIERS: readonly string[];
15
15
  /** The lowest httpx2 every emitted package accepts. */
16
16
  export declare const HTTPX2_FLOOR = "2.12.0";
17
- /** The dependency string every emitted package declares (`httpx2[ws]` when it needs WebSockets). */
18
- export declare const HTTPX2 = "httpx2>=2.12.0,<3";
19
17
  /** `name` when it is an import name a package may take: lower snake case, no keyword, not the runtime's. */
20
18
  export declare function validatePackageName(name: string): string;
21
19
  /** `version` when it is in PEP 440's release, pre, post and dev subset. */
@@ -20,26 +20,24 @@ export const PYTHON_CLASSIFIERS = [
20
20
  "Programming Language :: Python :: 3.14",
21
21
  "Typing :: Typed",
22
22
  ];
23
- /* clients' own record of what it wrote (gen/write.ts MANIFEST), which no sdist ships */
23
+ // clients' own record of what it wrote (gen/write.ts MANIFEST), which no sdist ships
24
24
  const MANIFEST = ".clients-generated.json";
25
25
  /** The lowest httpx2 every emitted package accepts. */
26
26
  export const HTTPX2_FLOOR = "2.12.0";
27
27
  /** The dependency string every emitted package declares (`httpx2[ws]` when it needs WebSockets). */
28
- export const HTTPX2 = `httpx2>=${HTTPX2_FLOOR},<3`;
29
- /* the hard keywords and the soft ones, none an import name */
28
+ const HTTPX2 = `httpx2>=${HTTPX2_FLOOR},<3`;
29
+ // the hard keywords and the soft ones, none an import name
30
30
  const KEYWORDS = " False None True and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield match case type _ ";
31
31
  /** `name` when it is an import name a package may take: lower snake case, no keyword, not the runtime's. */
32
32
  export function validatePackageName(name) {
33
- if (!/^[a-z][a-z0-9_]*$/.test(name) || KEYWORDS.includes(` ${name} `) || name === "_http") {
33
+ if (!/^[a-z][a-z0-9_]*$/.test(name) || KEYWORDS.includes(` ${name} `) || name === "_http")
34
34
  throw new Error(`Invalid package name: "${name}"`);
35
- }
36
35
  return name;
37
36
  }
38
37
  /** `version` when it is in PEP 440's release, pre, post and dev subset. */
39
38
  export function validateVersion(version) {
40
- if (!/^\d+(\.\d+)*((a|b|rc)\d+)?(\.post\d+)?(\.dev\d+)?$/.test(version)) {
39
+ if (!/^\d+(\.\d+)*((a|b|rc)\d+)?(\.post\d+)?(\.dev\d+)?$/.test(version))
41
40
  throw new Error(`Invalid version: "${version}"`);
42
- }
43
41
  return version;
44
42
  }
45
43
  /** A TOML basic string of `text`. */
@@ -74,7 +72,9 @@ function urls(metadata) {
74
72
  ["Documentation", documentation],
75
73
  ["Changelog", changelog],
76
74
  ].filter((entry) => entry[1] !== undefined);
77
- return labeled.length === 0 ? [] : ["[project.urls]", ...labeled.map(([label, url]) => `${label} = ${toml(url)}`), ""];
75
+ return labeled.length === 0
76
+ ? []
77
+ : ["[project.urls]", ...labeled.map(([label, url]) => `${label} = ${toml(url)}`), ""];
78
78
  }
79
79
  /** The manifest of package `pkg` (its import name; the distribution name has `-` for `_`). */
80
80
  export function pyproject(pkg, ws, metadata = {}) {
@@ -1,5 +1,5 @@
1
- import type { PythonCallPlan } from "./sdk-plan.ts";
2
1
  import { type Metadata, type PackageIdentity } from "../shared/metadata.ts";
2
+ import type { PythonCallPlan } from "./sdk-plan.ts";
3
3
  export type PythonSdkOptions = {
4
4
  /** the import name; `http_sdk` by default, its distribution name with `-` for `_` */
5
5
  readonly packageName?: string;