@neurosquad/card-sdk 1.0.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 (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +431 -0
  3. package/dist/card-sdk.js +5266 -0
  4. package/dist/cli.js +2838 -0
  5. package/dist/react.js +257 -0
  6. package/dist/testing.js +1150 -0
  7. package/dist/types/client/base64.d.ts +7 -0
  8. package/dist/types/client/card.d.ts +653 -0
  9. package/dist/types/client/channel.d.ts +49 -0
  10. package/dist/types/client/coalesce.d.ts +14 -0
  11. package/dist/types/client/connect.d.ts +39 -0
  12. package/dist/types/client/errors.d.ts +46 -0
  13. package/dist/types/client/helpers.d.ts +25 -0
  14. package/dist/types/client/net.d.ts +111 -0
  15. package/dist/types/client/theme.d.ts +31 -0
  16. package/dist/types/client/toolResult.d.ts +16 -0
  17. package/dist/types/contract/api.d.ts +812 -0
  18. package/dist/types/contract/index.d.ts +11 -0
  19. package/dist/types/contract/jsonSchema.d.ts +88 -0
  20. package/dist/types/contract/localized.d.ts +10 -0
  21. package/dist/types/contract/manifest.d.ts +179 -0
  22. package/dist/types/contract/network.d.ts +48 -0
  23. package/dist/types/contract/permissions.d.ts +180 -0
  24. package/dist/types/contract/ports.d.ts +237 -0
  25. package/dist/types/contract/protocol.d.ts +74 -0
  26. package/dist/types/contract/source.d.ts +111 -0
  27. package/dist/types/contract/theme.d.ts +21 -0
  28. package/dist/types/contract/version.d.ts +126 -0
  29. package/dist/types/i18n.d.ts +50 -0
  30. package/dist/types/index.d.ts +28 -0
  31. package/dist/types/react/index.d.ts +132 -0
  32. package/dist/types/testing/index.d.ts +7 -0
  33. package/dist/types/testing/mockHost.d.ts +315 -0
  34. package/dist/types/version.d.ts +2 -0
  35. package/dist/ui.css +581 -0
  36. package/package.json +77 -0
  37. package/schema/neurosquad-card.v1.json +434 -0
  38. package/templates/react/README.md +34 -0
  39. package/templates/react/_gitignore +10 -0
  40. package/templates/react/icon.png +0 -0
  41. package/templates/react/index.html +12 -0
  42. package/templates/react/neurosquad-card.json +94 -0
  43. package/templates/react/package.json +25 -0
  44. package/templates/react/src/App.tsx +131 -0
  45. package/templates/react/src/i18n.ts +61 -0
  46. package/templates/react/src/main.tsx +77 -0
  47. package/templates/react/src/styles.css +42 -0
  48. package/templates/react/tsconfig.json +18 -0
  49. package/templates/react/vite.config.ts +19 -0
  50. package/templates/vanilla/README.md +37 -0
  51. package/templates/vanilla/_gitignore +6 -0
  52. package/templates/vanilla/icon.png +0 -0
  53. package/templates/vanilla/index.html +41 -0
  54. package/templates/vanilla/main.js +256 -0
  55. package/templates/vanilla/neurosquad-card.json +94 -0
  56. package/templates/vanilla/style.css +41 -0
@@ -0,0 +1,434 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://neurosquad.ai/schemas/neurosquad-card.v1.json",
4
+ "title": "NeuroSquad custom card manifest",
5
+ "description": "neurosquad-card.json at the root of a NeuroSquad custom card package.",
6
+ "type": "object",
7
+ "required": ["manifestVersion", "name", "displayName", "version", "protocol"],
8
+ "additionalProperties": false,
9
+ "$defs": {
10
+ "localized80": {
11
+ "anyOf": [
12
+ {
13
+ "type": "string",
14
+ "minLength": 1,
15
+ "maxLength": 80
16
+ },
17
+ {
18
+ "type": "object",
19
+ "required": ["en"],
20
+ "additionalProperties": false,
21
+ "properties": {
22
+ "en": {
23
+ "type": "string",
24
+ "minLength": 1,
25
+ "maxLength": 80
26
+ },
27
+ "ru": {
28
+ "type": "string",
29
+ "minLength": 1,
30
+ "maxLength": 80
31
+ },
32
+ "zh": {
33
+ "type": "string",
34
+ "minLength": 1,
35
+ "maxLength": 80
36
+ }
37
+ }
38
+ }
39
+ ]
40
+ },
41
+ "localized300": {
42
+ "anyOf": [
43
+ {
44
+ "type": "string",
45
+ "minLength": 1,
46
+ "maxLength": 300
47
+ },
48
+ {
49
+ "type": "object",
50
+ "required": ["en"],
51
+ "additionalProperties": false,
52
+ "properties": {
53
+ "en": {
54
+ "type": "string",
55
+ "minLength": 1,
56
+ "maxLength": 300
57
+ },
58
+ "ru": {
59
+ "type": "string",
60
+ "minLength": 1,
61
+ "maxLength": 300
62
+ },
63
+ "zh": {
64
+ "type": "string",
65
+ "minLength": 1,
66
+ "maxLength": 300
67
+ }
68
+ }
69
+ }
70
+ ]
71
+ },
72
+ "localized500": {
73
+ "anyOf": [
74
+ {
75
+ "type": "string",
76
+ "minLength": 1,
77
+ "maxLength": 500
78
+ },
79
+ {
80
+ "type": "object",
81
+ "required": ["en"],
82
+ "additionalProperties": false,
83
+ "properties": {
84
+ "en": {
85
+ "type": "string",
86
+ "minLength": 1,
87
+ "maxLength": 500
88
+ },
89
+ "ru": {
90
+ "type": "string",
91
+ "minLength": 1,
92
+ "maxLength": 500
93
+ },
94
+ "zh": {
95
+ "type": "string",
96
+ "minLength": 1,
97
+ "maxLength": 500
98
+ }
99
+ }
100
+ }
101
+ ]
102
+ },
103
+ "size": {
104
+ "type": "object",
105
+ "required": ["w", "h"],
106
+ "additionalProperties": false,
107
+ "properties": {
108
+ "w": {
109
+ "type": "integer",
110
+ "minimum": 200,
111
+ "maximum": 2400
112
+ },
113
+ "h": {
114
+ "type": "integer",
115
+ "minimum": 120,
116
+ "maximum": 1800
117
+ }
118
+ }
119
+ },
120
+ "port": {
121
+ "type": "object",
122
+ "required": ["id", "label", "type"],
123
+ "additionalProperties": false,
124
+ "properties": {
125
+ "id": {
126
+ "type": "string",
127
+ "pattern": "^[a-z][a-z0-9-]{0,31}$"
128
+ },
129
+ "label": {
130
+ "$ref": "#/$defs/localized80"
131
+ },
132
+ "description": {
133
+ "$ref": "#/$defs/localized500"
134
+ },
135
+ "type": {
136
+ "type": "string",
137
+ "minLength": 1,
138
+ "maxLength": 97
139
+ },
140
+ "schema": {
141
+ "type": "object"
142
+ },
143
+ "mode": {
144
+ "enum": ["stream", "request"]
145
+ },
146
+ "response": {
147
+ "type": "object",
148
+ "required": ["type"],
149
+ "additionalProperties": false,
150
+ "properties": {
151
+ "type": {
152
+ "type": "string",
153
+ "minLength": 1,
154
+ "maxLength": 97
155
+ },
156
+ "schema": {
157
+ "type": "object"
158
+ }
159
+ }
160
+ },
161
+ "retain": {
162
+ "type": "boolean"
163
+ },
164
+ "default": {
165
+ "type": "boolean"
166
+ }
167
+ }
168
+ }
169
+ },
170
+ "properties": {
171
+ "$schema": {
172
+ "type": "string",
173
+ "maxLength": 500
174
+ },
175
+ "manifestVersion": {
176
+ "const": 1
177
+ },
178
+ "name": {
179
+ "type": "string",
180
+ "pattern": "^[a-z][a-z0-9-]{1,47}$"
181
+ },
182
+ "displayName": {
183
+ "$ref": "#/$defs/localized80"
184
+ },
185
+ "version": {
186
+ "type": "string",
187
+ "maxLength": 64,
188
+ "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$"
189
+ },
190
+ "description": {
191
+ "$ref": "#/$defs/localized300"
192
+ },
193
+ "author": {
194
+ "type": "object",
195
+ "required": ["name"],
196
+ "additionalProperties": false,
197
+ "properties": {
198
+ "name": {
199
+ "type": "string",
200
+ "minLength": 1,
201
+ "maxLength": 100
202
+ },
203
+ "url": {
204
+ "type": "string",
205
+ "format": "uri",
206
+ "maxLength": 500,
207
+ "pattern": "^https://"
208
+ }
209
+ }
210
+ },
211
+ "license": {
212
+ "type": "string",
213
+ "minLength": 1,
214
+ "maxLength": 100
215
+ },
216
+ "homepage": {
217
+ "type": "string",
218
+ "format": "uri",
219
+ "maxLength": 500,
220
+ "pattern": "^https://"
221
+ },
222
+ "icon": {
223
+ "type": "string",
224
+ "minLength": 1,
225
+ "maxLength": 240
226
+ },
227
+ "protocol": {
228
+ "type": "integer",
229
+ "minimum": 1,
230
+ "maximum": 1000
231
+ },
232
+ "minAppVersion": {
233
+ "type": "string",
234
+ "maxLength": 64,
235
+ "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$"
236
+ },
237
+ "entry": {
238
+ "type": "string",
239
+ "minLength": 1,
240
+ "maxLength": 240
241
+ },
242
+ "card": {
243
+ "type": "object",
244
+ "additionalProperties": false,
245
+ "properties": {
246
+ "defaultSize": {
247
+ "$ref": "#/$defs/size"
248
+ },
249
+ "minSize": {
250
+ "$ref": "#/$defs/size"
251
+ },
252
+ "maxSize": {
253
+ "$ref": "#/$defs/size"
254
+ }
255
+ }
256
+ },
257
+ "permissions": {
258
+ "type": "array",
259
+ "maxItems": 32,
260
+ "items": {
261
+ "anyOf": [
262
+ {
263
+ "type": "string",
264
+ "minLength": 1,
265
+ "maxLength": 64
266
+ },
267
+ {
268
+ "type": "object",
269
+ "required": ["id"],
270
+ "additionalProperties": false,
271
+ "properties": {
272
+ "id": {
273
+ "type": "string",
274
+ "minLength": 1,
275
+ "maxLength": 64
276
+ },
277
+ "hosts": {
278
+ "type": "array",
279
+ "maxItems": 32,
280
+ "items": {
281
+ "type": "string",
282
+ "minLength": 1,
283
+ "maxLength": 260
284
+ }
285
+ },
286
+ "reason": {
287
+ "$ref": "#/$defs/localized300"
288
+ },
289
+ "optional": {
290
+ "type": "boolean"
291
+ }
292
+ }
293
+ }
294
+ ]
295
+ }
296
+ },
297
+ "settings": {
298
+ "type": "array",
299
+ "maxItems": 40,
300
+ "items": {
301
+ "type": "object",
302
+ "required": ["key", "type", "label"],
303
+ "additionalProperties": false,
304
+ "properties": {
305
+ "key": {
306
+ "type": "string",
307
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"
308
+ },
309
+ "type": {
310
+ "enum": ["string", "text", "number", "boolean", "select", "secret", "color"]
311
+ },
312
+ "label": {
313
+ "$ref": "#/$defs/localized80"
314
+ },
315
+ "description": {
316
+ "$ref": "#/$defs/localized300"
317
+ },
318
+ "default": {
319
+ "type": ["string", "number", "boolean"]
320
+ },
321
+ "required": {
322
+ "type": "boolean"
323
+ },
324
+ "scope": {
325
+ "enum": ["instance", "package"]
326
+ },
327
+ "placeholder": {
328
+ "$ref": "#/$defs/localized80"
329
+ },
330
+ "maxLength": {
331
+ "type": "integer",
332
+ "minimum": 1,
333
+ "maximum": 100000
334
+ },
335
+ "min": {
336
+ "type": "number"
337
+ },
338
+ "max": {
339
+ "type": "number"
340
+ },
341
+ "step": {
342
+ "type": "number",
343
+ "exclusiveMinimum": 0
344
+ },
345
+ "options": {
346
+ "type": "array",
347
+ "minItems": 1,
348
+ "maxItems": 50,
349
+ "items": {
350
+ "type": "object",
351
+ "required": ["value", "label"],
352
+ "additionalProperties": false,
353
+ "properties": {
354
+ "value": {
355
+ "type": "string",
356
+ "maxLength": 200
357
+ },
358
+ "label": {
359
+ "$ref": "#/$defs/localized80"
360
+ }
361
+ }
362
+ }
363
+ }
364
+ }
365
+ }
366
+ },
367
+ "ports": {
368
+ "type": "object",
369
+ "additionalProperties": false,
370
+ "properties": {
371
+ "inputs": {
372
+ "type": "array",
373
+ "maxItems": 16,
374
+ "items": {
375
+ "$ref": "#/$defs/port"
376
+ }
377
+ },
378
+ "outputs": {
379
+ "type": "array",
380
+ "maxItems": 16,
381
+ "items": {
382
+ "$ref": "#/$defs/port"
383
+ }
384
+ }
385
+ }
386
+ },
387
+ "tools": {
388
+ "type": "array",
389
+ "maxItems": 32,
390
+ "items": {
391
+ "type": "object",
392
+ "required": ["name", "description", "inputSchema"],
393
+ "additionalProperties": false,
394
+ "properties": {
395
+ "name": {
396
+ "type": "string",
397
+ "pattern": "^[a-z][a-z0-9_]{0,39}$"
398
+ },
399
+ "title": {
400
+ "type": "string",
401
+ "minLength": 1,
402
+ "maxLength": 80
403
+ },
404
+ "description": {
405
+ "type": "string",
406
+ "minLength": 1,
407
+ "maxLength": 2000
408
+ },
409
+ "inputSchema": {
410
+ "type": "object"
411
+ },
412
+ "readOnly": {
413
+ "type": "boolean"
414
+ },
415
+ "timeoutMs": {
416
+ "type": "integer",
417
+ "minimum": 1000,
418
+ "maximum": 120000
419
+ }
420
+ }
421
+ }
422
+ },
423
+ "keywords": {
424
+ "type": "array",
425
+ "maxItems": 20,
426
+ "uniqueItems": true,
427
+ "items": {
428
+ "type": "string",
429
+ "minLength": 1,
430
+ "maxLength": 40
431
+ }
432
+ }
433
+ }
434
+ }
@@ -0,0 +1,34 @@
1
+ # __CARD_DISPLAY_NAME__
2
+
3
+ A custom card for [NeuroSquad](https://neurosquad.ai), made with `@neurosquad/card-sdk`
4
+ (React + Vite template).
5
+
6
+ ## Develop
7
+
8
+ ```sh
9
+ npm install
10
+ npm run dev # preview in the browser against a mock host with sample agents
11
+ ```
12
+
13
+ Live in the app:
14
+
15
+ 1. In NeuroSquad: **Settings → Custom cards → Developer mode**.
16
+ 2. `npx neurosquad-card dev` — it runs `npm run watch` (rebuilds `dist/` on save),
17
+ links this folder into the app (confirm there) and prints the card's log.
18
+ Add the card from the canvas: **+ → Custom card…**.
19
+
20
+ ## Check and share
21
+
22
+ ```sh
23
+ npm run build # dist/ — the app loads dist/index.html (see "entry" in the manifest)
24
+ npm run validate # the app's own checks + the install dialog preview
25
+ npm run pack # what would be installed, and the tree hash
26
+ ```
27
+
28
+ **Commit `dist/`.** NeuroSquad installs straight from the GitHub repository and
29
+ does not run your build. People install the card by pasting `owner/repo` (or
30
+ `owner/repo/path/to/folder`) into **Settings → Custom cards**.
31
+
32
+ Card code runs in a sandbox: no inline scripts, no external resources (Vite
33
+ bundles everything), network only through `card.net.fetch` to hosts declared in
34
+ the `network` permission.
@@ -0,0 +1,10 @@
1
+ node_modules
2
+ # packed archives (neurosquad-card pack)
3
+ *.tgz
4
+ .DS_Store
5
+ # secrets never go into a card package (pack refuses them anyway)
6
+ .env*
7
+ !.env.example
8
+ # dist/ is NOT ignored: the app installs the built card from the repository.
9
+ # The negation keeps it even inside a parent repository that ignores dist.
10
+ !dist/
Binary file
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>__CARD_DISPLAY_NAME__</title>
7
+ </head>
8
+ <body class="ns-kit">
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,94 @@
1
+ {
2
+ "$schema": "./node_modules/@neurosquad/card-sdk/schema/neurosquad-card.v1.json",
3
+ "manifestVersion": 1,
4
+ "name": "__CARD_NAME__",
5
+ "displayName": "__CARD_DISPLAY_NAME__",
6
+ "version": "0.1.0",
7
+ "protocol": 1,
8
+ "description": "A starter NeuroSquad card (React): live agent statuses, a scratchpad that is saved, a port and a tool for connected agents.",
9
+ "license": "MIT",
10
+ "icon": "icon.png",
11
+ "entry": "dist/index.html",
12
+ "card": {
13
+ "defaultSize": {
14
+ "w": 420,
15
+ "h": 360
16
+ },
17
+ "minSize": {
18
+ "w": 280,
19
+ "h": 220
20
+ }
21
+ },
22
+ "permissions": [
23
+ {
24
+ "id": "agents.read",
25
+ "reason": {
26
+ "en": "Shows which agents are working",
27
+ "ru": "Показывает, какие агенты работают",
28
+ "zh": "显示哪些智能体正在工作"
29
+ }
30
+ },
31
+ {
32
+ "id": "cards.connected",
33
+ "optional": true,
34
+ "reason": {
35
+ "en": "Sends the scratchpad to a note you connect with an arrow",
36
+ "ru": "Отправляет черновик в заметку, соединённую стрелкой",
37
+ "zh": "将草稿发送到用箭头连接的笔记"
38
+ }
39
+ }
40
+ ],
41
+ "settings": [
42
+ {
43
+ "key": "greeting",
44
+ "type": "string",
45
+ "label": {
46
+ "en": "Greeting",
47
+ "ru": "Приветствие",
48
+ "zh": "问候语"
49
+ },
50
+ "default": "Hello from __CARD_DISPLAY_NAME__",
51
+ "maxLength": 80
52
+ }
53
+ ],
54
+ "ports": {
55
+ "inputs": [
56
+ {
57
+ "id": "text",
58
+ "label": {
59
+ "en": "Text in",
60
+ "ru": "Текст",
61
+ "zh": "文本输入"
62
+ },
63
+ "description": "Appended to the scratchpad.",
64
+ "type": "ns:text",
65
+ "default": true
66
+ }
67
+ ],
68
+ "outputs": [
69
+ {
70
+ "id": "scratchpad",
71
+ "label": {
72
+ "en": "Scratchpad",
73
+ "ru": "Черновик",
74
+ "zh": "草稿"
75
+ },
76
+ "description": "The scratchpad text, when you press Send.",
77
+ "type": "ns:markdown",
78
+ "retain": true
79
+ }
80
+ ]
81
+ },
82
+ "tools": [
83
+ {
84
+ "name": "read_scratchpad",
85
+ "title": "Read the scratchpad",
86
+ "description": "Returns the text the user wrote in this card's scratchpad (may be empty).",
87
+ "inputSchema": {
88
+ "type": "object",
89
+ "properties": {}
90
+ },
91
+ "readOnly": true
92
+ }
93
+ ]
94
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "__CARD_NAME__",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc --noEmit && vite build",
9
+ "watch": "vite build --watch",
10
+ "validate": "neurosquad-card validate",
11
+ "pack": "neurosquad-card pack"
12
+ },
13
+ "dependencies": {
14
+ "@neurosquad/card-sdk": "^__SDK_VERSION__",
15
+ "react": "^19.2.0",
16
+ "react-dom": "^19.2.0"
17
+ },
18
+ "devDependencies": {
19
+ "@types/react": "^19.2.0",
20
+ "@types/react-dom": "^19.2.0",
21
+ "@vitejs/plugin-react": "^5.1.0",
22
+ "typescript": "^5.9.0",
23
+ "vite": "^7.2.0"
24
+ }
25
+ }