@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/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="" />&nbsp; @ryu/sdk
1
+ # <img src="https://raw.githubusercontent.com/amajorai/ryu/main/.github/logo.png" width="50" align="middle" alt="" />&nbsp; @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](https://shieldcn.dev/badge/License-Apache--2.0-73DC8C.svg?logo=apache&logoColor=white)](./LICENSE)
6
6
  [![Stack](https://shieldcn.dev/badge/TypeScript-SDK-3178C6.svg?logo=typescript&logoColor=white)](../../README.md)
7
7
 
8
- `@ryu/sdk` provides typed Runnable factories (`agent`, `workflow`, `tool`, `skill` plus 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, `@ryu/sdk-native` (the `crates/ryu-sdk-napi` binding).
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 @ryu/sdk
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
- - **Manifest model:** `PluginManifest` types + `PluginManifestSchema` / `validateManifestStrict` / `validatePluginId` (also exported from `@ryu/sdk/manifest`).
25
- - **Gateway-mandatory model client:** chat types and a client where every model call routes through the Ryu Gateway.
26
- - **MCP server/client:** author and consume MCP tool surfaces.
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.