@anvia/core 1.2.1 → 1.2.2
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/dist/agent/agent-tool.js +8 -8
- package/dist/agent/agent.js +25 -25
- package/dist/agent/index.d.ts +12 -12
- package/dist/agent/index.js +30 -30
- package/dist/agent/interactions/index.d.ts +1 -1
- package/dist/agent/resolve-options.js +12 -12
- package/dist/agent/resolved-agent.js +26 -26
- package/dist/agent/team/agent-team.js +30 -30
- package/dist/agent/team/index.js +30 -30
- package/dist/agent/tool-catalog.js +11 -11
- package/dist/{agent-C9VhENdj.d.ts → agent-CUZdf9G0.d.ts} +9 -9
- package/dist/{chunk-UTAB3XQI.js → chunk-2JZV4LUS.js} +2 -2
- package/dist/{chunk-SIYZDPVH.js → chunk-3EX524LK.js} +36 -27
- package/dist/chunk-3EX524LK.js.map +1 -0
- package/dist/{chunk-UOGM62JL.js → chunk-3P65RSBB.js} +3 -3
- package/dist/{chunk-RT5LUEO3.js → chunk-4PGI5HYY.js} +9 -9
- package/dist/{chunk-BDDC72GF.js → chunk-5HFXHKDD.js} +2 -2
- package/dist/{chunk-QHGYCYV6.js → chunk-5KS4SG2U.js} +4 -4
- package/dist/{chunk-72LBHKYP.js → chunk-5REZFNZ3.js} +2 -2
- package/dist/{chunk-B47EXUHL.js → chunk-5TMN4MYN.js} +2 -2
- package/dist/{chunk-LKIABZNR.js → chunk-63DUKYEG.js} +3 -3
- package/dist/{chunk-MHOJJYDK.js → chunk-647TQE3E.js} +2 -2
- package/dist/{chunk-HP34GRQX.js → chunk-AS7A2LU5.js} +2 -2
- package/dist/{chunk-BDKFFFVX.js → chunk-BD2USPK5.js} +4 -4
- package/dist/{chunk-4S4OECPW.js → chunk-BVAQJOZX.js} +9 -9
- package/dist/{chunk-T4KS577P.js → chunk-FSBDE6RF.js} +7 -6
- package/dist/chunk-FSBDE6RF.js.map +1 -0
- package/dist/{chunk-CKKNO4XB.js → chunk-GSVOMQEE.js} +2 -2
- package/dist/{chunk-TIZGADU4.js → chunk-HAVSSHOW.js} +7 -7
- package/dist/{chunk-TIZGADU4.js.map → chunk-HAVSSHOW.js.map} +1 -1
- package/dist/{chunk-IDNL6IH4.js → chunk-HJ6KTQTZ.js} +7 -1
- package/dist/chunk-HJ6KTQTZ.js.map +1 -0
- package/dist/{chunk-IV6YQTY2.js → chunk-ICDPUAKN.js} +2 -2
- package/dist/{chunk-MNYMLWWA.js → chunk-KSVFGXS6.js} +2 -2
- package/dist/{chunk-F3E2RLC7.js → chunk-KSXA7YK7.js} +3 -3
- package/dist/{chunk-O6DTOCBM.js → chunk-KX2TRKO2.js} +2 -2
- package/dist/{chunk-KZGSXJKU.js → chunk-LMZ54UNC.js} +2 -2
- package/dist/{chunk-Y7JTHNCU.js → chunk-N2AQUFGO.js} +2 -2
- package/dist/{chunk-5FCZ64HM.js → chunk-NA44V5OE.js} +3 -3
- package/dist/{chunk-AOG6KSV4.js → chunk-NSWBPKWH.js} +3 -3
- package/dist/{chunk-J4SINPUA.js → chunk-P6IEZWI3.js} +18 -6
- package/dist/chunk-P6IEZWI3.js.map +1 -0
- package/dist/{chunk-PPJ7SYQL.js → chunk-RGYVR4FE.js} +3 -3
- package/dist/{chunk-47NTHIVB.js → chunk-SCFWN3T2.js} +2 -1
- package/dist/chunk-SCFWN3T2.js.map +1 -0
- package/dist/{chunk-QUS6S2NB.js → chunk-SIXS4CCU.js} +2 -2
- package/dist/{chunk-G336L2IE.js → chunk-VCMBQTR4.js} +2 -2
- package/dist/{chunk-BUPC72Y2.js → chunk-VPTAGK7G.js} +3 -3
- package/dist/{chunk-T4IAJJUU.js → chunk-VQTSZ4ZW.js} +3 -3
- package/dist/{chunk-6N4ENZO4.js → chunk-VU6YTPPH.js} +2 -2
- package/dist/{chunk-XV3DH5GC.js → chunk-WUZG6B3Q.js} +2 -2
- package/dist/{chunk-XJRNBTIV.js → chunk-YNA3UR42.js} +2 -2
- package/dist/completion/generate-completion.js +4 -4
- package/dist/completion/index.d.ts +3 -3
- package/dist/completion/index.js +4 -4
- package/dist/completion/stream-accumulator.js +2 -2
- package/dist/completion/types.js +1 -1
- package/dist/{dynamic-tools-CNHSPXr1.d.ts → dynamic-tools-BXXLc34l.d.ts} +3 -3
- package/dist/embeddings/index.js +1 -1
- package/dist/evals/advanced-metrics.js +7 -7
- package/dist/evals/cli.js +6 -6
- package/dist/evals/index.d.ts +5 -5
- package/dist/evals/index.js +11 -11
- package/dist/evals/judge.js +6 -6
- package/dist/evals/metrics.js +7 -7
- package/dist/evals/runner.js +5 -5
- package/dist/extractor/extractor.js +5 -5
- package/dist/extractor/index.d.ts +1 -1
- package/dist/extractor/index.js +5 -5
- package/dist/guardrails/index.d.ts +4 -4
- package/dist/image-generation/index.d.ts +1 -1
- package/dist/index.d.ts +13 -13
- package/dist/index.js +33 -33
- package/dist/internal/agent-runtime/agent-run.js +21 -21
- package/dist/internal/agent-runtime/continuation-state.js +4 -4
- package/dist/internal/agent-runtime/interaction-suspension.js +4 -4
- package/dist/internal/agent-runtime/memory.js +6 -6
- package/dist/internal/agent-runtime/prepared-tool-call.js +2 -2
- package/dist/internal/agent-runtime/retrieval.js +9 -9
- package/dist/internal/agent-runtime/tool-execution.js +17 -17
- package/dist/internal/agent.d.ts +43 -10
- package/dist/internal/agent.js +26 -26
- package/dist/internal/completion-request.js +2 -2
- package/dist/internal/team-runtime/member.js +5 -5
- package/dist/internal/team-runtime/run.js +29 -29
- package/dist/internal/team-runtime/tools.js +4 -4
- package/dist/mcp/index.d.ts +4 -4
- package/dist/memory/compaction.js +5 -5
- package/dist/memory/index.d.ts +3 -3
- package/dist/memory/index.js +5 -5
- package/dist/{middleware-CWjnMbiH.d.ts → middleware-DORuwSy-.d.ts} +67 -4
- package/dist/observability/group.js +5 -5
- package/dist/observability/index.d.ts +5 -5
- package/dist/observability/index.js +5 -5
- package/dist/pipeline/index.d.ts +10 -10
- package/dist/pipeline/index.js +6 -6
- package/dist/pipeline/pipeline.js +6 -6
- package/dist/{provider-output-error-OQ4fjw5W.d.ts → provider-output-error-CMVoe1xT.d.ts} +1 -1
- package/dist/skills/index.d.ts +4 -4
- package/dist/skills/index.js +14 -14
- package/dist/skills/load.js +14 -14
- package/dist/skills/tools.js +13 -13
- package/dist/speech-generation/index.d.ts +1 -1
- package/dist/speech-generation/index.js +1 -1
- package/dist/{text-GbW4WYMg.d.ts → text-CklbSG7K.d.ts} +1 -1
- package/dist/{think-tool-YWsV98I5.d.ts → think-tool-2unWbq1w.d.ts} +1 -1
- package/dist/tool/create-tool.js +3 -3
- package/dist/tool/dynamic-tools.js +10 -10
- package/dist/tool/index.d.ts +8 -8
- package/dist/tool/index.js +12 -12
- package/dist/tool/question-tool.js +4 -4
- package/dist/tool/think-tool.js +4 -4
- package/dist/tool/tool.js +1 -1
- package/dist/{tool-DQMZpZSS.d.ts → tool-D_jV3cRZ.d.ts} +38 -1
- package/dist/transcription/index.d.ts +1 -1
- package/dist/{types-DfRPfehE.d.ts → types-0t3BczrD.d.ts} +2 -2
- package/dist/{types-CODGMHnp.d.ts → types-ChyQISt-.d.ts} +1 -1
- package/dist/{types-Bqw0AuFl.d.ts → types-CqiX-4_C.d.ts} +1 -1
- package/dist/{types-C1xYKXF2.d.ts → types-Cu2tEf3V.d.ts} +1 -1
- package/dist/{types-CiHjqE6J.d.ts → types-DYqZKDA8.d.ts} +140 -0
- package/dist/{types-CafU6Ux5.d.ts → types-DhWxTobb.d.ts} +37 -1
- package/dist/vector-store/index.d.ts +4 -4
- package/dist/vector-store/index.js +9 -9
- package/dist/vector-store/ingest.js +5 -5
- package/dist/vector-store/retrieve.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-47NTHIVB.js.map +0 -1
- package/dist/chunk-IDNL6IH4.js.map +0 -1
- package/dist/chunk-J4SINPUA.js.map +0 -1
- package/dist/chunk-SIYZDPVH.js.map +0 -1
- package/dist/chunk-T4KS577P.js.map +0 -1
- /package/dist/{chunk-UTAB3XQI.js.map → chunk-2JZV4LUS.js.map} +0 -0
- /package/dist/{chunk-UOGM62JL.js.map → chunk-3P65RSBB.js.map} +0 -0
- /package/dist/{chunk-RT5LUEO3.js.map → chunk-4PGI5HYY.js.map} +0 -0
- /package/dist/{chunk-BDDC72GF.js.map → chunk-5HFXHKDD.js.map} +0 -0
- /package/dist/{chunk-QHGYCYV6.js.map → chunk-5KS4SG2U.js.map} +0 -0
- /package/dist/{chunk-72LBHKYP.js.map → chunk-5REZFNZ3.js.map} +0 -0
- /package/dist/{chunk-B47EXUHL.js.map → chunk-5TMN4MYN.js.map} +0 -0
- /package/dist/{chunk-LKIABZNR.js.map → chunk-63DUKYEG.js.map} +0 -0
- /package/dist/{chunk-MHOJJYDK.js.map → chunk-647TQE3E.js.map} +0 -0
- /package/dist/{chunk-HP34GRQX.js.map → chunk-AS7A2LU5.js.map} +0 -0
- /package/dist/{chunk-BDKFFFVX.js.map → chunk-BD2USPK5.js.map} +0 -0
- /package/dist/{chunk-4S4OECPW.js.map → chunk-BVAQJOZX.js.map} +0 -0
- /package/dist/{chunk-CKKNO4XB.js.map → chunk-GSVOMQEE.js.map} +0 -0
- /package/dist/{chunk-IV6YQTY2.js.map → chunk-ICDPUAKN.js.map} +0 -0
- /package/dist/{chunk-MNYMLWWA.js.map → chunk-KSVFGXS6.js.map} +0 -0
- /package/dist/{chunk-F3E2RLC7.js.map → chunk-KSXA7YK7.js.map} +0 -0
- /package/dist/{chunk-O6DTOCBM.js.map → chunk-KX2TRKO2.js.map} +0 -0
- /package/dist/{chunk-KZGSXJKU.js.map → chunk-LMZ54UNC.js.map} +0 -0
- /package/dist/{chunk-Y7JTHNCU.js.map → chunk-N2AQUFGO.js.map} +0 -0
- /package/dist/{chunk-5FCZ64HM.js.map → chunk-NA44V5OE.js.map} +0 -0
- /package/dist/{chunk-AOG6KSV4.js.map → chunk-NSWBPKWH.js.map} +0 -0
- /package/dist/{chunk-PPJ7SYQL.js.map → chunk-RGYVR4FE.js.map} +0 -0
- /package/dist/{chunk-QUS6S2NB.js.map → chunk-SIXS4CCU.js.map} +0 -0
- /package/dist/{chunk-G336L2IE.js.map → chunk-VCMBQTR4.js.map} +0 -0
- /package/dist/{chunk-BUPC72Y2.js.map → chunk-VPTAGK7G.js.map} +0 -0
- /package/dist/{chunk-T4IAJJUU.js.map → chunk-VQTSZ4ZW.js.map} +0 -0
- /package/dist/{chunk-6N4ENZO4.js.map → chunk-VU6YTPPH.js.map} +0 -0
- /package/dist/{chunk-XV3DH5GC.js.map → chunk-WUZG6B3Q.js.map} +0 -0
- /package/dist/{chunk-XJRNBTIV.js.map → chunk-YNA3UR42.js.map} +0 -0
package/dist/tool/index.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import "../chunk-JMJFK3A4.js";
|
|
2
2
|
import {
|
|
3
3
|
createThinkTool
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-VU6YTPPH.js";
|
|
5
5
|
import {
|
|
6
6
|
createMiddleware
|
|
7
7
|
} from "../chunk-4AW2633B.js";
|
|
8
8
|
import {
|
|
9
9
|
createQuestionTool,
|
|
10
10
|
isQuestionTool
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-ICDPUAKN.js";
|
|
12
12
|
import {
|
|
13
13
|
createToolIndex,
|
|
14
14
|
embedTools,
|
|
15
15
|
isToolIndex
|
|
16
|
-
} from "../chunk-
|
|
17
|
-
import "../chunk-
|
|
16
|
+
} from "../chunk-VCMBQTR4.js";
|
|
17
|
+
import "../chunk-5REZFNZ3.js";
|
|
18
18
|
import "../chunk-ESOFEAYK.js";
|
|
19
19
|
import "../chunk-HAAGSIZH.js";
|
|
20
20
|
import "../chunk-5WLIHNNJ.js";
|
|
21
|
-
import "../chunk-
|
|
21
|
+
import "../chunk-5KS4SG2U.js";
|
|
22
|
+
import "../chunk-KO5NMTAM.js";
|
|
23
|
+
import "../chunk-TFIOU6UR.js";
|
|
24
|
+
import "../chunk-GPVXCY5I.js";
|
|
22
25
|
import "../chunk-ERN7P6Q4.js";
|
|
26
|
+
import "../chunk-DU4WA6LQ.js";
|
|
23
27
|
import "../chunk-7F53DOML.js";
|
|
24
28
|
import "../chunk-HHMLE3TZ.js";
|
|
25
|
-
import "../chunk-DU4WA6LQ.js";
|
|
26
29
|
import "../chunk-4FIVU53H.js";
|
|
27
|
-
import "../chunk-KO5NMTAM.js";
|
|
28
|
-
import "../chunk-TFIOU6UR.js";
|
|
29
|
-
import "../chunk-GPVXCY5I.js";
|
|
30
30
|
import "../chunk-5V533R7F.js";
|
|
31
31
|
import {
|
|
32
32
|
createTool
|
|
33
|
-
} from "../chunk-
|
|
33
|
+
} from "../chunk-WUZG6B3Q.js";
|
|
34
34
|
import "../chunk-YZVFIW5D.js";
|
|
35
|
-
import "../chunk-
|
|
35
|
+
import "../chunk-647TQE3E.js";
|
|
36
36
|
import {
|
|
37
37
|
ToolOutput,
|
|
38
38
|
ToolResultSerializationError,
|
|
39
39
|
normalizeToolResultOutput,
|
|
40
40
|
parseToolArgs,
|
|
41
41
|
toolResultContentToText
|
|
42
|
-
} from "../chunk-
|
|
42
|
+
} from "../chunk-SCFWN3T2.js";
|
|
43
43
|
import {
|
|
44
44
|
ToolCallError,
|
|
45
45
|
ToolJsonError,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createQuestionTool,
|
|
3
3
|
isQuestionTool
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-ICDPUAKN.js";
|
|
5
|
+
import "../chunk-WUZG6B3Q.js";
|
|
6
6
|
import "../chunk-YZVFIW5D.js";
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-647TQE3E.js";
|
|
8
|
+
import "../chunk-SCFWN3T2.js";
|
|
9
9
|
import "../chunk-J6S6MT7O.js";
|
|
10
10
|
import "../chunk-BONQTXRQ.js";
|
|
11
11
|
import "../chunk-4C7AXYOM.js";
|
package/dist/tool/think-tool.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createThinkTool
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-VU6YTPPH.js";
|
|
4
|
+
import "../chunk-WUZG6B3Q.js";
|
|
5
5
|
import "../chunk-YZVFIW5D.js";
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-647TQE3E.js";
|
|
7
|
+
import "../chunk-SCFWN3T2.js";
|
|
8
8
|
import "../chunk-J6S6MT7O.js";
|
|
9
9
|
import "../chunk-BONQTXRQ.js";
|
|
10
10
|
import "../chunk-4C7AXYOM.js";
|
package/dist/tool/tool.js
CHANGED
|
@@ -1,33 +1,53 @@
|
|
|
1
|
-
import { J as JsonObject, B as ToolDefinition, t as JsonValue, H as ToolResultOutput, G as ToolResultContentPart } from './types-
|
|
1
|
+
import { J as JsonObject, B as ToolDefinition, t as JsonValue, H as ToolResultOutput, G as ToolResultContentPart } from './types-DYqZKDA8.js';
|
|
2
2
|
|
|
3
|
+
/** Identifies the agent run that requested a tool approval. */
|
|
3
4
|
type ToolApprovalRunContext = {
|
|
4
5
|
agentId: string;
|
|
5
6
|
runId: string;
|
|
6
7
|
sessionId?: string;
|
|
7
8
|
metadata?: JsonObject;
|
|
8
9
|
};
|
|
10
|
+
/** Details of the pending tool call being evaluated for approval. */
|
|
9
11
|
type ToolApprovalContext<Args = unknown> = {
|
|
10
12
|
toolName: string;
|
|
11
13
|
args: Args;
|
|
14
|
+
/** The serialized argument string passed to hooks and approval checks. */
|
|
12
15
|
rawArgs: string;
|
|
13
16
|
toolCallId: string;
|
|
14
17
|
callId?: string;
|
|
15
18
|
internalCallId: string;
|
|
16
19
|
run: ToolApprovalRunContext;
|
|
17
20
|
};
|
|
21
|
+
/** An approval demand, with an optional human-readable reason. */
|
|
18
22
|
type ToolApprovalRequirement = {
|
|
19
23
|
reason?: string | undefined;
|
|
20
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Whether a tool call needs human approval before execution:
|
|
27
|
+
*
|
|
28
|
+
* - `boolean`: a static requirement
|
|
29
|
+
* - `ToolApprovalRequirement`: a requirement with a reason
|
|
30
|
+
* - a function: evaluated per call, receiving the parsed args and call context
|
|
31
|
+
*/
|
|
21
32
|
type ToolRequiresApproval<Args = unknown> = boolean | ToolApprovalRequirement | ((args: Args, context: ToolApprovalContext<Args>) => boolean | ToolApprovalRequirement | Promise<boolean | ToolApprovalRequirement>);
|
|
33
|
+
/** A child-agent event forwarded through a tool into the parent run's stream. */
|
|
22
34
|
type ToolCallStreamEvent = {
|
|
23
35
|
agentId: string;
|
|
24
36
|
agentName?: string | undefined;
|
|
25
37
|
event: unknown;
|
|
26
38
|
};
|
|
39
|
+
/** Execution context handed to a tool when the run invokes it. */
|
|
27
40
|
type ToolCallContext = {
|
|
41
|
+
/** Emits a child-agent event into the parent run's stream. */
|
|
28
42
|
emitStreamEvent?(event: ToolCallStreamEvent): void | Promise<void>;
|
|
43
|
+
/** Aborted when the run is cancelled or the stream consumer leaves. */
|
|
29
44
|
abortSignal?: AbortSignal | undefined;
|
|
30
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* A model-callable tool. `definition` builds the model-facing JSON description,
|
|
48
|
+
* `call` executes it, and the optional `parseInput` converts raw model-supplied
|
|
49
|
+
* JSON arguments into the typed `Args` before `call` runs.
|
|
50
|
+
*/
|
|
31
51
|
interface Tool<Args = unknown, Output = unknown> {
|
|
32
52
|
readonly name: string;
|
|
33
53
|
readonly requiresApproval?: ToolRequiresApproval<Args>;
|
|
@@ -35,24 +55,41 @@ interface Tool<Args = unknown, Output = unknown> {
|
|
|
35
55
|
call(args: Args, context?: ToolCallContext): Output | Promise<Output>;
|
|
36
56
|
parseInput?(args: JsonValue): Args;
|
|
37
57
|
}
|
|
58
|
+
/** A tool with its argument and output types erased, e.g. as stored in an agent's catalog. */
|
|
38
59
|
type AnyTool = Omit<Tool<unknown, unknown>, "requiresApproval"> & {
|
|
39
60
|
readonly requiresApproval?: unknown;
|
|
40
61
|
};
|
|
41
62
|
declare const richToolOutput: unique symbol;
|
|
63
|
+
/**
|
|
64
|
+
* A tool result carrying mixed content parts (text, files), created with
|
|
65
|
+
* {@link ToolOutput.content}. The brand symbol keeps plain objects from
|
|
66
|
+
* impersonating rich outputs.
|
|
67
|
+
*/
|
|
42
68
|
type RichToolOutput = Readonly<{
|
|
43
69
|
[richToolOutput]: true;
|
|
44
70
|
content: readonly ToolResultContentPart[];
|
|
45
71
|
}>;
|
|
72
|
+
/** Normalized tool result as stored in tool messages. */
|
|
46
73
|
type NormalizedToolOutput = ToolResultOutput;
|
|
74
|
+
/** Thrown when a tool returns a value that cannot be represented as a tool result. */
|
|
47
75
|
declare class ToolResultSerializationError extends TypeError {
|
|
48
76
|
readonly output: unknown;
|
|
49
77
|
constructor(output: unknown);
|
|
50
78
|
}
|
|
79
|
+
/** Helpers for building tool results. */
|
|
51
80
|
declare const ToolOutput: {
|
|
81
|
+
/** Wraps content parts so a tool can return text and files together. */
|
|
52
82
|
content(content: readonly ToolResultContentPart[]): RichToolOutput;
|
|
53
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* Coerces a tool's return value into a normalized result: strings become text,
|
|
86
|
+
* rich outputs are validated, and strict JSON values become JSON results.
|
|
87
|
+
* Anything else throws {@link ToolResultSerializationError}.
|
|
88
|
+
*/
|
|
54
89
|
declare function normalizeToolResultOutput(output: unknown): NormalizedToolOutput;
|
|
90
|
+
/** Renders tool result content as text; file parts become `[file:<mediaType>]` placeholders. */
|
|
55
91
|
declare function toolResultContentToText(content: readonly ToolResultContentPart[]): string;
|
|
92
|
+
/** Parses and JSON-validates the raw argument string supplied by the model. */
|
|
56
93
|
declare function parseToolArgs(args: string): JsonValue;
|
|
57
94
|
|
|
58
95
|
export { type AnyTool as A, type NormalizedToolOutput as N, type RichToolOutput as R, type Tool as T, type ToolApprovalContext as a, type ToolApprovalRequirement as b, type ToolCallContext as c, type ToolCallStreamEvent as d, type ToolRequiresApproval as e, type ToolApprovalRunContext as f, ToolOutput as g, ToolResultSerializationError as h, normalizeToolResultOutput as n, parseToolArgs as p, toolResultContentToText as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { M as ModelCallOptions } from '../model-call-options-CZkSw_xN.js';
|
|
2
2
|
import { b as RetrySetting } from '../retry-CjvSlKGW.js';
|
|
3
3
|
export { R as RetryContext, a as RetryOptions } from '../retry-CjvSlKGW.js';
|
|
4
|
-
import { J as JsonObject } from '../types-
|
|
4
|
+
import { J as JsonObject } from '../types-DYqZKDA8.js';
|
|
5
5
|
|
|
6
6
|
type TranscriptionRequest = {
|
|
7
7
|
data: Uint8Array;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { J as JsonObject } from './types-
|
|
2
|
-
import { A as AnyTool } from './tool-
|
|
1
|
+
import { J as JsonObject } from './types-DYqZKDA8.js';
|
|
2
|
+
import { A as AnyTool } from './tool-D_jV3cRZ.js';
|
|
3
3
|
|
|
4
4
|
type McpServerInfo = {
|
|
5
5
|
readonly name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { b as RetrySetting } from './retry-CjvSlKGW.js';
|
|
2
|
-
import { J as JsonObject } from './types-
|
|
2
|
+
import { J as JsonObject } from './types-DYqZKDA8.js';
|
|
3
3
|
import { b as VectorMetadataValue, V as VectorMetadata, a as EmbeddedDocument, S as SparseVector, E as EmbeddingModel, c as SparseEmbeddingModel } from './types-Cr4uiYo5.js';
|
|
4
4
|
|
|
5
5
|
type VectorFilter = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as Message, J as JsonObject, U as Usage } from './types-
|
|
1
|
+
import { M as Message, J as JsonObject, U as Usage } from './types-DYqZKDA8.js';
|
|
2
2
|
|
|
3
3
|
type MaybePromise<T> = T | Promise<T>;
|
|
4
4
|
type DeepReadonly<T> = T extends (...args: never[]) => unknown ? T : T extends readonly (infer Item)[] ? readonly DeepReadonly<Item>[] : T extends object ? {
|
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
import { M as ModelCallOptions } from './model-call-options-CZkSw_xN.js';
|
|
2
2
|
|
|
3
3
|
type JsonPrimitive = string | number | boolean | null;
|
|
4
|
+
/** Any JSON-compatible value: primitives, objects, or readonly arrays of JSON values. */
|
|
4
5
|
type JsonValue = JsonPrimitive | JsonObject | readonly JsonValue[];
|
|
5
6
|
type JsonObject = {
|
|
6
7
|
[key: string]: JsonValue;
|
|
7
8
|
};
|
|
9
|
+
/** A retrievable text document passed to a completion as grounding context. */
|
|
8
10
|
type Document = {
|
|
9
11
|
id: string;
|
|
10
12
|
text: string;
|
|
13
|
+
/** String metadata rendered as a `<metadata ... />` header above the text when documents are serialized into prompts. */
|
|
11
14
|
additionalProps?: Record<string, string>;
|
|
12
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* A text segment, optionally carrying a provider reasoning signature.
|
|
18
|
+
*/
|
|
13
19
|
type TextPart = Readonly<{
|
|
14
20
|
type: "text";
|
|
15
21
|
text: string;
|
|
22
|
+
/** Provider signature preserved so reasoning can be replayed on later turns. */
|
|
16
23
|
signature?: string;
|
|
17
24
|
}>;
|
|
25
|
+
/** Image input fidelity hint forwarded to providers that support it. */
|
|
18
26
|
type ImageDetail = "auto" | "low" | "high";
|
|
27
|
+
/**
|
|
28
|
+
* File payload for image/file parts: a remote URL, base64 data, or literal text
|
|
29
|
+
* interpreted as a document.
|
|
30
|
+
*/
|
|
19
31
|
type FileData = Readonly<{
|
|
20
32
|
type: "url";
|
|
21
33
|
url: string;
|
|
@@ -26,6 +38,7 @@ type FileData = Readonly<{
|
|
|
26
38
|
type: "text";
|
|
27
39
|
text: string;
|
|
28
40
|
}>;
|
|
41
|
+
/** Image input with an optional media type override and detail hint. */
|
|
29
42
|
type ImagePart = Readonly<{
|
|
30
43
|
type: "image";
|
|
31
44
|
image: Exclude<FileData, Readonly<{
|
|
@@ -35,18 +48,27 @@ type ImagePart = Readonly<{
|
|
|
35
48
|
mediaType?: string;
|
|
36
49
|
detail?: ImageDetail;
|
|
37
50
|
}>;
|
|
51
|
+
/** Document/file input part; non-text data is rejected by models without `documentInput`. */
|
|
38
52
|
type FilePart = Readonly<{
|
|
39
53
|
type: "file";
|
|
40
54
|
data: FileData;
|
|
41
55
|
mediaType: string;
|
|
42
56
|
filename?: string;
|
|
43
57
|
}>;
|
|
58
|
+
/** Model reasoning content, replayable across turns to preserve thinking state. */
|
|
44
59
|
type ReasoningPart = Readonly<{
|
|
45
60
|
type: "reasoning";
|
|
46
61
|
text: string;
|
|
47
62
|
id?: string;
|
|
48
63
|
details?: readonly ReasoningDetail[];
|
|
49
64
|
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Reasoning detail variants:
|
|
67
|
+
*
|
|
68
|
+
* - `text` / `summary`: displayable reasoning text
|
|
69
|
+
* - `encrypted` / `redacted`: opaque payloads that can only be echoed back to
|
|
70
|
+
* the provider; their content is not readable by the application
|
|
71
|
+
*/
|
|
50
72
|
type ReasoningDetail = Readonly<{
|
|
51
73
|
type: "text";
|
|
52
74
|
text: string;
|
|
@@ -62,6 +84,7 @@ type ReasoningDetail = Readonly<{
|
|
|
62
84
|
data: string;
|
|
63
85
|
}>;
|
|
64
86
|
type ReasoningContentType = ReasoningDetail["type"];
|
|
87
|
+
/** A tool call requested by the model; `signature` preserves provider replay state. */
|
|
65
88
|
type ToolCallPart = Readonly<{
|
|
66
89
|
type: "tool-call";
|
|
67
90
|
toolCallId: string;
|
|
@@ -70,7 +93,17 @@ type ToolCallPart = Readonly<{
|
|
|
70
93
|
input: JsonValue;
|
|
71
94
|
signature?: string;
|
|
72
95
|
}>;
|
|
96
|
+
/** The content variants allowed inside a tool result payload. */
|
|
73
97
|
type ToolResultContentPart = TextPart | FilePart;
|
|
98
|
+
/**
|
|
99
|
+
* Outcome of one tool execution, as recorded in tool messages:
|
|
100
|
+
*
|
|
101
|
+
* - `text` / `json`: successful result as plain text or JSON
|
|
102
|
+
* - `content`: successful result as mixed content parts
|
|
103
|
+
* - `execution-denied`: the call was blocked (e.g. by a required approval)
|
|
104
|
+
* - `error-text` / `error-json`: failure surfaced to the model so the run can
|
|
105
|
+
* continue instead of aborting
|
|
106
|
+
*/
|
|
74
107
|
type ToolResultOutput = Readonly<{
|
|
75
108
|
type: "text";
|
|
76
109
|
value: string;
|
|
@@ -90,6 +123,7 @@ type ToolResultOutput = Readonly<{
|
|
|
90
123
|
type: "error-json";
|
|
91
124
|
value: JsonValue;
|
|
92
125
|
}>;
|
|
126
|
+
/** Tool result reported back to the model, matched to its call via `toolCallId`. */
|
|
93
127
|
type ToolResultPart = Readonly<{
|
|
94
128
|
type: "tool-result";
|
|
95
129
|
toolCallId: string;
|
|
@@ -97,6 +131,7 @@ type ToolResultPart = Readonly<{
|
|
|
97
131
|
toolName: string;
|
|
98
132
|
output: ToolResultOutput;
|
|
99
133
|
}>;
|
|
134
|
+
/** Human decision on a tool call that required approval before execution. */
|
|
100
135
|
type ToolApprovalResponsePart = Readonly<{
|
|
101
136
|
type: "tool-approval-response";
|
|
102
137
|
interactionId: string;
|
|
@@ -106,10 +141,12 @@ type ToolApprovalResponsePart = Readonly<{
|
|
|
106
141
|
approved: boolean;
|
|
107
142
|
reason?: string;
|
|
108
143
|
}>;
|
|
144
|
+
/** Answer to one question asked by a tool suspended on a human interaction. */
|
|
109
145
|
type ToolQuestionAnswer = Readonly<{
|
|
110
146
|
questionId: string;
|
|
111
147
|
value: string;
|
|
112
148
|
}>;
|
|
149
|
+
/** Answers to tool questions, delivered back through the suspended run. */
|
|
113
150
|
type ToolQuestionResponsePart = Readonly<{
|
|
114
151
|
type: "tool-question-response";
|
|
115
152
|
interactionId: string;
|
|
@@ -118,8 +155,11 @@ type ToolQuestionResponsePart = Readonly<{
|
|
|
118
155
|
toolName: string;
|
|
119
156
|
answers: readonly ToolQuestionAnswer[];
|
|
120
157
|
}>;
|
|
158
|
+
/** A tool or human-interaction response delivered inside a `role: "tool"` message. */
|
|
121
159
|
type ToolInteractionResponsePart = ToolApprovalResponsePart | ToolQuestionResponsePart;
|
|
160
|
+
/** Content parts allowed in user messages. */
|
|
122
161
|
type UserContentPart = TextPart | ImagePart | FilePart;
|
|
162
|
+
/** Content parts allowed in assistant messages, including replayed reasoning and tool calls. */
|
|
123
163
|
type AssistantContentPart = TextPart | ImagePart | FilePart | ReasoningPart | ToolCallPart;
|
|
124
164
|
type SystemMessage<Metadata extends JsonObject = JsonObject> = Readonly<{
|
|
125
165
|
role: "system";
|
|
@@ -142,12 +182,25 @@ type ToolMessage<Metadata extends JsonObject = JsonObject> = Readonly<{
|
|
|
142
182
|
content: readonly (ToolResultPart | ToolInteractionResponsePart)[];
|
|
143
183
|
metadata?: Metadata;
|
|
144
184
|
}>;
|
|
185
|
+
/**
|
|
186
|
+
* A conversation message from the system, user, assistant, or tool role.
|
|
187
|
+
*
|
|
188
|
+
* Framework-generated metadata (provider, model, usage of the generation that
|
|
189
|
+
* produced an assistant message) is stored under the `anvia` key of `metadata`;
|
|
190
|
+
* read it back with {@link getAssistantGenerationMetadata}.
|
|
191
|
+
*/
|
|
145
192
|
type Message<Metadata extends JsonObject = JsonObject> = SystemMessage<Metadata> | UserMessage<Metadata> | AssistantMessage<Metadata> | ToolMessage<Metadata>;
|
|
193
|
+
/** Joins the human-readable text of a reasoning part or its details. */
|
|
146
194
|
declare function reasoningDisplayText(reasoning: ReasoningPart | readonly ReasoningDetail[]): string;
|
|
195
|
+
/**
|
|
196
|
+
* How the model may call tools: freely, mandatorily, never, or a named function.
|
|
197
|
+
* Requires the model's `toolChoice` capability.
|
|
198
|
+
*/
|
|
147
199
|
type ToolChoice = "auto" | "required" | "none" | {
|
|
148
200
|
type: "function";
|
|
149
201
|
name: string;
|
|
150
202
|
};
|
|
203
|
+
/** JSON Schema-shaped tool description sent to the model (a local tool's public face). */
|
|
151
204
|
type ToolDefinition = {
|
|
152
205
|
name: string;
|
|
153
206
|
description: string;
|
|
@@ -166,7 +219,9 @@ type ProviderTool = {
|
|
|
166
219
|
configuration?: JsonObject;
|
|
167
220
|
};
|
|
168
221
|
type CompletionTool = ToolDefinition | ProviderTool;
|
|
222
|
+
/** Narrows an unknown value to a well-formed {@link ProviderTool}. */
|
|
169
223
|
declare function isProviderTool(value: unknown): value is ProviderTool;
|
|
224
|
+
/** A grounding source (e.g. web result) returned by the provider, with optional text offsets. */
|
|
170
225
|
type CompletionSource = {
|
|
171
226
|
type: "url";
|
|
172
227
|
url: string;
|
|
@@ -175,6 +230,7 @@ type CompletionSource = {
|
|
|
175
230
|
startIndex?: number;
|
|
176
231
|
endIndex?: number;
|
|
177
232
|
};
|
|
233
|
+
/** A tool call executed on the provider side, surfaced for observability. */
|
|
178
234
|
type ProviderToolCall = {
|
|
179
235
|
id: string;
|
|
180
236
|
name: string;
|
|
@@ -188,15 +244,18 @@ type ProviderToolCall = {
|
|
|
188
244
|
* only aggregate key and should equal the sum of the other buckets.
|
|
189
245
|
*/
|
|
190
246
|
type UsageDetails = Record<string, number>;
|
|
247
|
+
/** Model context window bounds; unset input/output caps fall back to the window. */
|
|
191
248
|
type ModelContextLimits = {
|
|
192
249
|
contextWindow: number;
|
|
193
250
|
maxInputTokens?: number;
|
|
194
251
|
maxOutputTokens?: number;
|
|
195
252
|
};
|
|
253
|
+
/** Identifies a model together with its context limits. */
|
|
196
254
|
type CompletionModelInfo = {
|
|
197
255
|
modelId: string;
|
|
198
256
|
context: ModelContextLimits;
|
|
199
257
|
};
|
|
258
|
+
/** Snapshot of how much of a model's context window a request consumed. */
|
|
200
259
|
type ContextUsage = {
|
|
201
260
|
model: CompletionModelInfo;
|
|
202
261
|
usedTokens: number;
|
|
@@ -204,9 +263,13 @@ type ContextUsage = {
|
|
|
204
263
|
usedPercent: number;
|
|
205
264
|
remainingPercent: number;
|
|
206
265
|
};
|
|
266
|
+
/** Computes context usage, or undefined when the model or usage data is unusable. */
|
|
207
267
|
declare function calculateContextUsage(usage: Usage, model: CompletionModelInfo | undefined): ContextUsage | undefined;
|
|
268
|
+
/** Attaches context usage to a response when model limits are known. */
|
|
208
269
|
declare function withContextUsage<RawResponse>(response: CompletionResponse<RawResponse>, model: CompletionModelInfo | undefined): CompletionResponse<RawResponse>;
|
|
270
|
+
/** Resolves a model's context limits: explicit override wins over catalog lookup. */
|
|
209
271
|
declare function resolveModelContextLimits(modelId: string, catalog: Readonly<Record<string, ModelContextLimits>>, override?: ModelContextLimits): ModelContextLimits | undefined;
|
|
272
|
+
/** Provider/model/usage metadata embedded in assistant message metadata by the runtime. */
|
|
210
273
|
type AssistantGenerationMetadata = {
|
|
211
274
|
provider: string;
|
|
212
275
|
modelId: string;
|
|
@@ -217,6 +280,13 @@ type AssistantGenerationMetadata = {
|
|
|
217
280
|
sources?: CompletionSource[];
|
|
218
281
|
providerToolCalls?: ProviderToolCall[];
|
|
219
282
|
};
|
|
283
|
+
/**
|
|
284
|
+
* Token usage for one or more generations.
|
|
285
|
+
*
|
|
286
|
+
* `cachedInputTokens` counts input tokens served from the provider's prompt
|
|
287
|
+
* cache; `cacheCreationInputTokens` counts input tokens billed for writing to
|
|
288
|
+
* that cache. Both are subsets of `inputTokens`.
|
|
289
|
+
*/
|
|
220
290
|
type Usage = {
|
|
221
291
|
inputTokens: number;
|
|
222
292
|
outputTokens: number;
|
|
@@ -225,12 +295,26 @@ type Usage = {
|
|
|
225
295
|
cacheCreationInputTokens: number;
|
|
226
296
|
details?: UsageDetails;
|
|
227
297
|
};
|
|
298
|
+
/**
|
|
299
|
+
* Helpers for constructing and combining token usage.
|
|
300
|
+
*/
|
|
228
301
|
declare const Usage: {
|
|
302
|
+
/** Returns an all-zero usage value. */
|
|
229
303
|
empty(): Usage;
|
|
304
|
+
/**
|
|
305
|
+
* Sums two usage values bucket by bucket. `details` are merged only when
|
|
306
|
+
* both sides carry them; if either side omits them, the result omits them.
|
|
307
|
+
*/
|
|
230
308
|
add(left: Usage, right: Usage): Usage;
|
|
309
|
+
/** Returns true when every bucket, including `details`, is zero. */
|
|
231
310
|
isEmpty(usage: Usage): boolean;
|
|
232
311
|
};
|
|
312
|
+
/**
|
|
313
|
+
* Reads the generation metadata the runtime embeds in assistant messages, when
|
|
314
|
+
* present and structurally valid.
|
|
315
|
+
*/
|
|
233
316
|
declare function getAssistantGenerationMetadata(message: Message): AssistantGenerationMetadata | undefined;
|
|
317
|
+
/** Provider-agnostic completion request assembled by the runtime for adapters. */
|
|
234
318
|
type CompletionRequest = {
|
|
235
319
|
instructions?: string;
|
|
236
320
|
chatHistory: Message[];
|
|
@@ -240,25 +324,45 @@ type CompletionRequest = {
|
|
|
240
324
|
temperature?: number;
|
|
241
325
|
maxTokens?: number;
|
|
242
326
|
toolChoice?: ToolChoice;
|
|
327
|
+
/** Values for the model's declared completion controls; validated before sending. */
|
|
243
328
|
controls?: Readonly<Record<string, string>>;
|
|
329
|
+
/** Provider-specific passthrough options; never validated by the core runtime. */
|
|
244
330
|
providerOptions?: JsonObject;
|
|
331
|
+
/** JSON Schema the output must conform to; requires the `outputSchema` capability. */
|
|
245
332
|
outputSchema?: JsonObject;
|
|
246
333
|
};
|
|
334
|
+
/** Normalized finish reasons:
|
|
335
|
+
*
|
|
336
|
+
* - `stop`: the model finished naturally
|
|
337
|
+
* - `length`: an output token limit was hit
|
|
338
|
+
* - `content-filter`: output was blocked by a safety filter
|
|
339
|
+
* - `tool-calls`: the model stopped to request tool calls
|
|
340
|
+
* - `other`: any provider-specific reason
|
|
341
|
+
*/
|
|
247
342
|
type CompletionFinishReason = "stop" | "length" | "content-filter" | "tool-calls" | "other";
|
|
343
|
+
/** A provider's raw completion response: normalized parts plus usage and metadata. */
|
|
248
344
|
type CompletionResponse<RawResponse = unknown> = {
|
|
249
345
|
choice: AssistantContentPart[];
|
|
250
346
|
usage: Usage;
|
|
251
347
|
finishReason?: CompletionFinishReason;
|
|
252
348
|
providerFinishReason?: string;
|
|
253
349
|
contextUsage?: ContextUsage;
|
|
350
|
+
/** The provider SDK's original response object, unmodified. */
|
|
254
351
|
rawResponse: RawResponse;
|
|
255
352
|
messageId?: string;
|
|
256
353
|
sources?: CompletionSource[];
|
|
257
354
|
providerToolCalls?: ProviderToolCall[];
|
|
258
355
|
};
|
|
356
|
+
/** Final result of a completion: typed output, plain text, full content, and usage. */
|
|
259
357
|
type CompletionResult<Output = string, RawResponse = unknown> = {
|
|
358
|
+
/**
|
|
359
|
+
* The typed output. When an output schema was requested this is the parsed,
|
|
360
|
+
* validated object; otherwise it is the plain text.
|
|
361
|
+
*/
|
|
260
362
|
output: Output;
|
|
363
|
+
/** The generated text, joined from the response's text parts. */
|
|
261
364
|
text: string;
|
|
365
|
+
/** Every content part the model produced, including reasoning and tool calls. */
|
|
262
366
|
content: readonly AssistantContentPart[];
|
|
263
367
|
usage: Usage;
|
|
264
368
|
finishReason?: CompletionFinishReason;
|
|
@@ -269,6 +373,7 @@ type CompletionResult<Output = string, RawResponse = unknown> = {
|
|
|
269
373
|
sources?: readonly CompletionSource[];
|
|
270
374
|
providerToolCalls?: readonly ProviderToolCall[];
|
|
271
375
|
};
|
|
376
|
+
/** Feature flags a model declares; requests are validated against these at runtime. */
|
|
272
377
|
type CompletionModelCapabilities = {
|
|
273
378
|
streaming: boolean;
|
|
274
379
|
tools: boolean;
|
|
@@ -279,6 +384,7 @@ type CompletionModelCapabilities = {
|
|
|
279
384
|
reasoning: boolean;
|
|
280
385
|
providerTools?: boolean;
|
|
281
386
|
};
|
|
387
|
+
/** A selectable model control exposed to applications (e.g. "reasoning effort"). */
|
|
282
388
|
type CompletionModelSelectControl<Option extends string = string> = Readonly<{
|
|
283
389
|
type: "select";
|
|
284
390
|
label: string;
|
|
@@ -286,24 +392,50 @@ type CompletionModelSelectControl<Option extends string = string> = Readonly<{
|
|
|
286
392
|
description?: string | undefined;
|
|
287
393
|
defaultValue?: Option | undefined;
|
|
288
394
|
}>;
|
|
395
|
+
/** Named set of controls a model supports, keyed by control id. */
|
|
289
396
|
type CompletionModelControls = Readonly<Record<string, CompletionModelSelectControl<string>>>;
|
|
397
|
+
/** Marker type for models that accept no completion controls. */
|
|
290
398
|
type NoCompletionModelControls = Readonly<Record<string, never>>;
|
|
399
|
+
/** The option values a model's controls accept, keyed by control id. */
|
|
291
400
|
type CompletionControlValues<Controls extends CompletionModelControls> = Readonly<Partial<{
|
|
292
401
|
[Key in keyof Controls]: Controls[Key] extends CompletionModelSelectControl<infer Option> ? Option : never;
|
|
293
402
|
}>>;
|
|
403
|
+
/** Extracts a model's control types, defaulting to the open controls record. */
|
|
294
404
|
type CompletionModelControlsOf<Model> = Model extends CompletionModel<unknown, infer Controls> ? Controls : CompletionModelControls;
|
|
405
|
+
/**
|
|
406
|
+
* The provider-agnostic model contract every adapter implements: non-streaming
|
|
407
|
+
* completions plus capability, context, and control metadata.
|
|
408
|
+
*/
|
|
295
409
|
interface CompletionModel<RawResponse = unknown, Controls extends CompletionModelControls = CompletionModelControls> {
|
|
296
410
|
readonly provider: string;
|
|
297
411
|
readonly modelId: string;
|
|
298
412
|
readonly contextLimits?: ModelContextLimits | undefined;
|
|
299
413
|
readonly capabilities: CompletionModelCapabilities;
|
|
300
414
|
readonly controls?: Controls | undefined;
|
|
415
|
+
/**
|
|
416
|
+
* Returns a JSON-safe representation of the outgoing request for
|
|
417
|
+
* observability traces, or undefined to omit the trace payload. Errors
|
|
418
|
+
* thrown here are swallowed by the runtime and recorded as a trace error.
|
|
419
|
+
*/
|
|
301
420
|
traceRequest?(request: CompletionRequest, options?: {
|
|
302
421
|
stream?: boolean | undefined;
|
|
303
422
|
}): JsonObject | undefined;
|
|
304
423
|
completion(request: CompletionRequest, options?: ModelCallOptions): Promise<CompletionResponse<RawResponse>>;
|
|
305
424
|
}
|
|
425
|
+
/** How a `tool_call_delta` updates arguments: append to, or replace, accumulated JSON. */
|
|
306
426
|
type ToolCallArgumentsMode = "append" | "replace";
|
|
427
|
+
/**
|
|
428
|
+
* Incremental completion stream content:
|
|
429
|
+
*
|
|
430
|
+
* - `text_delta` / `reasoning_delta`: incremental text or reasoning content
|
|
431
|
+
* - `tool_call_delta`: partial tool call input; argument fragments accumulate
|
|
432
|
+
* according to `argumentsMode` (`append` continues the JSON string, `replace`
|
|
433
|
+
* restarts it)
|
|
434
|
+
* - `tool_call`: a complete tool call
|
|
435
|
+
* - `source`: a grounding source discovered during generation
|
|
436
|
+
* - `provider_tool_call`: progress on a provider-executed tool
|
|
437
|
+
* - `message_id`: the id of the message being generated
|
|
438
|
+
*/
|
|
307
439
|
type CompletionStreamPart = {
|
|
308
440
|
type: "text_delta";
|
|
309
441
|
delta: string;
|
|
@@ -312,6 +444,7 @@ type CompletionStreamPart = {
|
|
|
312
444
|
delta: string;
|
|
313
445
|
id?: string;
|
|
314
446
|
contentType?: ReasoningContentType;
|
|
447
|
+
/** Provider signature preserved for reasoning replay. */
|
|
315
448
|
signature?: string;
|
|
316
449
|
} | {
|
|
317
450
|
type: "tool_call_delta";
|
|
@@ -334,6 +467,7 @@ type CompletionStreamPart = {
|
|
|
334
467
|
type: "message_id";
|
|
335
468
|
id: string;
|
|
336
469
|
};
|
|
470
|
+
/** Raw model stream events: stream parts, the final response, or a terminal error. */
|
|
337
471
|
type CompletionModelStreamEvent<RawResponse = unknown> = CompletionStreamPart | {
|
|
338
472
|
type: "final";
|
|
339
473
|
response: CompletionResponse<RawResponse>;
|
|
@@ -342,6 +476,7 @@ type CompletionModelStreamEvent<RawResponse = unknown> = CompletionStreamPart |
|
|
|
342
476
|
error: unknown;
|
|
343
477
|
usage?: Usage;
|
|
344
478
|
};
|
|
479
|
+
/** High-level stream events: stream parts, the final typed result, or a terminal error. */
|
|
345
480
|
type CompletionStreamEvent<Output = string, RawResponse = unknown> = CompletionStreamPart | {
|
|
346
481
|
type: "final";
|
|
347
482
|
result: CompletionResult<Output, RawResponse>;
|
|
@@ -350,16 +485,21 @@ type CompletionStreamEvent<Output = string, RawResponse = unknown> = CompletionS
|
|
|
350
485
|
error: unknown;
|
|
351
486
|
usage: Usage;
|
|
352
487
|
};
|
|
488
|
+
/** A completion model that can additionally stream events as they are produced. */
|
|
353
489
|
interface StreamingCompletionModel<RawResponse = unknown, Controls extends CompletionModelControls = CompletionModelControls> extends CompletionModel<RawResponse, Controls> {
|
|
354
490
|
streamCompletion(request: CompletionRequest, options?: ModelCallOptions): AsyncIterable<CompletionModelStreamEvent<RawResponse>>;
|
|
355
491
|
}
|
|
492
|
+
/** Thrown when a request uses a capability the target model does not declare. */
|
|
356
493
|
declare class CompletionCapabilityError extends Error {
|
|
357
494
|
constructor(message: string);
|
|
358
495
|
}
|
|
496
|
+
/** Validates a request against a model's declared capabilities; throws {@link CompletionCapabilityError}. */
|
|
359
497
|
declare function assertCompletionRequestSupported(model: CompletionModel, request: CompletionRequest, options?: {
|
|
360
498
|
streaming?: boolean | undefined;
|
|
361
499
|
}): void;
|
|
500
|
+
/** Validates control values against a model's controls; throws {@link CompletionCapabilityError}. */
|
|
362
501
|
declare function assertCompletionControlsSupported(model: CompletionModel, controls: Readonly<Record<string, string | undefined>> | undefined): void;
|
|
502
|
+
/** Joins the text parts of assistant content with newlines. */
|
|
363
503
|
declare function textFromAssistantContent(content: readonly AssistantContentPart[]): string;
|
|
364
504
|
|
|
365
505
|
export { type CompletionStreamPart as $, type AssistantContentPart as A, type ToolDefinition as B, type CompletionControlValues as C, type Document as D, type ToolMessage as E, type FileData as F, type ToolResultContentPart as G, type ToolResultOutput as H, type ImageDetail as I, type JsonObject as J, type ToolResultPart as K, type UserContentPart as L, type Message as M, type NoCompletionModelControls as N, type UserMessage as O, type ProviderTool as P, calculateContextUsage as Q, type ReasoningContentType as R, type SystemMessage as S, type TextPart as T, Usage as U, getAssistantGenerationMetadata as V, isProviderTool as W, resolveModelContextLimits as X, withContextUsage as Y, CompletionCapabilityError as Z, type CompletionModelCapabilities as _, type AssistantGenerationMetadata as a, type StreamingCompletionModel as a0, type ToolApprovalResponsePart as a1, type ToolCallArgumentsMode as a2, type ToolInteractionResponsePart as a3, type ToolQuestionAnswer as a4, type ToolQuestionResponsePart as a5, type UsageDetails as a6, assertCompletionControlsSupported as a7, assertCompletionRequestSupported as a8, reasoningDisplayText as a9, textFromAssistantContent as aa, type AssistantMessage as b, type CompletionFinishReason as c, type CompletionModel as d, type CompletionModelControls as e, type CompletionModelControlsOf as f, type CompletionModelInfo as g, type CompletionModelSelectControl as h, type CompletionModelStreamEvent as i, type CompletionRequest as j, type CompletionResponse as k, type CompletionResult as l, type CompletionSource as m, type CompletionStreamEvent as n, type CompletionTool as o, type ContextUsage as p, type FilePart as q, type ImagePart as r, type JsonPrimitive as s, type JsonValue as t, type ModelContextLimits as u, type ProviderToolCall as v, type ReasoningDetail as w, type ReasoningPart as x, type ToolCallPart as y, type ToolChoice as z };
|