@sentry/junior 0.291.0 → 0.292.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/{adapter-zphAlWE2.js → adapter-Cigb1MTr.js} +1 -1
  2. package/dist/{admin-B3WR7Y6e.js → admin-BO9V7vnn.js} +2 -2
  3. package/dist/{agent-runner-ke-hOiuv.js → agent-runner-BuH7EHrX.js} +33 -26
  4. package/dist/api.js +23 -23
  5. package/dist/app.js +26 -26
  6. package/dist/{assistant-reply-BV8SZaVd.js → assistant-reply-ZjLRGHm2.js} +1 -1
  7. package/dist/{background-compaction-queue-QDH_JS3D.js → background-compaction-queue-CqZBPe9g.js} +4 -4
  8. package/dist/{briefs-Bdv9BG5J.js → briefs-DZrhXJss.js} +2 -2
  9. package/dist/{catalog-runtime-yGnL9ywD.js → catalog-runtime-Cj9I0dco.js} +1 -1
  10. package/dist/cli/chat.js +14 -14
  11. package/dist/cli/check.js +3 -3
  12. package/dist/cli/main.js +3 -3
  13. package/dist/cli/plugins.js +4 -4
  14. package/dist/cli/snapshot-create.js +4 -4
  15. package/dist/cli/upgrade.js +4 -3
  16. package/dist/{config-UsaBOQgC.js → config-BerMjSVL.js} +2 -2
  17. package/dist/{connections-CePSRCoR.js → connections-BWmTOVPB.js} +6 -6
  18. package/dist/{conversation-privacy-B3wmawmz.js → conversation-privacy-BMfbOUCo.js} +1 -1
  19. package/dist/{credential-sync-LNRLXZCn.js → credential-sync-DZDij2CU.js} +13 -13
  20. package/dist/{db-c__lw9GH.js → db-BlfjuqzW.js} +3 -3
  21. package/dist/{executor-N8-D5Gvv.js → executor-ikZvFaMD.js} +22 -3
  22. package/dist/instrumentation.js +2 -2
  23. package/dist/{logging-DbXHuhac.js → logging-CTCH5jOy.js} +1 -1
  24. package/dist/{message-D1MEh8iR.js → message-C1ID1tKi.js} +9 -9
  25. package/dist/nitro.js +2 -2
  26. package/dist/{oauth-callback-server-DUtqhYwP.js → oauth-callback-server-CStBgDU7.js} +2 -2
  27. package/dist/{projection-D7XadqRY.js → projection-DY93nCfX.js} +10 -10
  28. package/dist/{prompt-CzEV4BF4.js → prompt-exicBZeb.js} +3 -3
  29. package/dist/{registry-CTtGtXZP.js → registry-X_xdFY9L.js} +1 -1
  30. package/dist/{resolve-nUuQ8yyH.js → resolve-B9dYN-nS.js} +3 -3
  31. package/dist/{result-Cr9tUdfS.js → result-CC8bV8Fl.js} +8 -8
  32. package/dist/{runner-D7NMbBim.js → runner-D44qp4rc.js} +7 -7
  33. package/dist/{sandbox-egress-signals-BJAyfzOD.js → sandbox-egress-signals-BrH6DWkt.js} +1 -1
  34. package/dist/{service-account-_ml5D4Tk.js → service-account-89JZHWCE.js} +3 -3
  35. package/dist/{service-account-CP1oBWTc.js → service-account-DoNZuJb-.js} +3 -3
  36. package/dist/{session-stop-BbsyIbK2.js → session-stop-DNucbmPf.js} +11 -11
  37. package/dist/{skills-CayJ8-Bj.js → skills-BeUfmYXL.js} +2 -2
  38. package/dist/{spawn-CktAopv_.js → spawn-CIAcfcvZ.js} +5 -5
  39. package/dist/{stop-BUzUJuN_.js → stop-Ckd3735h.js} +24 -24
  40. package/dist/{store-lotbeXq3.js → store-CS0xoqXW.js} +3 -3
  41. package/dist/{task-runner-BinM1l5g.js → task-runner-DjjHCX_m.js} +10 -10
  42. package/dist/{turn-failure-response-DH5nE6HJ.js → turn-failure-response-D0bwI462.js} +7 -7
  43. package/dist/{validation-I0CqX5NC.js → validation-Cvx_AupF.js} +1 -1
  44. package/dist/{version-C3sVz3bv.js → version-BrDx4Fzc.js} +1 -1
  45. package/dist/version.js +1 -1
  46. package/dist/{viewer-so1MPU10.js → viewer-4CxdwLLQ.js} +3 -3
  47. package/dist/{warmup-BH9HRBCI.js → warmup-B62hd4lD.js} +8 -8
  48. package/dist/{work-Cw6Fzvfz.js → work-Cu315oJl.js} +11 -11
  49. package/dist/{worker-qEykG39-.js → worker-4ClZu6ry.js} +6 -6
  50. package/migrations/0095_web_linked_slack_identity_repair.sql +252 -0
  51. package/migrations/meta/0095_snapshot.json +4452 -0
  52. package/migrations/meta/_journal.json +7 -0
  53. package/package.json +4 -4
@@ -1,15 +1,15 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { Fa as createPluginEmbedder, Gi as openSlackDirectMessage, Hn as coreTaskRegistrations, Ia as createPluginModel, Ii as escapeSlackMrkdwnText, Ja as createPluginModelCostRecorder, Ji as postSlackMessage, Li as formatSlackLink, Mo as createDurableLocationConfigurationService, Ya as createPluginLogger, an as instructionTextForProjection, b as persistConversationMessages, dn as normalizeToolNameFromResult, en as getPiMessageRole, jo as createPluginCache, li as ToolInputError, ln as isToolResultError, oi as getDashboardTaskLink, oo as createPluginConversationEvents, ot as getTurnRecord, pn as stripRuntimeTurnContext, ti as JUNIOR_THREAD_STATE_TTL_MS, ui as createPluginState, un as isToolResultMessage, v as hydrateConversationMessages, w as fallbackShortTitle, zn as getPlugins } from "./projection-D7XadqRY.js";
3
- import { n as botConfig } from "./config-UsaBOQgC.js";
4
- import { E as withSpan, G as isRecord$1, K as toOptionalNumber, _ as runBestEffort, h as logWarn, q as toOptionalString } from "./logging-DbXHuhac.js";
2
+ import { Fa as createPluginEmbedder, Gi as openSlackDirectMessage, Hn as coreTaskRegistrations, Ia as createPluginModel, Ii as escapeSlackMrkdwnText, Ja as createPluginModelCostRecorder, Ji as postSlackMessage, Li as formatSlackLink, Mo as createDurableLocationConfigurationService, Ya as createPluginLogger, an as instructionTextForProjection, b as persistConversationMessages, dn as normalizeToolNameFromResult, en as getPiMessageRole, jo as createPluginCache, li as ToolInputError, ln as isToolResultError, oi as getDashboardTaskLink, oo as createPluginConversationEvents, ot as getTurnRecord, pn as stripRuntimeTurnContext, ti as JUNIOR_THREAD_STATE_TTL_MS, ui as createPluginState, un as isToolResultMessage, v as hydrateConversationMessages, w as fallbackShortTitle, zn as getPlugins } from "./projection-DY93nCfX.js";
3
+ import { n as botConfig } from "./config-BerMjSVL.js";
4
+ import { E as withSpan, G as isRecord$1, K as toOptionalNumber, _ as runBestEffort, h as logWarn, q as toOptionalString } from "./logging-CTCH5jOy.js";
5
5
  import { h as parseSlackMessageTs } from "./actor-6jsm_v96.js";
6
- import { H as agentTurnTotalTokens, V as agentTurnCostUsd, a as getConversationStore, o as getDb } from "./db-c__lw9GH.js";
7
- import { A as juniorConversations, d as juniorAutomationVersions, f as juniorAutomations, u as juniorAutomationRuns } from "./executor-N8-D5Gvv.js";
6
+ import { H as agentTurnTotalTokens, V as agentTurnCostUsd, a as getConversationStore, o as getDb } from "./db-BlfjuqzW.js";
7
+ import { A as juniorConversations, d as juniorAutomationVersions, f as juniorAutomations, u as juniorAutomationRuns } from "./executor-ikZvFaMD.js";
8
8
  import { v as sameActorIdentity } from "./media-BepyEUNm.js";
9
- import { h as credentialSubjectSchema } from "./registry-CTtGtXZP.js";
10
- import { i as readActorIdentity } from "./viewer-so1MPU10.js";
11
- import { r as getStateAdapter } from "./adapter-zphAlWE2.js";
12
- import { c as pluginTaskParamsSchema, d as sendVercelPluginTask, s as pluginTaskId } from "./background-compaction-queue-QDH_JS3D.js";
9
+ import { h as credentialSubjectSchema } from "./registry-X_xdFY9L.js";
10
+ import { i as readActorIdentity } from "./viewer-4CxdwLLQ.js";
11
+ import { r as getStateAdapter } from "./adapter-Cigb1MTr.js";
12
+ import { c as pluginTaskParamsSchema, d as sendVercelPluginTask, s as pluginTaskId } from "./background-compaction-queue-CqZBPe9g.js";
13
13
  import { O as eventAutomationSchema, S as automationVersionSchema, j as scheduledAutomationSchema } from "./automation-CrsYnvdV.js";
14
14
  import { createHash } from "node:crypto";
15
15
  import * as z from "zod";
@@ -349,7 +349,7 @@ function slackSourceForDestination(args) {
349
349
  * Reads parent Conversations when this Conversation has no Destination.
350
350
  */
351
351
  async function resolveConversationRouting(args) {
352
- const conversationStore = args.conversationStore ?? (await import("./db-c__lw9GH.js").then((n) => n.n)).getConversationStore();
352
+ const conversationStore = args.conversationStore ?? (await import("./db-BlfjuqzW.js").then((n) => n.n)).getConversationStore();
353
353
  const chain = await loadConversationChain(args.conversationId, conversationStore);
354
354
  let destination;
355
355
  let source;
@@ -1,13 +1,13 @@
1
- import { E as buildConversationContext, To as listConversationAnnotations, X as clearPendingAuth, j as markConversationMessage, v as hydrateConversationMessages } from "./projection-D7XadqRY.js";
2
- import { H as getProviderErrorAttributes, U as getProviderErrorUserMessage, V as findProviderError, g as TURN_REASONING_LEVELS, z as ProviderError } from "./config-UsaBOQgC.js";
3
- import { G as isRecord, b as setSpanAttributes, t as buildTurnFailureResponse } from "./logging-DbXHuhac.js";
1
+ import { E as buildConversationContext, To as listConversationAnnotations, X as clearPendingAuth, j as markConversationMessage, v as hydrateConversationMessages } from "./projection-DY93nCfX.js";
2
+ import { H as getProviderErrorAttributes, U as getProviderErrorUserMessage, V as findProviderError, g as TURN_REASONING_LEVELS, z as ProviderError } from "./config-BerMjSVL.js";
3
+ import { G as isRecord, b as setSpanAttributes, t as buildTurnFailureResponse } from "./logging-CTCH5jOy.js";
4
4
  import { h as parseSlackMessageTs } from "./actor-6jsm_v96.js";
5
- import { o as getDb, r as getConversationEventStore, s as getSqlExecutor } from "./db-c__lw9GH.js";
6
- import { g as juniorAgentInvocations } from "./executor-N8-D5Gvv.js";
7
- import { p as credentialContextSchema } from "./registry-CTtGtXZP.js";
5
+ import { o as getDb, r as getConversationEventStore, s as getSqlExecutor } from "./db-BlfjuqzW.js";
6
+ import { g as juniorAgentInvocations } from "./executor-ikZvFaMD.js";
7
+ import { p as credentialContextSchema } from "./registry-X_xdFY9L.js";
8
8
  import { B as resolveMessageCards, R as readMessageCardRefs, z as removedCardSchema } from "./conversation-CtjR1Zcx.js";
9
9
  import { C as AGENT_INVOCATION_PARENT_MAILBOX_STATUSES, S as AGENT_INVOCATION_MAILBOX_STATUSES } from "./reporting-window-B3Ze-Qnt.js";
10
- import { _t as persistThreadStateById, ht as getPersistedThreadState, vt as coerceThreadConversationState } from "./task-runner-BinM1l5g.js";
10
+ import { _t as persistThreadStateById, ht as getPersistedThreadState, vt as coerceThreadConversationState } from "./task-runner-DjjHCX_m.js";
11
11
  import { createHash } from "node:crypto";
12
12
  import * as z from "zod";
13
13
  import { and, asc, desc, eq, inArray, or, sql } from "drizzle-orm";
@@ -1,5 +1,5 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { n as pluginCatalogRuntime } from "./catalog-runtime-yGnL9ywD.js";
2
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-Cj9I0dco.js";
3
3
  import { isDeepStrictEqual } from "node:util";
4
4
  // src/chat/plugins/validation.ts
5
5
  var validation_exports = /* @__PURE__ */ __exportAll({
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.291.0";
2
+ var version = "0.292.0";
3
3
  // src/version.ts
4
4
  /** Installed Junior package version, or `unknown` when package metadata is unavailable. */
5
5
  const JUNIOR_VERSION = typeof version === "string" && version.trim() ? version : "unknown";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export { t as JUNIOR_VERSION } from "./version-C3sVz3bv.js";
1
+ export { t as JUNIOR_VERSION } from "./version-BrDx4Fzc.js";
@@ -1,6 +1,6 @@
1
- import { H as GOOGLE_IDENTITY_PROVIDER, W as normalizeIdentityEmail, h as logWarn } from "./logging-DbXHuhac.js";
2
- import { E as findActorIdentityId, o as getDb } from "./db-c__lw9GH.js";
3
- import { M as juniorUsers, j as juniorIdentities } from "./executor-N8-D5Gvv.js";
1
+ import { H as GOOGLE_IDENTITY_PROVIDER, W as normalizeIdentityEmail, h as logWarn } from "./logging-CTCH5jOy.js";
2
+ import { E as findActorIdentityId, o as getDb } from "./db-BlfjuqzW.js";
3
+ import { M as juniorUsers, j as juniorIdentities } from "./executor-ikZvFaMD.js";
4
4
  import { r as detectImageMediaType } from "./media-BepyEUNm.js";
5
5
  import { a as withLock } from "./locks-D-0h111u.js";
6
6
  import { createHash, randomUUID } from "node:crypto";
@@ -1,12 +1,12 @@
1
1
  import { n as captureMessage, v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { Ya as createPluginLogger, jo as createPluginCache, zn as getPlugins } from "./projection-D7XadqRY.js";
3
- import { E as resolveGatewayModel, W as isProviderRetryError, i as getChatConfig } from "./config-UsaBOQgC.js";
4
- import { E as withSpan, h as logWarn, m as logInfo, x as setSpanStatus } from "./logging-DbXHuhac.js";
5
- import { K as rootConversationIsArchived, a as getConversationStore, o as getDb, s as getSqlExecutor } from "./db-c__lw9GH.js";
6
- import { A as juniorConversations, C as isUserInstruction, j as juniorIdentities, w as juniorConversationEvents } from "./executor-N8-D5Gvv.js";
7
- import { u as completeText } from "./prompt-CzEV4BF4.js";
8
- import { r as getStateAdapter } from "./adapter-zphAlWE2.js";
9
- import { E as sendCacheWarmup } from "./background-compaction-queue-QDH_JS3D.js";
2
+ import { Ya as createPluginLogger, jo as createPluginCache, zn as getPlugins } from "./projection-DY93nCfX.js";
3
+ import { E as resolveGatewayModel, W as isProviderRetryError, i as getChatConfig } from "./config-BerMjSVL.js";
4
+ import { E as withSpan, h as logWarn, m as logInfo, x as setSpanStatus } from "./logging-CTCH5jOy.js";
5
+ import { K as rootConversationIsArchived, a as getConversationStore, o as getDb, s as getSqlExecutor } from "./db-BlfjuqzW.js";
6
+ import { A as juniorConversations, C as isUserInstruction, j as juniorIdentities, w as juniorConversationEvents } from "./executor-ikZvFaMD.js";
7
+ import { u as completeText } from "./prompt-exicBZeb.js";
8
+ import { r as getStateAdapter } from "./adapter-Cigb1MTr.js";
9
+ import { E as sendCacheWarmup } from "./background-compaction-queue-CqZBPe9g.js";
10
10
  import { streamSimple } from "@earendil-works/pi-ai/compat";
11
11
  import { promisify } from "node:util";
12
12
  import { randomUUID } from "node:crypto";
@@ -1,15 +1,15 @@
1
- import { H as PluginCredentialFailureError, K as AuthorizationFlowDisabledError, Sn as renderTag, Xt as isTurnExecutionLimitExceededError, at as failTurnRecord, et as lostWorkerBeforeFirstSave, ho as loadForkHistory, nt as saveTurnCheckpoint, ot as getTurnRecord, rt as abandonTurnRecord, s as openConversationProjection, tn as getTerminalAssistantMessages, tt as pauseLostWorkerTurn, v as hydrateConversationMessages, vn as escapeClosingTags } from "./projection-D7XadqRY.js";
2
- import { n as botConfig } from "./config-UsaBOQgC.js";
3
- import { T as SYSTEM_IDENTITY_ID, a as getConversationStore, r as getConversationEventStore, s as getSqlExecutor } from "./db-c__lw9GH.js";
4
- import { g as juniorAgentInvocations, h as juniorAgentBindings } from "./executor-N8-D5Gvv.js";
1
+ import { H as PluginCredentialFailureError, K as AuthorizationFlowDisabledError, Sn as renderTag, Xt as isTurnExecutionLimitExceededError, at as failTurnRecord, et as lostWorkerBeforeFirstSave, ho as loadForkHistory, nt as saveTurnCheckpoint, ot as getTurnRecord, rt as abandonTurnRecord, s as openConversationProjection, tn as getTerminalAssistantMessages, tt as pauseLostWorkerTurn, v as hydrateConversationMessages, vn as escapeClosingTags } from "./projection-DY93nCfX.js";
2
+ import { n as botConfig } from "./config-BerMjSVL.js";
3
+ import { T as SYSTEM_IDENTITY_ID, a as getConversationStore, r as getConversationEventStore, s as getSqlExecutor } from "./db-BlfjuqzW.js";
4
+ import { g as juniorAgentInvocations, h as juniorAgentBindings } from "./executor-ikZvFaMD.js";
5
5
  import { h as contextProvenance, m as agentInstructionProvenance, v as sameActorIdentity } from "./media-BepyEUNm.js";
6
- import { Dt as stopChildAgentsOf, Gt as finishTurn, Mt as supersedeOpenMailboxTurns, Ot as recordSubagentEnded, Ut as AgentRunError, Wt as executeTurn, an as AgentNameInUseError, kt as recordSubagentStarted, rn as AgentMessageQueueFullError, tn as AgentInvocationLimitError } from "./agent-runner-ke-hOiuv.js";
7
- import { k as getTurnRequestDeadline } from "./background-compaction-queue-QDH_JS3D.js";
8
- import { $ as getUnnamedAgentConversationId, A as markAgentInvocationPaused, C as isTerminalAgentInvocation, H as agentTypeStartsWithParentHistory, J as getAgentInvocationMessageId, L as agentBindingSchema, M as markAgentInvocationSteered, N as reportReplacedAgentInvocation, O as markAgentInvocationMailboxAppended, Q as getNamedAgentConversationId, T as listOpenAgentInvocations, V as agentTypeInstructions, W as getAgentInvocationId, X as getAgentInvocationTurnId, Z as getChildAgentLockName, _ as completeAgentInvocation, at as getConversationTurnBoundaryError, f as ConversationTurnLifecycleService, g as NON_TERMINAL_AGENT_INVOCATION_STATUSES, h as ACTIVE_AGENT_INVOCATION_STATUSES, j as markAgentInvocationRunning, rt as TurnInputCommitLostError, st as isTurnInputCommitLostError, v as getActiveAgentInvocationForConversation, w as listAgentInvocationsForConversation, x as getLatestAgentInvocationForConversation, y as getAgentInvocation, z as createAgentInvocationSchema } from "./turn-failure-response-DH5nE6HJ.js";
9
- import { n as getAssistantReplyText } from "./assistant-reply-BV8SZaVd.js";
10
- import { $ as withoutSavedSteeringMessages, B as maybePostAutomatedTurnLimitNotice, K as recordFinishedTurnForAutomatedLimit, X as buildSteeringPiMessage, Z as instructionForInputs, ct as readBlockedReport, h as parseWebMessages, i as resumeStoppedConversationTree, p as listActiveMailboxTurns, q as resetAutomatedTurnLimit, u as getActiveConversationTurnId } from "./session-stop-BbsyIbK2.js";
11
- import { r as appendAndEnqueueInboundMessage } from "./store-lotbeXq3.js";
12
- import { _t as persistThreadStateById, ht as getPersistedThreadState, mt as getPersistedSandboxState, vt as coerceThreadConversationState } from "./task-runner-BinM1l5g.js";
6
+ import { Dt as stopChildAgentsOf, Gt as finishTurn, Mt as supersedeOpenMailboxTurns, Ot as recordSubagentEnded, Ut as AgentRunError, Wt as executeTurn, an as AgentNameInUseError, kt as recordSubagentStarted, rn as AgentMessageQueueFullError, tn as AgentInvocationLimitError } from "./agent-runner-BuH7EHrX.js";
7
+ import { k as getTurnRequestDeadline } from "./background-compaction-queue-CqZBPe9g.js";
8
+ import { $ as getUnnamedAgentConversationId, A as markAgentInvocationPaused, C as isTerminalAgentInvocation, H as agentTypeStartsWithParentHistory, J as getAgentInvocationMessageId, L as agentBindingSchema, M as markAgentInvocationSteered, N as reportReplacedAgentInvocation, O as markAgentInvocationMailboxAppended, Q as getNamedAgentConversationId, T as listOpenAgentInvocations, V as agentTypeInstructions, W as getAgentInvocationId, X as getAgentInvocationTurnId, Z as getChildAgentLockName, _ as completeAgentInvocation, at as getConversationTurnBoundaryError, f as ConversationTurnLifecycleService, g as NON_TERMINAL_AGENT_INVOCATION_STATUSES, h as ACTIVE_AGENT_INVOCATION_STATUSES, j as markAgentInvocationRunning, rt as TurnInputCommitLostError, st as isTurnInputCommitLostError, v as getActiveAgentInvocationForConversation, w as listAgentInvocationsForConversation, x as getLatestAgentInvocationForConversation, y as getAgentInvocation, z as createAgentInvocationSchema } from "./turn-failure-response-D0bwI462.js";
9
+ import { n as getAssistantReplyText } from "./assistant-reply-ZjLRGHm2.js";
10
+ import { $ as withoutSavedSteeringMessages, B as maybePostAutomatedTurnLimitNotice, K as recordFinishedTurnForAutomatedLimit, X as buildSteeringPiMessage, Z as instructionForInputs, ct as readBlockedReport, h as parseWebMessages, i as resumeStoppedConversationTree, p as listActiveMailboxTurns, q as resetAutomatedTurnLimit, u as getActiveConversationTurnId } from "./session-stop-DNucbmPf.js";
11
+ import { r as appendAndEnqueueInboundMessage } from "./store-CS0xoqXW.js";
12
+ import { _t as persistThreadStateById, ht as getPersistedThreadState, mt as getPersistedSandboxState, vt as coerceThreadConversationState } from "./task-runner-DjjHCX_m.js";
13
13
  import { isDeepStrictEqual } from "node:util";
14
14
  import * as z from "zod";
15
15
  import { and, eq } from "drizzle-orm";
@@ -1,10 +1,10 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { At as isInvalidConversationRecordError, Dt as hasConversationStop, St as countPendingConversationMessages, kt as isFinalAttempt } from "./projection-D7XadqRY.js";
3
- import { W as isProviderRetryError, i as getChatConfig } from "./config-UsaBOQgC.js";
4
- import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-DbXHuhac.js";
5
- import { Ht as selectAttemptMessages, Vt as isAttemptInterrupt } from "./agent-runner-ke-hOiuv.js";
6
- import { k as getTurnRequestDeadline, y as ConversationQueueMessageRejectedError } from "./background-compaction-queue-QDH_JS3D.js";
7
- import { C as startConversationWork, b as releaseConversationWork, c as clearConsumedConversationWake, d as completeConversationWork, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, t as ackMessages, u as completeConversationStop, v as recordAttemptFailure, x as requestAnotherSlice, y as recordConversationRetry } from "./store-lotbeXq3.js";
2
+ import { At as isInvalidConversationRecordError, Dt as hasConversationStop, St as countPendingConversationMessages, kt as isFinalAttempt } from "./projection-DY93nCfX.js";
3
+ import { W as isProviderRetryError, i as getChatConfig } from "./config-BerMjSVL.js";
4
+ import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-CTCH5jOy.js";
5
+ import { Ht as selectAttemptMessages, Vt as isAttemptInterrupt } from "./agent-runner-BuH7EHrX.js";
6
+ import { k as getTurnRequestDeadline, y as ConversationQueueMessageRejectedError } from "./background-compaction-queue-CqZBPe9g.js";
7
+ import { C as startConversationWork, b as releaseConversationWork, c as clearConsumedConversationWake, d as completeConversationWork, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, t as ackMessages, u as completeConversationStop, v as recordAttemptFailure, x as requestAnotherSlice, y as recordConversationRetry } from "./store-CS0xoqXW.js";
8
8
  // src/chat/task-execution/worker.ts
9
9
  var worker_exports = /* @__PURE__ */ __exportAll({
10
10
  CONVERSATION_WORK_DEFER_DELAY_MS: () => CONVERSATION_WORK_DEFER_DELAY_MS,
@@ -0,0 +1,252 @@
1
+ -- Before #3066, a dashboard post into a Slack thread copied the poster's
2
+ -- email onto the thread starter's Slack Identity when Slack had returned no
3
+ -- email for the starter. The copied email linked that Identity to the
4
+ -- poster's User. The link made the poster a Participant of every root that
5
+ -- the Identity started or sent a Turn in.
6
+ --
7
+ -- Evidence: a Slack instruction stores the Actor from the Slack profile in
8
+ -- `provenance.actor`. Slack is the only source that may give a Slack Identity
9
+ -- its email, so an instruction with the Identity's Slack user and email
10
+ -- proves that email. Nothing else proves it. In the same way, an instruction
11
+ -- with the Identity's Slack user and name proves that the name came from
12
+ -- Slack.
13
+ --
14
+ -- A candidate is a Slack user Identity when all of these are true:
15
+ -- - It has a User and a verified email, and no evidence proves that email.
16
+ -- - The User's web Identity, with that same email, wrote an event in a
17
+ -- Conversation of a root that the Slack Identity started.
18
+ --
19
+ -- Slack emails are unique in a workspace, so one User has at most one
20
+ -- correct Slack Identity in each team. Repair a candidate only when evidence
21
+ -- proves exactly one other Slack Identity of its User in its team. Leave
22
+ -- every other candidate as it is. Without that proof, the data cannot tell a
23
+ -- victim from a person whose own link came through this path, or whose
24
+ -- events retention removed.
25
+ --
26
+ -- One statement repairs every table, so each part reads the same rows. The
27
+ -- migration reports its counts with `RAISE INFO`, and `junior upgrade`
28
+ -- prints them. The report has no identifiers.
29
+ DO $$
30
+ DECLARE
31
+ "report" record;
32
+ BEGIN
33
+ -- junior:bounded-backfill: changes only rows of damaged Identities, their Users, and the roots they started or sent Turns in. #3065 found few of these.
34
+ WITH "slack_actors" AS (
35
+ SELECT DISTINCT
36
+ "e"."payload"->'provenance'->'actor'->>'userId' AS "subject",
37
+ lower(btrim("e"."payload"->'provenance'->'actor'->>'email')) AS "email",
38
+ btrim("e"."payload"->'provenance'->'actor'->>'fullName') AS "full_name"
39
+ FROM "junior_conversation_events" AS "e"
40
+ WHERE "e"."type" = 'user_message'
41
+ AND "e"."payload"->'provenance'->>'authority' = 'instruction'
42
+ AND "e"."payload"->'provenance'->'actor'->>'platform' = 'slack'
43
+ ),
44
+ "slack_evidence" AS (
45
+ SELECT DISTINCT "subject", "email"
46
+ FROM "slack_actors"
47
+ WHERE "email" IS NOT NULL
48
+ ),
49
+ "proven" AS (
50
+ SELECT "slack"."id", "slack"."user_id", "slack"."provider_tenant_id",
51
+ "slack"."display_name"
52
+ FROM "junior_identities" AS "slack"
53
+ INNER JOIN "slack_evidence" AS "ev"
54
+ ON "ev"."subject" = "slack"."provider_subject_id"
55
+ AND "ev"."email" = "slack"."email_normalized"
56
+ WHERE "slack"."kind" = 'user'
57
+ AND "slack"."provider" = 'slack'
58
+ AND "slack"."user_id" IS NOT NULL
59
+ ),
60
+ "web_posts" AS (
61
+ SELECT DISTINCT "web"."user_id", "web"."email_normalized",
62
+ coalesce("c"."root_conversation_id", "c"."conversation_id") AS "root_id"
63
+ FROM "junior_identities" AS "web"
64
+ INNER JOIN "junior_conversation_events" AS "posted"
65
+ ON "posted"."actor_identity_id" = "web"."id"
66
+ INNER JOIN "junior_conversations" AS "c"
67
+ ON "c"."conversation_id" = "posted"."conversation_id"
68
+ WHERE "web"."kind" = 'user'
69
+ AND "web"."provider" = 'junior'
70
+ AND "web"."user_id" IS NOT NULL
71
+ ),
72
+ "candidates" AS (
73
+ SELECT DISTINCT "slack"."id" AS "identity_id", "slack"."user_id",
74
+ "slack"."provider_tenant_id"
75
+ FROM "junior_identities" AS "slack"
76
+ INNER JOIN "junior_conversations" AS "root"
77
+ ON "root"."actor_identity_id" = "slack"."id"
78
+ AND "root"."parent_conversation_id" IS NULL
79
+ INNER JOIN "web_posts" AS "w"
80
+ ON "w"."root_id" = "root"."conversation_id"
81
+ AND "w"."user_id" = "slack"."user_id"
82
+ AND "w"."email_normalized" = "slack"."email_normalized"
83
+ WHERE "slack"."kind" = 'user'
84
+ AND "slack"."provider" = 'slack'
85
+ AND "slack"."user_id" IS NOT NULL
86
+ AND "slack"."email_verified"
87
+ AND "slack"."id" NOT IN (SELECT "id" FROM "proven")
88
+ ),
89
+ "damaged" AS (
90
+ SELECT "candidate"."identity_id", "candidate"."user_id"
91
+ FROM "candidates" AS "candidate"
92
+ WHERE (
93
+ SELECT count(*)
94
+ FROM "proven" AS "kept"
95
+ WHERE "kept"."user_id" = "candidate"."user_id"
96
+ AND "kept"."provider_tenant_id" = "candidate"."provider_tenant_id"
97
+ ) = 1
98
+ ),
99
+ -- Roots where the link made the poster a Participant: roots that the damaged
100
+ -- Identity started, and roots where it sent a Turn.
101
+ "affected_roots" AS (
102
+ SELECT "d"."user_id", "root"."conversation_id" AS "root_id"
103
+ FROM "damaged" AS "d"
104
+ INNER JOIN "junior_conversations" AS "root"
105
+ ON "root"."actor_identity_id" = "d"."identity_id"
106
+ AND "root"."parent_conversation_id" IS NULL
107
+ UNION
108
+ SELECT "d"."user_id",
109
+ coalesce("c"."root_conversation_id", "c"."conversation_id") AS "root_id"
110
+ FROM "damaged" AS "d"
111
+ INNER JOIN "junior_conversation_events" AS "e"
112
+ ON "e"."actor_identity_id" = "d"."identity_id"
113
+ INNER JOIN "junior_conversations" AS "c"
114
+ ON "c"."conversation_id" = "e"."conversation_id"
115
+ ),
116
+ -- Keep a row when the User started the root or wrote in it through an
117
+ -- Identity that is not damaged.
118
+ "removed_participants" AS (
119
+ DELETE FROM "junior_conversation_participants" AS "p"
120
+ USING "affected_roots" AS "a"
121
+ WHERE "p"."user_id" = "a"."user_id"
122
+ AND "p"."root_conversation_id" = "a"."root_id"
123
+ AND NOT EXISTS (
124
+ SELECT 1
125
+ FROM "junior_conversations" AS "root"
126
+ INNER JOIN "junior_identities" AS "starter"
127
+ ON "starter"."id" = "root"."actor_identity_id"
128
+ WHERE "root"."conversation_id" = "a"."root_id"
129
+ AND "starter"."user_id" = "a"."user_id"
130
+ AND "starter"."id" NOT IN (SELECT "identity_id" FROM "damaged")
131
+ )
132
+ AND NOT EXISTS (
133
+ SELECT 1
134
+ FROM "junior_conversations" AS "c"
135
+ INNER JOIN "junior_conversation_events" AS "e"
136
+ ON "e"."conversation_id" = "c"."conversation_id"
137
+ INNER JOIN "junior_identities" AS "author"
138
+ ON "author"."id" = "e"."actor_identity_id"
139
+ WHERE coalesce("c"."root_conversation_id", "c"."conversation_id") = "a"."root_id"
140
+ AND "author"."user_id" = "a"."user_id"
141
+ AND "author"."id" NOT IN (SELECT "identity_id" FROM "damaged")
142
+ )
143
+ RETURNING 1
144
+ ),
145
+ -- The link gave the poster's User the starter's name when the User had none.
146
+ -- Later dashboard posts copy the User name to the poster's web Identity, and
147
+ -- the next save of that Identity copies it back to the User. So the web
148
+ -- Identity name is not evidence. A name is the starter's when Slack evidence
149
+ -- proves it for the damaged Identity and no proven Slack Identity of the User
150
+ -- has it. Clear it on the User and on the User's web Identities. The next
151
+ -- save of a kept Identity gives the User a name again.
152
+ "stolen_names" AS (
153
+ SELECT DISTINCT "u"."id" AS "user_id", "u"."display_name"
154
+ FROM "damaged" AS "d"
155
+ INNER JOIN "junior_identities" AS "slack" ON "slack"."id" = "d"."identity_id"
156
+ INNER JOIN "junior_users" AS "u" ON "u"."id" = "d"."user_id"
157
+ WHERE "u"."display_name" = "slack"."display_name"
158
+ AND EXISTS (
159
+ SELECT 1
160
+ FROM "slack_actors" AS "a"
161
+ WHERE "a"."subject" = "slack"."provider_subject_id"
162
+ AND "a"."full_name" = "slack"."display_name"
163
+ )
164
+ AND NOT EXISTS (
165
+ SELECT 1
166
+ FROM "proven" AS "kept"
167
+ WHERE "kept"."user_id" = "d"."user_id"
168
+ AND "kept"."display_name" = "u"."display_name"
169
+ )
170
+ ),
171
+ "renamed_users" AS (
172
+ UPDATE "junior_users" AS "u"
173
+ SET "display_name" = NULL,
174
+ "updated_at" = now()
175
+ FROM "stolen_names" AS "n"
176
+ WHERE "u"."id" = "n"."user_id"
177
+ RETURNING 1
178
+ ),
179
+ "renamed_web_identities" AS (
180
+ UPDATE "junior_identities" AS "web"
181
+ SET "display_name" = NULL,
182
+ "updated_at" = now()
183
+ FROM "stolen_names" AS "n"
184
+ WHERE "web"."user_id" = "n"."user_id"
185
+ AND "web"."kind" = 'user'
186
+ AND "web"."provider" = 'junior'
187
+ AND "web"."display_name" = "n"."display_name"
188
+ RETURNING 1
189
+ ),
190
+ -- The detail report of these roots shows the root Actor and Participants.
191
+ "touched_roots" AS (
192
+ UPDATE "junior_conversations" AS "root"
193
+ SET "detail_version" = "root"."detail_version" + 1
194
+ WHERE "root"."conversation_id" IN (SELECT "root_id" FROM "affected_roots")
195
+ RETURNING 1
196
+ ),
197
+ -- Put the Identity back to its state before the link. Slack gave it no
198
+ -- email, so a later Slack Turn cannot link it again. The same write copied
199
+ -- the poster's name when Slack gave none, so clear a name that matches the
200
+ -- poster's web Identity unless Slack evidence proves it. The next Slack Turn
201
+ -- of the Identity saves its own name again.
202
+ "unlinked" AS (
203
+ UPDATE "junior_identities" AS "i"
204
+ SET "user_id" = NULL,
205
+ "email" = NULL,
206
+ "email_normalized" = NULL,
207
+ "email_verified" = false,
208
+ "display_name" = CASE
209
+ WHEN EXISTS (
210
+ SELECT 1
211
+ FROM "junior_identities" AS "web"
212
+ WHERE "web"."user_id" = "d"."user_id"
213
+ AND "web"."provider" = 'junior'
214
+ AND "web"."display_name" = "i"."display_name"
215
+ ) AND NOT EXISTS (
216
+ SELECT 1
217
+ FROM "slack_actors" AS "a"
218
+ WHERE "a"."subject" = "i"."provider_subject_id"
219
+ AND "a"."full_name" = "i"."display_name"
220
+ ) THEN NULL
221
+ ELSE "i"."display_name"
222
+ END,
223
+ "updated_at" = now()
224
+ FROM "damaged" AS "d"
225
+ WHERE "i"."id" = "d"."identity_id"
226
+ RETURNING 1
227
+ )
228
+ SELECT
229
+ (SELECT count(*) FROM "candidates") AS "candidates",
230
+ (SELECT count(*) FROM "unlinked") AS "repaired",
231
+ (SELECT count(*) FROM "candidates" AS "c"
232
+ WHERE NOT EXISTS (
233
+ SELECT 1 FROM "proven" AS "p"
234
+ WHERE "p"."user_id" = "c"."user_id"
235
+ AND "p"."provider_tenant_id" = "c"."provider_tenant_id"
236
+ )) AS "skipped_unproven",
237
+ (SELECT count(*) FROM "candidates" AS "c"
238
+ WHERE (
239
+ SELECT count(*) FROM "proven" AS "p"
240
+ WHERE "p"."user_id" = "c"."user_id"
241
+ AND "p"."provider_tenant_id" = "c"."provider_tenant_id"
242
+ ) > 1) AS "skipped_many_proven",
243
+ (SELECT count(*) FROM "removed_participants") AS "participants",
244
+ (SELECT count(*) FROM "touched_roots") AS "roots",
245
+ (SELECT count(*) FROM "renamed_users") AS "users_renamed",
246
+ (SELECT count(*) FROM "renamed_web_identities") AS "web_identities_renamed"
247
+ INTO "report";
248
+ RAISE INFO '0095 Slack Identity repair: % candidates, % repaired, % skipped with no proven Slack Identity, % skipped with more than one, % Participant rows removed, % roots updated, % User names and % web Identity names cleared',
249
+ "report"."candidates", "report"."repaired", "report"."skipped_unproven",
250
+ "report"."skipped_many_proven", "report"."participants", "report"."roots",
251
+ "report"."users_renamed", "report"."web_identities_renamed";
252
+ END $$;