@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/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](./LICENSE)
|
|
6
6
|
[](../../README.md)
|
|
7
7
|
|
|
8
|
-
`@ryuhq/sdk` provides typed Runnable factories (`agent`, `workflow`, `tool`, `skill`
|
|
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
|
|
|
@@ -20,7 +20,10 @@ 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).
|
|
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.
|
|
24
27
|
- **Manifest model:** `PluginManifest` types + `PluginManifestSchema` / `validateManifestStrict` / `validatePluginId` (also exported from `@ryuhq/sdk/manifest`).
|
|
25
28
|
- **Gateway-mandatory model client:** chat types and a client where every model call routes through the Ryu Gateway (also from `@ryuhq/sdk/model`).
|
|
26
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`.
|
|
@@ -28,6 +31,52 @@ bun test
|
|
|
28
31
|
- **Runnables + builders as entries:** `@ryuhq/sdk/runnable` (the four kinds and their factories) and `@ryuhq/sdk/builder`.
|
|
29
32
|
- **CLI:** `bunx ryu pack <dir>` (and `ryu publish`) via the package `bin` entry.
|
|
30
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
|
+
|
|
31
80
|
## Managing a running node
|
|
32
81
|
|
|
33
82
|
`@ryuhq/sdk` is the *authoring* SDK — it builds, packs, and publishes plugin
|