@dexto/core 1.10.0 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/approval/schemas.cjs +2 -7
- package/dist/approval/schemas.d.ts +508 -5
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +1 -6
- package/dist/context/utils.cjs +28 -0
- package/dist/context/utils.d.ts.map +1 -1
- package/dist/context/utils.js +28 -0
- package/dist/index.browser.cjs +6 -0
- package/dist/index.browser.d.ts +4 -0
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +4 -0
- package/dist/llm/errors.d.ts +8 -8
- package/dist/llm/formatters/vercel.cjs +59 -24
- package/dist/llm/formatters/vercel.d.ts.map +1 -1
- package/dist/llm/formatters/vercel.js +59 -24
- package/dist/llm/schemas.d.ts +3 -3
- package/dist/llm/services/factory.cjs +7 -0
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +7 -0
- package/dist/session/schemas.d.ts +2 -2
- package/dist/storage/tool-executions/types.cjs +2 -1
- package/dist/storage/tool-executions/types.d.ts +254 -3
- package/dist/storage/tool-executions/types.d.ts.map +1 -1
- package/dist/storage/tool-executions/types.js +2 -1
- package/dist/systemPrompt/schemas.d.ts +3 -3
- package/dist/tools/activity.cjs +341 -0
- package/dist/tools/activity.d.ts +70 -0
- package/dist/tools/activity.d.ts.map +1 -0
- package/dist/tools/activity.js +318 -0
- package/dist/tools/display-types.cjs +34 -4
- package/dist/tools/display-types.d.ts.map +1 -1
- package/dist/tools/display-types.js +34 -4
- package/dist/tools/index.cjs +8 -1
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +8 -1
- package/dist/tools/presentation/tool-presentation.cjs +78 -25
- package/dist/tools/presentation/tool-presentation.d.ts +2 -1
- package/dist/tools/presentation/tool-presentation.d.ts.map +1 -1
- package/dist/tools/presentation/tool-presentation.js +78 -25
- package/dist/tools/presentation-schema.cjs +118 -0
- package/dist/tools/presentation-schema.d.ts +132 -0
- package/dist/tools/presentation-schema.d.ts.map +1 -0
- package/dist/tools/presentation-schema.js +94 -0
- package/dist/tools/presentation.cjs +8 -0
- package/dist/tools/presentation.d.ts +4 -0
- package/dist/tools/presentation.d.ts.map +1 -1
- package/dist/tools/presentation.js +8 -0
- package/dist/tools/types.d.ts +12 -79
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/workspace/types.d.ts +1 -0
- package/dist/workspace/types.d.ts.map +1 -1
- package/package.json +7 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/context/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,eAAe,EACf,QAAQ,EACR,SAAS,EACT,QAAQ,EAER,cAAc,EACd,WAAW,EACX,mBAAmB,EAEtB,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/context/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,eAAe,EACf,QAAQ,EACR,SAAS,EACT,QAAQ,EAER,cAAc,EACd,WAAW,EACX,mBAAmB,EAEtB,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAOvE,KAAK,qBAAqB,GAAG;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB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,oCAAoC,CACtD,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,OAAO,+BAA+B,EAAE,aAAa,EACrE,aAAa,CAAC,EAAE,qBAAqB,GACtC,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAyZrC;AA2DD,wBAAsB,kBAAkB,CACpC,MAAM,EAAE,OAAO,EACf,OAAO,EAAE;IACL,aAAa,CAAC,EAAE,OAAO,+BAA+B,EAAE,aAAa,CAAC;IACtE,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CACpB,EACD,MAAM,EAAE,MAAM,GACf,OAAO,CAAC,mBAAmB,CAAC,CAqD9B;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,GAAG,MAAM,CA2BvF;AAQD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,GAAG,MAAM,CAQhF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,GAAG,eAAe,EAAE,CA6CtF;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAkB3E"}
|
package/dist/context/utils.js
CHANGED
|
@@ -214,6 +214,34 @@ function buildToolBlobName(kind, mimeType, options, preferredName) {
|
|
|
214
214
|
}
|
|
215
215
|
async function resolveBlobReferenceToParts(resourceUri, resourceManager, logger, allowedMediaTypes, expandMatchingMedia = true) {
|
|
216
216
|
try {
|
|
217
|
+
let urlArtifact = null;
|
|
218
|
+
try {
|
|
219
|
+
urlArtifact = await resourceManager.getArtifactStore().retrieve({ reference: resourceUri, format: "url" });
|
|
220
|
+
} catch {
|
|
221
|
+
}
|
|
222
|
+
const urlMimeType = urlArtifact?.metadata.mimeType;
|
|
223
|
+
const shouldPlaceholderForUrlMedia = urlMimeType !== void 0 && (!expandMatchingMedia && isBinaryMediaMimeType(urlMimeType) || allowedMediaTypes !== void 0 && !matchesAnyMimePattern(urlMimeType, allowedMediaTypes));
|
|
224
|
+
if (urlArtifact !== null && shouldPlaceholderForUrlMedia) {
|
|
225
|
+
return [
|
|
226
|
+
{
|
|
227
|
+
type: "text",
|
|
228
|
+
text: generateMediaPlaceholder({
|
|
229
|
+
mimeType: urlArtifact.metadata.mimeType,
|
|
230
|
+
size: urlArtifact.metadata.size,
|
|
231
|
+
...urlArtifact.metadata.originalName === void 0 ? {} : { originalName: urlArtifact.metadata.originalName }
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
];
|
|
235
|
+
}
|
|
236
|
+
if (urlArtifact?.format === "url" && (urlArtifact.data.startsWith("https://") || urlArtifact.data.startsWith("http://")) && urlMimeType?.startsWith("image/")) {
|
|
237
|
+
return [
|
|
238
|
+
{
|
|
239
|
+
type: "image",
|
|
240
|
+
image: urlArtifact.data,
|
|
241
|
+
mimeType: urlMimeType
|
|
242
|
+
}
|
|
243
|
+
];
|
|
244
|
+
}
|
|
217
245
|
const result = await resourceManager.read(normalizeResourceUriForRead(resourceUri));
|
|
218
246
|
const mimeType = result.contents[0]?.mimeType;
|
|
219
247
|
const metadata = result._meta;
|
package/dist/index.browser.cjs
CHANGED
|
@@ -46,8 +46,10 @@ __export(index_browser_exports, {
|
|
|
46
46
|
isSystemMessage: () => import_types2.isSystemMessage,
|
|
47
47
|
isTextPart: () => import_types2.isTextPart,
|
|
48
48
|
isToolMessage: () => import_types2.isToolMessage,
|
|
49
|
+
isToolPresentationSnapshotV1: () => import_presentation_schema.isToolPresentationSnapshotV1,
|
|
49
50
|
isUIResourcePart: () => import_types2.isUIResourcePart,
|
|
50
51
|
isUserMessage: () => import_types2.isUserMessage,
|
|
52
|
+
isValidDisplayData: () => import_display_types.isValidDisplayData,
|
|
51
53
|
parseResourceReferences: () => import_reference_parser.parseResourceReferences,
|
|
52
54
|
recordOperationSpan: () => import_operation_span.recordOperationSpan,
|
|
53
55
|
resolveResourceReferences: () => import_reference_parser.resolveResourceReferences,
|
|
@@ -67,6 +69,8 @@ var import_error_codes = require("./storage/error-codes.js");
|
|
|
67
69
|
var import_schemas2 = require("./tools/schemas.js");
|
|
68
70
|
var import_types3 = require("./approval/types.js");
|
|
69
71
|
var import_registry = require("./systemPrompt/registry.js");
|
|
72
|
+
var import_display_types = require("./tools/display-types.js");
|
|
73
|
+
var import_presentation_schema = require("./tools/presentation-schema.js");
|
|
70
74
|
var import_browser = require("./telemetry/browser.js");
|
|
71
75
|
var import_operation_span = require("./telemetry/operation-span.js");
|
|
72
76
|
var import_reference_parser = require("./resources/reference-parser.js");
|
|
@@ -100,8 +104,10 @@ var import_reference_parser = require("./resources/reference-parser.js");
|
|
|
100
104
|
isSystemMessage,
|
|
101
105
|
isTextPart,
|
|
102
106
|
isToolMessage,
|
|
107
|
+
isToolPresentationSnapshotV1,
|
|
103
108
|
isUIResourcePart,
|
|
104
109
|
isUserMessage,
|
|
110
|
+
isValidDisplayData,
|
|
105
111
|
parseResourceReferences,
|
|
106
112
|
recordOperationSpan,
|
|
107
113
|
resolveResourceReferences,
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -22,6 +22,10 @@ export type { ContributorConfig, SystemPromptConfig } from './systemPrompt/schem
|
|
|
22
22
|
export type { SearchOptions, SearchResult, SessionSearchResult, SearchResponse, SessionSearchResponse, } from './search/types.js';
|
|
23
23
|
export type { AgentEventMap, SessionEventMap } from './events/index.js';
|
|
24
24
|
export type { ToolCallMetadata } from './tools/tool-call-metadata.js';
|
|
25
|
+
export type { ToolDisplayData } from './tools/display-types.js';
|
|
26
|
+
export { isValidDisplayData } from './tools/display-types.js';
|
|
27
|
+
export type { ToolPresentationSnapshotV1 } from './tools/presentation-schema.js';
|
|
28
|
+
export { isToolPresentationSnapshotV1 } from './tools/presentation-schema.js';
|
|
25
29
|
export type { HostRuntimeContext, HostRuntimeIds } from './runtime/host-runtime.js';
|
|
26
30
|
export { Telemetry } from './telemetry/browser.js';
|
|
27
31
|
export { recordOperationSpan, type OperationSpanOptions } from './telemetry/operation-span.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG1D,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGzE,YAAY,EACR,eAAe,EACf,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,cAAc,EACd,WAAW,EACX,QAAQ,EACR,kBAAkB,GACrB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EACH,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,WAAW,EACX,UAAU,EACV,gBAAgB,GACnB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG/E,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EACH,gBAAgB,EAChB,oBAAoB,EACpB,2BAA2B,GAC9B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,YAAY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AC7D,YAAY,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EACH,uBAAuB,EACvB,yBAAyB,GAC5B,MAAM,iCAAiC,CAAC"}
|
package/dist/index.browser.js
CHANGED
|
@@ -36,6 +36,8 @@ import {
|
|
|
36
36
|
DenialReason
|
|
37
37
|
} from "./approval/types.js";
|
|
38
38
|
import { PROMPT_GENERATOR_SOURCES } from "./systemPrompt/registry.js";
|
|
39
|
+
import { isValidDisplayData } from "./tools/display-types.js";
|
|
40
|
+
import { isToolPresentationSnapshotV1 } from "./tools/presentation-schema.js";
|
|
39
41
|
import { Telemetry } from "./telemetry/browser.js";
|
|
40
42
|
import { recordOperationSpan } from "./telemetry/operation-span.js";
|
|
41
43
|
import {
|
|
@@ -71,8 +73,10 @@ export {
|
|
|
71
73
|
isSystemMessage,
|
|
72
74
|
isTextPart,
|
|
73
75
|
isToolMessage,
|
|
76
|
+
isToolPresentationSnapshotV1,
|
|
74
77
|
isUIResourcePart,
|
|
75
78
|
isUserMessage,
|
|
79
|
+
isValidDisplayData,
|
|
76
80
|
parseResourceReferences,
|
|
77
81
|
recordOperationSpan,
|
|
78
82
|
resolveResourceReferences,
|
package/dist/llm/errors.d.ts
CHANGED
|
@@ -9,19 +9,19 @@ import type { LLMProvider } from '@dexto/llm';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class LLMError {
|
|
11
11
|
static unknownModel(provider: LLMProvider, model: string): DextoRuntimeError<{
|
|
12
|
-
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "
|
|
12
|
+
provider: "local" | "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "ollama" | "dexto-nova";
|
|
13
13
|
model: string;
|
|
14
14
|
}>;
|
|
15
15
|
static baseUrlMissing(provider: LLMProvider): DextoRuntimeError<{
|
|
16
|
-
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "
|
|
16
|
+
provider: "local" | "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "ollama" | "dexto-nova";
|
|
17
17
|
}>;
|
|
18
18
|
static missingConfig(provider: LLMProvider, configName: string): DextoRuntimeError<{
|
|
19
|
-
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "
|
|
19
|
+
provider: "local" | "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "ollama" | "dexto-nova";
|
|
20
20
|
configName: string;
|
|
21
21
|
}>;
|
|
22
22
|
static unsupportedProvider(provider: string): DextoRuntimeError<{
|
|
23
23
|
provider: string;
|
|
24
|
-
availableProviders: ("openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "
|
|
24
|
+
availableProviders: ("local" | "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "ollama" | "dexto-nova")[];
|
|
25
25
|
}>;
|
|
26
26
|
/**
|
|
27
27
|
* Runtime error when API key is missing for a provider that requires it.
|
|
@@ -29,16 +29,16 @@ export declare class LLMError {
|
|
|
29
29
|
* and the user then tries to use the LLM functionality.
|
|
30
30
|
*/
|
|
31
31
|
static apiKeyMissing(provider: LLMProvider, envVar: string): DextoRuntimeError<{
|
|
32
|
-
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "
|
|
32
|
+
provider: "local" | "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "ollama" | "dexto-nova";
|
|
33
33
|
envVar: string;
|
|
34
34
|
}>;
|
|
35
35
|
static modelProviderUnknown(model: string): DextoRuntimeError<{
|
|
36
36
|
model: string;
|
|
37
|
-
availableProviders: ("openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "
|
|
37
|
+
availableProviders: ("local" | "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "ollama" | "dexto-nova")[];
|
|
38
38
|
}>;
|
|
39
39
|
static rateLimitExceeded(provider: LLMProvider, retryAfter?: number): DextoRuntimeError<{
|
|
40
40
|
details: {
|
|
41
|
-
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "
|
|
41
|
+
provider: "local" | "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "ollama" | "dexto-nova";
|
|
42
42
|
retryAfter: number | undefined;
|
|
43
43
|
};
|
|
44
44
|
recovery: string;
|
|
@@ -53,7 +53,7 @@ export declare class LLMError {
|
|
|
53
53
|
static generationFailed(error: string, provider: LLMProvider, model: string): DextoRuntimeError<{
|
|
54
54
|
details: {
|
|
55
55
|
error: string;
|
|
56
|
-
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "
|
|
56
|
+
provider: "local" | "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "ollama" | "dexto-nova";
|
|
57
57
|
model: string;
|
|
58
58
|
};
|
|
59
59
|
}>;
|
|
@@ -145,7 +145,38 @@ class VercelMessageFormatter {
|
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
const pendingToolCalls = /* @__PURE__ */ new Map();
|
|
148
|
+
let pendingRemoteToolMedia = [];
|
|
149
|
+
const closePendingToolTurn = () => {
|
|
150
|
+
for (const [toolCallId, toolName] of pendingToolCalls) {
|
|
151
|
+
formatted.push({
|
|
152
|
+
role: "tool",
|
|
153
|
+
content: [
|
|
154
|
+
{
|
|
155
|
+
type: "tool-result",
|
|
156
|
+
toolCallId,
|
|
157
|
+
toolName,
|
|
158
|
+
output: {
|
|
159
|
+
type: "text",
|
|
160
|
+
value: "Error: Tool execution was interrupted (session crashed or cancelled before completion)"
|
|
161
|
+
},
|
|
162
|
+
isError: true
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
});
|
|
166
|
+
this.logger.warn(
|
|
167
|
+
`Tool call ${toolCallId} (${toolName}) had no matching tool result - added synthetic error result to prevent API errors`
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
pendingToolCalls.clear();
|
|
171
|
+
if (pendingRemoteToolMedia.length > 0) {
|
|
172
|
+
formatted.push({ role: "user", content: pendingRemoteToolMedia });
|
|
173
|
+
pendingRemoteToolMedia = [];
|
|
174
|
+
}
|
|
175
|
+
};
|
|
148
176
|
for (const msg of filteredHistory) {
|
|
177
|
+
if (msg.role !== "tool" && pendingToolCalls.size > 0) {
|
|
178
|
+
closePendingToolTurn();
|
|
179
|
+
}
|
|
149
180
|
switch (msg.role) {
|
|
150
181
|
case "user":
|
|
151
182
|
if (msg.content !== null) {
|
|
@@ -206,8 +237,14 @@ class VercelMessageFormatter {
|
|
|
206
237
|
break;
|
|
207
238
|
case "tool":
|
|
208
239
|
if (msg.toolCallId && pendingToolCalls.has(msg.toolCallId)) {
|
|
209
|
-
|
|
240
|
+
const toolResult = this.formatToolMessage(msg);
|
|
241
|
+
formatted.push(toolResult.message);
|
|
242
|
+
pendingRemoteToolMedia.push(...toolResult.remoteMedia);
|
|
210
243
|
pendingToolCalls.delete(msg.toolCallId);
|
|
244
|
+
if (pendingToolCalls.size === 0 && pendingRemoteToolMedia.length > 0) {
|
|
245
|
+
formatted.push({ role: "user", content: pendingRemoteToolMedia });
|
|
246
|
+
pendingRemoteToolMedia = [];
|
|
247
|
+
}
|
|
211
248
|
} else {
|
|
212
249
|
this.logger.warn(
|
|
213
250
|
`Skipping orphaned tool result ${msg.toolCallId} (no matching tool call found) - cannot send to Vercel AI SDK without corresponding tool-call`
|
|
@@ -216,28 +253,7 @@ class VercelMessageFormatter {
|
|
|
216
253
|
break;
|
|
217
254
|
}
|
|
218
255
|
}
|
|
219
|
-
|
|
220
|
-
for (const [toolCallId, toolName] of pendingToolCalls.entries()) {
|
|
221
|
-
formatted.push({
|
|
222
|
-
role: "tool",
|
|
223
|
-
content: [
|
|
224
|
-
{
|
|
225
|
-
type: "tool-result",
|
|
226
|
-
toolCallId,
|
|
227
|
-
toolName,
|
|
228
|
-
output: {
|
|
229
|
-
type: "text",
|
|
230
|
-
value: "Error: Tool execution was interrupted (session crashed or cancelled before completion)"
|
|
231
|
-
},
|
|
232
|
-
isError: true
|
|
233
|
-
}
|
|
234
|
-
]
|
|
235
|
-
});
|
|
236
|
-
this.logger.warn(
|
|
237
|
-
`Tool call ${toolCallId} (${toolName}) had no matching tool result - added synthetic error result to prevent API errors`
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
256
|
+
closePendingToolTurn();
|
|
241
257
|
return formatted;
|
|
242
258
|
}
|
|
243
259
|
/**
|
|
@@ -325,6 +341,7 @@ class VercelMessageFormatter {
|
|
|
325
341
|
// Helper to format Tool result messages
|
|
326
342
|
formatToolMessage(msg) {
|
|
327
343
|
let toolResultPart;
|
|
344
|
+
const remoteMedia = [];
|
|
328
345
|
if (Array.isArray(msg.content)) {
|
|
329
346
|
const content = msg.content.map((part) => {
|
|
330
347
|
if (part.type === "text") {
|
|
@@ -332,6 +349,13 @@ class VercelMessageFormatter {
|
|
|
332
349
|
}
|
|
333
350
|
if (part.type === "image") {
|
|
334
351
|
const data = (0, import_utils.getImageData)(part, this.logger);
|
|
352
|
+
if (/^https?:\/\//i.test(data)) {
|
|
353
|
+
remoteMedia.push({
|
|
354
|
+
type: "image",
|
|
355
|
+
image: new URL(data),
|
|
356
|
+
mediaType: part.mimeType || "image/jpeg"
|
|
357
|
+
});
|
|
358
|
+
}
|
|
335
359
|
const mediaData = normalizeToolMediaData(data);
|
|
336
360
|
if (!mediaData) {
|
|
337
361
|
return { type: "text", text: `Attached image: ${data}` };
|
|
@@ -344,6 +368,14 @@ class VercelMessageFormatter {
|
|
|
344
368
|
}
|
|
345
369
|
if (part.type === "file") {
|
|
346
370
|
const data = (0, import_utils.getFileData)(part, this.logger);
|
|
371
|
+
if (/^https?:\/\//i.test(data)) {
|
|
372
|
+
remoteMedia.push({
|
|
373
|
+
type: "file",
|
|
374
|
+
data: new URL(data),
|
|
375
|
+
mediaType: part.mimeType,
|
|
376
|
+
...part.filename === void 0 ? {} : { filename: part.filename }
|
|
377
|
+
});
|
|
378
|
+
}
|
|
347
379
|
const mediaData = normalizeToolMediaData(data);
|
|
348
380
|
if (!mediaData) {
|
|
349
381
|
return { type: "text", text: `Attached file: ${data}` };
|
|
@@ -391,7 +423,10 @@ class VercelMessageFormatter {
|
|
|
391
423
|
}
|
|
392
424
|
};
|
|
393
425
|
}
|
|
394
|
-
return {
|
|
426
|
+
return {
|
|
427
|
+
message: { role: "tool", content: [toolResultPart] },
|
|
428
|
+
remoteMedia
|
|
429
|
+
};
|
|
395
430
|
}
|
|
396
431
|
}
|
|
397
432
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel.d.ts","sourceRoot":"","sources":["../../../src/llm/formatters/vercel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"vercel.d.ts","sourceRoot":"","sources":["../../../src/llm/formatters/vercel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAoC,MAAM,IAAI,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACR,eAAe,EAIlB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAyHvD;;;;;;;;;;GAUG;AACH,qBAAa,sBAAsB;IAC/B,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM;IAG1B;;;;;;OAMG;IACH,MAAM,CACF,OAAO,EAAE,QAAQ,CAAC,eAAe,EAAE,CAAC,EACpC,OAAO,EAAE,UAAU,EACnB,YAAY,EAAE,MAAM,GAAG,IAAI,GAC5B,YAAY,EAAE;IAqLjB;;;;;;OAMG;IACH,kBAAkB,IAAI,IAAI;IAI1B,OAAO,CAAC,wBAAwB;IAUhC,OAAO,CAAC,sBAAsB;IAmG9B,OAAO,CAAC,iBAAiB;CAmG5B"}
|
|
@@ -128,7 +128,38 @@ class VercelMessageFormatter {
|
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
130
|
const pendingToolCalls = /* @__PURE__ */ new Map();
|
|
131
|
+
let pendingRemoteToolMedia = [];
|
|
132
|
+
const closePendingToolTurn = () => {
|
|
133
|
+
for (const [toolCallId, toolName] of pendingToolCalls) {
|
|
134
|
+
formatted.push({
|
|
135
|
+
role: "tool",
|
|
136
|
+
content: [
|
|
137
|
+
{
|
|
138
|
+
type: "tool-result",
|
|
139
|
+
toolCallId,
|
|
140
|
+
toolName,
|
|
141
|
+
output: {
|
|
142
|
+
type: "text",
|
|
143
|
+
value: "Error: Tool execution was interrupted (session crashed or cancelled before completion)"
|
|
144
|
+
},
|
|
145
|
+
isError: true
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
});
|
|
149
|
+
this.logger.warn(
|
|
150
|
+
`Tool call ${toolCallId} (${toolName}) had no matching tool result - added synthetic error result to prevent API errors`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
pendingToolCalls.clear();
|
|
154
|
+
if (pendingRemoteToolMedia.length > 0) {
|
|
155
|
+
formatted.push({ role: "user", content: pendingRemoteToolMedia });
|
|
156
|
+
pendingRemoteToolMedia = [];
|
|
157
|
+
}
|
|
158
|
+
};
|
|
131
159
|
for (const msg of filteredHistory) {
|
|
160
|
+
if (msg.role !== "tool" && pendingToolCalls.size > 0) {
|
|
161
|
+
closePendingToolTurn();
|
|
162
|
+
}
|
|
132
163
|
switch (msg.role) {
|
|
133
164
|
case "user":
|
|
134
165
|
if (msg.content !== null) {
|
|
@@ -189,8 +220,14 @@ class VercelMessageFormatter {
|
|
|
189
220
|
break;
|
|
190
221
|
case "tool":
|
|
191
222
|
if (msg.toolCallId && pendingToolCalls.has(msg.toolCallId)) {
|
|
192
|
-
|
|
223
|
+
const toolResult = this.formatToolMessage(msg);
|
|
224
|
+
formatted.push(toolResult.message);
|
|
225
|
+
pendingRemoteToolMedia.push(...toolResult.remoteMedia);
|
|
193
226
|
pendingToolCalls.delete(msg.toolCallId);
|
|
227
|
+
if (pendingToolCalls.size === 0 && pendingRemoteToolMedia.length > 0) {
|
|
228
|
+
formatted.push({ role: "user", content: pendingRemoteToolMedia });
|
|
229
|
+
pendingRemoteToolMedia = [];
|
|
230
|
+
}
|
|
194
231
|
} else {
|
|
195
232
|
this.logger.warn(
|
|
196
233
|
`Skipping orphaned tool result ${msg.toolCallId} (no matching tool call found) - cannot send to Vercel AI SDK without corresponding tool-call`
|
|
@@ -199,28 +236,7 @@ class VercelMessageFormatter {
|
|
|
199
236
|
break;
|
|
200
237
|
}
|
|
201
238
|
}
|
|
202
|
-
|
|
203
|
-
for (const [toolCallId, toolName] of pendingToolCalls.entries()) {
|
|
204
|
-
formatted.push({
|
|
205
|
-
role: "tool",
|
|
206
|
-
content: [
|
|
207
|
-
{
|
|
208
|
-
type: "tool-result",
|
|
209
|
-
toolCallId,
|
|
210
|
-
toolName,
|
|
211
|
-
output: {
|
|
212
|
-
type: "text",
|
|
213
|
-
value: "Error: Tool execution was interrupted (session crashed or cancelled before completion)"
|
|
214
|
-
},
|
|
215
|
-
isError: true
|
|
216
|
-
}
|
|
217
|
-
]
|
|
218
|
-
});
|
|
219
|
-
this.logger.warn(
|
|
220
|
-
`Tool call ${toolCallId} (${toolName}) had no matching tool result - added synthetic error result to prevent API errors`
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
239
|
+
closePendingToolTurn();
|
|
224
240
|
return formatted;
|
|
225
241
|
}
|
|
226
242
|
/**
|
|
@@ -308,6 +324,7 @@ class VercelMessageFormatter {
|
|
|
308
324
|
// Helper to format Tool result messages
|
|
309
325
|
formatToolMessage(msg) {
|
|
310
326
|
let toolResultPart;
|
|
327
|
+
const remoteMedia = [];
|
|
311
328
|
if (Array.isArray(msg.content)) {
|
|
312
329
|
const content = msg.content.map((part) => {
|
|
313
330
|
if (part.type === "text") {
|
|
@@ -315,6 +332,13 @@ class VercelMessageFormatter {
|
|
|
315
332
|
}
|
|
316
333
|
if (part.type === "image") {
|
|
317
334
|
const data = getImageData(part, this.logger);
|
|
335
|
+
if (/^https?:\/\//i.test(data)) {
|
|
336
|
+
remoteMedia.push({
|
|
337
|
+
type: "image",
|
|
338
|
+
image: new URL(data),
|
|
339
|
+
mediaType: part.mimeType || "image/jpeg"
|
|
340
|
+
});
|
|
341
|
+
}
|
|
318
342
|
const mediaData = normalizeToolMediaData(data);
|
|
319
343
|
if (!mediaData) {
|
|
320
344
|
return { type: "text", text: `Attached image: ${data}` };
|
|
@@ -327,6 +351,14 @@ class VercelMessageFormatter {
|
|
|
327
351
|
}
|
|
328
352
|
if (part.type === "file") {
|
|
329
353
|
const data = getFileData(part, this.logger);
|
|
354
|
+
if (/^https?:\/\//i.test(data)) {
|
|
355
|
+
remoteMedia.push({
|
|
356
|
+
type: "file",
|
|
357
|
+
data: new URL(data),
|
|
358
|
+
mediaType: part.mimeType,
|
|
359
|
+
...part.filename === void 0 ? {} : { filename: part.filename }
|
|
360
|
+
});
|
|
361
|
+
}
|
|
330
362
|
const mediaData = normalizeToolMediaData(data);
|
|
331
363
|
if (!mediaData) {
|
|
332
364
|
return { type: "text", text: `Attached file: ${data}` };
|
|
@@ -374,7 +406,10 @@ class VercelMessageFormatter {
|
|
|
374
406
|
}
|
|
375
407
|
};
|
|
376
408
|
}
|
|
377
|
-
return {
|
|
409
|
+
return {
|
|
410
|
+
message: { role: "tool", content: [toolResultPart] },
|
|
411
|
+
remoteMedia
|
|
412
|
+
};
|
|
378
413
|
}
|
|
379
414
|
}
|
|
380
415
|
export {
|
package/dist/llm/schemas.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
/** Business rules + compatibility checks */
|
|
3
3
|
export declare const LLMConfigBaseSchema: z.ZodObject<{
|
|
4
4
|
provider: z.ZodEnum<{
|
|
5
|
+
local: "local";
|
|
5
6
|
openai: "openai";
|
|
6
7
|
"openai-compatible": "openai-compatible";
|
|
7
8
|
anthropic: "anthropic";
|
|
@@ -16,7 +17,6 @@ export declare const LLMConfigBaseSchema: z.ZodObject<{
|
|
|
16
17
|
glama: "glama";
|
|
17
18
|
vertex: "vertex";
|
|
18
19
|
bedrock: "bedrock";
|
|
19
|
-
local: "local";
|
|
20
20
|
ollama: "ollama";
|
|
21
21
|
"dexto-nova": "dexto-nova";
|
|
22
22
|
}>;
|
|
@@ -42,6 +42,7 @@ export declare const LLMConfigBaseSchema: z.ZodObject<{
|
|
|
42
42
|
*/
|
|
43
43
|
export declare const LLMConfigSchema: z.ZodObject<{
|
|
44
44
|
provider: z.ZodEnum<{
|
|
45
|
+
local: "local";
|
|
45
46
|
openai: "openai";
|
|
46
47
|
"openai-compatible": "openai-compatible";
|
|
47
48
|
anthropic: "anthropic";
|
|
@@ -56,7 +57,6 @@ export declare const LLMConfigSchema: z.ZodObject<{
|
|
|
56
57
|
glama: "glama";
|
|
57
58
|
vertex: "vertex";
|
|
58
59
|
bedrock: "bedrock";
|
|
59
|
-
local: "local";
|
|
60
60
|
ollama: "ollama";
|
|
61
61
|
"dexto-nova": "dexto-nova";
|
|
62
62
|
}>;
|
|
@@ -81,6 +81,7 @@ export declare const LLMUpdatesSchema: z.ZodObject<{
|
|
|
81
81
|
budgetTokens: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
82
82
|
}, z.core.$strict>>>>;
|
|
83
83
|
provider: z.ZodOptional<z.ZodEnum<{
|
|
84
|
+
local: "local";
|
|
84
85
|
openai: "openai";
|
|
85
86
|
"openai-compatible": "openai-compatible";
|
|
86
87
|
anthropic: "anthropic";
|
|
@@ -95,7 +96,6 @@ export declare const LLMUpdatesSchema: z.ZodObject<{
|
|
|
95
96
|
glama: "glama";
|
|
96
97
|
vertex: "vertex";
|
|
97
98
|
bedrock: "bedrock";
|
|
98
|
-
local: "local";
|
|
99
99
|
ollama: "ollama";
|
|
100
100
|
"dexto-nova": "dexto-nova";
|
|
101
101
|
}>>;
|
|
@@ -255,6 +255,13 @@ async function createVercelModel(llmConfig, context) {
|
|
|
255
255
|
model
|
|
256
256
|
);
|
|
257
257
|
}
|
|
258
|
+
Object.defineProperty(chatModel, "supportedUrls", {
|
|
259
|
+
configurable: true,
|
|
260
|
+
enumerable: true,
|
|
261
|
+
value: {
|
|
262
|
+
"image/*": [/^https?:\/\/.*$/]
|
|
263
|
+
}
|
|
264
|
+
});
|
|
258
265
|
return chatModel;
|
|
259
266
|
}
|
|
260
267
|
case "vertex": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/llm/services/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EACR,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACvB,MAAM,YAAY,CAAC;AAoHpB;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACnC,SAAS,EAAE,kBAAkB,EAC7B,OAAO,CAAC,EAAE,oBAAoB,GAC/B,OAAO,CAAC,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/llm/services/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EACR,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACvB,MAAM,YAAY,CAAC;AAoHpB;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACnC,SAAS,EAAE,kBAAkB,EAC7B,OAAO,CAAC,EAAE,oBAAoB,GAC/B,OAAO,CAAC,aAAa,CAAC,CAyUxB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CAClC,MAAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,WAAW,EACxB,mBAAmB,EAAE,mBAAmB,EACxC,iBAAiB,EAAE,iBAAiB,EACpC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,OAAO,0BAA0B,EAAE,eAAe,EACnE,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,uBAAuB,EAChC,oBAAoB,CAAC,EAAE,oBAAoB,GAC5C,OAAO,CAAC,gBAAgB,CAAC,CAwC3B"}
|
|
@@ -227,6 +227,13 @@ async function createVercelModel(llmConfig, context) {
|
|
|
227
227
|
model
|
|
228
228
|
);
|
|
229
229
|
}
|
|
230
|
+
Object.defineProperty(chatModel, "supportedUrls", {
|
|
231
|
+
configurable: true,
|
|
232
|
+
enumerable: true,
|
|
233
|
+
value: {
|
|
234
|
+
"image/*": [/^https?:\/\/.*$/]
|
|
235
|
+
}
|
|
236
|
+
});
|
|
230
237
|
return chatModel;
|
|
231
238
|
}
|
|
232
239
|
case "vertex": {
|
|
@@ -34,7 +34,7 @@ export declare const SessionDataSchema: z.ZodObject<{
|
|
|
34
34
|
lastActivity: z.ZodNumber;
|
|
35
35
|
llmOverride: z.ZodOptional<z.ZodCustom<{
|
|
36
36
|
model: string;
|
|
37
|
-
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "
|
|
37
|
+
provider: "local" | "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "ollama" | "dexto-nova";
|
|
38
38
|
baseURL?: string | undefined;
|
|
39
39
|
maxInputTokens?: number | undefined;
|
|
40
40
|
maxOutputTokens?: number | undefined;
|
|
@@ -47,7 +47,7 @@ export declare const SessionDataSchema: z.ZodObject<{
|
|
|
47
47
|
maxIterations?: number | undefined;
|
|
48
48
|
}, {
|
|
49
49
|
model: string;
|
|
50
|
-
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "
|
|
50
|
+
provider: "local" | "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "ollama" | "dexto-nova";
|
|
51
51
|
baseURL?: string | undefined;
|
|
52
52
|
maxInputTokens?: number | undefined;
|
|
53
53
|
maxOutputTokens?: number | undefined;
|
|
@@ -31,6 +31,7 @@ __export(types_exports, {
|
|
|
31
31
|
module.exports = __toCommonJS(types_exports);
|
|
32
32
|
var import_crypto = require("crypto");
|
|
33
33
|
var import_zod = require("zod");
|
|
34
|
+
var import_presentation_schema = require("../../tools/presentation-schema.js");
|
|
34
35
|
const ToolExecutionIdentitySchema = import_zod.z.object({
|
|
35
36
|
runId: import_zod.z.string().min(1),
|
|
36
37
|
turnId: import_zod.z.string().min(1),
|
|
@@ -38,7 +39,7 @@ const ToolExecutionIdentitySchema = import_zod.z.object({
|
|
|
38
39
|
toolCallId: import_zod.z.string().min(1)
|
|
39
40
|
}).strict();
|
|
40
41
|
const ToolExecutionResultMetadataSchema = import_zod.z.object({
|
|
41
|
-
presentationSnapshot:
|
|
42
|
+
presentationSnapshot: import_presentation_schema.ToolPresentationSnapshotV1Schema.optional(),
|
|
42
43
|
meta: import_zod.z.custom().optional(),
|
|
43
44
|
requireApproval: import_zod.z.boolean().optional(),
|
|
44
45
|
approvalStatus: import_zod.z.enum(["approved", "rejected"]).optional()
|