@tutti-os/agent-gui 0.0.30 → 0.0.31
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/index.js +54 -173
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -18589,9 +18589,47 @@ function AgentComposer({
|
|
|
18589
18589
|
[onDraftContentChange]
|
|
18590
18590
|
);
|
|
18591
18591
|
const applyReferencePickResult = useCallback9(
|
|
18592
|
-
(result) => {
|
|
18592
|
+
async (result) => {
|
|
18593
18593
|
if (result.files.length > 0) {
|
|
18594
|
-
|
|
18594
|
+
const uploadPromptContent = agentActivityRuntime?.uploadPromptContent;
|
|
18595
|
+
const uploadedFiles = await Promise.all(
|
|
18596
|
+
result.files.map(async (file) => {
|
|
18597
|
+
const hostPath = file.hostPath?.trim() ?? "";
|
|
18598
|
+
if (!hostPath) {
|
|
18599
|
+
return file;
|
|
18600
|
+
}
|
|
18601
|
+
if (!uploadPromptContent) {
|
|
18602
|
+
throw new Error(
|
|
18603
|
+
"Prompt file uploads are not supported by this agent runtime."
|
|
18604
|
+
);
|
|
18605
|
+
}
|
|
18606
|
+
const uploaded = await uploadPromptContent({
|
|
18607
|
+
workspaceId,
|
|
18608
|
+
content: [
|
|
18609
|
+
{
|
|
18610
|
+
type: "file",
|
|
18611
|
+
hostPath,
|
|
18612
|
+
name: file.displayName,
|
|
18613
|
+
kind: "file"
|
|
18614
|
+
}
|
|
18615
|
+
]
|
|
18616
|
+
});
|
|
18617
|
+
const uploadedFile = uploaded.content.find(
|
|
18618
|
+
(block) => block.type === "file"
|
|
18619
|
+
);
|
|
18620
|
+
const uploadedPath = uploadedFile?.path?.trim() ?? "";
|
|
18621
|
+
if (!uploadedPath) {
|
|
18622
|
+
throw new Error("Prompt file upload completed without path.");
|
|
18623
|
+
}
|
|
18624
|
+
return {
|
|
18625
|
+
...file,
|
|
18626
|
+
path: uploadedPath,
|
|
18627
|
+
...uploadedFile?.name ? { displayName: uploadedFile.name } : file.displayName ? { displayName: file.displayName } : {},
|
|
18628
|
+
...uploadedFile?.sizeBytes ? { sizeBytes: uploadedFile.sizeBytes } : {}
|
|
18629
|
+
};
|
|
18630
|
+
})
|
|
18631
|
+
);
|
|
18632
|
+
editorHandleRef.current?.insertWorkspaceReferences(uploadedFiles);
|
|
18595
18633
|
}
|
|
18596
18634
|
if (result.mentionItems.length > 0) {
|
|
18597
18635
|
editorHandleRef.current?.insertMentionItems(result.mentionItems);
|
|
@@ -18600,13 +18638,13 @@ function AgentComposer({
|
|
|
18600
18638
|
addDraftFiles(result.hostAttachments);
|
|
18601
18639
|
}
|
|
18602
18640
|
},
|
|
18603
|
-
[addDraftFiles]
|
|
18641
|
+
[addDraftFiles, agentActivityRuntime, workspaceId]
|
|
18604
18642
|
);
|
|
18605
18643
|
const handleWorkspaceReferencePicker = useCallback9(async () => {
|
|
18606
18644
|
if (!onRequestWorkspaceReferences) {
|
|
18607
18645
|
return;
|
|
18608
18646
|
}
|
|
18609
|
-
applyReferencePickResult(await onRequestWorkspaceReferences());
|
|
18647
|
+
await applyReferencePickResult(await onRequestWorkspaceReferences());
|
|
18610
18648
|
}, [applyReferencePickResult, onRequestWorkspaceReferences]);
|
|
18611
18649
|
const handleOpenReferencesForEntity = useCallback9(
|
|
18612
18650
|
(entity) => {
|
|
@@ -18614,7 +18652,9 @@ function AgentComposer({
|
|
|
18614
18652
|
if (!onRequestWorkspaceReferences) {
|
|
18615
18653
|
return;
|
|
18616
18654
|
}
|
|
18617
|
-
void onRequestWorkspaceReferences(entity).then(
|
|
18655
|
+
void onRequestWorkspaceReferences(entity).then(
|
|
18656
|
+
(result) => applyReferencePickResult(result)
|
|
18657
|
+
);
|
|
18618
18658
|
},
|
|
18619
18659
|
[
|
|
18620
18660
|
closeFileMentionPalette,
|
|
@@ -20138,7 +20178,6 @@ function AgentGUINodeView({
|
|
|
20138
20178
|
workspaceAppIcons = EMPTY_WORKSPACE_APP_ICONS3
|
|
20139
20179
|
}) {
|
|
20140
20180
|
"use memo";
|
|
20141
|
-
const agentHostApi = useAgentHostApi();
|
|
20142
20181
|
const layoutElementRef = useRef13(null);
|
|
20143
20182
|
const railResizeInteractionRef = useRef13(null);
|
|
20144
20183
|
const [isRailResizing, setIsRailResizing] = useState11(false);
|
|
@@ -20159,121 +20198,7 @@ function AgentGUINodeView({
|
|
|
20159
20198
|
() => ({ files: [], mentionItems: [], hostAttachments: [] }),
|
|
20160
20199
|
[]
|
|
20161
20200
|
);
|
|
20162
|
-
const hostLocalFileLabel = uiLanguage === "zh-CN" ? "\u672C\u5730\u6587\u4EF6(\u5BBF\u4E3B\u673A)" : "Local files (Host)";
|
|
20163
|
-
const hostLocalFileSelectLabel = uiLanguage === "zh-CN" ? "\u4ECE\u7535\u8111\u9009\u62E9\u2026" : "Choose from computer\u2026";
|
|
20164
20201
|
const hostLocalFileSourceId = "host-local-file";
|
|
20165
|
-
const hostLocalFileActionPath = "host-local-file://select";
|
|
20166
|
-
const referenceSourceAggregatorWithHostLocalFile = useMemo10(() => {
|
|
20167
|
-
if (!referenceSourceAggregator) {
|
|
20168
|
-
return null;
|
|
20169
|
-
}
|
|
20170
|
-
const sourceId = hostLocalFileSourceId;
|
|
20171
|
-
const actionNode = {
|
|
20172
|
-
ref: { sourceId, nodeId: "select-files" },
|
|
20173
|
-
kind: "file",
|
|
20174
|
-
displayName: hostLocalFileSelectLabel
|
|
20175
|
-
};
|
|
20176
|
-
const rootNode = {
|
|
20177
|
-
ref: { sourceId, nodeId: "\0source-root" },
|
|
20178
|
-
kind: "folder",
|
|
20179
|
-
displayName: hostLocalFileLabel,
|
|
20180
|
-
hasChildren: true
|
|
20181
|
-
};
|
|
20182
|
-
let hostProvidedLocalFileSource = false;
|
|
20183
|
-
return {
|
|
20184
|
-
...referenceSourceAggregator,
|
|
20185
|
-
async listSources(scope) {
|
|
20186
|
-
const sources = await referenceSourceAggregator.listSources(scope);
|
|
20187
|
-
hostProvidedLocalFileSource = sources.some(
|
|
20188
|
-
(source) => source.sourceId === sourceId
|
|
20189
|
-
);
|
|
20190
|
-
if (hostProvidedLocalFileSource) {
|
|
20191
|
-
return sources;
|
|
20192
|
-
}
|
|
20193
|
-
return [
|
|
20194
|
-
...sources,
|
|
20195
|
-
{
|
|
20196
|
-
sourceId,
|
|
20197
|
-
label: hostLocalFileLabel,
|
|
20198
|
-
icon: "file",
|
|
20199
|
-
capabilities: {
|
|
20200
|
-
searchable: false,
|
|
20201
|
-
previewable: false,
|
|
20202
|
-
paginated: false,
|
|
20203
|
-
navigable: false,
|
|
20204
|
-
filterable: false
|
|
20205
|
-
}
|
|
20206
|
-
}
|
|
20207
|
-
];
|
|
20208
|
-
},
|
|
20209
|
-
async listRoot(scope) {
|
|
20210
|
-
const root = await referenceSourceAggregator.listRoot(scope);
|
|
20211
|
-
if (hostProvidedLocalFileSource) {
|
|
20212
|
-
return root;
|
|
20213
|
-
}
|
|
20214
|
-
return [...root, rootNode];
|
|
20215
|
-
},
|
|
20216
|
-
async listChildren(scope, node, input) {
|
|
20217
|
-
if (node.sourceId === sourceId && !hostProvidedLocalFileSource) {
|
|
20218
|
-
return { entries: [actionNode], nextCursor: null };
|
|
20219
|
-
}
|
|
20220
|
-
return await referenceSourceAggregator.listChildren(scope, node, input);
|
|
20221
|
-
},
|
|
20222
|
-
async search(scope, currentSourceId, input) {
|
|
20223
|
-
if (currentSourceId === sourceId && !hostProvidedLocalFileSource) {
|
|
20224
|
-
return { entries: [], nextCursor: null };
|
|
20225
|
-
}
|
|
20226
|
-
return await referenceSourceAggregator.search(
|
|
20227
|
-
scope,
|
|
20228
|
-
currentSourceId,
|
|
20229
|
-
input
|
|
20230
|
-
);
|
|
20231
|
-
},
|
|
20232
|
-
async open(scope, node) {
|
|
20233
|
-
if (node.ref.sourceId === sourceId && !hostProvidedLocalFileSource) {
|
|
20234
|
-
return;
|
|
20235
|
-
}
|
|
20236
|
-
await referenceSourceAggregator.open(scope, node);
|
|
20237
|
-
},
|
|
20238
|
-
async readPreview(scope, node) {
|
|
20239
|
-
if (node.ref.sourceId === sourceId && !hostProvidedLocalFileSource) {
|
|
20240
|
-
return null;
|
|
20241
|
-
}
|
|
20242
|
-
return await referenceSourceAggregator.readPreview(scope, node);
|
|
20243
|
-
},
|
|
20244
|
-
resolveSelection(node) {
|
|
20245
|
-
if (node.ref.sourceId === sourceId && !hostProvidedLocalFileSource) {
|
|
20246
|
-
return {
|
|
20247
|
-
path: hostLocalFileActionPath,
|
|
20248
|
-
kind: "file",
|
|
20249
|
-
displayName: actionNode.displayName
|
|
20250
|
-
};
|
|
20251
|
-
}
|
|
20252
|
-
return referenceSourceAggregator.resolveSelection(node);
|
|
20253
|
-
},
|
|
20254
|
-
async locateTarget(scope, currentSourceId, params) {
|
|
20255
|
-
if (currentSourceId === sourceId && !hostProvidedLocalFileSource) {
|
|
20256
|
-
return null;
|
|
20257
|
-
}
|
|
20258
|
-
return await referenceSourceAggregator.locateTarget(
|
|
20259
|
-
scope,
|
|
20260
|
-
currentSourceId,
|
|
20261
|
-
params
|
|
20262
|
-
);
|
|
20263
|
-
},
|
|
20264
|
-
getLoadedSource(currentSourceId) {
|
|
20265
|
-
if (currentSourceId === sourceId && !hostProvidedLocalFileSource) {
|
|
20266
|
-
return void 0;
|
|
20267
|
-
}
|
|
20268
|
-
return referenceSourceAggregator.getLoadedSource(currentSourceId);
|
|
20269
|
-
}
|
|
20270
|
-
};
|
|
20271
|
-
}, [
|
|
20272
|
-
hostLocalFileLabel,
|
|
20273
|
-
hostLocalFileSelectLabel,
|
|
20274
|
-
hostLocalFileSourceId,
|
|
20275
|
-
referenceSourceAggregator
|
|
20276
|
-
]);
|
|
20277
20202
|
const isWorkspaceReferencePickerNodeSelectable = useCallback10(
|
|
20278
20203
|
(node) => node.ref.sourceId !== hostLocalFileSourceId || node.kind === "file",
|
|
20279
20204
|
[hostLocalFileSourceId]
|
|
@@ -20283,10 +20208,10 @@ function AgentGUINodeView({
|
|
|
20283
20208
|
if (previewMode) {
|
|
20284
20209
|
return emptyReferencePickResult;
|
|
20285
20210
|
}
|
|
20286
|
-
if (!workspaceFileReferenceAdapter && !
|
|
20211
|
+
if (!workspaceFileReferenceAdapter && !referenceSourceAggregator || !workspaceFileReferenceCopy) {
|
|
20287
20212
|
return emptyReferencePickResult;
|
|
20288
20213
|
}
|
|
20289
|
-
const target = entity &&
|
|
20214
|
+
const target = entity && referenceSourceAggregator ? resolveMentionReferenceTarget?.(entity) ?? null : referenceSourceAggregator ? resolveWorkspaceReferenceInitialTarget?.({
|
|
20290
20215
|
activeConversation: viewModel.activeConversation,
|
|
20291
20216
|
composerSelectedProjectPath: viewModel.composerSettings.selectedProjectPath ?? null,
|
|
20292
20217
|
userProjects: viewModel.userProjects
|
|
@@ -20300,7 +20225,7 @@ function AgentGUINodeView({
|
|
|
20300
20225
|
[
|
|
20301
20226
|
emptyReferencePickResult,
|
|
20302
20227
|
previewMode,
|
|
20303
|
-
|
|
20228
|
+
referenceSourceAggregator,
|
|
20304
20229
|
resolveMentionReferenceTarget,
|
|
20305
20230
|
resolveWorkspaceReferenceInitialTarget,
|
|
20306
20231
|
viewModel.activeConversation,
|
|
@@ -20329,57 +20254,13 @@ function AgentGUINodeView({
|
|
|
20329
20254
|
[onWorkspaceFileReferencesAdded]
|
|
20330
20255
|
);
|
|
20331
20256
|
const confirmWorkspaceReferencePicker = useCallback10(
|
|
20332
|
-
|
|
20333
|
-
const wantsHostFiles = refs.some(
|
|
20334
|
-
(ref) => ref.path === hostLocalFileActionPath
|
|
20335
|
-
);
|
|
20336
|
-
const hostSourceRefs = refs.filter(
|
|
20337
|
-
(ref) => ref.sourceId === hostLocalFileSourceId && ref.path !== hostLocalFileActionPath
|
|
20338
|
-
);
|
|
20339
|
-
const hostSourceFileRefs = hostSourceRefs.filter(
|
|
20340
|
-
(ref) => ref.kind === "file"
|
|
20341
|
-
);
|
|
20342
|
-
if (!wantsHostFiles && hostSourceRefs.length === 0) {
|
|
20343
|
-
settleReferencePicker(
|
|
20344
|
-
{ files: refs, mentionItems: [], hostAttachments: [] },
|
|
20345
|
-
refs
|
|
20346
|
-
);
|
|
20347
|
-
return;
|
|
20348
|
-
}
|
|
20349
|
-
const workspaceRefs = refs.filter(
|
|
20350
|
-
(ref) => ref.path !== hostLocalFileActionPath && ref.sourceId !== hostLocalFileSourceId
|
|
20351
|
-
);
|
|
20352
|
-
const selected = wantsHostFiles ? await agentHostApi.workspace.selectFiles({
|
|
20353
|
-
allowDirectories: false
|
|
20354
|
-
}) : [];
|
|
20355
|
-
const selectedHostAttachments = selected.map((file) => ({
|
|
20356
|
-
hostPath: file.path,
|
|
20357
|
-
name: file.name || file.path.split("/").pop() || file.path,
|
|
20358
|
-
mimeType: null
|
|
20359
|
-
}));
|
|
20360
|
-
const browsedHostAttachments = hostSourceFileRefs.map((file) => ({
|
|
20361
|
-
hostPath: file.path,
|
|
20362
|
-
name: file.displayName || file.path.split("/").pop() || file.path,
|
|
20363
|
-
mimeType: null
|
|
20364
|
-
}));
|
|
20257
|
+
(refs) => {
|
|
20365
20258
|
settleReferencePicker(
|
|
20366
|
-
{
|
|
20367
|
-
|
|
20368
|
-
mentionItems: [],
|
|
20369
|
-
hostAttachments: [
|
|
20370
|
-
...selectedHostAttachments,
|
|
20371
|
-
...browsedHostAttachments
|
|
20372
|
-
]
|
|
20373
|
-
},
|
|
20374
|
-
workspaceRefs
|
|
20259
|
+
{ files: refs, mentionItems: [], hostAttachments: [] },
|
|
20260
|
+
refs
|
|
20375
20261
|
);
|
|
20376
20262
|
},
|
|
20377
|
-
[
|
|
20378
|
-
agentHostApi.workspace,
|
|
20379
|
-
hostLocalFileActionPath,
|
|
20380
|
-
hostLocalFileSourceId,
|
|
20381
|
-
settleReferencePicker
|
|
20382
|
-
]
|
|
20263
|
+
[settleReferencePicker]
|
|
20383
20264
|
);
|
|
20384
20265
|
const confirmWorkspaceReferenceBundles = useCallback10(
|
|
20385
20266
|
(result) => {
|
|
@@ -20767,10 +20648,10 @@ function AgentGUINodeView({
|
|
|
20767
20648
|
]
|
|
20768
20649
|
}
|
|
20769
20650
|
),
|
|
20770
|
-
|
|
20651
|
+
referenceSourceAggregator ? /* @__PURE__ */ jsx29(
|
|
20771
20652
|
ReferenceSourcePicker,
|
|
20772
20653
|
{
|
|
20773
|
-
aggregator:
|
|
20654
|
+
aggregator: referenceSourceAggregator,
|
|
20774
20655
|
copy: workspaceFileReferenceCopy ?? fallbackWorkspaceFileReferenceCopy,
|
|
20775
20656
|
initialTarget: workspaceReferencePickerTarget,
|
|
20776
20657
|
isNodeSelectable: isWorkspaceReferencePickerNodeSelectable,
|