@agent-native/core 0.7.19 → 0.7.20
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 -1
- package/dist/agent/engine/builder-engine.d.ts.map +1 -1
- package/dist/agent/engine/builder-engine.js +45 -2
- package/dist/agent/engine/builder-engine.js.map +1 -1
- package/dist/agent/loop-settings.d.ts +37 -0
- package/dist/agent/loop-settings.d.ts.map +1 -0
- package/dist/agent/loop-settings.js +127 -0
- package/dist/agent/loop-settings.js.map +1 -0
- package/dist/agent/production-agent.d.ts +8 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +268 -29
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +76 -3
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/run-store.d.ts +1 -1
- package/dist/agent/run-store.d.ts.map +1 -1
- package/dist/agent/run-store.js +65 -2
- package/dist/agent/run-store.js.map +1 -1
- package/dist/agent/thread-data-builder.d.ts +3 -0
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +52 -10
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/agent/tool-search.d.ts +37 -0
- package/dist/agent/tool-search.d.ts.map +1 -0
- package/dist/agent/tool-search.js +201 -0
- package/dist/agent/tool-search.js.map +1 -0
- package/dist/agent/types.d.ts +8 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +44 -9
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/workspacify.d.ts +2 -0
- package/dist/cli/workspacify.d.ts.map +1 -1
- package/dist/cli/workspacify.js +34 -1
- package/dist/cli/workspacify.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +277 -18
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/ConnectBuilderCard.d.ts.map +1 -1
- package/dist/client/ConnectBuilderCard.js +1 -1
- package/dist/client/ConnectBuilderCard.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +14 -6
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/NewWorkspaceAppFlow.d.ts +14 -0
- package/dist/client/NewWorkspaceAppFlow.d.ts.map +1 -0
- package/dist/client/NewWorkspaceAppFlow.js +200 -0
- package/dist/client/NewWorkspaceAppFlow.js.map +1 -0
- package/dist/client/PoweredByBadge.d.ts +10 -1
- package/dist/client/PoweredByBadge.d.ts.map +1 -1
- package/dist/client/PoweredByBadge.js +120 -8
- package/dist/client/PoweredByBadge.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts +3 -5
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +26 -19
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/agent-chat.d.ts.map +1 -1
- package/dist/client/agent-chat.js +15 -3
- package/dist/client/agent-chat.js.map +1 -1
- package/dist/client/analytics.d.ts +1 -1
- package/dist/client/analytics.d.ts.map +1 -1
- package/dist/client/analytics.js +141 -1
- package/dist/client/analytics.js.map +1 -1
- package/dist/client/builder-frame.d.ts +10 -0
- package/dist/client/builder-frame.d.ts.map +1 -0
- package/dist/client/builder-frame.js +94 -0
- package/dist/client/builder-frame.js.map +1 -0
- package/dist/client/composer/MentionPopover.d.ts.map +1 -1
- package/dist/client/composer/MentionPopover.js +5 -1
- package/dist/client/composer/MentionPopover.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +11 -6
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/error-format.d.ts +20 -1
- package/dist/client/error-format.d.ts.map +1 -1
- package/dist/client/error-format.js +53 -5
- package/dist/client/error-format.js.map +1 -1
- package/dist/client/index.d.ts +3 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +3 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/onboarding/OnboardingPanel.d.ts.map +1 -1
- package/dist/client/onboarding/OnboardingPanel.js +88 -6
- package/dist/client/onboarding/OnboardingPanel.js.map +1 -1
- package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/client/settings/SettingsPanel.js +145 -9
- package/dist/client/settings/SettingsPanel.js.map +1 -1
- package/dist/client/settings/useBuilderStatus.d.ts +13 -0
- package/dist/client/settings/useBuilderStatus.d.ts.map +1 -1
- package/dist/client/settings/useBuilderStatus.js +50 -9
- package/dist/client/settings/useBuilderStatus.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts +3 -0
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +88 -7
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/client/tools/ToolsListPage.d.ts.map +1 -1
- package/dist/client/tools/ToolsListPage.js +16 -1
- package/dist/client/tools/ToolsListPage.js.map +1 -1
- package/dist/client/tools/ToolsSidebarSection.d.ts.map +1 -1
- package/dist/client/tools/ToolsSidebarSection.js +63 -8
- package/dist/client/tools/ToolsSidebarSection.js.map +1 -1
- package/dist/client/tools/tool-order.d.ts +7 -0
- package/dist/client/tools/tool-order.d.ts.map +1 -0
- package/dist/client/tools/tool-order.js +47 -0
- package/dist/client/tools/tool-order.js.map +1 -0
- package/dist/client/transcription/BuilderTranscriptionCta.d.ts.map +1 -1
- package/dist/client/transcription/BuilderTranscriptionCta.js +71 -6
- package/dist/client/transcription/BuilderTranscriptionCta.js.map +1 -1
- package/dist/client/use-send-to-agent-chat.d.ts.map +1 -1
- package/dist/client/use-send-to-agent-chat.js +11 -3
- package/dist/client/use-send-to-agent-chat.js.map +1 -1
- package/dist/client/useProductionAgent.d.ts.map +1 -1
- package/dist/client/useProductionAgent.js +1 -1
- package/dist/client/useProductionAgent.js.map +1 -1
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +5 -1
- package/dist/db/client.js.map +1 -1
- package/dist/deploy/build.d.ts +1 -0
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +4 -1
- package/dist/deploy/build.js.map +1 -1
- package/dist/oauth-tokens/index.d.ts +1 -1
- package/dist/oauth-tokens/index.d.ts.map +1 -1
- package/dist/oauth-tokens/index.js +1 -1
- package/dist/oauth-tokens/index.js.map +1 -1
- package/dist/oauth-tokens/store.d.ts.map +1 -1
- package/dist/oauth-tokens/store.js +6 -0
- package/dist/oauth-tokens/store.js.map +1 -1
- package/dist/observability/store.d.ts.map +1 -1
- package/dist/observability/store.js +19 -19
- package/dist/observability/store.js.map +1 -1
- package/dist/onboarding/default-steps.d.ts.map +1 -1
- package/dist/onboarding/default-steps.js +95 -61
- package/dist/onboarding/default-steps.js.map +1 -1
- package/dist/onboarding/plugin.d.ts.map +1 -1
- package/dist/onboarding/plugin.js +17 -8
- package/dist/onboarding/plugin.js.map +1 -1
- package/dist/org/migrations.js +2 -2
- package/dist/org/migrations.js.map +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.d.ts.map +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.js +2 -3
- package/dist/scripts/agent-engines/list-agent-engines.js.map +1 -1
- package/dist/scripts/db/exec.d.ts +2 -1
- package/dist/scripts/db/exec.d.ts.map +1 -1
- package/dist/scripts/db/exec.js +264 -61
- package/dist/scripts/db/exec.js.map +1 -1
- package/dist/scripts/db/schema.d.ts.map +1 -1
- package/dist/scripts/db/schema.js +16 -4
- package/dist/scripts/db/schema.js.map +1 -1
- package/dist/scripts/dev/index.d.ts.map +1 -1
- package/dist/scripts/dev/index.js +36 -11
- package/dist/scripts/dev/index.js.map +1 -1
- package/dist/scripts/manage-agent-loop-settings.d.ts +7 -0
- package/dist/scripts/manage-agent-loop-settings.d.ts.map +1 -0
- package/dist/scripts/manage-agent-loop-settings.js +63 -0
- package/dist/scripts/manage-agent-loop-settings.js.map +1 -0
- package/dist/scripts/runner.d.ts.map +1 -1
- package/dist/scripts/runner.js +11 -0
- package/dist/scripts/runner.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +60 -18
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/app-url.d.ts +5 -4
- package/dist/server/app-url.d.ts.map +1 -1
- package/dist/server/app-url.js +8 -4
- package/dist/server/app-url.js.map +1 -1
- package/dist/server/auth.d.ts +8 -0
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +82 -29
- package/dist/server/auth.js.map +1 -1
- package/dist/server/better-auth-instance.d.ts.map +1 -1
- package/dist/server/better-auth-instance.js +16 -5
- package/dist/server/better-auth-instance.js.map +1 -1
- package/dist/server/builder-browser.d.ts +12 -0
- package/dist/server/builder-browser.d.ts.map +1 -1
- package/dist/server/builder-browser.js +36 -4
- package/dist/server/builder-browser.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +350 -53
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/credential-provider.d.ts +21 -3
- package/dist/server/credential-provider.d.ts.map +1 -1
- package/dist/server/credential-provider.js +51 -21
- package/dist/server/credential-provider.js.map +1 -1
- package/dist/server/google-oauth.d.ts +3 -0
- package/dist/server/google-oauth.d.ts.map +1 -1
- package/dist/server/google-oauth.js +27 -3
- package/dist/server/google-oauth.js.map +1 -1
- package/dist/server/index.d.ts +4 -3
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +4 -3
- package/dist/server/index.js.map +1 -1
- package/dist/server/schema-prompt.d.ts.map +1 -1
- package/dist/server/schema-prompt.js +2 -1
- package/dist/server/schema-prompt.js.map +1 -1
- package/dist/server/security-headers.d.ts +3 -0
- package/dist/server/security-headers.d.ts.map +1 -1
- package/dist/server/security-headers.js +7 -1
- package/dist/server/security-headers.js.map +1 -1
- package/dist/server/ssr-handler.d.ts.map +1 -1
- package/dist/server/ssr-handler.js +24 -4
- package/dist/server/ssr-handler.js.map +1 -1
- package/dist/templates/default/_gitignore +5 -1
- package/dist/templates/default/app/root.tsx +1 -0
- package/dist/templates/default/public/favicon.svg +3 -3
- package/dist/templates/default/public/icon-180.svg +3 -3
- package/dist/templates/default/public/icon-192.svg +3 -3
- package/dist/templates/default/public/icon-512.svg +3 -3
- package/dist/templates/workspace-core/AGENTS.md +23 -7
- package/dist/templates/workspace-core/package.json +2 -1
- package/dist/templates/workspace-core/src/credentials.ts +22 -11
- package/dist/templates/workspace-root/.env.example +7 -0
- package/dist/templates/workspace-root/README.md +6 -3
- package/dist/templates/workspace-root/_gitignore +3 -0
- package/dist/templates/workspace-root/package.json +3 -1
- package/dist/templates/workspace-root/scripts/workspace-dev.ts +410 -0
- package/dist/tools/actions.d.ts.map +1 -1
- package/dist/tools/actions.js +2 -0
- package/dist/tools/actions.js.map +1 -1
- package/dist/tools/html-shell.d.ts.map +1 -1
- package/dist/tools/html-shell.js +13 -1
- package/dist/tools/html-shell.js.map +1 -1
- package/dist/tools/store.d.ts.map +1 -1
- package/dist/tools/store.js +10 -10
- package/dist/tools/store.js.map +1 -1
- package/dist/tracking/providers.d.ts +1 -0
- package/dist/tracking/providers.d.ts.map +1 -1
- package/dist/tracking/providers.js +72 -0
- package/dist/tracking/providers.js.map +1 -1
- package/dist/vite/action-types-plugin.d.ts.map +1 -1
- package/dist/vite/action-types-plugin.js +106 -9
- package/dist/vite/action-types-plugin.js.map +1 -1
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +67 -2
- package/dist/vite/client.js.map +1 -1
- package/docs/content/authentication.md +17 -13
- package/docs/content/deployment.md +11 -11
- package/docs/content/mcp-clients.md +2 -2
- package/docs/content/onboarding.md +32 -30
- package/docs/content/security.md +1 -1
- package/docs/content/tools.md +4 -0
- package/package.json +2 -2
- package/src/templates/default/_gitignore +5 -1
- package/src/templates/default/app/root.tsx +1 -0
- package/src/templates/default/public/favicon.svg +3 -3
- package/src/templates/default/public/icon-180.svg +3 -3
- package/src/templates/default/public/icon-192.svg +3 -3
- package/src/templates/default/public/icon-512.svg +3 -3
- package/src/templates/workspace-core/AGENTS.md +23 -7
- package/src/templates/workspace-core/package.json +2 -1
- package/src/templates/workspace-core/src/credentials.ts +22 -11
- package/src/templates/workspace-root/.env.example +7 -0
- package/src/templates/workspace-root/README.md +6 -3
- package/src/templates/workspace-root/_gitignore +3 -0
- package/src/templates/workspace-root/package.json +3 -1
- package/src/templates/workspace-root/scripts/workspace-dev.ts +410 -0
|
@@ -4,6 +4,7 @@ import { getH3App, trackPluginInit } from "./framework-request-handler.js";
|
|
|
4
4
|
import { createProductionAgentHandler, runAgentLoop, actionsToEngineTools, getActiveRunForThreadAsync, abortRun, subscribeToRun, } from "../agent/production-agent.js";
|
|
5
5
|
import { resolveEngine, createAnthropicEngine } from "../agent/engine/index.js";
|
|
6
6
|
import { DEFAULT_MODEL } from "../agent/default-model.js";
|
|
7
|
+
import { attachToolSearch } from "../agent/tool-search.js";
|
|
7
8
|
import { McpClientManager, loadMcpConfig, autoDetectMcpConfig, mcpToolsToActionEntries, syncMcpActionEntries, mountMcpServersRoutes, mountMcpHubRoutes, buildMergedConfig, getHubStatus, isHubServeEnabled, } from "../mcp-client/index.js";
|
|
8
9
|
import { discoverAgents } from "./agent-discovery.js";
|
|
9
10
|
import { loadSchemaPromptBlock } from "./schema-prompt.js";
|
|
@@ -40,7 +41,11 @@ function wrapCliScript(tool, cliDefault, opts) {
|
|
|
40
41
|
run: async (args) => {
|
|
41
42
|
const cliArgs = [];
|
|
42
43
|
for (const [k, v] of Object.entries(args)) {
|
|
43
|
-
|
|
44
|
+
const raw = v;
|
|
45
|
+
const value = raw != null && typeof raw === "object"
|
|
46
|
+
? JSON.stringify(raw)
|
|
47
|
+
: String(raw);
|
|
48
|
+
cliArgs.push(`--${k}`, value);
|
|
44
49
|
}
|
|
45
50
|
return captureCliOutput(() => cliDefault(cliArgs));
|
|
46
51
|
},
|
|
@@ -264,6 +269,10 @@ async function createDbScriptEntries() {
|
|
|
264
269
|
type: "string",
|
|
265
270
|
description: "SELECT query to run, e.g. \"SELECT key, value FROM settings WHERE key LIKE 'sql-dashboard-%'\"",
|
|
266
271
|
},
|
|
272
|
+
args: {
|
|
273
|
+
type: "string",
|
|
274
|
+
description: 'Optional JSON array of positional bind args for parameterized placeholders. Example: \'["draft","form-123"]\'',
|
|
275
|
+
},
|
|
267
276
|
format: {
|
|
268
277
|
type: "string",
|
|
269
278
|
description: 'Output format: "json" or "text" (default: text)',
|
|
@@ -278,16 +287,28 @@ async function createDbScriptEntries() {
|
|
|
278
287
|
},
|
|
279
288
|
}, queryMod.default, { readOnly: true }),
|
|
280
289
|
"db-exec": wrapCliScript({
|
|
281
|
-
description: "Write to the app's own SQL database ONLY. Runs INSERT / UPDATE / DELETE against the app's internal tables. Writes are auto-scoped to the current user/org, and `owner_email` / `org_id` are auto-injected on INSERT. IMPORTANT: This tool CANNOT write to external data sources like BigQuery, HubSpot, etc. For external services, use the appropriate template action.",
|
|
290
|
+
description: "Write to the app's own SQL database ONLY. Runs INSERT / UPDATE / DELETE / REPLACE against the app's internal tables. For multiple related writes, pass `statements` so they run sequentially in one transaction instead of issuing several db-exec calls. Writes are auto-scoped to the current user/org, and `owner_email` / `org_id` are auto-injected on INSERT. Schema changes (CREATE/ALTER/DROP) are blocked. IMPORTANT: This tool CANNOT write to external data sources like BigQuery, HubSpot, etc. For external services, use the appropriate template action.",
|
|
282
291
|
parameters: {
|
|
283
292
|
type: "object",
|
|
284
293
|
properties: {
|
|
285
294
|
sql: {
|
|
286
295
|
type: "string",
|
|
287
|
-
description: "INSERT / UPDATE / DELETE statement. Use parameterized placeholders (?)
|
|
296
|
+
description: "Single INSERT / UPDATE / DELETE / REPLACE statement. Use parameterized placeholders (?) where possible.",
|
|
297
|
+
},
|
|
298
|
+
args: {
|
|
299
|
+
type: "string",
|
|
300
|
+
description: 'Optional JSON array of positional bind args for `sql`. Example: \'["published","form-123"]\'',
|
|
301
|
+
},
|
|
302
|
+
statements: {
|
|
303
|
+
type: "string",
|
|
304
|
+
description: 'Optional JSON array of write statements to execute in one transaction. Prefer this over multiple db-exec calls. Example: \'[{"sql":"INSERT INTO notes (id,title) VALUES (?,?)","args":["n1","One"]},{"sql":"UPDATE counters SET value = value + 1 WHERE key = ?","args":["notes"]}]\'',
|
|
305
|
+
},
|
|
306
|
+
format: {
|
|
307
|
+
type: "string",
|
|
308
|
+
description: 'Output format: "json" or "text" (default: text)',
|
|
309
|
+
enum: ["json", "text"],
|
|
288
310
|
},
|
|
289
311
|
},
|
|
290
|
-
required: ["sql"],
|
|
291
312
|
},
|
|
292
313
|
}, execMod.default),
|
|
293
314
|
"db-patch": wrapCliScript({
|
|
@@ -617,6 +638,21 @@ async function createAgentEngineScriptEntries() {
|
|
|
617
638
|
return {};
|
|
618
639
|
}
|
|
619
640
|
}
|
|
641
|
+
/**
|
|
642
|
+
* Creates the manage-agent-loop-settings tool. Lets the agent inspect and
|
|
643
|
+
* configure the loop step limit it may hit on long-running work.
|
|
644
|
+
*/
|
|
645
|
+
async function createAgentLoopSettingsScriptEntries() {
|
|
646
|
+
try {
|
|
647
|
+
const mod = await import("../scripts/manage-agent-loop-settings.js");
|
|
648
|
+
return {
|
|
649
|
+
"manage-agent-loop-settings": { tool: mod.tool, run: mod.run },
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
catch {
|
|
653
|
+
return {};
|
|
654
|
+
}
|
|
655
|
+
}
|
|
620
656
|
/**
|
|
621
657
|
* Creates the call-agent ActionEntry for cross-agent A2A communication.
|
|
622
658
|
* Binds selfAppId so the agent cannot call itself via call-agent.
|
|
@@ -933,6 +969,7 @@ const FRAMEWORK_CORE_COMPACT = `
|
|
|
933
969
|
8. **\`db-*\` tools are internal only** — \`db-query\`, \`db-exec\`, \`db-patch\` ONLY access the app's own SQL database (settings, application_state, template tables). They CANNOT reach BigQuery, HubSpot, GA4, Jira, or any external data source. If the user asks about a table that is NOT in the app schema (e.g. \`dbt_analytics.*\`, \`dbt_mart.*\`, or any fully-qualified \`project.dataset.table\`), use the appropriate template action instead — \`bigquery\` for warehouse tables, \`ga4-report\` for Google Analytics, \`hubspot-deals\` for HubSpot, etc. **Never use \`db-query\` for external data — it will fail.**
|
|
934
970
|
9. **Never fabricate data** — Do NOT invent numbers, metrics, records, or query results. Do NOT present estimated or example data as if it were real. If a data source is unavailable (missing credentials, connection error, tool failure), say so clearly, note the gap, and work with whatever data you do have. If no data can be retrieved at all, say "I can't retrieve this data right now" and explain why. Presenting made-up data as real is a critical failure — it is worse than admitting the limitation.
|
|
935
971
|
10. **Never fabricate success from tool errors** — When any tool call returns an error (marked \`isError: true\`, contains "Command failed", "Error:", or non-zero exit output), the operation FAILED. Do NOT synthesize a success narrative or describe what the action "would have" produced. Report the failure verbatim from the tool output. This applies especially to \`shell(command="pnpm action ...")\` calls: if the action threw, it did NOT succeed.
|
|
972
|
+
11. **Find tools when unsure** — Use \`tool-search\` to find the exact action/tool for a capability. It searches the live registry, including connected MCP server tools.
|
|
936
973
|
|
|
937
974
|
### Resources
|
|
938
975
|
|
|
@@ -1070,11 +1107,12 @@ Your memory index (\`memory/MEMORY.md\`) is loaded at the start of every convers
|
|
|
1070
1107
|
|
|
1071
1108
|
- \`db-schema\` — refresh the full schema with indexes and foreign keys
|
|
1072
1109
|
- \`db-query\` — run a SELECT (read-only; results already filtered to the current user/org)
|
|
1073
|
-
- \`db-exec\` — run INSERT / UPDATE / DELETE (writes already scoped; owner_email and org_id are auto-injected on INSERT)
|
|
1110
|
+
- \`db-exec\` — run INSERT / UPDATE / DELETE / REPLACE (writes already scoped; owner_email and org_id are auto-injected on INSERT). For multiple related writes, use \`statements\` so they run in one transaction instead of separate tool calls. Schema changes are blocked.
|
|
1074
1111
|
- \`db-patch\` — surgical search-and-replace on a large text column. Use for edits to large fields instead of re-sending multi-kilobyte strings.
|
|
1075
1112
|
|
|
1076
1113
|
### When to pick which SQL tool
|
|
1077
1114
|
- Set a short column outright, update multiple columns, or do computed updates → \`db-exec UPDATE\`
|
|
1115
|
+
- Insert/update several rows as one logical operation → \`db-exec\` with \`statements: '[{"sql":"...","args":[...]}]'\`
|
|
1078
1116
|
- Change a small slice of a large text/JSON column → \`db-patch\`
|
|
1079
1117
|
- A template-specific action exists for the table → use that action (it encodes business rules and pushes live Yjs updates)
|
|
1080
1118
|
- Read data → \`db-query\`. Never re-add \`WHERE owner_email = ...\` — scoping already applies it.
|
|
@@ -1099,6 +1137,7 @@ const FRAMEWORK_CORE = `
|
|
|
1099
1137
|
8. **\`db-*\` tools are internal only** — \`db-query\`, \`db-exec\`, \`db-patch\` ONLY access the app's own SQL database (settings, application_state, template tables). They CANNOT reach BigQuery, HubSpot, GA4, Jira, or any external data source. If the user asks about a table that is NOT in the app schema (e.g. \`dbt_analytics.*\`, \`dbt_mart.*\`, or any fully-qualified \`project.dataset.table\`), use the appropriate template action instead — \`bigquery\` for warehouse tables, \`ga4-report\` for Google Analytics, \`hubspot-deals\` for HubSpot, etc. **Never use \`db-query\` for external data — it will fail.**
|
|
1100
1138
|
9. **Never fabricate data** — Do NOT invent numbers, metrics, records, or query results. Do NOT present estimated or example data as if it were real. If a data source is unavailable (missing credentials, connection error, tool failure), say so clearly, note the gap, and work with whatever data you do have. If no data can be retrieved at all, say "I can't retrieve this data right now" and explain why. Presenting made-up data as real is a critical failure — it is worse than admitting the limitation.
|
|
1101
1139
|
10. **Never fabricate success from tool errors** — When any tool call returns an error (marked \`isError: true\`, contains "Command failed", "Error:", or non-zero exit output), the operation FAILED. Do NOT synthesize a success narrative, format a result table, or describe what the action "would have" produced. Report the failure verbatim from the tool output. This applies especially to \`shell(command="pnpm action ...")\` calls: if the underlying action threw (visible in the error text), the action did NOT succeed — report the error, do not describe a successful outcome.
|
|
1140
|
+
11. **Find tools when unsure** — Use \`tool-search\` to find the exact action/tool for a capability. It searches the live registry, including connected MCP server tools added through config, settings, or the MCP hub.
|
|
1102
1141
|
|
|
1103
1142
|
### Resources
|
|
1104
1143
|
|
|
@@ -1733,7 +1772,7 @@ export function createAgentChatPlugin(options) {
|
|
|
1733
1772
|
if (!rawActions && Object.keys(templateScripts).length === 0) {
|
|
1734
1773
|
try {
|
|
1735
1774
|
const { autoDiscoverActions } = await import("./action-discovery.js");
|
|
1736
|
-
templateScripts = await autoDiscoverActions(
|
|
1775
|
+
templateScripts = await autoDiscoverActions("auto");
|
|
1737
1776
|
}
|
|
1738
1777
|
catch {
|
|
1739
1778
|
// Filesystem discovery unavailable (serverless bundle) — skip.
|
|
@@ -1749,9 +1788,11 @@ export function createAgentChatPlugin(options) {
|
|
|
1749
1788
|
const lazyContext = options?.lazyContext !== false && !leanPrompt;
|
|
1750
1789
|
const urlTools = createUrlTools();
|
|
1751
1790
|
const engineScripts = await createAgentEngineScriptEntries();
|
|
1791
|
+
const loopSettingsScripts = await createAgentLoopSettingsScriptEntries();
|
|
1752
1792
|
const chatScripts = {
|
|
1753
1793
|
...(await createChatScriptEntries()),
|
|
1754
1794
|
...engineScripts,
|
|
1795
|
+
...loopSettingsScripts,
|
|
1755
1796
|
};
|
|
1756
1797
|
const callAgentScript = await createCallAgentScriptEntry(options?.appId);
|
|
1757
1798
|
const browserTools = createBuilderBrowserTool({
|
|
@@ -1968,7 +2009,7 @@ export function createAgentChatPlugin(options) {
|
|
|
1968
2009
|
// This avoids degenerate empty-object tool calls that Anthropic models
|
|
1969
2010
|
// sometimes emit for actions with complex schemas. Production keeps the
|
|
1970
2011
|
// native registration since it has no shell access.
|
|
1971
|
-
const allScripts = canToggle
|
|
2012
|
+
const allScripts = attachToolSearch(canToggle
|
|
1972
2013
|
? {
|
|
1973
2014
|
...resourceScripts,
|
|
1974
2015
|
...docsScripts,
|
|
@@ -2002,7 +2043,7 @@ export function createAgentChatPlugin(options) {
|
|
|
2002
2043
|
...toolActions,
|
|
2003
2044
|
...browserTools,
|
|
2004
2045
|
...devScriptsForA2A,
|
|
2005
|
-
};
|
|
2046
|
+
});
|
|
2006
2047
|
const { mountA2A } = await import("../a2a/server.js");
|
|
2007
2048
|
mountA2A(nitroApp, {
|
|
2008
2049
|
name: options?.appId
|
|
@@ -2157,7 +2198,7 @@ export function createAgentChatPlugin(options) {
|
|
|
2157
2198
|
// to prevent infinite recursive A2A loops (agent calling itself).
|
|
2158
2199
|
// In dev mode, template actions are invoked via shell (not native tools),
|
|
2159
2200
|
// so they're omitted from the tool registry — see allScripts comment.
|
|
2160
|
-
const a2aActions = devActive
|
|
2201
|
+
const a2aActions = attachToolSearch(devActive
|
|
2161
2202
|
? {
|
|
2162
2203
|
...resourceScripts,
|
|
2163
2204
|
...docsScripts,
|
|
@@ -2179,7 +2220,7 @@ export function createAgentChatPlugin(options) {
|
|
|
2179
2220
|
...chatScripts,
|
|
2180
2221
|
...toolActions,
|
|
2181
2222
|
...browserTools,
|
|
2182
|
-
};
|
|
2223
|
+
});
|
|
2183
2224
|
const a2aTools = actionsToEngineTools(a2aActions);
|
|
2184
2225
|
const a2aMessages = [
|
|
2185
2226
|
{ role: "user", content: [{ type: "text", text }] },
|
|
@@ -2276,7 +2317,7 @@ export function createAgentChatPlugin(options) {
|
|
|
2276
2317
|
// Same actions as A2A — without call-agent to prevent loops.
|
|
2277
2318
|
// In dev mode, template actions go through shell, not native tools.
|
|
2278
2319
|
const devActiveMcp = isDevMode();
|
|
2279
|
-
const mcpActions = devActiveMcp
|
|
2320
|
+
const mcpActions = attachToolSearch(devActiveMcp
|
|
2280
2321
|
? {
|
|
2281
2322
|
...resourceScripts,
|
|
2282
2323
|
...docsScripts,
|
|
@@ -2296,7 +2337,7 @@ export function createAgentChatPlugin(options) {
|
|
|
2296
2337
|
...urlTools,
|
|
2297
2338
|
...chatScripts,
|
|
2298
2339
|
...toolActions,
|
|
2299
|
-
};
|
|
2340
|
+
});
|
|
2300
2341
|
const mcpTools = actionsToEngineTools(mcpActions);
|
|
2301
2342
|
const resources = await loadResourcesForPrompt(DEV_MODE_USER_EMAIL, lazyContext);
|
|
2302
2343
|
const schemaBlock = lazyContext
|
|
@@ -2355,6 +2396,7 @@ export function createAgentChatPlugin(options) {
|
|
|
2355
2396
|
...discoveredActions,
|
|
2356
2397
|
...templateScripts,
|
|
2357
2398
|
...engineScripts,
|
|
2399
|
+
...loopSettingsScripts,
|
|
2358
2400
|
};
|
|
2359
2401
|
// Framework-level sharing actions — merged with skipExisting semantics so
|
|
2360
2402
|
// any template that provides a same-named action wins. When templates use
|
|
@@ -2599,15 +2641,15 @@ export function createAgentChatPlugin(options) {
|
|
|
2599
2641
|
// progress, call-agent, and MCP entries to keep the tool list tight and
|
|
2600
2642
|
// prevent the LLM from reaching for web-request instead of the
|
|
2601
2643
|
// template's native actions (e.g. log-meal).
|
|
2602
|
-
const leanActions = {
|
|
2644
|
+
const leanActions = attachToolSearch({
|
|
2603
2645
|
...templateScripts,
|
|
2604
2646
|
...resourceScripts,
|
|
2605
2647
|
...refreshScreenTool,
|
|
2606
2648
|
...urlTools,
|
|
2607
2649
|
...chatScripts,
|
|
2608
2650
|
...toolActions,
|
|
2609
|
-
};
|
|
2610
|
-
const prodActions = {
|
|
2651
|
+
});
|
|
2652
|
+
const prodActions = attachToolSearch({
|
|
2611
2653
|
...templateScripts,
|
|
2612
2654
|
...resourceScripts,
|
|
2613
2655
|
...docsScripts,
|
|
@@ -2626,7 +2668,7 @@ export function createAgentChatPlugin(options) {
|
|
|
2626
2668
|
...toolActions,
|
|
2627
2669
|
...browserTools,
|
|
2628
2670
|
...mcpActionEntries,
|
|
2629
|
-
};
|
|
2671
|
+
});
|
|
2630
2672
|
// Keep the prod action dict's MCP entries in sync when the manager's
|
|
2631
2673
|
// server set changes at runtime (e.g. a user adds a remote MCP server
|
|
2632
2674
|
// through the settings UI). getEngineTools() in production-agent re-reads
|
|
@@ -2732,7 +2774,7 @@ export function createAgentChatPlugin(options) {
|
|
|
2732
2774
|
// template's actions as native tools instead of routing through shell.
|
|
2733
2775
|
// Templates with structured-arg actions (objects/arrays) need this to
|
|
2734
2776
|
// avoid round-tripping JSON through the CLI parser.
|
|
2735
|
-
const devActions = leanPrompt
|
|
2777
|
+
const devActions = attachToolSearch(leanPrompt
|
|
2736
2778
|
? leanActions
|
|
2737
2779
|
: devNative
|
|
2738
2780
|
? prodActions
|
|
@@ -2752,7 +2794,7 @@ export function createAgentChatPlugin(options) {
|
|
|
2752
2794
|
...browserTools,
|
|
2753
2795
|
...mcpActionEntries,
|
|
2754
2796
|
...(await createDevScriptRegistry()),
|
|
2755
|
-
};
|
|
2797
|
+
});
|
|
2756
2798
|
// Keep dev action dict in sync with runtime MCP additions. When
|
|
2757
2799
|
// native-actions mode is on (lean or `nativeActionsInDev`), devActions
|
|
2758
2800
|
// === prodActions so the prod listener already covers it.
|