@segmentstream/agent 0.47.0 → 0.50.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 +75 -0
- package/README.md +14 -15
- package/dist/_chunks/{build-metadata-5S6uTvyu.mjs → build-metadata-DrQtDIMX.mjs} +1 -1
- package/dist/_chunks/principal-D5Tualrk.mjs +1836 -0
- package/dist/extension/channels/slack.mjs +2 -1
- package/dist/extension/channels/whatsapp.mjs +1 -0
- package/dist/extension/connections/ontology.mjs +1 -1
- package/dist/extension/hooks/authorization.mjs +1 -1
- package/dist/extension/instructions/persona.mjs +1 -1
- package/dist/extension/lib/actor.mjs +1 -46
- package/dist/extension/lib/attachment-tools.mjs +1 -3
- package/dist/extension/lib/attachments.d.ts +1 -1
- package/dist/extension/lib/attachments.mjs +1 -230
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/chat-address.mjs +1 -50
- package/dist/extension/lib/chat-context.mjs +1 -1
- package/dist/extension/lib/chat-recorder.mjs +1 -2
- package/dist/extension/lib/confirmations.mjs +1 -179
- package/dist/extension/lib/inbound-media/files.d.ts +91 -0
- package/dist/extension/lib/inbound-media/files.mjs +7 -0
- package/dist/extension/lib/{telegram → inbound-media}/images.d.ts +2 -0
- package/dist/extension/lib/{telegram → inbound-media}/images.mjs +1 -2
- package/dist/extension/lib/inbound-media/index.d.ts +55 -0
- package/dist/extension/lib/inbound-media/index.mjs +7 -0
- package/dist/extension/lib/inbound-media/plan.d.ts +59 -0
- package/dist/extension/lib/{telegram/media-policy.mjs → inbound-media/plan.mjs} +56 -4
- package/dist/extension/lib/inbound-media/report.d.ts +5 -0
- package/dist/extension/lib/inbound-media/report.mjs +7 -0
- package/dist/extension/lib/inbound-media/speech.d.ts +52 -0
- package/dist/extension/lib/inbound-media/speech.mjs +73 -0
- package/dist/extension/lib/ontology-connection.mjs +1 -101
- package/dist/extension/lib/ontology-file-call.mjs +1 -4
- package/dist/extension/lib/ontology-tools.mjs +1 -377
- package/dist/extension/lib/review/hold.mjs +1 -2
- package/dist/extension/lib/review/reply.mjs +1 -2
- 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 +1 -2
- package/dist/extension/lib/slack/adapter.d.ts +49 -7
- package/dist/extension/lib/slack/adapter.mjs +79 -21
- package/dist/extension/lib/slack/attachments-send.mjs +1 -3
- package/dist/extension/lib/slack/files.d.ts +12 -19
- package/dist/extension/lib/slack/files.mjs +26 -58
- package/dist/extension/lib/stored-files.mjs +1 -3
- package/dist/extension/lib/telegram/adapter.d.ts +3 -3
- package/dist/extension/lib/telegram/adapter.mjs +13 -17
- package/dist/extension/lib/telegram/attachment-description.d.ts +1 -1
- package/dist/extension/lib/telegram/attachment-description.mjs +2 -2
- package/dist/extension/lib/telegram/attachments-send.mjs +1 -3
- package/dist/extension/lib/telegram/callbacks.mjs +1 -2
- package/dist/extension/lib/telegram/chat-archive.mjs +1 -1
- package/dist/extension/lib/telegram/confirmations.mjs +1 -3
- package/dist/extension/lib/telegram/customer-text.mjs +1 -1
- package/dist/extension/lib/telegram/files.d.ts +8 -15
- package/dist/extension/lib/telegram/files.mjs +32 -107
- package/dist/extension/lib/telegram/health.mjs +1 -1
- package/dist/extension/lib/telegram/held-approvals.mjs +1 -1
- package/dist/extension/lib/telegram/inbound-request.d.ts +6 -12
- package/dist/extension/lib/telegram/inbound-request.mjs +1 -1
- package/dist/extension/lib/telegram/inbound.d.ts +3 -3
- package/dist/extension/lib/telegram/inbound.mjs +11 -11
- package/dist/extension/lib/telegram/lifecycle.mjs +2 -6
- package/dist/extension/lib/telegram/principal.mjs +1 -1
- package/dist/extension/lib/telegram/session-recovery.mjs +1 -1
- package/dist/extension/lib/telegram/silent.mjs +1 -1
- package/dist/extension/lib/telegram/structured.mjs +1 -1
- package/dist/extension/lib/telegram/turn-errors.mjs +1 -2
- package/dist/extension/lib/telegram/voice.d.ts +7 -38
- package/dist/extension/lib/telegram/voice.mjs +1 -64
- package/dist/extension/lib/telegram/workspace-action.mjs +1 -3
- package/dist/extension/lib/web/auth.d.ts +27 -4
- package/dist/extension/lib/web/auth.mjs +1 -124
- package/dist/extension/lib/web/channel.d.ts +13 -4
- package/dist/extension/lib/web/channel.mjs +15 -8
- package/dist/extension/lib/whatsapp/adapter.d.ts +37 -1
- package/dist/extension/lib/whatsapp/adapter.mjs +118 -21
- package/dist/extension/lib/whatsapp/files.d.ts +40 -0
- package/dist/extension/lib/whatsapp/files.mjs +70 -0
- package/dist/extension/lib/workspace-source.mjs +1 -3
- package/dist/extension/model.mjs +1 -1
- package/dist/extension/tools/attachments_discard.mjs +1 -1
- package/dist/extension/tools/attachments_list.mjs +1 -1
- package/dist/extension/tools/attachments_promote.mjs +1 -5
- package/dist/extension/tools/attachments_read.mjs +1 -1
- package/dist/extension/tools/attachments_send.mjs +1 -2
- package/dist/extension/tools/attachments_stage.mjs +1 -1
- package/dist/extension/tools/attachments_table.mjs +1 -1
- package/dist/extension/tools/questions_ask.mjs +1 -2
- package/dist/extension/tools/workspace_source.mjs +1 -1
- package/package.json +2 -2
- package/dist/_chunks/inbound-request-B3RhCuOw.mjs +0 -413
- package/dist/_chunks/principal-Dzs8hUDB.mjs +0 -128
- package/dist/extension/lib/telegram/media-policy.d.ts +0 -15
|
@@ -9,6 +9,7 @@ import { segmentstreamSlack } from "../lib/slack/adapter.mjs";
|
|
|
9
9
|
var slack_default = segmentstreamSlack({
|
|
10
10
|
settings: () => segmentstream.config.channels.slack,
|
|
11
11
|
admission: () => segmentstream.config,
|
|
12
|
-
groups: () => segmentstream.config.groups
|
|
12
|
+
groups: () => segmentstream.config.groups,
|
|
13
|
+
models: () => segmentstream.config.models
|
|
13
14
|
});
|
|
14
15
|
export { slack_default as default };
|
|
@@ -10,6 +10,7 @@ import { decide } from "eve/ai";
|
|
|
10
10
|
var whatsapp_default = segmentstreamWhatsApp({
|
|
11
11
|
settings: () => segmentstream.config.channels.whatsapp,
|
|
12
12
|
admission: () => segmentstream.config,
|
|
13
|
+
models: () => segmentstream.config.models,
|
|
13
14
|
review: {
|
|
14
15
|
settings: () => segmentstream.config.review,
|
|
15
16
|
decide: (options) => decide(options),
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import segmentstream from "../extension.mjs";
|
|
8
|
-
import { ontologyConnection } from "
|
|
8
|
+
import { E as ontologyConnection } from "../../_chunks/principal-D5Tualrk.mjs";
|
|
9
9
|
import { defineDynamic } from "eve/connections";
|
|
10
10
|
var ontology_default = defineDynamic(async (context) => {
|
|
11
11
|
if (!segmentstream.config.ontology.connection) return null;
|
|
@@ -7,7 +7,7 @@ __eveCreateRequire(import.meta.url);
|
|
|
7
7
|
import segmentstream from "../extension.mjs";
|
|
8
8
|
import { localizedText } from "../lib/admission.mjs";
|
|
9
9
|
import { confirmationLocale } from "../lib/telegram/confirmation-text.mjs";
|
|
10
|
-
import "../../_chunks/principal-
|
|
10
|
+
import "../../_chunks/principal-D5Tualrk.mjs";
|
|
11
11
|
import { defineHook } from "eve/hooks";
|
|
12
12
|
var authorization_default = defineHook({ events: { "interaction.opened": (event, context) => {
|
|
13
13
|
const principal = context.session.auth.current;
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import segmentstream from "../extension.mjs";
|
|
8
|
-
import { a as rolesOf } from "../../_chunks/principal-
|
|
8
|
+
import { a as rolesOf } from "../../_chunks/principal-D5Tualrk.mjs";
|
|
9
9
|
import { personaFor } from "../personas.mjs";
|
|
10
10
|
import { defineDynamic, defineInstructions } from "eve/instructions";
|
|
11
11
|
var persona_default = defineDynamic((context) => {
|
|
@@ -4,49 +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
|
-
|
|
8
|
-
import { i as memberIdOf, r as identityProviderOf } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
9
|
-
import { AGENT_GRANT_HEADER, webGrantOf } from "./web/auth.mjs";
|
|
10
|
-
import { defineDynamic } from "eve/tools";
|
|
11
|
-
const ACT_AS_HEADER = "X-SegmentStream-Act-As";
|
|
12
|
-
function member(memberId) {
|
|
13
|
-
return {
|
|
14
|
-
kind: "member",
|
|
15
|
-
memberId
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function actorOf(principal) {
|
|
19
|
-
const taskId = agentTaskIdOf(principal);
|
|
20
|
-
if (taskId !== void 0) return {
|
|
21
|
-
kind: "task",
|
|
22
|
-
taskId
|
|
23
|
-
};
|
|
24
|
-
const memberId = memberIdOf(principal);
|
|
25
|
-
return memberId === void 0 ? void 0 : member(memberId);
|
|
26
|
-
}
|
|
27
|
-
function actorKey(actor) {
|
|
28
|
-
return actor.kind === "member" ? `member:${actor.memberId}` : `task:${actor.taskId}`;
|
|
29
|
-
}
|
|
30
|
-
var ActorRequiredError = class extends Error {
|
|
31
|
-
name = "ActorRequiredError";
|
|
32
|
-
};
|
|
33
|
-
function actorHeaders(input) {
|
|
34
|
-
const { actor } = input;
|
|
35
|
-
if (actor.kind === "task") {
|
|
36
|
-
const secret = (input.secret ?? taskSecret)(actor.taskId);
|
|
37
|
-
if (secret === void 0) throw new ActorRequiredError("The task is no longer live in this session.");
|
|
38
|
-
return { [AGENT_TASK_HEADER]: secret };
|
|
39
|
-
}
|
|
40
|
-
const provider = memberIdOf(input.principal) === actor.memberId ? identityProviderOf(input.principal) : void 0;
|
|
41
|
-
const grant = provider === "web" ? webGrantOf(input.principal) : void 0;
|
|
42
|
-
if (provider === "web" && grant === void 0) throw new ActorRequiredError("The web session carries no agent token grant.");
|
|
43
|
-
return {
|
|
44
|
-
[ACT_AS_HEADER]: actor.memberId,
|
|
45
|
-
...provider === void 0 ? {} : { "X-SegmentStream-Identity-Provider": provider },
|
|
46
|
-
...grant === void 0 ? {} : { [AGENT_GRANT_HEADER]: grant }
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function memberTool(tool) {
|
|
50
|
-
return defineDynamic((context) => actorOf(context.session.auth.current)?.kind === "task" ? null : tool);
|
|
51
|
-
}
|
|
52
|
-
export { ACT_AS_HEADER, ActorRequiredError, actorHeaders, actorKey, actorOf, member, memberTool };
|
|
7
|
+
export { z as ACT_AS_HEADER, B as ActorRequiredError, V as actorHeaders, H as actorKey, U as actorOf, W as member, G as memberTool } from "../../_chunks/principal-D5Tualrk.mjs";
|
|
@@ -4,13 +4,11 @@ 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 { agentAttachments } from "
|
|
7
|
+
import { S as agentAttachments, i as memberIdOf, ot as chatAddressOf } from "../../_chunks/principal-D5Tualrk.mjs";
|
|
8
8
|
import { detectFile, documentText } from "./attachment-formats.mjs";
|
|
9
9
|
import { readSheets, typedTable } from "./attachment-tables.mjs";
|
|
10
10
|
import { appOrigin } from "./environment.mjs";
|
|
11
11
|
import { runtimeToken } from "./runtime-token.mjs";
|
|
12
|
-
import { chatAddressOf } from "./chat-address.mjs";
|
|
13
|
-
import { i as memberIdOf } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
14
12
|
const MAXIMUM_TEXT_CHARACTERS = 5e4;
|
|
15
13
|
const MAXIMUM_INLINE_BYTES = 5242880;
|
|
16
14
|
var AttachmentOwnerError = class extends Error {
|
|
@@ -21,7 +21,7 @@ export declare const SESSION_HEADER = "X-SegmentStream-Agent-Session";
|
|
|
21
21
|
/** The URL protocol of a file part that names a stored attachment instead of a Telegram file. */
|
|
22
22
|
export declare const ATTACHMENT_URL_PROTOCOL = "segmentstream-attachment:";
|
|
23
23
|
/** Where an attachment comes from: a channel's message, or the agent's sandbox. */
|
|
24
|
-
export type AttachmentSource = "telegram" | "slack" | "sandbox";
|
|
24
|
+
export type AttachmentSource = "telegram" | "slack" | "whatsapp" | "sandbox";
|
|
25
25
|
/** Who asks for attachment access, from the turn: the member, chat and agent session. */
|
|
26
26
|
export interface AttachmentOwner {
|
|
27
27
|
readonly memberId: string;
|
|
@@ -4,233 +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
|
-
|
|
8
|
-
import { ACT_AS_HEADER } from "./actor.mjs";
|
|
9
|
-
import { createHash } from "node:crypto";
|
|
10
|
-
const MAXIMUM_ATTACHMENT_BYTES = MAXIMUM_DOWNLOAD_BYTES;
|
|
11
|
-
const ATTACHMENT_TTL_HOURS = 24;
|
|
12
|
-
const CHAT_HEADER = "X-SegmentStream-Agent-Chat";
|
|
13
|
-
const EARLIER_CHAT_HEADER = "X-SegmentStream-Agent-Conversation";
|
|
14
|
-
const SESSION_HEADER = "X-SegmentStream-Agent-Session";
|
|
15
|
-
const ATTACHMENT_URL_PROTOCOL = "segmentstream-attachment:";
|
|
16
|
-
const CALL_TIMEOUT_MS = 3e4;
|
|
17
|
-
const TRANSFER_TIMEOUT_MS = 12e4;
|
|
18
|
-
var AttachmentError = class extends Error {
|
|
19
|
-
name = "AttachmentError";
|
|
20
|
-
code;
|
|
21
|
-
status;
|
|
22
|
-
constructor(input) {
|
|
23
|
-
super(input.message, input.cause === void 0 ? void 0 : { cause: input.cause });
|
|
24
|
-
this.code = input.code;
|
|
25
|
-
this.status = input.status;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
function isRecord(value) {
|
|
29
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30
|
-
}
|
|
31
|
-
function invalid(call) {
|
|
32
|
-
return new AttachmentError({
|
|
33
|
-
code: "invalid_response",
|
|
34
|
-
message: `The ontology service answered the ${call} with an invalid body.`
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
function attachmentOf(value, call) {
|
|
38
|
-
if (!isRecord(value) || typeof value.id !== "string" || typeof value.filename !== "string" || typeof value.content_type !== "string" || typeof value.size !== "number" || typeof value.sha256 !== "string" || typeof value.state !== "string" || typeof value.created_at !== "string" || typeof value.expires_at !== "string") throw invalid(call);
|
|
39
|
-
return {
|
|
40
|
-
id: value.id,
|
|
41
|
-
filename: value.filename,
|
|
42
|
-
contentType: value.content_type,
|
|
43
|
-
size: value.size,
|
|
44
|
-
sha256: value.sha256,
|
|
45
|
-
state: value.state,
|
|
46
|
-
createdAt: value.created_at,
|
|
47
|
-
expiresAt: value.expires_at,
|
|
48
|
-
promotion: value.promotion ?? null
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function grantOf(value, call) {
|
|
52
|
-
if (!isRecord(value) || typeof value.url !== "string" || value.method !== "GET" && value.method !== "PUT" || !isRecord(value.headers)) throw invalid(call);
|
|
53
|
-
return {
|
|
54
|
-
url: value.url,
|
|
55
|
-
method: value.method,
|
|
56
|
-
headers: Object.fromEntries(Object.entries(value.headers).filter((entry) => typeof entry[1] === "string"))
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
async function refusal(response, call) {
|
|
60
|
-
const status = response.status;
|
|
61
|
-
let value;
|
|
62
|
-
try {
|
|
63
|
-
value = await response.json();
|
|
64
|
-
} catch (error) {
|
|
65
|
-
return new AttachmentError({
|
|
66
|
-
code: `http_${status}`,
|
|
67
|
-
status,
|
|
68
|
-
message: `The ontology service refused the ${call} with HTTP ${status}.`,
|
|
69
|
-
cause: error
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
const body = isRecord(value) ? value : {};
|
|
73
|
-
return new AttachmentError({
|
|
74
|
-
code: typeof body.error === "string" ? body.error : `http_${status}`,
|
|
75
|
-
status,
|
|
76
|
-
message: `${typeof body.detail === "string" ? body.detail : `HTTP ${status}`}${typeof body.request_id === "string" ? ` (request ${body.request_id})` : ""}`
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
async function boundedBytes(response, maxBytes) {
|
|
80
|
-
const declared = Number(response.headers.get("content-length") ?? "");
|
|
81
|
-
if (Number.isFinite(declared) && declared > maxBytes) throw new AttachmentError({
|
|
82
|
-
code: "too_large",
|
|
83
|
-
message: "The stored file is too large."
|
|
84
|
-
});
|
|
85
|
-
if (response.body === null) return new Uint8Array();
|
|
86
|
-
const reader = response.body.getReader();
|
|
87
|
-
const chunks = [];
|
|
88
|
-
let size = 0;
|
|
89
|
-
for (;;) {
|
|
90
|
-
const next = await reader.read();
|
|
91
|
-
if (next.done) break;
|
|
92
|
-
size += next.value.byteLength;
|
|
93
|
-
if (size > maxBytes) {
|
|
94
|
-
await reader.cancel();
|
|
95
|
-
throw new AttachmentError({
|
|
96
|
-
code: "too_large",
|
|
97
|
-
message: "The stored file is too large."
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
chunks.push(next.value);
|
|
101
|
-
}
|
|
102
|
-
return new Uint8Array(Buffer.concat(chunks));
|
|
103
|
-
}
|
|
104
|
-
function agentAttachments(input) {
|
|
105
|
-
const fetchImpl = input.fetch ?? fetch;
|
|
106
|
-
const base = `${input.origin}/api/ontology/agent/attachments`;
|
|
107
|
-
async function call(owner, path, name, body) {
|
|
108
|
-
const token = await input.token();
|
|
109
|
-
let response;
|
|
110
|
-
try {
|
|
111
|
-
response = await fetchImpl(`${base}${path}`, {
|
|
112
|
-
method: body === void 0 ? "GET" : "POST",
|
|
113
|
-
headers: {
|
|
114
|
-
authorization: `Bearer ${token}`,
|
|
115
|
-
accept: "application/json",
|
|
116
|
-
[ACT_AS_HEADER]: owner.memberId,
|
|
117
|
-
[CHAT_HEADER]: owner.chat,
|
|
118
|
-
[EARLIER_CHAT_HEADER]: owner.chat,
|
|
119
|
-
...owner.sessionId === void 0 ? {} : { [SESSION_HEADER]: owner.sessionId },
|
|
120
|
-
...body === void 0 ? {} : { "content-type": "application/json" }
|
|
121
|
-
},
|
|
122
|
-
...body === void 0 ? {} : { body: JSON.stringify(body) },
|
|
123
|
-
redirect: "error",
|
|
124
|
-
signal: AbortSignal.timeout(CALL_TIMEOUT_MS)
|
|
125
|
-
});
|
|
126
|
-
} catch (error) {
|
|
127
|
-
throw new AttachmentError({
|
|
128
|
-
code: "unavailable",
|
|
129
|
-
message: "The ontology service could not be reached.",
|
|
130
|
-
cause: error
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
if (!response.ok) throw await refusal(response, name);
|
|
134
|
-
const value = await response.json().catch(() => void 0);
|
|
135
|
-
if (!isRecord(value)) throw invalid(name);
|
|
136
|
-
return value;
|
|
137
|
-
}
|
|
138
|
-
async function transfer(grant, body) {
|
|
139
|
-
try {
|
|
140
|
-
const response = await fetchImpl(grant.url, {
|
|
141
|
-
method: grant.method,
|
|
142
|
-
headers: grant.headers,
|
|
143
|
-
...body === void 0 ? {} : { body: Buffer.from(body) },
|
|
144
|
-
redirect: "error",
|
|
145
|
-
signal: AbortSignal.timeout(TRANSFER_TIMEOUT_MS)
|
|
146
|
-
});
|
|
147
|
-
if (!response.ok) throw new AttachmentError({
|
|
148
|
-
code: "storage_refused",
|
|
149
|
-
status: response.status,
|
|
150
|
-
message: `The file storage refused the transfer with HTTP ${response.status}.`
|
|
151
|
-
});
|
|
152
|
-
return response;
|
|
153
|
-
} catch (error) {
|
|
154
|
-
if (error instanceof AttachmentError) throw error;
|
|
155
|
-
throw new AttachmentError({
|
|
156
|
-
code: "storage_unavailable",
|
|
157
|
-
message: "The file storage could not be reached.",
|
|
158
|
-
cause: error
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
async receive(owner, file) {
|
|
164
|
-
if (file.bytes.byteLength > MAXIMUM_ATTACHMENT_BYTES) throw new AttachmentError({
|
|
165
|
-
code: "too_large",
|
|
166
|
-
message: `The file is larger than the ${MAXIMUM_ATTACHMENT_BYTES / 1024 / 1024} MB the agent accepts.`
|
|
167
|
-
});
|
|
168
|
-
const reserved = await call(owner, "", "attachment", {
|
|
169
|
-
source: file.source ?? "telegram",
|
|
170
|
-
source_ref: file.sourceRef,
|
|
171
|
-
filename: file.filename,
|
|
172
|
-
content_type: file.contentType,
|
|
173
|
-
size: file.bytes.byteLength,
|
|
174
|
-
sha256: createHash("sha256").update(file.bytes).digest("hex")
|
|
175
|
-
});
|
|
176
|
-
const attachment = attachmentOf(reserved.attachment, "attachment");
|
|
177
|
-
if (attachment.state !== "received") return attachment;
|
|
178
|
-
if (reserved.upload !== void 0) await transfer(grantOf(reserved.upload, "attachment"), file.bytes);
|
|
179
|
-
return attachmentOf((await call(owner, `/${encodeURIComponent(attachment.id)}/complete`, "attachment completion", {})).attachment, "attachment completion");
|
|
180
|
-
},
|
|
181
|
-
async list(owner) {
|
|
182
|
-
const listed = await call(owner, "", "attachment list");
|
|
183
|
-
if (!Array.isArray(listed.attachments)) throw invalid("attachment list");
|
|
184
|
-
return listed.attachments.map((item) => attachmentOf(item, "attachment list"));
|
|
185
|
-
},
|
|
186
|
-
async read(owner, id) {
|
|
187
|
-
const answer = await call(owner, `/${encodeURIComponent(id)}`, "attachment read");
|
|
188
|
-
return {
|
|
189
|
-
attachment: attachmentOf(answer.attachment, "attachment read"),
|
|
190
|
-
bytes: await boundedBytes(await transfer(grantOf(answer.download, "attachment read")), MAXIMUM_ATTACHMENT_BYTES)
|
|
191
|
-
};
|
|
192
|
-
},
|
|
193
|
-
async promote(owner, id, request) {
|
|
194
|
-
const answer = await call(owner, `/${encodeURIComponent(id)}/promote`, "promotion", {
|
|
195
|
-
entity: request.entity,
|
|
196
|
-
action: request.action,
|
|
197
|
-
...request.runtime === void 0 ? {} : { _meta: { _segmentstream: request.runtime } },
|
|
198
|
-
input: request.input ?? {},
|
|
199
|
-
...request.field === void 0 ? {} : { field: request.field },
|
|
200
|
-
...request.recordId === void 0 ? {} : { record_id: request.recordId }
|
|
201
|
-
});
|
|
202
|
-
return {
|
|
203
|
-
attachment: attachmentOf(answer.attachment, "promotion"),
|
|
204
|
-
deduplicated: answer.deduplicated === true,
|
|
205
|
-
result: answer.result ?? null
|
|
206
|
-
};
|
|
207
|
-
},
|
|
208
|
-
async discard(owner, id) {
|
|
209
|
-
return attachmentOf((await call(owner, `/${encodeURIComponent(id)}/discard`, "discard", {})).attachment, "discard");
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
function attachmentUrl(input) {
|
|
214
|
-
const query = new URLSearchParams({
|
|
215
|
-
member: input.memberId,
|
|
216
|
-
chat: input.chat
|
|
217
|
-
});
|
|
218
|
-
return new URL(`${ATTACHMENT_URL_PROTOCOL}${encodeURIComponent(input.id)}?${query.toString()}`);
|
|
219
|
-
}
|
|
220
|
-
function parseAttachmentUrl(url) {
|
|
221
|
-
let parsed;
|
|
222
|
-
try {
|
|
223
|
-
parsed = new URL(url);
|
|
224
|
-
} catch {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
const id = decodeURIComponent(parsed.pathname);
|
|
228
|
-
const memberId = parsed.searchParams.get("member");
|
|
229
|
-
const chat = parsed.searchParams.get("chat") ?? parsed.searchParams.get("conversation");
|
|
230
|
-
return parsed.protocol !== "segmentstream-attachment:" || id === "" || memberId === null || chat === null ? void 0 : {
|
|
231
|
-
id,
|
|
232
|
-
memberId,
|
|
233
|
-
chat
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
export { ATTACHMENT_TTL_HOURS, ATTACHMENT_URL_PROTOCOL, AttachmentError, CHAT_HEADER, EARLIER_CHAT_HEADER, MAXIMUM_ATTACHMENT_BYTES, SESSION_HEADER, agentAttachments, attachmentUrl, parseAttachmentUrl };
|
|
7
|
+
export { h as ATTACHMENT_TTL_HOURS, g as ATTACHMENT_URL_PROTOCOL, _ as AttachmentError, v as CHAT_HEADER, y as EARLIER_CHAT_HEADER, b as MAXIMUM_ATTACHMENT_BYTES, x as SESSION_HEADER, S as agentAttachments, C as attachmentUrl, w as parseAttachmentUrl } from "../../_chunks/principal-D5Tualrk.mjs";
|
|
@@ -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-DrQtDIMX.mjs";
|
|
@@ -4,53 +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
|
-
|
|
8
|
-
const CHAT_ATTRIBUTE = "segmentstreamChat";
|
|
9
|
-
const EARLIER_CHAT_ATTRIBUTE = "segmentstreamConversation";
|
|
10
|
-
function withChatAddress(principal, chat) {
|
|
11
|
-
return {
|
|
12
|
-
...principal,
|
|
13
|
-
attributes: {
|
|
14
|
-
...principal.attributes,
|
|
15
|
-
[CHAT_ATTRIBUTE]: JSON.stringify(chat)
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function chatAddressOf(principal) {
|
|
20
|
-
if (principal === void 0 || principal === null) return;
|
|
21
|
-
const attributes = principal.attributes;
|
|
22
|
-
if (principal.authenticator === "segmentstream-telegram") {
|
|
23
|
-
const chatId = attributes.chatId;
|
|
24
|
-
return typeof chatId !== "string" || chatId === "" ? void 0 : {
|
|
25
|
-
provider: "telegram",
|
|
26
|
-
chatId,
|
|
27
|
-
threadId: String(attributes.messageThreadId ?? ""),
|
|
28
|
-
kind: chatId.startsWith("-") ? "group" : "private"
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
const value = attributes["segmentstreamChat"] ?? attributes[EARLIER_CHAT_ATTRIBUTE];
|
|
32
|
-
if (typeof value !== "string") return;
|
|
33
|
-
try {
|
|
34
|
-
return parsedChatAddress(JSON.parse(value), attributes.identityProvider);
|
|
35
|
-
} catch {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function parsedChatAddress(value, provider) {
|
|
40
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return;
|
|
41
|
-
const item = value;
|
|
42
|
-
const text = (field, empty = false) => typeof field === "string" && (empty || field !== "") && field.length <= 512;
|
|
43
|
-
if (item.provider !== "slack" && item.provider !== "whatsapp" && item.provider !== "web" || item.provider !== provider || !text(item.chatId) || !text(item.threadId, true) || item.kind !== "private" && item.kind !== "group" || item.peer !== void 0 && !text(item.peer)) return;
|
|
44
|
-
return {
|
|
45
|
-
provider: item.provider,
|
|
46
|
-
chatId: item.chatId,
|
|
47
|
-
threadId: item.threadId,
|
|
48
|
-
kind: item.kind,
|
|
49
|
-
...item.peer === void 0 ? {} : { peer: item.peer }
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function isSameChat(chat, destination) {
|
|
53
|
-
if (chat.provider !== destination.provider) return false;
|
|
54
|
-
return chat.chatId === destination.externalId || chat.provider !== "telegram" && chat.kind === "private" && chat.peer === destination.externalId;
|
|
55
|
-
}
|
|
56
|
-
export { CHAT_ATTRIBUTE, chatAddressOf, isSameChat, withChatAddress };
|
|
7
|
+
export { at as CHAT_ATTRIBUTE, ot as chatAddressOf, st as isSameChat, ct as withChatAddress } from "../../_chunks/principal-D5Tualrk.mjs";
|
|
@@ -7,7 +7,7 @@ __eveCreateRequire(import.meta.url);
|
|
|
7
7
|
import { agentTaskIdOf } from "./agent-task.mjs";
|
|
8
8
|
import { chatCoordinates } from "./chat-recorder.mjs";
|
|
9
9
|
import { chatArchive, collapseChatEvents, topicContext } from "./chat-archive.mjs";
|
|
10
|
-
import {
|
|
10
|
+
import { _t as reportTelegramError } from "../../_chunks/principal-D5Tualrk.mjs";
|
|
11
11
|
import { createHash } from "node:crypto";
|
|
12
12
|
import { deliveries, runs, turns } from "eve/events";
|
|
13
13
|
import { defineState } from "eve/context";
|
|
@@ -7,8 +7,7 @@ __eveCreateRequire(import.meta.url);
|
|
|
7
7
|
import { n as contentText, t as CONTENT_CAPS } from "../../_chunks/content-cDtVnr8Y.mjs";
|
|
8
8
|
import { chatArchive, chatEvent, sessionFailureEventId, summarizeArguments } from "./chat-archive.mjs";
|
|
9
9
|
import { agentTaskIdOf } from "./agent-task.mjs";
|
|
10
|
-
import { chatAddressOf } from "
|
|
11
|
-
import { i as memberIdOf } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
10
|
+
import { i as memberIdOf, ot as chatAddressOf } from "../../_chunks/principal-D5Tualrk.mjs";
|
|
12
11
|
import { parseAddress } from "./telegram/sessions.mjs";
|
|
13
12
|
import { completionKind } from "./telegram/silent.mjs";
|
|
14
13
|
import { recordModelServiceAlert } from "./model-service-alert.mjs";
|
|
@@ -4,182 +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
|
-
|
|
8
|
-
import { i as memberIdOf } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
9
|
-
import { ConfirmationRefused, UnsafeConfirmationTarget } from "./confirmation-description.mjs";
|
|
10
|
-
import { chatPostDigest, isChatPost } from "./chat-post-confirmation.mjs";
|
|
11
|
-
import { promptFits } from "./confirmation-buttons.mjs";
|
|
12
|
-
import { chatAddressOf, isSameChat } from "./chat-address.mjs";
|
|
13
|
-
import { confirmationCopy, confirmationCopyIssue, confirmationLocale, renderConfirmation } from "./telegram/confirmation-text.mjs";
|
|
14
|
-
import { chatPostCard, chatPostPrompt } from "./telegram/chat-post-card.mjs";
|
|
15
|
-
import { withTelegramTexts } from "./telegram/texts.mjs";
|
|
16
|
-
import { createHash } from "node:crypto";
|
|
17
|
-
import { defineState } from "eve/context";
|
|
18
|
-
const CONFIRMATION_TTL_MS = 6e5;
|
|
19
|
-
function needsConfirmation(labels) {
|
|
20
|
-
return labels.readOnlyHint !== true && (labels.destructiveHint === true || labels.irreversibleHint === true || labels.openWorldHint === true || labels.destructiveHint === void 0 && labels.irreversibleHint === void 0);
|
|
21
|
-
}
|
|
22
|
-
function canonical(value) {
|
|
23
|
-
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
24
|
-
if (typeof value === "object" && value !== null) return `{${Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`).join(",")}}`;
|
|
25
|
-
const encoded = JSON.stringify(value);
|
|
26
|
-
if (encoded === void 0) throw new TypeError("Action input must be JSON.");
|
|
27
|
-
return encoded;
|
|
28
|
-
}
|
|
29
|
-
function inputHash(input) {
|
|
30
|
-
return createHash("sha256").update(canonical(input)).digest("hex");
|
|
31
|
-
}
|
|
32
|
-
function isSameSource(saved, current) {
|
|
33
|
-
return current !== void 0 && saved.provider === current.provider && saved.chatId === current.chatId && saved.threadId === current.threadId;
|
|
34
|
-
}
|
|
35
|
-
const confirmations = defineState("segmentstream.confirmations", () => ({}));
|
|
36
|
-
function connectionHints(ctx) {
|
|
37
|
-
const hints = ctx.toolAnnotations;
|
|
38
|
-
return typeof hints === "object" && hints !== null && !Array.isArray(hints) ? hints : void 0;
|
|
39
|
-
}
|
|
40
|
-
function actionApproval(options) {
|
|
41
|
-
const state = options.state ?? confirmations;
|
|
42
|
-
const now = options.now ?? Date.now;
|
|
43
|
-
const denied = (reason) => ({
|
|
44
|
-
type: "denied",
|
|
45
|
-
reason
|
|
46
|
-
});
|
|
47
|
-
return {
|
|
48
|
-
prompt({ callId }) {
|
|
49
|
-
try {
|
|
50
|
-
return state.get()[callId]?.prompt;
|
|
51
|
-
} catch {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
async request(ctx) {
|
|
56
|
-
const actor = actorOf(ctx.session.auth.current);
|
|
57
|
-
if (actor?.kind === "task") {
|
|
58
|
-
if (isChatPost(ctx.toolName)) return denied("Chat posting is unavailable in a task.");
|
|
59
|
-
if (connectionHints(ctx) !== void 0) return "approved";
|
|
60
|
-
try {
|
|
61
|
-
await options.labels(actor, ctx.toolName, ctx.toolInput ?? {});
|
|
62
|
-
} catch (error) {
|
|
63
|
-
console.warn("The ontology action permission check failed.", error);
|
|
64
|
-
return denied("The action is unavailable or the task's role does not permit it.");
|
|
65
|
-
}
|
|
66
|
-
return "approved";
|
|
67
|
-
}
|
|
68
|
-
const memberId = actor?.memberId;
|
|
69
|
-
if (memberId === void 0) return denied("A paired member is required.");
|
|
70
|
-
const present = (run) => options.texts === void 0 ? run() : withTelegramTexts(options.texts(), run, () => confirmationLocale(ctx.session.auth.current));
|
|
71
|
-
const hash = inputHash(ctx.toolInput ?? {});
|
|
72
|
-
const saved = state.get()[ctx.callId];
|
|
73
|
-
if (saved !== void 0) {
|
|
74
|
-
if (saved.memberId !== memberId || saved.action !== ctx.toolName || saved.inputHash !== hash) return denied("The confirmation belongs to another member, action or input.");
|
|
75
|
-
if (saved.expiresAt <= now()) return denied("The confirmation expired. Make a new call.");
|
|
76
|
-
if (saved.status === "consumed" || saved.status === "cancelled") return denied("The confirmation has already been used or cancelled.");
|
|
77
|
-
}
|
|
78
|
-
const hints = connectionHints(ctx);
|
|
79
|
-
if (saved === void 0 && !isChatPost(ctx.toolName) && hints !== void 0 && !needsConfirmation(hints)) return "approved";
|
|
80
|
-
let labels;
|
|
81
|
-
try {
|
|
82
|
-
labels = await options.labels(member(memberId), ctx.toolName, ctx.toolInput ?? {}, void 0, hints);
|
|
83
|
-
} catch (error) {
|
|
84
|
-
console.warn("The ontology action permission check failed.", error);
|
|
85
|
-
return denied("The action is unavailable or the member no longer has permission.");
|
|
86
|
-
}
|
|
87
|
-
const offered = options.copy === void 0 ? ctx.toolInput?._confirmation : options.copy(member(memberId), ctx.toolInput ?? {});
|
|
88
|
-
const copy = labels.confirmation === false ? void 0 : confirmationCopy(offered);
|
|
89
|
-
const businessInput = Object.fromEntries(Object.entries(ctx.toolInput ?? {}).filter(([key]) => key !== "_confirmation"));
|
|
90
|
-
const posting = isChatPost(ctx.toolName);
|
|
91
|
-
let description;
|
|
92
|
-
const missingCopy = () => denied((offered === void 0 ? "This action needs a confirmation card and the call has no _confirmation. " : `The call's _confirmation is invalid: ${confirmationCopyIssue(offered) ?? "it cannot be shown"}. `) + "Make the call again with _confirmation (for a file call, in its arguments file) in the chat's language: a plain single-line question naming the action and its key records and amounts (at most 300 characters), and short confirm, cancel, done, cancelled and failed labels without emoji.");
|
|
93
|
-
if (posting && saved === void 0 && labels.confirmation === true && copy === void 0) return missingCopy();
|
|
94
|
-
let prompt;
|
|
95
|
-
const chat = chatAddressOf(ctx.session.auth.current);
|
|
96
|
-
if (posting) try {
|
|
97
|
-
description = await options.describe?.(member(memberId), ctx.toolName, businessInput, hints);
|
|
98
|
-
const preview = description?.chatPost;
|
|
99
|
-
if (description === void 0 || preview === void 0 || chat === void 0 || isSameChat(chat, preview)) return denied("A complete preview for a different chat is required. Reply normally in this chat.");
|
|
100
|
-
const previewDescription = {
|
|
101
|
-
...description,
|
|
102
|
-
warning: labels.destructiveHint === true || labels.irreversibleHint === true
|
|
103
|
-
};
|
|
104
|
-
if (chat.provider === "telegram") present(() => chatPostCard(previewDescription, copy));
|
|
105
|
-
else {
|
|
106
|
-
prompt = present(() => chatPostPrompt(previewDescription, copy));
|
|
107
|
-
if (!promptFits(chat.provider, prompt)) return denied("The full message does not fit this chat's confirmation card. Make a shorter draft.");
|
|
108
|
-
}
|
|
109
|
-
if (saved !== void 0 && (saved.description?.chatPost === void 0 || chatPostDigest(saved.description.chatPost) !== chatPostDigest(preview) || saved.source === void 0 || !isSameSource(saved.source, chat))) return denied("The destination or attribution changed. Make a new call and confirmation.");
|
|
110
|
-
} catch (error) {
|
|
111
|
-
console.warn("The exact chat confirmation could not be prepared.", error);
|
|
112
|
-
return denied("The full exact chat preview is unavailable or too long. Make a new call.");
|
|
113
|
-
}
|
|
114
|
-
if (saved?.status === "approved") {
|
|
115
|
-
state.update((all) => ({
|
|
116
|
-
...all,
|
|
117
|
-
[ctx.callId]: {
|
|
118
|
-
...saved,
|
|
119
|
-
status: "consumed"
|
|
120
|
-
}
|
|
121
|
-
}));
|
|
122
|
-
return "approved";
|
|
123
|
-
}
|
|
124
|
-
if (saved !== void 0) return denied("The original call is waiting for its Confirm / Cancel buttons.");
|
|
125
|
-
if (!posting && !needsConfirmation(labels)) return "approved";
|
|
126
|
-
if (labels.confirmation === true && labels.preview !== true && copy === void 0) return missingCopy();
|
|
127
|
-
try {
|
|
128
|
-
if (!posting) description = await options.describe?.(member(memberId), ctx.toolName, businessInput, hints, confirmationLocale(ctx.session.auth.current));
|
|
129
|
-
if (description === void 0) throw new Error("A trusted confirmation description is required.");
|
|
130
|
-
} catch (error) {
|
|
131
|
-
if (error instanceof ConfirmationRefused) return denied(`The action refuses this input, so no card was shown and nothing ran: ${error.reason} Tell the member why in their language, in a short message; do not ask them to confirm it and do not make the same call again.`);
|
|
132
|
-
console.warn("The confirmation description could not be read.", error);
|
|
133
|
-
if (error instanceof UnsafeConfirmationTarget) return denied(`No confirmation card can name the ${error.label}: its title is missing, unreadable, or looks like a file name, link or identifier. Another call will be refused the same way; tell the member, who can rename that record or make the change in the app.`);
|
|
134
|
-
return denied("Trusted confirmation facts are incomplete, unsafe or too long. Resolve every target title and narrow the input before making a new call.");
|
|
135
|
-
}
|
|
136
|
-
description = description === void 0 ? void 0 : {
|
|
137
|
-
...description,
|
|
138
|
-
warning: labels.destructiveHint === true || labels.irreversibleHint === true
|
|
139
|
-
};
|
|
140
|
-
try {
|
|
141
|
-
if (!posting) prompt = present(() => renderConfirmation(description, copy)).text;
|
|
142
|
-
} catch {
|
|
143
|
-
return denied("The complete confirmation facts are unsafe or too long. Narrow the action input.");
|
|
144
|
-
}
|
|
145
|
-
if (prompt !== void 0 && !promptFits(ctx.session.auth.current?.attributes.identityProvider, prompt)) return denied("The complete confirmation facts are too long for this chat's confirmation card. Narrow the action input.");
|
|
146
|
-
state.update((all) => ({
|
|
147
|
-
...all,
|
|
148
|
-
[ctx.callId]: {
|
|
149
|
-
memberId,
|
|
150
|
-
action: ctx.toolName,
|
|
151
|
-
inputHash: hash,
|
|
152
|
-
expiresAt: now() + CONFIRMATION_TTL_MS,
|
|
153
|
-
status: "pending",
|
|
154
|
-
...copy === void 0 ? {} : { copy },
|
|
155
|
-
...description === void 0 ? {} : { description },
|
|
156
|
-
...prompt === void 0 ? {} : { prompt },
|
|
157
|
-
...posting && chat !== void 0 ? { source: chat } : {}
|
|
158
|
-
}
|
|
159
|
-
}));
|
|
160
|
-
return "user-approval";
|
|
161
|
-
},
|
|
162
|
-
response(ctx) {
|
|
163
|
-
const saved = state.get()[ctx.request.callId];
|
|
164
|
-
const reject = (reason) => ({
|
|
165
|
-
status: "rejected",
|
|
166
|
-
reason
|
|
167
|
-
});
|
|
168
|
-
if (saved === void 0 || saved.status !== "pending") return reject("This confirmation is no longer pending.");
|
|
169
|
-
if (ctx.response.principal.attributes.confirmationRequestId !== ctx.request.interactionId || ctx.response.principal.attributes.confirmationDecision !== (ctx.response.decision === "deny" ? "cancel" : "approve")) return reject("Use the Confirm or Cancel button on the action's message.");
|
|
170
|
-
if (memberIdOf(ctx.response.principal) !== saved.memberId || memberIdOf(ctx.request.principal) !== saved.memberId) return reject("Only the requesting member can confirm or cancel this action.");
|
|
171
|
-
if (saved.action !== ctx.request.toolName || saved.inputHash !== inputHash(ctx.request.toolInput ?? {})) return reject("The action or input changed. Make a new call.");
|
|
172
|
-
if (ctx.response.decision === "approve" && saved.expiresAt <= now()) return reject("This confirmation expired.");
|
|
173
|
-
state.update((all) => ({
|
|
174
|
-
...all,
|
|
175
|
-
[ctx.request.callId]: {
|
|
176
|
-
...saved,
|
|
177
|
-
status: ctx.response.decision === "approve" ? "approved" : "cancelled",
|
|
178
|
-
...ctx.response.decision === "deny" && ["edit", "expired"].includes(String(ctx.response.principal.attributes.confirmationReason)) ? { cancellationReason: ctx.response.principal.attributes.confirmationReason } : {}
|
|
179
|
-
}
|
|
180
|
-
}));
|
|
181
|
-
return { status: "allowed" };
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
export { CONFIRMATION_TTL_MS, actionApproval, confirmations, inputHash, needsConfirmation };
|
|
7
|
+
export { P as CONFIRMATION_TTL_MS, F as actionApproval, I as confirmations, L as inputHash, R as needsConfirmation } from "../../_chunks/principal-D5Tualrk.mjs";
|