@anchrd/colab-sdk 0.1.36 → 0.1.37

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 (48) hide show
  1. package/dist/actions/actions.d.ts +30 -23
  2. package/dist/actions/actions.js +2 -2
  3. package/dist/archive/archive.d.ts +1 -0
  4. package/dist/archive/archive.js +3 -0
  5. package/dist/boards/boards.d.ts +21 -21
  6. package/dist/columns/columns.d.ts +2 -2
  7. package/dist/connectors/connectors.d.ts +6 -6
  8. package/dist/crawls/crawls.d.ts +3 -3
  9. package/dist/error/error.d.ts +9 -3
  10. package/dist/error/error.js +12 -3
  11. package/dist/gadgets/gadgets.d.ts +125 -9
  12. package/dist/gadgets/gadgets.js +123 -0
  13. package/dist/goals/goals.d.ts +54 -10
  14. package/dist/goals/goals.js +36 -7
  15. package/dist/grammar/grammar.d.ts +2 -0
  16. package/dist/grammar/grammar.js +10 -0
  17. package/dist/home/home.d.ts +300 -0
  18. package/dist/home/home.js +53 -0
  19. package/dist/links/links.d.ts +166 -0
  20. package/dist/links/links.js +149 -0
  21. package/dist/mcps/mcps.d.ts +3 -3
  22. package/dist/messages/messages.d.ts +3 -0
  23. package/dist/nodes/nodes.d.ts +46 -20
  24. package/dist/nodes/nodes.js +11 -3
  25. package/dist/operators/operators.d.ts +389 -47
  26. package/dist/operators/operators.js +268 -70
  27. package/dist/organisation/organisation.d.ts +2 -0
  28. package/dist/organisation/organisation.js +9 -0
  29. package/dist/primitives/primitives.d.ts +9 -0
  30. package/dist/primitives/primitives.js +16 -0
  31. package/dist/roles/roles.d.ts +1 -0
  32. package/dist/roles/roles.js +3 -0
  33. package/dist/runs/runs.d.ts +2 -2
  34. package/dist/sdk.d.ts +10 -9
  35. package/dist/sdk.js +10 -9
  36. package/dist/skills/skills.d.ts +37 -7
  37. package/dist/skills/skills.js +50 -0
  38. package/dist/sources/sources.d.ts +54 -14
  39. package/dist/sources/sources.js +50 -5
  40. package/dist/tables/tables.d.ts +42 -0
  41. package/dist/tables/tables.js +55 -2
  42. package/dist/tool.d.ts +1 -0
  43. package/dist/tree-order/tree-order.d.ts +2 -2
  44. package/dist/tree-order/tree-order.js +1 -1
  45. package/dist/users/users.d.ts +2 -0
  46. package/dist/users/users.js +3 -2
  47. package/dist/versions/versions.d.ts +13 -13
  48. package/package.json +1 -1
@@ -223,11 +223,11 @@ export declare const ConnectorTestRun: z.ZodObject<{
223
223
  name: z.ZodString;
224
224
  durationMs: z.ZodNumber;
225
225
  code: z.ZodNullable<z.ZodEnum<{
226
+ unavailable: "unavailable";
226
227
  not_found: "not_found";
227
228
  invalid: "invalid";
228
229
  conflict: "conflict";
229
230
  unauthenticated: "unauthenticated";
230
- unavailable: "unavailable";
231
231
  }>>;
232
232
  }, z.core.$strip>>>;
233
233
  }, z.core.$strip>>;
@@ -238,11 +238,11 @@ export declare const ConnectorTestRun: z.ZodObject<{
238
238
  name: z.ZodString;
239
239
  durationMs: z.ZodNumber;
240
240
  code: z.ZodNullable<z.ZodEnum<{
241
+ unavailable: "unavailable";
241
242
  not_found: "not_found";
242
243
  invalid: "invalid";
243
244
  conflict: "conflict";
244
245
  unauthenticated: "unauthenticated";
245
- unavailable: "unavailable";
246
246
  }>>;
247
247
  }, z.core.$strip>>;
248
248
  }, z.core.$strip>>>;
@@ -516,11 +516,11 @@ export declare const ConnectorDetail: z.ZodObject<{
516
516
  name: z.ZodString;
517
517
  durationMs: z.ZodNumber;
518
518
  code: z.ZodNullable<z.ZodEnum<{
519
+ unavailable: "unavailable";
519
520
  not_found: "not_found";
520
521
  invalid: "invalid";
521
522
  conflict: "conflict";
522
523
  unauthenticated: "unauthenticated";
523
- unavailable: "unavailable";
524
524
  }>>;
525
525
  }, z.core.$strip>>>;
526
526
  }, z.core.$strip>>;
@@ -531,11 +531,11 @@ export declare const ConnectorDetail: z.ZodObject<{
531
531
  name: z.ZodString;
532
532
  durationMs: z.ZodNumber;
533
533
  code: z.ZodNullable<z.ZodEnum<{
534
+ unavailable: "unavailable";
534
535
  not_found: "not_found";
535
536
  invalid: "invalid";
536
537
  conflict: "conflict";
537
538
  unauthenticated: "unauthenticated";
538
- unavailable: "unavailable";
539
539
  }>>;
540
540
  }, z.core.$strip>>;
541
541
  }, z.core.$strip>>>;
@@ -616,11 +616,11 @@ export declare const ConnectorTestAnswer: z.ZodUnion<readonly [z.ZodObject<{
616
616
  name: z.ZodString;
617
617
  durationMs: z.ZodNumber;
618
618
  code: z.ZodNullable<z.ZodEnum<{
619
+ unavailable: "unavailable";
619
620
  not_found: "not_found";
620
621
  invalid: "invalid";
621
622
  conflict: "conflict";
622
623
  unauthenticated: "unauthenticated";
623
- unavailable: "unavailable";
624
624
  }>>;
625
625
  }, z.core.$strip>>>;
626
626
  }, z.core.$strip>>;
@@ -631,11 +631,11 @@ export declare const ConnectorTestAnswer: z.ZodUnion<readonly [z.ZodObject<{
631
631
  name: z.ZodString;
632
632
  durationMs: z.ZodNumber;
633
633
  code: z.ZodNullable<z.ZodEnum<{
634
+ unavailable: "unavailable";
634
635
  not_found: "not_found";
635
636
  invalid: "invalid";
636
637
  conflict: "conflict";
637
638
  unauthenticated: "unauthenticated";
638
- unavailable: "unavailable";
639
639
  }>>;
640
640
  }, z.core.$strip>>;
641
641
  }, z.core.$strip>>>;
@@ -34,8 +34,8 @@ export declare const CrawlGetInput: z.ZodObject<{
34
34
  }, z.core.$strict>;
35
35
  export type CrawlGetInput = z.infer<typeof CrawlGetInput>;
36
36
  export declare const CrawlStatus: z.ZodEnum<{
37
- expired: "expired";
38
37
  done: "done";
38
+ expired: "expired";
39
39
  running: "running";
40
40
  failed: "failed";
41
41
  starting: "starting";
@@ -46,8 +46,8 @@ export declare const Crawl: z.ZodObject<{
46
46
  crawlId: z.ZodTemplateLiteral<`crawl_${string}`>;
47
47
  url: z.ZodString;
48
48
  status: z.ZodEnum<{
49
- expired: "expired";
50
49
  done: "done";
50
+ expired: "expired";
51
51
  running: "running";
52
52
  failed: "failed";
53
53
  starting: "starting";
@@ -91,8 +91,8 @@ export declare const CrawlDetail: z.ZodObject<{
91
91
  crawlId: z.ZodTemplateLiteral<`crawl_${string}`>;
92
92
  url: z.ZodString;
93
93
  status: z.ZodEnum<{
94
- expired: "expired";
95
94
  done: "done";
95
+ expired: "expired";
96
96
  running: "running";
97
97
  failed: "failed";
98
98
  starting: "starting";
@@ -1,11 +1,11 @@
1
1
  import { z } from "zod";
2
2
  export declare const errorCodes: readonly ["not_found", "invalid", "conflict", "unauthenticated", "unavailable"];
3
3
  export declare const ErrorCode: z.ZodEnum<{
4
+ unavailable: "unavailable";
4
5
  not_found: "not_found";
5
6
  invalid: "invalid";
6
7
  conflict: "conflict";
7
8
  unauthenticated: "unauthenticated";
8
- unavailable: "unavailable";
9
9
  }>;
10
10
  export type ErrorCode = z.infer<typeof ErrorCode>;
11
11
  export declare const ErrorIssue: z.ZodObject<{
@@ -33,6 +33,7 @@ export declare const ErrorCurrent: z.ZodObject<{
33
33
  values: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
34
34
  }, z.core.$strict>;
35
35
  export type ErrorCurrent = z.infer<typeof ErrorCurrent>;
36
+ export declare const notFoundReasons: readonly ["no_access"];
36
37
  export declare const ErrorResponse: z.ZodObject<{
37
38
  error: z.ZodDiscriminatedUnion<[z.ZodObject<{
38
39
  code: z.ZodLiteral<"invalid">;
@@ -68,11 +69,16 @@ export declare const ErrorResponse: z.ZodObject<{
68
69
  savedAt: z.ZodISODateTime;
69
70
  values: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
70
71
  }, z.core.$strict>>>;
72
+ }, z.core.$strict>, z.ZodObject<{
73
+ code: z.ZodLiteral<"not_found">;
74
+ message: z.ZodString;
75
+ reason: z.ZodOptional<z.ZodEnum<{
76
+ no_access: "no_access";
77
+ }>>;
71
78
  }, z.core.$strict>, z.ZodObject<{
72
79
  code: z.ZodEnum<{
73
- not_found: "not_found";
74
- unauthenticated: "unauthenticated";
75
80
  unavailable: "unavailable";
81
+ unauthenticated: "unauthenticated";
76
82
  }>;
77
83
  message: z.ZodString;
78
84
  }, z.core.$strict>], "code">;
@@ -41,9 +41,13 @@ export const ErrorCurrent = z.strictObject({
41
41
  savedAt: z.iso.datetime(),
42
42
  values: z.record(z.string(), z.unknown()).optional(),
43
43
  });
44
+ // Why a `not_found` is one (E166, #985): `no_access`, the node exists and the caller may not read it.
45
+ // Only `/api` says so, only to a person in their browser session, and only for reading a node, so
46
+ // the UI shows "No access" instead of the 404; the code stays `not_found` for every client.
47
+ export const notFoundReasons = ["no_access"];
44
48
  // `issues` exists only next to `invalid` and `conflict` (a change of many entries names each stale
45
- // one, #630, #625), `current` only next to `conflict` (E128); on every other code a strict object
46
- // rejects them.
49
+ // one, #630, #625), `current` only next to `conflict` (E128), `reason` only next to `not_found`; on
50
+ // every other code a strict object rejects them.
47
51
  export const ErrorResponse = z.strictObject({
48
52
  error: z.discriminatedUnion("code", [
49
53
  z.strictObject({
@@ -58,7 +62,12 @@ export const ErrorResponse = z.strictObject({
58
62
  current: z.array(ErrorCurrent).optional(),
59
63
  }),
60
64
  z.strictObject({
61
- code: ErrorCode.exclude(["invalid", "conflict"]),
65
+ code: z.literal("not_found"),
66
+ message: z.string(),
67
+ reason: z.enum(notFoundReasons).optional(),
68
+ }),
69
+ z.strictObject({
70
+ code: ErrorCode.exclude(["invalid", "conflict", "not_found"]),
62
71
  message: z.string(),
63
72
  }),
64
73
  ]),
@@ -6,17 +6,41 @@ export declare const gadgetLimits: {
6
6
  readonly bytes: number;
7
7
  };
8
8
  export declare const GadgetFunctionName: z.ZodString;
9
+ export declare const GadgetRequires: z.ZodString;
9
10
  export declare const GadgetFunction: z.ZodObject<{
10
11
  description: z.ZodString;
11
12
  input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
13
+ requires: z.ZodOptional<z.ZodString>;
12
14
  }, z.core.$strict>;
13
15
  export type GadgetFunction = z.infer<typeof GadgetFunction>;
16
+ export declare const GadgetAccess: z.ZodObject<{
17
+ service: z.ZodTemplateLiteral<`service_${string}`>;
18
+ }, z.core.$strict>;
19
+ export type GadgetAccess = z.infer<typeof GadgetAccess>;
20
+ export declare const GadgetUseRight: z.ZodEnum<{
21
+ write: "write";
22
+ read: "read";
23
+ }>;
24
+ export type GadgetUseRight = z.infer<typeof GadgetUseRight>;
25
+ export declare const GadgetUses: z.ZodRecord<z.ZodTemplateLiteral<`node_${string}`>, z.ZodEnum<{
26
+ write: "write";
27
+ read: "read";
28
+ }>>;
29
+ export type GadgetUses = z.infer<typeof GadgetUses>;
14
30
  export declare const GadgetManifest: z.ZodObject<{
15
31
  name: z.ZodString;
16
32
  description: z.ZodOptional<z.ZodString>;
33
+ access: z.ZodOptional<z.ZodObject<{
34
+ service: z.ZodTemplateLiteral<`service_${string}`>;
35
+ }, z.core.$strict>>;
36
+ uses: z.ZodOptional<z.ZodRecord<z.ZodTemplateLiteral<`node_${string}`>, z.ZodEnum<{
37
+ write: "write";
38
+ read: "read";
39
+ }>>>;
17
40
  functions: z.ZodRecord<z.ZodString, z.ZodObject<{
18
41
  description: z.ZodString;
19
42
  input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
43
+ requires: z.ZodOptional<z.ZodString>;
20
44
  }, z.core.$strict>>;
21
45
  }, z.core.$strict>;
22
46
  export type GadgetManifest = z.infer<typeof GadgetManifest>;
@@ -40,6 +64,14 @@ export declare const GadgetCreateInput: z.ZodObject<{
40
64
  }>>;
41
65
  name: z.ZodString;
42
66
  files: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
67
+ from: z.ZodOptional<z.ZodObject<{
68
+ gadgetId: z.ZodTemplateLiteral<`node_${string}`>;
69
+ as: z.ZodEnum<{
70
+ link: "link";
71
+ copy: "copy";
72
+ }>;
73
+ uses: z.ZodOptional<z.ZodRecord<z.ZodTemplateLiteral<`node_${string}`>, z.ZodTemplateLiteral<`node_${string}`>>>;
74
+ }, z.core.$strict>>;
43
75
  idempotencyKey: z.ZodString;
44
76
  }, z.core.$strict>;
45
77
  export type GadgetCreateInput = z.infer<typeof GadgetCreateInput>;
@@ -52,6 +84,16 @@ export declare const GadgetGetInput: z.ZodObject<{
52
84
  include: z.ZodOptional<z.ZodPreprocess<z.ZodArray<z.ZodEnum<{
53
85
  files: "files";
54
86
  }>>, unknown>>;
87
+ compare: z.ZodOptional<z.ZodPreprocess<z.ZodObject<{
88
+ from: z.ZodPreprocess<z.ZodUnion<readonly [z.ZodEnum<{
89
+ live: "live";
90
+ draft: "draft";
91
+ }>, z.ZodNumber]>, unknown>;
92
+ to: z.ZodPreprocess<z.ZodUnion<readonly [z.ZodEnum<{
93
+ live: "live";
94
+ draft: "draft";
95
+ }>, z.ZodNumber]>, unknown>;
96
+ }, z.core.$strict>, unknown>>;
55
97
  }, z.core.$strict>;
56
98
  export type GadgetGetInput = z.infer<typeof GadgetGetInput>;
57
99
  export declare const GadgetUpdateInput: z.ZodObject<{
@@ -65,6 +107,8 @@ export declare const GadgetUpdateInput: z.ZodObject<{
65
107
  report: "report";
66
108
  }>>;
67
109
  logDays: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<7>, z.ZodLiteral<14>, z.ZodLiteral<30>]>>;
110
+ uses: z.ZodOptional<z.ZodRecord<z.ZodTemplateLiteral<`node_${string}`>, z.ZodTemplateLiteral<`node_${string}`>>>;
111
+ original: z.ZodOptional<z.ZodNull>;
68
112
  }, z.core.$strict>>;
69
113
  fromVersion: z.ZodOptional<z.ZodNumber>;
70
114
  discard: z.ZodOptional<z.ZodLiteral<true>>;
@@ -159,6 +203,17 @@ export declare const GadgetChange: z.ZodObject<{
159
203
  }>;
160
204
  }, z.core.$strip>;
161
205
  export type GadgetChange = z.infer<typeof GadgetChange>;
206
+ export declare const GadgetDiffFile: z.ZodObject<{
207
+ path: z.ZodString;
208
+ change: z.ZodEnum<{
209
+ added: "added";
210
+ changed: "changed";
211
+ removed: "removed";
212
+ }>;
213
+ before: z.ZodNullable<z.ZodString>;
214
+ after: z.ZodNullable<z.ZodString>;
215
+ }, z.core.$strip>;
216
+ export type GadgetDiffFile = z.infer<typeof GadgetDiffFile>;
162
217
  export declare const GadgetSettings: z.ZodObject<{
163
218
  responsible: z.ZodNullable<z.ZodObject<{
164
219
  userId: z.ZodString;
@@ -180,11 +235,11 @@ export declare const GadgetToolUse: z.ZodObject<{
180
235
  name: z.ZodString;
181
236
  durationMs: z.ZodNumber;
182
237
  code: z.ZodNullable<z.ZodEnum<{
238
+ unavailable: "unavailable";
183
239
  not_found: "not_found";
184
240
  invalid: "invalid";
185
241
  conflict: "conflict";
186
242
  unauthenticated: "unauthenticated";
187
- unavailable: "unavailable";
188
243
  }>>;
189
244
  }, z.core.$strip>;
190
245
  export type GadgetToolUse = z.infer<typeof GadgetToolUse>;
@@ -207,11 +262,11 @@ export declare const GadgetTestResult: z.ZodObject<{
207
262
  name: z.ZodString;
208
263
  durationMs: z.ZodNumber;
209
264
  code: z.ZodNullable<z.ZodEnum<{
265
+ unavailable: "unavailable";
210
266
  not_found: "not_found";
211
267
  invalid: "invalid";
212
268
  conflict: "conflict";
213
269
  unauthenticated: "unauthenticated";
214
- unavailable: "unavailable";
215
270
  }>>;
216
271
  }, z.core.$strip>>>;
217
272
  }, z.core.$strip>;
@@ -223,11 +278,11 @@ export declare const GadgetTestHooks: z.ZodObject<{
223
278
  name: z.ZodString;
224
279
  durationMs: z.ZodNumber;
225
280
  code: z.ZodNullable<z.ZodEnum<{
281
+ unavailable: "unavailable";
226
282
  not_found: "not_found";
227
283
  invalid: "invalid";
228
284
  conflict: "conflict";
229
285
  unauthenticated: "unauthenticated";
230
- unavailable: "unavailable";
231
286
  }>>;
232
287
  }, z.core.$strip>>;
233
288
  }, z.core.$strip>;
@@ -299,11 +354,11 @@ export declare const GadgetTestRun: z.ZodObject<{
299
354
  name: z.ZodString;
300
355
  durationMs: z.ZodNumber;
301
356
  code: z.ZodNullable<z.ZodEnum<{
357
+ unavailable: "unavailable";
302
358
  not_found: "not_found";
303
359
  invalid: "invalid";
304
360
  conflict: "conflict";
305
361
  unauthenticated: "unauthenticated";
306
- unavailable: "unavailable";
307
362
  }>>;
308
363
  }, z.core.$strip>>>;
309
364
  }, z.core.$strip>>;
@@ -314,11 +369,11 @@ export declare const GadgetTestRun: z.ZodObject<{
314
369
  name: z.ZodString;
315
370
  durationMs: z.ZodNumber;
316
371
  code: z.ZodNullable<z.ZodEnum<{
372
+ unavailable: "unavailable";
317
373
  not_found: "not_found";
318
374
  invalid: "invalid";
319
375
  conflict: "conflict";
320
376
  unauthenticated: "unauthenticated";
321
- unavailable: "unavailable";
322
377
  }>>;
323
378
  }, z.core.$strip>>;
324
379
  }, z.core.$strip>>>;
@@ -356,9 +411,17 @@ export declare const GadgetDetail: z.ZodObject<{
356
411
  manifest: z.ZodNullable<z.ZodObject<{
357
412
  name: z.ZodString;
358
413
  description: z.ZodOptional<z.ZodString>;
414
+ access: z.ZodOptional<z.ZodObject<{
415
+ service: z.ZodTemplateLiteral<`service_${string}`>;
416
+ }, z.core.$strict>>;
417
+ uses: z.ZodOptional<z.ZodRecord<z.ZodTemplateLiteral<`node_${string}`>, z.ZodEnum<{
418
+ write: "write";
419
+ read: "read";
420
+ }>>>;
359
421
  functions: z.ZodRecord<z.ZodString, z.ZodObject<{
360
422
  description: z.ZodString;
361
423
  input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
424
+ requires: z.ZodOptional<z.ZodString>;
362
425
  }, z.core.$strict>>;
363
426
  }, z.core.$strict>>;
364
427
  files: z.ZodArray<z.ZodObject<{
@@ -397,6 +460,14 @@ export declare const GadgetDetail: z.ZodObject<{
397
460
  }>;
398
461
  }, z.core.$strip>>;
399
462
  newTools: z.ZodArray<z.ZodString>;
463
+ newUses: z.ZodOptional<z.ZodArray<z.ZodObject<{
464
+ nodeId: z.ZodString;
465
+ name: z.ZodNullable<z.ZodString>;
466
+ right: z.ZodEnum<{
467
+ write: "write";
468
+ read: "read";
469
+ }>;
470
+ }, z.core.$strip>>>;
400
471
  }, z.core.$strip>>;
401
472
  test: z.ZodNullable<z.ZodObject<{
402
473
  version: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"draft">]>;
@@ -441,11 +512,11 @@ export declare const GadgetDetail: z.ZodObject<{
441
512
  name: z.ZodString;
442
513
  durationMs: z.ZodNumber;
443
514
  code: z.ZodNullable<z.ZodEnum<{
515
+ unavailable: "unavailable";
444
516
  not_found: "not_found";
445
517
  invalid: "invalid";
446
518
  conflict: "conflict";
447
519
  unauthenticated: "unauthenticated";
448
- unavailable: "unavailable";
449
520
  }>>;
450
521
  }, z.core.$strip>>>;
451
522
  }, z.core.$strip>>;
@@ -456,11 +527,11 @@ export declare const GadgetDetail: z.ZodObject<{
456
527
  name: z.ZodString;
457
528
  durationMs: z.ZodNumber;
458
529
  code: z.ZodNullable<z.ZodEnum<{
530
+ unavailable: "unavailable";
459
531
  not_found: "not_found";
460
532
  invalid: "invalid";
461
533
  conflict: "conflict";
462
534
  unauthenticated: "unauthenticated";
463
- unavailable: "unavailable";
464
535
  }>>;
465
536
  }, z.core.$strip>>;
466
537
  }, z.core.$strip>>>;
@@ -501,6 +572,47 @@ export declare const GadgetDetail: z.ZodObject<{
501
572
  rights: z.ZodObject<{
502
573
  write: z.ZodBoolean;
503
574
  }, z.core.$strip>;
575
+ access: z.ZodOptional<z.ZodNullable<z.ZodObject<{
576
+ serviceId: z.ZodString;
577
+ name: z.ZodNullable<z.ZodString>;
578
+ archived: z.ZodBoolean;
579
+ functions: z.ZodArray<z.ZodString>;
580
+ held: z.ZodArray<z.ZodString>;
581
+ }, z.core.$strip>>>;
582
+ uses: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
583
+ nodeId: z.ZodString;
584
+ name: z.ZodNullable<z.ZodString>;
585
+ path: z.ZodArray<z.ZodString>;
586
+ right: z.ZodEnum<{
587
+ write: "write";
588
+ read: "read";
589
+ }>;
590
+ missing: z.ZodBoolean;
591
+ own: z.ZodOptional<z.ZodBoolean>;
592
+ }, z.core.$strip>>>>;
593
+ link: z.ZodOptional<z.ZodNullable<z.ZodObject<{
594
+ originalId: z.ZodTemplateLiteral<`node_${string}`>;
595
+ name: z.ZodNullable<z.ZodString>;
596
+ uses: z.ZodRecord<z.ZodString, z.ZodString>;
597
+ }, z.core.$strip>>>;
598
+ links: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
599
+ gadgetId: z.ZodTemplateLiteral<`node_${string}`>;
600
+ name: z.ZodNullable<z.ZodString>;
601
+ }, z.core.$strip>>>>;
602
+ diff: z.ZodOptional<z.ZodNullable<z.ZodObject<{
603
+ from: z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"draft">]>>;
604
+ to: z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"draft">]>>;
605
+ files: z.ZodArray<z.ZodObject<{
606
+ path: z.ZodString;
607
+ change: z.ZodEnum<{
608
+ added: "added";
609
+ changed: "changed";
610
+ removed: "removed";
611
+ }>;
612
+ before: z.ZodNullable<z.ZodString>;
613
+ after: z.ZodNullable<z.ZodString>;
614
+ }, z.core.$strip>>;
615
+ }, z.core.$strip>>>;
504
616
  rev: z.ZodNumber;
505
617
  archivedAt: z.ZodNullable<z.ZodISODateTime>;
506
618
  }, z.core.$strip>;
@@ -545,13 +657,17 @@ export declare const GadgetCall: z.ZodObject<{
545
657
  name: z.ZodString;
546
658
  durationMs: z.ZodNumber;
547
659
  code: z.ZodNullable<z.ZodEnum<{
660
+ unavailable: "unavailable";
548
661
  not_found: "not_found";
549
662
  invalid: "invalid";
550
663
  conflict: "conflict";
551
664
  unauthenticated: "unauthenticated";
552
- unavailable: "unavailable";
553
665
  }>>;
554
666
  }, z.core.$strip>>;
667
+ missing: z.ZodOptional<z.ZodArray<z.ZodObject<{
668
+ nodeId: z.ZodNullable<z.ZodString>;
669
+ name: z.ZodNullable<z.ZodString>;
670
+ }, z.core.$strip>>>;
555
671
  }, z.core.$strip>;
556
672
  export type GadgetCall = z.infer<typeof GadgetCall>;
557
673
  export declare const GadgetCallItem: z.ZodObject<{
@@ -654,11 +770,11 @@ export declare const GadgetCallEntry: z.ZodObject<{
654
770
  name: z.ZodString;
655
771
  durationMs: z.ZodNumber;
656
772
  code: z.ZodNullable<z.ZodEnum<{
773
+ unavailable: "unavailable";
657
774
  not_found: "not_found";
658
775
  invalid: "invalid";
659
776
  conflict: "conflict";
660
777
  unauthenticated: "unauthenticated";
661
- unavailable: "unavailable";
662
778
  }>>;
663
779
  }, z.core.$strip>>;
664
780
  }, z.core.$strip>;
@@ -4,6 +4,7 @@ import { idSchema } from "../ids/ids.js";
4
4
  import { Limit } from "../list-input.js";
5
5
  import { CreateSection, NodeId, NodePath, NodePerson } from "../nodes/nodes.js";
6
6
  import { IdempotencyKey, Rev } from "../primitives/primitives.js";
7
+ import { ServiceId } from "../services/services.js";
7
8
  import { UserId } from "../users/users.js";
8
9
  // Gadgets (#642, E118, Nodes › Gadget): a small application an AI builds and Colab runs. Its files
9
10
  // without a build step, every change into the draft, publishing as a version, and calling a function
@@ -32,6 +33,13 @@ export const GadgetFunctionName = z
32
33
  .max(64)
33
34
  .regex(/^[A-Za-z_$][A-Za-z0-9_$]*$/)
34
35
  .describe("The function's name, exported by server.js under the same name.");
36
+ // The right a function needs (#790, E162): `interface.function` of the service in `access.service`,
37
+ // each word one word like every word of a right (E64).
38
+ export const GadgetRequires = z
39
+ .string()
40
+ .max(129)
41
+ .regex(/^[a-z][a-z0-9]*\.[a-z][a-z0-9]*$/)
42
+ .describe("The function of the gadget's service a caller needs, as interface.function, such as leads.read.");
35
43
  // One function of the manifest, under its name in `functions`.
36
44
  export const GadgetFunction = z.strictObject({
37
45
  description: z.string().max(2000).describe("What the function does, for the AI that calls it."),
@@ -39,10 +47,24 @@ export const GadgetFunction = z.strictObject({
39
47
  .record(z.string(), z.unknown())
40
48
  .optional()
41
49
  .describe("A JSON Schema of the function's input, an object; Colab checks every call against it. Leaving it out takes any object."),
50
+ requires: GadgetRequires.optional(),
51
+ });
52
+ // Rights per person over a service of Access (#790, E162): the gadget names a service an admin set
53
+ // up, and every function names the function of that service it requires.
54
+ export const GadgetAccess = z.strictObject({
55
+ service: ServiceId.describe("The service of Access whose functions this gadget's functions require, `service_…`. An admin creates it and switches it on in roles."),
42
56
  });
57
+ // The nodes a gadget reads and writes with rights of its own (#986, E163): node id to `read` or
58
+ // `write`. Granted at publish, only as far as the one who publishes holds them.
59
+ export const GadgetUseRight = z.enum(["read", "write"]);
60
+ export const GadgetUses = z
61
+ .record(NodeId, GadgetUseRight)
62
+ .describe("The nodes the gadget reads or writes with rights of its own, each node id with read or write. Granted when it goes live, only as far as you hold them yourself.");
43
63
  export const GadgetManifest = z.strictObject({
44
64
  name: z.string().min(1).max(200).describe("The gadget's name in the manifest."),
45
65
  description: z.string().max(2000).optional().describe("What the gadget is for."),
66
+ access: GadgetAccess.optional(),
67
+ uses: GadgetUses.optional(),
46
68
  functions: z
47
69
  .record(GadgetFunctionName, GadgetFunction)
48
70
  .describe("The functions server.js exports, each under its name."),
@@ -70,6 +92,19 @@ export const GadgetCreateInput = z.strictObject({
70
92
  .record(GadgetFilePath, FileContent)
71
93
  .optional()
72
94
  .describe("The gadget's first files by path, such as gadget.json, server.js, client.js and tests/*.test.js. They become its draft; nothing is live until it is published. Leaving it out creates an empty gadget."),
95
+ from: z
96
+ .strictObject({
97
+ gadgetId: NodeId.describe("The gadget to duplicate."),
98
+ as: z
99
+ .enum(["copy", "link"])
100
+ .describe("copy: its own code and history from here on, starting as a draft of the original's live state, for whoever may change the original. link: the original's code, following every version it publishes and read only here, with its own settings, data and storage; for whoever may read an original that is live."),
101
+ uses: z
102
+ .record(NodeId, NodeId)
103
+ .optional()
104
+ .describe("Only for a link: for a node of the original's uses, the node it uses here instead, with the same right (Daten an dieser Stelle). Nodes left out stay the original's."),
105
+ })
106
+ .optional()
107
+ .describe("Duplicate a gadget instead of giving files (E216)."),
73
108
  idempotencyKey: IdempotencyKey,
74
109
  });
75
110
  // `include` over REST is one comma-separated value (`?include=files`): a query string carries text.
@@ -81,6 +116,19 @@ export const GadgetGetInput = z.strictObject({
81
116
  .preprocess((value) => (typeof value === "string" ? value.split(",") : value), z.array(GadgetInclude).min(1).max(1))
82
117
  .optional()
83
118
  .describe("files: answer the text of every file of that state, not only their paths."),
119
+ // ⚠️ Over REST a query string carries text only: `?compare=6,live` is the same as the object.
120
+ compare: z
121
+ .preprocess((value) => {
122
+ if (typeof value !== "string")
123
+ return value;
124
+ const [from, to, ...rest] = value.split(",");
125
+ return rest.length === 0 && to !== undefined ? { from, to } : value;
126
+ }, z.strictObject({
127
+ from: GadgetVersionRef.describe("The older side: a version's number, live or draft."),
128
+ to: GadgetVersionRef.describe("The newer side: a version's number, live or draft."),
129
+ }))
130
+ .optional()
131
+ .describe("Also answer what changed from one state to another, file by file with both texts (the diff). Only for whoever may change the gadget."),
84
132
  });
85
133
  const GadgetSettingsInput = z.strictObject({
86
134
  responsibleId: UserId.nullable()
@@ -88,6 +136,14 @@ const GadgetSettingsInput = z.strictObject({
88
136
  .describe("The Operator or person who gets every new error and red test as an Action; null for nobody, then the publisher gets a hint."),
89
137
  level: GadgetLevel.optional().describe("How far the responsible goes: report, draft (repair as a draft, the default) or publish (repair and publish, only with every test green and no new rights)."),
90
138
  logDays: LogDays.optional(),
139
+ uses: z
140
+ .record(NodeId, NodeId)
141
+ .optional()
142
+ .describe("Only at a link: for a node of the original's uses, the node it uses here instead (Daten an dieser Stelle); the whole mapping, a node left out uses the original's again."),
143
+ original: z
144
+ .null()
145
+ .optional()
146
+ .describe("Only at a link: null turns it into a copy with its own code and history (In Kopie umwandeln)."),
91
147
  });
92
148
  export const GadgetUpdateInput = z.strictObject({
93
149
  gadgetId: GadgetId,
@@ -188,6 +244,11 @@ export const GadgetChange = z.object({
188
244
  path: z.string(),
189
245
  change: z.enum(["added", "changed", "removed"]),
190
246
  });
247
+ // A file of a diff (E216): its change with both texts, null on the side it is missing.
248
+ export const GadgetDiffFile = GadgetChange.extend({
249
+ before: z.string().nullable(),
250
+ after: z.string().nullable(),
251
+ });
191
252
  export const GadgetSettings = z.object({
192
253
  responsible: NodePerson.nullable(),
193
254
  level: GadgetLevel,
@@ -307,6 +368,10 @@ export const GadgetDetail = z.object({
307
368
  // The Colab tools the draft's backend names and the live one does not ("Keine neuen Rechte"),
308
369
  // read from the text of its files: a name built at run time is not seen.
309
370
  newTools: z.array(z.string()),
371
+ // The nodes the draft's `uses` adds or raises to write against live (#986, "Nutzt neu").
372
+ newUses: z
373
+ .array(z.object({ nodeId: z.string(), name: z.string().nullable(), right: GadgetUseRight }))
374
+ .optional(),
310
375
  })
311
376
  .nullable(),
312
377
  // The last run of the tests (#643); null for a reader and before the first.
@@ -323,6 +388,59 @@ export const GadgetDetail = z.object({
323
388
  // Only for whoever may change the gadget; null for a reader.
324
389
  settings: GadgetSettings.nullable(),
325
390
  rights: z.object({ write: z.boolean() }),
391
+ // The service of `access.service` in this state's manifest and what the caller holds of it (#790,
392
+ // E162): its functions as `interface.function`, and of them the ones the caller may call. `name`
393
+ // is null when the service is gone; an archived one holds nothing. Null without `access`.
394
+ access: z
395
+ .object({
396
+ serviceId: z.string(),
397
+ name: z.string().nullable(),
398
+ archived: z.boolean(),
399
+ functions: z.array(z.string()),
400
+ held: z.array(z.string()),
401
+ })
402
+ .nullable()
403
+ .optional(),
404
+ // The nodes of `uses` in this state (#986, E163), only for whoever may change the gadget: name
405
+ // (null where the reader cannot read it), the right, and `missing` for a node archived or out of
406
+ // the gadget's reach. Null for a reader and without `uses`.
407
+ uses: z
408
+ .array(z.object({
409
+ nodeId: z.string(),
410
+ name: z.string().nullable(),
411
+ path: z.array(z.string()),
412
+ right: GadgetUseRight,
413
+ missing: z.boolean(),
414
+ // Lies in Own (under a root folder): goes along when the gadget moves to Shared.
415
+ own: z.boolean().optional(),
416
+ }))
417
+ .nullable()
418
+ .optional(),
419
+ // A link (E216): its original, whose live version runs here, and what it uses here instead of
420
+ // the original's nodes. Null for an original and a copy.
421
+ link: z
422
+ .object({
423
+ originalId: NodeId,
424
+ // Null where the caller cannot read the original.
425
+ name: z.string().nullable(),
426
+ uses: z.record(z.string(), z.string()),
427
+ })
428
+ .nullable()
429
+ .optional(),
430
+ // An original's links (E216), only for whoever may change it: they run its live version.
431
+ links: z
432
+ .array(z.object({ gadgetId: NodeId, name: z.string().nullable() }))
433
+ .nullable()
434
+ .optional(),
435
+ // What `compare` asked for: the files that changed between the two states.
436
+ diff: z
437
+ .object({
438
+ from: z.union([z.number().int(), z.literal("draft")]).nullable(),
439
+ to: z.union([z.number().int(), z.literal("draft")]).nullable(),
440
+ files: z.array(GadgetDiffFile),
441
+ })
442
+ .nullable()
443
+ .optional(),
326
444
  // The state the next save sends (E70).
327
445
  rev: z.number().int(),
328
446
  archivedAt: z.iso.datetime().nullable(),
@@ -347,6 +465,11 @@ export const GadgetCall = z.object({
347
465
  durationMs: z.number().int(),
348
466
  console: z.array(GadgetConsoleLine),
349
467
  tools: z.array(GadgetToolUse),
468
+ // A live call that did not run because a node of `uses` is missing (#986): each with its name for
469
+ // whoever may change the gadget, null for a reader.
470
+ missing: z
471
+ .array(z.object({ nodeId: z.string().nullable(), name: z.string().nullable() }))
472
+ .optional(),
350
473
  });
351
474
  // One entry of the log as the list shows it (#643): a call of a function on the server, or the
352
475
  // interface opened in the browser (`function` null, "Geöffnet").