deepclause-sdk 0.0.89 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +481 -941
- package/dist/agent.d.ts +19 -2
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +75 -21
- package/dist/agent.js.map +1 -1
- package/dist/cli/config.d.ts +385 -178
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +161 -188
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/index.d.ts +3 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +85 -411
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/login.d.ts +29 -0
- package/dist/cli/login.d.ts.map +1 -0
- package/dist/cli/login.js +184 -0
- package/dist/cli/login.js.map +1 -0
- package/dist/cli/readline.d.ts +6 -0
- package/dist/cli/readline.d.ts.map +1 -0
- package/dist/cli/readline.js +15 -0
- package/dist/cli/readline.js.map +1 -0
- package/dist/cli/repl-bin.d.ts +9 -0
- package/dist/cli/repl-bin.d.ts.map +1 -0
- package/dist/cli/repl-bin.js +16 -0
- package/dist/cli/repl-bin.js.map +1 -0
- package/dist/cli/repl.d.ts +216 -0
- package/dist/cli/repl.d.ts.map +1 -0
- package/dist/cli/repl.js +1392 -0
- package/dist/cli/repl.js.map +1 -0
- package/dist/cli/run.d.ts +17 -18
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +202 -183
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/set-backend.d.ts +53 -0
- package/dist/cli/set-backend.d.ts.map +1 -0
- package/dist/cli/set-backend.js +259 -0
- package/dist/cli/set-backend.js.map +1 -0
- package/dist/cli/visualize.d.ts +42 -0
- package/dist/cli/visualize.d.ts.map +1 -0
- package/dist/cli/visualize.js +150 -0
- package/dist/cli/visualize.js.map +1 -0
- package/dist/compiler.d.ts +5 -52
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js +4 -768
- package/dist/compiler.js.map +1 -1
- package/dist/index.d.ts +27 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/prolog/bridge.d.ts +5 -1
- package/dist/prolog/bridge.d.ts.map +1 -1
- package/dist/prolog/bridge.js +10 -1
- package/dist/prolog/bridge.js.map +1 -1
- package/dist/prolog-src/deepclause_analysis.pl +10 -2
- package/dist/prolog-src/deepclause_mi.pl +2440 -49
- package/dist/repl/agent.d.ts +90 -0
- package/dist/repl/agent.d.ts.map +1 -0
- package/dist/repl/agent.js +410 -0
- package/dist/repl/agent.js.map +1 -0
- package/dist/repl/auth.d.ts +45 -0
- package/dist/repl/auth.d.ts.map +1 -0
- package/dist/repl/auth.js +116 -0
- package/dist/repl/auth.js.map +1 -0
- package/dist/repl/backend.d.ts +321 -0
- package/dist/repl/backend.d.ts.map +1 -0
- package/dist/repl/backend.js +415 -0
- package/dist/repl/backend.js.map +1 -0
- package/dist/repl/compaction.d.ts +122 -0
- package/dist/repl/compaction.d.ts.map +1 -0
- package/dist/repl/compaction.js +318 -0
- package/dist/repl/compaction.js.map +1 -0
- package/dist/repl/export.d.ts +30 -0
- package/dist/repl/export.d.ts.map +1 -0
- package/dist/repl/export.js +23 -0
- package/dist/repl/export.js.map +1 -0
- package/dist/repl/frames.d.ts +21 -0
- package/dist/repl/frames.d.ts.map +1 -0
- package/dist/repl/frames.js +79 -0
- package/dist/repl/frames.js.map +1 -0
- package/dist/repl/harness-tools.d.ts +99 -0
- package/dist/repl/harness-tools.d.ts.map +1 -0
- package/dist/repl/harness-tools.js +192 -0
- package/dist/repl/harness-tools.js.map +1 -0
- package/dist/repl/highlight.d.ts +30 -0
- package/dist/repl/highlight.d.ts.map +1 -0
- package/dist/repl/highlight.js +285 -0
- package/dist/repl/highlight.js.map +1 -0
- package/dist/repl/history.d.ts +234 -0
- package/dist/repl/history.d.ts.map +1 -0
- package/dist/repl/history.js +661 -0
- package/dist/repl/history.js.map +1 -0
- package/dist/repl/imagegen.d.ts +29 -0
- package/dist/repl/imagegen.d.ts.map +1 -0
- package/dist/repl/imagegen.js +84 -0
- package/dist/repl/imagegen.js.map +1 -0
- package/dist/repl/index.d.ts +130 -0
- package/dist/repl/index.d.ts.map +1 -0
- package/dist/repl/index.js +112 -0
- package/dist/repl/index.js.map +1 -0
- package/dist/repl/judge.d.ts +51 -0
- package/dist/repl/judge.d.ts.map +1 -0
- package/dist/repl/judge.js +58 -0
- package/dist/repl/judge.js.map +1 -0
- package/dist/repl/markdown.d.ts +25 -0
- package/dist/repl/markdown.d.ts.map +1 -0
- package/dist/repl/markdown.js +103 -0
- package/dist/repl/markdown.js.map +1 -0
- package/dist/repl/model-resolver.d.ts +59 -0
- package/dist/repl/model-resolver.d.ts.map +1 -0
- package/dist/repl/model-resolver.js +156 -0
- package/dist/repl/model-resolver.js.map +1 -0
- package/dist/repl/picker.d.ts +34 -0
- package/dist/repl/picker.d.ts.map +1 -0
- package/dist/repl/picker.js +81 -0
- package/dist/repl/picker.js.map +1 -0
- package/dist/repl/project-context.d.ts +16 -0
- package/dist/repl/project-context.d.ts.map +1 -0
- package/dist/repl/project-context.js +23 -0
- package/dist/repl/project-context.js.map +1 -0
- package/dist/repl/render.d.ts +187 -0
- package/dist/repl/render.d.ts.map +1 -0
- package/dist/repl/render.js +808 -0
- package/dist/repl/render.js.map +1 -0
- package/dist/repl/session.d.ts +424 -0
- package/dist/repl/session.d.ts.map +1 -0
- package/dist/repl/session.js +1473 -0
- package/dist/repl/session.js.map +1 -0
- package/dist/repl/status.d.ts +100 -0
- package/dist/repl/status.d.ts.map +1 -0
- package/dist/repl/status.js +218 -0
- package/dist/repl/status.js.map +1 -0
- package/dist/repl/tools.d.ts +53 -0
- package/dist/repl/tools.d.ts.map +1 -0
- package/dist/repl/tools.js +307 -0
- package/dist/repl/tools.js.map +1 -0
- package/dist/repl/toolset.d.ts +32 -0
- package/dist/repl/toolset.d.ts.map +1 -0
- package/dist/repl/toolset.js +82 -0
- package/dist/repl/toolset.js.map +1 -0
- package/dist/repl/tui/editor.d.ts +17 -0
- package/dist/repl/tui/editor.d.ts.map +1 -0
- package/dist/repl/tui/editor.js +39 -0
- package/dist/repl/tui/editor.js.map +1 -0
- package/dist/repl/tui/status-bar.d.ts +26 -0
- package/dist/repl/tui/status-bar.d.ts.map +1 -0
- package/dist/repl/tui/status-bar.js +47 -0
- package/dist/repl/tui/status-bar.js.map +1 -0
- package/dist/repl/tui/theme.d.ts +30 -0
- package/dist/repl/tui/theme.d.ts.map +1 -0
- package/dist/repl/tui/theme.js +81 -0
- package/dist/repl/tui/theme.js.map +1 -0
- package/dist/repl/tui/transcript.d.ts +41 -0
- package/dist/repl/tui/transcript.d.ts.map +1 -0
- package/dist/repl/tui/transcript.js +139 -0
- package/dist/repl/tui/transcript.js.map +1 -0
- package/dist/runner.d.ts +143 -13
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +532 -290
- package/dist/runner.js.map +1 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +0 -32
- package/dist/sdk.js.map +1 -1
- package/dist/system/assets/docs/AGENT_PROMPT.md +1447 -0
- package/dist/system/assets/docs/DML_AUTHORING.md +195 -0
- package/dist/system/assets/docs/DML_REFERENCE.md +344 -72
- package/dist/system/assets/docs/HARNESS_EXAMPLES.md +172 -0
- package/dist/system/assets/docs/HARNESS_PATTERNS.md +562 -0
- package/dist/system/assets/docs/META_PROMPT.md +68 -0
- package/dist/system/assets/docs/PROLOG_SNIPPETS.md +117 -0
- package/dist/system/assets/index.d.ts +9 -17
- package/dist/system/assets/index.d.ts.map +1 -1
- package/dist/system/assets/index.js +26 -85
- package/dist/system/assets/index.js.map +1 -1
- package/dist/system/runtime/agentvm-manager.d.ts +9 -2
- package/dist/system/runtime/agentvm-manager.d.ts.map +1 -1
- package/dist/system/runtime/agentvm-manager.js +70 -44
- package/dist/system/runtime/agentvm-manager.js.map +1 -1
- package/dist/system/runtime/media.d.ts +23 -0
- package/dist/system/runtime/media.d.ts.map +1 -0
- package/dist/system/runtime/media.js +55 -0
- package/dist/system/runtime/media.js.map +1 -0
- package/dist/system/runtime/shell-limits.d.ts +21 -0
- package/dist/system/runtime/shell-limits.d.ts.map +1 -0
- package/dist/system/runtime/shell-limits.js +39 -0
- package/dist/system/runtime/shell-limits.js.map +1 -0
- package/dist/system/runtime/shell-manager.d.ts +8 -3
- package/dist/system/runtime/shell-manager.d.ts.map +1 -1
- package/dist/system/runtime/shell-manager.js +56 -39
- package/dist/system/runtime/shell-manager.js.map +1 -1
- package/dist/system/runtime/shell-tool-events.js +5 -0
- package/dist/system/runtime/shell-tool-events.js.map +1 -1
- package/dist/system/runtime/token-usage.d.ts +2 -0
- package/dist/system/runtime/token-usage.d.ts.map +1 -1
- package/dist/system/runtime/token-usage.js +7 -0
- package/dist/system/runtime/token-usage.js.map +1 -1
- package/dist/tools.d.ts +3 -21
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +14 -168
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +136 -119
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +19 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +338 -0
- package/dist/validate.js.map +1 -0
- package/dist/visualize/ascii.d.ts +55 -0
- package/dist/visualize/ascii.d.ts.map +1 -0
- package/dist/visualize/ascii.js +242 -0
- package/dist/visualize/ascii.js.map +1 -0
- package/dist/visualize/display.d.ts +24 -0
- package/dist/visualize/display.d.ts.map +1 -0
- package/dist/visualize/display.js +29 -0
- package/dist/visualize/display.js.map +1 -0
- package/dist/visualize/graphics.d.ts +35 -0
- package/dist/visualize/graphics.d.ts.map +1 -0
- package/dist/visualize/graphics.js +96 -0
- package/dist/visualize/graphics.js.map +1 -0
- package/dist/visualize/image.d.ts +38 -0
- package/dist/visualize/image.d.ts.map +1 -0
- package/dist/visualize/image.js +95 -0
- package/dist/visualize/image.js.map +1 -0
- package/dist/visualize/index.d.ts +59 -0
- package/dist/visualize/index.d.ts.map +1 -0
- package/dist/visualize/index.js +198 -0
- package/dist/visualize/index.js.map +1 -0
- package/dist/visualize/raster.d.ts +23 -0
- package/dist/visualize/raster.d.ts.map +1 -0
- package/dist/visualize/raster.js +47 -0
- package/dist/visualize/raster.js.map +1 -0
- package/dist/visualize/svg.d.ts +39 -0
- package/dist/visualize/svg.d.ts.map +1 -0
- package/dist/visualize/svg.js +148 -0
- package/dist/visualize/svg.js.map +1 -0
- package/dist/visualize/transcode.d.ts +13 -0
- package/dist/visualize/transcode.d.ts.map +1 -0
- package/dist/visualize/transcode.js +40 -0
- package/dist/visualize/transcode.js.map +1 -0
- package/docs/images/repl.png +0 -0
- package/package.json +19 -15
- package/src/prolog-src/deepclause_analysis.pl +10 -2
- package/src/prolog-src/deepclause_mi.pl +2440 -49
- package/dist/cli/commands.d.ts +0 -42
- package/dist/cli/commands.d.ts.map +0 -1
- package/dist/cli/commands.js +0 -246
- package/dist/cli/commands.js.map +0 -1
- package/dist/cli/compile.d.ts +0 -99
- package/dist/cli/compile.d.ts.map +0 -1
- package/dist/cli/compile.js +0 -363
- package/dist/cli/compile.js.map +0 -1
- package/dist/cli/default-skills.d.ts +0 -10
- package/dist/cli/default-skills.d.ts.map +0 -1
- package/dist/cli/default-skills.js +0 -206
- package/dist/cli/default-skills.js.map +0 -1
- package/dist/cli/interactive.d.ts +0 -2
- package/dist/cli/interactive.d.ts.map +0 -1
- package/dist/cli/interactive.js +0 -20
- package/dist/cli/interactive.js.map +0 -1
- package/dist/cli/mcp.d.ts +0 -56
- package/dist/cli/mcp.d.ts.map +0 -1
- package/dist/cli/mcp.js +0 -138
- package/dist/cli/mcp.js.map +0 -1
- package/dist/cli/prompt.d.ts +0 -2
- package/dist/cli/prompt.d.ts.map +0 -1
- package/dist/cli/prompt.js +0 -2
- package/dist/cli/prompt.js.map +0 -1
- package/dist/cli/search.d.ts +0 -19
- package/dist/cli/search.d.ts.map +0 -1
- package/dist/cli/search.js +0 -189
- package/dist/cli/search.js.map +0 -1
- package/dist/cli/tool-args.d.ts +0 -2
- package/dist/cli/tool-args.d.ts.map +0 -1
- package/dist/cli/tool-args.js +0 -39
- package/dist/cli/tool-args.js.map +0 -1
- package/dist/cli/tools.d.ts +0 -36
- package/dist/cli/tools.d.ts.map +0 -1
- package/dist/cli/tools.js +0 -229
- package/dist/cli/tools.js.map +0 -1
- package/dist/cli/tui/index.d.ts +0 -22
- package/dist/cli/tui/index.d.ts.map +0 -1
- package/dist/cli/tui/index.js +0 -29
- package/dist/cli/tui/index.js.map +0 -1
- package/dist/cli/tui.d.ts +0 -167
- package/dist/cli/tui.d.ts.map +0 -1
- package/dist/cli/tui.js +0 -5228
- package/dist/cli/tui.js.map +0 -1
- package/dist/compiler_prompt.d.ts +0 -20
- package/dist/compiler_prompt.d.ts.map +0 -1
- package/dist/compiler_prompt.js +0 -870
- package/dist/compiler_prompt.js.map +0 -1
- package/dist/deepclause-cli.skill +0 -0
- package/dist/prolog-src/deepclause_mi.pl.bak +0 -570
- package/dist/system/assets/docs/CONDUCTOR_PROMPT.md +0 -105
- package/dist/system/assets/docs/DML_COMPILER_PROMPT.md +0 -700
- package/dist/system/assets/docs/TUI.md +0 -150
- package/dist/system/assets/recipes/deepclause-coding-workflow/SKILL.md +0 -100
- package/dist/system/assets/skills/conductor.dml +0 -76
- package/dist/system/assets/skills/deep-planner.dml +0 -412
- package/dist/system/assets/skills/plan.dml +0 -429
- package/dist/system/assets/skills/security-planner.dml +0 -337
- package/dist/system/assets/skills/skill-creator.dml +0 -187
- package/dist/system/runtime/catalog-recipes.d.ts +0 -24
- package/dist/system/runtime/catalog-recipes.d.ts.map +0 -1
- package/dist/system/runtime/catalog-recipes.js +0 -273
- package/dist/system/runtime/catalog-recipes.js.map +0 -1
- package/dist/system/runtime/catalog-skills.d.ts +0 -50
- package/dist/system/runtime/catalog-skills.d.ts.map +0 -1
- package/dist/system/runtime/catalog-skills.js +0 -152
- package/dist/system/runtime/catalog-skills.js.map +0 -1
- package/dist/system/runtime/conductor.d.ts +0 -105
- package/dist/system/runtime/conductor.d.ts.map +0 -1
- package/dist/system/runtime/conductor.js +0 -732
- package/dist/system/runtime/conductor.js.map +0 -1
- package/dist/system/runtime/console-capture.d.ts +0 -9
- package/dist/system/runtime/console-capture.d.ts.map +0 -1
- package/dist/system/runtime/console-capture.js +0 -67
- package/dist/system/runtime/console-capture.js.map +0 -1
- package/dist/system/runtime/dml-executor.d.ts +0 -52
- package/dist/system/runtime/dml-executor.d.ts.map +0 -1
- package/dist/system/runtime/dml-executor.js +0 -203
- package/dist/system/runtime/dml-executor.js.map +0 -1
- package/dist/system/runtime/runtime-tools.d.ts +0 -31
- package/dist/system/runtime/runtime-tools.d.ts.map +0 -1
- package/dist/system/runtime/runtime-tools.js +0 -312
- package/dist/system/runtime/runtime-tools.js.map +0 -1
- package/dist/system/runtime/skill-creator.d.ts +0 -38
- package/dist/system/runtime/skill-creator.d.ts.map +0 -1
- package/dist/system/runtime/skill-creator.js +0 -763
- package/dist/system/runtime/skill-creator.js.map +0 -1
- package/src/prolog-src/deepclause_mi.pl.bak +0 -570
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compiler_prompt.js","sourceRoot":"","sources":["../src/compiler_prompt.ts"],"names":[],"mappings":"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"}
|
|
Binary file
|
|
@@ -1,570 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* deepclause_mi.pl - Meta-interpreter for DeepClause SDK
|
|
3
|
-
*
|
|
4
|
-
* The simplified meta-interpreter that handles:
|
|
5
|
-
* - task/1 and task/N predicates (agent loops)
|
|
6
|
-
* - exec/2 predicate (external tool calls)
|
|
7
|
-
* - Memory predicates (system, user, push_context, pop_context)
|
|
8
|
-
* - Output predicates (answer, yield, log)
|
|
9
|
-
* - Parameter handling
|
|
10
|
-
*
|
|
11
|
-
* Key design decisions:
|
|
12
|
-
* - No @-predicates - all LLM interaction via task()
|
|
13
|
-
* - Cooperative execution via engine yields
|
|
14
|
-
* - Backtrackable memory via push_context/pop_context
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
:- module(deepclause_mi, [
|
|
18
|
-
parse_dml/4,
|
|
19
|
-
create_engine/4,
|
|
20
|
-
step_engine/4,
|
|
21
|
-
destroy_engine/1,
|
|
22
|
-
post_agent_result/3,
|
|
23
|
-
post_exec_result/3,
|
|
24
|
-
provide_input/2,
|
|
25
|
-
mi/4
|
|
26
|
-
]).
|
|
27
|
-
|
|
28
|
-
:- use_module(deepclause_memory).
|
|
29
|
-
:- use_module(deepclause_strings).
|
|
30
|
-
|
|
31
|
-
%% Dynamic predicates for session state
|
|
32
|
-
:- dynamic session_engine/2. % session_engine(SessionId, Engine)
|
|
33
|
-
:- dynamic session_memory/2. % session_memory(SessionId, MemoryId)
|
|
34
|
-
:- dynamic session_params/2. % session_params(SessionId, ParamsDict)
|
|
35
|
-
:- dynamic session_user_tools/2. % session_user_tools(SessionId, ToolName)
|
|
36
|
-
:- dynamic session_user_tool_schema/3. % session_user_tool_schema(SessionId, ToolName, Schema)
|
|
37
|
-
:- dynamic session_pending_input/2. % session_pending_input(SessionId, Input)
|
|
38
|
-
:- dynamic session_agent_result/2. % session_agent_result(SessionId, Result)
|
|
39
|
-
:- dynamic session_exec_result/2. % session_exec_result(SessionId, Result)
|
|
40
|
-
|
|
41
|
-
%% ============================================================
|
|
42
|
-
%% DML Parsing
|
|
43
|
-
%% ============================================================
|
|
44
|
-
|
|
45
|
-
%% parse_dml(+FilePath, +SessionId, +MemoryId, -Error)
|
|
46
|
-
%% Parse a DML file and load its clauses into the session module
|
|
47
|
-
parse_dml(FilePath, SessionId, MemoryId, Error) :-
|
|
48
|
-
catch(
|
|
49
|
-
(
|
|
50
|
-
read_file_to_string(FilePath, Code, []),
|
|
51
|
-
parse_dml_string(Code, SessionId, MemoryId),
|
|
52
|
-
Error = none
|
|
53
|
-
),
|
|
54
|
-
ParseError,
|
|
55
|
-
format(atom(Error), '~w', [ParseError])
|
|
56
|
-
).
|
|
57
|
-
|
|
58
|
-
%% parse_dml_string(+Code, +SessionId, +MemoryId)
|
|
59
|
-
%% Parse DML code from a string
|
|
60
|
-
parse_dml_string(Code, SessionId, MemoryId) :-
|
|
61
|
-
open_string(Code, Stream),
|
|
62
|
-
parse_clauses(Stream, SessionId, MemoryId),
|
|
63
|
-
close(Stream).
|
|
64
|
-
|
|
65
|
-
%% parse_clauses(+Stream, +SessionId, +MemoryId)
|
|
66
|
-
%% Read and process all clauses from a stream
|
|
67
|
-
parse_clauses(Stream, SessionId, MemoryId) :-
|
|
68
|
-
read_term(Stream, Term, [module(SessionId)]),
|
|
69
|
-
( Term == end_of_file
|
|
70
|
-
-> true
|
|
71
|
-
; process_clause(Term, SessionId, MemoryId),
|
|
72
|
-
parse_clauses(Stream, SessionId, MemoryId)
|
|
73
|
-
).
|
|
74
|
-
|
|
75
|
-
%% process_clause(+Term, +SessionId, +MemoryId)
|
|
76
|
-
%% Process a single clause and add to session
|
|
77
|
-
process_clause((:- Directive), SessionId, _MemoryId) :-
|
|
78
|
-
!,
|
|
79
|
-
process_directive(Directive, SessionId).
|
|
80
|
-
|
|
81
|
-
%% Handle tool/2 with description: tool(Head, Description) :- Body
|
|
82
|
-
process_clause((tool(ToolHead, Description) :- Body), SessionId, _MemoryId) :-
|
|
83
|
-
!,
|
|
84
|
-
extract_tool_schema(ToolHead, Description, ToolName, Schema),
|
|
85
|
-
assertz(session_user_tools(SessionId, ToolName)),
|
|
86
|
-
assertz(session_user_tool_schema(SessionId, ToolName, Schema)),
|
|
87
|
-
% Store the source code for the tool description
|
|
88
|
-
format(string(SourceCode), "tool(~w, ~q) :-~n ~w.", [ToolHead, Description, Body]),
|
|
89
|
-
assertz(SessionId:tool_source(ToolName, SourceCode)),
|
|
90
|
-
% Assert the tool implementation (use just ToolHead for execution)
|
|
91
|
-
assertz(SessionId:(tool(ToolHead) :- Body)).
|
|
92
|
-
|
|
93
|
-
%% Handle tool/1 without description: tool(Head) :- Body
|
|
94
|
-
process_clause((tool(ToolHead) :- Body), SessionId, _MemoryId) :-
|
|
95
|
-
!,
|
|
96
|
-
extract_tool_schema(ToolHead, none, ToolName, Schema),
|
|
97
|
-
assertz(session_user_tools(SessionId, ToolName)),
|
|
98
|
-
assertz(session_user_tool_schema(SessionId, ToolName, Schema)),
|
|
99
|
-
% Store the source code for the tool description
|
|
100
|
-
format(string(SourceCode), "tool(~w) :-~n ~w.", [ToolHead, Body]),
|
|
101
|
-
assertz(SessionId:tool_source(ToolName, SourceCode)),
|
|
102
|
-
% Assert the tool implementation
|
|
103
|
-
assertz(SessionId:(tool(ToolHead) :- Body)).
|
|
104
|
-
|
|
105
|
-
process_clause((Head :- Body), SessionId, _MemoryId) :-
|
|
106
|
-
!,
|
|
107
|
-
% Regular clause - assert it
|
|
108
|
-
assertz(SessionId:(Head :- Body)).
|
|
109
|
-
|
|
110
|
-
process_clause(Fact, SessionId, _MemoryId) :-
|
|
111
|
-
% Simple fact
|
|
112
|
-
assertz(SessionId:Fact).
|
|
113
|
-
|
|
114
|
-
%% ============================================================
|
|
115
|
-
%% Tool Schema Extraction
|
|
116
|
-
%% ============================================================
|
|
117
|
-
|
|
118
|
-
%% extract_tool_schema(+ToolHead, +Description, -ToolName, -Schema)
|
|
119
|
-
%% Parse tool head to extract schema information
|
|
120
|
-
%% Schema = schema{name, description, inputs, outputs}
|
|
121
|
-
%% Each param = param{name, type, direction}
|
|
122
|
-
extract_tool_schema(ToolHead, Description, ToolName, Schema) :-
|
|
123
|
-
ToolHead =.. [ToolName|Args],
|
|
124
|
-
length(Args, Arity),
|
|
125
|
-
extract_params(Args, 1, Arity, Inputs, Outputs),
|
|
126
|
-
(Description == none -> Desc = "" ; Desc = Description),
|
|
127
|
-
Schema = schema{
|
|
128
|
-
name: ToolName,
|
|
129
|
-
description: Desc,
|
|
130
|
-
inputs: Inputs,
|
|
131
|
-
outputs: Outputs
|
|
132
|
-
}.
|
|
133
|
-
|
|
134
|
-
%% extract_params(+Args, +Index, +Arity, -Inputs, -Outputs)
|
|
135
|
-
%% Extract input and output parameters from argument list
|
|
136
|
-
%% Uses positional inference: first N-1 args are inputs, last arg is output
|
|
137
|
-
%% Parameter names are generic: arg1, arg2, etc.
|
|
138
|
-
extract_params([], _, _, [], []) :- !.
|
|
139
|
-
extract_params([_Arg|Rest], Index, Arity, Inputs, Outputs) :-
|
|
140
|
-
format(atom(Name), 'arg~w', [Index]),
|
|
141
|
-
Type = string, % Default type
|
|
142
|
-
NextIndex is Index + 1,
|
|
143
|
-
extract_params(Rest, NextIndex, Arity, RestInputs, RestOutputs),
|
|
144
|
-
Param = param{name: Name, type: Type},
|
|
145
|
-
% Last arg is output, all others are inputs
|
|
146
|
-
( Index == Arity
|
|
147
|
-
-> Inputs = RestInputs, Outputs = [Param|RestOutputs]
|
|
148
|
-
; Inputs = [Param|RestInputs], Outputs = RestOutputs
|
|
149
|
-
).
|
|
150
|
-
|
|
151
|
-
%% process_directive(+Directive, +SessionId)
|
|
152
|
-
%% Handle directives like :- param(...)
|
|
153
|
-
process_directive(param(Key, Desc), SessionId) :-
|
|
154
|
-
!,
|
|
155
|
-
assertz(SessionId:param_decl(Key, Desc)).
|
|
156
|
-
process_directive(param(Key, Desc, Default), SessionId) :-
|
|
157
|
-
!,
|
|
158
|
-
assertz(SessionId:param_decl(Key, Desc, Default)).
|
|
159
|
-
process_directive(_, _).
|
|
160
|
-
|
|
161
|
-
%% ============================================================
|
|
162
|
-
%% Engine Management
|
|
163
|
-
%% ============================================================
|
|
164
|
-
|
|
165
|
-
%% create_engine(+SessionId, +MemoryId, +Params, -Engine)
|
|
166
|
-
%% Create a cooperative execution engine for agent_main
|
|
167
|
-
create_engine(SessionId, MemoryId, Params, Engine) :-
|
|
168
|
-
assertz(session_memory(SessionId, MemoryId)),
|
|
169
|
-
assertz(session_params(SessionId, Params)),
|
|
170
|
-
% Determine goal based on what agent_main arity is defined
|
|
171
|
-
determine_agent_goal(SessionId, Params, Goal),
|
|
172
|
-
% Create the engine - pass SessionId to mi/4
|
|
173
|
-
engine_create(_,
|
|
174
|
-
deepclause_mi:mi(Goal, MemoryId, Params, SessionId),
|
|
175
|
-
Engine),
|
|
176
|
-
assertz(session_engine(SessionId, Engine)).
|
|
177
|
-
|
|
178
|
-
%% determine_agent_goal(+SessionId, +Params, -Goal)
|
|
179
|
-
%% Determine the correct agent_main goal to call based on arity
|
|
180
|
-
determine_agent_goal(SessionId, _Params, SessionId:agent_main) :-
|
|
181
|
-
current_predicate(SessionId:agent_main/0), !.
|
|
182
|
-
determine_agent_goal(SessionId, Params, Goal) :-
|
|
183
|
-
current_predicate(SessionId:agent_main/1), !,
|
|
184
|
-
% Get first parameter value from dict
|
|
185
|
-
dict_pairs(Params, _, Pairs),
|
|
186
|
-
( Pairs = [_-V1|_]
|
|
187
|
-
-> Goal = SessionId:agent_main(V1)
|
|
188
|
-
; Goal = SessionId:agent_main(_)
|
|
189
|
-
).
|
|
190
|
-
determine_agent_goal(SessionId, Params, Goal) :-
|
|
191
|
-
current_predicate(SessionId:agent_main/2), !,
|
|
192
|
-
dict_pairs(Params, _, Pairs),
|
|
193
|
-
( Pairs = [_-V1, _-V2|_]
|
|
194
|
-
-> Goal = SessionId:agent_main(V1, V2)
|
|
195
|
-
; Pairs = [_-V1|_]
|
|
196
|
-
-> Goal = SessionId:agent_main(V1, _)
|
|
197
|
-
; Goal = SessionId:agent_main(_, _)
|
|
198
|
-
).
|
|
199
|
-
determine_agent_goal(SessionId, _Params, SessionId:agent_main).
|
|
200
|
-
|
|
201
|
-
%% step_engine(+SessionId, -Status, -Content, -Payload)
|
|
202
|
-
%% Execute one step of the engine and return the result
|
|
203
|
-
step_engine(SessionId, Status, Content, Payload) :-
|
|
204
|
-
session_engine(SessionId, Engine),
|
|
205
|
-
( engine_next(Engine, Result)
|
|
206
|
-
-> process_engine_result(Result, Status, Content, Payload)
|
|
207
|
-
; Status = finished,
|
|
208
|
-
Content = '',
|
|
209
|
-
Payload = none
|
|
210
|
-
).
|
|
211
|
-
|
|
212
|
-
%% process_engine_result(+Result, -Status, -Content, -Payload)
|
|
213
|
-
process_engine_result(output(Text), output, Text, none) :- !.
|
|
214
|
-
process_engine_result(log(Text), log, Text, none) :- !.
|
|
215
|
-
process_engine_result(answer(Text), answer, Text, none) :- !.
|
|
216
|
-
process_engine_result(request_agent_loop(Desc, Vars, Tools), request_agent_loop, '',
|
|
217
|
-
payload{taskDescription: Desc, outputVars: Vars, userTools: Tools}) :- !.
|
|
218
|
-
process_engine_result(request_exec(Tool, Args), request_exec, '',
|
|
219
|
-
payload{toolName: Tool, args: Args}) :- !.
|
|
220
|
-
process_engine_result(wait_input(Prompt), wait_input, Prompt, none) :- !.
|
|
221
|
-
process_engine_result(error(Msg), error, Msg, none) :- !.
|
|
222
|
-
process_engine_result(Other, error, Msg, none) :-
|
|
223
|
-
format(atom(Msg), 'Unknown engine result: ~w', [Other]).
|
|
224
|
-
|
|
225
|
-
%% destroy_engine(+SessionId)
|
|
226
|
-
%% Clean up engine and session state
|
|
227
|
-
destroy_engine(SessionId) :-
|
|
228
|
-
( session_engine(SessionId, Engine)
|
|
229
|
-
-> catch(engine_destroy(Engine), _, true)
|
|
230
|
-
; true
|
|
231
|
-
),
|
|
232
|
-
retractall(session_engine(SessionId, _)),
|
|
233
|
-
retractall(session_memory(SessionId, _)),
|
|
234
|
-
retractall(session_params(SessionId, _)),
|
|
235
|
-
retractall(session_user_tools(SessionId, _)),
|
|
236
|
-
retractall(session_user_tool_schema(SessionId, _, _)),
|
|
237
|
-
retractall(session_pending_input(SessionId, _)),
|
|
238
|
-
retractall(session_agent_result(SessionId, _)),
|
|
239
|
-
retractall(session_exec_result(SessionId, _)),
|
|
240
|
-
% Clean up session module (if it exists)
|
|
241
|
-
( current_module(SessionId)
|
|
242
|
-
-> catch(
|
|
243
|
-
( findall(Head,
|
|
244
|
-
(current_predicate(SessionId:Name/Arity),
|
|
245
|
-
functor(Head, Name, Arity),
|
|
246
|
-
clause(SessionId:Head, _)),
|
|
247
|
-
Heads),
|
|
248
|
-
forall(member(H, Heads), retractall(SessionId:H))
|
|
249
|
-
),
|
|
250
|
-
_,
|
|
251
|
-
true
|
|
252
|
-
)
|
|
253
|
-
; true
|
|
254
|
-
).
|
|
255
|
-
|
|
256
|
-
%% ============================================================
|
|
257
|
-
%% Result Posting (from JavaScript)
|
|
258
|
-
%% ============================================================
|
|
259
|
-
|
|
260
|
-
%% post_agent_result(+SessionId, +Success, +Variables)
|
|
261
|
-
%% Post the result of an agent loop back to the waiting engine
|
|
262
|
-
post_agent_result(SessionId, Success, Variables) :-
|
|
263
|
-
assertz(session_agent_result(SessionId, result{success: Success, variables: Variables})),
|
|
264
|
-
session_engine(SessionId, Engine),
|
|
265
|
-
engine_post(Engine, agent_done).
|
|
266
|
-
|
|
267
|
-
%% post_exec_result(+SessionId, +Status, +Result)
|
|
268
|
-
%% Post the result of an exec call back to the waiting engine
|
|
269
|
-
post_exec_result(SessionId, Status, Result) :-
|
|
270
|
-
assertz(session_exec_result(SessionId, result{status: Status, result: Result})),
|
|
271
|
-
session_engine(SessionId, Engine),
|
|
272
|
-
engine_post(Engine, exec_done).
|
|
273
|
-
|
|
274
|
-
%% provide_input(+SessionId, +Input)
|
|
275
|
-
%% Provide user input to a waiting engine
|
|
276
|
-
provide_input(SessionId, Input) :-
|
|
277
|
-
assertz(session_pending_input(SessionId, Input)),
|
|
278
|
-
session_engine(SessionId, Engine),
|
|
279
|
-
engine_post(Engine, input_provided).
|
|
280
|
-
|
|
281
|
-
%% ============================================================
|
|
282
|
-
%% Meta-Interpreter Core
|
|
283
|
-
%% ============================================================
|
|
284
|
-
|
|
285
|
-
%% mi(+Goal, +MemoryId, +Params, +SessionId)
|
|
286
|
-
%% Main meta-interpreter entry point
|
|
287
|
-
mi(Goal, MemoryId, Params, SessionId) :-
|
|
288
|
-
% Store session ID for use by get_session_id/1
|
|
289
|
-
nb_setval(current_session_id, SessionId),
|
|
290
|
-
catch(
|
|
291
|
-
mi_call(Goal, MemoryId, Params),
|
|
292
|
-
Error,
|
|
293
|
-
( format(atom(ErrMsg), 'Runtime error: ~w', [Error]),
|
|
294
|
-
engine_yield(error(ErrMsg)),
|
|
295
|
-
fail
|
|
296
|
-
)
|
|
297
|
-
).
|
|
298
|
-
|
|
299
|
-
%% ============================================================
|
|
300
|
-
%% Task Handling
|
|
301
|
-
%% ============================================================
|
|
302
|
-
|
|
303
|
-
%% collect_user_tools(+SessionId, -ToolSchemas)
|
|
304
|
-
%% Collect all user tool schemas for the session
|
|
305
|
-
collect_user_tools(SessionId, ToolSchemas) :-
|
|
306
|
-
findall(
|
|
307
|
-
tool_info{name: Name, schema: Schema, source: Source},
|
|
308
|
-
(
|
|
309
|
-
session_user_tool_schema(SessionId, Name, Schema),
|
|
310
|
-
(SessionId:tool_source(Name, Source) -> true ; Source = "")
|
|
311
|
-
),
|
|
312
|
-
ToolSchemas
|
|
313
|
-
).
|
|
314
|
-
|
|
315
|
-
%% mi_call(task(Desc), +MemoryId, +Params)
|
|
316
|
-
%% Handle task/1 - simple task without output variables
|
|
317
|
-
mi_call(task(Desc), MemoryId, Params) :-
|
|
318
|
-
!,
|
|
319
|
-
interpolate_desc(Desc, Params, InterpDesc),
|
|
320
|
-
get_session_id(SessionId),
|
|
321
|
-
collect_user_tools(SessionId, UserTools),
|
|
322
|
-
% Yield request to JavaScript with tool schemas
|
|
323
|
-
engine_yield(request_agent_loop(InterpDesc, [], UserTools)),
|
|
324
|
-
% Wait for result
|
|
325
|
-
engine_fetch(_Signal),
|
|
326
|
-
% Get and process result
|
|
327
|
-
session_agent_result(SessionId, Result),
|
|
328
|
-
retract(session_agent_result(SessionId, _)),
|
|
329
|
-
Result.success == true.
|
|
330
|
-
|
|
331
|
-
%% mi_call(task(Desc, Var1), +MemoryId, +Params)
|
|
332
|
-
%% Handle task/2 - task with one output variable
|
|
333
|
-
mi_call(task(Desc, Var1), MemoryId, Params) :-
|
|
334
|
-
!,
|
|
335
|
-
mi_call_task_n(Desc, [Var1], ['Var1'], MemoryId, Params).
|
|
336
|
-
|
|
337
|
-
%% mi_call(task(Desc, Var1, Var2), +MemoryId, +Params)
|
|
338
|
-
%% Handle task/3 - task with two output variables
|
|
339
|
-
mi_call(task(Desc, Var1, Var2), MemoryId, Params) :-
|
|
340
|
-
!,
|
|
341
|
-
mi_call_task_n(Desc, [Var1, Var2], ['Var1', 'Var2'], MemoryId, Params).
|
|
342
|
-
|
|
343
|
-
%% mi_call(task(Desc, Var1, Var2, Var3), +MemoryId, +Params)
|
|
344
|
-
%% Handle task/4 - task with three output variables
|
|
345
|
-
mi_call(task(Desc, Var1, Var2, Var3), MemoryId, Params) :-
|
|
346
|
-
!,
|
|
347
|
-
mi_call_task_n(Desc, [Var1, Var2, Var3], ['Var1', 'Var2', 'Var3'], MemoryId, Params).
|
|
348
|
-
|
|
349
|
-
%% mi_call_task_n(+Desc, +Vars, +VarNames, +MemoryId, +Params)
|
|
350
|
-
%% Generic handler for task/N with N-1 output variables
|
|
351
|
-
mi_call_task_n(Desc, Vars, VarNames, _MemoryId, Params) :-
|
|
352
|
-
interpolate_desc(Desc, Params, InterpDesc),
|
|
353
|
-
get_session_id(SessionId),
|
|
354
|
-
collect_user_tools(SessionId, UserTools),
|
|
355
|
-
% Yield request to JavaScript with tool schemas
|
|
356
|
-
engine_yield(request_agent_loop(InterpDesc, VarNames, UserTools)),
|
|
357
|
-
% Wait for result
|
|
358
|
-
engine_fetch(_Signal),
|
|
359
|
-
% Get and process result
|
|
360
|
-
session_agent_result(SessionId, Result),
|
|
361
|
-
retract(session_agent_result(SessionId, _)),
|
|
362
|
-
Result.success == true,
|
|
363
|
-
% Bind output variables
|
|
364
|
-
bind_task_variables(Result.variables, VarNames, Vars).
|
|
365
|
-
|
|
366
|
-
%% bind_task_variables(+VarsDict, +Names, -Values)
|
|
367
|
-
bind_task_variables(_, [], []) :- !.
|
|
368
|
-
bind_task_variables(VarsDict, [Name|Names], [Value|Values]) :-
|
|
369
|
-
( get_dict(Name, VarsDict, Value)
|
|
370
|
-
-> true
|
|
371
|
-
; true % Leave unbound if not present
|
|
372
|
-
),
|
|
373
|
-
bind_task_variables(VarsDict, Names, Values).
|
|
374
|
-
|
|
375
|
-
%% ============================================================
|
|
376
|
-
%% Exec Handling
|
|
377
|
-
%% ============================================================
|
|
378
|
-
|
|
379
|
-
%% mi_call(exec(ToolCall, Output), +MemoryId, +Params)
|
|
380
|
-
%% Handle exec/2 - external tool execution
|
|
381
|
-
mi_call(exec(ToolCall, Output), _MemoryId, _Params) :-
|
|
382
|
-
!,
|
|
383
|
-
ToolCall =.. [ToolName|Args],
|
|
384
|
-
get_session_id(SessionId),
|
|
385
|
-
% Yield request to JavaScript
|
|
386
|
-
engine_yield(request_exec(ToolName, Args)),
|
|
387
|
-
% Wait for result
|
|
388
|
-
engine_fetch(_Signal),
|
|
389
|
-
% Get and process result
|
|
390
|
-
session_exec_result(SessionId, Result),
|
|
391
|
-
retract(session_exec_result(SessionId, _)),
|
|
392
|
-
( Result.status == success
|
|
393
|
-
-> Output = Result.result
|
|
394
|
-
; fail
|
|
395
|
-
).
|
|
396
|
-
|
|
397
|
-
%% ============================================================
|
|
398
|
-
%% Memory Predicates
|
|
399
|
-
%% ============================================================
|
|
400
|
-
|
|
401
|
-
%% mi_call(system(Text), +MemoryId, +Params)
|
|
402
|
-
mi_call(system(Text), MemoryId, Params) :-
|
|
403
|
-
!,
|
|
404
|
-
interpolate_desc(Text, Params, InterpText),
|
|
405
|
-
deepclause_memory:push_memory(MemoryId, message{role: system, content: InterpText}).
|
|
406
|
-
|
|
407
|
-
%% mi_call(user(Text), +MemoryId, +Params)
|
|
408
|
-
mi_call(user(Text), MemoryId, Params) :-
|
|
409
|
-
!,
|
|
410
|
-
interpolate_desc(Text, Params, InterpText),
|
|
411
|
-
deepclause_memory:push_memory(MemoryId, message{role: user, content: InterpText}).
|
|
412
|
-
|
|
413
|
-
%% mi_call(push_context, +MemoryId, +Params)
|
|
414
|
-
mi_call(push_context, MemoryId, _Params) :-
|
|
415
|
-
!,
|
|
416
|
-
deepclause_memory:push_context(MemoryId).
|
|
417
|
-
|
|
418
|
-
%% mi_call(pop_context, +MemoryId, +Params)
|
|
419
|
-
mi_call(pop_context, MemoryId, _Params) :-
|
|
420
|
-
!,
|
|
421
|
-
deepclause_memory:pop_context(MemoryId).
|
|
422
|
-
|
|
423
|
-
%% ============================================================
|
|
424
|
-
%% Output Predicates
|
|
425
|
-
%% ============================================================
|
|
426
|
-
|
|
427
|
-
%% mi_call(answer(Text), +MemoryId, +Params)
|
|
428
|
-
mi_call(answer(Text), _MemoryId, Params) :-
|
|
429
|
-
!,
|
|
430
|
-
interpolate_desc(Text, Params, InterpText),
|
|
431
|
-
engine_yield(answer(InterpText)).
|
|
432
|
-
|
|
433
|
-
%% mi_call(yield(Text), +MemoryId, +Params)
|
|
434
|
-
mi_call(yield(Text), _MemoryId, Params) :-
|
|
435
|
-
!,
|
|
436
|
-
interpolate_desc(Text, Params, InterpText),
|
|
437
|
-
engine_yield(output(InterpText)).
|
|
438
|
-
|
|
439
|
-
%% mi_call(log(Text), +MemoryId, +Params)
|
|
440
|
-
mi_call(log(Text), _MemoryId, Params) :-
|
|
441
|
-
!,
|
|
442
|
-
interpolate_desc(Text, Params, InterpText),
|
|
443
|
-
engine_yield(log(InterpText)).
|
|
444
|
-
|
|
445
|
-
%% ============================================================
|
|
446
|
-
%% Parameter Handling
|
|
447
|
-
%% ============================================================
|
|
448
|
-
|
|
449
|
-
%% mi_call(param(Key, Desc, Value), +MemoryId, +Params)
|
|
450
|
-
mi_call(param(Key, _Desc, Value), _MemoryId, Params) :-
|
|
451
|
-
!,
|
|
452
|
-
( atom(Key)
|
|
453
|
-
-> KeyAtom = Key
|
|
454
|
-
; atom_string(KeyAtom, Key)
|
|
455
|
-
),
|
|
456
|
-
get_dict(KeyAtom, Params, Value).
|
|
457
|
-
|
|
458
|
-
%% ============================================================
|
|
459
|
-
%% Control Flow
|
|
460
|
-
%% ============================================================
|
|
461
|
-
|
|
462
|
-
%% mi_call((A, B), +MemoryId, +Params)
|
|
463
|
-
mi_call((A, B), MemoryId, Params) :-
|
|
464
|
-
!,
|
|
465
|
-
mi_call(A, MemoryId, Params),
|
|
466
|
-
mi_call(B, MemoryId, Params).
|
|
467
|
-
|
|
468
|
-
%% mi_call((A ; B), +MemoryId, +Params)
|
|
469
|
-
mi_call((A ; B), MemoryId, Params) :-
|
|
470
|
-
!,
|
|
471
|
-
( mi_call(A, MemoryId, Params)
|
|
472
|
-
; mi_call(B, MemoryId, Params)
|
|
473
|
-
).
|
|
474
|
-
|
|
475
|
-
%% mi_call((Cond -> Then ; Else), +MemoryId, +Params)
|
|
476
|
-
mi_call((Cond -> Then ; Else), MemoryId, Params) :-
|
|
477
|
-
!,
|
|
478
|
-
( mi_call(Cond, MemoryId, Params)
|
|
479
|
-
-> mi_call(Then, MemoryId, Params)
|
|
480
|
-
; mi_call(Else, MemoryId, Params)
|
|
481
|
-
).
|
|
482
|
-
|
|
483
|
-
%% mi_call((Cond -> Then), +MemoryId, +Params)
|
|
484
|
-
mi_call((Cond -> Then), MemoryId, Params) :-
|
|
485
|
-
!,
|
|
486
|
-
( mi_call(Cond, MemoryId, Params)
|
|
487
|
-
-> mi_call(Then, MemoryId, Params)
|
|
488
|
-
).
|
|
489
|
-
|
|
490
|
-
%% mi_call(\+(Goal), +MemoryId, +Params)
|
|
491
|
-
mi_call(\+(Goal), MemoryId, Params) :-
|
|
492
|
-
!,
|
|
493
|
-
\+ mi_call(Goal, MemoryId, Params).
|
|
494
|
-
|
|
495
|
-
%% mi_call(!, +MemoryId, +Params)
|
|
496
|
-
mi_call(!, _MemoryId, _Params) :-
|
|
497
|
-
!.
|
|
498
|
-
|
|
499
|
-
%% mi_call(true, +MemoryId, +Params)
|
|
500
|
-
mi_call(true, _MemoryId, _Params) :-
|
|
501
|
-
!.
|
|
502
|
-
|
|
503
|
-
%% mi_call(fail, +MemoryId, +Params)
|
|
504
|
-
mi_call(fail, _MemoryId, _Params) :-
|
|
505
|
-
!,
|
|
506
|
-
fail.
|
|
507
|
-
|
|
508
|
-
%% mi_call(false, +MemoryId, +Params)
|
|
509
|
-
mi_call(false, _MemoryId, _Params) :-
|
|
510
|
-
!,
|
|
511
|
-
fail.
|
|
512
|
-
|
|
513
|
-
%% ============================================================
|
|
514
|
-
%% Module-Qualified Goals
|
|
515
|
-
%% ============================================================
|
|
516
|
-
|
|
517
|
-
%% mi_call(Module:Goal, +MemoryId, +Params)
|
|
518
|
-
mi_call(Module:Goal, MemoryId, Params) :-
|
|
519
|
-
!,
|
|
520
|
-
( % Check if it's a user-defined predicate that needs meta-interpretation
|
|
521
|
-
callable(Module:Goal), clause(Module:Goal, Body),
|
|
522
|
-
Body \== true
|
|
523
|
-
-> mi_call(Body, MemoryId, Params)
|
|
524
|
-
; % Try direct call
|
|
525
|
-
call(Module:Goal)
|
|
526
|
-
).
|
|
527
|
-
|
|
528
|
-
%% ============================================================
|
|
529
|
-
%% Built-in and User-Defined Predicates
|
|
530
|
-
%% ============================================================
|
|
531
|
-
|
|
532
|
-
%% mi_call(Goal, +MemoryId, +Params)
|
|
533
|
-
%% Default handler - try built-in first, then user-defined
|
|
534
|
-
mi_call(Goal, MemoryId, Params) :-
|
|
535
|
-
% Guard: Goal must be callable (not a variable)
|
|
536
|
-
( var(Goal)
|
|
537
|
-
-> throw(error(instantiation_error, mi_call/3))
|
|
538
|
-
; true
|
|
539
|
-
),
|
|
540
|
-
% Try as built-in
|
|
541
|
-
( predicate_property(Goal, built_in)
|
|
542
|
-
-> call(Goal)
|
|
543
|
-
; % Try as user-defined with meta-interpretation
|
|
544
|
-
get_session_id(SessionId),
|
|
545
|
-
callable(Goal),
|
|
546
|
-
catch(clause(SessionId:Goal, Body), _, fail)
|
|
547
|
-
-> mi_call(Body, MemoryId, Params)
|
|
548
|
-
; % Final fallback - direct call
|
|
549
|
-
call(Goal)
|
|
550
|
-
).
|
|
551
|
-
|
|
552
|
-
%% ============================================================
|
|
553
|
-
%% Helper Predicates
|
|
554
|
-
%% ============================================================
|
|
555
|
-
|
|
556
|
-
%% interpolate_desc(+Template, +Params, -Result)
|
|
557
|
-
%% Expand {Variable} patterns using params
|
|
558
|
-
interpolate_desc(Template, Params, Result) :-
|
|
559
|
-
( is_dict(Params)
|
|
560
|
-
-> dict_pairs(Params, _, Pairs),
|
|
561
|
-
maplist([K-V, K=V]>>true, Pairs, Bindings),
|
|
562
|
-
deepclause_strings:interpolate_string(Template, Bindings, Result)
|
|
563
|
-
; Result = Template
|
|
564
|
-
).
|
|
565
|
-
|
|
566
|
-
%% get_session_id(-SessionId)
|
|
567
|
-
%% Extract session ID from current execution context
|
|
568
|
-
get_session_id(SessionId) :-
|
|
569
|
-
nb_current(current_session_id, SessionId), !.
|
|
570
|
-
get_session_id(default_session).
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
# Who you are
|
|
2
|
-
|
|
3
|
-
You are **{ASSISTANT_NAME}**, an agent build using the DeepClause framework. Complete the task described in your instructions autonomously and report the result clearly when you finish.
|
|
4
|
-
|
|
5
|
-
## What You Can Do
|
|
6
|
-
- **Run skills** from the local catalog via `run_skill`
|
|
7
|
-
- **Consult recipes** from the local recipe library via `consult_recipes`
|
|
8
|
-
- **Create new skills** via `create_new_skill`
|
|
9
|
-
- **Execute shell commands** via `run_bash`
|
|
10
|
-
- **Research the web** via `search_web`, `search_news`, and `fetch_url`
|
|
11
|
-
- **Download files** via `download_file`
|
|
12
|
-
- **Evaluate math** via `calculate`
|
|
13
|
-
|
|
14
|
-
## Workspace Environment
|
|
15
|
-
|
|
16
|
-
You run inside the local DeepClause runtime. The exact workspace path, skill catalog, docs path, and session directory are appended below in the local runtime context.
|
|
17
|
-
|
|
18
|
-
The local runtime context also includes the current session execution log path. That JSONL file accumulates structured records for conductor turns, session-scoped skill runs, child-skill events, tool calls, streamed model output, errors, and completion summaries.
|
|
19
|
-
|
|
20
|
-
Shell commands (`run_bash`) execute with the workspace as the current working directory. Prefer relative paths. Verify tool availability before relying on it, and install missing packages only when the task actually needs them.
|
|
21
|
-
|
|
22
|
-
Large web pages and raw HTML can blow the model context window. Treat text returned by `fetch_url` as a convenience preview, not as a safe place to dump entire docs sites or HTML pages into the next model call.
|
|
23
|
-
|
|
24
|
-
When a page is likely to be large, noisy, or highly structured, prefer downloading it first and inspecting it locally with focused commands or parsers. Use `download_file` to save the page, then `run_bash` with narrow inspection commands such as `rg`, `grep`, `sed -n`, `head`, or a small Python/Node parser to extract only the relevant snippet before you continue.
|
|
25
|
-
|
|
26
|
-
If you need to start a background service from `run_bash`, do not rely on a bare `command &` alone. Detach it from the tool's stdio, redirect logs, and print the PID or readiness marker, for example: `nohup python3 -m http.server 8080 >/tmp/http.log 2>&1 < /dev/null & echo $!`.
|
|
27
|
-
|
|
28
|
-
If the user asks about the fullscreen CLI TUI, consult the local TUI guide in the docs directory appended below. It documents the pane layout, menus, slash commands, direct `!<command>` shell mode, skill execution, and session behavior.
|
|
29
|
-
|
|
30
|
-
## Decision Flow
|
|
31
|
-
|
|
32
|
-
1. **Check your task instructions**.
|
|
33
|
-
2. **If an existing skill fits** -> run it with `run_skill(slug, args)`.
|
|
34
|
-
3. **If the user is asking how to do something, or you need workflow/convention guidance** -> use `consult_recipes(query)`.
|
|
35
|
-
4. **If the user asks to create a new recipe or update an existing recipe** -> treat it as a workspace file-editing task under `.deepclause/system/recipes/<slug>/SKILL.md`. Consult existing recipes first when helpful, then create or update the recipe markdown directly. Do **not** use `create_new_skill` for recipe authoring.
|
|
36
|
-
5. **If it needs code, files, or local tooling** -> use `run_bash`.
|
|
37
|
-
6. **If it needs research** -> use `search_web`, `search_news`, or `fetch_url`.
|
|
38
|
-
7. **If it needs a reusable automation** -> use `create_new_skill` with a detailed spec.
|
|
39
|
-
8. **If you are debugging a failure, retrying a similar task, or trying to reuse a previously working pattern** -> inspect the session execution log first with focused shell commands such as `tail`, `sed`, or `rg`, then adapt your next step based on the concrete failure or success pattern you find.
|
|
40
|
-
|
|
41
|
-
## Memory
|
|
42
|
-
|
|
43
|
-
You manage **task memory**: technical learnings from task execution. When the task instructions ask for a `MemoryUpdate` output, put the COMPLETE updated task memory markdown there if the run produced useful technical learnings. If nothing technically noteworthy should be recorded, return `NONE` for that memory output.
|
|
44
|
-
|
|
45
|
-
You may also receive optional **assistant memory** loaded from the session's `assistant-memory.md` file. It may be empty, and in the current CLI runtime it is not automatically maintained by a built-in conductor tool. Use it when relevant.
|
|
46
|
-
|
|
47
|
-
## Important Rules
|
|
48
|
-
- Work autonomously, but ask the user clarifying questions when required.
|
|
49
|
-
- Report results clearly when done.
|
|
50
|
-
- For `create_new_skill`, write a thorough spec covering purpose, inputs, outputs, tools, and edge cases.
|
|
51
|
-
- Recipe creation and recipe updates are file-authoring tasks, not skill-creation tasks. Edit recipe markdown under `.deepclause/system/recipes/<slug>/SKILL.md` directly.
|
|
52
|
-
- Forward the user's original intent faithfully.
|
|
53
|
-
- Keep the final answer concise and focused on whether the task succeeded, what result was produced, or what blocked completion.
|
|
54
|
-
- Only write task results to files when the user asked for files or the result is too large to present clearly inline.
|
|
55
|
-
- Not every intermediate action is visible to the user.
|
|
56
|
-
- Before you call any tool, briefly explain why you are using it.
|
|
57
|
-
- When a task failed earlier in this session, do not guess blindly. Inspect the session execution log first, identify the relevant failing tool call, error text, or successful prior pattern, and then decide whether to retry, adjust the approach, or reuse the working pattern.
|
|
58
|
-
- Prefer focused log inspection over dumping the whole file. Use recent tails and targeted searches so you can diagnose the issue or recover a known-good pattern quickly.
|
|
59
|
-
- Do not paste large raw HTML or whole documentation pages back into the model unless the task truly depends on that exact text. Prefer downloaded files plus narrow local extraction.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
## Background on Skills
|
|
63
|
-
|
|
64
|
-
DeepClause skills are not just freeform prompts. They are executable **DML** programs in the local skill catalog.
|
|
65
|
-
|
|
66
|
-
- **DML** stands for DeepClause Meta Language.
|
|
67
|
-
- DML is a **Prolog-based DSL** used to express task logic, tool calls, branching, retries, recursion, and other agent workflows with more reliable execution semantics than plain prompt text.
|
|
68
|
-
- In this runtime, the **conductor** is the router and orchestrator. Normal compiled skills are the worker programs it delegates to.
|
|
69
|
-
|
|
70
|
-
When you decide a task should become a reusable capability, do **not** try to invent or hand-author raw DML in your own reply. Instead, use `create_new_skill` so the dedicated **skill creator** can compile a proper skill from a detailed spec, validate it, test it, and publish it into the local catalog.
|
|
71
|
-
|
|
72
|
-
Use this model:
|
|
73
|
-
|
|
74
|
-
- If a matching existing skill already exists, run it with `run_skill`.
|
|
75
|
-
- If you need guidance on workflow, conventions, or how to approach a task, use `consult_recipes`.
|
|
76
|
-
- If the task is one-off and does not need reuse, solve it directly with the available tools.
|
|
77
|
-
- If the task should become a reusable automation, call `create_new_skill` with a strong specification.
|
|
78
|
-
|
|
79
|
-
## Background on Recipes
|
|
80
|
-
|
|
81
|
-
Recipes are **read-only markdown instruction packs**. They are not executable DML workers.
|
|
82
|
-
|
|
83
|
-
- Recipes capture workflow guidance, conventions, checklists, and examples.
|
|
84
|
-
- Recipes are searched through `consult_recipes`.
|
|
85
|
-
- Recipes may live in packaged defaults or in the workspace under `.deepclause/system/recipes/`.
|
|
86
|
-
- Recipes are useful when you need to know *how* to approach a task, not when you need to *execute* a reusable automation.
|
|
87
|
-
- A workspace recipe normally lives at `.deepclause/system/recipes/<slug>/SKILL.md`.
|
|
88
|
-
- If the user asks to create or update a recipe, first inspect nearby recipes for style and structure when helpful, then edit the target recipe markdown directly.
|
|
89
|
-
- Recipe requests should stay in markdown. Do **not** route them through `create_new_skill` unless the user explicitly asked for an executable skill instead of a recipe.
|
|
90
|
-
|
|
91
|
-
Use this model:
|
|
92
|
-
|
|
93
|
-
- **Skill**: executable DML worker for reusable automation.
|
|
94
|
-
- **Recipe**: markdown guidance for process, conventions, and decision-making.
|
|
95
|
-
- **Conductor**: the router that decides whether to run a skill, consult a recipe, or solve the task directly.
|
|
96
|
-
|
|
97
|
-
When writing a spec for `create_new_skill`, make it concrete. Describe:
|
|
98
|
-
|
|
99
|
-
- the skill's purpose
|
|
100
|
-
- its inputs and expected outputs
|
|
101
|
-
- the tools it should use
|
|
102
|
-
- important workflow steps and decision points
|
|
103
|
-
- edge cases, failure handling, and constraints
|
|
104
|
-
|
|
105
|
-
Prefer creating skills through the skill creator over trying to simulate a reusable skill manually inside the conductor. The goal is to produce a real compiled DML worker that can be reused later, not just an ad hoc one-turn solution.
|