@causyne/agent 1.20.9 → 1.20.11
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/package.json +2 -1
- package/src/agentLoop.js +127 -72
- package/src/agentLoop.ts +137 -75
- package/src/browser/causyneBrowser.js +36 -0
- package/src/browser/causyneBrowser.ts +36 -1
- package/src/commands.js +25 -0
- package/src/contextManager.js +16 -0
- package/src/providers/antigravity.js +63 -11
- package/src/providers/antigravity.ts +62 -12
- package/src/provisioning/capabilityProvisioner.js +2 -7
- package/src/provisioning/npmInstall.js +19 -0
- package/src/provisioning/npmInstall.ts +19 -0
- package/src/smartToolsUse.js +20 -0
- package/src/smartToolsUse.ts +21 -0
- package/src/stallGuard.js +347 -0
- package/src/stallGuard.ts +423 -0
- package/src/tools/browserAutomator.js +3 -3
- package/src/tools/browserAutomator.ts +3 -3
- package/src/tools/fsRead.js +91 -80
- package/src/tools/fsRead.ts +125 -0
- package/src/tools/peerAgent.js +1 -1
- package/src/tools/peerAgent.ts +1 -1
- package/src/tools/screenshot.js +5 -1
- package/src/tools/screenshot.ts +5 -1
- package/src/tools/toolScanner.js +19 -0
- package/src/tools/toolScanner.ts +17 -0
- package/src/tools/toolSelfRepair.js +63 -1
- package/src/tools/toolSelfRepair.ts +61 -1
- package/src/tools/visionInspector.js +80 -142
- package/src/tools/visionInspector.ts +110 -0
- package/src/tui/chatboxClipboard.js +152 -0
- package/src/tui/chatboxClipboard.ts +201 -0
- package/src/tui/clipboardSync.js +38 -7
- package/src/tui/clipboardSync.ts +39 -7
- package/src/tui/codeProgress.js +89 -18
- package/src/tui/codeProgress.ts +102 -17
- package/src/tui/codeStreamRenderer.js +7 -2
- package/src/tui/codeStreamRenderer.ts +7 -2
- package/src/tui/composerControls.js +9 -0
- package/src/tui/composerControls.ts +9 -0
- package/src/tui/dialogs.js +8 -3
- package/src/tui/diff.d.ts +1 -0
- package/src/tui/lineEditor.js +166 -14
- package/src/tui/mouseHover.js +6 -2
- package/src/tui/mouseHover.ts +7 -2
- package/src/tui/prompt.js +96 -19
- package/src/tui/stageSurface.js +3 -1
|
@@ -2,6 +2,7 @@ import { spawn } from 'node:child_process';
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { isLaunchOnlyPrompt } from '../launchIntent.js';
|
|
5
|
+
import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
|
|
5
6
|
import { LLMProvider } from './base.js';
|
|
6
7
|
/**
|
|
7
8
|
* Baseline fallback models for instant offline availability.
|
|
@@ -272,6 +273,21 @@ function describeNativeAction(toolInfo) {
|
|
|
272
273
|
}
|
|
273
274
|
return undefined;
|
|
274
275
|
}
|
|
276
|
+
export function isReadOnlyNativeInspection(name, parameters) {
|
|
277
|
+
const action = name.toLowerCase().replace(/[_\s-]/g, '');
|
|
278
|
+
if (/^(readfile|listdirectory|listfiles|search|searchweb|grep|findfiles)$/.test(action))
|
|
279
|
+
return true;
|
|
280
|
+
if (!/^(runcommand|command|sysrun|terminal|bash|shell)$/.test(action))
|
|
281
|
+
return false;
|
|
282
|
+
const command = String(parameters.CommandLine ?? parameters.command ?? parameters.cmd ?? '').trim();
|
|
283
|
+
// A compound shell command can inspect and then mutate; do not count it as
|
|
284
|
+
// read-only merely because its first command is a probe.
|
|
285
|
+
if (!/[;&|]/.test(command) && /^(?:ls|rg|grep|head|tail|cat|ps|pgrep|which|file|sips|mdls)\b/.test(command))
|
|
286
|
+
return true;
|
|
287
|
+
return /\bblender\b.*--python-expr\b/is.test(command)
|
|
288
|
+
&& /\bprint\s*\(/.test(command)
|
|
289
|
+
&& !/\b(?:save_as_mainfile|save|render|write|unlink|remove|delete)\b/.test(command);
|
|
290
|
+
}
|
|
275
291
|
export function mapNativeToolToCausyne(name, rawParams, index) {
|
|
276
292
|
if (!name || typeof name !== 'string')
|
|
277
293
|
return null;
|
|
@@ -498,7 +514,10 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
498
514
|
this.printTimeout = typeof config.printTimeout === 'string' && config.printTimeout.trim()
|
|
499
515
|
? config.printTimeout.trim()
|
|
500
516
|
: '1800s';
|
|
501
|
-
|
|
517
|
+
// This ACP bridge currently sends text-only stream-json messages. Image
|
|
518
|
+
// blocks are reduced to labels in formatDelta/formatConversation, so do
|
|
519
|
+
// not advertise vision or ask for desktop capture as proof of inspection.
|
|
520
|
+
this.visionModels = [];
|
|
502
521
|
this.audioModels = [];
|
|
503
522
|
}
|
|
504
523
|
formatDelta(messages) {
|
|
@@ -561,16 +580,21 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
561
580
|
' - Immediately open the URL or project in the user\'s browser using desktop.open with {"target": "http://localhost:<port>"} or run the native open command.\n' +
|
|
562
581
|
' - Confirm the application is accessible only after a readiness check succeeds.\n' +
|
|
563
582
|
'3. NEVER reply with conversational pleasantries, canned greetings (e.g. "How can I help you today?"), or ask what the user wants when an instruction has already been provided.\n' +
|
|
564
|
-
'4. Create or edit files only when the current user request authorizes it.\n
|
|
583
|
+
'4. Create or edit files only when the current user request authorizes it.\n' +
|
|
584
|
+
'5. TOKEN CONSERVATION & MEDIA DIRECTIVE:\n' +
|
|
585
|
+
' - NEVER attempt to read binary or media files (.png, .jpg, .blend, .glb, .wasm, .zip, etc.) using text reading tools like read_file or cat. This blows up the token context.\n' +
|
|
586
|
+
' - For 3D modeling, Blender, or media tasks: write a single self-contained generator script and execute it in one batch. Avoid dozens of speculative CLI exploration commands.\n' +
|
|
587
|
+
' - Use a model-readable image channel for visual verification when available. This text-only bridge does not deliver screenshot pixels to you; a saved image or file metadata proves the file exists, not how it looks. Report visual verification as unavailable when no image channel is present.\n\n' +
|
|
565
588
|
'[Environment State & Idempotency Directive]\n' +
|
|
566
589
|
'Reuse relevant verified tool results from this session, and check uncertain prerequisites before relying on them.\n\n' +
|
|
567
590
|
'[Language & Communication Directive]\n' +
|
|
568
591
|
'Dynamically reflect and match the exact language used by the user in their prompt. Respond naturally in that same language. Never send conversational pleasantries or canned greetings.');
|
|
569
592
|
if (tools && tools.length > 0) {
|
|
570
|
-
const
|
|
571
|
-
|
|
572
|
-
const
|
|
573
|
-
const
|
|
593
|
+
const scanReport = scanAndAdaptToolsForProvider(tools, 'antigravity');
|
|
594
|
+
const toolSummaries = scanReport.adaptedTools.map((t) => {
|
|
595
|
+
const name = t.name || 'unknown';
|
|
596
|
+
const desc = t.description || '';
|
|
597
|
+
const params = t.parameters || {};
|
|
574
598
|
const paramKeys = Object.keys(params.properties || {}).join(', ');
|
|
575
599
|
return `- ${name}(${paramKeys}): ${desc}`;
|
|
576
600
|
}).join('\n');
|
|
@@ -852,8 +876,15 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
852
876
|
promptTokens: 0, completionTokens: 0, cachedPromptTokens: 0,
|
|
853
877
|
thinkingTokens: 0, measurement: 'provider_reported', cacheMeasurement: 'provider_reported'
|
|
854
878
|
};
|
|
855
|
-
|
|
856
|
-
|
|
879
|
+
// A headless peer can run many paid model steps before chat() returns.
|
|
880
|
+
// Keep a finite per-call ceiling even when the optional task budget is
|
|
881
|
+
// disabled. Users can set a lower task budget through the existing UI.
|
|
882
|
+
const remainingTaskBudget = Number(options.maxTokensThisCall);
|
|
883
|
+
const tokenLimit = Number.isFinite(remainingTaskBudget) && remainingTaskBudget > 0
|
|
884
|
+
? remainingTaskBudget
|
|
885
|
+
: (typeof options.tokenLimit === 'number' && options.tokenLimit > 0
|
|
886
|
+
? options.tokenLimit
|
|
887
|
+
: 100_000);
|
|
857
888
|
const wallTimer = desktopTask ? setTimeout(() => {
|
|
858
889
|
const error = new Error('Antigravity exceeded the 180-second desktop task limit. Outcome is unverified.');
|
|
859
890
|
error.code = 'AGY_DESKTOP_TASK_LIMIT';
|
|
@@ -872,6 +903,24 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
872
903
|
if (isSettled)
|
|
873
904
|
return;
|
|
874
905
|
isSettled = true;
|
|
906
|
+
// Failed native turns can have already consumed several model steps.
|
|
907
|
+
// Preserve their reported usage for the outer task ledger and prevent
|
|
908
|
+
// the provider from silently replaying a paid turn.
|
|
909
|
+
if (partialUsage.promptTokens + partialUsage.completionTokens > 0) {
|
|
910
|
+
Object.assign(err, { partialUsage: { ...partialUsage } });
|
|
911
|
+
if ((err.code === 'AGY_EXPLORATION_LOOP'
|
|
912
|
+
|| err.code === 'AGY_TOKEN_BUDGET') && this.currentConversationId) {
|
|
913
|
+
const prior = resumedConversationId === this.lastCumulativeUsage?.conversationId
|
|
914
|
+
? this.lastCumulativeUsage : null;
|
|
915
|
+
this.lastCumulativeUsage = {
|
|
916
|
+
conversationId: this.currentConversationId,
|
|
917
|
+
input: (prior?.input || 0) + partialUsage.promptTokens,
|
|
918
|
+
output: (prior?.output || 0) + partialUsage.completionTokens,
|
|
919
|
+
thinking: (prior?.thinking || 0) + (partialUsage.thinkingTokens || 0),
|
|
920
|
+
cacheRead: (prior?.cacheRead || 0) + (partialUsage.cachedPromptTokens || 0)
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
}
|
|
875
924
|
cleanup();
|
|
876
925
|
reject(err);
|
|
877
926
|
};
|
|
@@ -938,9 +987,9 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
938
987
|
+ (Number(usage.cache_read_tokens) || 0);
|
|
939
988
|
partialUsage.thinkingTokens = (partialUsage.thinkingTokens || 0)
|
|
940
989
|
+ (Number(usage.thinking_tokens) || 0);
|
|
941
|
-
if (
|
|
942
|
-
|
|
943
|
-
const error = Object.assign(new Error(`Antigravity
|
|
990
|
+
if (Number.isFinite(tokenLimit) && tokenLimit > 0
|
|
991
|
+
&& partialUsage.promptTokens + partialUsage.completionTokens >= tokenLimit) {
|
|
992
|
+
const error = Object.assign(new Error(`Antigravity reported at least ${partialUsage.promptTokens + partialUsage.completionTokens} noncached tokens against a ${tokenLimit}-token per-call ceiling. This turn stopped and its outcome is unverified.`), { code: 'AGY_TOKEN_BUDGET', tokenLimit, partialUsage: { ...partialUsage } });
|
|
944
993
|
safeReject(error);
|
|
945
994
|
terminateChild();
|
|
946
995
|
return;
|
|
@@ -1233,6 +1282,9 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
1233
1282
|
if (options.signal?.aborted || err?.name === 'AbortError') {
|
|
1234
1283
|
throw err;
|
|
1235
1284
|
}
|
|
1285
|
+
if (err?.partialUsage?.promptTokens + err?.partialUsage?.completionTokens > 0) {
|
|
1286
|
+
throw err;
|
|
1287
|
+
}
|
|
1236
1288
|
const canRetryResetConversation = hadConversation && !this.currentConversationId
|
|
1237
1289
|
&& err?.code !== 'AGY_NATIVE_ACTION_DENIED'
|
|
1238
1290
|
&& err?.code !== 'AGY_TOKEN_BUDGET';
|
|
@@ -2,6 +2,7 @@ import { spawn } from 'node:child_process';
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { isLaunchOnlyPrompt } from '../launchIntent.js';
|
|
5
|
+
import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
|
|
5
6
|
import { LLMProvider, type ProviderConfig, type ChatOptions, type ChatResponse, type ChatResponseAction, type ChatResponseToolCall, type ChatResponseUsage } from './base.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -275,6 +276,19 @@ function describeNativeAction(toolInfo: any): string | undefined {
|
|
|
275
276
|
return undefined;
|
|
276
277
|
}
|
|
277
278
|
|
|
279
|
+
export function isReadOnlyNativeInspection(name: string, parameters: Record<string, unknown>): boolean {
|
|
280
|
+
const action = name.toLowerCase().replace(/[_\s-]/g, '');
|
|
281
|
+
if (/^(readfile|listdirectory|listfiles|search|searchweb|grep|findfiles)$/.test(action)) return true;
|
|
282
|
+
if (!/^(runcommand|command|sysrun|terminal|bash|shell)$/.test(action)) return false;
|
|
283
|
+
const command = String(parameters.CommandLine ?? parameters.command ?? parameters.cmd ?? '').trim();
|
|
284
|
+
// A compound shell command can inspect and then mutate; do not count it as
|
|
285
|
+
// read-only merely because its first command is a probe.
|
|
286
|
+
if (!/[;&|]/.test(command) && /^(?:ls|rg|grep|head|tail|cat|ps|pgrep|which|file|sips|mdls)\b/.test(command)) return true;
|
|
287
|
+
return /\bblender\b.*--python-expr\b/is.test(command)
|
|
288
|
+
&& /\bprint\s*\(/.test(command)
|
|
289
|
+
&& !/\b(?:save_as_mainfile|save|render|write|unlink|remove|delete)\b/.test(command);
|
|
290
|
+
}
|
|
291
|
+
|
|
278
292
|
export function mapNativeToolToCausyne(
|
|
279
293
|
name: string,
|
|
280
294
|
rawParams: Record<string, any>,
|
|
@@ -516,7 +530,10 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
516
530
|
this.printTimeout = typeof config.printTimeout === 'string' && config.printTimeout.trim()
|
|
517
531
|
? config.printTimeout.trim()
|
|
518
532
|
: '1800s';
|
|
519
|
-
|
|
533
|
+
// This ACP bridge currently sends text-only stream-json messages. Image
|
|
534
|
+
// blocks are reduced to labels in formatDelta/formatConversation, so do
|
|
535
|
+
// not advertise vision or ask for desktop capture as proof of inspection.
|
|
536
|
+
this.visionModels = [];
|
|
520
537
|
this.audioModels = [];
|
|
521
538
|
}
|
|
522
539
|
|
|
@@ -583,7 +600,11 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
583
600
|
' - Immediately open the URL or project in the user\'s browser using desktop.open with {"target": "http://localhost:<port>"} or run the native open command.\n' +
|
|
584
601
|
' - Confirm the application is accessible only after a readiness check succeeds.\n' +
|
|
585
602
|
'3. NEVER reply with conversational pleasantries, canned greetings (e.g. "How can I help you today?"), or ask what the user wants when an instruction has already been provided.\n' +
|
|
586
|
-
'4. Create or edit files only when the current user request authorizes it.\n
|
|
603
|
+
'4. Create or edit files only when the current user request authorizes it.\n' +
|
|
604
|
+
'5. TOKEN CONSERVATION & MEDIA DIRECTIVE:\n' +
|
|
605
|
+
' - NEVER attempt to read binary or media files (.png, .jpg, .blend, .glb, .wasm, .zip, etc.) using text reading tools like read_file or cat. This blows up the token context.\n' +
|
|
606
|
+
' - For 3D modeling, Blender, or media tasks: write a single self-contained generator script and execute it in one batch. Avoid dozens of speculative CLI exploration commands.\n' +
|
|
607
|
+
' - Use a model-readable image channel for visual verification when available. This text-only bridge does not deliver screenshot pixels to you; a saved image or file metadata proves the file exists, not how it looks. Report visual verification as unavailable when no image channel is present.\n\n' +
|
|
587
608
|
'[Environment State & Idempotency Directive]\n' +
|
|
588
609
|
'Reuse relevant verified tool results from this session, and check uncertain prerequisites before relying on them.\n\n' +
|
|
589
610
|
'[Language & Communication Directive]\n' +
|
|
@@ -591,10 +612,11 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
591
612
|
);
|
|
592
613
|
|
|
593
614
|
if (tools && tools.length > 0) {
|
|
594
|
-
const
|
|
595
|
-
|
|
596
|
-
const
|
|
597
|
-
const
|
|
615
|
+
const scanReport = scanAndAdaptToolsForProvider(tools, 'antigravity');
|
|
616
|
+
const toolSummaries = scanReport.adaptedTools.map((t: any) => {
|
|
617
|
+
const name = t.name || 'unknown';
|
|
618
|
+
const desc = t.description || '';
|
|
619
|
+
const params = t.parameters || {};
|
|
598
620
|
const paramKeys = Object.keys(params.properties || {}).join(', ');
|
|
599
621
|
return `- ${name}(${paramKeys}): ${desc}`;
|
|
600
622
|
}).join('\n');
|
|
@@ -892,8 +914,15 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
892
914
|
promptTokens: 0, completionTokens: 0, cachedPromptTokens: 0,
|
|
893
915
|
thinkingTokens: 0, measurement: 'provider_reported', cacheMeasurement: 'provider_reported'
|
|
894
916
|
};
|
|
895
|
-
|
|
896
|
-
|
|
917
|
+
// A headless peer can run many paid model steps before chat() returns.
|
|
918
|
+
// Keep a finite per-call ceiling even when the optional task budget is
|
|
919
|
+
// disabled. Users can set a lower task budget through the existing UI.
|
|
920
|
+
const remainingTaskBudget = Number(options.maxTokensThisCall);
|
|
921
|
+
const tokenLimit = Number.isFinite(remainingTaskBudget) && remainingTaskBudget > 0
|
|
922
|
+
? remainingTaskBudget
|
|
923
|
+
: (typeof (options as any).tokenLimit === 'number' && (options as any).tokenLimit > 0
|
|
924
|
+
? (options as any).tokenLimit
|
|
925
|
+
: 100_000);
|
|
897
926
|
const wallTimer = desktopTask ? setTimeout(() => {
|
|
898
927
|
const error = new Error('Antigravity exceeded the 180-second desktop task limit. Outcome is unverified.') as Error & { code: string };
|
|
899
928
|
error.code = 'AGY_DESKTOP_TASK_LIMIT';
|
|
@@ -912,6 +941,24 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
912
941
|
const safeReject = (err: Error) => {
|
|
913
942
|
if (isSettled) return;
|
|
914
943
|
isSettled = true;
|
|
944
|
+
// Failed native turns can have already consumed several model steps.
|
|
945
|
+
// Preserve their reported usage for the outer task ledger and prevent
|
|
946
|
+
// the provider from silently replaying a paid turn.
|
|
947
|
+
if (partialUsage.promptTokens + partialUsage.completionTokens > 0) {
|
|
948
|
+
Object.assign(err, { partialUsage: { ...partialUsage } });
|
|
949
|
+
if (((err as Error & { code?: string }).code === 'AGY_EXPLORATION_LOOP'
|
|
950
|
+
|| (err as Error & { code?: string }).code === 'AGY_TOKEN_BUDGET') && this.currentConversationId) {
|
|
951
|
+
const prior = resumedConversationId === this.lastCumulativeUsage?.conversationId
|
|
952
|
+
? this.lastCumulativeUsage : null;
|
|
953
|
+
this.lastCumulativeUsage = {
|
|
954
|
+
conversationId: this.currentConversationId,
|
|
955
|
+
input: (prior?.input || 0) + partialUsage.promptTokens,
|
|
956
|
+
output: (prior?.output || 0) + partialUsage.completionTokens,
|
|
957
|
+
thinking: (prior?.thinking || 0) + (partialUsage.thinkingTokens || 0),
|
|
958
|
+
cacheRead: (prior?.cacheRead || 0) + (partialUsage.cachedPromptTokens || 0)
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
}
|
|
915
962
|
cleanup();
|
|
916
963
|
reject(err);
|
|
917
964
|
};
|
|
@@ -981,11 +1028,11 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
981
1028
|
+ (Number(usage.cache_read_tokens) || 0);
|
|
982
1029
|
partialUsage.thinkingTokens = (partialUsage.thinkingTokens || 0)
|
|
983
1030
|
+ (Number(usage.thinking_tokens) || 0);
|
|
984
|
-
if (
|
|
985
|
-
|
|
1031
|
+
if (Number.isFinite(tokenLimit) && tokenLimit > 0
|
|
1032
|
+
&& partialUsage.promptTokens + partialUsage.completionTokens >= tokenLimit) {
|
|
986
1033
|
const error = Object.assign(
|
|
987
|
-
new Error(`Antigravity
|
|
988
|
-
{ code: 'AGY_TOKEN_BUDGET', partialUsage: { ...partialUsage } }
|
|
1034
|
+
new Error(`Antigravity reported at least ${partialUsage.promptTokens + partialUsage.completionTokens} noncached tokens against a ${tokenLimit}-token per-call ceiling. This turn stopped and its outcome is unverified.`),
|
|
1035
|
+
{ code: 'AGY_TOKEN_BUDGET', tokenLimit, partialUsage: { ...partialUsage } }
|
|
989
1036
|
);
|
|
990
1037
|
safeReject(error);
|
|
991
1038
|
terminateChild();
|
|
@@ -1291,6 +1338,9 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
1291
1338
|
if (options.signal?.aborted || err?.name === 'AbortError') {
|
|
1292
1339
|
throw err;
|
|
1293
1340
|
}
|
|
1341
|
+
if (err?.partialUsage?.promptTokens + err?.partialUsage?.completionTokens > 0) {
|
|
1342
|
+
throw err;
|
|
1343
|
+
}
|
|
1294
1344
|
const canRetryResetConversation =
|
|
1295
1345
|
hadConversation && !this.currentConversationId
|
|
1296
1346
|
&& (err as any)?.code !== 'AGY_NATIVE_ACTION_DENIED'
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { createRequire } from 'module';
|
|
6
|
-
import {
|
|
6
|
+
import { installCapabilityManifest } from './npmInstall.js';
|
|
7
7
|
import { pathToFileURL } from 'url';
|
|
8
8
|
import { loadConfig, saveConfig } from '../config.js';
|
|
9
9
|
import { isGroupGranted, isGroupDeclined } from './capabilityConsent.js';
|
|
@@ -169,12 +169,7 @@ export async function provisionCapabilities(groups = []) {
|
|
|
169
169
|
|
|
170
170
|
if (!needsInstall) return { installed: target, skipped: true };
|
|
171
171
|
|
|
172
|
-
|
|
173
|
-
execFileSync(
|
|
174
|
-
npm,
|
|
175
|
-
['install', '--ignore-scripts', '--no-fund'],
|
|
176
|
-
{ cwd: CAPABILITY_DIR, stdio: 'inherit' }
|
|
177
|
-
);
|
|
172
|
+
installCapabilityManifest(CAPABILITY_DIR);
|
|
178
173
|
return { installed: target, skipped: false };
|
|
179
174
|
}
|
|
180
175
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
/** Install optional capabilities without writing over the active terminal UI. */
|
|
3
|
+
export function installCapabilityManifest(directory) {
|
|
4
|
+
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
5
|
+
try {
|
|
6
|
+
execFileSync(npm, ['install', '--ignore-scripts', '--no-fund'], {
|
|
7
|
+
cwd: directory,
|
|
8
|
+
stdio: 'pipe',
|
|
9
|
+
encoding: 'utf8',
|
|
10
|
+
maxBuffer: 2 * 1024 * 1024,
|
|
11
|
+
timeout: 120_000,
|
|
12
|
+
windowsHide: true
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
17
|
+
throw new Error(`Capability installation failed: ${reason.slice(0, 600)}`, { cause: error });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
/** Install optional capabilities without writing over the active terminal UI. */
|
|
4
|
+
export function installCapabilityManifest(directory: string): void {
|
|
5
|
+
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
6
|
+
try {
|
|
7
|
+
execFileSync(npm, ['install', '--ignore-scripts', '--no-fund'], {
|
|
8
|
+
cwd: directory,
|
|
9
|
+
stdio: 'pipe',
|
|
10
|
+
encoding: 'utf8',
|
|
11
|
+
maxBuffer: 2 * 1024 * 1024,
|
|
12
|
+
timeout: 120_000,
|
|
13
|
+
windowsHide: true
|
|
14
|
+
});
|
|
15
|
+
} catch (error: unknown) {
|
|
16
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
17
|
+
throw new Error(`Capability installation failed: ${reason.slice(0, 600)}`, { cause: error });
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/smartToolsUse.js
CHANGED
|
@@ -110,6 +110,26 @@ export function determineToolScope(prompt, _taskShape) {
|
|
|
110
110
|
reason: 'Simple filesystem operation; suppresses external domain packs.'
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
+
// 5. Media / 3D generation & creative audio intent
|
|
114
|
+
if (EXPLICIT_MEDIA_GENERATION_PATTERN.test(text)) {
|
|
115
|
+
const tools = new Set([
|
|
116
|
+
'blender_act',
|
|
117
|
+
'creative_apps',
|
|
118
|
+
'execute_procedural_media',
|
|
119
|
+
'fs_read',
|
|
120
|
+
'fs_write',
|
|
121
|
+
'sysRun',
|
|
122
|
+
'view_image',
|
|
123
|
+
'update_plan',
|
|
124
|
+
'tool_search'
|
|
125
|
+
]);
|
|
126
|
+
return {
|
|
127
|
+
toolScope: tools,
|
|
128
|
+
archetype: 'media_3d_generation',
|
|
129
|
+
suppressedPacks: ['web', 'game', 'advanced', 'system'],
|
|
130
|
+
reason: 'Media generation intent prioritizes 3D studio, procedural media, and image inspection; suppresses web and game packs.'
|
|
131
|
+
};
|
|
132
|
+
}
|
|
113
133
|
// Default: unconstrained (standard progressive disclosure and packs apply)
|
|
114
134
|
return {
|
|
115
135
|
toolScope: null,
|
package/src/smartToolsUse.ts
CHANGED
|
@@ -151,6 +151,27 @@ export function determineToolScope(
|
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
// 5. Media / 3D generation & creative audio intent
|
|
155
|
+
if (EXPLICIT_MEDIA_GENERATION_PATTERN.test(text)) {
|
|
156
|
+
const tools = new Set([
|
|
157
|
+
'blender_act',
|
|
158
|
+
'creative_apps',
|
|
159
|
+
'execute_procedural_media',
|
|
160
|
+
'fs_read',
|
|
161
|
+
'fs_write',
|
|
162
|
+
'sysRun',
|
|
163
|
+
'view_image',
|
|
164
|
+
'update_plan',
|
|
165
|
+
'tool_search'
|
|
166
|
+
]);
|
|
167
|
+
return {
|
|
168
|
+
toolScope: tools,
|
|
169
|
+
archetype: 'media_3d_generation',
|
|
170
|
+
suppressedPacks: ['web', 'game', 'advanced', 'system'],
|
|
171
|
+
reason: 'Media generation intent prioritizes 3D studio, procedural media, and image inspection; suppresses web and game packs.'
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
154
175
|
// Default: unconstrained (standard progressive disclosure and packs apply)
|
|
155
176
|
return {
|
|
156
177
|
toolScope: null,
|