@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
@@ -13,13 +13,13 @@
13
13
  export declare function createNotificationsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<"" | import("./types.js").Notification[] | {
14
14
  count: number;
15
15
  updated?: undefined;
16
- ok?: undefined;
17
16
  error?: undefined;
17
+ ok?: undefined;
18
18
  } | {
19
19
  count?: undefined;
20
20
  updated: number;
21
- ok?: undefined;
22
21
  error?: undefined;
22
+ ok?: undefined;
23
23
  } | {
24
24
  count?: undefined;
25
25
  updated?: undefined;
@@ -62,6 +62,6 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
62
62
  summary?: undefined;
63
63
  spans?: undefined;
64
64
  id?: undefined;
65
- error?: undefined;
66
65
  ok: boolean;
66
+ error?: undefined;
67
67
  }>>;
@@ -15,6 +15,6 @@ export declare function createProgressHandler(): import("h3").EventHandlerWithFe
15
15
  error: string;
16
16
  ok?: undefined;
17
17
  } | {
18
- ok: boolean;
19
18
  error?: undefined;
19
+ ok: boolean;
20
20
  }>>;
@@ -75,9 +75,8 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
75
75
  user: "user";
76
76
  }>>;
77
77
  }, z.core.$strip>>, {
78
- message?: undefined;
78
+ id?: undefined;
79
79
  deleted?: undefined;
80
- found?: undefined;
81
80
  providers: {
82
81
  id: string;
83
82
  label: string;
@@ -89,21 +88,21 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
89
88
  }[];
90
89
  count: number;
91
90
  provider?: undefined;
91
+ found?: undefined;
92
92
  registered?: undefined;
93
- id?: undefined;
94
93
  label?: undefined;
95
- } | {
96
94
  message?: undefined;
95
+ } | {
96
+ id?: undefined;
97
97
  deleted?: undefined;
98
98
  providers?: undefined;
99
99
  count?: undefined;
100
100
  found: boolean;
101
101
  provider: import("../custom-registry.js").CustomProviderConfig;
102
102
  registered?: undefined;
103
- id?: undefined;
104
103
  label?: undefined;
105
- } | {
106
104
  message?: undefined;
105
+ } | {
107
106
  deleted?: undefined;
108
107
  providers?: undefined;
109
108
  count?: undefined;
@@ -112,22 +111,23 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
112
111
  id: string;
113
112
  registered?: undefined;
114
113
  label?: undefined;
115
- } | {
116
114
  message?: undefined;
117
- found?: undefined;
115
+ } | {
118
116
  providers?: undefined;
119
117
  count?: undefined;
120
118
  provider?: undefined;
119
+ found?: undefined;
121
120
  deleted: boolean;
122
121
  id: string;
123
122
  registered?: undefined;
124
123
  label?: undefined;
124
+ message?: undefined;
125
125
  } | {
126
126
  deleted?: undefined;
127
- found?: undefined;
128
127
  providers?: undefined;
129
128
  count?: undefined;
130
129
  provider?: undefined;
130
+ found?: undefined;
131
131
  registered: boolean;
132
132
  id: string;
133
133
  label: string;
@@ -311,10 +311,9 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
311
311
  notes?: string | undefined;
312
312
  scope?: "org" | "user" | undefined;
313
313
  }, {
314
- deleted?: undefined;
315
314
  id?: undefined;
316
315
  provider?: undefined;
317
- found?: undefined;
316
+ deleted?: undefined;
318
317
  message?: undefined;
319
318
  providers: {
320
319
  id: string;
@@ -326,12 +325,13 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
326
325
  updatedAt: number;
327
326
  }[];
328
327
  count: number;
328
+ found?: undefined;
329
329
  registered?: undefined;
330
330
  label?: undefined;
331
331
  } | {
332
- deleted?: undefined;
333
- count?: undefined;
334
332
  id?: undefined;
333
+ count?: undefined;
334
+ deleted?: undefined;
335
335
  message?: undefined;
336
336
  providers?: undefined;
337
337
  found: boolean;
@@ -339,9 +339,9 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
339
339
  registered?: undefined;
340
340
  label?: undefined;
341
341
  } | {
342
- deleted?: undefined;
343
342
  count?: undefined;
344
343
  provider?: undefined;
344
+ deleted?: undefined;
345
345
  message?: undefined;
346
346
  providers?: undefined;
347
347
  found: boolean;
@@ -351,19 +351,19 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
351
351
  } | {
352
352
  count?: undefined;
353
353
  provider?: undefined;
354
- found?: undefined;
355
354
  message?: undefined;
356
355
  providers?: undefined;
356
+ found?: undefined;
357
357
  deleted: boolean;
358
358
  id: string;
359
359
  registered?: undefined;
360
360
  label?: undefined;
361
361
  } | {
362
- deleted?: undefined;
363
362
  count?: undefined;
364
363
  provider?: undefined;
365
- found?: undefined;
364
+ deleted?: undefined;
366
365
  providers?: undefined;
366
+ found?: undefined;
367
367
  registered: boolean;
368
368
  id: string;
369
369
  label: string;
@@ -73,7 +73,6 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
73
73
  offset?: unknown;
74
74
  limit?: unknown;
75
75
  }, {
76
- deleted?: undefined;
77
76
  jobs: {
78
77
  id: string;
79
78
  name: string;
@@ -84,6 +83,7 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
84
83
  updatedAt: string;
85
84
  }[];
86
85
  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;
95
94
  jobs?: undefined;
96
95
  total?: undefined;
96
+ deleted?: undefined;
97
97
  jobId?: undefined;
98
98
  hits: Record<string, unknown>[];
99
99
  offset: number;
@@ -48,8 +48,8 @@ export declare function handleUpdateResource(event: any): Promise<import("./stor
48
48
  }>;
49
49
  /** DELETE /_agent-native/resources/:id — delete a resource */
50
50
  export declare function handleDeleteResource(event: any): Promise<{
51
- ok?: undefined;
52
51
  error: string;
52
+ ok?: undefined;
53
53
  } | {
54
54
  error?: undefined;
55
55
  ok: boolean;
@@ -127,12 +127,13 @@ async function loadAgentBundleDocs() {
127
127
  body: bundle.workspaceAgentsMd,
128
128
  });
129
129
  }
130
- if (bundle.agentsMd?.trim()) {
130
+ const runtimeAgentsMd = bundle.runtimeAgentsMd ?? bundle.agentsMd;
131
+ if (runtimeAgentsMd?.trim()) {
131
132
  docs.push({
132
133
  slug: "agents-template",
133
134
  title: "Template AGENTS.md",
134
135
  description: "Full bundled template/app agent instructions.",
135
- body: bundle.agentsMd,
136
+ body: runtimeAgentsMd,
136
137
  });
137
138
  }
138
139
  // Only runtime-visible skills are searchable/readable here — `scope: dev`
@@ -631,13 +631,14 @@ export async function loadResourcesForPrompt(owner, compact = false, selfAppId,
631
631
  });
632
632
  addSection(block, "required");
633
633
  }
634
- // 2. Template AGENTS.md — always included (critical template instructions).
635
- if (bundle.agentsMd.trim()) {
634
+ // 2. Runtime instruction file — always included when configured.
635
+ const runtimeAgentsMd = bundle.runtimeAgentsMd ?? bundle.agentsMd;
636
+ if (runtimeAgentsMd.trim()) {
636
637
  const block = promptResourceBlock({
637
638
  name: "AGENTS.md",
638
639
  scope: "template",
639
640
  path: "AGENTS.md",
640
- content: bundle.agentsMd,
641
+ content: runtimeAgentsMd,
641
642
  maxChars: promptResourceMaxChars,
642
643
  readHint: 'Use docs-search --slug "agents-template" to read the full template AGENTS.md.',
643
644
  });
@@ -15,7 +15,8 @@
15
15
  * 2. Filesystem fallback — `process.cwd()/AGENTS.md` +
16
16
  * `process.cwd()/.agents/skills/` (or legacy `.agent/skills/`). Only reliable in local dev and Node
17
17
  * production (`agent-native start`); not on Netlify/Vercel/CF at runtime.
18
- * 3. Empty bundle — everything silently returns empty strings.
18
+ * 3. Configuration and filesystem failures propagate so a broken bundle is
19
+ * visible instead of being mistaken for an app with no instructions.
19
20
  *
20
21
  * Result is cached in module scope so it's only computed once per cold start.
21
22
  */
@@ -68,8 +69,15 @@ export interface Skill {
68
69
  files: Record<string, string>;
69
70
  }
70
71
  export interface AgentsBundle {
71
- /** Contents of the template's AGENTS.md (empty string if missing). */
72
+ /**
73
+ * Legacy alias for the runtime instruction file. Empty when an explicitly
74
+ * configured runtime file is missing.
75
+ */
72
76
  agentsMd: string;
77
+ /** Contents of the runtime agent's selected instruction file. */
78
+ runtimeAgentsMd: string;
79
+ /** Contents of the development agent's selected instruction file. */
80
+ developmentAgentsMd: string;
73
81
  /**
74
82
  * Contents of the workspace core's AGENTS.md, if the app is inside an
75
83
  * enterprise monorepo with a `workspaceCore` configured. Empty string
@@ -86,6 +94,14 @@ export interface AgentsBundle {
86
94
  */
87
95
  skills: Record<string, Skill>;
88
96
  }
97
+ export interface AgentsBundleReadOptions {
98
+ instructions?: AgentNativeInstructionsConfig;
99
+ }
100
+ export interface AgentInstructionPaths {
101
+ runtime: string;
102
+ development: string;
103
+ }
104
+ export declare function resolveAgentInstructionPaths(instructions?: AgentNativeInstructionsConfig): AgentInstructionPaths;
89
105
  export declare function normalizeSkillScope(raw: string | undefined): SkillScope;
90
106
  /**
91
107
  * Parse the YAML frontmatter at the top of a skill file.
@@ -97,6 +113,7 @@ export declare function normalizeSkillScope(raw: string | undefined): SkillScope
97
113
  * - Literal scalar: `description: |\n multi\n line` → "multi\nline"
98
114
  */
99
115
  export declare function parseSkillFrontmatter(content: string): Partial<SkillMeta>;
116
+ import type { AgentNativeInstructionsConfig } from "../config.js";
100
117
  /**
101
118
  * Paths to a workspace-core's agent resources, for merging into a template's
102
119
  * bundle. All fields optional — pass null for any missing piece.
@@ -117,7 +134,7 @@ export interface WorkspaceAgentsSource {
117
134
  *
118
135
  * Synchronous — the Vite plugin's load hook calls it inline during the build.
119
136
  */
120
- export declare function readAgentsBundleFromFs(cwd: string, workspaceSource?: WorkspaceAgentsSource | null): AgentsBundle;
137
+ export declare function readAgentsBundleFromFs(cwd: string, workspaceSource?: WorkspaceAgentsSource | null, options?: AgentsBundleReadOptions): AgentsBundle;
121
138
  /**
122
139
  * Load the agents bundle. Returns a cached result on subsequent calls.
123
140
  * Tries the virtual module first (works everywhere, including edge), then
@@ -15,12 +15,19 @@
15
15
  * 2. Filesystem fallback — `process.cwd()/AGENTS.md` +
16
16
  * `process.cwd()/.agents/skills/` (or legacy `.agent/skills/`). Only reliable in local dev and Node
17
17
  * production (`agent-native start`); not on Netlify/Vercel/CF at runtime.
18
- * 3. Empty bundle — everything silently returns empty strings.
18
+ * 3. Configuration and filesystem failures propagate so a broken bundle is
19
+ * visible instead of being mistaken for an app with no instructions.
19
20
  *
20
21
  * Result is cached in module scope so it's only computed once per cold start.
21
22
  */
22
23
  export const DEFAULT_SKILL_SCOPE = "both";
23
- const EMPTY = { agentsMd: "", workspaceAgentsMd: "", skills: {} };
24
+ const DEFAULT_AGENT_INSTRUCTIONS_PATH = "AGENTS.md";
25
+ export function resolveAgentInstructionPaths(instructions) {
26
+ return {
27
+ runtime: instructions?.runtime ?? DEFAULT_AGENT_INSTRUCTIONS_PATH,
28
+ development: instructions?.development ?? DEFAULT_AGENT_INSTRUCTIONS_PATH,
29
+ };
30
+ }
24
31
  let cached = null;
25
32
  /**
26
33
  * Coerce a raw frontmatter `scope` value into a known `SkillScope`. Unknown,
@@ -125,6 +132,23 @@ const READABLE_SUBFILE_EXTENSIONS = new Set([".md", ".txt", ".json"]);
125
132
  */
126
133
  const MAX_SUBFILE_BYTES = 64 * 1024;
127
134
  const MAX_SKILL_FILES_BYTES = 256 * 1024;
135
+ function readInstructionFile(cwd, relativePath) {
136
+ const normalizedPath = relativePath.replaceAll("\\", "/");
137
+ const root = fs.realpathSync(path.resolve(cwd));
138
+ const absolutePath = path.resolve(root, normalizedPath);
139
+ if (absolutePath !== root && !absolutePath.startsWith(`${root}${path.sep}`)) {
140
+ throw new Error(`Agent instruction path must stay inside the app root: ${relativePath}`);
141
+ }
142
+ if (!fs.existsSync(absolutePath))
143
+ return "";
144
+ const realPath = fs.realpathSync(absolutePath);
145
+ if (realPath !== root && !realPath.startsWith(`${root}${path.sep}`)) {
146
+ throw new Error(`Agent instruction path must stay inside the app root: ${relativePath}`);
147
+ }
148
+ if (!fs.statSync(realPath).isFile())
149
+ return "";
150
+ return fs.readFileSync(realPath, "utf-8");
151
+ }
128
152
  /**
129
153
  * Read one skills directory into a `Record<string, Skill>`. Extracted so
130
154
  * both the template and workspace-core paths can reuse it. `dirPrefix` is
@@ -214,15 +238,10 @@ function readSkillsDir(skillsDir, rootForRelative, out, skipExistingNames) {
214
238
  *
215
239
  * Synchronous — the Vite plugin's load hook calls it inline during the build.
216
240
  */
217
- export function readAgentsBundleFromFs(cwd, workspaceSource = null) {
218
- let agentsMd = "";
219
- try {
220
- const agentsMdPath = path.join(cwd, "AGENTS.md");
221
- if (fs.existsSync(agentsMdPath)) {
222
- agentsMd = fs.readFileSync(agentsMdPath, "utf-8");
223
- }
224
- }
225
- catch { }
241
+ export function readAgentsBundleFromFs(cwd, workspaceSource = null, options = {}) {
242
+ const instructionPaths = resolveAgentInstructionPaths(options.instructions);
243
+ const runtimeAgentsMd = readInstructionFile(cwd, instructionPaths.runtime);
244
+ const developmentAgentsMd = readInstructionFile(cwd, instructionPaths.development);
226
245
  let workspaceAgentsMd = "";
227
246
  if (workspaceSource?.agentsMdPath) {
228
247
  try {
@@ -249,7 +268,15 @@ export function readAgentsBundleFromFs(cwd, workspaceSource = null) {
249
268
  }
250
269
  catch { }
251
270
  }
252
- return { agentsMd, workspaceAgentsMd, skills };
271
+ return {
272
+ // Keep the old field useful for callers that only know about the runtime
273
+ // bundle. Audience-aware consumers should use the explicit fields.
274
+ agentsMd: runtimeAgentsMd,
275
+ runtimeAgentsMd,
276
+ developmentAgentsMd,
277
+ workspaceAgentsMd,
278
+ skills,
279
+ };
253
280
  }
254
281
  /**
255
282
  * Load the agents bundle. Returns a cached result on subsequent calls.
@@ -279,29 +306,29 @@ export async function loadAgentsBundle() {
279
306
  }
280
307
  // 2. Filesystem fallback — works in dev / Node prod. If a workspace core
281
308
  // is present in the ancestor chain, merge its skills + AGENTS.md in.
309
+ let workspaceSource = null;
282
310
  try {
283
- let workspaceSource = null;
284
- try {
285
- const { getWorkspaceCoreExports } = await import("../deploy/workspace-core.js");
286
- const ws = await getWorkspaceCoreExports(process.cwd());
287
- if (ws) {
288
- workspaceSource = {
289
- skillsDir: ws.skillsDir,
290
- agentsMdPath: ws.agentsMdPath,
291
- rootDir: ws.packageDir,
292
- };
293
- }
294
- }
295
- catch {
296
- // workspace-core discovery isn't available (e.g. edge runtime).
311
+ const { getWorkspaceCoreExports } = await import("../deploy/workspace-core.js");
312
+ const ws = await getWorkspaceCoreExports(process.cwd());
313
+ if (ws) {
314
+ workspaceSource = {
315
+ skillsDir: ws.skillsDir,
316
+ agentsMdPath: ws.agentsMdPath,
317
+ rootDir: ws.packageDir,
318
+ };
297
319
  }
298
- cached = readAgentsBundleFromFs(process.cwd(), workspaceSource);
299
- return cached;
320
+ // coercion-ok: workspace-core discovery is optional in edge runtimes.
300
321
  }
301
322
  catch {
302
- cached = EMPTY;
303
- return cached;
323
+ // workspace-core discovery isn't available (e.g. edge runtime).
304
324
  }
325
+ const { createAgentNativeConfigContext, loadResolvedAgentNativeConfig } = await import("../vite/agent-native-config-loader.js");
326
+ const production = process.env.NODE_ENV === "production";
327
+ const config = await loadResolvedAgentNativeConfig(process.cwd(), createAgentNativeConfigContext(production ? "build" : "serve", production ? "production" : "development"));
328
+ cached = readAgentsBundleFromFs(process.cwd(), workspaceSource, {
329
+ instructions: config.instructions,
330
+ });
331
+ return cached;
305
332
  }
306
333
  /**
307
334
  * Generate the `<skills>` block to inject into the system prompt.
@@ -16,7 +16,7 @@ import { pgTable, text as pgText, timestamp as pgTimestamp, boolean as pgBoolean
16
16
  import { sqliteTable, text as sqliteText, integer as sqliteInteger, } from "drizzle-orm/sqlite-core";
17
17
  import { TEMPLATES } from "../cli/templates-meta.js";
18
18
  import { getDbExec, isPostgres } from "../db/client.js";
19
- import { getDialect, getDatabaseUrl, getDatabaseAuthToken, closePgliteClients, getPgliteClient, isPgliteUrl, loadPgliteDrizzle, pgPoolOptions, neonPoolOptions, attachNeonPoolErrorLogger, sharedDbPool, onSharedDbPoolsClosed, onSharedDbPoolReplaced, } from "../db/client.js";
19
+ import { getDialect, getDatabaseUrl, getDatabaseAuthToken, closePgliteClients, getPgliteClient, isPgliteUrl, loadPgliteDrizzle, pgPoolOptions, neonPoolOptions, guardNeonPool, sharedDbPool, onSharedDbPoolsClosed, onSharedDbPoolReplaced, } from "../db/client.js";
20
20
  import { CORE_RESET_PASSWORD_EMAIL_ID, CORE_VERIFY_SIGNUP_EMAIL_ID, } from "../email-catalog/system-emails.js";
21
21
  import { saveOAuthTokens } from "../oauth-tokens/store.js";
22
22
  import { acceptPendingInvitationsForEmail } from "../org/accept-pending.js";
@@ -1151,7 +1151,7 @@ async function buildDatabaseConfig(dialect) {
1151
1151
  // connections reached" across concurrent serverless instances.
1152
1152
  resetAuthOnPoolClose("neon", url);
1153
1153
  _neonAuthPool = sharedDbPool("neon", url, () => new Pool({ connectionString: url, ...neonPoolOptions() }));
1154
- attachNeonPoolErrorLogger(_neonAuthPool, "db/neon-auth");
1154
+ guardNeonPool(_neonAuthPool, url, "db/neon-auth");
1155
1155
  const { drizzle } = await import("drizzle-orm/neon-serverless");
1156
1156
  const db = drizzle(buildResilientNeonPool(_neonAuthPool), {
1157
1157
  schema: pgAuthSchema,
@@ -98,7 +98,7 @@ export function buildRuntimeConfigPrompt(report, appName) {
98
98
  "Detected issues:",
99
99
  issueLines || "- No issues were reported.",
100
100
  "",
101
- "Inspect the app's agent-native.json or agent-native.ts, its deployment configuration, and the framework defaults. Make the smallest safe fix. Keep secrets out of source control. Do not print secret values in your response. Tell me exactly which deploy settings still need to be set, then verify the production build and runtime health check.",
101
+ "Inspect the app's agent-native.json or agent-native.config.ts (including compatibility aliases), its deployment configuration, and the framework defaults. Make the smallest safe fix. Keep secrets out of source control. Do not print secret values in your response. Tell me exactly which deploy settings still need to be set, then verify the production build and runtime health check.",
102
102
  ].join("\n");
103
103
  }
104
104
  export function getRuntimeConfigReport(env, requirements = {}, options = {}) {
@@ -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