@segmentstream/agent 0.34.1 → 0.35.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/dist/_chunks/{build-metadata-BMjP89Jo.mjs → build-metadata-Dk0pEJxW.mjs} +1 -1
- package/dist/extension/config.d.ts +8 -0
- package/dist/extension/config.mjs +31 -7
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/group-routing/policy.d.ts +9 -0
- package/dist/extension/lib/group-routing/policy.mjs +56 -1
- package/dist/extension/lib/telegram/adapter.mjs +1 -1
- package/dist/extension/lib/telegram/health.mjs +1 -1
- package/dist/extension/lib/telegram/lifecycle.mjs +1 -1
- package/package.json +1 -1
|
@@ -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
|
-
var version = "0.
|
|
7
|
+
var version = "0.35.0";
|
|
8
8
|
function agentBuild(environment = process.env) {
|
|
9
9
|
return {
|
|
10
10
|
agent: version,
|
|
@@ -224,6 +224,14 @@ export interface ConfigIssue {
|
|
|
224
224
|
readonly message: string;
|
|
225
225
|
readonly path: ReadonlyArray<string>;
|
|
226
226
|
}
|
|
227
|
+
/** A setting `agent/segmentstream.json` sets that configures nothing: accepted, and ignored. */
|
|
228
|
+
export type ConfigWarning = ConfigIssue;
|
|
229
|
+
/**
|
|
230
|
+
* Every setting the configuration sets that configures nothing, for the deploy output and the
|
|
231
|
+
* console, so the builder learns of it where they work: retired session and group keys, and the
|
|
232
|
+
* older policies' thresholds where the conversation policy applies. The agent also logs them.
|
|
233
|
+
*/
|
|
234
|
+
export declare function configWarnings(value: unknown): ReadonlyArray<ConfigWarning>;
|
|
227
235
|
type Validation = {
|
|
228
236
|
readonly value: SegmentStreamAgentConfig;
|
|
229
237
|
readonly issues?: undefined;
|
|
@@ -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 { effectiveGroupPolicy, groupPolicy, ignoredGroupSettings } from "./lib/group-routing/policy.mjs";
|
|
7
|
+
import { effectiveGroupPolicy, groupPolicy, ignoredGroupSettings, inapplicableGroupThresholds } from "./lib/group-routing/policy.mjs";
|
|
8
8
|
import { localizedText as localizedText$1 } from "./lib/admission.mjs";
|
|
9
9
|
import { STRUCTURED_KINDS } from "./lib/telegram/structured-settings.mjs";
|
|
10
10
|
import { TELEGRAM_TEXT_KEYS } from "./lib/telegram/texts.mjs";
|
|
@@ -38,6 +38,29 @@ const ADMISSION_REPLY_KEYS = [
|
|
|
38
38
|
"refused"
|
|
39
39
|
];
|
|
40
40
|
const SESSION_SCOPES = ["chat", "thread"];
|
|
41
|
+
const IGNORED_SESSION_KEYS = [
|
|
42
|
+
"compactAt",
|
|
43
|
+
"timezone",
|
|
44
|
+
"idleResetHours"
|
|
45
|
+
];
|
|
46
|
+
const INAPPLICABLE_THRESHOLD = "applies only to the legacy and engaged policies; the conversation policy reads thresholds.reply and thresholds.defer, so remove it";
|
|
47
|
+
function configWarnings(value) {
|
|
48
|
+
const root = value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
49
|
+
return [
|
|
50
|
+
...(root?.sessions !== null && typeof root?.sessions === "object" && !Array.isArray(root.sessions) ? Object.keys(root.sessions) : []).filter((key) => IGNORED_SESSION_KEYS.includes(key)).map((key) => ({
|
|
51
|
+
path: ["sessions", key],
|
|
52
|
+
message: "no longer configures anything: eve compacts sessions and ends idle ones after limits.sessionTimeoutMs in agent.ts, so remove it"
|
|
53
|
+
})),
|
|
54
|
+
...ignoredGroupSettings(root?.groups, ["groups"]).map((path) => ({
|
|
55
|
+
path: path.split("."),
|
|
56
|
+
message: "no longer configures anything: group routing reads the chat's recent messages and has no conversation timers, so remove it"
|
|
57
|
+
})),
|
|
58
|
+
...inapplicableGroupThresholds(root?.groups).map((path) => ({
|
|
59
|
+
path: ["groups", ...path],
|
|
60
|
+
message: INAPPLICABLE_THRESHOLD
|
|
61
|
+
}))
|
|
62
|
+
];
|
|
63
|
+
}
|
|
41
64
|
var SegmentStreamAgentConfigError = class extends Error {
|
|
42
65
|
issues;
|
|
43
66
|
name = "SegmentStreamAgentConfigError";
|
|
@@ -326,12 +349,8 @@ function isSessionScope(value) {
|
|
|
326
349
|
return SESSION_SCOPES.some((scope) => scope === value);
|
|
327
350
|
}
|
|
328
351
|
let ignoredGroupSettingsReported = false;
|
|
329
|
-
const IGNORED_SESSION_KEYS = [
|
|
330
|
-
"compactAt",
|
|
331
|
-
"timezone",
|
|
332
|
-
"idleResetHours"
|
|
333
|
-
];
|
|
334
352
|
let ignoredSessionKeysReported = false;
|
|
353
|
+
let inapplicableThresholdsReported = false;
|
|
335
354
|
function sessionSettings(value, issues) {
|
|
336
355
|
const path = ["sessions"];
|
|
337
356
|
const sessions = section({
|
|
@@ -595,6 +614,11 @@ function validateConfig(input, options = {}) {
|
|
|
595
614
|
ignoredGroupSettingsReported = true;
|
|
596
615
|
console.warn(`[segmentstream] agent/segmentstream.json: ${ignoredGroups.join(", ")} no longer configure anything and are ignored. Group routing has no conversation timers: the classifier reads the chat's last groups.smart.context.messages messages, however old; remove these keys.`);
|
|
597
616
|
}
|
|
617
|
+
const inapplicable = inapplicableGroupThresholds(root?.groups);
|
|
618
|
+
if (inapplicable.length > 0 && !inapplicableThresholdsReported) {
|
|
619
|
+
inapplicableThresholdsReported = true;
|
|
620
|
+
console.warn(`[segmentstream] agent/segmentstream.json: ${inapplicable.map((path) => ["groups", ...path].join(".")).join(", ")} ${INAPPLICABLE_THRESHOLD}.`);
|
|
621
|
+
}
|
|
598
622
|
let authoredGroups = root?.groups;
|
|
599
623
|
if (authoredGroups !== void 0 && groupPolicyIssues(authoredGroups).length === 0) try {
|
|
600
624
|
authoredGroups = expandGroupFiles(authoredGroups, (path) => {
|
|
@@ -750,4 +774,4 @@ function manifestOf(config) {
|
|
|
750
774
|
if (validation.issues !== void 0) throw new SegmentStreamAgentConfigError(validation.issues);
|
|
751
775
|
return validation.value;
|
|
752
776
|
}
|
|
753
|
-
export { ADMISSION_REPLY_KEYS, DEFAULT_ADMISSION_LIMITS, DEFAULT_ATTACHMENTS_MODEL, DEFAULT_DECISION_MODEL, DEFAULT_IMAGE_DESCRIPTION_MODEL, DEFAULT_STT_MODEL, SESSION_SCOPES, SegmentStreamAgentConfigError, TELEGRAM_POLICIES, chatModelChoiceOf, configSchema, isLegacyAgentArchive, manifestOf, validateConfig };
|
|
777
|
+
export { ADMISSION_REPLY_KEYS, DEFAULT_ADMISSION_LIMITS, DEFAULT_ATTACHMENTS_MODEL, DEFAULT_DECISION_MODEL, DEFAULT_IMAGE_DESCRIPTION_MODEL, DEFAULT_STT_MODEL, SESSION_SCOPES, SegmentStreamAgentConfigError, TELEGRAM_POLICIES, chatModelChoiceOf, configSchema, configWarnings, isLegacyAgentArchive, manifestOf, validateConfig };
|
|
@@ -4,4 +4,4 @@ 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
|
-
export { t as agentBuild } from "../../_chunks/build-metadata-
|
|
7
|
+
export { t as agentBuild } from "../../_chunks/build-metadata-Dk0pEJxW.mjs";
|
|
@@ -78,6 +78,15 @@ export declare const IGNORED_GROUP_SETTINGS: {
|
|
|
78
78
|
export declare function ignoredGroupSetting(path: ReadonlyArray<string>): boolean;
|
|
79
79
|
/** The dotted paths of ignored settings an authored `groups` value sets, for a deploy warning. */
|
|
80
80
|
export declare function ignoredGroupSettings(value: unknown, prefix?: ReadonlyArray<string>): string[];
|
|
81
|
+
/**
|
|
82
|
+
* Paths of `engaged`, `neutral` and `humanThread` thresholds an authored `groups` value sets
|
|
83
|
+
* where the conversation policy applies and nothing reads them. Chats inherit the top level and a
|
|
84
|
+
* chat scope its parent chat; the shadow policy overlays each chat's effective policy, and takes
|
|
85
|
+
* that policy when it names none. Switching policy keeps authored thresholds
|
|
86
|
+
* (`overlaySmartPolicy`), so a threshold stays applicable while any section on an older policy
|
|
87
|
+
* inherits it.
|
|
88
|
+
*/
|
|
89
|
+
export declare function inapplicableGroupThresholds(value: unknown): string[][];
|
|
81
90
|
export declare function groupPolicy(input?: GroupPolicyInput, aliases?: {
|
|
82
91
|
readonly mode?: string;
|
|
83
92
|
readonly model?: string;
|
|
@@ -106,6 +106,61 @@ function ignoredGroupSettings(value, prefix = []) {
|
|
|
106
106
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return ignoredGroupSetting(prefix) ? [prefix.join(".")] : [];
|
|
107
107
|
return Object.entries(value).flatMap(([key, child]) => ignoredGroupSettings(child, [...prefix, key]));
|
|
108
108
|
}
|
|
109
|
+
const PARTICIPANT_THRESHOLDS = [
|
|
110
|
+
"engaged",
|
|
111
|
+
"neutral",
|
|
112
|
+
"humanThread"
|
|
113
|
+
];
|
|
114
|
+
function inapplicableGroupThresholds(value) {
|
|
115
|
+
const object = (v) => v !== null && typeof v === "object" && !Array.isArray(v) ? v : void 0;
|
|
116
|
+
const policyOf = (smart) => {
|
|
117
|
+
const policy = object(object(smart)?.engagement)?.policy;
|
|
118
|
+
return typeof policy === "string" ? policy : void 0;
|
|
119
|
+
};
|
|
120
|
+
const thresholdsOf = (smart) => object(object(smart)?.thresholds) ?? {};
|
|
121
|
+
const groups = object(value);
|
|
122
|
+
const chats = object(groups?.chats) ?? {};
|
|
123
|
+
const contexts = [{
|
|
124
|
+
path: ["smart"],
|
|
125
|
+
thresholds: thresholdsOf(groups?.smart),
|
|
126
|
+
parent: void 0,
|
|
127
|
+
policy: policyOf(groups?.smart) ?? "legacy"
|
|
128
|
+
}];
|
|
129
|
+
for (const key of Object.keys(chats).sort((a, b) => Number(a.includes("/")) - Number(b.includes("/")))) {
|
|
130
|
+
const parentKey = key.includes("/") ? key.slice(0, key.indexOf("/")) : void 0;
|
|
131
|
+
const found = contexts.findIndex((c) => c.path[1] === parentKey);
|
|
132
|
+
const parent = found === -1 ? 0 : found;
|
|
133
|
+
const smart = object(chats[key])?.smart;
|
|
134
|
+
contexts.push({
|
|
135
|
+
path: [
|
|
136
|
+
"chats",
|
|
137
|
+
key,
|
|
138
|
+
"smart"
|
|
139
|
+
],
|
|
140
|
+
thresholds: thresholdsOf(smart),
|
|
141
|
+
parent,
|
|
142
|
+
policy: policyOf(smart) ?? contexts[parent].policy
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const shadow = object(groups?.observability)?.shadow;
|
|
146
|
+
const shadowThresholds = thresholdsOf(shadow);
|
|
147
|
+
const shadowPolicy = policyOf(shadow);
|
|
148
|
+
const source = (index, key) => {
|
|
149
|
+
for (let i = index; i !== void 0; i = contexts[i].parent) if (key in contexts[i].thresholds) return i;
|
|
150
|
+
};
|
|
151
|
+
const shadowReads = (key) => shadow !== void 0 && shadowPolicy !== void 0 && shadowPolicy !== "conversation" && !(key in shadowThresholds);
|
|
152
|
+
const participant = (thresholds) => Object.keys(thresholds).filter((key) => PARTICIPANT_THRESHOLDS.includes(key));
|
|
153
|
+
return [...contexts.flatMap((context, index) => context.policy !== "conversation" ? [] : participant(context.thresholds).filter((key) => !shadowReads(key) && !contexts.some((other, i) => other.policy !== "conversation" && source(i, key) === index)).map((key) => [
|
|
154
|
+
...context.path,
|
|
155
|
+
"thresholds",
|
|
156
|
+
key
|
|
157
|
+
])), ...(shadowPolicy ?? (contexts.some((c) => c.policy !== "conversation") ? "" : "conversation")) === "conversation" ? participant(shadowThresholds).map((key) => [
|
|
158
|
+
"observability",
|
|
159
|
+
"shadow",
|
|
160
|
+
"thresholds",
|
|
161
|
+
key
|
|
162
|
+
]) : []];
|
|
163
|
+
}
|
|
109
164
|
function authored(value, source) {
|
|
110
165
|
return Object.fromEntries(Object.entries(sources(value, source)).filter(([path]) => !ignoredGroupSetting(path.split("."))));
|
|
111
166
|
}
|
|
@@ -188,4 +243,4 @@ function effectiveGroupPolicy(base, key) {
|
|
|
188
243
|
if (thresholds.defer !== void 0 && thresholds.defer > thresholds.reply) throw new RangeError("Group thresholds must satisfy defer <= reply after inheritance.");
|
|
189
244
|
return result;
|
|
190
245
|
}
|
|
191
|
-
export { DEFAULT_CRITERIA, DEFAULT_GROUP_POLICY, ENGAGED_CRITERIA, ENGAGED_INSTRUCTIONS, IGNORED_GROUP_SETTINGS, LEGACY_INSTRUCTIONS, effectiveGroupPolicy, groupPolicy, ignoredGroupSetting, ignoredGroupSettings, overlaySmartPolicy, smartPolicy };
|
|
246
|
+
export { DEFAULT_CRITERIA, DEFAULT_GROUP_POLICY, ENGAGED_CRITERIA, ENGAGED_INSTRUCTIONS, IGNORED_GROUP_SETTINGS, LEGACY_INSTRUCTIONS, effectiveGroupPolicy, groupPolicy, ignoredGroupSetting, ignoredGroupSettings, inapplicableGroupThresholds, overlaySmartPolicy, smartPolicy };
|
|
@@ -10,7 +10,7 @@ import { groupRoutingHealth } from "../group-routing/health.mjs";
|
|
|
10
10
|
import { dispatchStructuredMessage, structuredMessage } from "./structured.mjs";
|
|
11
11
|
import { handleWorkspaceCallback, isWorkspaceCallback } from "./callbacks.mjs";
|
|
12
12
|
import { telegramText, withTelegramTexts } from "./texts.mjs";
|
|
13
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
13
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-Dk0pEJxW.mjs";
|
|
14
14
|
import { attachmentLifecycle } from "./lifecycle.mjs";
|
|
15
15
|
import { manifestOf } from "../../config.mjs";
|
|
16
16
|
import { gatewayAttachmentDescriber } from "./attachment-description.mjs";
|
|
@@ -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 { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
7
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-Dk0pEJxW.mjs";
|
|
8
8
|
import { runtimeRequestFailure } from "./runtime-request.mjs";
|
|
9
9
|
import { GET } from "eve/channels";
|
|
10
10
|
const HEALTH_ROUTE = "/eve/v1/telegram/health";
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { d as telegramRuntimeSource, l as principalRuntimeSource, u as runtimeEnvelope } from "../../../_chunks/principal-UlkbLrgQ.mjs";
|
|
8
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
8
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-Dk0pEJxW.mjs";
|
|
9
9
|
import { n as currentInboundRequest } from "../../../_chunks/inbound-request-DgQB4g1J.mjs";
|
|
10
10
|
import { object } from "../confirmation-description.mjs";
|
|
11
11
|
import { needsConfirmation } from "../confirmations.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "Mount a SegmentStream workspace's agent on eve: the ontology as tools, acting as the member who writes, and Telegram through the workspace's connection.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|