@lvce-editor/test-worker 14.21.0 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.d.ts CHANGED
@@ -86,6 +86,34 @@ export interface DroppedFileHandle {
86
86
  readonly id: number;
87
87
  }
88
88
 
89
+ export interface ToolCallItemBase<TArguments, TName extends string> {
90
+ readonly toolCall: {
91
+ readonly arguments: TArguments;
92
+ readonly name: TName;
93
+ };
94
+ }
95
+
96
+ export interface ToolCallItemReadFileArgs {
97
+ readonly uri: string;
98
+ }
99
+
100
+ export interface ToolCallItemWriteFileArgs {
101
+ readonly content: string;
102
+ readonly uri: string;
103
+ }
104
+
105
+ export interface ToolCallItemSearchFilesArgs {
106
+ readonly query: string;
107
+ }
108
+
109
+ export interface ToolCallItemTextSearchArgs {
110
+ readonly query: string;
111
+ }
112
+
113
+ export interface TextItem {
114
+ readonly text: string;
115
+ }
116
+
89
117
  export interface MockErrorResponse {
90
118
  readonly code: string;
91
119
  readonly error: string;
@@ -101,17 +129,6 @@ export interface MockOpenAiResponseOptions {
101
129
  readonly value: any;
102
130
  }
103
131
 
104
- export interface ToolCallItem {
105
- readonly toolCall: {
106
- readonly arguments: any;
107
- readonly name: "list_files";
108
- };
109
- }
110
-
111
- export interface TextItem {
112
- readonly text: string;
113
- }
114
-
115
132
  export interface ChatDebugEvent {
116
133
  readonly [key: string]: unknown;
117
134
  }
@@ -145,6 +162,11 @@ export interface Dirent {
145
162
  readonly type: number;
146
163
  }
147
164
 
165
+ export interface GitInvocation {
166
+ readonly command: readonly string[];
167
+ readonly cwd: string;
168
+ }
169
+
148
170
  export interface LayoutExpectation extends LayoutExpectationObject {
149
171
  readonly activeGroupIndex?: number;
150
172
  readonly direction?: LayoutDirection;
@@ -156,6 +178,20 @@ export interface SelectItem2Options {
156
178
  readonly label: string;
157
179
  }
158
180
 
181
+ export type EmptyObject = Record<string, never>;
182
+
183
+ export type ToolCallItemGetWorkspaceUri = ToolCallItemBase<EmptyObject, "getWorkspaceUri">;
184
+
185
+ export type ToolCallItemReadFile = ToolCallItemBase<ToolCallItemReadFileArgs, "read_file">;
186
+
187
+ export type ToolCallItemWriteFile = ToolCallItemBase<ToolCallItemWriteFileArgs, "write_file">;
188
+
189
+ export type ToolCallItemSearchFiles = ToolCallItemBase<ToolCallItemSearchFilesArgs, "search_files">;
190
+
191
+ export type ToolCallItemTextSearch = ToolCallItemBase<ToolCallItemTextSearchArgs, "text_search">;
192
+
193
+ export type ToolCallItem = ToolCallItemGetWorkspaceUri | ToolCallItemReadFile | ToolCallItemWriteFile | ToolCallItemSearchFiles | ToolCallItemTextSearch;
194
+
159
195
  export type MockRequestInput = ToolCallItem | TextItem;
160
196
 
161
197
  export type ChatDebugInputName = "closeDetails" | "eventCategoryFilter" | "filter" | "showEventStreamFinishedEvents" | "showInputEvents" | "showResponsePartEvents" | "timelineRangePreset" | "useDevtoolsLayout";
@@ -601,6 +637,7 @@ interface FileSystem {
601
637
  readonly readFile: (uri: string) => Promise<string>;
602
638
  readonly remove: (uri: string) => Promise<void>;
603
639
  readonly setFiles: (files: readonly FileItem[]) => Promise<void>;
640
+ readonly shouldHaveFolder: (uri: string) => Promise<void>;
604
641
  readonly writeFile: (uri: string, content: string) => Promise<void>;
605
642
  readonly writeJson: (uri: string, data: any) => Promise<void>;
606
643
  }
@@ -623,6 +660,22 @@ interface FindWidget {
623
660
  readonly toggleUseRegularExpression: () => Promise<void>;
624
661
  }
625
662
 
663
+ interface Git {
664
+ readonly add: (pathSpec: string) => Promise<void>;
665
+ readonly addRemote: (name: string, remoteUrl: string) => Promise<void>;
666
+ readonly branch: (name: string) => Promise<void>;
667
+ readonly checkout: (ref: string) => Promise<void>;
668
+ readonly clone: (repositoryUrl: string, cwd: string) => Promise<void>;
669
+ readonly commit: (message: string) => Promise<void>;
670
+ readonly fetch: (remote: string) => Promise<void>;
671
+ readonly init: () => Promise<void>;
672
+ readonly pull: (remote: string, branch: string) => Promise<void>;
673
+ readonly push: (remote: string, branch: string) => Promise<void>;
674
+ readonly setConfig: (key: string, value: string) => Promise<void>;
675
+ readonly shouldHaveInvocations: (invocations: readonly GitInvocation[]) => Promise<void>;
676
+ readonly status: () => Promise<unknown>;
677
+ }
678
+
626
679
  interface IconTheme {
627
680
  readonly setIconTheme: (id: string) => Promise<void>;
628
681
  }
@@ -932,6 +985,7 @@ export interface TestApi {
932
985
  readonly ExtensionSearch: ExtensionSearch
933
986
  readonly FileSystem: FileSystem
934
987
  readonly FindWidget: FindWidget
988
+ readonly Git: Git
935
989
  readonly IconTheme: IconTheme
936
990
  readonly IframeInspector: IframeInspector
937
991
  readonly KeyBindingsEditor: KeyBindingsEditor
@@ -1091,7 +1091,7 @@ const createMockRpc = ({
1091
1091
  };
1092
1092
 
1093
1093
  const rpcs = Object.create(null);
1094
- const set$6 = (id, rpc) => {
1094
+ const set$7 = (id, rpc) => {
1095
1095
  rpcs[id] = rpc;
1096
1096
  };
1097
1097
  const get$2 = id => {
@@ -1124,7 +1124,7 @@ const create = rpcId => {
1124
1124
  const mockRpc = createMockRpc({
1125
1125
  commandMap
1126
1126
  });
1127
- set$6(rpcId, mockRpc);
1127
+ set$7(rpcId, mockRpc);
1128
1128
  // @ts-ignore
1129
1129
  mockRpc[Symbol.dispose] = () => {
1130
1130
  remove$1(rpcId);
@@ -1133,7 +1133,7 @@ const create = rpcId => {
1133
1133
  return mockRpc;
1134
1134
  },
1135
1135
  set(rpc) {
1136
- set$6(rpcId, rpc);
1136
+ set$7(rpcId, rpc);
1137
1137
  }
1138
1138
  };
1139
1139
  };
@@ -1146,6 +1146,7 @@ const Web = 1;
1146
1146
  const Remote = 3;
1147
1147
 
1148
1148
  const EditorWorker = 99;
1149
+ const ExtensionHostWorker = 44;
1149
1150
  const ExtensionManagementWorker = 9006;
1150
1151
  const OpenerWorker = 4561;
1151
1152
  const RendererWorker = 1;
@@ -1153,9 +1154,13 @@ const TestWorker = 9001;
1153
1154
 
1154
1155
  const {
1155
1156
  invoke: invoke$3,
1156
- set: set$5
1157
+ set: set$6
1157
1158
  } = create(EditorWorker);
1158
1159
 
1160
+ const {
1161
+ set: set$5
1162
+ } = create(ExtensionHostWorker);
1163
+
1159
1164
  const {
1160
1165
  invoke: invoke$2,
1161
1166
  set: set$4
@@ -1182,6 +1187,10 @@ const sendMessagePortToOpenerWorker = async (port, rpcId) => {
1182
1187
  const readFile$1 = async uri => {
1183
1188
  return invoke('FileSystem.readFile', uri);
1184
1189
  };
1190
+ const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
1191
+ const command = 'HandleMessagePort.handleMessagePort2';
1192
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1193
+ };
1185
1194
  const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
1186
1195
  const command = 'Extensions.handleMessagePort';
1187
1196
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
@@ -1190,10 +1199,21 @@ const getPreference = async key => {
1190
1199
  return await invoke('Preferences.get', key);
1191
1200
  };
1192
1201
 
1193
- const send$2 = async port => {
1202
+ const send$3 = async port => {
1194
1203
  await sendMessagePortToEditorWorker(port, TestWorker);
1195
1204
  };
1196
1205
  const initializeEditorWorker = async () => {
1206
+ const rpc = await create$3({
1207
+ commandMap: {},
1208
+ send: send$3
1209
+ });
1210
+ set$6(rpc);
1211
+ };
1212
+
1213
+ const send$2 = async port => {
1214
+ await sendMessagePortToExtensionHostWorker(port, TestWorker);
1215
+ };
1216
+ const initializeExtensionHostWorker = async () => {
1197
1217
  const rpc = await create$3({
1198
1218
  commandMap: {},
1199
1219
  send: send$2
@@ -3751,13 +3771,44 @@ const setFiles = async files => {
3751
3771
  const readDir = async uri => {
3752
3772
  return invoke('FileSystem.readDirWithFileTypes', uri);
3753
3773
  };
3774
+ const getParentUri = uri => {
3775
+ const url = new URL(uri);
3776
+ const pathSegments = url.pathname.split('/').filter(Boolean);
3777
+ pathSegments.pop();
3778
+ url.pathname = pathSegments.length === 0 ? '/' : `/${pathSegments.join('/')}`;
3779
+ return url.toString();
3780
+ };
3781
+ const getBaseName = uri => {
3782
+ const url = new URL(uri);
3783
+ const pathSegments = url.pathname.split('/').filter(Boolean);
3784
+ return pathSegments.at(-1) || '';
3785
+ };
3786
+ const shouldHaveFolder = async uri => {
3787
+ const parentUri = getParentUri(uri);
3788
+ const folderName = getBaseName(uri);
3789
+ const dirents = await readDir(parentUri);
3790
+ const matchingDirent = dirents.find(dirent => dirent.name === folderName);
3791
+ if (!matchingDirent) {
3792
+ throw new AssertionError(`expected filesystem to have folder "${uri}" but it was not found`);
3793
+ }
3794
+ if (matchingDirent.type !== Directory) {
3795
+ throw new AssertionError(`expected filesystem entry "${uri}" to be a folder but it was type ${matchingDirent.type}`);
3796
+ }
3797
+ };
3754
3798
  const remove = async uri => {
3755
3799
  await invoke('FileSystem.remove', uri);
3756
3800
  };
3801
+ const getTmpDirFileScheme = async () => {
3802
+ const tmpFolder = await invoke('PlatformPaths.getTmpDir');
3803
+ const tmpUri = tmpFolder.startsWith('file://') ? tmpFolder : `file://${tmpFolder}`;
3804
+ return `${tmpUri}/test-${Date.now()}`;
3805
+ };
3757
3806
  const getTmpDir = async ({
3758
3807
  scheme = Memfs
3759
3808
  } = {}) => {
3760
3809
  switch (scheme) {
3810
+ case 'file':
3811
+ return getTmpDirFileScheme();
3761
3812
  case Memfs:
3762
3813
  return 'memfs:///workspace';
3763
3814
  default:
@@ -3823,6 +3874,7 @@ const FileSystem = {
3823
3874
  readFile,
3824
3875
  remove,
3825
3876
  setFiles,
3877
+ shouldHaveFolder,
3826
3878
  writeFile,
3827
3879
  writeJson
3828
3880
  };
@@ -3891,6 +3943,63 @@ const FindWidget = {
3891
3943
  toggleUseRegularExpression: toggleUseRegularExpression$1
3892
3944
  };
3893
3945
 
3946
+ const init = async () => {
3947
+ // await RendererWorker.invoke('ExtensionHostManagement.activateByEvent', 'onSourceControl:')
3948
+ await invoke('ExtensionHost.executeCommand', 'git.init');
3949
+ };
3950
+ const clone = async (repositoryUrl, cwd) => {
3951
+ await invoke('ExtensionHost.executeCommand', 'Git.clone', repositoryUrl, cwd);
3952
+ };
3953
+ const add = async pathSpec => {
3954
+ await invoke('ExtensionHost.executeCommand', 'Git.add', pathSpec);
3955
+ };
3956
+ const commit = async message => {
3957
+ await invoke('ExtensionHost.executeCommand', 'Git.commit', message);
3958
+ };
3959
+ const push$1 = async (remote, branch) => {
3960
+ await invoke('ExtensionHost.executeCommand', 'Git.push', remote, branch);
3961
+ };
3962
+ const pull = async (remote, branch) => {
3963
+ await invoke('ExtensionHost.executeCommand', 'Git.pull', remote, branch);
3964
+ };
3965
+ const fetch$1 = async remote => {
3966
+ await invoke('ExtensionHost.executeCommand', 'Git.fetch', remote);
3967
+ };
3968
+ const checkout = async ref => {
3969
+ await invoke('ExtensionHost.executeCommand', 'Git.checkout', ref);
3970
+ };
3971
+ const branch = async name => {
3972
+ await invoke('ExtensionHost.executeCommand', 'Git.branch', name);
3973
+ };
3974
+ const status = async () => {
3975
+ return invoke('ExtensionHost.executeCommand', 'Git.status');
3976
+ };
3977
+ const addRemote = async (name, remoteUrl) => {
3978
+ await invoke('ExtensionHost.executeCommand', 'Git.addRemote', name, remoteUrl);
3979
+ };
3980
+ const setConfig = async (key, value) => {
3981
+ await invoke('ExtensionHost.executeCommand', 'Git.setConfig', key, value);
3982
+ };
3983
+ const shouldHaveInvocations = async invocations => {
3984
+ // TODO
3985
+ };
3986
+
3987
+ const Git = {
3988
+ add,
3989
+ addRemote,
3990
+ branch,
3991
+ checkout,
3992
+ clone,
3993
+ commit,
3994
+ fetch: fetch$1,
3995
+ init,
3996
+ pull,
3997
+ push: push$1,
3998
+ setConfig,
3999
+ shouldHaveInvocations,
4000
+ status
4001
+ };
4002
+
3894
4003
  const setIconTheme = async id => {
3895
4004
  await invoke('IconTheme.setIconTheme', id);
3896
4005
  };
@@ -4933,6 +5042,7 @@ const createApi = (platform, assetDir) => {
4933
5042
  FindWidget,
4934
5043
  getTmpDir: getTmpDir$1,
4935
5044
  // TODO maybe deprecate this or move to file system
5045
+ Git,
4936
5046
  IconTheme,
4937
5047
  IframeInspector,
4938
5048
  KeyBindingsEditor,
@@ -5607,7 +5717,7 @@ const initializeRendererWorker = async () => {
5607
5717
  };
5608
5718
 
5609
5719
  const listen = async () => {
5610
- await Promise.all([initializeRendererWorker(), initializeEditorWorker(), initializeOpenerWorker(), initializeExtensionManagementWorker()]);
5720
+ await Promise.all([initializeRendererWorker(), initializeEditorWorker(), initializeOpenerWorker(), initializeExtensionManagementWorker(), initializeExtensionHostWorker()]);
5611
5721
  };
5612
5722
 
5613
5723
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "14.21.0",
3
+ "version": "15.0.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",