@causyne/agent 1.20.118 → 1.20.120

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 (58) hide show
  1. package/package.json +1 -1
  2. package/src/agentLoop.js +29 -12
  3. package/src/agentLoop.ts +29 -16
  4. package/src/browser/causyneBrowser.js +231 -136
  5. package/src/browser/causyneBrowser.ts +229 -140
  6. package/src/browser/searchProviders.js +41 -30
  7. package/src/browser/searchProviders.ts +24 -14
  8. package/src/browser/workspacePathSafety.js +50 -0
  9. package/src/browser/workspacePathSafety.ts +50 -0
  10. package/src/browser/workspacePreview.js +27 -4
  11. package/src/browser/workspacePreview.ts +28 -4
  12. package/src/cliMode.js +1 -1
  13. package/src/commands.js +5 -13
  14. package/src/creative/liveBridge.js +34 -1
  15. package/src/creative/liveBridge.ts +28 -1
  16. package/src/observer/evidence.js +23 -0
  17. package/src/observer/evidence.ts +21 -0
  18. package/src/providers/anthropic.js +33 -17
  19. package/src/providers/base.js +14 -0
  20. package/src/providers/dashscope-byok.js +13 -7
  21. package/src/providers/deepseek.js +13 -18
  22. package/src/providers/gemini.js +33 -25
  23. package/src/providers/moonshot.js +13 -12
  24. package/src/providers/ollama.js +21 -21
  25. package/src/providers/openai-compatible.js +12 -19
  26. package/src/providers/openrouter.js +20 -90
  27. package/src/providers/openrouter.ts +31 -94
  28. package/src/providers/qwen-byok.js +13 -7
  29. package/src/providers/toolContracts.js +9 -3
  30. package/src/providers/toolContracts.ts +9 -3
  31. package/src/providers/wireNormalizer.js +238 -0
  32. package/src/providers/wireNormalizer.ts +279 -0
  33. package/src/providers/xai.js +13 -12
  34. package/src/tools/browserAutomator.js +13 -1
  35. package/src/tools/browserAutomator.ts +13 -0
  36. package/src/tools/creativeApps.js +2 -1
  37. package/src/tools/creativeApps.ts +2 -1
  38. package/src/tools/gameAssetFetcher.js +130 -26
  39. package/src/tools/gameAssetHarvester.js +80 -58
  40. package/src/tools/nativeEngine.js +1 -1
  41. package/src/tools/nativeEngine.ts +1 -1
  42. package/src/tools/registry.js +13 -0
  43. package/src/tools/toolScanner.js +596 -140
  44. package/src/tools/toolScanner.ts +665 -147
  45. package/src/tools/toolSelfRepair.js +243 -114
  46. package/src/tools/toolSelfRepair.ts +262 -111
  47. package/src/tools/webFetch.js +161 -24
  48. package/src/tools/webFetch.ts +157 -22
  49. package/src/tools/webSearch.js +33 -4
  50. package/src/tools/webSearch.ts +27 -4
  51. package/src/tui/sessionPicker.js +132 -35
  52. package/src/tui/sessionPicker.ts +153 -32
  53. package/src/tui/sessionPickerView.js +277 -34
  54. package/src/tui/sessionPickerView.ts +328 -34
  55. package/src/tui/statusLine.js +3 -0
  56. package/src/tui/statusLine.ts +5 -0
  57. package/src/tui/workspaceIdentity.js +133 -0
  58. package/src/tui/workspaceIdentity.ts +146 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@causyne/agent",
3
- "version": "1.20.118",
3
+ "version": "1.20.120",
4
4
  "description": "Agentic AI for software, tools, and computer workflows",
5
5
  "main": "bin/causyne.js",
6
6
  "type": "module",
package/src/agentLoop.js CHANGED
@@ -16,6 +16,7 @@ import { WorkspacePerception } from './perception.js';
16
16
  import { audioFormatForMimeType } from './providers/base.js';
17
17
  import { TaskBuffer } from './taskBuffer.js';
18
18
  import { TOOL_DEFINITIONS, getDynamicTools, getSearchableToolDefinitions, resolveTool, canonicalToolName } from './tools/registry.js';
19
+ import { scanAndAdaptToolsForProvider } from './tools/toolScanner.js';
19
20
  import { selfRepairToolCall, generateSelfRepairDiagnostic } from './tools/toolSelfRepair.js';
20
21
  import { validateToolArguments } from './tools/argumentValidation.js';
21
22
  import { Sandbox } from './sandbox.js';
@@ -40,7 +41,7 @@ import { requiresToolApproval, withToolAutonomyMode } from './approvalPolicy.js'
40
41
  import { AGENT_USER_POLICY } from './agentPolicy.js';
41
42
  import { VFETracker } from './vfeTracker.js';
42
43
  import { coldObserver } from './observer/coldObserver.js';
43
- import { isRenderedNativeBrowserAction, isVerificationCommand } from './observer/evidence.js';
44
+ import { inspectBrowserToolEvidence, isRenderedNativeBrowserAction, isVerificationCommand } from './observer/evidence.js';
44
45
  import { CausyneObserver, defaultObserver, extractClaimedLocalUrls } from './observer.js';
45
46
  import { TimeMachine, recoveryUserMessage, TIME_MACHINE_MAX_ATTEMPTS } from './timeMachine.js';
46
47
  import { packForTool, isCoreTool, isGameIntent, isWebIntent, PACK_PLAYBOOKS, PACKS } from './toolPacks.js';
@@ -403,9 +404,10 @@ You possess native reverse engineering capabilities powered by the Reverse Engin
403
404
  5. **Multiple Emulators/Devices**: When multiple devices or emulators are connected, specify \`-s <serial>\` (e.g. \`adb -s emulator-5554 ...\`) or set \`export ANDROID_SERIAL=<serial>\`.
404
405
 
405
406
  # Universal Tool Calling & Registry Discipline
406
- 1. **Strict Registry Adherence**: Use ONLY the tools declared in the catalogue. Invoke tools using exact parameter names specified in the schema. Do not invent or rename parameters.
407
- 2. **Valid JSON Formatting**: All tool call arguments must be valid JSON objects. Never include raw unescaped newlines or trailing commas inside argument strings.
408
- 3. **Automated Buffer & Self-Correction**: Causyne runs a Universal Tool Buffer with self-repair capabilities. If a tool returns a \`selfRepairGuidance\` result indicating missing or invalid parameters, immediately read the \`expectedParameters\` and re-invoke the tool with the corrected arguments.
407
+ 1. **Strict Root Registry Adherence**: Invoke ONLY tools registered in the active Causyne catalogue (native, plugin, or MCP) or permitted connected-peer capabilities across ACP/Antigravity/Pi. Use exact canonical parameter names and required fields defined in each tool schema without inventing or renaming parameters.
408
+ 2. **Pre-Flight Universal Schema Scan (\`toolsScan\`)**: Before dispatching schemas to any provider API, Causyne scans and compiles every tool declaration into that provider's dialect without reducing or altering underlying tool capability. When an adapted schema asks for a JSON-encoded string on an object, array, or union parameter (e.g. multi-file paths or free-form properties), pass valid JSON so the runtime buffer decodes it transparently to its native type.
409
+ 3. **Universal Self-Repair Buffer (\`toolsSelfRepair\`)**: Every tool call is filtered through \`toolsSelfRepair\`, which heals malformed JSON, decodes adapted free-form/polymorphic values, resolves parameter aliases, coerces types recursively, and emits structured \`selfRepairGuidance\` (\`expectedParameters\`) on incomplete invocations. Always read \`expectedParameters\` and re-invoke with the corrected arguments.
410
+ 4. **Valid JSON Formatting**: Never emit raw unescaped newlines, single-quoted keys, or trailing commas inside tool call JSON strings.
409
411
 
410
412
  # Completion
411
413
  Answer directly when no tool is needed. For action tasks, continue until the authorized work is done or a real blocker is evidenced; then report the verified outcome or blocker concisely.
@@ -662,6 +664,8 @@ export class AgentLoop {
662
664
  this.stallGuard = new StallGuardController();
663
665
  this.smartToolsGovernor = new SmartToolsGovernor(4);
664
666
  this._smartToolsNudge = null;
667
+ this.activeFreeFormPaths = new Map();
668
+ this._lastToolsScanKey = '';
665
669
  // Sovereign Progressive Disclosure: which capability packs have entered the
666
670
  // context window for this task. Nothing is disabled — see src/toolPacks.js.
667
671
  this.unlockedPacks = new Set();
@@ -2295,6 +2299,21 @@ export class AgentLoop {
2295
2299
  ? eligibleTools.filter((tool) => this.toolScope.has(tool.name)) : eligibleTools;
2296
2300
  const dynamicTools = this.smartTools.schemas(permittedTools, this.unlockedTools, this.unlockedPacks, this.config.grantAllTools === true);
2297
2301
  const dynamicToolNames = dynamicTools.map((t) => t.name);
2302
+ // Pre-flight universal schema audit (toolsScan): verify dialect readiness and cache
2303
+ // adapted free-form/polymorphic paths for lossless decoding inside toolsSelfRepair.
2304
+ const activeProviderName = String(this.config?.provider || 'openai');
2305
+ const scanKey = `${activeProviderName}:${dynamicToolNames.join(',')}`;
2306
+ if (scanKey !== this._lastToolsScanKey) {
2307
+ const preflightScan = scanAndAdaptToolsForProvider(dynamicTools, activeProviderName);
2308
+ this.activeFreeFormPaths = preflightScan.freeFormPaths;
2309
+ this._lastToolsScanKey = scanKey;
2310
+ if (preflightScan.repairedCount > 0) {
2311
+ this.debugLog(`[toolsScan] Pre-flight compiled ${preflightScan.repairedCount}/${preflightScan.totalTools} schemas for '${activeProviderName}' (universalReady=${preflightScan.universalReady})`);
2312
+ }
2313
+ if (!preflightScan.universalReady) {
2314
+ this.debugLog(`[toolsScan] Residual compatibility issues on '${activeProviderName}': ${preflightScan.residualIssues.slice(0, 5).map((issue) => `${issue.tool}:${issue.code}`).join(', ')}`);
2315
+ }
2316
+ }
2298
2317
  // Dynamically inject the absolute latest System context
2299
2318
  const autonomyMode = this.config.autonomyMode || 'C';
2300
2319
  const allowedPaths = this.sandbox.grantAllAccess
@@ -3924,7 +3943,8 @@ You are operating in a text-and-code modality without direct image pixel renderi
3924
3943
  const tool = resolveTool(functionName);
3925
3944
  const toolSchema = tool?.schema?.parameters || tool?.schema?.input_schema;
3926
3945
  const repair = selfRepairToolCall(toolCall, toolSchema, {
3927
- cwd: this.workspaceRoot || process.cwd()
3946
+ cwd: this.workspaceRoot || process.cwd(),
3947
+ freeFormPaths: this.activeFreeFormPaths?.get(functionName)
3928
3948
  });
3929
3949
  if (repair.error) {
3930
3950
  this.messages.push({
@@ -4439,14 +4459,11 @@ You are operating in a text-and-code modality without direct image pixel renderi
4439
4459
  if (functionName === 'browser_act' && result?.success === true) {
4440
4460
  const hasExplicitPlanInBatch = Array.isArray(response.toolCalls)
4441
4461
  && response.toolCalls.some((c) => canonicalToolName(c?.function?.name || '') === 'update_plan');
4442
- if (!hasExplicitPlanInBatch) {
4443
- this.advanceImplementationPlanProgress('verification');
4444
- }
4445
- const browserResults = Array.isArray(result.data) ? result.data : [];
4446
- const allRuntimeErrors = browserResults.flatMap((item) => Array.isArray(item?.data?.runtimeErrors) ? item.data.runtimeErrors : []);
4447
- const hasValidBrowserAction = browserResults.some((item) => ['preview', 'snapshot', 'scrape', 'screenshot'].includes(item?.action));
4448
- if (allRuntimeErrors.length === 0 && (hasValidBrowserAction || result.url || result.tabId)) {
4462
+ const { verified, runtimeErrors: allRuntimeErrors } = inspectBrowserToolEvidence(result);
4463
+ if (verified) {
4449
4464
  this.webVerificationState.browserActUsed = true;
4465
+ if (!hasExplicitPlanInBatch)
4466
+ this.advanceImplementationPlanProgress('verification');
4450
4467
  }
4451
4468
  else if (allRuntimeErrors.length > 0) {
4452
4469
  this.webVerificationState.browserActUsed = false;
package/src/agentLoop.ts CHANGED
@@ -17,6 +17,7 @@ import { WorkspacePerception } from './perception.js';
17
17
  import { audioFormatForMimeType } from './providers/base.js';
18
18
  import { TaskBuffer } from './taskBuffer.js';
19
19
  import { TOOL_DEFINITIONS, getDynamicTools, getSearchableToolDefinitions, resolveTool, canonicalToolName } from './tools/registry.js';
20
+ import { scanAndAdaptToolsForProvider } from './tools/toolScanner.js';
20
21
  import { selfRepairToolCall, generateSelfRepairDiagnostic } from './tools/toolSelfRepair.js';
21
22
  import { validateToolArguments } from './tools/argumentValidation.js';
22
23
  import { Sandbox } from './sandbox.js';
@@ -52,7 +53,7 @@ import { requiresToolApproval, withToolAutonomyMode } from './approvalPolicy.js'
52
53
  import { AGENT_USER_POLICY } from './agentPolicy.js';
53
54
  import { VFETracker } from './vfeTracker.js';
54
55
  import { coldObserver } from './observer/coldObserver.js';
55
- import { isRenderedNativeBrowserAction, isVerificationCommand } from './observer/evidence.js';
56
+ import { inspectBrowserToolEvidence, isRenderedNativeBrowserAction, isVerificationCommand } from './observer/evidence.js';
56
57
  import { CausyneObserver, defaultObserver, extractClaimedLocalUrls } from './observer.js';
57
58
  import type { Observation } from './observer.js';
58
59
  import { TimeMachine, recoveryUserMessage, TIME_MACHINE_MAX_ATTEMPTS } from './timeMachine.js';
@@ -485,9 +486,10 @@ You possess native reverse engineering capabilities powered by the Reverse Engin
485
486
  5. **Multiple Emulators/Devices**: When multiple devices or emulators are connected, specify \`-s <serial>\` (e.g. \`adb -s emulator-5554 ...\`) or set \`export ANDROID_SERIAL=<serial>\`.
486
487
 
487
488
  # Universal Tool Calling & Registry Discipline
488
- 1. **Strict Registry Adherence**: Use ONLY the tools declared in the catalogue. Invoke tools using exact parameter names specified in the schema. Do not invent or rename parameters.
489
- 2. **Valid JSON Formatting**: All tool call arguments must be valid JSON objects. Never include raw unescaped newlines or trailing commas inside argument strings.
490
- 3. **Automated Buffer & Self-Correction**: Causyne runs a Universal Tool Buffer with self-repair capabilities. If a tool returns a \`selfRepairGuidance\` result indicating missing or invalid parameters, immediately read the \`expectedParameters\` and re-invoke the tool with the corrected arguments.
489
+ 1. **Strict Root Registry Adherence**: Invoke ONLY tools registered in the active Causyne catalogue (native, plugin, or MCP) or permitted connected-peer capabilities across ACP/Antigravity/Pi. Use exact canonical parameter names and required fields defined in each tool schema without inventing or renaming parameters.
490
+ 2. **Pre-Flight Universal Schema Scan (\`toolsScan\`)**: Before dispatching schemas to any provider API, Causyne scans and compiles every tool declaration into that provider's dialect without reducing or altering underlying tool capability. When an adapted schema asks for a JSON-encoded string on an object, array, or union parameter (e.g. multi-file paths or free-form properties), pass valid JSON so the runtime buffer decodes it transparently to its native type.
491
+ 3. **Universal Self-Repair Buffer (\`toolsSelfRepair\`)**: Every tool call is filtered through \`toolsSelfRepair\`, which heals malformed JSON, decodes adapted free-form/polymorphic values, resolves parameter aliases, coerces types recursively, and emits structured \`selfRepairGuidance\` (\`expectedParameters\`) on incomplete invocations. Always read \`expectedParameters\` and re-invoke with the corrected arguments.
492
+ 4. **Valid JSON Formatting**: Never emit raw unescaped newlines, single-quoted keys, or trailing commas inside tool call JSON strings.
491
493
 
492
494
  # Completion
493
495
  Answer directly when no tool is needed. For action tasks, continue until the authorized work is done or a real blocker is evidenced; then report the verified outcome or blocker concisely.
@@ -762,6 +764,8 @@ export class AgentLoop {
762
764
  this.stallGuard = new StallGuardController();
763
765
  this.smartToolsGovernor = new SmartToolsGovernor(4);
764
766
  this._smartToolsNudge = null;
767
+ this.activeFreeFormPaths = new Map<string, string[][]>();
768
+ this._lastToolsScanKey = '';
765
769
 
766
770
  // Sovereign Progressive Disclosure: which capability packs have entered the
767
771
  // context window for this task. Nothing is disabled — see src/toolPacks.js.
@@ -2378,6 +2382,22 @@ export class AgentLoop {
2378
2382
  this.config.grantAllTools === true);
2379
2383
  const dynamicToolNames = dynamicTools.map((t: any) => t.name);
2380
2384
 
2385
+ // Pre-flight universal schema audit (toolsScan): verify dialect readiness and cache
2386
+ // adapted free-form/polymorphic paths for lossless decoding inside toolsSelfRepair.
2387
+ const activeProviderName = String(this.config?.provider || 'openai');
2388
+ const scanKey = `${activeProviderName}:${dynamicToolNames.join(',')}`;
2389
+ if (scanKey !== this._lastToolsScanKey) {
2390
+ const preflightScan = scanAndAdaptToolsForProvider(dynamicTools, activeProviderName);
2391
+ this.activeFreeFormPaths = preflightScan.freeFormPaths;
2392
+ this._lastToolsScanKey = scanKey;
2393
+ if (preflightScan.repairedCount > 0) {
2394
+ this.debugLog(`[toolsScan] Pre-flight compiled ${preflightScan.repairedCount}/${preflightScan.totalTools} schemas for '${activeProviderName}' (universalReady=${preflightScan.universalReady})`);
2395
+ }
2396
+ if (!preflightScan.universalReady) {
2397
+ this.debugLog(`[toolsScan] Residual compatibility issues on '${activeProviderName}': ${preflightScan.residualIssues.slice(0, 5).map((issue) => `${issue.tool}:${issue.code}`).join(', ')}`);
2398
+ }
2399
+ }
2400
+
2381
2401
  // Dynamically inject the absolute latest System context
2382
2402
  const autonomyMode = this.config.autonomyMode || 'C';
2383
2403
  const allowedPaths = this.sandbox.grantAllAccess
@@ -4090,7 +4110,8 @@ You are operating in a text-and-code modality without direct image pixel renderi
4090
4110
  const tool = resolveTool(functionName);
4091
4111
  const toolSchema = tool?.schema?.parameters || tool?.schema?.input_schema;
4092
4112
  const repair = selfRepairToolCall(toolCall, toolSchema, {
4093
- cwd: this.workspaceRoot || process.cwd()
4113
+ cwd: this.workspaceRoot || process.cwd(),
4114
+ freeFormPaths: this.activeFreeFormPaths?.get(functionName)
4094
4115
  });
4095
4116
 
4096
4117
  if (repair.error) {
@@ -4654,18 +4675,10 @@ You are operating in a text-and-code modality without direct image pixel renderi
4654
4675
  if (functionName === 'browser_act' && result?.success === true) {
4655
4676
  const hasExplicitPlanInBatch = Array.isArray(response.toolCalls)
4656
4677
  && response.toolCalls.some((c: any) => canonicalToolName(c?.function?.name || '') === 'update_plan');
4657
- if (!hasExplicitPlanInBatch) {
4658
- this.advanceImplementationPlanProgress('verification');
4659
- }
4660
- const browserResults = Array.isArray(result.data) ? result.data : [];
4661
- const allRuntimeErrors = browserResults.flatMap((item: any) =>
4662
- Array.isArray(item?.data?.runtimeErrors) ? item.data.runtimeErrors : []
4663
- );
4664
- const hasValidBrowserAction = browserResults.some((item: any) =>
4665
- ['preview', 'snapshot', 'scrape', 'screenshot'].includes(item?.action)
4666
- );
4667
- if (allRuntimeErrors.length === 0 && (hasValidBrowserAction || result.url || result.tabId)) {
4678
+ const { verified, runtimeErrors: allRuntimeErrors } = inspectBrowserToolEvidence(result);
4679
+ if (verified) {
4668
4680
  this.webVerificationState.browserActUsed = true;
4681
+ if (!hasExplicitPlanInBatch) this.advanceImplementationPlanProgress('verification');
4669
4682
  } else if (allRuntimeErrors.length > 0) {
4670
4683
  this.webVerificationState.browserActUsed = false;
4671
4684
  this.emitEvent({