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
|
@@ -1,299 +1,159 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
`
|
|
51
|
-
|
|
52
|
-
**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
**Start small, then improve.** Write the smallest harness that answers the actual
|
|
62
|
-
request end to end — often a single predicate — run it on a real input, and show
|
|
63
|
-
the user the result *before* extending it. Say what it does, what it does not do
|
|
64
|
-
yet, and what you would add next, then let the next request decide. A harness grows
|
|
65
|
-
in the direction the user actually takes it.
|
|
66
|
-
|
|
67
|
-
Adding capability speculatively is the expensive mistake, and it costs more here
|
|
68
|
-
than in a normal codebase: every predicate is part of the harness the next turn has
|
|
69
|
-
to reason about, and every helper is one more thing the model can be offered as a
|
|
70
|
-
tool. Do not write an error taxonomy before an error has occurred, retry and
|
|
71
|
-
fallback policies before something has failed, caching or configuration layers
|
|
72
|
-
before there is a reason, or a predicate per case for cases you have not seen.
|
|
73
|
-
Prefer the smallest change that makes the failing input work.
|
|
74
|
-
|
|
75
|
-
Signs you are overengineering:
|
|
76
|
-
|
|
77
|
-
- a predicate with one caller whose arguments are all literals from the request;
|
|
78
|
-
- an abstraction (a schema, an options list, a dispatch table) built for a single
|
|
79
|
-
shape or a single value;
|
|
80
|
-
- a helper "framework" written before the first end-to-end run;
|
|
81
|
-
- generalizing across cases that no one has asked for yet;
|
|
82
|
-
- a harness that does not run yet, because the parts are still being made tidy.
|
|
83
|
-
|
|
84
|
-
A small change is also easier to trust: each commit is one reviewable unit, the
|
|
85
|
-
`end_turn` probes report on a small surface, and `rollback` stays cheap. A harness
|
|
86
|
-
that is incomplete but working is a better answer than one that is complete and
|
|
87
|
-
unverified.
|
|
88
|
-
|
|
89
|
-
**Do not parse in DML — shell out or ask the model.** Prolog string handling is
|
|
90
|
-
the fiddliest thing here, and a hand-rolled parser (`sub_string/5`,
|
|
91
|
-
`split_string/4`, `atom_concat/3`, `format/2`, an accumulator) is the easiest way
|
|
92
|
-
to write DML that looks right and is quietly wrong. Split the work by what it is.
|
|
93
|
-
Mechanical work — pull a field, change a format, count, filter — belongs in a
|
|
94
|
-
**helper script** (`script_file/2` + `exec(bash(argv: [...]))`), which is testable
|
|
95
|
-
outside DML and written in a language made for text; have it emit **JSON** and read
|
|
96
|
-
it with `json_get/3`/`json_gets/3`/`json_text/2` instead of splitting stdout.
|
|
97
|
-
Work that needs *understanding* — find the field named X, classify, summarise —
|
|
98
|
-
belongs in a **model call** with a typed output (`task("…", list(string(Items)))`,
|
|
99
|
-
`schema/2`, `choose`/`rate`/`verify`). DML sequences and checks; it does not parse.
|
|
100
|
-
|
|
101
|
-
**Prefer orchestration over algorithms.** A skill should read as a short
|
|
102
|
-
sequence of steps. Describe each step with `task/N` (which sees the conversation
|
|
103
|
-
memory) or `prompt/N` (fresh context) and let the model extract, classify,
|
|
104
|
-
summarise, or decide; keep the Prolog between the steps to simple guards
|
|
105
|
-
(`->`, `;`, `once/1`, `==`, `\==`), `member/2`, `between/3`, `format/2`, and
|
|
106
|
-
small arithmetic. Reach for deep recursion, hand-rolled list algorithms, CLP, or
|
|
107
|
-
`assert`/`retract` only when the task is genuinely algorithmic — and prefer a
|
|
108
|
-
one-shot `execute` goal over committing it as a skill. DML is the orchestration
|
|
109
|
-
layer, not the logic library.
|
|
110
|
-
|
|
111
|
-
## 1. Skills vs one-shot work
|
|
112
|
-
|
|
113
|
-
A harness is a library of reusable **capabilities**, not a record of what you
|
|
114
|
-
did. Most requests mix two things, and you must separate them:
|
|
115
|
-
|
|
116
|
-
- **A reusable capability** — worth a named, documented, tested predicate. It
|
|
117
|
-
takes its inputs as arguments and works for any caller (`describe_image(Path,
|
|
118
|
-
Text)`, `tally(List, Counts)`).
|
|
119
|
-
- **A one-off action** — the concrete step for *this* request. Run it now with
|
|
120
|
-
an `execute` goal or `bash`; do not commit it as a predicate.
|
|
121
|
-
|
|
122
|
-
Example — "find the latest image in `~/Downloads` and tell me what's on it":
|
|
123
|
-
run the "find/copy the latest file" step once in the turn, and add only
|
|
124
|
-
`describe_image(Path, Text)` as the skill. Finding a latest file, copying files
|
|
125
|
-
around, moving data, or any single concrete invocation is a task, not a skill.
|
|
126
|
-
|
|
127
|
-
Never bake environment-specific values into a predicate: no host paths
|
|
128
|
-
(`/home/...`), machine-specific directories, or fixed filenames — a skill takes
|
|
129
|
-
them as arguments. A predicate that exists only to be called once, with literals
|
|
130
|
-
frozen in, is a script in disguise.
|
|
131
|
-
|
|
132
|
-
## 2. Only use tools from the catalog
|
|
133
|
-
|
|
134
|
-
The HOST TOOL CATALOG above is the complete set of `exec(...)` capability tools.
|
|
135
|
-
Do not invent names — there is no `calculator`, `fetch_url`, `web_search`, or
|
|
136
|
-
`vm_exec` unless the catalog lists it. By default the only capability tool is
|
|
137
|
-
**`bash`**.
|
|
138
|
-
|
|
139
|
-
**Prefer the shell for file I/O.** Use `bash` for reading, writing, copying, and
|
|
140
|
-
converting files. The DML file predicates (`read_file/2`, `open/3`,
|
|
141
|
-
`read_string/3`, `write_file/2`, `make_directory_path/1`, `directory_files/2`, …)
|
|
142
|
-
are for when the content must be bound and reasoned over **inside Prolog** — not
|
|
143
|
-
for moving bytes around. Reading a file into DML just to shell it out again is a
|
|
144
|
-
smell.
|
|
145
|
-
|
|
146
|
-
## 3. Scripts are files, linked from the harness
|
|
147
|
-
|
|
148
|
-
Materialize a script by running a DML goal with the `execute` tool — for example
|
|
149
|
-
`make_directory_path("scripts"), write_file("scripts/x.py", "…")` — then link it
|
|
150
|
-
with `script_file/2` and run it with `bash`. `write_file/2` writes to the
|
|
151
|
-
workspace immediately and does **not** create parent directories.
|
|
152
|
-
`script_file/2` is just a fact: it tells `export` which files belong to the
|
|
153
|
-
harness. Use a literal workspace-relative path and one fact per name. `export harness.zip` bundles the
|
|
154
|
-
`.dml` plus every linked file; `export harness.dml` inlines them so the single
|
|
155
|
-
file stays portable.
|
|
156
|
-
|
|
157
|
-
Untrusted data (URLs, file contents, user text) goes through a file or `stdin`,
|
|
158
|
-
never interpolated into the shell command string. See `HARNESS_EXAMPLES.md` §1.
|
|
159
|
-
|
|
160
|
-
A linked script is for a genuinely external capability (a library, `ffmpeg`, an
|
|
161
|
-
API) — not a substitute for a shell command you run once, and not one script per
|
|
162
|
-
request. When a script is the capability, it is a component: parameterize it and
|
|
163
|
-
document it with `doc/2`.
|
|
164
|
-
|
|
165
|
-
## 4. Annotate the harness (self-describing)
|
|
166
|
-
|
|
167
|
-
Keep the harness self-describing. `module_doc/1` is the harness's **skill
|
|
168
|
-
description** — the one line that says what the harness does and when to use it,
|
|
169
|
-
the same role a skill's `description` plays for routing. Write it like
|
|
170
|
-
frontmatter, not like a title:
|
|
1
|
+
# Authoring a living harness
|
|
2
|
+
|
|
3
|
+
Start small, then improve. Use the smallest end-to-end design that satisfies the
|
|
4
|
+
request, verify it on real input and show the user. Reuse existing predicates;
|
|
5
|
+
do not build speculative abstractions, duplicate helpers or a predicate per one-off
|
|
6
|
+
request. A harness is reusable capabilities, not a log of everything performed.
|
|
7
|
+
|
|
8
|
+
## Design and inspect
|
|
9
|
+
|
|
10
|
+
Call `listing(filter: "all")` first, then relevant `Name/Arity` entries.
|
|
11
|
+
Walk the user through a short plan: inputs/defaults, steps, reused workflows,
|
|
12
|
+
outputs, real evidence sources, effects, missing capabilities and test strategy.
|
|
13
|
+
Ask focused material questions with suggested defaults, then wait for approval
|
|
14
|
+
BEFORE transactions, file writes, execution or publication. Do not treat an initial
|
|
15
|
+
request as agreement on an unseen design. Discuss and agree the plan in the normal
|
|
16
|
+
conversation, then implement it. After a material scope change, agree a revised
|
|
17
|
+
plan. Do not keep reopening settled choices.
|
|
18
|
+
Normal conversational agents use `shell/1` plus tools/workflows, not a custom loop.
|
|
19
|
+
Use explicit argument modes and typed model outputs from the first small version.
|
|
20
|
+
|
|
21
|
+
Simple exact logic stays in DML; substantial parsing/file algorithms belong in
|
|
22
|
+
scripts; semantic work uses typed prompt/task calls. Choose by actual need, not
|
|
23
|
+
by a blanket ban on Prolog or a blanket preference for models. Read `patterns`
|
|
24
|
+
for a matching small shape and `examples` for a complete tested one.
|
|
25
|
+
|
|
26
|
+
## Common workflow building blocks
|
|
27
|
+
|
|
28
|
+
- **Reuse:** inspect `reference(topic: "workflows")` for host-supplied names,
|
|
29
|
+
descriptions, typed inputs/outputs and revision pins before creating a duplicate.
|
|
30
|
+
Same-module helpers are ordinary predicate calls. With the serve host grant,
|
|
31
|
+
`run_workflow("Existing name", _{'Text':Text}, R)` invokes another workflow;
|
|
32
|
+
require `get_dict(ok,R,true)`, then `get_dict(outputs,R,Outputs)` and extract
|
|
33
|
+
its named output. Child runtimes close on return; reuse completed outputs, not
|
|
34
|
+
detached process handles. On failure inspect status/error and stop or report it; never
|
|
35
|
+
claim success. This host capability is not universally available in SDK/browser
|
|
36
|
+
embeddings. It does not import code or grant another workflow's tools.
|
|
37
|
+
- **Retrieval pipeline:** choose approved feeds/endpoints or existing collectors;
|
|
38
|
+
retrieve with a registered tool, set request/response/time/count bounds, extract
|
|
39
|
+
dated evidence + source URLs + retrieval time, filter/deduplicate, then synthesize
|
|
40
|
+
and cite only that evidence. A tool-free prompt/llm is NOT web search. Never
|
|
41
|
+
replace fresh evidence with model knowledge. Fail honestly on no/failed evidence.
|
|
42
|
+
Fixture tests validate transformations, not live retrieval or factual freshness.
|
|
43
|
+
- **Scripts/files:** inspect `tools` for the actual registry. If Bash exists use
|
|
44
|
+
`exec(bash(argv:["python3","scripts/collect.py",Topic]),R)`, inspect exitCode,
|
|
45
|
+
stdout and stderr; throw/report nonzero exit, do not summarize errors as results.
|
|
46
|
+
`run_script/3` checks the exit code and parses JSON with a granted Bash/Python
|
|
47
|
+
backend. Link reusable code with script_file/2; pass arguments as argv, not shell
|
|
48
|
+
interpolation. No granted interpreter means script execution is unavailable.
|
|
49
|
+
- **Typed model stages:** deterministic validation/filtering in DML/scripts;
|
|
50
|
+
`prompt(...,string(Summary))` for evidence-grounded isolated synthesis, task for
|
|
51
|
+
explicitly scoped tools/memory. Pass evidence as data, not trusted instructions.
|
|
52
|
+
- **Inputs/results:** keep a small typed interface, useful field descriptions,
|
|
53
|
+
defaults for truly optional inputs, and named outputs (not answer/1). Persist
|
|
54
|
+
deliverables at workspace-relative unique paths; keep secrets out of source.
|
|
55
|
+
- **Effects/schedules:** bound work, make effects single-solution, propagate errors
|
|
56
|
+
and cancellation; no implicit retries. Publishing does not run or schedule it.
|
|
57
|
+
|
|
58
|
+
## Clock and today
|
|
59
|
+
|
|
60
|
+
No Bash is needed for the runtime UTC date:
|
|
171
61
|
|
|
172
62
|
```prolog
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
63
|
+
today_utc(Date) :-
|
|
64
|
+
get_time(Stamp),
|
|
65
|
+
stamp_date_time(Stamp, DT, 'UTC'),
|
|
66
|
+
format_time(string(Date), "%Y-%m-%d", DT).
|
|
177
67
|
```
|
|
178
68
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
no predicates is still a valid skill: it advertises the capability while the
|
|
183
|
-
body is empty.
|
|
184
|
-
- `tool(Head, "desc") :- Body.` — **an annotation, not an implementation**: it
|
|
185
|
-
exposes an existing predicate to the nested agent in `task/N`. Define the
|
|
186
|
-
predicate normally and delegate
|
|
187
|
-
(`tool(count_words(File, Count), "…") :- count_words(File, Count).`), so the
|
|
188
|
-
same predicate is callable from `execute` / `/goal` **and** from `task/N`. Logic
|
|
189
|
-
placed only inside `tool/2` is unreachable from `execute` (the loader asserts
|
|
190
|
-
`tool(Head)`, never `Head`).
|
|
191
|
-
- Annotate **capabilities** (file I/O, search, a script) that a nested agent
|
|
192
|
-
should use — not the LLM steps themselves. A `tool/2` whose implementation
|
|
193
|
-
calls `task/N` and advertises the same job is offered to the agent inside that
|
|
194
|
-
`task/N`, which then calls it. Absent the tool call stack, wrapper predicates
|
|
195
|
-
are the same job twice; keep the step a skill, or scope the task with
|
|
196
|
-
`without_tools([Head], task(…))`.
|
|
197
|
-
- `doc(Name/Arity, Text)` — one fact per skill, helper, or tool; terse, with
|
|
198
|
-
arguments (`+in` / `-out`) and an example goal.
|
|
199
|
-
|
|
200
|
-
They are shown in the manifest (so the next turn sees them), in `listing`, and
|
|
201
|
-
survive `export`. When you change a predicate, update its `doc/2`; when the
|
|
202
|
-
harness's purpose changes, update `module_doc/1`.
|
|
203
|
-
|
|
204
|
-
## 5. Media (images)
|
|
205
|
-
|
|
206
|
-
Images are **workspace files**, referenced by `media(Path, Mime)`; the bytes
|
|
207
|
-
never enter Prolog or conversation memory. Read a reference with `read_media/2`
|
|
208
|
-
and put it in context with `attach_media/1`; the next `task/N` sends it to the
|
|
209
|
-
model as an image block:
|
|
69
|
+
For a simple "today" workflow compute it internally, rather than requiring a date
|
|
70
|
+
input. This engine has no tzdata: `stamp_date_time/3` takes `'UTC'` or an integer
|
|
71
|
+
offset, so name a market zone through `zone_date_time/3` (DST-correct) instead:
|
|
210
72
|
|
|
211
73
|
```prolog
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
task("Describe the attached image in one sentence.", Text).
|
|
74
|
+
market_date(Zone, Date) :-
|
|
75
|
+
get_time(Stamp), zone_date_time(Stamp, Zone, DT),
|
|
76
|
+
format_time(string(Date), "%Y-%m-%d", DT).
|
|
216
77
|
```
|
|
217
78
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
call), and do not spawn for a single model call.
|
|
79
|
+
`local_date_time(Stamp, DT)` follows the host zone and `zone_offset(Zone, Stamp, Off)`
|
|
80
|
+
exposes the offset. If a date override is useful declare a string default `""` and
|
|
81
|
+
explicitly interpret empty/`"today"`. Preserve an explicit valid ISO date. UTC
|
|
82
|
+
date, a market's local date and the last trading session are different policies;
|
|
83
|
+
agree which one is needed. A fixed prompt timestamp is not a trading calendar.
|
|
84
|
+
|
|
85
|
+
## Draft versus live validation
|
|
86
|
+
|
|
87
|
+
Read `tools` for the actual registry. In serve, drafts inherit the configured host
|
|
88
|
+
tools, sandbox and network policy: Bash works when enabled, including without a
|
|
89
|
+
sandbox. Commands, network requests, messages and composed workflow calls are real.
|
|
90
|
+
Receive permissions, explicit new-Agent approvals and disabled tools still apply.
|
|
91
|
+
The separate draft directory protects source ownership, not the host from effects.
|
|
92
|
+
Scripts run with that directory as cwd; selected file inputs are copied there.
|
|
93
|
+
Private draft downloads are local presentation rather than published links.
|
|
94
|
+
Agree on bounded effectful tests in the normal conversation; prefer fixtures when
|
|
95
|
+
adequate and never claim fixture tests prove live retrieval. Transactions do not
|
|
96
|
+
undo shell/file/network/message effects. On an unsandboxed host the network flag
|
|
97
|
+
is not a firewall; AgentVM networking still follows the server's network setting.
|
|
98
|
+
|
|
99
|
+
## Transactions
|
|
100
|
+
|
|
101
|
+
`begin_turn` opens a snapshot; call it once, not before every define. `define`
|
|
102
|
+
and `delete` are refused without an open transaction. `end_turn` validates and
|
|
103
|
+
commits a version; `rollback` discards the open edit. After committing, open a
|
|
104
|
+
new transaction before editing again. Check per-call results and end_turn warnings.
|
|
105
|
+
`committed: false` or no changed predicates means the intended edit may not have
|
|
106
|
+
landed. Verify `listing` rather than asserting it worked.
|
|
107
|
+
|
|
108
|
+
Change the module only through those tools. Do not consult/load a workspace DML
|
|
109
|
+
file to bypass edits. A system library directive is different from importing a
|
|
110
|
+
user DML file. The user can load a harness as a separate action.
|
|
111
|
+
|
|
112
|
+
## Define targets
|
|
113
|
+
|
|
114
|
+
`define(head, clauses)` adds a NEW or replaces EXISTING complete predicate block.
|
|
115
|
+
Head is an indicator `"foo/2"` or actual head `"foo(A, B)"`, not a function name
|
|
116
|
+
whose arity you hope the tool infers. The block must define the target and may
|
|
117
|
+
include related predicates/annotations. All clauses end with their own period.
|
|
118
|
+
Preserve ordering; replacing a recursive predicate requires all its clauses.
|
|
119
|
+
|
|
120
|
+
For keyed annotations, use the actual two-argument head:
|
|
121
|
+
`define("doc(foo/2, _)", "doc(foo/2, \"...\").")`.
|
|
122
|
+
`doc(foo/2)` would name doc/1 and is rejected. `doc/2`, `schema/2`, `script_file/2`
|
|
123
|
+
merge by key so other entries survive. Changing foo/3 to foo/2 creates a different
|
|
124
|
+
predicate: delete the old one/doc key and define the new one in one transaction.
|
|
125
|
+
|
|
126
|
+
## Delete targets
|
|
127
|
+
|
|
128
|
+
- `delete("foo/2")`: whole predicate and its associated nested tool annotation.
|
|
129
|
+
- `delete("tool:foo/2")`: nested tool annotation, keeping delegate.
|
|
130
|
+
- `delete("doc:foo/2")`: one documentation entry.
|
|
131
|
+
- `delete("schema:person")`: one schema key.
|
|
132
|
+
- `delete("script_file:extract_py")`: one script link, not the file.
|
|
133
|
+
|
|
134
|
+
Missing annotation keys are errors. No assertion/retraction tools are offered.
|
|
135
|
+
Use define with the complete remaining clause set to remove one clause.
|
|
136
|
+
Script link names must differ from all user predicate names; prefer `_py` or
|
|
137
|
+
`script_` link names, not the predicate they implement.
|
|
138
|
+
|
|
139
|
+
## Documentation and scripts
|
|
140
|
+
|
|
141
|
+
`module_doc(Text)` describes purpose/when to use the harness. `doc(Name/Arity, Text)`
|
|
142
|
+
records inputs/outputs and an example goal; count every actual predicate argument.
|
|
143
|
+
`script_file(Name, Path)` links a workspace file for export. Write a script once
|
|
144
|
+
with the authoring write_file tool, then link/call it. Do not repeatedly overwrite
|
|
145
|
+
helper source every time a workflow runs. Unlinked files are not promised portable.
|
|
146
|
+
Do not hardcode user-specific host paths or secrets in code/facts.
|
|
147
|
+
|
|
148
|
+
## Test and hand over
|
|
149
|
+
|
|
150
|
+
A small pure validation test, actual bounded input, error case and cancellation
|
|
151
|
+
case where relevant are enough for the first version. Side effects must be
|
|
152
|
+
intentional and single-solution. Debug intermediate values with output/1 rather
|
|
153
|
+
than adding more model steps. Foreground form workflows cannot be exercised in
|
|
154
|
+
browser scratch execute; ask for a foreground run and test pure rules separately.
|
|
155
|
+
|
|
156
|
+
End_turn warnings are contract evidence, not a reason to add bogus alias predicates
|
|
157
|
+
to satisfy stale docs. Correct the annotation or arity. Clean up fixtures and test
|
|
158
|
+
processes you created, but never delete unrelated user files. Summarize what was
|
|
159
|
+
observed, what is still unverified and how to run it.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# DML basics
|
|
2
|
+
|
|
3
|
+
DML is Prolog with host-interpreted operations for models, tools, forms and
|
|
4
|
+
processes. A harness is a library; `agent_main/N` is optional for positional runs.
|
|
5
|
+
Read these contracts when syntax or failure behavior is uncertain.
|
|
6
|
+
|
|
7
|
+
## Terms and arguments
|
|
8
|
+
|
|
9
|
+
Variables start uppercase or `_`; lowercase words are atoms, and double quotes
|
|
10
|
+
are strings. `'two words'` is a quoted atom, not a string. `true` and `false`
|
|
11
|
+
are atoms. A bare `_` is a fresh anonymous variable on every occurrence.
|
|
12
|
+
Lists are `[a,b,c]` or `[Head|Tail]`; dicts are `_{name: "Ada", age: 36}` with
|
|
13
|
+
ATOM keys. Read controlled keys with `get_dict(name, D, X)`, varying model keys
|
|
14
|
+
with `dict_field(D, name, X)`.
|
|
15
|
+
|
|
16
|
+
Predicates are relations, not functions. `greet("Ada", Greeting)` supplies an
|
|
17
|
+
input and leaves the output variable to be bound. `greet/2` counts BOTH
|
|
18
|
+
arguments. `greet(+Name, -Text)` is documentation for intended modes.
|
|
19
|
+
Do not call `Text = greet("Ada")` expecting evaluation.
|
|
20
|
+
|
|
21
|
+
## Clauses and goals
|
|
22
|
+
|
|
23
|
+
A fact states a relation; a rule gives a body that must succeed:
|
|
24
|
+
|
|
25
|
+
```prolog
|
|
26
|
+
team(billing).
|
|
27
|
+
team(orders).
|
|
28
|
+
greet(Name, Text) :- format(string(Text), "Hello ~w", [Name]).
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Every fact/rule ends with a period, including `doc/2`, `schema/2`, `script_file/2`
|
|
32
|
+
and `shell/1`. Newlines alone do not separate clauses. `%` starts a line comment.
|
|
33
|
+
A query such as `greet("Ada", X)` runs the body and returns `X = "Hello Ada"`.
|
|
34
|
+
A predicate may have several clauses; their written order matters.
|
|
35
|
+
|
|
36
|
+
## Unification and arithmetic
|
|
37
|
+
|
|
38
|
+
`X = Y` unifies terms, binding variables if possible. `X = 1 + 2` binds a TERM,
|
|
39
|
+
not 3. `X is 1 + 2` evaluates arithmetic; inputs must be bound numbers.
|
|
40
|
+
`A =:= B` compares evaluated numbers. `A == B` tests identical terms without
|
|
41
|
+
binding; `A \== B` tests non-identity now. `dif(A, B)` constrains them to remain
|
|
42
|
+
different. A string `"yes"` and atom `yes` are not identical.
|
|
43
|
+
|
|
44
|
+
Use `number_string/2` or `atom_string/2` deliberately at a type boundary; do not
|
|
45
|
+
sprinkle conversions blindly. Model type wrappers bind actual numbers/booleans.
|
|
46
|
+
|
|
47
|
+
## Control flow
|
|
48
|
+
|
|
49
|
+
`A, B` is conjunction, `A ; B` disjunction. Parenthesize branching:
|
|
50
|
+
|
|
51
|
+
```prolog
|
|
52
|
+
size_label(Text, Label) :-
|
|
53
|
+
string_length(Text, N),
|
|
54
|
+
( N > 100 -> Label = long ; Label = short ).
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`\+ Goal` means the goal cannot be proved under current bindings. It is not
|
|
58
|
+
semantic truth or a model judgment. `catch(Goal, E, Recovery)` catches EXCEPTIONS,
|
|
59
|
+
not ordinary failure. `throw(Error)` raises an exception.
|
|
60
|
+
|
|
61
|
+
## Failure and determinism
|
|
62
|
+
|
|
63
|
+
A false guard or missing relation yields zero solutions; it may not throw.
|
|
64
|
+
`findall(X, Goal, Xs)` yields `[]` for no solutions, while `setof`/`bagof` fail.
|
|
65
|
+
`get_dict` fails for a missing key and throws for an invalid key/dict type.
|
|
66
|
+
|
|
67
|
+
Pure relations can enumerate intentionally. `once(Goal)` chooses the first
|
|
68
|
+
solution, `!` discards local alternatives, and `(C -> T ; E)` commits the
|
|
69
|
+
condition. Select a deterministic input BEFORE a model/file/network effect.
|
|
70
|
+
An earlier choicepoint can replay a later effect on backtracking. A trailing
|
|
71
|
+
cut only commits paths that reached it. Do not retry irreversible actions by
|
|
72
|
+
backtracking; use explicit, bounded, safe retry policies.
|
|
73
|
+
|
|
74
|
+
## Values and output
|
|
75
|
+
|
|
76
|
+
A reusable skill, nested tool or shell workflow binds its output arguments and
|
|
77
|
+
returns. The caller composes those values.
|
|
78
|
+
`output(Text)` emits progress/display without adding model memory.
|
|
79
|
+
`answer(Text)` emits the final one-shot answer and terminates the goal; it is NOT
|
|
80
|
+
`end_turn` and does not assign workflow outputs. Use it at a run entry point,
|
|
81
|
+
not in a helper whose caller must continue.
|
|
82
|
+
|
|
83
|
+
`system/1`/`user/1` add DML harness memory, not authoring conversation.
|
|
84
|
+
See `reference(topic: "tasks", section: "memory")` before relying on context.
|
|
85
|
+
|
|
86
|
+
## Standard glue
|
|
87
|
+
|
|
88
|
+
Use `maplist/3` for sequential mapping; it passes each item plus an output to a
|
|
89
|
+
predicate. Use `include/3`, `exclude/3`, `memberchk/2`, `findall/3`, `sort/2`,
|
|
90
|
+
`msort/2`, `sum_list/2`, JSON helpers and `format/3` for small exact operations.
|
|
91
|
+
`sort/2` removes duplicates; `msort/2` keeps them. `directory_files/2` gives bare
|
|
92
|
+
entry names. Do not hand-build a large parser/list algorithm when a script fits.
|
|
93
|
+
`reference(topic: "snippets")` has precise short recipes.
|