@sentry/junior 0.309.0 → 0.311.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 (117) hide show
  1. package/dist/adapter-B1wujchl.js +259 -0
  2. package/dist/{adapter-context-1YUbMpD3.js → adapter-context-G2M0y6rP.js} +2 -2
  3. package/dist/{admin-u30A8TcD.js → admin-DCiBhUT1.js} +1 -2
  4. package/dist/{agent-runner-sJLhgPQV.js → agent-runner-BVHPUIc8.js} +695 -1817
  5. package/dist/api/schema.d.ts +2 -2
  6. package/dist/api/schema.js +8 -7
  7. package/dist/api.d.ts +21 -3
  8. package/dist/api.js +1479 -372
  9. package/dist/{app-B_7Wn0en.d.ts → app-Cw5Vy6H6.d.ts} +14 -3
  10. package/dist/app.d.ts +2 -2
  11. package/dist/app.js +233 -506
  12. package/dist/{background-compaction-queue-CUJXVKG3.js → background-compaction-queue-CJDnWVOJ.js} +4 -4
  13. package/dist/{briefs-BHi70IR5.js → briefs-BDjnug6Y.js} +3 -3
  14. package/dist/{catalog-runtime-Chc_IP2o.js → catalog-runtime-DMY3VV-D.js} +1 -1
  15. package/dist/cli/chat.js +16 -16
  16. package/dist/cli/check.js +23 -29
  17. package/dist/cli/init.js +1 -6
  18. package/dist/cli/main.js +3 -3
  19. package/dist/cli/plugins.js +8 -7
  20. package/dist/cli/snapshot-create.js +5 -5
  21. package/dist/cli/upgrade.d.ts +1 -1
  22. package/dist/cli/upgrade.js +3 -3
  23. package/dist/{config-BIyIdTtA.js → config-BrXDQefC.js} +239 -5
  24. package/dist/{continue-in-slack-BQJBfiQh.js → continue-in-slack-DNXSC9So.js} +6 -5
  25. package/dist/{conversation-CzrLhdHG.js → conversation-ca__NDQW.js} +48 -9
  26. package/dist/{conversation-feed-B9e3_gxz.js → conversation-feed-DkinDu5o.js} +15 -6
  27. package/dist/{conversation-privacy-CkTW29hd.js → conversation-privacy-DxttrKb9.js} +1 -1
  28. package/dist/{conversation-turn-CZaYQUum.js → conversation-turn-DWw7Xhdr.js} +42 -39
  29. package/dist/{credential-sync-58m_CyIJ.js → credential-sync-Bk8wGb8Y.js} +15 -16
  30. package/dist/{db-B4Hjxr-u.d.ts → db-7ETESH44.d.ts} +3 -1
  31. package/dist/{db-CFUpEZi9.js → db-DTxzH7u5.js} +1618 -1041
  32. package/dist/{executor-DXL0O0MV.js → executor-DqTiYj9S.js} +454 -96
  33. package/dist/{history-N7IVbUom.js → history-CYstOMKX.js} +6 -0
  34. package/dist/{html-CaBu2VbT.js → html-B9Sl4Axb.js} +6 -6
  35. package/dist/{install-DhTBUUov.js → install-Sg4ePfLl.js} +2 -2
  36. package/dist/instrumentation.js +3 -3
  37. package/dist/{lineage-CxtOI2_p.js → lineage-BHAMpNKr.js} +2 -2
  38. package/dist/{logging-BNUovdcX.js → logging-FjclQsXu.js} +47 -9
  39. package/dist/{message-DcUsS2vg.js → message-CJ7_RL50.js} +5 -8
  40. package/dist/{model-input-o3rEqgwM.js → model-input-CMLh4Cwq.js} +3 -3
  41. package/dist/nitro.d.ts +1 -1
  42. package/dist/nitro.js +3 -3
  43. package/dist/{oauth-callback-server-1Fizd1EM.js → oauth-callback-server-RVcbiDjL.js} +2 -2
  44. package/dist/{oauth-relay-DOwngqdM.js → oauth-relay-Bu9kkaQu.js} +1 -1
  45. package/dist/{projection-Ce4pmhKP.js → projection-Cns7XwWa.js} +9206 -5318
  46. package/dist/{prompt-DEqjDVMs.js → prompt-CDqcsDYC.js} +4 -4
  47. package/dist/{registry-CNE4ZBnG.js → registry-BPwuOP2O.js} +5 -8
  48. package/dist/{resolve-qbPg-aC-.js → resolve-BK29bBry.js} +3 -3
  49. package/dist/rule-DAxQY-1h.js +20 -0
  50. package/dist/{runner-eGIxpAMf.js → runner-BcAE-cJm.js} +10 -10
  51. package/dist/{sandbox-egress-signals-DMFB1kCp.js → sandbox-egress-signals-C-q0go5b.js} +1 -1
  52. package/dist/{schedule-Cire6NU7.js → schedule-BLJ476XQ.js} +209 -43
  53. package/dist/{schema-CfIey9Ao.js → schema-BLgSZXcL.js} +255 -49
  54. package/dist/{schema-DriSvB40.d.ts → schema-DYcJeV7d.d.ts} +701 -62
  55. package/dist/{service-account-Cw_LWZ4-.js → service-account-gN0zqf0S.js} +68 -68
  56. package/dist/{service-account-B1VXCTqg.js → service-account-iJoCtkHR.js} +3 -3
  57. package/dist/{skills-Zg8-vrje.js → skills-BoZ80epJ.js} +77 -31
  58. package/dist/{slack-conversation-unfurl-DA51qH0c.js → slack-conversation-unfurl-CogYrITA.js} +8 -10
  59. package/dist/{spawn-DBi4-zD8.js → spawn-Dk92r7mX.js} +5 -6
  60. package/dist/{state-C-Ftk23K.js → state-DH3Cmgp3.js} +4 -4
  61. package/dist/{stop-D9xideLM.js → stop-CYsfc0Ed.js} +1064 -314
  62. package/dist/{store-BjIXA0Al.js → store-DmmMIrQi.js} +5 -5
  63. package/dist/{task-queue-D0_qbnpo.js → task-queue-C_zldF5J.js} +3 -3
  64. package/dist/{task-runner-DQMq4XY0.js → task-runner-C7oCJQIx.js} +21 -14
  65. package/dist/{thread-context-D0i1e-5O.js → thread-context-BW2BsQbH.js} +13 -11
  66. package/dist/{turn-session-routing-C0l68I_O.js → turn-session-routing-Xh_2nSQe.js} +52 -54
  67. package/dist/{validation-CRbvRPvu.js → validation-DrJd0nnq.js} +1 -1
  68. package/dist/{version-BYdVs12p.js → version-CNKZ8owc.js} +1 -1
  69. package/dist/version.js +1 -1
  70. package/dist/{warmup-DN9OHN1-.js → warmup-BWdHew2H.js} +14289 -7197
  71. package/dist/{web-message-id-BT8Mg8LL.js → web-message-id-Ch5dPq-a.js} +32 -144
  72. package/dist/{worker-C9ZfJXmV.js → worker-t9qpu_Zx.js} +7 -8
  73. package/migrations/0124_artifact_visibility.sql +9 -0
  74. package/migrations/0125_artifact_public_sha_index.sql +1 -0
  75. package/migrations/0126_artifact_drop_public.sql +8 -0
  76. package/migrations/0127_artifact_path.sql +4 -0
  77. package/migrations/0128_artifact_path_index.sql +1 -0
  78. package/migrations/0129_review_item_answered_index.sql +1 -0
  79. package/migrations/0130_review_item_status_index.sql +1 -0
  80. package/migrations/0131_brief_outcome_status.sql +1 -0
  81. package/migrations/0132_brief_outcome_status_backfill.sql +7 -0
  82. package/migrations/0133_brief_created_at_index.sql +1 -0
  83. package/migrations/0134_slack_person_search_index.sql +1 -0
  84. package/migrations/0135_code_change_size.sql +3 -0
  85. package/migrations/0136_merge_conflict_notice_dismiss.sql +16 -0
  86. package/migrations/0137_inbox_snoozes.sql +27 -0
  87. package/migrations/0138_code_change_search_index.sql +2 -0
  88. package/migrations/0139_review_item_owner.sql +22 -0
  89. package/migrations/0140_review_item_owner_index.sql +1 -0
  90. package/migrations/0141_memory_core_adoption.sql +89 -0
  91. package/migrations/0142_memory_core_indexes.sql +17 -0
  92. package/migrations/meta/0124_snapshot.json +5516 -0
  93. package/migrations/meta/0125_snapshot.json +5516 -0
  94. package/migrations/meta/0126_snapshot.json +5488 -0
  95. package/migrations/meta/0127_snapshot.json +5519 -0
  96. package/migrations/meta/0128_snapshot.json +5519 -0
  97. package/migrations/meta/0129_snapshot.json +5547 -0
  98. package/migrations/meta/0130_snapshot.json +5563 -0
  99. package/migrations/meta/0131_snapshot.json +5569 -0
  100. package/migrations/meta/0132_snapshot.json +5569 -0
  101. package/migrations/meta/0133_snapshot.json +5590 -0
  102. package/migrations/meta/0134_snapshot.json +5606 -0
  103. package/migrations/meta/0135_snapshot.json +5624 -0
  104. package/migrations/meta/0136_snapshot.json +5624 -0
  105. package/migrations/meta/0137_snapshot.json +5864 -0
  106. package/migrations/meta/0138_snapshot.json +5894 -0
  107. package/migrations/meta/0139_snapshot.json +5898 -0
  108. package/migrations/meta/0140_snapshot.json +5919 -0
  109. package/migrations/meta/0141_snapshot.json +6429 -0
  110. package/migrations/meta/0142_snapshot.json +6457 -0
  111. package/migrations/meta/_journal.json +134 -1
  112. package/package.json +6 -7
  113. package/dist/result-ZGnDzcsb.js +0 -548
  114. package/dist/session-stop-P2XdTiwr.js +0 -4252
  115. package/dist/turn-user-message-nBVvOXjs.js +0 -364
  116. package/dist/users-DdjMjbmM.js +0 -181
  117. package/dist/viewer-DudYrQGj.js +0 -212
@@ -1,4 +1,4 @@
1
- import { a as conversationTurnFailureReasonSchema, h as usageSchema, i as conversationTurnFailureCodeSchema } from "./history-N7IVbUom.js";
1
+ import { a as conversationTurnFailureReasonSchema, h as usageSchema, i as conversationTurnFailureCodeSchema } from "./history-CYstOMKX.js";
2
2
  import * as z from "zod";
3
3
  import { codeChangeStateSchema, conversationAnnotationInputSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, objectFactFields, objectTypeSchema } from "@sentry/junior-plugin-api";
4
4
  // src/chat/attachments/input.ts
@@ -158,6 +158,16 @@ const conversationTitleSchema = z.string().trim().min(1).max(200);
158
158
  const renameConversationBodySchema = z.object({ title: conversationTitleSchema }).strict();
159
159
  /** The stored title after the rename. */
160
160
  const renameConversationResponseSchema = z.object({ title: z.string().min(1) }).strict();
161
+ // src/api/schema/conversation-tree-state.ts
162
+ /**
163
+ * What a Conversation and its child Conversations need, for one viewer.
164
+ * See "Viewer state" in `TERMINOLOGY.md`.
165
+ */
166
+ const conversationTreeStateSchema = z.enum([
167
+ "needs_you",
168
+ "working",
169
+ "done"
170
+ ]);
161
171
  // src/chat/briefs/schema.ts
162
172
  /**
163
173
  * Runtime schemas for the Brief record and the generator input. Both cross a
@@ -347,12 +357,30 @@ const objectPreviewImageSchema = z.object({
347
357
  src: z.string().startsWith("/api/images/"),
348
358
  srcSet: z.string().min(1)
349
359
  }).strict();
360
+ const CUT_TOKEN_RE = /<(?:[@#!][^<>]*|[a-z]+:[^\s<>|]*(?:\|[^<>]*)?|[a-z]*)$/i;
361
+ /**
362
+ * Cut preview text to the schema limit. The cut ends with "…" at a word
363
+ * break, and never leaves half a surrogate pair or an unclosed Slack token
364
+ * such as `<@U1` or `<https://…`, so mentions and links still parse.
365
+ */
366
+ function activityPreviewText(text) {
367
+ if (text.length <= 400) return text;
368
+ let cut = text.slice(0, 399);
369
+ const space = cut.search(/\s\S*$/);
370
+ if (space > 0 && /\S/.test(text[cut.length])) cut = cut.slice(0, space);
371
+ const last = cut.charCodeAt(cut.length - 1);
372
+ if (last >= 55296 && last <= 56319) cut = cut.slice(0, -1);
373
+ return `${cut.replace(CUT_TOKEN_RE, "").trimEnd()}…`;
374
+ }
350
375
  // src/api/schema/conversation.ts
376
+ /**
377
+ * The status of one Conversation's own work. See `TERMINOLOGY.md` and
378
+ * `conversationStatusSql`, the only place that derives it.
379
+ */
351
380
  const conversationReportStatusSchema = z.enum([
352
- "active",
353
- "completed",
354
- "failed",
355
- "stopped"
381
+ "needs_input",
382
+ "working",
383
+ "done"
356
384
  ]);
357
385
  /** Where a Conversation sits in its tree. See `TERMINOLOGY.md`. */
358
386
  const conversationKindSchema = z.enum([
@@ -498,7 +526,7 @@ const conversationActivityPreviewSchema = z.object({
498
526
  createdAt: z.string().datetime(),
499
527
  mentions: z.array(actorIdentitySchema).optional(),
500
528
  role: z.enum(["assistant", "user"]),
501
- text: z.string().min(1)
529
+ text: z.string().min(1).max(400)
502
530
  }).strict();
503
531
  const conversationSummaryReportSchema = z.object({
504
532
  displayTitle: z.string(),
@@ -514,6 +542,18 @@ const conversationSummaryReportSchema = z.object({
514
542
  isParticipant: z.boolean(),
515
543
  visibility: z.enum(["private", "public"]).optional(),
516
544
  status: conversationReportStatusSchema,
545
+ /** Feed rows and the detail only. */
546
+ treeState: conversationTreeStateSchema.optional(),
547
+ /**
548
+ * A Conversation in the tree has an active Watch or a pending Timer.
549
+ * Feed rows and the detail only.
550
+ */
551
+ watching: z.boolean().optional(),
552
+ /**
553
+ * A Turn is queued or running. Live views poll and show thinking on it,
554
+ * since `status` can read `needs_input` while a Turn runs.
555
+ */
556
+ turnActive: z.boolean(),
517
557
  startedAt: z.string(),
518
558
  lastSeenAt: z.string(),
519
559
  lastProgressAt: z.string(),
@@ -941,8 +981,7 @@ const conversationEventPageSchema = z.object({
941
981
  }).strict().superRefine(validateConversationEvents);
942
982
  /**
943
983
  * Carries the detail version token in both directions. A custom header, not
944
- * `ETag` / `If-None-Match`: in production the Vercel CDN answered standard
945
- * validators itself, after the function had already built the full report.
984
+ * `ETag`, for the reason on `CONTENT_VERSION_HEADER`.
946
985
  */
947
986
  const CONVERSATION_DETAIL_VERSION_HEADER = "x-junior-detail-version";
948
987
  /**
@@ -1021,4 +1060,4 @@ const conversationDetailReportSchema = conversationSummaryReportSchema.extend({
1021
1060
  sentryConversationUrl: z.string().optional(),
1022
1061
  sourceTask: conversationSourceTaskSchema.optional()
1023
1062
  }).strict().superRefine(validateConversationEvents);
1024
- export { inputFileSchema as $, agentTypeSchema as A, conversationTitleSchema as B, createConversationMessageBodySchema as C, conversationChildAgentTotalsSchema as D, idempotencyKeySchema as E, briefResourceLabel as F, annotationCard as G, renameConversationResponseSchema as H, conversationBriefSchema as I, readMessageCardRefs as J, messageCardRef as K, parseBriefInput as L, briefCodeChangeSchema as M, briefLinkSchema as N, AGENT_TYPES as O, briefOutcomeStatusSchema as P, MAX_INPUT_ATTACHMENTS as Q, parseStoredBrief as R, createConversationBodySchema as S, forkConversationResponseSchema as T, conversationReadPositionSchema as U, renameConversationBodySchema as V, reviewItemChangeRecordSchema as W, resolveMessageCards as X, removedCardSchema as Y, MAX_ATTACHMENT_BYTES as Z, conversationReportMessageEventSchema as _, conversationActivityPreviewSchema as a, conversationSurfaceSchema as b, conversationAuxiliaryCostsSchema as c, conversationEventHistorySchema as d, messageAttachmentSchema as et, conversationEventPageSchema as f, conversationReportEventSchema as g, conversationReportEventDataSchema as h, actorIdentitySchema as i, formatAgentTypes as j, agentTypeInstructions as k, conversationDetailQuerySchema as l, conversationParamsSchema as m, CONVERSATION_VERSION_HEADER as n, conversationAttachmentParamsSchema as o, conversationEventsQuerySchema as p, messageCardText as q, acceptedConversationMessageSchema as r, conversationAttachmentQuerySchema as s, CONVERSATION_DETAIL_VERSION_HEADER as t, readMessageAttachments as tt, conversationDetailReportSchema as u, conversationReportStatusSchema as v, forkConversationBodySchema as w, conversationUsageSchema as x, conversationSummaryReportSchema as y, CONVERSATION_TITLE_MAX_LENGTH as z };
1063
+ export { MAX_ATTACHMENT_BYTES as $, agentTypeInstructions as A, conversationTreeStateSchema as B, createConversationMessageBodySchema as C, activityPreviewText as D, idempotencyKeySchema as E, briefOutcomeStatusSchema as F, conversationReadPositionSchema as G, conversationTitleSchema as H, briefResourceLabel as I, messageCardRef as J, reviewItemChangeRecordSchema as K, conversationBriefSchema as L, formatAgentTypes as M, briefCodeChangeSchema as N, conversationChildAgentTotalsSchema as O, briefLinkSchema as P, resolveMessageCards as Q, parseBriefInput as R, createConversationBodySchema as S, forkConversationResponseSchema as T, renameConversationBodySchema as U, CONVERSATION_TITLE_MAX_LENGTH as V, renameConversationResponseSchema as W, readMessageCardRefs as X, messageCardText as Y, removedCardSchema as Z, conversationReportMessageEventSchema as _, conversationActivityPreviewSchema as a, conversationSurfaceSchema as b, conversationAuxiliaryCostsSchema as c, conversationEventHistorySchema as d, MAX_INPUT_ATTACHMENTS as et, conversationEventPageSchema as f, conversationReportEventSchema as g, conversationReportEventDataSchema as h, actorIdentitySchema as i, agentTypeSchema as j, AGENT_TYPES as k, conversationDetailQuerySchema as l, conversationParamsSchema as m, CONVERSATION_VERSION_HEADER as n, messageAttachmentSchema as nt, conversationAttachmentParamsSchema as o, conversationEventsQuerySchema as p, annotationCard as q, acceptedConversationMessageSchema as r, readMessageAttachments as rt, conversationAttachmentQuerySchema as s, CONVERSATION_DETAIL_VERSION_HEADER as t, inputFileSchema as tt, conversationDetailReportSchema as u, conversationReportStatusSchema as v, forkConversationBodySchema as w, conversationUsageSchema as x, conversationSummaryReportSchema as y, parseStoredBrief as z };
@@ -1,13 +1,12 @@
1
- import { P as briefOutcomeStatusSchema, W as reviewItemChangeRecordSchema, et as messageAttachmentSchema, i as actorIdentitySchema, u as conversationDetailReportSchema, y as conversationSummaryReportSchema } from "./conversation-CzrLhdHG.js";
1
+ import { F as briefOutcomeStatusSchema, K as reviewItemChangeRecordSchema, i as actorIdentitySchema, nt as messageAttachmentSchema, u as conversationDetailReportSchema, y as conversationSummaryReportSchema } from "./conversation-ca__NDQW.js";
2
2
  import * as z from "zod";
3
3
  // src/api/objects/cards.ts
4
4
  const MAX_LABEL_CHARS = 256;
5
5
  const MAX_FACT_CHARS = 160;
6
6
  const conversationStates = {
7
- active: "running",
8
- completed: "idle",
9
- failed: "failed",
10
- stopped: "stopped"
7
+ done: "done",
8
+ needs_input: "needs input",
9
+ working: "working"
11
10
  };
12
11
  function personName(person) {
13
12
  return person.fullName ?? person.slackUserName ?? person.email;
@@ -321,6 +320,14 @@ const conversationFeedMediaSchema = z.object({
321
320
  id: z.string().min(1)
322
321
  }).strict();
323
322
  /**
323
+ * The viewer's newest answer to a Review item that the Conversation added:
324
+ * when it closed and the options they picked. A text answer has no choices.
325
+ */
326
+ const conversationFeedViewerAnswerSchema = z.object({
327
+ choices: z.array(z.string()),
328
+ closedAt: z.string().datetime()
329
+ }).strict();
330
+ /**
324
331
  * A root in the feed, or one of its visible Threads. A Thread nests under
325
332
  * its nearest visible Thread ancestor, or under the root. Tasks never show.
326
333
  */
@@ -334,7 +341,9 @@ const conversationFeedItemSchema = conversationSummaryReportSchema.extend({
334
341
  links: z.array(z.url()).max(3).optional(),
335
342
  /** Only with `include=media`. */
336
343
  media: z.array(conversationFeedMediaSchema).max(3).optional(),
337
- threads: z.lazy(() => z.array(conversationFeedItemSchema)).optional()
344
+ threads: z.lazy(() => z.array(conversationFeedItemSchema)).optional(),
345
+ /** Only on the viewer's own feed. */
346
+ viewerAnswer: conversationFeedViewerAnswerSchema.optional()
338
347
  });
339
348
  const conversationFeedSchema = z.object({
340
349
  conversations: z.array(conversationFeedItemSchema),
@@ -1,4 +1,4 @@
1
- import { h as logWarn } from "./logging-BNUovdcX.js";
1
+ import { h as logWarn } from "./logging-FjclQsXu.js";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  import { renderSystemMessageUpdate } from "@earendil-works/pi-ai";
4
4
  // src/chat/conversation-privacy.ts
@@ -1,22 +1,20 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { A as normalizeConversationText, Ho as readConversationAutomationRun, Jo as getDispatchIdForConversation, Ks as blockScheduledAutomation, Mi as verifyTimerWatchCredentialSubject, O as latestConversationMessageSeq, P as upsertConversationMessage, a as loadProjection, at as getTurnRecord, b as persistConversationMessages, cn as getAssistantReplyText, et as saveTurnCheckpoint, j as recordDeliveredAssistantMessage, k as markConversationMessage, os as notifyAutomationBlocked, pc as blockEventAutomation, rt as failTurnRecord, t as commitAcceptedReply, v as hydrateConversationMessages, vn as persistWithRetry } from "./projection-Ce4pmhKP.js";
3
- import { E as isTopLevelKind, T as isPersonInput, a as getConversationStore, k as turnBehavior, o as getDb, r as getConversationEventStore } from "./db-CFUpEZi9.js";
4
- import { E as withSpan, S as setTags, h as logWarn, p as logException } from "./logging-BNUovdcX.js";
5
- import { tt as readMessageAttachments } from "./conversation-CzrLhdHG.js";
6
- import { L as finalizeFailedTurnReplyWithEvent, O as isConversationDeliveryPaused, i as measureTurnCompactionWait } from "./agent-runner-sJLhgPQV.js";
7
- import { a as buildDeliveredTurnStatePatch, o as loadPendingMessageCards, r as completeAuthPauseTurn, t as buildTurnThreadContext } from "./thread-context-D0i1e-5O.js";
8
- import { Dn as supersedeOpenMailboxTurns, Dt as resolveConversationDestination, Hn as AgentRunError, Un as executeTurn, _n as completeCancelledConversationTurn, nn as childAgentTurnOptions, on as readParentMessage, rn as isParentMessageMeta, zn as createWebAuthorization } from "./warmup-DN9OHN1-.js";
9
- import { _ as ConversationTurnLifecycleService, d as isTurnInputCommitLostError, g as startActiveTurn, h as markTurnFailed, l as getConversationTurnBoundaryError, s as TurnInputCommitLostError, t as getTurnUserMessage, z as buildDeterministicTurnId } from "./turn-user-message-nBVvOXjs.js";
10
- import { p as credentialContextForActor } from "./registry-CNE4ZBnG.js";
2
+ import { A as latestConversationMessageSeq, Bs as blockEventAutomation, I as upsertConversationMessage, M as normalizeConversationText, N as recordDeliveredAssistantMessage, No as notifyAutomationBlocked, S as persistConversationMessages, at as failTurnRecord, b as hydrateConversationMessages, dn as getAssistantReplyText, ho as readConversationAutomationRun, j as markConversationMessage, nt as saveTurnCheckpoint, o as loadProjection, pi as verifyTimerWatchCredentialSubject, st as getTurnRecord, t as commitAcceptedReply, xn as persistWithRetry, xo as getDispatchIdForConversation, ys as blockScheduledAutomation } from "./projection-Cns7XwWa.js";
3
+ import { D as isPersonInput, P as turnBehavior, a as getConversationStore, k as isTopLevelKind, o as getDb, r as getConversationEventStore } from "./db-DTxzH7u5.js";
4
+ import { E as withSpan, S as setTags, h as logWarn, p as logException } from "./logging-FjclQsXu.js";
5
+ import { rt as readMessageAttachments } from "./conversation-ca__NDQW.js";
6
+ import { E as isConversationDeliveryPaused, F as finalizeFailedTurnReplyWithEvent } from "./agent-runner-BVHPUIc8.js";
7
+ import { a as buildDeliveredTurnStatePatch, o as loadPendingMessageCards, r as completeAuthPauseTurn, t as buildTurnThreadContext } from "./thread-context-BW2BsQbH.js";
8
+ import { $r as instructionActorFor, $t as sourceFromTurnInput, Er as getConversationTurnBoundaryError, Fr as executeTurn, Hn as getTurnUserMessage, Ir as ConversationTurnLifecycleService, Jr as loadReviewItemInput, Mn as childAgentTurnOptions, Mr as markTurnFailed, Nn as isParentMessageMeta, Nr as startActiveTurn, Or as isTurnInputCommitLostError, Pn as readParentMessage, Pr as AgentRunError, Qr as buildSteeringPiMessage, Vn as completeCancelledConversationTurn, Zt as getEventBatchDelayMs, _n as maybePostAutomatedTurnLimitNotice, an as renderEventBatchInputs, ei as instructionForInputs, en as turnInputFactsFromConversationMessage, h as measureTurnCompactionWait, hi as buildDeterministicTurnId, in as isEventMailboxMetadata, ni as turnRequestText, on as timerWatchCredentialSubject, pi as recordFinishedTurnForAutomatedLimit, qr as eventReviewItemInputs, ri as withoutSavedSteeringMessages, rn as eventBatchMessageMeta, sr as supersedeOpenMailboxTurns, tn as legacyWebMailboxMetadataSchema, wr as TurnInputCommitLostError, yr as createWebAuthorization, zt as resolveConversationDestination } from "./warmup-BWdHew2H.js";
9
+ import { p as credentialContextForActor } from "./registry-BPwuOP2O.js";
11
10
  import { i as getActiveSpan, r as continueTrace } from "./sentry-CPbZjomA.js";
12
- import { a as getPersistedThreadState, c as coerceThreadConversationState, i as getPersistedSandboxState, s as persistThreadStateById } from "./turn-session-routing-C0l68I_O.js";
13
- import { n as botConfig } from "./config-BIyIdTtA.js";
14
- import { B as renderEventBatchInputs, D as getEventBatchDelayMs, M as sourceFromTurnInput, N as turnInputFactsFromConversationMessage, P as legacyWebMailboxMetadataSchema, Q as maybePostAutomatedTurnLimitNotice, R as eventBatchMessageMeta, V as timerWatchCredentialSubject, c as loadReviewItemInput, f as buildSteeringPiMessage, g as withoutSavedSteeringMessages, m as instructionForInputs, p as instructionActorFor, s as eventReviewItemInputs, st as recordFinishedTurnForAutomatedLimit, z as isEventMailboxMetadata } from "./session-stop-P2XdTiwr.js";
15
- import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-DQMq4XY0.js";
11
+ import { a as getPersistedThreadState, c as coerceThreadConversationState, i as getPersistedSandboxState, s as persistThreadStateById } from "./turn-session-routing-Xh_2nSQe.js";
12
+ import { n as botConfig } from "./config-BrXDQefC.js";
13
+ import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-C7oCJQIx.js";
16
14
  import { t as mapBounded } from "./fan-out-Cod-yEHG.js";
17
- import { p as instructionProvenanceFor } from "./history-N7IVbUom.js";
18
- import { s as isEventConversationMessage } from "./prompt-DEqjDVMs.js";
19
- import { t as readConversationLineage } from "./lineage-CxtOI2_p.js";
15
+ import { p as instructionProvenanceFor } from "./history-CYstOMKX.js";
16
+ import { s as isEventConversationMessage } from "./prompt-CDqcsDYC.js";
17
+ import { t as readConversationLineage } from "./lineage-BHAMpNKr.js";
20
18
  import { isDeepStrictEqual } from "node:util";
21
19
  import { createHash } from "node:crypto";
22
20
  // src/chat/task-execution/turn-telemetry.ts
@@ -131,10 +129,7 @@ async function commitAssistantMessage(args) {
131
129
  async function webTurnInputs(messages) {
132
130
  const flat = (await mapBounded(messages, async (message) => {
133
131
  const reviewItem = await loadReviewItemInput(message.reviewItemChange);
134
- if (reviewItem) return [{
135
- kind: "runtime",
136
- text: reviewItem
137
- }];
132
+ if (reviewItem) return [reviewItem];
138
133
  const text = message.text.trim();
139
134
  return text ? [{
140
135
  kind: "person",
@@ -186,7 +181,7 @@ async function steeringMessageFromWeb(message, actor) {
186
181
  actor: instructionActorFor(actor),
187
182
  ...reviewItemInput ? { kind: "runtime" } : void 0,
188
183
  provenance: instructionProvenanceFor(actor),
189
- text: reviewItemInput ?? message.input.text.trim(),
184
+ text: reviewItemInput?.text ?? message.input.text.trim(),
190
185
  timestampMs: message.createdAtMs,
191
186
  ...storedAttachments.length ? { storedAttachments } : void 0
192
187
  };
@@ -309,10 +304,13 @@ function createConversationTurnWorker(agentRunner, deliverMessage, deliverToPare
309
304
  const messages = resolved.batch.map((entry) => entry.message);
310
305
  const firstMetadata = first.message.input.metadata;
311
306
  if (isEventMailboxMetadata(firstMetadata)) {
312
- inputs = renderEventBatchInputs(messages, await eventReviewItemInputs(messages)).map((text) => ({
307
+ const rendered = await eventReviewItemInputs(messages);
308
+ for (const { message, requestText } of resolved.batch) if (requestText) rendered.set(message.inboundMessageId, {
313
309
  kind: "runtime",
314
- text
315
- }));
310
+ text: message.input.text.trim(),
311
+ requestText
312
+ });
313
+ inputs = renderEventBatchInputs(messages, rendered);
316
314
  eventMeta = eventBatchMessageMeta(messages);
317
315
  } else {
318
316
  inputs = await webTurnInputs(messages.map((message) => message.input));
@@ -351,7 +349,8 @@ function createConversationTurnWorker(agentRunner, deliverMessage, deliverToPare
351
349
  userMessageId = userMessage.id;
352
350
  inputs = savedMessageIsEvent ? [{
353
351
  kind: "runtime",
354
- text: userMessage.text
352
+ text: userMessage.text,
353
+ ...userMessage.meta?.requestText ? { requestText: userMessage.meta.requestText } : void 0
355
354
  }] : await webTurnInputs(turnInputs.map((message) => ({
356
355
  reviewItemChange: message.meta?.reviewItemChanges?.[0],
357
356
  text: message.text
@@ -443,20 +442,24 @@ function createConversationTurnWorker(agentRunner, deliverMessage, deliverToPare
443
442
  replied: false
444
443
  }
445
444
  } : message);
446
- if (webInputMessages.length === 0) upsertConversationMessage(conversation, {
447
- id: userMessageId,
448
- role: "user",
449
- text: normalizeConversationText(text),
450
- createdAtMs: startedAtMs,
451
- author,
452
- ...authorIdentityId ? { authorIdentityId } : void 0,
453
- meta: {
454
- ...attachments.length ? { attachments } : void 0,
455
- explicitMention: true,
456
- replied: false,
457
- ...eventMeta
458
- }
459
- });
445
+ if (webInputMessages.length === 0) {
446
+ const requestText = turnRequestText({ instruction: instructionInputs });
447
+ upsertConversationMessage(conversation, {
448
+ id: userMessageId,
449
+ role: "user",
450
+ text: normalizeConversationText(text),
451
+ createdAtMs: startedAtMs,
452
+ author,
453
+ ...authorIdentityId ? { authorIdentityId } : void 0,
454
+ meta: {
455
+ ...attachments.length ? { attachments } : void 0,
456
+ explicitMention: true,
457
+ replied: false,
458
+ ...requestText ? { requestText } : void 0,
459
+ ...eventMeta
460
+ }
461
+ });
462
+ }
460
463
  await persistConversationMessages({
461
464
  conversation,
462
465
  conversationId: context.conversationId
@@ -1,22 +1,21 @@
1
- import { H as authorizationId, Sn as resolvePluginOAuthAccount, Ts as getSlackClient, Y as getConversationPendingAuth, at as getTurnRecord, bn as createUserTokenStore, d as recordAuthorizationCompleted, ia as resolveBaseUrl, na as formatProviderLabel, ps as postSlackMessage, ra as parseOAuthStatePayload, u as recordAuthenticationLinked } from "./projection-Ce4pmhKP.js";
2
- import { a as getRuntimeMetadata, n as botConfig } from "./config-BIyIdTtA.js";
1
+ import { Bi as resolveBaseUrl, Bo as postSlackMessage, Cn as createUserTokenStore, Qo as getSlackClient, Ri as formatProviderLabel, Tn as resolvePluginOAuthAccount, W as authorizationId, Z as getConversationPendingAuth, d as recordAuthenticationLinked, f as recordAuthorizationCompleted, st as getTurnRecord, zi as parseOAuthStatePayload } from "./projection-Cns7XwWa.js";
2
+ import { R as acquireActiveLock, a as getRuntimeMetadata, n as botConfig } from "./config-BrXDQefC.js";
3
3
  import { t as mapBounded } from "./fan-out-Cod-yEHG.js";
4
- import { W as isNativeIdentityProvider, _ as runBestEffort, h as logWarn, p as logException } from "./logging-BNUovdcX.js";
4
+ import { _ as runBestEffort, h as logWarn, p as logException, q as isNativeIdentityProvider } from "./logging-FjclQsXu.js";
5
5
  import { p as parseSlackUserId } from "./actor-BsBdxDXQ.js";
6
- import { H as findUserByVerifiedEmails, I as resolveActorIdentityId, et as getStateAdapter, it as acquireActiveLock, q as upsertLinkedIdentity, s as getSqlExecutor } from "./db-CFUpEZi9.js";
6
+ import { It as readIdentityById, Xt as resolveActorIdentityId, nn as findUserByVerifiedEmails, s as getSqlExecutor, sn as upsertLinkedIdentity } from "./db-DTxzH7u5.js";
7
+ import { i as getStateAdapter } from "./adapter-B1wujchl.js";
7
8
  import { i as homeDir } from "./package-discovery-DD9vencX.js";
8
- import { t as discoverSkills } from "./skills-Zg8-vrje.js";
9
- import { d as hasRequiredOAuthScope, n as buildOAuthTokenRequest, r as parseOAuthTokenResponse } from "./registry-CNE4ZBnG.js";
10
- import { n as pluginCatalogRuntime } from "./catalog-runtime-Chc_IP2o.js";
11
- import { o as finalizeMcpAuthorization } from "./agent-runner-sJLhgPQV.js";
12
- import { O as getMcpProviderErrorAttributes, S as putMcpStoredOAuthCredentials, f as deleteMcpAuthSession, g as getMcpAuthSession, v as getMcpStoredOAuthCredentials } from "./service-account-Cw_LWZ4-.js";
13
- import { o as readIdentityById } from "./viewer-DudYrQGj.js";
14
- import { d as readJuniorSecret } from "./task-queue-D0_qbnpo.js";
15
- import { Bn as deleteWebAuthorization, Mn as wakeAuthorizedTurn, Nn as wakePausedTurn } from "./warmup-DN9OHN1-.js";
16
- import { i as lookupSlackUserProfile } from "./users-DdjMjbmM.js";
17
- import { a as getPersistedThreadState, c as coerceThreadConversationState } from "./turn-session-routing-C0l68I_O.js";
18
- import { s as readConnectedOAuthTokens, t as escapeHtml, u as htmlCallbackResponse } from "./html-CaBu2VbT.js";
19
- import { n as relayLocalOAuthCallback } from "./oauth-relay-DOwngqdM.js";
9
+ import { t as discoverSkills } from "./skills-BoZ80epJ.js";
10
+ import { d as hasRequiredOAuthScope, n as buildOAuthTokenRequest, r as parseOAuthTokenResponse } from "./registry-BPwuOP2O.js";
11
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-DMY3VV-D.js";
12
+ import { i as finalizeMcpAuthorization } from "./agent-runner-BVHPUIc8.js";
13
+ import { O as getMcpProviderErrorAttributes, S as putMcpStoredOAuthCredentials, f as deleteMcpAuthSession, g as getMcpAuthSession, v as getMcpStoredOAuthCredentials } from "./service-account-gN0zqf0S.js";
14
+ import { d as readJuniorSecret } from "./task-queue-C_zldF5J.js";
15
+ import { br as deleteWebAuthorization, fr as wakeAuthorizedTurn, hn as lookupSlackUserProfile, pr as wakePausedTurn } from "./warmup-BWdHew2H.js";
16
+ import { a as getPersistedThreadState, c as coerceThreadConversationState } from "./turn-session-routing-Xh_2nSQe.js";
17
+ import { s as readConnectedOAuthTokens, t as escapeHtml, u as htmlCallbackResponse } from "./html-B9Sl4Axb.js";
18
+ import { n as relayLocalOAuthCallback } from "./oauth-relay-Bu9kkaQu.js";
20
19
  import * as z from "zod";
21
20
  import path from "node:path";
22
21
  import { createHmac, createSecretKey, timingSafeEqual } from "node:crypto";
@@ -1,4 +1,4 @@
1
- import "./schema-DriSvB40.js";
1
+ import "./schema-DYcJeV7d.js";
2
2
  import * as z from "zod";
3
3
  import "@earendil-works/pi-ai";
4
4
  import { Destination, Source, locationSchema } from "@sentry/junior-plugin-api";
@@ -100,6 +100,8 @@ interface Conversation {
100
100
  lastActivityAtMs: number;
101
101
  /** Immutable parent Conversation. */
102
102
  parentConversationId?: string;
103
+ /** Immutable root of the Conversation tree, read from storage. */
104
+ rootConversationId?: string;
103
105
  /**
104
106
  * When the Conversation was archived for everyone. Only archive, auto-archive,
105
107
  * pin, and a person's message write it; `upsertConversation` does not.