@anvia/core 1.0.0-rc.4 → 1.0.0-rc.6
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 +46 -3
- package/dist/agent/index.d.ts +41 -13
- package/dist/agent/index.js +17 -27
- package/dist/{interactions-csssHYcN.d.ts → agent/interactions/index.d.ts} +3 -55
- package/dist/agent/interactions/index.js +20 -0
- package/dist/agent/interactions/index.js.map +1 -0
- package/dist/{agent-CXScUOpX.d.ts → agent-BK3jud9q.d.ts} +10 -10
- package/dist/{chunk-VKYZZXP5.js → chunk-7O45T5F2.js} +2 -2
- package/dist/{chunk-AI5JMUW7.js → chunk-7OCVDT2X.js} +2 -2
- package/dist/{chunk-FXAIYTRE.js → chunk-7YAH2F3J.js} +3 -3
- package/dist/{chunk-RFHQY2IO.js → chunk-BAEFBTOW.js} +2 -2
- package/dist/chunk-BEU6FCTN.js +164 -0
- package/dist/chunk-BEU6FCTN.js.map +1 -0
- package/dist/{chunk-ZCPOIDAQ.js → chunk-BOCJCECN.js} +4 -4
- package/dist/{chunk-PK5LKOFL.js → chunk-G5OACQEI.js} +4 -66
- package/dist/chunk-G5OACQEI.js.map +1 -0
- package/dist/{chunk-GQL5KRAH.js → chunk-H7BI3BSP.js} +2 -2
- package/dist/{chunk-D2ECOWN5.js → chunk-HT4P3SSG.js} +66 -8
- package/dist/chunk-HT4P3SSG.js.map +1 -0
- package/dist/{chunk-BEYBU7VJ.js → chunk-HVHTVGPP.js} +2 -2
- package/dist/{chunk-J2W63PJI.js → chunk-JXZTTNCR.js} +3 -3
- package/dist/{chunk-KFR4CDGK.js → chunk-QXQQ2DBM.js} +2 -2
- package/dist/{chunk-5GXSQYQT.js → chunk-QXSVVYQK.js} +324 -191
- package/dist/chunk-QXSVVYQK.js.map +1 -0
- package/dist/{chunk-XYTPYUGB.js → chunk-RZDI7B6Z.js} +7 -5
- package/dist/{chunk-XYTPYUGB.js.map → chunk-RZDI7B6Z.js.map} +1 -1
- package/dist/chunk-SROQA7I7.js +69 -0
- package/dist/chunk-SROQA7I7.js.map +1 -0
- package/dist/{chunk-FN7HLLAZ.js → chunk-UBE4WH6G.js} +2 -1
- package/dist/chunk-UBE4WH6G.js.map +1 -0
- package/dist/{chunk-TRQ3XRFD.js → chunk-VGJRXUPT.js} +33 -1
- package/dist/chunk-VGJRXUPT.js.map +1 -0
- package/dist/{chunk-GKDERULJ.js → chunk-YXLDR2O4.js} +2 -2
- package/dist/{client-DvUatElp.d.ts → client-BdQ_QZsY.d.ts} +2 -2
- package/dist/completion/index.d.ts +3 -3
- package/dist/completion/index.js +8 -4
- package/dist/{dynamic-tools-AEBOTgu1.d.ts → dynamic-tools--Aw37H9d.d.ts} +3 -3
- package/dist/embeddings/index.js +2 -2
- package/dist/evals/index.d.ts +8 -7
- package/dist/evals/index.js +7 -6
- package/dist/evals/index.js.map +1 -1
- package/dist/extractor/index.d.ts +1 -1
- package/dist/extractor/index.js +5 -4
- package/dist/guardrails/index.d.ts +4 -4
- package/dist/image-generation/index.d.ts +1 -1
- package/dist/image-generation/index.js +2 -2
- package/dist/index.d.ts +17 -16
- package/dist/index.js +24 -29
- package/dist/internal/agent.d.ts +12 -11
- package/dist/internal/agent.js +13 -11
- package/dist/internal/agent.js.map +1 -1
- package/dist/mcp/index.d.ts +4 -4
- package/dist/mcp/index.js +7 -6
- package/dist/memory/index.d.ts +3 -3
- package/dist/memory/index.js +5 -4
- package/dist/{message-schema-B2M7AYzR.d.ts → message-schema-_sP_RKhh.d.ts} +18 -2
- package/dist/middleware-QZsbz7Hf.d.ts +56 -0
- package/dist/observability/index.d.ts +9 -8
- package/dist/observability/index.js +5 -4
- package/dist/pipeline/index.d.ts +13 -12
- package/dist/pipeline/index.js +6 -5
- package/dist/pipeline/index.js.map +1 -1
- package/dist/skills/index.d.ts +4 -4
- package/dist/skills/index.js +7 -6
- package/dist/speech-generation/index.d.ts +1 -1
- package/dist/speech-generation/index.js +2 -2
- package/dist/{text-C_6eKrbC.d.ts → text-DTg1a8Mg.d.ts} +1 -1
- package/dist/{think-tool-D8frXxwV.d.ts → think-tool-C0n_dF2K.d.ts} +2 -2
- package/dist/tool/index.d.ts +8 -7
- package/dist/tool/index.js +6 -5
- package/dist/{tool-r62gf3QY.d.ts → tool-xHM_GmzT.d.ts} +1 -1
- package/dist/transcription/index.d.ts +1 -1
- package/dist/transcription/index.js +2 -2
- package/dist/{types-CElwurHZ.d.ts → types-2DBdXArn.d.ts} +8 -5
- package/dist/{types-DbolvLtZ.d.ts → types-B1KL4w14.d.ts} +1 -1
- package/dist/{types-C3gv9EX6.d.ts → types-D0Y2ZWS3.d.ts} +1 -1
- package/dist/{types-CIPaIbZo.d.ts → types-D7A6CIGt.d.ts} +1 -1
- package/dist/{types-D9rKQ_as.d.ts → types-DboZvHR_.d.ts} +8 -1
- package/dist/{types-RT3cuyRk.d.ts → types-Dyp7arZQ.d.ts} +1 -1
- package/dist/vector-store/index.d.ts +4 -4
- package/dist/vector-store/index.js +5 -4
- package/package.json +6 -2
- package/dist/chunk-5GXSQYQT.js.map +0 -1
- package/dist/chunk-D2ECOWN5.js.map +0 -1
- package/dist/chunk-FN7HLLAZ.js.map +0 -1
- package/dist/chunk-PK5LKOFL.js.map +0 -1
- package/dist/chunk-TRQ3XRFD.js.map +0 -1
- /package/dist/{chunk-VKYZZXP5.js.map → chunk-7O45T5F2.js.map} +0 -0
- /package/dist/{chunk-AI5JMUW7.js.map → chunk-7OCVDT2X.js.map} +0 -0
- /package/dist/{chunk-FXAIYTRE.js.map → chunk-7YAH2F3J.js.map} +0 -0
- /package/dist/{chunk-RFHQY2IO.js.map → chunk-BAEFBTOW.js.map} +0 -0
- /package/dist/{chunk-ZCPOIDAQ.js.map → chunk-BOCJCECN.js.map} +0 -0
- /package/dist/{chunk-GQL5KRAH.js.map → chunk-H7BI3BSP.js.map} +0 -0
- /package/dist/{chunk-BEYBU7VJ.js.map → chunk-HVHTVGPP.js.map} +0 -0
- /package/dist/{chunk-J2W63PJI.js.map → chunk-JXZTTNCR.js.map} +0 -0
- /package/dist/{chunk-KFR4CDGK.js.map → chunk-QXQQ2DBM.js.map} +0 -0
- /package/dist/{chunk-GKDERULJ.js.map → chunk-YXLDR2O4.js.map} +0 -0
package/README.md
CHANGED
|
@@ -126,7 +126,17 @@ console.log(result.output.priority); // fully typed
|
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
`CompletionResult` consistently contains `output`, the original `text`, normalized `content`,
|
|
129
|
-
`usage`, and `rawResponse`, plus optional message, context, source,
|
|
129
|
+
`usage`, and `rawResponse`, plus optional message, context, source, provider-tool, and finish-reason
|
|
130
|
+
metadata. First-party adapters normalize provider termination into `finishReason` (`stop`, `length`,
|
|
131
|
+
`content-filter`, `tool-calls`, or `other`) while preserving the provider value separately as
|
|
132
|
+
`providerFinishReason`.
|
|
133
|
+
|
|
134
|
+
Schema-backed completion detects `finishReason: "length"` before JSON parsing and throws
|
|
135
|
+
`CompletionStructuredOutputError` with `phase: "truncated"`. Ordinary text completion remains
|
|
136
|
+
intentional: partial text is returned unchanged with its finish reason so the application decides
|
|
137
|
+
whether to display, continue, or discard it. A direct structured stream can similarly end with one
|
|
138
|
+
typed error event after any already-emitted deltas; it does not silently retract public stream
|
|
139
|
+
progress.
|
|
130
140
|
|
|
131
141
|
Use `streamCompletion` for the streaming form:
|
|
132
142
|
|
|
@@ -191,7 +201,9 @@ keys. Cancellation is forwarded to provider SDK calls and is never retried.
|
|
|
191
201
|
|
|
192
202
|
Agents own their default retry policy. A run with no `retries` value inherits the Agent setting;
|
|
193
203
|
`false` disables it for that run; an object replaces it for that run. Retries apply to the current
|
|
194
|
-
|
|
204
|
+
completion only, so completed tools and earlier turns are never replayed. `maxAttempts` is the
|
|
205
|
+
total number of model attempts for that completion, including the initial attempt; it is not the
|
|
206
|
+
number of additional retries.
|
|
195
207
|
|
|
196
208
|
```ts
|
|
197
209
|
const agent = new Agent({
|
|
@@ -208,6 +220,25 @@ await agent.generate({
|
|
|
208
220
|
});
|
|
209
221
|
```
|
|
210
222
|
|
|
223
|
+
When an Agent has `outputSchema`, truncation, JSON parsing, and schema-validation failures use the
|
|
224
|
+
same retry budget when retries are explicitly enabled. Each retry starts from the original request
|
|
225
|
+
rather than recursively accumulating failed attempts. Truncated output and reasoning are omitted;
|
|
226
|
+
parse and schema repairs include only a bounded, text-only preview of the latest failed response.
|
|
227
|
+
The correction asks for shorter raw JSON matching the schema, without Markdown or commentary.
|
|
228
|
+
Transport failures and structured-output failures therefore cannot exceed `maxAttempts` in total.
|
|
229
|
+
Completed Agent results expose the last generation's `finishReason` and `providerFinishReason`, and
|
|
230
|
+
the same fields remain attached to each assistant message's Anvia generation metadata.
|
|
231
|
+
|
|
232
|
+
Structured output remains strict: Core trims surrounding whitespace, parses JSON, and validates the
|
|
233
|
+
result with the configured Zod schema. As a compatibility fallback for OpenAI-compatible providers
|
|
234
|
+
that violate strict JSON mode, Core also accepts a response consisting entirely of one lowercase
|
|
235
|
+
`json` Markdown fence or one unlabeled Markdown fence. It does not search prose for JSON, accept
|
|
236
|
+
content before or after a fence, or bypass schema validation. `AgentStructuredOutputError` reports
|
|
237
|
+
the `truncated`, `parse`, or `schema` phase, attempt counts, output length/format metadata, per-attempt
|
|
238
|
+
and cumulative usage, finish reasons, and the original `cause` when one exists; its message never
|
|
239
|
+
contains the rejected model response. The `completion.retry` observer event records the same safe
|
|
240
|
+
diagnostics and whether failed output was omitted or previewed, never the model output itself.
|
|
241
|
+
|
|
211
242
|
Agent results are discriminated by `status`. Completed results include typed `output` and `text`;
|
|
212
243
|
guardrail blocks return `status: "blocked"`, `stage`, and `text`; tool approvals and first-class
|
|
213
244
|
questions return a JSON-safe `status: "suspended"` result.
|
|
@@ -240,6 +271,17 @@ continuation and current Agent/tool registration but does not provide a durable
|
|
|
240
271
|
or exactly-once execution. Use `createQuestionTool({ name, description })` when a model must ask for
|
|
241
272
|
structured free-text or choice answers.
|
|
242
273
|
|
|
274
|
+
Import JSON-safe interaction contracts and parsers from their browser-safe subpath. This entrypoint
|
|
275
|
+
does not load the Agent runtime, MCP clients, or Node infrastructure:
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
import {
|
|
279
|
+
type AgentInteractionResponse,
|
|
280
|
+
parseAgentInteractionRequest,
|
|
281
|
+
parseAgentInteractionResponse,
|
|
282
|
+
} from "@anvia/core/agent/interactions";
|
|
283
|
+
```
|
|
284
|
+
|
|
243
285
|
An Agent with `outputSchema` carries that output type through `generate`, `stream`, `asTool`, and
|
|
244
286
|
Pipeline Agent stages. Agent stream finals use the same result shape:
|
|
245
287
|
|
|
@@ -504,7 +546,8 @@ added to Agent instructions.
|
|
|
504
546
|
|
|
505
547
|
## Public Areas
|
|
506
548
|
|
|
507
|
-
- `agent`: typed Agent runtime,
|
|
549
|
+
- `agent`: typed Agent runtime, retries, and stream events
|
|
550
|
+
- `agent/interactions`: browser-safe interaction contracts, schemas, assertions, and parsers
|
|
508
551
|
- `tool`: typed tool creation and tool sets
|
|
509
552
|
- `completion`: direct completion helpers and provider-neutral model contracts
|
|
510
553
|
- `memory`: durable session memory interfaces and in-memory store
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,27 +1,55 @@
|
|
|
1
1
|
export { M as ModelCallOptions } from '../model-call-options-CZkSw_xN.js';
|
|
2
2
|
export { R as RetryContext, a as RetryOptions, b as RetrySetting } from '../retry-CjvSlKGW.js';
|
|
3
|
-
export { A as Agent, a as AgentContextInput, b as AgentMemory, c as AgentMemoryOptions, d as AgentOptions, e as AgentToolInput, f as AgentToolOptions, C as CreateHybridVectorContextOptions, g as CreateVectorContextOptions, V as VectorContext, h as VectorContextBaseOptions, i as createVectorContext, j as isVectorContext } from '../agent-
|
|
4
|
-
import { M as Message } from '../types-
|
|
5
|
-
import { A as AgentBlockedResult, t as AgentSuspendedResult } from '../types-
|
|
6
|
-
export { a as AgentChildStreamEvent, b as AgentDeltaEvent, c as AgentErrorEvent, d as AgentErrorStreamEvent, e as AgentFinishEvent, f as AgentInput, g as AgentLifecycle, h as AgentMemoryCompactionEvent, i as AgentPrompt, j as AgentResponse, k as AgentResult, l as AgentRunOptions, m as AgentRunSettings, n as AgentStartEvent, o as AgentSteerInput, p as AgentSteerReceipt, q as AgentStepFinishEvent, r as AgentStream, s as AgentStreamEvent, u as AgentToolCallDeltaEvent, v as AgentToolFinishEvent, w as AgentToolStartEvent } from '../types-
|
|
7
|
-
export { A as AgentContinuation, a as AgentInteractionRequest, b as AgentInteractionResponse, d as AgentQuestionAnswer, e as AgentQuestionChoice, f as AgentQuestionPrompt, g as AgentToolApprovalRequest, h as AgentToolQuestionRequest, p as agentContinuationSchema, q as agentInteractionRequestSchema, r as agentInteractionResponseSchema, w as assertAgentInteractionResponse, t as parseAgentContinuation, u as parseAgentInteractionRequest, v as parseAgentInteractionResponse } from '../interactions-csssHYcN.js';
|
|
3
|
+
export { A as Agent, a as AgentContextInput, b as AgentMemory, c as AgentMemoryOptions, d as AgentOptions, e as AgentToolInput, f as AgentToolOptions, C as CreateHybridVectorContextOptions, g as CreateVectorContextOptions, V as VectorContext, h as VectorContextBaseOptions, i as createVectorContext, j as isVectorContext } from '../agent-BK3jud9q.js';
|
|
4
|
+
import { M as Message, U as Usage, C as CompletionFinishReason } from '../types-DboZvHR_.js';
|
|
5
|
+
import { A as AgentBlockedResult, t as AgentSuspendedResult } from '../types-2DBdXArn.js';
|
|
6
|
+
export { a as AgentChildStreamEvent, b as AgentDeltaEvent, c as AgentErrorEvent, d as AgentErrorStreamEvent, e as AgentFinishEvent, f as AgentInput, g as AgentLifecycle, h as AgentMemoryCompactionEvent, i as AgentPrompt, j as AgentResponse, k as AgentResult, l as AgentRunOptions, m as AgentRunSettings, n as AgentStartEvent, o as AgentSteerInput, p as AgentSteerReceipt, q as AgentStepFinishEvent, r as AgentStream, s as AgentStreamEvent, u as AgentToolCallDeltaEvent, v as AgentToolFinishEvent, w as AgentToolStartEvent } from '../types-2DBdXArn.js';
|
|
8
7
|
import '../zod-schema-C7F4clpm.js';
|
|
9
8
|
import 'zod';
|
|
10
|
-
import '../types-
|
|
9
|
+
import '../types-D7A6CIGt.js';
|
|
11
10
|
import '../type-utils-CtHVDRn_.js';
|
|
12
|
-
import '../client-
|
|
11
|
+
import '../client-BdQ_QZsY.js';
|
|
13
12
|
import 'node:child_process';
|
|
14
13
|
import 'node:stream';
|
|
15
14
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
16
15
|
import '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
17
16
|
import '@modelcontextprotocol/sdk/shared/transport.js';
|
|
18
|
-
import '../tool-
|
|
19
|
-
import '../
|
|
20
|
-
import '../types-
|
|
21
|
-
import '../
|
|
17
|
+
import '../tool-xHM_GmzT.js';
|
|
18
|
+
import '../middleware-QZsbz7Hf.js';
|
|
19
|
+
import '../types-B1KL4w14.js';
|
|
20
|
+
import '../types-Dyp7arZQ.js';
|
|
21
|
+
import '../dynamic-tools--Aw37H9d.js';
|
|
22
22
|
import '../types-Cr4uiYo5.js';
|
|
23
|
-
import '../types-
|
|
23
|
+
import '../types-D0Y2ZWS3.js';
|
|
24
|
+
import './interactions/index.js';
|
|
24
25
|
|
|
26
|
+
type AgentStructuredOutputPhase = "truncated" | "parse" | "schema";
|
|
27
|
+
type AgentStructuredOutputFormat = "raw" | "json-fence" | "unlabeled-fence";
|
|
28
|
+
declare class AgentStructuredOutputError extends Error {
|
|
29
|
+
readonly phase: AgentStructuredOutputPhase;
|
|
30
|
+
readonly attempt: number;
|
|
31
|
+
readonly maxAttempts: number;
|
|
32
|
+
readonly outputLength: number;
|
|
33
|
+
readonly normalizedLength: number;
|
|
34
|
+
readonly outputFormat: AgentStructuredOutputFormat;
|
|
35
|
+
readonly attemptUsage: Usage;
|
|
36
|
+
readonly usage: Usage;
|
|
37
|
+
readonly finishReason: CompletionFinishReason | undefined;
|
|
38
|
+
readonly providerFinishReason: string | undefined;
|
|
39
|
+
constructor(options: {
|
|
40
|
+
phase: AgentStructuredOutputPhase;
|
|
41
|
+
attempt: number;
|
|
42
|
+
maxAttempts: number;
|
|
43
|
+
outputLength: number;
|
|
44
|
+
normalizedLength: number;
|
|
45
|
+
outputFormat: AgentStructuredOutputFormat;
|
|
46
|
+
attemptUsage: Usage;
|
|
47
|
+
usage: Usage;
|
|
48
|
+
finishReason?: CompletionFinishReason | undefined;
|
|
49
|
+
providerFinishReason?: string | undefined;
|
|
50
|
+
cause?: unknown;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
25
53
|
declare class MaxTurnsError extends Error {
|
|
26
54
|
readonly maxTurns: number;
|
|
27
55
|
readonly chatHistory: Message[];
|
|
@@ -45,4 +73,4 @@ declare class AgentToolSuspensionError extends Error {
|
|
|
45
73
|
constructor(result: AgentSuspendedResult);
|
|
46
74
|
}
|
|
47
75
|
|
|
48
|
-
export { AgentBlockedResult, AgentRunBlockedError, AgentRunCancelledError, AgentStreamClosedError, AgentSuspendedResult, AgentToolSuspensionError, MaxTurnsError };
|
|
76
|
+
export { AgentBlockedResult, AgentRunBlockedError, AgentRunCancelledError, AgentStreamClosedError, AgentStructuredOutputError, type AgentStructuredOutputFormat, type AgentStructuredOutputPhase, AgentSuspendedResult, AgentToolSuspensionError, MaxTurnsError };
|
package/dist/agent/index.js
CHANGED
|
@@ -1,51 +1,41 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Agent,
|
|
3
|
-
agentContinuationSchema,
|
|
4
|
-
agentInteractionRequestSchema,
|
|
5
|
-
agentInteractionResponseSchema,
|
|
6
|
-
assertAgentInteractionResponse,
|
|
7
3
|
createVectorContext,
|
|
8
|
-
isVectorContext
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-KFR4CDGK.js";
|
|
15
|
-
import "../chunk-VKYZZXP5.js";
|
|
4
|
+
isVectorContext
|
|
5
|
+
} from "../chunk-QXSVVYQK.js";
|
|
6
|
+
import "../chunk-BEU6FCTN.js";
|
|
7
|
+
import "../chunk-7YAH2F3J.js";
|
|
8
|
+
import "../chunk-QXQQ2DBM.js";
|
|
9
|
+
import "../chunk-7O45T5F2.js";
|
|
16
10
|
import "../chunk-YK4WAAS4.js";
|
|
17
11
|
import "../chunk-CQNNSZPG.js";
|
|
18
|
-
import "../chunk-
|
|
19
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-JXZTTNCR.js";
|
|
13
|
+
import "../chunk-RZDI7B6Z.js";
|
|
20
14
|
import {
|
|
21
15
|
AgentRunBlockedError,
|
|
22
16
|
AgentRunCancelledError,
|
|
23
17
|
AgentStreamClosedError,
|
|
18
|
+
AgentStructuredOutputError,
|
|
24
19
|
AgentToolSuspensionError,
|
|
25
20
|
MaxTurnsError
|
|
26
|
-
} from "../chunk-
|
|
27
|
-
import "../chunk-
|
|
21
|
+
} from "../chunk-VGJRXUPT.js";
|
|
22
|
+
import "../chunk-H7BI3BSP.js";
|
|
28
23
|
import "../chunk-3RM57ZT2.js";
|
|
29
24
|
import "../chunk-MGNTXGTX.js";
|
|
30
|
-
import "../chunk-
|
|
31
|
-
import "../chunk-
|
|
32
|
-
import "../chunk-
|
|
25
|
+
import "../chunk-HT4P3SSG.js";
|
|
26
|
+
import "../chunk-G5OACQEI.js";
|
|
27
|
+
import "../chunk-SROQA7I7.js";
|
|
28
|
+
import "../chunk-UBE4WH6G.js";
|
|
33
29
|
import "../chunk-AZB6N7P4.js";
|
|
34
30
|
export {
|
|
35
31
|
Agent,
|
|
36
32
|
AgentRunBlockedError,
|
|
37
33
|
AgentRunCancelledError,
|
|
38
34
|
AgentStreamClosedError,
|
|
35
|
+
AgentStructuredOutputError,
|
|
39
36
|
AgentToolSuspensionError,
|
|
40
37
|
MaxTurnsError,
|
|
41
|
-
agentContinuationSchema,
|
|
42
|
-
agentInteractionRequestSchema,
|
|
43
|
-
agentInteractionResponseSchema,
|
|
44
|
-
assertAgentInteractionResponse,
|
|
45
38
|
createVectorContext,
|
|
46
|
-
isVectorContext
|
|
47
|
-
parseAgentContinuation,
|
|
48
|
-
parseAgentInteractionRequest,
|
|
49
|
-
parseAgentInteractionResponse
|
|
39
|
+
isVectorContext
|
|
50
40
|
};
|
|
51
41
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,58 +1,6 @@
|
|
|
1
|
-
import { e as CompletionRequest, f as CompletionResponse, o as JsonValue, x as ToolResultContentPart, J as JsonObject, _ as ToolQuestionAnswer } from './types-D9rKQ_as.js';
|
|
2
|
-
import { M as MaybePromise } from './type-utils-CtHVDRn_.js';
|
|
3
1
|
import { z } from 'zod';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
turn: number;
|
|
7
|
-
request: CompletionRequest;
|
|
8
|
-
originalRequest: CompletionRequest;
|
|
9
|
-
};
|
|
10
|
-
type CompletionRequestMiddlewareResult = {
|
|
11
|
-
request: CompletionRequest;
|
|
12
|
-
} | undefined;
|
|
13
|
-
type CompletionResponseMiddlewareArgs<RawResponse = unknown> = {
|
|
14
|
-
turn: number;
|
|
15
|
-
request: CompletionRequest;
|
|
16
|
-
response: CompletionResponse<RawResponse>;
|
|
17
|
-
originalResponse: CompletionResponse<RawResponse>;
|
|
18
|
-
};
|
|
19
|
-
type CompletionResponseMiddlewareResult<RawResponse = unknown> = {
|
|
20
|
-
response: CompletionResponse<RawResponse>;
|
|
21
|
-
} | undefined;
|
|
22
|
-
type ToolInputMiddlewareArgs = {
|
|
23
|
-
toolName: string;
|
|
24
|
-
args: string;
|
|
25
|
-
originalArgs: string;
|
|
26
|
-
turn: number;
|
|
27
|
-
toolCallId?: string | undefined;
|
|
28
|
-
internalCallId: string;
|
|
29
|
-
};
|
|
30
|
-
type ToolInputMiddlewareResult = {
|
|
31
|
-
args: JsonValue | string;
|
|
32
|
-
} | undefined;
|
|
33
|
-
type ToolResultMiddlewareArgs = {
|
|
34
|
-
toolName: string;
|
|
35
|
-
args: string;
|
|
36
|
-
result: string;
|
|
37
|
-
originalResult: string;
|
|
38
|
-
structuredResult?: readonly ToolResultContentPart[] | undefined;
|
|
39
|
-
originalStructuredResult?: readonly ToolResultContentPart[] | undefined;
|
|
40
|
-
turn: number;
|
|
41
|
-
toolCallId?: string | undefined;
|
|
42
|
-
internalCallId: string;
|
|
43
|
-
};
|
|
44
|
-
type ToolOutputMiddlewareArgs = ToolResultMiddlewareArgs;
|
|
45
|
-
type ToolOutputMiddlewareResult = string | {
|
|
46
|
-
result?: string | undefined;
|
|
47
|
-
structuredResult?: readonly ToolResultContentPart[] | undefined;
|
|
48
|
-
} | undefined;
|
|
49
|
-
interface AgentMiddleware<RawResponse = unknown> {
|
|
50
|
-
onCompletionRequest?(args: CompletionRequestMiddlewareArgs): MaybePromise<CompletionRequestMiddlewareResult>;
|
|
51
|
-
onCompletionResponse?(args: CompletionResponseMiddlewareArgs<RawResponse>): MaybePromise<CompletionResponseMiddlewareResult<RawResponse>>;
|
|
52
|
-
onToolInput?(args: ToolInputMiddlewareArgs): MaybePromise<ToolInputMiddlewareResult>;
|
|
53
|
-
onToolOutput?(args: ToolOutputMiddlewareArgs): MaybePromise<ToolOutputMiddlewareResult>;
|
|
54
|
-
}
|
|
55
|
-
declare function createMiddleware<RawResponse = unknown>(middleware: AgentMiddleware<RawResponse>): AgentMiddleware<RawResponse>;
|
|
2
|
+
import { p as JsonValue, J as JsonObject, $ as ToolQuestionAnswer } from '../../types-DboZvHR_.js';
|
|
3
|
+
import '../../model-call-options-CZkSw_xN.js';
|
|
56
4
|
|
|
57
5
|
type AgentQuestionChoice = Readonly<{
|
|
58
6
|
label: string;
|
|
@@ -171,4 +119,4 @@ declare function parseAgentInteractionResponse(value: unknown): AgentInteraction
|
|
|
171
119
|
declare function parseAgentContinuation(value: unknown): AgentContinuation;
|
|
172
120
|
declare function assertAgentInteractionResponse(request: AgentInteractionRequest, response: AgentInteractionResponse): void;
|
|
173
121
|
|
|
174
|
-
export { type AgentContinuation
|
|
122
|
+
export { type AgentContinuation, type AgentInteractionRequest, type AgentInteractionResponse, type AgentQuestionAnswer, type AgentQuestionChoice, type AgentQuestionPrompt, type AgentToolApprovalRequest, type AgentToolQuestionRequest, agentContinuationSchema, agentInteractionRequestSchema, agentInteractionResponseSchema, assertAgentInteractionResponse, parseAgentContinuation, parseAgentInteractionRequest, parseAgentInteractionResponse };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
agentContinuationSchema,
|
|
3
|
+
agentInteractionRequestSchema,
|
|
4
|
+
agentInteractionResponseSchema,
|
|
5
|
+
assertAgentInteractionResponse,
|
|
6
|
+
parseAgentContinuation,
|
|
7
|
+
parseAgentInteractionRequest,
|
|
8
|
+
parseAgentInteractionResponse
|
|
9
|
+
} from "../../chunk-BEU6FCTN.js";
|
|
10
|
+
import "../../chunk-SROQA7I7.js";
|
|
11
|
+
export {
|
|
12
|
+
agentContinuationSchema,
|
|
13
|
+
agentInteractionRequestSchema,
|
|
14
|
+
agentInteractionResponseSchema,
|
|
15
|
+
assertAgentInteractionResponse,
|
|
16
|
+
parseAgentContinuation,
|
|
17
|
+
parseAgentInteractionRequest,
|
|
18
|
+
parseAgentInteractionResponse
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { b as RetrySetting } from './retry-CjvSlKGW.js';
|
|
2
|
-
import { D as Document,
|
|
2
|
+
import { D as Document, c as CompletionModel, P as ProviderTool, J as JsonObject, v as ToolChoice } from './types-DboZvHR_.js';
|
|
3
3
|
import { Z as ZodSchema } from './zod-schema-C7F4clpm.js';
|
|
4
|
-
import { d as GuardrailPolicyInput, c as GuardrailPolicy } from './types-
|
|
5
|
-
import { a as McpServer } from './client-
|
|
6
|
-
import { g as AgentLifecycle, E as AgentObservabilityOptions, l as AgentRunOptions, k as AgentResult, r as AgentStream, s as AgentStreamEvent } from './types-
|
|
7
|
-
import {
|
|
8
|
-
import { A as AnyTool, T as Tool, c as ToolCallContext, N as NormalizedToolOutput } from './tool-
|
|
9
|
-
import { D as MemoryStore, y as MemorySavePolicy, m as MemoryCompactor, d as MemoryCompactionConflictRetryOptions, x as MemoryOptions } from './types-
|
|
10
|
-
import { a as SkillSet } from './types-
|
|
11
|
-
import { T as ToolIndex } from './dynamic-tools
|
|
4
|
+
import { d as GuardrailPolicyInput, c as GuardrailPolicy } from './types-D7A6CIGt.js';
|
|
5
|
+
import { a as McpServer } from './client-BdQ_QZsY.js';
|
|
6
|
+
import { g as AgentLifecycle, E as AgentObservabilityOptions, l as AgentRunOptions, k as AgentResult, r as AgentStream, s as AgentStreamEvent } from './types-2DBdXArn.js';
|
|
7
|
+
import { A as AgentMiddleware } from './middleware-QZsbz7Hf.js';
|
|
8
|
+
import { A as AnyTool, T as Tool, c as ToolCallContext, N as NormalizedToolOutput } from './tool-xHM_GmzT.js';
|
|
9
|
+
import { D as MemoryStore, y as MemorySavePolicy, m as MemoryCompactor, d as MemoryCompactionConflictRetryOptions, x as MemoryOptions } from './types-B1KL4w14.js';
|
|
10
|
+
import { a as SkillSet } from './types-Dyp7arZQ.js';
|
|
11
|
+
import { T as ToolIndex } from './dynamic-tools--Aw37H9d.js';
|
|
12
12
|
import { E as EmbeddingModel, c as SparseEmbeddingModel } from './types-Cr4uiYo5.js';
|
|
13
|
-
import { V as VectorFilter, a as VectorSearchResult, d as VectorStore, H as HybridVectorStore, e as VectorFusion } from './types-
|
|
13
|
+
import { V as VectorFilter, a as VectorSearchResult, d as VectorStore, H as HybridVectorStore, e as VectorFusion } from './types-D0Y2ZWS3.js';
|
|
14
14
|
|
|
15
15
|
type VectorContextBaseOptions<T = unknown> = {
|
|
16
16
|
topK: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Usage
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HT4P3SSG.js";
|
|
4
4
|
|
|
5
5
|
// src/observability/snapshot.ts
|
|
6
6
|
function observerSnapshot(value) {
|
|
@@ -320,4 +320,4 @@ export {
|
|
|
320
320
|
AgentObserverDispatchError,
|
|
321
321
|
startAgentRunObservers
|
|
322
322
|
};
|
|
323
|
-
//# sourceMappingURL=chunk-
|
|
323
|
+
//# sourceMappingURL=chunk-7O45T5F2.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
resolveRetryOptions,
|
|
3
3
|
runWithRetries,
|
|
4
4
|
throwIfAborted
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-UBE4WH6G.js";
|
|
6
6
|
|
|
7
7
|
// src/speech-generation/generate-speech.ts
|
|
8
8
|
async function generateSpeech(options) {
|
|
@@ -42,4 +42,4 @@ function assertNonEmptyString(value, name) {
|
|
|
42
42
|
export {
|
|
43
43
|
generateSpeech
|
|
44
44
|
};
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-7OCVDT2X.js.map
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
} from "./chunk-CQNNSZPG.js";
|
|
4
4
|
import {
|
|
5
5
|
ToolOutput
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-RZDI7B6Z.js";
|
|
7
7
|
import {
|
|
8
8
|
abortError,
|
|
9
9
|
throwIfAborted
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-UBE4WH6G.js";
|
|
11
11
|
|
|
12
12
|
// src/mcp/client.ts
|
|
13
13
|
import { readFileSync } from "fs";
|
|
@@ -701,4 +701,4 @@ export {
|
|
|
701
701
|
McpClient,
|
|
702
702
|
McpClientGroup
|
|
703
703
|
};
|
|
704
|
-
//# sourceMappingURL=chunk-
|
|
704
|
+
//# sourceMappingURL=chunk-7YAH2F3J.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-CQNNSZPG.js";
|
|
7
7
|
import {
|
|
8
8
|
createTool
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-RZDI7B6Z.js";
|
|
10
10
|
|
|
11
11
|
// src/skills/instructions.ts
|
|
12
12
|
function skillInstructions(skills) {
|
|
@@ -395,4 +395,4 @@ export {
|
|
|
395
395
|
SkillValidationError,
|
|
396
396
|
skill
|
|
397
397
|
};
|
|
398
|
-
//# sourceMappingURL=chunk-
|
|
398
|
+
//# sourceMappingURL=chunk-BAEFBTOW.js.map
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isJsonValue
|
|
3
|
+
} from "./chunk-SROQA7I7.js";
|
|
4
|
+
|
|
5
|
+
// src/agent/interactions.ts
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
var nonblank = z.string().trim().min(1);
|
|
8
|
+
var jsonValueSchema = z.custom(isJsonValue, {
|
|
9
|
+
message: "Expected a strict JSON value"
|
|
10
|
+
});
|
|
11
|
+
var jsonObjectSchema = z.custom(
|
|
12
|
+
(value) => typeof value === "object" && value !== null && !Array.isArray(value) && isJsonValue(value),
|
|
13
|
+
{ message: "Expected a strict JSON object" }
|
|
14
|
+
);
|
|
15
|
+
var questionChoiceSchema = z.object({
|
|
16
|
+
label: nonblank,
|
|
17
|
+
value: nonblank
|
|
18
|
+
}).strict();
|
|
19
|
+
var questionPromptSchema = z.object({
|
|
20
|
+
id: nonblank,
|
|
21
|
+
text: nonblank,
|
|
22
|
+
choices: z.array(questionChoiceSchema).min(1).optional(),
|
|
23
|
+
allowCustom: z.boolean().optional()
|
|
24
|
+
}).strict().superRefine((question, context) => {
|
|
25
|
+
if (question.choices === void 0 && question.allowCustom === false) {
|
|
26
|
+
context.addIssue({
|
|
27
|
+
code: "custom",
|
|
28
|
+
message: "A free-text question cannot disable custom answers.",
|
|
29
|
+
path: ["allowCustom"]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const values = /* @__PURE__ */ new Set();
|
|
33
|
+
for (const [index, choice] of (question.choices ?? []).entries()) {
|
|
34
|
+
if (values.has(choice.value)) {
|
|
35
|
+
context.addIssue({
|
|
36
|
+
code: "custom",
|
|
37
|
+
message: "Question choice values must be unique.",
|
|
38
|
+
path: ["choices", index, "value"]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
values.add(choice.value);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
var questionAnswerSchema = z.object({
|
|
45
|
+
questionId: nonblank,
|
|
46
|
+
value: nonblank
|
|
47
|
+
}).strict();
|
|
48
|
+
var interactionBase = {
|
|
49
|
+
id: nonblank,
|
|
50
|
+
toolName: nonblank,
|
|
51
|
+
toolCallId: nonblank,
|
|
52
|
+
callId: z.string().optional(),
|
|
53
|
+
internalCallId: nonblank
|
|
54
|
+
};
|
|
55
|
+
var approvalRequestSchema = z.object({
|
|
56
|
+
type: z.literal("tool-approval"),
|
|
57
|
+
...interactionBase,
|
|
58
|
+
input: jsonValueSchema,
|
|
59
|
+
reason: z.string().optional()
|
|
60
|
+
}).strict();
|
|
61
|
+
var questionRequestSchema = z.object({
|
|
62
|
+
type: z.literal("tool-question"),
|
|
63
|
+
...interactionBase,
|
|
64
|
+
questions: z.array(questionPromptSchema).min(1)
|
|
65
|
+
}).strict().superRefine((request, context) => {
|
|
66
|
+
const ids = /* @__PURE__ */ new Set();
|
|
67
|
+
for (const [index, question] of request.questions.entries()) {
|
|
68
|
+
if (ids.has(question.id)) {
|
|
69
|
+
context.addIssue({
|
|
70
|
+
code: "custom",
|
|
71
|
+
message: "Question IDs must be unique.",
|
|
72
|
+
path: ["questions", index, "id"]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
ids.add(question.id);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
var agentInteractionRequestSchema = z.discriminatedUnion("type", [
|
|
79
|
+
approvalRequestSchema,
|
|
80
|
+
questionRequestSchema
|
|
81
|
+
]);
|
|
82
|
+
var agentInteractionResponseSchema = z.discriminatedUnion("type", [
|
|
83
|
+
z.object({
|
|
84
|
+
type: z.literal("tool-approval"),
|
|
85
|
+
approved: z.boolean(),
|
|
86
|
+
reason: z.string().optional()
|
|
87
|
+
}).strict(),
|
|
88
|
+
z.object({
|
|
89
|
+
type: z.literal("tool-question"),
|
|
90
|
+
answers: z.array(questionAnswerSchema)
|
|
91
|
+
}).strict()
|
|
92
|
+
]);
|
|
93
|
+
var agentContinuationSchema = z.object({
|
|
94
|
+
version: z.literal(1),
|
|
95
|
+
agentId: nonblank,
|
|
96
|
+
sourceRunId: nonblank,
|
|
97
|
+
interaction: agentInteractionRequestSchema,
|
|
98
|
+
state: jsonObjectSchema
|
|
99
|
+
}).strict();
|
|
100
|
+
function parseAgentInteractionRequest(value) {
|
|
101
|
+
return freeze(agentInteractionRequestSchema.parse(value));
|
|
102
|
+
}
|
|
103
|
+
function parseAgentInteractionResponse(value) {
|
|
104
|
+
return freeze(agentInteractionResponseSchema.parse(value));
|
|
105
|
+
}
|
|
106
|
+
function parseAgentQuestionPrompts(value) {
|
|
107
|
+
const request = questionRequestSchema.parse({
|
|
108
|
+
type: "tool-question",
|
|
109
|
+
id: "validation",
|
|
110
|
+
toolName: "validation",
|
|
111
|
+
toolCallId: "validation",
|
|
112
|
+
internalCallId: "validation",
|
|
113
|
+
questions: value
|
|
114
|
+
});
|
|
115
|
+
return freeze(request.questions);
|
|
116
|
+
}
|
|
117
|
+
function parseAgentContinuation(value) {
|
|
118
|
+
return freeze(agentContinuationSchema.parse(value));
|
|
119
|
+
}
|
|
120
|
+
function assertAgentInteractionResponse(request, response) {
|
|
121
|
+
if (request.type !== response.type) {
|
|
122
|
+
throw new TypeError("Interaction response type does not match the pending request.");
|
|
123
|
+
}
|
|
124
|
+
if (request.type === "tool-question" && response.type === "tool-question") {
|
|
125
|
+
assertQuestionAnswers(request, response.answers);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function assertQuestionAnswers(request, answers) {
|
|
129
|
+
const parsed = answers.map((answer) => questionAnswerSchema.parse(answer));
|
|
130
|
+
const byId = new Map(parsed.map((answer) => [answer.questionId, answer]));
|
|
131
|
+
if (byId.size !== parsed.length) {
|
|
132
|
+
throw new TypeError("Question answers must not contain duplicate question IDs.");
|
|
133
|
+
}
|
|
134
|
+
if (byId.size !== request.questions.length) {
|
|
135
|
+
throw new TypeError("Question responses must answer every question exactly once.");
|
|
136
|
+
}
|
|
137
|
+
for (const question of request.questions) {
|
|
138
|
+
const answer = byId.get(question.id);
|
|
139
|
+
if (answer === void 0) {
|
|
140
|
+
throw new TypeError(`Question response is missing an answer for "${question.id}".`);
|
|
141
|
+
}
|
|
142
|
+
const choices = question.choices;
|
|
143
|
+
if (choices !== void 0 && question.allowCustom !== true && !choices.some((choice) => choice.value === answer.value)) {
|
|
144
|
+
throw new TypeError(`Question "${question.id}" requires one of its configured choices.`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function freeze(value) {
|
|
149
|
+
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
150
|
+
for (const child of Object.values(value)) freeze(child);
|
|
151
|
+
return Object.freeze(value);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export {
|
|
155
|
+
agentInteractionRequestSchema,
|
|
156
|
+
agentInteractionResponseSchema,
|
|
157
|
+
agentContinuationSchema,
|
|
158
|
+
parseAgentInteractionRequest,
|
|
159
|
+
parseAgentInteractionResponse,
|
|
160
|
+
parseAgentQuestionPrompts,
|
|
161
|
+
parseAgentContinuation,
|
|
162
|
+
assertAgentInteractionResponse
|
|
163
|
+
};
|
|
164
|
+
//# sourceMappingURL=chunk-BEU6FCTN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agent/interactions.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { isJsonValue } from \"../completion/json\";\nimport type { JsonObject, JsonValue, ToolQuestionAnswer } from \"../completion/types\";\n\nexport type AgentQuestionChoice = Readonly<{\n label: string;\n value: string;\n}>;\n\nexport type AgentQuestionPrompt = Readonly<{\n id: string;\n text: string;\n choices?: readonly AgentQuestionChoice[];\n allowCustom?: boolean;\n}>;\n\nexport type AgentQuestionAnswer = ToolQuestionAnswer;\n\ntype AgentInteractionRequestBase = Readonly<{\n id: string;\n toolName: string;\n toolCallId: string;\n callId?: string;\n internalCallId: string;\n}>;\n\nexport type AgentToolApprovalRequest = AgentInteractionRequestBase &\n Readonly<{\n type: \"tool-approval\";\n input: JsonValue;\n reason?: string;\n }>;\n\nexport type AgentToolQuestionRequest = AgentInteractionRequestBase &\n Readonly<{\n type: \"tool-question\";\n questions: readonly AgentQuestionPrompt[];\n }>;\n\nexport type AgentInteractionRequest = AgentToolApprovalRequest | AgentToolQuestionRequest;\n\nexport type AgentInteractionResponse =\n | Readonly<{\n type: \"tool-approval\";\n approved: boolean;\n reason?: string;\n }>\n | Readonly<{\n type: \"tool-question\";\n answers: readonly AgentQuestionAnswer[];\n }>;\n\nexport type AgentContinuation = Readonly<{\n version: 1;\n agentId: string;\n sourceRunId: string;\n interaction: AgentInteractionRequest;\n state: JsonObject;\n}>;\n\nconst nonblank = z.string().trim().min(1);\nconst jsonValueSchema = z.custom<JsonValue>(isJsonValue, {\n message: \"Expected a strict JSON value\",\n});\nconst jsonObjectSchema = z.custom<JsonObject>(\n (value) =>\n typeof value === \"object\" && value !== null && !Array.isArray(value) && isJsonValue(value),\n { message: \"Expected a strict JSON object\" },\n);\n\nconst questionChoiceSchema = z\n .object({\n label: nonblank,\n value: nonblank,\n })\n .strict();\n\nconst questionPromptSchema = z\n .object({\n id: nonblank,\n text: nonblank,\n choices: z.array(questionChoiceSchema).min(1).optional(),\n allowCustom: z.boolean().optional(),\n })\n .strict()\n .superRefine((question, context) => {\n if (question.choices === undefined && question.allowCustom === false) {\n context.addIssue({\n code: \"custom\",\n message: \"A free-text question cannot disable custom answers.\",\n path: [\"allowCustom\"],\n });\n }\n const values = new Set<string>();\n for (const [index, choice] of (question.choices ?? []).entries()) {\n if (values.has(choice.value)) {\n context.addIssue({\n code: \"custom\",\n message: \"Question choice values must be unique.\",\n path: [\"choices\", index, \"value\"],\n });\n }\n values.add(choice.value);\n }\n });\n\nconst questionAnswerSchema = z\n .object({\n questionId: nonblank,\n value: nonblank,\n })\n .strict();\n\nconst interactionBase = {\n id: nonblank,\n toolName: nonblank,\n toolCallId: nonblank,\n callId: z.string().optional(),\n internalCallId: nonblank,\n};\n\nconst approvalRequestSchema = z\n .object({\n type: z.literal(\"tool-approval\"),\n ...interactionBase,\n input: jsonValueSchema,\n reason: z.string().optional(),\n })\n .strict();\n\nconst questionRequestSchema = z\n .object({\n type: z.literal(\"tool-question\"),\n ...interactionBase,\n questions: z.array(questionPromptSchema).min(1),\n })\n .strict()\n .superRefine((request, context) => {\n const ids = new Set<string>();\n for (const [index, question] of request.questions.entries()) {\n if (ids.has(question.id)) {\n context.addIssue({\n code: \"custom\",\n message: \"Question IDs must be unique.\",\n path: [\"questions\", index, \"id\"],\n });\n }\n ids.add(question.id);\n }\n });\n\nexport const agentInteractionRequestSchema = z.discriminatedUnion(\"type\", [\n approvalRequestSchema,\n questionRequestSchema,\n]);\n\nexport const agentInteractionResponseSchema = z.discriminatedUnion(\"type\", [\n z\n .object({\n type: z.literal(\"tool-approval\"),\n approved: z.boolean(),\n reason: z.string().optional(),\n })\n .strict(),\n z\n .object({\n type: z.literal(\"tool-question\"),\n answers: z.array(questionAnswerSchema),\n })\n .strict(),\n]);\n\nexport const agentContinuationSchema = z\n .object({\n version: z.literal(1),\n agentId: nonblank,\n sourceRunId: nonblank,\n interaction: agentInteractionRequestSchema,\n state: jsonObjectSchema,\n })\n .strict();\n\nexport function parseAgentInteractionRequest(value: unknown): AgentInteractionRequest {\n return freeze(agentInteractionRequestSchema.parse(value)) as AgentInteractionRequest;\n}\n\nexport function parseAgentInteractionResponse(value: unknown): AgentInteractionResponse {\n return freeze(agentInteractionResponseSchema.parse(value)) as AgentInteractionResponse;\n}\n\nexport function parseAgentQuestionPrompts(value: unknown): readonly AgentQuestionPrompt[] {\n const request = questionRequestSchema.parse({\n type: \"tool-question\",\n id: \"validation\",\n toolName: \"validation\",\n toolCallId: \"validation\",\n internalCallId: \"validation\",\n questions: value,\n });\n return freeze(request.questions) as readonly AgentQuestionPrompt[];\n}\n\nexport function parseAgentContinuation(value: unknown): AgentContinuation {\n return freeze(agentContinuationSchema.parse(value)) as AgentContinuation;\n}\n\nexport function assertAgentInteractionResponse(\n request: AgentInteractionRequest,\n response: AgentInteractionResponse,\n): void {\n if (request.type !== response.type) {\n throw new TypeError(\"Interaction response type does not match the pending request.\");\n }\n if (request.type === \"tool-question\" && response.type === \"tool-question\") {\n assertQuestionAnswers(request, response.answers);\n }\n}\n\nfunction assertQuestionAnswers(\n request: AgentToolQuestionRequest,\n answers: readonly AgentQuestionAnswer[],\n): void {\n const parsed = answers.map((answer) => questionAnswerSchema.parse(answer));\n const byId = new Map(parsed.map((answer) => [answer.questionId, answer]));\n if (byId.size !== parsed.length) {\n throw new TypeError(\"Question answers must not contain duplicate question IDs.\");\n }\n if (byId.size !== request.questions.length) {\n throw new TypeError(\"Question responses must answer every question exactly once.\");\n }\n for (const question of request.questions) {\n const answer = byId.get(question.id);\n if (answer === undefined) {\n throw new TypeError(`Question response is missing an answer for \"${question.id}\".`);\n }\n const choices = question.choices;\n if (\n choices !== undefined &&\n question.allowCustom !== true &&\n !choices.some((choice) => choice.value === answer.value)\n ) {\n throw new TypeError(`Question \"${question.id}\" requires one of its configured choices.`);\n }\n }\n}\n\nfunction freeze<T>(value: T): T {\n if (typeof value !== \"object\" || value === null || Object.isFrozen(value)) return value;\n for (const child of Object.values(value)) freeze(child);\n return Object.freeze(value);\n}\n"],"mappings":";;;;;AAAA,SAAS,SAAS;AA4DlB,IAAM,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;AACxC,IAAM,kBAAkB,EAAE,OAAkB,aAAa;AAAA,EACvD,SAAS;AACX,CAAC;AACD,IAAM,mBAAmB,EAAE;AAAA,EACzB,CAAC,UACC,OAAO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OAAO,UAAU,OAAO,KAAK,GACvD;AACA,YAAM,IAAI,UAAU,aAAa,SAAS,EAAE,2CAA2C;AAAA,IACzF;AAAA,EACF;AACF;AAEA,SAAS,OAAU,OAAa;AAC9B,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAO,SAAS,KAAK,EAAG,QAAO;AAClF,aAAW,SAAS,OAAO,OAAO,KAAK,EAAG,QAAO,KAAK;AACtD,SAAO,OAAO,OAAO,KAAK;AAC5B;","names":[]}
|
|
@@ -2,17 +2,17 @@ import {
|
|
|
2
2
|
CompletionCapabilityError,
|
|
3
3
|
Usage,
|
|
4
4
|
generateCompletion
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HT4P3SSG.js";
|
|
6
6
|
import {
|
|
7
7
|
toProviderJsonSchema
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-G5OACQEI.js";
|
|
9
9
|
import {
|
|
10
10
|
isAbortError,
|
|
11
11
|
resolveRetryOptions,
|
|
12
12
|
retryDelayMs,
|
|
13
13
|
retryOptionsForFailure,
|
|
14
14
|
waitForRetry
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-UBE4WH6G.js";
|
|
16
16
|
|
|
17
17
|
// src/extractor/extractor.ts
|
|
18
18
|
import { z } from "zod";
|
|
@@ -124,4 +124,4 @@ export {
|
|
|
124
124
|
ExtractionError,
|
|
125
125
|
extract
|
|
126
126
|
};
|
|
127
|
-
//# sourceMappingURL=chunk-
|
|
127
|
+
//# sourceMappingURL=chunk-BOCJCECN.js.map
|