@agent-native/core 0.18.1 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -11
- package/dist/a2a/caller-auth.d.ts +1 -0
- package/dist/a2a/caller-auth.d.ts.map +1 -1
- package/dist/a2a/caller-auth.js +1 -1
- package/dist/a2a/caller-auth.js.map +1 -1
- package/dist/a2a/client.d.ts +7 -0
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +3 -0
- package/dist/a2a/client.js.map +1 -1
- package/dist/agent/production-agent.d.ts +1 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +34 -2
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +47 -256
- package/dist/cli/code-agent-executor.js.map +1 -1
- package/dist/cli/connect.d.ts +94 -0
- package/dist/cli/connect.d.ts.map +1 -0
- package/dist/cli/connect.js +443 -0
- package/dist/cli/connect.js.map +1 -0
- package/dist/cli/index.js +16 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/mcp-config-writers.d.ts +71 -0
- package/dist/cli/mcp-config-writers.d.ts.map +1 -0
- package/dist/cli/mcp-config-writers.js +210 -0
- package/dist/cli/mcp-config-writers.js.map +1 -0
- package/dist/client/AgentPanel.d.ts +3 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +4 -4
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +3 -0
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +22 -66
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +4 -1
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/composer/PromptComposer.d.ts +6 -1
- package/dist/client/composer/PromptComposer.d.ts.map +1 -1
- package/dist/client/composer/PromptComposer.js +5 -4
- package/dist/client/composer/PromptComposer.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts +6 -1
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +20 -10
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/conversation/AgentConversation.d.ts +18 -0
- package/dist/client/conversation/AgentConversation.d.ts.map +1 -0
- package/dist/client/conversation/AgentConversation.js +94 -0
- package/dist/client/conversation/AgentConversation.js.map +1 -0
- package/dist/client/conversation/AgentConversation.spec.d.ts +2 -0
- package/dist/client/conversation/AgentConversation.spec.d.ts.map +1 -0
- package/dist/client/conversation/AgentConversation.spec.js +69 -0
- package/dist/client/conversation/AgentConversation.spec.js.map +1 -0
- package/dist/client/conversation/index.d.ts +4 -0
- package/dist/client/conversation/index.d.ts.map +1 -0
- package/dist/client/conversation/index.js +3 -0
- package/dist/client/conversation/index.js.map +1 -0
- package/dist/client/conversation/types.d.ts +54 -0
- package/dist/client/conversation/types.d.ts.map +1 -0
- package/dist/client/conversation/types.js +2 -0
- package/dist/client/conversation/types.js.map +1 -0
- package/dist/client/conversation/use-near-bottom-autoscroll.d.ts +15 -0
- package/dist/client/conversation/use-near-bottom-autoscroll.d.ts.map +1 -0
- package/dist/client/conversation/use-near-bottom-autoscroll.js +66 -0
- package/dist/client/conversation/use-near-bottom-autoscroll.js.map +1 -0
- package/dist/client/dynamic-suggestions.d.ts +43 -0
- package/dist/client/dynamic-suggestions.d.ts.map +1 -0
- package/dist/client/dynamic-suggestions.js +344 -0
- package/dist/client/dynamic-suggestions.js.map +1 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/resources/ResourceTree.d.ts.map +1 -1
- package/dist/client/resources/ResourceTree.js +2 -2
- package/dist/client/resources/ResourceTree.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +4 -28
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/client/settings/SettingsPanel.js +2 -2
- package/dist/client/settings/SettingsPanel.js.map +1 -1
- package/dist/code-agents/index.d.ts +1 -0
- package/dist/code-agents/index.d.ts.map +1 -1
- package/dist/code-agents/index.js +1 -0
- package/dist/code-agents/index.js.map +1 -1
- package/dist/code-agents/transcript-normalizer.d.ts +50 -0
- package/dist/code-agents/transcript-normalizer.d.ts.map +1 -0
- package/dist/code-agents/transcript-normalizer.js +356 -0
- package/dist/code-agents/transcript-normalizer.js.map +1 -0
- package/dist/coding-tools/index.d.ts +31 -0
- package/dist/coding-tools/index.d.ts.map +1 -0
- package/dist/coding-tools/index.js +411 -0
- package/dist/coding-tools/index.js.map +1 -0
- package/dist/extensions/schema.d.ts +1 -1
- package/dist/mcp/build-server.d.ts.map +1 -1
- package/dist/mcp/build-server.js +30 -0
- package/dist/mcp/build-server.js.map +1 -1
- package/dist/mcp/builtin-tools.d.ts.map +1 -1
- package/dist/mcp/builtin-tools.js +85 -26
- package/dist/mcp/builtin-tools.js.map +1 -1
- package/dist/mcp/connect-route.d.ts +43 -0
- package/dist/mcp/connect-route.d.ts.map +1 -0
- package/dist/mcp/connect-route.js +744 -0
- package/dist/mcp/connect-route.js.map +1 -0
- package/dist/mcp/connect-store.d.ts +132 -0
- package/dist/mcp/connect-store.d.ts.map +1 -0
- package/dist/mcp/connect-store.js +434 -0
- package/dist/mcp/connect-store.js.map +1 -0
- package/dist/mcp/org-directory.d.ts +83 -0
- package/dist/mcp/org-directory.d.ts.map +1 -0
- package/dist/mcp/org-directory.js +201 -0
- package/dist/mcp/org-directory.js.map +1 -0
- package/dist/mcp/server.d.ts +38 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +208 -77
- package/dist/mcp/server.js.map +1 -1
- package/dist/scripts/dev/index.d.ts +6 -4
- package/dist/scripts/dev/index.d.ts.map +1 -1
- package/dist/scripts/dev/index.js +28 -13
- package/dist/scripts/dev/index.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +6 -6
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +32 -32
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-teams.js +2 -2
- package/dist/server/agent-teams.js.map +1 -1
- package/dist/server/agents-bundle.d.ts +3 -3
- package/dist/server/agents-bundle.js +5 -5
- package/dist/server/agents-bundle.js.map +1 -1
- package/dist/server/auth.d.ts +17 -0
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +149 -33
- package/dist/server/auth.js.map +1 -1
- package/dist/server/better-auth-instance.d.ts +43 -0
- package/dist/server/better-auth-instance.d.ts.map +1 -1
- package/dist/server/better-auth-instance.js +25 -0
- package/dist/server/better-auth-instance.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts +12 -0
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +42 -0
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/identity-sso-store.d.ts +86 -0
- package/dist/server/identity-sso-store.d.ts.map +1 -0
- package/dist/server/identity-sso-store.js +243 -0
- package/dist/server/identity-sso-store.js.map +1 -0
- package/dist/server/identity-sso.d.ts +78 -0
- package/dist/server/identity-sso.d.ts.map +1 -0
- package/dist/server/identity-sso.js +425 -0
- package/dist/server/identity-sso.js.map +1 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +2 -1
- package/dist/server/onboarding-html.js.map +1 -1
- package/dist/server/sentry.d.ts.map +1 -1
- package/dist/server/sentry.js +17 -2
- package/dist/server/sentry.js.map +1 -1
- package/dist/sharing/schema.d.ts +1 -1
- package/docs/content/client.md +15 -0
- package/docs/content/code-agents-ui.md +25 -4
- package/docs/content/cross-app-sso.md +118 -0
- package/docs/content/drop-in-agent.md +3 -1
- package/docs/content/external-agents.md +130 -51
- package/docs/content/frames.md +1 -1
- package/docs/content/migration-workbench.md +6 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-agent-executor.d.ts","sourceRoot":"","sources":["../../src/cli/code-agent-executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"code-agent-executor.d.ts","sourceRoot":"","sources":["../../src/cli/code-agent-executor.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EACV,WAAW,EAKZ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC/B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAeD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAqSpC;AAED,wBAAsB,2BAA2B,CAC/C,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,IAAI,CAAC,0BAA0B,EAAE,OAAO,CAAM,GACtD,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAEpC;AAED,wBAAsB,+BAA+B,CACnD,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAA;CAAO,GAC/C,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CA0FpC;AA6OD,MAAM,MAAM,0BAA0B,GAClC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,MAAM,GACd,0BAA0B,CAuD5B"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { once } from "node:events";
|
|
5
1
|
import { createToolSearchEntry, TOOL_SEARCH_ACTION_NAME, } from "../agent/tool-search.js";
|
|
2
|
+
import { createCodingToolRegistry, isReadOnlyShellCommand, runCodingCommand, truncateCodingOutput, } from "../coding-tools/index.js";
|
|
6
3
|
import { buildMergedConfig, McpClientManager, mcpToolsToActionEntries, } from "../mcp-client/index.js";
|
|
7
4
|
import { runWithRequestContext } from "../server/request-context.js";
|
|
8
5
|
import { actionsToEngineTools, runAgentLoop, } from "../agent/production-agent.js";
|
|
@@ -144,7 +141,7 @@ export async function executeCodeAgentRun(options) {
|
|
|
144
141
|
metadata: {
|
|
145
142
|
type: "tool_done",
|
|
146
143
|
tool: event.tool,
|
|
147
|
-
result:
|
|
144
|
+
result: truncateCodingOutput(event.result, 4000),
|
|
148
145
|
},
|
|
149
146
|
});
|
|
150
147
|
return;
|
|
@@ -338,8 +335,8 @@ export async function executePendingCodeAgentApproval(runId, options = {}) {
|
|
|
338
335
|
command: approval.command,
|
|
339
336
|
},
|
|
340
337
|
});
|
|
341
|
-
const result = await
|
|
342
|
-
const summary =
|
|
338
|
+
const result = await runCodingCommand(approval.command, record.cwd || process.cwd(), DEFAULT_COMMAND_TIMEOUT_MS);
|
|
339
|
+
const summary = truncateCodingOutput([
|
|
343
340
|
`Approved command finished with exit code ${result.code}.`,
|
|
344
341
|
result.timedOut ? "Timed out: true" : "",
|
|
345
342
|
result.stdout ? `stdout:\n${result.stdout}` : "",
|
|
@@ -534,7 +531,8 @@ Work like a careful senior engineer:
|
|
|
534
531
|
- In Auto mode, edit files and run ordinary project commands without pausing. Pause only for genuinely destructive operations such as recursive deletes, package publishing, privileged commands, destructive database operations, or forbidden git branch/reset/stash/rebase operations.
|
|
535
532
|
- Do not create, switch, delete, reset, rebase, or stash git branches.
|
|
536
533
|
- Do not run destructive git commands.
|
|
537
|
-
- Use
|
|
534
|
+
- Use the shared coding tools: bash for search/list/test/build commands, read for file reads, edit for exact replacement edits, and write only for new files or intentional full rewrites.
|
|
535
|
+
- Prefer edit over write when changing existing files, then run focused verification with bash.
|
|
538
536
|
- Use tool-search when you need a capability that may come from MCP, including browser automation or computer control.
|
|
539
537
|
- Prefer Playwright MCP for deterministic browser testing; prefer Chrome DevTools MCP when the user needs their live logged-in Chrome session.
|
|
540
538
|
- Only use computer-control MCP tools when they are explicitly available and the user request warrants controlling the local computer.
|
|
@@ -542,192 +540,45 @@ Work like a careful senior engineer:
|
|
|
542
540
|
- Respect any AGENTS.md instructions in the repository.`;
|
|
543
541
|
}
|
|
544
542
|
function createLocalCodeAgentActions(cwd, permissionMode, runId) {
|
|
545
|
-
const actions = {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
},
|
|
560
|
-
},
|
|
561
|
-
run: async (args) => {
|
|
562
|
-
const result = await runCommand("rg --files", cwd, 30_000);
|
|
563
|
-
const output = result.code === 0
|
|
564
|
-
? result.stdout
|
|
565
|
-
: (await runCommand("find . -type f | sed 's#^./##'", cwd, 30_000))
|
|
566
|
-
.stdout;
|
|
567
|
-
const pattern = stringArg(args.pattern).toLowerCase();
|
|
568
|
-
const files = output
|
|
569
|
-
.split(/\r?\n/)
|
|
570
|
-
.filter(Boolean)
|
|
571
|
-
.filter((file) => !pattern || file.toLowerCase().includes(pattern))
|
|
572
|
-
.slice(0, 500);
|
|
573
|
-
return files.join("\n") || "(no files found)";
|
|
574
|
-
},
|
|
575
|
-
},
|
|
576
|
-
search_files: {
|
|
577
|
-
readOnly: true,
|
|
578
|
-
tool: {
|
|
579
|
-
description: "Search files with ripgrep.",
|
|
580
|
-
parameters: {
|
|
581
|
-
type: "object",
|
|
582
|
-
properties: {
|
|
583
|
-
query: { type: "string", description: "Search query or regex." },
|
|
584
|
-
glob: {
|
|
585
|
-
type: "string",
|
|
586
|
-
description: "Optional glob, for example src/**/*.ts.",
|
|
587
|
-
},
|
|
588
|
-
},
|
|
589
|
-
required: ["query"],
|
|
590
|
-
},
|
|
591
|
-
},
|
|
592
|
-
run: async (args) => {
|
|
593
|
-
const query = stringArg(args.query);
|
|
594
|
-
if (!query)
|
|
595
|
-
return "Error: query is required.";
|
|
596
|
-
const glob = stringArg(args.glob);
|
|
597
|
-
const command = glob
|
|
598
|
-
? `rg --line-number --no-heading ${shellQuote(query)} -g ${shellQuote(glob)}`
|
|
599
|
-
: `rg --line-number --no-heading ${shellQuote(query)}`;
|
|
600
|
-
const result = await runCommand(command, cwd, 30_000);
|
|
601
|
-
return truncate(result.stdout || result.stderr || "(no matches)", MAX_TOOL_OUTPUT_CHARS);
|
|
602
|
-
},
|
|
603
|
-
},
|
|
604
|
-
read_file: {
|
|
605
|
-
readOnly: true,
|
|
606
|
-
tool: {
|
|
607
|
-
description: "Read a UTF-8 text file inside the workspace.",
|
|
608
|
-
parameters: {
|
|
609
|
-
type: "object",
|
|
610
|
-
properties: {
|
|
611
|
-
path: { type: "string", description: "Relative file path." },
|
|
612
|
-
},
|
|
613
|
-
required: ["path"],
|
|
614
|
-
},
|
|
615
|
-
},
|
|
616
|
-
run: async (args) => {
|
|
617
|
-
const filePath = resolveInsideCwd(cwd, stringArg(args.path));
|
|
618
|
-
if (!filePath)
|
|
619
|
-
return "Error: path must stay inside the workspace.";
|
|
620
|
-
if (!fs.existsSync(filePath))
|
|
621
|
-
return `Error: file not found: ${args.path}`;
|
|
622
|
-
const stat = fs.statSync(filePath);
|
|
623
|
-
if (!stat.isFile())
|
|
624
|
-
return `Error: not a file: ${args.path}`;
|
|
625
|
-
return truncate(fs.readFileSync(filePath, "utf8"), MAX_FILE_READ_CHARS);
|
|
626
|
-
},
|
|
627
|
-
},
|
|
628
|
-
write_file: {
|
|
629
|
-
tool: {
|
|
630
|
-
description: "Write a complete UTF-8 text file inside the workspace.",
|
|
631
|
-
parameters: {
|
|
632
|
-
type: "object",
|
|
633
|
-
properties: {
|
|
634
|
-
path: { type: "string", description: "Relative file path." },
|
|
635
|
-
content: { type: "string", description: "Full file content." },
|
|
636
|
-
},
|
|
637
|
-
required: ["path", "content"],
|
|
638
|
-
},
|
|
639
|
-
},
|
|
640
|
-
run: async (args) => {
|
|
641
|
-
const permissionError = permissionErrorForWrite(permissionMode, "write_file");
|
|
642
|
-
if (permissionError)
|
|
643
|
-
return permissionError;
|
|
644
|
-
const filePath = resolveInsideCwd(cwd, stringArg(args.path));
|
|
645
|
-
if (!filePath)
|
|
646
|
-
return "Error: path must stay inside the workspace.";
|
|
647
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
648
|
-
fs.writeFileSync(filePath, stringArg(args.content));
|
|
649
|
-
return `Wrote ${path.relative(cwd, filePath)}`;
|
|
650
|
-
},
|
|
651
|
-
},
|
|
652
|
-
apply_patch: {
|
|
653
|
-
tool: {
|
|
654
|
-
description: "Apply a unified git patch from the workspace root. Prefer this for precise edits.",
|
|
655
|
-
parameters: {
|
|
656
|
-
type: "object",
|
|
657
|
-
properties: {
|
|
658
|
-
patch: { type: "string", description: "Unified diff patch text." },
|
|
659
|
-
},
|
|
660
|
-
required: ["patch"],
|
|
661
|
-
},
|
|
662
|
-
},
|
|
663
|
-
run: async (args) => {
|
|
664
|
-
const permissionError = permissionErrorForWrite(permissionMode, "apply_patch");
|
|
543
|
+
const actions = createCodingToolRegistry({
|
|
544
|
+
cwd,
|
|
545
|
+
restrictToCwd: true,
|
|
546
|
+
commandTimeoutMs: DEFAULT_COMMAND_TIMEOUT_MS,
|
|
547
|
+
maxOutputChars: MAX_TOOL_OUTPUT_CHARS,
|
|
548
|
+
maxFileReadChars: MAX_FILE_READ_CHARS,
|
|
549
|
+
canWrite: (toolName) => permissionErrorForWrite(permissionMode, toolName),
|
|
550
|
+
beforeBash: ({ command }) => {
|
|
551
|
+
const permission = classifyCodeAgentCommandPermission(command);
|
|
552
|
+
if (permission.kind === "forbidden") {
|
|
553
|
+
return `Error: command is blocked by Agent-Native Code policy: ${permission.reason}`;
|
|
554
|
+
}
|
|
555
|
+
if (permission.kind !== "read") {
|
|
556
|
+
const permissionError = permissionErrorForWrite(permissionMode, "bash");
|
|
665
557
|
if (permissionError)
|
|
666
558
|
return permissionError;
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
command: { type: "string", description: "Shell command to run." },
|
|
684
|
-
timeoutMs: {
|
|
685
|
-
type: "string",
|
|
686
|
-
description: "Optional timeout in milliseconds.",
|
|
687
|
-
},
|
|
688
|
-
},
|
|
689
|
-
required: ["command"],
|
|
690
|
-
},
|
|
691
|
-
},
|
|
692
|
-
run: async (args) => {
|
|
693
|
-
const command = stringArg(args.command);
|
|
694
|
-
if (!command)
|
|
695
|
-
return "Error: command is required.";
|
|
696
|
-
const permission = classifyCodeAgentCommandPermission(command);
|
|
697
|
-
if (permission.kind === "forbidden") {
|
|
698
|
-
return `Error: command is blocked by Agent-Native Code policy: ${permission.reason}`;
|
|
699
|
-
}
|
|
700
|
-
if (permission.kind === "approval-required") {
|
|
701
|
-
const approval = requestCodeAgentApproval(runId, {
|
|
702
|
-
tool: "run_command",
|
|
703
|
-
command,
|
|
704
|
-
reason: permission.reason,
|
|
705
|
-
permissionMode,
|
|
706
|
-
});
|
|
707
|
-
return [
|
|
708
|
-
`Approval required before running this command: ${permission.reason}.`,
|
|
709
|
-
`Approval id: ${approval.id}`,
|
|
710
|
-
`Command: ${command}`,
|
|
711
|
-
"The run is paused; approve from the Agent-Native Code UI/CLI if this command is intentional.",
|
|
712
|
-
].join("\n");
|
|
713
|
-
}
|
|
714
|
-
const timeoutMs = Number(args.timeoutMs);
|
|
715
|
-
const result = await runCommand(command, cwd, Number.isFinite(timeoutMs) && timeoutMs > 0
|
|
716
|
-
? Math.min(timeoutMs, 10 * 60_000)
|
|
717
|
-
: DEFAULT_COMMAND_TIMEOUT_MS);
|
|
718
|
-
return truncate([
|
|
719
|
-
`exitCode: ${result.code}`,
|
|
720
|
-
result.timedOut ? "timedOut: true" : "",
|
|
721
|
-
result.stdout ? `stdout:\n${result.stdout}` : "",
|
|
722
|
-
result.stderr ? `stderr:\n${result.stderr}` : "",
|
|
723
|
-
]
|
|
724
|
-
.filter(Boolean)
|
|
725
|
-
.join("\n\n"), MAX_TOOL_OUTPUT_CHARS);
|
|
726
|
-
},
|
|
559
|
+
}
|
|
560
|
+
if (permission.kind === "approval-required") {
|
|
561
|
+
const approval = requestCodeAgentApproval(runId, {
|
|
562
|
+
tool: "bash",
|
|
563
|
+
command,
|
|
564
|
+
reason: permission.reason,
|
|
565
|
+
permissionMode,
|
|
566
|
+
});
|
|
567
|
+
return [
|
|
568
|
+
`Approval required before running this command: ${permission.reason}.`,
|
|
569
|
+
`Approval id: ${approval.id}`,
|
|
570
|
+
`Command: ${command}`,
|
|
571
|
+
"The run is paused; approve from the Agent-Native Code UI/CLI if this command is intentional.",
|
|
572
|
+
].join("\n");
|
|
573
|
+
}
|
|
574
|
+
return null;
|
|
727
575
|
},
|
|
728
|
-
};
|
|
576
|
+
});
|
|
729
577
|
if (permissionMode === "read-only") {
|
|
730
|
-
return
|
|
578
|
+
return {
|
|
579
|
+
bash: actions.bash,
|
|
580
|
+
read: actions.read,
|
|
581
|
+
};
|
|
731
582
|
}
|
|
732
583
|
return actions;
|
|
733
584
|
}
|
|
@@ -767,23 +618,7 @@ export function classifyCodeAgentCommandPermission(command) {
|
|
|
767
618
|
return { kind: "approval-required", reason };
|
|
768
619
|
}
|
|
769
620
|
}
|
|
770
|
-
|
|
771
|
-
/^pwd\b/,
|
|
772
|
-
/^ls\b/,
|
|
773
|
-
/^find\b/,
|
|
774
|
-
/^rg\b/,
|
|
775
|
-
/^grep\b/,
|
|
776
|
-
/^cat\b/,
|
|
777
|
-
/^sed\s+-n\b/,
|
|
778
|
-
/^head\b/,
|
|
779
|
-
/^tail\b/,
|
|
780
|
-
/^wc\b/,
|
|
781
|
-
/^git\s+(status|diff|show|log)\b/,
|
|
782
|
-
/^git\s+branch\s+--show-current\b/,
|
|
783
|
-
/^pnpm\b.*\b(test|typecheck|lint|check)\b/,
|
|
784
|
-
/^npm\b.*\b(test|run\s+(test|typecheck|lint|check))\b/,
|
|
785
|
-
];
|
|
786
|
-
if (readPatterns.some((pattern) => pattern.test(normalized))) {
|
|
621
|
+
if (isReadOnlyShellCommand(command)) {
|
|
787
622
|
return { kind: "read" };
|
|
788
623
|
}
|
|
789
624
|
const writePatterns = [
|
|
@@ -850,7 +685,10 @@ function getPendingApproval(runId) {
|
|
|
850
685
|
if (!approval || typeof approval !== "object")
|
|
851
686
|
return null;
|
|
852
687
|
const candidate = approval;
|
|
853
|
-
|
|
688
|
+
const tool = candidate.tool === "bash" || candidate.tool === "run_command"
|
|
689
|
+
? candidate.tool
|
|
690
|
+
: null;
|
|
691
|
+
if (!tool ||
|
|
854
692
|
typeof candidate.command !== "string" ||
|
|
855
693
|
typeof candidate.reason !== "string" ||
|
|
856
694
|
typeof candidate.id !== "string" ||
|
|
@@ -859,7 +697,7 @@ function getPendingApproval(runId) {
|
|
|
859
697
|
}
|
|
860
698
|
return {
|
|
861
699
|
id: candidate.id,
|
|
862
|
-
tool
|
|
700
|
+
tool,
|
|
863
701
|
command: candidate.command,
|
|
864
702
|
reason: candidate.reason,
|
|
865
703
|
requestedAt: candidate.requestedAt,
|
|
@@ -871,51 +709,4 @@ function getPendingApproval(runId) {
|
|
|
871
709
|
: "full-auto",
|
|
872
710
|
};
|
|
873
711
|
}
|
|
874
|
-
function resolveInsideCwd(cwd, value) {
|
|
875
|
-
if (!value.trim())
|
|
876
|
-
return null;
|
|
877
|
-
const resolved = path.resolve(cwd, value);
|
|
878
|
-
const relative = path.relative(cwd, resolved);
|
|
879
|
-
if (relative.startsWith("..") || path.isAbsolute(relative))
|
|
880
|
-
return null;
|
|
881
|
-
return resolved;
|
|
882
|
-
}
|
|
883
|
-
async function runCommand(command, cwd, timeoutMs, stdin) {
|
|
884
|
-
const child = spawn(command, {
|
|
885
|
-
cwd,
|
|
886
|
-
shell: true,
|
|
887
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
888
|
-
});
|
|
889
|
-
let stdout = "";
|
|
890
|
-
let stderr = "";
|
|
891
|
-
let timedOut = false;
|
|
892
|
-
const timer = setTimeout(() => {
|
|
893
|
-
timedOut = true;
|
|
894
|
-
child.kill("SIGTERM");
|
|
895
|
-
}, timeoutMs);
|
|
896
|
-
child.stdout?.on("data", (chunk) => {
|
|
897
|
-
stdout += chunk.toString();
|
|
898
|
-
});
|
|
899
|
-
child.stderr?.on("data", (chunk) => {
|
|
900
|
-
stderr += chunk.toString();
|
|
901
|
-
});
|
|
902
|
-
if (stdin)
|
|
903
|
-
child.stdin?.end(stdin);
|
|
904
|
-
else
|
|
905
|
-
child.stdin?.end();
|
|
906
|
-
const [code] = (await once(child, "exit"));
|
|
907
|
-
clearTimeout(timer);
|
|
908
|
-
return { code, stdout, stderr, timedOut };
|
|
909
|
-
}
|
|
910
|
-
function stringArg(value) {
|
|
911
|
-
return typeof value === "string" ? value : "";
|
|
912
|
-
}
|
|
913
|
-
function shellQuote(value) {
|
|
914
|
-
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
915
|
-
}
|
|
916
|
-
function truncate(value, max) {
|
|
917
|
-
if (value.length <= max)
|
|
918
|
-
return value;
|
|
919
|
-
return `${value.slice(0, max)}\n\n...[truncated ${value.length - max} chars]`;
|
|
920
|
-
}
|
|
921
712
|
//# sourceMappingURL=code-agent-executor.js.map
|