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
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-backed meta tools (M3).
|
|
3
|
+
*
|
|
4
|
+
* A `meta` frame's agent tool set is *replaced* with exactly these tools; the
|
|
5
|
+
* harness's own DML tools are hidden from the code-writing model. The tools act
|
|
6
|
+
* on the live scratch module (snapshot/restored by the prompt transaction).
|
|
7
|
+
*
|
|
8
|
+
* M3 ships listing/assert/retract/execute; M6 adds ask_user.
|
|
9
|
+
*/
|
|
10
|
+
import { plainValue } from './frames.js';
|
|
11
|
+
function quoteString(value) {
|
|
12
|
+
return `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
13
|
+
}
|
|
14
|
+
function listingFilterTerm(filter) {
|
|
15
|
+
if (/^[a-z][a-zA-Z0-9_]*\/\d+$/.test(filter) || /^[a-z][a-zA-Z0-9_]*$/.test(filter)) {
|
|
16
|
+
return filter;
|
|
17
|
+
}
|
|
18
|
+
return `'${filter.replace(/'/g, "''")}'`;
|
|
19
|
+
}
|
|
20
|
+
function textResult(message) {
|
|
21
|
+
return { text: message };
|
|
22
|
+
}
|
|
23
|
+
export function createMetaTools(ctx) {
|
|
24
|
+
const tools = new Map();
|
|
25
|
+
// The AI SDK may issue several tool calls from one assistant message and run
|
|
26
|
+
// them concurrently. Meta tools mutate the shared session and create child
|
|
27
|
+
// frames, so serialize them: a child frame must run to completion before the
|
|
28
|
+
// meta frame resumes (proposal §10.3).
|
|
29
|
+
let queue = Promise.resolve();
|
|
30
|
+
const serialized = (fn) => {
|
|
31
|
+
const run = queue.then(fn, fn);
|
|
32
|
+
queue = run.then(() => undefined, () => undefined);
|
|
33
|
+
return run;
|
|
34
|
+
};
|
|
35
|
+
const notify = (toolName, toolArgs, state, toolSummary) => {
|
|
36
|
+
ctx.onEvent?.({ type: 'tool_call', toolName, toolArgs, toolState: state, toolSummary });
|
|
37
|
+
};
|
|
38
|
+
tools.set('listing', {
|
|
39
|
+
description: 'Read-only listing of the living harness: predicates, a Name/Arity, tools, or scripts.',
|
|
40
|
+
parameters: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties: {
|
|
43
|
+
filter: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
description: "One of: all (default), a Name/Arity, tools, scripts, or a name prefix.",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
required: [],
|
|
49
|
+
},
|
|
50
|
+
execute: (args) => serialized(async () => {
|
|
51
|
+
const filter = String(args.filter ?? 'all').trim() || 'all';
|
|
52
|
+
if (filter === 'tools' && ctx.hostToolsCatalog) {
|
|
53
|
+
return textResult(ctx.hostToolsCatalog);
|
|
54
|
+
}
|
|
55
|
+
const result = ctx.prologQuery(`deepclause_mi:repl_listing('${ctx.sessionId}', ${listingFilterTerm(filter)}, Text)`);
|
|
56
|
+
const text = plainValue(result?.Text);
|
|
57
|
+
const output = typeof text === 'string' ? text : '';
|
|
58
|
+
notify('listing', { filter }, 'completed', `${output.trim() ? output.trim().split('\n').length : 0} line(s)`);
|
|
59
|
+
return textResult(output);
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
tools.set('assert', {
|
|
63
|
+
description: 'Parse and assert a clause, tool/2, or script_body/2 fact into the scratch harness.',
|
|
64
|
+
parameters: {
|
|
65
|
+
type: 'object',
|
|
66
|
+
properties: {
|
|
67
|
+
clause: { type: 'string', description: 'The DML clause/fact text to assert (no trailing period required).' },
|
|
68
|
+
},
|
|
69
|
+
required: ['clause'],
|
|
70
|
+
},
|
|
71
|
+
execute: (args) => serialized(async () => {
|
|
72
|
+
if (ctx.isFrozen()) {
|
|
73
|
+
return { ok: false, error: 'harness is frozen; assert is disabled' };
|
|
74
|
+
}
|
|
75
|
+
const clause = String(args.clause ?? '');
|
|
76
|
+
const result = ctx.prologQuery(`deepclause_mi:repl_assert('${ctx.sessionId}', ${quoteString(clause)}, Result)`);
|
|
77
|
+
const outcome = plainValue(result?.Result);
|
|
78
|
+
if (outcome === 'ok') {
|
|
79
|
+
notify('assert', { clause }, 'completed', 'ok');
|
|
80
|
+
return { ok: true };
|
|
81
|
+
}
|
|
82
|
+
notify('assert', { clause }, 'failed', String(outcome));
|
|
83
|
+
return { ok: false, error: String(outcome) };
|
|
84
|
+
}),
|
|
85
|
+
});
|
|
86
|
+
tools.set('assert_many', {
|
|
87
|
+
description: 'Parse a block of clauses and assert them in the order written. Use this to define a whole predicate so clause order (base case before recursive rule) is preserved.',
|
|
88
|
+
parameters: {
|
|
89
|
+
type: 'object',
|
|
90
|
+
properties: {
|
|
91
|
+
clauses: { type: 'string', description: 'The DML clauses/facts, in order, each ending with a period.' },
|
|
92
|
+
},
|
|
93
|
+
required: ['clauses'],
|
|
94
|
+
},
|
|
95
|
+
execute: (args) => serialized(async () => {
|
|
96
|
+
if (ctx.isFrozen()) {
|
|
97
|
+
return { ok: false, error: 'harness is frozen; assert is disabled' };
|
|
98
|
+
}
|
|
99
|
+
const clauses = String(args.clauses ?? '');
|
|
100
|
+
const result = ctx.prologQuery(`deepclause_mi:repl_assert_many('${ctx.sessionId}', ${quoteString(clauses)}, Result)`);
|
|
101
|
+
const outcome = plainValue(result?.Result);
|
|
102
|
+
if (outcome === 'ok') {
|
|
103
|
+
notify('assert_many', { clauses }, 'completed', 'ok');
|
|
104
|
+
return { ok: true };
|
|
105
|
+
}
|
|
106
|
+
notify('assert_many', { clauses }, 'failed', String(outcome));
|
|
107
|
+
return { ok: false, error: String(outcome) };
|
|
108
|
+
}),
|
|
109
|
+
});
|
|
110
|
+
tools.set('retract', {
|
|
111
|
+
description: 'Remove matching clauses from the scratch harness (reserved names are protected).',
|
|
112
|
+
parameters: {
|
|
113
|
+
type: 'object',
|
|
114
|
+
properties: {
|
|
115
|
+
clause: { type: 'string', description: 'The clause pattern to retract (no trailing period required).' },
|
|
116
|
+
},
|
|
117
|
+
required: ['clause'],
|
|
118
|
+
},
|
|
119
|
+
execute: (args) => serialized(async () => {
|
|
120
|
+
if (ctx.isFrozen()) {
|
|
121
|
+
return { ok: false, error: 'harness is frozen; retract is disabled' };
|
|
122
|
+
}
|
|
123
|
+
const clause = String(args.clause ?? '');
|
|
124
|
+
const result = ctx.prologQuery(`deepclause_mi:repl_retract('${ctx.sessionId}', ${quoteString(clause)}, Result)`);
|
|
125
|
+
const outcome = plainValue(result?.Result);
|
|
126
|
+
if (outcome === 'ok') {
|
|
127
|
+
notify('retract', { clause }, 'completed', 'ok');
|
|
128
|
+
return { ok: true };
|
|
129
|
+
}
|
|
130
|
+
notify('retract', { clause }, 'failed', String(outcome));
|
|
131
|
+
return { ok: false, error: String(outcome) };
|
|
132
|
+
}),
|
|
133
|
+
});
|
|
134
|
+
tools.set('define', {
|
|
135
|
+
description: 'Replace the predicate(s) defined by a clause block: remove every predicate the block defines (plus the head pattern), then assert the block in order. A block may define several predicates. Prefer this over assert when changing existing predicates.',
|
|
136
|
+
parameters: {
|
|
137
|
+
type: 'object',
|
|
138
|
+
properties: {
|
|
139
|
+
head: { type: 'string', description: 'A head pattern for the predicate, e.g. "describe_image(Path, Text)" or "doc(describe_image/2, _)".' },
|
|
140
|
+
clauses: { type: 'string', description: 'The complete clause block for the predicate, in order, each ending with a period.' },
|
|
141
|
+
},
|
|
142
|
+
required: ['head', 'clauses'],
|
|
143
|
+
},
|
|
144
|
+
execute: (args) => serialized(async () => {
|
|
145
|
+
if (ctx.isFrozen()) {
|
|
146
|
+
return { ok: false, error: 'harness is frozen; define is disabled' };
|
|
147
|
+
}
|
|
148
|
+
const head = String(args.head ?? '');
|
|
149
|
+
const clauses = String(args.clauses ?? '');
|
|
150
|
+
const result = ctx.prologQuery(`deepclause_mi:repl_define('${ctx.sessionId}', ${quoteString(head)}, ${quoteString(clauses)}, Result)`);
|
|
151
|
+
const outcome = plainValue(result?.Result);
|
|
152
|
+
if (outcome === 'ok') {
|
|
153
|
+
notify('define', { head }, 'completed', 'ok');
|
|
154
|
+
return { ok: true };
|
|
155
|
+
}
|
|
156
|
+
notify('define', { head }, 'failed', String(outcome));
|
|
157
|
+
return { ok: false, error: String(outcome) };
|
|
158
|
+
}),
|
|
159
|
+
});
|
|
160
|
+
tools.set('execute', {
|
|
161
|
+
description: 'Run a DML goal against the scratch harness and return its bindings/output.',
|
|
162
|
+
parameters: {
|
|
163
|
+
type: 'object',
|
|
164
|
+
properties: {
|
|
165
|
+
goal: { type: 'string', description: 'The DML goal to run, e.g. "fact(5, F)".' },
|
|
166
|
+
limit: { type: 'integer', description: 'Maximum solutions to collect (default 5).' },
|
|
167
|
+
},
|
|
168
|
+
required: ['goal'],
|
|
169
|
+
},
|
|
170
|
+
execute: (args, context) => serialized(async () => {
|
|
171
|
+
const goal = String(args.goal ?? '');
|
|
172
|
+
const limit = typeof args.limit === 'number' ? args.limit : undefined;
|
|
173
|
+
const result = await ctx.executeGoal(goal, limit, context?.signal);
|
|
174
|
+
notify('execute', { goal }, result.error ? 'failed' : 'completed', result.error ?? `${result.solutions.length} solution(s)`);
|
|
175
|
+
return result;
|
|
176
|
+
}),
|
|
177
|
+
});
|
|
178
|
+
if (ctx.fileTools) {
|
|
179
|
+
const fileTools = ctx.fileTools;
|
|
180
|
+
tools.set('read_file', {
|
|
181
|
+
description: 'Read a workspace file. Paths are workspace-relative. Use this to inspect generated scripts.',
|
|
182
|
+
parameters: {
|
|
183
|
+
type: 'object',
|
|
184
|
+
properties: { path: { type: 'string', description: 'Workspace-relative file path.' } },
|
|
185
|
+
required: ['path'],
|
|
186
|
+
},
|
|
187
|
+
execute: (args) => serialized(async () => {
|
|
188
|
+
const filePath = String(args.path ?? '');
|
|
189
|
+
try {
|
|
190
|
+
const content = await fileTools.read(filePath);
|
|
191
|
+
if (content === null) {
|
|
192
|
+
notify('read_file', { path: filePath }, 'failed', 'not found');
|
|
193
|
+
return { error: `not found: ${filePath}` };
|
|
194
|
+
}
|
|
195
|
+
notify('read_file', { path: filePath }, 'completed', `${content.length} chars`);
|
|
196
|
+
return { path: filePath, content };
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
notify('read_file', { path: filePath }, 'failed', String(error));
|
|
200
|
+
return { error: String(error) };
|
|
201
|
+
}
|
|
202
|
+
}),
|
|
203
|
+
});
|
|
204
|
+
tools.set('write_file', {
|
|
205
|
+
description: 'Write a workspace file. Paths are workspace-relative; the write lands on disk immediately, so bash can run it in the same turn. Use this to author script files; link them with a script_file/2 fact and run them with exec(bash(...)).',
|
|
206
|
+
parameters: {
|
|
207
|
+
type: 'object',
|
|
208
|
+
properties: {
|
|
209
|
+
path: { type: 'string', description: 'Workspace-relative file path.' },
|
|
210
|
+
content: { type: 'string', description: 'The full file content.' },
|
|
211
|
+
},
|
|
212
|
+
required: ['path', 'content'],
|
|
213
|
+
},
|
|
214
|
+
execute: (args) => serialized(async () => {
|
|
215
|
+
const filePath = String(args.path ?? '');
|
|
216
|
+
const content = String(args.content ?? '');
|
|
217
|
+
try {
|
|
218
|
+
await fileTools.write(filePath, content);
|
|
219
|
+
notify('write_file', { path: filePath }, 'completed', `${content.length} chars`);
|
|
220
|
+
return { ok: true, path: filePath };
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
notify('write_file', { path: filePath }, 'failed', String(error));
|
|
224
|
+
return { ok: false, error: String(error) };
|
|
225
|
+
}
|
|
226
|
+
}),
|
|
227
|
+
});
|
|
228
|
+
tools.set('list_files', {
|
|
229
|
+
description: 'List a workspace directory.',
|
|
230
|
+
parameters: {
|
|
231
|
+
type: 'object',
|
|
232
|
+
properties: { path: { type: 'string', description: 'Workspace-relative directory (default ".").' } },
|
|
233
|
+
required: [],
|
|
234
|
+
},
|
|
235
|
+
execute: (args) => serialized(async () => {
|
|
236
|
+
const dir = args.path ? String(args.path) : '.';
|
|
237
|
+
try {
|
|
238
|
+
const entries = await fileTools.list(dir);
|
|
239
|
+
notify('list_files', { path: dir }, 'completed', `${entries.length} entries`);
|
|
240
|
+
return { path: dir, entries };
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
notify('list_files', { path: dir }, 'failed', String(error));
|
|
244
|
+
return { error: String(error) };
|
|
245
|
+
}
|
|
246
|
+
}),
|
|
247
|
+
});
|
|
248
|
+
tools.set('delete_file', {
|
|
249
|
+
description: 'Delete a workspace file.',
|
|
250
|
+
parameters: {
|
|
251
|
+
type: 'object',
|
|
252
|
+
properties: { path: { type: 'string', description: 'Workspace-relative file path.' } },
|
|
253
|
+
required: ['path'],
|
|
254
|
+
},
|
|
255
|
+
execute: (args) => serialized(async () => {
|
|
256
|
+
const filePath = String(args.path ?? '');
|
|
257
|
+
try {
|
|
258
|
+
await fileTools.remove(filePath);
|
|
259
|
+
notify('delete_file', { path: filePath }, 'completed', 'deleted');
|
|
260
|
+
return { ok: true };
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
notify('delete_file', { path: filePath }, 'failed', String(error));
|
|
264
|
+
return { ok: false, error: String(error) };
|
|
265
|
+
}
|
|
266
|
+
}),
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
if (ctx.askUser) {
|
|
270
|
+
tools.set('ask_user', {
|
|
271
|
+
description: 'Ask the human a clarifying question before writing the harness.',
|
|
272
|
+
parameters: {
|
|
273
|
+
type: 'object',
|
|
274
|
+
properties: {
|
|
275
|
+
prompt: { type: 'string', description: 'The question to ask.' },
|
|
276
|
+
options: { type: 'array', description: 'Optional menu of answers.' },
|
|
277
|
+
},
|
|
278
|
+
required: ['prompt'],
|
|
279
|
+
},
|
|
280
|
+
execute: (args) => serialized(async () => {
|
|
281
|
+
const prompt = String(args.prompt ?? '');
|
|
282
|
+
const options = Array.isArray(args.options) ? args.options.map(String) : undefined;
|
|
283
|
+
const result = await ctx.askUser(prompt, options);
|
|
284
|
+
notify('ask_user', { prompt }, 'completed', 'cancelled' in result ? 'cancelled' : result.answer);
|
|
285
|
+
return result;
|
|
286
|
+
}),
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
return tools;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Compact catalog injected into the meta prompt. The full schemas are always
|
|
293
|
+
* available through the `listing(tools)` / `listing` tool.
|
|
294
|
+
*/
|
|
295
|
+
export function describeMetaTools() {
|
|
296
|
+
return [
|
|
297
|
+
'- listing(filter) — read-only list of predicates (all), Name/Arity, tools, or scripts.',
|
|
298
|
+
'- assert(clause) / assert_many(clauses) — write DML clauses into the scratch harness.',
|
|
299
|
+
'- define(head, clauses) — replace a predicate (clear Name/Arity, then assert the clauses).',
|
|
300
|
+
'- retract(clause) — remove a predicate from the scratch harness.',
|
|
301
|
+
'- execute(goal, limit?) — run a DML goal against the scratch harness; returns bindings/output.',
|
|
302
|
+
'- read_file / write_file / list_files / delete_file — workspace-scoped file I/O (writes land immediately).',
|
|
303
|
+
'- ask_user(prompt, options?) — ask the human a clarifying question.',
|
|
304
|
+
'- bash — the capability host tool, available to probe the environment and run commands.',
|
|
305
|
+
].join('\n');
|
|
306
|
+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G,MAAM,GAAG,CAAC,OAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACnD,MAAM,CACJ,UAAU,EACV,EAAE,MAAM,EAAE,EACV,WAAW,EACX,WAAW,IAAI,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CACpD,CAAC;gBACF,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,wFAAwF;QACxF,uFAAuF;QACvF,4FAA4F;QAC5F,kEAAkE;QAClE,gGAAgG;QAChG,4GAA4G;QAC5G,qEAAqE;QACrE,yFAAyF;KAC1F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REPL capability host tools.
|
|
3
|
+
*
|
|
4
|
+
* The only capability tool is **`bash`**, registered through the SDK's shell
|
|
5
|
+
* manager and sandbox config. Everything else the model needs (file I/O,
|
|
6
|
+
* search, fetching) is DML language, a linked script run through `bash`, or the
|
|
7
|
+
* human-in-the-loop channel (`ask_user` / `input/2`). `--tools`/`--no-tools`
|
|
8
|
+
* control whether `bash` is registered.
|
|
9
|
+
*/
|
|
10
|
+
import { type HostShellConfig } from '../system/runtime/shell-manager.js';
|
|
11
|
+
import type { DMLEvent, ToolDefinition } from '../types.js';
|
|
12
|
+
export declare const DEFAULT_REPL_TOOLS: readonly ["bash"];
|
|
13
|
+
export interface ReplToolsetOptions {
|
|
14
|
+
workspacePath: string;
|
|
15
|
+
sandbox?: boolean;
|
|
16
|
+
network?: boolean;
|
|
17
|
+
hostConfig?: HostShellConfig;
|
|
18
|
+
/** Capability tool names to register. `null`/empty means no capability tools. */
|
|
19
|
+
toolNames?: string[] | null;
|
|
20
|
+
signal?: AbortSignal;
|
|
21
|
+
onEvent?: (event: DMLEvent) => void;
|
|
22
|
+
}
|
|
23
|
+
export interface ReplToolset {
|
|
24
|
+
tools: Map<string, ToolDefinition>;
|
|
25
|
+
/** Catalog text injected into the meta prompt. */
|
|
26
|
+
catalog: string;
|
|
27
|
+
dispose(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
/** Human-readable catalog of the registered capability tools. */
|
|
30
|
+
export declare function buildToolCatalog(tools: Map<string, ToolDefinition>): string;
|
|
31
|
+
export declare function createReplToolset(options: ReplToolsetOptions): Promise<ReplToolset>;
|
|
32
|
+
//# sourceMappingURL=toolset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolset.d.ts","sourceRoot":"","sources":["../../src/repl/toolset.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE9F,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE5D,eAAO,MAAM,kBAAkB,mBAAoB,CAAC;AAEpD,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;CACrC;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACnC,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,iEAAiE;AACjE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,MAAM,CAa3E;AAED,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CA4DzF"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REPL capability host tools.
|
|
3
|
+
*
|
|
4
|
+
* The only capability tool is **`bash`**, registered through the SDK's shell
|
|
5
|
+
* manager and sandbox config. Everything else the model needs (file I/O,
|
|
6
|
+
* search, fetching) is DML language, a linked script run through `bash`, or the
|
|
7
|
+
* human-in-the-loop channel (`ask_user` / `input/2`). `--tools`/`--no-tools`
|
|
8
|
+
* control whether `bash` is registered.
|
|
9
|
+
*/
|
|
10
|
+
import { createShellManager } from '../system/runtime/shell-manager.js';
|
|
11
|
+
import { createShellToolEventBridge } from '../system/runtime/shell-tool-events.js';
|
|
12
|
+
export const DEFAULT_REPL_TOOLS = ['bash'];
|
|
13
|
+
/** Human-readable catalog of the registered capability tools. */
|
|
14
|
+
export function buildToolCatalog(tools) {
|
|
15
|
+
if (tools.size === 0) {
|
|
16
|
+
return 'No capability host tools are registered. Use DML/Prolog, or write a script file and run it with exec(bash(...)).';
|
|
17
|
+
}
|
|
18
|
+
const lines = [];
|
|
19
|
+
for (const [name, tool] of tools) {
|
|
20
|
+
const properties = tool.parameters?.properties ?? {};
|
|
21
|
+
const params = Object.keys(properties).join(', ') || 'none';
|
|
22
|
+
lines.push(`- ${name}: ${tool.description} (parameters: ${params})`);
|
|
23
|
+
}
|
|
24
|
+
lines.push('');
|
|
25
|
+
lines.push('DML file I/O always uses the MI predicates (open/3, close/1, read_string/3, write/2, write_file/2, read_file/2, append_file/2); it is not a host tool.');
|
|
26
|
+
return lines.join('\n');
|
|
27
|
+
}
|
|
28
|
+
export async function createReplToolset(options) {
|
|
29
|
+
const requested = options.toolNames === null
|
|
30
|
+
? []
|
|
31
|
+
: options.toolNames ?? [...DEFAULT_REPL_TOOLS];
|
|
32
|
+
const tools = new Map();
|
|
33
|
+
let shell = requested.includes('bash')
|
|
34
|
+
? createShellManager({
|
|
35
|
+
workspacePath: options.workspacePath,
|
|
36
|
+
sandbox: options.sandbox,
|
|
37
|
+
network: options.network,
|
|
38
|
+
hostConfig: options.hostConfig,
|
|
39
|
+
})
|
|
40
|
+
: null;
|
|
41
|
+
if (shell) {
|
|
42
|
+
const shellManager = shell;
|
|
43
|
+
tools.set('bash', {
|
|
44
|
+
description: 'Run a shell command in the active workspace shell.',
|
|
45
|
+
parameters: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties: {
|
|
48
|
+
command: { type: 'string', description: 'Shell command to execute.' },
|
|
49
|
+
timeoutMs: {
|
|
50
|
+
type: 'integer',
|
|
51
|
+
description: 'Wall-clock timeout in milliseconds (optional; overrides DC_HOST_SHELL_TIMEOUT_MS).',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
required: ['command'],
|
|
55
|
+
},
|
|
56
|
+
execute: async (args, context) => {
|
|
57
|
+
const command = String(args.command ?? args.arg1 ?? '');
|
|
58
|
+
const timeoutMs = typeof args.timeoutMs === 'number' && Number.isFinite(args.timeoutMs) && args.timeoutMs > 0
|
|
59
|
+
? args.timeoutMs
|
|
60
|
+
: undefined;
|
|
61
|
+
// Prefer the per-turn signal the runner/agent loop passes so Ctrl-C
|
|
62
|
+
// terminates the running command (fall back to a startup signal).
|
|
63
|
+
return shellManager.exec(command, context?.signal ?? options.signal, createShellToolEventBridge({
|
|
64
|
+
toolName: 'bash',
|
|
65
|
+
toolArgs: timeoutMs === undefined ? { command } : { command, timeoutMs },
|
|
66
|
+
emit: options.onEvent,
|
|
67
|
+
}), { timeoutMs });
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
tools,
|
|
73
|
+
catalog: buildToolCatalog(tools),
|
|
74
|
+
dispose: async () => {
|
|
75
|
+
if (shell) {
|
|
76
|
+
await shell.dispose();
|
|
77
|
+
shell = null;
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=toolset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolset.js","sourceRoot":"","sources":["../../src/repl/toolset.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,kBAAkB,EAAwB,MAAM,oCAAoC,CAAC;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAGpF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAM,CAAU,CAAC;AAoBpD,iEAAiE;AACjE,MAAM,UAAU,gBAAgB,CAAC,KAAkC;IACjE,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,kHAAkH,CAAC;IAC5H,CAAC;IACD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;QACjC,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,IAAI,EAAE,CAAC;QACrD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC;QAC5D,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,KAAK,IAAI,CAAC,WAAW,iBAAiB,MAAM,GAAG,CAAC,CAAC;IACvE,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,wJAAwJ,CAAC,CAAC;IACrK,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAA2B;IACjE,MAAM,SAAS,GAAG,OAAO,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CAAC;gBACd,oEAAoE;gBACpE,kEAAkE;gBAClE,OAAO,YAAY,CAAC,IAAI,CACtB,OAAO,EACP,OAAO,EAAE,MAAM,IAAI,OAAO,CAAC,MAAM,EACjC,0BAA0B,CAAC;oBACzB,QAAQ,EAAE,MAAM;oBAChB,QAAQ,EAAE,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE;oBACxE,IAAI,EAAE,OAAO,CAAC,OAAO;iBACtB,CAAC,EACF,EAAE,SAAS,EAAE,CACd,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,KAAK;QACL,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC;QAChC,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;gBACtB,KAAK,GAAG,IAAI,CAAC;YACf,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor that can display a "human input needed" question in its top border.
|
|
3
|
+
*
|
|
4
|
+
* The REPL uses the same editor for normal prompts and for `ask_user` / `input/2`.
|
|
5
|
+
* While input is needed the border turns orange and shows the question, so the
|
|
6
|
+
* user can see *why* the cursor is waiting without a separate prompt line.
|
|
7
|
+
*/
|
|
8
|
+
import { Editor, type EditorTheme, type TUI } from '@earendil-works/pi-tui';
|
|
9
|
+
export declare class PromptEditor extends Editor {
|
|
10
|
+
private prompt;
|
|
11
|
+
constructor(tui: TUI, theme: EditorTheme);
|
|
12
|
+
/** Set (or clear) the question shown in the top border. */
|
|
13
|
+
setPrompt(prompt: string | null): void;
|
|
14
|
+
protected renderTopBorder(width: number, hiddenLineCount: number): string;
|
|
15
|
+
protected renderBottomBorder(width: number, hiddenLineCount: number): string;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../src/repl/tui/editor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAiC,KAAK,WAAW,EAAE,KAAK,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAI3G,qBAAa,YAAa,SAAQ,MAAM;IACtC,OAAO,CAAC,MAAM,CAAuB;gBAEzB,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW;IAIxC,2DAA2D;IAC3D,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAKtC,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM;IAazE,SAAS,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM;CAM7E"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor that can display a "human input needed" question in its top border.
|
|
3
|
+
*
|
|
4
|
+
* The REPL uses the same editor for normal prompts and for `ask_user` / `input/2`.
|
|
5
|
+
* While input is needed the border turns orange and shows the question, so the
|
|
6
|
+
* user can see *why* the cursor is waiting without a separate prompt line.
|
|
7
|
+
*/
|
|
8
|
+
import { Editor, truncateToWidth, visibleWidth } from '@earendil-works/pi-tui';
|
|
9
|
+
import { promptBorder, promptLabel } from './theme.js';
|
|
10
|
+
export class PromptEditor extends Editor {
|
|
11
|
+
prompt = null;
|
|
12
|
+
constructor(tui, theme) {
|
|
13
|
+
super(tui, theme);
|
|
14
|
+
}
|
|
15
|
+
/** Set (or clear) the question shown in the top border. */
|
|
16
|
+
setPrompt(prompt) {
|
|
17
|
+
this.prompt = prompt;
|
|
18
|
+
this.invalidate();
|
|
19
|
+
}
|
|
20
|
+
renderTopBorder(width, hiddenLineCount) {
|
|
21
|
+
if (!this.prompt || width <= 0) {
|
|
22
|
+
return super.renderTopBorder(width, hiddenLineCount);
|
|
23
|
+
}
|
|
24
|
+
const left = '── ';
|
|
25
|
+
const right = ' ';
|
|
26
|
+
const available = Math.max(1, width - visibleWidth(left) - visibleWidth(right));
|
|
27
|
+
const label = truncateToWidth(`? ${this.prompt}`, available, '…');
|
|
28
|
+
const used = visibleWidth(left) + visibleWidth(label) + visibleWidth(right);
|
|
29
|
+
const rest = '─'.repeat(Math.max(0, width - used));
|
|
30
|
+
return `${promptBorder(left)}${promptLabel(label)}${promptBorder(`${right}${rest}`)}`;
|
|
31
|
+
}
|
|
32
|
+
renderBottomBorder(width, hiddenLineCount) {
|
|
33
|
+
if (!this.prompt || width <= 0) {
|
|
34
|
+
return super.renderBottomBorder(width, hiddenLineCount);
|
|
35
|
+
}
|
|
36
|
+
return promptBorder('─'.repeat(width));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.js","sourceRoot":"","sources":["../../../src/repl/tui/editor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,YAAY,EAA8B,MAAM,wBAAwB,CAAC;AAE3G,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEvD,MAAM,OAAO,YAAa,SAAQ,MAAM;IAC9B,MAAM,GAAkB,IAAI,CAAC;IAErC,YAAY,GAAQ,EAAE,KAAkB;QACtC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,2DAA2D;IAC3D,SAAS,CAAC,MAAqB;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAES,eAAe,CAAC,KAAa,EAAE,eAAuB;QAC9D,IAAI,CAA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lines: workspace/session/backend, then token totals, context usage for
|
|
5
|
+
* the active frame slot, and the current model (with reasoning level).
|
|
6
|
+
*/
|
|
7
|
+
import { type Component } from '@earendil-works/pi-tui';
|
|
8
|
+
import { type ReplStatusSnapshot } from '../status.js';
|
|
9
|
+
export interface StatusBarOptions {
|
|
10
|
+
getSnapshot: () => ReplStatusSnapshot;
|
|
11
|
+
workspace: string;
|
|
12
|
+
sessionId: string;
|
|
13
|
+
/** Harness this session edits. */
|
|
14
|
+
harness?: string;
|
|
15
|
+
backend: string;
|
|
16
|
+
isFrozen?: () => boolean;
|
|
17
|
+
/** True while a turn is running (so the user knows they can steer). */
|
|
18
|
+
isRunning?: () => boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare class StatusBarComponent implements Component {
|
|
21
|
+
private readonly options;
|
|
22
|
+
constructor(options: StatusBarOptions);
|
|
23
|
+
render(width: number): string[];
|
|
24
|
+
invalidate(): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=status-bar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-bar.d.ts","sourceRoot":"","sources":["../../../src/repl/tui/status-bar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAiC,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEvF,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AAGtB,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,kBAAkB,CAAC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC;IACzB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC;CAC3B;AAmBD,qBAAa,kBAAmB,YAAW,SAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,gBAAgB;IAEtD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAmB/B,UAAU,IAAI,IAAI;CAGnB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fixed status bar for the REPL TUI (pi-style footer).
|
|
3
|
+
*
|
|
4
|
+
* Two lines: workspace/session/backend, then token totals, context usage for
|
|
5
|
+
* the active frame slot, and the current model (with reasoning level).
|
|
6
|
+
*/
|
|
7
|
+
import { truncateToWidth, visibleWidth } from '@earendil-works/pi-tui';
|
|
8
|
+
import { formatContextSegment, formatModelSegment, formatUsageSegment, } from '../status.js';
|
|
9
|
+
import { dim } from './theme.js';
|
|
10
|
+
/** Right-align `right` within `width`, truncating the left side if needed. */
|
|
11
|
+
function align(left, right, width) {
|
|
12
|
+
const minPadding = 2;
|
|
13
|
+
const leftWidth = visibleWidth(left);
|
|
14
|
+
const rightWidth = visibleWidth(right);
|
|
15
|
+
if (leftWidth + minPadding + rightWidth <= width) {
|
|
16
|
+
return left + ' '.repeat(width - leftWidth - rightWidth) + right;
|
|
17
|
+
}
|
|
18
|
+
const available = width - leftWidth - minPadding;
|
|
19
|
+
if (available <= 0) {
|
|
20
|
+
return truncateToWidth(left, width, '');
|
|
21
|
+
}
|
|
22
|
+
const truncated = truncateToWidth(right, available, '');
|
|
23
|
+
const total = leftWidth + visibleWidth(truncated);
|
|
24
|
+
return left + ' '.repeat(Math.max(0, width - total)) + truncated;
|
|
25
|
+
}
|
|
26
|
+
export class StatusBarComponent {
|
|
27
|
+
options;
|
|
28
|
+
constructor(options) {
|
|
29
|
+
this.options = options;
|
|
30
|
+
}
|
|
31
|
+
render(width) {
|
|
32
|
+
const snapshot = this.options.getSnapshot();
|
|
33
|
+
const frozen = this.options.isFrozen?.() ? ' · FROZEN' : '';
|
|
34
|
+
const running = this.options.isRunning?.() ? ' · running (type to steer)' : '';
|
|
35
|
+
const harness = this.options.harness ? ` · harness ${this.options.harness}` : '';
|
|
36
|
+
const line1 = truncateToWidth(`${this.options.workspace} · session ${this.options.sessionId}${harness} · backend ${this.options.backend}${frozen}${running}`, width, '…');
|
|
37
|
+
const usage = formatUsageSegment(snapshot);
|
|
38
|
+
const context = formatContextSegment(snapshot);
|
|
39
|
+
const left = [usage, context].filter(Boolean).join(' ');
|
|
40
|
+
const line2 = align(left, formatModelSegment(snapshot), width);
|
|
41
|
+
return [dim(line1), dim(line2)];
|
|
42
|
+
}
|
|
43
|
+
invalidate() {
|
|
44
|
+
// Stateless rendering: reads the snapshot on each frame.
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=status-bar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-bar.js","sourceRoot":"","sources":["../../../src/repl/tui/status-bar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAkB,MAAM,wBAAwB,CAAC;AAEvF,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,GAEnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAcjC,8EAA8E;AAC9E,SAAS,KAAK,CAAC,IAAY,EAAE,KAAa,EAAE,KAAa;IACvD,MAAM,UAAU,GAAG,CAAC,CAAC;IACrB,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACvC,IAAI,SAAS,GAAG,UAAU,GAAG,UAAU,IAAI,KAAK,EAAE,CAAC;QACjD,OAAO,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,SAAS,GAAG,UAAU,CAAC,GAAG,KAAK,CAAC;IACnE,CAAC;IACD,MAAM,SAAS,GAAG,KAAK,GAAG,SAAS,GAAG,UAAU,CAAC;IACj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G,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAC3C,MAAM,OAAO,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAC/C,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;QAE/D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAClC,CAAC;IAED,UAAU;QACR,yDAAyD;IAC3D,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal ANSI theme for the REPL TUI.
|
|
3
|
+
*
|
|
4
|
+
* The transcript is fed by `ReplRenderer` (rich mode) and the status bar is
|
|
5
|
+
* rendered as plain text; these helpers add the few colors the TUI itself owns
|
|
6
|
+
* (user-message blocks, the editor border, and the dim footer).
|
|
7
|
+
*/
|
|
8
|
+
import { type EditorTheme } from '@earendil-works/pi-tui';
|
|
9
|
+
/**
|
|
10
|
+
* Render one line of a user message as a full-width blue block (pi-style). The
|
|
11
|
+
* text is padded to the terminal width so the background spans the row.
|
|
12
|
+
*/
|
|
13
|
+
export declare function renderUserLine(text: string, width: number): string;
|
|
14
|
+
/** An `ask_user` / `input/2` answer echo (distinct from a normal prompt). */
|
|
15
|
+
export declare function formatInputAnswer(text: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Render one line of a steering message as a full-width amber block, prefixed
|
|
18
|
+
* with `Steering: ` on the first line. Padded to the terminal width.
|
|
19
|
+
*/
|
|
20
|
+
export declare const STEER_LABEL = " Steering: ";
|
|
21
|
+
export declare function renderSteerLine(text: string, width: number, first?: boolean): string;
|
|
22
|
+
/** The border of the editing box while the runtime needs human input. */
|
|
23
|
+
export declare function promptBorder(text: string): string;
|
|
24
|
+
/** The question shown inside the editing box while input is needed. */
|
|
25
|
+
export declare function promptLabel(text: string): string;
|
|
26
|
+
/** Dim the status bar so it recedes behind the transcript. */
|
|
27
|
+
export declare function dim(text: string): string;
|
|
28
|
+
/** Editor theme: a blue border, cyan selection. */
|
|
29
|
+
export declare function editorTheme(): EditorTheme;
|
|
30
|
+
//# sourceMappingURL=theme.d.ts.map
|