@sundaeswap/sprinkles 0.6.1 → 0.7.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 (153) hide show
  1. package/dist/cjs/Sprinkle/__tests__/action-integration.test.js +590 -0
  2. package/dist/cjs/Sprinkle/__tests__/action-integration.test.js.map +1 -0
  3. package/dist/cjs/Sprinkle/__tests__/action-registry.test.js +193 -0
  4. package/dist/cjs/Sprinkle/__tests__/action-registry.test.js.map +1 -0
  5. package/dist/cjs/Sprinkle/__tests__/action-runner.test.js +304 -0
  6. package/dist/cjs/Sprinkle/__tests__/action-runner.test.js.map +1 -0
  7. package/dist/cjs/Sprinkle/__tests__/builtin-actions.test.js +1110 -0
  8. package/dist/cjs/Sprinkle/__tests__/builtin-actions.test.js.map +1 -0
  9. package/dist/cjs/Sprinkle/__tests__/cli-adapter.test.js +722 -0
  10. package/dist/cjs/Sprinkle/__tests__/cli-adapter.test.js.map +1 -0
  11. package/dist/cjs/Sprinkle/__tests__/mcp-adapter.test.js +713 -0
  12. package/dist/cjs/Sprinkle/__tests__/mcp-adapter.test.js.map +1 -0
  13. package/dist/cjs/Sprinkle/__tests__/tui-helpers.test.js +334 -0
  14. package/dist/cjs/Sprinkle/__tests__/tui-helpers.test.js.map +1 -0
  15. package/dist/cjs/Sprinkle/__tests__/wallet-transaction-actions.test.js +749 -0
  16. package/dist/cjs/Sprinkle/__tests__/wallet-transaction-actions.test.js.map +1 -0
  17. package/dist/cjs/Sprinkle/actions/builtin/blaze-helper.js +61 -0
  18. package/dist/cjs/Sprinkle/actions/builtin/blaze-helper.js.map +1 -0
  19. package/dist/cjs/Sprinkle/actions/builtin/index.js +117 -0
  20. package/dist/cjs/Sprinkle/actions/builtin/index.js.map +1 -0
  21. package/dist/cjs/Sprinkle/actions/builtin/profile-actions.js +202 -0
  22. package/dist/cjs/Sprinkle/actions/builtin/profile-actions.js.map +1 -0
  23. package/dist/cjs/Sprinkle/actions/builtin/settings-actions.js +87 -0
  24. package/dist/cjs/Sprinkle/actions/builtin/settings-actions.js.map +1 -0
  25. package/dist/cjs/Sprinkle/actions/builtin/transaction-actions.js +345 -0
  26. package/dist/cjs/Sprinkle/actions/builtin/transaction-actions.js.map +1 -0
  27. package/dist/cjs/Sprinkle/actions/builtin/wallet-actions.js +212 -0
  28. package/dist/cjs/Sprinkle/actions/builtin/wallet-actions.js.map +1 -0
  29. package/dist/cjs/Sprinkle/actions/cli-adapter.js +372 -0
  30. package/dist/cjs/Sprinkle/actions/cli-adapter.js.map +1 -0
  31. package/dist/cjs/Sprinkle/actions/index.js +127 -0
  32. package/dist/cjs/Sprinkle/actions/index.js.map +1 -0
  33. package/dist/cjs/Sprinkle/actions/mcp-adapter.js +415 -0
  34. package/dist/cjs/Sprinkle/actions/mcp-adapter.js.map +1 -0
  35. package/dist/cjs/Sprinkle/actions/registry.js +92 -0
  36. package/dist/cjs/Sprinkle/actions/registry.js.map +1 -0
  37. package/dist/cjs/Sprinkle/actions/runner.js +190 -0
  38. package/dist/cjs/Sprinkle/actions/runner.js.map +1 -0
  39. package/dist/cjs/Sprinkle/actions/tui-helpers.js +96 -0
  40. package/dist/cjs/Sprinkle/actions/tui-helpers.js.map +1 -0
  41. package/dist/cjs/Sprinkle/actions/types.js +68 -0
  42. package/dist/cjs/Sprinkle/actions/types.js.map +1 -0
  43. package/dist/cjs/Sprinkle/index.js +412 -1
  44. package/dist/cjs/Sprinkle/index.js.map +1 -1
  45. package/dist/cjs/Sprinkle/prompts.js +12 -7
  46. package/dist/cjs/Sprinkle/prompts.js.map +1 -1
  47. package/dist/cjs/Sprinkle/type-guards.js +7 -1
  48. package/dist/cjs/Sprinkle/type-guards.js.map +1 -1
  49. package/dist/esm/Sprinkle/__tests__/action-integration.test.js +588 -0
  50. package/dist/esm/Sprinkle/__tests__/action-integration.test.js.map +1 -0
  51. package/dist/esm/Sprinkle/__tests__/action-registry.test.js +192 -0
  52. package/dist/esm/Sprinkle/__tests__/action-registry.test.js.map +1 -0
  53. package/dist/esm/Sprinkle/__tests__/action-runner.test.js +302 -0
  54. package/dist/esm/Sprinkle/__tests__/action-runner.test.js.map +1 -0
  55. package/dist/esm/Sprinkle/__tests__/builtin-actions.test.js +1107 -0
  56. package/dist/esm/Sprinkle/__tests__/builtin-actions.test.js.map +1 -0
  57. package/dist/esm/Sprinkle/__tests__/cli-adapter.test.js +720 -0
  58. package/dist/esm/Sprinkle/__tests__/cli-adapter.test.js.map +1 -0
  59. package/dist/esm/Sprinkle/__tests__/mcp-adapter.test.js +712 -0
  60. package/dist/esm/Sprinkle/__tests__/mcp-adapter.test.js.map +1 -0
  61. package/dist/esm/Sprinkle/__tests__/tui-helpers.test.js +332 -0
  62. package/dist/esm/Sprinkle/__tests__/tui-helpers.test.js.map +1 -0
  63. package/dist/esm/Sprinkle/__tests__/wallet-transaction-actions.test.js +747 -0
  64. package/dist/esm/Sprinkle/__tests__/wallet-transaction-actions.test.js.map +1 -0
  65. package/dist/esm/Sprinkle/actions/builtin/blaze-helper.js +55 -0
  66. package/dist/esm/Sprinkle/actions/builtin/blaze-helper.js.map +1 -0
  67. package/dist/esm/Sprinkle/actions/builtin/index.js +32 -0
  68. package/dist/esm/Sprinkle/actions/builtin/index.js.map +1 -0
  69. package/dist/esm/Sprinkle/actions/builtin/profile-actions.js +197 -0
  70. package/dist/esm/Sprinkle/actions/builtin/profile-actions.js.map +1 -0
  71. package/dist/esm/Sprinkle/actions/builtin/settings-actions.js +81 -0
  72. package/dist/esm/Sprinkle/actions/builtin/settings-actions.js.map +1 -0
  73. package/dist/esm/Sprinkle/actions/builtin/transaction-actions.js +340 -0
  74. package/dist/esm/Sprinkle/actions/builtin/transaction-actions.js.map +1 -0
  75. package/dist/esm/Sprinkle/actions/builtin/wallet-actions.js +207 -0
  76. package/dist/esm/Sprinkle/actions/builtin/wallet-actions.js.map +1 -0
  77. package/dist/esm/Sprinkle/actions/cli-adapter.js +361 -0
  78. package/dist/esm/Sprinkle/actions/cli-adapter.js.map +1 -0
  79. package/dist/esm/Sprinkle/actions/index.js +12 -0
  80. package/dist/esm/Sprinkle/actions/index.js.map +1 -0
  81. package/dist/esm/Sprinkle/actions/mcp-adapter.js +407 -0
  82. package/dist/esm/Sprinkle/actions/mcp-adapter.js.map +1 -0
  83. package/dist/esm/Sprinkle/actions/registry.js +85 -0
  84. package/dist/esm/Sprinkle/actions/registry.js.map +1 -0
  85. package/dist/esm/Sprinkle/actions/runner.js +182 -0
  86. package/dist/esm/Sprinkle/actions/runner.js.map +1 -0
  87. package/dist/esm/Sprinkle/actions/tui-helpers.js +91 -0
  88. package/dist/esm/Sprinkle/actions/tui-helpers.js.map +1 -0
  89. package/dist/esm/Sprinkle/actions/types.js +61 -0
  90. package/dist/esm/Sprinkle/actions/types.js.map +1 -0
  91. package/dist/esm/Sprinkle/index.js +260 -1
  92. package/dist/esm/Sprinkle/index.js.map +1 -1
  93. package/dist/esm/Sprinkle/prompts.js +12 -7
  94. package/dist/esm/Sprinkle/prompts.js.map +1 -1
  95. package/dist/esm/Sprinkle/type-guards.js +3 -0
  96. package/dist/esm/Sprinkle/type-guards.js.map +1 -1
  97. package/dist/types/Sprinkle/actions/builtin/blaze-helper.d.ts +39 -0
  98. package/dist/types/Sprinkle/actions/builtin/blaze-helper.d.ts.map +1 -0
  99. package/dist/types/Sprinkle/actions/builtin/index.d.ts +26 -0
  100. package/dist/types/Sprinkle/actions/builtin/index.d.ts.map +1 -0
  101. package/dist/types/Sprinkle/actions/builtin/profile-actions.d.ts +55 -0
  102. package/dist/types/Sprinkle/actions/builtin/profile-actions.d.ts.map +1 -0
  103. package/dist/types/Sprinkle/actions/builtin/settings-actions.d.ts +32 -0
  104. package/dist/types/Sprinkle/actions/builtin/settings-actions.d.ts.map +1 -0
  105. package/dist/types/Sprinkle/actions/builtin/transaction-actions.d.ts +70 -0
  106. package/dist/types/Sprinkle/actions/builtin/transaction-actions.d.ts.map +1 -0
  107. package/dist/types/Sprinkle/actions/builtin/wallet-actions.d.ts +50 -0
  108. package/dist/types/Sprinkle/actions/builtin/wallet-actions.d.ts.map +1 -0
  109. package/dist/types/Sprinkle/actions/cli-adapter.d.ts +104 -0
  110. package/dist/types/Sprinkle/actions/cli-adapter.d.ts.map +1 -0
  111. package/dist/types/Sprinkle/actions/index.d.ts +12 -0
  112. package/dist/types/Sprinkle/actions/index.d.ts.map +1 -0
  113. package/dist/types/Sprinkle/actions/mcp-adapter.d.ts +92 -0
  114. package/dist/types/Sprinkle/actions/mcp-adapter.d.ts.map +1 -0
  115. package/dist/types/Sprinkle/actions/registry.d.ts +42 -0
  116. package/dist/types/Sprinkle/actions/registry.d.ts.map +1 -0
  117. package/dist/types/Sprinkle/actions/runner.d.ts +45 -0
  118. package/dist/types/Sprinkle/actions/runner.d.ts.map +1 -0
  119. package/dist/types/Sprinkle/actions/tui-helpers.d.ts +53 -0
  120. package/dist/types/Sprinkle/actions/tui-helpers.d.ts.map +1 -0
  121. package/dist/types/Sprinkle/actions/types.d.ts +76 -0
  122. package/dist/types/Sprinkle/actions/types.d.ts.map +1 -0
  123. package/dist/types/Sprinkle/index.d.ts +81 -1
  124. package/dist/types/Sprinkle/index.d.ts.map +1 -1
  125. package/dist/types/Sprinkle/prompts.d.ts.map +1 -1
  126. package/dist/types/Sprinkle/type-guards.d.ts +4 -1
  127. package/dist/types/Sprinkle/type-guards.d.ts.map +1 -1
  128. package/dist/types/tsconfig.build.tsbuildinfo +1 -1
  129. package/package.json +9 -2
  130. package/src/Sprinkle/__tests__/action-integration.test.ts +558 -0
  131. package/src/Sprinkle/__tests__/action-registry.test.ts +187 -0
  132. package/src/Sprinkle/__tests__/action-runner.test.ts +324 -0
  133. package/src/Sprinkle/__tests__/builtin-actions.test.ts +1022 -0
  134. package/src/Sprinkle/__tests__/cli-adapter.test.ts +715 -0
  135. package/src/Sprinkle/__tests__/mcp-adapter.test.ts +718 -0
  136. package/src/Sprinkle/__tests__/tui-helpers.test.ts +325 -0
  137. package/src/Sprinkle/__tests__/wallet-transaction-actions.test.ts +695 -0
  138. package/src/Sprinkle/actions/builtin/blaze-helper.ts +89 -0
  139. package/src/Sprinkle/actions/builtin/index.ts +86 -0
  140. package/src/Sprinkle/actions/builtin/profile-actions.ts +229 -0
  141. package/src/Sprinkle/actions/builtin/settings-actions.ts +99 -0
  142. package/src/Sprinkle/actions/builtin/transaction-actions.ts +381 -0
  143. package/src/Sprinkle/actions/builtin/wallet-actions.ts +233 -0
  144. package/src/Sprinkle/actions/cli-adapter.ts +430 -0
  145. package/src/Sprinkle/actions/index.ts +32 -0
  146. package/src/Sprinkle/actions/mcp-adapter.ts +463 -0
  147. package/src/Sprinkle/actions/registry.ts +97 -0
  148. package/src/Sprinkle/actions/runner.ts +200 -0
  149. package/src/Sprinkle/actions/tui-helpers.ts +114 -0
  150. package/src/Sprinkle/actions/types.ts +91 -0
  151. package/src/Sprinkle/index.ts +351 -0
  152. package/src/Sprinkle/prompts.ts +118 -72
  153. package/src/Sprinkle/type-guards.ts +9 -0
@@ -0,0 +1,713 @@
1
+ "use strict";
2
+
3
+ var _bunTest = require("bun:test");
4
+ var _typebox = require("@sinclair/typebox");
5
+ var _index = require("../actions/index.js");
6
+ // ---------------------------------------------------------------------------
7
+ // typeboxToJsonSchema
8
+ // ---------------------------------------------------------------------------
9
+
10
+ (0, _bunTest.describe)("typeboxToJsonSchema", () => {
11
+ // --- Primitive types ---
12
+
13
+ (0, _bunTest.test)("String schema -> { type: 'string' }", () => {
14
+ (0, _bunTest.expect)((0, _index.typeboxToJsonSchema)(_typebox.Type.String())).toEqual({
15
+ type: "string"
16
+ });
17
+ });
18
+ (0, _bunTest.test)("Number schema -> { type: 'number' }", () => {
19
+ (0, _bunTest.expect)((0, _index.typeboxToJsonSchema)(_typebox.Type.Number())).toEqual({
20
+ type: "number"
21
+ });
22
+ });
23
+ (0, _bunTest.test)("Integer schema -> { type: 'integer' }", () => {
24
+ (0, _bunTest.expect)((0, _index.typeboxToJsonSchema)(_typebox.Type.Integer())).toEqual({
25
+ type: "integer"
26
+ });
27
+ });
28
+ (0, _bunTest.test)("Boolean schema -> { type: 'boolean' }", () => {
29
+ (0, _bunTest.expect)((0, _index.typeboxToJsonSchema)(_typebox.Type.Boolean())).toEqual({
30
+ type: "boolean"
31
+ });
32
+ });
33
+ (0, _bunTest.test)("Null schema -> { type: 'null' }", () => {
34
+ (0, _bunTest.expect)((0, _index.typeboxToJsonSchema)(_typebox.Type.Null())).toEqual({
35
+ type: "null"
36
+ });
37
+ });
38
+
39
+ // --- BigInt ---
40
+
41
+ (0, _bunTest.test)("BigInt schema -> { type: 'string', pattern: '^-?[0-9]+$' } with description", () => {
42
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.BigInt());
43
+ (0, _bunTest.expect)(result).toEqual({
44
+ type: "string",
45
+ pattern: "^-?[0-9]+$",
46
+ description: "BigInt value as string"
47
+ });
48
+ });
49
+
50
+ // --- Sensitive string ---
51
+
52
+ (0, _bunTest.test)("Sensitive string schema includes writeOnly: true", () => {
53
+ const schema = _typebox.Type.String({
54
+ sensitive: true
55
+ });
56
+ const result = (0, _index.typeboxToJsonSchema)(schema);
57
+ (0, _bunTest.expect)(result.type).toBe("string");
58
+ (0, _bunTest.expect)(result.writeOnly).toBe(true);
59
+ });
60
+ (0, _bunTest.test)("Non-sensitive string does not include writeOnly", () => {
61
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.String());
62
+ (0, _bunTest.expect)("writeOnly" in result).toBe(false);
63
+ });
64
+
65
+ // --- Array ---
66
+
67
+ (0, _bunTest.test)("Array of strings -> { type: 'array', items: { type: 'string' } }", () => {
68
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.Array(_typebox.Type.String()));
69
+ (0, _bunTest.expect)(result).toEqual({
70
+ type: "array",
71
+ items: {
72
+ type: "string"
73
+ }
74
+ });
75
+ });
76
+ (0, _bunTest.test)("Array of integers -> { type: 'array', items: { type: 'integer' } }", () => {
77
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.Array(_typebox.Type.Integer()));
78
+ (0, _bunTest.expect)(result).toEqual({
79
+ type: "array",
80
+ items: {
81
+ type: "integer"
82
+ }
83
+ });
84
+ });
85
+ (0, _bunTest.test)("Array of BigInt -> items maps BigInt to string pattern", () => {
86
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.Array(_typebox.Type.BigInt()));
87
+ (0, _bunTest.expect)(result).toEqual({
88
+ type: "array",
89
+ items: {
90
+ type: "string",
91
+ pattern: "^-?[0-9]+$",
92
+ description: "BigInt value as string"
93
+ }
94
+ });
95
+ });
96
+
97
+ // --- Object ---
98
+
99
+ (0, _bunTest.test)("Nested object -> recursive properties with required array", () => {
100
+ const schema = _typebox.Type.Object({
101
+ name: _typebox.Type.String(),
102
+ count: _typebox.Type.Integer()
103
+ });
104
+ const result = (0, _index.typeboxToJsonSchema)(schema);
105
+ (0, _bunTest.expect)(result.type).toBe("object");
106
+ (0, _bunTest.expect)(result.properties).toEqual({
107
+ name: {
108
+ type: "string"
109
+ },
110
+ count: {
111
+ type: "integer"
112
+ }
113
+ });
114
+ (0, _bunTest.expect)(result.required).toEqual(_bunTest.expect.arrayContaining(["name", "count"]));
115
+ });
116
+ (0, _bunTest.test)("Nested object with nested object property converts recursively", () => {
117
+ const schema = _typebox.Type.Object({
118
+ outer: _typebox.Type.String(),
119
+ inner: _typebox.Type.Object({
120
+ x: _typebox.Type.Number()
121
+ })
122
+ });
123
+ const result = (0, _index.typeboxToJsonSchema)(schema);
124
+ const props = result.properties;
125
+ (0, _bunTest.expect)(props.inner).toEqual({
126
+ type: "object",
127
+ properties: {
128
+ x: {
129
+ type: "number"
130
+ }
131
+ },
132
+ required: ["x"]
133
+ });
134
+ });
135
+
136
+ // --- Optional fields ---
137
+
138
+ (0, _bunTest.test)("Optional field is not listed in required array", () => {
139
+ const schema = _typebox.Type.Object({
140
+ required: _typebox.Type.String(),
141
+ optional: _typebox.Type.Optional(_typebox.Type.String())
142
+ });
143
+ const result = (0, _index.typeboxToJsonSchema)(schema);
144
+ const required = result.required;
145
+ (0, _bunTest.expect)(required).toContain("required");
146
+ (0, _bunTest.expect)(required).not.toContain("optional");
147
+ });
148
+ (0, _bunTest.test)("Object with all optional fields has no required array (or empty)", () => {
149
+ const schema = _typebox.Type.Object({
150
+ a: _typebox.Type.Optional(_typebox.Type.String()),
151
+ b: _typebox.Type.Optional(_typebox.Type.Number())
152
+ });
153
+ const result = (0, _index.typeboxToJsonSchema)(schema);
154
+ // Either no 'required' key or empty array
155
+ const required = result.required;
156
+ (0, _bunTest.expect)(!required || required.length === 0).toBe(true);
157
+ });
158
+
159
+ // --- Union types ---
160
+
161
+ (0, _bunTest.test)("Union of string and number -> { anyOf: [...] }", () => {
162
+ const schema = _typebox.Type.Union([_typebox.Type.String(), _typebox.Type.Number()]);
163
+ const result = (0, _index.typeboxToJsonSchema)(schema);
164
+ (0, _bunTest.expect)(result.anyOf).toEqual([{
165
+ type: "string"
166
+ }, {
167
+ type: "number"
168
+ }]);
169
+ });
170
+ (0, _bunTest.test)("Union containing BigInt -> BigInt member maps to string pattern", () => {
171
+ const schema = _typebox.Type.Union([_typebox.Type.String(), _typebox.Type.BigInt()]);
172
+ const result = (0, _index.typeboxToJsonSchema)(schema);
173
+ const anyOf = result.anyOf;
174
+ const bigIntMember = anyOf.find(m => m.pattern === "^-?[0-9]+$");
175
+ (0, _bunTest.expect)(bigIntMember).toBeDefined();
176
+ });
177
+
178
+ // --- Literal types ---
179
+
180
+ (0, _bunTest.test)("String literal -> { type: 'string', const: value }", () => {
181
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.Literal("hello"));
182
+ (0, _bunTest.expect)(result).toEqual({
183
+ type: "string",
184
+ const: "hello"
185
+ });
186
+ });
187
+ (0, _bunTest.test)("Number literal -> { type: 'number', const: value }", () => {
188
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.Literal(42));
189
+ (0, _bunTest.expect)(result).toEqual({
190
+ type: "number",
191
+ const: 42
192
+ });
193
+ });
194
+ (0, _bunTest.test)("Boolean literal -> { type: 'boolean', const: value }", () => {
195
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.Literal(true));
196
+ (0, _bunTest.expect)(result).toEqual({
197
+ type: "boolean",
198
+ const: true
199
+ });
200
+ });
201
+
202
+ // --- Annotations: description, title, examples, default ---
203
+
204
+ (0, _bunTest.test)("String schema preserves description annotation", () => {
205
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.String({
206
+ description: "A name"
207
+ }));
208
+ (0, _bunTest.expect)(result.description).toBe("A name");
209
+ });
210
+ (0, _bunTest.test)("String schema preserves title annotation", () => {
211
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.String({
212
+ title: "My Title"
213
+ }));
214
+ (0, _bunTest.expect)(result.title).toBe("My Title");
215
+ });
216
+ (0, _bunTest.test)("String schema preserves examples annotation", () => {
217
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.String({
218
+ examples: ["foo", "bar"]
219
+ }));
220
+ (0, _bunTest.expect)(result.examples).toEqual(["foo", "bar"]);
221
+ });
222
+ (0, _bunTest.test)("String schema preserves default annotation", () => {
223
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.String({
224
+ default: "fallback"
225
+ }));
226
+ (0, _bunTest.expect)(result.default).toBe("fallback");
227
+ });
228
+ (0, _bunTest.test)("Number schema preserves description annotation", () => {
229
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.Number({
230
+ description: "A count"
231
+ }));
232
+ (0, _bunTest.expect)(result.description).toBe("A count");
233
+ });
234
+ (0, _bunTest.test)("Number schema preserves minimum and maximum", () => {
235
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.Number({
236
+ minimum: 0,
237
+ maximum: 100
238
+ }));
239
+ (0, _bunTest.expect)(result.minimum).toBe(0);
240
+ (0, _bunTest.expect)(result.maximum).toBe(100);
241
+ });
242
+ (0, _bunTest.test)("Integer schema preserves minimum and maximum", () => {
243
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.Integer({
244
+ minimum: 1,
245
+ maximum: 10
246
+ }));
247
+ (0, _bunTest.expect)(result.minimum).toBe(1);
248
+ (0, _bunTest.expect)(result.maximum).toBe(10);
249
+ });
250
+ (0, _bunTest.test)("Boolean schema preserves default annotation", () => {
251
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.Boolean({
252
+ default: false
253
+ }));
254
+ (0, _bunTest.expect)(result.default).toBe(false);
255
+ });
256
+
257
+ // --- TypeBox internals stripped ---
258
+
259
+ (0, _bunTest.test)("Output does not contain [Kind] symbol key", () => {
260
+ const result = (0, _index.typeboxToJsonSchema)(_typebox.Type.String());
261
+ const keys = Object.keys(result);
262
+ (0, _bunTest.expect)(keys.every(k => !k.startsWith("["))).toBe(true);
263
+ });
264
+ (0, _bunTest.test)("Output does not contain $id key", () => {
265
+ const schema = _typebox.Type.String();
266
+ // Force-add a $id to confirm it is not emitted
267
+ schema.$id = "some-id";
268
+ const result = (0, _index.typeboxToJsonSchema)(schema);
269
+ (0, _bunTest.expect)("$id" in result).toBe(false);
270
+ });
271
+
272
+ // --- Unknown / empty schema fallback ---
273
+
274
+ (0, _bunTest.test)("Unknown TypeBox kind emits empty schema {} with console.warn", () => {
275
+ const warnSpy = (0, _bunTest.spyOn)(console, "warn").mockImplementation(() => {});
276
+ const unknownSchema = {
277
+ [Symbol.for("TypeBox.Kind")]: "UnknownKind"
278
+ };
279
+ const result = (0, _index.typeboxToJsonSchema)(unknownSchema);
280
+ (0, _bunTest.expect)(result).toEqual({});
281
+ (0, _bunTest.expect)(warnSpy).toHaveBeenCalled();
282
+ warnSpy.mockRestore();
283
+ });
284
+ });
285
+
286
+ // ---------------------------------------------------------------------------
287
+ // coerceMcpInput
288
+ // ---------------------------------------------------------------------------
289
+
290
+ (0, _bunTest.describe)("coerceMcpInput", () => {
291
+ // --- BigInt coercion ---
292
+
293
+ (0, _bunTest.test)("coerces BigInt string to BigInt when schema expects BigInt", () => {
294
+ const result = (0, _index.coerceMcpInput)("12345", _typebox.Type.BigInt());
295
+ (0, _bunTest.expect)(result).toBe(BigInt("12345"));
296
+ });
297
+ (0, _bunTest.test)("coerces negative BigInt string to BigInt", () => {
298
+ const result = (0, _index.coerceMcpInput)("-9876543210", _typebox.Type.BigInt());
299
+ (0, _bunTest.expect)(result).toBe(BigInt("-9876543210"));
300
+ });
301
+ (0, _bunTest.test)("coerces numeric input to BigInt via Math.trunc", () => {
302
+ const result = (0, _index.coerceMcpInput)(99.9, _typebox.Type.BigInt());
303
+ (0, _bunTest.expect)(result).toBe(BigInt(99));
304
+ });
305
+ (0, _bunTest.test)("passes through already-BigInt value unchanged", () => {
306
+ const result = (0, _index.coerceMcpInput)(BigInt(42), _typebox.Type.BigInt());
307
+ (0, _bunTest.expect)(result).toBe(BigInt(42));
308
+ });
309
+ (0, _bunTest.test)("non-numeric string left as-is for BigInt schema", () => {
310
+ const result = (0, _index.coerceMcpInput)("not-a-number", _typebox.Type.BigInt());
311
+ (0, _bunTest.expect)(result).toBe("not-a-number");
312
+ });
313
+
314
+ // --- Non-BigInt types passed through ---
315
+
316
+ (0, _bunTest.test)("string value passes through unchanged for String schema", () => {
317
+ const result = (0, _index.coerceMcpInput)("hello", _typebox.Type.String());
318
+ (0, _bunTest.expect)(result).toBe("hello");
319
+ });
320
+ (0, _bunTest.test)("number passes through unchanged for Number schema", () => {
321
+ const result = (0, _index.coerceMcpInput)(3.14, _typebox.Type.Number());
322
+ (0, _bunTest.expect)(result).toBe(3.14);
323
+ });
324
+ (0, _bunTest.test)("boolean passes through unchanged for Boolean schema", () => {
325
+ const result = (0, _index.coerceMcpInput)(true, _typebox.Type.Boolean());
326
+ (0, _bunTest.expect)(result).toBe(true);
327
+ });
328
+ (0, _bunTest.test)("null passes through unchanged", () => {
329
+ (0, _bunTest.expect)((0, _index.coerceMcpInput)(null, _typebox.Type.String())).toBeNull();
330
+ });
331
+ (0, _bunTest.test)("undefined passes through unchanged", () => {
332
+ (0, _bunTest.expect)((0, _index.coerceMcpInput)(undefined, _typebox.Type.String())).toBeUndefined();
333
+ });
334
+
335
+ // --- Nested objects ---
336
+
337
+ (0, _bunTest.test)("coerces BigInt fields within nested object", () => {
338
+ const schema = _typebox.Type.Object({
339
+ amount: _typebox.Type.BigInt(),
340
+ label: _typebox.Type.String()
341
+ });
342
+ const result = (0, _index.coerceMcpInput)({
343
+ amount: "99999999999999999",
344
+ label: "test"
345
+ }, schema);
346
+ (0, _bunTest.expect)(result.amount).toBe(BigInt("99999999999999999"));
347
+ (0, _bunTest.expect)(result.label).toBe("test");
348
+ });
349
+ (0, _bunTest.test)("non-BigInt fields in nested object pass through unchanged", () => {
350
+ const schema = _typebox.Type.Object({
351
+ name: _typebox.Type.String(),
352
+ count: _typebox.Type.Integer()
353
+ });
354
+ const input = {
355
+ name: "alice",
356
+ count: 5
357
+ };
358
+ const result = (0, _index.coerceMcpInput)(input, schema);
359
+ (0, _bunTest.expect)(result.name).toBe("alice");
360
+ (0, _bunTest.expect)(result.count).toBe(5);
361
+ });
362
+ (0, _bunTest.test)("coerces BigInt in nested object without touching other fields", () => {
363
+ const schema = _typebox.Type.Object({
364
+ stake: _typebox.Type.BigInt(),
365
+ fee: _typebox.Type.BigInt(),
366
+ memo: _typebox.Type.String()
367
+ });
368
+ const result = (0, _index.coerceMcpInput)({
369
+ stake: "1000",
370
+ fee: "50",
371
+ memo: "swap"
372
+ }, schema);
373
+ (0, _bunTest.expect)(result.stake).toBe(BigInt(1000));
374
+ (0, _bunTest.expect)(result.fee).toBe(BigInt(50));
375
+ (0, _bunTest.expect)(result.memo).toBe("swap");
376
+ });
377
+
378
+ // --- Arrays ---
379
+
380
+ (0, _bunTest.test)("coerces each BigInt string in array of BigInt", () => {
381
+ const schema = _typebox.Type.Array(_typebox.Type.BigInt());
382
+ const result = (0, _index.coerceMcpInput)(["100", "200", "300"], schema);
383
+ (0, _bunTest.expect)(result[0]).toBe(BigInt(100));
384
+ (0, _bunTest.expect)(result[1]).toBe(BigInt(200));
385
+ (0, _bunTest.expect)(result[2]).toBe(BigInt(300));
386
+ });
387
+ (0, _bunTest.test)("array of strings with String item schema passes through unchanged", () => {
388
+ const schema = _typebox.Type.Array(_typebox.Type.String());
389
+ const input = ["a", "b", "c"];
390
+ const result = (0, _index.coerceMcpInput)(input, schema);
391
+ (0, _bunTest.expect)(result).toEqual(["a", "b", "c"]);
392
+ });
393
+
394
+ // --- Union types ---
395
+
396
+ (0, _bunTest.test)("coerces BigInt string in Union containing BigInt", () => {
397
+ const schema = _typebox.Type.Union([_typebox.Type.String(), _typebox.Type.BigInt()]);
398
+ // A numeric string should be coerced to BigInt because there is a BigInt member
399
+ const result = (0, _index.coerceMcpInput)("12345", schema);
400
+ (0, _bunTest.expect)(result).toBe(BigInt(12345));
401
+ });
402
+ (0, _bunTest.test)("non-numeric string in Union passes through unchanged", () => {
403
+ const schema = _typebox.Type.Union([_typebox.Type.String(), _typebox.Type.BigInt()]);
404
+ const result = (0, _index.coerceMcpInput)("not-a-number", schema);
405
+ (0, _bunTest.expect)(result).toBe("not-a-number");
406
+ });
407
+ (0, _bunTest.test)("value in Union without BigInt member passes through unchanged", () => {
408
+ const schema = _typebox.Type.Union([_typebox.Type.String(), _typebox.Type.Number()]);
409
+ const result = (0, _index.coerceMcpInput)("hello", schema);
410
+ (0, _bunTest.expect)(result).toBe("hello");
411
+ });
412
+ });
413
+
414
+ // ---------------------------------------------------------------------------
415
+ // getMcpSdk -- lazy import and error handling
416
+ // ---------------------------------------------------------------------------
417
+
418
+ (0, _bunTest.describe)("getMcpSdk", () => {
419
+ (0, _bunTest.test)("returns an object with McpServer class when SDK is available", async () => {
420
+ // The SDK is installed as a dev dependency, so this should succeed
421
+ const sdk = await (0, _index.getMcpSdk)();
422
+ (0, _bunTest.expect)(sdk).toBeDefined();
423
+ (0, _bunTest.expect)(typeof sdk.McpServer).toBe("function");
424
+ });
425
+ });
426
+
427
+ // ---------------------------------------------------------------------------
428
+ // createMcpServer -- integration tests with mocked McpServer
429
+ // ---------------------------------------------------------------------------
430
+
431
+ (0, _bunTest.describe)("createMcpServer", () => {
432
+ // We mock the MCP SDK so that createMcpServer does not need a real stdio
433
+ // transport. The mock captures all tool registrations.
434
+
435
+ let registeredTools;
436
+ let mockMcpServer;
437
+ let MockMcpServerClass;
438
+ (0, _bunTest.beforeEach)(() => {
439
+ registeredTools = [];
440
+ mockMcpServer = {
441
+ tool: (name, description, schema, handler) => {
442
+ registeredTools.push({
443
+ name,
444
+ description,
445
+ schema,
446
+ handler
447
+ });
448
+ }
449
+ };
450
+ MockMcpServerClass = (0, _bunTest.mock)(() => mockMcpServer);
451
+ _bunTest.mock.module("@modelcontextprotocol/sdk/server/mcp.js", () => ({
452
+ McpServer: MockMcpServerClass
453
+ }));
454
+ });
455
+
456
+ // Helper: build a minimal Sprinkle-like mock
457
+ function makeMockSprinkle(actions) {
458
+ const actionMap = new Map(actions.map(a => [a.name, a]));
459
+ return {
460
+ listActions: () => actions,
461
+ getAction: name => actionMap.get(name),
462
+ settings: {}
463
+ };
464
+ }
465
+
466
+ // --- Tool registration ---
467
+
468
+ (0, _bunTest.test)("registers one MCP tool per action", async () => {
469
+ const sprinkle = makeMockSprinkle([{
470
+ name: "greet",
471
+ description: "Greets someone",
472
+ inputSchema: _typebox.Type.Object({
473
+ who: _typebox.Type.String()
474
+ }),
475
+ outputSchema: _typebox.Type.Object({
476
+ greeting: _typebox.Type.String()
477
+ }),
478
+ execute: async input => ({
479
+ greeting: `Hello, ${input.who}!`
480
+ })
481
+ }]);
482
+ await (0, _index.createMcpServer)(sprinkle, "test-server");
483
+ (0, _bunTest.expect)(registeredTools).toHaveLength(1);
484
+ });
485
+ (0, _bunTest.test)("tool name matches action name", async () => {
486
+ const sprinkle = makeMockSprinkle([{
487
+ name: "send-tx",
488
+ description: "Sends a transaction",
489
+ inputSchema: _typebox.Type.Object({}),
490
+ outputSchema: _typebox.Type.Object({}),
491
+ execute: async () => ({})
492
+ }]);
493
+ await (0, _index.createMcpServer)(sprinkle, "test-server");
494
+ (0, _bunTest.expect)(registeredTools[0].name).toBe("send-tx");
495
+ });
496
+ (0, _bunTest.test)("tool description matches action description", async () => {
497
+ const sprinkle = makeMockSprinkle([{
498
+ name: "get-balance",
499
+ description: "Gets the wallet balance",
500
+ inputSchema: _typebox.Type.Object({}),
501
+ outputSchema: _typebox.Type.Object({
502
+ balance: _typebox.Type.Number()
503
+ }),
504
+ execute: async () => ({
505
+ balance: 100
506
+ })
507
+ }]);
508
+ await (0, _index.createMcpServer)(sprinkle, "test-server");
509
+ (0, _bunTest.expect)(registeredTools[0].description).toBe("Gets the wallet balance");
510
+ });
511
+ (0, _bunTest.test)("registers all actions when multiple actions are provided", async () => {
512
+ const sprinkle = makeMockSprinkle([{
513
+ name: "action-one",
514
+ description: "First action",
515
+ inputSchema: _typebox.Type.Object({}),
516
+ outputSchema: _typebox.Type.Object({}),
517
+ execute: async () => ({})
518
+ }, {
519
+ name: "action-two",
520
+ description: "Second action",
521
+ inputSchema: _typebox.Type.Object({}),
522
+ outputSchema: _typebox.Type.Object({}),
523
+ execute: async () => ({})
524
+ }, {
525
+ name: "action-three",
526
+ description: "Third action",
527
+ inputSchema: _typebox.Type.Object({}),
528
+ outputSchema: _typebox.Type.Object({}),
529
+ execute: async () => ({})
530
+ }]);
531
+ await (0, _index.createMcpServer)(sprinkle, "test-server");
532
+ (0, _bunTest.expect)(registeredTools).toHaveLength(3);
533
+ const names = registeredTools.map(t => t.name);
534
+ (0, _bunTest.expect)(names).toContain("action-one");
535
+ (0, _bunTest.expect)(names).toContain("action-two");
536
+ (0, _bunTest.expect)(names).toContain("action-three");
537
+ });
538
+
539
+ // --- Empty action registry ---
540
+
541
+ (0, _bunTest.test)("server is created with no tools when action registry is empty", async () => {
542
+ const sprinkle = makeMockSprinkle([]);
543
+ await (0, _index.createMcpServer)(sprinkle, "test-server");
544
+ (0, _bunTest.expect)(registeredTools).toHaveLength(0);
545
+ });
546
+
547
+ // --- Tool input schema ---
548
+
549
+ (0, _bunTest.test)("tool input schema is the JSON Schema conversion of the action inputSchema", async () => {
550
+ const sprinkle = makeMockSprinkle([{
551
+ name: "typed-action",
552
+ description: "Has a typed input",
553
+ inputSchema: _typebox.Type.Object({
554
+ name: _typebox.Type.String(),
555
+ count: _typebox.Type.Integer()
556
+ }),
557
+ outputSchema: _typebox.Type.Object({}),
558
+ execute: async () => ({})
559
+ }]);
560
+ await (0, _index.createMcpServer)(sprinkle, "test-server");
561
+ const schema = registeredTools[0].schema;
562
+ (0, _bunTest.expect)(schema.type).toBe("object");
563
+ const props = schema.properties;
564
+ (0, _bunTest.expect)(props.name).toEqual({
565
+ type: "string"
566
+ });
567
+ (0, _bunTest.expect)(props.count).toEqual({
568
+ type: "integer"
569
+ });
570
+ });
571
+
572
+ // --- Tool handler: successful execution ---
573
+
574
+ (0, _bunTest.test)("tool handler returns content with JSON text on successful execution", async () => {
575
+ const sprinkle = makeMockSprinkle([{
576
+ name: "echo",
577
+ description: "Echoes input",
578
+ inputSchema: _typebox.Type.Object({
579
+ message: _typebox.Type.String()
580
+ }),
581
+ outputSchema: _typebox.Type.Object({
582
+ message: _typebox.Type.String()
583
+ }),
584
+ execute: async input => ({
585
+ message: input.message
586
+ })
587
+ }]);
588
+ await (0, _index.createMcpServer)(sprinkle, "test-server");
589
+ const handler = registeredTools[0].handler;
590
+ const response = await handler({
591
+ message: "hello"
592
+ });
593
+ (0, _bunTest.expect)(response.content).toHaveLength(1);
594
+ (0, _bunTest.expect)(response.content[0].type).toBe("text");
595
+ const data = JSON.parse(response.content[0].text);
596
+ (0, _bunTest.expect)(data.message).toBe("hello");
597
+ });
598
+ (0, _bunTest.test)("tool handler response does not include isError on success", async () => {
599
+ const sprinkle = makeMockSprinkle([{
600
+ name: "ok-action",
601
+ description: "Succeeds",
602
+ inputSchema: _typebox.Type.Object({}),
603
+ outputSchema: _typebox.Type.Object({
604
+ ok: _typebox.Type.Boolean()
605
+ }),
606
+ execute: async () => ({
607
+ ok: true
608
+ })
609
+ }]);
610
+ await (0, _index.createMcpServer)(sprinkle, "test-server");
611
+ const response = await registeredTools[0].handler({});
612
+ (0, _bunTest.expect)(response.isError).toBeUndefined();
613
+ });
614
+
615
+ // --- Tool handler: failed execution ---
616
+
617
+ (0, _bunTest.test)("tool handler returns isError: true on action failure", async () => {
618
+ const sprinkle = makeMockSprinkle([{
619
+ name: "fail-action",
620
+ description: "Always fails",
621
+ inputSchema: _typebox.Type.Object({}),
622
+ outputSchema: _typebox.Type.Object({}),
623
+ execute: async () => {
624
+ throw new Error("deliberate failure");
625
+ }
626
+ }]);
627
+ await (0, _index.createMcpServer)(sprinkle, "test-server");
628
+ const response = await registeredTools[0].handler({});
629
+ (0, _bunTest.expect)(response.isError).toBe(true);
630
+ });
631
+ (0, _bunTest.test)("tool handler error response contains error details in content text", async () => {
632
+ const sprinkle = makeMockSprinkle([{
633
+ name: "fail-action",
634
+ description: "Always fails",
635
+ inputSchema: _typebox.Type.Object({}),
636
+ outputSchema: _typebox.Type.Object({}),
637
+ execute: async () => {
638
+ throw new Error("something broke");
639
+ }
640
+ }]);
641
+ await (0, _index.createMcpServer)(sprinkle, "test-server");
642
+ const response = await registeredTools[0].handler({});
643
+ (0, _bunTest.expect)(response.content[0].type).toBe("text");
644
+ const errorData = JSON.parse(response.content[0].text);
645
+ (0, _bunTest.expect)(errorData.error).toBeDefined();
646
+ (0, _bunTest.expect)(errorData.error.message).toContain("something broke");
647
+ });
648
+ (0, _bunTest.test)("tool handler error response content has type: 'text'", async () => {
649
+ const sprinkle = makeMockSprinkle([{
650
+ name: "fail-action",
651
+ description: "Always fails",
652
+ inputSchema: _typebox.Type.Object({}),
653
+ outputSchema: _typebox.Type.Object({}),
654
+ execute: async () => {
655
+ throw new Error("oops");
656
+ }
657
+ }]);
658
+ await (0, _index.createMcpServer)(sprinkle, "test-server");
659
+ const response = await registeredTools[0].handler({});
660
+ (0, _bunTest.expect)(response.content[0].type).toBe("text");
661
+ });
662
+
663
+ // --- BigInt coercion in tool input ---
664
+
665
+ (0, _bunTest.test)("tool handler coerces BigInt string input before executing action", async () => {
666
+ let capturedInput;
667
+ const sprinkle = makeMockSprinkle([{
668
+ name: "bigint-action",
669
+ description: "Takes BigInt input",
670
+ inputSchema: _typebox.Type.Object({
671
+ amount: _typebox.Type.BigInt()
672
+ }),
673
+ outputSchema: _typebox.Type.Object({
674
+ amount: _typebox.Type.BigInt()
675
+ }),
676
+ execute: async input => {
677
+ capturedInput = input;
678
+ return {
679
+ amount: input.amount
680
+ };
681
+ }
682
+ }]);
683
+ await (0, _index.createMcpServer)(sprinkle, "test-server");
684
+ await registeredTools[0].handler({
685
+ amount: "999999999999999999"
686
+ });
687
+ (0, _bunTest.expect)(capturedInput.amount).toBe(BigInt("999999999999999999"));
688
+ });
689
+
690
+ // --- BigInt serialization in tool response ---
691
+
692
+ (0, _bunTest.test)("tool handler serializes BigInt values in response text", async () => {
693
+ const sprinkle = makeMockSprinkle([{
694
+ name: "bigint-return",
695
+ description: "Returns BigInt",
696
+ inputSchema: _typebox.Type.Object({}),
697
+ outputSchema: _typebox.Type.Object({
698
+ value: _typebox.Type.BigInt()
699
+ }),
700
+ execute: async () => ({
701
+ value: BigInt("9007199254740993")
702
+ })
703
+ }]);
704
+ await (0, _index.createMcpServer)(sprinkle, "test-server");
705
+ const response = await registeredTools[0].handler({});
706
+
707
+ // BigInt values cannot be JSON.stringify'd without a replacer.
708
+ // bigIntReplacer converts them to "Xn" strings.
709
+ const text = response.content[0].text;
710
+ (0, _bunTest.expect)(text).toContain("9007199254740993");
711
+ });
712
+ });
713
+ //# sourceMappingURL=mcp-adapter.test.js.map