@strands-agents/sdk 0.7.0 → 1.0.0-rc.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 +7 -7
- package/dist/src/__fixtures__/agent-helpers.d.ts +44 -0
- package/dist/src/__fixtures__/agent-helpers.d.ts.map +1 -1
- package/dist/src/__fixtures__/agent-helpers.js +45 -0
- package/dist/src/__fixtures__/agent-helpers.js.map +1 -1
- package/dist/src/__fixtures__/mock-plugin.d.ts.map +1 -1
- package/dist/src/__fixtures__/mock-plugin.js +3 -1
- package/dist/src/__fixtures__/mock-plugin.js.map +1 -1
- package/dist/src/__fixtures__/tool-helpers.d.ts.map +1 -1
- package/dist/src/__fixtures__/tool-helpers.js +1 -0
- package/dist/src/__fixtures__/tool-helpers.js.map +1 -1
- package/dist/src/a2a/__tests__/events.test.d.ts +2 -0
- package/dist/src/a2a/__tests__/events.test.d.ts.map +1 -0
- package/dist/src/a2a/__tests__/events.test.js +66 -0
- package/dist/src/a2a/__tests__/events.test.js.map +1 -0
- package/dist/src/a2a/a2a-agent.d.ts.map +1 -1
- package/dist/src/a2a/a2a-agent.js +1 -1
- package/dist/src/a2a/a2a-agent.js.map +1 -1
- package/dist/src/a2a/events.d.ts +2 -0
- package/dist/src/a2a/events.d.ts.map +1 -1
- package/dist/src/a2a/events.js +6 -0
- package/dist/src/a2a/events.js.map +1 -1
- package/dist/src/a2a/index.d.ts +0 -1
- package/dist/src/a2a/index.d.ts.map +1 -1
- package/dist/src/a2a/index.js +0 -1
- package/dist/src/a2a/index.js.map +1 -1
- package/dist/src/a2a/server.d.ts +1 -1
- package/dist/src/a2a/server.js +1 -1
- package/dist/src/agent/__tests__/agent.hook.test.js +229 -1
- package/dist/src/agent/__tests__/agent.hook.test.js.map +1 -1
- package/dist/src/agent/__tests__/agent.test.js +215 -42
- package/dist/src/agent/__tests__/agent.test.js.map +1 -1
- package/dist/src/agent/__tests__/agent.tracer.test.node.d.ts +2 -0
- package/dist/src/agent/__tests__/agent.tracer.test.node.d.ts.map +1 -0
- package/dist/src/agent/__tests__/{agent.tracer.test.js → agent.tracer.test.node.js} +52 -40
- package/dist/src/agent/__tests__/agent.tracer.test.node.js.map +1 -0
- package/dist/src/agent/__tests__/printer.test.js +7 -7
- package/dist/src/agent/__tests__/printer.test.js.map +1 -1
- package/dist/src/agent/__tests__/snapshot.test.js +39 -2
- package/dist/src/agent/__tests__/snapshot.test.js.map +1 -1
- package/dist/src/agent/agent.d.ts +16 -1
- package/dist/src/agent/agent.d.ts.map +1 -1
- package/dist/src/agent/agent.js +170 -94
- package/dist/src/agent/agent.js.map +1 -1
- package/dist/src/agent/printer.d.ts.map +1 -1
- package/dist/src/agent/printer.js +3 -0
- package/dist/src/agent/printer.js.map +1 -1
- package/dist/src/agent/snapshot.d.ts +3 -3
- package/dist/src/agent/snapshot.d.ts.map +1 -1
- package/dist/src/agent/snapshot.js +14 -7
- package/dist/src/agent/snapshot.js.map +1 -1
- package/dist/src/conversation-manager/__tests__/sliding-window-conversation-manager.test.js +72 -46
- package/dist/src/conversation-manager/__tests__/sliding-window-conversation-manager.test.js.map +1 -1
- package/dist/src/conversation-manager/sliding-window-conversation-manager.d.ts.map +1 -1
- package/dist/src/conversation-manager/sliding-window-conversation-manager.js +14 -7
- package/dist/src/conversation-manager/sliding-window-conversation-manager.js.map +1 -1
- package/dist/src/errors.d.ts +8 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +11 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/hooks/__tests__/events.test.js +387 -0
- package/dist/src/hooks/__tests__/events.test.js.map +1 -1
- package/dist/src/hooks/events.d.ts +104 -0
- package/dist/src/hooks/events.d.ts.map +1 -1
- package/dist/src/hooks/events.js +137 -0
- package/dist/src/hooks/events.js.map +1 -1
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/models/__tests__/anthropic.test.js +1 -2
- package/dist/src/models/__tests__/anthropic.test.js.map +1 -1
- package/dist/src/models/__tests__/bedrock.test.js +18 -18
- package/dist/src/models/__tests__/bedrock.test.js.map +1 -1
- package/dist/src/models/__tests__/google.test.d.ts +2 -0
- package/dist/src/models/__tests__/google.test.d.ts.map +1 -0
- package/dist/src/models/__tests__/{gemini.test.js → google.test.js} +55 -21
- package/dist/src/models/__tests__/google.test.js.map +1 -0
- package/dist/src/models/__tests__/openai.test.js +78 -71
- package/dist/src/models/__tests__/openai.test.js.map +1 -1
- package/dist/src/models/anthropic.d.ts.map +1 -1
- package/dist/src/models/anthropic.js +8 -7
- package/dist/src/models/anthropic.js.map +1 -1
- package/dist/src/models/bedrock.d.ts +3 -3
- package/dist/src/models/bedrock.d.ts.map +1 -1
- package/dist/src/models/bedrock.js +7 -7
- package/dist/src/models/bedrock.js.map +1 -1
- package/dist/src/models/{gemini → google}/adapters.d.ts +3 -3
- package/dist/src/models/{gemini → google}/adapters.d.ts.map +1 -1
- package/dist/src/models/{gemini → google}/adapters.js +1 -1
- package/dist/src/models/{gemini → google}/adapters.js.map +1 -1
- package/dist/src/models/{gemini → google}/errors.d.ts +7 -7
- package/dist/src/models/google/errors.d.ts.map +1 -0
- package/dist/src/models/{gemini → google}/errors.js +11 -5
- package/dist/src/models/google/errors.js.map +1 -0
- package/dist/src/models/google/index.d.ts +15 -0
- package/dist/src/models/google/index.d.ts.map +1 -0
- package/dist/src/models/google/index.js +15 -0
- package/dist/src/models/google/index.js.map +1 -0
- package/dist/src/models/{gemini → google}/model.d.ts +18 -18
- package/dist/src/models/{gemini → google}/model.d.ts.map +1 -1
- package/dist/src/models/{gemini → google}/model.js +22 -19
- package/dist/src/models/google/model.js.map +1 -0
- package/dist/src/models/{gemini → google}/types.d.ts +9 -9
- package/dist/src/models/{gemini → google}/types.d.ts.map +1 -1
- package/dist/src/models/google/types.js +5 -0
- package/dist/src/models/google/types.js.map +1 -0
- package/dist/src/models/model.js +2 -2
- package/dist/src/models/model.js.map +1 -1
- package/dist/src/models/openai.d.ts +29 -11
- package/dist/src/models/openai.d.ts.map +1 -1
- package/dist/src/models/openai.js +25 -15
- package/dist/src/models/openai.js.map +1 -1
- package/dist/src/models/streaming.d.ts +13 -0
- package/dist/src/models/streaming.d.ts.map +1 -1
- package/dist/src/models/streaming.js +29 -0
- package/dist/src/models/streaming.js.map +1 -1
- package/dist/src/multiagent/__tests__/events.test.js +177 -0
- package/dist/src/multiagent/__tests__/events.test.js.map +1 -1
- package/dist/src/multiagent/__tests__/graph.tracer.test.d.ts +2 -0
- package/dist/src/multiagent/__tests__/graph.tracer.test.d.ts.map +1 -0
- package/dist/src/multiagent/__tests__/graph.tracer.test.js +204 -0
- package/dist/src/multiagent/__tests__/graph.tracer.test.js.map +1 -0
- package/dist/src/multiagent/__tests__/nodes.test.js +48 -5
- package/dist/src/multiagent/__tests__/nodes.test.js.map +1 -1
- package/dist/src/multiagent/__tests__/swarm.test.js +34 -6
- package/dist/src/multiagent/__tests__/swarm.test.js.map +1 -1
- package/dist/src/multiagent/__tests__/swarm.tracer.test.d.ts +2 -0
- package/dist/src/multiagent/__tests__/swarm.tracer.test.d.ts.map +1 -0
- package/dist/src/multiagent/__tests__/swarm.tracer.test.js +235 -0
- package/dist/src/multiagent/__tests__/swarm.tracer.test.js.map +1 -0
- package/dist/src/multiagent/events.d.ts +14 -0
- package/dist/src/multiagent/events.d.ts.map +1 -1
- package/dist/src/multiagent/events.js +34 -0
- package/dist/src/multiagent/events.js.map +1 -1
- package/dist/src/multiagent/graph.d.ts +4 -0
- package/dist/src/multiagent/graph.d.ts.map +1 -1
- package/dist/src/multiagent/graph.js +42 -16
- package/dist/src/multiagent/graph.js.map +1 -1
- package/dist/src/multiagent/index.d.ts +1 -1
- package/dist/src/multiagent/index.d.ts.map +1 -1
- package/dist/src/multiagent/index.js.map +1 -1
- package/dist/src/multiagent/nodes.d.ts +23 -9
- package/dist/src/multiagent/nodes.d.ts.map +1 -1
- package/dist/src/multiagent/nodes.js +25 -14
- package/dist/src/multiagent/nodes.js.map +1 -1
- package/dist/src/multiagent/state.d.ts +8 -3
- package/dist/src/multiagent/state.d.ts.map +1 -1
- package/dist/src/multiagent/state.js +18 -4
- package/dist/src/multiagent/state.js.map +1 -1
- package/dist/src/multiagent/swarm.d.ts +15 -1
- package/dist/src/multiagent/swarm.d.ts.map +1 -1
- package/dist/src/multiagent/swarm.js +71 -30
- package/dist/src/multiagent/swarm.js.map +1 -1
- package/dist/src/session/__tests__/session-manager.test.js +36 -0
- package/dist/src/session/__tests__/session-manager.test.js.map +1 -1
- package/dist/src/session/session-manager.d.ts +2 -3
- package/dist/src/session/session-manager.d.ts.map +1 -1
- package/dist/src/session/session-manager.js +11 -9
- package/dist/src/session/session-manager.js.map +1 -1
- package/dist/src/telemetry/__tests__/local-trace.test.d.ts +2 -0
- package/dist/src/telemetry/__tests__/local-trace.test.d.ts.map +1 -0
- package/dist/src/telemetry/__tests__/local-trace.test.js +158 -0
- package/dist/src/telemetry/__tests__/local-trace.test.js.map +1 -0
- package/dist/src/telemetry/__tests__/tracer.test.node.js +28 -0
- package/dist/src/telemetry/__tests__/tracer.test.node.js.map +1 -1
- package/dist/src/telemetry/config.js +1 -1
- package/dist/src/telemetry/config.js.map +1 -1
- package/dist/src/telemetry/meter.d.ts +0 -13
- package/dist/src/telemetry/meter.d.ts.map +1 -1
- package/dist/src/telemetry/meter.js +8 -36
- package/dist/src/telemetry/meter.js.map +1 -1
- package/dist/src/telemetry/tracer.d.ts +107 -18
- package/dist/src/telemetry/tracer.d.ts.map +1 -1
- package/dist/src/telemetry/tracer.js +245 -33
- package/dist/src/telemetry/tracer.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +49 -0
- package/dist/src/telemetry/types.d.ts.map +1 -1
- package/dist/src/tools/__tests__/structured-output-tool.test.d.ts +2 -0
- package/dist/src/tools/__tests__/structured-output-tool.test.d.ts.map +1 -0
- package/dist/src/tools/__tests__/structured-output-tool.test.js +84 -0
- package/dist/src/tools/__tests__/structured-output-tool.test.js.map +1 -0
- package/dist/src/tools/structured-output-tool.d.ts +41 -0
- package/dist/src/tools/structured-output-tool.d.ts.map +1 -0
- package/dist/src/tools/structured-output-tool.js +82 -0
- package/dist/src/tools/structured-output-tool.js.map +1 -0
- package/dist/src/tools/zod-tool.js +1 -1
- package/dist/src/tools/zod-tool.js.map +1 -1
- package/dist/src/{utils/zod.d.ts → tools/zod-utils.d.ts} +1 -1
- package/dist/src/tools/zod-utils.d.ts.map +1 -0
- package/dist/src/{utils/zod.js → tools/zod-utils.js} +1 -1
- package/dist/src/tools/zod-utils.js.map +1 -0
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/src/types/__tests__/agent.test.js +127 -0
- package/dist/src/types/__tests__/agent.test.js.map +1 -1
- package/dist/src/types/agent.d.ts +27 -1
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/agent.js +26 -0
- package/dist/src/types/agent.js.map +1 -1
- package/dist/src/vended-tools/bash/__tests__/bash.test.node.js +12 -0
- package/dist/src/vended-tools/bash/__tests__/bash.test.node.js.map +1 -1
- package/dist/src/vended-tools/bash/bash.d.ts.map +1 -1
- package/dist/src/vended-tools/bash/bash.js +16 -14
- package/dist/src/vended-tools/bash/bash.js.map +1 -1
- package/package.json +12 -8
- package/dist/src/agent/__tests__/agent.tracer.test.d.ts +0 -2
- package/dist/src/agent/__tests__/agent.tracer.test.d.ts.map +0 -1
- package/dist/src/agent/__tests__/agent.tracer.test.js.map +0 -1
- package/dist/src/models/__tests__/gemini.test.d.ts +0 -2
- package/dist/src/models/__tests__/gemini.test.d.ts.map +0 -1
- package/dist/src/models/__tests__/gemini.test.js.map +0 -1
- package/dist/src/models/gemini/errors.d.ts.map +0 -1
- package/dist/src/models/gemini/errors.js.map +0 -1
- package/dist/src/models/gemini/model.js.map +0 -1
- package/dist/src/models/gemini/types.js +0 -5
- package/dist/src/models/gemini/types.js.map +0 -1
- package/dist/src/structured-output/__tests__/context.test.d.ts +0 -2
- package/dist/src/structured-output/__tests__/context.test.d.ts.map +0 -1
- package/dist/src/structured-output/__tests__/context.test.js +0 -201
- package/dist/src/structured-output/__tests__/context.test.js.map +0 -1
- package/dist/src/structured-output/__tests__/exceptions.test.d.ts +0 -2
- package/dist/src/structured-output/__tests__/exceptions.test.d.ts.map +0 -1
- package/dist/src/structured-output/__tests__/exceptions.test.js +0 -103
- package/dist/src/structured-output/__tests__/exceptions.test.js.map +0 -1
- package/dist/src/structured-output/__tests__/tool.test.d.ts +0 -2
- package/dist/src/structured-output/__tests__/tool.test.d.ts.map +0 -1
- package/dist/src/structured-output/__tests__/tool.test.js +0 -256
- package/dist/src/structured-output/__tests__/tool.test.js.map +0 -1
- package/dist/src/structured-output/__tests__/utils.test.d.ts +0 -2
- package/dist/src/structured-output/__tests__/utils.test.d.ts.map +0 -1
- package/dist/src/structured-output/__tests__/utils.test.js +0 -183
- package/dist/src/structured-output/__tests__/utils.test.js.map +0 -1
- package/dist/src/structured-output/context.d.ts +0 -91
- package/dist/src/structured-output/context.d.ts.map +0 -1
- package/dist/src/structured-output/context.js +0 -112
- package/dist/src/structured-output/context.js.map +0 -1
- package/dist/src/structured-output/exceptions.d.ts +0 -18
- package/dist/src/structured-output/exceptions.d.ts.map +0 -1
- package/dist/src/structured-output/exceptions.js +0 -28
- package/dist/src/structured-output/exceptions.js.map +0 -1
- package/dist/src/structured-output/tool.d.ts +0 -33
- package/dist/src/structured-output/tool.d.ts.map +0 -1
- package/dist/src/structured-output/tool.js +0 -73
- package/dist/src/structured-output/tool.js.map +0 -1
- package/dist/src/structured-output/utils.d.ts +0 -23
- package/dist/src/structured-output/utils.d.ts.map +0 -1
- package/dist/src/structured-output/utils.js +0 -104
- package/dist/src/structured-output/utils.js.map +0 -1
- package/dist/src/utils/zod.d.ts.map +0 -1
- package/dist/src/utils/zod.js.map +0 -1
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { StructuredOutputTool } from './tool.js';
|
|
3
|
-
/**
|
|
4
|
-
* Null object implementation that does nothing.
|
|
5
|
-
* Used when no structured output schema is provided.
|
|
6
|
-
*/
|
|
7
|
-
export class NullStructuredOutputContext {
|
|
8
|
-
isEnabled = false;
|
|
9
|
-
registerTool(_registry) {
|
|
10
|
-
// No-op
|
|
11
|
-
}
|
|
12
|
-
storeResult(_toolUseId, _result) {
|
|
13
|
-
// No-op
|
|
14
|
-
}
|
|
15
|
-
hasResult() {
|
|
16
|
-
return true; // Always "has result" to skip forcing logic
|
|
17
|
-
}
|
|
18
|
-
getResult() {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
getToolName() {
|
|
22
|
-
return 'strands_structured_output';
|
|
23
|
-
}
|
|
24
|
-
cleanup(_registry) {
|
|
25
|
-
// No-op
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Context for managing structured output tool lifecycle per-invocation.
|
|
30
|
-
* Handles tool registration, result storage, and cleanup.
|
|
31
|
-
*/
|
|
32
|
-
export class StructuredOutputContext {
|
|
33
|
-
isEnabled = true;
|
|
34
|
-
_schema;
|
|
35
|
-
// The `| undefined` is needed for `exactOptionalPropertyTypes` since we assign undefined in cleanup()
|
|
36
|
-
_tool;
|
|
37
|
-
_result = undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Creates a new StructuredOutputContext.
|
|
40
|
-
*
|
|
41
|
-
* @param schema - Zod schema for structured output
|
|
42
|
-
*/
|
|
43
|
-
constructor(schema) {
|
|
44
|
-
this._schema = schema;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Registers the structured output tool with the tool registry.
|
|
48
|
-
*
|
|
49
|
-
* @param registry - The tool registry to register with
|
|
50
|
-
*/
|
|
51
|
-
registerTool(registry) {
|
|
52
|
-
this._tool = new StructuredOutputTool(this._schema, 'strands_structured_output', this);
|
|
53
|
-
// Register tool (will be removed in cleanup)
|
|
54
|
-
registry.add(this._tool);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Stores the validated result from the structured output tool.
|
|
58
|
-
* If called multiple times, only the latest result is kept.
|
|
59
|
-
*
|
|
60
|
-
* @param toolUseId - The tool use ID (unused, kept for interface compatibility)
|
|
61
|
-
* @param result - The validated result
|
|
62
|
-
*/
|
|
63
|
-
storeResult(toolUseId, result) {
|
|
64
|
-
this._result = result;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Checks if a result has been stored.
|
|
68
|
-
*
|
|
69
|
-
* @returns true if a result has been stored
|
|
70
|
-
*/
|
|
71
|
-
hasResult() {
|
|
72
|
-
return this._result !== undefined;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Retrieves the stored result, if available.
|
|
76
|
-
*
|
|
77
|
-
* @returns The validated result or undefined if not yet stored
|
|
78
|
-
*/
|
|
79
|
-
getResult() {
|
|
80
|
-
return this._result;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Gets the tool name for forcing.
|
|
84
|
-
*
|
|
85
|
-
* @returns The tool name or 'strands_structured_output' as fallback
|
|
86
|
-
*/
|
|
87
|
-
getToolName() {
|
|
88
|
-
return this._tool?.name ?? 'strands_structured_output';
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Cleans up the structured output tool by removing it from the registry.
|
|
92
|
-
* Should be called in a finally block to ensure cleanup happens regardless of success/failure.
|
|
93
|
-
*
|
|
94
|
-
* @param registry - The tool registry to clean up from
|
|
95
|
-
*/
|
|
96
|
-
cleanup(registry) {
|
|
97
|
-
if (this._tool) {
|
|
98
|
-
registry.remove(this._tool.name);
|
|
99
|
-
this._tool = undefined;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Factory function to create the appropriate context based on schema presence.
|
|
105
|
-
*
|
|
106
|
-
* @param schema - Optional Zod schema for structured output
|
|
107
|
-
* @returns StructuredOutputContext if schema provided, NullStructuredOutputContext otherwise
|
|
108
|
-
*/
|
|
109
|
-
export function createStructuredOutputContext(schema) {
|
|
110
|
-
return schema ? new StructuredOutputContext(schema) : new NullStructuredOutputContext();
|
|
111
|
-
}
|
|
112
|
-
//# sourceMappingURL=context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/structured-output/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAgBhD;;;GAGG;AACH,MAAM,OAAO,2BAA2B;IAC7B,SAAS,GAAG,KAAK,CAAA;IAE1B,YAAY,CAAC,SAAuB;QAClC,QAAQ;IACV,CAAC;IAED,WAAW,CAAC,UAAkB,EAAE,OAAgB;QAC9C,QAAQ;IACV,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAA,CAAC,4CAA4C;IAC1D,CAAC;IAED,SAAS;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,WAAW;QACT,OAAO,2BAA2B,CAAA;IACpC,CAAC;IAED,OAAO,CAAC,SAAuB;QAC7B,QAAQ;IACV,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IACzB,SAAS,GAAG,IAAI,CAAA;IAEjB,OAAO,CAAa;IAC5B,sGAAsG;IAC9F,KAAK,CAAmC;IACxC,OAAO,GAAY,SAAS,CAAA;IAEpC;;;;OAIG;IACH,YAAY,MAAmB;QAC7B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACvB,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,QAAsB;QACjC,IAAI,CAAC,KAAK,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,2BAA2B,EAAE,IAAI,CAAC,CAAA;QAEtF,6CAA6C;QAC7C,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC1B,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,SAAiB,EAAE,MAAe;QAC5C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACvB,CAAC;IAED;;;;OAIG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,CAAA;IACnC,CAAC;IAED;;;;OAIG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAED;;;;OAIG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,KAAK,EAAE,IAAI,IAAI,2BAA2B,CAAA;IACxD,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,QAAsB;QAC5B,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAChC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;QACxB,CAAC;IACH,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAAC,MAAoB;IAChE,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,2BAA2B,EAAE,CAAA;AACzF,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { z } from 'zod';
|
|
2
|
-
/**
|
|
3
|
-
* Exception raised when the model fails to produce structured output.
|
|
4
|
-
* This is raised only when the LLM refuses to use the structured output tool
|
|
5
|
-
* even after being forced via toolChoice.
|
|
6
|
-
*/
|
|
7
|
-
export declare class StructuredOutputException extends Error {
|
|
8
|
-
constructor(message: string);
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Formats Zod validation errors into a human-readable bullet list.
|
|
12
|
-
* Used to provide LLM-friendly error feedback for retry attempts.
|
|
13
|
-
*
|
|
14
|
-
* @param issues - Array of Zod validation issues
|
|
15
|
-
* @returns Formatted error message with bullet points
|
|
16
|
-
*/
|
|
17
|
-
export declare function formatValidationErrors(issues: z.ZodIssue[]): string;
|
|
18
|
-
//# sourceMappingURL=exceptions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../../../src/structured-output/exceptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B;;;;GAIG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,GAAG,MAAM,CASnE"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Exception raised when the model fails to produce structured output.
|
|
3
|
-
* This is raised only when the LLM refuses to use the structured output tool
|
|
4
|
-
* even after being forced via toolChoice.
|
|
5
|
-
*/
|
|
6
|
-
export class StructuredOutputException extends Error {
|
|
7
|
-
constructor(message) {
|
|
8
|
-
super(message);
|
|
9
|
-
this.name = 'StructuredOutputException';
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Formats Zod validation errors into a human-readable bullet list.
|
|
14
|
-
* Used to provide LLM-friendly error feedback for retry attempts.
|
|
15
|
-
*
|
|
16
|
-
* @param issues - Array of Zod validation issues
|
|
17
|
-
* @returns Formatted error message with bullet points
|
|
18
|
-
*/
|
|
19
|
-
export function formatValidationErrors(issues) {
|
|
20
|
-
const formatted = issues
|
|
21
|
-
.map((issue) => {
|
|
22
|
-
const path = issue.path.length > 0 ? issue.path.join('.') : 'root';
|
|
23
|
-
return `- Field '${path}': ${issue.message}`;
|
|
24
|
-
})
|
|
25
|
-
.join('\n');
|
|
26
|
-
return formatted;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=exceptions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../../../src/structured-output/exceptions.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAClD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAA;IACzC,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAoB;IACzD,MAAM,SAAS,GAAG,MAAM;SACrB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACb,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;QAClE,OAAO,YAAY,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE,CAAA;IAC9C,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAA;IAEb,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { Tool, type ToolContext, type ToolStreamGenerator } from '../tools/tool.js';
|
|
3
|
-
import type { ToolSpec } from '../tools/types.js';
|
|
4
|
-
import type { StructuredOutputContext } from './context.js';
|
|
5
|
-
/**
|
|
6
|
-
* Tool implementation that validates LLM output against a Zod schema.
|
|
7
|
-
* Provides validation feedback to the LLM for retry on failures.
|
|
8
|
-
*/
|
|
9
|
-
export declare class StructuredOutputTool extends Tool {
|
|
10
|
-
readonly name: string;
|
|
11
|
-
readonly description: string;
|
|
12
|
-
readonly toolSpec: ToolSpec;
|
|
13
|
-
private _schema;
|
|
14
|
-
private _context;
|
|
15
|
-
/**
|
|
16
|
-
* Creates a new StructuredOutputTool.
|
|
17
|
-
*
|
|
18
|
-
* @param schema - The Zod schema to validate against
|
|
19
|
-
* @param toolName - The name of the tool
|
|
20
|
-
* @param context - The structured output context for result storage
|
|
21
|
-
*/
|
|
22
|
-
constructor(schema: z.ZodSchema, toolName: string, context: StructuredOutputContext);
|
|
23
|
-
/**
|
|
24
|
-
* Executes the tool by validating input against the schema.
|
|
25
|
-
* On success, stores the validated result in context.
|
|
26
|
-
* On failure, returns formatted validation errors for LLM retry.
|
|
27
|
-
*
|
|
28
|
-
* @param toolContext - The tool execution context
|
|
29
|
-
* @returns Generator that returns a ToolResultBlock
|
|
30
|
-
*/
|
|
31
|
-
stream(toolContext: ToolContext): ToolStreamGenerator;
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/structured-output/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACnF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAIjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAE3D;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,IAAI;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAE3B,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,QAAQ,CAAyB;IAEzC;;;;;;OAMG;gBACS,MAAM,EAAE,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB;IASnF;;;;;;;OAOG;IAGI,MAAM,CAAC,WAAW,EAAE,WAAW,GAAG,mBAAmB;CAmC7D"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { Tool } from '../tools/tool.js';
|
|
3
|
-
import { TextBlock, ToolResultBlock } from '../types/messages.js';
|
|
4
|
-
import { convertSchemaToToolSpec } from './utils.js';
|
|
5
|
-
import { formatValidationErrors } from './exceptions.js';
|
|
6
|
-
/**
|
|
7
|
-
* Tool implementation that validates LLM output against a Zod schema.
|
|
8
|
-
* Provides validation feedback to the LLM for retry on failures.
|
|
9
|
-
*/
|
|
10
|
-
export class StructuredOutputTool extends Tool {
|
|
11
|
-
name;
|
|
12
|
-
description;
|
|
13
|
-
toolSpec;
|
|
14
|
-
_schema;
|
|
15
|
-
_context;
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new StructuredOutputTool.
|
|
18
|
-
*
|
|
19
|
-
* @param schema - The Zod schema to validate against
|
|
20
|
-
* @param toolName - The name of the tool
|
|
21
|
-
* @param context - The structured output context for result storage
|
|
22
|
-
*/
|
|
23
|
-
constructor(schema, toolName, context) {
|
|
24
|
-
super();
|
|
25
|
-
this._schema = schema;
|
|
26
|
-
this._context = context;
|
|
27
|
-
this.toolSpec = convertSchemaToToolSpec(schema, toolName);
|
|
28
|
-
this.name = this.toolSpec.name;
|
|
29
|
-
this.description = this.toolSpec.description;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Executes the tool by validating input against the schema.
|
|
33
|
-
* On success, stores the validated result in context.
|
|
34
|
-
* On failure, returns formatted validation errors for LLM retry.
|
|
35
|
-
*
|
|
36
|
-
* @param toolContext - The tool execution context
|
|
37
|
-
* @returns Generator that returns a ToolResultBlock
|
|
38
|
-
*/
|
|
39
|
-
// Validation is synchronous, so no streaming events are yielded - only the final result is returned
|
|
40
|
-
// eslint-disable-next-line require-yield
|
|
41
|
-
async *stream(toolContext) {
|
|
42
|
-
const { toolUse } = toolContext;
|
|
43
|
-
try {
|
|
44
|
-
// Validate input against schema
|
|
45
|
-
const validated = this._schema.parse(toolUse.input);
|
|
46
|
-
// Store validated result in context
|
|
47
|
-
this._context.storeResult(toolUse.toolUseId, validated);
|
|
48
|
-
// Return success result
|
|
49
|
-
return new ToolResultBlock({
|
|
50
|
-
toolUseId: toolUse.toolUseId,
|
|
51
|
-
status: 'success',
|
|
52
|
-
content: [new TextBlock(JSON.stringify(validated))],
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
// Handle validation errors
|
|
57
|
-
if (error instanceof z.ZodError) {
|
|
58
|
-
const formattedErrors = formatValidationErrors(error.issues);
|
|
59
|
-
const errorMessage = `Validation failed for ${this.name}. Please fix the following errors:\n${formattedErrors}`;
|
|
60
|
-
// Return error result with formatted validation feedback
|
|
61
|
-
return new ToolResultBlock({
|
|
62
|
-
toolUseId: toolUse.toolUseId,
|
|
63
|
-
status: 'error',
|
|
64
|
-
content: [new TextBlock(errorMessage)],
|
|
65
|
-
error: error,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
// Re-throw unexpected errors
|
|
69
|
-
throw error;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=tool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../src/structured-output/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,IAAI,EAA8C,MAAM,kBAAkB,CAAA;AAEnF,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAGxD;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,IAAI;IACnC,IAAI,CAAQ;IACZ,WAAW,CAAQ;IACnB,QAAQ,CAAU;IAEnB,OAAO,CAAa;IACpB,QAAQ,CAAyB;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,CAAA;gBAE/G,yDAAyD;gBACzD,OAAO,IAAI,eAAe,CAAC;oBACzB,SAAS,EAAE,OAAO,CAAC,SAAS;oBAC5B,MAAM,EAAE,OAAO;oBACf,OAAO,EAAE,CAAC,IAAI,SAAS,CAAC,YAAY,CAAC,CAAC;oBACtC,KAAK,EAAE,KAAK;iBACb,CAAC,CAAA;YACJ,CAAC;YAED,6BAA6B;YAC7B,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { ToolSpec } from '../tools/types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Converts a Zod schema to a complete tool specification.
|
|
5
|
-
*
|
|
6
|
-
* Validates that the schema doesn't contain refinements or transforms, which cannot be
|
|
7
|
-
* properly represented in JSON Schema. Refinements are silently dropped by z.toJSONSchema(),
|
|
8
|
-
* creating a mismatch between what the LLM sees and what validation enforces.
|
|
9
|
-
*
|
|
10
|
-
* @param schema - The Zod schema to convert
|
|
11
|
-
* @param toolName - The name to use for the tool
|
|
12
|
-
* @returns Complete tool specification
|
|
13
|
-
* @throws StructuredOutputException if the schema contains unsupported features
|
|
14
|
-
*/
|
|
15
|
-
export declare function convertSchemaToToolSpec(schema: z.ZodSchema, toolName: string): ToolSpec;
|
|
16
|
-
/**
|
|
17
|
-
* Extracts a description from the Zod schema if available.
|
|
18
|
-
*
|
|
19
|
-
* @param schema - The Zod schema to extract description from
|
|
20
|
-
* @returns The schema description or empty string if not available
|
|
21
|
-
*/
|
|
22
|
-
export declare function getSchemaDescription(schema: z.ZodSchema): string;
|
|
23
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/structured-output/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAIjD;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAevF;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,GAAG,MAAM,CAahE"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { StructuredOutputException } from './exceptions.js';
|
|
3
|
-
import { zodSchemaToJsonSchema } from '../utils/zod.js';
|
|
4
|
-
/**
|
|
5
|
-
* Converts a Zod schema to a complete tool specification.
|
|
6
|
-
*
|
|
7
|
-
* Validates that the schema doesn't contain refinements or transforms, which cannot be
|
|
8
|
-
* properly represented in JSON Schema. Refinements are silently dropped by z.toJSONSchema(),
|
|
9
|
-
* creating a mismatch between what the LLM sees and what validation enforces.
|
|
10
|
-
*
|
|
11
|
-
* @param schema - The Zod schema to convert
|
|
12
|
-
* @param toolName - The name to use for the tool
|
|
13
|
-
* @returns Complete tool specification
|
|
14
|
-
* @throws StructuredOutputException if the schema contains unsupported features
|
|
15
|
-
*/
|
|
16
|
-
export function convertSchemaToToolSpec(schema, toolName) {
|
|
17
|
-
if (hasUnsupportedFeatures(schema)) {
|
|
18
|
-
throw new StructuredOutputException('Zod refinements and transforms are not supported in structured output schemas. Please use basic validation types only.');
|
|
19
|
-
}
|
|
20
|
-
const jsonSchema = zodSchemaToJsonSchema(schema);
|
|
21
|
-
const schemaDescription = getSchemaDescription(schema);
|
|
22
|
-
return {
|
|
23
|
-
name: toolName,
|
|
24
|
-
description: `IMPORTANT: This StructuredOutputTool should only be invoked as the last and final tool before returning the completed result to the caller. ${schemaDescription}`,
|
|
25
|
-
inputSchema: jsonSchema,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Extracts a description from the Zod schema if available.
|
|
30
|
-
*
|
|
31
|
-
* @param schema - The Zod schema to extract description from
|
|
32
|
-
* @returns The schema description or empty string if not available
|
|
33
|
-
*/
|
|
34
|
-
export function getSchemaDescription(schema) {
|
|
35
|
-
// Try to get description from schema metadata
|
|
36
|
-
if ('description' in schema && typeof schema.description === 'string') {
|
|
37
|
-
return schema.description;
|
|
38
|
-
}
|
|
39
|
-
// Check _def for description (common in Zod schemas)
|
|
40
|
-
const def = schema._def;
|
|
41
|
-
if (def && typeof def.description === 'string') {
|
|
42
|
-
return def.description;
|
|
43
|
-
}
|
|
44
|
-
return '';
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Checks if a Zod schema contains unsupported features like refinements or transforms.
|
|
48
|
-
* These features cannot be properly represented in JSON Schema for the LLM.
|
|
49
|
-
*
|
|
50
|
-
* @param schema - The Zod schema to check
|
|
51
|
-
* @returns true if unsupported features are detected
|
|
52
|
-
*/
|
|
53
|
-
function hasUnsupportedFeatures(schema) {
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
-
const def = schema._def;
|
|
56
|
-
if (!def) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
// Check for transforms
|
|
60
|
-
if (def.type === 'pipe' || def.type === 'transform') {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
// Check for refinements
|
|
64
|
-
if (def.checks?.length > 0) {
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
|
-
for (const check of def.checks) {
|
|
67
|
-
if (check.type === 'custom') {
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// superRefine() creates checks without 'type' at object/array level
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
|
-
if ((def.type === 'object' || def.type === 'array') && def.checks.some((c) => !c.type)) {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// Collect nested schemas to check recursively
|
|
78
|
-
const nested = [];
|
|
79
|
-
if (def.innerType)
|
|
80
|
-
nested.push(def.innerType);
|
|
81
|
-
if (def.in)
|
|
82
|
-
nested.push(def.in);
|
|
83
|
-
if (def.out)
|
|
84
|
-
nested.push(def.out);
|
|
85
|
-
if (def.element)
|
|
86
|
-
nested.push(def.element);
|
|
87
|
-
if (def.type)
|
|
88
|
-
nested.push(def.type);
|
|
89
|
-
if (def.shape) {
|
|
90
|
-
const shape = typeof def.shape === 'function' ? def.shape() : def.shape;
|
|
91
|
-
nested.push(...Object.values(shape));
|
|
92
|
-
}
|
|
93
|
-
if (def.options) {
|
|
94
|
-
nested.push(...def.options);
|
|
95
|
-
}
|
|
96
|
-
// Check all nested schemas
|
|
97
|
-
for (const item of nested) {
|
|
98
|
-
if (item && typeof item === 'object' && '_def' in item && hasUnsupportedFeatures(item)) {
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/structured-output/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAmB,EAAE,QAAgB;IAC3E,IAAI,sBAAsB,CAAC,MAAM,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,yBAAyB,CACjC,wHAAwH,CACzH,CAAA;IACH,CAAC;IAED,MAAM,UAAU,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAA;IAChD,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAA;IAEtD,OAAO;QACL,IAAI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AAC,EAAE,CAAC;YACtG,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../../src/utils/zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,GAAG,UAAU,CAIrE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zod.js","sourceRoot":"","sources":["../../../src/utils/zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAmB;IACvD,MAAM,MAAM,GAAG,CAAC,CAAC,YAAY,CAAC,MAAM,CAAsC,CAAA;IAC1E,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAA;IACnD,OAAO,UAAwB,CAAA;AACjC,CAAC"}
|