@sentry/junior 0.149.0 → 0.150.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 (68) hide show
  1. package/dist/{agent-hooks-CWMCXAMT.js → agent-hooks-G4LEACQB.js} +10 -10
  2. package/dist/api.d.ts +1 -1
  3. package/dist/api.js +25 -23
  4. package/dist/app.js +92 -85
  5. package/dist/{catalog-runtime-GAW5APVI.js → catalog-runtime-ZRSNE2MH.js} +5 -5
  6. package/dist/chat/agent/index.d.ts +5 -4
  7. package/dist/chat/agent/prompt.d.ts +8 -5
  8. package/dist/chat/agent/resume.d.ts +2 -2
  9. package/dist/chat/agent/tools.d.ts +4 -7
  10. package/dist/chat/agent/{request.d.ts → types.d.ts} +138 -129
  11. package/dist/chat/agent-dispatch/types.d.ts +2 -2
  12. package/dist/chat/agent-invocations/spawn.d.ts +2 -2
  13. package/dist/chat/plugins/viewer.d.ts +4 -0
  14. package/dist/chat/runtime/agent-runner.d.ts +7 -5
  15. package/dist/chat/runtime/slack-resume.d.ts +3 -3
  16. package/dist/chat/task-execution/paused-turn.d.ts +2 -2
  17. package/dist/chat/tools/types.d.ts +1 -1
  18. package/dist/{chunk-EW2LNCRL.js → chunk-2AWDPNP7.js} +4 -4
  19. package/dist/{chunk-X22XXSZA.js → chunk-2DIRU2C2.js} +1 -1
  20. package/dist/{chunk-5CWUQXXT.js → chunk-2Z7YX5PI.js} +20 -24
  21. package/dist/{chunk-RLVZIWNQ.js → chunk-3WIFZBJL.js} +1 -1
  22. package/dist/{chunk-MEMURSBG.js → chunk-4JV7GUUH.js} +1 -1
  23. package/dist/{chunk-3KGQOKIG.js → chunk-5NOHC2Z4.js} +1 -1
  24. package/dist/{chunk-2P6BQQER.js → chunk-6A24WEKX.js} +4 -4
  25. package/dist/{chunk-6G5RCDKP.js → chunk-6IWDFUXW.js} +1 -1
  26. package/dist/{chunk-4JGM7FXO.js → chunk-6ZYGORV4.js} +2 -2
  27. package/dist/{chunk-URDCZAL4.js → chunk-AD6N2KNE.js} +5 -5
  28. package/dist/{chunk-25SC7D6Z.js → chunk-B2YA2G26.js} +1 -1
  29. package/dist/{chunk-SWHPVZBV.js → chunk-D2PVJU5E.js} +2 -2
  30. package/dist/{chunk-32CXPIZE.js → chunk-FGP5W3NS.js} +2 -2
  31. package/dist/{chunk-3GYZ5YEH.js → chunk-GZ25ZSTX.js} +3 -3
  32. package/dist/{chunk-DK5UT6PQ.js → chunk-IQW6RFXG.js} +185 -126
  33. package/dist/{chunk-XPYWWMHR.js → chunk-IZE2EGCX.js} +5 -5
  34. package/dist/{chunk-4YKPOYRV.js → chunk-JBYWR6FW.js} +5 -5
  35. package/dist/{chunk-ZYMYLLWG.js → chunk-JUBPTYNO.js} +1 -1
  36. package/dist/{chunk-JMSMXXED.js → chunk-JVOLC6JZ.js} +4 -4
  37. package/dist/{chunk-3I2IVWSZ.js → chunk-KFHJQYKQ.js} +1 -1
  38. package/dist/{chunk-TFBNBXPU.js → chunk-LSI3EKZQ.js} +4 -4
  39. package/dist/{chunk-RB26T3LU.js → chunk-LWFHRWJI.js} +8 -8
  40. package/dist/{chunk-UZGASGOD.js → chunk-N6QJAPZS.js} +9 -9
  41. package/dist/{chunk-QIW7OQEO.js → chunk-OWLJZ6I7.js} +1 -1
  42. package/dist/{chunk-7BH46NB4.js → chunk-QNSV46AW.js} +15 -6
  43. package/dist/{chunk-ALJG73MQ.js → chunk-QO3OSJDS.js} +12 -12
  44. package/dist/{chunk-75DSYFFB.js → chunk-QZGYKKH6.js} +100 -107
  45. package/dist/{chunk-EXW76GW4.js → chunk-R53UTQ2Q.js} +1 -1
  46. package/dist/{chunk-GDFF3BQG.js → chunk-RF6J3DIO.js} +34 -36
  47. package/dist/{chunk-JMH3DBM5.js → chunk-SZ74ECCC.js} +6 -6
  48. package/dist/{chunk-2JHKISQA.js → chunk-TZRYLW3R.js} +1 -1
  49. package/dist/{chunk-W7UONUIZ.js → chunk-W3FQZAX5.js} +22 -26
  50. package/dist/{chunk-ART7P442.js → chunk-XED3H34M.js} +3 -3
  51. package/dist/cli/chat.js +31 -31
  52. package/dist/cli/check.js +6 -6
  53. package/dist/cli/plugins.js +13 -13
  54. package/dist/cli/snapshot-create.js +9 -9
  55. package/dist/cli/upgrade.js +7 -7
  56. package/dist/{db-JBZLRIVY.js → db-WRA5ZHYE.js} +7 -7
  57. package/dist/instrumentation.js +4 -4
  58. package/dist/nitro.js +2 -2
  59. package/dist/{oauth-callback-server-MNTVYY2I.js → oauth-callback-server-QWAYG3MI.js} +24 -24
  60. package/dist/{runner-K24BWZSZ.js → runner-5JQ54J6P.js} +40 -37
  61. package/dist/{skills-AU5ST2CG.js → skills-3YD55WPO.js} +6 -6
  62. package/dist/spawn-OOO26XDL.js +38 -0
  63. package/dist/{validation-IXGZCFRO.js → validation-ZXE3IRSB.js} +6 -6
  64. package/dist/version.js +1 -1
  65. package/dist/{work-WCZIYILX.js → work-7G2U64WI.js} +17 -17
  66. package/dist/{worker-U2AACBEY.js → worker-HJM2FZNI.js} +11 -11
  67. package/package.json +5 -5
  68. package/dist/spawn-6PO7CVJ6.js +0 -38
@@ -25,7 +25,7 @@ import type { OAuthAuthorization } from "@/chat/oauth-authorization";
25
25
  import type { Actor } from "@/chat/actor";
26
26
  import type { AuthorizationPauseError } from "@/chat/services/auth-pause";
27
27
  import type { AgentTurnSurface } from "@/chat/task-execution/checkpoint";
28
- import { type AgentRunDurability, type AgentRunObservers, type AgentRunPolicy, type AgentRunRouting, type AgentRunState } from "@/chat/agent/request";
28
+ import { type AgentDurability, type AgentEvent, type AgentRun, type AgentRunState } from "@/chat/agent/types";
29
29
  import type { ResumeState } from "@/chat/agent/resume";
30
30
  interface ToolWiringArgs {
31
31
  abortAgent: () => void;
@@ -43,22 +43,19 @@ interface ToolWiringArgs {
43
43
  configurationValues: Record<string, unknown>;
44
44
  connectedMcpProviders: Set<string>;
45
45
  conversationPrivacy?: ConversationPrivacy;
46
- durability: AgentRunDurability;
46
+ durability: AgentDurability;
47
47
  authorization?: OAuthAuthorization;
48
48
  generatedFiles: FileUpload[];
49
49
  invokedSkill: SkillMetadata | null;
50
- observers: AgentRunObservers;
50
+ onEvent?: (event: AgentEvent) => void | Promise<void>;
51
51
  onFatalToolError(error: Error): void;
52
52
  onSandboxRefChanged: (sandboxRef: SandboxRef) => void;
53
- policy: AgentRunPolicy;
54
53
  preAgentPromptMessages: () => PiMessage[];
55
54
  priorPiMessages: PiMessage[] | undefined;
56
55
  recordConnectedMcpProvider: (provider: string) => Promise<void>;
57
56
  requestHandoff?: ToolRuntimeContext["handoff"];
58
57
  resume: ResumeState;
59
- routing: AgentRunRouting;
60
- conversationId: string;
61
- turnId: string;
58
+ run: AgentRun;
62
59
  skillSandbox: SkillSandbox;
63
60
  spanContext: LogContext;
64
61
  state: AgentRunState;
@@ -1,11 +1,9 @@
1
1
  /**
2
- * Agent run request contract.
2
+ * Public agent-run launch contract.
3
3
  *
4
- * Groups the per-slice run request by the runtime role each field serves and
5
- * owns interpretation of the routing group: actor derivation, surface
6
- * inference, destination consistency checks, and session identifiers. Run
7
- * phases consume these groups directly; callers build them at runtime
8
- * boundaries.
4
+ * Providers build one flat `AgentRun` and call `AgentRunner.run`. Delivery and
5
+ * durability are capabilities that affect the run. `onEvent` is best-effort UI
6
+ * only. Stable composition binds stream, spawn, and tracing outside this type.
9
7
  */
10
8
  import type { Destination, ReplyAttribution, Source, SystemActor } from "@sentry/junior-plugin-api";
11
9
  import type { LocationConfigurationService } from "@/chat/configuration/types";
@@ -17,7 +15,6 @@ import type { SandboxRef } from "@/chat/sandbox/ref";
17
15
  import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress/tracing";
18
16
  import type { SandboxEgressSignalTransport } from "@/chat/sandbox/egress/signals";
19
17
  import type { OAuthAuthorization } from "@/chat/oauth-authorization";
20
- import type { AssistantStatusSpec } from "@/chat/slack/assistant-thread/status";
21
18
  import type { SlackConversationContext } from "@/chat/slack/conversation-context";
22
19
  import type { ConversationPendingAuthState } from "@/chat/state/conversation";
23
20
  import type { ConversationMessageProvenance } from "@/chat/conversations/provenance";
@@ -27,26 +24,33 @@ import type { SlackActionToken } from "@/chat/slack/action-token";
27
24
  import type { TurnReasoningLevel } from "@/chat/reasoning-level";
28
25
  import type { ImageGenerateToolDeps, ViewImageToolDeps, WebFetchToolDeps, WebSearchToolDeps } from "@/chat/tools/types";
29
26
  import type { AssistantMessage } from "@earendil-works/pi-ai";
30
- export interface AgentRunAttachment {
27
+ /** One attachment the model may see for the current instruction. */
28
+ export type AgentAttachment = {
31
29
  data?: Buffer;
32
30
  mediaType: string;
33
31
  filename?: string;
34
32
  promptText?: string;
35
- }
36
- export interface AgentRunInstructionActor {
33
+ };
34
+ /** Instruction author metadata used for prompt labels and provenance. */
35
+ export type AgentInstructionActor = {
37
36
  authorId?: string;
38
37
  authorName?: string;
38
+ /**
39
+ * Slack message ts for the instruction when known.
40
+ * TODO: generalize to a provider-neutral message id once prompt attrs are neutral.
41
+ */
39
42
  slackTs?: string;
40
- }
41
- export interface AgentRunSteeringMessage {
42
- actor?: AgentRunInstructionActor;
43
+ };
44
+ /** One mid-turn steered user message drained from the durable mailbox. */
45
+ export type AgentSteeringMessage = {
46
+ actor?: AgentInstructionActor;
43
47
  /** Provenance of this queued/steered message, carrying its original author. */
44
48
  provenance: ConversationMessageProvenance;
45
49
  omittedImageAttachmentCount?: number;
46
50
  text: string;
47
51
  timestampMs?: number;
48
- userAttachments?: AgentRunAttachment[];
49
- }
52
+ attachments?: AgentAttachment[];
53
+ };
50
54
  /** Model-safe input for one asynchronously delegated child-agent task. */
51
55
  export type SpawnAgentInput = {
52
56
  name?: string;
@@ -62,155 +66,160 @@ export type SpawnAgent = (input: SpawnAgentInput, options: {
62
66
  signal?: AbortSignal;
63
67
  toolCallId: string;
64
68
  }) => Promise<SpawnAgentResult>;
65
- /** Carries the user-visible content and prior transcript for one agent-run slice. */
66
- export interface AgentRunInput {
67
- actor?: AgentRunInstructionActor;
68
- includeConversationContextWithPiMessages?: boolean;
69
- messageText: string;
70
- userAttachments?: AgentRunAttachment[];
69
+ /** Current user instruction for one agent-run slice. */
70
+ export type AgentInstruction = {
71
+ text: string;
72
+ attachments?: readonly AgentAttachment[];
71
73
  inboundAttachmentCount?: number;
72
74
  omittedImageAttachmentCount?: number;
73
- /** Durable Pi transcript for this conversation, excluding ephemeral turn context. */
74
- piMessages?: PiMessage[];
75
- conversationContext?: string;
76
- }
77
- /**
78
- * Identity and addressing for one run.
79
- *
80
- * Set `actor` first (who runs). Derive `credentialContext` with
81
- * `credentialContextForActor(actor, subject?)` unless a caller already bound
82
- * credentials (dispatch with delegated subject). They name the same principal
83
- * except when a system actor carries `credentialContext.subject` for delegated
84
- * user tokens.
85
- */
86
- export interface AgentRunRouting {
87
- /** Who this run executes as. Prefer always setting this. */
88
- actor?: Actor;
89
- /** Credential authority projected from actor (plus optional subject). */
90
- credentialContext?: CredentialContext;
91
- source: Source;
92
- slackConversation?: SlackConversationContext;
75
+ /** Host-owned turn context shown to the model near the instruction. */
76
+ context?: string;
77
+ actor?: AgentInstructionActor;
93
78
  /**
94
- * TODO: Move ephemeral Slack credentials into provider-owned turn context so
95
- * the Slack tool registry can consume them without extending core routing.
79
+ * When history is present, still include `context` in the prompt. Default is
80
+ * to omit conversation context once durable history already carries it.
96
81
  */
97
- slackActionToken?: SlackActionToken;
98
- destination: Destination;
99
- /** When true, also publish assistant output to the conversation destination. */
100
- publishExternally?: boolean;
101
- /** Confirmed visibility of the destination where this run is delivered. */
102
- destinationVisibility?: ConversationPrivacy;
103
- surface?: AgentTurnSurface;
104
- dispatch?: {
105
- actor?: SystemActor;
106
- id: string;
107
- metadata?: Record<string, string>;
108
- plugin?: string;
109
- replyAttribution?: ReplyAttribution;
110
- };
111
- toolChannelId?: string;
112
- }
82
+ includeConversationContextWithHistory?: boolean;
83
+ };
84
+ /** Dispatch identity carried on plugin-authored runs. */
85
+ export type AgentDispatch = {
86
+ actor?: SystemActor;
87
+ id: string;
88
+ metadata?: Record<string, string>;
89
+ plugin?: string;
90
+ replyAttribution?: ReplyAttribution;
91
+ };
113
92
  /** Optional agent capabilities that a run slice can turn off. */
114
93
  export declare const AGENT_RUN_FEATURES: readonly ["handoff", "interactive-auth", "subagents"];
115
- /** One optional agent capability controlled by run policy. */
116
- export type AgentRunFeature = (typeof AGENT_RUN_FEATURES)[number];
117
- /** Return whether one optional agent capability is disabled for this run. */
118
- export declare function isAgentRunFeatureDisabled(policy: Pick<AgentRunPolicy, "disabledFeatures"> | undefined, feature: AgentRunFeature): boolean;
119
- /** Carries execution limits and dependency overrides for one run slice. */
120
- export interface AgentRunPolicy {
121
- /**
122
- * Optional agent capabilities disabled for this run slice.
123
- * `interactive-auth` blocks pausing to send an OAuth link; missing credentials
124
- * hard-fail instead. Default is enabled when omitted.
125
- * TODO(#881, #883): child invocations currently disable interactive-auth, but
126
- * may later need a path to force the auth flow when a delegated tool requires
127
- * credentials the parent can already request.
128
- */
129
- disabledFeatures?: readonly AgentRunFeature[];
130
- /** Absolute wall-clock deadline for this host request, in milliseconds. */
131
- turnDeadlineAtMs?: number;
132
- /** Cancels provider work when the owning host request is abandoned. */
133
- signal?: AbortSignal;
134
- /** Explicit per-agent reasoning level. When set, adaptive routing is disabled. */
135
- reasoningLevel?: TurnReasoningLevel;
136
- configuration?: Record<string, unknown>;
137
- locationConfiguration?: LocationConfigurationService;
138
- skillDirs?: string[];
139
- /** Per-slice override for app-owned sandbox egress trace propagation. */
140
- sandboxTracePropagation?: SandboxEgressTracePropagationConfig;
141
- /** Per-slice sandbox egress signal storage override. */
142
- sandboxEgressSignals?: SandboxEgressSignalTransport;
143
- toolOverrides?: {
144
- imageGenerate?: ImageGenerateToolDeps;
145
- viewImage?: ViewImageToolDeps;
146
- webFetch?: WebFetchToolDeps;
147
- webSearch?: WebSearchToolDeps;
148
- };
149
- }
150
- /** Carries durable state snapshots already loaded by the caller. */
151
- export interface AgentRunState {
94
+ /** One optional agent capability controlled per run. */
95
+ export type AgentFeature = (typeof AGENT_RUN_FEATURES)[number];
96
+ /** Already-loaded resume state for this conversation. */
97
+ export type AgentRunState = {
152
98
  pendingAuth?: ConversationPendingAuthState;
153
99
  /** Persisted sandbox reuse state from prior slices of this conversation. */
154
100
  sandboxRef?: SandboxRef;
155
- }
156
- /**
157
- * Carries notification-only callbacks for streaming UI and status surfaces;
158
- * their failures never affect the run.
159
- */
160
- export interface AgentRunObservers {
161
- onToolInvocation?: (invocation: {
162
- params: Record<string, unknown>;
163
- toolCallId: string;
164
- toolName: string;
165
- }) => void | Promise<void>;
166
- onToolResult?: (result: ToolExecutionReport) => void | Promise<void>;
167
- onStatus?: (status: AssistantStatusSpec) => void | Promise<void>;
168
- }
101
+ };
169
102
  /**
170
103
  * Delivers completed tool-free assistant messages in model order.
171
104
  *
172
105
  * The runner must commit the preceding agent boundary before invoking this
173
106
  * port; the accepted reply transaction appends only this message.
174
107
  */
175
- export type AgentRunDelivery = (message: AssistantMessage) => void | Promise<void>;
108
+ export type AgentDelivery = (message: AssistantMessage) => void | Promise<void>;
176
109
  /** Resume the agent turn after a transient or ambiguous delivery failure. */
177
110
  export declare class RetryableDeliveryError extends Error {
178
111
  constructor(cause: unknown);
179
112
  }
180
- /** Carries durable-worker ports that commit or update resumable run state. */
181
- export interface AgentRunDurability {
113
+ /** Durable-worker ports that commit or update resumable run state. */
114
+ export type AgentDurability = {
182
115
  /** Schedule delegated work with authority bound by the active parent run. */
183
116
  spawnAgent?: SpawnAgent;
184
117
  onInputCommitted?: () => void | Promise<void>;
185
118
  /** Return true when the durable worker should pause at the next Pi boundary. */
186
119
  shouldYield?: () => boolean;
187
- drainSteeringMessages?: (accept: (messages: AgentRunSteeringMessage[]) => Promise<void>) => Promise<AgentRunSteeringMessage[]>;
120
+ drainSteeringMessages?: (accept: (messages: AgentSteeringMessage[]) => Promise<void>) => Promise<AgentSteeringMessage[]>;
188
121
  recordPendingAuth?: (pendingAuth: ConversationPendingAuthState | undefined) => void | Promise<void>;
189
122
  onSandboxRefChanged?: (sandboxRef: SandboxRef) => void | Promise<void>;
190
- }
191
- /** Groups the per-slice run request by the runtime role each field serves. */
192
- export interface AgentRunRequest {
123
+ };
124
+ /** Best-effort progress events. Failures here never affect the run. */
125
+ export type AgentEvent = {
126
+ type: "status";
127
+ text: string;
128
+ } | {
129
+ type: "tool_started";
130
+ toolCallId: string;
131
+ toolName: string;
132
+ params: Record<string, unknown>;
133
+ } | {
134
+ type: "tool_finished";
135
+ report: ToolExecutionReport;
136
+ };
137
+ /** Resolved environment and optional per-run tool test overrides. */
138
+ export type AgentEnvironment = {
139
+ configuration?: Record<string, unknown>;
140
+ locationConfiguration?: LocationConfigurationService;
141
+ skillDirs?: string[];
142
+ /** Per-slice override for app-owned sandbox egress trace propagation. */
143
+ sandboxTracePropagation?: SandboxEgressTracePropagationConfig;
144
+ /** Per-slice sandbox egress signal storage override. */
145
+ sandboxEgressSignals?: SandboxEgressSignalTransport;
146
+ toolOverrides?: {
147
+ imageGenerate?: ImageGenerateToolDeps;
148
+ viewImage?: ViewImageToolDeps;
149
+ webFetch?: WebFetchToolDeps;
150
+ webSearch?: WebSearchToolDeps;
151
+ };
152
+ };
153
+ /**
154
+ * One provider-launched agent-run slice.
155
+ *
156
+ * Build identity, instruction, history, delivery, and durability here. Bind
157
+ * stable model/stream composition when creating the runner, not on each run.
158
+ */
159
+ export type AgentRun = {
193
160
  /** Durable conversation advanced by this run. */
194
161
  conversationId: string;
195
162
  /** Stable turn advanced across this run and any continuation runs. */
196
163
  turnId: string;
197
164
  /** Optional bounded-run identifier used only for observability. */
198
165
  runId?: string;
199
- input: AgentRunInput;
200
- routing: AgentRunRouting;
166
+ instruction: AgentInstruction;
167
+ /** Durable Pi transcript for this conversation, excluding ephemeral turn context. */
168
+ history?: readonly PiMessage[];
169
+ /**
170
+ * Who this run executes as. Prefer always setting this. Derive
171
+ * `credentialContext` with `credentialContextForActor(actor, subject?)`
172
+ * unless a caller already bound credentials.
173
+ */
174
+ actor?: Actor;
175
+ /** Credential authority projected from actor (plus optional subject). */
176
+ credentialContext?: CredentialContext;
177
+ source: Source;
178
+ destination: Destination;
179
+ /** When true, also publish assistant output to the conversation destination. */
180
+ publishExternally?: boolean;
181
+ /** Confirmed visibility of the destination where this run is delivered. */
182
+ destinationVisibility?: ConversationPrivacy;
183
+ surface?: AgentTurnSurface;
184
+ dispatch?: AgentDispatch;
185
+ /**
186
+ * TODO: Move ephemeral Slack credentials and conversation labels into
187
+ * provider-owned tool/prompt context so the shared run edge stays neutral.
188
+ */
189
+ slackConversation?: SlackConversationContext;
190
+ slackActionToken?: SlackActionToken;
191
+ toolChannelId?: string;
201
192
  /** Surface-owned OAuth state and private delivery capabilities. */
202
193
  authorization?: OAuthAuthorization;
203
- policy?: AgentRunPolicy;
194
+ /**
195
+ * Optional agent capabilities disabled for this run slice.
196
+ * `interactive-auth` blocks pausing to send an OAuth link; missing credentials
197
+ * hard-fail instead. Default is enabled when omitted.
198
+ * TODO(#881, #883): child invocations currently disable interactive-auth, but
199
+ * may later need a path to force the auth flow when a delegated tool requires
200
+ * credentials the parent can already request.
201
+ */
202
+ disabledFeatures?: readonly AgentFeature[];
203
+ /** Absolute wall-clock deadline for this host request, in milliseconds. */
204
+ deadlineAtMs?: number;
205
+ /** Cancels provider work when the owning host request is abandoned. */
206
+ signal?: AbortSignal;
207
+ /** Explicit per-agent reasoning level. When set, adaptive routing is disabled. */
208
+ reasoning?: TurnReasoningLevel;
209
+ environment?: AgentEnvironment;
204
210
  state?: AgentRunState;
205
- observers?: AgentRunObservers;
206
- delivery?: AgentRunDelivery;
207
- durability?: AgentRunDurability;
208
- }
209
- /** Resolve the explicit actor or the system credential actor for this run. */
210
- export declare function actorFromRouting(routing: AgentRunRouting): Actor | undefined;
211
+ /** Best-effort progress only. */
212
+ onEvent?: (event: AgentEvent) => void | Promise<void>;
213
+ delivery?: AgentDelivery;
214
+ durability?: AgentDurability;
215
+ };
216
+ /** Return whether one optional agent capability is disabled for this run. */
217
+ export declare function isAgentRunFeatureDisabled(disabledFeatures: readonly AgentFeature[] | undefined, feature: AgentFeature): boolean;
218
+ /** Resolve the explicit actor, dispatch actor, or credential actor for this run. */
219
+ export declare function actorFromRun(run: Pick<AgentRun, "actor" | "dispatch" | "credentialContext">): Actor | undefined;
211
220
  /** Reject contradictory provider coordinates before the run touches state. */
212
- export declare function assertRunRoutingConsistency(request: Pick<AgentRunRequest, "conversationId" | "routing">): void;
221
+ export declare function assertRunConsistency(run: Pick<AgentRun, "conversationId" | "source" | "destination" | "surface" | "publishExternally" | "actor" | "dispatch">): void;
213
222
  /** Route tool side effects to the tool channel when one overrides the destination. */
214
- export declare function toolInvocationDestination(routing: AgentRunRouting): Destination;
223
+ export declare function toolInvocationDestination(run: Pick<AgentRun, "destination" | "toolChannelId">): Destination;
215
224
  /** Infer the run surface when the caller did not state one. */
216
- export declare function surfaceFromRouting(routing: AgentRunRouting): AgentTurnSurface;
225
+ export declare function surfaceFromRun(run: Pick<AgentRun, "surface" | "source">): AgentTurnSurface;
@@ -1,6 +1,6 @@
1
1
  import type { DispatchOptions, DestinationVisibility, ReplyAttribution, Source, SlackDestination } from "@sentry/junior-plugin-api";
2
2
  import type { CredentialContext, CredentialSubject, CredentialSystemActor } from "@/chat/credentials/context";
3
- import type { AgentRunRouting } from "@/chat/agent/request";
3
+ import type { AgentDispatch } from "@/chat/agent/types";
4
4
  import type { AgentTurnSurface } from "@/chat/task-execution/checkpoint";
5
5
  import type { LocationConfigurationService } from "@/chat/configuration/types";
6
6
  export type DispatchStatus = "pending" | "running" | "awaiting_resume" | "completed" | "failed" | "blocked";
@@ -51,7 +51,7 @@ export interface DispatchTurnContext {
51
51
  locationConfiguration: LocationConfigurationService;
52
52
  credentialContext: CredentialContext;
53
53
  destinationVisibility: DestinationVisibility;
54
- dispatch: NonNullable<AgentRunRouting["dispatch"]>;
54
+ dispatch: AgentDispatch;
55
55
  skipProviderDefaultConfig: true;
56
56
  source: Source;
57
57
  surface: Extract<AgentTurnSurface, "api">;
@@ -1,6 +1,6 @@
1
1
  import type { StateAdapter } from "chat";
2
2
  import type { ConversationStore } from "@/chat/conversations/store";
3
- import type { AgentRunRequest, SpawnAgent } from "@/chat/agent/request";
3
+ import type { AgentRun, SpawnAgent } from "@/chat/agent/types";
4
4
  import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
5
5
  type SpawnOptions = {
6
6
  conversationStore?: ConversationStore;
@@ -8,5 +8,5 @@ type SpawnOptions = {
8
8
  state?: StateAdapter;
9
9
  };
10
10
  /** Bind one run's runtime-owned authority to the model-safe spawn capability. */
11
- export declare function bindSpawnAgent(request: AgentRunRequest, options: SpawnOptions): SpawnAgent | undefined;
11
+ export declare function bindSpawnAgent(run: AgentRun, options: SpawnOptions): SpawnAgent | undefined;
12
12
  export {};
@@ -4,6 +4,10 @@ import type { JuniorDatabase } from "@/db/db";
4
4
  export declare function resolveViewerUserFromSql(db: JuniorDatabase, email: string): Promise<User | undefined>;
5
5
  /** Resolve or create the canonical user for one authenticated viewer. */
6
6
  export declare function resolveViewerUser(email: string): Promise<User | undefined>;
7
+ /** Update one canonical user's display name in SQL. */
8
+ export declare function updateViewerDisplayNameFromSql(db: JuniorDatabase, userId: string, displayName: string): Promise<User | undefined>;
9
+ /** Update one canonical user's display name. */
10
+ export declare function updateViewerDisplayName(userId: string, displayName: string): Promise<User | undefined>;
7
11
  /** Resolve the stored identity and linked user for one runtime actor. */
8
12
  export declare function readActorIdentityFromSql(db: JuniorDatabase, actor: Actor): Promise<{
9
13
  identity: Identity;
@@ -1,12 +1,14 @@
1
- import { type AgentRunRequest, type SpawnAgent } from "@/chat/agent/request";
1
+ import type { StreamFn } from "@earendil-works/pi-agent-core";
2
+ import { type AgentRun, type SpawnAgent } from "@/chat/agent/types";
2
3
  import type { AgentRunOutcome } from "@/chat/runtime/agent-run-outcome";
3
4
  import type { SandboxEgressTracePropagationConfig } from "@/chat/sandbox/egress/tracing";
4
5
  /** Run one agent-run slice behind runtime-owned orchestration boundaries. */
5
6
  export interface AgentRunner {
6
- run(request: AgentRunRequest): Promise<AgentRunOutcome>;
7
+ run(run: AgentRun): Promise<AgentRunOutcome>;
7
8
  }
8
- /** Adapt the Pi-facing agent-run executor behind the runtime-owned runner seam. */
9
- export declare function createAgentRunner(run: AgentRunner["run"], options?: {
10
- bindSpawnAgent?: (request: AgentRunRequest) => SpawnAgent | undefined;
9
+ /** Compose the agent executor with stable host dependencies. */
10
+ export declare function createAgentRunner(execute: (run: AgentRun, streamFn?: StreamFn) => Promise<AgentRunOutcome>, options?: {
11
+ bindSpawnAgent?: (run: AgentRun) => SpawnAgent | undefined;
12
+ streamFn?: StreamFn;
11
13
  tracePropagation?: SandboxEgressTracePropagationConfig;
12
14
  }): AgentRunner;
@@ -1,4 +1,4 @@
1
- import { type AgentRunRequest } from "@/chat/agent/request";
1
+ import { type AgentRun } from "@/chat/agent/types";
2
2
  import type { AgentRunResult } from "@/chat/services/turn-result";
3
3
  import type { AgentRunner } from "@/chat/runtime/agent-runner";
4
4
  import { type ConversationTurnLifecycle } from "@/chat/conversations/turn-lifecycle";
@@ -44,8 +44,8 @@ interface ResumeSlackTurnArgs {
44
44
  beforeStart?: () => Promise<ResumePreparedTurn | false | void>;
45
45
  replyTimeoutMs?: number;
46
46
  }
47
- type ResumeReplyContext = Omit<AgentRunRequest, "conversationId" | "turnId" | "runId" | "input" | "delivery"> & {
48
- input?: Omit<AgentRunRequest["input"], "messageText">;
47
+ type ResumeReplyContext = Omit<AgentRun, "conversationId" | "turnId" | "runId" | "instruction" | "delivery"> & {
48
+ instruction?: Omit<AgentRun["instruction"], "text">;
49
49
  };
50
50
  interface ResumePreparedTurn {
51
51
  messageText: string;
@@ -1,13 +1,13 @@
1
1
  import { resumeSlackTurn } from "@/chat/runtime/slack-resume";
2
2
  import { type PausedTurnRequest } from "@/chat/task-execution/turn-wake";
3
3
  import type { AgentRunner } from "@/chat/runtime/agent-runner";
4
- import type { AgentRunRouting } from "@/chat/agent/request";
4
+ import type { AgentRun } from "@/chat/agent/types";
5
5
  /** Runtime ports for paused turn scheduling. */
6
6
  export interface PausedTurnOptions {
7
7
  agentRunner: AgentRunner;
8
8
  /** Exact persisted input ids accepted while running the paused turn. */
9
9
  inputMessageIds?: readonly string[];
10
- routingContext?: Pick<AgentRunRouting, "actor" | "credentialContext" | "destinationVisibility" | "dispatch" | "surface">;
10
+ routingContext?: Pick<AgentRun, "actor" | "credentialContext" | "destinationVisibility" | "dispatch" | "surface">;
11
11
  resumeTurn?: typeof resumeSlackTurn;
12
12
  wakePausedTurn?: (request: PausedTurnRequest) => Promise<void>;
13
13
  scheduleSessionCompletedPluginTasks?: (params: {
@@ -10,7 +10,7 @@ import type { WebActor, LocalActor, Actor, SlackActor } from "@/chat/actor";
10
10
  import type { SlackActionToken } from "@/chat/slack/action-token";
11
11
  import type { ModelProfile } from "@/chat/model-profile";
12
12
  import type { GeneratedArtifactFileRef } from "@/chat/tools/sandbox/file-uploads";
13
- import type { SpawnAgent } from "@/chat/agent/request";
13
+ import type { SpawnAgent } from "@/chat/agent/types";
14
14
  interface HandoffControl {
15
15
  /** Non-empty catalog of configured targets. */
16
16
  profiles: readonly [ModelProfile, ...ModelProfile[]];
@@ -13,7 +13,7 @@ import {
13
13
  instructionProvenanceFor,
14
14
  sanitizePostgresJson,
15
15
  withConversationEventLock
16
- } from "./chunk-3GYZ5YEH.js";
16
+ } from "./chunk-GZ25ZSTX.js";
17
17
  import {
18
18
  SANDBOX_WORKSPACE_ROOT,
19
19
  sleep
@@ -23,14 +23,14 @@ import {
23
23
  fenceLock,
24
24
  getStateAdapter,
25
25
  withLock
26
- } from "./chunk-25SC7D6Z.js";
26
+ } from "./chunk-B2YA2G26.js";
27
27
  import {
28
28
  botConfig,
29
29
  completeText,
30
30
  escapeXml,
31
31
  resolveGatewayModel,
32
32
  unwrapCurrentInstruction
33
- } from "./chunk-32CXPIZE.js";
33
+ } from "./chunk-FGP5W3NS.js";
34
34
  import {
35
35
  toStoredSlackActor
36
36
  } from "./chunk-HZF5P5UN.js";
@@ -42,7 +42,7 @@ import {
42
42
  logException,
43
43
  logWarn,
44
44
  setSpanAttributes
45
- } from "./chunk-RLVZIWNQ.js";
45
+ } from "./chunk-3WIFZBJL.js";
46
46
 
47
47
  // src/chat/turn-context-tag.ts
48
48
  var TURN_CONTEXT_TAG = "runtime-turn-context";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createPluginCatalogRuntime
3
- } from "./chunk-2JHKISQA.js";
3
+ } from "./chunk-TZRYLW3R.js";
4
4
 
5
5
  // src/chat/plugins/catalog-runtime.ts
6
6
  var pluginCatalogRuntime = createPluginCatalogRuntime();
@@ -1,26 +1,26 @@
1
1
  import {
2
2
  appendAndEnqueueInboundMessage
3
- } from "./chunk-JMSMXXED.js";
3
+ } from "./chunk-JVOLC6JZ.js";
4
4
  import {
5
5
  buildDeliveredTurnStatePatch,
6
6
  finalizeFailedTurnReplyWithEvent,
7
7
  getTurnUserMessage,
8
8
  processPluginTask,
9
9
  scheduleSessionCompletedPluginTasks
10
- } from "./chunk-UZGASGOD.js";
10
+ } from "./chunk-N6QJAPZS.js";
11
11
  import {
12
12
  ConversationTurnLifecycleService,
13
13
  coerceThreadConversationState,
14
14
  getPersistedSandboxState,
15
15
  getPersistedThreadState,
16
16
  persistThreadStateById
17
- } from "./chunk-4YKPOYRV.js";
17
+ } from "./chunk-JBYWR6FW.js";
18
18
  import {
19
19
  healthReportSchema
20
20
  } from "./chunk-UTL3MHPC.js";
21
21
  import {
22
22
  parseSlackThreadId
23
- } from "./chunk-MEMURSBG.js";
23
+ } from "./chunk-4JV7GUUH.js";
24
24
  import {
25
25
  TurnInputCommitLostError,
26
26
  buildConversationContext,
@@ -41,14 +41,14 @@ import {
41
41
  saveTurnCheckpoint,
42
42
  startActiveTurn,
43
43
  upsertConversationMessage
44
- } from "./chunk-EW2LNCRL.js";
44
+ } from "./chunk-2AWDPNP7.js";
45
45
  import {
46
46
  normalizeSlackConversationId
47
- } from "./chunk-SWHPVZBV.js";
47
+ } from "./chunk-D2PVJU5E.js";
48
48
  import {
49
49
  getConversationEventStore,
50
50
  getConversationStore
51
- } from "./chunk-3GYZ5YEH.js";
51
+ } from "./chunk-GZ25ZSTX.js";
52
52
  import {
53
53
  credentialContextForActor
54
54
  } from "./chunk-RUIXF3YQ.js";
@@ -56,7 +56,7 @@ import {
56
56
  logException,
57
57
  setTags,
58
58
  withLogContext
59
- } from "./chunk-RLVZIWNQ.js";
59
+ } from "./chunk-3WIFZBJL.js";
60
60
 
61
61
  // src/handlers/health.ts
62
62
  function readHealthReport() {
@@ -522,24 +522,20 @@ function createApiTurnWorker(options) {
522
522
  conversationId: context.conversationId,
523
523
  turnId,
524
524
  runId: currentRunId,
525
- input: {
526
- messageText: text,
527
- conversationContext: buildConversationContext(conversation, {
525
+ instruction: {
526
+ text,
527
+ context: buildConversationContext(conversation, {
528
528
  excludeMessageId: userMessageId
529
- }),
530
- piMessages
531
- },
532
- routing: {
533
- actor,
534
- credentialContext: credentialContextForActor(actor),
535
- destination,
536
- publishExternally: false,
537
- source,
538
- surface: "api"
539
- },
540
- policy: {
541
- disabledFeatures: ["interactive-auth"]
529
+ })
542
530
  },
531
+ history: piMessages,
532
+ actor,
533
+ credentialContext: credentialContextForActor(actor),
534
+ destination,
535
+ publishExternally: false,
536
+ source,
537
+ surface: "api",
538
+ disabledFeatures: ["interactive-auth"],
543
539
  state: {
544
540
  pendingAuth: conversation.processing.pendingAuth,
545
541
  sandboxRef
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-6GWA276C.js";
10
10
  import {
11
11
  getDeploymentTelemetryAttributes
12
- } from "./chunk-6G5RCDKP.js";
12
+ } from "./chunk-6IWDFUXW.js";
13
13
 
14
14
  // src/chat/logging.ts
15
15
  import path from "path";
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-F3B2YJ76.js";
6
6
  import {
7
7
  toOptionalString
8
- } from "./chunk-RLVZIWNQ.js";
8
+ } from "./chunk-3WIFZBJL.js";
9
9
 
10
10
  // src/chat/slack/context.ts
11
11
  import { z } from "zod";