@agent-native/core 0.49.25 → 0.49.27
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/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +8 -1
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/cli/recap.d.ts.map +1 -1
- package/dist/cli/recap.js +43 -11
- package/dist/cli/recap.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +2 -1
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/blocks/library/AnnotatedCodeBlock.js +7 -7
- package/dist/client/blocks/library/AnnotatedCodeBlock.js.map +1 -1
- package/dist/client/blocks/library/DiffBlock.js +3 -3
- package/dist/client/blocks/library/DiffBlock.js.map +1 -1
- package/dist/client/blocks/library/annotation-rail.d.ts +4 -3
- package/dist/client/blocks/library/annotation-rail.d.ts.map +1 -1
- package/dist/client/blocks/library/annotation-rail.js +16 -9
- package/dist/client/blocks/library/annotation-rail.js.map +1 -1
- package/dist/client/blocks/types.d.ts +2 -2
- package/dist/client/blocks/types.js.map +1 -1
- package/dist/coding-tools/run-code.d.ts.map +1 -1
- package/dist/coding-tools/run-code.js +198 -15
- package/dist/coding-tools/run-code.js.map +1 -1
- package/dist/extensions/fetch-tool.js +1 -1
- package/dist/extensions/fetch-tool.js.map +1 -1
- package/dist/file-upload/builder.d.ts.map +1 -1
- package/dist/file-upload/builder.js +115 -56
- package/dist/file-upload/builder.js.map +1 -1
- package/dist/mcp/build-server.d.ts.map +1 -1
- package/dist/mcp/build-server.js +1 -0
- package/dist/mcp/build-server.js.map +1 -1
- package/dist/mcp/builtin-tools.d.ts +8 -4
- package/dist/mcp/builtin-tools.d.ts.map +1 -1
- package/dist/mcp/builtin-tools.js +247 -13
- package/dist/mcp/builtin-tools.js.map +1 -1
- package/dist/provider-api/actions/query-staged-dataset.d.ts.map +1 -1
- package/dist/provider-api/actions/query-staged-dataset.js +1 -0
- package/dist/provider-api/actions/query-staged-dataset.js.map +1 -1
- package/dist/provider-api/index.d.ts +9 -4
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/provider-api/index.js +164 -33
- package/dist/provider-api/index.js.map +1 -1
- package/dist/provider-api/staged-datasets-store.d.ts.map +1 -1
- package/dist/provider-api/staged-datasets-store.js +29 -6
- package/dist/provider-api/staged-datasets-store.js.map +1 -1
- package/dist/provider-api/staging.d.ts +6 -1
- package/dist/provider-api/staging.d.ts.map +1 -1
- package/dist/provider-api/staging.js +35 -6
- package/dist/provider-api/staging.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +157 -80
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/prompts/shared-rules.d.ts +1 -1
- package/dist/server/prompts/shared-rules.d.ts.map +1 -1
- package/dist/server/prompts/shared-rules.js +5 -7
- package/dist/server/prompts/shared-rules.js.map +1 -1
- package/dist/server/schema-prompt.js +1 -1
- package/dist/server/schema-prompt.js.map +1 -1
- package/dist/templates/default/.agents/skills/actions/SKILL.md +16 -4
- package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +16 -4
- package/package.json +1 -1
- package/src/templates/default/.agents/skills/actions/SKILL.md +16 -4
- package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +16 -4
|
@@ -675,7 +675,7 @@ async function createDbScriptEntries() {
|
|
|
675
675
|
},
|
|
676
676
|
}, schemaMod.default, { readOnly: true }),
|
|
677
677
|
"db-query": wrapCliScript({
|
|
678
|
-
description: "Read from the app's own SQL database ONLY. Runs a SELECT against the app's internal tables (settings, application_state, template tables). Results are auto-scoped to the current user/org. IMPORTANT: This tool CANNOT access external data sources like
|
|
678
|
+
description: "Read from the app's own SQL database ONLY. Runs a SELECT against the app's internal tables (settings, application_state, template tables). Results are auto-scoped to the current user/org. IMPORTANT: This tool CANNOT access external data sources like data warehouses, CRMs, issue trackers, analytics platforms, calendars, mail, docs, or other third-party services. For those, use the relevant template/provider action, MCP connector, or provider-api-catalog/provider-api-docs/provider-api-request when available. If the user names a provider, that named provider wins; do not substitute a warehouse or app database copy unless they explicitly ask for it. If a table isn't in the app schema, don't try db-query — use the data-source-specific action. For extension management, use list-extensions, update-extension, hide-extension, or delete-extension instead of querying the legacy tools table.",
|
|
679
679
|
parameters: {
|
|
680
680
|
type: "object",
|
|
681
681
|
properties: {
|
|
@@ -2194,6 +2194,28 @@ Do NOT try to call these by name as if they were tools — they will not exist i
|
|
|
2194
2194
|
|
|
2195
2195
|
${lines.join("\n")}`;
|
|
2196
2196
|
}
|
|
2197
|
+
function generateCorpusToolsPrompt(registry) {
|
|
2198
|
+
const hasProviderApi = "provider-api-request" in registry;
|
|
2199
|
+
const providerDiscoveryTools = [
|
|
2200
|
+
"provider-api-catalog" in registry ? "`provider-api-catalog`" : null,
|
|
2201
|
+
"provider-api-docs" in registry ? "`provider-api-docs`" : null,
|
|
2202
|
+
].filter(Boolean);
|
|
2203
|
+
const hasRunCode = "run-code" in registry;
|
|
2204
|
+
const hasStagedDataset = "query-staged-dataset" in registry;
|
|
2205
|
+
if (!hasProviderApi && !hasRunCode && !hasStagedDataset)
|
|
2206
|
+
return "";
|
|
2207
|
+
const available = [
|
|
2208
|
+
...providerDiscoveryTools,
|
|
2209
|
+
hasProviderApi ? "`provider-api-request`" : null,
|
|
2210
|
+
hasStagedDataset ? "`query-staged-dataset`" : null,
|
|
2211
|
+
hasRunCode ? "`run-code`" : null,
|
|
2212
|
+
].filter(Boolean);
|
|
2213
|
+
return `\n\n## Broad Provider And Corpus Workflows
|
|
2214
|
+
|
|
2215
|
+
Available corpus-capable tools: ${available.join(", ")}.
|
|
2216
|
+
|
|
2217
|
+
For broad provider searches, raw API access, multi-page cohorts, cross-source joins, classification/counting over records, or absence-sensitive answers, do not stop at a bounded shortcut action. Use the provider's broad API/search/list surface, fetch every relevant page or an explicit bounded cohort, stage/save large responses when needed, and reduce the corpus with staged-dataset queries or code execution. In run-code, prefer providerFetchAll() for cursor/page/offset pagination and providerRequest() when response status, headers, or truncation metadata matters. Report source, filters, row counts, pagination/truncation, failed pages, and remaining gaps.`;
|
|
2218
|
+
}
|
|
2197
2219
|
/**
|
|
2198
2220
|
* Creates a Nitro plugin that mounts the agent chat endpoint.
|
|
2199
2221
|
*
|
|
@@ -2744,6 +2766,85 @@ export function createAgentChatPlugin(options) {
|
|
|
2744
2766
|
coreAttachmentTools = createCoreAttachmentActionEntries();
|
|
2745
2767
|
}
|
|
2746
2768
|
catch { }
|
|
2769
|
+
// -----------------------------------------------------------------------
|
|
2770
|
+
// Production code-execution mode resolution.
|
|
2771
|
+
//
|
|
2772
|
+
// Priority (highest -> lowest):
|
|
2773
|
+
// 1. AGENT_PROD_CODE_EXECUTION env var ("trusted" | "sandboxed" | "off")
|
|
2774
|
+
// 2. options.codeExecution.production
|
|
2775
|
+
// 3. Default: "off"
|
|
2776
|
+
//
|
|
2777
|
+
// Dev mode ignores this entirely: dev always gets the run-code sandbox.
|
|
2778
|
+
// Build these tools before A2A/MCP registries so every agent-loop surface
|
|
2779
|
+
// has the same code execution capability when enabled.
|
|
2780
|
+
// -----------------------------------------------------------------------
|
|
2781
|
+
const rawEnvCodeExec = (process.env.AGENT_PROD_CODE_EXECUTION ?? "")
|
|
2782
|
+
.toLowerCase()
|
|
2783
|
+
.trim();
|
|
2784
|
+
const resolvedProdCodeExec = rawEnvCodeExec === "trusted"
|
|
2785
|
+
? "trusted"
|
|
2786
|
+
: rawEnvCodeExec === "sandboxed"
|
|
2787
|
+
? "sandboxed"
|
|
2788
|
+
: rawEnvCodeExec === "off"
|
|
2789
|
+
? "off"
|
|
2790
|
+
: (options?.codeExecution?.production ?? "off");
|
|
2791
|
+
// Forward-declaration for the production run-code bridge supplier.
|
|
2792
|
+
// Must come before createRunCodeEntry so the closure can capture it.
|
|
2793
|
+
let prodRunCodeToolActions = {};
|
|
2794
|
+
let leanRunCodeToolActions = {};
|
|
2795
|
+
// Sandboxed run-code tool: available in "sandboxed" or "trusted" prod
|
|
2796
|
+
// modes and always in dev mode.
|
|
2797
|
+
const runCodeTool = {};
|
|
2798
|
+
const leanRunCodeTool = {};
|
|
2799
|
+
try {
|
|
2800
|
+
const { createRunCodeEntry } = await import("../coding-tools/run-code.js");
|
|
2801
|
+
runCodeTool["run-code"] = createRunCodeEntry(
|
|
2802
|
+
// Supplier is evaluated at invocation time so runtime additions to
|
|
2803
|
+
// prodActions (e.g. MCP sync) are visible to the bridge.
|
|
2804
|
+
() => prodRunCodeToolActions, { bridgeTools: options?.codeExecution?.bridgeTools });
|
|
2805
|
+
leanRunCodeTool["run-code"] = createRunCodeEntry(
|
|
2806
|
+
// Lean prompt mode intentionally exposes a much smaller action
|
|
2807
|
+
// surface; keep sandbox appAction() calls scoped to that same surface.
|
|
2808
|
+
() => leanRunCodeToolActions, { bridgeTools: options?.codeExecution?.bridgeTools });
|
|
2809
|
+
}
|
|
2810
|
+
catch {
|
|
2811
|
+
// Module unavailable (e.g. bundled browser build) — skip silently.
|
|
2812
|
+
}
|
|
2813
|
+
// Full coding tool registry (bash/read/edit/write) for "trusted" prod.
|
|
2814
|
+
// In dev mode this is handled separately via devHandler below.
|
|
2815
|
+
const prodCodingTools = {};
|
|
2816
|
+
if (resolvedProdCodeExec === "trusted" && !canToggle) {
|
|
2817
|
+
try {
|
|
2818
|
+
const { createCodingToolRegistry } = await import("../coding-tools/index.js");
|
|
2819
|
+
const codingRegistry = createCodingToolRegistry({
|
|
2820
|
+
cwd: process.cwd(),
|
|
2821
|
+
beforeBash: async ({ command: _command }) => {
|
|
2822
|
+
// In plan mode the agent loop blocks via isPlanModeToolCallAllowed;
|
|
2823
|
+
// this hook is a belt-and-suspenders guard inside trusted production.
|
|
2824
|
+
return null;
|
|
2825
|
+
},
|
|
2826
|
+
});
|
|
2827
|
+
Object.assign(prodCodingTools, codingRegistry);
|
|
2828
|
+
}
|
|
2829
|
+
catch {
|
|
2830
|
+
// Coding tools unavailable — skip silently.
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
// Forward-declaration: populated after devActions is assembled below.
|
|
2834
|
+
// Must be declared before devRunCodeTool so the closure can close over it.
|
|
2835
|
+
let devRunCodeToolActions = {};
|
|
2836
|
+
// Always register run-code in dev mode (when the coding module loads).
|
|
2837
|
+
const devRunCodeTool = {};
|
|
2838
|
+
if (canToggle) {
|
|
2839
|
+
try {
|
|
2840
|
+
const { createRunCodeEntry } = await import("../coding-tools/run-code.js");
|
|
2841
|
+
// devActions is not yet defined at this point; we use a late-binding
|
|
2842
|
+
// supplier so devRunCodeTool can reference the devActions registry
|
|
2843
|
+
// once it is built below (see devHandler block).
|
|
2844
|
+
devRunCodeTool["run-code"] = createRunCodeEntry(() => devRunCodeToolActions, { bridgeTools: options?.codeExecution?.bridgeTools });
|
|
2845
|
+
}
|
|
2846
|
+
catch { }
|
|
2847
|
+
}
|
|
2747
2848
|
const resolveExtraContext = async (event, owner) => {
|
|
2748
2849
|
if (!options?.extraContext)
|
|
2749
2850
|
return "";
|
|
@@ -2775,12 +2876,14 @@ export function createAgentChatPlugin(options) {
|
|
|
2775
2876
|
...progressTools,
|
|
2776
2877
|
...fetchTool,
|
|
2777
2878
|
...webSearchTool,
|
|
2879
|
+
...workspaceFilesTool,
|
|
2778
2880
|
...toolActions,
|
|
2779
2881
|
...browserSessionTools,
|
|
2780
2882
|
...coreEmailTools,
|
|
2781
2883
|
...coreAttachmentTools,
|
|
2782
2884
|
...browserTools,
|
|
2783
2885
|
...devScriptsForA2A,
|
|
2886
|
+
...devRunCodeTool,
|
|
2784
2887
|
}
|
|
2785
2888
|
: {
|
|
2786
2889
|
...discoveredActions,
|
|
@@ -2798,12 +2901,15 @@ export function createAgentChatPlugin(options) {
|
|
|
2798
2901
|
...progressTools,
|
|
2799
2902
|
...fetchTool,
|
|
2800
2903
|
...webSearchTool,
|
|
2904
|
+
...workspaceFilesTool,
|
|
2801
2905
|
...toolActions,
|
|
2802
2906
|
...browserSessionTools,
|
|
2803
2907
|
...coreEmailTools,
|
|
2804
2908
|
...coreAttachmentTools,
|
|
2805
2909
|
...browserTools,
|
|
2806
2910
|
...devScriptsForA2A,
|
|
2911
|
+
...(resolvedProdCodeExec !== "off" ? runCodeTool : {}),
|
|
2912
|
+
...prodCodingTools,
|
|
2807
2913
|
});
|
|
2808
2914
|
// Full ("production") MCP surface served to an authenticated *real
|
|
2809
2915
|
// caller* — a connect-minted token, an `agent-native mcp install` stdio
|
|
@@ -2832,12 +2938,14 @@ export function createAgentChatPlugin(options) {
|
|
|
2832
2938
|
...progressTools,
|
|
2833
2939
|
...fetchTool,
|
|
2834
2940
|
...webSearchTool,
|
|
2941
|
+
...workspaceFilesTool,
|
|
2835
2942
|
...toolActions,
|
|
2836
2943
|
...browserSessionTools,
|
|
2837
2944
|
...coreEmailTools,
|
|
2838
2945
|
...coreAttachmentTools,
|
|
2839
2946
|
...browserTools,
|
|
2840
2947
|
...devScriptsForA2A,
|
|
2948
|
+
...devRunCodeTool,
|
|
2841
2949
|
})
|
|
2842
2950
|
: undefined;
|
|
2843
2951
|
const { mountA2A } = await import("../a2a/server.js");
|
|
@@ -3019,12 +3127,17 @@ export function createAgentChatPlugin(options) {
|
|
|
3019
3127
|
...(lazyContext ? frameworkContextTool : {}),
|
|
3020
3128
|
...urlTools,
|
|
3021
3129
|
...chatScripts,
|
|
3130
|
+
...fetchTool,
|
|
3131
|
+
...webSearchTool,
|
|
3132
|
+
...workspaceFilesTool,
|
|
3022
3133
|
...toolActions,
|
|
3023
3134
|
...browserSessionTools,
|
|
3024
3135
|
...coreEmailTools,
|
|
3025
3136
|
...coreAttachmentTools,
|
|
3026
3137
|
...browserTools,
|
|
3138
|
+
...mcpActionEntries,
|
|
3027
3139
|
...devScriptsForA2A,
|
|
3140
|
+
...devRunCodeTool,
|
|
3028
3141
|
}
|
|
3029
3142
|
: {
|
|
3030
3143
|
...templateScripts,
|
|
@@ -3035,11 +3148,17 @@ export function createAgentChatPlugin(options) {
|
|
|
3035
3148
|
...(lazyContext ? frameworkContextTool : {}),
|
|
3036
3149
|
...urlTools,
|
|
3037
3150
|
...chatScripts,
|
|
3151
|
+
...fetchTool,
|
|
3152
|
+
...webSearchTool,
|
|
3153
|
+
...workspaceFilesTool,
|
|
3038
3154
|
...toolActions,
|
|
3039
3155
|
...browserSessionTools,
|
|
3040
3156
|
...coreEmailTools,
|
|
3041
3157
|
...coreAttachmentTools,
|
|
3042
3158
|
...browserTools,
|
|
3159
|
+
...mcpActionEntries,
|
|
3160
|
+
...(resolvedProdCodeExec !== "off" ? runCodeTool : {}),
|
|
3161
|
+
...prodCodingTools,
|
|
3043
3162
|
});
|
|
3044
3163
|
const a2aTools = actionsToEngineTools(a2aActions);
|
|
3045
3164
|
const a2aMessages = [
|
|
@@ -3119,8 +3238,16 @@ export function createAgentChatPlugin(options) {
|
|
|
3119
3238
|
// Dev: actions are invoked via bash — emit `pnpm action name --arg <type>`
|
|
3120
3239
|
// and include discoveredActions too, since those are also missing
|
|
3121
3240
|
// from the dev tool registry.
|
|
3122
|
-
const
|
|
3123
|
-
|
|
3241
|
+
const corpusToolsPrompt = generateCorpusToolsPrompt({
|
|
3242
|
+
...templateScripts,
|
|
3243
|
+
...(canToggle
|
|
3244
|
+
? devRunCodeTool
|
|
3245
|
+
: resolvedProdCodeExec !== "off"
|
|
3246
|
+
? runCodeTool
|
|
3247
|
+
: {}),
|
|
3248
|
+
});
|
|
3249
|
+
const prodActionsPrompt = generateActionsPrompt(templateScripts, "tool") + corpusToolsPrompt;
|
|
3250
|
+
const devActionsPrompt = generateActionsPrompt({ ...discoveredActions, ...templateScripts }, "cli") + corpusToolsPrompt;
|
|
3124
3251
|
// Build system prompts — dynamic functions that pre-load resources per-request.
|
|
3125
3252
|
// Production gets PROD_FRAMEWORK_PROMPT, dev gets DEV_FRAMEWORK_PROMPT.
|
|
3126
3253
|
// Custom systemPrompt from options overrides the framework default entirely.
|
|
@@ -3185,8 +3312,13 @@ export function createAgentChatPlugin(options) {
|
|
|
3185
3312
|
...(lazyContext ? frameworkContextTool : {}),
|
|
3186
3313
|
...urlTools,
|
|
3187
3314
|
...chatScripts,
|
|
3315
|
+
...fetchTool,
|
|
3316
|
+
...webSearchTool,
|
|
3317
|
+
...workspaceFilesTool,
|
|
3188
3318
|
...toolActions,
|
|
3319
|
+
...mcpActionEntries,
|
|
3189
3320
|
...devScriptsForA2A,
|
|
3321
|
+
...devRunCodeTool,
|
|
3190
3322
|
}
|
|
3191
3323
|
: {
|
|
3192
3324
|
...templateScripts,
|
|
@@ -3197,7 +3329,13 @@ export function createAgentChatPlugin(options) {
|
|
|
3197
3329
|
...(lazyContext ? frameworkContextTool : {}),
|
|
3198
3330
|
...urlTools,
|
|
3199
3331
|
...chatScripts,
|
|
3332
|
+
...fetchTool,
|
|
3333
|
+
...webSearchTool,
|
|
3334
|
+
...workspaceFilesTool,
|
|
3200
3335
|
...toolActions,
|
|
3336
|
+
...mcpActionEntries,
|
|
3337
|
+
...(resolvedProdCodeExec !== "off" ? runCodeTool : {}),
|
|
3338
|
+
...prodCodingTools,
|
|
3201
3339
|
});
|
|
3202
3340
|
const mcpTools = actionsToEngineTools(mcpActions);
|
|
3203
3341
|
const resources = await loadResourcesForPrompt(SHARED_OWNER, lazyContext, options?.appId);
|
|
@@ -3612,91 +3750,20 @@ export function createAgentChatPlugin(options) {
|
|
|
3612
3750
|
// progress, call-agent, and MCP entries to keep the tool list tight and
|
|
3613
3751
|
// prevent the LLM from reaching for web-request instead of the
|
|
3614
3752
|
// template's native actions (e.g. log-meal).
|
|
3615
|
-
const
|
|
3753
|
+
const leanActionEntries = {
|
|
3616
3754
|
...templateScripts,
|
|
3617
3755
|
...resourceScripts,
|
|
3618
3756
|
...refreshScreenTool,
|
|
3619
3757
|
...urlTools,
|
|
3620
3758
|
...chatScripts,
|
|
3621
3759
|
...toolActions,
|
|
3622
|
-
}
|
|
3760
|
+
};
|
|
3623
3761
|
const anonymousReadOnlyActions = attachToolSearch(filterReadOnlyActions(templateScripts));
|
|
3624
3762
|
// Full-database admin tools. Gated on NODE_ENV=development to match the
|
|
3625
3763
|
// DB-admin UI + HTTP routes (which gate on the environment, not the
|
|
3626
3764
|
// Code-mode toggle), so the agent has the same DB-admin capability the UI
|
|
3627
3765
|
// does whenever it is available — true agent/UI parity, in App or Code mode.
|
|
3628
3766
|
const dbAdminScripts = process.env.NODE_ENV === "development" ? createDbAdminAgentTools() : {};
|
|
3629
|
-
// -----------------------------------------------------------------------
|
|
3630
|
-
// Production code-execution mode resolution.
|
|
3631
|
-
//
|
|
3632
|
-
// Priority (highest → lowest):
|
|
3633
|
-
// 1. AGENT_PROD_CODE_EXECUTION env var ("trusted" | "sandboxed" | "off")
|
|
3634
|
-
// 2. options.codeExecution.production
|
|
3635
|
-
// 3. Default: "off"
|
|
3636
|
-
//
|
|
3637
|
-
// Dev mode ignores this entirely — dev always gets the full coding surface.
|
|
3638
|
-
// -----------------------------------------------------------------------
|
|
3639
|
-
const rawEnvCodeExec = (process.env.AGENT_PROD_CODE_EXECUTION ?? "")
|
|
3640
|
-
.toLowerCase()
|
|
3641
|
-
.trim();
|
|
3642
|
-
const resolvedProdCodeExec = rawEnvCodeExec === "trusted"
|
|
3643
|
-
? "trusted"
|
|
3644
|
-
: rawEnvCodeExec === "sandboxed"
|
|
3645
|
-
? "sandboxed"
|
|
3646
|
-
: rawEnvCodeExec === "off"
|
|
3647
|
-
? "off"
|
|
3648
|
-
: (options?.codeExecution?.production ?? "off");
|
|
3649
|
-
// Forward-declaration for the production run-code bridge supplier.
|
|
3650
|
-
// Must come before createRunCodeEntry so the closure can capture it.
|
|
3651
|
-
let prodRunCodeToolActions = {};
|
|
3652
|
-
// Sandboxed run-code tool — available in "sandboxed" or "trusted" prod
|
|
3653
|
-
// modes and always in dev mode.
|
|
3654
|
-
const runCodeTool = {};
|
|
3655
|
-
try {
|
|
3656
|
-
const { createRunCodeEntry } = await import("../coding-tools/run-code.js");
|
|
3657
|
-
runCodeTool["run-code"] = createRunCodeEntry(
|
|
3658
|
-
// Supplier is evaluated at invocation time so runtime additions to
|
|
3659
|
-
// prodActions (e.g. MCP sync) are visible to the bridge.
|
|
3660
|
-
() => prodRunCodeToolActions, { bridgeTools: options?.codeExecution?.bridgeTools });
|
|
3661
|
-
}
|
|
3662
|
-
catch {
|
|
3663
|
-
// Module unavailable (e.g. bundled browser build) — skip silently.
|
|
3664
|
-
}
|
|
3665
|
-
// Full coding tool registry (bash/read/edit/write) for "trusted" prod.
|
|
3666
|
-
// In dev mode this is handled separately via devHandler below.
|
|
3667
|
-
const prodCodingTools = {};
|
|
3668
|
-
if (resolvedProdCodeExec === "trusted" && !canToggle) {
|
|
3669
|
-
try {
|
|
3670
|
-
const { createCodingToolRegistry } = await import("../coding-tools/index.js");
|
|
3671
|
-
const codingRegistry = createCodingToolRegistry({
|
|
3672
|
-
cwd: process.cwd(),
|
|
3673
|
-
beforeBash: async ({ command: _command }) => {
|
|
3674
|
-
// In plan mode the agent loop blocks via isPlanModeToolCallAllowed;
|
|
3675
|
-
// this hook is a belt-and-suspenders guard inside "trusted" production.
|
|
3676
|
-
return null;
|
|
3677
|
-
},
|
|
3678
|
-
});
|
|
3679
|
-
Object.assign(prodCodingTools, codingRegistry);
|
|
3680
|
-
}
|
|
3681
|
-
catch {
|
|
3682
|
-
// Coding tools unavailable — skip silently.
|
|
3683
|
-
}
|
|
3684
|
-
}
|
|
3685
|
-
// Forward-declaration: populated after devActions is assembled below.
|
|
3686
|
-
// Must be declared BEFORE devRunCodeTool so the closure can close over it.
|
|
3687
|
-
let devRunCodeToolActions = {};
|
|
3688
|
-
// Always register run-code in dev mode (when the coding module loads).
|
|
3689
|
-
const devRunCodeTool = {};
|
|
3690
|
-
if (canToggle) {
|
|
3691
|
-
try {
|
|
3692
|
-
const { createRunCodeEntry } = await import("../coding-tools/run-code.js");
|
|
3693
|
-
// devActions is not yet defined at this point; we use a late-binding
|
|
3694
|
-
// supplier so devRunCodeTool can reference the devActions registry
|
|
3695
|
-
// once it is built below (see devHandler block).
|
|
3696
|
-
devRunCodeTool["run-code"] = createRunCodeEntry(() => devRunCodeToolActions, { bridgeTools: options?.codeExecution?.bridgeTools });
|
|
3697
|
-
}
|
|
3698
|
-
catch { }
|
|
3699
|
-
}
|
|
3700
3767
|
const prodActions = attachToolSearch({
|
|
3701
3768
|
...templateScripts,
|
|
3702
3769
|
...resourceScripts,
|
|
@@ -3722,14 +3789,24 @@ export function createAgentChatPlugin(options) {
|
|
|
3722
3789
|
...coreAttachmentTools,
|
|
3723
3790
|
...browserTools,
|
|
3724
3791
|
...mcpActionEntries,
|
|
3725
|
-
// Sandboxed run-code
|
|
3726
|
-
|
|
3792
|
+
// Sandboxed run-code for hosted production when enabled, and for the
|
|
3793
|
+
// app-rendered production-style handler in local dev.
|
|
3794
|
+
...(canToggle || resolvedProdCodeExec !== "off" ? runCodeTool : {}),
|
|
3727
3795
|
// Full coding tools in production when mode is "trusted".
|
|
3728
3796
|
...(!canToggle ? prodCodingTools : {}),
|
|
3729
3797
|
});
|
|
3730
3798
|
// Wire the prod run-code bridge supplier so it sees the fully-assembled
|
|
3731
3799
|
// prodActions registry (including MCP entries added at runtime).
|
|
3732
3800
|
prodRunCodeToolActions = prodActions;
|
|
3801
|
+
const leanActions = attachToolSearch({
|
|
3802
|
+
...leanActionEntries,
|
|
3803
|
+
// Lean mode still needs run-code when code execution is enabled.
|
|
3804
|
+
// Otherwise templates with a minimal prompt can advertise sandboxed
|
|
3805
|
+
// execution in the system prompt while the actual tool registry omits
|
|
3806
|
+
// it.
|
|
3807
|
+
...(canToggle || resolvedProdCodeExec !== "off" ? leanRunCodeTool : {}),
|
|
3808
|
+
});
|
|
3809
|
+
leanRunCodeToolActions = leanActions;
|
|
3733
3810
|
// Keep the prod action dict's MCP entries in sync when the manager's
|
|
3734
3811
|
// server set changes at runtime (e.g. a user adds a remote MCP server
|
|
3735
3812
|
// through the settings UI). getEngineTools() in production-agent re-reads
|
|
@@ -3834,8 +3911,8 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
|
|
|
3834
3911
|
// System-prompt note appended when production code execution is enabled.
|
|
3835
3912
|
const prodCodeExecPromptNote = !canToggle && resolvedProdCodeExec !== "off"
|
|
3836
3913
|
? resolvedProdCodeExec === "trusted"
|
|
3837
|
-
? "\n\n<code-execution-mode>Full shell access is enabled (trusted mode). You have bash, read, edit, write, and run-code tools available. Use bash for file discovery, running tests and builds, and project CLIs. Use run-code for sandboxed JavaScript
|
|
3838
|
-
: "\n\n<code-execution-mode>Sandboxed code execution is enabled. The run-code tool lets you execute isolated JavaScript (ESM, top-level await) to fetch, aggregate, and reduce data. Use providerFetch() and webFetch() inside run-code for authenticated provider calls.</code-execution-mode>"
|
|
3914
|
+
? "\n\n<code-execution-mode>Full shell access is enabled (trusted mode). You have bash, read, edit, write, and run-code tools available. Use bash for file discovery, running tests and builds, and project CLIs. Use run-code for sandboxed JavaScript data processing: provider/API pagination, joins, classification, aggregation, and large-response reduction. Use `pnpm action <name>` in bash to invoke registered app actions from the shell.</code-execution-mode>"
|
|
3915
|
+
: "\n\n<code-execution-mode>Sandboxed code execution is enabled. The run-code tool lets you execute isolated JavaScript (ESM, top-level await) to fetch, aggregate, and reduce data. Use providerFetch(), providerFetchAll(), providerRequest(), and webFetch() inside run-code for authenticated provider calls.</code-execution-mode>"
|
|
3839
3916
|
: "";
|
|
3840
3917
|
const prodHandler = createProductionAgentHandler({
|
|
3841
3918
|
actions: leanPrompt ? leanActions : prodActions,
|