@causyne/agent 1.20.0 → 1.20.7

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 (130) hide show
  1. package/README.md +13 -9
  2. package/SECURITY.md +1 -4
  3. package/package.json +1 -1
  4. package/src/acp/client.js +176 -26
  5. package/src/acp/client.ts +167 -25
  6. package/src/acp/protocol.js +116 -0
  7. package/src/acp/protocol.ts +163 -0
  8. package/src/acp/server.js +5 -6
  9. package/src/acp/server.ts +4 -6
  10. package/src/agentLoop.d.ts +1 -0
  11. package/src/agentLoop.js +681 -245
  12. package/src/agentLoop.ts +708 -262
  13. package/src/agentPolicy.js +9 -0
  14. package/src/agentPolicy.ts +9 -0
  15. package/src/approvalPolicy.js +55 -0
  16. package/src/approvalPolicy.ts +66 -0
  17. package/src/browser/browserRuntime.js +217 -14
  18. package/src/browser/browserRuntime.ts +255 -14
  19. package/src/browser/causyneBrowser.js +1215 -68
  20. package/src/browser/causyneBrowser.ts +1340 -72
  21. package/src/cliMode.js +52 -29
  22. package/src/commands.js +141 -17
  23. package/src/config.js +22 -12
  24. package/src/continuum/ui/continuumPicker.js +18 -1
  25. package/src/continuum/ui/continuumPicker.ts +19 -1
  26. package/src/dynamicCatalogue.js +87 -20
  27. package/src/dynamicCatalogue.ts +85 -15
  28. package/src/launchIntent.js +40 -0
  29. package/src/launchIntent.ts +49 -0
  30. package/src/memoryManager.js +26 -2
  31. package/src/modelCatalogue.js +2 -0
  32. package/src/planCache.js +320 -11
  33. package/src/planCache.ts +402 -13
  34. package/src/providers/acp.js +173 -18
  35. package/src/providers/acp.ts +169 -19
  36. package/src/providers/antigravity.d.ts +5 -1
  37. package/src/providers/antigravity.js +674 -34
  38. package/src/providers/antigravity.ts +707 -35
  39. package/src/providers/base.d.ts +10 -0
  40. package/src/providers/factory.js +2 -0
  41. package/src/providers/pi.js +161 -0
  42. package/src/providers/pi.ts +148 -0
  43. package/src/provisioning/capabilityProvisioner.js +17 -0
  44. package/src/provisioning/capabilityTools.js +1 -1
  45. package/src/sandbox.js +30 -39
  46. package/src/sessionJournal.js +53 -10
  47. package/src/sessionJournal.ts +64 -10
  48. package/src/taskShape.js +9 -9
  49. package/src/taskShape.ts +9 -9
  50. package/src/timeMachine.js +124 -0
  51. package/src/timeMachine.ts +141 -0
  52. package/src/toolPacks.js +4 -10
  53. package/src/tools/archive.js +196 -59
  54. package/src/tools/archive.ts +220 -0
  55. package/src/tools/browserAutomator.js +78 -9
  56. package/src/tools/browserAutomator.ts +90 -9
  57. package/src/tools/desktopOpen.js +114 -31
  58. package/src/tools/desktopOpen.ts +144 -0
  59. package/src/tools/gitExec.js +5 -3
  60. package/src/tools/nativeEngine.js +4 -3
  61. package/src/tools/nativeEngine.ts +5 -3
  62. package/src/tools/openSourceToolProvisioner.js +5 -4
  63. package/src/tools/openSourceToolProvisioner.ts +5 -4
  64. package/src/tools/registry.js +3 -0
  65. package/src/tools/screenshot.js +55 -71
  66. package/src/tools/screenshot.ts +70 -0
  67. package/src/tools/sysRun.js +284 -117
  68. package/src/tools/sysRun.ts +347 -0
  69. package/src/tools/toolSelfRepair.js +109 -2
  70. package/src/tools/toolSelfRepair.ts +100 -2
  71. package/src/tools/updatePlan.js +49 -1
  72. package/src/tools/updatePlan.ts +43 -1
  73. package/src/tools/viewImage.js +93 -78
  74. package/src/tools/viewImage.ts +116 -0
  75. package/src/tools/webFetch.js +20 -6
  76. package/src/tools/webFetch.ts +26 -6
  77. package/src/tui/activityLayout.js +9 -0
  78. package/src/tui/activityLayout.ts +10 -0
  79. package/src/tui/block.d.ts +1 -0
  80. package/src/tui/chatRenderer.d.ts +23 -0
  81. package/src/tui/chatRenderer.js +49 -49
  82. package/src/tui/clipboardSync.js +28 -1
  83. package/src/tui/clipboardSync.ts +26 -1
  84. package/src/tui/codeProgress.js +299 -0
  85. package/src/tui/codeProgress.ts +304 -0
  86. package/src/tui/codeStreamRenderer.js +132 -0
  87. package/src/tui/codeStreamRenderer.ts +141 -0
  88. package/src/tui/commandPresentation.js +11 -0
  89. package/src/tui/commandPresentation.ts +18 -0
  90. package/src/tui/completion.js +45 -13
  91. package/src/tui/composerControls.js +131 -0
  92. package/src/tui/composerControls.ts +184 -0
  93. package/src/tui/diff.d.ts +2 -0
  94. package/src/tui/home.js +4 -2
  95. package/src/tui/homeTransition.js +21 -0
  96. package/src/tui/homeTransition.ts +27 -0
  97. package/src/tui/homeView.js +62 -0
  98. package/src/tui/homeView.ts +91 -0
  99. package/src/tui/layout.js +46 -0
  100. package/src/tui/layout.ts +52 -0
  101. package/src/tui/messageActionPlacement.js +16 -0
  102. package/src/tui/messageActionPlacement.ts +25 -0
  103. package/src/tui/messageInteraction.js +221 -0
  104. package/src/tui/messageInteraction.ts +275 -0
  105. package/src/tui/modelPicker.js +4 -24
  106. package/src/tui/modelPicker.ts +4 -20
  107. package/src/tui/mouseHover.js +6 -0
  108. package/src/tui/mouseHover.ts +5 -0
  109. package/src/tui/prompt.js +175 -101
  110. package/src/tui/resizeRecovery.js +15 -0
  111. package/src/tui/resizeRecovery.ts +27 -0
  112. package/src/tui/scrollInteraction.js +97 -0
  113. package/src/tui/scrollInteraction.ts +189 -0
  114. package/src/tui/sessionLayout.js +12 -0
  115. package/src/tui/sessionLayout.ts +12 -0
  116. package/src/tui/sessionPicker.js +111 -16
  117. package/src/tui/sessionPicker.ts +121 -16
  118. package/src/tui/sessionSidebar.js +78 -0
  119. package/src/tui/sessionSidebar.ts +95 -0
  120. package/src/tui/setup.js +1 -1
  121. package/src/tui/setup.ts +1 -1
  122. package/src/tui/stageSurface.js +120 -58
  123. package/src/tui/text.d.ts +6 -0
  124. package/src/tui/textLayout.js +23 -0
  125. package/src/tui/textLayout.ts +28 -0
  126. package/src/tui/viewport.js +204 -279
  127. package/src/tui/viewport.ts +326 -0
  128. package/src/types/contracts.ts +54 -0
  129. package/src/utils/paths.js +5 -4
  130. package/src/utils/paths.ts +5 -5
@@ -1,9 +1,64 @@
1
- import { BrowserCapabilityError, causyneBrowser, type BrowserAction } from '../browser/causyneBrowser.js';
1
+ import {
2
+ BrowserCapabilityError,
3
+ causyneBrowser,
4
+ getSupportedSearchMacros,
5
+ type BrowserAction,
6
+ type BrowserActionType
7
+ } from '../browser/causyneBrowser.js';
8
+
9
+ interface SandboxContext {
10
+ workspacePaths?: string[];
11
+ workspaceRoot?: string;
12
+ }
13
+
14
+ const SUPPORTED_ACTION_TYPES: BrowserActionType[] = [
15
+ 'newTab', 'new_tab',
16
+ 'switchTab', 'switch_tab',
17
+ 'listTabs', 'list_tabs',
18
+ 'closeTab', 'close_tab',
19
+ 'search',
20
+ 'goto', 'open', 'navigate',
21
+ 'snapshot', 'scrape',
22
+ 'click', 'clickIndex',
23
+ 'type', 'typeIndex', 'fill',
24
+ 'selectOption', 'select',
25
+ 'keyPress', 'press',
26
+ 'hover',
27
+ 'scroll',
28
+ 'wait',
29
+ 'viewport',
30
+ 'back', 'forward', 'reload', 'refresh',
31
+ 'extract', 'links', 'images',
32
+ 'upload', 'download', 'screenshot'
33
+ ];
34
+
35
+ function normalizeActions(args: Record<string, unknown> | undefined): BrowserAction[] {
36
+ if (!args || typeof args !== 'object') return [];
37
+ if (Array.isArray(args.actions)) {
38
+ return args.actions.map(item => {
39
+ if (item && typeof item === 'object' && !('type' in item) && typeof (item as Record<string, unknown>).action === 'string') {
40
+ const { action, ...rest } = item as Record<string, unknown>;
41
+ return { ...rest, type: action as BrowserActionType } as BrowserAction;
42
+ }
43
+ return item as BrowserAction;
44
+ });
45
+ }
46
+ const singleType = typeof args.type === 'string'
47
+ ? args.type
48
+ : typeof args.action === 'string'
49
+ ? args.action
50
+ : null;
51
+ if (singleType) {
52
+ const { action: _action, ...rest } = args;
53
+ return [{ ...rest, type: singleType as BrowserActionType } as BrowserAction];
54
+ }
55
+ return [];
56
+ }
2
57
 
3
58
  export const browserAct = {
4
59
  schema: {
5
60
  name: 'browser.act',
6
- description: 'Use the dedicated Causyne Browser for resilient search, navigation, accessible snapshots, interaction, extraction, and workspace-scoped downloads. Take a snapshot before interacting by ref.',
61
+ description: `Use the dedicated Causyne Browser for resilient search, navigation, search macros (${getSupportedSearchMacros().slice(0, 6).join(', ')}, etc.), accessible snapshots (including child iframes and structured forms/tables), interaction, deterministic schema extraction, and workspace-scoped uploads/downloads. Take a snapshot before interacting by ref.`,
7
62
  parameters: {
8
63
  type: 'object',
9
64
  properties: {
@@ -16,20 +71,44 @@ export const browserAct = {
16
71
  properties: {
17
72
  type: {
18
73
  type: 'string',
19
- enum: ['newTab', 'switchTab', 'listTabs', 'closeTab', 'search', 'goto', 'snapshot', 'scrape', 'click', 'clickIndex', 'type', 'typeIndex', 'selectOption', 'keyPress', 'scroll', 'back', 'forward', 'reload', 'extract', 'download', 'screenshot']
74
+ enum: SUPPORTED_ACTION_TYPES
20
75
  },
21
76
  tabId: { type: 'string', description: 'Tab id returned by newTab or listTabs.' },
22
- url: { type: 'string', description: 'Public http(s) URL for goto or newTab.' },
23
- query: { type: 'string', description: 'Search query.' },
77
+ url: { type: 'string', description: 'Public http(s) URL or @macro_search shorthand for goto/newTab.' },
78
+ macro: { type: 'string', description: 'Search macro such as @google_search, @youtube_search, @wikipedia_search, @reddit_search, @amazon_search.' },
79
+ query: { type: 'string', description: 'Search query for search action or search macro.' },
24
80
  ref: { type: 'string', description: 'Current accessibility ref, for example e12.' },
25
81
  index: { type: 'number', description: 'Legacy numeric form of an accessibility ref.' },
26
82
  selector: { type: 'string', description: 'CSS selector when a current accessibility ref is unavailable.' },
27
83
  text: { type: 'string' },
28
84
  value: { type: 'string' },
29
- key: { type: 'string' },
85
+ option: { type: 'string', description: 'Option value or visible label for selectOption/select.' },
86
+ key: { type: 'string', description: 'Keyboard key or chord (e.g. Enter, Escape, Control+a, Meta+k).' },
87
+ mode: { type: 'string', enum: ['fill', 'keyboard'], description: 'Typing mode for type/fill action.' },
88
+ delay: { type: 'number', description: 'Per-character delay in ms when mode is keyboard.' },
89
+ submit: { type: 'boolean', description: 'Press Enter after typing text.' },
90
+ pressEnter: { type: 'boolean', description: 'Alias for submit: press Enter after typing text.' },
91
+ doubleClick: { type: 'boolean', description: 'Perform a double click instead of a single click.' },
30
92
  direction: { type: 'string', enum: ['up', 'down', 'left', 'right'] },
31
93
  amount: { type: 'number' },
32
- offset: { type: 'number', description: 'Character offset for a paged accessibility snapshot.' },
94
+ offset: { type: 'number', description: 'Character offset for a paged accessibility snapshot or links pagination.' },
95
+ limit: { type: 'number', description: 'Maximum number of links or images to return.' },
96
+ timeout: { type: 'number', description: 'Wait timeout in milliseconds for wait action.' },
97
+ waitForNetwork: { type: 'boolean', description: 'Wait for networkidle during wait action.' },
98
+ dismissConsent: { type: 'boolean', description: 'Automatically dismiss common cookie/consent banners.' },
99
+ width: { type: 'number', description: 'Viewport width in pixels (100-4000) for viewport action.' },
100
+ height: { type: 'number', description: 'Viewport height in pixels (100-4000) for viewport action.' },
101
+ schema: {
102
+ type: 'object',
103
+ description: 'Deterministic JSON Schema with x-ref annotations for extract action.'
104
+ },
105
+ filePath: {
106
+ oneOf: [
107
+ { type: 'string' },
108
+ { type: 'array', items: { type: 'string' } }
109
+ ],
110
+ description: 'Workspace-relative file path(s) for upload action.'
111
+ },
33
112
  outputFile: { type: 'string', description: 'Download or screenshot destination inside the selected workspace.' },
34
113
  fullPage: { type: 'boolean', description: 'Capture the complete page for a screenshot instead of the visible viewport.' }
35
114
  },
@@ -43,9 +122,11 @@ export const browserAct = {
43
122
  }
44
123
  },
45
124
 
46
- async execute(args: { actions?: BrowserAction[] }) {
125
+ async execute(args: { actions?: BrowserAction[] } & Record<string, unknown>, sandbox?: SandboxContext) {
47
126
  try {
48
- const results = await causyneBrowser().run(args.actions ?? []);
127
+ const workspace = sandbox?.workspacePaths?.[0] ?? sandbox?.workspaceRoot ?? process.cwd();
128
+ const actions = normalizeActions(args);
129
+ const results = await causyneBrowser({ workspace }).run(actions, { workspace });
49
130
  return { success: true, output: JSON.stringify(results, null, 2), data: results };
50
131
  } catch (error) {
51
132
  if (error instanceof BrowserCapabilityError) {
@@ -1,34 +1,117 @@
1
- import { ensureCapability, loadCapabilityPackage } from '../provisioning/capabilityProvisioner.js';
2
- export const desktopOpen = {
3
- schema: {
4
- name: 'desktop.open',
5
- description: 'Securely open files, URLs, or applications using native OS handlers without shell execution.',
6
- parameters: {
7
- type: 'object',
8
- properties: {
9
- target: { type: 'string', description: 'File path, URL, or app name' },
10
- app: { type: 'string', description: 'Specific app to open with (e.g., "Google Chrome")' }
11
- },
12
- required: ['target']
1
+ /**
2
+ * Causyne Agent — Desktop Open Tool (desktop_open / desktop.open)
3
+ *
4
+ * Securely opens files, URLs, or applications using native OS handlers
5
+ * without shell execution, npm dependencies, or capability consent stalls.
6
+ */
7
+ import { spawn } from 'node:child_process';
8
+ import os from 'node:os';
9
+ import path from 'node:path';
10
+ import fs from 'node:fs';
11
+ export function resolveOpenTarget(rawTarget, workspaceRoot = process.cwd()) {
12
+ let target = (rawTarget || '').trim();
13
+ if (!target)
14
+ return target;
15
+ // URLs (http, https, file, etc.)
16
+ if (/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(target)) {
17
+ return target;
18
+ }
19
+ // Tilde expansion: ~/path -> /Users/username/path
20
+ if (target === '~' || target.startsWith('~/') || target.startsWith('~\\')) {
21
+ target = path.normalize(target.replace(/^~(?=$|[\\/])/, os.homedir()));
13
22
  }
14
- },
15
- async execute(args) {
16
- try {
17
- const capability = await ensureCapability('desktop');
18
- if (!capability.ok) return { success: false, error: capability.reason, requiresConsent: capability.requiresConsent };
19
- const open = await loadCapabilityPackage('open');
20
-
21
- const options = {};
22
- if (args.app) {
23
- options.app = { name: args.app };
24
- }
25
-
26
- // Phase 6 AGI Upgrade: Native Cross-Platform OS Handler
27
- await open(args.target, options);
28
-
29
- return { success: true, output: `Successfully dispatched native OS open event for: ${args.target}` };
30
- } catch (e) {
31
- return { success: false, error: `Failed to open: ${e.message}` };
23
+ // If not absolute path, check if it exists relative to workspaceRoot or process.cwd()
24
+ if (!path.isAbsolute(target)) {
25
+ const fromWorkspace = path.resolve(workspaceRoot, target);
26
+ if (fs.existsSync(fromWorkspace)) {
27
+ return fromWorkspace;
28
+ }
29
+ const fromCwd = path.resolve(process.cwd(), target);
30
+ if (fs.existsSync(fromCwd)) {
31
+ return fromCwd;
32
+ }
33
+ return fromWorkspace;
34
+ }
35
+ return target;
36
+ }
37
+ export async function openWithNativeOS(target, app) {
38
+ return new Promise((resolve, reject) => {
39
+ let command;
40
+ let cliArgs;
41
+ const platform = os.platform();
42
+ if (platform === 'darwin') {
43
+ command = '/usr/bin/open';
44
+ cliArgs = app ? ['-a', app, target] : [target];
45
+ }
46
+ else if (platform === 'win32') {
47
+ command = 'cmd.exe';
48
+ cliArgs = app ? ['/c', 'start', '""', '/d', app, target] : ['/c', 'start', '""', target];
49
+ }
50
+ else {
51
+ command = 'xdg-open';
52
+ cliArgs = [target];
53
+ }
54
+ try {
55
+ const child = spawn(command, cliArgs, {
56
+ detached: true,
57
+ stdio: 'ignore'
58
+ });
59
+ child.unref();
60
+ child.on('error', (err) => {
61
+ reject(err);
62
+ });
63
+ // Brief tick to ensure the binary was dispatched without immediate spawn error
64
+ setTimeout(() => {
65
+ resolve({
66
+ success: true,
67
+ output: `Successfully dispatched native OS open event for: ${target}`
68
+ });
69
+ }, 50);
70
+ }
71
+ catch (e) {
72
+ reject(e);
73
+ }
74
+ });
75
+ }
76
+ export const desktopOpen = {
77
+ schema: {
78
+ name: 'desktop.open',
79
+ description: 'Securely open files, URLs, or applications using native OS handlers without shell execution.',
80
+ parameters: {
81
+ type: 'object',
82
+ properties: {
83
+ target: { type: 'string', description: 'File path, URL, or app name' },
84
+ app: { type: 'string', description: 'Specific app to open with (e.g., "Google Chrome")' }
85
+ },
86
+ required: ['target']
87
+ }
88
+ },
89
+ async execute(args, context = {}) {
90
+ if (!args || typeof args.target !== 'string' || !args.target.trim()) {
91
+ return { success: false, error: 'Missing required "target" parameter for desktop.open' };
92
+ }
93
+ const workspaceRoot = context?.parentLoop?.workspaceRoot || process.cwd();
94
+ const resolvedTarget = resolveOpenTarget(args.target, workspaceRoot);
95
+ try {
96
+ const nativeResult = await openWithNativeOS(resolvedTarget, args.app);
97
+ return { success: true, output: nativeResult.output };
98
+ }
99
+ catch (nativeErr) {
100
+ // Fallback: if optional npm 'open' package happens to be installed, try it
101
+ try {
102
+ const { loadCapabilityPackage, groupStatus } = await import('../provisioning/capabilityProvisioner.js');
103
+ if (groupStatus('desktop')?.state === 'ready') {
104
+ const openPkg = await loadCapabilityPackage('open');
105
+ const options = {};
106
+ if (args.app)
107
+ options.app = { name: args.app };
108
+ await openPkg(resolvedTarget, options);
109
+ return { success: true, output: `Successfully dispatched OS open event for: ${resolvedTarget}` };
110
+ }
111
+ }
112
+ catch { }
113
+ const msg = nativeErr instanceof Error ? nativeErr.message : String(nativeErr);
114
+ return { success: false, error: `Failed to open "${resolvedTarget}": ${msg}` };
115
+ }
32
116
  }
33
- }
34
117
  };
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Causyne Agent — Desktop Open Tool (desktop_open / desktop.open)
3
+ *
4
+ * Securely opens files, URLs, or applications using native OS handlers
5
+ * without shell execution, npm dependencies, or capability consent stalls.
6
+ */
7
+
8
+ import { spawn } from 'node:child_process';
9
+ import os from 'node:os';
10
+ import path from 'node:path';
11
+ import fs from 'node:fs';
12
+
13
+ export interface DesktopOpenArgs {
14
+ target: string;
15
+ app?: string | undefined;
16
+ }
17
+
18
+ export interface DesktopOpenResult {
19
+ success: boolean;
20
+ output?: string | undefined;
21
+ error?: string | undefined;
22
+ requiresConsent?: boolean | undefined;
23
+ }
24
+
25
+ export interface DesktopOpenContext {
26
+ parentLoop?: {
27
+ workspaceRoot?: string | undefined;
28
+ } | undefined;
29
+ }
30
+
31
+ export function resolveOpenTarget(rawTarget: string, workspaceRoot: string = process.cwd()): string {
32
+ let target = (rawTarget || '').trim();
33
+ if (!target) return target;
34
+
35
+ // URLs (http, https, file, etc.)
36
+ if (/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(target)) {
37
+ return target;
38
+ }
39
+
40
+ // Tilde expansion: ~/path -> /Users/username/path
41
+ if (target === '~' || target.startsWith('~/') || target.startsWith('~\\')) {
42
+ target = path.normalize(target.replace(/^~(?=$|[\\/])/, os.homedir()));
43
+ }
44
+
45
+ // If not absolute path, check if it exists relative to workspaceRoot or process.cwd()
46
+ if (!path.isAbsolute(target)) {
47
+ const fromWorkspace = path.resolve(workspaceRoot, target);
48
+ if (fs.existsSync(fromWorkspace)) {
49
+ return fromWorkspace;
50
+ }
51
+ const fromCwd = path.resolve(process.cwd(), target);
52
+ if (fs.existsSync(fromCwd)) {
53
+ return fromCwd;
54
+ }
55
+ return fromWorkspace;
56
+ }
57
+
58
+ return target;
59
+ }
60
+
61
+ export async function openWithNativeOS(target: string, app?: string): Promise<{ success: boolean; output: string }> {
62
+ return new Promise((resolve, reject) => {
63
+ let command: string;
64
+ let cliArgs: string[];
65
+
66
+ const platform = os.platform();
67
+ if (platform === 'darwin') {
68
+ command = '/usr/bin/open';
69
+ cliArgs = app ? ['-a', app, target] : [target];
70
+ } else if (platform === 'win32') {
71
+ command = 'cmd.exe';
72
+ cliArgs = app ? ['/c', 'start', '""', '/d', app, target] : ['/c', 'start', '""', target];
73
+ } else {
74
+ command = 'xdg-open';
75
+ cliArgs = [target];
76
+ }
77
+
78
+ try {
79
+ const child = spawn(command, cliArgs, {
80
+ detached: true,
81
+ stdio: 'ignore'
82
+ });
83
+ child.unref();
84
+
85
+ child.on('error', (err) => {
86
+ reject(err);
87
+ });
88
+
89
+ // Brief tick to ensure the binary was dispatched without immediate spawn error
90
+ setTimeout(() => {
91
+ resolve({
92
+ success: true,
93
+ output: `Successfully dispatched native OS open event for: ${target}`
94
+ });
95
+ }, 50);
96
+ } catch (e) {
97
+ reject(e);
98
+ }
99
+ });
100
+ }
101
+
102
+ export const desktopOpen = {
103
+ schema: {
104
+ name: 'desktop.open',
105
+ description: 'Securely open files, URLs, or applications using native OS handlers without shell execution.',
106
+ parameters: {
107
+ type: 'object',
108
+ properties: {
109
+ target: { type: 'string', description: 'File path, URL, or app name' },
110
+ app: { type: 'string', description: 'Specific app to open with (e.g., "Google Chrome")' }
111
+ },
112
+ required: ['target']
113
+ }
114
+ },
115
+
116
+ async execute(args: DesktopOpenArgs, context: DesktopOpenContext = {}): Promise<DesktopOpenResult> {
117
+ if (!args || typeof args.target !== 'string' || !args.target.trim()) {
118
+ return { success: false, error: 'Missing required "target" parameter for desktop.open' };
119
+ }
120
+
121
+ const workspaceRoot = context?.parentLoop?.workspaceRoot || process.cwd();
122
+ const resolvedTarget = resolveOpenTarget(args.target, workspaceRoot);
123
+
124
+ try {
125
+ const nativeResult = await openWithNativeOS(resolvedTarget, args.app);
126
+ return { success: true, output: nativeResult.output };
127
+ } catch (nativeErr: unknown) {
128
+ // Fallback: if optional npm 'open' package happens to be installed, try it
129
+ try {
130
+ const { loadCapabilityPackage, groupStatus } = await import('../provisioning/capabilityProvisioner.js');
131
+ if (groupStatus('desktop')?.state === 'ready') {
132
+ const openPkg = await loadCapabilityPackage('open') as (t: string, o?: Record<string, unknown>) => Promise<unknown>;
133
+ const options: Record<string, unknown> = {};
134
+ if (args.app) options.app = { name: args.app };
135
+ await openPkg(resolvedTarget, options);
136
+ return { success: true, output: `Successfully dispatched OS open event for: ${resolvedTarget}` };
137
+ }
138
+ } catch {}
139
+
140
+ const msg = nativeErr instanceof Error ? nativeErr.message : String(nativeErr);
141
+ return { success: false, error: `Failed to open "${resolvedTarget}": ${msg}` };
142
+ }
143
+ }
144
+ };
@@ -1,10 +1,11 @@
1
1
  import { exec } from 'child_process';
2
2
  import os from 'os';
3
+ import { currentToolAutonomyMode } from '../approvalPolicy.js';
3
4
 
4
5
  export const gitExec = {
5
6
  schema: {
6
7
  name: 'gitOp',
7
- description: 'Execute a git command securely. Features autonomous conflict detection and HitL interception for destructive commands.',
8
+ description: 'Execute a git command in the selected workspace. Destructive commands use the central session approval and sandbox policy.',
8
9
  parameters: {
9
10
  type: 'object',
10
11
  properties: {
@@ -23,8 +24,9 @@ export const gitExec = {
23
24
  return { success: false, error: 'Interactive workflows (e.g., rebase -i) are strictly forbidden in AGI automation. Use precise non-interactive commands.' };
24
25
  }
25
26
 
26
- if (cmdString.includes('push -f') || cmdString.includes('push --force') || cmdString.includes('branch -D')) {
27
- return { success: false, error: '[HITL_APPROVAL_REQUIRED] Destructive Git action detected. You must ask the user for explicit permission before running this.' };
27
+ if ((cmdString.includes('push -f') || cmdString.includes('push --force') || cmdString.includes('branch -D'))
28
+ && currentToolAutonomyMode() === undefined) {
29
+ return { success: false, error: 'Destructive Git action requires the agent session approval and sandbox policy.' };
28
30
  }
29
31
 
30
32
  const command = `git ${cmdString}`;
@@ -3,6 +3,7 @@ import path from 'node:path';
3
3
  import { spawn } from 'node:child_process';
4
4
  import { NATIVE_ENGINES, engineInstallDir, findEngineBinary, engineVersion, nativeEngine, runEngineBinary } from '../engines/registry.js';
5
5
  import { defaultEngineManifestUrl, installNativeEngine } from '../engines/installer.js';
6
+ import { isAutonomousToolContext } from '../approvalPolicy.js';
6
7
  const ACTIONS = [
7
8
  'status', 'catalog', 'describe', 'inspect', 'execute', 'batch', 'export', 'render', 'probe', 'install'
8
9
  ];
@@ -329,7 +330,7 @@ async function engineStatus(workspace, signal) {
329
330
  export const nativeEngineTool = {
330
331
  schema: {
331
332
  name: 'native_engine',
332
- description: 'Run an installed headless native engine directly. No MCP, no GUI automation, no screenshots. Start with status, then catalog. Use execute or batch with command ids from catalog; project/saveAs scope the document. export and render return artifact paths for immediate GUI/TUI preview. probe inspects media. If the engine is missing, install only after explicit user consent; install never downloads silently. Set open=true only when the user wants the artifact revealed in the OS.',
333
+ description: 'Run an installed headless native engine directly. No MCP, no GUI automation, no screenshots. Start with status, then catalog. Use execute or batch with command ids from catalog; project/saveAs scope the document. export and render return artifact paths for immediate GUI/TUI preview. probe inspects media. An in-scope install is authorized by Mode C; supervised modes require explicit confirmation. Set open=true only when the user wants the artifact revealed in the OS.',
333
334
  parameters: {
334
335
  type: 'object',
335
336
  properties: {
@@ -369,7 +370,7 @@ export const nativeEngineTool = {
369
370
  keepGoing: { type: 'boolean', description: 'Batch continues after a failed command.' },
370
371
  query: { type: 'string', description: 'Catalog filter, inspect target, or media path for probe.' },
371
372
  open: { type: 'boolean', description: 'Reveal the resulting artifact in the OS after success.' },
372
- confirm: { type: 'boolean', description: 'Explicit consent to download and install a missing engine. install without confirm only describes the download.' }
373
+ confirm: { type: 'boolean', description: 'Explicit confirmation in supervised modes. Mode C authorizes in-scope installs without this flag.' }
373
374
  },
374
375
  required: ['action'],
375
376
  additionalProperties: false
@@ -387,7 +388,7 @@ export const nativeEngineTool = {
387
388
  return { success: false, error: `Unknown engine: ${request.engine}`, available: Object.keys(NATIVE_ENGINES) };
388
389
  if (request.action === 'install') {
389
390
  return await installNativeEngine(adapter, {
390
- confirm: request.confirm === true,
391
+ confirm: request.confirm === true || isAutonomousToolContext(context),
391
392
  ...(context.signal ? { signal: context.signal } : {})
392
393
  });
393
394
  }
@@ -10,6 +10,7 @@ import {
10
10
  runEngineBinary
11
11
  } from '../engines/registry.js';
12
12
  import { defaultEngineManifestUrl, installNativeEngine } from '../engines/installer.js';
13
+ import { isAutonomousToolContext } from '../approvalPolicy.js';
13
14
  import type {
14
15
  NativeEngineAction,
15
16
  NativeEngineAdapter,
@@ -30,6 +31,7 @@ const OUTPUT_KEYS = new Set(['output', 'outputPath', 'out', 'outputFile']);
30
31
  type ToolContext = {
31
32
  signal?: AbortSignal;
32
33
  workspacePaths?: string[];
34
+ parentLoop?: unknown;
33
35
  };
34
36
 
35
37
  function object(value: unknown, name: string): Record<string, unknown> {
@@ -304,7 +306,7 @@ async function engineStatus(workspace: string, signal?: AbortSignal): Promise<Re
304
306
  export const nativeEngineTool = {
305
307
  schema: {
306
308
  name: 'native_engine',
307
- description: 'Run an installed headless native engine directly. No MCP, no GUI automation, no screenshots. Start with status, then catalog. Use execute or batch with command ids from catalog; project/saveAs scope the document. export and render return artifact paths for immediate GUI/TUI preview. probe inspects media. If the engine is missing, install only after explicit user consent; install never downloads silently. Set open=true only when the user wants the artifact revealed in the OS.',
309
+ description: 'Run an installed headless native engine directly. No MCP, no GUI automation, no screenshots. Start with status, then catalog. Use execute or batch with command ids from catalog; project/saveAs scope the document. export and render return artifact paths for immediate GUI/TUI preview. probe inspects media. An in-scope install is authorized by Mode C; supervised modes require explicit confirmation. Set open=true only when the user wants the artifact revealed in the OS.',
308
310
  parameters: {
309
311
  type: 'object',
310
312
  properties: {
@@ -344,7 +346,7 @@ export const nativeEngineTool = {
344
346
  keepGoing: { type: 'boolean', description: 'Batch continues after a failed command.' },
345
347
  query: { type: 'string', description: 'Catalog filter, inspect target, or media path for probe.' },
346
348
  open: { type: 'boolean', description: 'Reveal the resulting artifact in the OS after success.' },
347
- confirm: { type: 'boolean', description: 'Explicit consent to download and install a missing engine. install without confirm only describes the download.' }
349
+ confirm: { type: 'boolean', description: 'Explicit confirmation in supervised modes. Mode C authorizes in-scope installs without this flag.' }
348
350
  },
349
351
  required: ['action'],
350
352
  additionalProperties: false
@@ -361,7 +363,7 @@ export const nativeEngineTool = {
361
363
  if (!adapter) return { success: false, error: `Unknown engine: ${request.engine}`, available: Object.keys(NATIVE_ENGINES) };
362
364
  if (request.action === 'install') {
363
365
  return await installNativeEngine(adapter, {
364
- confirm: request.confirm === true,
366
+ confirm: request.confirm === true || isAutonomousToolContext(context),
365
367
  ...(context.signal ? { signal: context.signal } : {})
366
368
  });
367
369
  }
@@ -5,6 +5,7 @@ import path from 'node:path';
5
5
  import { execFile } from 'node:child_process';
6
6
  import util from 'node:util';
7
7
  import { causyneHome, resolveUserPath } from '../utils/paths.js';
8
+ import { isAutonomousToolContext } from '../approvalPolicy.js';
8
9
  const execFilePromise = util.promisify(execFile);
9
10
  export const CURATED_OPEN_SOURCE_CATALOGUE = {
10
11
  'f5-tts': {
@@ -244,7 +245,7 @@ export function searchCatalogue(intentOrQuery) {
244
245
  export const openSourceToolProvisioner = {
245
246
  schema: {
246
247
  name: 'open_source_tool_provisioner',
247
- description: 'Discover, evaluate compute/RAM hardware compatibility, and install sovereign open-source AI tools & models (voice cloning, TTS, speech-to-text, vision upscaling, local LLMs). Evaluates user hardware specs (RAM, CPU, GPU/MPS, disk) first and enforces Human-In-The-Loop (HITL) approval before any installation.',
248
+ description: 'Discover, evaluate hardware compatibility, and install open-source AI tools and models. Mode C authorizes in-scope installs; supervised modes require confirmation. Hardware, disk, and workspace checks still apply.',
248
249
  parameters: {
249
250
  type: 'object',
250
251
  properties: {
@@ -263,7 +264,7 @@ export const openSourceToolProvisioner = {
263
264
  },
264
265
  confirm: {
265
266
  type: 'boolean',
266
- description: 'Mandatory Human-In-The-Loop (HITL) consent flag. Must be set to true only after obtaining explicit user agreement.'
267
+ description: 'Explicit confirmation for supervised modes. Mode C authorizes in-scope installs without this flag.'
267
268
  },
268
269
  forceAlternative: {
269
270
  type: 'boolean',
@@ -277,7 +278,7 @@ export const openSourceToolProvisioner = {
277
278
  const action = String(args['action'] || 'discover');
278
279
  const intent = typeof args['intent'] === 'string' ? args['intent'] : '';
279
280
  let toolId = typeof args['toolId'] === 'string' ? args['toolId'].toLowerCase().trim() : '';
280
- const confirm = args['confirm'] === true;
281
+ const confirm = args['confirm'] === true || isAutonomousToolContext(sandbox);
281
282
  const forceAlternative = args['forceAlternative'] === true;
282
283
  const workspaceDir = (Array.isArray(sandbox['workspacePaths']) && sandbox['workspacePaths'][0])
283
284
  ? String(sandbox['workspacePaths'][0])
@@ -331,7 +332,7 @@ export const openSourceToolProvisioner = {
331
332
  diskSpace: specs.diskSpaceText
332
333
  },
333
334
  recommendations: evaluations,
334
- instruction: 'To install a candidate, review specs with the user, obtain HITL consent, and invoke with action: "install", toolId: "<id>", confirm: true.'
335
+ instruction: 'To install a candidate, review the hardware assessment and invoke with action: "install", toolId: "<id>". Supervised modes require explicit confirmation.'
335
336
  };
336
337
  }
337
338
  // ── ACTION: EVALUATE ──────────────────────────────────────────────────
@@ -5,6 +5,7 @@ import path from 'node:path';
5
5
  import { execFile } from 'node:child_process';
6
6
  import util from 'node:util';
7
7
  import { causyneHome, resolveUserPath } from '../utils/paths.js';
8
+ import { isAutonomousToolContext } from '../approvalPolicy.js';
8
9
 
9
10
  const execFilePromise = util.promisify(execFile);
10
11
 
@@ -299,7 +300,7 @@ export function searchCatalogue(intentOrQuery: string): OpenSourceToolProfile[]
299
300
  export const openSourceToolProvisioner = {
300
301
  schema: {
301
302
  name: 'open_source_tool_provisioner',
302
- description: 'Discover, evaluate compute/RAM hardware compatibility, and install sovereign open-source AI tools & models (voice cloning, TTS, speech-to-text, vision upscaling, local LLMs). Evaluates user hardware specs (RAM, CPU, GPU/MPS, disk) first and enforces Human-In-The-Loop (HITL) approval before any installation.',
303
+ description: 'Discover, evaluate hardware compatibility, and install open-source AI tools and models. Mode C authorizes in-scope installs; supervised modes require confirmation. Hardware, disk, and workspace checks still apply.',
303
304
  parameters: {
304
305
  type: 'object',
305
306
  properties: {
@@ -318,7 +319,7 @@ export const openSourceToolProvisioner = {
318
319
  },
319
320
  confirm: {
320
321
  type: 'boolean',
321
- description: 'Mandatory Human-In-The-Loop (HITL) consent flag. Must be set to true only after obtaining explicit user agreement.'
322
+ description: 'Explicit confirmation for supervised modes. Mode C authorizes in-scope installs without this flag.'
322
323
  },
323
324
  forceAlternative: {
324
325
  type: 'boolean',
@@ -333,7 +334,7 @@ export const openSourceToolProvisioner = {
333
334
  const action = String(args['action'] || 'discover');
334
335
  const intent = typeof args['intent'] === 'string' ? args['intent'] : '';
335
336
  let toolId = typeof args['toolId'] === 'string' ? args['toolId'].toLowerCase().trim() : '';
336
- const confirm = args['confirm'] === true;
337
+ const confirm = args['confirm'] === true || isAutonomousToolContext(sandbox);
337
338
  const forceAlternative = args['forceAlternative'] === true;
338
339
 
339
340
  const workspaceDir = (Array.isArray(sandbox['workspacePaths']) && sandbox['workspacePaths'][0])
@@ -393,7 +394,7 @@ export const openSourceToolProvisioner = {
393
394
  diskSpace: specs.diskSpaceText
394
395
  },
395
396
  recommendations: evaluations,
396
- instruction: 'To install a candidate, review specs with the user, obtain HITL consent, and invoke with action: "install", toolId: "<id>", confirm: true.'
397
+ instruction: 'To install a candidate, review the hardware assessment and invoke with action: "install", toolId: "<id>". Supervised modes require explicit confirmation.'
397
398
  };
398
399
  }
399
400
 
@@ -77,6 +77,7 @@ import { createSkill } from './createSkill.js';
77
77
  import { resolveActiveTools } from '../toolPacks.js';
78
78
  import { discoverTools, resolveMcpTool, isMcpToolName } from '../mcp/mcpRegistry.js';
79
79
  import { getPluginToolDefinitions, resolvePluginTool } from '../plugins/pluginManager.js';
80
+ import { canonicalizeToolName } from './toolSelfRepair.js';
80
81
 
81
82
  // Phase 6 AGI Upgrade: Schema Validation Hook
82
83
  function validateSchema(schema) {
@@ -294,6 +295,8 @@ export function canonicalToolName(name) {
294
295
  const normalized = normalizeToolName(name);
295
296
  if (toolRegistry[normalized]) return normalized;
296
297
  if (TOOL_ALIASES[normalized]) return TOOL_ALIASES[normalized];
298
+ const fromSelfRepair = canonicalizeToolName(name);
299
+ if (toolRegistry[fromSelfRepair]) return fromSelfRepair;
297
300
  const fuzzy = DELIMITER_FREE_INDEX[stripDelimiters(name)];
298
301
  if (fuzzy && toolRegistry[fuzzy]) return fuzzy;
299
302
  return normalized;