@agent-native/core 0.84.1 → 0.84.3

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 (100) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/core/CHANGELOG.md +15 -0
  3. package/corpus/core/docs/design/durable-agent-runs.md +34 -35
  4. package/corpus/core/package.json +1 -1
  5. package/corpus/core/src/agent/engine/builder-engine.ts +81 -9
  6. package/corpus/core/src/agent/production-agent.ts +9 -2
  7. package/corpus/core/src/agent/run-loop-with-resume.ts +38 -8
  8. package/corpus/core/src/agent/run-manager.ts +8 -7
  9. package/corpus/core/src/agent/thread-data-builder.ts +6 -0
  10. package/corpus/core/src/cli/design-connect.ts +175 -0
  11. package/corpus/core/src/cli/skills.ts +5 -7
  12. package/corpus/core/src/client/AgentPanel.tsx +8 -0
  13. package/corpus/core/src/client/MultiTabAssistantChat.tsx +4 -1
  14. package/corpus/core/src/client/agent-chat-adapter.ts +253 -24
  15. package/corpus/core/src/client/sharing/ShareButton.tsx +70 -21
  16. package/corpus/core/src/client/sse-event-processor.ts +46 -4
  17. package/corpus/core/src/templates/workspace-core/.agents/skills/reliable-mutations/SKILL.md +15 -17
  18. package/corpus/templates/analytics/AGENTS.md +1 -1
  19. package/corpus/templates/design/actions/apply-motion-edit.ts +50 -18
  20. package/corpus/templates/design/actions/get-motion-timeline.ts +4 -14
  21. package/corpus/templates/design/app/components/design/DesignCanvas.tsx +156 -12
  22. package/corpus/templates/design/app/components/design/MotionDock.tsx +2 -3
  23. package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +217 -75
  24. package/corpus/templates/design/app/components/design/QuestionFlow.tsx +39 -39
  25. package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +558 -37
  26. package/corpus/templates/design/app/components/design/bridge/hit-test.bridge.ts +75 -3
  27. package/corpus/templates/design/app/components/design/types.ts +13 -0
  28. package/corpus/templates/design/app/components/layout/Layout.tsx +1 -0
  29. package/corpus/templates/design/app/i18n/zh-TW.ts +17 -0
  30. package/corpus/templates/design/app/i18n-data.ts +245 -0
  31. package/corpus/templates/design/app/pages/DesignEditor.tsx +890 -252
  32. package/corpus/templates/design/changelog/2026-06-30-agent-chat-now-reports-saved-design-generations-clearly-when.md +6 -0
  33. package/corpus/templates/design/changelog/2026-06-30-apply-styles-now-appears-only-for-localhost-visual-edit-scre.md +6 -0
  34. package/corpus/templates/design/changelog/2026-06-30-copying-or-dragging-screen-elements-onto-the-infinite-canvas.md +6 -0
  35. package/corpus/templates/design/changelog/2026-06-30-design-questions-now-use-tighter-editor-typography-and-contr.md +6 -0
  36. package/corpus/templates/design/changelog/2026-06-30-element-drags-can-be-cancelled-with-escape-before-they-commi.md +6 -0
  37. package/corpus/templates/design/changelog/2026-06-30-pending-visual-style-edits-now-warn-before-you-leave-the-edi.md +6 -0
  38. package/corpus/templates/design/changelog/2026-06-30-share-options-now-make-export-and-agent-handoff-easier-to-no.md +6 -0
  39. package/corpus/templates/design/changelog/2026-06-30-visual-style-drags-stay-live-while-pending-edits-can-be-appl.md +6 -0
  40. package/corpus/templates/design/changelog/2026-07-01-design-chat-no-longer-shows-a-redundant-context-tab-above-the-composer.md +6 -0
  41. package/corpus/templates/design/changelog/2026-07-01-motion-track-creation-no-longer-fails-in-local-editors.md +6 -0
  42. package/corpus/templates/design/changelog/2026-07-01-share-general-access-menu-stays-open-when-choosing-organization.md +6 -0
  43. package/corpus/templates/design/server/plugins/db.ts +10 -0
  44. package/dist/agent/engine/builder-engine.d.ts.map +1 -1
  45. package/dist/agent/engine/builder-engine.js +61 -10
  46. package/dist/agent/engine/builder-engine.js.map +1 -1
  47. package/dist/agent/production-agent.d.ts.map +1 -1
  48. package/dist/agent/production-agent.js +9 -2
  49. package/dist/agent/production-agent.js.map +1 -1
  50. package/dist/agent/run-loop-with-resume.d.ts +2 -2
  51. package/dist/agent/run-loop-with-resume.d.ts.map +1 -1
  52. package/dist/agent/run-loop-with-resume.js +31 -8
  53. package/dist/agent/run-loop-with-resume.js.map +1 -1
  54. package/dist/agent/run-manager.d.ts +8 -7
  55. package/dist/agent/run-manager.d.ts.map +1 -1
  56. package/dist/agent/run-manager.js +8 -7
  57. package/dist/agent/run-manager.js.map +1 -1
  58. package/dist/agent/thread-data-builder.d.ts +2 -0
  59. package/dist/agent/thread-data-builder.d.ts.map +1 -1
  60. package/dist/agent/thread-data-builder.js +5 -0
  61. package/dist/agent/thread-data-builder.js.map +1 -1
  62. package/dist/cli/design-connect.d.ts +2 -0
  63. package/dist/cli/design-connect.d.ts.map +1 -1
  64. package/dist/cli/design-connect.js +140 -0
  65. package/dist/cli/design-connect.js.map +1 -1
  66. package/dist/cli/skills.d.ts.map +1 -1
  67. package/dist/cli/skills.js +5 -7
  68. package/dist/cli/skills.js.map +1 -1
  69. package/dist/client/AgentPanel.d.ts +5 -1
  70. package/dist/client/AgentPanel.d.ts.map +1 -1
  71. package/dist/client/AgentPanel.js +4 -4
  72. package/dist/client/AgentPanel.js.map +1 -1
  73. package/dist/client/MultiTabAssistantChat.d.ts +3 -1
  74. package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
  75. package/dist/client/MultiTabAssistantChat.js +2 -2
  76. package/dist/client/MultiTabAssistantChat.js.map +1 -1
  77. package/dist/client/agent-chat-adapter.d.ts.map +1 -1
  78. package/dist/client/agent-chat-adapter.js +216 -22
  79. package/dist/client/agent-chat-adapter.js.map +1 -1
  80. package/dist/client/sharing/ShareButton.d.ts +6 -0
  81. package/dist/client/sharing/ShareButton.d.ts.map +1 -1
  82. package/dist/client/sharing/ShareButton.js +25 -11
  83. package/dist/client/sharing/ShareButton.js.map +1 -1
  84. package/dist/client/sse-event-processor.d.ts +18 -1
  85. package/dist/client/sse-event-processor.d.ts.map +1 -1
  86. package/dist/client/sse-event-processor.js +34 -5
  87. package/dist/client/sse-event-processor.js.map +1 -1
  88. package/dist/collab/awareness.d.ts +2 -2
  89. package/dist/collab/awareness.d.ts.map +1 -1
  90. package/dist/collab/routes.d.ts +2 -2
  91. package/dist/file-upload/actions/upload-image.d.ts +2 -2
  92. package/dist/notifications/routes.d.ts +3 -3
  93. package/dist/observability/routes.d.ts +7 -7
  94. package/dist/resources/handlers.d.ts +2 -2
  95. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  96. package/dist/server/transcribe-voice.d.ts +1 -1
  97. package/dist/templates/workspace-core/.agents/skills/reliable-mutations/SKILL.md +15 -17
  98. package/docs/design/durable-agent-runs.md +34 -35
  99. package/package.json +1 -1
  100. package/src/templates/workspace-core/.agents/skills/reliable-mutations/SKILL.md +15 -17
@@ -1,3 +1,4 @@
1
+ import { spawn } from "node:child_process";
1
2
  import crypto from "node:crypto";
2
3
  import fsSync from "node:fs";
3
4
  import fs from "node:fs/promises";
@@ -44,6 +45,7 @@ export interface DesignConnectArgs {
44
45
  json: boolean;
45
46
  once: boolean;
46
47
  dryRun: boolean;
48
+ daemon: boolean;
47
49
  help: boolean;
48
50
  }
49
51
 
@@ -115,6 +117,7 @@ export function parseDesignConnectArgs(argv: string[]): DesignConnectArgs {
115
117
  json: false,
116
118
  once: false,
117
119
  dryRun: false,
120
+ daemon: false,
118
121
  help: false,
119
122
  };
120
123
 
@@ -155,6 +158,8 @@ export function parseDesignConnectArgs(argv: string[]): DesignConnectArgs {
155
158
  } else if (arg === "--dry-run") {
156
159
  parsed.dryRun = true;
157
160
  parsed.once = true;
161
+ } else if (arg === "--daemon") {
162
+ parsed.daemon = true;
158
163
  } else if (arg.startsWith("-")) {
159
164
  throw new Error(`Unknown option: ${arg}`);
160
165
  } else {
@@ -165,6 +170,11 @@ export function parseDesignConnectArgs(argv: string[]): DesignConnectArgs {
165
170
  if (!Number.isInteger(parsed.port) || parsed.port <= 0) {
166
171
  throw new Error("--port must be a positive integer");
167
172
  }
173
+ if (parsed.daemon && (parsed.json || parsed.once || parsed.dryRun)) {
174
+ throw new Error(
175
+ "--daemon cannot be combined with --json, --once, or --dry-run",
176
+ );
177
+ }
168
178
  parsed.root = path.resolve(parsed.root);
169
179
  parsed.url = parsed.url ? normalizeHttpUrl(parsed.url) : undefined;
170
180
  return parsed;
@@ -298,6 +308,86 @@ async function probeDevServer(url: string): Promise<boolean> {
298
308
  }
299
309
  }
300
310
 
311
+ async function waitForBridgeHealth(
312
+ bridgeUrl: string,
313
+ timeoutMs = 5_000,
314
+ ): Promise<boolean> {
315
+ const healthUrl = new URL("/health", bridgeUrl).toString();
316
+ const deadline = Date.now() + timeoutMs;
317
+ while (Date.now() < deadline) {
318
+ const controller = new AbortController();
319
+ const timeout = setTimeout(() => controller.abort(), 400);
320
+ try {
321
+ const response = await fetch(healthUrl, {
322
+ method: "GET",
323
+ signal: controller.signal,
324
+ });
325
+ if (response.ok) return true;
326
+ } catch {
327
+ // Keep polling until the detached process finishes binding the port.
328
+ } finally {
329
+ clearTimeout(timeout);
330
+ }
331
+ await new Promise((resolve) => setTimeout(resolve, 150));
332
+ }
333
+ return false;
334
+ }
335
+
336
+ function isDesignConnectManifest(
337
+ value: unknown,
338
+ ): value is DesignConnectManifest {
339
+ if (!value || typeof value !== "object") return false;
340
+ const manifest = value as Partial<DesignConnectManifest>;
341
+ return (
342
+ manifest.version === 1 &&
343
+ manifest.source === "agent-native-design-connect" &&
344
+ manifest.sourceType === "localhost" &&
345
+ manifest.localOnly === true &&
346
+ typeof manifest.devServerUrl === "string" &&
347
+ typeof manifest.bridgeUrl === "string" &&
348
+ typeof manifest.rootPath === "string"
349
+ );
350
+ }
351
+
352
+ async function fetchRunningBridgeManifest(
353
+ bridgeUrl: string,
354
+ ): Promise<DesignConnectManifest | null> {
355
+ const manifestUrl = new URL("/manifest.json", bridgeUrl).toString();
356
+ const controller = new AbortController();
357
+ const timeout = setTimeout(() => controller.abort(), 800);
358
+ try {
359
+ const response = await fetch(manifestUrl, {
360
+ method: "GET",
361
+ signal: controller.signal,
362
+ });
363
+ if (!response.ok) return null;
364
+ const body = (await response.json()) as unknown;
365
+ return isDesignConnectManifest(body) ? body : null;
366
+ } catch {
367
+ return null;
368
+ } finally {
369
+ clearTimeout(timeout);
370
+ }
371
+ }
372
+
373
+ export function designConnectManifestsTargetSameApp(
374
+ running: Pick<DesignConnectManifest, "devServerUrl" | "rootPath">,
375
+ requested: Pick<DesignConnectManifest, "devServerUrl" | "rootPath">,
376
+ ): boolean {
377
+ let runningUrl = running.devServerUrl;
378
+ let requestedUrl = requested.devServerUrl;
379
+ try {
380
+ runningUrl = normalizeHttpUrl(runningUrl);
381
+ requestedUrl = normalizeHttpUrl(requestedUrl);
382
+ } catch {
383
+ // Fall through to direct string comparison for malformed legacy manifests.
384
+ }
385
+ return (
386
+ runningUrl === requestedUrl &&
387
+ path.resolve(running.rootPath) === path.resolve(requested.rootPath)
388
+ );
389
+ }
390
+
301
391
  async function resolveDevServerUrl(url?: string): Promise<string> {
302
392
  if (url) return normalizeHttpUrl(url);
303
393
  for (const candidate of DEFAULT_DEV_SERVER_CANDIDATES) {
@@ -942,6 +1032,7 @@ Options:
942
1032
  --route-manifest <path> Non-destructive route manifest output path
943
1033
  --app-url <url> Deployed design app URL for self-registration
944
1034
  (also reads AGENT_NATIVE_URL / DESIGN_APP_URL env)
1035
+ --daemon Start the bridge detached, wait for /health, then exit
945
1036
  --json Print the manifest JSON and exit
946
1037
  --once Prepare/scaffold the manifest and exit
947
1038
  --dry-run Print what would be exposed without writing files
@@ -966,6 +1057,87 @@ Element provenance (resolveNodeToFile):
966
1057
  Cross-origin localhost iframes cannot be read regardless of attributes (CSP).`);
967
1058
  }
968
1059
 
1060
+ function removeDaemonFlag(argv: string[]): string[] {
1061
+ return argv.filter((arg) => arg !== "--daemon");
1062
+ }
1063
+
1064
+ function resolveCurrentCliInvocation(argv: string[]): {
1065
+ command: string;
1066
+ args: string[];
1067
+ } {
1068
+ const suffixLength = argv.length + 1; // leading "design" command + runDesign argv
1069
+ const prefixEnd = Math.max(1, process.argv.length - suffixLength);
1070
+ const cliPrefix = process.argv.slice(1, prefixEnd);
1071
+ const entry = cliPrefix[0] ?? process.argv[1];
1072
+ if (!entry) {
1073
+ throw new Error("Could not resolve current CLI entrypoint for --daemon");
1074
+ }
1075
+ if (entry.endsWith(".ts") || entry.endsWith(".tsx")) {
1076
+ return {
1077
+ command: "tsx",
1078
+ args: [...cliPrefix, "design", ...removeDaemonFlag(argv)],
1079
+ };
1080
+ }
1081
+ return {
1082
+ command: process.execPath,
1083
+ args: [...cliPrefix, "design", ...removeDaemonFlag(argv)],
1084
+ };
1085
+ }
1086
+
1087
+ async function startDetachedDesignBridge(
1088
+ argv: string[],
1089
+ manifest: DesignConnectManifest,
1090
+ ): Promise<number> {
1091
+ if (await waitForBridgeHealth(manifest.bridgeUrl, 800)) {
1092
+ const runningManifest = await fetchRunningBridgeManifest(
1093
+ manifest.bridgeUrl,
1094
+ );
1095
+ if (
1096
+ runningManifest &&
1097
+ designConnectManifestsTargetSameApp(runningManifest, manifest)
1098
+ ) {
1099
+ console.error(
1100
+ `Design localhost bridge already running at ${manifest.bridgeUrl}`,
1101
+ );
1102
+ console.log(JSON.stringify(runningManifest, null, 2));
1103
+ return 0;
1104
+ }
1105
+
1106
+ console.error(
1107
+ [
1108
+ `Design localhost bridge already running at ${manifest.bridgeUrl} for a different app.`,
1109
+ runningManifest
1110
+ ? `Running app: ${runningManifest.devServerUrl} (${runningManifest.rootPath})`
1111
+ : "Running bridge did not expose a compatible manifest.",
1112
+ `Requested app: ${manifest.devServerUrl} (${manifest.rootPath})`,
1113
+ "Stop the existing bridge or choose a different --port.",
1114
+ ].join("\n"),
1115
+ );
1116
+ return 1;
1117
+ }
1118
+
1119
+ const invocation = resolveCurrentCliInvocation(argv);
1120
+ const child = spawn(invocation.command, invocation.args, {
1121
+ cwd: process.cwd(),
1122
+ detached: true,
1123
+ env: process.env,
1124
+ stdio: "ignore",
1125
+ shell: process.platform === "win32",
1126
+ });
1127
+ child.unref();
1128
+
1129
+ if (await waitForBridgeHealth(manifest.bridgeUrl)) {
1130
+ console.error(`Design localhost bridge running at ${manifest.bridgeUrl}`);
1131
+ console.log(JSON.stringify(manifest, null, 2));
1132
+ return 0;
1133
+ }
1134
+
1135
+ console.error(
1136
+ `Timed out waiting for detached Design bridge at ${manifest.bridgeUrl}`,
1137
+ );
1138
+ return 1;
1139
+ }
1140
+
969
1141
  export async function runDesign(argv: string[]) {
970
1142
  const subcommand = argv[0];
971
1143
  if (subcommand !== "connect") {
@@ -988,6 +1160,9 @@ export async function runDesign(argv: string[]) {
988
1160
  }
989
1161
 
990
1162
  const manifest = await prepareDesignConnectManifest(parsed);
1163
+ if (parsed.daemon) {
1164
+ return startDetachedDesignBridge(argv, manifest);
1165
+ }
991
1166
  if (parsed.json || parsed.once || parsed.dryRun) {
992
1167
  console.log(JSON.stringify(manifest, null, 2));
993
1168
  return 0;
@@ -464,18 +464,16 @@ iframe-backed screens on the infinite canvas.
464
464
  From the target app repo, make sure its dev server is running, then run:
465
465
 
466
466
  \`\`\`bash
467
- npx @agent-native/core@latest design connect --url http://localhost:5173 --root .
467
+ npx @agent-native/core@latest design connect --url http://localhost:5173 --root . --daemon
468
468
  \`\`\`
469
469
 
470
- Use the app's real port. The command starts a local bridge on
471
- \`http://127.0.0.1:7331\` by default and exposes \`/manifest.json\`,
472
- \`/routes.json\`, and \`/health\`.
470
+ Use the app's real port. The command starts a detached local bridge on
471
+ \`http://127.0.0.1:7331\` by default, waits for \`/health\`, prints the
472
+ manifest JSON, and keeps the bridge alive after the agent command exits.
473
473
 
474
- For one-shot agent setup, ask for JSON and keep the long-running bridge open in
475
- a second terminal if the user needs live updates:
474
+ For a manual health/manifest check:
476
475
 
477
476
  \`\`\`bash
478
- npx @agent-native/core@latest design connect --url http://localhost:5173 --root .
479
477
  curl http://127.0.0.1:7331/manifest.json
480
478
  \`\`\`
481
479
 
@@ -548,6 +548,8 @@ export interface AgentPanelProps extends Omit<
548
548
  * see the `Layout` files for each template.
549
549
  */
550
550
  scope?: import("./use-chat-threads.js").ChatThreadScope | null;
551
+ /** Show the compact scope chip above the composer. Default: true. */
552
+ showScopeBadge?: MultiTabAssistantChatProps["showScopeBadge"];
551
553
  /** Stable browser tab id used for tab-scoped app-state context. */
552
554
  browserTabId?: string;
553
555
  /** Keep chat thread selection in URL state. */
@@ -673,6 +675,7 @@ function AgentPanelInner({
673
675
  storageKey,
674
676
  restoreActiveThread = true,
675
677
  scope,
678
+ showScopeBadge,
676
679
  browserTabId,
677
680
  threadUrlSync,
678
681
  chatNotice,
@@ -1710,6 +1713,7 @@ function AgentPanelInner({
1710
1713
  storageKey={storageKey}
1711
1714
  restoreActiveThread={restoreActiveThread}
1712
1715
  scope={scope}
1716
+ showScopeBadge={showScopeBadge}
1713
1717
  browserTabId={browserTabId}
1714
1718
  threadUrlSync={threadUrlSync}
1715
1719
  />
@@ -2393,6 +2397,8 @@ export interface AgentSidebarProps {
2393
2397
  * Templates compute this from the active route (see template layouts).
2394
2398
  */
2395
2399
  scope?: import("./use-chat-threads.js").ChatThreadScope | null;
2400
+ /** Show the compact scope chip above the composer. Default: true. */
2401
+ showScopeBadge?: MultiTabAssistantChatProps["showScopeBadge"];
2396
2402
  /** Stable browser tab id used for tab-scoped app-state context. */
2397
2403
  browserTabId?: string;
2398
2404
  /** Keep chat thread selection in URL state. */
@@ -2422,6 +2428,7 @@ export function AgentSidebar({
2422
2428
  openOnChatRunning = false,
2423
2429
  onFullscreenRequest,
2424
2430
  scope,
2431
+ showScopeBadge,
2425
2432
  browserTabId,
2426
2433
  threadUrlSync,
2427
2434
  }: AgentSidebarProps) {
@@ -2955,6 +2962,7 @@ export function AgentSidebar({
2955
2962
  }
2956
2963
  storageKey={storageKey}
2957
2964
  scope={scope}
2965
+ showScopeBadge={showScopeBadge}
2958
2966
  browserTabId={browserTabId}
2959
2967
  threadUrlSync={threadUrlSync}
2960
2968
  />
@@ -929,6 +929,8 @@ export type MultiTabAssistantChatProps = Omit<
929
929
  * the composer.
930
930
  */
931
931
  scope?: ChatThreadScope | null;
932
+ /** Show the compact scope chip above the composer. Default: true. */
933
+ showScopeBadge?: boolean;
932
934
  };
933
935
 
934
936
  export function MultiTabAssistantChat({
@@ -942,6 +944,7 @@ export function MultiTabAssistantChat({
942
944
  browserTabId,
943
945
  threadUrlSync = false,
944
946
  scope = null,
947
+ showScopeBadge = true,
945
948
  ...props
946
949
  }: MultiTabAssistantChatProps) {
947
950
  const {
@@ -2625,7 +2628,7 @@ export function MultiTabAssistantChat({
2625
2628
  ? props.dynamicSuggestions
2626
2629
  : false;
2627
2630
  const scopeComposerSlot =
2628
- tabId === activeThreadId && !contentHidden ? (
2631
+ showScopeBadge && tabId === activeThreadId && !contentHidden ? (
2629
2632
  tabScope && activeThreadId ? (
2630
2633
  <ScopeBadge
2631
2634
  scope={tabScope}