@agent-native/core 0.78.0 → 0.78.2

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 (96) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/core/CHANGELOG.md +15 -0
  3. package/corpus/core/package.json +1 -1
  4. package/corpus/core/src/agent/production-agent.ts +269 -237
  5. package/corpus/core/src/agent/types.ts +22 -0
  6. package/corpus/core/src/client/AgentPanel.tsx +8 -0
  7. package/corpus/core/src/client/AssistantChat.tsx +40 -0
  8. package/corpus/core/src/client/agent-chat.ts +173 -0
  9. package/corpus/core/src/client/composer/TiptapComposer.tsx +316 -60
  10. package/corpus/core/src/client/composer/extensions/MentionReference.tsx +3 -0
  11. package/corpus/core/src/client/composer/types.ts +22 -0
  12. package/corpus/core/src/client/index.ts +5 -0
  13. package/corpus/core/src/server/agent-chat-plugin.ts +10 -0
  14. package/corpus/core/src/server/request-context.ts +8 -0
  15. package/corpus/templates/analytics/server/plugins/agent-chat.ts +13 -0
  16. package/corpus/templates/assets/.agents/skills/asset-generation/SKILL.md +10 -2
  17. package/corpus/templates/assets/.agents/skills/image-generation/SKILL.md +14 -7
  18. package/corpus/templates/assets/.agents/skills/library-management/SKILL.md +12 -0
  19. package/corpus/templates/assets/AGENTS.md +18 -3
  20. package/corpus/templates/assets/actions/_image-model-default.ts +24 -0
  21. package/corpus/templates/assets/actions/dismiss-variant-slots.ts +15 -22
  22. package/corpus/templates/assets/actions/generate-asset.ts +30 -23
  23. package/corpus/templates/assets/actions/generate-image-batch.ts +76 -29
  24. package/corpus/templates/assets/actions/generate-image.ts +46 -30
  25. package/corpus/templates/assets/actions/generate-video.ts +18 -3
  26. package/corpus/templates/assets/actions/list-assets.ts +39 -8
  27. package/corpus/templates/assets/actions/list-libraries.ts +24 -2
  28. package/corpus/templates/assets/actions/navigate.ts +1 -1
  29. package/corpus/templates/assets/actions/open-asset-picker.ts +38 -1
  30. package/corpus/templates/assets/actions/refresh-generation-run.ts +10 -0
  31. package/corpus/templates/assets/actions/save-generated-image.ts +21 -19
  32. package/corpus/templates/assets/actions/variant-slots.ts +131 -28
  33. package/corpus/templates/assets/actions/view-screen.ts +9 -0
  34. package/corpus/templates/assets/app/components/generation/GenerationResults.tsx +425 -0
  35. package/corpus/templates/assets/app/components/layout/Header.tsx +3 -1
  36. package/corpus/templates/assets/app/components/layout/Layout.tsx +5 -0
  37. package/corpus/templates/assets/app/components/layout/Sidebar.tsx +4 -6
  38. package/corpus/templates/assets/app/hooks/use-navigation-state.ts +47 -21
  39. package/corpus/templates/assets/app/i18n-data.ts +1815 -0
  40. package/corpus/templates/assets/app/lib/libraries.ts +6 -0
  41. package/corpus/templates/assets/app/lib/picker-chat-handoff.ts +71 -0
  42. package/corpus/templates/assets/app/routes/_index.tsx +4 -0
  43. package/corpus/templates/assets/app/routes/asset.$id.tsx +2 -2
  44. package/corpus/templates/assets/app/routes/audit.tsx +1 -1
  45. package/corpus/templates/assets/app/routes/brand-kits.$id.tsx +1557 -2164
  46. package/corpus/templates/assets/app/routes/brand-kits._index.tsx +7 -191
  47. package/corpus/templates/assets/app/routes/brand-kits.tsx +1 -5
  48. package/corpus/templates/assets/app/routes/libraries.tsx +4 -4
  49. package/corpus/templates/assets/app/routes/library.$id.tsx +9 -7
  50. package/corpus/templates/assets/app/routes/library.tsx +1454 -175
  51. package/corpus/templates/assets/server/db/index.ts +1 -1
  52. package/corpus/templates/assets/server/lib/generation.ts +86 -15
  53. package/corpus/templates/assets/server/plugins/agent-chat.ts +196 -0
  54. package/corpus/templates/assets/server/plugins/db.ts +5 -0
  55. package/corpus/templates/assets/shared/api.ts +6 -3
  56. package/dist/agent/production-agent.d.ts.map +1 -1
  57. package/dist/agent/production-agent.js +50 -29
  58. package/dist/agent/production-agent.js.map +1 -1
  59. package/dist/agent/types.d.ts +21 -0
  60. package/dist/agent/types.d.ts.map +1 -1
  61. package/dist/agent/types.js.map +1 -1
  62. package/dist/client/AgentPanel.d.ts +5 -1
  63. package/dist/client/AgentPanel.d.ts.map +1 -1
  64. package/dist/client/AgentPanel.js +2 -2
  65. package/dist/client/AgentPanel.js.map +1 -1
  66. package/dist/client/AssistantChat.d.ts +6 -0
  67. package/dist/client/AssistantChat.d.ts.map +1 -1
  68. package/dist/client/AssistantChat.js +15 -3
  69. package/dist/client/AssistantChat.js.map +1 -1
  70. package/dist/client/agent-chat.d.ts +32 -0
  71. package/dist/client/agent-chat.d.ts.map +1 -1
  72. package/dist/client/agent-chat.js +113 -0
  73. package/dist/client/agent-chat.js.map +1 -1
  74. package/dist/client/composer/TiptapComposer.d.ts +2 -1
  75. package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
  76. package/dist/client/composer/TiptapComposer.js +228 -56
  77. package/dist/client/composer/TiptapComposer.js.map +1 -1
  78. package/dist/client/composer/extensions/MentionReference.d.ts.map +1 -1
  79. package/dist/client/composer/extensions/MentionReference.js +3 -0
  80. package/dist/client/composer/extensions/MentionReference.js.map +1 -1
  81. package/dist/client/composer/types.d.ts +21 -0
  82. package/dist/client/composer/types.d.ts.map +1 -1
  83. package/dist/client/composer/types.js.map +1 -1
  84. package/dist/client/index.d.ts +1 -1
  85. package/dist/client/index.d.ts.map +1 -1
  86. package/dist/client/index.js +1 -1
  87. package/dist/client/index.js.map +1 -1
  88. package/dist/notifications/routes.d.ts +1 -1
  89. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  90. package/dist/server/agent-chat-plugin.js +5 -0
  91. package/dist/server/agent-chat-plugin.js.map +1 -1
  92. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  93. package/dist/server/request-context.d.ts +8 -0
  94. package/dist/server/request-context.d.ts.map +1 -1
  95. package/dist/server/request-context.js.map +1 -1
  96. package/package.json +1 -1
@@ -92,6 +92,34 @@ export interface AgentChatContextState {
92
92
  items: AgentChatContextItem[];
93
93
  updatedAt: number;
94
94
  }
95
+ export interface AgentComposerReference {
96
+ label: string;
97
+ icon?: string;
98
+ source?: string;
99
+ refType: string;
100
+ refId?: string | null;
101
+ refPath?: string | null;
102
+ /** Stable composer slot this reference occupies. Slot references replace older values. */
103
+ slotKey?: string;
104
+ /** Short label shown before the selected value in the composer chip. */
105
+ slotLabel?: string;
106
+ /** Additional app-defined data used by the client for filtering and grouping. */
107
+ metadata?: Record<string, unknown>;
108
+ /** Slots to remove when this reference is inserted or removed. */
109
+ clearsSlots?: string[];
110
+ /** Additional references to insert before this one. */
111
+ relatedReferences?: AgentComposerReference[];
112
+ }
113
+ export interface AgentComposerReferenceInsertOptions {
114
+ /**
115
+ * Whether to open the agent sidebar before inserting the reference.
116
+ * Defaults to false so contextual auto-tags can stay quiet.
117
+ */
118
+ openSidebar?: boolean;
119
+ }
120
+ export interface AgentComposerReferenceInsertPayload extends AgentComposerReference {
121
+ insertMessageId: string;
122
+ }
95
123
  export interface AgentChatContextMutationOptions {
96
124
  /**
97
125
  * Whether to open the agent sidebar if it's currently hidden.
@@ -107,6 +135,8 @@ export declare const AGENT_CHAT_CONTEXT_CHANGED_EVENT = "agentNative.chatContext
107
135
  export declare const AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE = "agentNative.setChatContext";
108
136
  export declare const AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE = "agentNative.removeChatContext";
109
137
  export declare const AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE = "agentNative.clearChatContext";
138
+ export declare const AGENT_CHAT_INSERT_REFERENCE_MESSAGE_TYPE = "agentNative.insertComposerReference";
139
+ export declare const AGENT_CHAT_INSERT_REFERENCE_EVENT = "agentNative:insert-composer-reference";
110
140
  /** Generate a unique tab ID */
111
141
  export declare function generateTabId(): string;
112
142
  /** Unclaimed self-submit payloads, for the panel to replay once it mounts. */
@@ -127,6 +157,7 @@ export declare function subscribeAgentChatContext(listener: () => void): () => v
127
157
  export declare function refreshAgentChatContext(): Promise<AgentChatContextState>;
128
158
  export declare function formatAgentChatContextItemsForPrompt(items: readonly AgentChatContextItem[]): string;
129
159
  export declare function appendAgentChatContextToMessage(message: string, context: string): string;
160
+ export declare function normalizeAgentComposerReference(value: unknown): AgentComposerReference | null;
130
161
  /** A normalized `agentNative.submitChat` payload — decode via {@link parseSubmitChatMessage}. */
131
162
  export interface ParsedSubmitChat {
132
163
  /** Visible prompt text (non-empty). */
@@ -163,6 +194,7 @@ export declare function setAgentChatContextItem(opts: AgentChatContextSetOptions
163
194
  export declare const setContextToAgentChat: typeof setAgentChatContextItem;
164
195
  /** @deprecated Use `setAgentChatContextItem` instead. */
165
196
  export declare const addContextToAgentChat: typeof setAgentChatContextItem;
197
+ export declare function insertAgentComposerReference(ref: AgentComposerReference, options?: AgentComposerReferenceInsertOptions): void;
166
198
  export declare function removeAgentChatContextItem(keyOrOpts: string | AgentChatContextRemoveOptions): void;
167
199
  export declare function clearAgentChatContext(opts?: AgentChatContextMutationOptions): void;
168
200
  export declare function _resetAgentChatContextForTests(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-chat.d.ts","sourceRoot":"","sources":["../../src/client/agent-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAmBrE,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,MAAM,CAAC;AAElD,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,yCAAyC;IACzC,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IACnC,wEAAwE;IACxE,MAAM,CAAC,EAAE,M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,6BAA6B,GAChD,IAAI,CAeN;AAED,wBAAgB,qBAAqB,CACnC,IAAI,GAAE,+BAAoC,GACzC,IAAI,CAQN;AAED,wBAAgB,8BAA8B,IAAI,IAAI,CAGrD"}
@@ -18,6 +18,8 @@ export const AGENT_CHAT_CONTEXT_CHANGED_EVENT = "agentNative.chatContextChanged"
18
18
  export const AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE = "agentNative.setChatContext";
19
19
  export const AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE = "agentNative.removeChatContext";
20
20
  export const AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE = "agentNative.clearChatContext";
21
+ export const AGENT_CHAT_INSERT_REFERENCE_MESSAGE_TYPE = "agentNative.insertComposerReference";
22
+ export const AGENT_CHAT_INSERT_REFERENCE_EVENT = "agentNative:insert-composer-reference";
21
23
  const AGENT_PANEL_PREPARE_EVENT = "agent-panel:prepare";
22
24
  let agentChatContextState = {
23
25
  items: [],
@@ -222,6 +224,70 @@ export function appendAgentChatContextToMessage(message, context) {
222
224
  return message;
223
225
  return `${message.trim()}\n\n<context>\n${trimmedContext}\n</context>`;
224
226
  }
227
+ function normalizeStringArray(value) {
228
+ if (!Array.isArray(value))
229
+ return undefined;
230
+ const normalized = value
231
+ .filter((item) => typeof item === "string")
232
+ .map((item) => item.trim())
233
+ .filter(Boolean);
234
+ return normalized.length > 0 ? normalized : undefined;
235
+ }
236
+ function normalizeMetadata(value) {
237
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
238
+ return undefined;
239
+ }
240
+ return value;
241
+ }
242
+ function normalizeAgentComposerReferenceInternal(value, depth) {
243
+ if (typeof value !== "object" || value === null)
244
+ return null;
245
+ const candidate = value;
246
+ const label = typeof candidate.label === "string" ? candidate.label.trim() : "";
247
+ const refType = typeof candidate.refType === "string" ? candidate.refType.trim() : "";
248
+ if (!label || !refType)
249
+ return null;
250
+ const normalized = {
251
+ label,
252
+ icon: typeof candidate.icon === "string" && candidate.icon.trim()
253
+ ? candidate.icon.trim()
254
+ : undefined,
255
+ source: typeof candidate.source === "string" && candidate.source.trim()
256
+ ? candidate.source.trim()
257
+ : undefined,
258
+ refType,
259
+ refId: typeof candidate.refId === "string" && candidate.refId.trim()
260
+ ? candidate.refId.trim()
261
+ : null,
262
+ refPath: typeof candidate.refPath === "string" && candidate.refPath.trim()
263
+ ? candidate.refPath.trim()
264
+ : null,
265
+ };
266
+ const slotKey = typeof candidate.slotKey === "string" ? candidate.slotKey.trim() : "";
267
+ if (slotKey)
268
+ normalized.slotKey = slotKey;
269
+ const slotLabel = typeof candidate.slotLabel === "string" ? candidate.slotLabel.trim() : "";
270
+ if (slotLabel)
271
+ normalized.slotLabel = slotLabel;
272
+ const metadata = normalizeMetadata(candidate.metadata);
273
+ if (metadata)
274
+ normalized.metadata = metadata;
275
+ const clearsSlots = normalizeStringArray(candidate.clearsSlots);
276
+ if (clearsSlots)
277
+ normalized.clearsSlots = clearsSlots;
278
+ if (depth < 3 && Array.isArray(candidate.relatedReferences)) {
279
+ const relatedReferences = candidate.relatedReferences
280
+ .map((item) => normalizeAgentComposerReferenceInternal(item, depth + 1))
281
+ .filter((item) => item !== null);
282
+ if (relatedReferences.length > 0) {
283
+ normalized.relatedReferences = relatedReferences;
284
+ }
285
+ }
286
+ return normalized;
287
+ }
288
+ export function normalizeAgentComposerReference(value) {
289
+ return normalizeAgentComposerReferenceInternal(value, 0);
290
+ }
225
291
  function postAgentChatContextMessage(type, data, options) {
226
292
  if (typeof window === "undefined")
227
293
  return;
@@ -252,6 +318,42 @@ function postAgentChatContextMessage(type, data, options) {
252
318
  postToTarget();
253
319
  }
254
320
  }
321
+ function postAgentChatReferenceMessage(payload, options) {
322
+ if (typeof window === "undefined")
323
+ return;
324
+ const message = {
325
+ type: AGENT_CHAT_INSERT_REFERENCE_MESSAGE_TYPE,
326
+ data: payload,
327
+ };
328
+ const targetSelf = isInBuilderFrame() || isDirectMcpAppEmbedSession();
329
+ const target = targetSelf
330
+ ? window
331
+ : window.parent !== window
332
+ ? window.parent
333
+ : window;
334
+ const targetOrigin = targetSelf
335
+ ? window.location.origin
336
+ : getFramePostMessageTargetOrigin() || window.location.origin;
337
+ if (options.openSidebar) {
338
+ window.dispatchEvent(new CustomEvent("agent-panel:set-mode", {
339
+ detail: { mode: "chat" },
340
+ }));
341
+ window.dispatchEvent(new CustomEvent("agent-panel:open"));
342
+ }
343
+ else {
344
+ window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));
345
+ }
346
+ window.dispatchEvent(new CustomEvent(AGENT_CHAT_INSERT_REFERENCE_EVENT, {
347
+ detail: payload,
348
+ }));
349
+ const postToTarget = () => target.postMessage(message, targetOrigin);
350
+ if (target === window) {
351
+ setTimeout(postToTarget, 0);
352
+ }
353
+ else {
354
+ postToTarget();
355
+ }
356
+ }
255
357
  function isMcpAppChatBridgeEnabled() {
256
358
  if (typeof window === "undefined" || window.parent === window)
257
359
  return false;
@@ -437,6 +539,17 @@ export function setAgentChatContextItem(opts) {
437
539
  export const setContextToAgentChat = setAgentChatContextItem;
438
540
  /** @deprecated Use `setAgentChatContextItem` instead. */
439
541
  export const addContextToAgentChat = setAgentChatContextItem;
542
+ export function insertAgentComposerReference(ref, options = {}) {
543
+ const normalized = normalizeAgentComposerReference(ref);
544
+ if (!normalized || typeof window === "undefined")
545
+ return;
546
+ postAgentChatReferenceMessage({
547
+ ...normalized,
548
+ insertMessageId: `reference-${Date.now()}-${Math.random()
549
+ .toString(36)
550
+ .slice(2, 8)}`,
551
+ }, { openSidebar: options.openSidebar === true });
552
+ }
440
553
  export function removeAgentChatContextItem(keyOrOpts) {
441
554
  const key = typeof keyOrOpts === "string" ? keyOrOpts.trim() : keyOrOpts.key.trim();
442
555
  if (!key || typeof window === "undefined")
@@ -1 +1 @@
1
- {"version":3,"file":"agent-chat.js","sourceRoot":"","sources":["../../src/client/agent-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE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D,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAE7D,MAAM,UAAU,0BAA0B,CACxC,SAAiD;IAEjD,MAAM,GAAG,GACP,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IAC1E,IAAI,CAAC,GAAG,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO;IAClD,MAAM,WAAW,GACf,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,KAAK,IAAI,CAAC;IAEzE,4BAA4B,CAC1B,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,CAC/D,CAAC;IACF,2BAA2B,CACzB,sCAAsC,EACtC,EAAE,GAAG,EAAE,EACP,EAAE,WAAW,EAAE,CAChB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,IAAI,GAAoC,EAAE;IAE1C,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO;IAC1C,4BAA4B,CAAC,EAAE,CAAC,CAAC;IACjC,2BAA2B,CACzB,qCAAqC,EACrC,EAAE,EACF,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,KAAK,IAAI,EAAE,CAC3C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,8BAA8B;IAC5C,qBAAqB,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACpD,+BAA+B,EAAE,CAAC;AACpC,CAAC","sourcesContent":["/**\n * Agent Chat Bridge (browser)\n *\n * Sends structured messages to the agent chat from UI interactions.\n * Messages are sent via postMessage to the parent window (or self if top-level).\n * Builder frames are special: code requests go to Builder, but content prompts\n * stay inside the embedded app so its own AgentSidebar can receive them.\n */\n\nimport type { ReasoningEffort } from \"../shared/reasoning-effort.js\";\nimport { agentNativePath } from \"./api-path.js\";\nimport {\n isInBuilderFrame,\n isTrustedBuilderMessage,\n sendToBuilderChat,\n} from \"./builder-frame.js\";\nimport {\n isEmbedAuthActive,\n isEmbedMcpChatBridgeActive,\n markEmbedMcpChatBridgeActive,\n readEmbedMcpChatBridgeFlagFromUrl,\n} from \"./embed-auth.js\";\nimport {\n getFramePostMessageTargetOrigin,\n isTrustedFrameMessage,\n} from \"./frame.js\";\nimport { sendMcpAppHostMessage } from \"./mcp-app-host.js\";\n\nexport type AgentChatRequestMode = \"act\" | \"plan\";\n\nexport interface AgentChatMessage {\n /** The visible prompt message sent to the chat */\n message: string;\n /** Hidden context appended to the message (not shown in chat UI) */\n context?: string;\n /** true = auto-submit, false = prefill only, omit = use project setting */\n submit?: boolean;\n /** Optional project slug for structured context */\n projectSlug?: string;\n /** Optional preset name for downstream consumers */\n preset?: string;\n /** Optional reference image paths */\n referenceImagePaths?: string[];\n /** Optional uploaded reference images */\n uploadedReferenceImages?: string[];\n /** Optional image data URLs to include in the submitted chat message */\n images?: string[];\n /** Stable tab identifier — auto-generated if omitted */\n tabId?: string;\n /**\n * Message routing type:\n * - \"content\" (default): stays in the embedded app agent for content/data operations\n * - \"code\": routes to the code editing frame (Agent Native Desktop or Builder.io)\n *\n * When type is \"code\" and no frame is connected, a dialog is shown.\n * `requiresCode: true` is treated as `type: \"code\"` for backward compatibility.\n */\n type?: \"content\" | \"code\";\n /** @deprecated Use `type: \"code\"` instead. If true, treated as `type: \"code\"`. */\n requiresCode?: boolean;\n /** Model preference for this sub-agent (e.g. \"claude-haiku-4-5\"). Uses default if omitted */\n model?: string;\n /** Engine preference paired with model for cross-provider switches. */\n engine?: string;\n /** Reasoning effort preference paired with model. */\n effort?: ReasoningEffort;\n /**\n * Execution mode for this submitted turn. When omitted, sendToAgentChat\n * snapshots the current AgentPanel mode from localStorage when available.\n */\n mode?: AgentChatRequestMode;\n /** @deprecated Use `mode` instead. */\n requestMode?: AgentChatRequestMode;\n /** Scoped system prompt additions for this sub-agent */\n instructions?: string;\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true — submitting a chat should make the response visible.\n * Pass `false` for background/silent sends that shouldn't pop the UI open.\n */\n openSidebar?: boolean;\n /**\n * When true, opens a new chat tab before sending the message.\n * Use for creation requests (create tool, dashboard, etc.) that deserve\n * their own isolated thread rather than cluttering an existing conversation.\n */\n newTab?: boolean;\n /**\n * When true with newTab, creates the tab in the background without\n * focusing it or opening the sidebar. The message runs silently.\n */\n background?: boolean;\n}\n\nexport interface AgentChatContextItem {\n /** Stable key used to replace an existing context nugget. */\n key: string;\n /** Short label shown in the composer context chip. */\n title: string;\n /** Hidden context included with the next submitted prompt. */\n context: string;\n}\n\nexport interface AgentChatContextSetOptions extends AgentChatContextItem {\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true so the user can see the staged context.\n */\n openSidebar?: boolean;\n}\n\n/** @deprecated Use `AgentChatContextSetOptions` instead. */\nexport type AgentChatContextMessage = AgentChatContextSetOptions;\n\nexport interface AgentChatContextState {\n items: AgentChatContextItem[];\n updatedAt: number;\n}\n\nexport interface AgentChatContextMutationOptions {\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true for set/add and false for remove/clear.\n */\n openSidebar?: boolean;\n}\n\nexport interface AgentChatContextRemoveOptions extends AgentChatContextMutationOptions {\n /** Stable key of the staged context nugget to remove. */\n key: string;\n}\n\nconst AGENT_CHAT_MESSAGE_TYPE = \"agentNative.submitChat\";\nconst AGENT_CHAT_CONTEXT_STATE_KEY = \"agent-chat-context\";\nconst AGENT_CHAT_EXEC_MODE_KEY = \"agent-native-exec-mode\";\nexport const AGENT_CHAT_CONTEXT_CHANGED_EVENT =\n \"agentNative.chatContextChanged\";\nexport const AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE = \"agentNative.setChatContext\";\nexport const AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE =\n \"agentNative.removeChatContext\";\nexport const AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE =\n \"agentNative.clearChatContext\";\nconst AGENT_PANEL_PREPARE_EVENT = \"agent-panel:prepare\";\n\nlet agentChatContextState: AgentChatContextState = {\n items: [],\n updatedAt: 0,\n};\nconst agentChatContextListeners = new Set<() => void>();\n\n/**\n * Listen for chatRunning messages from the frame (postMessage)\n * and re-dispatch as a CustomEvent so hooks like useAgentChatGenerating() work.\n */\nif (typeof window !== \"undefined\") {\n window.addEventListener(\"message\", (event) => {\n if (!isTrustedFrameMessage(event) && !isTrustedBuilderMessage(event)) {\n return;\n }\n if (\n event.data?.type === \"agentNative.chatRunning\" ||\n event.data?.type === \"builder.chatRunning\"\n ) {\n window.dispatchEvent(\n new CustomEvent(\"agentNative.chatRunning\", {\n detail: event.data.detail ?? event.data.data,\n }),\n );\n }\n });\n}\n\n/** Generate a unique tab ID */\nexport function generateTabId(): string {\n return `chat-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\n/** Unique id for one submitted message, used to dedup live + replayed sends. */\nfunction generateSubmitMessageId(): string {\n return `submit-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\n// Self-submit buffer: same-window sends post to `window` itself, but the\n// receiver is lazy-loaded and may not be listening yet. Buffer each submit so\n// the panel can replay it on mount; claimAgentChatSubmit dedups by id so a\n// submit received both live and replayed is delivered exactly once.\ninterface BufferedSelfSubmit {\n id: string;\n data: Record<string, unknown>;\n at: number;\n}\n\nconst SELF_SUBMIT_BUFFER_TTL_MS = 8000;\nconst bufferedSelfSubmits: BufferedSelfSubmit[] = [];\nconst claimedSubmitIds = new Set<string>();\n\nfunction pruneSelfSubmitBuffer(now: number): void {\n for (let i = bufferedSelfSubmits.length - 1; i >= 0; i -= 1) {\n if (now - bufferedSelfSubmits[i].at > SELF_SUBMIT_BUFFER_TTL_MS) {\n const [removed] = bufferedSelfSubmits.splice(i, 1);\n if (removed) claimedSubmitIds.delete(removed.id);\n }\n }\n}\n\nfunction bufferSelfSubmit(data: Record<string, unknown>): void {\n const id =\n typeof data.submitMessageId === \"string\" ? data.submitMessageId : undefined;\n if (!id) return;\n const now = Date.now();\n pruneSelfSubmitBuffer(now);\n bufferedSelfSubmits.push({ id, data, at: now });\n}\n\n/** Unclaimed self-submit payloads, for the panel to replay once it mounts. */\nexport function drainBufferedAgentChatSubmits(): Array<\n Record<string, unknown>\n> {\n pruneSelfSubmitBuffer(Date.now());\n return bufferedSelfSubmits\n .filter((entry) => !claimedSubmitIds.has(entry.id))\n .map((entry) => entry.data);\n}\n\n/** Claim a submit; false if already handled. Idless submits always pass. */\nexport function claimAgentChatSubmit(id: string | undefined): boolean {\n if (!id) return true;\n if (claimedSubmitIds.has(id)) return false;\n claimedSubmitIds.add(id);\n return true;\n}\n\n/** Test-only: reset the self-submit buffer and claim set. */\nexport function _resetAgentChatSubmitBufferForTests(): void {\n bufferedSelfSubmits.length = 0;\n claimedSubmitIds.clear();\n}\n\nexport function normalizeAgentChatContextItem(\n item: unknown,\n): AgentChatContextItem | null {\n if (typeof item !== \"object\" || item === null) return null;\n const candidate = item as Partial<AgentChatContextItem>;\n if (\n typeof candidate.key !== \"string\" ||\n typeof candidate.context !== \"string\" ||\n typeof candidate.title !== \"string\"\n ) {\n return null;\n }\n const key = candidate.key.trim();\n const context = candidate.context.trim();\n if (!key || !context) return null;\n return {\n key,\n title: candidate.title.trim() || key,\n context,\n };\n}\n\nexport function normalizeAgentChatContextItems(\n items: unknown,\n): AgentChatContextItem[] {\n if (!Array.isArray(items)) return [];\n const deduped = new Map<string, AgentChatContextItem>();\n for (const rawItem of items) {\n const item = normalizeAgentChatContextItem(rawItem);\n if (!item) continue;\n deduped.set(item.key, item);\n }\n return [...deduped.values()];\n}\n\nfunction normalizeAgentChatContextState(\n value: unknown,\n): AgentChatContextState | null {\n if (!value || typeof value !== \"object\") return null;\n const raw = value as {\n value?: unknown;\n items?: unknown;\n updatedAt?: unknown;\n };\n const candidate =\n raw.value && typeof raw.value === \"object\"\n ? (raw.value as { items?: unknown; updatedAt?: unknown })\n : raw;\n const items = normalizeAgentChatContextItems(candidate.items);\n return {\n items,\n updatedAt:\n typeof candidate.updatedAt === \"number\" ? candidate.updatedAt : 0,\n };\n}\n\nfunction withReplacedAgentChatContextItem(\n items: readonly AgentChatContextItem[],\n item: AgentChatContextItem,\n): AgentChatContextItem[] {\n const index = items.findIndex((current) => current.key === item.key);\n if (index === -1) return [...items, item];\n return items.map((current, currentIndex) =>\n currentIndex === index ? item : current,\n );\n}\n\nfunction notifyAgentChatContextListeners(): void {\n for (const listener of agentChatContextListeners) listener();\n}\n\nfunction persistAgentChatContextState(state: AgentChatContextState): void {\n if (typeof window === \"undefined\" || typeof fetch !== \"function\") return;\n fetch(\n agentNativePath(\n `/_agent-native/application-state/${AGENT_CHAT_CONTEXT_STATE_KEY}`,\n ),\n {\n method: \"PUT\",\n keepalive: true,\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(state),\n },\n ).catch(() => {});\n}\n\nexport function publishAgentChatContextItems(\n items: readonly AgentChatContextItem[],\n options?: { persist?: boolean; updatedAt?: number },\n): AgentChatContextState {\n const next: AgentChatContextState = {\n items: normalizeAgentChatContextItems([...items]),\n updatedAt: options?.updatedAt ?? Date.now(),\n };\n if (next.updatedAt < agentChatContextState.updatedAt) {\n return agentChatContextState;\n }\n agentChatContextState = next;\n notifyAgentChatContextListeners();\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(AGENT_CHAT_CONTEXT_CHANGED_EVENT, {\n detail: next,\n }),\n );\n }\n if (options?.persist !== false) {\n persistAgentChatContextState(next);\n }\n return next;\n}\n\nexport function getAgentChatContextState(): AgentChatContextState {\n return agentChatContextState;\n}\n\nexport function listAgentChatContext(): AgentChatContextItem[] {\n return [...agentChatContextState.items];\n}\n\nexport function subscribeAgentChatContext(listener: () => void): () => void {\n agentChatContextListeners.add(listener);\n return () => {\n agentChatContextListeners.delete(listener);\n };\n}\n\nexport async function refreshAgentChatContext(): Promise<AgentChatContextState> {\n if (typeof window === \"undefined\" || typeof fetch !== \"function\") {\n return agentChatContextState;\n }\n try {\n const res = await fetch(\n agentNativePath(\n `/_agent-native/application-state/${AGENT_CHAT_CONTEXT_STATE_KEY}`,\n ),\n );\n if (!res.ok || res.status === 204) return agentChatContextState;\n const text = await res.text();\n if (!text) return agentChatContextState;\n const state = normalizeAgentChatContextState(JSON.parse(text));\n if (!state) return agentChatContextState;\n return publishAgentChatContextItems(state.items, {\n persist: false,\n updatedAt: state.updatedAt,\n });\n } catch {\n return agentChatContextState;\n }\n}\n\nexport function formatAgentChatContextItemsForPrompt(\n items: readonly AgentChatContextItem[],\n): string {\n return items\n .map(normalizeAgentChatContextItem)\n .filter((item): item is AgentChatContextItem => item !== null)\n .map((item) => [`## ${item.title}`, item.context].join(\"\\n\"))\n .join(\"\\n\\n\");\n}\n\nexport function appendAgentChatContextToMessage(\n message: string,\n context: string,\n): string {\n const trimmedContext = context.trim();\n if (!trimmedContext) return message;\n return `${message.trim()}\\n\\n<context>\\n${trimmedContext}\\n</context>`;\n}\n\nfunction postAgentChatContextMessage(\n type:\n | typeof AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE\n | typeof AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE\n | typeof AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE,\n data: unknown,\n options: { openSidebar: boolean },\n): void {\n if (typeof window === \"undefined\") return;\n\n const payload = { type, data };\n const targetSelf = isInBuilderFrame() || isDirectMcpAppEmbedSession();\n const target = targetSelf\n ? window\n : window.parent !== window\n ? window.parent\n : window;\n const targetOrigin = targetSelf\n ? window.location.origin\n : getFramePostMessageTargetOrigin() || window.location.origin;\n\n if (options.openSidebar) {\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:set-mode\", {\n detail: { mode: \"chat\" },\n }),\n );\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n } else {\n window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));\n }\n\n const postToTarget = () => target.postMessage(payload, targetOrigin);\n if (target === window) {\n setTimeout(postToTarget, 0);\n } else {\n postToTarget();\n }\n}\n\nfunction isMcpAppChatBridgeEnabled(): boolean {\n if (typeof window === \"undefined\" || window.parent === window) return false;\n if (readEmbedMcpChatBridgeFlagFromUrl()) markEmbedMcpChatBridgeActive();\n return isEmbedMcpChatBridgeActive() && isEmbedAuthActive();\n}\n\nfunction isDirectMcpAppEmbedSession(): boolean {\n if (typeof window === \"undefined\" || window.parent === window) return false;\n if (readEmbedMcpChatBridgeFlagFromUrl()) markEmbedMcpChatBridgeActive();\n return isEmbedAuthActive() && !isEmbedMcpChatBridgeActive();\n}\n\nfunction dispatchAgentChatRunning(isRunning: boolean): void {\n if (typeof window === \"undefined\") return;\n window.dispatchEvent(\n new CustomEvent(\"agentNative.chatRunning\", {\n detail: { isRunning },\n }),\n );\n}\n\nfunction normalizeAgentChatRequestMode(\n value: unknown,\n): AgentChatRequestMode | undefined {\n return value === \"act\" || value === \"plan\" ? value : undefined;\n}\n\n/** A normalized `agentNative.submitChat` payload — decode via {@link parseSubmitChatMessage}. */\nexport interface ParsedSubmitChat {\n /** Visible prompt text (non-empty). */\n message: string;\n context?: string;\n /** Submit (true) or prefill only (false); defaults to true. */\n submit: boolean;\n openSidebar?: boolean;\n model?: string;\n /** Raw effort hint; the receiver validates it against the model. */\n effort?: unknown;\n newTab?: boolean;\n background?: boolean;\n tabId?: string;\n images?: string[];\n /** Mode as sent; the receiver falls back to its exec mode when undefined. */\n requestMode?: AgentChatRequestMode;\n /** Id used to dedup the live post against a cold-start replay. */\n submitMessageId?: string;\n}\n\n/** Decode a `message` event into a submit payload, or null if it isn't one / has no text. */\nexport function parseSubmitChatMessage(\n event: MessageEvent,\n): ParsedSubmitChat | null {\n const envelope =\n event.data && typeof event.data === \"object\"\n ? (event.data as { type?: unknown; data?: unknown })\n : null;\n if (!envelope || envelope.type !== AGENT_CHAT_MESSAGE_TYPE) return null;\n const raw =\n envelope.data && typeof envelope.data === \"object\"\n ? (envelope.data as Record<string, unknown>)\n : null;\n if (!raw) return null;\n const message = typeof raw.message === \"string\" ? raw.message : \"\";\n if (!message) return null;\n const images = Array.isArray(raw.images)\n ? raw.images.filter(\n (image): image is string =>\n typeof image === \"string\" && image.length > 0,\n )\n : undefined;\n return {\n message,\n context: typeof raw.context === \"string\" ? raw.context : undefined,\n submit: raw.submit !== false,\n openSidebar:\n typeof raw.openSidebar === \"boolean\" ? raw.openSidebar : undefined,\n model: typeof raw.model === \"string\" ? raw.model : undefined,\n effort: raw.effort,\n newTab: typeof raw.newTab === \"boolean\" ? raw.newTab : undefined,\n background:\n typeof raw.background === \"boolean\" ? raw.background : undefined,\n tabId: typeof raw.tabId === \"string\" ? raw.tabId : undefined,\n images,\n requestMode: normalizeAgentChatRequestMode(raw.requestMode ?? raw.mode),\n submitMessageId:\n typeof raw.submitMessageId === \"string\" ? raw.submitMessageId : undefined,\n };\n}\n\nfunction normalizeStoredAgentChatExecMode(\n value: string | null,\n): AgentChatRequestMode | undefined {\n if (value === \"plan\") return \"plan\";\n if (value === \"build\" || value === \"act\") return \"act\";\n return undefined;\n}\n\nfunction readStoredAgentChatRequestMode(): AgentChatRequestMode | undefined {\n if (typeof window === \"undefined\") return undefined;\n try {\n const storage = window.localStorage;\n const saved = normalizeStoredAgentChatExecMode(\n storage.getItem(AGENT_CHAT_EXEC_MODE_KEY),\n );\n if (saved) return saved;\n const scopedModes: AgentChatRequestMode[] = [];\n for (let index = 0; index < storage.length; index += 1) {\n const key = storage.key(index);\n if (!key?.startsWith(`${AGENT_CHAT_EXEC_MODE_KEY}:`)) continue;\n const scopedSaved = normalizeStoredAgentChatExecMode(\n storage.getItem(key),\n );\n if (scopedSaved) scopedModes.push(scopedSaved);\n }\n if (scopedModes.length === 1) return scopedModes[0];\n } catch {}\n return undefined;\n}\n\n/**\n * Send a message to the agent chat via postMessage.\n * Returns the stable tabId for tracking this chat run.\n */\nexport function sendToAgentChat(opts: AgentChatMessage): string {\n const tabId = opts.tabId ?? generateTabId();\n const isCodeRequest = opts.type === \"code\" || opts.requiresCode === true;\n const requestMode =\n normalizeAgentChatRequestMode(opts.requestMode ?? opts.mode) ??\n readStoredAgentChatRequestMode();\n if (isCodeRequest && isInBuilderFrame()) {\n sendToBuilderChat({\n message: opts.message,\n context: opts.context,\n submit: opts.submit,\n ...(requestMode ? { mode: requestMode, requestMode } : {}),\n });\n return tabId;\n }\n\n const submitMessageId = generateSubmitMessageId();\n const payload = {\n type: AGENT_CHAT_MESSAGE_TYPE,\n data: {\n ...opts,\n tabId,\n submitMessageId,\n ...(requestMode ? { mode: requestMode, requestMode } : {}),\n },\n };\n\n if (opts.submit !== false && isMcpAppChatBridgeEnabled()) {\n const directHostMessage = sendMcpAppHostMessage({\n message: opts.message,\n context: opts.context,\n ...(requestMode ? { mode: requestMode, requestMode } : {}),\n });\n if (directHostMessage) {\n void Promise.resolve(directHostMessage)\n .then((ok) => {\n if (!ok) {\n window.parent.postMessage(\n payload,\n getFramePostMessageTargetOrigin() || \"*\",\n );\n }\n })\n .finally(() => {\n dispatchAgentChatRunning(false);\n });\n return tabId;\n }\n window.parent.postMessage(\n payload,\n getFramePostMessageTargetOrigin() || \"*\",\n );\n return tabId;\n }\n\n const shouldOpenSidebar = opts.openSidebar !== false && !opts.background;\n\n const targetSelf =\n !isCodeRequest && (isInBuilderFrame() || isDirectMcpAppEmbedSession());\n const target = targetSelf\n ? window\n : window.parent !== window\n ? window.parent\n : window;\n const targetOrigin = targetSelf\n ? window.location.origin\n : getFramePostMessageTargetOrigin() || window.location.origin;\n if (shouldOpenSidebar) {\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:set-mode\", {\n detail: { mode: \"chat\" },\n }),\n );\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n } else if (!isCodeRequest) {\n window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));\n }\n\n const postToTarget = () => target.postMessage(payload, targetOrigin);\n\n // Same-window: defer one tick so a sidebar mounting now can attach its\n // listener, and buffer the submit so the lazy panel can replay it if it\n // mounts later. The live post and the replay dedup by submitMessageId.\n if (!isCodeRequest && target === window) {\n bufferSelfSubmit(payload.data);\n setTimeout(postToTarget, 0);\n } else {\n postToTarget();\n }\n return tabId;\n}\n\n/**\n * Add or replace a keyed context nugget in the active agent chat composer.\n * The context is not submitted until the user sends the prompt.\n */\nexport function setAgentChatContextItem(\n opts: AgentChatContextSetOptions,\n): void {\n const item = normalizeAgentChatContextItem(opts);\n if (!item || typeof window === \"undefined\") return;\n\n publishAgentChatContextItems(\n withReplacedAgentChatContextItem(agentChatContextState.items, item),\n );\n postAgentChatContextMessage(AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE, item, {\n openSidebar: opts.openSidebar !== false,\n });\n}\n\n/** @deprecated Use `setAgentChatContextItem` instead. */\nexport const setContextToAgentChat = setAgentChatContextItem;\n\n/** @deprecated Use `setAgentChatContextItem` instead. */\nexport const addContextToAgentChat = setAgentChatContextItem;\n\nexport function removeAgentChatContextItem(\n keyOrOpts: string | AgentChatContextRemoveOptions,\n): void {\n const key =\n typeof keyOrOpts === \"string\" ? keyOrOpts.trim() : keyOrOpts.key.trim();\n if (!key || typeof window === \"undefined\") return;\n const openSidebar =\n typeof keyOrOpts === \"string\" ? false : keyOrOpts.openSidebar === true;\n\n publishAgentChatContextItems(\n agentChatContextState.items.filter((item) => item.key !== key),\n );\n postAgentChatContextMessage(\n AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE,\n { key },\n { openSidebar },\n );\n}\n\nexport function clearAgentChatContext(\n opts: AgentChatContextMutationOptions = {},\n): void {\n if (typeof window === \"undefined\") return;\n publishAgentChatContextItems([]);\n postAgentChatContextMessage(\n AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE,\n {},\n { openSidebar: opts.openSidebar === true },\n );\n}\n\nexport function _resetAgentChatContextForTests(): void {\n agentChatContextState = { items: [], updatedAt: 0 };\n notifyAgentChatContextListeners();\n}\n"]}
1
+ {"version":3,"file":"agent-chat.js","sourceRoot":"","sources":["../../src/client/agent-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,4BAA4B,EAC5B,iCAAiC,GAClC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAyI1D,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AACzD,MAAM,4BAA4B,GAAG,oBAAoB,CAAC;AAC1D,MAAM,wBAAwB,GAAG,wBAAwB,CAAC;AAC1D,MAAM,CAAC,MAAM,gCAAgC,GAC3C,gCAAgC,CAAC;AACnC,MAAM,CAAC,MAAM,mCAAmC,GAAG,4BAA4B,CAAC;AAChF,MAAM,CAAC,MAAM,sCAAsC,GACjD,+BAA+B,CAAC;AAClC,MAAM,CAAC,MAAM,qCAAqC,GAChD,8BAA8B,CAAC;AACjC,MAAM,CAAC,MAAM,wCAAwC,GACnD,qCAAqC,CAAC;AACxC,MAAM,CAAC,MAAM,iCAAiC,GAC5C,uCAAuC,CAAC;AAC1C,MAAM,yBAAyB,GAAG,qBAAqB,CAAC;AAExD,IAAI,qBAAqB,GAA0B;IACjD,KAAK,EAAE,EAAE;IACT,SAAS,EAAE,CAAC;CACb,CAAC;AACF,MAAM,yBAAyB,GAAG,IAAI,GAAG,EAAc,CAAC;AAExD;;;GAGG;AACH,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IAClC,MAAM,C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E,EACF,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,KAAK,IAAI,EAAE,CAC3C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,8BAA8B;IAC5C,qBAAqB,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACpD,+BAA+B,EAAE,CAAC;AACpC,CAAC","sourcesContent":["/**\n * Agent Chat Bridge (browser)\n *\n * Sends structured messages to the agent chat from UI interactions.\n * Messages are sent via postMessage to the parent window (or self if top-level).\n * Builder frames are special: code requests go to Builder, but content prompts\n * stay inside the embedded app so its own AgentSidebar can receive them.\n */\n\nimport type { ReasoningEffort } from \"../shared/reasoning-effort.js\";\nimport { agentNativePath } from \"./api-path.js\";\nimport {\n isInBuilderFrame,\n isTrustedBuilderMessage,\n sendToBuilderChat,\n} from \"./builder-frame.js\";\nimport {\n isEmbedAuthActive,\n isEmbedMcpChatBridgeActive,\n markEmbedMcpChatBridgeActive,\n readEmbedMcpChatBridgeFlagFromUrl,\n} from \"./embed-auth.js\";\nimport {\n getFramePostMessageTargetOrigin,\n isTrustedFrameMessage,\n} from \"./frame.js\";\nimport { sendMcpAppHostMessage } from \"./mcp-app-host.js\";\n\nexport type AgentChatRequestMode = \"act\" | \"plan\";\n\nexport interface AgentChatMessage {\n /** The visible prompt message sent to the chat */\n message: string;\n /** Hidden context appended to the message (not shown in chat UI) */\n context?: string;\n /** true = auto-submit, false = prefill only, omit = use project setting */\n submit?: boolean;\n /** Optional project slug for structured context */\n projectSlug?: string;\n /** Optional preset name for downstream consumers */\n preset?: string;\n /** Optional reference image paths */\n referenceImagePaths?: string[];\n /** Optional uploaded reference images */\n uploadedReferenceImages?: string[];\n /** Optional image data URLs to include in the submitted chat message */\n images?: string[];\n /** Stable tab identifier — auto-generated if omitted */\n tabId?: string;\n /**\n * Message routing type:\n * - \"content\" (default): stays in the embedded app agent for content/data operations\n * - \"code\": routes to the code editing frame (Agent Native Desktop or Builder.io)\n *\n * When type is \"code\" and no frame is connected, a dialog is shown.\n * `requiresCode: true` is treated as `type: \"code\"` for backward compatibility.\n */\n type?: \"content\" | \"code\";\n /** @deprecated Use `type: \"code\"` instead. If true, treated as `type: \"code\"`. */\n requiresCode?: boolean;\n /** Model preference for this sub-agent (e.g. \"claude-haiku-4-5\"). Uses default if omitted */\n model?: string;\n /** Engine preference paired with model for cross-provider switches. */\n engine?: string;\n /** Reasoning effort preference paired with model. */\n effort?: ReasoningEffort;\n /**\n * Execution mode for this submitted turn. When omitted, sendToAgentChat\n * snapshots the current AgentPanel mode from localStorage when available.\n */\n mode?: AgentChatRequestMode;\n /** @deprecated Use `mode` instead. */\n requestMode?: AgentChatRequestMode;\n /** Scoped system prompt additions for this sub-agent */\n instructions?: string;\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true — submitting a chat should make the response visible.\n * Pass `false` for background/silent sends that shouldn't pop the UI open.\n */\n openSidebar?: boolean;\n /**\n * When true, opens a new chat tab before sending the message.\n * Use for creation requests (create tool, dashboard, etc.) that deserve\n * their own isolated thread rather than cluttering an existing conversation.\n */\n newTab?: boolean;\n /**\n * When true with newTab, creates the tab in the background without\n * focusing it or opening the sidebar. The message runs silently.\n */\n background?: boolean;\n}\n\nexport interface AgentChatContextItem {\n /** Stable key used to replace an existing context nugget. */\n key: string;\n /** Short label shown in the composer context chip. */\n title: string;\n /** Hidden context included with the next submitted prompt. */\n context: string;\n}\n\nexport interface AgentChatContextSetOptions extends AgentChatContextItem {\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true so the user can see the staged context.\n */\n openSidebar?: boolean;\n}\n\n/** @deprecated Use `AgentChatContextSetOptions` instead. */\nexport type AgentChatContextMessage = AgentChatContextSetOptions;\n\nexport interface AgentChatContextState {\n items: AgentChatContextItem[];\n updatedAt: number;\n}\n\nexport interface AgentComposerReference {\n label: string;\n icon?: string;\n source?: string;\n refType: string;\n refId?: string | null;\n refPath?: string | null;\n /** Stable composer slot this reference occupies. Slot references replace older values. */\n slotKey?: string;\n /** Short label shown before the selected value in the composer chip. */\n slotLabel?: string;\n /** Additional app-defined data used by the client for filtering and grouping. */\n metadata?: Record<string, unknown>;\n /** Slots to remove when this reference is inserted or removed. */\n clearsSlots?: string[];\n /** Additional references to insert before this one. */\n relatedReferences?: AgentComposerReference[];\n}\n\nexport interface AgentComposerReferenceInsertOptions {\n /**\n * Whether to open the agent sidebar before inserting the reference.\n * Defaults to false so contextual auto-tags can stay quiet.\n */\n openSidebar?: boolean;\n}\n\nexport interface AgentComposerReferenceInsertPayload extends AgentComposerReference {\n insertMessageId: string;\n}\n\nexport interface AgentChatContextMutationOptions {\n /**\n * Whether to open the agent sidebar if it's currently hidden.\n * Defaults to true for set/add and false for remove/clear.\n */\n openSidebar?: boolean;\n}\n\nexport interface AgentChatContextRemoveOptions extends AgentChatContextMutationOptions {\n /** Stable key of the staged context nugget to remove. */\n key: string;\n}\n\nconst AGENT_CHAT_MESSAGE_TYPE = \"agentNative.submitChat\";\nconst AGENT_CHAT_CONTEXT_STATE_KEY = \"agent-chat-context\";\nconst AGENT_CHAT_EXEC_MODE_KEY = \"agent-native-exec-mode\";\nexport const AGENT_CHAT_CONTEXT_CHANGED_EVENT =\n \"agentNative.chatContextChanged\";\nexport const AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE = \"agentNative.setChatContext\";\nexport const AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE =\n \"agentNative.removeChatContext\";\nexport const AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE =\n \"agentNative.clearChatContext\";\nexport const AGENT_CHAT_INSERT_REFERENCE_MESSAGE_TYPE =\n \"agentNative.insertComposerReference\";\nexport const AGENT_CHAT_INSERT_REFERENCE_EVENT =\n \"agentNative:insert-composer-reference\";\nconst AGENT_PANEL_PREPARE_EVENT = \"agent-panel:prepare\";\n\nlet agentChatContextState: AgentChatContextState = {\n items: [],\n updatedAt: 0,\n};\nconst agentChatContextListeners = new Set<() => void>();\n\n/**\n * Listen for chatRunning messages from the frame (postMessage)\n * and re-dispatch as a CustomEvent so hooks like useAgentChatGenerating() work.\n */\nif (typeof window !== \"undefined\") {\n window.addEventListener(\"message\", (event) => {\n if (!isTrustedFrameMessage(event) && !isTrustedBuilderMessage(event)) {\n return;\n }\n if (\n event.data?.type === \"agentNative.chatRunning\" ||\n event.data?.type === \"builder.chatRunning\"\n ) {\n window.dispatchEvent(\n new CustomEvent(\"agentNative.chatRunning\", {\n detail: event.data.detail ?? event.data.data,\n }),\n );\n }\n });\n}\n\n/** Generate a unique tab ID */\nexport function generateTabId(): string {\n return `chat-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\n/** Unique id for one submitted message, used to dedup live + replayed sends. */\nfunction generateSubmitMessageId(): string {\n return `submit-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n}\n\n// Self-submit buffer: same-window sends post to `window` itself, but the\n// receiver is lazy-loaded and may not be listening yet. Buffer each submit so\n// the panel can replay it on mount; claimAgentChatSubmit dedups by id so a\n// submit received both live and replayed is delivered exactly once.\ninterface BufferedSelfSubmit {\n id: string;\n data: Record<string, unknown>;\n at: number;\n}\n\nconst SELF_SUBMIT_BUFFER_TTL_MS = 8000;\nconst bufferedSelfSubmits: BufferedSelfSubmit[] = [];\nconst claimedSubmitIds = new Set<string>();\n\nfunction pruneSelfSubmitBuffer(now: number): void {\n for (let i = bufferedSelfSubmits.length - 1; i >= 0; i -= 1) {\n if (now - bufferedSelfSubmits[i].at > SELF_SUBMIT_BUFFER_TTL_MS) {\n const [removed] = bufferedSelfSubmits.splice(i, 1);\n if (removed) claimedSubmitIds.delete(removed.id);\n }\n }\n}\n\nfunction bufferSelfSubmit(data: Record<string, unknown>): void {\n const id =\n typeof data.submitMessageId === \"string\" ? data.submitMessageId : undefined;\n if (!id) return;\n const now = Date.now();\n pruneSelfSubmitBuffer(now);\n bufferedSelfSubmits.push({ id, data, at: now });\n}\n\n/** Unclaimed self-submit payloads, for the panel to replay once it mounts. */\nexport function drainBufferedAgentChatSubmits(): Array<\n Record<string, unknown>\n> {\n pruneSelfSubmitBuffer(Date.now());\n return bufferedSelfSubmits\n .filter((entry) => !claimedSubmitIds.has(entry.id))\n .map((entry) => entry.data);\n}\n\n/** Claim a submit; false if already handled. Idless submits always pass. */\nexport function claimAgentChatSubmit(id: string | undefined): boolean {\n if (!id) return true;\n if (claimedSubmitIds.has(id)) return false;\n claimedSubmitIds.add(id);\n return true;\n}\n\n/** Test-only: reset the self-submit buffer and claim set. */\nexport function _resetAgentChatSubmitBufferForTests(): void {\n bufferedSelfSubmits.length = 0;\n claimedSubmitIds.clear();\n}\n\nexport function normalizeAgentChatContextItem(\n item: unknown,\n): AgentChatContextItem | null {\n if (typeof item !== \"object\" || item === null) return null;\n const candidate = item as Partial<AgentChatContextItem>;\n if (\n typeof candidate.key !== \"string\" ||\n typeof candidate.context !== \"string\" ||\n typeof candidate.title !== \"string\"\n ) {\n return null;\n }\n const key = candidate.key.trim();\n const context = candidate.context.trim();\n if (!key || !context) return null;\n return {\n key,\n title: candidate.title.trim() || key,\n context,\n };\n}\n\nexport function normalizeAgentChatContextItems(\n items: unknown,\n): AgentChatContextItem[] {\n if (!Array.isArray(items)) return [];\n const deduped = new Map<string, AgentChatContextItem>();\n for (const rawItem of items) {\n const item = normalizeAgentChatContextItem(rawItem);\n if (!item) continue;\n deduped.set(item.key, item);\n }\n return [...deduped.values()];\n}\n\nfunction normalizeAgentChatContextState(\n value: unknown,\n): AgentChatContextState | null {\n if (!value || typeof value !== \"object\") return null;\n const raw = value as {\n value?: unknown;\n items?: unknown;\n updatedAt?: unknown;\n };\n const candidate =\n raw.value && typeof raw.value === \"object\"\n ? (raw.value as { items?: unknown; updatedAt?: unknown })\n : raw;\n const items = normalizeAgentChatContextItems(candidate.items);\n return {\n items,\n updatedAt:\n typeof candidate.updatedAt === \"number\" ? candidate.updatedAt : 0,\n };\n}\n\nfunction withReplacedAgentChatContextItem(\n items: readonly AgentChatContextItem[],\n item: AgentChatContextItem,\n): AgentChatContextItem[] {\n const index = items.findIndex((current) => current.key === item.key);\n if (index === -1) return [...items, item];\n return items.map((current, currentIndex) =>\n currentIndex === index ? item : current,\n );\n}\n\nfunction notifyAgentChatContextListeners(): void {\n for (const listener of agentChatContextListeners) listener();\n}\n\nfunction persistAgentChatContextState(state: AgentChatContextState): void {\n if (typeof window === \"undefined\" || typeof fetch !== \"function\") return;\n fetch(\n agentNativePath(\n `/_agent-native/application-state/${AGENT_CHAT_CONTEXT_STATE_KEY}`,\n ),\n {\n method: \"PUT\",\n keepalive: true,\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(state),\n },\n ).catch(() => {});\n}\n\nexport function publishAgentChatContextItems(\n items: readonly AgentChatContextItem[],\n options?: { persist?: boolean; updatedAt?: number },\n): AgentChatContextState {\n const next: AgentChatContextState = {\n items: normalizeAgentChatContextItems([...items]),\n updatedAt: options?.updatedAt ?? Date.now(),\n };\n if (next.updatedAt < agentChatContextState.updatedAt) {\n return agentChatContextState;\n }\n agentChatContextState = next;\n notifyAgentChatContextListeners();\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(AGENT_CHAT_CONTEXT_CHANGED_EVENT, {\n detail: next,\n }),\n );\n }\n if (options?.persist !== false) {\n persistAgentChatContextState(next);\n }\n return next;\n}\n\nexport function getAgentChatContextState(): AgentChatContextState {\n return agentChatContextState;\n}\n\nexport function listAgentChatContext(): AgentChatContextItem[] {\n return [...agentChatContextState.items];\n}\n\nexport function subscribeAgentChatContext(listener: () => void): () => void {\n agentChatContextListeners.add(listener);\n return () => {\n agentChatContextListeners.delete(listener);\n };\n}\n\nexport async function refreshAgentChatContext(): Promise<AgentChatContextState> {\n if (typeof window === \"undefined\" || typeof fetch !== \"function\") {\n return agentChatContextState;\n }\n try {\n const res = await fetch(\n agentNativePath(\n `/_agent-native/application-state/${AGENT_CHAT_CONTEXT_STATE_KEY}`,\n ),\n );\n if (!res.ok || res.status === 204) return agentChatContextState;\n const text = await res.text();\n if (!text) return agentChatContextState;\n const state = normalizeAgentChatContextState(JSON.parse(text));\n if (!state) return agentChatContextState;\n return publishAgentChatContextItems(state.items, {\n persist: false,\n updatedAt: state.updatedAt,\n });\n } catch {\n return agentChatContextState;\n }\n}\n\nexport function formatAgentChatContextItemsForPrompt(\n items: readonly AgentChatContextItem[],\n): string {\n return items\n .map(normalizeAgentChatContextItem)\n .filter((item): item is AgentChatContextItem => item !== null)\n .map((item) => [`## ${item.title}`, item.context].join(\"\\n\"))\n .join(\"\\n\\n\");\n}\n\nexport function appendAgentChatContextToMessage(\n message: string,\n context: string,\n): string {\n const trimmedContext = context.trim();\n if (!trimmedContext) return message;\n return `${message.trim()}\\n\\n<context>\\n${trimmedContext}\\n</context>`;\n}\n\nfunction normalizeStringArray(value: unknown): string[] | undefined {\n if (!Array.isArray(value)) return undefined;\n const normalized = value\n .filter((item): item is string => typeof item === \"string\")\n .map((item) => item.trim())\n .filter(Boolean);\n return normalized.length > 0 ? normalized : undefined;\n}\n\nfunction normalizeMetadata(\n value: unknown,\n): Record<string, unknown> | undefined {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return undefined;\n }\n return value as Record<string, unknown>;\n}\n\nfunction normalizeAgentComposerReferenceInternal(\n value: unknown,\n depth: number,\n): AgentComposerReference | null {\n if (typeof value !== \"object\" || value === null) return null;\n const candidate = value as Partial<AgentComposerReference>;\n const label =\n typeof candidate.label === \"string\" ? candidate.label.trim() : \"\";\n const refType =\n typeof candidate.refType === \"string\" ? candidate.refType.trim() : \"\";\n if (!label || !refType) return null;\n const normalized: AgentComposerReference = {\n label,\n icon:\n typeof candidate.icon === \"string\" && candidate.icon.trim()\n ? candidate.icon.trim()\n : undefined,\n source:\n typeof candidate.source === \"string\" && candidate.source.trim()\n ? candidate.source.trim()\n : undefined,\n refType,\n refId:\n typeof candidate.refId === \"string\" && candidate.refId.trim()\n ? candidate.refId.trim()\n : null,\n refPath:\n typeof candidate.refPath === \"string\" && candidate.refPath.trim()\n ? candidate.refPath.trim()\n : null,\n };\n const slotKey =\n typeof candidate.slotKey === \"string\" ? candidate.slotKey.trim() : \"\";\n if (slotKey) normalized.slotKey = slotKey;\n const slotLabel =\n typeof candidate.slotLabel === \"string\" ? candidate.slotLabel.trim() : \"\";\n if (slotLabel) normalized.slotLabel = slotLabel;\n const metadata = normalizeMetadata(candidate.metadata);\n if (metadata) normalized.metadata = metadata;\n const clearsSlots = normalizeStringArray(candidate.clearsSlots);\n if (clearsSlots) normalized.clearsSlots = clearsSlots;\n if (depth < 3 && Array.isArray(candidate.relatedReferences)) {\n const relatedReferences = candidate.relatedReferences\n .map((item) => normalizeAgentComposerReferenceInternal(item, depth + 1))\n .filter((item): item is AgentComposerReference => item !== null);\n if (relatedReferences.length > 0) {\n normalized.relatedReferences = relatedReferences;\n }\n }\n return normalized;\n}\n\nexport function normalizeAgentComposerReference(\n value: unknown,\n): AgentComposerReference | null {\n return normalizeAgentComposerReferenceInternal(value, 0);\n}\n\nfunction postAgentChatContextMessage(\n type:\n | typeof AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE\n | typeof AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE\n | typeof AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE,\n data: unknown,\n options: { openSidebar: boolean },\n): void {\n if (typeof window === \"undefined\") return;\n\n const payload = { type, data };\n const targetSelf = isInBuilderFrame() || isDirectMcpAppEmbedSession();\n const target = targetSelf\n ? window\n : window.parent !== window\n ? window.parent\n : window;\n const targetOrigin = targetSelf\n ? window.location.origin\n : getFramePostMessageTargetOrigin() || window.location.origin;\n\n if (options.openSidebar) {\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:set-mode\", {\n detail: { mode: \"chat\" },\n }),\n );\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n } else {\n window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));\n }\n\n const postToTarget = () => target.postMessage(payload, targetOrigin);\n if (target === window) {\n setTimeout(postToTarget, 0);\n } else {\n postToTarget();\n }\n}\n\nfunction postAgentChatReferenceMessage(\n payload: AgentComposerReferenceInsertPayload,\n options: { openSidebar: boolean },\n): void {\n if (typeof window === \"undefined\") return;\n\n const message = {\n type: AGENT_CHAT_INSERT_REFERENCE_MESSAGE_TYPE,\n data: payload,\n };\n const targetSelf = isInBuilderFrame() || isDirectMcpAppEmbedSession();\n const target = targetSelf\n ? window\n : window.parent !== window\n ? window.parent\n : window;\n const targetOrigin = targetSelf\n ? window.location.origin\n : getFramePostMessageTargetOrigin() || window.location.origin;\n\n if (options.openSidebar) {\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:set-mode\", {\n detail: { mode: \"chat\" },\n }),\n );\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n } else {\n window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));\n }\n\n window.dispatchEvent(\n new CustomEvent(AGENT_CHAT_INSERT_REFERENCE_EVENT, {\n detail: payload,\n }),\n );\n\n const postToTarget = () => target.postMessage(message, targetOrigin);\n if (target === window) {\n setTimeout(postToTarget, 0);\n } else {\n postToTarget();\n }\n}\n\nfunction isMcpAppChatBridgeEnabled(): boolean {\n if (typeof window === \"undefined\" || window.parent === window) return false;\n if (readEmbedMcpChatBridgeFlagFromUrl()) markEmbedMcpChatBridgeActive();\n return isEmbedMcpChatBridgeActive() && isEmbedAuthActive();\n}\n\nfunction isDirectMcpAppEmbedSession(): boolean {\n if (typeof window === \"undefined\" || window.parent === window) return false;\n if (readEmbedMcpChatBridgeFlagFromUrl()) markEmbedMcpChatBridgeActive();\n return isEmbedAuthActive() && !isEmbedMcpChatBridgeActive();\n}\n\nfunction dispatchAgentChatRunning(isRunning: boolean): void {\n if (typeof window === \"undefined\") return;\n window.dispatchEvent(\n new CustomEvent(\"agentNative.chatRunning\", {\n detail: { isRunning },\n }),\n );\n}\n\nfunction normalizeAgentChatRequestMode(\n value: unknown,\n): AgentChatRequestMode | undefined {\n return value === \"act\" || value === \"plan\" ? value : undefined;\n}\n\n/** A normalized `agentNative.submitChat` payload — decode via {@link parseSubmitChatMessage}. */\nexport interface ParsedSubmitChat {\n /** Visible prompt text (non-empty). */\n message: string;\n context?: string;\n /** Submit (true) or prefill only (false); defaults to true. */\n submit: boolean;\n openSidebar?: boolean;\n model?: string;\n /** Raw effort hint; the receiver validates it against the model. */\n effort?: unknown;\n newTab?: boolean;\n background?: boolean;\n tabId?: string;\n images?: string[];\n /** Mode as sent; the receiver falls back to its exec mode when undefined. */\n requestMode?: AgentChatRequestMode;\n /** Id used to dedup the live post against a cold-start replay. */\n submitMessageId?: string;\n}\n\n/** Decode a `message` event into a submit payload, or null if it isn't one / has no text. */\nexport function parseSubmitChatMessage(\n event: MessageEvent,\n): ParsedSubmitChat | null {\n const envelope =\n event.data && typeof event.data === \"object\"\n ? (event.data as { type?: unknown; data?: unknown })\n : null;\n if (!envelope || envelope.type !== AGENT_CHAT_MESSAGE_TYPE) return null;\n const raw =\n envelope.data && typeof envelope.data === \"object\"\n ? (envelope.data as Record<string, unknown>)\n : null;\n if (!raw) return null;\n const message = typeof raw.message === \"string\" ? raw.message : \"\";\n if (!message) return null;\n const images = Array.isArray(raw.images)\n ? raw.images.filter(\n (image): image is string =>\n typeof image === \"string\" && image.length > 0,\n )\n : undefined;\n return {\n message,\n context: typeof raw.context === \"string\" ? raw.context : undefined,\n submit: raw.submit !== false,\n openSidebar:\n typeof raw.openSidebar === \"boolean\" ? raw.openSidebar : undefined,\n model: typeof raw.model === \"string\" ? raw.model : undefined,\n effort: raw.effort,\n newTab: typeof raw.newTab === \"boolean\" ? raw.newTab : undefined,\n background:\n typeof raw.background === \"boolean\" ? raw.background : undefined,\n tabId: typeof raw.tabId === \"string\" ? raw.tabId : undefined,\n images,\n requestMode: normalizeAgentChatRequestMode(raw.requestMode ?? raw.mode),\n submitMessageId:\n typeof raw.submitMessageId === \"string\" ? raw.submitMessageId : undefined,\n };\n}\n\nfunction normalizeStoredAgentChatExecMode(\n value: string | null,\n): AgentChatRequestMode | undefined {\n if (value === \"plan\") return \"plan\";\n if (value === \"build\" || value === \"act\") return \"act\";\n return undefined;\n}\n\nfunction readStoredAgentChatRequestMode(): AgentChatRequestMode | undefined {\n if (typeof window === \"undefined\") return undefined;\n try {\n const storage = window.localStorage;\n const saved = normalizeStoredAgentChatExecMode(\n storage.getItem(AGENT_CHAT_EXEC_MODE_KEY),\n );\n if (saved) return saved;\n const scopedModes: AgentChatRequestMode[] = [];\n for (let index = 0; index < storage.length; index += 1) {\n const key = storage.key(index);\n if (!key?.startsWith(`${AGENT_CHAT_EXEC_MODE_KEY}:`)) continue;\n const scopedSaved = normalizeStoredAgentChatExecMode(\n storage.getItem(key),\n );\n if (scopedSaved) scopedModes.push(scopedSaved);\n }\n if (scopedModes.length === 1) return scopedModes[0];\n } catch {}\n return undefined;\n}\n\n/**\n * Send a message to the agent chat via postMessage.\n * Returns the stable tabId for tracking this chat run.\n */\nexport function sendToAgentChat(opts: AgentChatMessage): string {\n const tabId = opts.tabId ?? generateTabId();\n const isCodeRequest = opts.type === \"code\" || opts.requiresCode === true;\n const requestMode =\n normalizeAgentChatRequestMode(opts.requestMode ?? opts.mode) ??\n readStoredAgentChatRequestMode();\n if (isCodeRequest && isInBuilderFrame()) {\n sendToBuilderChat({\n message: opts.message,\n context: opts.context,\n submit: opts.submit,\n ...(requestMode ? { mode: requestMode, requestMode } : {}),\n });\n return tabId;\n }\n\n const submitMessageId = generateSubmitMessageId();\n const payload = {\n type: AGENT_CHAT_MESSAGE_TYPE,\n data: {\n ...opts,\n tabId,\n submitMessageId,\n ...(requestMode ? { mode: requestMode, requestMode } : {}),\n },\n };\n\n if (opts.submit !== false && isMcpAppChatBridgeEnabled()) {\n const directHostMessage = sendMcpAppHostMessage({\n message: opts.message,\n context: opts.context,\n ...(requestMode ? { mode: requestMode, requestMode } : {}),\n });\n if (directHostMessage) {\n void Promise.resolve(directHostMessage)\n .then((ok) => {\n if (!ok) {\n window.parent.postMessage(\n payload,\n getFramePostMessageTargetOrigin() || \"*\",\n );\n }\n })\n .finally(() => {\n dispatchAgentChatRunning(false);\n });\n return tabId;\n }\n window.parent.postMessage(\n payload,\n getFramePostMessageTargetOrigin() || \"*\",\n );\n return tabId;\n }\n\n const shouldOpenSidebar = opts.openSidebar !== false && !opts.background;\n\n const targetSelf =\n !isCodeRequest && (isInBuilderFrame() || isDirectMcpAppEmbedSession());\n const target = targetSelf\n ? window\n : window.parent !== window\n ? window.parent\n : window;\n const targetOrigin = targetSelf\n ? window.location.origin\n : getFramePostMessageTargetOrigin() || window.location.origin;\n if (shouldOpenSidebar) {\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:set-mode\", {\n detail: { mode: \"chat\" },\n }),\n );\n window.dispatchEvent(new CustomEvent(\"agent-panel:open\"));\n } else if (!isCodeRequest) {\n window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));\n }\n\n const postToTarget = () => target.postMessage(payload, targetOrigin);\n\n // Same-window: defer one tick so a sidebar mounting now can attach its\n // listener, and buffer the submit so the lazy panel can replay it if it\n // mounts later. The live post and the replay dedup by submitMessageId.\n if (!isCodeRequest && target === window) {\n bufferSelfSubmit(payload.data);\n setTimeout(postToTarget, 0);\n } else {\n postToTarget();\n }\n return tabId;\n}\n\n/**\n * Add or replace a keyed context nugget in the active agent chat composer.\n * The context is not submitted until the user sends the prompt.\n */\nexport function setAgentChatContextItem(\n opts: AgentChatContextSetOptions,\n): void {\n const item = normalizeAgentChatContextItem(opts);\n if (!item || typeof window === \"undefined\") return;\n\n publishAgentChatContextItems(\n withReplacedAgentChatContextItem(agentChatContextState.items, item),\n );\n postAgentChatContextMessage(AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE, item, {\n openSidebar: opts.openSidebar !== false,\n });\n}\n\n/** @deprecated Use `setAgentChatContextItem` instead. */\nexport const setContextToAgentChat = setAgentChatContextItem;\n\n/** @deprecated Use `setAgentChatContextItem` instead. */\nexport const addContextToAgentChat = setAgentChatContextItem;\n\nexport function insertAgentComposerReference(\n ref: AgentComposerReference,\n options: AgentComposerReferenceInsertOptions = {},\n): void {\n const normalized = normalizeAgentComposerReference(ref);\n if (!normalized || typeof window === \"undefined\") return;\n postAgentChatReferenceMessage(\n {\n ...normalized,\n insertMessageId: `reference-${Date.now()}-${Math.random()\n .toString(36)\n .slice(2, 8)}`,\n },\n { openSidebar: options.openSidebar === true },\n );\n}\n\nexport function removeAgentChatContextItem(\n keyOrOpts: string | AgentChatContextRemoveOptions,\n): void {\n const key =\n typeof keyOrOpts === \"string\" ? keyOrOpts.trim() : keyOrOpts.key.trim();\n if (!key || typeof window === \"undefined\") return;\n const openSidebar =\n typeof keyOrOpts === \"string\" ? false : keyOrOpts.openSidebar === true;\n\n publishAgentChatContextItems(\n agentChatContextState.items.filter((item) => item.key !== key),\n );\n postAgentChatContextMessage(\n AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE,\n { key },\n { openSidebar },\n );\n}\n\nexport function clearAgentChatContext(\n opts: AgentChatContextMutationOptions = {},\n): void {\n if (typeof window === \"undefined\") return;\n publishAgentChatContextItems([]);\n postAgentChatContextMessage(\n AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE,\n {},\n { openSidebar: opts.openSidebar === true },\n );\n}\n\nexport function _resetAgentChatContextForTests(): void {\n agentChatContextState = { items: [], updatedAt: 0 };\n notifyAgentChatContextListeners();\n}\n"]}
@@ -1,11 +1,12 @@
1
1
  import type { EditorView } from "@tiptap/pm/view";
2
2
  import React from "react";
3
3
  import { type ReasoningEffort } from "../../shared/reasoning-effort.js";
4
- import { type AgentChatContextItem } from "../agent-chat.js";
4
+ import { AgentComposerReference, type AgentChatContextItem } from "../agent-chat.js";
5
5
  import type { SkillResult, Reference, SlashCommand, AgentComposerLayoutVariant } from "./types.js";
6
6
  export interface TiptapComposerHandle {
7
7
  focus(): void;
8
8
  setText(text: string): void;
9
+ insertReference(ref: AgentComposerReference): void;
9
10
  }
10
11
  export type ComposerSubmitIntent = "immediate" | "queued";
11
12
  export declare const DEFAULT_VOICE_DICTATION_ENABLED = false;
@@ -1 +1 @@
1
- {"version":3,"file":"TiptapComposer.d.ts","sourceRoot":"","sources":["../../../src/client/composer/TiptapComposer.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,KAON,MAAM,OAAO,CAAC;AAEf,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAmB,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAwB9E,OAAO,KAAK,EAEV,WAAW,EACX,SAAS,EACT,YAAY,EAEZ,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AAMpB,MAAM,WAAW,oBAAoB;IACnC,KAAK,IAAI,IAAI,CAAC;IACd,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE1D,eAAO,MAAM,+BAA+B,QAAQ,CAAC;AAErD,MAAM,WAAW,2BAA2B;IAC1C,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,OAAO,CAKV;AAWD,wBAAgB,mCAAmC,CACjD,WAAW,EAAE,aAAa,CAAC,OAAO,CAAC,GAClC,MAAM,GAAG,IAAI,CAiBf;AAED,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC,EACtE,KAAK,EAAE,OAAO,GACb,oBAAoB,GAAG,IAAI,CAS7B;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AK,CAAC,EAAE,MAAM,CAAC;CAChB;AAiXD,wBAAgB,cAAc,CAAC,EAC7B,WAAgC,EAChC,QAAgB,EAChB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,QAAQ,EACR,aAAoB,EACpB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,WAAW,EACX,aAAyB,EACzB,aAAkB,EAClB,WAAgB,EAChB,2BAAkC,EAClC,yBAAgC,EAChC,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,gBAAwB,EACxB,sBAAsB,EACtB,YAA8C,EAC9C,aAAa,EACb,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,4BAA4B,EAC5B,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,YAAiB,EACjB,mBAAmB,EACnB,YAAqB,EACrB,gCAAwC,EACxC,iBAAiB,GAClB,EAAE,mBAAmB,qBAsnCrB"}
1
+ {"version":3,"file":"TiptapComposer.d.ts","sourceRoot":"","sources":["../../../src/client/composer/TiptapComposer.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,KAON,MAAM,OAAO,CAAC;AAEf,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,sBAAsB,EAGtB,KAAK,oBAAoB,EAI1B,MAAM,kBAAkB,CAAC;AA0B1B,OAAO,KAAK,EAEV,WAAW,EACX,SAAS,EACT,YAAY,EAEZ,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AAKpB,MAAM,WAAW,oBAAoB;IACnC,KAAK,IAAI,IAAI,CAAC;IACd,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,eAAe,CAAC,GAAG,EAAE,sBAAsB,GAAG,IAAI,CAAC;CACpD;AAED,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE1D,eAAO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