deepclause-sdk 0.6.0 → 0.7.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 (244) hide show
  1. package/README.md +57 -0
  2. package/dist/agent.d.ts +2 -0
  3. package/dist/agent.d.ts.map +1 -1
  4. package/dist/agent.js +5 -0
  5. package/dist/agent.js.map +1 -1
  6. package/dist/cli/agent-inbox.d.ts +25 -0
  7. package/dist/cli/agent-inbox.d.ts.map +1 -0
  8. package/dist/cli/agent-inbox.js +46 -0
  9. package/dist/cli/agent-inbox.js.map +1 -0
  10. package/dist/cli/config.d.ts +28 -28
  11. package/dist/cli/index.d.ts +1 -1
  12. package/dist/cli/index.js +7 -2
  13. package/dist/cli/index.js.map +1 -1
  14. package/dist/cli/repl.d.ts +7 -0
  15. package/dist/cli/repl.d.ts.map +1 -1
  16. package/dist/cli/repl.js +181 -13
  17. package/dist/cli/repl.js.map +1 -1
  18. package/dist/cli/run.d.ts +1 -0
  19. package/dist/cli/run.d.ts.map +1 -1
  20. package/dist/cli/run.js +3 -1
  21. package/dist/cli/run.js.map +1 -1
  22. package/dist/cli/serve.d.ts +3 -0
  23. package/dist/cli/serve.d.ts.map +1 -0
  24. package/dist/cli/serve.js +131 -0
  25. package/dist/cli/serve.js.map +1 -0
  26. package/dist/index.d.ts +1 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/judge/llm.d.ts.map +1 -1
  30. package/dist/judge/llm.js +9 -4
  31. package/dist/judge/llm.js.map +1 -1
  32. package/dist/judge/types.d.ts +10 -0
  33. package/dist/judge/types.d.ts.map +1 -1
  34. package/dist/judge/types.js.map +1 -1
  35. package/dist/prolog-src/deepclause_mi.pl +370 -54
  36. package/dist/repl/agent-inbox.d.ts +73 -0
  37. package/dist/repl/agent-inbox.d.ts.map +1 -0
  38. package/dist/repl/agent-inbox.js +168 -0
  39. package/dist/repl/agent-inbox.js.map +1 -0
  40. package/dist/repl/agent.d.ts +14 -1
  41. package/dist/repl/agent.d.ts.map +1 -1
  42. package/dist/repl/agent.js +25 -6
  43. package/dist/repl/agent.js.map +1 -1
  44. package/dist/repl/backend.d.ts +6 -0
  45. package/dist/repl/backend.d.ts.map +1 -1
  46. package/dist/repl/backend.js +17 -2
  47. package/dist/repl/backend.js.map +1 -1
  48. package/dist/repl/event-history.d.ts.map +1 -1
  49. package/dist/repl/event-history.js +3 -0
  50. package/dist/repl/event-history.js.map +1 -1
  51. package/dist/repl/harness-tools.d.ts +9 -2
  52. package/dist/repl/harness-tools.d.ts.map +1 -1
  53. package/dist/repl/harness-tools.js +38 -14
  54. package/dist/repl/harness-tools.js.map +1 -1
  55. package/dist/repl/history.d.ts +14 -3
  56. package/dist/repl/history.d.ts.map +1 -1
  57. package/dist/repl/history.js +62 -5
  58. package/dist/repl/history.js.map +1 -1
  59. package/dist/repl/index.d.ts +11 -0
  60. package/dist/repl/index.d.ts.map +1 -1
  61. package/dist/repl/index.js +6 -2
  62. package/dist/repl/index.js.map +1 -1
  63. package/dist/repl/process-backend.d.ts +1 -0
  64. package/dist/repl/process-backend.d.ts.map +1 -1
  65. package/dist/repl/process-executor.d.ts +4 -0
  66. package/dist/repl/process-executor.d.ts.map +1 -1
  67. package/dist/repl/process-executor.js +36 -1
  68. package/dist/repl/process-executor.js.map +1 -1
  69. package/dist/repl/process-worker.d.ts.map +1 -1
  70. package/dist/repl/process-worker.js +33 -8
  71. package/dist/repl/process-worker.js.map +1 -1
  72. package/dist/repl/processes.d.ts +14 -1
  73. package/dist/repl/processes.d.ts.map +1 -1
  74. package/dist/repl/processes.js +8 -2
  75. package/dist/repl/processes.js.map +1 -1
  76. package/dist/repl/reference.d.ts.map +1 -1
  77. package/dist/repl/reference.js +4 -3
  78. package/dist/repl/reference.js.map +1 -1
  79. package/dist/repl/render.d.ts.map +1 -1
  80. package/dist/repl/render.js +13 -0
  81. package/dist/repl/render.js.map +1 -1
  82. package/dist/repl/session.d.ts +72 -5
  83. package/dist/repl/session.d.ts.map +1 -1
  84. package/dist/repl/session.js +595 -42
  85. package/dist/repl/session.js.map +1 -1
  86. package/dist/repl/toolset.d.ts +8 -0
  87. package/dist/repl/toolset.d.ts.map +1 -1
  88. package/dist/repl/toolset.js +53 -4
  89. package/dist/repl/toolset.js.map +1 -1
  90. package/dist/repl/tui/renderer.d.ts.map +1 -1
  91. package/dist/repl/tui/renderer.js +3 -1
  92. package/dist/repl/tui/renderer.js.map +1 -1
  93. package/dist/repl/work-hooks.d.ts +29 -0
  94. package/dist/repl/work-hooks.d.ts.map +1 -0
  95. package/dist/repl/work-hooks.js +117 -0
  96. package/dist/repl/work-hooks.js.map +1 -0
  97. package/dist/repl/worker-host.d.ts +2 -0
  98. package/dist/repl/worker-host.d.ts.map +1 -1
  99. package/dist/repl/worker-host.js +48 -4
  100. package/dist/repl/worker-host.js.map +1 -1
  101. package/dist/repl/worker-protocol.d.ts +23 -2
  102. package/dist/repl/worker-protocol.d.ts.map +1 -1
  103. package/dist/repl/worker-protocol.js +1 -1
  104. package/dist/runner.d.ts +2 -2
  105. package/dist/runner.d.ts.map +1 -1
  106. package/dist/runner.js +19 -3
  107. package/dist/runner.js.map +1 -1
  108. package/dist/runtime-identity.json +6 -6
  109. package/dist/serve/agent-broadcast.d.ts +29 -0
  110. package/dist/serve/agent-broadcast.d.ts.map +1 -0
  111. package/dist/serve/agent-broadcast.js +28 -0
  112. package/dist/serve/agent-broadcast.js.map +1 -0
  113. package/dist/serve/agent-preferences.d.ts +16 -0
  114. package/dist/serve/agent-preferences.d.ts.map +1 -0
  115. package/dist/serve/agent-preferences.js +42 -0
  116. package/dist/serve/agent-preferences.js.map +1 -0
  117. package/dist/serve/api-docs.d.ts +61 -0
  118. package/dist/serve/api-docs.d.ts.map +1 -0
  119. package/dist/serve/api-docs.js +122 -0
  120. package/dist/serve/api-docs.js.map +1 -0
  121. package/dist/serve/backend.d.ts +12 -0
  122. package/dist/serve/backend.d.ts.map +1 -0
  123. package/dist/serve/backend.js +52 -0
  124. package/dist/serve/backend.js.map +1 -0
  125. package/dist/serve/capabilities.d.ts +6 -0
  126. package/dist/serve/capabilities.d.ts.map +1 -0
  127. package/dist/serve/capabilities.js +21 -0
  128. package/dist/serve/capabilities.js.map +1 -0
  129. package/dist/serve/example-agent.d.ts +5 -0
  130. package/dist/serve/example-agent.d.ts.map +1 -0
  131. package/dist/serve/example-agent.js +5 -0
  132. package/dist/serve/example-agent.js.map +1 -0
  133. package/dist/serve/files.d.ts +55 -0
  134. package/dist/serve/files.d.ts.map +1 -0
  135. package/dist/serve/files.js +249 -0
  136. package/dist/serve/files.js.map +1 -0
  137. package/dist/serve/harness.d.ts +3 -0
  138. package/dist/serve/harness.d.ts.map +1 -0
  139. package/dist/serve/harness.js +53 -0
  140. package/dist/serve/harness.js.map +1 -0
  141. package/dist/serve/previews.d.ts +40 -0
  142. package/dist/serve/previews.d.ts.map +1 -0
  143. package/dist/serve/previews.js +240 -0
  144. package/dist/serve/previews.js.map +1 -0
  145. package/dist/serve/protocol.d.ts +228 -0
  146. package/dist/serve/protocol.d.ts.map +1 -0
  147. package/dist/serve/protocol.js +2 -0
  148. package/dist/serve/protocol.js.map +1 -0
  149. package/dist/serve/schedules.d.ts +85 -0
  150. package/dist/serve/schedules.d.ts.map +1 -0
  151. package/dist/serve/schedules.js +249 -0
  152. package/dist/serve/schedules.js.map +1 -0
  153. package/dist/serve/server.d.ts +50 -0
  154. package/dist/serve/server.d.ts.map +1 -0
  155. package/dist/serve/server.js +1696 -0
  156. package/dist/serve/server.js.map +1 -0
  157. package/dist/serve/session-worker.d.ts +2 -0
  158. package/dist/serve/session-worker.d.ts.map +1 -0
  159. package/dist/serve/session-worker.js +291 -0
  160. package/dist/serve/session-worker.js.map +1 -0
  161. package/dist/serve/sessions.d.ts +178 -0
  162. package/dist/serve/sessions.d.ts.map +1 -0
  163. package/dist/serve/sessions.js +905 -0
  164. package/dist/serve/sessions.js.map +1 -0
  165. package/dist/serve/storage.d.ts +41 -0
  166. package/dist/serve/storage.d.ts.map +1 -0
  167. package/dist/serve/storage.js +211 -0
  168. package/dist/serve/storage.js.map +1 -0
  169. package/dist/serve/ui/api-docs.html +17 -0
  170. package/dist/serve/ui/api-docs.js +36 -0
  171. package/dist/serve/ui/app.js +958 -0
  172. package/dist/serve/ui/authoring.js +92 -0
  173. package/dist/serve/ui/deepclause-logo.png +0 -0
  174. package/dist/serve/ui/deepclause-mark.svg +1 -0
  175. package/dist/serve/ui/diff.js +16 -0
  176. package/dist/serve/ui/dompurify-LICENSE.txt +202 -0
  177. package/dist/serve/ui/features.css +15 -0
  178. package/dist/serve/ui/files.js +13 -0
  179. package/dist/serve/ui/ibm-plex-mono-latin.woff2 +0 -0
  180. package/dist/serve/ui/ibmplexmono-OFL.txt +93 -0
  181. package/dist/serve/ui/icons.js +30 -0
  182. package/dist/serve/ui/index.html +68 -0
  183. package/dist/serve/ui/manrope-OFL.txt +93 -0
  184. package/dist/serve/ui/manrope-latin.woff2 +0 -0
  185. package/dist/serve/ui/markdown.js +38 -0
  186. package/dist/serve/ui/marked-LICENSE.txt +44 -0
  187. package/dist/serve/ui/marked.js +88 -0
  188. package/dist/serve/ui/purify.js +2454 -0
  189. package/dist/serve/ui/style.css +249 -0
  190. package/dist/serve/ui/web-work.css +247 -0
  191. package/dist/serve/ui/web.css +1848 -0
  192. package/dist/serve/workflow-bundles.d.ts +8 -0
  193. package/dist/serve/workflow-bundles.d.ts.map +1 -0
  194. package/dist/serve/workflow-bundles.js +78 -0
  195. package/dist/serve/workflow-bundles.js.map +1 -0
  196. package/dist/serve/workflow-calls.d.ts +6 -0
  197. package/dist/serve/workflow-calls.d.ts.map +1 -0
  198. package/dist/serve/workflow-calls.js +13 -0
  199. package/dist/serve/workflow-calls.js.map +1 -0
  200. package/dist/serve/workflows.d.ts +93 -0
  201. package/dist/serve/workflows.d.ts.map +1 -0
  202. package/dist/serve/workflows.js +219 -0
  203. package/dist/serve/workflows.js.map +1 -0
  204. package/dist/system/assets/docs/AGENT_PROMPT.md +6 -6
  205. package/dist/system/assets/docs/DML_AUTHORING.md +80 -2
  206. package/dist/system/assets/docs/DML_PROCESSES.md +24 -0
  207. package/dist/system/assets/docs/DML_REFERENCE.md +98 -10
  208. package/dist/system/assets/docs/DML_SHELL.md +149 -7
  209. package/dist/system/assets/docs/DML_TASKS.md +10 -3
  210. package/dist/system/assets/docs/LOCAL_AGENT_PROMPT.md +6 -6
  211. package/dist/system/environment.d.ts +5 -1
  212. package/dist/system/environment.d.ts.map +1 -1
  213. package/dist/system/environment.js +14 -8
  214. package/dist/system/environment.js.map +1 -1
  215. package/dist/system/runtime/agentvm-manager.d.ts +12 -1
  216. package/dist/system/runtime/agentvm-manager.d.ts.map +1 -1
  217. package/dist/system/runtime/agentvm-manager.js +136 -20
  218. package/dist/system/runtime/agentvm-manager.js.map +1 -1
  219. package/dist/system/runtime/shell-manager.d.ts +3 -0
  220. package/dist/system/runtime/shell-manager.d.ts.map +1 -1
  221. package/dist/system/runtime/shell-manager.js +1 -1
  222. package/dist/system/runtime/shell-manager.js.map +1 -1
  223. package/dist/system/timezone.d.ts +20 -0
  224. package/dist/system/timezone.d.ts.map +1 -0
  225. package/dist/system/timezone.js +37 -0
  226. package/dist/system/timezone.js.map +1 -0
  227. package/dist/types.d.ts +37 -1
  228. package/dist/types.d.ts.map +1 -1
  229. package/dist/work/index.d.ts +13 -3
  230. package/dist/work/index.d.ts.map +1 -1
  231. package/dist/work/index.js +80 -15
  232. package/dist/work/index.js.map +1 -1
  233. package/docs/DEEP_RESEARCH_EXAMPLE.md +127 -0
  234. package/docs/SERVE.md +664 -0
  235. package/docs/WORK_AGENT_HOOKS_PLAN.md +416 -0
  236. package/docs/WORK_AGENT_INBOX.md +140 -0
  237. package/docs/WORK_AGENT_INBOX_PLAN.md +91 -0
  238. package/docs/WORK_MODE.md +269 -0
  239. package/package.json +24 -2
  240. package/sdk-examples/deep-research.dml +144 -0
  241. package/sdk-examples/deep-research.py +502 -0
  242. package/sdk-examples/hooked-agent.dml +49 -0
  243. package/sdk-examples/subagent-inbox.dml +66 -0
  244. package/src/prolog-src/deepclause_mi.pl +370 -54
@@ -12,6 +12,11 @@ Facts and rules use Prolog syntax and end with periods. Predicates are identifie
12
12
  by name/arity (ALL inputs and outputs). `agent_main/N` is an OPTIONAL positional
13
13
  run entry point; all its arguments are inputs. Libraries and explicit workflow
14
14
  or goal calls can name any predicate. Normal Work conversation uses shell/1.
15
+ An agent shell may opt into `inbox: _{sources:[process]}` (Work contract 3).
16
+ Capture agent_self/1 in the owning foreground, pass the reference to children,
17
+ and agent_post/3 their data results to schedule another on_message turn without a
18
+ human/browser. See shell/processes topics for provenance, consume, limits and
19
+ restore semantics. No custom input loop or automatic process recovery is implied.
15
20
  `doc(Name/Arity, Text)` describes modes and an example; `module_doc(Text)` describes
16
21
  purpose; `schema/2` defines model data shapes; `script_file/2` links bundled files.
17
22
  Use distinct script link/predicate names, e.g. extract_py versus extract/2.
@@ -66,15 +71,22 @@ text/vision and fails if no image backend is configured.
66
71
  `push_context(clear)` also starts empty. Use with_fresh_memory for normal scopes.
67
72
  A nested task in a tool starts fresh; explicit arguments carry context. Processes
68
73
  have independent memory. A fresh prompt does not see attached images.
74
+ Opt-in Work `on_start`/`on_message` hooks bridge their successful DML memory edits
75
+ into the agent's effective messages. Hooks use `Hook(Context,StateIn,StateOut,Decision)`;
76
+ message decisions are continue, reply(Text), or reject(Reason). Return normally,
77
+ not through answer/suspend. See `shell` for state, provenance and lifecycle rules.
69
78
 
70
79
  `with_tools([Name,...], Goal)` limits nested task tools; `without_tools` excludes
71
- names. `with_model(Spec, Goal)` uses a different available model for scoped calls;
72
- string specs use provider:model and optional #reasoning, or a model dict.
73
- `with_reasoning(Goal, Level)` (GOAL FIRST) scopes supported reasoning effort.
74
- `with_recipe(Goal, Query)` adds transient recipe context when the embedding has
75
- configured a recipe library; it is not persistent memory. These scopes do not
76
- change judgment backend; see judgments section for with_judgment/require_judgment.
77
- Never invent a model id or infer credentials. Use current models/catalog.
80
+ names. `with_model(Spec, Goal)` uses a different available model for scoped
81
+ task/prompt/llm calls, sample_token/2-3, and LLM-backed judgments; string specs
82
+ use provider:model and optional #reasoning, or a model dict. It does not switch
83
+ the judgment backend: fixed-model backends (Jev, mock, custom services) keep
84
+ their own model. `with_reasoning(Goal, Level)` (GOAL FIRST) scopes supported
85
+ reasoning effort. `with_recipe(Goal, Query)` adds transient recipe context when
86
+ the embedding has configured a recipe library; it is not persistent memory. Use
87
+ `with_judgment`/`require_judgment` to choose the judgment backend or require a
88
+ capability. Never invent a model id or infer credentials. Use current
89
+ models/catalog.
78
90
 
79
91
  ## Sampling
80
92
 
@@ -85,11 +97,55 @@ use that fallback as evidence that an external condition was verified.
85
97
  This is for a grammar/label frontier, not a replacement for typed task outputs.
86
98
  `with_model` applies to it. For a semantic bounded choice prefer choose/4.
87
99
 
100
+ ## Clock and date
101
+
102
+ `get_time(Stamp)` reads runtime epoch seconds without a host tool, and needs no
103
+ network or model. For UTC today: `stamp_date_time(Stamp,DT,'UTC'),
104
+ format_time(string(Date),"%Y-%m-%d",DT)`.
105
+
106
+ The engine is WebAssembly without tzdata, so `stamp_date_time/3` accepts only
107
+ `'UTC'` or an explicit integer offset in seconds — an IANA zone name there is a
108
+ domain error. Use the zone predicates instead; they resolve DST at that instant
109
+ through the host's time-zone database and then call `stamp_date_time/3`:
110
+
111
+ ```prolog
112
+ today_in(Zone, Date) :-
113
+ get_time(Stamp),
114
+ zone_date_time(Stamp, Zone, DT),
115
+ format_time(string(Date), "%Y-%m-%d", DT).
116
+
117
+ market_date_ny(Date) :- today_in('America/New_York', Date).
118
+ today_local(Date) :- get_time(Stamp), local_date_time(Stamp, DT),
119
+ format_time(string(Date), "%Y-%m-%d", DT).
120
+ ```
121
+
122
+ `zone_offset(Zone, Stamp, OffsetSeconds)` returns the offset east of UTC
123
+ (`28800` for UTC+8) when you need the number itself. Pass it to
124
+ `stamp_date_time/3` as `-OffsetSeconds`: that builtin's integer zone counts
125
+ seconds *west* of UTC, the opposite sign. `zone_date_time/3` already does this. `'Local'` means the server's own zone and can change with DST, so
126
+ name an explicit market zone for dated market reports. Use get_time first; Date is
127
+ an ISO date string. A market-local date and last trading
128
+ session require an explicit timezone/calendar policy. See authoring for a recipe.
129
+
130
+ ## Workflow calls
131
+
132
+ Same-module predicates are ordinary Prolog calls. With the serve host capability,
133
+ `run_workflow(Name, InputsDict, Result)` invokes an existing named workflow using
134
+ the root turn's pinned catalog. Inspect reference topic workflows first. Check
135
+ Result.ok/status/error and consume Result.outputs by exact named key. Typed inputs,
136
+ cancellation, depth/call limits and normal runtime permissions apply. Authors may
137
+ inspect the catalog and execute real workflows from draft tests under the same
138
+ configured host policy; external effects are not rolled back.
139
+ No implicit host grant exists in other SDK embeddings. See shell for a full recipe.
140
+
88
141
  ## Host calls and scripts
89
142
 
90
143
  `exec(Tool(key: Value,...), Result)` invokes a CURRENT registered host capability.
91
144
  Do not copy an arbitrary tool name from another embedding. Read topic tools for
92
- actual schemas; topic python is the browser Python contract.
145
+ actual schemas and draft/published scope restrictions; topic python is the browser
146
+ Python contract, not a promise that Python is registered here. Tool-free prompts
147
+ cannot search. Fresh retrieval needs actual permitted tools/network and cited,
148
+ dated evidence; never silently substitute model knowledge or offline fixtures.
93
149
 
94
150
  `run_script(Name, Args, Value)` resolves script_file(Name, Path), stringifies atomic
95
151
  arguments, checks exitCode and parses JSON stdout (else returns stdout).
@@ -128,7 +184,38 @@ and terminates execution via the answer commit; it does NOT commit code edits.
128
184
  Workflow/helper/tool outputs must be bound arguments and normal return, not answer.
129
185
 
130
186
  `output(media(Path))`, `output(media{svg: Svg})` display images; `save_image/2`
131
- saves a reference. Browser `output(html(Path))` renders a workspace miniapp.
187
+ saves a reference. Browser `output(html(Path))` renders a workspace miniapp in
188
+ hosts that support it (serve does not execute HTML on the Work origin).
189
+ `output(file("reports/result.csv"))` emits a downloadable workspace-file reference;
190
+ serve validates it and displays a file-icon ribbon. A serve Work Agent can use
191
+ `download_file`, or a relative Markdown link, for the same presentation. Private
192
+ runtime/auth files, traversal and symlinks are rejected; downloads require auth.
193
+
194
+ In serve Work turns and workflows,
195
+ `agent_send(existing(AgentIdOrUniqueName), message{text:Text}, Receipt)` sends to
196
+ an explicitly addressed Work Agent. Enable **Allow incoming messages** separately
197
+ on each receiving Agent (`allowMessages:true` in the host API). Multiple Agents
198
+ may opt in; there is no workspace default and no run-specific recipient grant.
199
+ Names must be exact and unique; IDs survive renames. Disabled, deleted, Develop,
200
+ and closed/saved Agents reject delivery (reopen saved Agents explicitly).
201
+ The host rechecks permission on every send. DML cannot enable receivers.
202
+ `recipient` is only a legacy explicitly supplied run address alias, not a default
203
+ or permission grant. `new(_{title:"Review"})` still requires explicit creation
204
+ permission and creates one receive-enabled result Agent per run.
205
+ Receipt fields `status`, `agent`, `message` acknowledge durable queue acceptance,
206
+ not an Agent reply. Messages have workflow provenance, do not grant authority,
207
+ and never trigger Develop authoring. Tests record previews without sending.
208
+ `agent_recipients(Agents)` lists minimal live opted-in Work Agent IDs/names/status;
209
+ busy Agents may queue messages. It excludes authors, runs and closed/disabled
210
+ recipients and does not grant authority or reopen them. `agent_broadcast(message{text:Text},Report)`
211
+ snapshots those recipients, excludes a sending Agent itself, and independently
212
+ rechecks each acceptance with concurrency two. `Report` has `accepted`, `failed`,
213
+ `skipped` counts and `results`; individual failures do not abort other recipients.
214
+ The existing 16-attempt operation budget applies; cancellation skips unsent work,
215
+ not accepted messages. No automatic retries or reply wait. Empty audiences succeed
216
+ with zero counts. Draft tests use the same live discovery and real delivery with
217
+ normal receive permissions and operation limits; they are not message previews.
218
+ These optional host capabilities do not change `agent_post/3` process references.
132
219
  Read media for distinctions between display, vision and generation.
133
220
 
134
221
  ## Data and schemas
@@ -241,7 +328,8 @@ Choose returns a supplied atom; verify is yes/no/unknown. Supply real evidence;
241
328
  judgments do not see task memory/images and are not a guarantee of external state.
242
329
  `with_judgment(Backend, Goal)` selects a configured backend;
243
330
  `require_judgment(Capability, Goal)` requires calibrated/probability/etc support.
244
- `with_model` does not select the judgment backend. Inspect actual registration.
331
+ `with_model` scopes the model used by an LLM-backed judge (`llm`) but does not
332
+ select the backend; Jev, mock, and custom fixed-model backends keep their model.
245
333
 
246
334
  ## Constraint search
247
335
 
@@ -56,6 +56,55 @@ use a JSON string or a file instead. General task/schema outputs still support
56
56
  complex values. Runtime tool schemas are authoritative, not a wish list.
57
57
  Old `args` is legacy input data only; author new shells with `inputs`/`outputs`.
58
58
 
59
+ Fields preserve `description` in forms and tool schemas. Inputs are required by
60
+ default. A typed `default` makes an input optional; `required:false` requires a
61
+ default, and `required:true` cannot also have one. For example:
62
+ `_{name:"Date",type:string,description:"Empty means today's UTC date",default:""}`.
63
+ Omitted/undefined inputs use their defaults; explicit empty strings remain empty
64
+ strings for DML to interpret. Null is invalid; false and zero are real values.
65
+ Clearing an optional numeric form field omits it; numeric/boolean defaults must
66
+ have those types, not quoted strings. Outputs may describe their meaning but must
67
+ always bind and cannot declare defaults/required. Every declared input still
68
+ occupies one positional predicate argument, including an omitted defaulted input.
69
+
70
+ ## Workflow composition
71
+
72
+ Same-module predicates compose normally. In `serve`, when the host registers the
73
+ run_workflow capability, a workflow can invoke another existing bundled/published
74
+ workflow without copying source:
75
+
76
+ ```prolog
77
+ reuse(Text, Report) :-
78
+ run_workflow("Text statistics", _{'Text':Text}, R),
79
+ ( get_dict(ok,R,true) ->
80
+ get_dict(outputs,R,Outputs), get_dict('Report',Outputs,Report)
81
+ ; throw(error(workflow_failed(R),reuse/2))
82
+ ).
83
+ ```
84
+
85
+ Use the EXACT supplied name and input/output keys from reference topic workflows;
86
+ this example's name/fields are placeholders, not a guaranteed installed workflow.
87
+ The result contains ok/status/outputs/output/elapsedMs and error on failure.
88
+ A missing/deleted workflow or invalid typed inputs fails honestly. Calls run in
89
+ separate ordinary workflow execution sessions; use returned data explicitly, not
90
+ shared memory or another workflow's private predicates. Child runtimes close on
91
+ return and stop their background processes: compose completed results, not detached
92
+ job handles or durable suspended stacks. Pending inputs are on the child run;
93
+ suspended is not success. Work assistant calls to its own bundled workflows retain
94
+ the original owning foreground and process/coordinator semantics. Capabilities remain those
95
+ of the approved server runtime; no new network, credentials or message grants.
96
+
97
+ The root turn captures the catalog's revisions and passes that same catalog down
98
+ all nested calls. Publishing during a call cannot silently switch a downstream
99
+ revision. Deletion still prevents new calls. Cycles are refused; maximum chain
100
+ length is 4 workflows and budget is 16 attempted child calls per root operation,
101
+ with the normal live-session limit and timeouts still applying. Cancellation
102
+ propagates to active children; there is no retry/replay. Draft authors can discover
103
+ contracts and test real workflow calls with the same host policy. These calls have
104
+ real effects; fixtures alone are not live integration verification. Outside serve this predicate requires an explicitly registered
105
+ run_workflow host capability. The Work MODEL's run_workflow tool is distinct from
106
+ DML's three-argument predicate.
107
+
59
108
  ## Workflows versus tools
60
109
 
61
110
  A workflow is a recurring user task with a prescribed result, e.g. intake,
@@ -67,19 +116,34 @@ Do not export internal helpers, docs, schemas or all predicates indiscriminately
67
116
  `shell.tools` is NOT `tool/2`: the latter exposes a predicate to a nested agent
68
117
  inside `task/N`, with a single last output and input types in its annotation.
69
118
  A predicate may participate in both interfaces if needed, with one implementation.
70
- Host tools are a third surface (`exec/2`); `host_tools: [show_image]` allows the
71
- Work image-display helper, not arbitrary DML/host execution.
119
+ Host capabilities are also accessible to DML through `exec/2`.
120
+ `host_tools: [show_image]` enables the Work image-display helper. To request the
121
+ host's bash tool directly for the Work assistant, use `host_tools: [bash]` (or
122
+ `[bash, show_image]`). Bash is supplied only when registered and allowed by the
123
+ host; its policy/approval wrapper and cancellation still apply. This does not
124
+ expose `execute`, authoring tools, or other registry entries. Bash is powerful:
125
+ use it only with trusted harnesses/users. `deepclause serve` registers bash by
126
+ default; `--no-tools` disables it. DML `exec(bash(...), R)` needs a registered
127
+ bash capability, but does not require declaring bash to the assistant.
72
128
 
73
129
  ## Workflow-only shell
74
130
 
75
131
  ```prolog
132
+ workflow(_{name:"Uppercase",goal:"uppercase",
133
+ inputs:[_{name:"Text",type:string}],
134
+ outputs:[_{name:"Upper",type:string}]}).
76
135
  uppercase(Text, Upper) :- string_upper(Text, Upper).
77
- shell(_{kind: workflow, system: "", host_tools: [], tools: [],
78
- workflows: [_{name: "Uppercase", goal: "uppercase",
79
- inputs: [_{name: "Text", type: string}],
80
- outputs: [_{name: "Upper", type: string}]}], welcome: "Choose a task."}).
81
136
  ```
82
137
 
138
+ Exactly one literal `workflow/1` declaration derives a workflow-only runtime shell
139
+ when no explicit `shell/1` exists. General SDK hosts may still use an explicit
140
+ workflow shell; isolated serve authors instead expose only the declaration,
141
+ implementation/private helpers and supporting assets. They cannot redefine the
142
+ Agent shell, `agent_main`, `bp_*`/`dc_*`, qualified heads or expansion hooks, execute
143
+ arbitrary directives, or replace host-pinned `use_harness` dependencies. A bundled
144
+ source needs reviewed per-workflow ownership provenance; old flattened harnesses
145
+ are not copied into editors. See `docs/SERVE_WORKFLOWS.md` for migration.
146
+
83
147
  There is no assistant loop. A manual start executes exactly the selected workflow
84
148
  with validated inputs and no intervening assistant call, for BOTH shell kinds.
85
149
  Outputs are named typed values; no solution/unbound output/cancel/suspend is not
@@ -89,12 +153,90 @@ Interactive workflows must run through foreground form/input handlers. Browser
89
153
  scratch `execute` workers and worker-hosted processes do not support forms.
90
154
  Test pure validation/headless paths separately from actual foreground form submits.
91
155
 
156
+ ## Agent hooks (Work contract 2)
157
+
158
+ For per-message routing or explicit application state, keep `kind: agent` and add
159
+ hooks. All hooks have signature `Hook(Context, StateIn, StateOut, Decision)`:
160
+
161
+ ```prolog
162
+ initialize(_, _, state{turns: 0}, continue) :-
163
+ system("Be concise and factual.").
164
+ handle_message(Context, State0, state{turns: N}, Decision) :-
165
+ get_dict(turns, State0, Previous), N is Previous + 1,
166
+ get_dict(message, Context, Text),
167
+ ( Text == "ping" -> Decision = reply("pong")
168
+ ; user("Harness context: turn number {N}."), Decision = continue
169
+ ).
170
+ shell(_{kind: agent, system: "Helpful assistant", host_tools: [], tools: [],
171
+ workflows: [], welcome: "Ask a question, or say ping.",
172
+ hooks: _{on_start: "initialize", on_message: "handle_message"}}).
173
+ ```
174
+
175
+ `on_start` runs once, lazily before the first user message, starting from `state{}`.
176
+ It must return `continue`. `on_message` returns `continue` (default assistant),
177
+ `reply(Text)` (publish directly, no outer assistant call), or `reject(Reason)`.
178
+ Context contains version 1, event, session_id, turn, and message (message hook only).
179
+ State must be bounded ground data: tagged dicts/lists/atoms/strings/finite numbers,
180
+ with safe integers, maximum depth 32 and maximum serialized size 64 KiB.
181
+
182
+ The original user message is already in effective memory. `system/1`, `user/1`,
183
+ and memory-bearing tasks update that context for the next outer model call.
184
+ They do not fabricate visible human turns. `get_memory/1` reads the current hook
185
+ view; provider/tool groups appear as opaque text projections, not writable native
186
+ blobs. `clear_memory` rebuilds editable context, never host policy. Isolated
187
+ prompts and fresh-memory scopes do not leak scratch changes.
188
+
189
+ Hook failure/cancellation discards staged memory/state, with no assistant fallback.
190
+ Rejection commits state but discards staged messages. Hooks execute once, use the
191
+ same policy and shared model budget, and have a 30-second wall-clock bound. Side
192
+ effects cannot be rolled back. Return the decision normally: do not use answer,
193
+ suspend, or an input loop. Internal streams/output are technical activity, not the
194
+ final reply. Initialization/state/context persist on restore; interrupted/failed
195
+ initialization is not replayed. Steering is not yet supported with hooks.
196
+
197
+ Manual workflows still execute directly, and `run_workflow` remains available to
198
+ the normal assistant. Develop, worker-internal work and title/compaction calls do
199
+ not invoke owner hooks; an explicit agent_post delivery does. Only `on_start` and `on_message` are implemented; other keys fail
200
+ validation. No agent_main entry is required.
201
+
202
+ ## Work-agent inbox (Work contract 3)
203
+
204
+ Opt in with `inbox: _{sources:[process]}` on an agent shell. Optional max_pending
205
+ (1..32) and max_auto_turns (1..10) lower the host caps. The owning foreground calls
206
+ `agent_self(Agent)` and explicitly passes that reference into a child goal.
207
+ `agent_post(Agent, message{text:Text, data:payload{...}}, MessageId)` queues a new
208
+ agent input; data/key are optional. Acceptance waits for the durable queue write,
209
+ not for an answer. References are not pids or persistable state; a child cannot
210
+ acquire the parent's reference implicitly. Stale/cross-session references fail.
211
+
212
+ The existing on_message context has source=user or source=process (atoms). Process
213
+ inputs also include message_id, authenticated sender pid/name, and data. Continue,
214
+ reply and reject keep their meanings. Process-only consume commits state/memory
215
+ without an outer model call or assistant reply. Human consume is invalid. The
216
+ input stays visibly labelled as background data, not a human submission or policy.
217
+ No hooks are required: absent on_message, the normal assistant handles the input.
218
+
219
+ FIFO deliveries wait until the active operation ends; they do not interrupt or
220
+ recursively invoke hooks. Defaults: 32 queued/running, 16 KiB each, 32 posts/minute,
221
+ 10 autonomous turns between human messages/resumes, and at most 10 model calls
222
+ per background turn. Limits/failure pause delivery; no silent retries. Posting
223
+ errors are explicit. Optional key strings deduplicate recent identical posts by
224
+ sender pid. Host policy can disable/tighten the inbox without granting tools.
225
+
226
+ With serve, background execution/replies continue without a browser. Pure-browser
227
+ execution cannot continue after page closure. Restore holds pending inputs and
228
+ marks running inputs interrupted; it never restarts processes or replays effects.
229
+ User messages or explicit resume release held data. Input/approval waits for a
230
+ human. Closing a tab is not closing a session. Consult the shipped
231
+ sdk-examples/subagent-inbox.dml for a complete generic launch/result pattern.
232
+
92
233
  ## Custom conversation
93
234
 
94
235
  A custom DML `input/1` + `chat/1` loop is for a required protocol or per-turn
95
236
  state, e.g. staged intake that validates each stage before advancing. Merely
96
237
  asking for a conversational agent or changing its persona does not require it.
97
- Use `next/1` only if the conversation must also react to process messages.
238
+ For a turn-based Work agent, use the inbox above for process results, not next/1.
239
+ Use `next/1` only for an intentionally custom foreground conversation protocol.
98
240
  Such loops must run in foreground with an input host, not inside scratch execute.
99
241
  See `examples` section `custom-intake` for a minimal custom staged protocol.
100
242
 
@@ -60,6 +60,12 @@ be an input or supplied with `system/1` inside that body. A process has its own
60
60
  memory snapshot. Attached media is harness memory, so a fresh `prompt/N` will
61
61
  not see an image attached for a task.
62
62
 
63
+ Opt-in Work agent hooks are an explicit bridge between these stores: a hook's
64
+ `system/1`, `user/1`, and memory-bearing task changes become effective Work model
65
+ context on successful return. `prompt/N` and fresh-memory isolation still apply.
66
+ This does not change ordinary workflow/authoring memory semantics. See `shell` for
67
+ `on_start`/`on_message`, explicit state, decisions, limits, and restore behavior.
68
+
63
69
  ## Nested tools
64
70
 
65
71
  Host registration is NOT nested-agent exposure. `exec(python(...), R)` calls a
@@ -107,6 +113,7 @@ returns a number; `holds/2` succeeds for yes. `judge(State, Specs)` batches
107
113
  questions such as `choose(Question, Options)-Choice` in one request.
108
114
  Judgments do not see task memory or images. Supply observed evidence as State;
109
115
  `unknown` is not no, and neither is a failed goal.
110
- `with_model(Spec, Goal)` changes task/prompt/llm model selection, not judgment
111
- backend selection; use only model ids available in this session. Read the exact
112
- scopes and backend capabilities in the language reference before relying on them.
116
+ `with_model(Spec, Goal)` changes task/prompt/llm and LLM-judge model selection,
117
+ not judgment backend selection; fixed-model judges such as Jev keep their own
118
+ model. Use only model ids available in this session. Read the exact scopes and
119
+ backend capabilities in the language reference before relying on them.
@@ -9,12 +9,12 @@ features. Never invent a tool, supported parameter or successful result.
9
9
 
10
10
  ## Work in small verified steps
11
11
 
12
- Start small: inspect `listing`, settle ambiguity, open `begin_turn`, `define`/
13
- `delete`, test a bounded `execute`, read `end_turn` changed/warnings, then report
14
- observed evidence. Reopen a transaction before further edits; rollback a bad one.
15
- Add intermediate `output/1` calls to debug; use `bindings: "brief"` for large
16
- results. Side effects are real. No speculative features. Keep module docs,
17
- `Name/Arity` and predicate modes accurate.
12
+ Start small: inspect `listing`, explain the inputs, steps, reuse, capabilities and
13
+ checks; plan WITH the user and wait for approval before edits/tests. Then use
14
+ `begin_turn`, `define`/`delete`, bounded `execute`, `end_turn`; report evidence.
15
+ Reopen a transaction for more edits; rollback a bad one. Add intermediate `output/1`
16
+ to debug; use `bindings: "brief"` for large results. Side effects are real.
17
+ Keep docs, `Name/Arity` and modes accurate.
18
18
 
19
19
 
20
20
  Reply without tool calls to finish or ask the user. You do not call `finish` or
@@ -22,6 +22,10 @@ export interface EnvironmentBlockOptions {
22
22
  * the model calls a tool that does not exist.
23
23
  */
24
24
  capabilityTool?: string;
25
+ /** Actual DML capability registry. An empty list means no host capabilities. */
26
+ capabilityTools?: string[];
27
+ /** Embeddings with scoped DML task tools must not label those as host grants. */
28
+ capabilityLabel?: string;
25
29
  /** Injectable clock, so tests do not depend on the wall calendar. */
26
30
  now?: Date;
27
31
  }
@@ -36,7 +40,7 @@ export declare function describeNow(now?: Date): string;
36
40
  */
37
41
  export declare function describeEnvironment(options?: EnvironmentBlockOptions): string;
38
42
  /** `NOW` — always recomputed, so a long session does not read yesterday's date. */
39
- export declare function describeCurrentTime(now?: Date, capabilityTool?: string): string;
43
+ export declare function describeCurrentTime(now?: Date, _capabilityTool?: string): string;
40
44
  /** Both blocks, in the order they should be appended. */
41
45
  export declare function describeRuntimeContext(options?: EnvironmentBlockOptions): string;
42
46
  //# sourceMappingURL=environment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/system/environment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAE/F,MAAM,WAAW,uBAAuB;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ;AAED,gFAAgF;AAChF,wBAAgB,WAAW,CAAC,GAAG,GAAE,IAAiB,GAAG,MAAM,CAoB1D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,uBAA4B,GAAG,MAAM,CAuCjF;AAED,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,IAAiB,EAAE,cAAc,SAAS,GAAG,MAAM,CAS3F;AAED,yDAAyD;AACzD,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,uBAA4B,GAAG,MAAM,CAEpF"}
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/system/environment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAE/F,MAAM,WAAW,uBAAuB;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,iFAAiF;IACjF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qEAAqE;IACrE,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ;AAED,gFAAgF;AAChF,wBAAgB,WAAW,CAAC,GAAG,GAAE,IAAiB,GAAG,MAAM,CAoB1D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,uBAA4B,GAAG,MAAM,CA0CjF;AAED,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,IAAiB,EAAE,eAAe,SAAS,GAAG,MAAM,CAW5F;AAED,yDAAyD;AACzD,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,uBAA4B,GAAG,MAAM,CAEpF"}
@@ -40,24 +40,28 @@ export function describeNow(now = new Date()) {
40
40
  * the host: that is the WASM filesystem's mount, which is always there.
41
41
  */
42
42
  export function describeEnvironment(options = {}) {
43
- const { workspacePath, environment, capabilityTool } = options;
43
+ const { workspacePath, environment, capabilityTool, capabilityTools } = options;
44
44
  const sandboxed = environment?.sandboxed ?? false;
45
45
  const workspace = workspacePath ?? process.cwd();
46
46
  const label = environment?.backendLabel ?? 'unknown';
47
- const tool = capabilityTool ?? 'bash';
47
+ const tool = capabilityTools === undefined ? capabilityTool ?? 'bash'
48
+ : capabilityTools.includes(capabilityTool ?? 'bash') ? capabilityTool ?? 'bash'
49
+ : capabilityTools.includes('python') ? 'python' : undefined;
48
50
  const lines = [
49
51
  'EXECUTION ENVIRONMENT',
50
52
  `- Capability backend: ${label}${environment?.description ? ` (${environment.description})` : ''}.`,
51
53
  ];
52
54
  if (!sandboxed) {
53
- lines.push(`- There is NO sandbox: \`exec(${tool}(...))\` and the capability tool run as your user `
55
+ lines.push(`- There is NO sandbox: ${tool ? `\`exec(${tool}(...), Result)\` and the capability tool run` : 'Any granted host shell would run'} as your user `
54
56
  + 'account. Writes outside the workspace are real files on this machine and '
55
57
  + 'persist, and a `rm` is a real `rm`.');
56
58
  }
57
59
  else {
58
- lines.push(`- \`exec(${tool}(...))\` is isolated by ${environment?.description}. Writes outside `
60
+ lines.push(`- ${tool ? `\`exec(${tool}(...), Result)\` is isolated` : 'Host execution is isolated'} by ${environment?.description}. Writes outside `
59
61
  + 'the workspace stay inside that sandbox and are gone when it ends.');
60
62
  }
63
+ if (capabilityTools !== undefined)
64
+ lines.push(`- Registered ${options.capabilityLabel ?? 'DML host capabilities'}: ${capabilityTools.join(', ') || 'none'}. Tool schemas are authoritative; examples never grant absent tools.`);
61
65
  lines.push(`- Workspace, as your own tools see it: ${workspace}`, `- Workspace, inside DML and \`exec\`: ${SANDBOX_WORKSPACE_PATH} — and it is the `
62
66
  + `working directory, so \`out.txt\` and \`${SANDBOX_WORKSPACE_PATH}/out.txt\` are the `
63
67
  + 'same file. Prefer this name; it is the same everywhere.', '- Only files under the workspace reach the host. In DML, any other absolute path '
@@ -69,10 +73,12 @@ export function describeEnvironment(options = {}) {
69
73
  return lines.join('\n') + '\n';
70
74
  }
71
75
  /** `NOW` — always recomputed, so a long session does not read yesterday's date. */
72
- export function describeCurrentTime(now = new Date(), capabilityTool = 'bash') {
73
- const lookup = capabilityTool === 'bash'
74
- ? 'run `date` (or `exec(bash(argv: ["date", "-Is"]))`)'
75
- : 'use the host tool, e.g. `exec(python(code: "import datetime; print(datetime.datetime.now().isoformat())"), R)`';
76
+ export function describeCurrentTime(now = new Date(), _capabilityTool = 'bash') {
77
+ const lookup = 'use DML `get_time(Stamp)` (no host tool required). For a UTC date: '
78
+ + '`stamp_date_time(Stamp, DT, \'UTC\'), format_time(string(Date), "%Y-%m-%d", DT)`. '
79
+ + 'For an IANA zone (DST-correct, e.g. a market clock) use '
80
+ + '`zone_date_time(Stamp, \'America/New_York\', DT)`; `local_date_time(Stamp, DT)` follows the host zone. '
81
+ + 'This engine has no tzdata, so `stamp_date_time/3` itself accepts only UTC or an integer offset in seconds.';
76
82
  return [
77
83
  'NOW',
78
84
  `- ${describeNow(now)}`,
@@ -1 +1 @@
1
- {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/system/environment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,sBAAsB,EAA6B,MAAM,4BAA4B,CAAC;AAe/F,gFAAgF;AAChF,MAAM,UAAU,WAAW,CAAC,MAAY,IAAI,IAAI,EAAE;IAChD,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;QAC7C,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,SAAS;QACd,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,MAAM;QACf,YAAY,EAAE,OAAO;KACtB,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAEtB,MAAM,GAAG,GAAG,CAAC,IAAkC,EAAU,EAAE,CACzD,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;IACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC;IAEl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C,sBAAsB,qBAAqB;UACtF,yDAAyD,EAC7D,mFAAmF;UAC/E,iFAAiF;UACjF,YAAY,WAAW,EAAE,IAAI,KAAK,MAAM;YACxC,CAAC,CAAC,wGAAwG;YAC1G,CAAC,CAAC,6EAA6E,EAAE,EACrF,qFAAqF;UACjF,oEAAoE,CACzE,CAAC;IAEF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACjC,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,mBAAmB,CAAC,MAAY,IAAI,IAAI,EAAE,EAAE,eAAe,GAAG,MAAM;IAClF,MAAM,MAAM,GAAG,qEAAqE;UAChF,oFAAoF;UACpF,0DAA0D;UAC1D,yGAAyG;UACzG,4GAA4G,CAAC;IACjH,OAAO;QACL,KAAK;QACL,KAAK,WAAW,CAAC,GAAG,CAAC,EAAE;QACvB,uEAAuE,MAAM,GAAG;KACjF,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACtB,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,sBAAsB,CAAC,UAAmC,EAAE;IAC1E,OAAO,KAAK,mBAAmB,CAAC,OAAO,CAAC,KAAK,mBAAmB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC;AAC5G,CAAC"}
@@ -46,10 +46,21 @@ export declare class AgentVMManager {
46
46
  private readonly workspacePath;
47
47
  private readonly network;
48
48
  private readonly defaultTimeoutMs?;
49
+ private readonly onReset?;
49
50
  private vm;
51
+ private queue;
52
+ private stopping;
53
+ private generation;
50
54
  readonly kind: "sandbox";
51
- constructor(workspacePath: string, network: boolean, defaultTimeoutMs?: number | undefined);
55
+ private forwards;
56
+ private forwarding;
57
+ constructor(workspacePath: string, network: boolean, defaultTimeoutMs?: number | undefined, onReset?: (() => void) | undefined);
58
+ /** Trusted host only: fixed guest address, ephemeral loopback TCP listeners. */
59
+ forwardPort(guestPort: number, signal?: AbortSignal): Promise<number>;
60
+ private openForward;
61
+ removePortForward(guestPort: number): void;
52
62
  exec(command: string, signal?: AbortSignal, observer?: ShellExecObserver, options?: ShellExecOptions): Promise<ShellExecResult>;
63
+ private execExclusive;
53
64
  dispose(): Promise<void>;
54
65
  private getVM;
55
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"agentvm-manager.d.ts","sourceRoot":"","sources":["../../../src/system/runtime/agentvm-manager.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,YAAY,C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