deepclause-sdk 0.4.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 +191 -2
- package/dist/agent.d.ts +2 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +159 -28
- 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 +166 -156
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +3 -0
- package/dist/cli/config.js.map +1 -1
- 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/login.d.ts +2 -1
- package/dist/cli/login.d.ts.map +1 -1
- package/dist/cli/login.js +15 -2
- package/dist/cli/login.js.map +1 -1
- package/dist/cli/repl.d.ts +61 -1
- package/dist/cli/repl.d.ts.map +1 -1
- package/dist/cli/repl.js +618 -67
- 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/cli/set-backend.d.ts +2 -2
- package/dist/cli/set-backend.d.ts.map +1 -1
- package/dist/cli/set-backend.js +54 -8
- package/dist/cli/set-backend.js.map +1 -1
- package/dist/cli/work.d.ts +16 -0
- package/dist/cli/work.d.ts.map +1 -0
- package/dist/cli/work.js +45 -0
- package/dist/cli/work.js.map +1 -0
- package/dist/index.d.ts +9 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- 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 +2791 -302
- package/dist/prolog-src/deepclause_strings.pl +36 -3
- 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 +19 -1
- package/dist/repl/agent.d.ts.map +1 -1
- package/dist/repl/agent.js +44 -13
- package/dist/repl/agent.js.map +1 -1
- package/dist/repl/auth.d.ts +6 -3
- package/dist/repl/auth.d.ts.map +1 -1
- package/dist/repl/auth.js +55 -5
- package/dist/repl/auth.js.map +1 -1
- package/dist/repl/backend.d.ts +30 -0
- package/dist/repl/backend.d.ts.map +1 -1
- package/dist/repl/backend.js +309 -14
- package/dist/repl/backend.js.map +1 -1
- package/dist/repl/compaction.d.ts +2 -0
- package/dist/repl/compaction.d.ts.map +1 -1
- package/dist/repl/compaction.js +9 -0
- package/dist/repl/compaction.js.map +1 -1
- package/dist/repl/event-history.d.ts +4 -0
- package/dist/repl/event-history.d.ts.map +1 -0
- package/dist/repl/event-history.js +36 -0
- package/dist/repl/event-history.js.map +1 -0
- package/dist/repl/harness-tools.d.ts +32 -18
- package/dist/repl/harness-tools.d.ts.map +1 -1
- package/dist/repl/harness-tools.js +127 -34
- package/dist/repl/harness-tools.js.map +1 -1
- package/dist/repl/history.d.ts +66 -5
- package/dist/repl/history.d.ts.map +1 -1
- package/dist/repl/history.js +174 -8
- package/dist/repl/history.js.map +1 -1
- package/dist/repl/index.d.ts +38 -5
- package/dist/repl/index.d.ts.map +1 -1
- package/dist/repl/index.js +32 -1
- 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 +31 -0
- package/dist/repl/reference.d.ts.map +1 -0
- package/dist/repl/reference.js +144 -0
- package/dist/repl/reference.js.map +1 -0
- package/dist/repl/render.d.ts +3 -1
- package/dist/repl/render.d.ts.map +1 -1
- package/dist/repl/render.js +20 -0
- package/dist/repl/render.js.map +1 -1
- package/dist/repl/session.d.ts +199 -27
- package/dist/repl/session.d.ts.map +1 -1
- package/dist/repl/session.js +1471 -219
- 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/autocomplete.d.ts.map +1 -1
- package/dist/repl/tui/autocomplete.js +5 -1
- package/dist/repl/tui/autocomplete.js.map +1 -1
- package/dist/repl/tui/renderer.d.ts +2 -1
- package/dist/repl/tui/renderer.d.ts.map +1 -1
- package/dist/repl/tui/renderer.js +23 -4
- package/dist/repl/tui/renderer.js.map +1 -1
- package/dist/repl/tui/status-bar.d.ts +5 -2
- package/dist/repl/tui/status-bar.d.ts.map +1 -1
- package/dist/repl/tui/status-bar.js +8 -3
- package/dist/repl/tui/status-bar.js.map +1 -1
- package/dist/repl/tui/tool-pane.d.ts +1 -1
- package/dist/repl/tui/tool-pane.d.ts.map +1 -1
- package/dist/repl/tui/tool-pane.js +13 -7
- package/dist/repl/tui/tool-pane.js.map +1 -1
- package/dist/repl/tui/work-view.d.ts +10 -0
- package/dist/repl/tui/work-view.d.ts.map +1 -0
- package/dist/repl/tui/work-view.js +28 -0
- package/dist/repl/tui/work-view.js.map +1 -0
- 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 +69 -22
- package/dist/runner.js.map +1 -1
- package/dist/runtime-identity.json +10 -0
- 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 +265 -3008
- package/dist/system/assets/docs/DML_AUTHORING.md +151 -291
- package/dist/system/assets/docs/DML_BASICS.md +93 -0
- package/dist/system/assets/docs/DML_DEBUGGING.md +73 -0
- package/dist/system/assets/docs/DML_FORMS.md +94 -728
- package/dist/system/assets/docs/DML_MEDIA.md +63 -0
- package/dist/system/assets/docs/DML_PROCESSES.md +124 -0
- package/dist/system/assets/docs/DML_PYTHON.md +74 -0
- package/dist/system/assets/docs/DML_REFERENCE.md +353 -2012
- package/dist/system/assets/docs/DML_SHELL.md +249 -0
- package/dist/system/assets/docs/DML_TASKS.md +119 -0
- package/dist/system/assets/docs/HARNESS_EXAMPLES.md +255 -179
- package/dist/system/assets/docs/HARNESS_PATTERNS.md +65 -538
- package/dist/system/assets/docs/LOCAL_AGENT_PROMPT.md +186 -0
- package/dist/system/assets/docs/PROLOG_SNIPPETS.md +61 -154
- package/dist/system/assets/index.d.ts +1 -1
- package/dist/system/assets/index.d.ts.map +1 -1
- package/dist/system/assets/index.js +7 -0
- package/dist/system/assets/index.js.map +1 -1
- package/dist/system/environment.d.ts +5 -1
- package/dist/system/environment.d.ts.map +1 -1
- package/dist/system/environment.js +20 -10
- 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 +4 -1
- 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 +85 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/work/index.d.ts +92 -0
- package/dist/work/index.d.ts.map +1 -0
- package/dist/work/index.js +297 -0
- package/dist/work/index.js.map +1 -0
- 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 +35 -4
- 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 +2791 -302
- package/src/prolog-src/deepclause_strings.pl +36 -3
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# Work shell contract
|
|
2
|
+
|
|
3
|
+
Use a normal shell assistant for ordinary conversation, even with a custom
|
|
4
|
+
persona, welcome or tools. Write a DML chat loop only for explicitly custom
|
|
5
|
+
turn-by-turn control logic. A shell library needs no `agent_main`.
|
|
6
|
+
|
|
7
|
+
## Agent shell
|
|
8
|
+
|
|
9
|
+
```prolog
|
|
10
|
+
length_of(Text, N) :- string_length(Text, N).
|
|
11
|
+
label(Text, Label) :- prompt("Give a short title for: {Text}", string(Label)).
|
|
12
|
+
shell(_{
|
|
13
|
+
kind: agent,
|
|
14
|
+
system: "You are a concise writing assistant.",
|
|
15
|
+
host_tools: [],
|
|
16
|
+
tools: [_{name: "text_length", goal: "length_of", description: "Count characters.",
|
|
17
|
+
inputs: [_{name: "Text", type: string}], outputs: [_{name: "N", type: integer}]}],
|
|
18
|
+
workflows: [_{name: "Create title", goal: "label",
|
|
19
|
+
inputs: [_{name: "Text", type: string}], outputs: [_{name: "Label", type: string}]}],
|
|
20
|
+
welcome: "Ask about text, or create a title."
|
|
21
|
+
}).
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The Work assistant gets real typed tools plus `run_workflow` if workflows exist.
|
|
25
|
+
It does not get DML/authoring tools such as `execute`, `listing` or `define`.
|
|
26
|
+
Describe persona/domain in `system`; put capability semantics in tool descriptions.
|
|
27
|
+
`welcome` is Markdown. Users can edit this contract in the web Shell editor or in
|
|
28
|
+
Develop. TUI Work is entered with `deepclause repl --mode work --harness NAME`;
|
|
29
|
+
`/workflows` opens its chooser. Without a shell, use Develop or an explicit Run;
|
|
30
|
+
internal predicates are never automatically exported.
|
|
31
|
+
|
|
32
|
+
## Metadata names must be text, not variables
|
|
33
|
+
|
|
34
|
+
Write `name: "Query"`, `name: "Url"`, `name: "Report"` (or quoted atoms).
|
|
35
|
+
Bare capitalized `Query`, `Url`, `Report` are Prolog variables, not labels. They
|
|
36
|
+
produce unbound/empty runtime parameter names. The visual editor quotes names
|
|
37
|
+
for you; when authoring DML directly, include the quotes.
|
|
38
|
+
|
|
39
|
+
`end_turn` refuses an invalid shell before publishing a version. Keep the
|
|
40
|
+
transaction open, correct the declarations, then commit again. Full-source
|
|
41
|
+
editor saves are checked too. This validates the Work interface; executing a
|
|
42
|
+
backing predicate alone is not a substitute for validating its tool declaration.
|
|
43
|
+
|
|
44
|
+
## Inputs and outputs
|
|
45
|
+
|
|
46
|
+
For EVERY tool/workflow, actual predicate arguments are inputs followed by outputs,
|
|
47
|
+
in declared order. Arity = input count + output count. Manual starts ask only
|
|
48
|
+
inputs, leaving outputs unbound. Bind outputs and return; do not call `answer/1`
|
|
49
|
+
in place of returning them. An output cannot be left unbound just because text
|
|
50
|
+
was printed. Use zero outputs explicitly for a side-effect-only workflow.
|
|
51
|
+
|
|
52
|
+
Supported Work boundary types are string, integer, number, boolean and file.
|
|
53
|
+
A `file` input is a workspace-relative path supplied by the picker/upload, not raw
|
|
54
|
+
bytes or a raw Prolog term. Object/array boundary types are currently rejected;
|
|
55
|
+
use a JSON string or a file instead. General task/schema outputs still support
|
|
56
|
+
complex values. Runtime tool schemas are authoritative, not a wish list.
|
|
57
|
+
Old `args` is legacy input data only; author new shells with `inputs`/`outputs`.
|
|
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
|
+
|
|
108
|
+
## Workflows versus tools
|
|
109
|
+
|
|
110
|
+
A workflow is a recurring user task with a prescribed result, e.g. intake,
|
|
111
|
+
reporting or a review. Users can start it from the sidebar; the assistant can use
|
|
112
|
+
`run_workflow(name, inputs)`. A tool is a composable capability the ASSISTANT
|
|
113
|
+
chooses. Tools appear for discovery but cannot be run directly from the sidebar.
|
|
114
|
+
Do not export internal helpers, docs, schemas or all predicates indiscriminately.
|
|
115
|
+
|
|
116
|
+
`shell.tools` is NOT `tool/2`: the latter exposes a predicate to a nested agent
|
|
117
|
+
inside `task/N`, with a single last output and input types in its annotation.
|
|
118
|
+
A predicate may participate in both interfaces if needed, with one implementation.
|
|
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.
|
|
128
|
+
|
|
129
|
+
## Workflow-only shell
|
|
130
|
+
|
|
131
|
+
```prolog
|
|
132
|
+
workflow(_{name:"Uppercase",goal:"uppercase",
|
|
133
|
+
inputs:[_{name:"Text",type:string}],
|
|
134
|
+
outputs:[_{name:"Upper",type:string}]}).
|
|
135
|
+
uppercase(Text, Upper) :- string_upper(Text, Upper).
|
|
136
|
+
```
|
|
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
|
+
|
|
147
|
+
There is no assistant loop. A manual start executes exactly the selected workflow
|
|
148
|
+
with validated inputs and no intervening assistant call, for BOTH shell kinds.
|
|
149
|
+
Outputs are named typed values; no solution/unbound output/cancel/suspend is not
|
|
150
|
+
success. Active Work conversations are pinned to their program/script snapshot;
|
|
151
|
+
refresh opens a new one instead of mixing an old shell with new code.
|
|
152
|
+
Interactive workflows must run through foreground form/input handlers. Browser
|
|
153
|
+
scratch `execute` workers and worker-hosted processes do not support forms.
|
|
154
|
+
Test pure validation/headless paths separately from actual foreground form submits.
|
|
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
|
+
|
|
233
|
+
## Custom conversation
|
|
234
|
+
|
|
235
|
+
A custom DML `input/1` + `chat/1` loop is for a required protocol or per-turn
|
|
236
|
+
state, e.g. staged intake that validates each stage before advancing. Merely
|
|
237
|
+
asking for a conversational agent or changing its persona does not require it.
|
|
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.
|
|
240
|
+
Such loops must run in foreground with an input host, not inside scratch execute.
|
|
241
|
+
See `examples` section `custom-intake` for a minimal custom staged protocol.
|
|
242
|
+
|
|
243
|
+
## Authoring and validation
|
|
244
|
+
|
|
245
|
+
Define the shell together with the predicates it exposes in one transaction.
|
|
246
|
+
Validate goal names/arities, unique tool/workflow names, input/output types and
|
|
247
|
+
bound output values. Keep the shell small and its descriptions specific.
|
|
248
|
+
A shell change refreshes Work; an already-running process still has its old
|
|
249
|
+
harness snapshot. Do not assume a live process updates with edits.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Model calls, schemas and nested tools
|
|
2
|
+
|
|
3
|
+
Choose by tools, memory and output contract, not by which name sounds familiar.
|
|
4
|
+
|
|
5
|
+
## Selecting a model operation
|
|
6
|
+
|
|
7
|
+
| Operation | Context | Tools | Result |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| `prompt(Description, Type(Out))` | fresh; no memory read/write | no callable harness tools | typed output |
|
|
10
|
+
| `task(Description, Type(Out))` | DML harness memory; reply accumulates | declared nested tools, scoped explicitly | typed output |
|
|
11
|
+
| `llm(Messages, Reply)` | explicit message list (or supported text input) | none | raw text; no memory writeback |
|
|
12
|
+
| `chat(Message[, Reply])` | ongoing DML conversation | nested tools | conversational reply |
|
|
13
|
+
| `choose/rate/verify/judge` | explicit evidence/state | none | constrained semantic judgment |
|
|
14
|
+
|
|
15
|
+
For a normal Work assistant, use `shell/1`; `chat` is only for an explicitly
|
|
16
|
+
custom conversation protocol. `task/1` and `prompt/1` discard structured outputs;
|
|
17
|
+
prefer output-bearing forms when a later step needs the value.
|
|
18
|
+
|
|
19
|
+
## Typed outputs
|
|
20
|
+
|
|
21
|
+
A bare output variable is a string. Supported common wrappers:
|
|
22
|
+
`string(X)`, `integer(X)`, `number(X)`, `float(X)`, `boolean(X)`,
|
|
23
|
+
`list(string(Xs))`, `object(D)`, `schema(person, D)`,
|
|
24
|
+
`list(schema(person, Ds))`. Types are checked by the runtime, not just prose.
|
|
25
|
+
`media(X)` is image generation, not a general file output, and needs an image backend.
|
|
26
|
+
|
|
27
|
+
```prolog
|
|
28
|
+
schema(person, [field(name, string, required), field(age, integer, default(0))]).
|
|
29
|
+
extract_person(Text, Person) :-
|
|
30
|
+
prompt("Extract a person from: {Text}", schema(person, Person)).
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Schema field types include primitives, `list(Type)` and nested `schema(Name)` /
|
|
34
|
+
`schema(Name, _)`. Defaults fill missing fields; missing required/wrong-typed
|
|
35
|
+
fields fail validation; undeclared fields are retained. `schema_fill/3` applies a
|
|
36
|
+
schema to an existing dict. Keep one structured result per conceptual step.
|
|
37
|
+
Multiple typed outputs are possible; use the actual argument names consistently.
|
|
38
|
+
|
|
39
|
+
## Memory
|
|
40
|
+
|
|
41
|
+
Authoring conversation, Work chat and DML harness memory are different stores.
|
|
42
|
+
A task sees ONLY harness memory (prior DML `system`, `user`, `task` messages),
|
|
43
|
+
not the authoring user's whole conversation. Pass the input explicitly.
|
|
44
|
+
Consecutive tasks accumulate conversation memory; prompts neither read nor change
|
|
45
|
+
it. Do not assume a typed result is restated in assistant prose or all tool results
|
|
46
|
+
remain in memory; pass the actual bound outputs explicitly to the next step.
|
|
47
|
+
|
|
48
|
+
```prolog
|
|
49
|
+
explain(Text, Report) :-
|
|
50
|
+
with_fresh_memory((
|
|
51
|
+
task("Find the main claim: {Text}", string(Claim)),
|
|
52
|
+
task("Explain the claim using only {Text}: {Claim}", string(Report))
|
|
53
|
+
)).
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`with_fresh_memory/1` isolates a group: its tasks share memory WITH EACH OTHER,
|
|
57
|
+
then the original memory is restored. `system/1` and `user/1` changes are
|
|
58
|
+
backtrackable. A task inside a nested `tool/N` engine starts fresh: context must
|
|
59
|
+
be an input or supplied with `system/1` inside that body. A process has its own
|
|
60
|
+
memory snapshot. Attached media is harness memory, so a fresh `prompt/N` will
|
|
61
|
+
not see an image attached for a task.
|
|
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
|
+
|
|
69
|
+
## Nested tools
|
|
70
|
+
|
|
71
|
+
Host registration is NOT nested-agent exposure. `exec(python(...), R)` calls a
|
|
72
|
+
host capability from DML. To offer a capability to a nested task, define the
|
|
73
|
+
predicate AND its thin annotation:
|
|
74
|
+
|
|
75
|
+
```prolog
|
|
76
|
+
length_of(Text, N) :- string_length(Text, N).
|
|
77
|
+
tool(length_of(Text, N), "Count text characters.", [string]) :- length_of(Text, N).
|
|
78
|
+
inspect(Text, Reply) :-
|
|
79
|
+
with_tools([length_of], task("Use length_of on {Text}; report its result.", string(Reply))).
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The annotation and delegate share name AND arity. Exactly one output, LAST;
|
|
83
|
+
all earlier arguments are inputs. The optional type list describes input types
|
|
84
|
+
only (default string). A write capability needs e.g. `(Path, Content, Result)`,
|
|
85
|
+
not `(Path, Content)`. Several result fields belong in a dict.
|
|
86
|
+
Use names in `with_tools`, not indicators. `without_tools/2` excludes names.
|
|
87
|
+
Tool-free tasks can use `with_tools([], task(...))`; task result/finish machinery
|
|
88
|
+
is internal, not a harness tool you must write. Built-in form tools are otherwise
|
|
89
|
+
available to tasks, so scope non-form work.
|
|
90
|
+
|
|
91
|
+
Do not implement the work ONLY inside an annotation: DML callers invoke the real
|
|
92
|
+
predicate. Do not advertise an LLM step as the very tool offered inside its own
|
|
93
|
+
task; keep it a skill or explicitly exclude that tool to prevent self-delegation.
|
|
94
|
+
`shell.tools` is a DIFFERENT, explicit Work-agent interface; no annotation is
|
|
95
|
+
needed unless a nested task needs the same capability.
|
|
96
|
+
|
|
97
|
+
## Data and evidence
|
|
98
|
+
|
|
99
|
+
Interpolate bound DML data with `{Var}` in task/prompt descriptions. Include the
|
|
100
|
+
actual input in every step; variable names alone do not supply their values.
|
|
101
|
+
Use typed extraction, then deterministic guards. A successful model response is
|
|
102
|
+
not evidence that a file was saved or an API action completed. Inspect the host
|
|
103
|
+
result, check `exitCode` for Python, and do not ask a model to fill missing data.
|
|
104
|
+
Use `dict_field/3,4` for varying model keys, `get_dict/3` for keys you control,
|
|
105
|
+
and `json_get/3,4` / `json_gets/3` for paths and projections.
|
|
106
|
+
|
|
107
|
+
## Judgments and models
|
|
108
|
+
|
|
109
|
+
`choose(State, Question, Options, Choice)` returns an option atom.
|
|
110
|
+
`rate(State, Question, Levels, Level)` returns a supplied level.
|
|
111
|
+
`verify(State, Question, Truth)` returns `yes | no | unknown`; `probability/3`
|
|
112
|
+
returns a number; `holds/2` succeeds for yes. `judge(State, Specs)` batches
|
|
113
|
+
questions such as `choose(Question, Options)-Choice` in one request.
|
|
114
|
+
Judgments do not see task memory or images. Supply observed evidence as State;
|
|
115
|
+
`unknown` is not no, and neither is a failed goal.
|
|
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.
|