@percena/weft 0.4.0-next.3 → 0.4.0-next.5
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/dist/action-bridge.cjs +172 -6
- package/dist/action-bridge.d.cts +112 -13
- package/dist/action-bridge.d.ts +112 -13
- package/dist/action-bridge.js +166 -4
- package/dist/chat.cjs +982 -3
- package/dist/chat.d.cts +30 -1
- package/dist/chat.d.ts +30 -1
- package/dist/chat.js +981 -2
- package/dist/index.cjs +341 -1616
- package/dist/index.d.cts +4 -274
- package/dist/index.d.ts +4 -274
- package/dist/index.js +174 -1408
- package/dist/styles/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/dist/styles/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/dist/styles/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Main-Bold.woff +0 -0
- package/dist/styles/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/dist/styles/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Main-Italic.woff +0 -0
- package/dist/styles/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Main-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/dist/styles/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Math-Italic.woff +0 -0
- package/dist/styles/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Script-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/styles/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/dist/styles/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/dist/styles/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/package.json +2 -30
- package/dist/local-runtime.cjs +0 -1387
- package/dist/local-runtime.d.cts +0 -3314
- package/dist/local-runtime.d.ts +0 -3314
- package/dist/local-runtime.js +0 -1345
- package/dist/skills-browser.cjs +0 -118
- package/dist/skills-browser.d.cts +0 -105
- package/dist/skills-browser.d.ts +0 -105
- package/dist/skills-browser.js +0 -88
package/dist/index.cjs
CHANGED
|
@@ -32,774 +32,16 @@ var src_exports = {};
|
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
AgentChatPanel: () => AgentChatPanel,
|
|
34
34
|
EN_FALLBACK: () => EN_FALLBACK,
|
|
35
|
-
RPC_CHANNELS: () => RPC_CHANNELS,
|
|
36
|
-
THINKING_LEVELS: () => THINKING_LEVELS,
|
|
37
|
-
THINKING_LEVEL_IDS: () => THINKING_LEVEL_IDS,
|
|
38
|
-
THINKING_TO_EFFORT: () => THINKING_TO_EFFORT,
|
|
39
35
|
TimelineAgentChatPanel: () => TimelineAgentChatPanel,
|
|
40
|
-
appendTimelineItem: () => appendTimelineItem,
|
|
41
36
|
createFlitroEmbedRuntime: () => createFlitroEmbedRuntime,
|
|
42
|
-
createInMemoryApprovalStore: () => createInMemoryApprovalStore,
|
|
43
|
-
createPermissionPolicy: () => createPermissionPolicy,
|
|
44
|
-
createPermissionPolicyFromConfig: () => createPermissionPolicyFromConfig,
|
|
45
|
-
createPolicyDecisionReceipt: () => createPolicyDecisionReceipt,
|
|
46
|
-
createRuntimeCapabilityReport: () => createRuntimeCapabilityReport,
|
|
47
|
-
createRuntimeExtensionContext: () => createRuntimeExtensionContext,
|
|
48
|
-
createSourcePolicyLayer: () => createSourcePolicyLayer,
|
|
49
|
-
createTimelineCursor: () => createTimelineCursor,
|
|
50
|
-
createTimelineSequencer: () => createTimelineSequencer,
|
|
51
|
-
debug: () => debug,
|
|
52
|
-
evaluateToolPolicy: () => evaluateToolPolicy,
|
|
53
|
-
explainToolPolicy: () => explainToolPolicy,
|
|
54
|
-
fetchTimeline: () => fetchTimeline,
|
|
55
|
-
findMentionMatches: () => findMentionMatches,
|
|
56
|
-
generateMessageId: () => generateMessageId,
|
|
57
|
-
getThinkingLevelNameKey: () => getThinkingLevelNameKey,
|
|
58
|
-
getThinkingTokens: () => getThinkingTokens,
|
|
59
|
-
invokeSessionTool: () => invokeSessionTool,
|
|
60
|
-
isValidThinkingLevel: () => isValidThinkingLevel,
|
|
61
|
-
mergeTimeline: () => mergeTimeline,
|
|
62
|
-
messageToStored: () => messageToStored,
|
|
63
|
-
normalizePath: () => normalizePath,
|
|
64
|
-
normalizeThinkingLevel: () => normalizeThinkingLevel,
|
|
65
|
-
parseMentions: () => parseMentions,
|
|
66
|
-
pathStartsWith: () => pathStartsWith,
|
|
67
|
-
reduceRuntimeState: () => reduceRuntimeState,
|
|
68
|
-
resolveFileMentions: () => resolveFileMentions,
|
|
69
|
-
resolvePathMentions: () => resolvePathMentions,
|
|
70
|
-
resolveSkillMentions: () => resolveSkillMentions,
|
|
71
|
-
resolveSourceMentions: () => resolveSourceMentions,
|
|
72
|
-
sanitizeProviderSourceTools: () => sanitizeProviderSourceTools,
|
|
73
|
-
selectRuntimeCandidate: () => selectRuntimeCandidate,
|
|
74
|
-
storedToMessage: () => storedToMessage,
|
|
75
|
-
stripAllMentions: () => stripAllMentions,
|
|
76
|
-
stripPathPrefix: () => stripPathPrefix,
|
|
77
37
|
useAgentChatSession: () => useAgentChatSession,
|
|
78
|
-
useAgentSession: () =>
|
|
79
|
-
useTimelineAgentChatSession: () => useTimelineAgentChatSession
|
|
80
|
-
validatePolicyConfig: () => validatePolicyConfig
|
|
38
|
+
useAgentSession: () => useAgentSession,
|
|
39
|
+
useTimelineAgentChatSession: () => useTimelineAgentChatSession
|
|
81
40
|
});
|
|
82
41
|
module.exports = __toCommonJS(src_exports);
|
|
83
42
|
|
|
84
|
-
// ../packages/
|
|
85
|
-
|
|
86
|
-
return `msg-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
87
|
-
}
|
|
88
|
-
function messageToStored(msg) {
|
|
89
|
-
const { role, isStreaming, isPending, ...rest } = msg;
|
|
90
|
-
return { ...rest, type: role };
|
|
91
|
-
}
|
|
92
|
-
function storedToMessage(stored) {
|
|
93
|
-
const { type, ...rest } = stored;
|
|
94
|
-
return { ...rest, role: type, timestamp: stored.timestamp ?? Date.now() };
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// ../packages/core/dist/chunk-LCDW7EA2.js
|
|
98
|
-
function debug(..._args) {
|
|
99
|
-
}
|
|
100
|
-
function normalizePath(path) {
|
|
101
|
-
return path.replace(/\\/g, "/");
|
|
102
|
-
}
|
|
103
|
-
function pathStartsWith(filePath, dirPath) {
|
|
104
|
-
const normalizedFile = normalizePath(filePath);
|
|
105
|
-
const normalizedDir = normalizePath(dirPath);
|
|
106
|
-
return normalizedFile.startsWith(normalizedDir + "/") || normalizedFile === normalizedDir;
|
|
107
|
-
}
|
|
108
|
-
function stripPathPrefix(filePath, prefix) {
|
|
109
|
-
const normalizedFile = normalizePath(filePath);
|
|
110
|
-
const normalizedPrefix = normalizePath(prefix);
|
|
111
|
-
if (normalizedFile.startsWith(normalizedPrefix + "/")) {
|
|
112
|
-
return normalizedFile.slice(normalizedPrefix.length + 1);
|
|
113
|
-
}
|
|
114
|
-
return filePath;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// ../packages/core/dist/index.js
|
|
118
|
-
var THINKING_LEVEL_IDS = [
|
|
119
|
-
"off",
|
|
120
|
-
"low",
|
|
121
|
-
"medium",
|
|
122
|
-
"high",
|
|
123
|
-
"xhigh",
|
|
124
|
-
"max"
|
|
125
|
-
];
|
|
126
|
-
var THINKING_LEVELS = [
|
|
127
|
-
{ id: "off", nameKey: "thinking.off", descriptionKey: "thinking.offDesc" },
|
|
128
|
-
{ id: "low", nameKey: "thinking.low", descriptionKey: "thinking.lowDesc" },
|
|
129
|
-
{ id: "medium", nameKey: "thinking.medium", descriptionKey: "thinking.mediumDesc" },
|
|
130
|
-
{ id: "high", nameKey: "thinking.high", descriptionKey: "thinking.highDesc" },
|
|
131
|
-
{ id: "xhigh", nameKey: "thinking.xhigh", descriptionKey: "thinking.xhighDesc" },
|
|
132
|
-
{ id: "max", nameKey: "thinking.max", descriptionKey: "thinking.maxDesc" }
|
|
133
|
-
];
|
|
134
|
-
var THINKING_TO_EFFORT = {
|
|
135
|
-
off: null,
|
|
136
|
-
low: "low",
|
|
137
|
-
medium: "medium",
|
|
138
|
-
high: "high",
|
|
139
|
-
xhigh: "xhigh",
|
|
140
|
-
max: "max"
|
|
141
|
-
};
|
|
142
|
-
var TOKEN_BUDGETS = {
|
|
143
|
-
haiku: {
|
|
144
|
-
off: 0,
|
|
145
|
-
low: 2e3,
|
|
146
|
-
medium: 4e3,
|
|
147
|
-
high: 6e3,
|
|
148
|
-
xhigh: 7e3,
|
|
149
|
-
max: 8e3
|
|
150
|
-
},
|
|
151
|
-
default: {
|
|
152
|
-
off: 0,
|
|
153
|
-
low: 4e3,
|
|
154
|
-
medium: 1e4,
|
|
155
|
-
high: 2e4,
|
|
156
|
-
xhigh: 26e3,
|
|
157
|
-
max: 32e3
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
function getThinkingTokens(level, modelId) {
|
|
161
|
-
const isHaiku = modelId.toLowerCase().includes("haiku");
|
|
162
|
-
const budgets = isHaiku ? TOKEN_BUDGETS.haiku : TOKEN_BUDGETS.default;
|
|
163
|
-
return budgets[level];
|
|
164
|
-
}
|
|
165
|
-
function getThinkingLevelNameKey(level) {
|
|
166
|
-
const def = THINKING_LEVELS.find((l) => l.id === level);
|
|
167
|
-
return def?.nameKey ?? `thinking.${level}`;
|
|
168
|
-
}
|
|
169
|
-
function isValidThinkingLevel(value) {
|
|
170
|
-
return typeof value === "string" && THINKING_LEVEL_IDS.includes(value);
|
|
171
|
-
}
|
|
172
|
-
function normalizeThinkingLevel(value) {
|
|
173
|
-
if (value === "think") return "medium";
|
|
174
|
-
if (isValidThinkingLevel(value)) return value;
|
|
175
|
-
return void 0;
|
|
176
|
-
}
|
|
177
|
-
var RPC_CHANNELS = {
|
|
178
|
-
remote: {
|
|
179
|
-
TEST_CONNECTION: "remote:testConnection"
|
|
180
|
-
},
|
|
181
|
-
server: {
|
|
182
|
-
GET_WORKSPACES: "server:getWorkspaces",
|
|
183
|
-
CREATE_WORKSPACE: "server:createWorkspace",
|
|
184
|
-
GET_STATUS: "server:getStatus",
|
|
185
|
-
GET_HEALTH: "server:getHealth",
|
|
186
|
-
GET_ACTIVE_SESSIONS: "server:getActiveSessions",
|
|
187
|
-
SHUTTING_DOWN: "server:shuttingDown",
|
|
188
|
-
STATUS_CHANGED: "server:statusChanged",
|
|
189
|
-
HOME_DIR: "server:homeDir"
|
|
190
|
-
},
|
|
191
|
-
sessions: {
|
|
192
|
-
GET: "sessions:get",
|
|
193
|
-
GET_UNREAD_SUMMARY: "sessions:getUnreadSummary",
|
|
194
|
-
MARK_ALL_READ: "sessions:markAllRead",
|
|
195
|
-
UNREAD_SUMMARY_CHANGED: "sessions:unreadSummaryChanged",
|
|
196
|
-
CREATE: "sessions:create",
|
|
197
|
-
DELETE: "sessions:delete",
|
|
198
|
-
GET_MESSAGES: "sessions:getMessages",
|
|
199
|
-
SEND_MESSAGE: "sessions:sendMessage",
|
|
200
|
-
CANCEL: "sessions:cancel",
|
|
201
|
-
KILL_SHELL: "sessions:killShell",
|
|
202
|
-
RESPOND_TO_PERMISSION: "sessions:respondToPermission",
|
|
203
|
-
RESPOND_TO_CREDENTIAL: "sessions:respondToCredential",
|
|
204
|
-
COMMAND: "sessions:command",
|
|
205
|
-
GET_PENDING_PLAN_EXECUTION: "sessions:getPendingPlanExecution",
|
|
206
|
-
GET_PERMISSION_MODE_STATE: "sessions:getPermissionModeState",
|
|
207
|
-
EVENT: "session:event",
|
|
208
|
-
GET_MODEL: "session:getModel",
|
|
209
|
-
SET_MODEL: "session:setModel",
|
|
210
|
-
GET_FILES: "sessions:getFiles",
|
|
211
|
-
GET_NOTES: "sessions:getNotes",
|
|
212
|
-
SET_NOTES: "sessions:setNotes",
|
|
213
|
-
WATCH_FILES: "sessions:watchFiles",
|
|
214
|
-
UNWATCH_FILES: "sessions:unwatchFiles",
|
|
215
|
-
FILES_CHANGED: "sessions:filesChanged",
|
|
216
|
-
SEARCH_CONTENT: "sessions:searchContent",
|
|
217
|
-
EXPORT: "sessions:export",
|
|
218
|
-
IMPORT: "sessions:import",
|
|
219
|
-
EXPORT_REMOTE_TRANSFER: "sessions:exportRemoteTransfer",
|
|
220
|
-
IMPORT_REMOTE_TRANSFER: "sessions:importRemoteTransfer"
|
|
221
|
-
},
|
|
222
|
-
transfer: {
|
|
223
|
-
START: "transfer:start",
|
|
224
|
-
CHUNK: "transfer:chunk",
|
|
225
|
-
COMMIT: "transfer:commit",
|
|
226
|
-
ABORT: "transfer:abort"
|
|
227
|
-
},
|
|
228
|
-
tasks: {
|
|
229
|
-
GET_OUTPUT: "tasks:getOutput"
|
|
230
|
-
},
|
|
231
|
-
workspaces: {
|
|
232
|
-
GET: "workspaces:get",
|
|
233
|
-
CREATE: "workspaces:create",
|
|
234
|
-
CHECK_SLUG: "workspaces:checkSlug",
|
|
235
|
-
UPDATE_REMOTE: "workspaces:updateRemote"
|
|
236
|
-
},
|
|
237
|
-
window: {
|
|
238
|
-
GET_WORKSPACE: "window:getWorkspace",
|
|
239
|
-
GET_MODE: "window:getMode",
|
|
240
|
-
OPEN_WORKSPACE: "window:openWorkspace",
|
|
241
|
-
OPEN_SESSION_IN_NEW_WINDOW: "window:openSessionInNewWindow",
|
|
242
|
-
SWITCH_WORKSPACE: "window:switchWorkspace",
|
|
243
|
-
CLOSE: "window:close",
|
|
244
|
-
CLOSE_REQUESTED: "window:closeRequested",
|
|
245
|
-
CONFIRM_CLOSE: "window:confirmClose",
|
|
246
|
-
CANCEL_CLOSE: "window:cancelClose",
|
|
247
|
-
SET_TRAFFIC_LIGHTS: "window:setTrafficLights",
|
|
248
|
-
FOCUS_STATE: "window:focusState",
|
|
249
|
-
GET_FOCUS_STATE: "window:getFocusState"
|
|
250
|
-
},
|
|
251
|
-
file: {
|
|
252
|
-
READ: "file:read",
|
|
253
|
-
READ_DATA_URL: "file:readDataUrl",
|
|
254
|
-
READ_PREVIEW_DATA_URL: "file:readPreviewDataUrl",
|
|
255
|
-
READ_BINARY: "file:readBinary",
|
|
256
|
-
OPEN_DIALOG: "file:openDialog",
|
|
257
|
-
READ_ATTACHMENT: "file:readAttachment",
|
|
258
|
-
READ_USER_ATTACHMENT: "file:readUserAttachment",
|
|
259
|
-
STORE_ATTACHMENT: "file:storeAttachment",
|
|
260
|
-
GENERATE_THUMBNAIL: "file:generateThumbnail"
|
|
261
|
-
},
|
|
262
|
-
fs: {
|
|
263
|
-
SEARCH: "fs:search",
|
|
264
|
-
LIST_DIRECTORY: "fs:listDirectory"
|
|
265
|
-
},
|
|
266
|
-
debug: {
|
|
267
|
-
LOG: "debug:log"
|
|
268
|
-
},
|
|
269
|
-
theme: {
|
|
270
|
-
GET_SYSTEM_PREFERENCE: "theme:getSystemPreference",
|
|
271
|
-
SYSTEM_CHANGED: "theme:systemChanged",
|
|
272
|
-
APP_CHANGED: "theme:appChanged",
|
|
273
|
-
GET_APP: "theme:getApp",
|
|
274
|
-
GET_PRESETS: "theme:getPresets",
|
|
275
|
-
LOAD_PRESET: "theme:loadPreset",
|
|
276
|
-
GET_COLOR_THEME: "theme:getColorTheme",
|
|
277
|
-
SET_COLOR_THEME: "theme:setColorTheme",
|
|
278
|
-
BROADCAST_PREFERENCES: "theme:broadcastPreferences",
|
|
279
|
-
PREFERENCES_CHANGED: "theme:preferencesChanged",
|
|
280
|
-
GET_WORKSPACE_COLOR_THEME: "theme:getWorkspaceColorTheme",
|
|
281
|
-
SET_WORKSPACE_COLOR_THEME: "theme:setWorkspaceColorTheme",
|
|
282
|
-
GET_ALL_WORKSPACE_THEMES: "theme:getAllWorkspaceThemes",
|
|
283
|
-
BROADCAST_WORKSPACE_THEME: "theme:broadcastWorkspaceTheme",
|
|
284
|
-
WORKSPACE_THEME_CHANGED: "theme:workspaceThemeChanged"
|
|
285
|
-
},
|
|
286
|
-
system: {
|
|
287
|
-
VERSIONS: "system:versions",
|
|
288
|
-
HOME_DIR: "system:homeDir",
|
|
289
|
-
IS_DEBUG_MODE: "system:isDebugMode"
|
|
290
|
-
},
|
|
291
|
-
update: {
|
|
292
|
-
CHECK: "update:check",
|
|
293
|
-
GET_INFO: "update:getInfo",
|
|
294
|
-
INSTALL: "update:install",
|
|
295
|
-
DISMISS: "update:dismiss",
|
|
296
|
-
GET_DISMISSED: "update:getDismissed",
|
|
297
|
-
AVAILABLE: "update:available",
|
|
298
|
-
DOWNLOAD_PROGRESS: "update:downloadProgress"
|
|
299
|
-
},
|
|
300
|
-
shell: {
|
|
301
|
-
OPEN_URL: "shell:openUrl",
|
|
302
|
-
OPEN_FILE: "shell:openFile",
|
|
303
|
-
SHOW_IN_FOLDER: "shell:showInFolder"
|
|
304
|
-
},
|
|
305
|
-
menu: {
|
|
306
|
-
NEW_CHAT: "menu:newChat",
|
|
307
|
-
NEW_WINDOW: "menu:newWindow",
|
|
308
|
-
OPEN_SETTINGS: "menu:openSettings",
|
|
309
|
-
KEYBOARD_SHORTCUTS: "menu:keyboardShortcuts",
|
|
310
|
-
TOGGLE_FOCUS_MODE: "menu:toggleFocusMode",
|
|
311
|
-
TOGGLE_SIDEBAR: "menu:toggleSidebar",
|
|
312
|
-
QUIT: "menu:quit",
|
|
313
|
-
MINIMIZE: "menu:minimize",
|
|
314
|
-
MAXIMIZE: "menu:maximize",
|
|
315
|
-
ZOOM_IN: "menu:zoomIn",
|
|
316
|
-
ZOOM_OUT: "menu:zoomOut",
|
|
317
|
-
ZOOM_RESET: "menu:zoomReset",
|
|
318
|
-
TOGGLE_DEV_TOOLS: "menu:toggleDevTools",
|
|
319
|
-
UNDO: "menu:undo",
|
|
320
|
-
REDO: "menu:redo",
|
|
321
|
-
CUT: "menu:cut",
|
|
322
|
-
COPY: "menu:copy",
|
|
323
|
-
PASTE: "menu:paste",
|
|
324
|
-
SELECT_ALL: "menu:selectAll"
|
|
325
|
-
},
|
|
326
|
-
deeplink: {
|
|
327
|
-
NAVIGATE: "deeplink:navigate"
|
|
328
|
-
},
|
|
329
|
-
auth: {
|
|
330
|
-
LOGOUT: "auth:logout",
|
|
331
|
-
SHOW_LOGOUT_CONFIRMATION: "auth:showLogoutConfirmation",
|
|
332
|
-
SHOW_DELETE_SESSION_CONFIRMATION: "auth:showDeleteSessionConfirmation"
|
|
333
|
-
},
|
|
334
|
-
credentials: {
|
|
335
|
-
HEALTH_CHECK: "credentials:healthCheck"
|
|
336
|
-
},
|
|
337
|
-
onboarding: {
|
|
338
|
-
GET_AUTH_STATE: "onboarding:getAuthState",
|
|
339
|
-
VALIDATE_MCP: "onboarding:validateMcp",
|
|
340
|
-
START_MCP_OAUTH: "onboarding:startMcpOAuth",
|
|
341
|
-
START_CLAUDE_OAUTH: "onboarding:startClaudeOAuth",
|
|
342
|
-
EXCHANGE_CLAUDE_CODE: "onboarding:exchangeClaudeCode",
|
|
343
|
-
HAS_CLAUDE_OAUTH_STATE: "onboarding:hasClaudeOAuthState",
|
|
344
|
-
CLEAR_CLAUDE_OAUTH_STATE: "onboarding:clearClaudeOAuthState",
|
|
345
|
-
DEFER_SETUP: "onboarding:deferSetup"
|
|
346
|
-
},
|
|
347
|
-
llmConnections: {
|
|
348
|
-
LIST: "LLM_Connection:list",
|
|
349
|
-
LIST_WITH_STATUS: "LLM_Connection:listWithStatus",
|
|
350
|
-
GET: "LLM_Connection:get",
|
|
351
|
-
GET_API_KEY: "LLM_Connection:getApiKey",
|
|
352
|
-
SAVE: "LLM_Connection:save",
|
|
353
|
-
DELETE: "LLM_Connection:delete",
|
|
354
|
-
TEST: "LLM_Connection:test",
|
|
355
|
-
SET_DEFAULT: "LLM_Connection:setDefault",
|
|
356
|
-
SET_WORKSPACE_DEFAULT: "LLM_Connection:setWorkspaceDefault",
|
|
357
|
-
REFRESH_MODELS: "LLM_Connection:refreshModels",
|
|
358
|
-
CHANGED: "LLM_Connection:changed"
|
|
359
|
-
},
|
|
360
|
-
chatgpt: {
|
|
361
|
-
START_OAUTH: "chatgpt:startOAuth",
|
|
362
|
-
COMPLETE_OAUTH: "chatgpt:completeOAuth",
|
|
363
|
-
CANCEL_OAUTH: "chatgpt:cancelOAuth",
|
|
364
|
-
GET_AUTH_STATUS: "chatgpt:getAuthStatus",
|
|
365
|
-
LOGOUT: "chatgpt:logout"
|
|
366
|
-
},
|
|
367
|
-
copilot: {
|
|
368
|
-
START_OAUTH: "copilot:startOAuth",
|
|
369
|
-
CANCEL_OAUTH: "copilot:cancelOAuth",
|
|
370
|
-
GET_AUTH_STATUS: "copilot:getAuthStatus",
|
|
371
|
-
LOGOUT: "copilot:logout",
|
|
372
|
-
DEVICE_CODE: "copilot:deviceCode"
|
|
373
|
-
},
|
|
374
|
-
settings: {
|
|
375
|
-
SETUP_LLM_CONNECTION: "settings:setupLlmConnection",
|
|
376
|
-
TEST_LLM_CONNECTION_SETUP: "settings:testLlmConnectionSetup",
|
|
377
|
-
GET_DEFAULT_THINKING_LEVEL: "settings:getDefaultThinkingLevel",
|
|
378
|
-
SET_DEFAULT_THINKING_LEVEL: "settings:setDefaultThinkingLevel",
|
|
379
|
-
GET_NETWORK_PROXY: "settings:getNetworkProxy",
|
|
380
|
-
SET_NETWORK_PROXY: "settings:setNetworkProxy",
|
|
381
|
-
GET_SERVER_CONFIG: "settings:getServerConfig",
|
|
382
|
-
SET_SERVER_CONFIG: "settings:setServerConfig",
|
|
383
|
-
GET_SERVER_STATUS: "settings:getServerStatus"
|
|
384
|
-
},
|
|
385
|
-
pi: {
|
|
386
|
-
GET_API_KEY_PROVIDERS: "pi:getApiKeyProviders",
|
|
387
|
-
GET_PROVIDER_BASE_URL: "pi:getProviderBaseUrl",
|
|
388
|
-
GET_PROVIDER_MODELS: "pi:getProviderModels"
|
|
389
|
-
},
|
|
390
|
-
dialog: {
|
|
391
|
-
OPEN_FOLDER: "dialog:openFolder"
|
|
392
|
-
},
|
|
393
|
-
preferences: {
|
|
394
|
-
READ: "preferences:read",
|
|
395
|
-
WRITE: "preferences:write"
|
|
396
|
-
},
|
|
397
|
-
drafts: {
|
|
398
|
-
GET: "drafts:get",
|
|
399
|
-
SET: "drafts:set",
|
|
400
|
-
DELETE: "drafts:delete",
|
|
401
|
-
GET_ALL: "drafts:getAll"
|
|
402
|
-
},
|
|
403
|
-
sources: {
|
|
404
|
-
GET: "sources:get",
|
|
405
|
-
CREATE: "sources:create",
|
|
406
|
-
DELETE: "sources:delete",
|
|
407
|
-
START_OAUTH: "sources:startOAuth",
|
|
408
|
-
SAVE_CREDENTIALS: "sources:saveCredentials",
|
|
409
|
-
CHANGED: "sources:changed",
|
|
410
|
-
GET_PERMISSIONS: "sources:getPermissions",
|
|
411
|
-
GET_MCP_TOOLS: "sources:getMcpTools"
|
|
412
|
-
},
|
|
413
|
-
oauth: {
|
|
414
|
-
START: "oauth:start",
|
|
415
|
-
COMPLETE: "oauth:complete",
|
|
416
|
-
CANCEL: "oauth:cancel",
|
|
417
|
-
REVOKE: "oauth:revoke"
|
|
418
|
-
},
|
|
419
|
-
workspace: {
|
|
420
|
-
GET_PERMISSIONS: "workspace:getPermissions",
|
|
421
|
-
READ_IMAGE: "workspace:readImage",
|
|
422
|
-
WRITE_IMAGE: "workspace:writeImage",
|
|
423
|
-
SETTINGS_GET: "workspaceSettings:get",
|
|
424
|
-
SETTINGS_UPDATE: "workspaceSettings:update"
|
|
425
|
-
},
|
|
426
|
-
permissions: {
|
|
427
|
-
GET_DEFAULTS: "permissions:getDefaults",
|
|
428
|
-
DEFAULTS_CHANGED: "permissions:defaultsChanged"
|
|
429
|
-
},
|
|
430
|
-
skills: {
|
|
431
|
-
GET: "skills:get",
|
|
432
|
-
GET_FILES: "skills:getFiles",
|
|
433
|
-
DELETE: "skills:delete",
|
|
434
|
-
OPEN_EDITOR: "skills:openEditor",
|
|
435
|
-
OPEN_FINDER: "skills:openFinder",
|
|
436
|
-
CHANGED: "skills:changed"
|
|
437
|
-
},
|
|
438
|
-
statuses: {
|
|
439
|
-
LIST: "statuses:list",
|
|
440
|
-
REORDER: "statuses:reorder",
|
|
441
|
-
CHANGED: "statuses:changed"
|
|
442
|
-
},
|
|
443
|
-
labels: {
|
|
444
|
-
LIST: "labels:list",
|
|
445
|
-
CREATE: "labels:create",
|
|
446
|
-
DELETE: "labels:delete",
|
|
447
|
-
CHANGED: "labels:changed"
|
|
448
|
-
},
|
|
449
|
-
views: {
|
|
450
|
-
LIST: "views:list",
|
|
451
|
-
SAVE: "views:save"
|
|
452
|
-
},
|
|
453
|
-
toolIcons: {
|
|
454
|
-
GET_MAPPINGS: "toolIcons:getMappings"
|
|
455
|
-
},
|
|
456
|
-
logo: {
|
|
457
|
-
GET_URL: "logo:getUrl"
|
|
458
|
-
},
|
|
459
|
-
notification: {
|
|
460
|
-
SHOW: "notification:show",
|
|
461
|
-
NAVIGATE: "notification:navigate",
|
|
462
|
-
GET_ENABLED: "notification:getEnabled",
|
|
463
|
-
SET_ENABLED: "notification:setEnabled"
|
|
464
|
-
},
|
|
465
|
-
input: {
|
|
466
|
-
GET_AUTO_CAPITALISATION: "input:getAutoCapitalisation",
|
|
467
|
-
SET_AUTO_CAPITALISATION: "input:setAutoCapitalisation",
|
|
468
|
-
GET_SEND_MESSAGE_KEY: "input:getSendMessageKey",
|
|
469
|
-
SET_SEND_MESSAGE_KEY: "input:setSendMessageKey",
|
|
470
|
-
GET_SPELL_CHECK: "input:getSpellCheck",
|
|
471
|
-
SET_SPELL_CHECK: "input:setSpellCheck"
|
|
472
|
-
},
|
|
473
|
-
power: {
|
|
474
|
-
GET_KEEP_AWAKE: "power:getKeepAwake",
|
|
475
|
-
SET_KEEP_AWAKE: "power:setKeepAwake"
|
|
476
|
-
},
|
|
477
|
-
appearance: {
|
|
478
|
-
GET_RICH_TOOL_DESCRIPTIONS: "appearance:getRichToolDescriptions",
|
|
479
|
-
SET_RICH_TOOL_DESCRIPTIONS: "appearance:setRichToolDescriptions"
|
|
480
|
-
},
|
|
481
|
-
tools: {
|
|
482
|
-
GET_BROWSER_TOOL_ENABLED: "tools:getBrowserToolEnabled",
|
|
483
|
-
SET_BROWSER_TOOL_ENABLED: "tools:setBrowserToolEnabled"
|
|
484
|
-
},
|
|
485
|
-
caching: {
|
|
486
|
-
GET_EXTENDED_PROMPT_CACHE: "caching:getExtendedPromptCache",
|
|
487
|
-
SET_EXTENDED_PROMPT_CACHE: "caching:setExtendedPromptCache",
|
|
488
|
-
GET_ENABLE_1M_CONTEXT: "caching:getEnable1MContext",
|
|
489
|
-
SET_ENABLE_1M_CONTEXT: "caching:setEnable1MContext"
|
|
490
|
-
},
|
|
491
|
-
badge: {
|
|
492
|
-
REFRESH: "badge:refresh",
|
|
493
|
-
SET_ICON: "badge:setIcon",
|
|
494
|
-
DRAW: "badge:draw",
|
|
495
|
-
DRAW_WINDOWS: "badge:draw-windows"
|
|
496
|
-
},
|
|
497
|
-
releaseNotes: {
|
|
498
|
-
GET: "releaseNotes:get",
|
|
499
|
-
GET_LATEST_VERSION: "releaseNotes:getLatestVersion"
|
|
500
|
-
},
|
|
501
|
-
git: {
|
|
502
|
-
GET_BRANCH: "git:getBranch"
|
|
503
|
-
},
|
|
504
|
-
gitbash: {
|
|
505
|
-
CHECK: "gitbash:check",
|
|
506
|
-
BROWSE: "gitbash:browse",
|
|
507
|
-
SET_PATH: "gitbash:setPath"
|
|
508
|
-
},
|
|
509
|
-
browserPane: {
|
|
510
|
-
CREATE: "browser-pane:create",
|
|
511
|
-
DESTROY: "browser-pane:destroy",
|
|
512
|
-
LIST: "browser-pane:list",
|
|
513
|
-
NAVIGATE: "browser-pane:navigate",
|
|
514
|
-
GO_BACK: "browser-pane:go-back",
|
|
515
|
-
GO_FORWARD: "browser-pane:go-forward",
|
|
516
|
-
RELOAD: "browser-pane:reload",
|
|
517
|
-
STOP: "browser-pane:stop",
|
|
518
|
-
FOCUS: "browser-pane:focus",
|
|
519
|
-
SNAPSHOT: "browser-pane:snapshot",
|
|
520
|
-
CLICK: "browser-pane:click",
|
|
521
|
-
FILL: "browser-pane:fill",
|
|
522
|
-
SELECT: "browser-pane:select",
|
|
523
|
-
SCREENSHOT: "browser-pane:screenshot",
|
|
524
|
-
EVALUATE: "browser-pane:evaluate",
|
|
525
|
-
SCROLL: "browser-pane:scroll",
|
|
526
|
-
LAUNCH: "browser-empty-state:launch",
|
|
527
|
-
STATE_CHANGED: "browser-pane:state-changed",
|
|
528
|
-
REMOVED: "browser-pane:removed",
|
|
529
|
-
INTERACTED: "browser-pane:interacted"
|
|
530
|
-
},
|
|
531
|
-
automations: {
|
|
532
|
-
GET: "automations:get",
|
|
533
|
-
TEST: "automations:test",
|
|
534
|
-
SET_ENABLED: "automations:setEnabled",
|
|
535
|
-
DUPLICATE: "automations:duplicate",
|
|
536
|
-
DELETE: "automations:delete",
|
|
537
|
-
GET_HISTORY: "automations:getHistory",
|
|
538
|
-
GET_LAST_EXECUTED: "automations:getLastExecuted",
|
|
539
|
-
REPLAY: "automations:replay",
|
|
540
|
-
CHANGED: "automations:changed"
|
|
541
|
-
},
|
|
542
|
-
resources: {
|
|
543
|
-
EXPORT: "resources:export",
|
|
544
|
-
IMPORT: "resources:import"
|
|
545
|
-
},
|
|
546
|
-
messaging: {
|
|
547
|
-
// WhatsApp subprocess → Gateway (subprocess invokes on server)
|
|
548
|
-
WA_REGISTER: "messaging:wa:register",
|
|
549
|
-
WA_INCOMING: "messaging:wa:incoming",
|
|
550
|
-
WA_BUTTON_PRESS: "messaging:wa:buttonPress",
|
|
551
|
-
WA_STATUS: "messaging:wa:status",
|
|
552
|
-
WA_QR: "messaging:wa:qr",
|
|
553
|
-
// Gateway → WhatsApp subprocess (server invokes on client)
|
|
554
|
-
WA_SEND: "messaging:wa:send",
|
|
555
|
-
WA_SEND_BUTTONS: "messaging:wa:sendButtons",
|
|
556
|
-
WA_SEND_TYPING: "messaging:wa:sendTyping",
|
|
557
|
-
WA_SEND_FILE: "messaging:wa:sendFile",
|
|
558
|
-
WA_CONNECT: "messaging:wa:connect",
|
|
559
|
-
WA_DISCONNECT: "messaging:wa:disconnect",
|
|
560
|
-
// Gateway → UI clients (broadcast)
|
|
561
|
-
BINDING_CHANGED: "messaging:bindingChanged",
|
|
562
|
-
PLATFORM_STATUS: "messaging:platformStatus",
|
|
563
|
-
/** Broadcast when the workspace's pending-senders list mutates. */
|
|
564
|
-
PENDING_CHANGED: "messaging:pendingChanged",
|
|
565
|
-
// UI ↔ Server (config/binding CRUD)
|
|
566
|
-
GET_CONFIG: "messaging:getConfig",
|
|
567
|
-
UPDATE_CONFIG: "messaging:updateConfig",
|
|
568
|
-
TEST_TELEGRAM: "messaging:testTelegram",
|
|
569
|
-
SAVE_TELEGRAM: "messaging:saveTelegram",
|
|
570
|
-
TEST_LARK: "messaging:testLark",
|
|
571
|
-
SAVE_LARK: "messaging:saveLark",
|
|
572
|
-
DISCONNECT: "messaging:disconnect",
|
|
573
|
-
FORGET: "messaging:forget",
|
|
574
|
-
GET_BINDINGS: "messaging:getBindings",
|
|
575
|
-
GENERATE_CODE: "messaging:generateCode",
|
|
576
|
-
UNBIND: "messaging:unbind",
|
|
577
|
-
UNBIND_BINDING: "messaging:unbindBinding",
|
|
578
|
-
/** Workspace-supergroup pairing (Telegram forum support). UI ↔ Server. */
|
|
579
|
-
GENERATE_SUPERGROUP_CODE: "messaging:generateSupergroupCode",
|
|
580
|
-
GET_SUPERGROUP: "messaging:getSupergroup",
|
|
581
|
-
UNBIND_SUPERGROUP: "messaging:unbindSupergroup",
|
|
582
|
-
// UI ↔ Server — WhatsApp pairing/connection flow (Baileys subprocess adapter)
|
|
583
|
-
WA_START_CONNECT: "messaging:wa:startConnect",
|
|
584
|
-
WA_SUBMIT_PHONE: "messaging:wa:submitPhone",
|
|
585
|
-
/** Broadcast to UI clients: QR string, pairing code, status, unavailable, error. */
|
|
586
|
-
WA_UI_EVENT: "messaging:wa:uiEvent",
|
|
587
|
-
// UI ↔ Server — Access control (per-platform owners + per-binding allow-list)
|
|
588
|
-
GET_PLATFORM_OWNERS: "messaging:access:getOwners",
|
|
589
|
-
SET_PLATFORM_OWNERS: "messaging:access:setOwners",
|
|
590
|
-
GET_PLATFORM_ACCESS_MODE: "messaging:access:getMode",
|
|
591
|
-
SET_PLATFORM_ACCESS_MODE: "messaging:access:setMode",
|
|
592
|
-
GET_PENDING_SENDERS: "messaging:access:getPending",
|
|
593
|
-
DISMISS_PENDING_SENDER: "messaging:access:dismissPending",
|
|
594
|
-
ALLOW_PENDING_SENDER: "messaging:access:allowPending",
|
|
595
|
-
SET_BINDING_ACCESS: "messaging:access:setBindingAccess"
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
var SKILL_PATTERN = /\[skill:([^\]]+)\]/g;
|
|
599
|
-
var SOURCE_PATTERN = /\[source:([^\]]+)\]/g;
|
|
600
|
-
var FILE_PATTERN = /\[file:([^\]]+)\]/g;
|
|
601
|
-
var FOLDER_PATTERN = /\[folder:([^\]]+)\]/g;
|
|
602
|
-
function parseMentions(text, availableSkillSlugs, availableSourceSlugs) {
|
|
603
|
-
const skillSet = new Set(availableSkillSlugs);
|
|
604
|
-
const sourceSet = new Set(availableSourceSlugs);
|
|
605
|
-
const skills = [];
|
|
606
|
-
const invalidSkills = [];
|
|
607
|
-
const sources = [];
|
|
608
|
-
const files = [];
|
|
609
|
-
const folders = [];
|
|
610
|
-
for (const match of text.matchAll(SKILL_PATTERN)) {
|
|
611
|
-
const slug = extractSkillSlug(match[1]);
|
|
612
|
-
if (skillSet.has(slug)) {
|
|
613
|
-
if (!skills.includes(slug)) skills.push(slug);
|
|
614
|
-
} else {
|
|
615
|
-
if (!invalidSkills.includes(slug)) invalidSkills.push(slug);
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
for (const match of text.matchAll(SOURCE_PATTERN)) {
|
|
619
|
-
const slug = match[1].trim();
|
|
620
|
-
if (sourceSet.has(slug) && !sources.includes(slug)) {
|
|
621
|
-
sources.push(slug);
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
for (const match of text.matchAll(FILE_PATTERN)) {
|
|
625
|
-
const path = match[1].trim();
|
|
626
|
-
if (path && !files.includes(path)) files.push(path);
|
|
627
|
-
}
|
|
628
|
-
for (const match of text.matchAll(FOLDER_PATTERN)) {
|
|
629
|
-
const path = match[1].trim();
|
|
630
|
-
if (path && !folders.includes(path)) folders.push(path);
|
|
631
|
-
}
|
|
632
|
-
return { skills, invalidSkills, sources, files, folders };
|
|
633
|
-
}
|
|
634
|
-
function resolveSkillMentions(text, skillNames) {
|
|
635
|
-
return text.replace(SKILL_PATTERN, (full, raw) => {
|
|
636
|
-
const slug = extractSkillSlug(raw);
|
|
637
|
-
const displayName = skillNames.get(slug) ?? slug;
|
|
638
|
-
return `[Mentioned skill: ${displayName} (slug: ${slug})]`;
|
|
639
|
-
});
|
|
640
|
-
}
|
|
641
|
-
function resolveSourceMentions(text) {
|
|
642
|
-
return text.replace(SOURCE_PATTERN, (_, slug) => {
|
|
643
|
-
return `[Mentioned source: ${slug.trim()}]`;
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
async function resolvePathMentions(text, workingDirectory) {
|
|
647
|
-
const { basename } = await import("path");
|
|
648
|
-
const cwd = workingDirectory ?? process.cwd();
|
|
649
|
-
const fileMatches = [...text.matchAll(FILE_PATTERN)];
|
|
650
|
-
const folderMatches = [...text.matchAll(FOLDER_PATTERN)];
|
|
651
|
-
const fileReplacements = /* @__PURE__ */ new Map();
|
|
652
|
-
for (const match of fileMatches) {
|
|
653
|
-
const rawPath = match[1].trim();
|
|
654
|
-
const absPath = await resolvePath(rawPath, cwd);
|
|
655
|
-
const name = basename(absPath);
|
|
656
|
-
fileReplacements.set(match[0], `[Mentioned file: ${name} (at ${absPath})]`);
|
|
657
|
-
}
|
|
658
|
-
const folderReplacements = /* @__PURE__ */ new Map();
|
|
659
|
-
for (const match of folderMatches) {
|
|
660
|
-
const rawPath = match[1].trim();
|
|
661
|
-
const absPath = await resolvePath(rawPath, cwd);
|
|
662
|
-
const name = basename(absPath);
|
|
663
|
-
folderReplacements.set(match[0], `[Mentioned folder: ${name} (at ${absPath})]`);
|
|
664
|
-
}
|
|
665
|
-
let result = text;
|
|
666
|
-
for (const [original, replacement] of fileReplacements) {
|
|
667
|
-
result = result.replace(original, replacement);
|
|
668
|
-
}
|
|
669
|
-
for (const [original, replacement] of folderReplacements) {
|
|
670
|
-
result = result.replace(original, replacement);
|
|
671
|
-
}
|
|
672
|
-
return result;
|
|
673
|
-
}
|
|
674
|
-
function resolveFileMentions(text, workingDirectory) {
|
|
675
|
-
return resolvePathMentions(text, workingDirectory);
|
|
676
|
-
}
|
|
677
|
-
function stripAllMentions(text) {
|
|
678
|
-
let result = text;
|
|
679
|
-
result = result.replace(SKILL_PATTERN, (_, raw) => extractSkillSlug(raw));
|
|
680
|
-
result = result.replace(SOURCE_PATTERN, (_, slug) => slug.trim());
|
|
681
|
-
result = result.replace(FILE_PATTERN, (_, p) => p.trim());
|
|
682
|
-
result = result.replace(FOLDER_PATTERN, (_, p) => p.trim());
|
|
683
|
-
return result.replace(/\s{2,}/g, " ").trim();
|
|
684
|
-
}
|
|
685
|
-
function findMentionMatches(text, availableSkillSlugs, availableSourceSlugs) {
|
|
686
|
-
const matches = [];
|
|
687
|
-
for (const match of text.matchAll(SKILL_PATTERN)) {
|
|
688
|
-
matches.push({
|
|
689
|
-
type: "skill",
|
|
690
|
-
id: extractSkillSlug(match[1]),
|
|
691
|
-
fullMatch: match[0],
|
|
692
|
-
startIndex: match.index
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
for (const match of text.matchAll(SOURCE_PATTERN)) {
|
|
696
|
-
matches.push({
|
|
697
|
-
type: "source",
|
|
698
|
-
id: match[1].trim(),
|
|
699
|
-
fullMatch: match[0],
|
|
700
|
-
startIndex: match.index
|
|
701
|
-
});
|
|
702
|
-
}
|
|
703
|
-
for (const match of text.matchAll(FILE_PATTERN)) {
|
|
704
|
-
matches.push({
|
|
705
|
-
type: "file",
|
|
706
|
-
id: match[1].trim(),
|
|
707
|
-
fullMatch: match[0],
|
|
708
|
-
startIndex: match.index
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
for (const match of text.matchAll(FOLDER_PATTERN)) {
|
|
712
|
-
matches.push({
|
|
713
|
-
type: "folder",
|
|
714
|
-
id: match[1].trim(),
|
|
715
|
-
fullMatch: match[0],
|
|
716
|
-
startIndex: match.index
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
|
-
return matches.sort((a, b) => a.startIndex - b.startIndex);
|
|
720
|
-
}
|
|
721
|
-
function extractSkillSlug(raw) {
|
|
722
|
-
const parts = raw.trim().split(":");
|
|
723
|
-
return parts[parts.length - 1].trim();
|
|
724
|
-
}
|
|
725
|
-
async function resolvePath(path, cwd) {
|
|
726
|
-
const { resolve } = await import("path");
|
|
727
|
-
if (path.startsWith("~")) {
|
|
728
|
-
const { homedir } = await import("os");
|
|
729
|
-
return resolve(homedir(), path.slice(2));
|
|
730
|
-
}
|
|
731
|
-
if (path.startsWith("/")) return path;
|
|
732
|
-
return resolve(cwd, path);
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
// ../packages/timeline/dist/index.js
|
|
736
|
-
function createTimelineSequencer(options) {
|
|
737
|
-
let seq = options.startSeq ?? 0;
|
|
738
|
-
const now = options.now ?? Date.now;
|
|
739
|
-
return {
|
|
740
|
-
append(item, rawRef) {
|
|
741
|
-
seq += 1;
|
|
742
|
-
return appendTimelineItem({
|
|
743
|
-
sessionId: options.sessionId,
|
|
744
|
-
provider: options.provider,
|
|
745
|
-
epoch: options.epoch,
|
|
746
|
-
seq,
|
|
747
|
-
timestamp: now(),
|
|
748
|
-
item,
|
|
749
|
-
rawRef
|
|
750
|
-
});
|
|
751
|
-
}
|
|
752
|
-
};
|
|
753
|
-
}
|
|
754
|
-
function appendTimelineItem(envelope) {
|
|
755
|
-
return {
|
|
756
|
-
...envelope,
|
|
757
|
-
rawRef: envelope.rawRef ? { ...envelope.rawRef } : void 0
|
|
758
|
-
};
|
|
759
|
-
}
|
|
760
|
-
function createTimelineCursor(cursor) {
|
|
761
|
-
return {
|
|
762
|
-
epoch: cursor.epoch,
|
|
763
|
-
afterSeq: cursor.afterSeq
|
|
764
|
-
};
|
|
765
|
-
}
|
|
766
|
-
function fetchTimeline(timeline, request = {}) {
|
|
767
|
-
const ordered = sortTimeline(timeline);
|
|
768
|
-
const cursor = request.cursor ?? cursorFromTimelineStart(ordered);
|
|
769
|
-
const items = ordered.filter((item) => item.epoch === cursor.epoch && item.seq > cursor.afterSeq).slice(0, request.limit);
|
|
770
|
-
const lastSeq = items.at(-1)?.seq ?? cursor.afterSeq;
|
|
771
|
-
const firstSeq = items[0]?.seq;
|
|
772
|
-
return {
|
|
773
|
-
items,
|
|
774
|
-
nextCursor: {
|
|
775
|
-
epoch: cursor.epoch,
|
|
776
|
-
afterSeq: lastSeq
|
|
777
|
-
},
|
|
778
|
-
hasGap: firstSeq !== void 0 && firstSeq > cursor.afterSeq + 1
|
|
779
|
-
};
|
|
780
|
-
}
|
|
781
|
-
function mergeTimeline(existing, incoming) {
|
|
782
|
-
const byKey = /* @__PURE__ */ new Map();
|
|
783
|
-
for (const item of [...existing, ...incoming]) {
|
|
784
|
-
byKey.set(timelineKey(item), item);
|
|
785
|
-
}
|
|
786
|
-
return sortTimeline([...byKey.values()]);
|
|
787
|
-
}
|
|
788
|
-
function cursorFromTimelineStart(timeline) {
|
|
789
|
-
return {
|
|
790
|
-
epoch: timeline[0]?.epoch ?? "default",
|
|
791
|
-
afterSeq: 0
|
|
792
|
-
};
|
|
793
|
-
}
|
|
794
|
-
function sortTimeline(timeline) {
|
|
795
|
-
return [...timeline].sort((left, right) => {
|
|
796
|
-
if (left.epoch !== right.epoch) return left.epoch.localeCompare(right.epoch);
|
|
797
|
-
return left.seq - right.seq;
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
|
-
function timelineKey(item) {
|
|
801
|
-
return `${item.epoch}:${item.seq}`;
|
|
802
|
-
}
|
|
43
|
+
// ../packages/react/src/use-agent-session.ts
|
|
44
|
+
var import_react = require("react");
|
|
803
45
|
|
|
804
46
|
// ../packages/runtime-core/dist/index.js
|
|
805
47
|
var RUNTIME_KINDS = ["native-sdk", "app-server", "compatible-sdk", "cli-fallback"];
|
|
@@ -902,203 +144,9 @@ function createRuntimeExtensionContext(context = {}) {
|
|
|
902
144
|
hostServices: context.hostServices
|
|
903
145
|
};
|
|
904
146
|
}
|
|
905
|
-
function sanitizeProviderSourceTools(sourceTools) {
|
|
906
|
-
if (!sourceTools || sourceTools.length === 0) return [];
|
|
907
|
-
const sanitized = [];
|
|
908
|
-
for (const sourceTool of sourceTools) {
|
|
909
|
-
if (sourceTool.kind === "api-source") {
|
|
910
|
-
const defaultHeaders = sourceTool.defaultHeaders ? copyNonCredentialStringRecord(sourceTool.defaultHeaders) : void 0;
|
|
911
|
-
sanitized.push({
|
|
912
|
-
kind: "api-source",
|
|
913
|
-
sourceSlug: sourceTool.sourceSlug,
|
|
914
|
-
baseUrl: sourceTool.baseUrl,
|
|
915
|
-
authType: sourceTool.authType,
|
|
916
|
-
...defaultHeaders && Object.keys(defaultHeaders).length > 0 ? { defaultHeaders } : {},
|
|
917
|
-
...sourceTool.credentialRef ? { credentialRef: sanitizeSourceCredentialRef(sourceTool.credentialRef) } : {}
|
|
918
|
-
});
|
|
919
|
-
continue;
|
|
920
|
-
}
|
|
921
|
-
if (sourceTool.kind === "local-source") {
|
|
922
|
-
sanitized.push({
|
|
923
|
-
kind: "local-source",
|
|
924
|
-
sourceSlug: sourceTool.sourceSlug,
|
|
925
|
-
path: sourceTool.path,
|
|
926
|
-
...sourceTool.format ? { format: sourceTool.format } : {}
|
|
927
|
-
});
|
|
928
|
-
continue;
|
|
929
|
-
}
|
|
930
|
-
if (sourceTool.kind === "mcp-server") {
|
|
931
|
-
const env = sourceTool.env ? copyNonCredentialStringRecord(sourceTool.env) : void 0;
|
|
932
|
-
const headers = sourceTool.headers ? copyNonCredentialStringRecord(sourceTool.headers) : void 0;
|
|
933
|
-
sanitized.push({
|
|
934
|
-
kind: "mcp-server",
|
|
935
|
-
sourceSlug: sourceTool.sourceSlug,
|
|
936
|
-
transport: sourceTool.transport,
|
|
937
|
-
...sourceTool.url ? { url: sourceTool.url } : {},
|
|
938
|
-
...sourceTool.command ? { command: sourceTool.command } : {},
|
|
939
|
-
...sourceTool.args ? { args: sourceTool.args.filter((value) => typeof value === "string") } : {},
|
|
940
|
-
...env && Object.keys(env).length > 0 ? { env } : {},
|
|
941
|
-
...headers && Object.keys(headers).length > 0 ? { headers } : {},
|
|
942
|
-
...sourceTool.credentialRef ? { credentialRef: sanitizeSourceCredentialRef(sourceTool.credentialRef) } : {}
|
|
943
|
-
});
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
return sanitized;
|
|
947
|
-
}
|
|
948
|
-
var sessionToolRequestCounter = 0;
|
|
949
|
-
async function invokeSessionTool(options) {
|
|
950
|
-
const requestId = `session-tool-${++sessionToolRequestCounter}`;
|
|
951
|
-
const origin = originFromSessionToolRequest(options.request) ?? options.commandOrigin;
|
|
952
|
-
const policyDecision = await evaluateSessionToolPolicy(options, requestId);
|
|
953
|
-
const timelineRefs = [];
|
|
954
|
-
const append = (item) => {
|
|
955
|
-
const envelope = options.appendTimeline?.(item);
|
|
956
|
-
if (envelope) {
|
|
957
|
-
timelineRefs.push({ epoch: envelope.epoch, seq: envelope.seq });
|
|
958
|
-
}
|
|
959
|
-
};
|
|
960
|
-
if (policyDecision.decision !== "allow") {
|
|
961
|
-
const reason = policyDecision.decision === "deny" ? policyDecision.reason : policyDecision.reason;
|
|
962
|
-
append({
|
|
963
|
-
type: "host_state_changed",
|
|
964
|
-
state: {
|
|
965
|
-
kind: "host_tool_denied",
|
|
966
|
-
requestId,
|
|
967
|
-
toolName: options.toolName,
|
|
968
|
-
reason
|
|
969
|
-
}
|
|
970
|
-
});
|
|
971
|
-
return {
|
|
972
|
-
ok: false,
|
|
973
|
-
requestId,
|
|
974
|
-
toolName: options.toolName,
|
|
975
|
-
origin,
|
|
976
|
-
policyDecision,
|
|
977
|
-
reason,
|
|
978
|
-
timelineRefs
|
|
979
|
-
};
|
|
980
|
-
}
|
|
981
|
-
append({
|
|
982
|
-
type: "host_state_changed",
|
|
983
|
-
state: {
|
|
984
|
-
kind: "host_tool_invoked",
|
|
985
|
-
requestId,
|
|
986
|
-
toolName: options.toolName,
|
|
987
|
-
...origin ? { origin } : {}
|
|
988
|
-
}
|
|
989
|
-
});
|
|
990
|
-
const callback = options.bridge[options.toolName];
|
|
991
|
-
if (!callback) {
|
|
992
|
-
const reason = `Session tool bridge callback is not registered: ${String(options.toolName)}`;
|
|
993
|
-
append({
|
|
994
|
-
type: "host_state_changed",
|
|
995
|
-
state: {
|
|
996
|
-
kind: "host_tool_result",
|
|
997
|
-
requestId,
|
|
998
|
-
toolName: options.toolName,
|
|
999
|
-
ok: false,
|
|
1000
|
-
reason
|
|
1001
|
-
}
|
|
1002
|
-
});
|
|
1003
|
-
return {
|
|
1004
|
-
ok: false,
|
|
1005
|
-
requestId,
|
|
1006
|
-
toolName: options.toolName,
|
|
1007
|
-
origin,
|
|
1008
|
-
policyDecision,
|
|
1009
|
-
reason,
|
|
1010
|
-
timelineRefs
|
|
1011
|
-
};
|
|
1012
|
-
}
|
|
1013
|
-
try {
|
|
1014
|
-
const result = await callback(options.request);
|
|
1015
|
-
append({
|
|
1016
|
-
type: "host_state_changed",
|
|
1017
|
-
state: {
|
|
1018
|
-
kind: "host_tool_result",
|
|
1019
|
-
requestId,
|
|
1020
|
-
toolName: options.toolName,
|
|
1021
|
-
ok: true
|
|
1022
|
-
}
|
|
1023
|
-
});
|
|
1024
|
-
return {
|
|
1025
|
-
ok: true,
|
|
1026
|
-
requestId,
|
|
1027
|
-
toolName: options.toolName,
|
|
1028
|
-
origin,
|
|
1029
|
-
policyDecision,
|
|
1030
|
-
result,
|
|
1031
|
-
timelineRefs
|
|
1032
|
-
};
|
|
1033
|
-
} catch (error) {
|
|
1034
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
1035
|
-
append({
|
|
1036
|
-
type: "host_state_changed",
|
|
1037
|
-
state: {
|
|
1038
|
-
kind: "host_tool_result",
|
|
1039
|
-
requestId,
|
|
1040
|
-
toolName: options.toolName,
|
|
1041
|
-
ok: false,
|
|
1042
|
-
reason
|
|
1043
|
-
}
|
|
1044
|
-
});
|
|
1045
|
-
return {
|
|
1046
|
-
ok: false,
|
|
1047
|
-
requestId,
|
|
1048
|
-
toolName: options.toolName,
|
|
1049
|
-
origin,
|
|
1050
|
-
policyDecision,
|
|
1051
|
-
reason,
|
|
1052
|
-
timelineRefs
|
|
1053
|
-
};
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
async function evaluateSessionToolPolicy(options, requestId) {
|
|
1057
|
-
if (!options.policy) return { decision: "allow" };
|
|
1058
|
-
return options.policy({
|
|
1059
|
-
toolName: `host.${String(options.toolName)}`,
|
|
1060
|
-
input: recordFromSessionToolRequest(options.request),
|
|
1061
|
-
toolIntent: { kind: "unknown", toolName: `host.${String(options.toolName)}` },
|
|
1062
|
-
scope: { type: "session", sessionId: options.sessionId }
|
|
1063
|
-
});
|
|
1064
|
-
}
|
|
1065
|
-
function originFromSessionToolRequest(request) {
|
|
1066
|
-
const record = recordFromSessionToolRequest(request);
|
|
1067
|
-
const origin = record.origin ?? record.commandOrigin;
|
|
1068
|
-
return isCommandOrigin(origin) ? origin : void 0;
|
|
1069
|
-
}
|
|
1070
|
-
function recordFromSessionToolRequest(request) {
|
|
1071
|
-
return request && typeof request === "object" ? { ...request } : {};
|
|
1072
|
-
}
|
|
1073
|
-
function isCommandOrigin(value) {
|
|
1074
|
-
if (!value || typeof value !== "object") return false;
|
|
1075
|
-
const type = value.type;
|
|
1076
|
-
return type === "user" || type === "automation" || type === "scheduler" || type === "host" || type === "replay" || type === "system";
|
|
1077
|
-
}
|
|
1078
147
|
function unique(values) {
|
|
1079
148
|
return [...new Set(values)];
|
|
1080
149
|
}
|
|
1081
|
-
function sanitizeSourceCredentialRef(credentialRef) {
|
|
1082
|
-
return {
|
|
1083
|
-
type: credentialRef.type,
|
|
1084
|
-
sourceSlug: credentialRef.sourceSlug,
|
|
1085
|
-
...credentialRef.workspaceId ? { workspaceId: credentialRef.workspaceId } : {}
|
|
1086
|
-
};
|
|
1087
|
-
}
|
|
1088
|
-
function copyStringRecord(record) {
|
|
1089
|
-
return Object.fromEntries(
|
|
1090
|
-
Object.entries(record).filter((entry) => typeof entry[0] === "string" && typeof entry[1] === "string")
|
|
1091
|
-
);
|
|
1092
|
-
}
|
|
1093
|
-
function copyNonCredentialStringRecord(record) {
|
|
1094
|
-
return Object.fromEntries(
|
|
1095
|
-
Object.entries(copyStringRecord(record)).filter(([key]) => !isCredentialKey(key))
|
|
1096
|
-
);
|
|
1097
|
-
}
|
|
1098
|
-
function isCredentialKey(key) {
|
|
1099
|
-
const normalized = key.toLowerCase();
|
|
1100
|
-
return normalized === "authorization" || normalized === "proxy-authorization" || normalized === "cookie" || normalized === "set-cookie" || normalized.includes("api-key") || normalized.includes("apikey") || normalized.includes("token") || normalized.includes("secret") || normalized.includes("password");
|
|
1101
|
-
}
|
|
1102
150
|
function findCandidate(candidates, kind) {
|
|
1103
151
|
return candidates.find((candidate) => candidate.kind === kind);
|
|
1104
152
|
}
|
|
@@ -1184,463 +232,51 @@ function normalizeExtensionCapabilities(capabilities = {}) {
|
|
|
1184
232
|
};
|
|
1185
233
|
}
|
|
1186
234
|
|
|
1187
|
-
// ../packages/
|
|
1188
|
-
|
|
1189
|
-
var DANGEROUS_BASH_COMMANDS = /* @__PURE__ */ new Set([
|
|
1190
|
-
"rm",
|
|
1191
|
-
"rmdir",
|
|
1192
|
-
"sudo",
|
|
1193
|
-
"su",
|
|
1194
|
-
"chmod",
|
|
1195
|
-
"chown",
|
|
1196
|
-
"chgrp",
|
|
1197
|
-
"mv",
|
|
1198
|
-
"cp",
|
|
1199
|
-
"dd",
|
|
1200
|
-
"mkfs",
|
|
1201
|
-
"fdisk",
|
|
1202
|
-
"parted",
|
|
1203
|
-
"kill",
|
|
1204
|
-
"killall",
|
|
1205
|
-
"pkill",
|
|
1206
|
-
"reboot",
|
|
1207
|
-
"shutdown",
|
|
1208
|
-
"halt",
|
|
1209
|
-
"poweroff",
|
|
1210
|
-
"curl",
|
|
1211
|
-
"wget",
|
|
1212
|
-
"ssh",
|
|
1213
|
-
"scp",
|
|
1214
|
-
"rsync"
|
|
1215
|
-
]);
|
|
1216
|
-
var READ_ONLY_BASH_PATTERNS = [
|
|
1217
|
-
/^git\s+status(\s|$)/,
|
|
1218
|
-
/^git\s+diff(\s|$)/,
|
|
1219
|
-
/^git\s+log(\s|$)/,
|
|
1220
|
-
/^ls(\s|$)/,
|
|
1221
|
-
/^pwd(\s|$)/,
|
|
1222
|
-
/^cat\s+/,
|
|
1223
|
-
/^sed\s+-n\s+/,
|
|
1224
|
-
/^rg(\s|$)/,
|
|
1225
|
-
/^find\s+/
|
|
1226
|
-
];
|
|
1227
|
-
function createPermissionPolicy(options = {}) {
|
|
1228
|
-
return {
|
|
1229
|
-
mode: options.mode ?? "ask",
|
|
1230
|
-
alwaysAllow: [...options.alwaysAllow ?? []],
|
|
1231
|
-
approvals: [...options.approvals ?? []],
|
|
1232
|
-
layers: [...options.layers ?? []]
|
|
1233
|
-
};
|
|
1234
|
-
}
|
|
1235
|
-
function createSourcePolicyLayer(options) {
|
|
1236
|
-
return {
|
|
1237
|
-
id: options.id ?? `source:${options.sourceSlug}`,
|
|
1238
|
-
rules: {
|
|
1239
|
-
...options.rules,
|
|
1240
|
-
allowedMcpPatterns: options.rules.allowedMcpPatterns?.map(
|
|
1241
|
-
(pattern) => scopeMcpPatternToSource(options.sourceSlug, pattern)
|
|
1242
|
-
)
|
|
1243
|
-
}
|
|
1244
|
-
};
|
|
1245
|
-
}
|
|
1246
|
-
function validatePolicyConfig(input) {
|
|
1247
|
-
const errors = [];
|
|
1248
|
-
const warnings = [];
|
|
1249
|
-
const config = asRecord(input);
|
|
1250
|
-
const mode = config.mode;
|
|
1251
|
-
if (mode !== void 0 && !isPermissionMode(mode)) {
|
|
1252
|
-
errors.push({
|
|
1253
|
-
path: "mode",
|
|
1254
|
-
message: `Invalid permission mode: ${String(mode)}`,
|
|
1255
|
-
suggestion: "Use one of: safe, ask, allow-all"
|
|
1256
|
-
});
|
|
1257
|
-
}
|
|
1258
|
-
if (config.layers !== void 0 && !Array.isArray(config.layers)) {
|
|
1259
|
-
errors.push({
|
|
1260
|
-
path: "layers",
|
|
1261
|
-
message: "Expected layers to be an array"
|
|
1262
|
-
});
|
|
1263
|
-
}
|
|
1264
|
-
if (Array.isArray(config.layers)) {
|
|
1265
|
-
config.layers.forEach((layerValue, layerIndex) => {
|
|
1266
|
-
const layer = asRecord(layerValue);
|
|
1267
|
-
const basePath = `layers[${layerIndex}]`;
|
|
1268
|
-
if (typeof layer.id !== "string" || layer.id.length === 0) {
|
|
1269
|
-
errors.push({
|
|
1270
|
-
path: `${basePath}.id`,
|
|
1271
|
-
message: "Layer id is required"
|
|
1272
|
-
});
|
|
1273
|
-
}
|
|
1274
|
-
validateRuleSet(layer.rules, `${basePath}.rules`, errors);
|
|
1275
|
-
});
|
|
1276
|
-
}
|
|
1277
|
-
return {
|
|
1278
|
-
valid: errors.length === 0,
|
|
1279
|
-
errors,
|
|
1280
|
-
warnings
|
|
1281
|
-
};
|
|
1282
|
-
}
|
|
1283
|
-
function createPermissionPolicyFromConfig(input) {
|
|
1284
|
-
const validation = validatePolicyConfig(input);
|
|
1285
|
-
if (!validation.valid) return { validation };
|
|
1286
|
-
const config = asRecord(input);
|
|
1287
|
-
return {
|
|
1288
|
-
validation,
|
|
1289
|
-
policy: createPermissionPolicy({
|
|
1290
|
-
mode: config.mode,
|
|
1291
|
-
alwaysAllow: config.alwaysAllow,
|
|
1292
|
-
approvals: config.approvals,
|
|
1293
|
-
layers: (config.layers ?? []).map(
|
|
1294
|
-
(layer) => layer.sourceSlug ? createSourcePolicyLayer({
|
|
1295
|
-
id: layer.id,
|
|
1296
|
-
sourceSlug: layer.sourceSlug,
|
|
1297
|
-
rules: layer.rules
|
|
1298
|
-
}) : {
|
|
1299
|
-
id: layer.id,
|
|
1300
|
-
rules: layer.rules,
|
|
1301
|
-
scope: layer.scope
|
|
1302
|
-
}
|
|
1303
|
-
)
|
|
1304
|
-
})
|
|
1305
|
-
};
|
|
1306
|
-
}
|
|
1307
|
-
function evaluateToolPolicy(policy, request) {
|
|
1308
|
-
const explanation = explainToolPolicy(policy, request);
|
|
1309
|
-
if (explanation.decision === "allow") return { decision: "allow" };
|
|
235
|
+
// ../packages/timeline/dist/index.js
|
|
236
|
+
function createTimelineCursor(cursor) {
|
|
1310
237
|
return {
|
|
1311
|
-
|
|
1312
|
-
|
|
238
|
+
epoch: cursor.epoch,
|
|
239
|
+
afterSeq: cursor.afterSeq
|
|
1313
240
|
};
|
|
1314
241
|
}
|
|
1315
|
-
function
|
|
1316
|
-
const
|
|
1317
|
-
const
|
|
242
|
+
function fetchTimeline(timeline, request = {}) {
|
|
243
|
+
const ordered = sortTimeline(timeline);
|
|
244
|
+
const cursor = request.cursor ?? cursorFromTimelineStart(ordered);
|
|
245
|
+
const items = ordered.filter((item) => item.epoch === cursor.epoch && item.seq > cursor.afterSeq).slice(0, request.limit);
|
|
246
|
+
const lastSeq = items.at(-1)?.seq ?? cursor.afterSeq;
|
|
247
|
+
const firstSeq = items[0]?.seq;
|
|
1318
248
|
return {
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
...options.origin ? { origin: options.origin } : {},
|
|
1326
|
-
...options.ttl !== void 0 ? { ttl: options.ttl } : {},
|
|
1327
|
-
...explanation.hint ? { hint: explanation.hint } : {},
|
|
1328
|
-
...options.timelineRefs ? { timelineRefs: options.timelineRefs } : {}
|
|
249
|
+
items,
|
|
250
|
+
nextCursor: {
|
|
251
|
+
epoch: cursor.epoch,
|
|
252
|
+
afterSeq: lastSeq
|
|
253
|
+
},
|
|
254
|
+
hasGap: firstSeq !== void 0 && firstSeq > cursor.afterSeq + 1
|
|
1329
255
|
};
|
|
1330
256
|
}
|
|
1331
|
-
function
|
|
1332
|
-
const
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
}
|
|
1336
|
-
if (matchesAlwaysAllow(policy, request)) {
|
|
1337
|
-
return { decision: "allow", intent };
|
|
1338
|
-
}
|
|
1339
|
-
if (policy.mode === "allow-all") {
|
|
1340
|
-
return { decision: "allow", intent };
|
|
1341
|
-
}
|
|
1342
|
-
const layeredAllow = findLayeredAllow(policy, intent, request.scope);
|
|
1343
|
-
if (layeredAllow) {
|
|
1344
|
-
return {
|
|
1345
|
-
decision: "allow",
|
|
1346
|
-
intent,
|
|
1347
|
-
matchedRule: layeredAllow
|
|
1348
|
-
};
|
|
1349
|
-
}
|
|
1350
|
-
if (intent.kind === "file_write") {
|
|
1351
|
-
if (policy.mode === "ask") {
|
|
1352
|
-
return {
|
|
1353
|
-
decision: "ask",
|
|
1354
|
-
reason: `${intent.toolName} requires approval in ask mode`,
|
|
1355
|
-
intent
|
|
1356
|
-
};
|
|
1357
|
-
}
|
|
1358
|
-
return {
|
|
1359
|
-
decision: "deny",
|
|
1360
|
-
reason: `${intent.toolName} is blocked in safe mode`,
|
|
1361
|
-
intent
|
|
1362
|
-
};
|
|
1363
|
-
}
|
|
1364
|
-
if (intent.kind === "bash") {
|
|
1365
|
-
return evaluateBashPolicy(policy, intent);
|
|
1366
|
-
}
|
|
1367
|
-
if (intent.kind === "mcp" && policy.mode === "safe") {
|
|
1368
|
-
return {
|
|
1369
|
-
decision: "deny",
|
|
1370
|
-
reason: `MCP tool is blocked in safe mode: ${intent.name}`,
|
|
1371
|
-
intent
|
|
1372
|
-
};
|
|
1373
|
-
}
|
|
1374
|
-
if (intent.kind === "api" && policy.mode === "safe") {
|
|
1375
|
-
return {
|
|
1376
|
-
decision: "deny",
|
|
1377
|
-
reason: `API endpoint is blocked in safe mode: ${intent.method} ${intent.path}`,
|
|
1378
|
-
intent
|
|
1379
|
-
};
|
|
257
|
+
function mergeTimeline(existing, incoming) {
|
|
258
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
259
|
+
for (const item of [...existing, ...incoming]) {
|
|
260
|
+
byKey.set(timelineKey(item), item);
|
|
1380
261
|
}
|
|
1381
|
-
return
|
|
262
|
+
return sortTimeline([...byKey.values()]);
|
|
1382
263
|
}
|
|
1383
|
-
function
|
|
1384
|
-
const approvals = /* @__PURE__ */ new Map();
|
|
1385
|
-
const now = options.now ?? Date.now;
|
|
264
|
+
function cursorFromTimelineStart(timeline) {
|
|
1386
265
|
return {
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
...approval,
|
|
1390
|
-
createdAt: approval.createdAt ?? now()
|
|
1391
|
-
});
|
|
1392
|
-
},
|
|
1393
|
-
revoke(id) {
|
|
1394
|
-
approvals.delete(id);
|
|
1395
|
-
},
|
|
1396
|
-
snapshot() {
|
|
1397
|
-
const currentTime = now();
|
|
1398
|
-
return [...approvals.values()].filter((approval) => !approval.expiresAt || approval.expiresAt > currentTime);
|
|
1399
|
-
}
|
|
266
|
+
epoch: timeline[0]?.epoch ?? "default",
|
|
267
|
+
afterSeq: 0
|
|
1400
268
|
};
|
|
1401
269
|
}
|
|
1402
|
-
function
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
function matchesAlwaysAllow(policy, request) {
|
|
1407
|
-
const requestScope = scopeKey(request.scope);
|
|
1408
|
-
return policy.alwaysAllow.some((rule) => {
|
|
1409
|
-
if (rule.toolName !== request.toolName) return false;
|
|
1410
|
-
if (!rule.scope) return true;
|
|
1411
|
-
return scopeKey(rule.scope) === requestScope;
|
|
1412
|
-
});
|
|
1413
|
-
}
|
|
1414
|
-
function scopeKey(scope) {
|
|
1415
|
-
if (!scope) return "global";
|
|
1416
|
-
if (typeof scope === "string") return scope;
|
|
1417
|
-
switch (scope.type) {
|
|
1418
|
-
case "session":
|
|
1419
|
-
return `session:${scope.sessionId}`;
|
|
1420
|
-
case "workspace":
|
|
1421
|
-
return `workspace:${scope.workspaceId}`;
|
|
1422
|
-
case "source":
|
|
1423
|
-
return `source:${scope.sourceSlug}`;
|
|
1424
|
-
case "skill":
|
|
1425
|
-
return `skill:${scope.skillSlug}`;
|
|
1426
|
-
case "automation":
|
|
1427
|
-
return `automation:${scope.automationId}`;
|
|
1428
|
-
case "tool-call":
|
|
1429
|
-
return `tool-call:${scope.callId}`;
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
function evaluateBashPolicy(policy, intent) {
|
|
1433
|
-
if (intent.kind !== "bash") {
|
|
1434
|
-
return { decision: "allow", intent };
|
|
1435
|
-
}
|
|
1436
|
-
if (policy.mode === "ask" && DANGEROUS_BASH_COMMANDS.has(intent.baseCommand)) {
|
|
1437
|
-
return {
|
|
1438
|
-
decision: "ask",
|
|
1439
|
-
reason: `${intent.baseCommand} requires approval in ask mode`,
|
|
1440
|
-
intent
|
|
1441
|
-
};
|
|
1442
|
-
}
|
|
1443
|
-
if (policy.mode === "safe") {
|
|
1444
|
-
const layeredAllow = findLayeredAllow(policy, intent);
|
|
1445
|
-
const readOnly = READ_ONLY_BASH_PATTERNS.some((pattern) => pattern.test(intent.command.trim()));
|
|
1446
|
-
if (!readOnly) {
|
|
1447
|
-
const hint = findBlockedCommandHint(policy, intent);
|
|
1448
|
-
return {
|
|
1449
|
-
decision: "deny",
|
|
1450
|
-
reason: `Bash command is blocked in safe mode: ${intent.baseCommand || "unknown command"}`,
|
|
1451
|
-
intent,
|
|
1452
|
-
hint: hint?.reason,
|
|
1453
|
-
matchedRule: hint?.match,
|
|
1454
|
-
...hint?.tryInstead?.length ? { tryInstead: hint.tryInstead } : {},
|
|
1455
|
-
...hint?.context ? { hintContext: hint.context } : {}
|
|
1456
|
-
};
|
|
1457
|
-
}
|
|
1458
|
-
if (layeredAllow) {
|
|
1459
|
-
return { decision: "allow", intent, matchedRule: layeredAllow };
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
return { decision: "allow", intent };
|
|
1463
|
-
}
|
|
1464
|
-
function normalizeToolIntent(request) {
|
|
1465
|
-
if (request.toolIntent) return request.toolIntent;
|
|
1466
|
-
if (request.toolName === "Bash") {
|
|
1467
|
-
const command = String(request.input?.command ?? "");
|
|
1468
|
-
const baseCommand = command.trim().split(/\s+/)[0] ?? "";
|
|
1469
|
-
return { kind: "bash", command, baseCommand };
|
|
1470
|
-
}
|
|
1471
|
-
if (FILE_WRITE_TOOLS.has(request.toolName)) {
|
|
1472
|
-
return {
|
|
1473
|
-
kind: "file_write",
|
|
1474
|
-
toolName: request.toolName,
|
|
1475
|
-
path: String(request.input?.file_path ?? request.input?.path ?? "")
|
|
1476
|
-
};
|
|
1477
|
-
}
|
|
1478
|
-
if (request.toolName === "MCP") {
|
|
1479
|
-
return {
|
|
1480
|
-
kind: "mcp",
|
|
1481
|
-
name: String(request.input?.name ?? request.input?.toolName ?? request.input?.tool ?? "")
|
|
1482
|
-
};
|
|
1483
|
-
}
|
|
1484
|
-
if (request.toolName === "API") {
|
|
1485
|
-
const url = request.input?.url ? String(request.input.url) : void 0;
|
|
1486
|
-
return {
|
|
1487
|
-
kind: "api",
|
|
1488
|
-
method: String(request.input?.method ?? "GET").toUpperCase(),
|
|
1489
|
-
path: pathFromUrl(url ?? String(request.input?.path ?? "/")),
|
|
1490
|
-
url
|
|
1491
|
-
};
|
|
1492
|
-
}
|
|
1493
|
-
return { kind: "unknown", toolName: request.toolName };
|
|
1494
|
-
}
|
|
1495
|
-
function findLayeredAllow(policy, intent, scope) {
|
|
1496
|
-
for (const layer of policy.layers) {
|
|
1497
|
-
if (layer.scope && scopeKey(layer.scope) !== scopeKey(scope)) continue;
|
|
1498
|
-
const match = matchLayerRules(layer, intent);
|
|
1499
|
-
if (match) return match;
|
|
1500
|
-
}
|
|
1501
|
-
return void 0;
|
|
1502
|
-
}
|
|
1503
|
-
function matchLayerRules(layer, intent) {
|
|
1504
|
-
if (intent.kind === "file_write") {
|
|
1505
|
-
const pattern = layer.rules.allowedWritePaths?.find((rule) => globMatches(rule, intent.path));
|
|
1506
|
-
return pattern ? { layerId: layer.id, ruleType: "write-path", pattern } : void 0;
|
|
1507
|
-
}
|
|
1508
|
-
if (intent.kind === "mcp") {
|
|
1509
|
-
const pattern = layer.rules.allowedMcpPatterns?.find((rule) => regexMatches(rule, intent.name));
|
|
1510
|
-
return pattern ? { layerId: layer.id, ruleType: "mcp-pattern", pattern } : void 0;
|
|
1511
|
-
}
|
|
1512
|
-
if (intent.kind === "api") {
|
|
1513
|
-
const rule = layer.rules.allowedApiEndpoints?.find((candidate) => candidate.method.toUpperCase() === intent.method && globMatches(candidate.pattern, intent.path));
|
|
1514
|
-
return rule ? { layerId: layer.id, ruleType: "api-endpoint", pattern: `${rule.method.toUpperCase()} ${rule.pattern}` } : void 0;
|
|
1515
|
-
}
|
|
1516
|
-
if (intent.kind === "bash") {
|
|
1517
|
-
const pattern = layer.rules.allowedBashPatterns?.find((rule) => regexMatches(rule, intent.command));
|
|
1518
|
-
return pattern ? { layerId: layer.id, ruleType: "bash-pattern", pattern } : void 0;
|
|
1519
|
-
}
|
|
1520
|
-
return void 0;
|
|
1521
|
-
}
|
|
1522
|
-
function findBlockedCommandHint(policy, intent) {
|
|
1523
|
-
for (const layer of policy.layers) {
|
|
1524
|
-
const hint = layer.rules.blockedCommandHints?.find((rule) => {
|
|
1525
|
-
if (rule.command !== intent.baseCommand) return false;
|
|
1526
|
-
if (!rule.whenNotMatching) return true;
|
|
1527
|
-
return !regexMatches(rule.whenNotMatching, intent.command);
|
|
1528
|
-
});
|
|
1529
|
-
if (hint) {
|
|
1530
|
-
return {
|
|
1531
|
-
reason: hint.reason,
|
|
1532
|
-
match: {
|
|
1533
|
-
layerId: layer.id,
|
|
1534
|
-
ruleType: "blocked-command-hint",
|
|
1535
|
-
pattern: hint.command
|
|
1536
|
-
},
|
|
1537
|
-
...hint.tryInstead?.length ? { tryInstead: hint.tryInstead } : {},
|
|
1538
|
-
...hint.context ? { context: hint.context } : {}
|
|
1539
|
-
};
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
return void 0;
|
|
1543
|
-
}
|
|
1544
|
-
function pathFromUrl(value) {
|
|
1545
|
-
try {
|
|
1546
|
-
return new URL(value).pathname;
|
|
1547
|
-
} catch {
|
|
1548
|
-
return value.startsWith("/") ? value : `/${value}`;
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
|
-
function regexMatches(pattern, value) {
|
|
1552
|
-
try {
|
|
1553
|
-
return new RegExp(pattern).test(value);
|
|
1554
|
-
} catch {
|
|
1555
|
-
return pattern === value;
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
|
-
function globMatches(pattern, value) {
|
|
1559
|
-
const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "__DOUBLE_STAR__").replace(/\*/g, "[^/]*").replace(/__DOUBLE_STAR__/g, ".*");
|
|
1560
|
-
return new RegExp(`^${escaped}$`).test(value);
|
|
1561
|
-
}
|
|
1562
|
-
function scopeMcpPatternToSource(sourceSlug, pattern) {
|
|
1563
|
-
if (pattern.includes("mcp__")) return pattern;
|
|
1564
|
-
return `^mcp__${escapeRegex(sourceSlug)}__.*${pattern}`;
|
|
1565
|
-
}
|
|
1566
|
-
function escapeRegex(value) {
|
|
1567
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1568
|
-
}
|
|
1569
|
-
function validateRuleSet(rulesValue, path, errors) {
|
|
1570
|
-
if (rulesValue === void 0) {
|
|
1571
|
-
errors.push({
|
|
1572
|
-
path,
|
|
1573
|
-
message: "Layer rules are required"
|
|
1574
|
-
});
|
|
1575
|
-
return;
|
|
1576
|
-
}
|
|
1577
|
-
const rules = asRecord(rulesValue);
|
|
1578
|
-
validateRegexList(rules.allowedBashPatterns, `${path}.allowedBashPatterns`, errors);
|
|
1579
|
-
validateRegexList(rules.allowedMcpPatterns, `${path}.allowedMcpPatterns`, errors);
|
|
1580
|
-
validateApiEndpointRules(rules.allowedApiEndpoints, `${path}.allowedApiEndpoints`, errors);
|
|
1581
|
-
}
|
|
1582
|
-
function validateRegexList(value, path, errors) {
|
|
1583
|
-
if (value === void 0) return;
|
|
1584
|
-
if (!Array.isArray(value)) {
|
|
1585
|
-
errors.push({ path, message: "Expected an array of regular expression strings" });
|
|
1586
|
-
return;
|
|
1587
|
-
}
|
|
1588
|
-
value.forEach((pattern, index) => {
|
|
1589
|
-
if (typeof pattern !== "string") {
|
|
1590
|
-
errors.push({ path: `${path}[${index}]`, message: "Expected a regular expression string" });
|
|
1591
|
-
return;
|
|
1592
|
-
}
|
|
1593
|
-
if (!isValidRegex(pattern)) {
|
|
1594
|
-
errors.push({
|
|
1595
|
-
path: `${path}[${index}]`,
|
|
1596
|
-
message: `Invalid regular expression: ${pattern}`
|
|
1597
|
-
});
|
|
1598
|
-
}
|
|
1599
|
-
});
|
|
1600
|
-
}
|
|
1601
|
-
function validateApiEndpointRules(value, path, errors) {
|
|
1602
|
-
if (value === void 0) return;
|
|
1603
|
-
if (!Array.isArray(value)) {
|
|
1604
|
-
errors.push({ path, message: "Expected an array of API endpoint rules" });
|
|
1605
|
-
return;
|
|
1606
|
-
}
|
|
1607
|
-
value.forEach((ruleValue, index) => {
|
|
1608
|
-
const rule = asRecord(ruleValue);
|
|
1609
|
-
const method = rule.method;
|
|
1610
|
-
if (typeof method !== "string" || !HTTP_METHODS.has(method.toUpperCase())) {
|
|
1611
|
-
errors.push({
|
|
1612
|
-
path: `${path}[${index}].method`,
|
|
1613
|
-
message: `Invalid HTTP method: ${String(method)}`,
|
|
1614
|
-
suggestion: "Use one of: GET, POST, PUT, PATCH, DELETE"
|
|
1615
|
-
});
|
|
1616
|
-
}
|
|
1617
|
-
if (typeof rule.pattern !== "string") {
|
|
1618
|
-
errors.push({
|
|
1619
|
-
path: `${path}[${index}].pattern`,
|
|
1620
|
-
message: "API endpoint pattern is required"
|
|
1621
|
-
});
|
|
1622
|
-
}
|
|
270
|
+
function sortTimeline(timeline) {
|
|
271
|
+
return [...timeline].sort((left, right) => {
|
|
272
|
+
if (left.epoch !== right.epoch) return left.epoch.localeCompare(right.epoch);
|
|
273
|
+
return left.seq - right.seq;
|
|
1623
274
|
});
|
|
1624
275
|
}
|
|
1625
|
-
function
|
|
1626
|
-
return
|
|
1627
|
-
}
|
|
1628
|
-
var HTTP_METHODS = /* @__PURE__ */ new Set(["GET", "POST", "PUT", "PATCH", "DELETE"]);
|
|
1629
|
-
function isValidRegex(pattern) {
|
|
1630
|
-
try {
|
|
1631
|
-
new RegExp(pattern);
|
|
1632
|
-
return true;
|
|
1633
|
-
} catch {
|
|
1634
|
-
return false;
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
function asRecord(value) {
|
|
1638
|
-
return value && typeof value === "object" ? value : {};
|
|
276
|
+
function timelineKey(item) {
|
|
277
|
+
return `${item.epoch}:${item.seq}`;
|
|
1639
278
|
}
|
|
1640
279
|
|
|
1641
|
-
// src/index.ts
|
|
1642
|
-
var import_weft_react = require("@percena/weft-react");
|
|
1643
|
-
|
|
1644
280
|
// ../packages/client/dist/index.js
|
|
1645
281
|
var FlitroHttpClient = class {
|
|
1646
282
|
baseUrl;
|
|
@@ -2301,8 +937,111 @@ var PushTimelineStream = class {
|
|
|
2301
937
|
}
|
|
2302
938
|
};
|
|
2303
939
|
|
|
940
|
+
// ../packages/react/src/use-agent-session.ts
|
|
941
|
+
function useAgentSession(options) {
|
|
942
|
+
const onTokenExpiredRef = (0, import_react.useRef)(options.onTokenExpired);
|
|
943
|
+
onTokenExpiredRef.current = options.onTokenExpired;
|
|
944
|
+
const tokenRef = (0, import_react.useRef)(options.token);
|
|
945
|
+
tokenRef.current = options.token;
|
|
946
|
+
const runtime = (0, import_react.useMemo)(() => {
|
|
947
|
+
return createDeferredAgentRuntime({
|
|
948
|
+
provider: "flitro",
|
|
949
|
+
runtimeKind: "app-server",
|
|
950
|
+
sessionId: options.sessionId,
|
|
951
|
+
createRuntime: () => createFlitroEmbedRuntime({
|
|
952
|
+
baseUrl: options.server,
|
|
953
|
+
token: tokenRef.current,
|
|
954
|
+
sessionId: options.sessionId,
|
|
955
|
+
onTokenExpired: () => onTokenExpiredRef.current?.()
|
|
956
|
+
})
|
|
957
|
+
});
|
|
958
|
+
}, [options.server, options.sessionId]);
|
|
959
|
+
(0, import_react.useEffect)(() => {
|
|
960
|
+
return () => {
|
|
961
|
+
void runtime.disposeIfCreated();
|
|
962
|
+
};
|
|
963
|
+
}, [runtime]);
|
|
964
|
+
return { runtime, sessionId: options.sessionId, server: options.server };
|
|
965
|
+
}
|
|
966
|
+
function createDeferredAgentRuntime(options) {
|
|
967
|
+
let runtime = null;
|
|
968
|
+
let disposed = false;
|
|
969
|
+
const getRuntime = () => {
|
|
970
|
+
if (disposed) {
|
|
971
|
+
throw new Error("Agent runtime has been disposed");
|
|
972
|
+
}
|
|
973
|
+
runtime ??= options.createRuntime();
|
|
974
|
+
return runtime;
|
|
975
|
+
};
|
|
976
|
+
return {
|
|
977
|
+
get sessionId() {
|
|
978
|
+
return runtime?.sessionId ?? options.sessionId;
|
|
979
|
+
},
|
|
980
|
+
get provider() {
|
|
981
|
+
return runtime?.provider ?? options.provider;
|
|
982
|
+
},
|
|
983
|
+
get runtimeKind() {
|
|
984
|
+
return runtime?.runtimeKind ?? options.runtimeKind;
|
|
985
|
+
},
|
|
986
|
+
events: {
|
|
987
|
+
connect(onEvent, onError, onClose) {
|
|
988
|
+
getRuntime().events.connect(onEvent, onError, onClose);
|
|
989
|
+
},
|
|
990
|
+
disconnect() {
|
|
991
|
+
runtime?.events.disconnect();
|
|
992
|
+
},
|
|
993
|
+
isConnected() {
|
|
994
|
+
return runtime?.events.isConnected() ?? false;
|
|
995
|
+
}
|
|
996
|
+
},
|
|
997
|
+
commands: {
|
|
998
|
+
sendMessage(message, sendOptions) {
|
|
999
|
+
return getRuntime().commands.sendMessage(message, sendOptions);
|
|
1000
|
+
},
|
|
1001
|
+
abort(reason) {
|
|
1002
|
+
return getRuntime().commands.abort(reason);
|
|
1003
|
+
},
|
|
1004
|
+
respondToPermission(requestId, allowed, remember) {
|
|
1005
|
+
return getRuntime().commands.respondToPermission(requestId, allowed, remember);
|
|
1006
|
+
},
|
|
1007
|
+
async resumeTool(runId, resumeData) {
|
|
1008
|
+
const commands = getRuntime().commands;
|
|
1009
|
+
if (!commands.resumeTool) {
|
|
1010
|
+
throw new Error(`resumeTool is not supported by the ${options.provider} runtime`);
|
|
1011
|
+
}
|
|
1012
|
+
await commands.resumeTool(runId, resumeData);
|
|
1013
|
+
},
|
|
1014
|
+
dispose() {
|
|
1015
|
+
disposed = true;
|
|
1016
|
+
const current = runtime;
|
|
1017
|
+
runtime = null;
|
|
1018
|
+
return current?.commands.dispose() ?? Promise.resolve();
|
|
1019
|
+
}
|
|
1020
|
+
},
|
|
1021
|
+
preflight() {
|
|
1022
|
+
return getRuntime().preflight();
|
|
1023
|
+
},
|
|
1024
|
+
fetchTimeline(request) {
|
|
1025
|
+
return getRuntime().fetchTimeline(request);
|
|
1026
|
+
},
|
|
1027
|
+
getState() {
|
|
1028
|
+
return runtime?.getState() ?? {
|
|
1029
|
+
status: initialRuntimeState.status,
|
|
1030
|
+
acceptedMessages: [],
|
|
1031
|
+
queuedMessages: []
|
|
1032
|
+
};
|
|
1033
|
+
},
|
|
1034
|
+
async disposeIfCreated() {
|
|
1035
|
+
if (!runtime) return;
|
|
1036
|
+
const current = runtime;
|
|
1037
|
+
runtime = null;
|
|
1038
|
+
await current.commands.dispose();
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
|
|
2304
1043
|
// ../packages/local-chat/dist/index.js
|
|
2305
|
-
var
|
|
1044
|
+
var import_react19 = require("react");
|
|
2306
1045
|
|
|
2307
1046
|
// ../packages/ui/dist/chunk-MRPTNS4U.js
|
|
2308
1047
|
var EN_FALLBACK = {
|
|
@@ -2341,11 +1080,38 @@ var EN_FALLBACK = {
|
|
|
2341
1080
|
"plan.acceptAndSendFollowups": "Accept & send follow-ups"
|
|
2342
1081
|
};
|
|
2343
1082
|
|
|
1083
|
+
// ../packages/core/dist/chunk-QEEF5TZY.js
|
|
1084
|
+
function generateMessageId() {
|
|
1085
|
+
return `msg-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
1086
|
+
}
|
|
1087
|
+
function storedToMessage(stored) {
|
|
1088
|
+
const { type, ...rest } = stored;
|
|
1089
|
+
return { ...rest, role: type, timestamp: stored.timestamp ?? Date.now() };
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
// ../packages/core/dist/chunk-LCDW7EA2.js
|
|
1093
|
+
function normalizePath(path) {
|
|
1094
|
+
return path.replace(/\\/g, "/");
|
|
1095
|
+
}
|
|
1096
|
+
function pathStartsWith(filePath, dirPath) {
|
|
1097
|
+
const normalizedFile = normalizePath(filePath);
|
|
1098
|
+
const normalizedDir = normalizePath(dirPath);
|
|
1099
|
+
return normalizedFile.startsWith(normalizedDir + "/") || normalizedFile === normalizedDir;
|
|
1100
|
+
}
|
|
1101
|
+
function stripPathPrefix(filePath, prefix) {
|
|
1102
|
+
const normalizedFile = normalizePath(filePath);
|
|
1103
|
+
const normalizedPrefix = normalizePath(prefix);
|
|
1104
|
+
if (normalizedFile.startsWith(normalizedPrefix + "/")) {
|
|
1105
|
+
return normalizedFile.slice(normalizedPrefix.length + 1);
|
|
1106
|
+
}
|
|
1107
|
+
return filePath;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
2344
1110
|
// ../packages/ui/dist/index.js
|
|
2345
1111
|
var React10 = __toESM(require("react"), 1);
|
|
2346
|
-
var
|
|
1112
|
+
var import_react2 = require("react");
|
|
2347
1113
|
var import_i18next = __toESM(require("i18next"), 1);
|
|
2348
|
-
var
|
|
1114
|
+
var import_react3 = require("motion/react");
|
|
2349
1115
|
var import_lucide_react = require("lucide-react");
|
|
2350
1116
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
2351
1117
|
var React2 = __toESM(require("react"), 1);
|
|
@@ -2355,12 +1121,12 @@ var React = __toESM(require("react"), 1);
|
|
|
2355
1121
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2356
1122
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2357
1123
|
var import_i18next2 = __toESM(require("i18next"), 1);
|
|
2358
|
-
var
|
|
2359
|
-
var
|
|
1124
|
+
var import_react4 = require("react");
|
|
1125
|
+
var import_react5 = require("motion/react");
|
|
2360
1126
|
var import_lucide_react3 = require("lucide-react");
|
|
2361
1127
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2362
1128
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2363
|
-
var
|
|
1129
|
+
var import_react6 = require("react");
|
|
2364
1130
|
var import_react_i18next2 = require("react-i18next");
|
|
2365
1131
|
var import_lucide_react4 = require("lucide-react");
|
|
2366
1132
|
var React6 = __toESM(require("react"), 1);
|
|
@@ -2372,7 +1138,7 @@ var import_remark_math = __toESM(require("remark-math"), 1);
|
|
|
2372
1138
|
var React3 = __toESM(require("react"), 1);
|
|
2373
1139
|
var import_core2 = require("@shikijs/core");
|
|
2374
1140
|
var import_engine_javascript = require("@shikijs/engine-javascript");
|
|
2375
|
-
var
|
|
1141
|
+
var import_react7 = require("react");
|
|
2376
1142
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2377
1143
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
2378
1144
|
var React4 = __toESM(require("react"), 1);
|
|
@@ -2387,31 +1153,31 @@ var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
|
2387
1153
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2388
1154
|
var React5 = __toESM(require("react"), 1);
|
|
2389
1155
|
var import_lucide_react5 = require("lucide-react");
|
|
2390
|
-
var
|
|
1156
|
+
var import_react8 = require("motion/react");
|
|
2391
1157
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2392
|
-
var
|
|
1158
|
+
var import_react9 = require("react");
|
|
2393
1159
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2394
1160
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2395
1161
|
var React7 = __toESM(require("react"), 1);
|
|
2396
1162
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2397
1163
|
var React8 = __toESM(require("react"), 1);
|
|
2398
1164
|
var React9 = __toESM(require("react"), 1);
|
|
2399
|
-
var
|
|
1165
|
+
var import_react10 = require("react");
|
|
2400
1166
|
var import_react_i18next3 = require("react-i18next");
|
|
2401
1167
|
var ReactDOM = __toESM(require("react-dom"), 1);
|
|
2402
1168
|
var import_lucide_react6 = require("lucide-react");
|
|
2403
1169
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2404
1170
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2405
1171
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2406
|
-
var
|
|
1172
|
+
var import_react11 = require("motion/react");
|
|
2407
1173
|
var import_lucide_react7 = require("lucide-react");
|
|
2408
1174
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2409
1175
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2410
1176
|
var import_react_i18next4 = require("react-i18next");
|
|
2411
1177
|
var import_lucide_react8 = require("lucide-react");
|
|
2412
1178
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2413
|
-
var import_react11 = require("react");
|
|
2414
1179
|
var import_react12 = require("react");
|
|
1180
|
+
var import_react13 = require("react");
|
|
2415
1181
|
var import_lucide_react9 = require("lucide-react");
|
|
2416
1182
|
var import_lucide_react10 = require("lucide-react");
|
|
2417
1183
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
@@ -2420,18 +1186,18 @@ var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
|
2420
1186
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
2421
1187
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
2422
1188
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
2423
|
-
var import_react13 = require("react");
|
|
2424
1189
|
var import_react14 = require("react");
|
|
1190
|
+
var import_react15 = require("react");
|
|
2425
1191
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
2426
1192
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
2427
1193
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
2428
|
-
var
|
|
1194
|
+
var import_react16 = require("react");
|
|
2429
1195
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
2430
1196
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
2431
|
-
var
|
|
1197
|
+
var import_react17 = require("react");
|
|
2432
1198
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
2433
1199
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
2434
|
-
var
|
|
1200
|
+
var import_react18 = require("react");
|
|
2435
1201
|
function getAssistantTurnUiKey(turn, index) {
|
|
2436
1202
|
if (turn.response?.messageId) {
|
|
2437
1203
|
return `assistant:msg:${turn.response.messageId}`;
|
|
@@ -2948,7 +1714,7 @@ function groupActivitiesByParent(activities) {
|
|
|
2948
1714
|
}
|
|
2949
1715
|
return result;
|
|
2950
1716
|
}
|
|
2951
|
-
function
|
|
1717
|
+
function asRecord(value) {
|
|
2952
1718
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
2953
1719
|
}
|
|
2954
1720
|
function normalizeFollowUpText(text) {
|
|
@@ -2958,7 +1724,7 @@ function getAnnotationNoteText(annotation) {
|
|
|
2958
1724
|
const noteBody = annotation.body.find((body) => body.type === "note");
|
|
2959
1725
|
const bodyText = noteBody?.text?.trim() ?? "";
|
|
2960
1726
|
if (bodyText.length > 0) return bodyText;
|
|
2961
|
-
const followUpMeta =
|
|
1727
|
+
const followUpMeta = asRecord(asRecord(annotation.meta)?.followUp);
|
|
2962
1728
|
const metaText = typeof followUpMeta?.text === "string" ? followUpMeta.text.trim() : "";
|
|
2963
1729
|
return metaText;
|
|
2964
1730
|
}
|
|
@@ -3521,8 +2287,8 @@ function ActivityStatusIcon({
|
|
|
3521
2287
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.XCircle, { className: cn(SIZE_CONFIG.iconSize, "shrink-0 text-destructive") });
|
|
3522
2288
|
}
|
|
3523
2289
|
};
|
|
3524
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3525
|
-
|
|
2290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react5.AnimatePresence, { mode: "wait", initial: false, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2291
|
+
import_react5.motion.div,
|
|
3526
2292
|
{
|
|
3527
2293
|
initial: { opacity: 0, scale: 0.8 },
|
|
3528
2294
|
animate: { opacity: 1, scale: 1 },
|
|
@@ -3748,12 +2514,12 @@ function ActivityRow({ activity, onOpenDetails, isLastChild, sessionFolderPath,
|
|
|
3748
2514
|
] });
|
|
3749
2515
|
}
|
|
3750
2516
|
function ActivityGroupRow({ group, expandedGroups: externalExpandedGroups, onExpandedGroupsChange, onOpenActivityDetails, animationIndex = 0, sessionFolderPath, displayMode = "detailed" }) {
|
|
3751
|
-
const [localExpandedGroups, setLocalExpandedGroups] = (0,
|
|
2517
|
+
const [localExpandedGroups, setLocalExpandedGroups] = (0, import_react4.useState)(/* @__PURE__ */ new Set());
|
|
3752
2518
|
const expandedGroups = externalExpandedGroups ?? localExpandedGroups;
|
|
3753
2519
|
const setExpandedGroups = onExpandedGroupsChange ?? setLocalExpandedGroups;
|
|
3754
2520
|
const groupId = group.parent.id;
|
|
3755
2521
|
const isExpanded = expandedGroups.has(groupId);
|
|
3756
|
-
const toggleExpanded = (0,
|
|
2522
|
+
const toggleExpanded = (0, import_react4.useCallback)(() => {
|
|
3757
2523
|
const next = new Set(expandedGroups);
|
|
3758
2524
|
if (next.has(groupId)) {
|
|
3759
2525
|
next.delete(groupId);
|
|
@@ -3767,7 +2533,7 @@ function ActivityGroupRow({ group, expandedGroups: externalExpandedGroups, onExp
|
|
|
3767
2533
|
const isComplete = group.parent.status === "completed" || group.parent.status === "error";
|
|
3768
2534
|
const hasError = group.parent.status === "error";
|
|
3769
2535
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3770
|
-
|
|
2536
|
+
import_react5.motion.div,
|
|
3771
2537
|
{
|
|
3772
2538
|
initial: { opacity: 0, x: -8 },
|
|
3773
2539
|
animate: { opacity: 1, x: 0 },
|
|
@@ -3785,7 +2551,7 @@ function ActivityGroupRow({ group, expandedGroups: externalExpandedGroups, onExp
|
|
|
3785
2551
|
onClick: toggleExpanded,
|
|
3786
2552
|
children: [
|
|
3787
2553
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3788
|
-
|
|
2554
|
+
import_react5.motion.div,
|
|
3789
2555
|
{
|
|
3790
2556
|
initial: false,
|
|
3791
2557
|
animate: { rotate: isExpanded ? 90 : 0 },
|
|
@@ -3834,8 +2600,8 @@ function ActivityGroupRow({ group, expandedGroups: externalExpandedGroups, onExp
|
|
|
3834
2600
|
]
|
|
3835
2601
|
}
|
|
3836
2602
|
),
|
|
3837
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3838
|
-
|
|
2603
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react5.AnimatePresence, { initial: false, children: isExpanded && group.children.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2604
|
+
import_react5.motion.div,
|
|
3839
2605
|
{
|
|
3840
2606
|
initial: { height: 0, opacity: 0 },
|
|
3841
2607
|
animate: { height: "auto", opacity: 1 },
|
|
@@ -3846,7 +2612,7 @@ function ActivityGroupRow({ group, expandedGroups: externalExpandedGroups, onExp
|
|
|
3846
2612
|
},
|
|
3847
2613
|
className: "overflow-hidden",
|
|
3848
2614
|
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "pl-0 space-y-0.5 border-l-2 border-muted ml-[5px]", children: group.children.map((child, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3849
|
-
|
|
2615
|
+
import_react5.motion.div,
|
|
3850
2616
|
{
|
|
3851
2617
|
initial: { opacity: 0, x: -4 },
|
|
3852
2618
|
animate: { opacity: 1, x: 0 },
|
|
@@ -3871,9 +2637,9 @@ function ActivityGroupRow({ group, expandedGroups: externalExpandedGroups, onExp
|
|
|
3871
2637
|
}
|
|
3872
2638
|
);
|
|
3873
2639
|
}
|
|
3874
|
-
var ShikiThemeContext = (0,
|
|
2640
|
+
var ShikiThemeContext = (0, import_react7.createContext)(null);
|
|
3875
2641
|
function useShikiTheme() {
|
|
3876
|
-
return (0,
|
|
2642
|
+
return (0, import_react7.useContext)(ShikiThemeContext);
|
|
3877
2643
|
}
|
|
3878
2644
|
var LANGUAGE_LOADERS = {
|
|
3879
2645
|
bash: () => import("@shikijs/langs/bash"),
|
|
@@ -4123,8 +2889,8 @@ var remarkCollapsibleSections = function() {
|
|
|
4123
2889
|
};
|
|
4124
2890
|
var remarkCollapsibleSections_default = remarkCollapsibleSections;
|
|
4125
2891
|
function AnimatedCollapsibleContent({ isOpen, children }) {
|
|
4126
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4127
|
-
|
|
2892
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react8.AnimatePresence, { initial: false, children: isOpen && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2893
|
+
import_react8.motion.div,
|
|
4128
2894
|
{
|
|
4129
2895
|
initial: { height: 0, opacity: 0 },
|
|
4130
2896
|
animate: { height: "auto", opacity: 1 },
|
|
@@ -4161,7 +2927,7 @@ function CollapsibleSection({
|
|
|
4161
2927
|
onClick: () => hasContent && onToggle(sectionId),
|
|
4162
2928
|
children: [
|
|
4163
2929
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4164
|
-
|
|
2930
|
+
import_react8.motion.div,
|
|
4165
2931
|
{
|
|
4166
2932
|
initial: false,
|
|
4167
2933
|
animate: { rotate: isExpanded ? 90 : 0 },
|
|
@@ -4182,9 +2948,9 @@ function CollapsibleSection({
|
|
|
4182
2948
|
hasContent && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AnimatedCollapsibleContent, { isOpen: isExpanded, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "collapsible-section-content", children: content }) })
|
|
4183
2949
|
] });
|
|
4184
2950
|
}
|
|
4185
|
-
var CollapsibleMarkdownContext = (0,
|
|
2951
|
+
var CollapsibleMarkdownContext = (0, import_react9.createContext)(null);
|
|
4186
2952
|
function useCollapsibleMarkdown() {
|
|
4187
|
-
return (0,
|
|
2953
|
+
return (0, import_react9.useContext)(CollapsibleMarkdownContext);
|
|
4188
2954
|
}
|
|
4189
2955
|
function wrapWithSafeProxy(components) {
|
|
4190
2956
|
return components;
|
|
@@ -4873,11 +3639,11 @@ function AcceptPlanDropdown({
|
|
|
4873
3639
|
const { t: t2 } = (0, import_react_i18next3.useTranslation)();
|
|
4874
3640
|
const effectiveAcceptLabel = acceptLabel ?? t2("plan.acceptPlan");
|
|
4875
3641
|
const effectiveAcceptOptionLabel = acceptOptionLabel ?? t2("plan.accept");
|
|
4876
|
-
const [isOpen, setIsOpen] = (0,
|
|
4877
|
-
const [position, setPosition] = (0,
|
|
4878
|
-
const triggerRef = (0,
|
|
4879
|
-
const menuRef = (0,
|
|
4880
|
-
const updatePosition = (0,
|
|
3642
|
+
const [isOpen, setIsOpen] = (0, import_react10.useState)(false);
|
|
3643
|
+
const [position, setPosition] = (0, import_react10.useState)(null);
|
|
3644
|
+
const triggerRef = (0, import_react10.useRef)(null);
|
|
3645
|
+
const menuRef = (0, import_react10.useRef)(null);
|
|
3646
|
+
const updatePosition = (0, import_react10.useCallback)(() => {
|
|
4881
3647
|
if (!triggerRef.current) return;
|
|
4882
3648
|
const rect = triggerRef.current.getBoundingClientRect();
|
|
4883
3649
|
const menuWidth = 280;
|
|
@@ -4892,7 +3658,7 @@ function AcceptPlanDropdown({
|
|
|
4892
3658
|
}
|
|
4893
3659
|
setPosition({ top, left });
|
|
4894
3660
|
}, []);
|
|
4895
|
-
const handleToggle = (0,
|
|
3661
|
+
const handleToggle = (0, import_react10.useCallback)((e) => {
|
|
4896
3662
|
e.stopPropagation();
|
|
4897
3663
|
if (!isOpen) {
|
|
4898
3664
|
if (triggerRef.current) {
|
|
@@ -4912,25 +3678,25 @@ function AcceptPlanDropdown({
|
|
|
4912
3678
|
}
|
|
4913
3679
|
setIsOpen((prev) => !prev);
|
|
4914
3680
|
}, [isOpen]);
|
|
4915
|
-
const handleClose = (0,
|
|
3681
|
+
const handleClose = (0, import_react10.useCallback)(() => {
|
|
4916
3682
|
setIsOpen(false);
|
|
4917
3683
|
}, []);
|
|
4918
|
-
const handleSelectAccept = (0,
|
|
3684
|
+
const handleSelectAccept = (0, import_react10.useCallback)((e) => {
|
|
4919
3685
|
e.stopPropagation();
|
|
4920
3686
|
handleClose();
|
|
4921
3687
|
onAccept();
|
|
4922
3688
|
}, [handleClose, onAccept]);
|
|
4923
|
-
const handleSelectCompact = (0,
|
|
3689
|
+
const handleSelectCompact = (0, import_react10.useCallback)((e) => {
|
|
4924
3690
|
e.stopPropagation();
|
|
4925
3691
|
handleClose();
|
|
4926
3692
|
onAcceptWithCompact();
|
|
4927
3693
|
}, [handleClose, onAcceptWithCompact]);
|
|
4928
|
-
(0,
|
|
3694
|
+
(0, import_react10.useEffect)(() => {
|
|
4929
3695
|
if (isOpen) {
|
|
4930
3696
|
updatePosition();
|
|
4931
3697
|
}
|
|
4932
3698
|
}, [isOpen, updatePosition]);
|
|
4933
|
-
(0,
|
|
3699
|
+
(0, import_react10.useEffect)(() => {
|
|
4934
3700
|
if (!isOpen) return;
|
|
4935
3701
|
const handleClickOutside = (e) => {
|
|
4936
3702
|
if (menuRef.current && !menuRef.current.contains(e.target) && triggerRef.current && !triggerRef.current.contains(e.target)) {
|
|
@@ -5139,11 +3905,11 @@ function ResponseCard({
|
|
|
5139
3905
|
annotationInteractionMode = "interactive"
|
|
5140
3906
|
}) {
|
|
5141
3907
|
const { t: t2 } = (0, import_react_i18next2.useTranslation)();
|
|
5142
|
-
const [displayedText, setDisplayedText] = (0,
|
|
5143
|
-
const lastUpdateRef = (0,
|
|
5144
|
-
const [copied, setCopied] = (0,
|
|
5145
|
-
const [isFullscreen, setIsFullscreen] = (0,
|
|
5146
|
-
const [isDarkMode, setIsDarkMode] = (0,
|
|
3908
|
+
const [displayedText, setDisplayedText] = (0, import_react6.useState)(text);
|
|
3909
|
+
const lastUpdateRef = (0, import_react6.useRef)(Date.now());
|
|
3910
|
+
const [copied, setCopied] = (0, import_react6.useState)(false);
|
|
3911
|
+
const [isFullscreen, setIsFullscreen] = (0, import_react6.useState)(false);
|
|
3912
|
+
const [isDarkMode, setIsDarkMode] = (0, import_react6.useState)(false);
|
|
5147
3913
|
const interaction = useAnnotationInteractionController();
|
|
5148
3914
|
const {
|
|
5149
3915
|
state: interactionState,
|
|
@@ -5163,23 +3929,23 @@ function ResponseCard({
|
|
|
5163
3929
|
const followUpDraft = interactionState.followUpDraft;
|
|
5164
3930
|
const followUpMode = interactionState.followUpMode;
|
|
5165
3931
|
const activeAnnotationDetail = interactionState.activeAnnotationDetail;
|
|
5166
|
-
const [selectionMenuShowNonce, setSelectionMenuShowNonce] = (0,
|
|
5167
|
-
const [selectionMenuTransitionConfig, setSelectionMenuTransitionConfig] = (0,
|
|
3932
|
+
const [selectionMenuShowNonce, setSelectionMenuShowNonce] = (0, import_react6.useState)(0);
|
|
3933
|
+
const [selectionMenuTransitionConfig, setSelectionMenuTransitionConfig] = (0, import_react6.useState)(
|
|
5168
3934
|
buildAnnotationChipEntryTransition()
|
|
5169
3935
|
);
|
|
5170
|
-
const [annotationOverlay, setAnnotationOverlay] = (0,
|
|
5171
|
-
const contentRef = (0,
|
|
5172
|
-
const contentLayerRef = (0,
|
|
5173
|
-
const lastPointerRef = (0,
|
|
5174
|
-
const dragStartPointerRef = (0,
|
|
5175
|
-
const selectionStartedInContentRef = (0,
|
|
3936
|
+
const [annotationOverlay, setAnnotationOverlay] = (0, import_react6.useState)({ rects: [], chips: [] });
|
|
3937
|
+
const contentRef = (0, import_react6.useRef)(null);
|
|
3938
|
+
const contentLayerRef = (0, import_react6.useRef)(null);
|
|
3939
|
+
const lastPointerRef = (0, import_react6.useRef)(null);
|
|
3940
|
+
const dragStartPointerRef = (0, import_react6.useRef)(null);
|
|
3941
|
+
const selectionStartedInContentRef = (0, import_react6.useRef)(false);
|
|
5176
3942
|
const canAnnotate = canAnnotateMessage({
|
|
5177
3943
|
hasAddAnnotationHandler: !!onAddAnnotation,
|
|
5178
3944
|
hasMessageId: !!messageId,
|
|
5179
3945
|
isStreaming
|
|
5180
3946
|
});
|
|
5181
3947
|
const allowAnnotationIsland = annotationInteractionMode === "interactive";
|
|
5182
|
-
(0,
|
|
3948
|
+
(0, import_react6.useEffect)(() => {
|
|
5183
3949
|
const checkDarkMode = () => {
|
|
5184
3950
|
setIsDarkMode(document.documentElement.classList.contains("dark"));
|
|
5185
3951
|
};
|
|
@@ -5188,22 +3954,22 @@ function ResponseCard({
|
|
|
5188
3954
|
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] });
|
|
5189
3955
|
return () => observer.disconnect();
|
|
5190
3956
|
}, []);
|
|
5191
|
-
const closeSelectionMenu = (0,
|
|
3957
|
+
const closeSelectionMenu = (0, import_react6.useCallback)(() => {
|
|
5192
3958
|
closeAll();
|
|
5193
3959
|
}, [closeAll]);
|
|
5194
|
-
const isTargetInsideAnnotationIsland = (0,
|
|
3960
|
+
const isTargetInsideAnnotationIsland = (0, import_react6.useCallback)((target) => {
|
|
5195
3961
|
if (!target) return false;
|
|
5196
3962
|
const element = target instanceof Element ? target : target.parentElement;
|
|
5197
3963
|
if (!element) return false;
|
|
5198
3964
|
return !!element.closest('[data-ca-annotation-island="true"]');
|
|
5199
3965
|
}, []);
|
|
5200
|
-
const triggerSelectionMenuEntryReplay = (0,
|
|
3966
|
+
const triggerSelectionMenuEntryReplay = (0, import_react6.useCallback)(() => {
|
|
5201
3967
|
setSelectionMenuShowNonce((prev) => prev + 1);
|
|
5202
3968
|
}, []);
|
|
5203
|
-
const activeMenuAnchor = (0,
|
|
3969
|
+
const activeMenuAnchor = (0, import_react6.useMemo)(() => {
|
|
5204
3970
|
return getAnnotationInteractionAnchor(interactionState);
|
|
5205
3971
|
}, [interactionState]);
|
|
5206
|
-
const selectionMenuSourceKey = (0,
|
|
3972
|
+
const selectionMenuSourceKey = (0, import_react6.useMemo)(() => {
|
|
5207
3973
|
const messageScope = messageId ?? "no-message";
|
|
5208
3974
|
return getAnnotationInteractionSourceKey(interactionState, messageScope);
|
|
5209
3975
|
}, [interactionState, messageId]);
|
|
@@ -5218,7 +3984,7 @@ function ResponseCard({
|
|
|
5218
3984
|
anchor: activeMenuAnchor,
|
|
5219
3985
|
sourceKey: selectionMenuSourceKey
|
|
5220
3986
|
});
|
|
5221
|
-
const handleCopy = (0,
|
|
3987
|
+
const handleCopy = (0, import_react6.useCallback)(async () => {
|
|
5222
3988
|
try {
|
|
5223
3989
|
await navigator.clipboard.writeText(text);
|
|
5224
3990
|
setCopied(true);
|
|
@@ -5227,7 +3993,7 @@ function ResponseCard({
|
|
|
5227
3993
|
console.error("Failed to copy:", err);
|
|
5228
3994
|
}
|
|
5229
3995
|
}, [text]);
|
|
5230
|
-
const renderedAnnotations = (0,
|
|
3996
|
+
const renderedAnnotations = (0, import_react6.useMemo)(() => {
|
|
5231
3997
|
const persisted = annotations ?? [];
|
|
5232
3998
|
if (!pendingSelection || !selectionMenuView || !messageId) {
|
|
5233
3999
|
return persisted;
|
|
@@ -5240,17 +4006,17 @@ function ResponseCard({
|
|
|
5240
4006
|
createSelectionPreviewAnnotation(messageId, pendingSelection, sessionId ?? "")
|
|
5241
4007
|
];
|
|
5242
4008
|
}, [annotations, pendingSelection, selectionMenuView, messageId]);
|
|
5243
|
-
const activeAnnotation = (0,
|
|
4009
|
+
const activeAnnotation = (0, import_react6.useMemo)(() => {
|
|
5244
4010
|
if (!activeAnnotationDetail) return null;
|
|
5245
4011
|
return (annotations ?? []).find((annotation) => annotation.id === activeAnnotationDetail.annotationId) ?? null;
|
|
5246
4012
|
}, [annotations, activeAnnotationDetail]);
|
|
5247
|
-
(0,
|
|
4013
|
+
(0, import_react6.useEffect)(() => {
|
|
5248
4014
|
if (!activeAnnotationDetail) return;
|
|
5249
4015
|
if (!activeAnnotation) {
|
|
5250
4016
|
closeSelectionMenu();
|
|
5251
4017
|
}
|
|
5252
4018
|
}, [activeAnnotationDetail, activeAnnotation, closeSelectionMenu]);
|
|
5253
|
-
(0,
|
|
4019
|
+
(0, import_react6.useEffect)(() => {
|
|
5254
4020
|
const root = contentLayerRef.current;
|
|
5255
4021
|
if (!root) {
|
|
5256
4022
|
setAnnotationOverlay({ rects: [], chips: [] });
|
|
@@ -5286,18 +4052,18 @@ function ResponseCard({
|
|
|
5286
4052
|
window.removeEventListener("resize", recomputeOverlay);
|
|
5287
4053
|
};
|
|
5288
4054
|
}, [annotations, renderedAnnotations, text, displayedText, isStreaming]);
|
|
5289
|
-
(0,
|
|
4055
|
+
(0, import_react6.useEffect)(() => {
|
|
5290
4056
|
if (!canAnnotate) {
|
|
5291
4057
|
closeSelectionMenu();
|
|
5292
4058
|
}
|
|
5293
4059
|
}, [canAnnotate, closeSelectionMenu]);
|
|
5294
|
-
(0,
|
|
4060
|
+
(0, import_react6.useEffect)(() => {
|
|
5295
4061
|
closeSelectionMenu();
|
|
5296
4062
|
resetPresentation();
|
|
5297
4063
|
dragStartPointerRef.current = null;
|
|
5298
4064
|
lastPointerRef.current = null;
|
|
5299
4065
|
}, [sessionId, closeSelectionMenu, resetPresentation]);
|
|
5300
|
-
(0,
|
|
4066
|
+
(0, import_react6.useEffect)(() => {
|
|
5301
4067
|
if (!hasAnnotationInteraction(interactionState) || !isSelectionMenuVisible) return;
|
|
5302
4068
|
const handleSelectionChange = () => {
|
|
5303
4069
|
if (selectionMenuOpenedAtRef.current == null || Date.now() - selectionMenuOpenedAtRef.current < 180) {
|
|
@@ -5327,15 +4093,15 @@ function ResponseCard({
|
|
|
5327
4093
|
document.removeEventListener("selectionchange", handleSelectionChange);
|
|
5328
4094
|
};
|
|
5329
4095
|
}, [interactionState, isSelectionMenuVisible, closeSelectionMenu, isTargetInsideAnnotationIsland, selectionMenuOpenedAtRef]);
|
|
5330
|
-
const handleOpenFollowUpView = (0,
|
|
4096
|
+
const handleOpenFollowUpView = (0, import_react6.useCallback)(() => {
|
|
5331
4097
|
if (!pendingSelection) return;
|
|
5332
4098
|
clearDomSelection();
|
|
5333
4099
|
openFollowUpFromSelection();
|
|
5334
4100
|
}, [pendingSelection, openFollowUpFromSelection]);
|
|
5335
|
-
const handleRequestFollowUpEdit = (0,
|
|
4101
|
+
const handleRequestFollowUpEdit = (0, import_react6.useCallback)(() => {
|
|
5336
4102
|
requestEdit();
|
|
5337
4103
|
}, [requestEdit]);
|
|
5338
|
-
const saveFollowUp = (0,
|
|
4104
|
+
const saveFollowUp = (0, import_react6.useCallback)(async (note) => {
|
|
5339
4105
|
const normalizedNote = note.trim();
|
|
5340
4106
|
if (!messageId) return null;
|
|
5341
4107
|
if (activeAnnotationDetail) {
|
|
@@ -5409,10 +4175,10 @@ function ResponseCard({
|
|
|
5409
4175
|
markSubmitSuccess,
|
|
5410
4176
|
text
|
|
5411
4177
|
]);
|
|
5412
|
-
const handleSubmitFollowUp = (0,
|
|
4178
|
+
const handleSubmitFollowUp = (0, import_react6.useCallback)((note) => {
|
|
5413
4179
|
void saveFollowUp(note);
|
|
5414
4180
|
}, [saveFollowUp]);
|
|
5415
|
-
const handleSubmitAndSendFollowUp = (0,
|
|
4181
|
+
const handleSubmitAndSendFollowUp = (0, import_react6.useCallback)((note) => {
|
|
5416
4182
|
void saveFollowUp(note).then((savedFollowUp) => {
|
|
5417
4183
|
if (!savedFollowUp) return;
|
|
5418
4184
|
onSaveAndSendFollowUp?.(savedFollowUp);
|
|
@@ -5422,7 +4188,7 @@ function ResponseCard({
|
|
|
5422
4188
|
contentRootRef: contentLayerRef,
|
|
5423
4189
|
cancelFollowUp
|
|
5424
4190
|
});
|
|
5425
|
-
const handleOpenAnnotationDetail = (0,
|
|
4191
|
+
const handleOpenAnnotationDetail = (0, import_react6.useCallback)((annotationId, index, anchorX, anchorY, mode = "view") => {
|
|
5426
4192
|
if (!allowAnnotationIsland) return;
|
|
5427
4193
|
const annotation = (annotations ?? []).find((item) => item.id === annotationId);
|
|
5428
4194
|
const noteText = annotation ? getAnnotationNoteText(annotation) : "";
|
|
@@ -5431,7 +4197,7 @@ function ResponseCard({
|
|
|
5431
4197
|
triggerSelectionMenuEntryReplay();
|
|
5432
4198
|
openFromAnnotation({ annotationId, index, anchorX, anchorY }, noteText, mode);
|
|
5433
4199
|
}, [allowAnnotationIsland, annotations, triggerSelectionMenuEntryReplay, openFromAnnotation]);
|
|
5434
|
-
(0,
|
|
4200
|
+
(0, import_react6.useEffect)(() => {
|
|
5435
4201
|
if (!allowAnnotationIsland) return;
|
|
5436
4202
|
const contentRect = contentLayerRef.current?.getBoundingClientRect();
|
|
5437
4203
|
const fallbackAnchor = {
|
|
@@ -5455,12 +4221,12 @@ function ResponseCard({
|
|
|
5455
4221
|
consumeExternalOpenRequest,
|
|
5456
4222
|
triggerSelectionMenuEntryReplay
|
|
5457
4223
|
]);
|
|
5458
|
-
const handleDeleteActiveAnnotation = (0,
|
|
4224
|
+
const handleDeleteActiveAnnotation = (0, import_react6.useCallback)(() => {
|
|
5459
4225
|
if (!onRemoveAnnotation || !messageId || !activeAnnotationDetail) return;
|
|
5460
4226
|
onRemoveAnnotation(messageId, activeAnnotationDetail.annotationId);
|
|
5461
4227
|
markDeleteSuccess();
|
|
5462
4228
|
}, [onRemoveAnnotation, messageId, activeAnnotationDetail, markDeleteSuccess]);
|
|
5463
|
-
const handleSelectionPointerDown = (0,
|
|
4229
|
+
const handleSelectionPointerDown = (0, import_react6.useCallback)((event) => {
|
|
5464
4230
|
selectionStartedInContentRef.current = true;
|
|
5465
4231
|
const snapshot = {
|
|
5466
4232
|
x: event.clientX,
|
|
@@ -5470,7 +4236,7 @@ function ResponseCard({
|
|
|
5470
4236
|
dragStartPointerRef.current = snapshot;
|
|
5471
4237
|
lastPointerRef.current = snapshot;
|
|
5472
4238
|
}, []);
|
|
5473
|
-
const showSelectionMenuFromCurrentSelection = (0,
|
|
4239
|
+
const showSelectionMenuFromCurrentSelection = (0, import_react6.useCallback)(() => {
|
|
5474
4240
|
const root = contentLayerRef.current;
|
|
5475
4241
|
if (!root) return;
|
|
5476
4242
|
requestAnimationFrame(() => {
|
|
@@ -5561,7 +4327,7 @@ function ResponseCard({
|
|
|
5561
4327
|
dragStartPointerRef.current = null;
|
|
5562
4328
|
});
|
|
5563
4329
|
}, [annotations, closeSelectionMenu, triggerSelectionMenuEntryReplay, openFromSelection]);
|
|
5564
|
-
const handleTextSelection = (0,
|
|
4330
|
+
const handleTextSelection = (0, import_react6.useCallback)((event) => {
|
|
5565
4331
|
if (!canAnnotate || !onAddAnnotation || !messageId) return;
|
|
5566
4332
|
const root = contentLayerRef.current;
|
|
5567
4333
|
if (!root) return;
|
|
@@ -5622,7 +4388,7 @@ function ResponseCard({
|
|
|
5622
4388
|
selectionStartedInContentRef.current = false;
|
|
5623
4389
|
showSelectionMenuFromCurrentSelection();
|
|
5624
4390
|
}, [canAnnotate, onAddAnnotation, messageId, annotations, showSelectionMenuFromCurrentSelection, closeSelectionMenu]);
|
|
5625
|
-
(0,
|
|
4391
|
+
(0, import_react6.useEffect)(() => {
|
|
5626
4392
|
if (!canAnnotate || !onAddAnnotation || !messageId) return;
|
|
5627
4393
|
const handleDocumentMouseUp = (event) => {
|
|
5628
4394
|
if (!selectionStartedInContentRef.current) return;
|
|
@@ -5645,7 +4411,7 @@ function ResponseCard({
|
|
|
5645
4411
|
document.removeEventListener("mouseup", handleDocumentMouseUp);
|
|
5646
4412
|
};
|
|
5647
4413
|
}, [canAnnotate, onAddAnnotation, messageId, showSelectionMenuFromCurrentSelection]);
|
|
5648
|
-
const handleSelectionMenuRequestBack = (0,
|
|
4414
|
+
const handleSelectionMenuRequestBack = (0, import_react6.useCallback)(() => {
|
|
5649
4415
|
if (selectionMenuView !== "compact") {
|
|
5650
4416
|
handleCancelFollowUp();
|
|
5651
4417
|
return true;
|
|
@@ -5697,7 +4463,7 @@ function ResponseCard({
|
|
|
5697
4463
|
}
|
|
5698
4464
|
}
|
|
5699
4465
|
);
|
|
5700
|
-
(0,
|
|
4466
|
+
(0, import_react6.useEffect)(() => {
|
|
5701
4467
|
if (!isStreaming) {
|
|
5702
4468
|
setDisplayedText(text);
|
|
5703
4469
|
return;
|
|
@@ -5715,7 +4481,7 @@ function ResponseCard({
|
|
|
5715
4481
|
return () => clearTimeout(timeout);
|
|
5716
4482
|
}
|
|
5717
4483
|
}, [text, isStreaming]);
|
|
5718
|
-
const bufferDecision = (0,
|
|
4484
|
+
const bufferDecision = (0, import_react6.useMemo)(() => {
|
|
5719
4485
|
return shouldShowStreamingContent(text, isStreaming, streamStartTime);
|
|
5720
4486
|
}, [text, isStreaming, streamStartTime]);
|
|
5721
4487
|
const isCompleted = !isStreaming;
|
|
@@ -5941,7 +4707,7 @@ function TodoList({ todos }) {
|
|
|
5941
4707
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "pl-4 pr-2 pt-2.5 pb-1.5 space-y-0.5 border-l-2 border-muted ml-[13px]", children: [
|
|
5942
4708
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: cn("text-muted-foreground pb-1", SIZE_CONFIG.fontSize), children: "Todo List" }),
|
|
5943
4709
|
todos.map((todo, index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
5944
|
-
|
|
4710
|
+
import_react11.motion.div,
|
|
5945
4711
|
{
|
|
5946
4712
|
initial: { opacity: 0, x: -8 },
|
|
5947
4713
|
animate: { opacity: 1, x: 0 },
|
|
@@ -5991,7 +4757,7 @@ var TurnCard = React10.memo(function TurnCard2({
|
|
|
5991
4757
|
openAnnotationRequest,
|
|
5992
4758
|
annotationInteractionMode = "interactive"
|
|
5993
4759
|
}) {
|
|
5994
|
-
const turnPhase = (0,
|
|
4760
|
+
const turnPhase = (0, import_react2.useMemo)(() => {
|
|
5995
4761
|
const turnData = {
|
|
5996
4762
|
isComplete,
|
|
5997
4763
|
response,
|
|
@@ -5999,15 +4765,15 @@ var TurnCard = React10.memo(function TurnCard2({
|
|
|
5999
4765
|
};
|
|
6000
4766
|
return deriveTurnPhase(turnData);
|
|
6001
4767
|
}, [isComplete, response, activities]);
|
|
6002
|
-
const [localExpandedTurns, setLocalExpandedTurns] = (0,
|
|
4768
|
+
const [localExpandedTurns, setLocalExpandedTurns] = (0, import_react2.useState)(() => defaultExpanded ? /* @__PURE__ */ new Set([turnId]) : /* @__PURE__ */ new Set());
|
|
6003
4769
|
const isExpanded = externalIsExpanded ?? localExpandedTurns.has(turnId);
|
|
6004
|
-
const hasUserToggled = (0,
|
|
6005
|
-
const activitiesContainerRef = (0,
|
|
6006
|
-
const hasMounted = (0,
|
|
6007
|
-
(0,
|
|
4770
|
+
const hasUserToggled = (0, import_react2.useRef)(false);
|
|
4771
|
+
const activitiesContainerRef = (0, import_react2.useRef)(null);
|
|
4772
|
+
const hasMounted = (0, import_react2.useRef)(false);
|
|
4773
|
+
(0, import_react2.useEffect)(() => {
|
|
6008
4774
|
hasMounted.current = true;
|
|
6009
4775
|
}, []);
|
|
6010
|
-
const toggleExpanded = (0,
|
|
4776
|
+
const toggleExpanded = (0, import_react2.useCallback)(() => {
|
|
6011
4777
|
hasUserToggled.current = true;
|
|
6012
4778
|
const newExpanded = !isExpanded;
|
|
6013
4779
|
if (onExpandedChange) {
|
|
@@ -6024,7 +4790,7 @@ var TurnCard = React10.memo(function TurnCard2({
|
|
|
6024
4790
|
});
|
|
6025
4791
|
}
|
|
6026
4792
|
}, [turnId, isExpanded, onExpandedChange]);
|
|
6027
|
-
(0,
|
|
4793
|
+
(0, import_react2.useEffect)(() => {
|
|
6028
4794
|
if (isExpanded && hasUserToggled.current && activitiesContainerRef.current) {
|
|
6029
4795
|
const timer = setTimeout(() => {
|
|
6030
4796
|
activitiesContainerRef.current?.scrollTo({
|
|
@@ -6035,38 +4801,38 @@ var TurnCard = React10.memo(function TurnCard2({
|
|
|
6035
4801
|
return () => clearTimeout(timer);
|
|
6036
4802
|
}
|
|
6037
4803
|
}, [isExpanded]);
|
|
6038
|
-
const [localExpandedActivityGroups, setLocalExpandedActivityGroups] = (0,
|
|
4804
|
+
const [localExpandedActivityGroups, setLocalExpandedActivityGroups] = (0, import_react2.useState)(/* @__PURE__ */ new Set());
|
|
6039
4805
|
const expandedActivityGroups = externalExpandedActivityGroups ?? localExpandedActivityGroups;
|
|
6040
4806
|
const handleExpandedActivityGroupsChange = onExpandedActivityGroupsChange ?? setLocalExpandedActivityGroups;
|
|
6041
|
-
const isBuffering = (0,
|
|
4807
|
+
const isBuffering = (0, import_react2.useMemo)(
|
|
6042
4808
|
() => isResponseBuffering(response),
|
|
6043
4809
|
[response]
|
|
6044
4810
|
);
|
|
6045
|
-
const previewText = (0,
|
|
4811
|
+
const previewText = (0, import_react2.useMemo)(
|
|
6046
4812
|
() => getPreviewText(activities, intent, isStreaming, !!response, isComplete),
|
|
6047
4813
|
[activities, intent, isStreaming, response, isComplete, import_i18next.default.language]
|
|
6048
4814
|
);
|
|
6049
|
-
const allSortedActivities = (0,
|
|
4815
|
+
const allSortedActivities = (0, import_react2.useMemo)(
|
|
6050
4816
|
() => [...activities].sort((a, b) => a.timestamp - b.timestamp),
|
|
6051
4817
|
[activities]
|
|
6052
4818
|
);
|
|
6053
|
-
const planActivities = (0,
|
|
4819
|
+
const planActivities = (0, import_react2.useMemo)(
|
|
6054
4820
|
() => allSortedActivities.filter((a) => a.type === "plan"),
|
|
6055
4821
|
[allSortedActivities]
|
|
6056
4822
|
);
|
|
6057
|
-
const sortedActivities = (0,
|
|
4823
|
+
const sortedActivities = (0, import_react2.useMemo)(
|
|
6058
4824
|
() => allSortedActivities.filter((a) => a.type !== "plan"),
|
|
6059
4825
|
[allSortedActivities]
|
|
6060
4826
|
);
|
|
6061
|
-
const hasTaskSubagents = (0,
|
|
4827
|
+
const hasTaskSubagents = (0, import_react2.useMemo)(
|
|
6062
4828
|
() => sortedActivities.some((a) => a.toolName === "Task"),
|
|
6063
4829
|
[sortedActivities]
|
|
6064
4830
|
);
|
|
6065
|
-
const groupedActivities = (0,
|
|
4831
|
+
const groupedActivities = (0, import_react2.useMemo)(
|
|
6066
4832
|
() => hasTaskSubagents ? groupActivitiesByParent(sortedActivities) : null,
|
|
6067
4833
|
[sortedActivities, hasTaskSubagents]
|
|
6068
4834
|
);
|
|
6069
|
-
const lastChildSet = (0,
|
|
4835
|
+
const lastChildSet = (0, import_react2.useMemo)(
|
|
6070
4836
|
() => !hasTaskSubagents ? computeLastChildSet(sortedActivities) : /* @__PURE__ */ new Set(),
|
|
6071
4837
|
[sortedActivities, hasTaskSubagents]
|
|
6072
4838
|
);
|
|
@@ -6099,7 +4865,7 @@ var TurnCard = React10.memo(function TurnCard2({
|
|
|
6099
4865
|
),
|
|
6100
4866
|
children: [
|
|
6101
4867
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
6102
|
-
|
|
4868
|
+
import_react3.motion.div,
|
|
6103
4869
|
{
|
|
6104
4870
|
initial: false,
|
|
6105
4871
|
animate: { rotate: isExpanded ? 90 : 0 },
|
|
@@ -6109,8 +4875,8 @@ var TurnCard = React10.memo(function TurnCard2({
|
|
|
6109
4875
|
}
|
|
6110
4876
|
),
|
|
6111
4877
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "-ml-0.5 shrink-0 px-1.5 py-0.5 rounded-[4px] bg-background shadow-minimal text-[10px] font-medium tabular-nums", children: activities.length }),
|
|
6112
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "relative flex-1 min-w-0 h-5 flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
6113
|
-
|
|
4878
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "relative flex-1 min-w-0 h-5 flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react3.AnimatePresence, { initial: false, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4879
|
+
import_react3.motion.span,
|
|
6114
4880
|
{
|
|
6115
4881
|
initial: { opacity: 0 },
|
|
6116
4882
|
animate: { opacity: 1 },
|
|
@@ -6132,8 +4898,8 @@ var TurnCard = React10.memo(function TurnCard2({
|
|
|
6132
4898
|
]
|
|
6133
4899
|
}
|
|
6134
4900
|
),
|
|
6135
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
6136
|
-
|
|
4901
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react3.AnimatePresence, { initial: false, children: isExpanded && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
4902
|
+
import_react3.motion.div,
|
|
6137
4903
|
{
|
|
6138
4904
|
initial: { height: 0, opacity: 0 },
|
|
6139
4905
|
animate: { height: "auto", opacity: 1 },
|
|
@@ -6155,7 +4921,7 @@ var TurnCard = React10.memo(function TurnCard2({
|
|
|
6155
4921
|
style: {
|
|
6156
4922
|
maxHeight: sortedActivities.length > SIZE_CONFIG.maxVisibleActivities ? SIZE_CONFIG.maxVisibleActivities * SIZE_CONFIG.activityRowHeight : void 0
|
|
6157
4923
|
},
|
|
6158
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
4924
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_react3.AnimatePresence, { mode: "sync", children: [
|
|
6159
4925
|
groupedActivities ? groupedActivities.map((item, index) => isActivityGroup(item) ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
6160
4926
|
ActivityGroupRow,
|
|
6161
4927
|
{
|
|
@@ -6169,7 +4935,7 @@ var TurnCard = React10.memo(function TurnCard2({
|
|
|
6169
4935
|
},
|
|
6170
4936
|
item.parent.id
|
|
6171
4937
|
) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
6172
|
-
|
|
4938
|
+
import_react3.motion.div,
|
|
6173
4939
|
{
|
|
6174
4940
|
initial: hasUserToggled.current || hasMounted.current ? { opacity: 0, x: -8 } : false,
|
|
6175
4941
|
animate: { opacity: 1, x: 0 },
|
|
@@ -6188,7 +4954,7 @@ var TurnCard = React10.memo(function TurnCard2({
|
|
|
6188
4954
|
)) : (
|
|
6189
4955
|
/* Flat view for simple tool calls */
|
|
6190
4956
|
sortedActivities.map((activity, index) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
6191
|
-
|
|
4957
|
+
import_react3.motion.div,
|
|
6192
4958
|
{
|
|
6193
4959
|
initial: hasUserToggled.current || hasMounted.current ? { opacity: 0, x: -8 } : false,
|
|
6194
4960
|
animate: { opacity: 1, x: 0 },
|
|
@@ -6208,7 +4974,7 @@ var TurnCard = React10.memo(function TurnCard2({
|
|
|
6208
4974
|
))
|
|
6209
4975
|
),
|
|
6210
4976
|
isThinking && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
6211
|
-
|
|
4977
|
+
import_react3.motion.div,
|
|
6212
4978
|
{
|
|
6213
4979
|
initial: { opacity: 0, x: -8 },
|
|
6214
4980
|
animate: { opacity: 1, x: 0 },
|
|
@@ -6264,8 +5030,8 @@ var TurnCard = React10.memo(function TurnCard2({
|
|
|
6264
5030
|
annotationInteractionMode
|
|
6265
5031
|
}
|
|
6266
5032
|
) }, planActivity.id)),
|
|
6267
|
-
animateResponse && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
6268
|
-
|
|
5033
|
+
animateResponse && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react3.AnimatePresence, { children: response && !isBuffering && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5034
|
+
import_react3.motion.div,
|
|
6269
5035
|
{
|
|
6270
5036
|
initial: { opacity: 0, y: 8 },
|
|
6271
5037
|
animate: { opacity: 1, y: 0 },
|
|
@@ -6749,15 +5515,15 @@ function UserMessageBubble({
|
|
|
6749
5515
|
}) {
|
|
6750
5516
|
const { t: t2 } = (0, import_react_i18next5.useTranslation)();
|
|
6751
5517
|
const hasAttachments = attachments && attachments.length > 0;
|
|
6752
|
-
const [showQueued, setShowQueued] = (0,
|
|
6753
|
-
const queuedShownAtRef = (0,
|
|
6754
|
-
const clearTimerRef = (0,
|
|
6755
|
-
(0,
|
|
5518
|
+
const [showQueued, setShowQueued] = (0, import_react13.useState)(isQueued ?? false);
|
|
5519
|
+
const queuedShownAtRef = (0, import_react13.useRef)(isQueued ? Date.now() : null);
|
|
5520
|
+
const clearTimerRef = (0, import_react13.useRef)(null);
|
|
5521
|
+
(0, import_react13.useEffect)(() => {
|
|
6756
5522
|
return () => {
|
|
6757
5523
|
if (clearTimerRef.current) clearTimeout(clearTimerRef.current);
|
|
6758
5524
|
};
|
|
6759
5525
|
}, []);
|
|
6760
|
-
(0,
|
|
5526
|
+
(0, import_react13.useEffect)(() => {
|
|
6761
5527
|
if (clearTimerRef.current) {
|
|
6762
5528
|
clearTimeout(clearTimerRef.current);
|
|
6763
5529
|
clearTimerRef.current = null;
|
|
@@ -7053,8 +5819,8 @@ function ChatTranscript({
|
|
|
7053
5819
|
sessionFolderPath,
|
|
7054
5820
|
children
|
|
7055
5821
|
}) {
|
|
7056
|
-
const turns = (0,
|
|
7057
|
-
const [expandedTurns, setExpandedTurns] = (0,
|
|
5822
|
+
const turns = (0, import_react12.useMemo)(() => groupMessagesByTurn(messages), [messages]);
|
|
5823
|
+
const [expandedTurns, setExpandedTurns] = (0, import_react12.useState)(() => {
|
|
7058
5824
|
if (defaultExpanded) {
|
|
7059
5825
|
return new Set(
|
|
7060
5826
|
turns.map(
|
|
@@ -7064,8 +5830,8 @@ function ChatTranscript({
|
|
|
7064
5830
|
}
|
|
7065
5831
|
return /* @__PURE__ */ new Set();
|
|
7066
5832
|
});
|
|
7067
|
-
const [expandedActivityGroups, setExpandedActivityGroups] = (0,
|
|
7068
|
-
const handleExpandedChange = (0,
|
|
5833
|
+
const [expandedActivityGroups, setExpandedActivityGroups] = (0, import_react12.useState)(/* @__PURE__ */ new Set());
|
|
5834
|
+
const handleExpandedChange = (0, import_react12.useCallback)((turnId, expanded) => {
|
|
7069
5835
|
setExpandedTurns((prev) => {
|
|
7070
5836
|
const next = new Set(prev);
|
|
7071
5837
|
if (expanded) {
|
|
@@ -7076,17 +5842,17 @@ function ChatTranscript({
|
|
|
7076
5842
|
return next;
|
|
7077
5843
|
});
|
|
7078
5844
|
}, []);
|
|
7079
|
-
const handleExpandedActivityGroupsChange = (0,
|
|
5845
|
+
const handleExpandedActivityGroupsChange = (0, import_react12.useCallback)((groups) => {
|
|
7080
5846
|
setExpandedActivityGroups(groups);
|
|
7081
5847
|
}, []);
|
|
7082
|
-
const handleOpenActivityDetails = (0,
|
|
5848
|
+
const handleOpenActivityDetails = (0, import_react12.useCallback)((activity) => {
|
|
7083
5849
|
if (onActivityClick) {
|
|
7084
5850
|
onActivityClick(activity);
|
|
7085
5851
|
} else if (platformActions.onOpenActivityDetails) {
|
|
7086
5852
|
platformActions.onOpenActivityDetails(sessionId, activity.id);
|
|
7087
5853
|
}
|
|
7088
5854
|
}, [onActivityClick, platformActions, sessionId]);
|
|
7089
|
-
const handleOpenTurnDetails = (0,
|
|
5855
|
+
const handleOpenTurnDetails = (0, import_react12.useCallback)((turnId) => {
|
|
7090
5856
|
if (onTurnClick) {
|
|
7091
5857
|
onTurnClick(turnId);
|
|
7092
5858
|
} else if (platformActions.onOpenTurnDetails) {
|
|
@@ -7191,7 +5957,7 @@ function ChatTranscript({
|
|
|
7191
5957
|
}
|
|
7192
5958
|
);
|
|
7193
5959
|
}
|
|
7194
|
-
var PlatformContext = (0,
|
|
5960
|
+
var PlatformContext = (0, import_react15.createContext)({});
|
|
7195
5961
|
function PlatformProvider({
|
|
7196
5962
|
actions,
|
|
7197
5963
|
children
|
|
@@ -7210,7 +5976,7 @@ function SessionViewer({
|
|
|
7210
5976
|
footer,
|
|
7211
5977
|
sessionFolderPath
|
|
7212
5978
|
}) {
|
|
7213
|
-
const messages = (0,
|
|
5979
|
+
const messages = (0, import_react14.useMemo)(
|
|
7214
5980
|
() => session.messages.map(storedToMessage),
|
|
7215
5981
|
[session.messages]
|
|
7216
5982
|
);
|
|
@@ -7266,9 +6032,9 @@ function AssistantTurnCard({
|
|
|
7266
6032
|
isLast,
|
|
7267
6033
|
onInspectActivity
|
|
7268
6034
|
}) {
|
|
7269
|
-
const [isExpanded, setIsExpanded] = (0,
|
|
7270
|
-
const [expandedActivityGroups, setExpandedActivityGroups] = (0,
|
|
7271
|
-
(0,
|
|
6035
|
+
const [isExpanded, setIsExpanded] = (0, import_react16.useState)(true);
|
|
6036
|
+
const [expandedActivityGroups, setExpandedActivityGroups] = (0, import_react16.useState)(/* @__PURE__ */ new Set());
|
|
6037
|
+
(0, import_react16.useEffect)(() => {
|
|
7272
6038
|
if (turn.isStreaming) {
|
|
7273
6039
|
setIsExpanded(true);
|
|
7274
6040
|
}
|
|
@@ -7343,7 +6109,7 @@ function ActivityDetailsPanel({
|
|
|
7343
6109
|
activity,
|
|
7344
6110
|
onClose
|
|
7345
6111
|
}) {
|
|
7346
|
-
(0,
|
|
6112
|
+
(0, import_react17.useEffect)(() => {
|
|
7347
6113
|
if (!activity) return;
|
|
7348
6114
|
const handleKeyDown = (e) => {
|
|
7349
6115
|
if (e.key === "Escape") onClose();
|
|
@@ -8982,12 +7748,12 @@ function normalizeTokenUsage(usage) {
|
|
|
8982
7748
|
}
|
|
8983
7749
|
function useEventProcessor(options) {
|
|
8984
7750
|
const { eventSource, sessionId, workspaceId, workspaceName, onEffect, onError, onClose } = options;
|
|
8985
|
-
const [session, setSession] = (0,
|
|
8986
|
-
const sessionRef = (0,
|
|
8987
|
-
const streamingStates = (0,
|
|
8988
|
-
const [isConnected, setIsConnected] = (0,
|
|
8989
|
-
const processedCount = (0,
|
|
8990
|
-
const processAgentEvent = (0,
|
|
7751
|
+
const [session, setSession] = (0, import_react18.useState)(null);
|
|
7752
|
+
const sessionRef = (0, import_react18.useRef)(null);
|
|
7753
|
+
const streamingStates = (0, import_react18.useRef)(/* @__PURE__ */ new Map());
|
|
7754
|
+
const [isConnected, setIsConnected] = (0, import_react18.useState)(false);
|
|
7755
|
+
const processedCount = (0, import_react18.useRef)(0);
|
|
7756
|
+
const processAgentEvent = (0, import_react18.useCallback)((event) => {
|
|
8991
7757
|
const processorEvent = mapCoreEventToProcessorEvent(event, sessionId);
|
|
8992
7758
|
const currentSession = sessionRef.current ?? createEmptySession(sessionId, workspaceId, workspaceName ?? "");
|
|
8993
7759
|
const currentState = {
|
|
@@ -9007,7 +7773,7 @@ function useEventProcessor(options) {
|
|
|
9007
7773
|
effects: result.effects
|
|
9008
7774
|
};
|
|
9009
7775
|
}, [sessionId, workspaceId, workspaceName]);
|
|
9010
|
-
(0,
|
|
7776
|
+
(0, import_react18.useEffect)(() => {
|
|
9011
7777
|
eventSource.connect(
|
|
9012
7778
|
(coreEvent) => {
|
|
9013
7779
|
const result = processAgentEvent(coreEvent);
|
|
@@ -9030,10 +7796,10 @@ function useEventProcessor(options) {
|
|
|
9030
7796
|
setIsConnected(false);
|
|
9031
7797
|
};
|
|
9032
7798
|
}, [eventSource, processAgentEvent, onEffect, onError, onClose]);
|
|
9033
|
-
const clearStreamingState = (0,
|
|
7799
|
+
const clearStreamingState = (0, import_react18.useCallback)(() => {
|
|
9034
7800
|
streamingStates.current.delete(sessionId);
|
|
9035
7801
|
}, [sessionId]);
|
|
9036
|
-
const getStreamingState = (0,
|
|
7802
|
+
const getStreamingState = (0, import_react18.useCallback)(() => {
|
|
9037
7803
|
return streamingStates.current.get(sessionId) ?? null;
|
|
9038
7804
|
}, [sessionId]);
|
|
9039
7805
|
return {
|
|
@@ -9047,9 +7813,9 @@ function useEventProcessor(options) {
|
|
|
9047
7813
|
}
|
|
9048
7814
|
|
|
9049
7815
|
// ../packages/local-chat/dist/index.js
|
|
9050
|
-
var import_react19 = require("react");
|
|
9051
|
-
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
9052
7816
|
var import_react20 = require("react");
|
|
7817
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
7818
|
+
var import_react21 = require("react");
|
|
9053
7819
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
9054
7820
|
function createAgentChatPanelModel(args) {
|
|
9055
7821
|
return {
|
|
@@ -9099,8 +7865,8 @@ function createTimelineDetailItems(timeline) {
|
|
|
9099
7865
|
}
|
|
9100
7866
|
function useAgentChatSession(options) {
|
|
9101
7867
|
const { runtime, workspaceId = "local-workspace", workspaceName = "Local Workspace" } = options;
|
|
9102
|
-
const [auth, setAuth] = (0,
|
|
9103
|
-
const [error, setError] = (0,
|
|
7868
|
+
const [auth, setAuth] = (0, import_react20.useState)(null);
|
|
7869
|
+
const [error, setError] = (0, import_react20.useState)(null);
|
|
9104
7870
|
const processor = useEventProcessor({
|
|
9105
7871
|
eventSource: runtime.events,
|
|
9106
7872
|
sessionId: runtime.sessionId,
|
|
@@ -9108,7 +7874,7 @@ function useAgentChatSession(options) {
|
|
|
9108
7874
|
workspaceName,
|
|
9109
7875
|
onError: setError
|
|
9110
7876
|
});
|
|
9111
|
-
const sendMessage = (0,
|
|
7877
|
+
const sendMessage = (0, import_react20.useCallback)(async (message) => {
|
|
9112
7878
|
setError(null);
|
|
9113
7879
|
try {
|
|
9114
7880
|
if (!auth) {
|
|
@@ -9124,13 +7890,13 @@ function useAgentChatSession(options) {
|
|
|
9124
7890
|
throw err;
|
|
9125
7891
|
}
|
|
9126
7892
|
}, [auth, runtime]);
|
|
9127
|
-
const abort = (0,
|
|
7893
|
+
const abort = (0, import_react20.useCallback)(async () => {
|
|
9128
7894
|
await runtime.commands.abort("User aborted");
|
|
9129
7895
|
}, [runtime]);
|
|
9130
|
-
const respondToPermission = (0,
|
|
7896
|
+
const respondToPermission = (0, import_react20.useCallback)(async (requestId, allowed, remember) => {
|
|
9131
7897
|
await runtime.commands.respondToPermission(requestId, allowed, remember);
|
|
9132
7898
|
}, [runtime]);
|
|
9133
|
-
const model = (0,
|
|
7899
|
+
const model = (0, import_react20.useMemo)(
|
|
9134
7900
|
() => createAgentChatPanelModel({ session: processor.session, runtime, auth, error }),
|
|
9135
7901
|
[processor.session, runtime, auth, error]
|
|
9136
7902
|
);
|
|
@@ -9147,8 +7913,8 @@ function useAgentChatSession(options) {
|
|
|
9147
7913
|
}
|
|
9148
7914
|
function useTimelineAgentChatSession(options) {
|
|
9149
7915
|
const { runtime, workspaceId = "local-workspace", workspaceName = "Local Workspace" } = options;
|
|
9150
|
-
const [timeline, setTimeline] = (0,
|
|
9151
|
-
const [sessionState, setSessionState] = (0,
|
|
7916
|
+
const [timeline, setTimeline] = (0, import_react20.useState)([]);
|
|
7917
|
+
const [sessionState, setSessionState] = (0, import_react20.useState)(() => ({
|
|
9152
7918
|
session: {
|
|
9153
7919
|
id: runtime.sessionId,
|
|
9154
7920
|
workspaceId,
|
|
@@ -9159,12 +7925,12 @@ function useTimelineAgentChatSession(options) {
|
|
|
9159
7925
|
},
|
|
9160
7926
|
streaming: null
|
|
9161
7927
|
}));
|
|
9162
|
-
const [capabilityReport, setCapabilityReport] = (0,
|
|
9163
|
-
const [error, setError] = (0,
|
|
9164
|
-
const [isReconnecting, setIsReconnecting] = (0,
|
|
9165
|
-
const [hasGap, setHasGap] = (0,
|
|
9166
|
-
const lastCursorRef = (0,
|
|
9167
|
-
(0,
|
|
7928
|
+
const [capabilityReport, setCapabilityReport] = (0, import_react20.useState)(null);
|
|
7929
|
+
const [error, setError] = (0, import_react20.useState)(null);
|
|
7930
|
+
const [isReconnecting, setIsReconnecting] = (0, import_react20.useState)(false);
|
|
7931
|
+
const [hasGap, setHasGap] = (0, import_react20.useState)(false);
|
|
7932
|
+
const lastCursorRef = (0, import_react20.useRef)(null);
|
|
7933
|
+
(0, import_react20.useEffect)(() => {
|
|
9168
7934
|
let catchupAbort = false;
|
|
9169
7935
|
const onEvent = (envelope) => {
|
|
9170
7936
|
lastCursorRef.current = { epoch: envelope.epoch, afterSeq: envelope.seq };
|
|
@@ -9215,7 +7981,7 @@ function useTimelineAgentChatSession(options) {
|
|
|
9215
7981
|
runtime.events.disconnect();
|
|
9216
7982
|
};
|
|
9217
7983
|
}, [runtime]);
|
|
9218
|
-
const sendMessage = (0,
|
|
7984
|
+
const sendMessage = (0, import_react20.useCallback)(async (message, options2) => {
|
|
9219
7985
|
setError(null);
|
|
9220
7986
|
setHasGap(false);
|
|
9221
7987
|
try {
|
|
@@ -9230,13 +7996,13 @@ function useTimelineAgentChatSession(options) {
|
|
|
9230
7996
|
throw err;
|
|
9231
7997
|
}
|
|
9232
7998
|
}, [capabilityReport, runtime]);
|
|
9233
|
-
const abort = (0,
|
|
7999
|
+
const abort = (0, import_react20.useCallback)(async () => {
|
|
9234
8000
|
await runtime.commands.abort("User aborted");
|
|
9235
8001
|
}, [runtime]);
|
|
9236
|
-
const respondToPermission = (0,
|
|
8002
|
+
const respondToPermission = (0, import_react20.useCallback)(async (requestId, allowed, remember) => {
|
|
9237
8003
|
await runtime.commands.respondToPermission(requestId, allowed, remember);
|
|
9238
8004
|
}, [runtime]);
|
|
9239
|
-
const turns = (0,
|
|
8005
|
+
const turns = (0, import_react20.useMemo)(
|
|
9240
8006
|
() => groupMessagesByTurn(sessionState.session.messages),
|
|
9241
8007
|
[sessionState]
|
|
9242
8008
|
);
|
|
@@ -9471,7 +8237,7 @@ function AgentChatPanel({
|
|
|
9471
8237
|
className
|
|
9472
8238
|
}) {
|
|
9473
8239
|
const chat = useAgentChatSession({ runtime, workspaceId, workspaceName });
|
|
9474
|
-
const [draft, setDraft] = (0,
|
|
8240
|
+
const [draft, setDraft] = (0, import_react19.useState)("");
|
|
9475
8241
|
async function handleSubmit(event) {
|
|
9476
8242
|
event.preventDefault();
|
|
9477
8243
|
const message = draft.trim();
|
|
@@ -9587,15 +8353,15 @@ function TimelineAgentChatPanel({
|
|
|
9587
8353
|
className
|
|
9588
8354
|
}) {
|
|
9589
8355
|
const chat = useTimelineAgentChatSession({ runtime, workspaceId, workspaceName });
|
|
9590
|
-
const [draft, setDraft] = (0,
|
|
9591
|
-
const [selectedActivity, setSelectedActivity] = (0,
|
|
9592
|
-
const [selectedDetail, setSelectedDetail] = (0,
|
|
9593
|
-
const [permissionMode, setPermissionMode] = (0,
|
|
9594
|
-
const [isPermMenuOpen, setIsPermMenuOpen] = (0,
|
|
8356
|
+
const [draft, setDraft] = (0, import_react21.useState)("");
|
|
8357
|
+
const [selectedActivity, setSelectedActivity] = (0, import_react21.useState)(null);
|
|
8358
|
+
const [selectedDetail, setSelectedDetail] = (0, import_react21.useState)(null);
|
|
8359
|
+
const [permissionMode, setPermissionMode] = (0, import_react21.useState)("ask");
|
|
8360
|
+
const [isPermMenuOpen, setIsPermMenuOpen] = (0, import_react21.useState)(false);
|
|
9595
8361
|
const runtimeState = runtime.getState();
|
|
9596
8362
|
const isWaitingPermission = runtimeState.status === "waiting_for_permission";
|
|
9597
8363
|
const waitingRequestId = runtimeState.waitingPermissionRequestId;
|
|
9598
|
-
const { visibleTurns, showPendingIndicator } = (0,
|
|
8364
|
+
const { visibleTurns, showPendingIndicator } = (0, import_react21.useMemo)(() => {
|
|
9599
8365
|
const lastTurn = chat.turns.at(-1);
|
|
9600
8366
|
if (!chat.isConnected && !chat.isReconnecting) return { visibleTurns: chat.turns, showPendingIndicator: false };
|
|
9601
8367
|
if (lastTurn?.type === "assistant" && lastTurn.activities.length === 0 && !lastTurn.response && lastTurn.isStreaming) {
|
|
@@ -9604,16 +8370,16 @@ function TimelineAgentChatPanel({
|
|
|
9604
8370
|
if (lastTurn?.type === "user") return { visibleTurns: chat.turns, showPendingIndicator: true };
|
|
9605
8371
|
return { visibleTurns: chat.turns, showPendingIndicator: false };
|
|
9606
8372
|
}, [chat.turns, chat.isConnected, chat.isReconnecting]);
|
|
9607
|
-
const permissionRequest = (0,
|
|
8373
|
+
const permissionRequest = (0, import_react21.useMemo)(() => {
|
|
9608
8374
|
if (!isWaitingPermission || !waitingRequestId) return null;
|
|
9609
8375
|
return findActivePermissionRequest(chat.timeline);
|
|
9610
8376
|
}, [isWaitingPermission, waitingRequestId, chat.timeline]);
|
|
9611
|
-
const detailItems = (0,
|
|
8377
|
+
const detailItems = (0, import_react21.useMemo)(
|
|
9612
8378
|
() => createTimelineDetailItems(chat.timeline),
|
|
9613
8379
|
[chat.timeline]
|
|
9614
8380
|
);
|
|
9615
|
-
const scrollRef = (0,
|
|
9616
|
-
(0,
|
|
8381
|
+
const scrollRef = (0, import_react21.useRef)(null);
|
|
8382
|
+
(0, import_react21.useEffect)(() => {
|
|
9617
8383
|
if (scrollRef.current) {
|
|
9618
8384
|
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
|
9619
8385
|
}
|
|
@@ -9628,10 +8394,10 @@ function TimelineAgentChatPanel({
|
|
|
9628
8394
|
} catch {
|
|
9629
8395
|
}
|
|
9630
8396
|
}
|
|
9631
|
-
const handlePermissionAllow = (0,
|
|
8397
|
+
const handlePermissionAllow = (0, import_react21.useCallback)((requestId, remember) => {
|
|
9632
8398
|
void chat.respondToPermission(requestId, true, remember);
|
|
9633
8399
|
}, [chat]);
|
|
9634
|
-
const handlePermissionDeny = (0,
|
|
8400
|
+
const handlePermissionDeny = (0, import_react21.useCallback)((requestId) => {
|
|
9635
8401
|
void chat.respondToPermission(requestId, false);
|
|
9636
8402
|
}, [chat]);
|
|
9637
8403
|
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: `flex flex-col h-full ${className ?? ""}`, children: [
|
|
@@ -9775,50 +8541,9 @@ function TimelineAgentChatPanel({
|
|
|
9775
8541
|
0 && (module.exports = {
|
|
9776
8542
|
AgentChatPanel,
|
|
9777
8543
|
EN_FALLBACK,
|
|
9778
|
-
RPC_CHANNELS,
|
|
9779
|
-
THINKING_LEVELS,
|
|
9780
|
-
THINKING_LEVEL_IDS,
|
|
9781
|
-
THINKING_TO_EFFORT,
|
|
9782
8544
|
TimelineAgentChatPanel,
|
|
9783
|
-
appendTimelineItem,
|
|
9784
8545
|
createFlitroEmbedRuntime,
|
|
9785
|
-
createInMemoryApprovalStore,
|
|
9786
|
-
createPermissionPolicy,
|
|
9787
|
-
createPermissionPolicyFromConfig,
|
|
9788
|
-
createPolicyDecisionReceipt,
|
|
9789
|
-
createRuntimeCapabilityReport,
|
|
9790
|
-
createRuntimeExtensionContext,
|
|
9791
|
-
createSourcePolicyLayer,
|
|
9792
|
-
createTimelineCursor,
|
|
9793
|
-
createTimelineSequencer,
|
|
9794
|
-
debug,
|
|
9795
|
-
evaluateToolPolicy,
|
|
9796
|
-
explainToolPolicy,
|
|
9797
|
-
fetchTimeline,
|
|
9798
|
-
findMentionMatches,
|
|
9799
|
-
generateMessageId,
|
|
9800
|
-
getThinkingLevelNameKey,
|
|
9801
|
-
getThinkingTokens,
|
|
9802
|
-
invokeSessionTool,
|
|
9803
|
-
isValidThinkingLevel,
|
|
9804
|
-
mergeTimeline,
|
|
9805
|
-
messageToStored,
|
|
9806
|
-
normalizePath,
|
|
9807
|
-
normalizeThinkingLevel,
|
|
9808
|
-
parseMentions,
|
|
9809
|
-
pathStartsWith,
|
|
9810
|
-
reduceRuntimeState,
|
|
9811
|
-
resolveFileMentions,
|
|
9812
|
-
resolvePathMentions,
|
|
9813
|
-
resolveSkillMentions,
|
|
9814
|
-
resolveSourceMentions,
|
|
9815
|
-
sanitizeProviderSourceTools,
|
|
9816
|
-
selectRuntimeCandidate,
|
|
9817
|
-
storedToMessage,
|
|
9818
|
-
stripAllMentions,
|
|
9819
|
-
stripPathPrefix,
|
|
9820
8546
|
useAgentChatSession,
|
|
9821
8547
|
useAgentSession,
|
|
9822
|
-
useTimelineAgentChatSession
|
|
9823
|
-
validatePolicyConfig
|
|
8548
|
+
useTimelineAgentChatSession
|
|
9824
8549
|
});
|