@sentry/junior 0.144.0 → 0.145.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 (88) hide show
  1. package/dist/{agent-hooks-GCUTGKY3.js → agent-hooks-L7D2BDVV.js} +10 -10
  2. package/dist/api/conversations/detail.d.ts +1 -0
  3. package/dist/api/schema/conversation.d.ts +2 -0
  4. package/dist/api/schema.js +1 -1
  5. package/dist/api.js +40 -22
  6. package/dist/app.js +335 -409
  7. package/dist/{catalog-runtime-DWVYKDC6.js → catalog-runtime-QLAC4Q3W.js} +5 -5
  8. package/dist/chat/agent/request.d.ts +1 -1
  9. package/dist/chat/agent/resume.d.ts +6 -15
  10. package/dist/chat/agent/tools.d.ts +1 -1
  11. package/dist/chat/agent-dispatch/types.d.ts +1 -1
  12. package/dist/chat/app/conversation-work.d.ts +24 -0
  13. package/dist/chat/conversations/projection.d.ts +11 -3
  14. package/dist/chat/conversations/store.d.ts +1 -1
  15. package/dist/chat/runtime/agent-run-outcome.d.ts +1 -1
  16. package/dist/chat/runtime/reply-executor.d.ts +5 -5
  17. package/dist/chat/runtime/slack-resume.d.ts +12 -4
  18. package/dist/chat/state/locks.d.ts +28 -0
  19. package/dist/chat/task-execution/checkpoint.d.ts +86 -0
  20. package/dist/chat/task-execution/paused-turn.d.ts +29 -0
  21. package/dist/chat/task-execution/queue-signing.d.ts +1 -0
  22. package/dist/chat/task-execution/queue.d.ts +7 -1
  23. package/dist/chat/task-execution/slack-work.d.ts +1 -1
  24. package/dist/chat/task-execution/state.d.ts +4 -4
  25. package/dist/chat/task-execution/store.d.ts +2 -2
  26. package/dist/chat/task-execution/turn-cursor-keys.d.ts +6 -0
  27. package/dist/chat/{state/turn-session.d.ts → task-execution/turn-cursor.d.ts} +52 -42
  28. package/dist/chat/task-execution/turn-wake.d.ts +29 -0
  29. package/dist/chat/tools/types.d.ts +1 -1
  30. package/dist/{chunk-HNO2E5WB.js → chunk-27TEJTZO.js} +1 -1
  31. package/dist/{chunk-RIFJUJSI.js → chunk-2LWPFSB4.js} +1 -1
  32. package/dist/{chunk-SBZP2J5Q.js → chunk-2UH3JI64.js} +10 -9
  33. package/dist/{chunk-QUZJDAQQ.js → chunk-2XET6PKP.js} +93 -89
  34. package/dist/{chunk-SUK7NC5A.js → chunk-5PNPQYTO.js} +2 -2
  35. package/dist/{chunk-SSDTQDYQ.js → chunk-64SBYW2O.js} +132 -127
  36. package/dist/{chunk-DVO5VKYQ.js → chunk-B46ZMVOV.js} +5 -5
  37. package/dist/{chunk-A67GZN73.js → chunk-CD2XFGYQ.js} +1 -1
  38. package/dist/{chunk-WTX2RFJG.js → chunk-DS3J6WGY.js} +1 -1
  39. package/dist/{chunk-PKH6762I.js → chunk-DXEQAIUV.js} +1 -1
  40. package/dist/{chunk-WSOLZJJS.js → chunk-EIX2LQ6L.js} +3 -3
  41. package/dist/{chunk-KQBXT5B7.js → chunk-FUBRJA5F.js} +6 -6
  42. package/dist/{chunk-I44JB7HQ.js → chunk-GDV5LXRA.js} +1 -1
  43. package/dist/{chunk-7KAW7UF4.js → chunk-GUWLDMGF.js} +4 -4
  44. package/dist/{chunk-PELZ2ZSY.js → chunk-HISR3DTV.js} +33 -61
  45. package/dist/{chunk-HD6BHR25.js → chunk-HLOUZC5C.js} +32 -34
  46. package/dist/{chunk-BBCWYXHB.js → chunk-I47UGQPJ.js} +7 -7
  47. package/dist/{chunk-IUFM5JWV.js → chunk-JAL3CH4G.js} +3 -0
  48. package/dist/{chunk-E7HCWOHG.js → chunk-JLMVCNXL.js} +2 -1
  49. package/dist/{chunk-STFCL3K4.js → chunk-JTGS3ZZE.js} +1 -1
  50. package/dist/{chunk-GKA74DRA.js → chunk-LVVSIMBB.js} +1 -1
  51. package/dist/{chunk-SHEEZSLY.js → chunk-PJ4NMVQB.js} +2 -2
  52. package/dist/{chunk-W7JFV5SB.js → chunk-QJBDABQA.js} +14 -17
  53. package/dist/{chunk-UDQMY6RS.js → chunk-QUG4JSZK.js} +43 -1
  54. package/dist/{chunk-4X5KM7Z6.js → chunk-RUSS62EN.js} +14 -14
  55. package/dist/{chunk-ZF3N3JD6.js → chunk-SIN3MXH6.js} +1 -1
  56. package/dist/{chunk-QE3TICD4.js → chunk-TZRXYWRE.js} +2 -2
  57. package/dist/{chunk-CNTWB2SM.js → chunk-VTDMB7XX.js} +1 -1
  58. package/dist/{chunk-LDWNYCZ6.js → chunk-WF5HVH3M.js} +1 -1
  59. package/dist/{chunk-KCBZSJRU.js → chunk-WR76IVA5.js} +5 -2
  60. package/dist/{chunk-3GU4PWA3.js → chunk-XFKIRN3Q.js} +29 -29
  61. package/dist/{chunk-ZZCTGAIT.js → chunk-YD54Q45G.js} +4 -4
  62. package/dist/{chunk-BEGGFVFR.js → chunk-ZIAMN2UW.js} +407 -523
  63. package/dist/{chunk-44RJWAND.js → chunk-ZIMRGFYL.js} +6 -6
  64. package/dist/{chunk-54JMYQYS.js → chunk-ZYAJMESY.js} +2 -2
  65. package/dist/cli/chat.js +32 -32
  66. package/dist/cli/check.js +6 -6
  67. package/dist/cli/plugins.js +13 -13
  68. package/dist/cli/snapshot-create.js +9 -9
  69. package/dist/cli/upgrade.js +7 -7
  70. package/dist/{db-EFLHTBU6.js → db-62PW6LM3.js} +7 -7
  71. package/dist/instrumentation.js +4 -4
  72. package/dist/nitro.js +4 -4
  73. package/dist/{oauth-callback-server-RO3IQKWM.js → oauth-callback-server-6NZNHJAM.js} +25 -25
  74. package/dist/{runner-LOWW7JKA.js → runner-GCRPG3GQ.js} +19 -18
  75. package/dist/{skills-ZLMUG7AE.js → skills-2S3MDFIQ.js} +6 -6
  76. package/dist/spawn-7WK37BTD.js +39 -0
  77. package/dist/{validation-MAKEZNTS.js → validation-HAOLCJ5A.js} +6 -6
  78. package/dist/version.js +1 -1
  79. package/dist/{work-5OAGC3I4.js → work-R4XYKMUW.js} +17 -16
  80. package/dist/worker-U2UCVR7M.js +24 -0
  81. package/package.json +4 -4
  82. package/dist/chat/agent/session.d.ts +0 -19
  83. package/dist/chat/runtime/agent-continue-runner.d.ts +0 -37
  84. package/dist/chat/services/agent-continue.d.ts +0 -29
  85. package/dist/chat/services/turn-session-record.d.ts +0 -164
  86. package/dist/chat/state/turn-session-keys.d.ts +0 -6
  87. package/dist/spawn-R3LUV6RF.js +0 -38
  88. package/dist/worker-KTGGRTTP.js +0 -24
@@ -1,11 +1,11 @@
1
1
  /**
2
- * Turn session records.
2
+ * Internal turn cursor storage for `checkpoint.ts`.
3
3
  *
4
- * These records track one user request across auth pauses, timeout slices, and
5
- * completion. Full Pi messages live in the durable conversation event store; this
6
- * record stores resumability metadata and a committed `seq` cursor into
7
- * `junior_conversation_events` so resumes can materialize the exact continuable
8
- * boundary without duplicating the event history.
4
+ * Callers outside `task-execution/` should use `checkpoint.ts` only.
5
+ * These records track one turn across auth pauses, timeout slices, and
6
+ * completion. Full Pi messages live in SQL conversation events; this store
7
+ * keeps resume metadata and a committed `seq` cursor into
8
+ * `junior_conversation_events`.
9
9
  */
10
10
  import type { Destination, Source } from "@sentry/junior-plugin-api";
11
11
  import { type PiMessage } from "@/chat/pi/messages";
@@ -15,12 +15,13 @@ import type { PluginTurnContext } from "@/chat/plugins/prompt";
15
15
  import type { AgentTurnUsage } from "@/chat/usage";
16
16
  import type { ConversationPrivacy } from "@/chat/conversation-privacy";
17
17
  import type { ConversationStore } from "@/chat/conversations/store";
18
- export type AgentTurnSessionStatus = "running" | "awaiting_resume" | "completed" | "failed" | "abandoned";
18
+ type TurnStatus = "running" | "paused" | "completed" | "failed" | "abandoned";
19
19
  export type AgentTurnSurface = "slack" | "api" | "scheduler" | "internal";
20
- export type AgentTurnResumeReason = "timeout" | "auth" | "yield" | "retry";
20
+ export type TurnPauseReason = "timeout" | "auth" | "yield" | "retry";
21
21
  export type AgentDispatchOutcome = "blocked" | "completed" | "failed";
22
- export interface AgentTurnSessionRecord {
22
+ export interface TurnRecord {
23
23
  channelName?: string;
24
+ schemaVersion: 2;
24
25
  version: number;
25
26
  conversationId: string;
26
27
  cumulativeDurationMs: number;
@@ -44,37 +45,38 @@ export interface AgentTurnSessionRecord {
44
45
  * replaces the singular execution actor, which is rebuilt at resume.
45
46
  */
46
47
  actors: Actor[];
47
- resumeReason?: AgentTurnResumeReason;
48
+ resumeReason?: TurnPauseReason;
48
49
  resumedFromSliceId?: number;
49
- sessionId: string;
50
+ turnId: string;
50
51
  sliceId: number;
51
52
  startedAtMs: number;
52
- state: AgentTurnSessionStatus;
53
+ state: TurnStatus;
53
54
  surface?: AgentTurnSurface;
54
55
  traceId?: string;
55
56
  turnStartMessageIndex?: number;
56
57
  updatedAtMs: number;
57
58
  }
58
- export interface AgentTurnSessionSummary {
59
+ export interface TurnSummary {
60
+ schemaVersion: 2;
59
61
  conversationId: string;
60
62
  dispatchId?: string;
61
63
  dispatchOutcome?: AgentDispatchOutcome;
62
64
  /** Provider-owned identifier returned after visible delivery is accepted. */
63
65
  resultMessageId?: string;
64
- resumeReason?: AgentTurnResumeReason;
65
- sessionId: string;
66
+ resumeReason?: TurnPauseReason;
67
+ turnId: string;
66
68
  sliceId: number;
67
- state: AgentTurnSessionStatus;
69
+ state: TurnStatus;
68
70
  surface?: AgentTurnSurface;
69
71
  updatedAtMs: number;
70
72
  version: number;
71
73
  }
72
74
  /** Read a turn record pinned to the history version containing its checkpoint. */
73
- export declare function getAgentTurnSessionRecord(conversationId: string, sessionId: string): Promise<AgentTurnSessionRecord | undefined>;
74
- /** Read a turn session for resume, following a newer committed replacement while unfinished. */
75
- export declare function getAgentTurnSessionRecordForResume(conversationId: string, sessionId: string): Promise<AgentTurnSessionRecord | undefined>;
76
- /** Commit stable Pi session state and advance the turn session record. */
77
- export declare function upsertAgentTurnSessionRecord(args: {
75
+ export declare function getTurnRecord(conversationId: string, turnId: string): Promise<TurnRecord | undefined>;
76
+ /** Read a turn cursor for resume, following a newer committed replacement while unfinished. */
77
+ export declare function getTurnRecordForResume(conversationId: string, turnId: string): Promise<TurnRecord | undefined>;
78
+ /** Commit stable Pi state and advance the turn cursor. */
79
+ export declare function upsertTurnRecord(args: {
78
80
  channelName?: string;
79
81
  conversationId: string;
80
82
  cumulativeDurationMs?: number;
@@ -90,15 +92,15 @@ export declare function upsertAgentTurnSessionRecord(args: {
90
92
  loadedSkillNames?: string[];
91
93
  modelId: string;
92
94
  conversationStore?: ConversationStore;
93
- sessionId: string;
95
+ turnId: string;
94
96
  sliceId: number;
95
- state: AgentTurnSessionStatus;
97
+ state: TurnStatus;
96
98
  surface?: AgentTurnSurface;
97
99
  piMessages: PiMessage[];
98
100
  /** Provenance for trailing newly committed messages, such as steering. */
99
101
  trailingMessageProvenance?: ConversationMessageProvenance[];
100
102
  actor?: Actor;
101
- resumeReason?: AgentTurnResumeReason;
103
+ resumeReason?: TurnPauseReason;
102
104
  reasoningLevel?: string;
103
105
  errorMessage?: string;
104
106
  resumedFromSliceId?: number;
@@ -106,9 +108,8 @@ export declare function upsertAgentTurnSessionRecord(args: {
106
108
  turnContexts?: PluginTurnContext[];
107
109
  turnStartMessageIndex?: number;
108
110
  ttlMs?: number;
109
- }): Promise<AgentTurnSessionRecord>;
110
- /** Record turn-session metadata without storing conversation messages. */
111
- export declare function recordAgentTurnSessionSummary(args: {
111
+ }): Promise<TurnRecord>;
112
+ type TurnSummaryWrite = {
112
113
  channelName?: string;
113
114
  conversationId: string;
114
115
  cumulativeDurationMs?: number;
@@ -117,7 +118,6 @@ export declare function recordAgentTurnSessionSummary(args: {
117
118
  dispatchId?: string;
118
119
  dispatchOutcome?: AgentDispatchOutcome;
119
120
  resultMessageId?: string;
120
- /** Confirmed destination visibility; omit when unavailable. */
121
121
  destinationVisibility?: ConversationPrivacy;
122
122
  source?: Source;
123
123
  lastProgressAtMs?: number;
@@ -125,28 +125,38 @@ export declare function recordAgentTurnSessionSummary(args: {
125
125
  modelId?: string;
126
126
  conversationStore?: ConversationStore;
127
127
  actor?: Actor;
128
- resumeReason?: AgentTurnResumeReason;
128
+ resumeReason?: TurnPauseReason;
129
129
  reasoningLevel?: string;
130
- sessionId: string;
130
+ turnId: string;
131
131
  sliceId: number;
132
132
  startedAtMs?: number;
133
- state: AgentTurnSessionStatus;
133
+ state: TurnStatus;
134
134
  surface?: AgentTurnSurface;
135
135
  traceId?: string;
136
136
  ttlMs?: number;
137
- }): Promise<void>;
138
- /** List retained turn-session recovery projections for one conversation. */
139
- export declare function listAgentTurnSessionSummariesForConversation(conversationId: string): Promise<AgentTurnSessionSummary[]>;
140
- /** Mark an unfinished turn session record as abandoned when a newer turn wins. */
141
- export declare function abandonAgentTurnSessionRecord(args: {
137
+ };
138
+ /** Record turn metadata without storing conversation messages. */
139
+ export declare function recordTurnSummary(args: TurnSummaryWrite): Promise<void>;
140
+ /** List retained turn recovery projections for one conversation. */
141
+ export declare function listTurnSummaries(conversationId: string): Promise<TurnSummary[]>;
142
+ /** Mark an unfinished turn cursor as abandoned when a newer turn wins. */
143
+ export declare function abandonTurnRecord(args: {
142
144
  conversationId: string;
143
- sessionId: string;
145
+ turnId: string;
144
146
  errorMessage?: string;
145
- }): Promise<AgentTurnSessionRecord | undefined>;
146
- /** Mark an unfinished turn session record as failed so it cannot resume. */
147
- export declare function failAgentTurnSessionRecord(args: {
147
+ }): Promise<TurnRecord | undefined>;
148
+ /** Mark an unfinished turn cursor as completed after delivery was accepted. */
149
+ export declare function completeTurnRecord(args: {
150
+ conversationId: string;
151
+ expectedVersion: number;
152
+ resultMessageId?: string;
153
+ turnId: string;
154
+ }): Promise<TurnRecord | undefined>;
155
+ /** Mark an unfinished turn cursor as failed so it cannot resume. */
156
+ export declare function failTurnRecord(args: {
148
157
  conversationId: string;
149
158
  expectedVersion: number;
150
- sessionId: string;
159
+ turnId: string;
151
160
  errorMessage?: string;
152
- }): Promise<AgentTurnSessionRecord | undefined>;
161
+ }): Promise<TurnRecord | undefined>;
162
+ export {};
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Continue a paused turn via the conversation work queue.
3
+ *
4
+ * Wake-only: mailbox/lease own liveness; this just nudges the worker.
5
+ */
6
+ import type { StateAdapter } from "chat";
7
+ import type { Destination } from "@sentry/junior-plugin-api";
8
+ import type { ConversationStore } from "@/chat/conversations/store";
9
+ import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
10
+ export interface PausedTurnRequest {
11
+ conversationId: string;
12
+ destination: Destination;
13
+ expectedVersion: number;
14
+ turnId: string;
15
+ }
16
+ interface TurnWakeOptions {
17
+ nowMs?: number;
18
+ queue?: ConversationWorkQueue;
19
+ state?: StateAdapter;
20
+ }
21
+ /** Build the worker input for a paused turn. */
22
+ export declare function getPausedTurnRequest(args: {
23
+ conversationId: string;
24
+ conversationStore?: ConversationStore;
25
+ turnId: string;
26
+ }): Promise<PausedTurnRequest | undefined>;
27
+ /** Wake the conversation worker for a paused turn. */
28
+ export declare function wakePausedTurn(request: PausedTurnRequest, options?: TurnWakeOptions): Promise<void>;
29
+ export {};
@@ -2,7 +2,7 @@ import type { FileUpload } from "chat";
2
2
  import type { Destination, Identity, LocalDestination, LocalSource, PluginEgress, SlackDestination, SlackSource, Source, User } from "@sentry/junior-plugin-api";
3
3
  import type { McpToolManager } from "@/chat/mcp/tool-manager";
4
4
  import type { SandboxWorkspace } from "@/chat/sandbox/workspace";
5
- import type { AgentTurnSurface } from "@/chat/state/turn-session";
5
+ import type { AgentTurnSurface } from "@/chat/task-execution/checkpoint";
6
6
  import type { ThreadArtifactsState } from "@/chat/state/artifacts";
7
7
  import type { Skill } from "@/chat/skills";
8
8
  import type { LoadSkillMetadata } from "@/chat/tools/skill/load-skill";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_SQL_STATEMENT_TIMEOUT_MS
3
- } from "./chunk-3GU4PWA3.js";
3
+ } from "./chunk-XFKIRN3Q.js";
4
4
  import {
5
5
  juniorDestinations,
6
6
  timestamptz
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-6GWA276C.js";
10
10
  import {
11
11
  getDeploymentTelemetryAttributes
12
- } from "./chunk-WTX2RFJG.js";
12
+ } from "./chunk-DS3J6WGY.js";
13
13
 
14
14
  // src/chat/logging.ts
15
15
  import path from "path";
@@ -5,12 +5,12 @@ import {
5
5
  juniorConversations,
6
6
  juniorIdentities,
7
7
  juniorUsers
8
- } from "./chunk-HNO2E5WB.js";
8
+ } from "./chunk-27TEJTZO.js";
9
9
  import {
10
10
  TURN_REASONING_LEVELS,
11
11
  getChatConfig,
12
12
  modelProfileSchema
13
- } from "./chunk-3GU4PWA3.js";
13
+ } from "./chunk-XFKIRN3Q.js";
14
14
  import {
15
15
  juniorDestinations
16
16
  } from "./chunk-VFUK3X5B.js";
@@ -20,7 +20,7 @@ import {
20
20
  } from "./chunk-F3B2YJ76.js";
21
21
  import {
22
22
  normalizeIdentityEmail
23
- } from "./chunk-RIFJUJSI.js";
23
+ } from "./chunk-2LWPFSB4.js";
24
24
 
25
25
  // src/chat/conversations/sql/store.ts
26
26
  import { randomUUID as randomUUID2 } from "crypto";
@@ -376,16 +376,17 @@ function destinationUpsertFromDestination(args) {
376
376
  };
377
377
  }
378
378
  function executionStatusFromValue(value) {
379
- if (value === "awaiting_resume" || value === "failed" || value === "idle" || value === "pending" || value === "running") {
379
+ if (value === "awaiting_resume" || value === "paused") return "paused";
380
+ if (value === "failed" || value === "idle" || value === "pending" || value === "running") {
380
381
  return value;
381
382
  }
382
383
  throw new Error("Conversation record execution status is invalid");
383
384
  }
385
+ function executionStatusToSql(status) {
386
+ return status === "paused" ? "awaiting_resume" : status;
387
+ }
384
388
  function actorFromIdentityRow(identity, userDisplayName) {
385
- if (!identity) {
386
- return void 0;
387
- }
388
- if (identity.provider !== "slack") {
389
+ if (!identity || identity.provider !== "slack") {
389
390
  return void 0;
390
391
  }
391
392
  const fullName = userDisplayName?.trim() ? userDisplayName : identity.displayName;
@@ -816,7 +817,7 @@ var SqlStore = class {
816
817
  lastActivityAt: dateFromMs2(conversation.lastActivityAtMs),
817
818
  updatedAt: dateFromMs2(conversation.updatedAtMs),
818
819
  executionUpdatedAt: conversation.execution.updatedAtMs === void 0 ? null : dateFromMs2(conversation.execution.updatedAtMs),
819
- executionStatus: conversation.execution.status,
820
+ executionStatus: executionStatusToSql(conversation.execution.status),
820
821
  runId: conversation.execution.runId ?? null,
821
822
  lastCheckpointAt: conversation.execution.lastCheckpointAtMs === void 0 ? null : dateFromMs2(conversation.execution.lastCheckpointAtMs),
822
823
  lastEnqueuedAt: conversation.execution.lastEnqueuedAtMs === void 0 ? null : dateFromMs2(conversation.execution.lastEnqueuedAtMs),