@dudko.dev/agent 0.0.57 → 0.0.59
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.
- package/README.md +104 -6
- package/dist/cli.js +142 -139
- package/dist/index.cjs +151 -115
- package/dist/index.d.cts +718 -657
- package/dist/index.d.ts +718 -657
- package/dist/index.js +151 -115
- package/dist/subagent-worker.js +101 -99
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Experimental_DecisionModel, ToolSet, Tool, ImageModel, SpeechModel, Tra
|
|
|
3
3
|
import { PipelineEvent, PipelineNode, PipelineDefinition, PipelineResult, PipelineNodeRunner } from './pipeline-engine.js';
|
|
4
4
|
export { PIPELINE_LIMITS, PIPELINE_ROUTER_SYSTEM, PipelineAbortBehaviour, PipelineCondition, PipelineEdge, PipelineGraphRunOptions, PipelineIssue, PipelineNodeContext, PipelineNodeError, PipelineNodeEvent, PipelineNodeInput, PipelineNodeOutput, PipelineNodeSource, PipelinePlan, PipelineRoute, PipelineStop, PipelineTraceEntry, PipelineUsage, PipelineValidation, PipelineValidationError, matchPipelineRoute, normalizePipeline, preparePipeline, renderPipelineNodeInput, renderPipelineRoutePrompt, runPipelineGraph, testPipelineCondition, validatePipeline } from './pipeline-engine.js';
|
|
5
5
|
import { JsonWebKey, KeyObject } from 'node:crypto';
|
|
6
|
+
import { ResourceLimits } from 'node:worker_threads';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Steering a run that is already going.
|
|
@@ -422,318 +423,6 @@ declare class SandboxUnavailableError extends Error {
|
|
|
422
423
|
constructor(message: string);
|
|
423
424
|
}
|
|
424
425
|
|
|
425
|
-
declare const GENERATE_IMAGE_TOOL = "generate_image";
|
|
426
|
-
declare const GENERATE_SPEECH_TOOL = "generate_speech";
|
|
427
|
-
declare const TRANSCRIBE_AUDIO_TOOL = "transcribe_audio";
|
|
428
|
-
type MediaKind = 'image' | 'speech' | 'transcription';
|
|
429
|
-
declare const MEDIA_DEFAULT_MAX_CALLS = 8;
|
|
430
|
-
declare const MEDIA_TIMEOUT_MS = 120000;
|
|
431
|
-
declare const MEDIA_MAX_IMAGE_BYTES: number;
|
|
432
|
-
declare const MEDIA_MAX_SPEECH_BYTES: number;
|
|
433
|
-
declare const MEDIA_MAX_AUDIO_INPUT_BYTES: number;
|
|
434
|
-
declare const MEDIA_MAX_PROMPT_CHARS = 4000;
|
|
435
|
-
declare const MEDIA_MAX_SPEECH_CHARS = 4000;
|
|
436
|
-
declare const MEDIA_MAX_TRANSCRIPT_CHARS = 20000;
|
|
437
|
-
declare const MEDIA_MAX_ATTACHED_AUDIO = 4;
|
|
438
|
-
declare const MEDIA_MAX_REFERENCE_IMAGES = 4;
|
|
439
|
-
declare const MEDIA_MAX_REFERENCE_BYTES: number;
|
|
440
|
-
declare const MEDIA_MAX_REFERENCE_TOTAL_BYTES: number;
|
|
441
|
-
declare const MEDIA_MAX_REFERENCE_SIDE = 4096;
|
|
442
|
-
declare const MEDIA_FOLDER = "media";
|
|
443
|
-
declare class MediaError extends Error {
|
|
444
|
-
constructor(message: string);
|
|
445
|
-
toJSON(): string;
|
|
446
|
-
}
|
|
447
|
-
declare class MediaBudgetError extends MediaError {
|
|
448
|
-
constructor(cap: number);
|
|
449
|
-
}
|
|
450
|
-
declare const MEDIA_IMAGE_TYPES: Readonly<Record<string, string>>;
|
|
451
|
-
declare const MEDIA_AUDIO_TYPES: Readonly<Record<string, string>>;
|
|
452
|
-
declare const MEDIA_REFERENCE_TYPES: Readonly<Record<string, string>>;
|
|
453
|
-
declare const sniffMediaType: (bytes: Uint8Array) => string | undefined;
|
|
454
|
-
interface IAcceptedMedia {
|
|
455
|
-
mediaType: string;
|
|
456
|
-
ext: string;
|
|
457
|
-
}
|
|
458
|
-
declare const acceptMedia: (family: "image" | "audio", bytes: Uint8Array, maxBytes: number, what: string) => IAcceptedMedia;
|
|
459
|
-
interface IImageSize {
|
|
460
|
-
width: number;
|
|
461
|
-
height: number;
|
|
462
|
-
}
|
|
463
|
-
declare const imageDimensions: (bytes: Uint8Array) => IImageSize | undefined;
|
|
464
|
-
interface IAcceptedReference extends IAcceptedMedia, IImageSize {
|
|
465
|
-
}
|
|
466
|
-
declare const acceptReference: (bytes: Uint8Array, what: string) => IAcceptedReference;
|
|
467
|
-
interface IReferenceUse {
|
|
468
|
-
used: boolean;
|
|
469
|
-
count: number;
|
|
470
|
-
paths: string[];
|
|
471
|
-
}
|
|
472
|
-
interface IReferenceResult extends IReferenceUse {
|
|
473
|
-
note?: string;
|
|
474
|
-
}
|
|
475
|
-
interface IMediaUsage {
|
|
476
|
-
mediaCalls: number;
|
|
477
|
-
imagesGenerated: number;
|
|
478
|
-
speechCharacters: number;
|
|
479
|
-
transcriptionSeconds: number;
|
|
480
|
-
}
|
|
481
|
-
declare const mediaUsageOf: (usage: Partial<IMediaUsage> | undefined) => IMediaUsage | undefined;
|
|
482
|
-
interface ITranscriptBlock {
|
|
483
|
-
name: string;
|
|
484
|
-
text: string;
|
|
485
|
-
language?: string;
|
|
486
|
-
durationInSeconds?: number;
|
|
487
|
-
}
|
|
488
|
-
declare const wrapTranscript: (block: ITranscriptBlock) => string;
|
|
489
|
-
|
|
490
|
-
type IMediaModelSpec = IAgentStageOverride & {
|
|
491
|
-
model: string;
|
|
492
|
-
};
|
|
493
|
-
type MediaImageModel = Exclude<ImageModel, string>;
|
|
494
|
-
type MediaSpeechModel = Exclude<SpeechModel, string>;
|
|
495
|
-
type MediaTranscriptionModel = Exclude<TranscriptionModel, string>;
|
|
496
|
-
interface IMediaConfig {
|
|
497
|
-
imageModel?: MediaImageModel | IMediaModelSpec;
|
|
498
|
-
imageInputs?: boolean;
|
|
499
|
-
speechModel?: MediaSpeechModel | IMediaModelSpec;
|
|
500
|
-
transcriptionModel?: MediaTranscriptionModel | IMediaModelSpec;
|
|
501
|
-
maxCalls?: number;
|
|
502
|
-
timeoutMs?: number;
|
|
503
|
-
dir?: string;
|
|
504
|
-
voice?: string;
|
|
505
|
-
speechFormat?: string;
|
|
506
|
-
}
|
|
507
|
-
interface IRunFile {
|
|
508
|
-
data: string | Uint8Array;
|
|
509
|
-
mediaType?: string;
|
|
510
|
-
name?: string;
|
|
511
|
-
}
|
|
512
|
-
interface IMediaFile {
|
|
513
|
-
path: string;
|
|
514
|
-
mediaType: string;
|
|
515
|
-
bytes: number;
|
|
516
|
-
references?: IReferenceResult;
|
|
517
|
-
}
|
|
518
|
-
interface ITranscription {
|
|
519
|
-
path: string;
|
|
520
|
-
text: string;
|
|
521
|
-
language?: string;
|
|
522
|
-
durationInSeconds?: number;
|
|
523
|
-
truncated?: true;
|
|
524
|
-
untrusted: true;
|
|
525
|
-
}
|
|
526
|
-
interface IMedia {
|
|
527
|
-
tools: ToolSet;
|
|
528
|
-
attach: (input: string, files: IRunFile[], signal?: AbortSignal) => Promise<string>;
|
|
529
|
-
}
|
|
530
|
-
declare const createMedia: (config: IAgentConfig) => Promise<IMedia | undefined>;
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* MCP elicitation, the part the two agent packages share: a server asks the user for input in
|
|
534
|
-
* the middle of a tool call, the HOST answers through a callback, and the call goes on. Pure, no
|
|
535
|
-
* imports: the limits, what a request must look like before a host sees it, what an answer must
|
|
536
|
-
* look like before a server sees it, the one function that asks, and the two ways a tool call
|
|
537
|
-
* with questions is driven (`elicitation/create` requests on the 2025 revisions, `input_required`
|
|
538
|
-
* results on 2026-07-28).
|
|
539
|
-
*
|
|
540
|
-
* A consent boundary. The server's text is third-party data: cleaned and capped here, shown only
|
|
541
|
-
* to the host's callback and in the `mcp.elicitation-requested` event, never put into a prompt.
|
|
542
|
-
* The answer goes to the server that asked and nowhere else: nothing in this file logs, emits or
|
|
543
|
-
* returns a value the user entered - events and errors carry field NAMES only.
|
|
544
|
-
*
|
|
545
|
-
* This file is a COPY, byte for byte, in `@dudko.dev/agent` (`src/mcp-elicitation.ts`) and
|
|
546
|
-
* `@dudko.dev/agent-web` (`src/mcp/elicitation.ts`): change both. The Node package's
|
|
547
|
-
* `tests/mcp-elicitation-shared.test.ts` compares the two files and tests every guard here; each
|
|
548
|
-
* needs a mutation check.
|
|
549
|
-
*/
|
|
550
|
-
/** How long one question waits for the host's answer, by default: a human is reading it. */
|
|
551
|
-
declare const MCP_ELICITATION_TIMEOUT_MS = 300000;
|
|
552
|
-
/** The most questions one tool call may ask, by default. */
|
|
553
|
-
declare const MCP_ELICITATION_MAX_PER_TOOL_CALL = 5;
|
|
554
|
-
/** The most questions one run may be asked, by default (its helpers' calls included). */
|
|
555
|
-
declare const MCP_ELICITATION_MAX_PER_RUN = 20;
|
|
556
|
-
/** One field of a form: the flat subset of JSON Schema the specification allows, nothing else. */
|
|
557
|
-
interface McpElicitationFieldSchema {
|
|
558
|
-
type: 'string' | 'number' | 'integer' | 'boolean' | 'array';
|
|
559
|
-
title?: string;
|
|
560
|
-
description?: string;
|
|
561
|
-
default?: string | number | boolean | string[];
|
|
562
|
-
/** string */
|
|
563
|
-
minLength?: number;
|
|
564
|
-
maxLength?: number;
|
|
565
|
-
format?: 'email' | 'uri' | 'date' | 'date-time';
|
|
566
|
-
/** string: single-select, plain (`enumNames`: the older titled form). */
|
|
567
|
-
enum?: string[];
|
|
568
|
-
enumNames?: string[];
|
|
569
|
-
/** string: single-select with titles. */
|
|
570
|
-
oneOf?: {
|
|
571
|
-
const: string;
|
|
572
|
-
title: string;
|
|
573
|
-
}[];
|
|
574
|
-
/** number / integer */
|
|
575
|
-
minimum?: number;
|
|
576
|
-
maximum?: number;
|
|
577
|
-
/** array: multi-select. */
|
|
578
|
-
minItems?: number;
|
|
579
|
-
maxItems?: number;
|
|
580
|
-
items?: {
|
|
581
|
-
type?: 'string';
|
|
582
|
-
enum?: string[];
|
|
583
|
-
anyOf?: {
|
|
584
|
-
const: string;
|
|
585
|
-
title: string;
|
|
586
|
-
}[];
|
|
587
|
-
};
|
|
588
|
-
}
|
|
589
|
-
/** The form a server asks for, as a host is shown it: checked, cleaned and capped. */
|
|
590
|
-
interface McpElicitationSchema {
|
|
591
|
-
type: 'object';
|
|
592
|
-
properties: Record<string, McpElicitationFieldSchema>;
|
|
593
|
-
required?: string[];
|
|
594
|
-
}
|
|
595
|
-
/** What the host's callback is given. Every string in it is third-party text. */
|
|
596
|
-
interface McpElicitationRequest {
|
|
597
|
-
/** Unique per question; the same id is in the two events. */
|
|
598
|
-
id: string;
|
|
599
|
-
/** The server that asks: its key in the host's configuration. */
|
|
600
|
-
server: string;
|
|
601
|
-
/** The tool call during which it asks: the tool's name as the model called it. */
|
|
602
|
-
tool: string;
|
|
603
|
-
mode: 'form' | 'url';
|
|
604
|
-
/** The server's words, cleaned and capped (MCP_ELICITATION_MESSAGE_MAX_CHARS). */
|
|
605
|
-
message: string;
|
|
606
|
-
/** Form mode: the fields to fill in. */
|
|
607
|
-
requestedSchema?: McpElicitationSchema;
|
|
608
|
-
/**
|
|
609
|
-
* URL mode: the link the server wants the user to open. It is only handed over: nothing in
|
|
610
|
-
* these packages fetches or opens it. https, or http on a loopback host.
|
|
611
|
-
*/
|
|
612
|
-
url?: string;
|
|
613
|
-
/** URL mode on the 2025 revisions: the server's id for this interaction. */
|
|
614
|
-
elicitationId?: string;
|
|
615
|
-
runId?: string;
|
|
616
|
-
/** Set when a helper the model started is the one whose call asks (`elicitation.subagents`). */
|
|
617
|
-
subagent?: {
|
|
618
|
-
id: string;
|
|
619
|
-
depth: number;
|
|
620
|
-
};
|
|
621
|
-
}
|
|
622
|
-
type McpElicitationContent = Record<string, string | number | boolean | string[]>;
|
|
623
|
-
/**
|
|
624
|
-
* The host's answer. `accept` carries the form's values (form mode) or nothing (URL mode: it
|
|
625
|
-
* says the user agreed to open the link); `decline` is a no; `cancel` is "dismissed".
|
|
626
|
-
*/
|
|
627
|
-
type McpElicitationResult = {
|
|
628
|
-
action: 'accept';
|
|
629
|
-
content?: McpElicitationContent;
|
|
630
|
-
} | {
|
|
631
|
-
action: 'decline';
|
|
632
|
-
} | {
|
|
633
|
-
action: 'cancel';
|
|
634
|
-
};
|
|
635
|
-
interface McpElicitationContext {
|
|
636
|
-
/** Aborted when the answer is no longer wanted: the run stopped, or the time ran out. */
|
|
637
|
-
signal: AbortSignal;
|
|
638
|
-
}
|
|
639
|
-
/** `onElicitation`: the host decides, never the model. */
|
|
640
|
-
type McpElicitationHandler = (request: McpElicitationRequest, ctx: McpElicitationContext) => McpElicitationResult | Promise<McpElicitationResult>;
|
|
641
|
-
/** The `elicitation` settings beside `onElicitation`. */
|
|
642
|
-
interface McpElicitationOptions {
|
|
643
|
-
/**
|
|
644
|
-
* How long one question waits for an answer. Default 300 000. `0` or `Infinity` = no limit of
|
|
645
|
-
* its own (the question waits until the run is stopped), and so is a value above 2^31 - 1 (about
|
|
646
|
-
* 24.8 days, the most a timer holds). Negative or NaN: a configuration error.
|
|
647
|
-
*/
|
|
648
|
-
timeoutMs?: number;
|
|
649
|
-
/** Questions one tool call may ask. Default 5. */
|
|
650
|
-
maxPerToolCall?: number;
|
|
651
|
-
/** Questions one run may be asked. Default 20. */
|
|
652
|
-
maxPerRun?: number;
|
|
653
|
-
/** Also accept URL mode (a link to open). Default false: only forms are declared. */
|
|
654
|
-
url?: boolean;
|
|
655
|
-
/**
|
|
656
|
-
* Let a tool call made by a helper (a subagent) ask the user too. Default false: such a
|
|
657
|
-
* question is cancelled without the callback being called.
|
|
658
|
-
*/
|
|
659
|
-
subagents?: boolean;
|
|
660
|
-
}
|
|
661
|
-
/** Why a question was answered without the host deciding. */
|
|
662
|
-
type McpElicitationReason = 'unsupported-schema' | 'unsupported-mode' | 'insecure-url' | 'invalid-request' | 'subagent' | 'cap-per-call' | 'cap-per-run' | 'handler-error' | 'timeout' | 'invalid-answer' | 'aborted' | 'step-timeout' | 'after-failure' | 'no-tool-call';
|
|
663
|
-
type Checked<T> = {
|
|
664
|
-
ok: true;
|
|
665
|
-
value: T;
|
|
666
|
-
} | {
|
|
667
|
-
ok: false;
|
|
668
|
-
reason: string;
|
|
669
|
-
};
|
|
670
|
-
/**
|
|
671
|
-
* The form a server asked for, reduced to what the specification allows a form to be: a flat
|
|
672
|
-
* object of strings, numbers, booleans and selects. Anything else - a nested object, a list of
|
|
673
|
-
* objects, a type union, an unknown format, too many fields or options, a name that could not
|
|
674
|
-
* be sent back verbatim - is refused with a reason (the caller declines the request). Keywords
|
|
675
|
-
* outside the subset are dropped; titles and descriptions are cleaned and capped.
|
|
676
|
-
*/
|
|
677
|
-
declare const normalizeMcpElicitationSchema: (raw: unknown) => Checked<McpElicitationSchema>;
|
|
678
|
-
/**
|
|
679
|
-
* An accepted form, checked against the schema it answers: every value of the type and within
|
|
680
|
-
* the limits its field states, every required field there, and NO field the form did not ask
|
|
681
|
-
* for (what the server did not request is not sent to it). The result is a fresh object holding
|
|
682
|
-
* only the form's own fields. A refusal names the field and the rule, never the value.
|
|
683
|
-
*/
|
|
684
|
-
declare const validateMcpElicitationContent: (schema: McpElicitationSchema, content: unknown) => Checked<McpElicitationContent>;
|
|
685
|
-
|
|
686
|
-
/**
|
|
687
|
-
* What the MCP connectors of the two agent packages share: how a server's `instructions` reach a
|
|
688
|
-
* system prompt, how a tool result's `structuredContent` reaches the model, and what the
|
|
689
|
-
* per-server `protocol` option means. Pure, no imports.
|
|
690
|
-
*
|
|
691
|
-
* This file is a COPY, byte for byte, in `@dudko.dev/agent` (`src/mcp-shared.ts`) and
|
|
692
|
-
* `@dudko.dev/agent-web` (`src/mcp/shared.ts`): change both. The Node package's
|
|
693
|
-
* `tests/mcp-shared.test.ts` compares the two files and tests every cap and guard here.
|
|
694
|
-
*/
|
|
695
|
-
/** The `instructions` one connected MCP server returned in its `initialize` result. */
|
|
696
|
-
interface McpServerInstructions {
|
|
697
|
-
/** The server's name: its key in the host's configuration. */
|
|
698
|
-
server: string;
|
|
699
|
-
instructions: string;
|
|
700
|
-
}
|
|
701
|
-
/** The most one server's instructions take in a system prompt, in characters. */
|
|
702
|
-
declare const MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER = 2000;
|
|
703
|
-
/** The most all servers' instructions take together, in characters. */
|
|
704
|
-
declare const MCP_INSTRUCTIONS_MAX_CHARS_TOTAL = 8000;
|
|
705
|
-
/**
|
|
706
|
-
* The system-prompt section for the servers' instructions, or '' when no server sent any (the
|
|
707
|
-
* prompt is then exactly what it was). Each server's text is capped
|
|
708
|
-
* (MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER), so is the sum (MCP_INSTRUCTIONS_MAX_CHARS_TOTAL, in
|
|
709
|
-
* the order given: a server past the total is named as omitted), and every line of it is
|
|
710
|
-
* prefixed with "| ", so a server cannot write something that reads as a heading of this prompt
|
|
711
|
-
* or as another server's note.
|
|
712
|
-
*/
|
|
713
|
-
declare const renderMcpInstructions: (list: readonly McpServerInstructions[] | undefined) => string;
|
|
714
|
-
/**
|
|
715
|
-
* Which revisions of the protocol a connection to one server may use (the server config's
|
|
716
|
-
* `protocol`):
|
|
717
|
-
*
|
|
718
|
-
* - `'legacy'` (default): the 2025 revisions, the `initialize` handshake. Nothing of the 2026
|
|
719
|
-
* revision is sent.
|
|
720
|
-
* - `'auto'`: ask first (`server/discover`); a server that answers with 2026-07-28 is spoken to
|
|
721
|
-
* that way, any other is given the 2025 handshake. Decided once, at connect.
|
|
722
|
-
* - `'modern'`: 2026-07-28 only. A server that does not offer it fails the connect.
|
|
723
|
-
*/
|
|
724
|
-
type McpProtocolMode = 'legacy' | 'auto' | 'modern';
|
|
725
|
-
/** The revision `protocol: 'modern'` pins: the one this connector is tested against. */
|
|
726
|
-
declare const MCP_MODERN_PROTOCOL_VERSION = "2026-07-28";
|
|
727
|
-
/** What a connection negotiated with one server. */
|
|
728
|
-
interface McpServerProtocol {
|
|
729
|
-
/** The server's name: its key in the host's configuration. */
|
|
730
|
-
server: string;
|
|
731
|
-
/** The protocol revision in use, e.g. `2025-11-25` or `2026-07-28`. */
|
|
732
|
-
version: string;
|
|
733
|
-
/** `modern` from 2026-07-28 on (stateless, `server/discover`), `legacy` before. */
|
|
734
|
-
era: 'legacy' | 'modern';
|
|
735
|
-
}
|
|
736
|
-
|
|
737
426
|
/**
|
|
738
427
|
* MCP Skills (the `io.modelcontextprotocol/skills` extension, SEP-2640, Beta; written against
|
|
739
428
|
* base revision 2026-07-28): what the two agent packages share about a server's skills. The
|
|
@@ -843,84 +532,341 @@ type McpSkillConsent = 'ask' | 'once-per-skill' | 'never';
|
|
|
843
532
|
/** Every value of {@link McpSkillConsent}. */
|
|
844
533
|
declare const MCP_SKILL_CONSENTS: readonly McpSkillConsent[];
|
|
845
534
|
/**
|
|
846
|
-
* The default: asked the first time a skill would enter the context in the agent's life, and again
|
|
847
|
-
* only when its entry changed - often enough that every text a person did not see is shown, seldom
|
|
848
|
-
* enough that a yes still means something.
|
|
535
|
+
* The default: asked the first time a skill would enter the context in the agent's life, and again
|
|
536
|
+
* only when its entry changed - often enough that every text a person did not see is shown, seldom
|
|
537
|
+
* enough that a yes still means something.
|
|
538
|
+
*/
|
|
539
|
+
declare const MCP_SKILL_CONSENT_DEFAULT: McpSkillConsent;
|
|
540
|
+
/** `skills` on a server's config, as an object. */
|
|
541
|
+
interface McpSkillsOptions {
|
|
542
|
+
/**
|
|
543
|
+
* `'once-per-skill'` (default): a person is asked the first time each skill would enter the
|
|
544
|
+
* model's context, and a yes holds for the agent's life while the skill's entry is the same;
|
|
545
|
+
* `'ask'`: asked in every run that loads it; `'never'`: never asked - for a server the host
|
|
546
|
+
* vetted (its skills load as soon as the model asks). Whatever the approval mode says.
|
|
547
|
+
*/
|
|
548
|
+
consent?: McpSkillConsent;
|
|
549
|
+
/**
|
|
550
|
+
* `true`: also take this server's GENERATED skills (`"resources": "dynamic"` - no checksums;
|
|
551
|
+
* declined by default). When one would enter the model's context, the agent first reads all
|
|
552
|
+
* of it - `SKILL.md` and, if the server serves `resources/directory/read`, every file its
|
|
553
|
+
* directories list, within the specification's limits - computes each file's digest itself,
|
|
554
|
+
* and holds that copy in memory: the person approves that copy (the consent binds to its
|
|
555
|
+
* digests), and the model is given only that copy, never a later read. Per server, for a
|
|
556
|
+
* server you trust with this; there is no agent-wide switch.
|
|
557
|
+
*/
|
|
558
|
+
dynamic?: boolean;
|
|
559
|
+
}
|
|
560
|
+
/** `skills` on a server's config: `true`, or options (on, with them); `false` / absent: off. */
|
|
561
|
+
type McpSkillsSetting = boolean | McpSkillsOptions;
|
|
562
|
+
/**
|
|
563
|
+
* What a person is shown before a server's skill enters the model's context - the request's
|
|
564
|
+
* `skill` (the core's `tool.approval-requested` event). Every string is the SERVER's, cleaned:
|
|
565
|
+
* show it as plain text, captioned as the server's.
|
|
566
|
+
*/
|
|
567
|
+
interface McpSkillConsentView {
|
|
568
|
+
/** The host's label of the server that serves it. */
|
|
569
|
+
server: string;
|
|
570
|
+
/** Its name in the agent's catalog (`<server>/<skill>`). */
|
|
571
|
+
name: string;
|
|
572
|
+
/** Its frontmatter name. */
|
|
573
|
+
skill: string;
|
|
574
|
+
/** The URI of its `SKILL.md` (cleaned, at most 200 characters). */
|
|
575
|
+
uri: string;
|
|
576
|
+
/** The description from its entry, on one line, at most {@link MCP_SKILL_DESCRIPTION_MAX_CHARS}. */
|
|
577
|
+
description: string;
|
|
578
|
+
/** Bytes of its `SKILL.md`, and of all its files. */
|
|
579
|
+
size: number;
|
|
580
|
+
totalSize: number;
|
|
581
|
+
/** Its other files, by path (at most {@link MCP_SKILL_FILES_SHOWN_MAX}), and how many there are. */
|
|
582
|
+
files: string[];
|
|
583
|
+
fileCount: number;
|
|
584
|
+
/** Its instructions exactly as the model would read them ({@link mcpSkillBodyPreview}). */
|
|
585
|
+
body: string;
|
|
586
|
+
/** Named by URI (`skills/get`), not in the server's listing. */
|
|
587
|
+
byUri?: true;
|
|
588
|
+
/** It sits inside this skill of the same server, whose approval does not cover it. */
|
|
589
|
+
nestedIn?: string;
|
|
590
|
+
/**
|
|
591
|
+
* Generated by the server (`"resources": "dynamic"`, taken with `skills: { dynamic: true }`):
|
|
592
|
+
* there are no checksums. The size, the files and the text are those of the copy the agent just
|
|
593
|
+
* read (its snapshot), and only that copy is used - say so.
|
|
594
|
+
*/
|
|
595
|
+
dynamic?: true;
|
|
596
|
+
/**
|
|
597
|
+
* (with `dynamic`) The server cannot list the skill's files (no `resources/directory/read`): the
|
|
598
|
+
* copy is its `SKILL.md` alone, and no other file of it can be read.
|
|
599
|
+
*/
|
|
600
|
+
noFileListing?: true;
|
|
601
|
+
/** Asked for this run only (`'ask'`) or, on a yes, for the agent's life (`'once-per-skill'`). */
|
|
602
|
+
consent: Exclude<McpSkillConsent, 'never'>;
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* The most directories one snapshot reads (`resources/directory/read`, the skill's root
|
|
606
|
+
* included). One read is one directory, its pages walked by the SDK (bounded by its own page cap).
|
|
607
|
+
*/
|
|
608
|
+
declare const MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES = 64;
|
|
609
|
+
/** The deepest directory of a skill a snapshot reads: its root is 0, `templates` 1, ... */
|
|
610
|
+
declare const MCP_SKILL_SNAPSHOT_MAX_DEPTH = 8;
|
|
611
|
+
/** The most bytes the snapshots of one agent hold in memory together. */
|
|
612
|
+
declare const MCP_SKILL_SNAPSHOTS_MAX_BYTES: number;
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Thrown from inside a tool's execute when the call was not approved. The AI
|
|
616
|
+
* SDK records it as a failed tool call (`ok: false`), so the replanner sees
|
|
617
|
+
* it; `toJSON` keeps the message when a trace is serialised.
|
|
618
|
+
*/
|
|
619
|
+
declare class ToolDeniedError extends Error {
|
|
620
|
+
readonly reason?: string;
|
|
621
|
+
constructor(reason?: string);
|
|
622
|
+
toJSON(): string;
|
|
623
|
+
}
|
|
624
|
+
declare const markReadOnly: <T extends object>(tool: T, readOnly?: boolean) => T;
|
|
625
|
+
declare const isReadOnlyTool: (tool: unknown) => boolean;
|
|
626
|
+
declare const markCodeExecution: <T extends object>(tool: T, codeExecution?: boolean) => T;
|
|
627
|
+
declare const isCodeExecutionTool: (tool: unknown) => boolean;
|
|
628
|
+
/**
|
|
629
|
+
* The most specific rule matching `name`: an exact key wins, then the
|
|
630
|
+
* longest matching '*' glob (ties: the first declared). Pure.
|
|
631
|
+
*/
|
|
632
|
+
declare const matchToolRule: (rules: Record<string, ToolPermission> | undefined, name: string) => {
|
|
633
|
+
pattern: string;
|
|
634
|
+
permission: ToolPermission;
|
|
635
|
+
} | undefined;
|
|
636
|
+
interface IToolDecisionInput {
|
|
637
|
+
name: string;
|
|
638
|
+
readOnly: boolean;
|
|
639
|
+
mode: ToolApprovalMode;
|
|
640
|
+
rules?: Record<string, ToolPermission>;
|
|
641
|
+
remembered?: ReadonlySet<string>;
|
|
642
|
+
builtIn?: boolean;
|
|
643
|
+
codeExecution?: boolean;
|
|
644
|
+
mcpSkills?: readonly string[];
|
|
645
|
+
}
|
|
646
|
+
interface IToolDecision {
|
|
647
|
+
permission: ToolPermission;
|
|
648
|
+
source: 'builtin' | 'remembered' | 'rule' | 'mode' | 'mcp-skill';
|
|
649
|
+
rule?: string;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Decide one call. Pure. Order: built-in -> remembered "always allow" ->
|
|
653
|
+
* most specific rule -> mode default (autopilot: allow; read-only: allow if
|
|
654
|
+
* readOnly else deny; ask-writes: allow if readOnly else ask; ask-all: ask).
|
|
655
|
+
* Then one rule that only ever tightens: a call that runs code while the run acts on an MCP
|
|
656
|
+
* server's skill is asked when it would have been allowed - by the mode, a rule or an "always
|
|
657
|
+
* allow" alike (the Skills extension: no code runs here on a server's skill without a person's
|
|
658
|
+
* approval). A deny stays a deny.
|
|
659
|
+
*/
|
|
660
|
+
declare const decideToolPermission: (input: IToolDecisionInput) => IToolDecision;
|
|
661
|
+
/** How long a question waits for a decision when `toolApproval.timeoutMs` is not set: 5 minutes. */
|
|
662
|
+
declare const TOOL_APPROVAL_TIMEOUT_MS = 300000;
|
|
663
|
+
|
|
664
|
+
declare const ASK_USER_TOOL = "ask_user";
|
|
665
|
+
/** How long one question waits for the person, by default: a human is reading it. */
|
|
666
|
+
declare const ASK_USER_TIMEOUT_MS = 300000;
|
|
667
|
+
/**
|
|
668
|
+
* The longest wait a timer holds (2^31 - 1 ms, about 24.8 days). `setTimeout` fires a longer one -
|
|
669
|
+
* Infinity included - after about 1 ms, so a `timeoutMs` past it is taken as no limit at all.
|
|
670
|
+
*/
|
|
671
|
+
declare const ASK_USER_TIMEOUT_MAX_MS = 2147483647;
|
|
672
|
+
/** The most questions one run may ask, by default (its helpers' and subagents' included). */
|
|
673
|
+
declare const ASK_USER_MAX_PER_RUN = 3;
|
|
674
|
+
/** A question offers at least this many options... */
|
|
675
|
+
declare const ASK_USER_MIN_OPTIONS = 2;
|
|
676
|
+
/** ...and at most this many. */
|
|
677
|
+
declare const ASK_USER_MAX_OPTIONS = 6;
|
|
678
|
+
/** The longest question, in characters (after cleaning). */
|
|
679
|
+
declare const ASK_USER_QUESTION_MAX_CHARS = 500;
|
|
680
|
+
/** The longest option label. */
|
|
681
|
+
declare const ASK_USER_LABEL_MAX_CHARS = 80;
|
|
682
|
+
/** The longest option description. */
|
|
683
|
+
declare const ASK_USER_DESCRIPTION_MAX_CHARS = 200;
|
|
684
|
+
/** The most of a person's own words (`{ other }`) the model is given; the rest is cut. */
|
|
685
|
+
declare const ASK_USER_OTHER_MAX_CHARS = 2000;
|
|
686
|
+
/** One option of a question, as the person is shown it. Both strings are the MODEL's, cleaned. */
|
|
687
|
+
interface AskUserOption {
|
|
688
|
+
label: string;
|
|
689
|
+
description?: string;
|
|
690
|
+
}
|
|
691
|
+
/** A question as checked and cleaned: what a host shows and an event carries. */
|
|
692
|
+
interface AskUserQuestion {
|
|
693
|
+
question: string;
|
|
694
|
+
options: AskUserOption[];
|
|
695
|
+
/** The person may pick several options. */
|
|
696
|
+
multiple: boolean;
|
|
697
|
+
/** The person may answer in their own words instead of picking. */
|
|
698
|
+
allowOther: boolean;
|
|
699
|
+
}
|
|
700
|
+
/** What the host's `onQuestion` is given. Every string in it is the model's text, cleaned. */
|
|
701
|
+
interface AskUserRequest<TStep = unknown> extends AskUserQuestion {
|
|
702
|
+
/** Unique per question; the same id is in the two events. */
|
|
703
|
+
id: string;
|
|
704
|
+
/** The plan step whose tool call asks. */
|
|
705
|
+
step?: TStep;
|
|
706
|
+
runId?: string;
|
|
707
|
+
/** Set when a helper or a subagent of the run asks, not the run itself: its id and depth. */
|
|
708
|
+
subagent?: {
|
|
709
|
+
id: string;
|
|
710
|
+
depth: number;
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* The person's answer: the labels they picked (exactly as offered; one unless `multiple`), their
|
|
715
|
+
* own words (only when `allowOther`), or that they would rather not answer.
|
|
716
|
+
*/
|
|
717
|
+
type AskUserAnswer = {
|
|
718
|
+
choice: string[];
|
|
719
|
+
} | {
|
|
720
|
+
other: string;
|
|
721
|
+
} | {
|
|
722
|
+
declined: true;
|
|
723
|
+
};
|
|
724
|
+
interface AskUserContext {
|
|
725
|
+
/**
|
|
726
|
+
* Aborted when the question ends WITHOUT the host's answer: no answer within `timeoutMs`
|
|
727
|
+
* (`signal.reason` is an Error named 'TimeoutError'), the run was stopped, or the handler
|
|
728
|
+
* failed. Take the prompt down then: an answer given later is ignored. Never aborted once the
|
|
729
|
+
* host has answered.
|
|
730
|
+
*/
|
|
731
|
+
signal: AbortSignal;
|
|
732
|
+
}
|
|
733
|
+
/** How a question ended. `automatic`: nobody decided (a time limit, a stop, a failed handler). */
|
|
734
|
+
type AskUserAction = 'choice' | 'other' | 'declined' | 'timeout' | 'stopped';
|
|
735
|
+
/** Why a question was closed as `declined` without the person deciding. */
|
|
736
|
+
type AskUserReason = 'handler-error' | 'invalid-answer' | 'cannot-park';
|
|
737
|
+
/** The two events of a question. Neither ever carries the person's own words. */
|
|
738
|
+
type AskUserEvent<TStep = unknown> = {
|
|
739
|
+
type: 'user.question-asked';
|
|
740
|
+
id: string;
|
|
741
|
+
question: string;
|
|
742
|
+
options: AskUserOption[];
|
|
743
|
+
multiple: boolean;
|
|
744
|
+
allowOther: boolean;
|
|
745
|
+
step?: TStep;
|
|
746
|
+
subagent?: {
|
|
747
|
+
id: string;
|
|
748
|
+
depth: number;
|
|
749
|
+
};
|
|
750
|
+
} | {
|
|
751
|
+
type: 'user.question-answered';
|
|
752
|
+
id: string;
|
|
753
|
+
action: AskUserAction;
|
|
754
|
+
/** true when nobody decided: a time limit, a stop, a failed handler, an unusable answer. */
|
|
755
|
+
automatic: boolean;
|
|
756
|
+
/** Action 'choice': the labels picked. Never the text of an `other` answer. */
|
|
757
|
+
choice?: string[];
|
|
758
|
+
/** Action 'declined' with `automatic`: why. */
|
|
759
|
+
reason?: AskUserReason;
|
|
760
|
+
};
|
|
761
|
+
/** A bad `ask_user` input: the tool call fails with this message, which says what to fix. */
|
|
762
|
+
declare class AskUserInputError extends Error {
|
|
763
|
+
constructor(message: string);
|
|
764
|
+
toJSON(): string;
|
|
765
|
+
}
|
|
766
|
+
/** The model's text as a person may be shown it: a string, invisible characters removed, trimmed. */
|
|
767
|
+
declare const cleanAskUserText: (raw: unknown, oneLine?: boolean) => string;
|
|
768
|
+
/**
|
|
769
|
+
* Check and clean the model's `ask_user` arguments: 2-6 options, no two labels alike (letter case
|
|
770
|
+
* and spaces aside), each label 1-80 characters, a description at most 200, a question of 1-500 -
|
|
771
|
+
* all measured after cleaning. An option may be given as a bare string (its label). Throws
|
|
772
|
+
* {@link AskUserInputError} with what to fix.
|
|
773
|
+
*/
|
|
774
|
+
declare const checkAskUserInput: (raw: unknown) => AskUserQuestion;
|
|
775
|
+
/** An answer as checked: what the model is told. */
|
|
776
|
+
type AskUserCheckedAnswer = {
|
|
777
|
+
kind: 'choice';
|
|
778
|
+
choice: string[];
|
|
779
|
+
} | {
|
|
780
|
+
kind: 'other';
|
|
781
|
+
text: string;
|
|
782
|
+
} | {
|
|
783
|
+
kind: 'declined';
|
|
784
|
+
};
|
|
785
|
+
/**
|
|
786
|
+
* Check the host's answer against the question: exactly one of `choice` (labels that were
|
|
787
|
+
* offered, no repeats, one unless `multiple`), `other` (a non-empty text, only when `allowOther`;
|
|
788
|
+
* cleaned and cut at {@link ASK_USER_OTHER_MAX_CHARS}) or `declined: true`. Anything else is not
|
|
789
|
+
* an answer.
|
|
849
790
|
*/
|
|
850
|
-
declare const
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
*/
|
|
869
|
-
dynamic?: boolean;
|
|
791
|
+
declare const checkAskUserAnswer: (q: AskUserQuestion, raw: unknown) => {
|
|
792
|
+
ok: true;
|
|
793
|
+
value: AskUserCheckedAnswer;
|
|
794
|
+
} | {
|
|
795
|
+
ok: false;
|
|
796
|
+
reason: string;
|
|
797
|
+
};
|
|
798
|
+
|
|
799
|
+
declare const SPAWN_SUBAGENT_TOOL = "spawn_subagent";
|
|
800
|
+
type SubagentDefaultTools = 'read-only' | 'all';
|
|
801
|
+
interface IDynamicSubagentsConfig {
|
|
802
|
+
maxDepth?: number;
|
|
803
|
+
maxChildren?: number;
|
|
804
|
+
maxConcurrent?: number;
|
|
805
|
+
budgetShare?: number;
|
|
806
|
+
minTokens?: number;
|
|
807
|
+
timeoutMs?: number;
|
|
808
|
+
defaultTools?: SubagentDefaultTools;
|
|
870
809
|
}
|
|
871
|
-
|
|
872
|
-
|
|
810
|
+
interface ISubagentsConfig {
|
|
811
|
+
dynamic?: boolean | IDynamicSubagentsConfig;
|
|
812
|
+
}
|
|
813
|
+
interface IResolvedDynamicSubagents {
|
|
814
|
+
maxDepth: number;
|
|
815
|
+
maxChildren: number;
|
|
816
|
+
maxConcurrent: number;
|
|
817
|
+
budgetShare: number;
|
|
818
|
+
minTokens: number;
|
|
819
|
+
timeoutMs: number;
|
|
820
|
+
defaultTools: SubagentDefaultTools;
|
|
821
|
+
}
|
|
822
|
+
declare const SUBAGENT_DEFAULTS: IResolvedDynamicSubagents;
|
|
823
|
+
declare const SUBAGENT_MAX_DEPTH_LIMIT = 4;
|
|
873
824
|
/**
|
|
874
|
-
*
|
|
875
|
-
*
|
|
876
|
-
* show it as plain text, captioned as the server's.
|
|
825
|
+
* The effective settings, or undefined when the feature is off (nothing is mounted, nothing is
|
|
826
|
+
* added to a prompt). A bad value is a configuration error, thrown when the agent is created.
|
|
877
827
|
*/
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
uri: string;
|
|
887
|
-
/** The description from its entry, on one line, at most {@link MCP_SKILL_DESCRIPTION_MAX_CHARS}. */
|
|
888
|
-
description: string;
|
|
889
|
-
/** Bytes of its `SKILL.md`, and of all its files. */
|
|
890
|
-
size: number;
|
|
891
|
-
totalSize: number;
|
|
892
|
-
/** Its other files, by path (at most {@link MCP_SKILL_FILES_SHOWN_MAX}), and how many there are. */
|
|
893
|
-
files: string[];
|
|
894
|
-
fileCount: number;
|
|
895
|
-
/** Its instructions exactly as the model would read them ({@link mcpSkillBodyPreview}). */
|
|
896
|
-
body: string;
|
|
897
|
-
/** Named by URI (`skills/get`), not in the server's listing. */
|
|
898
|
-
byUri?: true;
|
|
899
|
-
/** It sits inside this skill of the same server, whose approval does not cover it. */
|
|
900
|
-
nestedIn?: string;
|
|
901
|
-
/**
|
|
902
|
-
* Generated by the server (`"resources": "dynamic"`, taken with `skills: { dynamic: true }`):
|
|
903
|
-
* there are no checksums. The size, the files and the text are those of the copy the agent just
|
|
904
|
-
* read (its snapshot), and only that copy is used - say so.
|
|
905
|
-
*/
|
|
906
|
-
dynamic?: true;
|
|
907
|
-
/**
|
|
908
|
-
* (with `dynamic`) The server cannot list the skill's files (no `resources/directory/read`): the
|
|
909
|
-
* copy is its `SKILL.md` alone, and no other file of it can be read.
|
|
910
|
-
*/
|
|
911
|
-
noFileListing?: true;
|
|
912
|
-
/** Asked for this run only (`'ask'`) or, on a yes, for the agent's life (`'once-per-skill'`). */
|
|
913
|
-
consent: Exclude<McpSkillConsent, 'never'>;
|
|
828
|
+
declare const resolveDynamicSubagents: (subagents: ISubagentsConfig | undefined) => IResolvedDynamicSubagents | undefined;
|
|
829
|
+
/**
|
|
830
|
+
* A spawn that was refused: the model reads the message as the tool's error and can correct the
|
|
831
|
+
* call or carry on without a helper.
|
|
832
|
+
*/
|
|
833
|
+
declare class SubagentSpawnError extends Error {
|
|
834
|
+
constructor(message: string);
|
|
835
|
+
toJSON(): string;
|
|
914
836
|
}
|
|
837
|
+
declare const SPAWN_INPUT_SCHEMA: {
|
|
838
|
+
readonly type: "object";
|
|
839
|
+
readonly properties: {
|
|
840
|
+
readonly task: {
|
|
841
|
+
readonly type: "string";
|
|
842
|
+
readonly description: "The complete, self-contained sub-task. The helper sees nothing of your context except this text: include every fact, id and constraint it needs, and say what to return.";
|
|
843
|
+
};
|
|
844
|
+
readonly role: {
|
|
845
|
+
readonly type: "string";
|
|
846
|
+
readonly description: "Optional: who the helper should be for this task and how to work, in a sentence or two (e.g. \"a careful code reviewer; report only real bugs\").";
|
|
847
|
+
};
|
|
848
|
+
readonly tools: {
|
|
849
|
+
readonly type: "array";
|
|
850
|
+
readonly items: {
|
|
851
|
+
readonly type: "string";
|
|
852
|
+
};
|
|
853
|
+
readonly description: "Optional: the names of YOUR tools the helper may use. Only tools you have can be named. Omit it for the default set; pass [] for a helper that only reasons.";
|
|
854
|
+
};
|
|
855
|
+
};
|
|
856
|
+
readonly required: string[];
|
|
857
|
+
readonly additionalProperties: false;
|
|
858
|
+
};
|
|
915
859
|
/**
|
|
916
|
-
*
|
|
917
|
-
*
|
|
860
|
+
* A child's event on its way up through the subagent `parentId` (the `subagent.event` envelope is
|
|
861
|
+
* added by the caller). A `subagent.start` is emitted with `depth: 1` and the id of the run that
|
|
862
|
+
* made the call as `parentId`; each subagent it passes through on the way up adds one level, and
|
|
863
|
+
* the first one - its real parent - puts its own id in `parentId`. So at the top of the stream
|
|
864
|
+
* every start carries its true depth and parent, whatever mix of static and dynamic subagents,
|
|
865
|
+
* threads and workers is below.
|
|
918
866
|
*/
|
|
919
|
-
declare const
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
/** The most bytes the snapshots of one agent hold in memory together. */
|
|
923
|
-
declare const MCP_SKILL_SNAPSHOTS_MAX_BYTES: number;
|
|
867
|
+
declare const adoptSubagentEvent: <E extends {
|
|
868
|
+
type: string;
|
|
869
|
+
}>(event: E, parentId: string) => E;
|
|
924
870
|
|
|
925
871
|
interface IRunLease {
|
|
926
872
|
acquire: (runId: string, options: IRunLeaseOptions) => boolean | Promise<boolean>;
|
|
@@ -948,261 +894,400 @@ declare class RunLeaseError extends Error {
|
|
|
948
894
|
}
|
|
949
895
|
declare const RUN_LEASE_DEFAULT_TTL_MS = 30000;
|
|
950
896
|
|
|
951
|
-
declare const
|
|
952
|
-
declare const
|
|
953
|
-
type IFilledUsage = Required<Omit<IUsage, 'decisionCalls' | keyof IMediaUsage>> & Pick<IUsage, 'decisionCalls'> & Partial<IMediaUsage>;
|
|
954
|
-
interface ISdkUsageLike {
|
|
955
|
-
inputTokens?: number;
|
|
956
|
-
outputTokens?: number;
|
|
957
|
-
totalTokens?: number;
|
|
958
|
-
inputTokenDetails?: {
|
|
959
|
-
cacheReadTokens?: number;
|
|
960
|
-
cacheWriteTokens?: number;
|
|
961
|
-
};
|
|
962
|
-
outputTokenDetails?: {
|
|
963
|
-
reasoningTokens?: number;
|
|
964
|
-
};
|
|
965
|
-
decisionCalls?: number;
|
|
966
|
-
reasoningTokens?: number;
|
|
967
|
-
cachedInputTokens?: number;
|
|
968
|
-
mediaCalls?: number;
|
|
969
|
-
imagesGenerated?: number;
|
|
970
|
-
speechCharacters?: number;
|
|
971
|
-
transcriptionSeconds?: number;
|
|
972
|
-
}
|
|
973
|
-
declare const normalizeUsage: (usage: ISdkUsageLike | undefined | null) => IFilledUsage;
|
|
974
|
-
declare const isAuthError: (err: unknown, seen?: Set<unknown>) => boolean;
|
|
975
|
-
declare const addUsage: (a: IUsage, b: IUsage) => IFilledUsage;
|
|
897
|
+
declare const REPLAY_NOTE = "[not run again: this exact call already succeeded in an earlier attempt at this step, and its effect is in place. Its result then:]";
|
|
898
|
+
declare const isReplayedToolOutput: (output: unknown) => boolean;
|
|
976
899
|
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
900
|
+
declare const GENERATE_IMAGE_TOOL = "generate_image";
|
|
901
|
+
declare const GENERATE_SPEECH_TOOL = "generate_speech";
|
|
902
|
+
declare const TRANSCRIBE_AUDIO_TOOL = "transcribe_audio";
|
|
903
|
+
type MediaKind = 'image' | 'speech' | 'transcription';
|
|
904
|
+
declare const MEDIA_DEFAULT_MAX_CALLS = 8;
|
|
905
|
+
declare const MEDIA_TIMEOUT_MS = 120000;
|
|
906
|
+
declare const MEDIA_MAX_IMAGE_BYTES: number;
|
|
907
|
+
declare const MEDIA_MAX_SPEECH_BYTES: number;
|
|
908
|
+
declare const MEDIA_MAX_AUDIO_INPUT_BYTES: number;
|
|
909
|
+
declare const MEDIA_MAX_PROMPT_CHARS = 4000;
|
|
910
|
+
declare const MEDIA_MAX_SPEECH_CHARS = 4000;
|
|
911
|
+
declare const MEDIA_MAX_TRANSCRIPT_CHARS = 20000;
|
|
912
|
+
declare const MEDIA_MAX_ATTACHED_AUDIO = 4;
|
|
913
|
+
declare const MEDIA_MAX_REFERENCE_IMAGES = 4;
|
|
914
|
+
declare const MEDIA_MAX_REFERENCE_BYTES: number;
|
|
915
|
+
declare const MEDIA_MAX_REFERENCE_TOTAL_BYTES: number;
|
|
916
|
+
declare const MEDIA_MAX_REFERENCE_SIDE = 4096;
|
|
917
|
+
declare const MEDIA_MAX_REFERENCE_SOURCE_BYTES: number;
|
|
918
|
+
declare const MEDIA_MAX_REFERENCE_SOURCE_PIXELS = 200000000;
|
|
919
|
+
declare const MEDIA_FIT_TIMEOUT_MS = 30000;
|
|
920
|
+
declare const MEDIA_FOLDER = "media";
|
|
921
|
+
declare class MediaError extends Error {
|
|
922
|
+
constructor(message: string);
|
|
923
|
+
toJSON(): string;
|
|
985
924
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
signal?: AbortSignal;
|
|
989
|
-
}) => void | Promise<void>;
|
|
990
|
-
afterModelCall?: (call: IModelCall, usage: IUsage, outcome: {
|
|
991
|
-
ok: boolean;
|
|
992
|
-
}) => void | Promise<void>;
|
|
925
|
+
declare class MediaBudgetError extends MediaError {
|
|
926
|
+
constructor(cap: number);
|
|
993
927
|
}
|
|
994
|
-
declare
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
928
|
+
declare const MEDIA_IMAGE_TYPES: Readonly<Record<string, string>>;
|
|
929
|
+
declare const MEDIA_AUDIO_TYPES: Readonly<Record<string, string>>;
|
|
930
|
+
declare const MEDIA_REFERENCE_TYPES: Readonly<Record<string, string>>;
|
|
931
|
+
declare const sniffMediaType: (bytes: Uint8Array) => string | undefined;
|
|
932
|
+
interface IAcceptedMedia {
|
|
933
|
+
mediaType: string;
|
|
934
|
+
ext: string;
|
|
935
|
+
}
|
|
936
|
+
declare const acceptMedia: (family: "image" | "audio", bytes: Uint8Array, maxBytes: number, what: string) => IAcceptedMedia;
|
|
937
|
+
interface IImageSize {
|
|
938
|
+
width: number;
|
|
939
|
+
height: number;
|
|
940
|
+
}
|
|
941
|
+
declare const imageDimensions: (bytes: Uint8Array) => IImageSize | undefined;
|
|
942
|
+
interface IAcceptedReference extends IAcceptedMedia, IImageSize {
|
|
943
|
+
}
|
|
944
|
+
declare const acceptReference: (bytes: Uint8Array, what: string) => IAcceptedReference;
|
|
945
|
+
interface IReferencePicture {
|
|
946
|
+
bytes: Uint8Array;
|
|
947
|
+
mediaType: string;
|
|
948
|
+
width: number;
|
|
949
|
+
height: number;
|
|
950
|
+
path: string;
|
|
951
|
+
}
|
|
952
|
+
interface IReferenceBounds {
|
|
953
|
+
maxSide: number;
|
|
954
|
+
maxBytes: number;
|
|
955
|
+
}
|
|
956
|
+
interface IFitReferenceOptions {
|
|
957
|
+
signal: AbortSignal;
|
|
958
|
+
}
|
|
959
|
+
interface IFittedReference {
|
|
960
|
+
bytes: Uint8Array;
|
|
961
|
+
mediaType?: string;
|
|
962
|
+
}
|
|
963
|
+
type MediaFitReference = (picture: IReferencePicture, bounds: IReferenceBounds, options: IFitReferenceOptions) => Promise<IFittedReference | undefined>;
|
|
964
|
+
declare const acceptReferenceSource: (bytes: Uint8Array, what: string) => IAcceptedReference;
|
|
965
|
+
interface IReferenceUse {
|
|
966
|
+
used: boolean;
|
|
967
|
+
count: number;
|
|
968
|
+
paths: string[];
|
|
969
|
+
fitted?: string[];
|
|
970
|
+
}
|
|
971
|
+
interface IReferenceResult extends IReferenceUse {
|
|
972
|
+
note?: string;
|
|
973
|
+
}
|
|
974
|
+
interface IMediaUsage {
|
|
975
|
+
mediaCalls: number;
|
|
976
|
+
imagesGenerated: number;
|
|
977
|
+
speechCharacters: number;
|
|
978
|
+
transcriptionSeconds: number;
|
|
979
|
+
}
|
|
980
|
+
declare const mediaUsageOf: (usage: Partial<IMediaUsage> | undefined) => IMediaUsage | undefined;
|
|
981
|
+
interface ITranscriptBlock {
|
|
982
|
+
name: string;
|
|
983
|
+
text: string;
|
|
984
|
+
language?: string;
|
|
985
|
+
durationInSeconds?: number;
|
|
998
986
|
}
|
|
987
|
+
declare const wrapTranscript: (block: ITranscriptBlock) => string;
|
|
999
988
|
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
989
|
+
type IMediaModelSpec = IAgentStageOverride & {
|
|
990
|
+
model: string;
|
|
991
|
+
};
|
|
992
|
+
type MediaImageModel = Exclude<ImageModel, string>;
|
|
993
|
+
type MediaSpeechModel = Exclude<SpeechModel, string>;
|
|
994
|
+
type MediaTranscriptionModel = Exclude<TranscriptionModel, string>;
|
|
995
|
+
interface IMediaConfig {
|
|
996
|
+
imageModel?: MediaImageModel | IMediaModelSpec;
|
|
997
|
+
imageInputs?: boolean;
|
|
998
|
+
fitReference?: MediaFitReference;
|
|
999
|
+
fitTimeoutMs?: number;
|
|
1000
|
+
viewGenerated?: boolean;
|
|
1001
|
+
speechModel?: MediaSpeechModel | IMediaModelSpec;
|
|
1002
|
+
transcriptionModel?: MediaTranscriptionModel | IMediaModelSpec;
|
|
1003
|
+
maxCalls?: number;
|
|
1008
1004
|
timeoutMs?: number;
|
|
1009
|
-
|
|
1005
|
+
dir?: string;
|
|
1006
|
+
voice?: string;
|
|
1007
|
+
speechFormat?: string;
|
|
1010
1008
|
}
|
|
1011
|
-
interface
|
|
1012
|
-
|
|
1009
|
+
interface IRunFile {
|
|
1010
|
+
data: string | Uint8Array;
|
|
1011
|
+
mediaType?: string;
|
|
1012
|
+
name?: string;
|
|
1013
1013
|
}
|
|
1014
|
-
interface
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
timeoutMs: number;
|
|
1021
|
-
defaultTools: SubagentDefaultTools;
|
|
1014
|
+
interface IMediaFile {
|
|
1015
|
+
path: string;
|
|
1016
|
+
mediaType: string;
|
|
1017
|
+
bytes: number;
|
|
1018
|
+
references?: IReferenceResult;
|
|
1019
|
+
pictureNote?: string;
|
|
1022
1020
|
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
/**
|
|
1031
|
-
* A spawn that was refused: the model reads the message as the tool's error and can correct the
|
|
1032
|
-
* call or carry on without a helper.
|
|
1033
|
-
*/
|
|
1034
|
-
declare class SubagentSpawnError extends Error {
|
|
1035
|
-
constructor(message: string);
|
|
1036
|
-
toJSON(): string;
|
|
1021
|
+
interface ITranscription {
|
|
1022
|
+
path: string;
|
|
1023
|
+
text: string;
|
|
1024
|
+
language?: string;
|
|
1025
|
+
durationInSeconds?: number;
|
|
1026
|
+
truncated?: true;
|
|
1027
|
+
untrusted: true;
|
|
1037
1028
|
}
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
readonly type: "string";
|
|
1043
|
-
readonly description: "The complete, self-contained sub-task. The helper sees nothing of your context except this text: include every fact, id and constraint it needs, and say what to return.";
|
|
1044
|
-
};
|
|
1045
|
-
readonly role: {
|
|
1046
|
-
readonly type: "string";
|
|
1047
|
-
readonly description: "Optional: who the helper should be for this task and how to work, in a sentence or two (e.g. \"a careful code reviewer; report only real bugs\").";
|
|
1048
|
-
};
|
|
1049
|
-
readonly tools: {
|
|
1050
|
-
readonly type: "array";
|
|
1051
|
-
readonly items: {
|
|
1052
|
-
readonly type: "string";
|
|
1053
|
-
};
|
|
1054
|
-
readonly description: "Optional: the names of YOUR tools the helper may use. Only tools you have can be named. Omit it for the default set; pass [] for a helper that only reasons.";
|
|
1055
|
-
};
|
|
1029
|
+
interface IMedia {
|
|
1030
|
+
tools: ToolSet;
|
|
1031
|
+
pictures?: {
|
|
1032
|
+
setting: boolean | undefined;
|
|
1056
1033
|
};
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
/**
|
|
1061
|
-
* A child's event on its way up through the subagent `parentId` (the `subagent.event` envelope is
|
|
1062
|
-
* added by the caller). A `subagent.start` is emitted with `depth: 1` and the id of the run that
|
|
1063
|
-
* made the call as `parentId`; each subagent it passes through on the way up adds one level, and
|
|
1064
|
-
* the first one - its real parent - puts its own id in `parentId`. So at the top of the stream
|
|
1065
|
-
* every start carries its true depth and parent, whatever mix of static and dynamic subagents,
|
|
1066
|
-
* threads and workers is below.
|
|
1067
|
-
*/
|
|
1068
|
-
declare const adoptSubagentEvent: <E extends {
|
|
1069
|
-
type: string;
|
|
1070
|
-
}>(event: E, parentId: string) => E;
|
|
1034
|
+
attach: (input: string, files: IRunFile[], signal?: AbortSignal) => Promise<string>;
|
|
1035
|
+
}
|
|
1036
|
+
declare const createMedia: (config: IAgentConfig) => Promise<IMedia | undefined>;
|
|
1071
1037
|
|
|
1072
|
-
declare const ASK_USER_TOOL = "ask_user";
|
|
1073
|
-
/** How long one question waits for the person, by default: a human is reading it. */
|
|
1074
|
-
declare const ASK_USER_TIMEOUT_MS = 300000;
|
|
1075
1038
|
/**
|
|
1076
|
-
*
|
|
1077
|
-
*
|
|
1039
|
+
* MCP elicitation, the part the two agent packages share: a server asks the user for input in
|
|
1040
|
+
* the middle of a tool call, the HOST answers through a callback, and the call goes on. Pure, no
|
|
1041
|
+
* imports: the limits, what a request must look like before a host sees it, what an answer must
|
|
1042
|
+
* look like before a server sees it, the one function that asks, and the two ways a tool call
|
|
1043
|
+
* with questions is driven (`elicitation/create` requests on the 2025 revisions, `input_required`
|
|
1044
|
+
* results on 2026-07-28).
|
|
1045
|
+
*
|
|
1046
|
+
* A consent boundary. The server's text is third-party data: cleaned and capped here, shown only
|
|
1047
|
+
* to the host's callback and in the `mcp.elicitation-requested` event, never put into a prompt.
|
|
1048
|
+
* The answer goes to the server that asked and nowhere else: nothing in this file logs, emits or
|
|
1049
|
+
* returns a value the user entered - events and errors carry field NAMES only.
|
|
1050
|
+
*
|
|
1051
|
+
* This file is a COPY, byte for byte, in `@dudko.dev/agent` (`src/mcp-elicitation.ts`) and
|
|
1052
|
+
* `@dudko.dev/agent-web` (`src/mcp/elicitation.ts`): change both. The Node package's
|
|
1053
|
+
* `tests/mcp-elicitation-shared.test.ts` compares the two files and tests every guard here; each
|
|
1054
|
+
* needs a mutation check.
|
|
1078
1055
|
*/
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
declare const ASK_USER_LABEL_MAX_CHARS = 80;
|
|
1090
|
-
/** The longest option description. */
|
|
1091
|
-
declare const ASK_USER_DESCRIPTION_MAX_CHARS = 200;
|
|
1092
|
-
/** The most of a person's own words (`{ other }`) the model is given; the rest is cut. */
|
|
1093
|
-
declare const ASK_USER_OTHER_MAX_CHARS = 2000;
|
|
1094
|
-
/** One option of a question, as the person is shown it. Both strings are the MODEL's, cleaned. */
|
|
1095
|
-
interface AskUserOption {
|
|
1096
|
-
label: string;
|
|
1056
|
+
/** How long one question waits for the host's answer, by default: a human is reading it. */
|
|
1057
|
+
declare const MCP_ELICITATION_TIMEOUT_MS = 300000;
|
|
1058
|
+
/** The most questions one tool call may ask, by default. */
|
|
1059
|
+
declare const MCP_ELICITATION_MAX_PER_TOOL_CALL = 5;
|
|
1060
|
+
/** The most questions one run may be asked, by default (its helpers' calls included). */
|
|
1061
|
+
declare const MCP_ELICITATION_MAX_PER_RUN = 20;
|
|
1062
|
+
/** One field of a form: the flat subset of JSON Schema the specification allows, nothing else. */
|
|
1063
|
+
interface McpElicitationFieldSchema {
|
|
1064
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'array';
|
|
1065
|
+
title?: string;
|
|
1097
1066
|
description?: string;
|
|
1067
|
+
default?: string | number | boolean | string[];
|
|
1068
|
+
/** string */
|
|
1069
|
+
minLength?: number;
|
|
1070
|
+
maxLength?: number;
|
|
1071
|
+
format?: 'email' | 'uri' | 'date' | 'date-time';
|
|
1072
|
+
/** string: single-select, plain (`enumNames`: the older titled form). */
|
|
1073
|
+
enum?: string[];
|
|
1074
|
+
enumNames?: string[];
|
|
1075
|
+
/** string: single-select with titles. */
|
|
1076
|
+
oneOf?: {
|
|
1077
|
+
const: string;
|
|
1078
|
+
title: string;
|
|
1079
|
+
}[];
|
|
1080
|
+
/** number / integer */
|
|
1081
|
+
minimum?: number;
|
|
1082
|
+
maximum?: number;
|
|
1083
|
+
/** array: multi-select. */
|
|
1084
|
+
minItems?: number;
|
|
1085
|
+
maxItems?: number;
|
|
1086
|
+
items?: {
|
|
1087
|
+
type?: 'string';
|
|
1088
|
+
enum?: string[];
|
|
1089
|
+
anyOf?: {
|
|
1090
|
+
const: string;
|
|
1091
|
+
title: string;
|
|
1092
|
+
}[];
|
|
1093
|
+
};
|
|
1098
1094
|
}
|
|
1099
|
-
/**
|
|
1100
|
-
interface
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
multiple: boolean;
|
|
1105
|
-
/** The person may answer in their own words instead of picking. */
|
|
1106
|
-
allowOther: boolean;
|
|
1095
|
+
/** The form a server asks for, as a host is shown it: checked, cleaned and capped. */
|
|
1096
|
+
interface McpElicitationSchema {
|
|
1097
|
+
type: 'object';
|
|
1098
|
+
properties: Record<string, McpElicitationFieldSchema>;
|
|
1099
|
+
required?: string[];
|
|
1107
1100
|
}
|
|
1108
|
-
/** What the host's
|
|
1109
|
-
interface
|
|
1101
|
+
/** What the host's callback is given. Every string in it is third-party text. */
|
|
1102
|
+
interface McpElicitationRequest {
|
|
1110
1103
|
/** Unique per question; the same id is in the two events. */
|
|
1111
1104
|
id: string;
|
|
1112
|
-
/** The
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
/**
|
|
1122
|
-
* The person's answer: the labels they picked (exactly as offered; one unless `multiple`), their
|
|
1123
|
-
* own words (only when `allowOther`), or that they would rather not answer.
|
|
1124
|
-
*/
|
|
1125
|
-
type AskUserAnswer = {
|
|
1126
|
-
choice: string[];
|
|
1127
|
-
} | {
|
|
1128
|
-
other: string;
|
|
1129
|
-
} | {
|
|
1130
|
-
declined: true;
|
|
1131
|
-
};
|
|
1132
|
-
interface AskUserContext {
|
|
1105
|
+
/** The server that asks: its key in the host's configuration. */
|
|
1106
|
+
server: string;
|
|
1107
|
+
/** The tool call during which it asks: the tool's name as the model called it. */
|
|
1108
|
+
tool: string;
|
|
1109
|
+
mode: 'form' | 'url';
|
|
1110
|
+
/** The server's words, cleaned and capped (MCP_ELICITATION_MESSAGE_MAX_CHARS). */
|
|
1111
|
+
message: string;
|
|
1112
|
+
/** Form mode: the fields to fill in. */
|
|
1113
|
+
requestedSchema?: McpElicitationSchema;
|
|
1133
1114
|
/**
|
|
1134
|
-
*
|
|
1135
|
-
*
|
|
1136
|
-
* failed. Take the prompt down then: an answer given later is ignored. Never aborted once the
|
|
1137
|
-
* host has answered.
|
|
1115
|
+
* URL mode: the link the server wants the user to open. It is only handed over: nothing in
|
|
1116
|
+
* these packages fetches or opens it. https, or http on a loopback host.
|
|
1138
1117
|
*/
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
/**
|
|
1144
|
-
type AskUserReason = 'handler-error' | 'invalid-answer' | 'cannot-park';
|
|
1145
|
-
/** The two events of a question. Neither ever carries the person's own words. */
|
|
1146
|
-
type AskUserEvent<TStep = unknown> = {
|
|
1147
|
-
type: 'user.question-asked';
|
|
1148
|
-
id: string;
|
|
1149
|
-
question: string;
|
|
1150
|
-
options: AskUserOption[];
|
|
1151
|
-
multiple: boolean;
|
|
1152
|
-
allowOther: boolean;
|
|
1153
|
-
step?: TStep;
|
|
1118
|
+
url?: string;
|
|
1119
|
+
/** URL mode on the 2025 revisions: the server's id for this interaction. */
|
|
1120
|
+
elicitationId?: string;
|
|
1121
|
+
runId?: string;
|
|
1122
|
+
/** Set when a helper the model started is the one whose call asks (`elicitation.subagents`). */
|
|
1154
1123
|
subagent?: {
|
|
1155
1124
|
id: string;
|
|
1156
1125
|
depth: number;
|
|
1157
1126
|
};
|
|
1158
|
-
} | {
|
|
1159
|
-
type: 'user.question-answered';
|
|
1160
|
-
id: string;
|
|
1161
|
-
action: AskUserAction;
|
|
1162
|
-
/** true when nobody decided: a time limit, a stop, a failed handler, an unusable answer. */
|
|
1163
|
-
automatic: boolean;
|
|
1164
|
-
/** Action 'choice': the labels picked. Never the text of an `other` answer. */
|
|
1165
|
-
choice?: string[];
|
|
1166
|
-
/** Action 'declined' with `automatic`: why. */
|
|
1167
|
-
reason?: AskUserReason;
|
|
1168
|
-
};
|
|
1169
|
-
/** A bad `ask_user` input: the tool call fails with this message, which says what to fix. */
|
|
1170
|
-
declare class AskUserInputError extends Error {
|
|
1171
|
-
constructor(message: string);
|
|
1172
|
-
toJSON(): string;
|
|
1173
1127
|
}
|
|
1174
|
-
|
|
1175
|
-
declare const cleanAskUserText: (raw: unknown, oneLine?: boolean) => string;
|
|
1128
|
+
type McpElicitationContent = Record<string, string | number | boolean | string[]>;
|
|
1176
1129
|
/**
|
|
1177
|
-
*
|
|
1178
|
-
*
|
|
1179
|
-
* all measured after cleaning. An option may be given as a bare string (its label). Throws
|
|
1180
|
-
* {@link AskUserInputError} with what to fix.
|
|
1130
|
+
* The host's answer. `accept` carries the form's values (form mode) or nothing (URL mode: it
|
|
1131
|
+
* says the user agreed to open the link); `decline` is a no; `cancel` is "dismissed".
|
|
1181
1132
|
*/
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
kind: 'choice';
|
|
1186
|
-
choice: string[];
|
|
1133
|
+
type McpElicitationResult = {
|
|
1134
|
+
action: 'accept';
|
|
1135
|
+
content?: McpElicitationContent;
|
|
1187
1136
|
} | {
|
|
1188
|
-
|
|
1189
|
-
text: string;
|
|
1137
|
+
action: 'decline';
|
|
1190
1138
|
} | {
|
|
1191
|
-
|
|
1139
|
+
action: 'cancel';
|
|
1192
1140
|
};
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1141
|
+
interface McpElicitationContext {
|
|
1142
|
+
/** Aborted when the answer is no longer wanted: the run stopped, or the time ran out. */
|
|
1143
|
+
signal: AbortSignal;
|
|
1144
|
+
}
|
|
1145
|
+
/** `onElicitation`: the host decides, never the model. */
|
|
1146
|
+
type McpElicitationHandler = (request: McpElicitationRequest, ctx: McpElicitationContext) => McpElicitationResult | Promise<McpElicitationResult>;
|
|
1147
|
+
/** The `elicitation` settings beside `onElicitation`. */
|
|
1148
|
+
interface McpElicitationOptions {
|
|
1149
|
+
/**
|
|
1150
|
+
* How long one question waits for an answer. Default 300 000. `0` or `Infinity` = no limit of
|
|
1151
|
+
* its own (the question waits until the run is stopped), and so is a value above 2^31 - 1 (about
|
|
1152
|
+
* 24.8 days, the most a timer holds). Negative or NaN: a configuration error.
|
|
1153
|
+
*/
|
|
1154
|
+
timeoutMs?: number;
|
|
1155
|
+
/** Questions one tool call may ask. Default 5. */
|
|
1156
|
+
maxPerToolCall?: number;
|
|
1157
|
+
/** Questions one run may be asked. Default 20. */
|
|
1158
|
+
maxPerRun?: number;
|
|
1159
|
+
/** Also accept URL mode (a link to open). Default false: only forms are declared. */
|
|
1160
|
+
url?: boolean;
|
|
1161
|
+
/**
|
|
1162
|
+
* Let a tool call made by a helper (a subagent) ask the user too. Default false: such a
|
|
1163
|
+
* question is cancelled without the callback being called.
|
|
1164
|
+
*/
|
|
1165
|
+
subagents?: boolean;
|
|
1166
|
+
}
|
|
1167
|
+
/** Why a question was answered without the host deciding. */
|
|
1168
|
+
type McpElicitationReason = 'unsupported-schema' | 'unsupported-mode' | 'insecure-url' | 'invalid-request' | 'subagent' | 'cap-per-call' | 'cap-per-run' | 'handler-error' | 'timeout' | 'invalid-answer' | 'aborted' | 'step-timeout' | 'after-failure' | 'no-tool-call';
|
|
1169
|
+
type Checked<T> = {
|
|
1200
1170
|
ok: true;
|
|
1201
|
-
value:
|
|
1171
|
+
value: T;
|
|
1202
1172
|
} | {
|
|
1203
1173
|
ok: false;
|
|
1204
1174
|
reason: string;
|
|
1205
1175
|
};
|
|
1176
|
+
/**
|
|
1177
|
+
* The form a server asked for, reduced to what the specification allows a form to be: a flat
|
|
1178
|
+
* object of strings, numbers, booleans and selects. Anything else - a nested object, a list of
|
|
1179
|
+
* objects, a type union, an unknown format, too many fields or options, a name that could not
|
|
1180
|
+
* be sent back verbatim - is refused with a reason (the caller declines the request). Keywords
|
|
1181
|
+
* outside the subset are dropped; titles and descriptions are cleaned and capped.
|
|
1182
|
+
*/
|
|
1183
|
+
declare const normalizeMcpElicitationSchema: (raw: unknown) => Checked<McpElicitationSchema>;
|
|
1184
|
+
/**
|
|
1185
|
+
* An accepted form, checked against the schema it answers: every value of the type and within
|
|
1186
|
+
* the limits its field states, every required field there, and NO field the form did not ask
|
|
1187
|
+
* for (what the server did not request is not sent to it). The result is a fresh object holding
|
|
1188
|
+
* only the form's own fields. A refusal names the field and the rule, never the value.
|
|
1189
|
+
*/
|
|
1190
|
+
declare const validateMcpElicitationContent: (schema: McpElicitationSchema, content: unknown) => Checked<McpElicitationContent>;
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
* What the MCP connectors of the two agent packages share: how a server's `instructions` reach a
|
|
1194
|
+
* system prompt, how a tool result's `structuredContent` reaches the model, and what the
|
|
1195
|
+
* per-server `protocol` option means. Pure, no imports.
|
|
1196
|
+
*
|
|
1197
|
+
* This file is a COPY, byte for byte, in `@dudko.dev/agent` (`src/mcp-shared.ts`) and
|
|
1198
|
+
* `@dudko.dev/agent-web` (`src/mcp/shared.ts`): change both. The Node package's
|
|
1199
|
+
* `tests/mcp-shared.test.ts` compares the two files and tests every cap and guard here.
|
|
1200
|
+
*/
|
|
1201
|
+
/** The `instructions` one connected MCP server returned in its `initialize` result. */
|
|
1202
|
+
interface McpServerInstructions {
|
|
1203
|
+
/** The server's name: its key in the host's configuration. */
|
|
1204
|
+
server: string;
|
|
1205
|
+
instructions: string;
|
|
1206
|
+
}
|
|
1207
|
+
/** The most one server's instructions take in a system prompt, in characters. */
|
|
1208
|
+
declare const MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER = 2000;
|
|
1209
|
+
/** The most all servers' instructions take together, in characters. */
|
|
1210
|
+
declare const MCP_INSTRUCTIONS_MAX_CHARS_TOTAL = 8000;
|
|
1211
|
+
/**
|
|
1212
|
+
* The system-prompt section for the servers' instructions, or '' when no server sent any (the
|
|
1213
|
+
* prompt is then exactly what it was). Each server's text is capped
|
|
1214
|
+
* (MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER), so is the sum (MCP_INSTRUCTIONS_MAX_CHARS_TOTAL, in
|
|
1215
|
+
* the order given: a server past the total is named as omitted), and every line of it is
|
|
1216
|
+
* prefixed with "| ", so a server cannot write something that reads as a heading of this prompt
|
|
1217
|
+
* or as another server's note.
|
|
1218
|
+
*/
|
|
1219
|
+
declare const renderMcpInstructions: (list: readonly McpServerInstructions[] | undefined) => string;
|
|
1220
|
+
/**
|
|
1221
|
+
* Which revisions of the protocol a connection to one server may use (the server config's
|
|
1222
|
+
* `protocol`):
|
|
1223
|
+
*
|
|
1224
|
+
* - `'legacy'` (default): the 2025 revisions, the `initialize` handshake. Nothing of the 2026
|
|
1225
|
+
* revision is sent.
|
|
1226
|
+
* - `'auto'`: ask first (`server/discover`); a server that answers with 2026-07-28 is spoken to
|
|
1227
|
+
* that way, any other is given the 2025 handshake. Decided once, at connect.
|
|
1228
|
+
* - `'modern'`: 2026-07-28 only. A server that does not offer it fails the connect.
|
|
1229
|
+
*/
|
|
1230
|
+
type McpProtocolMode = 'legacy' | 'auto' | 'modern';
|
|
1231
|
+
/** The revision `protocol: 'modern'` pins: the one this connector is tested against. */
|
|
1232
|
+
declare const MCP_MODERN_PROTOCOL_VERSION = "2026-07-28";
|
|
1233
|
+
/** What a connection negotiated with one server. */
|
|
1234
|
+
interface McpServerProtocol {
|
|
1235
|
+
/** The server's name: its key in the host's configuration. */
|
|
1236
|
+
server: string;
|
|
1237
|
+
/** The protocol revision in use, e.g. `2025-11-25` or `2026-07-28`. */
|
|
1238
|
+
version: string;
|
|
1239
|
+
/** `modern` from 2026-07-28 on (stateless, `server/discover`), `legacy` before. */
|
|
1240
|
+
era: 'legacy' | 'modern';
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
declare const isModelCallRefused: (err: unknown, seen?: Set<unknown>) => boolean;
|
|
1244
|
+
declare const redactHeaders: (headers: Record<string, string> | undefined) => Record<string, string> | undefined;
|
|
1245
|
+
type IFilledUsage = Required<Omit<IUsage, 'decisionCalls' | keyof IMediaUsage>> & Pick<IUsage, 'decisionCalls'> & Partial<IMediaUsage>;
|
|
1246
|
+
interface ISdkUsageLike {
|
|
1247
|
+
inputTokens?: number;
|
|
1248
|
+
outputTokens?: number;
|
|
1249
|
+
totalTokens?: number;
|
|
1250
|
+
inputTokenDetails?: {
|
|
1251
|
+
cacheReadTokens?: number;
|
|
1252
|
+
cacheWriteTokens?: number;
|
|
1253
|
+
};
|
|
1254
|
+
outputTokenDetails?: {
|
|
1255
|
+
reasoningTokens?: number;
|
|
1256
|
+
};
|
|
1257
|
+
decisionCalls?: number;
|
|
1258
|
+
reasoningTokens?: number;
|
|
1259
|
+
cachedInputTokens?: number;
|
|
1260
|
+
mediaCalls?: number;
|
|
1261
|
+
imagesGenerated?: number;
|
|
1262
|
+
speechCharacters?: number;
|
|
1263
|
+
transcriptionSeconds?: number;
|
|
1264
|
+
}
|
|
1265
|
+
declare const normalizeUsage: (usage: ISdkUsageLike | undefined | null) => IFilledUsage;
|
|
1266
|
+
declare const isAuthError: (err: unknown, seen?: Set<unknown>) => boolean;
|
|
1267
|
+
declare const addUsage: (a: IUsage, b: IUsage) => IFilledUsage;
|
|
1268
|
+
|
|
1269
|
+
type ModelCallStage = AgentStage | 'compaction' | 'route';
|
|
1270
|
+
interface IModelCall {
|
|
1271
|
+
runId?: string;
|
|
1272
|
+
stage: ModelCallStage;
|
|
1273
|
+
provider?: string;
|
|
1274
|
+
modelId: string;
|
|
1275
|
+
estimatedInputTokens?: number;
|
|
1276
|
+
maxOutputTokens?: number;
|
|
1277
|
+
}
|
|
1278
|
+
interface ISharedLimits {
|
|
1279
|
+
beforeModelCall: (call: IModelCall, context: {
|
|
1280
|
+
signal?: AbortSignal;
|
|
1281
|
+
}) => void | Promise<void>;
|
|
1282
|
+
afterModelCall?: (call: IModelCall, usage: IUsage, outcome: {
|
|
1283
|
+
ok: boolean;
|
|
1284
|
+
}) => void | Promise<void>;
|
|
1285
|
+
}
|
|
1286
|
+
declare class ModelCallRefusedError extends Error {
|
|
1287
|
+
readonly call: IModelCall;
|
|
1288
|
+
constructor(call: IModelCall, cause: unknown);
|
|
1289
|
+
toJSON(): string;
|
|
1290
|
+
}
|
|
1206
1291
|
|
|
1207
1292
|
type ProviderType = 'openai' | 'anthropic' | 'openai-compatible' | 'google' | 'xai' | 'azure' | 'amazon-bedrock' | 'google-vertex' | 'deepseek' | 'gateway' | 'cloudflare';
|
|
1208
1293
|
type AgentModel = Exclude<LanguageModel, string>;
|
|
@@ -1786,6 +1871,7 @@ interface IAgentRunResult {
|
|
|
1786
1871
|
usage: IUsage;
|
|
1787
1872
|
compactedHistory?: IConversationTurn[];
|
|
1788
1873
|
undelivered?: string[];
|
|
1874
|
+
actionRecord?: string;
|
|
1789
1875
|
parked?: IParkedRun;
|
|
1790
1876
|
}
|
|
1791
1877
|
interface IRunSnapshot {
|
|
@@ -1927,59 +2013,6 @@ interface IAgent {
|
|
|
1927
2013
|
}
|
|
1928
2014
|
declare const createAgent: (config: IAgentConfig, baseEventHandler?: EventHandler) => Promise<IAgent>;
|
|
1929
2015
|
|
|
1930
|
-
/**
|
|
1931
|
-
* Thrown from inside a tool's execute when the call was not approved. The AI
|
|
1932
|
-
* SDK records it as a failed tool call (`ok: false`), so the replanner sees
|
|
1933
|
-
* it; `toJSON` keeps the message when a trace is serialised.
|
|
1934
|
-
*/
|
|
1935
|
-
declare class ToolDeniedError extends Error {
|
|
1936
|
-
readonly reason?: string;
|
|
1937
|
-
constructor(reason?: string);
|
|
1938
|
-
toJSON(): string;
|
|
1939
|
-
}
|
|
1940
|
-
declare const markReadOnly: <T extends object>(tool: T, readOnly?: boolean) => T;
|
|
1941
|
-
declare const isReadOnlyTool: (tool: unknown) => boolean;
|
|
1942
|
-
declare const markCodeExecution: <T extends object>(tool: T, codeExecution?: boolean) => T;
|
|
1943
|
-
declare const isCodeExecutionTool: (tool: unknown) => boolean;
|
|
1944
|
-
/**
|
|
1945
|
-
* The most specific rule matching `name`: an exact key wins, then the
|
|
1946
|
-
* longest matching '*' glob (ties: the first declared). Pure.
|
|
1947
|
-
*/
|
|
1948
|
-
declare const matchToolRule: (rules: Record<string, ToolPermission> | undefined, name: string) => {
|
|
1949
|
-
pattern: string;
|
|
1950
|
-
permission: ToolPermission;
|
|
1951
|
-
} | undefined;
|
|
1952
|
-
interface IToolDecisionInput {
|
|
1953
|
-
name: string;
|
|
1954
|
-
readOnly: boolean;
|
|
1955
|
-
mode: ToolApprovalMode;
|
|
1956
|
-
rules?: Record<string, ToolPermission>;
|
|
1957
|
-
remembered?: ReadonlySet<string>;
|
|
1958
|
-
builtIn?: boolean;
|
|
1959
|
-
codeExecution?: boolean;
|
|
1960
|
-
mcpSkills?: readonly string[];
|
|
1961
|
-
}
|
|
1962
|
-
interface IToolDecision {
|
|
1963
|
-
permission: ToolPermission;
|
|
1964
|
-
source: 'builtin' | 'remembered' | 'rule' | 'mode' | 'mcp-skill';
|
|
1965
|
-
rule?: string;
|
|
1966
|
-
}
|
|
1967
|
-
/**
|
|
1968
|
-
* Decide one call. Pure. Order: built-in -> remembered "always allow" ->
|
|
1969
|
-
* most specific rule -> mode default (autopilot: allow; read-only: allow if
|
|
1970
|
-
* readOnly else deny; ask-writes: allow if readOnly else ask; ask-all: ask).
|
|
1971
|
-
* Then one rule that only ever tightens: a call that runs code while the run acts on an MCP
|
|
1972
|
-
* server's skill is asked when it would have been allowed - by the mode, a rule or an "always
|
|
1973
|
-
* allow" alike (the Skills extension: no code runs here on a server's skill without a person's
|
|
1974
|
-
* approval). A deny stays a deny.
|
|
1975
|
-
*/
|
|
1976
|
-
declare const decideToolPermission: (input: IToolDecisionInput) => IToolDecision;
|
|
1977
|
-
/** How long a question waits for a decision when `toolApproval.timeoutMs` is not set: 5 minutes. */
|
|
1978
|
-
declare const TOOL_APPROVAL_TIMEOUT_MS = 300000;
|
|
1979
|
-
|
|
1980
|
-
declare const REPLAY_NOTE = "[not run again: this exact call already succeeded in an earlier attempt at this step, and its effect is in place. Its result then:]";
|
|
1981
|
-
declare const isReplayedToolOutput: (output: unknown) => boolean;
|
|
1982
|
-
|
|
1983
2016
|
/** The bounds on what comes from outside the run (a deferred call's note, an answer). */
|
|
1984
2017
|
declare const JOURNAL_LIMITS: Readonly<{
|
|
1985
2018
|
noteChars: 2000;
|
|
@@ -2670,6 +2703,28 @@ declare const truncateToolModelOutput: (output: ToolModelOutput, maxChars: numbe
|
|
|
2670
2703
|
*/
|
|
2671
2704
|
declare const withToolOutputLimit: <T extends Tool>(tool: T, maxChars: number) => T;
|
|
2672
2705
|
|
|
2706
|
+
/** The whole record at most, in characters (UTF-16 code units, as `.length` counts them). */
|
|
2707
|
+
declare const ACTION_RECORD_MAX_CHARS = 300;
|
|
2708
|
+
/**
|
|
2709
|
+
* The one sentence a stage reads with a conversation that carries a record. In the USER prompt,
|
|
2710
|
+
* next to the conversation, and only when a record is in it: a system prompt stays as it was.
|
|
2711
|
+
*/
|
|
2712
|
+
declare const ACTION_RECORD_NOTE = "NOTE: a \"[done: ...]\" line at the end of an assistant message (or of a summary) is the runner's own record of what that turn actually did - the tools it called and how each call ended, the files it wrote or deleted, the media it made and whether reference pictures were used; it outweighs anything an answer said about that turn.";
|
|
2713
|
+
/**
|
|
2714
|
+
* A text kept in the conversation - a model's answer, a summary, the user's message - with every
|
|
2715
|
+
* "[done:" in it made "(done:": only the runner's own record has the mark's shape.
|
|
2716
|
+
*/
|
|
2717
|
+
declare const neutralizeActionRecords: (text: string) => string;
|
|
2718
|
+
/**
|
|
2719
|
+
* What the conversation keeps of an assistant's turn: its answer - with any look-alike made
|
|
2720
|
+
* harmless - and the runner's record on the last line. A turn without an answer (`text` empty:
|
|
2721
|
+
* the run was stopped, or failed) keeps a fixed sentence saying so above its record. Without a
|
|
2722
|
+
* record (no tool ran) it is the answer alone; `record` must be the runner's (`[done: ...]`).
|
|
2723
|
+
*/
|
|
2724
|
+
declare const withActionRecord: (text: string, record?: string, ended?: "stopped" | "failed") => string;
|
|
2725
|
+
/** The record of a run's result, or of the error a run threw (the Node package): or undefined. */
|
|
2726
|
+
declare const actionRecordOf: (value: unknown) => string | undefined;
|
|
2727
|
+
|
|
2673
2728
|
/**
|
|
2674
2729
|
* Validate a skill (name, description, content, files) and return a
|
|
2675
2730
|
* normalised copy. Throws a descriptive error on anything invalid.
|
|
@@ -2797,6 +2852,12 @@ interface IWebFetchOptions {
|
|
|
2797
2852
|
declare const createWebFetchTool: (options?: IWebFetchOptions) => Tool;
|
|
2798
2853
|
declare const createEgressTools: (egress: boolean | IEgressPolicy | undefined) => ToolSet | undefined;
|
|
2799
2854
|
|
|
2855
|
+
interface IFitReferenceWorkerOptions {
|
|
2856
|
+
exportName?: string;
|
|
2857
|
+
resourceLimits?: ResourceLimits;
|
|
2858
|
+
}
|
|
2859
|
+
declare const fitReferenceInWorker: (module: string | URL, options?: IFitReferenceWorkerOptions) => MediaFitReference;
|
|
2860
|
+
|
|
2800
2861
|
interface IResolvedStage {
|
|
2801
2862
|
providerType: ProviderType;
|
|
2802
2863
|
baseURL?: string;
|
|
@@ -2912,5 +2973,5 @@ declare const REMOTE_SUBAGENT_LIMITS: {
|
|
|
2912
2973
|
*/
|
|
2913
2974
|
declare const createSubagentTool: (opts: ISubagentToolOptions) => Tool;
|
|
2914
2975
|
|
|
2915
|
-
export { ASK_USER_DESCRIPTION_MAX_CHARS, ASK_USER_LABEL_MAX_CHARS, ASK_USER_MAX_OPTIONS, ASK_USER_MAX_PER_RUN, ASK_USER_MIN_OPTIONS, ASK_USER_OTHER_MAX_CHARS, ASK_USER_QUESTION_MAX_CHARS, ASK_USER_TIMEOUT_MAX_MS, ASK_USER_TIMEOUT_MS, ASK_USER_TOOL, AskUserInputError, DEFAULT_COMPACTION_THRESHOLD_RATIO, DEFAULT_DECISION_CONFIDENCE_THRESHOLD, DEFAULT_DECISION_TIMEOUT_MS, DirSkillStore, ENTERPRISE_MANAGED_AUTHORIZATION_EXTENSION, EgressError, EnterpriseOAuthError, FORGET_SKILL_TOOL, FileOAuthStore, GENERATE_IMAGE_TOOL, GENERATE_SPEECH_TOOL, JOURNAL_LIMITS, JournalError, MCP_ELICITATION_MAX_PER_RUN, MCP_ELICITATION_MAX_PER_TOOL_CALL, MCP_ELICITATION_TIMEOUT_MS, MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER, MCP_INSTRUCTIONS_MAX_CHARS_TOTAL, MCP_MODERN_PROTOCOL_VERSION, MCP_SKILLS_EXTENSION, MCP_SKILLS_MAX_PER_SERVER, MCP_SKILLS_MAX_TOTAL, MCP_SKILL_BODY_MAX_CHARS, MCP_SKILL_CONSENTS, MCP_SKILL_CONSENT_DEFAULT, MCP_SKILL_DESCRIPTION_MAX_CHARS, MCP_SKILL_DIRECTORY_ENTRIES_MAX, MCP_SKILL_FILE_MAX_CHARS, MCP_SKILL_MAX_RESOURCES, MCP_SKILL_MAX_TOTAL_BYTES, MCP_SKILL_SNAPSHOTS_MAX_BYTES, MCP_SKILL_SNAPSHOT_MAX_DEPTH, MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES, MCP_SKILL_URI_MAX_CHARS, MEDIA_AUDIO_TYPES, MEDIA_DEFAULT_MAX_CALLS, MEDIA_FOLDER, MEDIA_IMAGE_TYPES, MEDIA_MAX_ATTACHED_AUDIO, MEDIA_MAX_AUDIO_INPUT_BYTES, MEDIA_MAX_IMAGE_BYTES, MEDIA_MAX_PROMPT_CHARS, MEDIA_MAX_REFERENCE_BYTES, MEDIA_MAX_REFERENCE_IMAGES, MEDIA_MAX_REFERENCE_SIDE, MEDIA_MAX_REFERENCE_TOTAL_BYTES, MEDIA_MAX_SPEECH_BYTES, MEDIA_MAX_SPEECH_CHARS, MEDIA_MAX_TRANSCRIPT_CHARS, MEDIA_REFERENCE_TYPES, MEDIA_TIMEOUT_MS, MediaBudgetError, MediaError, MemoryOAuthStore, MemorySkillStore, ModelCallRefusedError, NodeEnterpriseOAuthProvider, NodeOAuthProvider, PipelineDefinition, PipelineEvent, PipelineNode, PipelineNodeRunner, PipelineResult, REMOTE_SUBAGENT_LIMITS, REPLAY_NOTE, RUN_JS_TOOL, RUN_LEASE_DEFAULT_TTL_MS, RunLeaseError, SAVE_SKILL_TOOL, SEARCH_API_BASE_URL, SEARCH_DEFAULT_MAX_RESULTS, SEARCH_GOOGLE_DEFAULT_MODEL, SEARCH_GOOGLE_NOTE, SEARCH_MAX_NOTE_CHARS, SEARCH_MAX_QUERY_CHARS, SEARCH_MAX_RESULTS, SEARCH_MAX_SNIPPET_CHARS, SEARCH_MAX_SUMMARY_CHARS, SEARCH_MAX_TITLE_CHARS, SEARCH_MAX_TOTAL_CHARS, SEARCH_MAX_URL_CHARS, SEARCH_PROVIDERS, SPAWN_INPUT_SCHEMA, SPAWN_SUBAGENT_TOOL, SUBAGENT_DEFAULTS, SUBAGENT_MAX_DEPTH_LIMIT, SUMMARY_PREFIX, SandboxUnavailableError, SubagentSpawnError, TOOL_APPROVAL_TIMEOUT_MS, TRANSCRIBE_AUDIO_TOOL, ToolBudgetError, ToolDeniedError, WEB_FETCH_TOOL, WEB_SEARCH_TOOL, acceptMedia, acceptReference, addUsage, adoptSubagentEvent, askDecisionModel, beginMcpOAuth, buildInstructions, buildMediaModelFromStage, buildSearchRequest, checkAskUserAnswer, checkAskUserInput, checkAuthorizationResponseIssuer, checkEgressUrl, checkLimits, checkRedirect, classifyAddress, cleanAskUserText, compactHistory, createAgent, createEgressTools, createEnterpriseOAuthProvider, createLearning, createMedia, createNodeOAuthProvider, createPipeline, createRunControl, createSafeFetch, createSandboxTool, createSandboxTools, createSearchTools, createSubagentTool, createToolResultClearer, createWebFetchTool, createWebSearchTool, decideToolPermission, decisionModelFromAiSdk, deferResult, defineSkill, estimateTokens, findSecret, finishMcpOAuth, getCurrentRunId, getCurrentRunSandbox, hostMatches, htmlToText, imageDimensions, isAuthError, isCodeExecutionTool, isDeferredResult, isModelCallRefused, isReadOnlyTool, isReplayedToolOutput, loadSkillsFromDir, markCodeExecution, markReadOnly, matchToolRule, mcpSkillEntryRefusal, mcpSkillPreamble, mcpSkillUriRefusal, mediaUsageOf, mergeProviderOptions, nodeResolver, normalizeMcpElicitationSchema, normalizeSkillName, normalizeUsage, parseSearchResponse, parseSkillMarkdown, pickPipelineRoute, redactHeaders, renderMcpInstructions, resolveCompaction, resolveDynamicSubagents, resolveEgressPolicy, resolveLimits, resolvePromptCaching, resolveSandboxLimits, resolveThinking, sanitizeSearchResults, searchEgressPolicy, searchEngineAnswer, searchStatusMessage, searchToolResult, searchTools, searchUsageOf, sniffMediaType, truncateToolModelOutput, validateMcpElicitationContent, withRollingBreakpoint, withToolOutputLimit, wrapTranscript };
|
|
2916
|
-
export type { AgentEvent, AgentModel, AgentStage, AskUserAction, AskUserAnswer, AskUserCheckedAnswer, AskUserContext, AskUserDecision, AskUserHandler, AskUserOption, AskUserQuestion, AskUserReason, BudgetKind, DecisionFallbackReason, DecisionPoint, EgressErrorCode, EnterpriseAssertionAlgorithm, EnterpriseAssertionAudience, EnterpriseAssertionType, EnterpriseOAuthHop, EnterpriseOAuthLog, EnterprisePrivateKey, EscalationReason, EventHandler, IAgent, IAgentConfig, IAgentRunOptions, IAgentRunResult, IAgentStageOverride, IAiSdkDecisionOptions, IAskUserConfig, IAskUserRequest, IClearedInfo, ICloseOptions, ICompactHistoryOptions, ICompactHistoryResult, ICompactOptions, ICompactResult, ICompactionConfig, IConversationTurn, IDecisionAnswer, IDecisionCallOptions, IDecisionConfig, IDecisionEvent, IDecisionModel, IDecisionOption, IDecisionOutcome, IDecisionQuestion, IDeferredResult, IDynamicSubagentsConfig, IEgressPolicy, IEnterpriseIdpOptions, IEnterpriseOAuthProviderOptions, IEscalationConfig, IImageSize, IJournalAnswerEntry, IJournalEntry, IJournalModelEntry, IJournalPendingEntry, IJournalToolEntry, ILearning, ILearningConfig, ILimitBreach, ILocalSubagentToolOptions, IMcpHttpServerConfig, IMcpServerConfig, IMcpSkillOrigin, IMcpStdioServerConfig, IMedia, IMediaConfig, IMediaFile, IMediaModelSpec, IMediaUsage, IModelCall, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IParkedRun, IPersistence, IPlan, IPlanStep, IReferenceUse, IRemoteSubagentContext, IRemoteSubagentResult, IRemoteSubagentTask, IRemoteSubagentToolOptions, IResolvedAddress, IResolvedDynamicSubagents, IResolvedThinking, IRunFile, IRunJournal, IRunLease, IRunLeaseOptions, IRunSnapshot, ISandboxConfig, ISandboxError, ISandboxLimits, ISandboxResult, ISanitizedSearch, ISaveSkillInput, ISearchAnswer, ISearchConfig, ISearchEngineAnswer, ISearchOptions, ISearchRequest, ISearchResult, ISearchToolResult, ISearchToolsOptions, ISearchUsage, ISharedLimits, ISkill, ISkillOrigin, ISkillStore, IStepEscalation, IStepResult, IStepStartInfo, ISubagentProfile, ISubagentToolOptions, ISubagentsConfig, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalContext, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, ITranscription, IUsage, IWebSearchOptions, LogLevel, McpElicitationContent, McpElicitationContext, McpElicitationFieldSchema, McpElicitationHandler, McpElicitationOptions, McpElicitationReason, McpElicitationRequest, McpElicitationResult, McpElicitationSchema, McpOAuthRegistration, McpOAuthRegistrationKind, McpProtocolMode, McpServerInstructions, McpServerProtocol, McpSkillConsent, McpSkillConsentView, McpSkillsOptions, McpSkillsSetting, MediaImageModel, MediaKind, MediaModelKind, MediaSpeechModel, MediaTranscriptionModel, ModelCallStage, ModelTier, NodeResolverOptions, ParkAnswer, ParkedItem, Pipeline, PipelineModelConfig, PipelineOptions, PipelineRouteOptions, PipelineRouteResult, PipelineRunOptions, PromptCachingSetting, ProviderType, RemoteSubagentDispatch, ReplanCause, ReplanTrigger, RunControl, RunLeaseLostReason, SafeFetch, SearchEngine, SearchFreshness, SearchProvider, SkillDirectoryListing, StepComplexity, SubagentDefaultTools, SubagentInfo, SubagentIsolation, ThinkingLevel, ThinkingSetting, TierReason, TokenLimitKind, ToolApprovalAnswer, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolResultAnswer, ToolSelectionStrategy, UsagePhase };
|
|
2976
|
+
export { ACTION_RECORD_MAX_CHARS, ACTION_RECORD_NOTE, ASK_USER_DESCRIPTION_MAX_CHARS, ASK_USER_LABEL_MAX_CHARS, ASK_USER_MAX_OPTIONS, ASK_USER_MAX_PER_RUN, ASK_USER_MIN_OPTIONS, ASK_USER_OTHER_MAX_CHARS, ASK_USER_QUESTION_MAX_CHARS, ASK_USER_TIMEOUT_MAX_MS, ASK_USER_TIMEOUT_MS, ASK_USER_TOOL, AskUserInputError, DEFAULT_COMPACTION_THRESHOLD_RATIO, DEFAULT_DECISION_CONFIDENCE_THRESHOLD, DEFAULT_DECISION_TIMEOUT_MS, DirSkillStore, ENTERPRISE_MANAGED_AUTHORIZATION_EXTENSION, EgressError, EnterpriseOAuthError, FORGET_SKILL_TOOL, FileOAuthStore, GENERATE_IMAGE_TOOL, GENERATE_SPEECH_TOOL, JOURNAL_LIMITS, JournalError, MCP_ELICITATION_MAX_PER_RUN, MCP_ELICITATION_MAX_PER_TOOL_CALL, MCP_ELICITATION_TIMEOUT_MS, MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER, MCP_INSTRUCTIONS_MAX_CHARS_TOTAL, MCP_MODERN_PROTOCOL_VERSION, MCP_SKILLS_EXTENSION, MCP_SKILLS_MAX_PER_SERVER, MCP_SKILLS_MAX_TOTAL, MCP_SKILL_BODY_MAX_CHARS, MCP_SKILL_CONSENTS, MCP_SKILL_CONSENT_DEFAULT, MCP_SKILL_DESCRIPTION_MAX_CHARS, MCP_SKILL_DIRECTORY_ENTRIES_MAX, MCP_SKILL_FILE_MAX_CHARS, MCP_SKILL_MAX_RESOURCES, MCP_SKILL_MAX_TOTAL_BYTES, MCP_SKILL_SNAPSHOTS_MAX_BYTES, MCP_SKILL_SNAPSHOT_MAX_DEPTH, MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES, MCP_SKILL_URI_MAX_CHARS, MEDIA_AUDIO_TYPES, MEDIA_DEFAULT_MAX_CALLS, MEDIA_FIT_TIMEOUT_MS, MEDIA_FOLDER, MEDIA_IMAGE_TYPES, MEDIA_MAX_ATTACHED_AUDIO, MEDIA_MAX_AUDIO_INPUT_BYTES, MEDIA_MAX_IMAGE_BYTES, MEDIA_MAX_PROMPT_CHARS, MEDIA_MAX_REFERENCE_BYTES, MEDIA_MAX_REFERENCE_IMAGES, MEDIA_MAX_REFERENCE_SIDE, MEDIA_MAX_REFERENCE_SOURCE_BYTES, MEDIA_MAX_REFERENCE_SOURCE_PIXELS, MEDIA_MAX_REFERENCE_TOTAL_BYTES, MEDIA_MAX_SPEECH_BYTES, MEDIA_MAX_SPEECH_CHARS, MEDIA_MAX_TRANSCRIPT_CHARS, MEDIA_REFERENCE_TYPES, MEDIA_TIMEOUT_MS, MediaBudgetError, MediaError, MemoryOAuthStore, MemorySkillStore, ModelCallRefusedError, NodeEnterpriseOAuthProvider, NodeOAuthProvider, PipelineDefinition, PipelineEvent, PipelineNode, PipelineNodeRunner, PipelineResult, REMOTE_SUBAGENT_LIMITS, REPLAY_NOTE, RUN_JS_TOOL, RUN_LEASE_DEFAULT_TTL_MS, RunLeaseError, SAVE_SKILL_TOOL, SEARCH_API_BASE_URL, SEARCH_DEFAULT_MAX_RESULTS, SEARCH_GOOGLE_DEFAULT_MODEL, SEARCH_GOOGLE_NOTE, SEARCH_MAX_NOTE_CHARS, SEARCH_MAX_QUERY_CHARS, SEARCH_MAX_RESULTS, SEARCH_MAX_SNIPPET_CHARS, SEARCH_MAX_SUMMARY_CHARS, SEARCH_MAX_TITLE_CHARS, SEARCH_MAX_TOTAL_CHARS, SEARCH_MAX_URL_CHARS, SEARCH_PROVIDERS, SPAWN_INPUT_SCHEMA, SPAWN_SUBAGENT_TOOL, SUBAGENT_DEFAULTS, SUBAGENT_MAX_DEPTH_LIMIT, SUMMARY_PREFIX, SandboxUnavailableError, SubagentSpawnError, TOOL_APPROVAL_TIMEOUT_MS, TRANSCRIBE_AUDIO_TOOL, ToolBudgetError, ToolDeniedError, WEB_FETCH_TOOL, WEB_SEARCH_TOOL, acceptMedia, acceptReference, acceptReferenceSource, actionRecordOf, addUsage, adoptSubagentEvent, askDecisionModel, beginMcpOAuth, buildInstructions, buildMediaModelFromStage, buildSearchRequest, checkAskUserAnswer, checkAskUserInput, checkAuthorizationResponseIssuer, checkEgressUrl, checkLimits, checkRedirect, classifyAddress, cleanAskUserText, compactHistory, createAgent, createEgressTools, createEnterpriseOAuthProvider, createLearning, createMedia, createNodeOAuthProvider, createPipeline, createRunControl, createSafeFetch, createSandboxTool, createSandboxTools, createSearchTools, createSubagentTool, createToolResultClearer, createWebFetchTool, createWebSearchTool, decideToolPermission, decisionModelFromAiSdk, deferResult, defineSkill, estimateTokens, findSecret, finishMcpOAuth, fitReferenceInWorker, getCurrentRunId, getCurrentRunSandbox, hostMatches, htmlToText, imageDimensions, isAuthError, isCodeExecutionTool, isDeferredResult, isModelCallRefused, isReadOnlyTool, isReplayedToolOutput, loadSkillsFromDir, markCodeExecution, markReadOnly, matchToolRule, mcpSkillEntryRefusal, mcpSkillPreamble, mcpSkillUriRefusal, mediaUsageOf, mergeProviderOptions, neutralizeActionRecords, nodeResolver, normalizeMcpElicitationSchema, normalizeSkillName, normalizeUsage, parseSearchResponse, parseSkillMarkdown, pickPipelineRoute, redactHeaders, renderMcpInstructions, resolveCompaction, resolveDynamicSubagents, resolveEgressPolicy, resolveLimits, resolvePromptCaching, resolveSandboxLimits, resolveThinking, sanitizeSearchResults, searchEgressPolicy, searchEngineAnswer, searchStatusMessage, searchToolResult, searchTools, searchUsageOf, sniffMediaType, truncateToolModelOutput, validateMcpElicitationContent, withActionRecord, withRollingBreakpoint, withToolOutputLimit, wrapTranscript };
|
|
2977
|
+
export type { AgentEvent, AgentModel, AgentStage, AskUserAction, AskUserAnswer, AskUserCheckedAnswer, AskUserContext, AskUserDecision, AskUserHandler, AskUserOption, AskUserQuestion, AskUserReason, BudgetKind, DecisionFallbackReason, DecisionPoint, EgressErrorCode, EnterpriseAssertionAlgorithm, EnterpriseAssertionAudience, EnterpriseAssertionType, EnterpriseOAuthHop, EnterpriseOAuthLog, EnterprisePrivateKey, EscalationReason, EventHandler, IAgent, IAgentConfig, IAgentRunOptions, IAgentRunResult, IAgentStageOverride, IAiSdkDecisionOptions, IAskUserConfig, IAskUserRequest, IClearedInfo, ICloseOptions, ICompactHistoryOptions, ICompactHistoryResult, ICompactOptions, ICompactResult, ICompactionConfig, IConversationTurn, IDecisionAnswer, IDecisionCallOptions, IDecisionConfig, IDecisionEvent, IDecisionModel, IDecisionOption, IDecisionOutcome, IDecisionQuestion, IDeferredResult, IDynamicSubagentsConfig, IEgressPolicy, IEnterpriseIdpOptions, IEnterpriseOAuthProviderOptions, IEscalationConfig, IFitReferenceOptions, IFitReferenceWorkerOptions, IFittedReference, IImageSize, IJournalAnswerEntry, IJournalEntry, IJournalModelEntry, IJournalPendingEntry, IJournalToolEntry, ILearning, ILearningConfig, ILimitBreach, ILocalSubagentToolOptions, IMcpHttpServerConfig, IMcpServerConfig, IMcpSkillOrigin, IMcpStdioServerConfig, IMedia, IMediaConfig, IMediaFile, IMediaModelSpec, IMediaUsage, IModelCall, INodeOAuthProviderOptions, IOAuthRequestOptions, IOAuthStore, IParkedRun, IPersistence, IPlan, IPlanStep, IReferenceBounds, IReferencePicture, IReferenceUse, IRemoteSubagentContext, IRemoteSubagentResult, IRemoteSubagentTask, IRemoteSubagentToolOptions, IResolvedAddress, IResolvedDynamicSubagents, IResolvedThinking, IRunFile, IRunJournal, IRunLease, IRunLeaseOptions, IRunSnapshot, ISandboxConfig, ISandboxError, ISandboxLimits, ISandboxResult, ISanitizedSearch, ISaveSkillInput, ISearchAnswer, ISearchConfig, ISearchEngineAnswer, ISearchOptions, ISearchRequest, ISearchResult, ISearchToolResult, ISearchToolsOptions, ISearchUsage, ISharedLimits, ISkill, ISkillOrigin, ISkillStore, IStepEscalation, IStepResult, IStepStartInfo, ISubagentProfile, ISubagentToolOptions, ISubagentsConfig, IThinkingConfig, ITokenLimits, IToolApprovalConfig, IToolApprovalContext, IToolApprovalRequest, IToolCatalogEntry, IToolDecision, IToolDecisionInput, IToolResultClearing, ITranscription, IUsage, IWebSearchOptions, LogLevel, McpElicitationContent, McpElicitationContext, McpElicitationFieldSchema, McpElicitationHandler, McpElicitationOptions, McpElicitationReason, McpElicitationRequest, McpElicitationResult, McpElicitationSchema, McpOAuthRegistration, McpOAuthRegistrationKind, McpProtocolMode, McpServerInstructions, McpServerProtocol, McpSkillConsent, McpSkillConsentView, McpSkillsOptions, McpSkillsSetting, MediaFitReference, MediaImageModel, MediaKind, MediaModelKind, MediaSpeechModel, MediaTranscriptionModel, ModelCallStage, ModelTier, NodeResolverOptions, ParkAnswer, ParkedItem, Pipeline, PipelineModelConfig, PipelineOptions, PipelineRouteOptions, PipelineRouteResult, PipelineRunOptions, PromptCachingSetting, ProviderType, RemoteSubagentDispatch, ReplanCause, ReplanTrigger, RunControl, RunLeaseLostReason, SafeFetch, SearchEngine, SearchFreshness, SearchProvider, SkillDirectoryListing, StepComplexity, SubagentDefaultTools, SubagentInfo, SubagentIsolation, ThinkingLevel, ThinkingSetting, TierReason, TokenLimitKind, ToolApprovalAnswer, ToolApprovalDecision, ToolApprovalMode, ToolPermission, ToolResultAnswer, ToolSelectionStrategy, UsagePhase };
|