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.
- package/README.md +57 -0
- package/dist/agent.d.ts +2 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +5 -0
- package/dist/agent.js.map +1 -1
- package/dist/cli/agent-inbox.d.ts +25 -0
- package/dist/cli/agent-inbox.d.ts.map +1 -0
- package/dist/cli/agent-inbox.js +46 -0
- package/dist/cli/agent-inbox.js.map +1 -0
- package/dist/cli/config.d.ts +28 -28
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +7 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/repl.d.ts +7 -0
- package/dist/cli/repl.d.ts.map +1 -1
- package/dist/cli/repl.js +181 -13
- package/dist/cli/repl.js.map +1 -1
- package/dist/cli/run.d.ts +1 -0
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +3 -1
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/serve.d.ts +3 -0
- package/dist/cli/serve.d.ts.map +1 -0
- package/dist/cli/serve.js +131 -0
- package/dist/cli/serve.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/judge/llm.d.ts.map +1 -1
- package/dist/judge/llm.js +9 -4
- package/dist/judge/llm.js.map +1 -1
- package/dist/judge/types.d.ts +10 -0
- package/dist/judge/types.d.ts.map +1 -1
- package/dist/judge/types.js.map +1 -1
- package/dist/prolog-src/deepclause_mi.pl +370 -54
- package/dist/repl/agent-inbox.d.ts +73 -0
- package/dist/repl/agent-inbox.d.ts.map +1 -0
- package/dist/repl/agent-inbox.js +168 -0
- package/dist/repl/agent-inbox.js.map +1 -0
- package/dist/repl/agent.d.ts +14 -1
- package/dist/repl/agent.d.ts.map +1 -1
- package/dist/repl/agent.js +25 -6
- package/dist/repl/agent.js.map +1 -1
- package/dist/repl/backend.d.ts +6 -0
- package/dist/repl/backend.d.ts.map +1 -1
- package/dist/repl/backend.js +17 -2
- package/dist/repl/backend.js.map +1 -1
- package/dist/repl/event-history.d.ts.map +1 -1
- package/dist/repl/event-history.js +3 -0
- package/dist/repl/event-history.js.map +1 -1
- package/dist/repl/harness-tools.d.ts +9 -2
- package/dist/repl/harness-tools.d.ts.map +1 -1
- package/dist/repl/harness-tools.js +38 -14
- package/dist/repl/harness-tools.js.map +1 -1
- package/dist/repl/history.d.ts +14 -3
- package/dist/repl/history.d.ts.map +1 -1
- package/dist/repl/history.js +62 -5
- package/dist/repl/history.js.map +1 -1
- package/dist/repl/index.d.ts +11 -0
- package/dist/repl/index.d.ts.map +1 -1
- package/dist/repl/index.js +6 -2
- package/dist/repl/index.js.map +1 -1
- package/dist/repl/process-backend.d.ts +1 -0
- package/dist/repl/process-backend.d.ts.map +1 -1
- package/dist/repl/process-executor.d.ts +4 -0
- package/dist/repl/process-executor.d.ts.map +1 -1
- package/dist/repl/process-executor.js +36 -1
- package/dist/repl/process-executor.js.map +1 -1
- package/dist/repl/process-worker.d.ts.map +1 -1
- package/dist/repl/process-worker.js +33 -8
- package/dist/repl/process-worker.js.map +1 -1
- package/dist/repl/processes.d.ts +14 -1
- package/dist/repl/processes.d.ts.map +1 -1
- package/dist/repl/processes.js +8 -2
- package/dist/repl/processes.js.map +1 -1
- package/dist/repl/reference.d.ts.map +1 -1
- package/dist/repl/reference.js +4 -3
- package/dist/repl/reference.js.map +1 -1
- package/dist/repl/render.d.ts.map +1 -1
- package/dist/repl/render.js +13 -0
- package/dist/repl/render.js.map +1 -1
- package/dist/repl/session.d.ts +72 -5
- package/dist/repl/session.d.ts.map +1 -1
- package/dist/repl/session.js +595 -42
- package/dist/repl/session.js.map +1 -1
- package/dist/repl/toolset.d.ts +8 -0
- package/dist/repl/toolset.d.ts.map +1 -1
- package/dist/repl/toolset.js +53 -4
- package/dist/repl/toolset.js.map +1 -1
- package/dist/repl/tui/renderer.d.ts.map +1 -1
- package/dist/repl/tui/renderer.js +3 -1
- package/dist/repl/tui/renderer.js.map +1 -1
- package/dist/repl/work-hooks.d.ts +29 -0
- package/dist/repl/work-hooks.d.ts.map +1 -0
- package/dist/repl/work-hooks.js +117 -0
- package/dist/repl/work-hooks.js.map +1 -0
- package/dist/repl/worker-host.d.ts +2 -0
- package/dist/repl/worker-host.d.ts.map +1 -1
- package/dist/repl/worker-host.js +48 -4
- package/dist/repl/worker-host.js.map +1 -1
- package/dist/repl/worker-protocol.d.ts +23 -2
- package/dist/repl/worker-protocol.d.ts.map +1 -1
- package/dist/repl/worker-protocol.js +1 -1
- package/dist/runner.d.ts +2 -2
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +19 -3
- package/dist/runner.js.map +1 -1
- package/dist/runtime-identity.json +6 -6
- package/dist/serve/agent-broadcast.d.ts +29 -0
- package/dist/serve/agent-broadcast.d.ts.map +1 -0
- package/dist/serve/agent-broadcast.js +28 -0
- package/dist/serve/agent-broadcast.js.map +1 -0
- package/dist/serve/agent-preferences.d.ts +16 -0
- package/dist/serve/agent-preferences.d.ts.map +1 -0
- package/dist/serve/agent-preferences.js +42 -0
- package/dist/serve/agent-preferences.js.map +1 -0
- package/dist/serve/api-docs.d.ts +61 -0
- package/dist/serve/api-docs.d.ts.map +1 -0
- package/dist/serve/api-docs.js +122 -0
- package/dist/serve/api-docs.js.map +1 -0
- package/dist/serve/backend.d.ts +12 -0
- package/dist/serve/backend.d.ts.map +1 -0
- package/dist/serve/backend.js +52 -0
- package/dist/serve/backend.js.map +1 -0
- package/dist/serve/capabilities.d.ts +6 -0
- package/dist/serve/capabilities.d.ts.map +1 -0
- package/dist/serve/capabilities.js +21 -0
- package/dist/serve/capabilities.js.map +1 -0
- package/dist/serve/example-agent.d.ts +5 -0
- package/dist/serve/example-agent.d.ts.map +1 -0
- package/dist/serve/example-agent.js +5 -0
- package/dist/serve/example-agent.js.map +1 -0
- package/dist/serve/files.d.ts +55 -0
- package/dist/serve/files.d.ts.map +1 -0
- package/dist/serve/files.js +249 -0
- package/dist/serve/files.js.map +1 -0
- package/dist/serve/harness.d.ts +3 -0
- package/dist/serve/harness.d.ts.map +1 -0
- package/dist/serve/harness.js +53 -0
- package/dist/serve/harness.js.map +1 -0
- package/dist/serve/previews.d.ts +40 -0
- package/dist/serve/previews.d.ts.map +1 -0
- package/dist/serve/previews.js +240 -0
- package/dist/serve/previews.js.map +1 -0
- package/dist/serve/protocol.d.ts +228 -0
- package/dist/serve/protocol.d.ts.map +1 -0
- package/dist/serve/protocol.js +2 -0
- package/dist/serve/protocol.js.map +1 -0
- package/dist/serve/schedules.d.ts +85 -0
- package/dist/serve/schedules.d.ts.map +1 -0
- package/dist/serve/schedules.js +249 -0
- package/dist/serve/schedules.js.map +1 -0
- package/dist/serve/server.d.ts +50 -0
- package/dist/serve/server.d.ts.map +1 -0
- package/dist/serve/server.js +1696 -0
- package/dist/serve/server.js.map +1 -0
- package/dist/serve/session-worker.d.ts +2 -0
- package/dist/serve/session-worker.d.ts.map +1 -0
- package/dist/serve/session-worker.js +291 -0
- package/dist/serve/session-worker.js.map +1 -0
- package/dist/serve/sessions.d.ts +178 -0
- package/dist/serve/sessions.d.ts.map +1 -0
- package/dist/serve/sessions.js +905 -0
- package/dist/serve/sessions.js.map +1 -0
- package/dist/serve/storage.d.ts +41 -0
- package/dist/serve/storage.d.ts.map +1 -0
- package/dist/serve/storage.js +211 -0
- package/dist/serve/storage.js.map +1 -0
- package/dist/serve/ui/api-docs.html +17 -0
- package/dist/serve/ui/api-docs.js +36 -0
- package/dist/serve/ui/app.js +958 -0
- package/dist/serve/ui/authoring.js +92 -0
- package/dist/serve/ui/deepclause-logo.png +0 -0
- package/dist/serve/ui/deepclause-mark.svg +1 -0
- package/dist/serve/ui/diff.js +16 -0
- package/dist/serve/ui/dompurify-LICENSE.txt +202 -0
- package/dist/serve/ui/features.css +15 -0
- package/dist/serve/ui/files.js +13 -0
- package/dist/serve/ui/ibm-plex-mono-latin.woff2 +0 -0
- package/dist/serve/ui/ibmplexmono-OFL.txt +93 -0
- package/dist/serve/ui/icons.js +30 -0
- package/dist/serve/ui/index.html +68 -0
- package/dist/serve/ui/manrope-OFL.txt +93 -0
- package/dist/serve/ui/manrope-latin.woff2 +0 -0
- package/dist/serve/ui/markdown.js +38 -0
- package/dist/serve/ui/marked-LICENSE.txt +44 -0
- package/dist/serve/ui/marked.js +88 -0
- package/dist/serve/ui/purify.js +2454 -0
- package/dist/serve/ui/style.css +249 -0
- package/dist/serve/ui/web-work.css +247 -0
- package/dist/serve/ui/web.css +1848 -0
- package/dist/serve/workflow-bundles.d.ts +8 -0
- package/dist/serve/workflow-bundles.d.ts.map +1 -0
- package/dist/serve/workflow-bundles.js +78 -0
- package/dist/serve/workflow-bundles.js.map +1 -0
- package/dist/serve/workflow-calls.d.ts +6 -0
- package/dist/serve/workflow-calls.d.ts.map +1 -0
- package/dist/serve/workflow-calls.js +13 -0
- package/dist/serve/workflow-calls.js.map +1 -0
- package/dist/serve/workflows.d.ts +93 -0
- package/dist/serve/workflows.d.ts.map +1 -0
- package/dist/serve/workflows.js +219 -0
- package/dist/serve/workflows.js.map +1 -0
- package/dist/system/assets/docs/AGENT_PROMPT.md +6 -6
- package/dist/system/assets/docs/DML_AUTHORING.md +80 -2
- package/dist/system/assets/docs/DML_PROCESSES.md +24 -0
- package/dist/system/assets/docs/DML_REFERENCE.md +98 -10
- package/dist/system/assets/docs/DML_SHELL.md +149 -7
- package/dist/system/assets/docs/DML_TASKS.md +10 -3
- package/dist/system/assets/docs/LOCAL_AGENT_PROMPT.md +6 -6
- package/dist/system/environment.d.ts +5 -1
- package/dist/system/environment.d.ts.map +1 -1
- package/dist/system/environment.js +14 -8
- package/dist/system/environment.js.map +1 -1
- package/dist/system/runtime/agentvm-manager.d.ts +12 -1
- package/dist/system/runtime/agentvm-manager.d.ts.map +1 -1
- package/dist/system/runtime/agentvm-manager.js +136 -20
- package/dist/system/runtime/agentvm-manager.js.map +1 -1
- package/dist/system/runtime/shell-manager.d.ts +3 -0
- package/dist/system/runtime/shell-manager.d.ts.map +1 -1
- package/dist/system/runtime/shell-manager.js +1 -1
- package/dist/system/runtime/shell-manager.js.map +1 -1
- package/dist/system/timezone.d.ts +20 -0
- package/dist/system/timezone.d.ts.map +1 -0
- package/dist/system/timezone.js +37 -0
- package/dist/system/timezone.js.map +1 -0
- package/dist/types.d.ts +37 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/work/index.d.ts +13 -3
- package/dist/work/index.d.ts.map +1 -1
- package/dist/work/index.js +80 -15
- package/dist/work/index.js.map +1 -1
- package/docs/DEEP_RESEARCH_EXAMPLE.md +127 -0
- package/docs/SERVE.md +664 -0
- package/docs/WORK_AGENT_HOOKS_PLAN.md +416 -0
- package/docs/WORK_AGENT_INBOX.md +140 -0
- package/docs/WORK_AGENT_INBOX_PLAN.md +91 -0
- package/docs/WORK_MODE.md +269 -0
- package/package.json +24 -2
- package/sdk-examples/deep-research.dml +144 -0
- package/sdk-examples/deep-research.py +502 -0
- package/sdk-examples/hooked-agent.dml +49 -0
- package/sdk-examples/subagent-inbox.dml +66 -0
- package/src/prolog-src/deepclause_mi.pl +370 -54
package/docs/SERVE.md
ADDED
|
@@ -0,0 +1,664 @@
|
|
|
1
|
+
# Serve a Work harness over HTTP
|
|
2
|
+
|
|
3
|
+
`deepclause serve` hosts **one validated Work harness**, with multiple independent
|
|
4
|
+
server-owned conversations and a bundled web interface. The client reuses the
|
|
5
|
+
DeepClause web project's warm-grey/teal theme, logo, Work navigation and fonts;
|
|
6
|
+
it adds responsive navigation/process drawers and safe Markdown/code rendering. It never exposes Develop,
|
|
7
|
+
arbitrary goals, compilation, or a remote file editor.
|
|
8
|
+
|
|
9
|
+
Agent shells can declare DML `on_start`/`on_message` hooks with persistent explicit
|
|
10
|
+
state and editable model-facing memory. Direct hook replies bypass the outer
|
|
11
|
+
assistant; `continue` retains the normal assistant and its declared `run_workflow`
|
|
12
|
+
tool. Manual workflow runs do not invoke agent hooks. See
|
|
13
|
+
[`WORK_MODE.md`](WORK_MODE.md#stateful-dml-agent-hooks) and
|
|
14
|
+
[`../sdk-examples/hooked-agent.dml`](../sdk-examples/hooked-agent.dml).
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
Build from source once (`npm run build`), then:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
deepclause serve writing.dml
|
|
22
|
+
# From this checkout: node dist/cli/index.js serve writing.dml
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Open the printed URL, including its `#token=…` fragment. The client moves the token
|
|
26
|
+
into tab-local session storage and removes the fragment. The fragment is not sent
|
|
27
|
+
in HTTP requests. Treat the printed URL as a secret.
|
|
28
|
+
|
|
29
|
+
The default model backend is pi: existing model selection, credentials and model
|
|
30
|
+
catalog are reused; the server does not request keys or change provider environment
|
|
31
|
+
variables. Explicit `--model` and `--thinking` overrides are available. Environment
|
|
32
|
+
provider credentials can be used with `--backend env --model openai:gpt-4o`.
|
|
33
|
+
Pure workflows need no credentials with `--backend env`.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Reuse pi's existing authentication; select a provider/model explicitly:
|
|
37
|
+
deepclause serve writing.dml --model anthropic/claude-sonnet-4-20250514
|
|
38
|
+
# Or use existing environment-provider credentials:
|
|
39
|
+
deepclause serve writing.dml --backend env --model openai:gpt-4o-mini
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Model and reasoning settings
|
|
43
|
+
|
|
44
|
+
Three layers can set the model, and two can set reasoning. They compose in this
|
|
45
|
+
order, narrowest last:
|
|
46
|
+
|
|
47
|
+
1. **Deployment (startup).** `--backend pi|env` and `--model`:
|
|
48
|
+
- pi: `--model provider/model` (for example `deepseek/deepseek-flash`);
|
|
49
|
+
- env: `--model provider:model` with credentials already in the environment.
|
|
50
|
+
`--thinking off|minimal|low|medium|high|xhigh|max` sets the default reasoning
|
|
51
|
+
level for the deployment. On pi it is validated against the chosen model and
|
|
52
|
+
dropped with a warning when unsupported; on `--backend env` it maps through
|
|
53
|
+
the bundled model database (effort, token budget or thinking config) and is
|
|
54
|
+
ignored with a warning when the model declares no reasoning support.
|
|
55
|
+
2. **DML scope (`with_model/2`)** — `with_model("provider:model", Goal)`
|
|
56
|
+
switches one goal, including `#level` (`with_model("deepseek/deepseek-reasoner#high", Goal)`).
|
|
57
|
+
`provider/model` and `provider:model` are both accepted; the provider must
|
|
58
|
+
exist and have credentials. The scope applies to `task/N`, `prompt/N`,
|
|
59
|
+
`sample_token/N` and LLM-backed judgments.
|
|
60
|
+
3. **DML scope (`with_reasoning/2`)** — `with_reasoning(Goal, Effort)` sets
|
|
61
|
+
`none|low|medium|high` for one goal. It now reaches both backends: pi maps it
|
|
62
|
+
onto the model's thinking level for those calls only, and the env backend
|
|
63
|
+
translates it into provider options. `none` disables thinking for the scope.
|
|
64
|
+
|
|
65
|
+
There is deliberately no server-wide live model switch: restart `serve` with a
|
|
66
|
+
different `--model`/`--thinking` for a new deployment default. Changing a saved
|
|
67
|
+
Agent's model or a published workflow's model is not a separate permission; the
|
|
68
|
+
server always uses its current model plus the DML scopes above. Startup prints
|
|
69
|
+
`Model: provider/model`; `/api/harness` and the UI footer expose that selection.
|
|
70
|
+
Explicitly continued conversations use the current server model and current tool
|
|
71
|
+
policy, not saved credentials or a stale model setting.
|
|
72
|
+
|
|
73
|
+
A minimal example:
|
|
74
|
+
|
|
75
|
+
```prolog
|
|
76
|
+
uppercase(Text, Upper) :- string_upper(Text, Upper).
|
|
77
|
+
|
|
78
|
+
shell(_{
|
|
79
|
+
kind: agent,
|
|
80
|
+
system: "You are a concise writing assistant.",
|
|
81
|
+
welcome: "Ask about writing, or choose Uppercase.",
|
|
82
|
+
host_tools: [],
|
|
83
|
+
tools: [],
|
|
84
|
+
workflows: [_{name: "Uppercase", goal: "uppercase",
|
|
85
|
+
inputs: [_{name: "Text", type: string}],
|
|
86
|
+
outputs: [_{name: "Upper", type: string}]}]
|
|
87
|
+
}).
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Use `kind: workflow` for workflows without a chat assistant. An `agent_main` entry
|
|
91
|
+
is not required. Missing or invalid `shell/1` fails startup; helpers are never
|
|
92
|
+
implicitly exported. See [Work mode](./WORK_MODE.md) for types and semantics.
|
|
93
|
+
|
|
94
|
+
## Configuration and workspace
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
deepclause serve writing.dml --workspace ./project --port 8080
|
|
98
|
+
deepclause serve --harness writing --workspace ./project
|
|
99
|
+
deepclause serve --harness --workspace ./project # defaults to the main slot
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Choose a file **or** `--harness [name]`, not both. An explicit `.dml` file may
|
|
103
|
+
live anywhere inside the workspace, including `.deepclause/`. Real-path/symlink
|
|
104
|
+
containment still prevents loading source from outside the workspace.
|
|
105
|
+
|
|
106
|
+
Named slots are read from the standalone SDK's
|
|
107
|
+
`.deepclause/repl/harnesses/<name>/harness.dml` first, then
|
|
108
|
+
`.pi/deepclause/repl/harnesses/<name>/harness.dml` for compatibility. A HEAD-only
|
|
109
|
+
slot falls back to `HEAD.json` and its matching `versions/NNNN_*.json` module in
|
|
110
|
+
the same store. The standalone SDK store takes precedence if both contain a
|
|
111
|
+
source. Lookup is read-only: it does not initialize, migrate, or rewrite either
|
|
112
|
+
store, and source loading does not import standalone credentials/configuration.
|
|
113
|
+
|
|
114
|
+
For an existing standalone REPL workspace, either command works without copying:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
deepclause serve .deepclause/repl/harnesses/main/harness.dml
|
|
118
|
+
deepclause serve --harness main
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Serve runtime state and policy defaults remain under `.pi/deepclause/`; this
|
|
122
|
+
standalone source lookup does not change the pi extension's workspace layout.
|
|
123
|
+
|
|
124
|
+
Runtime defaults are read from `.pi/deepclause/config.json` through the shared
|
|
125
|
+
Work policy resolver (`repl.gasLimit`, `maxModelCalls`, `maxDepth`,
|
|
126
|
+
`providerConcurrency`, `compaction`). No configuration file is created/overwritten.
|
|
127
|
+
|
|
128
|
+
New serve state defaults to:
|
|
129
|
+
|
|
130
|
+
```text
|
|
131
|
+
.pi/deepclause/serve/
|
|
132
|
+
server.lock
|
|
133
|
+
events.jsonl
|
|
134
|
+
diagrams/<artifact-id>.json # bounded SVG/Mermaid artifacts
|
|
135
|
+
sessions/<session-id>/
|
|
136
|
+
session.json
|
|
137
|
+
processes.json
|
|
138
|
+
trace.json # when captured
|
|
139
|
+
trace-<process-id>.json # when captured
|
|
140
|
+
history/ # SDK-owned snapshots and history
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`--state-dir` changes the root, which must remain inside the workspace. State
|
|
144
|
+
paths cannot be symlinked. New directories/files are created with private
|
|
145
|
+
permissions. A missing state-local `.gitignore` is seeded to ignore runtime data. Existing user documentation and DML files are not overwritten.
|
|
146
|
+
Each runtime has a distinct SDK history root, avoiding shared history/HEAD writers.
|
|
147
|
+
The main server is the sole event-journal/process-registry writer.
|
|
148
|
+
|
|
149
|
+
Startup captures a pinned **base deployment** snapshot. Fresh Work Agents start
|
|
150
|
+
from that snapshot, not another conversation's mutated facts. Editing its source
|
|
151
|
+
files does not change the base deployment. Separately, **Create workflow** opens a
|
|
152
|
+
Develop Agent: successful REPL commits atomically activate versioned workflows
|
|
153
|
+
without restarting serve. Running jobs and schedules retain their selected code
|
|
154
|
+
and asset revisions. Work Agents refresh only their external workflow catalog
|
|
155
|
+
between turns. See [Live workflows, schedules and files](SERVE_WORKFLOWS.md).
|
|
156
|
+
|
|
157
|
+
## Sessions and processes
|
|
158
|
+
|
|
159
|
+
The sidebar separates **Agents**, **Workflows**, and **Runs**; the header also
|
|
160
|
+
opens **Schedules** and the button-hidden workspace **Files** browser:
|
|
161
|
+
|
|
162
|
+
- **New agent** asks for a name, optional additional system instructions, and
|
|
163
|
+
whether to allow incoming Agent/workflow messages. The instructions are
|
|
164
|
+
appended to the existing harness prompt, not substituted for it. Workflow-only
|
|
165
|
+
deployments can create restricted result-reviewing Agents without shell or
|
|
166
|
+
authoring tools. Agent conversations have a chat composer.
|
|
167
|
+
- **Agent settings** edits name/instructions and **Allow incoming messages**.
|
|
168
|
+
Multiple Agents can opt in independently; there is no workspace default or
|
|
169
|
+
per-run recipient grant. DML names its destination explicitly. Instruction
|
|
170
|
+
edits require an idle Agent; receiver permission is checked on every send. See [Agent management](SERVE_WORKFLOWS.md#agent-creation-settings-and-deletion).
|
|
171
|
+
- The trash button permanently deletes an Agent's private runtime/history/inbox/
|
|
172
|
+
traces/draft and shared-journal records, revokes its receiver permission and pauses
|
|
173
|
+
schedules targeting it. **Close** remains separate and retains saved history.
|
|
174
|
+
Published workflows and ordinary workspace files are not deleted.
|
|
175
|
+
- Clicking a workflow opens its input dialog and creates a **new, independent
|
|
176
|
+
workflow execution session** named after that workflow. It does not run inside
|
|
177
|
+
or interrupt the selected agent conversation. The workflow run has no composer;
|
|
178
|
+
status and typed result/outputs are also available in `session.workflow`.
|
|
179
|
+
- Completed workflow roots remain live when they may own processes. Explicitly
|
|
180
|
+
close unneeded runs to release a slot; closing stops their managed processes.
|
|
181
|
+
- Unless a user supplied a name, Agent titles are generated by the selected model after the first chat and every
|
|
182
|
+
third chat. It generates a purpose-based name and one-sentence summary. The naming
|
|
183
|
+
job has no tools, a 12-second timeout, at most 160 output tokens, and bounded
|
|
184
|
+
question/answer context. Naming usage is included in session
|
|
185
|
+
totals (`usage.source: session_title`). Failure falls back to the first question
|
|
186
|
+
and never fails the chat. A manual rename wins races and disables auto-naming
|
|
187
|
+
for that conversation. An untitled continued conversation is named from its
|
|
188
|
+
restored questions, without needing another chat first. Workflow naming never
|
|
189
|
+
makes an LLM call.
|
|
190
|
+
- **Info**, at the top right beside **Processes**, contains Assistant tools and
|
|
191
|
+
Host capabilities. Those sections are no longer shown in the sidebar. Assistant
|
|
192
|
+
tools are descriptive, not direct manual invocation controls; their diagram
|
|
193
|
+
buttons remain available in Info.
|
|
194
|
+
|
|
195
|
+
Each live session owns a root worker, its conversation, foreground operation,
|
|
196
|
+
input/forms and background process host. Workflow-only deployments do not create
|
|
197
|
+
an empty agent session at startup. Older workflow-only multi-run histories are
|
|
198
|
+
labelled as legacy workflow sessions, not resumable agent conversations.
|
|
199
|
+
|
|
200
|
+
- Switching sessions or disconnecting the browser does **not** stop execution.
|
|
201
|
+
- Foreground operations are serialized per session; different sessions can run
|
|
202
|
+
concurrently. Manual workflow starts call the exact named entry without an
|
|
203
|
+
assistant decision.
|
|
204
|
+
- Stop foreground cancels that operation. Stopping a selected process respects
|
|
205
|
+
existing process links. Closing a session explicitly stops all its processes.
|
|
206
|
+
- Sessions with services are never silently expired. Default maximum: 8 live
|
|
207
|
+
sessions. Close sessions explicitly to release slots.
|
|
208
|
+
- Provider concurrency is bounded across sessions (default 4). Each SDK process
|
|
209
|
+
host also has its existing live-process/mailbox limits.
|
|
210
|
+
- Default foreground wall-clock limit: 10 minutes (`--operation-timeout <ms>`).
|
|
211
|
+
Work gas defaults to 1,000,000; gas is not a universal native-call time limit.
|
|
212
|
+
- An operation that cannot acknowledge cancellation within 2 seconds triggers
|
|
213
|
+
root-worker termination. That session is marked interrupted; other sessions
|
|
214
|
+
continue. Host calls are brokered by the server so cancellation can reach them.
|
|
215
|
+
- Node's existing L2 worker hosts a session's processes together. If stopping one
|
|
216
|
+
requires hard termination, the whole session and sibling processes are marked
|
|
217
|
+
interrupted. The UI warns about this rather than claiming process-local hard
|
|
218
|
+
preemption.
|
|
219
|
+
|
|
220
|
+
The process panel shows states, activity, registered aliases, mailbox depth and
|
|
221
|
+
usage. Select a process for logs, follow-tail, saved log pages, and its trace.
|
|
222
|
+
Logs continue to be collected when the process/session is not selected.
|
|
223
|
+
|
|
224
|
+
### Continue a saved agent conversation
|
|
225
|
+
|
|
226
|
+
Selecting saved history does not start execution. A compatible saved agent has
|
|
227
|
+
an editable composer: **send a message to continue**, with no separate Continue
|
|
228
|
+
button. The chat operation first restores the same session ID, durable SDK memory
|
|
229
|
+
and private harness state, then submits the new message. It works after explicit
|
|
230
|
+
Close, runtime interruption or a server restart. Workflows can start separate runs
|
|
231
|
+
while history is selected; diagrams do not require a live conversation. API clients
|
|
232
|
+
can optionally call `POST /api/sessions/:id/continue` to reopen without a new message.
|
|
233
|
+
|
|
234
|
+
Continuation requires the same deployment **program hash**, a valid saved snapshot,
|
|
235
|
+
and a free live-session slot. A file basename (`harness`) and a named slot (`main`)
|
|
236
|
+
may label the same program differently; this does not block continuation. The
|
|
237
|
+
original SDK history namespace is retained, so changing launch syntax cannot
|
|
238
|
+
silently lose conversation memory.
|
|
239
|
+
|
|
240
|
+
A genuinely different program is rejected rather than silently mixed with saved
|
|
241
|
+
state. Its history stays read-only, the UI explains the saved/current hashes, and
|
|
242
|
+
an enabled **New agent conversation** action is offered instead of a dead Continue
|
|
243
|
+
button. The current server model,
|
|
244
|
+
authentication and tool policy apply. Missing/corrupt saved process metadata is
|
|
245
|
+
reported rather than overwritten. A new conversation is the fallback when an
|
|
246
|
+
old deployment cannot be restored.
|
|
247
|
+
|
|
248
|
+
Executable snapshots must preserve clause order within each Prolog predicate.
|
|
249
|
+
Older builds with the source-view ordering defect could save reordered clauses,
|
|
250
|
+
breaking cut/fallback dispatch and coordinator reuse. Updating the SDK does not
|
|
251
|
+
repair those already-saved programs: redeploy the reviewed original source and
|
|
252
|
+
start a fresh Agent. Do not guess a new clause order or replay failed jobs as a
|
|
253
|
+
migration. Removing saved state is a separate, explicitly destructive action.
|
|
254
|
+
|
|
255
|
+
**Conversation continuation is not process recovery.** The UI/API explicitly list
|
|
256
|
+
previous interrupted process attempts: those managed processes stopped when the
|
|
257
|
+
old runtime ended and were **not restarted**. Old forms, input handles, mailboxes
|
|
258
|
+
and suspended execution continuations are not restored. The SDK also adds a
|
|
259
|
+
resume note to the agent's memory so it does not assume old services are alive.
|
|
260
|
+
New processes use a fresh PID namespace; old PIDs cannot address new processes.
|
|
261
|
+
External side effects/independently daemonized commands are not rolled back.
|
|
262
|
+
|
|
263
|
+
Workflow execution sessions remain inspectable history, not agent conversations;
|
|
264
|
+
start another workflow to create a fresh run. Merely opening a saved session never
|
|
265
|
+
restarts processes or replays a workflow.
|
|
266
|
+
|
|
267
|
+
### Process definitions: restart-ready, not automatic restart
|
|
268
|
+
|
|
269
|
+
Each process has a stable logical ID and an attempt ID separate from its PID.
|
|
270
|
+
Before its body runs, the host awaits atomic persistence of a launch definition:
|
|
271
|
+
goal/options/snapshot, deployment identity, effective model, capability names and
|
|
272
|
+
limits. Failed registration prevents execution. Explicit Stop persists
|
|
273
|
+
`desiredState: stopped` before cancellation.
|
|
274
|
+
|
|
275
|
+
This version deliberately has **no process Restart action or automatic recovery**.
|
|
276
|
+
Saved sessions remain history until a new chat message or explicit API continuation
|
|
277
|
+
reopens them (agent only); no background
|
|
278
|
+
process is silently recreated. A future process restart can execute a saved definition
|
|
279
|
+
as a fresh attempt, subject to current policy and dependency checks. It is not
|
|
280
|
+
checkpoint/resume, and may repeat side effects. There is no exactly-once guarantee.
|
|
281
|
+
|
|
282
|
+
Live DML suspension has an explicit Resume action; merely viewing history never
|
|
283
|
+
executes a continuation. Forms/handles/mailboxes are not restored from event logs.
|
|
284
|
+
|
|
285
|
+
## Traces and diagrams
|
|
286
|
+
|
|
287
|
+
Root and process traces come from actual SDK MI/tool traces, not inferred logs.
|
|
288
|
+
The SDK caps its internal trace store at 50,000 entries; HTTP captures expose at
|
|
289
|
+
most 10,000 entries and report partial/truncated status. The process host retains
|
|
290
|
+
traces for up to 50 completed children; serve also saves captures at process/turn
|
|
291
|
+
completion where available. If a busy engine cannot answer, return the last saved
|
|
292
|
+
capture with an explicit stale/partial note, or report unavailable. Trace contents
|
|
293
|
+
can include sensitive arguments/results.
|
|
294
|
+
|
|
295
|
+
Diagram buttons are available for declared workflows/tools. Generation makes an
|
|
296
|
+
explicit model call on a separate pinned, capability-free runtime, with usage
|
|
297
|
+
reported to the requesting session, including saved history. Global
|
|
298
|
+
`POST /api/diagrams` works even before a workflow-only deployment has any sessions;
|
|
299
|
+
without a session owner its usage is recorded in the server journal. Diagrams
|
|
300
|
+
always explain the current pinned deployment, not a different archived program.
|
|
301
|
+
Results are cached by deployment/entry/mode
|
|
302
|
+
for this server lifetime. One generation at a time is allowed, with cancellation.
|
|
303
|
+
Artifacts are stored separately from the journal (maximum 4 MiB), so replay
|
|
304
|
+
contains references rather than large SVG payloads. The UI displays SVG as an
|
|
305
|
+
image and offers Mermaid source. These are model-generated
|
|
306
|
+
explanations, not exact execution traces. No executable HTML miniapp bridge exists.
|
|
307
|
+
|
|
308
|
+
The UI renders sanitized Markdown with the same marked/DOMPurify stack as
|
|
309
|
+
DeepClause web. Code fences remain code; HTML applications, scripts, remote media
|
|
310
|
+
embeds and the `dc.call`/workspace bridges are never enabled. File
|
|
311
|
+
inputs are existing workspace-relative files, with real-path/symlink containment
|
|
312
|
+
checks for manual workflows and assistant-declared tools. File inputs offer an
|
|
313
|
+
upload or workspace picker, Files opens a bounded browser, and relative Markdown
|
|
314
|
+
file links, `download_file` and DML `output(file(Path))` produce authenticated
|
|
315
|
+
attachment ribbons. HTML is never executed on the Work origin. See the
|
|
316
|
+
[file policy and API](SERVE_WORKFLOWS.md#files-browser-picker-and-downloads).
|
|
317
|
+
|
|
318
|
+
## Event journal
|
|
319
|
+
|
|
320
|
+
The JSONL file contains the same versioned envelope as the SSE feed:
|
|
321
|
+
|
|
322
|
+
```json
|
|
323
|
+
{"v":1,"seq":42,"time":"2026-11-19T10:00:00Z","sessionId":"s_…","processId":"p_…","attemptId":"a_…","kind":"process_event","payload":{"type":"output","content":"Checked sources"}}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Events are broadcast immediately and buffered in a memory ring capped at 2,000
|
|
327
|
+
events and 8 MiB. Disk appends are serialized, batched every 250 ms, 200 events or
|
|
328
|
+
256 KiB, and flushed at turn end
|
|
329
|
+
and graceful shutdown. No per-event fsync: abrupt crashes/power loss can lose the
|
|
330
|
+
unflushed tail. The journal is not a transactional execution log.
|
|
331
|
+
|
|
332
|
+
At startup the file is scanned to recover sequence numbers and the recent buffer.
|
|
333
|
+
Malformed/incomplete records are diagnosed and skipped, and an incomplete final
|
|
334
|
+
line is terminated before appending. Writes that fail produce a persistence warning;
|
|
335
|
+
execution continues. Lost batches are not silently represented as durable.
|
|
336
|
+
|
|
337
|
+
Sensitive credential-shaped fields and the bearer token are redacted before
|
|
338
|
+
memory, broadcast and disk. Add text patterns with repeatable `--redact <regex>`.
|
|
339
|
+
This is not a guarantee of automatic secret detection. The executable process
|
|
340
|
+
registry/SDK snapshots are private recovery metadata, not redacted launch code.
|
|
341
|
+
|
|
342
|
+
Clients reconnect with a sequence cursor. Memory covers normal reconnects; JSONL
|
|
343
|
+
history supplies bounded older pages. A cursor gap requests snapshot/history
|
|
344
|
+
refresh. Large traces are separate captures; large strings are truncated in events.
|
|
345
|
+
The browser retains recent events and offers paged saved process logs.
|
|
346
|
+
|
|
347
|
+
No indexes, database, log rotation or automatic retention deletion are added.
|
|
348
|
+
Archive state while the server is stopped. Preserve sequence continuity if retaining
|
|
349
|
+
an active journal; archive the entire state directory for a clean deployment.
|
|
350
|
+
The ownership lock prevents two servers sharing a state directory. After a crash,
|
|
351
|
+
verify the recorded PID is not serving before manually removing `server.lock`.
|
|
352
|
+
|
|
353
|
+
## HTTP API
|
|
354
|
+
|
|
355
|
+
API requests require `Authorization: Bearer <token>`. JSON action requests require
|
|
356
|
+
`Content-Type: application/json`; maximum body size is 256 KiB. No query-string
|
|
357
|
+
authentication or permissive CORS is supported.
|
|
358
|
+
|
|
359
|
+
The **API** header link opens `/api-docs`, a bundled documentation page generated
|
|
360
|
+
for the deployed harness. It reuses tab authentication and includes typed workflow
|
|
361
|
+
curl examples, continuation, processes, inputs/forms, traces, diagrams and SSE.
|
|
362
|
+
`GET /api/docs` returns the same discovery data, and `GET /api/openapi.json` returns
|
|
363
|
+
OpenAPI 3.1. The page can download that document. Examples use token placeholders;
|
|
364
|
+
no bearer secret is embedded in documentation responses.
|
|
365
|
+
|
|
366
|
+
| Method/path | Purpose |
|
|
367
|
+
|---|---|
|
|
368
|
+
| `GET /api/docs` / `GET /api/openapi.json` | Authenticated harness-specific docs / OpenAPI |
|
|
369
|
+
| `GET /api/harness` | Public Work interface, model/capabilities and persistence health |
|
|
370
|
+
| `GET /api/sessions` | Live and archived sessions |
|
|
371
|
+
| `POST /api/sessions` | New Agent `{title,additionalSystemPrompt,allowMessages}`; a name is required for workflow-only result-reviewing Agents |
|
|
372
|
+
| `POST /api/workflows/:name/runs` | New isolated workflow execution (`{ "inputs": {…} }`); returns 202, sessionId and operationId |
|
|
373
|
+
| `POST /api/sessions/:id/continue` | Explicit saved-agent continuation (`{}`); returns restored view and process-loss notice |
|
|
374
|
+
| `GET/PATCH/DELETE /api/sessions/:id` | Inspect/edit Agent settings; DELETE closes and retains history |
|
|
375
|
+
| `DELETE /api/sessions/:id?purge=true` | Permanently delete an Agent and its private records |
|
|
376
|
+
| `POST /api/sessions/:id/operations` | Agent chat / live suspension resume; legacy workflow starts remain compatible; returns 202 |
|
|
377
|
+
| `POST /api/sessions/:id/cancel` | Cancel the identified current operation |
|
|
378
|
+
| `POST /api/sessions/:id/inputs/:inputId` | Answer/cancel pending input |
|
|
379
|
+
| `POST /api/sessions/:id/forms/:formId` | Submit action, revision and values |
|
|
380
|
+
| `GET /api/sessions/:id/processes` | Current process table |
|
|
381
|
+
| `GET /api/sessions/:id/processes/:processId/logs` | Saved log events |
|
|
382
|
+
| `POST /api/sessions/:id/processes/:processId/stop` | Explicit process stop (`{}`) |
|
|
383
|
+
| `GET /api/sessions/:id/trace` | Root trace capture |
|
|
384
|
+
| `GET /api/sessions/:id/processes/:processId/trace` | Process trace capture |
|
|
385
|
+
| `POST /api/diagrams` | Generate/cache declared entry diagram; optional sessionId, no live session required |
|
|
386
|
+
| `POST /api/diagrams/jobs/:jobId/cancel` | Cancel global generation (`{}`) |
|
|
387
|
+
| `POST /api/sessions/:id/diagrams` | Compatibility route attributing generation to a live/saved session |
|
|
388
|
+
| `POST /api/sessions/:id/diagrams/:jobId/cancel` | Cancel generation (`{}`) |
|
|
389
|
+
| `GET /api/diagrams/:artifactId` | Read a saved diagram artifact |
|
|
390
|
+
| `GET /api/events?after=N` | Authenticated multiplexed SSE |
|
|
391
|
+
| `GET /api/events/history?after=N&limit=500` | JSONL replay; optional sessionId/processId filters |
|
|
392
|
+
|
|
393
|
+
Example for the minimal harness above (the running server's API page generates
|
|
394
|
+
commands for its **actual** declared workflows and input types):
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
export BASE_URL='http://127.0.0.1:8080'
|
|
398
|
+
export DC_SERVE_TOKEN='paste-the-server-token-here'
|
|
399
|
+
curl -X POST "$BASE_URL/api/workflows/Uppercase/runs" \
|
|
400
|
+
-H "Authorization: Bearer $DC_SERVE_TOKEN" \
|
|
401
|
+
-H 'Content-Type: application/json' \
|
|
402
|
+
--data '{"inputs":{"Text":"hello"}}'
|
|
403
|
+
# Save sessionId from that response, then inspect status and typed outputs:
|
|
404
|
+
export SESSION_ID='s_...'
|
|
405
|
+
curl "$BASE_URL/api/sessions/$SESSION_ID" \
|
|
406
|
+
-H "Authorization: Bearer $DC_SERVE_TOKEN"
|
|
407
|
+
curl -N "$BASE_URL/api/events" \
|
|
408
|
+
-H "Authorization: Bearer $DC_SERVE_TOKEN"
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
`session.kind` distinguishes `agent` / `workflow`; a run's name, status and actual
|
|
412
|
+
result are in `session.workflow`. A repeated workflow creates another session;
|
|
413
|
+
POSTing another workflow to an already-started execution session is rejected.
|
|
414
|
+
|
|
415
|
+
For compatibility, the old operation body
|
|
416
|
+
`{"kind":"workflow","name":"Uppercase","inputs":{"Text":"hello"}}`
|
|
417
|
+
can still run inside an agent session. New clients should use the dedicated
|
|
418
|
+
workflow-run endpoint rather than mix conversations and manual runs.
|
|
419
|
+
|
|
420
|
+
Chat body: `{"kind":"chat","text":"Help me write…"}`.
|
|
421
|
+
Resume body: `{"kind":"resume"}`.
|
|
422
|
+
Cancel body: `{"operationId":"…"}`.
|
|
423
|
+
Workflow success is determined by `workflow_result.result`, not merely an ended
|
|
424
|
+
stream. Do not automatically retry operations after network errors: effects may
|
|
425
|
+
already have happened.
|
|
426
|
+
|
|
427
|
+
## Security and public exposure
|
|
428
|
+
|
|
429
|
+
This is for a **trusted operator, trusted harness and trusted users** sharing one
|
|
430
|
+
principal. A bearer token is not tenant isolation. Sessions have independent runtime
|
|
431
|
+
state, but share workspace files. Concurrent filesystem side effects require
|
|
432
|
+
harness-level coordination. No distributed writer leases are implemented.
|
|
433
|
+
|
|
434
|
+
**Bash is enabled by default in serve.** Existing DML `exec(bash(...), Result)`
|
|
435
|
+
and background processes can use it without another flag. To expose bash directly
|
|
436
|
+
to the Work assistant, declare `host_tools: [bash]` in `shell/1`. Both declaration
|
|
437
|
+
and host registration are required; undeclared tools are not exposed to the model.
|
|
438
|
+
The original host tool/approval wrapper, cancellation signal and SDK tool policy
|
|
439
|
+
are preserved. This does not expose arbitrary DML/authoring tools.
|
|
440
|
+
|
|
441
|
+
```bash
|
|
442
|
+
deepclause serve writing.dml --no-tools # disable host capabilities
|
|
443
|
+
deepclause serve writing.dml --tools bash # explicit selection
|
|
444
|
+
deepclause serve writing.dml --sandbox --require-sandbox
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
Only the supported `bash` capability is registered. **Info** reports whether
|
|
448
|
+
it is available to DML only, to the assistant as well, or disabled by the host.
|
|
449
|
+
Startup also prints the effective shell backend and whether it is sandboxed.
|
|
450
|
+
Without a sandbox, bash executes as your user account. Only serve trusted harnesses
|
|
451
|
+
to trusted users; use `--no-tools` when shell access is not needed.
|
|
452
|
+
|
|
453
|
+
`--sandbox` selects the **AgentVM Linux/WASM shell backend** for DML workflows,
|
|
454
|
+
background processes, and explicitly declared assistant bash tools. Each live
|
|
455
|
+
session lazily starts its own VM on its first bash call, mounts the workspace
|
|
456
|
+
read/write at `/workspace`, and disables guest networking by default. `--allow-network`
|
|
457
|
+
explicitly enables outbound VM TCP/UDP; `--no-allow-network` disables it. These
|
|
458
|
+
flags require `--sandbox`; they do not change a host shell's network policy.
|
|
459
|
+
Networking includes reachable host/private networks, not just the Internet. Model requests still
|
|
460
|
+
use the server's configured model backend, not guest networking. Bash calls within
|
|
461
|
+
one session share a command channel and are serialized; different sessions retain
|
|
462
|
+
independent VMs. Cancelling an active command or hitting its timeout resets that
|
|
463
|
+
VM and cancels pending commands rather than replaying them. Cancelling a queued
|
|
464
|
+
command does not interrupt another command. Saved processes are never restarted.
|
|
465
|
+
There is no fallback to an unsandboxed host shell if AgentVM fails to start.
|
|
466
|
+
`--no-tools` continues to disable bash even with `--sandbox`.
|
|
467
|
+
|
|
468
|
+
Work mode and worker isolation are not a security sandbox. `--require-sandbox`
|
|
469
|
+
fails if the effective shell boundary is unavailable; combine it with `--sandbox`
|
|
470
|
+
to select AgentVM explicitly. AgentVM/WASI is experimental, not a production
|
|
471
|
+
multi-tenant security boundary. Shell sandboxing does not isolate the HTTP server,
|
|
472
|
+
model provider, or all SDK operations. Native/workspace operations remain subject
|
|
473
|
+
to the SDK's existing boundaries and operator grants.
|
|
474
|
+
|
|
475
|
+
Default bind is loopback with a generated token. Explicit tokens must contain at
|
|
476
|
+
least 24 non-whitespace characters. Non-loopback always requires an explicit secret
|
|
477
|
+
and, by default, an expected public origin:
|
|
478
|
+
|
|
479
|
+
```bash
|
|
480
|
+
export DC_SERVE_TOKEN='a-long-random-secret-at-least-24-characters'
|
|
481
|
+
deepclause serve writing.dml --host 0.0.0.0 \
|
|
482
|
+
--public-url https://work.example.com --token-env DC_SERVE_TOKEN
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### Optional Host and Origin checks
|
|
486
|
+
|
|
487
|
+
Both checks are **enabled by default** and can be disabled independently:
|
|
488
|
+
|
|
489
|
+
- `--no-host-check` accepts requests addressed to other hostnames/IPs.
|
|
490
|
+
- `--no-origin-check` accepts a supplied `Origin` other than the canonical origin.
|
|
491
|
+
An absent Origin is already allowed for clients such as curl.
|
|
492
|
+
|
|
493
|
+
For a trusted deployment that needs access through multiple addresses:
|
|
494
|
+
|
|
495
|
+
```bash
|
|
496
|
+
export DC_SERVE_TOKEN="$(openssl rand -hex 32)"
|
|
497
|
+
deepclause serve writing.dml --host 0.0.0.0 --port 8080 \
|
|
498
|
+
--token-env DC_SERVE_TOKEN --no-host-check --no-origin-check
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
Choose a real hostname/IP in the browser, not `0.0.0.0`. `--public-url` is optional
|
|
502
|
+
only when **both** checks are disabled; when provided it remains the canonical
|
|
503
|
+
origin for startup links and API documentation. Disabling only one check leaves
|
|
504
|
+
the other enforced against that origin, so accepting alias Host headers alone
|
|
505
|
+
does not accept alias browser Origins on POST requests.
|
|
506
|
+
|
|
507
|
+
SDK callers use `startServe({ ..., hostCheck: false, originCheck: false })`.
|
|
508
|
+
These are startup options, not settings an Agent or HTTP client can change.
|
|
509
|
+
The CLI reports both states and warns when either check is disabled.
|
|
510
|
+
|
|
511
|
+
**This reduces DNS-rebinding/cross-origin protection.** Bearer authentication and
|
|
512
|
+
non-loopback token requirements are unchanged. It does not enable CORS, add
|
|
513
|
+
permissive preflight responses, relax CSP, grant sandbox/network access, or
|
|
514
|
+
remove the separate app-preview gateway checks. Use only on trusted networks
|
|
515
|
+
with trusted clients; prefer explicit origins and TLS for exposed deployments.
|
|
516
|
+
|
|
517
|
+
### App previews on a public plain-HTTP deployment
|
|
518
|
+
|
|
519
|
+
When the Work origin is not loopback, previews need a name browsers can reach
|
|
520
|
+
the per-app ports through:
|
|
521
|
+
|
|
522
|
+
```bash
|
|
523
|
+
deepclause serve app-agent.dml --host 0.0.0.0 --port 8080 \
|
|
524
|
+
--public-url http://laptop.example.ts.net:8080 --token-env DC_SERVE_TOKEN \
|
|
525
|
+
--sandbox --allow-network --allow-previews --preview-host laptop.example.ts.net
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
`--preview-host` is the explicit opt-in. It only names the origin; the server
|
|
529
|
+
still owns the per-app ports, one-time launch, cookie authentication, request/
|
|
530
|
+
response limits and blocked redirects described below. The Work page's CSP
|
|
531
|
+
frames that host on any port, and each app keeps its own origin.
|
|
532
|
+
|
|
533
|
+
Requirements and limits:
|
|
534
|
+
|
|
535
|
+
- Every preview port range must be reachable by the browser (e.g. all ports on a
|
|
536
|
+
tailnet or private LAN). A normal reverse proxy that forwards only `:8080`
|
|
537
|
+
cannot reach them.
|
|
538
|
+
- The preview gateway binds the same address as `--host` (for example `0.0.0.0`),
|
|
539
|
+
so remote clients can connect. Restrict that with firewall rules when needed.
|
|
540
|
+
- Plain HTTP only. An `https` Work origin needs TLS for every preview port, i.e.
|
|
541
|
+
a per-app hostname/certificate; that mode is not implemented. Keep previews on
|
|
542
|
+
loopback behind such a proxy, or host them on a separate plain-HTTP interface.
|
|
543
|
+
- Apps still must not be treated as trusted: keep the Work token out of them and
|
|
544
|
+
publish only what the VM is allowed to expose.
|
|
545
|
+
- Cookies are host-scoped, not port-scoped: the preview cookie lives on
|
|
546
|
+
`--preview-host`, the same host as the Work UI. It is HttpOnly and per-preview
|
|
547
|
+
random, and the Work UI authenticates with session storage rather than cookies.
|
|
548
|
+
|
|
549
|
+
### Local VM app previews
|
|
550
|
+
|
|
551
|
+
```bash
|
|
552
|
+
deepclause serve app-agent.dml --sandbox --allow-network --allow-previews
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
This opt-in supports loopback Work deployments by default, and remote plain-HTTP
|
|
556
|
+
deployments through `--preview-host <hostname>` (see above). Start an app bound to
|
|
557
|
+
`0.0.0.0` inside the session VM, then
|
|
558
|
+
publish its guest port in **Apps**, through the authenticated API, or from trusted
|
|
559
|
+
DML using `exec(bash(previewPort:3000), Result)`. Host bash tools expose this field
|
|
560
|
+
only when previews are enabled. To unpublish use
|
|
561
|
+
`exec(bash(closePreviewPort:3000), Result)`. Do not combine app actions with
|
|
562
|
+
`command`/`argv`. Publication is not a readiness check or a server launch.
|
|
563
|
+
|
|
564
|
+
Each app gets its own ephemeral HTTP origin (loopback by default), never a path
|
|
565
|
+
on the authenticated Work origin, so app code cannot read the Work UI's token,
|
|
566
|
+
cookies or storage. **Apps → Open preview**
|
|
567
|
+
mints a one-use URL (60-second validity) and establishes a session-lifetime
|
|
568
|
+
HttpOnly/SameSite cookie before loading the app. Never send the Work bearer token
|
|
569
|
+
to that origin. The proxy drops browser Authorization/Cookie and app Set-Cookie
|
|
570
|
+
headers; app HTML never executes on the Work origin. The sandboxed iframe has no
|
|
571
|
+
SDK bridge, top navigation/popups, service workers or external browser network
|
|
572
|
+
access. Root-relative assets and HTTP APIs work; WebSockets/HMR, CDN assets,
|
|
573
|
+
public publishing and remote/reverse-proxy previews are not supported yet.
|
|
574
|
+
|
|
575
|
+
Ports are integers 1024..65535, at most three per session; clients cannot choose
|
|
576
|
+
arbitrary target hosts or host bind ports. The internal TCP forward always binds
|
|
577
|
+
the gateway's loopback; the preview gateway itself listens on loopback unless
|
|
578
|
+
public hosting is enabled. Local OS processes can access loopback: this is not
|
|
579
|
+
multi-user/tenant isolation. Requests are bounded to 1 MiB, responses to 16 MiB,
|
|
580
|
+
and proxy idle timeouts to 30 seconds. External redirects are rejected.
|
|
581
|
+
|
|
582
|
+
Close publication to revoke its listeners/connections; it does not kill the guest
|
|
583
|
+
server process. Session close/interruption, VM reset and serve shutdown revoke all
|
|
584
|
+
previews. No app process or port forward is restored/replayed. Starting an app
|
|
585
|
+
with `... >/tmp/app.log 2>&1 </dev/null &` keeps its console output out of the
|
|
586
|
+
programmatic shell channel; inspect the log and actual HTTP response for readiness.
|
|
587
|
+
|
|
588
|
+
API (all require normal Work bearer authentication):
|
|
589
|
+
|
|
590
|
+
- `GET /api/sessions/{id}/previews`
|
|
591
|
+
- `POST /api/sessions/{id}/previews` with `{"port":3000}`
|
|
592
|
+
- `POST /api/sessions/{id}/previews/3000/launch` with `{}`
|
|
593
|
+
- `DELETE /api/sessions/{id}/previews/3000`
|
|
594
|
+
|
|
595
|
+
### Binding to a specific address or LAN
|
|
596
|
+
|
|
597
|
+
`--host` and `--port` control the listening socket independently of the expected
|
|
598
|
+
browser origin. Defaults: `--host 127.0.0.1 --port 8080`.
|
|
599
|
+
|
|
600
|
+
```bash
|
|
601
|
+
# Another local port:
|
|
602
|
+
deepclause serve writing.dml --host 127.0.0.1 --port 9090
|
|
603
|
+
# IPv6 loopback:
|
|
604
|
+
deepclause serve writing.dml --host ::1 --port 9090
|
|
605
|
+
|
|
606
|
+
# All IPv4 interfaces; replace the example LAN IP with this machine's address:
|
|
607
|
+
export DC_SERVE_TOKEN="$(openssl rand -hex 32)"
|
|
608
|
+
deepclause serve writing.dml --host 0.0.0.0 --port 9090 \
|
|
609
|
+
--public-url http://192.168.1.50:9090 --token-env DC_SERVE_TOKEN
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
Use a specific interface IP instead of `0.0.0.0` to bind only that interface.
|
|
613
|
+
Open the printed public URL; `0.0.0.0` is a bind address, not a browser destination.
|
|
614
|
+
Non-loopback bindings always require an explicit token; a public origin is also
|
|
615
|
+
required unless both request checks are explicitly disabled as described above.
|
|
616
|
+
Plain HTTP exposes the token to
|
|
617
|
+
the network: use it only on a trusted LAN, or use HTTPS via a reverse proxy.
|
|
618
|
+
The CLI prints the actual listening address/port separately from the public URL.
|
|
619
|
+
|
|
620
|
+
Use a TLS reverse proxy that preserves the public Host, disables buffering for
|
|
621
|
+
SSE, and allows long-lived event responses. Enabled Host/Origin checks are exact. No provider
|
|
622
|
+
credentials are sent to the browser; no login or arbitrary RPC endpoint exists.
|
|
623
|
+
|
|
624
|
+
## Development checks
|
|
625
|
+
|
|
626
|
+
```bash
|
|
627
|
+
npm run test:serve # builds worker/assets, then focused tests
|
|
628
|
+
npm run smoke:serve # Node >=22 + Google Chrome; CHROME overrides binary
|
|
629
|
+
npm run smoke:previews # real AgentVM app + Chrome isolation/cleanup checks
|
|
630
|
+
DC_TEST_AGENTVM=1 npx vitest run tests/serve-previews-vm.test.ts
|
|
631
|
+
npm test
|
|
632
|
+
npm run check:runtime
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
The SDK package includes UI assets and workers. No sibling web checkout, browser
|
|
636
|
+
WASM/Pyodide installation or frontend development server is needed at runtime.
|
|
637
|
+
|
|
638
|
+
## Agent inbox and headless subagent results
|
|
639
|
+
|
|
640
|
+
Agent shells can opt into `inbox: _{sources:[process]}` (Work contract 3). A declared
|
|
641
|
+
Work tool/hook captures `agent_self(Main)` and passes it to a child; the child uses
|
|
642
|
+
`agent_post(Main, message{text:Text, data:result{...}}, Id)`. Serve's session worker
|
|
643
|
+
queues the message durably, then schedules the ordinary hook/assistant turn through
|
|
644
|
+
its server-owned operation machinery. No SSE connection or browser is required.
|
|
645
|
+
The transcript labels the process sender; returning users see responses and unread
|
|
646
|
+
background counts. Human/tool approvals still wait for explicit input.
|
|
647
|
+
|
|
648
|
+
The inbox status panel provides Pause/Resume background. Pausing holds subsequent
|
|
649
|
+
messages; Stop cancels the current operation. Authenticated live-session control:
|
|
650
|
+
`POST /api/sessions/{id}/inbox` with `{"action":"pause"}` or
|
|
651
|
+
`{"action":"resume"}`. No API allows arbitrary cross-session posting. Limits,
|
|
652
|
+
checkpoint failures and hook errors pause delivery instead of silently retrying.
|
|
653
|
+
On server restart, running messages are interrupted and pending data is held until
|
|
654
|
+
human activity or explicit resume. Processes/services are never restarted.
|
|
655
|
+
|
|
656
|
+
Try from the SDK checkout:
|
|
657
|
+
|
|
658
|
+
```sh
|
|
659
|
+
deepclause serve sdk-examples/subagent-inbox.dml
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
Ask for one or more self-contained background tasks. Workers are bounded and
|
|
663
|
+
intentionally have no host/browsing tools. See [the inbox contract](WORK_AGENT_INBOX.md)
|
|
664
|
+
and [implementation plan](WORK_AGENT_INBOX_PLAN.md) for details.
|