@isdk/tool-electron 1.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/README.cn.md +588 -0
- package/README.md +461 -0
- package/dist/index.d.mts +463 -0
- package/dist/index.d.ts +463 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/docs/README.md +465 -0
- package/docs/_media/README.cn.md +588 -0
- package/docs/classes/ElectronClientPubSubTransport.md +163 -0
- package/docs/classes/ElectronServerPubSubTransport.md +384 -0
- package/docs/classes/IpcClientToolTransport.md +416 -0
- package/docs/classes/IpcServerToolTransport.md +479 -0
- package/docs/globals.md +20 -0
- package/docs/type-aliases/Bridge.md +37 -0
- package/docs/type-aliases/Channels.md +27 -0
- package/docs/type-aliases/PubSubBridge.md +81 -0
- package/docs/type-aliases/ServerIpcMain.md +55 -0
- package/docs/type-aliases/ServerPubSubIpcMain.md +55 -0
- package/package.json +88 -0
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
[**@isdk/tool-electron**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@isdk/tool-electron](../globals.md) / IpcClientToolTransport
|
|
6
|
+
|
|
7
|
+
# Class: IpcClientToolTransport
|
|
8
|
+
|
|
9
|
+
Defined in: [tool-electron/src/ipc-client.ts:65](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-client.ts#L65)
|
|
10
|
+
|
|
11
|
+
Renderer-side RPC transport over Electron IPC.
|
|
12
|
+
|
|
13
|
+
## Param
|
|
14
|
+
|
|
15
|
+
URI in `electron://host` format; defaults to `IPCDefaultChannelName`
|
|
16
|
+
(see normalizeNamespace for URI extraction logic).
|
|
17
|
+
|
|
18
|
+
## Param
|
|
19
|
+
|
|
20
|
+
Optional config.
|
|
21
|
+
|
|
22
|
+
## Param
|
|
23
|
+
|
|
24
|
+
Injectable bridge object with `invoke` method.
|
|
25
|
+
When provided, used instead of directly importing `ipcRenderer`.
|
|
26
|
+
Required when `contextIsolation` is enabled.
|
|
27
|
+
|
|
28
|
+
## Extends
|
|
29
|
+
|
|
30
|
+
- `ClientToolTransport`
|
|
31
|
+
|
|
32
|
+
## Constructors
|
|
33
|
+
|
|
34
|
+
### Constructor
|
|
35
|
+
|
|
36
|
+
> **new IpcClientToolTransport**(`apiUrl?`, `options?`): `IpcClientToolTransport`
|
|
37
|
+
|
|
38
|
+
Defined in: [tool-electron/src/ipc-client.ts:69](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-client.ts#L69)
|
|
39
|
+
|
|
40
|
+
#### Parameters
|
|
41
|
+
|
|
42
|
+
##### apiUrl?
|
|
43
|
+
|
|
44
|
+
`string` = `IPCDefaultChannelName`
|
|
45
|
+
|
|
46
|
+
##### options?
|
|
47
|
+
|
|
48
|
+
`IpcClientToolTransportOptions`
|
|
49
|
+
|
|
50
|
+
#### Returns
|
|
51
|
+
|
|
52
|
+
`IpcClientToolTransport`
|
|
53
|
+
|
|
54
|
+
#### Overrides
|
|
55
|
+
|
|
56
|
+
`ClientToolTransport.constructor`
|
|
57
|
+
|
|
58
|
+
## Properties
|
|
59
|
+
|
|
60
|
+
### apiUrl
|
|
61
|
+
|
|
62
|
+
> **apiUrl**: `string`
|
|
63
|
+
|
|
64
|
+
Defined in: tool-rpc/dist/index-Bemsc4p1.d.ts:571
|
|
65
|
+
|
|
66
|
+
#### Inherited from
|
|
67
|
+
|
|
68
|
+
`ClientToolTransport.apiUrl`
|
|
69
|
+
|
|
70
|
+
***
|
|
71
|
+
|
|
72
|
+
### channels
|
|
73
|
+
|
|
74
|
+
> **channels**: [`Channels`](../type-aliases/Channels.md)
|
|
75
|
+
|
|
76
|
+
Defined in: [tool-electron/src/ipc-client.ts:66](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-client.ts#L66)
|
|
77
|
+
|
|
78
|
+
***
|
|
79
|
+
|
|
80
|
+
### manager
|
|
81
|
+
|
|
82
|
+
> **manager**: `RpcTransportManager`
|
|
83
|
+
|
|
84
|
+
Defined in: tool-rpc/dist/index-Bemsc4p1.d.ts:558
|
|
85
|
+
|
|
86
|
+
所属管理器引用
|
|
87
|
+
|
|
88
|
+
#### Inherited from
|
|
89
|
+
|
|
90
|
+
`ClientToolTransport.manager`
|
|
91
|
+
|
|
92
|
+
***
|
|
93
|
+
|
|
94
|
+
### options?
|
|
95
|
+
|
|
96
|
+
> `optional` **options?**: `ClientToolTransportOptions`
|
|
97
|
+
|
|
98
|
+
Defined in: tool-rpc/dist/index-Bemsc4p1.d.ts:572
|
|
99
|
+
|
|
100
|
+
#### Inherited from
|
|
101
|
+
|
|
102
|
+
`ClientToolTransport.options`
|
|
103
|
+
|
|
104
|
+
## Accessors
|
|
105
|
+
|
|
106
|
+
### apiRoot
|
|
107
|
+
|
|
108
|
+
#### Get Signature
|
|
109
|
+
|
|
110
|
+
> **get** **apiRoot**(): `string`
|
|
111
|
+
|
|
112
|
+
Defined in: tool-rpc/dist/index-Bemsc4p1.d.ts:575
|
|
113
|
+
|
|
114
|
+
##### Deprecated
|
|
115
|
+
|
|
116
|
+
use apiUrl instead
|
|
117
|
+
|
|
118
|
+
##### Returns
|
|
119
|
+
|
|
120
|
+
`string`
|
|
121
|
+
|
|
122
|
+
#### Set Signature
|
|
123
|
+
|
|
124
|
+
> **set** **apiRoot**(`val`): `void`
|
|
125
|
+
|
|
126
|
+
Defined in: tool-rpc/dist/index-Bemsc4p1.d.ts:577
|
|
127
|
+
|
|
128
|
+
##### Deprecated
|
|
129
|
+
|
|
130
|
+
use apiUrl instead
|
|
131
|
+
|
|
132
|
+
##### Parameters
|
|
133
|
+
|
|
134
|
+
###### val
|
|
135
|
+
|
|
136
|
+
`string`
|
|
137
|
+
|
|
138
|
+
##### Returns
|
|
139
|
+
|
|
140
|
+
`void`
|
|
141
|
+
|
|
142
|
+
#### Inherited from
|
|
143
|
+
|
|
144
|
+
`ClientToolTransport.apiRoot`
|
|
145
|
+
|
|
146
|
+
## Methods
|
|
147
|
+
|
|
148
|
+
### \_fetch()
|
|
149
|
+
|
|
150
|
+
> **\_fetch**(`name`, `args?`, `act?`, `subName?`, `_fetchOptions?`): `Promise`\<`any`\>
|
|
151
|
+
|
|
152
|
+
Defined in: [tool-electron/src/ipc-client.ts:136](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-client.ts#L136)
|
|
153
|
+
|
|
154
|
+
Call a remote tool via IPC.
|
|
155
|
+
Sends an RPC request on the `{namespace}:rpc` channel and returns the result.
|
|
156
|
+
Server errors (`{ __error__: true, error: ... }`) are automatically re-thrown as `CommonError`.
|
|
157
|
+
|
|
158
|
+
#### Parameters
|
|
159
|
+
|
|
160
|
+
##### name
|
|
161
|
+
|
|
162
|
+
`string`
|
|
163
|
+
|
|
164
|
+
Tool name (becomes `toolId` in the IPC payload).
|
|
165
|
+
|
|
166
|
+
##### args?
|
|
167
|
+
|
|
168
|
+
`any`
|
|
169
|
+
|
|
170
|
+
Parameters to pass to the tool.
|
|
171
|
+
|
|
172
|
+
##### act?
|
|
173
|
+
|
|
174
|
+
`string`
|
|
175
|
+
|
|
176
|
+
Optional action name for REST-style sub-resources.
|
|
177
|
+
|
|
178
|
+
##### subName?
|
|
179
|
+
|
|
180
|
+
`any`
|
|
181
|
+
|
|
182
|
+
Optional sub-resource identifier.
|
|
183
|
+
|
|
184
|
+
##### \_fetchOptions?
|
|
185
|
+
|
|
186
|
+
`any`
|
|
187
|
+
|
|
188
|
+
Optional fetch options (e.g., `{ signal: AbortSignal }` for cancellation).
|
|
189
|
+
|
|
190
|
+
#### Returns
|
|
191
|
+
|
|
192
|
+
`Promise`\<`any`\>
|
|
193
|
+
|
|
194
|
+
The tool's return value.
|
|
195
|
+
|
|
196
|
+
#### Throws
|
|
197
|
+
|
|
198
|
+
If the server returns an error response.
|
|
199
|
+
|
|
200
|
+
#### Throws
|
|
201
|
+
|
|
202
|
+
If the request is cancelled via `AbortSignal`.
|
|
203
|
+
|
|
204
|
+
#### Overrides
|
|
205
|
+
|
|
206
|
+
`ClientToolTransport._fetch`
|
|
207
|
+
|
|
208
|
+
***
|
|
209
|
+
|
|
210
|
+
### fetch()
|
|
211
|
+
|
|
212
|
+
> **fetch**(`name`, `args?`, `act?`, `subName?`, `fetchOptions?`, `toolTimeout?`): `Promise`\<`any`\>
|
|
213
|
+
|
|
214
|
+
Defined in: tool-rpc/dist/index-Bemsc4p1.d.ts:584
|
|
215
|
+
|
|
216
|
+
#### Parameters
|
|
217
|
+
|
|
218
|
+
##### name
|
|
219
|
+
|
|
220
|
+
`string`
|
|
221
|
+
|
|
222
|
+
##### args?
|
|
223
|
+
|
|
224
|
+
`any`
|
|
225
|
+
|
|
226
|
+
##### act?
|
|
227
|
+
|
|
228
|
+
`string`
|
|
229
|
+
|
|
230
|
+
##### subName?
|
|
231
|
+
|
|
232
|
+
`any`
|
|
233
|
+
|
|
234
|
+
##### fetchOptions?
|
|
235
|
+
|
|
236
|
+
`any`
|
|
237
|
+
|
|
238
|
+
##### toolTimeout?
|
|
239
|
+
|
|
240
|
+
`any`
|
|
241
|
+
|
|
242
|
+
#### Returns
|
|
243
|
+
|
|
244
|
+
`Promise`\<`any`\>
|
|
245
|
+
|
|
246
|
+
#### Inherited from
|
|
247
|
+
|
|
248
|
+
`ClientToolTransport.fetch`
|
|
249
|
+
|
|
250
|
+
***
|
|
251
|
+
|
|
252
|
+
### loadApis()
|
|
253
|
+
|
|
254
|
+
> **loadApis**(): `Promise`\<`Funcs`\>
|
|
255
|
+
|
|
256
|
+
Defined in: [tool-electron/src/ipc-client.ts:113](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-client.ts#L113)
|
|
257
|
+
|
|
258
|
+
Load available tool definitions from the server via IPC.
|
|
259
|
+
Invokes the `{namespace}:discover` channel to fetch the tool manifest.
|
|
260
|
+
|
|
261
|
+
#### Returns
|
|
262
|
+
|
|
263
|
+
`Promise`\<`Funcs`\>
|
|
264
|
+
|
|
265
|
+
A promise resolving to the tool function definitions.
|
|
266
|
+
|
|
267
|
+
#### Throws
|
|
268
|
+
|
|
269
|
+
If `apiUrl` has not been set (channels not initialized).
|
|
270
|
+
|
|
271
|
+
#### Overrides
|
|
272
|
+
|
|
273
|
+
`ClientToolTransport.loadApis`
|
|
274
|
+
|
|
275
|
+
***
|
|
276
|
+
|
|
277
|
+
### mount()
|
|
278
|
+
|
|
279
|
+
> **mount**(`toolsClass`): `void`
|
|
280
|
+
|
|
281
|
+
Defined in: [tool-electron/src/ipc-client.ts:78](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-client.ts#L78)
|
|
282
|
+
|
|
283
|
+
Mount the transport to a tools class and register with RpcTransportManager.
|
|
284
|
+
|
|
285
|
+
#### Parameters
|
|
286
|
+
|
|
287
|
+
##### toolsClass
|
|
288
|
+
|
|
289
|
+
`any`
|
|
290
|
+
|
|
291
|
+
The client tools class to mount (e.g., `ClientTools`).
|
|
292
|
+
|
|
293
|
+
#### Returns
|
|
294
|
+
|
|
295
|
+
`void`
|
|
296
|
+
|
|
297
|
+
#### Overrides
|
|
298
|
+
|
|
299
|
+
`ClientToolTransport.mount`
|
|
300
|
+
|
|
301
|
+
***
|
|
302
|
+
|
|
303
|
+
### pollTaskStatus()
|
|
304
|
+
|
|
305
|
+
> **pollTaskStatus**(`taskId`, `parentFetchOptions?`): `Promise`\<`any`\>
|
|
306
|
+
|
|
307
|
+
Defined in: tool-rpc/dist/index-Bemsc4p1.d.ts:592
|
|
308
|
+
|
|
309
|
+
模块化复用的轮询探查接口
|
|
310
|
+
|
|
311
|
+
#### Parameters
|
|
312
|
+
|
|
313
|
+
##### taskId
|
|
314
|
+
|
|
315
|
+
`string`
|
|
316
|
+
|
|
317
|
+
##### parentFetchOptions?
|
|
318
|
+
|
|
319
|
+
`any`
|
|
320
|
+
|
|
321
|
+
#### Returns
|
|
322
|
+
|
|
323
|
+
`Promise`\<`any`\>
|
|
324
|
+
|
|
325
|
+
#### Inherited from
|
|
326
|
+
|
|
327
|
+
`ClientToolTransport.pollTaskStatus`
|
|
328
|
+
|
|
329
|
+
***
|
|
330
|
+
|
|
331
|
+
### ~~setApiRoot()~~
|
|
332
|
+
|
|
333
|
+
> **setApiRoot**(`apiRoot`): `void`
|
|
334
|
+
|
|
335
|
+
Defined in: [tool-electron/src/ipc-client.ts:103](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-client.ts#L103)
|
|
336
|
+
|
|
337
|
+
#### Parameters
|
|
338
|
+
|
|
339
|
+
##### apiRoot
|
|
340
|
+
|
|
341
|
+
`string`
|
|
342
|
+
|
|
343
|
+
#### Returns
|
|
344
|
+
|
|
345
|
+
`void`
|
|
346
|
+
|
|
347
|
+
#### Deprecated
|
|
348
|
+
|
|
349
|
+
Use [setApiUrl](#setapiurl) instead
|
|
350
|
+
|
|
351
|
+
***
|
|
352
|
+
|
|
353
|
+
### setApiUrl()
|
|
354
|
+
|
|
355
|
+
> **setApiUrl**(`apiUrl`): `void`
|
|
356
|
+
|
|
357
|
+
Defined in: [tool-electron/src/ipc-client.ts:92](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-client.ts#L92)
|
|
358
|
+
|
|
359
|
+
Set the API URL and derive IPC channel names.
|
|
360
|
+
|
|
361
|
+
#### Parameters
|
|
362
|
+
|
|
363
|
+
##### apiUrl
|
|
364
|
+
|
|
365
|
+
`string`
|
|
366
|
+
|
|
367
|
+
URI in `electron://host` format (e.g., `'electron://my-app'`).
|
|
368
|
+
The host is extracted as the namespace for channel generation:
|
|
369
|
+
`electron://my-app` → channels `my-app:discover`, `my-app:rpc`.
|
|
370
|
+
|
|
371
|
+
#### Returns
|
|
372
|
+
|
|
373
|
+
`void`
|
|
374
|
+
|
|
375
|
+
#### Overrides
|
|
376
|
+
|
|
377
|
+
`ClientToolTransport.setApiUrl`
|
|
378
|
+
|
|
379
|
+
***
|
|
380
|
+
|
|
381
|
+
### ~~toObject()~~
|
|
382
|
+
|
|
383
|
+
> **toObject**(`res`): `Promise`\<`any`\>
|
|
384
|
+
|
|
385
|
+
Defined in: [tool-electron/src/ipc-client.ts:210](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-client.ts#L210)
|
|
386
|
+
|
|
387
|
+
Convert an IPC response to a plain object.
|
|
388
|
+
If the response contains a server error (`{ __error__: true }`),
|
|
389
|
+
it is re-thrown as a `CommonError`.
|
|
390
|
+
Otherwise, the response is passed through as-is.
|
|
391
|
+
|
|
392
|
+
#### Parameters
|
|
393
|
+
|
|
394
|
+
##### res
|
|
395
|
+
|
|
396
|
+
`any`
|
|
397
|
+
|
|
398
|
+
The raw response from the IPC channel.
|
|
399
|
+
|
|
400
|
+
#### Returns
|
|
401
|
+
|
|
402
|
+
`Promise`\<`any`\>
|
|
403
|
+
|
|
404
|
+
The deserialized result.
|
|
405
|
+
|
|
406
|
+
#### Throws
|
|
407
|
+
|
|
408
|
+
If the response indicates a server error.
|
|
409
|
+
|
|
410
|
+
#### Deprecated
|
|
411
|
+
|
|
412
|
+
Use `_fetch` directly, which throws `CommonError` automatically.
|
|
413
|
+
|
|
414
|
+
#### Overrides
|
|
415
|
+
|
|
416
|
+
`ClientToolTransport.toObject`
|