@segmentstream/ontology 0.110.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +7 -1
  3. package/dist/agent-review.d.ts +2 -0
  4. package/dist/agent-review.js +11 -1
  5. package/dist/analyze.d.ts +34 -34
  6. package/dist/analyze.js +49 -26
  7. package/dist/chat-channel.d.ts +22 -0
  8. package/dist/chat-channel.js +35 -0
  9. package/dist/index.d.ts +3 -1
  10. package/dist/index.js +1 -0
  11. package/dist/manifest.d.ts +100 -24
  12. package/dist/manifest.js +13 -4
  13. package/dist/migrate/model.d.ts +44 -0
  14. package/dist/runtime/agents.js +3 -0
  15. package/dist/runtime-source.d.ts +4 -0
  16. package/dist/runtime-source.js +5 -0
  17. package/dist/runtime.d.ts +4 -1
  18. package/dist/service/agent/protocol.d.ts +1 -0
  19. package/dist/service/agent/protocol.js +5 -0
  20. package/dist/service/agent/server.js +11 -0
  21. package/dist/service/authentication.d.ts +4 -3
  22. package/dist/service/authentication.js +10 -5
  23. package/dist/service/chat/delivery.js +9 -5
  24. package/dist/service/chat/envelope.d.ts +6 -0
  25. package/dist/service/chat/providers/index.d.ts +19 -9
  26. package/dist/service/chat/providers/index.js +31 -11
  27. package/dist/service/chat/reads.d.ts +6 -3
  28. package/dist/service/chat/reads.js +26 -14
  29. package/dist/service/chat/resolve.d.ts +6 -2
  30. package/dist/service/chat/resolve.js +7 -3
  31. package/dist/service/chat/review-delivery.d.ts +2 -2
  32. package/dist/service/chat/review-delivery.js +16 -8
  33. package/dist/service/chat/routes.js +2 -1
  34. package/dist/service/chat/schemas.d.ts +2 -0
  35. package/dist/service/chat/schemas.js +8 -1
  36. package/dist/service/mcp/server.js +2 -1
  37. package/dist/service/runtime-contract.d.ts +9 -0
  38. package/dist/service/schemas.d.ts +8 -0
  39. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
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
+
3
23
  ## 0.110.0
4
24
 
5
25
  History keeps the chat an action came from. The app's agent names the chat it acts in and its
package/README.md CHANGED
@@ -1552,8 +1552,14 @@ timeout, a 5xx or an answer naming no message is `uncertain`. The receipt's `mes
1552
1552
  `wamid…` Meta accepted; it has no URL, and a failure Meta reports later in delivery statuses does
1553
1553
  not change it.
1554
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
+
1555
1561
  `chat_list({ query?, chat?, after?, limit? })` returns eligible routing metadata and server-derived
1556
- 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.
1557
1563
  `chat` selects an exact ID/title. Choose an ID or exact title; ambiguous titles return candidates and never guess.
1558
1564
  Paired private chats have stable handles `telegram:private:<member UUID>`, and
1559
1565
  `slack:private:<member UUID>` or `whatsapp:private:<member UUID>` when that provider is declared.
@@ -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";
@@ -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({ managed: true, description: "The channel, for example telegram." }),
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 providers the built-in exact chat post delivers to, each through its connection, which
94
- * must be listed in `connections`. Only declared providers are destinations. A reply the agent
95
- * held for review is sent through the same connection. `email` names the mailbox the agent's
96
- * mail channel reads: only reviewed replies leave through it, never a chat post.
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";
@@ -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 providers `chat` may declare a posting connection for, in the order posting lists them. */
36
- const CHAT_PROVIDER_KEYS = ["telegram", "slack", "whatsapp", "email"];
37
- /** The `chat` providers reviewed replies leave through, but chat posts never reach. */
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 declared = isPlainObject(config.chat)
152
- ? CHAT_PROVIDER_KEYS.filter((name) => config.chat?.[name] !== undefined)
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
- ? Object.keys(config.chat).find((key) => key !== "attribution" && !CHAT_PROVIDER_KEYS.includes(key))
165
+ ? entries.find(([name]) => !CHAT_CHANNEL_NAME.test(name) || RESERVED_CHAT_NAMES.has(name))?.[0]
156
166
  : "chat";
157
- const malformed = declared.find((name) => {
158
- const provider = config.chat?.[name];
159
- return (!isPlainObject(provider) ||
160
- Object.keys(provider).some((key) => key !== "connection") ||
161
- !isConnection(provider.connection));
162
- });
163
- // Read only once every declared provider is well formed.
164
- const handles = malformed === undefined
165
- ? declared.map((name) => [name, config.chat[name].connection])
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 only ${CHAT_PROVIDER_KEYS.join(", ")} and attribution.`);
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 provider connection must be listed in connections.");
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 provider needs its own connection.");
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.map(([name, handle]) => [name, { connection: handle.key }])),
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 provider that only sends reviewed replies.
192
- const reaches = (entity) => handles.filter(([name]) => entity === "agent_review" || !REVIEW_ONLY_CHAT_PROVIDERS.has(name));
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
- const adapters = config.chat;
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
- const adapters = config.chat;
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
  }
@@ -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";
@@ -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";
package/dist/index.js CHANGED
@@ -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.
@@ -1,4 +1,5 @@
1
1
  import type { ChatAttributionSettings } from "./chat.js";
2
+ import { CHAT_CHANNEL_KINDS } from "./chat-channel.js";
2
3
  import { Effect, Schema } from "effect";
3
4
  import type { ResolvedConnection, ResolvedEntity } from "./analyze.js";
4
5
  import type { ResolvedFeedback } from "./feedback-config.js";
@@ -77,6 +78,9 @@ import { type ResolvedGuest, type ResolvedSignInOptions, type SignInPolicy } fro
77
78
  * guest passes and the workspace secret its verification reads, and `confirmations: true`, written
78
79
  * only when declared. Older readers ignore both: they ask new guests for no challenge, and keep
79
80
  * refusing guests the actions that need a confirmation.
81
+ * Within version 15, `chat` may carry `channels`, written only when declared: the agent's channels
82
+ * not named after their kind, such as `sales_whatsapp`, each with its `kind` and connection. Older
83
+ * readers ignore it and send nothing through those channels.
80
84
  */
81
85
  export declare const MANIFEST_VERSION = 15;
82
86
  /** The phrase used for a direction the author did not phrase. */
@@ -1043,10 +1047,11 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
1043
1047
  readonly delivers: Schema.optionalKey<Schema.Literal<true>>;
1044
1048
  }>>>;
1045
1049
  /**
1046
- * The providers whose chats the built-in exact chat post delivers to, each through its declared
1047
- * connection, and the attribution it adds. Absent, or without a provider, delivers nowhere.
1048
- * `email`, within version 15, is the mailbox reviewed replies to mail leave from; no chat post
1049
- * goes to it.
1050
+ * The agent's channels whose chats the built-in exact chat post delivers to, each through its
1051
+ * declared connection, and the attribution it adds. Absent, or without a channel, delivers
1052
+ * nowhere. The channel named after each kind has its key; `channels` holds the others by name,
1053
+ * with their kinds. `email`, within version 15, is the mailbox reviewed replies to mail leave
1054
+ * from; no chat post goes to it, nor to another channel of its kind.
1050
1055
  */
1051
1056
  readonly chat: Schema.optionalKey<Schema.Struct<{
1052
1057
  readonly telegram: Schema.optionalKey<Schema.Struct<{
@@ -1061,6 +1066,10 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
1061
1066
  readonly email: Schema.optionalKey<Schema.Struct<{
1062
1067
  readonly connection: Schema.String;
1063
1068
  }>>;
1069
+ readonly channels: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Struct<{
1070
+ readonly kind: Schema.Literals<readonly ["telegram", "slack", "whatsapp", "email"]>;
1071
+ readonly connection: Schema.String;
1072
+ }>>>;
1064
1073
  readonly attribution: Schema.optionalKey<Schema.Struct<{
1065
1074
  readonly template: Schema.optionalKey<Schema.String>;
1066
1075
  readonly separator: Schema.optionalKey<Schema.String>;
@@ -1312,6 +1321,12 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1312
1321
  readonly slack?: {
1313
1322
  readonly connection: string;
1314
1323
  } | undefined;
1324
+ readonly channels?: {
1325
+ readonly [x: string]: {
1326
+ readonly kind: "telegram" | "email" | "whatsapp" | "slack";
1327
+ readonly connection: string;
1328
+ };
1329
+ } | undefined;
1315
1330
  readonly attribution?: {
1316
1331
  readonly template?: string | undefined;
1317
1332
  readonly separator?: string | undefined;
@@ -1608,6 +1623,12 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1608
1623
  readonly slack?: {
1609
1624
  readonly connection: string;
1610
1625
  } | undefined;
1626
+ readonly channels?: {
1627
+ readonly [x: string]: {
1628
+ readonly kind: "telegram" | "email" | "whatsapp" | "slack";
1629
+ readonly connection: string;
1630
+ };
1631
+ } | undefined;
1611
1632
  readonly attribution?: {
1612
1633
  readonly template?: string | undefined;
1613
1634
  readonly separator?: string | undefined;
@@ -1904,6 +1925,12 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1904
1925
  readonly slack?: {
1905
1926
  readonly connection: string;
1906
1927
  } | undefined;
1928
+ readonly channels?: {
1929
+ readonly [x: string]: {
1930
+ readonly kind: "telegram" | "email" | "whatsapp" | "slack";
1931
+ readonly connection: string;
1932
+ };
1933
+ } | undefined;
1907
1934
  readonly attribution?: {
1908
1935
  readonly template?: string | undefined;
1909
1936
  readonly separator?: string | undefined;
@@ -2200,6 +2227,12 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2200
2227
  readonly slack?: {
2201
2228
  readonly connection: string;
2202
2229
  } | undefined;
2230
+ readonly channels?: {
2231
+ readonly [x: string]: {
2232
+ readonly kind: "telegram" | "email" | "whatsapp" | "slack";
2233
+ readonly connection: string;
2234
+ };
2235
+ } | undefined;
2203
2236
  readonly attribution?: {
2204
2237
  readonly template?: string | undefined;
2205
2238
  readonly separator?: string | undefined;
@@ -2630,10 +2663,11 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2630
2663
  readonly delivers: Schema.optionalKey<Schema.Literal<true>>;
2631
2664
  }>>>;
2632
2665
  /**
2633
- * The providers whose chats the built-in exact chat post delivers to, each through its declared
2634
- * connection, and the attribution it adds. Absent, or without a provider, delivers nowhere.
2635
- * `email`, within version 15, is the mailbox reviewed replies to mail leave from; no chat post
2636
- * goes to it.
2666
+ * The agent's channels whose chats the built-in exact chat post delivers to, each through its
2667
+ * declared connection, and the attribution it adds. Absent, or without a channel, delivers
2668
+ * nowhere. The channel named after each kind has its key; `channels` holds the others by name,
2669
+ * with their kinds. `email`, within version 15, is the mailbox reviewed replies to mail leave
2670
+ * from; no chat post goes to it, nor to another channel of its kind.
2637
2671
  */
2638
2672
  readonly chat: Schema.optionalKey<Schema.Struct<{
2639
2673
  readonly telegram: Schema.optionalKey<Schema.Struct<{
@@ -2648,6 +2682,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2648
2682
  readonly email: Schema.optionalKey<Schema.Struct<{
2649
2683
  readonly connection: Schema.String;
2650
2684
  }>>;
2685
+ readonly channels: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Struct<{
2686
+ readonly kind: Schema.Literals<readonly ["telegram", "slack", "whatsapp", "email"]>;
2687
+ readonly connection: Schema.String;
2688
+ }>>>;
2651
2689
  readonly attribution: Schema.optionalKey<Schema.Struct<{
2652
2690
  readonly template: Schema.optionalKey<Schema.String>;
2653
2691
  readonly separator: Schema.optionalKey<Schema.String>;
@@ -3020,10 +3058,11 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3020
3058
  readonly delivers: Schema.optionalKey<Schema.Literal<true>>;
3021
3059
  }>>>;
3022
3060
  /**
3023
- * The providers whose chats the built-in exact chat post delivers to, each through its declared
3024
- * connection, and the attribution it adds. Absent, or without a provider, delivers nowhere.
3025
- * `email`, within version 15, is the mailbox reviewed replies to mail leave from; no chat post
3026
- * goes to it.
3061
+ * The agent's channels whose chats the built-in exact chat post delivers to, each through its
3062
+ * declared connection, and the attribution it adds. Absent, or without a channel, delivers
3063
+ * nowhere. The channel named after each kind has its key; `channels` holds the others by name,
3064
+ * with their kinds. `email`, within version 15, is the mailbox reviewed replies to mail leave
3065
+ * from; no chat post goes to it, nor to another channel of its kind.
3027
3066
  */
3028
3067
  readonly chat: Schema.optionalKey<Schema.Struct<{
3029
3068
  readonly telegram: Schema.optionalKey<Schema.Struct<{
@@ -3038,6 +3077,10 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3038
3077
  readonly email: Schema.optionalKey<Schema.Struct<{
3039
3078
  readonly connection: Schema.String;
3040
3079
  }>>;
3080
+ readonly channels: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Struct<{
3081
+ readonly kind: Schema.Literals<readonly ["telegram", "slack", "whatsapp", "email"]>;
3082
+ readonly connection: Schema.String;
3083
+ }>>>;
3041
3084
  readonly attribution: Schema.optionalKey<Schema.Struct<{
3042
3085
  readonly template: Schema.optionalKey<Schema.String>;
3043
3086
  readonly separator: Schema.optionalKey<Schema.String>;
@@ -3281,6 +3324,12 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3281
3324
  readonly slack?: {
3282
3325
  readonly connection: string;
3283
3326
  } | undefined;
3327
+ readonly channels?: {
3328
+ readonly [x: string]: {
3329
+ readonly kind: "telegram" | "email" | "whatsapp" | "slack";
3330
+ readonly connection: string;
3331
+ };
3332
+ } | undefined;
3284
3333
  readonly attribution?: {
3285
3334
  readonly template?: string | undefined;
3286
3335
  readonly separator?: string | undefined;
@@ -3577,6 +3626,12 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3577
3626
  readonly slack?: {
3578
3627
  readonly connection: string;
3579
3628
  } | undefined;
3629
+ readonly channels?: {
3630
+ readonly [x: string]: {
3631
+ readonly kind: "telegram" | "email" | "whatsapp" | "slack";
3632
+ readonly connection: string;
3633
+ };
3634
+ } | undefined;
3580
3635
  readonly attribution?: {
3581
3636
  readonly template?: string | undefined;
3582
3637
  readonly separator?: string | undefined;
@@ -3879,6 +3934,12 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
3879
3934
  readonly slack?: {
3880
3935
  readonly connection: string;
3881
3936
  } | undefined;
3937
+ readonly channels?: {
3938
+ readonly [x: string]: {
3939
+ readonly kind: "telegram" | "email" | "whatsapp" | "slack";
3940
+ readonly connection: string;
3941
+ };
3942
+ } | undefined;
3882
3943
  readonly attribution?: {
3883
3944
  readonly template?: string | undefined;
3884
3945
  readonly separator?: string | undefined;
@@ -4175,6 +4236,12 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
4175
4236
  readonly slack?: {
4176
4237
  readonly connection: string;
4177
4238
  } | undefined;
4239
+ readonly channels?: {
4240
+ readonly [x: string]: {
4241
+ readonly kind: "telegram" | "email" | "whatsapp" | "slack";
4242
+ readonly connection: string;
4243
+ };
4244
+ } | undefined;
4178
4245
  readonly attribution?: {
4179
4246
  readonly template?: string | undefined;
4180
4247
  readonly separator?: string | undefined;
@@ -4382,21 +4449,30 @@ export declare function manifestHash(manifest: Readonly<Record<string, unknown>>
4382
4449
  * aggregates, top-level or inside arithmetic: `check` lets them name one property at most.
4383
4450
  */
4384
4451
  export declare function metricsManifest(resolved: ResolvedEntity): ReadonlyArray<MetricManifest>;
4452
+ /** `chat` as the manifest writes it: the channel of each kind, the other channels, attribution. */
4453
+ export interface ChatManifestInput {
4454
+ readonly telegram?: {
4455
+ readonly connection: string;
4456
+ };
4457
+ readonly slack?: {
4458
+ readonly connection: string;
4459
+ };
4460
+ readonly whatsapp?: {
4461
+ readonly connection: string;
4462
+ };
4463
+ readonly email?: {
4464
+ readonly connection: string;
4465
+ };
4466
+ readonly channels?: Readonly<Record<string, {
4467
+ readonly kind: (typeof CHAT_CHANNEL_KINDS)[number];
4468
+ readonly connection: string;
4469
+ }>>;
4470
+ readonly attribution?: ChatAttributionSettings;
4471
+ }
4385
4472
  /** Builds the manifest of a resolved ontology that passed `check`. */
4386
4473
  export declare function buildManifest(input: {
4387
4474
  readonly feedback?: ResolvedFeedback;
4388
- readonly chat?: {
4389
- readonly telegram?: {
4390
- readonly connection: string;
4391
- };
4392
- readonly slack?: {
4393
- readonly connection: string;
4394
- };
4395
- readonly whatsapp?: {
4396
- readonly connection: string;
4397
- };
4398
- readonly attribution?: ChatAttributionSettings;
4399
- };
4475
+ readonly chat?: ChatManifestInput;
4400
4476
  readonly entities: ReadonlyArray<ResolvedEntity>;
4401
4477
  readonly roles: ReadonlyArray<Role>;
4402
4478
  readonly signIn: ResolvedSignInOptions;