@segmentstream/ontology 0.190.0 → 0.191.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 +14 -0
- package/dist/service/chat/schemas.d.ts +10 -0
- package/dist/service/chat/schemas.js +12 -0
- package/dist/service/mcp/tools.d.ts +2 -2
- package/dist/service/mcp/tools.js +32 -16
- package/dist/service/operations.js +18 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.191.0
|
|
4
|
+
|
|
5
|
+
`chat_send` is now an agent session's exact-post tool, as `chat_post_message` has been. Where the
|
|
6
|
+
ontology declares a chat connection, `chat_send` carries the `segmentstream/chat-post` protocol.
|
|
7
|
+
For an agent's session it takes only `chat`, `text`, `reply_to` and `as: "me"`, which it may omit,
|
|
8
|
+
since a session writes in its member's voice alone. As with `chat_post_message`, the key is the
|
|
9
|
+
approved call's, and the service sends only the text the member approved, with the frozen preview's
|
|
10
|
+
destination and digest. A member's own client, and every other caller, still give `chat_send` its
|
|
11
|
+
full input and their own `idempotency_key`.
|
|
12
|
+
|
|
13
|
+
This is the first step of the `chat_post_message` deprecation (`ontology.chat-post-message`): an
|
|
14
|
+
agent SDK that recognizes the protocol on `chat_send` posts through it, and `chat_post_message` keeps
|
|
15
|
+
working for earlier agents until the deprecation's date.
|
|
16
|
+
|
|
3
17
|
## 0.190.0
|
|
4
18
|
|
|
5
19
|
Let a linked member authorize source reads for selected workspaces in a private conversation, with an expiry and revocation.
|
|
@@ -58,6 +58,16 @@ export declare const RuntimeChatPostWire: Schema.Struct<{
|
|
|
58
58
|
readonly text: Schema.String;
|
|
59
59
|
readonly reply_to: Schema.optionalKey<Schema.String>;
|
|
60
60
|
}>;
|
|
61
|
+
/**
|
|
62
|
+
* What an agent's session sends: the exact text its member approved, in their voice. The key is
|
|
63
|
+
* the runtime's, from the approved call; the session sends no files, buttons or template.
|
|
64
|
+
*/
|
|
65
|
+
export declare const RuntimeChatSendWire: Schema.Struct<{
|
|
66
|
+
readonly chat: Schema.String;
|
|
67
|
+
readonly text: Schema.String;
|
|
68
|
+
readonly reply_to: Schema.optionalKey<Schema.String>;
|
|
69
|
+
readonly as: Schema.optionalKey<Schema.Literal<"me">>;
|
|
70
|
+
}>;
|
|
61
71
|
export declare const ChatList: Schema.Struct<{
|
|
62
72
|
readonly chat: Schema.optionalKey<Schema.String>;
|
|
63
73
|
readonly query: Schema.optionalKey<Schema.String>;
|
|
@@ -10,6 +10,18 @@ export const RuntimeChatPostWire = Schema.Struct({
|
|
|
10
10
|
text: ChatPostInput.fields.text,
|
|
11
11
|
reply_to: Schema.optionalKey(Id),
|
|
12
12
|
});
|
|
13
|
+
/**
|
|
14
|
+
* What an agent's session sends: the exact text its member approved, in their voice. The key is
|
|
15
|
+
* the runtime's, from the approved call; the session sends no files, buttons or template.
|
|
16
|
+
*/
|
|
17
|
+
export const RuntimeChatSendWire = Schema.Struct({
|
|
18
|
+
chat: ChatPostInput.fields.chat,
|
|
19
|
+
text: ChatPostInput.fields.text,
|
|
20
|
+
reply_to: Schema.optionalKey(Id),
|
|
21
|
+
as: Schema.optionalKey(Schema.Literal("me").annotate({
|
|
22
|
+
description: "me, the member you act for: a session writes in their voice alone.",
|
|
23
|
+
})),
|
|
24
|
+
});
|
|
13
25
|
export const ChatList = Schema.Struct({
|
|
14
26
|
chat: Schema.optionalKey(Id),
|
|
15
27
|
query: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(512))),
|
|
@@ -89,8 +89,8 @@ export declare const ACTION_OPTIONS_ARGUMENT = "_options";
|
|
|
89
89
|
/** The `me` tool's marker: tool calls accept the runtime envelope's chat source. */
|
|
90
90
|
export declare const RUNTIME_SOURCE_META = "segmentstream/runtime-source";
|
|
91
91
|
/**
|
|
92
|
-
* The
|
|
93
|
-
*
|
|
92
|
+
* The exact-post tools' marker: the deployment posts the exact text an agent's member approved to
|
|
93
|
+
* its chat, through `chat_send` with `as: "me"`, or `chat_post_message`, its earlier name.
|
|
94
94
|
*/
|
|
95
95
|
export declare const CHAT_POST_META = "segmentstream/chat-post";
|
|
96
96
|
/**
|
|
@@ -12,7 +12,7 @@ import { ChatSearch } from "../agent/chat-archive.js";
|
|
|
12
12
|
import { declaredChatProviders } from "../chat/providers/index.js";
|
|
13
13
|
import { runtimeAllows } from "./runtime-policy.js";
|
|
14
14
|
import { confirmationFacts, needsConfirmation, withConfirmation, } from "./confirmation.js";
|
|
15
|
-
import { ChatList, ChatListResult, ChatHistory, ChatPostWire, RuntimeChatPostWire, } from "../chat/schemas.js";
|
|
15
|
+
import { ChatList, ChatListResult, ChatHistory, ChatPostWire, RuntimeChatPostWire, RuntimeChatSendWire, } from "../chat/schemas.js";
|
|
16
16
|
import { ChatPostResult } from "../../chat.js";
|
|
17
17
|
import { actionDescription, requires } from "../descriptions.js";
|
|
18
18
|
import { DiscoverInput, DiscoverToolOutput } from "../discovery-schemas.js";
|
|
@@ -268,8 +268,8 @@ export const ACTION_OPTIONS_ARGUMENT = "_options";
|
|
|
268
268
|
/** The `me` tool's marker: tool calls accept the runtime envelope's chat source. */
|
|
269
269
|
export const RUNTIME_SOURCE_META = "segmentstream/runtime-source";
|
|
270
270
|
/**
|
|
271
|
-
* The
|
|
272
|
-
*
|
|
271
|
+
* The exact-post tools' marker: the deployment posts the exact text an agent's member approved to
|
|
272
|
+
* its chat, through `chat_send` with `as: "me"`, or `chat_post_message`, its earlier name.
|
|
273
273
|
*/
|
|
274
274
|
export const CHAT_POST_META = "segmentstream/chat-post";
|
|
275
275
|
const ACTION_OPTIONS_SCHEMA = {
|
|
@@ -799,6 +799,13 @@ export function mcpTools(built, chatHistory = false, storage = {}, navigation =
|
|
|
799
799
|
};
|
|
800
800
|
tools[post] = replacement;
|
|
801
801
|
}
|
|
802
|
+
// An agent's session sends the exact text its member approved through send as me, by the same
|
|
803
|
+
// protocol; a member's own client sends with its own key.
|
|
804
|
+
const send = tools.findIndex((tool) => tool.name === "chat_send");
|
|
805
|
+
if (send >= 0 && declaredChatProviders(manifest.chat).length > 0) {
|
|
806
|
+
const original = tools[send];
|
|
807
|
+
tools[send] = { ...original, _meta: { ...original._meta, [CHAT_POST_META]: 1 } };
|
|
808
|
+
}
|
|
802
809
|
tools.push({
|
|
803
810
|
name: "chat_list",
|
|
804
811
|
title: "List eligible chats",
|
|
@@ -977,6 +984,23 @@ const USER_TOOL_TARGETS = new Set([
|
|
|
977
984
|
"chat-list",
|
|
978
985
|
"chat-history",
|
|
979
986
|
]);
|
|
987
|
+
/**
|
|
988
|
+
* What an agent's session gives an exact-post tool: the approved text alone, whose key the runtime
|
|
989
|
+
* derives from the approved call. Undefined for any other tool or caller.
|
|
990
|
+
*/
|
|
991
|
+
function runtimeChatInput(tool, provenance) {
|
|
992
|
+
if (provenance.kind !== "runtime") {
|
|
993
|
+
return undefined;
|
|
994
|
+
}
|
|
995
|
+
if (tool.name === "chat_send" && tool._meta?.[CHAT_POST_META] === 1) {
|
|
996
|
+
return withConfirmation(encodedJsonSchema(RuntimeChatSendWire), tool.annotations);
|
|
997
|
+
}
|
|
998
|
+
// @legacy ontology.chat-post-message
|
|
999
|
+
if (tool.name === "chat_post_message") {
|
|
1000
|
+
return withConfirmation(encodedJsonSchema(RuntimeChatPostWire), tool.annotations);
|
|
1001
|
+
}
|
|
1002
|
+
return undefined;
|
|
1003
|
+
}
|
|
980
1004
|
/**
|
|
981
1005
|
* The tools a caller may see: those whose every permission the caller's roles grant, each with the
|
|
982
1006
|
* caller's input schema. A guest sees none of the tools only a user has.
|
|
@@ -990,21 +1014,13 @@ export function visibleTools(tools, caller, provenance = { kind: "unverified" })
|
|
|
990
1014
|
return [];
|
|
991
1015
|
}
|
|
992
1016
|
const description = tool.descriptionFor?.(caller) ?? tool.description;
|
|
1017
|
+
const runtime = runtimeChatInput(tool, provenance);
|
|
993
1018
|
if (tool.inputSchemaFor === undefined) {
|
|
994
|
-
return [
|
|
995
|
-
{
|
|
996
|
-
...tool,
|
|
997
|
-
description,
|
|
998
|
-
// @legacy ontology.chat-post-message
|
|
999
|
-
...(tool.name === "chat_post_message" && provenance.kind === "runtime"
|
|
1000
|
-
? {
|
|
1001
|
-
inputSchema: withConfirmation(encodedJsonSchema(RuntimeChatPostWire), tool.annotations),
|
|
1002
|
-
}
|
|
1003
|
-
: {}),
|
|
1004
|
-
},
|
|
1005
|
-
];
|
|
1019
|
+
return [{ ...tool, description, ...(runtime === undefined ? {} : { inputSchema: runtime }) }];
|
|
1006
1020
|
}
|
|
1007
1021
|
const inputSchema = tool.inputSchemaFor(caller);
|
|
1008
|
-
return inputSchema === undefined
|
|
1022
|
+
return inputSchema === undefined
|
|
1023
|
+
? []
|
|
1024
|
+
: [{ ...tool, description, inputSchema: runtime ?? inputSchema }];
|
|
1009
1025
|
});
|
|
1010
1026
|
}
|
|
@@ -14,7 +14,7 @@ import { requireRuntimeOperation } from "./mcp/runtime-policy.js";
|
|
|
14
14
|
import { ChatDelivery } from "../chat.js";
|
|
15
15
|
import { withoutConfirmation } from "./mcp/confirmation.js";
|
|
16
16
|
import { consumeChatEnvelope, CurrentChatCall } from "./chat/envelope.js";
|
|
17
|
-
import { ChatPostWire, ChatSendWire, RuntimeChatPostWire } from "./chat/schemas.js";
|
|
17
|
+
import { ChatPostWire, ChatSendWire, RuntimeChatPostWire, RuntimeChatSendWire, } from "./chat/schemas.js";
|
|
18
18
|
import { OIDC_TOKEN_HEADER } from "./connections.js";
|
|
19
19
|
import { InvalidActionInput, RequestId } from "./errors.js";
|
|
20
20
|
import { recordReads } from "./record-reads.js";
|
|
@@ -233,17 +233,29 @@ function runActionOf(backend, plan, hooks, connections, replicate, chatDelivery)
|
|
|
233
233
|
"for a task whatever its workflow's role grants; the workflow sends what the task wrote.",
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
|
-
//
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
// The agent's sessions post the exact text their member approved through send as me, or
|
|
237
|
+
// through post_message, its earlier name (@legacy ontology.chat-post-message): the key is
|
|
238
|
+
// the approved call's, never the model's.
|
|
239
|
+
if (planned.name === "agent_chat" &&
|
|
240
|
+
(name === "send" || name === "post_message") &&
|
|
241
|
+
caller.kind === "runtime") {
|
|
242
|
+
const sending = name === "send";
|
|
243
|
+
const values = yield* Schema.decodeUnknownEffect(sending ? RuntimeChatSendWire : RuntimeChatPostWire)(consumed.input, {
|
|
239
244
|
onExcessProperty: "error",
|
|
240
245
|
}).pipe(Effect.mapError(() => new ActionRejected({
|
|
241
|
-
message:
|
|
246
|
+
message: sending
|
|
247
|
+
? "Runtime chat keys are application-owned; only chat, text, reply_to and " +
|
|
248
|
+
'as "me" are accepted.'
|
|
249
|
+
: "Runtime chat keys are application-owned; only chat, text and reply_to are accepted.",
|
|
242
250
|
})));
|
|
243
251
|
if (!envelope?.operation_id) {
|
|
244
252
|
return yield* new ActionRejected({ message: "A confirmed runtime call is required." });
|
|
245
253
|
}
|
|
246
|
-
input = {
|
|
254
|
+
input = {
|
|
255
|
+
...values,
|
|
256
|
+
...(sending ? { as: "me" } : {}),
|
|
257
|
+
idempotency_key: envelope.operation_id,
|
|
258
|
+
};
|
|
247
259
|
}
|
|
248
260
|
// Approving a draft sends it to a person: a member, or the agent acting for one with
|
|
249
261
|
// their confirmation, decides; an agent task has no one to confirm it.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/ontology",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.191.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",
|