@segmentstream/ontology 0.106.2 → 0.107.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.
- package/CHANGELOG.md +55 -0
- package/README.md +38 -8
- package/dist/analyze.d.ts +7 -1
- package/dist/analyze.js +237 -13
- package/dist/authoring.js +6 -0
- package/dist/diagnostics.d.ts +3 -3
- package/dist/diagnostics.js +1 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +5 -3
- package/dist/manifest.d.ts +69 -1
- package/dist/manifest.js +51 -4
- package/dist/migrate/apply.d.ts +6 -0
- package/dist/migrate/apply.js +25 -5
- package/dist/migrate/model.d.ts +32 -0
- package/dist/migrate/storage.d.ts +2 -0
- package/dist/migrate/storage.js +8 -0
- package/dist/names.d.ts +5 -0
- package/dist/names.js +5 -0
- package/dist/ontology.d.ts +4 -1
- package/dist/permissions.d.ts +30 -2
- package/dist/permissions.js +51 -6
- package/dist/replication/shadow.d.ts +4 -2
- package/dist/replication/shadow.js +1 -1
- package/dist/replication/store.js +4 -0
- package/dist/runtime/agent-counters.d.ts +5 -1
- package/dist/runtime/agent-counters.js +21 -6
- package/dist/runtime/agent-web.d.ts +9 -6
- package/dist/runtime/agent-web.js +101 -5
- package/dist/runtime/generated-actions.js +2 -3
- package/dist/runtime/guests.d.ts +32 -0
- package/dist/runtime/guests.js +64 -0
- package/dist/runtime/new-user-hook.js +2 -1
- package/dist/runtime/oauth.js +7 -1
- package/dist/runtime/pipeline.js +3 -2
- package/dist/runtime/principals.js +6 -4
- package/dist/runtime/service-binding.js +2 -2
- package/dist/runtime/sql-runtime.js +2 -1
- package/dist/runtime.d.ts +10 -2
- package/dist/service/agent/authentication.d.ts +6 -4
- package/dist/service/agent/authentication.js +20 -5
- package/dist/service/agent/protocol.d.ts +28 -2
- package/dist/service/agent/protocol.js +23 -10
- package/dist/service/agent/server.d.ts +9 -2
- package/dist/service/agent/server.js +12 -12
- package/dist/service/agent/tasks.d.ts +3 -0
- package/dist/service/agent/tasks.js +5 -3
- package/dist/service/agent/web-tokens.d.ts +28 -13
- package/dist/service/agent/web-tokens.js +91 -38
- package/dist/service/authentication.d.ts +6 -0
- package/dist/service/authentication.js +11 -2
- package/dist/service/chat/review-delivery.js +4 -0
- package/dist/service/mcp/server.js +3 -3
- package/dist/service/mcp/tools.d.ts +4 -2
- package/dist/service/mcp/tools.js +14 -2
- package/dist/service/oauth/protocol.js +8 -2
- package/dist/service/oauth/server.js +5 -1
- package/dist/service/runtime-contract.d.ts +58 -6
- package/dist/service/schemas.d.ts +8 -0
- package/dist/service/service.js +15 -4
- package/dist/sign-in.d.ts +58 -9
- package/dist/sign-in.js +87 -9
- package/package.json +1 -1
package/dist/diagnostics.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export type { ActionsBuilder, AnyEntity, ActionHandle, ActionInvoker, MetricQuer
|
|
|
24
24
|
export { ActionRejected, BatchErrorDetails, Conflict, DeploymentInterrupted, DeploymentSwitching, LimitErrorDetails, NotFound, PermissionDenied, ScopeViolated, } from "./errors.js";
|
|
25
25
|
export type { ActionError } from "./errors.js";
|
|
26
26
|
export { browserAuthenticationCompatible } from "./manifest-compatibility.js";
|
|
27
|
-
export { ActionManifest, actionConnectionKeys, canonicalJson, ConnectionManifest, EntityManifest, EntityPermissionsManifest, decodeManifestDocument, encodeManifest, formatManifest, IndexManifest, isValueMatched, MANIFEST_VERSION, manifestHash, ModelMetricManifest, OntologyManifest, OntologyManifestWire, PropertyManifest, RelationshipManifest, RoleManifest, ActionTriggerManifest, ScopeManifest, CronTriggerManifest, isActionTrigger, isCronTrigger, isWebhookTrigger, OtherTriggerManifest, WebhookTriggerManifest, WorkflowManifest, WorkflowTriggerManifest, SelectOptionManifest, SignInManifest, signInPolicyOf, channelPolicyOf, signUpOriginsOf, signUpRolesOf, } from "./manifest.js";
|
|
27
|
+
export { ActionManifest, actionConnectionKeys, canonicalJson, ConnectionManifest, EntityManifest, EntityPermissionsManifest, decodeManifestDocument, encodeManifest, formatManifest, IndexManifest, isValueMatched, MANIFEST_VERSION, manifestHash, ModelMetricManifest, OntologyManifest, OntologyManifestWire, PropertyManifest, RelationshipManifest, RoleManifest, ActionTriggerManifest, ScopeManifest, CronTriggerManifest, isActionTrigger, isCronTrigger, isWebhookTrigger, OtherTriggerManifest, WebhookTriggerManifest, WorkflowManifest, WorkflowTriggerManifest, SelectOptionManifest, SignInManifest, GuestManifest, guestOf, signInPolicyOf, channelPolicyOf, signUpOriginsOf, signUpRolesOf, } from "./manifest.js";
|
|
28
28
|
export { SYSTEM_PROPERTIES } from "./names.js";
|
|
29
29
|
export type { SystemProperty } from "./names.js";
|
|
30
30
|
export { isMe, isMeMarker, MAX_ME_HOPS, me, ME_KEY, MeMarker, mePathOf, meToWire, MeTypeId, } from "./me.js";
|
|
@@ -33,8 +33,8 @@ export { check, defineOntology } from "./ontology.js";
|
|
|
33
33
|
export { webhookDeliveryJsonSchema } from "./analyze.js";
|
|
34
34
|
export { webhookToken, webhookTokenMatches, WEBHOOK_TOKEN_CONTEXT } from "./webhook-token.js";
|
|
35
35
|
export type { Ontology } from "./ontology.js";
|
|
36
|
-
export { DEFAULT_MEMBER_PERMISSIONS, effectiveScope, generatedActionPermissions, grants, isAllowed, parsePermission, permissionsOf, principalScopes, READ_VERB, readScope, rolesGranting, scopesOf, USER_IDENTITY_VERBS, USER_MEMBER_VERBS, WILDCARD, WILDCARD_ENTITY_VERBS, WORKSPACE_SOURCE_PERMISSION, } from "./permissions.js";
|
|
37
|
-
export type { ParsedPermission, PermissionHolder, RolePermissions, ScopedPermission, ScopeFilter, ScopeValue, ScopeWhere, UserMemberVerb, } from "./permissions.js";
|
|
36
|
+
export { AGENT_TOOL_VERBS, agentToolPermission, agentToolsOf, DEFAULT_MEMBER_PERMISSIONS, effectiveScope, generatedActionPermissions, grants, isAllowed, parsePermission, permissionsOf, principalScopes, READ_VERB, readScope, rolesGranting, scopesOf, USER_IDENTITY_VERBS, USER_MEMBER_VERBS, WILDCARD, WILDCARD_ENTITY_VERBS, WORKSPACE_SOURCE_PERMISSION, } from "./permissions.js";
|
|
37
|
+
export type { AgentToolVerb, ParsedPermission, PermissionHolder, RolePermissions, ScopedPermission, ScopeFilter, ScopeValue, ScopeWhere, UserMemberVerb, } from "./permissions.js";
|
|
38
38
|
export { p, PROPERTY_TYPES, propertyDefinition } from "./property.js";
|
|
39
39
|
export type { AnyProperty, NumberOptions, Property, PropertyDefinition, PropertyOf, PropertyOptions, BlobOptions, ListOptions, PropertyType, ReferenceOptions, SelectOption, SelectOptionInput, TextOptions, } from "./property.js";
|
|
40
40
|
export { ON_DELETE, rel } from "./relationship.js";
|
|
@@ -48,8 +48,8 @@ export { after, changed, cron, cronNeverFires, cronProblem, isWorkflow, isWorkfl
|
|
|
48
48
|
export { MAX_WEBHOOK_BODY_BYTES, MAX_META_WEBHOOK_BODY_BYTES, MAX_WEBHOOK_HEADERS, MAX_WEBHOOKS, WEBHOOK_BASE_PATH, WEBHOOK_SIGNATURE_SCHEMES, webhookDelivery, webhookHeaderProblem, webhookPath, } from "./webhooks.js";
|
|
49
49
|
export type { WebhookDelivery, WebhookSignatureScheme } from "./webhooks.js";
|
|
50
50
|
export type { ActionEvent, ActionTrigger, AfterOptions, AnyActionHandle, AnyWorkflow, ChangedBounds, CronOptions, CronProblem, CronTrigger, TriggerFunction, TriggerRecord, WebhookOptions, WebhookSignature, WebhookVerification, WebhookTrigger, Workflow, WorkflowFunction, WorkflowOptions, WorkflowRunContext, WorkflowTrigger, } from "./workflow.js";
|
|
51
|
-
export { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_IN_METHODS, SIGN_IN_POLICIES, SIGN_UP_CHANNELS, signUpOrigin, } from "./sign-in.js";
|
|
52
|
-
export type { ChannelProvider, ResolvedSignInOptions, ResolvedSignUp, SignInCheck, SignInMethod, SignInOptions, SignInPolicy, SignUpChannel, SignUpOptions, } from "./sign-in.js";
|
|
51
|
+
export { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_IN_METHODS, SIGN_IN_POLICIES, SIGN_UP_CHANNELS, GUEST_CHANNELS, matchesWebsite, signUpOrigin, websiteOrigin, } from "./sign-in.js";
|
|
52
|
+
export type { ChannelProvider, GuestChannel, GuestOptions, ResolvedGuest, ResolvedSignInOptions, ResolvedSignUp, SignInCheck, SignInMethod, SignInOptions, SignInPolicy, SignUpChannel, SignUpOptions, } from "./sign-in.js";
|
|
53
53
|
export type { EmailTemplate } from "./emails.js";
|
|
54
54
|
export { OntologyActions, OntologyReads, OntologyRuntime, OntologyWrites } from "./runtime.js";
|
|
55
55
|
export type { ActionRunOptions } from "./runtime.js";
|
|
@@ -86,7 +86,7 @@ export { configFromEnv, ENVIRONMENT_VARIABLES, NEON_AUTH_ENVIRONMENT_VARIABLES,
|
|
|
86
86
|
export type { ActionCommitted, AfterCommitHook, NeonAuthEnvironment, OntologyEnvironment, OntologyServiceConfig, } from "./service/config.js";
|
|
87
87
|
export type { Decide, DecisionRequest } from "./service/decisions.js";
|
|
88
88
|
export { IdentityInUse, NotInvited, OntologyBackend } from "./service/runtime-contract.js";
|
|
89
|
-
export type { AgentIdentity, AgentMember, AgentLimits, AgentLimitScope, ChannelSignInInput, AgentResolution, ResolveIdentityInput, AgentPairing, AgentStore, AgentWebStore, VisitorSignUp, WebTurnLimit, SeenChat, HeldReplyInput, HeldReview, GeneratedActionsProvider, IdentityProvider, OAuthClient, OAuthClientAuthMethod, OAuthGrant, OAuthDevice, DevicePoll, OAuthRequest, OAuthStore, OAuthToken, OAuthTokenKind, OntologyServiceRuntime, RunActionInput, SignInIdentity, UsedOAuthToken, } from "./service/runtime-contract.js";
|
|
89
|
+
export type { AgentIdentity, AgentMember, AgentLimits, AgentLimitScope, ChannelSignInInput, AgentResolution, ResolveIdentityInput, AgentPairing, AgentStore, AgentWebStore, GuestIssue, VisitorSignUp, WebTurnLimit, SeenChat, HeldReplyInput, HeldReview, GeneratedActionsProvider, IdentityProvider, OAuthClient, OAuthClientAuthMethod, OAuthGrant, OAuthDevice, DevicePoll, OAuthRequest, OAuthStore, OAuthToken, OAuthTokenKind, OntologyServiceRuntime, RunActionInput, SignInIdentity, UsedOAuthToken, } from "./service/runtime-contract.js";
|
|
90
90
|
export { createOntologyService, ONTOLOGY_HASH_HEADER, REQUEST_ID_HEADER, } from "./service/service.js";
|
|
91
91
|
export { AGENT_PATH, AGENT_TOKEN_INTROSPECTION_PATH, AGENT_TOKENS_PATH, AGENT_VISITORS_PATH, } from "./service/agent/server.js";
|
|
92
92
|
export { AGENT_TASK_PATH, AGENT_TASK_RESULT_PATH } from "./service/agent/tasks.js";
|
package/dist/index.js
CHANGED
|
@@ -13,20 +13,22 @@ export { entity, isEntity } from "./entity.js";
|
|
|
13
13
|
export { isToolset, MCP_TOOL_NAME, TOOLSET_LOCK_VERSION, toolset, ToolsetLock, ToolsetLockTool, } from "./toolset.js";
|
|
14
14
|
export { ActionRejected, BatchErrorDetails, Conflict, DeploymentInterrupted, DeploymentSwitching, LimitErrorDetails, NotFound, PermissionDenied, ScopeViolated, } from "./errors.js";
|
|
15
15
|
export { browserAuthenticationCompatible } from "./manifest-compatibility.js";
|
|
16
|
-
export { ActionManifest, actionConnectionKeys, canonicalJson, ConnectionManifest, EntityManifest, EntityPermissionsManifest, decodeManifestDocument, encodeManifest, formatManifest, IndexManifest, isValueMatched, MANIFEST_VERSION, manifestHash, ModelMetricManifest, OntologyManifest, OntologyManifestWire, PropertyManifest, RelationshipManifest, RoleManifest, ActionTriggerManifest, ScopeManifest, CronTriggerManifest, isActionTrigger, isCronTrigger, isWebhookTrigger, OtherTriggerManifest, WebhookTriggerManifest, WorkflowManifest, WorkflowTriggerManifest, SelectOptionManifest, SignInManifest, signInPolicyOf, channelPolicyOf, signUpOriginsOf, signUpRolesOf, } from "./manifest.js";
|
|
16
|
+
export { ActionManifest, actionConnectionKeys, canonicalJson, ConnectionManifest, EntityManifest, EntityPermissionsManifest, decodeManifestDocument, encodeManifest, formatManifest, IndexManifest, isValueMatched, MANIFEST_VERSION, manifestHash, ModelMetricManifest, OntologyManifest, OntologyManifestWire, PropertyManifest, RelationshipManifest, RoleManifest, ActionTriggerManifest, ScopeManifest, CronTriggerManifest, isActionTrigger, isCronTrigger, isWebhookTrigger, OtherTriggerManifest, WebhookTriggerManifest, WorkflowManifest, WorkflowTriggerManifest, SelectOptionManifest, SignInManifest, GuestManifest, guestOf, signInPolicyOf, channelPolicyOf, signUpOriginsOf, signUpRolesOf, } from "./manifest.js";
|
|
17
17
|
export { SYSTEM_PROPERTIES } from "./names.js";
|
|
18
18
|
export { isMe, isMeMarker, MAX_ME_HOPS, me, ME_KEY, MeMarker, mePathOf, meToWire, MeTypeId, } from "./me.js";
|
|
19
19
|
export { check, defineOntology } from "./ontology.js";
|
|
20
20
|
export { webhookDeliveryJsonSchema } from "./analyze.js";
|
|
21
21
|
export { webhookToken, webhookTokenMatches, WEBHOOK_TOKEN_CONTEXT } from "./webhook-token.js";
|
|
22
|
-
export { DEFAULT_MEMBER_PERMISSIONS, effectiveScope, generatedActionPermissions, grants, isAllowed, parsePermission, permissionsOf, principalScopes, READ_VERB, readScope, rolesGranting, scopesOf, USER_IDENTITY_VERBS, USER_MEMBER_VERBS, WILDCARD, WILDCARD_ENTITY_VERBS, WORKSPACE_SOURCE_PERMISSION, } from "./permissions.js";
|
|
22
|
+
export { AGENT_TOOL_VERBS, agentToolPermission, agentToolsOf, DEFAULT_MEMBER_PERMISSIONS, effectiveScope, generatedActionPermissions, grants, isAllowed, parsePermission, permissionsOf, principalScopes, READ_VERB, readScope, rolesGranting, scopesOf, USER_IDENTITY_VERBS, USER_MEMBER_VERBS, WILDCARD, WILDCARD_ENTITY_VERBS, WORKSPACE_SOURCE_PERMISSION, } from "./permissions.js";
|
|
23
23
|
export { p, PROPERTY_TYPES, propertyDefinition } from "./property.js";
|
|
24
24
|
export { ON_DELETE, rel } from "./relationship.js";
|
|
25
25
|
export { renderCatalog } from "./render.js";
|
|
26
26
|
export { member, role, roleEntries, rolePermissions } from "./role.js";
|
|
27
27
|
export { after, changed, cron, cronNeverFires, cronProblem, isWorkflow, isWorkflowTrigger, MAX_ACTION_TRIGGERS, MAX_WORKFLOWS, nextCronTime, webhook, workflow, } from "./workflow.js";
|
|
28
28
|
export { MAX_WEBHOOK_BODY_BYTES, MAX_META_WEBHOOK_BODY_BYTES, MAX_WEBHOOK_HEADERS, MAX_WEBHOOKS, WEBHOOK_BASE_PATH, WEBHOOK_SIGNATURE_SCHEMES, webhookDelivery, webhookHeaderProblem, webhookPath, } from "./webhooks.js";
|
|
29
|
-
export { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_IN_METHODS, SIGN_IN_POLICIES, SIGN_UP_CHANNELS,
|
|
29
|
+
export { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_IN_METHODS, SIGN_IN_POLICIES, SIGN_UP_CHANNELS, GUEST_CHANNELS, matchesWebsite,
|
|
30
|
+
// @legacy ontology.sign-up-origin-name
|
|
31
|
+
signUpOrigin, websiteOrigin, } from "./sign-in.js";
|
|
30
32
|
export { OntologyActions, OntologyReads, OntologyRuntime, OntologyWrites } from "./runtime.js";
|
|
31
33
|
export { User } from "./user.js";
|
|
32
34
|
export { AgentChat } from "./agent-chat.js";
|
package/dist/manifest.d.ts
CHANGED
|
@@ -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,11 @@ 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.
|
|
66
71
|
*/
|
|
67
72
|
export declare const MANIFEST_VERSION = 15;
|
|
68
73
|
/** The phrase used for a direction the author did not phrase. */
|
|
@@ -619,6 +624,15 @@ export declare const SignUpManifest: Schema.Struct<{
|
|
|
619
624
|
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
620
625
|
readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
621
626
|
}>;
|
|
627
|
+
/**
|
|
628
|
+
* Guests: the channels they talk to the agent on and the websites whose visitors they are. Their
|
|
629
|
+
* permissions are the built-in `guest` role's. Read as text: channels and origins a reader does not
|
|
630
|
+
* know admit nobody.
|
|
631
|
+
*/
|
|
632
|
+
export declare const GuestManifest: Schema.Struct<{
|
|
633
|
+
readonly channels: Schema.$Array<Schema.String>;
|
|
634
|
+
readonly origins: Schema.$Array<Schema.String>;
|
|
635
|
+
}>;
|
|
622
636
|
export declare const SignInManifest: Schema.encodeKeys<Schema.Struct<{
|
|
623
637
|
readonly browser: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
|
|
624
638
|
readonly methods: Schema.$Array<Schema.String>;
|
|
@@ -639,6 +653,10 @@ export declare const SignInManifest: Schema.encodeKeys<Schema.Struct<{
|
|
|
639
653
|
readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
640
654
|
}>>;
|
|
641
655
|
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
656
|
+
readonly guest: Schema.optionalKey<Schema.Struct<{
|
|
657
|
+
readonly channels: Schema.$Array<Schema.String>;
|
|
658
|
+
readonly origins: Schema.$Array<Schema.String>;
|
|
659
|
+
}>>;
|
|
642
660
|
}>, {
|
|
643
661
|
readonly onNewUser: "on_new_user";
|
|
644
662
|
readonly codeLink: "code_link";
|
|
@@ -920,6 +938,10 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
|
|
|
920
938
|
readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
921
939
|
}>>;
|
|
922
940
|
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
941
|
+
readonly guest: Schema.optionalKey<Schema.Struct<{
|
|
942
|
+
readonly channels: Schema.$Array<Schema.String>;
|
|
943
|
+
readonly origins: Schema.$Array<Schema.String>;
|
|
944
|
+
}>>;
|
|
923
945
|
}>, {
|
|
924
946
|
readonly onNewUser: "on_new_user";
|
|
925
947
|
readonly codeLink: "code_link";
|
|
@@ -1292,6 +1314,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
1292
1314
|
} | undefined;
|
|
1293
1315
|
readonly signIn?: {
|
|
1294
1316
|
readonly policy: string;
|
|
1317
|
+
readonly guest?: {
|
|
1318
|
+
readonly channels: readonly string[];
|
|
1319
|
+
readonly origins: readonly string[];
|
|
1320
|
+
} | undefined;
|
|
1295
1321
|
readonly browser?: {
|
|
1296
1322
|
readonly methods: readonly string[];
|
|
1297
1323
|
readonly primary: string;
|
|
@@ -1564,6 +1590,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
1564
1590
|
} | undefined;
|
|
1565
1591
|
readonly signIn?: {
|
|
1566
1592
|
readonly policy: string;
|
|
1593
|
+
readonly guest?: {
|
|
1594
|
+
readonly channels: readonly string[];
|
|
1595
|
+
readonly origins: readonly string[];
|
|
1596
|
+
} | undefined;
|
|
1567
1597
|
readonly browser?: {
|
|
1568
1598
|
readonly methods: readonly string[];
|
|
1569
1599
|
readonly primary: string;
|
|
@@ -1887,6 +1917,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
1887
1917
|
}[] | undefined;
|
|
1888
1918
|
readonly sign_in?: {
|
|
1889
1919
|
readonly policy: string;
|
|
1920
|
+
readonly guest?: {
|
|
1921
|
+
readonly channels: readonly string[];
|
|
1922
|
+
readonly origins: readonly string[];
|
|
1923
|
+
} | undefined;
|
|
1890
1924
|
readonly browser?: {
|
|
1891
1925
|
readonly methods: readonly string[];
|
|
1892
1926
|
readonly primary: string;
|
|
@@ -2108,6 +2142,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
2108
2142
|
} | undefined;
|
|
2109
2143
|
readonly signIn?: {
|
|
2110
2144
|
readonly policy: string;
|
|
2145
|
+
readonly guest?: {
|
|
2146
|
+
readonly channels: readonly string[];
|
|
2147
|
+
readonly origins: readonly string[];
|
|
2148
|
+
} | undefined;
|
|
2111
2149
|
readonly browser?: {
|
|
2112
2150
|
readonly methods: readonly string[];
|
|
2113
2151
|
readonly primary: string;
|
|
@@ -2381,6 +2419,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
2381
2419
|
readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
2382
2420
|
}>>;
|
|
2383
2421
|
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
2422
|
+
readonly guest: Schema.optionalKey<Schema.Struct<{
|
|
2423
|
+
readonly channels: Schema.$Array<Schema.String>;
|
|
2424
|
+
readonly origins: Schema.$Array<Schema.String>;
|
|
2425
|
+
}>>;
|
|
2384
2426
|
}>, {
|
|
2385
2427
|
readonly onNewUser: "on_new_user";
|
|
2386
2428
|
readonly codeLink: "code_link";
|
|
@@ -2741,6 +2783,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
2741
2783
|
readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
2742
2784
|
}>>;
|
|
2743
2785
|
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
2786
|
+
readonly guest: Schema.optionalKey<Schema.Struct<{
|
|
2787
|
+
readonly channels: Schema.$Array<Schema.String>;
|
|
2788
|
+
readonly origins: Schema.$Array<Schema.String>;
|
|
2789
|
+
}>>;
|
|
2744
2790
|
}>, {
|
|
2745
2791
|
readonly onNewUser: "on_new_user";
|
|
2746
2792
|
readonly codeLink: "code_link";
|
|
@@ -3105,6 +3151,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
3105
3151
|
} | undefined;
|
|
3106
3152
|
readonly signIn?: {
|
|
3107
3153
|
readonly policy: string;
|
|
3154
|
+
readonly guest?: {
|
|
3155
|
+
readonly channels: readonly string[];
|
|
3156
|
+
readonly origins: readonly string[];
|
|
3157
|
+
} | undefined;
|
|
3108
3158
|
readonly browser?: {
|
|
3109
3159
|
readonly methods: readonly string[];
|
|
3110
3160
|
readonly primary: string;
|
|
@@ -3377,6 +3427,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
3377
3427
|
} | undefined;
|
|
3378
3428
|
readonly signIn?: {
|
|
3379
3429
|
readonly policy: string;
|
|
3430
|
+
readonly guest?: {
|
|
3431
|
+
readonly channels: readonly string[];
|
|
3432
|
+
readonly origins: readonly string[];
|
|
3433
|
+
} | undefined;
|
|
3380
3434
|
readonly browser?: {
|
|
3381
3435
|
readonly methods: readonly string[];
|
|
3382
3436
|
readonly primary: string;
|
|
@@ -3655,6 +3709,10 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
|
|
|
3655
3709
|
} | undefined;
|
|
3656
3710
|
readonly signIn?: {
|
|
3657
3711
|
readonly policy: string;
|
|
3712
|
+
readonly guest?: {
|
|
3713
|
+
readonly channels: readonly string[];
|
|
3714
|
+
readonly origins: readonly string[];
|
|
3715
|
+
} | undefined;
|
|
3658
3716
|
readonly browser?: {
|
|
3659
3717
|
readonly methods: readonly string[];
|
|
3660
3718
|
readonly primary: string;
|
|
@@ -3927,6 +3985,10 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
|
|
|
3927
3985
|
} | undefined;
|
|
3928
3986
|
readonly signIn?: {
|
|
3929
3987
|
readonly policy: string;
|
|
3988
|
+
readonly guest?: {
|
|
3989
|
+
readonly channels: readonly string[];
|
|
3990
|
+
readonly origins: readonly string[];
|
|
3991
|
+
} | undefined;
|
|
3930
3992
|
readonly browser?: {
|
|
3931
3993
|
readonly methods: readonly string[];
|
|
3932
3994
|
readonly primary: string;
|
|
@@ -4017,6 +4079,12 @@ export declare function signUpRolesOf(manifest: Pick<OntologyManifest, "signIn">
|
|
|
4017
4079
|
* sign-up. Entries that are not an origin `signUp.origins` accepts are left out.
|
|
4018
4080
|
*/
|
|
4019
4081
|
export declare function signUpOriginsOf(manifest: Pick<OntologyManifest, "signIn">): ReadonlyArray<string>;
|
|
4082
|
+
/**
|
|
4083
|
+
* Where guests talk to the agent and the websites whose visitors they are, as a manifest declares
|
|
4084
|
+
* them: `undefined` when it admits no guests, because it declares none, or none on a channel this
|
|
4085
|
+
* reader knows, or no website it can read.
|
|
4086
|
+
*/
|
|
4087
|
+
export declare function guestOf(manifest: Pick<OntologyManifest, "signIn">): ResolvedGuest | undefined;
|
|
4020
4088
|
/** Unsupported providers and missing or unknown channel policies require invitation. */
|
|
4021
4089
|
export declare function channelPolicyOf(manifest: Pick<OntologyManifest, "signIn">, provider: string): SignInPolicy;
|
|
4022
4090
|
/** 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,
|
|
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,11 @@ 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.
|
|
66
71
|
*/
|
|
67
72
|
export const MANIFEST_VERSION = 15;
|
|
68
73
|
/** The first version whose documents use snake_case names on the wire. */
|
|
@@ -397,6 +402,15 @@ export const SignUpManifest = Schema.Struct({
|
|
|
397
402
|
channels: Schema.Record(Schema.String, Schema.Unknown),
|
|
398
403
|
origins: Schema.optionalKey(Schema.Array(Schema.String)),
|
|
399
404
|
});
|
|
405
|
+
/**
|
|
406
|
+
* Guests: the channels they talk to the agent on and the websites whose visitors they are. Their
|
|
407
|
+
* permissions are the built-in `guest` role's. Read as text: channels and origins a reader does not
|
|
408
|
+
* know admit nobody.
|
|
409
|
+
*/
|
|
410
|
+
export const GuestManifest = Schema.Struct({
|
|
411
|
+
channels: Schema.Array(Schema.String),
|
|
412
|
+
origins: Schema.Array(Schema.String),
|
|
413
|
+
});
|
|
400
414
|
export const SignInManifest = Schema.Struct({
|
|
401
415
|
browser: Schema.optionalKey(BrowserSignInManifest),
|
|
402
416
|
policy: Schema.String,
|
|
@@ -405,6 +419,7 @@ export const SignInManifest = Schema.Struct({
|
|
|
405
419
|
codeLink: Schema.optionalKey(Schema.Boolean),
|
|
406
420
|
signUp: Schema.optionalKey(SignUpManifest),
|
|
407
421
|
onSignUp: Schema.optionalKey(Schema.String),
|
|
422
|
+
guest: Schema.optionalKey(GuestManifest),
|
|
408
423
|
}).pipe(Schema.encodeKeys({
|
|
409
424
|
onNewUser: "on_new_user",
|
|
410
425
|
codeLink: "code_link",
|
|
@@ -573,10 +588,32 @@ export function signUpOriginsOf(manifest) {
|
|
|
573
588
|
const origins = manifest.signIn?.signUp?.origins;
|
|
574
589
|
return Array.isArray(origins)
|
|
575
590
|
? origins.flatMap((candidate) => {
|
|
576
|
-
const origin =
|
|
591
|
+
const origin = websiteOrigin(candidate);
|
|
592
|
+
return origin === undefined ? [] : [origin];
|
|
593
|
+
})
|
|
594
|
+
: [];
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Where guests talk to the agent and the websites whose visitors they are, as a manifest declares
|
|
598
|
+
* them: `undefined` when it admits no guests, because it declares none, or none on a channel this
|
|
599
|
+
* reader knows, or no website it can read.
|
|
600
|
+
*/
|
|
601
|
+
export function guestOf(manifest) {
|
|
602
|
+
const declared = manifest.signIn?.guest;
|
|
603
|
+
if (typeof declared !== "object" || declared === null) {
|
|
604
|
+
return undefined;
|
|
605
|
+
}
|
|
606
|
+
const { channels, origins } = declared;
|
|
607
|
+
const known = Array.isArray(channels) ? channels.filter(isGuestChannel) : [];
|
|
608
|
+
const websites = Array.isArray(origins)
|
|
609
|
+
? origins.flatMap((candidate) => {
|
|
610
|
+
const origin = websiteOrigin(candidate);
|
|
577
611
|
return origin === undefined ? [] : [origin];
|
|
578
612
|
})
|
|
579
613
|
: [];
|
|
614
|
+
return known.length === 0 || websites.length === 0
|
|
615
|
+
? undefined
|
|
616
|
+
: { channels: [...new Set(known)], origins: websites };
|
|
580
617
|
}
|
|
581
618
|
// @legacy ontology.legacy-channel-admission
|
|
582
619
|
/** Unsupported providers and missing or unknown channel policies require invitation. */
|
|
@@ -799,7 +836,9 @@ export function buildManifest(input) {
|
|
|
799
836
|
roles: input.roles.map((candidate) => ({
|
|
800
837
|
name: candidate.name,
|
|
801
838
|
description: candidate.description,
|
|
802
|
-
builtIn: candidate.name === MEMBER_ROLE ||
|
|
839
|
+
builtIn: candidate.name === MEMBER_ROLE ||
|
|
840
|
+
candidate.name === FEEDBACK_REPORTER_ROLE ||
|
|
841
|
+
(candidate.name === GUEST_ROLE && input.signIn.guest !== undefined),
|
|
803
842
|
permissions: [...candidate.permissions],
|
|
804
843
|
...((candidate.scopes ?? []).length > 0
|
|
805
844
|
? {
|
|
@@ -832,6 +871,14 @@ export function buildManifest(input) {
|
|
|
832
871
|
},
|
|
833
872
|
}),
|
|
834
873
|
...(input.signIn.onSignUp === undefined ? {} : { onSignUp: input.signIn.onSignUp }),
|
|
874
|
+
...(input.signIn.guest === undefined
|
|
875
|
+
? {}
|
|
876
|
+
: {
|
|
877
|
+
guest: {
|
|
878
|
+
channels: [...input.signIn.guest.channels],
|
|
879
|
+
origins: [...input.signIn.guest.origins],
|
|
880
|
+
},
|
|
881
|
+
}),
|
|
835
882
|
},
|
|
836
883
|
...(Object.keys(emails).length > 0 ? { emails } : {}),
|
|
837
884
|
...(input.chat === undefined ? {} : { chat: input.chat }),
|
package/dist/migrate/apply.d.ts
CHANGED
|
@@ -47,6 +47,12 @@ export type ApplyMigrationError = MigrationRefused | CatalogMismatch | CatalogIn
|
|
|
47
47
|
* decoded with the manifest contract, so fields this SDK does not know are dropped.
|
|
48
48
|
*/
|
|
49
49
|
export declare const readCatalog: (input: CatalogInput) => Effect.Effect<OntologyManifest | undefined, CatalogInvalid | SqlError>;
|
|
50
|
+
/**
|
|
51
|
+
* The hash recorded by the last applied migration, or undefined when none was applied. A migration
|
|
52
|
+
* writes it in the statement that writes the manifest it names, so this reads the hash alone, not
|
|
53
|
+
* the manifest that `readCatalog` reads and checks, which is megabytes for a large ontology.
|
|
54
|
+
*/
|
|
55
|
+
export declare const readCatalogHash: (input: CatalogInput) => Effect.Effect<string | undefined, CatalogInvalid | SqlError>;
|
|
50
56
|
/**
|
|
51
57
|
* The storage the catalog records as kept: what removals retained, which declaring the entity or
|
|
52
58
|
* @legacy ontology.pre-upgrade-database-tolerance
|
package/dist/migrate/apply.js
CHANGED
|
@@ -19,7 +19,7 @@ import { principalsOntology, reconcileWorkflowUsers } from "../runtime/principal
|
|
|
19
19
|
import { FEDERATION_TABLES } from "../runtime/federation-tables.js";
|
|
20
20
|
import { syncUserIdentities, USER_IDENTITY_ENTITY_ID } from "../runtime/user-identities.js";
|
|
21
21
|
import { resolveReplicationSelection, } from "../replication/model.js";
|
|
22
|
-
import { ACTION_ATTRIBUTION_TABLE, AGENT_TABLES, API_KEYS_TABLE, CATALOG_TABLE, CHANNEL_USERS_TABLE, OAUTH_TABLES, USER_ROLES_TABLE, quoteIdentifier, quoteLiteral, historyTableName, } from "./storage.js";
|
|
22
|
+
import { ACTION_ATTRIBUTION_TABLE, AGENT_TABLES, API_KEYS_TABLE, CATALOG_TABLE, CHANNEL_USERS_TABLE, OAUTH_GRANTS_GUEST_CHECK, OAUTH_TABLES, USER_ROLES_TABLE, quoteIdentifier, quoteLiteral, historyTableName, } from "./storage.js";
|
|
23
23
|
const CATALOG = quoteIdentifier(CATALOG_TABLE);
|
|
24
24
|
const IDENTITY_SYNC = "Copy members' sign-in identities the legacy identity stores hold.";
|
|
25
25
|
/**
|
|
@@ -36,13 +36,12 @@ const DEFAULT_STATEMENT_TIMEOUT = "5 minutes";
|
|
|
36
36
|
const DEFAULT_LOCK_TIMEOUT = "5 seconds";
|
|
37
37
|
const Presence = Schema.Struct({ present: Schema.Boolean });
|
|
38
38
|
const CatalogRow = Schema.Struct({ hash: Schema.String, manifest: Schema.String });
|
|
39
|
+
const CatalogHashRow = Schema.Struct({ hash: Schema.String });
|
|
39
40
|
const RetainedRow = Schema.Struct({ retained: Schema.NullOr(Schema.String) });
|
|
40
41
|
const decodeManifest = decodeManifestDocument;
|
|
42
|
+
const catalogPresent = (sql) => sql.unsafe(`SELECT to_regclass($1) IS NOT NULL AS present`, [CATALOG]).pipe(Effect.flatMap(Schema.decodeUnknownEffect(Schema.Array(Presence))), Effect.map((presence) => presence[0]?.present === true));
|
|
41
43
|
const readCatalogRow = (sql, options) => Effect.gen(function* () {
|
|
42
|
-
|
|
43
|
-
.unsafe(`SELECT to_regclass($1) IS NOT NULL AS present`, [CATALOG])
|
|
44
|
-
.pipe(Effect.flatMap(Schema.decodeUnknownEffect(Schema.Array(Presence))));
|
|
45
|
-
if (presence[0]?.present !== true) {
|
|
44
|
+
if (!(yield* catalogPresent(sql))) {
|
|
46
45
|
return undefined;
|
|
47
46
|
}
|
|
48
47
|
const lock = options.forUpdate ? "FOR UPDATE" : "";
|
|
@@ -82,6 +81,20 @@ export const readCatalog = (input) => Effect.gen(function* () {
|
|
|
82
81
|
}
|
|
83
82
|
return manifest;
|
|
84
83
|
}).pipe(Effect.withSpan("ontology.migrate.readCatalog"));
|
|
84
|
+
/**
|
|
85
|
+
* The hash recorded by the last applied migration, or undefined when none was applied. A migration
|
|
86
|
+
* writes it in the statement that writes the manifest it names, so this reads the hash alone, not
|
|
87
|
+
* the manifest that `readCatalog` reads and checks, which is megabytes for a large ontology.
|
|
88
|
+
*/
|
|
89
|
+
export const readCatalogHash = (input) => Effect.gen(function* () {
|
|
90
|
+
if (!(yield* catalogPresent(input.sql))) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
const rows = yield* input.sql
|
|
94
|
+
.unsafe(`SELECT "hash" FROM ${CATALOG} WHERE "id"`)
|
|
95
|
+
.pipe(Effect.flatMap(Schema.decodeUnknownEffect(Schema.Array(CatalogHashRow))));
|
|
96
|
+
return rows[0]?.hash;
|
|
97
|
+
}).pipe(Effect.catchTag("SchemaError", (cause) => Effect.fail(new CatalogInvalid({ message: "The _ontology catalog has an unexpected shape.", cause }))), Effect.withSpan("ontology.migrate.readCatalogHash"));
|
|
85
98
|
/**
|
|
86
99
|
* The storage the catalog records as kept: what removals retained, which declaring the entity or
|
|
87
100
|
* @legacy ontology.pre-upgrade-database-tolerance
|
|
@@ -489,6 +502,13 @@ export const readRuntimeTables = (input) => input.sql
|
|
|
489
502
|
`AND ("tablename" <> '_oauth_grants' OR EXISTS (` +
|
|
490
503
|
`SELECT 1 FROM information_schema.columns WHERE table_schema = current_schema() ` +
|
|
491
504
|
`AND table_name = '_oauth_grants' AND column_name = 'identity_id')) ` +
|
|
505
|
+
// Without the guests' check the OAuth DDL runs again and lets guests' grants name no user.
|
|
506
|
+
`AND ("tablename" <> '_oauth_grants' OR EXISTS (` +
|
|
507
|
+
`SELECT 1 FROM pg_catalog.pg_constraint c ` +
|
|
508
|
+
`JOIN pg_catalog.pg_class t ON t.oid = c.conrelid ` +
|
|
509
|
+
`JOIN pg_catalog.pg_namespace n ON n.oid = t.relnamespace ` +
|
|
510
|
+
`WHERE n.nspname = current_schema() AND t.relname = '_oauth_grants' ` +
|
|
511
|
+
`AND c.conname = ${quoteLiteral(OAUTH_GRANTS_GUEST_CHECK)})) ` +
|
|
492
512
|
// Without `signed_up` the agent tables' idempotent DDL runs again and adds it.
|
|
493
513
|
`AND ("tablename" <> ${quoteLiteral(CHANNEL_USERS_TABLE)} OR EXISTS (` +
|
|
494
514
|
`SELECT 1 FROM information_schema.columns WHERE table_schema = current_schema() ` +
|
package/dist/migrate/model.d.ts
CHANGED
|
@@ -481,6 +481,10 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
481
481
|
} | undefined;
|
|
482
482
|
readonly signIn?: {
|
|
483
483
|
readonly policy: string;
|
|
484
|
+
readonly guest?: {
|
|
485
|
+
readonly channels: readonly string[];
|
|
486
|
+
readonly origins: readonly string[];
|
|
487
|
+
} | undefined;
|
|
484
488
|
readonly browser?: {
|
|
485
489
|
readonly methods: readonly string[];
|
|
486
490
|
readonly primary: string;
|
|
@@ -753,6 +757,10 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
753
757
|
} | undefined;
|
|
754
758
|
readonly signIn?: {
|
|
755
759
|
readonly policy: string;
|
|
760
|
+
readonly guest?: {
|
|
761
|
+
readonly channels: readonly string[];
|
|
762
|
+
readonly origins: readonly string[];
|
|
763
|
+
} | undefined;
|
|
756
764
|
readonly browser?: {
|
|
757
765
|
readonly methods: readonly string[];
|
|
758
766
|
readonly primary: string;
|
|
@@ -1076,6 +1084,10 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1076
1084
|
}[] | undefined;
|
|
1077
1085
|
readonly sign_in?: {
|
|
1078
1086
|
readonly policy: string;
|
|
1087
|
+
readonly guest?: {
|
|
1088
|
+
readonly channels: readonly string[];
|
|
1089
|
+
readonly origins: readonly string[];
|
|
1090
|
+
} | undefined;
|
|
1079
1091
|
readonly browser?: {
|
|
1080
1092
|
readonly methods: readonly string[];
|
|
1081
1093
|
readonly primary: string;
|
|
@@ -1297,6 +1309,10 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1297
1309
|
} | undefined;
|
|
1298
1310
|
readonly signIn?: {
|
|
1299
1311
|
readonly policy: string;
|
|
1312
|
+
readonly guest?: {
|
|
1313
|
+
readonly channels: readonly string[];
|
|
1314
|
+
readonly origins: readonly string[];
|
|
1315
|
+
} | undefined;
|
|
1300
1316
|
readonly browser?: {
|
|
1301
1317
|
readonly methods: readonly string[];
|
|
1302
1318
|
readonly primary: string;
|
|
@@ -1526,6 +1542,10 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1526
1542
|
readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
1527
1543
|
}>>;
|
|
1528
1544
|
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
1545
|
+
readonly guest: Schema.optionalKey<Schema.Struct<{
|
|
1546
|
+
readonly channels: Schema.$Array<Schema.String>;
|
|
1547
|
+
readonly origins: Schema.$Array<Schema.String>;
|
|
1548
|
+
}>>;
|
|
1529
1549
|
}>, {
|
|
1530
1550
|
readonly onNewUser: "on_new_user";
|
|
1531
1551
|
readonly codeLink: "code_link";
|
|
@@ -1789,6 +1809,10 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1789
1809
|
readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
1790
1810
|
}>>;
|
|
1791
1811
|
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
1812
|
+
readonly guest: Schema.optionalKey<Schema.Struct<{
|
|
1813
|
+
readonly channels: Schema.$Array<Schema.String>;
|
|
1814
|
+
readonly origins: Schema.$Array<Schema.String>;
|
|
1815
|
+
}>>;
|
|
1792
1816
|
}>, {
|
|
1793
1817
|
readonly onNewUser: "on_new_user";
|
|
1794
1818
|
readonly codeLink: "code_link";
|
|
@@ -2108,6 +2132,10 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2108
2132
|
} | undefined;
|
|
2109
2133
|
readonly signIn?: {
|
|
2110
2134
|
readonly policy: string;
|
|
2135
|
+
readonly guest?: {
|
|
2136
|
+
readonly channels: readonly string[];
|
|
2137
|
+
readonly origins: readonly string[];
|
|
2138
|
+
} | undefined;
|
|
2111
2139
|
readonly browser?: {
|
|
2112
2140
|
readonly methods: readonly string[];
|
|
2113
2141
|
readonly primary: string;
|
|
@@ -2380,6 +2408,10 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2380
2408
|
} | undefined;
|
|
2381
2409
|
readonly signIn?: {
|
|
2382
2410
|
readonly policy: string;
|
|
2411
|
+
readonly guest?: {
|
|
2412
|
+
readonly channels: readonly string[];
|
|
2413
|
+
readonly origins: readonly string[];
|
|
2414
|
+
} | undefined;
|
|
2383
2415
|
readonly browser?: {
|
|
2384
2416
|
readonly methods: readonly string[];
|
|
2385
2417
|
readonly primary: string;
|
|
@@ -172,6 +172,8 @@ export declare const OAUTH_REQUESTS_TABLE = "_oauth_requests";
|
|
|
172
172
|
export declare const OAUTH_GRANTS_TABLE = "_oauth_grants";
|
|
173
173
|
/** Authorization codes, access tokens and refresh tokens, stored only as SHA-256 hashes. */
|
|
174
174
|
export declare const OAUTH_TOKENS_TABLE = "_oauth_tokens";
|
|
175
|
+
/** The check that only the agent's client (`agent-web`) holds grants without a user: guests'. */
|
|
176
|
+
export declare const OAUTH_GRANTS_GUEST_CHECK = "_oauth_grants_guest_check";
|
|
175
177
|
/** The OAuth tables, in the order they are created. */
|
|
176
178
|
export declare const OAUTH_TABLES: ReadonlyArray<string>;
|
|
177
179
|
/** The OAuth tables of the MCP server's authorization server. Every statement is idempotent. */
|
package/dist/migrate/storage.js
CHANGED
|
@@ -484,6 +484,8 @@ export const OAUTH_REQUESTS_TABLE = "_oauth_requests";
|
|
|
484
484
|
export const OAUTH_GRANTS_TABLE = "_oauth_grants";
|
|
485
485
|
/** Authorization codes, access tokens and refresh tokens, stored only as SHA-256 hashes. */
|
|
486
486
|
export const OAUTH_TOKENS_TABLE = "_oauth_tokens";
|
|
487
|
+
/** The check that only the agent's client (`agent-web`) holds grants without a user: guests'. */
|
|
488
|
+
export const OAUTH_GRANTS_GUEST_CHECK = `${OAUTH_GRANTS_TABLE}_guest_check`;
|
|
487
489
|
/** The OAuth tables, in the order they are created. */
|
|
488
490
|
export const OAUTH_TABLES = [
|
|
489
491
|
OAUTH_CLIENTS_TABLE,
|
|
@@ -559,6 +561,12 @@ export const OAUTH_TABLES_DDL = [
|
|
|
559
561
|
`CREATE INDEX IF NOT EXISTS "${OAUTH_TOKENS_TABLE}_grant_id_idx" ` +
|
|
560
562
|
`ON ${quoteIdentifier(OAUTH_TOKENS_TABLE)} ("grant_id")`,
|
|
561
563
|
`ALTER TABLE "${OAUTH_GRANTS_TABLE}" ADD COLUMN IF NOT EXISTS "identity_id" uuid`,
|
|
564
|
+
// A guest's grant to the agent names no user: a guest is a session, not a user. Only the agent's
|
|
565
|
+
// first-party client holds such grants.
|
|
566
|
+
`ALTER TABLE "${OAUTH_GRANTS_TABLE}" ALTER COLUMN "user_id" DROP NOT NULL`,
|
|
567
|
+
`ALTER TABLE "${OAUTH_GRANTS_TABLE}" DROP CONSTRAINT IF EXISTS "${OAUTH_GRANTS_GUEST_CHECK}", ` +
|
|
568
|
+
`ADD CONSTRAINT "${OAUTH_GRANTS_GUEST_CHECK}" ` +
|
|
569
|
+
`CHECK ("user_id" IS NOT NULL OR "client_id" = 'agent-web')`,
|
|
562
570
|
`ALTER TABLE "_oauth_tokens" ADD COLUMN IF NOT EXISTS "replay" text`,
|
|
563
571
|
`ALTER TABLE "_oauth_tokens" ADD COLUMN IF NOT EXISTS "successor_hash" text`,
|
|
564
572
|
`CREATE TABLE IF NOT EXISTS "_oauth_devices" (
|
package/dist/names.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ export declare const GENERATED_UPSERT_PREFIX = "upsert_by_";
|
|
|
18
18
|
export declare const MEMBER_ROLE = "member";
|
|
19
19
|
/** Implicit human feedback authority; never a stored or assignable role. */
|
|
20
20
|
export declare const FEEDBACK_REPORTER_ROLE = "feedback_reporter";
|
|
21
|
+
/**
|
|
22
|
+
* The built-in role every guest holds, and only guests: `defineOntology({ guest })` gives it its
|
|
23
|
+
* permissions. Reserved once the ontology declares `guest`; never a stored or assignable role.
|
|
24
|
+
*/
|
|
25
|
+
export declare const GUEST_ROLE = "guest";
|
|
21
26
|
/** Suffix reserved for the history table each entity gets. */
|
|
22
27
|
export declare const HISTORY_SUFFIX = "_history";
|
|
23
28
|
/** The combinators of the query language, which take the place of field names in a `where`. */
|
package/dist/names.js
CHANGED
|
@@ -50,6 +50,11 @@ export const GENERATED_UPSERT_PREFIX = "upsert_by_";
|
|
|
50
50
|
export const MEMBER_ROLE = "member";
|
|
51
51
|
/** Implicit human feedback authority; never a stored or assignable role. */
|
|
52
52
|
export const FEEDBACK_REPORTER_ROLE = "feedback_reporter";
|
|
53
|
+
/**
|
|
54
|
+
* The built-in role every guest holds, and only guests: `defineOntology({ guest })` gives it its
|
|
55
|
+
* permissions. Reserved once the ontology declares `guest`; never a stored or assignable role.
|
|
56
|
+
*/
|
|
57
|
+
export const GUEST_ROLE = "guest";
|
|
53
58
|
/** Suffix reserved for the history table each entity gets. */
|
|
54
59
|
export const HISTORY_SUFFIX = "_history";
|
|
55
60
|
/** The combinators of the query language, which take the place of field names in a `where`. */
|
package/dist/ontology.d.ts
CHANGED
|
@@ -12,7 +12,10 @@ export interface Ontology<Entities extends ReadonlyArray<AnyEntity> = ReadonlyAr
|
|
|
12
12
|
readonly config: OntologyConfig<Entities, Metrics>;
|
|
13
13
|
/** The built-in `User` first, then the declared entities in order. */
|
|
14
14
|
readonly entities: ReadonlyArray<ResolvedEntity>;
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* The workspace-owned `member` role first, declared roles, then the implicit reporter when
|
|
17
|
+
* enabled, then `guest` when the definition declares guests.
|
|
18
|
+
*/
|
|
16
19
|
readonly roles: ReadonlyArray<Role>;
|
|
17
20
|
/** Who may become a member by signing in, with the default policy when the definition sets none. */
|
|
18
21
|
readonly signIn: ResolvedSignInOptions;
|