@segmentstream/ontology 0.106.3 → 0.108.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 (59) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +45 -11
  3. package/dist/analyze.d.ts +7 -1
  4. package/dist/analyze.js +271 -16
  5. package/dist/authoring.js +6 -0
  6. package/dist/diagnostics.d.ts +3 -3
  7. package/dist/diagnostics.js +1 -0
  8. package/dist/emails.d.ts +36 -5
  9. package/dist/emails.js +139 -2
  10. package/dist/index.d.ts +7 -7
  11. package/dist/index.js +5 -3
  12. package/dist/manifest.d.ts +262 -1
  13. package/dist/manifest.js +73 -4
  14. package/dist/migrate/apply.js +8 -1
  15. package/dist/migrate/model.d.ts +154 -0
  16. package/dist/migrate/storage.d.ts +2 -0
  17. package/dist/migrate/storage.js +8 -0
  18. package/dist/names.d.ts +5 -0
  19. package/dist/names.js +5 -0
  20. package/dist/ontology.d.ts +4 -1
  21. package/dist/permissions.d.ts +30 -2
  22. package/dist/permissions.js +51 -6
  23. package/dist/runtime/agent-counters.d.ts +5 -1
  24. package/dist/runtime/agent-counters.js +21 -6
  25. package/dist/runtime/agent-web.d.ts +9 -6
  26. package/dist/runtime/agent-web.js +101 -5
  27. package/dist/runtime/generated-actions.js +2 -3
  28. package/dist/runtime/guests.d.ts +32 -0
  29. package/dist/runtime/guests.js +64 -0
  30. package/dist/runtime/new-user-hook.js +2 -1
  31. package/dist/runtime/oauth.js +7 -1
  32. package/dist/runtime/pipeline.js +3 -2
  33. package/dist/runtime/principals.js +6 -4
  34. package/dist/runtime/sql-runtime.js +2 -1
  35. package/dist/runtime.d.ts +10 -2
  36. package/dist/service/agent/authentication.d.ts +6 -4
  37. package/dist/service/agent/authentication.js +20 -5
  38. package/dist/service/agent/protocol.d.ts +28 -2
  39. package/dist/service/agent/protocol.js +23 -10
  40. package/dist/service/agent/server.d.ts +9 -2
  41. package/dist/service/agent/server.js +12 -12
  42. package/dist/service/agent/tasks.d.ts +3 -0
  43. package/dist/service/agent/tasks.js +5 -3
  44. package/dist/service/agent/web-tokens.d.ts +28 -13
  45. package/dist/service/agent/web-tokens.js +91 -38
  46. package/dist/service/authentication.d.ts +6 -0
  47. package/dist/service/authentication.js +11 -2
  48. package/dist/service/chat/review-delivery.js +4 -0
  49. package/dist/service/mcp/server.js +3 -3
  50. package/dist/service/mcp/tools.d.ts +4 -2
  51. package/dist/service/mcp/tools.js +14 -2
  52. package/dist/service/oauth/protocol.js +8 -2
  53. package/dist/service/oauth/server.js +5 -1
  54. package/dist/service/runtime-contract.d.ts +58 -6
  55. package/dist/service/schemas.d.ts +40 -0
  56. package/dist/service/service.js +15 -4
  57. package/dist/sign-in.d.ts +66 -9
  58. package/dist/sign-in.js +87 -9
  59. package/package.json +1 -1
@@ -4,7 +4,7 @@ import type { ResolvedConnection, ResolvedEntity } from "./analyze.js";
4
4
  import type { ResolvedFeedback } from "./feedback-config.js";
5
5
  import type { Role } from "./role.js";
6
6
  import type { ResolvedToolset } from "./toolset.js";
7
- import { type ResolvedSignInOptions, type SignInPolicy } from "./sign-in.js";
7
+ import { type ResolvedGuest, type ResolvedSignInOptions, type SignInPolicy } from "./sign-in.js";
8
8
  /**
9
9
  * The manifest format this SDK writes. Readers accept any version and ignore unknown fields. Version
10
10
  * 2 replaced the actions' `allow` with `permission`, and added the roles' `permissions` and the
@@ -63,6 +63,16 @@ import { type ResolvedSignInOptions, type SignInPolicy } from "./sign-in.js";
63
63
  * Within version 15, `signUp` may carry `web` among its channels and `origins`, the websites whose
64
64
  * visitors sign up on it, written only when declared. Older readers ignore both and keep `web`
65
65
  * closed.
66
+ * Within version 15, `signIn` may carry `guest`, written only when declared: the `channels` guests
67
+ * talk to the agent on and the `origins` of their websites, and `roles` then ends with the built-in
68
+ * `guest` role, which holds the guests' permissions. Origins of `guest` and `signUp` may be patterns
69
+ * such as `https://*.example.com`. Older readers ignore `guest` and admit no guests, and leave out
70
+ * the patterns they cannot read.
71
+ * Within version 15, an email may carry `sections`, boxes below its button, and its texts may use
72
+ * `{{app.url}}` and `{{app.mcpUrl}}`; `signIn` may carry `invitationEmail`, written only when
73
+ * declared: the wire name of the email the platform sends instead of its own invitation. Older
74
+ * readers ignore `sections` and `invitationEmail`, leave the two values empty and send the
75
+ * platform's invitation.
66
76
  */
67
77
  export declare const MANIFEST_VERSION = 15;
68
78
  /** The phrase used for a direction the author did not phrase. */
@@ -619,6 +629,15 @@ export declare const SignUpManifest: Schema.Struct<{
619
629
  readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
620
630
  readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
621
631
  }>;
632
+ /**
633
+ * Guests: the channels they talk to the agent on and the websites whose visitors they are. Their
634
+ * permissions are the built-in `guest` role's. Read as text: channels and origins a reader does not
635
+ * know admit nobody.
636
+ */
637
+ export declare const GuestManifest: Schema.Struct<{
638
+ readonly channels: Schema.$Array<Schema.String>;
639
+ readonly origins: Schema.$Array<Schema.String>;
640
+ }>;
622
641
  export declare const SignInManifest: Schema.encodeKeys<Schema.Struct<{
623
642
  readonly browser: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
624
643
  readonly methods: Schema.$Array<Schema.String>;
@@ -639,11 +658,18 @@ export declare const SignInManifest: Schema.encodeKeys<Schema.Struct<{
639
658
  readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
640
659
  }>>;
641
660
  readonly onSignUp: Schema.optionalKey<Schema.String>;
661
+ readonly guest: Schema.optionalKey<Schema.Struct<{
662
+ readonly channels: Schema.$Array<Schema.String>;
663
+ readonly origins: Schema.$Array<Schema.String>;
664
+ }>>;
665
+ /** The wire name of the email the platform sends instead of its own invitation. */
666
+ readonly invitationEmail: Schema.optionalKey<Schema.String>;
642
667
  }>, {
643
668
  readonly onNewUser: "on_new_user";
644
669
  readonly codeLink: "code_link";
645
670
  readonly signUp: "sign_up";
646
671
  readonly onSignUp: "on_sign_up";
672
+ readonly invitationEmail: "invitation_email";
647
673
  }>;
648
674
  export type SignInManifest = typeof SignInManifest.Type;
649
675
  /** One of the workspace's emails, as `defineOntology({ emails })` declares it; see `EmailTemplate`. */
@@ -658,6 +684,20 @@ export declare const EmailTemplateManifest: Schema.encodeKeys<Schema.Struct<{
658
684
  readonly note: Schema.optionalKey<Schema.String>;
659
685
  readonly paragraphs: Schema.optionalKey<Schema.$Array<Schema.String>>;
660
686
  readonly action: Schema.String;
687
+ readonly sections: Schema.optionalKey<Schema.$Array<Schema.Struct<{
688
+ readonly title: Schema.String;
689
+ readonly text: Schema.optionalKey<Schema.String>;
690
+ readonly copy: Schema.optionalKey<Schema.Struct<{
691
+ readonly label: Schema.optionalKey<Schema.String>;
692
+ readonly value: Schema.String;
693
+ }>>;
694
+ readonly items: Schema.optionalKey<Schema.$Array<Schema.Struct<{
695
+ readonly label: Schema.String;
696
+ readonly text: Schema.optionalKey<Schema.String>;
697
+ readonly code: Schema.optionalKey<Schema.String>;
698
+ }>>>;
699
+ readonly note: Schema.optionalKey<Schema.String>;
700
+ }>>>;
661
701
  readonly footer: Schema.optionalKey<Schema.String>;
662
702
  readonly replyTo: Schema.optionalKey<Schema.String>;
663
703
  }>, {
@@ -920,11 +960,18 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
920
960
  readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
921
961
  }>>;
922
962
  readonly onSignUp: Schema.optionalKey<Schema.String>;
963
+ readonly guest: Schema.optionalKey<Schema.Struct<{
964
+ readonly channels: Schema.$Array<Schema.String>;
965
+ readonly origins: Schema.$Array<Schema.String>;
966
+ }>>;
967
+ /** The wire name of the email the platform sends instead of its own invitation. */
968
+ readonly invitationEmail: Schema.optionalKey<Schema.String>;
923
969
  }>, {
924
970
  readonly onNewUser: "on_new_user";
925
971
  readonly codeLink: "code_link";
926
972
  readonly signUp: "sign_up";
927
973
  readonly onSignUp: "on_sign_up";
974
+ readonly invitationEmail: "invitation_email";
928
975
  }>>;
929
976
  /** The workspace's own emails by wire name. Written only when there are some; absent reads as none. */
930
977
  readonly emails: Schema.optionalKey<Schema.$Record<Schema.String, Schema.encodeKeys<Schema.Struct<{
@@ -938,6 +985,20 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
938
985
  readonly note: Schema.optionalKey<Schema.String>;
939
986
  readonly paragraphs: Schema.optionalKey<Schema.$Array<Schema.String>>;
940
987
  readonly action: Schema.String;
988
+ readonly sections: Schema.optionalKey<Schema.$Array<Schema.Struct<{
989
+ readonly title: Schema.String;
990
+ readonly text: Schema.optionalKey<Schema.String>;
991
+ readonly copy: Schema.optionalKey<Schema.Struct<{
992
+ readonly label: Schema.optionalKey<Schema.String>;
993
+ readonly value: Schema.String;
994
+ }>>;
995
+ readonly items: Schema.optionalKey<Schema.$Array<Schema.Struct<{
996
+ readonly label: Schema.String;
997
+ readonly text: Schema.optionalKey<Schema.String>;
998
+ readonly code: Schema.optionalKey<Schema.String>;
999
+ }>>>;
1000
+ readonly note: Schema.optionalKey<Schema.String>;
1001
+ }>>>;
941
1002
  readonly footer: Schema.optionalKey<Schema.String>;
942
1003
  readonly replyTo: Schema.optionalKey<Schema.String>;
943
1004
  }>, {
@@ -1292,6 +1353,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1292
1353
  } | undefined;
1293
1354
  readonly signIn?: {
1294
1355
  readonly policy: string;
1356
+ readonly guest?: {
1357
+ readonly channels: readonly string[];
1358
+ readonly origins: readonly string[];
1359
+ } | undefined;
1295
1360
  readonly browser?: {
1296
1361
  readonly methods: readonly string[];
1297
1362
  readonly primary: string;
@@ -1312,6 +1377,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1312
1377
  readonly origins?: readonly string[] | undefined;
1313
1378
  } | undefined;
1314
1379
  readonly onSignUp?: string | undefined;
1380
+ readonly invitationEmail?: string | undefined;
1315
1381
  } | undefined;
1316
1382
  readonly emails?: {
1317
1383
  readonly [x: string]: {
@@ -1326,6 +1392,20 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1326
1392
  } | undefined;
1327
1393
  readonly note?: string | undefined;
1328
1394
  readonly paragraphs?: readonly string[] | undefined;
1395
+ readonly sections?: readonly {
1396
+ readonly title: string;
1397
+ readonly text?: string | undefined;
1398
+ readonly items?: readonly {
1399
+ readonly label: string;
1400
+ readonly code?: string | undefined;
1401
+ readonly text?: string | undefined;
1402
+ }[] | undefined;
1403
+ readonly note?: string | undefined;
1404
+ readonly copy?: {
1405
+ readonly value: string;
1406
+ readonly label?: string | undefined;
1407
+ } | undefined;
1408
+ }[] | undefined;
1329
1409
  readonly footer?: string | undefined;
1330
1410
  };
1331
1411
  } | undefined;
@@ -1564,6 +1644,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1564
1644
  } | undefined;
1565
1645
  readonly signIn?: {
1566
1646
  readonly policy: string;
1647
+ readonly guest?: {
1648
+ readonly channels: readonly string[];
1649
+ readonly origins: readonly string[];
1650
+ } | undefined;
1567
1651
  readonly browser?: {
1568
1652
  readonly methods: readonly string[];
1569
1653
  readonly primary: string;
@@ -1584,6 +1668,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1584
1668
  readonly origins?: readonly string[] | undefined;
1585
1669
  } | undefined;
1586
1670
  readonly onSignUp?: string | undefined;
1671
+ readonly invitationEmail?: string | undefined;
1587
1672
  } | undefined;
1588
1673
  readonly emails?: {
1589
1674
  readonly [x: string]: {
@@ -1598,6 +1683,20 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1598
1683
  } | undefined;
1599
1684
  readonly note?: string | undefined;
1600
1685
  readonly paragraphs?: readonly string[] | undefined;
1686
+ readonly sections?: readonly {
1687
+ readonly title: string;
1688
+ readonly text?: string | undefined;
1689
+ readonly items?: readonly {
1690
+ readonly label: string;
1691
+ readonly code?: string | undefined;
1692
+ readonly text?: string | undefined;
1693
+ }[] | undefined;
1694
+ readonly note?: string | undefined;
1695
+ readonly copy?: {
1696
+ readonly value: string;
1697
+ readonly label?: string | undefined;
1698
+ } | undefined;
1699
+ }[] | undefined;
1601
1700
  readonly footer?: string | undefined;
1602
1701
  };
1603
1702
  } | undefined;
@@ -1846,6 +1945,20 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1846
1945
  } | undefined;
1847
1946
  readonly note?: string | undefined;
1848
1947
  readonly paragraphs?: readonly string[] | undefined;
1948
+ readonly sections?: readonly {
1949
+ readonly title: string;
1950
+ readonly text?: string | undefined;
1951
+ readonly items?: readonly {
1952
+ readonly label: string;
1953
+ readonly code?: string | undefined;
1954
+ readonly text?: string | undefined;
1955
+ }[] | undefined;
1956
+ readonly note?: string | undefined;
1957
+ readonly copy?: {
1958
+ readonly value: string;
1959
+ readonly label?: string | undefined;
1960
+ } | undefined;
1961
+ }[] | undefined;
1849
1962
  readonly footer?: string | undefined;
1850
1963
  readonly reply_to?: string | undefined;
1851
1964
  };
@@ -1887,6 +2000,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1887
2000
  }[] | undefined;
1888
2001
  readonly sign_in?: {
1889
2002
  readonly policy: string;
2003
+ readonly guest?: {
2004
+ readonly channels: readonly string[];
2005
+ readonly origins: readonly string[];
2006
+ } | undefined;
1890
2007
  readonly browser?: {
1891
2008
  readonly methods: readonly string[];
1892
2009
  readonly primary: string;
@@ -1907,6 +2024,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1907
2024
  readonly origins?: readonly string[] | undefined;
1908
2025
  } | undefined;
1909
2026
  readonly on_sign_up?: string | undefined;
2027
+ readonly invitation_email?: string | undefined;
1910
2028
  } | undefined;
1911
2029
  } | {
1912
2030
  readonly version: number;
@@ -2108,6 +2226,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2108
2226
  } | undefined;
2109
2227
  readonly signIn?: {
2110
2228
  readonly policy: string;
2229
+ readonly guest?: {
2230
+ readonly channels: readonly string[];
2231
+ readonly origins: readonly string[];
2232
+ } | undefined;
2111
2233
  readonly browser?: {
2112
2234
  readonly methods: readonly string[];
2113
2235
  readonly primary: string;
@@ -2128,6 +2250,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2128
2250
  readonly origins?: readonly string[] | undefined;
2129
2251
  } | undefined;
2130
2252
  readonly on_sign_up?: string | undefined;
2253
+ readonly invitation_email?: string | undefined;
2131
2254
  } | undefined;
2132
2255
  readonly emails?: {
2133
2256
  readonly [x: string]: {
@@ -2141,6 +2264,20 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2141
2264
  } | undefined;
2142
2265
  readonly note?: string | undefined;
2143
2266
  readonly paragraphs?: readonly string[] | undefined;
2267
+ readonly sections?: readonly {
2268
+ readonly title: string;
2269
+ readonly text?: string | undefined;
2270
+ readonly items?: readonly {
2271
+ readonly label: string;
2272
+ readonly code?: string | undefined;
2273
+ readonly text?: string | undefined;
2274
+ }[] | undefined;
2275
+ readonly note?: string | undefined;
2276
+ readonly copy?: {
2277
+ readonly value: string;
2278
+ readonly label?: string | undefined;
2279
+ } | undefined;
2280
+ }[] | undefined;
2144
2281
  readonly footer?: string | undefined;
2145
2282
  readonly reply_to?: string | undefined;
2146
2283
  };
@@ -2381,11 +2518,18 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2381
2518
  readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
2382
2519
  }>>;
2383
2520
  readonly onSignUp: Schema.optionalKey<Schema.String>;
2521
+ readonly guest: Schema.optionalKey<Schema.Struct<{
2522
+ readonly channels: Schema.$Array<Schema.String>;
2523
+ readonly origins: Schema.$Array<Schema.String>;
2524
+ }>>;
2525
+ /** The wire name of the email the platform sends instead of its own invitation. */
2526
+ readonly invitationEmail: Schema.optionalKey<Schema.String>;
2384
2527
  }>, {
2385
2528
  readonly onNewUser: "on_new_user";
2386
2529
  readonly codeLink: "code_link";
2387
2530
  readonly signUp: "sign_up";
2388
2531
  readonly onSignUp: "on_sign_up";
2532
+ readonly invitationEmail: "invitation_email";
2389
2533
  }>>;
2390
2534
  /** The workspace's own emails by wire name. Written only when there are some; absent reads as none. */
2391
2535
  readonly emails: Schema.optionalKey<Schema.$Record<Schema.String, Schema.encodeKeys<Schema.Struct<{
@@ -2399,6 +2543,20 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2399
2543
  readonly note: Schema.optionalKey<Schema.String>;
2400
2544
  readonly paragraphs: Schema.optionalKey<Schema.$Array<Schema.String>>;
2401
2545
  readonly action: Schema.String;
2546
+ readonly sections: Schema.optionalKey<Schema.$Array<Schema.Struct<{
2547
+ readonly title: Schema.String;
2548
+ readonly text: Schema.optionalKey<Schema.String>;
2549
+ readonly copy: Schema.optionalKey<Schema.Struct<{
2550
+ readonly label: Schema.optionalKey<Schema.String>;
2551
+ readonly value: Schema.String;
2552
+ }>>;
2553
+ readonly items: Schema.optionalKey<Schema.$Array<Schema.Struct<{
2554
+ readonly label: Schema.String;
2555
+ readonly text: Schema.optionalKey<Schema.String>;
2556
+ readonly code: Schema.optionalKey<Schema.String>;
2557
+ }>>>;
2558
+ readonly note: Schema.optionalKey<Schema.String>;
2559
+ }>>>;
2402
2560
  readonly footer: Schema.optionalKey<Schema.String>;
2403
2561
  readonly replyTo: Schema.optionalKey<Schema.String>;
2404
2562
  }>, {
@@ -2741,11 +2899,18 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2741
2899
  readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
2742
2900
  }>>;
2743
2901
  readonly onSignUp: Schema.optionalKey<Schema.String>;
2902
+ readonly guest: Schema.optionalKey<Schema.Struct<{
2903
+ readonly channels: Schema.$Array<Schema.String>;
2904
+ readonly origins: Schema.$Array<Schema.String>;
2905
+ }>>;
2906
+ /** The wire name of the email the platform sends instead of its own invitation. */
2907
+ readonly invitationEmail: Schema.optionalKey<Schema.String>;
2744
2908
  }>, {
2745
2909
  readonly onNewUser: "on_new_user";
2746
2910
  readonly codeLink: "code_link";
2747
2911
  readonly signUp: "sign_up";
2748
2912
  readonly onSignUp: "on_sign_up";
2913
+ readonly invitationEmail: "invitation_email";
2749
2914
  }>>;
2750
2915
  /** The workspace's own emails by wire name. Written only when there are some; absent reads as none. */
2751
2916
  readonly emails: Schema.optionalKey<Schema.$Record<Schema.String, Schema.encodeKeys<Schema.Struct<{
@@ -2759,6 +2924,20 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2759
2924
  readonly note: Schema.optionalKey<Schema.String>;
2760
2925
  readonly paragraphs: Schema.optionalKey<Schema.$Array<Schema.String>>;
2761
2926
  readonly action: Schema.String;
2927
+ readonly sections: Schema.optionalKey<Schema.$Array<Schema.Struct<{
2928
+ readonly title: Schema.String;
2929
+ readonly text: Schema.optionalKey<Schema.String>;
2930
+ readonly copy: Schema.optionalKey<Schema.Struct<{
2931
+ readonly label: Schema.optionalKey<Schema.String>;
2932
+ readonly value: Schema.String;
2933
+ }>>;
2934
+ readonly items: Schema.optionalKey<Schema.$Array<Schema.Struct<{
2935
+ readonly label: Schema.String;
2936
+ readonly text: Schema.optionalKey<Schema.String>;
2937
+ readonly code: Schema.optionalKey<Schema.String>;
2938
+ }>>>;
2939
+ readonly note: Schema.optionalKey<Schema.String>;
2940
+ }>>>;
2762
2941
  readonly footer: Schema.optionalKey<Schema.String>;
2763
2942
  readonly replyTo: Schema.optionalKey<Schema.String>;
2764
2943
  }>, {
@@ -3105,6 +3284,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3105
3284
  } | undefined;
3106
3285
  readonly signIn?: {
3107
3286
  readonly policy: string;
3287
+ readonly guest?: {
3288
+ readonly channels: readonly string[];
3289
+ readonly origins: readonly string[];
3290
+ } | undefined;
3108
3291
  readonly browser?: {
3109
3292
  readonly methods: readonly string[];
3110
3293
  readonly primary: string;
@@ -3125,6 +3308,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3125
3308
  readonly origins?: readonly string[] | undefined;
3126
3309
  } | undefined;
3127
3310
  readonly onSignUp?: string | undefined;
3311
+ readonly invitationEmail?: string | undefined;
3128
3312
  } | undefined;
3129
3313
  readonly emails?: {
3130
3314
  readonly [x: string]: {
@@ -3139,6 +3323,20 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3139
3323
  } | undefined;
3140
3324
  readonly note?: string | undefined;
3141
3325
  readonly paragraphs?: readonly string[] | undefined;
3326
+ readonly sections?: readonly {
3327
+ readonly title: string;
3328
+ readonly text?: string | undefined;
3329
+ readonly items?: readonly {
3330
+ readonly label: string;
3331
+ readonly code?: string | undefined;
3332
+ readonly text?: string | undefined;
3333
+ }[] | undefined;
3334
+ readonly note?: string | undefined;
3335
+ readonly copy?: {
3336
+ readonly value: string;
3337
+ readonly label?: string | undefined;
3338
+ } | undefined;
3339
+ }[] | undefined;
3142
3340
  readonly footer?: string | undefined;
3143
3341
  };
3144
3342
  } | undefined;
@@ -3377,6 +3575,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3377
3575
  } | undefined;
3378
3576
  readonly signIn?: {
3379
3577
  readonly policy: string;
3578
+ readonly guest?: {
3579
+ readonly channels: readonly string[];
3580
+ readonly origins: readonly string[];
3581
+ } | undefined;
3380
3582
  readonly browser?: {
3381
3583
  readonly methods: readonly string[];
3382
3584
  readonly primary: string;
@@ -3397,6 +3599,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3397
3599
  readonly origins?: readonly string[] | undefined;
3398
3600
  } | undefined;
3399
3601
  readonly onSignUp?: string | undefined;
3602
+ readonly invitationEmail?: string | undefined;
3400
3603
  } | undefined;
3401
3604
  readonly emails?: {
3402
3605
  readonly [x: string]: {
@@ -3411,6 +3614,20 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3411
3614
  } | undefined;
3412
3615
  readonly note?: string | undefined;
3413
3616
  readonly paragraphs?: readonly string[] | undefined;
3617
+ readonly sections?: readonly {
3618
+ readonly title: string;
3619
+ readonly text?: string | undefined;
3620
+ readonly items?: readonly {
3621
+ readonly label: string;
3622
+ readonly code?: string | undefined;
3623
+ readonly text?: string | undefined;
3624
+ }[] | undefined;
3625
+ readonly note?: string | undefined;
3626
+ readonly copy?: {
3627
+ readonly value: string;
3628
+ readonly label?: string | undefined;
3629
+ } | undefined;
3630
+ }[] | undefined;
3414
3631
  readonly footer?: string | undefined;
3415
3632
  };
3416
3633
  } | undefined;
@@ -3655,6 +3872,10 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
3655
3872
  } | undefined;
3656
3873
  readonly signIn?: {
3657
3874
  readonly policy: string;
3875
+ readonly guest?: {
3876
+ readonly channels: readonly string[];
3877
+ readonly origins: readonly string[];
3878
+ } | undefined;
3658
3879
  readonly browser?: {
3659
3880
  readonly methods: readonly string[];
3660
3881
  readonly primary: string;
@@ -3675,6 +3896,7 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
3675
3896
  readonly origins?: readonly string[] | undefined;
3676
3897
  } | undefined;
3677
3898
  readonly onSignUp?: string | undefined;
3899
+ readonly invitationEmail?: string | undefined;
3678
3900
  } | undefined;
3679
3901
  readonly emails?: {
3680
3902
  readonly [x: string]: {
@@ -3689,6 +3911,20 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
3689
3911
  } | undefined;
3690
3912
  readonly note?: string | undefined;
3691
3913
  readonly paragraphs?: readonly string[] | undefined;
3914
+ readonly sections?: readonly {
3915
+ readonly title: string;
3916
+ readonly text?: string | undefined;
3917
+ readonly items?: readonly {
3918
+ readonly label: string;
3919
+ readonly code?: string | undefined;
3920
+ readonly text?: string | undefined;
3921
+ }[] | undefined;
3922
+ readonly note?: string | undefined;
3923
+ readonly copy?: {
3924
+ readonly value: string;
3925
+ readonly label?: string | undefined;
3926
+ } | undefined;
3927
+ }[] | undefined;
3692
3928
  readonly footer?: string | undefined;
3693
3929
  };
3694
3930
  } | undefined;
@@ -3927,6 +4163,10 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
3927
4163
  } | undefined;
3928
4164
  readonly signIn?: {
3929
4165
  readonly policy: string;
4166
+ readonly guest?: {
4167
+ readonly channels: readonly string[];
4168
+ readonly origins: readonly string[];
4169
+ } | undefined;
3930
4170
  readonly browser?: {
3931
4171
  readonly methods: readonly string[];
3932
4172
  readonly primary: string;
@@ -3947,6 +4187,7 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
3947
4187
  readonly origins?: readonly string[] | undefined;
3948
4188
  } | undefined;
3949
4189
  readonly onSignUp?: string | undefined;
4190
+ readonly invitationEmail?: string | undefined;
3950
4191
  } | undefined;
3951
4192
  readonly emails?: {
3952
4193
  readonly [x: string]: {
@@ -3961,6 +4202,20 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
3961
4202
  } | undefined;
3962
4203
  readonly note?: string | undefined;
3963
4204
  readonly paragraphs?: readonly string[] | undefined;
4205
+ readonly sections?: readonly {
4206
+ readonly title: string;
4207
+ readonly text?: string | undefined;
4208
+ readonly items?: readonly {
4209
+ readonly label: string;
4210
+ readonly code?: string | undefined;
4211
+ readonly text?: string | undefined;
4212
+ }[] | undefined;
4213
+ readonly note?: string | undefined;
4214
+ readonly copy?: {
4215
+ readonly value: string;
4216
+ readonly label?: string | undefined;
4217
+ } | undefined;
4218
+ }[] | undefined;
3964
4219
  readonly footer?: string | undefined;
3965
4220
  };
3966
4221
  } | undefined;
@@ -4017,6 +4272,12 @@ export declare function signUpRolesOf(manifest: Pick<OntologyManifest, "signIn">
4017
4272
  * sign-up. Entries that are not an origin `signUp.origins` accepts are left out.
4018
4273
  */
4019
4274
  export declare function signUpOriginsOf(manifest: Pick<OntologyManifest, "signIn">): ReadonlyArray<string>;
4275
+ /**
4276
+ * Where guests talk to the agent and the websites whose visitors they are, as a manifest declares
4277
+ * them: `undefined` when it admits no guests, because it declares none, or none on a channel this
4278
+ * reader knows, or no website it can read.
4279
+ */
4280
+ export declare function guestOf(manifest: Pick<OntologyManifest, "signIn">): ResolvedGuest | undefined;
4020
4281
  /** Unsupported providers and missing or unknown channel policies require invitation. */
4021
4282
  export declare function channelPolicyOf(manifest: Pick<OntologyManifest, "signIn">, provider: string): SignInPolicy;
4022
4283
  /** JSON with object keys sorted at every level and no whitespace: the input of the manifest hash. */
package/dist/manifest.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { balancesOf, metricExpression } from "./metric.js";
2
2
  import { Effect, Schema, SchemaTransformation } from "effect";
3
3
  import { acceptingEarlierManifestNames, withEarlierManifestNames } from "./legacy.js";
4
- import { humanize, MEMBER_ROLE, FEEDBACK_REPORTER_ROLE } from "./names.js";
4
+ import { humanize, MEMBER_ROLE, FEEDBACK_REPORTER_ROLE, GUEST_ROLE } from "./names.js";
5
5
  import { PROPERTY_TYPES } from "./property.js";
6
6
  import { ON_DELETE } from "./relationship.js";
7
- import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isSignInPolicy, isSignUpChannel, signUpOrigin, } from "./sign-in.js";
7
+ import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isGuestChannel, isSignInPolicy, isSignUpChannel, websiteOrigin, } from "./sign-in.js";
8
8
  /**
9
9
  * The manifest format this SDK writes. Readers accept any version and ignore unknown fields. Version
10
10
  * 2 replaced the actions' `allow` with `permission`, and added the roles' `permissions` and the
@@ -63,6 +63,16 @@ import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isSignInPolicy, isSignUpChan
63
63
  * Within version 15, `signUp` may carry `web` among its channels and `origins`, the websites whose
64
64
  * visitors sign up on it, written only when declared. Older readers ignore both and keep `web`
65
65
  * closed.
66
+ * Within version 15, `signIn` may carry `guest`, written only when declared: the `channels` guests
67
+ * talk to the agent on and the `origins` of their websites, and `roles` then ends with the built-in
68
+ * `guest` role, which holds the guests' permissions. Origins of `guest` and `signUp` may be patterns
69
+ * such as `https://*.example.com`. Older readers ignore `guest` and admit no guests, and leave out
70
+ * the patterns they cannot read.
71
+ * Within version 15, an email may carry `sections`, boxes below its button, and its texts may use
72
+ * `{{app.url}}` and `{{app.mcpUrl}}`; `signIn` may carry `invitationEmail`, written only when
73
+ * declared: the wire name of the email the platform sends instead of its own invitation. Older
74
+ * readers ignore `sections` and `invitationEmail`, leave the two values empty and send the
75
+ * platform's invitation.
66
76
  */
67
77
  export const MANIFEST_VERSION = 15;
68
78
  /** The first version whose documents use snake_case names on the wire. */
@@ -397,6 +407,15 @@ export const SignUpManifest = Schema.Struct({
397
407
  channels: Schema.Record(Schema.String, Schema.Unknown),
398
408
  origins: Schema.optionalKey(Schema.Array(Schema.String)),
399
409
  });
410
+ /**
411
+ * Guests: the channels they talk to the agent on and the websites whose visitors they are. Their
412
+ * permissions are the built-in `guest` role's. Read as text: channels and origins a reader does not
413
+ * know admit nobody.
414
+ */
415
+ export const GuestManifest = Schema.Struct({
416
+ channels: Schema.Array(Schema.String),
417
+ origins: Schema.Array(Schema.String),
418
+ });
400
419
  export const SignInManifest = Schema.Struct({
401
420
  browser: Schema.optionalKey(BrowserSignInManifest),
402
421
  policy: Schema.String,
@@ -405,11 +424,15 @@ export const SignInManifest = Schema.Struct({
405
424
  codeLink: Schema.optionalKey(Schema.Boolean),
406
425
  signUp: Schema.optionalKey(SignUpManifest),
407
426
  onSignUp: Schema.optionalKey(Schema.String),
427
+ guest: Schema.optionalKey(GuestManifest),
428
+ /** The wire name of the email the platform sends instead of its own invitation. */
429
+ invitationEmail: Schema.optionalKey(Schema.String),
408
430
  }).pipe(Schema.encodeKeys({
409
431
  onNewUser: "on_new_user",
410
432
  codeLink: "code_link",
411
433
  signUp: "sign_up",
412
434
  onSignUp: "on_sign_up",
435
+ invitationEmail: "invitation_email",
413
436
  }));
414
437
  /** One of the workspace's emails, as `defineOntology({ emails })` declares it; see `EmailTemplate`. */
415
438
  export const EmailTemplateManifest = Schema.Struct({
@@ -420,6 +443,17 @@ export const EmailTemplateManifest = Schema.Struct({
420
443
  note: Schema.optionalKey(Schema.String),
421
444
  paragraphs: Schema.optionalKey(Schema.Array(Schema.String)),
422
445
  action: Schema.String,
446
+ sections: Schema.optionalKey(Schema.Array(Schema.Struct({
447
+ title: Schema.String,
448
+ text: Schema.optionalKey(Schema.String),
449
+ copy: Schema.optionalKey(Schema.Struct({ label: Schema.optionalKey(Schema.String), value: Schema.String })),
450
+ items: Schema.optionalKey(Schema.Array(Schema.Struct({
451
+ label: Schema.String,
452
+ text: Schema.optionalKey(Schema.String),
453
+ code: Schema.optionalKey(Schema.String),
454
+ }))),
455
+ note: Schema.optionalKey(Schema.String),
456
+ }))),
423
457
  footer: Schema.optionalKey(Schema.String),
424
458
  replyTo: Schema.optionalKey(Schema.String),
425
459
  }).pipe(Schema.encodeKeys({ replyTo: "reply_to" }));
@@ -573,11 +607,33 @@ export function signUpOriginsOf(manifest) {
573
607
  const origins = manifest.signIn?.signUp?.origins;
574
608
  return Array.isArray(origins)
575
609
  ? origins.flatMap((candidate) => {
576
- const origin = signUpOrigin(candidate);
610
+ const origin = websiteOrigin(candidate);
577
611
  return origin === undefined ? [] : [origin];
578
612
  })
579
613
  : [];
580
614
  }
615
+ /**
616
+ * Where guests talk to the agent and the websites whose visitors they are, as a manifest declares
617
+ * them: `undefined` when it admits no guests, because it declares none, or none on a channel this
618
+ * reader knows, or no website it can read.
619
+ */
620
+ export function guestOf(manifest) {
621
+ const declared = manifest.signIn?.guest;
622
+ if (typeof declared !== "object" || declared === null) {
623
+ return undefined;
624
+ }
625
+ const { channels, origins } = declared;
626
+ const known = Array.isArray(channels) ? channels.filter(isGuestChannel) : [];
627
+ const websites = Array.isArray(origins)
628
+ ? origins.flatMap((candidate) => {
629
+ const origin = websiteOrigin(candidate);
630
+ return origin === undefined ? [] : [origin];
631
+ })
632
+ : [];
633
+ return known.length === 0 || websites.length === 0
634
+ ? undefined
635
+ : { channels: [...new Set(known)], origins: websites };
636
+ }
581
637
  // @legacy ontology.legacy-channel-admission
582
638
  /** Unsupported providers and missing or unknown channel policies require invitation. */
583
639
  export function channelPolicyOf(manifest, provider) {
@@ -799,7 +855,9 @@ export function buildManifest(input) {
799
855
  roles: input.roles.map((candidate) => ({
800
856
  name: candidate.name,
801
857
  description: candidate.description,
802
- builtIn: candidate.name === MEMBER_ROLE || candidate.name === FEEDBACK_REPORTER_ROLE,
858
+ builtIn: candidate.name === MEMBER_ROLE ||
859
+ candidate.name === FEEDBACK_REPORTER_ROLE ||
860
+ (candidate.name === GUEST_ROLE && input.signIn.guest !== undefined),
803
861
  permissions: [...candidate.permissions],
804
862
  ...((candidate.scopes ?? []).length > 0
805
863
  ? {
@@ -815,6 +873,9 @@ export function buildManifest(input) {
815
873
  ...(input.signIn.browser === undefined ? {} : { browser: input.signIn.browser }),
816
874
  ...(input.signIn.onNewUser === undefined ? {} : { onNewUser: input.signIn.onNewUser }),
817
875
  ...(input.signIn.codeLink === undefined ? {} : { codeLink: input.signIn.codeLink }),
876
+ ...(input.signIn.invitationEmail === undefined
877
+ ? {}
878
+ : { invitationEmail: input.signIn.invitationEmail }),
818
879
  ...(Object.keys(input.signIn.channels ?? {}).length > 0
819
880
  ? { channels: input.signIn.channels }
820
881
  : {}),
@@ -832,6 +893,14 @@ export function buildManifest(input) {
832
893
  },
833
894
  }),
834
895
  ...(input.signIn.onSignUp === undefined ? {} : { onSignUp: input.signIn.onSignUp }),
896
+ ...(input.signIn.guest === undefined
897
+ ? {}
898
+ : {
899
+ guest: {
900
+ channels: [...input.signIn.guest.channels],
901
+ origins: [...input.signIn.guest.origins],
902
+ },
903
+ }),
835
904
  },
836
905
  ...(Object.keys(emails).length > 0 ? { emails } : {}),
837
906
  ...(input.chat === undefined ? {} : { chat: input.chat }),