@causyne/agent 1.20.124 → 1.20.127

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 (235) hide show
  1. package/bin/causyne.js +1 -1
  2. package/package.json +4 -4
  3. package/src/acp/protocol.ts +19 -1
  4. package/src/acp/server.js +282 -8
  5. package/src/acp/server.ts +284 -8
  6. package/src/agent/abortableDelay.js +2 -2
  7. package/src/agent/abortableDelay.ts +2 -2
  8. package/src/agent/errorClassifier.js +9 -1
  9. package/src/agent/errorClassifier.ts +8 -1
  10. package/src/agentLoop.js +83 -27
  11. package/src/agentLoop.ts +92 -26
  12. package/src/approvalPolicy.js +34 -10
  13. package/src/approvalPolicy.ts +42 -11
  14. package/src/browser/causyneBrowser.js +30 -3
  15. package/src/browser/causyneBrowser.ts +33 -3
  16. package/src/browser/urlPolicy.js +14 -1
  17. package/src/browser/urlPolicy.ts +12 -1
  18. package/src/cliMode.js +21 -9
  19. package/src/cliMode.ts +20 -8
  20. package/src/commands.js +188 -32
  21. package/src/commands.ts +209 -32
  22. package/src/config.js +19 -4
  23. package/src/config.ts +18 -4
  24. package/src/core/contextCompactor.js +54 -7
  25. package/src/core/contextCompactor.ts +63 -7
  26. package/src/core/goalLoop.js +257 -0
  27. package/src/core/goalLoop.ts +310 -0
  28. package/src/entrypoint.js +135 -3
  29. package/src/entrypoint.ts +136 -3
  30. package/src/game/causyneCoreBridge.js +686 -0
  31. package/src/game/causyneCoreBridge.ts +702 -0
  32. package/src/game/gameLauncher.js +287 -0
  33. package/src/game/gameLauncher.ts +352 -0
  34. package/src/game/gameProvisioner.js +425 -0
  35. package/src/game/gameProvisioner.ts +488 -0
  36. package/src/headlessCli.js +19 -12
  37. package/src/headlessCli.ts +22 -8
  38. package/src/infra/atomicWriter.js +40 -4
  39. package/src/infra/atomicWriter.ts +36 -4
  40. package/src/launchIntent.js +73 -3
  41. package/src/launchIntent.ts +76 -3
  42. package/src/lsp/lspClient.js +83 -12
  43. package/src/lsp/lspClient.ts +75 -12
  44. package/src/mcp/mcpRegistry.js +75 -8
  45. package/src/mcp/mcpRegistry.ts +70 -7
  46. package/src/memory/contextBudget.js +2 -0
  47. package/src/memory/contextBudget.ts +1 -0
  48. package/src/modelVariants.js +45 -0
  49. package/src/modelVariants.ts +54 -0
  50. package/src/outputRecovery.js +3 -2
  51. package/src/outputRecovery.ts +4 -2
  52. package/src/permissionPresets.js +327 -0
  53. package/src/permissionPresets.ts +361 -0
  54. package/src/providers/antigravity.js +62 -9
  55. package/src/providers/antigravity.ts +73 -9
  56. package/src/providers/byokHttp.js +7 -1
  57. package/src/providers/byokHttp.ts +6 -1
  58. package/src/providers/byokStream.js +21 -8
  59. package/src/providers/byokStream.ts +17 -7
  60. package/src/providers/dashscope-byok.js +21 -5
  61. package/src/providers/dashscope-byok.ts +29 -11
  62. package/src/providers/moonshot.js +26 -7
  63. package/src/providers/moonshot.ts +34 -13
  64. package/src/providers/muse.js +6 -0
  65. package/src/providers/muse.ts +8 -0
  66. package/src/providers/ollama.js +39 -7
  67. package/src/providers/ollama.ts +36 -7
  68. package/src/providers/openai-compatible.js +16 -3
  69. package/src/providers/openai-compatible.ts +13 -3
  70. package/src/providers/openai.js +62 -4
  71. package/src/providers/openai.ts +50 -4
  72. package/src/providers/openrouter.js +19 -4
  73. package/src/providers/openrouter.ts +21 -4
  74. package/src/providers/qwen-byok.js +21 -5
  75. package/src/providers/qwen-byok.ts +29 -11
  76. package/src/providers/xai.js +26 -10
  77. package/src/providers/xai.ts +34 -16
  78. package/src/reporting.js +4 -2
  79. package/src/reporting.ts +4 -2
  80. package/src/sandbox.js +34 -0
  81. package/src/sandbox.ts +43 -0
  82. package/src/scheduler/scheduler.js +372 -0
  83. package/src/scheduler/scheduler.ts +433 -0
  84. package/src/sessionSearchIndex.js +267 -0
  85. package/src/sessionSearchIndex.ts +311 -0
  86. package/src/skillsManager.js +2 -3
  87. package/src/skillsManager.ts +2 -3
  88. package/src/toolPacks.js +6 -0
  89. package/src/toolPacks.ts +6 -0
  90. package/src/tools/applyPatch.js +1 -1
  91. package/src/tools/applyPatch.ts +1 -1
  92. package/src/tools/generateMediaViaApi.js +4 -3
  93. package/src/tools/generateMediaViaApi.ts +4 -3
  94. package/src/tools/nativeEngine.js +2 -2
  95. package/src/tools/nativeEngine.ts +2 -2
  96. package/src/tools/openSourceToolProvisioner.js +2 -2
  97. package/src/tools/openSourceToolProvisioner.ts +2 -2
  98. package/src/tools/payloadSanitizer.js +0 -1
  99. package/src/tools/payloadSanitizer.ts +0 -1
  100. package/src/tools/pdfReader.js +122 -20
  101. package/src/tools/pdfReader.ts +111 -20
  102. package/src/tools/presentDeliverable.js +103 -0
  103. package/src/tools/presentDeliverable.ts +127 -0
  104. package/src/tools/ptcRuntime.js +444 -0
  105. package/src/tools/ptcRuntime.ts +490 -0
  106. package/src/tools/ptyTerminal.js +1096 -0
  107. package/src/tools/ptyTerminal.ts +1231 -0
  108. package/src/tools/registry.js +21 -12
  109. package/src/tools/registry.ts +21 -12
  110. package/src/tools/toolOutputStore.js +26 -4
  111. package/src/tools/toolOutputStore.ts +22 -4
  112. package/src/tools/webFetch.js +158 -11
  113. package/src/tools/webFetch.ts +145 -11
  114. package/src/tools/webSearch.js +123 -36
  115. package/src/tools/webSearch.ts +124 -33
  116. package/src/tui/banner.js +5 -1
  117. package/src/tui/banner.ts +6 -1
  118. package/src/tui/chatRenderer.js +1 -2
  119. package/src/tui/chatRenderer.ts +1 -2
  120. package/src/tui/completion.js +1 -0
  121. package/src/tui/completion.ts +1 -0
  122. package/src/tui/composerControls.js +111 -27
  123. package/src/tui/composerControls.ts +124 -28
  124. package/src/tui/dialogs.js +3 -16
  125. package/src/tui/dialogs.ts +3 -16
  126. package/src/tui/home.js +1 -0
  127. package/src/tui/home.ts +1 -0
  128. package/src/tui/invocation.js +1 -2
  129. package/src/tui/invocation.ts +1 -2
  130. package/src/tui/modelPicker.js +22 -12
  131. package/src/tui/modelPicker.ts +22 -12
  132. package/src/tui/overlay.js +2 -5
  133. package/src/tui/overlay.ts +2 -5
  134. package/src/tui/prompt.js +6 -4
  135. package/src/tui/prompt.ts +6 -4
  136. package/src/tui/selectList.js +4 -12
  137. package/src/tui/selectList.ts +4 -12
  138. package/src/tui/setup.js +22 -9
  139. package/src/tui/setup.ts +26 -9
  140. package/src/tui/statusLine.ts +2 -0
  141. package/src/web/client/browserPanel.js +702 -0
  142. package/src/web/client/browserPanel.ts +663 -0
  143. package/src/web/client/chatStream.js +309 -0
  144. package/src/web/client/chatStream.ts +289 -0
  145. package/src/web/client/cliPanel.js +165 -0
  146. package/src/web/client/cliPanel.ts +171 -0
  147. package/src/web/client/composer.js +204 -0
  148. package/src/web/client/composer.ts +209 -0
  149. package/src/web/client/diffPanel.js +176 -0
  150. package/src/web/client/diffPanel.ts +203 -0
  151. package/src/web/client/dom.js +220 -0
  152. package/src/web/client/dom.ts +221 -0
  153. package/src/web/client/filesAndCanvas.js +231 -0
  154. package/src/web/client/filesAndCanvas.ts +238 -0
  155. package/src/web/client/gameLauncherUi.js +78 -0
  156. package/src/web/client/gameLauncherUi.ts +78 -0
  157. package/src/web/client/main.js +301 -0
  158. package/src/web/client/main.ts +368 -0
  159. package/src/web/client/markdown.js +364 -0
  160. package/src/web/client/markdown.ts +373 -0
  161. package/src/web/client/modelPicker.js +455 -0
  162. package/src/web/client/modelPicker.ts +451 -0
  163. package/src/web/client/permissionPresetsUi.js +307 -0
  164. package/src/web/client/permissionPresetsUi.ts +333 -0
  165. package/src/web/client/sessions.js +353 -0
  166. package/src/web/client/sessions.ts +372 -0
  167. package/src/web/client/settingsModal.js +191 -0
  168. package/src/web/client/settingsModal.ts +176 -0
  169. package/src/web/client/state.js +250 -0
  170. package/src/web/client/state.ts +233 -0
  171. package/src/web/client/streamSmoother.js +127 -0
  172. package/src/web/client/streamSmoother.ts +119 -0
  173. package/src/web/client/studioLayout.js +54 -0
  174. package/src/web/client/studioLayout.ts +60 -0
  175. package/src/web/client/studioShell.js +327 -0
  176. package/src/web/client/studioShell.ts +340 -0
  177. package/src/web/client/studioStart.js +77 -0
  178. package/src/web/client/studioStart.ts +89 -0
  179. package/src/web/client/terminalPanel.js +357 -0
  180. package/src/web/client/terminalPanel.ts +345 -0
  181. package/src/web/client/turnView.js +934 -0
  182. package/src/web/client/turnView.ts +981 -0
  183. package/src/web/client/types.js +1 -0
  184. package/src/web/client/types.ts +319 -0
  185. package/src/web/client/validators.js +106 -0
  186. package/src/web/client/validators.ts +96 -0
  187. package/src/web/server/activeRuns.js +152 -0
  188. package/src/web/server/activeRuns.ts +171 -0
  189. package/src/web/server/routesBrowser.js +355 -0
  190. package/src/web/server/routesBrowser.ts +386 -0
  191. package/src/web/server/routesChat.js +304 -0
  192. package/src/web/server/routesChat.ts +347 -0
  193. package/src/web/server/routesCore.js +472 -0
  194. package/src/web/server/routesCore.ts +522 -0
  195. package/src/web/server/routesTerminal.js +162 -0
  196. package/src/web/server/routesTerminal.ts +182 -0
  197. package/src/web/server/routesWorkspace.js +510 -0
  198. package/src/web/server/routesWorkspace.ts +546 -0
  199. package/src/web/server/security.js +98 -0
  200. package/src/web/server/security.ts +108 -0
  201. package/src/web/server/sessionTranscript.js +586 -0
  202. package/src/web/server/sessionTranscript.ts +566 -0
  203. package/src/web/server/staticAssets.js +80 -0
  204. package/src/web/server/staticAssets.ts +91 -0
  205. package/src/web/server/types.js +1 -0
  206. package/src/web/server/types.ts +135 -0
  207. package/src/web/server/workspaceFiles.js +368 -0
  208. package/src/web/server/workspaceFiles.ts +363 -0
  209. package/src/web/skybridgeServer.js +76 -2449
  210. package/src/web/skybridgeServer.ts +118 -2600
  211. package/src/web/skybridgeUi.js +16 -450
  212. package/src/web/skybridgeUi.ts +16 -454
  213. package/src/web/styles/agent.css +380 -0
  214. package/src/web/styles/composer.css +193 -0
  215. package/src/web/styles/overlays.css +436 -0
  216. package/src/web/styles/shell.css +387 -0
  217. package/src/web/styles/studio.css +723 -0
  218. package/src/web/styles/thread.css +221 -0
  219. package/src/web/styles/tokens.css +94 -0
  220. package/src/web/ui/brandMark.js +73 -0
  221. package/src/web/ui/brandMark.ts +82 -0
  222. package/src/web/ui/modalsTemplate.js +139 -0
  223. package/src/web/ui/modalsTemplate.ts +139 -0
  224. package/src/web/ui/sidebarTemplate.js +63 -0
  225. package/src/web/ui/sidebarTemplate.ts +64 -0
  226. package/src/web/ui/studioTemplate.js +258 -0
  227. package/src/web/ui/studioTemplate.ts +258 -0
  228. package/src/web/ui/workspaceTemplate.js +72 -0
  229. package/src/web/ui/workspaceTemplate.ts +73 -0
  230. package/src/worktreeManager.js +16 -1
  231. package/src/worktreeManager.ts +22 -1
  232. package/src/web/skybridgeClientScript.js +0 -3951
  233. package/src/web/skybridgeClientScript.ts +0 -3952
  234. package/src/web/skybridgeStyles.js +0 -827
  235. package/src/web/skybridgeStyles.ts +0 -828
@@ -0,0 +1,311 @@
1
+ /**
2
+ * Causyne Agent — Disposable SQLite FTS5 Session Search Index & Tool
3
+ *
4
+ * Indexes workspace-scoped JSONL session transcripts under `~/.causyne/sessions/`
5
+ * using Node's built-in `node:sqlite` FTS5 (zero external npm dependencies) with
6
+ * automatic fallback to linear streaming scan if SQLite FTS5 is unavailable.
7
+ */
8
+
9
+ import fs from 'node:fs';
10
+ import path from 'node:path';
11
+ import { listSessions, getSession } from './sessionJournal.js';
12
+ import { physicalPath } from './agent/workspaceBoundary.js';
13
+ import { causyneHome } from './utils/paths.js';
14
+ import {
15
+ boundedInteger,
16
+ resolveToolWorkspaceRoots,
17
+ sanitizeToolError,
18
+ type ToolWorkspaceContext
19
+ } from './tools/toolPathSafety.js';
20
+
21
+ export interface SessionSearchHit {
22
+ sessionId: string;
23
+ title: string;
24
+ updatedAt: number;
25
+ messageIndex: number;
26
+ role: string;
27
+ snippet: string;
28
+ score: number;
29
+ }
30
+
31
+ const INDEX_SCHEMA_VERSION = 1;
32
+ const MAX_SNIPPET_CHARS = 240;
33
+
34
+ function extractMessagePlainText(msg: unknown): string {
35
+ if (!msg || typeof msg !== 'object') return '';
36
+ const rec = msg as { content?: unknown };
37
+ if (typeof rec.content === 'string') return rec.content;
38
+ if (Array.isArray(rec.content)) {
39
+ const parts: string[] = [];
40
+ for (const block of rec.content) {
41
+ if (typeof block === 'string') parts.push(block);
42
+ else if (block && typeof block === 'object' && typeof (block as { text?: unknown }).text === 'string') {
43
+ parts.push((block as { text: string }).text);
44
+ }
45
+ }
46
+ return parts.join('\n');
47
+ }
48
+ return '';
49
+ }
50
+
51
+ function buildMatchSnippet(text: string, query: string): string {
52
+ const cleaned = text.replace(/\s+/g, ' ').trim();
53
+ if (cleaned.length <= MAX_SNIPPET_CHARS) return cleaned;
54
+ const lower = cleaned.toLowerCase();
55
+ const terms = query.toLowerCase().split(/\s+/).filter(Boolean);
56
+ let pos = -1;
57
+ for (const term of terms) {
58
+ const found = lower.indexOf(term);
59
+ if (found !== -1 && (pos === -1 || found < pos)) pos = found;
60
+ }
61
+ if (pos === -1) return `${cleaned.slice(0, MAX_SNIPPET_CHARS)}...`;
62
+ const start = Math.max(0, pos - 70);
63
+ const end = Math.min(cleaned.length, start + MAX_SNIPPET_CHARS);
64
+ return `${start > 0 ? '...' : ''}${cleaned.slice(start, end)}${end < cleaned.length ? '...' : ''}`;
65
+ }
66
+
67
+ function quoteFtsQuery(rawQuery: string): string {
68
+ const tokens = rawQuery
69
+ .trim()
70
+ .split(/\s+/)
71
+ .map((t) => t.replace(/"/g, '').trim())
72
+ .filter((t) => t.length > 0)
73
+ .slice(0, 12);
74
+ if (tokens.length === 0) return '';
75
+ return tokens.map((t) => `"${t}"`).join(' AND ');
76
+ }
77
+
78
+ function sameWorkspace(sessionWorkspace: string, workspaceRoot: string): boolean {
79
+ if (!sessionWorkspace) return false;
80
+ const a = physicalPath(sessionWorkspace) || path.resolve(sessionWorkspace);
81
+ const b = physicalPath(workspaceRoot) || path.resolve(workspaceRoot);
82
+ return a === b;
83
+ }
84
+
85
+ async function searchWithSqliteFts5(
86
+ workspaceRoot: string,
87
+ query: string,
88
+ options: { limit: number; excludeSessionId?: string | undefined }
89
+ ): Promise<SessionSearchHit[] | null> {
90
+ let DatabaseSyncCtor: any;
91
+ try {
92
+ const mod = await import('node:sqlite');
93
+ DatabaseSyncCtor = (mod as { DatabaseSync?: unknown }).DatabaseSync;
94
+ } catch {
95
+ return null;
96
+ }
97
+ if (typeof DatabaseSyncCtor !== 'function') return null;
98
+
99
+ const ftsQuery = quoteFtsQuery(query);
100
+ if (!ftsQuery) return [];
101
+
102
+ const indexDir = path.join(causyneHome(), 'cache');
103
+ const dbPath = path.join(indexDir, 'session-search-fts5.sqlite');
104
+ fs.mkdirSync(indexDir, { recursive: true, mode: 0o700 });
105
+
106
+ const db = new DatabaseSyncCtor(dbPath);
107
+ try {
108
+ const verRow = db.prepare('PRAGMA user_version').get() as { user_version?: number } | undefined;
109
+ if (!verRow || verRow.user_version !== INDEX_SCHEMA_VERSION) {
110
+ db.exec('DROP TABLE IF EXISTS session_meta; DROP TABLE IF EXISTS session_docs;');
111
+ db.exec(`
112
+ CREATE TABLE session_meta (
113
+ session_id TEXT PRIMARY KEY,
114
+ workspace TEXT NOT NULL,
115
+ title TEXT NOT NULL,
116
+ updated_at INTEGER NOT NULL,
117
+ message_count INTEGER NOT NULL
118
+ );
119
+ CREATE VIRTUAL TABLE session_docs USING fts5(
120
+ session_id UNINDEXED,
121
+ workspace UNINDEXED,
122
+ title,
123
+ role UNINDEXED,
124
+ message_index UNINDEXED,
125
+ body,
126
+ tokenize='unicode61'
127
+ );
128
+ PRAGMA user_version = ${INDEX_SCHEMA_VERSION};
129
+ `);
130
+ }
131
+
132
+ const sessions = listSessions().filter((s) => sameWorkspace(s.workspace, workspaceRoot));
133
+ const selectMeta = db.prepare('SELECT updated_at, message_count FROM session_meta WHERE session_id = ?');
134
+ const deleteDocs = db.prepare('DELETE FROM session_docs WHERE session_id = ?');
135
+ const upsertMeta = db.prepare(
136
+ 'INSERT OR REPLACE INTO session_meta (session_id, workspace, title, updated_at, message_count) VALUES (?, ?, ?, ?, ?)'
137
+ );
138
+ const insertDoc = db.prepare(
139
+ 'INSERT INTO session_docs (session_id, workspace, title, role, message_index, body) VALUES (?, ?, ?, ?, ?, ?)'
140
+ );
141
+
142
+ const normalizedWorkspace = physicalPath(workspaceRoot) || path.resolve(workspaceRoot);
143
+ for (const summary of sessions.slice(0, 120)) {
144
+ const existing = selectMeta.get(summary.id) as { updated_at?: number; message_count?: number } | undefined;
145
+ if (existing && existing.updated_at === summary.updatedAt && existing.message_count === summary.messageCount) {
146
+ continue;
147
+ }
148
+ const full = getSession(summary.id);
149
+ if (!full) continue;
150
+ deleteDocs.run(summary.id);
151
+ upsertMeta.run(summary.id, normalizedWorkspace, summary.title || '', summary.updatedAt || 0, full.messages.length);
152
+ for (let i = 0; i < full.messages.length; i++) {
153
+ const msg = full.messages[i];
154
+ const body = extractMessagePlainText(msg).slice(0, 16_000);
155
+ if (!body.trim()) continue;
156
+ insertDoc.run(
157
+ summary.id,
158
+ normalizedWorkspace,
159
+ summary.title || '',
160
+ String(msg?.role || 'unknown'),
161
+ i,
162
+ body
163
+ );
164
+ }
165
+ }
166
+
167
+ const rows = db.prepare(`
168
+ SELECT d.session_id, d.title, d.role, d.message_index, d.body, m.updated_at, bm25(session_docs) AS rank
169
+ FROM session_docs d
170
+ JOIN session_meta m ON m.session_id = d.session_id
171
+ WHERE d.workspace = ? AND session_docs MATCH ?
172
+ ORDER BY rank ASC, m.updated_at DESC
173
+ LIMIT ?
174
+ `).all(normalizedWorkspace, ftsQuery, Math.max(options.limit * 4, 24)) as Array<{
175
+ session_id: string;
176
+ title: string;
177
+ role: string;
178
+ message_index: number;
179
+ body: string;
180
+ updated_at: number;
181
+ rank: number;
182
+ }>;
183
+
184
+ const bestPerSession = new Map<string, SessionSearchHit>();
185
+ for (const row of rows) {
186
+ if (options.excludeSessionId && row.session_id === options.excludeSessionId) continue;
187
+ if (bestPerSession.has(row.session_id)) continue;
188
+ bestPerSession.set(row.session_id, {
189
+ sessionId: row.session_id,
190
+ title: row.title || 'Untitled session',
191
+ updatedAt: Number(row.updated_at || 0),
192
+ messageIndex: Number(row.message_index || 0),
193
+ role: row.role || 'unknown',
194
+ snippet: buildMatchSnippet(row.body || '', query),
195
+ score: Number.isFinite(row.rank) ? -row.rank : 0
196
+ });
197
+ if (bestPerSession.size >= options.limit) break;
198
+ }
199
+
200
+ return [...bestPerSession.values()];
201
+ } finally {
202
+ try { db.close(); } catch { /* ignore */ }
203
+ }
204
+ }
205
+
206
+ function searchLinearFallback(
207
+ workspaceRoot: string,
208
+ query: string,
209
+ options: { limit: number; excludeSessionId?: string | undefined }
210
+ ): SessionSearchHit[] {
211
+ const terms = query.toLowerCase().split(/\s+/).filter(Boolean);
212
+ if (terms.length === 0) return [];
213
+ const sessions = listSessions().filter((s) => sameWorkspace(s.workspace, workspaceRoot));
214
+ const hits: SessionSearchHit[] = [];
215
+
216
+ for (const summary of sessions.slice(0, 120)) {
217
+ if (options.excludeSessionId && summary.id === options.excludeSessionId) continue;
218
+ const full = getSession(summary.id);
219
+ if (!full) continue;
220
+ for (let i = full.messages.length - 1; i >= 0; i--) {
221
+ const msg = full.messages[i];
222
+ const text = extractMessagePlainText(msg);
223
+ const lower = text.toLowerCase();
224
+ if (terms.every((t) => lower.includes(t))) {
225
+ hits.push({
226
+ sessionId: summary.id,
227
+ title: summary.title || 'Untitled session',
228
+ updatedAt: summary.updatedAt || 0,
229
+ messageIndex: i,
230
+ role: String(msg?.role || 'unknown'),
231
+ snippet: buildMatchSnippet(text, query),
232
+ score: 1
233
+ });
234
+ break;
235
+ }
236
+ }
237
+ if (hits.length >= options.limit) break;
238
+ }
239
+ return hits;
240
+ }
241
+
242
+ export async function searchWorkspaceSessions(
243
+ workspaceRoot: string,
244
+ query: string,
245
+ options: { limit?: number | undefined; excludeSessionId?: string | undefined } = {}
246
+ ): Promise<SessionSearchHit[]> {
247
+ const trimmed = String(query || '').trim();
248
+ if (!trimmed) return [];
249
+ const limit = boundedInteger(options.limit, 8, 1, 25);
250
+ try {
251
+ const fts = await searchWithSqliteFts5(workspaceRoot, trimmed, {
252
+ limit,
253
+ excludeSessionId: options.excludeSessionId
254
+ });
255
+ if (fts !== null) return fts;
256
+ } catch {
257
+ // Fall back gracefully if SQLite FTS5 is unavailable
258
+ }
259
+ return searchLinearFallback(workspaceRoot, trimmed, {
260
+ limit,
261
+ excludeSessionId: options.excludeSessionId
262
+ });
263
+ }
264
+
265
+ export const sessionSearchTool = {
266
+ schema: {
267
+ name: 'session_search',
268
+ description:
269
+ 'Full-text search across prior saved Causyne sessions in the current workspace (backed by disposable SQLite FTS5). Use to recall prior decisions, commands, file changes, or error resolutions.',
270
+ parameters: {
271
+ type: 'object',
272
+ properties: {
273
+ query: { type: 'string', description: 'Search keywords or phrase (1-300 characters).' },
274
+ limit: { type: 'integer', description: 'Maximum sessions to return (1-25, default 8).' }
275
+ },
276
+ required: ['query'],
277
+ additionalProperties: false
278
+ }
279
+ },
280
+
281
+ async execute(
282
+ args: { query?: string; limit?: number },
283
+ context: ToolWorkspaceContext & { parentLoop?: { sessionId?: string | undefined } | undefined } = {}
284
+ ) {
285
+ try {
286
+ const query = typeof args?.query === 'string' ? args.query.trim() : '';
287
+ if (!query || query.length > 300) {
288
+ return { success: false, error: 'query must contain 1-300 characters.' };
289
+ }
290
+ const scope = resolveToolWorkspaceRoots(context);
291
+ const workspaceRoot = scope.primaryRoot || process.cwd();
292
+ const hits = await searchWorkspaceSessions(workspaceRoot, query, {
293
+ limit: args.limit,
294
+ excludeSessionId: context.parentLoop?.sessionId
295
+ });
296
+ if (hits.length === 0) {
297
+ return { success: true, hits: [], output: `No matching prior sessions found for "${query}".` };
298
+ }
299
+ const lines = hits.map(
300
+ (h, idx) => `${idx + 1}. [${h.sessionId}] ${h.title} (msg #${h.messageIndex}, ${h.role})\n ${h.snippet}`
301
+ );
302
+ return {
303
+ success: true,
304
+ hits,
305
+ output: `Found ${hits.length} matching session(s):\n${lines.join('\n')}`
306
+ };
307
+ } catch (error) {
308
+ return { success: false, error: sanitizeToolError(error) };
309
+ }
310
+ }
311
+ };
@@ -155,9 +155,8 @@ export function ensureSkillRepo(domain) {
155
155
  * Progressive disclosure. 100 skills is roughly 250 KB of markdown; injecting it
156
156
  * would consume the context window before the task was read. What goes in is one
157
157
  * line per skill — the name and WHEN TO USE IT — and the model pulls the body
158
- * with fs_read_skill only for the one it needs. This is the same contract
159
- * claude-code and openclaw use, and it is what makes a large skill library
160
- * possible at all.
158
+ * with fs_read_skill only for the one it needs, allowing a large skill library
159
+ * to scale cleanly without inflating prompt context.
161
160
  *
162
161
  * Capped at MAX_INDEXED_SKILLS. A workspace matching eight domains would
163
162
  * otherwise inject fifty-odd descriptions; the detected domains come first so
@@ -181,9 +181,8 @@ export function ensureSkillRepo(domain: string): boolean {
181
181
  * Progressive disclosure. 100 skills is roughly 250 KB of markdown; injecting it
182
182
  * would consume the context window before the task was read. What goes in is one
183
183
  * line per skill — the name and WHEN TO USE IT — and the model pulls the body
184
- * with fs_read_skill only for the one it needs. This is the same contract
185
- * claude-code and openclaw use, and it is what makes a large skill library
186
- * possible at all.
184
+ * with fs_read_skill only for the one it needs, allowing a large skill library
185
+ * to scale cleanly without inflating prompt context.
187
186
  *
188
187
  * Capped at MAX_INDEXED_SKILLS. A workspace matching eight domains would
189
188
  * otherwise inject fifty-odd descriptions; the detected domains come first so
package/src/toolPacks.js CHANGED
@@ -85,6 +85,7 @@ export const PACKS = {
85
85
  'resolve_act',
86
86
  'palmier_act',
87
87
  'document_forge',
88
+ 'present',
88
89
  'open_source_tool_provisioner'
89
90
  ],
90
91
  system: [
@@ -98,6 +99,7 @@ export const PACKS = {
98
99
  'computer_use',
99
100
  'process_list',
100
101
  'proc_term',
102
+ 'terminal_pty',
101
103
  'archive',
102
104
  'clipboard',
103
105
  'desktop_open',
@@ -119,6 +121,10 @@ export const PACKS = {
119
121
  'apply_patch',
120
122
  'code_repo_map',
121
123
  'task_bg',
124
+ 'run_code',
125
+ 'session_search',
126
+ 'goal',
127
+ 'schedule',
122
128
  'pdf_read'
123
129
  ],
124
130
  reverse_engineering: [
package/src/toolPacks.ts CHANGED
@@ -112,6 +112,7 @@ export const PACKS: Record<PackName, string[]> = {
112
112
  'resolve_act',
113
113
  'palmier_act',
114
114
  'document_forge',
115
+ 'present',
115
116
  'open_source_tool_provisioner'
116
117
  ],
117
118
  system: [
@@ -125,6 +126,7 @@ export const PACKS: Record<PackName, string[]> = {
125
126
  'computer_use',
126
127
  'process_list',
127
128
  'proc_term',
129
+ 'terminal_pty',
128
130
  'archive',
129
131
  'clipboard',
130
132
  'desktop_open',
@@ -146,6 +148,10 @@ export const PACKS: Record<PackName, string[]> = {
146
148
  'apply_patch',
147
149
  'code_repo_map',
148
150
  'task_bg',
151
+ 'run_code',
152
+ 'session_search',
153
+ 'goal',
154
+ 'schedule',
149
155
  'pdf_read'
150
156
  ],
151
157
  reverse_engineering: [
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Causyne Agent — Transactional Multi-File Patch Engine (`apply_patch`)
3
3
  *
4
- * Applies Codex-style multi-file V4A patches (`*** Begin Patch` ... `*** End Patch`)
4
+ * Applies multi-file V4A patches (`*** Begin Patch` ... `*** End Patch`)
5
5
  * atomically across multiple files in a single tool call:
6
6
  * - `*** Add File: <path>`
7
7
  * - `*** Update File: <path>` (with optional `*** Move to: <newPath>`)
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Causyne Agent — Transactional Multi-File Patch Engine (`apply_patch`)
3
3
  *
4
- * Applies Codex-style multi-file V4A patches (`*** Begin Patch` ... `*** End Patch`)
4
+ * Applies multi-file V4A patches (`*** Begin Patch` ... `*** End Patch`)
5
5
  * atomically across multiple files in a single tool call:
6
6
  * - `*** Add File: <path>`
7
7
  * - `*** Update File: <path>` (with optional `*** Move to: <newPath>`)
@@ -2,6 +2,7 @@ import { causyneHome, resolveUserPath } from '../utils/paths.js';
2
2
  import { assertPublicWebUrl } from '../browser/urlPolicy.js';
3
3
  import { validateToolArguments } from './argumentValidation.js';
4
4
  import { assertSafeWorkspaceOutput } from './toolPathSafety.js';
5
+ import { resolveConfigPermissionPreset } from '../permissionPresets.js';
5
6
  const MAX_MEDIA_DOWNLOAD_BYTES = 50 * 1024 * 1024;
6
7
  async function readBoundedMediaResponse(response, maxBytes = MAX_MEDIA_DOWNLOAD_BYTES) {
7
8
  const declaredLen = Number(response.headers.get('content-length') ?? '0');
@@ -138,9 +139,9 @@ async function routeMultimediaRequest(args, config, sandbox, tokenTracker) {
138
139
  // Pre-Flight Consent Modal (`approval_request`) for Paid API Handoffs (unless in Mode C/Super Max and pre-approved)
139
140
  const approvalHost = resolveApprovalHost(sandbox);
140
141
  if (approvalHost && typeof approvalHost.waitForApproval === 'function') {
141
- // The paid-media consent modal is skipped in Mode C (pre-approved) and in
142
+ // The paid-media consent modal is skipped in Full access and in
142
143
  // hardened developer emulator mode (secret-gated — see devMode.js).
143
- if (!isDevEmulator(config) && config.autonomyMode !== 'C') {
144
+ if (!isDevEmulator(config) && resolveConfigPermissionPreset(config, 'danger-full-access') !== 'danger-full-access') {
144
145
  const approvalId = `media_${crypto.randomUUID()}`;
145
146
  if (typeof approvalHost.emitEvent === 'function') {
146
147
  approvalHost.emitEvent({
@@ -367,7 +368,7 @@ export const generateMediaViaApi = {
367
368
  if (mediaType === 'video_animation')
368
369
  return { success: false, code: 'MEDIA_PROVIDER_UNAVAILABLE', error: 'No supported video endpoint is configured. No media artifact was produced.' };
369
370
  const approvalHost = resolveApprovalHost(sandbox);
370
- if (approvalHost?.waitForApproval && !isDevEmulator(config) && config.autonomyMode !== 'C') {
371
+ if (approvalHost?.waitForApproval && !isDevEmulator(config) && resolveConfigPermissionPreset(config, 'danger-full-access') !== 'danger-full-access') {
371
372
  const approvalId = `media_${crypto.randomUUID()}`;
372
373
  approvalHost.emitEvent?.({ type: 'approval_request', toolCallId: approvalId, tool: 'generate_media_via_api', args: { mediaType, targetProvider: 'pollinations' }, risk: 'monetary_cost' });
373
374
  if (!await approvalHost.waitForApproval(approvalId))
@@ -2,6 +2,7 @@ import { causyneHome, resolveUserPath } from '../utils/paths.js';
2
2
  import { assertPublicWebUrl } from '../browser/urlPolicy.js';
3
3
  import { validateToolArguments } from './argumentValidation.js';
4
4
  import { assertSafeWorkspaceOutput } from './toolPathSafety.js';
5
+ import { resolveConfigPermissionPreset } from '../permissionPresets.js';
5
6
  import type { ParameterSchema } from './toolSelfRepair.js';
6
7
 
7
8
  const MAX_MEDIA_DOWNLOAD_BYTES = 50 * 1024 * 1024;
@@ -137,9 +138,9 @@ async function routeMultimediaRequest(args: MediaArgs, config: Record<string, an
137
138
  // Pre-Flight Consent Modal (`approval_request`) for Paid API Handoffs (unless in Mode C/Super Max and pre-approved)
138
139
  const approvalHost = resolveApprovalHost(sandbox);
139
140
  if (approvalHost && typeof approvalHost.waitForApproval === 'function') {
140
- // The paid-media consent modal is skipped in Mode C (pre-approved) and in
141
+ // The paid-media consent modal is skipped in Full access and in
141
142
  // hardened developer emulator mode (secret-gated — see devMode.js).
142
- if (!isDevEmulator(config) && config.autonomyMode !== 'C') {
143
+ if (!isDevEmulator(config) && resolveConfigPermissionPreset(config, 'danger-full-access') !== 'danger-full-access') {
143
144
  const approvalId = `media_${crypto.randomUUID()}`;
144
145
  if (typeof approvalHost.emitEvent === 'function') {
145
146
  approvalHost.emitEvent({
@@ -367,7 +368,7 @@ export const generateMediaViaApi: { schema: { name: string; description: string;
367
368
  };
368
369
  if (mediaType === 'video_animation') return { success: false, code: 'MEDIA_PROVIDER_UNAVAILABLE', error: 'No supported video endpoint is configured. No media artifact was produced.' };
369
370
  const approvalHost = resolveApprovalHost(sandbox);
370
- if (approvalHost?.waitForApproval && !isDevEmulator(config) && config.autonomyMode !== 'C') {
371
+ if (approvalHost?.waitForApproval && !isDevEmulator(config) && resolveConfigPermissionPreset(config, 'danger-full-access') !== 'danger-full-access') {
371
372
  const approvalId = `media_${crypto.randomUUID()}`;
372
373
  approvalHost.emitEvent?.({ type: 'approval_request', toolCallId: approvalId, tool: 'generate_media_via_api', args: { mediaType, targetProvider: 'pollinations' }, risk: 'monetary_cost' });
373
374
  if (!await approvalHost.waitForApproval(approvalId)) return { success: false, code: 'MEDIA_APPROVAL_DENIED', error: 'Media generation was declined. No artifact was produced.' };
@@ -360,7 +360,7 @@ async function engineStatus(workspace, signal) {
360
360
  export const nativeEngineTool = {
361
361
  schema: {
362
362
  name: 'native_engine',
363
- description: 'Run an installed headless native engine directly. No MCP, no GUI automation, no screenshots. Start with status, then catalog. Use execute or batch with command ids from catalog; project/saveAs scope the document. export and render return artifact paths for immediate GUI/TUI preview. probe inspects media. An in-scope install is authorized by Mode C; supervised modes require explicit confirmation. Set open=true only when the user wants the artifact revealed in the OS.',
363
+ description: 'Run an installed headless native engine directly. No MCP, no GUI automation, no screenshots. Start with status, then catalog. Use execute or batch with command ids from catalog; project/saveAs scope the document. export and render return artifact paths for immediate GUI/TUI preview. probe inspects media. An in-scope install is authorized in Full access; Workspace Write requires explicit confirmation. Set open=true only when the user wants the artifact revealed in the OS.',
364
364
  parameters: {
365
365
  type: 'object',
366
366
  properties: {
@@ -400,7 +400,7 @@ export const nativeEngineTool = {
400
400
  keepGoing: { type: 'boolean', description: 'Batch continues after a failed command.' },
401
401
  query: { type: 'string', description: 'Catalog filter, inspect target, or media path for probe.' },
402
402
  open: { type: 'boolean', description: 'Reveal the resulting artifact in the OS after success.' },
403
- confirm: { type: 'boolean', description: 'Explicit confirmation in supervised modes. Mode C authorizes in-scope installs without this flag.' }
403
+ confirm: { type: 'boolean', description: 'Explicit confirmation in Workspace Write. Full access authorizes in-scope installs without this flag.' }
404
404
  },
405
405
  required: ['action'],
406
406
  additionalProperties: false
@@ -332,7 +332,7 @@ async function engineStatus(workspace: string, signal?: AbortSignal): Promise<Re
332
332
  export const nativeEngineTool = {
333
333
  schema: {
334
334
  name: 'native_engine',
335
- description: 'Run an installed headless native engine directly. No MCP, no GUI automation, no screenshots. Start with status, then catalog. Use execute or batch with command ids from catalog; project/saveAs scope the document. export and render return artifact paths for immediate GUI/TUI preview. probe inspects media. An in-scope install is authorized by Mode C; supervised modes require explicit confirmation. Set open=true only when the user wants the artifact revealed in the OS.',
335
+ description: 'Run an installed headless native engine directly. No MCP, no GUI automation, no screenshots. Start with status, then catalog. Use execute or batch with command ids from catalog; project/saveAs scope the document. export and render return artifact paths for immediate GUI/TUI preview. probe inspects media. An in-scope install is authorized in Full access; Workspace Write requires explicit confirmation. Set open=true only when the user wants the artifact revealed in the OS.',
336
336
  parameters: {
337
337
  type: 'object',
338
338
  properties: {
@@ -372,7 +372,7 @@ export const nativeEngineTool = {
372
372
  keepGoing: { type: 'boolean', description: 'Batch continues after a failed command.' },
373
373
  query: { type: 'string', description: 'Catalog filter, inspect target, or media path for probe.' },
374
374
  open: { type: 'boolean', description: 'Reveal the resulting artifact in the OS after success.' },
375
- confirm: { type: 'boolean', description: 'Explicit confirmation in supervised modes. Mode C authorizes in-scope installs without this flag.' }
375
+ confirm: { type: 'boolean', description: 'Explicit confirmation in Workspace Write. Full access authorizes in-scope installs without this flag.' }
376
376
  },
377
377
  required: ['action'],
378
378
  additionalProperties: false
@@ -245,7 +245,7 @@ export function searchCatalogue(intentOrQuery) {
245
245
  export const openSourceToolProvisioner = {
246
246
  schema: {
247
247
  name: 'open_source_tool_provisioner',
248
- description: 'Discover, evaluate hardware compatibility, and install open-source AI tools and models. Mode C authorizes in-scope installs; supervised modes require confirmation. Hardware, disk, and workspace checks still apply.',
248
+ description: 'Discover, evaluate hardware compatibility, and install open-source AI tools and models. Full access authorizes in-scope installs; Workspace Write requires confirmation. Hardware, disk, and workspace checks still apply.',
249
249
  parameters: {
250
250
  type: 'object',
251
251
  properties: {
@@ -264,7 +264,7 @@ export const openSourceToolProvisioner = {
264
264
  },
265
265
  confirm: {
266
266
  type: 'boolean',
267
- description: 'Explicit confirmation for supervised modes. Mode C authorizes in-scope installs without this flag.'
267
+ description: 'Explicit confirmation in Workspace Write. Full access authorizes in-scope installs without this flag.'
268
268
  },
269
269
  forceAlternative: {
270
270
  type: 'boolean',
@@ -300,7 +300,7 @@ export function searchCatalogue(intentOrQuery: string): OpenSourceToolProfile[]
300
300
  export const openSourceToolProvisioner = {
301
301
  schema: {
302
302
  name: 'open_source_tool_provisioner',
303
- description: 'Discover, evaluate hardware compatibility, and install open-source AI tools and models. Mode C authorizes in-scope installs; supervised modes require confirmation. Hardware, disk, and workspace checks still apply.',
303
+ description: 'Discover, evaluate hardware compatibility, and install open-source AI tools and models. Full access authorizes in-scope installs; Workspace Write requires confirmation. Hardware, disk, and workspace checks still apply.',
304
304
  parameters: {
305
305
  type: 'object',
306
306
  properties: {
@@ -319,7 +319,7 @@ export const openSourceToolProvisioner = {
319
319
  },
320
320
  confirm: {
321
321
  type: 'boolean',
322
- description: 'Explicit confirmation for supervised modes. Mode C authorizes in-scope installs without this flag.'
322
+ description: 'Explicit confirmation in Workspace Write. Full access authorizes in-scope installs without this flag.'
323
323
  },
324
324
  forceAlternative: {
325
325
  type: 'boolean',
@@ -2,7 +2,6 @@
2
2
  * @file src/tools/payloadSanitizer.ts
3
3
  * Causyne Agent — Media Payload Ceilings & Format Sniffer
4
4
  *
5
- * Ported & elevated from OpenClaw (src/media/configured-max-bytes.ts).
6
5
  * Enforces strict per-media-kind byte limits (images, audio, video) and
7
6
  * validates container magic numbers before staging payloads to LLM APIs,
8
7
  * preventing multimodal payloads from overflowing context limits.
@@ -2,7 +2,6 @@
2
2
  * @file src/tools/payloadSanitizer.ts
3
3
  * Causyne Agent — Media Payload Ceilings & Format Sniffer
4
4
  *
5
- * Ported & elevated from OpenClaw (src/media/configured-max-bytes.ts).
6
5
  * Enforces strict per-media-kind byte limits (images, audio, video) and
7
6
  * validates container magic numbers before staging payloads to LLM APIs,
8
7
  * preventing multimodal payloads from overflowing context limits.