deepclause-sdk 0.1.0 → 0.1.2

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.
Files changed (142) hide show
  1. package/README.md +83 -12
  2. package/dist/agent.d.ts +14 -1
  3. package/dist/agent.d.ts.map +1 -1
  4. package/dist/agent.js +117 -9
  5. package/dist/agent.js.map +1 -1
  6. package/dist/cli/config.d.ts +86 -26
  7. package/dist/cli/config.d.ts.map +1 -1
  8. package/dist/cli/config.js +15 -0
  9. package/dist/cli/config.js.map +1 -1
  10. package/dist/cli/index.js +38 -0
  11. package/dist/cli/index.js.map +1 -1
  12. package/dist/cli/repl.d.ts +27 -0
  13. package/dist/cli/repl.d.ts.map +1 -1
  14. package/dist/cli/repl.js +191 -5
  15. package/dist/cli/repl.js.map +1 -1
  16. package/dist/cli/run.d.ts.map +1 -1
  17. package/dist/cli/run.js +16 -0
  18. package/dist/cli/run.js.map +1 -1
  19. package/dist/cli/visualize.d.ts +4 -0
  20. package/dist/cli/visualize.d.ts.map +1 -1
  21. package/dist/cli/visualize.js +29 -4
  22. package/dist/cli/visualize.js.map +1 -1
  23. package/dist/prolog/bridge.d.ts +3 -1
  24. package/dist/prolog/bridge.d.ts.map +1 -1
  25. package/dist/prolog/bridge.js +2 -0
  26. package/dist/prolog/bridge.js.map +1 -1
  27. package/dist/prolog/loader.d.ts +32 -0
  28. package/dist/prolog/loader.d.ts.map +1 -1
  29. package/dist/prolog/loader.js +87 -0
  30. package/dist/prolog/loader.js.map +1 -1
  31. package/dist/prolog-src/deepclause_mi.pl +1217 -120
  32. package/dist/repl/agent.d.ts +33 -1
  33. package/dist/repl/agent.d.ts.map +1 -1
  34. package/dist/repl/agent.js +91 -8
  35. package/dist/repl/agent.js.map +1 -1
  36. package/dist/repl/backend.d.ts +31 -0
  37. package/dist/repl/backend.d.ts.map +1 -1
  38. package/dist/repl/backend.js +122 -77
  39. package/dist/repl/backend.js.map +1 -1
  40. package/dist/repl/harness-tools.d.ts +49 -2
  41. package/dist/repl/harness-tools.d.ts.map +1 -1
  42. package/dist/repl/harness-tools.js +87 -7
  43. package/dist/repl/harness-tools.js.map +1 -1
  44. package/dist/repl/imagegen.d.ts +29 -0
  45. package/dist/repl/imagegen.d.ts.map +1 -0
  46. package/dist/repl/imagegen.js +84 -0
  47. package/dist/repl/imagegen.js.map +1 -0
  48. package/dist/repl/index.d.ts +20 -2
  49. package/dist/repl/index.d.ts.map +1 -1
  50. package/dist/repl/index.js +6 -0
  51. package/dist/repl/index.js.map +1 -1
  52. package/dist/repl/model-resolver.d.ts +59 -0
  53. package/dist/repl/model-resolver.d.ts.map +1 -0
  54. package/dist/repl/model-resolver.js +156 -0
  55. package/dist/repl/model-resolver.js.map +1 -0
  56. package/dist/repl/render.d.ts +36 -2
  57. package/dist/repl/render.d.ts.map +1 -1
  58. package/dist/repl/render.js +175 -17
  59. package/dist/repl/render.js.map +1 -1
  60. package/dist/repl/session.d.ts +129 -4
  61. package/dist/repl/session.d.ts.map +1 -1
  62. package/dist/repl/session.js +380 -17
  63. package/dist/repl/session.js.map +1 -1
  64. package/dist/repl/tool-arguments.d.ts +36 -0
  65. package/dist/repl/tool-arguments.d.ts.map +1 -0
  66. package/dist/repl/tool-arguments.js +123 -0
  67. package/dist/repl/tool-arguments.js.map +1 -0
  68. package/dist/repl/toolset.d.ts +28 -1
  69. package/dist/repl/toolset.d.ts.map +1 -1
  70. package/dist/repl/toolset.js +52 -4
  71. package/dist/repl/toolset.js.map +1 -1
  72. package/dist/repl/tui/transcript.d.ts +2 -0
  73. package/dist/repl/tui/transcript.d.ts.map +1 -1
  74. package/dist/repl/tui/transcript.js +16 -0
  75. package/dist/repl/tui/transcript.js.map +1 -1
  76. package/dist/runner.d.ts +44 -2
  77. package/dist/runner.d.ts.map +1 -1
  78. package/dist/runner.js +293 -33
  79. package/dist/runner.js.map +1 -1
  80. package/dist/system/assets/docs/AGENT_PROMPT.md +1000 -44
  81. package/dist/system/assets/docs/DML_AUTHORING.md +96 -17
  82. package/dist/system/assets/docs/DML_REFERENCE.md +652 -39
  83. package/dist/system/assets/docs/PROLOG_SNIPPETS.md +45 -1
  84. package/dist/system/assets/docs/TASK_PROMPT.md +2 -0
  85. package/dist/system/environment.d.ts +36 -0
  86. package/dist/system/environment.d.ts.map +1 -0
  87. package/dist/system/environment.js +81 -0
  88. package/dist/system/environment.js.map +1 -0
  89. package/dist/system/runtime/shell-manager.d.ts +40 -2
  90. package/dist/system/runtime/shell-manager.d.ts.map +1 -1
  91. package/dist/system/runtime/shell-manager.js +82 -16
  92. package/dist/system/runtime/shell-manager.js.map +1 -1
  93. package/dist/system/runtime/shell-tool-events.js +25 -1
  94. package/dist/system/runtime/shell-tool-events.js.map +1 -1
  95. package/dist/types.d.ts +76 -2
  96. package/dist/types.d.ts.map +1 -1
  97. package/dist/visualize/ascii.d.ts +55 -0
  98. package/dist/visualize/ascii.d.ts.map +1 -0
  99. package/dist/visualize/ascii.js +242 -0
  100. package/dist/visualize/ascii.js.map +1 -0
  101. package/dist/visualize/display.d.ts +24 -0
  102. package/dist/visualize/display.d.ts.map +1 -0
  103. package/dist/visualize/display.js +29 -0
  104. package/dist/visualize/display.js.map +1 -0
  105. package/dist/visualize/graphics.d.ts +35 -0
  106. package/dist/visualize/graphics.d.ts.map +1 -0
  107. package/dist/visualize/graphics.js +96 -0
  108. package/dist/visualize/graphics.js.map +1 -0
  109. package/dist/visualize/image.d.ts +38 -0
  110. package/dist/visualize/image.d.ts.map +1 -0
  111. package/dist/visualize/image.js +95 -0
  112. package/dist/visualize/image.js.map +1 -0
  113. package/dist/visualize/index.d.ts +7 -0
  114. package/dist/visualize/index.d.ts.map +1 -1
  115. package/dist/visualize/index.js +9 -0
  116. package/dist/visualize/index.js.map +1 -1
  117. package/dist/visualize/raster.d.ts +23 -0
  118. package/dist/visualize/raster.d.ts.map +1 -0
  119. package/dist/visualize/raster.js +47 -0
  120. package/dist/visualize/raster.js.map +1 -0
  121. package/dist/visualize/svg.d.ts +39 -0
  122. package/dist/visualize/svg.d.ts.map +1 -0
  123. package/dist/visualize/svg.js +148 -0
  124. package/dist/visualize/svg.js.map +1 -0
  125. package/dist/visualize/transcode.d.ts +13 -0
  126. package/dist/visualize/transcode.d.ts.map +1 -0
  127. package/dist/visualize/transcode.js +40 -0
  128. package/dist/visualize/transcode.js.map +1 -0
  129. package/docs/images/repl.png +0 -0
  130. package/package.json +10 -6
  131. package/src/prolog-src/deepclause_mi.pl +1217 -120
  132. package/dist/compaction.d.ts +0 -98
  133. package/dist/compaction.d.ts.map +0 -1
  134. package/dist/compaction.js +0 -471
  135. package/dist/compaction.js.map +0 -1
  136. package/dist/repl/tools.d.ts +0 -53
  137. package/dist/repl/tools.d.ts.map +0 -1
  138. package/dist/repl/tools.js +0 -307
  139. package/dist/repl/tools.js.map +0 -1
  140. package/dist/system/assets/compactors/default-loop-compactor.dml +0 -43
  141. package/dist/system/assets/compactors/default-session-compactor.dml +0 -30
  142. package/dist/system/assets/docs/META_PROMPT.md +0 -68
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/repl/session.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,OAAO,EAAwB,KAAK,KAAK,EAA2B,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7G,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAAA,OAAO,KAAK,EAC9F,QAAQ,EACR,SAAS,EAET,aAAa,EACb,cAAc,EACd,UAAU,EACX,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAIL,KAAK,cAAc,EAGpB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,iBAAiB;IAChC,4DAA4D;IAC5D,SAAS,C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
11
11
  import { strFromU8, strToU8, unzipSync, zipSync } from 'fflate';
12
- import { loadProlog, mountWorkspace } from '../prolog/loader.js';
12
+ import { loadProlog, mountWorkspace, takePrologMessages, } from '../prolog/loader.js';
13
+ import { describeShellExecutionBackend, } from '../system/runtime/shell-manager.js';
13
14
  import { getWorkspaceDocAssetPath } from '../system/assets/index.js';
14
15
  import { DMLRunner, toJsValue } from '../runner.js';
15
16
  import { compactMemory, estimateMemoryTokens, shouldCompact, toCompactionEvent, } from './compaction.js';
16
17
  import { HarnessAgent } from './agent.js';
17
- import { createHarnessTools } from './harness-tools.js';
18
+ import { BRIEF_VALUE_CHARS, createHarnessTools } from './harness-tools.js';
18
19
  import { buildParamsTerm, plainValue, quotePrologString } from './frames.js';
19
20
  import { buildHarnessHeader, } from './export.js';
20
21
  import { HistoryStore, harnessHash, } from './history.js';
22
+ import { buildDiagramPrompt, extractMermaid, parseMermaidFlowchart, rasterizeSvg, renderFlowchartSvg, renderMermaidAscii, resolveMedia, validateMermaid, } from '../visualize/index.js';
23
+ import { generateLlmReply } from '../prolog/bridge.js';
24
+ import { formatModelCatalogEntry } from './model-resolver.js';
21
25
  let sessionCounter = 0;
22
26
  function nextSessionId() {
23
27
  sessionCounter += 1;
@@ -42,6 +46,8 @@ export class DMLSession {
42
46
  compactionAuto = false;
43
47
  contextWindow;
44
48
  llmBackend;
49
+ imageBackend;
50
+ modelResolver;
45
51
  temperature = 0.7;
46
52
  maxTokens = 65536;
47
53
  /** Persisted authoring-agent conversation (agent mode). */
@@ -72,6 +78,10 @@ export class DMLSession {
72
78
  resume;
73
79
  /** Harness this session edits. */
74
80
  harnessName;
81
+ /** Effective shell backend; see DMLSessionOptions.executionBackend. */
82
+ executionBackend;
83
+ /** Full resolution for the backend, for the agent's environment block. */
84
+ executionEnvironment;
75
85
  autoLoadHarness;
76
86
  /** Monotonic per-session turn counter used by history records. */
77
87
  turnCounter = 0;
@@ -96,17 +106,22 @@ export class DMLSession {
96
106
  this.historyOptions = options.history;
97
107
  this.resume = options.resume ?? false;
98
108
  this.harnessName = options.harnessName ?? 'main';
109
+ this.executionBackend = options.executionBackend ?? 'clean-room';
110
+ this.executionEnvironment = describeShellExecutionBackend(this.executionBackend === 'agentvm', this.executionBackend === 'agentvm' ? {} : { wrapper: this.executionBackend });
99
111
  this.autoLoadHarness = options.autoLoadHarness ?? true;
100
112
  this.compactionSettings = options.compaction?.settings;
101
113
  this.compactionAuto = options.compaction?.auto ?? false;
102
114
  this.contextWindow = options.contextWindow;
103
115
  this.llmBackend = options.runnerOptions.llmBackend;
116
+ this.imageBackend = options.runnerOptions.imageBackend;
117
+ this.modelResolver = options.runnerOptions.modelResolver;
104
118
  this.temperature = options.runnerOptions.temperature;
105
119
  this.maxTokens = options.runnerOptions.maxTokens;
106
120
  this.runner = new DMLRunner(swipl, {
107
121
  ...options.runnerOptions,
122
+ environment: this.executionEnvironment,
108
123
  compactMessages: options.compaction
109
- ? (messages, lastInputTokens) => this.compactLoopMessages(messages, lastInputTokens)
124
+ ? (messages, lastInputTokens, contextWindow) => this.compactLoopMessages(messages, lastInputTokens, contextWindow)
110
125
  : undefined,
111
126
  });
112
127
  this.runner.bindSession(this.sessionId);
@@ -136,6 +151,10 @@ export class DMLSession {
136
151
  const sessionParams = {
137
152
  workspace_path: options.workspacePath ?? './',
138
153
  trace: options.trace ?? false,
154
+ // `sandbox-exec` is a subtraction expression to a Prolog parser, so the
155
+ // hyphen becomes an underscore on the way in; the model still sees the
156
+ // real name in its environment block.
157
+ sandbox: session.executionBackend.replace(/-/g, '_'),
139
158
  ...options.params,
140
159
  };
141
160
  if (options.gasLimit !== undefined) {
@@ -172,6 +191,16 @@ export class DMLSession {
172
191
  getSessionId() {
173
192
  return this.sessionId;
174
193
  }
194
+ /**
195
+ * Prolog output captured since the last drain.
196
+ *
197
+ * The step loop surfaces this while a goal runs; this accessor is for messages
198
+ * produced by paths that are not the step loop — a load, a host query — so a
199
+ * host can render them rather than have them vanish into a queue.
200
+ */
201
+ takePrologMessages() {
202
+ return takePrologMessages();
203
+ }
175
204
  /** Parse and load DML source into the living module. */
176
205
  async loadCode(code) {
177
206
  if (this.disposed) {
@@ -182,7 +211,25 @@ export class DMLSession {
182
211
  if (error === undefined || error === null) {
183
212
  return { error: 'Failed to load code' };
184
213
  }
185
- return error === 'none' ? {} : { error: String(error) };
214
+ if (error !== 'none')
215
+ return { error: String(error) };
216
+ // Parsing is where the term reader speaks up (`\`-continuation, singleton
217
+ // warnings), so load-time diagnostics belong with the load's warnings
218
+ // instead of arriving mid-render later.
219
+ const prologWarnings = takePrologMessages().map((message) => message.text);
220
+ return { warnings: [...this.unhandledDirectives(), ...prologWarnings] };
221
+ }
222
+ /**
223
+ * Directives the loader recorded because it does not handle them. They did
224
+ * nothing, which is worth saying: `:- repl_delete(f/1).` silently discarded was
225
+ * a predicate the author believed they had removed.
226
+ */
227
+ unhandledDirectives() {
228
+ const result = this.prologQuery(`deepclause_mi:repl_unhandled_directives('${this.sessionId}', Ds)`);
229
+ const raw = plainValue(result?.Ds);
230
+ if (!Array.isArray(raw))
231
+ return [];
232
+ return raw.map((directive) => `unrecognised directive ignored: ${formatTerm(directive)}`);
186
233
  }
187
234
  /**
188
235
  * Load a DML file (or a `.zip` bundle) into the living module.
@@ -593,6 +640,10 @@ export class DMLSession {
593
640
  const result = this.prologQuery(`deepclause_mi:repl_user_predicates_text('${this.sessionId}', Text)`);
594
641
  return String(plainValue(result?.Text) ?? '').trim() === '';
595
642
  }
643
+ /** Number of user predicates (`Name/Arity`) currently in the harness. */
644
+ predicateCount() {
645
+ return this.predicateList().length;
646
+ }
596
647
  async saveCurrentHarness(reason, header = `aborted turn: ${reason}`) {
597
648
  const result = this.prologQuery(`deepclause_mi:export_harness('${this.sessionId}', ${quoteString(header)}, Text)`);
598
649
  const text = String(plainValue(result?.Text) ?? '');
@@ -732,7 +783,7 @@ export class DMLSession {
732
783
  * The child frame uses the living scratch module and may itself call task()
733
784
  * (RLM-style recursion); its harness-memory writes are discarded afterward.
734
785
  */
735
- async executeGoal(goal, limit = 5, onEvent, signal) {
786
+ async executeGoal(goal, limit = 5, onEvent, signal, bindingMode = 'full') {
736
787
  const startedAt = Date.now();
737
788
  const elapsed = () => Date.now() - startedAt;
738
789
  const childDepth = this.frameDepth + 1;
@@ -765,8 +816,16 @@ export class DMLSession {
765
816
  try {
766
817
  for await (const event of this.runner.runFrame(frame.id, this.buildRunOptions({ signal }))) {
767
818
  onEvent?.(event);
768
- if (event.type === 'solution' && solutions.length < limit) {
769
- solutions.push(event.solution?.bindings ?? []);
819
+ if (event.type === 'solution') {
820
+ if (solutions.length < limit) {
821
+ solutions.push(event.solution?.bindings ?? []);
822
+ }
823
+ // Stop enumerating once the limit is reached: a nondeterministic goal
824
+ // (e.g. an unlabelled CLP model) can otherwise produce unbounded
825
+ // solutions and flood the session before the turn timeout.
826
+ if (solutions.length >= limit) {
827
+ break;
828
+ }
770
829
  }
771
830
  else if (event.type === 'output' || event.type === 'answer') {
772
831
  output += `${event.content ?? ''}\n`;
@@ -781,12 +840,19 @@ export class DMLSession {
781
840
  this.frameDepth = childDepth - 1;
782
841
  this.setMemory('harness', memoryBefore);
783
842
  }
843
+ const bindingCount = solutions[0]?.length ?? 0;
784
844
  return {
785
- bindings: solutions[0] ?? [],
786
- solutions,
845
+ ...shapeBindings(solutions, bindingMode),
787
846
  output: output.slice(0, 4000),
788
847
  error: runError,
789
848
  elapsedMs: elapsed(),
849
+ ...(bindingMode === 'full'
850
+ ? {}
851
+ : {
852
+ bindingsNote: bindingMode === 'none'
853
+ ? `${bindingCount} binding${bindingCount === 1 ? '' : 's'} omitted (use bindings: "brief" to see the names, or "full" for the values)`
854
+ : `values shortened to ${BRIEF_VALUE_CHARS} characters (use bindings: "full" for the whole value)`,
855
+ }),
790
856
  };
791
857
  }
792
858
  // ---- Authoring agent (TS) ----------------------------------------------
@@ -903,11 +969,15 @@ export class DMLSession {
903
969
  maxTokens: this.maxTokens,
904
970
  streaming: true,
905
971
  maxModelCalls: this.maxModelCalls,
972
+ askInput: (prompt, options) => this.requireInput(prompt, options),
906
973
  contextWindow: this.contextWindow,
907
974
  compaction: this.compactionSettings
908
975
  ? { settings: this.compactionSettings, auto: this.compactionAuto }
909
976
  : undefined,
910
977
  workspacePath: this.workspacePath,
978
+ environment: this.executionEnvironment,
979
+ currentModel: `${this.provider}:${this.model}`,
980
+ modelCatalog: this.modelResolver?.catalog(),
911
981
  knownMessages: this.agentMessages,
912
982
  });
913
983
  return this.harnessAgent;
@@ -916,11 +986,141 @@ export class DMLSession {
916
986
  async manifest() {
917
987
  return this.manifestText();
918
988
  }
989
+ /** The models available in this session (agent `models` tool). */
990
+ async listModels() {
991
+ const current = `${this.provider}:${this.model}`;
992
+ const resolver = this.modelResolver;
993
+ if (!resolver) {
994
+ return `current model: ${current}\n(no model catalog is configured; with_model is unavailable)`;
995
+ }
996
+ const models = resolver.catalog();
997
+ const body = models.length > 0
998
+ ? models.map((model) => ` ${formatModelCatalogEntry(model)}`).join('\n')
999
+ : ' (none)';
1000
+ return `current model: ${current}\n\navailable models (price = USD per 1M tokens, input/output):\n${body}`;
1001
+ }
1002
+ /**
1003
+ * Generate a diagram of one entry predicate: ask the active model for Mermaid,
1004
+ * then render it deterministically to a Unicode tree (always) and an SVG (for
1005
+ * the terminal-image path). One model call.
1006
+ */
1007
+ async diagram(entry, mode = 'presentation', options = {}) {
1008
+ if (!this.llmBackend) {
1009
+ throw new Error('diagram generation needs a model backend');
1010
+ }
1011
+ const listing = await this.listing('all');
1012
+ const resolved = (entry ?? '').trim() || this.defaultDiagramEntry(listing);
1013
+ if (!resolved) {
1014
+ throw new Error('the harness has no predicate to diagram yet');
1015
+ }
1016
+ const prompt = buildDiagramPrompt({ entry: resolved, mode, listing });
1017
+ const { text } = await generateLlmReply({
1018
+ messages: [{ role: 'user', content: prompt }],
1019
+ modelOptions: { provider: this.provider, model: this.model, temperature: this.temperature },
1020
+ llmBackend: this.llmBackend,
1021
+ signal: options.signal,
1022
+ });
1023
+ const mermaid = extractMermaid(text);
1024
+ const warnings = validateMermaid(mermaid);
1025
+ const svg = renderFlowchartSvg(parseMermaidFlowchart(mermaid));
1026
+ return {
1027
+ entry: resolved,
1028
+ mode,
1029
+ mermaid,
1030
+ ascii: renderMermaidAscii(mermaid),
1031
+ svg: svg.svg,
1032
+ width: svg.width,
1033
+ height: svg.height,
1034
+ warnings,
1035
+ };
1036
+ }
1037
+ /** Diagram of a skill for the authoring agent's `visualize` tool. */
1038
+ async visualize(entry, mode = 'presentation') {
1039
+ const result = await this.diagram(entry, mode);
1040
+ const png = await rasterizeSvg(result.svg, { width: result.width, height: result.height });
1041
+ if (png) {
1042
+ return {
1043
+ message: `Diagram of ${result.entry} (${result.mode}) is displayed to the user as an image. Do not repeat the diagram text.`,
1044
+ event: { type: 'media', media: { mimeType: 'image/svg+xml', data: png.toString('base64') } },
1045
+ };
1046
+ }
1047
+ return { message: result.ascii };
1048
+ }
1049
+ /** Display a workspace image (agent `show_image` tool). */
1050
+ async showImage(relPath) {
1051
+ return this.mediaEventFor(relPath);
1052
+ }
1053
+ /** Generate an image and display it (agent `generate_image` tool). */
1054
+ async generateImage(prompt) {
1055
+ if (!this.imageBackend) {
1056
+ return { message: 'Image generation is unavailable: no image backend is configured.' };
1057
+ }
1058
+ const result = await this.imageBackend.generate({ prompt });
1059
+ const shown = await this.mediaEventFor(result.path);
1060
+ return { message: `Generated ${result.path} (${result.mimeType}). ${shown.message}`, event: shown.event };
1061
+ }
1062
+ /** Write a workspace file (agent `write_file` tool); creates parent dirs. */
1063
+ async writeFile(relPath, content) {
1064
+ try {
1065
+ const abs = this.resolveWorkspacePath(relPath);
1066
+ await fs.mkdir(path.dirname(abs), { recursive: true });
1067
+ await fs.writeFile(abs, content, 'utf8');
1068
+ return { ok: true };
1069
+ }
1070
+ catch (error) {
1071
+ return { ok: false, error: error.message };
1072
+ }
1073
+ }
1074
+ /**
1075
+ * Build a `media` event for a workspace image (resolved to a PNG for inline
1076
+ * display). Returning an event lets any host render it through its normal
1077
+ * event pipeline — no session-specific image channel needed.
1078
+ */
1079
+ async mediaEventFor(relPath) {
1080
+ const resolved = await resolveMedia(this.workspacePath ?? process.cwd(), { path: relPath });
1081
+ if (!resolved) {
1082
+ return { message: `Cannot read image ${relPath}.` };
1083
+ }
1084
+ const event = {
1085
+ type: 'media',
1086
+ media: { path: relPath, mimeType: resolved.mimeType, data: resolved.pngBase64 },
1087
+ };
1088
+ const message = resolved.pngBase64
1089
+ ? `Image ${relPath} (${resolved.mimeType}) is displayed to the user.`
1090
+ : `Image ${relPath} (${resolved.mimeType}) is at workspace path ${relPath} `
1091
+ + '(not rasterized for inline display: SVG needs @resvg/resvg-js, rasters need sharp).';
1092
+ return { message, event };
1093
+ }
1094
+ /** Pick a default diagram entry: `agent_main/N`, else the first predicate. */
1095
+ defaultDiagramEntry(listing) {
1096
+ const mains = this.predicateArities('agent_main');
1097
+ if (mains.length > 0) {
1098
+ return `agent_main/${mains[0]}`;
1099
+ }
1100
+ const reserved = new Set(['doc', 'module_doc', 'tool', 'system', 'user', 'param', 'parameters', 'answer']);
1101
+ for (const line of listing.split('\n')) {
1102
+ const match = /^([a-z][A-Za-z0-9_]*)\/(\d+)\s*$/.exec(line.trim());
1103
+ if (match && !reserved.has(match[1])) {
1104
+ return `${match[1]}/${match[2]}`;
1105
+ }
1106
+ }
1107
+ return undefined;
1108
+ }
919
1109
  async beginTurn() {
1110
+ // A second begin_turn would re-snapshot the *mid-transaction* state, so
1111
+ // `rollback` would stop meaning "the last committed harness" and the
1112
+ // recorded diff would lose the edits made before it.
1113
+ if (this.transactionBefore !== null) {
1114
+ return {
1115
+ ok: false,
1116
+ error: 'a transaction is already open; call end_turn to commit it, or rollback to discard it',
1117
+ };
1118
+ }
920
1119
  this.prologQuery(`deepclause_mi:repl_snapshot_save('${this.sessionId}')`);
921
1120
  this.prologQuery(`deepclause_mi:repl_edit_touched_clear('${this.sessionId}')`);
922
1121
  this.transactionBefore = this.predicateList();
923
1122
  this.transactionDirty = false;
1123
+ return { ok: true };
924
1124
  }
925
1125
  async endTurn() {
926
1126
  if (this.transactionBefore === null) {
@@ -929,18 +1129,104 @@ export class DMLSession {
929
1129
  const before = this.transactionBefore;
930
1130
  const after = this.predicateList();
931
1131
  const changed = this.simplePredicateDiff(before, after);
1132
+ const touched = this.editTouched();
932
1133
  this.transactionBefore = null;
933
1134
  const committed = this.transactionDirty;
934
1135
  let version;
935
1136
  if (committed && this.history) {
936
- version = await this.recordHistoryChange('commit', this.turnCounter, before, { touched: this.editTouched() });
1137
+ version = await this.recordHistoryChange('commit', this.turnCounter, before, { touched });
937
1138
  }
938
1139
  this.lastTurnCommitted = committed;
939
1140
  this.lastCommitVersion = version;
940
1141
  this.transactionDirty = false;
941
1142
  this.prologQuery(`deepclause_mi:repl_edit_touched_clear('${this.sessionId}')`);
942
1143
  await this.persistSessionHarness(this.history?.currentVersion ?? 0);
943
- return { committed: true, changed };
1144
+ // Advisory: probe changed pure predicates for accidental nondeterminism.
1145
+ let warnings = [];
1146
+ if (committed) {
1147
+ const candidates = new Set();
1148
+ for (const entry of touched)
1149
+ candidates.add(entry.trim());
1150
+ for (const entry of changed)
1151
+ if (entry.startsWith('+'))
1152
+ candidates.add(entry.slice(1));
1153
+ warnings = await this.probeNondeterminism([...candidates]);
1154
+ warnings.push(...this.probeToolContracts());
1155
+ warnings.push(...this.probeDocContracts());
1156
+ }
1157
+ return { committed: true, changed, warnings };
1158
+ }
1159
+ /**
1160
+ * Check every registered `tool/2` annotation: the nested agent inside `task/N`
1161
+ * calls the tool body, so it must reach real logic with the same name and
1162
+ * arity. Violations only surface when a nested agent calls the tool, which may
1163
+ * be long after the commit — report them here instead.
1164
+ */
1165
+ probeToolContracts() {
1166
+ try {
1167
+ const result = this.prologQuery(`deepclause_mi:repl_validate_tools('${this.sessionId}', Warnings)`);
1168
+ const raw = plainValue(result?.Warnings);
1169
+ if (!Array.isArray(raw))
1170
+ return [];
1171
+ return raw.map((entry) => String(entry)).filter(Boolean);
1172
+ }
1173
+ catch {
1174
+ // A validation failure must never fail the commit.
1175
+ return [];
1176
+ }
1177
+ }
1178
+ /**
1179
+ * Warn about `doc/2` facts that document a predicate with no clauses. Such a
1180
+ * predicate fails silently when called, and its name still appears in the
1181
+ * manifest, so the harness looks fine and returns empty results.
1182
+ */
1183
+ probeDocContracts() {
1184
+ try {
1185
+ const result = this.prologQuery(`deepclause_mi:repl_validate_docs('${this.sessionId}', Warnings)`);
1186
+ const raw = plainValue(result?.Warnings);
1187
+ if (!Array.isArray(raw))
1188
+ return [];
1189
+ return raw.map((entry) => String(entry)).filter(Boolean);
1190
+ }
1191
+ catch {
1192
+ // A validation failure must never fail the commit.
1193
+ return [];
1194
+ }
1195
+ }
1196
+ /**
1197
+ * Probe changed predicates for accidental nondeterminism: a pure predicate
1198
+ * that yields more than `threshold` solutions on fresh variables is very likely
1199
+ * missing an `once/1`/`!` and would flood an `execute`. Fact tables and
1200
+ * side-effecting predicates are skipped by the Prolog probe.
1201
+ */
1202
+ async probeNondeterminism(indicators) {
1203
+ const reserved = new Set(['doc', 'module_doc', 'tool']);
1204
+ const warnings = [];
1205
+ const threshold = 100;
1206
+ const bound = 200000;
1207
+ for (const indicator of indicators.slice(0, 8)) {
1208
+ const match = /^([a-z][A-Za-z0-9_]*)\/(\d+)$/.exec(indicator);
1209
+ if (!match || reserved.has(match[1]))
1210
+ continue;
1211
+ const name = match[1];
1212
+ const arity = match[2];
1213
+ try {
1214
+ const result = this.prologQuery(`deepclause_mi:repl_probe_nondeterminism('${this.sessionId}', ${name}, ${arity}, ${threshold}, ${bound}, Result)`);
1215
+ const verdict = String(plainValue(result?.Result) ?? '');
1216
+ if (verdict === 'many') {
1217
+ warnings.push(`${name}/${arity} yields more than ${threshold} solutions when called with fresh variables. `
1218
+ + 'If a single answer is intended, make it deterministic with once/1 or !.');
1219
+ }
1220
+ else if (verdict === 'timeout') {
1221
+ warnings.push(`${name}/${arity} did not settle within the inference limit when probed `
1222
+ + '(possible unbounded search, e.g. label/1 without once/1).');
1223
+ }
1224
+ }
1225
+ catch {
1226
+ // A probe failure must never fail the commit.
1227
+ }
1228
+ }
1229
+ return warnings;
944
1230
  }
945
1231
  /** Predicates touched by edit tools in the current transaction. */
946
1232
  editTouched() {
@@ -983,6 +1269,13 @@ export class DMLSession {
983
1269
  this.transactionDirty = true;
984
1270
  return { ok: true };
985
1271
  }
1272
+ // `ok(Note)` carries a detail the agent should see, e.g. how many clauses a
1273
+ // retract actually removed. Reporting it is the point of counting them.
1274
+ const match = /^ok\(([\s\S]*)\)$/.exec(String(result).trim());
1275
+ if (match) {
1276
+ this.transactionDirty = true;
1277
+ return { ok: true, note: match[1] };
1278
+ }
986
1279
  return { ok: false, error: String(result) };
987
1280
  }
988
1281
  async define(head, clauses) {
@@ -1046,8 +1339,8 @@ export class DMLSession {
1046
1339
  return `unknown reference topic '${topic}'. Topics: language, authoring, examples, patterns, snippets, tools.`;
1047
1340
  }
1048
1341
  }
1049
- async execute(goal, limit, signal, onEvent) {
1050
- return this.executeGoal(goal, limit ?? 5, onEvent, signal);
1342
+ async execute(goal, limit, signal, onEvent, bindingMode = 'full') {
1343
+ return this.executeGoal(goal, limit ?? 5, onEvent, signal, bindingMode);
1051
1344
  }
1052
1345
  /**
1053
1346
  * Prompt mode: English request -> meta task -> DML -> commit -> entry run.
@@ -1136,13 +1429,13 @@ export class DMLSession {
1136
1429
  };
1137
1430
  }
1138
1431
  /** Loop compaction hook: run before each model call inside a frame. */
1139
- async compactLoopMessages(messages, lastInputTokens) {
1432
+ async compactLoopMessages(messages, lastInputTokens, contextWindow) {
1140
1433
  const settings = this.compactionSettings;
1141
1434
  if (!settings?.enabled || !this.llmBackend) {
1142
1435
  return { messages };
1143
1436
  }
1144
1437
  const contextTokens = lastInputTokens ?? estimateMemoryTokens(messages);
1145
- if (!shouldCompact(contextTokens, this.contextWindow ?? 0, settings)) {
1438
+ if (!shouldCompact(contextTokens, contextWindow ?? this.contextWindow ?? 0, settings)) {
1146
1439
  return { messages };
1147
1440
  }
1148
1441
  const result = await compactMemory({
@@ -1206,6 +1499,13 @@ export class DMLSession {
1206
1499
  setInputHandler(handler) {
1207
1500
  this.inputHandler = handler;
1208
1501
  }
1502
+ /**
1503
+ * @deprecated Terminal images now flow as `media` events (rendered by the
1504
+ * host), so this is a no-op kept for backwards compatibility.
1505
+ */
1506
+ setImageHandler(_handler) {
1507
+ // no-op
1508
+ }
1209
1509
  /** Resolve a human answer, or undefined when no channel is configured. */
1210
1510
  async requireInput(prompt, options) {
1211
1511
  if (!this.inputHandler) {
@@ -1237,12 +1537,14 @@ export class DMLSession {
1237
1537
  if (!this.inputHandler) {
1238
1538
  return false;
1239
1539
  }
1240
- const answer = await this.inputHandler(`Max model-call budget reached (${this.modelCallBudget}). Continue for another ${this.maxModelCalls} calls? (yes/no)`);
1540
+ const answer = await this.inputHandler(`Max model-call budget reached (${this.modelCallBudget}). Continue for another ${this.maxModelCalls} calls? (yes/no)\n`
1541
+ + 'change the limit: repl.maxModelCalls in .deepclause/config.json '
1542
+ + '("repl": { "maxModelCalls": N }), or pass --max-model-calls N; 0 means unlimited', ['yes', 'no']);
1241
1543
  return /^(y|yes)$/i.test((answer ?? '').trim());
1242
1544
  }
1243
1545
  prologQuery(goal) {
1244
1546
  try {
1245
- const result = this.swipl.prolog.query(goal).once();
1547
+ const result = this.swipl.prolog.query(qualifyWithSession(goal, this.sessionId)).once();
1246
1548
  return (result ?? null);
1247
1549
  }
1248
1550
  catch (error) {
@@ -1258,6 +1560,67 @@ export class DMLSession {
1258
1560
  .join(', ');
1259
1561
  }
1260
1562
  }
1563
+ /**
1564
+ * Qualify a goal with the session module unless it already names one.
1565
+ *
1566
+ * DML code resolves unqualified goals in the session module, which is where the
1567
+ * harness and the workspace predicates live. A host query would otherwise
1568
+ * resolve them in `user`, so `read_file("f.txt", C)` failed from here while
1569
+ * working from `execute` or `/goal`. Goals that already carry a qualifier
1570
+ * (`deepclause_mi:…`) are left alone.
1571
+ */
1572
+ export function qualifyWithSession(goal, sessionId) {
1573
+ const trimmed = goal.trim();
1574
+ if (trimmed.length === 0)
1575
+ return goal;
1576
+ if (/^[a-z][A-Za-z0-9_]*\s*:/.test(trimmed))
1577
+ return goal;
1578
+ return `${sessionId}:(${trimmed})`;
1579
+ }
1580
+ /**
1581
+ * Apply the `bindings` option to the solutions returned to the agent.
1582
+ *
1583
+ * `bindings` mirrors `solutions[0]`, so the mode applies to both — a half-done
1584
+ * job would leave the full value sitting in the other field.
1585
+ */
1586
+ function shapeBindings(solutions, mode) {
1587
+ const first = solutions[0] ?? [];
1588
+ if (mode === 'none')
1589
+ return { bindings: [], solutions: [] };
1590
+ if (mode === 'brief') {
1591
+ const shorten = (entries) => entries.map(({ name, value }) => ({
1592
+ name,
1593
+ value: value.length > BRIEF_VALUE_CHARS
1594
+ ? `${value.slice(0, BRIEF_VALUE_CHARS)}… (${value.length} chars)`
1595
+ : value,
1596
+ }));
1597
+ return { bindings: shorten(first), solutions: solutions.map(shorten) };
1598
+ }
1599
+ return { bindings: first, solutions };
1600
+ }
1601
+ /** Render a Prolog value for a warning message. */
1602
+ function formatTerm(value) {
1603
+ if (typeof value === 'string')
1604
+ return value;
1605
+ if (value === null || value === undefined)
1606
+ return String(value);
1607
+ if (typeof value === 'object') {
1608
+ const record = value;
1609
+ const keys = Object.keys(record).filter((k) => !k.startsWith('$'));
1610
+ if (keys.length === 1) {
1611
+ const inner = record[keys[0]];
1612
+ const args = Array.isArray(inner) && inner.length === 1 && Array.isArray(inner[0]) ? inner[0] : [];
1613
+ return `${keys[0]}(${args.map((a) => formatTerm(a)).join(', ')})`;
1614
+ }
1615
+ try {
1616
+ return JSON.stringify(value);
1617
+ }
1618
+ catch {
1619
+ return String(value);
1620
+ }
1621
+ }
1622
+ return String(value);
1623
+ }
1261
1624
  /** Quote a JS string as a Prolog double-quoted string. */
1262
1625
  export function quoteString(value) {
1263
1626
  return `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;