@ryuhq/sdk 0.1.14 → 0.2.2
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.md +69 -7
- package/dist/action.cjs +839 -0
- package/dist/action.d.cts +88 -0
- package/dist/action.d.ts +88 -0
- package/dist/action.js +8 -0
- package/dist/agent-plugin.cjs +46 -0
- package/dist/agent-plugin.d.cts +43 -33
- package/dist/agent-plugin.d.ts +43 -33
- package/dist/agent-plugin.js +1 -1
- package/dist/agent.cjs +16 -0
- package/dist/agent.d.cts +377 -1
- package/dist/agent.d.ts +377 -1
- package/dist/agent.js +4 -2
- package/dist/app-B0Z9Ew_R.d.cts +141 -0
- package/dist/app-C-BDJwfG.d.ts +141 -0
- package/dist/builder.cjs +1194 -0
- package/dist/builder.d.cts +217 -0
- package/dist/builder.d.ts +217 -0
- package/dist/builder.js +29 -0
- package/dist/chunk-4TPUZDTI.js +94 -0
- package/dist/chunk-BC3A7HMO.js +164 -0
- package/dist/chunk-FZSFZOIN.js +200 -0
- package/dist/{chunk-ODFEUVPW.js → chunk-HACAGK65.js} +1 -18
- package/dist/chunk-HLKJZAFK.js +361 -0
- package/dist/chunk-IKEDLLFY.js +19 -0
- package/dist/{chunk-G6FLVEC4.js → chunk-JX6DDRXV.js} +46 -0
- package/dist/{chunk-AO2KJRDD.js → chunk-NZKVOSC2.js} +192 -3
- package/dist/chunk-QYFUNJOH.js +83 -0
- package/dist/chunk-SN2QBJUF.js +148 -0
- package/dist/chunk-TLDPEGC7.js +21 -0
- package/dist/chunk-TXSHHZF2.js +0 -0
- package/dist/chunk-VLIRNNAE.js +154 -0
- package/dist/{chunk-MTUBUPIV.js → chunk-Z57QDDJR.js} +8 -227
- package/dist/chunk-ZTJWBRUL.js +282 -0
- package/dist/cli.cjs +347 -18
- package/dist/cli.js +128 -23
- package/dist/client-D5U6ssPc.d.cts +84 -0
- package/dist/client-D5U6ssPc.d.ts +84 -0
- package/dist/index.cjs +810 -86
- package/dist/index.d.cts +19 -634
- package/dist/index.d.ts +19 -634
- package/dist/index.js +82 -699
- package/dist/manifest.cjs +200 -4
- package/dist/manifest.d.cts +260 -5
- package/dist/manifest.d.ts +260 -5
- package/dist/manifest.js +15 -1
- package/dist/mcp/client.cjs +180 -0
- package/dist/mcp/client.d.cts +49 -0
- package/dist/mcp/client.d.ts +49 -0
- package/dist/mcp/client.js +10 -0
- package/dist/mcp/server.cjs +370 -0
- package/dist/mcp/server.d.cts +127 -0
- package/dist/mcp/server.d.ts +127 -0
- package/dist/mcp/server.js +9 -0
- package/dist/mcp.cjs +376 -0
- package/dist/mcp.d.cts +2 -0
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.js +17 -0
- package/dist/model.cjs +141 -0
- package/dist/model.d.cts +33 -0
- package/dist/model.d.ts +33 -0
- package/dist/model.js +18 -0
- package/dist/plugin.cjs +46 -0
- package/dist/plugin.d.cts +215 -0
- package/dist/plugin.d.ts +215 -0
- package/dist/plugin.js +8 -0
- package/dist/runnable.cjs +1438 -0
- package/dist/runnable.d.cts +274 -0
- package/dist/runnable.d.ts +274 -0
- package/dist/runnable.js +34 -0
- package/dist/{index-B6SkaAjJ.d.ts → tool-AjkdFvhE.d.ts} +88 -461
- package/dist/{index-BvAB5eMk.d.cts → tool-CgzW92O_.d.cts} +88 -461
- package/package.json +48 -3
- package/src/agent/loop.test.ts +4 -4
- package/src/agent/tools.ts +3 -3
- package/src/agent-plugin.test.ts +58 -0
- package/src/agent-plugin.ts +109 -36
- package/src/builder.ts +9 -0
- package/src/cli/dev.test.ts +26 -47
- package/src/cli/dev.ts +10 -2
- package/src/cli-security.test.ts +109 -0
- package/src/cli.ts +141 -25
- package/src/contracts-lockstep.test.ts +16 -2
- package/src/exports-lockstep.test.ts +93 -0
- package/src/generated/plugin-manifest.ts +322 -29
- package/src/index.ts +53 -0
- package/src/manifest-schema.test.ts +30 -1
- package/src/manifest.fixtures.test.ts +22 -6
- package/src/manifest.test.ts +165 -10
- package/src/manifest.ts +454 -188
- package/src/mcp/index.ts +18 -0
- package/src/mcp/server.ts +2 -1
- package/src/model/index.ts +22 -0
- package/src/plugin/ryu-plugin.ts +82 -0
- package/src/runnable/action.test.ts +128 -0
- package/src/runnable/action.ts +202 -0
- package/src/runnable/app.test.ts +2 -0
- package/src/runnable/app.ts +50 -14
- package/src/runnable/index.ts +20 -3
- package/src/runnable/primitives.test.ts +34 -0
- package/src/runnable/primitives.ts +116 -0
- package/src/runnable/runnable-types.ts +3 -0
- package/src/runnable/tool.ts +36 -5
- package/src/runnable/turn-hook.ts +8 -3
- package/src/slash-command.test.ts +69 -0
package/dist/manifest.d.ts
CHANGED
|
@@ -182,6 +182,23 @@ declare const WidgetContributionSchema: z.ZodObject<{
|
|
|
182
182
|
default_display_mode: z.ZodDefault<z.ZodString>;
|
|
183
183
|
}, z.core.$strip>;
|
|
184
184
|
type WidgetContribution = z.infer<typeof WidgetContributionSchema>;
|
|
185
|
+
/** Metadata-only chat affordance. The host owns rendering and dispatch; the
|
|
186
|
+
* manifest carries identifiers and copy only. */
|
|
187
|
+
declare const ChatWidgetTemplateSchema: z.ZodObject<{
|
|
188
|
+
id: z.ZodString;
|
|
189
|
+
title: z.ZodString;
|
|
190
|
+
description: z.ZodOptional<z.ZodString>;
|
|
191
|
+
triggers: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
192
|
+
examples: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
193
|
+
backing: z.ZodObject<{
|
|
194
|
+
tool_id: z.ZodOptional<z.ZodString>;
|
|
195
|
+
view_id: z.ZodOptional<z.ZodString>;
|
|
196
|
+
}, z.core.$strip>;
|
|
197
|
+
display_mode: z.ZodString;
|
|
198
|
+
safe_action_ids: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
199
|
+
availability: z.ZodDefault<z.ZodString>;
|
|
200
|
+
}, z.core.$strip>;
|
|
201
|
+
type ChatWidgetTemplate = z.infer<typeof ChatWidgetTemplateSchema>;
|
|
185
202
|
/**
|
|
186
203
|
* The `config` blob carried by a Ryu App's `kind:"tool"` runnable. Core's strict
|
|
187
204
|
* `ToolConfig` (`apps/core/src/plugin_manifest/schema.rs`) requires `slug` and
|
|
@@ -200,10 +217,80 @@ declare const ToolAppConfigSchema: z.ZodObject<{
|
|
|
200
217
|
invoked: z.ZodOptional<z.ZodString>;
|
|
201
218
|
}, z.core.$strip>;
|
|
202
219
|
type ToolAppConfig = z.infer<typeof ToolAppConfigSchema>;
|
|
220
|
+
/** One selectable value for a plugin/app slash-command argument. */
|
|
221
|
+
declare const SlashCommandOptionSchema: z.ZodObject<{
|
|
222
|
+
description: z.ZodOptional<z.ZodString>;
|
|
223
|
+
label: z.ZodString;
|
|
224
|
+
value: z.ZodString;
|
|
225
|
+
}, z.core.$loose>;
|
|
226
|
+
type SlashCommandOption = z.infer<typeof SlashCommandOptionSchema>;
|
|
227
|
+
/** A registered free-form option shown alongside an argument's choices. */
|
|
228
|
+
declare const SlashCommandCustomOptionSchema: z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
|
|
229
|
+
description: z.ZodOptional<z.ZodString>;
|
|
230
|
+
label: z.ZodOptional<z.ZodString>;
|
|
231
|
+
}, z.core.$loose>]>;
|
|
232
|
+
type SlashCommandCustomOption = z.infer<typeof SlashCommandCustomOptionSchema>;
|
|
233
|
+
/** One sequential argument in a plugin/app slash command. */
|
|
234
|
+
declare const SlashCommandArgumentSchema: z.ZodObject<{
|
|
235
|
+
allow_custom: z.ZodOptional<z.ZodBoolean>;
|
|
236
|
+
custom: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
|
|
237
|
+
description: z.ZodOptional<z.ZodString>;
|
|
238
|
+
label: z.ZodOptional<z.ZodString>;
|
|
239
|
+
}, z.core.$loose>]>>;
|
|
240
|
+
description: z.ZodOptional<z.ZodString>;
|
|
241
|
+
name: z.ZodString;
|
|
242
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
243
|
+
description: z.ZodOptional<z.ZodString>;
|
|
244
|
+
label: z.ZodString;
|
|
245
|
+
value: z.ZodString;
|
|
246
|
+
}, z.core.$loose>>>;
|
|
247
|
+
}, z.core.$loose>;
|
|
248
|
+
type SlashCommandArgument = z.infer<typeof SlashCommandArgumentSchema>;
|
|
249
|
+
/**
|
|
250
|
+
* A command registered by a plugin or Ryu App. `args` is the preferred key;
|
|
251
|
+
* `parameters` is accepted as a readable alias for hand-authored manifests.
|
|
252
|
+
* Each argument's options are plugin-owned, so the shell never needs a closed
|
|
253
|
+
* enum for app-specific values.
|
|
254
|
+
*/
|
|
255
|
+
declare const SlashCommandContributionSchema: z.ZodObject<{
|
|
256
|
+
args: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
257
|
+
allow_custom: z.ZodOptional<z.ZodBoolean>;
|
|
258
|
+
custom: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
|
|
259
|
+
description: z.ZodOptional<z.ZodString>;
|
|
260
|
+
label: z.ZodOptional<z.ZodString>;
|
|
261
|
+
}, z.core.$loose>]>>;
|
|
262
|
+
description: z.ZodOptional<z.ZodString>;
|
|
263
|
+
name: z.ZodString;
|
|
264
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
265
|
+
description: z.ZodOptional<z.ZodString>;
|
|
266
|
+
label: z.ZodString;
|
|
267
|
+
value: z.ZodString;
|
|
268
|
+
}, z.core.$loose>>>;
|
|
269
|
+
}, z.core.$loose>>>;
|
|
270
|
+
body: z.ZodOptional<z.ZodString>;
|
|
271
|
+
command: z.ZodString;
|
|
272
|
+
description: z.ZodOptional<z.ZodString>;
|
|
273
|
+
id: z.ZodOptional<z.ZodString>;
|
|
274
|
+
parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
275
|
+
allow_custom: z.ZodOptional<z.ZodBoolean>;
|
|
276
|
+
custom: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
|
|
277
|
+
description: z.ZodOptional<z.ZodString>;
|
|
278
|
+
label: z.ZodOptional<z.ZodString>;
|
|
279
|
+
}, z.core.$loose>]>>;
|
|
280
|
+
description: z.ZodOptional<z.ZodString>;
|
|
281
|
+
name: z.ZodString;
|
|
282
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
283
|
+
description: z.ZodOptional<z.ZodString>;
|
|
284
|
+
label: z.ZodString;
|
|
285
|
+
value: z.ZodString;
|
|
286
|
+
}, z.core.$loose>>>;
|
|
287
|
+
}, z.core.$loose>>>;
|
|
288
|
+
}, z.core.$loose>;
|
|
289
|
+
type SlashCommandContribution = z.infer<typeof SlashCommandContributionSchema>;
|
|
203
290
|
/**
|
|
204
291
|
* The `contributes` block. Mirrors `Contributes` in
|
|
205
292
|
* `apps/core/src/plugin_manifest/mod.rs`. The declarative UI surfaces
|
|
206
|
-
* (`composer_controls` / `
|
|
293
|
+
* (`composer_controls` / `chat_features` / `settings_tabs`) are passed verbatim
|
|
207
294
|
* to the desktop renderer, so they are typed loosely here (records).
|
|
208
295
|
*/
|
|
209
296
|
declare const ContributesSchema: z.ZodObject<{
|
|
@@ -226,8 +313,42 @@ declare const ContributesSchema: z.ZodObject<{
|
|
|
226
313
|
payload_example: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
227
314
|
}, z.core.$strip>>>;
|
|
228
315
|
composer_controls: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
316
|
+
chat_features: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
229
317
|
settings_tabs: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
230
|
-
slash_commands: z.ZodDefault<z.ZodArray<z.
|
|
318
|
+
slash_commands: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
319
|
+
args: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
320
|
+
allow_custom: z.ZodOptional<z.ZodBoolean>;
|
|
321
|
+
custom: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
|
|
322
|
+
description: z.ZodOptional<z.ZodString>;
|
|
323
|
+
label: z.ZodOptional<z.ZodString>;
|
|
324
|
+
}, z.core.$loose>]>>;
|
|
325
|
+
description: z.ZodOptional<z.ZodString>;
|
|
326
|
+
name: z.ZodString;
|
|
327
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
328
|
+
description: z.ZodOptional<z.ZodString>;
|
|
329
|
+
label: z.ZodString;
|
|
330
|
+
value: z.ZodString;
|
|
331
|
+
}, z.core.$loose>>>;
|
|
332
|
+
}, z.core.$loose>>>;
|
|
333
|
+
body: z.ZodOptional<z.ZodString>;
|
|
334
|
+
command: z.ZodString;
|
|
335
|
+
description: z.ZodOptional<z.ZodString>;
|
|
336
|
+
id: z.ZodOptional<z.ZodString>;
|
|
337
|
+
parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
338
|
+
allow_custom: z.ZodOptional<z.ZodBoolean>;
|
|
339
|
+
custom: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
|
|
340
|
+
description: z.ZodOptional<z.ZodString>;
|
|
341
|
+
label: z.ZodOptional<z.ZodString>;
|
|
342
|
+
}, z.core.$loose>]>>;
|
|
343
|
+
description: z.ZodOptional<z.ZodString>;
|
|
344
|
+
name: z.ZodString;
|
|
345
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
346
|
+
description: z.ZodOptional<z.ZodString>;
|
|
347
|
+
label: z.ZodString;
|
|
348
|
+
value: z.ZodString;
|
|
349
|
+
}, z.core.$loose>>>;
|
|
350
|
+
}, z.core.$loose>>>;
|
|
351
|
+
}, z.core.$loose>>>;
|
|
231
352
|
widgets: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
232
353
|
tool_id: z.ZodString;
|
|
233
354
|
uri: z.ZodString;
|
|
@@ -235,9 +356,24 @@ declare const ContributesSchema: z.ZodObject<{
|
|
|
235
356
|
mime: z.ZodDefault<z.ZodString>;
|
|
236
357
|
default_display_mode: z.ZodDefault<z.ZodString>;
|
|
237
358
|
}, z.core.$strip>>>;
|
|
359
|
+
chat_widget_templates: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
360
|
+
id: z.ZodString;
|
|
361
|
+
title: z.ZodString;
|
|
362
|
+
description: z.ZodOptional<z.ZodString>;
|
|
363
|
+
triggers: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
364
|
+
examples: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
365
|
+
backing: z.ZodObject<{
|
|
366
|
+
tool_id: z.ZodOptional<z.ZodString>;
|
|
367
|
+
view_id: z.ZodOptional<z.ZodString>;
|
|
368
|
+
}, z.core.$strip>;
|
|
369
|
+
display_mode: z.ZodString;
|
|
370
|
+
safe_action_ids: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
371
|
+
availability: z.ZodDefault<z.ZodString>;
|
|
372
|
+
}, z.core.$strip>>>;
|
|
238
373
|
sidebar_sections: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
239
374
|
sidebar_buttons: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
240
375
|
dock_panels: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
376
|
+
live_activities: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
241
377
|
data_categories: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
242
378
|
lsp_servers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
243
379
|
pi_extensions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
@@ -250,6 +386,8 @@ declare const ContributesSchema: z.ZodObject<{
|
|
|
250
386
|
file: z.ZodOptional<z.ZodString>;
|
|
251
387
|
source: z.ZodOptional<z.ZodString>;
|
|
252
388
|
}, z.core.$strip>>>;
|
|
389
|
+
message_actions: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
390
|
+
selection_actions: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
253
391
|
}, z.core.$strip>;
|
|
254
392
|
type Contributes = z.infer<typeof ContributesSchema>;
|
|
255
393
|
/**
|
|
@@ -359,6 +497,33 @@ declare const EnginesReqSchema: z.ZodObject<{
|
|
|
359
497
|
web: z.ZodOptional<z.ZodString>;
|
|
360
498
|
}, z.core.$strip>;
|
|
361
499
|
type EnginesReq = z.infer<typeof EnginesReqSchema>;
|
|
500
|
+
declare const McpServerAuthSchema: z.ZodObject<{
|
|
501
|
+
client_id: z.ZodOptional<z.ZodString>;
|
|
502
|
+
type: z.ZodLiteral<"oauth">;
|
|
503
|
+
}, z.core.$strict>;
|
|
504
|
+
declare const McpServerDeclSchema: z.ZodObject<{
|
|
505
|
+
args: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
506
|
+
auth: z.ZodOptional<z.ZodObject<{
|
|
507
|
+
client_id: z.ZodOptional<z.ZodString>;
|
|
508
|
+
type: z.ZodLiteral<"oauth">;
|
|
509
|
+
}, z.core.$strict>>;
|
|
510
|
+
command: z.ZodOptional<z.ZodString>;
|
|
511
|
+
command_env: z.ZodOptional<z.ZodString>;
|
|
512
|
+
description: z.ZodOptional<z.ZodString>;
|
|
513
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
514
|
+
env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
515
|
+
headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
516
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
517
|
+
stdio: "stdio";
|
|
518
|
+
http: "http";
|
|
519
|
+
"streamable-http": "streamable-http";
|
|
520
|
+
streamable_http: "streamable_http";
|
|
521
|
+
sse: "sse";
|
|
522
|
+
}>>;
|
|
523
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
524
|
+
}, z.core.$strip>;
|
|
525
|
+
type McpServerAuth = z.infer<typeof McpServerAuthSchema>;
|
|
526
|
+
type McpServerDecl = z.infer<typeof McpServerDeclSchema>;
|
|
362
527
|
/**
|
|
363
528
|
* Full schema for a `manifest.json` Plugin manifest. Mirrors `PluginManifest` in
|
|
364
529
|
* `apps/core/src/plugin_manifest/mod.rs`.
|
|
@@ -373,6 +538,7 @@ declare const PluginManifestSchema: z.ZodObject<{
|
|
|
373
538
|
id: z.ZodString;
|
|
374
539
|
name: z.ZodString;
|
|
375
540
|
version: z.ZodString;
|
|
541
|
+
stability: z.ZodOptional<z.ZodUnknown>;
|
|
376
542
|
ui_code_sha256: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
377
543
|
runnables: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
378
544
|
id: z.ZodString;
|
|
@@ -387,6 +553,39 @@ declare const PluginManifestSchema: z.ZodObject<{
|
|
|
387
553
|
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
388
554
|
}, z.core.$strip>>>;
|
|
389
555
|
permission_grants: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
556
|
+
permissions: z.ZodOptional<z.ZodObject<{
|
|
557
|
+
fs: z.ZodOptional<z.ZodObject<{
|
|
558
|
+
read: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
559
|
+
write: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
560
|
+
}, z.core.$strip>>;
|
|
561
|
+
child_process: z.ZodOptional<z.ZodBoolean>;
|
|
562
|
+
run: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
563
|
+
network: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
|
|
564
|
+
tool: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
565
|
+
}, z.core.$strip>>;
|
|
566
|
+
permission_levels: z.ZodOptional<z.ZodUnknown>;
|
|
567
|
+
mcp_servers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
568
|
+
args: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
569
|
+
auth: z.ZodOptional<z.ZodObject<{
|
|
570
|
+
client_id: z.ZodOptional<z.ZodString>;
|
|
571
|
+
type: z.ZodLiteral<"oauth">;
|
|
572
|
+
}, z.core.$strict>>;
|
|
573
|
+
command: z.ZodOptional<z.ZodString>;
|
|
574
|
+
command_env: z.ZodOptional<z.ZodString>;
|
|
575
|
+
description: z.ZodOptional<z.ZodString>;
|
|
576
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
577
|
+
env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
578
|
+
headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
579
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
580
|
+
stdio: "stdio";
|
|
581
|
+
http: "http";
|
|
582
|
+
"streamable-http": "streamable-http";
|
|
583
|
+
streamable_http: "streamable_http";
|
|
584
|
+
sse: "sse";
|
|
585
|
+
}>>;
|
|
586
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
587
|
+
}, z.core.$strip>>>;
|
|
588
|
+
sidecars: z.ZodOptional<z.ZodUnknown>;
|
|
390
589
|
companion: z.ZodOptional<z.ZodObject<{
|
|
391
590
|
label: z.ZodString;
|
|
392
591
|
icon: z.ZodOptional<z.ZodString>;
|
|
@@ -413,8 +612,42 @@ declare const PluginManifestSchema: z.ZodObject<{
|
|
|
413
612
|
payload_example: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
414
613
|
}, z.core.$strip>>>;
|
|
415
614
|
composer_controls: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
615
|
+
chat_features: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
416
616
|
settings_tabs: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
417
|
-
slash_commands: z.ZodDefault<z.ZodArray<z.
|
|
617
|
+
slash_commands: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
618
|
+
args: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
619
|
+
allow_custom: z.ZodOptional<z.ZodBoolean>;
|
|
620
|
+
custom: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
|
|
621
|
+
description: z.ZodOptional<z.ZodString>;
|
|
622
|
+
label: z.ZodOptional<z.ZodString>;
|
|
623
|
+
}, z.core.$loose>]>>;
|
|
624
|
+
description: z.ZodOptional<z.ZodString>;
|
|
625
|
+
name: z.ZodString;
|
|
626
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
627
|
+
description: z.ZodOptional<z.ZodString>;
|
|
628
|
+
label: z.ZodString;
|
|
629
|
+
value: z.ZodString;
|
|
630
|
+
}, z.core.$loose>>>;
|
|
631
|
+
}, z.core.$loose>>>;
|
|
632
|
+
body: z.ZodOptional<z.ZodString>;
|
|
633
|
+
command: z.ZodString;
|
|
634
|
+
description: z.ZodOptional<z.ZodString>;
|
|
635
|
+
id: z.ZodOptional<z.ZodString>;
|
|
636
|
+
parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
637
|
+
allow_custom: z.ZodOptional<z.ZodBoolean>;
|
|
638
|
+
custom: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
|
|
639
|
+
description: z.ZodOptional<z.ZodString>;
|
|
640
|
+
label: z.ZodOptional<z.ZodString>;
|
|
641
|
+
}, z.core.$loose>]>>;
|
|
642
|
+
description: z.ZodOptional<z.ZodString>;
|
|
643
|
+
name: z.ZodString;
|
|
644
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
645
|
+
description: z.ZodOptional<z.ZodString>;
|
|
646
|
+
label: z.ZodString;
|
|
647
|
+
value: z.ZodString;
|
|
648
|
+
}, z.core.$loose>>>;
|
|
649
|
+
}, z.core.$loose>>>;
|
|
650
|
+
}, z.core.$loose>>>;
|
|
418
651
|
widgets: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
419
652
|
tool_id: z.ZodString;
|
|
420
653
|
uri: z.ZodString;
|
|
@@ -422,9 +655,24 @@ declare const PluginManifestSchema: z.ZodObject<{
|
|
|
422
655
|
mime: z.ZodDefault<z.ZodString>;
|
|
423
656
|
default_display_mode: z.ZodDefault<z.ZodString>;
|
|
424
657
|
}, z.core.$strip>>>;
|
|
658
|
+
chat_widget_templates: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
659
|
+
id: z.ZodString;
|
|
660
|
+
title: z.ZodString;
|
|
661
|
+
description: z.ZodOptional<z.ZodString>;
|
|
662
|
+
triggers: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
663
|
+
examples: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
664
|
+
backing: z.ZodObject<{
|
|
665
|
+
tool_id: z.ZodOptional<z.ZodString>;
|
|
666
|
+
view_id: z.ZodOptional<z.ZodString>;
|
|
667
|
+
}, z.core.$strip>;
|
|
668
|
+
display_mode: z.ZodString;
|
|
669
|
+
safe_action_ids: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
670
|
+
availability: z.ZodDefault<z.ZodString>;
|
|
671
|
+
}, z.core.$strip>>>;
|
|
425
672
|
sidebar_sections: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
426
673
|
sidebar_buttons: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
427
674
|
dock_panels: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
675
|
+
live_activities: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
428
676
|
data_categories: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
429
677
|
lsp_servers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
430
678
|
pi_extensions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
@@ -437,6 +685,8 @@ declare const PluginManifestSchema: z.ZodObject<{
|
|
|
437
685
|
file: z.ZodOptional<z.ZodString>;
|
|
438
686
|
source: z.ZodOptional<z.ZodString>;
|
|
439
687
|
}, z.core.$strip>>>;
|
|
688
|
+
message_actions: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
689
|
+
selection_actions: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
440
690
|
}, z.core.$strip>>;
|
|
441
691
|
requires: z.ZodOptional<z.ZodObject<{
|
|
442
692
|
apps: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
@@ -459,6 +709,7 @@ declare const PluginManifestSchema: z.ZodObject<{
|
|
|
459
709
|
web: "web";
|
|
460
710
|
cli: "cli";
|
|
461
711
|
}>>>;
|
|
712
|
+
surfaces: z.ZodOptional<z.ZodUnknown>;
|
|
462
713
|
engines: z.ZodOptional<z.ZodObject<{
|
|
463
714
|
cli: z.ZodOptional<z.ZodString>;
|
|
464
715
|
desktop: z.ZodOptional<z.ZodString>;
|
|
@@ -492,12 +743,16 @@ declare const PluginManifestSchema: z.ZodObject<{
|
|
|
492
743
|
email: z.ZodOptional<z.ZodString>;
|
|
493
744
|
url: z.ZodOptional<z.ZodString>;
|
|
494
745
|
}, z.core.$strip>]>>;
|
|
746
|
+
repository: z.ZodOptional<z.ZodString>;
|
|
747
|
+
external: z.ZodOptional<z.ZodBoolean>;
|
|
495
748
|
homepage: z.ZodOptional<z.ZodString>;
|
|
496
749
|
keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
750
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
497
751
|
category: z.ZodOptional<z.ZodString>;
|
|
498
752
|
license: z.ZodOptional<z.ZodString>;
|
|
499
753
|
iconUrl: z.ZodOptional<z.ZodString>;
|
|
500
754
|
icon: z.ZodOptional<z.ZodString>;
|
|
755
|
+
banner: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
501
756
|
iconDither: z.ZodOptional<z.ZodObject<{
|
|
502
757
|
from: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
503
758
|
to: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
@@ -524,7 +779,7 @@ declare const PluginManifestSchema: z.ZodObject<{
|
|
|
524
779
|
actionLabel: z.ZodOptional<z.ZodString>;
|
|
525
780
|
actionUrl: z.ZodOptional<z.ZodString>;
|
|
526
781
|
}, z.core.$strip>>]>>;
|
|
527
|
-
}, z.core.$
|
|
782
|
+
}, z.core.$loose>;
|
|
528
783
|
type PluginManifest = z.infer<typeof PluginManifestSchema>;
|
|
529
784
|
/**
|
|
530
785
|
* Validate a plugin id with Core's strict reverse-domain, path-traversal-safe
|
|
@@ -543,4 +798,4 @@ declare function validateManifestStrict(manifestJson: string): string;
|
|
|
543
798
|
*/
|
|
544
799
|
declare function coreManifestJsonSchema(): unknown;
|
|
545
800
|
|
|
546
|
-
export { type AppDependency, AppDependencySchema, type CapabilityReq, CapabilityReqSchema, type CompanionSurface, CompanionSurfaceSchema, type Contributes, ContributesSchema, type EnginesReq, EnginesReqSchema, type HookEventContribution, HookEventContributionSchema, type OutputStyleContribution, OutputStyleContributionSchema, type PiExtensionContribution, PiExtensionContributionSchema, type PluginManifest, PluginManifestSchema, type Requires, RequiresSchema, type RunnableKind, RunnableKindSchema, type RunnableMeta, RunnableMetaSchema, type SetupStep, SetupStepSchema, type Surface, SurfaceSchema, type ToolAppConfig, ToolAppConfigSchema, type TurnHookContribution, TurnHookContributionSchema, type WidgetContribution, WidgetContributionSchema, coreManifestJsonSchema, labelImpersonatesSystemChrome, validateManifestStrict, validatePluginId };
|
|
801
|
+
export { type AppDependency, AppDependencySchema, type CapabilityReq, CapabilityReqSchema, type ChatWidgetTemplate, ChatWidgetTemplateSchema, type CompanionSurface, CompanionSurfaceSchema, type Contributes, ContributesSchema, type EnginesReq, EnginesReqSchema, type HookEventContribution, HookEventContributionSchema, type McpServerAuth, McpServerAuthSchema, type McpServerDecl, McpServerDeclSchema, type OutputStyleContribution, OutputStyleContributionSchema, type PiExtensionContribution, PiExtensionContributionSchema, type PluginManifest, PluginManifestSchema, type Requires, RequiresSchema, type RunnableKind, RunnableKindSchema, type RunnableMeta, RunnableMetaSchema, type SetupStep, SetupStepSchema, type SlashCommandArgument, SlashCommandArgumentSchema, type SlashCommandContribution, SlashCommandContributionSchema, type SlashCommandCustomOption, SlashCommandCustomOptionSchema, type SlashCommandOption, SlashCommandOptionSchema, type Surface, SurfaceSchema, type ToolAppConfig, ToolAppConfigSchema, type TurnHookContribution, TurnHookContributionSchema, type WidgetContribution, WidgetContributionSchema, coreManifestJsonSchema, labelImpersonatesSystemChrome, validateManifestStrict, validatePluginId };
|
package/dist/manifest.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AppDependencySchema,
|
|
3
3
|
CapabilityReqSchema,
|
|
4
|
+
ChatWidgetTemplateSchema,
|
|
4
5
|
CompanionSurfaceSchema,
|
|
5
6
|
ContributesSchema,
|
|
6
7
|
EnginesReqSchema,
|
|
7
8
|
HookEventContributionSchema,
|
|
9
|
+
McpServerAuthSchema,
|
|
10
|
+
McpServerDeclSchema,
|
|
8
11
|
OutputStyleContributionSchema,
|
|
9
12
|
PiExtensionContributionSchema,
|
|
10
13
|
PluginManifestSchema,
|
|
@@ -12,6 +15,10 @@ import {
|
|
|
12
15
|
RunnableKindSchema,
|
|
13
16
|
RunnableMetaSchema,
|
|
14
17
|
SetupStepSchema,
|
|
18
|
+
SlashCommandArgumentSchema,
|
|
19
|
+
SlashCommandContributionSchema,
|
|
20
|
+
SlashCommandCustomOptionSchema,
|
|
21
|
+
SlashCommandOptionSchema,
|
|
15
22
|
SurfaceSchema,
|
|
16
23
|
ToolAppConfigSchema,
|
|
17
24
|
TurnHookContributionSchema,
|
|
@@ -20,14 +27,17 @@ import {
|
|
|
20
27
|
labelImpersonatesSystemChrome,
|
|
21
28
|
validateManifestStrict,
|
|
22
29
|
validatePluginId
|
|
23
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-NZKVOSC2.js";
|
|
24
31
|
export {
|
|
25
32
|
AppDependencySchema,
|
|
26
33
|
CapabilityReqSchema,
|
|
34
|
+
ChatWidgetTemplateSchema,
|
|
27
35
|
CompanionSurfaceSchema,
|
|
28
36
|
ContributesSchema,
|
|
29
37
|
EnginesReqSchema,
|
|
30
38
|
HookEventContributionSchema,
|
|
39
|
+
McpServerAuthSchema,
|
|
40
|
+
McpServerDeclSchema,
|
|
31
41
|
OutputStyleContributionSchema,
|
|
32
42
|
PiExtensionContributionSchema,
|
|
33
43
|
PluginManifestSchema,
|
|
@@ -35,6 +45,10 @@ export {
|
|
|
35
45
|
RunnableKindSchema,
|
|
36
46
|
RunnableMetaSchema,
|
|
37
47
|
SetupStepSchema,
|
|
48
|
+
SlashCommandArgumentSchema,
|
|
49
|
+
SlashCommandContributionSchema,
|
|
50
|
+
SlashCommandCustomOptionSchema,
|
|
51
|
+
SlashCommandOptionSchema,
|
|
38
52
|
SurfaceSchema,
|
|
39
53
|
ToolAppConfigSchema,
|
|
40
54
|
TurnHookContributionSchema,
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/mcp/client.ts
|
|
21
|
+
var client_exports = {};
|
|
22
|
+
__export(client_exports, {
|
|
23
|
+
MCP_PROTOCOL_VERSION: () => MCP_PROTOCOL_VERSION,
|
|
24
|
+
callTool: () => callTool,
|
|
25
|
+
listTools: () => listTools
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(client_exports);
|
|
28
|
+
var import_node_child_process = require("child_process");
|
|
29
|
+
var import_node_readline = require("readline");
|
|
30
|
+
var MCP_PROTOCOL_VERSION = "2024-11-05";
|
|
31
|
+
var RPC_TIMEOUT_MS = 6e4;
|
|
32
|
+
var McpConnection = class _McpConnection {
|
|
33
|
+
proc;
|
|
34
|
+
nextId = 1;
|
|
35
|
+
closed = false;
|
|
36
|
+
waiters = [];
|
|
37
|
+
constructor(proc) {
|
|
38
|
+
this.proc = proc;
|
|
39
|
+
}
|
|
40
|
+
/** Spawn the server and complete the MCP `initialize` handshake. */
|
|
41
|
+
static async connect(cmd) {
|
|
42
|
+
const env = { ...process.env, ...cmd.env ?? {} };
|
|
43
|
+
const proc = (0, import_node_child_process.spawn)(cmd.command, cmd.args ?? [], {
|
|
44
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
45
|
+
env
|
|
46
|
+
});
|
|
47
|
+
if (!(proc.stdin && proc.stdout)) {
|
|
48
|
+
proc.kill();
|
|
49
|
+
throw new Error(`MCP server '${cmd.command}' stdin/stdout unavailable`);
|
|
50
|
+
}
|
|
51
|
+
if (proc.stderr) {
|
|
52
|
+
proc.stderr.on("data", (chunk) => {
|
|
53
|
+
process.stderr.write(`[mcp-server] ${chunk.toString()}`);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const conn = new _McpConnection(proc);
|
|
57
|
+
const rl = (0, import_node_readline.createInterface)({
|
|
58
|
+
input: proc.stdout,
|
|
59
|
+
crlfDelay: Number.POSITIVE_INFINITY
|
|
60
|
+
});
|
|
61
|
+
rl.on("line", (rawLine) => {
|
|
62
|
+
const trimmed = rawLine.trim();
|
|
63
|
+
if (!trimmed) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
let parsed;
|
|
67
|
+
try {
|
|
68
|
+
parsed = JSON.parse(trimmed);
|
|
69
|
+
} catch {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (parsed.id === void 0 || parsed.id === null) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const idx = conn.waiters.findIndex((w) => w.id === parsed.id);
|
|
76
|
+
if (idx === -1) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const [waiter] = conn.waiters.splice(idx, 1);
|
|
80
|
+
if (!waiter) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
clearTimeout(waiter.timer);
|
|
84
|
+
if (parsed.error) {
|
|
85
|
+
waiter.reject(new Error(`MCP error: ${JSON.stringify(parsed.error)}`));
|
|
86
|
+
} else {
|
|
87
|
+
waiter.resolve(parsed.result ?? null);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
rl.on("close", () => {
|
|
91
|
+
for (const waiter of conn.waiters.splice(0)) {
|
|
92
|
+
clearTimeout(waiter.timer);
|
|
93
|
+
waiter.reject(new Error("MCP server closed the connection"));
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
await conn.request("initialize", {
|
|
97
|
+
protocolVersion: MCP_PROTOCOL_VERSION,
|
|
98
|
+
capabilities: {},
|
|
99
|
+
clientInfo: { name: "ryu-sdk", version: "0.0.1" }
|
|
100
|
+
});
|
|
101
|
+
conn.notify("notifications/initialized", {});
|
|
102
|
+
return conn;
|
|
103
|
+
}
|
|
104
|
+
/** Send a JSON-RPC request and return the `result` field. */
|
|
105
|
+
request(method, params) {
|
|
106
|
+
const id = this.nextId++;
|
|
107
|
+
const frame = JSON.stringify({
|
|
108
|
+
jsonrpc: "2.0",
|
|
109
|
+
id,
|
|
110
|
+
method,
|
|
111
|
+
params
|
|
112
|
+
});
|
|
113
|
+
this.write(frame);
|
|
114
|
+
return new Promise((resolve, reject) => {
|
|
115
|
+
const timer = setTimeout(
|
|
116
|
+
() => reject(new Error(`MCP request '${method}' timed out`)),
|
|
117
|
+
RPC_TIMEOUT_MS
|
|
118
|
+
);
|
|
119
|
+
this.waiters.push({ id, resolve, reject, timer });
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/** Send a JSON-RPC notification (no response expected). */
|
|
123
|
+
notify(method, params) {
|
|
124
|
+
const frame = JSON.stringify({ jsonrpc: "2.0", method, params });
|
|
125
|
+
this.write(frame);
|
|
126
|
+
}
|
|
127
|
+
write(frame) {
|
|
128
|
+
if (this.closed) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
this.proc.stdin?.write(`${frame}
|
|
132
|
+
`);
|
|
133
|
+
}
|
|
134
|
+
/** Graceful shutdown: close stdin, then kill. */
|
|
135
|
+
async shutdown() {
|
|
136
|
+
this.closed = true;
|
|
137
|
+
this.proc.stdin?.end();
|
|
138
|
+
await new Promise((resolve) => {
|
|
139
|
+
this.proc.once("exit", () => resolve());
|
|
140
|
+
this.proc.kill();
|
|
141
|
+
setTimeout(resolve, 500);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
async function listTools(cmd) {
|
|
146
|
+
const conn = await McpConnection.connect(cmd);
|
|
147
|
+
let result;
|
|
148
|
+
try {
|
|
149
|
+
result = await conn.request("tools/list", {});
|
|
150
|
+
} finally {
|
|
151
|
+
await conn.shutdown();
|
|
152
|
+
}
|
|
153
|
+
const tools = result?.tools ?? [];
|
|
154
|
+
return tools.map((t) => {
|
|
155
|
+
const tool = t;
|
|
156
|
+
const name = tool.name;
|
|
157
|
+
if (typeof name !== "string") {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
name,
|
|
162
|
+
description: typeof tool.description === "string" ? tool.description : void 0,
|
|
163
|
+
inputSchema: tool.inputSchema
|
|
164
|
+
};
|
|
165
|
+
}).filter((t) => t !== null);
|
|
166
|
+
}
|
|
167
|
+
async function callTool(cmd, tool, args) {
|
|
168
|
+
const conn = await McpConnection.connect(cmd);
|
|
169
|
+
try {
|
|
170
|
+
return await conn.request("tools/call", { name: tool, arguments: args });
|
|
171
|
+
} finally {
|
|
172
|
+
await conn.shutdown();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
176
|
+
0 && (module.exports = {
|
|
177
|
+
MCP_PROTOCOL_VERSION,
|
|
178
|
+
callTool,
|
|
179
|
+
listTools
|
|
180
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK MCP stdio client — a TypeScript mirror of the wire contract in
|
|
3
|
+
* `apps/core/src/sidecar/mcp/client.rs`.
|
|
4
|
+
*
|
|
5
|
+
* This implements the same JSON-RPC 2.0 / newline-delimited transport:
|
|
6
|
+
* 1. Spawn the MCP server process.
|
|
7
|
+
* 2. Send `initialize` (protocolVersion "2024-11-05") and receive the result.
|
|
8
|
+
* 3. Send `notifications/initialized`.
|
|
9
|
+
* 4. Call `tools/list` or `tools/call` as needed.
|
|
10
|
+
* 5. Tear down the process.
|
|
11
|
+
*
|
|
12
|
+
* POLICY NOTE: this client does NOT implement tool-approval or request-level
|
|
13
|
+
* policy enforcement. Approval and policy live in the chat layer and the
|
|
14
|
+
* Gateway (per issue #86). Any policy that must run before a tool call must be
|
|
15
|
+
* wired upstream by the caller, not here.
|
|
16
|
+
*/
|
|
17
|
+
/** MCP protocol version sent during `initialize`. Matches client.rs. */
|
|
18
|
+
declare const MCP_PROTOCOL_VERSION = "2024-11-05";
|
|
19
|
+
/** A tool entry from `tools/list`. */
|
|
20
|
+
interface McpTool {
|
|
21
|
+
description?: string;
|
|
22
|
+
/** JSON Schema object for the tool's input arguments. */
|
|
23
|
+
inputSchema?: unknown;
|
|
24
|
+
name: string;
|
|
25
|
+
}
|
|
26
|
+
/** Command descriptor for spawning an MCP stdio server. */
|
|
27
|
+
interface McpStdioCommand {
|
|
28
|
+
args?: string[];
|
|
29
|
+
command: string;
|
|
30
|
+
env?: Record<string, string>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* List the tools an MCP server advertises (`tools/list`).
|
|
34
|
+
*
|
|
35
|
+
* Spawns the server, completes the initialize handshake, calls `tools/list`,
|
|
36
|
+
* and tears down the process — matching the stateless per-request pattern in
|
|
37
|
+
* `apps/core/src/sidecar/mcp/client.rs`.
|
|
38
|
+
*/
|
|
39
|
+
declare function listTools(cmd: McpStdioCommand): Promise<McpTool[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Call a tool on an MCP server (`tools/call`) and return the raw result.
|
|
42
|
+
*
|
|
43
|
+
* The returned value is the full `tools/call` result object
|
|
44
|
+
* `{ content: [{type, text}], isError? }`. Callers that need the plain text
|
|
45
|
+
* output should extract `.content[0].text`.
|
|
46
|
+
*/
|
|
47
|
+
declare function callTool(cmd: McpStdioCommand, tool: string, args: unknown): Promise<unknown>;
|
|
48
|
+
|
|
49
|
+
export { MCP_PROTOCOL_VERSION, type McpStdioCommand, type McpTool, callTool, listTools };
|