@agent-native/core 0.84.38 → 0.84.40

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 (41) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +12 -0
  3. package/corpus/core/package.json +1 -1
  4. package/corpus/core/src/agent/action-continuation-guidance.ts +38 -0
  5. package/corpus/core/src/agent/production-agent.ts +209 -4
  6. package/corpus/core/src/agent/run-loop-with-resume.ts +128 -16
  7. package/corpus/core/src/agent/types.ts +8 -0
  8. package/corpus/core/src/client/agent-chat-adapter.ts +2 -40
  9. package/corpus/templates/design/app/components/design/CodeWorkbenchHost.tsx +486 -341
  10. package/corpus/templates/design/app/components/design/DesignCanvas.tsx +13 -0
  11. package/corpus/templates/design/app/components/design/DesignImportPanel.tsx +76 -58
  12. package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +6 -0
  13. package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +80 -8
  14. package/corpus/templates/design/app/i18n/zh-TW.ts +2 -2
  15. package/corpus/templates/design/app/i18n-data.ts +22 -30
  16. package/corpus/templates/design/app/lib/design-import.ts +42 -0
  17. package/corpus/templates/design/app/pages/DesignEditor.tsx +180 -109
  18. package/corpus/templates/design/changelog/2026-07-01-code-workspace-now-opens-a-vs-code-like-editor-with-real-cod.md +6 -0
  19. package/corpus/templates/design/changelog/2026-07-01-import-is-more-compact-local-app-setup-is-clearer-and-figma.md +6 -0
  20. package/corpus/templates/design/package.json +1 -0
  21. package/dist/agent/action-continuation-guidance.d.ts +3 -0
  22. package/dist/agent/action-continuation-guidance.d.ts.map +1 -0
  23. package/dist/agent/action-continuation-guidance.js +38 -0
  24. package/dist/agent/action-continuation-guidance.js.map +1 -0
  25. package/dist/agent/production-agent.d.ts +6 -2
  26. package/dist/agent/production-agent.d.ts.map +1 -1
  27. package/dist/agent/production-agent.js +160 -4
  28. package/dist/agent/production-agent.js.map +1 -1
  29. package/dist/agent/run-loop-with-resume.d.ts.map +1 -1
  30. package/dist/agent/run-loop-with-resume.js +69 -18
  31. package/dist/agent/run-loop-with-resume.js.map +1 -1
  32. package/dist/agent/types.d.ts +2 -0
  33. package/dist/agent/types.d.ts.map +1 -1
  34. package/dist/agent/types.js.map +1 -1
  35. package/dist/client/agent-chat-adapter.d.ts.map +1 -1
  36. package/dist/client/agent-chat-adapter.js +2 -39
  37. package/dist/client/agent-chat-adapter.js.map +1 -1
  38. package/dist/collab/routes.d.ts +1 -1
  39. package/dist/file-upload/actions/upload-image.d.ts +2 -2
  40. package/dist/observability/routes.d.ts +5 -5
  41. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  import type { ChatModelAdapter, ChatModelRunResult } from "@assistant-ui/react";
2
2
 
3
+ import { actionPreparationContinuationNote } from "../agent/action-continuation-guidance.js";
3
4
  import type {
4
5
  AgentChatStructuredContentPart,
5
6
  AgentChatStructuredMessage,
@@ -927,42 +928,6 @@ function contentAfterContinuationPrefix(
927
928
  return [...delta, ...content.slice(contentIndex)];
928
929
  }
929
930
 
930
- // Concrete "ship a compact first version, then refine incrementally" guidance
931
- // keyed by the large-payload action the model was cut off while preparing. A run
932
- // cut off mid-stream while streaming one big tool input (extension HTML, a full
933
- // design file set, an entire dashboard config) re-streams the SAME oversized
934
- // payload on every continuation and never finishes inside the soft-timeout
935
- // window — the classic thrash loop. Pointing the resumed model at the
936
- // incremental-edit path for that specific action is what breaks the loop.
937
- // Returns undefined for tools with no known incremental counterpart so the
938
- // caller falls back to generic compact-first advice.
939
- function incrementalActionGuidance(tool: string): string | undefined {
940
- switch (tool) {
941
- case "create-extension":
942
- case "update-extension":
943
- return "create a compact working v1 with `create-extension`, then use focused `update-extension` edits for refinements";
944
- case "generate-design":
945
- case "update-design":
946
- return 'if an existing design file or snapshot is already in history, especially after a Design variant pick, stop retrying `generate-design`: call `get-design-snapshot` for the selected file, then call `edit-design` once on that same `fileId` (`mode: "replace-file"` for a compact full-file replacement, or search/replace for smaller edits). Use `generate-design` only for a brand-new compact first file when no target file exists yet';
947
- case "edit-design":
948
- return "retry with a smaller `edit-design` payload: prefer a handful of exact search/replace edits against the already-snapshotted file, and avoid `replacementContent` for a huge full-file rewrite. If a selected variant needs expansion, upgrade the highest-value visible sections first, save once, and summarize any remaining refinements";
949
- case "present-design-variants":
950
- return 'call `present-design-variants` with concise labels, descriptions, accent colors, and feature bullets; omit large `content` HTML when needed so the action can render compact representative screens. After the user picks a direction, delete unchosen screens, snapshot the selected `fileId`, and refine that same file with `edit-design` (`mode: "replace-file"` for placeholder expansion). Do not call `generate-design` after the variant pick';
951
- case "create-visual-plan":
952
- case "create-ui-plan":
953
- case "create-plan-design":
954
- case "create-prototype-plan":
955
- return "create the plan with its core sections or first screen, then expand it with `update-visual-plan`/`patch-visual-plan-source` follow-up edits";
956
- case "update-visual-plan":
957
- case "patch-visual-plan-source":
958
- return "apply smaller, targeted `patch-visual-plan-source` edits rather than rewriting the whole plan in one call";
959
- case "update-dashboard":
960
- return "save a small dashboard first, then add panels one at a time with `update-dashboard` incremental `ops` edits instead of authoring the whole config in one call";
961
- default:
962
- return undefined;
963
- }
964
- }
965
-
966
931
  function autoContinueMessage(signal: AgentAutoContinueSignal): string {
967
932
  const tool = lastActivityTool(signal.activityTrail);
968
933
  const reason =
@@ -987,10 +952,7 @@ function autoContinueMessage(signal: AgentAutoContinueSignal): string {
987
952
  signal.reason === "no_progress";
988
953
  let actionInputNote = "";
989
954
  if (cutoffPreparingAction && tool) {
990
- const guidance = incrementalActionGuidance(tool);
991
- actionInputNote = guidance
992
- ? `\n\nThe previous run was cut off while preparing the \`${tool}\` action input before the action could finish. Avoid spending another whole run assembling one large tool payload — ${guidance}.`
993
- : `\n\nThe previous run was cut off while preparing the \`${tool}\` action input before the action could finish. Avoid re-assembling one large tool payload: produce a compact first result you can finish in a single run, then refine it with smaller follow-up edits.`;
955
+ actionInputNote = actionPreparationContinuationNote(tool);
994
956
  }
995
957
  return `${AUTO_CONTINUE_PROMPT}\n\n${AUTO_CONTINUE_COMPLETION_GUARD}\n\nInternal note: ${reason}${actionInputNote}`;
996
958
  }