@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.
Files changed (105) hide show
  1. package/README.md +69 -7
  2. package/dist/action.cjs +839 -0
  3. package/dist/action.d.cts +88 -0
  4. package/dist/action.d.ts +88 -0
  5. package/dist/action.js +8 -0
  6. package/dist/agent-plugin.cjs +46 -0
  7. package/dist/agent-plugin.d.cts +43 -33
  8. package/dist/agent-plugin.d.ts +43 -33
  9. package/dist/agent-plugin.js +1 -1
  10. package/dist/agent.cjs +16 -0
  11. package/dist/agent.d.cts +377 -1
  12. package/dist/agent.d.ts +377 -1
  13. package/dist/agent.js +4 -2
  14. package/dist/app-B0Z9Ew_R.d.cts +141 -0
  15. package/dist/app-C-BDJwfG.d.ts +141 -0
  16. package/dist/builder.cjs +1194 -0
  17. package/dist/builder.d.cts +217 -0
  18. package/dist/builder.d.ts +217 -0
  19. package/dist/builder.js +29 -0
  20. package/dist/chunk-4TPUZDTI.js +94 -0
  21. package/dist/chunk-BC3A7HMO.js +164 -0
  22. package/dist/chunk-FZSFZOIN.js +200 -0
  23. package/dist/{chunk-ODFEUVPW.js → chunk-HACAGK65.js} +1 -18
  24. package/dist/chunk-HLKJZAFK.js +361 -0
  25. package/dist/chunk-IKEDLLFY.js +19 -0
  26. package/dist/{chunk-G6FLVEC4.js → chunk-JX6DDRXV.js} +46 -0
  27. package/dist/{chunk-AO2KJRDD.js → chunk-NZKVOSC2.js} +192 -3
  28. package/dist/chunk-QYFUNJOH.js +83 -0
  29. package/dist/chunk-SN2QBJUF.js +148 -0
  30. package/dist/chunk-TLDPEGC7.js +21 -0
  31. package/dist/chunk-TXSHHZF2.js +0 -0
  32. package/dist/chunk-VLIRNNAE.js +154 -0
  33. package/dist/{chunk-MTUBUPIV.js → chunk-Z57QDDJR.js} +8 -227
  34. package/dist/chunk-ZTJWBRUL.js +282 -0
  35. package/dist/cli.cjs +347 -18
  36. package/dist/cli.js +128 -23
  37. package/dist/client-D5U6ssPc.d.cts +84 -0
  38. package/dist/client-D5U6ssPc.d.ts +84 -0
  39. package/dist/index.cjs +810 -86
  40. package/dist/index.d.cts +19 -634
  41. package/dist/index.d.ts +19 -634
  42. package/dist/index.js +82 -699
  43. package/dist/manifest.cjs +200 -4
  44. package/dist/manifest.d.cts +260 -5
  45. package/dist/manifest.d.ts +260 -5
  46. package/dist/manifest.js +15 -1
  47. package/dist/mcp/client.cjs +180 -0
  48. package/dist/mcp/client.d.cts +49 -0
  49. package/dist/mcp/client.d.ts +49 -0
  50. package/dist/mcp/client.js +10 -0
  51. package/dist/mcp/server.cjs +370 -0
  52. package/dist/mcp/server.d.cts +127 -0
  53. package/dist/mcp/server.d.ts +127 -0
  54. package/dist/mcp/server.js +9 -0
  55. package/dist/mcp.cjs +376 -0
  56. package/dist/mcp.d.cts +2 -0
  57. package/dist/mcp.d.ts +2 -0
  58. package/dist/mcp.js +17 -0
  59. package/dist/model.cjs +141 -0
  60. package/dist/model.d.cts +33 -0
  61. package/dist/model.d.ts +33 -0
  62. package/dist/model.js +18 -0
  63. package/dist/plugin.cjs +46 -0
  64. package/dist/plugin.d.cts +215 -0
  65. package/dist/plugin.d.ts +215 -0
  66. package/dist/plugin.js +8 -0
  67. package/dist/runnable.cjs +1438 -0
  68. package/dist/runnable.d.cts +274 -0
  69. package/dist/runnable.d.ts +274 -0
  70. package/dist/runnable.js +34 -0
  71. package/dist/{index-B6SkaAjJ.d.ts → tool-AjkdFvhE.d.ts} +88 -461
  72. package/dist/{index-BvAB5eMk.d.cts → tool-CgzW92O_.d.cts} +88 -461
  73. package/package.json +48 -3
  74. package/src/agent/loop.test.ts +4 -4
  75. package/src/agent/tools.ts +3 -3
  76. package/src/agent-plugin.test.ts +58 -0
  77. package/src/agent-plugin.ts +109 -36
  78. package/src/builder.ts +9 -0
  79. package/src/cli/dev.test.ts +26 -47
  80. package/src/cli/dev.ts +10 -2
  81. package/src/cli-security.test.ts +109 -0
  82. package/src/cli.ts +141 -25
  83. package/src/contracts-lockstep.test.ts +16 -2
  84. package/src/exports-lockstep.test.ts +93 -0
  85. package/src/generated/plugin-manifest.ts +322 -29
  86. package/src/index.ts +53 -0
  87. package/src/manifest-schema.test.ts +30 -1
  88. package/src/manifest.fixtures.test.ts +22 -6
  89. package/src/manifest.test.ts +165 -10
  90. package/src/manifest.ts +454 -188
  91. package/src/mcp/index.ts +18 -0
  92. package/src/mcp/server.ts +2 -1
  93. package/src/model/index.ts +22 -0
  94. package/src/plugin/ryu-plugin.ts +82 -0
  95. package/src/runnable/action.test.ts +128 -0
  96. package/src/runnable/action.ts +202 -0
  97. package/src/runnable/app.test.ts +2 -0
  98. package/src/runnable/app.ts +50 -14
  99. package/src/runnable/index.ts +20 -3
  100. package/src/runnable/primitives.test.ts +34 -0
  101. package/src/runnable/primitives.ts +116 -0
  102. package/src/runnable/runnable-types.ts +3 -0
  103. package/src/runnable/tool.ts +36 -5
  104. package/src/runnable/turn-hook.ts +8 -3
  105. package/src/slash-command.test.ts +69 -0
package/dist/index.js CHANGED
@@ -1,710 +1,87 @@
1
+ import {
2
+ toDisposable
3
+ } from "./chunk-TLDPEGC7.js";
4
+ import {
5
+ defineAgent,
6
+ defineSkill,
7
+ defineWorkflow
8
+ } from "./chunk-BC3A7HMO.js";
9
+ import {
10
+ AgentBuilder,
11
+ AppBuilder,
12
+ PluginBuilder,
13
+ SkillBuilder,
14
+ ToolBuilder,
15
+ WorkflowBuilder,
16
+ agent,
17
+ app,
18
+ skill,
19
+ tool,
20
+ workflow
21
+ } from "./chunk-HLKJZAFK.js";
22
+ import {
23
+ appToolId,
24
+ defineApp
25
+ } from "./chunk-SN2QBJUF.js";
26
+ import {
27
+ Agent,
28
+ createAgent,
29
+ query,
30
+ ryuTool
31
+ } from "./chunk-Z57QDDJR.js";
32
+ import {
33
+ PRIMITIVE_BINDINGS,
34
+ createPrimitives,
35
+ httpPrimitiveTransport
36
+ } from "./chunk-ZTJWBRUL.js";
37
+ import {
38
+ defineAction
39
+ } from "./chunk-4TPUZDTI.js";
40
+ import {
41
+ defineTool,
42
+ inlineToolRunnable
43
+ } from "./chunk-QYFUNJOH.js";
1
44
  import {
2
45
  AppDependencySchema,
3
46
  CapabilityReqSchema,
4
47
  CompanionSurfaceSchema,
48
+ McpServerAuthSchema,
49
+ McpServerDeclSchema,
5
50
  PluginManifestSchema,
6
51
  RequiresSchema,
7
52
  RunnableKindSchema,
8
53
  RunnableMetaSchema,
54
+ SlashCommandArgumentSchema,
55
+ SlashCommandContributionSchema,
56
+ SlashCommandCustomOptionSchema,
57
+ SlashCommandOptionSchema,
9
58
  SurfaceSchema,
10
59
  ToolAppConfigSchema,
11
60
  WidgetContributionSchema,
12
61
  coreManifestJsonSchema,
13
62
  validateManifestStrict,
14
63
  validatePluginId
15
- } from "./chunk-AO2KJRDD.js";
64
+ } from "./chunk-NZKVOSC2.js";
16
65
  import {
17
- Agent,
18
- PRIMITIVE_BINDINGS,
19
- createAgent,
20
- createPrimitives,
21
- httpPrimitiveTransport,
22
- query,
23
- ryuTool
24
- } from "./chunk-MTUBUPIV.js";
66
+ ModelClient,
67
+ defineModel
68
+ } from "./chunk-HACAGK65.js";
25
69
  import {
26
70
  DEFAULT_GATEWAY_URL,
27
- ModelClient,
28
71
  assertAllowedEgressUrl,
29
- defineModel,
30
72
  resolveGatewayToken,
31
73
  resolveGatewayUrl
32
- } from "./chunk-ODFEUVPW.js";
33
-
34
- // src/runnable/app.ts
35
- var DEFAULT_APP_WIDGET_MIME = "text/html+skybridge";
36
- var DEFAULT_APP_DISPLAY_MODE = "inline";
37
- var WIDGET_RENDER_GRANT = "widget:render";
38
- function withWidgetRenderGrant(grants, widgets) {
39
- const out = [...grants];
40
- if (widgets.length > 0 && !out.includes(WIDGET_RENDER_GRANT)) {
41
- out.push(WIDGET_RENDER_GRANT);
42
- }
43
- return out;
44
- }
45
- function appToolId(server, name) {
46
- return `${server}__${name}`;
47
- }
48
- function defineApp(options) {
49
- const server = options.server ?? options.slug;
50
- const uri = `ui://widget/${options.slug}.html`;
51
- const mime = options.mime ?? DEFAULT_APP_WIDGET_MIME;
52
- const displayMode = options.displayMode ?? DEFAULT_APP_DISPLAY_MODE;
53
- const hasCompanions = options.tools.some((t) => t.accessible === true);
54
- const runnables = [];
55
- const widgets = [];
56
- for (const spec of options.tools) {
57
- const isRender = spec.accessible !== true;
58
- const id = appToolId(server, spec.name);
59
- const config = {
60
- slug: id,
61
- description: spec.description,
62
- widget: isRender,
63
- widget_accessible: isRender ? hasCompanions : true,
64
- ...spec.inputSchema ? { input_schema: spec.inputSchema } : {},
65
- ...spec.invoking ? { invoking: spec.invoking } : {},
66
- ...spec.invoked ? { invoked: spec.invoked } : {}
67
- };
68
- runnables.push({
69
- id,
70
- name: spec.name,
71
- kind: "tool",
72
- config
73
- });
74
- if (isRender) {
75
- widgets.push({
76
- tool_id: id,
77
- uri,
78
- ui_entry: options.uiEntry,
79
- mime,
80
- default_display_mode: displayMode
81
- });
82
- }
83
- }
84
- const contributes = {
85
- turn_hooks: [],
86
- // This builder synthesises an app from its runnables; an app that emits
87
- // events declares them in a hand-authored `manifest.json`, same as
88
- // `lsp_servers` below.
89
- hook_events: [],
90
- composer_controls: [],
91
- settings_tabs: [],
92
- slash_commands: [],
93
- sidebar_sections: [],
94
- sidebar_buttons: [],
95
- dock_panels: [],
96
- // Empty for the same reason as every sibling family above: this builder
97
- // synthesises `widgets` from the app's own runnables and nothing else, and
98
- // takes no `contributes` passthrough. An app that wants to declare language
99
- // servers writes them in a hand-authored `manifest.json`.
100
- lsp_servers: {},
101
- // Same reason again: a danger-zone category, a Pi extension and an output
102
- // style are all hand-authored declarations, not something derivable from
103
- // runnables. An output style in particular points at a Markdown file next
104
- // to the manifest, which this builder never writes.
105
- data_categories: [],
106
- pi_extensions: [],
107
- output_styles: [],
108
- widgets
109
- };
110
- const raw = {
111
- id: options.id,
112
- name: options.title,
113
- version: options.version,
114
- runnables,
115
- // An app that synthesises widgets MUST hold `widget:render`, so this
116
- // builder declares it rather than leaving the author to discover it.
117
- //
118
- // Core gates widget promotion on declared-AND-enabled-AND-granted, and a
119
- // missing grant fails as `DeniedNoGrant` — which is an `info!` log and
120
- // nothing else. The widget silently renders as plain text, with no error
121
- // in the UI and nothing pointing at the manifest. Every app scaffolded
122
- // through `defineApp` hit that, because the only fix was a grant string
123
- // the templates never mention and the builder never added; the one
124
- // working example on disk hand-writes it.
125
- //
126
- // Added only when there is a widget to render, and unioned rather than
127
- // overwritten so an author's own `grants` list survives and re-declaring
128
- // it is not an error.
129
- permission_grants: withWidgetRenderGrant(options.grants ?? [], widgets),
130
- activation_events: options.activationEvents ?? ["*"],
131
- contributes,
132
- // `targets: []` means EVERY surface, so an app that declares none is
133
- // unrestricted — the backward-compatible default.
134
- targets: options.targets ?? [],
135
- // `requires` stays ABSENT (not `{apps:[],grants:[]}`) when undeclared, so the
136
- // emitted manifest carries no key at all — matching Core's
137
- // `Option<Requires>` + `skip_serializing_if = "Option::is_none"`.
138
- ...options.requires ? {
139
- requires: {
140
- apps: options.requires.apps ?? [],
141
- capabilities: options.requires.capabilities ?? [],
142
- grants: options.requires.grants ?? []
143
- }
144
- } : {}
145
- };
146
- const result = PluginManifestSchema.safeParse(raw);
147
- if (!result.success) {
148
- const first = result.error.issues[0];
149
- const field = first?.path.join(".") ?? "unknown";
150
- const message = first?.message ?? "validation failed";
151
- throw new Error(
152
- `manifest.json validation failed at '${field}': ${message}`
153
- );
154
- }
155
- return result.data;
156
- }
157
-
158
- // src/builder.ts
159
- var RunnableBuilder = class {
160
- _id = "";
161
- _name = "";
162
- id(value) {
163
- this._id = value;
164
- return this;
165
- }
166
- name(value) {
167
- this._name = value;
168
- return this;
169
- }
170
- };
171
- var AgentBuilder = class extends RunnableBuilder {
172
- build() {
173
- const result = RunnableMetaSchema.safeParse({
174
- id: this._id,
175
- name: this._name,
176
- kind: "agent"
177
- });
178
- if (!result.success) {
179
- throw new Error(
180
- `Invalid agent runnable: ${result.error.issues.map((i) => i.message).join("; ")}`
181
- );
182
- }
183
- return result.data;
184
- }
185
- };
186
- var WorkflowBuilder = class extends RunnableBuilder {
187
- build() {
188
- const result = RunnableMetaSchema.safeParse({
189
- id: this._id,
190
- name: this._name,
191
- kind: "workflow"
192
- });
193
- if (!result.success) {
194
- throw new Error(
195
- `Invalid workflow runnable: ${result.error.issues.map((i) => i.message).join("; ")}`
196
- );
197
- }
198
- return result.data;
199
- }
200
- };
201
- var ToolBuilder = class extends RunnableBuilder {
202
- build() {
203
- const result = RunnableMetaSchema.safeParse({
204
- id: this._id,
205
- name: this._name,
206
- kind: "tool"
207
- });
208
- if (!result.success) {
209
- throw new Error(
210
- `Invalid tool runnable: ${result.error.issues.map((i) => i.message).join("; ")}`
211
- );
212
- }
213
- return result.data;
214
- }
215
- };
216
- var SkillBuilder = class extends RunnableBuilder {
217
- build() {
218
- const result = RunnableMetaSchema.safeParse({
219
- id: this._id,
220
- name: this._name,
221
- kind: "skill"
222
- });
223
- if (!result.success) {
224
- throw new Error(
225
- `Invalid skill runnable: ${result.error.issues.map((i) => i.message).join("; ")}`
226
- );
227
- }
228
- return result.data;
229
- }
230
- };
231
- var agent = () => new AgentBuilder();
232
- var workflow = () => new WorkflowBuilder();
233
- var tool = () => new ToolBuilder();
234
- var skill = () => new SkillBuilder();
235
- var PluginBuilder = class {
236
- _id = "";
237
- _name = "";
238
- _version = "";
239
- _runnables = [];
240
- _grants = [];
241
- _companion = void 0;
242
- _dependencies = [];
243
- _requiredCapabilities = [];
244
- _requiredGrants = [];
245
- _targets = [];
246
- /** Set the reverse-domain app id (e.g. `"com.example.my-app"`). */
247
- id(value) {
248
- this._id = value;
249
- return this;
250
- }
251
- /** Set the human-readable display name. */
252
- name(value) {
253
- this._name = value;
254
- return this;
255
- }
256
- /** Set the semver version string (e.g. `"1.0.0"`). */
257
- version(value) {
258
- this._version = value;
259
- return this;
260
- }
261
- /** Append a pre-built `RunnableMeta` (from any per-kind builder). */
262
- runnable(meta) {
263
- this._runnables.push(meta);
264
- return this;
265
- }
266
- /** Declare a permission grant (e.g. `"mcp:web_search"`). */
267
- grant(permission) {
268
- this._grants.push(permission);
269
- return this;
270
- }
271
- /** Set an optional Companion surface descriptor. */
272
- companion(surface) {
273
- this._companion = surface;
274
- return this;
275
- }
276
- /**
277
- * Declare a **plugin-to-plugin dependency**: `id` must be installed and is
278
- * auto-enabled (in dependency order) before this plugin enables.
279
- *
280
- * `minVersion` is a MINIMUM — a bare `"1.2.0"` means `">=1.2.0"`, so an
281
- * installed `2.0.0` satisfies it (comparator syntax like `">=1.2, <2"` is
282
- * honoured verbatim).
283
- */
284
- dependsOn(id, minVersion) {
285
- this._dependencies.push(
286
- minVersion ? { id, min_version: minVersion } : { id }
287
- );
288
- return this;
289
- }
290
- /**
291
- * Declare a permission grant implied by this plugin's dependencies
292
- * (`requires.grants`). Declaration only — the Gateway remains the sole
293
- * authority on what a grant allows. Use {@link PluginBuilder.grant} for the
294
- * grants this plugin needs in its own right.
295
- */
296
- requiredGrant(permission) {
297
- this._requiredGrants.push(permission);
298
- return this;
299
- }
300
- /**
301
- * Declare an abstract **capability** edge (`requires.capabilities`) the broker
302
- * resolves to a bound provider at enable time — e.g. `requiresCapability("rag")`.
303
- * Distinct from a specific-plugin dependency: a capability edge lets the
304
- * binding registry choose the provider. `minVersion` is a MINIMUM (`"1.2.0"`
305
- * = `">=1.2.0"`).
306
- */
307
- requiresCapability(capability, minVersion) {
308
- this._requiredCapabilities.push(
309
- minVersion ? { capability, min_version: minVersion } : { capability }
310
- );
311
- return this;
312
- }
313
- /**
314
- * Restrict this plugin to a host surface (`"desktop"`, `"island"`, …).
315
- * Declaring NO target is the default and means **every** surface.
316
- */
317
- target(surface) {
318
- this._targets.push(surface);
319
- return this;
320
- }
321
- /**
322
- * Validate and return the assembled `PluginManifest`. Throws an `Error` with
323
- * the failing field name and message when validation fails.
324
- */
325
- build() {
326
- const hasRequires = this._dependencies.length > 0 || this._requiredCapabilities.length > 0 || this._requiredGrants.length > 0;
327
- const raw = {
328
- id: this._id,
329
- name: this._name,
330
- version: this._version,
331
- runnables: this._runnables,
332
- permission_grants: this._grants,
333
- companion: this._companion,
334
- targets: this._targets,
335
- ...hasRequires ? {
336
- requires: {
337
- apps: this._dependencies,
338
- capabilities: this._requiredCapabilities,
339
- grants: this._requiredGrants
340
- }
341
- } : {}
342
- };
343
- const result = PluginManifestSchema.safeParse(raw);
344
- if (!result.success) {
345
- const first = result.error.issues[0];
346
- const field = first?.path.join(".") ?? "unknown";
347
- const message = first?.message ?? "validation failed";
348
- throw new Error(
349
- `manifest.json validation failed at '${field}': ${message}`
350
- );
351
- }
352
- return result.data;
353
- }
354
- };
355
- var AppBuilder = class {
356
- _id = "";
357
- _title = "";
358
- _version = "";
359
- _slug = "";
360
- _server = void 0;
361
- _displayMode = void 0;
362
- _mime = void 0;
363
- _uiEntry = "";
364
- _grants = [];
365
- _activationEvents = [];
366
- _tools = [];
367
- _dependencies = [];
368
- _requiredCapabilities = [];
369
- _requiredGrants = [];
370
- _targets = [];
371
- /** Set the reverse-domain app id (e.g. `"com.example.checklist"`). */
372
- id(value) {
373
- this._id = value;
374
- return this;
375
- }
376
- /** Set the human-readable display name. */
377
- title(value) {
378
- this._title = value;
379
- return this;
380
- }
381
- /** Set the semver version string (e.g. `"1.0.0"`). */
382
- version(value) {
383
- this._version = value;
384
- return this;
385
- }
386
- /** Set the app slug (drives `ui://widget/<slug>.html` and the server default). */
387
- slug(value) {
388
- this._slug = value;
389
- return this;
390
- }
391
- /** Override the MCP server namespace for tool ids (defaults to the slug). */
392
- server(value) {
393
- this._server = value;
394
- return this;
395
- }
396
- /** Set the default widget display mode (`inline` | `fullscreen` | `pip`). */
397
- displayMode(value) {
398
- this._displayMode = value;
399
- return this;
400
- }
401
- /** Override the widget MIME dialect (defaults to `text/html+skybridge`). */
402
- mime(value) {
403
- this._mime = value;
404
- return this;
405
- }
406
- /** Set the widget UI source entry `ryu pack` bundles into `ui_code`. */
407
- uiEntry(value) {
408
- this._uiEntry = value;
409
- return this;
410
- }
411
- /** Declare a permission grant (e.g. `"mcp:web_search"`). */
412
- grant(permission) {
413
- this._grants.push(permission);
414
- return this;
415
- }
416
- /** Add a VS-Code-style activation event (empty = eager `["*"]`). */
417
- activationEvent(event) {
418
- this._activationEvents.push(event);
419
- return this;
420
- }
421
- /** Append a tool spec (render tool unless `accessible:true`). */
422
- tool(spec) {
423
- this._tools.push(spec);
424
- return this;
425
- }
426
- /**
427
- * Declare a **plugin-to-plugin dependency** (auto-enabled, in dependency order,
428
- * before this app). `minVersion` is a MINIMUM (`"1.2.0"` = `">=1.2.0"`).
429
- */
430
- dependsOn(id, minVersion) {
431
- this._dependencies.push(
432
- minVersion ? { id, min_version: minVersion } : { id }
433
- );
434
- return this;
435
- }
436
- /** Declare a grant implied by this app's dependencies (`requires.grants`). */
437
- requiredGrant(permission) {
438
- this._requiredGrants.push(permission);
439
- return this;
440
- }
441
- /**
442
- * Declare an abstract **capability** edge (`requires.capabilities`) the broker
443
- * resolves to a bound provider at enable time — e.g. `requiresCapability("rag")`.
444
- * Distinct from a specific-plugin dependency: a capability edge lets the
445
- * binding registry choose the provider. `minVersion` is a MINIMUM (`"1.2.0"`
446
- * = `">=1.2.0"`).
447
- */
448
- requiresCapability(capability, minVersion) {
449
- this._requiredCapabilities.push(
450
- minVersion ? { capability, min_version: minVersion } : { capability }
451
- );
452
- return this;
453
- }
454
- /** Restrict this app to a host surface. No target = every surface. */
455
- target(surface) {
456
- this._targets.push(surface);
457
- return this;
458
- }
459
- /**
460
- * Validate and return the assembled `PluginManifest`. Throws an `Error` naming
461
- * the failing field when validation fails.
462
- */
463
- build() {
464
- const hasRequires = this._dependencies.length > 0 || this._requiredCapabilities.length > 0 || this._requiredGrants.length > 0;
465
- const options = {
466
- id: this._id,
467
- title: this._title,
468
- version: this._version,
469
- slug: this._slug,
470
- uiEntry: this._uiEntry,
471
- tools: this._tools,
472
- grants: this._grants,
473
- ...this._server ? { server: this._server } : {},
474
- ...this._displayMode ? { displayMode: this._displayMode } : {},
475
- ...this._mime ? { mime: this._mime } : {},
476
- ...this._activationEvents.length > 0 ? { activationEvents: this._activationEvents } : {},
477
- ...hasRequires ? {
478
- requires: {
479
- apps: this._dependencies,
480
- capabilities: this._requiredCapabilities,
481
- grants: this._requiredGrants
482
- }
483
- } : {},
484
- ...this._targets.length > 0 ? { targets: this._targets } : {}
485
- };
486
- return defineApp(options);
487
- }
488
- };
489
- var app = () => new AppBuilder();
490
-
491
- // src/runnable/agent.ts
492
- var CAPABILITY_SLOTS = ["rag", "memory", "tts", "stt"];
493
- function lowerChatSlot(chat) {
494
- if (chat === void 0) {
495
- return {};
496
- }
497
- if (typeof chat === "string") {
498
- return { model: chat };
499
- }
500
- return {
501
- model: chat.model,
502
- engine: chat.engine,
503
- persona: chat.persona,
504
- modelPrefKey: chat.modelPrefKey
505
- };
506
- }
507
- function lowerCapabilitySlot(capability, slot, card) {
508
- if (slot === void 0 || slot === false) {
509
- return;
510
- }
511
- if (slot === true) {
512
- card.capabilities.push({ capability });
513
- return;
514
- }
515
- if (typeof slot === "string") {
516
- card.capabilities.push({ capability });
517
- card.providers[capability] = slot;
518
- return;
519
- }
520
- card.capabilities.push(
521
- slot.minVersion ? { capability, min_version: slot.minVersion } : { capability }
522
- );
523
- if (slot.provider) {
524
- card.providers[capability] = slot.provider;
525
- }
526
- }
527
- function lowerSlots(options) {
528
- const card = {
529
- ...lowerChatSlot(options.chat),
530
- capabilities: [],
531
- providers: {},
532
- tools: []
533
- };
534
- for (const capability of CAPABILITY_SLOTS) {
535
- lowerCapabilitySlot(capability, options[capability], card);
536
- }
537
- for (const t of options.tools ?? []) {
538
- card.tools.push(typeof t === "string" ? t : t.id);
539
- }
540
- return card;
541
- }
542
- function defaultRun(card) {
543
- return async (input, ctx) => {
544
- const content = typeof input === "string" ? input : JSON.stringify(input ?? "");
545
- const messages = card.persona ? [
546
- { role: "system", content: card.persona },
547
- { role: "user", content }
548
- ] : [{ role: "user", content }];
549
- const result = await ctx.gateway.chat(messages);
550
- return result.content;
551
- };
552
- }
553
- function cardConfig(card) {
554
- const config = {};
555
- if (card.model) {
556
- config.model = card.model;
557
- }
558
- if (card.engine) {
559
- config.engine = card.engine;
560
- }
561
- if (card.persona) {
562
- config.persona = card.persona;
563
- }
564
- if (card.modelPrefKey) {
565
- config.model_pref_key = card.modelPrefKey;
566
- }
567
- if (Object.keys(card.providers).length > 0) {
568
- config.capability_providers = card.providers;
569
- }
570
- if (card.tools.length > 0) {
571
- config.tools = card.tools;
572
- }
573
- return config;
574
- }
575
- function agentToManifest(agent2, options) {
576
- const config = cardConfig(agent2.card);
577
- const meta = {
578
- id: agent2.id,
579
- name: agent2.name,
580
- kind: "agent",
581
- ...Object.keys(config).length > 0 ? { config } : {}
582
- };
583
- const hasRequires = agent2.card.capabilities.length > 0 || (options.grants?.length ?? 0) > 0;
584
- const raw = {
585
- id: options.id,
586
- name: options.name ?? agent2.name,
587
- version: options.version,
588
- runnables: [meta],
589
- ...hasRequires ? {
590
- requires: {
591
- apps: [],
592
- capabilities: agent2.card.capabilities,
593
- grants: options.grants ?? []
594
- }
595
- } : {}
596
- };
597
- const result = PluginManifestSchema.safeParse(raw);
598
- if (!result.success) {
599
- const first = result.error.issues[0];
600
- const field = first?.path.join(".") ?? "unknown";
601
- const message = first?.message ?? "validation failed";
602
- throw new Error(
603
- `agent manifest validation failed at '${field}': ${message}`
604
- );
605
- }
606
- return result.data;
607
- }
608
- function defineAgent(options) {
609
- const { id, name } = options;
610
- const card = lowerSlots(options);
611
- const run = options.run ?? defaultRun(card);
612
- return {
613
- id,
614
- name,
615
- kind: "agent",
616
- run,
617
- card,
618
- toManifest(manifestOptions) {
619
- return agentToManifest(this, manifestOptions);
620
- }
621
- };
622
- }
623
-
624
- // src/runnable/skill.ts
625
- function defineSkill(options) {
626
- const { id, name, run } = options;
627
- return {
628
- id,
629
- name,
630
- kind: "skill",
631
- run
632
- };
633
- }
634
-
635
- // src/runnable/tool.ts
636
- function validateInput(input, schema, toolId) {
637
- if (typeof input !== "object" || input === null || Array.isArray(input)) {
638
- throw new Error(
639
- `[ryu-sdk] Tool "${toolId}" input must be an object, got ${JSON.stringify(input)}`
640
- );
641
- }
642
- const record = input;
643
- for (const requiredKey of schema.required ?? []) {
644
- if (!(requiredKey in record)) {
645
- throw new Error(
646
- `[ryu-sdk] Tool "${toolId}" input missing required field "${requiredKey}"`
647
- );
648
- }
649
- }
650
- for (const [key, prop] of Object.entries(schema.properties)) {
651
- if (!(key in record)) {
652
- continue;
653
- }
654
- const value = record[key];
655
- if (!checkType(value, prop.type)) {
656
- throw new Error(
657
- `[ryu-sdk] Tool "${toolId}" input field "${key}" expected type "${prop.type}", got ${JSON.stringify(value)}`
658
- );
659
- }
660
- }
661
- }
662
- function checkType(value, type) {
663
- switch (type) {
664
- case "string":
665
- return typeof value === "string";
666
- case "number":
667
- case "integer":
668
- return typeof value === "number";
669
- case "boolean":
670
- return typeof value === "boolean";
671
- case "array":
672
- return Array.isArray(value);
673
- case "object":
674
- return typeof value === "object" && value !== null && !Array.isArray(value);
675
- default:
676
- return false;
677
- }
678
- }
679
- function defineTool(options) {
680
- const { id, name, schema, run } = options;
681
- const code = `return await (${run.toString()})(input, host);`;
682
- return {
683
- id,
684
- name,
685
- kind: "tool",
686
- schema,
687
- code,
688
- run(input, ctx) {
689
- validateInput(input, schema, id);
690
- return run(input, ctx);
691
- }
692
- };
693
- }
694
- function inlineToolRunnable(tool2, options) {
695
- return {
696
- id: tool2.id,
697
- name: tool2.name,
698
- kind: "tool",
699
- config: {
700
- slug: tool2.id,
701
- backend: "inline_deno",
702
- code: tool2.code,
703
- input_schema: tool2.schema,
704
- ...options?.description ? { description: options.description } : {}
705
- }
706
- };
707
- }
74
+ } from "./chunk-IKEDLLFY.js";
75
+ import "./chunk-TXSHHZF2.js";
76
+ import {
77
+ McpServer,
78
+ unwrapContent
79
+ } from "./chunk-FZSFZOIN.js";
80
+ import {
81
+ MCP_PROTOCOL_VERSION,
82
+ callTool,
83
+ listTools
84
+ } from "./chunk-VLIRNNAE.js";
708
85
 
709
86
  // src/runnable/turn-hook.ts
710
87
  function defineTurnHook(options) {
@@ -721,6 +98,7 @@ function definePlugin(options) {
721
98
  turn_hooks: options.turnHooks ?? [],
722
99
  hook_events: options.hookEvents ?? [],
723
100
  composer_controls: options.composerControls ?? [],
101
+ chat_features: [],
724
102
  settings_tabs: options.settingsTabs ?? [],
725
103
  slash_commands: options.slashCommands ?? [],
726
104
  lsp_servers: options.lspServers ?? {},
@@ -732,9 +110,12 @@ function definePlugin(options) {
732
110
  sidebar_sections: [],
733
111
  sidebar_buttons: [],
734
112
  dock_panels: [],
113
+ live_activities: [],
735
114
  data_categories: [],
736
115
  pi_extensions: [],
737
- output_styles: []
116
+ output_styles: [],
117
+ message_actions: [],
118
+ selection_actions: []
738
119
  };
739
120
  const tools = options.tools ?? [];
740
121
  const runnables = tools.map((t) => inlineToolRunnable(t));
@@ -763,17 +144,6 @@ function definePlugin(options) {
763
144
  } : {}
764
145
  };
765
146
  }
766
-
767
- // src/runnable/workflow.ts
768
- function defineWorkflow(options) {
769
- const { id, name, run } = options;
770
- return {
771
- id,
772
- name,
773
- kind: "workflow",
774
- run
775
- };
776
- }
777
147
  export {
778
148
  Agent,
779
149
  AgentBuilder,
@@ -782,6 +152,10 @@ export {
782
152
  CapabilityReqSchema,
783
153
  CompanionSurfaceSchema,
784
154
  DEFAULT_GATEWAY_URL,
155
+ MCP_PROTOCOL_VERSION,
156
+ McpServer,
157
+ McpServerAuthSchema,
158
+ McpServerDeclSchema,
785
159
  ModelClient,
786
160
  PRIMITIVE_BINDINGS,
787
161
  PluginBuilder,
@@ -790,6 +164,10 @@ export {
790
164
  RunnableKindSchema,
791
165
  RunnableMetaSchema,
792
166
  SkillBuilder,
167
+ SlashCommandArgumentSchema,
168
+ SlashCommandContributionSchema,
169
+ SlashCommandCustomOptionSchema,
170
+ SlashCommandOptionSchema,
793
171
  SurfaceSchema,
794
172
  ToolAppConfigSchema,
795
173
  ToolBuilder,
@@ -799,9 +177,11 @@ export {
799
177
  app,
800
178
  appToolId,
801
179
  assertAllowedEgressUrl,
180
+ callTool,
802
181
  coreManifestJsonSchema,
803
182
  createAgent,
804
183
  createPrimitives,
184
+ defineAction,
805
185
  defineAgent,
806
186
  defineApp,
807
187
  defineModel,
@@ -812,12 +192,15 @@ export {
812
192
  defineWorkflow,
813
193
  httpPrimitiveTransport,
814
194
  inlineToolRunnable,
195
+ listTools,
815
196
  query,
816
197
  resolveGatewayToken,
817
198
  resolveGatewayUrl,
818
199
  ryuTool,
819
200
  skill,
201
+ toDisposable,
820
202
  tool,
203
+ unwrapContent,
821
204
  validateManifestStrict,
822
205
  validatePluginId,
823
206
  workflow