@sentry/junior 0.65.0 → 0.65.1

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 (69) hide show
  1. package/dist/app.d.ts +3 -0
  2. package/dist/app.js +3299 -1343
  3. package/dist/chat/agent-dispatch/heartbeat.d.ts +8 -0
  4. package/dist/chat/agent-dispatch/store.d.ts +2 -2
  5. package/dist/chat/agent-dispatch/types.d.ts +8 -22
  6. package/dist/chat/agent-dispatch/validation.d.ts +3 -1
  7. package/dist/chat/app/production.d.ts +11 -5
  8. package/dist/chat/capabilities/factory.d.ts +2 -1
  9. package/dist/chat/capabilities/router.d.ts +3 -2
  10. package/dist/chat/config.d.ts +5 -0
  11. package/dist/chat/credentials/broker.d.ts +2 -1
  12. package/dist/chat/credentials/context.d.ts +28 -0
  13. package/dist/chat/credentials/subject.d.ts +20 -0
  14. package/dist/chat/ingress/slack-webhook.d.ts +19 -0
  15. package/dist/chat/mcp/errors.d.ts +1 -1
  16. package/dist/chat/plugins/github-permissions.d.ts +11 -0
  17. package/dist/chat/plugins/types.d.ts +2 -0
  18. package/dist/chat/prompt.d.ts +2 -0
  19. package/dist/chat/respond-helpers.d.ts +4 -2
  20. package/dist/chat/respond.d.ts +23 -13
  21. package/dist/chat/runtime/processing-reaction.d.ts +1 -0
  22. package/dist/chat/runtime/reply-executor.d.ts +5 -0
  23. package/dist/chat/runtime/request-deadline.d.ts +8 -0
  24. package/dist/chat/runtime/slack-resume.d.ts +4 -5
  25. package/dist/chat/runtime/slack-runtime.d.ts +10 -0
  26. package/dist/chat/runtime/thread-context.d.ts +5 -2
  27. package/dist/chat/runtime/timeout-resume-runner.d.ts +19 -0
  28. package/dist/chat/runtime/turn-preparation.d.ts +1 -0
  29. package/dist/chat/runtime/turn.d.ts +13 -0
  30. package/dist/chat/sandbox/egress-policy.d.ts +1 -1
  31. package/dist/chat/sandbox/egress-session.d.ts +13 -12
  32. package/dist/chat/sandbox/sandbox.d.ts +2 -3
  33. package/dist/chat/services/timeout-resume.d.ts +9 -4
  34. package/dist/chat/services/turn-session-record.d.ts +19 -2
  35. package/dist/chat/slack/adapter-context.d.ts +25 -0
  36. package/dist/chat/slack/conversation-context.d.ts +28 -0
  37. package/dist/chat/state/turn-session.d.ts +1 -1
  38. package/dist/chat/task-execution/heartbeat.d.ts +13 -0
  39. package/dist/chat/task-execution/queue-signing.d.ts +12 -0
  40. package/dist/chat/task-execution/queue.d.ts +13 -0
  41. package/dist/chat/task-execution/slack-work.d.ts +32 -0
  42. package/dist/chat/task-execution/store.d.ts +153 -0
  43. package/dist/chat/task-execution/vercel-callback.d.ts +21 -0
  44. package/dist/chat/task-execution/vercel-queue.d.ts +16 -0
  45. package/dist/chat/task-execution/worker.d.ts +28 -0
  46. package/dist/{chunk-EDHJIYHS.js → chunk-657CJCUO.js} +218 -62
  47. package/dist/chunk-6YY4Q3D4.js +12 -0
  48. package/dist/chunk-75UZ4JLC.js +213 -0
  49. package/dist/{chunk-PYU2YB35.js → chunk-F57QSMOJ.js} +1 -1
  50. package/dist/{chunk-K3JNVV4Q.js → chunk-HRQQS63X.js} +2 -2
  51. package/dist/{chunk-SCQPBJAU.js → chunk-QUXPUKBH.js} +1 -7
  52. package/dist/{chunk-7KZXQNA6.js → chunk-X2HJLKQT.js} +368 -13
  53. package/dist/{chunk-OMQ5X5QH.js → chunk-ZOV3XJAH.js} +3 -2
  54. package/dist/cli/check.js +115 -2
  55. package/dist/cli/init.js +13 -1
  56. package/dist/cli/snapshot-warmup.js +3 -3
  57. package/dist/deployment.d.ts +4 -0
  58. package/dist/handlers/heartbeat.d.ts +5 -1
  59. package/dist/handlers/turn-resume.d.ts +3 -2
  60. package/dist/handlers/webhooks.d.ts +11 -9
  61. package/dist/nitro.d.ts +3 -1
  62. package/dist/nitro.js +48 -4
  63. package/dist/reporting.js +13 -16
  64. package/dist/vercel.d.ts +1 -1
  65. package/dist/vercel.js +1 -1
  66. package/package.json +5 -4
  67. package/dist/chat/services/turn-continuation-response.d.ts +0 -2
  68. package/dist/chat/slack/turn-continuation-notice.d.ts +0 -8
  69. package/dist/chunk-5VDO6LSG.js +0 -104
@@ -1,6 +1,7 @@
1
1
  import { type AgentTurnSessionRecord, type AgentTurnRequester } from "@/chat/state/turn-session";
2
2
  import type { PiMessage } from "@/chat/pi/messages";
3
3
  import { type AgentTurnUsage } from "@/chat/usage";
4
+ export declare const AGENT_TURN_TIMEOUT_RESUME_MAX_SLICES = 48;
4
5
  export interface TurnSessionContext {
5
6
  conversationId?: string;
6
7
  sessionId?: string;
@@ -31,7 +32,7 @@ export declare function persistRunningSessionRecord(args: {
31
32
  loadedSkillNames?: string[];
32
33
  logContext: SessionRecordLogContext;
33
34
  requester?: AgentTurnRequester;
34
- }): Promise<void>;
35
+ }): Promise<boolean>;
35
36
  /** Persist a completed turn session record. */
36
37
  export declare function persistCompletedSessionRecord(args: {
37
38
  channelName?: string;
@@ -64,7 +65,7 @@ export declare function persistAuthPauseSessionRecord(args: {
64
65
  }): Promise<AgentTurnSessionRecord | undefined>;
65
66
  /**
66
67
  * Persist a timeout session record at the last safe boundary. Returns the durable
67
- * record when persistence succeeds so callers can enqueue a continuation.
68
+ * record so callers can distinguish scheduled continuations from terminal caps.
68
69
  */
69
70
  export declare function persistTimeoutSessionRecord(args: {
70
71
  channelName?: string;
@@ -79,4 +80,20 @@ export declare function persistTimeoutSessionRecord(args: {
79
80
  logContext: SessionRecordLogContext;
80
81
  requester?: AgentTurnRequester;
81
82
  }): Promise<AgentTurnSessionRecord | undefined>;
83
+ /**
84
+ * Persist a cooperative-yield boundary without advancing timeout slice counts.
85
+ */
86
+ export declare function persistYieldSessionRecord(args: {
87
+ channelName?: string;
88
+ conversationId: string;
89
+ sessionId: string;
90
+ currentSliceId: number;
91
+ currentDurationMs?: number;
92
+ currentUsage?: AgentTurnUsage;
93
+ messages: PiMessage[];
94
+ loadedSkillNames?: string[];
95
+ errorMessage: string;
96
+ logContext: SessionRecordLogContext;
97
+ requester?: AgentTurnRequester;
98
+ }): Promise<AgentTurnSessionRecord | undefined>;
82
99
  export {};
@@ -0,0 +1,25 @@
1
+ import type { SlackAdapter } from "@chat-adapter/slack";
2
+ import type { StateAdapter } from "chat";
3
+ export interface SlackInstallationContext {
4
+ enterpriseId?: string;
5
+ isEnterpriseInstall?: boolean;
6
+ teamId?: string;
7
+ }
8
+ /** Initialize the Slack adapter against the repository state adapter. */
9
+ export declare function ensureSlackAdapterInitialized(args: {
10
+ adapter: SlackAdapter;
11
+ state?: StateAdapter;
12
+ }): Promise<void>;
13
+ /** Verify a Slack request using the adapter's configured signing secret. */
14
+ export declare function verifySlackSignature(args: {
15
+ adapter: SlackAdapter;
16
+ body: string;
17
+ request: Request;
18
+ }): boolean;
19
+ /** Run Slack work with the installation token that matches the inbound event. */
20
+ export declare function runWithSlackInstallation<T>(args: {
21
+ adapter: SlackAdapter;
22
+ installation: SlackInstallationContext;
23
+ state?: StateAdapter;
24
+ task: () => T | Promise<T>;
25
+ }): Promise<T>;
@@ -0,0 +1,28 @@
1
+ /** Slack Events API channel_type values relevant to message surfaces. */
2
+ export type SlackEventChannelType = "channel" | "group" | "mpim" | "im";
3
+ /** Slack conversation categories Junior can share with agents. */
4
+ export type SlackConversationType = "public_channel" | "private_channel" | "group_dm" | "direct_message" | "private_channel_or_group_dm";
5
+ /** Slack conversation facts available to the bot for runtime context. */
6
+ export interface SlackConversationContext {
7
+ type: SlackConversationType;
8
+ name?: string;
9
+ }
10
+ /** Resolve Slack's raw event channel type from a Chat SDK message-like object. */
11
+ export declare function resolveSlackChannelTypeFromMessage(message: unknown): SlackEventChannelType | undefined;
12
+ /** Build Slack conversation facts available to runtime consumers. */
13
+ export declare function resolveSlackConversationContext(input: {
14
+ channelId?: string;
15
+ channelName?: string;
16
+ channelType?: SlackEventChannelType;
17
+ }): SlackConversationContext | undefined;
18
+ /** Build Slack conversation facts from Junior's persisted Slack thread id. */
19
+ export declare function resolveSlackConversationContextFromThreadId(input: {
20
+ threadId?: string;
21
+ channelName?: string;
22
+ }): SlackConversationContext | undefined;
23
+ /** Render a human label for a privacy-preserving Slack conversation type. */
24
+ export declare function formatSlackConversationTypeLabel(type: SlackConversationType): string;
25
+ /** Render a Slack conversation label for surfaces allowed to expose names. */
26
+ export declare function formatSlackConversationContextLabel(context: SlackConversationContext | undefined): string | undefined;
27
+ /** Render a Slack conversation label without exposing conversation names. */
28
+ export declare function formatSlackConversationRedactedLabel(context: SlackConversationContext | undefined): string | undefined;
@@ -1,7 +1,7 @@
1
1
  import type { PiMessage } from "@/chat/pi/messages";
2
2
  import type { AgentTurnUsage } from "@/chat/usage";
3
3
  export type AgentTurnSessionStatus = "running" | "awaiting_resume" | "completed" | "failed" | "abandoned";
4
- export type AgentTurnResumeReason = "timeout" | "auth";
4
+ export type AgentTurnResumeReason = "timeout" | "auth" | "yield";
5
5
  export interface AgentTurnRequester {
6
6
  email?: string;
7
7
  fullName?: string;
@@ -0,0 +1,13 @@
1
+ import type { StateAdapter } from "chat";
2
+ import type { ConversationWorkQueue } from "./queue";
3
+ export interface ConversationWorkRecoveryResult {
4
+ expiredLeaseCount: number;
5
+ pendingCount: number;
6
+ }
7
+ /** Requeue expired leases and stranded mailbox work without running the agent. */
8
+ export declare function recoverConversationWork(args: {
9
+ limit?: number;
10
+ nowMs: number;
11
+ queue: ConversationWorkQueue;
12
+ state?: StateAdapter;
13
+ }): Promise<ConversationWorkRecoveryResult>;
@@ -0,0 +1,12 @@
1
+ import type { ConversationQueueMessage } from "./queue";
2
+ declare const CONVERSATION_WORK_QUEUE_SIGNATURE_VERSION = "v1";
3
+ interface SignedConversationQueueMessage extends ConversationQueueMessage {
4
+ signature: string;
5
+ signatureVersion: typeof CONVERSATION_WORK_QUEUE_SIGNATURE_VERSION;
6
+ signedAtMs: number;
7
+ }
8
+ /** Sign a conversation queue payload before it crosses the public callback route. */
9
+ export declare function signConversationQueueMessage(message: ConversationQueueMessage, nowMs?: number): SignedConversationQueueMessage;
10
+ /** Verify a signed conversation queue payload from the Vercel Queue callback. */
11
+ export declare function verifySignedConversationQueueMessage(value: unknown, nowMs?: number): ConversationQueueMessage | undefined;
12
+ export {};
@@ -0,0 +1,13 @@
1
+ export interface ConversationQueueMessage {
2
+ conversationId: string;
3
+ }
4
+ export interface ConversationQueueSendOptions {
5
+ delayMs?: number;
6
+ idempotencyKey?: string;
7
+ }
8
+ export interface ConversationQueueSendResult {
9
+ messageId?: string;
10
+ }
11
+ export interface ConversationWorkQueue {
12
+ send(message: ConversationQueueMessage, options?: ConversationQueueSendOptions): Promise<ConversationQueueSendResult | void>;
13
+ }
@@ -0,0 +1,32 @@
1
+ import type { SlackAdapter } from "@chat-adapter/slack";
2
+ import { Message, ThreadImpl, type SerializedMessage, type SerializedThread, type StateAdapter } from "chat";
3
+ import type { SlackTurnRuntime } from "@/chat/runtime/slack-runtime";
4
+ import type { InboundMessageRecord } from "@/chat/task-execution/store";
5
+ import type { ConversationWorkerContext, ConversationWorkerResult } from "@/chat/task-execution/worker";
6
+ import { type SlackInstallationContext } from "@/chat/slack/adapter-context";
7
+ export type SlackConversationRoute = "mention" | "subscribed";
8
+ export interface SlackConversationMessageMetadata {
9
+ [key: string]: unknown;
10
+ installation?: SlackInstallationContext;
11
+ message: SerializedMessage;
12
+ platform: "slack";
13
+ route: SlackConversationRoute;
14
+ thread: SerializedThread;
15
+ }
16
+ export interface CreateSlackConversationWorkerOptions {
17
+ getSlackAdapter: () => SlackAdapter;
18
+ resumeAwaitingContinuation?: (conversationId: string) => Promise<boolean>;
19
+ runtime: Pick<SlackTurnRuntime<unknown>, "handleNewMention" | "handleSubscribedMessage">;
20
+ state?: StateAdapter;
21
+ }
22
+ /** Build the worker run function for queued Slack conversation work. */
23
+ export declare function createSlackConversationWorker(options: CreateSlackConversationWorkerOptions): (context: ConversationWorkerContext) => Promise<ConversationWorkerResult>;
24
+ /** Serialize a Slack message into the generic durable conversation mailbox. */
25
+ export declare function buildSlackInboundMessage(args: {
26
+ conversationId: string;
27
+ installation?: SlackInstallationContext;
28
+ message: Message;
29
+ receivedAtMs: number;
30
+ route: SlackConversationRoute;
31
+ thread: ThreadImpl;
32
+ }): InboundMessageRecord;
@@ -0,0 +1,153 @@
1
+ import type { StateAdapter } from "chat";
2
+ import type { ConversationWorkQueue } from "./queue";
3
+ export declare const CONVERSATION_WORK_LEASE_TTL_MS = 90000;
4
+ export declare const CONVERSATION_WORK_CHECK_IN_INTERVAL_MS = 15000;
5
+ export declare const CONVERSATION_WORK_STALE_ENQUEUE_MS = 60000;
6
+ export type InboundMessageSource = "plugin" | "scheduler" | "slack";
7
+ export interface AgentInputMessage {
8
+ attachments?: unknown[];
9
+ authorId?: string;
10
+ metadata?: Record<string, unknown>;
11
+ text: string;
12
+ }
13
+ export interface InboundMessageRecord {
14
+ conversationId: string;
15
+ createdAtMs: number;
16
+ inboundMessageId: string;
17
+ injectedAtMs?: number;
18
+ input: AgentInputMessage;
19
+ receivedAtMs: number;
20
+ source: InboundMessageSource;
21
+ }
22
+ export interface ConversationLease {
23
+ acquiredAtMs: number;
24
+ lastCheckInAtMs: number;
25
+ leaseExpiresAtMs: number;
26
+ leaseToken: string;
27
+ }
28
+ export interface ConversationWorkState {
29
+ conversationId: string;
30
+ lastEnqueuedAtMs?: number;
31
+ lease?: ConversationLease;
32
+ messages: InboundMessageRecord[];
33
+ needsRun: boolean;
34
+ schemaVersion: 1;
35
+ updatedAtMs: number;
36
+ }
37
+ export interface ConversationLeaseAcquired {
38
+ leaseExpiresAtMs: number;
39
+ leaseToken: string;
40
+ status: "acquired";
41
+ }
42
+ export interface ConversationLeaseActive {
43
+ leaseExpiresAtMs: number;
44
+ status: "active";
45
+ }
46
+ export interface ConversationLeaseNoWork {
47
+ status: "no_work";
48
+ }
49
+ export type ConversationLeaseStartResult = ConversationLeaseAcquired | ConversationLeaseActive | ConversationLeaseNoWork;
50
+ export interface AppendInboundMessageResult {
51
+ status: "appended" | "duplicate";
52
+ }
53
+ export interface AppendAndEnqueueInboundMessageResult extends AppendInboundMessageResult {
54
+ queueMessageId?: string;
55
+ }
56
+ export interface RequestConversationWorkResult {
57
+ status: "created" | "updated";
58
+ }
59
+ /** Return a persisted conversation work record, if one exists. */
60
+ export declare function getConversationWorkState(args: {
61
+ conversationId: string;
62
+ state?: StateAdapter;
63
+ }): Promise<ConversationWorkState | undefined>;
64
+ /** Count mailbox messages that have not yet reached the session log. */
65
+ export declare function countPendingConversationMessages(state: ConversationWorkState): number;
66
+ /** Return whether a conversation has pending or resumable execution work. */
67
+ export declare function hasRunnableConversationWork(state: ConversationWorkState): boolean;
68
+ /** Persist one inbound message idempotently in its conversation mailbox. */
69
+ export declare function appendInboundMessage(args: {
70
+ message: InboundMessageRecord;
71
+ nowMs?: number;
72
+ state?: StateAdapter;
73
+ }): Promise<AppendInboundMessageResult>;
74
+ /** Persist inbound work and send the queue nudge that wakes a worker. */
75
+ export declare function appendAndEnqueueInboundMessage(args: {
76
+ message: InboundMessageRecord;
77
+ nowMs?: number;
78
+ queue: ConversationWorkQueue;
79
+ state?: StateAdapter;
80
+ }): Promise<AppendAndEnqueueInboundMessageResult>;
81
+ /** Mark a conversation runnable when there is no new mailbox message. */
82
+ export declare function requestConversationWork(args: {
83
+ conversationId: string;
84
+ nowMs?: number;
85
+ state?: StateAdapter;
86
+ }): Promise<RequestConversationWorkResult>;
87
+ /** Record that a wake-up nudge was accepted for the conversation. */
88
+ export declare function markConversationWorkEnqueued(args: {
89
+ conversationId: string;
90
+ nowMs?: number;
91
+ state?: StateAdapter;
92
+ }): Promise<void>;
93
+ /** Try to acquire the durable execution lease for one conversation. */
94
+ export declare function startConversationWork(args: {
95
+ conversationId: string;
96
+ nowMs?: number;
97
+ state?: StateAdapter;
98
+ }): Promise<ConversationLeaseStartResult>;
99
+ /** Extend the durable execution lease when the worker checks in. */
100
+ export declare function checkInConversationWork(args: {
101
+ conversationId: string;
102
+ leaseToken: string;
103
+ nowMs?: number;
104
+ state?: StateAdapter;
105
+ }): Promise<boolean>;
106
+ /** Drain pending mailbox entries after the caller has durably injected them. */
107
+ export declare function drainConversationMailbox(args: {
108
+ conversationId: string;
109
+ inject: (messages: InboundMessageRecord[]) => Promise<void>;
110
+ leaseToken: string;
111
+ nowMs?: number;
112
+ state?: StateAdapter;
113
+ }): Promise<InboundMessageRecord[]>;
114
+ /** Mark selected leased mailbox entries after their session-log injection succeeds. */
115
+ export declare function markConversationMessagesInjected(args: {
116
+ conversationId: string;
117
+ inboundMessageIds: string[];
118
+ leaseToken: string;
119
+ nowMs?: number;
120
+ state?: StateAdapter;
121
+ }): Promise<boolean>;
122
+ /** Mark the leased conversation as needing another queue-delivered slice. */
123
+ export declare function requestConversationContinuation(args: {
124
+ conversationId: string;
125
+ leaseToken: string;
126
+ nowMs?: number;
127
+ state?: StateAdapter;
128
+ }): Promise<boolean>;
129
+ /** Release the durable execution lease without changing completion state. */
130
+ export declare function releaseConversationWork(args: {
131
+ conversationId: string;
132
+ leaseToken: string;
133
+ nowMs?: number;
134
+ state?: StateAdapter;
135
+ }): Promise<boolean>;
136
+ /** Finish a leased conversation and report whether runnable work remains. */
137
+ export declare function completeConversationWork(args: {
138
+ conversationId: string;
139
+ leaseToken: string;
140
+ nowMs?: number;
141
+ state?: StateAdapter;
142
+ }): Promise<"completed" | "lost_lease" | "pending">;
143
+ /** Clear an expired durable lease so a later worker can resume safely. */
144
+ export declare function clearExpiredConversationLease(args: {
145
+ conversationId: string;
146
+ nowMs?: number;
147
+ state?: StateAdapter;
148
+ }): Promise<boolean>;
149
+ /** List bounded conversation ids that may need heartbeat recovery. */
150
+ export declare function listConversationWorkIds(args?: {
151
+ limit?: number;
152
+ state?: StateAdapter;
153
+ }): Promise<string[]>;
@@ -0,0 +1,21 @@
1
+ import type { StateAdapter } from "chat";
2
+ import type { ConversationWorkQueue } from "./queue";
3
+ import { type ConversationWorkProcessResult, type ConversationWorkerResult, type ConversationWorkerContext } from "./worker";
4
+ export declare const CONVERSATION_WORK_VISIBILITY_TIMEOUT_BUFFER_SECONDS = 30;
5
+ export interface ProcessConversationQueueMessageOptions {
6
+ checkInIntervalMs?: number;
7
+ nowMs?: () => number;
8
+ queue?: ConversationWorkQueue;
9
+ run(context: ConversationWorkerContext): Promise<ConversationWorkerResult>;
10
+ softYieldAfterMs?: number;
11
+ state?: StateAdapter;
12
+ }
13
+ export interface VercelConversationWorkCallbackOptions extends ProcessConversationQueueMessageOptions {
14
+ visibilityTimeoutSeconds?: number;
15
+ }
16
+ /** Resolve queue visibility so redelivery waits past the host timeout boundary. */
17
+ export declare function resolveConversationWorkVisibilityTimeoutSeconds(functionMaxDurationSeconds?: number): number;
18
+ /** Process one Vercel Queue payload with the generic conversation worker. */
19
+ export declare function processConversationQueueMessage(message: unknown, options: ProcessConversationQueueMessageOptions): Promise<ConversationWorkProcessResult>;
20
+ /** Create the Vercel Queue push callback for conversation work nudges. */
21
+ export declare function createVercelConversationWorkCallback(options: VercelConversationWorkCallbackOptions): (request: Request) => Promise<Response>;
@@ -0,0 +1,16 @@
1
+ import type { SendOptions, SendResult } from "@vercel/queue";
2
+ import type { ConversationWorkQueue } from "./queue";
3
+ export declare const DEFAULT_CONVERSATION_WORK_QUEUE_TOPIC = "junior_conversation_work";
4
+ interface QueueSender {
5
+ send<T = unknown>(topicName: string, payload: T, options?: SendOptions): Promise<SendResult>;
6
+ }
7
+ export interface VercelConversationWorkQueueOptions {
8
+ client?: QueueSender;
9
+ retentionSeconds?: number;
10
+ topic?: string;
11
+ }
12
+ /** Create the Vercel Queue implementation for conversation wake-up nudges. */
13
+ export declare function createVercelConversationWorkQueue(options?: VercelConversationWorkQueueOptions): ConversationWorkQueue;
14
+ /** Return the default production conversation work queue. */
15
+ export declare function getVercelConversationWorkQueue(): ConversationWorkQueue;
16
+ export {};
@@ -0,0 +1,28 @@
1
+ import type { StateAdapter } from "chat";
2
+ import type { ConversationWorkQueue } from "./queue";
3
+ import { type InboundMessageRecord } from "./store";
4
+ export declare const CONVERSATION_WORK_DEFER_DELAY_MS = 15000;
5
+ export declare const CONVERSATION_WORK_SOFT_YIELD_AFTER_MS = 240000;
6
+ export interface ConversationWorkerContext {
7
+ checkIn(): Promise<boolean>;
8
+ conversationId: string;
9
+ drainMailbox(inject: (messages: InboundMessageRecord[]) => Promise<void>): Promise<InboundMessageRecord[]>;
10
+ leaseToken: string;
11
+ shouldYield(): boolean;
12
+ }
13
+ export interface ConversationWorkerResult {
14
+ status: "completed" | "lost_lease" | "yielded";
15
+ }
16
+ export interface ConversationWorkProcessResult {
17
+ status: "active" | "completed" | "lost_lease" | "no_work" | "pending_requeued" | "yielded";
18
+ }
19
+ export interface ProcessConversationWorkOptions {
20
+ checkInIntervalMs?: number;
21
+ nowMs?: () => number;
22
+ queue: ConversationWorkQueue;
23
+ run(context: ConversationWorkerContext): Promise<ConversationWorkerResult>;
24
+ softYieldAfterMs?: number;
25
+ state?: StateAdapter;
26
+ }
27
+ /** Process one queue wake-up for a conversation. */
28
+ export declare function processConversationWork(conversationId: string, options: ProcessConversationWorkOptions): Promise<ConversationWorkProcessResult>;