@segmentstream/agent 0.52.1 → 0.54.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 +74 -0
- package/README.md +17 -4
- package/dist/_chunks/{build-metadata-DJ3WHCte.mjs → build-metadata-2TyBXJEt.mjs} +1 -1
- package/dist/_chunks/{principal-JoaOmdFL.mjs → principal-DUla0Xge.mjs} +53 -23
- package/dist/extension/config.d.ts +23 -1
- package/dist/extension/config.mjs +37 -3
- package/dist/extension/connections/ontology.mjs +1 -1
- package/dist/extension/hooks/authorization.mjs +1 -1
- package/dist/extension/hooks/guest-usage.d.ts +3 -0
- package/dist/extension/hooks/guest-usage.mjs +11 -0
- package/dist/extension/instructions/persona.mjs +1 -1
- package/dist/extension/instructions.md +8 -5
- package/dist/extension/lib/actor.mjs +1 -1
- package/dist/extension/lib/attachment-tools.mjs +1 -1
- package/dist/extension/lib/attachments-send.d.ts +84 -0
- package/dist/extension/lib/attachments-send.mjs +88 -0
- package/dist/extension/lib/attachments.d.ts +1 -2
- package/dist/extension/lib/attachments.mjs +1 -1
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/chat-address.d.ts +11 -0
- package/dist/extension/lib/chat-address.mjs +1 -1
- package/dist/extension/lib/chat-archive.d.ts +35 -0
- package/dist/extension/lib/chat-archive.mjs +37 -1
- package/dist/extension/lib/chat-context.d.ts +1 -1
- package/dist/extension/lib/chat-context.mjs +4 -3
- package/dist/extension/lib/chat-recorder.mjs +3 -2
- package/dist/extension/lib/confirmations.d.ts +6 -1
- package/dist/extension/lib/confirmations.mjs +1 -1
- package/dist/extension/lib/email/attachments-send.d.ts +43 -0
- package/dist/extension/lib/email/attachments-send.mjs +130 -0
- package/dist/extension/lib/email/channel.d.ts +7 -1
- package/dist/extension/lib/email/channel.mjs +222 -53
- package/dist/extension/lib/email/gmail.d.ts +22 -6
- package/dist/extension/lib/email/gmail.mjs +101 -5
- package/dist/extension/lib/email/message.d.ts +19 -0
- package/dist/extension/lib/email/message.mjs +22 -1
- package/dist/extension/lib/guest-usage.d.ts +53 -0
- package/dist/extension/lib/guest-usage.mjs +52 -0
- package/dist/extension/lib/inbound-media/files.mjs +1 -1
- package/dist/extension/lib/inbound-media/index.mjs +1 -1
- package/dist/extension/lib/ontology-connection.mjs +1 -1
- package/dist/extension/lib/ontology-file-call.mjs +2 -1
- package/dist/extension/lib/ontology-tools.d.ts +2 -0
- package/dist/extension/lib/ontology-tools.mjs +1 -1
- package/dist/extension/lib/review/hold.mjs +1 -1
- package/dist/extension/lib/review/judge.mjs +2 -2
- package/dist/extension/lib/review/reply.mjs +1 -1
- package/dist/extension/lib/role-skill.mjs +1 -1
- package/dist/extension/lib/runtime-envelope.mjs +1 -1
- package/dist/extension/lib/sent-files.d.ts +29 -9
- package/dist/extension/lib/sent-files.mjs +36 -14
- package/dist/extension/lib/slack/adapter.mjs +1 -1
- package/dist/extension/lib/slack/attachments-send.d.ts +6 -14
- package/dist/extension/lib/slack/attachments-send.mjs +128 -170
- package/dist/extension/lib/stored-files.mjs +1 -1
- package/dist/extension/lib/telegram/adapter.mjs +2 -2
- package/dist/extension/lib/telegram/attachment-description.mjs +1 -1
- package/dist/extension/lib/telegram/attachments-send.mjs +9 -12
- package/dist/extension/lib/telegram/callbacks.mjs +1 -1
- package/dist/extension/lib/telegram/chat-archive.mjs +1 -1
- package/dist/extension/lib/telegram/confirmations.mjs +2 -2
- package/dist/extension/lib/telegram/customer-text.mjs +1 -1
- package/dist/extension/lib/telegram/files.mjs +1 -1
- 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.mjs +1 -1
- package/dist/extension/lib/telegram/inbound.mjs +1 -1
- package/dist/extension/lib/telegram/lifecycle.mjs +2 -2
- 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 -1
- package/dist/extension/lib/telegram/workspace-action.mjs +1 -1
- package/dist/extension/lib/web/auth.d.ts +18 -4
- package/dist/extension/lib/web/auth.mjs +1 -1
- package/dist/extension/lib/web/channel.d.ts +10 -3
- package/dist/extension/lib/web/channel.mjs +10 -3
- package/dist/extension/lib/whatsapp/adapter.mjs +1 -1
- package/dist/extension/lib/whatsapp/attachments-send.d.ts +35 -0
- package/dist/extension/lib/whatsapp/attachments-send.mjs +117 -0
- package/dist/extension/lib/whatsapp/files.mjs +1 -1
- package/dist/extension/lib/workspace-source.mjs +1 -1
- 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 -1
- package/dist/extension/tools/attachments_read.mjs +1 -1
- package/dist/extension/tools/attachments_send.mjs +18 -7
- 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 -1
- package/dist/extension/tools/unanswered.d.ts +2 -0
- package/dist/extension/tools/unanswered.mjs +39 -0
- package/dist/extension/tools/workspace_source.mjs +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.mjs +2 -1
- package/package.json +2 -2
|
@@ -4,15 +4,12 @@ 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 {
|
|
8
|
-
import {
|
|
7
|
+
import { _ as AttachmentError } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
8
|
+
import { sendStoredAttachments } from "../attachments-send.mjs";
|
|
9
9
|
import { MAXIMUM_PROXY_BODY_BYTES, connectionProxy } from "../connection-proxy.mjs";
|
|
10
10
|
import { redactDiagnostic } from "../diagnostics.mjs";
|
|
11
|
-
import {
|
|
12
|
-
import { transientFileStatus } from "../file-grant.mjs";
|
|
13
|
-
import { runtimeToken } from "../runtime-token.mjs";
|
|
11
|
+
import { proxyEnvironment } from "../environment.mjs";
|
|
14
12
|
import { StoredFileError, fetchStoredFile } from "../sent-files.mjs";
|
|
15
|
-
import { confirmationLocale } from "../telegram/confirmation-text.mjs";
|
|
16
13
|
import { proxiedSlackFetch } from "./adapter.mjs";
|
|
17
14
|
import { randomUUID } from "node:crypto";
|
|
18
15
|
const SLACK_API = "https://slack.com/api/";
|
|
@@ -36,172 +33,133 @@ function reportSlackError(operation, error, secrets) {
|
|
|
36
33
|
return reference;
|
|
37
34
|
}
|
|
38
35
|
async function sendSlackAttachments(options) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
detail: failureText(reference, "attachment", locale),
|
|
51
|
-
reference
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
const chat = chatAddressOf(principal);
|
|
55
|
-
if (!channelsEnabled(environment)) return unavailable("channels_disabled", "Attachments can be sent only in production.");
|
|
56
|
-
if (options.connection === void 0) return unavailable("unsupported", "The Slack channel is not configured.");
|
|
57
|
-
if (chat?.provider !== "slack") return unavailable("no_slack_chat", "This turn has no Slack chat.");
|
|
58
|
-
let owner;
|
|
59
|
-
try {
|
|
60
|
-
owner = attachmentOwner({
|
|
61
|
-
principal,
|
|
62
|
-
sessionId: options.sessionId
|
|
63
|
-
});
|
|
64
|
-
} catch (error) {
|
|
65
|
-
const reference = reportSlackError("attachment_owner_refused", error, secrets);
|
|
66
|
-
return {
|
|
67
|
-
error: "forbidden",
|
|
68
|
-
detail: failureText(reference, "attachment", locale),
|
|
69
|
-
reference
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
const runtimeToken$1 = options.token ?? runtimeToken;
|
|
73
|
-
const token = async () => {
|
|
74
|
-
const value = await runtimeToken$1();
|
|
75
|
-
secrets.add(value);
|
|
76
|
-
return value;
|
|
77
|
-
};
|
|
78
|
-
const fetchImpl = options.fetch ?? fetch;
|
|
79
|
-
const connection = options.connection;
|
|
80
|
-
const slack = proxiedSlackFetch(() => connectionProxy({
|
|
81
|
-
environment: proxyEnvironment(environment),
|
|
82
|
-
connection,
|
|
83
|
-
token,
|
|
84
|
-
fetch: fetchImpl
|
|
85
|
-
}), fetchImpl);
|
|
86
|
-
const call = async (method, init) => {
|
|
87
|
-
const response = await slack(`${SLACK_API}${method}`, {
|
|
88
|
-
method: "POST",
|
|
89
|
-
...init
|
|
90
|
-
});
|
|
91
|
-
const answer = await response.json().catch(() => void 0);
|
|
92
|
-
if (!response.ok || !isRecord(answer) || answer.ok !== true) {
|
|
93
|
-
const code = isRecord(answer) && typeof answer.error === "string" ? answer.error : "";
|
|
94
|
-
throw new AttachmentError({
|
|
95
|
-
code: code === "missing_scope" || code === "not_in_channel" ? "forbidden" : "send_failed",
|
|
96
|
-
message: `Slack refused ${method}${code === "" ? "" : `: ${code}`}.`,
|
|
97
|
-
status: response.status
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
return answer;
|
|
101
|
-
};
|
|
102
|
-
const results = options.input.documentIds.map(({ id }) => ({
|
|
103
|
-
id,
|
|
104
|
-
filename: ""
|
|
105
|
-
}));
|
|
106
|
-
const uploaded = [];
|
|
107
|
-
for (const [index, reference] of options.input.documentIds.entries()) {
|
|
108
|
-
const failed = (error, operation) => {
|
|
109
|
-
const errorReference = reportSlackError(operation, error, secrets);
|
|
110
|
-
const stored = error instanceof StoredFileError ? error : void 0;
|
|
111
|
-
results[index] = {
|
|
112
|
-
id: reference.id,
|
|
113
|
-
filename: stored?.filename ?? results[index].filename,
|
|
114
|
-
error: error instanceof AttachmentError ? error.code : "send_failed",
|
|
115
|
-
detail: failureText(errorReference, "attachment", locale),
|
|
116
|
-
reference: errorReference,
|
|
117
|
-
...error instanceof AttachmentError && error.status !== void 0 ? {
|
|
118
|
-
status: error.status,
|
|
119
|
-
retryable: transientFileStatus(error.status)
|
|
120
|
-
} : {},
|
|
121
|
-
...stored?.requestId === void 0 ? {} : { requestId: stored.requestId }
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
let file;
|
|
125
|
-
try {
|
|
126
|
-
file = await fetchStoredFile({
|
|
127
|
-
reference,
|
|
128
|
-
owner,
|
|
129
|
-
origin: appOrigin(environment),
|
|
36
|
+
return sendStoredAttachments({
|
|
37
|
+
...options,
|
|
38
|
+
provider: "slack",
|
|
39
|
+
channel: "Slack",
|
|
40
|
+
report: (operation, error, _metadata, secrets) => reportSlackError(operation, error, secrets),
|
|
41
|
+
async send(context) {
|
|
42
|
+
const { input, chat, connection, owner, origin, environment, fetch, token, secrets } = context;
|
|
43
|
+
const failed = context.failed;
|
|
44
|
+
const slack = proxiedSlackFetch(() => connectionProxy({
|
|
45
|
+
environment: proxyEnvironment(environment),
|
|
46
|
+
connection,
|
|
130
47
|
token,
|
|
131
|
-
fetch
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
48
|
+
fetch
|
|
49
|
+
}), fetch);
|
|
50
|
+
const call = async (method, init) => {
|
|
51
|
+
const response = await slack(`${SLACK_API}${method}`, {
|
|
52
|
+
method: "POST",
|
|
53
|
+
...init
|
|
54
|
+
});
|
|
55
|
+
const answer = await response.json().catch(() => void 0);
|
|
56
|
+
if (!response.ok || !isRecord(answer) || answer.ok !== true) {
|
|
57
|
+
const code = isRecord(answer) && typeof answer.error === "string" ? answer.error : "";
|
|
58
|
+
throw new AttachmentError({
|
|
59
|
+
code: code === "missing_scope" || code === "not_in_channel" ? "forbidden" : "send_failed",
|
|
60
|
+
message: `Slack refused ${method}${code === "" ? "" : `: ${code}`}.`,
|
|
61
|
+
status: response.status
|
|
62
|
+
});
|
|
138
63
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
64
|
+
return answer;
|
|
65
|
+
};
|
|
66
|
+
const results = input.documentIds.map(({ id }) => ({
|
|
67
|
+
id,
|
|
68
|
+
filename: ""
|
|
69
|
+
}));
|
|
70
|
+
const uploaded = [];
|
|
71
|
+
for (const [index, reference] of input.documentIds.entries()) {
|
|
72
|
+
const fail = (error, operation) => {
|
|
73
|
+
const stored = error instanceof StoredFileError ? error : void 0;
|
|
74
|
+
results[index] = {
|
|
75
|
+
id: reference.id,
|
|
76
|
+
filename: stored?.filename ?? results[index].filename,
|
|
77
|
+
...failed(error, operation)
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
let file;
|
|
81
|
+
try {
|
|
82
|
+
file = await fetchStoredFile({
|
|
83
|
+
reference,
|
|
84
|
+
owner,
|
|
85
|
+
origin,
|
|
86
|
+
token,
|
|
87
|
+
fetch,
|
|
88
|
+
secrets,
|
|
89
|
+
tooLarge: () => refused("too_large", PROXY_LIMIT),
|
|
90
|
+
limit: ({ size }) => {
|
|
91
|
+
if (size > 2097152) throw refused("too_large", PROXY_LIMIT);
|
|
92
|
+
if (size === 0) throw refused("unsupported", "Slack cannot share an empty file.");
|
|
93
|
+
return MAXIMUM_PROXY_BODY_BYTES;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
} catch (error) {
|
|
97
|
+
fail(error, "stored_attachment_fetch_failed");
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
results[index] = {
|
|
101
|
+
id: reference.id,
|
|
102
|
+
filename: file.filename
|
|
103
|
+
};
|
|
104
|
+
try {
|
|
105
|
+
const ticket = await call("files.getUploadURLExternal", {
|
|
106
|
+
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
107
|
+
body: new URLSearchParams({
|
|
108
|
+
filename: file.filename,
|
|
109
|
+
length: String(file.bytes.byteLength)
|
|
110
|
+
}).toString()
|
|
111
|
+
});
|
|
112
|
+
if (typeof ticket.upload_url !== "string" || typeof ticket.file_id !== "string") throw refused("invalid_response", "Slack answered no upload address.");
|
|
113
|
+
secrets.add(ticket.upload_url);
|
|
114
|
+
const upload = await slack(ticket.upload_url, {
|
|
115
|
+
method: "POST",
|
|
116
|
+
headers: { "content-type": file.contentType },
|
|
117
|
+
body: Buffer.from(file.bytes)
|
|
118
|
+
});
|
|
119
|
+
await upload.body?.cancel();
|
|
120
|
+
if (!upload.ok) throw new AttachmentError({
|
|
121
|
+
code: "send_failed",
|
|
122
|
+
message: "Slack refused the file's bytes.",
|
|
123
|
+
status: upload.status
|
|
124
|
+
});
|
|
125
|
+
uploaded.push({
|
|
126
|
+
index,
|
|
127
|
+
slackId: ticket.file_id
|
|
128
|
+
});
|
|
129
|
+
} catch (error) {
|
|
130
|
+
fail(error, "attachment_upload_failed");
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (uploaded.length === 0) return { files: results };
|
|
134
|
+
try {
|
|
135
|
+
const shared = await call("files.completeUploadExternal", {
|
|
136
|
+
headers: { "content-type": "application/json; charset=utf-8" },
|
|
137
|
+
body: JSON.stringify({
|
|
138
|
+
files: uploaded.map(({ index, slackId }) => ({
|
|
139
|
+
id: slackId,
|
|
140
|
+
title: results[index].filename
|
|
141
|
+
})),
|
|
142
|
+
channel_id: chat.chatId,
|
|
143
|
+
...chat.threadId === "" ? {} : { thread_ts: chat.threadId },
|
|
144
|
+
...input.caption === void 0 ? {} : { initial_comment: input.caption }
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
if (!Array.isArray(shared.files)) throw refused("invalid_response", "Slack did not answer the shared files.");
|
|
148
|
+
for (const { index, slackId } of uploaded) results[index] = {
|
|
149
|
+
...results[index],
|
|
150
|
+
slackFileId: slackId
|
|
151
|
+
};
|
|
152
|
+
} catch (error) {
|
|
153
|
+
const failure = failed(error, "attachment_share_failed");
|
|
154
|
+
for (const { index } of uploaded) results[index] = {
|
|
155
|
+
...results[index],
|
|
156
|
+
error: failure.error,
|
|
157
|
+
detail: failure.detail,
|
|
158
|
+
reference: failure.reference
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
return { files: results };
|
|
175
162
|
}
|
|
176
|
-
}
|
|
177
|
-
if (uploaded.length === 0) return { files: results };
|
|
178
|
-
try {
|
|
179
|
-
const shared = await call("files.completeUploadExternal", {
|
|
180
|
-
headers: { "content-type": "application/json; charset=utf-8" },
|
|
181
|
-
body: JSON.stringify({
|
|
182
|
-
files: uploaded.map(({ index, slackId }) => ({
|
|
183
|
-
id: slackId,
|
|
184
|
-
title: results[index].filename
|
|
185
|
-
})),
|
|
186
|
-
channel_id: chat.chatId,
|
|
187
|
-
...chat.threadId === "" ? {} : { thread_ts: chat.threadId },
|
|
188
|
-
...options.input.caption === void 0 ? {} : { initial_comment: options.input.caption }
|
|
189
|
-
})
|
|
190
|
-
});
|
|
191
|
-
if (!Array.isArray(shared.files)) throw refused("invalid_response", "Slack did not answer the shared files.");
|
|
192
|
-
for (const { index, slackId } of uploaded) results[index] = {
|
|
193
|
-
...results[index],
|
|
194
|
-
slackFileId: slackId
|
|
195
|
-
};
|
|
196
|
-
} catch (error) {
|
|
197
|
-
const reference = reportSlackError("attachment_share_failed", error, secrets);
|
|
198
|
-
for (const { index } of uploaded) results[index] = {
|
|
199
|
-
...results[index],
|
|
200
|
-
error: error instanceof AttachmentError ? error.code : "send_failed",
|
|
201
|
-
detail: failureText(reference, "attachment", locale),
|
|
202
|
-
reference
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
return { files: results };
|
|
163
|
+
});
|
|
206
164
|
}
|
|
207
165
|
export { sendSlackAttachments };
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { object } from "./confirmation-description.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { D as OntologyFileUnavailable, W as member, i as memberIdOf, j as ontologyTools } from "../../_chunks/principal-DUla0Xge.mjs";
|
|
9
9
|
import { redactDiagnostic } from "./diagnostics.mjs";
|
|
10
10
|
import { createHash } from "node:crypto";
|
|
11
11
|
async function readStoredFile(input, principal, options = {}) {
|
|
@@ -10,12 +10,12 @@ 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-2TyBXJEt.mjs";
|
|
14
14
|
import { attachmentLifecycle } from "./lifecycle.mjs";
|
|
15
15
|
import { manifestOf } from "../../config.mjs";
|
|
16
16
|
import { gatewayAttachmentDescriber } from "./attachment-description.mjs";
|
|
17
17
|
import { chooseModel } from "../../model.mjs";
|
|
18
|
-
import {
|
|
18
|
+
import { At as withDeliveryLocale, Et as failureText, Ot as reportTelegramError, S as fetchStoredAttachment, b as agentAttachments, c as currentInboundRequest, kt as safeTelegramFetch, l as runInboundRequest, n as chatLanguage, o as telegramPrincipal, s as InboundRequest, u as withReplacedText, xt as currentLocale } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
19
19
|
import { MAXIMUM_DOWNLOAD_BYTES, connectionProxy } from "../connection-proxy.mjs";
|
|
20
20
|
import { appOrigin, channelsEnabled, proxyEnvironment, runtimeIdentityEnvironment, webhookSecret } from "../environment.mjs";
|
|
21
21
|
import { agentIdentities } from "../identities.mjs";
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { describableImage } from "../inbound-media/images.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { Ot as reportTelegramError } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
9
9
|
import { gateway, generateText } from "ai";
|
|
10
10
|
const MAXIMUM_ROUTING_ATTACHMENT_BYTES = 5242880;
|
|
11
11
|
const ROUTING_ATTACHMENT_TIMEOUT_MS = 15e3;
|
|
@@ -5,10 +5,10 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { attachmentOwner } from "../attachment-tools.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { Dt as formattingRefused, Et as failureText, Ot as reportTelegramError, _ as AttachmentError, wt as customerMessage } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
9
|
+
import { attachmentFailure } from "../attachments-send.mjs";
|
|
9
10
|
import { MAXIMUM_PROXY_BODY_BYTES, connectionProxy } from "../connection-proxy.mjs";
|
|
10
11
|
import { redactDiagnostic } from "../diagnostics.mjs";
|
|
11
|
-
import { transientFileStatus } from "../file-grant.mjs";
|
|
12
12
|
import { StoredFileError, fetchStoredFile } from "../sent-files.mjs";
|
|
13
13
|
import { appOrigin, channelsEnabled, proxyEnvironment } from "../environment.mjs";
|
|
14
14
|
import { runtimeToken } from "../runtime-token.mjs";
|
|
@@ -144,18 +144,15 @@ async function sendAttachmentsInOrder(options) {
|
|
|
144
144
|
});
|
|
145
145
|
} catch (error) {
|
|
146
146
|
const errorId = reportTelegramError("stored_attachment_fetch_failed", error, { id: reference.id }, secrets);
|
|
147
|
-
const failed = error instanceof StoredFileError ? error : void 0;
|
|
148
147
|
results[index] = {
|
|
149
148
|
id: reference.id,
|
|
150
|
-
filename:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
} : {},
|
|
158
|
-
...failed?.requestId === void 0 ? {} : { requestId: failed.requestId }
|
|
149
|
+
filename: error instanceof StoredFileError ? error.filename : "",
|
|
150
|
+
...attachmentFailure({
|
|
151
|
+
error,
|
|
152
|
+
reference: errorId,
|
|
153
|
+
locale,
|
|
154
|
+
fallback: "unavailable"
|
|
155
|
+
})
|
|
159
156
|
};
|
|
160
157
|
}
|
|
161
158
|
function multipart(files, caption) {
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { object } from "../confirmation-description.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { Ft as telegramRuntimeSource, Ot as reportTelegramError, Pt as runtimeEnvelope, c as currentInboundRequest, i as memberIdOf, o as telegramPrincipal } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
9
9
|
import { formatAddress, parseAddress, scopedAddress } from "./sessions.mjs";
|
|
10
10
|
import { telegramText } from "./texts.mjs";
|
|
11
11
|
import { workspaceAction } from "./workspace-action.mjs";
|
|
@@ -9,7 +9,7 @@ import { n as contentText, t as CONTENT_CAPS } from "../../../_chunks/content-cD
|
|
|
9
9
|
import { chatEvent, sessionFailureEventId } from "../chat-archive.mjs";
|
|
10
10
|
import { currentConfirmationPrompt } from "../group-routing/messages.mjs";
|
|
11
11
|
import { messageMetadata } from "./message-metadata.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import { Ot as reportTelegramError, St as currentThreadId, c as currentInboundRequest } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
13
13
|
import { reportMembership } from "./membership.mjs";
|
|
14
14
|
import { currentDeliveryScope } from "./delivery-diagnostics.mjs";
|
|
15
15
|
import { contentShape, messageContent } from "./content.mjs";
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { telegramText } from "./texts.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { F as confirmations, Ot as reportTelegramError, c as currentInboundRequest, i as memberIdOf, o as telegramPrincipal } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
9
9
|
import { humanText } from "../confirmation-description.mjs";
|
|
10
10
|
import { withConfirmationPrompt } from "../group-routing/messages.mjs";
|
|
11
11
|
import { chatPostOperationId, isChatPost } from "../chat-post-confirmation.mjs";
|
|
@@ -222,7 +222,7 @@ function telegramConfirmationEvents(archive, scope) {
|
|
|
222
222
|
chatId: source.chatId,
|
|
223
223
|
chatType: source.chatId.startsWith("-") ? "group" : "private",
|
|
224
224
|
threadId: source.threadId || null,
|
|
225
|
-
participantIds: [saved.memberId],
|
|
225
|
+
participantIds: saved.memberId === void 0 ? [] : [saved.memberId],
|
|
226
226
|
kind: "tool_result",
|
|
227
227
|
operationId,
|
|
228
228
|
toolCallId: operationId,
|
|
@@ -5,5 +5,5 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { isTechnicalText } from "../customer-text-safety.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { At as withDeliveryLocale, Ct as customerCopy, Dt as formattingRefused, Et as failureText, Ot as reportTelegramError, St as currentThreadId, Tt as customerText, bt as TelegramDeliveryError, kt as safeTelegramFetch, wt as customerMessage, xt as currentLocale } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
9
9
|
export { TelegramDeliveryError, currentLocale, currentThreadId, customerCopy, customerMessage, customerText, failureText, formattingRefused, isTechnicalText, reportTelegramError, safeTelegramFetch, withDeliveryLocale };
|
|
@@ -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 {
|
|
7
|
+
import { Ot as reportTelegramError, p as storeFiles } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
8
8
|
function telegramChat(chatId) {
|
|
9
9
|
return `telegram:${chatId}`;
|
|
10
10
|
}
|
|
@@ -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-2TyBXJEt.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";
|
|
@@ -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 {
|
|
7
|
+
import { N as CONFIRMATION_TTL_MS } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
8
8
|
import { object } from "../confirmation-description.mjs";
|
|
9
9
|
import { SessionNotActiveError } from "eve/sessions";
|
|
10
10
|
function heldApprovals(events) {
|
|
@@ -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 { s as InboundRequest, c as currentInboundRequest, l as runInboundRequest, u as withReplacedText } from "../../../_chunks/principal-
|
|
7
|
+
export { s as InboundRequest, c as currentInboundRequest, l as runInboundRequest, u as withReplacedText } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
@@ -6,7 +6,7 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { WorkspaceActionAlreadyDispatched } from "./workspace-action.mjs";
|
|
8
8
|
import { structuredMessage } from "./structured.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { Ft as telegramRuntimeSource, Ot as reportTelegramError, Pt as runtimeEnvelope, f as attachmentsContext, n as chatLanguage, o as telegramPrincipal, x as attachmentUrl } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
10
10
|
import { routingBurst } from "../group-routing/burst.mjs";
|
|
11
11
|
import { telegramSignals } from "./signals.mjs";
|
|
12
12
|
import { addressingReason, chatKey, otherRecipient } from "../group-routing/signals.mjs";
|
|
@@ -4,8 +4,8 @@ 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 {
|
|
8
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
7
|
+
import { E as OntologyActionNotPermitted, Ft as telegramRuntimeSource, L as needsConfirmation, Nt as principalRuntimeSource, Pt as runtimeEnvelope, W as member, c as currentInboundRequest, j as ontologyTools, k as actionToolName } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
8
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-2TyBXJEt.mjs";
|
|
9
9
|
import { object } from "../confirmation-description.mjs";
|
|
10
10
|
var AttachmentLifecycleNotPermitted = class extends Error {
|
|
11
11
|
code = "attachment_lifecycle_not_permitted";
|
|
@@ -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 TELEGRAM_AUTHENTICATOR, n as chatLanguage, r as identityProviderOf, i as memberIdOf, a as rolesOf, o as telegramPrincipal } from "../../../_chunks/principal-
|
|
7
|
+
export { t as TELEGRAM_AUTHENTICATOR, n as chatLanguage, r as identityProviderOf, i as memberIdOf, a as rolesOf, o as telegramPrincipal } from "../../../_chunks/principal-DUla0Xge.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 {
|
|
7
|
+
import { Ot as reportTelegramError } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
8
8
|
import { createHash } from "node:crypto";
|
|
9
9
|
function strandedRun(error) {
|
|
10
10
|
if (!(error instanceof Error) || error.name !== "RunKeyFetchError" || !("status" in error) || error.status !== 404) return;
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { Ot as reportTelegramError, bt as TelegramDeliveryError, wt as customerMessage, xt as currentLocale } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
9
9
|
import { splitTelegramText } from "./format.mjs";
|
|
10
10
|
import { inTelegramSendQueue } from "./send-queue.mjs";
|
|
11
11
|
const NO_REPLY_TOOL = "no_reply";
|
|
@@ -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 {
|
|
7
|
+
import { Ft as telegramRuntimeSource, Pt as runtimeEnvelope } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
8
8
|
import { workspaceAction } from "./workspace-action.mjs";
|
|
9
9
|
import { STRUCTURED_KINDS } from "./structured-settings.mjs";
|
|
10
10
|
const record = (value) => {
|
|
@@ -7,7 +7,7 @@ __eveCreateRequire(import.meta.url);
|
|
|
7
7
|
import { telegramText } from "./texts.mjs";
|
|
8
8
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
9
9
|
import { recordSessionFailure } from "./chat-archive.mjs";
|
|
10
|
-
import { Ct as failureText,
|
|
10
|
+
import { Ct as customerCopy, Et as failureText, Ot as reportTelegramError, St as currentThreadId, i as memberIdOf, xt as currentLocale } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
11
11
|
import { modelServiceFailure } from "../model-service-failure.mjs";
|
|
12
12
|
function telegramFailureEvents(input) {
|
|
13
13
|
return {
|
|
@@ -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 {
|
|
7
|
+
import { L as needsConfirmation, W as member, j as ontologyTools, k as actionToolName } from "../../../_chunks/principal-DUla0Xge.mjs";
|
|
8
8
|
import { object } from "../confirmation-description.mjs";
|
|
9
9
|
var WorkspaceActionAlreadyDispatched = class extends Error {};
|
|
10
10
|
async function workspaceAction(input) {
|
|
@@ -24,6 +24,11 @@ export declare const WEB_GRANT_ATTRIBUTE = "webGrant";
|
|
|
24
24
|
export declare const KIND_ATTRIBUTE = "kind";
|
|
25
25
|
/** The principal attribute holding a guest's id, which names no user. */
|
|
26
26
|
export declare const GUEST_ID_ATTRIBUTE = "guestId";
|
|
27
|
+
/**
|
|
28
|
+
* The principal attribute marking a guest who may confirm actions in the website's chat, as the
|
|
29
|
+
* ontology's `guest.confirmations` allows: `"true"`.
|
|
30
|
+
*/
|
|
31
|
+
export declare const GUEST_CONFIRMATIONS_ATTRIBUTE = "guestConfirmations";
|
|
27
32
|
/** The role every guest holds, and only guests. */
|
|
28
33
|
export declare const GUEST_ROLE = "guest";
|
|
29
34
|
/** How every access token of the ontology's OAuth server, agent tokens too, begins. */
|
|
@@ -65,6 +70,8 @@ export interface WebGuest {
|
|
|
65
70
|
readonly roles: ReadonlyArray<string>;
|
|
66
71
|
/** The verbs of the `agent_tool:<verb>` permissions guests hold. */
|
|
67
72
|
readonly agentTools: ReadonlyArray<string>;
|
|
73
|
+
/** Whether the guest may confirm actions with the chat's buttons, as `guest.confirmations` says. */
|
|
74
|
+
readonly confirmations?: boolean;
|
|
68
75
|
/** For a turn the guest starts: the agent's guest limit it exceeds, and when the next may run. */
|
|
69
76
|
readonly limited?: {
|
|
70
77
|
readonly scope: string;
|
|
@@ -83,14 +90,16 @@ export type WebIntrospection = (token: string, origin: string, turn?: boolean) =
|
|
|
83
90
|
/** The code of the answer to a turn the agent's limits refuse, as the ontology's own refusals. */
|
|
84
91
|
export declare const TURN_LIMITED_CODE = "rate_limited";
|
|
85
92
|
/**
|
|
86
|
-
* A turn the agent's limits
|
|
87
|
-
*
|
|
88
|
-
*
|
|
93
|
+
* A turn the agent's limits refuse: answered `429 rate_limited` with `Retry-After`, before the turn
|
|
94
|
+
* reaches the model, and with the limit's `scope`, such as `guestTurnsPerDay` or
|
|
95
|
+
* `guestWorkspaceUsdPerDay`, when the ontology names it. The answer carries no words: the app's
|
|
96
|
+
* chat reports it by its code and scope in the workspace's own.
|
|
89
97
|
*/
|
|
90
98
|
export declare class TurnLimitedError extends ForbiddenError {
|
|
91
99
|
readonly retryAfterSeconds: number;
|
|
100
|
+
readonly scope?: string | undefined;
|
|
92
101
|
readonly response: Response;
|
|
93
|
-
constructor(retryAfterSeconds: number);
|
|
102
|
+
constructor(retryAfterSeconds: number, scope?: string | undefined);
|
|
94
103
|
}
|
|
95
104
|
/**
|
|
96
105
|
* Whom an introspection answer names, when it is active: a member in their own chat, or a guest,
|
|
@@ -113,6 +122,11 @@ export declare function ontologyIntrospection(options?: {
|
|
|
113
122
|
* has no `memberId`, so nothing that needs a member takes them for one.
|
|
114
123
|
*/
|
|
115
124
|
export declare function guestPrincipal(guest: WebGuest): SessionAuthContext;
|
|
125
|
+
/**
|
|
126
|
+
* Whether a guest's web principal may confirm actions with the chat's buttons: only where the
|
|
127
|
+
* ontology's `guest.confirmations` allows it, as its answer for the guest's token said.
|
|
128
|
+
*/
|
|
129
|
+
export declare function guestConfirms(principal: SessionAuthContext | null | undefined): boolean;
|
|
116
130
|
/** The guest id a web principal of a guest carries; `undefined` for anyone else. */
|
|
117
131
|
export declare function guestIdOf(principal: SessionAuthContext | null | undefined): string | undefined;
|
|
118
132
|
/** The session principal of a member who wrote on the web, in their own chat. */
|
|
@@ -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 {
|
|
7
|
+
export { q as ACCESS_TOKEN_PREFIX, J as AGENT_GRANT_HEADER, Y as GUEST_CONFIRMATIONS_ATTRIBUTE, X as GUEST_ID_ATTRIBUTE, Z as GUEST_ROLE, Q as INTROSPECTION_PATH, $ as KIND_ATTRIBUTE, et as TURN_LIMITED_CODE, tt as TurnLimitedError, nt as WEB_AUTHENTICATOR, rt as WEB_GRANT_ATTRIBUTE, it as WEB_PROVIDER, at as guestConfirms, ot as guestIdOf, st as guestPrincipal, ct as ontologyIntrospection, lt as webAuth, ut as webGrantOf, dt as webMemberOf, ft as webPrincipal } from "../../../_chunks/principal-DUla0Xge.mjs";
|