@sentry/junior 0.285.0 → 0.287.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 (78) hide show
  1. package/dist/{adapter-DN5AB4VU.js → adapter-CL-HUKgd.js} +1 -1
  2. package/dist/{admin-DOITMKnn.js → admin-C9urXVfi.js} +2 -1
  3. package/dist/{agent-runner-BsWhHe4N.js → agent-runner-Bfnw551N.js} +2174 -1323
  4. package/dist/api/schema.d.ts +2 -2
  5. package/dist/api/schema.js +7 -7
  6. package/dist/api.d.ts +1 -1
  7. package/dist/api.js +73 -112
  8. package/dist/{app-DyMs9330.d.ts → app-DBY5TnfY.d.ts} +2 -3
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +72 -42
  11. package/dist/{assistant-reply-9Jip5bsr.js → assistant-reply-u_PRYzuz.js} +1 -1
  12. package/dist/{automation-Mk8aaHzy.js → automation-DksGNDRO.js} +3 -6
  13. package/dist/{background-compaction-queue-DXkLsWoH.js → background-compaction-queue-CYI909P5.js} +137 -3
  14. package/dist/{briefs-Cl8-nK9B.js → briefs-DaXiMWzT.js} +6 -5
  15. package/dist/{catalog-runtime-Bte6jRB2.js → catalog-runtime-BCIuBe4d.js} +1 -1
  16. package/dist/cli/chat.js +14 -14
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/main.js +3 -3
  19. package/dist/cli/plugins.js +4 -4
  20. package/dist/cli/snapshot-create.js +5 -6
  21. package/dist/cli/upgrade.d.ts +1 -1
  22. package/dist/cli/upgrade.js +3 -3
  23. package/dist/{client-DDbBucBw.js → config-CkHcUMN7.js} +580 -3
  24. package/dist/{connections-DA4LT9LL.js → connections-BnIj0wtx.js} +16 -50
  25. package/dist/{conversation-D8kVoCrP.js → conversation-E7ZPJx2H.js} +22 -6
  26. package/dist/{conversation-pending-messages-BvROq1bq.js → conversation-pending-messages-DVch6YQw.js} +2 -5
  27. package/dist/{conversation-privacy-D0j_h70R.js → conversation-privacy-DF1hW0ja.js} +1 -1
  28. package/dist/{credential-sync-hcsYatw-.js → credential-sync-CzMar9hq.js} +13 -13
  29. package/dist/{viewer-1Ea81s0b.js → db-DJ11eZqq.js} +64 -367
  30. package/dist/{db-BhHZSuFw.d.ts → db-YDKKDxlh.d.ts} +4 -4
  31. package/dist/{executor-BLEMIgIZ.js → executor-BY9TB31g.js} +20 -19
  32. package/dist/instrumentation.js +2 -2
  33. package/dist/{logging-BfORLKoq.js → logging-BO5zU6Mt.js} +1 -1
  34. package/dist/{media-Bu9C6lz0.js → media-Cz1ZiV1U.js} +16 -4
  35. package/dist/{message-DqjuKzUx.js → message-CsUbuEc8.js} +10 -10
  36. package/dist/nitro.d.ts +1 -1
  37. package/dist/nitro.js +2 -3
  38. package/dist/{oauth-callback-server-CFSRzu1n.js → oauth-callback-server-hiDKK0_n.js} +2 -2
  39. package/dist/{projection-DliWYrnT.js → projection-CL_YWeGf.js} +352 -356
  40. package/dist/{prompt-BvIUzY4y.js → prompt-BHOEQSmf.js} +182 -2
  41. package/dist/{registry-rC7MCxu8.js → registry-BriFLnaJ.js} +1 -1
  42. package/dist/{reporting-window-B4TwyuJo.js → reporting-window-B3Ze-Qnt.js} +4 -1
  43. package/dist/{resolve-Biu8Qw3u.js → resolve-Bt6GgAiA.js} +3 -3
  44. package/dist/{result-DxJMCX47.js → result-Bo1TZu0Q.js} +8 -8
  45. package/dist/{runner-BQJSFLKg.js → runner-D3YeCQgt.js} +16 -12
  46. package/dist/{sandbox-egress-signals-6aMxJSDn.js → sandbox-egress-signals-CcnSPP4S.js} +1 -1
  47. package/dist/{schema-BasXTvi2.js → schema-BWE3RJEB.js} +19 -7
  48. package/dist/{schema-BUviRAs8.d.ts → schema-C6fsEwjo.d.ts} +90 -8
  49. package/dist/{service-account-BI5Wgx22.js → service-account-DiQQuuw7.js} +3 -3
  50. package/dist/{service-account-CAE-_1dR.js → service-account-r6fl0b-9.js} +3 -3
  51. package/dist/{session-stop-CA-jOJ84.js → session-stop-B2Nut40V.js} +27 -25
  52. package/dist/{skills-B22duVJU.js → skills-CD5aJdzg.js} +2 -2
  53. package/dist/spawn-CalgZQiu.js +79 -0
  54. package/dist/{stop-DioIcEAu.js → stop-kujZLbi0.js} +233 -1127
  55. package/dist/{store-Dn4W7qgH.js → store-DdIEUL1q.js} +3 -3
  56. package/dist/{turn-session-routing-CGMKrYOj.js → task-runner-D_RDr2Hu.js} +1440 -993
  57. package/dist/{store-B26LV6UP.js → turn-failure-response-B5nV1Er-.js} +337 -6
  58. package/dist/{validation-TzhfQABF.js → validation-K4pqwoVZ.js} +1 -1
  59. package/dist/{version-DSk8CFvA.js → version-DBvhk1X9.js} +1 -1
  60. package/dist/version.js +1 -1
  61. package/dist/viewer-DrMmFUul.js +337 -0
  62. package/dist/{work-ybG4_q5C.js → work-ljRoODGu.js} +110 -94
  63. package/dist/{worker-ccSyZRNz.js → worker-CYO1Q0Js.js} +5 -6
  64. package/migrations/0086_shared_archive.sql +31 -0
  65. package/migrations/0087_child_location.sql +64 -0
  66. package/migrations/0088_conversation_unsubscribe.sql +1 -0
  67. package/migrations/meta/0086_snapshot.json +4366 -0
  68. package/migrations/meta/0087_snapshot.json +4366 -0
  69. package/migrations/meta/0088_snapshot.json +4372 -0
  70. package/migrations/meta/_journal.json +21 -0
  71. package/package.json +5 -4
  72. package/dist/config-DqFnykQT.js +0 -579
  73. package/dist/spawn-BB2_4VYn.js +0 -31
  74. package/dist/task-queue-Bt0IoR2i.js +0 -139
  75. package/dist/task-runner-D8lddjzp.js +0 -290
  76. package/dist/thread-state-CrFk3K_7.js +0 -173
  77. package/dist/turn-failure-response-DaJ04qVj.js +0 -224
  78. package/dist/turn-lifecycle-C2mXS7AZ.js +0 -58
@@ -1,5 +1,185 @@
1
- import { G as conversationBriefSchema, K as parseBriefInput, U as briefOutcomeStatusSchema } from "./conversation-D8kVoCrP.js";
1
+ import { C as completeText$1, S as completeObject$1, x as completeDecision$1 } from "./config-CkHcUMN7.js";
2
+ import { _ as runBestEffort, a as extractGenAiUsageSummary } from "./logging-BO5zU6Mt.js";
3
+ import { H as agentTurnCostUsd, r as getConversationEventStore } from "./db-DJ11eZqq.js";
4
+ import { G as conversationBriefSchema, K as parseBriefInput, U as briefOutcomeStatusSchema } from "./conversation-E7ZPJx2H.js";
2
5
  import * as z from "zod";
6
+ import { conversationEventPresentationSchema, defineConversationEvent } from "@sentry/junior-plugin-api";
7
+ // src/chat/conversations/structured-events.ts
8
+ /** Reserved namespace for Junior-owned conversation metadata events. */
9
+ const JUNIOR_NATIVE_EVENT_NAMESPACE = "junior";
10
+ const authenticationEventContentSchema = z.object({
11
+ accountLabel: z.string().trim().min(1).max(120).optional(),
12
+ actorId: z.string().min(1),
13
+ authorizationId: z.string().min(1).optional(),
14
+ provider: z.string().regex(/^[a-z][a-z0-9-]*$/),
15
+ providerLabel: z.string().trim().min(1).max(80).optional()
16
+ }).strict();
17
+ const agentsInstructionsUpdatedContentSchema = z.object({
18
+ action: z.enum([
19
+ "loaded",
20
+ "replaced",
21
+ "cleared"
22
+ ]),
23
+ directory: z.string().trim().min(1).max(500).optional(),
24
+ fingerprint: z.string().trim().min(1).max(128),
25
+ sources: z.array(z.object({
26
+ content: z.string().min(1).max(32768),
27
+ path: z.string().trim().min(1).max(500)
28
+ }).strict()).max(32),
29
+ textBytes: z.number().int().nonnegative().optional()
30
+ }).strict();
31
+ function providerTitle(content) {
32
+ return content.providerLabel?.trim() || content.provider;
33
+ }
34
+ function agentsInstructionsTitle(action) {
35
+ if (action === "loaded") return "Loaded AGENTS.md";
36
+ if (action === "replaced") return "Updated AGENTS.md";
37
+ return "Cleared AGENTS.md";
38
+ }
39
+ function sourceFilename(sourcePath) {
40
+ return sourcePath.split("/").at(-1) || sourcePath;
41
+ }
42
+ function formatBytes(bytes) {
43
+ if (bytes < 1024) return `${bytes} bytes`;
44
+ const kilobytes = bytes / 1024;
45
+ return `${Number.isInteger(kilobytes) ? kilobytes : kilobytes.toFixed(1)} KB`;
46
+ }
47
+ function agentsInstructionsPreview(content) {
48
+ const source = content.sources[0];
49
+ if (!source) return void 0;
50
+ const filename = sourceFilename(source.path);
51
+ const label = content.sources.length === 1 ? filename : `${content.sources.length} AGENTS.md files`;
52
+ return typeof content.textBytes === "number" ? `${label} · ${formatBytes(content.textBytes)}` : label;
53
+ }
54
+ /** Junior-owned account-link transcript event. */
55
+ const authenticationLinkedEvent = defineConversationEvent({
56
+ name: "authentication_linked",
57
+ version: 1,
58
+ schema: authenticationEventContentSchema,
59
+ renderEvent(event) {
60
+ const provider = providerTitle(event);
61
+ return {
62
+ icon: "link",
63
+ title: `${provider} connected`,
64
+ ...event.accountLabel ? { preview: `Connected as \`${event.accountLabel}\`` } : void 0,
65
+ details: [{
66
+ title: `${provider} connected`,
67
+ ...event.accountLabel ? { description: `Connected as \`${event.accountLabel}\`` } : void 0,
68
+ metadata: [event.provider]
69
+ }]
70
+ };
71
+ }
72
+ });
73
+ /** Junior-owned account-unlink transcript event. */
74
+ const authenticationUnlinkedEvent = defineConversationEvent({
75
+ name: "authentication_unlinked",
76
+ version: 1,
77
+ schema: authenticationEventContentSchema,
78
+ renderEvent(event) {
79
+ const provider = providerTitle(event);
80
+ return {
81
+ icon: "key",
82
+ title: `${provider} disconnected`,
83
+ details: [{
84
+ title: `${provider} disconnected`,
85
+ metadata: [event.provider]
86
+ }]
87
+ };
88
+ }
89
+ });
90
+ /** Junior-owned AGENTS.md bootstrap transition for the dashboard timeline. */
91
+ const agentsInstructionsUpdatedEvent = defineConversationEvent({
92
+ name: "agents_instructions_updated",
93
+ version: 1,
94
+ schema: agentsInstructionsUpdatedContentSchema,
95
+ renderEvent(event) {
96
+ const title = agentsInstructionsTitle(event.action);
97
+ const preview = agentsInstructionsPreview(event);
98
+ return {
99
+ icon: "brain",
100
+ title,
101
+ ...preview ? { preview } : void 0,
102
+ ...event.sources.length > 0 ? { details: event.sources.map((source) => ({
103
+ title: sourceFilename(source.path),
104
+ content: source.content
105
+ })) } : void 0
106
+ };
107
+ }
108
+ });
109
+ /** Core-written Conversation note. `notes.ts` owns when the model sees it. */
110
+ const conversationNoteEvent = defineConversationEvent({
111
+ name: "conversation_note",
112
+ version: 1,
113
+ schema: z.object({ text: z.string().trim().min(1).max(500) }).strict(),
114
+ renderEvent(event) {
115
+ return {
116
+ icon: "info",
117
+ title: "Note for the next Turn",
118
+ preview: event.text
119
+ };
120
+ }
121
+ });
122
+ const NATIVE_EVENT_DEFINITIONS = [
123
+ authenticationLinkedEvent,
124
+ authenticationUnlinkedEvent,
125
+ agentsInstructionsUpdatedEvent,
126
+ conversationNoteEvent
127
+ ];
128
+ /** Resolve a registered Junior-native conversation event definition. */
129
+ function getJuniorNativeEventDefinition(args) {
130
+ return NATIVE_EVENT_DEFINITIONS.find((definition) => definition.eventName === args.name && definition.version === args.version);
131
+ }
132
+ /** Render one Junior-native event through its active definition. */
133
+ function renderJuniorNativeConversationEvent(args) {
134
+ if (args.namespace !== "junior") return void 0;
135
+ const definition = getJuniorNativeEventDefinition(args);
136
+ if (!definition) return void 0;
137
+ const presentation = definition.renderEvent(definition.parse(args.content));
138
+ return presentation === void 0 ? void 0 : conversationEventPresentationSchema.parse(presentation);
139
+ }
140
+ // src/chat/core-model.ts
141
+ function gatewayParams(params) {
142
+ const { cost: _cost, operation, ...rest } = params;
143
+ return {
144
+ ...rest,
145
+ promptName: `junior.${operation}`
146
+ };
147
+ }
148
+ async function recordCost(attribution, costUsd) {
149
+ const { cost, operation } = attribution;
150
+ if (costUsd === void 0 || !("conversationId" in cost)) return;
151
+ await runBestEffort(async () => {
152
+ await getConversationEventStore().append(cost.conversationId, [{
153
+ createdAtMs: Date.now(),
154
+ data: {
155
+ type: "structured_event",
156
+ namespace: JUNIOR_NATIVE_EVENT_NAMESPACE,
157
+ name: operation,
158
+ version: 1,
159
+ ...cost.turnId ? { turnId: cost.turnId } : void 0,
160
+ content: { costUsd }
161
+ }
162
+ }], { activity: "preserve" });
163
+ }, "model_cost.record.failed", { "gen_ai.prompt.name": `junior.${operation}` });
164
+ }
165
+ /** Run a text completion and attribute its cost. */
166
+ async function completeText(params) {
167
+ const result = await completeText$1(gatewayParams(params));
168
+ await recordCost(params, agentTurnCostUsd(extractGenAiUsageSummary(result.message)));
169
+ return result;
170
+ }
171
+ /** Run a schema-constrained completion and attribute its cost. */
172
+ async function completeObject(params) {
173
+ const result = await completeObject$1(gatewayParams(params));
174
+ await recordCost(params, result.costUsd);
175
+ return result;
176
+ }
177
+ /** Answer decision questions and attribute the cost. */
178
+ async function completeDecision(params) {
179
+ const result = await completeDecision$1(gatewayParams(params));
180
+ await recordCost(params, result.costUsd);
181
+ return result;
182
+ }
3
183
  // src/chat/briefs/generate.ts
4
184
  const MAX_INPUT_CHARS = 6e4;
5
185
  const MAX_MESSAGE_TEXT_CHARS = 4e3;
@@ -526,4 +706,4 @@ Rules:
526
706
  - Cite a URL only when its exact full string occurs in an entry, evidence, or the previous Brief. Return cited URLs in \`urls\`. Core adds code changes and resources separately.
527
707
  - Keep the summary under 600 characters, intent under 400 characters, outcome text under 600 characters, and each other string under 400 characters.
528
708
  `;
529
- export { EVENT_SYSTEM_ACTOR as a, EVENT_MESSAGE_AUTHOR as i, briefEntriesFromReportEvents as n, isEventConversationMessage as o, EVENT_AUTHOR_ID as r, generateBrief as s, BRIEF_PROMPT as t };
709
+ export { EVENT_SYSTEM_ACTOR as a, completeDecision as c, JUNIOR_NATIVE_EVENT_NAMESPACE as d, agentsInstructionsUpdatedEvent as f, renderJuniorNativeConversationEvent as g, conversationNoteEvent as h, EVENT_MESSAGE_AUTHOR as i, completeObject as l, authenticationUnlinkedEvent as m, briefEntriesFromReportEvents as n, isEventConversationMessage as o, authenticationLinkedEvent as p, EVENT_AUTHOR_ID as r, generateBrief as s, BRIEF_PROMPT as t, completeText as u };
@@ -1,4 +1,4 @@
1
- import { b as setSpanAttributes, h as logWarn, m as logInfo } from "./logging-BfORLKoq.js";
1
+ import { b as setSpanAttributes, h as logWarn, m as logInfo } from "./logging-BO5zU6Mt.js";
2
2
  import { o as isUserActor, s as parseActorUserId } from "./actor-6jsm_v96.js";
3
3
  import { n as normalizePluginPackageNames, o as pluginRoots, t as discoverInstalledPluginPackageContent } from "./package-discovery-DJhGdS4c.js";
4
4
  import path from "node:path";
@@ -160,6 +160,9 @@ function formatUserInputAnswer(request, answer) {
160
160
  if (normalized.other) lines.push(answerLine(`Other: ${normalized.other}`));
161
161
  return lines.join("\n");
162
162
  }
163
+ // src/api/schema/common.ts
164
+ /** Stable error body returned by Junior-owned REST endpoints. */
165
+ const apiErrorSchema = z.object({ error: z.string().min(1) }).strict();
163
166
  // src/chat/conversations/web-message-id.ts
164
167
  /**
165
168
  * Build the retry-stable Message id shared by web ingress and browser sends.
@@ -292,4 +295,4 @@ function sumUtcHoursIntoSixHours(args) {
292
295
  rows: bySix
293
296
  });
294
297
  }
295
- export { AGENT_INVOCATION_STATUSES as C, userCustomizationTextSchema as E, AGENT_INVOCATION_PARENT_MAILBOX_STATUSES as S, userCustomizationSchema as T, formatUserInputAnswer as _, fillUtcSixHours as a, userInputRequestSchema as b, trailingUtcDayWindow as c, utcDayKey as d, utcHourKey as f, buttonUserInputField as g, USER_INPUT_NOTE as h, fillUtcHours as i, trailingUtcHourWindow as l, USER_INPUT_LIMITS as m, HOUR_MS as n, startOfUtcHour as o, webMessageId as p, fillUtcDays as r, sumUtcHoursIntoSixHours as s, DAY_MS as t, trailingUtcSixHourWindow as u, isEmptyUserInputAnswer as v, USER_CUSTOMIZATION_MAX_CHARS as w, AGENT_INVOCATION_MAILBOX_STATUSES as x, normalizeUserInputAnswer as y };
298
+ export { AGENT_INVOCATION_PARENT_MAILBOX_STATUSES as C, userCustomizationTextSchema as D, userCustomizationSchema as E, AGENT_INVOCATION_MAILBOX_STATUSES as S, USER_CUSTOMIZATION_MAX_CHARS as T, buttonUserInputField as _, fillUtcSixHours as a, normalizeUserInputAnswer as b, trailingUtcDayWindow as c, utcDayKey as d, utcHourKey as f, USER_INPUT_NOTE as g, USER_INPUT_LIMITS as h, fillUtcHours as i, trailingUtcHourWindow as l, apiErrorSchema as m, HOUR_MS as n, startOfUtcHour as o, webMessageId as p, fillUtcDays as r, sumUtcHoursIntoSixHours as s, DAY_MS as t, trailingUtcSixHourWindow as u, formatUserInputAnswer as v, AGENT_INVOCATION_STATUSES as w, userInputRequestSchema as x, isEmptyUserInputAnswer as y };
@@ -1,6 +1,6 @@
1
- import { Di as isStale, La as SANDBOX_COMMAND_PATH, Ti as create, Va as SANDBOX_WORKSPACE_ROOT, ja as sleep, ki as getSandboxProvider, qa as runNonInteractiveCommand } from "./projection-DliWYrnT.js";
2
- import { E as withSpan, b as setSpanAttributes } from "./logging-BfORLKoq.js";
3
- import { r as getStateAdapter } from "./adapter-DN5AB4VU.js";
1
+ import { Fa as sleep, Ga as SANDBOX_WORKSPACE_ROOT, Ni as getSandboxProvider, Va as SANDBOX_COMMAND_PATH, Za as runNonInteractiveCommand, ji as isStale, ki as create } from "./projection-CL_YWeGf.js";
2
+ import { E as withSpan, b as setSpanAttributes } from "./logging-BO5zU6Mt.js";
3
+ import { r as getStateAdapter } from "./adapter-CL-HUKgd.js";
4
4
  import * as z from "zod";
5
5
  // src/chat/sandbox/resources.ts
6
6
  let configuredResources;
@@ -1,12 +1,12 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { _n as renderUntrustedTag } from "./projection-DliWYrnT.js";
3
- import { H as SYSTEM_IDENTITY_ID } from "./viewer-1Ea81s0b.js";
4
- import { f as credentialContextForActor } from "./registry-rC7MCxu8.js";
5
- import { jt as listUnreportedSiblingAgents } from "./agent-runner-BsWhHe4N.js";
6
- import { A as getAgentInvocationIdForEvents, M as getAgentInvocationIdForResult, P as getAgentInvocationResultMessageId, a as getAgentInvocation, h as markAgentInvocationParentMailboxAppended, j as getAgentInvocationIdForMessage, l as isTerminalAgentInvocation, s as getLatestAgentInvocationForConversation } from "./store-B26LV6UP.js";
7
- import { C as isEventMailboxMetadata, T as timerWatchCredentialSubject, b as EVENT_WAIT_MS, d as getEventBatchDelayMs, n as isWatchEvent, p as parseEventMessages, s as eventReviewItemInputs, w as renderEventBatchInputs } from "./session-stop-CA-jOJ84.js";
8
- import { r as appendAndEnqueueInboundMessage } from "./store-Dn4W7qgH.js";
9
- import { a as resolveAgentInvocationId, i as enqueueAgentInvocation, l as createAgentInvocationFromLatest, t as createAgentInvocationWorker } from "./work-ybG4_q5C.js";
2
+ import { bn as renderUntrustedTag } from "./projection-CL_YWeGf.js";
3
+ import { T as SYSTEM_IDENTITY_ID } from "./db-DJ11eZqq.js";
4
+ import { f as credentialContextForActor } from "./registry-BriFLnaJ.js";
5
+ import { Jt as listUnreportedSiblingAgents } from "./agent-runner-Bfnw551N.js";
6
+ import { C as isTerminalAgentInvocation, G as getAgentInvocationIdForEvents, K as getAgentInvocationIdForMessage, Y as getAgentInvocationResultMessageId, k as markAgentInvocationParentMailboxAppended, q as getAgentInvocationIdForResult, x as getLatestAgentInvocationForConversation, y as getAgentInvocation } from "./turn-failure-response-B5nV1Er-.js";
7
+ import { D as timerWatchCredentialSubject, E as renderEventBatchInputs, S as EVENT_WAIT_MS, T as isEventMailboxMetadata, f as getEventBatchDelayMs, m as parseEventMessages, n as isWatchEvent, s as eventReviewItemInputs } from "./session-stop-B2Nut40V.js";
8
+ import { r as appendAndEnqueueInboundMessage } from "./store-DdIEUL1q.js";
9
+ import { a as enqueueAgentInvocation, l as createAgentInvocationFromLatest, o as resolveAgentInvocationId, t as createAgentInvocationWorker } from "./work-ljRoODGu.js";
10
10
  import { n as isAgentInvocationResultEventType, t as agentInvocationResultEventType } from "./result-event-type-DD6BAgT7.js";
11
11
  // src/chat/agent-invocations/result.ts
12
12
  var result_exports = /* @__PURE__ */ __exportAll({
@@ -1,14 +1,11 @@
1
- import { F as recordDeliveredAssistantMessage, L as upsertConversationMessage, N as markConversationMessage, O as buildConversationContext, P as normalizeConversationText, Q as saveTurnCheckpoint, V as authorizationId, a as loadProjection, d as recordAuthorizationCompleted, qt as persistWithRetry, t as commitAcceptedReply, v as hydrateConversationMessages, y as persistConversationMessages } from "./projection-DliWYrnT.js";
2
- import { S as setTags, T as withLogContext, p as logException } from "./logging-BfORLKoq.js";
3
- import { H as SYSTEM_IDENTITY_ID, x as getConversationStore, y as getConversationEventStore } from "./viewer-1Ea81s0b.js";
4
- import { f as credentialContextForActor } from "./registry-rC7MCxu8.js";
5
- import { N as messageCardText } from "./conversation-D8kVoCrP.js";
6
- import { X as markTurnFailed, Z as startActiveTurn } from "./store-B26LV6UP.js";
7
- import { n as getAssistantReplyText } from "./assistant-reply-9Jip5bsr.js";
8
- import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-C2mXS7AZ.js";
9
- import { a as persistThreadStateById, n as getPersistedSandboxState, o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-CrFk3K_7.js";
10
- import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-D8lddjzp.js";
11
- import { i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, t as finalizeFailedTurnReplyWithEvent, u as loadPendingMessageCards } from "./turn-failure-response-DaJ04qVj.js";
1
+ import { L as upsertConversationMessage, M as markConversationMessage, N as normalizeConversationText, P as recordDeliveredAssistantMessage, V as authorizationId, Yt as persistWithRetry, a as loadProjection, b as persistConversationMessages, d as recordAuthorizationCompleted, et as saveTurnCheckpoint, j as latestConversationMessageSeq, t as commitAcceptedReply, v as hydrateConversationMessages } from "./projection-CL_YWeGf.js";
2
+ import { S as setTags, T as withLogContext, p as logException } from "./logging-BO5zU6Mt.js";
3
+ import { T as SYSTEM_IDENTITY_ID, a as getConversationStore, r as getConversationEventStore } from "./db-DJ11eZqq.js";
4
+ import { f as credentialContextForActor } from "./registry-BriFLnaJ.js";
5
+ import { N as messageCardText } from "./conversation-E7ZPJx2H.js";
6
+ import { dt as markTurnFailed, f as ConversationTurnLifecycleService, ft as startActiveTurn, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, m as loadPendingMessageCards, t as finalizeFailedTurnReplyWithEvent, u as buildTurnThreadContext } from "./turn-failure-response-B5nV1Er-.js";
7
+ import { n as getAssistantReplyText } from "./assistant-reply-u_PRYzuz.js";
8
+ import { _t as getPersistedThreadState, bt as coerceThreadConversationState, gt as getPersistedSandboxState, n as scheduleSessionCompletedPluginTasks, t as processPluginTask, yt as persistThreadStateById } from "./task-runner-D_RDr2Hu.js";
12
9
  import { randomUUID } from "node:crypto";
13
10
  import { createLocalSource, localDestinationSchema } from "@sentry/junior-plugin-api";
14
11
  // src/chat/local/runner.ts
@@ -115,6 +112,7 @@ async function runLocalAgentTurnInContext(input, deps) {
115
112
  createdAtMs: Date.now(),
116
113
  inputMessageIds: [userMessageId],
117
114
  surface: "internal",
115
+ threadContextThroughSeq: latestConversationMessageSeq(conversation),
118
116
  turnId
119
117
  });
120
118
  startActiveTurn({
@@ -184,7 +182,13 @@ async function runLocalAgentTurnInContext(input, deps) {
184
182
  runId: currentRunId,
185
183
  instruction: {
186
184
  text,
187
- context: buildConversationContext(conversation, { excludeMessageIds: [userMessageId] })
185
+ context: await buildTurnThreadContext({
186
+ conversation,
187
+ conversationId: input.conversationId,
188
+ excludeMessageIds: [userMessageId],
189
+ hasHistory: Boolean(messages?.length),
190
+ turnId
191
+ })
188
192
  },
189
193
  history: messages,
190
194
  actor: localActor,
@@ -1,4 +1,4 @@
1
- import { Ea as sandboxEgressSignalsResponseSchema } from "./projection-DliWYrnT.js";
1
+ import { Aa as sandboxEgressSignalsResponseSchema } from "./projection-CL_YWeGf.js";
2
2
  // src/chat/local/sandbox-egress-signals.ts
3
3
  const SANDBOX_EGRESS_SIGNALS_PATH = "/api/internal/sandbox-egress/signals";
4
4
  const LOCAL_DEV_SERVER_TIMEOUT_MS = 1e3;
@@ -1,8 +1,8 @@
1
1
  import { r as notificationScheduleSchema } from "./schedule-BTp__wrw.js";
2
- import { D as conversationChildAgentTotalsSchema, S as conversationUsageSchema, b as conversationSummaryReportSchema, i as actorIdentitySchema, s as conversationAuxiliaryCostsSchema } from "./conversation-D8kVoCrP.js";
3
- import { C as AGENT_INVOCATION_STATUSES, b as userInputRequestSchema, i as fillUtcHours, r as fillUtcDays, s as sumUtcHoursIntoSixHours } from "./reporting-window-B4TwyuJo.js";
4
- import "./automation-Mk8aaHzy.js";
5
- import "./conversation-pending-messages-BvROq1bq.js";
2
+ import { D as conversationChildAgentTotalsSchema, S as conversationUsageSchema, b as conversationSummaryReportSchema, i as actorIdentitySchema, s as conversationAuxiliaryCostsSchema } from "./conversation-E7ZPJx2H.js";
3
+ import { i as fillUtcHours, r as fillUtcDays, s as sumUtcHoursIntoSixHours, w as AGENT_INVOCATION_STATUSES, x as userInputRequestSchema } from "./reporting-window-B3Ze-Qnt.js";
4
+ import "./automation-DksGNDRO.js";
5
+ import "./conversation-pending-messages-DVch6YQw.js";
6
6
  import { t as isPushServiceEndpoint } from "./push-endpoint-CO-nomUd.js";
7
7
  import * as z from "zod";
8
8
  import { codeChangeStateSchema, eventMatchSchema } from "@sentry/junior-plugin-api";
@@ -33,6 +33,18 @@ const pinConversationResponseSchema = z.object({ pinnedAt: z.string().datetime()
33
33
  const reorderPinnedConversationsBodySchema = z.object({ conversationIds: z.array(z.string().min(1)).min(1).max(500).refine((ids) => new Set(ids).size === ids.length, { message: "Each Conversation can appear once." }) }).strict();
34
34
  /** The pinned Conversations that got a new place, in order. */
35
35
  const reorderPinnedConversationsResponseSchema = z.object({ conversationIds: z.array(z.string()) }).strict();
36
+ // src/api/schema/conversation-subscription.ts
37
+ /** Subscribe to or unsubscribe from one Conversation for the viewer. */
38
+ const conversationSubscriptionBodySchema = z.object({ subscribed: z.boolean() }).strict();
39
+ /**
40
+ * The viewer's subscription after the change. `archivedAt` is set when the
41
+ * viewer was the last subscriber, so the unsubscribe archived the
42
+ * Conversation for everyone.
43
+ */
44
+ const conversationSubscriptionResponseSchema = z.object({
45
+ archivedAt: z.string().datetime().nullable(),
46
+ subscribed: z.boolean()
47
+ }).strict();
36
48
  // src/api/schema/conversation-unread.ts
37
49
  /** Mark one Conversation read or unread for the signed-in viewer. */
38
50
  const markConversationUnreadBodySchema = z.object({ unread: z.boolean() }).strict();
@@ -165,6 +177,8 @@ const continueConversationInSlackResponseSchema = z.object({
165
177
  */
166
178
  const conversationChildAgentSchema = z.object({
167
179
  auxiliaryCosts: conversationAuxiliaryCostsSchema.optional(),
180
+ /** When the child was archived for everyone, or null. */
181
+ archivedAt: z.string().datetime().nullable(),
168
182
  childAgentTotals: conversationChildAgentTotalsSchema.optional(),
169
183
  conversationId: z.string().min(1),
170
184
  cumulativeDurationMs: z.number(),
@@ -175,8 +189,6 @@ const conversationChildAgentSchema = z.object({
175
189
  redacted: z.literal(true).optional(),
176
190
  status: z.enum(AGENT_INVOCATION_STATUSES),
177
191
  task: z.string().optional(),
178
- /** When the child was archived for everyone, or null. */
179
- childArchivedAt: z.string().datetime().nullable(),
180
192
  title: z.string().min(1).optional(),
181
193
  updatedAt: z.string().datetime()
182
194
  }).strict().superRefine((data, context) => {
@@ -768,4 +780,4 @@ const versionsSchema = z.object({
768
780
  /** The viewer's rolling model spend. */
769
781
  spend: z.string().min(1)
770
782
  }).strict();
771
- export { codeChangeSummaryReportSchema as $, actorDirectoryReportSchema as A, activityHours as B, startServiceAccountSignInResponseSchema as C, pinConversationBodySchema as Ct, personalTokenMetadataSchema as D, conversationCatchUpBodySchema as Dt, personalTokenListSchema as E, reorderPinnedConversationsResponseSchema as Et, locationActivityDayReportSchema as F, pushSubscriptionDeleteBodySchema as G, dailyConversationActivitySchema as H, locationDetailReportSchema as I, connectionParamsSchema as J, testNotificationResponseSchema as K, locationDirectoryReportSchema as L, avatarParamsSchema as M, personParamsSchema as N, personalTokenParamsSchema as O, conversationCatchUpSchema as Ot, personalSpendReportSchema as P, codeActivityDaySchema as Q, locationParamsSchema as R, serviceAccountSchema as S, markConversationUnreadBodySchema as St, createdPersonalTokenSchema as T, reorderPinnedConversationsBodySchema as Tt, notificationSettingsSchema as U, activitySixHours as V, pushSubscriptionBodySchema as W, disconnectConnectionResponseSchema as X, connectionSchema as Y, startConnectionResponseSchema as Z, reviewItemSchema as _, archiveConversationBodySchema as _t, baselineSnapshotSchema as a, codeRepositorySummarySchema as at, serviceAccountListSchema as b, conversationAutoArchiveSchema as bt, workspaceListSchema as c, conversationChildAgentSchema as ct, workspaceSchema as d, continueConversationInSlackResponseSchema as dt, codeChangeSummarySchema as et, reviewItemActionSchema as f, stopConversationTurnResponseSchema as ft, reviewItemParamsSchema as g, renameConversationResponseSchema as gt, reviewItemListSchema as h, renameConversationBodySchema as ht, statsReportSchema as i, codeRepositoryReportSchema as it, actorProfileReportSchema as j, revokePersonalTokenResponseSchema as k, workspaceParamsSchema as l, conversationChildAgentsReportSchema as lt, reviewItemListQuerySchema as m, CONVERSATION_TITLE_MAX_LENGTH as mt, versionsSchema as n, codePersonReportSchema as nt, deleteWorkspaceResponseSchema as o, conversationWatchSchema as ot, reviewItemCountSchema as p, conversationStatsReportSchema as pt, connectionListSchema as q, statSchema as r, codeRepositoryParamsSchema as rt, workspaceBodySchema as s, conversationWatchesReportSchema as st, versionsQuerySchema as t, codeOverviewReportSchema as tt, workspaceRepoSchema as u, continueConversationInSlackBodySchema as ut, reviewItemWaitingConversationsSchema as v, archiveConversationResponseSchema as vt, createPersonalTokenBodySchema as w, pinConversationResponseSchema as wt, serviceAccountParamsSchema as x, conversationUnreadSchema as xt, disconnectServiceAccountResponseSchema as y, archiveDoneConversationsResponseSchema as yt, activityDays as z };
783
+ export { codeChangeSummaryReportSchema as $, actorDirectoryReportSchema as A, conversationCatchUpSchema as At, activityHours as B, startServiceAccountSignInResponseSchema as C, conversationSubscriptionBodySchema as Ct, personalTokenMetadataSchema as D, reorderPinnedConversationsBodySchema as Dt, personalTokenListSchema as E, pinConversationResponseSchema as Et, locationActivityDayReportSchema as F, pushSubscriptionDeleteBodySchema as G, dailyConversationActivitySchema as H, locationDetailReportSchema as I, connectionParamsSchema as J, testNotificationResponseSchema as K, locationDirectoryReportSchema as L, avatarParamsSchema as M, personParamsSchema as N, personalTokenParamsSchema as O, reorderPinnedConversationsResponseSchema as Ot, personalSpendReportSchema as P, codeActivityDaySchema as Q, locationParamsSchema as R, serviceAccountSchema as S, markConversationUnreadBodySchema as St, createdPersonalTokenSchema as T, pinConversationBodySchema as Tt, notificationSettingsSchema as U, activitySixHours as V, pushSubscriptionBodySchema as W, disconnectConnectionResponseSchema as X, connectionSchema as Y, startConnectionResponseSchema as Z, reviewItemSchema as _, archiveConversationBodySchema as _t, baselineSnapshotSchema as a, codeRepositorySummarySchema as at, serviceAccountListSchema as b, conversationAutoArchiveSchema as bt, workspaceListSchema as c, conversationChildAgentSchema as ct, workspaceSchema as d, continueConversationInSlackResponseSchema as dt, codeChangeSummarySchema as et, reviewItemActionSchema as f, stopConversationTurnResponseSchema as ft, reviewItemParamsSchema as g, renameConversationResponseSchema as gt, reviewItemListSchema as h, renameConversationBodySchema as ht, statsReportSchema as i, codeRepositoryReportSchema as it, actorProfileReportSchema as j, revokePersonalTokenResponseSchema as k, conversationCatchUpBodySchema as kt, workspaceParamsSchema as l, conversationChildAgentsReportSchema as lt, reviewItemListQuerySchema as m, CONVERSATION_TITLE_MAX_LENGTH as mt, versionsSchema as n, codePersonReportSchema as nt, deleteWorkspaceResponseSchema as o, conversationWatchSchema as ot, reviewItemCountSchema as p, conversationStatsReportSchema as pt, connectionListSchema as q, statSchema as r, codeRepositoryParamsSchema as rt, workspaceBodySchema as s, conversationWatchesReportSchema as st, versionsQuerySchema as t, codeOverviewReportSchema as tt, workspaceRepoSchema as u, continueConversationInSlackBodySchema as ut, reviewItemWaitingConversationsSchema as v, archiveConversationResponseSchema as vt, createPersonalTokenBodySchema as w, conversationSubscriptionResponseSchema as wt, serviceAccountParamsSchema as x, conversationUnreadSchema as xt, disconnectServiceAccountResponseSchema as y, archiveDoneConversationsResponseSchema as yt, activityDays as z };