dsh-plugin-dev-kb 1.8.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/CHANGELOG.md +186 -178
  2. package/README.en.md +172 -172
  3. package/README.md +183 -183
  4. package/kb/INDEX.md +236 -234
  5. package/kb/README.md +88 -88
  6. package/kb/extra/AGENTS.md +77 -77
  7. package/kb/extra/deepseek-llm-api-wire-extensions.md +162 -162
  8. package/kb/extra/deepseek-llm-api-wire-extensions.zh.md +162 -162
  9. package/kb/extra/defensive-patterns/package-surface.md +233 -232
  10. package/kb/extra/defensive-patterns/package-surface.zh.md +233 -232
  11. package/kb/extra/defensive-patterns/remote-and-api.md +117 -117
  12. package/kb/extra/defensive-patterns/remote-and-api.zh.md +117 -117
  13. package/kb/extra/development.md +221 -221
  14. package/kb/extra/development.zh.md +228 -228
  15. package/kb/extra/event-producer-consumer.md +133 -123
  16. package/kb/extra/event-producer-consumer.zh.md +135 -125
  17. package/kb/extra/module-graph.md +1961 -1888
  18. package/kb/extra/module-graph.zh.md +1963 -1890
  19. package/kb/extra/persistence-changes/2026-11-05-timeline-priority-notice.md +60 -0
  20. package/kb/extra/persistence-changes/2026-11-05-timeline-priority-notice.zh.md +60 -0
  21. package/kb/extra/persistence-changes/README.md +92 -92
  22. package/kb/extra/persistence-changes/README.zh.md +92 -92
  23. package/kb/extra/persistence-changes/historical-formats/README.md +75 -75
  24. package/kb/extra/persistence-changes/historical-formats/README.zh.md +75 -75
  25. package/kb/extra/persistence-changes/releases/README.md +103 -103
  26. package/kb/extra/persistence-changes/releases/README.zh.md +103 -103
  27. package/kb/extra/rescope.md +55 -55
  28. package/kb/extra/rescope.zh.md +55 -55
  29. package/kb/extra/subsystems/boot.md +631 -621
  30. package/kb/extra/subsystems/boot.zh.md +631 -621
  31. package/kb/extra/subsystems/computer-use.md +179 -137
  32. package/kb/extra/subsystems/computer-use.zh.md +179 -137
  33. package/kb/extra/subsystems/extensions.md +387 -384
  34. package/kb/extra/subsystems/extensions.zh.md +387 -384
  35. package/kb/extra/subsystems/feedback.md +418 -400
  36. package/kb/extra/subsystems/feedback.zh.md +418 -400
  37. package/kb/extra/subsystems/forge.md +2169 -1226
  38. package/kb/extra/subsystems/forge.zh.md +2171 -1226
  39. package/kb/extra/subsystems/liveshare.md +167 -158
  40. package/kb/extra/subsystems/liveshare.zh.md +167 -158
  41. package/kb/extra/subsystems/mcp.md +237 -234
  42. package/kb/extra/subsystems/mcp.zh.md +237 -234
  43. package/kb/extra/subsystems/office-kit.md +122 -0
  44. package/kb/extra/subsystems/office-kit.zh.md +122 -0
  45. package/kb/extra/subsystems/working-directory.md +95 -64
  46. package/kb/extra/subsystems/working-directory.zh.md +95 -64
  47. package/kb/extra/subsystems/worktrees.md +187 -127
  48. package/kb/extra/subsystems/worktrees.zh.md +187 -127
  49. package/kb/extra/upgrade-guide/v0.2.1-alpha.1/python-ptc-sandbox/guide.md +21 -21
  50. package/kb/extra/upgrade-guide/v0.2.1-alpha.1/python-ptc-sandbox/guide.zh.md +21 -21
  51. package/kb/extra/upgrade-guide/v0.2.1-rc.4/sandbox-unsupported-policy-error/guide.md +18 -0
  52. package/kb/extra/upgrade-guide/v0.2.1-rc.4/sandbox-unsupported-policy-error/guide.zh.md +18 -0
  53. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/llm-error-builtin-codes/guide.md +18 -0
  54. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/llm-error-builtin-codes/guide.zh.md +18 -0
  55. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-kit-package/guide.md +34 -0
  56. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-kit-package/guide.zh.md +34 -0
  57. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-operation-tools/guide.md +49 -0
  58. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-operation-tools/guide.zh.md +49 -0
  59. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-skill-resources/guide.md +36 -0
  60. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-skill-resources/guide.zh.md +36 -0
  61. package/kb/extra/upgrade-guide/v0.2.2-rc.1/account-notification-fields/guide.md +26 -0
  62. package/kb/extra/upgrade-guide/v0.2.2-rc.1/account-notification-fields/guide.zh.md +26 -0
  63. package/kb/extra/upgrade-guide/v0.2.2-rc.1/account-remote-provider/guide.md +22 -0
  64. package/kb/extra/upgrade-guide/v0.2.2-rc.1/account-remote-provider/guide.zh.md +22 -0
  65. package/kb/extra/upgrade-guide/v0.2.2-rc.1/archive-worktrees/guide.md +21 -0
  66. package/kb/extra/upgrade-guide/v0.2.2-rc.1/archive-worktrees/guide.zh.md +21 -0
  67. package/kb/extra/upgrade-guide/v0.2.2-rc.1/attachment-error-codes/guide.md +23 -0
  68. package/kb/extra/upgrade-guide/v0.2.2-rc.1/attachment-error-codes/guide.zh.md +23 -0
  69. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-ax-read-limits/guide.md +20 -0
  70. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-ax-read-limits/guide.zh.md +20 -0
  71. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-hover-ax-only/guide.md +18 -0
  72. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-hover-ax-only/guide.zh.md +18 -0
  73. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-native-platform/guide.md +23 -0
  74. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-native-platform/guide.zh.md +23 -0
  75. package/kb/extra/upgrade-guide/v0.2.2-rc.1/dsh-doc-skill/guide.md +35 -0
  76. package/kb/extra/upgrade-guide/v0.2.2-rc.1/dsh-doc-skill/guide.zh.md +35 -0
  77. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-change-request-overview/guide.md +26 -0
  78. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-change-request-overview/guide.zh.md +26 -0
  79. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-pinned-diff/guide.md +26 -0
  80. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-pinned-diff/guide.zh.md +26 -0
  81. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-review-reads/guide.md +19 -0
  82. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-review-reads/guide.zh.md +19 -0
  83. package/kb/extra/upgrade-guide/v0.2.2-rc.1/package-export-cleanup/guide.md +26 -0
  84. package/kb/extra/upgrade-guide/v0.2.2-rc.1/package-export-cleanup/guide.zh.md +26 -0
  85. package/kb/extra/upgrade-guide/v0.2.2-rc.1/plugin-update-method/guide.md +22 -0
  86. package/kb/extra/upgrade-guide/v0.2.2-rc.1/plugin-update-method/guide.zh.md +22 -0
  87. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-bootstrap-protocol/guide.md +25 -0
  88. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-bootstrap-protocol/guide.zh.md +25 -0
  89. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-inspect-output/guide.md +48 -0
  90. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-inspect-output/guide.zh.md +48 -0
  91. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-scoped-repl-default/guide.md +45 -0
  92. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-scoped-repl-default/guide.zh.md +45 -0
  93. package/kb/extra/upgrade-guide/v0.2.2-rc.1/runtime-context-reminders/guide.md +19 -0
  94. package/kb/extra/upgrade-guide/v0.2.2-rc.1/runtime-context-reminders/guide.zh.md +19 -0
  95. package/kb/extra/upgrade-guide/v0.2.2-rc.1/session-append-overloads/guide.md +17 -0
  96. package/kb/extra/upgrade-guide/v0.2.2-rc.1/session-append-overloads/guide.zh.md +17 -0
  97. package/kb/extra/upgrade-guide/v0.2.2-rc.1/subagent-interrupt-default/guide.md +27 -0
  98. package/kb/extra/upgrade-guide/v0.2.2-rc.1/subagent-interrupt-default/guide.zh.md +27 -0
  99. package/kb/extra/upgrade-guide/v0.2.2-rc.1/terminal-backend-cleanup-error/guide.md +20 -0
  100. package/kb/extra/upgrade-guide/v0.2.2-rc.1/terminal-backend-cleanup-error/guide.zh.md +20 -0
  101. package/kb/extra/upgrade-guide/v0.2.2-rc.1/terminal-bundle-sidebar-backend/guide.md +19 -0
  102. package/kb/extra/upgrade-guide/v0.2.2-rc.1/terminal-bundle-sidebar-backend/guide.zh.md +19 -0
  103. package/kb/extra/upgrade-guide/v0.2.2-rc.1/web-fetch-transport-error-codes/guide.md +18 -0
  104. package/kb/extra/upgrade-guide/v0.2.2-rc.1/web-fetch-transport-error-codes/guide.zh.md +18 -0
  105. package/kb/extra/upgrade-guide/v0.2.2-rc.1/web-search-billing/guide.md +41 -0
  106. package/kb/extra/upgrade-guide/v0.2.2-rc.1/web-search-billing/guide.zh.md +41 -0
  107. package/kb/extra/upgrade-guide/v0.2.2-rc.1/window-drag-regions/guide.md +21 -0
  108. package/kb/extra/upgrade-guide/v0.2.2-rc.1/window-drag-regions/guide.zh.md +21 -0
  109. package/kb/extra/upgrade-guide/v0.2.2-rc.2/client-module-metadata/guide.md +29 -0
  110. package/kb/extra/upgrade-guide/v0.2.2-rc.2/client-module-metadata/guide.zh.md +29 -0
  111. package/kb/extra/upgrade-guide/v0.2.2-rc.2/connection-page-peer/guide.md +25 -0
  112. package/kb/extra/upgrade-guide/v0.2.2-rc.2/connection-page-peer/guide.zh.md +25 -0
  113. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cordis-root-and-intercept-metadata/guide.md +31 -0
  114. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cordis-root-and-intercept-metadata/guide.zh.md +31 -0
  115. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-agents-without-preset/guide.md +24 -0
  116. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-agents-without-preset/guide.zh.md +24 -0
  117. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-macos-provider/guide.md +24 -0
  118. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-macos-provider/guide.zh.md +24 -0
  119. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-partial-observations/guide.md +19 -0
  120. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-partial-observations/guide.zh.md +19 -0
  121. package/kb/extra/upgrade-guide/v0.2.2-rc.2/deepseek-files-timeout/guide.md +15 -0
  122. package/kb/extra/upgrade-guide/v0.2.2-rc.2/deepseek-files-timeout/guide.zh.md +15 -0
  123. package/kb/extra/upgrade-guide/v0.2.2-rc.2/experimental-tool-error-codes/guide.md +28 -0
  124. package/kb/extra/upgrade-guide/v0.2.2-rc.2/experimental-tool-error-codes/guide.zh.md +28 -0
  125. package/kb/extra/upgrade-guide/v0.2.2-rc.2/package-export-cleanup/guide.md +36 -0
  126. package/kb/extra/upgrade-guide/v0.2.2-rc.2/package-export-cleanup/guide.zh.md +36 -0
  127. package/kb/extra/upgrade-guide/v0.2.2-rc.2/python-ptc-removal/guide.md +22 -0
  128. package/kb/extra/upgrade-guide/v0.2.2-rc.2/python-ptc-removal/guide.zh.md +22 -0
  129. package/kb/extra/upgrade-guide/v0.2.2-rc.2/session-status-package/guide.md +31 -0
  130. package/kb/extra/upgrade-guide/v0.2.2-rc.2/session-status-package/guide.zh.md +31 -0
  131. package/kb/extra/upgrade-guide/v0.2.2-rc.2/shared-search-filter/guide.md +18 -0
  132. package/kb/extra/upgrade-guide/v0.2.2-rc.2/shared-search-filter/guide.zh.md +18 -0
  133. package/kb/extra/upgrade-guide/v0.2.2-rc.2/shell-fs-tool-error-codes/guide.md +30 -0
  134. package/kb/extra/upgrade-guide/v0.2.2-rc.2/shell-fs-tool-error-codes/guide.zh.md +30 -0
  135. package/kb/extra/web-styling.md +57 -57
  136. package/kb/extra/web-styling.zh.md +57 -57
  137. package/kb/meta/search-index.json +4508 -3980
  138. package/kb/meta/source.json +18 -18
  139. package/kb/site/develop/practice/llm-adapter.md +192 -192
  140. package/kb/site/en/develop/practice/llm-adapter.md +192 -192
  141. package/kb/site/en/guide/desktop-uninstall-cleanup.md +63 -0
  142. package/kb/site/en/guide/plugin-market.md +153 -151
  143. package/kb/site/en/guide/providers.md +234 -234
  144. package/kb/site/en/guide/quickstart.md +35 -34
  145. package/kb/site/en/reference/capability-seams.md +789 -767
  146. package/kb/site/en/reference/config-catalog.md +5432 -5128
  147. package/kb/site/en/reference/cookbook/adding-a-package.md +175 -175
  148. package/kb/site/en/reference/cookbook/adding-a-tool.md +105 -104
  149. package/kb/site/en/reference/cookbook/extension-cookbook.md +178 -135
  150. package/kb/site/en/reference/cordis-api/context.md +373 -369
  151. package/kb/site/en/reference/cordis-api/fiber.md +457 -433
  152. package/kb/site/en/reference/cordis-api/inherited.md +44 -44
  153. package/kb/site/en/reference/cordis-api/service.md +118 -107
  154. package/kb/site/en/reference/experimental-persistence-catalog.md +36 -23
  155. package/kb/site/en/reference/index.md +174 -174
  156. package/kb/site/en/reference/persistence-catalog.md +9453 -9432
  157. package/kb/site/en/reference/subsystems/compaction.md +288 -288
  158. package/kb/site/en/reference/subsystems/core.md +1172 -1171
  159. package/kb/site/en/reference/subsystems/credentials.md +526 -497
  160. package/kb/site/en/reference/subsystems/filesystem.md +708 -708
  161. package/kb/site/en/reference/subsystems/index.md +82 -82
  162. package/kb/site/en/reference/subsystems/llm-streaming.md +1290 -1288
  163. package/kb/site/en/reference/subsystems/lsp.md +230 -206
  164. package/kb/site/en/reference/subsystems/persistence.md +451 -432
  165. package/kb/site/en/reference/subsystems/plan.md +91 -91
  166. package/kb/site/en/reference/subsystems/ptc-runtime.md +295 -261
  167. package/kb/site/en/reference/subsystems/sandbox.md +250 -232
  168. package/kb/site/en/reference/subsystems/session-query.md +525 -515
  169. package/kb/site/en/reference/subsystems/session-reference.md +231 -229
  170. package/kb/site/en/reference/subsystems/session.md +1478 -1431
  171. package/kb/site/en/reference/subsystems/sidebar-right.md +165 -165
  172. package/kb/site/en/reference/subsystems/skills.md +356 -356
  173. package/kb/site/en/reference/subsystems/slots.md +235 -231
  174. package/kb/site/en/reference/subsystems/terminal.md +188 -188
  175. package/kb/site/en/reference/subsystems/tools.md +902 -891
  176. package/kb/site/en/reference/subsystems/user-questions.md +330 -327
  177. package/kb/site/en/reference/subsystems/web-client.md +161 -104
  178. package/kb/site/en/reference/subsystems/web-server.md +434 -351
  179. package/kb/site/en/reference/subsystems/web.md +268 -268
  180. package/kb/site/en/reference/subsystems/workflow.md +287 -282
  181. package/kb/site/en/reference/subsystems/workspace.md +743 -651
  182. package/kb/site/en/reference/tool-catalog.md +2867 -2704
  183. package/kb/site/guide/desktop-uninstall-cleanup.md +63 -0
  184. package/kb/site/guide/plugin-market.md +153 -151
  185. package/kb/site/guide/providers.md +234 -234
  186. package/kb/site/guide/quickstart.md +35 -34
  187. package/kb/site/reference/capability-seams.md +789 -767
  188. package/kb/site/reference/config-catalog.md +5432 -5128
  189. package/kb/site/reference/cookbook/adding-a-package.md +175 -175
  190. package/kb/site/reference/cookbook/adding-a-tool.md +107 -106
  191. package/kb/site/reference/cookbook/extension-cookbook.md +182 -139
  192. package/kb/site/reference/cordis-api/context.md +373 -369
  193. package/kb/site/reference/cordis-api/fiber.md +459 -435
  194. package/kb/site/reference/cordis-api/inherited.md +44 -44
  195. package/kb/site/reference/cordis-api/service.md +118 -107
  196. package/kb/site/reference/experimental-persistence-catalog.md +36 -23
  197. package/kb/site/reference/index.md +178 -178
  198. package/kb/site/reference/persistence-catalog.md +9453 -9432
  199. package/kb/site/reference/subsystems/compaction.md +288 -288
  200. package/kb/site/reference/subsystems/core.md +1184 -1183
  201. package/kb/site/reference/subsystems/credentials.md +526 -497
  202. package/kb/site/reference/subsystems/filesystem.md +708 -708
  203. package/kb/site/reference/subsystems/index.md +82 -82
  204. package/kb/site/reference/subsystems/llm-streaming.md +1296 -1294
  205. package/kb/site/reference/subsystems/lsp.md +230 -206
  206. package/kb/site/reference/subsystems/persistence.md +451 -432
  207. package/kb/site/reference/subsystems/plan.md +91 -91
  208. package/kb/site/reference/subsystems/ptc-runtime.md +295 -261
  209. package/kb/site/reference/subsystems/sandbox.md +250 -232
  210. package/kb/site/reference/subsystems/session-query.md +525 -515
  211. package/kb/site/reference/subsystems/session-reference.md +231 -229
  212. package/kb/site/reference/subsystems/session.md +1482 -1435
  213. package/kb/site/reference/subsystems/sidebar-right.md +165 -165
  214. package/kb/site/reference/subsystems/skills.md +356 -356
  215. package/kb/site/reference/subsystems/slots.md +239 -235
  216. package/kb/site/reference/subsystems/terminal.md +188 -188
  217. package/kb/site/reference/subsystems/tools.md +902 -891
  218. package/kb/site/reference/subsystems/user-questions.md +330 -327
  219. package/kb/site/reference/subsystems/web-client.md +161 -104
  220. package/kb/site/reference/subsystems/web-server.md +434 -351
  221. package/kb/site/reference/subsystems/web.md +268 -268
  222. package/kb/site/reference/subsystems/workflow.md +287 -282
  223. package/kb/site/reference/subsystems/workspace.md +743 -651
  224. package/kb/site/reference/tool-catalog.md +2872 -2709
  225. package/lib/index.js +359 -359
  226. package/package.json +68 -68
  227. package/skills/dsh-plugin-dev-kb.md +71 -70
  228. package/kb/extra/subsystems/office-to-pdf.md +0 -87
  229. package/kb/extra/subsystems/office-to-pdf.zh.md +0 -87
@@ -1,261 +1,295 @@
1
- ---
2
- editSource: "docs/subsystems/ptc-runtime.md"
3
- rawMarkdownPath: "en/reference/subsystems/ptc-runtime.md"
4
- outline: [2,3]
5
- ---
6
-
7
- # PTC runtime
8
-
9
- The PTC execution [capability seam](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/architecture/2026-06-13-capability-seams.md) supplies `ctx.ptcRuntime` through [dsh-ptc-runtime](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/ptc-runtime/ptc-runtime). It runs one program against host bindings and reports output, failure and applicable sandbox facts. PTC execution is optional rather than part of [the agent-loop spine](./core.md). The [PTC foundation](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-06-15-ptc.md) owns registry presentation, the [typed-return contract](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-07-20-ptc-typed-tool-returns.md) owns binding values, and the [sandboxed Node decision](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/architecture/2026-09-11-sandboxed-node-ptc-runtime.md) owns the shipped execution provider.
10
-
11
- Source: [`packages/ptc-runtime/ptc-runtime/src/types.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/ptc-runtime/ptc-runtime/src/types.ts)
12
-
13
- ## The run: request in, result out
14
-
15
- `PtcRunRequest` contains the program, bindings, cancellation and optional execution choices. The provider's `resolve` validates supported choices and applies its deployment defaults; `run` receives a `PtcRunSpec` with an explicit directory and deadline choice. An omitted timeout uses provider defaults, a number requests a capped elapsed budget, and `null` requests no elapsed deadline. Providers reject unsupported choices before execution:
16
-
17
- ```ts type-equiv
18
- /**
19
- * Caller inputs for one program. The provider's resolve method validates supported
20
- * options and supplies directory, deadline, and authority before execution.
21
- */
22
- interface PtcRunRequest {
23
- /**
24
- * The program source, in the runtime's {@link ../index.ts | language}. It
25
- * follows the provider's programFormat: an async function body supports
26
- * top-level `await` and `return`; REPL and Script programs support top-level
27
- * declarations, `await`, and a final expression, but not top-level `return`.
28
- * The Script provider lowers top-level await; its executionInstructions and
29
- * documentation define retained-binding semantics. The completion value
30
- * becomes {@link PtcRunResult.value}.
31
- */
32
- program: string
33
- /**
34
- * Object-identity owner for optional in-memory state. Omission requests a fresh
35
- * environment. Consumers must await runtime.release(owner) when the owner ends.
36
- * Stateless providers ignore this field; retained state is never durable.
37
- */
38
- stateOwner?: object
39
- /** Host functions exposed to the program, one global object per namespace. */
40
- bindings: PtcBindingNamespace[]
41
- /** Working directory in the mounted filesystem and subprocess execution world. */
42
- cwd?: string
43
- /**
44
- * Elapsed execution budget in milliseconds. Omission uses provider defaults;
45
- * null requests no deadline. Providers validate and cap numeric budgets or reject unsupported choices.
46
- */
47
- timeoutMs?: number | null
48
- /** Resolved authority for this execution. Providers without confinement reject an explicit policy. */
49
- sandboxPolicy?: SandboxExecutionPolicy
50
- /**
51
- * Abort the run: the runtime stops the program (hard, even mid-loop) and
52
- * resolves with a {@link PtcRunFailure} of kind `'abort'`. In-flight
53
- * binding calls are the CALLER's to settle — the runtime only stops asking.
54
- */
55
- signal?: AbortSignal
56
- }
57
- ```
58
-
59
- ```ts type-equiv
60
- /** Fully resolved execution inputs; run never supplies a missing directory or deadline choice. */
61
- interface PtcRunSpec extends PtcRunRequest {
62
- /** Absolute directory in the provider's execution world. */
63
- cwd: string
64
- /** Positive finite elapsed budget in milliseconds after provider capping, or null for no deadline. */
65
- timeoutMs: number | null
66
- }
67
- ```
68
-
69
- ```ts type-equiv
70
- /** File confinement applied to a program, independently of its terminal outcome. */
71
- interface PtcRunSandbox {
72
- /** File-effect mode used for this execution. */
73
- mode: SandboxMode
74
- /** Program failure text matched backend diagnostics; not enforcement proof or an exhaustive denial record. */
75
- denied: boolean
76
- /** Completeness reported by the selected confining backend; absent for full access. */
77
- enforcement?: SandboxEnforcement
78
- }
79
- ```
80
-
81
- Program failures resolve through `PtcRunResult.error`; invalid caller inputs may reject before execution. Sandbox mode, observed denial and enforcement completeness are separate facts, so a successful program does not by itself prove that every requested restriction was enforced:
82
-
83
- ```ts type-equiv
84
- /**
85
- * The outcome of one run. An error is a FIELD on a resolved result, never a
86
- * rejection of `run()` — reporting a failed program is the caller's job, not
87
- * an exception path.
88
- */
89
- interface PtcRunResult {
90
- /** Applied file policy and observed denial, when the provider enforces file policy. */
91
- sandbox?: PtcRunSandbox
92
- /**
93
- * The program's completion value (a return or final REPL/Script expression), when it ran to
94
- * completion and the value crossed the runtime's lossless-JSON boundary.
95
- * Invalid or over-limit completions fail the run instead of substituting a
96
- * rendered string; a failed or value-less run leaves this absent.
97
- */
98
- value?: PtcJsonValue
99
- /**
100
- * Captured text. Each source channel preserves emission order; interleaving
101
- * across independent channels is backend-dependent. Bounded only as part of
102
- * the outer result.
103
- */
104
- logs: string[]
105
- /** Present iff the run failed; see {@link PtcRunFailure} for the taxonomy. */
106
- error?: PtcRunFailure
107
- }
108
- ```
109
-
110
- ```ts type-equiv
111
- /** Source evaluation form, independent of retained program state. */
112
- type PtcProgramFormat = 'function-body' | 'repl' | 'script'
113
- ```
114
-
115
- `programFormat` distinguishes async function bodies, REPL statements, and scripts. REPL and Script programs accept top-level `await`, declarations, and a final expression; top-level `return` is not supported. The Node Script provider lowers top-level await and awaits the completion value; its [declaration limitations](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/ptc-runtime/ptc-runtime-node/README.md#known-limitations-and-deferred-work) apply to transformed programs. `retainsState` reports memory retention independently of source syntax. `stateOwner` is an in-process object identity for optional retained memory; distinct objects remain isolated. Consumers await `release(owner)` when that owner ends; cleanup failures reject that call. Omitted owners are one-shot, and stateless providers ignore ownership. The [persistent Node provider](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/ptc-runtime/ptc-runtime-node/README.md#persistent-repl) defines reset and recovery behavior; no retained object enters the durable Session format.
116
-
117
- ## Bindings: host functions as program globals
118
-
119
- Each `PtcBindingNamespace` becomes a global object of async callables; PTC passes `tools`. Arguments and resolutions must be lossless JSON. Providers enforce their own transport caps; the seam sets no uniform binding-byte limit. An optional error-class descriptor creates program-visible typed rejections without naming a consumer inside the runtime. Binding names are own properties, so `__proto__` cannot traverse a prototype:
120
-
121
- ```ts type-equiv
122
- /**
123
- * Program-visible typed rejection for one binding namespace. The runtime
124
- * injects a real error constructor under `name`; rejected member calls become
125
- * its instances and expose the exact member name through
126
- * `memberNameProperty`. Both strings are runtime data rather than knowledge
127
- * of a particular consumer such as PTC mode.
128
- */
129
- interface PtcBindingErrorClass {
130
- /** Constructor global and resulting `Error.name`; same portable identifier rule as {@link PtcBindingNamespace.global}. */
131
- name: string
132
- /**
133
- * Non-empty own property for the member name. The portable exclusion set is
134
- * `RESERVED_ERROR_MEMBERS` plus dunder-form names (`__x__`, non-empty
135
- * middle), enforced identically by every backend; any other name —
136
- * identifiers or not — is accepted everywhere.
137
- */
138
- memberNameProperty: string
139
- }
140
- ```
141
-
142
- ```ts type-equiv
143
- /**
144
- * A named group of {@link PtcBindingFunction}s the runtime exposes to the
145
- * program as one global object (e.g. `tools`). Function names are arbitrary
146
- * strings — a runtime must treat names like `__proto__` or `constructor` as
147
- * ordinary own properties (null-prototype construction), never as prototype
148
- * collisions.
149
- */
150
- interface PtcBindingNamespace {
151
- /**
152
- * The global identifier the program sees. Must match the LANGUAGE-PORTABLE
153
- * identifier subset `[A-Za-z_][A-Za-z0-9_]*` and no language's reserved
154
- * words, so the same namespace list works against every backend regardless
155
- * of `language` — a JS-only spelling like `$tools` is rejected by design,
156
- * not just by the Python backend. Names that satisfy the identifier rule but
157
- * name a backend-owned slot (`RESERVED_BINDING_GLOBALS`, e.g. `console`,
158
- * `__dsh_main__`) are also refused everywhere; see its declaration for the
159
- * exact set and why each entry is reserved.
160
- */
161
- global: string
162
- /** The callable members, keyed by the exact name the program calls. */
163
- functions: Record<string, PtcBindingFunction>
164
- /** Optional program-visible typed rejection contract for this namespace. */
165
- errorClass?: PtcBindingErrorClass
166
- }
167
- ```
168
-
169
- ```ts type-equiv
170
- /** A lossless JSON value transferable through the dependency-light Service Definition. */
171
- type PtcJsonValue = null | boolean | number | string | PtcJsonValue[] | { [key: string]: PtcJsonValue }
172
- ```
173
-
174
- ```ts type-equiv
175
- /**
176
- * One host-side function exposed to the program as an async callable. The
177
- * runtime bridges calls to it (possibly across a serialization boundary), so
178
- * `args` and the resolution value MUST be lossless JSON. A runtime rejects a
179
- * lossy or non-cloneable value with a descriptive error rather than corrupting
180
- * the run. No seam-level byte cap applies to a binding resolution. A rejection
181
- * of this function surfaces inside the program as a rejection of the
182
- * corresponding call.
183
- */
184
- type PtcBindingFunction = (args: unknown) => Promise<PtcJsonValue>
185
- ```
186
-
187
- ## Captured output and the failure taxonomy
188
-
189
- Logs are plain strings. Each source channel preserves emission order, while interleaving across independent channels is backend-dependent because channel metadata is not part of the seam. The runtime captures the program's console and stream output, and consumers render only the text. Implementations cap the serialized outer log-array plus completion-value or failure-message payload; fixed result-envelope syntax and consumer presentation whitespace are not part of that variable-payload ledger. Overflow is an explicit failure rather than in-band value substitution.
190
-
191
- Failure kinds are **orthogonal outcomes reported independently** (per [defensive-patterns](https://github.com/deepseek-ai/deepseek-harness/blob/master/docs/defensive-patterns/general.md)): a budget expiry is not an exception, an abort is not a timeout, and a substrate death (e.g. OOM) is neither:
192
-
193
- ```ts type-equiv
194
- /**
195
- * Why a run failed. The kinds are orthogonal outcomes reported independently
196
- * (per docs/defensive-patterns/general.md): a budget expiry is not an exception, an
197
- * abort is not a timeout, and a substrate death is neither.
198
- *
199
- * - `'exception'` — the program threw or failed to parse/transform.
200
- * - `'timeout'` — an implementation-owned budget expired; the message says which.
201
- * - `'abort'` — {@link PtcRunRequest.signal} fired.
202
- * - `'worker-exit'` — the execution substrate died without settling (e.g. OOM).
203
- * - `'invalid-output'` — the completion value was not lossless JSON.
204
- * - `'output-limit'` — the serialized outer logs/value/diagnostic exceeded the configured cap.
205
- * - `'protocol'` — the program sent invalid or over-budget control traffic.
206
- * - `'sandbox-unavailable'` — required confinement could not be established.
207
- */
208
- interface PtcRunFailure {
209
- /** The failure class (see the interface doc for each kind's meaning). */
210
- kind: 'exception' | 'timeout' | 'abort' | 'worker-exit' | 'invalid-output' | 'output-limit' | 'protocol' | 'sandbox-unavailable'
211
- /** Human-readable detail, suitable for feeding back to a model to self-correct. */
212
- message: string
213
- }
214
- ```
215
-
216
- ## The service
217
-
218
- `PtcRuntime` is defined in [`src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/ptc-runtime/ptc-runtime/src/index.ts). `resolve(request)` returns complete execution inputs, and `run(spec)` executes them. `executionInstructions` supplies provider-owned usage guidance for consumer presentation. `timeout` reports the configured elapsed-time default and maximum when per-call overrides are supported; `resolve` still validates and caps each request. `language` selects supported program presentation; `isolation` describes the substrate without claiming security. `sandboxMode` advertises file-policy support, with `undefined` for a provider that does not supply confinement. Each implementation keeps program state separate between runs and terminates and awaits active executions during disposal.
219
-
220
- <!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
221
-
222
- <a id="cordis-surface"></a>
223
-
224
- ## Cordis API
225
-
226
- Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnpm run verify-cordis-catalog` in doc-sync; regenerate with `pnpm run gen-cordis-catalog`) — the language sides differ only in locale-specific paired document paths. Signature blocks use a `ts cordis-catalog` fence and keep the original source JSDoc; dispatch modes are defined in the [primer](../cordis-primer.md#dispatch-modes), and the framework-inherited `ctx` API lives in [cordis-api/inherited.md](../cordis-api/inherited.md).
227
-
228
- <a id="ctxptcruntime--ptcruntime-abstract-seam"></a>
229
-
230
- ### `ctx.ptcRuntime` — `PtcRuntime` (abstract seam)
231
-
232
- Registers one `ctx.ptcRuntime` implementation. Program, budget, abort, and substrate failures resolve in PtcRunResult; only Service Definition contract misuse rejects. Implementations bridge structured-cloneable bindings, materialize each declared namespace rejection class, treat programs as hostile peers, isolate distinct state owners, and terminate and await in-flight runs during disposal.
233
-
234
- ```ts cordis-catalog
235
- /**
236
- * Release an owner's retained environment and await its execution resources.
237
- * Stateless providers have no retained resources to release.
238
- * @param owner - The exact object supplied as the request's state owner.
239
- * @returns Completion after all owned execution resources have been released.
240
- * @throws When managed resource cleanup fails.
241
- */
242
- release(owner: object): Promise<void>
243
-
244
- /**
245
- * Resolve supported options and provider defaults before execution.
246
- * @param request - Program, bindings, cancellation and optional execution choices.
247
- * @returns Complete directory, deadline and supported authority for run.
248
- * @throws When an explicit choice is invalid or unsupported by this provider.
249
- */
250
- abstract resolve(request: PtcRunRequest): PtcRunSpec
251
-
252
- /**
253
- * Execute resolved inputs; program outcomes resolve as result fields.
254
- * @param spec - directory, deadline, program, bindings, cancellation and supported policy.
255
- * @returns Captured output and the execution outcome.
256
- */
257
- abstract run(spec: PtcRunSpec): Promise<PtcRunResult>
258
- ```
259
-
260
- Source: [`packages/ptc-runtime/ptc-runtime/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/ptc-runtime/ptc-runtime/src/index.ts)
261
- <!-- END GENERATED cordis-surface -->
1
+ ---
2
+ editSource: "docs/subsystems/ptc-runtime.md"
3
+ rawMarkdownPath: "en/reference/subsystems/ptc-runtime.md"
4
+ outline: [2,3]
5
+ ---
6
+
7
+ # PTC runtime
8
+
9
+ The PTC execution [capability seam](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/architecture/2026-06-13-capability-seams.md) supplies `ctx.ptcRuntime` through [dsh-ptc-runtime](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/ptc-runtime/ptc-runtime). It runs one program against host bindings and reports output, failure and applicable sandbox facts. PTC execution is optional rather than part of [the agent-loop spine](./core.md). The [PTC foundation](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-06-15-ptc.md) owns registry presentation, the [typed-return contract](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-07-20-ptc-typed-tool-returns.md) owns binding values, and the [sandboxed Node decision](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/architecture/2026-09-11-sandboxed-node-ptc-runtime.md) owns the shipped execution provider.
10
+
11
+ Source: [`packages/ptc-runtime/ptc-runtime/src/types.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/ptc-runtime/ptc-runtime/src/types.ts)
12
+
13
+ ## The run: request in, result out
14
+
15
+ `PtcRunRequest` contains the program, bindings, cancellation and optional execution choices. The provider's `resolve` validates supported choices and applies its deployment defaults; `run` receives a `PtcRunSpec` with an explicit directory and deadline choice. An omitted timeout uses provider defaults, a number requests a capped elapsed budget, and `null` requests no elapsed deadline. Providers reject unsupported choices before execution:
16
+
17
+ ```ts type-equiv
18
+ /**
19
+ * Caller inputs for one program. The provider's resolve method validates supported
20
+ * options and supplies directory, deadline, and authority before execution.
21
+ */
22
+ interface PtcRunRequest {
23
+ /**
24
+ * The program source, in the runtime's {@link ../index.ts | language}. It
25
+ * follows the provider's programFormat: an async function body supports
26
+ * top-level `await` and `return`; REPL (`repl`, `scoped-repl`) and Script programs support top-level
27
+ * declarations, `await`, and a final expression, but not top-level `return`.
28
+ * The Script provider lowers top-level await; its executionInstructions and
29
+ * documentation define retained-binding semantics. The completion value
30
+ * becomes {@link PtcRunResult.value}.
31
+ */
32
+ program: string
33
+ /** Discard the completion without JSON validation when true; omission preserves the completion value. */
34
+ discardCompletion?: boolean
35
+ /**
36
+ * Object-identity owner for optional in-memory state. Omission requests a fresh
37
+ * environment. Consumers must await runtime.release(owner) when the owner ends.
38
+ * Stateless providers ignore this field; retained state is never durable.
39
+ */
40
+ stateOwner?: object
41
+ /** Host functions exposed to the program, one global object per namespace. */
42
+ bindings: PtcBindingNamespace[]
43
+ /** Working directory in the mounted filesystem and subprocess execution world. */
44
+ cwd?: string
45
+ /**
46
+ * Elapsed execution budget in milliseconds. Omission uses provider defaults;
47
+ * null requests no deadline. Providers validate and cap numeric budgets or reject unsupported choices.
48
+ */
49
+ timeoutMs?: number | null
50
+ /** Resolved authority for this execution. Providers without confinement reject an explicit policy. */
51
+ sandboxPolicy?: SandboxExecutionPolicy
52
+ /**
53
+ * Abort the run: the runtime stops the program (hard, even mid-loop) and
54
+ * resolves with a {@link PtcRunFailure} of kind `'abort'`. In-flight
55
+ * binding calls are the CALLER's to settle — the runtime only stops asking.
56
+ */
57
+ signal?: AbortSignal
58
+ }
59
+ ```
60
+
61
+ ```ts type-equiv
62
+ /** Fully resolved execution inputs; run never supplies a missing directory or deadline choice. */
63
+ interface PtcRunSpec extends PtcRunRequest {
64
+ /** Absolute directory in the provider's execution world. */
65
+ cwd: string
66
+ /** Positive finite elapsed budget in milliseconds after provider capping, or null for no deadline. */
67
+ timeoutMs: number | null
68
+ }
69
+ ```
70
+
71
+ ```ts type-equiv
72
+ /** File confinement applied to a program, independently of its terminal outcome. */
73
+ interface PtcRunSandbox {
74
+ /** File-effect mode used for this execution. */
75
+ mode: SandboxMode
76
+ /** Program failure text matched backend diagnostics; not enforcement proof or an exhaustive denial record. */
77
+ denied: boolean
78
+ /** Completeness reported by the selected confining backend; absent for full access. */
79
+ enforcement?: SandboxEnforcement
80
+ }
81
+ ```
82
+
83
+ Program failures resolve through `PtcRunResult.error`; invalid caller inputs may reject before execution. Sandbox mode, observed denial and enforcement completeness are separate facts, so a successful program does not by itself prove that every requested restriction was enforced:
84
+
85
+ ```ts type-equiv
86
+ /**
87
+ * The outcome of one run. An error is a FIELD on a resolved result, never a
88
+ * rejection of `run()` — reporting a failed program is the caller's job, not
89
+ * an exception path.
90
+ */
91
+ interface PtcRunResult {
92
+ /** Applied file policy and observed denial, when the provider enforces file policy. */
93
+ sandbox?: PtcRunSandbox
94
+ /**
95
+ * The program's completion value (a return or final REPL/Script expression), when it ran to
96
+ * completion and the value crossed the runtime's lossless-JSON boundary.
97
+ * Invalid or over-limit completions fail the run instead of substituting a
98
+ * rendered string; a failed or value-less run leaves this absent.
99
+ */
100
+ value?: PtcJsonValue
101
+ /**
102
+ * Captured text fragments retain their emitted line breaks. Concatenate adjacent text without separators.
103
+ * Each source channel preserves emission order; interleaving
104
+ * across independent channels is backend-dependent. Bounded only as part of
105
+ * the outer result.
106
+ */
107
+ output: PtcOutput[]
108
+ /** Present iff the run failed; see {@link PtcRunFailure} for the taxonomy. */
109
+ error?: PtcRunFailure
110
+ }
111
+ ```
112
+
113
+ ```ts type-equiv
114
+ /** Source evaluation form, independent of retained program state. */
115
+ type PtcProgramFormat = 'function-body' | 'repl' | 'script' | 'scoped-repl'
116
+ ```
117
+
118
+ `programFormat` distinguishes async function bodies, REPL statements, scoped REPL statements, and scripts. REPL, scoped REPL, and Script programs accept top-level `await`, declarations, and a final expression; top-level `return` is not supported. Retained REPL calls share one scope, while each scoped REPL call starts with copies of the top-level bindings that earlier calls left, so it can declare those names again without changing earlier code. The Node Script provider lowers top-level await and awaits the completion value; its [declaration limitations](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/ptc-runtime/ptc-runtime-node/README.md#known-limitations-and-deferred-work) apply to transformed programs. `retainsState` reports memory retention independently of source syntax. `stateOwner` is an in-process object identity for optional retained memory; distinct objects remain isolated. Consumers await `release(owner)` when that owner ends; cleanup failures reject that call. Omitted owners are one-shot, and stateless providers ignore ownership. The [persistent Node provider](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/ptc-runtime/ptc-runtime-node/README.md#persistent-repl) defines reset and recovery behavior; no retained object enters the durable Session format.
119
+
120
+ ## Bindings: host functions as program globals
121
+
122
+ Each `PtcBindingNamespace` becomes a global object of async callables; PTC passes `tools`. Arguments and resolutions must be lossless JSON. Providers enforce their own transport caps; the seam sets no uniform binding-byte limit. An optional error-class descriptor creates program-visible typed rejections without naming a consumer inside the runtime. Binding names are own properties, so `__proto__` cannot traverse a prototype:
123
+
124
+ ```ts type-equiv
125
+ /**
126
+ * Program-visible typed rejection for one binding namespace. The runtime
127
+ * injects a real error constructor under `name`; rejected member calls become
128
+ * its instances and expose the exact member name through
129
+ * `memberNameProperty`. Both strings are runtime data rather than knowledge
130
+ * of a particular consumer such as PTC mode.
131
+ */
132
+ interface PtcBindingErrorClass {
133
+ /** Constructor global and resulting `Error.name`; same identifier rule as {@link PtcBindingNamespace.global}. */
134
+ name: string
135
+ /**
136
+ * Non-empty own property for the member name, excluding `name`, `message`,
137
+ * and `stack` (`RESERVED_ERROR_MEMBERS`). Other property names are accepted.
138
+ */
139
+ memberNameProperty: string
140
+ }
141
+ ```
142
+
143
+ ```ts type-equiv
144
+ /**
145
+ * A named group of {@link PtcBindingFunction}s the runtime exposes to the
146
+ * program as one global object (e.g. `tools`). Function names are arbitrary
147
+ * strings — a runtime must treat names like `__proto__` or `constructor` as
148
+ * ordinary own properties (null-prototype construction), never as prototype
149
+ * collisions.
150
+ */
151
+ interface PtcBindingNamespace {
152
+ /**
153
+ * The global identifier the program sees. Must match `[A-Za-z_$][A-Za-z0-9_$]*`
154
+ * and exclude ECMAScript keywords and strict-mode names (`RESERVED_BINDING_WORDS`).
155
+ * Runtime output globals (`console`, `inspect`, `Image` in `RESERVED_BINDING_GLOBALS`)
156
+ * are also refused.
157
+ */
158
+ global: string
159
+ /** The callable members, keyed by the exact name the program calls. */
160
+ functions: Record<string, PtcBindingFunction>
161
+ /** Optional program-visible typed rejection contract for this namespace. */
162
+ errorClass?: PtcBindingErrorClass
163
+ }
164
+ ```
165
+
166
+ ```ts type-equiv
167
+ /** A lossless JSON value transferable through the dependency-light Service Definition. */
168
+ type PtcJsonValue = null | boolean | number | string | PtcJsonValue[] | { [key: string]: PtcJsonValue }
169
+ ```
170
+
171
+ ```ts type-equiv
172
+ /**
173
+ * One host-side function exposed to the program as an async callable. The
174
+ * runtime bridges calls to it (possibly across a serialization boundary), so
175
+ * `args` must be lossless JSON; resolutions also support host-issued PtcImage values. A runtime rejects a
176
+ * lossy or non-cloneable value with a descriptive error rather than corrupting
177
+ * the run. No seam-level byte cap applies to a binding resolution. A rejection
178
+ * of this function surfaces inside the program as a rejection of the
179
+ * corresponding call.
180
+ */
181
+ type PtcBindingFunction = (args: unknown) => Promise<PtcJsonValue>
182
+ ```
183
+
184
+ ## Captured output and the failure taxonomy
185
+
186
+ `output` contains text and image entries in emission order: `{ type: 'text', text }` or `{ type: 'image', attachment }`. Text entries retain emitted newline characters; concatenate adjacent text without separators. Each source channel preserves emission order; interleaving across independent channels is backend-dependent. Host bindings return `PtcImage` descriptors containing the attachment reference and a readable execution-world `path`; the program receives an `Image` with that path and the stored pixel dimensions. The Node provider caps serialized text, image descriptors, and completion or diagnostic payloads together; overflow is an explicit failure.
187
+
188
+ ```ts public-api
189
+ /** A stored image readable from the program's execution environment. */
190
+ declare class PtcImage {
191
+ readonly [key: string]: PtcJsonValue;
192
+ /** Absolute attachment file path readable in the execution world. */
193
+ readonly path: string;
194
+ /** Stored image selected when the program inspects this value. */
195
+ readonly attachment: Readonly<ImageAttachmentRef>;
196
+ /**
197
+ * Describe one immutable image file in the execution world.
198
+ * @param path - Absolute path to the stored image.
199
+ * @param attachment - Reference to the immutable stored image.
200
+ */
201
+ constructor(path: string, attachment: ImageAttachmentRef);
202
+ }
203
+ ```
204
+
205
+ ```ts type-equiv
206
+ /** Raw text fragments and inspected images in emission order; concatenate adjacent text without separators. */
207
+ type PtcOutput = { type: 'text'; text: string } | { type: 'image'; attachment: ImageAttachmentRef }
208
+ ```
209
+
210
+ Failure kinds are **orthogonal outcomes reported independently** (per [defensive-patterns](https://github.com/deepseek-ai/deepseek-harness/blob/master/docs/defensive-patterns/general.md)): a budget expiry is not an exception, an abort is not a timeout, and a substrate death (e.g. OOM) is neither:
211
+
212
+ ```ts type-equiv
213
+ /**
214
+ * Why a run failed. The kinds are orthogonal outcomes reported independently
215
+ * (per docs/defensive-patterns/general.md): a budget expiry is not an exception, an
216
+ * abort is not a timeout, and a substrate death is neither.
217
+ *
218
+ * - `'exception'` — the program threw or failed to parse/transform.
219
+ * - `'timeout'` — an implementation-owned budget expired; the message says which.
220
+ * - `'abort'` — {@link PtcRunRequest.signal} fired.
221
+ * - `'worker-exit'` — the execution substrate died without settling (e.g. OOM).
222
+ * - `'invalid-output'` — the completion value was not lossless JSON.
223
+ * - `'output-limit'` — the serialized outer logs/value/diagnostic exceeded the configured cap.
224
+ * - `'protocol'` — the program sent invalid or over-budget control traffic.
225
+ * - `'sandbox-unavailable'` — required confinement could not be established.
226
+ */
227
+ interface PtcRunFailure {
228
+ /** The failure class (see the interface doc for each kind's meaning). */
229
+ kind: 'exception' | 'timeout' | 'abort' | 'worker-exit' | 'invalid-output' | 'output-limit' | 'protocol' | 'sandbox-unavailable'
230
+ /** Human-readable detail, suitable for feeding back to a model to self-correct. */
231
+ message: string
232
+ }
233
+ ```
234
+
235
+ ## The service
236
+
237
+ `PtcRuntime` is defined in [`src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/ptc-runtime/ptc-runtime/src/index.ts). `resolve(request)` returns complete execution inputs, and `run(spec)` executes them. `executionInstructions` supplies provider-owned usage guidance for consumer presentation. `timeout` reports the configured elapsed-time default and maximum when per-call overrides are supported; `resolve` still validates and caps each request. `language` identifies the source language so consumers can check their requirements (see the [PTC executor](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/core/tool-executor-ptc/README.md)); `isolation` describes the substrate without claiming security. `sandboxMode` advertises file-policy support, with `undefined` for a provider that does not supply confinement. Each implementation keeps program state separate between runs and terminates and awaits active executions during disposal.
238
+
239
+ <!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
240
+
241
+ <a id="cordis-surface"></a>
242
+
243
+ ## Cordis API
244
+
245
+ Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnpm run verify-cordis-catalog` in doc-sync; regenerate with `pnpm run gen-cordis-catalog`) — the language sides differ only in locale-specific paired document paths. Signature blocks use a `ts cordis-catalog` fence and keep the original source JSDoc; dispatch modes are defined in the [primer](../cordis-primer.md#dispatch-modes), and the framework-inherited `ctx` API lives in [cordis-api/inherited.md](../cordis-api/inherited.md).
246
+
247
+ <a id="ctxptcruntime--ptcruntime-abstract-seam"></a>
248
+
249
+ ### `ctx.ptcRuntime` — `PtcRuntime` (abstract seam)
250
+
251
+ Registers one `ctx.ptcRuntime` implementation. Program, budget, abort, and substrate failures resolve in PtcRunResult; only Service Definition contract misuse rejects, with PtcRuntimeError. Implementations bridge structured-cloneable bindings, materialize each declared namespace rejection class, treat programs as hostile peers, isolate distinct state owners, and terminate and await in-flight runs during disposal.
252
+
253
+ ```ts cordis-catalog
254
+ /**
255
+ * Release an owner's retained environment and await its execution resources.
256
+ * Stateless providers have no retained resources to release.
257
+ * @param owner - The exact object supplied as the request's state owner.
258
+ * @returns Completion after all owned execution resources have been released.
259
+ * @throws When managed resource cleanup fails.
260
+ */
261
+ release(owner: object): Promise<void>
262
+
263
+ /**
264
+ * Register source evaluated once when each execution environment is created.
265
+ * Registration must precede the first run admission; only one initializer may
266
+ * be registered. Current bindings are installed before initialization. Its
267
+ * completion is discarded; logs, timeout, cancellation and output bounds share
268
+ * the first run. Initialization failure discards the environment without
269
+ * executing the user program or rolling back external effects.
270
+ * @param program - Initialization source in the provider's language and format.
271
+ * @returns An idempotent async disposer that stops admission, cancels and drains
272
+ * admitted runs, and releases environments. Failed cleanup blocks execution
273
+ * until the disposer succeeds on retry. The caller owns this disposer.
274
+ * @throws When unsupported, registered twice, registered after admission, or invalid.
275
+ */
276
+ registerEnvironmentInitializer(program: string): () => Promise<void>
277
+
278
+ /**
279
+ * Resolve supported options and provider defaults before execution.
280
+ * @param request - Program, bindings, cancellation and optional execution choices.
281
+ * @returns Complete directory, deadline and supported authority for run.
282
+ * @throws When an explicit choice is invalid or unsupported by this provider; contract misuse throws {@link PtcRuntimeError}.
283
+ */
284
+ abstract resolve(request: PtcRunRequest): PtcRunSpec
285
+
286
+ /**
287
+ * Execute resolved inputs; program outcomes resolve as result fields.
288
+ * @param spec - directory, deadline, program, bindings, cancellation and supported policy.
289
+ * @returns Captured output and the execution outcome.
290
+ */
291
+ abstract run(spec: PtcRunSpec): Promise<PtcRunResult>
292
+ ```
293
+
294
+ Source: [`packages/ptc-runtime/ptc-runtime/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/ptc-runtime/ptc-runtime/src/index.ts)
295
+ <!-- END GENERATED cordis-surface -->