@segmentstream/agent 0.42.1 → 0.43.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/README.md +24 -24
- package/dist/_chunks/{build-metadata-BPEZ5XVM.mjs → build-metadata-CkBdh-TE.mjs} +1 -1
- package/dist/_chunks/{principal-BIX7T6Hh.mjs → principal-nQ_gwLJs.mjs} +4 -4
- package/dist/extension/channels/telegram.mjs +1 -1
- package/dist/extension/channels/whatsapp.mjs +1 -1
- package/dist/extension/config.d.ts +14 -16
- package/dist/extension/config.mjs +57 -12
- package/dist/extension/conventions.d.ts +1 -1
- package/dist/extension/conventions.mjs +22 -19
- package/dist/extension/extension.d.ts +2 -2
- package/dist/extension/extension.mjs +3 -3
- package/dist/extension/hooks/authorization.mjs +1 -1
- package/dist/extension/hooks/{conversations.mjs → chat-recorder.mjs} +4 -4
- package/dist/extension/hooks/sandbox.d.ts +2 -2
- package/dist/extension/instructions/{conversations.mjs → chat-context.mjs} +2 -2
- package/dist/extension/instructions/persona.mjs +1 -1
- package/dist/extension/instructions/sandbox.mjs +2 -2
- package/dist/extension/instructions.md +10 -10
- package/dist/extension/lib/actor.mjs +1 -1
- package/dist/extension/lib/attachment-tools.d.ts +1 -1
- package/dist/extension/lib/attachment-tools.mjs +7 -7
- package/dist/extension/lib/attachments.d.ts +9 -4
- package/dist/extension/lib/attachments.mjs +9 -7
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/chat-address.d.ts +33 -0
- package/dist/extension/lib/{conversation.mjs → chat-address.mjs} +13 -12
- package/dist/extension/lib/{conversations.d.ts → chat-archive.d.ts} +12 -12
- package/dist/extension/lib/{conversations.mjs → chat-archive.mjs} +9 -9
- package/dist/extension/lib/chat-context.d.ts +5 -5
- package/dist/extension/lib/chat-context.mjs +6 -6
- package/dist/extension/lib/{conversation-runtime.d.ts → chat-recorder.d.ts} +3 -3
- package/dist/extension/lib/{conversation-runtime.mjs → chat-recorder.mjs} +13 -13
- package/dist/extension/lib/confirmations.d.ts +3 -3
- package/dist/extension/lib/confirmations.mjs +8 -8
- package/dist/extension/lib/group-routing/addressing.d.ts +1 -1
- package/dist/extension/lib/group-routing/addressing.mjs +2 -2
- package/dist/extension/lib/group-routing/burst.mjs +2 -2
- package/dist/extension/lib/group-routing/{conversation-prompt.d.ts → chat-prompt.d.ts} +2 -2
- package/dist/extension/lib/group-routing/{conversation-prompt.mjs → chat-prompt.mjs} +3 -3
- package/dist/extension/lib/group-routing/{conversation-router.d.ts → chat-router.d.ts} +6 -6
- package/dist/extension/lib/group-routing/{conversation-router.mjs → chat-router.mjs} +9 -9
- package/dist/extension/lib/group-routing/engagement.mjs +2 -2
- package/dist/extension/lib/group-routing/messages.d.ts +1 -1
- package/dist/extension/lib/group-routing/policy.d.ts +6 -6
- package/dist/extension/lib/group-routing/policy.mjs +16 -16
- package/dist/extension/lib/group-routing/replay.mjs +36 -9
- package/dist/extension/lib/group-routing/router.d.ts +3 -3
- package/dist/extension/lib/group-routing/router.mjs +16 -16
- package/dist/extension/lib/group-routing/routing-context.d.ts +2 -2
- package/dist/extension/lib/group-routing/routing-context.mjs +2 -2
- package/dist/extension/lib/group-routing/signals.d.ts +3 -3
- package/dist/extension/lib/group-routing/signals.mjs +5 -5
- package/dist/extension/lib/model-service-alert.d.ts +2 -2
- package/dist/extension/lib/model-service-alert.mjs +2 -2
- package/dist/extension/lib/ontology-connection.mjs +1 -1
- package/dist/extension/lib/ontology-file-call.mjs +1 -1
- package/dist/extension/lib/ontology-tools.mjs +1 -1
- package/dist/extension/lib/review/hold.d.ts +7 -7
- package/dist/extension/lib/review/hold.mjs +12 -12
- package/dist/extension/lib/review/judge.d.ts +9 -9
- package/dist/extension/lib/review/judge.mjs +12 -12
- package/dist/extension/lib/review/reply.d.ts +13 -13
- package/dist/extension/lib/review/reply.mjs +20 -20
- package/dist/extension/lib/role-skill.mjs +1 -1
- package/dist/extension/lib/runtime-envelope.mjs +1 -1
- package/dist/extension/lib/sent-files.mjs +3 -2
- package/dist/extension/lib/slack/adapter.mjs +2 -2
- package/dist/extension/lib/slack/attachments-send.d.ts +2 -2
- package/dist/extension/lib/slack/attachments-send.mjs +5 -5
- package/dist/extension/lib/slack/files.mjs +4 -4
- package/dist/extension/lib/stored-files.mjs +1 -1
- package/dist/extension/lib/telegram/adapter.d.ts +4 -3
- package/dist/extension/lib/telegram/adapter.mjs +10 -10
- package/dist/extension/lib/telegram/attachments-send.mjs +1 -1
- package/dist/extension/lib/telegram/callbacks.mjs +1 -1
- package/dist/extension/lib/telegram/{conversations.d.ts → chat-archive.d.ts} +7 -7
- package/dist/extension/lib/telegram/{conversations.mjs → chat-archive.mjs} +10 -10
- package/dist/extension/lib/telegram/confirmation-text.mjs +1 -0
- package/dist/extension/lib/telegram/confirmations.d.ts +2 -2
- package/dist/extension/lib/telegram/confirmations.mjs +3 -3
- package/dist/extension/lib/telegram/delivery-diagnostics.d.ts +3 -3
- package/dist/extension/lib/telegram/delivery-diagnostics.mjs +2 -2
- package/dist/extension/lib/telegram/files.d.ts +1 -1
- package/dist/extension/lib/telegram/files.mjs +8 -8
- package/dist/extension/lib/telegram/health.mjs +1 -1
- package/dist/extension/lib/telegram/inbound-request.d.ts +1 -1
- package/dist/extension/lib/telegram/inbound.d.ts +3 -3
- package/dist/extension/lib/telegram/inbound.mjs +36 -36
- package/dist/extension/lib/telegram/lifecycle.mjs +3 -3
- package/dist/extension/lib/telegram/principal.d.ts +2 -2
- package/dist/extension/lib/telegram/principal.mjs +1 -1
- package/dist/extension/lib/telegram/router.mjs +2 -2
- package/dist/extension/lib/telegram/sessions.d.ts +1 -1
- package/dist/extension/lib/telegram/signals.mjs +1 -1
- package/dist/extension/lib/telegram/silent.d.ts +2 -2
- package/dist/extension/lib/telegram/structured.mjs +1 -1
- package/dist/extension/lib/telegram/turn-errors.d.ts +2 -2
- package/dist/extension/lib/telegram/turn-errors.mjs +2 -2
- package/dist/extension/lib/telegram/voice.d.ts +1 -1
- package/dist/extension/lib/whatsapp/adapter.d.ts +2 -2
- package/dist/extension/lib/whatsapp/adapter.mjs +2 -2
- package/dist/extension/lib/workflow-serializable.d.ts +1 -1
- package/dist/extension/model.mjs +1 -1
- package/dist/extension/personas.d.ts +1 -1
- package/dist/extension/review.d.ts +23 -20
- package/dist/extension/review.mjs +21 -34
- package/dist/extension/tools/attachments_promote.mjs +1 -1
- package/dist/extension/tools/attachments_send.mjs +3 -3
- package/dist/extension/tools/no_reply.d.ts +1 -1
- package/dist/extension/tools/questions_ask.mjs +4 -4
- package/dist/extension/tools/sandbox.mjs +2 -2
- package/package.json +2 -2
- package/dist/extension/lib/conversation.d.ts +0 -33
- /package/dist/extension/hooks/{conversations.d.ts → chat-recorder.d.ts} +0 -0
- /package/dist/extension/instructions/{conversations.d.ts → chat-context.d.ts} +0 -0
|
@@ -6,13 +6,13 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
const REVIEW_DIRECTORY = "review";
|
|
8
8
|
const MAXIMUM_CRITERIA_LENGTH = 8e3;
|
|
9
|
-
const
|
|
9
|
+
const DEFAULT_REVIEW = "default";
|
|
10
10
|
const REVIEW_MODES = [
|
|
11
11
|
"never",
|
|
12
12
|
"always",
|
|
13
13
|
"whenUnsure"
|
|
14
14
|
];
|
|
15
|
-
const SEND_REPLIES = {
|
|
15
|
+
const SEND_REPLIES = { mode: "never" };
|
|
16
16
|
const FILE_NAME = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
17
17
|
function isRecord(value) {
|
|
18
18
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -20,9 +20,9 @@ function isRecord(value) {
|
|
|
20
20
|
function reviewFile(key) {
|
|
21
21
|
return FILE_NAME.test(key) ? `${REVIEW_DIRECTORY}/${key}.md` : void 0;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function reviewFor(settings, roles) {
|
|
24
24
|
if (settings === void 0) return SEND_REPLIES;
|
|
25
|
-
for (const [role,
|
|
25
|
+
for (const [role, review] of Object.entries(settings.byRole)) if (roles.includes(role)) return review;
|
|
26
26
|
return settings.default;
|
|
27
27
|
}
|
|
28
28
|
function review(value, path, issues) {
|
|
@@ -79,33 +79,11 @@ function review(value, path, issues) {
|
|
|
79
79
|
...typeof value.criteria === "string" ? { criteria: value.criteria } : {}
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
function conversation(value, path, issues) {
|
|
83
|
-
if (!isRecord(value)) {
|
|
84
|
-
issues.push({
|
|
85
|
-
message: "must be an object",
|
|
86
|
-
path
|
|
87
|
-
});
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
for (const key of Object.keys(value)) if (key !== "review") issues.push({
|
|
91
|
-
message: "is not a known setting",
|
|
92
|
-
path: [...path, key]
|
|
93
|
-
});
|
|
94
|
-
if (value.review === void 0) {
|
|
95
|
-
issues.push({
|
|
96
|
-
message: "is required",
|
|
97
|
-
path: [...path, "review"]
|
|
98
|
-
});
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const settings = review(value.review, [...path, "review"], issues);
|
|
102
|
-
return settings === void 0 ? void 0 : { review: settings };
|
|
103
|
-
}
|
|
104
82
|
function role(value) {
|
|
105
83
|
return value.trim() !== "" && value.trim() === value;
|
|
106
84
|
}
|
|
107
|
-
function
|
|
108
|
-
const path = ["
|
|
85
|
+
function reviewSettings(value, issues) {
|
|
86
|
+
const path = ["review"];
|
|
109
87
|
if (value === void 0) return;
|
|
110
88
|
if (!isRecord(value)) {
|
|
111
89
|
issues.push({
|
|
@@ -140,7 +118,7 @@ function conversationsSettings(value, issues) {
|
|
|
140
118
|
});
|
|
141
119
|
continue;
|
|
142
120
|
}
|
|
143
|
-
const settings =
|
|
121
|
+
const settings = review(entry, [
|
|
144
122
|
...path,
|
|
145
123
|
"byRole",
|
|
146
124
|
name
|
|
@@ -150,7 +128,16 @@ function conversationsSettings(value, issues) {
|
|
|
150
128
|
}
|
|
151
129
|
return {
|
|
152
130
|
byRole,
|
|
153
|
-
default: (value.default === void 0 ? SEND_REPLIES :
|
|
131
|
+
default: (value.default === void 0 ? SEND_REPLIES : review(value.default, [...path, "default"], issues)) ?? SEND_REPLIES
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function earlierReviewInput(value) {
|
|
135
|
+
if (!isRecord(value)) return value;
|
|
136
|
+
const inner = (entry) => isRecord(entry) ? entry.review : entry;
|
|
137
|
+
return {
|
|
138
|
+
...value,
|
|
139
|
+
...isRecord(value.byRole) ? { byRole: Object.fromEntries(Object.entries(value.byRole).map(([role, entry]) => [role, inner(entry)])) } : {},
|
|
140
|
+
...value.default === void 0 ? {} : { default: inner(value.default) }
|
|
154
141
|
};
|
|
155
142
|
}
|
|
156
143
|
function criteriaFiles(value) {
|
|
@@ -160,12 +147,12 @@ function criteriaFiles(value) {
|
|
|
160
147
|
entry,
|
|
161
148
|
file: reviewFile(name)
|
|
162
149
|
})) : [], {
|
|
163
|
-
path: [
|
|
150
|
+
path: [DEFAULT_REVIEW],
|
|
164
151
|
entry: value.default,
|
|
165
|
-
file: reviewFile(
|
|
166
|
-
}].flatMap(({ path, entry, file }) => file !== void 0 && isRecord(entry) &&
|
|
152
|
+
file: reviewFile(DEFAULT_REVIEW)
|
|
153
|
+
}].flatMap(({ path, entry, file }) => file !== void 0 && isRecord(entry) && entry.mode === "whenUnsure" ? [{
|
|
167
154
|
path,
|
|
168
155
|
file
|
|
169
156
|
}] : []);
|
|
170
157
|
}
|
|
171
|
-
export {
|
|
158
|
+
export { DEFAULT_REVIEW, MAXIMUM_CRITERIA_LENGTH, REVIEW_DIRECTORY, REVIEW_MODES, SEND_REPLIES, criteriaFiles, earlierReviewInput, reviewFile, reviewFor, reviewSettings };
|
|
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
|
|
|
4
4
|
const __filename = __eveFileURLToPath(import.meta.url);
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
|
-
import { u as runtimeEnvelope } from "../../_chunks/principal-
|
|
7
|
+
import { u as runtimeEnvelope } from "../../_chunks/principal-nQ_gwLJs.mjs";
|
|
8
8
|
import segmentstream from "../extension.mjs";
|
|
9
9
|
import { n as workflowToolResult } from "../../_chunks/workflow-serializable-DU7WeCIW.mjs";
|
|
10
10
|
import { actionApproval } from "../lib/confirmations.mjs";
|
|
@@ -6,14 +6,14 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { n as workflowToolResult } from "../../_chunks/workflow-serializable-DU7WeCIW.mjs";
|
|
8
8
|
import segmentstream from "../extension.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { chatAddressOf } from "../lib/chat-address.mjs";
|
|
10
10
|
import { sendSlackAttachments } from "../lib/slack/attachments-send.mjs";
|
|
11
11
|
import { sendAttachments, sendAttachmentsInput } from "../lib/telegram/attachments-send.mjs";
|
|
12
12
|
import { memberTool } from "../lib/actor.mjs";
|
|
13
13
|
import { defineTool } from "eve/tools";
|
|
14
14
|
const tool = defineTool({
|
|
15
15
|
availableInSubagents: false,
|
|
16
|
-
description: "Send 1 to 10 stored ontology files to this turn's Telegram chat or Slack
|
|
16
|
+
description: "Send 1 to 10 stored ontology files to this turn's Telegram chat or Slack chat, as the paired member. Bare ids are document record ids; use entity/id/property references for other file records. In Telegram, images use sendPhoto, other files sendDocument, with compatible albums when possible; in Slack the files are shared together in the thread, with the caption. Uploads are limited to 2 MiB by the connection proxy. Use the question as caption when sending documents with a question; one question per message. In groups follow the chat's purpose and never send restricted documents.",
|
|
17
17
|
inputSchema: {
|
|
18
18
|
type: "object",
|
|
19
19
|
properties: {
|
|
@@ -58,7 +58,7 @@ const tool = defineTool({
|
|
|
58
58
|
principal,
|
|
59
59
|
sessionId: ctx.session.id
|
|
60
60
|
};
|
|
61
|
-
return workflowToolResult(
|
|
61
|
+
return workflowToolResult(chatAddressOf(principal)?.provider === "slack" ? await sendSlackAttachments({
|
|
62
62
|
...options,
|
|
63
63
|
connection: segmentstream.config.channels.slack?.connection
|
|
64
64
|
}) : await sendAttachments({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { noReply } from "eve/tools/no_reply";
|
|
2
2
|
/**
|
|
3
3
|
* Eve's `no_reply`, offered to every workspace agent: the turn ends without a message, and the
|
|
4
|
-
* call keeps the model's reason in the session history and the
|
|
4
|
+
* call keeps the model's reason in the session history and the chat archive. Silence is a
|
|
5
5
|
* recorded decision, not text the channel has to recognize. Only root sessions receive it.
|
|
6
6
|
*/
|
|
7
7
|
export default noReply;
|
|
@@ -7,9 +7,9 @@ __eveCreateRequire(import.meta.url);
|
|
|
7
7
|
import { n as workflowToolResult } from "../../_chunks/workflow-serializable-DU7WeCIW.mjs";
|
|
8
8
|
import { agentTaskIdOf, agentTaskSessions } from "../lib/agent-task.mjs";
|
|
9
9
|
import { stringArgument } from "../lib/attachment-tools.mjs";
|
|
10
|
-
import {
|
|
10
|
+
import { chatAddressOf } from "../lib/chat-address.mjs";
|
|
11
11
|
import { pendingQuestions, questionKey } from "../lib/questions.mjs";
|
|
12
|
-
import { i as memberIdOf } from "../../_chunks/principal-
|
|
12
|
+
import { i as memberIdOf } from "../../_chunks/principal-nQ_gwLJs.mjs";
|
|
13
13
|
import { defineTool } from "eve/tools";
|
|
14
14
|
var questions_ask_default = defineTool({
|
|
15
15
|
availableInSubagents: false,
|
|
@@ -43,8 +43,8 @@ var questions_ask_default = defineTool({
|
|
|
43
43
|
} : task);
|
|
44
44
|
return workflowToolResult({ question: text }, ctx);
|
|
45
45
|
}
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
46
|
+
const chat = chatAddressOf(ctx.session.auth.current);
|
|
47
|
+
if (chat !== void 0 && chat.provider !== "telegram") throw new Error(`questions_ask is unavailable in ${chat.provider}: ask the question in your reply; the member's answer continues this chat.`);
|
|
48
48
|
const memberId = memberIdOf(ctx.session.auth.current);
|
|
49
49
|
const chatId = ctx.session.auth.current?.attributes.chatId;
|
|
50
50
|
if (memberId === void 0 || typeof chatId !== "string") throw new Error("A member in a chat is required.");
|
|
@@ -15,7 +15,7 @@ const tools = {
|
|
|
15
15
|
inputSchema: bash.inputSchema,
|
|
16
16
|
outputSchema: bash.outputSchema,
|
|
17
17
|
label: bash.label,
|
|
18
|
-
description: "Run a shell command in
|
|
18
|
+
description: "Run a shell command in your isolated sandbox, which has no network. A command still running after its wait (60 seconds, or `timeout` up to 120) keeps running and returns status \"running\" with its output so far and the directory of its stdout, stderr and exit files.",
|
|
19
19
|
async execute(input, ctx) {
|
|
20
20
|
await sessionSandbox(ctx);
|
|
21
21
|
return await bash.execute(input, ctx);
|
|
@@ -41,7 +41,7 @@ const tools = {
|
|
|
41
41
|
inputSchema: writeFile.inputSchema,
|
|
42
42
|
outputSchema: writeFile.outputSchema,
|
|
43
43
|
label: writeFile.label,
|
|
44
|
-
description: "Write a complete file in
|
|
44
|
+
description: "Write a complete file in your isolated sandbox, creating directories as needed. Read an existing file with read_file before overwriting it.",
|
|
45
45
|
async execute(input, ctx) {
|
|
46
46
|
await sessionSandbox(ctx);
|
|
47
47
|
return await writeFile.execute(input, ctx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.0",
|
|
4
4
|
"description": "Mount a SegmentStream workspace's agent on eve: the ontology as tools, acting as the member who writes, and Telegram, WhatsApp and Slack through the workspace's connections.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@chat-adapter/state-memory": "4.42.0",
|
|
77
77
|
"@chat-adapter/telegram": "4.41.0",
|
|
78
78
|
"@chat-adapter/whatsapp": "4.42.0",
|
|
79
|
-
"@segmentstream/ontology": "0.
|
|
79
|
+
"@segmentstream/ontology": "0.99.0",
|
|
80
80
|
"@vercel/oidc": "^3.8.4",
|
|
81
81
|
"ai": "^7.0.137",
|
|
82
82
|
"chat": "4.42.0",
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { SessionAuthContext } from "eve/context";
|
|
2
|
-
/**
|
|
3
|
-
* The conversation a member's message came from, the same way for every channel: the provider,
|
|
4
|
-
* its id for the conversation and thread, whether it is the member's own direct conversation, and
|
|
5
|
-
* there the member's id on the provider, which a private destination on that provider names.
|
|
6
|
-
*/
|
|
7
|
-
export interface Conversation {
|
|
8
|
-
readonly provider: "telegram" | "slack" | "whatsapp";
|
|
9
|
-
readonly chatId: string;
|
|
10
|
-
/** `""` without a thread. */
|
|
11
|
-
readonly threadId: string;
|
|
12
|
-
readonly kind: "private" | "group";
|
|
13
|
-
readonly peer?: string;
|
|
14
|
-
}
|
|
15
|
-
/** The session attribute that carries a non-Telegram channel's conversation, as JSON. */
|
|
16
|
-
export declare const CONVERSATION_ATTRIBUTE = "segmentstreamConversation";
|
|
17
|
-
/** A channel's principal with the conversation its message came from. */
|
|
18
|
-
export declare function withConversation(principal: SessionAuthContext, conversation: Conversation): SessionAuthContext;
|
|
19
|
-
/**
|
|
20
|
-
* The conversation a session's principal speaks from, or undefined for one without a channel
|
|
21
|
-
* conversation, such as a task. Telegram's comes from the chat attributes its principal always
|
|
22
|
-
* carried, so sessions from before this attribute keep working.
|
|
23
|
-
*/
|
|
24
|
-
export declare function conversationOf(principal?: SessionAuthContext | null): Conversation | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* Whether a destination is the conversation itself. A private destination names its person, not
|
|
27
|
-
* the conversation: a Slack direct message is `D…` while its person is `U…`.
|
|
28
|
-
*/
|
|
29
|
-
export declare function isSameConversation(conversation: Conversation, destination: {
|
|
30
|
-
readonly provider: string;
|
|
31
|
-
readonly externalId: string;
|
|
32
|
-
readonly kind?: string;
|
|
33
|
-
}): boolean;
|
|
File without changes
|
|
File without changes
|