@segmentstream/ontology 0.123.0 → 0.124.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.124.0
4
+
5
+ Staff take an inbox chat over from the agent. `agent_chat.takeOver({ chat })` sets the record's new
6
+ `handledBy` relationship to the member (`agent_chat:take_over`), `agent_chat.handBack({ chat })`
7
+ clears it (`agent_chat:hand_back`), and a chat another member holds is refused until it is handed
8
+ back. `inbox.takeover.channels` names the channels of `chat` where staff take chats over: every one
9
+ of them when absent, none with `[]`; `check` reports `invalid-inbox` for an undeclared channel and
10
+ for `web`, whose visitors' page staff replies do not reach yet. Where takeover is open, the answer
11
+ to the agent's admission says `takeover: true` and the report of a private chat says
12
+ `handled: true` while staff hold it. The generated `update` of a built-in entity no longer takes
13
+ its relationships.
14
+
3
15
  ## 0.123.0
4
16
 
5
17
  `memoryFileStorage()` keeps an ontology's files in memory, so tests that run actions in process can
package/README.md CHANGED
@@ -1389,17 +1389,17 @@ task header on any other route are a 403.
1389
1389
 
1390
1390
  Without either header the agent may call only the agent routes:
1391
1391
 
1392
- | Route | Caller | Does |
1393
- | ------------------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------- |
1394
- | `POST /api/ontology/agent/pairings` | agent | `{ provider, external_id, display? }` → `{ code, expires_at }` |
1395
- | `GET /api/ontology/agent/pairings/{code}` | member | `{ provider, display, expires_at }`, for the connect page |
1396
- | `POST /api/ontology/agent/pairings/{code}/approve` | member | Pairs the account with the member → `{ identity }` |
1397
- | `POST /api/ontology/agent/identities/resolve` | agent | Admission and turn limits; see below |
1398
- | `POST /api/ontology/agent/identities/notice` | agent | `{ provider, external_id, sha256, version? }` acknowledges notice delivery: 204 |
1399
- | `GET /api/ontology/agent/identities/{provider}/{external_id}` | agent | `{ user: { id, name }, roles, agent_tools }`; 404 unpaired, 403 revoked, inactive |
1400
- | `GET /api/ontology/agent/identities` | member | `{ identities }`: the member's live identities |
1401
- | `DELETE /api/ontology/agent/identities/{id}` | member | Revokes one of them: 204 |
1402
- | `POST /api/ontology/agent/chats/seen` | agent | `{ provider, externalId, title, memberId?, leftMemberId?, agentLeft?, migratedFrom? }` → `{ id, title, purpose, whenToUse }` |
1392
+ | Route | Caller | Does |
1393
+ | ------------------------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------- |
1394
+ | `POST /api/ontology/agent/pairings` | agent | `{ provider, external_id, display? }` → `{ code, expires_at }` |
1395
+ | `GET /api/ontology/agent/pairings/{code}` | member | `{ provider, display, expires_at }`, for the connect page |
1396
+ | `POST /api/ontology/agent/pairings/{code}/approve` | member | Pairs the account with the member → `{ identity }` |
1397
+ | `POST /api/ontology/agent/identities/resolve` | agent | Admission and turn limits; see below |
1398
+ | `POST /api/ontology/agent/identities/notice` | agent | `{ provider, external_id, sha256, version? }` acknowledges notice delivery: 204 |
1399
+ | `GET /api/ontology/agent/identities/{provider}/{external_id}` | agent | `{ user: { id, name }, roles, agent_tools }`; 404 unpaired, 403 revoked, inactive |
1400
+ | `GET /api/ontology/agent/identities` | member | `{ identities }`: the member's live identities |
1401
+ | `DELETE /api/ontology/agent/identities/{id}` | member | Revokes one of them: 204 |
1402
+ | `POST /api/ontology/agent/chats/seen` | agent | `{ provider, externalId, title, memberId?, leftMemberId?, agentLeft?, migratedFrom? }` → `{ id, title, purpose, whenToUse, handled? }` |
1403
1403
 
1404
1404
  A pairing code is eight characters without look-alikes (no 0, O, 1, I or L), stored as its
1405
1405
  SHA-256, valid ten minutes and used once. Each instance allows a client address 60 new
@@ -1419,8 +1419,10 @@ database an earlier SDK migrated. Additive migrations also create `_agent_counte
1419
1419
  display?, username?, notice_version?, notice_sha256?, limits? }` with a verified runtime token.
1420
1420
  It returns 200 with `status`:
1421
1421
 
1422
- - `created` or `existing`: `{ user: { id, name }, roles, agent_tools, provisioned, notice_due, on_new_user_pending }`.
1422
+ - `created` or `existing`: `{ user: { id, name }, roles, agent_tools, provisioned, notice_due, on_new_user_pending, inbox?, takeover? }`.
1423
1423
  `agent_tools` names the agent's own tools the user's roles grant, such as `sandbox`.
1424
+ `inbox: true` asks the agent to report the private chat to `chats/seen`; `takeover: true` asks it to
1425
+ report every message there, and to answer none while the report says `handled: true`.
1424
1426
  The optional onboarding hook has already been attempted before this response; pending means retry.
1425
1427
  - `pairing_required`: unknown account on an invited channel, in a group, or with `turn: false`.
1426
1428
  - `refused`: `{ reason: "blocked" | "inactive" }`; revoked bindings also return `blocked` and never re-create.
@@ -1523,7 +1525,8 @@ old id of a group that became a supergroup, it moves the old record to `external
1523
1525
  both are recorded, moves the members and a missing `purpose` and `whenToUse` to the new one and
1524
1526
  deletes the old one. `provider`, `externalId`, `title` and `lastMessageAt` are
1525
1527
  managed. Members set `purpose` and `whenToUse` with the generated
1526
- `agent_chat.update`, the chat's only generated action. Chat read/update permissions remain
1528
+ `agent_chat.update`, the chat's only generated action, which sets no relationship: `handledBy`
1529
+ changes only through `agent_chat.takeOver` and `agent_chat.handBack`. Chat read/update permissions remain
1527
1530
  `agent_chat:read` and `agent_chat:update`, granted explicitly; wildcard entity grants do not
1528
1531
  cover this built-in registry.
1529
1532
 
@@ -1,3 +1,4 @@
1
+ import { Schema } from "effect";
1
2
  export declare const TELEGRAM = "telegram";
2
3
  /** Existing chat registry and membership storage; delivery lives in the ontology service. */
3
4
  export declare const AgentChat: import("./entity.js").Entity<"agent_chat", {
@@ -5,25 +6,38 @@ export declare const AgentChat: import("./entity.js").Entity<"agent_chat", {
5
6
  readonly kind: import("./property.js").Property<"group" | "private", true, false>;
6
7
  readonly externalId: import("./property.js").Property<string, false, false>;
7
8
  readonly title: import("./property.js").Property<string, false, false>;
8
- readonly recipient: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
9
- readonly threadId: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
10
- readonly lastMessageAt: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
11
- readonly purpose: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
12
- readonly whenToUse: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
9
+ readonly recipient: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
10
+ readonly threadId: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
11
+ readonly lastMessageAt: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
12
+ readonly purpose: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
13
+ readonly whenToUse: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
13
14
  }, {
14
15
  readonly members: import("./relationship.js").ManyRelationship;
16
+ readonly handledBy: import("./relationship.js").OneRelationship<true, false, "user">;
15
17
  }, import("./entity.js").InvocableActions<{
16
- readonly previewMessage: import("./action.js").Action<import("effect/Schema").Struct<{
17
- readonly chat: import("effect/Schema").String;
18
- readonly text: import("effect/Schema").String;
19
- readonly replyTo: import("effect/Schema").optionalKey<import("effect/Schema").String>;
20
- readonly idempotencyKey: import("effect/Schema").String;
18
+ readonly takeOver: import("./action.js").Action<Schema.Struct<{
19
+ readonly chat: Schema.Codec<string, string, never, never>;
20
+ }>, {
21
+ chat: string;
22
+ handled_by: string;
23
+ }>;
24
+ readonly handBack: import("./action.js").Action<Schema.Struct<{
25
+ readonly chat: Schema.Codec<string, string, never, never>;
26
+ }>, {
27
+ chat: string;
28
+ handled_by: null;
29
+ }>;
30
+ readonly previewMessage: import("./action.js").Action<Schema.Struct<{
31
+ readonly chat: Schema.String;
32
+ readonly text: Schema.String;
33
+ readonly replyTo: Schema.optionalKey<Schema.String>;
34
+ readonly idempotencyKey: Schema.String;
21
35
  }>, import("./chat.js").ChatPreview>;
22
- readonly postMessage: import("./action.js").Action<import("effect/Schema").Struct<{
23
- readonly chat: import("effect/Schema").String;
24
- readonly text: import("effect/Schema").String;
25
- readonly replyTo: import("effect/Schema").optionalKey<import("effect/Schema").String>;
26
- readonly idempotencyKey: import("effect/Schema").String;
36
+ readonly postMessage: import("./action.js").Action<Schema.Struct<{
37
+ readonly chat: Schema.String;
38
+ readonly text: Schema.String;
39
+ readonly replyTo: Schema.optionalKey<Schema.String>;
40
+ readonly idempotencyKey: Schema.String;
27
41
  }>, {
28
42
  readonly status: "sent" | "uncertain";
29
43
  readonly message_id: string | null;
@@ -46,5 +60,6 @@ export declare const AgentChat: import("./entity.js").Entity<"agent_chat", {
46
60
  readonly lastMessageAt: string | null;
47
61
  readonly purpose: string | null;
48
62
  readonly whenToUse: string | null;
63
+ readonly handledById: string | null;
49
64
  }>, Readonly<Record<never, never>>, "generated">;
50
65
  export type AgentChat = typeof AgentChat.Type;
@@ -1,4 +1,4 @@
1
- import { Effect, Option } from "effect";
1
+ import { Effect, Option, Schema } from "effect";
2
2
  import { action } from "./action.js";
3
3
  import { entity } from "./entity.js";
4
4
  import { ActionRejected } from "./errors.js";
@@ -72,9 +72,73 @@ export const AgentChat = entity("agent_chat", {
72
72
  description: "Workspace members the agent has seen writing in the chat; a private chat's one member " +
73
73
  "is its person.",
74
74
  }),
75
+ handledBy: rel.one("user", {
76
+ optional: true,
77
+ inverse: "handledAgentChats",
78
+ onDelete: "setNull",
79
+ phrase: ["is handled by", "handles"],
80
+ description: "The member of staff who took the chat over from the agent: while set, the agent records " +
81
+ "the person's messages and answers none of them. Empty while the agent answers.",
82
+ }),
75
83
  },
76
84
  indexes: [{ properties: ["provider", "externalId"], unique: true }],
77
- }).actions(() => ({
85
+ }).actions((self) => ({
86
+ takeOver: action({
87
+ description: "Take a person's private chat over from the agent, as yourself: until a member hands it " +
88
+ "back, the agent records the person's messages and answers none of them, and staff answer " +
89
+ "with postMessage. Refused for a group chat, for a chat on a channel the ontology's " +
90
+ "inbox.takeover does not list, and for a chat another member took over; taking over a " +
91
+ "chat you hold changes nothing.",
92
+ hints: { destructive: false, irreversible: false, idempotent: true },
93
+ input: Schema.Struct({ chat: self.ref }),
94
+ handler: ({ input, principal }) => Effect.gen(function* () {
95
+ const delivery = yield* Effect.serviceOption(ChatDelivery);
96
+ const channels = Option.isSome(delivery) ? delivery.value.takeoverChannels : undefined;
97
+ if (principal.kind !== "member") {
98
+ return yield* new ActionRejected({ message: "Only a member takes a chat over." });
99
+ }
100
+ if (channels === undefined) {
101
+ return yield* new ActionRejected({
102
+ message: "Taking a chat over requires the authenticated ontology service.",
103
+ });
104
+ }
105
+ const chat = yield* self.get(input.chat, { forUpdate: true });
106
+ if (chat.kind !== "private") {
107
+ return yield* new ActionRejected({
108
+ message: "Only a person's private chat is taken over: in a group the agent answers " +
109
+ "only those who address it.",
110
+ });
111
+ }
112
+ if (!channels.has(chat.provider)) {
113
+ return yield* new ActionRejected({
114
+ message: `Chats on ${chat.provider} are not taken over: inbox.takeover does not list ` +
115
+ "the channel.",
116
+ });
117
+ }
118
+ if (chat.handledById !== null && chat.handledById !== principal.id) {
119
+ return yield* new ActionRejected({
120
+ message: "Another member has taken the chat over: hand it back first.",
121
+ });
122
+ }
123
+ if (chat.handledById === null) {
124
+ yield* self.update(chat, { handledBy: principal.id });
125
+ }
126
+ return { chat: chat.id, handled_by: principal.id };
127
+ }),
128
+ }),
129
+ handBack: action({
130
+ description: "Hand a chat a member took over back to the agent, which answers the person's next " +
131
+ "message with what was said meanwhile in its context. A chat no one holds changes nothing.",
132
+ hints: { destructive: false, irreversible: false, idempotent: true },
133
+ input: Schema.Struct({ chat: self.ref }),
134
+ handler: ({ input }) => Effect.gen(function* () {
135
+ const chat = yield* self.get(input.chat, { forUpdate: true });
136
+ if (chat.handledById !== null) {
137
+ yield* self.update(chat, { handledBy: null });
138
+ }
139
+ return { chat: chat.id, handled_by: null };
140
+ }),
141
+ }),
78
142
  previewMessage: action({
79
143
  description: "Render an exact chat message with its verified destination and sender attribution, without reserving a key, " +
80
144
  "writing history or sending. Requires the same explicit post permission as delivery. " +
package/dist/analyze.d.ts CHANGED
@@ -233,6 +233,10 @@ export interface Analysis {
233
233
  /** The wire names of the roles whose private chats join the inbox, when declared. */
234
234
  readonly inbox?: {
235
235
  readonly roles: ReadonlyArray<string>;
236
+ /** The channels whose private chats staff may take over from the agent. */
237
+ readonly takeover: {
238
+ readonly channels: ReadonlyArray<string>;
239
+ };
236
240
  };
237
241
  readonly entities: ReadonlyArray<ResolvedEntity>;
238
242
  /** The workspace-owned `member` role and declared roles, then the implicit reporter when enabled. */
package/dist/analyze.js CHANGED
@@ -102,7 +102,11 @@ export function analyze(config, options = {}) {
102
102
  ...(linkEmail === undefined ? {} : { linkEmail }),
103
103
  ...(codeEmail === undefined ? {} : { codeEmail }),
104
104
  };
105
- const inbox = inboxOptions(config.inbox, declaredRoles, guest !== undefined, report);
105
+ const inbox = inboxOptions(config.inbox, declaredRoles, guest !== undefined, isPlainObject(config.chat)
106
+ ? Object.entries(config.chat)
107
+ .filter(([name, channel]) => name !== "attribution" && channel !== undefined)
108
+ .map(([name]) => name)
109
+ : [], report);
106
110
  const discovery = config.discovery;
107
111
  if (discovery !== undefined &&
108
112
  (!isPlainObject(discovery) ||
@@ -349,21 +353,25 @@ export function analyze(config, options = {}) {
349
353
  }
350
354
  /**
351
355
  * `inbox`: the wire names of the roles whose private chats join the inbox, each a declared role or
352
- * `member`; `undefined` when absent or malformed.
356
+ * `member`, and the channels whose chats staff may take over: those `takeover.channels` lists, or
357
+ * every channel `chat` declares; `undefined` when absent or malformed.
353
358
  */
354
359
  function inboxOptions(value, declaredRoles,
355
360
  /** Whether the ontology declares `guest`, whose visitors' chats the inbox may take. */
356
- guests, report) {
361
+ guests,
362
+ /** The names of the channels `chat` declares. */
363
+ chatChannels, report) {
357
364
  if (value === undefined) {
358
365
  return undefined;
359
366
  }
360
367
  if (!isPlainObject(value) ||
361
- Object.keys(value).some((key) => key !== "roles") ||
368
+ Object.keys(value).some((key) => key !== "roles" && key !== "takeover") ||
362
369
  !Array.isArray(value.roles) ||
363
370
  value.roles.length === 0) {
364
- report("invalid-inbox", "inbox", "inbox takes { roles: [...] }, at least one role.");
371
+ report("invalid-inbox", "inbox", "inbox takes { roles: [...], takeover?: { channels?: [...] } }, at least one role.");
365
372
  return undefined;
366
373
  }
374
+ const takeover = takeoverOptions(value.takeover, chatChannels, report);
367
375
  const declared = new Set(declaredRoles.map((candidate) => candidate.name));
368
376
  if (guests) {
369
377
  declared.add(GUEST_ROLE);
@@ -384,7 +392,43 @@ guests, report) {
384
392
  roles.push(name);
385
393
  }
386
394
  });
387
- return valid ? { roles } : undefined;
395
+ return valid && takeover !== undefined ? { roles, takeover } : undefined;
396
+ }
397
+ /**
398
+ * `inbox.takeover`: the channels whose private chats staff may take over from the agent, each a
399
+ * channel `chat` declares, since staff answer through it; every one of them when `channels` is
400
+ * absent. The website's chat is none of them: staff replies do not reach it yet.
401
+ */
402
+ function takeoverOptions(value, chatChannels, report) {
403
+ if (value === undefined) {
404
+ return { channels: chatChannels };
405
+ }
406
+ if (!isPlainObject(value) ||
407
+ Object.keys(value).some((key) => key !== "channels") ||
408
+ (value.channels !== undefined && !Array.isArray(value.channels))) {
409
+ report("invalid-inbox", "inbox.takeover", "inbox.takeover takes { channels?: [...] }.");
410
+ return undefined;
411
+ }
412
+ if (value.channels === undefined) {
413
+ return { channels: chatChannels };
414
+ }
415
+ const channels = [];
416
+ let valid = true;
417
+ value.channels.forEach((candidate, index) => {
418
+ const path = `inbox.takeover.channels[${index}]`;
419
+ if (candidate === "web") {
420
+ report("invalid-inbox", path, "The website's chat is not taken over yet: staff replies do not reach it.");
421
+ valid = false;
422
+ }
423
+ else if (typeof candidate !== "string" || !chatChannels.includes(candidate)) {
424
+ report("invalid-inbox", path, "Use a channel chat declares: staff answer a chat they took over through it.");
425
+ valid = false;
426
+ }
427
+ else if (!channels.includes(candidate)) {
428
+ channels.push(candidate);
429
+ }
430
+ });
431
+ return valid ? { channels } : undefined;
388
432
  }
389
433
  /**
390
434
  * Warns where workspace code declares a field by the name an earlier SDK gave it, naming the current
package/dist/chat.d.ts CHANGED
@@ -10,6 +10,14 @@ export interface ChatAttributionSettings {
10
10
  */
11
11
  export interface InboxOptions<R = unknown> {
12
12
  readonly roles: ReadonlyArray<R>;
13
+ /**
14
+ * Where staff may take a chat over from the agent, which then records the person's messages and
15
+ * answers none until a member hands it back: `channels` lists channels `chat` declares, `[]` for
16
+ * none; absent, every channel `chat` declares. The website's chat is none of them yet.
17
+ */
18
+ readonly takeover?: {
19
+ readonly channels?: ReadonlyArray<string>;
20
+ };
13
21
  }
14
22
  import { Context, Effect, Schema } from "effect";
15
23
  import type { ActionError } from "./errors.js";
@@ -60,6 +68,8 @@ declare const ChatDelivery_base: Context.ServiceClass<ChatDelivery, "@segmentstr
60
68
  readonly post: (input: ChatPostInput) => Effect.Effect<ChatPostResult, ActionError>;
61
69
  /** Sends a reply a member approved, as the agent and without attribution, at most once. */
62
70
  readonly sendReview?: (input: ReviewSendInput) => Effect.Effect<ReviewSendResult, ActionError>;
71
+ /** The channels whose private chats staff may take over, as the ontology's inbox lists them. */
72
+ readonly takeoverChannels?: ReadonlySet<string>;
63
73
  }>;
64
74
  /** Deliver the exact Markdown source through the channel renderer, without invoking an agent. */
65
75
  export declare class ChatDelivery extends ChatDelivery_base {
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, GuestManifest, guestOf, signInPolicyOf, channelPolicyOf, signUpOriginsOf, inboxRolesOf, signUpRolesOf, } from "./manifest.js";
27
+ export { ActionManifest, actionConnectionKeys, canonicalJson, ConnectionManifest, EntityManifest, EntityPermissionsManifest, decodeManifestDocument, encodeManifest, formatManifest, IndexManifest, isValueMatched, MANIFEST_VERSION, manifestHash, ModelMetricManifest, OntologyManifest, OntologyManifestWire, PropertyManifest, RelationshipManifest, RoleManifest, ActionTriggerManifest, ScopeManifest, CronTriggerManifest, isActionTrigger, isCronTrigger, isWebhookTrigger, OtherTriggerManifest, WebhookTriggerManifest, WorkflowManifest, WorkflowTriggerManifest, SelectOptionManifest, SignInManifest, GuestManifest, guestOf, signInPolicyOf, channelPolicyOf, signUpOriginsOf, inboxRolesOf, takeoverChannelsOf, 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";
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, GuestManifest, guestOf, signInPolicyOf, channelPolicyOf, signUpOriginsOf, inboxRolesOf, signUpRolesOf, } from "./manifest.js";
16
+ export { ActionManifest, actionConnectionKeys, canonicalJson, ConnectionManifest, EntityManifest, EntityPermissionsManifest, decodeManifestDocument, encodeManifest, formatManifest, IndexManifest, isValueMatched, MANIFEST_VERSION, manifestHash, ModelMetricManifest, OntologyManifest, OntologyManifestWire, PropertyManifest, RelationshipManifest, RoleManifest, ActionTriggerManifest, ScopeManifest, CronTriggerManifest, isActionTrigger, isCronTrigger, isWebhookTrigger, OtherTriggerManifest, WebhookTriggerManifest, WorkflowManifest, WorkflowTriggerManifest, SelectOptionManifest, SignInManifest, GuestManifest, guestOf, signInPolicyOf, channelPolicyOf, signUpOriginsOf, inboxRolesOf, takeoverChannelsOf, 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";
@@ -91,7 +91,8 @@ import { type ResolvedGuest, type ResolvedSignInOptions, type SignInPolicy } fro
91
91
  * `channel:<name>`, its people's accounts.
92
92
  * Within version 15, the top-level `inbox`, written only when declared, holds the wire names of the
93
93
  * `roles` whose people's private chats the agent registers as `agent_chat` records of kind
94
- * `private`. Older readers ignore it and register none.
94
+ * `private`, and in `takeover.channels` the channels whose chats staff may take over from the
95
+ * agent. Older readers ignore it, register none and let none be taken over.
95
96
  */
96
97
  export declare const MANIFEST_VERSION = 15;
97
98
  /** The phrase used for a direction the author did not phrase. */
@@ -1179,11 +1180,16 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
1179
1180
  }>>;
1180
1181
  }>>;
1181
1182
  /**
1182
- * Whose private chats join the inbox, within version 15: the wire names of their roles. Written
1183
- * only when declared; absent registers no private chat, and older readers ignore it.
1183
+ * Whose private chats join the inbox, within version 15: the wire names of their roles, and the
1184
+ * channels whose chats staff may take over from the agent. Written only when declared; absent
1185
+ * registers no private chat, absent `takeover` lets no chat be taken over, and older readers
1186
+ * ignore both.
1184
1187
  */
1185
1188
  readonly inbox: Schema.optionalKey<Schema.Struct<{
1186
1189
  readonly roles: Schema.$Array<Schema.String>;
1190
+ readonly takeover: Schema.optionalKey<Schema.Struct<{
1191
+ readonly channels: Schema.$Array<Schema.String>;
1192
+ }>>;
1187
1193
  }>>;
1188
1194
  /**
1189
1195
  * The metrics of the model, since version 8. Written only when there are some; absent reads as
@@ -1595,6 +1601,9 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1595
1601
  } | undefined;
1596
1602
  readonly inbox?: {
1597
1603
  readonly roles: readonly string[];
1604
+ readonly takeover?: {
1605
+ readonly channels: readonly string[];
1606
+ } | undefined;
1598
1607
  } | undefined;
1599
1608
  readonly toolsets?: readonly {
1600
1609
  readonly name: string;
@@ -1912,6 +1921,9 @@ export declare const OntologyManifest: Schema.declareConstructor<{
1912
1921
  } | undefined;
1913
1922
  readonly inbox?: {
1914
1923
  readonly roles: readonly string[];
1924
+ readonly takeover?: {
1925
+ readonly channels: readonly string[];
1926
+ } | undefined;
1915
1927
  } | undefined;
1916
1928
  readonly toolsets?: readonly {
1917
1929
  readonly name: string;
@@ -2194,6 +2206,9 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2194
2206
  } | undefined;
2195
2207
  readonly inbox?: {
2196
2208
  readonly roles: readonly string[];
2209
+ readonly takeover?: {
2210
+ readonly channels: readonly string[];
2211
+ } | undefined;
2197
2212
  } | undefined;
2198
2213
  readonly toolsets?: readonly {
2199
2214
  readonly name: string;
@@ -2546,6 +2561,9 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2546
2561
  } | undefined;
2547
2562
  readonly inbox?: {
2548
2563
  readonly roles: readonly string[];
2564
+ readonly takeover?: {
2565
+ readonly channels: readonly string[];
2566
+ } | undefined;
2549
2567
  } | undefined;
2550
2568
  readonly toolsets?: readonly {
2551
2569
  readonly name: string;
@@ -2891,11 +2909,16 @@ export declare const OntologyManifest: Schema.declareConstructor<{
2891
2909
  }>>;
2892
2910
  }>>;
2893
2911
  /**
2894
- * Whose private chats join the inbox, within version 15: the wire names of their roles. Written
2895
- * only when declared; absent registers no private chat, and older readers ignore it.
2912
+ * Whose private chats join the inbox, within version 15: the wire names of their roles, and the
2913
+ * channels whose chats staff may take over from the agent. Written only when declared; absent
2914
+ * registers no private chat, absent `takeover` lets no chat be taken over, and older readers
2915
+ * ignore both.
2896
2916
  */
2897
2917
  readonly inbox: Schema.optionalKey<Schema.Struct<{
2898
2918
  readonly roles: Schema.$Array<Schema.String>;
2919
+ readonly takeover: Schema.optionalKey<Schema.Struct<{
2920
+ readonly channels: Schema.$Array<Schema.String>;
2921
+ }>>;
2899
2922
  }>>;
2900
2923
  /**
2901
2924
  * The metrics of the model, since version 8. Written only when there are some; absent reads as
@@ -3322,11 +3345,16 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3322
3345
  }>>;
3323
3346
  }>>;
3324
3347
  /**
3325
- * Whose private chats join the inbox, within version 15: the wire names of their roles. Written
3326
- * only when declared; absent registers no private chat, and older readers ignore it.
3348
+ * Whose private chats join the inbox, within version 15: the wire names of their roles, and the
3349
+ * channels whose chats staff may take over from the agent. Written only when declared; absent
3350
+ * registers no private chat, absent `takeover` lets no chat be taken over, and older readers
3351
+ * ignore both.
3327
3352
  */
3328
3353
  readonly inbox: Schema.optionalKey<Schema.Struct<{
3329
3354
  readonly roles: Schema.$Array<Schema.String>;
3355
+ readonly takeover: Schema.optionalKey<Schema.Struct<{
3356
+ readonly channels: Schema.$Array<Schema.String>;
3357
+ }>>;
3330
3358
  }>>;
3331
3359
  /**
3332
3360
  * The metrics of the model, since version 8. Written only when there are some; absent reads as
@@ -3730,6 +3758,9 @@ export declare const OntologyManifest: Schema.declareConstructor<{
3730
3758
  } | undefined;
3731
3759
  readonly inbox?: {
3732
3760
  readonly roles: readonly string[];
3761
+ readonly takeover?: {
3762
+ readonly channels: readonly string[];
3763
+ } | undefined;
3733
3764
  } | undefined;
3734
3765
  readonly toolsets?: readonly {
3735
3766
  readonly name: string;
@@ -4047,6 +4078,9 @@ export declare const OntologyManifest: Schema.declareConstructor<{
4047
4078
  } | undefined;
4048
4079
  readonly inbox?: {
4049
4080
  readonly roles: readonly string[];
4081
+ readonly takeover?: {
4082
+ readonly channels: readonly string[];
4083
+ } | undefined;
4050
4084
  } | undefined;
4051
4085
  readonly toolsets?: readonly {
4052
4086
  readonly name: string;
@@ -4370,6 +4404,9 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
4370
4404
  } | undefined;
4371
4405
  readonly inbox?: {
4372
4406
  readonly roles: readonly string[];
4407
+ readonly takeover?: {
4408
+ readonly channels: readonly string[];
4409
+ } | undefined;
4373
4410
  } | undefined;
4374
4411
  readonly toolsets?: readonly {
4375
4412
  readonly name: string;
@@ -4687,6 +4724,9 @@ export declare const decodeManifestDocument: (value: unknown) => Effect.Effect<{
4687
4724
  } | undefined;
4688
4725
  readonly inbox?: {
4689
4726
  readonly roles: readonly string[];
4727
+ readonly takeover?: {
4728
+ readonly channels: readonly string[];
4729
+ } | undefined;
4690
4730
  } | undefined;
4691
4731
  readonly toolsets?: readonly {
4692
4732
  readonly name: string;
@@ -4738,6 +4778,16 @@ export declare function signInPolicyOf(manifest: Pick<OntologyManifest, "signIn"
4738
4778
  export declare function signUpRolesOf(manifest: Pick<OntologyManifest, "signIn">, channel: string): ReadonlyArray<string> | undefined;
4739
4779
  /** The wire names of the roles whose people's private chats join the inbox; empty without one. */
4740
4780
  export declare function inboxRolesOf(manifest: Pick<OntologyManifest, "inbox">): ReadonlySet<string>;
4781
+ /** The channels whose private chats staff may take over from the agent; empty without any. */
4782
+ export declare function takeoverChannelsOf(manifest: Pick<OntologyManifest, "inbox">): ReadonlySet<string>;
4783
+ /**
4784
+ * The account providers people write from on the channels staff take chats over on: a platform
4785
+ * channel's kind, whose accounts every channel of the kind shares, and `channel:<name>` for a
4786
+ * workspace channel. Admission names an account's provider, never its channel, so a private chat on
4787
+ * any channel of a listed kind is reported at each message; the report names the channel, and only
4788
+ * a chat on a listed channel is ever held.
4789
+ */
4790
+ export declare function takeoverProvidersOf(manifest: Pick<OntologyManifest, "inbox" | "chat">): ReadonlySet<string>;
4741
4791
  /**
4742
4792
  * The websites whose visitors may sign up on `web`, by origin: empty while `web` is closed to
4743
4793
  * sign-up. Entries that are not an origin `signUp.origins` accepts are left out.
@@ -4790,6 +4840,9 @@ export declare function buildManifest(input: {
4790
4840
  readonly chat?: ChatManifestInput;
4791
4841
  readonly inbox?: {
4792
4842
  readonly roles: ReadonlyArray<string>;
4843
+ readonly takeover: {
4844
+ readonly channels: ReadonlyArray<string>;
4845
+ };
4793
4846
  };
4794
4847
  readonly entities: ReadonlyArray<ResolvedEntity>;
4795
4848
  readonly roles: ReadonlyArray<Role>;
package/dist/manifest.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CHAT_CHANNEL_NAME, CHAT_KINDS } from "./chat-channel.js";
1
+ import { CHAT_CHANNEL_NAME, CHAT_KINDS, channelIdentityProvider, isChatChannelKind, } from "./chat-channel.js";
2
2
  import { balancesOf, metricExpression } from "./metric.js";
3
3
  import { Effect, Schema, SchemaTransformation } from "effect";
4
4
  import { acceptingEarlierManifestNames, withEarlierManifestNames } from "./legacy.js";
@@ -92,7 +92,8 @@ import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isGuestBotCheckScheme, isGue
92
92
  * `channel:<name>`, its people's accounts.
93
93
  * Within version 15, the top-level `inbox`, written only when declared, holds the wire names of the
94
94
  * `roles` whose people's private chats the agent registers as `agent_chat` records of kind
95
- * `private`. Older readers ignore it and register none.
95
+ * `private`, and in `takeover.channels` the channels whose chats staff may take over from the
96
+ * agent. Older readers ignore it, register none and let none be taken over.
96
97
  */
97
98
  export const MANIFEST_VERSION = 15;
98
99
  /** The first version whose documents use snake_case names on the wire. */
@@ -562,10 +563,15 @@ const OntologyManifestModel = Schema.Struct({
562
563
  })),
563
564
  })),
564
565
  /**
565
- * Whose private chats join the inbox, within version 15: the wire names of their roles. Written
566
- * only when declared; absent registers no private chat, and older readers ignore it.
566
+ * Whose private chats join the inbox, within version 15: the wire names of their roles, and the
567
+ * channels whose chats staff may take over from the agent. Written only when declared; absent
568
+ * registers no private chat, absent `takeover` lets no chat be taken over, and older readers
569
+ * ignore both.
567
570
  */
568
- inbox: Schema.optionalKey(Schema.Struct({ roles: Schema.Array(Schema.String) })),
571
+ inbox: Schema.optionalKey(Schema.Struct({
572
+ roles: Schema.Array(Schema.String),
573
+ takeover: Schema.optionalKey(Schema.Struct({ channels: Schema.Array(Schema.String) })),
574
+ })),
569
575
  /**
570
576
  * The metrics of the model, since version 8. Written only when there are some; absent reads as
571
577
  * none.
@@ -664,6 +670,24 @@ export function signUpRolesOf(manifest, channel) {
664
670
  export function inboxRolesOf(manifest) {
665
671
  return new Set(manifest.inbox?.roles ?? []);
666
672
  }
673
+ /** The channels whose private chats staff may take over from the agent; empty without any. */
674
+ export function takeoverChannelsOf(manifest) {
675
+ return new Set(manifest.inbox?.takeover?.channels ?? []);
676
+ }
677
+ /**
678
+ * The account providers people write from on the channels staff take chats over on: a platform
679
+ * channel's kind, whose accounts every channel of the kind shares, and `channel:<name>` for a
680
+ * workspace channel. Admission names an account's provider, never its channel, so a private chat on
681
+ * any channel of a listed kind is reported at each message; the report names the channel, and only
682
+ * a chat on a listed channel is ever held.
683
+ */
684
+ export function takeoverProvidersOf(manifest) {
685
+ const named = manifest.chat?.channels ?? {};
686
+ return new Set([...takeoverChannelsOf(manifest)].flatMap((name) => {
687
+ const kind = isChatChannelKind(name) ? name : named[name]?.kind;
688
+ return kind === undefined ? [] : [channelIdentityProvider(kind, name)];
689
+ }));
690
+ }
667
691
  /**
668
692
  * The websites whose visitors may sign up on `web`, by origin: empty while `web` is closed to
669
693
  * sign-up. Entries that are not an origin `signUp.origins` accepts are left out.
@@ -1002,7 +1026,14 @@ export function buildManifest(input) {
1002
1026
  },
1003
1027
  ...(Object.keys(emails).length > 0 ? { emails } : {}),
1004
1028
  ...(input.chat === undefined ? {} : { chat: input.chat }),
1005
- ...(input.inbox === undefined ? {} : { inbox: { roles: [...input.inbox.roles] } }),
1029
+ ...(input.inbox === undefined
1030
+ ? {}
1031
+ : {
1032
+ inbox: {
1033
+ roles: [...input.inbox.roles],
1034
+ takeover: { channels: [...input.inbox.takeover.channels] },
1035
+ },
1036
+ }),
1006
1037
  ...(connections.length > 0
1007
1038
  ? {
1008
1039
  connections: connections.map((candidate) => ({
@@ -562,6 +562,9 @@ export declare const MigrationPlan: Schema.Struct<{
562
562
  } | undefined;
563
563
  readonly inbox?: {
564
564
  readonly roles: readonly string[];
565
+ readonly takeover?: {
566
+ readonly channels: readonly string[];
567
+ } | undefined;
565
568
  } | undefined;
566
569
  readonly toolsets?: readonly {
567
570
  readonly name: string;
@@ -879,6 +882,9 @@ export declare const MigrationPlan: Schema.Struct<{
879
882
  } | undefined;
880
883
  readonly inbox?: {
881
884
  readonly roles: readonly string[];
885
+ readonly takeover?: {
886
+ readonly channels: readonly string[];
887
+ } | undefined;
882
888
  } | undefined;
883
889
  readonly toolsets?: readonly {
884
890
  readonly name: string;
@@ -1161,6 +1167,9 @@ export declare const MigrationPlan: Schema.Struct<{
1161
1167
  } | undefined;
1162
1168
  readonly inbox?: {
1163
1169
  readonly roles: readonly string[];
1170
+ readonly takeover?: {
1171
+ readonly channels: readonly string[];
1172
+ } | undefined;
1164
1173
  } | undefined;
1165
1174
  readonly toolsets?: readonly {
1166
1175
  readonly name: string;
@@ -1513,6 +1522,9 @@ export declare const MigrationPlan: Schema.Struct<{
1513
1522
  } | undefined;
1514
1523
  readonly inbox?: {
1515
1524
  readonly roles: readonly string[];
1525
+ readonly takeover?: {
1526
+ readonly channels: readonly string[];
1527
+ } | undefined;
1516
1528
  } | undefined;
1517
1529
  readonly toolsets?: readonly {
1518
1530
  readonly name: string;
@@ -1795,6 +1807,9 @@ export declare const MigrationPlan: Schema.Struct<{
1795
1807
  }>>;
1796
1808
  readonly inbox: Schema.optionalKey<Schema.Struct<{
1797
1809
  readonly roles: Schema.$Array<Schema.String>;
1810
+ readonly takeover: Schema.optionalKey<Schema.Struct<{
1811
+ readonly channels: Schema.$Array<Schema.String>;
1812
+ }>>;
1798
1813
  }>>;
1799
1814
  readonly metrics: Schema.optionalKey<Schema.$Array<Schema.Struct<{
1800
1815
  readonly name: Schema.String;
@@ -2108,6 +2123,9 @@ export declare const MigrationPlan: Schema.Struct<{
2108
2123
  }>>;
2109
2124
  readonly inbox: Schema.optionalKey<Schema.Struct<{
2110
2125
  readonly roles: Schema.$Array<Schema.String>;
2126
+ readonly takeover: Schema.optionalKey<Schema.Struct<{
2127
+ readonly channels: Schema.$Array<Schema.String>;
2128
+ }>>;
2111
2129
  }>>;
2112
2130
  readonly metrics: Schema.optionalKey<Schema.$Array<Schema.Struct<{
2113
2131
  readonly name: Schema.String;
@@ -2469,6 +2487,9 @@ export declare const MigrationPlan: Schema.Struct<{
2469
2487
  } | undefined;
2470
2488
  readonly inbox?: {
2471
2489
  readonly roles: readonly string[];
2490
+ readonly takeover?: {
2491
+ readonly channels: readonly string[];
2492
+ } | undefined;
2472
2493
  } | undefined;
2473
2494
  readonly toolsets?: readonly {
2474
2495
  readonly name: string;
@@ -2786,6 +2807,9 @@ export declare const MigrationPlan: Schema.Struct<{
2786
2807
  } | undefined;
2787
2808
  readonly inbox?: {
2788
2809
  readonly roles: readonly string[];
2810
+ readonly takeover?: {
2811
+ readonly channels: readonly string[];
2812
+ } | undefined;
2789
2813
  } | undefined;
2790
2814
  readonly toolsets?: readonly {
2791
2815
  readonly name: string;
@@ -6,7 +6,7 @@ import { AgentChat } from "../agent-chat.js";
6
6
  import { chatChannelKind } from "../chat-channel.js";
7
7
  import { AgentReview } from "../agent-review.js";
8
8
  import { AGENT_IDENTITIES_TABLE, AGENT_PAIRINGS_TABLE, CHANNEL_USERS_TABLE, IDENTITY_NOTICES_TABLE, USER_TABLE, } from "../migrate/storage.js";
9
- import { inboxRolesOf } from "../manifest.js";
9
+ import { inboxRolesOf, takeoverChannelsOf, takeoverProvidersOf } from "../manifest.js";
10
10
  import { GUEST_ROLE } from "../names.js";
11
11
  import { MAX_QUERY_LIMIT } from "../query.js";
12
12
  import { beginReplicationWrite } from "../replication/transaction.js";
@@ -547,6 +547,11 @@ export function sqlAgentStore(ontology, sql) {
547
547
  title: String(chat.title),
548
548
  purpose: nullableText(chat.purpose),
549
549
  whenToUse: nullableText(chat.when_to_use),
550
+ // A member of staff took the chat over: the agent records the person and answers none.
551
+ ...((chat.handled_by_id ?? null) !== null &&
552
+ takeoverChannelsOf(ontology.manifest).has(input.provider)
553
+ ? { handled: true }
554
+ : {}),
550
555
  };
551
556
  }));
552
557
  }).pipe(Effect.orDie),
@@ -694,9 +699,14 @@ export function resolveChannelSignIn(ontology, sql, input) {
694
699
  */
695
700
  function inInbox(ontology, input, resolution) {
696
701
  const roles = inboxRolesOf(ontology.manifest);
697
- return (resolution.status === "existing" || resolution.status === "created") &&
698
- input.chat === "private" &&
699
- resolution.member.principal.roles.some((role) => roles.has(role))
700
- ? { ...resolution, inbox: true }
701
- : resolution;
702
+ if ((resolution.status !== "existing" && resolution.status !== "created") ||
703
+ input.chat !== "private" ||
704
+ !resolution.member.principal.roles.some((role) => roles.has(role))) {
705
+ return resolution;
706
+ }
707
+ // Staff may take chats over on a channel of this account's provider: the agent reports every
708
+ // message, and the report, which names the channel, says whether a member of staff holds the chat.
709
+ return takeoverProvidersOf(ontology.manifest).has(input.provider)
710
+ ? { ...resolution, inbox: true, takeover: true }
711
+ : { ...resolution, inbox: true };
702
712
  }
@@ -68,6 +68,11 @@ function valueFields(ontology, entity, { mode }) {
68
68
  : Schema.optionalKey(field.nullable ? Schema.NullOr(value) : value);
69
69
  }
70
70
  for (const link of entity.links.values()) {
71
+ // A built-in entity's relationships change only through the platform's own actions, such as
72
+ // agent_chat's takeOver: its update takes its unmanaged properties alone.
73
+ if (link.via === "key" && entity.resolved.builtIn) {
74
+ continue;
75
+ }
71
76
  if (link.via === "key") {
72
77
  const target = reference(link, relationshipDescription(entity, link));
73
78
  const required = mode === "create" && !link.optional;
@@ -210,6 +210,7 @@ function resolveChannelIdentity(store, agentTools) {
210
210
  notice_due: resolution.noticeDue,
211
211
  on_new_user_pending: resolution.onNewUserPending,
212
212
  ...(resolution.inbox === true ? { inbox: true } : {}),
213
+ ...(resolution.takeover === true ? { takeover: true } : {}),
213
214
  });
214
215
  case "limited":
215
216
  return json({
@@ -1,4 +1,5 @@
1
1
  import { validateTelegramPreviews } from "../../telegram.js";
2
+ import { takeoverChannelsOf } from "../../manifest.js";
2
3
  import { randomUUID } from "node:crypto";
3
4
  import { Cause, Effect } from "effect";
4
5
  import { chatOperationId, chatPreviewDigest, } from "../../chat.js";
@@ -43,6 +44,7 @@ agent = {}) {
43
44
  }
44
45
  const attribution = ontology.config.chat?.attribution;
45
46
  const separator = attribution?.separator ?? "\n\n";
47
+ const takeoverChannels = takeoverChannelsOf(ontology.manifest);
46
48
  const providers = listedChatProviders(ontology.manifest.chat);
47
49
  const destination = ontology.manifest.chat?.telegram?.connection;
48
50
  const destinationPreviews = previews.settings?.connection === destination ? previews : { ownOrigins: previews.ownOrigins };
@@ -228,6 +230,7 @@ agent = {}) {
228
230
  fetch: agent.fetch ?? ((request) => fetch(request)),
229
231
  };
230
232
  return {
233
+ takeoverChannels,
231
234
  sendReview: reviewSender({
232
235
  ontology,
233
236
  connections,
@@ -528,6 +528,11 @@ export type AgentResolution = {
528
528
  * reports the chat (`POST /api/ontology/agent/chats/seen`), which registers it.
529
529
  */
530
530
  readonly inbox?: true;
531
+ /**
532
+ * Staff may take the chat over on its channel (`inbox.takeover.channels`): the agent reports
533
+ * every message, and answers it only while the report does not say the chat is `handled`.
534
+ */
535
+ readonly takeover?: true;
531
536
  } | {
532
537
  readonly status: "pairing_required";
533
538
  } | {
@@ -544,12 +549,17 @@ declare const IdentityInUse_base: Schema.Class<IdentityInUse, Schema.TaggedStruc
544
549
  /** An account already belongs to another member; approval must roll back without consuming the code. */
545
550
  export declare class IdentityInUse extends IdentityInUse_base {
546
551
  }
547
- /** A group chat the agent saw, as `POST /api/ontology/agent/chats/seen` answers. */
552
+ /** A chat the agent saw, as `POST /api/ontology/agent/chats/seen` answers. */
548
553
  export interface SeenChat {
549
554
  readonly id: string;
550
555
  readonly title: string;
551
556
  readonly purpose: string | null;
552
557
  readonly whenToUse: string | null;
558
+ /**
559
+ * A person's private chat a member of staff took over: the agent records the message and answers
560
+ * none of it until they hand it back.
561
+ */
562
+ readonly handled?: true;
553
563
  }
554
564
  /**
555
565
  * Where the app's agent keeps pairing codes and the identities they create: the runtime's agent
@@ -547,6 +547,9 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
547
547
  }>>;
548
548
  readonly inbox: Schema.optionalKey<Schema.Struct<{
549
549
  readonly roles: Schema.$Array<Schema.String>;
550
+ readonly takeover: Schema.optionalKey<Schema.Struct<{
551
+ readonly channels: Schema.$Array<Schema.String>;
552
+ }>>;
550
553
  }>>;
551
554
  readonly metrics: Schema.optionalKey<Schema.$Array<Schema.Struct<{
552
555
  readonly name: Schema.String;
@@ -873,6 +876,9 @@ export declare const Catalog: Schema.decodeTo<Schema.Struct<{
873
876
  }>>>;
874
877
  readonly inbox: Schema.toEncoded<Schema.optionalKey<Schema.Struct<{
875
878
  readonly roles: Schema.$Array<Schema.String>;
879
+ readonly takeover: Schema.optionalKey<Schema.Struct<{
880
+ readonly channels: Schema.$Array<Schema.String>;
881
+ }>>;
876
882
  }>>>;
877
883
  readonly metrics: Schema.toEncoded<Schema.optionalKey<Schema.$Array<Schema.Struct<{
878
884
  readonly name: Schema.String;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/ontology",
3
- "version": "0.123.0",
3
+ "version": "0.124.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",