@agent-native/core 0.109.3 → 0.109.4

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 (249) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +8 -0
  3. package/corpus/core/docs/content/agent-native-toolkit.mdx +46 -13
  4. package/corpus/core/docs/content/locales/ar-SA/agent-native-toolkit.mdx +79 -55
  5. package/corpus/core/docs/content/locales/ar-SA/toolkit-capability-packages.mdx +21 -0
  6. package/corpus/core/docs/content/locales/ar-SA/toolkit-context-knowledge.mdx +12 -0
  7. package/corpus/core/docs/content/locales/ar-SA/toolkit-editors-canvases.mdx +17 -0
  8. package/corpus/core/docs/content/locales/de-DE/agent-native-toolkit.mdx +82 -54
  9. package/corpus/core/docs/content/locales/de-DE/toolkit-capability-packages.mdx +21 -0
  10. package/corpus/core/docs/content/locales/de-DE/toolkit-context-knowledge.mdx +12 -0
  11. package/corpus/core/docs/content/locales/de-DE/toolkit-editors-canvases.mdx +17 -0
  12. package/corpus/core/docs/content/locales/es-ES/agent-native-toolkit.mdx +81 -52
  13. package/corpus/core/docs/content/locales/es-ES/toolkit-capability-packages.mdx +21 -0
  14. package/corpus/core/docs/content/locales/es-ES/toolkit-context-knowledge.mdx +12 -0
  15. package/corpus/core/docs/content/locales/es-ES/toolkit-editors-canvases.mdx +21 -0
  16. package/corpus/core/docs/content/locales/fr-FR/agent-native-toolkit.mdx +84 -54
  17. package/corpus/core/docs/content/locales/fr-FR/toolkit-capability-packages.mdx +21 -0
  18. package/corpus/core/docs/content/locales/fr-FR/toolkit-context-knowledge.mdx +12 -0
  19. package/corpus/core/docs/content/locales/fr-FR/toolkit-editors-canvases.mdx +21 -0
  20. package/corpus/core/docs/content/locales/hi-IN/agent-native-toolkit.mdx +69 -62
  21. package/corpus/core/docs/content/locales/hi-IN/toolkit-capability-packages.mdx +21 -0
  22. package/corpus/core/docs/content/locales/hi-IN/toolkit-context-knowledge.mdx +12 -0
  23. package/corpus/core/docs/content/locales/hi-IN/toolkit-editors-canvases.mdx +17 -0
  24. package/corpus/core/docs/content/locales/ja-JP/agent-native-toolkit.mdx +69 -62
  25. package/corpus/core/docs/content/locales/ja-JP/toolkit-capability-packages.mdx +21 -0
  26. package/corpus/core/docs/content/locales/ja-JP/toolkit-context-knowledge.mdx +12 -0
  27. package/corpus/core/docs/content/locales/ja-JP/toolkit-editors-canvases.mdx +17 -0
  28. package/corpus/core/docs/content/locales/ko-KR/agent-native-toolkit.mdx +69 -62
  29. package/corpus/core/docs/content/locales/ko-KR/toolkit-capability-packages.mdx +21 -0
  30. package/corpus/core/docs/content/locales/ko-KR/toolkit-context-knowledge.mdx +12 -0
  31. package/corpus/core/docs/content/locales/ko-KR/toolkit-editors-canvases.mdx +17 -0
  32. package/corpus/core/docs/content/locales/pt-BR/agent-native-toolkit.mdx +82 -54
  33. package/corpus/core/docs/content/locales/pt-BR/toolkit-capability-packages.mdx +21 -0
  34. package/corpus/core/docs/content/locales/pt-BR/toolkit-context-knowledge.mdx +12 -0
  35. package/corpus/core/docs/content/locales/pt-BR/toolkit-editors-canvases.mdx +17 -0
  36. package/corpus/core/docs/content/locales/zh-CN/agent-native-toolkit.mdx +69 -62
  37. package/corpus/core/docs/content/locales/zh-CN/toolkit-capability-packages.mdx +21 -0
  38. package/corpus/core/docs/content/locales/zh-CN/toolkit-context-knowledge.mdx +12 -0
  39. package/corpus/core/docs/content/locales/zh-CN/toolkit-editors-canvases.mdx +17 -0
  40. package/corpus/core/docs/content/locales/zh-TW/agent-native-toolkit.mdx +69 -62
  41. package/corpus/core/docs/content/locales/zh-TW/toolkit-capability-packages.mdx +21 -0
  42. package/corpus/core/docs/content/locales/zh-TW/toolkit-context-knowledge.mdx +12 -0
  43. package/corpus/core/docs/content/locales/zh-TW/toolkit-editors-canvases.mdx +17 -0
  44. package/corpus/core/docs/content/toolkit-capability-packages.mdx +52 -0
  45. package/corpus/core/docs/content/toolkit-context-knowledge.mdx +46 -0
  46. package/corpus/core/docs/content/toolkit-editors-canvases.mdx +55 -0
  47. package/corpus/core/package.json +35 -34
  48. package/corpus/core/src/cli/create.ts +39 -3
  49. package/corpus/core/src/cli/package-lifecycle.ts +2 -0
  50. package/corpus/core/src/cli/skills-content/visual-plan-skill.ts +2 -0
  51. package/corpus/core/src/client/context-xray/ContextMeter.tsx +31 -111
  52. package/corpus/core/src/client/context-xray/ContextSegmentRow.tsx +8 -111
  53. package/corpus/core/src/client/context-xray/ContextTreemap.tsx +6 -111
  54. package/corpus/core/src/client/context-xray/ContextXRayPanel.tsx +31 -391
  55. package/corpus/core/src/client/context-xray/SegmentProvenancePopover.tsx +4 -52
  56. package/corpus/core/src/client/context-xray/format.ts +0 -33
  57. package/corpus/core/src/client/rich-markdown-editor/index.ts +42 -57
  58. package/corpus/core/src/client/rich-markdown-editor/uploadEditorImage.ts +2 -1
  59. package/corpus/core/src/client/visual-style-controls.tsx +1 -1088
  60. package/corpus/core/src/collab/agent-identity.ts +5 -22
  61. package/corpus/core/src/collab/client.ts +1 -53
  62. package/corpus/core/src/styles/rich-markdown-editor.css +1 -510
  63. package/corpus/core/src/testing.ts +1 -1
  64. package/corpus/core/src/vite/client.ts +3 -0
  65. package/corpus/templates/content/app/components/editor/VisualEditor.tsx +5 -3
  66. package/corpus/templates/content/app/components/editor/extensions/DragHandle.tsx +4 -4
  67. package/corpus/templates/content/package.json +25 -25
  68. package/corpus/templates/design/app/components/design/TweaksPanel.tsx +2 -1
  69. package/corpus/templates/design/package.json +1 -1
  70. package/corpus/templates/mail/package.json +9 -9
  71. package/corpus/templates/plan/.agents/skills/visual-plan/SKILL.md +2 -0
  72. package/corpus/templates/plan/app/components/editor/PlanDocumentEditor.tsx +8 -8
  73. package/corpus/templates/plan/app/components/editor/planSlashCommands.ts +6 -6
  74. package/corpus/templates/plan/app/components/plan/PlanImageNode.tsx +4 -7
  75. package/corpus/templates/plan/app/components/plan/PlanMarkdownEditor.tsx +6 -4
  76. package/corpus/templates/plan/app/components/plan/PlanVisualSurface.tsx +1 -1
  77. package/corpus/templates/plan/changelog/2026-07-18-visual-plans-now-open-on-wireframes-by-default-when-a-protot.md +6 -0
  78. package/corpus/templates/plan/package.json +3 -3
  79. package/corpus/templates/slides/app/components/editor/SlideStyleInspector.tsx +2 -2
  80. package/corpus/templates/slides/app/components/editor/TweaksPanel.tsx +2 -2
  81. package/corpus/templates/slides/package.json +13 -13
  82. package/dist/catalog.json +39 -1
  83. package/dist/cli/create.d.ts.map +1 -1
  84. package/dist/cli/create.js +32 -3
  85. package/dist/cli/create.js.map +1 -1
  86. package/dist/cli/package-lifecycle.d.ts.map +1 -1
  87. package/dist/cli/package-lifecycle.js +2 -0
  88. package/dist/cli/package-lifecycle.js.map +1 -1
  89. package/dist/cli/skills-content/visual-plan-skill.d.ts +1 -1
  90. package/dist/cli/skills-content/visual-plan-skill.d.ts.map +1 -1
  91. package/dist/cli/skills-content/visual-plan-skill.js +2 -0
  92. package/dist/cli/skills-content/visual-plan-skill.js.map +1 -1
  93. package/dist/client/context-xray/ContextMeter.d.ts.map +1 -1
  94. package/dist/client/context-xray/ContextMeter.js +8 -23
  95. package/dist/client/context-xray/ContextMeter.js.map +1 -1
  96. package/dist/client/context-xray/ContextSegmentRow.d.ts.map +1 -1
  97. package/dist/client/context-xray/ContextSegmentRow.js +3 -19
  98. package/dist/client/context-xray/ContextSegmentRow.js.map +1 -1
  99. package/dist/client/context-xray/ContextTreemap.d.ts.map +1 -1
  100. package/dist/client/context-xray/ContextTreemap.js +3 -54
  101. package/dist/client/context-xray/ContextTreemap.js.map +1 -1
  102. package/dist/client/context-xray/ContextXRayPanel.d.ts.map +1 -1
  103. package/dist/client/context-xray/ContextXRayPanel.js +21 -163
  104. package/dist/client/context-xray/ContextXRayPanel.js.map +1 -1
  105. package/dist/client/context-xray/SegmentProvenancePopover.d.ts.map +1 -1
  106. package/dist/client/context-xray/SegmentProvenancePopover.js +3 -4
  107. package/dist/client/context-xray/SegmentProvenancePopover.js.map +1 -1
  108. package/dist/client/context-xray/format.d.ts +0 -4
  109. package/dist/client/context-xray/format.d.ts.map +1 -1
  110. package/dist/client/context-xray/format.js +0 -49
  111. package/dist/client/context-xray/format.js.map +1 -1
  112. package/dist/client/rich-markdown-editor/index.d.ts +1 -12
  113. package/dist/client/rich-markdown-editor/index.d.ts.map +1 -1
  114. package/dist/client/rich-markdown-editor/index.js +1 -12
  115. package/dist/client/rich-markdown-editor/index.js.map +1 -1
  116. package/dist/client/rich-markdown-editor/uploadEditorImage.d.ts +1 -1
  117. package/dist/client/rich-markdown-editor/uploadEditorImage.d.ts.map +1 -1
  118. package/dist/client/rich-markdown-editor/uploadEditorImage.js.map +1 -1
  119. package/dist/client/visual-style-controls.d.ts +1 -89
  120. package/dist/client/visual-style-controls.d.ts.map +1 -1
  121. package/dist/client/visual-style-controls.js +1 -498
  122. package/dist/client/visual-style-controls.js.map +1 -1
  123. package/dist/collab/agent-identity.d.ts +1 -14
  124. package/dist/collab/agent-identity.d.ts.map +1 -1
  125. package/dist/collab/agent-identity.js +1 -13
  126. package/dist/collab/agent-identity.js.map +1 -1
  127. package/dist/collab/awareness.d.ts +2 -2
  128. package/dist/collab/awareness.d.ts.map +1 -1
  129. package/dist/collab/client.d.ts +1 -19
  130. package/dist/collab/client.d.ts.map +1 -1
  131. package/dist/collab/client.js +1 -53
  132. package/dist/collab/client.js.map +1 -1
  133. package/dist/collab/routes.d.ts +1 -1
  134. package/dist/file-upload/actions/upload-image.d.ts +1 -1
  135. package/dist/notifications/routes.d.ts +3 -3
  136. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  137. package/dist/styles/rich-markdown-editor.css +1 -510
  138. package/dist/testing.d.ts +1 -1
  139. package/dist/testing.d.ts.map +1 -1
  140. package/dist/testing.js +1 -1
  141. package/dist/testing.js.map +1 -1
  142. package/dist/vite/client.d.ts.map +1 -1
  143. package/dist/vite/client.js +3 -0
  144. package/dist/vite/client.js.map +1 -1
  145. package/docs/content/agent-native-toolkit.mdx +46 -13
  146. package/docs/content/locales/ar-SA/agent-native-toolkit.mdx +79 -55
  147. package/docs/content/locales/ar-SA/toolkit-capability-packages.mdx +21 -0
  148. package/docs/content/locales/ar-SA/toolkit-context-knowledge.mdx +12 -0
  149. package/docs/content/locales/ar-SA/toolkit-editors-canvases.mdx +17 -0
  150. package/docs/content/locales/de-DE/agent-native-toolkit.mdx +82 -54
  151. package/docs/content/locales/de-DE/toolkit-capability-packages.mdx +21 -0
  152. package/docs/content/locales/de-DE/toolkit-context-knowledge.mdx +12 -0
  153. package/docs/content/locales/de-DE/toolkit-editors-canvases.mdx +17 -0
  154. package/docs/content/locales/es-ES/agent-native-toolkit.mdx +81 -52
  155. package/docs/content/locales/es-ES/toolkit-capability-packages.mdx +21 -0
  156. package/docs/content/locales/es-ES/toolkit-context-knowledge.mdx +12 -0
  157. package/docs/content/locales/es-ES/toolkit-editors-canvases.mdx +21 -0
  158. package/docs/content/locales/fr-FR/agent-native-toolkit.mdx +84 -54
  159. package/docs/content/locales/fr-FR/toolkit-capability-packages.mdx +21 -0
  160. package/docs/content/locales/fr-FR/toolkit-context-knowledge.mdx +12 -0
  161. package/docs/content/locales/fr-FR/toolkit-editors-canvases.mdx +21 -0
  162. package/docs/content/locales/hi-IN/agent-native-toolkit.mdx +69 -62
  163. package/docs/content/locales/hi-IN/toolkit-capability-packages.mdx +21 -0
  164. package/docs/content/locales/hi-IN/toolkit-context-knowledge.mdx +12 -0
  165. package/docs/content/locales/hi-IN/toolkit-editors-canvases.mdx +17 -0
  166. package/docs/content/locales/ja-JP/agent-native-toolkit.mdx +69 -62
  167. package/docs/content/locales/ja-JP/toolkit-capability-packages.mdx +21 -0
  168. package/docs/content/locales/ja-JP/toolkit-context-knowledge.mdx +12 -0
  169. package/docs/content/locales/ja-JP/toolkit-editors-canvases.mdx +17 -0
  170. package/docs/content/locales/ko-KR/agent-native-toolkit.mdx +69 -62
  171. package/docs/content/locales/ko-KR/toolkit-capability-packages.mdx +21 -0
  172. package/docs/content/locales/ko-KR/toolkit-context-knowledge.mdx +12 -0
  173. package/docs/content/locales/ko-KR/toolkit-editors-canvases.mdx +17 -0
  174. package/docs/content/locales/pt-BR/agent-native-toolkit.mdx +82 -54
  175. package/docs/content/locales/pt-BR/toolkit-capability-packages.mdx +21 -0
  176. package/docs/content/locales/pt-BR/toolkit-context-knowledge.mdx +12 -0
  177. package/docs/content/locales/pt-BR/toolkit-editors-canvases.mdx +17 -0
  178. package/docs/content/locales/zh-CN/agent-native-toolkit.mdx +69 -62
  179. package/docs/content/locales/zh-CN/toolkit-capability-packages.mdx +21 -0
  180. package/docs/content/locales/zh-CN/toolkit-context-knowledge.mdx +12 -0
  181. package/docs/content/locales/zh-CN/toolkit-editors-canvases.mdx +17 -0
  182. package/docs/content/locales/zh-TW/agent-native-toolkit.mdx +69 -62
  183. package/docs/content/locales/zh-TW/toolkit-capability-packages.mdx +21 -0
  184. package/docs/content/locales/zh-TW/toolkit-context-knowledge.mdx +12 -0
  185. package/docs/content/locales/zh-TW/toolkit-editors-canvases.mdx +17 -0
  186. package/docs/content/toolkit-capability-packages.mdx +52 -0
  187. package/docs/content/toolkit-context-knowledge.mdx +46 -0
  188. package/docs/content/toolkit-editors-canvases.mdx +55 -0
  189. package/package.json +27 -26
  190. package/corpus/core/src/client/rich-markdown-editor/BubbleToolbar.tsx +0 -253
  191. package/corpus/core/src/client/rich-markdown-editor/CodeBlockNode.tsx +0 -258
  192. package/corpus/core/src/client/rich-markdown-editor/DragHandle.ts +0 -1437
  193. package/corpus/core/src/client/rich-markdown-editor/ImageExtension.ts +0 -306
  194. package/corpus/core/src/client/rich-markdown-editor/RichMarkdownEditor.tsx +0 -80
  195. package/corpus/core/src/client/rich-markdown-editor/RunId.ts +0 -61
  196. package/corpus/core/src/client/rich-markdown-editor/SharedRichEditor.tsx +0 -321
  197. package/corpus/core/src/client/rich-markdown-editor/SlashCommandMenu.tsx +0 -310
  198. package/corpus/core/src/client/rich-markdown-editor/extensions.ts +0 -402
  199. package/corpus/core/src/client/rich-markdown-editor/gfmDoc.ts +0 -92
  200. package/corpus/core/src/client/rich-markdown-editor/surgical-apply.ts +0 -192
  201. package/corpus/core/src/client/rich-markdown-editor/useCollabReconcile.ts +0 -590
  202. package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts +0 -37
  203. package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts.map +0 -1
  204. package/dist/client/rich-markdown-editor/BubbleToolbar.js +0 -171
  205. package/dist/client/rich-markdown-editor/BubbleToolbar.js.map +0 -1
  206. package/dist/client/rich-markdown-editor/CodeBlockNode.d.ts +0 -49
  207. package/dist/client/rich-markdown-editor/CodeBlockNode.d.ts.map +0 -1
  208. package/dist/client/rich-markdown-editor/CodeBlockNode.js +0 -127
  209. package/dist/client/rich-markdown-editor/CodeBlockNode.js.map +0 -1
  210. package/dist/client/rich-markdown-editor/DragHandle.d.ts +0 -97
  211. package/dist/client/rich-markdown-editor/DragHandle.d.ts.map +0 -1
  212. package/dist/client/rich-markdown-editor/DragHandle.js +0 -1066
  213. package/dist/client/rich-markdown-editor/DragHandle.js.map +0 -1
  214. package/dist/client/rich-markdown-editor/ImageExtension.d.ts +0 -63
  215. package/dist/client/rich-markdown-editor/ImageExtension.d.ts.map +0 -1
  216. package/dist/client/rich-markdown-editor/ImageExtension.js +0 -243
  217. package/dist/client/rich-markdown-editor/ImageExtension.js.map +0 -1
  218. package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts +0 -51
  219. package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts.map +0 -1
  220. package/dist/client/rich-markdown-editor/RichMarkdownEditor.js +0 -37
  221. package/dist/client/rich-markdown-editor/RichMarkdownEditor.js.map +0 -1
  222. package/dist/client/rich-markdown-editor/RunId.d.ts +0 -28
  223. package/dist/client/rich-markdown-editor/RunId.d.ts.map +0 -1
  224. package/dist/client/rich-markdown-editor/RunId.js +0 -60
  225. package/dist/client/rich-markdown-editor/RunId.js.map +0 -1
  226. package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts +0 -110
  227. package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts.map +0 -1
  228. package/dist/client/rich-markdown-editor/SharedRichEditor.js +0 -144
  229. package/dist/client/rich-markdown-editor/SharedRichEditor.js.map +0 -1
  230. package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts +0 -41
  231. package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts.map +0 -1
  232. package/dist/client/rich-markdown-editor/SlashCommandMenu.js +0 -221
  233. package/dist/client/rich-markdown-editor/SlashCommandMenu.js.map +0 -1
  234. package/dist/client/rich-markdown-editor/extensions.d.ts +0 -178
  235. package/dist/client/rich-markdown-editor/extensions.d.ts.map +0 -1
  236. package/dist/client/rich-markdown-editor/extensions.js +0 -224
  237. package/dist/client/rich-markdown-editor/extensions.js.map +0 -1
  238. package/dist/client/rich-markdown-editor/gfmDoc.d.ts +0 -24
  239. package/dist/client/rich-markdown-editor/gfmDoc.d.ts.map +0 -1
  240. package/dist/client/rich-markdown-editor/gfmDoc.js +0 -83
  241. package/dist/client/rich-markdown-editor/gfmDoc.js.map +0 -1
  242. package/dist/client/rich-markdown-editor/surgical-apply.d.ts +0 -66
  243. package/dist/client/rich-markdown-editor/surgical-apply.d.ts.map +0 -1
  244. package/dist/client/rich-markdown-editor/surgical-apply.js +0 -147
  245. package/dist/client/rich-markdown-editor/surgical-apply.js.map +0 -1
  246. package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts +0 -110
  247. package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts.map +0 -1
  248. package/dist/client/rich-markdown-editor/useCollabReconcile.js +0 -441
  249. package/dist/client/rich-markdown-editor/useCollabReconcile.js.map +0 -1
@@ -1,22 +1,5 @@
1
- /**
2
- * Canonical agent identity constants for collaborative editing.
3
- *
4
- * Centralizes the agent's client ID, name, email, and cursor color
5
- * so templates don't hardcode these values.
6
- */
7
-
8
- export const AGENT_CLIENT_ID = 2147483647; // Max 32-bit signed int, reserved for agent
9
-
10
- export interface AgentIdentity {
11
- clientId: number;
12
- name: string;
13
- email: string;
14
- color: string;
15
- }
16
-
17
- export const DEFAULT_AGENT_IDENTITY: AgentIdentity = {
18
- clientId: AGENT_CLIENT_ID,
19
- name: "AI Assistant",
20
- email: "agent@system",
21
- color: "#00B5FF", // agent-native blue
22
- };
1
+ export {
2
+ AGENT_CLIENT_ID,
3
+ DEFAULT_AGENT_IDENTITY,
4
+ type AgentIdentity,
5
+ } from "@agent-native/toolkit/collab-ui";
@@ -45,12 +45,11 @@ import * as Y from "yjs";
45
45
 
46
46
  import { agentNativePath } from "../client/api-path.js";
47
47
  import { subscribeSyncEvents, type SyncEvent } from "../client/use-db-sync.js";
48
- import { AGENT_CLIENT_ID } from "./agent-identity.js";
49
-
50
48
  export {
51
49
  dedupeCollabUsersByEmail,
52
50
  emailToColor,
53
51
  emailToName,
52
+ isReconcileLeadClient,
54
53
  type CollabUser,
55
54
  } from "@agent-native/toolkit/collab-ui";
56
55
 
@@ -119,57 +118,6 @@ function collabUsersEqual(a: CollabUser[], b: CollabUser[]): boolean {
119
118
  return true;
120
119
  }
121
120
 
122
- /**
123
- * Leader election for applying authoritative external snapshots into a shared
124
- * collaborative document.
125
- *
126
- * When the agent (or a Notion pull, or any full-document rewrite) writes new
127
- * content to SQL, the open editor reconciles it into the live Y.Doc with
128
- * `setContent`. If EVERY connected client did that independently, each would
129
- * diff the same snapshot into the CRDT and the changed region would be inserted
130
- * N times (concurrent inserts at the same position → duplicated text). So only
131
- * ONE client — the "lead" — applies the snapshot; every other client receives
132
- * the result through normal Yjs sync.
133
- *
134
- * The lead is the present client with the lowest Yjs `clientID`. The agent's
135
- * awareness entry uses `AGENT_CLIENT_ID` (max int) so it can never be the lead,
136
- * and a client editing alone is always the lead. This is deterministic across
137
- * clients with no coordination round-trip.
138
- */
139
- export function isReconcileLeadClient(
140
- awareness: Awareness | null | undefined,
141
- localClientId: number | null | undefined,
142
- ): boolean {
143
- if (localClientId == null) return false;
144
- if (!awareness) return true; // standalone / tests — act alone
145
-
146
- let hasPeer = false;
147
- let minVisible = localClientId;
148
- awareness.getStates().forEach((state, clientId) => {
149
- if (clientId === AGENT_CLIENT_ID) return; // agent never leads
150
- if (clientId === localClientId) return;
151
- const s = state as { user?: unknown; visible?: boolean };
152
- if (!s || !s.user) return; // skip empty/stale entries
153
- hasPeer = true;
154
- // Only VISIBLE peers can act; a peer published `visible: false` (backgrounded)
155
- // is skipped. A peer that hasn't published the field is treated as visible.
156
- if (s.visible !== false && clientId < minVisible) minVisible = clientId;
157
- });
158
-
159
- // Sole client: always the applier — no other client can duplicate the edit,
160
- // so single-user agent edits apply even if this tab reports hidden.
161
- if (!hasPeer) return true;
162
-
163
- // With peers present, exactly one VISIBLE client applies (the lowest clientId
164
- // among visible ones). A backgrounded tab pauses its poll and can't reliably
165
- // act, so it yields — otherwise an agent edit would never reach the tab the
166
- // user is actually looking at. The caller re-elects on visibility change.
167
- const localHidden =
168
- typeof document !== "undefined" && document.visibilityState === "hidden";
169
- if (localHidden) return false;
170
- return localClientId <= minVisible;
171
- }
172
-
173
121
  export interface RemoteAwarenessSnapshot {
174
122
  clientId: number;
175
123
  state: unknown;
@@ -1,510 +1 @@
1
- .an-rich-md-wrapper {
2
- min-height: 100%;
3
- position: relative;
4
- cursor: text;
5
- }
6
-
7
- .an-rich-md-wrapper--readonly {
8
- cursor: default;
9
- }
10
-
11
- .an-rich-md-loading {
12
- min-height: 7rem;
13
- }
14
-
15
- .an-rich-md-prose {
16
- outline: none;
17
- color: hsl(var(--foreground));
18
- line-height: 1.65;
19
- font-size: 0.95rem;
20
- min-height: 1.65em;
21
- text-align: start;
22
- }
23
-
24
- .an-rich-md-prose > *:first-child {
25
- margin-top: 0;
26
- }
27
-
28
- .an-rich-md-prose h1 {
29
- font-size: 1.85em;
30
- font-weight: 700;
31
- margin: 1em 0 0.3em;
32
- line-height: 1.18;
33
- }
34
-
35
- .an-rich-md-prose h2 {
36
- font-size: 1.45em;
37
- font-weight: 650;
38
- margin: 0.9em 0 0.25em;
39
- line-height: 1.25;
40
- }
41
-
42
- .an-rich-md-prose h3 {
43
- font-size: 1.18em;
44
- font-weight: 650;
45
- margin: 0.75em 0 0.2em;
46
- line-height: 1.32;
47
- }
48
-
49
- .an-rich-md-prose h4 {
50
- font-size: 1em;
51
- font-weight: 650;
52
- margin: 0.65em 0 0.15em;
53
- line-height: 1.35;
54
- }
55
-
56
- .an-rich-md-prose p {
57
- margin: 0.45em 0;
58
- min-height: 1.65em;
59
- }
60
-
61
- .an-rich-md-prose ul:not(.an-rich-md-task-list),
62
- .an-rich-md-prose ol {
63
- padding-inline-start: 1.45em;
64
- margin: 0.35em 0;
65
- }
66
-
67
- .an-rich-md-prose ul:not(.an-rich-md-task-list) {
68
- list-style-type: disc;
69
- }
70
-
71
- .an-rich-md-prose ol {
72
- list-style-type: decimal;
73
- }
74
-
75
- .an-rich-md-prose li {
76
- margin: 0.12em 0;
77
- }
78
-
79
- .an-rich-md-prose li p {
80
- margin: 0;
81
- }
82
-
83
- .an-rich-md-task-list {
84
- list-style: none;
85
- margin: 0.35em 0;
86
- padding-inline-start: 0;
87
- }
88
-
89
- .an-rich-md-task-list li {
90
- display: flex;
91
- align-items: flex-start;
92
- gap: 0.45em;
93
- margin: 0.18em 0;
94
- }
95
-
96
- .an-rich-md-task-list li label {
97
- display: inline-flex;
98
- align-items: center;
99
- height: 1.65em;
100
- }
101
-
102
- .an-rich-md-task-list li input[type="checkbox"] {
103
- width: 0.95em;
104
- height: 0.95em;
105
- accent-color: hsl(var(--primary));
106
- }
107
-
108
- .an-rich-md-task-list li > div {
109
- flex: 1;
110
- }
111
-
112
- .an-rich-md-prose blockquote {
113
- border-inline-start: 2px solid hsl(var(--border));
114
- padding-inline-start: 0.9em;
115
- margin: 0.45em 0;
116
- color: hsl(var(--muted-foreground));
117
- }
118
-
119
- .an-rich-md-prose code {
120
- unicode-bidi: isolate;
121
- font-family:
122
- ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
123
- font-size: 0.88em;
124
- background: hsl(var(--muted));
125
- padding: 0.12em 0.32em;
126
- border-radius: 4px;
127
- }
128
-
129
- .an-rich-md-prose :not(pre) > code {
130
- direction: ltr;
131
- }
132
-
133
- .an-rich-md-prose pre {
134
- font-family:
135
- ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
136
- font-size: 0.86em;
137
- /* Theme-aware code surface: follows the app's muted/foreground/border tokens
138
- so block code respects light and dark mode (the token palette below is
139
- tuned to read on a muted surface in both). */
140
- background: hsl(var(--muted));
141
- color: hsl(var(--foreground));
142
- border: 1px solid hsl(var(--border));
143
- border-radius: 6px;
144
- padding: 0.8em 1em;
145
- margin: 0.55em 0;
146
- overflow-x: auto;
147
- line-height: 1.5;
148
- }
149
-
150
- .an-rich-md-prose pre code {
151
- background: none;
152
- border: none;
153
- padding: 0;
154
- font-size: inherit;
155
- color: inherit;
156
- }
157
-
158
- /* highlight.js (lowlight) token palette. Scoped to block code so inline `code`
159
- keeps its own background. No highlight.js base theme is imported; these rules
160
- are the entire theme, tuned (mid-lightness HSL) to read on the muted surface
161
- above in both light and dark mode. */
162
- .an-rich-md-prose pre code .hljs-comment,
163
- .an-rich-md-prose pre code .hljs-quote {
164
- color: hsl(var(--muted-foreground));
165
- font-style: italic;
166
- }
167
- .an-rich-md-prose pre code .hljs-keyword,
168
- .an-rich-md-prose pre code .hljs-selector-tag,
169
- .an-rich-md-prose pre code .hljs-literal,
170
- .an-rich-md-prose pre code .hljs-doctag {
171
- color: hsl(280 60% 58%);
172
- }
173
- .an-rich-md-prose pre code .hljs-string,
174
- .an-rich-md-prose pre code .hljs-regexp,
175
- .an-rich-md-prose pre code .hljs-addition {
176
- color: hsl(140 52% 40%);
177
- }
178
- .an-rich-md-prose pre code .hljs-number,
179
- .an-rich-md-prose pre code .hljs-symbol,
180
- .an-rich-md-prose pre code .hljs-literal {
181
- color: hsl(28 78% 48%);
182
- }
183
- .an-rich-md-prose pre code .hljs-meta {
184
- color: hsl(var(--muted-foreground));
185
- }
186
- .an-rich-md-prose pre code .hljs-title,
187
- .an-rich-md-prose pre code .hljs-title.function_,
188
- .an-rich-md-prose pre code .hljs-section {
189
- color: hsl(210 72% 52%);
190
- }
191
- .an-rich-md-prose pre code .hljs-built_in,
192
- .an-rich-md-prose pre code .hljs-type,
193
- .an-rich-md-prose pre code .hljs-title.class_,
194
- .an-rich-md-prose pre code .hljs-variable.language_ {
195
- color: hsl(190 64% 40%);
196
- }
197
- .an-rich-md-prose pre code .hljs-attr,
198
- .an-rich-md-prose pre code .hljs-attribute,
199
- .an-rich-md-prose pre code .hljs-property,
200
- .an-rich-md-prose pre code .hljs-params {
201
- color: hsl(35 68% 46%);
202
- }
203
- .an-rich-md-prose pre code .hljs-name,
204
- .an-rich-md-prose pre code .hljs-tag,
205
- .an-rich-md-prose pre code .hljs-selector-id,
206
- .an-rich-md-prose pre code .hljs-selector-class {
207
- color: hsl(350 62% 52%);
208
- }
209
- .an-rich-md-prose pre code .hljs-deletion {
210
- color: hsl(0 62% 52%);
211
- }
212
- .an-rich-md-prose pre code .hljs-emphasis {
213
- font-style: italic;
214
- }
215
- .an-rich-md-prose pre code .hljs-strong {
216
- font-weight: 600;
217
- }
218
-
219
- /* In dark mode, lift the token lightness for contrast on the dark muted surface. */
220
- .dark .an-rich-md-prose pre code .hljs-keyword,
221
- .dark .an-rich-md-prose pre code .hljs-selector-tag,
222
- .dark .an-rich-md-prose pre code .hljs-literal,
223
- .dark .an-rich-md-prose pre code .hljs-doctag {
224
- color: hsl(280 72% 72%);
225
- }
226
- .dark .an-rich-md-prose pre code .hljs-string,
227
- .dark .an-rich-md-prose pre code .hljs-regexp,
228
- .dark .an-rich-md-prose pre code .hljs-addition {
229
- color: hsl(140 48% 62%);
230
- }
231
- .dark .an-rich-md-prose pre code .hljs-number,
232
- .dark .an-rich-md-prose pre code .hljs-symbol,
233
- .dark .an-rich-md-prose pre code .hljs-literal {
234
- color: hsl(30 85% 65%);
235
- }
236
- .dark .an-rich-md-prose pre code .hljs-title,
237
- .dark .an-rich-md-prose pre code .hljs-title.function_,
238
- .dark .an-rich-md-prose pre code .hljs-section {
239
- color: hsl(210 80% 70%);
240
- }
241
- .dark .an-rich-md-prose pre code .hljs-built_in,
242
- .dark .an-rich-md-prose pre code .hljs-type,
243
- .dark .an-rich-md-prose pre code .hljs-title.class_,
244
- .dark .an-rich-md-prose pre code .hljs-variable.language_ {
245
- color: hsl(190 70% 62%);
246
- }
247
- .dark .an-rich-md-prose pre code .hljs-attr,
248
- .dark .an-rich-md-prose pre code .hljs-attribute,
249
- .dark .an-rich-md-prose pre code .hljs-property,
250
- .dark .an-rich-md-prose pre code .hljs-params {
251
- color: hsl(40 78% 66%);
252
- }
253
- .dark .an-rich-md-prose pre code .hljs-name,
254
- .dark .an-rich-md-prose pre code .hljs-tag,
255
- .dark .an-rich-md-prose pre code .hljs-selector-id,
256
- .dark .an-rich-md-prose pre code .hljs-selector-class {
257
- color: hsl(350 72% 68%);
258
- }
259
-
260
- .an-rich-md-prose hr {
261
- border: none;
262
- border-top: 1px solid hsl(var(--border));
263
- margin: 1.1em 0;
264
- }
265
-
266
- .an-rich-md-table {
267
- width: 100%;
268
- border-collapse: collapse;
269
- margin: 0.7em 0;
270
- table-layout: fixed;
271
- }
272
-
273
- .an-rich-md-table td,
274
- .an-rich-md-table th {
275
- border: 1px solid hsl(var(--border));
276
- padding: 0.45em 0.55em;
277
- vertical-align: top;
278
- }
279
-
280
- .an-rich-md-table th {
281
- background: hsl(var(--muted) / 0.6);
282
- font-weight: 650;
283
- }
284
-
285
- .an-rich-md-table p {
286
- margin: 0;
287
- }
288
-
289
- .an-rich-md-prose strong {
290
- font-weight: 650;
291
- }
292
-
293
- .an-rich-md-prose em {
294
- font-style: italic;
295
- }
296
-
297
- .an-rich-md-prose s {
298
- text-decoration: line-through;
299
- }
300
-
301
- .an-rich-md-link {
302
- color: hsl(var(--foreground));
303
- text-decoration: underline;
304
- text-underline-offset: 2px;
305
- text-decoration-color: hsl(var(--muted-foreground));
306
- cursor: pointer;
307
- }
308
-
309
- .an-rich-md-link:hover {
310
- text-decoration-color: hsl(var(--foreground));
311
- }
312
-
313
- .an-rich-md-prose p.is-editor-empty:first-child::before,
314
- .an-rich-md-prose p.is-empty::before,
315
- .an-rich-md-prose h1.is-empty::before,
316
- .an-rich-md-prose h2.is-empty::before,
317
- .an-rich-md-prose h3.is-empty::before,
318
- .an-rich-md-prose h4.is-empty::before {
319
- content: attr(data-placeholder);
320
- float: inline-start;
321
- color: hsl(var(--muted-foreground));
322
- opacity: 0.55;
323
- pointer-events: none;
324
- height: 0;
325
- }
326
-
327
- .an-rich-md-prose ::selection {
328
- background: hsl(var(--ring) / 0.22);
329
- }
330
-
331
- .an-rich-md-bubble-toolbar {
332
- z-index: 9999;
333
- display: flex;
334
- align-items: center;
335
- border-radius: 6px;
336
- background: hsl(var(--popover));
337
- color: hsl(var(--popover-foreground));
338
- padding: 3px;
339
- box-shadow:
340
- 0 4px 16px rgb(0 0 0 / 0.25),
341
- 0 0 0 1px hsl(var(--border));
342
- }
343
-
344
- .an-rich-md-bubble-items,
345
- .an-rich-md-link-editor {
346
- display: flex;
347
- align-items: center;
348
- gap: 2px;
349
- }
350
-
351
- .an-rich-md-bubble-button {
352
- padding: 3px 6px;
353
- border-radius: 4px;
354
- font-size: 12px;
355
- color: hsl(var(--popover-foreground) / 0.76);
356
- background: none;
357
- border: none;
358
- cursor: pointer;
359
- line-height: 1;
360
- }
361
-
362
- .an-rich-md-bubble-button:hover {
363
- background: hsl(var(--accent));
364
- color: hsl(var(--accent-foreground));
365
- }
366
-
367
- .an-rich-md-bubble-button--active {
368
- background: hsl(var(--accent));
369
- color: hsl(var(--accent-foreground));
370
- }
371
-
372
- .an-rich-md-bubble-divider {
373
- width: 1px;
374
- height: 16px;
375
- margin: 0 2px;
376
- background: hsl(var(--border));
377
- }
378
-
379
- .an-rich-md-link-editor {
380
- padding: 4px;
381
- }
382
-
383
- .an-rich-md-link-editor input {
384
- width: 10rem;
385
- border: none;
386
- outline: none;
387
- background: transparent;
388
- color: hsl(var(--popover-foreground));
389
- font-size: 12px;
390
- padding: 2px 4px;
391
- }
392
-
393
- .an-rich-md-link-editor button {
394
- border: none;
395
- background: none;
396
- color: hsl(var(--primary));
397
- cursor: pointer;
398
- font-size: 11px;
399
- font-weight: 500;
400
- padding: 2px 6px;
401
- }
402
-
403
- .an-rich-md-slash-menu {
404
- z-index: 9999;
405
- width: min(420px, calc(100vw - 24px));
406
- min-width: 230px;
407
- max-height: 320px;
408
- overflow-y: auto;
409
- color: hsl(var(--foreground));
410
- background: hsl(var(--popover));
411
- border: 1px solid hsl(var(--border));
412
- border-radius: 7px;
413
- box-shadow:
414
- 0 4px 20px rgb(0 0 0 / 0.12),
415
- 0 0 0 1px rgb(0 0 0 / 0.04);
416
- padding: 4px 0;
417
- }
418
-
419
- .an-rich-md-slash-heading {
420
- padding: 4px 10px;
421
- font-size: 10px;
422
- font-weight: 650;
423
- text-transform: uppercase;
424
- letter-spacing: 0.06em;
425
- color: hsl(var(--muted-foreground));
426
- }
427
-
428
- .an-rich-md-slash-item {
429
- width: 100%;
430
- min-width: 0;
431
- min-height: 44px;
432
- display: flex;
433
- align-items: center;
434
- gap: 8px;
435
- padding: 6px 10px;
436
- text-align: start;
437
- background: none;
438
- border: none;
439
- cursor: pointer;
440
- color: hsl(var(--foreground));
441
- font-size: 13px;
442
- }
443
-
444
- .an-rich-md-slash-item:hover,
445
- .an-rich-md-slash-item--active {
446
- background: hsl(var(--accent));
447
- }
448
-
449
- .an-rich-md-slash-icon {
450
- display: flex;
451
- align-items: center;
452
- justify-content: center;
453
- width: 28px;
454
- height: 28px;
455
- border-radius: 4px;
456
- border: 1px solid hsl(var(--border));
457
- background: hsl(var(--background));
458
- font-size: 11px;
459
- font-weight: 650;
460
- color: hsl(var(--muted-foreground));
461
- flex-shrink: 0;
462
- }
463
-
464
- .an-rich-md-slash-copy {
465
- display: block;
466
- min-width: 0;
467
- flex: 1;
468
- }
469
-
470
- .an-rich-md-slash-title {
471
- display: block;
472
- overflow: hidden;
473
- text-overflow: ellipsis;
474
- white-space: nowrap;
475
- font-weight: 500;
476
- font-size: 13px;
477
- }
478
-
479
- .an-rich-md-slash-description {
480
- display: block;
481
- overflow: hidden;
482
- text-overflow: ellipsis;
483
- white-space: nowrap;
484
- font-size: 11px;
485
- color: hsl(var(--muted-foreground));
486
- }
487
-
488
- /* Shared block-level image node (the editor's `.an-rich-md-image` and the
489
- read-only markdown renderer's <img>). Constrained to the prose width and
490
- responsive; a still-uploading placeholder (empty src) shows a subtle frame. */
491
- .an-rich-md-prose img,
492
- .an-rich-md-image {
493
- display: block;
494
- max-width: 100%;
495
- height: auto;
496
- margin: 12px 0;
497
- border-radius: 8px;
498
- }
499
-
500
- .an-rich-md-image[src=""],
501
- .an-rich-md-image:not([src]) {
502
- min-height: 64px;
503
- background: hsl(var(--muted));
504
- border: 1px dashed hsl(var(--border));
505
- }
506
-
507
- .ProseMirror-selectednode.an-rich-md-image {
508
- outline: 2px solid hsl(var(--ring));
509
- outline-offset: 2px;
510
- }
1
+ @import "@agent-native/toolkit/editor.css";
@@ -23,4 +23,4 @@ export {
23
23
  type DesignConnectBridge,
24
24
  } from "./cli/design-connect.js";
25
25
 
26
- export { DragHandle } from "./client/rich-markdown-editor/DragHandle.js";
26
+ export { DragHandle } from "@agent-native/toolkit/editor";
@@ -811,6 +811,9 @@ const TOOLKIT_CLIENT_SUBPATHS = [
811
811
  "@agent-native/toolkit",
812
812
  "@agent-native/toolkit/app-shell",
813
813
  "@agent-native/toolkit/collab-ui",
814
+ "@agent-native/toolkit/context-ui",
815
+ "@agent-native/toolkit/design-tweaks",
816
+ "@agent-native/toolkit/editor",
814
817
  "@agent-native/toolkit/hooks",
815
818
  "@agent-native/toolkit/onboarding",
816
819
  "@agent-native/toolkit/provider",
@@ -1,6 +1,4 @@
1
1
  import {
2
- createSharedEditorExtensions,
3
- useCollabReconcile,
4
2
  usePresence,
5
3
  useRecentEdits,
6
4
  RecentEditHighlights,
@@ -8,8 +6,12 @@ import {
8
6
  useT,
9
7
  type AttributedRecentEdit,
10
8
  type RegistryBlockSideMapBlock,
11
- type UseCollabReconcileResult,
12
9
  } from "@agent-native/core/client";
10
+ import {
11
+ createSharedEditorExtensions,
12
+ useCollabReconcile,
13
+ type UseCollabReconcileResult,
14
+ } from "@agent-native/toolkit/editor";
13
15
  import { canonicalizeNfm, docToNfm, nfmToDoc } from "@shared/nfm";
14
16
  import {
15
17
  serializeRegistryBlockToMdx,
@@ -1,15 +1,15 @@
1
- import { DragHandle as CoreDragHandle } from "@agent-native/core/client";
1
+ import { DragHandle as ToolkitDragHandle } from "@agent-native/toolkit/editor";
2
2
 
3
3
  /**
4
4
  * Content's drag-handle extension.
5
5
  *
6
- * The implementation now lives in the shared core
7
- * (`packages/core/src/client/rich-markdown-editor/DragHandle.ts`) so other apps
6
+ * The implementation lives in Toolkit
7
+ * (`packages/toolkit/src/editor/DragHandle.ts`) so other apps
8
8
  * (e.g. the plan editor) can reuse the same `::` grip + block-selection +
9
9
  * drag-to-reorder affordance. This module is a thin re-export configured with
10
10
  * Content's wrapper selector so the behavior stays byte-identical and existing
11
11
  * imports (`./extensions/DragHandle`) keep working unchanged.
12
12
  */
13
- export const DragHandle = CoreDragHandle.configure({
13
+ export const DragHandle = ToolkitDragHandle.configure({
14
14
  wrapperSelector: ".visual-editor-wrapper",
15
15
  });