@agent-native/core 0.12.20 → 0.12.22

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 (81) hide show
  1. package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
  2. package/dist/agent/engine/ai-sdk-engine.js +7 -3
  3. package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
  4. package/dist/agent/production-agent.d.ts +1 -1
  5. package/dist/agent/production-agent.d.ts.map +1 -1
  6. package/dist/agent/production-agent.js +1 -1
  7. package/dist/agent/production-agent.js.map +1 -1
  8. package/dist/agent/run-manager.d.ts.map +1 -1
  9. package/dist/agent/run-manager.js +36 -0
  10. package/dist/agent/run-manager.js.map +1 -1
  11. package/dist/checkpoints/service.d.ts +1 -0
  12. package/dist/checkpoints/service.d.ts.map +1 -1
  13. package/dist/checkpoints/service.js +6 -3
  14. package/dist/checkpoints/service.js.map +1 -1
  15. package/dist/cli/workspace-dev.d.ts +1 -0
  16. package/dist/cli/workspace-dev.d.ts.map +1 -1
  17. package/dist/cli/workspace-dev.js +14 -0
  18. package/dist/cli/workspace-dev.js.map +1 -1
  19. package/dist/client/AgentPanel.d.ts +1 -1
  20. package/dist/client/AgentPanel.d.ts.map +1 -1
  21. package/dist/client/AgentPanel.js +1 -11
  22. package/dist/client/AgentPanel.js.map +1 -1
  23. package/dist/client/AssistantChat.d.ts.map +1 -1
  24. package/dist/client/AssistantChat.js +16 -1
  25. package/dist/client/AssistantChat.js.map +1 -1
  26. package/dist/client/agent-chat-adapter.d.ts.map +1 -1
  27. package/dist/client/agent-chat-adapter.js +70 -2
  28. package/dist/client/agent-chat-adapter.js.map +1 -1
  29. package/dist/client/agent-chat.d.ts +5 -0
  30. package/dist/client/agent-chat.d.ts.map +1 -1
  31. package/dist/client/agent-chat.js.map +1 -1
  32. package/dist/client/analytics.d.ts +7 -0
  33. package/dist/client/analytics.d.ts.map +1 -1
  34. package/dist/client/analytics.js +9 -0
  35. package/dist/client/analytics.js.map +1 -1
  36. package/dist/client/composer/ComposerPlusMenu.d.ts.map +1 -1
  37. package/dist/client/composer/ComposerPlusMenu.js +2 -2
  38. package/dist/client/composer/ComposerPlusMenu.js.map +1 -1
  39. package/dist/client/composer/PromptComposer.d.ts +10 -4
  40. package/dist/client/composer/PromptComposer.d.ts.map +1 -1
  41. package/dist/client/composer/PromptComposer.js +15 -5
  42. package/dist/client/composer/PromptComposer.js.map +1 -1
  43. package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
  44. package/dist/client/composer/TiptapComposer.js +2 -2
  45. package/dist/client/composer/TiptapComposer.js.map +1 -1
  46. package/dist/client/composer/index.d.ts +1 -1
  47. package/dist/client/composer/index.d.ts.map +1 -1
  48. package/dist/client/composer/index.js.map +1 -1
  49. package/dist/client/composer/useVoiceDictation.d.ts +1 -0
  50. package/dist/client/composer/useVoiceDictation.d.ts.map +1 -1
  51. package/dist/client/composer/useVoiceDictation.js +52 -7
  52. package/dist/client/composer/useVoiceDictation.js.map +1 -1
  53. package/dist/client/index.d.ts +2 -2
  54. package/dist/client/index.d.ts.map +1 -1
  55. package/dist/client/index.js +1 -1
  56. package/dist/client/index.js.map +1 -1
  57. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  58. package/dist/server/agent-chat-plugin.js +52 -12
  59. package/dist/server/agent-chat-plugin.js.map +1 -1
  60. package/dist/server/capture-error.d.ts +30 -0
  61. package/dist/server/capture-error.d.ts.map +1 -0
  62. package/dist/server/capture-error.js +37 -0
  63. package/dist/server/capture-error.js.map +1 -0
  64. package/dist/server/google-auth-plugin.d.ts.map +1 -1
  65. package/dist/server/google-auth-plugin.js +79 -3
  66. package/dist/server/google-auth-plugin.js.map +1 -1
  67. package/dist/server/index.d.ts +1 -0
  68. package/dist/server/index.d.ts.map +1 -1
  69. package/dist/server/index.js +1 -0
  70. package/dist/server/index.js.map +1 -1
  71. package/dist/server/onboarding-html.d.ts.map +1 -1
  72. package/dist/server/onboarding-html.js +78 -3
  73. package/dist/server/onboarding-html.js.map +1 -1
  74. package/dist/server/security-headers.d.ts +5 -4
  75. package/dist/server/security-headers.d.ts.map +1 -1
  76. package/dist/server/security-headers.js +6 -5
  77. package/dist/server/security-headers.js.map +1 -1
  78. package/dist/server/sentry-plugin.d.ts.map +1 -1
  79. package/dist/server/sentry-plugin.js +2 -0
  80. package/dist/server/sentry-plugin.js.map +1 -1
  81. package/package.json +1 -1
@@ -1405,13 +1405,17 @@ The agent and the UI are equal partners — everything the UI can do, you can do
1405
1405
 
1406
1406
  **In production mode, you operate through registered actions exposed as tools.** These are your capabilities — use them to read data, take actions, and help the user. You cannot edit source code or access the filesystem directly. Your tools are the app's API.
1407
1407
 
1408
+ ### Plan Mode
1409
+
1410
+ If the current turn is in Plan mode, plan before anything gets written. This applies to source-code handoffs and to app-created artifacts such as extensions, widgets, dashboards, calculators, mini-apps, documents, designs, slides, or videos. Use only read-only tools, clarify the goal when needed, and return a concrete plan for approval. Do not call \`create-extension\`, \`update-extension\`, \`connect-builder\`, or any action that creates, updates, deletes, sends, publishes, or persists data until the user switches back to Act mode.
1411
+
1408
1412
  ### Extensions (Mini-Apps) — Use \`create-extension\` for extensions / widgets / dashboards
1409
1413
 
1410
- If the user asks you to create, build, or make an **extension**, **widget**, **dashboard**, **calculator**, **mini-app**, or any small self-contained interactive utility — call \`create-extension\` immediately with a self-contained Alpine.js HTML body. This is **NOT** a code change and does **NOT** go through \`connect-builder\`. Extensions are sandboxed mini-apps stored in the database — no source files are touched, no PR is opened, no build is required. The extension appears in the Extensions view and can be edited later via \`update-extension\`.
1414
+ In Act mode, if the user asks you to create, build, or make an **extension**, **widget**, **dashboard**, **calculator**, **mini-app**, or any small self-contained interactive utility — call \`create-extension\` immediately with a self-contained Alpine.js HTML body. This is **NOT** a code change and does **NOT** go through \`connect-builder\`. Extensions are sandboxed mini-apps stored in the database — no source files are touched, no PR is opened, no build is required. The extension appears in the Extensions view and can be edited later via \`update-extension\`.
1411
1415
 
1412
1416
  If the user asks to change, edit, fix, style, rename, or add behavior to an existing extension/widget/dashboard/calculator/mini-app, use \`list-extensions\` and \`update-extension\` for that extension. Existing extension edits are SQL data updates, not source-code changes, even when the request says "change the UI" or "fix this". Do **NOT** call \`connect-builder\` for existing extension edits.
1413
1417
 
1414
- When in doubt — if the request mentions creating an extension, widget, dashboard, calculator, or asks for a new small interactive utility — choose \`create-extension\`. If it references an existing one or the current extension page, choose \`update-extension\`. Do **not** preface the call with planning text like "let me build the dashboard…" — just call the right extension action directly.
1418
+ In Act mode, when in doubt — if the request mentions creating an extension, widget, dashboard, calculator, or asks for a new small interactive utility — choose \`create-extension\`. If it references an existing one or the current extension page, choose \`update-extension\`. Do **not** preface the call with planning text like "let me build the dashboard…" — just call the right extension action directly.
1415
1419
 
1416
1420
  Note: "extension" is the user-facing primitive (the sandboxed Alpine.js mini-app). Don't confuse it with the LLM concept of "tools" (function calls) — those are how you invoke ANY action, including \`create-extension\` itself.
1417
1421
 
@@ -1421,12 +1425,12 @@ For existing extensions, use \`list-extensions\` to find what the user can see,
1421
1425
 
1422
1426
  If the request matches the Extensions section above (extension / widget / dashboard / calculator / mini-app), use \`create-extension\` or \`update-extension\` instead — do NOT route it to \`connect-builder\`.
1423
1427
 
1424
- When the user asks you to change the UI, modify code, add a feature, fix a bug in the app itself, change styles, add a hook, create a component, add a route, add an integration, or anything else that requires editing source files — you MUST take exactly these steps, in order:
1428
+ In Act mode, when the user asks you to change the UI, modify code, add a feature, fix a bug in the app itself, change styles, add a hook, create a component, add a route, add an integration, or anything else that requires editing source files — you MUST take exactly these steps, in order:
1425
1429
 
1426
1430
  1. Call the \`connect-builder\` tool, passing the user's full request verbatim as the \`prompt\` argument. This renders an inline card. If Builder is connected, the card hands the prompt off to Builder's cloud agent on one click and returns a branch URL; otherwise it shows the Connect Builder flow. Either way, Builder writes the code — no local setup, no clone, no install.
1427
1431
  2. After the card renders, write a single short sentence telling the user to click Connect Builder to have this built for them in the cloud, and mention they can also clone the app locally with \`npx agent-native create <app-name>\` if they'd rather work offline.
1428
1432
 
1429
- **Hard rules — do NOT break these:**
1433
+ **Act-mode hard rules — do NOT break these:**
1430
1434
  - Do NOT read source files, list directories, or explore the codebase. You have no filesystem tools and don't need to look at code to recommend Builder.
1431
1435
  - Do NOT write an implementation plan. Do NOT write code in your response. Do NOT describe which files to create or modify. Builder will figure that out in its sandbox.
1432
1436
  - Do NOT save plans, specs, or code to \`resource-write\`. Resources are for app data, not implementation plans the user didn't ask for.
@@ -1468,9 +1472,13 @@ The agent and the UI are equal partners — everything the UI can do, you can do
1468
1472
 
1469
1473
  **In production mode, you operate through registered actions exposed as tools.** These are your capabilities — use them to read data, take actions, and help the user. You cannot edit source code or access the filesystem directly. Your tools are the app's API.
1470
1474
 
1475
+ ### Plan Mode
1476
+
1477
+ If the turn is in Plan mode, plan before anything gets written — including extensions, widgets, dashboards, calculators, mini-apps, documents, designs, slides, videos, and code-change handoffs. Use read-only tools only and do not call \`create-extension\`, \`update-extension\`, \`connect-builder\`, or other write actions until the user switches back to Act mode.
1478
+
1471
1479
  ### Extensions (Mini-Apps) — Use \`create-extension\`
1472
1480
 
1473
- If the user asks for an **extension**, **widget**, **dashboard**, **calculator**, or **mini-app**, call \`create-extension\` immediately with a self-contained Alpine.js HTML body. This is NOT a code change — extensions are sandboxed mini-apps stored in the database. Do not preface with "let me build…" — just call \`create-extension\`.
1481
+ In Act mode, if the user asks for an **extension**, **widget**, **dashboard**, **calculator**, or **mini-app**, call \`create-extension\` immediately with a self-contained Alpine.js HTML body. This is NOT a code change — extensions are sandboxed mini-apps stored in the database. Do not preface with "let me build…" — just call \`create-extension\`.
1474
1482
 
1475
1483
  If the user asks to change, edit, fix, style, rename, or add behavior to an existing extension/widget/dashboard/calculator/mini-app, use \`list-extensions\` and \`update-extension\`. Existing extension edits are SQL data updates, not source-code changes. Do NOT call \`connect-builder\` for them.
1476
1484
 
@@ -1478,7 +1486,7 @@ For existing extensions, use \`list-extensions\`, \`update-extension\`, \`hide-e
1478
1486
 
1479
1487
  ### Code Changes — Call \`connect-builder\`
1480
1488
 
1481
- When the user asks to change the UI, modify code, add a feature, or fix a bug in the app itself — call \`connect-builder\` immediately, passing the user's request as the \`prompt\`. (Extension / widget / dashboard requests use \`create-extension\` or \`update-extension\` instead — see above.) Do NOT write code, list files, make plans, or spawn sub-agents for code changes. Builder handles it in the cloud. Mention \`npx agent-native create <app-name>\` as an offline fallback.
1489
+ In Act mode, when the user asks to change the UI, modify code, add a feature, or fix a bug in the app itself — call \`connect-builder\` immediately, passing the user's request as the \`prompt\`. (Extension / widget / dashboard requests use \`create-extension\` or \`update-extension\` instead — see above.) Do NOT write code, list files, make plans, or spawn sub-agents for code changes. Builder handles it in the cloud. Mention \`npx agent-native create <app-name>\` as an offline fallback.
1482
1490
  ${FRAMEWORK_CORE_COMPACT}`;
1483
1491
  const DEV_FRAMEWORK_PROMPT_COMPACT = `## Agent-Native Framework — Development Mode
1484
1492
 
@@ -2610,11 +2618,28 @@ export function createAgentChatPlugin(options) {
2610
2618
  resolveOrgId: options?.resolveOrgId,
2611
2619
  });
2612
2620
  }
2621
+ const preRunGitStatusByThread = new Map();
2622
+ async function recordPreRunGitStatus(threadId) {
2623
+ if (!isDevMode())
2624
+ return;
2625
+ try {
2626
+ const { getUncommittedStatus, isGitRepo } = await import("../checkpoints/service.js");
2627
+ const cwd = process.cwd();
2628
+ preRunGitStatusByThread.set(threadId, isGitRepo(cwd) ? getUncommittedStatus(cwd) : null);
2629
+ }
2630
+ catch {
2631
+ preRunGitStatusByThread.set(threadId, null);
2632
+ }
2633
+ }
2613
2634
  // Callback to persist agent response when run finishes (even if client disconnected).
2614
2635
  // Reconstructs the assistant message from buffered events and appends to thread_data.
2615
2636
  const onRunComplete = async (run, threadId) => {
2616
- if (!threadId)
2637
+ const runThreadId = String(run?.threadId ?? threadId ?? "");
2638
+ if (!threadId) {
2639
+ if (runThreadId)
2640
+ preRunGitStatusByThread.delete(runThreadId);
2617
2641
  return;
2642
+ }
2618
2643
  // Serialize the read-modify-write against the same thread's other
2619
2644
  // `thread_data` writers (setThreadQueuedMessages, setThreadEngineMeta,
2620
2645
  // the frontend-triggered saves below). Without the lock, a concurrent
@@ -2699,9 +2724,21 @@ export function createAgentChatPlugin(options) {
2699
2724
  // Auto-checkpoint in dev mode after file-modifying agent turns
2700
2725
  if (isDevMode()) {
2701
2726
  try {
2702
- const { createCheckpoint: gitCheckpoint, isGitRepo, hasUncommittedChanges, getChangedFileNames, } = await import("../checkpoints/service.js");
2727
+ const { createCheckpoint: gitCheckpoint, isGitRepo, hasUncommittedChanges, getChangedFileNames, getUncommittedStatus, } = await import("../checkpoints/service.js");
2703
2728
  const cwd = process.cwd();
2704
- if (isGitRepo(cwd) && hasUncommittedChanges(cwd)) {
2729
+ const preRunStatus = runThreadId
2730
+ ? preRunGitStatusByThread.get(runThreadId)
2731
+ : undefined;
2732
+ if (runThreadId)
2733
+ preRunGitStatusByThread.delete(runThreadId);
2734
+ // Only auto-commit checkpoints for changes produced by this run.
2735
+ // If the tree was already dirty, a checkpoint commit would sweep
2736
+ // up the user's unrelated work when a reconnect/refresh finishes.
2737
+ const postRunStatus = getUncommittedStatus(cwd);
2738
+ if (preRunStatus === "" &&
2739
+ postRunStatus?.trim() &&
2740
+ isGitRepo(cwd) &&
2741
+ hasUncommittedChanges(cwd)) {
2705
2742
  let summary = "";
2706
2743
  // Try to extract the first sentence of the assistant's text response
2707
2744
  let assistantText = "";
@@ -2920,7 +2957,8 @@ export function createAgentChatPlugin(options) {
2920
2957
  runCtx.model = model;
2921
2958
  }
2922
2959
  },
2923
- onRunStart: (send, threadId) => {
2960
+ onRunStart: async (send, threadId) => {
2961
+ await recordPreRunGitStatus(threadId);
2924
2962
  _runSendByThread.set(threadId, send);
2925
2963
  const runCtx = ensureRequestRunContext();
2926
2964
  if (runCtx)
@@ -2955,7 +2993,8 @@ export function createAgentChatPlugin(options) {
2955
2993
  runCtx.model = model;
2956
2994
  }
2957
2995
  },
2958
- onRunStart: (send, threadId) => {
2996
+ onRunStart: async (send, threadId) => {
2997
+ await recordPreRunGitStatus(threadId);
2959
2998
  _runSendByThread.set(threadId, send);
2960
2999
  const runCtx = ensureRequestRunContext();
2961
3000
  if (runCtx)
@@ -3038,7 +3077,8 @@ export function createAgentChatPlugin(options) {
3038
3077
  runCtx.model = model;
3039
3078
  }
3040
3079
  },
3041
- onRunStart: (send, threadId) => {
3080
+ onRunStart: async (send, threadId) => {
3081
+ await recordPreRunGitStatus(threadId);
3042
3082
  _runSendByThread.set(threadId, send);
3043
3083
  const runCtx = ensureRequestRunContext();
3044
3084
  if (runCtx)