@segmentstream/ontology 0.111.0 → 0.114.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 (51) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +9 -3
  3. package/dist/analyze.d.ts +8 -4
  4. package/dist/analyze.js +83 -35
  5. package/dist/chat-channel.d.ts +27 -2
  6. package/dist/chat-channel.js +36 -2
  7. package/dist/email-html.d.ts +23 -0
  8. package/dist/email-html.js +249 -0
  9. package/dist/emails.d.ts +38 -6
  10. package/dist/emails.js +71 -2
  11. package/dist/index.d.ts +5 -3
  12. package/dist/index.js +3 -1
  13. package/dist/manifest.d.ts +208 -52
  14. package/dist/manifest.js +32 -6
  15. package/dist/migrate/model.d.ts +98 -34
  16. package/dist/permissions.d.ts +10 -3
  17. package/dist/permissions.js +10 -3
  18. package/dist/runtime/guests.d.ts +2 -1
  19. package/dist/runtime/guests.js +4 -3
  20. package/dist/runtime/resolve-agent-identity.js +4 -1
  21. package/dist/service/agent/protocol.d.ts +4 -1
  22. package/dist/service/agent/protocol.js +7 -3
  23. package/dist/service/agent/server.js +8 -2
  24. package/dist/service/authentication.d.ts +2 -1
  25. package/dist/service/authentication.js +13 -3
  26. package/dist/service/chat/delivery.d.ts +10 -1
  27. package/dist/service/chat/delivery.js +21 -3
  28. package/dist/service/chat/envelope.d.ts +2 -2
  29. package/dist/service/chat/providers/custom.d.ts +13 -0
  30. package/dist/service/chat/providers/custom.js +103 -0
  31. package/dist/service/chat/providers/index.d.ts +1 -0
  32. package/dist/service/chat/providers/index.js +12 -3
  33. package/dist/service/chat/providers/provider.d.ts +19 -0
  34. package/dist/service/chat/reads.d.ts +1 -1
  35. package/dist/service/chat/reads.js +2 -2
  36. package/dist/service/chat/resolve.d.ts +2 -1
  37. package/dist/service/chat/resolve.js +6 -2
  38. package/dist/service/chat/review-delivery.d.ts +3 -0
  39. package/dist/service/chat/review-delivery.js +9 -3
  40. package/dist/service/chat/schemas.d.ts +2 -2
  41. package/dist/service/chat/schemas.js +2 -2
  42. package/dist/service/config.d.ts +6 -2
  43. package/dist/service/schemas.d.ts +30 -8
  44. package/dist/service/service.js +6 -1
  45. package/dist/sign-in.d.ts +22 -1
  46. package/dist/sign-in.js +3 -1
  47. package/dist/storage/tables.d.ts +4 -3
  48. package/dist/storage/tables.js +11 -3
  49. package/dist/workspace-channel.d.ts +54 -0
  50. package/dist/workspace-channel.js +36 -0
  51. package/package.json +5 -1
package/dist/manifest.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CHAT_CHANNEL_KINDS, CHAT_CHANNEL_NAME } from "./chat-channel.js";
1
+ import { CHAT_CHANNEL_NAME, CHAT_KINDS } from "./chat-channel.js";
2
2
  import { balancesOf, metricExpression } from "./metric.js";
3
3
  import { Effect, Schema, SchemaTransformation } from "effect";
4
4
  import { acceptingEarlierManifestNames, withEarlierManifestNames } from "./legacy.js";
@@ -78,9 +78,17 @@ import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isGuestBotCheckScheme, isGue
78
78
  * guest passes and the workspace secret its verification reads, and `confirmations: true`, written
79
79
  * only when declared. Older readers ignore both: they ask new guests for no challenge, and keep
80
80
  * refusing guests the actions that need a confirmation.
81
+ * Within version 15, `signIn` may also carry `linkEmail` and `codeEmail`, written only when
82
+ * declared: the wire names of the emails the platform sends instead of its own sign-in link and
83
+ * sign-in code; the code email fills `{{code}}`. Older readers ignore both and send the platform's.
84
+ * Within version 15, an email may instead be a document the workspace lays out itself: `subject`,
85
+ * `html` and `text`, whose placeholders include `{{link}}`, the sign-in link. Older readers do not
86
+ * decode such an email and send the platform's own in its place where they can.
81
87
  * Within version 15, `chat` may carry `channels`, written only when declared: the agent's channels
82
88
  * not named after their kind, such as `sales_whatsapp`, each with its `kind` and connection. Older
83
- * readers ignore it and send nothing through those channels.
89
+ * readers ignore it and send nothing through those channels. A channel the workspace defines in
90
+ * its own code has kind `custom` and no connection, as the agent sends through it; sign-up may open
91
+ * `channel:<name>`, its people's accounts.
84
92
  */
85
93
  export const MANIFEST_VERSION = 15;
86
94
  /** The first version whose documents use snake_case names on the wire. */
@@ -439,15 +447,21 @@ export const SignInManifest = Schema.Struct({
439
447
  guest: Schema.optionalKey(GuestManifest),
440
448
  /** The wire name of the email the platform sends instead of its own invitation. */
441
449
  invitationEmail: Schema.optionalKey(Schema.String),
450
+ /** The wire name of the email the platform sends instead of its own sign-in link. */
451
+ linkEmail: Schema.optionalKey(Schema.String),
452
+ /** The wire name of the email the platform sends instead of its own sign-in code. */
453
+ codeEmail: Schema.optionalKey(Schema.String),
442
454
  }).pipe(Schema.encodeKeys({
443
455
  onNewUser: "on_new_user",
444
456
  codeLink: "code_link",
445
457
  signUp: "sign_up",
446
458
  onSignUp: "on_sign_up",
447
459
  invitationEmail: "invitation_email",
460
+ linkEmail: "link_email",
461
+ codeEmail: "code_email",
448
462
  }));
449
- /** One of the workspace's emails, as `defineOntology({ emails })` declares it; see `EmailTemplate`. */
450
- export const EmailTemplateManifest = Schema.Struct({
463
+ /** An email as fields the platform lays out; see `EmailLayout`. */
464
+ export const EmailLayoutManifest = Schema.Struct({
451
465
  subject: Schema.String,
452
466
  eyebrow: Schema.optionalKey(Schema.String),
453
467
  heading: Schema.String,
@@ -469,6 +483,15 @@ export const EmailTemplateManifest = Schema.Struct({
469
483
  footer: Schema.optionalKey(Schema.String),
470
484
  replyTo: Schema.optionalKey(Schema.String),
471
485
  }).pipe(Schema.encodeKeys({ replyTo: "reply_to" }));
486
+ /** An email the workspace lays out itself: subject, HTML and plain text; see `EmailDocument`. */
487
+ export const EmailDocumentManifest = Schema.Struct({
488
+ subject: Schema.String,
489
+ html: Schema.String,
490
+ text: Schema.String,
491
+ replyTo: Schema.optionalKey(Schema.String),
492
+ }).pipe(Schema.encodeKeys({ replyTo: "reply_to" }));
493
+ /** One of the workspace's emails, as `defineOntology({ emails })` declares it; see `EmailTemplate`. */
494
+ export const EmailTemplateManifest = Schema.Union([EmailDocumentManifest, EmailLayoutManifest]);
472
495
  /**
473
496
  * The ontology catalog: the contract between the SDK, backend-next, the console and the CLI. Decoding
474
497
  * ignores unknown fields and accepts any `version`. The closed sets (property types, cardinalities,
@@ -511,8 +534,9 @@ const OntologyManifestModel = Schema.Struct({
511
534
  whatsapp: Schema.optionalKey(Schema.Struct({ connection: Schema.String })),
512
535
  email: Schema.optionalKey(Schema.Struct({ connection: Schema.String })),
513
536
  channels: Schema.optionalKey(Schema.Record(Schema.String.check(Schema.isPattern(CHAT_CHANNEL_NAME)), Schema.Struct({
514
- kind: Schema.Literals(CHAT_CHANNEL_KINDS),
515
- connection: Schema.String,
537
+ kind: Schema.Literals(CHAT_KINDS),
538
+ // A workspace channel (`custom`) has none: the agent sends through it.
539
+ connection: Schema.optionalKey(Schema.String),
516
540
  }))),
517
541
  attribution: Schema.optionalKey(Schema.Struct({
518
542
  template: Schema.optionalKey(Schema.String),
@@ -911,6 +935,8 @@ export function buildManifest(input) {
911
935
  ...(input.signIn.invitationEmail === undefined
912
936
  ? {}
913
937
  : { invitationEmail: input.signIn.invitationEmail }),
938
+ ...(input.signIn.linkEmail === undefined ? {} : { linkEmail: input.signIn.linkEmail }),
939
+ ...(input.signIn.codeEmail === undefined ? {} : { codeEmail: input.signIn.codeEmail }),
914
940
  ...(Object.keys(input.signIn.channels ?? {}).length > 0
915
941
  ? { channels: input.signIn.channels }
916
942
  : {}),
@@ -400,19 +400,19 @@ export declare const MigrationPlan: Schema.Struct<{
400
400
  readonly telegram?: {
401
401
  readonly connection: string;
402
402
  } | undefined;
403
- readonly email?: {
403
+ readonly slack?: {
404
404
  readonly connection: string;
405
405
  } | undefined;
406
406
  readonly whatsapp?: {
407
407
  readonly connection: string;
408
408
  } | undefined;
409
- readonly slack?: {
409
+ readonly email?: {
410
410
  readonly connection: string;
411
411
  } | undefined;
412
412
  readonly channels?: {
413
413
  readonly [x: string]: {
414
- readonly kind: "telegram" | "email" | "whatsapp" | "slack";
415
- readonly connection: string;
414
+ readonly kind: "telegram" | "slack" | "whatsapp" | "email" | "custom";
415
+ readonly connection?: string | undefined;
416
416
  };
417
417
  } | undefined;
418
418
  readonly attribution?: {
@@ -517,9 +517,16 @@ export declare const MigrationPlan: Schema.Struct<{
517
517
  } | undefined;
518
518
  readonly onSignUp?: string | undefined;
519
519
  readonly invitationEmail?: string | undefined;
520
+ readonly linkEmail?: string | undefined;
521
+ readonly codeEmail?: string | undefined;
520
522
  } | undefined;
521
523
  readonly emails?: {
522
524
  readonly [x: string]: {
525
+ readonly subject: string;
526
+ readonly text: string;
527
+ readonly html: string;
528
+ readonly replyTo?: string | undefined;
529
+ } | {
523
530
  readonly subject: string;
524
531
  readonly action: string;
525
532
  readonly heading: string;
@@ -702,19 +709,19 @@ export declare const MigrationPlan: Schema.Struct<{
702
709
  readonly telegram?: {
703
710
  readonly connection: string;
704
711
  } | undefined;
705
- readonly email?: {
712
+ readonly slack?: {
706
713
  readonly connection: string;
707
714
  } | undefined;
708
715
  readonly whatsapp?: {
709
716
  readonly connection: string;
710
717
  } | undefined;
711
- readonly slack?: {
718
+ readonly email?: {
712
719
  readonly connection: string;
713
720
  } | undefined;
714
721
  readonly channels?: {
715
722
  readonly [x: string]: {
716
- readonly kind: "telegram" | "email" | "whatsapp" | "slack";
717
- readonly connection: string;
723
+ readonly kind: "telegram" | "slack" | "whatsapp" | "email" | "custom";
724
+ readonly connection?: string | undefined;
718
725
  };
719
726
  } | undefined;
720
727
  readonly attribution?: {
@@ -819,9 +826,16 @@ export declare const MigrationPlan: Schema.Struct<{
819
826
  } | undefined;
820
827
  readonly onSignUp?: string | undefined;
821
828
  readonly invitationEmail?: string | undefined;
829
+ readonly linkEmail?: string | undefined;
830
+ readonly codeEmail?: string | undefined;
822
831
  } | undefined;
823
832
  readonly emails?: {
824
833
  readonly [x: string]: {
834
+ readonly subject: string;
835
+ readonly text: string;
836
+ readonly html: string;
837
+ readonly replyTo?: string | undefined;
838
+ } | {
825
839
  readonly subject: string;
826
840
  readonly action: string;
827
841
  readonly heading: string;
@@ -1004,19 +1018,19 @@ export declare const MigrationPlan: Schema.Struct<{
1004
1018
  readonly telegram?: {
1005
1019
  readonly connection: string;
1006
1020
  } | undefined;
1007
- readonly email?: {
1021
+ readonly slack?: {
1008
1022
  readonly connection: string;
1009
1023
  } | undefined;
1010
1024
  readonly whatsapp?: {
1011
1025
  readonly connection: string;
1012
1026
  } | undefined;
1013
- readonly slack?: {
1027
+ readonly email?: {
1014
1028
  readonly connection: string;
1015
1029
  } | undefined;
1016
1030
  readonly channels?: {
1017
1031
  readonly [x: string]: {
1018
- readonly kind: "telegram" | "email" | "whatsapp" | "slack";
1019
- readonly connection: string;
1032
+ readonly kind: "telegram" | "slack" | "whatsapp" | "email" | "custom";
1033
+ readonly connection?: string | undefined;
1020
1034
  };
1021
1035
  } | undefined;
1022
1036
  readonly attribution?: {
@@ -1091,9 +1105,15 @@ export declare const MigrationPlan: Schema.Struct<{
1091
1105
  } | undefined;
1092
1106
  readonly emails?: {
1093
1107
  readonly [x: string]: {
1108
+ readonly subject: string;
1109
+ readonly text: string;
1110
+ readonly html: string;
1111
+ readonly reply_to?: string | undefined;
1112
+ } | {
1094
1113
  readonly subject: string;
1095
1114
  readonly action: string;
1096
1115
  readonly heading: string;
1116
+ readonly reply_to?: string | undefined;
1097
1117
  readonly eyebrow?: string | undefined;
1098
1118
  readonly card?: {
1099
1119
  readonly title: string;
@@ -1116,7 +1136,6 @@ export declare const MigrationPlan: Schema.Struct<{
1116
1136
  } | undefined;
1117
1137
  }[] | undefined;
1118
1138
  readonly footer?: string | undefined;
1119
- readonly reply_to?: string | undefined;
1120
1139
  };
1121
1140
  } | undefined;
1122
1141
  readonly toolsets?: readonly {
@@ -1186,6 +1205,8 @@ export declare const MigrationPlan: Schema.Struct<{
1186
1205
  } | undefined;
1187
1206
  readonly on_sign_up?: string | undefined;
1188
1207
  readonly invitation_email?: string | undefined;
1208
+ readonly link_email?: string | undefined;
1209
+ readonly code_email?: string | undefined;
1189
1210
  } | undefined;
1190
1211
  } | {
1191
1212
  readonly version: number;
@@ -1306,19 +1327,19 @@ export declare const MigrationPlan: Schema.Struct<{
1306
1327
  readonly telegram?: {
1307
1328
  readonly connection: string;
1308
1329
  } | undefined;
1309
- readonly email?: {
1330
+ readonly slack?: {
1310
1331
  readonly connection: string;
1311
1332
  } | undefined;
1312
1333
  readonly whatsapp?: {
1313
1334
  readonly connection: string;
1314
1335
  } | undefined;
1315
- readonly slack?: {
1336
+ readonly email?: {
1316
1337
  readonly connection: string;
1317
1338
  } | undefined;
1318
1339
  readonly channels?: {
1319
1340
  readonly [x: string]: {
1320
- readonly kind: "telegram" | "email" | "whatsapp" | "slack";
1321
- readonly connection: string;
1341
+ readonly kind: "telegram" | "slack" | "whatsapp" | "email" | "custom";
1342
+ readonly connection?: string | undefined;
1322
1343
  };
1323
1344
  } | undefined;
1324
1345
  readonly attribution?: {
@@ -1423,12 +1444,20 @@ export declare const MigrationPlan: Schema.Struct<{
1423
1444
  } | undefined;
1424
1445
  readonly on_sign_up?: string | undefined;
1425
1446
  readonly invitation_email?: string | undefined;
1447
+ readonly link_email?: string | undefined;
1448
+ readonly code_email?: string | undefined;
1426
1449
  } | undefined;
1427
1450
  readonly emails?: {
1428
1451
  readonly [x: string]: {
1452
+ readonly subject: string;
1453
+ readonly text: string;
1454
+ readonly html: string;
1455
+ readonly reply_to?: string | undefined;
1456
+ } | {
1429
1457
  readonly subject: string;
1430
1458
  readonly action: string;
1431
1459
  readonly heading: string;
1460
+ readonly reply_to?: string | undefined;
1432
1461
  readonly eyebrow?: string | undefined;
1433
1462
  readonly card?: {
1434
1463
  readonly title: string;
@@ -1451,7 +1480,6 @@ export declare const MigrationPlan: Schema.Struct<{
1451
1480
  } | undefined;
1452
1481
  }[] | undefined;
1453
1482
  readonly footer?: string | undefined;
1454
- readonly reply_to?: string | undefined;
1455
1483
  };
1456
1484
  } | undefined;
1457
1485
  readonly toolsets?: readonly {
@@ -1658,14 +1686,25 @@ export declare const MigrationPlan: Schema.Struct<{
1658
1686
  readonly botCheck: "bot_check";
1659
1687
  }>>;
1660
1688
  readonly invitationEmail: Schema.optionalKey<Schema.String>;
1689
+ readonly linkEmail: Schema.optionalKey<Schema.String>;
1690
+ readonly codeEmail: Schema.optionalKey<Schema.String>;
1661
1691
  }>, {
1662
1692
  readonly onNewUser: "on_new_user";
1663
1693
  readonly codeLink: "code_link";
1664
1694
  readonly signUp: "sign_up";
1665
1695
  readonly onSignUp: "on_sign_up";
1666
1696
  readonly invitationEmail: "invitation_email";
1697
+ readonly linkEmail: "link_email";
1698
+ readonly codeEmail: "code_email";
1667
1699
  }>>;
1668
- readonly emails: Schema.optionalKey<Schema.$Record<Schema.String, Schema.encodeKeys<Schema.Struct<{
1700
+ readonly emails: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.encodeKeys<Schema.Struct<{
1701
+ readonly subject: Schema.String;
1702
+ readonly html: Schema.String;
1703
+ readonly text: Schema.String;
1704
+ readonly replyTo: Schema.optionalKey<Schema.String>;
1705
+ }>, {
1706
+ readonly replyTo: "reply_to";
1707
+ }>, Schema.encodeKeys<Schema.Struct<{
1669
1708
  readonly subject: Schema.String;
1670
1709
  readonly eyebrow: Schema.optionalKey<Schema.String>;
1671
1710
  readonly heading: Schema.String;
@@ -1694,7 +1733,7 @@ export declare const MigrationPlan: Schema.Struct<{
1694
1733
  readonly replyTo: Schema.optionalKey<Schema.String>;
1695
1734
  }>, {
1696
1735
  readonly replyTo: "reply_to";
1697
- }>>>;
1736
+ }>]>>>;
1698
1737
  readonly connections: Schema.optionalKey<Schema.$Array<Schema.Struct<{
1699
1738
  readonly key: Schema.String;
1700
1739
  readonly description: Schema.String;
@@ -1714,8 +1753,8 @@ export declare const MigrationPlan: Schema.Struct<{
1714
1753
  readonly connection: Schema.String;
1715
1754
  }>>;
1716
1755
  readonly channels: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Struct<{
1717
- readonly kind: Schema.Literals<readonly ["telegram", "slack", "whatsapp", "email"]>;
1718
- readonly connection: Schema.String;
1756
+ readonly kind: Schema.Literals<readonly ["telegram", "slack", "whatsapp", "email", "custom"]>;
1757
+ readonly connection: Schema.optionalKey<Schema.String>;
1719
1758
  }>>>;
1720
1759
  readonly attribution: Schema.optionalKey<Schema.Struct<{
1721
1760
  readonly template: Schema.optionalKey<Schema.String>;
@@ -1952,14 +1991,25 @@ export declare const MigrationPlan: Schema.Struct<{
1952
1991
  readonly botCheck: "bot_check";
1953
1992
  }>>;
1954
1993
  readonly invitationEmail: Schema.optionalKey<Schema.String>;
1994
+ readonly linkEmail: Schema.optionalKey<Schema.String>;
1995
+ readonly codeEmail: Schema.optionalKey<Schema.String>;
1955
1996
  }>, {
1956
1997
  readonly onNewUser: "on_new_user";
1957
1998
  readonly codeLink: "code_link";
1958
1999
  readonly signUp: "sign_up";
1959
2000
  readonly onSignUp: "on_sign_up";
1960
2001
  readonly invitationEmail: "invitation_email";
2002
+ readonly linkEmail: "link_email";
2003
+ readonly codeEmail: "code_email";
1961
2004
  }>>;
1962
- readonly emails: Schema.optionalKey<Schema.$Record<Schema.String, Schema.encodeKeys<Schema.Struct<{
2005
+ readonly emails: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.encodeKeys<Schema.Struct<{
2006
+ readonly subject: Schema.String;
2007
+ readonly html: Schema.String;
2008
+ readonly text: Schema.String;
2009
+ readonly replyTo: Schema.optionalKey<Schema.String>;
2010
+ }>, {
2011
+ readonly replyTo: "reply_to";
2012
+ }>, Schema.encodeKeys<Schema.Struct<{
1963
2013
  readonly subject: Schema.String;
1964
2014
  readonly eyebrow: Schema.optionalKey<Schema.String>;
1965
2015
  readonly heading: Schema.String;
@@ -1988,7 +2038,7 @@ export declare const MigrationPlan: Schema.Struct<{
1988
2038
  readonly replyTo: Schema.optionalKey<Schema.String>;
1989
2039
  }>, {
1990
2040
  readonly replyTo: "reply_to";
1991
- }>>>;
2041
+ }>]>>>;
1992
2042
  readonly connections: Schema.optionalKey<Schema.$Array<Schema.Struct<{
1993
2043
  readonly key: Schema.String;
1994
2044
  readonly description: Schema.String;
@@ -2008,8 +2058,8 @@ export declare const MigrationPlan: Schema.Struct<{
2008
2058
  readonly connection: Schema.String;
2009
2059
  }>>;
2010
2060
  readonly channels: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Struct<{
2011
- readonly kind: Schema.Literals<readonly ["telegram", "slack", "whatsapp", "email"]>;
2012
- readonly connection: Schema.String;
2061
+ readonly kind: Schema.Literals<readonly ["telegram", "slack", "whatsapp", "email", "custom"]>;
2062
+ readonly connection: Schema.optionalKey<Schema.String>;
2013
2063
  }>>>;
2014
2064
  readonly attribution: Schema.optionalKey<Schema.Struct<{
2015
2065
  readonly template: Schema.optionalKey<Schema.String>;
@@ -2209,19 +2259,19 @@ export declare const MigrationPlan: Schema.Struct<{
2209
2259
  readonly telegram?: {
2210
2260
  readonly connection: string;
2211
2261
  } | undefined;
2212
- readonly email?: {
2262
+ readonly slack?: {
2213
2263
  readonly connection: string;
2214
2264
  } | undefined;
2215
2265
  readonly whatsapp?: {
2216
2266
  readonly connection: string;
2217
2267
  } | undefined;
2218
- readonly slack?: {
2268
+ readonly email?: {
2219
2269
  readonly connection: string;
2220
2270
  } | undefined;
2221
2271
  readonly channels?: {
2222
2272
  readonly [x: string]: {
2223
- readonly kind: "telegram" | "email" | "whatsapp" | "slack";
2224
- readonly connection: string;
2273
+ readonly kind: "telegram" | "slack" | "whatsapp" | "email" | "custom";
2274
+ readonly connection?: string | undefined;
2225
2275
  };
2226
2276
  } | undefined;
2227
2277
  readonly attribution?: {
@@ -2326,9 +2376,16 @@ export declare const MigrationPlan: Schema.Struct<{
2326
2376
  } | undefined;
2327
2377
  readonly onSignUp?: string | undefined;
2328
2378
  readonly invitationEmail?: string | undefined;
2379
+ readonly linkEmail?: string | undefined;
2380
+ readonly codeEmail?: string | undefined;
2329
2381
  } | undefined;
2330
2382
  readonly emails?: {
2331
2383
  readonly [x: string]: {
2384
+ readonly subject: string;
2385
+ readonly text: string;
2386
+ readonly html: string;
2387
+ readonly replyTo?: string | undefined;
2388
+ } | {
2332
2389
  readonly subject: string;
2333
2390
  readonly action: string;
2334
2391
  readonly heading: string;
@@ -2511,19 +2568,19 @@ export declare const MigrationPlan: Schema.Struct<{
2511
2568
  readonly telegram?: {
2512
2569
  readonly connection: string;
2513
2570
  } | undefined;
2514
- readonly email?: {
2571
+ readonly slack?: {
2515
2572
  readonly connection: string;
2516
2573
  } | undefined;
2517
2574
  readonly whatsapp?: {
2518
2575
  readonly connection: string;
2519
2576
  } | undefined;
2520
- readonly slack?: {
2577
+ readonly email?: {
2521
2578
  readonly connection: string;
2522
2579
  } | undefined;
2523
2580
  readonly channels?: {
2524
2581
  readonly [x: string]: {
2525
- readonly kind: "telegram" | "email" | "whatsapp" | "slack";
2526
- readonly connection: string;
2582
+ readonly kind: "telegram" | "slack" | "whatsapp" | "email" | "custom";
2583
+ readonly connection?: string | undefined;
2527
2584
  };
2528
2585
  } | undefined;
2529
2586
  readonly attribution?: {
@@ -2628,9 +2685,16 @@ export declare const MigrationPlan: Schema.Struct<{
2628
2685
  } | undefined;
2629
2686
  readonly onSignUp?: string | undefined;
2630
2687
  readonly invitationEmail?: string | undefined;
2688
+ readonly linkEmail?: string | undefined;
2689
+ readonly codeEmail?: string | undefined;
2631
2690
  } | undefined;
2632
2691
  readonly emails?: {
2633
2692
  readonly [x: string]: {
2693
+ readonly subject: string;
2694
+ readonly text: string;
2695
+ readonly html: string;
2696
+ readonly replyTo?: string | undefined;
2697
+ } | {
2634
2698
  readonly subject: string;
2635
2699
  readonly action: string;
2636
2700
  readonly heading: string;
@@ -45,11 +45,18 @@ export declare const AGENT_TOOL = "agent_tool";
45
45
  /**
46
46
  * The agent's own tools a role may grant. `sandbox`: the shell and file tools in the agent's
47
47
  * sandbox, copying a file the caller may read into it, and calling an ontology tool with arguments
48
- * from a file in it. `web`: fetching pages from the domains the agent's configuration lists. The
49
- * agent's configuration says which of them the agent has; the roles say which caller gets them.
48
+ * from a file in it. `web`: fetching pages from the domains the agent's configuration lists.
49
+ * `browser`: driving the agent's own cloud browser, signed in as the agent, with scripts that run
50
+ * in its sandbox, so the agent also needs the sandbox for it. The agent's configuration says which
51
+ * of them the agent has; the roles say which caller gets them.
50
52
  */
51
- export declare const AGENT_TOOL_VERBS: readonly ["sandbox", "web"];
53
+ export declare const AGENT_TOOL_VERBS: readonly ["sandbox", "web", "browser"];
52
54
  export type AgentToolVerb = (typeof AGENT_TOOL_VERBS)[number];
55
+ /**
56
+ * The agent tools no guest may hold, whoever opens the website: the sandbox reads the records and
57
+ * files of whoever the agent acts for, and the browser acts with the agent's own sign-ins.
58
+ */
59
+ export declare const MEMBER_AGENT_TOOLS: ReadonlySet<AgentToolVerb>;
53
60
  /** `agent_tool:sandbox`. */
54
61
  export declare function agentToolPermission(tool: AgentToolVerb): string;
55
62
  /**
@@ -52,10 +52,17 @@ export const AGENT_TOOL = "agent_tool";
52
52
  /**
53
53
  * The agent's own tools a role may grant. `sandbox`: the shell and file tools in the agent's
54
54
  * sandbox, copying a file the caller may read into it, and calling an ontology tool with arguments
55
- * from a file in it. `web`: fetching pages from the domains the agent's configuration lists. The
56
- * agent's configuration says which of them the agent has; the roles say which caller gets them.
55
+ * from a file in it. `web`: fetching pages from the domains the agent's configuration lists.
56
+ * `browser`: driving the agent's own cloud browser, signed in as the agent, with scripts that run
57
+ * in its sandbox, so the agent also needs the sandbox for it. The agent's configuration says which
58
+ * of them the agent has; the roles say which caller gets them.
57
59
  */
58
- export const AGENT_TOOL_VERBS = ["sandbox", "web"];
60
+ export const AGENT_TOOL_VERBS = ["sandbox", "web", "browser"];
61
+ /**
62
+ * The agent tools no guest may hold, whoever opens the website: the sandbox reads the records and
63
+ * files of whoever the agent acts for, and the browser acts with the agent's own sign-ins.
64
+ */
65
+ export const MEMBER_AGENT_TOOLS = new Set(["sandbox", "browser"]);
59
66
  /** `agent_tool:sandbox`. */
60
67
  export function agentToolPermission(tool) {
61
68
  return `${AGENT_TOOL}:${tool}`;
@@ -17,7 +17,8 @@ export declare function isGuestRole(ontology: Ontology, role: string): boolean;
17
17
  export declare function userRoleNames(ontology: Ontology): ReadonlyArray<string>;
18
18
  /**
19
19
  * The agent's own tools a caller holds, as every answer naming whom the agent acts for carries them.
20
- * A guest holds those `guest.permissions` grant, never the sandbox and never implicitly. Anyone
20
+ * A guest holds those `guest.permissions` grant, never the sandbox or the browser, and never
21
+ * implicitly. Anyone
21
22
  * else holds those the ontology's roles grant, and the guests' role decides nothing for them: while
22
23
  * no other role names an agent tool, they keep the earlier implicit sandbox.
23
24
  */
@@ -1,5 +1,5 @@
1
1
  import { GUEST_ROLE } from "../names.js";
2
- import { AGENT_TOOL_VERBS, agentToolPermission, agentToolsOf, isAllowed, permissionsOf, principalScopes, } from "../permissions.js";
2
+ import { AGENT_TOOL_VERBS, agentToolPermission, agentToolsOf, isAllowed, MEMBER_AGENT_TOOLS, permissionsOf, principalScopes, } from "../permissions.js";
3
3
  import { WEB_PROVIDER } from "../service/runtime-identity.js";
4
4
  import { isRecordId } from "./records.js";
5
5
  /**
@@ -26,13 +26,14 @@ export function userRoleNames(ontology) {
26
26
  }
27
27
  /**
28
28
  * The agent's own tools a caller holds, as every answer naming whom the agent acts for carries them.
29
- * A guest holds those `guest.permissions` grant, never the sandbox and never implicitly. Anyone
29
+ * A guest holds those `guest.permissions` grant, never the sandbox or the browser, and never
30
+ * implicitly. Anyone
30
31
  * else holds those the ontology's roles grant, and the guests' role decides nothing for them: while
31
32
  * no other role names an agent tool, they keep the earlier implicit sandbox.
32
33
  */
33
34
  export function agentToolsFor(ontology, principal) {
34
35
  if (principal.kind === "guest") {
35
- return AGENT_TOOL_VERBS.filter((tool) => tool !== "sandbox" && isAllowed(agentToolPermission(tool), principal));
36
+ return AGENT_TOOL_VERBS.filter((tool) => !MEMBER_AGENT_TOOLS.has(tool) && isAllowed(agentToolPermission(tool), principal));
36
37
  }
37
38
  return agentToolsOf(ontology.roles.filter((candidate) => !isGuestRole(ontology, candidate.name)), principal);
38
39
  }
@@ -2,6 +2,7 @@ import { randomUUID } from "node:crypto";
2
2
  import { Effect, Option, Schema } from "effect";
3
3
  import { isSqlError } from "effect/unstable/sql/SqlError";
4
4
  import { Conflict } from "../errors.js";
5
+ import { workspaceChannelOf } from "../chat-channel.js";
5
6
  import { channelPolicyOf, signUpRolesOf } from "../manifest.js";
6
7
  import { AGENT_IDENTITIES_TABLE, CHANNEL_USERS_TABLE, USER_TABLE } from "../migrate/storage.js";
7
8
  import { EMAIL_PATTERN } from "../property.js";
@@ -101,7 +102,9 @@ export function resolveAgentIdentity(ontology, sql, store, requested, context =
101
102
  }
102
103
  const display = input.display?.trim() || null;
103
104
  const username = input.username?.trim().replace(/^@/, "");
104
- const providerName = input.provider.charAt(0).toUpperCase() + input.provider.slice(1);
105
+ // A workspace channel's account is named after the channel, as the workspace named it.
106
+ const providerName = workspaceChannelOf(input.provider) ??
107
+ input.provider.charAt(0).toUpperCase() + input.provider.slice(1);
105
108
  const actionId = randomUUID();
106
109
  const writer = makePrincipalUserWriter(ontology, sql, {
107
110
  action: "user.provision",
@@ -17,7 +17,10 @@ export declare function newPairingCode(): string;
17
17
  * without the spaces or dashes someone may type between groups. `undefined` when it cannot be one.
18
18
  */
19
19
  export declare function canonicalPairingCode(value: string): string | undefined;
20
- /** A channel's name: `telegram`, `slack`. It is part of a URL path and of every identity. */
20
+ /**
21
+ * A channel's name: `telegram`, `slack`. It is part of a URL path and of every identity. The
22
+ * accounts of a channel the workspace defines in its own code are its own, `channel:<name>`.
23
+ */
21
24
  export declare const Provider: Schema.String;
22
25
  /** `POST /api/ontology/agent/pairings`: the account an unknown sender writes from. */
23
26
  export declare const PairingRequest: Schema.Struct<{
@@ -30,9 +30,13 @@ export function canonicalPairingCode(value) {
30
30
  }
31
31
  const MAX_EXTERNAL_ID_LENGTH = 256;
32
32
  const MAX_DISPLAY_LENGTH = 200;
33
- /** A channel's name: `telegram`, `slack`. It is part of a URL path and of every identity. */
34
- export const Provider = Schema.String.check(Schema.isPattern(/^[a-z][a-z0-9_-]{0,31}$/)).annotate({
35
- description: "The channel, such as telegram: lower case letters, digits, - and _.",
33
+ /**
34
+ * A channel's name: `telegram`, `slack`. It is part of a URL path and of every identity. The
35
+ * accounts of a channel the workspace defines in its own code are its own, `channel:<name>`.
36
+ */
37
+ export const Provider = Schema.String.check(Schema.isPattern(/^(?:[a-z][a-z0-9_-]{0,31}|channel:[a-z][a-z0-9_]{0,31})$/)).annotate({
38
+ description: "The channel, such as telegram: lower case letters, digits, - and _; or channel:<name>, the " +
39
+ "accounts of a channel the workspace defines.",
36
40
  });
37
41
  /** `POST /api/ontology/agent/pairings`: the account an unknown sender writes from. */
38
42
  export const PairingRequest = Schema.Struct({
@@ -3,7 +3,7 @@ import { randomUUID } from "node:crypto";
3
3
  import { Effect, Layer, Redacted, Result, Schema } from "effect";
4
4
  import { HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
5
5
  import { HttpApiBuilder, HttpApiSecurity } from "effect/unstable/httpapi";
6
- import { isChatChannelKind } from "../../chat-channel.js";
6
+ import { isChatChannelKind, WORKSPACE_CHANNEL_KIND } from "../../chat-channel.js";
7
7
  import { API_KEY_PREFIX } from "../../runtime/principals.js";
8
8
  import { schemaIssues } from "../../runtime/validation.js";
9
9
  import { BASE_PATH } from "../api.js";
@@ -306,7 +306,7 @@ function holdReply(store) {
306
306
  return toServerResponse(notFound(requestId, "This ontology service holds no replies."));
307
307
  }
308
308
  const body = decoded.success;
309
- // A channel named after a kind is that kind.
309
+ // A channel named after a kind is that kind, and a workspace channel has a name of its own.
310
310
  if (body.channel !== undefined &&
311
311
  isChatChannelKind(body.channel) &&
312
312
  body.channel !== body.provider) {
@@ -314,6 +314,12 @@ function holdReply(store) {
314
314
  { path: ["channel"], message: "A channel named after a kind is that kind." },
315
315
  ]);
316
316
  }
317
+ if (body.provider === WORKSPACE_CHANNEL_KIND &&
318
+ (body.channel === undefined || body.channel === WORKSPACE_CHANNEL_KIND)) {
319
+ return invalidBody(requestId, [
320
+ { path: ["channel"], message: "A workspace channel's reply names its channel." },
321
+ ]);
322
+ }
317
323
  const review = yield* store.holdReply({
318
324
  key: body.key,
319
325
  provider: body.provider,
@@ -209,7 +209,8 @@ export interface CredentialOptions {
209
209
  * The chat a verified runtime caller names, kept as the principal's when it can be the chat it acts
210
210
  * in: on the web, the member's or guest's own chat, which their agent token names; on a messenger,
211
211
  * a chat on a channel of the kind the member wrote from. The chat names its channel by name, as
212
- * the archive does; `kindOf` answers the channel's kind, as the ontology's `chat` declares it.
212
+ * the archive does; `kindOf` answers the channel's kind, as the ontology's `chat` declares it. A
213
+ * workspace channel's accounts are its own (`channel:<name>`), so they name its chats' channel.
213
214
  * Anything else is left out, never refused: it only attributes.
214
215
  */
215
216
  export declare function actingChat(principal: Principal, provider: string | undefined, chat: ChatProvenance | undefined, kindOf?: (channel: string) => string | undefined): ChatProvenance | undefined;