@anvia/core 1.11.1 → 1.13.0
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 +40 -2
- package/dist/agent/agent.js +4 -4
- package/dist/agent/index.js +7 -7
- package/dist/agent/resolved-agent.js +5 -5
- package/dist/agent/team/agent-team.js +7 -7
- package/dist/agent/team/index.js +7 -7
- package/dist/{chunk-7XDM7A3W.js → chunk-22E25UM7.js} +2 -2
- package/dist/{chunk-2K7NSWUC.js → chunk-AGOZCYFP.js} +6 -6
- package/dist/{chunk-PLJQ4274.js → chunk-CKWIXVXM.js} +3 -3
- package/dist/{chunk-GSMLYI4Z.js → chunk-D43A3KOF.js} +3 -3
- package/dist/{chunk-DRSKZVC6.js → chunk-ED7RKQHE.js} +2 -2
- package/dist/{chunk-TXWNIEZU.js → chunk-HF5SX5BQ.js} +2 -2
- package/dist/chunk-IRXAEVEQ.js +105 -0
- package/dist/chunk-IRXAEVEQ.js.map +1 -0
- package/dist/{chunk-GNBPXJC6.js → chunk-KL652GO5.js} +2 -2
- package/dist/{chunk-4IOC4SP6.js → chunk-KLDNHX4Z.js} +4 -4
- package/dist/{chunk-SHSSCEGO.js → chunk-MG7JYQN2.js} +2 -2
- package/dist/chunk-MG7JYQN2.js.map +1 -0
- package/dist/{chunk-WU4ODZKR.js → chunk-OZ2GZHWH.js} +13 -4
- package/dist/chunk-OZ2GZHWH.js.map +1 -0
- package/dist/{chunk-GI6APIEU.js → chunk-R4AJ2EE3.js} +4 -4
- package/dist/evals/advanced-metrics.js +3 -3
- package/dist/evals/cli.js +3 -3
- package/dist/evals/index.js +7 -7
- package/dist/evals/metrics.js +3 -3
- package/dist/evals/runner.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -9
- package/dist/internal/agent-runtime/agent-run.js +3 -3
- package/dist/internal/agent-runtime/execution.js +1 -1
- package/dist/internal/agent-runtime/tool-execution.js +2 -2
- package/dist/internal/agent.d.ts +7 -2
- package/dist/internal/agent.js +6 -6
- package/dist/internal/team-runtime/run.js +6 -6
- package/dist/skills/index.js +2 -2
- package/dist/skills/load.js +1 -1
- package/dist/skills/tools.js +1 -1
- package/dist/think-tool-CTuagAtn.d.ts +44 -0
- package/dist/tool/index.d.ts +1 -1
- package/dist/tool/index.js +5 -1
- package/dist/tool/question-tool.js +5 -1
- package/package.json +1 -1
- package/dist/chunk-MNBKSRS5.js +0 -47
- package/dist/chunk-MNBKSRS5.js.map +0 -1
- package/dist/chunk-SHSSCEGO.js.map +0 -1
- package/dist/chunk-WU4ODZKR.js.map +0 -1
- package/dist/think-tool-DJbtUDZm.d.ts +0 -40
- /package/dist/{chunk-7XDM7A3W.js.map → chunk-22E25UM7.js.map} +0 -0
- /package/dist/{chunk-2K7NSWUC.js.map → chunk-AGOZCYFP.js.map} +0 -0
- /package/dist/{chunk-PLJQ4274.js.map → chunk-CKWIXVXM.js.map} +0 -0
- /package/dist/{chunk-GSMLYI4Z.js.map → chunk-D43A3KOF.js.map} +0 -0
- /package/dist/{chunk-DRSKZVC6.js.map → chunk-ED7RKQHE.js.map} +0 -0
- /package/dist/{chunk-TXWNIEZU.js.map → chunk-HF5SX5BQ.js.map} +0 -0
- /package/dist/{chunk-GNBPXJC6.js.map → chunk-KL652GO5.js.map} +0 -0
- /package/dist/{chunk-4IOC4SP6.js.map → chunk-KLDNHX4Z.js.map} +0 -0
- /package/dist/{chunk-GI6APIEU.js.map → chunk-R4AJ2EE3.js.map} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ToolCallExecutor
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-ED7RKQHE.js";
|
|
4
4
|
import "../../chunk-5IURMWFN.js";
|
|
5
5
|
import "../../chunk-2NLINXRF.js";
|
|
6
6
|
import "../../chunk-JMJFK3A4.js";
|
|
7
|
-
import "../../chunk-
|
|
7
|
+
import "../../chunk-IRXAEVEQ.js";
|
|
8
8
|
import "../../chunk-CASF2TDK.js";
|
|
9
9
|
import "../../chunk-4AW2633B.js";
|
|
10
10
|
import "../../chunk-OJF67RNM.js";
|
package/dist/internal/agent.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { R as ResolvedAgentOptions, A as Agent } from '../agent-BuX5AXsO.js';
|
|
2
|
-
import { d as CompletionModel, P as ProviderTool, M as Message, U as Usage, k as CompletionResponse, j as CompletionRequest, y as ToolCallPart, G as ToolResultContentPart } from '../types-DYqZKDA8.js';
|
|
2
|
+
import { d as CompletionModel, P as ProviderTool, M as Message, U as Usage, k as CompletionResponse, O as UserMessage, j as CompletionRequest, y as ToolCallPart, G as ToolResultContentPart } from '../types-DYqZKDA8.js';
|
|
3
3
|
import { T as ToolIndex } from '../dynamic-tools-B3OjYyhC.js';
|
|
4
4
|
import { A as AnyTool, c as ToolCallContext, N as NormalizedToolOutput } from '../tool-W1cAPuRF.js';
|
|
5
5
|
import { e as MemoryCompactionInfo, G as MemoryTokenCounter, o as MemoryCompactor, B as MemoryScope } from '../types-CWh9AQrq.js';
|
|
@@ -65,7 +65,7 @@ declare function finishLoopContext(plan: LoopContextPlan, result: {
|
|
|
65
65
|
}, counter?: MemoryTokenCounter, signal?: AbortSignal, attempts?: number): Promise<PreparedLoopContext>;
|
|
66
66
|
|
|
67
67
|
/** Runtime capability marker: older core versions must fail before accepting durable work. */
|
|
68
|
-
declare const AGENT_RUN_EXECUTION_VERSION =
|
|
68
|
+
declare const AGENT_RUN_EXECUTION_VERSION = 4;
|
|
69
69
|
/** Normalized generation progress; never includes raw provider responses. */
|
|
70
70
|
type AgentCompletionStreamEvent = Extract<AgentStreamEvent<unknown, unknown>, {
|
|
71
71
|
type: "text_delta" | "reasoning_delta" | "tool_call_delta" | "tool_call" | "source" | "provider_tool_call";
|
|
@@ -81,6 +81,11 @@ type AgentToolExecutionResult = {
|
|
|
81
81
|
};
|
|
82
82
|
/** Internal persistence boundary used by execution runtimes. Callbacks own external effects. */
|
|
83
83
|
interface AgentRunExecution {
|
|
84
|
+
/** Synchronously checkpoint queued input at a safe boundary, including empty/closing drains. */
|
|
85
|
+
drainSteering?(turn: number, closing: boolean): {
|
|
86
|
+
id: string;
|
|
87
|
+
messages: UserMessage[];
|
|
88
|
+
}[];
|
|
84
89
|
/** Persist the context selected before each model call, including skipped compaction decisions. */
|
|
85
90
|
prepareMessages?(turn: number, messages: readonly Message[], checkpoint?: LoopContextCheckpoint): Promise<PreparedLoopContext>;
|
|
86
91
|
completion(turn: number, request: CompletionRequest, execute: () => Promise<CompletionResponse>): Promise<CompletionResponse>;
|
package/dist/internal/agent.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AGENT_RUN_EXECUTION_VERSION
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-MG7JYQN2.js";
|
|
4
4
|
import {
|
|
5
5
|
createResolvedAgent,
|
|
6
6
|
getResolvedAgentOptions
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-22E25UM7.js";
|
|
8
8
|
import {
|
|
9
9
|
Agent
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import "../chunk-
|
|
10
|
+
} from "../chunk-HF5SX5BQ.js";
|
|
11
|
+
import "../chunk-OZ2GZHWH.js";
|
|
12
12
|
import "../chunk-SXE4J43E.js";
|
|
13
|
-
import "../chunk-
|
|
13
|
+
import "../chunk-ED7RKQHE.js";
|
|
14
14
|
import "../chunk-LAIATEUB.js";
|
|
15
15
|
import "../chunk-3F6ZY63S.js";
|
|
16
16
|
import {
|
|
@@ -29,7 +29,7 @@ import "../chunk-5ZM5DB3O.js";
|
|
|
29
29
|
import "../chunk-5IURMWFN.js";
|
|
30
30
|
import "../chunk-2NLINXRF.js";
|
|
31
31
|
import "../chunk-JMJFK3A4.js";
|
|
32
|
-
import "../chunk-
|
|
32
|
+
import "../chunk-IRXAEVEQ.js";
|
|
33
33
|
import "../chunk-CASF2TDK.js";
|
|
34
34
|
import "../chunk-4AW2633B.js";
|
|
35
35
|
import "../chunk-YNA3UR42.js";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TeamRun
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-CKWIXVXM.js";
|
|
4
4
|
import "../../chunk-PIMD4DYG.js";
|
|
5
5
|
import "../../chunk-FSBDE6RF.js";
|
|
6
6
|
import "../../chunk-X35O3AQG.js";
|
|
7
7
|
import "../../chunk-ENZ2XX27.js";
|
|
8
|
-
import "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
10
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-22E25UM7.js";
|
|
9
|
+
import "../../chunk-HF5SX5BQ.js";
|
|
10
|
+
import "../../chunk-OZ2GZHWH.js";
|
|
11
11
|
import "../../chunk-SXE4J43E.js";
|
|
12
|
-
import "../../chunk-
|
|
12
|
+
import "../../chunk-ED7RKQHE.js";
|
|
13
13
|
import "../../chunk-LAIATEUB.js";
|
|
14
14
|
import "../../chunk-3F6ZY63S.js";
|
|
15
15
|
import "../../chunk-ZWYMXBGB.js";
|
|
@@ -21,7 +21,7 @@ import "../../chunk-5ZM5DB3O.js";
|
|
|
21
21
|
import "../../chunk-5IURMWFN.js";
|
|
22
22
|
import "../../chunk-2NLINXRF.js";
|
|
23
23
|
import "../../chunk-JMJFK3A4.js";
|
|
24
|
-
import "../../chunk-
|
|
24
|
+
import "../../chunk-IRXAEVEQ.js";
|
|
25
25
|
import "../../chunk-CASF2TDK.js";
|
|
26
26
|
import "../../chunk-4AW2633B.js";
|
|
27
27
|
import "../../chunk-YNA3UR42.js";
|
package/dist/skills/index.js
CHANGED
|
@@ -6,14 +6,14 @@ import "../chunk-JBQNCUXA.js";
|
|
|
6
6
|
import {
|
|
7
7
|
skill
|
|
8
8
|
} from "../chunk-ZUFS6R7L.js";
|
|
9
|
+
import "../chunk-5G4NMOTJ.js";
|
|
9
10
|
import {
|
|
10
11
|
SkillValidationError
|
|
11
12
|
} from "../chunk-B5JQDR33.js";
|
|
12
|
-
import "../chunk-5G4NMOTJ.js";
|
|
13
13
|
import "../chunk-V4OZ7ISA.js";
|
|
14
14
|
import "../chunk-2NLINXRF.js";
|
|
15
15
|
import "../chunk-JMJFK3A4.js";
|
|
16
|
-
import "../chunk-
|
|
16
|
+
import "../chunk-IRXAEVEQ.js";
|
|
17
17
|
import "../chunk-CASF2TDK.js";
|
|
18
18
|
import "../chunk-4AW2633B.js";
|
|
19
19
|
import "../chunk-VUY2C2QD.js";
|
package/dist/skills/load.js
CHANGED
|
@@ -5,7 +5,7 @@ import "../chunk-JBQNCUXA.js";
|
|
|
5
5
|
import "../chunk-5G4NMOTJ.js";
|
|
6
6
|
import "../chunk-2NLINXRF.js";
|
|
7
7
|
import "../chunk-JMJFK3A4.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-IRXAEVEQ.js";
|
|
9
9
|
import "../chunk-CASF2TDK.js";
|
|
10
10
|
import "../chunk-4AW2633B.js";
|
|
11
11
|
import "../chunk-VUY2C2QD.js";
|
package/dist/skills/tools.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "../chunk-5G4NMOTJ.js";
|
|
4
4
|
import "../chunk-2NLINXRF.js";
|
|
5
5
|
import "../chunk-JMJFK3A4.js";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-IRXAEVEQ.js";
|
|
7
7
|
import "../chunk-CASF2TDK.js";
|
|
8
8
|
import "../chunk-4AW2633B.js";
|
|
9
9
|
import "../chunk-VUY2C2QD.js";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Z as ZodSchema } from './zod-schema-C7F4clpm.js';
|
|
3
|
+
import { e as ToolRequiresApproval, c as ToolCallContext, T as Tool } from './tool-W1cAPuRF.js';
|
|
4
|
+
import { AgentQuestionPrompt, AgentQuestionAnswer } from './agent/interactions/index.js';
|
|
5
|
+
|
|
6
|
+
type CreateToolOptions<InputSchema extends ZodSchema, OutputSchema extends ZodSchema | undefined = undefined, Output = unknown> = {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
inputSchema: InputSchema;
|
|
10
|
+
outputSchema?: OutputSchema;
|
|
11
|
+
requiresApproval?: ToolRequiresApproval<z.output<InputSchema>>;
|
|
12
|
+
execute(args: z.output<InputSchema>, context: ToolCallContext): OutputSchema extends ZodSchema ? z.input<OutputSchema> | Promise<z.input<OutputSchema>> : Output | Promise<Output>;
|
|
13
|
+
};
|
|
14
|
+
declare function createTool<InputSchema extends ZodSchema, Output = unknown>(options: CreateToolOptions<InputSchema, undefined, Output> & {
|
|
15
|
+
outputSchema?: undefined;
|
|
16
|
+
}): Tool<z.output<InputSchema>, Output>;
|
|
17
|
+
declare function createTool<InputSchema extends ZodSchema, OutputSchema extends ZodSchema>(options: CreateToolOptions<InputSchema, OutputSchema>): Tool<z.output<InputSchema>, z.output<OutputSchema>>;
|
|
18
|
+
|
|
19
|
+
declare const DEFAULT_QUESTION_TOOL_NAME = "ask_user";
|
|
20
|
+
declare const DEFAULT_QUESTION_TOOL_DESCRIPTION = "Ask the user questions and wait for their answers before continuing.\n\nUse this tool only when you cannot continue without the user's input:\n- The request is ambiguous, and different readings would lead to clearly different results.\n- A decision belongs to the user: a preference, a tradeoff, or something that is hard to undo.\n- Information you need is missing and you cannot find it with your other tools or work it out from the conversation.\n\nDo not use it:\n- For facts you can look up with your other tools, or work out from the conversation.\n- To ask permission for routine steps the user has already asked for.\n- To check whether your answer or plan is good. Finish the work and let the user react.\n- For choices with a sensible default. Pick it, and mention the choice in your reply.\n\nHow to ask:\n- Put every question you need into one call instead of calling the tool repeatedly. Ask no more than 4 questions per call.\n- Give each question a short, unique `id` in snake_case.\n- Write `text` as one complete, self-contained question that ends with a question mark.\n- When there is a known set of reasonable answers, give 2\u20134 `choices` with a short `label` and a stable `value`. Make the choices mutually exclusive. If you recommend one, list it first and add \" (recommended)\" to its label.\n- Set `allowCustom: true` when the user might want an answer outside the list. Leave out `choices` for open-ended questions. Do not add an \"Other\" choice.\n\nAfter you get the answers:\n- Each answer has a `questionId` and a `value` (the chosen value or the user's free text).\n- Follow the answers. Do not ask the same question again unless an answer is unclear or contradicts another one.";
|
|
21
|
+
type QuestionToolInput = {
|
|
22
|
+
questions: readonly AgentQuestionPrompt[];
|
|
23
|
+
};
|
|
24
|
+
type QuestionToolOutput = {
|
|
25
|
+
answers: readonly AgentQuestionAnswer[];
|
|
26
|
+
};
|
|
27
|
+
type CreateQuestionToolOptions = {
|
|
28
|
+
/** Defaults when omitted. Supply a nonblank name; explicit strings are preserved. */
|
|
29
|
+
name?: string;
|
|
30
|
+
/** Defaults when omitted. Supply nonblank instructions; explicit strings are preserved. */
|
|
31
|
+
description?: string;
|
|
32
|
+
};
|
|
33
|
+
declare function createQuestionTool(options?: CreateQuestionToolOptions): Tool<QuestionToolInput, QuestionToolOutput>;
|
|
34
|
+
declare function isQuestionTool(tool: unknown): tool is Tool<QuestionToolInput, QuestionToolOutput>;
|
|
35
|
+
|
|
36
|
+
type CreateThinkToolOptions = {
|
|
37
|
+
name?: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
};
|
|
40
|
+
declare function createThinkTool(options?: CreateThinkToolOptions): Tool<{
|
|
41
|
+
thought: string;
|
|
42
|
+
}, string>;
|
|
43
|
+
|
|
44
|
+
export { type CreateToolOptions as C, DEFAULT_QUESTION_TOOL_DESCRIPTION as D, type QuestionToolInput as Q, DEFAULT_QUESTION_TOOL_NAME as a, createThinkTool as b, createQuestionTool as c, createTool as d, type CreateQuestionToolOptions as e, type CreateThinkToolOptions as f, type QuestionToolOutput as g, isQuestionTool as i };
|
package/dist/tool/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { e as CreateQuestionToolOptions, f as CreateThinkToolOptions, C as CreateToolOptions, D as DEFAULT_QUESTION_TOOL_DESCRIPTION, a as DEFAULT_QUESTION_TOOL_NAME, Q as QuestionToolInput, g as QuestionToolOutput, c as createQuestionTool, b as createThinkTool, d as createTool, i as isQuestionTool } from '../think-tool-CTuagAtn.js';
|
|
2
2
|
export { C as CreateToolIndexOptions, E as EmbedToolsOptions, T as ToolIndex, a as ToolSearchDocument, c as createToolIndex, e as embedTools, i as isToolIndex } from '../dynamic-tools-B3OjYyhC.js';
|
|
3
3
|
export { k as AgentMiddleware, C as CompletionRequestMiddlewareArgs, z as CompletionRequestMiddlewareResult, B as CompletionResponseMiddlewareArgs, D as CompletionResponseMiddlewareResult, T as ToolInputMiddlewareArgs, E as ToolInputMiddlewareResult, F as ToolOutputMiddlewareArgs, G as ToolOutputMiddlewareResult, H as ToolResultMiddlewareArgs, I as createMiddleware } from '../middleware-D_kNSjzW.js';
|
|
4
4
|
export { A as AnyTool, N as NormalizedToolOutput, R as RichToolOutput, T as Tool, a as ToolApprovalContext, b as ToolApprovalRequirement, f as ToolApprovalRunContext, c as ToolCallContext, d as ToolCallStreamEvent, g as ToolOutput, e as ToolRequiresApproval, h as ToolResultSerializationError, n as normalizeToolResultOutput, p as parseToolArgs, t as toolResultContentToText } from '../tool-W1cAPuRF.js';
|
package/dist/tool/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import "../chunk-JMJFK3A4.js";
|
|
2
2
|
import {
|
|
3
|
+
DEFAULT_QUESTION_TOOL_DESCRIPTION,
|
|
4
|
+
DEFAULT_QUESTION_TOOL_NAME,
|
|
3
5
|
createQuestionTool,
|
|
4
6
|
isQuestionTool
|
|
5
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-IRXAEVEQ.js";
|
|
6
8
|
import {
|
|
7
9
|
createThinkTool
|
|
8
10
|
} from "../chunk-CASF2TDK.js";
|
|
@@ -51,6 +53,8 @@ import "../chunk-SQAAVYJG.js";
|
|
|
51
53
|
import "../chunk-POXHJF3H.js";
|
|
52
54
|
import "../chunk-USRKPEQN.js";
|
|
53
55
|
export {
|
|
56
|
+
DEFAULT_QUESTION_TOOL_DESCRIPTION,
|
|
57
|
+
DEFAULT_QUESTION_TOOL_NAME,
|
|
54
58
|
ToolCallError,
|
|
55
59
|
ToolJsonError,
|
|
56
60
|
ToolNotFoundError,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DEFAULT_QUESTION_TOOL_DESCRIPTION,
|
|
3
|
+
DEFAULT_QUESTION_TOOL_NAME,
|
|
2
4
|
createQuestionTool,
|
|
3
5
|
isQuestionTool
|
|
4
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-IRXAEVEQ.js";
|
|
5
7
|
import "../chunk-MEFGXAKJ.js";
|
|
6
8
|
import "../chunk-27MBNR47.js";
|
|
7
9
|
import "../chunk-YZVFIW5D.js";
|
|
@@ -11,6 +13,8 @@ import "../chunk-BONQTXRQ.js";
|
|
|
11
13
|
import "../chunk-4C7AXYOM.js";
|
|
12
14
|
import "../chunk-SQAAVYJG.js";
|
|
13
15
|
export {
|
|
16
|
+
DEFAULT_QUESTION_TOOL_DESCRIPTION,
|
|
17
|
+
DEFAULT_QUESTION_TOOL_NAME,
|
|
14
18
|
createQuestionTool,
|
|
15
19
|
isQuestionTool
|
|
16
20
|
};
|
package/package.json
CHANGED
package/dist/chunk-MNBKSRS5.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createTool
|
|
3
|
-
} from "./chunk-MEFGXAKJ.js";
|
|
4
|
-
|
|
5
|
-
// src/tool/question-tool.ts
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
var questionToolMarker = /* @__PURE__ */ Symbol("anvia.question-tool");
|
|
8
|
-
function createQuestionTool(options) {
|
|
9
|
-
const tool = createTool({
|
|
10
|
-
name: options.name,
|
|
11
|
-
description: options.description,
|
|
12
|
-
inputSchema: z.object({
|
|
13
|
-
questions: z.array(
|
|
14
|
-
z.object({
|
|
15
|
-
id: z.string().trim().min(1),
|
|
16
|
-
text: z.string().trim().min(1),
|
|
17
|
-
choices: z.array(
|
|
18
|
-
z.object({
|
|
19
|
-
label: z.string().trim().min(1),
|
|
20
|
-
value: z.string().trim().min(1)
|
|
21
|
-
}).strict()
|
|
22
|
-
).min(1).optional(),
|
|
23
|
-
allowCustom: z.boolean().optional()
|
|
24
|
-
}).strict()
|
|
25
|
-
).min(1)
|
|
26
|
-
}).strict(),
|
|
27
|
-
execute() {
|
|
28
|
-
throw new Error("Question tools can only be resolved through an Agent interaction.");
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(tool, questionToolMarker, {
|
|
32
|
-
configurable: false,
|
|
33
|
-
enumerable: false,
|
|
34
|
-
value: true,
|
|
35
|
-
writable: false
|
|
36
|
-
});
|
|
37
|
-
return tool;
|
|
38
|
-
}
|
|
39
|
-
function isQuestionTool(tool) {
|
|
40
|
-
return typeof tool === "object" && tool !== null && questionToolMarker in tool;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export {
|
|
44
|
-
createQuestionTool,
|
|
45
|
-
isQuestionTool
|
|
46
|
-
};
|
|
47
|
-
//# sourceMappingURL=chunk-MNBKSRS5.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tool/question-tool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { AgentQuestionAnswer, AgentQuestionPrompt } from \"../agent/interactions\";\nimport { createTool } from \"./create-tool\";\nimport type { Tool } from \"./tool\";\n\nconst questionToolMarker = Symbol(\"anvia.question-tool\");\n\nexport type QuestionToolInput = {\n questions: readonly AgentQuestionPrompt[];\n};\n\nexport type QuestionToolOutput = {\n answers: readonly AgentQuestionAnswer[];\n};\n\nexport type CreateQuestionToolOptions = {\n name: string;\n description: string;\n};\n\ntype MarkedQuestionTool = Tool<QuestionToolInput, QuestionToolOutput> & {\n readonly [questionToolMarker]: true;\n};\n\nexport function createQuestionTool(\n options: CreateQuestionToolOptions,\n): Tool<QuestionToolInput, QuestionToolOutput> {\n const tool = createTool({\n name: options.name,\n description: options.description,\n inputSchema: z\n .object({\n questions: z\n .array(\n z\n .object({\n id: z.string().trim().min(1),\n text: z.string().trim().min(1),\n choices: z\n .array(\n z\n .object({\n label: z.string().trim().min(1),\n value: z.string().trim().min(1),\n })\n .strict(),\n )\n .min(1)\n .optional(),\n allowCustom: z.boolean().optional(),\n })\n .strict(),\n )\n .min(1),\n })\n .strict(),\n execute(): never {\n throw new Error(\"Question tools can only be resolved through an Agent interaction.\");\n },\n }) as unknown as MarkedQuestionTool;\n Object.defineProperty(tool, questionToolMarker, {\n configurable: false,\n enumerable: false,\n value: true,\n writable: false,\n });\n return tool;\n}\n\nexport function isQuestionTool(tool: unknown): tool is Tool<QuestionToolInput, QuestionToolOutput> {\n return typeof tool === \"object\" && tool !== null && questionToolMarker in tool;\n}\n"],"mappings":";;;;;AAAA,SAAS,SAAS;AAKlB,IAAM,qBAAqB,uBAAO,qBAAqB;AAmBhD,SAAS,mBACd,SAC6C;AAC7C,QAAM,OAAO,WAAW;AAAA,IACtB,MAAM,QAAQ;AAAA,IACd,aAAa,QAAQ;AAAA,IACrB,aAAa,EACV,OAAO;AAAA,MACN,WAAW,EACR;AAAA,QACC,EACG,OAAO;AAAA,UACN,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;AAAA,UAC3B,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;AAAA,UAC7B,SAAS,EACN;AAAA,YACC,EACG,OAAO;AAAA,cACN,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;AAAA,cAC9B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;AAAA,YAChC,CAAC,EACA,OAAO;AAAA,UACZ,EACC,IAAI,CAAC,EACL,SAAS;AAAA,UACZ,aAAa,EAAE,QAAQ,EAAE,SAAS;AAAA,QACpC,CAAC,EACA,OAAO;AAAA,MACZ,EACC,IAAI,CAAC;AAAA,IACV,CAAC,EACA,OAAO;AAAA,IACV,UAAiB;AACf,YAAM,IAAI,MAAM,mEAAmE;AAAA,IACrF;AAAA,EACF,CAAC;AACD,SAAO,eAAe,MAAM,oBAAoB;AAAA,IAC9C,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,UAAU;AAAA,EACZ,CAAC;AACD,SAAO;AACT;AAEO,SAAS,eAAe,MAAoE;AACjG,SAAO,OAAO,SAAS,YAAY,SAAS,QAAQ,sBAAsB;AAC5E;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/agent-runtime/execution.ts"],"sourcesContent":["import type { PreparedLoopContext, LoopContextCheckpoint } from \"./loop-context\";\nimport type {\n CompletionRequest,\n CompletionResponse,\n ToolCallPart,\n Message,\n} from \"../../completion\";\nimport type { NormalizedToolOutput, ToolCallContext } from \"../../tool\";\nimport type { AgentStreamEvent } from \"../../agent/run-types\";\n\n/** Runtime capability marker: older core versions must fail before accepting durable work. */\nexport const AGENT_RUN_EXECUTION_VERSION = 3;\n\n/** Normalized generation progress; never includes raw provider responses. */\nexport type AgentCompletionStreamEvent = Extract<\n AgentStreamEvent<unknown, unknown>,\n {\n type:\n | \"text_delta\"\n | \"reasoning_delta\"\n | \"tool_call_delta\"\n | \"tool_call\"\n | \"source\"\n | \"provider_tool_call\";\n }\n>;\n\nexport type AgentCompletionStream = AsyncGenerator<AgentCompletionStreamEvent, CompletionResponse>;\n\nexport type AgentToolExecutionResult =\n | { output: NormalizedToolOutput; failed: false }\n | { output: NormalizedToolOutput; failed: true; error: unknown };\n\n/** Internal persistence boundary used by execution runtimes. Callbacks own external effects. */\nexport interface AgentRunExecution {\n /** Persist the context selected before each model call, including skipped compaction decisions. */\n prepareMessages?(\n turn: number,\n messages: readonly Message[],\n checkpoint?: LoopContextCheckpoint,\n ): Promise<PreparedLoopContext>;\n completion(\n turn: number,\n request: CompletionRequest,\n execute: () => Promise<CompletionResponse>,\n ): Promise<CompletionResponse>;\n streamCompletion?(\n turn: number,\n request: CompletionRequest,\n execute: () => AgentCompletionStream,\n ): AgentCompletionStream;\n tool(\n call: { turn: number; toolCall: ToolCallPart; args: string },\n execute: (context?: Pick<ToolCallContext, \"operationId\">) => Promise<AgentToolExecutionResult>,\n ): Promise<AgentToolExecutionResult>;\n}\n"],"mappings":";AAWO,IAAM,8BAA8B;","names":[]}
|