@sentry/junior 0.251.0 → 0.253.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 (59) hide show
  1. package/dist/{admin-Dth5-1lw.js → admin-CZnlnlg9.js} +1 -1
  2. package/dist/{agent-hooks-Ctw_jKaS.js → agent-hooks-CvcbAtJH.js} +8 -8
  3. package/dist/{agent-runner-dgQdPoGH.js → agent-runner-B4FMVbCs.js} +20 -20
  4. package/dist/api/schema.d.ts +32 -32
  5. package/dist/api.js +22 -22
  6. package/dist/app.js +122 -84
  7. package/dist/{assistant-reply-DBFRnZRx.js → assistant-reply-BU05IECs.js} +1 -1
  8. package/dist/{briefs-SDwPKduW.js → briefs-DyspoG90.js} +2 -2
  9. package/dist/{catalog-runtime-ulFceOA-.js → catalog-runtime-Br8s-TYx.js} +1 -1
  10. package/dist/cli/chat.js +15 -15
  11. package/dist/cli/check.js +3 -3
  12. package/dist/cli/main.js +2 -2
  13. package/dist/cli/plugins.js +4 -4
  14. package/dist/cli/snapshot-create.js +3 -3
  15. package/dist/cli/upgrade.js +3 -3
  16. package/dist/{client-DMt9kArs.js → client-CRVXpEWi.js} +2 -2
  17. package/dist/{config-iEOq080E.js → config-B7joRWt7.js} +2 -2
  18. package/dist/{connections-BFU6GarA.js → connections-CGPYNw2B.js} +9 -9
  19. package/dist/{conversation-privacy-yZhQHnBe.js → conversation-privacy-0JuTT_OJ.js} +1 -1
  20. package/dist/{credential-sync-GW0Rj57H.js → credential-sync-C-k3fnY5.js} +14 -14
  21. package/dist/{executor-BeH9LDKI.js → executor-YL577nNt.js} +88 -20
  22. package/dist/{images-hIXWwpRg.js → images-DopOctPc.js} +2 -2
  23. package/dist/instrumentation.js +2 -2
  24. package/dist/{job-queue-Bxlao6zL.js → job-queue-CIhKXUE3.js} +1 -1
  25. package/dist/{logging-BkI10z0D.js → logging-B0QxCh3D.js} +1 -1
  26. package/dist/{message-BUcVfXmK.js → message-DQvor8lM.js} +3 -3
  27. package/dist/nitro.js +3 -3
  28. package/dist/{oauth-callback-server-CYSEV35l.js → oauth-callback-server-BT7cSxBm.js} +2 -2
  29. package/dist/{pending-auth-h0B3FQEo.js → pending-auth-CwA1uLA9.js} +2 -2
  30. package/dist/{profile-AsD2uz0m.js → profile-p1oiViVs.js} +4 -4
  31. package/dist/{registry-CN2Nie72.js → registry-BO2LM2oW.js} +1 -1
  32. package/dist/{resolve-CrgwPWTS.js → resolve-CtWKGuKE.js} +2 -2
  33. package/dist/{result-Cokw_MYC.js → result-DR5JTBcb.js} +6 -6
  34. package/dist/{runner-D-VZlBb_.js → runner-BIxTJF9a.js} +9 -9
  35. package/dist/{sandbox-egress-signals-Sie51RW0.js → sandbox-egress-signals-DF3Pu813.js} +1 -1
  36. package/dist/{session-stop-DD0k0BXI.js → session-stop-BRq8Vxrr.js} +10 -10
  37. package/dist/{skills-CpyJJyqH.js → skills-DitcC3Vw.js} +2 -2
  38. package/dist/{spawn-DX3YjDtm.js → spawn-CHQ42PAo.js} +2 -2
  39. package/dist/{store-D-n2b2cI.js → store-DIFp9K52.js} +6 -6
  40. package/dist/{task-queue-Bj2hFpjr.js → task-queue-UAeJGLYM.js} +3 -3
  41. package/dist/{task-runner-B3g16wjr.js → task-runner-DwD-i2ta.js} +147 -131
  42. package/dist/{tasks-DDzBxMio.js → tasks-DThIG7F-.js} +136 -218
  43. package/dist/{thread-state-BlD6loX7.js → thread-state-BQxkL7Xm.js} +6 -6
  44. package/dist/{turn-failure-response-BRlfATgu.js → turn-failure-response-OAIxgzNh.js} +7 -7
  45. package/dist/{turn-lifecycle-hMCbr_Ah.js → turn-lifecycle-BAEJpjDI.js} +1 -1
  46. package/dist/{turn-session-routing-DLb6eQMT.js → turn-session-routing-F5s728f0.js} +1 -1
  47. package/dist/{validation-C2lG6yVH.js → validation-DFM4-vDr.js} +1 -1
  48. package/dist/{version-CyJ_kMe8.js → version-B80CD9sN.js} +1 -1
  49. package/dist/version.js +1 -1
  50. package/dist/{viewer-C8u1HAdN.js → viewer-CPxNfHWa.js} +3 -3
  51. package/dist/{web-input-DHgIfSwj.js → web-input-DIO177R0.js} +80 -121
  52. package/dist/{work-hoPN8qjl.js → work-Dl5KPKjW.js} +9 -9
  53. package/dist/{worker-CavJZxi8.js → worker-CJkE86Co.js} +5 -5
  54. package/migrations/0055_automations.sql +125 -0
  55. package/migrations/0056_automation_runs.sql +69 -0
  56. package/migrations/meta/0055_snapshot.json +3948 -0
  57. package/migrations/meta/0056_snapshot.json +4280 -0
  58. package/migrations/meta/_journal.json +14 -0
  59. 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-dgQdPoGH.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-BkI10z0D.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-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";
3
3
  import { n as captureMessage, r as continueTrace } from "./sentry-CgWZM_kV.js";
4
- import { t as JUNIOR_VERSION } from "./version-CyJ_kMe8.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-iEOq080E.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";
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-C8u1HAdN.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
8
  import { a as juniorAgentInvocations, d as juniorDestinations, i as juniorAgentBindings, s as juniorConversations } from "./agent-invocations-D_YoNnAn.js";
9
- import { _ as juniorConversationEvents, a as juniorSchedulerRuns, m as juniorConversationBriefs, o as juniorSchedulerTasks } from "./executor-BeH9LDKI.js";
10
- import { n as pluginCatalogRuntime } from "./catalog-runtime-ulFceOA-.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-DDzBxMio.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-Ctw_jKaS.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";
13
13
  import { W as annotationCard } from "./conversation-T18Xlkx9.js";
14
- import { O as withLock$1, w as getStateAdapter } from "./profile-AsD2uz0m.js";
15
- import { c as getThreadStopDecision } from "./pending-auth-h0B3FQEo.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-DD0k0BXI.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";
17
17
  import { n as getNextRunAtMs } from "./cadence-D00SCzT1.js";
18
- import { f as setSandboxResourceConfig, u as getSandboxResourceConfig } from "./resolve-CrgwPWTS.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-Bxlao6zL.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-D-n2b2cI.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
21
  import { D as scheduledRunSchema } from "./automation-gznOMaQ2.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-C2lG6yVH.js";
23
+ import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "./validation-DFM4-vDr.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-DHgIfSwj.js";
26
- import { a as confirmDispatchMailboxAppend, b as notifyAutomationBlocked, f as getPluginDispatchProjection, j as recordAutomationExecution, m as listPendingDispatchMailboxAppends, o as createOrGetDispatch, p as isTerminalDispatchStatus, s as getDispatchConversationId, t as processPluginTask, u as getDispatchRecord, v as markDispatchFailed } from "./task-runner-B3g16wjr.js";
27
- import { o as getAuthPausedConversationTurnId, t as enqueueAgentInvocationResult } from "./result-Cokw_MYC.js";
28
- import { r as enqueueAgentInvocation } from "./work-hoPN8qjl.js";
29
- import { s as coerceThreadConversationState } from "./thread-state-BlD6loX7.js";
30
- import { o as unlinkProvider } from "./connections-BFU6GarA.js";
31
- import { a as GET$4, i as publishAppHomeView, r as GET$5, t as receiveLocalOAuthCredential } from "./credential-sync-GW0Rj57H.js";
32
- import { a as registerVercelPluginTaskDevConsumer, n as createVercelPluginTaskCallback, s as queueCallback } from "./task-queue-Bj2hFpjr.js";
33
- import { t as processConversationWork } from "./worker-CavJZxi8.js";
34
- import { t as bindMessageAgent } from "./message-BUcVfXmK.js";
35
- import { t as bindSpawnAgent } from "./spawn-DX3YjDtm.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";
36
36
  import { createRequire } from "node:module";
37
37
  import { Hono } from "hono";
38
38
  import { z } from "zod";
@@ -343,6 +343,43 @@ async function getScheduledAutomationDispatch(id) {
343
343
  });
344
344
  }
345
345
  //#endregion
346
+ //#region src/chat/event-automations/runs.ts
347
+ /**
348
+ * Record a dispatched event automation run and link its Conversation when it
349
+ * exists. The dispatch can finish before this write, so a stored run, or a
350
+ * retry of the same Event, keeps the row it has.
351
+ */
352
+ async function recordEventAutomationRunStarted(db, args) {
353
+ await db.insert(juniorAutomationRuns).values({
354
+ id: args.dispatchId,
355
+ automationId: args.automationId,
356
+ conversationId: existingConversationId(getDispatchConversationId({ id: args.dispatchId })),
357
+ startedAtMs: args.nowMs,
358
+ status: "running"
359
+ }).onConflictDoNothing({ target: juniorAutomationRuns.id });
360
+ }
361
+ /**
362
+ * Settle running event automation runs whose dispatch has ended. A run whose
363
+ * dispatch record is gone fails.
364
+ */
365
+ async function settleEventAutomationRuns(db, nowMs) {
366
+ const runs = await db.select({
367
+ automationId: juniorAutomationRuns.automationId,
368
+ id: juniorAutomationRuns.id
369
+ }).from(juniorAutomationRuns).innerJoin(juniorAutomations, eq(juniorAutomations.id, juniorAutomationRuns.automationId)).where(and(eq(juniorAutomations.kind, "event"), eq(juniorAutomationRuns.status, "running")));
370
+ for (const run of runs) {
371
+ const dispatch = await getDispatchRecord(run.id);
372
+ const status = dispatch?.status ?? "failed";
373
+ if (status !== "blocked" && status !== "completed" && status !== "failed") continue;
374
+ await recordAutomationExecution(run.automationId, {
375
+ errorMessage: dispatch ? dispatch.errorMessage : "Event automation dispatch record is missing.",
376
+ executionId: run.id,
377
+ nowMs: dispatch?.updatedAtMs ?? nowMs,
378
+ status
379
+ });
380
+ }
381
+ }
382
+ //#endregion
346
383
  //#region src/chat/automations/reply-attribution.ts
347
384
  /** Name the Automation in the footer of the replies that its runs post. */
348
385
  function automationReplyAttribution(title) {
@@ -357,45 +394,56 @@ function automationReplyAttribution(title) {
357
394
  const PENDING_CLAIM_STALE_MS = 6e4;
358
395
  const MISSED_RUN_MAX_AGE_MS = 864e5;
359
396
  const INCOMPLETE_RUN_STATUSES = ["pending", "running"];
360
- const retainedScheduledRunSchema = scheduledRunSchema.extend({
361
- idempotencyKey: z.string().optional(),
362
- taskVersion: z.number().optional()
363
- }).strict();
364
- /** Decode a scheduler run row and remove retained legacy fields. */
397
+ /** Decode a Scheduled automation run row. Returns undefined for an invalid row. */
365
398
  function parseScheduledRunRow(row) {
366
- const parsed = retainedScheduledRunSchema.safeParse(row.record);
367
- if (!parsed.success) return void 0;
368
- const { idempotencyKey: _idempotencyKey, taskVersion: _taskVersion, ...run } = parsed.data;
369
- return run;
399
+ const parsed = scheduledRunSchema.safeParse({
400
+ id: row.id,
401
+ attempt: row.attempt,
402
+ claimedAtMs: row.claimedAtMs,
403
+ completedAtMs: row.completedAtMs ?? void 0,
404
+ dispatchId: row.dispatchId ?? void 0,
405
+ errorMessage: row.errorMessage ?? void 0,
406
+ resultMessageTs: row.resultMessageTs ?? void 0,
407
+ scheduledForMs: row.scheduledForMs,
408
+ startedAtMs: row.startedAtMs ?? void 0,
409
+ status: row.status,
410
+ taskId: row.automationId
411
+ });
412
+ return parsed.success ? parsed.data : void 0;
370
413
  }
371
414
  function present(value) {
372
415
  return value !== void 0;
373
416
  }
374
417
  async function readRun(db, runId) {
375
- const rows = await db.select({ record: juniorSchedulerRuns.record }).from(juniorSchedulerRuns).where(eq(juniorSchedulerRuns.id, runId)).limit(1);
418
+ const rows = await db.select().from(juniorAutomationRuns).where(eq(juniorAutomationRuns.id, runId)).limit(1);
376
419
  return rows[0] ? parseScheduledRunRow(rows[0]) : void 0;
377
420
  }
378
421
  async function writeRun(db, run) {
379
422
  const stored = scheduledRunSchema.parse(run);
380
- await db.insert(juniorSchedulerRuns).values({
381
- id: stored.id,
382
- record: stored,
423
+ const columns = {
424
+ attempt: stored.attempt,
425
+ automationId: stored.taskId,
426
+ claimedAtMs: stored.claimedAtMs,
427
+ completedAtMs: stored.completedAtMs ?? null,
428
+ conversationId: stored.dispatchId ? existingConversationId(getDispatchConversationId({ id: stored.dispatchId })) : null,
429
+ dispatchId: stored.dispatchId ?? null,
430
+ errorMessage: stored.errorMessage ?? null,
431
+ resultMessageTs: stored.resultMessageTs ?? null,
383
432
  scheduledForMs: stored.scheduledForMs,
384
- status: stored.status,
385
- taskId: stored.taskId
433
+ startedAtMs: stored.startedAtMs ?? null,
434
+ status: stored.status
435
+ };
436
+ await db.insert(juniorAutomationRuns).values({
437
+ id: stored.id,
438
+ ...columns
386
439
  }).onConflictDoUpdate({
387
- target: juniorSchedulerRuns.id,
388
- set: {
389
- record: sql`excluded.record`,
390
- scheduledForMs: sql`excluded.scheduled_for_ms`,
391
- status: sql`excluded.status`,
392
- taskId: sql`excluded.task_id`
393
- }
440
+ target: juniorAutomationRuns.id,
441
+ set: columns
394
442
  });
395
443
  }
396
444
  async function listIncompleteRunsForTaskIds(db, taskIds) {
397
445
  if (taskIds.length === 0) return [];
398
- return (await db.select({ record: juniorSchedulerRuns.record }).from(juniorSchedulerRuns).where(and(inArray(juniorSchedulerRuns.taskId, taskIds), inArray(juniorSchedulerRuns.status, [...INCOMPLETE_RUN_STATUSES]))).orderBy(asc(juniorSchedulerRuns.scheduledForMs), asc(juniorSchedulerRuns.id))).map(parseScheduledRunRow).filter(present);
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);
399
447
  }
400
448
  /** List incomplete runs for retained scheduled automations. */
401
449
  async function listIncompleteScheduledRuns(db) {
@@ -482,7 +530,7 @@ async function claimDueScheduledRun(db, args) {
482
530
  const skippedRuns = [];
483
531
  const claimed = await db.transaction(async (tx) => {
484
532
  await tx.execute(sql`SELECT pg_advisory_xact_lock(hashtext('junior:scheduler:claim'))`);
485
- const rows = await tx.select({ id: juniorSchedulerTasks.id }).from(juniorSchedulerTasks).where(and(eq(juniorSchedulerTasks.status, "active"), or(and(isNotNull(juniorSchedulerTasks.runNowAtMs), lte(juniorSchedulerTasks.runNowAtMs, args.nowMs)), and(isNotNull(juniorSchedulerTasks.nextRunAtMs), lte(juniorSchedulerTasks.nextRunAtMs, args.nowMs))))).orderBy(asc(juniorSchedulerTasks.createdAtMs), asc(juniorSchedulerTasks.id));
533
+ const rows = await tx.select({ id: juniorAutomations.id }).from(juniorAutomations).where(and(eq(juniorAutomations.kind, "scheduled"), eq(juniorAutomations.status, "active"), or(and(isNotNull(juniorAutomations.runNowAtMs), lte(juniorAutomations.runNowAtMs, args.nowMs)), and(isNotNull(juniorAutomations.nextRunAtMs), lte(juniorAutomations.nextRunAtMs, args.nowMs))))).orderBy(asc(juniorAutomations.createdAtMs), asc(juniorAutomations.id));
486
534
  for (const row of rows) {
487
535
  const run = await withScheduledAutomationLock(tx, row.id, async (taskTx) => {
488
536
  const task = await readScheduledAutomation(taskTx, row.id);
@@ -503,7 +551,16 @@ async function claimDueScheduledRun(db, args) {
503
551
  await writeRun(taskTx, reclaimed);
504
552
  return reclaimed;
505
553
  }
506
- if (await readRun(taskTx, runId)) return void 0;
554
+ const finishedRun = await readRun(taskTx, runId);
555
+ if (finishedRun) {
556
+ if (finishedRun.status === "blocked" || finishedRun.status === "completed" || finishedRun.status === "failed") await advanceScheduledAutomationAfterRun(taskTx, {
557
+ errorMessage: finishedRun.errorMessage,
558
+ nowMs: args.nowMs,
559
+ run: finishedRun,
560
+ status: finishedRun.status
561
+ });
562
+ return;
563
+ }
507
564
  if (scheduledForMs + MISSED_RUN_MAX_AGE_MS < args.nowMs) {
508
565
  const skipped = await skipMissedRun(taskTx, {
509
566
  nowMs: args.nowMs,
@@ -686,15 +743,6 @@ function shouldSkipRun(task, run) {
686
743
  if (task.status !== "active") return `Scheduled automation ${task.id} was ${task.status} before the run started.`;
687
744
  if (task.nextRunAtMs !== run.scheduledForMs && task.runNowAtMs !== run.scheduledForMs) return `Scheduled automation ${task.id} no longer targets ${new Date(run.scheduledForMs).toISOString()}.`;
688
745
  }
689
- async function recordScheduledExecution(args) {
690
- const dispatchId = args.run.dispatchId;
691
- await recordAutomationExecution("scheduled", args.run.taskId, {
692
- ...dispatchId ? { conversationId: getDispatchConversationId({ id: dispatchId }) } : void 0,
693
- executionId: args.run.id,
694
- nowMs: args.nowMs,
695
- status: args.status
696
- });
697
- }
698
746
  async function logRunOutcome(args) {
699
747
  const task = args.task ?? await readScheduledAutomation(args.db, args.run.taskId);
700
748
  if (!task) {
@@ -726,11 +774,6 @@ async function applyDispatchResult(args) {
726
774
  run: args.run,
727
775
  status: "completed"
728
776
  });
729
- await recordScheduledExecution({
730
- nowMs: args.nowMs,
731
- run: args.run,
732
- status: "completed"
733
- });
734
777
  await logRunOutcome({
735
778
  eventName: "scheduled_automation.run.completed",
736
779
  run: completed,
@@ -757,11 +800,6 @@ async function applyDispatchResult(args) {
757
800
  kind: "scheduled",
758
801
  reason: blocked.errorMessage ?? "Dispatch blocked."
759
802
  });
760
- await recordScheduledExecution({
761
- nowMs: args.nowMs,
762
- run: args.run,
763
- status: "blocked"
764
- });
765
803
  await logRunOutcome({
766
804
  eventName: "scheduled_automation.run.blocked",
767
805
  run: blocked,
@@ -784,11 +822,6 @@ async function applyDispatchResult(args) {
784
822
  run: args.run,
785
823
  status: "failed"
786
824
  });
787
- await recordScheduledExecution({
788
- nowMs: args.nowMs,
789
- run: args.run,
790
- status: "failed"
791
- });
792
825
  await logRunOutcome({
793
826
  eventName: "scheduled_automation.run.failed",
794
827
  run: failed,
@@ -821,11 +854,6 @@ async function finishClaimedRun(args) {
821
854
  kind: "scheduled",
822
855
  reason: args.errorMessage
823
856
  });
824
- await recordScheduledExecution({
825
- nowMs: args.nowMs,
826
- run: args.run,
827
- status: args.status
828
- });
829
857
  await logRunOutcome({
830
858
  eventName: args.status === "blocked" ? "scheduled_automation.run.blocked" : "scheduled_automation.run.failed",
831
859
  run: finished,
@@ -833,9 +861,13 @@ async function finishClaimedRun(args) {
833
861
  extras: { "app.task.run.error": args.errorMessage }
834
862
  });
835
863
  }
836
- /** Reconcile completed dispatches and enqueue a bounded batch of due tasks. */
864
+ /**
865
+ * Settle finished runs of both Automation kinds, then enqueue a bounded batch
866
+ * of due Scheduled automations.
867
+ */
837
868
  async function runScheduledAutomationHeartbeat(args) {
838
869
  const db = getDb();
870
+ await settleEventAutomationRuns(db, args.nowMs);
839
871
  let processedCount = 0;
840
872
  let dispatchCount = 0;
841
873
  for (const run of await listIncompleteScheduledRuns(db)) {
@@ -2060,7 +2092,7 @@ async function ingestEventAutomations(input, options) {
2060
2092
  allowedWhen: "event-automation",
2061
2093
  taskId: task.id
2062
2094
  } : void 0;
2063
- if ((await dispatchEventAutomation({
2095
+ const dispatch = await dispatchEventAutomation({
2064
2096
  conversationWorkQueue: options.queue,
2065
2097
  nowMs,
2066
2098
  options: {
@@ -2073,7 +2105,13 @@ async function ingestEventAutomations(input, options) {
2073
2105
  replyAttribution: automationReplyAttribution(task.title),
2074
2106
  outcomes
2075
2107
  }
2076
- })).status === "created") dispatched += 1;
2108
+ });
2109
+ await recordEventAutomationRunStarted(db, {
2110
+ automationId: task.id,
2111
+ dispatchId: dispatch.id,
2112
+ nowMs
2113
+ });
2114
+ if (dispatch.status === "created") dispatched += 1;
2077
2115
  } catch (error) {
2078
2116
  errors.push(error);
2079
2117
  }
@@ -1,4 +1,4 @@
1
- import { lt as extractAssistantText } from "./tasks-DDzBxMio.js";
1
+ import { lt as extractAssistantText } from "./tasks-DThIG7F-.js";
2
2
  //#region src/chat/no-reply.ts
3
3
  const NO_REPLY_MARKER = "[[NO_REPLY]]";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { r as completeObject } from "./client-DMt9kArs.js";
1
+ import { r as completeObject } from "./client-CRVXpEWi.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-iEOq080E.js").then((n) => n.r);
272
+ const { botConfig } = await import("./config-B7joRWt7.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-CN2Nie72.js";
2
+ import { t as createPluginCatalogRuntime } from "./registry-BO2LM2oW.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-dgQdPoGH.js";
1
+ import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-B4FMVbCs.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-Ctw_jKaS.js").then((n) => n.t),
104
- import("../catalog-runtime-ulFceOA-.js").then((n) => n.t),
105
- import("../validation-C2lG6yVH.js").then((n) => n.r),
106
- import("../viewer-C8u1HAdN.js").then((n) => n.s)
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)
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-Ctw_jKaS.js").then((n) => n.m);
158
+ const { setBriefsConfig } = await import("../agent-hooks-CvcbAtJH.js").then((n) => n.m);
159
159
  setBriefsConfig({ enabled: true });
160
- const { runLocalAgentTurn } = await import("../runner-D-VZlBb_.js");
161
- const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-CYSEV35l.js");
160
+ const { runLocalAgentTurn } = await import("../runner-BIxTJF9a.js");
161
+ const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-BT7cSxBm.js");
162
162
  const { createLocalOAuthState } = await import("../oauth-relay-CdCnu80W.js").then((n) => n.t);
163
- const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-Sie51RW0.js");
164
- const { bindSpawnAgent } = await import("../spawn-DX3YjDtm.js").then((n) => n.n);
165
- const { bindMessageAgent } = await import("../message-BUcVfXmK.js").then((n) => n.n);
166
- const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-hoPN8qjl.js").then((n) => n.a);
167
- const { startAgentInvocationsForChildInput } = await import("../result-Cokw_MYC.js").then((n) => n.r);
168
- const { skipInputBeforeConversationStop } = await import("../session-stop-DD0k0BXI.js").then((n) => n.r);
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);
169
169
  const { createLocalConversationWork } = await import("../conversation-work-C6y3T5Hx.js");
170
- const { processConversationWork } = await import("../worker-CavJZxi8.js").then((n) => n.n);
170
+ const { processConversationWork } = await import("../worker-CJkE86Co.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-BkI10z0D.js";
2
- import { _ as parsePluginManifest, g as parseInlinePluginManifest } from "../registry-CN2Nie72.js";
3
- import { i as parseSkillFile } from "../skills-CpyJJyqH.js";
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";
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-Dth5-1lw.js")).runAdmin(argv);
28
+ return await (await import("../admin-CZnlnlg9.js")).runAdmin(argv);
29
29
  }
30
30
  async function runBriefs(argv) {
31
- return await (await import("../briefs-SDwPKduW.js")).runBriefs(argv);
31
+ return await (await import("../briefs-DyspoG90.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-C8u1HAdN.js";
2
- import { n as pluginCatalogRuntime } from "../catalog-runtime-ulFceOA-.js";
3
- import { d as setPlugins, f as validatePlugins, ft as createPluginLogger } from "../agent-hooks-Ctw_jKaS.js";
4
- import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-C2lG6yVH.js";
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";
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-ulFceOA-.js";
2
- import { S as disconnectStateAdapter, t as create } from "../profile-AsD2uz0m.js";
3
- import { r as resolve } from "../resolve-CrgwPWTS.js";
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";
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-iEOq080E.js";
2
- import { t as createJuniorSqlExecutor } from "../executor-BeH9LDKI.js";
3
- import { t as createPluginCatalogRuntime } from "../registry-CN2Nie72.js";
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";
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-BkI10z0D.js";
2
- import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-yZhQHnBe.js";
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";
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-DMt9kArs.js";
3
- import { p as logWarn } from "./logging-BkI10z0D.js";
2
+ import { S as toOptionalTrimmed, o as resolveGatewayModel } from "./client-CRVXpEWi.js";
3
+ import { p as logWarn } from "./logging-B0QxCh3D.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-dgQdPoGH.js";
2
- import { D as deleteProviderIdentityForSlackUser, c as getConversationEventStore, f as getSqlExecutor } from "./viewer-C8u1HAdN.js";
3
- import { u as hasRequiredOAuthScope } from "./registry-CN2Nie72.js";
4
- import { n as pluginCatalogRuntime } from "./catalog-runtime-ulFceOA-.js";
5
- import { Q as getTurnRecord, Z as failTurnRecord, q as loadTurnCheckpoint } from "./tasks-DDzBxMio.js";
6
- import { w as getStateAdapter } from "./profile-AsD2uz0m.js";
7
- import { a as getVercelConversationWorkQueue } from "./job-queue-Bxlao6zL.js";
8
- import { m as ensureConversationWake, w as requestConversationWork } from "./store-D-n2b2cI.js";
9
- import { n as resolveTurnSessionRouting } from "./turn-session-routing-DLb6eQMT.js";
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";
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-BkI10z0D.js";
1
+ import { p as logWarn } from "./logging-B0QxCh3D.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-dgQdPoGH.js";
2
- import { f as escapeXml } from "./client-DMt9kArs.js";
3
- import { d as logException, h as runBestEffort, p as logWarn } from "./logging-BkI10z0D.js";
4
- import { a as getRuntimeMetadata, n as botConfig } from "./config-iEOq080E.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-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";
5
5
  import { f as parseSlackUserId } from "./actor-BTtLaeWy.js";
6
- import { A as upsertIdentity, f as getSqlExecutor, j as upsertLinkedIdentity } from "./viewer-C8u1HAdN.js";
6
+ import { A as upsertIdentity, f as getSqlExecutor, j as upsertLinkedIdentity } from "./viewer-CPxNfHWa.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-CN2Nie72.js";
9
- import { n as pluginCatalogRuntime } from "./catalog-runtime-ulFceOA-.js";
10
- import { t as discoverSkills } from "./skills-CpyJJyqH.js";
11
- import { It as recordAuthenticationLinked, Lt as recordAuthorizationCompleted, Q as getTurnRecord, V as postSlackMessage } from "./tasks-DDzBxMio.js";
12
- import { Ht as getSlackClient } from "./agent-hooks-Ctw_jKaS.js";
13
- import { E as acquireActiveLock, w as getStateAdapter } from "./profile-AsD2uz0m.js";
14
- import { i as getConversationPendingAuth } from "./pending-auth-h0B3FQEo.js";
15
- import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-BlD6loX7.js";
16
- import { c as deleteWebAuthorization, f as wakeAuthorizedTurn, i as readConnectedOAuthTokens, p as wakePausedTurn } from "./connections-BFU6GarA.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";
17
17
  import { n as relayLocalOAuthCallback } from "./oauth-relay-CdCnu80W.js";
18
18
  import path from "node:path";
19
19
  import { z } from "zod";