@segmentstream/ontology 0.114.0 → 0.116.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.
@@ -89,6 +89,9 @@ import { type ResolvedGuest, type ResolvedSignInOptions, type SignInPolicy } fro
89
89
  * readers ignore it and send nothing through those channels. A channel the workspace defines in
90
90
  * its own code has kind `custom` and no connection, as the agent sends through it; sign-up may open
91
91
  * `channel:<name>`, its people's accounts.
92
+ * Within version 15, the top-level `inbox`, written only when declared, holds the wire names of the
93
+ * `roles` whose people's private chats the agent registers as `agent_chat` records of kind
94
+ * `private`. Older readers ignore it and register none.
92
95
  */
93
96
  export declare const MANIFEST_VERSION = 15;
94
97
  /** The phrase used for a direction the author did not phrase. */
@@ -457,7 +460,8 @@ export type ActionTriggerManifest = typeof ActionTriggerManifest.Type;
457
460
  * delivery to `/api/webhooks/<name>`. With `signature`, deliveries are checked with the provider's
458
461
  * scheme against the named workspace secret; without it, the URL ends in a derived token.
459
462
  * `verification` opts into a registration handshake; `headers` lists the request headers the
460
- * delivery carries. Optional settings are written only when declared.
463
+ * delivery carries; `connection` names the connection whose provider sends to it. Optional
464
+ * settings are written only when declared.
461
465
  */
462
466
  export declare const WebhookTriggerManifest: Schema.Struct<{
463
467
  readonly kind: Schema.Literal<"webhook">;
@@ -472,6 +476,8 @@ export declare const WebhookTriggerManifest: Schema.Struct<{
472
476
  readonly verifyToken: Schema.String;
473
477
  }>>;
474
478
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
479
+ /** The key of the connection whose provider sends to the webhook, when declared. */
480
+ readonly connection: Schema.optionalKey<Schema.String>;
475
481
  }>;
476
482
  export type WebhookTriggerManifest = typeof WebhookTriggerManifest.Type;
477
483
  /**
@@ -510,6 +516,8 @@ export declare const WorkflowTriggerManifest: Schema.Union<readonly [Schema.Stru
510
516
  readonly verifyToken: Schema.String;
511
517
  }>>;
512
518
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
519
+ /** The key of the connection whose provider sends to the webhook, when declared. */
520
+ readonly connection: Schema.optionalKey<Schema.String>;
513
521
  }>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
514
522
  export type WorkflowTriggerManifest = typeof WorkflowTriggerManifest.Type;
515
523
  /** Whether a trigger is a cron trigger. */
@@ -555,6 +563,8 @@ export declare const WorkflowManifest: Schema.Struct<{
555
563
  readonly verifyToken: Schema.String;
556
564
  }>>;
557
565
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
566
+ /** The key of the connection whose provider sends to the webhook, when declared. */
567
+ readonly connection: Schema.optionalKey<Schema.String>;
558
568
  }>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>>;
559
569
  }>;
560
570
  export type WorkflowManifest = typeof WorkflowManifest.Type;
@@ -1149,6 +1159,13 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
1149
1159
  readonly separator: Schema.optionalKey<Schema.String>;
1150
1160
  }>>;
1151
1161
  }>>;
1162
+ /**
1163
+ * Whose private chats join the inbox, within version 15: the wire names of their roles. Written
1164
+ * only when declared; absent registers no private chat, and older readers ignore it.
1165
+ */
1166
+ readonly inbox: Schema.optionalKey<Schema.Struct<{
1167
+ readonly roles: Schema.$Array<Schema.String>;
1168
+ }>>;
1152
1169
  /**
1153
1170
  * The metrics of the model, since version 8. Written only when there are some; absent reads as
1154
1171
  * none.
@@ -1203,6 +1220,8 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
1203
1220
  readonly verifyToken: Schema.String;
1204
1221
  }>>;
1205
1222
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
1223
+ /** The key of the connection whose provider sends to the webhook, when declared. */
1224
+ readonly connection: Schema.optionalKey<Schema.String>;
1206
1225
  }>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>>;
1207
1226
  }>>>;
1208
1227
  /**
@@ -1430,6 +1449,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1430
1449
  readonly kind: "webhook";
1431
1450
  readonly name: string;
1432
1451
  readonly description: string;
1452
+ readonly connection?: string | undefined;
1433
1453
  readonly signature?: {
1434
1454
  readonly scheme: string;
1435
1455
  readonly secret: string;
@@ -1541,6 +1561,9 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1541
1561
  readonly footer?: string | undefined;
1542
1562
  };
1543
1563
  } | undefined;
1564
+ readonly inbox?: {
1565
+ readonly roles: readonly string[];
1566
+ } | undefined;
1544
1567
  readonly toolsets?: readonly {
1545
1568
  readonly name: string;
1546
1569
  readonly description: string;
@@ -1739,6 +1762,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1739
1762
  readonly kind: "webhook";
1740
1763
  readonly name: string;
1741
1764
  readonly description: string;
1765
+ readonly connection?: string | undefined;
1742
1766
  readonly signature?: {
1743
1767
  readonly scheme: string;
1744
1768
  readonly secret: string;
@@ -1850,6 +1874,9 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1850
1874
  readonly footer?: string | undefined;
1851
1875
  };
1852
1876
  } | undefined;
1877
+ readonly inbox?: {
1878
+ readonly roles: readonly string[];
1879
+ } | undefined;
1853
1880
  readonly toolsets?: readonly {
1854
1881
  readonly name: string;
1855
1882
  readonly description: string;
@@ -2050,6 +2077,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2050
2077
  readonly kind: "webhook";
2051
2078
  readonly name: string;
2052
2079
  readonly description: string;
2080
+ readonly connection?: string | undefined;
2053
2081
  readonly signature?: {
2054
2082
  readonly scheme: string;
2055
2083
  readonly secret: string;
@@ -2124,6 +2152,9 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2124
2152
  readonly footer?: string | undefined;
2125
2153
  };
2126
2154
  } | undefined;
2155
+ readonly inbox?: {
2156
+ readonly roles: readonly string[];
2157
+ } | undefined;
2127
2158
  readonly toolsets?: readonly {
2128
2159
  readonly name: string;
2129
2160
  readonly description: string;
@@ -2359,6 +2390,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2359
2390
  readonly kind: "webhook";
2360
2391
  readonly name: string;
2361
2392
  readonly description: string;
2393
+ readonly connection?: string | undefined;
2362
2394
  readonly signature?: {
2363
2395
  readonly scheme: string;
2364
2396
  readonly secret: string;
@@ -2468,6 +2500,9 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2468
2500
  readonly footer?: string | undefined;
2469
2501
  };
2470
2502
  } | undefined;
2503
+ readonly inbox?: {
2504
+ readonly roles: readonly string[];
2505
+ } | undefined;
2471
2506
  readonly toolsets?: readonly {
2472
2507
  readonly name: string;
2473
2508
  readonly description: string;
@@ -2806,6 +2841,13 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2806
2841
  readonly separator: Schema.optionalKey<Schema.String>;
2807
2842
  }>>;
2808
2843
  }>>;
2844
+ /**
2845
+ * Whose private chats join the inbox, within version 15: the wire names of their roles. Written
2846
+ * only when declared; absent registers no private chat, and older readers ignore it.
2847
+ */
2848
+ readonly inbox: Schema.optionalKey<Schema.Struct<{
2849
+ readonly roles: Schema.$Array<Schema.String>;
2850
+ }>>;
2809
2851
  /**
2810
2852
  * The metrics of the model, since version 8. Written only when there are some; absent reads as
2811
2853
  * none.
@@ -2860,6 +2902,8 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2860
2902
  readonly verifyToken: Schema.String;
2861
2903
  }>>;
2862
2904
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
2905
+ /** The key of the connection whose provider sends to the webhook, when declared. */
2906
+ readonly connection: Schema.optionalKey<Schema.String>;
2863
2907
  }>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>>;
2864
2908
  }>>>;
2865
2909
  /**
@@ -3214,6 +3258,13 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3214
3258
  readonly separator: Schema.optionalKey<Schema.String>;
3215
3259
  }>>;
3216
3260
  }>>;
3261
+ /**
3262
+ * Whose private chats join the inbox, within version 15: the wire names of their roles. Written
3263
+ * only when declared; absent registers no private chat, and older readers ignore it.
3264
+ */
3265
+ readonly inbox: Schema.optionalKey<Schema.Struct<{
3266
+ readonly roles: Schema.$Array<Schema.String>;
3267
+ }>>;
3217
3268
  /**
3218
3269
  * The metrics of the model, since version 8. Written only when there are some; absent reads as
3219
3270
  * none.
@@ -3268,6 +3319,8 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3268
3319
  readonly verifyToken: Schema.String;
3269
3320
  }>>;
3270
3321
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
3322
+ /** The key of the connection whose provider sends to the webhook, when declared. */
3323
+ readonly connection: Schema.optionalKey<Schema.String>;
3271
3324
  }>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>>;
3272
3325
  }>>>;
3273
3326
  /**
@@ -3487,6 +3540,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3487
3540
  readonly kind: "webhook";
3488
3541
  readonly name: string;
3489
3542
  readonly description: string;
3543
+ readonly connection?: string | undefined;
3490
3544
  readonly signature?: {
3491
3545
  readonly scheme: string;
3492
3546
  readonly secret: string;
@@ -3598,6 +3652,9 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3598
3652
  readonly footer?: string | undefined;
3599
3653
  };
3600
3654
  } | undefined;
3655
+ readonly inbox?: {
3656
+ readonly roles: readonly string[];
3657
+ } | undefined;
3601
3658
  readonly toolsets?: readonly {
3602
3659
  readonly name: string;
3603
3660
  readonly description: string;
@@ -3796,6 +3853,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3796
3853
  readonly kind: "webhook";
3797
3854
  readonly name: string;
3798
3855
  readonly description: string;
3856
+ readonly connection?: string | undefined;
3799
3857
  readonly signature?: {
3800
3858
  readonly scheme: string;
3801
3859
  readonly secret: string;
@@ -3907,6 +3965,9 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3907
3965
  readonly footer?: string | undefined;
3908
3966
  };
3909
3967
  } | undefined;
3968
+ readonly inbox?: {
3969
+ readonly roles: readonly string[];
3970
+ } | undefined;
3910
3971
  readonly toolsets?: readonly {
3911
3972
  readonly name: string;
3912
3973
  readonly description: string;
@@ -4111,6 +4172,7 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
4111
4172
  readonly kind: "webhook";
4112
4173
  readonly name: string;
4113
4174
  readonly description: string;
4175
+ readonly connection?: string | undefined;
4114
4176
  readonly signature?: {
4115
4177
  readonly scheme: string;
4116
4178
  readonly secret: string;
@@ -4222,6 +4284,9 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
4222
4284
  readonly footer?: string | undefined;
4223
4285
  };
4224
4286
  } | undefined;
4287
+ readonly inbox?: {
4288
+ readonly roles: readonly string[];
4289
+ } | undefined;
4225
4290
  readonly toolsets?: readonly {
4226
4291
  readonly name: string;
4227
4292
  readonly description: string;
@@ -4420,6 +4485,7 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
4420
4485
  readonly kind: "webhook";
4421
4486
  readonly name: string;
4422
4487
  readonly description: string;
4488
+ readonly connection?: string | undefined;
4423
4489
  readonly signature?: {
4424
4490
  readonly scheme: string;
4425
4491
  readonly secret: string;
@@ -4531,6 +4597,9 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
4531
4597
  readonly footer?: string | undefined;
4532
4598
  };
4533
4599
  } | undefined;
4600
+ readonly inbox?: {
4601
+ readonly roles: readonly string[];
4602
+ } | undefined;
4534
4603
  readonly toolsets?: readonly {
4535
4604
  readonly name: string;
4536
4605
  readonly description: string;
@@ -4579,6 +4648,8 @@ export declare function signInPolicyOf(manifest: Pick<OntologyManifest, "signIn"
4579
4648
  * the channel is closed to sign-up: not a channel this reader knows, or no well-formed entry.
4580
4649
  */
4581
4650
  export declare function signUpRolesOf(manifest: Pick<OntologyManifest, "signIn">, channel: string): ReadonlyArray<string> | undefined;
4651
+ /** The wire names of the roles whose people's private chats join the inbox; empty without one. */
4652
+ export declare function inboxRolesOf(manifest: Pick<OntologyManifest, "inbox">): ReadonlySet<string>;
4582
4653
  /**
4583
4654
  * The websites whose visitors may sign up on `web`, by origin: empty while `web` is closed to
4584
4655
  * sign-up. Entries that are not an origin `signUp.origins` accepts are left out.
@@ -4629,6 +4700,9 @@ export interface ChatManifestInput {
4629
4700
  export declare function buildManifest(input: {
4630
4701
  readonly feedback?: ResolvedFeedback;
4631
4702
  readonly chat?: ChatManifestInput;
4703
+ readonly inbox?: {
4704
+ readonly roles: ReadonlyArray<string>;
4705
+ };
4632
4706
  readonly entities: ReadonlyArray<ResolvedEntity>;
4633
4707
  readonly roles: ReadonlyArray<Role>;
4634
4708
  readonly signIn: ResolvedSignInOptions;
package/dist/manifest.js CHANGED
@@ -89,6 +89,9 @@ import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isGuestBotCheckScheme, isGue
89
89
  * readers ignore it and send nothing through those channels. A channel the workspace defines in
90
90
  * its own code has kind `custom` and no connection, as the agent sends through it; sign-up may open
91
91
  * `channel:<name>`, its people's accounts.
92
+ * Within version 15, the top-level `inbox`, written only when declared, holds the wire names of the
93
+ * `roles` whose people's private chats the agent registers as `agent_chat` records of kind
94
+ * `private`. Older readers ignore it and register none.
92
95
  */
93
96
  export const MANIFEST_VERSION = 15;
94
97
  /** The first version whose documents use snake_case names on the wire. */
@@ -327,7 +330,8 @@ export const ActionTriggerManifest = Schema.Struct({
327
330
  * delivery to `/api/webhooks/<name>`. With `signature`, deliveries are checked with the provider's
328
331
  * scheme against the named workspace secret; without it, the URL ends in a derived token.
329
332
  * `verification` opts into a registration handshake; `headers` lists the request headers the
330
- * delivery carries. Optional settings are written only when declared.
333
+ * delivery carries; `connection` names the connection whose provider sends to it. Optional
334
+ * settings are written only when declared.
331
335
  */
332
336
  export const WebhookTriggerManifest = Schema.Struct({
333
337
  kind: Schema.Literal("webhook"),
@@ -336,6 +340,8 @@ export const WebhookTriggerManifest = Schema.Struct({
336
340
  signature: Schema.optionalKey(Schema.Struct({ scheme: Schema.String, secret: Schema.String })),
337
341
  verification: Schema.optionalKey(Schema.Struct({ scheme: Schema.String, verifyToken: Schema.String })),
338
342
  headers: Schema.optionalKey(Schema.Array(Schema.String)),
343
+ /** The key of the connection whose provider sends to the webhook, when declared. */
344
+ connection: Schema.optionalKey(Schema.String),
339
345
  });
340
346
  /** The trigger kinds this reader knows. */
341
347
  const KNOWN_TRIGGER_KINDS = ["cron", "action", "webhook"];
@@ -543,6 +549,11 @@ const OntologyManifestModel = Schema.Struct({
543
549
  separator: Schema.optionalKey(Schema.String),
544
550
  })),
545
551
  })),
552
+ /**
553
+ * Whose private chats join the inbox, within version 15: the wire names of their roles. Written
554
+ * only when declared; absent registers no private chat, and older readers ignore it.
555
+ */
556
+ inbox: Schema.optionalKey(Schema.Struct({ roles: Schema.Array(Schema.String) })),
546
557
  /**
547
558
  * The metrics of the model, since version 8. Written only when there are some; absent reads as
548
559
  * none.
@@ -637,6 +648,10 @@ export function signUpRolesOf(manifest, channel) {
637
648
  ? roles
638
649
  : undefined;
639
650
  }
651
+ /** The wire names of the roles whose people's private chats join the inbox; empty without one. */
652
+ export function inboxRolesOf(manifest) {
653
+ return new Set(manifest.inbox?.roles ?? []);
654
+ }
640
655
  /**
641
656
  * The websites whose visitors may sign up on `web`, by origin: empty while `web` is closed to
642
657
  * sign-up. Entries that are not an origin `signUp.origins` accepts are left out.
@@ -974,6 +989,7 @@ export function buildManifest(input) {
974
989
  },
975
990
  ...(Object.keys(emails).length > 0 ? { emails } : {}),
976
991
  ...(input.chat === undefined ? {} : { chat: input.chat }),
992
+ ...(input.inbox === undefined ? {} : { inbox: { roles: [...input.inbox.roles] } }),
977
993
  ...(connections.length > 0
978
994
  ? {
979
995
  connections: connections.map((candidate) => ({
@@ -444,6 +444,7 @@ export declare const MigrationPlan: Schema.Struct<{
444
444
  readonly kind: "webhook";
445
445
  readonly name: string;
446
446
  readonly description: string;
447
+ readonly connection?: string | undefined;
447
448
  readonly signature?: {
448
449
  readonly scheme: string;
449
450
  readonly secret: string;
@@ -555,6 +556,9 @@ export declare const MigrationPlan: Schema.Struct<{
555
556
  readonly footer?: string | undefined;
556
557
  };
557
558
  } | undefined;
559
+ readonly inbox?: {
560
+ readonly roles: readonly string[];
561
+ } | undefined;
558
562
  readonly toolsets?: readonly {
559
563
  readonly name: string;
560
564
  readonly description: string;
@@ -753,6 +757,7 @@ export declare const MigrationPlan: Schema.Struct<{
753
757
  readonly kind: "webhook";
754
758
  readonly name: string;
755
759
  readonly description: string;
760
+ readonly connection?: string | undefined;
756
761
  readonly signature?: {
757
762
  readonly scheme: string;
758
763
  readonly secret: string;
@@ -864,6 +869,9 @@ export declare const MigrationPlan: Schema.Struct<{
864
869
  readonly footer?: string | undefined;
865
870
  };
866
871
  } | undefined;
872
+ readonly inbox?: {
873
+ readonly roles: readonly string[];
874
+ } | undefined;
867
875
  readonly toolsets?: readonly {
868
876
  readonly name: string;
869
877
  readonly description: string;
@@ -1064,6 +1072,7 @@ export declare const MigrationPlan: Schema.Struct<{
1064
1072
  readonly kind: "webhook";
1065
1073
  readonly name: string;
1066
1074
  readonly description: string;
1075
+ readonly connection?: string | undefined;
1067
1076
  readonly signature?: {
1068
1077
  readonly scheme: string;
1069
1078
  readonly secret: string;
@@ -1138,6 +1147,9 @@ export declare const MigrationPlan: Schema.Struct<{
1138
1147
  readonly footer?: string | undefined;
1139
1148
  };
1140
1149
  } | undefined;
1150
+ readonly inbox?: {
1151
+ readonly roles: readonly string[];
1152
+ } | undefined;
1141
1153
  readonly toolsets?: readonly {
1142
1154
  readonly name: string;
1143
1155
  readonly description: string;
@@ -1373,6 +1385,7 @@ export declare const MigrationPlan: Schema.Struct<{
1373
1385
  readonly kind: "webhook";
1374
1386
  readonly name: string;
1375
1387
  readonly description: string;
1388
+ readonly connection?: string | undefined;
1376
1389
  readonly signature?: {
1377
1390
  readonly scheme: string;
1378
1391
  readonly secret: string;
@@ -1482,6 +1495,9 @@ export declare const MigrationPlan: Schema.Struct<{
1482
1495
  readonly footer?: string | undefined;
1483
1496
  };
1484
1497
  } | undefined;
1498
+ readonly inbox?: {
1499
+ readonly roles: readonly string[];
1500
+ } | undefined;
1485
1501
  readonly toolsets?: readonly {
1486
1502
  readonly name: string;
1487
1503
  readonly description: string;
@@ -1761,6 +1777,9 @@ export declare const MigrationPlan: Schema.Struct<{
1761
1777
  readonly separator: Schema.optionalKey<Schema.String>;
1762
1778
  }>>;
1763
1779
  }>>;
1780
+ readonly inbox: Schema.optionalKey<Schema.Struct<{
1781
+ readonly roles: Schema.$Array<Schema.String>;
1782
+ }>>;
1764
1783
  readonly metrics: Schema.optionalKey<Schema.$Array<Schema.Struct<{
1765
1784
  readonly name: Schema.String;
1766
1785
  readonly label: Schema.String;
@@ -1802,6 +1821,7 @@ export declare const MigrationPlan: Schema.Struct<{
1802
1821
  readonly verifyToken: Schema.String;
1803
1822
  }>>;
1804
1823
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
1824
+ readonly connection: Schema.optionalKey<Schema.String>;
1805
1825
  }>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>>;
1806
1826
  }>>>;
1807
1827
  readonly toolsets: Schema.optionalKey<Schema.$Array<Schema.Struct<{
@@ -2066,6 +2086,9 @@ export declare const MigrationPlan: Schema.Struct<{
2066
2086
  readonly separator: Schema.optionalKey<Schema.String>;
2067
2087
  }>>;
2068
2088
  }>>;
2089
+ readonly inbox: Schema.optionalKey<Schema.Struct<{
2090
+ readonly roles: Schema.$Array<Schema.String>;
2091
+ }>>;
2069
2092
  readonly metrics: Schema.optionalKey<Schema.$Array<Schema.Struct<{
2070
2093
  readonly name: Schema.String;
2071
2094
  readonly label: Schema.String;
@@ -2107,6 +2130,7 @@ export declare const MigrationPlan: Schema.Struct<{
2107
2130
  readonly verifyToken: Schema.String;
2108
2131
  }>>;
2109
2132
  readonly headers: Schema.optionalKey<Schema.$Array<Schema.String>>;
2133
+ readonly connection: Schema.optionalKey<Schema.String>;
2110
2134
  }>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>>;
2111
2135
  }>>>;
2112
2136
  readonly toolsets: Schema.optionalKey<Schema.$Array<Schema.Struct<{
@@ -2303,6 +2327,7 @@ export declare const MigrationPlan: Schema.Struct<{
2303
2327
  readonly kind: "webhook";
2304
2328
  readonly name: string;
2305
2329
  readonly description: string;
2330
+ readonly connection?: string | undefined;
2306
2331
  readonly signature?: {
2307
2332
  readonly scheme: string;
2308
2333
  readonly secret: string;
@@ -2414,6 +2439,9 @@ export declare const MigrationPlan: Schema.Struct<{
2414
2439
  readonly footer?: string | undefined;
2415
2440
  };
2416
2441
  } | undefined;
2442
+ readonly inbox?: {
2443
+ readonly roles: readonly string[];
2444
+ } | undefined;
2417
2445
  readonly toolsets?: readonly {
2418
2446
  readonly name: string;
2419
2447
  readonly description: string;
@@ -2612,6 +2640,7 @@ export declare const MigrationPlan: Schema.Struct<{
2612
2640
  readonly kind: "webhook";
2613
2641
  readonly name: string;
2614
2642
  readonly description: string;
2643
+ readonly connection?: string | undefined;
2615
2644
  readonly signature?: {
2616
2645
  readonly scheme: string;
2617
2646
  readonly secret: string;
@@ -2723,6 +2752,9 @@ export declare const MigrationPlan: Schema.Struct<{
2723
2752
  readonly footer?: string | undefined;
2724
2753
  };
2725
2754
  } | undefined;
2755
+ readonly inbox?: {
2756
+ readonly roles: readonly string[];
2757
+ } | undefined;
2726
2758
  readonly toolsets?: readonly {
2727
2759
  readonly name: string;
2728
2760
  readonly description: string;
@@ -1,7 +1,7 @@
1
1
  import { Effect } from "effect";
2
2
  import { SqlClient } from "effect/unstable/sql";
3
3
  import type { Ontology } from "../ontology.js";
4
- import { type AgentStore, type ResolveIdentityInput, type ChannelSignInInput } from "../service/runtime-contract.js";
4
+ import { type AgentResolution, type AgentStore, type ResolveIdentityInput, type ChannelSignInInput } from "../service/runtime-contract.js";
5
5
  /**
6
6
  * The agent store on the runtime's agent tables, as `ontology_app`. Expiry is the database's
7
7
  * `now()`; a pairing is consumed with one `UPDATE … WHERE "consumed_at" IS NULL`, so two concurrent
@@ -10,6 +10,6 @@ import { type AgentStore, type ResolveIdentityInput, type ChannelSignInInput } f
10
10
  */
11
11
  export declare function sqlAgentStore(ontology: Ontology, sql: SqlClient.SqlClient): AgentStore;
12
12
  /** Shared verified admission for agents and channel-app adapters; never expose trusted inputs to browsers. */
13
- export declare function resolveChannelIdentity(ontology: Ontology, sql: SqlClient.SqlClient, input: ResolveIdentityInput): Effect.Effect<import("../index.js").AgentResolution, never, never>;
13
+ export declare function resolveChannelIdentity(ontology: Ontology, sql: SqlClient.SqlClient, input: ResolveIdentityInput): Effect.Effect<AgentResolution, never, never>;
14
14
  /** Call only after verifying a channel-app assertion. Shares admission, limits and onboarding with agents. */
15
- export declare function resolveChannelSignIn(ontology: Ontology, sql: SqlClient.SqlClient, input: ChannelSignInInput): Effect.Effect<import("../index.js").AgentResolution, never, never>;
15
+ export declare function resolveChannelSignIn(ontology: Ontology, sql: SqlClient.SqlClient, input: ChannelSignInInput): Effect.Effect<AgentResolution, never, never>;
@@ -6,6 +6,7 @@ import { AgentChat } from "../agent-chat.js";
6
6
  import { chatChannelKind } from "../chat-channel.js";
7
7
  import { AgentReview } from "../agent-review.js";
8
8
  import { AGENT_IDENTITIES_TABLE, AGENT_PAIRINGS_TABLE, CHANNEL_USERS_TABLE, IDENTITY_NOTICES_TABLE, USER_TABLE, } from "../migrate/storage.js";
9
+ import { inboxRolesOf } from "../manifest.js";
9
10
  import { MAX_QUERY_LIMIT } from "../query.js";
10
11
  import { beginReplicationWrite } from "../replication/transaction.js";
11
12
  import { IdentityInUse, } from "../service/runtime-contract.js";
@@ -215,7 +216,7 @@ export function sqlAgentStore(ontology, sql) {
215
216
  return created === undefined ? undefined : identityOf(created);
216
217
  }))
217
218
  .pipe(Effect.catchIf((error) => error._tag !== "IdentityInUse", (error) => Effect.die(error))),
218
- resolveIdentity: (input) => resolveAgentIdentity(ontology, sql, store, input),
219
+ resolveIdentity: (input) => resolveAgentIdentity(ontology, sql, store, input).pipe(Effect.map((resolution) => inInbox(ontology, input, resolution))),
219
220
  completeLimitNotice: (input) => completeAgentLimitNotice(sql, input),
220
221
  setMemberBlocked: (input) => setMemberBlocked(ontology, input).pipe(Effect.provideService(SqlClient.SqlClient, sql), Effect.as(true), Effect.catchTag("MemberNotFound", () => Effect.succeed(false))),
221
222
  // The notice is operational state beside the identity; the legacy columns are kept in step.
@@ -446,6 +447,96 @@ export function sqlAgentStore(ontology, sql) {
446
447
  };
447
448
  }))
448
449
  .pipe(Effect.orDie),
450
+ seeInboxChat: (input) => Effect.gen(function* () {
451
+ const roles = inboxRolesOf(ontology.manifest);
452
+ const member = isRecordId(input.memberId) ? yield* store.member(input.memberId) : undefined;
453
+ // Only the private chats of people whose roles the inbox takes are recorded.
454
+ if (member === undefined || !member.principal.roles.some((role) => roles.has(role))) {
455
+ return undefined;
456
+ }
457
+ return yield* sql.withTransaction(Effect.gen(function* () {
458
+ yield* beginReplicationWrite(sql);
459
+ // Calls for one chat run one after the other: the first creates it, the rest find it.
460
+ yield* rows(`SELECT pg_advisory_xact_lock(hashtext($1))`, [
461
+ `chat:${input.provider}:${input.externalId}`,
462
+ ]);
463
+ const runtime = makeOntologyRuntime(ontology, sql, {
464
+ action: `${AgentChat.name}.seen`,
465
+ actionId: randomUUID(),
466
+ principalId: null,
467
+ });
468
+ const [found] = yield* runtime.find({
469
+ entity: AgentChat.name,
470
+ options: {
471
+ where: { provider: input.provider, external_id: input.externalId },
472
+ limit: 1,
473
+ forUpdate: true,
474
+ },
475
+ });
476
+ // A group chat's id is never a person's private chat.
477
+ if (found !== undefined && found.kind !== "private") {
478
+ return undefined;
479
+ }
480
+ const now = new Date();
481
+ const recipient = input.recipient ?? null;
482
+ const threadId = input.threadId ?? null;
483
+ const changes = {
484
+ ...(found?.title === input.title ? {} : { title: input.title }),
485
+ ...((found?.recipient ?? null) === recipient ? {} : { recipient }),
486
+ ...((found?.thread_id ?? null) === threadId ? {} : { thread_id: threadId }),
487
+ ...(messageDue(found?.last_message_at, now)
488
+ ? { last_message_at: now.toISOString() }
489
+ : {}),
490
+ };
491
+ const chat = found === undefined
492
+ ? yield* runtime.create({
493
+ entity: AgentChat.name,
494
+ values: {
495
+ provider: input.provider,
496
+ external_id: input.externalId,
497
+ kind: "private",
498
+ ...changes,
499
+ },
500
+ })
501
+ : Object.keys(changes).length === 0
502
+ ? found
503
+ : yield* runtime.update({
504
+ entity: AgentChat.name,
505
+ id: String(found.id),
506
+ values: changes,
507
+ });
508
+ // A private chat has one member, its person now: an account paired with someone else
509
+ // since leaves the earlier person out. A link already there changes nothing.
510
+ const members = yield* runtime.related({
511
+ entity: AgentChat.name,
512
+ id: String(chat.id),
513
+ relationship: "members",
514
+ query: { limit: MAX_QUERY_LIMIT },
515
+ });
516
+ for (const member of members.items) {
517
+ if (String(member.id) !== input.memberId) {
518
+ yield* runtime.unlink({
519
+ entity: AgentChat.name,
520
+ relationship: "members",
521
+ id: String(chat.id),
522
+ targetId: String(member.id),
523
+ });
524
+ }
525
+ }
526
+ yield* runtime.link({
527
+ entity: AgentChat.name,
528
+ relationship: "members",
529
+ id: String(chat.id),
530
+ targetId: input.memberId,
531
+ });
532
+ return {
533
+ id: String(chat.id),
534
+ title: String(chat.title),
535
+ purpose: nullableText(chat.purpose),
536
+ whenToUse: nullableText(chat.when_to_use),
537
+ };
538
+ }));
539
+ }).pipe(Effect.orDie),
449
540
  holdReply: (input) => sql
450
541
  .withTransaction(Effect.gen(function* () {
451
542
  if (!isRecordId(input.memberId)) {
@@ -522,3 +613,15 @@ export function resolveChannelSignIn(ontology, sql, input) {
522
613
  };
523
614
  return resolveAgentIdentity(ontology, sql, sqlAgentStore(ontology, sql), identity, "channel_app");
524
615
  }
616
+ /**
617
+ * Marks an admitted person's private chat for the inbox when they hold one of its roles, so the
618
+ * agent reports the chat and the ontology registers it.
619
+ */
620
+ function inInbox(ontology, input, resolution) {
621
+ const roles = inboxRolesOf(ontology.manifest);
622
+ return (resolution.status === "existing" || resolution.status === "created") &&
623
+ input.chat === "private" &&
624
+ resolution.member.principal.roles.some((role) => roles.has(role))
625
+ ? { ...resolution, inbox: true }
626
+ : resolution;
627
+ }
@@ -34,6 +34,11 @@ export type ChatArchiveTransport = (input: {
34
34
  * `agent_chat:read`, as their attachments are; see `withChatMembership`.
35
35
  */
36
36
  readonly memberGroups?: ReadonlyArray<string>;
37
+ /**
38
+ * Chats (`provider:chatId`) of any type the ontology checked the member may read, such as a
39
+ * private chat its inbox registered, which `agent_chat:read` within its scope reads.
40
+ */
41
+ readonly chats?: ReadonlyArray<string>;
37
42
  }) => Effect.Effect<ChatPage, ChatArchiveUnavailable | PermissionDenied>;
38
43
  /** The authenticated ontology service forwards its resolved member, never a caller-supplied ID. */
39
44
  export declare function platformChatArchive(environment: OntologyEnvironment, fetchImpl?: typeof fetch): ChatArchiveTransport;
@@ -22,7 +22,7 @@ export class ChatArchiveUnavailable extends Schema.TaggedError()("ChatArchiveUna
22
22
  }
23
23
  /** The authenticated ontology service forwards its resolved member, never a caller-supplied ID. */
24
24
  export function platformChatArchive(environment, fetchImpl = fetch) {
25
- return ({ search, principal, identityToken, memberGroups }) => {
25
+ return ({ search, principal, identityToken, memberGroups, chats }) => {
26
26
  if (principal.kind !== "member") {
27
27
  return Effect.fail(new PermissionDenied({
28
28
  message: "Only members may read chats.",
@@ -49,6 +49,7 @@ export function platformChatArchive(environment, fetchImpl = fetch) {
49
49
  participantId: principal.id,
50
50
  groups: isAllowed("agent_chat:read", principal),
51
51
  groupChats: memberGroups ?? [],
52
+ ...(chats === undefined || chats.length === 0 ? {} : { chats }),
52
53
  admin: false,
53
54
  },
54
55
  }),
@@ -123,6 +123,9 @@ export declare const ChatSeenRequest: Schema.Struct<{
123
123
  readonly leftMemberId: Schema.optionalKey<Schema.String>;
124
124
  readonly agentLeft: Schema.optionalKey<Schema.Literal<true>>;
125
125
  readonly migratedFrom: Schema.optionalKey<Schema.String>;
126
+ readonly kind: Schema.optionalKey<Schema.Literal<"private">>;
127
+ readonly recipient: Schema.optionalKey<Schema.String>;
128
+ readonly threadId: Schema.optionalKey<Schema.String>;
126
129
  }>;
127
130
  /**
128
131
  * `POST /api/ontology/agent/reviews`: a reply the agent held for a member to review, for the member