@anchrd/intel-contract 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @anchrd/intel-contract
2
2
 
3
- The shared wire contract for [`@anchrd/intel`](https://www.npmjs.com/package/@anchrd/intel): Zod
3
+ The shared wire contract for [`@anchrd/intel-api`](https://www.npmjs.com/package/@anchrd/intel-api): Zod
4
4
  schemas that describe every payload crossing Intel's HTTP, MCP and browser surfaces.
5
5
 
6
6
  You rarely install this directly — the server and the UI both depend on it. Reach for it when you
@@ -10,6 +10,12 @@ export declare const ProblemDetails: z.ZodObject<{
10
10
  code: z.ZodOptional<z.ZodString>;
11
11
  }, z.core.$strict>;
12
12
  export type ProblemDetails = z.infer<typeof ProblemDetails>;
13
+ export declare const SessionUser: z.ZodObject<{
14
+ id: z.ZodString;
15
+ email: z.ZodEmail;
16
+ name: z.ZodNullable<z.ZodString>;
17
+ }, z.core.$strict>;
18
+ export type SessionUser = z.infer<typeof SessionUser>;
13
19
  export declare const KnowledgeNodeKind: z.ZodEnum<{
14
20
  folder: "folder";
15
21
  document: "document";
@@ -483,18 +489,7 @@ export declare const DeleteKnowledgeLinkResult: z.ZodObject<{
483
489
  }, z.core.$strict>;
484
490
  export type DeleteKnowledgeLinkResult = z.infer<typeof DeleteKnowledgeLinkResult>;
485
491
  export declare const ToolSourceUrl: z.ZodURL;
486
- export declare const ToolSource: z.ZodObject<{
487
- id: z.ZodString;
488
- name: z.ZodString;
489
- url: z.ZodURL;
490
- connectionHandle: z.ZodString;
491
- enabled: z.ZodBoolean;
492
- createdBy: z.ZodString;
493
- createdAt: z.ZodISODateTime;
494
- updatedAt: z.ZodISODateTime;
495
- lastDiscoveredAt: z.ZodNullable<z.ZodISODateTime>;
496
- }, z.core.$strict>;
497
- export type ToolSource = z.infer<typeof ToolSource>;
492
+ export declare const ToolName: z.ZodString;
498
493
  export declare const ToolAnnotations: z.ZodObject<{
499
494
  title: z.ZodOptional<z.ZodString>;
500
495
  readOnlyHint: z.ZodOptional<z.ZodBoolean>;
@@ -504,7 +499,6 @@ export declare const ToolAnnotations: z.ZodObject<{
504
499
  }, z.core.$strict>;
505
500
  export type ToolAnnotations = z.infer<typeof ToolAnnotations>;
506
501
  export declare const ToolCapability: z.ZodObject<{
507
- sourceId: z.ZodString;
508
502
  name: z.ZodString;
509
503
  title: z.ZodNullable<z.ZodString>;
510
504
  description: z.ZodNullable<z.ZodString>;
@@ -518,30 +512,11 @@ export declare const ToolCapability: z.ZodObject<{
518
512
  openWorldHint: z.ZodOptional<z.ZodBoolean>;
519
513
  }, z.core.$strict>;
520
514
  fingerprint: z.ZodString;
521
- discoveredAt: z.ZodISODateTime;
522
515
  }, z.core.$strict>;
523
516
  export type ToolCapability = z.infer<typeof ToolCapability>;
524
- export declare const ToolConnectionStatus: z.ZodEnum<{
525
- connected: "connected";
526
- missing: "missing";
527
- forbidden: "forbidden";
528
- invalid: "invalid";
529
- }>;
530
- export type ToolConnectionStatus = z.infer<typeof ToolConnectionStatus>;
531
- export declare const ToolCatalogEntry: z.ZodObject<{
532
- source: z.ZodObject<{
533
- id: z.ZodString;
534
- name: z.ZodString;
535
- url: z.ZodURL;
536
- connectionHandle: z.ZodString;
537
- enabled: z.ZodBoolean;
538
- createdBy: z.ZodString;
539
- createdAt: z.ZodISODateTime;
540
- updatedAt: z.ZodISODateTime;
541
- lastDiscoveredAt: z.ZodNullable<z.ZodISODateTime>;
542
- }, z.core.$strict>;
543
- capability: z.ZodObject<{
544
- sourceId: z.ZodString;
517
+ export declare const ToolCatalog: z.ZodObject<{
518
+ portalConnected: z.ZodBoolean;
519
+ items: z.ZodArray<z.ZodObject<{
545
520
  name: z.ZodString;
546
521
  title: z.ZodNullable<z.ZodString>;
547
522
  description: z.ZodNullable<z.ZodString>;
@@ -555,89 +530,15 @@ export declare const ToolCatalogEntry: z.ZodObject<{
555
530
  openWorldHint: z.ZodOptional<z.ZodBoolean>;
556
531
  }, z.core.$strict>;
557
532
  fingerprint: z.ZodString;
558
- discoveredAt: z.ZodISODateTime;
559
- }, z.core.$strict>;
560
- connectionStatus: z.ZodEnum<{
561
- connected: "connected";
562
- missing: "missing";
563
- forbidden: "forbidden";
564
- invalid: "invalid";
565
- }>;
566
- }, z.core.$strict>;
567
- export type ToolCatalogEntry = z.infer<typeof ToolCatalogEntry>;
568
- export declare const ToolSourceList: z.ZodObject<{
569
- items: z.ZodArray<z.ZodObject<{
570
- id: z.ZodString;
571
- name: z.ZodString;
572
- url: z.ZodURL;
573
- connectionHandle: z.ZodString;
574
- enabled: z.ZodBoolean;
575
- createdBy: z.ZodString;
576
- createdAt: z.ZodISODateTime;
577
- updatedAt: z.ZodISODateTime;
578
- lastDiscoveredAt: z.ZodNullable<z.ZodISODateTime>;
579
- }, z.core.$strict>>;
580
- }, z.core.$strict>;
581
- export type ToolSourceList = z.infer<typeof ToolSourceList>;
582
- export declare const ToolCatalog: z.ZodObject<{
583
- items: z.ZodArray<z.ZodObject<{
584
- source: z.ZodObject<{
585
- id: z.ZodString;
586
- name: z.ZodString;
587
- url: z.ZodURL;
588
- connectionHandle: z.ZodString;
589
- enabled: z.ZodBoolean;
590
- createdBy: z.ZodString;
591
- createdAt: z.ZodISODateTime;
592
- updatedAt: z.ZodISODateTime;
593
- lastDiscoveredAt: z.ZodNullable<z.ZodISODateTime>;
594
- }, z.core.$strict>;
595
- capability: z.ZodObject<{
596
- sourceId: z.ZodString;
597
- name: z.ZodString;
598
- title: z.ZodNullable<z.ZodString>;
599
- description: z.ZodNullable<z.ZodString>;
600
- inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
601
- outputSchema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
602
- annotations: z.ZodObject<{
603
- title: z.ZodOptional<z.ZodString>;
604
- readOnlyHint: z.ZodOptional<z.ZodBoolean>;
605
- destructiveHint: z.ZodOptional<z.ZodBoolean>;
606
- idempotentHint: z.ZodOptional<z.ZodBoolean>;
607
- openWorldHint: z.ZodOptional<z.ZodBoolean>;
608
- }, z.core.$strict>;
609
- fingerprint: z.ZodString;
610
- discoveredAt: z.ZodISODateTime;
611
- }, z.core.$strict>;
612
- connectionStatus: z.ZodEnum<{
613
- connected: "connected";
614
- missing: "missing";
615
- forbidden: "forbidden";
616
- invalid: "invalid";
617
- }>;
618
533
  }, z.core.$strict>>;
619
534
  }, z.core.$strict>;
620
535
  export type ToolCatalog = z.infer<typeof ToolCatalog>;
621
- export declare const CreateToolSourceInput: z.ZodObject<{
622
- name: z.ZodString;
623
- url: z.ZodURL;
624
- connectionHandle: z.ZodDefault<z.ZodString>;
625
- idempotencyKey: z.ZodString;
626
- }, z.core.$strict>;
627
- export type CreateToolSourceInput = z.infer<typeof CreateToolSourceInput>;
628
- export declare const DiscoverToolSourceInput: z.ZodObject<{
629
- sourceId: z.ZodString;
630
- idempotencyKey: z.ZodString;
631
- }, z.core.$strict>;
632
- export type DiscoverToolSourceInput = z.infer<typeof DiscoverToolSourceInput>;
633
536
  export declare const TestToolInput: z.ZodObject<{
634
- sourceId: z.ZodString;
635
537
  name: z.ZodString;
636
538
  arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
637
539
  }, z.core.$strict>;
638
540
  export type TestToolInput = z.infer<typeof TestToolInput>;
639
541
  export declare const ExecuteToolInput: z.ZodObject<{
640
- sourceId: z.ZodString;
641
542
  name: z.ZodString;
642
543
  arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
643
544
  }, z.core.$strict>;
@@ -703,7 +604,6 @@ export declare const FlowNode: z.ZodDiscriminatedUnion<[z.ZodObject<{
703
604
  }, z.core.$strict>, z.ZodObject<{
704
605
  kind: z.ZodLiteral<"tool">;
705
606
  configuration: z.ZodObject<{
706
- sourceId: z.ZodString;
707
607
  toolName: z.ZodString;
708
608
  fingerprint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
709
609
  arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -814,7 +714,6 @@ export declare const FlowGraph: z.ZodObject<{
814
714
  }, z.core.$strict>, z.ZodObject<{
815
715
  kind: z.ZodLiteral<"tool">;
816
716
  configuration: z.ZodObject<{
817
- sourceId: z.ZodString;
818
717
  toolName: z.ZodString;
819
718
  fingerprint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
820
719
  arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -876,6 +775,7 @@ export declare const FlowGraph: z.ZodObject<{
876
775
  export type FlowGraph = z.infer<typeof FlowGraph>;
877
776
  export declare const Flow: z.ZodObject<{
878
777
  id: z.ZodString;
778
+ parentId: z.ZodNullable<z.ZodString>;
879
779
  title: z.ZodString;
880
780
  description: z.ZodNullable<z.ZodString>;
881
781
  ownerId: z.ZodString;
@@ -941,7 +841,6 @@ export declare const FlowVersion: z.ZodObject<{
941
841
  }, z.core.$strict>, z.ZodObject<{
942
842
  kind: z.ZodLiteral<"tool">;
943
843
  configuration: z.ZodObject<{
944
- sourceId: z.ZodString;
945
844
  toolName: z.ZodString;
946
845
  fingerprint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
947
846
  arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -1007,6 +906,7 @@ export type FlowVersion = z.infer<typeof FlowVersion>;
1007
906
  export declare const FlowDocument: z.ZodObject<{
1008
907
  flow: z.ZodObject<{
1009
908
  id: z.ZodString;
909
+ parentId: z.ZodNullable<z.ZodString>;
1010
910
  title: z.ZodString;
1011
911
  description: z.ZodNullable<z.ZodString>;
1012
912
  ownerId: z.ZodString;
@@ -1071,7 +971,6 @@ export declare const FlowDocument: z.ZodObject<{
1071
971
  }, z.core.$strict>, z.ZodObject<{
1072
972
  kind: z.ZodLiteral<"tool">;
1073
973
  configuration: z.ZodObject<{
1074
- sourceId: z.ZodString;
1075
974
  toolName: z.ZodString;
1076
975
  fingerprint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1077
976
  arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -1138,6 +1037,7 @@ export type FlowDocument = z.infer<typeof FlowDocument>;
1138
1037
  export declare const FlowList: z.ZodObject<{
1139
1038
  items: z.ZodArray<z.ZodObject<{
1140
1039
  id: z.ZodString;
1040
+ parentId: z.ZodNullable<z.ZodString>;
1141
1041
  title: z.ZodString;
1142
1042
  description: z.ZodNullable<z.ZodString>;
1143
1043
  ownerId: z.ZodString;
@@ -1150,11 +1050,25 @@ export declare const FlowList: z.ZodObject<{
1150
1050
  }, z.core.$strict>;
1151
1051
  export type FlowList = z.infer<typeof FlowList>;
1152
1052
  export declare const CreateFlowInput: z.ZodObject<{
1053
+ parentId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1153
1054
  title: z.ZodString;
1154
1055
  description: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1155
1056
  idempotencyKey: z.ZodString;
1156
1057
  }, z.core.$strict>;
1157
1058
  export type CreateFlowInput = z.infer<typeof CreateFlowInput>;
1059
+ export declare const UpdateFlowInput: z.ZodObject<{
1060
+ flowId: z.ZodString;
1061
+ baseUpdatedAt: z.ZodISODateTime;
1062
+ title: z.ZodOptional<z.ZodString>;
1063
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1064
+ parentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1065
+ idempotencyKey: z.ZodString;
1066
+ }, z.core.$strict>;
1067
+ export type UpdateFlowInput = z.infer<typeof UpdateFlowInput>;
1068
+ export declare const ListFlowsInput: z.ZodObject<{
1069
+ parentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1070
+ }, z.core.$strict>;
1071
+ export type ListFlowsInput = z.infer<typeof ListFlowsInput>;
1158
1072
  export declare const GetFlowInput: z.ZodObject<{
1159
1073
  flowId: z.ZodString;
1160
1074
  }, z.core.$strict>;
@@ -1213,7 +1127,6 @@ export declare const SaveFlowVersionInput: z.ZodObject<{
1213
1127
  }, z.core.$strict>, z.ZodObject<{
1214
1128
  kind: z.ZodLiteral<"tool">;
1215
1129
  configuration: z.ZodObject<{
1216
- sourceId: z.ZodString;
1217
1130
  toolName: z.ZodString;
1218
1131
  fingerprint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1219
1132
  arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -1415,7 +1328,6 @@ export declare const FlowRunStep: z.ZodObject<{
1415
1328
  }, z.core.$strict>, z.ZodObject<{
1416
1329
  kind: z.ZodLiteral<"tool">;
1417
1330
  configuration: z.ZodObject<{
1418
- sourceId: z.ZodString;
1419
1331
  toolName: z.ZodString;
1420
1332
  fingerprint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
1421
1333
  arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -9,6 +9,13 @@ export const ProblemDetails = z.strictObject({
9
9
  instance: z.string().optional(),
10
10
  code: z.string().optional(),
11
11
  });
12
+ // Who the caller is, as Gate resolved it from the bearer. Deliberately identity only: no
13
+ // capabilities, no token, nothing a surface could mistake for a permission.
14
+ export const SessionUser = z.strictObject({
15
+ id: IntelId,
16
+ email: z.email(),
17
+ name: z.string().min(1).max(240).nullable(),
18
+ });
12
19
  export const KnowledgeNodeKind = z.enum(["folder", "document", "attachment"]);
13
20
  export const ContextPolicy = z.enum(["pinned", "relevant", "explicit"]);
14
21
  export const ResourceRole = z.enum(["viewer", "commenter", "editor", "manager"]);
@@ -227,18 +234,10 @@ export const ToolSourceUrl = z.url().refine((value) => {
227
234
  catch {
228
235
  return false;
229
236
  }
230
- }, "Tool source must use an approved public HTTPS host without embedded credentials");
231
- export const ToolSource = z.strictObject({
232
- id: IntelId,
233
- name: z.string().min(1).max(120),
234
- url: ToolSourceUrl,
235
- connectionHandle: z.string().regex(/^[a-z0-9][a-z0-9-]{1,62}$/),
236
- enabled: z.boolean(),
237
- createdBy: IntelId,
238
- createdAt: IsoDateTime,
239
- updatedAt: IsoDateTime,
240
- lastDiscoveredAt: IsoDateTime.nullable(),
241
- });
237
+ }, "The portal must use an approved public HTTPS host without embedded credentials");
238
+ // The portal namespaces every upstream tool, so the name alone identifies the target server. Intel
239
+ // never learns which server that is — the portal resolves it and attaches the credentials.
240
+ export const ToolName = z.string().min(1).max(240);
242
241
  export const ToolAnnotations = z.strictObject({
243
242
  title: z.string().max(240).optional(),
244
243
  readOnlyHint: z.boolean().optional(),
@@ -247,40 +246,22 @@ export const ToolAnnotations = z.strictObject({
247
246
  openWorldHint: z.boolean().optional(),
248
247
  });
249
248
  export const ToolCapability = z.strictObject({
250
- sourceId: IntelId,
251
- name: z.string().min(1).max(240),
249
+ name: ToolName,
252
250
  title: z.string().max(240).nullable(),
253
251
  description: z.string().max(10_000).nullable(),
254
252
  inputSchema: z.record(z.string(), z.unknown()),
255
253
  outputSchema: z.record(z.string(), z.unknown()).nullable(),
256
254
  annotations: ToolAnnotations,
257
255
  fingerprint: z.string().regex(/^[a-f0-9]{64}$/),
258
- discoveredAt: IsoDateTime,
259
- });
260
- export const ToolConnectionStatus = z.enum(["connected", "missing", "forbidden", "invalid"]);
261
- export const ToolCatalogEntry = z.strictObject({
262
- source: ToolSource,
263
- capability: ToolCapability,
264
- connectionStatus: ToolConnectionStatus,
265
- });
266
- export const ToolSourceList = z.strictObject({ items: z.array(ToolSource) });
267
- export const ToolCatalog = z.strictObject({ items: z.array(ToolCatalogEntry) });
268
- export const CreateToolSourceInput = z.strictObject({
269
- name: z.string().trim().min(1).max(120),
270
- url: ToolSourceUrl,
271
- connectionHandle: z
272
- .string()
273
- .regex(/^[a-z0-9][a-z0-9-]{1,62}$/)
274
- .default("intel-tools"),
275
- idempotencyKey: z.string().min(8).max(200),
276
256
  });
277
- export const DiscoverToolSourceInput = z.strictObject({
278
- sourceId: IntelId,
279
- idempotencyKey: z.string().min(8).max(200),
257
+ // The catalog reflects one live tools/list for the requesting user. It is never stored as a
258
+ // permission mirror, so there is no per-source state and no Intel-owned connection status.
259
+ export const ToolCatalog = z.strictObject({
260
+ portalConnected: z.boolean(),
261
+ items: z.array(ToolCapability),
280
262
  });
281
263
  export const TestToolInput = z.strictObject({
282
- sourceId: IntelId,
283
- name: z.string().min(1).max(240),
264
+ name: ToolName,
284
265
  arguments: z.record(z.string(), z.unknown()).default({}),
285
266
  });
286
267
  export const ExecuteToolInput = TestToolInput;
@@ -325,8 +306,7 @@ export const FlowNode = z.discriminatedUnion("kind", [
325
306
  ...FlowNodeBase,
326
307
  kind: z.literal("tool"),
327
308
  configuration: z.strictObject({
328
- sourceId: IntelId,
329
- toolName: z.string().min(1).max(240),
309
+ toolName: ToolName,
330
310
  fingerprint: z
331
311
  .string()
332
312
  .regex(/^[a-f0-9]{64}$/)
@@ -370,6 +350,10 @@ export const FlowGraph = z.strictObject({
370
350
  });
371
351
  export const Flow = z.strictObject({
372
352
  id: IntelId,
353
+ // The one thing a Flow shares with a document: its place in the Knowledge folder tree (ADR-0004).
354
+ // Everything else stays apart — versions, R2 body and Vectorize belong to the document, the graph,
355
+ // runs and approvals to the flow. `null` is the root of that same tree.
356
+ parentId: IntelId.nullable(),
373
357
  title: z.string().min(1).max(240),
374
358
  description: z.string().max(2_000).nullable(),
375
359
  ownerId: IntelId,
@@ -393,10 +377,30 @@ export const FlowDocument = z.strictObject({
393
377
  });
394
378
  export const FlowList = z.strictObject({ items: z.array(Flow) });
395
379
  export const CreateFlowInput = z.strictObject({
380
+ parentId: IntelId.nullable().default(null),
396
381
  title: z.string().trim().min(1).max(240),
397
382
  description: z.string().trim().max(2_000).nullable().default(null),
398
383
  idempotencyKey: z.string().min(8).max(200),
399
384
  });
385
+ // Renaming and moving a flow. Both are organization and nothing else: they touch no version, no
386
+ // published graph and no run, because organization has to stay free of consequence or nobody dares
387
+ // to reorganize (ADR-0004).
388
+ export const UpdateFlowInput = z
389
+ .strictObject({
390
+ flowId: IntelId,
391
+ baseUpdatedAt: IsoDateTime,
392
+ title: z.string().trim().min(1).max(240).optional(),
393
+ description: z.string().trim().max(2_000).nullable().optional(),
394
+ parentId: IntelId.nullable().optional(),
395
+ idempotencyKey: z.string().min(8).max(200),
396
+ })
397
+ .refine((input) => input.title !== undefined || input.description !== undefined || input.parentId !== undefined, { error: "At least one change is required" });
398
+ // Three answers, not two: an absent `parentId` lists every visible flow (the search dialog asks
399
+ // that), `null` lists the root of the shared tree and an ID lists one folder (the sidebar tree asks
400
+ // per level, which is what keeps the tree off the N+1 it used to load with).
401
+ export const ListFlowsInput = z.strictObject({
402
+ parentId: IntelId.nullable().optional(),
403
+ });
400
404
  export const GetFlowInput = z.strictObject({ flowId: IntelId });
401
405
  export const SaveFlowVersionInput = z.strictObject({
402
406
  flowId: IntelId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anchrd/intel-contract",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {