@agent-native/core 0.35.2 → 0.36.0
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.
- package/README.md +1 -1
- package/dist/cli/context-xray-local.d.ts +2 -2
- package/dist/cli/context-xray-local.d.ts.map +1 -1
- package/dist/cli/context-xray-local.js +1449 -53
- package/dist/cli/context-xray-local.js.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +381 -73
- package/dist/cli/skills.js.map +1 -1
- package/dist/cli/templates-meta.d.ts.map +1 -1
- package/dist/cli/templates-meta.js +8 -4
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +5 -11
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +6 -0
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +50 -26
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +81 -8
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +68 -24
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/agent-chat.d.ts +39 -3
- package/dist/client/agent-chat.d.ts.map +1 -1
- package/dist/client/agent-chat.js +168 -33
- package/dist/client/agent-chat.js.map +1 -1
- package/dist/client/application-state.d.ts +13 -0
- package/dist/client/application-state.d.ts.map +1 -0
- package/dist/client/application-state.js +99 -0
- package/dist/client/application-state.js.map +1 -0
- package/dist/client/composer/ComposerPlusMenu.d.ts.map +1 -1
- package/dist/client/composer/ComposerPlusMenu.js +174 -8
- package/dist/client/composer/ComposerPlusMenu.js.map +1 -1
- package/dist/client/composer/PromptComposer.d.ts +2 -0
- package/dist/client/composer/PromptComposer.d.ts.map +1 -1
- package/dist/client/composer/PromptComposer.js +2 -2
- package/dist/client/composer/PromptComposer.js.map +1 -1
- package/dist/client/composer/TiptapComposer.js +1 -1
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/context-xray/ContextMeter.d.ts +2 -1
- package/dist/client/context-xray/ContextMeter.d.ts.map +1 -1
- package/dist/client/context-xray/ContextMeter.js +19 -25
- package/dist/client/context-xray/ContextMeter.js.map +1 -1
- package/dist/client/context-xray/ContextXRayPanel.d.ts +1 -3
- package/dist/client/context-xray/ContextXRayPanel.d.ts.map +1 -1
- package/dist/client/context-xray/ContextXRayPanel.js +27 -24
- package/dist/client/context-xray/ContextXRayPanel.js.map +1 -1
- package/dist/client/conversation/AgentConversation.d.ts.map +1 -1
- package/dist/client/conversation/AgentConversation.js +2 -1
- package/dist/client/conversation/AgentConversation.js.map +1 -1
- package/dist/client/frame-protocol.d.ts +11 -3
- package/dist/client/frame-protocol.d.ts.map +1 -1
- package/dist/client/frame-protocol.js.map +1 -1
- package/dist/client/index.d.ts +4 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +4 -2
- package/dist/client/index.js.map +1 -1
- package/dist/client/progress/RunsTray.d.ts +1 -0
- package/dist/client/progress/RunsTray.d.ts.map +1 -1
- package/dist/client/progress/RunsTray.js +50 -16
- package/dist/client/progress/RunsTray.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts +1 -0
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +62 -15
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/client/tool-display.d.ts +4 -0
- package/dist/client/tool-display.d.ts.map +1 -0
- package/dist/client/tool-display.js +28 -0
- package/dist/client/tool-display.js.map +1 -0
- package/dist/client/use-action.d.ts +12 -0
- package/dist/client/use-action.d.ts.map +1 -1
- package/dist/client/use-action.js +14 -2
- package/dist/client/use-action.js.map +1 -1
- package/dist/client/use-agent-chat-context.d.ts +15 -0
- package/dist/client/use-agent-chat-context.d.ts.map +1 -0
- package/dist/client/use-agent-chat-context.js +32 -0
- package/dist/client/use-agent-chat-context.js.map +1 -0
- package/dist/client/use-chat-threads.d.ts.map +1 -1
- package/dist/client/use-chat-threads.js +40 -31
- package/dist/client/use-chat-threads.js.map +1 -1
- package/dist/client/use-external-value.d.ts.map +1 -1
- package/dist/client/use-external-value.js +14 -7
- package/dist/client/use-external-value.js.map +1 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +1 -2
- package/dist/deploy/build.js.map +1 -1
- package/dist/extensions/html-shell.d.ts +3 -2
- package/dist/extensions/html-shell.d.ts.map +1 -1
- package/dist/extensions/html-shell.js +12 -2
- package/dist/extensions/html-shell.js.map +1 -1
- package/dist/extensions/routes.js +2 -7
- package/dist/extensions/routes.js.map +1 -1
- package/dist/index.browser.d.ts +1 -1
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.d.ts +4 -2
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +33 -4
- package/dist/mcp/server.js.map +1 -1
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/provider-api/index.js +14 -6
- package/dist/provider-api/index.js.map +1 -1
- package/dist/server/agent-teams.d.ts +4 -1
- package/dist/server/agent-teams.d.ts.map +1 -1
- package/dist/server/agent-teams.js +104 -28
- package/dist/server/agent-teams.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +21 -11
- package/dist/server/auth.js.map +1 -1
- package/dist/server/core-routes-plugin.js +2 -2
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/request-context.d.ts +3 -4
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/request-context.js.map +1 -1
- package/dist/server/security-headers.d.ts +16 -19
- package/dist/server/security-headers.d.ts.map +1 -1
- package/dist/server/security-headers.js +24 -25
- package/dist/server/security-headers.js.map +1 -1
- package/dist/server/self-dispatch.d.ts.map +1 -1
- package/dist/server/self-dispatch.js +17 -1
- package/dist/server/self-dispatch.js.map +1 -1
- package/dist/server/ssr-handler.d.ts.map +1 -1
- package/dist/server/ssr-handler.js +9 -18
- package/dist/server/ssr-handler.js.map +1 -1
- package/dist/templates/default/AGENTS.md +1 -1
- package/dist/templates/default/DEVELOPING.md +7 -13
- package/dist/templates/workspace-core/AGENTS.md +6 -4
- package/dist/templates/workspace-root/AGENTS.md +6 -4
- package/docs/content/actions.md +5 -7
- package/docs/content/client.md +49 -44
- package/docs/content/context-awareness.md +20 -33
- package/docs/content/creating-templates.md +2 -2
- package/docs/content/external-agents.md +1 -1
- package/docs/content/key-concepts.md +3 -3
- package/docs/content/sharing.md +1 -1
- package/docs/content/template-mail.md +1 -1
- package/docs/content/voice-input.md +1 -1
- package/package.json +5 -1
- package/src/templates/default/AGENTS.md +1 -1
- package/src/templates/default/DEVELOPING.md +7 -13
- package/src/templates/workspace-core/AGENTS.md +6 -4
- package/src/templates/workspace-root/AGENTS.md +6 -4
|
@@ -71,16 +71,46 @@ export interface AgentChatContextItem {
|
|
|
71
71
|
/** Hidden context included with the next submitted prompt. */
|
|
72
72
|
context: string;
|
|
73
73
|
}
|
|
74
|
-
export interface
|
|
74
|
+
export interface AgentChatContextSetOptions extends AgentChatContextItem {
|
|
75
75
|
/**
|
|
76
76
|
* Whether to open the agent sidebar if it's currently hidden.
|
|
77
77
|
* Defaults to true so the user can see the staged context.
|
|
78
78
|
*/
|
|
79
79
|
openSidebar?: boolean;
|
|
80
80
|
}
|
|
81
|
+
/** @deprecated Use `AgentChatContextSetOptions` instead. */
|
|
82
|
+
export type AgentChatContextMessage = AgentChatContextSetOptions;
|
|
83
|
+
export interface AgentChatContextState {
|
|
84
|
+
items: AgentChatContextItem[];
|
|
85
|
+
updatedAt: number;
|
|
86
|
+
}
|
|
87
|
+
export interface AgentChatContextMutationOptions {
|
|
88
|
+
/**
|
|
89
|
+
* Whether to open the agent sidebar if it's currently hidden.
|
|
90
|
+
* Defaults to true for set/add and false for remove/clear.
|
|
91
|
+
*/
|
|
92
|
+
openSidebar?: boolean;
|
|
93
|
+
}
|
|
94
|
+
export interface AgentChatContextRemoveOptions extends AgentChatContextMutationOptions {
|
|
95
|
+
/** Stable key of the staged context nugget to remove. */
|
|
96
|
+
key: string;
|
|
97
|
+
}
|
|
98
|
+
export declare const AGENT_CHAT_CONTEXT_CHANGED_EVENT = "agentNative.chatContextChanged";
|
|
99
|
+
export declare const AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE = "agentNative.setChatContext";
|
|
100
|
+
export declare const AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE = "agentNative.removeChatContext";
|
|
101
|
+
export declare const AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE = "agentNative.clearChatContext";
|
|
81
102
|
/** Generate a unique tab ID */
|
|
82
103
|
export declare function generateTabId(): string;
|
|
83
104
|
export declare function normalizeAgentChatContextItem(item: unknown): AgentChatContextItem | null;
|
|
105
|
+
export declare function normalizeAgentChatContextItems(items: unknown): AgentChatContextItem[];
|
|
106
|
+
export declare function publishAgentChatContextItems(items: readonly AgentChatContextItem[], options?: {
|
|
107
|
+
persist?: boolean;
|
|
108
|
+
updatedAt?: number;
|
|
109
|
+
}): AgentChatContextState;
|
|
110
|
+
export declare function getAgentChatContextState(): AgentChatContextState;
|
|
111
|
+
export declare function listAgentChatContext(): AgentChatContextItem[];
|
|
112
|
+
export declare function subscribeAgentChatContext(listener: () => void): () => void;
|
|
113
|
+
export declare function refreshAgentChatContext(): Promise<AgentChatContextState>;
|
|
84
114
|
export declare function formatAgentChatContextItemsForPrompt(items: readonly AgentChatContextItem[]): string;
|
|
85
115
|
export declare function appendAgentChatContextToMessage(message: string, context: string): string;
|
|
86
116
|
/**
|
|
@@ -92,6 +122,12 @@ export declare function sendToAgentChat(opts: AgentChatMessage): string;
|
|
|
92
122
|
* Add or replace a keyed context nugget in the active agent chat composer.
|
|
93
123
|
* The context is not submitted until the user sends the prompt.
|
|
94
124
|
*/
|
|
95
|
-
export declare function
|
|
96
|
-
|
|
125
|
+
export declare function setAgentChatContextItem(opts: AgentChatContextSetOptions): void;
|
|
126
|
+
/** @deprecated Use `setAgentChatContextItem` instead. */
|
|
127
|
+
export declare const setContextToAgentChat: typeof setAgentChatContextItem;
|
|
128
|
+
/** @deprecated Use `setAgentChatContextItem` instead. */
|
|
129
|
+
export declare const addContextToAgentChat: typeof setAgentChatContextItem;
|
|
130
|
+
export declare function removeAgentChatContextItem(keyOrOpts: string | AgentChatContextRemoveOptions): void;
|
|
131
|
+
export declare function clearAgentChatContext(opts?: AgentChatContextMutationOptions): void;
|
|
132
|
+
export declare function _resetAgentChatContextForTests(): void;
|
|
97
133
|
//# sourceMappingURL=agent-chat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-chat.d.ts","sourceRoot":"","sources":["../../src/client/agent-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-chat.d.ts","sourceRoot":"","sources":["../../src/client/agent-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAerE,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;I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B,CAAC;AAE7D,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,gCAA0B,CAAC;AAE7D,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,MAAM,GAAG,6BAA6B,GAChD,IAAI,CAeN;AAED,wBAAgB,qBAAqB,CACnC,IAAI,GAAE,+BAAoC,GACzC,IAAI,CAQN;AAED,wBAAgB,8BAA8B,IAAI,IAAI,CAGrD"}
|
|
@@ -10,9 +10,19 @@ import { getFramePostMessageTargetOrigin, isTrustedFrameMessage, } from "./frame
|
|
|
10
10
|
import { isEmbedAuthActive, isEmbedMcpChatBridgeActive, markEmbedMcpChatBridgeActive, readEmbedMcpChatBridgeFlagFromUrl, } from "./embed-auth.js";
|
|
11
11
|
import { sendMcpAppHostMessage } from "./mcp-app-host.js";
|
|
12
12
|
import { isInBuilderFrame, isTrustedBuilderMessage, sendToBuilderChat, } from "./builder-frame.js";
|
|
13
|
+
import { agentNativePath } from "./api-path.js";
|
|
13
14
|
const AGENT_CHAT_MESSAGE_TYPE = "agentNative.submitChat";
|
|
14
|
-
const
|
|
15
|
+
const AGENT_CHAT_CONTEXT_STATE_KEY = "agent-chat-context";
|
|
16
|
+
export const AGENT_CHAT_CONTEXT_CHANGED_EVENT = "agentNative.chatContextChanged";
|
|
17
|
+
export const AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE = "agentNative.setChatContext";
|
|
18
|
+
export const AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE = "agentNative.removeChatContext";
|
|
19
|
+
export const AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE = "agentNative.clearChatContext";
|
|
15
20
|
const AGENT_PANEL_PREPARE_EVENT = "agent-panel:prepare";
|
|
21
|
+
let agentChatContextState = {
|
|
22
|
+
items: [],
|
|
23
|
+
updatedAt: 0,
|
|
24
|
+
};
|
|
25
|
+
const agentChatContextListeners = new Set();
|
|
16
26
|
/**
|
|
17
27
|
* Listen for chatRunning messages from the frame (postMessage)
|
|
18
28
|
* and re-dispatch as a CustomEvent so hooks like useAgentChatGenerating() work.
|
|
@@ -53,6 +63,106 @@ export function normalizeAgentChatContextItem(item) {
|
|
|
53
63
|
context,
|
|
54
64
|
};
|
|
55
65
|
}
|
|
66
|
+
export function normalizeAgentChatContextItems(items) {
|
|
67
|
+
if (!Array.isArray(items))
|
|
68
|
+
return [];
|
|
69
|
+
const deduped = new Map();
|
|
70
|
+
for (const rawItem of items) {
|
|
71
|
+
const item = normalizeAgentChatContextItem(rawItem);
|
|
72
|
+
if (!item)
|
|
73
|
+
continue;
|
|
74
|
+
deduped.set(item.key, item);
|
|
75
|
+
}
|
|
76
|
+
return [...deduped.values()];
|
|
77
|
+
}
|
|
78
|
+
function normalizeAgentChatContextState(value) {
|
|
79
|
+
if (!value || typeof value !== "object")
|
|
80
|
+
return null;
|
|
81
|
+
const raw = value;
|
|
82
|
+
const candidate = raw.value && typeof raw.value === "object"
|
|
83
|
+
? raw.value
|
|
84
|
+
: raw;
|
|
85
|
+
const items = normalizeAgentChatContextItems(candidate.items);
|
|
86
|
+
return {
|
|
87
|
+
items,
|
|
88
|
+
updatedAt: typeof candidate.updatedAt === "number" ? candidate.updatedAt : 0,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function withReplacedAgentChatContextItem(items, item) {
|
|
92
|
+
const index = items.findIndex((current) => current.key === item.key);
|
|
93
|
+
if (index === -1)
|
|
94
|
+
return [...items, item];
|
|
95
|
+
return items.map((current, currentIndex) => currentIndex === index ? item : current);
|
|
96
|
+
}
|
|
97
|
+
function notifyAgentChatContextListeners() {
|
|
98
|
+
for (const listener of agentChatContextListeners)
|
|
99
|
+
listener();
|
|
100
|
+
}
|
|
101
|
+
function persistAgentChatContextState(state) {
|
|
102
|
+
if (typeof window === "undefined" || typeof fetch !== "function")
|
|
103
|
+
return;
|
|
104
|
+
fetch(agentNativePath(`/_agent-native/application-state/${AGENT_CHAT_CONTEXT_STATE_KEY}`), {
|
|
105
|
+
method: "PUT",
|
|
106
|
+
keepalive: true,
|
|
107
|
+
headers: { "Content-Type": "application/json" },
|
|
108
|
+
body: JSON.stringify(state),
|
|
109
|
+
}).catch(() => { });
|
|
110
|
+
}
|
|
111
|
+
export function publishAgentChatContextItems(items, options) {
|
|
112
|
+
const next = {
|
|
113
|
+
items: normalizeAgentChatContextItems([...items]),
|
|
114
|
+
updatedAt: options?.updatedAt ?? Date.now(),
|
|
115
|
+
};
|
|
116
|
+
if (next.updatedAt < agentChatContextState.updatedAt) {
|
|
117
|
+
return agentChatContextState;
|
|
118
|
+
}
|
|
119
|
+
agentChatContextState = next;
|
|
120
|
+
notifyAgentChatContextListeners();
|
|
121
|
+
if (typeof window !== "undefined") {
|
|
122
|
+
window.dispatchEvent(new CustomEvent(AGENT_CHAT_CONTEXT_CHANGED_EVENT, {
|
|
123
|
+
detail: next,
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
if (options?.persist !== false) {
|
|
127
|
+
persistAgentChatContextState(next);
|
|
128
|
+
}
|
|
129
|
+
return next;
|
|
130
|
+
}
|
|
131
|
+
export function getAgentChatContextState() {
|
|
132
|
+
return agentChatContextState;
|
|
133
|
+
}
|
|
134
|
+
export function listAgentChatContext() {
|
|
135
|
+
return [...agentChatContextState.items];
|
|
136
|
+
}
|
|
137
|
+
export function subscribeAgentChatContext(listener) {
|
|
138
|
+
agentChatContextListeners.add(listener);
|
|
139
|
+
return () => {
|
|
140
|
+
agentChatContextListeners.delete(listener);
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export async function refreshAgentChatContext() {
|
|
144
|
+
if (typeof window === "undefined" || typeof fetch !== "function") {
|
|
145
|
+
return agentChatContextState;
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
const res = await fetch(agentNativePath(`/_agent-native/application-state/${AGENT_CHAT_CONTEXT_STATE_KEY}`));
|
|
149
|
+
if (!res.ok || res.status === 204)
|
|
150
|
+
return agentChatContextState;
|
|
151
|
+
const text = await res.text();
|
|
152
|
+
if (!text)
|
|
153
|
+
return agentChatContextState;
|
|
154
|
+
const state = normalizeAgentChatContextState(JSON.parse(text));
|
|
155
|
+
if (!state)
|
|
156
|
+
return agentChatContextState;
|
|
157
|
+
return publishAgentChatContextItems(state.items, {
|
|
158
|
+
persist: false,
|
|
159
|
+
updatedAt: state.updatedAt,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return agentChatContextState;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
56
166
|
export function formatAgentChatContextItemsForPrompt(items) {
|
|
57
167
|
return items
|
|
58
168
|
.map(normalizeAgentChatContextItem)
|
|
@@ -66,6 +176,36 @@ export function appendAgentChatContextToMessage(message, context) {
|
|
|
66
176
|
return message;
|
|
67
177
|
return `${message.trim()}\n\n<context>\n${trimmedContext}\n</context>`;
|
|
68
178
|
}
|
|
179
|
+
function postAgentChatContextMessage(type, data, options) {
|
|
180
|
+
if (typeof window === "undefined")
|
|
181
|
+
return;
|
|
182
|
+
const payload = { type, data };
|
|
183
|
+
const targetSelf = isInBuilderFrame() || isDirectMcpAppEmbedSession();
|
|
184
|
+
const target = targetSelf
|
|
185
|
+
? window
|
|
186
|
+
: window.parent !== window
|
|
187
|
+
? window.parent
|
|
188
|
+
: window;
|
|
189
|
+
const targetOrigin = targetSelf
|
|
190
|
+
? window.location.origin
|
|
191
|
+
: getFramePostMessageTargetOrigin() || window.location.origin;
|
|
192
|
+
if (options.openSidebar) {
|
|
193
|
+
window.dispatchEvent(new CustomEvent("agent-panel:set-mode", {
|
|
194
|
+
detail: { mode: "chat" },
|
|
195
|
+
}));
|
|
196
|
+
window.dispatchEvent(new CustomEvent("agent-panel:open"));
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
window.dispatchEvent(new CustomEvent(AGENT_PANEL_PREPARE_EVENT));
|
|
200
|
+
}
|
|
201
|
+
const postToTarget = () => target.postMessage(payload, targetOrigin);
|
|
202
|
+
if (target === window) {
|
|
203
|
+
setTimeout(postToTarget, 0);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
postToTarget();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
69
209
|
function isMcpAppChatBridgeEnabled() {
|
|
70
210
|
if (typeof window === "undefined" || window.parent === window)
|
|
71
211
|
return false;
|
|
@@ -161,40 +301,35 @@ export function sendToAgentChat(opts) {
|
|
|
161
301
|
* Add or replace a keyed context nugget in the active agent chat composer.
|
|
162
302
|
* The context is not submitted until the user sends the prompt.
|
|
163
303
|
*/
|
|
164
|
-
export function
|
|
304
|
+
export function setAgentChatContextItem(opts) {
|
|
165
305
|
const item = normalizeAgentChatContextItem(opts);
|
|
166
306
|
if (!item || typeof window === "undefined")
|
|
167
307
|
return;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
postToTarget();
|
|
197
|
-
}
|
|
308
|
+
publishAgentChatContextItems(withReplacedAgentChatContextItem(agentChatContextState.items, item));
|
|
309
|
+
postAgentChatContextMessage(AGENT_CHAT_SET_CONTEXT_MESSAGE_TYPE, item, {
|
|
310
|
+
openSidebar: opts.openSidebar !== false,
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
/** @deprecated Use `setAgentChatContextItem` instead. */
|
|
314
|
+
export const setContextToAgentChat = setAgentChatContextItem;
|
|
315
|
+
/** @deprecated Use `setAgentChatContextItem` instead. */
|
|
316
|
+
export const addContextToAgentChat = setAgentChatContextItem;
|
|
317
|
+
export function removeAgentChatContextItem(keyOrOpts) {
|
|
318
|
+
const key = typeof keyOrOpts === "string" ? keyOrOpts.trim() : keyOrOpts.key.trim();
|
|
319
|
+
if (!key || typeof window === "undefined")
|
|
320
|
+
return;
|
|
321
|
+
const openSidebar = typeof keyOrOpts === "string" ? false : keyOrOpts.openSidebar === true;
|
|
322
|
+
publishAgentChatContextItems(agentChatContextState.items.filter((item) => item.key !== key));
|
|
323
|
+
postAgentChatContextMessage(AGENT_CHAT_REMOVE_CONTEXT_MESSAGE_TYPE, { key }, { openSidebar });
|
|
324
|
+
}
|
|
325
|
+
export function clearAgentChatContext(opts = {}) {
|
|
326
|
+
if (typeof window === "undefined")
|
|
327
|
+
return;
|
|
328
|
+
publishAgentChatContextItems([]);
|
|
329
|
+
postAgentChatContextMessage(AGENT_CHAT_CLEAR_CONTEXT_MESSAGE_TYPE, {}, { openSidebar: opts.openSidebar === true });
|
|
330
|
+
}
|
|
331
|
+
export function _resetAgentChatContextForTests() {
|
|
332
|
+
agentChatContextState = { items: [], updatedAt: 0 };
|
|
333
|
+
notifyAgentChatContextListeners();
|
|
198
334
|
}
|
|
199
|
-
export const addContextToAgentChat = setContextToAgentChat;
|
|
200
335
|
//# sourceMappingURL=agent-chat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-chat.js","sourceRoot":"","sources":["../../src/client/agent-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,4BAA4B,EAC5B,iCAAiC,GAClC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AA4E5B,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AACzD,MAAM,+BAA+B,G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AE,IAAI,EAAE,MAAM,EAAE;SACzB,CAAC,CACH,CAAC;QACF,MAAM,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC5D,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,yBAAyB,CAAC,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACrE,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IAC9B,CAAC;SAAM,CAAC;QACN,YAAY,EAAE,CAAC;IACjB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,qBAAqB,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 {\n getFramePostMessageTargetOrigin,\n isTrustedFrameMessage,\n} from \"./frame.js\";\nimport type { ReasoningEffort } from \"../shared/reasoning-effort.js\";\nimport {\n isEmbedAuthActive,\n isEmbedMcpChatBridgeActive,\n markEmbedMcpChatBridgeActive,\n readEmbedMcpChatBridgeFlagFromUrl,\n} from \"./embed-auth.js\";\nimport { sendMcpAppHostMessage } from \"./mcp-app-host.js\";\nimport {\n isInBuilderFrame,\n isTrustedBuilderMessage,\n sendToBuilderChat,\n} from \"./builder-frame.js\";\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 /** 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 AgentChatContextMessage 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\nconst AGENT_CHAT_MESSAGE_TYPE = \"agentNative.submitChat\";\nconst AGENT_CHAT_CONTEXT_MESSAGE_TYPE = \"agentNative.setChatContext\";\nconst AGENT_PANEL_PREPARE_EVENT = \"agent-panel:prepare\";\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\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 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 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\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 if (isCodeRequest && isInBuilderFrame()) {\n sendToBuilderChat({\n message: opts.message,\n context: opts.context,\n submit: opts.submit,\n });\n return tabId;\n }\n\n const payload = {\n type: AGENT_CHAT_MESSAGE_TYPE,\n data: { ...opts, tabId },\n };\n\n if (opts.submit !== false && isMcpAppChatBridgeEnabled()) {\n const directHostMessage = sendMcpAppHostMessage({\n message: opts.message,\n context: opts.context,\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 // When the local app owns the chat surface, opening/preparing the sidebar\n // may mount the MessageEvent listener that receives this payload. Defer the\n // post one tick so a closed sidebar cannot drop the prompt while mounting.\n if (!isCodeRequest && target === window) {\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 setContextToAgentChat(opts: AgentChatContextMessage): void {\n const item = normalizeAgentChatContextItem(opts);\n if (!item || typeof window === \"undefined\") return;\n\n const payload = {\n type: AGENT_CHAT_CONTEXT_MESSAGE_TYPE,\n data: item,\n };\n const shouldOpenSidebar = opts.openSidebar !== false;\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 (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 {\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\nexport const addContextToAgentChat = setContextToAgentChat;\n"]}
|
|
1
|
+
{"version":3,"file":"agent-chat.js","sourceRoot":"","sources":["../../src/client/agent-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1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,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 {\n getFramePostMessageTargetOrigin,\n isTrustedFrameMessage,\n} from \"./frame.js\";\nimport type { ReasoningEffort } from \"../shared/reasoning-effort.js\";\nimport {\n isEmbedAuthActive,\n isEmbedMcpChatBridgeActive,\n markEmbedMcpChatBridgeActive,\n readEmbedMcpChatBridgeFlagFromUrl,\n} from \"./embed-auth.js\";\nimport { sendMcpAppHostMessage } from \"./mcp-app-host.js\";\nimport {\n isInBuilderFrame,\n isTrustedBuilderMessage,\n sendToBuilderChat,\n} from \"./builder-frame.js\";\nimport { agentNativePath } from \"./api-path.js\";\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 /** 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\";\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\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\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 if (isCodeRequest && isInBuilderFrame()) {\n sendToBuilderChat({\n message: opts.message,\n context: opts.context,\n submit: opts.submit,\n });\n return tabId;\n }\n\n const payload = {\n type: AGENT_CHAT_MESSAGE_TYPE,\n data: { ...opts, tabId },\n };\n\n if (opts.submit !== false && isMcpAppChatBridgeEnabled()) {\n const directHostMessage = sendMcpAppHostMessage({\n message: opts.message,\n context: opts.context,\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 // When the local app owns the chat surface, opening/preparing the sidebar\n // may mount the MessageEvent listener that receives this payload. Defer the\n // post one tick so a closed sidebar cannot drop the prompt while mounting.\n if (!isCodeRequest && target === window) {\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"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ClientAppStateReadOptions {
|
|
2
|
+
signal?: AbortSignal;
|
|
3
|
+
}
|
|
4
|
+
export interface ClientAppStateWriteOptions {
|
|
5
|
+
keepalive?: boolean;
|
|
6
|
+
requestSource?: string;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
export declare function readClientAppState<T = unknown>(key: string, options?: ClientAppStateReadOptions): Promise<T | null>;
|
|
10
|
+
export declare function writeClientAppState<T = unknown>(key: string, value: T, options?: ClientAppStateWriteOptions): Promise<T>;
|
|
11
|
+
export declare function deleteClientAppState(key: string, options?: ClientAppStateWriteOptions): Promise<void>;
|
|
12
|
+
export declare function setClientAppState<T = unknown>(key: string, value: T | null | undefined, options?: ClientAppStateWriteOptions): Promise<T | null>;
|
|
13
|
+
//# sourceMappingURL=application-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application-state.d.ts","sourceRoot":"","sources":["../../src/client/application-state.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,yBAAyB;IACxC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAmFD,wBAAsB,kBAAkB,CAAC,CAAC,GAAG,OAAO,EAClD,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAUnB;AAED,wBAAsB,mBAAmB,CAAC,CAAC,GAAG,OAAO,EACnD,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,CAAC,EACR,OAAO,GAAE,0BAA+B,GACvC,OAAO,CAAC,CAAC,CAAC,CASZ;AAED,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,0BAA+B,GACvC,OAAO,CAAC,IAAI,CAAC,CAaf;AAED,wBAAsB,iBAAiB,CAAC,CAAC,GAAG,OAAO,EACjD,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,EAC3B,OAAO,GAAE,0BAA+B,GACvC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAMnB"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { agentNativePath } from "./api-path.js";
|
|
2
|
+
const APP_STATE_KEY_PATTERN = /^[a-zA-Z0-9_:-]+$/;
|
|
3
|
+
function appStateUrl(key) {
|
|
4
|
+
if (!APP_STATE_KEY_PATTERN.test(key)) {
|
|
5
|
+
throw new TypeError("Application state keys may only contain letters, numbers, underscores, hyphens, and colons.");
|
|
6
|
+
}
|
|
7
|
+
return agentNativePath(`/_agent-native/application-state/${key}`);
|
|
8
|
+
}
|
|
9
|
+
function buildHeaders(requestSource) {
|
|
10
|
+
const headers = {
|
|
11
|
+
"Content-Type": "application/json",
|
|
12
|
+
};
|
|
13
|
+
if (requestSource)
|
|
14
|
+
headers["X-Request-Source"] = requestSource;
|
|
15
|
+
return headers;
|
|
16
|
+
}
|
|
17
|
+
async function parseAppStateResponse(response, operation) {
|
|
18
|
+
let raw = "";
|
|
19
|
+
try {
|
|
20
|
+
raw = await response.text();
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
const cause = err instanceof Error ? err.message : String(err);
|
|
24
|
+
const error = new Error(`${operation} failed: response body could not be read: ${cause}`);
|
|
25
|
+
error.status = response.status;
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
let data = undefined;
|
|
29
|
+
if (raw.length > 0) {
|
|
30
|
+
try {
|
|
31
|
+
data = JSON.parse(raw);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
if (response.ok) {
|
|
35
|
+
const error = new Error(`${operation} returned a non-JSON ${response.status} response: ${raw.slice(0, 200)}`);
|
|
36
|
+
error.status = response.status;
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (!response.ok) {
|
|
42
|
+
const message = (data &&
|
|
43
|
+
typeof data === "object" &&
|
|
44
|
+
("error" in data || "message" in data) &&
|
|
45
|
+
String(data.error ??
|
|
46
|
+
data.message)) ||
|
|
47
|
+
raw.slice(0, 200) ||
|
|
48
|
+
response.statusText ||
|
|
49
|
+
`HTTP ${response.status}`;
|
|
50
|
+
const error = new Error(`${operation} failed: ${message}`);
|
|
51
|
+
error.status = response.status;
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
return (data ?? null);
|
|
55
|
+
}
|
|
56
|
+
function jsonBody(value) {
|
|
57
|
+
const body = JSON.stringify(value);
|
|
58
|
+
if (body === undefined) {
|
|
59
|
+
throw new TypeError("Application state values must be JSON-serializable. Use deleteClientAppState or setClientAppState with undefined to clear a key.");
|
|
60
|
+
}
|
|
61
|
+
return body;
|
|
62
|
+
}
|
|
63
|
+
export async function readClientAppState(key, options = {}) {
|
|
64
|
+
const response = await fetch(appStateUrl(key), {
|
|
65
|
+
method: "GET",
|
|
66
|
+
cache: "no-store",
|
|
67
|
+
signal: options.signal,
|
|
68
|
+
});
|
|
69
|
+
return parseAppStateResponse(response, `Read application state "${key}"`);
|
|
70
|
+
}
|
|
71
|
+
export async function writeClientAppState(key, value, options = {}) {
|
|
72
|
+
const response = await fetch(appStateUrl(key), {
|
|
73
|
+
method: "PUT",
|
|
74
|
+
headers: buildHeaders(options.requestSource),
|
|
75
|
+
body: jsonBody(value),
|
|
76
|
+
keepalive: options.keepalive,
|
|
77
|
+
signal: options.signal,
|
|
78
|
+
});
|
|
79
|
+
return parseAppStateResponse(response, `Write application state "${key}"`);
|
|
80
|
+
}
|
|
81
|
+
export async function deleteClientAppState(key, options = {}) {
|
|
82
|
+
const response = await fetch(appStateUrl(key), {
|
|
83
|
+
method: "DELETE",
|
|
84
|
+
headers: options.requestSource
|
|
85
|
+
? { "X-Request-Source": options.requestSource }
|
|
86
|
+
: undefined,
|
|
87
|
+
keepalive: options.keepalive,
|
|
88
|
+
signal: options.signal,
|
|
89
|
+
});
|
|
90
|
+
await parseAppStateResponse(response, `Delete application state "${key}"`);
|
|
91
|
+
}
|
|
92
|
+
export async function setClientAppState(key, value, options = {}) {
|
|
93
|
+
if (value === null || value === undefined) {
|
|
94
|
+
await deleteClientAppState(key, options);
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return writeClientAppState(key, value, options);
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=application-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application-state.js","sourceRoot":"","sources":["../../src/client/application-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAYlD,SAAS,WAAW,CAAC,GAAW;IAC9B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,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,mBAAmB,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC","sourcesContent":["import { agentNativePath } from \"./api-path.js\";\n\nconst APP_STATE_KEY_PATTERN = /^[a-zA-Z0-9_:-]+$/;\n\nexport interface ClientAppStateReadOptions {\n signal?: AbortSignal;\n}\n\nexport interface ClientAppStateWriteOptions {\n keepalive?: boolean;\n requestSource?: string;\n signal?: AbortSignal;\n}\n\nfunction appStateUrl(key: string): string {\n if (!APP_STATE_KEY_PATTERN.test(key)) {\n throw new TypeError(\n \"Application state keys may only contain letters, numbers, underscores, hyphens, and colons.\",\n );\n }\n return agentNativePath(`/_agent-native/application-state/${key}`);\n}\n\nfunction buildHeaders(requestSource?: string): Record<string, string> {\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n if (requestSource) headers[\"X-Request-Source\"] = requestSource;\n return headers;\n}\n\nasync function parseAppStateResponse<T>(\n response: Response,\n operation: string,\n): Promise<T> {\n let raw = \"\";\n try {\n raw = await response.text();\n } catch (err) {\n const cause = err instanceof Error ? err.message : String(err);\n const error = new Error(\n `${operation} failed: response body could not be read: ${cause}`,\n );\n (error as { status?: number }).status = response.status;\n throw error;\n }\n\n let data: unknown = undefined;\n if (raw.length > 0) {\n try {\n data = JSON.parse(raw);\n } catch {\n if (response.ok) {\n const error = new Error(\n `${operation} returned a non-JSON ${response.status} response: ${raw.slice(\n 0,\n 200,\n )}`,\n );\n (error as { status?: number }).status = response.status;\n throw error;\n }\n }\n }\n\n if (!response.ok) {\n const message =\n (data &&\n typeof data === \"object\" &&\n (\"error\" in data || \"message\" in data) &&\n String(\n (data as { error?: unknown; message?: unknown }).error ??\n (data as { error?: unknown; message?: unknown }).message,\n )) ||\n raw.slice(0, 200) ||\n response.statusText ||\n `HTTP ${response.status}`;\n const error = new Error(`${operation} failed: ${message}`);\n (error as { status?: number }).status = response.status;\n throw error;\n }\n\n return (data ?? null) as T;\n}\n\nfunction jsonBody(value: unknown): string {\n const body = JSON.stringify(value);\n if (body === undefined) {\n throw new TypeError(\n \"Application state values must be JSON-serializable. Use deleteClientAppState or setClientAppState with undefined to clear a key.\",\n );\n }\n return body;\n}\n\nexport async function readClientAppState<T = unknown>(\n key: string,\n options: ClientAppStateReadOptions = {},\n): Promise<T | null> {\n const response = await fetch(appStateUrl(key), {\n method: \"GET\",\n cache: \"no-store\",\n signal: options.signal,\n });\n return parseAppStateResponse<T | null>(\n response,\n `Read application state \"${key}\"`,\n );\n}\n\nexport async function writeClientAppState<T = unknown>(\n key: string,\n value: T,\n options: ClientAppStateWriteOptions = {},\n): Promise<T> {\n const response = await fetch(appStateUrl(key), {\n method: \"PUT\",\n headers: buildHeaders(options.requestSource),\n body: jsonBody(value),\n keepalive: options.keepalive,\n signal: options.signal,\n });\n return parseAppStateResponse<T>(response, `Write application state \"${key}\"`);\n}\n\nexport async function deleteClientAppState(\n key: string,\n options: ClientAppStateWriteOptions = {},\n): Promise<void> {\n const response = await fetch(appStateUrl(key), {\n method: \"DELETE\",\n headers: options.requestSource\n ? { \"X-Request-Source\": options.requestSource }\n : undefined,\n keepalive: options.keepalive,\n signal: options.signal,\n });\n await parseAppStateResponse<unknown>(\n response,\n `Delete application state \"${key}\"`,\n );\n}\n\nexport async function setClientAppState<T = unknown>(\n key: string,\n value: T | null | undefined,\n options: ClientAppStateWriteOptions = {},\n): Promise<T | null> {\n if (value === null || value === undefined) {\n await deleteClientAppState(key, options);\n return null;\n }\n return writeClientAppState(key, value, options);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerPlusMenu.d.ts","sourceRoot":"","sources":["../../../src/client/composer/ComposerPlusMenu.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ComposerPlusMenu.d.ts","sourceRoot":"","sources":["../../../src/client/composer/ComposerPlusMenu.tsx"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAQ/C,UAAU,qBAAqB;IAC7B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;IAC5C;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;CAC/B;AAwJD,wBAAgB,gBAAgB,CAAC,EAC/B,YAAY,EACZ,IAAa,GACd,EAAE,qBAAqB,2CAKvB"}
|