@sentry/junior 0.303.0 → 0.305.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/dist/{adapter-context-BdVnSuY5.js → adapter-context-BpvbUki8.js} +2 -2
- package/dist/{admin-AfeAdS3J.js → admin-CoDt35ny.js} +5 -5
- package/dist/{agent-runner-BP8_DLUv.js → agent-runner-C5d6rY5g.js} +600 -389
- package/dist/api/schema.d.ts +1 -1
- package/dist/api/schema.js +5 -5
- package/dist/api.d.ts +1 -1
- package/dist/api.js +59 -61
- package/dist/{app-Dd9v1mNx.d.ts → app-Cs157Zc5.d.ts} +5 -3
- package/dist/app.d.ts +1 -1
- package/dist/app.js +86 -82
- package/dist/{automation-D9MvhOWY.js → automation-CuA3yEcD.js} +1 -1
- package/dist/{background-compaction-queue-xaE05jxH.js → background-compaction-queue-BTqMIfTA.js} +7 -3
- package/dist/{briefs-D8i-dKTp.js → briefs-BRdznF7c.js} +11 -8
- package/dist/{catalog-runtime-d1EM6Z0V.js → catalog-runtime-J52Tej47.js} +1 -1
- package/dist/cli/chat.js +15 -15
- package/dist/cli/check.js +5 -5
- package/dist/cli/init.js +1 -1
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +5 -5
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +4 -4
- package/dist/{config-oGM7KA9M.js → config-CBZp0udd.js} +101 -7
- package/dist/{connections-BlikzEJv.js → connections-BYmuJ6Vm.js} +6 -6
- package/dist/{continue-in-slack-BZnYifiG.js → continue-in-slack-Cvot6S38.js} +8 -8
- package/dist/{conversation-CY1jnBiC.js → conversation-BOqdRtUx.js} +4 -12
- package/dist/{conversation-feed-BZJRk6UV.js → conversation-feed-CgpgP7yi.js} +35 -2
- package/dist/{conversation-privacy-Cx515ddM.js → conversation-privacy-D2pOzBNl.js} +10 -2
- package/dist/{conversation-turn-DAhRdX4m.js → conversation-turn-CI8WDpnK.js} +17 -17
- package/dist/{credential-sync-DfhmWFeo.js → credential-sync-COqnZ1Dx.js} +14 -14
- package/dist/{db-C-2tFxk3.js → db-DU84dCVu.js} +169 -6
- package/dist/{db-DPqcEM9_.d.ts → db-zbN5ZV_o.d.ts} +2 -2
- package/dist/{executor-NVfS8aQ2.js → executor-CFyrgOu1.js} +43 -9
- package/dist/{history-UZ3M2M9r.js → history-m2-ceTTX.js} +8 -2
- package/dist/{install-CHLrpRZc.js → install-CQ76CfRw.js} +2 -2
- package/dist/instrumentation.js +7 -3
- package/dist/{lineage-HGLhd_-N.js → lineage-DLd2UxVP.js} +2 -2
- package/dist/{logging-DiyqRLBx.js → logging-BPNTQVFu.js} +1 -1
- package/dist/{message-CkCOcbFH.js → message-BWJLeQ5e.js} +8 -8
- package/dist/{model-input-DmoPPtPE.js → model-input-DoM9Ht-d.js} +2 -2
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +5 -5
- package/dist/{oauth-callback-server-CIf_6YmA.js → oauth-callback-server-DeHbnAQl.js} +2 -2
- package/dist/{projection-DBq8tsA5.js → projection-CcFBVFUo.js} +552 -63
- package/dist/{prompt-D2KlJopL.js → prompt-C5LREK2p.js} +185 -12
- package/dist/{queue-DFaOscp5.js → queue-B2AAL3ym.js} +4 -4
- package/dist/{registry-Bu0Z9BEO.js → registry-BjZZqKqi.js} +1 -1
- package/dist/{resolve-DXuA3G0g.js → resolve-CeJgXuH1.js} +3 -3
- package/dist/{result-DpiNseDA.js → result-icDrueyB.js} +8 -8
- package/dist/{runner-iu1heRFv.js → runner-nVfMkMMB.js} +9 -9
- package/dist/{sandbox-egress-signals-2HFYDcQf.js → sandbox-egress-signals-H9vQ5qRf.js} +1 -1
- package/dist/{schema-DvfX3Gq_.js → schema-Bx0Mlo32.js} +3 -3
- package/dist/{schema-DHMOaRzC.d.ts → schema-CKcu-IK6.d.ts} +43 -11
- package/dist/{service-account-BcT5LR7V.js → service-account-DU5865XA.js} +6 -5
- package/dist/{service-account-xYkaQTrw.js → service-account-Dw06p3zm.js} +5 -5
- package/dist/{session-stop-BLLp1IP_.js → session-stop-uotLtp4g.js} +181 -59
- package/dist/{skills-CNAGH4ju.js → skills-Bex1EaO5.js} +2 -2
- package/dist/{slack-conversation-unfurl-DYnqe5ci.js → slack-conversation-unfurl-EPG3riWF.js} +12 -11
- package/dist/{spawn-cGasWW33.js → spawn-CoD3vDuS.js} +6 -6
- package/dist/{state-CDS6h_Wv.js → state-nCR4Muhn.js} +4 -4
- package/dist/{stop-DMMA67yT.js → stop-BFVd0P0m.js} +170 -65
- package/dist/{store-Dgs7Oe44.js → store-Ca6G962n.js} +5 -5
- package/dist/{task-queue-DcF0nhhz.js → task-queue-BLPZU6kC.js} +3 -3
- package/dist/{task-runner-BGXF7Fo7.js → task-runner-xsOPIxCZ.js} +7 -7
- package/dist/{thread-context-BPky1KBe.js → thread-context-BOvZhsKK.js} +8 -8
- package/dist/{turn-session-routing-DGvn9MSl.js → turn-session-routing-2bW2qfeb.js} +8 -8
- package/dist/{turn-user-message-19CkuUvM.js → turn-user-message-BrhuyYrH.js} +3 -3
- package/dist/{validation-lu1DgjNQ.js → validation-BnY9K5WB.js} +1 -1
- package/dist/{version-Uo3c94Dx.js → version-qROlRQGF.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-BPQHMx3-.js → viewer-CxUiOraX.js} +3 -3
- package/dist/{warmup-H8uLvW9e.js → warmup--Gkz7iB-.js} +79 -476
- package/dist/{worker-B-pM_-3K.js → worker-DJ8d9fmD.js} +7 -7
- package/migrations/0111_attachment_kinds.sql +14 -0
- package/migrations/0112_attachment_url_fill.sql +51 -0
- package/migrations/0113_attachment_url_index.sql +1 -0
- package/migrations/meta/0099_snapshot.json +102 -326
- package/migrations/meta/0111_snapshot.json +5011 -0
- package/migrations/meta/0112_snapshot.json +5011 -0
- package/migrations/meta/0113_snapshot.json +5033 -0
- package/migrations/meta/_journal.json +21 -0
- package/package.json +7 -7
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
|
|
2
|
-
import { d as contextProvenance, f as instructionActors, n as agentHistoryItemSchema, p as instructionProvenanceFor } from "./history-
|
|
3
|
-
import { _ as
|
|
4
|
-
import { $ as
|
|
5
|
-
import { D as juniorConversationAnnotations, F as juniorDestinations, M as
|
|
6
|
-
import { E as withSpan, J as toOptionalString, K as isRecord$2, _ as runBestEffort, a as extractGenAiUsageSummary, b as setSpanAttributes, c as getLogContextAttributes, d as logAudit, h as logWarn, m as logInfo, o as getActiveTraceContext, p as logException, q as toOptionalNumber, t as buildTurnFailureResponse, x as setSpanStatus, y as setSentryUser } from "./logging-
|
|
7
|
-
import { _ as CredentialUnavailableError, a as resolveAuthTokenPlaceholder, f as credentialContextForActor, g as credentialUserSubjectId, h as credentialSubjectSchema, m as credentialLogContext, o as resolvePluginCommandEnv, p as credentialContextSchema } from "./registry-
|
|
2
|
+
import { d as contextProvenance, f as instructionActors, n as agentHistoryItemSchema, p as instructionProvenanceFor } from "./history-m2-ceTTX.js";
|
|
3
|
+
import { _ as agentsInstructionsUpdatedEvent, d as embedTexts, g as JUNIOR_NATIVE_EVENT_NAMESPACE, l as completeObject, n as briefEntriesFromReportEvents, o as isEventConversationMessage, s as generateBrief, t as BRIEF_PROMPT, u as completeText, v as authenticationLinkedEvent, x as renderJuniorNativeConversationEvent, y as authenticationUnlinkedEvent } from "./prompt-C5LREK2p.js";
|
|
4
|
+
import { $ as MUTATION_LOCK_TTL_MS, I as resolveActorIdentityId, N as startLocationThread, Q as setStateValues, S as createSqlStore, T as isPersonInput, U as saveUserTimezone, V as readUserTimezone, X as getStateAdapter, Y as getDefaultRedisStateAdapterFor, Z as getStateValues, _t as parseDestination, a as getConversationStore, c as hasAnnotationKey, d as eventFromRow, et as acquireActiveLock, ht as touchConversationDetail, l as treeHasAnnotationKey, m as withConversationEventLock, nt as withLock, o as getDb, ot as addAgentTurnUsage, pt as conversationDetailTouch, q as createCache, r as getConversationEventStore, rt as claimProviderConversation, s as getSqlExecutor, tt as fenceLock, u as createSqlConversationEventStore, ut as hasAgentTurnUsage, yt as sameDestination } from "./db-DU84dCVu.js";
|
|
5
|
+
import { D as juniorConversationAnnotations, F as juniorUsers, I as juniorDestinations, M as juniorMessageAttachments, N as juniorConversations, O as juniorCodeChanges, P as juniorIdentities, T as juniorConversationEvents, a as juniorPushSubscriptions, b as juniorConversationEmbeddings, f as juniorAutomations, i as juniorWorkspaces, j as juniorAttachments, k as juniorCodeRepositories, l as juniorReviewItems, m as juniorLocationConfigurations, n as juniorSnapshots, o as juniorReviewItemAssignees, r as juniorWorkspaceRepos, s as juniorReviewItemConversations, v as juniorConversationParticipants, x as juniorConversationBriefs } from "./executor-CFyrgOu1.js";
|
|
6
|
+
import { E as withSpan, J as toOptionalString, K as isRecord$2, _ as runBestEffort, a as extractGenAiUsageSummary, b as setSpanAttributes, c as getLogContextAttributes, d as logAudit, h as logWarn, m as logInfo, o as getActiveTraceContext, p as logException, q as toOptionalNumber, t as buildTurnFailureResponse, x as setSpanStatus, y as setSentryUser } from "./logging-BPNTQVFu.js";
|
|
7
|
+
import { _ as CredentialUnavailableError, a as resolveAuthTokenPlaceholder, f as credentialContextForActor, g as credentialUserSubjectId, h as credentialSubjectSchema, m as credentialLogContext, o as resolvePluginCommandEnv, p as credentialContextSchema } from "./registry-BjZZqKqi.js";
|
|
8
8
|
import { n as isWithinNotificationSchedule, r as notificationScheduleSchema, s as isValidTimeZone, t as DEFAULT_NOTIFICATION_SCHEDULE } from "./schedule-cP0AACm1.js";
|
|
9
|
-
import {
|
|
9
|
+
import { $ as bufferBody, B as unwrapCurrentInstruction, C as completeObject$1, O as rerankTexts, P as estimateTextTokens, S as completeDecision, T as embedTexts$1, V as escapeXml, b as GEN_AI_PROVIDER_NAME, i as getChatConfig, k as resolveGatewayModel, n as botConfig, o as getSlackBotToken, tt as toOptionalTrimmed, y as normalizeSlackEmojiName } from "./config-CBZp0udd.js";
|
|
10
10
|
import { c as parseStoredSlackActor, d as parseSlackChannelReferenceId, f as parseSlackTeamId, i as isActorUserId, l as toStoredSlackActor, p as parseSlackUserId, s as parseActorUserId, v as parseSlackMessageTs } from "./actor-D2iXzvlN.js";
|
|
11
|
-
import { i as readActorIdentity, l as resolveViewerUser, n as findUserByEmailFromSql, o as readIdentityById, p as parseAvatarUrl, s as readIdentityByIdFromSql } from "./viewer-
|
|
12
|
-
import { $ as
|
|
11
|
+
import { i as readActorIdentity, l as resolveViewerUser, n as findUserByEmailFromSql, o as readIdentityById, p as parseAvatarUrl, s as readIdentityByIdFromSql } from "./viewer-CxUiOraX.js";
|
|
12
|
+
import { $ as conversationBriefSchema, J as readMessageAttachments, L as reviewItemChangeRecordSchema, Q as briefResourceLabel, V as readMessageCardRefs, _ as conversationReportMessageEventSchema, et as parseBriefInput, g as conversationReportEventSchema, tt as parseStoredBrief, z as messageCardRef } from "./conversation-BOqdRtUx.js";
|
|
13
13
|
import { a as getClient$1, h as startSpan, n as captureMessage, r as continueTrace } from "./sentry-CPbZjomA.js";
|
|
14
|
-
import { t as canExposeConversationPayload } from "./conversation-privacy-
|
|
15
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
14
|
+
import { t as canExposeConversationPayload } from "./conversation-privacy-D2pOzBNl.js";
|
|
15
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-J52Tej47.js";
|
|
16
16
|
import { n as redactSandboxEgressProxyPath, t as SANDBOX_EGRESS_PROXY_PATH } from "./proxy-path-BHYoKZdq.js";
|
|
17
|
-
import { n as readEncryptedState, r as findLegacyWebActorUserId, t as createEncryptedState } from "./state-
|
|
17
|
+
import { n as readEncryptedState, r as findLegacyWebActorUserId, t as createEncryptedState } from "./state-nCR4Muhn.js";
|
|
18
18
|
import { i as readWebPushPrivateKey, t as readJuniorSecret } from "./secrets-DHaJ5TTn.js";
|
|
19
19
|
import * as z from "zod";
|
|
20
20
|
import path from "node:path";
|
|
@@ -93,7 +93,10 @@ function historyItemFromPiMessage(message, provenance) {
|
|
|
93
93
|
...fields,
|
|
94
94
|
type: "tool_result"
|
|
95
95
|
});
|
|
96
|
-
|
|
96
|
+
return agentHistoryItemSchema.parse({
|
|
97
|
+
...fields,
|
|
98
|
+
type: "system_message"
|
|
99
|
+
});
|
|
97
100
|
}
|
|
98
101
|
/** Translate one Junior-native history item into the Pi message it represents. */
|
|
99
102
|
function piMessageFromHistoryItem(data) {
|
|
@@ -111,6 +114,13 @@ function piMessageFromHistoryItem(data) {
|
|
|
111
114
|
role: "assistant"
|
|
112
115
|
});
|
|
113
116
|
}
|
|
117
|
+
if (data.type === "system_message") {
|
|
118
|
+
const { type: _, ...fields } = data;
|
|
119
|
+
return piMessageSchema.parse({
|
|
120
|
+
...fields,
|
|
121
|
+
role: "system"
|
|
122
|
+
});
|
|
123
|
+
}
|
|
114
124
|
const { type: _, ...fields } = data;
|
|
115
125
|
return piMessageSchema.parse({
|
|
116
126
|
...fields,
|
|
@@ -148,7 +158,7 @@ function projectConversationEvents$1(events, options = {}) {
|
|
|
148
158
|
}
|
|
149
159
|
continue;
|
|
150
160
|
}
|
|
151
|
-
if (event.data.type === "user_message" || event.data.type === "assistant_message" || event.data.type === "tool_result") {
|
|
161
|
+
if (event.data.type === "user_message" || event.data.type === "assistant_message" || event.data.type === "tool_result" || event.data.type === "system_message") {
|
|
152
162
|
const message = piMessageFromHistoryItem(event.data);
|
|
153
163
|
messages.push(message);
|
|
154
164
|
provenance.push(historyItemProvenance(event.data));
|
|
@@ -1716,6 +1726,485 @@ async function streamPrivateSlackFile(url) {
|
|
|
1716
1726
|
if (!response.body) throw new Error("Slack file download returned no body");
|
|
1717
1727
|
return response.body;
|
|
1718
1728
|
}
|
|
1729
|
+
// src/chat/attachments/store.ts
|
|
1730
|
+
const DAY_MS$3 = 864e5;
|
|
1731
|
+
const ATTACHMENT_GC_BATCH_LIMIT = 200;
|
|
1732
|
+
/** Time that Junior keeps attachment bytes after the file is stored. */
|
|
1733
|
+
const ATTACHMENT_RETENTION_MS = 30 * DAY_MS$3;
|
|
1734
|
+
/** Only `file` rows: a `url` row has no storage or file fields. */
|
|
1735
|
+
const isFileAttachment = eq(juniorAttachments.kind, "file");
|
|
1736
|
+
/**
|
|
1737
|
+
* The storage and file fields of a `file` row. Every `file` row has them, so
|
|
1738
|
+
* a missing one is a broken row.
|
|
1739
|
+
*/
|
|
1740
|
+
function fileFields(row) {
|
|
1741
|
+
const { bytes, contentType, storageProvider, title } = row;
|
|
1742
|
+
if (bytes === null || contentType === null || storageProvider === null || title === null) throw new Error(`Attachment ${row.id} has no file fields`);
|
|
1743
|
+
return {
|
|
1744
|
+
bytes,
|
|
1745
|
+
contentType,
|
|
1746
|
+
filename: title,
|
|
1747
|
+
storageProvider
|
|
1748
|
+
};
|
|
1749
|
+
}
|
|
1750
|
+
function attachmentIdentity(file) {
|
|
1751
|
+
if ("data" in file) return file.source ?? { sha256: createHash("sha256").update(file.data).digest("hex") };
|
|
1752
|
+
return file.source;
|
|
1753
|
+
}
|
|
1754
|
+
/** Stable conversation-owned id for one file and its presentation metadata. */
|
|
1755
|
+
function attachmentId(args) {
|
|
1756
|
+
const identity = "sha256" in args.identity ? [
|
|
1757
|
+
args.conversationId,
|
|
1758
|
+
args.storageProvider,
|
|
1759
|
+
args.identity.sha256,
|
|
1760
|
+
args.filename,
|
|
1761
|
+
args.contentType
|
|
1762
|
+
] : [
|
|
1763
|
+
args.conversationId,
|
|
1764
|
+
args.storageProvider,
|
|
1765
|
+
args.filename,
|
|
1766
|
+
args.contentType,
|
|
1767
|
+
args.identity.provider,
|
|
1768
|
+
args.identity.id
|
|
1769
|
+
];
|
|
1770
|
+
return createHash("sha256").update(identity.join("\0")).digest("hex");
|
|
1771
|
+
}
|
|
1772
|
+
/**
|
|
1773
|
+
* Object key for one write attempt.
|
|
1774
|
+
*
|
|
1775
|
+
* Attachment ids are content-stable. Object keys are not: each put gets a fresh
|
|
1776
|
+
* key so a failed-write cleanup or GC delete cannot remove another writer's
|
|
1777
|
+
* durable blob.
|
|
1778
|
+
*/
|
|
1779
|
+
function attachmentKey(args) {
|
|
1780
|
+
return `conversations/${args.conversationId}/attachments/${args.attachmentId}/${args.writeId}/${args.filename}`;
|
|
1781
|
+
}
|
|
1782
|
+
/** A source whose bytes do not match its declared size. A retry cannot fix it. */
|
|
1783
|
+
var AttachmentSizeError = class extends Error {
|
|
1784
|
+
constructor(bytes, expected, options) {
|
|
1785
|
+
super(`Attachment body does not match its declared ${expected} bytes (read ${bytes})`, options);
|
|
1786
|
+
this.name = "AttachmentSizeError";
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
/** Tries for one object write, each with a freshly opened body. */
|
|
1790
|
+
const WRITE_ATTEMPTS = 3;
|
|
1791
|
+
async function bestEffortDelete(storage, key) {
|
|
1792
|
+
if (key === null) return;
|
|
1793
|
+
try {
|
|
1794
|
+
await storage.delete([key]);
|
|
1795
|
+
} catch {}
|
|
1796
|
+
}
|
|
1797
|
+
/**
|
|
1798
|
+
* Stream one file to a fresh key, and return its size and digest.
|
|
1799
|
+
*
|
|
1800
|
+
* The digest is taken while the bytes stream, so the body is never held
|
|
1801
|
+
* whole. A body that does not match its declared size is not kept.
|
|
1802
|
+
*/
|
|
1803
|
+
async function writeAttachmentObject(args) {
|
|
1804
|
+
for (let attempt = 1;; attempt += 1) try {
|
|
1805
|
+
return await writeAttachmentObjectOnce(args);
|
|
1806
|
+
} catch (error) {
|
|
1807
|
+
if (error instanceof AttachmentSizeError || error instanceof AttachmentSourceUnavailableError || attempt >= WRITE_ATTEMPTS) {
|
|
1808
|
+
await bestEffortDelete(args.storage, args.key);
|
|
1809
|
+
throw error;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
async function writeAttachmentObjectOnce(args) {
|
|
1814
|
+
const { file } = args;
|
|
1815
|
+
const expected = "data" in file ? file.data.byteLength : file.bytes;
|
|
1816
|
+
const source = "data" in file ? bufferBody(file.data) : await file.open();
|
|
1817
|
+
const hash = createHash("sha256");
|
|
1818
|
+
let bytes = 0;
|
|
1819
|
+
const body = source.pipeThrough(new TransformStream({ transform(chunk, controller) {
|
|
1820
|
+
bytes += chunk.byteLength;
|
|
1821
|
+
if (bytes > expected) throw new AttachmentSizeError(bytes, expected);
|
|
1822
|
+
hash.update(chunk);
|
|
1823
|
+
controller.enqueue(chunk);
|
|
1824
|
+
} }));
|
|
1825
|
+
try {
|
|
1826
|
+
await args.storage.put({
|
|
1827
|
+
body,
|
|
1828
|
+
bytes: expected,
|
|
1829
|
+
contentType: file.mimeType,
|
|
1830
|
+
key: args.key
|
|
1831
|
+
});
|
|
1832
|
+
} catch (error) {
|
|
1833
|
+
if (bytes > expected) throw new AttachmentSizeError(bytes, expected, { cause: error });
|
|
1834
|
+
throw error;
|
|
1835
|
+
}
|
|
1836
|
+
if (bytes !== expected) throw new AttachmentSizeError(bytes, expected);
|
|
1837
|
+
return {
|
|
1838
|
+
bytes,
|
|
1839
|
+
sha256: hash.digest("hex")
|
|
1840
|
+
};
|
|
1841
|
+
}
|
|
1842
|
+
async function isConversationPurged(db, conversationId) {
|
|
1843
|
+
const [row] = await db.db().select({ transcriptPurgedAt: juniorConversations.transcriptPurgedAt }).from(juniorConversations).where(eq(juniorConversations.conversationId, conversationId));
|
|
1844
|
+
return row?.transcriptPurgedAt != null;
|
|
1845
|
+
}
|
|
1846
|
+
function purgedConversationError(conversationId) {
|
|
1847
|
+
return /* @__PURE__ */ new Error(`Cannot store attachment for purged conversation ${conversationId}`);
|
|
1848
|
+
}
|
|
1849
|
+
async function assertConversationNotPurged(db, conversationId) {
|
|
1850
|
+
if (await isConversationPurged(db, conversationId)) throw purgedConversationError(conversationId);
|
|
1851
|
+
}
|
|
1852
|
+
/** Mark a just-written row for deletion and drop its unused object. */
|
|
1853
|
+
async function rejectPurgedAttachmentWrite(args) {
|
|
1854
|
+
const db = args.db.db();
|
|
1855
|
+
await db.with(conversationDetailTouch(db, [args.conversationId])).update(juniorAttachments).set({ deleteRequestedAt: args.now }).where(eq(juniorAttachments.id, args.id));
|
|
1856
|
+
await bestEffortDelete(args.storage, args.storageKey);
|
|
1857
|
+
throw purgedConversationError(args.conversationId);
|
|
1858
|
+
}
|
|
1859
|
+
/**
|
|
1860
|
+
* Return another writer's live row only when the conversation is still active.
|
|
1861
|
+
*
|
|
1862
|
+
* The caller already wrote a unique object for this attempt. Delete that unused
|
|
1863
|
+
* object either way. If the conversation is purged, do not report success for a
|
|
1864
|
+
* row that purge/GC is about to remove.
|
|
1865
|
+
*/
|
|
1866
|
+
async function reuseLiveAttachment(args) {
|
|
1867
|
+
await bestEffortDelete(args.storage, args.storageKey);
|
|
1868
|
+
await assertConversationNotPurged(args.db, args.conversationId);
|
|
1869
|
+
return { id: args.id };
|
|
1870
|
+
}
|
|
1871
|
+
/**
|
|
1872
|
+
* Persist one conversation-owned file.
|
|
1873
|
+
*
|
|
1874
|
+
* Identity is stable under the conversation: it comes from the file's source
|
|
1875
|
+
* when it has one, and from its digest otherwise. Object storage is written
|
|
1876
|
+
* first under a unique key; the SQL row is created only after that write
|
|
1877
|
+
* succeeds. A row means the attachment is durable. Retries reuse an existing
|
|
1878
|
+
* live row. A purge-marked row is revived by writing a new object and pointing
|
|
1879
|
+
* the row at it, unless the conversation is still purged. If the SQL write
|
|
1880
|
+
* fails after object storage accepts the bytes, this path deletes that unique
|
|
1881
|
+
* object. A process crash between those steps can leave an unreferenced unique
|
|
1882
|
+
* object with no SQL row.
|
|
1883
|
+
*/
|
|
1884
|
+
async function storeAttachment(args) {
|
|
1885
|
+
const now = new Date(args.nowMs ?? Date.now());
|
|
1886
|
+
const identity = attachmentIdentity(args.file);
|
|
1887
|
+
const source = args.file.source;
|
|
1888
|
+
const id = attachmentId({
|
|
1889
|
+
conversationId: args.conversationId,
|
|
1890
|
+
contentType: args.file.mimeType,
|
|
1891
|
+
filename: args.file.filename,
|
|
1892
|
+
identity,
|
|
1893
|
+
storageProvider: args.storage.provider
|
|
1894
|
+
});
|
|
1895
|
+
const [existing] = await args.db.db().select({
|
|
1896
|
+
contentType: juniorAttachments.contentType,
|
|
1897
|
+
conversationId: juniorAttachments.conversationId,
|
|
1898
|
+
deleteRequestedAt: juniorAttachments.deleteRequestedAt,
|
|
1899
|
+
filename: juniorAttachments.title,
|
|
1900
|
+
id: juniorAttachments.id,
|
|
1901
|
+
provider: juniorAttachments.provider,
|
|
1902
|
+
providerId: juniorAttachments.providerId,
|
|
1903
|
+
storageProvider: juniorAttachments.storageProvider,
|
|
1904
|
+
sha256: juniorAttachments.sha256,
|
|
1905
|
+
storageKey: juniorAttachments.storageKey
|
|
1906
|
+
}).from(juniorAttachments).where(eq(juniorAttachments.id, id));
|
|
1907
|
+
if (existing) {
|
|
1908
|
+
if (existing.contentType !== args.file.mimeType || existing.conversationId !== args.conversationId || existing.filename !== args.file.filename || existing.provider !== (source?.provider ?? null) || existing.providerId !== (source?.id ?? null) || existing.storageProvider !== args.storage.provider || "sha256" in identity && existing.sha256 !== identity.sha256) throw new Error(`Attachment write conflicts with ${existing.id}`);
|
|
1909
|
+
if (existing.deleteRequestedAt === null) {
|
|
1910
|
+
await assertConversationNotPurged(args.db, args.conversationId);
|
|
1911
|
+
return { id: existing.id };
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
await assertConversationNotPurged(args.db, args.conversationId);
|
|
1915
|
+
const { file } = args;
|
|
1916
|
+
let storageKey = null;
|
|
1917
|
+
let written;
|
|
1918
|
+
if ("deferred" in file) written = {
|
|
1919
|
+
bytes: file.bytes,
|
|
1920
|
+
sha256: null
|
|
1921
|
+
};
|
|
1922
|
+
else {
|
|
1923
|
+
storageKey = attachmentKey({
|
|
1924
|
+
attachmentId: id,
|
|
1925
|
+
conversationId: args.conversationId,
|
|
1926
|
+
filename: file.filename,
|
|
1927
|
+
writeId: randomUUID()
|
|
1928
|
+
});
|
|
1929
|
+
written = await writeAttachmentObject({
|
|
1930
|
+
file,
|
|
1931
|
+
key: storageKey,
|
|
1932
|
+
storage: args.storage
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
1935
|
+
if (existing?.deleteRequestedAt != null) {
|
|
1936
|
+
if (await isConversationPurged(args.db, args.conversationId)) {
|
|
1937
|
+
await bestEffortDelete(args.storage, storageKey);
|
|
1938
|
+
throw purgedConversationError(args.conversationId);
|
|
1939
|
+
}
|
|
1940
|
+
const oldStorageKey = existing.storageKey;
|
|
1941
|
+
if ((await args.db.db().with(conversationDetailTouch(args.db.db(), [args.conversationId])).update(juniorAttachments).set({
|
|
1942
|
+
...written,
|
|
1943
|
+
deleteRequestedAt: null,
|
|
1944
|
+
storageKey
|
|
1945
|
+
}).where(and(eq(juniorAttachments.id, id), isNotNull(juniorAttachments.deleteRequestedAt))).returning({ id: juniorAttachments.id })).length > 0) {
|
|
1946
|
+
if (await isConversationPurged(args.db, args.conversationId)) await rejectPurgedAttachmentWrite({
|
|
1947
|
+
conversationId: args.conversationId,
|
|
1948
|
+
db: args.db,
|
|
1949
|
+
id,
|
|
1950
|
+
now,
|
|
1951
|
+
storage: args.storage,
|
|
1952
|
+
storageKey
|
|
1953
|
+
});
|
|
1954
|
+
if (oldStorageKey !== storageKey) await bestEffortDelete(args.storage, oldStorageKey);
|
|
1955
|
+
return { id };
|
|
1956
|
+
}
|
|
1957
|
+
const [afterRace] = await args.db.db().select({
|
|
1958
|
+
deleteRequestedAt: juniorAttachments.deleteRequestedAt,
|
|
1959
|
+
id: juniorAttachments.id,
|
|
1960
|
+
storageKey: juniorAttachments.storageKey
|
|
1961
|
+
}).from(juniorAttachments).where(eq(juniorAttachments.id, id));
|
|
1962
|
+
if (afterRace?.deleteRequestedAt === null) return reuseLiveAttachment({
|
|
1963
|
+
conversationId: args.conversationId,
|
|
1964
|
+
db: args.db,
|
|
1965
|
+
id: afterRace.id,
|
|
1966
|
+
storage: args.storage,
|
|
1967
|
+
storageKey
|
|
1968
|
+
});
|
|
1969
|
+
}
|
|
1970
|
+
let inserted = [];
|
|
1971
|
+
try {
|
|
1972
|
+
inserted = await args.db.db().with(conversationDetailTouch(args.db.db(), [args.conversationId])).insert(juniorAttachments).values({
|
|
1973
|
+
id,
|
|
1974
|
+
conversationId: args.conversationId,
|
|
1975
|
+
storageProvider: args.storage.provider,
|
|
1976
|
+
storageKey,
|
|
1977
|
+
provider: source?.provider,
|
|
1978
|
+
providerId: source?.id,
|
|
1979
|
+
title: args.file.filename,
|
|
1980
|
+
contentType: args.file.mimeType,
|
|
1981
|
+
...written,
|
|
1982
|
+
createdAt: now
|
|
1983
|
+
}).onConflictDoNothing({ target: juniorAttachments.id }).returning({ id: juniorAttachments.id });
|
|
1984
|
+
} catch (error) {
|
|
1985
|
+
await bestEffortDelete(args.storage, storageKey);
|
|
1986
|
+
throw error;
|
|
1987
|
+
}
|
|
1988
|
+
if (inserted.length > 0) {
|
|
1989
|
+
if (await isConversationPurged(args.db, args.conversationId)) await rejectPurgedAttachmentWrite({
|
|
1990
|
+
conversationId: args.conversationId,
|
|
1991
|
+
db: args.db,
|
|
1992
|
+
id,
|
|
1993
|
+
now,
|
|
1994
|
+
storage: args.storage,
|
|
1995
|
+
storageKey
|
|
1996
|
+
});
|
|
1997
|
+
return { id };
|
|
1998
|
+
}
|
|
1999
|
+
const [row] = await args.db.db().select({
|
|
2000
|
+
deleteRequestedAt: juniorAttachments.deleteRequestedAt,
|
|
2001
|
+
id: juniorAttachments.id,
|
|
2002
|
+
storageKey: juniorAttachments.storageKey
|
|
2003
|
+
}).from(juniorAttachments).where(eq(juniorAttachments.id, id));
|
|
2004
|
+
if (!row) {
|
|
2005
|
+
await bestEffortDelete(args.storage, storageKey);
|
|
2006
|
+
throw new Error(`Attachment row missing after write for ${id}`);
|
|
2007
|
+
}
|
|
2008
|
+
if (row.deleteRequestedAt === null) return reuseLiveAttachment({
|
|
2009
|
+
conversationId: args.conversationId,
|
|
2010
|
+
db: args.db,
|
|
2011
|
+
id: row.id,
|
|
2012
|
+
storage: args.storage,
|
|
2013
|
+
storageKey
|
|
2014
|
+
});
|
|
2015
|
+
if (await isConversationPurged(args.db, args.conversationId)) {
|
|
2016
|
+
await bestEffortDelete(args.storage, storageKey);
|
|
2017
|
+
throw purgedConversationError(args.conversationId);
|
|
2018
|
+
}
|
|
2019
|
+
if ((await args.db.db().with(conversationDetailTouch(args.db.db(), [args.conversationId])).update(juniorAttachments).set({
|
|
2020
|
+
...written,
|
|
2021
|
+
deleteRequestedAt: null,
|
|
2022
|
+
storageKey
|
|
2023
|
+
}).where(and(eq(juniorAttachments.id, id), isNotNull(juniorAttachments.deleteRequestedAt))).returning({ id: juniorAttachments.id })).length > 0) {
|
|
2024
|
+
if (await isConversationPurged(args.db, args.conversationId)) await rejectPurgedAttachmentWrite({
|
|
2025
|
+
conversationId: args.conversationId,
|
|
2026
|
+
db: args.db,
|
|
2027
|
+
id,
|
|
2028
|
+
now,
|
|
2029
|
+
storage: args.storage,
|
|
2030
|
+
storageKey
|
|
2031
|
+
});
|
|
2032
|
+
if (row.storageKey !== storageKey) await bestEffortDelete(args.storage, row.storageKey);
|
|
2033
|
+
return { id };
|
|
2034
|
+
}
|
|
2035
|
+
const [afterRace] = await args.db.db().select({
|
|
2036
|
+
deleteRequestedAt: juniorAttachments.deleteRequestedAt,
|
|
2037
|
+
id: juniorAttachments.id
|
|
2038
|
+
}).from(juniorAttachments).where(eq(juniorAttachments.id, id));
|
|
2039
|
+
if (afterRace?.deleteRequestedAt === null) return reuseLiveAttachment({
|
|
2040
|
+
conversationId: args.conversationId,
|
|
2041
|
+
db: args.db,
|
|
2042
|
+
id: afterRace.id,
|
|
2043
|
+
storage: args.storage,
|
|
2044
|
+
storageKey
|
|
2045
|
+
});
|
|
2046
|
+
await bestEffortDelete(args.storage, storageKey);
|
|
2047
|
+
throw new Error(`Attachment ${id} disappeared while reviving`);
|
|
2048
|
+
}
|
|
2049
|
+
/**
|
|
2050
|
+
* Record an object that a browser already wrote, under the upload's id.
|
|
2051
|
+
*
|
|
2052
|
+
* The row takes over the object key. A retry with the same id keeps the
|
|
2053
|
+
* first row. The caller checked the object's size, type, and digest.
|
|
2054
|
+
*/
|
|
2055
|
+
async function recordUploadedAttachment(args) {
|
|
2056
|
+
const { attachment } = args;
|
|
2057
|
+
const now = new Date(args.nowMs);
|
|
2058
|
+
await assertConversationNotPurged(args.db, attachment.conversationId);
|
|
2059
|
+
if ((await args.db.db().with(conversationDetailTouch(args.db.db(), [attachment.conversationId])).insert(juniorAttachments).values({
|
|
2060
|
+
bytes: attachment.bytes,
|
|
2061
|
+
contentType: attachment.contentType,
|
|
2062
|
+
conversationId: attachment.conversationId,
|
|
2063
|
+
createdAt: now,
|
|
2064
|
+
id: attachment.id,
|
|
2065
|
+
sha256: attachment.sha256,
|
|
2066
|
+
storageKey: attachment.storageKey,
|
|
2067
|
+
storageProvider: args.storage.provider,
|
|
2068
|
+
title: attachment.filename
|
|
2069
|
+
}).onConflictDoNothing({ target: juniorAttachments.id }).returning({ id: juniorAttachments.id })).length > 0 && await isConversationPurged(args.db, attachment.conversationId)) await rejectPurgedAttachmentWrite({
|
|
2070
|
+
conversationId: attachment.conversationId,
|
|
2071
|
+
db: args.db,
|
|
2072
|
+
id: attachment.id,
|
|
2073
|
+
now,
|
|
2074
|
+
storage: args.storage,
|
|
2075
|
+
storageKey: attachment.storageKey
|
|
2076
|
+
});
|
|
2077
|
+
}
|
|
2078
|
+
/**
|
|
2079
|
+
* Store a file that Junior recorded without its bytes, on its first read.
|
|
2080
|
+
*
|
|
2081
|
+
* The bytes stream from the source to a fresh key. The row then takes that
|
|
2082
|
+
* key only while it is still unstored, live, and in a conversation that is
|
|
2083
|
+
* not purged. Purge marks rows in the transaction that purges the
|
|
2084
|
+
* conversation, so this update cannot revive a purged row. When the update
|
|
2085
|
+
* misses, the new object is deleted: return the row that another writer
|
|
2086
|
+
* stored, or null when the row is no longer live.
|
|
2087
|
+
*/
|
|
2088
|
+
async function storeDeferredAttachment(args) {
|
|
2089
|
+
const { attachment, storage } = args;
|
|
2090
|
+
const storageKey = attachmentKey({
|
|
2091
|
+
attachmentId: attachment.id,
|
|
2092
|
+
conversationId: attachment.conversationId,
|
|
2093
|
+
filename: attachment.filename,
|
|
2094
|
+
writeId: randomUUID()
|
|
2095
|
+
});
|
|
2096
|
+
const written = await writeAttachmentObject({
|
|
2097
|
+
file: {
|
|
2098
|
+
bytes: args.file.bytes,
|
|
2099
|
+
filename: attachment.filename,
|
|
2100
|
+
mimeType: attachment.contentType,
|
|
2101
|
+
open: args.file.open,
|
|
2102
|
+
source: attachment.source
|
|
2103
|
+
},
|
|
2104
|
+
key: storageKey,
|
|
2105
|
+
storage
|
|
2106
|
+
});
|
|
2107
|
+
const db = args.db.db();
|
|
2108
|
+
if ((await db.with(conversationDetailTouch(db, [attachment.conversationId])).update(juniorAttachments).set({
|
|
2109
|
+
...written,
|
|
2110
|
+
storageKey
|
|
2111
|
+
}).where(and(eq(juniorAttachments.id, attachment.id), eq(juniorAttachments.conversationId, attachment.conversationId), eq(juniorAttachments.storageProvider, storage.provider), isNull(juniorAttachments.storageKey), isNull(juniorAttachments.deleteRequestedAt), notExists(db.select({ id: juniorConversations.conversationId }).from(juniorConversations).where(and(eq(juniorConversations.conversationId, attachment.conversationId), isNotNull(juniorConversations.transcriptPurgedAt)))))).returning({ id: juniorAttachments.id })).length > 0) return {
|
|
2112
|
+
...attachment,
|
|
2113
|
+
bytes: written.bytes,
|
|
2114
|
+
storageKey
|
|
2115
|
+
};
|
|
2116
|
+
await bestEffortDelete(storage, storageKey);
|
|
2117
|
+
const current = await readLiveAttachment({
|
|
2118
|
+
attachmentId: attachment.id,
|
|
2119
|
+
conversationId: attachment.conversationId,
|
|
2120
|
+
db: args.db
|
|
2121
|
+
});
|
|
2122
|
+
return current?.storageKey ? {
|
|
2123
|
+
...current,
|
|
2124
|
+
storageKey: current.storageKey
|
|
2125
|
+
} : null;
|
|
2126
|
+
}
|
|
2127
|
+
/** Load one live attachment owned by a conversation. */
|
|
2128
|
+
async function readLiveAttachment(args) {
|
|
2129
|
+
const [row] = await args.db.db().select({
|
|
2130
|
+
bytes: juniorAttachments.bytes,
|
|
2131
|
+
contentType: juniorAttachments.contentType,
|
|
2132
|
+
conversationId: juniorAttachments.conversationId,
|
|
2133
|
+
deleteRequestedAt: juniorAttachments.deleteRequestedAt,
|
|
2134
|
+
id: juniorAttachments.id,
|
|
2135
|
+
provider: juniorAttachments.provider,
|
|
2136
|
+
providerId: juniorAttachments.providerId,
|
|
2137
|
+
storageProvider: juniorAttachments.storageProvider,
|
|
2138
|
+
storageKey: juniorAttachments.storageKey,
|
|
2139
|
+
title: juniorAttachments.title
|
|
2140
|
+
}).from(juniorAttachments).where(and(eq(juniorAttachments.id, args.attachmentId), isFileAttachment, eq(juniorAttachments.conversationId, args.conversationId), isNull(juniorAttachments.deleteRequestedAt)));
|
|
2141
|
+
if (!row) return null;
|
|
2142
|
+
if (await isConversationPurged(args.db, args.conversationId)) return null;
|
|
2143
|
+
return {
|
|
2144
|
+
...fileFields(row),
|
|
2145
|
+
conversationId: row.conversationId,
|
|
2146
|
+
id: row.id,
|
|
2147
|
+
source: row.provider && row.providerId ? {
|
|
2148
|
+
id: row.providerId,
|
|
2149
|
+
provider: row.provider
|
|
2150
|
+
} : null,
|
|
2151
|
+
storageKey: row.storageKey
|
|
2152
|
+
};
|
|
2153
|
+
}
|
|
2154
|
+
/** Persist many conversation-owned files. */
|
|
2155
|
+
async function storeAttachments(args) {
|
|
2156
|
+
const stored = [];
|
|
2157
|
+
for (const file of args.files) stored.push(await storeAttachment({
|
|
2158
|
+
conversationId: args.conversationId,
|
|
2159
|
+
db: args.db,
|
|
2160
|
+
file: {
|
|
2161
|
+
data: file.data,
|
|
2162
|
+
filename: file.filename,
|
|
2163
|
+
mimeType: file.mimeType
|
|
2164
|
+
},
|
|
2165
|
+
...args.nowMs !== void 0 ? { nowMs: args.nowMs } : void 0,
|
|
2166
|
+
storage: args.storage
|
|
2167
|
+
}));
|
|
2168
|
+
return stored;
|
|
2169
|
+
}
|
|
2170
|
+
/** Mark attachments unavailable when their conversation content is purged. */
|
|
2171
|
+
async function requestAttachmentDeletion(db, conversationIds, nowMs) {
|
|
2172
|
+
if (conversationIds.length === 0) return;
|
|
2173
|
+
await db.db().with(conversationDetailTouch(db.db(), conversationIds)).update(juniorAttachments).set({ deleteRequestedAt: new Date(nowMs) }).where(and(inArray(juniorAttachments.conversationId, conversationIds), isNull(juniorAttachments.deleteRequestedAt)));
|
|
2174
|
+
}
|
|
2175
|
+
/**
|
|
2176
|
+
* Delete purged attachments in one bounded batch.
|
|
2177
|
+
*
|
|
2178
|
+
* Eligible files are 30 days old, explicitly purge-marked, or owned by a
|
|
2179
|
+
* conversation whose transcript is already purged. A `url` row has no bytes,
|
|
2180
|
+
* so it lives as long as its message: it is eligible only when purge-marked
|
|
2181
|
+
* or purged. Delete object keys first, then remove rows that are still
|
|
2182
|
+
* eligible so a failed blob delete remains retryable.
|
|
2183
|
+
*/
|
|
2184
|
+
async function collectAttachmentGarbage(args) {
|
|
2185
|
+
const expiresBefore = /* @__PURE__ */ new Date(args.nowMs - ATTACHMENT_RETENTION_MS);
|
|
2186
|
+
const purged = or(isNotNull(juniorAttachments.deleteRequestedAt), isNotNull(juniorConversations.transcriptPurgedAt));
|
|
2187
|
+
const eligible = or(lte(juniorAttachments.createdAt, expiresBefore), purged);
|
|
2188
|
+
const isUrl = eq(juniorAttachments.kind, "url");
|
|
2189
|
+
const rows = await args.db.db().select({
|
|
2190
|
+
id: juniorAttachments.id,
|
|
2191
|
+
storageKey: juniorAttachments.storageKey
|
|
2192
|
+
}).from(juniorAttachments).innerJoin(juniorConversations, eq(juniorAttachments.conversationId, juniorConversations.conversationId)).where(or(and(eq(juniorAttachments.storageProvider, args.storage.provider), eligible), and(isUrl, purged))).orderBy(asc(juniorAttachments.createdAt), asc(juniorAttachments.id)).limit(args.limit ?? ATTACHMENT_GC_BATCH_LIMIT);
|
|
2193
|
+
if (rows.length === 0) return { deleted: 0 };
|
|
2194
|
+
const keys = rows.flatMap((row) => row.storageKey ? [row.storageKey] : []);
|
|
2195
|
+
if (keys.length > 0) await args.storage.delete(keys);
|
|
2196
|
+
const stillEligible = await args.db.db().select({ id: juniorAttachments.id }).from(juniorAttachments).innerJoin(juniorConversations, eq(juniorAttachments.conversationId, juniorConversations.conversationId)).where(and(inArray(juniorAttachments.id, rows.map((row) => row.id)), or(and(isFileAttachment, eligible), and(isUrl, purged))));
|
|
2197
|
+
if (stillEligible.length === 0) return { deleted: 0 };
|
|
2198
|
+
const removed = await args.db.db().delete(juniorAttachments).where(inArray(juniorAttachments.id, stillEligible.map((row) => row.id))).returning({
|
|
2199
|
+
conversationId: juniorAttachments.conversationId,
|
|
2200
|
+
id: juniorAttachments.id,
|
|
2201
|
+
kind: juniorAttachments.kind
|
|
2202
|
+
});
|
|
2203
|
+
const urls = removed.filter((row) => row.kind === "url");
|
|
2204
|
+
if (urls.length > 0) await args.db.db().delete(juniorMessageAttachments).where(and(inArray(juniorMessageAttachments.conversationId, urls.map((row) => row.conversationId)), inArray(juniorMessageAttachments.attachmentId, urls.map((row) => row.id))));
|
|
2205
|
+
await touchConversationDetail(args.db.db(), removed.map((row) => row.conversationId));
|
|
2206
|
+
return { deleted: removed.length };
|
|
2207
|
+
}
|
|
1719
2208
|
// src/chat/slack/attachments.ts
|
|
1720
2209
|
/** Save the vision summary for a stored Slack attachment. */
|
|
1721
2210
|
async function recordSlackAttachment(args) {
|
|
@@ -1735,20 +2224,32 @@ async function matchSlackAttachments(args) {
|
|
|
1735
2224
|
providerId: juniorAttachments.providerId,
|
|
1736
2225
|
bytes: juniorAttachments.bytes,
|
|
1737
2226
|
contentType: juniorAttachments.contentType,
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
2227
|
+
storageKey: juniorAttachments.storageKey,
|
|
2228
|
+
storageProvider: juniorAttachments.storageProvider,
|
|
2229
|
+
title: juniorAttachments.title
|
|
2230
|
+
}).from(juniorAttachments).where(and(eq(juniorAttachments.conversationId, args.conversationId), eq(juniorAttachments.provider, "slack"), inArray(juniorAttachments.providerId, args.providerIds), isNull(juniorAttachments.deleteRequestedAt)))).map((row) => {
|
|
2231
|
+
const { bytes, contentType, filename } = fileFields(row);
|
|
2232
|
+
const attachment = {
|
|
2233
|
+
bytes,
|
|
2234
|
+
contentType,
|
|
2235
|
+
filename,
|
|
2236
|
+
id: row.id,
|
|
2237
|
+
providerId: row.providerId
|
|
2238
|
+
};
|
|
2239
|
+
return row.storageKey === null ? {
|
|
2240
|
+
...attachment,
|
|
2241
|
+
pending: true
|
|
2242
|
+
} : attachment;
|
|
2243
|
+
});
|
|
1744
2244
|
}
|
|
1745
2245
|
/**
|
|
1746
2246
|
* Fingerprint the live Slack attachments that `matchSlackAttachments` can
|
|
1747
|
-
* return for a Conversation. It changes when one is stored or
|
|
1748
|
-
* reader can tell that stored messages may now show other
|
|
2247
|
+
* return for a Conversation. It changes when one is recorded, stored, or
|
|
2248
|
+
* deleted, so a reader can tell that stored messages may now show other
|
|
2249
|
+
* files, or a file that is no longer pending.
|
|
1749
2250
|
*/
|
|
1750
2251
|
function slackAttachmentsVersionQuery(db, conversationId) {
|
|
1751
|
-
return db.select({ version: sql`coalesce(md5(string_agg(${juniorAttachments.id}, ',' order by ${juniorAttachments.id})), '')` }).from(juniorAttachments).where(and(eq(juniorAttachments.conversationId, conversationId), eq(juniorAttachments.provider, "slack"), isNull(juniorAttachments.deleteRequestedAt)));
|
|
2252
|
+
return db.select({ version: sql`coalesce(md5(string_agg(concat(${juniorAttachments.id}, ':', ${juniorAttachments.storageKey} is null), ',' order by ${juniorAttachments.id})), '')` }).from(juniorAttachments).where(and(eq(juniorAttachments.conversationId, conversationId), eq(juniorAttachments.provider, "slack"), isNull(juniorAttachments.deleteRequestedAt)));
|
|
1752
2253
|
}
|
|
1753
2254
|
/** Read the Slack file identity retained by the Chat SDK. */
|
|
1754
2255
|
function getSlackFileId(attachment) {
|
|
@@ -1757,13 +2258,13 @@ function getSlackFileId(attachment) {
|
|
|
1757
2258
|
return (attachment.url ?? attachment.fetchMetadata?.["url"] ?? "").match(/(?:^|[-/])(F[A-Z0-9]+)(?:[-/]|$)/)?.[1];
|
|
1758
2259
|
}
|
|
1759
2260
|
/**
|
|
1760
|
-
* Look up a Slack file that Junior recorded without storing it.
|
|
2261
|
+
* Look up a Slack file that Junior recorded without storing it yet.
|
|
1761
2262
|
*
|
|
1762
2263
|
* Uses the installation token that the caller binds: the Slack turn, or the
|
|
1763
2264
|
* dashboard route for the conversation's Slack team.
|
|
1764
2265
|
*/
|
|
1765
2266
|
const readSlackAttachmentSource = async (source) => {
|
|
1766
|
-
const unavailable = (cause) => new AttachmentSourceUnavailableError("The Slack file was deleted, or
|
|
2267
|
+
const unavailable = (cause) => new AttachmentSourceUnavailableError("The Slack file was deleted, or this app can no longer access it.", { cause });
|
|
1767
2268
|
if (source.provider !== "slack") throw unavailable();
|
|
1768
2269
|
const file = await readPrivateSlackFile(source.id);
|
|
1769
2270
|
if (!file) throw unavailable();
|
|
@@ -2894,6 +3395,7 @@ async function updateConversationBrief(context) {
|
|
|
2894
3395
|
const input = await briefInputFromSql(executor, run.conversationId, terminalSeq);
|
|
2895
3396
|
const modelId = botConfig.fastModelId;
|
|
2896
3397
|
const generation = await generateBrief({
|
|
3398
|
+
assistantName: botConfig.userName,
|
|
2897
3399
|
completeObject: (request) => completeObject({
|
|
2898
3400
|
...request,
|
|
2899
3401
|
modelId,
|
|
@@ -4326,7 +4828,7 @@ const SANDBOX_FILE_OWNER = {
|
|
|
4326
4828
|
user: SANDBOX_USER
|
|
4327
4829
|
};
|
|
4328
4830
|
// src/chat/sandbox/docker/certificates.ts
|
|
4329
|
-
const CA_COMMON_NAME = "
|
|
4831
|
+
const CA_COMMON_NAME = "Docker Sandbox Egress CA";
|
|
4330
4832
|
const CA_VALID_DAYS = 3650;
|
|
4331
4833
|
/** Clients reject long-lived leaf certificates, so keep them short. */
|
|
4332
4834
|
const LEAF_VALID_DAYS = 365;
|
|
@@ -6256,8 +6758,11 @@ const payload = z.strictObject({
|
|
|
6256
6758
|
custom_fields: z.array(customField).optional(),
|
|
6257
6759
|
display_order: z.array(z.string()).optional()
|
|
6258
6760
|
});
|
|
6259
|
-
/**
|
|
6260
|
-
|
|
6761
|
+
/**
|
|
6762
|
+
* Limit IDs to Junior's safe subset. Slack drops all message metadata when an
|
|
6763
|
+
* ID has JSON punctuation or is longer than 128 characters.
|
|
6764
|
+
*/
|
|
6765
|
+
const slackExternalRefIdSchema = z.string().min(1).max(128).regex(/^[A-Za-z0-9_-]+$/, "Unsupported Slack external reference ID");
|
|
6261
6766
|
const entity = z.strictObject({
|
|
6262
6767
|
external_ref: z.strictObject({
|
|
6263
6768
|
id: slackExternalRefIdSchema,
|
|
@@ -9136,7 +9641,7 @@ async function resolveAssignee(db, value, tenant, findMentionedUserId) {
|
|
|
9136
9641
|
if (mentionedUserId) return { userId: mentionedUserId };
|
|
9137
9642
|
if (text.includes("@")) {
|
|
9138
9643
|
const user = await findUserByEmailFromSql(db, text);
|
|
9139
|
-
if (!user) throw new ToolInputError(`No
|
|
9644
|
+
if (!user) throw new ToolInputError(`No User has the email ${text}.`);
|
|
9140
9645
|
return { userId: user.id };
|
|
9141
9646
|
}
|
|
9142
9647
|
throw new ToolInputError(`Unknown assignee ${JSON.stringify(text)}. Use ${EVERYONE_ASSIGNEE}, an email, or a mention such as <@U123>.`);
|
|
@@ -10119,7 +10624,7 @@ async function notifyReply(context) {
|
|
|
10119
10624
|
payload: {
|
|
10120
10625
|
body: notificationPreview(reply.text) || "New reply",
|
|
10121
10626
|
tag: run.conversationId,
|
|
10122
|
-
title: await readConversationTitle(db, run.conversationId) ??
|
|
10627
|
+
title: await readConversationTitle(db, run.conversationId) ?? botConfig.userName,
|
|
10123
10628
|
url
|
|
10124
10629
|
},
|
|
10125
10630
|
userId
|
|
@@ -12308,21 +12813,18 @@ const TURN_CONTEXT_TAG = "runtime-turn-context";
|
|
|
12308
12813
|
/** Turn context section that only session context includes. */
|
|
12309
12814
|
const SESSION_CONTEXT_SECTION_TAG = "runtime";
|
|
12310
12815
|
/**
|
|
12311
|
-
*
|
|
12312
|
-
*
|
|
12313
|
-
*
|
|
12314
|
-
|
|
12315
|
-
|
|
12316
|
-
/**
|
|
12317
|
-
* Turn context sections that list what the model can use now. A Turn adds
|
|
12318
|
-
* one only when it differs from the latest copy in history, and context
|
|
12319
|
-
* compaction keeps only that latest copy.
|
|
12816
|
+
* Named system prompt sections that list what the model can use now: the
|
|
12817
|
+
* skills, MCP catalogs, tool guidance, Workspaces, and the tools that a Code
|
|
12818
|
+
* Mode script can call. A Turn sends a changed section in a later system
|
|
12819
|
+
* message (`systemSectionsUpdate`). The Turn context of older Turns held
|
|
12820
|
+
* copies of them, which context compaction drops.
|
|
12320
12821
|
*/
|
|
12321
12822
|
const CAPABILITY_SECTION_TAG = {
|
|
12322
12823
|
availableSkills: "available-skills",
|
|
12323
12824
|
activeMcpCatalogs: "active-mcp-catalogs",
|
|
12324
12825
|
toolGuidance: "tool-guidance",
|
|
12325
|
-
workspaces: "workspaces"
|
|
12826
|
+
workspaces: "workspaces",
|
|
12827
|
+
scriptTools: "script-tools"
|
|
12326
12828
|
};
|
|
12327
12829
|
/**
|
|
12328
12830
|
* Turn context sections that are true only for the Turn that received them.
|
|
@@ -12401,7 +12903,9 @@ function getPiMessageRole(value) {
|
|
|
12401
12903
|
}
|
|
12402
12904
|
/** Return whether Pi can continue directly from the current history tail. */
|
|
12403
12905
|
function isContinuablePiBoundary(messages) {
|
|
12404
|
-
|
|
12906
|
+
let end = messages.length;
|
|
12907
|
+
while (end > 0 && getPiMessageRole(messages[end - 1]) === "system") end -= 1;
|
|
12908
|
+
const lastRole = getPiMessageRole(messages[end - 1]);
|
|
12405
12909
|
return lastRole === "user" || lastRole === "toolResult";
|
|
12406
12910
|
}
|
|
12407
12911
|
/** Concatenate text content parts from an assistant message. */
|
|
@@ -12439,23 +12943,6 @@ function retainRuntimeTurnContext(messages) {
|
|
|
12439
12943
|
});
|
|
12440
12944
|
}
|
|
12441
12945
|
/**
|
|
12442
|
-
* Find the latest copy of one `<runtime-turn-context>` section in history,
|
|
12443
|
-
* such as `<script-tools>`, with its tags.
|
|
12444
|
-
*/
|
|
12445
|
-
function latestTurnContextSection(messages, tag) {
|
|
12446
|
-
const section = new RegExp(`\\n<${tag}>\\n[\\s\\S]*?\\n</${tag}>`, "g");
|
|
12447
|
-
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
12448
|
-
const texts = (userMessageContent(messages[index]) ?? []).flatMap((part) => {
|
|
12449
|
-
const text = textPartValue(part);
|
|
12450
|
-
return text?.startsWith(RUNTIME_TURN_CONTEXT_START) ? [text] : [];
|
|
12451
|
-
});
|
|
12452
|
-
for (const text of texts.reverse()) {
|
|
12453
|
-
const match = [...text.matchAll(section)].at(-1);
|
|
12454
|
-
if (match) return match[0].slice(1);
|
|
12455
|
-
}
|
|
12456
|
-
}
|
|
12457
|
-
}
|
|
12458
|
-
/**
|
|
12459
12946
|
* Reduce a runtime user-turn prompt to only the current turn's instruction.
|
|
12460
12947
|
*
|
|
12461
12948
|
* Live user prompts embed prior-thread context as `<thread-context
|
|
@@ -15943,6 +16430,7 @@ function normalizeDurableMessage(message) {
|
|
|
15943
16430
|
*/
|
|
15944
16431
|
function durableMessageIdentity(message) {
|
|
15945
16432
|
const record = message;
|
|
16433
|
+
if (record.role === "system") return message;
|
|
15946
16434
|
if (record.role === "toolResult") return {
|
|
15947
16435
|
role: "toolResult",
|
|
15948
16436
|
timestamp: record.timestamp,
|
|
@@ -16055,10 +16543,11 @@ function messageTimestamp(message) {
|
|
|
16055
16543
|
* Append newly stable native history items.
|
|
16056
16544
|
*
|
|
16057
16545
|
* Checkpoints are append-only against the durable identity of the committed
|
|
16058
|
-
* prefix (role, timestamp, content; tool results also match call id
|
|
16059
|
-
* history or a true content branch is
|
|
16060
|
-
* intentionally replace active model history.
|
|
16061
|
-
*
|
|
16546
|
+
* prefix (role, timestamp, content; tool results also match call id; system
|
|
16547
|
+
* messages match in full). A shorter history or a true content branch is
|
|
16548
|
+
* rejected — only compaction may intentionally replace active model history.
|
|
16549
|
+
* In-place Pi mutations of already committed assistant envelopes
|
|
16550
|
+
* (usage/stopReason) do not block the suffix.
|
|
16062
16551
|
*/
|
|
16063
16552
|
async function commitMessages(args) {
|
|
16064
16553
|
const executor = args.executor ?? getSqlExecutor();
|
|
@@ -16380,4 +16869,4 @@ async function recordGuardianActionReviewed(args) {
|
|
|
16380
16869
|
createdAtMs: Date.now()
|
|
16381
16870
|
}]);
|
|
16382
16871
|
}
|
|
16383
|
-
export { loadTurnCheckpoint as $, SANDBOX_RUNTIME as $a, loadSnapshotsForProfile as $i, resolvePluginOAuthAccount as $n, isConversationScopedChannel as $o, reviewItemReaderForUser as $r, TurnSliceLimitExceededError as $t, latestConversationMessageSeq as A, removeReactionFromMessage as Aa, JUNIOR_THREAD_STATE_TTL_MS as Ai, isStandaloneRuntimeContextMessage as An, createPluginConversationEvents as Ao, countOpenReviewItemsForUser as Ar, setConfigDefaults as As, getConversationWorkStates as At, getAgentContextInputLimitTokens as B, WorkspaceSnapshotNotReadyError as Ba, parseDashboardPersonLink as Bi, SCRIPT_TOOLS_SECTION_TAG as Bn, loadForkHistory as Bo, takeReviewItem as Br, recordConversationRetry as Bt, settleConversationTitleWork as C, addReactionToMessage as Ca, bindEventAutomationCredentialSubject as Ci, getTerminalAssistantMessages as Cn, readConversationAccessFromSql as Co, saveNotificationSchedule as Cr, createPluginCache as Cs, countPendingConversationMessages as Ct, estimateConversationMessagesTokens as D, openSlackModal as Da, verifyScheduledAutomationCredentialSubject as Di, instructionTextForProjection as Dn, conversationPinnedForUser as Do, createPluginReviewItems as Dr, piMessageFromHistoryItem as Ds, dropPendingMessages as Dt, buildConversationContext as E, openSlackDirectMessage as Ea, verifyEventAutomationCredentialSubject as Ei, hasTurnInput as En, conversationIsNotUnsubscribedRoot as Eo, projectConversationMessages as Er, historyItemFromPiMessage as Es, drainConversationMailbox as Et, turnHasReply as F, slackExternalRefIdSchema as Fa, getDashboardReviewItemLink as Fi, retainRuntimeTurnContext as Fn, readConversationEventPageAround as Fo, insertReviewItem as Fr, listActiveConversationIds as Ft, AuthPausePersistenceError as G, consumeSandboxEgressAuthRequiredSignal as Ga, deleteWorkspace as Gi, readParentAgentTask as Gn, readSlackAttachmentSource as Go, canReadReviewItem as Gr, startConversationWork as Gt, PluginCredentialFailureError as H, isWorkspaceSnapshotNotReadyError as Ha, createPluginState as Hi, TURN_CONTEXT_TAG as Hn, getSlackFileId as Ho, PLUGIN_REVIEW_ITEM_KEY_PREFIX as Hr, releaseInboundMessage as Ht, upsertConversationMessage as I, isAbortError as Ia, getDashboardSettingsLink as Ii, stripRuntimeTurnContext as In, readConversationLastEventSeq as Io, listReplyActionItems as Ir, markConversationWorkEnqueued as It, abandonReplacedPendingAuth as J, parseSandboxEgressCredentialToken as Ja, listWorkspaces as Ji, renderUntrustedTag as Jn, SlackActionError as Jo, itemNeedsUser as Jr, takeDeferredConversationMove as Jt, AuthorizationFlowDisabledError as K, consumeSandboxEgressPermissionDeniedSignal as Ka, getWorkspace as Ki, renderChildTag as Kn, recordSlackAttachment as Ko, canUserReadReviewItem as Kr, steerWebPendingMessages as Kt, calculateContextCompactionTargetTokens as L, isAlreadyExistsError as La, getDashboardTaskLink as Li, trimTrailingAssistantMessages as Ln, readConversationMessageEventSeq as Lo, listWaitingConversations as Lr, moveIdleConversationDestination as Lt, normalizeConversationText as M, updateSlackMessage as Ma, getDashboardLinkFilter as Mi, isToolResultMessage as Mn, readLatestConversationBrief as Mo, dismissOpenReviewItems as Mr, hasRunnableConversationWork as Mt, recordDeliveredAssistantMessage as N, uploadFilesToConversation as Na, getDashboardObjectIconLink as Ni, latestTurnContextSection as Nn, readConversationEventPage as No, getOpenReviewItemByDedupeKey as Nr, isFinalAttempt as Nt, getConversationMessageSlackTs as O, postSlackEphemeralMessage as Oa, verifySlackDirectCredentialSubject as Oi, isAssistantMessage as On, conversationViewerMarks as Oo, REVIEW_ITEM_REPLIED_REASON as Or, projectConversationEvents$1 as Os, getConversation as Ot, trimConversationMessages as P, slackEntitySchema as Pa, getDashboardPersonLink as Pi, normalizeToolNameFromResult as Pn, readConversationEventPageAfter as Po, getReviewItem as Pr, isInvalidConversationRecordError as Pt, continuableMessages as Q, normalizeSandboxEgressTracePropagationDomains as Qa, invalidateReadySnapshot as Qi, getOAuthAccountProviders as Qn, getSlackClient as Qo, reviewItemNeedsSomeone as Qr, TurnBudgetExceededError as Qt, getAgentBackgroundCompactionMarkTokens as R, throwSandboxOperationError as Ra, isDashboardLink as Ri, CAPABILITY_SECTION_TAG as Rn, buildSentryConversationUrl as Ro, reviewItemsNeedingUserVersionQuery as Rr, pruneActiveConversation as Rt, resolveConversationTitle as S, truncateStatusText as Sa, takeDueTimerWatches as Si, getPiMessageRole as Sn, createConversationAccessReader as So, readNotificationSchedule as Sr, credentialAuditSource as Ss, completeConversationWork as St, resolveTaskTitle as T, getSlackMessagePermalink as Ta, bindSlackDirectCredentialSubject as Ti, hasRuntimeTurnContext as Tn, conversationIsMemberRoot as To, isPausedBySlack as Tr, configValueSchema as Ts, deferConversationMove as Tt, createPluginAuthOrchestration as U, workspaceSnapshotNotReadyUserMessage as Ua, renderToolResultNudge as Ui, escapeClosingTags as Un, matchSlackAttachments as Uo, canActOnReviewItem as Ur, requestAnotherSlice as Ut, createPluginEgress as V, getWorkspaceSnapshotNotReadyError as Va, setDashboardConversationLinkOptions as Vi, SESSION_CONTEXT_SECTION_TAG as Vn, notInheritedByForkChild as Vo, updateReviewItemContent as Vr, releaseConversationWork as Vt, authorizationId as W, clearSandboxEgressSignals as Wa, createWorkspace as Wi, escapeTagText as Wn, readAttachmentVisionSummary as Wo, canAgentChangeReviewItem as Wr, requestConversationWork as Wt, clearPendingAuth as X, buildSandboxEgressNetworkPolicy as Xa, updateWorkspace as Xi, SANDBOX_EGRESS_AUTH_REQUIRED_MARKER as Xn, getFilePermalink as Xo, requireReviewItemAssignees as Xr, GATED_TURN_LIMIT_WRAP_UP_MESSAGE as Xt, canReusePendingAuthLink as Y, sandboxEgressSignalsResponseSchema as Ya, listWorkspacesByRepository as Yi, tagJson as Yn, downloadPrivateSlackFile as Yo, readReviewItemAgentScope as Yr, readInboundMessageSender as Yt, getConversationPendingAuth as Z, resolveSandboxCommandEnvironment as Za, WorkspaceValidationError as Zi, createUserTokenStore as Zn, getHeaderString as Zo, requireReviewItemLinks as Zr, TURN_LIMIT_WRAP_UP_MESSAGE as Zt, appendConversationMessages as _, normalizeSlackReplyMarkdown as _a, createWatch as _i, CODE_MODE_CALL_STATUS_TEXT as _n, runNonInteractiveCommand as _o, readWebPushConfig as _r, defaultTimezone as _s, checkInConversationWork as _t, loadProjection as a, ensureDockerDaemon as aa, resolveAssignees as ai, isAnswerToolName as an, createPluginEmbedder as ao, getPluginRoutes as ar, withSlackRetries as as, failTurnRecord as at, persistConversationMessages as b, slackMentionedUserIds as ba, getWatch as bi, persistWithRetry as bn, canAccessConversation as bo, deletePushSubscription as br, lookupSlackUserNames as bs, clearExpiredConversationLease as bt, recordAgentsInstructionsUpdated as c, proxyVercelSandboxEgressRequest as ca, getSlackToolContext as ci, replyTextSchema as cn, SANDBOX_DATA_ROOT as co, getPluginTools as cr, runWithWorkspaceTeamId as cs, listTurnSummaries as ct, recordAuthorizationCompleted as d, parseOAuthStatePayload as da, RESOURCE_WATCH_TOOL_SOURCE as di, sanitizeAssistantText as dn, SANDBOX_WORKSPACE_ROOT as do, getStaticPluginToolDefinitions as dr, searchConversations as ds, CONVERSATION_WORK_STALE_ENQUEUE_MS as dt, setWorkspaceSnapshot as ea, reviewItemReaderForUserInConversation as ei, TurnToolCallLimitExceededError as en, tryWorkspaceRepoCheckoutPath as eo, agent_hooks_exports as er, isDmChannel as es, lostWorkerBeforeFirstSave as et, recordAuthorizationRequested as f, resolveBaseUrl as fa, STOP_WATCHING_TOOL_NAME as fi, NO_REPLY_TOOL_NAME as fn, sandboxSkillDir as fo, setPlugins as fr, createConversationEmbedder as fs, ackMessages as ft, recordToolExecutionStarted as g, formatSlackLink as ga, createTimerWatch as gi, CODEMODE_TOOL_NAME as gn, buildNonInteractiveShellScript as go, setBriefsConfig as gr, listConversationAnnotationsById as gs, cancelHumanFacingPendingMessages as gt, recordSubscribedReplyRoute as h, escapeSlackMrkdwnText as ha, collectEventMatchKeys as hi, readNoReply as hn, buildCommandScript as ho, registration_exports as hr, listConversationAnnotations as hs, beginConversationResume as ht, loadConversationProjection as i, isStale as ia, resolveAssignee as ii, REPLY_TOOL_NAME as in, PluginToolDeniedError as io, getPluginApiRoutes as ir, streamPrivateSlackFile as is, completeTurnRecord as it, markConversationMessage as j, unfurlSlackLinks as ja, getDashboardConversationLink as ji, isToolResultError as jn, readConversationBriefThrough as jo, countReviewItemsNeedingUserBySubject as jr, hasConversationStop as jt, isHumanConversationMessage as k, postSlackMessage as ka, verifyTimerWatchCredentialSubject as ki, isContinuablePiBoundary as kn, viewerMarksFromParticipant as ko, closeReviewItem as kr, getConfigDefaults as ks, getConversationWorkState as kt, recordAttachmentsDelivered as l, deliverOAuthAuthorization as la, RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS as li, decideReply as ln, SANDBOX_REPOS_ROOT as lo, getPluginUserPromptContributions as lr, AttachmentSourceUnavailableError as ls, recordTurnSummary as lt, recordMcpProviderConnected as m, SLACK_USER_MENTION_RE as ma, cancelWatch as mi, isLegacyNoReplyMarker as mn, sandboxSkillPathResolution as mo, coreTaskRegistrations as mr, createPluginAnnotations as ms, appendInboundMessage as mt, commitMessages as n, create as na, activeParticipantUserIds as ni, createTurnLimitGate as nn, ToolInputError as no, createPluginEventPublisher as nr, normalizeSlackConversationId as ns, saveTurnCheckpoint as nt, loadTurnProjection as o, getSandboxProvider as oa, createCodeChangePublisher as oi, readTurnAnswer as on, createPluginModel as oo, getPluginSlackConversationLink as or, sleep$2 as os, getStoredTurnFields as ot, recordGuardianActionReviewed as p, startOAuthFlow as pa, cancelSubscriptions as pi, findLegacyNoReplyMarker as pn, sandboxSkillFile as po, validatePlugins as pr, saveObjectAnnotations as ps, appendExclusiveInboundMessage as pt, AuthorizationPauseError as q, createSandboxEgressCredentialToken as qa, getWorkspaceByName as qi, renderTag as qn, slackAttachmentsVersionQuery as qo, isOnlyAssignee as qr, stopConversationWork as qt, loadConnectedMcpProviders as r, hash as ra, automationCreatorUserId as ri, isTurnExecutionLimitExceededError as rn, isToolInputError as ro, createPluginHookRunner as rr, runWithSlackInstallationToken as rs, abandonTurnRecord as rt, openConversationProjection as s, isVercelSandboxEgressRequest as sa, resolveChannelCapabilities as si, remindMissingAnswer as sn, SANDBOX_COMMAND_PATH as so, getPluginSystemPromptContributions as sr, getWorkspaceTeamId as ss, getTurnRecord as st, commitAcceptedReply as t, setWorkspaceSnapshotBuild as ta, EVERYONE_ASSIGNEE as ti, buildTurnErrorResponse as tn, workspaceRepoCheckoutPath as to, applyPluginFormatMarkdown as tr, isSlackRequestTimeout as ts, pauseLostWorkerTurn as tt, recordAuthenticationLinked as u, formatProviderLabel as ua, RESOURCE_SUBSCRIPTION_MAX_TTL_MS as ui, getAssistantReplyText as un, SANDBOX_SKILLS_ROOT as uo, getPlugins as ur, resolveRootVisibility as us, CONVERSATION_WORK_CHECK_IN_INTERVAL_MS as ut, hydrateConversationMessages as v, normalizeSlackStatusText as va, deliverWatch as vi, REPORT_BLOCKED_TOOL_NAME as vn, createPluginModelCostRecorder as vo, sendPushNotificationToUser as vr, resolveUserTimezone as vs, claimInboundMessage as vt, fallbackShortTitle as w, deleteSlackMessage as wa, bindScheduledAutomationCredentialSubject as wi, getUserMessageInstructionText as wn, conversationHasParticipantUser as wo, savePushSubscription as wr, createDurableLocationConfigurationService as ws, deadLetterAttempt as wt, toStoredConversationMessage as x, wrapBareSlackUserIds as xa, listWatches as xi, extractAssistantText as xn, canAddConversationMessages as xo, listPushSubscriptions as xr, credentialAuditAttributes as xs, completeConversationStop as xt, persistConversationMessageWindow as y, slackMention as ya, findMatchingWatches as yi, readBlockedReport as yn, createPluginLogger as yo, resolveNotificationTimezone as yr, lookupSlackUser as ys, clearConsumedConversationWake as yt, getAgentContextCompactionTriggerTokens as z, wrapSandboxSetupError as za, parseDashboardConversationLink as zi, REQUEST_CONTEXT_SECTION_TAG as zn, FORK_INSTRUCTIONS as zo, searchReviewItems as zr, recordAttemptFailure as zt };
|
|
16872
|
+
export { loadTurnCheckpoint as $, workspaceRepoCheckoutPath as $a, setWorkspaceSnapshotBuild as $i, applyPluginFormatMarkdown as $n, storeDeferredAttachment as $o, EVERYONE_ASSIGNEE as $r, TurnSliceLimitExceededError as $t, latestConversationMessageSeq as A, updateSlackMessage as Aa, getDashboardLinkFilter as Ai, isStandaloneRuntimeContextMessage as An, readLatestConversationBrief as Ao, dismissOpenReviewItems as Ar, createDurableLocationConfigurationService as As, getConversationWorkStates as At, getAgentContextInputLimitTokens as B, isWorkspaceSnapshotNotReadyError as Ba, createPluginState as Bi, TURN_CONTEXT_TAG as Bn, getSlackFileId as Bo, PLUGIN_REVIEW_ITEM_KEY_PREFIX as Br, recordConversationRetry as Bt, settleConversationTitleWork as C, getSlackMessagePermalink as Ca, bindSlackDirectCredentialSubject as Ci, getTerminalAssistantMessages as Cn, conversationIsMemberRoot as Co, isPausedBySlack as Cr, defaultTimezone as Cs, countPendingConversationMessages as Ct, estimateConversationMessagesTokens as D, postSlackMessage as Da, verifyTimerWatchCredentialSubject as Di, instructionTextForProjection as Dn, viewerMarksFromParticipant as Do, closeReviewItem as Dr, credentialAuditAttributes as Ds, dropPendingMessages as Dt, buildConversationContext as E, postSlackEphemeralMessage as Ea, verifySlackDirectCredentialSubject as Ei, hasTurnInput as En, conversationViewerMarks as Eo, REVIEW_ITEM_REPLIED_REASON as Er, lookupSlackUserNames as Es, drainConversationMailbox as Et, turnHasReply as F, isAlreadyExistsError as Fa, getDashboardTaskLink as Fi, stripRuntimeTurnContext as Fn, readConversationMessageEventSeq as Fo, listWaitingConversations as Fr, getConfigDefaults as Fs, listActiveConversationIds as Ft, AuthPausePersistenceError as G, createSandboxEgressCredentialToken as Ga, getWorkspaceByName as Gi, renderTag as Gn, slackAttachmentsVersionQuery as Go, isOnlyAssignee as Gr, startConversationWork as Gt, PluginCredentialFailureError as H, clearSandboxEgressSignals as Ha, createWorkspace as Hi, escapeTagText as Hn, readAttachmentVisionSummary as Ho, canAgentChangeReviewItem as Hr, releaseInboundMessage as Ht, upsertConversationMessage as I, throwSandboxOperationError as Ia, isDashboardLink as Ii, trimTrailingAssistantMessages as In, buildSentryConversationUrl as Io, reviewItemsNeedingUserVersionQuery as Ir, setConfigDefaults as Is, markConversationWorkEnqueued as It, abandonReplacedPendingAuth as J, buildSandboxEgressNetworkPolicy as Ja, updateWorkspace as Ji, SANDBOX_EGRESS_AUTH_REQUIRED_MARKER as Jn, readLiveAttachment as Jo, requireReviewItemAssignees as Jr, takeDeferredConversationMove as Jt, AuthorizationFlowDisabledError as K, parseSandboxEgressCredentialToken as Ka, listWorkspaces as Ki, renderUntrustedTag as Kn, collectAttachmentGarbage as Ko, itemNeedsUser as Kr, steerWebPendingMessages as Kt, calculateContextCompactionTargetTokens as L, wrapSandboxSetupError as La, parseDashboardConversationLink as Li, CAPABILITY_SECTION_TAG as Ln, FORK_INSTRUCTIONS as Lo, searchReviewItems as Lr, moveIdleConversationDestination as Lt, normalizeConversationText as M, slackEntitySchema as Ma, getDashboardPersonLink as Mi, isToolResultMessage as Mn, readConversationEventPageAfter as Mo, getReviewItem as Mr, historyItemFromPiMessage as Ms, hasRunnableConversationWork as Mt, recordDeliveredAssistantMessage as N, slackExternalRefIdSchema as Na, getDashboardReviewItemLink as Ni, normalizeToolNameFromResult as Nn, readConversationEventPageAround as No, insertReviewItem as Nr, piMessageFromHistoryItem as Ns, isFinalAttempt as Nt, getConversationMessageSlackTs as O, removeReactionFromMessage as Oa, JUNIOR_THREAD_STATE_TTL_MS as Oi, isAssistantMessage as On, createPluginConversationEvents as Oo, countOpenReviewItemsForUser as Or, credentialAuditSource as Os, getConversation as Ot, trimConversationMessages as P, isAbortError as Pa, getDashboardSettingsLink as Pi, retainRuntimeTurnContext as Pn, readConversationLastEventSeq as Po, listReplyActionItems as Pr, projectConversationEvents$1 as Ps, isInvalidConversationRecordError as Pt, continuableMessages as Q, tryWorkspaceRepoCheckoutPath as Qa, setWorkspaceSnapshot as Qi, agent_hooks_exports as Qn, storeAttachments as Qo, reviewItemReaderForUserInConversation as Qr, TurnBudgetExceededError as Qt, getAgentBackgroundCompactionMarkTokens as R, WorkspaceSnapshotNotReadyError as Ra, parseDashboardPersonLink as Ri, REQUEST_CONTEXT_SECTION_TAG as Rn, loadForkHistory as Ro, takeReviewItem as Rr, pruneActiveConversation as Rt, resolveConversationTitle as S, deleteSlackMessage as Sa, bindScheduledAutomationCredentialSubject as Si, getPiMessageRole as Sn, conversationHasParticipantUser as So, savePushSubscription as Sr, listConversationAnnotationsById as Ss, completeConversationWork as St, resolveTaskTitle as T, openSlackModal as Ta, verifyScheduledAutomationCredentialSubject as Ti, hasRuntimeTurnContext as Tn, conversationPinnedForUser as To, createPluginReviewItems as Tr, lookupSlackUser as Ts, deferConversationMove as Tt, createPluginAuthOrchestration as U, consumeSandboxEgressAuthRequiredSignal as Ua, deleteWorkspace as Ui, readParentAgentTask as Un, readSlackAttachmentSource as Uo, canReadReviewItem as Ur, requestAnotherSlice as Ut, createPluginEgress as V, workspaceSnapshotNotReadyUserMessage as Va, renderToolResultNudge as Vi, escapeClosingTags as Vn, matchSlackAttachments as Vo, canActOnReviewItem as Vr, releaseConversationWork as Vt, authorizationId as W, consumeSandboxEgressPermissionDeniedSignal as Wa, getWorkspace as Wi, renderChildTag as Wn, recordSlackAttachment as Wo, canUserReadReviewItem as Wr, requestConversationWork as Wt, clearPendingAuth as X, normalizeSandboxEgressTracePropagationDomains as Xa, invalidateReadySnapshot as Xi, getOAuthAccountProviders as Xn, requestAttachmentDeletion as Xo, reviewItemNeedsSomeone as Xr, GATED_TURN_LIMIT_WRAP_UP_MESSAGE as Xt, canReusePendingAuthLink as Y, resolveSandboxCommandEnvironment as Ya, WorkspaceValidationError as Yi, createUserTokenStore as Yn, recordUploadedAttachment as Yo, requireReviewItemLinks as Yr, readInboundMessageSender as Yt, getConversationPendingAuth as Z, SANDBOX_RUNTIME as Za, loadSnapshotsForProfile as Zi, resolvePluginOAuthAccount as Zn, storeAttachment as Zo, reviewItemReaderForUser as Zr, TURN_LIMIT_WRAP_UP_MESSAGE as Zt, appendConversationMessages as _, slackMention as _a, findMatchingWatches as _i, CODE_MODE_CALL_STATUS_TEXT as _n, createPluginLogger as _o, resolveNotificationTimezone as _r, searchConversations as _s, checkInConversationWork as _t, loadProjection as a, isVercelSandboxEgressRequest as aa, resolveChannelCapabilities as ai, isAnswerToolName as an, SANDBOX_COMMAND_PATH as ao, getPluginSystemPromptContributions as ar, isConversationScopedChannel as as, failTurnRecord as at, persistConversationMessages as b, truncateStatusText as ba, takeDueTimerWatches as bi, persistWithRetry as bn, createConversationAccessReader as bo, readNotificationSchedule as br, createPluginAnnotations as bs, clearExpiredConversationLease as bt, recordAgentsInstructionsUpdated as c, formatProviderLabel as ca, RESOURCE_SUBSCRIPTION_MAX_TTL_MS as ci, replyTextSchema as cn, SANDBOX_SKILLS_ROOT as co, getPlugins as cr, normalizeSlackConversationId as cs, listTurnSummaries as ct, recordAuthorizationCompleted as d, startOAuthFlow as da, cancelSubscriptions as di, sanitizeAssistantText as dn, sandboxSkillFile as do, validatePlugins as dr, withSlackRetries as ds, CONVERSATION_WORK_STALE_ENQUEUE_MS as dt, create as ea, activeParticipantUserIds as ei, TurnToolCallLimitExceededError as en, ToolInputError as eo, createPluginEventPublisher as er, SlackActionError as es, lostWorkerBeforeFirstSave as et, recordAuthorizationRequested as f, SLACK_USER_MENTION_RE as fa, cancelWatch as fi, NO_REPLY_TOOL_NAME as fn, sandboxSkillPathResolution as fo, coreTaskRegistrations as fr, sleep$2 as fs, ackMessages as ft, recordToolExecutionStarted as g, normalizeSlackStatusText as ga, deliverWatch as gi, CODEMODE_TOOL_NAME as gn, createPluginModelCostRecorder as go, sendPushNotificationToUser as gr, resolveRootVisibility as gs, cancelHumanFacingPendingMessages as gt, recordSubscribedReplyRoute as h, normalizeSlackReplyMarkdown as ha, createWatch as hi, readNoReply as hn, runNonInteractiveCommand as ho, readWebPushConfig as hr, AttachmentSourceUnavailableError as hs, beginConversationResume as ht, loadConversationProjection as i, getSandboxProvider as ia, createCodeChangePublisher as ii, REPLY_TOOL_NAME as in, createPluginModel as io, getPluginSlackConversationLink as ir, getSlackClient as is, completeTurnRecord as it, markConversationMessage as j, uploadFilesToConversation as ja, getDashboardObjectIconLink as ji, isToolResultError as jn, readConversationEventPage as jo, getOpenReviewItemByDedupeKey as jr, configValueSchema as js, hasConversationStop as jt, isHumanConversationMessage as k, unfurlSlackLinks as ka, getDashboardConversationLink as ki, isContinuablePiBoundary as kn, readConversationBriefThrough as ko, countReviewItemsNeedingUserBySubject as kr, createPluginCache as ks, getConversationWorkState as kt, recordAttachmentsDelivered as l, parseOAuthStatePayload as la, RESOURCE_WATCH_TOOL_SOURCE as li, decideReply as ln, SANDBOX_WORKSPACE_ROOT as lo, getStaticPluginToolDefinitions as lr, runWithSlackInstallationToken as ls, recordTurnSummary as lt, recordMcpProviderConnected as m, formatSlackLink as ma, createTimerWatch as mi, isLegacyNoReplyMarker as mn, buildNonInteractiveShellScript as mo, setBriefsConfig as mr, runWithWorkspaceTeamId as ms, appendInboundMessage as mt, commitMessages as n, isStale as na, resolveAssignee as ni, createTurnLimitGate as nn, PluginToolDeniedError as no, getPluginApiRoutes as nr, getFilePermalink as ns, saveTurnCheckpoint as nt, loadTurnProjection as o, proxyVercelSandboxEgressRequest as oa, getSlackToolContext as oi, readTurnAnswer as on, SANDBOX_DATA_ROOT as oo, getPluginTools as or, isDmChannel as os, getStoredTurnFields as ot, recordGuardianActionReviewed as p, escapeSlackMrkdwnText as pa, collectEventMatchKeys as pi, findLegacyNoReplyMarker as pn, buildCommandScript as po, registration_exports as pr, getWorkspaceTeamId as ps, appendExclusiveInboundMessage as pt, AuthorizationPauseError as q, sandboxEgressSignalsResponseSchema as qa, listWorkspacesByRepository as qi, tagJson as qn, isFileAttachment as qo, readReviewItemAgentScope as qr, stopConversationWork as qt, loadConnectedMcpProviders as r, ensureDockerDaemon as ra, resolveAssignees as ri, isTurnExecutionLimitExceededError as rn, createPluginEmbedder as ro, getPluginRoutes as rr, getHeaderString as rs, abandonTurnRecord as rt, openConversationProjection as s, deliverOAuthAuthorization as sa, RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS as si, remindMissingAnswer as sn, SANDBOX_REPOS_ROOT as so, getPluginUserPromptContributions as sr, isSlackRequestTimeout as ss, getTurnRecord as st, commitAcceptedReply as t, hash as ta, automationCreatorUserId as ti, buildTurnErrorResponse as tn, isToolInputError as to, createPluginHookRunner as tr, downloadPrivateSlackFile as ts, pauseLostWorkerTurn as tt, recordAuthenticationLinked as u, resolveBaseUrl as ua, STOP_WATCHING_TOOL_NAME as ui, getAssistantReplyText as un, sandboxSkillDir as uo, setPlugins as ur, streamPrivateSlackFile as us, CONVERSATION_WORK_CHECK_IN_INTERVAL_MS as ut, hydrateConversationMessages as v, slackMentionedUserIds as va, getWatch as vi, REPORT_BLOCKED_TOOL_NAME as vn, canAccessConversation as vo, deletePushSubscription as vr, createConversationEmbedder as vs, claimInboundMessage as vt, fallbackShortTitle as w, openSlackDirectMessage as wa, verifyEventAutomationCredentialSubject as wi, getUserMessageInstructionText as wn, conversationIsNotUnsubscribedRoot as wo, projectConversationMessages as wr, resolveUserTimezone as ws, deadLetterAttempt as wt, toStoredConversationMessage as x, addReactionToMessage as xa, bindEventAutomationCredentialSubject as xi, extractAssistantText as xn, readConversationAccessFromSql as xo, saveNotificationSchedule as xr, listConversationAnnotations as xs, completeConversationStop as xt, persistConversationMessageWindow as y, wrapBareSlackUserIds as ya, listWatches as yi, readBlockedReport as yn, canAddConversationMessages as yo, listPushSubscriptions as yr, saveObjectAnnotations as ys, clearConsumedConversationWake as yt, getAgentContextCompactionTriggerTokens as z, getWorkspaceSnapshotNotReadyError as za, setDashboardConversationLinkOptions as zi, SESSION_CONTEXT_SECTION_TAG as zn, notInheritedByForkChild as zo, updateReviewItemContent as zr, recordAttemptFailure as zt };
|