@causyne/agent 1.11.0 → 1.13.0
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/docs/THIRD_PARTY_NOTICES.md +12 -0
- package/package.json +2 -2
- package/src/acp/protocol.js +1 -0
- package/src/acp/protocol.ts +22 -0
- package/src/acp/server.js +158 -21
- package/src/acp/server.ts +167 -21
- package/src/agentLoop.d.ts +22 -1
- package/src/agentLoop.js +15 -5
- package/src/approvalGrants.js +33 -0
- package/src/approvalGrants.ts +50 -0
- package/src/decisionPolicy.js +2 -0
- package/src/decisionPolicy.ts +1 -0
- package/src/engines/cad.js +113 -0
- package/src/engines/cad.ts +128 -0
- package/src/engines/deck.js +105 -0
- package/src/engines/deck.ts +109 -0
- package/src/engines/design.js +123 -0
- package/src/engines/design.ts +141 -0
- package/src/engines/effect.js +128 -0
- package/src/engines/effect.ts +142 -0
- package/src/engines/film.js +108 -0
- package/src/engines/film.ts +104 -0
- package/src/engines/grid.js +106 -0
- package/src/engines/grid.ts +121 -0
- package/src/engines/installer.js +226 -0
- package/src/engines/installer.ts +248 -0
- package/src/engines/light.js +107 -0
- package/src/engines/light.ts +122 -0
- package/src/engines/pdf.js +108 -0
- package/src/engines/pdf.ts +124 -0
- package/src/engines/photo.js +126 -0
- package/src/engines/photo.ts +137 -0
- package/src/engines/registry.js +200 -0
- package/src/engines/registry.ts +199 -0
- package/src/engines/sound.js +117 -0
- package/src/engines/sound.ts +130 -0
- package/src/engines/types.js +1 -0
- package/src/engines/types.ts +73 -0
- package/src/engines/word.js +112 -0
- package/src/engines/word.ts +127 -0
- package/src/memoryManager.js +9 -3
- package/src/promptMentions.js +1 -1
- package/src/promptMentions.ts +1 -1
- package/src/sandbox.js +8 -0
- package/src/sessionJournal.js +12 -2
- package/src/sessionJournal.ts +12 -2
- package/src/toolPacks.js +15 -7
- package/src/tools/generateMediaViaApi.js +1 -1
- package/src/tools/nativeEngine.js +464 -0
- package/src/tools/nativeEngine.ts +433 -0
- package/src/tools/openSourceToolProvisioner.js +510 -0
- package/src/tools/openSourceToolProvisioner.ts +590 -0
- package/src/tools/registry.js +4 -1
- package/src/tui/completion.js +2 -2
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import type {
|
|
3
|
+
NativeEngineAction,
|
|
4
|
+
NativeEngineAdapter,
|
|
5
|
+
NativeEngineContext,
|
|
6
|
+
NativeEngineInvocation,
|
|
7
|
+
NativeEngineRequest,
|
|
8
|
+
NativeEngineStep
|
|
9
|
+
} from './types.js';
|
|
10
|
+
|
|
11
|
+
// Document typesetting, DOCX/PDF formatting, and text processing engine for Causyne Agent.
|
|
12
|
+
// Headless word processor, document structural inspector, and batch runner.
|
|
13
|
+
// Operates deterministically via clean CLI subcommands.
|
|
14
|
+
|
|
15
|
+
const TIMEOUTS: Record<NativeEngineAction, number> = {
|
|
16
|
+
status: 10_000,
|
|
17
|
+
catalog: 30_000,
|
|
18
|
+
describe: 30_000,
|
|
19
|
+
inspect: 60_000,
|
|
20
|
+
execute: 180_000,
|
|
21
|
+
batch: 600_000,
|
|
22
|
+
export: 300_000,
|
|
23
|
+
render: 300_000,
|
|
24
|
+
probe: 60_000,
|
|
25
|
+
install: 600_000
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function positional(value: string): string {
|
|
29
|
+
return value.startsWith('-') ? `.${path.sep}${value}` : value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function requireProject(context: NativeEngineContext, action: string): string {
|
|
33
|
+
if (!context.project) throw new Error(`${action} requires project`);
|
|
34
|
+
return positional(context.project);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function commandArgs(steps: NativeEngineStep[]): string[] {
|
|
38
|
+
const args: string[] = [];
|
|
39
|
+
for (const step of steps) {
|
|
40
|
+
if (step.params && Object.keys(step.params).length > 0) {
|
|
41
|
+
args.push('--cmd', `${step.id}=${JSON.stringify(step.params)}`);
|
|
42
|
+
} else {
|
|
43
|
+
args.push('--cmd', step.id);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return args;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const wordEngine: NativeEngineAdapter = {
|
|
50
|
+
id: 'word',
|
|
51
|
+
label: 'Causyne Word Engine',
|
|
52
|
+
envVar: 'CAUSYNE_ENGINE_WORD',
|
|
53
|
+
binaryName: 'causyne-engine-word',
|
|
54
|
+
actions: ['catalog', 'describe', 'inspect', 'execute', 'batch', 'export', 'render', 'probe'],
|
|
55
|
+
invoke(request: NativeEngineRequest, context: NativeEngineContext): NativeEngineInvocation {
|
|
56
|
+
let args: string[];
|
|
57
|
+
let artifacts: string[] = [];
|
|
58
|
+
|
|
59
|
+
switch (request.action) {
|
|
60
|
+
case 'status':
|
|
61
|
+
args = ['--version'];
|
|
62
|
+
break;
|
|
63
|
+
case 'catalog':
|
|
64
|
+
args = ['commands', '--json'];
|
|
65
|
+
break;
|
|
66
|
+
case 'describe':
|
|
67
|
+
args = ['commands', '--json'];
|
|
68
|
+
break;
|
|
69
|
+
case 'inspect':
|
|
70
|
+
args = ['info', requireProject(context, 'inspect')];
|
|
71
|
+
break;
|
|
72
|
+
case 'probe':
|
|
73
|
+
args = ['info', positional(request.query ?? '')];
|
|
74
|
+
break;
|
|
75
|
+
case 'execute':
|
|
76
|
+
case 'batch': {
|
|
77
|
+
const steps: NativeEngineStep[] = request.action === 'execute'
|
|
78
|
+
? [{ id: request.command ?? '', ...(request.params ? { params: request.params } : {}) }]
|
|
79
|
+
: (request.steps ?? []);
|
|
80
|
+
|
|
81
|
+
args = ['run'];
|
|
82
|
+
if (context.project) {
|
|
83
|
+
args.push('--file', positional(context.project));
|
|
84
|
+
} else if (context.demo) {
|
|
85
|
+
args.push('--template', 'blank');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
args.push(...commandArgs(steps));
|
|
89
|
+
|
|
90
|
+
if (context.saveAs) {
|
|
91
|
+
args.push('--save', context.saveAs);
|
|
92
|
+
artifacts.push(context.saveAs);
|
|
93
|
+
} else if (context.save && context.project) {
|
|
94
|
+
args.push('--save', context.project);
|
|
95
|
+
artifacts.push(context.project);
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
case 'export': {
|
|
100
|
+
const output = request.output ?? '';
|
|
101
|
+
args = ['convert', requireProject(context, 'export'), positional(output)];
|
|
102
|
+
artifacts = [output];
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
case 'render': {
|
|
106
|
+
const output = request.output ?? '';
|
|
107
|
+
args = ['render', requireProject(context, 'render'), positional(output)];
|
|
108
|
+
if (request.range) {
|
|
109
|
+
args.push('--page', request.range);
|
|
110
|
+
}
|
|
111
|
+
if (request.scale !== undefined) {
|
|
112
|
+
args.push('--scale', String(request.scale));
|
|
113
|
+
}
|
|
114
|
+
artifacts = [output];
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
default:
|
|
118
|
+
throw new Error(`Unsupported word engine action: ${request.action}`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
args,
|
|
123
|
+
artifacts,
|
|
124
|
+
timeoutMs: TIMEOUTS[request.action] ?? 60_000
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
};
|
package/src/memoryManager.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { resolveSession, createSession, switchSession, saveSessionMessages } from './sessionStore.js';
|
|
3
|
+
import { resolveSession, createSession, getSession, switchSession, saveSessionMessages } from './sessionStore.js';
|
|
4
4
|
import os from 'os';
|
|
5
5
|
import { causyneHome } from './utils/paths.js';
|
|
6
6
|
|
|
@@ -30,10 +30,16 @@ export class MemoryManager {
|
|
|
30
30
|
* directory — so typing continue in a new project resumed a conversation
|
|
31
31
|
* from a different one, months old. See src/sessionStore.js.
|
|
32
32
|
*/
|
|
33
|
-
constructor(workspace = process.cwd()) {
|
|
33
|
+
constructor(workspace = process.cwd(), sessionId = null) {
|
|
34
34
|
this.ensureMemoryDir();
|
|
35
35
|
this.workspace = workspace;
|
|
36
|
-
|
|
36
|
+
if (sessionId) {
|
|
37
|
+
// A server-owned conversation is pinned by id. It must never fall back to
|
|
38
|
+
// resolveSession(), which could silently attach it to a different chat.
|
|
39
|
+
this.session = getSession(sessionId) || createSession(workspace, 'Untitled', false);
|
|
40
|
+
} else {
|
|
41
|
+
this.session = resolveSession(workspace);
|
|
42
|
+
}
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
/** The active session's id, for the status line and /sessions. */
|
package/src/promptMentions.js
CHANGED
|
@@ -114,7 +114,7 @@ export async function resolveMentionedContext(prompt, options = {}) {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
const relPath = path.relative(cwd, targetPath);
|
|
117
|
+
const relPath = path.relative(cwd, targetPath).split(path.sep).join('/');
|
|
118
118
|
if (!found) {
|
|
119
119
|
sections.push(`📂 REFERENCED PATH: ${m.path} (Note: path was not found on disk at ${relPath})`);
|
|
120
120
|
continue;
|
package/src/promptMentions.ts
CHANGED
|
@@ -148,7 +148,7 @@ export async function resolveMentionedContext(
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
const relPath = path.relative(cwd, targetPath);
|
|
151
|
+
const relPath = path.relative(cwd, targetPath).split(path.sep).join('/');
|
|
152
152
|
|
|
153
153
|
if (!found) {
|
|
154
154
|
sections.push(`📂 REFERENCED PATH: ${m.path} (Note: path was not found on disk at ${relPath})`);
|
package/src/sandbox.js
CHANGED
|
@@ -302,6 +302,14 @@ export class Sandbox {
|
|
|
302
302
|
return { allowed: true, risk: args.action === 'status' ? 'safe' : 'dangerous' };
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
+
if (toolName === 'native_engine') {
|
|
306
|
+
if (args.action === 'install') {
|
|
307
|
+
return { allowed: true, risk: 'extreme', reason: 'Downloads and installs a native engine binary' };
|
|
308
|
+
}
|
|
309
|
+
const readOnly = ['status', 'catalog', 'describe', 'inspect', 'probe'];
|
|
310
|
+
return { allowed: true, risk: readOnly.includes(args.action) ? 'safe' : 'dangerous' };
|
|
311
|
+
}
|
|
312
|
+
|
|
305
313
|
if (toolName === 'game_asset_fetch' && args.action === 'download_asset') {
|
|
306
314
|
if (!args.url || this.isInternalUrl(args.url)) {
|
|
307
315
|
return { allowed: false, reason: 'Cannot download from an internal or invalid URL', risk: 'forbidden' };
|
package/src/sessionJournal.js
CHANGED
|
@@ -263,7 +263,7 @@ export function pruneSessions(max = MAX_SESSIONS) {
|
|
|
263
263
|
}
|
|
264
264
|
return removed;
|
|
265
265
|
}
|
|
266
|
-
export function createSession(workspace, title = 'Untitled') {
|
|
266
|
+
export function createSession(workspace, title = 'Untitled', makeActive = true) {
|
|
267
267
|
const now = Date.now();
|
|
268
268
|
const workspaceText = String(workspace ?? '');
|
|
269
269
|
const session = {
|
|
@@ -278,10 +278,20 @@ export function createSession(workspace, title = 'Untitled') {
|
|
|
278
278
|
// Persistence is best-effort. An unavailable state directory must not stop a
|
|
279
279
|
// user from starting an otherwise usable foreground session.
|
|
280
280
|
writeNewTranscript(session);
|
|
281
|
-
|
|
281
|
+
if (makeActive)
|
|
282
|
+
setActiveSession(session.id);
|
|
282
283
|
pruneSessions();
|
|
283
284
|
return session;
|
|
284
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Read one conversation without making it the active session.
|
|
288
|
+
*
|
|
289
|
+
* Server-owned conversations must never move the terminal's active pointer;
|
|
290
|
+
* they only need the transcript that belongs to their own id.
|
|
291
|
+
*/
|
|
292
|
+
export function getSession(id) {
|
|
293
|
+
return readSession(id);
|
|
294
|
+
}
|
|
285
295
|
export function getActiveSessionId() {
|
|
286
296
|
try {
|
|
287
297
|
if (!fs.existsSync(POINTER_FILE))
|
package/src/sessionJournal.ts
CHANGED
|
@@ -295,7 +295,7 @@ export function pruneSessions(max = MAX_SESSIONS): number {
|
|
|
295
295
|
return removed;
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
export function createSession(workspace: unknown, title = 'Untitled'): SessionRecord {
|
|
298
|
+
export function createSession(workspace: unknown, title = 'Untitled', makeActive = true): SessionRecord {
|
|
299
299
|
const now = Date.now();
|
|
300
300
|
const workspaceText = String(workspace ?? '');
|
|
301
301
|
const session: SessionRecord = {
|
|
@@ -310,11 +310,21 @@ export function createSession(workspace: unknown, title = 'Untitled'): SessionRe
|
|
|
310
310
|
// Persistence is best-effort. An unavailable state directory must not stop a
|
|
311
311
|
// user from starting an otherwise usable foreground session.
|
|
312
312
|
writeNewTranscript(session);
|
|
313
|
-
setActiveSession(session.id);
|
|
313
|
+
if (makeActive) setActiveSession(session.id);
|
|
314
314
|
pruneSessions();
|
|
315
315
|
return session;
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
+
/**
|
|
319
|
+
* Read one conversation without making it the active session.
|
|
320
|
+
*
|
|
321
|
+
* Server-owned conversations must never move the terminal's active pointer;
|
|
322
|
+
* they only need the transcript that belongs to their own id.
|
|
323
|
+
*/
|
|
324
|
+
export function getSession(id: unknown): SessionRecord | null {
|
|
325
|
+
return readSession(id);
|
|
326
|
+
}
|
|
327
|
+
|
|
318
328
|
export function getActiveSessionId(): string | null {
|
|
319
329
|
try {
|
|
320
330
|
if (!fs.existsSync(POINTER_FILE)) return null;
|
package/src/toolPacks.js
CHANGED
|
@@ -86,9 +86,11 @@ export const PACKS = {
|
|
|
86
86
|
'manage_local_dependencies',
|
|
87
87
|
'blender_act',
|
|
88
88
|
'creative_apps',
|
|
89
|
+
'native_engine',
|
|
89
90
|
'resolve_act',
|
|
90
91
|
'palmier_act',
|
|
91
|
-
'document_forge'
|
|
92
|
+
'document_forge',
|
|
93
|
+
'open_source_tool_provisioner'
|
|
92
94
|
],
|
|
93
95
|
system: [
|
|
94
96
|
// Channel B of the Three-Channel Doctrine: reading the screen as structured
|
|
@@ -228,6 +230,10 @@ You MUST produce visually UNIQUE output on every project. Specifically:
|
|
|
228
230
|
- **ENFORCED, NOT ADVISORY**: every HTML/CSS file you write is read back and scored by an automatic gate before the task can finish (src/slopDetector.js). It looks for the stock gradient hexes, purple-to-blue ramps, placeholder marketing copy, emoji used as icons, default-only typography, the centered-hero/3-cards/"Get Started" skeleton and the stock soft shadow. Score too high and you will be sent back to rebuild with a named design movement. Design it properly the first time; the gate is not fooled by swapping one gradient for another.`,
|
|
229
231
|
|
|
230
232
|
media: `# Media Generation Protocol (Sovereign 5-Stage Hierarchy & Seamless Consent Routing)
|
|
233
|
+
|
|
234
|
+
## Native engine-first for file media work
|
|
235
|
+
For editing or producing media from files in the workspace, check \`native_engine\` status first; engines are added one at a time, starting with film. If the engine is missing, explain the download and ask before calling \`install\` with \`confirm: true\`. When the needed engine is installed, use \`catalog\` -> \`execute\` or \`batch\`. Pass \`project\` to edit an existing document or \`saveAs\` for a new one, then \`render\` a preview and inspect it before exporting. Engines are headless: never use MCP servers, \`computer_use\`, or screenshots to drive them. The generation chain below applies only when no native engine capability exists or the user explicitly asks for generated media.
|
|
236
|
+
|
|
231
237
|
When the user asks you to generate images, audio, music, video, or any creative media, you MUST navigate this exact 5-Stage priority chain:
|
|
232
238
|
|
|
233
239
|
## Stage 1: Specialized Paid APIs (Primary / Auto-Router)
|
|
@@ -238,12 +244,14 @@ Always attempt calling \`generate_media_via_api\` FIRST.
|
|
|
238
244
|
|
|
239
245
|
## Stage 2: Local AI Models / Binaries (Mode B & C — First Fallback)
|
|
240
246
|
When Stage 1 is denied or unconfigured, you MUST evaluate local processing on the user's PC:
|
|
241
|
-
1. **Mandatory Gatekeeper**: Call \`check_system_specs\` FIRST
|
|
242
|
-
2. **Eligibility & Action**:
|
|
243
|
-
- **
|
|
244
|
-
- **
|
|
245
|
-
|
|
246
|
-
|
|
247
|
+
1. **Mandatory Gatekeeper**: Call \`open_source_tool_provisioner\` (action: 'discover' or 'evaluate') or \`check_system_specs\` FIRST to verify hardware (RAM, CPU cores, GPU/Metal acceleration, disk space).
|
|
248
|
+
2. **Eligibility & Action**: Use \`open_source_tool_provisioner\` to discover and inspect open-source tools matching user intent:
|
|
249
|
+
- **Voice Generation / Cloning**: F5-TTS, Kokoro-82M, XTTS-v2, Chatterbox (with exact RAM, compute, and disk size reported).
|
|
250
|
+
- **Audio / Transcription**: Whisper.cpp, Faster-Whisper.
|
|
251
|
+
- **Image / Restoration**: Real-ESRGAN, Rembg.
|
|
252
|
+
- **Local LLMs**: Ollama.
|
|
253
|
+
3. **Mandatory HITL Consent**: \`open_source_tool_provisioner\` enforces Human-In-The-Loop approval (\`confirm: true\` or structured \`request_decision\`) before downloading or installing any model or package.
|
|
254
|
+
4. **Seamless Denial Routing**: If hardware is insufficient OR the user denies local downloads, immediately transition to Stage 3.
|
|
247
255
|
|
|
248
256
|
## Stage 3: Free Cloud APIs / Pollinations.ai (Mode D — Second Fallback)
|
|
249
257
|
When Stage 2 is impossible or denied, fall back to free cloud APIs via \`generate_media_via_api\` (\`provider: 'pollinations'\`).
|
|
@@ -119,7 +119,7 @@ async function routeMultimediaRequest(args, config, sandbox, tokenTracker) {
|
|
|
119
119
|
return {
|
|
120
120
|
success: true,
|
|
121
121
|
mode: 'Fallback (Stage 2 / Stage 4 / Stage 5)',
|
|
122
|
-
message: `User denied Stage 1 paid API switch ($${estimatedCost.toFixed(2)}). Stage 2 Fallback: Please invoke 'check_system_specs' right now.
|
|
122
|
+
message: `User denied Stage 1 paid API switch ($${estimatedCost.toFixed(2)}). Stage 2 Fallback: Please invoke 'open_source_tool_provisioner' (or 'check_system_specs') right now. It checks local hardware (RAM, Apple Silicon Metal/CUDA, disk space), discovers top open-source tools matching the intent (e.g., F5-TTS/Kokoro for voice cloning, Whisper for transcription), and provides compute specs with mandatory Human-In-The-Loop approval before installation.`
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
}
|