@sentry/junior 0.71.3 → 0.73.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 (103) hide show
  1. package/bin/junior.mjs +22 -10
  2. package/dist/api-reference.d.ts +2 -0
  3. package/dist/app.d.ts +12 -3
  4. package/dist/app.js +2522 -15560
  5. package/dist/chat/agent-dispatch/heartbeat.d.ts +0 -6
  6. package/dist/chat/agent-dispatch/runner.d.ts +2 -0
  7. package/dist/chat/agent-dispatch/store.d.ts +2 -2
  8. package/dist/chat/agent-dispatch/types.d.ts +6 -3
  9. package/dist/chat/agent-dispatch/validation.d.ts +2 -3
  10. package/dist/chat/app/production.d.ts +8 -1
  11. package/dist/chat/app/services.d.ts +7 -0
  12. package/dist/chat/destination.d.ts +3 -1
  13. package/dist/chat/logging.d.ts +3 -0
  14. package/dist/chat/mcp/errors.d.ts +3 -0
  15. package/dist/chat/mcp/tool-manager.d.ts +5 -1
  16. package/dist/chat/oauth-flow.d.ts +1 -1
  17. package/dist/chat/plugins/agent-hooks.d.ts +3 -2
  18. package/dist/chat/plugins/registry.d.ts +2 -0
  19. package/dist/chat/plugins/types.d.ts +2 -0
  20. package/dist/chat/prompt.d.ts +4 -1
  21. package/dist/chat/requester.d.ts +67 -0
  22. package/dist/chat/respond.d.ts +8 -8
  23. package/dist/chat/runtime/agent-continue-runner.d.ts +25 -0
  24. package/dist/chat/runtime/reply-executor.d.ts +7 -5
  25. package/dist/chat/runtime/slack-resume.d.ts +3 -3
  26. package/dist/chat/runtime/slack-runtime.d.ts +13 -3
  27. package/dist/chat/runtime/turn.d.ts +17 -3
  28. package/dist/chat/sandbox/egress-credentials.d.ts +5 -2
  29. package/dist/chat/sandbox/egress-policy.d.ts +5 -1
  30. package/dist/chat/sandbox/egress-proxy.d.ts +2 -0
  31. package/dist/chat/sandbox/egress-schemas.d.ts +4 -0
  32. package/dist/chat/sandbox/egress-session.d.ts +3 -1
  33. package/dist/chat/sandbox/egress-tracing.d.ts +7 -0
  34. package/dist/chat/sandbox/sandbox.d.ts +2 -0
  35. package/dist/chat/sandbox/session.d.ts +3 -2
  36. package/dist/chat/services/agent-continue.d.ts +27 -0
  37. package/dist/chat/services/auth-pause-response.d.ts +1 -1
  38. package/dist/chat/services/auth-pause.d.ts +2 -1
  39. package/dist/chat/services/mcp-auth-orchestration.d.ts +1 -1
  40. package/dist/chat/services/message-actor-identity.d.ts +12 -4
  41. package/dist/chat/services/plugin-auth-orchestration.d.ts +9 -8
  42. package/dist/chat/services/turn-result.d.ts +3 -0
  43. package/dist/chat/services/turn-session-record.d.ts +10 -7
  44. package/dist/chat/slack/user.d.ts +4 -4
  45. package/dist/chat/state/adapter.d.ts +2 -0
  46. package/dist/chat/state/conversation-details.d.ts +4 -3
  47. package/dist/chat/state/session-log.d.ts +43 -0
  48. package/dist/chat/state/turn-session.d.ts +7 -10
  49. package/dist/chat/task-execution/slack-work.d.ts +5 -5
  50. package/dist/chat/task-execution/store.d.ts +83 -48
  51. package/dist/chat/task-execution/worker.d.ts +3 -3
  52. package/dist/chat/tools/definition.d.ts +3 -0
  53. package/dist/chat/tools/execution/tool-error-handler.d.ts +2 -1
  54. package/dist/chat/tools/slack/canvas-tools.d.ts +3 -2
  55. package/dist/chat/tools/slack/channel-list-messages.d.ts +2 -2
  56. package/dist/chat/tools/slack/channel-post-message.d.ts +3 -2
  57. package/dist/chat/tools/slack/context.d.ts +15 -2
  58. package/dist/chat/tools/slack/message-add-reaction.d.ts +3 -2
  59. package/dist/chat/tools/slack/thread-read.d.ts +2 -2
  60. package/dist/chat/tools/types.d.ts +20 -23
  61. package/dist/{chunk-BBXYXOJW.js → chunk-3BYAPS6B.js} +48 -529
  62. package/dist/{chunk-UXG6TU2U.js → chunk-7Q5YOUUT.js} +16 -93
  63. package/dist/chunk-AL5T52ZD.js +1119 -0
  64. package/dist/chunk-CYUI7JU5.js +195 -0
  65. package/dist/{chunk-R62YWUNO.js → chunk-DIMX5F3T.js} +10 -28
  66. package/dist/chunk-G3E7SCME.js +28 -0
  67. package/dist/chunk-KVZL5NZS.js +519 -0
  68. package/dist/chunk-M4FLLXXD.js +212 -0
  69. package/dist/chunk-OQSYYOLM.js +12787 -0
  70. package/dist/{chunk-GT67ZWZQ.js → chunk-OR6NQJ5E.js} +5 -3
  71. package/dist/{chunk-B5HKWWQB.js → chunk-RY6AL5C7.js} +8 -6
  72. package/dist/chunk-SJHUF3DP.js +43 -0
  73. package/dist/{chunk-XE2VFQQN.js → chunk-UOTZ3EEQ.js} +1 -1
  74. package/dist/{chunk-HOGQL2H6.js → chunk-UZVHXZ7V.js} +1357 -1486
  75. package/dist/{chunk-76YMBKW7.js → chunk-V4VYUY4A.js} +27 -14
  76. package/dist/{chunk-JS4HURDT.js → chunk-WS2EG3GW.js} +224 -224
  77. package/dist/chunk-ZDA2HYX5.js +275 -0
  78. package/dist/cli/chat.js +205 -0
  79. package/dist/cli/check.js +6 -5
  80. package/dist/cli/run.js +18 -2
  81. package/dist/cli/snapshot-warmup.js +11 -8
  82. package/dist/cli/upgrade.js +599 -0
  83. package/dist/deployment.d.ts +4 -0
  84. package/dist/handlers/agent-dispatch.d.ts +6 -1
  85. package/dist/handlers/mcp-oauth-callback.d.ts +6 -1
  86. package/dist/handlers/oauth-callback.d.ts +6 -1
  87. package/dist/handlers/sandbox-egress-proxy.d.ts +2 -0
  88. package/dist/handlers/webhooks.d.ts +4 -2
  89. package/dist/instrumentation.js +17 -2
  90. package/dist/nitro.d.ts +1 -1
  91. package/dist/nitro.js +10 -10
  92. package/dist/plugins.d.ts +1 -1
  93. package/dist/reporting/conversations.d.ts +116 -0
  94. package/dist/reporting.d.ts +24 -129
  95. package/dist/reporting.js +320 -166
  96. package/dist/runner-LMAM4OGD.js +259 -0
  97. package/package.json +3 -3
  98. package/dist/chat/runtime/timeout-resume-runner.d.ts +0 -19
  99. package/dist/chat/services/requester-identity.d.ts +0 -19
  100. package/dist/chat/services/timeout-resume.d.ts +0 -23
  101. package/dist/chunk-6YY4Q3D4.js +0 -12
  102. package/dist/chunk-Z3YD6NHK.js +0 -12
  103. package/dist/handlers/turn-resume.d.ts +0 -4
@@ -0,0 +1,7 @@
1
+ export interface SandboxEgressTracePropagationConfig {
2
+ domains?: string[];
3
+ }
4
+ /** Normalize exact and leading-wildcard sandbox egress trace domains. */
5
+ export declare function normalizeSandboxEgressTracePropagationDomains(domains: string[] | undefined): string[];
6
+ /** Return whether a host may carry sandbox egress trace propagation headers. */
7
+ export declare function shouldPropagateSandboxEgressTrace(host: string, config?: SandboxEgressTracePropagationConfig): boolean;
@@ -1,5 +1,6 @@
1
1
  import { type LogContext } from "@/chat/logging";
2
2
  import { type SandboxEgressAuthRequiredSignal, type SandboxEgressPermissionDeniedSignal } from "@/chat/sandbox/egress-session";
3
+ import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress-tracing";
3
4
  import type { CredentialContext } from "@/chat/credentials/context";
4
5
  import type { AgentPluginHookRunner } from "@/chat/plugins/agent-hooks";
5
6
  import type { SandboxInstance } from "@/chat/sandbox/workspace";
@@ -46,6 +47,7 @@ export declare function createSandboxExecutor(options?: {
46
47
  sandboxDependencyProfileHash?: string;
47
48
  timeoutMs?: number;
48
49
  traceContext?: LogContext;
50
+ tracePropagation?: SandboxEgressTracePropagationConfig;
49
51
  credentialEgress?: CredentialContext;
50
52
  agentHooks?: AgentPluginHookRunner;
51
53
  onSandboxAcquired?: (sandbox: SandboxAcquiredState) => void | Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import { type NetworkPolicy } from "@vercel/sandbox";
2
- import { type LogContext } from "@/chat/logging";
2
+ import { type LogContext, type TracePropagationHeaders } from "@/chat/logging";
3
3
  import { type SandboxFileSystem, type SandboxInstance } from "@/chat/sandbox/workspace";
4
4
  import type { SkillMetadata } from "@/chat/skills";
5
5
  interface SandboxToolExecutors {
@@ -38,6 +38,7 @@ interface SandboxSessionManager {
38
38
  getDependencyProfileHash(): string | undefined;
39
39
  createSandbox(): Promise<SandboxInstance>;
40
40
  ensureToolExecutors(): Promise<SandboxToolExecutors>;
41
+ refreshNetworkPolicy(traceHeaders?: TracePropagationHeaders): Promise<void>;
41
42
  dispose(): Promise<void>;
42
43
  }
43
44
  /** Manage sandbox lifecycle, sync, keepalive, and tool executor caching for one executor instance. */
@@ -47,7 +48,7 @@ export declare function createSandboxSessionManager(options?: {
47
48
  timeoutMs?: number;
48
49
  traceContext?: LogContext;
49
50
  commandEnv?: () => Promise<Record<string, string>>;
50
- createNetworkPolicy?: (egressId: string) => NetworkPolicy | undefined;
51
+ createNetworkPolicy?: (egressId: string, traceHeaders?: TracePropagationHeaders) => NetworkPolicy | undefined;
51
52
  onSandboxPrepare?: (sandbox: SandboxInstance) => void | Promise<void>;
52
53
  onSandboxAcquired?: (sandbox: {
53
54
  sandboxId: string;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Durable agent continuation scheduling.
3
+ *
4
+ * This module owns the queue handoff used when an agent run pauses at a safe
5
+ * Pi continuation boundary and needs another execution slice.
6
+ */
7
+ import type { StateAdapter } from "chat";
8
+ import type { Destination } from "@sentry/junior-plugin-api";
9
+ import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
10
+ export interface AgentContinueRequest {
11
+ conversationId: string;
12
+ destination: Destination;
13
+ expectedVersion: number;
14
+ sessionId: string;
15
+ }
16
+ export interface ScheduleAgentContinueOptions {
17
+ nowMs?: number;
18
+ queue?: ConversationWorkQueue;
19
+ state?: StateAdapter;
20
+ }
21
+ /** Build the queue request for an awaiting automatic agent continuation. */
22
+ export declare function getAwaitingAgentContinueRequest(args: {
23
+ conversationId: string;
24
+ sessionId: string;
25
+ }): Promise<AgentContinueRequest | undefined>;
26
+ /** Schedule durable conversation work to continue a paused agent run. */
27
+ export declare function scheduleAgentContinue(request: AgentContinueRequest, options?: ScheduleAgentContinueOptions): Promise<void>;
@@ -1,2 +1,2 @@
1
1
  /** Build the visible Slack thread note for an auth-paused turn. */
2
- export declare function buildAuthPauseResponse(): string;
2
+ export declare function buildAuthPauseResponse(slackUserId: string | undefined, providerDisplayName: string): string;
@@ -9,7 +9,8 @@ export declare class AuthorizationPauseError extends Error {
9
9
  readonly disposition: AuthorizationPauseDisposition;
10
10
  readonly kind: AuthorizationPauseKind;
11
11
  readonly provider: string;
12
- constructor(kind: AuthorizationPauseKind, provider: string, disposition: AuthorizationPauseDisposition);
12
+ readonly providerDisplayName: string;
13
+ constructor(kind: AuthorizationPauseKind, provider: string, providerDisplayName: string, disposition: AuthorizationPauseDisposition);
13
14
  }
14
15
  /** Error indicating this turn cannot start an external authorization flow. */
15
16
  export declare class AuthorizationFlowDisabledError extends Error {
@@ -5,7 +5,7 @@ import type { ThreadArtifactsState } from "@/chat/state/artifacts";
5
5
  import type { ConversationPendingAuthState } from "@/chat/state/conversation";
6
6
  import type { PluginDefinition } from "@/chat/plugins/types";
7
7
  export declare class McpAuthorizationPauseError extends AuthorizationPauseError {
8
- constructor(provider: string, disposition: "link_already_sent" | "link_sent");
8
+ constructor(provider: string, providerDisplayName: string, disposition: "link_already_sent" | "link_sent");
9
9
  }
10
10
  export interface McpAuthOrchestrationDeps {
11
11
  conversationId?: string;
@@ -1,8 +1,16 @@
1
1
  import type { Message } from "chat";
2
- import { type ActorIdentityInput, type SlackActorProfile } from "@/chat/services/requester-identity";
2
+ import { type Requester, type SlackRequester, type SlackRequesterProfile } from "@/chat/requester";
3
+ interface MessageAuthorIdentity {
4
+ email?: string;
5
+ fullName?: string;
6
+ userId: string;
7
+ userName?: string;
8
+ }
9
+ type MessageActorIdentity = Requester | MessageAuthorIdentity;
3
10
  /** Preserve runtime-owned identity on Chat SDK messages before persistence. */
4
- export declare function bindMessageActorIdentity(message: Message, identity: ActorIdentityInput): ActorIdentityInput;
11
+ export declare function bindMessageActorIdentity(message: Message, requester: Requester): Requester;
5
12
  /** Read message identity without promoting adapter display fallbacks. */
6
- export declare function getMessageActorIdentity(message: Message): ActorIdentityInput | undefined;
13
+ export declare function getMessageActorIdentity(message: Message): MessageActorIdentity | undefined;
7
14
  /** Attach Slack display fields only after the author id is exact. */
8
- export declare function ensureSlackMessageActorIdentity(message: Message, lookupSlackUser: (userId: string) => Promise<SlackActorProfile | null | undefined>): Promise<ActorIdentityInput>;
15
+ export declare function ensureSlackMessageActorIdentity(message: Message, teamId: string, lookupSlackUser: (teamId: string, userId: string) => Promise<SlackRequesterProfile | null | undefined>): Promise<SlackRequester>;
16
+ export {};
@@ -3,9 +3,8 @@ import type { ChannelConfigurationService } from "@/chat/configuration/types";
3
3
  import type { UserTokenStore } from "@/chat/credentials/user-token-store";
4
4
  import { AuthorizationPauseError, type AuthorizationFlowMode } from "@/chat/services/auth-pause";
5
5
  import type { ConversationPendingAuthState } from "@/chat/state/conversation";
6
- import type { Skill } from "@/chat/skills";
7
6
  export declare class PluginAuthorizationPauseError extends AuthorizationPauseError {
8
- constructor(provider: string, disposition: "link_already_sent" | "link_sent");
7
+ constructor(provider: string, providerDisplayName: string, disposition: "link_already_sent" | "link_sent");
9
8
  }
10
9
  export declare class PluginCredentialFailureError extends Error {
11
10
  readonly provider: string;
@@ -26,14 +25,16 @@ export interface PluginAuthOrchestrationDeps {
26
25
  userTokenStore?: UserTokenStore;
27
26
  }
28
27
  export interface PluginAuthOrchestration {
29
- handleCommandFailure: (input: {
30
- activeSkill: Skill | null;
31
- command: string;
32
- details: unknown;
33
- }) => Promise<void>;
28
+ /**
29
+ * Inspect a sandbox tool result for an `auth_required` signal from the
30
+ * egress proxy. If one is present and an OAuth flow is available, parks the
31
+ * current turn and sends the user an authorization link. No-ops when the
32
+ * result carries no auth signal.
33
+ */
34
+ maybeHandleAuthSignal: (details: unknown) => Promise<void>;
34
35
  getPendingPause: () => PluginAuthorizationPauseError | undefined;
35
36
  }
36
37
  /**
37
- * Start plugin OAuth from an authenticated bash command and park the turn.
38
+ * Start plugin OAuth from a sandbox egress auth signal and park the turn.
38
39
  */
39
40
  export declare function createPluginAuthOrchestration(deps: PluginAuthOrchestrationDeps, abortAgent: () => void): PluginAuthOrchestration;
@@ -1,5 +1,6 @@
1
1
  import type { FileUpload } from "chat";
2
2
  import type { LogContext } from "@/chat/logging";
3
+ import type { PiMessage } from "@/chat/pi/messages";
3
4
  import type { TurnThinkingSelection } from "@/chat/services/turn-thinking-level";
4
5
  import type { AgentTurnUsage } from "@/chat/usage";
5
6
  import { type ReplyDeliveryPlan } from "@/chat/services/reply-delivery-plan";
@@ -27,6 +28,7 @@ export interface AssistantReply {
27
28
  deliveryMode?: "thread" | "channel_only";
28
29
  sandboxId?: string;
29
30
  sandboxDependencyProfileHash?: string;
31
+ piMessages?: PiMessage[];
30
32
  diagnostics: AgentTurnDiagnostics;
31
33
  }
32
34
  export interface TurnResultInput {
@@ -37,6 +39,7 @@ export interface TurnResultInput {
37
39
  toolCalls: string[];
38
40
  sandboxId?: string;
39
41
  sandboxDependencyProfileHash?: string;
42
+ piMessages?: PiMessage[];
40
43
  durationMs?: number;
41
44
  generatedFileCount: number;
42
45
  shouldTrace: boolean;
@@ -1,8 +1,9 @@
1
- import { type AgentTurnSessionRecord, type AgentTurnRequester, type AgentTurnSurface } from "@/chat/state/turn-session";
1
+ import { type AgentTurnSessionRecord, type AgentTurnSurface } from "@/chat/state/turn-session";
2
+ import type { StoredSlackRequester } from "@/chat/requester";
2
3
  import type { Destination } from "@sentry/junior-plugin-api";
3
4
  import type { PiMessage } from "@/chat/pi/messages";
4
5
  import { type AgentTurnUsage } from "@/chat/usage";
5
- export declare const AGENT_TURN_TIMEOUT_RESUME_MAX_SLICES = 48;
6
+ export declare const AGENT_CONTINUE_MAX_SLICES = 48;
6
7
  export interface TurnSessionContext {
7
8
  conversationId?: string;
8
9
  sessionId?: string;
@@ -33,8 +34,9 @@ export declare function persistRunningSessionRecord(args: {
33
34
  messages: PiMessage[];
34
35
  loadedSkillNames?: string[];
35
36
  logContext: SessionRecordLogContext;
36
- requester?: AgentTurnRequester;
37
+ requester?: StoredSlackRequester;
37
38
  surface?: AgentTurnSurface;
39
+ turnStartMessageIndex?: number;
38
40
  }): Promise<boolean>;
39
41
  /** Persist a completed turn session record. */
40
42
  export declare function persistCompletedSessionRecord(args: {
@@ -48,8 +50,9 @@ export declare function persistCompletedSessionRecord(args: {
48
50
  allMessages: PiMessage[];
49
51
  loadedSkillNames?: string[];
50
52
  logContext: SessionRecordLogContext;
51
- requester?: AgentTurnRequester;
53
+ requester?: StoredSlackRequester;
52
54
  surface?: AgentTurnSurface;
55
+ turnStartMessageIndex?: number;
53
56
  }): Promise<void>;
54
57
  /**
55
58
  * Persist an auth-pause session record. Returns the durable record only when
@@ -67,7 +70,7 @@ export declare function persistAuthPauseSessionRecord(args: {
67
70
  loadedSkillNames?: string[];
68
71
  errorMessage: string;
69
72
  logContext: SessionRecordLogContext;
70
- requester?: AgentTurnRequester;
73
+ requester?: StoredSlackRequester;
71
74
  surface?: AgentTurnSurface;
72
75
  }): Promise<AgentTurnSessionRecord | undefined>;
73
76
  /**
@@ -86,7 +89,7 @@ export declare function persistTimeoutSessionRecord(args: {
86
89
  loadedSkillNames?: string[];
87
90
  errorMessage: string;
88
91
  logContext: SessionRecordLogContext;
89
- requester?: AgentTurnRequester;
92
+ requester?: StoredSlackRequester;
90
93
  surface?: AgentTurnSurface;
91
94
  }): Promise<AgentTurnSessionRecord | undefined>;
92
95
  /**
@@ -104,7 +107,7 @@ export declare function persistYieldSessionRecord(args: {
104
107
  loadedSkillNames?: string[];
105
108
  errorMessage: string;
106
109
  logContext: SessionRecordLogContext;
107
- requester?: AgentTurnRequester;
110
+ requester?: StoredSlackRequester;
108
111
  surface?: AgentTurnSurface;
109
112
  }): Promise<AgentTurnSessionRecord | undefined>;
110
113
  export {};
@@ -1,11 +1,11 @@
1
- import { type ActorIdentityInput } from "@/chat/services/requester-identity";
1
+ import { type SlackRequester } from "@/chat/requester";
2
2
  interface SlackUserLookupResult {
3
3
  userName?: string;
4
4
  fullName?: string;
5
5
  email?: string;
6
6
  }
7
7
  /** Fetch Slack user profile info with in-memory TTL cache to avoid repeated API calls. */
8
- export declare function lookupSlackUser(userId?: string): Promise<SlackUserLookupResult | null>;
9
- /** Resolve the canonical Slack actor identity from Slack profile data. */
10
- export declare function lookupSlackActorIdentity(userId: string): Promise<ActorIdentityInput>;
8
+ export declare function lookupSlackUser(teamId: string, userId?: string): Promise<SlackUserLookupResult | null>;
9
+ /** Resolve the canonical Slack requester from Slack profile data. */
10
+ export declare function lookupSlackRequester(teamId: string, userId: string): Promise<SlackRequester>;
11
11
  export {};
@@ -5,5 +5,7 @@ export declare function getConnectedStateContext(): Promise<{
5
5
  redisStateAdapter?: RedisStateAdapter;
6
6
  stateAdapter: StateAdapter;
7
7
  }>;
8
+ /** Return the Redis adapter only when the caller is using the default state adapter. */
9
+ export declare function getDefaultRedisStateAdapterFor(adapter: StateAdapter): Promise<RedisStateAdapter | undefined>;
8
10
  export declare function getStateAdapter(): StateAdapter;
9
11
  export declare function disconnectStateAdapter(): Promise<void>;
@@ -1,4 +1,5 @@
1
- import type { AgentTurnRequester, AgentTurnSurface } from "./turn-session";
1
+ import { type StoredSlackRequester } from "@/chat/requester";
2
+ import type { AgentTurnSurface } from "./turn-session";
2
3
  export interface ConversationDetailsRecord {
3
4
  conversationId: string;
4
5
  /** Generated display title from the LLM. Absent until title has been produced. */
@@ -10,7 +11,7 @@ export interface ConversationDetailsRecord {
10
11
  /** Surface on which the conversation was started. */
11
12
  originSurface?: AgentTurnSurface;
12
13
  /** Requester who initiated the conversation (first turn). */
13
- originRequester?: AgentTurnRequester;
14
+ originRequester?: StoredSlackRequester;
14
15
  /** Timestamp of the first turn in the conversation. */
15
16
  startedAtMs?: number;
16
17
  }
@@ -21,7 +22,7 @@ export interface ConversationDetailsRecord {
21
22
  export declare function initConversationContext(conversationId: string, context: {
22
23
  channelName?: string;
23
24
  originSurface?: AgentTurnSurface;
24
- originRequester?: AgentTurnRequester;
25
+ originRequester?: StoredSlackRequester;
25
26
  startedAtMs: number;
26
27
  }): Promise<void>;
27
28
  /**
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import type { PiMessage } from "@/chat/pi/messages";
3
+ import { type StoredSlackRequester } from "@/chat/requester";
3
4
  declare const authorizationKindSchema: z.ZodUnion<readonly [z.ZodLiteral<"plugin">, z.ZodLiteral<"mcp">]>;
4
5
  declare const sessionLogEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
5
6
  schemaVersion: z.ZodLiteral<1>;
@@ -11,6 +12,14 @@ declare const sessionLogEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
11
12
  [x: string]: unknown;
12
13
  role: string;
13
14
  }>>;
15
+ requester: z.ZodOptional<z.ZodObject<{
16
+ email: z.ZodOptional<z.ZodString>;
17
+ fullName: z.ZodOptional<z.ZodString>;
18
+ platform: z.ZodOptional<z.ZodLiteral<"slack">>;
19
+ slackUserId: z.ZodOptional<z.ZodString>;
20
+ slackUserName: z.ZodOptional<z.ZodString>;
21
+ teamId: z.ZodOptional<z.ZodString>;
22
+ }, z.core.$strict>>;
14
23
  }, z.core.$strip>, z.ZodObject<{
15
24
  schemaVersion: z.ZodLiteral<1>;
16
25
  type: z.ZodLiteral<"projection_reset">;
@@ -21,6 +30,26 @@ declare const sessionLogEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
21
30
  [x: string]: unknown;
22
31
  role: string;
23
32
  }>>>;
33
+ requester: z.ZodOptional<z.ZodObject<{
34
+ email: z.ZodOptional<z.ZodString>;
35
+ fullName: z.ZodOptional<z.ZodString>;
36
+ platform: z.ZodOptional<z.ZodLiteral<"slack">>;
37
+ slackUserId: z.ZodOptional<z.ZodString>;
38
+ slackUserName: z.ZodOptional<z.ZodString>;
39
+ teamId: z.ZodOptional<z.ZodString>;
40
+ }, z.core.$strict>>;
41
+ }, z.core.$strip>, z.ZodObject<{
42
+ schemaVersion: z.ZodLiteral<1>;
43
+ type: z.ZodLiteral<"requester_recorded">;
44
+ sessionId: z.ZodDefault<z.ZodString>;
45
+ requester: z.ZodObject<{
46
+ email: z.ZodOptional<z.ZodString>;
47
+ fullName: z.ZodOptional<z.ZodString>;
48
+ platform: z.ZodOptional<z.ZodLiteral<"slack">>;
49
+ slackUserId: z.ZodOptional<z.ZodString>;
50
+ slackUserName: z.ZodOptional<z.ZodString>;
51
+ teamId: z.ZodOptional<z.ZodString>;
52
+ }, z.core.$strict>;
24
53
  }, z.core.$strip>, z.ZodObject<{
25
54
  schemaVersion: z.ZodLiteral<1>;
26
55
  type: z.ZodLiteral<"mcp_provider_connected">;
@@ -46,6 +75,7 @@ declare const sessionLogEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
46
75
  requesterId: z.ZodString;
47
76
  authorizationId: z.ZodString;
48
77
  }, z.core.$strip>], "type">;
78
+ /** Requester identity stored with turn-start messages for durable continuation. */
49
79
  export type SessionLogEntry = z.infer<typeof sessionLogEntrySchema>;
50
80
  export type AuthorizationKind = z.infer<typeof authorizationKindSchema>;
51
81
  interface Scope {
@@ -60,6 +90,10 @@ export interface SessionLogStore {
60
90
  append(args: AppendArgs): Promise<void>;
61
91
  read(scope: Scope): Promise<SessionLogEntry[]>;
62
92
  }
93
+ export interface SessionProjection {
94
+ messages: PiMessage[];
95
+ requester?: StoredSlackRequester;
96
+ }
63
97
  /** Load the committed Pi-message projection for a conversation. */
64
98
  export declare function loadMessages(args: Scope & {
65
99
  store?: SessionLogStore;
@@ -71,6 +105,14 @@ export declare function loadProjection(args: Scope & {
71
105
  store?: SessionLogStore;
72
106
  sessionId?: string;
73
107
  }): Promise<PiMessage[]>;
108
+ /**
109
+ * Load the Pi-message projection and derived requester identity in one read.
110
+ * Used at continuation boundaries to avoid a second log scan.
111
+ */
112
+ export declare function loadProjectionWithRequester(args: Scope & {
113
+ store?: SessionLogStore;
114
+ sessionId?: string;
115
+ }): Promise<SessionProjection>;
74
116
  /** Load MCP providers that were durably connected in this conversation. */
75
117
  export declare function loadConnectedMcpProviders(args: Scope & {
76
118
  store?: SessionLogStore;
@@ -111,6 +153,7 @@ export declare function commitMessages(args: Scope & {
111
153
  store?: SessionLogStore;
112
154
  messages: PiMessage[];
113
155
  ttlMs: number;
156
+ requester?: StoredSlackRequester;
114
157
  }): Promise<{
115
158
  sessionId: string;
116
159
  }>;
@@ -1,15 +1,10 @@
1
1
  import type { Destination } from "@sentry/junior-plugin-api";
2
2
  import type { PiMessage } from "@/chat/pi/messages";
3
+ import { type StoredSlackRequester } from "@/chat/requester";
3
4
  import type { AgentTurnUsage } from "@/chat/usage";
4
5
  export type AgentTurnSessionStatus = "running" | "awaiting_resume" | "completed" | "failed" | "abandoned";
5
6
  export type AgentTurnSurface = "slack" | "api" | "scheduler" | "internal";
6
7
  export type AgentTurnResumeReason = "timeout" | "auth" | "yield";
7
- export interface AgentTurnRequester {
8
- email?: string;
9
- fullName?: string;
10
- slackUserId?: string;
11
- slackUserName?: string;
12
- }
13
8
  export interface AgentTurnSessionRecord {
14
9
  channelName?: string;
15
10
  version: number;
@@ -21,7 +16,7 @@ export interface AgentTurnSessionRecord {
21
16
  lastProgressAtMs: number;
22
17
  loadedSkillNames?: string[];
23
18
  piMessages: PiMessage[];
24
- requester?: AgentTurnRequester;
19
+ requester?: StoredSlackRequester;
25
20
  resumeReason?: AgentTurnResumeReason;
26
21
  resumedFromSliceId?: number;
27
22
  sessionId: string;
@@ -30,9 +25,10 @@ export interface AgentTurnSessionRecord {
30
25
  state: AgentTurnSessionStatus;
31
26
  surface?: AgentTurnSurface;
32
27
  traceId?: string;
28
+ turnStartMessageIndex?: number;
33
29
  updatedAtMs: number;
34
30
  }
35
- export type AgentTurnSessionSummary = Omit<AgentTurnSessionRecord, "errorMessage" | "piMessages">;
31
+ export type AgentTurnSessionSummary = Omit<AgentTurnSessionRecord, "errorMessage" | "piMessages" | "turnStartMessageIndex">;
36
32
  /** Read a materialized turn session record for resume and history loading. */
37
33
  export declare function getAgentTurnSessionRecord(conversationId: string, sessionId: string): Promise<AgentTurnSessionRecord | undefined>;
38
34
  /** Commit stable Pi session state and advance the turn session record. */
@@ -49,11 +45,12 @@ export declare function upsertAgentTurnSessionRecord(args: {
49
45
  state: AgentTurnSessionStatus;
50
46
  surface?: AgentTurnSurface;
51
47
  piMessages: PiMessage[];
52
- requester?: AgentTurnRequester;
48
+ requester?: StoredSlackRequester;
53
49
  resumeReason?: AgentTurnResumeReason;
54
50
  errorMessage?: string;
55
51
  resumedFromSliceId?: number;
56
52
  traceId?: string;
53
+ turnStartMessageIndex?: number;
57
54
  ttlMs?: number;
58
55
  }): Promise<AgentTurnSessionRecord>;
59
56
  /** Record turn-session metadata without storing conversation messages. */
@@ -65,7 +62,7 @@ export declare function recordAgentTurnSessionSummary(args: {
65
62
  destination?: Destination;
66
63
  lastProgressAtMs?: number;
67
64
  loadedSkillNames?: string[];
68
- requester?: AgentTurnRequester;
65
+ requester?: StoredSlackRequester;
69
66
  resumeReason?: AgentTurnResumeReason;
70
67
  sessionId: string;
71
68
  sliceId: number;
@@ -1,10 +1,10 @@
1
1
  import type { SlackAdapter } from "@chat-adapter/slack";
2
2
  import { Message, ThreadImpl, type SerializedMessage, type SerializedThread, type StateAdapter } from "chat";
3
3
  import type { SlackTurnRuntime } from "@/chat/runtime/slack-runtime";
4
- import type { InboundMessageRecord } from "@/chat/task-execution/store";
4
+ import type { InboundMessage } from "@/chat/task-execution/store";
5
5
  import type { ConversationWorkerContext, ConversationWorkerResult } from "@/chat/task-execution/worker";
6
6
  import { type SlackInstallationContext } from "@/chat/slack/adapter-context";
7
- import { type SlackActorProfile } from "@/chat/services/requester-identity";
7
+ import { type SlackRequesterProfile } from "@/chat/requester";
8
8
  export type SlackConversationRoute = "mention" | "subscribed";
9
9
  export interface SlackConversationMessageMetadata {
10
10
  [key: string]: unknown;
@@ -16,8 +16,8 @@ export interface SlackConversationMessageMetadata {
16
16
  }
17
17
  export interface CreateSlackConversationWorkerOptions {
18
18
  getSlackAdapter: () => SlackAdapter;
19
- lookupSlackUser?: (userId: string) => Promise<SlackActorProfile | null | undefined>;
20
- resumeAwaitingContinuation?: (conversationId: string) => Promise<boolean>;
19
+ lookupSlackUser?: (teamId: string, userId: string) => Promise<SlackRequesterProfile | null | undefined>;
20
+ resumeAwaitingContinuation: (conversationId: string) => Promise<boolean>;
21
21
  runtime: Pick<SlackTurnRuntime<unknown>, "handleNewMention" | "handleSubscribedMessage">;
22
22
  state?: StateAdapter;
23
23
  }
@@ -31,4 +31,4 @@ export declare function buildSlackInboundMessage(args: {
31
31
  receivedAtMs: number;
32
32
  route: SlackConversationRoute;
33
33
  thread: ThreadImpl;
34
- }): InboundMessageRecord;
34
+ }): InboundMessage;