@causyne/agent 1.20.7 → 1.20.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/package.json +1 -1
  2. package/src/acp/agentCatalog.js +9 -3
  3. package/src/acp/agentCatalog.ts +20 -4
  4. package/src/agentLoop.js +167 -34
  5. package/src/agentLoop.ts +188 -37
  6. package/src/commands.js +25 -10
  7. package/src/compiledSkills.js +7330 -319
  8. package/src/computerUse/types.js +8 -0
  9. package/src/computerUse/types.ts +121 -0
  10. package/src/computerUse/visionGrounding.js +87 -29
  11. package/src/computerUse/visionGrounding.ts +108 -36
  12. package/src/decisionPolicy.js +7 -9
  13. package/src/decisionPolicy.ts +7 -9
  14. package/src/documentEngine/antiSlopAuditor.js +13 -43
  15. package/src/documentEngine/antiSlopAuditor.ts +15 -47
  16. package/src/documentEngine/documentForge.js +3 -3
  17. package/src/documentEngine/documentForge.ts +3 -3
  18. package/src/dynamicCatalogue.js +568 -77
  19. package/src/dynamicCatalogue.ts +608 -79
  20. package/src/launchIntent.js +3 -3
  21. package/src/launchIntent.ts +3 -3
  22. package/src/planCache.js +4 -14
  23. package/src/planCache.ts +4 -14
  24. package/src/providers/acp.js +39 -4
  25. package/src/providers/acp.ts +42 -4
  26. package/src/providers/antigravity.d.ts +7 -1
  27. package/src/providers/antigravity.js +222 -34
  28. package/src/providers/antigravity.ts +220 -33
  29. package/src/providers/base.d.ts +2 -0
  30. package/src/providers/pi.js +3 -1
  31. package/src/providers/pi.ts +4 -2
  32. package/src/sandbox.js +7 -10
  33. package/src/smartToolsUse.js +203 -0
  34. package/src/smartToolsUse.ts +263 -0
  35. package/src/taskShape.js +7 -7
  36. package/src/taskShape.ts +7 -7
  37. package/src/toolPacks.js +5 -5
  38. package/src/tools/blenderAutomator.js +198 -11
  39. package/src/tools/documentForge.js +1 -1
  40. package/src/tools/documentForge.ts +1 -1
  41. package/src/tui/modelPicker.js +288 -69
  42. package/src/tui/modelPicker.ts +333 -72
@@ -1,5 +1,5 @@
1
- const LAUNCH_VERBS = /\b(open|launch|start|run|play|serve|preview|buka|jalankan|mainkan|pratinjau)\b/i;
2
- const CHANGE_VERBS = /\b(create|build|make|write|edit|fix|modify|change|update|implement|generate|refactor|delete|remove|install|deploy|buat|bangun|tulis|ubah|perbaiki|hapus|pasang)\b/i;
1
+ const LAUNCH_VERBS = /\b(open|launch|start|run|play|serve|preview)\b/i;
2
+ const CHANGE_VERBS = /\b(create|build|make|write|edit|fix|modify|change|update|implement|generate|refactor|delete|remove|install|deploy)\b/i;
3
3
  const SERVER_COMMAND = /^\s*(?:python(?:3(?:\.\d+)?)?\s+(?:-u\s+)?(?:\S*\/)?server\.py\b|python(?:3(?:\.\d+)?)?\s+-m\s+http\.server\b|(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?(?:dev|start|serve)\b|(?:npx|bunx)\s+(?:vite|next\s+dev|http-server)\b|uvicorn\b|gunicorn\b|flask\s+run\b)/i;
4
4
  const READ_ONLY_COMMAND = /^\s*(?:pwd|ls|rg|grep|cat|head|tail|find|which|where|ps|pgrep|lsof|netstat|ss|git\s+(?:status|diff|log|show)|node\s+(?:-v|--version)|python(?:3(?:\.\d+)?)?\s+(?:-V|--version))\b/i;
5
5
  const OPEN_COMMAND = /^\s*(?:open|xdg-open|start)\s+\S+/i;
@@ -11,7 +11,7 @@ const MUTATION_TOOLS = new Set([
11
11
  'create_skill', 'manage_local_dependencies'
12
12
  ]);
13
13
  export function isLaunchOnlyPrompt(prompt) {
14
- if (/\b(?:run|jalankan)\s+(?:the\s+)?(?:tests?|checks?|lint|benchmarks?|scripts?|commands?)\b/i.test(prompt))
14
+ if (/\brun\s+(?:the\s+)?(?:tests?|checks?|lint|benchmarks?|scripts?|commands?)\b/i.test(prompt))
15
15
  return false;
16
16
  return LAUNCH_VERBS.test(prompt) && !CHANGE_VERBS.test(prompt);
17
17
  }
@@ -1,5 +1,5 @@
1
- const LAUNCH_VERBS = /\b(open|launch|start|run|play|serve|preview|buka|jalankan|mainkan|pratinjau)\b/i;
2
- const CHANGE_VERBS = /\b(create|build|make|write|edit|fix|modify|change|update|implement|generate|refactor|delete|remove|install|deploy|buat|bangun|tulis|ubah|perbaiki|hapus|pasang)\b/i;
1
+ const LAUNCH_VERBS = /\b(open|launch|start|run|play|serve|preview)\b/i;
2
+ const CHANGE_VERBS = /\b(create|build|make|write|edit|fix|modify|change|update|implement|generate|refactor|delete|remove|install|deploy)\b/i;
3
3
  const SERVER_COMMAND = /^\s*(?:python(?:3(?:\.\d+)?)?\s+(?:-u\s+)?(?:\S*\/)?server\.py\b|python(?:3(?:\.\d+)?)?\s+-m\s+http\.server\b|(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?(?:dev|start|serve)\b|(?:npx|bunx)\s+(?:vite|next\s+dev|http-server)\b|uvicorn\b|gunicorn\b|flask\s+run\b)/i;
4
4
  const READ_ONLY_COMMAND = /^\s*(?:pwd|ls|rg|grep|cat|head|tail|find|which|where|ps|pgrep|lsof|netstat|ss|git\s+(?:status|diff|log|show)|node\s+(?:-v|--version)|python(?:3(?:\.\d+)?)?\s+(?:-V|--version))\b/i;
5
5
  const OPEN_COMMAND = /^\s*(?:open|xdg-open|start)\s+\S+/i;
@@ -13,7 +13,7 @@ const MUTATION_TOOLS = new Set([
13
13
  ]);
14
14
 
15
15
  export function isLaunchOnlyPrompt(prompt: string): boolean {
16
- if (/\b(?:run|jalankan)\s+(?:the\s+)?(?:tests?|checks?|lint|benchmarks?|scripts?|commands?)\b/i.test(prompt)) return false;
16
+ if (/\brun\s+(?:the\s+)?(?:tests?|checks?|lint|benchmarks?|scripts?|commands?)\b/i.test(prompt)) return false;
17
17
  return LAUNCH_VERBS.test(prompt) && !CHANGE_VERBS.test(prompt);
18
18
  }
19
19
 
package/src/planCache.js CHANGED
@@ -77,22 +77,12 @@ const STOPWORDS = new Set([
77
77
  'with', 'from', 'into', 'then', 'this', 'that', 'it', 'its', 'as', 'by',
78
78
  'please', 'just', 'now', 'my', 'me', 'you', 'your', 'i',
79
79
  // Generic creation verbs. Every task has one, so they inflate the union
80
- // without discriminating between tasks — the exact shape that made
81
- // "buat pena 3D di Blender" and "bikin pulpen 3D di blender" score 0.40
82
- // when they describe the same job. `build`, `fix`, `debug` and `render` are
80
+ // without discriminating between tasks. `build`, `fix`, `debug` and `render` are
83
81
  // deliberately NOT here: those DO separate tasks inside one archetype.
84
- 'make', 'create', 'creating', 'made', 'generate',
85
- // Indonesian — the owner writes in both, and a mixed-language prompt must
86
- // key the same way whichever language framed it.
87
- 'dan', 'atau', 'yang', 'untuk', 'dari', 'ke', 'di', 'itu', 'ini', 'dengan',
88
- 'tolong', 'saya', 'aku', 'kamu', 'adalah', 'pada', 'juga', 'agar', 'jadi',
89
- 'buat', 'bikin', 'membuat', 'lalu', 'kemudian', 'terus', 'dulu', 'saja',
90
- 'sekarang', 'harus', 'bisa', 'sudah', 'belum', 'akan', 'mau', 'coba'
82
+ 'make', 'create', 'creating', 'made', 'generate'
91
83
  ]);
92
- // HONEST LIMIT. Matching is LEXICAL. A task cached in English and re-asked in
93
- // Indonesian (or the reverse) will miss, because Jaccard cannot know that
94
- // "pen" and "pena" are the same object. That is a deliberate trade: this path
95
- // is deterministic, instant, and works on a machine with no embedding model
84
+ // HONEST LIMIT. Matching is LEXICAL.
85
+ // This path is deterministic, instant, and works on a machine with no embedding model
96
86
  // provisioned. Cortex is the semantic route and already carries embeddings;
97
87
  // these two compose rather than compete.
98
88
  /**
package/src/planCache.ts CHANGED
@@ -203,23 +203,13 @@ const STOPWORDS: ReadonlySet<string> = new Set([
203
203
  'with', 'from', 'into', 'then', 'this', 'that', 'it', 'its', 'as', 'by',
204
204
  'please', 'just', 'now', 'my', 'me', 'you', 'your', 'i',
205
205
  // Generic creation verbs. Every task has one, so they inflate the union
206
- // without discriminating between tasks — the exact shape that made
207
- // "buat pena 3D di Blender" and "bikin pulpen 3D di blender" score 0.40
208
- // when they describe the same job. `build`, `fix`, `debug` and `render` are
206
+ // without discriminating between tasks. `build`, `fix`, `debug` and `render` are
209
207
  // deliberately NOT here: those DO separate tasks inside one archetype.
210
- 'make', 'create', 'creating', 'made', 'generate',
211
- // Indonesian — the owner writes in both, and a mixed-language prompt must
212
- // key the same way whichever language framed it.
213
- 'dan', 'atau', 'yang', 'untuk', 'dari', 'ke', 'di', 'itu', 'ini', 'dengan',
214
- 'tolong', 'saya', 'aku', 'kamu', 'adalah', 'pada', 'juga', 'agar', 'jadi',
215
- 'buat', 'bikin', 'membuat', 'lalu', 'kemudian', 'terus', 'dulu', 'saja',
216
- 'sekarang', 'harus', 'bisa', 'sudah', 'belum', 'akan', 'mau', 'coba'
208
+ 'make', 'create', 'creating', 'made', 'generate'
217
209
  ]);
218
210
 
219
- // HONEST LIMIT. Matching is LEXICAL. A task cached in English and re-asked in
220
- // Indonesian (or the reverse) will miss, because Jaccard cannot know that
221
- // "pen" and "pena" are the same object. That is a deliberate trade: this path
222
- // is deterministic, instant, and works on a machine with no embedding model
211
+ // HONEST LIMIT. Matching is LEXICAL.
212
+ // This path is deterministic, instant, and works on a machine with no embedding model
223
213
  // provisioned. Cortex is the semantic route and already carries embeddings;
224
214
  // these two compose rather than compete.
225
215
 
@@ -1,5 +1,6 @@
1
1
  import { canonicalModelId } from '../modelIds.js';
2
2
  import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
3
+ import { saveCachedModels } from '../dynamicCatalogue.js';
3
4
  import { LLMProvider } from './base.js';
4
5
  import { AcpClient } from '../acp/client.js';
5
6
  import { getPeerProfile } from '../acp/peerProfiles.js';
@@ -70,7 +71,7 @@ export class AcpProvider extends LLMProvider {
70
71
  }
71
72
  formatConversation(messages, tools = []) {
72
73
  const lines = [];
73
- lines.push('[System Instructions]\nYou are acting as an AI reasoning engine for Causyne Agent over ACP. Do NOT invoke your own internal host CLI tools or execute commands directly. When an action or tool is required, output an explicit tool call in this exact format:\n<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>\nCausyne Agent will execute the tool in its secure environment and return the results back to you.\n\n[Language & Communication Directive]\nDynamically reflect and match the exact language used by the user in their prompt. If the user writes in English, you must respond strictly in English. Default to English for all responses and reasoning. Never default to Indonesian.');
74
+ lines.push('[System Instructions]\nYou are acting as an AI reasoning engine for Causyne Agent over ACP. Do NOT invoke your own internal host CLI tools or execute commands directly. When an action or tool is required, output an explicit tool call in this exact format:\n<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>\nCausyne Agent will execute the tool in its secure environment and return the results back to you.\n\n[Language & Communication Directive]\nDynamically reflect and match the exact language used by the user in their prompt. Respond naturally in that same language.');
74
75
  if (tools && tools.length > 0) {
75
76
  const toolSummaries = tools.map(t => {
76
77
  const name = t.name || t.function?.name || 'unknown';
@@ -376,10 +377,31 @@ export class AcpProvider extends LLMProvider {
376
377
  });
377
378
  await client.start(signal);
378
379
  const sessionId = await client.newSession(process.cwd(), [], signal);
380
+ const sessionModels = client.getSessionModels(sessionId);
381
+ const liveModels = sessionModels.availableModels;
382
+ if (liveModels.length > 0 && !process.env.NODE_TEST_CONTEXT) {
383
+ saveCachedModels(`acp/${this.peerId}`, liveModels, {
384
+ ...(sessionModels.currentModelId ? { currentModel: sessionModels.currentModelId } : {})
385
+ });
386
+ }
379
387
  let targetModel = this.model;
380
- if (this.peerId === 'opencode' && targetModel !== this.peerId && !targetModel.startsWith('opencode/')) {
388
+ if (this.peerId === 'opencode' && targetModel !== this.peerId && !targetModel.includes('/')) {
381
389
  targetModel = `opencode/${targetModel}`;
382
390
  }
391
+ if (liveModels.length > 0 && targetModel && !liveModels.includes(targetModel)) {
392
+ const matched = liveModels.find((m) => m.toLowerCase() === targetModel.toLowerCase() || m.endsWith(`/${targetModel}`));
393
+ if (matched) {
394
+ targetModel = matched;
395
+ this.model = matched;
396
+ }
397
+ else {
398
+ const staticDefault = DEFAULT_MODEL_BY_PROVIDER[`acp/${this.peerId}`];
399
+ if (targetModel === staticDefault || targetModel === this.peerId || targetModel === 'acp') {
400
+ targetModel = sessionModels.currentModelId || liveModels[0];
401
+ this.model = targetModel;
402
+ }
403
+ }
404
+ }
383
405
  if (targetModel && targetModel !== 'acp' && targetModel !== this.peerId) {
384
406
  try {
385
407
  await client.setSessionModel(sessionId, targetModel, signal);
@@ -389,7 +411,18 @@ export class AcpProvider extends LLMProvider {
389
411
  await client.close();
390
412
  throw err;
391
413
  }
392
- // peer does not support setSessionModel
414
+ // If the requested model is unavailable on the user's current account/tier,
415
+ // gracefully fall back to the peer's active or first advertised live model.
416
+ const fallbackModel = sessionModels.currentModelId || liveModels[0];
417
+ if (fallbackModel && fallbackModel !== targetModel) {
418
+ this.model = fallbackModel;
419
+ try {
420
+ await client.setSessionModel(sessionId, fallbackModel, signal);
421
+ }
422
+ catch {
423
+ // Peer already defaults to its own active session model
424
+ }
425
+ }
393
426
  }
394
427
  }
395
428
  this.activeClient = client;
@@ -472,7 +505,9 @@ export class AcpProvider extends LLMProvider {
472
505
  usage: {
473
506
  promptTokens: Math.ceil(promptText.length / 4),
474
507
  completionTokens: Math.ceil(rawContent.length / 4),
475
- cachedPromptTokens: 0
508
+ cachedPromptTokens: 0,
509
+ measurement: 'text_estimate',
510
+ cacheMeasurement: 'unavailable'
476
511
  }
477
512
  };
478
513
  if (toolCalls.length > 0) {
@@ -1,5 +1,6 @@
1
1
  import { canonicalModelId } from '../modelIds.js';
2
2
  import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
3
+ import { saveCachedModels } from '../dynamicCatalogue.js';
3
4
  import { LLMProvider, type ProviderConfig, type ChatOptions, type ChatResponse, type ChatResponseToolCall, type ChatResponseAction } from './base.js';
4
5
  import { AcpClient } from '../acp/client.js';
5
6
  import { getPeerProfile } from '../acp/peerProfiles.js';
@@ -72,7 +73,7 @@ export class AcpProvider extends LLMProvider {
72
73
 
73
74
  formatConversation(messages: any[], tools: any[] = []): string {
74
75
  const lines: string[] = [];
75
- lines.push('[System Instructions]\nYou are acting as an AI reasoning engine for Causyne Agent over ACP. Do NOT invoke your own internal host CLI tools or execute commands directly. When an action or tool is required, output an explicit tool call in this exact format:\n<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>\nCausyne Agent will execute the tool in its secure environment and return the results back to you.\n\n[Language & Communication Directive]\nDynamically reflect and match the exact language used by the user in their prompt. If the user writes in English, you must respond strictly in English. Default to English for all responses and reasoning. Never default to Indonesian.');
76
+ lines.push('[System Instructions]\nYou are acting as an AI reasoning engine for Causyne Agent over ACP. Do NOT invoke your own internal host CLI tools or execute commands directly. When an action or tool is required, output an explicit tool call in this exact format:\n<tool_call>{"name": "tool_name", "arguments": { ... }}</tool_call>\nCausyne Agent will execute the tool in its secure environment and return the results back to you.\n\n[Language & Communication Directive]\nDynamically reflect and match the exact language used by the user in their prompt. Respond naturally in that same language.');
76
77
 
77
78
  if (tools && tools.length > 0) {
78
79
  const toolSummaries = tools.map(t => {
@@ -378,10 +379,35 @@ export class AcpProvider extends LLMProvider {
378
379
  await client.start(signal);
379
380
  const sessionId = await client.newSession(process.cwd(), [], signal);
380
381
 
382
+ const sessionModels = client.getSessionModels(sessionId);
383
+ const liveModels = sessionModels.availableModels;
384
+ if (liveModels.length > 0 && !process.env.NODE_TEST_CONTEXT) {
385
+ saveCachedModels(`acp/${this.peerId}`, liveModels, {
386
+ ...(sessionModels.currentModelId ? { currentModel: sessionModels.currentModelId } : {})
387
+ });
388
+ }
389
+
381
390
  let targetModel = this.model;
382
- if (this.peerId === 'opencode' && targetModel !== this.peerId && !targetModel.startsWith('opencode/')) {
391
+ if (this.peerId === 'opencode' && targetModel !== this.peerId && !targetModel.includes('/')) {
383
392
  targetModel = `opencode/${targetModel}`;
384
393
  }
394
+
395
+ if (liveModels.length > 0 && targetModel && !liveModels.includes(targetModel)) {
396
+ const matched = liveModels.find(
397
+ (m) => m.toLowerCase() === targetModel.toLowerCase() || m.endsWith(`/${targetModel}`)
398
+ );
399
+ if (matched) {
400
+ targetModel = matched;
401
+ this.model = matched;
402
+ } else {
403
+ const staticDefault = (DEFAULT_MODEL_BY_PROVIDER as Record<string, string>)[`acp/${this.peerId}`];
404
+ if (targetModel === staticDefault || targetModel === this.peerId || targetModel === 'acp') {
405
+ targetModel = sessionModels.currentModelId || liveModels[0]!;
406
+ this.model = targetModel;
407
+ }
408
+ }
409
+ }
410
+
385
411
  if (targetModel && targetModel !== 'acp' && targetModel !== this.peerId) {
386
412
  try {
387
413
  await client.setSessionModel(sessionId, targetModel, signal);
@@ -390,7 +416,17 @@ export class AcpProvider extends LLMProvider {
390
416
  await client.close();
391
417
  throw err;
392
418
  }
393
- // peer does not support setSessionModel
419
+ // If the requested model is unavailable on the user's current account/tier,
420
+ // gracefully fall back to the peer's active or first advertised live model.
421
+ const fallbackModel = sessionModels.currentModelId || liveModels[0];
422
+ if (fallbackModel && fallbackModel !== targetModel) {
423
+ this.model = fallbackModel;
424
+ try {
425
+ await client.setSessionModel(sessionId, fallbackModel, signal);
426
+ } catch {
427
+ // Peer already defaults to its own active session model
428
+ }
429
+ }
394
430
  }
395
431
  }
396
432
 
@@ -480,7 +516,9 @@ export class AcpProvider extends LLMProvider {
480
516
  usage: {
481
517
  promptTokens: Math.ceil(promptText.length / 4),
482
518
  completionTokens: Math.ceil(rawContent.length / 4),
483
- cachedPromptTokens: 0
519
+ cachedPromptTokens: 0,
520
+ measurement: 'text_estimate',
521
+ cacheMeasurement: 'unavailable'
484
522
  }
485
523
  };
486
524
  if (toolCalls.length > 0) {
@@ -2,8 +2,14 @@ export const BASELINE_ANTIGRAVITY_MODELS: Record<string, string>;
2
2
  export const ANTIGRAVITY_MODELS: string[];
3
3
  export const ANTIGRAVITY_MODEL_IDS: Record<string, string>;
4
4
  export const ANTIGRAVITY_LABEL_BY_ID: Record<string, string>;
5
+ export function synthesizeAgySlug(input: string): string;
5
6
  export function registerAntigravityModel(slug: string, label?: string): void;
6
- export function parseAgyModelsOutput(stdout: string): Array<{ id: string; label: string }>;
7
+ export function replaceAntigravityModels(items: Array<{ id: string; label?: string } | string>): string[];
8
+ export function parseAgyModelsOutput(
9
+ stdout: string,
10
+ options?: { replaceActiveList?: boolean }
11
+ ): Array<{ id: string; label: string }>;
12
+ export function isAntigravityOnboarded(): boolean;
7
13
  export function resolveAgyModelId(model: string | null | undefined): string;
8
14
  export function resolveAgyEffort(model: string | null | undefined): string;
9
15
  export function isAntigravityProvider(provider: string | null | undefined): boolean;