@agent-native/core 0.119.2 → 0.119.4
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/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +19 -0
- package/corpus/core/package.json +3 -3
- package/corpus/core/src/agent/production-agent.ts +107 -125
- package/corpus/core/src/agent/run-manager.ts +45 -2
- package/corpus/core/src/agent/thread-data-builder.ts +85 -8
- package/corpus/core/src/cli/create.ts +44 -5
- package/corpus/core/src/client/AssistantChat.tsx +37 -9
- package/corpus/core/src/client/chat/message-components.tsx +9 -1
- package/corpus/core/src/client/chat/repo-helpers.ts +77 -0
- package/corpus/core/src/client/chat/tool-call-display.tsx +51 -15
- package/corpus/core/src/server/agent-chat/framework-prompts.ts +3 -1
- package/corpus/core/src/server/agent-chat/plugin-options.ts +9 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +12 -3
- package/corpus/core/src/templates/chat/.agents/skills/actions/SKILL.md +512 -0
- package/corpus/core/src/templates/chat/.agents/skills/adding-a-feature/SKILL.md +189 -0
- package/corpus/core/src/templates/chat/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/core/src/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +177 -0
- package/corpus/core/src/templates/chat/.agents/skills/capture-learnings/SKILL.md +89 -0
- package/corpus/core/src/templates/chat/.agents/skills/create-skill/SKILL.md +221 -0
- package/corpus/core/src/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +220 -0
- package/corpus/core/src/templates/chat/.agents/skills/delegate-to-agent/SKILL.md +263 -0
- package/corpus/core/src/templates/chat/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/core/src/templates/chat/.agents/skills/frontend-design/SKILL.md +160 -0
- package/corpus/core/src/templates/chat/.agents/skills/real-time-sync/SKILL.md +232 -0
- package/corpus/core/src/templates/chat/.agents/skills/security/SKILL.md +280 -0
- package/corpus/core/src/templates/chat/.agents/skills/self-modifying-code/SKILL.md +118 -0
- package/corpus/core/src/templates/chat/.agents/skills/shadcn-ui/SKILL.md +119 -0
- package/corpus/core/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +100 -0
- package/corpus/core/src/templates/chat/.env.example +5 -0
- package/corpus/core/src/templates/chat/.ignore +0 -0
- package/corpus/core/src/templates/chat/.oxfmtrc.json +8 -0
- package/corpus/core/src/templates/chat/AGENTS.md +69 -0
- package/corpus/core/src/templates/chat/CHANGELOG.md +10 -0
- package/corpus/core/src/templates/chat/DEVELOPING.md +185 -0
- package/corpus/core/src/templates/chat/README.md +32 -0
- package/corpus/core/src/templates/chat/_gitignore +43 -0
- package/corpus/core/src/templates/chat/actions/hello.ts +13 -0
- package/corpus/core/src/templates/chat/actions/navigate.ts +41 -0
- package/corpus/core/src/templates/chat/actions/run.ts +2 -0
- package/corpus/core/src/templates/chat/actions/view-screen.ts +31 -0
- package/corpus/core/src/templates/chat/app/components/layout/Header.tsx +60 -0
- package/corpus/core/src/templates/chat/app/components/layout/Layout.tsx +185 -0
- package/corpus/core/src/templates/chat/app/components/layout/Sidebar.tsx +450 -0
- package/corpus/core/src/templates/chat/app/components/ui/button.tsx +1 -0
- package/corpus/core/src/templates/chat/app/components/ui/card.tsx +1 -0
- package/corpus/core/src/templates/chat/app/components/ui/dropdown-menu.tsx +1 -0
- package/corpus/core/src/templates/chat/app/components/ui/input.tsx +1 -0
- package/corpus/core/src/templates/chat/app/components/ui/label.tsx +1 -0
- package/corpus/core/src/templates/chat/app/components/ui/sheet.tsx +1 -0
- package/corpus/core/src/templates/chat/app/components/ui/toolkit-provider.tsx +17 -0
- package/corpus/core/src/templates/chat/app/components/ui/tooltip.tsx +1 -0
- package/corpus/core/src/templates/chat/app/design-system.ts +3 -0
- package/corpus/core/src/templates/chat/app/entry.client.tsx +19 -0
- package/corpus/core/src/templates/chat/app/entry.server.tsx +10 -0
- package/corpus/core/src/templates/chat/app/global.css +93 -0
- package/corpus/core/src/templates/chat/app/hooks/use-navigation-state.ts +93 -0
- package/corpus/core/src/templates/chat/app/i18n/ar-SA.ts +68 -0
- package/corpus/core/src/templates/chat/app/i18n/de-DE.ts +71 -0
- package/corpus/core/src/templates/chat/app/i18n/en-US.ts +70 -0
- package/corpus/core/src/templates/chat/app/i18n/es-ES.ts +71 -0
- package/corpus/core/src/templates/chat/app/i18n/fr-FR.ts +71 -0
- package/corpus/core/src/templates/chat/app/i18n/hi-IN.ts +69 -0
- package/corpus/core/src/templates/chat/app/i18n/index.ts +34 -0
- package/corpus/core/src/templates/chat/app/i18n/ja-JP.ts +70 -0
- package/corpus/core/src/templates/chat/app/i18n/ko-KR.ts +70 -0
- package/corpus/core/src/templates/chat/app/i18n/pt-BR.ts +71 -0
- package/corpus/core/src/templates/chat/app/i18n/zh-CN.ts +66 -0
- package/corpus/core/src/templates/chat/app/i18n/zh-TW.ts +66 -0
- package/corpus/core/src/templates/chat/app/i18n-data.ts +556 -0
- package/corpus/core/src/templates/chat/app/lib/agent-page.tsx +49 -0
- package/corpus/core/src/templates/chat/app/lib/app-config.ts +11 -0
- package/corpus/core/src/templates/chat/app/lib/tab-id.ts +1 -0
- package/corpus/core/src/templates/chat/app/lib/utils.ts +1 -0
- package/corpus/core/src/templates/chat/app/root.tsx +173 -0
- package/corpus/core/src/templates/chat/app/routes/_index.tsx +94 -0
- package/corpus/core/src/templates/chat/app/routes/agent.tsx +24 -0
- package/corpus/core/src/templates/chat/app/routes/chat.$threadId.tsx +1 -0
- package/corpus/core/src/templates/chat/app/routes/database.tsx +17 -0
- package/corpus/core/src/templates/chat/app/routes/extensions.$id.$slug.tsx +2 -0
- package/corpus/core/src/templates/chat/app/routes/extensions.$id.tsx +11 -0
- package/corpus/core/src/templates/chat/app/routes/extensions._index.tsx +11 -0
- package/corpus/core/src/templates/chat/app/routes/extensions.tsx +5 -0
- package/corpus/core/src/templates/chat/app/routes/observability.tsx +19 -0
- package/corpus/core/src/templates/chat/app/routes/settings.tsx +89 -0
- package/corpus/core/src/templates/chat/app/routes/team.tsx +11 -0
- package/corpus/core/src/templates/chat/app/routes.ts +4 -0
- package/corpus/core/src/templates/chat/app/vite-env.d.ts +6 -0
- package/corpus/core/src/templates/chat/changelog/2026-06-24-a-new-settings-page-gives-quick-access-to-language-workspace.md +6 -0
- package/corpus/core/src/templates/chat/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +6 -0
- package/corpus/core/src/templates/chat/changelog/2026-06-27-traditional-chinese-copy-uses-taiwan-terminology.md +6 -0
- package/corpus/core/src/templates/chat/changelog/2026-06-28-left-sidebar-collapse-motion-and-footer-chrome-are-quieter.md +6 -0
- package/corpus/core/src/templates/chat/changelog/2026-06-29-chat-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/core/src/templates/chat/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +5 -0
- package/corpus/core/src/templates/chat/changelog/2026-07-10-chat-now-makes-ai-connection-setup-clear-without-shifting-th.md +6 -0
- package/corpus/core/src/templates/chat/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +6 -0
- package/corpus/core/src/templates/chat/changelog/2026-07-14-chat-opens-reliably-on-hosted-deployments-instead-of-failing.md +6 -0
- package/corpus/core/src/templates/chat/changelog/2026-07-14-fixed-chat-template-startup-with-older-core-versions.md +6 -0
- package/corpus/core/src/templates/chat/changelog/2026-07-15-chat-navigation-focuses-on-chat-and-agent.md +6 -0
- package/corpus/core/src/templates/chat/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +6 -0
- package/corpus/core/src/templates/chat/changelog/2026-07-22-compact-sidebar-footer.md +6 -0
- package/corpus/core/src/templates/chat/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +6 -0
- package/corpus/core/src/templates/chat/changelog/2026-07-22-manage-agent-navigation-now-uses-the-connected-nodes-icon.md +6 -0
- package/corpus/core/src/templates/chat/changelog/2026-07-22-recent-chats-are-easier-to-scan-and-expand.md +6 -0
- package/corpus/core/src/templates/chat/changelog/2026-07-23-full-page-chat-is-better-centered-with-quieter-chat-history-.md +6 -0
- package/corpus/core/src/templates/chat/components.json +20 -0
- package/corpus/core/src/templates/chat/learnings.defaults.md +5 -0
- package/corpus/core/src/templates/chat/netlify.toml +10 -0
- package/corpus/core/src/templates/chat/package.json +92 -0
- package/corpus/core/src/templates/chat/public/agent-native-icon-dark.svg +10 -0
- package/corpus/core/src/templates/chat/public/agent-native-icon-light.svg +10 -0
- package/corpus/core/src/templates/chat/public/agent-native-logo-dark.svg +21 -0
- package/corpus/core/src/templates/chat/public/agent-native-logo-light.svg +21 -0
- package/corpus/core/src/templates/chat/public/favicon.svg +1 -0
- package/corpus/core/src/templates/chat/public/icon-180.svg +1 -0
- package/corpus/core/src/templates/chat/public/icon-192.svg +1 -0
- package/corpus/core/src/templates/chat/public/icon-512.svg +1 -0
- package/corpus/core/src/templates/chat/public/manifest.json +21 -0
- package/corpus/core/src/templates/chat/react-router.config.ts +7 -0
- package/corpus/core/src/templates/chat/server/middleware/auth.ts +15 -0
- package/corpus/core/src/templates/chat/server/plugins/agent-chat.ts +21 -0
- package/corpus/core/src/templates/chat/server/plugins/auth.ts +17 -0
- package/corpus/core/src/templates/chat/server/routes/[...page].get.ts +5 -0
- package/corpus/core/src/templates/chat/ssr-entry.ts +15 -0
- package/corpus/core/src/templates/chat/tsconfig.json +21 -0
- package/corpus/core/src/templates/chat/vite.config.ts +19 -0
- package/corpus/templates/analytics/AGENTS.md +19 -11
- package/corpus/templates/analytics/actions/list-data-dictionary.ts +3 -1
- package/corpus/templates/analytics/actions/save-data-dictionary-entry.ts +14 -0
- package/corpus/templates/analytics/actions/search-analytics-query-catalog.ts +41 -0
- package/corpus/templates/analytics/app/components/dashboard/DashboardPanelSkeleton.tsx +13 -0
- package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +12 -11
- package/corpus/templates/analytics/app/pages/adhoc/DashboardSkeleton.tsx +3 -3
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +7 -1
- package/corpus/templates/analytics/app/pages/analyses/AnalysisDetail.tsx +8 -1
- package/corpus/templates/analytics/changelog/2026-07-22-fixed-dashboards-and-analyses-missing-a-copyable-share-link.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-23-dashboard-chart-loading-placeholders-are-easier-to-see-in-da.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-23-routine-analytics-lookups-reuse-existing-query-definitions.md +6 -0
- package/corpus/templates/analytics/server/lib/agent-chat-plan-mode.ts +1 -12
- package/corpus/templates/analytics/server/lib/analytics-query-catalog.ts +405 -0
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +11 -16
- package/corpus/templates/content/changelog/2026-07-23-database-toolbar-sort-and-filter-controls-open-reliably.md +6 -0
- package/corpus/templates/forms/app/lib/public-form-link.ts +14 -0
- package/corpus/templates/forms/app/pages/FormBuilderPage.tsx +6 -14
- package/corpus/templates/forms/changelog/2026-07-23-published-form-links-can-be-copied-without-being-asked-to-re.md +6 -0
- package/corpus/templates/mail/changelog/2026-07-23-scheduled-emails-now-send-only-once-when-multiple-requests-r.md +6 -0
- package/corpus/templates/mail/server/lib/jobs.ts +13 -4
- package/corpus/templates/mail/server/plugins/mail-jobs.ts +1 -1
- package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +7 -18
- package/corpus/templates/slides/app/lib/agent-visible-message.ts +28 -0
- package/corpus/templates/slides/app/pages/Index.tsx +6 -34
- package/corpus/templates/slides/changelog/2026-07-23-full-prompts-stay-visible-in-chat-when-creating-decks-or-add.md +6 -0
- package/corpus/toolkit/CHANGELOG.md +13 -0
- package/corpus/toolkit/package.json +1 -1
- package/corpus/toolkit/src/editor/SharedRichEditor.tsx +23 -2
- package/corpus/toolkit/src/editor/SlashCommandMenu.tsx +68 -2
- package/corpus/toolkit/src/editor/index.ts +1 -0
- package/corpus/toolkit/src/editor.css +75 -0
- package/corpus/toolkit/src/ui/button.tsx +3 -2
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +96 -115
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-manager.d.ts +9 -1
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +26 -0
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/thread-data-builder.d.ts +2 -0
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +69 -9
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/cli/create.d.ts +2 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +43 -6
- package/dist/cli/create.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +32 -10
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/chat/message-components.d.ts +2 -1
- package/dist/client/chat/message-components.d.ts.map +1 -1
- package/dist/client/chat/message-components.js +9 -3
- package/dist/client/chat/message-components.js.map +1 -1
- package/dist/client/chat/repo-helpers.d.ts +4 -0
- package/dist/client/chat/repo-helpers.d.ts.map +1 -1
- package/dist/client/chat/repo-helpers.js +61 -0
- package/dist/client/chat/repo-helpers.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts +2 -1
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +10 -9
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/routes.d.ts +3 -3
- package/dist/provider-api/actions/custom-provider-registration.d.ts +7 -7
- package/dist/provider-api/actions/provider-api.d.ts +7 -7
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/agent-chat/framework-prompts.d.ts.map +1 -1
- package/dist/server/agent-chat/framework-prompts.js +3 -1
- package/dist/server/agent-chat/framework-prompts.js.map +1 -1
- package/dist/server/agent-chat/plugin-options.d.ts +9 -0
- package/dist/server/agent-chat/plugin-options.d.ts.map +1 -1
- package/dist/server/agent-chat/plugin-options.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +11 -2
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/package.json +4 -4
- package/src/agent/production-agent.ts +107 -125
- package/src/agent/run-manager.ts +45 -2
- package/src/agent/thread-data-builder.ts +85 -8
- package/src/cli/create.ts +44 -5
- package/src/client/AssistantChat.tsx +37 -9
- package/src/client/chat/message-components.tsx +9 -1
- package/src/client/chat/repo-helpers.ts +77 -0
- package/src/client/chat/tool-call-display.tsx +51 -15
- package/src/server/agent-chat/framework-prompts.ts +3 -1
- package/src/server/agent-chat/plugin-options.ts +9 -0
- package/src/server/agent-chat-plugin.ts +12 -3
- package/src/templates/chat/actions/hello.spec.ts +0 -23
- package/src/templates/chat/actions/navigate.spec.ts +0 -68
- package/src/templates/chat/actions/view-screen.spec.ts +0 -40
- package/src/templates/chat/app/lib/agent-page.spec.tsx +0 -61
|
@@ -73,6 +73,7 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
|
|
|
73
73
|
offset?: unknown;
|
|
74
74
|
limit?: unknown;
|
|
75
75
|
}, {
|
|
76
|
+
deleted?: undefined;
|
|
76
77
|
jobs: {
|
|
77
78
|
id: string;
|
|
78
79
|
name: string;
|
|
@@ -83,7 +84,6 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
|
|
|
83
84
|
updatedAt: string;
|
|
84
85
|
}[];
|
|
85
86
|
total: number;
|
|
86
|
-
deleted?: undefined;
|
|
87
87
|
jobId?: undefined;
|
|
88
88
|
} | {
|
|
89
89
|
jobs?: undefined;
|
|
@@ -91,9 +91,9 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
|
|
|
91
91
|
deleted: boolean;
|
|
92
92
|
jobId: string;
|
|
93
93
|
} | {
|
|
94
|
+
deleted?: undefined;
|
|
94
95
|
jobs?: undefined;
|
|
95
96
|
total?: undefined;
|
|
96
|
-
deleted?: undefined;
|
|
97
97
|
jobId?: undefined;
|
|
98
98
|
hits: Record<string, unknown>[];
|
|
99
99
|
offset: number;
|
|
@@ -49,8 +49,8 @@ export declare function handleUpdateResource(event: any): Promise<import("./stor
|
|
|
49
49
|
}>;
|
|
50
50
|
/** DELETE /_agent-native/resources/:id — delete a resource */
|
|
51
51
|
export declare function handleDeleteResource(event: any): Promise<{
|
|
52
|
-
ok?: undefined;
|
|
53
52
|
error: string;
|
|
53
|
+
ok?: undefined;
|
|
54
54
|
} | {
|
|
55
55
|
error?: undefined;
|
|
56
56
|
ok: boolean;
|
package/dist/secrets/routes.d.ts
CHANGED
|
@@ -34,37 +34,37 @@ export declare function createListSecretsHandler(): import("h3").EventHandlerWit
|
|
|
34
34
|
/** POST /_agent-native/secrets/:key — write a secret. */
|
|
35
35
|
export declare function createWriteSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
36
36
|
error: string;
|
|
37
|
-
ok?: undefined;
|
|
38
37
|
status?: undefined;
|
|
38
|
+
ok?: undefined;
|
|
39
39
|
} | {
|
|
40
|
-
error?: undefined;
|
|
41
40
|
ok: boolean;
|
|
42
41
|
status: string;
|
|
42
|
+
error?: undefined;
|
|
43
43
|
} | {
|
|
44
|
-
ok?: undefined;
|
|
45
44
|
error: string;
|
|
46
45
|
removed?: undefined;
|
|
46
|
+
ok?: undefined;
|
|
47
47
|
} | {
|
|
48
|
-
error?: undefined;
|
|
49
48
|
ok: boolean;
|
|
50
49
|
removed: boolean;
|
|
50
|
+
error?: undefined;
|
|
51
51
|
}>>;
|
|
52
52
|
/**
|
|
53
53
|
* POST /_agent-native/secrets/:key/test — re-run the validator against the
|
|
54
54
|
* current stored value without changing anything. Useful for the "Test" button.
|
|
55
55
|
*/
|
|
56
56
|
export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
57
|
-
ok?: undefined;
|
|
58
57
|
error: string;
|
|
59
58
|
note?: undefined;
|
|
59
|
+
ok?: undefined;
|
|
60
60
|
} | {
|
|
61
|
-
error?: undefined;
|
|
62
61
|
ok: boolean;
|
|
63
62
|
note?: undefined;
|
|
64
|
-
} | {
|
|
65
63
|
error?: undefined;
|
|
64
|
+
} | {
|
|
66
65
|
ok: boolean;
|
|
67
66
|
note: string;
|
|
67
|
+
error?: undefined;
|
|
68
68
|
} | {
|
|
69
69
|
note?: undefined;
|
|
70
70
|
ok: boolean;
|
|
@@ -95,12 +95,12 @@ export interface AdHocSecretPayload {
|
|
|
95
95
|
export declare function createAdHocSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<AdHocSecretPayload[] | {
|
|
96
96
|
error: string;
|
|
97
97
|
} | {
|
|
98
|
-
error?: undefined;
|
|
99
98
|
ok: boolean;
|
|
100
99
|
key: string;
|
|
101
|
-
} | {
|
|
102
100
|
error?: undefined;
|
|
101
|
+
} | {
|
|
103
102
|
ok: boolean;
|
|
104
103
|
removed: boolean;
|
|
104
|
+
error?: undefined;
|
|
105
105
|
}>>;
|
|
106
106
|
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-prompts.d.ts","sourceRoot":"","sources":["../../../src/server/agent-chat/framework-prompts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,qBAAqB,CAA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,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAC,GACtE,OAAO,CAAC,IAAI,CAAC,CAqCf"}
|
|
@@ -352,7 +352,9 @@ export function generateCorpusToolsPrompt(registry) {
|
|
|
352
352
|
|
|
353
353
|
Available corpus-capable tools: ${available.join(", ")}.
|
|
354
354
|
|
|
355
|
-
|
|
355
|
+
This workflow does not apply to ordinary structured lookups, bounded aggregates, or counts grouped over one known source. For those requests, use the single most directly authoritative source, run one bounded query, and answer as soon as it succeeds. Do not cross-check or expand into a corpus workflow unless the user asks for multiple sources, exhaustive unstructured-record coverage, or an absence claim.
|
|
356
|
+
|
|
357
|
+
For broad provider searches, raw API access, multi-page cohorts, cross-source joins, classification over unstructured 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 durable corpus jobs, staged-dataset queries, or code execution.
|
|
356
358
|
|
|
357
359
|
When \`provider-corpus-job\` is available, prefer it for transcript/message/ticket/issue/document scans that may exceed one turn, need provider-side backoff, or need a defensible "not found" conclusion. Use operation="start" with mode="paginated-search" for any paginated provider endpoint, or mode="batch-search" when a prior cohort of ids/records must feed a second provider endpoint. Continue paused jobs with operation="continue" until status is completed or quota_wait, then read operation="results". In run-code, prefer providerFetchAll() for short cursor/page/offset pagination and providerRequest() when response status, headers, or truncation metadata matters. Report source, filters, row counts, pagination/truncation, failed pages, quota_wait times, and remaining gaps.`;
|
|
358
360
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-prompts.js","sourceRoot":"","sources":["../../../src/server/agent-chat/framework-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AAIjC,OA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AChC,CAAC,CAAC;QACH,IAAI,KAAK;YACP,MAAM,YAAY,CAChB,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,EAC9B,OAAO,EACP,KAAK,GAAG,CAAC,EACT,OAAO,CACR,CAAC;IACN,CAAC;AACH,CAAC","sourcesContent":["import nodePath from \"node:path\";\n\nimport type { ActionEntry } from \"../../agent/production-agent.js\";\nimport type { DatabaseToolsOption } from \"../../scripts/db/tool-mode.js\";\nimport {\n buildFrameworkCore,\n buildFrameworkCoreCompact,\n type PromptExamples,\n} from \"../prompts/index.js\";\nimport { getRequestOrgId } from \"../request-context.js\";\nimport { loadSchemaPromptBlock } from \"../schema-prompt.js\";\nimport { resolveInitialToolNames } from \"./action-filters-a2a.js\";\nimport {\n createDataWidgetActionEntries,\n FRAMEWORK_CONTEXT_SECTIONS,\n} from \"./context-tools.js\";\nimport { lazyFs } from \"./lazy-fs.js\";\nimport { compactPromptLine } from \"./prompt-resources.js\";\n\n// ---------------------------------------------------------------------------\n// Framework-level system prompt assembly (production/dev, full/compact),\n// the \"Available Actions\" and corpus-tools prompt sections, the SQL schema\n// block, and the codebase file-tree walker used by a few dev-mode tools.\n// ---------------------------------------------------------------------------\n\nconst MAX_ACTION_SUMMARY_DESCRIPTION_CHARS = 140;\n\n/**\n * Framework-level instructions injected into every agent's system prompt.\n * Prompt text lives in packages/core/src/server/prompts/ so this file stays\n * focused on routing and assembly logic.\n *\n * buildFrameworkPrompts() is called once per plugin instantiation (not per\n * request) with the template's promptExamples, producing the four assembled\n * prompt strings used at request time.\n */\nexport function buildFrameworkPrompts(\n examples?: PromptExamples,\n options?: { databaseTools?: DatabaseToolsOption; extensionTools?: boolean },\n): {\n FRAMEWORK_CORE: string;\n FRAMEWORK_CORE_COMPACT: string;\n PROD_FRAMEWORK_PROMPT: string;\n DEV_FRAMEWORK_PROMPT: string;\n PROD_FRAMEWORK_PROMPT_COMPACT: string;\n DEV_FRAMEWORK_PROMPT_COMPACT: string;\n} {\n const FRAMEWORK_CORE = buildFrameworkCore(examples, options);\n const FRAMEWORK_CORE_COMPACT = buildFrameworkCoreCompact(examples, options);\n const extensionToolsEnabled = options?.extensionTools !== false;\n const planModeArtifactList = extensionToolsEnabled\n ? \"source-code handoffs and app-created artifacts such as extensions, widgets, dashboards, calculators, mini-apps, documents, designs, slides, or videos\"\n : \"source-code handoffs and app-created artifacts such as documents, designs, slides, or videos\";\n const planModeBlockedTools = extensionToolsEnabled\n ? \"`render-inline-extension`, `create-extension`, `update-extension`, `connect-builder`, or any action that creates, updates, deletes, sends, publishes, or persists data\"\n : \"`connect-builder`, or any action that creates, updates, deletes, sends, publishes, or persists data\";\n const extensionConnectBuilderGuard = extensionToolsEnabled\n ? \"If the complete request can be satisfied by a self-contained extension or an existing named slot, use `render-inline-extension`, `create-extension`, `show-extension-inline`, or `update-extension` instead. If the exact placement or behavior requires changing the host UI or no suitable slot exists, continue with the normal `connect-builder` source-change flow even if the user called it an extension; never stop at saying extensions cannot do it.\"\n : \"Because extension tools are disabled, do NOT invent an extension workflow. Only use `connect-builder` when the request genuinely requires changing the host app's source code.\";\n const extensionInstructionsFull = extensionToolsEnabled\n ? `### Generative UI and Extensions (Mini-Apps)\n\nIn Act mode, if the user asks for generated interactive UI in chat, choose the smallest extension action that matches the lifetime:\n\n- For a **one-time inline UI** that answers the current chat turn (knobs, controls, pickers, calculators, temporary dashboards, visualizers), call \\`render-inline-extension\\` immediately with a self-contained Alpine.js HTML body. It renders inside the transcript and is not saved.\n- For a **reusable or saved UI** (an extension/widget/dashboard/calculator/mini-app the user can reopen from Extensions), call \\`create-extension\\` with a self-contained Alpine.js HTML body. It saves to the Extensions view and also renders inline in chat.\n- To **reuse an existing saved extension inline**, call \\`show-extension-inline\\` with its id, or a search string when the id is unknown.\n\nThese are **NOT** source-code changes and do **NOT** go through \\`connect-builder\\`. Extensions are sandboxed mini-apps — no source files are touched, no PR is opened, no build is required. Saved extensions can be edited later via \\`update-extension\\`.\n\nIf the app exposes native actions or instructions for dashboards, reports, analyses, charts, documents, decks, or other domain artifacts, use those app-native actions first. Choose an extension only when the user explicitly asks for an extension/custom mini-app, or when the app's native artifact format cannot faithfully express the requested interaction.\n\nKeep \\`create-extension\\` payloads compact enough to finish quickly. For complex extensions, create a useful working v1 first, then call \\`update-extension\\` with focused edits for refinements instead of trying to assemble one enormous initial tool input.\n\nGenerated UI content can use appAction(), appFetch(), dbQuery(), extensionFetch(), extensionData, agentNative.ui.output(value, opts?), and agentNative.chat.send(...)/sendToAgentChat(...). Use appAction() for app data writes, and dbQuery() only for read-only inspection of known app SQL tables. It can receive chat inputs through slotContext/window.onSlotContext. Use agentNative.ui.output for passive current values from knobs, sliders, selections, and controls; it writes application state at \\`inline-ui:<extensionId>:output\\` scoped to the inline extension id returned by \\`render-inline-extension\\` or \\`show-extension-inline\\`. When the user later says \"use that value\", \"apply the current setting\", or similar, read it with \\`readAppState(\"inline-ui:<id>:output\")\\` instead of asking them to send it again. Use agentNative.chat.send for visible submit/apply actions that should put a message into chat. Transient extensionData is browser-local and not agent-readable, synced, promoted, or garbage-collected; use application_state/appFetch, appAction, ui.output, or chat.send for anything the agent or app must observe. Use semantic Tailwind classes like bg-background, text-foreground, bg-primary, border-border, and text-muted-foreground so the UI inherits the parent app theme.\n\nIf the user asks to change, edit, fix, style, rename, or add behavior to an existing extension/widget/dashboard/calculator/mini-app, use the current extension id from \\`<current-screen>\\` or \\`<current-url>\\` when present. Call \\`get-extension\\` only if you need to inspect its content, then call \\`update-extension\\` with exactly \\`id\\`, \\`operation\\`, and \\`payloadJson\\`; encode the operation payload as a JSON string and never send empty placeholder fields. After one content read, keep the body in working memory and use \\`operation=\"edit\"\\` with focused \\`edits\\`/\\`patches\\` inside \\`payloadJson\\`; do not loop on repeated \\`get-extension\\` + \\`run-code\\` string scans before writing. For a data-only repair, preserve the existing layout, CSS, copy, and interactions. Use \\`operation=\"replace\"\\` only when the user explicitly requests a broad visual rewrite or supplies a complete replacement body. Use \\`operation=\"metadata\"\\` for name/description/icon, and use \\`set-resource-visibility\\` for sharing changes. If a focused patch fails, read the current body and change the target rather than retrying identical arguments. Use \\`list-extensions\\` only when no current id/name is available. Existing extension edits are SQL data updates, not source-code changes, even when the request says \"change the UI\" or \"fix this\". Do **NOT** call \\`connect-builder\\` for existing extension edits.\n\nIn Act mode, when in doubt — if the request asks for a new small interactive utility and does not need reuse, choose \\`render-inline-extension\\`; if it mentions saving/reuse or asks for an extension/widget/dashboard/calculator/mini-app, choose \\`create-extension\\`. If it references an existing one or the current extension page, choose \\`update-extension\\`. Do **not** preface the call with planning text like \"let me build the dashboard…\" — just call the right extension action directly.\n\nNote: \"extension\" is the user-facing primitive (the sandboxed Alpine.js mini-app). Don't confuse it with the LLM concept of \"tools\" (function calls) — those are how you invoke ANY action, including \\`create-extension\\` itself.\n\nFor existing extensions, use \\`get-extension\\` or \\`update-extension\\` directly when \\`<current-screen>\\` or \\`<current-url>\\` provides an \\`extensionId\\`. Use \\`list-extensions\\` only to browse or resolve an unknown name. If the user wants a shared extension removed only from their view, use \\`hide-extension\\` — do not query or mutate the legacy \\`tools\\` table directly.\n\n### Extensions vs. Code Changes — Pick the Right Path\n\nRoute by the exact outcome, not by whether the user calls it an extension. Extensions render in their own sandboxed iframe, either on their own page or inside an existing named slot. They CANNOT change the host app's nav, restyle or inject elements into existing native components, replace built-in views, or render at an arbitrary location that has no slot.\n\n<routing>\n| The request is for… | Path |\n| ---------------------------------------------------------------- | ------------------------------ |\n| A one-off interactive answer inside chat (controls, picker, calculator, temporary visualizer) | \\`render-inline-extension\\` — inline only |\n| A new self-contained surface (widget, dashboard, calculator, viewer, list, tracker) | \\`create-extension\\` — ships instantly, no PR |\n| Loading a saved extension inside chat | \\`show-extension-inline\\` |\n| Editing an existing extension (fix, restyle, rename, add behavior) | \\`update-extension\\` |\n| The host app's own chrome (nav bar, sidebar, layout, routes, shipped components, existing styles, business logic) | \\`connect-builder\\` — a real source-code change |\n| UI inside or beside a native component where no named slot exists | \\`connect-builder\\` — add the native UI or a suitable slot in source |\n| Ambiguous, satisfiable either way (e.g. \"give me an unread view\") | \\`render-inline-extension\\` for chat-only, \\`create-extension\\` for reusable |\n</routing>\n\nIf an extension could only approximate the request in a different location, do not silently downgrade the requirement and do not end with \"extensions cannot do that.\" Briefly explain the boundary, then follow the normal source-code handoff so the app can still be customized fully.\n\nWorked examples: \"a widget showing unread emails grouped by sender\", \"a tracker for my newsletter subscriptions\", \"a custom kanban board with drag-and-drop rules the app does not have\" → \\`create-extension\\`. \"Add an Unread tab to the left navigation\", \"show local time beside every native Calendar attendee row\", \"make the subject lines wrap\", \"change the inbox grouping logic\", \"add a field to the compose form\" → \\`connect-builder\\`.`\n : `### Extensions Disabled\n\nExtension creation and management tools are disabled for this app. Do not claim you can create, edit, hide, or delete Agent-Native extensions unless the template exposes its own typed action for that workflow. For requests that would otherwise be handled as an extension/widget/dashboard/calculator mini-app, explain that this app has disabled extension tools and use the app's available actions instead.`;\n const extensionInstructionsCompact = extensionToolsEnabled\n ? `### Generative UI and Extensions (Mini-Apps)\n\nIn Act mode, if the user asks for generated interactive UI in chat, call \\`render-inline-extension\\` for one-time inline controls/knobs/calculators/visualizers that do not need saving. If the user asks for an **extension**, **widget**, **dashboard**, **calculator**, or **mini-app** that should be reusable or saved, call \\`create-extension\\` with a self-contained Alpine.js HTML body. To load a saved extension inline, call \\`show-extension-inline\\`. These are NOT code changes — extensions are sandboxed mini-apps. Do not preface with \"let me build…\" — just call the right extension action.\n\nUse app-native artifact actions first when they exist for dashboards, reports, analyses, charts, documents, decks, or similar domain artifacts. Pick \\`create-extension\\` only for explicit extension/custom mini-app requests or for behavior the native artifact format cannot support.\n\nKeep the first \\`create-extension\\` call compact and working. If the request is complex, create the v1 first and then refine with focused \\`update-extension\\` edits.\n\nGenerated UI can read chat inputs from slotContext/window.onSlotContext, see/update app state through appFetch/appAction, use extensionData, record passive current values through agentNative.ui.output(value, opts?), and send visible results through agentNative.chat.send(...) or sendToAgentChat(...). ui.output writes \\`inline-ui:<extensionId>:output\\` in application state; when the user asks to use the current slider/selection/value, read \\`readAppState(\"inline-ui:<id>:output\")\\`. Transient extensionData is browser-local only, so do not rely on it for values the agent or app must observe. Use semantic Tailwind theme classes.\n\nIf the user asks to change, edit, fix, style, rename, or add behavior to an existing extension/widget/dashboard/calculator/mini-app, use the current extension id from \\`<current-screen>\\` or \\`<current-url>\\` when present. Call \\`get-extension\\` only if you need to inspect its content, then call \\`update-extension\\` with exactly \\`id\\`, \\`operation\\`, and \\`payloadJson\\`; encode the operation payload as a JSON string and never send empty placeholder fields. After one content read, use \\`operation=\"edit\"\\` with focused \\`edits\\`/\\`patches\\` inside \\`payloadJson\\`; do not repeatedly re-read and scan the same HTML with \\`run-code\\` before writing. For a data-only repair, preserve the existing layout, CSS, copy, and interactions. Use \\`operation=\"replace\"\\` only when the user explicitly requests a broad visual rewrite or supplies a complete replacement body. Use \\`operation=\"metadata\"\\` for name/description/icon, and use \\`set-resource-visibility\\` for sharing changes. If a focused patch fails, read the current body and change the target rather than retrying identical arguments. Use \\`list-extensions\\` only when no current id/name is available. Existing extension edits are SQL data updates, not source-code changes. Do NOT call \\`connect-builder\\` for them.\n\nFor existing extensions, use \\`get-extension\\` or \\`update-extension\\` directly when \\`<current-screen>\\` or \\`<current-url>\\` provides an \\`extensionId\\`. Use \\`list-extensions\\` only to browse or resolve an unknown name. Use \\`hide-extension\\` when the user wants a shared extension removed only from their own view. Do not query the legacy \\`tools\\` table directly.\n\n### Extensions vs. Code Changes — Pick the Right Path\n\nIf the user wants a **one-off interactive answer in chat**, use \\`render-inline-extension\\`. If they want a **new reusable self-contained surface** (custom widget, dashboard, list, viewer, calculator), use \\`create-extension\\` — extensions ship instantly without a PR. Extensions can render only on their own page or in an existing named slot; they cannot inject UI into arbitrary native components. If the exact request changes host chrome, native components, layout, styles, routes, business logic, or needs placement where no slot exists, treat it as a source-code change and use the normal \\`connect-builder\\` flow even if the user called it an extension. Never stop at \"extensions cannot do that\" or silently offer a different placement; explain the boundary briefly and continue the code-change handoff.`\n : `### Extensions Disabled\n\nExtension creation and management tools are disabled for this app. Do not claim you can create, edit, hide, or delete Agent-Native extensions unless the template exposes its own typed action for that workflow.`;\n\n const PROD_FRAMEWORK_PROMPT = `## Agent-Native Framework — Production Mode\n\nYou are an AI agent in an agent-native application, running in **production mode**.\n\nThe agent and the UI are equal partners — everything the UI can do, you can do via your tools, and vice versa. They share the same SQL database and stay in sync automatically.\n\n**In production mode, you operate through registered actions exposed as tools.** These are your capabilities — use them to read data, take actions, and help the user. You cannot edit source code or access the filesystem directly. Your tools are the app's API.\n\n### Plan Mode\n\nIf the current turn is in Plan mode, plan before anything gets written. This applies to ${planModeArtifactList}. Use only read-only tools, clarify the goal when needed, and return a concrete plan for approval. Do not call ${planModeBlockedTools} until the user switches back to Act mode.\n\n${extensionInstructionsFull}\n\n### Code Changes Not Available — Call \\`connect-builder\\` Immediately\n\n${extensionConnectBuilderGuard}\n\nIn Act mode, when the user asks you to change the UI, modify code, add a feature, fix a bug in the app itself, change styles, add a hook, create a component, add a route, add an integration, or anything else that requires editing source files — you MUST take exactly these steps, in order:\n\n1. Briefly acknowledge the user's specific request in their own terms — one short clause naming what they asked for (e.g. \"Got it — wider subject lines in the email list.\"). Do NOT restate the request verbatim, do NOT add a generic preamble, and do NOT promise outcomes. Skip this step entirely if the user already knows you're handing off (e.g. they said \"send this to Builder\").\n2. Call the \\`connect-builder\\` tool, passing the user's full request verbatim as the \\`prompt\\` argument. This renders an inline card. The returned \\`builderEnabled\\` flag is authoritative: \\`true\\` means Builder Cloud Agents can take the code-change handoff; \\`false\\` means this still requires a code change, but no Builder Cloud Agent can run from this workspace. If Builder is connected and \\`builderEnabled\\` is true, the card hands the prompt off to Builder's cloud agent on one click and returns a branch URL. If Builder is not connected and \\`builderEnabled\\` is true, it shows the Connect Builder flow. If \\`builderEnabled\\` is false, it still shows the card, but as a code-change fallback instead of a runnable cloud handoff.\n3. After the card renders, inspect the tool result and write one sentence that frames the next click around what the user just asked — not as a Builder pitch. If \\`builderEnabled\\` is true and the card can send, say something like \"Click Send to Builder and it'll wire that up for you.\" If the user needs to connect first, say something like \"Connect Builder once and it'll handle this and future changes.\" If \\`builderEnabled\\` is false, say: \"This requires a code change. Edit locally or use Builder.io to edit this code in the cloud and continue customizing the app any way you like.\" Do NOT say \"click Send to Builder\", mention a branch URL, say the card is pre-loaded, or imply a Builder Cloud Agent can run when \\`builderEnabled\\` is false.\n\nWhen \\`builderEnabled\\` is false, Builder Cloud Agents are not self-serve from Builder org settings. Do NOT tell the user to go to Builder org settings, beta features, \"Cloud Agents\", or \"AI Agents\" to enable them. The only allowed guidance is the card's code-change fallback: edit locally, use Agent Native Desktop, or use Builder.io to edit this code in the cloud and continue customizing the app any way you like.\n\n**Act-mode handoff — do exactly this:** The moment a code change is requested, call \\`connect-builder\\` with the user's verbatim request, then write one sentence framing the next click. That is the whole job: Builder plans and edits in its own sandbox, so the planning, file-mapping, and code all happen there, not here. Keep your turn to the call plus that one sentence — skip code exploration, implementation plans, \\`resources\\` writes of specs, and sub-agents (they have no code-editing tools either). You don't need filesystem access to recommend Builder, so don't reach for it or list tools you lack.\n\nBuilder Cloud Agents are the recommended path when \\`builderEnabled\\` is true because they are one-click and run in the cloud. Local dev, Agent Native Desktop, and Builder.io cloud editing are the fallback when \\`builderEnabled\\` is false.\n${FRAMEWORK_CORE}`;\n\n const DEV_FRAMEWORK_PROMPT = `## Agent-Native Framework — Development Mode\n\nYou are an AI agent in an agent-native application, running in **development mode**.\n\nThe agent and the UI are equal partners — everything the UI can do, you can do via tools/scripts, and vice versa. They share the same SQL database and stay in sync automatically.\n\n**In development mode, you have full local access — use it with senior-engineer judgment** (read before you edit, keep changes scoped, verify before you claim done):\n- Run any shell command via the \\`bash\\` tool (node, curl, pnpm, rg, git, etc.), including arbitrary code: \\`bash({ command: 'node -e \"console.log(1+1)\"' })\\`\n- Read and write any file on the filesystem; edit source, install packages, modify the app\n- Query and modify the database\n- Call external APIs (via bash with curl, or via scripts)\n\nWhen no dedicated tool/action exists for what you need, reach for \\`bash\\` — e.g. \\`bash({ command: 'curl -s https://api.example.com/data' })\\`.\n\n**Template-specific actions are invoked via bash, NOT as direct tools.** In dev mode, the only tools registered as native tool calls are framework-level utilities (bash, read, edit, write, database, resources, chat, teams, jobs). Anything from the template's \\`actions/\\` directory must be run through bash: \\`bash({ command: 'pnpm action <name> --arg value' })\\`. The \"Available Actions\" section below shows the exact CLI syntax for each one — copy that command verbatim and pass it to \\`bash\\`. Do not try to call template actions by name as if they were tools; they will not appear in your tool list.\n\nWhen editing code, follow the agent-native architecture:\n- Every feature needs all four areas: UI + scripts + skills/instructions + application-state sync\n- All SQL must be dialect-agnostic (works on SQLite and Postgres)\n- No Node.js-specific APIs in server routes (must work on Cloudflare Workers, etc.)\n- Use shadcn/ui components and Tabler Icons for all UI work\n${FRAMEWORK_CORE}`;\n\n const PROD_FRAMEWORK_PROMPT_COMPACT = `## Agent-Native Framework — Production Mode\n\nYou are an AI agent in an agent-native application, running in **production mode**.\n\nThe agent and the UI are equal partners — everything the UI can do, you can do via your tools, and vice versa. They share the same SQL database and stay in sync automatically.\n\n**In production mode, you operate through registered actions exposed as tools.** These are your capabilities — use them to read data, take actions, and help the user. You cannot edit source code or access the filesystem directly. Your tools are the app's API.\n\n### Plan Mode\n\nIf the turn is in Plan mode, plan before anything gets written — including ${planModeArtifactList}. Use read-only tools only and do not call ${planModeBlockedTools} until the user switches back to Act mode.\n\n${extensionInstructionsCompact}\n\n### Code Changes — Call \\`connect-builder\\`\n\nIn Act mode, when a request genuinely needs a source-code edit (per the rules above), do this in order: (1) briefly acknowledge the user's specific ask in their own terms — one short clause, no preamble — then (2) call \\`connect-builder\\` with the user's request as the \\`prompt\\`, then (3) inspect \\`builderEnabled\\` in the result and write one sentence framing the next click around what they asked for, not a Builder pitch. When \\`builderEnabled\\` is true, Builder Cloud Agents can take the handoff; when \\`builderEnabled\\` is false, say this requires a code change and they can edit locally or use Builder.io to edit this code in the cloud and continue customizing the app any way they like. Do NOT write code, list files, make plans, or spawn sub-agents. Mention \\`npx agent-native create <app-name>\\`, Agent Native Desktop, or the code-change fallback when Builder Cloud Agents aren't available. Never tell users to enable Builder Cloud Agents from Builder org settings, beta features, \"Cloud Agents\", or \"AI Agents\"; they are not self-serve there.\n${FRAMEWORK_CORE_COMPACT}`;\n\n const DEV_FRAMEWORK_PROMPT_COMPACT = `## Agent-Native Framework — Development Mode\n\nYou are an AI agent in an agent-native application, running in **development mode**.\n\nThe agent and the UI are equal partners — everything the UI can do, you can do via tools/scripts, and vice versa. They share the same SQL database and stay in sync automatically.\n\n**In development mode, you have full local access** — shell, filesystem, database, external APIs, source edits, and package installs. Use it with senior-engineer judgment: read before you edit, keep changes scoped, verify before you claim done.\n\n**Template-specific actions are invoked via bash, NOT as direct tools.** Run them with: \\`bash({ command: 'pnpm action <name> --arg value' })\\`. See the \"Available Actions\" section below for CLI syntax.\n\nWhen editing code, follow the agent-native architecture:\n- Every feature needs all four areas: UI + scripts + skills/instructions + application-state sync\n- All SQL must be dialect-agnostic (works on SQLite and Postgres)\n- No Node.js-specific APIs in server routes (must work on Cloudflare Workers, etc.)\n- Use shadcn/ui components and Tabler Icons for all UI work\n${FRAMEWORK_CORE_COMPACT}`;\n\n return {\n FRAMEWORK_CORE,\n FRAMEWORK_CORE_COMPACT,\n PROD_FRAMEWORK_PROMPT,\n DEV_FRAMEWORK_PROMPT,\n PROD_FRAMEWORK_PROMPT_COMPACT,\n DEV_FRAMEWORK_PROMPT_COMPACT,\n };\n}\n\nexport const _agentChatPromptSectionsForTests = (() => {\n // Built with default (no template-specific) examples for test stability.\n const {\n FRAMEWORK_CORE: frameworkCore,\n FRAMEWORK_CORE_COMPACT: frameworkCoreCompact,\n } = buildFrameworkPrompts();\n return {\n frameworkCore,\n frameworkCoreCompact,\n frameworkContextSections: FRAMEWORK_CONTEXT_SECTIONS,\n buildFrameworkPrompts,\n generateActionsPrompt,\n resolveInitialToolNames,\n createDataWidgetActionEntries,\n };\n})();\n\n/**\n * Build the per-request SQL-schema context block. Reads AGENT_ORG_ID live\n * from the environment so scheduler/A2A/HTTP call sites all see whatever\n * org was just resolved for this request.\n */\nexport async function buildSchemaBlock(\n owner: string,\n databaseTools: DatabaseToolsOption = \"read\",\n): Promise<string> {\n try {\n return await loadSchemaPromptBlock({\n owner,\n orgId: getRequestOrgId() ?? null,\n databaseTools,\n });\n } catch {\n return \"\";\n }\n}\n\n/**\n * Generates a system prompt section describing registered template actions.\n * This helps the agent prefer template-specific actions over raw db-query/db-exec.\n *\n * Two output modes:\n *\n * - `\"tool\"` — used in production, where template actions are registered\n * as native Anthropic tools. Output reads `name(arg*: type; ...) — desc`.\n * - `\"cli\"` — used in dev, where template actions are NOT registered as\n * native tools and must be invoked via `bash(command=\"pnpm action ...\")`.\n * Output reads `pnpm action name --arg <type> [--opt <type>] — desc`.\n */\nexport function generateActionsPrompt(\n registry: Record<string, ActionEntry>,\n mode: \"cli\" | \"tool\" = \"tool\",\n initialToolNames?: string[],\n): string {\n if (!registry || Object.keys(registry).length === 0) return \"\";\n\n const allActionEntries = Object.entries(registry);\n const initialNames = initialToolNames ? new Set(initialToolNames) : undefined;\n const actionEntries = initialNames\n ? allActionEntries.filter(([name]) => initialNames.has(name))\n : allActionEntries;\n const omittedActionCount = allActionEntries.length - actionEntries.length;\n const nativeWidgetNote = (entry: ActionEntry) =>\n entry.chatUI && typeof entry.chatUI.renderer === \"string\"\n ? ` Native chat widget: \\`${entry.chatUI.renderer}\\`.`\n : \"\";\n\n if (mode === \"tool\") {\n const summaryLines = actionEntries.map(([name, entry]) => {\n const desc = compactPromptLine(\n entry.tool.description,\n MAX_ACTION_SUMMARY_DESCRIPTION_CHARS,\n );\n return `- \\`${name}\\` — ${desc}${nativeWidgetNote(entry)}`;\n });\n\n return `\\n\\n## Available Actions\n\n**Use these actions directly as tool calls.** They handle database access, validation, and business logic internally. The native tool schemas contain the full parameter details.\n\n${summaryLines.join(\"\\n\")}${\n omittedActionCount > 0\n ? `\\n\\n${omittedActionCount} less-common app action${omittedActionCount === 1 ? \" is\" : \"s are\"} available on demand. Use \\`tool-search\\` with a specific capability query to load the matching schemas when needed.`\n : \"\"\n }`;\n }\n\n const lines = actionEntries.map(([name, entry]) => {\n const desc = entry.tool.description;\n const params = entry.tool.parameters?.properties;\n const requiredFields = new Set(entry.tool.parameters?.required ?? []);\n\n // CLI mode: emit `pnpm action <name> --required <type> [--optional <type>]`\n if (!params || Object.keys(params).length === 0) {\n return `- \\`pnpm action ${name}\\` — ${desc}${nativeWidgetNote(entry)}`;\n }\n const entries = Object.entries(params);\n // Required first (alphabetical), then optional (alphabetical)\n entries.sort(([a], [b]) => {\n const ar = requiredFields.has(a) ? 0 : 1;\n const br = requiredFields.has(b) ? 0 : 1;\n if (ar !== br) return ar - br;\n return a.localeCompare(b);\n });\n const required: string[] = [];\n const optional: string[] = [];\n const requiredNames: string[] = [];\n for (const [k, v] of entries) {\n const type = (v as { type?: string }).type ?? \"any\";\n const flag = `--${k} <${type}>`;\n if (requiredFields.has(k)) {\n required.push(flag);\n requiredNames.push(`--${k}`);\n } else {\n optional.push(`[${flag}]`);\n }\n }\n const cmd = [\"pnpm action \" + name, ...required, ...optional].join(\" \");\n const requiredNote =\n requiredNames.length > 0 ? ` Required: ${requiredNames.join(\", \")}.` : \"\";\n return `- \\`${cmd}\\` — ${desc}.${requiredNote}${nativeWidgetNote(entry)}`;\n });\n\n return `\\n\\n## Available Actions\n\n**These template actions are NOT exposed as direct tools in dev mode. To run any of them, use the \\`bash\\` tool with the exact command shown below.** Example: \\`bash(command=\"pnpm action add-slide --deckId abc --content 'Hello'\")\\`.\n\nDo NOT try to call these by name as if they were tools — they will not exist in your tool list. Always go through \\`bash\\`.\n\n${lines.join(\"\\n\")}`;\n}\n\n/**\n * Tool names `generateCorpusToolsPrompt` teaches BY NAME, in the same order\n * it lists them. Exported so callers that build a request's initial\n * engine-tool set can fold in exactly the subset present in a given\n * registry — keeping \"what the prompt just told the model exists\" and\n * \"what tools are actually callable on the first request\" in sync. See the\n * corpus-prompt/initial-tools note at this function's call site in\n * agent-chat-plugin.ts.\n */\nconst CORPUS_TOOL_NAMES = [\n \"provider-api-catalog\",\n \"provider-api-docs\",\n \"provider-api-request\",\n \"provider-corpus-job\",\n \"query-staged-dataset\",\n \"run-code\",\n] as const;\n\nexport function corpusToolNamesTaughtByPrompt(\n registry: Record<string, ActionEntry>,\n): string[] {\n return CORPUS_TOOL_NAMES.filter((name) => name in registry);\n}\n\nexport function generateCorpusToolsPrompt(\n registry: Record<string, ActionEntry>,\n): string {\n const hasProviderApi = \"provider-api-request\" in registry;\n const hasProviderCorpusJob = \"provider-corpus-job\" in registry;\n const providerDiscoveryTools = [\n \"provider-api-catalog\" in registry ? \"`provider-api-catalog`\" : null,\n \"provider-api-docs\" in registry ? \"`provider-api-docs`\" : null,\n ].filter(Boolean);\n const hasRunCode = \"run-code\" in registry;\n const hasStagedDataset = \"query-staged-dataset\" in registry;\n if (\n !hasProviderApi &&\n !hasProviderCorpusJob &&\n !hasRunCode &&\n !hasStagedDataset\n )\n return \"\";\n\n const available = [\n ...providerDiscoveryTools,\n hasProviderApi ? \"`provider-api-request`\" : null,\n hasProviderCorpusJob ? \"`provider-corpus-job`\" : null,\n hasStagedDataset ? \"`query-staged-dataset`\" : null,\n hasRunCode ? \"`run-code`\" : null,\n ].filter(Boolean);\n\n return `\\n\\n## Broad Provider And Corpus Workflows\n\nAvailable corpus-capable tools: ${available.join(\", \")}.\n\nFor 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 durable corpus jobs, staged-dataset queries, or code execution.\n\nWhen \\`provider-corpus-job\\` is available, prefer it for transcript/message/ticket/issue/document scans that may exceed one turn, need provider-side backoff, or need a defensible \"not found\" conclusion. Use operation=\"start\" with mode=\"paginated-search\" for any paginated provider endpoint, or mode=\"batch-search\" when a prior cohort of ids/records must feed a second provider endpoint. Continue paused jobs with operation=\"continue\" until status is completed or quota_wait, then read operation=\"results\". In run-code, prefer providerFetchAll() for short cursor/page/offset pagination and providerRequest() when response status, headers, or truncation metadata matters. Report source, filters, row counts, pagination/truncation, failed pages, quota_wait times, and remaining gaps.`;\n}\n\n/**\n * Walks the local filesystem (dev mode only) to build a bounded file/folder\n * tree, used by a couple of dev-mode workspace-inspection tools.\n */\nexport async function collectFiles(\n dir: string,\n prefix: string,\n depth: number,\n results: Array<{ path: string; name: string; type: \"file\" | \"folder\" }>,\n): Promise<void> {\n if (depth > 4 || results.length >= 500) return;\n const skip = new Set([\n \"node_modules\",\n \".git\",\n \".next\",\n \".output\",\n \"dist\",\n \".cache\",\n \".turbo\",\n \"data\",\n ]);\n let entries: import(\"fs\").Dirent[];\n try {\n const fs = await lazyFs();\n entries = fs.readdirSync(dir, { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries) {\n if (results.length >= 500) return;\n if (skip.has(entry.name) || entry.name.startsWith(\".\")) continue;\n const relPath = prefix ? `${prefix}/${entry.name}` : entry.name;\n const isDir = entry.isDirectory();\n results.push({\n path: relPath,\n name: entry.name,\n type: isDir ? \"folder\" : \"file\",\n });\n if (isDir)\n await collectFiles(\n nodePath.join(dir, entry.name),\n relPath,\n depth + 1,\n results,\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"framework-prompts.js","sourceRoot":"","sources":["../../../src/server/agent-chat/framework-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AAIjC,OAAO,EACL,kBAAkB,EAClB,yBAAyB,GAE1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MA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sourcesContent":["import nodePath from \"node:path\";\n\nimport type { ActionEntry } from \"../../agent/production-agent.js\";\nimport type { DatabaseToolsOption } from \"../../scripts/db/tool-mode.js\";\nimport {\n buildFrameworkCore,\n buildFrameworkCoreCompact,\n type PromptExamples,\n} from \"../prompts/index.js\";\nimport { getRequestOrgId } from \"../request-context.js\";\nimport { loadSchemaPromptBlock } from \"../schema-prompt.js\";\nimport { resolveInitialToolNames } from \"./action-filters-a2a.js\";\nimport {\n createDataWidgetActionEntries,\n FRAMEWORK_CONTEXT_SECTIONS,\n} from \"./context-tools.js\";\nimport { lazyFs } from \"./lazy-fs.js\";\nimport { compactPromptLine } from \"./prompt-resources.js\";\n\n// ---------------------------------------------------------------------------\n// Framework-level system prompt assembly (production/dev, full/compact),\n// the \"Available Actions\" and corpus-tools prompt sections, the SQL schema\n// block, and the codebase file-tree walker used by a few dev-mode tools.\n// ---------------------------------------------------------------------------\n\nconst MAX_ACTION_SUMMARY_DESCRIPTION_CHARS = 140;\n\n/**\n * Framework-level instructions injected into every agent's system prompt.\n * Prompt text lives in packages/core/src/server/prompts/ so this file stays\n * focused on routing and assembly logic.\n *\n * buildFrameworkPrompts() is called once per plugin instantiation (not per\n * request) with the template's promptExamples, producing the four assembled\n * prompt strings used at request time.\n */\nexport function buildFrameworkPrompts(\n examples?: PromptExamples,\n options?: { databaseTools?: DatabaseToolsOption; extensionTools?: boolean },\n): {\n FRAMEWORK_CORE: string;\n FRAMEWORK_CORE_COMPACT: string;\n PROD_FRAMEWORK_PROMPT: string;\n DEV_FRAMEWORK_PROMPT: string;\n PROD_FRAMEWORK_PROMPT_COMPACT: string;\n DEV_FRAMEWORK_PROMPT_COMPACT: string;\n} {\n const FRAMEWORK_CORE = buildFrameworkCore(examples, options);\n const FRAMEWORK_CORE_COMPACT = buildFrameworkCoreCompact(examples, options);\n const extensionToolsEnabled = options?.extensionTools !== false;\n const planModeArtifactList = extensionToolsEnabled\n ? \"source-code handoffs and app-created artifacts such as extensions, widgets, dashboards, calculators, mini-apps, documents, designs, slides, or videos\"\n : \"source-code handoffs and app-created artifacts such as documents, designs, slides, or videos\";\n const planModeBlockedTools = extensionToolsEnabled\n ? \"`render-inline-extension`, `create-extension`, `update-extension`, `connect-builder`, or any action that creates, updates, deletes, sends, publishes, or persists data\"\n : \"`connect-builder`, or any action that creates, updates, deletes, sends, publishes, or persists data\";\n const extensionConnectBuilderGuard = extensionToolsEnabled\n ? \"If the complete request can be satisfied by a self-contained extension or an existing named slot, use `render-inline-extension`, `create-extension`, `show-extension-inline`, or `update-extension` instead. If the exact placement or behavior requires changing the host UI or no suitable slot exists, continue with the normal `connect-builder` source-change flow even if the user called it an extension; never stop at saying extensions cannot do it.\"\n : \"Because extension tools are disabled, do NOT invent an extension workflow. Only use `connect-builder` when the request genuinely requires changing the host app's source code.\";\n const extensionInstructionsFull = extensionToolsEnabled\n ? `### Generative UI and Extensions (Mini-Apps)\n\nIn Act mode, if the user asks for generated interactive UI in chat, choose the smallest extension action that matches the lifetime:\n\n- For a **one-time inline UI** that answers the current chat turn (knobs, controls, pickers, calculators, temporary dashboards, visualizers), call \\`render-inline-extension\\` immediately with a self-contained Alpine.js HTML body. It renders inside the transcript and is not saved.\n- For a **reusable or saved UI** (an extension/widget/dashboard/calculator/mini-app the user can reopen from Extensions), call \\`create-extension\\` with a self-contained Alpine.js HTML body. It saves to the Extensions view and also renders inline in chat.\n- To **reuse an existing saved extension inline**, call \\`show-extension-inline\\` with its id, or a search string when the id is unknown.\n\nThese are **NOT** source-code changes and do **NOT** go through \\`connect-builder\\`. Extensions are sandboxed mini-apps — no source files are touched, no PR is opened, no build is required. Saved extensions can be edited later via \\`update-extension\\`.\n\nIf the app exposes native actions or instructions for dashboards, reports, analyses, charts, documents, decks, or other domain artifacts, use those app-native actions first. Choose an extension only when the user explicitly asks for an extension/custom mini-app, or when the app's native artifact format cannot faithfully express the requested interaction.\n\nKeep \\`create-extension\\` payloads compact enough to finish quickly. For complex extensions, create a useful working v1 first, then call \\`update-extension\\` with focused edits for refinements instead of trying to assemble one enormous initial tool input.\n\nGenerated UI content can use appAction(), appFetch(), dbQuery(), extensionFetch(), extensionData, agentNative.ui.output(value, opts?), and agentNative.chat.send(...)/sendToAgentChat(...). Use appAction() for app data writes, and dbQuery() only for read-only inspection of known app SQL tables. It can receive chat inputs through slotContext/window.onSlotContext. Use agentNative.ui.output for passive current values from knobs, sliders, selections, and controls; it writes application state at \\`inline-ui:<extensionId>:output\\` scoped to the inline extension id returned by \\`render-inline-extension\\` or \\`show-extension-inline\\`. When the user later says \"use that value\", \"apply the current setting\", or similar, read it with \\`readAppState(\"inline-ui:<id>:output\")\\` instead of asking them to send it again. Use agentNative.chat.send for visible submit/apply actions that should put a message into chat. Transient extensionData is browser-local and not agent-readable, synced, promoted, or garbage-collected; use application_state/appFetch, appAction, ui.output, or chat.send for anything the agent or app must observe. Use semantic Tailwind classes like bg-background, text-foreground, bg-primary, border-border, and text-muted-foreground so the UI inherits the parent app theme.\n\nIf the user asks to change, edit, fix, style, rename, or add behavior to an existing extension/widget/dashboard/calculator/mini-app, use the current extension id from \\`<current-screen>\\` or \\`<current-url>\\` when present. Call \\`get-extension\\` only if you need to inspect its content, then call \\`update-extension\\` with exactly \\`id\\`, \\`operation\\`, and \\`payloadJson\\`; encode the operation payload as a JSON string and never send empty placeholder fields. After one content read, keep the body in working memory and use \\`operation=\"edit\"\\` with focused \\`edits\\`/\\`patches\\` inside \\`payloadJson\\`; do not loop on repeated \\`get-extension\\` + \\`run-code\\` string scans before writing. For a data-only repair, preserve the existing layout, CSS, copy, and interactions. Use \\`operation=\"replace\"\\` only when the user explicitly requests a broad visual rewrite or supplies a complete replacement body. Use \\`operation=\"metadata\"\\` for name/description/icon, and use \\`set-resource-visibility\\` for sharing changes. If a focused patch fails, read the current body and change the target rather than retrying identical arguments. Use \\`list-extensions\\` only when no current id/name is available. Existing extension edits are SQL data updates, not source-code changes, even when the request says \"change the UI\" or \"fix this\". Do **NOT** call \\`connect-builder\\` for existing extension edits.\n\nIn Act mode, when in doubt — if the request asks for a new small interactive utility and does not need reuse, choose \\`render-inline-extension\\`; if it mentions saving/reuse or asks for an extension/widget/dashboard/calculator/mini-app, choose \\`create-extension\\`. If it references an existing one or the current extension page, choose \\`update-extension\\`. Do **not** preface the call with planning text like \"let me build the dashboard…\" — just call the right extension action directly.\n\nNote: \"extension\" is the user-facing primitive (the sandboxed Alpine.js mini-app). Don't confuse it with the LLM concept of \"tools\" (function calls) — those are how you invoke ANY action, including \\`create-extension\\` itself.\n\nFor existing extensions, use \\`get-extension\\` or \\`update-extension\\` directly when \\`<current-screen>\\` or \\`<current-url>\\` provides an \\`extensionId\\`. Use \\`list-extensions\\` only to browse or resolve an unknown name. If the user wants a shared extension removed only from their view, use \\`hide-extension\\` — do not query or mutate the legacy \\`tools\\` table directly.\n\n### Extensions vs. Code Changes — Pick the Right Path\n\nRoute by the exact outcome, not by whether the user calls it an extension. Extensions render in their own sandboxed iframe, either on their own page or inside an existing named slot. They CANNOT change the host app's nav, restyle or inject elements into existing native components, replace built-in views, or render at an arbitrary location that has no slot.\n\n<routing>\n| The request is for… | Path |\n| ---------------------------------------------------------------- | ------------------------------ |\n| A one-off interactive answer inside chat (controls, picker, calculator, temporary visualizer) | \\`render-inline-extension\\` — inline only |\n| A new self-contained surface (widget, dashboard, calculator, viewer, list, tracker) | \\`create-extension\\` — ships instantly, no PR |\n| Loading a saved extension inside chat | \\`show-extension-inline\\` |\n| Editing an existing extension (fix, restyle, rename, add behavior) | \\`update-extension\\` |\n| The host app's own chrome (nav bar, sidebar, layout, routes, shipped components, existing styles, business logic) | \\`connect-builder\\` — a real source-code change |\n| UI inside or beside a native component where no named slot exists | \\`connect-builder\\` — add the native UI or a suitable slot in source |\n| Ambiguous, satisfiable either way (e.g. \"give me an unread view\") | \\`render-inline-extension\\` for chat-only, \\`create-extension\\` for reusable |\n</routing>\n\nIf an extension could only approximate the request in a different location, do not silently downgrade the requirement and do not end with \"extensions cannot do that.\" Briefly explain the boundary, then follow the normal source-code handoff so the app can still be customized fully.\n\nWorked examples: \"a widget showing unread emails grouped by sender\", \"a tracker for my newsletter subscriptions\", \"a custom kanban board with drag-and-drop rules the app does not have\" → \\`create-extension\\`. \"Add an Unread tab to the left navigation\", \"show local time beside every native Calendar attendee row\", \"make the subject lines wrap\", \"change the inbox grouping logic\", \"add a field to the compose form\" → \\`connect-builder\\`.`\n : `### Extensions Disabled\n\nExtension creation and management tools are disabled for this app. Do not claim you can create, edit, hide, or delete Agent-Native extensions unless the template exposes its own typed action for that workflow. For requests that would otherwise be handled as an extension/widget/dashboard/calculator mini-app, explain that this app has disabled extension tools and use the app's available actions instead.`;\n const extensionInstructionsCompact = extensionToolsEnabled\n ? `### Generative UI and Extensions (Mini-Apps)\n\nIn Act mode, if the user asks for generated interactive UI in chat, call \\`render-inline-extension\\` for one-time inline controls/knobs/calculators/visualizers that do not need saving. If the user asks for an **extension**, **widget**, **dashboard**, **calculator**, or **mini-app** that should be reusable or saved, call \\`create-extension\\` with a self-contained Alpine.js HTML body. To load a saved extension inline, call \\`show-extension-inline\\`. These are NOT code changes — extensions are sandboxed mini-apps. Do not preface with \"let me build…\" — just call the right extension action.\n\nUse app-native artifact actions first when they exist for dashboards, reports, analyses, charts, documents, decks, or similar domain artifacts. Pick \\`create-extension\\` only for explicit extension/custom mini-app requests or for behavior the native artifact format cannot support.\n\nKeep the first \\`create-extension\\` call compact and working. If the request is complex, create the v1 first and then refine with focused \\`update-extension\\` edits.\n\nGenerated UI can read chat inputs from slotContext/window.onSlotContext, see/update app state through appFetch/appAction, use extensionData, record passive current values through agentNative.ui.output(value, opts?), and send visible results through agentNative.chat.send(...) or sendToAgentChat(...). ui.output writes \\`inline-ui:<extensionId>:output\\` in application state; when the user asks to use the current slider/selection/value, read \\`readAppState(\"inline-ui:<id>:output\")\\`. Transient extensionData is browser-local only, so do not rely on it for values the agent or app must observe. Use semantic Tailwind theme classes.\n\nIf the user asks to change, edit, fix, style, rename, or add behavior to an existing extension/widget/dashboard/calculator/mini-app, use the current extension id from \\`<current-screen>\\` or \\`<current-url>\\` when present. Call \\`get-extension\\` only if you need to inspect its content, then call \\`update-extension\\` with exactly \\`id\\`, \\`operation\\`, and \\`payloadJson\\`; encode the operation payload as a JSON string and never send empty placeholder fields. After one content read, use \\`operation=\"edit\"\\` with focused \\`edits\\`/\\`patches\\` inside \\`payloadJson\\`; do not repeatedly re-read and scan the same HTML with \\`run-code\\` before writing. For a data-only repair, preserve the existing layout, CSS, copy, and interactions. Use \\`operation=\"replace\"\\` only when the user explicitly requests a broad visual rewrite or supplies a complete replacement body. Use \\`operation=\"metadata\"\\` for name/description/icon, and use \\`set-resource-visibility\\` for sharing changes. If a focused patch fails, read the current body and change the target rather than retrying identical arguments. Use \\`list-extensions\\` only when no current id/name is available. Existing extension edits are SQL data updates, not source-code changes. Do NOT call \\`connect-builder\\` for them.\n\nFor existing extensions, use \\`get-extension\\` or \\`update-extension\\` directly when \\`<current-screen>\\` or \\`<current-url>\\` provides an \\`extensionId\\`. Use \\`list-extensions\\` only to browse or resolve an unknown name. Use \\`hide-extension\\` when the user wants a shared extension removed only from their own view. Do not query the legacy \\`tools\\` table directly.\n\n### Extensions vs. Code Changes — Pick the Right Path\n\nIf the user wants a **one-off interactive answer in chat**, use \\`render-inline-extension\\`. If they want a **new reusable self-contained surface** (custom widget, dashboard, list, viewer, calculator), use \\`create-extension\\` — extensions ship instantly without a PR. Extensions can render only on their own page or in an existing named slot; they cannot inject UI into arbitrary native components. If the exact request changes host chrome, native components, layout, styles, routes, business logic, or needs placement where no slot exists, treat it as a source-code change and use the normal \\`connect-builder\\` flow even if the user called it an extension. Never stop at \"extensions cannot do that\" or silently offer a different placement; explain the boundary briefly and continue the code-change handoff.`\n : `### Extensions Disabled\n\nExtension creation and management tools are disabled for this app. Do not claim you can create, edit, hide, or delete Agent-Native extensions unless the template exposes its own typed action for that workflow.`;\n\n const PROD_FRAMEWORK_PROMPT = `## Agent-Native Framework — Production Mode\n\nYou are an AI agent in an agent-native application, running in **production mode**.\n\nThe agent and the UI are equal partners — everything the UI can do, you can do via your tools, and vice versa. They share the same SQL database and stay in sync automatically.\n\n**In production mode, you operate through registered actions exposed as tools.** These are your capabilities — use them to read data, take actions, and help the user. You cannot edit source code or access the filesystem directly. Your tools are the app's API.\n\n### Plan Mode\n\nIf the current turn is in Plan mode, plan before anything gets written. This applies to ${planModeArtifactList}. Use only read-only tools, clarify the goal when needed, and return a concrete plan for approval. Do not call ${planModeBlockedTools} until the user switches back to Act mode.\n\n${extensionInstructionsFull}\n\n### Code Changes Not Available — Call \\`connect-builder\\` Immediately\n\n${extensionConnectBuilderGuard}\n\nIn Act mode, when the user asks you to change the UI, modify code, add a feature, fix a bug in the app itself, change styles, add a hook, create a component, add a route, add an integration, or anything else that requires editing source files — you MUST take exactly these steps, in order:\n\n1. Briefly acknowledge the user's specific request in their own terms — one short clause naming what they asked for (e.g. \"Got it — wider subject lines in the email list.\"). Do NOT restate the request verbatim, do NOT add a generic preamble, and do NOT promise outcomes. Skip this step entirely if the user already knows you're handing off (e.g. they said \"send this to Builder\").\n2. Call the \\`connect-builder\\` tool, passing the user's full request verbatim as the \\`prompt\\` argument. This renders an inline card. The returned \\`builderEnabled\\` flag is authoritative: \\`true\\` means Builder Cloud Agents can take the code-change handoff; \\`false\\` means this still requires a code change, but no Builder Cloud Agent can run from this workspace. If Builder is connected and \\`builderEnabled\\` is true, the card hands the prompt off to Builder's cloud agent on one click and returns a branch URL. If Builder is not connected and \\`builderEnabled\\` is true, it shows the Connect Builder flow. If \\`builderEnabled\\` is false, it still shows the card, but as a code-change fallback instead of a runnable cloud handoff.\n3. After the card renders, inspect the tool result and write one sentence that frames the next click around what the user just asked — not as a Builder pitch. If \\`builderEnabled\\` is true and the card can send, say something like \"Click Send to Builder and it'll wire that up for you.\" If the user needs to connect first, say something like \"Connect Builder once and it'll handle this and future changes.\" If \\`builderEnabled\\` is false, say: \"This requires a code change. Edit locally or use Builder.io to edit this code in the cloud and continue customizing the app any way you like.\" Do NOT say \"click Send to Builder\", mention a branch URL, say the card is pre-loaded, or imply a Builder Cloud Agent can run when \\`builderEnabled\\` is false.\n\nWhen \\`builderEnabled\\` is false, Builder Cloud Agents are not self-serve from Builder org settings. Do NOT tell the user to go to Builder org settings, beta features, \"Cloud Agents\", or \"AI Agents\" to enable them. The only allowed guidance is the card's code-change fallback: edit locally, use Agent Native Desktop, or use Builder.io to edit this code in the cloud and continue customizing the app any way you like.\n\n**Act-mode handoff — do exactly this:** The moment a code change is requested, call \\`connect-builder\\` with the user's verbatim request, then write one sentence framing the next click. That is the whole job: Builder plans and edits in its own sandbox, so the planning, file-mapping, and code all happen there, not here. Keep your turn to the call plus that one sentence — skip code exploration, implementation plans, \\`resources\\` writes of specs, and sub-agents (they have no code-editing tools either). You don't need filesystem access to recommend Builder, so don't reach for it or list tools you lack.\n\nBuilder Cloud Agents are the recommended path when \\`builderEnabled\\` is true because they are one-click and run in the cloud. Local dev, Agent Native Desktop, and Builder.io cloud editing are the fallback when \\`builderEnabled\\` is false.\n${FRAMEWORK_CORE}`;\n\n const DEV_FRAMEWORK_PROMPT = `## Agent-Native Framework — Development Mode\n\nYou are an AI agent in an agent-native application, running in **development mode**.\n\nThe agent and the UI are equal partners — everything the UI can do, you can do via tools/scripts, and vice versa. They share the same SQL database and stay in sync automatically.\n\n**In development mode, you have full local access — use it with senior-engineer judgment** (read before you edit, keep changes scoped, verify before you claim done):\n- Run any shell command via the \\`bash\\` tool (node, curl, pnpm, rg, git, etc.), including arbitrary code: \\`bash({ command: 'node -e \"console.log(1+1)\"' })\\`\n- Read and write any file on the filesystem; edit source, install packages, modify the app\n- Query and modify the database\n- Call external APIs (via bash with curl, or via scripts)\n\nWhen no dedicated tool/action exists for what you need, reach for \\`bash\\` — e.g. \\`bash({ command: 'curl -s https://api.example.com/data' })\\`.\n\n**Template-specific actions are invoked via bash, NOT as direct tools.** In dev mode, the only tools registered as native tool calls are framework-level utilities (bash, read, edit, write, database, resources, chat, teams, jobs). Anything from the template's \\`actions/\\` directory must be run through bash: \\`bash({ command: 'pnpm action <name> --arg value' })\\`. The \"Available Actions\" section below shows the exact CLI syntax for each one — copy that command verbatim and pass it to \\`bash\\`. Do not try to call template actions by name as if they were tools; they will not appear in your tool list.\n\nWhen editing code, follow the agent-native architecture:\n- Every feature needs all four areas: UI + scripts + skills/instructions + application-state sync\n- All SQL must be dialect-agnostic (works on SQLite and Postgres)\n- No Node.js-specific APIs in server routes (must work on Cloudflare Workers, etc.)\n- Use shadcn/ui components and Tabler Icons for all UI work\n${FRAMEWORK_CORE}`;\n\n const PROD_FRAMEWORK_PROMPT_COMPACT = `## Agent-Native Framework — Production Mode\n\nYou are an AI agent in an agent-native application, running in **production mode**.\n\nThe agent and the UI are equal partners — everything the UI can do, you can do via your tools, and vice versa. They share the same SQL database and stay in sync automatically.\n\n**In production mode, you operate through registered actions exposed as tools.** These are your capabilities — use them to read data, take actions, and help the user. You cannot edit source code or access the filesystem directly. Your tools are the app's API.\n\n### Plan Mode\n\nIf the turn is in Plan mode, plan before anything gets written — including ${planModeArtifactList}. Use read-only tools only and do not call ${planModeBlockedTools} until the user switches back to Act mode.\n\n${extensionInstructionsCompact}\n\n### Code Changes — Call \\`connect-builder\\`\n\nIn Act mode, when a request genuinely needs a source-code edit (per the rules above), do this in order: (1) briefly acknowledge the user's specific ask in their own terms — one short clause, no preamble — then (2) call \\`connect-builder\\` with the user's request as the \\`prompt\\`, then (3) inspect \\`builderEnabled\\` in the result and write one sentence framing the next click around what they asked for, not a Builder pitch. When \\`builderEnabled\\` is true, Builder Cloud Agents can take the handoff; when \\`builderEnabled\\` is false, say this requires a code change and they can edit locally or use Builder.io to edit this code in the cloud and continue customizing the app any way they like. Do NOT write code, list files, make plans, or spawn sub-agents. Mention \\`npx agent-native create <app-name>\\`, Agent Native Desktop, or the code-change fallback when Builder Cloud Agents aren't available. Never tell users to enable Builder Cloud Agents from Builder org settings, beta features, \"Cloud Agents\", or \"AI Agents\"; they are not self-serve there.\n${FRAMEWORK_CORE_COMPACT}`;\n\n const DEV_FRAMEWORK_PROMPT_COMPACT = `## Agent-Native Framework — Development Mode\n\nYou are an AI agent in an agent-native application, running in **development mode**.\n\nThe agent and the UI are equal partners — everything the UI can do, you can do via tools/scripts, and vice versa. They share the same SQL database and stay in sync automatically.\n\n**In development mode, you have full local access** — shell, filesystem, database, external APIs, source edits, and package installs. Use it with senior-engineer judgment: read before you edit, keep changes scoped, verify before you claim done.\n\n**Template-specific actions are invoked via bash, NOT as direct tools.** Run them with: \\`bash({ command: 'pnpm action <name> --arg value' })\\`. See the \"Available Actions\" section below for CLI syntax.\n\nWhen editing code, follow the agent-native architecture:\n- Every feature needs all four areas: UI + scripts + skills/instructions + application-state sync\n- All SQL must be dialect-agnostic (works on SQLite and Postgres)\n- No Node.js-specific APIs in server routes (must work on Cloudflare Workers, etc.)\n- Use shadcn/ui components and Tabler Icons for all UI work\n${FRAMEWORK_CORE_COMPACT}`;\n\n return {\n FRAMEWORK_CORE,\n FRAMEWORK_CORE_COMPACT,\n PROD_FRAMEWORK_PROMPT,\n DEV_FRAMEWORK_PROMPT,\n PROD_FRAMEWORK_PROMPT_COMPACT,\n DEV_FRAMEWORK_PROMPT_COMPACT,\n };\n}\n\nexport const _agentChatPromptSectionsForTests = (() => {\n // Built with default (no template-specific) examples for test stability.\n const {\n FRAMEWORK_CORE: frameworkCore,\n FRAMEWORK_CORE_COMPACT: frameworkCoreCompact,\n } = buildFrameworkPrompts();\n return {\n frameworkCore,\n frameworkCoreCompact,\n frameworkContextSections: FRAMEWORK_CONTEXT_SECTIONS,\n buildFrameworkPrompts,\n generateActionsPrompt,\n resolveInitialToolNames,\n createDataWidgetActionEntries,\n };\n})();\n\n/**\n * Build the per-request SQL-schema context block. Reads AGENT_ORG_ID live\n * from the environment so scheduler/A2A/HTTP call sites all see whatever\n * org was just resolved for this request.\n */\nexport async function buildSchemaBlock(\n owner: string,\n databaseTools: DatabaseToolsOption = \"read\",\n): Promise<string> {\n try {\n return await loadSchemaPromptBlock({\n owner,\n orgId: getRequestOrgId() ?? null,\n databaseTools,\n });\n } catch {\n return \"\";\n }\n}\n\n/**\n * Generates a system prompt section describing registered template actions.\n * This helps the agent prefer template-specific actions over raw db-query/db-exec.\n *\n * Two output modes:\n *\n * - `\"tool\"` — used in production, where template actions are registered\n * as native Anthropic tools. Output reads `name(arg*: type; ...) — desc`.\n * - `\"cli\"` — used in dev, where template actions are NOT registered as\n * native tools and must be invoked via `bash(command=\"pnpm action ...\")`.\n * Output reads `pnpm action name --arg <type> [--opt <type>] — desc`.\n */\nexport function generateActionsPrompt(\n registry: Record<string, ActionEntry>,\n mode: \"cli\" | \"tool\" = \"tool\",\n initialToolNames?: string[],\n): string {\n if (!registry || Object.keys(registry).length === 0) return \"\";\n\n const allActionEntries = Object.entries(registry);\n const initialNames = initialToolNames ? new Set(initialToolNames) : undefined;\n const actionEntries = initialNames\n ? allActionEntries.filter(([name]) => initialNames.has(name))\n : allActionEntries;\n const omittedActionCount = allActionEntries.length - actionEntries.length;\n const nativeWidgetNote = (entry: ActionEntry) =>\n entry.chatUI && typeof entry.chatUI.renderer === \"string\"\n ? ` Native chat widget: \\`${entry.chatUI.renderer}\\`.`\n : \"\";\n\n if (mode === \"tool\") {\n const summaryLines = actionEntries.map(([name, entry]) => {\n const desc = compactPromptLine(\n entry.tool.description,\n MAX_ACTION_SUMMARY_DESCRIPTION_CHARS,\n );\n return `- \\`${name}\\` — ${desc}${nativeWidgetNote(entry)}`;\n });\n\n return `\\n\\n## Available Actions\n\n**Use these actions directly as tool calls.** They handle database access, validation, and business logic internally. The native tool schemas contain the full parameter details.\n\n${summaryLines.join(\"\\n\")}${\n omittedActionCount > 0\n ? `\\n\\n${omittedActionCount} less-common app action${omittedActionCount === 1 ? \" is\" : \"s are\"} available on demand. Use \\`tool-search\\` with a specific capability query to load the matching schemas when needed.`\n : \"\"\n }`;\n }\n\n const lines = actionEntries.map(([name, entry]) => {\n const desc = entry.tool.description;\n const params = entry.tool.parameters?.properties;\n const requiredFields = new Set(entry.tool.parameters?.required ?? []);\n\n // CLI mode: emit `pnpm action <name> --required <type> [--optional <type>]`\n if (!params || Object.keys(params).length === 0) {\n return `- \\`pnpm action ${name}\\` — ${desc}${nativeWidgetNote(entry)}`;\n }\n const entries = Object.entries(params);\n // Required first (alphabetical), then optional (alphabetical)\n entries.sort(([a], [b]) => {\n const ar = requiredFields.has(a) ? 0 : 1;\n const br = requiredFields.has(b) ? 0 : 1;\n if (ar !== br) return ar - br;\n return a.localeCompare(b);\n });\n const required: string[] = [];\n const optional: string[] = [];\n const requiredNames: string[] = [];\n for (const [k, v] of entries) {\n const type = (v as { type?: string }).type ?? \"any\";\n const flag = `--${k} <${type}>`;\n if (requiredFields.has(k)) {\n required.push(flag);\n requiredNames.push(`--${k}`);\n } else {\n optional.push(`[${flag}]`);\n }\n }\n const cmd = [\"pnpm action \" + name, ...required, ...optional].join(\" \");\n const requiredNote =\n requiredNames.length > 0 ? ` Required: ${requiredNames.join(\", \")}.` : \"\";\n return `- \\`${cmd}\\` — ${desc}.${requiredNote}${nativeWidgetNote(entry)}`;\n });\n\n return `\\n\\n## Available Actions\n\n**These template actions are NOT exposed as direct tools in dev mode. To run any of them, use the \\`bash\\` tool with the exact command shown below.** Example: \\`bash(command=\"pnpm action add-slide --deckId abc --content 'Hello'\")\\`.\n\nDo NOT try to call these by name as if they were tools — they will not exist in your tool list. Always go through \\`bash\\`.\n\n${lines.join(\"\\n\")}`;\n}\n\n/**\n * Tool names `generateCorpusToolsPrompt` teaches BY NAME, in the same order\n * it lists them. Exported so callers that build a request's initial\n * engine-tool set can fold in exactly the subset present in a given\n * registry — keeping \"what the prompt just told the model exists\" and\n * \"what tools are actually callable on the first request\" in sync. See the\n * corpus-prompt/initial-tools note at this function's call site in\n * agent-chat-plugin.ts.\n */\nconst CORPUS_TOOL_NAMES = [\n \"provider-api-catalog\",\n \"provider-api-docs\",\n \"provider-api-request\",\n \"provider-corpus-job\",\n \"query-staged-dataset\",\n \"run-code\",\n] as const;\n\nexport function corpusToolNamesTaughtByPrompt(\n registry: Record<string, ActionEntry>,\n): string[] {\n return CORPUS_TOOL_NAMES.filter((name) => name in registry);\n}\n\nexport function generateCorpusToolsPrompt(\n registry: Record<string, ActionEntry>,\n): string {\n const hasProviderApi = \"provider-api-request\" in registry;\n const hasProviderCorpusJob = \"provider-corpus-job\" in registry;\n const providerDiscoveryTools = [\n \"provider-api-catalog\" in registry ? \"`provider-api-catalog`\" : null,\n \"provider-api-docs\" in registry ? \"`provider-api-docs`\" : null,\n ].filter(Boolean);\n const hasRunCode = \"run-code\" in registry;\n const hasStagedDataset = \"query-staged-dataset\" in registry;\n if (\n !hasProviderApi &&\n !hasProviderCorpusJob &&\n !hasRunCode &&\n !hasStagedDataset\n )\n return \"\";\n\n const available = [\n ...providerDiscoveryTools,\n hasProviderApi ? \"`provider-api-request`\" : null,\n hasProviderCorpusJob ? \"`provider-corpus-job`\" : null,\n hasStagedDataset ? \"`query-staged-dataset`\" : null,\n hasRunCode ? \"`run-code`\" : null,\n ].filter(Boolean);\n\n return `\\n\\n## Broad Provider And Corpus Workflows\n\nAvailable corpus-capable tools: ${available.join(\", \")}.\n\nThis workflow does not apply to ordinary structured lookups, bounded aggregates, or counts grouped over one known source. For those requests, use the single most directly authoritative source, run one bounded query, and answer as soon as it succeeds. Do not cross-check or expand into a corpus workflow unless the user asks for multiple sources, exhaustive unstructured-record coverage, or an absence claim.\n\nFor broad provider searches, raw API access, multi-page cohorts, cross-source joins, classification over unstructured 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 durable corpus jobs, staged-dataset queries, or code execution.\n\nWhen \\`provider-corpus-job\\` is available, prefer it for transcript/message/ticket/issue/document scans that may exceed one turn, need provider-side backoff, or need a defensible \"not found\" conclusion. Use operation=\"start\" with mode=\"paginated-search\" for any paginated provider endpoint, or mode=\"batch-search\" when a prior cohort of ids/records must feed a second provider endpoint. Continue paused jobs with operation=\"continue\" until status is completed or quota_wait, then read operation=\"results\". In run-code, prefer providerFetchAll() for short cursor/page/offset pagination and providerRequest() when response status, headers, or truncation metadata matters. Report source, filters, row counts, pagination/truncation, failed pages, quota_wait times, and remaining gaps.`;\n}\n\n/**\n * Walks the local filesystem (dev mode only) to build a bounded file/folder\n * tree, used by a couple of dev-mode workspace-inspection tools.\n */\nexport async function collectFiles(\n dir: string,\n prefix: string,\n depth: number,\n results: Array<{ path: string; name: string; type: \"file\" | \"folder\" }>,\n): Promise<void> {\n if (depth > 4 || results.length >= 500) return;\n const skip = new Set([\n \"node_modules\",\n \".git\",\n \".next\",\n \".output\",\n \"dist\",\n \".cache\",\n \".turbo\",\n \"data\",\n ]);\n let entries: import(\"fs\").Dirent[];\n try {\n const fs = await lazyFs();\n entries = fs.readdirSync(dir, { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries) {\n if (results.length >= 500) return;\n if (skip.has(entry.name) || entry.name.startsWith(\".\")) continue;\n const relPath = prefix ? `${prefix}/${entry.name}` : entry.name;\n const isDir = entry.isDirectory();\n results.push({\n path: relPath,\n name: entry.name,\n type: isDir ? \"folder\" : \"file\",\n });\n if (isDir)\n await collectFiles(\n nodePath.join(dir, entry.name),\n relPath,\n depth + 1,\n results,\n );\n }\n}\n"]}
|
|
@@ -192,6 +192,15 @@ export interface AgentChatPluginOptions {
|
|
|
192
192
|
* tool-search unless the app explicitly includes them in this list.
|
|
193
193
|
*/
|
|
194
194
|
initialToolNames?: string[];
|
|
195
|
+
/**
|
|
196
|
+
* Controls whether broad provider/corpus tools and their workflow prompt are
|
|
197
|
+
* loaded into the first model request. Use `"lazy"` for apps that can answer
|
|
198
|
+
* ordinary lookups from a compact curated tool set; corpus tools remain
|
|
199
|
+
* discoverable through tool-search and the full retry surface.
|
|
200
|
+
*
|
|
201
|
+
* @default "initial"
|
|
202
|
+
*/
|
|
203
|
+
corpusTools?: "initial" | "lazy";
|
|
195
204
|
/**
|
|
196
205
|
* Use a compact system prompt with on-demand context loading. The system
|
|
197
206
|
* prompt includes essential behavioral rules and action signatures, but
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-options.d.ts","sourceRoot":"","sources":["../../../src/server/agent-chat/plugin-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D;4EAC4E;AAC5E,MAAM,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAErE,MAAM,WAAW,sBAAsB;IACrC,+DAA+D;IAC/D,OAAO,CAAC,EACJ,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC3B,CAAC,MACG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC3B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAC9C,wCAAwC;IACxC,OAAO,CAAC,EACJ,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC3B,CAAC,MACG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC3B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAC9C,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,eAAe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C;IAE5B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,mBAAmB,CAAC;IAErC;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;;;;;;;;;;;;;;OAkBG;IACH,aAAa,CAAC,EAAE;QACd,UAAU,CAAC,EAAE,KAAK,GAAG,WAAW,GAAG,SAAS,CAAC;QAC7C;;;;WAIG;QACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;KACxB,CAAC;IAEF;;;OAGG;IACH,UAAU,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-options.js","sourceRoot":"","sources":["../../../src/server/agent-chat/plugin-options.ts"],"names":[],"mappings":"","sourcesContent":["import type { ActionEntry } from \"../../agent/production-agent.js\";\nimport type { AgentLoopFinalResponseGuard } from \"../../agent/production-agent.js\";\nimport type {\n AgentChatAttachment,\n AgentChatReference,\n MentionProvider,\n} from \"../../agent/types.js\";\nimport type { ExternalAgentPolicy } from \"../../mcp/external-agent-policy.js\";\nimport type { DatabaseToolsOption } from \"../../scripts/db/tool-mode.js\";\nimport type { PromptExamples } from \"../prompts/index.js\";\n\n/** Shape of a Nitro plugin function: receives the Nitro app instance at\n * startup and may register routes/hooks synchronously or asynchronously. */\nexport type NitroPluginDef = (nitroApp: any) => void | Promise<void>;\n\nexport interface AgentChatPluginOptions {\n /** Template-specific actions (email ops, booking ops, etc.) */\n actions?:\n | Record<string, ActionEntry>\n | (() =>\n | Record<string, ActionEntry>\n | Promise<Record<string, ActionEntry>>);\n /** @deprecated Use `actions` instead */\n scripts?:\n | Record<string, ActionEntry>\n | (() =>\n | Record<string, ActionEntry>\n | Promise<Record<string, ActionEntry>>);\n /** System prompt for the agent. A sensible default is provided. */\n systemPrompt?: string;\n /** Additional system prompt prepended in dev mode */\n devSystemPrompt?: string;\n /** Model to use. Defaults to the resolved engine's default model. */\n model?: string;\n /** Optional per-app agent run chunk budget in milliseconds. Defaults to\n * AGENT_RUN_SOFT_TIMEOUT_MS when set, otherwise no framework-imposed\n * timeout. When reached, long runs continue through the hidden continuation\n * path instead of surfacing a timeout warning. */\n runSoftTimeoutMs?: number;\n /** Optional per-app run-manager no-progress watchdog in milliseconds. */\n runNoProgressTimeoutMs?: number;\n /**\n * Opt this app into Netlify durable background-function agent-chat runs. This\n * gives hosted agent turns the 15-minute async-function budget when the app's\n * Netlify build also emits the background function. Set this to `false` to\n * explicitly disable a stale deploy-wide `AGENT_CHAT_DURABLE_BACKGROUND`\n * flag for this app.\n */\n durableBackgroundRuns?: boolean;\n /** Anthropic API key. Falls back to ANTHROPIC_API_KEY env var */\n apiKey?: string;\n /**\n * Agent engine to use. Can be a pre-constructed AgentEngine, a registered\n * engine name (e.g. \"anthropic\", \"ai-sdk:openai\"), or an object with name\n * and config. Defaults to the \"anthropic\" engine using ANTHROPIC_API_KEY.\n */\n engine?:\n | import(\"../../agent/engine/types.js\").AgentEngine\n | string\n | { name: string; config: Record<string, unknown> };\n /** Route path. Default: /_agent-native/agent-chat */\n path?: string;\n /** Custom mention providers for @-tagging template entities */\n mentionProviders?:\n | Record<string, MentionProvider>\n | (() =>\n | Record<string, MentionProvider>\n | Promise<Record<string, MentionProvider>>);\n /** App ID used to exclude self from agent discovery (e.g., \"mail\", \"calendar\") */\n appId?: string;\n /** Optional MCP server branding surfaced during the initialize handshake. */\n mcpServerInfo?: {\n /** Human-facing title. Defaults to the capitalized app id/name. */\n title?: string;\n /** Host-facing description. Defaults to \"Agent-native <app> agent\". */\n description?: string;\n /** Canonical app URL. Relative URLs are resolved against the request origin. */\n websiteUrl?: string;\n /** App icons. Relative `src` values are resolved against the request origin. */\n icons?: Array<{\n src: string;\n mimeType?: string;\n sizes?: string[];\n theme?: \"light\" | \"dark\";\n }>;\n };\n /**\n * Optional callback to resolve the org ID for the current request.\n * When provided, the resolved value is set as AGENT_ORG_ID env var so\n * that db-query/db-exec automatically scope by org_id in addition to\n * owner_email.\n *\n * If not provided, the framework automatically uses `session.orgId` from\n * Better Auth's active organization. Only provide this callback when you\n * need custom org resolution logic (e.g., Atlassian org mapping).\n */\n resolveOrgId?: (event: any) => string | null | Promise<string | null>;\n /**\n * Optional owner resolver for public/anonymous chat surfaces. When the\n * normal app session is missing, this callback may return a synthetic\n * owner id for a narrowly-scoped public request (for example, a public\n * shared document page). Anonymous requests use a read-only tool set by\n * default so public viewers cannot mutate app data through the agent.\n */\n anonymousOwner?: (event: any) => string | null | Promise<string | null>;\n /**\n * Keep anonymous-owner requests on read-only template actions. Defaults to\n * true. Only disable for single-tenant apps that intentionally allow public\n * agent mutations.\n */\n anonymousReadOnly?: boolean;\n /**\n * Optional auth adapter for the HTTP action route\n * (`/_agent-native/actions/*`). Its `resolveCaller` runs before the\n * cookie/bearer `getSession` chain, letting an app accept caller identities\n * `getSession` doesn't understand (e.g. an A2A JWT verified with\n * `verifyA2AToken`) declaratively, instead of pre-seeding request context\n * from a Nitro `request` hook.\n *\n * Returning `null` defers to the normal chain; THROWING hard-rejects with a\n * 401 (an invalid/forged credential must not fall through to a same-origin\n * session cookie). A resolved caller's org comes exclusively from the\n * verified credential — the returned `orgId` or the owner-email membership\n * lookup — never from the request's session cookie.\n * See {@link import(\"../action-routes.js\").ActionRouteAuthAdapter}.\n */\n actionRouteAuth?: import(\"../action-routes.js\").ActionRouteAuthAdapter;\n /**\n * Optional callback to append template-specific context to the system\n * prompt on each request. Runs after AGENTS.md / skills / memory are\n * loaded and before the schema block — use it to inject dynamic SQL\n * context like a data dictionary, active feature flags, or whatever\n * the agent should know about *right now* for this user/org.\n *\n * Return `null` or an empty string to skip. The string you return is\n * appended verbatim, so wrap it in your own XML tags (e.g.\n * `<data-dictionary>…</data-dictionary>`) to keep the prompt scannable.\n *\n * Called on every request in every prompt variant (lean, lazy, full).\n * Templates that want to suppress it in a particular mode should return\n * `null` from the callback based on their own logic.\n */\n extraContext?: (\n event: any,\n owner: string,\n ) => string | null | Promise<string | null>;\n /**\n * Optional final-answer guard. Templates can use this to require a\n * corrective retry before accepting a text-only final answer, e.g. forcing\n * real data-source tool calls for analytics requests.\n */\n finalResponseGuard?: AgentLoopFinalResponseGuard;\n /**\n * Optional per-template request normalizer. Runs after authentication and\n * before the model sees the message, so apps can translate chat attachments\n * into template-native file handles while preserving the user's visible text.\n */\n prepareRequest?: (details: {\n event: any;\n ownerEmail: string | null;\n message: string;\n displayMessage?: string;\n attachments: AgentChatAttachment[];\n references: AgentChatReference[];\n threadId?: string;\n internalContinuation?: boolean;\n mode: \"act\" | \"plan\";\n }) =>\n | void\n | {\n message?: string;\n displayMessage?: string;\n attachments?: AgentChatAttachment[];\n }\n | Promise<void | {\n message?: string;\n displayMessage?: string;\n attachments?: AgentChatAttachment[];\n }>;\n /**\n * Use ONLY the template's `systemPrompt` and the actions list — skip the\n * framework prompt wrapper, resource loading (AGENTS.md/LEARNINGS.md/\n * memory), the SQL schema block, and the workspace files/skills/agents\n * inventory. Intended for minimal or voice-first apps where a long,\n * generic preamble adds latency and iteration noise without adding value.\n *\n * When set, the same lean prompt is used in both dev and prod modes. In\n * dev mode the tool registry is ALSO swapped to the template's actions\n * (same set as prod) — the dev-only bash/db-exec/file-system tools\n * and the resource/docs/chat/team/job/browser scripts are dropped. The\n * lean system prompt has no bash-usage guidance, so routing actions\n * through bash would break. If you need the full dev tool surface,\n * leave this off.\n */\n leanPrompt?: boolean;\n /**\n * Skip auto-injecting the workspace files/skills/agents inventory on the\n * first message of a conversation while keeping the normal prompt, resources,\n * and tool surface. Use this for domain-focused apps where broad workspace\n * inventory is mostly latency/noise unless the user explicitly references it.\n *\n * `leanPrompt: true` and the default `lazyContext` mode imply this because\n * those catalogs are already discoverable through resources, docs-search,\n * tool-search, and the compact resource indexes. Set `false` explicitly only\n * when a workspace-wide inventory is central to the app's first-turn job.\n */\n skipFilesContext?: boolean;\n /**\n * Initial native tool schemas to send to the LLM provider. When set, the\n * agent starts with only these tools plus `tool-search`; the live registry\n * remains searchable, and matching schemas from `tool-search` results are\n * loaded into the next model request. Use this for domain-focused apps that\n * have a few common actions and many rare framework utilities. Common\n * discovery and resource-reading tools are promoted automatically when\n * present. Provider, MCP, extension, and code-execution schemas stay behind\n * tool-search unless the app explicitly includes them in this list.\n */\n initialToolNames?: string[];\n /**\n * Use a compact system prompt with on-demand context loading. The system\n * prompt includes essential behavioral rules and action signatures, but\n * defers verbose framework details, SQL schema, skills, learnings, and\n * memory behind tools (`get-framework-context`, `db-schema`,\n * `resources` (action: read)). The agent fetches these on-demand when needed.\n *\n * This reduces the system prompt by ~60-70%, significantly improving\n * time-to-first-token and reducing \"thinking\" time. The agent retains\n * all capabilities — it just loads context lazily instead of upfront.\n *\n * Defaults to `true`. Set to `false` to use the original full prompt.\n * Ignored when `leanPrompt` is set (lean mode is even more minimal).\n */\n lazyContext?: boolean;\n /**\n * In dev mode, register the template's actions as native tools the agent\n * can call directly with structured JSON args — skipping the default\n * `bash(command=\"pnpm action <name> ...\")` indirection.\n *\n * The default dev behavior shells out because it \"mirrors how Claude Code\n * works locally\" and reduces empty-object tool calls for templates with\n * simple string args. But templates whose actions take structured data\n * (objects, arrays, nested JSON) can't round-trip those cleanly through\n * the CLI parser — stringified JSON on the way in, loss of type fidelity\n * on the way out.\n *\n * Set to `true` to get the same tool surface in dev that production uses.\n * `leanPrompt: true` implies this already (lean mode has no bash-usage\n * guidance, so actions must be native). Set this flag without\n * `leanPrompt` when you want native actions AND the full system prompt.\n *\n * Defaults to `false`.\n */\n nativeActionsInDev?: boolean;\n /**\n * Expose raw SQL/native database tools to the app agent.\n *\n * Defaults to `\"read\"`: `db-schema`/`db-query` are available for inspection,\n * while writes route through typed app actions. Set to `\"write\"` (also\n * `true`) to expose `db-exec`/`db-patch` for scoped raw SQL maintenance.\n * Set to `\"off\"` (also `false`) for chat-first apps that want agents to use\n * typed actions only.\n */\n databaseTools?: DatabaseToolsOption;\n /**\n * Expose framework extension management actions (`create-extension`,\n * `update-extension`, `list-extensions`, etc.) to the app agent. Defaults to\n * true. Set to false for apps that do not want the LLM to create or manage\n * sandboxed extension mini-apps, even though the core extension routes may\n * still be mounted for other surfaces.\n */\n extensionTools?: boolean;\n /**\n * Optional A2A-only deterministic response path. Runs after inbound A2A text\n * and user context are resolved, but before an agent engine/model is loaded.\n * Return a message to complete the A2A task without invoking the LLM, or\n * null/undefined to continue through the normal agent loop.\n */\n a2aMessageFallback?: (details: {\n message: import(\"../../a2a/types.js\").Message;\n text: string;\n context: import(\"../../a2a/types.js\").A2AHandlerContext;\n userEmail: string | undefined;\n }) =>\n | import(\"../../a2a/types.js\").Message\n | string\n | null\n | undefined\n | Promise<import(\"../../a2a/types.js\").Message | string | null | undefined>;\n /**\n * Optional injectable prompt examples for core rules (rule 5 auto-refresh\n * examples and rule 8 external provider names). When absent, generic\n * placeholders are used so no template-specific names appear in the core\n * prompt by default.\n *\n * - `providerActions`: external provider action names this template exposes\n * (e.g. `[\"warehouse-query\", \"crm-records\"]` for a template).\n * - `appActions`: representative template action names for rule 5's refresh\n * examples (e.g. `[\"log-meal\", \"update-form\"]` for a forms template).\n */\n promptExamples?: PromptExamples;\n /**\n * Curated allow-list of action names to serve external **connector** clients\n * on a hosted multi-tenant deployment.\n *\n * Whenever this list is non-empty it is active by default for **every**\n * caller (hosted connectors, code/stdio clients, and the local CLI): external\n * MCP clients see (and can call) only these actions plus the builtin\n * cross-app tools (`list_apps`, `open_app`, `ask_app`, `create_embed_session`).\n * Calls to any tool outside the list are rejected with \"Unknown tool\".\n * This prevents the full ~105-tool catalog from bloating external-agent\n * context windows and removes footguns (db-exec, seed-*, extension suite,\n * browser-session tools) from connectors. It is no longer gated behind an\n * environment variable, and the catalog is never inferred from the client.\n *\n * `tool-search` stays available for discovery; a trimmed action still needs\n * the connector catalog, authenticated-read policy, or full-catalog opt-in\n * before an external caller can execute it.\n * Callers who need the full surface up front opt in explicitly with\n * `agent-native connect --full-catalog` (embeds a `catalog_scope: \"full\"`\n * claim in their connect-minted JWT) or the deployment-wide\n * `AGENT_NATIVE_MCP_FULL_CATALOG=1` env override.\n *\n * Declare here rather than in MCPConfig directly; the plugin copies it through.\n */\n connectorCatalog?: string[];\n\n /**\n * Default authenticated external-agent policy. In `auto` read mode, every\n * action explicitly marked as GET + readOnly + publicAgent.requiresAuth is\n * added to the connector surface automatically. Writes remain ask_app-only\n * unless `writes: \"allowlisted\"` is explicitly selected.\n */\n externalAgents?: ExternalAgentPolicy;\n\n /**\n * Skip mounting the remote MCP protocol route.\n *\n * Most apps should leave this off so agent chat, A2A, and MCP share one\n * runtime. Hosted apps with a dedicated early MCP plugin can set this to\n * true so their external connector does not depend on the heavier chat\n * plugin initialization path.\n */\n disableMcp?: boolean;\n\n /**\n * Code-execution capability for the production agent.\n *\n * - `\"off\"` (default) — no code-execution tools in production.\n * - `\"sandboxed\"` — registers the `run-code` tool (isolated Node.js sandbox\n * with a bridge to allowlisted registered tools). Safe for shared or\n * hosted deployments.\n * - `\"trusted\"` — registers both the full coding tool registry\n * (bash / read / edit / write) and the `run-code` sandbox. Only use in\n * single-tenant or operator-controlled deployments where full shell access\n * to the host machine is intentional.\n *\n * The `AGENT_PROD_CODE_EXECUTION` environment variable (`\"trusted\"`,\n * `\"sandboxed\"`, or `\"off\"`) takes precedence over this option, allowing\n * per-deployment overrides without code changes.\n *\n * Dev-mode behavior is unchanged — both the coding tools and `run-code` are\n * always available when the environment allows toggling.\n */\n codeExecution?: {\n production?: \"off\" | \"sandboxed\" | \"trusted\";\n /**\n * Extra registered-tool names the sandbox bridge may forward (beyond the\n * default allowlist: provider-api-request, provider-api-docs,\n * provider-api-catalog, web-request).\n */\n bridgeTools?: string[];\n };\n\n /**\n * App-level default tool-call limits. Individual actions override these with\n * their own `timeoutMs` / `maxResultChars` declarations.\n */\n toolLimits?: { timeoutMs?: number; maxResultChars?: number };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"plugin-options.js","sourceRoot":"","sources":["../../../src/server/agent-chat/plugin-options.ts"],"names":[],"mappings":"","sourcesContent":["import type { ActionEntry } from \"../../agent/production-agent.js\";\nimport type { AgentLoopFinalResponseGuard } from \"../../agent/production-agent.js\";\nimport type {\n AgentChatAttachment,\n AgentChatReference,\n MentionProvider,\n} from \"../../agent/types.js\";\nimport type { ExternalAgentPolicy } from \"../../mcp/external-agent-policy.js\";\nimport type { DatabaseToolsOption } from \"../../scripts/db/tool-mode.js\";\nimport type { PromptExamples } from \"../prompts/index.js\";\n\n/** Shape of a Nitro plugin function: receives the Nitro app instance at\n * startup and may register routes/hooks synchronously or asynchronously. */\nexport type NitroPluginDef = (nitroApp: any) => void | Promise<void>;\n\nexport interface AgentChatPluginOptions {\n /** Template-specific actions (email ops, booking ops, etc.) */\n actions?:\n | Record<string, ActionEntry>\n | (() =>\n | Record<string, ActionEntry>\n | Promise<Record<string, ActionEntry>>);\n /** @deprecated Use `actions` instead */\n scripts?:\n | Record<string, ActionEntry>\n | (() =>\n | Record<string, ActionEntry>\n | Promise<Record<string, ActionEntry>>);\n /** System prompt for the agent. A sensible default is provided. */\n systemPrompt?: string;\n /** Additional system prompt prepended in dev mode */\n devSystemPrompt?: string;\n /** Model to use. Defaults to the resolved engine's default model. */\n model?: string;\n /** Optional per-app agent run chunk budget in milliseconds. Defaults to\n * AGENT_RUN_SOFT_TIMEOUT_MS when set, otherwise no framework-imposed\n * timeout. When reached, long runs continue through the hidden continuation\n * path instead of surfacing a timeout warning. */\n runSoftTimeoutMs?: number;\n /** Optional per-app run-manager no-progress watchdog in milliseconds. */\n runNoProgressTimeoutMs?: number;\n /**\n * Opt this app into Netlify durable background-function agent-chat runs. This\n * gives hosted agent turns the 15-minute async-function budget when the app's\n * Netlify build also emits the background function. Set this to `false` to\n * explicitly disable a stale deploy-wide `AGENT_CHAT_DURABLE_BACKGROUND`\n * flag for this app.\n */\n durableBackgroundRuns?: boolean;\n /** Anthropic API key. Falls back to ANTHROPIC_API_KEY env var */\n apiKey?: string;\n /**\n * Agent engine to use. Can be a pre-constructed AgentEngine, a registered\n * engine name (e.g. \"anthropic\", \"ai-sdk:openai\"), or an object with name\n * and config. Defaults to the \"anthropic\" engine using ANTHROPIC_API_KEY.\n */\n engine?:\n | import(\"../../agent/engine/types.js\").AgentEngine\n | string\n | { name: string; config: Record<string, unknown> };\n /** Route path. Default: /_agent-native/agent-chat */\n path?: string;\n /** Custom mention providers for @-tagging template entities */\n mentionProviders?:\n | Record<string, MentionProvider>\n | (() =>\n | Record<string, MentionProvider>\n | Promise<Record<string, MentionProvider>>);\n /** App ID used to exclude self from agent discovery (e.g., \"mail\", \"calendar\") */\n appId?: string;\n /** Optional MCP server branding surfaced during the initialize handshake. */\n mcpServerInfo?: {\n /** Human-facing title. Defaults to the capitalized app id/name. */\n title?: string;\n /** Host-facing description. Defaults to \"Agent-native <app> agent\". */\n description?: string;\n /** Canonical app URL. Relative URLs are resolved against the request origin. */\n websiteUrl?: string;\n /** App icons. Relative `src` values are resolved against the request origin. */\n icons?: Array<{\n src: string;\n mimeType?: string;\n sizes?: string[];\n theme?: \"light\" | \"dark\";\n }>;\n };\n /**\n * Optional callback to resolve the org ID for the current request.\n * When provided, the resolved value is set as AGENT_ORG_ID env var so\n * that db-query/db-exec automatically scope by org_id in addition to\n * owner_email.\n *\n * If not provided, the framework automatically uses `session.orgId` from\n * Better Auth's active organization. Only provide this callback when you\n * need custom org resolution logic (e.g., Atlassian org mapping).\n */\n resolveOrgId?: (event: any) => string | null | Promise<string | null>;\n /**\n * Optional owner resolver for public/anonymous chat surfaces. When the\n * normal app session is missing, this callback may return a synthetic\n * owner id for a narrowly-scoped public request (for example, a public\n * shared document page). Anonymous requests use a read-only tool set by\n * default so public viewers cannot mutate app data through the agent.\n */\n anonymousOwner?: (event: any) => string | null | Promise<string | null>;\n /**\n * Keep anonymous-owner requests on read-only template actions. Defaults to\n * true. Only disable for single-tenant apps that intentionally allow public\n * agent mutations.\n */\n anonymousReadOnly?: boolean;\n /**\n * Optional auth adapter for the HTTP action route\n * (`/_agent-native/actions/*`). Its `resolveCaller` runs before the\n * cookie/bearer `getSession` chain, letting an app accept caller identities\n * `getSession` doesn't understand (e.g. an A2A JWT verified with\n * `verifyA2AToken`) declaratively, instead of pre-seeding request context\n * from a Nitro `request` hook.\n *\n * Returning `null` defers to the normal chain; THROWING hard-rejects with a\n * 401 (an invalid/forged credential must not fall through to a same-origin\n * session cookie). A resolved caller's org comes exclusively from the\n * verified credential — the returned `orgId` or the owner-email membership\n * lookup — never from the request's session cookie.\n * See {@link import(\"../action-routes.js\").ActionRouteAuthAdapter}.\n */\n actionRouteAuth?: import(\"../action-routes.js\").ActionRouteAuthAdapter;\n /**\n * Optional callback to append template-specific context to the system\n * prompt on each request. Runs after AGENTS.md / skills / memory are\n * loaded and before the schema block — use it to inject dynamic SQL\n * context like a data dictionary, active feature flags, or whatever\n * the agent should know about *right now* for this user/org.\n *\n * Return `null` or an empty string to skip. The string you return is\n * appended verbatim, so wrap it in your own XML tags (e.g.\n * `<data-dictionary>…</data-dictionary>`) to keep the prompt scannable.\n *\n * Called on every request in every prompt variant (lean, lazy, full).\n * Templates that want to suppress it in a particular mode should return\n * `null` from the callback based on their own logic.\n */\n extraContext?: (\n event: any,\n owner: string,\n ) => string | null | Promise<string | null>;\n /**\n * Optional final-answer guard. Templates can use this to require a\n * corrective retry before accepting a text-only final answer, e.g. forcing\n * real data-source tool calls for analytics requests.\n */\n finalResponseGuard?: AgentLoopFinalResponseGuard;\n /**\n * Optional per-template request normalizer. Runs after authentication and\n * before the model sees the message, so apps can translate chat attachments\n * into template-native file handles while preserving the user's visible text.\n */\n prepareRequest?: (details: {\n event: any;\n ownerEmail: string | null;\n message: string;\n displayMessage?: string;\n attachments: AgentChatAttachment[];\n references: AgentChatReference[];\n threadId?: string;\n internalContinuation?: boolean;\n mode: \"act\" | \"plan\";\n }) =>\n | void\n | {\n message?: string;\n displayMessage?: string;\n attachments?: AgentChatAttachment[];\n }\n | Promise<void | {\n message?: string;\n displayMessage?: string;\n attachments?: AgentChatAttachment[];\n }>;\n /**\n * Use ONLY the template's `systemPrompt` and the actions list — skip the\n * framework prompt wrapper, resource loading (AGENTS.md/LEARNINGS.md/\n * memory), the SQL schema block, and the workspace files/skills/agents\n * inventory. Intended for minimal or voice-first apps where a long,\n * generic preamble adds latency and iteration noise without adding value.\n *\n * When set, the same lean prompt is used in both dev and prod modes. In\n * dev mode the tool registry is ALSO swapped to the template's actions\n * (same set as prod) — the dev-only bash/db-exec/file-system tools\n * and the resource/docs/chat/team/job/browser scripts are dropped. The\n * lean system prompt has no bash-usage guidance, so routing actions\n * through bash would break. If you need the full dev tool surface,\n * leave this off.\n */\n leanPrompt?: boolean;\n /**\n * Skip auto-injecting the workspace files/skills/agents inventory on the\n * first message of a conversation while keeping the normal prompt, resources,\n * and tool surface. Use this for domain-focused apps where broad workspace\n * inventory is mostly latency/noise unless the user explicitly references it.\n *\n * `leanPrompt: true` and the default `lazyContext` mode imply this because\n * those catalogs are already discoverable through resources, docs-search,\n * tool-search, and the compact resource indexes. Set `false` explicitly only\n * when a workspace-wide inventory is central to the app's first-turn job.\n */\n skipFilesContext?: boolean;\n /**\n * Initial native tool schemas to send to the LLM provider. When set, the\n * agent starts with only these tools plus `tool-search`; the live registry\n * remains searchable, and matching schemas from `tool-search` results are\n * loaded into the next model request. Use this for domain-focused apps that\n * have a few common actions and many rare framework utilities. Common\n * discovery and resource-reading tools are promoted automatically when\n * present. Provider, MCP, extension, and code-execution schemas stay behind\n * tool-search unless the app explicitly includes them in this list.\n */\n initialToolNames?: string[];\n /**\n * Controls whether broad provider/corpus tools and their workflow prompt are\n * loaded into the first model request. Use `\"lazy\"` for apps that can answer\n * ordinary lookups from a compact curated tool set; corpus tools remain\n * discoverable through tool-search and the full retry surface.\n *\n * @default \"initial\"\n */\n corpusTools?: \"initial\" | \"lazy\";\n /**\n * Use a compact system prompt with on-demand context loading. The system\n * prompt includes essential behavioral rules and action signatures, but\n * defers verbose framework details, SQL schema, skills, learnings, and\n * memory behind tools (`get-framework-context`, `db-schema`,\n * `resources` (action: read)). The agent fetches these on-demand when needed.\n *\n * This reduces the system prompt by ~60-70%, significantly improving\n * time-to-first-token and reducing \"thinking\" time. The agent retains\n * all capabilities — it just loads context lazily instead of upfront.\n *\n * Defaults to `true`. Set to `false` to use the original full prompt.\n * Ignored when `leanPrompt` is set (lean mode is even more minimal).\n */\n lazyContext?: boolean;\n /**\n * In dev mode, register the template's actions as native tools the agent\n * can call directly with structured JSON args — skipping the default\n * `bash(command=\"pnpm action <name> ...\")` indirection.\n *\n * The default dev behavior shells out because it \"mirrors how Claude Code\n * works locally\" and reduces empty-object tool calls for templates with\n * simple string args. But templates whose actions take structured data\n * (objects, arrays, nested JSON) can't round-trip those cleanly through\n * the CLI parser — stringified JSON on the way in, loss of type fidelity\n * on the way out.\n *\n * Set to `true` to get the same tool surface in dev that production uses.\n * `leanPrompt: true` implies this already (lean mode has no bash-usage\n * guidance, so actions must be native). Set this flag without\n * `leanPrompt` when you want native actions AND the full system prompt.\n *\n * Defaults to `false`.\n */\n nativeActionsInDev?: boolean;\n /**\n * Expose raw SQL/native database tools to the app agent.\n *\n * Defaults to `\"read\"`: `db-schema`/`db-query` are available for inspection,\n * while writes route through typed app actions. Set to `\"write\"` (also\n * `true`) to expose `db-exec`/`db-patch` for scoped raw SQL maintenance.\n * Set to `\"off\"` (also `false`) for chat-first apps that want agents to use\n * typed actions only.\n */\n databaseTools?: DatabaseToolsOption;\n /**\n * Expose framework extension management actions (`create-extension`,\n * `update-extension`, `list-extensions`, etc.) to the app agent. Defaults to\n * true. Set to false for apps that do not want the LLM to create or manage\n * sandboxed extension mini-apps, even though the core extension routes may\n * still be mounted for other surfaces.\n */\n extensionTools?: boolean;\n /**\n * Optional A2A-only deterministic response path. Runs after inbound A2A text\n * and user context are resolved, but before an agent engine/model is loaded.\n * Return a message to complete the A2A task without invoking the LLM, or\n * null/undefined to continue through the normal agent loop.\n */\n a2aMessageFallback?: (details: {\n message: import(\"../../a2a/types.js\").Message;\n text: string;\n context: import(\"../../a2a/types.js\").A2AHandlerContext;\n userEmail: string | undefined;\n }) =>\n | import(\"../../a2a/types.js\").Message\n | string\n | null\n | undefined\n | Promise<import(\"../../a2a/types.js\").Message | string | null | undefined>;\n /**\n * Optional injectable prompt examples for core rules (rule 5 auto-refresh\n * examples and rule 8 external provider names). When absent, generic\n * placeholders are used so no template-specific names appear in the core\n * prompt by default.\n *\n * - `providerActions`: external provider action names this template exposes\n * (e.g. `[\"warehouse-query\", \"crm-records\"]` for a template).\n * - `appActions`: representative template action names for rule 5's refresh\n * examples (e.g. `[\"log-meal\", \"update-form\"]` for a forms template).\n */\n promptExamples?: PromptExamples;\n /**\n * Curated allow-list of action names to serve external **connector** clients\n * on a hosted multi-tenant deployment.\n *\n * Whenever this list is non-empty it is active by default for **every**\n * caller (hosted connectors, code/stdio clients, and the local CLI): external\n * MCP clients see (and can call) only these actions plus the builtin\n * cross-app tools (`list_apps`, `open_app`, `ask_app`, `create_embed_session`).\n * Calls to any tool outside the list are rejected with \"Unknown tool\".\n * This prevents the full ~105-tool catalog from bloating external-agent\n * context windows and removes footguns (db-exec, seed-*, extension suite,\n * browser-session tools) from connectors. It is no longer gated behind an\n * environment variable, and the catalog is never inferred from the client.\n *\n * `tool-search` stays available for discovery; a trimmed action still needs\n * the connector catalog, authenticated-read policy, or full-catalog opt-in\n * before an external caller can execute it.\n * Callers who need the full surface up front opt in explicitly with\n * `agent-native connect --full-catalog` (embeds a `catalog_scope: \"full\"`\n * claim in their connect-minted JWT) or the deployment-wide\n * `AGENT_NATIVE_MCP_FULL_CATALOG=1` env override.\n *\n * Declare here rather than in MCPConfig directly; the plugin copies it through.\n */\n connectorCatalog?: string[];\n\n /**\n * Default authenticated external-agent policy. In `auto` read mode, every\n * action explicitly marked as GET + readOnly + publicAgent.requiresAuth is\n * added to the connector surface automatically. Writes remain ask_app-only\n * unless `writes: \"allowlisted\"` is explicitly selected.\n */\n externalAgents?: ExternalAgentPolicy;\n\n /**\n * Skip mounting the remote MCP protocol route.\n *\n * Most apps should leave this off so agent chat, A2A, and MCP share one\n * runtime. Hosted apps with a dedicated early MCP plugin can set this to\n * true so their external connector does not depend on the heavier chat\n * plugin initialization path.\n */\n disableMcp?: boolean;\n\n /**\n * Code-execution capability for the production agent.\n *\n * - `\"off\"` (default) — no code-execution tools in production.\n * - `\"sandboxed\"` — registers the `run-code` tool (isolated Node.js sandbox\n * with a bridge to allowlisted registered tools). Safe for shared or\n * hosted deployments.\n * - `\"trusted\"` — registers both the full coding tool registry\n * (bash / read / edit / write) and the `run-code` sandbox. Only use in\n * single-tenant or operator-controlled deployments where full shell access\n * to the host machine is intentional.\n *\n * The `AGENT_PROD_CODE_EXECUTION` environment variable (`\"trusted\"`,\n * `\"sandboxed\"`, or `\"off\"`) takes precedence over this option, allowing\n * per-deployment overrides without code changes.\n *\n * Dev-mode behavior is unchanged — both the coding tools and `run-code` are\n * always available when the environment allows toggling.\n */\n codeExecution?: {\n production?: \"off\" | \"sandboxed\" | \"trusted\";\n /**\n * Extra registered-tool names the sandbox bridge may forward (beyond the\n * default allowlist: provider-api-request, provider-api-docs,\n * provider-api-catalog, web-request).\n */\n bridgeTools?: string[];\n };\n\n /**\n * App-level default tool-call limits. Individual actions override these with\n * their own `timeoutMs` / `maxResultChars` declarations.\n */\n toolLimits?: { timeoutMs?: number; maxResultChars?: number };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-chat-plugin.d.ts","sourceRoot":"","sources":["../../src/server/agent-chat-plugin.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAqH7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EACL,yBAAyB,EACzB,KAAK,6BAA6B,EACnC,MAAM,+BAA+B,CAAC;AAkCvC,OAAO,E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C;AAE9E,OAAO,EAEL,mBAAmB,EACnB,uBAAuB,EAGxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -825,7 +825,10 @@ export function createAgentChatPlugin(options) {
|
|
|
825
825
|
// that never emit the corpus prompt (no provider/run-code tools
|
|
826
826
|
// registered), so this never silently expands the initial set for
|
|
827
827
|
// apps that don't teach these tools by name.
|
|
828
|
-
const
|
|
828
|
+
const loadCorpusToolsInitially = options?.corpusTools !== "lazy";
|
|
829
|
+
const corpusToolNames = loadCorpusToolsInitially
|
|
830
|
+
? corpusToolNamesTaughtByPrompt(corpusPromptRegistry)
|
|
831
|
+
: [];
|
|
829
832
|
const effectiveInitialToolNames = corpusToolNames.length > 0
|
|
830
833
|
? [...new Set([...templateInitialToolNames, ...corpusToolNames])]
|
|
831
834
|
: templateInitialToolNames;
|
|
@@ -1462,7 +1465,9 @@ export function createAgentChatPlugin(options) {
|
|
|
1462
1465
|
// Dev: actions are invoked via bash — emit `pnpm action name --arg <type>`
|
|
1463
1466
|
// and include discoveredActions too, since those are also missing
|
|
1464
1467
|
// from the dev tool registry.
|
|
1465
|
-
const corpusToolsPrompt =
|
|
1468
|
+
const corpusToolsPrompt = loadCorpusToolsInitially
|
|
1469
|
+
? generateCorpusToolsPrompt(corpusPromptRegistry)
|
|
1470
|
+
: "";
|
|
1466
1471
|
const prodActionsPrompt = generateActionsPrompt(templateScripts, "tool", lazyContext ? effectiveInitialToolNames : undefined) + corpusToolsPrompt;
|
|
1467
1472
|
const devActionsPrompt = generateActionsPrompt({ ...discoveredActions, ...templateScripts }, "cli") + corpusToolsPrompt;
|
|
1468
1473
|
// Build system prompts — dynamic functions that pre-load resources per-request.
|
|
@@ -1745,6 +1750,10 @@ export function createAgentChatPlugin(options) {
|
|
|
1745
1750
|
turnId: typeof run.turnId === "string" && run.turnId
|
|
1746
1751
|
? run.turnId
|
|
1747
1752
|
: undefined,
|
|
1753
|
+
runDurationMs: typeof run.startedAt === "number" &&
|
|
1754
|
+
Number.isFinite(run.startedAt)
|
|
1755
|
+
? Math.max(0, Date.now() - run.startedAt)
|
|
1756
|
+
: undefined,
|
|
1748
1757
|
});
|
|
1749
1758
|
if (!assistantMsg) {
|
|
1750
1759
|
// No content produced — just bump timestamp
|