@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.
Files changed (98) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +17 -4
  3. package/dist/_chunks/{build-metadata-DJ3WHCte.mjs → build-metadata-2TyBXJEt.mjs} +1 -1
  4. package/dist/_chunks/{principal-JoaOmdFL.mjs → principal-DUla0Xge.mjs} +53 -23
  5. package/dist/extension/config.d.ts +23 -1
  6. package/dist/extension/config.mjs +37 -3
  7. package/dist/extension/connections/ontology.mjs +1 -1
  8. package/dist/extension/hooks/authorization.mjs +1 -1
  9. package/dist/extension/hooks/guest-usage.d.ts +3 -0
  10. package/dist/extension/hooks/guest-usage.mjs +11 -0
  11. package/dist/extension/instructions/persona.mjs +1 -1
  12. package/dist/extension/instructions.md +8 -5
  13. package/dist/extension/lib/actor.mjs +1 -1
  14. package/dist/extension/lib/attachment-tools.mjs +1 -1
  15. package/dist/extension/lib/attachments-send.d.ts +84 -0
  16. package/dist/extension/lib/attachments-send.mjs +88 -0
  17. package/dist/extension/lib/attachments.d.ts +1 -2
  18. package/dist/extension/lib/attachments.mjs +1 -1
  19. package/dist/extension/lib/build-metadata.mjs +1 -1
  20. package/dist/extension/lib/chat-address.d.ts +11 -0
  21. package/dist/extension/lib/chat-address.mjs +1 -1
  22. package/dist/extension/lib/chat-archive.d.ts +35 -0
  23. package/dist/extension/lib/chat-archive.mjs +37 -1
  24. package/dist/extension/lib/chat-context.d.ts +1 -1
  25. package/dist/extension/lib/chat-context.mjs +4 -3
  26. package/dist/extension/lib/chat-recorder.mjs +3 -2
  27. package/dist/extension/lib/confirmations.d.ts +6 -1
  28. package/dist/extension/lib/confirmations.mjs +1 -1
  29. package/dist/extension/lib/email/attachments-send.d.ts +43 -0
  30. package/dist/extension/lib/email/attachments-send.mjs +130 -0
  31. package/dist/extension/lib/email/channel.d.ts +7 -1
  32. package/dist/extension/lib/email/channel.mjs +222 -53
  33. package/dist/extension/lib/email/gmail.d.ts +22 -6
  34. package/dist/extension/lib/email/gmail.mjs +101 -5
  35. package/dist/extension/lib/email/message.d.ts +19 -0
  36. package/dist/extension/lib/email/message.mjs +22 -1
  37. package/dist/extension/lib/guest-usage.d.ts +53 -0
  38. package/dist/extension/lib/guest-usage.mjs +52 -0
  39. package/dist/extension/lib/inbound-media/files.mjs +1 -1
  40. package/dist/extension/lib/inbound-media/index.mjs +1 -1
  41. package/dist/extension/lib/ontology-connection.mjs +1 -1
  42. package/dist/extension/lib/ontology-file-call.mjs +2 -1
  43. package/dist/extension/lib/ontology-tools.d.ts +2 -0
  44. package/dist/extension/lib/ontology-tools.mjs +1 -1
  45. package/dist/extension/lib/review/hold.mjs +1 -1
  46. package/dist/extension/lib/review/judge.mjs +2 -2
  47. package/dist/extension/lib/review/reply.mjs +1 -1
  48. package/dist/extension/lib/role-skill.mjs +1 -1
  49. package/dist/extension/lib/runtime-envelope.mjs +1 -1
  50. package/dist/extension/lib/sent-files.d.ts +29 -9
  51. package/dist/extension/lib/sent-files.mjs +36 -14
  52. package/dist/extension/lib/slack/adapter.mjs +1 -1
  53. package/dist/extension/lib/slack/attachments-send.d.ts +6 -14
  54. package/dist/extension/lib/slack/attachments-send.mjs +128 -170
  55. package/dist/extension/lib/stored-files.mjs +1 -1
  56. package/dist/extension/lib/telegram/adapter.mjs +2 -2
  57. package/dist/extension/lib/telegram/attachment-description.mjs +1 -1
  58. package/dist/extension/lib/telegram/attachments-send.mjs +9 -12
  59. package/dist/extension/lib/telegram/callbacks.mjs +1 -1
  60. package/dist/extension/lib/telegram/chat-archive.mjs +1 -1
  61. package/dist/extension/lib/telegram/confirmations.mjs +2 -2
  62. package/dist/extension/lib/telegram/customer-text.mjs +1 -1
  63. package/dist/extension/lib/telegram/files.mjs +1 -1
  64. package/dist/extension/lib/telegram/health.mjs +1 -1
  65. package/dist/extension/lib/telegram/held-approvals.mjs +1 -1
  66. package/dist/extension/lib/telegram/inbound-request.mjs +1 -1
  67. package/dist/extension/lib/telegram/inbound.mjs +1 -1
  68. package/dist/extension/lib/telegram/lifecycle.mjs +2 -2
  69. package/dist/extension/lib/telegram/principal.mjs +1 -1
  70. package/dist/extension/lib/telegram/session-recovery.mjs +1 -1
  71. package/dist/extension/lib/telegram/silent.mjs +1 -1
  72. package/dist/extension/lib/telegram/structured.mjs +1 -1
  73. package/dist/extension/lib/telegram/turn-errors.mjs +1 -1
  74. package/dist/extension/lib/telegram/workspace-action.mjs +1 -1
  75. package/dist/extension/lib/web/auth.d.ts +18 -4
  76. package/dist/extension/lib/web/auth.mjs +1 -1
  77. package/dist/extension/lib/web/channel.d.ts +10 -3
  78. package/dist/extension/lib/web/channel.mjs +10 -3
  79. package/dist/extension/lib/whatsapp/adapter.mjs +1 -1
  80. package/dist/extension/lib/whatsapp/attachments-send.d.ts +35 -0
  81. package/dist/extension/lib/whatsapp/attachments-send.mjs +117 -0
  82. package/dist/extension/lib/whatsapp/files.mjs +1 -1
  83. package/dist/extension/lib/workspace-source.mjs +1 -1
  84. package/dist/extension/model.mjs +1 -1
  85. package/dist/extension/tools/attachments_discard.mjs +1 -1
  86. package/dist/extension/tools/attachments_list.mjs +1 -1
  87. package/dist/extension/tools/attachments_promote.mjs +1 -1
  88. package/dist/extension/tools/attachments_read.mjs +1 -1
  89. package/dist/extension/tools/attachments_send.mjs +18 -7
  90. package/dist/extension/tools/attachments_stage.mjs +1 -1
  91. package/dist/extension/tools/attachments_table.mjs +1 -1
  92. package/dist/extension/tools/questions_ask.mjs +1 -1
  93. package/dist/extension/tools/unanswered.d.ts +2 -0
  94. package/dist/extension/tools/unanswered.mjs +39 -0
  95. package/dist/extension/tools/workspace_source.mjs +1 -1
  96. package/dist/tools/index.d.ts +1 -0
  97. package/dist/tools/index.mjs +2 -1
  98. 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 { attachmentOwner } from "../attachment-tools.mjs";
8
- import { Ct as failureText, _ as AttachmentError, mt as chatAddressOf } from "../../../_chunks/principal-JoaOmdFL.mjs";
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 { appOrigin, channelsEnabled, proxyEnvironment } from "../environment.mjs";
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
- const environment = options.environment ?? process.env;
40
- const principal = options.principal;
41
- const locale = confirmationLocale(principal);
42
- const secrets = new Set();
43
- const unavailable = (error, diagnostic) => {
44
- const reference = reportSlackError("attachment_send_refused", {
45
- error,
46
- diagnostic
47
- }, secrets);
48
- return {
49
- error,
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: fetchImpl,
132
- secrets,
133
- tooLarge: () => refused("too_large", PROXY_LIMIT),
134
- limit: ({ size }) => {
135
- if (size > 2097152) throw refused("too_large", PROXY_LIMIT);
136
- if (size === 0) throw refused("unsupported", "Slack cannot share an empty file.");
137
- return MAXIMUM_PROXY_BODY_BYTES;
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
- } catch (error) {
141
- failed(error, "stored_attachment_fetch_failed");
142
- continue;
143
- }
144
- results[index] = {
145
- id: reference.id,
146
- filename: file.filename
147
- };
148
- try {
149
- const ticket = await call("files.getUploadURLExternal", {
150
- headers: { "content-type": "application/x-www-form-urlencoded" },
151
- body: new URLSearchParams({
152
- filename: file.filename,
153
- length: String(file.bytes.byteLength)
154
- }).toString()
155
- });
156
- if (typeof ticket.upload_url !== "string" || typeof ticket.file_id !== "string") throw refused("invalid_response", "Slack answered no upload address.");
157
- secrets.add(ticket.upload_url);
158
- const upload = await slack(ticket.upload_url, {
159
- method: "POST",
160
- headers: { "content-type": file.contentType },
161
- body: Buffer.from(file.bytes)
162
- });
163
- await upload.body?.cancel();
164
- if (!upload.ok) throw new AttachmentError({
165
- code: "send_failed",
166
- message: "Slack refused the file's bytes.",
167
- status: upload.status
168
- });
169
- uploaded.push({
170
- index,
171
- slackId: ticket.file_id
172
- });
173
- } catch (error) {
174
- failed(error, "attachment_upload_failed");
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 { K as member, N as ontologyTools, i as memberIdOf, k as OntologyFileUnavailable } from "../../_chunks/principal-JoaOmdFL.mjs";
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-DJ3WHCte.mjs";
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 { Ct as failureText, Dt as withDeliveryLocale, Et as safeTelegramFetch, S as agentAttachments, Tt as reportTelegramError, c as currentInboundRequest, l as runInboundRequest, n as chatLanguage, o as telegramPrincipal, s as InboundRequest, u as withReplacedText, vt as currentLocale, w as fetchStoredAttachment } from "../../../_chunks/principal-JoaOmdFL.mjs";
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 { Tt as reportTelegramError } from "../../../_chunks/principal-JoaOmdFL.mjs";
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 { Ct as failureText, Tt as reportTelegramError, _ as AttachmentError, wt as formattingRefused, xt as customerMessage } from "../../../_chunks/principal-JoaOmdFL.mjs";
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: failed?.filename ?? "",
151
- error: error instanceof AttachmentError ? error.code : "unavailable",
152
- detail: failureText(errorId, "attachment", locale),
153
- reference: errorId,
154
- ...error instanceof AttachmentError && error.status !== void 0 ? {
155
- status: error.status,
156
- retryable: transientFileStatus(error.status)
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 { Mt as telegramRuntimeSource, Tt as reportTelegramError, c as currentInboundRequest, i as memberIdOf, jt as runtimeEnvelope, o as telegramPrincipal } from "../../../_chunks/principal-JoaOmdFL.mjs";
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 { Tt as reportTelegramError, c as currentInboundRequest, yt as currentThreadId } from "../../../_chunks/principal-JoaOmdFL.mjs";
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 { L as confirmations, Tt as reportTelegramError, c as currentInboundRequest, i as memberIdOf, o as telegramPrincipal } from "../../../_chunks/principal-JoaOmdFL.mjs";
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 { Ct as failureText, Dt as withDeliveryLocale, Et as safeTelegramFetch, St as customerText, Tt as reportTelegramError, _t as TelegramDeliveryError, bt as customerCopy, vt as currentLocale, wt as formattingRefused, xt as customerMessage, yt as currentThreadId } from "../../../_chunks/principal-JoaOmdFL.mjs";
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 { Tt as reportTelegramError, p as storeFiles } from "../../../_chunks/principal-JoaOmdFL.mjs";
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-DJ3WHCte.mjs";
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 { F as CONFIRMATION_TTL_MS } from "../../../_chunks/principal-JoaOmdFL.mjs";
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-JoaOmdFL.mjs";
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 { C as attachmentUrl, Mt as telegramRuntimeSource, Tt as reportTelegramError, f as attachmentsContext, jt as runtimeEnvelope, n as chatLanguage, o as telegramPrincipal } from "../../../_chunks/principal-JoaOmdFL.mjs";
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 { At as principalRuntimeSource, K as member, Mt as telegramRuntimeSource, N as ontologyTools, O as OntologyActionNotPermitted, c as currentInboundRequest, j as actionToolName, jt as runtimeEnvelope, z as needsConfirmation } from "../../../_chunks/principal-JoaOmdFL.mjs";
8
- import { t as agentBuild } from "../../../_chunks/build-metadata-DJ3WHCte.mjs";
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-JoaOmdFL.mjs";
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 { Tt as reportTelegramError } from "../../../_chunks/principal-JoaOmdFL.mjs";
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 { Tt as reportTelegramError, _t as TelegramDeliveryError, vt as currentLocale, xt as customerMessage } from "../../../_chunks/principal-JoaOmdFL.mjs";
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 { Mt as telegramRuntimeSource, jt as runtimeEnvelope } from "../../../_chunks/principal-JoaOmdFL.mjs";
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, Tt as reportTelegramError, bt as customerCopy, i as memberIdOf, vt as currentLocale, yt as currentThreadId } from "../../../_chunks/principal-JoaOmdFL.mjs";
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 { K as member, N as ontologyTools, j as actionToolName, z as needsConfirmation } from "../../../_chunks/principal-JoaOmdFL.mjs";
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 for people who signed up refuse: answered `429 rate_limited` with
87
- * `Retry-After`, before the turn reaches the model. The answer carries no words: the app's chat
88
- * reports it by its code in the workspace's own.
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 { Y as ACCESS_TOKEN_PREFIX, X as AGENT_GRANT_HEADER, Z as GUEST_ID_ATTRIBUTE, Q as GUEST_ROLE, $ as INTROSPECTION_PATH, et as KIND_ATTRIBUTE, tt as TURN_LIMITED_CODE, nt as TurnLimitedError, rt as WEB_AUTHENTICATOR, it as WEB_GRANT_ATTRIBUTE, at as WEB_PROVIDER, ot as guestIdOf, st as guestPrincipal, ct as ontologyIntrospection, lt as webAuth, ut as webGrantOf, dt as webMemberOf, ft as webPrincipal } from "../../../_chunks/principal-JoaOmdFL.mjs";
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";