@namzu/sdk 40.0.0 → 41.0.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 (121) hide show
  1. package/CHANGELOG.md +177 -0
  2. package/dist/bridge/a2a/mapper.d.ts.map +1 -1
  3. package/dist/bridge/a2a/mapper.js +8 -0
  4. package/dist/bridge/a2a/mapper.js.map +1 -1
  5. package/dist/bridge/sse/mapper.d.ts.map +1 -1
  6. package/dist/bridge/sse/mapper.js +11 -0
  7. package/dist/bridge/sse/mapper.js.map +1 -1
  8. package/dist/connector/index.d.ts +2 -2
  9. package/dist/connector/index.d.ts.map +1 -1
  10. package/dist/connector/index.js +1 -1
  11. package/dist/connector/index.js.map +1 -1
  12. package/dist/connector/mcp/adapter.d.ts.map +1 -1
  13. package/dist/connector/mcp/adapter.js +92 -4
  14. package/dist/connector/mcp/adapter.js.map +1 -1
  15. package/dist/connector/mcp/audio-admission.d.ts +17 -0
  16. package/dist/connector/mcp/audio-admission.d.ts.map +1 -0
  17. package/dist/connector/mcp/audio-admission.js +171 -0
  18. package/dist/connector/mcp/audio-admission.js.map +1 -0
  19. package/dist/connector/mcp/client.d.ts +252 -1
  20. package/dist/connector/mcp/client.d.ts.map +1 -1
  21. package/dist/connector/mcp/client.js +611 -39
  22. package/dist/connector/mcp/client.js.map +1 -1
  23. package/dist/connector/mcp/envelope.d.ts +91 -0
  24. package/dist/connector/mcp/envelope.d.ts.map +1 -0
  25. package/dist/connector/mcp/envelope.js +173 -0
  26. package/dist/connector/mcp/envelope.js.map +1 -0
  27. package/dist/connector/mcp/era.d.ts +130 -0
  28. package/dist/connector/mcp/era.d.ts.map +1 -0
  29. package/dist/connector/mcp/era.js +304 -0
  30. package/dist/connector/mcp/era.js.map +1 -0
  31. package/dist/connector/mcp/errors.d.ts +106 -0
  32. package/dist/connector/mcp/errors.d.ts.map +1 -0
  33. package/dist/connector/mcp/errors.js +154 -0
  34. package/dist/connector/mcp/errors.js.map +1 -0
  35. package/dist/connector/mcp/http-sse.d.ts +11 -0
  36. package/dist/connector/mcp/http-sse.d.ts.map +1 -1
  37. package/dist/connector/mcp/http-sse.js +21 -6
  38. package/dist/connector/mcp/http-sse.js.map +1 -1
  39. package/dist/connector/mcp/index.d.ts +7 -0
  40. package/dist/connector/mcp/index.d.ts.map +1 -1
  41. package/dist/connector/mcp/index.js +10 -0
  42. package/dist/connector/mcp/index.js.map +1 -1
  43. package/dist/connector/mcp/streamable-http.d.ts +83 -0
  44. package/dist/connector/mcp/streamable-http.d.ts.map +1 -1
  45. package/dist/connector/mcp/streamable-http.js +177 -11
  46. package/dist/connector/mcp/streamable-http.js.map +1 -1
  47. package/dist/connector/mcp/x-mcp-header.d.ts +56 -0
  48. package/dist/connector/mcp/x-mcp-header.d.ts.map +1 -0
  49. package/dist/connector/mcp/x-mcp-header.js +254 -0
  50. package/dist/connector/mcp/x-mcp-header.js.map +1 -0
  51. package/dist/constants/mcp/index.d.ts +123 -15
  52. package/dist/constants/mcp/index.d.ts.map +1 -1
  53. package/dist/constants/mcp/index.js +135 -16
  54. package/dist/constants/mcp/index.js.map +1 -1
  55. package/dist/manager/agent/lifecycle.d.ts.map +1 -1
  56. package/dist/manager/agent/lifecycle.js +23 -0
  57. package/dist/manager/agent/lifecycle.js.map +1 -1
  58. package/dist/prompt/coding-agent-doctrine.d.ts +20 -0
  59. package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
  60. package/dist/prompt/coding-agent-doctrine.js +19 -3
  61. package/dist/prompt/coding-agent-doctrine.js.map +1 -1
  62. package/dist/prompt/index.d.ts +1 -1
  63. package/dist/prompt/index.d.ts.map +1 -1
  64. package/dist/prompt/index.js +1 -1
  65. package/dist/prompt/index.js.map +1 -1
  66. package/dist/public-runtime.d.ts +3 -3
  67. package/dist/public-runtime.d.ts.map +1 -1
  68. package/dist/public-runtime.js +3 -3
  69. package/dist/public-runtime.js.map +1 -1
  70. package/dist/sandbox/provider/local.d.ts.map +1 -1
  71. package/dist/sandbox/provider/local.js +46 -3
  72. package/dist/sandbox/provider/local.js.map +1 -1
  73. package/dist/scheduler/local.d.ts.map +1 -1
  74. package/dist/scheduler/local.js +8 -0
  75. package/dist/scheduler/local.js.map +1 -1
  76. package/dist/store/run/disk.d.ts +35 -1
  77. package/dist/store/run/disk.d.ts.map +1 -1
  78. package/dist/store/run/disk.js +100 -0
  79. package/dist/store/run/disk.js.map +1 -1
  80. package/dist/types/agent/scheduler.d.ts +20 -0
  81. package/dist/types/agent/scheduler.d.ts.map +1 -1
  82. package/dist/types/agent/task.d.ts +20 -0
  83. package/dist/types/agent/task.d.ts.map +1 -1
  84. package/dist/types/connector/mcp.d.ts +205 -0
  85. package/dist/types/connector/mcp.d.ts.map +1 -1
  86. package/dist/types/run/events.d.ts +56 -0
  87. package/dist/types/run/events.d.ts.map +1 -1
  88. package/dist/types/run/events.js.map +1 -1
  89. package/dist/types/run/store.d.ts +41 -0
  90. package/dist/types/run/store.d.ts.map +1 -1
  91. package/dist/types/sandbox/index.d.ts +68 -1
  92. package/dist/types/sandbox/index.d.ts.map +1 -1
  93. package/dist/types/sandbox/index.js.map +1 -1
  94. package/package.json +1 -1
  95. package/src/bridge/a2a/mapper.ts +8 -0
  96. package/src/bridge/sse/mapper.ts +11 -0
  97. package/src/connector/index.ts +27 -0
  98. package/src/connector/mcp/adapter.ts +103 -4
  99. package/src/connector/mcp/audio-admission.ts +173 -0
  100. package/src/connector/mcp/client.ts +694 -45
  101. package/src/connector/mcp/envelope.ts +235 -0
  102. package/src/connector/mcp/era.ts +400 -0
  103. package/src/connector/mcp/errors.ts +171 -0
  104. package/src/connector/mcp/http-sse.ts +23 -6
  105. package/src/connector/mcp/index.ts +37 -0
  106. package/src/connector/mcp/streamable-http.ts +199 -11
  107. package/src/connector/mcp/x-mcp-header.ts +322 -0
  108. package/src/constants/mcp/index.ts +145 -16
  109. package/src/manager/agent/lifecycle.ts +29 -0
  110. package/src/prompt/coding-agent-doctrine.ts +31 -4
  111. package/src/prompt/index.ts +1 -0
  112. package/src/public-runtime.ts +28 -0
  113. package/src/sandbox/provider/local.ts +45 -2
  114. package/src/scheduler/local.ts +8 -0
  115. package/src/store/run/disk.ts +108 -0
  116. package/src/types/agent/scheduler.ts +21 -0
  117. package/src/types/agent/task.ts +21 -0
  118. package/src/types/connector/mcp.ts +205 -1
  119. package/src/types/run/events.ts +56 -0
  120. package/src/types/run/store.ts +42 -0
  121. package/src/types/sandbox/index.ts +69 -1
@@ -261,6 +261,35 @@ export interface SandboxTcpConnectOptions {
261
261
  readonly host?: '127.0.0.1' | '::1'
262
262
  }
263
263
 
264
+ /**
265
+ * What to read, and how to stop reading it. Every field is optional, so
266
+ * `readFile(path)` and `readFile(path, {})` mean the same thing: the whole
267
+ * file.
268
+ */
269
+ export interface SandboxReadFileOptions {
270
+ /** First byte to read. Defaults to 0. */
271
+ readonly offset?: number
272
+ /**
273
+ * How many bytes to read. Defaults to the rest of the file. A range
274
+ * that runs past the end returns the bytes that exist, not an error —
275
+ * a caller resuming from a remembered offset must be able to ask
276
+ * without knowing the answer first.
277
+ *
278
+ * **A backend may cap how large a single range it will serve**, and
279
+ * one past that cap is REFUSED rather than shortened — a caller that
280
+ * asked for 4 MiB, got 1 MiB and was told nothing would read the short
281
+ * answer as the end of its range. The agent-backed backends cap it at
282
+ * `NAMZU_AGENT_READ_FILE_RANGE_BYTES` (1 MiB by default), because one
283
+ * range is one wire frame there; a provider reading from local disk has
284
+ * no such ceiling. A caller that wants more than a frame's worth in one
285
+ * call iterates {@link Sandbox.readFileStream} instead, which is not
286
+ * capped.
287
+ */
288
+ readonly length?: number
289
+ /** Aborts the read. */
290
+ readonly signal?: AbortSignal
291
+ }
292
+
264
293
  export interface Sandbox {
265
294
  readonly id: SandboxId
266
295
  readonly status: SandboxStatus
@@ -323,7 +352,46 @@ export interface Sandbox {
323
352
  */
324
353
  openTcpConnection?(options: SandboxTcpConnectOptions): Promise<SandboxTcpConnection>
325
354
  writeFile(path: string, content: string | Buffer): Promise<void>
326
- readFile(path: string): Promise<Buffer>
355
+ /**
356
+ * Read a file out of the sandbox.
357
+ *
358
+ * `options` is optional in both directions, which is what keeps this
359
+ * source-compatible: a caller may go on writing `readFile(path)`, and a
360
+ * backend may go on declaring the one-parameter form and still satisfy
361
+ * this signature. A backend that accepts the parameter and IGNORES
362
+ * `offset`/`length` does not — returning the whole file where a slice
363
+ * was asked for is a wrong answer, not a degraded one, so such a
364
+ * backend must reject instead.
365
+ *
366
+ * @param options.offset First byte to read. Defaults to 0.
367
+ * @param options.length How many bytes to read. Defaults to the rest of
368
+ * the file. A range that runs past the end returns the bytes that
369
+ * exist rather than failing.
370
+ * @param options.signal Aborts the read.
371
+ */
372
+ readFile(path: string, options?: SandboxReadFileOptions): Promise<Buffer>
373
+ /**
374
+ * Read a file as a stream of chunks, so neither the sandbox nor this
375
+ * process ever holds the whole of it.
376
+ *
377
+ * Optional, in the same way {@link Sandbox.openTerminal} is: a backend
378
+ * that cannot read a file incrementally must OMIT this rather than
379
+ * implement it by reading the file whole and chopping the result up,
380
+ * which would give a caller the bounded-memory behaviour it asked for in
381
+ * name only. A caller that needs the bound therefore refuses an absent
382
+ * method rather than falling back to {@link Sandbox.readFile}.
383
+ *
384
+ * Chunk boundaries are not part of the contract — only the order and
385
+ * the concatenation are. Aborting `options.signal`, or leaving the loop
386
+ * early, must stop the transfer and release whatever the sandbox opened
387
+ * for it.
388
+ *
389
+ * Hosts that drain agent-produced output files before {@link destroy}
390
+ * (see {@link listFiles}) are the reason this exists: those files are
391
+ * routinely tens to hundreds of megabytes, and a whole-file read of one
392
+ * of them costs several times its size in the sandbox.
393
+ */
394
+ readFileStream?(path: string, options?: SandboxReadFileOptions): AsyncIterable<Buffer>
327
395
  /**
328
396
  * Recursively enumerate regular files under `rootPath`. Directories,
329
397
  * symlinks, sockets, and other non-regular entries are skipped.