@segmentstream/ontology 0.101.0 → 0.104.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 +44 -0
- package/README.md +25 -18
- package/dist/analyze.js +34 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/manifest.d.ts +25 -1
- package/dist/manifest.js +28 -2
- package/dist/migrate/model.d.ts +8 -0
- package/dist/runtime/agent-web.d.ts +9 -2
- package/dist/runtime/agent-web.js +121 -3
- package/dist/runtime/agents.js +4 -1
- package/dist/service/agent/server.d.ts +4 -0
- package/dist/service/agent/server.js +9 -2
- package/dist/service/agent/web-tokens.d.ts +19 -3
- package/dist/service/agent/web-tokens.js +94 -2
- package/dist/service/runtime-contract.d.ts +35 -0
- package/dist/service/schemas.d.ts +2 -0
- package/dist/service/service.js +18 -5
- package/dist/sign-in.d.ts +18 -3
- package/dist/sign-in.js +23 -3
- package/dist/storage/tables.d.ts +1 -1
- package/dist/storage/tables.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.104.0
|
|
4
|
+
|
|
5
|
+
The agent answers a website's visitors. `signUp` takes the channel `web` with `origins`, the
|
|
6
|
+
websites by exact origin: a browser on one of them signs its visitor up at
|
|
7
|
+
`POST /api/ontology/agent/visitors`, which creates a user holding the roles `signUp` gives `web`
|
|
8
|
+
and answers an agent token with a refresh token. The refresh token renews the agent token at the
|
|
9
|
+
ontology's OAuth token endpoint as client `agent-web`, which the service serves for visitors even
|
|
10
|
+
with `mcp: false`. A visitor's `onSignUp` that fails runs again before their next turn, as it does
|
|
11
|
+
on a messenger, and so does that of anyone sign-up created who talks to the agent from the app. Any other origin is refused with
|
|
12
|
+
`origin_not_allowed`; one network address may start 10 visitors an hour, and the workspace's cap on
|
|
13
|
+
new users and the agent's turn limits apply as to everyone `signUp` created. `check` refuses `web`
|
|
14
|
+
without origins, and an origin with a path, a wildcard, or `http` beyond `localhost`.
|
|
15
|
+
|
|
16
|
+
The agent's web channel answers browsers on any origin, since every request carries an agent token
|
|
17
|
+
as its bearer, never a cookie.
|
|
18
|
+
|
|
19
|
+
`useAgent({ app })` in `@segmentstream/app/agent` talks to the agent of the workspace app at `app`
|
|
20
|
+
from another website, as its visitor: it signs them up with their first message and keeps their
|
|
21
|
+
refresh token in the browser, so they stay the same user. `visitorToken(app)` gets the token
|
|
22
|
+
outside React and `forgetVisitorTokens()` starts over as a new visitor.
|
|
23
|
+
|
|
24
|
+
## 0.103.0
|
|
25
|
+
|
|
26
|
+
The agent's temporary attachments accept `whatsapp` as a source, so files members send the agent
|
|
27
|
+
in WhatsApp are stored as Telegram's and Slack's are. The next `segmentstream-ontology migrate`
|
|
28
|
+
(every deploy runs it) widens the attachment table's source check; no data changes.
|
|
29
|
+
|
|
30
|
+
## 0.102.0
|
|
31
|
+
|
|
32
|
+
The agent's limits for people who signed up now apply to the web. Each message a member sends from
|
|
33
|
+
the browser starts a turn that the ontology counts against `limits` when `signUp` created them, by
|
|
34
|
+
email too, on the same counters as their turns on a messenger. Invited and paired members are never
|
|
35
|
+
counted. A turn beyond the limits is refused before it reaches the model with `429 rate_limited` and
|
|
36
|
+
`Retry-After`, and `useAgent()` reports it, like every refusal of the agent's routes, as a
|
|
37
|
+
`SegmentStreamApiError` with its code. The counts use the `limits` the agent last sent with a
|
|
38
|
+
messenger's turn, or the platform's defaults.
|
|
39
|
+
|
|
40
|
+
The agent token introspection (`POST /api/ontology/agent/tokens/introspect`) accepts `turn: true`
|
|
41
|
+
and then answers `limited: { scope, retry_after_seconds }` for a turn beyond the limits.
|
|
42
|
+
|
|
43
|
+
Action required: upgrade the ontology SDK together with the agent SDK. With an ontology SDK released
|
|
44
|
+
before this one, the agent asks again without the turn and web turns stay uncounted until
|
|
45
|
+
2027-02-15; after that date they fail.
|
|
46
|
+
|
|
3
47
|
## 0.101.0
|
|
4
48
|
|
|
5
49
|
A member signed in to the app can reach the app's agent from the browser with an agent token: an
|
package/README.md
CHANGED
|
@@ -11,6 +11,9 @@ database and the HTTP service under `/api/ontology`. Every read and every action
|
|
|
11
11
|
a permission that the caller's roles grant, and every change to a record goes through an
|
|
12
12
|
action and is kept in history.
|
|
13
13
|
|
|
14
|
+
Guides named by path below, such as `docs/ontology.md`, are in every workspace project;
|
|
15
|
+
`segmentstream sync` keeps them current.
|
|
16
|
+
|
|
14
17
|
TypeScript definitions, handler records and SDK calls use camelCase: `jobTitle`,
|
|
15
18
|
`assignedOwnerId`, `createdAt`, and `changeStatus`. The SDK converts ontology names,
|
|
16
19
|
select identifiers and declared action input fields to snake_case for the generated
|
|
@@ -118,7 +121,7 @@ every aggregate, so that a metric reads only the rows its conditions accept (`m.
|
|
|
118
121
|
it or filter it to one day. Aggregate requests
|
|
119
122
|
take the `notEquals`, `notIn`, `gt`, `gte`, `lt`, `lte`, `contains`, `startsWith`, `endsWith` and
|
|
120
123
|
`inPeriod` operators, the `hour`, `quarter` and `year` granularities and a `timezone`. See
|
|
121
|
-
|
|
124
|
+
ontology metrics (`docs/ontology-metrics.md`).
|
|
122
125
|
|
|
123
126
|
SDK 0.14.0 lets the app's own agent call the service as a paired member (see
|
|
124
127
|
[Agents](#agents)). Its migration adds the agent's runtime tables.
|
|
@@ -132,7 +135,7 @@ fields and business relationships. Existing history captures immutable snapshots
|
|
|
132
135
|
service wakes the publisher after commits. Upgrade and redeploy to activate it; workspace
|
|
133
136
|
configuration can intentionally exclude exported data. Automatic repairs build a private replacement
|
|
134
137
|
while the serving analytical projection keeps receiving changes and answering queries. See
|
|
135
|
-
|
|
138
|
+
replication lifecycle (`docs/ontology-replication.md`).
|
|
136
139
|
The next release supports schema changes during active copies: property renames adapt views over retained
|
|
137
140
|
JSON, and restored or newly included data is exported through scoped resumable scans. No manual pause
|
|
138
141
|
is required for deployment or recovery. Explicit opt-outs and supported-writer fences remain in force.
|
|
@@ -141,7 +144,7 @@ SDK 0.13.0 writes manifest version 6. Relationships may target warehouse-backed
|
|
|
141
144
|
stored or warehouse-backed entities, matched by value through `on`, and `unique` is allowed on
|
|
142
145
|
warehouse-backed properties as an unenforced assertion. Upgrading: 0.12 accepted an explicit `onDelete`, or `optional: true`, on a
|
|
143
146
|
warehouse → stored relationship; 0.13.0 `check` refuses both, so remove them. See
|
|
144
|
-
|
|
147
|
+
ontology metrics (`docs/ontology-metrics.md#relationships`).
|
|
145
148
|
|
|
146
149
|
SDK 0.13.0 also serves aggregates. Upgrade notes:
|
|
147
150
|
|
|
@@ -161,8 +164,7 @@ SDK 0.13.0 also serves aggregates. Upgrade notes:
|
|
|
161
164
|
warehouse-backed entities through aggregates. Grant those to `member` by name
|
|
162
165
|
(`acme_sales:read`), or keep the `invited` policy.
|
|
163
166
|
|
|
164
|
-
See
|
|
165
|
-
and [ontology analytics](https://github.com/segmentstream/segmentstream/blob/main/docs/ontology-aggregates-spec.md).
|
|
167
|
+
See `docs/ontology-metrics.md`.
|
|
166
168
|
|
|
167
169
|
## File storage
|
|
168
170
|
|
|
@@ -227,7 +229,7 @@ allow more types, then check, migrate and redeploy the ontology. The app SDK sto
|
|
|
227
229
|
0.13.1 or later uses `application/octet-stream` when the browser supplies no MIME type.
|
|
228
230
|
REST callers should supply that type themselves for unknown formats.
|
|
229
231
|
|
|
230
|
-
See
|
|
232
|
+
See `docs/ontology.md#file-transfers`
|
|
231
233
|
for upload tickets, transfer grants and retained revisions.
|
|
232
234
|
|
|
233
235
|
SDK 0.56.0 adds server-side file transfers through `Files`. In an action, declare
|
|
@@ -238,7 +240,7 @@ authorized retained revision for sending to another provider. Use `files: []` wh
|
|
|
238
240
|
preparation only reads files and has no connections. Callers of staging actions provide
|
|
239
241
|
an idempotency key; workflow action calls derive a stable key from the run, step and input
|
|
240
242
|
when omitted. Streams stay within the step; carry tickets and references between steps.
|
|
241
|
-
See
|
|
243
|
+
See `docs/ontology.md#file-transfers`
|
|
242
244
|
for the API and recovery rules.
|
|
243
245
|
|
|
244
246
|
Buffered `get`/`post`/`request` calls receive the provider's response through a streamed
|
|
@@ -263,7 +265,7 @@ commit. They are never replayed. This declaration is independent of
|
|
|
263
265
|
timeouts, cancellation, permission failures, cleanup failures or uncertain commits.
|
|
264
266
|
Custom service runtime implementations own their retry policy; wrappers around
|
|
265
267
|
the default backend are not replayed. See
|
|
266
|
-
|
|
268
|
+
action deadlines and load (`docs/ontology.md#action-deadlines-and-load`)
|
|
267
269
|
for the full replay contract.
|
|
268
270
|
|
|
269
271
|
An action with `hints: { connectionsReadOnly: true, destructive: false }` may read
|
|
@@ -408,9 +410,14 @@ export default defineOntology({
|
|
|
408
410
|
affected member has linked email before restoring an email-only deployment. `User.sendSignInLink`
|
|
409
411
|
preserves Neon links in compatibility and dual mode; sole SegmentStream uses interactive central
|
|
410
412
|
sign-in, preserving templates, reply routing and the requested landing path.
|
|
411
|
-
- `signUp: { channels, roles, byChannel? }` opens sign-up to strangers on each listed
|
|
412
|
-
`email` (signing in to the app by email code), `telegram` (a first private message to
|
|
413
|
-
or opening the Mini App)
|
|
413
|
+
- `signUp: { channels, roles, byChannel?, origins? }` opens sign-up to strangers on each listed
|
|
414
|
+
channel: `email` (signing in to the app by email code), `telegram` (a first private message to
|
|
415
|
+
the bot, or opening the Mini App), `whatsapp` (a first message to the number) and `web` (a
|
|
416
|
+
visitor of a website `origins` lists, by exact origin, who writes to the agent there; `http` only
|
|
417
|
+
for `localhost` and `127.0.0.1`). `web` signs a visitor up at
|
|
418
|
+
`POST /api/ontology/agent/visitors`, which answers only browsers on those origins, at most 10 new
|
|
419
|
+
visitors per network address an hour, with an agent token and a refresh token that renews it at
|
|
420
|
+
the OAuth token endpoint as client `agent-web`. The new user holds
|
|
414
421
|
exactly `roles`, declared roles passed as role objects or names, or the channel's own list in
|
|
415
422
|
`byChannel`; `[]` grants nothing beyond what is later granted or shared. Sign-up writes them as
|
|
416
423
|
ordinary role assignments in its own transaction, so one person's roles can be revoked or added
|
|
@@ -427,9 +434,9 @@ export default defineOntology({
|
|
|
427
434
|
commits: before the first agent turn or Mini App session, and before an email user's first
|
|
428
435
|
request. Every channel's roles must be able to run it, it cannot grant roles, and a failure
|
|
429
436
|
leaves it pending for the next contact. Promote a person with an ordinary action that calls
|
|
430
|
-
`User.grantRoles`. The manifest carries `sign_in.sign_up` (each channel's role wire names
|
|
431
|
-
`sign_in.on_sign_up` only when declared; `signUpRolesOf(manifest, channel)`
|
|
432
|
-
|
|
437
|
+
`User.grantRoles`. The manifest carries `sign_in.sign_up` (each channel's role wire names, and `origins` with
|
|
438
|
+
`web`) and `sign_in.on_sign_up` only when declared; `signUpRolesOf(manifest, channel)` and
|
|
439
|
+
`signUpOriginsOf(manifest)` read them and keep unknown or malformed channels closed.
|
|
433
440
|
- `signIn: { policy }` decides who may become a member by signing in. `invited`, the
|
|
434
441
|
default, admits only people whose email a member already has, from an invitation or a
|
|
435
442
|
role grant; anyone else is answered 403 `not_invited`. `open` makes anyone who signs in a
|
|
@@ -905,7 +912,7 @@ selects. Metric queries lock nothing: lock the record the decision depends on wi
|
|
|
905
912
|
`forUpdate`. Balance
|
|
906
913
|
metrics, model metrics and workflow steps stay with the warehouse's `query_metrics`.
|
|
907
914
|
`aggregate`, the earlier name of `queryMetrics`, remains as a deprecated alias.
|
|
908
|
-
See
|
|
915
|
+
See fresh metric queries inside an action (`docs/ontology.md#fresh-metric-queries-inside-an-action`).
|
|
909
916
|
|
|
910
917
|
## Permissions
|
|
911
918
|
|
|
@@ -1258,7 +1265,7 @@ API from the ontology's MCP server: each tool in the lock, written by
|
|
|
1258
1265
|
confirmed. Fixed values the connection declares are removed from the tool's input and added to each
|
|
1259
1266
|
call, and backend-next admits only the declared tools and values. A toolset has no records. It is
|
|
1260
1267
|
served over MCP only: not by the REST API, to workflows or under the OAuth `ontology:read` scope.
|
|
1261
|
-
See
|
|
1268
|
+
See `docs/ontology.md#provider-mcp-tools-toolsets` and `docs/connections.md#declare-an-mcp-server`.
|
|
1262
1269
|
|
|
1263
1270
|
## Agents
|
|
1264
1271
|
|
|
@@ -1728,9 +1735,9 @@ Apache-2.0
|
|
|
1728
1735
|
|
|
1729
1736
|
## Entity sources and metric queries
|
|
1730
1737
|
|
|
1731
|
-
Entities with a warehouse source declare mapped properties, metrics and relationships without ontology storage tables or actions. `find`, `query` and `get` read observations through the workspace's warehouse API, with opaque source-key record IDs and bounded, permission-checked relationship reads. See
|
|
1738
|
+
Entities with a warehouse source declare mapped properties, metrics and relationships without ontology storage tables or actions. `find`, `query` and `get` read observations through the workspace's warehouse API, with opaque source-key record IDs and bounded, permission-checked relationship reads. See warehouse record reads (`docs/ontology-record-reads.md`). Stored entities may declare metrics too; they are computed over the entity's replication view, whose columns are the properties' snake_case names. See ontology metrics (`docs/ontology-metrics.md`) for declaration rules, metric query paths, source verification and workspace authorization.
|
|
1732
1739
|
|
|
1733
|
-
See
|
|
1740
|
+
See release order and rollback (`docs/agent-chat-delivery-migration.md`).
|
|
1734
1741
|
|
|
1735
1742
|
### Telegram link previews
|
|
1736
1743
|
|
package/dist/analyze.js
CHANGED
|
@@ -11,7 +11,7 @@ import { REFERENCE_ANNOTATION, propertyDefinition, propertyOptionNames, unknownP
|
|
|
11
11
|
import { EXPLICIT_GRANT_ENTITIES, generatedActionPermissions, grants, isAllowed, normalizePermission, parsePermission, parseWorkflowPermission, permissionOf, READ_VERB, rolesGranting, USER_IDENTITY_VERBS, USER_MEMBER_VERBS, WILDCARD, wildcardEntityCovers, WORKSPACE_SOURCE, WORKSPACE_SOURCE_PERMISSION, } from "./permissions.js";
|
|
12
12
|
import { ON_DELETE, isRelationship } from "./relationship.js";
|
|
13
13
|
import { isRole, member, role } from "./role.js";
|
|
14
|
-
import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_UP_CHANNELS, SIGN_UP_CHAT_CHANNELS, isSignInPolicy, isSignUpChannel, } from "./sign-in.js";
|
|
14
|
+
import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_UP_CHANNELS, SIGN_UP_CHAT_CHANNELS, isSignInPolicy, isSignUpChannel, signUpOrigin, } from "./sign-in.js";
|
|
15
15
|
import { emailOptions } from "./emails.js";
|
|
16
16
|
import { AgentChat } from "./agent-chat.js";
|
|
17
17
|
import { AgentReview } from "./agent-review.js";
|
|
@@ -1288,11 +1288,11 @@ function signUpOptions(config, signIn, declaredRoles, report) {
|
|
|
1288
1288
|
return result;
|
|
1289
1289
|
}
|
|
1290
1290
|
if (!isPlainObject(options)) {
|
|
1291
|
-
report("invalid-sign-in", "signUp", 'signUp takes { channels: ["telegram", "whatsapp", "email"], roles: [...] }.');
|
|
1291
|
+
report("invalid-sign-in", "signUp", 'signUp takes { channels: ["telegram", "whatsapp", "email", "web"], roles: [...] }.');
|
|
1292
1292
|
return result;
|
|
1293
1293
|
}
|
|
1294
1294
|
for (const key of Object.keys(options)) {
|
|
1295
|
-
if (!["channels", "roles", "byChannel"].includes(key)) {
|
|
1295
|
+
if (!["channels", "roles", "byChannel", "origins"].includes(key)) {
|
|
1296
1296
|
report("invalid-sign-in", `signUp.${key}`, `Unknown signUp key: ${key}.`);
|
|
1297
1297
|
}
|
|
1298
1298
|
}
|
|
@@ -1376,9 +1376,40 @@ function signUpOptions(config, signIn, declaredRoles, report) {
|
|
|
1376
1376
|
}
|
|
1377
1377
|
}
|
|
1378
1378
|
}
|
|
1379
|
+
const origins = [];
|
|
1380
|
+
if (options.origins !== undefined) {
|
|
1381
|
+
if (!channels.includes("web")) {
|
|
1382
|
+
report("invalid-sign-in", "signUp.origins", "origins are the websites of web; list web.");
|
|
1383
|
+
}
|
|
1384
|
+
else if (!Array.isArray(options.origins)) {
|
|
1385
|
+
report("invalid-sign-in", "signUp.origins", "List the websites' origins, such as https://www.example.com.");
|
|
1386
|
+
}
|
|
1387
|
+
else {
|
|
1388
|
+
options.origins.forEach((candidate, index) => {
|
|
1389
|
+
const origin = signUpOrigin(candidate);
|
|
1390
|
+
const path = `signUp.origins[${index}]`;
|
|
1391
|
+
if (origin === undefined) {
|
|
1392
|
+
report("invalid-sign-in", path, "Use an exact origin alone, such as https://www.example.com; http only for localhost.");
|
|
1393
|
+
}
|
|
1394
|
+
else if (origins.includes(origin)) {
|
|
1395
|
+
report("invalid-sign-in", path, `${origin} is listed twice.`);
|
|
1396
|
+
}
|
|
1397
|
+
else {
|
|
1398
|
+
origins.push(origin);
|
|
1399
|
+
}
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
if (channels.includes("web") &&
|
|
1404
|
+
origins.length === 0 &&
|
|
1405
|
+
(options.origins === undefined ||
|
|
1406
|
+
(Array.isArray(options.origins) && options.origins.length === 0))) {
|
|
1407
|
+
report("invalid-sign-in", "signUp.origins", "Signing up on web needs the websites' origins in signUp.origins.");
|
|
1408
|
+
}
|
|
1379
1409
|
if (channels.length > 0 && roles !== undefined) {
|
|
1380
1410
|
result.signUp = {
|
|
1381
1411
|
channels: Object.fromEntries(channels.map((channel) => [channel, byChannel[channel] ?? roles])),
|
|
1412
|
+
...(origins.length === 0 ? {} : { origins }),
|
|
1382
1413
|
};
|
|
1383
1414
|
}
|
|
1384
1415
|
return result;
|
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, 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, 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";
|
|
@@ -48,7 +48,7 @@ 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, } from "./sign-in.js";
|
|
51
|
+
export { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_IN_METHODS, SIGN_IN_POLICIES, SIGN_UP_CHANNELS, signUpOrigin, } from "./sign-in.js";
|
|
52
52
|
export type { ChannelProvider, 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";
|
|
@@ -86,9 +86,9 @@ 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, 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, 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
|
-
export { AGENT_PATH, AGENT_TOKEN_INTROSPECTION_PATH, AGENT_TOKENS_PATH, } from "./service/agent/server.js";
|
|
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";
|
|
93
93
|
export { WORKSPACE_SOURCE_PATH } from "./service/agent/source.js";
|
|
94
94
|
export { AGENT_WEB_CLIENT_ID, agentResource } from "./service/agent/web-tokens.js";
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ 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, 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, 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";
|
|
@@ -26,7 +26,7 @@ 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, } from "./sign-in.js";
|
|
29
|
+
export { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_IN_METHODS, SIGN_IN_POLICIES, SIGN_UP_CHANNELS, signUpOrigin, } from "./sign-in.js";
|
|
30
30
|
export { OntologyActions, OntologyReads, OntologyRuntime, OntologyWrites } from "./runtime.js";
|
|
31
31
|
export { User } from "./user.js";
|
|
32
32
|
export { AgentChat } from "./agent-chat.js";
|
|
@@ -54,7 +54,7 @@ export { IdentityInUse, NotInvited, OntologyBackend } from "./service/runtime-co
|
|
|
54
54
|
export { createOntologyService, ONTOLOGY_HASH_HEADER, REQUEST_ID_HEADER, } from "./service/service.js";
|
|
55
55
|
// The app's own agent: pairing channel accounts with members, and acting as them, or as a
|
|
56
56
|
// workflow's user in the tasks workflows hand it.
|
|
57
|
-
export { AGENT_PATH, AGENT_TOKEN_INTROSPECTION_PATH, AGENT_TOKENS_PATH, } from "./service/agent/server.js";
|
|
57
|
+
export { AGENT_PATH, AGENT_TOKEN_INTROSPECTION_PATH, AGENT_TOKENS_PATH, AGENT_VISITORS_PATH, } from "./service/agent/server.js";
|
|
58
58
|
export { AGENT_TASK_PATH, AGENT_TASK_RESULT_PATH } from "./service/agent/tasks.js";
|
|
59
59
|
export { WORKSPACE_SOURCE_PATH } from "./service/agent/source.js";
|
|
60
60
|
// Agent tokens: access tokens of a member's grant to the agent, which a browser shows the agent.
|
package/dist/manifest.d.ts
CHANGED
|
@@ -60,6 +60,9 @@ import { type ResolvedSignInOptions, type SignInPolicy } from "./sign-in.js";
|
|
|
60
60
|
* Within version 15, `signIn` may carry `signUp`, the wire names of the roles each channel open to
|
|
61
61
|
* sign-up grants, and `onSignUp`, written only when declared. Older readers ignore them and keep
|
|
62
62
|
* every channel closed to sign-up.
|
|
63
|
+
* Within version 15, `signUp` may carry `web` among its channels and `origins`, the websites whose
|
|
64
|
+
* visitors sign up on it, written only when declared. Older readers ignore both and keep `web`
|
|
65
|
+
* closed.
|
|
63
66
|
*/
|
|
64
67
|
export declare const MANIFEST_VERSION = 15;
|
|
65
68
|
/** The phrase used for a direction the author did not phrase. */
|
|
@@ -608,9 +611,13 @@ export declare const BrowserSignInManifest: Schema.encodeKeys<Schema.Struct<{
|
|
|
608
611
|
}>, {
|
|
609
612
|
readonly autoRedirect: "auto_redirect";
|
|
610
613
|
}>;
|
|
611
|
-
/**
|
|
614
|
+
/**
|
|
615
|
+
* Sign-up: the wire names of the roles each open channel grants, and the websites whose visitors
|
|
616
|
+
* may sign up on `web`. Unknown channels stay closed.
|
|
617
|
+
*/
|
|
612
618
|
export declare const SignUpManifest: Schema.Struct<{
|
|
613
619
|
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
620
|
+
readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
614
621
|
}>;
|
|
615
622
|
export declare const SignInManifest: Schema.encodeKeys<Schema.Struct<{
|
|
616
623
|
readonly browser: Schema.optionalKey<Schema.encodeKeys<Schema.Struct<{
|
|
@@ -629,6 +636,7 @@ export declare const SignInManifest: Schema.encodeKeys<Schema.Struct<{
|
|
|
629
636
|
readonly codeLink: Schema.optionalKey<Schema.Boolean>;
|
|
630
637
|
readonly signUp: Schema.optionalKey<Schema.Struct<{
|
|
631
638
|
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
639
|
+
readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
632
640
|
}>>;
|
|
633
641
|
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
634
642
|
}>, {
|
|
@@ -909,6 +917,7 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
|
|
|
909
917
|
readonly codeLink: Schema.optionalKey<Schema.Boolean>;
|
|
910
918
|
readonly signUp: Schema.optionalKey<Schema.Struct<{
|
|
911
919
|
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
920
|
+
readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
912
921
|
}>>;
|
|
913
922
|
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
914
923
|
}>, {
|
|
@@ -1292,6 +1301,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
1292
1301
|
readonly channels: {
|
|
1293
1302
|
readonly [x: string]: unknown;
|
|
1294
1303
|
};
|
|
1304
|
+
readonly origins?: readonly string[] | undefined;
|
|
1295
1305
|
} | undefined;
|
|
1296
1306
|
readonly onSignUp?: string | undefined;
|
|
1297
1307
|
} | undefined;
|
|
@@ -1560,6 +1570,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
1560
1570
|
readonly channels: {
|
|
1561
1571
|
readonly [x: string]: unknown;
|
|
1562
1572
|
};
|
|
1573
|
+
readonly origins?: readonly string[] | undefined;
|
|
1563
1574
|
} | undefined;
|
|
1564
1575
|
readonly onSignUp?: string | undefined;
|
|
1565
1576
|
} | undefined;
|
|
@@ -1879,6 +1890,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
1879
1890
|
readonly channels: {
|
|
1880
1891
|
readonly [x: string]: unknown;
|
|
1881
1892
|
};
|
|
1893
|
+
readonly origins?: readonly string[] | undefined;
|
|
1882
1894
|
} | undefined;
|
|
1883
1895
|
readonly on_sign_up?: string | undefined;
|
|
1884
1896
|
} | undefined;
|
|
@@ -2096,6 +2108,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
2096
2108
|
readonly channels: {
|
|
2097
2109
|
readonly [x: string]: unknown;
|
|
2098
2110
|
};
|
|
2111
|
+
readonly origins?: readonly string[] | undefined;
|
|
2099
2112
|
} | undefined;
|
|
2100
2113
|
readonly on_sign_up?: string | undefined;
|
|
2101
2114
|
} | undefined;
|
|
@@ -2348,6 +2361,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
2348
2361
|
readonly codeLink: Schema.optionalKey<Schema.Boolean>;
|
|
2349
2362
|
readonly signUp: Schema.optionalKey<Schema.Struct<{
|
|
2350
2363
|
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
2364
|
+
readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
2351
2365
|
}>>;
|
|
2352
2366
|
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
2353
2367
|
}>, {
|
|
@@ -2702,6 +2716,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
2702
2716
|
readonly codeLink: Schema.optionalKey<Schema.Boolean>;
|
|
2703
2717
|
readonly signUp: Schema.optionalKey<Schema.Struct<{
|
|
2704
2718
|
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
2719
|
+
readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
2705
2720
|
}>>;
|
|
2706
2721
|
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
2707
2722
|
}>, {
|
|
@@ -3077,6 +3092,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
3077
3092
|
readonly channels: {
|
|
3078
3093
|
readonly [x: string]: unknown;
|
|
3079
3094
|
};
|
|
3095
|
+
readonly origins?: readonly string[] | undefined;
|
|
3080
3096
|
} | undefined;
|
|
3081
3097
|
readonly onSignUp?: string | undefined;
|
|
3082
3098
|
} | undefined;
|
|
@@ -3345,6 +3361,7 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
3345
3361
|
readonly channels: {
|
|
3346
3362
|
readonly [x: string]: unknown;
|
|
3347
3363
|
};
|
|
3364
|
+
readonly origins?: readonly string[] | undefined;
|
|
3348
3365
|
} | undefined;
|
|
3349
3366
|
readonly onSignUp?: string | undefined;
|
|
3350
3367
|
} | undefined;
|
|
@@ -3619,6 +3636,7 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
|
|
|
3619
3636
|
readonly channels: {
|
|
3620
3637
|
readonly [x: string]: unknown;
|
|
3621
3638
|
};
|
|
3639
|
+
readonly origins?: readonly string[] | undefined;
|
|
3622
3640
|
} | undefined;
|
|
3623
3641
|
readonly onSignUp?: string | undefined;
|
|
3624
3642
|
} | undefined;
|
|
@@ -3887,6 +3905,7 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
|
|
|
3887
3905
|
readonly channels: {
|
|
3888
3906
|
readonly [x: string]: unknown;
|
|
3889
3907
|
};
|
|
3908
|
+
readonly origins?: readonly string[] | undefined;
|
|
3890
3909
|
} | undefined;
|
|
3891
3910
|
readonly onSignUp?: string | undefined;
|
|
3892
3911
|
} | undefined;
|
|
@@ -3954,6 +3973,11 @@ export declare function signInPolicyOf(manifest: Pick<OntologyManifest, "signIn"
|
|
|
3954
3973
|
* the channel is closed to sign-up: not a channel this reader knows, or no well-formed entry.
|
|
3955
3974
|
*/
|
|
3956
3975
|
export declare function signUpRolesOf(manifest: Pick<OntologyManifest, "signIn">, channel: string): ReadonlyArray<string> | undefined;
|
|
3976
|
+
/**
|
|
3977
|
+
* The websites whose visitors may sign up on `web`, by origin: empty while `web` is closed to
|
|
3978
|
+
* sign-up. Entries that are not an origin `signUp.origins` accepts are left out.
|
|
3979
|
+
*/
|
|
3980
|
+
export declare function signUpOriginsOf(manifest: Pick<OntologyManifest, "signIn">): ReadonlyArray<string>;
|
|
3957
3981
|
/** Unsupported providers and missing or unknown channel policies require invitation. */
|
|
3958
3982
|
export declare function channelPolicyOf(manifest: Pick<OntologyManifest, "signIn">, provider: string): SignInPolicy;
|
|
3959
3983
|
/** JSON with object keys sorted at every level and no whitespace: the input of the manifest hash. */
|
package/dist/manifest.js
CHANGED
|
@@ -4,7 +4,7 @@ import { acceptingEarlierManifestNames, withEarlierManifestNames } from "./legac
|
|
|
4
4
|
import { humanize, MEMBER_ROLE, FEEDBACK_REPORTER_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, } from "./sign-in.js";
|
|
7
|
+
import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isSignInPolicy, isSignUpChannel, signUpOrigin, } 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
|
|
@@ -60,6 +60,9 @@ import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isSignInPolicy, isSignUpChan
|
|
|
60
60
|
* Within version 15, `signIn` may carry `signUp`, the wire names of the roles each channel open to
|
|
61
61
|
* sign-up grants, and `onSignUp`, written only when declared. Older readers ignore them and keep
|
|
62
62
|
* every channel closed to sign-up.
|
|
63
|
+
* Within version 15, `signUp` may carry `web` among its channels and `origins`, the websites whose
|
|
64
|
+
* visitors sign up on it, written only when declared. Older readers ignore both and keep `web`
|
|
65
|
+
* closed.
|
|
63
66
|
*/
|
|
64
67
|
export const MANIFEST_VERSION = 15;
|
|
65
68
|
/** The first version whose documents use snake_case names on the wire. */
|
|
@@ -386,9 +389,13 @@ export const BrowserSignInManifest = Schema.Struct({
|
|
|
386
389
|
autoRedirect: Schema.Boolean,
|
|
387
390
|
local: Schema.optionalKey(Schema.Struct({ port: Schema.Int })),
|
|
388
391
|
}).pipe(Schema.encodeKeys({ autoRedirect: "auto_redirect" }));
|
|
389
|
-
/**
|
|
392
|
+
/**
|
|
393
|
+
* Sign-up: the wire names of the roles each open channel grants, and the websites whose visitors
|
|
394
|
+
* may sign up on `web`. Unknown channels stay closed.
|
|
395
|
+
*/
|
|
390
396
|
export const SignUpManifest = Schema.Struct({
|
|
391
397
|
channels: Schema.Record(Schema.String, Schema.Unknown),
|
|
398
|
+
origins: Schema.optionalKey(Schema.Array(Schema.String)),
|
|
392
399
|
});
|
|
393
400
|
export const SignInManifest = Schema.Struct({
|
|
394
401
|
browser: Schema.optionalKey(BrowserSignInManifest),
|
|
@@ -552,6 +559,22 @@ export function signUpRolesOf(manifest, channel) {
|
|
|
552
559
|
? roles
|
|
553
560
|
: undefined;
|
|
554
561
|
}
|
|
562
|
+
/**
|
|
563
|
+
* The websites whose visitors may sign up on `web`, by origin: empty while `web` is closed to
|
|
564
|
+
* sign-up. Entries that are not an origin `signUp.origins` accepts are left out.
|
|
565
|
+
*/
|
|
566
|
+
export function signUpOriginsOf(manifest) {
|
|
567
|
+
if (signUpRolesOf(manifest, "web") === undefined) {
|
|
568
|
+
return [];
|
|
569
|
+
}
|
|
570
|
+
const origins = manifest.signIn?.signUp?.origins;
|
|
571
|
+
return Array.isArray(origins)
|
|
572
|
+
? origins.flatMap((candidate) => {
|
|
573
|
+
const origin = signUpOrigin(candidate);
|
|
574
|
+
return origin === undefined ? [] : [origin];
|
|
575
|
+
})
|
|
576
|
+
: [];
|
|
577
|
+
}
|
|
555
578
|
// @legacy ontology.legacy-channel-admission
|
|
556
579
|
/** Unsupported providers and missing or unknown channel policies require invitation. */
|
|
557
580
|
export function channelPolicyOf(manifest, provider) {
|
|
@@ -800,6 +823,9 @@ export function buildManifest(input) {
|
|
|
800
823
|
channel,
|
|
801
824
|
[...(roles ?? [])],
|
|
802
825
|
])),
|
|
826
|
+
...(input.signIn.signUp.origins === undefined
|
|
827
|
+
? {}
|
|
828
|
+
: { origins: [...input.signIn.signUp.origins] }),
|
|
803
829
|
},
|
|
804
830
|
}),
|
|
805
831
|
...(input.signIn.onSignUp === undefined ? {} : { onSignUp: input.signIn.onSignUp }),
|
package/dist/migrate/model.d.ts
CHANGED
|
@@ -495,6 +495,7 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
495
495
|
readonly channels: {
|
|
496
496
|
readonly [x: string]: unknown;
|
|
497
497
|
};
|
|
498
|
+
readonly origins?: readonly string[] | undefined;
|
|
498
499
|
} | undefined;
|
|
499
500
|
readonly onSignUp?: string | undefined;
|
|
500
501
|
} | undefined;
|
|
@@ -763,6 +764,7 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
763
764
|
readonly channels: {
|
|
764
765
|
readonly [x: string]: unknown;
|
|
765
766
|
};
|
|
767
|
+
readonly origins?: readonly string[] | undefined;
|
|
766
768
|
} | undefined;
|
|
767
769
|
readonly onSignUp?: string | undefined;
|
|
768
770
|
} | undefined;
|
|
@@ -1082,6 +1084,7 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1082
1084
|
readonly channels: {
|
|
1083
1085
|
readonly [x: string]: unknown;
|
|
1084
1086
|
};
|
|
1087
|
+
readonly origins?: readonly string[] | undefined;
|
|
1085
1088
|
} | undefined;
|
|
1086
1089
|
readonly on_sign_up?: string | undefined;
|
|
1087
1090
|
} | undefined;
|
|
@@ -1299,6 +1302,7 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1299
1302
|
readonly channels: {
|
|
1300
1303
|
readonly [x: string]: unknown;
|
|
1301
1304
|
};
|
|
1305
|
+
readonly origins?: readonly string[] | undefined;
|
|
1302
1306
|
} | undefined;
|
|
1303
1307
|
readonly on_sign_up?: string | undefined;
|
|
1304
1308
|
} | undefined;
|
|
@@ -1507,6 +1511,7 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1507
1511
|
readonly codeLink: Schema.optionalKey<Schema.Boolean>;
|
|
1508
1512
|
readonly signUp: Schema.optionalKey<Schema.Struct<{
|
|
1509
1513
|
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
1514
|
+
readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
1510
1515
|
}>>;
|
|
1511
1516
|
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
1512
1517
|
}>, {
|
|
@@ -1766,6 +1771,7 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
1766
1771
|
readonly codeLink: Schema.optionalKey<Schema.Boolean>;
|
|
1767
1772
|
readonly signUp: Schema.optionalKey<Schema.Struct<{
|
|
1768
1773
|
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
1774
|
+
readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
1769
1775
|
}>>;
|
|
1770
1776
|
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
1771
1777
|
}>, {
|
|
@@ -2098,6 +2104,7 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2098
2104
|
readonly channels: {
|
|
2099
2105
|
readonly [x: string]: unknown;
|
|
2100
2106
|
};
|
|
2107
|
+
readonly origins?: readonly string[] | undefined;
|
|
2101
2108
|
} | undefined;
|
|
2102
2109
|
readonly onSignUp?: string | undefined;
|
|
2103
2110
|
} | undefined;
|
|
@@ -2366,6 +2373,7 @@ export declare const MigrationPlan: Schema.Struct<{
|
|
|
2366
2373
|
readonly channels: {
|
|
2367
2374
|
readonly [x: string]: unknown;
|
|
2368
2375
|
};
|
|
2376
|
+
readonly origins?: readonly string[] | undefined;
|
|
2369
2377
|
} | undefined;
|
|
2370
2378
|
readonly onSignUp?: string | undefined;
|
|
2371
2379
|
} | undefined;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
1
2
|
import type { SqlClient } from "effect/unstable/sql";
|
|
2
3
|
import type { Ontology } from "../ontology.js";
|
|
3
|
-
import type { AgentWebStore } from "../service/runtime-contract.js";
|
|
4
|
+
import type { AgentResolution, AgentWebStore } from "../service/runtime-contract.js";
|
|
4
5
|
/**
|
|
5
6
|
* Agent tokens in the ontology's OAuth tables, as channel sessions are: one standing grant per
|
|
6
7
|
* member and resource for the first-party client `agent-web`, and a new access token on each
|
|
7
8
|
* request. Blocking or deactivating the member revokes the grant with every other one of theirs.
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
+
/** How many new website visitors one network address may start an hour. */
|
|
11
|
+
export declare const VISITORS_PER_CLIENT_PER_HOUR = 10;
|
|
12
|
+
export interface AgentWebAdmission {
|
|
13
|
+
/** Admits a new visitor on `web` as `signUp` admits a channel account: their user, or why not. */
|
|
14
|
+
readonly signUp: (visitorId: string) => Effect.Effect<AgentResolution>;
|
|
15
|
+
}
|
|
16
|
+
export declare function sqlAgentWebStore(ontology: Ontology, sql: SqlClient.SqlClient, admission: AgentWebAdmission): AgentWebStore;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
|
-
import { OAUTH_CLIENTS_TABLE, OAUTH_GRANTS_TABLE, USER_TABLE } from "../migrate/storage.js";
|
|
3
|
+
import { CHANNEL_USERS_TABLE, OAUTH_CLIENTS_TABLE, OAUTH_GRANTS_TABLE, USER_TABLE, } from "../migrate/storage.js";
|
|
4
4
|
import { AGENT_WEB_CLIENT_ID } from "../service/agent/web-tokens.js";
|
|
5
|
-
import { ACCESS_TOKEN_PREFIX, FULL_SCOPE, newSecret, secretHash, } from "../service/oauth/protocol.js";
|
|
5
|
+
import { ACCESS_TOKEN_PREFIX, ACCESS_TOKEN_TTL_MS, FULL_SCOPE, REFRESH_TOKEN_PREFIX, REFRESH_TOKEN_TTL_MS, newSecret, secretHash, } from "../service/oauth/protocol.js";
|
|
6
|
+
import { completeAgentLimitNotice, countAgentAttempt, effectiveChannelLimits, } from "./agent-counters.js";
|
|
7
|
+
import { channelUsersAvailable } from "./member-tables.js";
|
|
8
|
+
import { runNewUserHook } from "./new-user-hook.js";
|
|
9
|
+
import { CHANNEL_IDENTITIES_FROM, LIVE_CHANNEL_IDENTITY } from "./user-identity-sql.js";
|
|
10
|
+
import { WEB_PROVIDER } from "../service/runtime-identity.js";
|
|
6
11
|
import { sqlOAuthStore } from "./oauth.js";
|
|
7
12
|
import { isMemberBlocked } from "./principals.js";
|
|
8
13
|
import { isRecordId } from "./records.js";
|
|
@@ -12,7 +17,9 @@ const GRANTS = `"${OAUTH_GRANTS_TABLE}"`;
|
|
|
12
17
|
* member and resource for the first-party client `agent-web`, and a new access token on each
|
|
13
18
|
* request. Blocking or deactivating the member revokes the grant with every other one of theirs.
|
|
14
19
|
*/
|
|
15
|
-
|
|
20
|
+
/** How many new website visitors one network address may start an hour. */
|
|
21
|
+
export const VISITORS_PER_CLIENT_PER_HOUR = 10;
|
|
22
|
+
export function sqlAgentWebStore(ontology, sql, admission) {
|
|
16
23
|
const oauth = sqlOAuthStore(ontology, sql);
|
|
17
24
|
return {
|
|
18
25
|
issue: ({ userId, resource, expiresAt }) => sql
|
|
@@ -57,5 +64,116 @@ export function sqlAgentWebStore(ontology, sql) {
|
|
|
57
64
|
.pipe(Effect.orDie);
|
|
58
65
|
return standing === undefined ? undefined : yield* oauth.memberPrincipal(userId);
|
|
59
66
|
}),
|
|
67
|
+
countTurn: (userId) => Effect.gen(function* () {
|
|
68
|
+
// @legacy ontology.pre-upgrade-database-tolerance
|
|
69
|
+
if (!isRecordId(userId) || !(yield* channelUsersAvailable(sql))) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
const [lifecycle] = yield* sql.unsafe(`SELECT COALESCE(to_jsonb("c") ->> 'signed_up', 'false') = 'true' AS "signed_up",
|
|
73
|
+
"c"."on_new_user_completed_at" IS NULL AND "c"."blocked_at" IS NULL AS "pending"
|
|
74
|
+
FROM "${CHANNEL_USERS_TABLE}" AS "c" WHERE "c"."user_id" = $1::uuid`, [userId]);
|
|
75
|
+
if (lifecycle?.signed_up !== true) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
const limits = yield* effectiveChannelLimits(sql);
|
|
79
|
+
for (const [scope, subject, window] of [
|
|
80
|
+
["turnsPerMinute", userId, "minute"],
|
|
81
|
+
["turnsPerDay", userId, "day"],
|
|
82
|
+
["workspaceTurnsPerDay", "workspace", "day"],
|
|
83
|
+
]) {
|
|
84
|
+
const limited = yield* countAgentAttempt(sql, {
|
|
85
|
+
scope,
|
|
86
|
+
subject,
|
|
87
|
+
window,
|
|
88
|
+
limit: scope === "workspaceTurnsPerDay"
|
|
89
|
+
? limits.workspaceTurnsPerDay
|
|
90
|
+
: limits.perSender[scope],
|
|
91
|
+
});
|
|
92
|
+
if (limited !== undefined) {
|
|
93
|
+
// The refusal the browser gets is this window's notice, on every channel.
|
|
94
|
+
if (limited.notificationId !== undefined) {
|
|
95
|
+
yield* completeAgentLimitNotice(sql, {
|
|
96
|
+
notificationId: limited.notificationId,
|
|
97
|
+
delivered: true,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return { scope: limited.scope, retryAfterSeconds: limited.retryAfterSeconds };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Onboarding that failed at sign-up runs again before an admitted turn, as a messenger's
|
|
104
|
+
// does; a refused turn never runs it.
|
|
105
|
+
if (lifecycle.pending && ontology.signIn.onSignUp !== undefined) {
|
|
106
|
+
const principal = yield* oauth.memberPrincipal(userId);
|
|
107
|
+
if (principal !== undefined) {
|
|
108
|
+
yield* runNewUserHook(ontology, sql, principal);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return undefined;
|
|
112
|
+
}).pipe(Effect.orDie),
|
|
113
|
+
visitor: ({ visitorId, resource, client }) => Effect.gen(function* () {
|
|
114
|
+
const crowded = yield* countAgentAttempt(sql, {
|
|
115
|
+
scope: "newUsersPerHour",
|
|
116
|
+
subject: `web:${client}`,
|
|
117
|
+
window: "hour",
|
|
118
|
+
limit: VISITORS_PER_CLIENT_PER_HOUR,
|
|
119
|
+
});
|
|
120
|
+
if (crowded !== undefined) {
|
|
121
|
+
return { status: "limited", retryAfterSeconds: crowded.retryAfterSeconds };
|
|
122
|
+
}
|
|
123
|
+
// Admission commits the user, their identity and onboarding before the grant, as a channel
|
|
124
|
+
// session's does; never inside the issuer transaction.
|
|
125
|
+
const admitted = yield* admission.signUp(visitorId);
|
|
126
|
+
if (admitted.status === "limited") {
|
|
127
|
+
return { status: "limited", retryAfterSeconds: admitted.retryAfterSeconds };
|
|
128
|
+
}
|
|
129
|
+
if (admitted.status !== "created" && admitted.status !== "existing") {
|
|
130
|
+
return { status: "refused" };
|
|
131
|
+
}
|
|
132
|
+
const userId = admitted.member.principal.id;
|
|
133
|
+
return yield* sql.withTransaction(Effect.gen(function* () {
|
|
134
|
+
// Same lock as the member's lifecycle operations, so a blocked visitor gets nothing.
|
|
135
|
+
const [member] = yield* sql.unsafe(`SELECT "kind"::text AS "kind", "active" FROM "${USER_TABLE}"
|
|
136
|
+
WHERE "id" = $1::uuid FOR SHARE`, [userId]);
|
|
137
|
+
if (member?.kind !== "member" ||
|
|
138
|
+
!member.active ||
|
|
139
|
+
(yield* isMemberBlocked(sql, userId))) {
|
|
140
|
+
return { status: "refused" };
|
|
141
|
+
}
|
|
142
|
+
// The grant lives as long as the visitor's `web` account: revoking the account revokes
|
|
143
|
+
// it, as it revokes a channel's sessions, and a revoked account gets none.
|
|
144
|
+
const [identity] = yield* sql.unsafe(`SELECT "i"."id"::text AS "id", "i"."user_id"::text AS "user_id"
|
|
145
|
+
FROM ${CHANNEL_IDENTITIES_FROM}
|
|
146
|
+
WHERE "i"."provider" = $1 AND "i"."subject" = $2 AND ${LIVE_CHANNEL_IDENTITY}
|
|
147
|
+
FOR UPDATE OF "i"`, [WEB_PROVIDER, visitorId]);
|
|
148
|
+
if (identity === undefined || identity.user_id !== userId) {
|
|
149
|
+
return { status: "refused" };
|
|
150
|
+
}
|
|
151
|
+
yield* sql.unsafe(`INSERT INTO "${OAUTH_CLIENTS_TABLE}" ("id", "name", "redirect_uris", "auth_method")
|
|
152
|
+
VALUES ($1, $1, '[]'::jsonb, 'none') ON CONFLICT ("id") DO NOTHING`, [AGENT_WEB_CLIENT_ID]);
|
|
153
|
+
const grantId = randomUUID();
|
|
154
|
+
const token = newSecret(ACCESS_TOKEN_PREFIX);
|
|
155
|
+
const refreshToken = newSecret(REFRESH_TOKEN_PREFIX);
|
|
156
|
+
const now = Date.now();
|
|
157
|
+
const expiresAt = new Date(now + ACCESS_TOKEN_TTL_MS);
|
|
158
|
+
yield* oauth.saveGrant({
|
|
159
|
+
id: grantId,
|
|
160
|
+
clientId: AGENT_WEB_CLIENT_ID,
|
|
161
|
+
userId,
|
|
162
|
+
scope: FULL_SCOPE,
|
|
163
|
+
resource,
|
|
164
|
+
});
|
|
165
|
+
yield* sql.unsafe(`UPDATE "${OAUTH_GRANTS_TABLE}" SET "identity_id" = $2::uuid WHERE "id" = $1::uuid`, [grantId, identity.id]);
|
|
166
|
+
yield* oauth.saveTokens([
|
|
167
|
+
{ hash: secretHash(token), grantId, kind: "access", expiresAt },
|
|
168
|
+
{
|
|
169
|
+
hash: secretHash(refreshToken),
|
|
170
|
+
grantId,
|
|
171
|
+
kind: "refresh",
|
|
172
|
+
expiresAt: new Date(now + REFRESH_TOKEN_TTL_MS),
|
|
173
|
+
},
|
|
174
|
+
]);
|
|
175
|
+
return { status: "signed_up", userId, token, refreshToken, expiresAt };
|
|
176
|
+
}));
|
|
177
|
+
}).pipe(Effect.orDie),
|
|
60
178
|
};
|
|
61
179
|
}
|
package/dist/runtime/agents.js
CHANGED
|
@@ -13,6 +13,7 @@ import { resolveAgentIdentity } from "./resolve-agent-identity.js";
|
|
|
13
13
|
import { completeAgentLimitNotice } from "./agent-counters.js";
|
|
14
14
|
import { isMemberBlocked, setMemberBlocked, resolveMemberById } from "./principals.js";
|
|
15
15
|
import { sqlAgentWebStore } from "./agent-web.js";
|
|
16
|
+
import { WEB_PROVIDER } from "../service/runtime-identity.js";
|
|
16
17
|
import { isRecordId } from "./records.js";
|
|
17
18
|
import { makeOntologyRuntime } from "./sql-runtime.js";
|
|
18
19
|
import { CHANNEL_IDENTITIES_FROM, CHANNEL_ORIGIN_SQL, CHANNEL_REVOKED_AT, LIVE_CHANNEL_IDENTITY, makeIdentityWriter, USER_IDENTITY_TABLE, } from "./user-identities.js";
|
|
@@ -489,7 +490,9 @@ export function sqlAgentStore(ontology, sql) {
|
|
|
489
490
|
return { id: String(review.id), status: "pending", created: true };
|
|
490
491
|
}))
|
|
491
492
|
.pipe(Effect.orDie),
|
|
492
|
-
web: sqlAgentWebStore(ontology, sql
|
|
493
|
+
web: sqlAgentWebStore(ontology, sql, {
|
|
494
|
+
signUp: (visitorId) => resolveChannelSignIn(ontology, sql, { provider: WEB_PROVIDER, externalId: visitorId }),
|
|
495
|
+
}),
|
|
493
496
|
};
|
|
494
497
|
return store;
|
|
495
498
|
}
|
|
@@ -10,6 +10,8 @@ export declare const AGENT_PATH = "/api/ontology/agent";
|
|
|
10
10
|
/** Where a signed-in member gets an agent token, and where the agent asks whom one stands for. */
|
|
11
11
|
export declare const AGENT_TOKENS_PATH = "/api/ontology/agent/tokens";
|
|
12
12
|
export declare const AGENT_TOKEN_INTROSPECTION_PATH = "/api/ontology/agent/tokens/introspect";
|
|
13
|
+
/** Where a browser on a declared website signs its visitor up on `web`. */
|
|
14
|
+
export declare const AGENT_VISITORS_PATH = "/api/ontology/agent/visitors";
|
|
13
15
|
/**
|
|
14
16
|
* Pairings one client address may start per minute; each one is a row in the database. The agent's
|
|
15
17
|
* functions share a few egress addresses, so the limit leaves room for a busy channel.
|
|
@@ -17,6 +19,8 @@ export declare const AGENT_TOKEN_INTROSPECTION_PATH = "/api/ontology/agent/token
|
|
|
17
19
|
export declare const PAIRING_LIMIT: RateLimit;
|
|
18
20
|
export interface AgentServerOptions {
|
|
19
21
|
readonly verifyToken: TokenVerifier;
|
|
22
|
+
/** The websites whose visitors may sign up on `web`, by origin; none while `web` is closed. */
|
|
23
|
+
readonly visitorOrigins?: ReadonlyArray<string>;
|
|
20
24
|
/** The deployment's runtime tokens; `undefined` while runtime authentication is disabled. */
|
|
21
25
|
readonly verifyRuntime: RuntimeTokenVerifier | undefined;
|
|
22
26
|
readonly exchangeSession: SessionExchange | undefined;
|
|
@@ -13,7 +13,7 @@ import { clientAddress, fixedWindowLimiter, } from "../rate-limit.js";
|
|
|
13
13
|
import { OntologyBackend } from "../runtime-contract.js";
|
|
14
14
|
import { AGENT_TASK_HEADER, agentTaskSecret, logRuntimeRejection, } from "../runtime-identity.js";
|
|
15
15
|
import { ChatSeenRequest, ReviewRequest, ResolveIdentityRequest, IdentityNoticeRequest, LimitNoticeRequest, PAIRING_TTL_MS, PairingRequest, canonicalPairingCode, identityForWire, memberForWire, newPairingCode, } from "./protocol.js";
|
|
16
|
-
import { AGENT_TOKEN_LIMIT, introspectAgentToken, issueAgentToken } from "./web-tokens.js";
|
|
16
|
+
import { AGENT_TOKEN_LIMIT, introspectAgentToken, issueAgentToken, signUpVisitor, visitorPreflight, } from "./web-tokens.js";
|
|
17
17
|
/** The agent's endpoints, under the ontology service's path. */
|
|
18
18
|
export const AGENT_PATH = `${BASE_PATH}/agent`;
|
|
19
19
|
const PAIRINGS_PATH = `${AGENT_PATH}/pairings`;
|
|
@@ -23,6 +23,8 @@ const REVIEWS_PATH = `${AGENT_PATH}/reviews`;
|
|
|
23
23
|
/** Where a signed-in member gets an agent token, and where the agent asks whom one stands for. */
|
|
24
24
|
export const AGENT_TOKENS_PATH = `${AGENT_PATH}/tokens`;
|
|
25
25
|
export const AGENT_TOKEN_INTROSPECTION_PATH = `${AGENT_TOKENS_PATH}/introspect`;
|
|
26
|
+
/** Where a browser on a declared website signs its visitor up on `web`. */
|
|
27
|
+
export const AGENT_VISITORS_PATH = `${AGENT_PATH}/visitors`;
|
|
26
28
|
/**
|
|
27
29
|
* Pairings one client address may start per minute; each one is a row in the database. The agent's
|
|
28
30
|
* functions share a few egress addresses, so the limit leaves room for a busy channel.
|
|
@@ -434,7 +436,12 @@ export function agentLayer(options) {
|
|
|
434
436
|
yield* router.add("DELETE", `${IDENTITIES_PATH}/:id`, asMember((_, member) => revokeIdentity(store, member)));
|
|
435
437
|
if (store.web !== undefined && backend.oauth !== undefined) {
|
|
436
438
|
yield* router.add("POST", AGENT_TOKENS_PATH, asMember(issueAgentToken(store, store.web, fixedWindowLimiter(AGENT_TOKEN_LIMIT))));
|
|
437
|
-
yield* router.add("POST", AGENT_TOKEN_INTROSPECTION_PATH, asRuntime(introspectAgentToken(store, backend.oauth)));
|
|
439
|
+
yield* router.add("POST", AGENT_TOKEN_INTROSPECTION_PATH, asRuntime(introspectAgentToken(store, store.web, backend.oauth)));
|
|
440
|
+
const origins = options.visitorOrigins ?? [];
|
|
441
|
+
if (origins.length > 0) {
|
|
442
|
+
yield* router.add("OPTIONS", AGENT_VISITORS_PATH, visitorPreflight(origins));
|
|
443
|
+
yield* router.add("POST", AGENT_VISITORS_PATH, signUpVisitor(store.web, origins));
|
|
444
|
+
}
|
|
438
445
|
}
|
|
439
446
|
}));
|
|
440
447
|
}
|
|
@@ -2,7 +2,7 @@ import { Effect } from "effect";
|
|
|
2
2
|
import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
|
3
3
|
import type { Principal } from "../../runtime.js";
|
|
4
4
|
import { RequestId } from "../errors.js";
|
|
5
|
-
import type
|
|
5
|
+
import { type RateLimit, type RateLimiter } from "../rate-limit.js";
|
|
6
6
|
import type { AgentStore, AgentWebStore, OAuthStore } from "../runtime-contract.js";
|
|
7
7
|
/**
|
|
8
8
|
* A member's browser reaches the app's agent with an ordinary access token of the ontology's OAuth
|
|
@@ -26,6 +26,22 @@ export declare function issueAgentToken(store: AgentStore, web: AgentWebStore, l
|
|
|
26
26
|
/**
|
|
27
27
|
* `POST /api/ontology/agent/tokens/introspect`, for the agent only (RFC 7662 in spirit): whom an
|
|
28
28
|
* agent token a browser showed stands for. `{ active: false }` for any token that is not a live
|
|
29
|
-
* `agent-web` token for the origin, or whose member may no longer sign in.
|
|
29
|
+
* `agent-web` token for the origin, or whose member may no longer sign in. With `turn: true` the
|
|
30
|
+
* member is starting a turn: someone `signUp` created has it counted against the agent's limits,
|
|
31
|
+
* and the answer names the limit it exceeds as `limited`.
|
|
30
32
|
*/
|
|
31
|
-
export declare function introspectAgentToken(store: AgentStore, oauth: OAuthStore): (request: HttpServerRequest.HttpServerRequest) => Effect.Effect<HttpServerResponse.HttpServerResponse, never, RequestId>;
|
|
33
|
+
export declare function introspectAgentToken(store: AgentStore, web: AgentWebStore, oauth: OAuthStore): (request: HttpServerRequest.HttpServerRequest) => Effect.Effect<HttpServerResponse.HttpServerResponse, never, RequestId>;
|
|
34
|
+
/**
|
|
35
|
+
* `OPTIONS /api/ontology/agent/visitors`: lets a browser on one of `signUp.origins` sign its visitor
|
|
36
|
+
* up; any other origin gets no permission.
|
|
37
|
+
*/
|
|
38
|
+
export declare function visitorPreflight(origins: ReadonlyArray<string>): (request: HttpServerRequest.HttpServerRequest) => Effect.Effect<HttpServerResponse.HttpServerResponse, never, never>;
|
|
39
|
+
/**
|
|
40
|
+
* `POST /api/ontology/agent/visitors`, for a browser on one of the websites `signUp.origins` names:
|
|
41
|
+
* signs a new visitor up on `web` with the roles `signUp` gives it, and answers
|
|
42
|
+
* `{ token, expires_at, refresh_token, chat }`. The token is an agent token like a member's; the
|
|
43
|
+
* refresh token renews it at the ontology's OAuth token endpoint, as client `agent-web`. Any other
|
|
44
|
+
* origin is refused. A browser's Origin proves no sender, so the limits on new visitors per network
|
|
45
|
+
* address and per workspace, and on each one's turns, are what bound it.
|
|
46
|
+
*/
|
|
47
|
+
export declare function signUpVisitor(web: AgentWebStore, origins: ReadonlyArray<string>): (request: HttpServerRequest.HttpServerRequest) => Effect.Effect<HttpServerResponse.HttpServerResponse, never, RequestId>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
1
2
|
import { Effect, Result, Schema } from "effect";
|
|
2
3
|
import { HttpServerResponse } from "effect/unstable/http";
|
|
3
4
|
import { schemaIssues } from "../../runtime/validation.js";
|
|
4
5
|
import { BASE_PATH } from "../api.js";
|
|
5
6
|
import { RequestId, errorBodyForWire, forbidden, rateLimited, toServerResponse, } from "../errors.js";
|
|
6
7
|
import { ACCESS_TOKEN_PREFIX, ACCESS_TOKEN_TTL_MS, callerOfAccessToken, publicOrigin, } from "../oauth/protocol.js";
|
|
8
|
+
import { clientAddress } from "../rate-limit.js";
|
|
7
9
|
/**
|
|
8
10
|
* A member's browser reaches the app's agent with an ordinary access token of the ontology's OAuth
|
|
9
11
|
* server (`sso_…`): the token of the member's grant to the first-party client `agent-web`, for the
|
|
@@ -59,6 +61,8 @@ const IntrospectionRequest = Schema.Struct({
|
|
|
59
61
|
token: Schema.String.check(Schema.isMaxLength(512)),
|
|
60
62
|
/** The origin the member reached the agent on; by default the one the agent calls this on. */
|
|
61
63
|
origin: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(2048))),
|
|
64
|
+
/** The token starts a turn: count it against the agent's limits for people who signed up. */
|
|
65
|
+
turn: Schema.optionalKey(Schema.Boolean),
|
|
62
66
|
});
|
|
63
67
|
function originOf(value, request) {
|
|
64
68
|
if (value === undefined) {
|
|
@@ -72,9 +76,11 @@ function originOf(value, request) {
|
|
|
72
76
|
/**
|
|
73
77
|
* `POST /api/ontology/agent/tokens/introspect`, for the agent only (RFC 7662 in spirit): whom an
|
|
74
78
|
* agent token a browser showed stands for. `{ active: false }` for any token that is not a live
|
|
75
|
-
* `agent-web` token for the origin, or whose member may no longer sign in.
|
|
79
|
+
* `agent-web` token for the origin, or whose member may no longer sign in. With `turn: true` the
|
|
80
|
+
* member is starting a turn: someone `signUp` created has it counted against the agent's limits,
|
|
81
|
+
* and the answer names the limit it exceeds as `limited`.
|
|
76
82
|
*/
|
|
77
|
-
export function introspectAgentToken(store, oauth) {
|
|
83
|
+
export function introspectAgentToken(store, web, oauth) {
|
|
78
84
|
return (request) => Effect.gen(function* () {
|
|
79
85
|
const requestId = yield* RequestId;
|
|
80
86
|
const body = yield* Effect.map(Effect.orDie(request.text), (text) => {
|
|
@@ -109,6 +115,7 @@ export function introspectAgentToken(store, oauth) {
|
|
|
109
115
|
if (authenticated === undefined || member === undefined) {
|
|
110
116
|
return json({ active: false });
|
|
111
117
|
}
|
|
118
|
+
const limited = decoded.success.turn === true ? yield* web.countTurn(member.principal.id) : undefined;
|
|
112
119
|
return json({
|
|
113
120
|
active: true,
|
|
114
121
|
member_id: member.principal.id,
|
|
@@ -116,6 +123,91 @@ export function introspectAgentToken(store, oauth) {
|
|
|
116
123
|
roles: member.principal.roles,
|
|
117
124
|
grant_id: authenticated.grantId,
|
|
118
125
|
chat: personalChat(member.principal.id),
|
|
126
|
+
...(limited === undefined
|
|
127
|
+
? {}
|
|
128
|
+
: {
|
|
129
|
+
limited: { scope: limited.scope, retry_after_seconds: limited.retryAfterSeconds },
|
|
130
|
+
}),
|
|
119
131
|
});
|
|
120
132
|
});
|
|
121
133
|
}
|
|
134
|
+
/** The headers that let a website on `origin` read an answer to its visitor's browser. */
|
|
135
|
+
function websiteHeaders(origin) {
|
|
136
|
+
return { "access-control-allow-origin": origin, vary: "Origin" };
|
|
137
|
+
}
|
|
138
|
+
/** The declared website a browser's request comes from, when it comes from one. */
|
|
139
|
+
function websiteOf(request, origins) {
|
|
140
|
+
const origin = request.headers.origin;
|
|
141
|
+
return origin !== undefined && origins.includes(origin) ? origin : undefined;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* `OPTIONS /api/ontology/agent/visitors`: lets a browser on one of `signUp.origins` sign its visitor
|
|
145
|
+
* up; any other origin gets no permission.
|
|
146
|
+
*/
|
|
147
|
+
export function visitorPreflight(origins) {
|
|
148
|
+
return (request) => Effect.sync(() => {
|
|
149
|
+
const origin = websiteOf(request, origins);
|
|
150
|
+
return origin === undefined
|
|
151
|
+
? HttpServerResponse.empty({ status: 403, headers: { vary: "Origin" } })
|
|
152
|
+
: HttpServerResponse.empty({
|
|
153
|
+
status: 204,
|
|
154
|
+
headers: {
|
|
155
|
+
...websiteHeaders(origin),
|
|
156
|
+
"access-control-allow-methods": "POST",
|
|
157
|
+
"access-control-allow-headers": "content-type",
|
|
158
|
+
"access-control-max-age": "600",
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* `POST /api/ontology/agent/visitors`, for a browser on one of the websites `signUp.origins` names:
|
|
165
|
+
* signs a new visitor up on `web` with the roles `signUp` gives it, and answers
|
|
166
|
+
* `{ token, expires_at, refresh_token, chat }`. The token is an agent token like a member's; the
|
|
167
|
+
* refresh token renews it at the ontology's OAuth token endpoint, as client `agent-web`. Any other
|
|
168
|
+
* origin is refused. A browser's Origin proves no sender, so the limits on new visitors per network
|
|
169
|
+
* address and per workspace, and on each one's turns, are what bound it.
|
|
170
|
+
*/
|
|
171
|
+
export function signUpVisitor(web, origins) {
|
|
172
|
+
return (request) => Effect.gen(function* () {
|
|
173
|
+
const requestId = yield* RequestId;
|
|
174
|
+
const origin = websiteOf(request, origins);
|
|
175
|
+
if (origin === undefined) {
|
|
176
|
+
return HttpServerResponse.jsonUnsafe(errorBodyForWire({
|
|
177
|
+
error: "origin_not_allowed",
|
|
178
|
+
detail: "This origin is not one of signUp.origins.",
|
|
179
|
+
requestId,
|
|
180
|
+
}), { status: 403, headers: { ...NO_STORE, vary: "Origin" } });
|
|
181
|
+
}
|
|
182
|
+
const headers = { ...NO_STORE, ...websiteHeaders(origin) };
|
|
183
|
+
const signedUp = yield* web.visitor({
|
|
184
|
+
visitorId: randomUUID(),
|
|
185
|
+
resource: agentResource(publicOrigin(request)),
|
|
186
|
+
client: createHash("sha256").update(clientAddress(request)).digest("hex"),
|
|
187
|
+
});
|
|
188
|
+
switch (signedUp.status) {
|
|
189
|
+
case "signed_up":
|
|
190
|
+
return HttpServerResponse.jsonUnsafe({
|
|
191
|
+
token: signedUp.token,
|
|
192
|
+
expires_at: signedUp.expiresAt.toISOString(),
|
|
193
|
+
refresh_token: signedUp.refreshToken,
|
|
194
|
+
chat: personalChat(signedUp.userId),
|
|
195
|
+
}, { status: 200, headers });
|
|
196
|
+
case "limited":
|
|
197
|
+
return HttpServerResponse.jsonUnsafe(errorBodyForWire({
|
|
198
|
+
error: "rate_limited",
|
|
199
|
+
detail: "Too many new visitors; try again later.",
|
|
200
|
+
requestId,
|
|
201
|
+
}), {
|
|
202
|
+
status: 429,
|
|
203
|
+
headers: { ...headers, "retry-after": String(signedUp.retryAfterSeconds) },
|
|
204
|
+
});
|
|
205
|
+
case "refused":
|
|
206
|
+
return HttpServerResponse.jsonUnsafe(errorBodyForWire({
|
|
207
|
+
error: "forbidden",
|
|
208
|
+
detail: "The visitor could not be signed up.",
|
|
209
|
+
requestId,
|
|
210
|
+
}), { status: 403, headers });
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
@@ -254,6 +254,41 @@ export interface AgentWebStore {
|
|
|
254
254
|
readonly grantId: string;
|
|
255
255
|
readonly userId: string;
|
|
256
256
|
}) => Effect.Effect<Principal | undefined>;
|
|
257
|
+
/**
|
|
258
|
+
* Counts one turn a member starts on the web against the agent's limits when `signUp` created
|
|
259
|
+
* them, as their turns on a messenger are counted, on the same counters; invited and paired
|
|
260
|
+
* members are never counted. Their `onSignUp`, if it is still pending, runs again first. The
|
|
261
|
+
* limit the turn exceeds, or `undefined` when it may run.
|
|
262
|
+
*/
|
|
263
|
+
readonly countTurn: (userId: string) => Effect.Effect<WebTurnLimit | undefined>;
|
|
264
|
+
/**
|
|
265
|
+
* Signs up a new visitor of a website on `web`: the user `signUp` creates for them, and the access
|
|
266
|
+
* and refresh tokens of their grant to the agent at `resource`. `client` keys how many visitors one
|
|
267
|
+
* network address may start an hour; the workspace's own cap on new users applies too.
|
|
268
|
+
*/
|
|
269
|
+
readonly visitor: (input: {
|
|
270
|
+
readonly visitorId: string;
|
|
271
|
+
readonly resource: string;
|
|
272
|
+
readonly client: string;
|
|
273
|
+
}) => Effect.Effect<VisitorSignUp>;
|
|
274
|
+
}
|
|
275
|
+
/** A website visitor's sign-up on `web`, as {@link AgentWebStore.visitor} answers it. */
|
|
276
|
+
export type VisitorSignUp = {
|
|
277
|
+
readonly status: "signed_up";
|
|
278
|
+
readonly userId: string;
|
|
279
|
+
readonly token: string;
|
|
280
|
+
readonly refreshToken: string;
|
|
281
|
+
readonly expiresAt: Date;
|
|
282
|
+
} | {
|
|
283
|
+
readonly status: "limited";
|
|
284
|
+
readonly retryAfterSeconds: number;
|
|
285
|
+
} | {
|
|
286
|
+
readonly status: "refused";
|
|
287
|
+
};
|
|
288
|
+
/** The limit a member's turn on the web exceeds, and when the next one may run. */
|
|
289
|
+
export interface WebTurnLimit {
|
|
290
|
+
readonly scope: AgentLimitScope;
|
|
291
|
+
readonly retryAfterSeconds: number;
|
|
257
292
|
}
|
|
258
293
|
/** A member as the agent names them: their user's name and the roles they hold now. */
|
|
259
294
|
export interface AgentMember {
|
|
@@ -425,6 +425,7 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
|
|
|
425
425
|
readonly codeLink: Schema.optionalKey<Schema.Boolean>;
|
|
426
426
|
readonly signUp: Schema.optionalKey<Schema.Struct<{
|
|
427
427
|
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
428
|
+
readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
428
429
|
}>>;
|
|
429
430
|
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
430
431
|
}>, {
|
|
@@ -697,6 +698,7 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
|
|
|
697
698
|
readonly codeLink: Schema.optionalKey<Schema.Boolean>;
|
|
698
699
|
readonly signUp: Schema.optionalKey<Schema.Struct<{
|
|
699
700
|
readonly channels: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
701
|
+
readonly origins: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
700
702
|
}>>;
|
|
701
703
|
readonly onSignUp: Schema.optionalKey<Schema.String>;
|
|
702
704
|
}>, {
|
package/dist/service/service.js
CHANGED
|
@@ -9,6 +9,7 @@ import { RuntimeDeployment } from "../runtime/deployment.js";
|
|
|
9
9
|
import { nameToWire } from "../authoring-names.js";
|
|
10
10
|
import { bundledNavigationCatalog } from "../navigation-artifact.js";
|
|
11
11
|
import { parsePageCatalog } from "../navigation-catalog.js";
|
|
12
|
+
import { signUpOriginsOf } from "../manifest.js";
|
|
12
13
|
import { isAllowed } from "../permissions.js";
|
|
13
14
|
import { sqlServiceRuntime } from "../runtime/service-binding.js";
|
|
14
15
|
import { neonSignInLinks, segmentstreamSignInLinks } from "../runtime/sign-in-links.js";
|
|
@@ -349,8 +350,15 @@ export function createOntologyService(ontology, config) {
|
|
|
349
350
|
ErrorResponsesLive,
|
|
350
351
|
storageMaintenanceAuthenticationLayer(config.storageMaintenanceKey),
|
|
351
352
|
]));
|
|
352
|
-
const
|
|
353
|
+
const visitorOrigins = signUpOriginsOf(ontology.manifest);
|
|
354
|
+
const oauth = preview
|
|
353
355
|
? Layer.empty
|
|
356
|
+
: oauthLayer({ verifyToken, refreshReuseGraceMs: config.oauthRefreshReuseGraceMs });
|
|
357
|
+
const mcp = config.mcp === false
|
|
358
|
+
? // A website's visitors renew their agent tokens at the OAuth token endpoint.
|
|
359
|
+
visitorOrigins.length > 0
|
|
360
|
+
? oauth
|
|
361
|
+
: Layer.empty
|
|
354
362
|
: Layer.mergeAll(mcpLayer({
|
|
355
363
|
built,
|
|
356
364
|
hooks,
|
|
@@ -366,10 +374,15 @@ export function createOntologyService(ontology, config) {
|
|
|
366
374
|
streamMaxDurationMs: config.mcpStreamMaxDurationMs,
|
|
367
375
|
workspaceId: config.workspaceId,
|
|
368
376
|
decide: config.decisions,
|
|
369
|
-
}),
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
377
|
+
}), oauth);
|
|
378
|
+
const agent = preview
|
|
379
|
+
? Layer.empty
|
|
380
|
+
: agentLayer({
|
|
381
|
+
verifyToken,
|
|
382
|
+
verifyRuntime,
|
|
383
|
+
exchangeSession,
|
|
384
|
+
visitorOrigins,
|
|
385
|
+
});
|
|
373
386
|
const agentTasks = preview
|
|
374
387
|
? Layer.empty
|
|
375
388
|
: agentTasksLayer({
|
package/dist/sign-in.d.ts
CHANGED
|
@@ -11,10 +11,11 @@ export declare const DEFAULT_SIGN_IN_POLICY: SignInPolicy;
|
|
|
11
11
|
export declare const CHANNEL_PROVIDERS: readonly ["telegram"];
|
|
12
12
|
export type ChannelProvider = (typeof CHANNEL_PROVIDERS)[number];
|
|
13
13
|
/**
|
|
14
|
-
* The channels a stranger may sign up through. `email` is sign-in by email code in the app;
|
|
15
|
-
*
|
|
14
|
+
* The channels a stranger may sign up through. `email` is sign-in by email code in the app; `web`
|
|
15
|
+
* is a visitor who writes to the agent from one of the websites `signUp.origins` names; the others
|
|
16
|
+
* are a first private message to the agent, or opening the Telegram Mini App.
|
|
16
17
|
*/
|
|
17
|
-
export declare const SIGN_UP_CHANNELS: readonly ["email", "telegram", "whatsapp"];
|
|
18
|
+
export declare const SIGN_UP_CHANNELS: readonly ["email", "telegram", "whatsapp", "web"];
|
|
18
19
|
export type SignUpChannel = (typeof SIGN_UP_CHANNELS)[number];
|
|
19
20
|
/** The sign-up channels a person reaches through a chat, which need a matching `chat` adapter. */
|
|
20
21
|
export declare const SIGN_UP_CHAT_CHANNELS: ReadonlyArray<SignUpChannel>;
|
|
@@ -30,11 +31,25 @@ export interface SignUpOptions<R = unknown> {
|
|
|
30
31
|
readonly roles: ReadonlyArray<R>;
|
|
31
32
|
/** Roles for a listed channel that differs from `roles`. */
|
|
32
33
|
readonly byChannel?: Readonly<Partial<Record<SignUpChannel, ReadonlyArray<R>>>>;
|
|
34
|
+
/**
|
|
35
|
+
* The websites whose visitors may sign up on `web`, by origin, such as
|
|
36
|
+
* `https://www.example.com`: the agent's sign-up answers a browser on one of them. Required with
|
|
37
|
+
* `web`; `http` only for `localhost` and `127.0.0.1`.
|
|
38
|
+
*/
|
|
39
|
+
readonly origins?: ReadonlyArray<string>;
|
|
33
40
|
}
|
|
34
41
|
/** Sign-up as the manifest carries it: the wire names of the roles each open channel grants. */
|
|
35
42
|
export interface ResolvedSignUp {
|
|
36
43
|
readonly channels: Readonly<Partial<Record<SignUpChannel, ReadonlyArray<string>>>>;
|
|
44
|
+
/** The websites whose visitors may sign up on `web`, by origin. */
|
|
45
|
+
readonly origins?: ReadonlyArray<string>;
|
|
37
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* The origin a website's address declares, when it is one `signUp.origins` accepts: the exact
|
|
49
|
+
* origin of an `https` address, or of an `http` address on `localhost` or `127.0.0.1`, written as
|
|
50
|
+
* the origin alone, without a path.
|
|
51
|
+
*/
|
|
52
|
+
export declare function signUpOrigin(value: unknown): string | undefined;
|
|
38
53
|
/** How people become members of the app. Email and channel admission are independent. */
|
|
39
54
|
export interface SignInOptions {
|
|
40
55
|
readonly policy: SignInPolicy;
|
package/dist/sign-in.js
CHANGED
|
@@ -10,15 +10,35 @@ export const DEFAULT_SIGN_IN_POLICY = "invited";
|
|
|
10
10
|
/** Channels `signIn.channels` can open; `signUp` replaces it. */
|
|
11
11
|
export const CHANNEL_PROVIDERS = ["telegram"];
|
|
12
12
|
/**
|
|
13
|
-
* The channels a stranger may sign up through. `email` is sign-in by email code in the app;
|
|
14
|
-
*
|
|
13
|
+
* The channels a stranger may sign up through. `email` is sign-in by email code in the app; `web`
|
|
14
|
+
* is a visitor who writes to the agent from one of the websites `signUp.origins` names; the others
|
|
15
|
+
* are a first private message to the agent, or opening the Telegram Mini App.
|
|
15
16
|
*/
|
|
16
|
-
export const SIGN_UP_CHANNELS = ["email", "telegram", "whatsapp"];
|
|
17
|
+
export const SIGN_UP_CHANNELS = ["email", "telegram", "whatsapp", "web"];
|
|
17
18
|
/** The sign-up channels a person reaches through a chat, which need a matching `chat` adapter. */
|
|
18
19
|
export const SIGN_UP_CHAT_CHANNELS = ["telegram", "whatsapp"];
|
|
19
20
|
export function isSignUpChannel(value) {
|
|
20
21
|
return SIGN_UP_CHANNELS.includes(value);
|
|
21
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* The origin a website's address declares, when it is one `signUp.origins` accepts: the exact
|
|
25
|
+
* origin of an `https` address, or of an `http` address on `localhost` or `127.0.0.1`, written as
|
|
26
|
+
* the origin alone, without a path.
|
|
27
|
+
*/
|
|
28
|
+
export function signUpOrigin(value) {
|
|
29
|
+
if (typeof value !== "string" || !URL.canParse(value)) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
const url = new URL(value);
|
|
33
|
+
const local = url.hostname === "localhost" || url.hostname === "127.0.0.1";
|
|
34
|
+
// The service compares a browser's origin exactly, so a pattern such as `*.example.com` would
|
|
35
|
+
// match nothing.
|
|
36
|
+
return (url.protocol === "https:" || (url.protocol === "http:" && local)) &&
|
|
37
|
+
!url.hostname.includes("*") &&
|
|
38
|
+
url.origin === value
|
|
39
|
+
? url.origin
|
|
40
|
+
: undefined;
|
|
41
|
+
}
|
|
22
42
|
/**
|
|
23
43
|
* How a person signs in with an address. `code`: a six-digit code, for a member who has signed in
|
|
24
44
|
* with Neon Auth before, so their Neon Auth account exists. `link`: an emailed sign-in link, for
|
package/dist/storage/tables.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const ATTACHMENTS_TABLE = "_agent_attachments";
|
|
|
6
6
|
* Where an attachment comes from: a chat message on a channel, or a file the agent produced in its
|
|
7
7
|
* sandbox and stores so that an action can keep it.
|
|
8
8
|
*/
|
|
9
|
-
export declare const ATTACHMENT_SOURCES: readonly ["telegram", "slack", "sandbox"];
|
|
9
|
+
export declare const ATTACHMENT_SOURCES: readonly ["telegram", "slack", "whatsapp", "sandbox"];
|
|
10
10
|
/** The check that limits `source` to {@link ATTACHMENT_SOURCES}; its name is PostgreSQL's default. */
|
|
11
11
|
export declare const ATTACHMENT_SOURCE_CHECK = "_agent_attachments_source_check";
|
|
12
12
|
/**
|
package/dist/storage/tables.js
CHANGED
|
@@ -59,7 +59,7 @@ export const ATTACHMENTS_TABLE = "_agent_attachments";
|
|
|
59
59
|
* Where an attachment comes from: a chat message on a channel, or a file the agent produced in its
|
|
60
60
|
* sandbox and stores so that an action can keep it.
|
|
61
61
|
*/
|
|
62
|
-
export const ATTACHMENT_SOURCES = ["telegram", "slack", "sandbox"];
|
|
62
|
+
export const ATTACHMENT_SOURCES = ["telegram", "slack", "whatsapp", "sandbox"];
|
|
63
63
|
/** The check that limits `source` to {@link ATTACHMENT_SOURCES}; its name is PostgreSQL's default. */
|
|
64
64
|
export const ATTACHMENT_SOURCE_CHECK = `${ATTACHMENTS_TABLE}_source_check`;
|
|
65
65
|
const SOURCE_CHECK = `CHECK ("source" IN (${ATTACHMENT_SOURCES.map((source) => `'${source}'`).join(", ")}))`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/ontology",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.104.0",
|
|
4
4
|
"description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|