@ryuhq/sdk 0.1.13 → 0.2.0

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 (90) hide show
  1. package/README.md +19 -6
  2. package/dist/agent-plugin.cjs +46 -0
  3. package/dist/agent-plugin.d.cts +42 -32
  4. package/dist/agent-plugin.d.ts +42 -32
  5. package/dist/agent-plugin.js +1 -1
  6. package/dist/agent.cjs +9 -0
  7. package/dist/agent.d.cts +377 -1
  8. package/dist/agent.d.ts +377 -1
  9. package/dist/agent.js +4 -2
  10. package/dist/app-Bkw7LlCK.d.ts +129 -0
  11. package/dist/app-DNaGmLVf.d.cts +129 -0
  12. package/dist/builder.cjs +1095 -0
  13. package/dist/builder.d.cts +212 -0
  14. package/dist/builder.d.ts +212 -0
  15. package/dist/builder.js +28 -0
  16. package/dist/chunk-A3RGEPDG.js +250 -0
  17. package/dist/chunk-FZSFZOIN.js +200 -0
  18. package/dist/{chunk-ODFEUVPW.js → chunk-HACAGK65.js} +1 -18
  19. package/dist/{chunk-AO2KJRDD.js → chunk-IEUQ3CDG.js} +125 -2
  20. package/dist/chunk-IKEDLLFY.js +19 -0
  21. package/dist/chunk-IOLP5FFE.js +354 -0
  22. package/dist/{chunk-G6FLVEC4.js → chunk-JX6DDRXV.js} +46 -0
  23. package/dist/chunk-T5676WL2.js +240 -0
  24. package/dist/chunk-TLDPEGC7.js +21 -0
  25. package/dist/chunk-TXSHHZF2.js +0 -0
  26. package/dist/{chunk-MTUBUPIV.js → chunk-ULSVL7EC.js} +8 -227
  27. package/dist/chunk-VLIRNNAE.js +154 -0
  28. package/dist/chunk-W3KPP4WN.js +135 -0
  29. package/dist/cli.cjs +258 -14
  30. package/dist/cli.js +96 -16
  31. package/dist/client-D5U6ssPc.d.cts +84 -0
  32. package/dist/client-D5U6ssPc.d.ts +84 -0
  33. package/dist/index.cjs +519 -5
  34. package/dist/index.d.cts +16 -632
  35. package/dist/index.d.ts +16 -632
  36. package/dist/index.js +63 -695
  37. package/dist/manifest.cjs +129 -3
  38. package/dist/manifest.d.cts +105 -2
  39. package/dist/manifest.d.ts +105 -2
  40. package/dist/manifest.js +7 -1
  41. package/dist/mcp/client.cjs +180 -0
  42. package/dist/mcp/client.d.cts +49 -0
  43. package/dist/mcp/client.d.ts +49 -0
  44. package/dist/mcp/client.js +10 -0
  45. package/dist/mcp/server.cjs +370 -0
  46. package/dist/mcp/server.d.cts +126 -0
  47. package/dist/mcp/server.d.ts +126 -0
  48. package/dist/mcp/server.js +9 -0
  49. package/dist/mcp.cjs +376 -0
  50. package/dist/mcp.d.cts +2 -0
  51. package/dist/mcp.d.ts +2 -0
  52. package/dist/mcp.js +17 -0
  53. package/dist/model.cjs +141 -0
  54. package/dist/model.d.cts +33 -0
  55. package/dist/model.d.ts +33 -0
  56. package/dist/model.js +18 -0
  57. package/dist/plugin.cjs +46 -0
  58. package/dist/plugin.d.cts +215 -0
  59. package/dist/plugin.d.ts +215 -0
  60. package/dist/plugin.js +8 -0
  61. package/dist/runnable.cjs +1230 -0
  62. package/dist/runnable.d.cts +271 -0
  63. package/dist/runnable.d.ts +271 -0
  64. package/dist/runnable.js +28 -0
  65. package/dist/{index-B6SkaAjJ.d.ts → tool-DSx2bFx8.d.ts} +35 -458
  66. package/dist/{index-BvAB5eMk.d.cts → tool-u-VR0fLF.d.cts} +35 -458
  67. package/package.json +38 -2
  68. package/src/agent/loop.test.ts +4 -4
  69. package/src/agent/tools.ts +3 -3
  70. package/src/agent-plugin.test.ts +58 -0
  71. package/src/agent-plugin.ts +108 -35
  72. package/src/cli/dev.test.ts +26 -47
  73. package/src/cli/dev.ts +10 -2
  74. package/src/cli.ts +98 -15
  75. package/src/exports-lockstep.test.ts +92 -0
  76. package/src/generated/plugin-manifest.ts +243 -27
  77. package/src/index.ts +35 -0
  78. package/src/manifest-schema.test.ts +30 -1
  79. package/src/manifest.fixtures.test.ts +13 -3
  80. package/src/manifest.test.ts +96 -10
  81. package/src/manifest.ts +334 -187
  82. package/src/mcp/index.ts +18 -0
  83. package/src/model/index.ts +22 -0
  84. package/src/plugin/ryu-plugin.ts +82 -0
  85. package/src/runnable/app.test.ts +2 -0
  86. package/src/runnable/app.ts +5 -2
  87. package/src/runnable/index.ts +2 -0
  88. package/src/runnable/primitives.ts +57 -0
  89. package/src/runnable/tool.ts +1 -1
  90. package/src/runnable/turn-hook.ts +4 -1
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Gateway-mandatory model client for the Ryu SDK.
3
+ *
4
+ * Rust-cored: this is a thin TypeScript wrapper over the `@ryuhq/sdk-native`
5
+ * addon's `ModelClient`, which is the `crates/ryu-sdk` Rust core. Every model
6
+ * call is routed by the Rust core to the Ryu gateway's OpenAI-compatible
7
+ * `/v1/chat/completions` endpoint; direct-provider base URLs are rejected at
8
+ * construction. No provider SDK or base URL is ever imported here.
9
+ *
10
+ * Usage:
11
+ *
12
+ * const model = defineModel("gpt-4o");
13
+ * const reply = await model.chat([{ role: "user", content: "hello" }]);
14
+ * for await (const delta of model.stream([{ role: "user", content: "hi" }])) {
15
+ * process.stdout.write(delta.content);
16
+ * }
17
+ */
18
+ /** A single message in a chat conversation. */
19
+ interface ChatMessage {
20
+ /** The message text. */
21
+ content: string;
22
+ /** The speaker: "system", "user", or "assistant". */
23
+ role: "system" | "user" | "assistant";
24
+ }
25
+ /** A streaming chat completion delta. */
26
+ interface ChatDelta {
27
+ /** Incremental text fragment from the model. */
28
+ content: string | null;
29
+ /** Non-null on the final chunk when `finish_reason` is set. */
30
+ finishReason: string | null;
31
+ }
32
+ /** Non-streaming chat completion result. */
33
+ interface ChatResult {
34
+ /** The full assistant reply text. */
35
+ content: string;
36
+ /** The gateway/model-reported finish reason. */
37
+ finishReason: string | null;
38
+ /** Usage stats as reported by the gateway (optional — gateway may omit). */
39
+ usage?: {
40
+ promptTokens: number;
41
+ completionTokens: number;
42
+ totalTokens: number;
43
+ };
44
+ }
45
+ /** Options accepted by `defineModel`. */
46
+ interface ModelClientOptions {
47
+ /**
48
+ * Gateway base URL (no trailing `/v1`). Defaults to `RYU_GATEWAY_URL` then
49
+ * the Rust core's default. Direct provider URLs are rejected at construction.
50
+ */
51
+ baseUrl?: string;
52
+ /**
53
+ * Bearer token forwarded to the gateway. Defaults to `RYU_GATEWAY_TOKEN`.
54
+ * This is the gateway token, never a provider API key.
55
+ */
56
+ token?: string;
57
+ }
58
+ /**
59
+ * A gateway-mandatory model client backed by the Rust core.
60
+ *
61
+ * All calls go through the native `ModelClient`; if the configured base URL is a
62
+ * direct provider, construction throws.
63
+ */
64
+ declare class ModelClient {
65
+ readonly model: string;
66
+ readonly baseUrl: string;
67
+ private readonly native;
68
+ constructor(model: string, options?: ModelClientOptions);
69
+ /** Send a non-streaming chat completion request to the gateway. */
70
+ chat(messages: ChatMessage[]): Promise<ChatResult>;
71
+ /** Send a streaming chat completion request, yielding deltas as they arrive. */
72
+ stream(messages: ChatMessage[]): AsyncGenerator<ChatDelta>;
73
+ }
74
+ /**
75
+ * Create a gateway-mandatory model client for `modelId`.
76
+ *
77
+ * const model = defineModel("gpt-4o");
78
+ * const model = defineModel("claude-3-5-sonnet", { baseUrl: "http://my-gateway:7981" });
79
+ *
80
+ * A direct provider URL throws immediately (egress enforcement in the Rust core).
81
+ */
82
+ declare function defineModel(modelId: string, options?: ModelClientOptions): ModelClient;
83
+
84
+ export { type ChatDelta as C, ModelClient as M, type ChatMessage as a, type ChatResult as b, type ModelClientOptions as c, defineModel as d };