@segmentstream/agent 0.82.2 → 0.83.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 +9 -0
- package/dist/_chunks/{build-metadata-BLzTREgp.mjs → build-metadata-Bo-QTQbc.mjs} +1 -1
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/chat-context.mjs +6 -3
- package/dist/extension/lib/review/client.d.ts +4 -1
- package/dist/extension/lib/review/client.mjs +9 -5
- package/dist/extension/lib/review/hold.d.ts +6 -0
- package/dist/extension/lib/review/hold.mjs +2 -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 +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.83.0
|
|
4
|
+
|
|
5
|
+
A held reply names the turn that wrote it (`turn_id`), so the ontology can tell whether the person
|
|
6
|
+
wrote after it. An ontology service from before it refuses the field, and the reply is held
|
|
7
|
+
without it. A session takes a draft status it does not know, such as the new `dismissed`, for a
|
|
8
|
+
reply the person never received.
|
|
9
|
+
|
|
10
|
+
Pins @segmentstream/ontology 0.161.0.
|
|
11
|
+
|
|
3
12
|
## 0.82.2
|
|
4
13
|
|
|
5
14
|
Pins @segmentstream/ontology 0.160.0.
|
|
@@ -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.83.0";
|
|
8
8
|
function agentBuild(environment = process.env) {
|
|
9
9
|
return {
|
|
10
10
|
agent: version,
|
|
@@ -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-Bo-QTQbc.mjs";
|
|
@@ -17,16 +17,19 @@ const HELD_STATUSES = {
|
|
|
17
17
|
uncertain: "uncertain",
|
|
18
18
|
failed: "not_sent",
|
|
19
19
|
rejected: "not_sent",
|
|
20
|
-
superseded: "not_sent"
|
|
20
|
+
superseded: "not_sent",
|
|
21
|
+
dismissed: "not_sent"
|
|
21
22
|
};
|
|
23
|
+
function heldStatus(status) {
|
|
24
|
+
return Object.hasOwn(HELD_STATUSES, status) ? HELD_STATUSES[status] : "not_sent";
|
|
25
|
+
}
|
|
22
26
|
const HELD_REPLY_TEXT = 1e3;
|
|
23
27
|
const HELD_REPLIES_REMEMBERED = 200;
|
|
24
28
|
function heldRepliesBlock(reviews, shown) {
|
|
25
29
|
const entries = [];
|
|
26
30
|
const next = { ...shown };
|
|
27
31
|
for (const review of [...reviews].reverse()) {
|
|
28
|
-
const status =
|
|
29
|
-
if (status === void 0) continue;
|
|
32
|
+
const status = heldStatus(review.status);
|
|
30
33
|
const before = shown[review.id];
|
|
31
34
|
next[review.id] = status;
|
|
32
35
|
if (before === status || before === void 0 && status === "sent" && !review.edited) continue;
|
|
@@ -14,7 +14,10 @@ export declare function agentReviews(input: {
|
|
|
14
14
|
/** What became of a reply an agent session held for review, as the ontology service answers. */
|
|
15
15
|
export interface SessionReview {
|
|
16
16
|
readonly id: string;
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* `pending`, `sent`, `uncertain`, `failed`, `rejected`, `superseded` or `dismissed`; a status an
|
|
19
|
+
* ontology adds later is read as never sent.
|
|
20
|
+
*/
|
|
18
21
|
readonly status: string;
|
|
19
22
|
/** The reply as the session wrote it. */
|
|
20
23
|
readonly draft: string;
|
|
@@ -43,7 +43,8 @@ function agentReviews(input) {
|
|
|
43
43
|
session_id: reply.sessionId,
|
|
44
44
|
text: reply.text,
|
|
45
45
|
mode: reply.mode,
|
|
46
|
-
confidence: reply.confidence
|
|
46
|
+
confidence: reply.confidence,
|
|
47
|
+
...named.turnId === void 0 ? {} : { turn_id: named.turnId }
|
|
47
48
|
}),
|
|
48
49
|
redirect: "error",
|
|
49
50
|
signal: AbortSignal.timeout(CALL_TIMEOUT_MS)
|
|
@@ -58,17 +59,20 @@ function agentReviews(input) {
|
|
|
58
59
|
};
|
|
59
60
|
let response = await send({
|
|
60
61
|
recipients,
|
|
61
|
-
participants
|
|
62
|
+
participants,
|
|
63
|
+
turnId: reply.turnId
|
|
62
64
|
});
|
|
63
|
-
if (response.status === 400 && (recipients !== void 0 || participants !== void 0)) {
|
|
65
|
+
if (response.status === 400 && (recipients !== void 0 || participants !== void 0 || reply.turnId !== void 0)) {
|
|
64
66
|
const refused = await refusedFields(response);
|
|
65
67
|
const withoutCopies = recipients !== void 0 && (refused.has("to") || refused.has("cc"));
|
|
66
68
|
const withoutReaders = participants !== void 0 && refused.has("participants");
|
|
69
|
+
const withoutTurn = reply.turnId !== void 0 && refused.has("turn_id");
|
|
67
70
|
if (withoutCopies) console.error("[segmentstream] reply held without its copies: the ontology predates them", { key: reply.key });
|
|
68
71
|
if (withoutReaders) console.error("[segmentstream] reply held without its readers: the ontology predates them", { key: reply.key });
|
|
69
|
-
if (withoutCopies || withoutReaders) response = await send({
|
|
72
|
+
if (withoutCopies || withoutReaders || withoutTurn) response = await send({
|
|
70
73
|
recipients: withoutCopies ? void 0 : recipients,
|
|
71
|
-
participants: withoutReaders ? void 0 : participants
|
|
74
|
+
participants: withoutReaders ? void 0 : participants,
|
|
75
|
+
turnId: withoutTurn ? void 0 : reply.turnId
|
|
72
76
|
});
|
|
73
77
|
}
|
|
74
78
|
if (!response.ok) {
|
|
@@ -49,6 +49,11 @@ export interface HeldReply {
|
|
|
49
49
|
readonly mode: "always" | "whenUnsure";
|
|
50
50
|
/** The decision model's probability that staff would send it as written; null when unjudged. */
|
|
51
51
|
readonly confidence: number | null;
|
|
52
|
+
/**
|
|
53
|
+
* The turn that wrote the reply: the draft names it, and where the turn read the chat to, so that
|
|
54
|
+
* a message the person wrote after it is known to be one the reply did not see.
|
|
55
|
+
*/
|
|
56
|
+
readonly turnId?: string;
|
|
52
57
|
}
|
|
53
58
|
/** Reports a held reply; resolves when the review exists. */
|
|
54
59
|
export type HoldReply = (reply: HeldReply) => Promise<void>;
|
|
@@ -81,6 +86,7 @@ export declare function heldReply(input: {
|
|
|
81
86
|
readonly sessionId: string;
|
|
82
87
|
readonly partId: string;
|
|
83
88
|
readonly text: string;
|
|
89
|
+
readonly turnId?: string | null;
|
|
84
90
|
readonly outcome: Extract<ReviewOutcome, {
|
|
85
91
|
send: false;
|
|
86
92
|
}>;
|
|
@@ -61,7 +61,8 @@ function heldReply(input) {
|
|
|
61
61
|
sessionId: input.sessionId,
|
|
62
62
|
text: input.text,
|
|
63
63
|
mode: input.outcome.mode,
|
|
64
|
-
confidence: input.outcome.confidence
|
|
64
|
+
confidence: input.outcome.confidence,
|
|
65
|
+
...input.turnId === void 0 || input.turnId === null || input.turnId === "" ? {} : { turnId: input.turnId }
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
export { heldReply, repliesReviewed, reviewOf, reviewOutcome };
|
|
@@ -10,7 +10,7 @@ import { groupRoutingHealth } from "../group-routing/health.mjs";
|
|
|
10
10
|
import { dispatchStructuredMessage, structuredMessage } from "./structured.mjs";
|
|
11
11
|
import { handleWorkspaceCallback } 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-Bo-QTQbc.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-Bo-QTQbc.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 { E as OntologyActionNotPermitted, Et as principalRuntimeSource, L as needsConfirmation, Ot as runtimeEnvelope, W as member, c as currentInboundRequest, j as ontologyTools, k as actionToolName, kt as telegramRuntimeSource } from "../../../_chunks/principal-dEQyjF1n.mjs";
|
|
8
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
8
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-Bo-QTQbc.mjs";
|
|
9
9
|
import { object } from "../confirmation-description.mjs";
|
|
10
10
|
var AttachmentLifecycleNotPermitted = class extends Error {
|
|
11
11
|
code = "attachment_lifecycle_not_permitted";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.83.0",
|
|
4
4
|
"description": "The SegmentStream workspace agent: the ontology as tools, acting as the member who writes, and the browser, Telegram, WhatsApp and Slack through the workspace's connections.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@chat-adapter/state-memory": "4.42.0",
|
|
89
89
|
"@chat-adapter/telegram": "4.41.0",
|
|
90
90
|
"@chat-adapter/whatsapp": "4.42.0",
|
|
91
|
-
"@segmentstream/ontology": "0.
|
|
91
|
+
"@segmentstream/ontology": "0.161.0",
|
|
92
92
|
"@vercel/oidc": "^3.8.4",
|
|
93
93
|
"ai": "^7.0.172",
|
|
94
94
|
"chat": "4.42.0",
|