@sentry/junior 0.253.0 → 0.255.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 (63) hide show
  1. package/dist/{admin-CZnlnlg9.js → admin-CeJh4SuR.js} +1 -1
  2. package/dist/{agent-hooks-CvcbAtJH.js → agent-hooks-CDVx26Uu.js} +9 -9
  3. package/dist/{agent-invocations-D_YoNnAn.js → agent-invocations-BY60iNw-.js} +0 -4
  4. package/dist/{agent-runner-B4FMVbCs.js → agent-runner-Caiof09f.js} +25 -22
  5. package/dist/api/schema.d.ts +0 -8
  6. package/dist/api/schema.js +2 -2
  7. package/dist/api.js +61 -71
  8. package/dist/app.js +38 -37
  9. package/dist/{assistant-reply-BU05IECs.js → assistant-reply-BddmM66R.js} +1 -1
  10. package/dist/{automation-gznOMaQ2.js → automation-CHdlHVZP.js} +3 -4
  11. package/dist/{briefs-DyspoG90.js → briefs-iVq_8-ft.js} +2 -2
  12. package/dist/{catalog-runtime-Br8s-TYx.js → catalog-runtime-hKmI-iZa.js} +1 -1
  13. package/dist/cli/chat.js +15 -15
  14. package/dist/cli/check.js +3 -3
  15. package/dist/cli/main.js +2 -2
  16. package/dist/cli/plugins.js +4 -4
  17. package/dist/cli/snapshot-create.js +3 -3
  18. package/dist/cli/upgrade.js +3 -3
  19. package/dist/{client-CRVXpEWi.js → client-Clj7onnT.js} +2 -2
  20. package/dist/{config-B7joRWt7.js → config-BDAfLTI9.js} +2 -2
  21. package/dist/{connections-CGPYNw2B.js → connections-BC0RTejT.js} +9 -9
  22. package/dist/{conversation-privacy-0JuTT_OJ.js → conversation-privacy-1ERtieuM.js} +1 -1
  23. package/dist/{credential-sync-C-k3fnY5.js → credential-sync-BZuqqIHk.js} +14 -14
  24. package/dist/{executor-YL577nNt.js → executor-Dh4Ofsnx.js} +14 -94
  25. package/dist/{images-DopOctPc.js → images-C-WOnTc_.js} +2 -2
  26. package/dist/instrumentation.js +2 -2
  27. package/dist/{job-queue-CIhKXUE3.js → job-queue-BaCL36FY.js} +1 -1
  28. package/dist/{logging-B0QxCh3D.js → logging-D3aYP0aG.js} +1 -1
  29. package/dist/{message-DQvor8lM.js → message-B9xqD2BP.js} +3 -3
  30. package/dist/nitro.js +3 -3
  31. package/dist/{oauth-callback-server-BT7cSxBm.js → oauth-callback-server-i5qdAou6.js} +2 -2
  32. package/dist/{pending-auth-CwA1uLA9.js → pending-auth-D2t1Moxf.js} +2 -2
  33. package/dist/{profile-p1oiViVs.js → profile-DnkX3e2S.js} +4 -4
  34. package/dist/{registry-BO2LM2oW.js → registry-CmKmKHpp.js} +1 -1
  35. package/dist/{resolve-CtWKGuKE.js → resolve-jfNHtEBx.js} +2 -2
  36. package/dist/{result-DR5JTBcb.js → result-Df5nEDX2.js} +6 -6
  37. package/dist/{runner-BIxTJF9a.js → runner-CmzoXEI4.js} +9 -9
  38. package/dist/{sandbox-egress-signals-DF3Pu813.js → sandbox-egress-signals-DjMNKLZz.js} +1 -1
  39. package/dist/{schema-C9Vnyb_f.js → schema-BBgv0MNf.js} +2 -2
  40. package/dist/{session-stop-BRq8Vxrr.js → session-stop-BEBfE97J.js} +11 -11
  41. package/dist/{skills-DitcC3Vw.js → skills-Dc-AMYi4.js} +2 -2
  42. package/dist/{spawn-CHQ42PAo.js → spawn-OgTwBUj0.js} +2 -2
  43. package/dist/{store-DIFp9K52.js → store-BashBewg.js} +6 -6
  44. package/dist/{task-queue-UAeJGLYM.js → task-queue-VvIKqlQ4.js} +3 -3
  45. package/dist/{task-runner-DwD-i2ta.js → task-runner-D2CpD6GN.js} +11 -11
  46. package/dist/{tasks-DThIG7F-.js → tasks-dJooqiip.js} +16 -26
  47. package/dist/{thread-state-BQxkL7Xm.js → thread-state-CsMC-ob0.js} +7 -7
  48. package/dist/{turn-failure-response-OAIxgzNh.js → turn-failure-response-zB364t7_.js} +7 -7
  49. package/dist/{turn-lifecycle-BAEJpjDI.js → turn-lifecycle-BfodfmiY.js} +1 -1
  50. package/dist/{turn-session-routing-F5s728f0.js → turn-session-routing-BAh_qsBJ.js} +1 -1
  51. package/dist/{validation-DFM4-vDr.js → validation-LzIilOb6.js} +1 -1
  52. package/dist/{version-B80CD9sN.js → version-CDM8Rq6E.js} +1 -1
  53. package/dist/version.js +1 -1
  54. package/dist/{viewer-CPxNfHWa.js → viewer-Rnim7alE.js} +4 -13
  55. package/dist/{web-input-DIO177R0.js → web-input-Dc1VwcT4.js} +75 -76
  56. package/dist/{work-Dl5KPKjW.js → work-BAn43SsN.js} +9 -9
  57. package/dist/{worker-CJkE86Co.js → worker-mBXq4_zg.js} +5 -5
  58. package/migrations/0057_drop_legacy_automation_tables.sql +10 -0
  59. package/migrations/0058_automation_creator_identity.sql +45 -0
  60. package/migrations/meta/0057_snapshot.json +3618 -0
  61. package/migrations/meta/0058_snapshot.json +3598 -0
  62. package/migrations/meta/_journal.json +14 -0
  63. package/package.json +4 -4
package/dist/app.js CHANGED
@@ -1,38 +1,38 @@
1
- import { At as consumeSandboxEgressPermissionDeniedSignal, B as effectiveTaskOutcomes, Ct as ingestEvent, Dt as SANDBOX_EGRESS_PROXY_PATH, E as requestAttachmentDeletion, Et as shouldPropagateSandboxEgressTrace, F as logScheduledAutomationRunSkipped, I as scheduledAutomationRunAttributes, It as startOAuthFlow, Kt as getConfigDefaults, Lt as createUserTokenStore, Nt as formatProviderLabel, O as parseSlackThreadId, Ot as clearSandboxEgressSignals, St as processWorkspaceSnapshotJob, Tt as normalizeSandboxEgressTracePropagationDomains, U as stopConversationSession, W as recordSubagentEnded, b as unpublishedArtifactHeaders, i as executeCredentialedEgressRequest, jt as parseSandboxEgressCredentialToken, kt as consumeSandboxEgressAuthRequiredSignal, lt as listPendingAgentInvocationMailboxAppends, n as executeAgentRun, qt as setConfigDefaults, t as createAgentRunner, ut as listPendingAgentInvocationResults, v as publicArtifactHeaders, w as collectAttachmentGarbage, wt as resolveSandboxEgressProviderForHost, x as lookupSlackUserProfile, y as readPublicArtifact } from "./agent-runner-B4FMVbCs.js";
2
- import { C as withLogContext, O as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, S as withContext, d as logException, f as logInfo, j as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, p as logWarn, r as createRequestContext, v as setSpanAttributes, w as withSpan, y as setSpanStatus } from "./logging-B0QxCh3D.js";
1
+ import { At as consumeSandboxEgressPermissionDeniedSignal, B as effectiveTaskOutcomes, Ct as ingestEvent, Dt as SANDBOX_EGRESS_PROXY_PATH, E as requestAttachmentDeletion, Et as shouldPropagateSandboxEgressTrace, F as logScheduledAutomationRunSkipped, I as scheduledAutomationRunAttributes, It as startOAuthFlow, Kt as getConfigDefaults, Lt as createUserTokenStore, Nt as formatProviderLabel, O as parseSlackThreadId, Ot as clearSandboxEgressSignals, St as processWorkspaceSnapshotJob, Tt as normalizeSandboxEgressTracePropagationDomains, U as stopConversationSession, W as recordSubagentEnded, b as unpublishedArtifactHeaders, i as executeCredentialedEgressRequest, jt as parseSandboxEgressCredentialToken, kt as consumeSandboxEgressAuthRequiredSignal, lt as listPendingAgentInvocationMailboxAppends, n as executeAgentRun, qt as setConfigDefaults, t as createAgentRunner, ut as listPendingAgentInvocationResults, v as publicArtifactHeaders, w as collectAttachmentGarbage, wt as resolveSandboxEgressProviderForHost, x as lookupSlackUserProfile, y as readPublicArtifact } from "./agent-runner-Caiof09f.js";
2
+ import { C as withLogContext, O as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, S as withContext, d as logException, f as logInfo, j as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, p as logWarn, r as createRequestContext, v as setSpanAttributes, w as withSpan, y as setSpanStatus } from "./logging-D3aYP0aG.js";
3
3
  import { n as captureMessage, r as continueTrace } from "./sentry-CgWZM_kV.js";
4
- import { t as JUNIOR_VERSION } from "./version-B80CD9sN.js";
5
- import { _ as snapshotRuntimeConfig, d as restoreRuntimeConfig, f as setBotModelConfig, g as setSlackReactionConfig, h as setRuntimeLimits, i as getChatConfig, m as setProfiles, n as botConfig, o as getSlackBotToken, p as setCrossActorMidRunMode, u as resetRuntimeConfig } from "./config-B7joRWt7.js";
4
+ import { t as JUNIOR_VERSION } from "./version-CDM8Rq6E.js";
5
+ import { _ as snapshotRuntimeConfig, d as restoreRuntimeConfig, f as setBotModelConfig, g as setSlackReactionConfig, h as setRuntimeLimits, i as getChatConfig, m as setProfiles, n as botConfig, o as getSlackBotToken, p as setCrossActorMidRunMode, u as resetRuntimeConfig } from "./config-BDAfLTI9.js";
6
6
  import { _ as slackMessageTsSchema, d as parseSlackTeamId, f as parseSlackUserId, h as slackUserIdSchema, m as slackTeamIdSchema, o as parseActorUserId, p as slackChannelIdSchema } from "./actor-BTtLaeWy.js";
7
- import { c as getConversationEventStore, d as getDb, f as getSqlExecutor, g as withConversationMutationLock, m as withConversationEventLock, r as readActorIdentity, u as getConversationStore } from "./viewer-CPxNfHWa.js";
8
- import { a as juniorAgentInvocations, d as juniorDestinations, i as juniorAgentBindings, s as juniorConversations } from "./agent-invocations-D_YoNnAn.js";
9
- import { f as juniorConversationBriefs, h as juniorConversationEvents, o as juniorAutomationRuns, s as juniorAutomations } from "./executor-YL577nNt.js";
10
- import { n as pluginCatalogRuntime } from "./catalog-runtime-Br8s-TYx.js";
11
- import { C as eventAutomationRunLimitReason, F as slackMention, G as slackExternalRefIdSchema, S as admitEventAutomationRun, W as slackEntitySchema, Wt as appendConversationMessages, Xt as settleConversationTitleWork, a as readScheduledAutomation, c as scheduledRunId, d as collectEventAutomationMatchKeys, h as findMatchingEventAutomations, l as withScheduledAutomationLock, n as listScheduledAutomations, qt as projectConversationMessages, r as listScheduledAutomationsForTeam, s as saveScheduledAutomationInLock, u as blockEventAutomation } from "./tasks-DThIG7F-.js";
12
- import { $ as bindSlackDirectCredentialSubject, At as resolveRootVisibility, Ht as getSlackClient, Jt as getWorkspaceTeamId, Nt as listConversationAnnotations, Q as bindScheduledAutomationCredentialSubject, U as collectEventMatchKeys, Wt as isDmChannel, X as takeDueTimerWatches, Yt as runWithWorkspaceTeamId, Z as bindEventAutomationCredentialSubject, a as getPluginRoutes, at as getDashboardConversationLink, ct as setDashboardConversationLinkOptions, d as setPlugins, et as verifyEventAutomationCredentialSubject, f as validatePlugins, ft as createPluginLogger, h as setBriefsConfig, i as getPluginApiRoutes, lt as createPluginState, nt as verifySlackDirectCredentialSubject, pt as readConversationAccessFromSql, q as findMatchingWatches, st as getDashboardTaskLink, tt as verifyScheduledAutomationCredentialSubject, u as getPlugins } from "./agent-hooks-CvcbAtJH.js";
7
+ import { c as getConversationEventStore, d as getDb, f as getSqlExecutor, g as withConversationMutationLock, m as withConversationEventLock, r as readActorIdentity, u as getConversationStore } from "./viewer-Rnim7alE.js";
8
+ import { a as juniorAgentInvocations, d as juniorDestinations, i as juniorAgentBindings, s as juniorConversations } from "./agent-invocations-BY60iNw-.js";
9
+ import { f as juniorConversationBriefs, h as juniorConversationEvents, o as juniorAutomationRuns, s as juniorAutomations } from "./executor-Dh4Ofsnx.js";
10
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-hKmI-iZa.js";
11
+ import { Gt as projectConversationMessages, H as slackEntitySchema, Ht as appendConversationMessages, Jt as settleConversationTitleWork, N as slackMention, U as slackExternalRefIdSchema, b as admitEventAutomationRun, c as withScheduledAutomationLock, i as readScheduledAutomation, l as blockEventAutomation, n as listScheduledAutomationsForTeam, o as saveScheduledAutomationInLock, p as findMatchingEventAutomations, s as scheduledRunId, u as collectEventAutomationMatchKeys, x as eventAutomationRunLimitReason } from "./tasks-dJooqiip.js";
12
+ import { $ as bindSlackDirectCredentialSubject, At as resolveRootVisibility, Ht as getSlackClient, Jt as getWorkspaceTeamId, Nt as listConversationAnnotations, Q as bindScheduledAutomationCredentialSubject, U as collectEventMatchKeys, Wt as isDmChannel, X as takeDueTimerWatches, Yt as runWithWorkspaceTeamId, Z as bindEventAutomationCredentialSubject, a as getPluginRoutes, at as getDashboardConversationLink, ct as setDashboardConversationLinkOptions, d as setPlugins, et as verifyEventAutomationCredentialSubject, f as validatePlugins, ft as createPluginLogger, h as setBriefsConfig, i as getPluginApiRoutes, lt as createPluginState, nt as verifySlackDirectCredentialSubject, pt as readConversationAccessFromSql, q as findMatchingWatches, st as getDashboardTaskLink, tt as verifyScheduledAutomationCredentialSubject, u as getPlugins } from "./agent-hooks-CDVx26Uu.js";
13
13
  import { W as annotationCard } from "./conversation-T18Xlkx9.js";
14
- import { O as withLock$1, w as getStateAdapter } from "./profile-p1oiViVs.js";
15
- import { c as getThreadStopDecision } from "./pending-auth-CwA1uLA9.js";
16
- import { O as renderTaskInput, f as slackChannelMessageEvent, l as getEventCatalog, p as slackChannelMessageReplyThreadTs, u as SLACK_EVENT_NAMESPACE, y as eventGuidance } from "./session-stop-BRq8Vxrr.js";
14
+ import { O as withLock$1, w as getStateAdapter } from "./profile-DnkX3e2S.js";
15
+ import { c as getThreadStopDecision } from "./pending-auth-D2t1Moxf.js";
16
+ import { O as renderTaskInput, f as slackChannelMessageEvent, l as getEventCatalog, p as slackChannelMessageReplyThreadTs, u as SLACK_EVENT_NAMESPACE, y as eventGuidance } from "./session-stop-BEBfE97J.js";
17
17
  import { n as getNextRunAtMs } from "./cadence-D00SCzT1.js";
18
- import { f as setSandboxResourceConfig, u as getSandboxResourceConfig } from "./resolve-CtWKGuKE.js";
19
- import { a as getVercelConversationWorkQueue, g as isConversationQueueMessageRejectedError, h as conversationQueueMessageSchema, i as verifyWorkspaceSnapshotJobMessage, o as resolveConversationWorkQueueTopic, s as verifyConversationQueueMessage, t as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC } from "./job-queue-CIhKXUE3.js";
20
- import { A as hasRunnableConversationWork$1, M as isInvalidConversationRecordError, O as CONVERSATION_WORK_STALE_ENQUEUE_MS, S as removeActiveConversation, _ as hasRunnableConversationWork, c as clearExpiredConversationLease, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, r as appendAndEnqueueInboundMessage, v as listActiveConversationIds } from "./store-DIFp9K52.js";
21
- import { D as scheduledRunSchema } from "./automation-gznOMaQ2.js";
18
+ import { f as setSandboxResourceConfig, u as getSandboxResourceConfig } from "./resolve-jfNHtEBx.js";
19
+ import { a as getVercelConversationWorkQueue, g as isConversationQueueMessageRejectedError, h as conversationQueueMessageSchema, i as verifyWorkspaceSnapshotJobMessage, o as resolveConversationWorkQueueTopic, s as verifyConversationQueueMessage, t as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC } from "./job-queue-BaCL36FY.js";
20
+ import { A as hasRunnableConversationWork$1, M as isInvalidConversationRecordError, O as CONVERSATION_WORK_STALE_ENQUEUE_MS, S as removeActiveConversation, _ as hasRunnableConversationWork, c as clearExpiredConversationLease, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, r as appendAndEnqueueInboundMessage, v as listActiveConversationIds } from "./store-BashBewg.js";
21
+ import { D as scheduledRunSchema } from "./automation-CHdlHVZP.js";
22
22
  import { i as setExperimentalFeatures, n as getExperimentalFeatures, r as isExperimentalFeatureEnabled } from "./experimental-Qn9rKLgx.js";
23
- import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "./validation-DFM4-vDr.js";
23
+ import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "./validation-LzIilOb6.js";
24
24
  import { a as pluginRuntimeRegistrationsFromPluginSet, n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "./plugins-egKWjgue.js";
25
- import { A as withNormalizedThreadId, C as buildSlackInboundMessage, D as isSlackMessageStopped, E as verifySlackSignature, F as renderSlackObjectCard, I as createVercelAttachmentStorage, M as THREAD_OPTOUT_ACK, N as startProcessingReaction, O as stopSlackThread, P as parseContent, R as enqueueAgentDispatch, S as recordSkippedConversationMessage, T as runWithSlackInstallation, a as recordWebConversationActivity, c as createProductionSlackWebhookServices, f as createSlackWebApiStatusSender, j as stopConversationTurn, k as normalizeIncomingSlackThreadId, l as getProductionSlackAdapter, n as conversationTurnIdForMessage, o as webActorFromEmail, s as createProductionConversationWorkOptions, t as appendAndEnqueueWebMessage, v as readViewerAutomationSummary, w as clearSlackPendingReactions, z as GET$3 } from "./web-input-DIO177R0.js";
26
- import { M as recordAutomationExecution, S as existingConversationId, a as confirmDispatchMailboxAppend, b as notifyAutomationBlocked, f as getPluginDispatchProjection, m as listPendingDispatchMailboxAppends, o as createOrGetDispatch, p as isTerminalDispatchStatus, s as getDispatchConversationId, t as processPluginTask, u as getDispatchRecord, v as markDispatchFailed } from "./task-runner-DwD-i2ta.js";
27
- import { o as getAuthPausedConversationTurnId, t as enqueueAgentInvocationResult } from "./result-DR5JTBcb.js";
28
- import { r as enqueueAgentInvocation } from "./work-Dl5KPKjW.js";
29
- import { s as coerceThreadConversationState } from "./thread-state-BQxkL7Xm.js";
30
- import { o as unlinkProvider } from "./connections-CGPYNw2B.js";
31
- import { a as GET$4, i as publishAppHomeView, r as GET$5, t as receiveLocalOAuthCredential } from "./credential-sync-C-k3fnY5.js";
32
- import { a as registerVercelPluginTaskDevConsumer, n as createVercelPluginTaskCallback, s as queueCallback } from "./task-queue-UAeJGLYM.js";
33
- import { t as processConversationWork } from "./worker-CJkE86Co.js";
34
- import { t as bindMessageAgent } from "./message-DQvor8lM.js";
35
- import { t as bindSpawnAgent } from "./spawn-CHQ42PAo.js";
25
+ import { A as withNormalizedThreadId, C as buildSlackInboundMessage, D as isSlackMessageStopped, E as verifySlackSignature, F as renderSlackObjectCard, I as createVercelAttachmentStorage, M as THREAD_OPTOUT_ACK, N as startProcessingReaction, O as stopSlackThread, P as parseContent, R as enqueueAgentDispatch, S as recordSkippedConversationMessage, T as runWithSlackInstallation, a as recordWebConversationActivity, c as createProductionSlackWebhookServices, f as createSlackWebApiStatusSender, j as stopConversationTurn, k as normalizeIncomingSlackThreadId, l as getProductionSlackAdapter, n as conversationTurnIdForMessage, o as webActorFromEmail, s as createProductionConversationWorkOptions, t as appendAndEnqueueWebMessage, v as readViewerAutomationSummary, w as clearSlackPendingReactions, z as GET$3 } from "./web-input-Dc1VwcT4.js";
26
+ import { M as recordAutomationExecution, S as existingConversationId, a as confirmDispatchMailboxAppend, b as notifyAutomationBlocked, f as getPluginDispatchProjection, m as listPendingDispatchMailboxAppends, o as createOrGetDispatch, p as isTerminalDispatchStatus, s as getDispatchConversationId, t as processPluginTask, u as getDispatchRecord, v as markDispatchFailed } from "./task-runner-D2CpD6GN.js";
27
+ import { o as getAuthPausedConversationTurnId, t as enqueueAgentInvocationResult } from "./result-Df5nEDX2.js";
28
+ import { r as enqueueAgentInvocation } from "./work-BAn43SsN.js";
29
+ import { s as coerceThreadConversationState } from "./thread-state-CsMC-ob0.js";
30
+ import { o as unlinkProvider } from "./connections-BC0RTejT.js";
31
+ import { a as GET$4, i as publishAppHomeView, r as GET$5, t as receiveLocalOAuthCredential } from "./credential-sync-BZuqqIHk.js";
32
+ import { a as registerVercelPluginTaskDevConsumer, n as createVercelPluginTaskCallback, s as queueCallback } from "./task-queue-VvIKqlQ4.js";
33
+ import { t as processConversationWork } from "./worker-mBXq4_zg.js";
34
+ import { t as bindMessageAgent } from "./message-B9xqD2BP.js";
35
+ import { t as bindSpawnAgent } from "./spawn-OgTwBUj0.js";
36
36
  import { createRequire } from "node:module";
37
37
  import { Hono } from "hono";
38
38
  import { z } from "zod";
@@ -372,6 +372,7 @@ async function settleEventAutomationRuns(db, nowMs) {
372
372
  const status = dispatch?.status ?? "failed";
373
373
  if (status !== "blocked" && status !== "completed" && status !== "failed") continue;
374
374
  await recordAutomationExecution(run.automationId, {
375
+ conversationId: getDispatchConversationId({ id: run.id }),
375
376
  errorMessage: dispatch ? dispatch.errorMessage : "Event automation dispatch record is missing.",
376
377
  executionId: run.id,
377
378
  nowMs: dispatch?.updatedAtMs ?? nowMs,
@@ -441,13 +442,13 @@ async function writeRun(db, run) {
441
442
  set: columns
442
443
  });
443
444
  }
444
- async function listIncompleteRunsForTaskIds(db, taskIds) {
445
- if (taskIds.length === 0) return [];
446
- return (await db.select().from(juniorAutomationRuns).where(and(inArray(juniorAutomationRuns.automationId, taskIds), inArray(juniorAutomationRuns.status, [...INCOMPLETE_RUN_STATUSES]))).orderBy(asc(juniorAutomationRuns.scheduledForMs), asc(juniorAutomationRuns.id))).map(parseScheduledRunRow).filter(present);
447
- }
448
- /** List incomplete runs for retained scheduled automations. */
449
- async function listIncompleteScheduledRuns(db) {
450
- return await listIncompleteRunsForTaskIds(db, (await listScheduledAutomations(db)).map((task) => task.id));
445
+ /**
446
+ * List incomplete Scheduled automation runs, optionally for one automation.
447
+ * Deleted automations are included: a run that was already dispatched when
448
+ * its automation was deleted must still settle.
449
+ */
450
+ async function listIncompleteScheduledRuns(db, automationId) {
451
+ return (await db.select({ run: juniorAutomationRuns }).from(juniorAutomationRuns).innerJoin(juniorAutomations, eq(juniorAutomations.id, juniorAutomationRuns.automationId)).where(and(eq(juniorAutomations.kind, "scheduled"), automationId === void 0 ? void 0 : eq(juniorAutomationRuns.automationId, automationId), inArray(juniorAutomationRuns.status, [...INCOMPLETE_RUN_STATUSES]))).orderBy(asc(juniorAutomationRuns.scheduledForMs), asc(juniorAutomationRuns.id))).map(({ run }) => parseScheduledRunRow(run)).filter(present);
451
452
  }
452
453
  function getDueRunAtMs(task, nowMs) {
453
454
  if (typeof task.runNowAtMs === "number" && Number.isFinite(task.runNowAtMs) && task.runNowAtMs <= nowMs) return task.runNowAtMs;
@@ -538,7 +539,7 @@ async function claimDueScheduledRun(db, args) {
538
539
  const scheduledForMs = getDueRunAtMs(task, args.nowMs);
539
540
  if (scheduledForMs === void 0) return void 0;
540
541
  const runId = scheduledRunId(task.id, scheduledForMs);
541
- const incompleteRuns = await listIncompleteRunsForTaskIds(taskTx, [task.id]);
542
+ const incompleteRuns = await listIncompleteScheduledRuns(taskTx, task.id);
542
543
  const incompleteRun = incompleteRuns.find((item) => item.id === runId);
543
544
  if (incompleteRuns.find((item) => item.id !== runId && !isStalePendingRun(item, args.nowMs))) return void 0;
544
545
  if (incompleteRun) {
@@ -1,4 +1,4 @@
1
- import { lt as extractAssistantText } from "./tasks-DThIG7F-.js";
1
+ import { st as extractAssistantText } from "./tasks-dJooqiip.js";
2
2
  //#region src/chat/no-reply.ts
3
3
  const NO_REPLY_MARKER = "[[NO_REPLY]]";
4
4
  /**
@@ -234,6 +234,8 @@ const eventAutomationSchema = z.object({
234
234
  id: z.string().min(1),
235
235
  createdAtMs: z.number().finite(),
236
236
  createdBy: eventAutomationPrincipalSchema,
237
+ /** Junior identity that created the automation. It decides ownership. */
238
+ creatorIdentityId: z.string().min(1),
237
239
  credentialMode: z.enum(["system", "creator"]),
238
240
  destination: eventAutomationDestinationSchema,
239
241
  destinationVisibility: destinationVisibilitySchema,
@@ -501,10 +503,7 @@ const automationListSchema = z.object({
501
503
  creators: z.array(automationFilterOptionSchema),
502
504
  destinations: z.array(automationFilterOptionSchema)
503
505
  }).strict();
504
- const automationParamsSchema = z.object({
505
- id: z.string().min(1),
506
- kind: z.enum(["scheduled", "event"])
507
- }).strict();
506
+ const automationParamsSchema = z.object({ id: z.string().min(1) }).strict();
508
507
  const automationExecutionStatusSchema = z.enum([
509
508
  "blocked",
510
509
  "completed",
@@ -1,4 +1,4 @@
1
- import { r as completeObject } from "./client-CRVXpEWi.js";
1
+ import { r as completeObject } from "./client-Clj7onnT.js";
2
2
  import { r as defaultModelId } from "./model-profile-BwU8mqwD.js";
3
3
  import { U as parseBriefInput, d as conversationDetailReportSchema, p as conversationEventPageSchema, z as briefCodeChangeSchema } from "./conversation-T18Xlkx9.js";
4
4
  import { n as briefEntriesFromReportEvents, s as generateBrief, t as BRIEF_PROMPT } from "./prompt-C04mP1hu.js";
@@ -269,7 +269,7 @@ async function parseRunOptions(argv) {
269
269
  * `DATABASE_URL` at import, and `briefs pull` must work with only a token.
270
270
  */
271
271
  async function configuredDefaultModelId() {
272
- const { botConfig } = await import("./config-B7joRWt7.js").then((n) => n.r);
272
+ const { botConfig } = await import("./config-BDAfLTI9.js").then((n) => n.r);
273
273
  return defaultModelId(botConfig);
274
274
  }
275
275
  function apiUrl(baseUrl, pathname) {
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { t as createPluginCatalogRuntime } from "./registry-BO2LM2oW.js";
2
+ import { t as createPluginCatalogRuntime } from "./registry-CmKmKHpp.js";
3
3
  //#region src/chat/plugins/catalog-runtime.ts
4
4
  var catalog_runtime_exports = /* @__PURE__ */ __exportAll({ pluginCatalogRuntime: () => pluginCatalogRuntime });
5
5
  const pluginCatalogRuntime = createPluginCatalogRuntime();
package/dist/cli/chat.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-B4FMVbCs.js";
1
+ import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-Caiof09f.js";
2
2
  import { t as loadAppPluginSet } from "../plugin-module-CVvEUSMH.js";
3
3
  import path from "node:path";
4
4
  import { createHash, randomUUID } from "node:crypto";
@@ -100,10 +100,10 @@ async function loadLocalPluginSet() {
100
100
  async function configureLocalChatPlugins(pluginSet) {
101
101
  const [pluginsModule, agentHooksModule, catalogRuntimeModule, validationModule, databaseModule] = await Promise.all([
102
102
  import("../plugins-egKWjgue.js").then((n) => n.o),
103
- import("../agent-hooks-CvcbAtJH.js").then((n) => n.t),
104
- import("../catalog-runtime-Br8s-TYx.js").then((n) => n.t),
105
- import("../validation-DFM4-vDr.js").then((n) => n.r),
106
- import("../viewer-CPxNfHWa.js").then((n) => n.s)
103
+ import("../agent-hooks-CDVx26Uu.js").then((n) => n.t),
104
+ import("../catalog-runtime-hKmI-iZa.js").then((n) => n.t),
105
+ import("../validation-LzIilOb6.js").then((n) => n.r),
106
+ import("../viewer-Rnim7alE.js").then((n) => n.s)
107
107
  ]);
108
108
  const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
109
109
  const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
@@ -155,19 +155,19 @@ async function prepareLocalChatRun(io, pluginSet) {
155
155
  await configureLocalChatPlugins(pluginSet);
156
156
  const { setExperimentalFeatures } = await import("../experimental-Qn9rKLgx.js").then((n) => n.t);
157
157
  setExperimentalFeatures({ subagents: true });
158
- const { setBriefsConfig } = await import("../agent-hooks-CvcbAtJH.js").then((n) => n.m);
158
+ const { setBriefsConfig } = await import("../agent-hooks-CDVx26Uu.js").then((n) => n.m);
159
159
  setBriefsConfig({ enabled: true });
160
- const { runLocalAgentTurn } = await import("../runner-BIxTJF9a.js");
161
- const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-BT7cSxBm.js");
160
+ const { runLocalAgentTurn } = await import("../runner-CmzoXEI4.js");
161
+ const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-i5qdAou6.js");
162
162
  const { createLocalOAuthState } = await import("../oauth-relay-CdCnu80W.js").then((n) => n.t);
163
- const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-DF3Pu813.js");
164
- const { bindSpawnAgent } = await import("../spawn-CHQ42PAo.js").then((n) => n.n);
165
- const { bindMessageAgent } = await import("../message-DQvor8lM.js").then((n) => n.n);
166
- const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-Dl5KPKjW.js").then((n) => n.a);
167
- const { startAgentInvocationsForChildInput } = await import("../result-DR5JTBcb.js").then((n) => n.r);
168
- const { skipInputBeforeConversationStop } = await import("../session-stop-BRq8Vxrr.js").then((n) => n.r);
163
+ const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-DjMNKLZz.js");
164
+ const { bindSpawnAgent } = await import("../spawn-OgTwBUj0.js").then((n) => n.n);
165
+ const { bindMessageAgent } = await import("../message-B9xqD2BP.js").then((n) => n.n);
166
+ const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-BAn43SsN.js").then((n) => n.a);
167
+ const { startAgentInvocationsForChildInput } = await import("../result-Df5nEDX2.js").then((n) => n.r);
168
+ const { skipInputBeforeConversationStop } = await import("../session-stop-BEBfE97J.js").then((n) => n.r);
169
169
  const { createLocalConversationWork } = await import("../conversation-work-C6y3T5Hx.js");
170
- const { processConversationWork } = await import("../worker-CJkE86Co.js").then((n) => n.n);
170
+ const { processConversationWork } = await import("../worker-mBXq4_zg.js").then((n) => n.n);
171
171
  let agentRunner;
172
172
  const localConversationWork = createLocalConversationWork(async (message) => {
173
173
  if (!agentRunner) throw new Error("Local agent runner is not ready");
package/dist/cli/check.js CHANGED
@@ -1,6 +1,6 @@
1
- import { D as JUNIOR_HEARTBEAT_ROUTE, M as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, T as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE } from "../logging-B0QxCh3D.js";
2
- import { _ as parsePluginManifest, g as parseInlinePluginManifest } from "../registry-BO2LM2oW.js";
3
- import { i as parseSkillFile } from "../skills-DitcC3Vw.js";
1
+ import { D as JUNIOR_HEARTBEAT_ROUTE, M as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, T as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE } from "../logging-D3aYP0aG.js";
2
+ import { _ as parsePluginManifest, g as parseInlinePluginManifest } from "../registry-CmKmKHpp.js";
3
+ import { i as parseSkillFile } from "../skills-Dc-AMYi4.js";
4
4
  import path from "node:path";
5
5
  import fs from "node:fs/promises";
6
6
  import { pathToFileURL } from "node:url";
package/dist/cli/main.js CHANGED
@@ -25,10 +25,10 @@ async function runChat(argv, pluginSet) {
25
25
  return await (await import("./chat.js")).runChat(argv, void 0, { pluginSet });
26
26
  }
27
27
  async function runAdmin(argv) {
28
- return await (await import("../admin-CZnlnlg9.js")).runAdmin(argv);
28
+ return await (await import("../admin-CeJh4SuR.js")).runAdmin(argv);
29
29
  }
30
30
  async function runBriefs(argv) {
31
- return await (await import("../briefs-DyspoG90.js")).runBriefs(argv);
31
+ return await (await import("../briefs-iVq_8-ft.js")).runBriefs(argv);
32
32
  }
33
33
  function topLevelCommand(argv) {
34
34
  return (argv[0] === "--" ? argv.slice(1) : argv)[0];
@@ -1,7 +1,7 @@
1
- import { d as getDb } from "../viewer-CPxNfHWa.js";
2
- import { n as pluginCatalogRuntime } from "../catalog-runtime-Br8s-TYx.js";
3
- import { d as setPlugins, f as validatePlugins, ft as createPluginLogger } from "../agent-hooks-CvcbAtJH.js";
4
- import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-DFM4-vDr.js";
1
+ import { d as getDb } from "../viewer-Rnim7alE.js";
2
+ import { n as pluginCatalogRuntime } from "../catalog-runtime-hKmI-iZa.js";
3
+ import { d as setPlugins, f as validatePlugins, ft as createPluginLogger } from "../agent-hooks-CDVx26Uu.js";
4
+ import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-LzIilOb6.js";
5
5
  import { a as pluginRuntimeRegistrationsFromPluginSet, i as pluginCliRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "../plugins-egKWjgue.js";
6
6
  import { t as loadAppPluginSet } from "../plugin-module-CVvEUSMH.js";
7
7
  import { stderr, stdout } from "node:process";
@@ -1,6 +1,6 @@
1
- import { n as pluginCatalogRuntime } from "../catalog-runtime-Br8s-TYx.js";
2
- import { S as disconnectStateAdapter, t as create } from "../profile-p1oiViVs.js";
3
- import { r as resolve } from "../resolve-CtWKGuKE.js";
1
+ import { n as pluginCatalogRuntime } from "../catalog-runtime-hKmI-iZa.js";
2
+ import { S as disconnectStateAdapter, t as create } from "../profile-DnkX3e2S.js";
3
+ import { r as resolve } from "../resolve-jfNHtEBx.js";
4
4
  //#region src/cli/snapshot-create.ts
5
5
  const DEFAULT_RUNTIME = "node22";
6
6
  const DEFAULT_TIMEOUT_MS = 6e5;
@@ -1,6 +1,6 @@
1
- import { i as getChatConfig } from "../config-B7joRWt7.js";
2
- import { t as createJuniorSqlExecutor } from "../executor-YL577nNt.js";
3
- import { t as createPluginCatalogRuntime } from "../registry-BO2LM2oW.js";
1
+ import { i as getChatConfig } from "../config-BDAfLTI9.js";
2
+ import { t as createJuniorSqlExecutor } from "../executor-Dh4Ofsnx.js";
3
+ import { t as createPluginCatalogRuntime } from "../registry-CmKmKHpp.js";
4
4
  import { n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "../plugins-egKWjgue.js";
5
5
  import { t as loadAppPluginSet } from "../plugin-module-CVvEUSMH.js";
6
6
  import { basename, dirname, join, resolve } from "node:path";
@@ -1,5 +1,5 @@
1
- import { d as logException, g as serializeGenAiAttribute, i as extractGenAiUsageAttributes, m as normalizeGenAiFinishReason, p as logWarn, w as withSpan } from "./logging-B0QxCh3D.js";
2
- import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-0JuTT_OJ.js";
1
+ import { d as logException, g as serializeGenAiAttribute, i as extractGenAiUsageAttributes, m as normalizeGenAiFinishReason, p as logWarn, w as withSpan } from "./logging-D3aYP0aG.js";
2
+ import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-1ERtieuM.js";
3
3
  import { calculateCost, completeSimple, getEnvApiKey, getModels, registerApiProvider } from "@earendil-works/pi-ai/compat";
4
4
  import { stream as streamAnthropic, streamSimple as streamSimpleAnthropic } from "@earendil-works/pi-ai/api/anthropic-messages";
5
5
  import { createGatewayProvider } from "@ai-sdk/gateway";
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { S as toOptionalTrimmed, o as resolveGatewayModel } from "./client-CRVXpEWi.js";
3
- import { p as logWarn } from "./logging-B0QxCh3D.js";
2
+ import { S as toOptionalTrimmed, o as resolveGatewayModel } from "./client-Clj7onnT.js";
3
+ import { p as logWarn } from "./logging-D3aYP0aG.js";
4
4
  import { l as TURN_REASONING_LEVELS, s as modelProfileSchema, t as DEFAULT_MODEL_PROFILES, u as parseTurnReasoningLevel } from "./model-profile-BwU8mqwD.js";
5
5
  //#region src/chat/slack/emoji.ts
6
6
  const SLACK_EMOJI_NAME_RE = /^(?:[a-z0-9_+-]+)(?:::(?:skin-tone-[2-6]))?$/;
@@ -1,12 +1,12 @@
1
- import { It as startOAuthFlow, c as deleteMcpAuthSessionsForUserProvider, l as deleteMcpServerSessionId, u as deleteMcpStoredOAuthCredentials } from "./agent-runner-B4FMVbCs.js";
2
- import { D as deleteProviderIdentityForSlackUser, c as getConversationEventStore, f as getSqlExecutor } from "./viewer-CPxNfHWa.js";
3
- import { u as hasRequiredOAuthScope } from "./registry-BO2LM2oW.js";
4
- import { n as pluginCatalogRuntime } from "./catalog-runtime-Br8s-TYx.js";
5
- import { Q as getTurnRecord, Z as failTurnRecord, q as loadTurnCheckpoint } from "./tasks-DThIG7F-.js";
6
- import { w as getStateAdapter } from "./profile-p1oiViVs.js";
7
- import { a as getVercelConversationWorkQueue } from "./job-queue-CIhKXUE3.js";
8
- import { m as ensureConversationWake, w as requestConversationWork } from "./store-DIFp9K52.js";
9
- import { n as resolveTurnSessionRouting } from "./turn-session-routing-F5s728f0.js";
1
+ import { It as startOAuthFlow, c as deleteMcpAuthSessionsForUserProvider, l as deleteMcpServerSessionId, u as deleteMcpStoredOAuthCredentials } from "./agent-runner-Caiof09f.js";
2
+ import { D as deleteProviderIdentityForSlackUser, c as getConversationEventStore, f as getSqlExecutor } from "./viewer-Rnim7alE.js";
3
+ import { u as hasRequiredOAuthScope } from "./registry-CmKmKHpp.js";
4
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-hKmI-iZa.js";
5
+ import { G as loadTurnCheckpoint, X as getTurnRecord, Y as failTurnRecord } from "./tasks-dJooqiip.js";
6
+ import { w as getStateAdapter } from "./profile-DnkX3e2S.js";
7
+ import { a as getVercelConversationWorkQueue } from "./job-queue-BaCL36FY.js";
8
+ import { m as ensureConversationWake, w as requestConversationWork } from "./store-BashBewg.js";
9
+ import { n as resolveTurnSessionRouting } from "./turn-session-routing-BAh_qsBJ.js";
10
10
  import { z } from "zod";
11
11
  import { randomBytes, randomUUID } from "node:crypto";
12
12
  //#region src/chat/task-execution/authorized-turn.ts
@@ -1,4 +1,4 @@
1
- import { p as logWarn } from "./logging-B0QxCh3D.js";
1
+ import { p as logWarn } from "./logging-D3aYP0aG.js";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  //#region src/chat/conversation-privacy.ts
4
4
  const SAFE_METADATA_KEY_LIMIT = 20;
@@ -1,19 +1,19 @@
1
- import { Ft as resolveBaseUrl, Lt as createUserTokenStore, Nt as formatProviderLabel, Pt as parseOAuthStatePayload, _ as resolvePluginOAuthAccount, d as getMcpAuthSession, f as getMcpStoredOAuthCredentials, o as finalizeMcpAuthorization, p as putMcpStoredOAuthCredentials, s as deleteMcpAuthSession, x as lookupSlackUserProfile, xt as getMcpProviderErrorAttributes } from "./agent-runner-B4FMVbCs.js";
2
- import { f as escapeXml } from "./client-CRVXpEWi.js";
3
- import { d as logException, h as runBestEffort, p as logWarn } from "./logging-B0QxCh3D.js";
4
- import { a as getRuntimeMetadata, n as botConfig } from "./config-B7joRWt7.js";
1
+ import { Ft as resolveBaseUrl, Lt as createUserTokenStore, Nt as formatProviderLabel, Pt as parseOAuthStatePayload, _ as resolvePluginOAuthAccount, d as getMcpAuthSession, f as getMcpStoredOAuthCredentials, o as finalizeMcpAuthorization, p as putMcpStoredOAuthCredentials, s as deleteMcpAuthSession, x as lookupSlackUserProfile, xt as getMcpProviderErrorAttributes } from "./agent-runner-Caiof09f.js";
2
+ import { f as escapeXml } from "./client-Clj7onnT.js";
3
+ import { d as logException, h as runBestEffort, p as logWarn } from "./logging-D3aYP0aG.js";
4
+ import { a as getRuntimeMetadata, n as botConfig } from "./config-BDAfLTI9.js";
5
5
  import { f as parseSlackUserId } from "./actor-BTtLaeWy.js";
6
- import { A as upsertIdentity, f as getSqlExecutor, j as upsertLinkedIdentity } from "./viewer-CPxNfHWa.js";
6
+ import { A as upsertIdentity, f as getSqlExecutor, j as upsertLinkedIdentity } from "./viewer-Rnim7alE.js";
7
7
  import { i as homeDir } from "./package-discovery-BVvSnQBB.js";
8
- import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-BO2LM2oW.js";
9
- import { n as pluginCatalogRuntime } from "./catalog-runtime-Br8s-TYx.js";
10
- import { t as discoverSkills } from "./skills-DitcC3Vw.js";
11
- import { It as recordAuthenticationLinked, Lt as recordAuthorizationCompleted, Q as getTurnRecord, V as postSlackMessage } from "./tasks-DThIG7F-.js";
12
- import { Ht as getSlackClient } from "./agent-hooks-CvcbAtJH.js";
13
- import { E as acquireActiveLock, w as getStateAdapter } from "./profile-p1oiViVs.js";
14
- import { i as getConversationPendingAuth } from "./pending-auth-CwA1uLA9.js";
15
- import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-BQxkL7Xm.js";
16
- import { c as deleteWebAuthorization, f as wakeAuthorizedTurn, i as readConnectedOAuthTokens, p as wakePausedTurn } from "./connections-CGPYNw2B.js";
8
+ import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-CmKmKHpp.js";
9
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-hKmI-iZa.js";
10
+ import { t as discoverSkills } from "./skills-Dc-AMYi4.js";
11
+ import { Ft as recordAuthorizationCompleted, Pt as recordAuthenticationLinked, X as getTurnRecord, z as postSlackMessage } from "./tasks-dJooqiip.js";
12
+ import { Ht as getSlackClient } from "./agent-hooks-CDVx26Uu.js";
13
+ import { E as acquireActiveLock, w as getStateAdapter } from "./profile-DnkX3e2S.js";
14
+ import { i as getConversationPendingAuth } from "./pending-auth-D2t1Moxf.js";
15
+ import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-CsMC-ob0.js";
16
+ import { c as deleteWebAuthorization, f as wakeAuthorizedTurn, i as readConnectedOAuthTokens, p as wakePausedTurn } from "./connections-BC0RTejT.js";
17
17
  import { n as relayLocalOAuthCallback } from "./oauth-relay-CdCnu80W.js";
18
18
  import path from "node:path";
19
19
  import { z } from "zod";
@@ -1,7 +1,7 @@
1
- import { d as logException } from "./logging-B0QxCh3D.js";
1
+ import { d as logException } from "./logging-D3aYP0aG.js";
2
2
  import { g as startSpanManual } from "./sentry-CgWZM_kV.js";
3
- import "./config-B7joRWt7.js";
4
- import { a as juniorAgentInvocations, c as juniorIdentities, d as juniorDestinations, f as timestamptz, i as juniorAgentBindings, l as juniorUsers, s as juniorConversations } from "./agent-invocations-D_YoNnAn.js";
3
+ import "./config-BDAfLTI9.js";
4
+ import { a as juniorAgentInvocations, c as juniorIdentities, d as juniorDestinations, f as timestamptz, i as juniorAgentBindings, l as juniorUsers, s as juniorConversations } from "./agent-invocations-BY60iNw-.js";
5
5
  import { AsyncLocalStorage } from "node:async_hooks";
6
6
  import { sql } from "drizzle-orm";
7
7
  import { bigint, boolean, check, date, doublePrecision, foreignKey, index, integer, jsonb, pgTable, primaryKey, text, uniqueIndex, uuid } from "drizzle-orm/pg-core";
@@ -278,19 +278,6 @@ const juniorLocationConfigurations = pgTable("junior_location_configurations", {
278
278
  expiresAt: text("expires_at")
279
279
  }, (table) => [primaryKey({ columns: [table.locationId, table.key] })]);
280
280
  //#endregion
281
- //#region src/db/schema/event-automations.ts
282
- const juniorEventAutomations = pgTable("junior_event_tasks", {
283
- id: text("id").primaryKey(),
284
- teamId: text("team_id").notNull(),
285
- namespace: text("namespace").notNull(),
286
- identifier: text("identifier").notNull(),
287
- createdAtMs: bigint("created_at_ms", { mode: "number" }).notNull(),
288
- status: text("status").notNull().default("active"),
289
- statusReason: text("status_reason"),
290
- title: text("title"),
291
- task: jsonb("task_json").notNull()
292
- }, (table) => [index("junior_event_tasks_team_idx").on(table.teamId, table.createdAtMs, table.id).where(sql`${table.status} <> 'deleted'`), index("junior_event_tasks_match_idx").on(table.namespace, table.identifier, table.createdAtMs, table.id).where(sql`${table.status} <> 'deleted'`)]);
293
- //#endregion
294
281
  //#region src/db/schema/stats.ts
295
282
  /**
296
283
  * Daily named counters used by Junior and loaded plugins.
@@ -313,36 +300,6 @@ const juniorStats = pgTable("junior_stats", {
313
300
  ]
314
301
  })]);
315
302
  //#endregion
316
- //#region src/db/schema/automation-executions.ts
317
- const juniorAutomationExecutions = pgTable("junior_task_executions", {
318
- executionId: text("execution_id").notNull(),
319
- kind: text("kind").notNull(),
320
- namespace: text("namespace").notNull(),
321
- automationId: text("task_id").notNull(),
322
- conversationId: text("conversation_id"),
323
- executedAtMs: bigint("executed_at_ms", { mode: "number" }).notNull(),
324
- status: text("status").$type().notNull()
325
- }, (table) => [
326
- check("junior_task_executions_kind_check", sql`${table.kind} in ('scheduled', 'event')`),
327
- check("junior_task_executions_status_check", sql`${table.status} in ('blocked', 'completed', 'failed')`),
328
- primaryKey({
329
- name: "junior_task_executions_kind_namespace_execution_id_pk",
330
- columns: [
331
- table.kind,
332
- table.namespace,
333
- table.executionId
334
- ]
335
- }),
336
- foreignKey({
337
- name: "junior_task_executions_conversation_id_junior_conversations_conversation_id_fk",
338
- columns: [table.conversationId],
339
- foreignColumns: [juniorConversations.conversationId]
340
- }),
341
- index("junior_task_executions_task_time_idx").on(table.kind, table.namespace, table.automationId, table.executedAtMs),
342
- index("junior_task_executions_time_kind_idx").on(table.executedAtMs, table.kind),
343
- index("junior_task_executions_conversation_time_idx").on(table.conversationId, table.executedAtMs)
344
- ]);
345
- //#endregion
346
303
  //#region src/db/schema/automations.ts
347
304
  /**
348
305
  * One row per Automation of either kind. `record` holds the fields that have
@@ -356,8 +313,8 @@ const juniorAutomations = pgTable("junior_automations", {
356
313
  teamId: text("team_id").notNull(),
357
314
  channelId: text("channel_id").notNull(),
358
315
  creatorSlackUserId: text("creator_slack_user_id").notNull(),
359
- /** Provider identity that created a Scheduled automation. */
360
- creatorIdentityId: text("creator_identity_id"),
316
+ /** Junior identity that created the Automation. It decides ownership. */
317
+ creatorIdentityId: text("creator_identity_id").notNull().references(() => juniorIdentities.id),
361
318
  status: text("status").$type().notNull(),
362
319
  /** Why a run blocked this Automation, until its creator resumes it. */
363
320
  statusReason: text("status_reason"),
@@ -375,8 +332,7 @@ const juniorAutomations = pgTable("junior_automations", {
375
332
  check("junior_automations_record_check", sql`jsonb_typeof(${table.record}) = 'object'`),
376
333
  check("junior_automations_trigger_check", sql`(${table.kind} = 'scheduled' and ${table.namespace} is null and ${table.identifier} is null) or (${table.kind} = 'event' and ${table.namespace} is not null and ${table.identifier} is not null and ${table.nextRunAtMs} is null and ${table.runNowAtMs} is null and ${table.status} <> 'completed')`),
377
334
  index("junior_automations_team_idx").on(table.teamId, table.createdAtMs, table.id).where(sql`${table.status} <> 'deleted'`),
378
- index("junior_automations_creator_idx").on(table.teamId, table.creatorSlackUserId, table.createdAtMs, table.id),
379
- index("junior_automations_creator_identity_idx").on(table.creatorIdentityId, table.createdAtMs, table.id).where(sql`${table.creatorIdentityId} IS NOT NULL`),
335
+ index("junior_automations_creator_identity_idx").on(table.creatorIdentityId, table.createdAtMs, table.id),
380
336
  index("junior_automations_run_now_due_idx").on(table.runNowAtMs, table.createdAtMs, table.id).where(sql`${table.status} = 'active' AND ${table.runNowAtMs} IS NOT NULL`),
381
337
  index("junior_automations_next_run_due_idx").on(table.nextRunAtMs, table.createdAtMs, table.id).where(sql`${table.status} = 'active' AND ${table.nextRunAtMs} IS NOT NULL`),
382
338
  index("junior_automations_match_idx").on(table.namespace, table.identifier, table.createdAtMs, table.id).where(sql`${table.status} <> 'deleted'`)
@@ -413,7 +369,6 @@ const juniorAutomationRuns = pgTable("junior_automation_runs", {
413
369
  //#region src/db/schema/automation-versions.ts
414
370
  /** One saved Automation definition. Lifecycle and scheduler state are not versioned. */
415
371
  const juniorAutomationVersions = pgTable("junior_automation_versions", {
416
- kind: text("kind").$type(),
417
372
  automationId: text("automation_id").notNull(),
418
373
  /** Starts at 1 and increases by 1 for each saved definition change. */
419
374
  version: integer("version").notNull(),
@@ -421,45 +376,14 @@ const juniorAutomationVersions = pgTable("junior_automation_versions", {
421
376
  /** Slack principal that saved this definition. Null when unknown. */
422
377
  editedBy: jsonb("edited_by"),
423
378
  definition: jsonb("definition").notNull()
424
- }, (table) => [
425
- check("junior_automation_versions_kind_check", sql`${table.kind} in ('scheduled', 'event')`),
426
- primaryKey({
427
- name: "junior_automation_versions_pk",
428
- columns: [table.automationId, table.version]
429
- }),
430
- foreignKey({
431
- name: "junior_automation_versions_automation_id_fk",
432
- columns: [table.automationId],
433
- foreignColumns: [juniorAutomations.id]
434
- }).onDelete("cascade")
435
- ]);
436
- //#endregion
437
- //#region src/db/schema/scheduled-automations.ts
438
- const juniorSchedulerTasks = pgTable("junior_scheduler_tasks", {
439
- id: text("id").primaryKey(),
440
- teamId: text("team_id").notNull(),
441
- creatorSlackUserId: text("creator_slack_user_id"),
442
- creatorIdentityId: text("creator_identity_id"),
443
- status: text("status").notNull(),
444
- nextRunAtMs: bigint("next_run_at_ms", { mode: "number" }),
445
- runNowAtMs: bigint("run_now_at_ms", { mode: "number" }),
446
- createdAtMs: bigint("created_at_ms", { mode: "number" }).notNull(),
447
- title: text("title"),
448
- record: jsonb("record").notNull()
449
- }, (table) => [
450
- index("junior_scheduler_tasks_creator_idx").on(table.teamId, table.creatorSlackUserId, table.createdAtMs, table.id).where(sql`${table.status} <> 'deleted'`),
451
- index("junior_scheduler_tasks_creator_identity_idx").on(table.creatorIdentityId, table.createdAtMs, table.id).where(sql`${table.status} <> 'deleted' AND ${table.creatorIdentityId} IS NOT NULL`),
452
- index("junior_scheduler_tasks_team_status_idx").on(table.teamId, table.createdAtMs, table.id).where(sql`${table.status} <> 'deleted'`),
453
- index("junior_scheduler_tasks_run_now_due_idx").on(table.runNowAtMs, table.createdAtMs, table.id).where(sql`${table.status} = 'active' AND ${table.runNowAtMs} IS NOT NULL`),
454
- index("junior_scheduler_tasks_next_run_due_idx").on(table.nextRunAtMs, table.createdAtMs, table.id).where(sql`${table.status} = 'active' AND ${table.nextRunAtMs} IS NOT NULL`)
455
- ]);
456
- const juniorSchedulerRuns = pgTable("junior_scheduler_runs", {
457
- id: text("id").primaryKey(),
458
- taskId: text("task_id").notNull(),
459
- status: text("status").notNull(),
460
- scheduledForMs: bigint("scheduled_for_ms", { mode: "number" }).notNull(),
461
- record: jsonb("record").$type().notNull()
462
- }, (table) => [index("junior_scheduler_runs_task_status_idx").on(table.taskId, table.status, table.scheduledForMs), index("junior_scheduler_runs_status_idx").on(table.status, table.scheduledForMs)]);
379
+ }, (table) => [primaryKey({
380
+ name: "junior_automation_versions_pk",
381
+ columns: [table.automationId, table.version]
382
+ }), foreignKey({
383
+ name: "junior_automation_versions_automation_id_fk",
384
+ columns: [table.automationId],
385
+ foreignColumns: [juniorAutomations.id]
386
+ }).onDelete("cascade")]);
463
387
  //#endregion
464
388
  //#region src/db/schema/workspaces.ts
465
389
  /** Named recipe used to prepare a reusable Sandbox. */
@@ -534,16 +458,12 @@ const juniorSqlSchema = {
534
458
  juniorConversations,
535
459
  juniorLocationConfigurations,
536
460
  juniorDestinations,
537
- juniorEventAutomations,
538
461
  juniorIdentities,
539
462
  juniorSnapshots,
540
463
  juniorStats,
541
- juniorAutomationExecutions,
542
464
  juniorAutomationRuns,
543
465
  juniorAutomationVersions,
544
466
  juniorAutomations,
545
- juniorSchedulerRuns,
546
- juniorSchedulerTasks,
547
467
  juniorUsers,
548
468
  juniorWorkspaceRepos,
549
469
  juniorWorkspaces
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { D as storeAttachment, T as readLiveAttachment } from "./agent-runner-B4FMVbCs.js";
3
- import { f as getSqlExecutor } from "./viewer-CPxNfHWa.js";
2
+ import { D as storeAttachment, T as readLiveAttachment } from "./agent-runner-Caiof09f.js";
3
+ import { f as getSqlExecutor } from "./viewer-Rnim7alE.js";
4
4
  import { L as detectImageMediaType } from "./conversation-T18Xlkx9.js";
5
5
  //#region src/chat/attachments/images.ts
6
6
  var images_exports = /* @__PURE__ */ __exportAll({
@@ -1,6 +1,6 @@
1
- import { N as getDeploymentServiceVersion, P as getDeploymentTelemetryAttributes } from "./logging-B0QxCh3D.js";
1
+ import { N as getDeploymentServiceVersion, P as getDeploymentTelemetryAttributes } from "./logging-D3aYP0aG.js";
2
2
  import { _ as vercelAIIntegration, a as getClient, b as withStreamedSpan, c as init, o as getGlobalScope } from "./sentry-CgWZM_kV.js";
3
- import { n as getCurrentConversationPrivacy } from "./conversation-privacy-0JuTT_OJ.js";
3
+ import { n as getCurrentConversationPrivacy } from "./conversation-privacy-1ERtieuM.js";
4
4
  import { t as consumePrivateTraceResultMarker } from "./private-trace-result-BLvBjy_e.js";
5
5
  //#region src/chat/sentry-payload-filter.ts
6
6
  const PAYLOAD_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([
@@ -1,4 +1,4 @@
1
- import { i as getChatConfig } from "./config-B7joRWt7.js";
1
+ import { i as getChatConfig } from "./config-BDAfLTI9.js";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  import { z } from "zod";
4
4
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
@@ -1,5 +1,5 @@
1
1
  import { d as setTag, f as setUser, h as startSpan, i as getActiveSpan, l as logger, n as captureMessage, p as spanToJSON, s as getTraceData, t as captureException, y as withScope } from "./sentry-CgWZM_kV.js";
2
- import { t as JUNIOR_VERSION } from "./version-B80CD9sN.js";
2
+ import { t as JUNIOR_VERSION } from "./version-CDM8Rq6E.js";
3
3
  import path from "node:path";
4
4
  import { styleText } from "node:util";
5
5
  import { ConfigError, configureSync, getConfig, getLogger } from "@logtape/logtape";
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { Ht as toolInvocationDestination, Q as getActiveAgentInvocationForConversation, Vt as actorFromRun, Y as createAgentInvocationForMessage, Z as findChildAgentConversationId, _t as AgentMessageTargetError, vt as PARENT_AGENT_TARGET } from "./agent-runner-B4FMVbCs.js";
3
- import { n as enqueueAgentMessageToParent } from "./result-DR5JTBcb.js";
4
- import { r as enqueueAgentInvocation } from "./work-Dl5KPKjW.js";
2
+ import { Ht as toolInvocationDestination, Q as getActiveAgentInvocationForConversation, Vt as actorFromRun, Y as createAgentInvocationForMessage, Z as findChildAgentConversationId, _t as AgentMessageTargetError, vt as PARENT_AGENT_TARGET } from "./agent-runner-Caiof09f.js";
3
+ import { n as enqueueAgentMessageToParent } from "./result-Df5nEDX2.js";
4
+ import { r as enqueueAgentInvocation } from "./work-BAn43SsN.js";
5
5
  //#region src/chat/agent-invocations/message.ts
6
6
  var message_exports = /* @__PURE__ */ __exportAll({ bindMessageAgent: () => bindMessageAgent });
7
7
  /**