@segmentstream/ontology 0.109.0 → 0.111.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 +77 -0
- package/README.md +28 -1
- package/dist/agent-review.d.ts +2 -0
- package/dist/agent-review.js +11 -1
- package/dist/analyze.d.ts +34 -34
- package/dist/analyze.js +104 -29
- package/dist/chat-channel.d.ts +22 -0
- package/dist/chat-channel.js +35 -0
- package/dist/index.d.ts +8 -6
- package/dist/index.js +3 -2
- package/dist/manifest.d.ts +194 -29
- package/dist/manifest.js +54 -10
- package/dist/migrate/apply.d.ts +4 -3
- package/dist/migrate/apply.js +8 -3
- package/dist/migrate/model.d.ts +90 -2
- package/dist/migrate/plan.js +1 -1
- package/dist/migrate/preview.js +2 -1
- package/dist/migrate/storage.d.ts +13 -1
- package/dist/migrate/storage.js +33 -1
- package/dist/runtime/agent-counters.d.ts +36 -0
- package/dist/runtime/agent-counters.js +84 -0
- package/dist/runtime/agent-web.d.ts +1 -1
- package/dist/runtime/agent-web.js +175 -3
- package/dist/runtime/agents.js +3 -0
- package/dist/runtime/batch.js +4 -6
- package/dist/runtime/history.d.ts +24 -0
- package/dist/runtime/history.js +35 -1
- package/dist/runtime/pipeline.js +3 -0
- package/dist/runtime/principals.d.ts +6 -0
- package/dist/runtime/principals.js +25 -6
- package/dist/runtime/reads.js +9 -2
- package/dist/runtime/sign-in-links.d.ts +10 -0
- package/dist/runtime/sign-in-links.js +26 -25
- package/dist/runtime/sql-runtime.d.ts +1 -1
- package/dist/runtime/sql-runtime.js +3 -2
- package/dist/runtime/writes.js +4 -6
- package/dist/runtime-source.d.ts +4 -0
- package/dist/runtime-source.js +5 -0
- package/dist/runtime.d.ts +21 -0
- package/dist/service/agent/authentication.d.ts +3 -2
- package/dist/service/agent/authentication.js +2 -11
- package/dist/service/agent/bot-check.d.ts +42 -0
- package/dist/service/agent/bot-check.js +32 -0
- package/dist/service/agent/guest-sign-up.d.ts +140 -0
- package/dist/service/agent/guest-sign-up.js +545 -0
- package/dist/service/agent/protocol.d.ts +34 -1
- package/dist/service/agent/protocol.js +46 -1
- package/dist/service/agent/server.d.ts +17 -0
- package/dist/service/agent/server.js +53 -3
- package/dist/service/agent/web-tokens.d.ts +21 -3
- package/dist/service/agent/web-tokens.js +79 -6
- package/dist/service/authentication.d.ts +9 -1
- package/dist/service/authentication.js +31 -5
- package/dist/service/chat/delivery.js +9 -5
- package/dist/service/chat/envelope.d.ts +6 -0
- package/dist/service/chat/providers/index.d.ts +19 -9
- package/dist/service/chat/providers/index.js +31 -11
- package/dist/service/chat/reads.d.ts +6 -3
- package/dist/service/chat/reads.js +26 -14
- package/dist/service/chat/resolve.d.ts +6 -2
- package/dist/service/chat/resolve.js +7 -3
- package/dist/service/chat/review-delivery.d.ts +2 -2
- package/dist/service/chat/review-delivery.js +16 -8
- package/dist/service/chat/routes.js +2 -1
- package/dist/service/chat/schemas.d.ts +2 -0
- package/dist/service/chat/schemas.js +8 -1
- package/dist/service/config.d.ts +10 -0
- package/dist/service/mcp/server.js +2 -1
- package/dist/service/operations.d.ts +5 -0
- package/dist/service/runtime-contract.d.ts +133 -1
- package/dist/service/runtime-identity.d.ts +23 -0
- package/dist/service/runtime-identity.js +31 -0
- package/dist/service/schemas.d.ts +54 -2
- package/dist/service/service.js +27 -1
- package/dist/service/webhooks.d.ts +15 -0
- package/dist/service/webhooks.js +15 -4
- package/dist/sign-in.d.ts +29 -0
- package/dist/sign-in.js +8 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,82 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.111.0
|
|
4
|
+
|
|
5
|
+
`chat` names the agent's channels as its `channels` does: the channel named after its kind
|
|
6
|
+
(`telegram`, `slack`, `whatsapp`, `email`) as before, and any other with its `kind`, such as
|
|
7
|
+
`chat: { sales_whatsapp: { kind: "whatsapp", connection: waSales } }`. Each channel's connection
|
|
8
|
+
is granted to `agent_review.approve`, and those of kinds that take posts to
|
|
9
|
+
`agent_chat.post_message`. A chat of another channel is keyed by the channel's name: its
|
|
10
|
+
`agent_chat` record's `provider`, a member's private chat `<channel>:private:<member>`, and its
|
|
11
|
+
archive and attachments. A member's account reaches them on every channel of its kind.
|
|
12
|
+
|
|
13
|
+
`agent_review` records `channel`, the channel the chat is on, and approval sends the reply
|
|
14
|
+
through that channel's connection, refusing a channel `chat` does not declare or of another kind.
|
|
15
|
+
A review held before has no `channel` and leaves through the channel named after its kind. A
|
|
16
|
+
runtime source may name its `channel`.
|
|
17
|
+
|
|
18
|
+
`chat_list` gives each destination's `kind` beside its `provider`, the channel's name, so an agent
|
|
19
|
+
renders a post to `sales_whatsapp` as WhatsApp does. History keeps the chat an action came from by
|
|
20
|
+
its channel's name, and keeps a messenger's chat only on a channel of the kind the member wrote
|
|
21
|
+
from: the channel named after the kind, or one of another name `chat` declares with that kind.
|
|
22
|
+
|
|
23
|
+
## 0.110.0
|
|
24
|
+
|
|
25
|
+
History keeps the chat an action came from. The app's agent names the chat it acts in and its
|
|
26
|
+
session there (`X-SegmentStream-Agent-Chat`, `X-SegmentStream-Agent-Session`, as on its attachment
|
|
27
|
+
routes) on every ontology request it makes for a member or a website's guest. With the
|
|
28
|
+
deployment's runtime token, the ontology keeps that chat as the principal's: an action's handler
|
|
29
|
+
sees it as `principal.chat` (`{ provider, chatId, sessionId? }`, as the chat archive names them,
|
|
30
|
+
such as `web` and `guest:<id>`), and every history entry the action writes carries it as `chat`,
|
|
31
|
+
in the runtime's action attribution table beside a pipeline's verified execution. A web chat counts
|
|
32
|
+
only as the acting member's or guest's own, a messenger's only on the provider the member wrote
|
|
33
|
+
from; any other chat is left out, never refused, and nothing else carries one. So a lead a guest
|
|
34
|
+
left, created by nobody, leads back to the guest's chat; an action can keep `principal.chat` on
|
|
35
|
+
the record for metrics by chat.
|
|
36
|
+
|
|
37
|
+
The next deploy's migration adds the nullable `chat` column to `_ontology_action_attribution` and
|
|
38
|
+
lets `execution` be empty, keeping every row. An agent built before this sends no chat, and an
|
|
39
|
+
ontology built before this ignores the headers. The app SDK's `HistoryEntry` type names `chat`.
|
|
40
|
+
|
|
41
|
+
Guests can be held to a bot check, a money cap, confirmations of their own, and can become users.
|
|
42
|
+
|
|
43
|
+
- `guest.botCheck: { scheme: "turnstile", secret: "turnstile-secret-key" }` makes every new guest
|
|
44
|
+
pass the website's challenge: `POST /api/ontology/agent/visitors` then needs the challenge's
|
|
45
|
+
token as `{ "bot_check": "<token>" }`, and answers `403 bot_check_required` without one,
|
|
46
|
+
`403 bot_check_failed` for one the provider refuses or that was solved on a page whose hostname
|
|
47
|
+
is not the requesting website's, and `503 bot_check_unavailable` when it cannot be checked. `secret` names a workspace secret holding the provider's secret key
|
|
48
|
+
(`segmentstream secret create`); SegmentStream's backend checks each token for the deployed
|
|
49
|
+
ontology, which never holds the key. Renewals need no check.
|
|
50
|
+
- `guest.confirmations: true` answers a guest's agent token introspection with
|
|
51
|
+
`confirmations: true`, so that the app's agent puts actions that need a confirmation to the
|
|
52
|
+
guest in the website's chat, as to a member. Without it nothing changes.
|
|
53
|
+
- The agent's limits may cap guests' daily model cost: `limits.guest.usdPerDay` for each guest
|
|
54
|
+
(at most 100) and `workspaceUsdPerDay` for every guest together (at most 10000), in US dollars.
|
|
55
|
+
The agent reports a guest's spend at `POST /api/ontology/agent/guests/usage` (runtime only,
|
|
56
|
+
`{ guest_id, cost_usd, key }`, once per key), and a guest's turn past a cap is answered
|
|
57
|
+
`limited` with the scope `guestUsdPerDay` or `guestWorkspaceUsdPerDay`. No cap applies unless set.
|
|
58
|
+
- Where `signUp` lists `email`, a guest becomes a user by proving an address with the app's own
|
|
59
|
+
sign-in email, with the guest's agent token, from a guest website.
|
|
60
|
+
`POST /api/ontology/agent/guests/email-code` (`{ email, return_to? }`) answers `{ sent: true }`
|
|
61
|
+
either way: an address whose Neon Auth account receives codes gets the six-digit code, which
|
|
62
|
+
`POST /api/ontology/agent/guests/sign-up` takes as `{ email, code }`; any other gets the app's
|
|
63
|
+
sign-in link, which creates its account. Opened, the link lands on
|
|
64
|
+
`GET /api/ontology/agent/guests/link`, which admits the user and redirects to `return_to` with
|
|
65
|
+
`#segmentstream_guest=<handoff>`; `/sign-up` takes `{ handoff }` only from the guest who asked
|
|
66
|
+
for the link, and refuses another browser's guest `handoff_other_browser`. The guest becomes the
|
|
67
|
+
user sign-up created with the address, or a new one with the roles `signUp` gives `email` (and
|
|
68
|
+
`onSignUp`); the address of a member is refused `member_address`. The guest's grant becomes
|
|
69
|
+
the user's, with new tokens in the answer
|
|
70
|
+
`{ token, expires_at, refresh_token, chat, user_id, created }`. Other refusals are
|
|
71
|
+
`email_sign_up_closed`, `code_invalid`, `link_invalid`, `handoff_invalid`, `rate_limited` and
|
|
72
|
+
`email_unavailable`. Pending links live in the new agent
|
|
73
|
+
table `_agent_guest_links`, which the next deploy creates; nonces and handoffs are stored as
|
|
74
|
+
hashes.
|
|
75
|
+
|
|
76
|
+
The manifest carries `sign_in.guest.bot_check` and `confirmations` only when declared, so other
|
|
77
|
+
manifests keep their hashes. Declare `guest.botCheck` only once SegmentStream verifies challenge
|
|
78
|
+
tokens for it; a deployment without that support answers new guests `503 bot_check_unavailable`.
|
|
79
|
+
|
|
3
80
|
## 0.109.0
|
|
4
81
|
|
|
5
82
|
`emailReplyMessage` from `@segmentstream/ontology/email` takes `attachments` (file name, MIME type
|
package/README.md
CHANGED
|
@@ -427,6 +427,27 @@ export default defineOntology({
|
|
|
427
427
|
whose `*` is one whole leftmost label over a domain of at least two labels (`websiteOrigin`,
|
|
428
428
|
`matchesWebsite`). The manifest carries `sign_in.guest` and the built-in role only when
|
|
429
429
|
declared; `guestOf(manifest)` reads them.
|
|
430
|
+
- `guest.botCheck: { scheme: "turnstile", secret }` makes a new guest's request carry the
|
|
431
|
+
website challenge's token as `bot_check`; the ontology has SegmentStream's backend check it with
|
|
432
|
+
the challenge's provider under the workspace secret `secret` names, at
|
|
433
|
+
`…/secrets/{name}/verify-challenge`, and refuses `bot_check_required`, `bot_check_failed` or
|
|
434
|
+
`503 bot_check_unavailable`; each check carries an idempotency key, and a challenge solved on a
|
|
435
|
+
page whose hostname is not the requesting website's fails. `guest.confirmations: true` answers a
|
|
436
|
+
guest's introspection with `confirmations: true`, for the agent to put actions that need a
|
|
437
|
+
confirmation to the guest. Agent limits may cap guests' daily model cost with
|
|
438
|
+
`limits.guest.usdPerDay` (each guest, at most $100) and `workspaceUsdPerDay` (every guest
|
|
439
|
+
together, at most $10,000); the agent reports each answer's cost at
|
|
440
|
+
`POST /api/ontology/agent/guests/usage`, once per `key`, and a guest's turn past a cap is
|
|
441
|
+
answered `limited` with the scope `guestUsdPerDay` or `guestWorkspaceUsdPerDay`. With `signUp`
|
|
442
|
+
listing `email`, a guest becomes a user with the app's own sign-in email:
|
|
443
|
+
`POST /api/ontology/agent/guests/email-code` sends a code to an address whose Neon Auth account
|
|
444
|
+
receives codes and a sign-in link to any other, answering the same either way. A code goes back
|
|
445
|
+
to `…/guests/sign-up` as `{ email, code }`; a link lands on `GET …/guests/link`, which admits the
|
|
446
|
+
user and returns to the website with a single-use handoff, which `…/guests/sign-up` takes as
|
|
447
|
+
`{ handoff }` only from the guest who asked (`handoff_other_browser` otherwise). The user is the
|
|
448
|
+
one sign-up created with the address, or a new one, and the guest's grant moves to them with new
|
|
449
|
+
tokens; a member's address is refused `member_address`. Pending links and handoffs live in
|
|
450
|
+
`_agent_guest_links`, as hashes. See the guests' section of the ontology docs.
|
|
430
451
|
- `signUp: { channels, roles, byChannel?, origins? }` opens sign-up to strangers on each listed
|
|
431
452
|
channel: `email` (signing in to the app by email code), `telegram` (a first private message to
|
|
432
453
|
the bot, or opening the Mini App), `whatsapp` (a first message to the number) and `web` (a
|
|
@@ -1531,8 +1552,14 @@ timeout, a 5xx or an answer naming no message is `uncertain`. The receipt's `mes
|
|
|
1531
1552
|
`wamid…` Meta accepted; it has no URL, and a failure Meta reports later in delivery statuses does
|
|
1532
1553
|
not change it.
|
|
1533
1554
|
|
|
1555
|
+
`chat` names the agent's channels as its `channels` does. A channel not named after its kind,
|
|
1556
|
+
such as a second number, says its kind: `chat: { sales_whatsapp: { kind: "whatsapp", connection:
|
|
1557
|
+
waSales } }`. Its chats are keyed by its name (`sales_whatsapp:private:<member UUID>`, and the
|
|
1558
|
+
`provider` of its `agent_chat` records), and posts and reviewed replies there leave through its
|
|
1559
|
+
connection. A member's account reaches them on every channel of its kind.
|
|
1560
|
+
|
|
1534
1561
|
`chat_list({ query?, chat?, after?, limit? })` returns eligible routing metadata and server-derived
|
|
1535
|
-
attribution. `query` filters titles by a case-insensitive literal substring before pagination.
|
|
1562
|
+
attribution: each item's `provider` is the channel the chat is on, by name, and `kind` its kind. `query` filters titles by a case-insensitive literal substring before pagination.
|
|
1536
1563
|
`chat` selects an exact ID/title. Choose an ID or exact title; ambiguous titles return candidates and never guess.
|
|
1537
1564
|
Paired private chats have stable handles `telegram:private:<member UUID>`, and
|
|
1538
1565
|
`slack:private:<member UUID>` or `whatsapp:private:<member UUID>` when that provider is declared.
|
package/dist/agent-review.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export declare const AGENT_REVIEW_TEXT_LIMIT = 20000;
|
|
|
36
36
|
export declare const AgentReview: import("./entity.js").Entity<"agent_review", {
|
|
37
37
|
readonly key: import("./property.js").Property<string, false, true>;
|
|
38
38
|
readonly provider: import("./property.js").Property<string, false, false>;
|
|
39
|
+
readonly channel: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
|
|
39
40
|
readonly chatId: import("./property.js").Property<string, false, false>;
|
|
40
41
|
readonly recipient: import("./property.js").Property<string, false, false>;
|
|
41
42
|
readonly chatKind: import("./property.js").Property<"private" | "group", false, false>;
|
|
@@ -76,6 +77,7 @@ export declare const AgentReview: import("./entity.js").Entity<"agent_review", {
|
|
|
76
77
|
readonly updatedBy: string | null;
|
|
77
78
|
readonly key: string;
|
|
78
79
|
readonly provider: string;
|
|
80
|
+
readonly channel: string | null;
|
|
79
81
|
readonly chatId: string;
|
|
80
82
|
readonly recipient: string;
|
|
81
83
|
readonly chatKind: "private" | "group";
|
package/dist/agent-review.js
CHANGED
|
@@ -49,7 +49,17 @@ export const AgentReview = entity("agent_review", {
|
|
|
49
49
|
unique: true,
|
|
50
50
|
description: "The agent's key for the reply, so a repeated report holds it once.",
|
|
51
51
|
}),
|
|
52
|
-
provider: p.text({
|
|
52
|
+
provider: p.text({
|
|
53
|
+
managed: true,
|
|
54
|
+
description: "The kind of channel the chat is on, for example telegram.",
|
|
55
|
+
}),
|
|
56
|
+
channel: p.text({
|
|
57
|
+
optional: true,
|
|
58
|
+
managed: true,
|
|
59
|
+
description: "The agent's channel the chat is on, by its name, such as telegram or sales_whatsapp: " +
|
|
60
|
+
"approval sends the reply through that channel's connection. Empty on a reply held " +
|
|
61
|
+
"before channels had names, which is on the channel named after its kind.",
|
|
62
|
+
}),
|
|
53
63
|
chatId: p.text({ managed: true, description: "The chat's id at the provider." }),
|
|
54
64
|
recipient: p.text({
|
|
55
65
|
managed: true,
|
package/dist/analyze.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ChatAttributionSettings } from "./chat.js";
|
|
2
|
+
import { type ChatChannelKind } from "./chat-channel.js";
|
|
3
|
+
import type { ChatManifestInput } from "./manifest.js";
|
|
2
4
|
import { Schema } from "effect";
|
|
3
5
|
import { type Action, type ActionHints } from "./action.js";
|
|
4
6
|
import { type AnyConnectionHandle } from "./connection.js";
|
|
@@ -90,26 +92,15 @@ export interface OntologyConfig<Entities extends ReadonlyArray<AnyEntity> = Read
|
|
|
90
92
|
*/
|
|
91
93
|
readonly toolsets?: ReadonlyArray<Toolset>;
|
|
92
94
|
/**
|
|
93
|
-
* The
|
|
94
|
-
* must be listed in `connections`. Only
|
|
95
|
-
*
|
|
96
|
-
*
|
|
95
|
+
* The agent's channels the built-in exact chat post delivers to, by the names the agent's
|
|
96
|
+
* `channels` give them, each through its connection, which must be listed in `connections`. Only
|
|
97
|
+
* declared channels are destinations. A reply the agent held for review is sent through the
|
|
98
|
+
* connection of the channel its chat is on. A channel named after its kind (`telegram`, `slack`,
|
|
99
|
+
* `whatsapp`, `email`) is that kind; any other, such as `sales_whatsapp`, says its `kind`. An
|
|
100
|
+
* `email` channel names the mailbox the agent's mail channel reads: only reviewed replies leave
|
|
101
|
+
* through it, never a chat post.
|
|
97
102
|
*/
|
|
98
|
-
readonly chat?:
|
|
99
|
-
readonly telegram?: {
|
|
100
|
-
readonly connection: AnyConnectionHandle;
|
|
101
|
-
};
|
|
102
|
-
readonly slack?: {
|
|
103
|
-
readonly connection: AnyConnectionHandle;
|
|
104
|
-
};
|
|
105
|
-
readonly whatsapp?: {
|
|
106
|
-
readonly connection: AnyConnectionHandle;
|
|
107
|
-
};
|
|
108
|
-
readonly email?: {
|
|
109
|
-
readonly connection: AnyConnectionHandle;
|
|
110
|
-
};
|
|
111
|
-
readonly attribution?: ChatAttributionSettings;
|
|
112
|
-
};
|
|
103
|
+
readonly chat?: ChatConfig;
|
|
113
104
|
/**
|
|
114
105
|
* Metrics of the model, by camelCase name: each combines metrics of entities, read with
|
|
115
106
|
* `m.ref("entity.metric")`, or other model metrics, read with `m.ref("name")`, through
|
|
@@ -218,21 +209,7 @@ export interface ResolvedEntity {
|
|
|
218
209
|
}
|
|
219
210
|
export interface Analysis {
|
|
220
211
|
readonly feedback: ResolvedFeedback;
|
|
221
|
-
readonly chat?:
|
|
222
|
-
readonly telegram?: {
|
|
223
|
-
readonly connection: string;
|
|
224
|
-
};
|
|
225
|
-
readonly slack?: {
|
|
226
|
-
readonly connection: string;
|
|
227
|
-
};
|
|
228
|
-
readonly whatsapp?: {
|
|
229
|
-
readonly connection: string;
|
|
230
|
-
};
|
|
231
|
-
readonly email?: {
|
|
232
|
-
readonly connection: string;
|
|
233
|
-
};
|
|
234
|
-
readonly attribution?: ChatAttributionSettings;
|
|
235
|
-
};
|
|
212
|
+
readonly chat?: ChatManifestInput;
|
|
236
213
|
readonly entities: ReadonlyArray<ResolvedEntity>;
|
|
237
214
|
/** The workspace-owned `member` role and declared roles, then the implicit reporter when enabled. */
|
|
238
215
|
readonly roles: ReadonlyArray<Role>;
|
|
@@ -250,6 +227,29 @@ export interface Analysis {
|
|
|
250
227
|
readonly toolsets: ReadonlyArray<ResolvedToolset>;
|
|
251
228
|
readonly diagnostics: ReadonlyArray<Diagnostic>;
|
|
252
229
|
}
|
|
230
|
+
/** One channel of `chat`, by name: the channel named after its kind, or one that says its kind. */
|
|
231
|
+
export interface ChatChannelConfig {
|
|
232
|
+
readonly kind?: ChatChannelKind;
|
|
233
|
+
readonly connection: AnyConnectionHandle;
|
|
234
|
+
}
|
|
235
|
+
/** `chat` of {@link OntologyConfig}: the agent's channels by name, and the post attribution. */
|
|
236
|
+
export interface ChatConfig {
|
|
237
|
+
readonly telegram?: {
|
|
238
|
+
readonly connection: AnyConnectionHandle;
|
|
239
|
+
};
|
|
240
|
+
readonly slack?: {
|
|
241
|
+
readonly connection: AnyConnectionHandle;
|
|
242
|
+
};
|
|
243
|
+
readonly whatsapp?: {
|
|
244
|
+
readonly connection: AnyConnectionHandle;
|
|
245
|
+
};
|
|
246
|
+
readonly email?: {
|
|
247
|
+
readonly connection: AnyConnectionHandle;
|
|
248
|
+
};
|
|
249
|
+
readonly attribution?: ChatAttributionSettings;
|
|
250
|
+
/** A channel of another name, such as `sales_whatsapp`, with its `kind`. */
|
|
251
|
+
readonly [name: string]: ChatChannelConfig | ChatAttributionSettings | undefined;
|
|
252
|
+
}
|
|
253
253
|
/**
|
|
254
254
|
* Resolves an ontology definition and checks it. It never throws: every problem, including a thunk
|
|
255
255
|
* that throws, becomes a diagnostic.
|
package/dist/analyze.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { validateBrowserSignIn } from "./sign-in.js";
|
|
2
|
+
import { CHAT_CHANNEL_KINDS, CHAT_CHANNEL_NAME, chatChannelKind, isChatChannelKind, } from "./chat-channel.js";
|
|
2
3
|
import { checkWarehouseSource } from "./warehouse-backed.js";
|
|
3
4
|
import { Result, Schema } from "effect";
|
|
4
5
|
import { BLOB_UPLOAD_ANNOTATION } from "./blob.js";
|
|
@@ -11,7 +12,7 @@ import { REFERENCE_ANNOTATION, propertyDefinition, propertyOptionNames, unknownP
|
|
|
11
12
|
import { AGENT_TOOL, AGENT_TOOL_VERBS, EXPLICIT_GRANT_ENTITIES, generatedActionPermissions, grants, isAllowed, namesAgentTools, normalizePermission, parsePermission, parseWorkflowPermission, permissionOf, READ_VERB, rolesGranting, USER_IDENTITY_VERBS, USER_MEMBER_VERBS, WILDCARD, wildcardEntityCovers, WORKSPACE_SOURCE, WORKSPACE_SOURCE_PERMISSION, } from "./permissions.js";
|
|
12
13
|
import { ON_DELETE, isRelationship } from "./relationship.js";
|
|
13
14
|
import { isRole, member, role } from "./role.js";
|
|
14
|
-
import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, GUEST_CHANNELS, SIGN_UP_CHANNELS, SIGN_UP_CHAT_CHANNELS, isGuestChannel, isSignInPolicy, isSignUpChannel, websiteOrigin, } from "./sign-in.js";
|
|
15
|
+
import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, GUEST_BOT_CHECK_SCHEMES, GUEST_CHANNELS, SIGN_UP_CHANNELS, SIGN_UP_CHAT_CHANNELS, isGuestBotCheckScheme, isGuestChannel, isSignInPolicy, isSignUpChannel, websiteOrigin, } from "./sign-in.js";
|
|
15
16
|
import { BUILT_IN_EMAIL_VALUES, emailOptions, emailValueNames, } from "./emails.js";
|
|
16
17
|
import { AgentChat } from "./agent-chat.js";
|
|
17
18
|
import { AgentReview } from "./agent-review.js";
|
|
@@ -32,10 +33,19 @@ import { actionInputToWire } from "./authoring-input.js";
|
|
|
32
33
|
import { validate } from "./runtime/validation.js";
|
|
33
34
|
import { fixedArgumentsConflict, isToolset, MAXIMUM_TOOLSET_TOOLS, MCP_TOOL_NAME, toolHints, ToolsetLock, withoutFixedArguments, } from "./toolset.js";
|
|
34
35
|
const GENERATED_UPSERT = new RegExp(`^${GENERATED_UPSERT_PREFIX}`);
|
|
35
|
-
/** The
|
|
36
|
-
const CHAT_PROVIDER_KEYS =
|
|
37
|
-
/** The
|
|
36
|
+
/** The kinds of channel `chat` may declare a connection for, in the order posting lists them. */
|
|
37
|
+
const CHAT_PROVIDER_KEYS = CHAT_CHANNEL_KINDS;
|
|
38
|
+
/** The kinds of channel reviewed replies leave through, but chat posts never reach. */
|
|
38
39
|
const REVIEW_ONLY_CHAT_PROVIDERS = new Set(["email"]);
|
|
40
|
+
/** Names the agent keeps its own chats under, which no channel of `chat` takes. */
|
|
41
|
+
const RESERVED_CHAT_NAMES = new Set(["web", "task"]);
|
|
42
|
+
/** Whether `chat` declares a channel of `kind`: the one named after it, or another of the kind. */
|
|
43
|
+
function declaresChatKind(chat, kind) {
|
|
44
|
+
return (isPlainObject(chat) &&
|
|
45
|
+
Object.entries(chat).some(([name, value]) => name !== "attribution" &&
|
|
46
|
+
value !== undefined &&
|
|
47
|
+
chatChannelKind(chat, name) === kind));
|
|
48
|
+
}
|
|
39
49
|
function errorMessage(error) {
|
|
40
50
|
return error instanceof Error ? error.message : String(error);
|
|
41
51
|
}
|
|
@@ -148,39 +158,54 @@ export function analyze(config, options = {}) {
|
|
|
148
158
|
];
|
|
149
159
|
let chat;
|
|
150
160
|
if (config.chat !== undefined) {
|
|
151
|
-
const
|
|
152
|
-
?
|
|
161
|
+
const entries = isPlainObject(config.chat)
|
|
162
|
+
? Object.entries(config.chat).filter(([name, value]) => name !== "attribution" && value !== undefined)
|
|
153
163
|
: [];
|
|
154
164
|
const unknown = isPlainObject(config.chat)
|
|
155
|
-
?
|
|
165
|
+
? entries.find(([name]) => !CHAT_CHANNEL_NAME.test(name) || RESERVED_CHAT_NAMES.has(name))?.[0]
|
|
156
166
|
: "chat";
|
|
157
|
-
const malformed =
|
|
158
|
-
const
|
|
159
|
-
return (!isPlainObject(
|
|
160
|
-
Object.keys(
|
|
161
|
-
!isConnection(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
167
|
+
const malformed = entries.find(([name, value]) => {
|
|
168
|
+
const named = !CHAT_PROVIDER_KEYS.includes(name);
|
|
169
|
+
return (!isPlainObject(value) ||
|
|
170
|
+
Object.keys(value).some((key) => key !== "connection" && key !== "kind") ||
|
|
171
|
+
!isConnection(value.connection) ||
|
|
172
|
+
(named ? !isChatChannelKind(value.kind) : value.kind !== undefined && value.kind !== name));
|
|
173
|
+
})?.[0];
|
|
174
|
+
// Read only once every declared channel is well formed.
|
|
175
|
+
const handles = malformed === undefined && unknown === undefined
|
|
176
|
+
? entries.map(([name, value]) => {
|
|
177
|
+
const entry = value;
|
|
178
|
+
return [name, entry.connection, entry.kind ?? name];
|
|
179
|
+
})
|
|
166
180
|
: [];
|
|
167
181
|
const unlisted = handles.find(([, handle]) => !(config.connections ?? []).includes(handle));
|
|
168
182
|
const shared = handles.find(([, handle], index) => handles.findIndex(([, other]) => other === handle) !== index);
|
|
169
183
|
if (unknown !== undefined) {
|
|
170
|
-
report("invalid-connection", "chat", `chat accepts
|
|
184
|
+
report("invalid-connection", "chat", `chat accepts attribution and channels by the agent's names for them: ` +
|
|
185
|
+
`${CHAT_PROVIDER_KEYS.join(", ")}, or another lower-case name with its kind; ` +
|
|
186
|
+
"web and task are the agent's own.");
|
|
171
187
|
}
|
|
172
188
|
else if (malformed !== undefined) {
|
|
173
|
-
report("invalid-connection", "chat", `chat.${malformed}.connection must reference a declared connection handle
|
|
189
|
+
report("invalid-connection", "chat", `chat.${malformed}.connection must reference a declared connection handle, and a ` +
|
|
190
|
+
`channel not named after its kind needs kind: ${CHAT_PROVIDER_KEYS.join(", ")}.`);
|
|
174
191
|
}
|
|
175
192
|
else if (unlisted !== undefined) {
|
|
176
|
-
report("invalid-connection", `chat.${unlisted[0]}.connection`, "The chat
|
|
193
|
+
report("invalid-connection", `chat.${unlisted[0]}.connection`, "The chat channel connection must be listed in connections.");
|
|
177
194
|
}
|
|
178
195
|
else if (shared !== undefined) {
|
|
179
|
-
report("invalid-connection", `chat.${shared[0]}.connection`, "Each chat
|
|
196
|
+
report("invalid-connection", `chat.${shared[0]}.connection`, "Each chat channel needs its own connection.");
|
|
180
197
|
}
|
|
181
198
|
else if (handles.length > 0) {
|
|
199
|
+
const named = handles.filter(([name]) => !CHAT_PROVIDER_KEYS.includes(name));
|
|
182
200
|
chat = {
|
|
183
|
-
...Object.fromEntries(handles
|
|
201
|
+
...Object.fromEntries(handles
|
|
202
|
+
.filter(([name]) => CHAT_PROVIDER_KEYS.includes(name))
|
|
203
|
+
.map(([name, handle]) => [name, { connection: handle.key }])),
|
|
204
|
+
...(named.length === 0
|
|
205
|
+
? {}
|
|
206
|
+
: {
|
|
207
|
+
channels: Object.fromEntries(named.map(([name, handle, kind]) => [name, { kind, connection: handle.key }])),
|
|
208
|
+
}),
|
|
184
209
|
...(config.chat.attribution === undefined ? {} : { attribution: config.chat.attribution }),
|
|
185
210
|
};
|
|
186
211
|
// Posting to a chat and sending a reviewed reply both send through the chat connections.
|
|
@@ -188,8 +213,8 @@ export function analyze(config, options = {}) {
|
|
|
188
213
|
agent_chat: "post_message",
|
|
189
214
|
agent_review: "approve",
|
|
190
215
|
};
|
|
191
|
-
// A chat post never reaches a
|
|
192
|
-
const reaches = (entity) => handles.filter(([
|
|
216
|
+
// A chat post never reaches a channel whose kind only sends reviewed replies.
|
|
217
|
+
const reaches = (entity) => handles.filter(([, , kind]) => entity === "agent_review" || !REVIEW_ONLY_CHAT_PROVIDERS.has(kind));
|
|
193
218
|
resolved = resolved.map((entity) => sends[entity.name] === undefined
|
|
194
219
|
? entity
|
|
195
220
|
: {
|
|
@@ -1261,8 +1286,7 @@ function signInOptions(config, report) {
|
|
|
1261
1286
|
report("invalid-sign-in", `signIn.channels.${provider}`, 'Use "open" or "invited".');
|
|
1262
1287
|
}
|
|
1263
1288
|
else {
|
|
1264
|
-
|
|
1265
|
-
if (adapters?.[provider] === undefined) {
|
|
1289
|
+
if (!declaresChatKind(config.chat, provider)) {
|
|
1266
1290
|
report("invalid-sign-in", `signIn.channels.${provider}`, `Configure a matching chat.${provider} adapter.`);
|
|
1267
1291
|
}
|
|
1268
1292
|
channels[provider] = policy;
|
|
@@ -1427,8 +1451,7 @@ function signUpOptions(config, signIn, declaredRoles, report) {
|
|
|
1427
1451
|
: `${channel} is opened by signIn.channels too; declare it in signUp only.`);
|
|
1428
1452
|
}
|
|
1429
1453
|
if (SIGN_UP_CHAT_CHANNELS.includes(channel)) {
|
|
1430
|
-
|
|
1431
|
-
if (adapters?.[channel] === undefined) {
|
|
1454
|
+
if (!declaresChatKind(config.chat, channel)) {
|
|
1432
1455
|
report("invalid-sign-in", `signUp.channels`, `Signing up on ${channel} needs a matching chat.${channel} adapter.`);
|
|
1433
1456
|
}
|
|
1434
1457
|
}
|
|
@@ -1484,7 +1507,13 @@ const WEBSITE_ORIGIN_HINT = "Use an origin alone, such as https://www.example.co
|
|
|
1484
1507
|
/** The built-in `guest` roles `defineOntology({ guest })` made, as opposed to a declared one. */
|
|
1485
1508
|
const BUILT_IN_GUESTS = new WeakSet();
|
|
1486
1509
|
/** The guest keys `defineOntology({ guest })` takes. */
|
|
1487
|
-
const GUEST_KEYS = [
|
|
1510
|
+
const GUEST_KEYS = [
|
|
1511
|
+
"channels",
|
|
1512
|
+
"origins",
|
|
1513
|
+
"permissions",
|
|
1514
|
+
"botCheck",
|
|
1515
|
+
"confirmations",
|
|
1516
|
+
];
|
|
1488
1517
|
/**
|
|
1489
1518
|
* Where guests talk to the agent, and the built-in role `guest` with their permissions, when the
|
|
1490
1519
|
* definition declares `guest`. Every problem is reported; the role is made from the permissions
|
|
@@ -1545,6 +1574,10 @@ function guestOptions(config, report) {
|
|
|
1545
1574
|
if (!Array.isArray(options.permissions)) {
|
|
1546
1575
|
report("missing-permissions", "guest.permissions", 'List what every guest may do, such as permissions: ["lead:submit"]; [] grants nothing.');
|
|
1547
1576
|
}
|
|
1577
|
+
const botCheck = guestBotCheck(options.botCheck, report);
|
|
1578
|
+
if (options.confirmations !== undefined && typeof options.confirmations !== "boolean") {
|
|
1579
|
+
report("invalid-sign-in", "guest.confirmations", "confirmations is true to let guests confirm actions in the website's chat, or false.");
|
|
1580
|
+
}
|
|
1548
1581
|
const guest = role(GUEST_ROLE, {
|
|
1549
1582
|
description: "Every guest: a visitor of a declared website, who is no user.",
|
|
1550
1583
|
permissions: Array.isArray(options.permissions)
|
|
@@ -1552,7 +1585,49 @@ function guestOptions(config, report) {
|
|
|
1552
1585
|
: [],
|
|
1553
1586
|
});
|
|
1554
1587
|
BUILT_IN_GUESTS.add(guest);
|
|
1555
|
-
return {
|
|
1588
|
+
return {
|
|
1589
|
+
resolved: {
|
|
1590
|
+
channels,
|
|
1591
|
+
origins,
|
|
1592
|
+
...(botCheck === undefined ? {} : { botCheck }),
|
|
1593
|
+
...(options.confirmations === true ? { confirmations: true } : {}),
|
|
1594
|
+
},
|
|
1595
|
+
role: guest,
|
|
1596
|
+
};
|
|
1597
|
+
}
|
|
1598
|
+
/**
|
|
1599
|
+
* The challenge a new guest passes, as `guest.botCheck` declares it: the provider's scheme and the
|
|
1600
|
+
* workspace secret holding its secret key. Every problem is reported.
|
|
1601
|
+
*/
|
|
1602
|
+
function guestBotCheck(value, report) {
|
|
1603
|
+
if (value === undefined) {
|
|
1604
|
+
return undefined;
|
|
1605
|
+
}
|
|
1606
|
+
const shape = `guest.botCheck takes { scheme: "${GUEST_BOT_CHECK_SCHEMES[0]}", secret: "<workspace secret>" }: ` +
|
|
1607
|
+
"the challenge's provider and the workspace secret holding its secret key.";
|
|
1608
|
+
if (!isPlainObject(value)) {
|
|
1609
|
+
report("invalid-sign-in", "guest.botCheck", shape);
|
|
1610
|
+
return undefined;
|
|
1611
|
+
}
|
|
1612
|
+
for (const key of Object.keys(value)) {
|
|
1613
|
+
if (key !== "scheme" && key !== "secret") {
|
|
1614
|
+
report("invalid-sign-in", `guest.botCheck.${key}`, `Unknown botCheck key: ${key}. ${shape}`);
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
const { scheme, secret } = value;
|
|
1618
|
+
if (!isGuestBotCheckScheme(scheme)) {
|
|
1619
|
+
report("invalid-sign-in", "guest.botCheck.scheme", `${JSON.stringify(scheme) ?? "undefined"} is not a bot check; use one of ` +
|
|
1620
|
+
`${GUEST_BOT_CHECK_SCHEMES.join(", ")}.`);
|
|
1621
|
+
}
|
|
1622
|
+
if (typeof secret !== "string" || !WORKSPACE_SECRET_NAME.test(secret)) {
|
|
1623
|
+
report("invalid-sign-in", "guest.botCheck.secret", `${JSON.stringify(secret) ?? "undefined"} is not a workspace secret name; name the secret ` +
|
|
1624
|
+
"that holds the challenge's secret key, such as turnstile-secret-key.");
|
|
1625
|
+
}
|
|
1626
|
+
return isGuestBotCheckScheme(scheme) &&
|
|
1627
|
+
typeof secret === "string" &&
|
|
1628
|
+
WORKSPACE_SECRET_NAME.test(secret)
|
|
1629
|
+
? { scheme, secret }
|
|
1630
|
+
: undefined;
|
|
1556
1631
|
}
|
|
1557
1632
|
/** Whether a scope's `where` names `me` or a path from it anywhere. */
|
|
1558
1633
|
function usesMe(value) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Channels by name (`docs/agent.md`, "Channels"). The agent answers on channels its
|
|
4
|
+
* `agent/segmentstream.json` names, several of one kind if it likes: two WhatsApp numbers, a few
|
|
5
|
+
* Telegram bots, several mailboxes. The channel named after its kind, such as `telegram`, is that
|
|
6
|
+
* kind and keeps every key it always had; any other name says its `kind`. The ontology's `chat`
|
|
7
|
+
* takes the same names, so a reply a member approves, or a chat post, leaves through the connection
|
|
8
|
+
* of the channel the chat is on. Where the platform keys a chat by its `provider`, such as
|
|
9
|
+
* `agent_chat` and the archive, the value is the channel's name.
|
|
10
|
+
*/
|
|
11
|
+
/** The kinds of channel the platform sends to, as the agent's channels and `chat` name them. */
|
|
12
|
+
export declare const CHAT_CHANNEL_KINDS: readonly ["telegram", "slack", "whatsapp", "email"];
|
|
13
|
+
export type ChatChannelKind = (typeof CHAT_CHANNEL_KINDS)[number];
|
|
14
|
+
export declare function isChatChannelKind(value: unknown): value is ChatChannelKind;
|
|
15
|
+
/** A channel's name: a lower-case letter, then up to 31 lower-case letters, digits or `_`. */
|
|
16
|
+
export declare const CHAT_CHANNEL_NAME: RegExp;
|
|
17
|
+
export declare const ChatChannelName: Schema.String;
|
|
18
|
+
/**
|
|
19
|
+
* The kind of the channel `name`, by `chat`'s entries: the kind an entry names, or the name itself
|
|
20
|
+
* for the channel named after its kind. Undefined for a name that is neither.
|
|
21
|
+
*/
|
|
22
|
+
export declare function chatChannelKind(chat: Readonly<Record<string, unknown>> | undefined, name: string): ChatChannelKind | undefined;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Channels by name (`docs/agent.md`, "Channels"). The agent answers on channels its
|
|
4
|
+
* `agent/segmentstream.json` names, several of one kind if it likes: two WhatsApp numbers, a few
|
|
5
|
+
* Telegram bots, several mailboxes. The channel named after its kind, such as `telegram`, is that
|
|
6
|
+
* kind and keeps every key it always had; any other name says its `kind`. The ontology's `chat`
|
|
7
|
+
* takes the same names, so a reply a member approves, or a chat post, leaves through the connection
|
|
8
|
+
* of the channel the chat is on. Where the platform keys a chat by its `provider`, such as
|
|
9
|
+
* `agent_chat` and the archive, the value is the channel's name.
|
|
10
|
+
*/
|
|
11
|
+
/** The kinds of channel the platform sends to, as the agent's channels and `chat` name them. */
|
|
12
|
+
export const CHAT_CHANNEL_KINDS = ["telegram", "slack", "whatsapp", "email"];
|
|
13
|
+
export function isChatChannelKind(value) {
|
|
14
|
+
return CHAT_CHANNEL_KINDS.some((kind) => kind === value);
|
|
15
|
+
}
|
|
16
|
+
/** A channel's name: a lower-case letter, then up to 31 lower-case letters, digits or `_`. */
|
|
17
|
+
export const CHAT_CHANNEL_NAME = /^[a-z][a-z0-9_]{0,31}$/;
|
|
18
|
+
export const ChatChannelName = Schema.String.check(Schema.isPattern(CHAT_CHANNEL_NAME)).annotate({
|
|
19
|
+
description: "The channel's name, as the agent's channels and the ontology's chat name it: its kind, such " +
|
|
20
|
+
"as telegram, for the channel named after its kind.",
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* The kind of the channel `name`, by `chat`'s entries: the kind an entry names, or the name itself
|
|
24
|
+
* for the channel named after its kind. Undefined for a name that is neither.
|
|
25
|
+
*/
|
|
26
|
+
export function chatChannelKind(chat, name) {
|
|
27
|
+
const entry = chat?.[name];
|
|
28
|
+
const kind = entry !== null && typeof entry === "object" && "kind" in entry
|
|
29
|
+
? entry.kind
|
|
30
|
+
: undefined;
|
|
31
|
+
if (isChatChannelKind(name)) {
|
|
32
|
+
return kind === undefined || kind === name ? name : undefined;
|
|
33
|
+
}
|
|
34
|
+
return isChatChannelKind(kind) ? kind : undefined;
|
|
35
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type { ConfirmContext } from "./confirmation.js";
|
|
|
14
14
|
export type { Action, ActionConfig, ActionConfigWithConnections, ActionContext, ActionIdentity, ActionEncodedInput, ActionHints, ActionInput, ActionResult, ActionWriteTarget, Actions, AnyAction, PrepareContext, PrepareError, } from "./action.js";
|
|
15
15
|
export { CONNECTION_ERROR_REASONS, CONNECTION_KEY, CONNECTION_METHODS, connection, ConnectionError, Connections, ConnectionTransport, isConnection, MAXIMUM_CONNECTION_BODY_BYTES, MAXIMUM_CONNECTION_RESPONSE_BYTES, } from "./connection.js";
|
|
16
16
|
export type { AnyConnectionHandle, Connection, ConnectionCall, ConnectionClient, ConnectionErrorReason, ConnectionHandle, ConnectionHeaders, ConnectionMethod, ConnectionOptions, ConnectionReply, ConnectionRequest, ConnectionRequestOptions, ConnectionResponse, ConnectionStreamReply, ConnectionStreamResponse, ConnectionsOf, ConnectionStub, StubRequest, StubResponse, } from "./connection.js";
|
|
17
|
-
export type { DiscoveryOptions, EntityPermissions, JsonSchemaObject, MemberOptions, OntologyConfig, ResolvedAction, ResolvedConnection, ResolvedEntity, ResolvedIndex, ResolvedProperty, ResolvedRelationship, } from "./analyze.js";
|
|
17
|
+
export type { ChatChannelConfig, ChatConfig, DiscoveryOptions, EntityPermissions, JsonSchemaObject, MemberOptions, OntologyConfig, ResolvedAction, ResolvedConnection, ResolvedEntity, ResolvedIndex, ResolvedProperty, ResolvedRelationship, } from "./analyze.js";
|
|
18
18
|
export { Diagnostic, DIAGNOSTIC_CODES, formatDiagnostics, InvalidOntology } from "./diagnostics.js";
|
|
19
19
|
export type { DiagnosticCode } from "./diagnostics.js";
|
|
20
20
|
export { entity, isEntity } from "./entity.js";
|
|
@@ -48,12 +48,12 @@ 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, 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";
|
|
51
|
+
export { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_IN_METHODS, SIGN_IN_POLICIES, SIGN_UP_CHANNELS, GUEST_BOT_CHECK_SCHEMES, GUEST_CHANNELS, matchesWebsite, signUpOrigin, websiteOrigin, } from "./sign-in.js";
|
|
52
|
+
export type { ChannelProvider, GuestBotCheck, GuestBotCheckScheme, GuestChannel, GuestOptions, ResolvedGuest, ResolvedSignInOptions, ResolvedSignUp, SignInCheck, SignInMethod, SignInOptions, SignInPolicy, SignUpChannel, SignUpOptions, } from "./sign-in.js";
|
|
53
53
|
export type { EmailSection, EmailSectionItem, EmailTemplate } from "./emails.js";
|
|
54
54
|
export { OntologyActions, OntologyReads, OntologyRuntime, OntologyWrites } from "./runtime.js";
|
|
55
55
|
export type { ActionRunOptions } from "./runtime.js";
|
|
56
|
-
export type { BatchOptions, BatchRecordResult, BatchResult, BatchReturning, BatchSummaryResult, CreateManyInput, FieldCondition, OntologyRuntimeService, FindOptions, FreshMetricQueryOptions, GetOptions, Principal, RecordWhere, StoredRecord, StoredValues, UpsertResult, UpdateManyInput, UpsertManyInput, } from "./runtime.js";
|
|
56
|
+
export type { BatchOptions, BatchRecordResult, BatchResult, BatchReturning, BatchSummaryResult, ChatProvenance, CreateManyInput, FieldCondition, OntologyRuntimeService, FindOptions, FreshMetricQueryOptions, GetOptions, Principal, RecordWhere, StoredRecord, StoredValues, UpsertResult, UpdateManyInput, UpsertManyInput, } from "./runtime.js";
|
|
57
57
|
export { User } from "./user.js";
|
|
58
58
|
export type { UserHandle, UserMemberWrites } from "./user.js";
|
|
59
59
|
export { AgentChat } from "./agent-chat.js";
|
|
@@ -62,6 +62,8 @@ export { ATTACHABLE_IDENTITY_PROVIDERS, UserIdentity, USER_IDENTITY_ORIGINS, } f
|
|
|
62
62
|
export type { AttachableIdentityProvider, UserIdentityOrigin } from "./user-identity.js";
|
|
63
63
|
export { AppFeedback, AppFeedbackFile, APP_FEEDBACK_ENTITIES, APP_FEEDBACK_FILE_MAX_BYTES, } from "./app-feedback.js";
|
|
64
64
|
export { ChatDelivery, ChatPostInput, ChatPostResult } from "./chat.js";
|
|
65
|
+
export { CHAT_CHANNEL_KINDS, CHAT_CHANNEL_NAME } from "./chat-channel.js";
|
|
66
|
+
export type { ChatChannelKind } from "./chat-channel.js";
|
|
65
67
|
export type { ReviewSendInput, ReviewSendResult } from "./chat.js";
|
|
66
68
|
export { DEFAULT_QUERY_LIMIT, entityQueryResultSchema, entityQuerySchema, entityQuerySchemas, entityRecordSchema, FILTER_OPERATORS, LIST_FILTER_OPERATORS, MANY_QUANTIFIERS, MAX_IN_VALUES, MAX_QUERY_LIMIT, OrderBy, Query, queryFields, queryJsonSchema, queryLinks, QueryResult, queryResultJsonSchema, queryResultSchema, SortDirection, WHERE_COMBINATORS, } from "./query.js";
|
|
67
69
|
export type { EntityQuerySchemas, FieldFilter, FilterOperator, JsonRecord, ListFilterOperator, ManyFilter, QueryField, QueryLink, StorageType, Where, } from "./query.js";
|
|
@@ -86,9 +88,9 @@ export { configFromEnv, ENVIRONMENT_VARIABLES, NEON_AUTH_ENVIRONMENT_VARIABLES,
|
|
|
86
88
|
export type { ActionCommitted, AfterCommitHook, NeonAuthEnvironment, OntologyEnvironment, OntologyServiceConfig, } from "./service/config.js";
|
|
87
89
|
export type { Decide, DecisionRequest } from "./service/decisions.js";
|
|
88
90
|
export { IdentityInUse, NotInvited, OntologyBackend } 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";
|
|
91
|
+
export type { AgentIdentity, AgentMember, AgentLimits, AgentLimitScope, ChannelSignInInput, AgentResolution, ResolveIdentityInput, AgentPairing, AgentStore, AgentWebStore, GuestIssue, GuestUpgrade, 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
92
|
export { createOntologyService, ONTOLOGY_HASH_HEADER, REQUEST_ID_HEADER, } from "./service/service.js";
|
|
91
|
-
export { AGENT_PATH, AGENT_TOKEN_INTROSPECTION_PATH, AGENT_TOKENS_PATH, AGENT_VISITORS_PATH, } from "./service/agent/server.js";
|
|
93
|
+
export { AGENT_PATH, AGENT_TOKEN_INTROSPECTION_PATH, AGENT_TOKENS_PATH, AGENT_VISITORS_PATH, GUEST_EMAIL_CODE_PATH, GUEST_SIGN_UP_PATH, GUEST_USAGE_PATH, GUEST_LINK_PATH, } from "./service/agent/server.js";
|
|
92
94
|
export { AGENT_TASK_PATH, AGENT_TASK_RESULT_PATH } from "./service/agent/tasks.js";
|
|
93
95
|
export { WORKSPACE_SOURCE_PATH } from "./service/agent/source.js";
|
|
94
96
|
export { AGENT_WEB_CLIENT_ID, agentResource } from "./service/agent/web-tokens.js";
|
package/dist/index.js
CHANGED
|
@@ -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, GUEST_CHANNELS, matchesWebsite,
|
|
29
|
+
export { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_IN_METHODS, SIGN_IN_POLICIES, SIGN_UP_CHANNELS, GUEST_BOT_CHECK_SCHEMES, GUEST_CHANNELS, matchesWebsite,
|
|
30
30
|
// @legacy ontology.sign-up-origin-name
|
|
31
31
|
signUpOrigin, websiteOrigin, } from "./sign-in.js";
|
|
32
32
|
export { OntologyActions, OntologyReads, OntologyRuntime, OntologyWrites } from "./runtime.js";
|
|
@@ -36,6 +36,7 @@ export { AgentReview, AGENT_REVIEW_MODES, AGENT_REVIEW_STATUSES, AGENT_REVIEW_TE
|
|
|
36
36
|
export { ATTACHABLE_IDENTITY_PROVIDERS, UserIdentity, USER_IDENTITY_ORIGINS, } from "./user-identity.js";
|
|
37
37
|
export { AppFeedback, AppFeedbackFile, APP_FEEDBACK_ENTITIES, APP_FEEDBACK_FILE_MAX_BYTES, } from "./app-feedback.js";
|
|
38
38
|
export { ChatDelivery, ChatPostInput, ChatPostResult } from "./chat.js";
|
|
39
|
+
export { CHAT_CHANNEL_KINDS, CHAT_CHANNEL_NAME } from "./chat-channel.js";
|
|
39
40
|
// The query language of `find` and of the service's list, query and traversal routes.
|
|
40
41
|
export { DEFAULT_QUERY_LIMIT, entityQueryResultSchema, entityQuerySchema, entityQuerySchemas, entityRecordSchema, FILTER_OPERATORS, LIST_FILTER_OPERATORS, MANY_QUANTIFIERS, MAX_IN_VALUES, MAX_QUERY_LIMIT, OrderBy, Query, queryFields, queryJsonSchema, queryLinks, QueryResult, queryResultJsonSchema, queryResultSchema, SortDirection, WHERE_COMBINATORS, } from "./query.js";
|
|
41
42
|
// The SQL runtime: data access, the action pipeline, generated actions, history and principals.
|
|
@@ -56,7 +57,7 @@ export { IdentityInUse, NotInvited, OntologyBackend } from "./service/runtime-co
|
|
|
56
57
|
export { createOntologyService, ONTOLOGY_HASH_HEADER, REQUEST_ID_HEADER, } from "./service/service.js";
|
|
57
58
|
// The app's own agent: pairing channel accounts with members, and acting as them, or as a
|
|
58
59
|
// workflow's user in the tasks workflows hand it.
|
|
59
|
-
export { AGENT_PATH, AGENT_TOKEN_INTROSPECTION_PATH, AGENT_TOKENS_PATH, AGENT_VISITORS_PATH, } from "./service/agent/server.js";
|
|
60
|
+
export { AGENT_PATH, AGENT_TOKEN_INTROSPECTION_PATH, AGENT_TOKENS_PATH, AGENT_VISITORS_PATH, GUEST_EMAIL_CODE_PATH, GUEST_SIGN_UP_PATH, GUEST_USAGE_PATH, GUEST_LINK_PATH, } from "./service/agent/server.js";
|
|
60
61
|
export { AGENT_TASK_PATH, AGENT_TASK_RESULT_PATH } from "./service/agent/tasks.js";
|
|
61
62
|
export { WORKSPACE_SOURCE_PATH } from "./service/agent/source.js";
|
|
62
63
|
// Agent tokens: access tokens of a member's grant to the agent, which a browser shows the agent.
|