@segmentstream/ontology 0.201.1 → 0.202.1

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,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.202.1
4
+
5
+ A `tools/list` cursor now survives a redeploy of the app between pages. The listing resumes after
6
+ the last tool it returned, or at that tool's position when the new catalog no longer has it, so MCP
7
+ clients no longer fail to load a workspace's tools while it is being deployed. A cursor from other
8
+ permissions is still refused.
9
+
10
+ ## 0.202.0
11
+
12
+ A member of staff answers the chat of someone the agent never admitted. Recording a channel
13
+ (`record: "all"`) with the channel in `inbox.channels` registers such a chat without a member, for
14
+ example a supplier's mail or a WhatsApp number that wrote in. Until now `agent_chat.send` refused
15
+ it in either voice ("The chat has no person to answer"). A member now answers it from their own
16
+ session in their own voice, `as: "me"`, under `agent_chat:post_message` within a scope that holds
17
+ the record. The reply goes to the address or account the chat names, and staff alone read it. The
18
+ agent's voice, workflows, services and `agent_chat.draft` stay refused, since nothing unattended
19
+ answers people no one admitted. A chat of several members outside a shared thread stays refused.
20
+
3
21
  ## 0.201.1
4
22
 
5
23
  `chat_send` and `chat_post_message` tell agents to mention the particular people a group-chat
@@ -416,7 +416,9 @@ export const AgentChat = entity("agent_chat", {
416
416
  "reads, to required with cc; confirm its recipients with the member first. A person's own " +
417
417
  "chat keeps its person among them (refusal recipient_required); addresses that are no " +
418
418
  "plain addresses, or more than 50, are refused with recipients_invalid, and another chat " +
419
- "refuses them with recipients_unsupported, each before the key is spent.",
419
+ "refuses them with recipients_unsupported, each before the key is spent. The chat of someone " +
420
+ "the agent never admitted, which the inbox registered without a member, takes only a " +
421
+ "member's reply as me, to whom it names.",
420
422
  // Each voice needs its own permission, which the delivery checks: either opens the action.
421
423
  permission: ["agent_chat:send", "agent_chat:post_message"],
422
424
  input: ChatSendInput,
@@ -445,7 +445,15 @@ chats) {
445
445
  threadId !== null &&
446
446
  channelProvider(ontology.manifest.chat, String(record.provider))?.threadRecipients !==
447
447
  undefined;
448
- if (!shared && people.length !== 1) {
448
+ // A chat of several members outside a shared thread has no one person to answer. A chat no
449
+ // one was admitted to, which recording the channel registered, has none yet: a member of
450
+ // staff answers whom it names in their own voice. The agent never admitted its person, and
451
+ // a workflow or a service would answer it unattended, as an auto-responder to strangers. A
452
+ // member answers from their own session in the app or their own MCP client.
453
+ const staffReply = permission === "agent_chat:post_message" &&
454
+ (context.caller.kind === "member" || context.caller.kind === "oauth") &&
455
+ context.principal.kind === "member";
456
+ if (!shared && (people.length > 1 || (people.length === 0 && !staffReply))) {
449
457
  return yield* new ActionRejected({
450
458
  message: "The chat has no person to answer. Nothing was sent.",
451
459
  });
@@ -461,7 +469,7 @@ chats) {
461
469
  provider: String(record.provider),
462
470
  external_id: recipient,
463
471
  kind: "private",
464
- participantIds: shared ? [] : [String(people[0].id)],
472
+ participantIds: shared || people[0] === undefined ? [] : [String(people[0].id)],
465
473
  },
466
474
  chatId,
467
475
  threadId,
@@ -19,8 +19,16 @@ export declare function toolDefinition(tool: McpTool): {
19
19
  openWorldHint: boolean;
20
20
  };
21
21
  };
22
- /** Standard MCP operation definitions; pagination never substitutes search or dispatch tools. */
23
- export declare function listTools(tools: ReadonlyArray<McpTool>, principal: PermissionHolder, caller: CallerContext, hash: string, cursor?: unknown): {
22
+ /**
23
+ * Standard MCP operation definitions; pagination never substitutes search or dispatch tools.
24
+ *
25
+ * A cursor names the last tool it listed, its position and the caller's permissions. A listing
26
+ * survives a redeploy of the app between pages: it resumes after that tool in the current
27
+ * catalog, or at its position when the tool is gone, since clients do not restart a listing whose
28
+ * cursor is refused. A cursor from other permissions is refused, so no page lists a tool the
29
+ * caller may not use.
30
+ */
31
+ export declare function listTools(tools: ReadonlyArray<McpTool>, principal: PermissionHolder, caller: CallerContext, cursor?: unknown): {
24
32
  tools: Array<ReturnType<typeof toolDefinition>>;
25
33
  nextCursor?: string;
26
34
  };
@@ -24,16 +24,19 @@ function invalidCursor() {
24
24
  detail: "The tool-list cursor is invalid or the catalog or permissions changed. Restart tools/list.",
25
25
  });
26
26
  }
27
- /** Standard MCP operation definitions; pagination never substitutes search or dispatch tools. */
28
- export function listTools(tools, principal, caller, hash, cursor) {
27
+ /**
28
+ * Standard MCP operation definitions; pagination never substitutes search or dispatch tools.
29
+ *
30
+ * A cursor names the last tool it listed, its position and the caller's permissions. A listing
31
+ * survives a redeploy of the app between pages: it resumes after that tool in the current
32
+ * catalog, or at its position when the tool is gone, since clients do not restart a listing whose
33
+ * cursor is refused. A cursor from other permissions is refused, so no page lists a tool the
34
+ * caller may not use.
35
+ */
36
+ export function listTools(tools, principal, caller, cursor) {
29
37
  const visible = visibleTools(tools, principal, caller);
30
38
  const scope = createHash("sha256")
31
- .update(JSON.stringify([
32
- hash,
33
- caller.kind,
34
- [...new Set(principal.permissions)].sort(),
35
- visible.map(({ name }) => name),
36
- ]))
39
+ .update(JSON.stringify([caller.kind, [...new Set(principal.permissions)].sort()]))
37
40
  .digest("hex");
38
41
  let start = 0;
39
42
  if (cursor !== undefined) {
@@ -51,16 +54,18 @@ export function listTools(tools, principal, caller, hash, cursor) {
51
54
  decoded === null ||
52
55
  !("scope" in decoded) ||
53
56
  !("last" in decoded) ||
57
+ !("at" in decoded) ||
54
58
  decoded.scope !== scope ||
55
- typeof decoded.last !== "string") {
59
+ typeof decoded.last !== "string" ||
60
+ typeof decoded.at !== "number" ||
61
+ !Number.isSafeInteger(decoded.at) ||
62
+ decoded.at < 0) {
56
63
  return invalidCursor();
57
64
  }
58
65
  const last = decoded.last;
59
66
  const position = visible.findIndex(({ name }) => name === last);
60
- if (position < 0) {
61
- return invalidCursor();
62
- }
63
- start = position + 1;
67
+ // Gone from the catalog: the tool after it now holds its position.
68
+ start = position >= 0 ? position + 1 : Math.min(decoded.at, visible.length);
64
69
  }
65
70
  // Eve 0.85 calls listTools once, unlike AI SDK's tools() which follows nextCursor.
66
71
  // Keep deployed runtime clients working; both paths expose the same direct operations.
@@ -85,7 +90,7 @@ export function listTools(tools, principal, caller, hash, cursor) {
85
90
  tools: selected,
86
91
  ...(last !== undefined && start + selected.length < visible.length
87
92
  ? {
88
- nextCursor: Buffer.from(JSON.stringify({ scope, last: last.name })).toString("base64url"),
93
+ nextCursor: Buffer.from(JSON.stringify({ scope, last: last.name, at: start + selected.length - 1 })).toString("base64url"),
89
94
  }
90
95
  : {}),
91
96
  };
@@ -701,7 +701,7 @@ function dispatch(server, message, request) {
701
701
  return rpcResult(id, {});
702
702
  case "tools/list": {
703
703
  return yield* Effect.try({
704
- try: () => listTools(server.tools, principal, caller, server.built.plan.ontology.manifest.hash, params.cursor),
704
+ try: () => listTools(server.tools, principal, caller, params.cursor),
705
705
  catch: (error) => error,
706
706
  }).pipe(Effect.map((result) => rpcResult(id, result)), Effect.catchIf((error) => error instanceof DiscoveryError, (error) => Effect.succeed(rpcError(id, INVALID_PARAMS, error.detail))));
707
707
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/ontology",
3
- "version": "0.201.1",
3
+ "version": "0.202.1",
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",