@causyne/agent 1.20.121 → 1.20.122
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/package.json +1 -1
- package/src/acp/agentCatalog.js +81 -26
- package/src/acp/agentCatalog.ts +73 -29
- package/src/acp/client.js +210 -53
- package/src/acp/client.ts +202 -52
- package/src/acp/peerProfiles.js +55 -22
- package/src/acp/peerProfiles.ts +51 -22
- package/src/acp/protocol.js +37 -8
- package/src/acp/protocol.ts +30 -8
- package/src/acp/server.js +123 -25
- package/src/acp/server.ts +124 -24
- package/src/agent/errorClassifier.js +6 -2
- package/src/agent/errorClassifier.ts +6 -2
- package/src/agentLoop.js +11 -5
- package/src/agentLoop.ts +11 -5
- package/src/approvalGrants.js +19 -7
- package/src/approvalGrants.ts +20 -7
- package/src/approvalPolicy.js +48 -15
- package/src/approvalPolicy.ts +46 -15
- package/src/autoUpdate.js +5 -2
- package/src/autoUpdate.ts +5 -2
- package/src/browser/causyneBrowser.js +3 -2
- package/src/browser/causyneBrowser.ts +3 -2
- package/src/browser/searchProviders.js +1 -1
- package/src/browser/searchProviders.ts +1 -1
- package/src/config.js +287 -250
- package/src/config.ts +342 -0
- package/src/configVault.js +84 -17
- package/src/configVault.ts +77 -17
- package/src/continuum/compactor.js +2 -1
- package/src/continuum/compactor.ts +2 -1
- package/src/continuum/sanitizer.js +10 -3
- package/src/continuum/sanitizer.ts +9 -3
- package/src/continuum/ui/continuumPickerView.js +3 -2
- package/src/continuum/ui/continuumPickerView.ts +3 -2
- package/src/cortex/vectorDb.js +26 -15
- package/src/cortex/vectorDb.ts +26 -16
- package/src/creative/liveBridge.js +7 -5
- package/src/creative/liveBridge.ts +7 -5
- package/src/creative/studioScripts.js +16 -5
- package/src/creative/studioScripts.ts +14 -5
- package/src/decisionPolicy.js +16 -4
- package/src/decisionPolicy.ts +14 -4
- package/src/documentEngine/antiSlopAuditor.js +10 -5
- package/src/documentEngine/antiSlopAuditor.ts +11 -5
- package/src/documentEngine/documentForge.js +47 -15
- package/src/documentEngine/documentForge.ts +43 -14
- package/src/engines/design.js +2 -1
- package/src/engines/design.ts +2 -1
- package/src/engines/film.js +4 -4
- package/src/engines/film.ts +2 -2
- package/src/engines/light.js +2 -1
- package/src/engines/light.ts +2 -1
- package/src/engines/registry.js +1 -1
- package/src/engines/registry.ts +1 -1
- package/src/engines/reverseHarness.js +4 -3
- package/src/engines/reverseHarness.ts +4 -3
- package/src/headlessCli.js +2 -1
- package/src/headlessCli.ts +2 -1
- package/src/historyPruner.js +3 -2
- package/src/historyPruner.ts +3 -2
- package/src/hooks.js +3 -0
- package/src/hooks.ts +3 -0
- package/src/implementationPlan.js +21 -11
- package/src/implementationPlan.ts +21 -11
- package/src/infra/atomicWriter.js +4 -1
- package/src/infra/atomicWriter.ts +4 -1
- package/src/launchIntent.js +1 -1
- package/src/launchIntent.ts +1 -1
- package/src/memory/scopedFacts.js +1 -1
- package/src/memory/scopedFacts.ts +1 -1
- package/src/memory/symbolFolder.js +1 -1
- package/src/memory/symbolFolder.ts +1 -1
- package/src/modelRouter.js +1 -1
- package/src/modelRouter.ts +1 -1
- package/src/observer/evidence.js +10 -4
- package/src/observer/evidence.ts +10 -4
- package/src/osKeychain.js +62 -8
- package/src/osKeychain.ts +50 -8
- package/src/perception.js +3 -2
- package/src/perception.ts +3 -2
- package/src/planCache.js +2 -2
- package/src/planCache.ts +2 -2
- package/src/pluginsFactory/pluginsFactory.js +19 -11
- package/src/pluginsFactory/pluginsFactory.ts +18 -11
- package/src/promptMentions.js +2 -2
- package/src/promptMentions.ts +2 -2
- package/src/providers/acp.js +1 -1
- package/src/providers/acp.ts +1 -1
- package/src/providers/anthropic.js +327 -401
- package/src/providers/anthropic.ts +386 -0
- package/src/providers/antigravity.js +10 -4
- package/src/providers/antigravity.ts +10 -4
- package/src/providers/base.js +221 -319
- package/src/providers/base.ts +340 -0
- package/src/providers/byokHttp.js +58 -15
- package/src/providers/byokHttp.ts +59 -16
- package/src/providers/byokStream.js +142 -51
- package/src/providers/byokStream.ts +146 -42
- package/src/providers/dashscope-byok.js +97 -89
- package/src/providers/dashscope-byok.ts +114 -0
- package/src/providers/deepseek.js +73 -72
- package/src/providers/deepseek.ts +99 -0
- package/src/providers/factory.js +35 -28
- package/src/providers/factory.ts +40 -0
- package/src/providers/gemini.js +227 -278
- package/src/providers/gemini.ts +261 -0
- package/src/providers/loopGuard.js +9 -5
- package/src/providers/loopGuard.ts +10 -5
- package/src/providers/moonshot.js +70 -72
- package/src/providers/moonshot.ts +93 -0
- package/src/providers/muse.js +82 -152
- package/src/providers/muse.ts +122 -0
- package/src/providers/ollama.js +114 -106
- package/src/providers/ollama.ts +135 -0
- package/src/providers/openai-compatible.js +113 -96
- package/src/providers/openai-compatible.ts +139 -0
- package/src/providers/openai.js +22 -15
- package/src/providers/openai.ts +30 -0
- package/src/providers/openrouter.js +136 -74
- package/src/providers/openrouter.ts +133 -72
- package/src/providers/pi.js +6 -0
- package/src/providers/pi.ts +6 -0
- package/src/providers/qwen-byok.js +96 -87
- package/src/providers/qwen-byok.ts +113 -0
- package/src/providers/toolContracts.js +40 -14
- package/src/providers/toolContracts.ts +35 -14
- package/src/providers/wireNormalizer.js +78 -11
- package/src/providers/wireNormalizer.ts +68 -12
- package/src/providers/xai.js +73 -72
- package/src/providers/xai.ts +97 -0
- package/src/reliability/assetEvidence.js +4 -2
- package/src/reliability/assetEvidence.ts +4 -2
- package/src/sandbox.js +489 -554
- package/src/sandbox.ts +552 -0
- package/src/sandboxPolicy.js +95 -16
- package/src/sandboxPolicy.ts +97 -16
- package/src/sessionJournal.js +8 -3
- package/src/sessionJournal.ts +9 -3
- package/src/skills/skillResourceSafety.js +19 -8
- package/src/skills/skillResourceSafety.ts +16 -7
- package/src/skillsManager.js +3 -3
- package/src/skillsManager.ts +3 -3
- package/src/smartToolsUse.js +28 -4
- package/src/smartToolsUse.ts +29 -7
- package/src/stallGuard.js +45 -22
- package/src/stallGuard.ts +46 -22
- package/src/subagentJournal.js +6 -4
- package/src/subagentJournal.ts +6 -4
- package/src/textDiff.js +6 -1
- package/src/textDiff.ts +6 -1
- package/src/timeMachine.js +7 -1
- package/src/timeMachine.ts +7 -1
- package/src/tokenTracker.js +43 -28
- package/src/tokenTracker.ts +44 -30
- package/src/toolPacks.js +3 -1
- package/src/toolPacks.ts +3 -1
- package/src/tools/archive.js +245 -35
- package/src/tools/archive.ts +244 -35
- package/src/tools/computerUse.js +7 -3
- package/src/tools/computerUse.ts +7 -3
- package/src/tools/creativeApps.js +13 -8
- package/src/tools/creativeApps.ts +22 -9
- package/src/tools/deferredMcpSearch.js +26 -14
- package/src/tools/deferredMcpSearch.ts +26 -14
- package/src/tools/desktopOpen.js +69 -10
- package/src/tools/desktopOpen.ts +70 -11
- package/src/tools/documentForge.js +167 -82
- package/src/tools/documentForge.ts +169 -84
- package/src/tools/fsEdit.js +101 -30
- package/src/tools/fsEdit.ts +105 -32
- package/src/tools/fsFind.js +8 -5
- package/src/tools/fsFind.ts +7 -4
- package/src/tools/fsRead.js +119 -13
- package/src/tools/fsRead.ts +124 -13
- package/src/tools/fsWrite.js +17 -5
- package/src/tools/fsWrite.ts +17 -7
- package/src/tools/generateMediaViaApi.js +82 -19
- package/src/tools/generateMediaViaApi.ts +80 -19
- package/src/tools/memoryRecall.js +62 -11
- package/src/tools/memoryRecall.ts +70 -13
- package/src/tools/memoryWrite.js +27 -14
- package/src/tools/memoryWrite.ts +30 -14
- package/src/tools/multiEdit.js +100 -30
- package/src/tools/multiEdit.ts +104 -32
- package/src/tools/nativeEngine.js +33 -18
- package/src/tools/nativeEngine.ts +31 -18
- package/src/tools/openSourceToolProvisioner.js +49 -14
- package/src/tools/openSourceToolProvisioner.ts +54 -15
- package/src/tools/osSandbox.js +54 -14
- package/src/tools/osSandbox.ts +48 -14
- package/src/tools/payloadSanitizer.js +40 -8
- package/src/tools/payloadSanitizer.ts +39 -8
- package/src/tools/peerAgent.js +96 -34
- package/src/tools/peerAgent.ts +114 -37
- package/src/tools/pluginsFactory.js +38 -6
- package/src/tools/pluginsFactory.ts +42 -6
- package/src/tools/readNativeSkill.js +10 -8
- package/src/tools/readNativeSkill.ts +10 -8
- package/src/tools/requestDecision.js +10 -3
- package/src/tools/requestDecision.ts +10 -3
- package/src/tools/resolveAutomator.js +91 -17
- package/src/tools/resolveAutomator.ts +102 -17
- package/src/tools/reverseEngineering.js +168 -41
- package/src/tools/reverseEngineering.ts +161 -41
- package/src/tools/sysRun.js +69 -29
- package/src/tools/sysRun.ts +66 -24
- package/src/tools/toolDispatch.js +24 -1
- package/src/tools/toolDispatch.ts +21 -1
- package/src/tools/toolOutputStore.js +62 -23
- package/src/tools/toolOutputStore.ts +56 -23
- package/src/tools/toolScanner.js +13 -10
- package/src/tools/toolScanner.ts +13 -10
- package/src/tools/toolSelfRepair.js +94 -28
- package/src/tools/toolSelfRepair.ts +96 -28
- package/src/tools/uiForge.js +71 -6
- package/src/tools/uiForge.ts +74 -6
- package/src/tools/viewImage.js +62 -17
- package/src/tools/viewImage.ts +57 -12
- package/src/tools/visionInspector.js +15 -3
- package/src/tools/visionInspector.ts +15 -3
- package/src/tools/walkerSafety.js +2 -0
- package/src/tools/walkerSafety.ts +1 -0
- package/src/tools/webFetch.js +105 -10
- package/src/tools/webFetch.ts +105 -11
- package/src/tui/banner.js +3 -2
- package/src/tui/banner.ts +3 -2
- package/src/tui/consoleGuard.js +12 -4
- package/src/tui/consoleGuard.ts +9 -4
- package/src/tui/messageInteraction.js +2 -3
- package/src/tui/messageInteraction.ts +2 -3
- package/src/tui/modelPicker.js +1 -0
- package/src/tui/modelPicker.ts +1 -0
- package/src/tui/overlay.js +3 -1
- package/src/tui/overlay.ts +3 -1
- package/src/tui/sessionPicker.js +3 -2
- package/src/tui/sessionPicker.ts +3 -2
- package/src/tui/sessionPickerView.js +7 -1
- package/src/tui/sessionPickerView.ts +6 -1
- package/src/tui/toolOutputNormalizer.js +2 -3
- package/src/tui/toolOutputNormalizer.ts +4 -3
- package/src/tui/viewport.js +4 -4
- package/src/tui/viewport.ts +5 -5
- package/src/tui/workspaceIdentity.js +2 -1
- package/src/tui/workspaceIdentity.ts +2 -1
- package/src/uncertainty.js +8 -3
- package/src/uncertainty.ts +8 -3
- package/src/utils/paths.js +8 -5
- package/src/utils/paths.ts +9 -7
- package/src/vfeTracker.js +9 -3
- package/src/vfeTracker.ts +9 -3
- package/src/config.d.ts +0 -2
- package/src/providers/base.d.ts +0 -94
- package/src/providers/factory.d.ts +0 -1
- package/src/sandbox.d.ts +0 -1
|
@@ -183,8 +183,13 @@ def scriptapp(name):
|
|
|
183
183
|
return _MockResolveApp()
|
|
184
184
|
return None
|
|
185
185
|
`;
|
|
186
|
+
const MAX_RESOLVE_STDIO_CHARS = 2 * 1024 * 1024;
|
|
187
|
+
const DEFAULT_RESOLVE_TIMEOUT_MS = 60_000;
|
|
186
188
|
export async function runResolveBridge(args, options = {}) {
|
|
187
|
-
const simulate =
|
|
189
|
+
const simulate = options.simulate === true || args.simulate === true || process.env.CAUSYNE_SIMULATE_RESOLVE === '1';
|
|
190
|
+
const timeoutMs = typeof options.timeoutMs === 'number' && Number.isFinite(options.timeoutMs) && options.timeoutMs > 0
|
|
191
|
+
? Math.floor(options.timeoutMs)
|
|
192
|
+
: DEFAULT_RESOLVE_TIMEOUT_MS;
|
|
188
193
|
let tempMockDir = null;
|
|
189
194
|
try {
|
|
190
195
|
const extraDirs = [];
|
|
@@ -197,40 +202,80 @@ export async function runResolveBridge(args, options = {}) {
|
|
|
197
202
|
const payload = JSON.stringify(args);
|
|
198
203
|
const pyBin = os.platform() === 'win32' ? platformCfg.pythonBin : 'python3';
|
|
199
204
|
return await new Promise((resolvePromise) => {
|
|
200
|
-
|
|
205
|
+
if (options.signal?.aborted) {
|
|
206
|
+
resolvePromise({ success: false, error: 'DaVinci Resolve operation aborted.' });
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const child = spawn(pyBin, ['-', payload], { env: platformCfg.env, windowsHide: true });
|
|
201
210
|
let outputData = '';
|
|
202
211
|
let errorData = '';
|
|
212
|
+
let settled = false;
|
|
213
|
+
const finish = (result) => {
|
|
214
|
+
if (settled)
|
|
215
|
+
return;
|
|
216
|
+
settled = true;
|
|
217
|
+
clearTimeout(timer);
|
|
218
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
219
|
+
resolvePromise(result);
|
|
220
|
+
};
|
|
221
|
+
const onAbort = () => {
|
|
222
|
+
try {
|
|
223
|
+
child.kill('SIGKILL');
|
|
224
|
+
}
|
|
225
|
+
catch { /* ignore */ }
|
|
226
|
+
finish({ success: false, error: 'DaVinci Resolve operation aborted.' });
|
|
227
|
+
};
|
|
228
|
+
options.signal?.addEventListener('abort', onAbort, { once: true });
|
|
229
|
+
const timer = setTimeout(() => {
|
|
230
|
+
try {
|
|
231
|
+
child.kill('SIGKILL');
|
|
232
|
+
}
|
|
233
|
+
catch { /* ignore */ }
|
|
234
|
+
finish({ success: false, error: `DaVinci Resolve bridge timed out after ${timeoutMs}ms.` });
|
|
235
|
+
}, timeoutMs);
|
|
203
236
|
child.stdout.on('data', (data) => {
|
|
204
|
-
outputData
|
|
237
|
+
if (outputData.length < MAX_RESOLVE_STDIO_CHARS) {
|
|
238
|
+
outputData += data.toString().slice(0, MAX_RESOLVE_STDIO_CHARS - outputData.length);
|
|
239
|
+
}
|
|
205
240
|
});
|
|
206
241
|
child.stderr.on('data', (data) => {
|
|
207
|
-
errorData
|
|
242
|
+
if (errorData.length < MAX_RESOLVE_STDIO_CHARS) {
|
|
243
|
+
errorData += data.toString().slice(0, MAX_RESOLVE_STDIO_CHARS - errorData.length);
|
|
244
|
+
}
|
|
208
245
|
});
|
|
209
246
|
child.on('error', (err) => {
|
|
210
|
-
|
|
247
|
+
finish({
|
|
211
248
|
success: false,
|
|
212
249
|
error: `Failed to spawn Python interpreter (${pyBin}): ${err.message}`
|
|
213
250
|
});
|
|
214
251
|
});
|
|
215
252
|
child.on('close', (code) => {
|
|
216
253
|
if (outputData.trim()) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
if (
|
|
221
|
-
|
|
222
|
-
|
|
254
|
+
const lines = outputData.trim().split('\n');
|
|
255
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
256
|
+
const candidate = lines[i]?.trim() || '';
|
|
257
|
+
if (!candidate.startsWith('{') || !candidate.endsWith('}'))
|
|
258
|
+
continue;
|
|
259
|
+
try {
|
|
260
|
+
const parsed = JSON.parse(candidate);
|
|
261
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
262
|
+
finish(parsed);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
continue;
|
|
223
268
|
}
|
|
224
|
-
}
|
|
225
|
-
catch {
|
|
226
|
-
// Fall through to error return
|
|
227
269
|
}
|
|
228
270
|
}
|
|
229
|
-
|
|
271
|
+
finish({
|
|
230
272
|
success: false,
|
|
231
273
|
error: errorData.trim() || outputData.trim() || `Python process exited with code ${String(code)}`
|
|
232
274
|
});
|
|
233
275
|
});
|
|
276
|
+
child.stdin.on('error', () => {
|
|
277
|
+
// Ignore EPIPE when Python fails to spawn or exits before reading stdin
|
|
278
|
+
});
|
|
234
279
|
child.stdin.write(PYTHON_SCRIPT);
|
|
235
280
|
child.stdin.end();
|
|
236
281
|
});
|
|
@@ -360,10 +405,39 @@ export const resolveAutomator = {
|
|
|
360
405
|
required: ['action']
|
|
361
406
|
}
|
|
362
407
|
},
|
|
363
|
-
async execute(args) {
|
|
408
|
+
async execute(args, context) {
|
|
364
409
|
if (!args || typeof args !== 'object' || Array.isArray(args)) {
|
|
365
410
|
return { success: false, error: 'Expected DaVinci Resolve action arguments' };
|
|
366
411
|
}
|
|
367
|
-
|
|
412
|
+
const normalized = { ...args };
|
|
413
|
+
if (typeof normalized.customName === 'string') {
|
|
414
|
+
const cname = normalized.customName.trim();
|
|
415
|
+
if (/[/\\]/.test(cname) || cname === '..' || cname.includes('..') || /[\x00-\x1f\x7f]/.test(cname)) {
|
|
416
|
+
return { success: false, error: `Invalid customName "${normalized.customName}": must be a plain filename without path traversal.` };
|
|
417
|
+
}
|
|
418
|
+
normalized.customName = cname;
|
|
419
|
+
}
|
|
420
|
+
const workspaceRoot = context?.parentLoop?.workspaceRoot
|
|
421
|
+
|| context?.workspaceRoot
|
|
422
|
+
|| context?.workspacePaths?.find((p) => typeof p === 'string' && p.trim().length > 0)
|
|
423
|
+
|| process.cwd();
|
|
424
|
+
const policy = context?.parentLoop?.sandbox ?? context;
|
|
425
|
+
for (const pathKey of ['targetDir', 'mediaPath', 'lutPath']) {
|
|
426
|
+
const rawVal = normalized[pathKey];
|
|
427
|
+
if (typeof rawVal === 'string' && rawVal.trim()) {
|
|
428
|
+
const trimmed = rawVal.trim();
|
|
429
|
+
const expanded = trimmed === '~'
|
|
430
|
+
? os.homedir()
|
|
431
|
+
: (trimmed.startsWith('~/') || trimmed.startsWith('~\\'))
|
|
432
|
+
? path.join(os.homedir(), trimmed.slice(2))
|
|
433
|
+
: trimmed;
|
|
434
|
+
const resolved = path.isAbsolute(expanded) ? path.resolve(expanded) : path.resolve(workspaceRoot, expanded);
|
|
435
|
+
if (context?.grantAllAccess !== true && typeof policy?.isPathAllowed === 'function' && !policy.isPathAllowed(resolved)) {
|
|
436
|
+
return { success: false, error: `${pathKey} resolves outside allowed workspace: ${resolved}` };
|
|
437
|
+
}
|
|
438
|
+
normalized[pathKey] = resolved;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return await runResolveBridge(normalized, { signal: context?.signal });
|
|
368
442
|
}
|
|
369
443
|
};
|
|
@@ -204,11 +204,22 @@ def scriptapp(name):
|
|
|
204
204
|
return None
|
|
205
205
|
`;
|
|
206
206
|
|
|
207
|
+
const MAX_RESOLVE_STDIO_CHARS = 2 * 1024 * 1024;
|
|
208
|
+
const DEFAULT_RESOLVE_TIMEOUT_MS = 60_000;
|
|
209
|
+
|
|
207
210
|
export async function runResolveBridge(
|
|
208
211
|
args: Record<string, unknown>,
|
|
209
|
-
options: {
|
|
212
|
+
options: {
|
|
213
|
+
simulate?: boolean | undefined;
|
|
214
|
+
platform?: NodeJS.Platform | undefined;
|
|
215
|
+
timeoutMs?: number | undefined;
|
|
216
|
+
signal?: AbortSignal | undefined;
|
|
217
|
+
} = {}
|
|
210
218
|
): Promise<Record<string, unknown>> {
|
|
211
|
-
const simulate =
|
|
219
|
+
const simulate = options.simulate === true || args.simulate === true || process.env.CAUSYNE_SIMULATE_RESOLVE === '1';
|
|
220
|
+
const timeoutMs = typeof options.timeoutMs === 'number' && Number.isFinite(options.timeoutMs) && options.timeoutMs > 0
|
|
221
|
+
? Math.floor(options.timeoutMs)
|
|
222
|
+
: DEFAULT_RESOLVE_TIMEOUT_MS;
|
|
212
223
|
let tempMockDir: string | null = null;
|
|
213
224
|
|
|
214
225
|
try {
|
|
@@ -224,21 +235,49 @@ export async function runResolveBridge(
|
|
|
224
235
|
const pyBin = os.platform() === 'win32' ? platformCfg.pythonBin : 'python3';
|
|
225
236
|
|
|
226
237
|
return await new Promise<Record<string, unknown>>((resolvePromise) => {
|
|
227
|
-
|
|
238
|
+
if (options.signal?.aborted) {
|
|
239
|
+
resolvePromise({ success: false, error: 'DaVinci Resolve operation aborted.' });
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const child = spawn(pyBin, ['-', payload], { env: platformCfg.env, windowsHide: true });
|
|
228
243
|
|
|
229
244
|
let outputData = '';
|
|
230
245
|
let errorData = '';
|
|
246
|
+
let settled = false;
|
|
247
|
+
|
|
248
|
+
const finish = (result: Record<string, unknown>): void => {
|
|
249
|
+
if (settled) return;
|
|
250
|
+
settled = true;
|
|
251
|
+
clearTimeout(timer);
|
|
252
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
253
|
+
resolvePromise(result);
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const onAbort = (): void => {
|
|
257
|
+
try { child.kill('SIGKILL'); } catch { /* ignore */ }
|
|
258
|
+
finish({ success: false, error: 'DaVinci Resolve operation aborted.' });
|
|
259
|
+
};
|
|
260
|
+
options.signal?.addEventListener('abort', onAbort, { once: true });
|
|
261
|
+
|
|
262
|
+
const timer = setTimeout(() => {
|
|
263
|
+
try { child.kill('SIGKILL'); } catch { /* ignore */ }
|
|
264
|
+
finish({ success: false, error: `DaVinci Resolve bridge timed out after ${timeoutMs}ms.` });
|
|
265
|
+
}, timeoutMs);
|
|
231
266
|
|
|
232
267
|
child.stdout.on('data', (data: Buffer) => {
|
|
233
|
-
outputData
|
|
268
|
+
if (outputData.length < MAX_RESOLVE_STDIO_CHARS) {
|
|
269
|
+
outputData += data.toString().slice(0, MAX_RESOLVE_STDIO_CHARS - outputData.length);
|
|
270
|
+
}
|
|
234
271
|
});
|
|
235
272
|
|
|
236
273
|
child.stderr.on('data', (data: Buffer) => {
|
|
237
|
-
errorData
|
|
274
|
+
if (errorData.length < MAX_RESOLVE_STDIO_CHARS) {
|
|
275
|
+
errorData += data.toString().slice(0, MAX_RESOLVE_STDIO_CHARS - errorData.length);
|
|
276
|
+
}
|
|
238
277
|
});
|
|
239
278
|
|
|
240
279
|
child.on('error', (err: Error) => {
|
|
241
|
-
|
|
280
|
+
finish({
|
|
242
281
|
success: false,
|
|
243
282
|
error: `Failed to spawn Python interpreter (${pyBin}): ${err.message}`
|
|
244
283
|
});
|
|
@@ -246,23 +285,30 @@ export async function runResolveBridge(
|
|
|
246
285
|
|
|
247
286
|
child.on('close', (code: number | null) => {
|
|
248
287
|
if (outputData.trim()) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const
|
|
252
|
-
if (
|
|
253
|
-
|
|
254
|
-
|
|
288
|
+
const lines = outputData.trim().split('\n');
|
|
289
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
290
|
+
const candidate = lines[i]?.trim() || '';
|
|
291
|
+
if (!candidate.startsWith('{') || !candidate.endsWith('}')) continue;
|
|
292
|
+
try {
|
|
293
|
+
const parsed: unknown = JSON.parse(candidate);
|
|
294
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
295
|
+
finish(parsed as Record<string, unknown>);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
} catch {
|
|
299
|
+
continue;
|
|
255
300
|
}
|
|
256
|
-
} catch {
|
|
257
|
-
// Fall through to error return
|
|
258
301
|
}
|
|
259
302
|
}
|
|
260
|
-
|
|
303
|
+
finish({
|
|
261
304
|
success: false,
|
|
262
305
|
error: errorData.trim() || outputData.trim() || `Python process exited with code ${String(code)}`
|
|
263
306
|
});
|
|
264
307
|
});
|
|
265
308
|
|
|
309
|
+
child.stdin.on('error', () => {
|
|
310
|
+
// Ignore EPIPE when Python fails to spawn or exits before reading stdin
|
|
311
|
+
});
|
|
266
312
|
child.stdin.write(PYTHON_SCRIPT);
|
|
267
313
|
child.stdin.end();
|
|
268
314
|
});
|
|
@@ -393,11 +439,50 @@ export const resolveAutomator = {
|
|
|
393
439
|
required: ['action']
|
|
394
440
|
}
|
|
395
441
|
},
|
|
396
|
-
async execute(
|
|
442
|
+
async execute(
|
|
443
|
+
args: unknown,
|
|
444
|
+
context?: {
|
|
445
|
+
signal?: AbortSignal;
|
|
446
|
+
workspaceRoot?: string;
|
|
447
|
+
workspacePaths?: string[];
|
|
448
|
+
grantAllAccess?: boolean;
|
|
449
|
+
isPathAllowed?: (p: string) => boolean;
|
|
450
|
+
parentLoop?: { workspaceRoot?: string; sandbox?: { isPathAllowed?: (p: string) => boolean } };
|
|
451
|
+
}
|
|
452
|
+
) {
|
|
397
453
|
if (!args || typeof args !== 'object' || Array.isArray(args)) {
|
|
398
454
|
return { success: false, error: 'Expected DaVinci Resolve action arguments' };
|
|
399
455
|
}
|
|
400
|
-
|
|
456
|
+
const normalized: Record<string, unknown> = { ...(args as Record<string, unknown>) };
|
|
457
|
+
if (typeof normalized.customName === 'string') {
|
|
458
|
+
const cname = normalized.customName.trim();
|
|
459
|
+
if (/[/\\]/.test(cname) || cname === '..' || cname.includes('..') || /[\x00-\x1f\x7f]/.test(cname)) {
|
|
460
|
+
return { success: false, error: `Invalid customName "${normalized.customName}": must be a plain filename without path traversal.` };
|
|
461
|
+
}
|
|
462
|
+
normalized.customName = cname;
|
|
463
|
+
}
|
|
464
|
+
const workspaceRoot = context?.parentLoop?.workspaceRoot
|
|
465
|
+
|| context?.workspaceRoot
|
|
466
|
+
|| context?.workspacePaths?.find((p): p is string => typeof p === 'string' && p.trim().length > 0)
|
|
467
|
+
|| process.cwd();
|
|
468
|
+
const policy = context?.parentLoop?.sandbox ?? context;
|
|
469
|
+
for (const pathKey of ['targetDir', 'mediaPath', 'lutPath'] as const) {
|
|
470
|
+
const rawVal = normalized[pathKey];
|
|
471
|
+
if (typeof rawVal === 'string' && rawVal.trim()) {
|
|
472
|
+
const trimmed = rawVal.trim();
|
|
473
|
+
const expanded = trimmed === '~'
|
|
474
|
+
? os.homedir()
|
|
475
|
+
: (trimmed.startsWith('~/') || trimmed.startsWith('~\\'))
|
|
476
|
+
? path.join(os.homedir(), trimmed.slice(2))
|
|
477
|
+
: trimmed;
|
|
478
|
+
const resolved = path.isAbsolute(expanded) ? path.resolve(expanded) : path.resolve(workspaceRoot, expanded);
|
|
479
|
+
if (context?.grantAllAccess !== true && typeof policy?.isPathAllowed === 'function' && !policy.isPathAllowed(resolved)) {
|
|
480
|
+
return { success: false, error: `${pathKey} resolves outside allowed workspace: ${resolved}` };
|
|
481
|
+
}
|
|
482
|
+
normalized[pathKey] = resolved;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return await runResolveBridge(normalized, { signal: context?.signal });
|
|
401
486
|
}
|
|
402
487
|
};
|
|
403
488
|
|