@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/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
# <img src="https://raw.githubusercontent.com/amajorai/ryu/main/.github/logo.png" width="50" align="middle" alt="" /> @
|
|
1
|
+
# <img src="https://raw.githubusercontent.com/amajorai/ryu/main/.github/logo.png" width="50" align="middle" alt="" /> @ryuhq/sdk
|
|
2
2
|
|
|
3
3
|
> Ryu's own developer SDK for authoring agents, workflows, tools, and skills. Part of [Ryu](../../README.md).
|
|
4
4
|
|
|
5
5
|
[](./LICENSE)
|
|
6
6
|
[](../../README.md)
|
|
7
7
|
|
|
8
|
-
`@
|
|
8
|
+
`@ryuhq/sdk` provides a canonical `defineAction` contract plus typed Runnable factories (`agent`, `workflow`, `tool`, `skill` and their builders), a gateway-mandatory model client so every model call routes through the Ryu Gateway, an MCP server/client, and a `ryu` CLI for packing and publishing plugin bundles. It is Runnable-native: reference the AI SDK / Mastra / ACP patterns, but depend on none of them. The native logic ships through a prebuilt addon, `@ryuhq/sdk-native` (the `crates/sdk/napi` binding).
|
|
9
9
|
|
|
10
10
|
**Tier:** OSS (Apache-2.0)
|
|
11
11
|
|
|
12
12
|
## Install / Build
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
bun add @
|
|
15
|
+
bun add @ryuhq/sdk
|
|
16
16
|
# build from source
|
|
17
17
|
bun run build # tsup → dist/
|
|
18
18
|
bun test
|
|
@@ -20,12 +20,74 @@ bun test
|
|
|
20
20
|
|
|
21
21
|
## What it provides
|
|
22
22
|
|
|
23
|
-
- **Runnable factories:** `agent`, `workflow`, `tool`, `skill` (and `AgentBuilder` / `WorkflowBuilder` / `ToolBuilder` / `SkillBuilder` / `PluginBuilder`) for the one Runnable contract (input to run to output).
|
|
24
|
-
- **
|
|
25
|
-
- **
|
|
26
|
-
- **
|
|
23
|
+
- **Runnable factories:** `agent`, `workflow`, `tool`, `skill` (and `AgentBuilder` / `WorkflowBuilder` / `ToolBuilder` / `SkillBuilder` / `PluginBuilder`) for the one Runnable contract (input to run to output). `defineApp` can attach a `ToolRunnable` so a widget's behavior ships as a grant-gated Core `inline_deno` tool.
|
|
24
|
+
- **Canonical Actions:** `defineAction` adds one description, input schema, output schema, effect, approval requirement, and implementation, then lowers it to a governed Ryu Tool/Runnable.
|
|
25
|
+
- **Action adapters:** the same contract is callable through Core HTTP (`@ryuhq/core-client/actions`), `ryu action`, the SDK MCP adapter, and A2A card discovery; calls remain Core-governed.
|
|
26
|
+
- **App-owned state:** `RunnableContext.storage` exposes the grant-gated `storage:kv` bridge for durable plugin state. Relational app data remains owned by an app sidecar.
|
|
27
|
+
- **Manifest model:** `PluginManifest` types + `PluginManifestSchema` / `validateManifestStrict` / `validatePluginId` (also exported from `@ryuhq/sdk/manifest`).
|
|
28
|
+
- **Gateway-mandatory model client:** chat types and a client where every model call routes through the Ryu Gateway (also from `@ryuhq/sdk/model`).
|
|
29
|
+
- **MCP server/client:** author (`McpServer`) and consume (`listTools` / `callTool`) MCP tool surfaces, via `@ryuhq/sdk/mcp`, `@ryuhq/sdk/mcp/server`, or `@ryuhq/sdk/mcp/client`.
|
|
30
|
+
- **Plugin host surface:** `RyuPlugin` / `PluginContext` / `definePlugin` types for the desktop companion host, via `@ryuhq/sdk/plugin`.
|
|
31
|
+
- **Runnables + builders as entries:** `@ryuhq/sdk/runnable` (the four kinds and their factories) and `@ryuhq/sdk/builder`.
|
|
27
32
|
- **CLI:** `bunx ryu pack <dir>` (and `ryu publish`) via the package `bin` entry.
|
|
28
33
|
|
|
34
|
+
## Canonical Actions
|
|
35
|
+
|
|
36
|
+
An Action is Ryu's public contract for a business operation. It keeps the implementation beside the
|
|
37
|
+
input/output contract and declares the effect that Core uses for read-only and approval enforcement.
|
|
38
|
+
The same Action can run in-process, be adapted to the SDK MCP server, or be lowered into an
|
|
39
|
+
installable `inline_deno` tool without maintaining a second implementation.
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { defineAction } from "@ryuhq/sdk";
|
|
43
|
+
|
|
44
|
+
export const createTicket = defineAction({
|
|
45
|
+
id: "action-create-ticket",
|
|
46
|
+
name: "Create Ticket",
|
|
47
|
+
description: "Create a support ticket for a customer.",
|
|
48
|
+
schema: {
|
|
49
|
+
type: "object",
|
|
50
|
+
properties: {
|
|
51
|
+
customer: { type: "string" },
|
|
52
|
+
summary: { type: "string" },
|
|
53
|
+
},
|
|
54
|
+
required: ["customer", "summary"],
|
|
55
|
+
},
|
|
56
|
+
outputSchema: {
|
|
57
|
+
type: "object",
|
|
58
|
+
properties: { id: { type: "string" } },
|
|
59
|
+
required: ["id"],
|
|
60
|
+
},
|
|
61
|
+
effect: "mutate",
|
|
62
|
+
needsApproval: true,
|
|
63
|
+
async run(input, _ctx) {
|
|
64
|
+
return { id: `${input.customer}:${input.summary}` };
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`createTicket.toManifest({ id: "com.example.support", version: "1.0.0" })` emits the existing
|
|
70
|
+
`kind: "tool"` manifest shape with `backend: "inline_deno"`, `output_schema`, MCP effect annotations,
|
|
71
|
+
and `needs_approval`. Core keeps the existing tool registry, Gateway grants, audit trail, and
|
|
72
|
+
approval inbox as the execution authorities; `defineAction` is the shared authoring seam, not a
|
|
73
|
+
second runtime.
|
|
74
|
+
|
|
75
|
+
The generated Action can also be invoked by `POST /api/actions/<id>` or `ryu action <id> <json>
|
|
76
|
+
--agent <agent-id>`. Both require the calling agent explicitly, so a node token cannot silently
|
|
77
|
+
become an unscoped action principal. A2A publishes enabled Actions as skills on the agent card and
|
|
78
|
+
delegates the actual request to the published agent.
|
|
79
|
+
|
|
80
|
+
## Managing a running node
|
|
81
|
+
|
|
82
|
+
`@ryuhq/sdk` is the *authoring* SDK — it builds, packs, and publishes plugin
|
|
83
|
+
bundles and runs Runnables in-process. If you want to **drive a running Ryu
|
|
84
|
+
node programmatically** (install/enable/disable plugins, manage agents, models,
|
|
85
|
+
skills, MCP servers, spaces, workflows, gateway config, chat against Core),
|
|
86
|
+
that surface lives in [`@ryuhq/core-client`](../../packages/core-client) — the
|
|
87
|
+
same client the desktop app, TUI, and CLI run on — plus `@ryuhq/client` for
|
|
88
|
+
embedded agent chat. Nothing here duplicates it; `@ryuhq/sdk` deliberately
|
|
89
|
+
stays the authoring layer.
|
|
90
|
+
|
|
29
91
|
## License
|
|
30
92
|
|
|
31
93
|
Apache-2.0. See [LICENSE](./LICENSE). © 2026 A Major Pte. Ltd.
|