@segmentstream/agent 0.102.1 → 0.103.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 +6 -0
- package/README.md +8 -20
- package/dist/_chunks/{build-metadata-Bnac65E-.mjs → build-metadata-BkLo_nGS.mjs} +1 -1
- package/dist/_chunks/{chat-archive-DmCXcI8G.mjs → chat-archive-CMyCVvpe.mjs} +1 -1
- package/dist/_chunks/{principal-DL9NdRRP.mjs → principal-DIQHp6AG.mjs} +32 -11
- package/dist/_chunks/{silent-xJcJ8SNJ.mjs → silent-CWcAjHwt.mjs} +1 -1
- package/dist/extension/config.d.ts +0 -13
- package/dist/extension/config.mjs +0 -56
- package/dist/extension/connections/ontology.mjs +1 -1
- package/dist/extension/extension.d.ts +0 -2
- package/dist/extension/hooks/authorization.mjs +1 -1
- package/dist/extension/instructions/persona.mjs +1 -1
- package/dist/extension/lib/actor.mjs +1 -1
- package/dist/extension/lib/attachment-tools.mjs +1 -1
- package/dist/extension/lib/attachments-dispatch.mjs +2 -2
- package/dist/extension/lib/attachments-send.mjs +1 -1
- package/dist/extension/lib/attachments.mjs +1 -1
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/channel-guest.d.ts +15 -0
- package/dist/extension/lib/channel-guest.mjs +54 -0
- package/dist/extension/lib/chat-address.mjs +1 -1
- package/dist/extension/lib/chat-context.mjs +1 -1
- package/dist/extension/lib/chat-persona.mjs +1 -1
- package/dist/extension/lib/chat-recorder.mjs +2 -2
- package/dist/extension/lib/confirmations.mjs +1 -1
- package/dist/extension/lib/email/attachments-send.mjs +1 -1
- package/dist/extension/lib/email/channel.mjs +2 -2
- package/dist/extension/lib/guest-usage.mjs +1 -1
- package/dist/extension/lib/identities.d.ts +22 -0
- package/dist/extension/lib/identities.mjs +25 -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 +1 -1
- package/dist/extension/lib/ontology-recall.mjs +1 -1
- package/dist/extension/lib/ontology-tools.mjs +1 -1
- package/dist/extension/lib/review/files.mjs +1 -1
- package/dist/extension/lib/review/hold.mjs +1 -1
- package/dist/extension/lib/review/reply.mjs +2 -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 -1
- package/dist/extension/lib/slack/adapter.d.ts +2 -0
- package/dist/extension/lib/slack/adapter.mjs +86 -18
- package/dist/extension/lib/slack/attachments-send.mjs +1 -1
- package/dist/extension/lib/slack/callbacks.mjs +1 -1
- package/dist/extension/lib/slack/confirmation-card.mjs +1 -1
- package/dist/extension/lib/stored-files.mjs +1 -1
- package/dist/extension/lib/telegram/adapter.mjs +19 -12
- package/dist/extension/lib/telegram/attachment-description.mjs +1 -1
- package/dist/extension/lib/telegram/attachments-send.mjs +1 -1
- 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.d.ts +2 -0
- package/dist/extension/lib/telegram/confirmations.mjs +49 -13
- 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.d.ts +2 -0
- package/dist/extension/lib/telegram/inbound-request.mjs +1 -1
- package/dist/extension/lib/telegram/inbound.mjs +30 -15
- package/dist/extension/lib/telegram/lifecycle.mjs +2 -2
- package/dist/extension/lib/telegram/principal.mjs +1 -1
- package/dist/extension/lib/telegram/routing-context.mjs +1 -1
- package/dist/extension/lib/telegram/session-recovery.mjs +1 -1
- package/dist/extension/lib/telegram/sessions.d.ts +2 -0
- package/dist/extension/lib/telegram/sessions.mjs +9 -1
- package/dist/extension/lib/telegram/silent.mjs +1 -1
- package/dist/extension/lib/telegram/store-capture.mjs +1 -1
- package/dist/extension/lib/telegram/structured.mjs +1 -1
- package/dist/extension/lib/telegram/turn-errors.mjs +2 -2
- package/dist/extension/lib/triage.mjs +1 -1
- package/dist/extension/lib/web/auth.d.ts +1 -0
- package/dist/extension/lib/web/auth.mjs +1 -1
- package/dist/extension/lib/web/channel.mjs +1 -1
- package/dist/extension/lib/whatsapp/adapter.mjs +25 -2
- package/dist/extension/lib/whatsapp/attachments-send.mjs +1 -1
- package/dist/extension/lib/whatsapp/callbacks.mjs +1 -1
- package/dist/extension/lib/whatsapp/files.mjs +1 -1
- package/dist/extension/lib/workspace-action.mjs +1 -1
- package/dist/extension/lib/workspace-channel/attachments-send.mjs +1 -1
- package/dist/extension/lib/workspace-channel/channel.mjs +2 -2
- 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 +2 -2
- package/dist/extension/tools/attachments_stage.mjs +1 -1
- package/dist/extension/tools/attachments_table.mjs +1 -1
- package/dist/extension/tools/handoff.mjs +1 -1
- package/dist/extension/tools/questions_ask.mjs +1 -1
- package/dist/extension/tools/workspace_source.mjs +1 -1
- package/package.json +2 -2
- package/dist/extension/lib/public-group-knowledge.d.ts +0 -16
- package/dist/extension/lib/public-group-knowledge.mjs +0 -44
- package/dist/extension/lib/public-group.d.ts +0 -28
- package/dist/extension/lib/public-group.mjs +0 -116
|
@@ -68,6 +68,7 @@ function resolution(value) {
|
|
|
68
68
|
status: value.status,
|
|
69
69
|
member: pairedMember(value),
|
|
70
70
|
provisioned: value.provisioned,
|
|
71
|
+
...value.separate_session === true && { separateSession: true },
|
|
71
72
|
...typeof value.counted === "boolean" ? { counted: value.counted } : {},
|
|
72
73
|
noticeDue: value.notice_due,
|
|
73
74
|
onNewUserPending: value.on_new_user_pending,
|
|
@@ -199,6 +200,30 @@ function agentIdentities(input) {
|
|
|
199
200
|
}
|
|
200
201
|
return {
|
|
201
202
|
lookup,
|
|
203
|
+
async reportInvite(input) {
|
|
204
|
+
const response = await call("/chats/invite", { body: input });
|
|
205
|
+
if (!response.ok && response.status !== 404) throw await safeRefusal(response, "chat invitation");
|
|
206
|
+
},
|
|
207
|
+
async admitGuest(input) {
|
|
208
|
+
const response = await call("/chats/admit-guest", { body: input });
|
|
209
|
+
if (response.status === 404) return { status: "closed" };
|
|
210
|
+
if (!response.ok) throw await safeRefusal(response, "guest admission");
|
|
211
|
+
const result = await response.json();
|
|
212
|
+
if (isRecord(result)) {
|
|
213
|
+
if (result.status === "closed" || result.status === "limited") return { status: result.status };
|
|
214
|
+
if (result.status === "guest" && typeof result.guestId === "string" && /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i.test(result.guestId) && Array.isArray(result.roles) && result.roles.every((role) => typeof role === "string") && Array.isArray(result.agentTools) && result.agentTools.every((tool) => typeof tool === "string")) return {
|
|
215
|
+
status: "guest",
|
|
216
|
+
guestId: result.guestId,
|
|
217
|
+
...result.confirmations === true && { confirmations: true },
|
|
218
|
+
roles: result.roles,
|
|
219
|
+
agentTools: result.agentTools.filter((tool) => tool !== "sandbox" && tool !== "browser")
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
throw new AgentIdentityError({
|
|
223
|
+
code: "invalid_response",
|
|
224
|
+
message: "The ontology returned invalid guest admission."
|
|
225
|
+
});
|
|
226
|
+
},
|
|
202
227
|
async resolve(account) {
|
|
203
228
|
const { externalId, noticeVersion, noticeSha256, addressVerified, ...details } = account;
|
|
204
229
|
const response = await call("/identities/resolve", { body: {
|
|
@@ -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 { f as attachmentsContext, p as storeFiles, m as turnContent } from "../../../_chunks/principal-
|
|
7
|
+
export { f as attachmentsContext, p as storeFiles, m as turnContent } from "../../../_chunks/principal-DIQHp6AG.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 { f as attachmentsContext, d as prepareInboundMedia, p as storeFiles, m as turnContent } from "../../../_chunks/principal-
|
|
7
|
+
export { f as attachmentsContext, d as prepareInboundMedia, p as storeFiles, m as turnContent } from "../../../_chunks/principal-DIQHp6AG.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 { R as ACT_AS_HEADER, w as actAsHeaders, T as ontologyConnection } from "../../_chunks/principal-
|
|
7
|
+
export { R as ACT_AS_HEADER, w as actAsHeaders, T as ontologyConnection } from "../../_chunks/principal-DIQHp6AG.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 { F as confirmations, H as actorOf, I as inputHash,
|
|
7
|
+
import { F as confirmations, H as actorOf, I as inputHash, P as actionApproval, V as actorKey, j as ontologyTools, kt as runtimeEnvelope } from "../../_chunks/principal-DIQHp6AG.mjs";
|
|
8
8
|
import { isChatPost } from "./chat-post-confirmation.mjs";
|
|
9
9
|
import { sandboxFile } from "./sandbox-session.mjs";
|
|
10
10
|
import { saveOntologyResult } from "./ontology-result-file.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 { H as actorOf, a as rolesOf, j as ontologyTools, k as actionToolName } from "../../_chunks/principal-
|
|
7
|
+
import { H as actorOf, a as rolesOf, j as ontologyTools, k as actionToolName } from "../../_chunks/principal-DIQHp6AG.mjs";
|
|
8
8
|
import { object } from "./confirmation-description.mjs";
|
|
9
9
|
import { redactDiagnostic } from "./diagnostics.mjs";
|
|
10
10
|
import { defineMemoryProvider } from "eve/memory";
|
|
@@ -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 { E as OntologyActionNotPermitted, D as OntologyFileUnavailable, O as OntologyToolRejected, k as actionToolName, A as ontologyToolLabels, j as ontologyTools, M as promotionTarget } from "../../_chunks/principal-
|
|
7
|
+
export { E as OntologyActionNotPermitted, D as OntologyFileUnavailable, O as OntologyToolRejected, k as actionToolName, A as ontologyToolLabels, j as ontologyTools, M as promotionTarget } from "../../_chunks/principal-DIQHp6AG.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 { c as CAPTION_LIMIT, l as DRAFT_FILES_LIMIT, u as ReplyFilesRefused, d as attachToReply, f as checkReplyFiles, p as fileGroups, m as filesAfterReply, h as partFiles, g as turnFiles, _ as withCaptions } from "../../../_chunks/silent-
|
|
7
|
+
export { c as CAPTION_LIMIT, l as DRAFT_FILES_LIMIT, u as ReplyFilesRefused, d as attachToReply, f as checkReplyFiles, p as fileGroups, m as filesAfterReply, h as partFiles, g as turnFiles, _ as withCaptions } from "../../../_chunks/silent-CWcAjHwt.mjs";
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { reviewFor } from "../../review.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { It as chatAddressOf, Vt as participantsOf, a as rolesOf, i as memberIdOf } from "../../../_chunks/principal-DIQHp6AG.mjs";
|
|
9
9
|
function reviewOf(settings, principal) {
|
|
10
10
|
return reviewFor(settings, rolesOf(principal));
|
|
11
11
|
}
|
|
@@ -5,12 +5,12 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { reviewPolicy } from "../../review.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { It as chatAddressOf, Lt as chatChannel, i as memberIdOf } from "../../../_chunks/principal-DIQHp6AG.mjs";
|
|
9
9
|
import { a as chatEvent, r as chatArchive } from "../../../_chunks/chat-archive-_IBU0CXG.mjs";
|
|
10
10
|
import { stampedChat } from "../chat-recorder.mjs";
|
|
11
11
|
import { appOrigin } from "../environment.mjs";
|
|
12
12
|
import { agentReplies, agentReviews } from "./client.mjs";
|
|
13
|
-
import { _ as withCaptions, h as partFiles, m as filesAfterReply, n as completionKind, p as fileGroups } from "../../../_chunks/silent-
|
|
13
|
+
import { _ as withCaptions, h as partFiles, m as filesAfterReply, n as completionKind, p as fileGroups } from "../../../_chunks/silent-CWcAjHwt.mjs";
|
|
14
14
|
import { heldReply, proposedReply, repliesReviewed, reviewOf, reviewOutcome } from "./hold.mjs";
|
|
15
15
|
import { judgeReply, readChat } from "./judge.mjs";
|
|
16
16
|
const VERDICTS_REMEMBERED = 512;
|
|
@@ -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 { a as rolesOf } from "../../_chunks/principal-
|
|
7
|
+
import { a as rolesOf } from "../../_chunks/principal-DIQHp6AG.mjs";
|
|
8
8
|
import { defineDynamic, defineSkill } from "eve/skills";
|
|
9
9
|
function forRoles(roles, skill) {
|
|
10
10
|
if (!Array.isArray(roles) || roles.length === 0 || !roles.every((role) => typeof role === "string" && role.trim() !== "")) throw new TypeError("forRoles() needs at least one role name; a skill for everyone is an ordinary skill file.");
|
|
@@ -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 { Tt as RUNTIME_SOURCE_PROTOCOL, Et as compatibleRuntimeEnvelope, Dt as principalRuntimeSource, Ot as readableRuntimeEnvelope, kt as runtimeEnvelope, At as telegramRuntimeSource } from "../../_chunks/principal-DIQHp6AG.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 { Ft as SESSION_HEADER, Mt as CHAT_HEADER, R as ACT_AS_HEADER, _ as AttachmentError, v as EARLIER_CHAT_HEADER } from "../../_chunks/principal-DIQHp6AG.mjs";
|
|
8
8
|
import { fetchFileGrant, transientFileStatus } from "./file-grant.mjs";
|
|
9
9
|
import { ontologyDeploymentHeaders } from "./environment.mjs";
|
|
10
10
|
var StoredFileError = class extends AttachmentError {
|
|
@@ -162,6 +162,8 @@ export declare function followsThreadReply(input: {
|
|
|
162
162
|
readonly message: Pick<SlackMessage, "author" | "ts" | "threadTs">;
|
|
163
163
|
readonly mode: GroupPolicy["mode"] | undefined;
|
|
164
164
|
}): Promise<boolean>;
|
|
165
|
+
/** Eve binds a source before its admission hook runs. Select its sender at dispatch time. */
|
|
166
|
+
export declare function slackSessionSource<State>(current: () => ChannelSource<State>): ChannelSource<State>;
|
|
165
167
|
/**
|
|
166
168
|
* A session source whose `send` delivers the message as the inbound media pipeline left its files:
|
|
167
169
|
* a voice clip's transcript in place of the clip, and an image the chat model does not read
|
|
@@ -4,13 +4,13 @@ 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 { Ht as withChatAddress, b as agentAttachments, d as prepareInboundMedia, m as turnContent, ot as guestConfirms } from "../../../_chunks/principal-DIQHp6AG.mjs";
|
|
8
|
+
import { admitChannelGuest, senderSession } from "../channel-guest.mjs";
|
|
8
9
|
import { admitMessage, localizedText } from "../admission.mjs";
|
|
9
10
|
import { agentToolsAttribute } from "../agent-tools.mjs";
|
|
10
11
|
import { agentChats, channelChats } from "../chats.mjs";
|
|
11
12
|
import { withButtonDecision } from "../confirmation-buttons.mjs";
|
|
12
13
|
import { personaPrincipal } from "../chat-persona.mjs";
|
|
13
|
-
import { Vt as withChatAddress, b as agentAttachments, d as prepareInboundMedia, m as turnContent } from "../../../_chunks/principal-DL9NdRRP.mjs";
|
|
14
14
|
import { channelAttributes, currentChannel, withNamedRoutes, withSessionChannels } from "../channel-scope.mjs";
|
|
15
15
|
import { redactDiagnostic } from "../diagnostics.mjs";
|
|
16
16
|
import { MAXIMUM_DOWNLOAD_BYTES, connectionProxy } from "../connection-proxy.mjs";
|
|
@@ -233,7 +233,13 @@ function segmentstreamSlack(options) {
|
|
|
233
233
|
const registry = options.chats ?? channelChats("slack", (provider) => agentChats({
|
|
234
234
|
provider,
|
|
235
235
|
identities: pairing,
|
|
236
|
-
onInvite: (chat, inviter) =>
|
|
236
|
+
onInvite: async (chat, inviter) => {
|
|
237
|
+
await pairing().reportInvite?.({
|
|
238
|
+
provider: "slack",
|
|
239
|
+
key: `${provider}:${chat}`,
|
|
240
|
+
inviter
|
|
241
|
+
});
|
|
242
|
+
}
|
|
237
243
|
}));
|
|
238
244
|
const chats = () => registry;
|
|
239
245
|
let records = options.archive;
|
|
@@ -259,6 +265,33 @@ function segmentstreamSlack(options) {
|
|
|
259
265
|
return lookup.status === "paired" ? slackPrincipal(lookup.member, user) : null;
|
|
260
266
|
}
|
|
261
267
|
let store = options.attachments;
|
|
268
|
+
async function groupPrincipal(user, chatId, threadId) {
|
|
269
|
+
const identities = pairing();
|
|
270
|
+
const resolved = await identities.resolve({
|
|
271
|
+
provider: "slack",
|
|
272
|
+
externalId: user,
|
|
273
|
+
chat: "group",
|
|
274
|
+
turn: false
|
|
275
|
+
});
|
|
276
|
+
const address = {
|
|
277
|
+
provider: "slack",
|
|
278
|
+
kind: "group",
|
|
279
|
+
channel: currentChannel("slack"),
|
|
280
|
+
chatId,
|
|
281
|
+
threadId,
|
|
282
|
+
peer: user
|
|
283
|
+
};
|
|
284
|
+
const work = requestWork.getStore();
|
|
285
|
+
if (resolved.status === "existing" || resolved.status === "created") {
|
|
286
|
+
if (resolved.separateSession && work) work.sessionOwner = senderSession(resolved.member.id, resolved.member.roles);
|
|
287
|
+
const { channel, ...base } = address;
|
|
288
|
+
return withChatAddress(slackPrincipal(resolved.member, user), channel === "slack" ? base : address);
|
|
289
|
+
}
|
|
290
|
+
if (resolved.status !== "pairing_required") return null;
|
|
291
|
+
const guest = await admitChannelGuest(identities, options.admission(), address, async () => {}, { purpose: "identify" });
|
|
292
|
+
if (guest && work) work.sessionOwner = slackGuestOwner(guest);
|
|
293
|
+
return guest ?? null;
|
|
294
|
+
}
|
|
262
295
|
const capabilities = options.modelCapabilities ?? gatewayMediaCapabilities(options.fetch, reportWithReference);
|
|
263
296
|
const files = {
|
|
264
297
|
attachments: () => store ??= agentAttachments({
|
|
@@ -365,8 +398,17 @@ function segmentstreamSlack(options) {
|
|
|
365
398
|
onAppMention: admit(false, true),
|
|
366
399
|
onDirectMessage: admit(true),
|
|
367
400
|
onMessage: async (ctx, message) => {
|
|
401
|
+
const subscribed = async () => {
|
|
402
|
+
if (await ctx.isSubscribed()) return true;
|
|
403
|
+
const user = message.author?.userId;
|
|
404
|
+
if (!user || !ctx.slack.channelId || !await groupPrincipal(user, ctx.slack.channelId, ctx.slack.threadTs ?? "")) return false;
|
|
405
|
+
return !!requestWork.getStore()?.sessionOwner && await ctx.isSubscribed();
|
|
406
|
+
};
|
|
368
407
|
if (!await followsThreadReply({
|
|
369
|
-
ctx
|
|
408
|
+
ctx: {
|
|
409
|
+
edit: ctx.edit,
|
|
410
|
+
isSubscribed: subscribed
|
|
411
|
+
},
|
|
370
412
|
message,
|
|
371
413
|
mode: options.groups?.().mode
|
|
372
414
|
})) return null;
|
|
@@ -378,8 +420,9 @@ function segmentstreamSlack(options) {
|
|
|
378
420
|
};
|
|
379
421
|
},
|
|
380
422
|
onAnswers: async (ctx, submission) => {
|
|
381
|
-
const
|
|
382
|
-
|
|
423
|
+
const { channelId, threadTs } = ctx.slack;
|
|
424
|
+
const auth = channelId && !channelId.startsWith("D") ? await groupPrincipal(submission.user.id, channelId, threadTs ?? "") : await pairedPrincipal(submission.user.id);
|
|
425
|
+
if (auth === null || auth.authenticator === "segmentstream-channel-guest" && !guestConfirms(auth)) return null;
|
|
383
426
|
if (submission.type !== "block_actions") return { auth };
|
|
384
427
|
const decision = withButtonDecision(auth, submission.answers);
|
|
385
428
|
const calls = requestWork.getStore()?.confirmationCalls ?? [];
|
|
@@ -434,14 +477,31 @@ function gatedRoute(route, settings, environment, observe, delivered) {
|
|
|
434
477
|
if (!channelsEnabled(environment) || settings() === null || webhookSecret(environment) === void 0) return new Response(null, { status: 404 });
|
|
435
478
|
const waitUntil = (task) => args.waitUntil(task);
|
|
436
479
|
const work = { waitUntil };
|
|
480
|
+
const sessionAddress = (address) => work.sessionOwner && !address.endsWith(`/sender/${work.sessionOwner}`) ? `${address}/sender/${work.sessionOwner}` : address;
|
|
437
481
|
await observe(request, work, waitUntil);
|
|
438
482
|
return requestWork.run(work, () => route.handler(request, {
|
|
439
483
|
...args,
|
|
440
|
-
|
|
484
|
+
resolveSession: (address) => args.resolveSession(sessionAddress(address)),
|
|
485
|
+
from: (address) => withTurnMedia(slackSessionSource(() => args.from(sessionAddress(address))), () => work.turn, (delivery) => delivered(work, delivery))
|
|
441
486
|
}));
|
|
442
487
|
}
|
|
443
488
|
};
|
|
444
489
|
}
|
|
490
|
+
function slackSessionSource(current) {
|
|
491
|
+
return {
|
|
492
|
+
create: (options) => current().create(options),
|
|
493
|
+
send: (message, options) => current().send(message, options),
|
|
494
|
+
respond: (answers, options) => current().respond(answers, options),
|
|
495
|
+
cancel: (options) => current().cancel(options),
|
|
496
|
+
compact: (options) => current().compact(options),
|
|
497
|
+
clear: (options) => current().clear(options),
|
|
498
|
+
end: (options) => current().end(options)
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
function slackGuestOwner(auth) {
|
|
502
|
+
const roles = auth.attributes.roles;
|
|
503
|
+
return senderSession(auth.principalId, Array.isArray(roles) ? roles : []);
|
|
504
|
+
}
|
|
445
505
|
function withTurnMedia(source, turn, delivered) {
|
|
446
506
|
return {
|
|
447
507
|
...source,
|
|
@@ -488,21 +548,29 @@ async function receive(input) {
|
|
|
488
548
|
} } : {},
|
|
489
549
|
inboxFailed: (error) => report("inbox_report_failed", error)
|
|
490
550
|
});
|
|
491
|
-
if (!input.direct &&
|
|
492
|
-
|
|
493
|
-
|
|
551
|
+
if (!input.direct && resolution.status === "pairing_required" && turn && !ctx.edit) {
|
|
552
|
+
const auth = await admitChannelGuest(identities, admission, {
|
|
553
|
+
provider: "slack",
|
|
494
554
|
channel: currentChannel("slack"),
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
555
|
+
chatId: ctx.slack.channelId,
|
|
556
|
+
threadId: ctx.slack.threadTs,
|
|
557
|
+
kind: "group",
|
|
558
|
+
peer: user
|
|
559
|
+
}, notify, { message: message.ts });
|
|
560
|
+
if (auth !== void 0) {
|
|
561
|
+
if (auth === null) return null;
|
|
562
|
+
const work = requestWork.getStore();
|
|
563
|
+
if (work) work.sessionOwner = slackGuestOwner(auth);
|
|
564
|
+
return { auth };
|
|
565
|
+
}
|
|
502
566
|
}
|
|
503
567
|
switch (resolution.status) {
|
|
504
568
|
case "existing":
|
|
505
569
|
case "created":
|
|
570
|
+
if (resolution.separateSession && !input.direct) {
|
|
571
|
+
const work = requestWork.getStore();
|
|
572
|
+
if (work) work.sessionOwner = senderSession(resolution.member.id, resolution.member.roles);
|
|
573
|
+
}
|
|
506
574
|
if (resolution.handled === true) {
|
|
507
575
|
if (turn && ctx.edit === void 0) await recordHandledMessage(input.archive?.() ?? chatArchive({ environment: input.environment }), {
|
|
508
576
|
chat: {
|
|
@@ -689,4 +757,4 @@ function reportWithReference(operation, error, metadata = {}) {
|
|
|
689
757
|
function digest(value) {
|
|
690
758
|
return createHash("sha256").update(value, "utf8").digest();
|
|
691
759
|
}
|
|
692
|
-
export { SLACK_AUTHENTICATOR, SlackProxyRouteError, followsThreadReply, proxiedSlackFetch, receive, relayedRequestVerifier, reportMembership, segmentstreamSlack, slackChannelTitle, slackPrincipal, withTurnMedia };
|
|
760
|
+
export { SLACK_AUTHENTICATOR, SlackProxyRouteError, followsThreadReply, proxiedSlackFetch, receive, relayedRequestVerifier, reportMembership, segmentstreamSlack, slackChannelTitle, slackPrincipal, slackSessionSource, withTurnMedia };
|
|
@@ -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 { _ as AttachmentError } from "../../../_chunks/principal-
|
|
7
|
+
import { _ as AttachmentError } from "../../../_chunks/principal-DIQHp6AG.mjs";
|
|
8
8
|
import { sendStoredAttachments } from "../attachments-send.mjs";
|
|
9
9
|
import { connectionProxy } from "../connection-proxy.mjs";
|
|
10
10
|
import { redactDiagnostic } from "../diagnostics.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 { Ht as withChatAddress, kt as runtimeEnvelope, zt as chatRuntimeSource } from "../../../_chunks/principal-DIQHp6AG.mjs";
|
|
8
8
|
import { currentChannel } from "../channel-scope.mjs";
|
|
9
9
|
import { pressWorkspaceButton, queueWorkspaceButtonTurn, workspaceAction, workspaceButtonToken } from "../workspace-action.mjs";
|
|
10
10
|
import { pairingNotice } from "./pairing.mjs";
|
|
@@ -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 { F as confirmations } from "../../../_chunks/principal-
|
|
8
|
+
import { F as confirmations } from "../../../_chunks/principal-DIQHp6AG.mjs";
|
|
9
9
|
import { chatPostReceipt } from "../telegram/chat-post-card.mjs";
|
|
10
10
|
import { renderConfirmation } from "../telegram/confirmation-text.mjs";
|
|
11
11
|
import { telegramText, withTelegramTexts } from "../telegram/texts.mjs";
|
|
@@ -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 { D as OntologyFileUnavailable, W as member, i as memberIdOf, j as ontologyTools } from "../../_chunks/principal-
|
|
8
|
+
import { D as OntologyFileUnavailable, W as member, i as memberIdOf, j as ontologyTools } from "../../_chunks/principal-DIQHp6AG.mjs";
|
|
9
9
|
import { redactDiagnostic } from "./diagnostics.mjs";
|
|
10
10
|
import { createHash } from "node:crypto";
|
|
11
11
|
async function readStoredFile(input, principal, options = {}) {
|
|
@@ -4,7 +4,6 @@ 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 { publicGroupInvite } from "../public-group.mjs";
|
|
8
7
|
import { logConfirmationPress } from "./confirmation-press.mjs";
|
|
9
8
|
import { object } from "../confirmation-description.mjs";
|
|
10
9
|
import { archivedRoutingMessages } from "../group-routing/routing-context.mjs";
|
|
@@ -13,21 +12,21 @@ import { dispatchStructuredMessage, structuredMessage } from "./structured.mjs";
|
|
|
13
12
|
import { handleWorkspaceCallback } from "./callbacks.mjs";
|
|
14
13
|
import { workspaceTriage } from "../triage.mjs";
|
|
15
14
|
import { telegramText, withTelegramTexts } from "./texts.mjs";
|
|
16
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
15
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-BkLo_nGS.mjs";
|
|
17
16
|
import { attachmentLifecycle } from "./lifecycle.mjs";
|
|
18
17
|
import { manifestOf } from "../../config.mjs";
|
|
19
18
|
import { gatewayAttachmentDescriber } from "./attachment-description.mjs";
|
|
20
19
|
import { chooseModel } from "../../model.mjs";
|
|
21
|
-
import { Ct as
|
|
20
|
+
import { Ct as safeTelegramFetch, S as fetchStoredAttachment, St as reportTelegramError, b as agentAttachments, bt as failureText, c as currentInboundRequest, ht as currentLocale, l as runInboundRequest, n as chatLanguage, o as telegramPrincipal, s as InboundRequest, u as withReplacedText, wt as withDeliveryLocale } from "../../../_chunks/principal-DIQHp6AG.mjs";
|
|
22
21
|
import { MAXIMUM_DOWNLOAD_BYTES, connectionProxy } from "../connection-proxy.mjs";
|
|
23
22
|
import { appOrigin, channelsEnabled, proxyEnvironment, runtimeIdentityEnvironment, webhookSecret } from "../environment.mjs";
|
|
24
23
|
import { agentIdentities } from "../identities.mjs";
|
|
25
24
|
import { h as topicContext, r as chatArchive } from "../../../_chunks/chat-archive-_IBU0CXG.mjs";
|
|
26
|
-
import { a as captureTelegramFetch, h as telegramChatCapture, i as captureRouteDecider, s as chatIdentities, u as recordGateDecision } from "../../../_chunks/chat-archive-
|
|
25
|
+
import { a as captureTelegramFetch, h as telegramChatCapture, i as captureRouteDecider, s as chatIdentities, u as recordGateDecision } from "../../../_chunks/chat-archive-CMyCVvpe.mjs";
|
|
27
26
|
import { runtimeTokenVerifier } from "../runtime-identity.mjs";
|
|
28
27
|
import { runtimeToken } from "../runtime-token.mjs";
|
|
29
|
-
import { isWorkspaceCallback } from "../workspace-action.mjs";
|
|
30
28
|
import { botIdentityCache, proxiedBotRequest, runtimeBotIdentity } from "./bot.mjs";
|
|
29
|
+
import { isWorkspaceCallback } from "../workspace-action.mjs";
|
|
31
30
|
import { handleConfirmationCallback, telegramConfirmationEvents } from "./confirmations.mjs";
|
|
32
31
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
33
32
|
import { telegramAppLinkContext } from "./app-links.mjs";
|
|
@@ -41,8 +40,8 @@ import { recoverableSessions } from "./session-recovery.mjs";
|
|
|
41
40
|
import { TELEGRAM_PLACEHOLDER_TOKEN, TELEGRAM_PROXY_ORIGIN, telegramProxyFetch } from "./proxy-fetch.mjs";
|
|
42
41
|
import { healthRoute } from "./health.mjs";
|
|
43
42
|
import { decisionRouter } from "../group-routing/router.mjs";
|
|
44
|
-
import { scopedAddress } from "./sessions.mjs";
|
|
45
|
-
import { a as isNoReplyCall, i as interimTexts, s as replyDelivery } from "../../../_chunks/silent-
|
|
43
|
+
import { scopedAddress, senderAddress } from "./sessions.mjs";
|
|
44
|
+
import { a as isNoReplyCall, i as interimTexts, s as replyDelivery } from "../../../_chunks/silent-CWcAjHwt.mjs";
|
|
46
45
|
import { channelReview, holdFilesAfterTurn } from "../review/reply.mjs";
|
|
47
46
|
import { telegramSendScope } from "./send-queue.mjs";
|
|
48
47
|
import { telegramFailureEvents } from "./turn-errors.mjs";
|
|
@@ -161,7 +160,13 @@ function segmentstreamTelegram(options) {
|
|
|
161
160
|
const chats = channelChats("telegram", (provider) => agentChats({
|
|
162
161
|
provider,
|
|
163
162
|
identities: pairing,
|
|
164
|
-
onInvite: (chat, inviter) =>
|
|
163
|
+
onInvite: async (chat, inviter) => {
|
|
164
|
+
await pairing().reportInvite?.({
|
|
165
|
+
provider: "telegram",
|
|
166
|
+
key: `${provider}:${chat}`,
|
|
167
|
+
inviter
|
|
168
|
+
});
|
|
169
|
+
}
|
|
165
170
|
}));
|
|
166
171
|
const capture = telegramChatCapture({
|
|
167
172
|
archive,
|
|
@@ -402,6 +407,7 @@ function segmentstreamTelegram(options) {
|
|
|
402
407
|
query,
|
|
403
408
|
identities: pairing(),
|
|
404
409
|
read: readInteractions,
|
|
410
|
+
admission: options.admission?.() ?? manifestOf({}),
|
|
405
411
|
scope: options.sessions().scope
|
|
406
412
|
});
|
|
407
413
|
} catch (error) {
|
|
@@ -576,11 +582,12 @@ function gatedRoute(input) {
|
|
|
576
582
|
runtime: agentBuild(environment)
|
|
577
583
|
});
|
|
578
584
|
const scoped = (address) => scopedAddress(address, options.sessions().scope);
|
|
585
|
+
const sessionAddress = (address) => senderAddress(address, inbound.sessionOwner);
|
|
579
586
|
inbound.sessions = {
|
|
580
|
-
resolveSession: args.resolveSession,
|
|
581
|
-
from: args.from
|
|
587
|
+
resolveSession: (address) => args.resolveSession(sessionAddress(address)),
|
|
588
|
+
from: (address) => args.from(sessionAddress(address))
|
|
582
589
|
};
|
|
583
|
-
inbound.respond = (address, requestId, decision, auth, text) => args.from(scoped(address)).respond([{
|
|
590
|
+
inbound.respond = (address, requestId, decision, auth, text) => args.from(inbound.responseAddress ?? sessionAddress(scoped(address))).respond([{
|
|
584
591
|
interactionId: requestId,
|
|
585
592
|
optionId: decision === "cancel" ? "deny" : "approve",
|
|
586
593
|
...text === void 0 ? {} : { text }
|
|
@@ -595,7 +602,7 @@ function gatedRoute(input) {
|
|
|
595
602
|
const response = await route.handler(routedRequest, {
|
|
596
603
|
...args,
|
|
597
604
|
waitUntil,
|
|
598
|
-
from: (address) => withReplacedText(args.from(inbound.address ?? scoped(address)), inbound)
|
|
605
|
+
from: (address) => withReplacedText(args.from(sessionAddress(inbound.address ?? scoped(address))), inbound)
|
|
599
606
|
});
|
|
600
607
|
for (let completed = 0; completed < tasks.length;) {
|
|
601
608
|
const pending = tasks.slice(completed);
|
|
@@ -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 { St as reportTelegramError } from "../../../_chunks/principal-DIQHp6AG.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,7 +5,7 @@ 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 { St as reportTelegramError, _ as AttachmentError, bt as failureText, vt as customerMessage } from "../../../_chunks/principal-DIQHp6AG.mjs";
|
|
9
9
|
import { attachmentFailure } from "../attachments-send.mjs";
|
|
10
10
|
import { connectionProxy } from "../connection-proxy.mjs";
|
|
11
11
|
import { StoredFileError, downloadStoredFile, storedChannelFile, storedFileGrant } from "../sent-files.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 { At as telegramRuntimeSource, St as reportTelegramError, c as currentInboundRequest, i as memberIdOf, kt as runtimeEnvelope, o as telegramPrincipal } from "../../../_chunks/principal-DIQHp6AG.mjs";
|
|
8
8
|
import { formatAddress, parseAddress, scopedAddress } from "./sessions.mjs";
|
|
9
9
|
import { telegramText } from "./texts.mjs";
|
|
10
10
|
import { isWorkspaceCallback, pressWorkspaceButton, queueWorkspaceButtonTurn, workspaceAction, workspaceButtonToken } from "../workspace-action.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 REVISION_CLAIM_TTL_MS, n as attachmentIdentity, r as attachmentRefs, i as captureRouteDecider, a as captureTelegramFetch, o as captureTelegramWebhook, s as chatIdentities, c as currentCapture, l as participants, u as recordGateDecision, d as recordInboundContent, f as recordRouteDecision, p as recordSessionFailure, m as registerCapture, h as telegramChatCapture } from "../../../_chunks/chat-archive-
|
|
7
|
+
export { t as REVISION_CLAIM_TTL_MS, n as attachmentIdentity, r as attachmentRefs, i as captureRouteDecider, a as captureTelegramFetch, o as captureTelegramWebhook, s as chatIdentities, c as currentCapture, l as participants, u as recordGateDecision, d as recordInboundContent, f as recordRouteDecision, p as recordSessionFailure, m as registerCapture, h as telegramChatCapture } from "../../../_chunks/chat-archive-CMyCVvpe.mjs";
|
|
@@ -4,6 +4,7 @@ import { type ConfirmationPrompt, type PendingConfirmation, type RecentMessage }
|
|
|
4
4
|
import { type ChatArchive } from "../chat-archive.js";
|
|
5
5
|
import type { AgentIdentities } from "../identities.js";
|
|
6
6
|
import { type PendingQuestion } from "../questions.js";
|
|
7
|
+
import type { AdmissionSettings } from "../../config.js";
|
|
7
8
|
import { type HistoryReader, type RecordedEvent } from "./sessions.js";
|
|
8
9
|
export declare function confirmationCallback(requestId: string, memberId: string, decision: "approve" | "cancel" | "edit"): string;
|
|
9
10
|
/** A usage-limit button's callback: the question it answers and whether the session goes on. */
|
|
@@ -39,6 +40,7 @@ export declare function handleConfirmationCallback(input: {
|
|
|
39
40
|
readonly identities: AgentIdentities;
|
|
40
41
|
readonly read: HistoryReader;
|
|
41
42
|
readonly scope: "chat" | "thread";
|
|
43
|
+
readonly admission?: AdmissionSettings;
|
|
42
44
|
readonly now?: number;
|
|
43
45
|
}): Promise<void>;
|
|
44
46
|
/**
|