@segmentstream/agent 0.10.1 → 0.10.2
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-BD1PqnN9.mjs → build-metadata-D8CuCrak.mjs} +1 -1
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/ontology-tools.d.ts +4 -0
- package/dist/extension/lib/ontology-tools.mjs +5 -2
- package/dist/extension/lib/telegram/adapter.mjs +1 -1
- package/dist/extension/lib/telegram/health.mjs +1 -1
- package/dist/extension/lib/telegram/inbound.mjs +17 -5
- package/dist/extension/lib/telegram/lifecycle.d.ts +4 -0
- package/dist/extension/lib/telegram/lifecycle.mjs +10 -4
- 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.10.
|
|
7
|
+
var version = "0.10.2";
|
|
8
8
|
function agentBuild(environment = process.env) {
|
|
9
9
|
return {
|
|
10
10
|
agent: version,
|
|
@@ -4,5 +4,5 @@ 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-D8CuCrak.mjs";
|
|
8
8
|
export { agentBuild };
|
|
@@ -6,6 +6,10 @@ import { type RuntimeToken } from "./runtime-token.js";
|
|
|
6
6
|
export declare class OntologyToolRejected extends Error {
|
|
7
7
|
readonly code = "ontology_tool_rejected";
|
|
8
8
|
}
|
|
9
|
+
/** The member's permission-filtered catalog has no such action; retrying cannot change that. */
|
|
10
|
+
export declare class OntologyActionNotPermitted extends Error {
|
|
11
|
+
readonly code = "ontology_action_not_permitted";
|
|
12
|
+
}
|
|
9
13
|
/** A fresh, permission-filtered catalog. Listing tools cannot run an action's prepare step. */
|
|
10
14
|
export declare function ontologyTools(options?: {
|
|
11
15
|
readonly principal?: SessionAuthContext | null;
|
|
@@ -14,6 +14,9 @@ import { randomUUID } from "node:crypto";
|
|
|
14
14
|
var OntologyToolRejected = class extends Error {
|
|
15
15
|
code = "ontology_tool_rejected";
|
|
16
16
|
};
|
|
17
|
+
var OntologyActionNotPermitted = class extends Error {
|
|
18
|
+
code = "ontology_action_not_permitted";
|
|
19
|
+
};
|
|
17
20
|
function ontologyTools(options = {}) {
|
|
18
21
|
async function rpc(memberId, method, params, signal) {
|
|
19
22
|
const provider = memberIdOf(options.principal) === memberId ? identityProviderOf(options.principal) : void 0;
|
|
@@ -87,7 +90,7 @@ function ontologyTools(options = {}) {
|
|
|
87
90
|
const candidate = object(object(inspected.structuredContent).tool);
|
|
88
91
|
if (candidate.name === bareName) tool = candidate;
|
|
89
92
|
}
|
|
90
|
-
if (tool === void 0) throw new
|
|
93
|
+
if (tool === void 0) throw new OntologyActionNotPermitted("Action not permitted.");
|
|
91
94
|
return {
|
|
92
95
|
tool,
|
|
93
96
|
tools
|
|
@@ -218,4 +221,4 @@ function promotionTarget(input) {
|
|
|
218
221
|
}
|
|
219
222
|
};
|
|
220
223
|
}
|
|
221
|
-
export { OntologyToolRejected, actionToolName, ontologyToolLabels, ontologyTools, promotionTarget };
|
|
224
|
+
export { OntologyActionNotPermitted, OntologyToolRejected, actionToolName, ontologyToolLabels, ontologyTools, promotionTarget };
|
|
@@ -14,7 +14,7 @@ import { runtimeToken } from "../runtime-token.mjs";
|
|
|
14
14
|
import { groupSettings } from "../group-routing/settings.mjs";
|
|
15
15
|
import { conversations } from "../conversations.mjs";
|
|
16
16
|
import { archivedRoutingMessages } from "../group-routing/routing-context.mjs";
|
|
17
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
17
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-D8CuCrak.mjs";
|
|
18
18
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
19
19
|
import { telegramSendScope } from "./send-queue.mjs";
|
|
20
20
|
import { d as failureText, h as withDeliveryLocale, i as withReplacedText, m as safeTelegramFetch, n as currentInboundRequest, p as reportTelegramError, r as runInboundRequest, t as InboundRequest } from "../../../_chunks/inbound-request-BrWspFw5.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-D8CuCrak.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";
|
|
@@ -13,7 +13,7 @@ import { conversationContext, routeMessage } from "../group-routing/router.mjs";
|
|
|
13
13
|
import { observedContext } from "../group-routing/observed.mjs";
|
|
14
14
|
import { debounceBurst, routingBurst } from "../group-routing/burst.mjs";
|
|
15
15
|
import { p as reportTelegramError } from "../../../_chunks/inbound-request-BrWspFw5.mjs";
|
|
16
|
-
import { startTypingHeartbeat, typingUntilComplete } from "./lifecycle.mjs";
|
|
16
|
+
import { AttachmentLifecycleNotPermitted, startTypingHeartbeat, typingUntilComplete } from "./lifecycle.mjs";
|
|
17
17
|
import { formatAddress, messageAddress, scopedAddress } from "./sessions.mjs";
|
|
18
18
|
import { contentShape, messageContent } from "./content.mjs";
|
|
19
19
|
import { messageAudience } from "./audience.mjs";
|
|
@@ -408,12 +408,24 @@ async function handleInboundMessage(input) {
|
|
|
408
408
|
});
|
|
409
409
|
}
|
|
410
410
|
} catch (error) {
|
|
411
|
-
input.request.
|
|
411
|
+
input.request.lifecycle = void 0;
|
|
412
|
+
if (!(error instanceof AttachmentLifecycleNotPermitted)) {
|
|
413
|
+
input.request.retryReference = reportTelegramError("intake_admission_failed", error, {
|
|
414
|
+
chatId: sent.chat.id,
|
|
415
|
+
messageId: sent.messageId
|
|
416
|
+
});
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
input.request.stopTyping?.();
|
|
420
|
+
input.request.stopTyping = void 0;
|
|
421
|
+
console.info("[segmentstream] telegram.phase", {
|
|
422
|
+
phase: "lifecycle_not_permitted",
|
|
423
|
+
traceId: input.request.traceId,
|
|
424
|
+
at: new Date().toISOString(),
|
|
412
425
|
chatId: sent.chat.id,
|
|
413
|
-
messageId: sent.messageId
|
|
426
|
+
messageId: sent.messageId,
|
|
427
|
+
memberId: member.id
|
|
414
428
|
});
|
|
415
|
-
input.request.lifecycle = void 0;
|
|
416
|
-
return null;
|
|
417
429
|
}
|
|
418
430
|
}
|
|
419
431
|
if (input.request !== void 0) {
|
|
@@ -26,6 +26,10 @@ export interface LifecycleResult {
|
|
|
26
26
|
readonly input: Record<string, unknown>;
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
+
/** The sender may not run the lifecycle action, so the hook does not apply to their message. */
|
|
30
|
+
export declare class AttachmentLifecycleNotPermitted extends Error {
|
|
31
|
+
readonly code = "attachment_lifecycle_not_permitted";
|
|
32
|
+
}
|
|
29
33
|
/** Opt-in workspace action; the workspace owns grouping, copy, retention and completion decisions. */
|
|
30
34
|
export declare function attachmentLifecycle(options: {
|
|
31
35
|
readonly configuration: AttachmentLifecycle;
|
|
@@ -4,11 +4,14 @@ 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-D8CuCrak.mjs";
|
|
8
8
|
import { object } from "../confirmation-description.mjs";
|
|
9
9
|
import { n as currentInboundRequest, p as reportTelegramError } from "../../../_chunks/inbound-request-BrWspFw5.mjs";
|
|
10
10
|
import { needsConfirmation } from "../confirmations.mjs";
|
|
11
|
-
import { actionToolName, ontologyTools } from "../ontology-tools.mjs";
|
|
11
|
+
import { OntologyActionNotPermitted, actionToolName, ontologyTools } from "../ontology-tools.mjs";
|
|
12
|
+
var AttachmentLifecycleNotPermitted = class extends Error {
|
|
13
|
+
code = "attachment_lifecycle_not_permitted";
|
|
14
|
+
};
|
|
12
15
|
function attachmentLifecycle(options) {
|
|
13
16
|
const tools = ontologyTools(options);
|
|
14
17
|
const action = actionToolName(options.configuration.entity, options.configuration.action);
|
|
@@ -37,7 +40,10 @@ function attachmentLifecycle(options) {
|
|
|
37
40
|
...options.configuration.contextVersion === 2 && typeof options.message.raw?.date === "number" && Number.isSafeInteger(options.message.raw.date) && options.message.raw.date > 0 ? { source_at: options.message.raw.date * 1e3 } : {}
|
|
38
41
|
}
|
|
39
42
|
};
|
|
40
|
-
|
|
43
|
+
const labels = await tools.labels(options.memberId, action, input).catch((error) => {
|
|
44
|
+
throw error instanceof OntologyActionNotPermitted ? new AttachmentLifecycleNotPermitted("The sender may not run the lifecycle action.", { cause: error }) : error;
|
|
45
|
+
});
|
|
46
|
+
if (needsConfirmation(labels)) throw new Error("An attachment lifecycle hook must be a permitted routine action.");
|
|
41
47
|
const raw = await tools.rpc(options.memberId, "tools/call", {
|
|
42
48
|
name: action,
|
|
43
49
|
arguments: input
|
|
@@ -165,4 +171,4 @@ function startTypingHeartbeat(telegram) {
|
|
|
165
171
|
if (timer !== void 0) clearTimeout(timer);
|
|
166
172
|
};
|
|
167
173
|
}
|
|
168
|
-
export { attachmentLifecycle, startTypingHeartbeat, typingUntilComplete };
|
|
174
|
+
export { AttachmentLifecycleNotPermitted, attachmentLifecycle, startTypingHeartbeat, typingUntilComplete };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/agent",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
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",
|