librechat-data-provider 0.8.509 → 0.8.522

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 (61) hide show
  1. package/dist/{data-service-BsdHkdKS.mjs → data-service-CaB7saTP.mjs} +2175 -113
  2. package/dist/data-service-CaB7saTP.mjs.map +1 -0
  3. package/dist/{data-service-XTxx76uB.js → data-service-D5kHzBt-.js} +2806 -150
  4. package/dist/data-service-D5kHzBt-.js.map +1 -0
  5. package/dist/index.js +1403 -92
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +1248 -93
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/react-query/index.js +2 -1
  10. package/dist/react-query/index.js.map +1 -1
  11. package/dist/react-query/index.mjs +2 -1
  12. package/dist/react-query/index.mjs.map +1 -1
  13. package/dist/types/accessPermissions.d.ts +4 -0
  14. package/dist/types/actions.d.ts +3 -3
  15. package/dist/types/agentToolOptions.d.ts +11 -0
  16. package/dist/types/api-endpoints.d.ts +28 -2
  17. package/dist/types/bedrock.d.ts +220 -0
  18. package/dist/types/cadence.d.ts +33 -0
  19. package/dist/types/codeEnvRef.d.ts +21 -0
  20. package/dist/types/config.d.ts +13457 -1573
  21. package/dist/types/data-service.d.ts +65 -14
  22. package/dist/types/feedback.d.ts +9 -1
  23. package/dist/types/file-config.d.ts +42 -5
  24. package/dist/types/filters.d.ts +1422 -0
  25. package/dist/types/generate.d.ts +85 -1
  26. package/dist/types/index.d.ts +10 -0
  27. package/dist/types/keys.d.ts +29 -4
  28. package/dist/types/langchain.d.ts +4 -0
  29. package/dist/types/limits.d.ts +13 -0
  30. package/dist/types/mcp.d.ts +338 -228
  31. package/dist/types/messages.d.ts +13 -0
  32. package/dist/types/models.d.ts +840 -68
  33. package/dist/types/parameterSettings.d.ts +7 -3
  34. package/dist/types/parsers.d.ts +13 -1
  35. package/dist/types/permissions.d.ts +42 -1
  36. package/dist/types/providers.d.ts +36 -0
  37. package/dist/types/react-query/react-query-service.d.ts +2 -7
  38. package/dist/types/request.d.ts +4 -2
  39. package/dist/types/roles.d.ts +34 -0
  40. package/dist/types/runSteps.d.ts +59 -0
  41. package/dist/types/schemas.d.ts +1358 -34
  42. package/dist/types/stateful-code.d.ts +7 -0
  43. package/dist/types/types/agents.d.ts +303 -8
  44. package/dist/types/types/assistants.d.ts +170 -7
  45. package/dist/types/types/files.d.ts +29 -8
  46. package/dist/types/types/index.d.ts +2 -0
  47. package/dist/types/types/insights.d.ts +62 -0
  48. package/dist/types/types/mcpServers.d.ts +25 -0
  49. package/dist/types/types/mutations.d.ts +2 -0
  50. package/dist/types/types/queries.d.ts +47 -5
  51. package/dist/types/types/queuedTurns.d.ts +870 -0
  52. package/dist/types/types/runs.d.ts +206 -26
  53. package/dist/types/types/schedules.d.ts +306 -0
  54. package/dist/types/types/skills.d.ts +34 -6
  55. package/dist/types/types/subagents.d.ts +159 -0
  56. package/dist/types/types/web.d.ts +12 -2
  57. package/dist/types/types.d.ts +175 -2
  58. package/dist/types/upload.d.ts +2 -0
  59. package/package.json +7 -5
  60. package/dist/data-service-BsdHkdKS.mjs.map +0 -1
  61. package/dist/data-service-XTxx76uB.js.map +0 -1
@@ -0,0 +1,7 @@
1
+ export declare const STATEFUL_CODE_ENVIRONMENTS: readonly ["user", "agent-user", "conversation"];
2
+ export type StatefulCodeEnvironment = (typeof STATEFUL_CODE_ENVIRONMENTS)[number];
3
+ /** Resolve a deployment allowlist in stable UI order. An omitted value preserves
4
+ * the backward-compatible behavior where every environment is available. */
5
+ export declare function resolveAllowedStatefulCodeEnvironments(configured?: readonly StatefulCodeEnvironment[] | null): StatefulCodeEnvironment[];
6
+ /** Keep an allowed preference, otherwise select the first deployment-allowed scope. */
7
+ export declare function resolveStatefulCodeEnvironment(preferred: StatefulCodeEnvironment | null | undefined, configured?: readonly StatefulCodeEnvironment[] | null): StatefulCodeEnvironment | undefined;
@@ -1,6 +1,6 @@
1
- import type { FunctionToolCall, SummaryContentPart } from './assistants';
2
- import type { TTokenUsageEvent, TContextUsageEvent } from './runs';
1
+ import type { TTokenUsageEvent, TContextUsageEvent, TPendingSteer } from './runs';
3
2
  import type { TAttachment, TPlugin } from 'src/schemas';
3
+ import type { SummaryContentPart } from './assistants';
4
4
  import { StepTypes, ContentTypes, ToolCallTypes } from './runs';
5
5
  export declare namespace Agents {
6
6
  type MessageType = 'human' | 'ai' | 'generic' | 'system' | 'function' | 'tool' | 'remove';
@@ -52,20 +52,52 @@ export declare namespace Agents {
52
52
  * A call to a tool.
53
53
  */
54
54
  type ToolCall = {
55
- /** Type ("tool_call") according to Assistants Tool Call Structure */
56
- type: ToolCallTypes.TOOL_CALL;
55
+ /** Type ("tool_call") according to Assistants Tool Call Structure; optional literal
56
+ * form included to mirror langchain's ToolCall, whose `type` is optional. */
57
+ type?: ToolCallTypes.TOOL_CALL | 'tool_call';
57
58
  /** The name of the tool to be called */
58
59
  name: string;
60
+ /** Host-derived MCP server identity retained to disambiguate historical tool keys. */
61
+ mcpServerName?: string;
59
62
  /** The arguments to the tool call */
60
63
  args?: string | Record<string, any>;
61
64
  /** If provided, an identifier associated with the tool call */
62
65
  id?: string;
66
+ /** Host run-step identity; unlike provider ids, this is unique across turns. */
67
+ stepId?: string;
63
68
  /** If provided, the output of the tool call */
64
69
  output?: string;
70
+ /** Host-owned durable receipt for a detached ordinary tool result.
71
+ * It lives beside the original call so reload, manual collection, and
72
+ * automatic continuation all arbitrate the same result identity. */
73
+ backgroundTask?: {
74
+ version: 1;
75
+ taskId: string;
76
+ toolName: string;
77
+ status: 'completed' | 'error';
78
+ settledAt: Date;
79
+ resultClaim?: {
80
+ kind: 'manual' | 'wakeup';
81
+ claimId: string;
82
+ claimedAt: Date;
83
+ };
84
+ };
85
+ /** The tool call was rejected before execution because its input failed schema validation. */
86
+ inputValidationError?: true;
65
87
  /** Auth URL */
66
88
  auth?: string;
67
89
  /** Expiration time */
68
90
  expires_at?: number;
91
+ /**
92
+ * When set, this tool call is paused for human review.
93
+ * The presence of this field signals the UI to render approval controls
94
+ * instead of the in-flight tool execution state.
95
+ */
96
+ approval?: {
97
+ actionId: string;
98
+ allowed_decisions: ToolApprovalDecisionType[];
99
+ description?: string;
100
+ };
69
101
  };
70
102
  type ToolEndEvent = {
71
103
  /** The Step Id of the Tool Call */
@@ -165,7 +197,35 @@ export declare namespace Agents {
165
197
  groupId?: number;
166
198
  stepDetails: StepDetails;
167
199
  summary?: SummaryContentPart;
168
- usage: null | object;
200
+ /** Optional to mirror the agents SDK, which omits usage until a step reports it. */
201
+ usage?: null | object;
202
+ /** Epoch ms the step was opened. Emitted by `@librechat/agents` >= 3.4.6. */
203
+ created_at?: number;
204
+ status?: RunStepStatus;
205
+ };
206
+ /** Lifecycle status of a run step. `in_progress` until a terminal close. */
207
+ type RunStepStatus = 'in_progress' | 'completed' | 'cancelled' | 'failed';
208
+ /** Terminal status a run step can close with. */
209
+ type RunStepClosedStatus = Exclude<RunStepStatus, 'in_progress'>;
210
+ /**
211
+ * Payload of {@link StepEvents.ON_RUN_STEP_CLOSED}. Emitted once per step
212
+ * when it reaches a terminal state, including steps swept at end-of-run
213
+ * because the caller aborted — which is the only signal that distinguishes
214
+ * a stopped step from one still in flight.
215
+ */
216
+ type RunStepClosedEvent = {
217
+ id: string;
218
+ index: number;
219
+ type: StepTypes;
220
+ status: RunStepClosedStatus;
221
+ /** Epoch ms the step was opened, when the emitter knows it. */
222
+ created_at?: number;
223
+ /** Epoch ms the step reached its terminal state. */
224
+ closed_at: number;
225
+ runId?: string;
226
+ agentId?: string;
227
+ groupId?: number;
228
+ stepIndex?: number;
169
229
  };
170
230
  /** Content part for aggregated message content */
171
231
  interface ContentPart {
@@ -179,6 +239,21 @@ export declare namespace Agents {
179
239
  parentMessageId?: string;
180
240
  conversationId?: string;
181
241
  text?: string;
242
+ /** Skill selections on the turn, carried so a HITL-resumed turn's reconstructed
243
+ * requestMessage keeps its skill pills (they aren't on the DB row the client refetches
244
+ * until reload). */
245
+ manualSkills?: string[];
246
+ alwaysAppliedSkills?: string[];
247
+ }
248
+ /** Client-safe state for one MCP authorization prompt that remains actionable. */
249
+ interface PendingMCPOAuthPrompt {
250
+ stepId: string;
251
+ runId?: string;
252
+ index: number;
253
+ toolCallId?: string;
254
+ toolName: string;
255
+ authURL: string;
256
+ expiresAt?: number;
182
257
  }
183
258
  /** State data sent to reconnecting clients */
184
259
  interface ResumeState {
@@ -187,6 +262,8 @@ export declare namespace Agents {
187
262
  aggregatedContent?: MessageContentComplex[];
188
263
  userMessage?: UserMessageMeta;
189
264
  responseMessageId?: string;
265
+ /** True when the live generation replaces an existing assistant branch. */
266
+ isRegenerate?: boolean;
190
267
  conversationId?: string;
191
268
  sender?: string;
192
269
  iconURL?: string;
@@ -203,10 +280,24 @@ export declare namespace Agents {
203
280
  data?: unknown;
204
281
  [key: string]: unknown;
205
282
  }>;
283
+ /** Pending MCP authorization prompts projected from durable stream state. */
284
+ pendingOAuthPrompts?: PendingMCPOAuthPrompt[];
206
285
  /** Cumulative provider-reported usage for the run; backfills usage totals on resume */
207
286
  collectedUsage?: TTokenUsageEvent[];
208
287
  /** Latest context window snapshot; restores the usage gauge on resume */
209
288
  contextUsage?: TContextUsageEvent;
289
+ /**
290
+ * Live pending approval when the run is paused for human review. Carried in
291
+ * the resume contract (not just /chat/status) so a reloading or
292
+ * cross-replica client can rebuild and render the prompt from `resumeState`.
293
+ */
294
+ pendingAction?: PendingAction;
295
+ /**
296
+ * Steers queued server-side but not yet injected into the run. Injected
297
+ * steers already live inside `aggregatedContent`; these are the remainder,
298
+ * so a reconnecting client can rebuild its pending-steer chips.
299
+ */
300
+ pendingSteers?: TPendingSteer[];
210
301
  }
211
302
  /**
212
303
  * Represents a run step delta i.e. any changed fields on a run step during
@@ -227,19 +318,214 @@ export declare namespace Agents {
227
318
  type: StepTypes.MESSAGE_CREATION;
228
319
  message_creation: {
229
320
  message_id: string;
321
+ /** Provider content kind and Open Responses semantic text channel. */
322
+ content_type?: 'text' | 'think';
323
+ phase?: 'commentary' | 'final_answer';
230
324
  };
231
325
  };
232
326
  type ToolCallsDetails = {
233
327
  type: StepTypes.TOOL_CALLS;
234
- tool_calls: AgentToolCall[];
328
+ tool_calls?: AgentToolCall[];
235
329
  };
236
330
  type ToolCallDelta = {
237
331
  type: StepTypes.TOOL_CALLS | string;
238
332
  tool_calls?: ToolCallChunk[];
239
333
  auth?: string;
240
334
  expires_at?: number;
335
+ /** Approval metadata, set when a tool call is paused for human review. */
336
+ approval?: {
337
+ actionId: string;
338
+ allowed_decisions: ToolApprovalDecisionType[];
339
+ description?: string;
340
+ };
341
+ };
342
+ /**
343
+ * Mirrors the agents SDK's function tool-call variant: `arguments` may arrive as a
344
+ * parsed object, and `output` is attached by LibreChat aggregation only once available
345
+ * (the legacy assistants `FunctionToolCall` requires both as string/present).
346
+ */
347
+ type AgentFunctionToolCall = {
348
+ id: string;
349
+ type: 'function';
350
+ function: {
351
+ name: string;
352
+ arguments: string | object;
353
+ output?: string | null;
354
+ };
241
355
  };
242
- type AgentToolCall = FunctionToolCall | ToolCall;
356
+ type AgentToolCall = AgentFunctionToolCall | ToolCall;
357
+ /**
358
+ * Human-in-the-loop interrupt categories. The discriminator on
359
+ * {@link HumanInterruptPayload}.
360
+ *
361
+ * - `tool_approval`: agent paused before executing one or more tools; user
362
+ * approves / rejects / edits each call.
363
+ * - `ask_user_question`: agent invoked the `AskUserQuestion` tool to gather
364
+ * clarification; user replies with free-form text (or selects an option).
365
+ *
366
+ * `tool_approval` is a permission gate; `ask_user_question` is a clarification
367
+ * channel — they share the {@link PendingAction} envelope but have different
368
+ * UI affordances and resume payloads.
369
+ */
370
+ type HumanInterruptType = 'tool_approval' | 'ask_user_question';
371
+ /** String enum of decision kinds the user can make on a paused tool call. */
372
+ type ToolApprovalDecisionType = 'approve' | 'reject' | 'edit' | 'respond';
373
+ /**
374
+ * One pending tool execution awaiting user review.
375
+ * Field naming mirrors LangChain HumanInterrupt's `ActionRequest`.
376
+ */
377
+ interface ToolApprovalRequest {
378
+ /** Tool name as registered with the agent */
379
+ name: string;
380
+ /** Sanitized arguments (no auth tokens / file blobs). May be string or parsed object. */
381
+ arguments: string | Record<string, unknown>;
382
+ /** Provider tool_call_id linking this request to the model's tool_use block */
383
+ tool_call_id: string;
384
+ /** Optional human-readable description shown alongside the prompt */
385
+ description?: string;
386
+ }
387
+ /**
388
+ * Per-call review configuration: which decisions the user is allowed to make.
389
+ *
390
+ * `tool_call_id` (NOT `action_name`) is the join key against
391
+ * {@link ToolApprovalRequest.tool_call_id}. By-position mapping breaks the
392
+ * moment a single batch contains the same tool called twice — e.g. a model
393
+ * fanning out two `mcp:server:search` calls in parallel — so always join
394
+ * by `tool_call_id`. `action_name` is retained for display only.
395
+ */
396
+ interface ToolReviewConfig {
397
+ action_name: string;
398
+ tool_call_id: string;
399
+ allowed_decisions: ToolApprovalDecisionType[];
400
+ }
401
+ /** Interrupt payload for a tool-approval pause. */
402
+ interface ToolApprovalInterruptPayload {
403
+ type: 'tool_approval';
404
+ action_requests: ToolApprovalRequest[];
405
+ review_configs: ToolReviewConfig[];
406
+ }
407
+ /** A selectable answer for an ask-user-question prompt. */
408
+ interface AskUserQuestionOption {
409
+ label: string;
410
+ value: string;
411
+ }
412
+ /** The question itself: free-form prompt with optional curated answers. */
413
+ interface AskUserQuestionRequest {
414
+ question: string;
415
+ /** Optional descriptive context for the prompt; mirrors the SDK field. */
416
+ description?: string;
417
+ options?: AskUserQuestionOption[];
418
+ /** When true the user may pick several options; the answer is their
419
+ * selected option values joined with ", ". */
420
+ multiSelect?: boolean;
421
+ }
422
+ /** One independently answerable question in a batched clarification. */
423
+ interface AskUserQuestionBatchItem extends AskUserQuestionRequest {
424
+ /** Batch-unique identifier used to map the submitted answer. */
425
+ id: string;
426
+ /** Optional short heading rendered above the question. */
427
+ header?: string;
428
+ }
429
+ /** Input shape for one tool call that asks several related questions. */
430
+ interface AskUserQuestionsRequest {
431
+ questions: AskUserQuestionBatchItem[];
432
+ }
433
+ /** Interrupt payload for an ask-user-question pause. */
434
+ interface AskUserQuestionInterruptPayload {
435
+ type: 'ask_user_question';
436
+ question: AskUserQuestionRequest;
437
+ /** Present for a batched clarification; `question` remains the first-item fallback. */
438
+ questions?: AskUserQuestionBatchItem[];
439
+ /**
440
+ * The ask tool call that raised this interrupt (mirrors the SDK field,
441
+ * present from `@librechat/agents` > 3.3.8). Lets the question/answer
442
+ * stamps target the exact tool-call part instead of guessing by
443
+ * position when a model emits several ask calls in one turn.
444
+ */
445
+ tool_call_id?: string;
446
+ }
447
+ /**
448
+ * Discriminated by `type`. Mirrors `@librechat/agents`'s `HumanInterruptPayload`
449
+ * so the SDK's `Run.getInterrupt()` output can be embedded directly.
450
+ */
451
+ type HumanInterruptPayload = ToolApprovalInterruptPayload | AskUserQuestionInterruptPayload;
452
+ /**
453
+ * Server-side record of a job that is waiting for user input.
454
+ * Persisted with the job; consumed by approval routes and the status endpoint.
455
+ */
456
+ interface PendingAction {
457
+ /** Stable identifier used in approval URLs */
458
+ actionId: string;
459
+ streamId: string;
460
+ conversationId?: string;
461
+ /** Stable per-turn identifier (LangGraph checkpoint_ns) when available */
462
+ runId?: string;
463
+ responseMessageId?: string;
464
+ payload: HumanInterruptPayload;
465
+ createdAt: number;
466
+ /** Optional expiry; clients should treat past `expiresAt` as stale */
467
+ expiresAt?: number;
468
+ /**
469
+ * SDK interrupt id (`RunInterruptResult.interruptId`). Persisted so a
470
+ * cross-process resume can correlate the decision with the LangGraph
471
+ * interrupt after the original `Run` object is gone.
472
+ */
473
+ interruptId?: string;
474
+ /**
475
+ * LangGraph `thread_id` the run was bound to (`RunInterruptResult.threadId`).
476
+ * Required, with the checkpointer, to rebuild `Command({ resume })` on a
477
+ * worker that didn't originate the run.
478
+ */
479
+ threadId?: string;
480
+ /**
481
+ * Fingerprint of the request fields that determine the agent/graph + tool set
482
+ * (endpoint, agent_id, model, spec, ephemeralAgent), captured at pause time. The
483
+ * resume route recomputes it from the resume request and rejects a mismatch — the
484
+ * guard that catches an ephemeral-agent config swap, where `agent_id` is undefined
485
+ * so the id check can't.
486
+ */
487
+ requestFingerprint?: string;
488
+ /**
489
+ * Graph-determining request fields (endpoint, agent_id, model, spec, promptPrefix,
490
+ * ephemeralAgent) captured at pause. The resume route REPLAYS these onto the request
491
+ * before rebuilding the run, so a reload/cross-replica resume — where the client can
492
+ * no longer reconstruct the ephemeral config — still rebuilds the same agent/graph.
493
+ */
494
+ resumeContext?: Record<string, unknown>;
495
+ }
496
+ /**
497
+ * Scope of a tool-approval decision — drives the "remember this" persistence
498
+ * envelope. Storage of session/always decisions is a Slice B+ concern; the
499
+ * field is on the wire today so route signatures don't break later.
500
+ */
501
+ type DecisionScope = 'once' | 'session' | 'always';
502
+ /**
503
+ * Per-tool decision returned from the approval UI.
504
+ * Wire format. The host adapts each entry to the SDK's discriminated
505
+ * `ToolApprovalDecision` (e.g. `{ type: 'edit', updatedInput }`) at the resume route.
506
+ *
507
+ * Constraints:
508
+ * - `editedArguments` is required when `decision === 'edit'`.
509
+ * - `responseText` is required when `decision === 'respond'`.
510
+ * - `reason` is optional metadata; useful for reject/edit audit trails.
511
+ * - `scope` defaults to `'once'`.
512
+ */
513
+ interface ToolApprovalResolution {
514
+ tool_call_id: string;
515
+ decision: ToolApprovalDecisionType;
516
+ editedArguments?: Record<string, unknown>;
517
+ responseText?: string;
518
+ reason?: string;
519
+ scope?: DecisionScope;
520
+ }
521
+ /** Wire format for an ask-user-question response. */
522
+ interface AskUserQuestionResolution {
523
+ answer: string;
524
+ }
525
+ /** Wire format for a batched ask-user-question response. */
526
+ interface AskUserQuestionsResolution {
527
+ answers: Record<string, string>;
528
+ }
243
529
  interface ExtendedMessageContent {
244
530
  type?: string;
245
531
  text?: string;
@@ -436,8 +722,17 @@ export type GraphEdge = {
436
722
  *
437
723
  * For handoff edges: Description for the input parameter that the handoff tool accepts,
438
724
  * allowing the supervisor to pass specific instructions/context to the transferred agent.
725
+ *
726
+ * The callback receives a minimal structural view of the run's messages (data-provider
727
+ * cannot depend on langchain's BaseMessage): every langchain message satisfies
728
+ * `{ content: unknown }`, and callbacks typed against richer structural message shapes
729
+ * remain assignable. The promise branch mirrors the agents SDK signature exactly —
730
+ * widening it (e.g. to `Promise<string | undefined>`) would break assignability of
731
+ * stored edges into the SDK's `GraphEdge`.
439
732
  */
440
- prompt?: string | ((messages: BaseMessage[], runStartIndex: number) => string | undefined);
733
+ prompt?: string | ((messages: {
734
+ content: unknown;
735
+ }[], runStartIndex: number) => string | Promise<string> | undefined);
441
736
  /**
442
737
  * When true, excludes messages from startIndex when adding prompt.
443
738
  * Automatically set to true when {results} variable is used in prompt.
@@ -1,9 +1,12 @@
1
1
  import type { OpenAPIV3 } from 'openapi-types';
2
- import type { AssistantsEndpoint, AgentProvider } from 'src/schemas';
2
+ import type { AssistantsEndpoint, AgentProvider, MemoryScope, SkillsScope } from 'src/schemas';
3
+ import type { StatefulCodeEnvironment } from '../stateful-code';
3
4
  import type { Agents, GraphEdge } from './agents';
4
5
  import type { ContentTypes } from './runs';
5
6
  import type { TFile } from './files';
6
7
  import { ArtifactModes } from 'src/artifacts';
8
+ export { STATEFUL_CODE_ENVIRONMENTS, resolveStatefulCodeEnvironment, resolveAllowedStatefulCodeEnvironments, } from '../stateful-code';
9
+ export type { StatefulCodeEnvironment } from '../stateful-code';
7
10
  export type Schema = OpenAPIV3.SchemaObject & {
8
11
  description?: string;
9
12
  };
@@ -188,6 +191,9 @@ export type SupportContact = {
188
191
  name?: string;
189
192
  email?: string;
190
193
  };
194
+ export type AgentOwnerContact = {
195
+ name?: string;
196
+ };
191
197
  /**
192
198
  * Specifies who can invoke a tool.
193
199
  * - 'direct': LLM can call directly
@@ -211,6 +217,21 @@ export type ToolOptions = {
211
217
  * @default ['direct']
212
218
  */
213
219
  allowed_callers?: AllowedCaller[];
220
+ /**
221
+ * If true (and the `run_in_background` capability is enabled), the tool's
222
+ * schema gains a `run_in_background` boolean so the model can dispatch the
223
+ * call detached and poll its result via `check_background_task`.
224
+ * @default false
225
+ */
226
+ run_in_background?: boolean;
227
+ /**
228
+ * If true (and the `tool_intents` capability is enabled), the tool's schema
229
+ * gains an `intent` string as its FIRST property — one model-authored
230
+ * sentence per call, rendered as the call's live status label. Native host
231
+ * tools default on while the capability is enabled; `false` opts one out.
232
+ * @default false
233
+ */
234
+ describe_intent?: boolean;
214
235
  };
215
236
  /**
216
237
  * Map of tool_id to its configuration options.
@@ -220,14 +241,36 @@ export type AgentToolOptions = Record<string, ToolOptions>;
220
241
  /**
221
242
  * Configuration for spawning subagents (isolated-context child agents) from an agent.
222
243
  * When `enabled` is true, the agent gets a subagent-spawn tool that can delegate work
223
- * to either itself (when `allowSelf` is true) and/or the listed `agent_ids`.
244
+ * to itself, listed single-agent targets, and/or explicit saved-agent teams.
224
245
  */
246
+ export type AgentSubagentGraphEdge = Omit<GraphEdge, 'edgeType' | 'condition' | 'prompt' | 'promptKey'> & {
247
+ edgeType: 'direct';
248
+ condition?: never;
249
+ prompt?: string;
250
+ promptKey?: never;
251
+ };
252
+ /** A bounded saved-agent team that can be spawned as one isolated child graph. */
253
+ export type AgentSubagentGraph = {
254
+ /** Stable spawn-tool enum value for the team. */
255
+ type: string;
256
+ name: string;
257
+ description: string;
258
+ /** Member IDs. In create/update payloads, an empty ID refers to the current agent. */
259
+ agent_ids: string[];
260
+ edges: AgentSubagentGraphEdge[];
261
+ /** Entry member ID. In create/update payloads, an empty ID refers to the current agent. */
262
+ entry_agent_id: string;
263
+ /** Result member ID. In create/update payloads, an empty ID refers to the current agent. */
264
+ result_agent_id: string;
265
+ };
225
266
  export type AgentSubagentsConfig = {
226
267
  enabled?: boolean;
227
268
  /** When true (default), the agent may spawn itself in an isolated context. */
228
269
  allowSelf?: boolean;
229
270
  /** Specific agents that may be spawned as subagents. */
230
271
  agent_ids?: string[];
272
+ /** Explicit saved-agent teams that may be spawned as bounded child graphs. */
273
+ graphs?: AgentSubagentGraph[];
231
274
  };
232
275
  export type Agent = {
233
276
  _id?: string;
@@ -255,21 +298,49 @@ export type Agent = {
255
298
  edges?: GraphEdge[];
256
299
  end_after_tools?: boolean;
257
300
  hide_sequential_outputs?: boolean;
301
+ /** Per-agent opt-in for stateful code sessions (requires the app-level capability). */
302
+ stateful_code_sessions?: boolean;
303
+ /** Stateful workspace sharing scope. Defaults to one workspace per user. */
304
+ stateful_code_environment?: StatefulCodeEnvironment;
305
+ /** Operator-configured managed or attached stateful execution environment. */
306
+ code_environment_id?: string | null;
258
307
  artifacts?: ArtifactModes;
259
308
  recursion_limit?: number;
260
309
  isPublic?: boolean;
310
+ /**
311
+ * Whether the requesting user holds EDIT on this agent, so a single VIEW-scoped fetch can
312
+ * serve consumers that only need the editable subset instead of issuing a second full
313
+ * paginated walk under an EDIT-scoped cache key.
314
+ *
315
+ * Set by the list endpoint only; single-agent responses omit it. Treat absence as unknown
316
+ * and fail open (`isEditable !== false`), never as `false`, since a client on an older
317
+ * server would otherwise see an empty list rather than too many rows.
318
+ *
319
+ * Reflects the caller's ACL grant. The `MANAGE_AGENTS` capability bypasses ACL on write,
320
+ * so a capability holder can edit agents this flag reports as not editable.
321
+ */
322
+ isEditable?: boolean;
261
323
  version?: number;
262
324
  category?: string;
263
325
  support_contact?: SupportContact;
326
+ owner_contact?: AgentOwnerContact;
264
327
  /** Per-tool configuration options (deferred loading, allowed callers, etc.) */
265
328
  tool_options?: AgentToolOptions;
329
+ /** Attached action registrations, each `${encodedDomain}${actionDelimiter}${action_id}` */
330
+ actions?: string[];
266
331
  /** Optional allowlist of skill ObjectIds. Only applies when `skills_enabled`. */
267
332
  skills?: string[];
268
333
  /** Master toggle for skill use on this agent. `true` = active (full catalog unless
269
334
  * `skills` narrows it). `false`/undefined = inactive (no skills available). */
270
335
  skills_enabled?: boolean;
336
+ /** Enables runtime skill creation without exposing an existing skill catalog. */
337
+ skill_authoring_enabled?: boolean;
338
+ /** Explicit catalog exposure while skills are enabled. Missing preserves legacy semantics. */
339
+ skills_scope?: SkillsScope;
271
340
  /** Subagent spawning configuration — isolated-context child agents. */
272
341
  subagents?: AgentSubagentsConfig;
342
+ /** Memory partition: `agent` isolates memories per (user, agent); default shared pool */
343
+ memory_scope?: MemoryScope;
273
344
  };
274
345
  export type TAgentsMap = Record<string, Agent | undefined>;
275
346
  export type AgentCreateParams = {
@@ -282,7 +353,7 @@ export type AgentCreateParams = {
282
353
  provider: AgentProvider;
283
354
  model: string | null;
284
355
  model_parameters: AgentModelParameters;
285
- } & Pick<Agent, 'agent_ids' | 'edges' | 'end_after_tools' | 'hide_sequential_outputs' | 'artifacts' | 'recursion_limit' | 'category' | 'support_contact' | 'tool_options' | 'skills' | 'skills_enabled' | 'subagents'>;
356
+ } & Pick<Agent, 'agent_ids' | 'edges' | 'end_after_tools' | 'hide_sequential_outputs' | 'stateful_code_sessions' | 'stateful_code_environment' | 'code_environment_id' | 'artifacts' | 'recursion_limit' | 'category' | 'support_contact' | 'tool_options' | 'skills' | 'skills_enabled' | 'skill_authoring_enabled' | 'skills_scope' | 'subagents' | 'memory_scope'>;
286
357
  export type AgentUpdateParams = {
287
358
  name?: string | null;
288
359
  description?: string | null;
@@ -294,7 +365,7 @@ export type AgentUpdateParams = {
294
365
  provider?: AgentProvider;
295
366
  model?: string | null;
296
367
  model_parameters?: AgentModelParameters;
297
- } & Pick<Agent, 'agent_ids' | 'edges' | 'end_after_tools' | 'hide_sequential_outputs' | 'artifacts' | 'recursion_limit' | 'category' | 'support_contact' | 'tool_options' | 'skills' | 'skills_enabled' | 'subagents'>;
368
+ } & Pick<Agent, 'agent_ids' | 'edges' | 'end_after_tools' | 'hide_sequential_outputs' | 'stateful_code_sessions' | 'stateful_code_environment' | 'code_environment_id' | 'artifacts' | 'recursion_limit' | 'category' | 'support_contact' | 'tool_options' | 'skills' | 'skills_enabled' | 'skill_authoring_enabled' | 'skills_scope' | 'subagents' | 'memory_scope'>;
298
369
  export type AgentListParams = {
299
370
  limit?: number;
300
371
  requiredPermission: number;
@@ -454,9 +525,46 @@ export type PartMetadata = {
454
525
  agentId?: string;
455
526
  /** Group ID for parallel content - parts with same groupId are displayed in columns */
456
527
  groupId?: number;
528
+ /**
529
+ * Terminal lifecycle status of the run step that produced this part, from
530
+ * `on_run_step_closed`. Distinct from `status`, which is already claimed by
531
+ * activity-label and question-form parts. Absent on parts predating the
532
+ * event or from endpoints that do not emit it, in which case renderers fall
533
+ * back to inferring "stopped" from `progress` and `isSubmitting`.
534
+ */
535
+ runStepStatus?: Agents.RunStepClosedStatus;
536
+ /**
537
+ * Wall-clock milliseconds the run step took, derived from the same
538
+ * `on_run_step_closed` event as {@link runStepStatus} via
539
+ * `getRunStepDurationMs`. Only written when the event carried both
540
+ * timestamps and they agree in order — so its absence means "not
541
+ * derivable", never "instant". The raw value is persisted unfiltered;
542
+ * whether it is worth showing (`isReportableRunStepDuration`) is decided
543
+ * at render time.
544
+ */
545
+ runStepDurationMs?: number;
546
+ /**
547
+ * Stamped by the background harvester when a detached task's final output
548
+ * replaces the dispatch handle in `tool_call.output`. The handle JSON and
549
+ * the live status-marker attachment are both transient, so after the patch
550
+ * (or a reload) this is the only signal that the call ran in the
551
+ * background — renderers use it to keep treating {@link runStepDurationMs}
552
+ * as dispatch time rather than the task's runtime.
553
+ */
554
+ backgrounded?: boolean;
555
+ /**
556
+ * Content index this part occupied while its run streamed. The aggregator
557
+ * writes parts at provider-source indexes, so the streamed array is sparse;
558
+ * persistence compacts it and every part after a hole shifts down. The
559
+ * client's final handler stamps the streamed position onto the compacted
560
+ * parts it adopts, so index-derived render identity survives the swap
561
+ * instead of remounting the settled message. Client-only and absent
562
+ * everywhere else — persisted content never carries it.
563
+ */
564
+ streamedIndex?: number;
457
565
  };
458
566
  /** Metadata for parallel content rendering - subset of PartMetadata */
459
- export type ContentMetadata = Pick<PartMetadata, 'agentId' | 'groupId'>;
567
+ export type ContentMetadata = Pick<PartMetadata, 'agentId' | 'groupId' | 'streamedIndex'>;
460
568
  export type ContentPart = (CodeToolCall | RetrievalToolCall | FileSearchToolCall | FunctionToolCall | Agents.AgentToolCall | ImageFile | Text) & PartMetadata;
461
569
  export type TextData = (Text & PartMetadata) | undefined;
462
570
  export type SummaryContentPart = {
@@ -476,6 +584,27 @@ export type SummaryContentPart = {
476
584
  contentIndex: number;
477
585
  };
478
586
  };
587
+ /**
588
+ * A user steering message injected mid-run at a tool-batch boundary.
589
+ * Persisted inline in the response message's content array (keyed by the
590
+ * type name like `text`/`think` so token counting reads it for free);
591
+ * replayed as a user message on subsequent turns by `formatAgentMessages`.
592
+ */
593
+ export type SteerContentPart = {
594
+ type: ContentTypes.STEER;
595
+ steer: string;
596
+ steerId?: string;
597
+ /** Stable optimistic-client id used to settle a POST whose response was lost. */
598
+ clientSteerId?: string;
599
+ createdAt?: number;
600
+ /** Attachments steered with the message; re-encoded per turn on replay
601
+ * like any other user-message media (refs only, never encoded data). */
602
+ files?: Partial<TFile>[];
603
+ /** Quoted excerpts steered with the message, persisted separately from the
604
+ * typed text (mirroring `TMessage.quotes`) so the UI renders them as
605
+ * reference blocks; merged into the model-bound user turn on every replay. */
606
+ quotes?: string[];
607
+ };
479
608
  export type TMessageContentParts = ({
480
609
  type: ContentTypes.ERROR;
481
610
  text?: string | TextData;
@@ -483,17 +612,51 @@ export type TMessageContentParts = ({
483
612
  } & ContentMetadata) | ({
484
613
  type: ContentTypes.THINK;
485
614
  think?: string | TextData;
486
- } & ContentMetadata) | ({
615
+ /** Generated orientation for this user-visible reasoning step. */
616
+ reasoning_label?: string;
617
+ /** Stable SDK run-step identity used to correlate live revisions. */
618
+ reasoning_label_step_id?: string;
619
+ /** Durable provider-call count used to enforce the per-run cost cap across resumes. */
620
+ reasoning_label_attempts?: number;
621
+ /** Visible reasoning length included in this step's latest provider call. */
622
+ reasoning_label_submitted_chars?: number;
623
+ /** Monotonic provider-call revision; gaps are allowed after unsuccessful attempts. */
624
+ reasoning_label_revision?: number;
625
+ /** Whether the reasoning step can still produce a newer label. */
626
+ reasoning_label_status?: 'streaming' | 'complete';
627
+ /** The reasoning happened but its text is not available to this view
628
+ * (e.g. detached subagent projections retain only a marker). */
629
+ reasoning_unavailable?: boolean;
630
+ } & ContentMetadata) | (SteerContentPart & ContentMetadata) | ({
487
631
  type: ContentTypes.TEXT;
488
632
  text?: string | TextData;
489
633
  tool_call_ids?: string[];
634
+ /** Open Responses semantic channel for assistant text. */
635
+ phase?: 'commentary' | 'final_answer';
490
636
  } & ContentMetadata) | ({
491
637
  type: ContentTypes.TOOL_CALL;
492
638
  tool_call: (CodeToolCall | RetrievalToolCall | FileSearchToolCall | FunctionToolCall | Agents.AgentToolCall) & PartMetadata;
493
639
  } & ContentMetadata) | ({
494
640
  type: ContentTypes.IMAGE_FILE;
495
641
  image_file: ImageFile & PartMetadata;
496
- } & ContentMetadata) | (SummaryContentPart & ContentMetadata) | (Agents.AgentUpdate & ContentMetadata) | (Agents.MessageContentImageUrl & ContentMetadata) | (Agents.MessageContentVideoUrl & ContentMetadata) | (Agents.MessageContentInputAudio & ContentMetadata);
642
+ } & ContentMetadata) | (SummaryContentPart & ContentMetadata) | ({
643
+ /** One-line LLM-generated note describing a completed tool batch. UI-only:
644
+ * never sent to the model (stripped before payload formatting). */
645
+ type: ContentTypes.ACTIVITY_LABEL;
646
+ activity_label?: string;
647
+ /** Missing means the legacy/per-batch activity label. */
648
+ activity_label_type?: 'phase';
649
+ tool_call_ids?: string[];
650
+ /** Parent phase bounds and telemetry. */
651
+ activity_start_index?: number;
652
+ /** Exclusive end of the grouped content; may precede the marker itself. */
653
+ activity_end_index?: number;
654
+ activity_count?: number;
655
+ agent_ids?: string[];
656
+ /** ok = all tools succeeded, failed = all failed, partial = mixed. */
657
+ status?: 'ok' | 'partial' | 'failed';
658
+ pending?: boolean;
659
+ } & ContentMetadata) | (Agents.AgentUpdate & ContentMetadata) | (Agents.MessageContentImageUrl & ContentMetadata) | (Agents.MessageContentVideoUrl & ContentMetadata) | (Agents.MessageContentInputAudio & ContentMetadata);
497
660
  export type StreamContentData = TMessageContentParts & {
498
661
  /** The index of the current content part */
499
662
  index: number;