@ryuhq/sdk 0.2.0 → 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 +51 -2
- 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.d.cts +1 -1
- package/dist/agent-plugin.d.ts +1 -1
- package/dist/agent.cjs +7 -0
- package/dist/agent.d.cts +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +2 -2
- package/dist/{app-DNaGmLVf.d.cts → app-B0Z9Ew_R.d.cts} +18 -6
- package/dist/{app-Bkw7LlCK.d.ts → app-C-BDJwfG.d.ts} +18 -6
- package/dist/builder.cjs +110 -11
- package/dist/builder.d.cts +7 -2
- package/dist/builder.d.ts +7 -2
- package/dist/builder.js +4 -3
- package/dist/chunk-4TPUZDTI.js +94 -0
- package/dist/{chunk-T5676WL2.js → chunk-BC3A7HMO.js} +1 -77
- package/dist/{chunk-IOLP5FFE.js → chunk-HLKJZAFK.js} +9 -2
- package/dist/{chunk-IEUQ3CDG.js → chunk-NZKVOSC2.js} +71 -5
- package/dist/chunk-QYFUNJOH.js +83 -0
- package/dist/{chunk-W3KPP4WN.js → chunk-SN2QBJUF.js} +20 -7
- package/dist/{chunk-ULSVL7EC.js → chunk-Z57QDDJR.js} +1 -1
- package/dist/{chunk-A3RGEPDG.js → chunk-ZTJWBRUL.js} +32 -0
- package/dist/cli.cjs +93 -8
- package/dist/cli.js +33 -8
- package/dist/index.cjs +297 -87
- package/dist/index.d.cts +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.js +34 -19
- package/dist/manifest.cjs +76 -6
- package/dist/manifest.d.cts +157 -5
- package/dist/manifest.d.ts +157 -5
- package/dist/manifest.js +9 -1
- package/dist/mcp/server.d.cts +2 -1
- package/dist/mcp/server.d.ts +2 -1
- package/dist/runnable.cjs +279 -71
- package/dist/runnable.d.cts +6 -3
- package/dist/runnable.d.ts +6 -3
- package/dist/runnable.js +11 -5
- package/dist/{tool-DSx2bFx8.d.ts → tool-AjkdFvhE.d.ts} +54 -4
- package/dist/{tool-u-VR0fLF.d.cts → tool-CgzW92O_.d.cts} +54 -4
- package/package.json +12 -3
- package/src/agent-plugin.ts +1 -1
- package/src/builder.ts +9 -0
- package/src/cli-security.test.ts +109 -0
- package/src/cli.ts +43 -10
- package/src/contracts-lockstep.test.ts +16 -2
- package/src/exports-lockstep.test.ts +1 -0
- package/src/generated/plugin-manifest.ts +82 -5
- package/src/index.ts +18 -0
- package/src/manifest.fixtures.test.ts +9 -3
- package/src/manifest.test.ts +69 -0
- package/src/manifest.ts +137 -18
- package/src/mcp/server.ts +2 -1
- package/src/runnable/action.test.ts +128 -0
- package/src/runnable/action.ts +202 -0
- package/src/runnable/app.ts +45 -12
- package/src/runnable/index.ts +18 -3
- package/src/runnable/primitives.test.ts +34 -0
- package/src/runnable/primitives.ts +59 -0
- package/src/runnable/runnable-types.ts +3 -0
- package/src/runnable/tool.ts +35 -4
- package/src/runnable/turn-hook.ts +4 -2
- package/src/slash-command.test.ts +69 -0
package/dist/action.cjs
ADDED
|
@@ -0,0 +1,839 @@
|
|
|
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/runnable/action.ts
|
|
21
|
+
var action_exports = {};
|
|
22
|
+
__export(action_exports, {
|
|
23
|
+
defineAction: () => defineAction
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(action_exports);
|
|
26
|
+
|
|
27
|
+
// src/manifest.ts
|
|
28
|
+
var import_node_module = require("module");
|
|
29
|
+
var import_zod = require("zod");
|
|
30
|
+
var RunnableKindSchema = import_zod.z.enum([
|
|
31
|
+
"agent",
|
|
32
|
+
"workflow",
|
|
33
|
+
"tool",
|
|
34
|
+
"skill",
|
|
35
|
+
// A companion surface (in-desktop panel). Added so a packable plugin can
|
|
36
|
+
// declare a companion runnable that flows through Core's existing Companion
|
|
37
|
+
// handler → app_contrib → `GET /api/plugins/contributions` → the desktop
|
|
38
|
+
// `/plugin/<id>` route. Its `config.ui_entry` (see `CompanionRunnableConfigSchema`)
|
|
39
|
+
// is what `ryu pack` bundles into `ui_code`.
|
|
40
|
+
"companion"
|
|
41
|
+
]);
|
|
42
|
+
var RunnableMetaSchema = import_zod.z.object({
|
|
43
|
+
/** Stable unique identifier (e.g. `"agent-researcher"`). */
|
|
44
|
+
id: import_zod.z.string().min(1),
|
|
45
|
+
/** Human-readable display name. */
|
|
46
|
+
name: import_zod.z.string().min(1),
|
|
47
|
+
/** Which kind of runnable this entry describes. */
|
|
48
|
+
kind: RunnableKindSchema,
|
|
49
|
+
/**
|
|
50
|
+
* Optional per-kind config blob. Mirrors Core's `RunnableEntry.config`
|
|
51
|
+
* (`Option<serde_json::Value>`) so a manifest authored here round-trips
|
|
52
|
+
* through Core-strict validation. Left opaque (a record) at this authoring
|
|
53
|
+
* layer; the per-kind shape is enforced by Core's `validate_runnable`.
|
|
54
|
+
*
|
|
55
|
+
* For a `companion` runnable, `config.ui_entry` names the plugin's UI entry
|
|
56
|
+
* module (relative to the manifest dir). `ryu pack` bundles that entry into
|
|
57
|
+
* the emitted `ui_code`; Core's `CompanionConfig.ui_entry` is the lockstep
|
|
58
|
+
* field so a packed companion validates.
|
|
59
|
+
*/
|
|
60
|
+
config: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
|
|
61
|
+
});
|
|
62
|
+
function labelImpersonatesSystemChrome(label) {
|
|
63
|
+
const lower = label.toLowerCase();
|
|
64
|
+
return lower.includes("ryu") || lower.includes("system");
|
|
65
|
+
}
|
|
66
|
+
var CompanionSurfaceSchema = import_zod.z.object({
|
|
67
|
+
/** Display label for the companion panel tab or tooltip. Anti-impersonation:
|
|
68
|
+
* may not pose as first-party Ryu/system chrome (see
|
|
69
|
+
* {@link labelImpersonatesSystemChrome}). */
|
|
70
|
+
label: import_zod.z.string().min(1).refine((value) => !labelImpersonatesSystemChrome(value), {
|
|
71
|
+
message: "companion label must not impersonate system chrome (must not contain 'ryu' or 'system')"
|
|
72
|
+
}),
|
|
73
|
+
/** Icon identifier resolved by the desktop shell. */
|
|
74
|
+
icon: import_zod.z.string().optional(),
|
|
75
|
+
/** Keyboard shortcut string (e.g. `"ctrl+shift+r"`). */
|
|
76
|
+
shortcut: import_zod.z.string().optional()
|
|
77
|
+
});
|
|
78
|
+
var TurnHookContributionSchema = import_zod.z.object({
|
|
79
|
+
/** Stable id for this hook (unique within the plugin). */
|
|
80
|
+
id: import_zod.z.string().min(1),
|
|
81
|
+
/** Turn boundary this fires on. Today only `"post_assistant_turn"`. */
|
|
82
|
+
on: import_zod.z.string().min(1).default("post_assistant_turn"),
|
|
83
|
+
/** The JS hook body executed in the sandbox (returns a directive). */
|
|
84
|
+
code: import_zod.z.string().min(1).optional(),
|
|
85
|
+
/** Path to the hook body, relative to the plugin root (`hooks/<name>.js`). */
|
|
86
|
+
code_file: import_zod.z.string().min(1).optional(),
|
|
87
|
+
/**
|
|
88
|
+
* Cheap pre-gate mirroring Core's `HookMatch` (serde name `match` on
|
|
89
|
+
* `TurnHookContribution.run_when`). MUST round-trip through this schema:
|
|
90
|
+
* `ryu pack`/`publish` persist `safeParse(...).data`, so a field missing here
|
|
91
|
+
* is silently STRIPPED before signing — a tool-gated `pre_tool_use` hook
|
|
92
|
+
* (e.g. `tools: ["bash*"]`) would lose its gate and run on EVERY tool call.
|
|
93
|
+
*/
|
|
94
|
+
match: import_zod.z.object({
|
|
95
|
+
/** Run only if the request set this composer flag true. */
|
|
96
|
+
flag: import_zod.z.string().optional(),
|
|
97
|
+
/** Run if the last user message starts with any of these prefixes. */
|
|
98
|
+
commands: import_zod.z.array(import_zod.z.string()).default([]),
|
|
99
|
+
/** Run if the plugin has stored state for this conversation. */
|
|
100
|
+
stateful: import_zod.z.boolean().default(false),
|
|
101
|
+
/** Run if `ctx.tool_name` matches any of these `*`-wildcard patterns. */
|
|
102
|
+
tools: import_zod.z.array(import_zod.z.string()).default([])
|
|
103
|
+
}).optional()
|
|
104
|
+
}).refine((h) => Boolean(h.code) !== Boolean(h.code_file), {
|
|
105
|
+
message: "a turn hook must declare exactly one of 'code' (inline body) or 'code_file' (path to hooks/<name>.js)",
|
|
106
|
+
path: ["code_file"]
|
|
107
|
+
});
|
|
108
|
+
var HookEventContributionSchema = import_zod.z.object({
|
|
109
|
+
/** Fully-qualified event id: `<plugin id>#<event name>`, e.g. `@acme/meetings#meeting.ended`. */
|
|
110
|
+
id: import_zod.z.string().min(1),
|
|
111
|
+
/** Human-readable title for the event picker. */
|
|
112
|
+
title: import_zod.z.string().min(1),
|
|
113
|
+
/** What the event means and when it fires. */
|
|
114
|
+
description: import_zod.z.string().optional(),
|
|
115
|
+
/** Example of the `ctx.event` payload. Documentation, not a validated schema. */
|
|
116
|
+
payload_example: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
|
|
117
|
+
});
|
|
118
|
+
var PiExtensionContributionSchema = import_zod.z.object({
|
|
119
|
+
/** Stable id for this extension within the plugin (`[a-z0-9][a-z0-9._-]*`). */
|
|
120
|
+
id: import_zod.z.string().min(1),
|
|
121
|
+
/** Path to the source, relative to the plugin root: `pi-extensions/<name>.ts`. */
|
|
122
|
+
file: import_zod.z.string().min(1),
|
|
123
|
+
/** Optional one-liner describing what the extension adds to the agent. */
|
|
124
|
+
description: import_zod.z.string().optional()
|
|
125
|
+
});
|
|
126
|
+
var OutputStyleContributionSchema = import_zod.z.object({
|
|
127
|
+
/** Stable id for this style within the plugin (`[a-z0-9][a-z0-9._-]*`). It is
|
|
128
|
+
* also the persisted selection key, so it must survive a settings key and a URL
|
|
129
|
+
* path. */
|
|
130
|
+
id: import_zod.z.string().min(1),
|
|
131
|
+
/** SOURCE form: path to the Markdown file, relative to the plugin root —
|
|
132
|
+
* exactly `output-styles/<name>.md`. `ryu pack` replaces this with `source`. */
|
|
133
|
+
file: import_zod.z.string().min(1).optional(),
|
|
134
|
+
/** WIRE form: the file's contents verbatim, frontmatter INCLUDED. The whole file
|
|
135
|
+
* rather than a pre-split body plus mirrored `name`/`description` keys, so a
|
|
136
|
+
* plugin style and a user's own `output-styles/*.md` go through one parser and
|
|
137
|
+
* the frontmatter stays the single source of truth for a style's metadata. */
|
|
138
|
+
source: import_zod.z.string().optional()
|
|
139
|
+
});
|
|
140
|
+
var DEFAULT_WIDGET_MIME = "text/html+skybridge";
|
|
141
|
+
var DEFAULT_WIDGET_DISPLAY_MODE = "inline";
|
|
142
|
+
var WidgetContributionSchema = import_zod.z.object({
|
|
143
|
+
/** The fully-qualified tool id whose result renders this widget. */
|
|
144
|
+
tool_id: import_zod.z.string().min(1),
|
|
145
|
+
/** `ui://widget/<slug>.html` — the widget resource uri. */
|
|
146
|
+
uri: import_zod.z.string().min(1),
|
|
147
|
+
/** Source entry (e.g. `src/apps/checklist/index.tsx`) for `ryu pack`. */
|
|
148
|
+
ui_entry: import_zod.z.string().optional(),
|
|
149
|
+
/** Widget MIME dialect (default `text/html+skybridge`). */
|
|
150
|
+
mime: import_zod.z.string().default(DEFAULT_WIDGET_MIME),
|
|
151
|
+
/** Default display mode (`inline` | `fullscreen` | `pip`). */
|
|
152
|
+
default_display_mode: import_zod.z.string().default(DEFAULT_WIDGET_DISPLAY_MODE)
|
|
153
|
+
});
|
|
154
|
+
var ChatWidgetTemplateSchema = import_zod.z.object({
|
|
155
|
+
id: import_zod.z.string().regex(/^[a-z0-9][a-z0-9._:-]*$/),
|
|
156
|
+
title: import_zod.z.string().min(1),
|
|
157
|
+
description: import_zod.z.string().optional(),
|
|
158
|
+
triggers: import_zod.z.array(import_zod.z.string()).default([]),
|
|
159
|
+
examples: import_zod.z.array(import_zod.z.string()).default([]),
|
|
160
|
+
backing: import_zod.z.object({
|
|
161
|
+
tool_id: import_zod.z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/).optional(),
|
|
162
|
+
view_id: import_zod.z.string().regex(/^[a-z0-9][a-z0-9._:-]*$/).optional()
|
|
163
|
+
}),
|
|
164
|
+
display_mode: import_zod.z.string().min(1),
|
|
165
|
+
safe_action_ids: import_zod.z.array(import_zod.z.string().regex(/^[a-z0-9][a-z0-9._-]*$/)).default([]),
|
|
166
|
+
availability: import_zod.z.string().default("available")
|
|
167
|
+
}).superRefine((value, ctx) => {
|
|
168
|
+
const count = Number(Boolean(value.backing.tool_id)) + Number(Boolean(value.backing.view_id));
|
|
169
|
+
if (count !== 1 && value.availability === "available") {
|
|
170
|
+
ctx.addIssue({
|
|
171
|
+
code: "custom",
|
|
172
|
+
path: ["backing"],
|
|
173
|
+
message: "available templates need exactly one backing tool_id or view_id"
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
if (count > 1) {
|
|
177
|
+
ctx.addIssue({
|
|
178
|
+
code: "custom",
|
|
179
|
+
path: ["backing"],
|
|
180
|
+
message: "backing must declare at most one of tool_id or view_id"
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
var ToolAppConfigSchema = import_zod.z.object({
|
|
185
|
+
/** MCP tool slug this runnable wraps — the fully-qualified `<server>.<name>` id. */
|
|
186
|
+
slug: import_zod.z.string().min(1),
|
|
187
|
+
/** The tool description the model reads when choosing it. Carried here because a
|
|
188
|
+
* packed app's manifest is the only channel (there is no `generated.rs`); Core's
|
|
189
|
+
* app-tool synthesis reads it back onto the `RegistryTool`. */
|
|
190
|
+
description: import_zod.z.string(),
|
|
191
|
+
/** JSON Schema for the tool's arguments (used for validation + the LLM tool
|
|
192
|
+
* surface). Snake_case to match `widget_accessible`. Absent = no arguments. */
|
|
193
|
+
input_schema: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional(),
|
|
194
|
+
/** True when calling this tool renders the app's widget (carries the template). */
|
|
195
|
+
widget: import_zod.z.boolean().default(false),
|
|
196
|
+
/** True when a mounted widget may `callTool` this tool (a companion), or when a
|
|
197
|
+
* render tool's widget may call any companion the app declares. */
|
|
198
|
+
widget_accessible: import_zod.z.boolean().default(false),
|
|
199
|
+
/** Optional status label shown while the render tool runs. */
|
|
200
|
+
invoking: import_zod.z.string().optional(),
|
|
201
|
+
/** Optional status label shown when the render tool finishes. */
|
|
202
|
+
invoked: import_zod.z.string().optional()
|
|
203
|
+
});
|
|
204
|
+
var SlashCommandOptionSchema = import_zod.z.object({
|
|
205
|
+
description: import_zod.z.string().optional(),
|
|
206
|
+
label: import_zod.z.string().min(1),
|
|
207
|
+
value: import_zod.z.string().min(1)
|
|
208
|
+
}).passthrough();
|
|
209
|
+
var SlashCommandCustomOptionSchema = import_zod.z.union([
|
|
210
|
+
import_zod.z.literal(true),
|
|
211
|
+
import_zod.z.object({
|
|
212
|
+
description: import_zod.z.string().optional(),
|
|
213
|
+
label: import_zod.z.string().min(1).optional()
|
|
214
|
+
}).passthrough()
|
|
215
|
+
]);
|
|
216
|
+
var SlashCommandArgumentSchema = import_zod.z.object({
|
|
217
|
+
allow_custom: import_zod.z.boolean().optional(),
|
|
218
|
+
custom: SlashCommandCustomOptionSchema.optional(),
|
|
219
|
+
description: import_zod.z.string().optional(),
|
|
220
|
+
name: import_zod.z.string().min(1),
|
|
221
|
+
options: import_zod.z.array(SlashCommandOptionSchema).optional()
|
|
222
|
+
}).passthrough();
|
|
223
|
+
var SlashCommandContributionSchema = import_zod.z.object({
|
|
224
|
+
args: import_zod.z.array(SlashCommandArgumentSchema).optional(),
|
|
225
|
+
body: import_zod.z.string().optional(),
|
|
226
|
+
command: import_zod.z.string().min(1),
|
|
227
|
+
description: import_zod.z.string().optional(),
|
|
228
|
+
id: import_zod.z.string().optional(),
|
|
229
|
+
parameters: import_zod.z.array(SlashCommandArgumentSchema).optional()
|
|
230
|
+
}).passthrough();
|
|
231
|
+
var ContributesSchema = import_zod.z.object({
|
|
232
|
+
turn_hooks: import_zod.z.array(TurnHookContributionSchema).default([]),
|
|
233
|
+
/** App events this plugin EMITS — the provider half of the hook system, whose
|
|
234
|
+
* consumer half is `turn_hooks`. Mirrors the Rust `Contributes.hook_events`;
|
|
235
|
+
* omitting it here would have `ryu pack` strip every declared event before
|
|
236
|
+
* signing, leaving an app that emits events nothing is allowed to subscribe to. */
|
|
237
|
+
hook_events: import_zod.z.array(HookEventContributionSchema).default([]),
|
|
238
|
+
composer_controls: import_zod.z.array(import_zod.z.record(import_zod.z.string(), import_zod.z.unknown())).default([]),
|
|
239
|
+
/** Chat feature descriptors whose behavior is implemented by the host shell.
|
|
240
|
+
* Mirrors the Rust-side `Contributes.chat_features`; keeping this field in the
|
|
241
|
+
* authoring schema prevents `ryu pack` from silently deleting a plugin's chat
|
|
242
|
+
* feature declaration before signing. */
|
|
243
|
+
chat_features: import_zod.z.array(import_zod.z.record(import_zod.z.string(), import_zod.z.unknown())).default([]),
|
|
244
|
+
settings_tabs: import_zod.z.array(import_zod.z.record(import_zod.z.string(), import_zod.z.unknown())).default([]),
|
|
245
|
+
slash_commands: import_zod.z.array(SlashCommandContributionSchema).default([]),
|
|
246
|
+
/** App widgets (Ryu Apps). Each binds a render tool id to its
|
|
247
|
+
* `ui://widget/<slug>.html` template. Mirrors the Rust-side
|
|
248
|
+
* `Contributes.widgets` field, without which the CLI's zod parse would strip
|
|
249
|
+
* every widget an app authored here declares. */
|
|
250
|
+
widgets: import_zod.z.array(WidgetContributionSchema).default([]),
|
|
251
|
+
/** Metadata-only chat widget templates. */
|
|
252
|
+
chat_widget_templates: import_zod.z.array(ChatWidgetTemplateSchema).optional(),
|
|
253
|
+
/** App-registered sidebar sections (header + live list) and buttons (single nav
|
|
254
|
+
* rows). Loosely typed here — the shell owns the spec vocabulary — matching how
|
|
255
|
+
* `composer_controls`/`settings_tabs` are declared. Mirrors the Rust-side
|
|
256
|
+
* `Contributes.sidebar_sections` / `Contributes.sidebar_buttons`. */
|
|
257
|
+
sidebar_sections: import_zod.z.array(import_zod.z.record(import_zod.z.string(), import_zod.z.unknown())).default([]),
|
|
258
|
+
sidebar_buttons: import_zod.z.array(import_zod.z.record(import_zod.z.string(), import_zod.z.unknown())).default([]),
|
|
259
|
+
/** App-registered workspace dock panels (a tab in the desktop's bottom/right
|
|
260
|
+
* dock). Loosely typed for the same reason as the surfaces above — the shell
|
|
261
|
+
* owns the `panel` render-mode vocabulary and the `spec` payload. Mirrors the
|
|
262
|
+
* Rust-side `Contributes.dock_panels`; without it the CLI's zod parse would
|
|
263
|
+
* strip the dock panel an app declares here. */
|
|
264
|
+
dock_panels: import_zod.z.array(import_zod.z.record(import_zod.z.string(), import_zod.z.unknown())).default([]),
|
|
265
|
+
/** App-registered live activities (the desktop "Dynamic Island" cards). Loosely
|
|
266
|
+
* typed for the same reason as the surfaces above — the shell owns the
|
|
267
|
+
* `spec` vocabulary. Mirrors the Rust-side `Contributes.live_activities`;
|
|
268
|
+
* without it the CLI's zod parse would strip every live activity an app
|
|
269
|
+
* declares here, so a packed bundle would ship a dock that silently stays
|
|
270
|
+
* empty. */
|
|
271
|
+
live_activities: import_zod.z.array(import_zod.z.record(import_zod.z.string(), import_zod.z.unknown())).default([]),
|
|
272
|
+
/** Deletable data categories the app owns — one "Delete all X" row in Settings
|
|
273
|
+
* → Danger Zone. Mirrors the Rust-side `Contributes.data_categories`; without
|
|
274
|
+
* it the CLI's zod parse would strip the declaration before signing, and the
|
|
275
|
+
* app's danger-zone row would simply never appear on any node that installed
|
|
276
|
+
* the packed bundle. Loosely typed here for the same reason as the surfaces
|
|
277
|
+
* above — Core is the layer that types it, because Core is the layer that has
|
|
278
|
+
* to resolve the id to something that can actually delete the rows. */
|
|
279
|
+
data_categories: import_zod.z.array(import_zod.z.record(import_zod.z.string(), import_zod.z.unknown())).default([]),
|
|
280
|
+
/** Language servers the plugin declares, keyed by server name — the mirror of
|
|
281
|
+
* Claude Code's `.lsp.json` / `lspServers`, so a config written for either host
|
|
282
|
+
* loads in the other. Mirrors the Rust-side `Contributes.lsp_servers`; without
|
|
283
|
+
* it the CLI's zod parse would strip every language server a plugin declares,
|
|
284
|
+
* before the manifest is signed.
|
|
285
|
+
*
|
|
286
|
+
* The ENTRY is deliberately a loose record and not a 13-field `z.object()`
|
|
287
|
+
* mirroring `LspServerContribution`. Claude Code owns this field vocabulary,
|
|
288
|
+
* not Ryu: a typed object here would strip a field from a newer Claude release
|
|
289
|
+
* on its way through `ryu pack` — the same silent-deletion bug this field
|
|
290
|
+
* exists to fix, one level down. Core is the layer that types it, because Core
|
|
291
|
+
* is the layer that acts on it. */
|
|
292
|
+
lsp_servers: import_zod.z.record(import_zod.z.string(), import_zod.z.record(import_zod.z.string(), import_zod.z.unknown())).default({}),
|
|
293
|
+
/** Pi extensions the plugin ships — TypeScript the managed `ryu` (Pi) agent
|
|
294
|
+
* loads at process start. Mirrors the Rust-side `Contributes.pi_extensions`;
|
|
295
|
+
* without it the CLI's zod parse would strip the declaration before signing,
|
|
296
|
+
* and the packed plugin would ship a `pi-extensions/` folder nothing loads.
|
|
297
|
+
*
|
|
298
|
+
* Typed (not a loose record) because Ryu owns this vocabulary — three fields,
|
|
299
|
+
* all of them Core-interpreted — unlike `lsp_servers`, whose entry shape is
|
|
300
|
+
* Claude Code's to extend. */
|
|
301
|
+
pi_extensions: import_zod.z.array(PiExtensionContributionSchema).default([]),
|
|
302
|
+
/** Output styles the plugin ships — Markdown files that rewrite the system
|
|
303
|
+
* prompt's voice. Mirrors the Rust-side `Contributes.output_styles`; without it
|
|
304
|
+
* the CLI's zod parse would strip the declaration, and `ryu pack` would sign a
|
|
305
|
+
* bundle whose styles simply do not exist. Worse than the usual case of that
|
|
306
|
+
* bug: the styles' `.md` files are not carried by the bundle either, so there
|
|
307
|
+
* would be no residue to notice — the plugin would install clean and contribute
|
|
308
|
+
* nothing. */
|
|
309
|
+
output_styles: import_zod.z.array(OutputStyleContributionSchema).default([]),
|
|
310
|
+
/** Per-message actions contributed by an enabled plugin. Kept as loose records
|
|
311
|
+
* so renderer-specific `kind`/`args` payloads survive `ryu pack` unchanged. */
|
|
312
|
+
message_actions: import_zod.z.array(import_zod.z.record(import_zod.z.string(), import_zod.z.unknown())).default([]),
|
|
313
|
+
/** Buttons contributed to the floating text-selection toolbar. Kept as loose
|
|
314
|
+
* records so host-owned dispatch args survive `ryu pack` unchanged. */
|
|
315
|
+
selection_actions: import_zod.z.array(import_zod.z.record(import_zod.z.string(), import_zod.z.unknown())).default([])
|
|
316
|
+
});
|
|
317
|
+
var SetupStepSchema = import_zod.z.object({
|
|
318
|
+
/** Card heading (e.g. the companion app name). */
|
|
319
|
+
title: import_zod.z.string().optional(),
|
|
320
|
+
/** Instruction body shown under the title. */
|
|
321
|
+
description: import_zod.z.string().optional(),
|
|
322
|
+
/** Label for the optional action button. */
|
|
323
|
+
actionLabel: import_zod.z.string().optional(),
|
|
324
|
+
/** URL the action button opens (validated server-side on publish). */
|
|
325
|
+
actionUrl: import_zod.z.string().optional()
|
|
326
|
+
});
|
|
327
|
+
var AppDependencySchema = import_zod.z.object({
|
|
328
|
+
/** The `id` of the plugin this one depends on. */
|
|
329
|
+
id: import_zod.z.string().min(1, "dependency id is required"),
|
|
330
|
+
/** Optional MINIMUM version the dependency must satisfy (`"1.2.0"` = `">=1.2.0"`). */
|
|
331
|
+
min_version: import_zod.z.string().min(1).optional()
|
|
332
|
+
});
|
|
333
|
+
var CapabilityReqSchema = import_zod.z.object({
|
|
334
|
+
/** Capability name (e.g. `"rag"`, `"memory"`, `"tts"`). Matched against a
|
|
335
|
+
* provider's `provides[].capability`. */
|
|
336
|
+
capability: import_zod.z.string().min(1, "capability name is required"),
|
|
337
|
+
/** Optional MINIMUM capability version the bound provider must satisfy
|
|
338
|
+
* (`"1.2.0"` = `">=1.2.0"`). Absent = any version. */
|
|
339
|
+
min_version: import_zod.z.string().min(1).optional()
|
|
340
|
+
});
|
|
341
|
+
var RequiresSchema = import_zod.z.object({
|
|
342
|
+
/** Other plugins that must be installed + enabled before this one enables. */
|
|
343
|
+
apps: import_zod.z.array(AppDependencySchema).default([]),
|
|
344
|
+
/**
|
|
345
|
+
* Abstract capability edges the broker resolves to a bound provider at
|
|
346
|
+
* enable time. Mirrors `Requires::capabilities` in
|
|
347
|
+
* `crates/ryu-kernel-contracts` — an `apps` edge names a specific plugin; a
|
|
348
|
+
* `capabilities` edge names a capability and lets the binding registry choose
|
|
349
|
+
* the provider. Each is lowered to an app-id graph edge once bound, so the
|
|
350
|
+
* enable/disable/cycle machinery is shared. Empty for the common case.
|
|
351
|
+
*/
|
|
352
|
+
capabilities: import_zod.z.array(CapabilityReqSchema).default([]),
|
|
353
|
+
/**
|
|
354
|
+
* Permission grants implied by the dependencies. Declaration only — the
|
|
355
|
+
* Gateway remains the sole authority on what a grant *allows*, and Core's
|
|
356
|
+
* dependency graph resolves `apps` only.
|
|
357
|
+
*/
|
|
358
|
+
grants: import_zod.z.array(import_zod.z.string()).default([])
|
|
359
|
+
});
|
|
360
|
+
var SurfaceSchema = import_zod.z.enum([
|
|
361
|
+
/** The Ryu Gateway. */
|
|
362
|
+
"gateway",
|
|
363
|
+
/** A headless Core node (no UI). */
|
|
364
|
+
"core",
|
|
365
|
+
/** The Tauri desktop app. */
|
|
366
|
+
"desktop",
|
|
367
|
+
/** The Electron dynamic-island companion. */
|
|
368
|
+
"island",
|
|
369
|
+
/** The Expo/React-Native mobile app. */
|
|
370
|
+
"mobile",
|
|
371
|
+
/** The browser extension. */
|
|
372
|
+
"extension",
|
|
373
|
+
/** The Next.js web app. */
|
|
374
|
+
"web",
|
|
375
|
+
/** The terminal client. */
|
|
376
|
+
"cli"
|
|
377
|
+
]);
|
|
378
|
+
var EnginesReqSchema = import_zod.z.object({
|
|
379
|
+
/** Floor for the terminal (`cli`) surface. */
|
|
380
|
+
cli: import_zod.z.string().optional(),
|
|
381
|
+
/** Floor for the Tauri desktop app. */
|
|
382
|
+
desktop: import_zod.z.string().optional(),
|
|
383
|
+
/** Floor for the browser extension. */
|
|
384
|
+
extension: import_zod.z.string().optional(),
|
|
385
|
+
/** Floor for the Ryu Gateway. */
|
|
386
|
+
gateway: import_zod.z.string().optional(),
|
|
387
|
+
/** Floor for the dynamic-island companion. */
|
|
388
|
+
island: import_zod.z.string().optional(),
|
|
389
|
+
/** Floor for the mobile app. */
|
|
390
|
+
mobile: import_zod.z.string().optional(),
|
|
391
|
+
/** Floor for the running **Core** (e.g. `">=0.3.0"`). Required. */
|
|
392
|
+
ryu: import_zod.z.string().min(1, "engines.ryu is required when engines is present"),
|
|
393
|
+
/** Floor for the Next.js web app. */
|
|
394
|
+
web: import_zod.z.string().optional()
|
|
395
|
+
});
|
|
396
|
+
var McpServerAuthSchema = import_zod.z.object({
|
|
397
|
+
client_id: import_zod.z.string().min(1).optional(),
|
|
398
|
+
type: import_zod.z.literal("oauth")
|
|
399
|
+
}).strict();
|
|
400
|
+
var McpServerDeclSchema = import_zod.z.object({
|
|
401
|
+
args: import_zod.z.array(import_zod.z.string()).default([]),
|
|
402
|
+
auth: McpServerAuthSchema.optional(),
|
|
403
|
+
command: import_zod.z.string().optional(),
|
|
404
|
+
command_env: import_zod.z.string().optional(),
|
|
405
|
+
description: import_zod.z.string().optional(),
|
|
406
|
+
enabled: import_zod.z.boolean().default(true),
|
|
407
|
+
env: import_zod.z.record(import_zod.z.string(), import_zod.z.string()).default({}),
|
|
408
|
+
headers: import_zod.z.record(import_zod.z.string(), import_zod.z.string()).default({}),
|
|
409
|
+
type: import_zod.z.enum(["stdio", "http", "streamable-http", "streamable_http", "sse"]).optional(),
|
|
410
|
+
url: import_zod.z.url().optional()
|
|
411
|
+
}).superRefine((server, context) => {
|
|
412
|
+
if (!(server.command || server.url)) {
|
|
413
|
+
context.addIssue({
|
|
414
|
+
code: "custom",
|
|
415
|
+
message: "an MCP server requires command or url"
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
if (!server.auth) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
if (server.command || server.type === "stdio" || !server.url) {
|
|
422
|
+
context.addIssue({
|
|
423
|
+
code: "custom",
|
|
424
|
+
message: "OAuth is supported only for remote HTTP MCP servers"
|
|
425
|
+
});
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (Object.keys(server.headers).some(
|
|
429
|
+
(name) => name.toLowerCase() === "authorization"
|
|
430
|
+
)) {
|
|
431
|
+
context.addIssue({
|
|
432
|
+
code: "custom",
|
|
433
|
+
message: "OAuth cannot be combined with a static Authorization header"
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
const url = new URL(server.url);
|
|
437
|
+
const loopback = url.hostname === "localhost" || url.hostname.startsWith("127.") || url.hostname === "[::1]" || url.hostname === "::1";
|
|
438
|
+
if (url.username || url.password || url.hash) {
|
|
439
|
+
context.addIssue({
|
|
440
|
+
code: "custom",
|
|
441
|
+
message: "OAuth MCP URLs cannot contain credentials or fragments"
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && loopback)) {
|
|
445
|
+
context.addIssue({
|
|
446
|
+
code: "custom",
|
|
447
|
+
message: "OAuth MCP URLs must use HTTPS except on loopback"
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
var PluginManifestSchema = import_zod.z.object({
|
|
452
|
+
/** Reverse-domain unique identifier (e.g. `"com.example.my-plugin"`). */
|
|
453
|
+
id: import_zod.z.string().min(1, "id is required"),
|
|
454
|
+
/** Human-readable display name shown in the plugin store / launcher. */
|
|
455
|
+
name: import_zod.z.string().min(1, "name is required"),
|
|
456
|
+
/**
|
|
457
|
+
* Semver version string (e.g. `"1.0.0"`). Core's loader rejects any manifest
|
|
458
|
+
* whose version is not valid semver; the regex here enforces the same rule at
|
|
459
|
+
* SDK-build time.
|
|
460
|
+
*/
|
|
461
|
+
version: import_zod.z.string().regex(
|
|
462
|
+
/^\d+\.\d+\.\d+(?:-[\w.]+)?(?:\+[\w.]+)?$/,
|
|
463
|
+
"version must be a valid semver string (e.g. 1.0.0)"
|
|
464
|
+
),
|
|
465
|
+
/** Core-owned release maturity metadata. The Rust contract validates the
|
|
466
|
+
* richer shape; the SDK authoring parser must preserve it for pack/publish. */
|
|
467
|
+
stability: import_zod.z.unknown().optional(),
|
|
468
|
+
/**
|
|
469
|
+
* Lower-case hex `sha256(utf8_bytes(ui_code))` binding the plugin's bundled
|
|
470
|
+
* sandboxed-UI code to this manifest. `ryu pack` / `ryu publish` compute it and
|
|
471
|
+
* write it here BEFORE the manifest is signed, so the hash rides INSIDE the
|
|
472
|
+
* Gateway-signed surface while the `ui_code` blob rides OUTSIDE it as payload;
|
|
473
|
+
* Core's install path recomputes the hash over the fetched code and rejects a
|
|
474
|
+
* mismatch fail-closed. Absent for a manifest-only plugin (no bundled UI).
|
|
475
|
+
* Mirrors Core's `PluginManifest.ui_code_sha256`.
|
|
476
|
+
*/
|
|
477
|
+
ui_code_sha256: import_zod.z.string().nullish(),
|
|
478
|
+
/** The Runnables this plugin bundles. */
|
|
479
|
+
runnables: import_zod.z.array(RunnableMetaSchema).default([]),
|
|
480
|
+
/**
|
|
481
|
+
* Permission grants this plugin declares it needs (e.g. `"mcp:web_search"`).
|
|
482
|
+
* Declarations only — grant enforcement is the Gateway's responsibility.
|
|
483
|
+
*/
|
|
484
|
+
permission_grants: import_zod.z.array(import_zod.z.string()).default([]),
|
|
485
|
+
/** Deny-by-default sandbox permissions. Core remains authoritative; this
|
|
486
|
+
* schema mirrors the fields so `ryu pack` cannot strip them. */
|
|
487
|
+
permissions: import_zod.z.object({
|
|
488
|
+
fs: import_zod.z.object({
|
|
489
|
+
read: import_zod.z.array(import_zod.z.string()).default([]),
|
|
490
|
+
write: import_zod.z.array(import_zod.z.string()).default([])
|
|
491
|
+
}).optional(),
|
|
492
|
+
child_process: import_zod.z.boolean().optional(),
|
|
493
|
+
run: import_zod.z.array(import_zod.z.string()).default([]),
|
|
494
|
+
network: import_zod.z.union([import_zod.z.boolean(), import_zod.z.array(import_zod.z.string())]).optional(),
|
|
495
|
+
tool: import_zod.z.array(import_zod.z.string()).default([])
|
|
496
|
+
}).optional(),
|
|
497
|
+
/** Core-owned permission presentation levels. Preserved verbatim here and
|
|
498
|
+
* validated by Core's authoritative manifest contract. */
|
|
499
|
+
permission_levels: import_zod.z.unknown().optional(),
|
|
500
|
+
/** Remote or stdio MCP servers registered by this plugin. */
|
|
501
|
+
mcp_servers: import_zod.z.record(import_zod.z.string(), McpServerDeclSchema).optional(),
|
|
502
|
+
/** Core-owned sidecar declarations. Their full process/HTTP schema stays in
|
|
503
|
+
* the Rust contract; this authoring layer must never strip them. */
|
|
504
|
+
sidecars: import_zod.z.unknown().optional(),
|
|
505
|
+
/**
|
|
506
|
+
* Optional Companion surface (an in-desktop overlay or sidebar panel).
|
|
507
|
+
* Absent when the plugin has no Companion surface.
|
|
508
|
+
*/
|
|
509
|
+
companion: CompanionSurfaceSchema.optional(),
|
|
510
|
+
/**
|
|
511
|
+
* VS-Code-style activation events (`"*"`, `"onStartup"`, `"onChat"`,
|
|
512
|
+
* `"onCommand:<id>"`). Empty = eager. Turn-hook plugins are driven by their
|
|
513
|
+
* enabled flag, so `["*"]` is the usual value.
|
|
514
|
+
*/
|
|
515
|
+
activation_events: import_zod.z.array(import_zod.z.string()).default([]),
|
|
516
|
+
/**
|
|
517
|
+
* Contribution points: server-side turn hooks + declarative UI widgets.
|
|
518
|
+
* Absent for a plugin that contributes nothing here.
|
|
519
|
+
*/
|
|
520
|
+
contributes: ContributesSchema.optional(),
|
|
521
|
+
/**
|
|
522
|
+
* **Plugin-to-plugin dependencies** — the other plugins this one needs. Core
|
|
523
|
+
* resolves them into a topological enable order (dependencies enable first;
|
|
524
|
+
* disabling one is refused while an enabled dependent needs it).
|
|
525
|
+
*
|
|
526
|
+
* Absent = **no dependencies**, the backward-compatible default. Kept
|
|
527
|
+
* `.optional()` (never defaulted) so a manifest that declares none serialises
|
|
528
|
+
* with no `requires` key at all, exactly like Core's
|
|
529
|
+
* `#[serde(skip_serializing_if = "Option::is_none")]`.
|
|
530
|
+
*/
|
|
531
|
+
requires: RequiresSchema.optional(),
|
|
532
|
+
/**
|
|
533
|
+
* Host surfaces this plugin runs on. **Empty or absent = runs on EVERY
|
|
534
|
+
* surface** — the backward-compatible default, which must never be read as
|
|
535
|
+
* "runs nowhere". Core filters only when the list is explicitly non-empty, and
|
|
536
|
+
* only at the read boundary (`GET /api/plugins`, keyed on `x-ryu-surface`), so
|
|
537
|
+
* an unsupported-target plugin stays installable and inspectable.
|
|
538
|
+
*/
|
|
539
|
+
targets: import_zod.z.array(SurfaceSchema).default([]),
|
|
540
|
+
/** Rich per-surface declarations (`support`, UI, contributed commands, …).
|
|
541
|
+
* Core owns and validates the nested vocabulary. */
|
|
542
|
+
surfaces: import_zod.z.unknown().optional(),
|
|
543
|
+
/**
|
|
544
|
+
* Host version floors — the semver requirement each surface must satisfy for
|
|
545
|
+
* this plugin to install. Mirrors Core's `EnginesReq`
|
|
546
|
+
* (`crates/core/kernel-contracts/src/manifest.rs`).
|
|
547
|
+
*
|
|
548
|
+
* `ryu` is the **Core** floor and the only required key (it is the legacy
|
|
549
|
+
* spelling; every manifest in the wild carries just that one). The rest are
|
|
550
|
+
* optional per-surface floors.
|
|
551
|
+
*
|
|
552
|
+
* REGRESSION THIS FIXES: `engines` was absent from this schema entirely, and
|
|
553
|
+
* zod strips unlisted keys — so `ryu pack` silently dropped the whole block
|
|
554
|
+
* from every bundle it produced. A plugin could declare a Core floor, publish,
|
|
555
|
+
* and ship a bundle that declared none. Any new host floor MUST be added here
|
|
556
|
+
* as well as in the Rust contract, or it does not survive packing.
|
|
557
|
+
*/
|
|
558
|
+
engines: EnginesReqSchema.optional(),
|
|
559
|
+
/**
|
|
560
|
+
* Optional per-item AFFILIATE terms: the commission paid to a referrer when a
|
|
561
|
+
* referred user buys this (paid) item. `value` is basis points for `percent`
|
|
562
|
+
* (2000 = 20%) or minor units (cents) for `flat`. Absent (or `enabled:false`)
|
|
563
|
+
* falls back to the seller org owner's default affiliate terms. This is the
|
|
564
|
+
* authoring surface for the marketplace publish body's `affiliate` field (the
|
|
565
|
+
* server re-validates it); it only takes effect on a paid item.
|
|
566
|
+
*/
|
|
567
|
+
affiliate: import_zod.z.object({
|
|
568
|
+
enabled: import_zod.z.boolean().default(false),
|
|
569
|
+
rule: import_zod.z.object({
|
|
570
|
+
type: import_zod.z.enum(["percent", "flat"]),
|
|
571
|
+
value: import_zod.z.number().nonnegative(),
|
|
572
|
+
recurring: import_zod.z.boolean().default(false),
|
|
573
|
+
durationMonths: import_zod.z.number().int().positive().nullish(),
|
|
574
|
+
fundedBy: import_zod.z.enum(["platform", "seller"]).default("platform")
|
|
575
|
+
}).optional()
|
|
576
|
+
}).optional(),
|
|
577
|
+
// ── Rich listing metadata (Phase 1.5) ──────────────────────────────────────
|
|
578
|
+
// Optional store-listing fields a plugin author declares so the marketplace
|
|
579
|
+
// detail dialog renders a richer App-Store-style preview. Field names align
|
|
580
|
+
// with the Claude `.claude-plugin/marketplace.json` plugin-entry standard where
|
|
581
|
+
// one exists (`author`, `homepage`, `keywords`, `category`, `license`); the
|
|
582
|
+
// rest are Ryu extensions. `ryu publish` forwards these FLAT into the publish
|
|
583
|
+
// body (not inside the signed manifest blob) so the control plane stores them.
|
|
584
|
+
// All optional + additive: a manifest omitting them still validates.
|
|
585
|
+
/** Longer plain/markdown description shown in the detail dialog. */
|
|
586
|
+
description: import_zod.z.string().optional(),
|
|
587
|
+
/** Short one-line pitch shown under the name (Ryu extension). */
|
|
588
|
+
tagline: import_zod.z.string().optional(),
|
|
589
|
+
/**
|
|
590
|
+
* Publisher identity. A bare string OR a Claude-style object; `ryu publish`
|
|
591
|
+
* resolves it to the display `developer` (`author.name` when an object).
|
|
592
|
+
*/
|
|
593
|
+
author: import_zod.z.union([
|
|
594
|
+
import_zod.z.string(),
|
|
595
|
+
import_zod.z.object({
|
|
596
|
+
name: import_zod.z.string(),
|
|
597
|
+
email: import_zod.z.string().optional(),
|
|
598
|
+
url: import_zod.z.string().optional()
|
|
599
|
+
})
|
|
600
|
+
]).optional(),
|
|
601
|
+
/** Public source repository URL (Claude/Codex `repository`). */
|
|
602
|
+
repository: import_zod.z.string().url().optional(),
|
|
603
|
+
/** True when the provider operates outside the local Ryu runtime. */
|
|
604
|
+
external: import_zod.z.boolean().optional(),
|
|
605
|
+
/** Project/marketing homepage — maps to the listing `website` (Claude field). */
|
|
606
|
+
homepage: import_zod.z.string().optional(),
|
|
607
|
+
/** Free-text search keywords (Claude field). */
|
|
608
|
+
keywords: import_zod.z.array(import_zod.z.string()).optional(),
|
|
609
|
+
/** Stable Marketplace filter labels (Ryu extension). */
|
|
610
|
+
tags: import_zod.z.array(import_zod.z.string()).optional(),
|
|
611
|
+
/** Taxonomy category beyond the runnable kinds (Claude field). */
|
|
612
|
+
category: import_zod.z.string().optional(),
|
|
613
|
+
/** SPDX-ish license identifier (Claude field). */
|
|
614
|
+
license: import_zod.z.string().optional(),
|
|
615
|
+
/** Square logo/icon URL for the listing card + detail header. */
|
|
616
|
+
iconUrl: import_zod.z.string().optional(),
|
|
617
|
+
/**
|
|
618
|
+
* Icon-primitive id for the listing card (Ryu extension): an Iconify/icons0
|
|
619
|
+
* `prefix:name`, a bare Hugeicons name, or a URL, resolved by the shared `Icon`
|
|
620
|
+
* primitive. A monochrome GLYPH masked with the current text colour — distinct
|
|
621
|
+
* from `iconUrl` (a raster logo). Falls back to `iconUrl` when omitted.
|
|
622
|
+
*/
|
|
623
|
+
icon: import_zod.z.string().optional(),
|
|
624
|
+
/** Optional detail-page hero banner metadata forwarded to the marketplace. */
|
|
625
|
+
banner: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional(),
|
|
626
|
+
/**
|
|
627
|
+
* Dithered-gradient background for the card's icon square (Ryu extension),
|
|
628
|
+
* mirroring dither-kit's `DitherGradient` props. `from`/`to` are a palette-colour
|
|
629
|
+
* name (`green`, `blue`, `purple`, `pink`, `orange`, `red`, `grey`) or a hue
|
|
630
|
+
* number (0–360); `direction` is where `to` ends up. Renders behind the glyph in
|
|
631
|
+
* place of a flat `iconBackground`; the render layer validates + falls back.
|
|
632
|
+
*/
|
|
633
|
+
iconDither: import_zod.z.object({
|
|
634
|
+
from: import_zod.z.union([import_zod.z.string(), import_zod.z.number()]),
|
|
635
|
+
to: import_zod.z.union([import_zod.z.string(), import_zod.z.number()]).optional(),
|
|
636
|
+
direction: import_zod.z.enum(["up", "down", "left", "right"]).optional()
|
|
637
|
+
}).optional(),
|
|
638
|
+
/** Ordered App-Store-style screenshot gallery URLs (Ryu extension). */
|
|
639
|
+
screenshots: import_zod.z.array(import_zod.z.string()).optional(),
|
|
640
|
+
/** Privacy policy URL surfaced on detail (Ryu extension). */
|
|
641
|
+
privacyPolicyUrl: import_zod.z.string().optional(),
|
|
642
|
+
/** Terms-of-service URL surfaced on detail (Ryu extension). */
|
|
643
|
+
termsOfServiceUrl: import_zod.z.string().optional(),
|
|
644
|
+
/**
|
|
645
|
+
* Human-readable capability strings (Ryu extension). When omitted the control
|
|
646
|
+
* plane derives a default from `permission_grants`, so declaring this is only
|
|
647
|
+
* needed to override the derived labels.
|
|
648
|
+
*/
|
|
649
|
+
capabilities: import_zod.z.array(import_zod.z.string()).optional(),
|
|
650
|
+
/** Example prompt chips shown on detail (Ryu extension). */
|
|
651
|
+
examplePrompts: import_zod.z.array(import_zod.z.string()).optional(),
|
|
652
|
+
/**
|
|
653
|
+
* Optional companion/config card (Ryu extension): a single setup step or an
|
|
654
|
+
* array of steps guiding the user through post-install configuration.
|
|
655
|
+
*/
|
|
656
|
+
setup: import_zod.z.union([SetupStepSchema, import_zod.z.array(SetupStepSchema)]).optional()
|
|
657
|
+
}).passthrough().superRefine((manifest, context) => {
|
|
658
|
+
const hasOAuthServer = Object.values(manifest.mcp_servers ?? {}).some(
|
|
659
|
+
(server) => server.auth?.type === "oauth"
|
|
660
|
+
);
|
|
661
|
+
if (!hasOAuthServer) {
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
for (const grant of ["mcp:server", "identity.read"]) {
|
|
665
|
+
if (!manifest.permission_grants.includes(grant)) {
|
|
666
|
+
context.addIssue({
|
|
667
|
+
code: "custom",
|
|
668
|
+
message: `OAuth MCP servers require the ${grant} permission grant`,
|
|
669
|
+
path: ["permission_grants"]
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
});
|
|
674
|
+
|
|
675
|
+
// src/runnable/tool.ts
|
|
676
|
+
function validateInput(input, schema, toolId) {
|
|
677
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) {
|
|
678
|
+
throw new Error(
|
|
679
|
+
`[ryu-sdk] Tool "${toolId}" input must be an object, got ${JSON.stringify(input)}`
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
const record = input;
|
|
683
|
+
for (const requiredKey of schema.required ?? []) {
|
|
684
|
+
if (!(requiredKey in record)) {
|
|
685
|
+
throw new Error(
|
|
686
|
+
`[ryu-sdk] Tool "${toolId}" input missing required field "${requiredKey}"`
|
|
687
|
+
);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
for (const [key, prop] of Object.entries(schema.properties)) {
|
|
691
|
+
if (!(key in record)) {
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
const value = record[key];
|
|
695
|
+
if (!checkType(value, prop.type)) {
|
|
696
|
+
throw new Error(
|
|
697
|
+
`[ryu-sdk] Tool "${toolId}" input field "${key}" expected type "${prop.type}", got ${JSON.stringify(value)}`
|
|
698
|
+
);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
function checkType(value, type) {
|
|
703
|
+
switch (type) {
|
|
704
|
+
case "string":
|
|
705
|
+
return typeof value === "string";
|
|
706
|
+
case "number":
|
|
707
|
+
case "integer":
|
|
708
|
+
return typeof value === "number";
|
|
709
|
+
case "boolean":
|
|
710
|
+
return typeof value === "boolean";
|
|
711
|
+
case "array":
|
|
712
|
+
return Array.isArray(value);
|
|
713
|
+
case "object":
|
|
714
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
715
|
+
default:
|
|
716
|
+
return false;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
function defineTool(options) {
|
|
720
|
+
const { description, id, name, schema, run } = options;
|
|
721
|
+
const code = `return await (${run.toString()})(input, host);`;
|
|
722
|
+
return {
|
|
723
|
+
id,
|
|
724
|
+
name,
|
|
725
|
+
kind: "tool",
|
|
726
|
+
schema,
|
|
727
|
+
...description === void 0 ? {} : { description },
|
|
728
|
+
code,
|
|
729
|
+
run(input, ctx) {
|
|
730
|
+
validateInput(input, schema, id);
|
|
731
|
+
return run(input, ctx);
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
function inlineToolRunnable(tool, options) {
|
|
736
|
+
return {
|
|
737
|
+
id: tool.id,
|
|
738
|
+
name: tool.name,
|
|
739
|
+
kind: "tool",
|
|
740
|
+
config: {
|
|
741
|
+
slug: tool.id,
|
|
742
|
+
backend: "inline_deno",
|
|
743
|
+
code: tool.code,
|
|
744
|
+
input_schema: tool.schema,
|
|
745
|
+
...options?.description === void 0 ? tool.description === void 0 ? {} : { description: tool.description } : { description: options.description },
|
|
746
|
+
...options?.outputSchema ? { output_schema: options.outputSchema } : {},
|
|
747
|
+
...options?.annotations ? { annotations: options.annotations } : {},
|
|
748
|
+
...options?.action === void 0 ? {} : { action: options.action },
|
|
749
|
+
...options?.needsApproval === void 0 ? {} : { needs_approval: options.needsApproval }
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// src/runnable/action.ts
|
|
755
|
+
function deriveAnnotations(effect, annotations) {
|
|
756
|
+
const resolved = {
|
|
757
|
+
...annotations,
|
|
758
|
+
readOnlyHint: annotations?.readOnlyHint ?? effect === "read",
|
|
759
|
+
destructiveHint: annotations?.destructiveHint ?? effect === "mutate"
|
|
760
|
+
};
|
|
761
|
+
if (effect === "read" && resolved.destructiveHint) {
|
|
762
|
+
throw new Error(
|
|
763
|
+
"[ryu-sdk] read actions cannot set annotations.destructiveHint=true"
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
if (effect === "mutate" && resolved.readOnlyHint) {
|
|
767
|
+
throw new Error(
|
|
768
|
+
"[ryu-sdk] mutate actions cannot set annotations.readOnlyHint=true"
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
return resolved;
|
|
772
|
+
}
|
|
773
|
+
function actionManifestEntry(action) {
|
|
774
|
+
const options = {
|
|
775
|
+
action: true,
|
|
776
|
+
annotations: action.annotations,
|
|
777
|
+
description: action.description,
|
|
778
|
+
needsApproval: action.needsApproval,
|
|
779
|
+
...action.outputSchema ? { outputSchema: action.outputSchema } : {}
|
|
780
|
+
};
|
|
781
|
+
return inlineToolRunnable(action, options);
|
|
782
|
+
}
|
|
783
|
+
function actionToManifest(action, options) {
|
|
784
|
+
const grants = [.../* @__PURE__ */ new Set([...options.grants ?? [], "tool:execute"])];
|
|
785
|
+
const raw = {
|
|
786
|
+
id: options.id,
|
|
787
|
+
name: options.name ?? action.name,
|
|
788
|
+
version: options.version,
|
|
789
|
+
runnables: [actionManifestEntry(action)],
|
|
790
|
+
permission_grants: grants,
|
|
791
|
+
activation_events: [...options.activationEvents ?? ["*"]],
|
|
792
|
+
targets: [...options.targets ?? []]
|
|
793
|
+
};
|
|
794
|
+
const result = PluginManifestSchema.safeParse(raw);
|
|
795
|
+
if (!result.success) {
|
|
796
|
+
const first = result.error.issues[0];
|
|
797
|
+
const field = first?.path.join(".") ?? "unknown";
|
|
798
|
+
const message = first?.message ?? "validation failed";
|
|
799
|
+
throw new Error(
|
|
800
|
+
`[ryu-sdk] action manifest validation failed at '${field}': ${message}`
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
return result.data;
|
|
804
|
+
}
|
|
805
|
+
function defineAction(options) {
|
|
806
|
+
const annotations = deriveAnnotations(options.effect, options.annotations);
|
|
807
|
+
const tool = defineTool({
|
|
808
|
+
description: options.description,
|
|
809
|
+
id: options.id,
|
|
810
|
+
name: options.name,
|
|
811
|
+
run: options.run,
|
|
812
|
+
schema: options.schema
|
|
813
|
+
});
|
|
814
|
+
const action = {
|
|
815
|
+
...tool,
|
|
816
|
+
action: true,
|
|
817
|
+
annotations,
|
|
818
|
+
description: options.description,
|
|
819
|
+
effect: options.effect,
|
|
820
|
+
needsApproval: options.needsApproval ?? false,
|
|
821
|
+
...options.outputSchema ? { outputSchema: options.outputSchema } : {},
|
|
822
|
+
toManifest(manifestOptions) {
|
|
823
|
+
return actionToManifest(action, manifestOptions);
|
|
824
|
+
},
|
|
825
|
+
toMcpTool(context) {
|
|
826
|
+
return {
|
|
827
|
+
name: action.id,
|
|
828
|
+
description: action.description,
|
|
829
|
+
inputSchema: action.schema,
|
|
830
|
+
run: (input) => action.run(input, context)
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
return action;
|
|
835
|
+
}
|
|
836
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
837
|
+
0 && (module.exports = {
|
|
838
|
+
defineAction
|
|
839
|
+
});
|