@agent-native/core 0.145.8 → 0.146.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/analytics/.agents/skills/turn-into-app/SKILL.md +37 -11
  3. package/corpus/templates/analytics/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  4. package/corpus/templates/analytics/actions/get-sql-dashboard.ts +20 -4
  5. package/corpus/templates/analytics/actions/migrate-first-party-analytics-to-bigquery.ts +59 -24
  6. package/corpus/templates/analytics/changelog/2026-08-07-analytics-migrations-now-use-bounded-pressure-aware-backgrou.md +6 -0
  7. package/corpus/templates/analytics/changelog/2026-08-07-template-activity-charts-now-show-only-core-agent-native-app.md +6 -0
  8. package/corpus/templates/analytics/scripts/emit-netlify-dashboard-report-cron.ts +110 -0
  9. package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +13 -13
  10. package/corpus/templates/analytics/server/jobs/analytics-bigquery-backfill.ts +448 -0
  11. package/corpus/templates/analytics/server/jobs/analytics-rollup-backfill.ts +2 -2
  12. package/corpus/templates/analytics/server/lib/analytics-rollup-lock.ts +4 -5
  13. package/corpus/templates/analytics/server/lib/canonical-first-party-dashboard-repair.ts +35 -0
  14. package/corpus/templates/analytics/server/lib/dashboard-catalog.ts +3 -5
  15. package/corpus/templates/analytics/server/lib/first-party-analytics-backend.ts +10 -4
  16. package/corpus/templates/analytics/server/lib/first-party-analytics-rollups.ts +4 -11
  17. package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +74 -28
  18. package/corpus/templates/analytics/server/plugins/analytics-rollup-backfill-jobs.ts +2 -5
  19. package/corpus/templates/analytics/server/plugins/db.ts +42 -0
  20. package/corpus/templates/analytics/server/routes/api/analytics-bigquery/backfill.post.ts +55 -0
  21. package/corpus/templates/analytics/server/routes/api/dashboard-agent-context.json.get.ts +22 -4
  22. package/corpus/templates/assets/.agents/skills/turn-into-app/SKILL.md +37 -11
  23. package/corpus/templates/assets/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  24. package/corpus/templates/brain/.agents/skills/turn-into-app/SKILL.md +37 -11
  25. package/corpus/templates/brain/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  26. package/corpus/templates/brain/server/lib/connectors.ts +38 -14
  27. package/corpus/templates/calendar/.agents/skills/turn-into-app/SKILL.md +37 -11
  28. package/corpus/templates/calendar/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  29. package/corpus/templates/chat/.agents/skills/turn-into-app/SKILL.md +37 -11
  30. package/corpus/templates/chat/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  31. package/corpus/templates/clips/.agents/skills/turn-into-app/SKILL.md +37 -11
  32. package/corpus/templates/clips/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  33. package/corpus/templates/content/.agents/skills/turn-into-app/SKILL.md +37 -11
  34. package/corpus/templates/content/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  35. package/corpus/templates/crm/.agents/skills/turn-into-app/SKILL.md +37 -11
  36. package/corpus/templates/crm/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  37. package/corpus/templates/design/.agents/skills/turn-into-app/SKILL.md +37 -11
  38. package/corpus/templates/design/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  39. package/corpus/templates/dispatch/.agents/skills/turn-into-app/SKILL.md +37 -11
  40. package/corpus/templates/dispatch/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  41. package/corpus/templates/factory/.agents/skills/turn-into-app/SKILL.md +37 -11
  42. package/corpus/templates/factory/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  43. package/corpus/templates/forms/.agents/skills/turn-into-app/SKILL.md +37 -11
  44. package/corpus/templates/forms/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  45. package/corpus/templates/macros/.agents/skills/turn-into-app/SKILL.md +37 -11
  46. package/corpus/templates/macros/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  47. package/corpus/templates/mail/.agents/skills/turn-into-app/SKILL.md +37 -11
  48. package/corpus/templates/mail/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  49. package/corpus/templates/plan/.agents/skills/turn-into-app/SKILL.md +37 -11
  50. package/corpus/templates/plan/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  51. package/corpus/templates/slides/.agents/skills/turn-into-app/SKILL.md +37 -11
  52. package/corpus/templates/slides/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  53. package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +13 -0
  54. package/corpus/templates/slides/app/components/editor/GeneratingSlidePreview.tsx +5 -0
  55. package/corpus/templates/slides/app/components/presentation/PresentationView.tsx +5 -0
  56. package/corpus/templates/slides/app/components/presentation/PresenterView.tsx +5 -0
  57. package/corpus/templates/slides/app/pages/DeckEditor.tsx +3 -0
  58. package/corpus/templates/slides/app/pages/Presentation.tsx +3 -0
  59. package/corpus/templates/slides/app/pages/SharedPresentation.tsx +5 -0
  60. package/corpus/templates/slides/app/routes/slide.tsx +10 -5
  61. package/corpus/templates/slides/changelog/2026-08-07-slide-previews-and-present-now-keep-deck-colors-consistent.md +6 -0
  62. package/corpus/templates/slides/server/db/schema.ts +1 -0
  63. package/corpus/templates/slides/server/handlers/share.ts +51 -3
  64. package/corpus/templates/slides/server/plugins/db.ts +5 -0
  65. package/corpus/templates/slides/shared/api.ts +2 -0
  66. package/corpus/templates/tasks/.agents/skills/turn-into-app/SKILL.md +37 -11
  67. package/corpus/templates/tasks/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  68. package/dist/cli/code-agent-executor.js +8 -3
  69. package/dist/client/ConnectBuilderCard.d.ts +7 -7
  70. package/dist/client/ConnectBuilderCard.js +45 -20
  71. package/dist/collab/struct-routes.d.ts +1 -1
  72. package/dist/config.d.ts +9 -2
  73. package/dist/config.js +38 -2
  74. package/dist/db/client.d.ts +13 -1
  75. package/dist/db/client.js +76 -2
  76. package/dist/db/create-get-db.js +2 -2
  77. package/dist/deploy/build.js +5 -1
  78. package/dist/file-upload/actions/upload-image.d.ts +1 -1
  79. package/dist/notifications/routes.d.ts +2 -2
  80. package/dist/observability/routes.d.ts +1 -1
  81. package/dist/progress/routes.d.ts +1 -1
  82. package/dist/provider-api/actions/custom-provider-registration.d.ts +9 -9
  83. package/dist/provider-api/actions/provider-api.d.ts +8 -8
  84. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  85. package/dist/resources/handlers.d.ts +1 -1
  86. package/dist/scripts/docs/search.js +3 -2
  87. package/dist/server/agent-chat/prompt-resources.js +4 -3
  88. package/dist/server/agents-bundle.d.ts +20 -3
  89. package/dist/server/agents-bundle.js +57 -30
  90. package/dist/server/better-auth-instance.js +2 -2
  91. package/dist/shared/runtime-config.js +1 -1
  92. package/dist/templates/chat/.agents/skills/turn-into-app/SKILL.md +37 -11
  93. package/dist/templates/chat/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  94. package/dist/templates/default/.agents/skills/turn-into-app/SKILL.md +37 -11
  95. package/dist/templates/default/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  96. package/dist/templates/headless/.agents/skills/turn-into-app/SKILL.md +37 -11
  97. package/dist/templates/headless/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  98. package/dist/templates/workspace-core/.agents/skills/turn-into-app/SKILL.md +37 -11
  99. package/dist/templates/workspace-core/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  100. package/dist/vite/agent-native-config-loader.d.ts +10 -0
  101. package/dist/vite/agent-native-config-loader.js +56 -0
  102. package/dist/vite/agents-bundle-plugin.d.ts +5 -1
  103. package/dist/vite/agents-bundle-plugin.js +29 -6
  104. package/dist/vite/client.d.ts +4 -2
  105. package/dist/vite/client.js +4 -49
  106. package/dist/vite/index.d.ts +2 -2
  107. package/dist/vite/index.js +1 -1
  108. package/docs/content/agent-native-config.mdx +43 -17
  109. package/docs/content/environment-variables.mdx +1 -1
  110. package/package.json +3 -3
  111. package/src/templates/chat/.agents/skills/turn-into-app/SKILL.md +37 -11
  112. package/src/templates/chat/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  113. package/src/templates/default/.agents/skills/turn-into-app/SKILL.md +37 -11
  114. package/src/templates/default/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  115. package/src/templates/headless/.agents/skills/turn-into-app/SKILL.md +37 -11
  116. package/src/templates/headless/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
  117. package/src/templates/workspace-core/.agents/skills/turn-into-app/SKILL.md +37 -11
  118. package/src/templates/workspace-core/.agents/skills/turn-into-app/references/fresh-project.md +13 -2
@@ -51,13 +51,24 @@ also place the skill instructions or this reference in the Project
51
51
  instructions/knowledge files. Then add and authenticate the Dispatch MCP
52
52
  connector from the packaged `adapters/chatgpt-mcp/connector.json`.
53
53
 
54
+ For Claude Web, ChatGPT Web, and their web Projects, the host is an
55
+ orchestrator, not the build environment. After forming the source brief, call
56
+ the Dispatch `start-workspace-app-creation` action so Builder creates the app
57
+ in the connected workspace. Do not use the host's code interpreter, shell,
58
+ artifact editor, `create_workspace_app`, or local `pnpm`/`npm` commands. If the
59
+ handoff action is unavailable, stop and ask the user to authenticate Dispatch;
60
+ do not fall back to a local sandbox build. Claude Code and Codex Code are the
61
+ local-agent exception and may follow the implementation steps in the main
62
+ skill.
63
+
54
64
  In a new Project chat, say:
55
65
 
56
66
  ```text
57
67
  Turn this project into an app. Use the visible Project instructions,
58
68
  knowledge files, and any selected successful runs as the source. Create the
59
- app in the connected Agent-Native workspace, keep the source brief bounded,
60
- and report the real path and verification result.
69
+ app in the connected Agent-Native workspace through Dispatch and Builder, keep
70
+ the source brief bounded, and report the real Builder branch/path and
71
+ verification result. Do not build it in this chat's sandbox.
61
72
  ```
62
73
 
63
74
  If the host does not show the Project instructions or files to the model, stop
@@ -4,7 +4,7 @@ description: >-
4
4
  Turn visible project context, a proven thread, skill, or workflow into a
5
5
  runnable Agent-Native app with simple buttons, visible agent steps, preview,
6
6
  and deployment handoff. Use when a user invokes `/turn-into-app` or asks to
7
- make a workflow into an app.
7
+ make a workflow into an app, including from Claude or ChatGPT on the web.
8
8
  user-invocable: true
9
9
  scope: both
10
10
  metadata:
@@ -13,9 +13,32 @@ metadata:
13
13
 
14
14
  # Turn Into App
15
15
 
16
+ ## Host execution boundary
17
+
18
+ The build location depends on the host. Treat this as a hard routing rule:
19
+
20
+ - In Claude Web, ChatGPT Web, or a Claude/ChatGPT Project on the web, you are
21
+ the source analyst and handoff orchestrator. You must not build the app in
22
+ the host sandbox. Do not run `npm`, `pnpm`, `npx`, `agent-native create`, or
23
+ `add-app`; do not edit files, create artifacts, or start a local dev server.
24
+ After writing the bounded source brief, call the connected Dispatch action
25
+ `start-workspace-app-creation`. Pass the brief and repeatable workflow in
26
+ `prompt`, plus the inferred `appId`, `description`, `template`, and selected
27
+ `resourceIds` when available. This is the Builder handoff.
28
+ - Do not substitute the generic `create_workspace_app` MCP tool in an online
29
+ host. That tool is a local workspace scaffolder, not the Builder handoff.
30
+ - If `start-workspace-app-creation` is not available or Dispatch is not
31
+ authenticated, stop with the connector setup needed. Do not fall back to a
32
+ local build or claim that the app exists.
33
+ - In Claude Code, Codex Code, or another local code-agent runtime with a target
34
+ workspace, follow the local implementation steps below. The local agent may
35
+ scaffold, edit, run, and verify the app there.
36
+
16
37
  ## Default behavior
17
38
 
18
- This is an end-to-end build skill, not a request for an app proposal.
39
+ For a local code-agent runtime this is an end-to-end build skill, not a request
40
+ for an app proposal. For an online host, the end-to-end result is a verified
41
+ Builder handoff and the resulting workspace app, not code written in the host.
19
42
 
20
43
  - With no argument, choose the source in this order: visible project context,
21
44
  then the current thread. A fresh Claude or ChatGPT Project is a valid source
@@ -47,9 +70,12 @@ private web access, invent an importer, add fake OAuth, or scrape a logged-in
47
70
  page. If the needed context is not visible, ask for an export, transcript, or
48
71
  attachment and treat that artifact as imported source material.
49
72
 
50
- Deliver a fresh app in a new directory, implement the repeatable workflow with
51
- buttons and agent handoffs, start its dev server, verify the main path, and
52
- continue through build/deployment handoff. Do not stop at a plan.
73
+ For local code-agent runtimes, deliver a fresh app in a new directory,
74
+ implement the repeatable workflow with buttons and agent handoffs, start its dev
75
+ server, verify the main path, and continue through build/deployment handoff. Do
76
+ not stop at a plan. For online hosts, call Dispatch first after the source brief,
77
+ then report the returned Builder branch/path and verify the workspace app through
78
+ Dispatch when it becomes available.
53
79
 
54
80
  ## Fresh project context mode
55
81
 
@@ -190,12 +216,12 @@ Do not use `create` for an existing workspace; it scaffolds a new standalone
190
216
  workspace rather than adding an app to the current one.
191
217
 
192
218
  When the source came from a fresh external Project and the target is a Builder
193
- workspace, prefer the available Dispatch MCP workspace handoff after writing
194
- the source brief. Call `start-workspace-app-creation` with a concise prompt,
195
- the inferred app id, and the brief's repeatable workflow. Pass selected
196
- workspace resource IDs when they are available, rather than pasting entire
197
- knowledge files. Continue from the returned workspace path or Builder handoff
198
- and report the actual verification result.
219
+ workspace, the online host path is mandatory: after writing the source brief,
220
+ call `start-workspace-app-creation` with a concise prompt, the inferred app id,
221
+ and the brief's repeatable workflow. Pass selected workspace resource IDs when
222
+ they are available, rather than pasting entire knowledge files. Continue from
223
+ the returned workspace path or Builder branch handoff and report the actual
224
+ verification result. Do not run the local scaffold commands in this host mode.
199
225
 
200
226
  Use a first-party template only when it materially fits the workflow. Keep the
201
227
  new app independent from the source thread's working tree unless the user
@@ -51,13 +51,24 @@ also place the skill instructions or this reference in the Project
51
51
  instructions/knowledge files. Then add and authenticate the Dispatch MCP
52
52
  connector from the packaged `adapters/chatgpt-mcp/connector.json`.
53
53
 
54
+ For Claude Web, ChatGPT Web, and their web Projects, the host is an
55
+ orchestrator, not the build environment. After forming the source brief, call
56
+ the Dispatch `start-workspace-app-creation` action so Builder creates the app
57
+ in the connected workspace. Do not use the host's code interpreter, shell,
58
+ artifact editor, `create_workspace_app`, or local `pnpm`/`npm` commands. If the
59
+ handoff action is unavailable, stop and ask the user to authenticate Dispatch;
60
+ do not fall back to a local sandbox build. Claude Code and Codex Code are the
61
+ local-agent exception and may follow the implementation steps in the main
62
+ skill.
63
+
54
64
  In a new Project chat, say:
55
65
 
56
66
  ```text
57
67
  Turn this project into an app. Use the visible Project instructions,
58
68
  knowledge files, and any selected successful runs as the source. Create the
59
- app in the connected Agent-Native workspace, keep the source brief bounded,
60
- and report the real path and verification result.
69
+ app in the connected Agent-Native workspace through Dispatch and Builder, keep
70
+ the source brief bounded, and report the real Builder branch/path and
71
+ verification result. Do not build it in this chat's sandbox.
61
72
  ```
62
73
 
63
74
  If the host does not show the Project instructions or files to the model, stop
@@ -4,7 +4,7 @@ description: >-
4
4
  Turn visible project context, a proven thread, skill, or workflow into a
5
5
  runnable Agent-Native app with simple buttons, visible agent steps, preview,
6
6
  and deployment handoff. Use when a user invokes `/turn-into-app` or asks to
7
- make a workflow into an app.
7
+ make a workflow into an app, including from Claude or ChatGPT on the web.
8
8
  user-invocable: true
9
9
  scope: both
10
10
  metadata:
@@ -13,9 +13,32 @@ metadata:
13
13
 
14
14
  # Turn Into App
15
15
 
16
+ ## Host execution boundary
17
+
18
+ The build location depends on the host. Treat this as a hard routing rule:
19
+
20
+ - In Claude Web, ChatGPT Web, or a Claude/ChatGPT Project on the web, you are
21
+ the source analyst and handoff orchestrator. You must not build the app in
22
+ the host sandbox. Do not run `npm`, `pnpm`, `npx`, `agent-native create`, or
23
+ `add-app`; do not edit files, create artifacts, or start a local dev server.
24
+ After writing the bounded source brief, call the connected Dispatch action
25
+ `start-workspace-app-creation`. Pass the brief and repeatable workflow in
26
+ `prompt`, plus the inferred `appId`, `description`, `template`, and selected
27
+ `resourceIds` when available. This is the Builder handoff.
28
+ - Do not substitute the generic `create_workspace_app` MCP tool in an online
29
+ host. That tool is a local workspace scaffolder, not the Builder handoff.
30
+ - If `start-workspace-app-creation` is not available or Dispatch is not
31
+ authenticated, stop with the connector setup needed. Do not fall back to a
32
+ local build or claim that the app exists.
33
+ - In Claude Code, Codex Code, or another local code-agent runtime with a target
34
+ workspace, follow the local implementation steps below. The local agent may
35
+ scaffold, edit, run, and verify the app there.
36
+
16
37
  ## Default behavior
17
38
 
18
- This is an end-to-end build skill, not a request for an app proposal.
39
+ For a local code-agent runtime this is an end-to-end build skill, not a request
40
+ for an app proposal. For an online host, the end-to-end result is a verified
41
+ Builder handoff and the resulting workspace app, not code written in the host.
19
42
 
20
43
  - With no argument, choose the source in this order: visible project context,
21
44
  then the current thread. A fresh Claude or ChatGPT Project is a valid source
@@ -47,9 +70,12 @@ private web access, invent an importer, add fake OAuth, or scrape a logged-in
47
70
  page. If the needed context is not visible, ask for an export, transcript, or
48
71
  attachment and treat that artifact as imported source material.
49
72
 
50
- Deliver a fresh app in a new directory, implement the repeatable workflow with
51
- buttons and agent handoffs, start its dev server, verify the main path, and
52
- continue through build/deployment handoff. Do not stop at a plan.
73
+ For local code-agent runtimes, deliver a fresh app in a new directory,
74
+ implement the repeatable workflow with buttons and agent handoffs, start its dev
75
+ server, verify the main path, and continue through build/deployment handoff. Do
76
+ not stop at a plan. For online hosts, call Dispatch first after the source brief,
77
+ then report the returned Builder branch/path and verify the workspace app through
78
+ Dispatch when it becomes available.
53
79
 
54
80
  ## Fresh project context mode
55
81
 
@@ -190,12 +216,12 @@ Do not use `create` for an existing workspace; it scaffolds a new standalone
190
216
  workspace rather than adding an app to the current one.
191
217
 
192
218
  When the source came from a fresh external Project and the target is a Builder
193
- workspace, prefer the available Dispatch MCP workspace handoff after writing
194
- the source brief. Call `start-workspace-app-creation` with a concise prompt,
195
- the inferred app id, and the brief's repeatable workflow. Pass selected
196
- workspace resource IDs when they are available, rather than pasting entire
197
- knowledge files. Continue from the returned workspace path or Builder handoff
198
- and report the actual verification result.
219
+ workspace, the online host path is mandatory: after writing the source brief,
220
+ call `start-workspace-app-creation` with a concise prompt, the inferred app id,
221
+ and the brief's repeatable workflow. Pass selected workspace resource IDs when
222
+ they are available, rather than pasting entire knowledge files. Continue from
223
+ the returned workspace path or Builder branch handoff and report the actual
224
+ verification result. Do not run the local scaffold commands in this host mode.
199
225
 
200
226
  Use a first-party template only when it materially fits the workflow. Keep the
201
227
  new app independent from the source thread's working tree unless the user
@@ -51,13 +51,24 @@ also place the skill instructions or this reference in the Project
51
51
  instructions/knowledge files. Then add and authenticate the Dispatch MCP
52
52
  connector from the packaged `adapters/chatgpt-mcp/connector.json`.
53
53
 
54
+ For Claude Web, ChatGPT Web, and their web Projects, the host is an
55
+ orchestrator, not the build environment. After forming the source brief, call
56
+ the Dispatch `start-workspace-app-creation` action so Builder creates the app
57
+ in the connected workspace. Do not use the host's code interpreter, shell,
58
+ artifact editor, `create_workspace_app`, or local `pnpm`/`npm` commands. If the
59
+ handoff action is unavailable, stop and ask the user to authenticate Dispatch;
60
+ do not fall back to a local sandbox build. Claude Code and Codex Code are the
61
+ local-agent exception and may follow the implementation steps in the main
62
+ skill.
63
+
54
64
  In a new Project chat, say:
55
65
 
56
66
  ```text
57
67
  Turn this project into an app. Use the visible Project instructions,
58
68
  knowledge files, and any selected successful runs as the source. Create the
59
- app in the connected Agent-Native workspace, keep the source brief bounded,
60
- and report the real path and verification result.
69
+ app in the connected Agent-Native workspace through Dispatch and Builder, keep
70
+ the source brief bounded, and report the real Builder branch/path and
71
+ verification result. Do not build it in this chat's sandbox.
61
72
  ```
62
73
 
63
74
  If the host does not show the Project instructions or files to the model, stop
@@ -0,0 +1,10 @@
1
+ import { type AgentNativeConfig, type AgentNativeConfigContext, type AgentNativeConfigInput } from "../config.js";
2
+ /** The canonical filename comes first; the remaining names stay compatible. */
3
+ export declare const AGENT_NATIVE_CONFIG_FILE_CANDIDATES: readonly ["agent-native.config.ts", "agent-native.ts", "agent-native.mts", "agent-native.config.mts"];
4
+ export declare function createAgentNativeConfigContext(command: AgentNativeConfigContext["command"] | undefined, mode: string): AgentNativeConfigContext;
5
+ export declare function readAgentNativeJsonConfig(cwd: string): AgentNativeConfig;
6
+ export declare function loadAgentNativeConfigFile(cwd: string): Promise<AgentNativeConfigInput | undefined>;
7
+ export declare function loadResolvedAgentNativeConfig(cwd: string, context: AgentNativeConfigContext, options?: {
8
+ loadProjectConfig?: boolean;
9
+ projectConfig?: AgentNativeConfigInput;
10
+ }): Promise<AgentNativeConfig>;
@@ -0,0 +1,56 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { pathToFileURL } from "node:url";
4
+ import { mergeAgentNativeConfigs, normalizeAgentNativeConfig, resolveAgentNativeConfig, } from "../config.js";
5
+ /** The canonical filename comes first; the remaining names stay compatible. */
6
+ export const AGENT_NATIVE_CONFIG_FILE_CANDIDATES = [
7
+ "agent-native.config.ts",
8
+ "agent-native.ts",
9
+ "agent-native.mts",
10
+ "agent-native.config.mts",
11
+ ];
12
+ export function createAgentNativeConfigContext(command, mode) {
13
+ const resolvedCommand = command === "build" ? "build" : "serve";
14
+ return {
15
+ command: resolvedCommand,
16
+ mode,
17
+ isDev: resolvedCommand === "serve",
18
+ isBuild: resolvedCommand === "build",
19
+ };
20
+ }
21
+ export function readAgentNativeJsonConfig(cwd) {
22
+ const configPath = path.join(cwd, "agent-native.json");
23
+ if (!fs.existsSync(configPath))
24
+ return {};
25
+ let parsed;
26
+ try {
27
+ parsed = JSON.parse(fs.readFileSync(configPath, "utf8"));
28
+ }
29
+ catch (error) {
30
+ throw new Error(`Could not read ${configPath}: ${error instanceof Error ? error.message : String(error)}`);
31
+ }
32
+ return normalizeAgentNativeConfig(parsed, configPath);
33
+ }
34
+ export async function loadAgentNativeConfigFile(cwd) {
35
+ const configPath = AGENT_NATIVE_CONFIG_FILE_CANDIDATES.map((filename) => path.join(cwd, filename)).find((candidate) => fs.existsSync(candidate));
36
+ if (!configPath)
37
+ return undefined;
38
+ try {
39
+ const module = (await import(pathToFileURL(configPath).href));
40
+ const config = module.default ?? module.agentNativeConfig;
41
+ if (typeof config !== "object" && typeof config !== "function") {
42
+ throw new Error("the default export must be an object or function");
43
+ }
44
+ return config;
45
+ }
46
+ catch (error) {
47
+ throw new Error(`Could not load ${configPath}: ${error instanceof Error ? error.message : String(error)}`);
48
+ }
49
+ }
50
+ export async function loadResolvedAgentNativeConfig(cwd, context, options = {}) {
51
+ const projectConfig = options.projectConfig ??
52
+ (options.loadProjectConfig === false
53
+ ? undefined
54
+ : await loadAgentNativeConfigFile(cwd));
55
+ return resolveAgentNativeConfig(mergeAgentNativeConfigs(readAgentNativeJsonConfig(cwd), projectConfig ? resolveAgentNativeConfig(projectConfig, context) : {}), context);
56
+ }
@@ -1,2 +1,6 @@
1
1
  import type { Plugin } from "vite";
2
- export declare function agentsBundlePlugin(): Plugin;
2
+ import type { AgentNativeConfigInput } from "../config.js";
3
+ export interface AgentsBundlePluginOptions {
4
+ agentNativeConfig?: AgentNativeConfigInput;
5
+ }
6
+ export declare function agentsBundlePlugin(options?: AgentsBundlePluginOptions): Plugin;
@@ -15,7 +15,8 @@ import fs from "fs";
15
15
  */
16
16
  import path from "path";
17
17
  import { getWorkspaceCoreExports } from "../deploy/workspace-core.js";
18
- import { readAgentsBundleFromFs, } from "../server/agents-bundle.js";
18
+ import { readAgentsBundleFromFs, resolveAgentInstructionPaths, } from "../server/agents-bundle.js";
19
+ import { createAgentNativeConfigContext, loadResolvedAgentNativeConfig, } from "./agent-native-config-loader.js";
19
20
  const VIRTUAL_ID = "virtual:agents-bundle";
20
21
  const RESOLVED_ID = "\0" + VIRTUAL_ID;
21
22
  const TEMPLATE_SKILLS_DIRS = [
@@ -33,7 +34,7 @@ const TEMPLATE_SKILLS_DIRS = [
33
34
  * reload is batched.
34
35
  */
35
36
  const FULL_RELOAD_COALESCE_MS = 500;
36
- async function emitBundleModule(projectRoot) {
37
+ async function emitBundleModule(projectRoot, agentConfig) {
37
38
  // If the project is inside an enterprise monorepo with a workspace core,
38
39
  // merge in its AGENTS.md + skills. Template skills override workspace
39
40
  // core skills on name collision.
@@ -51,7 +52,9 @@ async function emitBundleModule(projectRoot) {
51
52
  catch {
52
53
  // fall back to template-only
53
54
  }
54
- const bundle = readAgentsBundleFromFs(projectRoot, workspaceSource);
55
+ const bundle = readAgentsBundleFromFs(projectRoot, workspaceSource, {
56
+ instructions: agentConfig.instructions,
57
+ });
55
58
  // Serialize as JSON and wrap in `export default` — this produces a valid
56
59
  // ES module that any bundler (Rollup, esbuild, Rolldown) can statically
57
60
  // analyze and tree-shake if nothing imports it.
@@ -62,12 +65,17 @@ const bundle = ${JSON.stringify(bundle)};
62
65
  export default bundle;
63
66
  `;
64
67
  }
65
- export function agentsBundlePlugin() {
68
+ export function agentsBundlePlugin(options = {}) {
66
69
  let projectRoot = "";
70
+ let agentConfigPromise = Promise.resolve({});
67
71
  return {
68
72
  name: "agent-native-agents-bundle",
69
- configResolved(config) {
73
+ async configResolved(config) {
70
74
  projectRoot = config.root;
75
+ agentConfigPromise = loadResolvedAgentNativeConfig(projectRoot, createAgentNativeConfigContext(config.command, config.mode), {
76
+ loadProjectConfig: options.agentNativeConfig === undefined,
77
+ projectConfig: options.agentNativeConfig,
78
+ });
71
79
  },
72
80
  resolveId(id) {
73
81
  if (id === VIRTUAL_ID)
@@ -79,7 +87,7 @@ export function agentsBundlePlugin() {
79
87
  return null;
80
88
  if (!projectRoot)
81
89
  projectRoot = process.cwd();
82
- return await emitBundleModule(projectRoot);
90
+ return await emitBundleModule(projectRoot, await agentConfigPromise);
83
91
  },
84
92
  async configureServer(server) {
85
93
  // Watch AGENTS.md + any SKILL.md changes and invalidate the virtual
@@ -87,6 +95,9 @@ export function agentsBundlePlugin() {
87
95
  // the workspace core's AGENTS.md + skills directory (if present)
88
96
  // so edits to the enterprise mid-layer propagate to every app.
89
97
  const watcher = server.watcher;
98
+ const agentConfig = await agentConfigPromise;
99
+ const instructionPaths = resolveAgentInstructionPaths(agentConfig.instructions);
100
+ const instructionFiles = new Set([instructionPaths.runtime, instructionPaths.development].map((file) => path.resolve(projectRoot, file)));
90
101
  // Resolve the workspace core up front so we can tell which files
91
102
  // outside projectRoot should trigger invalidation.
92
103
  let workspaceAgentsMdPath = null;
@@ -102,6 +113,8 @@ export function agentsBundlePlugin() {
102
113
  // ignore
103
114
  }
104
115
  const shouldInvalidate = (file) => {
116
+ if (instructionFiles.has(path.resolve(file)))
117
+ return true;
105
118
  const rel = path.relative(projectRoot, file);
106
119
  if (!rel.startsWith("..")) {
107
120
  if (rel === "AGENTS.md")
@@ -158,6 +171,16 @@ export function agentsBundlePlugin() {
158
171
  if (fs.existsSync(skillsDir))
159
172
  watcher.add(skillsDir);
160
173
  }
174
+ for (const instructionFile of instructionFiles) {
175
+ if (fs.existsSync(instructionFile)) {
176
+ watcher.add(instructionFile);
177
+ }
178
+ else {
179
+ const parent = path.dirname(instructionFile);
180
+ if (fs.existsSync(parent))
181
+ watcher.add(parent);
182
+ }
183
+ }
161
184
  if (workspaceAgentsMdPath && fs.existsSync(workspaceAgentsMdPath)) {
162
185
  watcher.add(workspaceAgentsMdPath);
163
186
  }
@@ -117,8 +117,10 @@ export interface ClientConfigOptions {
117
117
  define?: UserConfig["define"];
118
118
  /**
119
119
  * Public app behavior from `agent-native.json` or an optional typed
120
- * `agent-native.ts` file. Explicit Vite options win over the JSON file,
121
- * while the file remains the default project-level source of truth.
120
+ * `agent-native.config.ts` file. Explicit Vite options win over the JSON
121
+ * file, while the typed file remains the default project-level source of
122
+ * truth. `agent-native.ts`, `.mts`, and `agent-native.config.mts` remain
123
+ * compatibility aliases.
122
124
  */
123
125
  agentNativeConfig?: AgentNativeConfigInput;
124
126
  /**
@@ -2,12 +2,12 @@ import { EventEmitter } from "events";
2
2
  import fs from "fs";
3
3
  import { createRequire, syncBuiltinESMExports } from "module";
4
4
  import path from "path";
5
- import { fileURLToPath, pathToFileURL } from "url";
5
+ import { fileURLToPath } from "url";
6
6
  import { renderDesignSystemThemeCss, } from "@agent-native/toolkit/design-system/theme";
7
7
  import { loadEnv, } from "vite";
8
8
  import { mergePendingChangelog, parsePendingEntry, } from "../changelog/parse.js";
9
9
  import { getViteDevRecoveryScript } from "../client/vite-dev-recovery-script.js";
10
- import { mergeAgentNativeConfigs, normalizeAgentNativeConfig, resolveAgentNativeConfig, } from "../config.js";
10
+ import { mergeAgentNativeConfigs, resolveAgentNativeConfig, } from "../config.js";
11
11
  import { writeAgentNativeNitroPresetMarker } from "../deploy/nitro-preset.js";
12
12
  import { findWorkspaceRoot } from "../scripts/utils.js";
13
13
  import { verifyEmbedSessionToken } from "../server/embed-session.js";
@@ -17,6 +17,7 @@ import { normalizeMcpIntegrationsConfig, } from "../shared/mcp-integration-confi
17
17
  import { normalizeAgentNativeRouteWarmupConfig, } from "../shared/route-warmup-config.js";
18
18
  import { formatRuntimeConfigReport, getRuntimeConfigReport, } from "../shared/runtime-config.js";
19
19
  import { actionTypesPlugin } from "./action-types-plugin.js";
20
+ import { createAgentNativeConfigContext, loadAgentNativeConfigFile, readAgentNativeJsonConfig, } from "./agent-native-config-loader.js";
20
21
  import { agentsBundlePlugin } from "./agents-bundle-plugin.js";
21
22
  const require = createRequire(import.meta.url);
22
23
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -2568,7 +2569,7 @@ function createAgentNativePlugins(options, { command, includeReactTransform, use
2568
2569
  ...userPlugins,
2569
2570
  appChangelogRawPlugin(),
2570
2571
  actionTypesPlugin(),
2571
- agentsBundlePlugin(),
2572
+ agentsBundlePlugin({ agentNativeConfig: options.agentNativeConfig }),
2572
2573
  autoReloadOnOptimizeDep(),
2573
2574
  fullReloadOnOptimizeDep504(),
2574
2575
  embedDevFrameHeaders(),
@@ -2612,52 +2613,6 @@ function resolveAgentNativeTemplate(cwd) {
2612
2613
  ?.trim()
2613
2614
  .toLowerCase() ?? "");
2614
2615
  }
2615
- function createAgentNativeConfigContext(command, mode) {
2616
- const resolvedCommand = command === "build" ? "build" : "serve";
2617
- return {
2618
- command: resolvedCommand,
2619
- mode,
2620
- isDev: resolvedCommand === "serve",
2621
- isBuild: resolvedCommand === "build",
2622
- };
2623
- }
2624
- function readAgentNativeJsonConfig(cwd) {
2625
- const configPath = path.join(cwd, "agent-native.json");
2626
- if (!fs.existsSync(configPath))
2627
- return {};
2628
- let parsed;
2629
- try {
2630
- parsed = JSON.parse(fs.readFileSync(configPath, "utf8"));
2631
- }
2632
- catch (error) {
2633
- throw new Error(`Could not read ${configPath}: ${error instanceof Error ? error.message : String(error)}`);
2634
- }
2635
- return normalizeAgentNativeConfig(parsed, configPath);
2636
- }
2637
- async function loadAgentNativeConfigFile(cwd) {
2638
- const candidates = [
2639
- "agent-native.ts",
2640
- "agent-native.mts",
2641
- "agent-native.config.ts",
2642
- "agent-native.config.mts",
2643
- ];
2644
- const configPath = candidates
2645
- .map((filename) => path.join(cwd, filename))
2646
- .find((candidate) => fs.existsSync(candidate));
2647
- if (!configPath)
2648
- return undefined;
2649
- try {
2650
- const module = (await import(pathToFileURL(configPath).href));
2651
- const config = module.default ?? module.agentNativeConfig;
2652
- if (typeof config !== "object" && typeof config !== "function") {
2653
- throw new Error("the default export must be an object or function");
2654
- }
2655
- return config;
2656
- }
2657
- catch (error) {
2658
- throw new Error(`Could not load ${configPath}: ${error instanceof Error ? error.message : String(error)}`);
2659
- }
2660
- }
2661
2616
  function reportRuntimeConfigDiagnostics(appConfig, context, mode, env = process.env) {
2662
2617
  const production = mode === "production" || process.env.NODE_ENV === "production";
2663
2618
  if (!production)
@@ -1,6 +1,6 @@
1
1
  export { agentNative, defineConfig, type AgentNativeVitePluginOptions, type ClientConfigOptions, type NitroOptions, } from "./client.js";
2
- export { defineAgentNativeConfig, type AgentNativeConfig, type AgentNativeConfigContext, type AgentNativeConfigFactory, type AgentNativeConfigInput, type AgentNativeDiagnosticsConfig, type AgentNativeFirstRunOnboardingMode, type AgentNativeFirstRunOnboardingSetting, type AgentNativeRuntimeAuthConfig, type AgentNativeRuntimeConfig, type AgentNativeRuntimeDatabaseConfig, type AgentNativeRuntimeEnvironmentConfig, } from "../config.js";
2
+ export { defineAgentNativeConfig, type AgentNativeConfig, type AgentNativeConfigContext, type AgentNativeConfigFactory, type AgentNativeConfigInput, type AgentNativeDiagnosticsConfig, type AgentNativeFirstRunOnboardingMode, type AgentNativeFirstRunOnboardingSetting, type AgentNativeInstructionsConfig, type AgentNativeRuntimeAuthConfig, type AgentNativeRuntimeConfig, type AgentNativeRuntimeDatabaseConfig, type AgentNativeRuntimeEnvironmentConfig, } from "../config.js";
3
3
  export type { AgentNativeRouteWarmupConfigInput, AgentNativeRouteWarmupResolvedConfig, AgentNativeRouteWarmupStrategy, } from "../shared/route-warmup-config.js";
4
4
  export { actionTypesPlugin, generateActionRegistryForProject, } from "./action-types-plugin.js";
5
- export { agentsBundlePlugin } from "./agents-bundle-plugin.js";
5
+ export { agentsBundlePlugin, type AgentsBundlePluginOptions, } from "./agents-bundle-plugin.js";
6
6
  export { createAgentWebVitePlugin, type AgentWebVitePluginOptions, } from "./agent-web-plugin.js";
@@ -1,5 +1,5 @@
1
1
  export { agentNative, defineConfig, } from "./client.js";
2
2
  export { defineAgentNativeConfig, } from "../config.js";
3
3
  export { actionTypesPlugin, generateActionRegistryForProject, } from "./action-types-plugin.js";
4
- export { agentsBundlePlugin } from "./agents-bundle-plugin.js";
4
+ export { agentsBundlePlugin, } from "./agents-bundle-plugin.js";
5
5
  export { createAgentWebVitePlugin, } from "./agent-web-plugin.js";