@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.
@@ -0,0 +1,479 @@
1
+ [**@isdk/tool-electron**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/tool-electron](../globals.md) / IpcServerToolTransport
6
+
7
+ # Class: IpcServerToolTransport
8
+
9
+ Defined in: [tool-electron/src/ipc-server.ts:44](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-server.ts#L44)
10
+
11
+ Main-process RPC transport over Electron IPC.
12
+
13
+ Registers `ipcMain.handle` listeners for tool discovery and RPC calls.
14
+ Supports injectable `ipcMain` bridge for testing or custom setups.
15
+
16
+ ## Extends
17
+
18
+ - `ServerToolTransport`
19
+
20
+ ## Constructors
21
+
22
+ ### Constructor
23
+
24
+ > **new IpcServerToolTransport**(`options?`): `IpcServerToolTransport`
25
+
26
+ Defined in: [tool-electron/src/ipc-server.ts:60](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-server.ts#L60)
27
+
28
+ Creates an IPC server transport.
29
+
30
+ #### Parameters
31
+
32
+ ##### options?
33
+
34
+ ###### apiUrl?
35
+
36
+ `string`
37
+
38
+ URI in `electron://host` format (e.g., `'electron://my-app'`).
39
+ The host is extracted as the namespace for IPC channel generation:
40
+ `electron://my-app` → channels `my-app:discover`, `my-app:rpc`.
41
+ Defaults to IPCDefaultChannelName (`'electron://ai-tool'`).
42
+
43
+ ###### dispatcher?
44
+
45
+ `RpcServerDispatcher`
46
+
47
+ Optional RpcServerDispatcher for v2.6 dispatch pattern.
48
+
49
+ ###### ipcMain?
50
+
51
+ [`ServerIpcMain`](../type-aliases/ServerIpcMain.md)
52
+
53
+ Optional custom ipcMain bridge (with `handle` and `removeHandler` methods).
54
+ When provided, used instead of the direct `electron` import.
55
+ Useful for testing or custom main-process IPC setups.
56
+
57
+ #### Returns
58
+
59
+ `IpcServerToolTransport`
60
+
61
+ #### Overrides
62
+
63
+ `ServerToolTransport.constructor`
64
+
65
+ ## Properties
66
+
67
+ ### apiUrl
68
+
69
+ > **apiUrl**: `string`
70
+
71
+ Defined in: tool-rpc/dist/index-Bemsc4p1.d.ts:418
72
+
73
+ #### Inherited from
74
+
75
+ `ServerToolTransport.apiUrl`
76
+
77
+ ***
78
+
79
+ ### canStream
80
+
81
+ > **canStream**: `boolean`
82
+
83
+ Defined in: tool-rpc/dist/index-Bemsc4p1.d.ts:421
84
+
85
+ 是否支持原生的流式传输 (如 HTTP 支持, Mailbox 通常不支持)
86
+
87
+ #### Inherited from
88
+
89
+ `ServerToolTransport.canStream`
90
+
91
+ ***
92
+
93
+ ### dispatcher
94
+
95
+ > **dispatcher**: `RpcServerDispatcher`
96
+
97
+ Defined in: tool-rpc/dist/index-Bemsc4p1.d.ts:420
98
+
99
+ #### Inherited from
100
+
101
+ `ServerToolTransport.dispatcher`
102
+
103
+ ***
104
+
105
+ ### manager
106
+
107
+ > **manager**: `RpcTransportManager`
108
+
109
+ Defined in: tool-rpc/dist/index-Bemsc4p1.d.ts:558
110
+
111
+ 所属管理器引用
112
+
113
+ #### Inherited from
114
+
115
+ `ServerToolTransport.manager`
116
+
117
+ ***
118
+
119
+ ### options?
120
+
121
+ > `optional` **options?**: `ServerToolTransportOptions`
122
+
123
+ Defined in: tool-rpc/dist/index-Bemsc4p1.d.ts:419
124
+
125
+ #### Inherited from
126
+
127
+ `ServerToolTransport.options`
128
+
129
+ ## Methods
130
+
131
+ ### \_start()
132
+
133
+ > **\_start**(): `Promise`\<`void`\>
134
+
135
+ Defined in: [tool-electron/src/ipc-server.ts:222](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-server.ts#L222)
136
+
137
+ Start the transport (marks as started).
138
+ IPC handlers are already registered via `addRpcHandler`/`addDiscoveryHandler`,
139
+ so this method primarily serves as a lifecycle flag.
140
+
141
+ #### Returns
142
+
143
+ `Promise`\<`void`\>
144
+
145
+ #### Overrides
146
+
147
+ `ServerToolTransport._start`
148
+
149
+ ***
150
+
151
+ ### addDiscoveryHandler()
152
+
153
+ > **addDiscoveryHandler**(`apiPrefix`, `handler`): `void`
154
+
155
+ Defined in: [tool-electron/src/ipc-server.ts:101](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-server.ts#L101)
156
+
157
+ Register an IPC handler for tool discovery.
158
+ Listens on the `{namespace}:discover` channel and returns the tool manifest.
159
+ Automatically removes any previous handler for the same channel to prevent duplicates.
160
+
161
+ #### Parameters
162
+
163
+ ##### apiPrefix
164
+
165
+ `string`
166
+
167
+ URI or namespace for the IPC channel (e.g., `'electron://my-app'`).
168
+
169
+ ##### handler
170
+
171
+ () => `any`
172
+
173
+ Function returning the tool definitions.
174
+ If the return value has a `toJSON()` method, it is called for serialization.
175
+
176
+ #### Returns
177
+
178
+ `void`
179
+
180
+ #### Overrides
181
+
182
+ `ServerToolTransport.addDiscoveryHandler`
183
+
184
+ ***
185
+
186
+ ### addRpcHandler()
187
+
188
+ > **addRpcHandler**(`apiPrefix`, `options?`): `void`
189
+
190
+ Defined in: [tool-electron/src/ipc-server.ts:125](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-server.ts#L125)
191
+
192
+ Register an IPC handler for RPC calls.
193
+ Listens on the `{namespace}:rpc` channel and routes incoming requests
194
+ to the appropriate tool handler. In v2.6, uses the dispatcher for routing
195
+ when available; falls back to direct tool lookup for backward compatibility.
196
+
197
+ #### Parameters
198
+
199
+ ##### apiPrefix
200
+
201
+ `string`
202
+
203
+ URI or namespace for the IPC channel (e.g., `'electron://my-app'`).
204
+
205
+ ##### options?
206
+
207
+ Optional config.
208
+
209
+ ###### registry?
210
+
211
+ `any`
212
+
213
+ A Tools class (with static `.get()`) or a map-like registry
214
+ (with `.get()` method). Defaults to `ServerTools`.
215
+
216
+ ###### tools?
217
+
218
+ `any`
219
+
220
+ Alias for `options.registry`. If both are provided, `tools` takes precedence.
221
+
222
+ #### Returns
223
+
224
+ `void`
225
+
226
+ #### Overrides
227
+
228
+ `ServerToolTransport.addRpcHandler`
229
+
230
+ ***
231
+
232
+ ### getListenAddr()
233
+
234
+ > **getListenAddr**(): `string`
235
+
236
+ Defined in: [tool-electron/src/ipc-server.ts:252](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-server.ts#L252)
237
+
238
+ Get the listen address (URI) for this transport.
239
+ Returns the `apiUrl` in `electron://` format (e.g., `'electron://my-app'`),
240
+ or the default `IPCDefaultChannelName` if not set.
241
+
242
+ #### Returns
243
+
244
+ `string`
245
+
246
+ #### Overrides
247
+
248
+ `ServerToolTransport.getListenAddr`
249
+
250
+ ***
251
+
252
+ ### getRaw()
253
+
254
+ > **getRaw**(): `object`
255
+
256
+ Defined in: [tool-electron/src/ipc-server.ts:243](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-server.ts#L243)
257
+
258
+ Get the raw IPC main object and channel names.
259
+ Useful for testing and introspection.
260
+
261
+ #### Returns
262
+
263
+ `object`
264
+
265
+ ##### channels
266
+
267
+ > **channels**: [`Channels`](../type-aliases/Channels.md)
268
+
269
+ ##### ipcMain
270
+
271
+ > **ipcMain**: [`ServerIpcMain`](../type-aliases/ServerIpcMain.md)
272
+
273
+ #### Overrides
274
+
275
+ `ServerToolTransport.getRaw`
276
+
277
+ ***
278
+
279
+ ### getRoutes()
280
+
281
+ > **getRoutes**(): `string`[]
282
+
283
+ Defined in: [tool-electron/src/ipc-server.ts:260](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-server.ts#L260)
284
+
285
+ Get the routes exposed by this transport.
286
+ IPC transports expose a single root route `['/']`.
287
+
288
+ #### Returns
289
+
290
+ `string`[]
291
+
292
+ #### Overrides
293
+
294
+ `ServerToolTransport.getRoutes`
295
+
296
+ ***
297
+
298
+ ### processIncomingCall()
299
+
300
+ > `protected` **processIncomingCall**(`rawReq`, `rawRes`, `registry?`): `Promise`\<`void`\>
301
+
302
+ Defined in: tool-rpc/dist/index-Bemsc4p1.d.ts:430
303
+
304
+ Template Method:处理物理请求流水线。
305
+ 下层具体协议收到请求后,将其转化为内部结构,送入 Dispatcher 并写回。
306
+
307
+ #### Parameters
308
+
309
+ ##### rawReq
310
+
311
+ `any`
312
+
313
+ ##### rawRes
314
+
315
+ `any`
316
+
317
+ ##### registry?
318
+
319
+ `any`
320
+
321
+ #### Returns
322
+
323
+ `Promise`\<`void`\>
324
+
325
+ #### Inherited from
326
+
327
+ `ServerToolTransport.processIncomingCall`
328
+
329
+ ***
330
+
331
+ ### sendRpcResponse()
332
+
333
+ > `protected` **sendRpcResponse**(`rpcRes`, `rawRes`): `Promise`\<`void`\>
334
+
335
+ Defined in: [tool-electron/src/ipc-server.ts:202](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-server.ts#L202)
336
+
337
+ #### Parameters
338
+
339
+ ##### rpcRes
340
+
341
+ `ToolRpcResponse`
342
+
343
+ ##### rawRes
344
+
345
+ `any`
346
+
347
+ #### Returns
348
+
349
+ `Promise`\<`void`\>
350
+
351
+ #### Overrides
352
+
353
+ `ServerToolTransport.sendRpcResponse`
354
+
355
+ ***
356
+
357
+ ### ~~setApiRoot()~~
358
+
359
+ > **setApiRoot**(`apiRoot`): `void`
360
+
361
+ Defined in: [tool-electron/src/ipc-server.ts:80](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-server.ts#L80)
362
+
363
+ #### Parameters
364
+
365
+ ##### apiRoot
366
+
367
+ `string`
368
+
369
+ #### Returns
370
+
371
+ `void`
372
+
373
+ #### Deprecated
374
+
375
+ Use setApiUrl instead
376
+
377
+ ***
378
+
379
+ ### setApiUrl()
380
+
381
+ > **setApiUrl**(`apiUrl`): `void`
382
+
383
+ Defined in: [tool-electron/src/ipc-server.ts:74](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-server.ts#L74)
384
+
385
+ Set the API URL and derive IPC channel names.
386
+
387
+ #### Parameters
388
+
389
+ ##### apiUrl
390
+
391
+ `string`
392
+
393
+ URI in `electron://host` format (e.g., `'electron://my-app'`).
394
+ The host is extracted as the namespace for channel generation:
395
+ `electron://my-app` → channels `my-app:discover`, `my-app:rpc`.
396
+
397
+ #### Returns
398
+
399
+ `void`
400
+
401
+ #### Overrides
402
+
403
+ `ServerToolTransport.setApiUrl`
404
+
405
+ ***
406
+
407
+ ### start()
408
+
409
+ > **start**(`options?`): `Promise`\<`any`\>
410
+
411
+ Defined in: tool-rpc/dist/index-Bemsc4p1.d.ts:425
412
+
413
+ 启动物理监听
414
+
415
+ #### Parameters
416
+
417
+ ##### options?
418
+
419
+ `any`
420
+
421
+ #### Returns
422
+
423
+ `Promise`\<`any`\>
424
+
425
+ #### Inherited from
426
+
427
+ `ServerToolTransport.start`
428
+
429
+ ***
430
+
431
+ ### stop()
432
+
433
+ > **stop**(`force?`): `Promise`\<`void`\>
434
+
435
+ Defined in: [tool-electron/src/ipc-server.ts:230](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-server.ts#L230)
436
+
437
+ Stop the transport and remove IPC handlers.
438
+
439
+ #### Parameters
440
+
441
+ ##### force?
442
+
443
+ `boolean`
444
+
445
+ If `true`, skip the `started` check and always stop.
446
+
447
+ #### Returns
448
+
449
+ `Promise`\<`void`\>
450
+
451
+ #### Overrides
452
+
453
+ `ServerToolTransport.stop`
454
+
455
+ ***
456
+
457
+ ### toRpcRequest()
458
+
459
+ > `protected` **toRpcRequest**(`rawReq`, `rawRes?`): `Promise`\<`ToolRpcRequest`\>
460
+
461
+ Defined in: [tool-electron/src/ipc-server.ts:183](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/ipc-server.ts#L183)
462
+
463
+ #### Parameters
464
+
465
+ ##### rawReq
466
+
467
+ `any`
468
+
469
+ ##### rawRes?
470
+
471
+ `any`
472
+
473
+ #### Returns
474
+
475
+ `Promise`\<`ToolRpcRequest`\>
476
+
477
+ #### Overrides
478
+
479
+ `ServerToolTransport.toRpcRequest`
@@ -0,0 +1,20 @@
1
+ [**@isdk/tool-electron**](README.md)
2
+
3
+ ***
4
+
5
+ # @isdk/tool-electron
6
+
7
+ ## Classes
8
+
9
+ - [ElectronClientPubSubTransport](classes/ElectronClientPubSubTransport.md)
10
+ - [ElectronServerPubSubTransport](classes/ElectronServerPubSubTransport.md)
11
+ - [IpcClientToolTransport](classes/IpcClientToolTransport.md)
12
+ - [IpcServerToolTransport](classes/IpcServerToolTransport.md)
13
+
14
+ ## Type Aliases
15
+
16
+ - [Bridge](type-aliases/Bridge.md)
17
+ - [Channels](type-aliases/Channels.md)
18
+ - [PubSubBridge](type-aliases/PubSubBridge.md)
19
+ - [ServerIpcMain](type-aliases/ServerIpcMain.md)
20
+ - [ServerPubSubIpcMain](type-aliases/ServerPubSubIpcMain.md)
@@ -0,0 +1,37 @@
1
+ [**@isdk/tool-electron**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/tool-electron](../globals.md) / Bridge
6
+
7
+ # Type Alias: Bridge
8
+
9
+ > **Bridge** = `object`
10
+
11
+ Defined in: [tool-electron/src/types.ts:20](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/types.ts#L20)
12
+
13
+ Renderer-side RPC bridge.
14
+ Injected into import('./ipc-client').IpcClientToolTransport
15
+ to call `ipcRenderer.invoke` via `contextBridge` instead of importing `electron` directly.
16
+
17
+ ## Properties
18
+
19
+ ### invoke
20
+
21
+ > **invoke**: (`channel`, ...`args`) => `Promise`\<`any`\>
22
+
23
+ Defined in: [tool-electron/src/types.ts:21](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/types.ts#L21)
24
+
25
+ #### Parameters
26
+
27
+ ##### channel
28
+
29
+ `string`
30
+
31
+ ##### args
32
+
33
+ ...`any`[]
34
+
35
+ #### Returns
36
+
37
+ `Promise`\<`any`\>
@@ -0,0 +1,27 @@
1
+ [**@isdk/tool-electron**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/tool-electron](../globals.md) / Channels
6
+
7
+ # Type Alias: Channels
8
+
9
+ > **Channels** = `object`
10
+
11
+ Defined in: [tool-electron/src/types.ts:58](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/types.ts#L58)
12
+
13
+ ## Properties
14
+
15
+ ### discover
16
+
17
+ > **discover**: `string`
18
+
19
+ Defined in: [tool-electron/src/types.ts:59](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/types.ts#L59)
20
+
21
+ ***
22
+
23
+ ### rpc
24
+
25
+ > **rpc**: `string`
26
+
27
+ Defined in: [tool-electron/src/types.ts:60](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/types.ts#L60)
@@ -0,0 +1,81 @@
1
+ [**@isdk/tool-electron**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/tool-electron](../globals.md) / PubSubBridge
6
+
7
+ # Type Alias: PubSubBridge
8
+
9
+ > **PubSubBridge** = `object`
10
+
11
+ Defined in: [tool-electron/src/types.ts:41](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/types.ts#L41)
12
+
13
+ Renderer-side Pub/Sub bridge.
14
+ Injected into import('./pubsub/electron-client').ElectronClientPubSubTransport
15
+ to listen, remove listeners, and send IPC messages for the event bus.
16
+
17
+ ## Methods
18
+
19
+ ### off()
20
+
21
+ > **off**(`channel`, `listener`): `void`
22
+
23
+ Defined in: [tool-electron/src/types.ts:43](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/types.ts#L43)
24
+
25
+ #### Parameters
26
+
27
+ ##### channel
28
+
29
+ `string`
30
+
31
+ ##### listener
32
+
33
+ (`event`, ...`args`) => `void`
34
+
35
+ #### Returns
36
+
37
+ `void`
38
+
39
+ ***
40
+
41
+ ### on()
42
+
43
+ > **on**(`channel`, `listener`): `void`
44
+
45
+ Defined in: [tool-electron/src/types.ts:42](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/types.ts#L42)
46
+
47
+ #### Parameters
48
+
49
+ ##### channel
50
+
51
+ `string`
52
+
53
+ ##### listener
54
+
55
+ (`event`, ...`args`) => `void`
56
+
57
+ #### Returns
58
+
59
+ `void`
60
+
61
+ ***
62
+
63
+ ### send()
64
+
65
+ > **send**(`channel`, ...`args`): `void`
66
+
67
+ Defined in: [tool-electron/src/types.ts:44](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/types.ts#L44)
68
+
69
+ #### Parameters
70
+
71
+ ##### channel
72
+
73
+ `string`
74
+
75
+ ##### args
76
+
77
+ ...`any`[]
78
+
79
+ #### Returns
80
+
81
+ `void`
@@ -0,0 +1,55 @@
1
+ [**@isdk/tool-electron**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/tool-electron](../globals.md) / ServerIpcMain
6
+
7
+ # Type Alias: ServerIpcMain
8
+
9
+ > **ServerIpcMain** = `object`
10
+
11
+ Defined in: [tool-electron/src/types.ts:30](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/types.ts#L30)
12
+
13
+ Main-side RPC bridge.
14
+ Injected into import('./ipc-server').IpcServerToolTransport
15
+ to register `ipcMain.handle` handlers via a custom object (e.g. mock).
16
+
17
+ ## Methods
18
+
19
+ ### handle()
20
+
21
+ > **handle**(`channel`, `handler`): `void`
22
+
23
+ Defined in: [tool-electron/src/types.ts:31](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/types.ts#L31)
24
+
25
+ #### Parameters
26
+
27
+ ##### channel
28
+
29
+ `string`
30
+
31
+ ##### handler
32
+
33
+ (`event`, ...`args`) => `any`
34
+
35
+ #### Returns
36
+
37
+ `void`
38
+
39
+ ***
40
+
41
+ ### removeHandler()
42
+
43
+ > **removeHandler**(`channel`): `void`
44
+
45
+ Defined in: [tool-electron/src/types.ts:32](https://github.com/isdk/ai-tool-electron.js/blob/7342c9cf7d483faaa9613fa3cacb08c7e4c19c6f/src/types.ts#L32)
46
+
47
+ #### Parameters
48
+
49
+ ##### channel
50
+
51
+ `string`
52
+
53
+ #### Returns
54
+
55
+ `void`