@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.
- package/bin/causyne.js +1 -1
- package/package.json +4 -4
- package/src/acp/protocol.ts +19 -1
- package/src/acp/server.js +282 -8
- package/src/acp/server.ts +284 -8
- package/src/agent/abortableDelay.js +2 -2
- package/src/agent/abortableDelay.ts +2 -2
- package/src/agent/errorClassifier.js +9 -1
- package/src/agent/errorClassifier.ts +8 -1
- package/src/agentLoop.js +83 -27
- package/src/agentLoop.ts +92 -26
- package/src/approvalPolicy.js +34 -10
- package/src/approvalPolicy.ts +42 -11
- package/src/browser/causyneBrowser.js +30 -3
- package/src/browser/causyneBrowser.ts +33 -3
- package/src/browser/urlPolicy.js +14 -1
- package/src/browser/urlPolicy.ts +12 -1
- package/src/cliMode.js +21 -9
- package/src/cliMode.ts +20 -8
- package/src/commands.js +188 -32
- package/src/commands.ts +209 -32
- package/src/config.js +19 -4
- package/src/config.ts +18 -4
- package/src/core/contextCompactor.js +54 -7
- package/src/core/contextCompactor.ts +63 -7
- package/src/core/goalLoop.js +257 -0
- package/src/core/goalLoop.ts +310 -0
- package/src/entrypoint.js +135 -3
- package/src/entrypoint.ts +136 -3
- package/src/game/causyneCoreBridge.js +686 -0
- package/src/game/causyneCoreBridge.ts +702 -0
- package/src/game/gameLauncher.js +287 -0
- package/src/game/gameLauncher.ts +352 -0
- package/src/game/gameProvisioner.js +425 -0
- package/src/game/gameProvisioner.ts +488 -0
- package/src/headlessCli.js +19 -12
- package/src/headlessCli.ts +22 -8
- package/src/infra/atomicWriter.js +40 -4
- package/src/infra/atomicWriter.ts +36 -4
- package/src/launchIntent.js +73 -3
- package/src/launchIntent.ts +76 -3
- package/src/lsp/lspClient.js +83 -12
- package/src/lsp/lspClient.ts +75 -12
- package/src/mcp/mcpRegistry.js +75 -8
- package/src/mcp/mcpRegistry.ts +70 -7
- package/src/memory/contextBudget.js +2 -0
- package/src/memory/contextBudget.ts +1 -0
- package/src/modelVariants.js +45 -0
- package/src/modelVariants.ts +54 -0
- package/src/outputRecovery.js +3 -2
- package/src/outputRecovery.ts +4 -2
- package/src/permissionPresets.js +327 -0
- package/src/permissionPresets.ts +361 -0
- package/src/providers/antigravity.js +62 -9
- package/src/providers/antigravity.ts +73 -9
- package/src/providers/byokHttp.js +7 -1
- package/src/providers/byokHttp.ts +6 -1
- package/src/providers/byokStream.js +21 -8
- package/src/providers/byokStream.ts +17 -7
- package/src/providers/dashscope-byok.js +21 -5
- package/src/providers/dashscope-byok.ts +29 -11
- package/src/providers/moonshot.js +26 -7
- package/src/providers/moonshot.ts +34 -13
- package/src/providers/muse.js +6 -0
- package/src/providers/muse.ts +8 -0
- package/src/providers/ollama.js +39 -7
- package/src/providers/ollama.ts +36 -7
- package/src/providers/openai-compatible.js +16 -3
- package/src/providers/openai-compatible.ts +13 -3
- package/src/providers/openai.js +62 -4
- package/src/providers/openai.ts +50 -4
- package/src/providers/openrouter.js +19 -4
- package/src/providers/openrouter.ts +21 -4
- package/src/providers/qwen-byok.js +21 -5
- package/src/providers/qwen-byok.ts +29 -11
- package/src/providers/xai.js +26 -10
- package/src/providers/xai.ts +34 -16
- package/src/reporting.js +4 -2
- package/src/reporting.ts +4 -2
- package/src/sandbox.js +34 -0
- package/src/sandbox.ts +43 -0
- package/src/scheduler/scheduler.js +372 -0
- package/src/scheduler/scheduler.ts +433 -0
- package/src/sessionSearchIndex.js +267 -0
- package/src/sessionSearchIndex.ts +311 -0
- package/src/skillsManager.js +2 -3
- package/src/skillsManager.ts +2 -3
- package/src/toolPacks.js +6 -0
- package/src/toolPacks.ts +6 -0
- package/src/tools/applyPatch.js +1 -1
- package/src/tools/applyPatch.ts +1 -1
- package/src/tools/generateMediaViaApi.js +4 -3
- package/src/tools/generateMediaViaApi.ts +4 -3
- package/src/tools/nativeEngine.js +2 -2
- package/src/tools/nativeEngine.ts +2 -2
- package/src/tools/openSourceToolProvisioner.js +2 -2
- package/src/tools/openSourceToolProvisioner.ts +2 -2
- package/src/tools/payloadSanitizer.js +0 -1
- package/src/tools/payloadSanitizer.ts +0 -1
- package/src/tools/pdfReader.js +122 -20
- package/src/tools/pdfReader.ts +111 -20
- package/src/tools/presentDeliverable.js +103 -0
- package/src/tools/presentDeliverable.ts +127 -0
- package/src/tools/ptcRuntime.js +444 -0
- package/src/tools/ptcRuntime.ts +490 -0
- package/src/tools/ptyTerminal.js +1096 -0
- package/src/tools/ptyTerminal.ts +1231 -0
- package/src/tools/registry.js +21 -12
- package/src/tools/registry.ts +21 -12
- package/src/tools/toolOutputStore.js +26 -4
- package/src/tools/toolOutputStore.ts +22 -4
- package/src/tools/webFetch.js +158 -11
- package/src/tools/webFetch.ts +145 -11
- package/src/tools/webSearch.js +123 -36
- package/src/tools/webSearch.ts +124 -33
- package/src/tui/banner.js +5 -1
- package/src/tui/banner.ts +6 -1
- package/src/tui/chatRenderer.js +1 -2
- package/src/tui/chatRenderer.ts +1 -2
- package/src/tui/completion.js +1 -0
- package/src/tui/completion.ts +1 -0
- package/src/tui/composerControls.js +111 -27
- package/src/tui/composerControls.ts +124 -28
- package/src/tui/dialogs.js +3 -16
- package/src/tui/dialogs.ts +3 -16
- package/src/tui/home.js +1 -0
- package/src/tui/home.ts +1 -0
- package/src/tui/invocation.js +1 -2
- package/src/tui/invocation.ts +1 -2
- package/src/tui/modelPicker.js +22 -12
- package/src/tui/modelPicker.ts +22 -12
- package/src/tui/overlay.js +2 -5
- package/src/tui/overlay.ts +2 -5
- package/src/tui/prompt.js +6 -4
- package/src/tui/prompt.ts +6 -4
- package/src/tui/selectList.js +4 -12
- package/src/tui/selectList.ts +4 -12
- package/src/tui/setup.js +22 -9
- package/src/tui/setup.ts +26 -9
- package/src/tui/statusLine.ts +2 -0
- package/src/web/client/browserPanel.js +702 -0
- package/src/web/client/browserPanel.ts +663 -0
- package/src/web/client/chatStream.js +309 -0
- package/src/web/client/chatStream.ts +289 -0
- package/src/web/client/cliPanel.js +165 -0
- package/src/web/client/cliPanel.ts +171 -0
- package/src/web/client/composer.js +204 -0
- package/src/web/client/composer.ts +209 -0
- package/src/web/client/diffPanel.js +176 -0
- package/src/web/client/diffPanel.ts +203 -0
- package/src/web/client/dom.js +220 -0
- package/src/web/client/dom.ts +221 -0
- package/src/web/client/filesAndCanvas.js +231 -0
- package/src/web/client/filesAndCanvas.ts +238 -0
- package/src/web/client/gameLauncherUi.js +78 -0
- package/src/web/client/gameLauncherUi.ts +78 -0
- package/src/web/client/main.js +301 -0
- package/src/web/client/main.ts +368 -0
- package/src/web/client/markdown.js +364 -0
- package/src/web/client/markdown.ts +373 -0
- package/src/web/client/modelPicker.js +455 -0
- package/src/web/client/modelPicker.ts +451 -0
- package/src/web/client/permissionPresetsUi.js +307 -0
- package/src/web/client/permissionPresetsUi.ts +333 -0
- package/src/web/client/sessions.js +353 -0
- package/src/web/client/sessions.ts +372 -0
- package/src/web/client/settingsModal.js +191 -0
- package/src/web/client/settingsModal.ts +176 -0
- package/src/web/client/state.js +250 -0
- package/src/web/client/state.ts +233 -0
- package/src/web/client/streamSmoother.js +127 -0
- package/src/web/client/streamSmoother.ts +119 -0
- package/src/web/client/studioLayout.js +54 -0
- package/src/web/client/studioLayout.ts +60 -0
- package/src/web/client/studioShell.js +327 -0
- package/src/web/client/studioShell.ts +340 -0
- package/src/web/client/studioStart.js +77 -0
- package/src/web/client/studioStart.ts +89 -0
- package/src/web/client/terminalPanel.js +357 -0
- package/src/web/client/terminalPanel.ts +345 -0
- package/src/web/client/turnView.js +934 -0
- package/src/web/client/turnView.ts +981 -0
- package/src/web/client/types.js +1 -0
- package/src/web/client/types.ts +319 -0
- package/src/web/client/validators.js +106 -0
- package/src/web/client/validators.ts +96 -0
- package/src/web/server/activeRuns.js +152 -0
- package/src/web/server/activeRuns.ts +171 -0
- package/src/web/server/routesBrowser.js +355 -0
- package/src/web/server/routesBrowser.ts +386 -0
- package/src/web/server/routesChat.js +304 -0
- package/src/web/server/routesChat.ts +347 -0
- package/src/web/server/routesCore.js +472 -0
- package/src/web/server/routesCore.ts +522 -0
- package/src/web/server/routesTerminal.js +162 -0
- package/src/web/server/routesTerminal.ts +182 -0
- package/src/web/server/routesWorkspace.js +510 -0
- package/src/web/server/routesWorkspace.ts +546 -0
- package/src/web/server/security.js +98 -0
- package/src/web/server/security.ts +108 -0
- package/src/web/server/sessionTranscript.js +586 -0
- package/src/web/server/sessionTranscript.ts +566 -0
- package/src/web/server/staticAssets.js +80 -0
- package/src/web/server/staticAssets.ts +91 -0
- package/src/web/server/types.js +1 -0
- package/src/web/server/types.ts +135 -0
- package/src/web/server/workspaceFiles.js +368 -0
- package/src/web/server/workspaceFiles.ts +363 -0
- package/src/web/skybridgeServer.js +76 -2449
- package/src/web/skybridgeServer.ts +118 -2600
- package/src/web/skybridgeUi.js +16 -450
- package/src/web/skybridgeUi.ts +16 -454
- package/src/web/styles/agent.css +380 -0
- package/src/web/styles/composer.css +193 -0
- package/src/web/styles/overlays.css +436 -0
- package/src/web/styles/shell.css +387 -0
- package/src/web/styles/studio.css +723 -0
- package/src/web/styles/thread.css +221 -0
- package/src/web/styles/tokens.css +94 -0
- package/src/web/ui/brandMark.js +73 -0
- package/src/web/ui/brandMark.ts +82 -0
- package/src/web/ui/modalsTemplate.js +139 -0
- package/src/web/ui/modalsTemplate.ts +139 -0
- package/src/web/ui/sidebarTemplate.js +63 -0
- package/src/web/ui/sidebarTemplate.ts +64 -0
- package/src/web/ui/studioTemplate.js +258 -0
- package/src/web/ui/studioTemplate.ts +258 -0
- package/src/web/ui/workspaceTemplate.js +72 -0
- package/src/web/ui/workspaceTemplate.ts +73 -0
- package/src/worktreeManager.js +16 -1
- package/src/worktreeManager.ts +22 -1
- package/src/web/skybridgeClientScript.js +0 -3951
- package/src/web/skybridgeClientScript.ts +0 -3952
- package/src/web/skybridgeStyles.js +0 -827
- 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
|
+
};
|
package/src/skillsManager.js
CHANGED
|
@@ -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
|
|
159
|
-
*
|
|
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
|
package/src/skillsManager.ts
CHANGED
|
@@ -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
|
|
185
|
-
*
|
|
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: [
|
package/src/tools/applyPatch.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Causyne Agent — Transactional Multi-File Patch Engine (`apply_patch`)
|
|
3
3
|
*
|
|
4
|
-
* Applies
|
|
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>`)
|
package/src/tools/applyPatch.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Causyne Agent — Transactional Multi-File Patch Engine (`apply_patch`)
|
|
3
3
|
*
|
|
4
|
-
* Applies
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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.
|
|
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
|
|
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.
|