veryfront 0.0.65 → 0.0.67
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/ai/client.js +17 -23
- package/dist/ai/client.js.map +2 -2
- package/dist/ai/components.js +20 -26
- package/dist/ai/components.js.map +2 -2
- package/dist/ai/dev.js +20 -32
- package/dist/ai/dev.js.map +2 -2
- package/dist/ai/index.js +206 -164
- package/dist/ai/index.js.map +3 -3
- package/dist/ai/primitives.js +17 -23
- package/dist/ai/primitives.js.map +2 -2
- package/dist/ai/production.js +37 -37
- package/dist/ai/production.js.map +2 -2
- package/dist/ai/react.js +17 -23
- package/dist/ai/react.js.map +2 -2
- package/dist/ai/workflow-react.js +17 -23
- package/dist/ai/workflow-react.js.map +2 -2
- package/dist/ai/workflow.js +71 -63
- package/dist/ai/workflow.js.map +2 -2
- package/dist/cli.js +603 -1016
- package/dist/components.js +285 -4159
- package/dist/components.js.map +4 -4
- package/dist/config.js +23 -31
- package/dist/config.js.map +2 -2
- package/dist/data.js +49 -50
- package/dist/data.js.map +2 -2
- package/dist/index.js +316 -4193
- package/dist/index.js.map +4 -4
- package/dist/oauth/handlers.js +24 -29
- package/dist/oauth/handlers.js.map +2 -2
- package/dist/oauth/index.js +24 -29
- package/dist/oauth/index.js.map +2 -2
- package/dist/oauth/providers.js +20 -23
- package/dist/oauth/providers.js.map +2 -2
- package/dist/oauth/token-store.js +21 -29
- package/dist/oauth/token-store.js.map +2 -2
- package/package.json +5 -5
package/dist/ai/index.js
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
// src/_shims/deno-env.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
delete
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
globalThis.Deno = globalThis.Deno || {
|
|
3
|
+
env: {
|
|
4
|
+
get(key) {
|
|
5
|
+
return process.env[key];
|
|
6
|
+
},
|
|
7
|
+
set(key, value) {
|
|
8
|
+
process.env[key] = value;
|
|
9
|
+
},
|
|
10
|
+
delete(key) {
|
|
11
|
+
delete process.env[key];
|
|
12
|
+
},
|
|
13
|
+
has(key) {
|
|
14
|
+
return key in process.env;
|
|
15
|
+
},
|
|
16
|
+
toObject() {
|
|
17
|
+
return { ...process.env };
|
|
18
|
+
}
|
|
17
19
|
}
|
|
18
20
|
};
|
|
19
|
-
if (typeof globalThis.Deno === "undefined") {
|
|
20
|
-
globalThis.Deno = {
|
|
21
|
-
env: denoEnvShim,
|
|
22
|
-
cwd: () => process.cwd()
|
|
23
|
-
};
|
|
24
|
-
} else if (typeof globalThis.Deno.env === "undefined") {
|
|
25
|
-
globalThis.Deno.env = denoEnvShim;
|
|
26
|
-
}
|
|
27
21
|
|
|
28
22
|
// src/ai/providers/openai.ts
|
|
29
23
|
import { z as z2 } from "zod";
|
|
@@ -180,6 +174,7 @@ var OpenAIStreamChunkSchema = z.object({
|
|
|
180
174
|
})).min(1)
|
|
181
175
|
});
|
|
182
176
|
var BaseProvider = class {
|
|
177
|
+
config;
|
|
183
178
|
constructor(config) {
|
|
184
179
|
this.config = config;
|
|
185
180
|
this.validateConfig();
|
|
@@ -394,9 +389,12 @@ var OpenAIResponseSchema = z2.object({
|
|
|
394
389
|
}).optional()
|
|
395
390
|
});
|
|
396
391
|
var OpenAIProvider = class extends BaseProvider {
|
|
392
|
+
name = "openai";
|
|
393
|
+
apiKey;
|
|
394
|
+
baseURL;
|
|
395
|
+
organizationId;
|
|
397
396
|
constructor(config) {
|
|
398
397
|
super(config);
|
|
399
|
-
this.name = "openai";
|
|
400
398
|
this.apiKey = config.apiKey;
|
|
401
399
|
this.baseURL = config.baseURL || "https://api.openai.com/v1";
|
|
402
400
|
this.organizationId = config.organizationId;
|
|
@@ -435,12 +433,12 @@ var OpenAIProvider = class extends BaseProvider {
|
|
|
435
433
|
body.top_p = request.topP;
|
|
436
434
|
}
|
|
437
435
|
if (request.tools && request.tools.length > 0) {
|
|
438
|
-
body.tools = request.tools.map((
|
|
436
|
+
body.tools = request.tools.map((tool3) => ({
|
|
439
437
|
type: "function",
|
|
440
438
|
function: {
|
|
441
|
-
name:
|
|
442
|
-
description:
|
|
443
|
-
parameters:
|
|
439
|
+
name: tool3.name,
|
|
440
|
+
description: tool3.description,
|
|
441
|
+
parameters: tool3.parameters
|
|
444
442
|
}
|
|
445
443
|
}));
|
|
446
444
|
}
|
|
@@ -498,9 +496,11 @@ var OpenAIProvider = class extends BaseProvider {
|
|
|
498
496
|
|
|
499
497
|
// src/ai/providers/anthropic.ts
|
|
500
498
|
var AnthropicProvider = class extends BaseProvider {
|
|
499
|
+
name = "anthropic";
|
|
500
|
+
apiKey;
|
|
501
|
+
baseURL;
|
|
501
502
|
constructor(config) {
|
|
502
503
|
super(config);
|
|
503
|
-
this.name = "anthropic";
|
|
504
504
|
this.apiKey = config.apiKey;
|
|
505
505
|
this.baseURL = config.baseURL || "https://api.anthropic.com";
|
|
506
506
|
}
|
|
@@ -592,10 +592,10 @@ var AnthropicProvider = class extends BaseProvider {
|
|
|
592
592
|
body.top_p = request.topP;
|
|
593
593
|
}
|
|
594
594
|
if (request.tools && request.tools.length > 0) {
|
|
595
|
-
body.tools = request.tools.map((
|
|
596
|
-
name:
|
|
597
|
-
description:
|
|
598
|
-
input_schema:
|
|
595
|
+
body.tools = request.tools.map((tool3) => ({
|
|
596
|
+
name: tool3.name,
|
|
597
|
+
description: tool3.description,
|
|
598
|
+
input_schema: tool3.parameters
|
|
599
599
|
}));
|
|
600
600
|
}
|
|
601
601
|
return body;
|
|
@@ -798,9 +798,11 @@ var GoogleResponseSchema = z3.object({
|
|
|
798
798
|
}).optional()
|
|
799
799
|
});
|
|
800
800
|
var GoogleProvider = class extends BaseProvider {
|
|
801
|
+
name = "google";
|
|
802
|
+
apiKey;
|
|
803
|
+
baseURL;
|
|
801
804
|
constructor(config) {
|
|
802
805
|
super(config);
|
|
803
|
-
this.name = "google";
|
|
804
806
|
this.apiKey = config.apiKey;
|
|
805
807
|
this.baseURL = config.baseURL || "https://generativelanguage.googleapis.com/v1beta";
|
|
806
808
|
}
|
|
@@ -831,12 +833,12 @@ var GoogleProvider = class extends BaseProvider {
|
|
|
831
833
|
body.top_p = request.topP;
|
|
832
834
|
}
|
|
833
835
|
if (request.tools && request.tools.length > 0) {
|
|
834
|
-
body.tools = request.tools.map((
|
|
836
|
+
body.tools = request.tools.map((tool3) => ({
|
|
835
837
|
type: "function",
|
|
836
838
|
function: {
|
|
837
|
-
name:
|
|
838
|
-
description:
|
|
839
|
-
parameters:
|
|
839
|
+
name: tool3.name,
|
|
840
|
+
description: tool3.description,
|
|
841
|
+
parameters: tool3.parameters
|
|
840
842
|
}
|
|
841
843
|
}));
|
|
842
844
|
}
|
|
@@ -922,11 +924,9 @@ function getEnv(key) {
|
|
|
922
924
|
|
|
923
925
|
// src/ai/providers/factory.ts
|
|
924
926
|
var ProviderRegistry = class {
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
this.autoInitialized = false;
|
|
929
|
-
}
|
|
927
|
+
providers = /* @__PURE__ */ new Map();
|
|
928
|
+
config = {};
|
|
929
|
+
autoInitialized = false;
|
|
930
930
|
/**
|
|
931
931
|
* Auto-initialize providers from environment variables
|
|
932
932
|
* This is called lazily when a provider is first requested
|
|
@@ -1299,9 +1299,7 @@ function generateToolId() {
|
|
|
1299
1299
|
return `tool_${Date.now()}_${toolIdCounter++}`;
|
|
1300
1300
|
}
|
|
1301
1301
|
var ToolRegistryClass = class {
|
|
1302
|
-
|
|
1303
|
-
this.tools = /* @__PURE__ */ new Map();
|
|
1304
|
-
}
|
|
1302
|
+
tools = /* @__PURE__ */ new Map();
|
|
1305
1303
|
register(id, toolInstance) {
|
|
1306
1304
|
if (this.tools.has(id)) {
|
|
1307
1305
|
agentLogger.debug(`Tool "${id}" is already registered. Overwriting.`);
|
|
@@ -1345,27 +1343,27 @@ var ToolRegistryClass = class {
|
|
|
1345
1343
|
var TOOL_REGISTRY_KEY = "__veryfront_tool_registry__";
|
|
1346
1344
|
var _globalTool = globalThis;
|
|
1347
1345
|
var toolRegistry = _globalTool[TOOL_REGISTRY_KEY] ||= new ToolRegistryClass();
|
|
1348
|
-
function toolToProviderDefinition(
|
|
1349
|
-
const jsonSchema =
|
|
1346
|
+
function toolToProviderDefinition(tool3) {
|
|
1347
|
+
const jsonSchema = tool3.inputSchemaJson || zodToJsonSchema(tool3.inputSchema);
|
|
1350
1348
|
agentLogger.info(
|
|
1351
|
-
`[TOOL] Using ${
|
|
1349
|
+
`[TOOL] Using ${tool3.inputSchemaJson ? "pre-converted" : "runtime-converted"} schema for "${tool3.id}"`
|
|
1352
1350
|
);
|
|
1353
1351
|
return {
|
|
1354
|
-
name:
|
|
1355
|
-
description:
|
|
1352
|
+
name: tool3.id,
|
|
1353
|
+
description: tool3.description,
|
|
1356
1354
|
parameters: jsonSchema
|
|
1357
1355
|
};
|
|
1358
1356
|
}
|
|
1359
1357
|
async function executeTool(toolId, input, context) {
|
|
1360
|
-
const
|
|
1361
|
-
if (!
|
|
1358
|
+
const tool3 = toolRegistry.get(toolId);
|
|
1359
|
+
if (!tool3) {
|
|
1362
1360
|
throw toError(createError({
|
|
1363
1361
|
type: "agent",
|
|
1364
1362
|
message: `Tool "${toolId}" not found`
|
|
1365
1363
|
}));
|
|
1366
1364
|
}
|
|
1367
1365
|
try {
|
|
1368
|
-
const result = await
|
|
1366
|
+
const result = await tool3.execute(input, context);
|
|
1369
1367
|
return result;
|
|
1370
1368
|
} catch (error) {
|
|
1371
1369
|
throw toError(createError({
|
|
@@ -1532,8 +1530,9 @@ function validatePlatformCompatibility(config, platform) {
|
|
|
1532
1530
|
|
|
1533
1531
|
// src/ai/agent/memory.ts
|
|
1534
1532
|
var ConversationMemory = class {
|
|
1533
|
+
messages = [];
|
|
1534
|
+
config;
|
|
1535
1535
|
constructor(config) {
|
|
1536
|
-
this.messages = [];
|
|
1537
1536
|
this.config = config;
|
|
1538
1537
|
}
|
|
1539
1538
|
async add(message) {
|
|
@@ -1578,8 +1577,10 @@ var ConversationMemory = class {
|
|
|
1578
1577
|
}
|
|
1579
1578
|
};
|
|
1580
1579
|
var BufferMemory = class {
|
|
1580
|
+
messages = [];
|
|
1581
|
+
config;
|
|
1582
|
+
bufferSize;
|
|
1581
1583
|
constructor(config) {
|
|
1582
|
-
this.messages = [];
|
|
1583
1584
|
this.config = config;
|
|
1584
1585
|
this.bufferSize = config.maxMessages || 10;
|
|
1585
1586
|
}
|
|
@@ -1613,9 +1614,11 @@ var BufferMemory = class {
|
|
|
1613
1614
|
}
|
|
1614
1615
|
};
|
|
1615
1616
|
var SummaryMemory = class {
|
|
1617
|
+
messages = [];
|
|
1618
|
+
summary = "";
|
|
1619
|
+
config;
|
|
1620
|
+
summaryThreshold;
|
|
1616
1621
|
constructor(config) {
|
|
1617
|
-
this.messages = [];
|
|
1618
|
-
this.summary = "";
|
|
1619
1622
|
this.config = config;
|
|
1620
1623
|
this.summaryThreshold = config.maxMessages || 20;
|
|
1621
1624
|
}
|
|
@@ -1702,7 +1705,7 @@ var LRU_DEFAULT_MAX_SIZE_BYTES = 50 * 1024 * 1024;
|
|
|
1702
1705
|
// deno.json
|
|
1703
1706
|
var deno_default = {
|
|
1704
1707
|
name: "veryfront",
|
|
1705
|
-
version: "0.0.
|
|
1708
|
+
version: "0.0.67",
|
|
1706
1709
|
nodeModulesDir: "auto",
|
|
1707
1710
|
exclude: [
|
|
1708
1711
|
"npm/",
|
|
@@ -1811,11 +1814,11 @@ var deno_default = {
|
|
|
1811
1814
|
hast: "npm:@types/hast@3.0.3",
|
|
1812
1815
|
unist: "npm:@types/unist@3.0.2",
|
|
1813
1816
|
unified: "npm:unified@11.0.5",
|
|
1814
|
-
ai: "https://esm.sh/ai@5.0.
|
|
1815
|
-
"ai/react": "https://esm.sh/@ai-sdk/react@2.0.
|
|
1816
|
-
"@ai-sdk/react": "https://esm.sh/@ai-sdk/react@2.0.
|
|
1817
|
-
"@ai-sdk/openai": "https://esm.sh/@ai-sdk/openai@2.0.
|
|
1818
|
-
"@ai-sdk/anthropic": "https://esm.sh/@ai-sdk/anthropic@2.0.
|
|
1817
|
+
ai: "https://esm.sh/ai@5.0.76?deps=react@18.3.1,react-dom@18.3.1",
|
|
1818
|
+
"ai/react": "https://esm.sh/@ai-sdk/react@2.0.1?deps=react@18.3.1,react-dom@18.3.1",
|
|
1819
|
+
"@ai-sdk/react": "https://esm.sh/@ai-sdk/react@2.0.1?deps=react@18.3.1,react-dom@18.3.1",
|
|
1820
|
+
"@ai-sdk/openai": "https://esm.sh/@ai-sdk/openai@2.0.1",
|
|
1821
|
+
"@ai-sdk/anthropic": "https://esm.sh/@ai-sdk/anthropic@2.0.1",
|
|
1819
1822
|
unocss: "https://esm.sh/unocss@0.59.0",
|
|
1820
1823
|
"@unocss/core": "https://esm.sh/@unocss/core@0.59.0",
|
|
1821
1824
|
"@unocss/preset-wind": "https://esm.sh/@unocss/preset-wind@0.59.0",
|
|
@@ -2049,11 +2052,9 @@ var VERYFRONT_PATHS = {
|
|
|
2049
2052
|
|
|
2050
2053
|
// src/core/utils/bundle-manifest.ts
|
|
2051
2054
|
var InMemoryBundleManifestStore = class {
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
this.sourceIndex = /* @__PURE__ */ new Map();
|
|
2056
|
-
}
|
|
2055
|
+
metadata = /* @__PURE__ */ new Map();
|
|
2056
|
+
code = /* @__PURE__ */ new Map();
|
|
2057
|
+
sourceIndex = /* @__PURE__ */ new Map();
|
|
2057
2058
|
getBundleMetadata(key) {
|
|
2058
2059
|
const entry = this.metadata.get(key);
|
|
2059
2060
|
if (!entry)
|
|
@@ -2345,16 +2346,14 @@ var ContextPropagation = class {
|
|
|
2345
2346
|
|
|
2346
2347
|
// src/observability/tracing/manager.ts
|
|
2347
2348
|
var TracingManager = class {
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
this.contextProp = null;
|
|
2357
|
-
}
|
|
2349
|
+
state = {
|
|
2350
|
+
initialized: false,
|
|
2351
|
+
tracer: null,
|
|
2352
|
+
api: null,
|
|
2353
|
+
propagator: null
|
|
2354
|
+
};
|
|
2355
|
+
spanOps = null;
|
|
2356
|
+
contextProp = null;
|
|
2358
2357
|
async initialize(config = {}, adapter) {
|
|
2359
2358
|
if (this.state.initialized) {
|
|
2360
2359
|
serverLogger.debug("[tracing] Already initialized");
|
|
@@ -2483,8 +2482,11 @@ var AgentStreamEventSchema = z4.discriminatedUnion("type", [
|
|
|
2483
2482
|
var DEFAULT_MAX_TOKENS = 4096;
|
|
2484
2483
|
var DEFAULT_TEMPERATURE = 0.7;
|
|
2485
2484
|
var AgentRuntime = class {
|
|
2485
|
+
id;
|
|
2486
|
+
config;
|
|
2487
|
+
memory;
|
|
2488
|
+
status = "idle";
|
|
2486
2489
|
constructor(id, config) {
|
|
2487
|
-
this.status = "idle";
|
|
2488
2490
|
this.id = id;
|
|
2489
2491
|
this.config = config;
|
|
2490
2492
|
const memoryConfig = config.memory || { type: "conversation", maxTokens: 4e3 };
|
|
@@ -3057,8 +3059,8 @@ var AgentRuntime = class {
|
|
|
3057
3059
|
if (this.config.tools === true) {
|
|
3058
3060
|
const allTools = toolRegistry.getAll();
|
|
3059
3061
|
serverLogger.debug(`[AGENT] Loading all ${allTools.size} tools from registry`);
|
|
3060
|
-
for (const [name,
|
|
3061
|
-
const def = toolToProviderDefinition(
|
|
3062
|
+
for (const [name, tool3] of allTools) {
|
|
3063
|
+
const def = toolToProviderDefinition(tool3);
|
|
3062
3064
|
serverLogger.debug(`[AGENT] Tool definition for "${name}":`, JSON.stringify(def, null, 2));
|
|
3063
3065
|
tools.push(def);
|
|
3064
3066
|
}
|
|
@@ -3066,9 +3068,9 @@ var AgentRuntime = class {
|
|
|
3066
3068
|
}
|
|
3067
3069
|
for (const [name, entry] of Object.entries(this.config.tools)) {
|
|
3068
3070
|
if (entry === true) {
|
|
3069
|
-
const
|
|
3070
|
-
if (
|
|
3071
|
-
const def = toolToProviderDefinition(
|
|
3071
|
+
const tool3 = toolRegistry.get(name);
|
|
3072
|
+
if (tool3) {
|
|
3073
|
+
const def = toolToProviderDefinition(tool3);
|
|
3072
3074
|
serverLogger.debug(`[AGENT] Tool definition for "${name}":`, JSON.stringify(def, null, 2));
|
|
3073
3075
|
tools.push(def);
|
|
3074
3076
|
}
|
|
@@ -3179,9 +3181,7 @@ function patternToId(pattern) {
|
|
|
3179
3181
|
return pattern.replace(/^\//, "").replace(/\//g, "_").replace(/:/g, "");
|
|
3180
3182
|
}
|
|
3181
3183
|
var ResourceRegistryClass = class {
|
|
3182
|
-
|
|
3183
|
-
this.resources = /* @__PURE__ */ new Map();
|
|
3184
|
-
}
|
|
3184
|
+
resources = /* @__PURE__ */ new Map();
|
|
3185
3185
|
/**
|
|
3186
3186
|
* Register a resource
|
|
3187
3187
|
*/
|
|
@@ -3277,9 +3277,7 @@ function interpolateVariables(template, variables) {
|
|
|
3277
3277
|
});
|
|
3278
3278
|
}
|
|
3279
3279
|
var PromptRegistryClass = class {
|
|
3280
|
-
|
|
3281
|
-
this.prompts = /* @__PURE__ */ new Map();
|
|
3282
|
-
}
|
|
3280
|
+
prompts = /* @__PURE__ */ new Map();
|
|
3283
3281
|
/**
|
|
3284
3282
|
* Register a prompt
|
|
3285
3283
|
*/
|
|
@@ -3333,8 +3331,8 @@ function getMCPRegistry() {
|
|
|
3333
3331
|
prompts: promptRegistry.getAll()
|
|
3334
3332
|
};
|
|
3335
3333
|
}
|
|
3336
|
-
function registerTool(id,
|
|
3337
|
-
toolRegistry.register(id,
|
|
3334
|
+
function registerTool(id, tool3) {
|
|
3335
|
+
toolRegistry.register(id, tool3);
|
|
3338
3336
|
}
|
|
3339
3337
|
function registerResource(id, resource2) {
|
|
3340
3338
|
resourceRegistry.register(id, resource2);
|
|
@@ -3409,9 +3407,7 @@ function createWorkflow(config) {
|
|
|
3409
3407
|
};
|
|
3410
3408
|
}
|
|
3411
3409
|
var AgentRegistryClass = class {
|
|
3412
|
-
|
|
3413
|
-
this.agents = /* @__PURE__ */ new Map();
|
|
3414
|
-
}
|
|
3410
|
+
agents = /* @__PURE__ */ new Map();
|
|
3415
3411
|
/**
|
|
3416
3412
|
* Register an agent
|
|
3417
3413
|
*/
|
|
@@ -4106,12 +4102,10 @@ function createMockAdapter() {
|
|
|
4106
4102
|
|
|
4107
4103
|
// src/platform/compat/fs.ts
|
|
4108
4104
|
var NodeFileSystem = class {
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
this.initialized = false;
|
|
4114
|
-
}
|
|
4105
|
+
fs = null;
|
|
4106
|
+
os = null;
|
|
4107
|
+
path = null;
|
|
4108
|
+
initialized = false;
|
|
4115
4109
|
async ensureInitialized() {
|
|
4116
4110
|
if (this.initialized)
|
|
4117
4111
|
return;
|
|
@@ -4627,15 +4621,15 @@ async function discoverTools(dir, result, context, verbose) {
|
|
|
4627
4621
|
for (const file of files) {
|
|
4628
4622
|
try {
|
|
4629
4623
|
const module = await importModule(file, context);
|
|
4630
|
-
const
|
|
4631
|
-
if (!
|
|
4624
|
+
const tool3 = module.default;
|
|
4625
|
+
if (!tool3 || typeof tool3.execute !== "function") {
|
|
4632
4626
|
if (verbose) {
|
|
4633
4627
|
agentLogger.warn(`[Discovery] ${file} does not export a valid tool`);
|
|
4634
4628
|
}
|
|
4635
4629
|
continue;
|
|
4636
4630
|
}
|
|
4637
4631
|
const id = filenameToId(file);
|
|
4638
|
-
const toolWithId = { ...
|
|
4632
|
+
const toolWithId = { ...tool3, id };
|
|
4639
4633
|
registerTool(id, toolWithId);
|
|
4640
4634
|
result.tools.set(id, toolWithId);
|
|
4641
4635
|
if (verbose) {
|
|
@@ -4842,38 +4836,38 @@ function isAISDKModel(value) {
|
|
|
4842
4836
|
);
|
|
4843
4837
|
}
|
|
4844
4838
|
var useAISDK = aiSDKModel;
|
|
4845
|
-
function getToolSchema(
|
|
4846
|
-
if (
|
|
4847
|
-
return
|
|
4839
|
+
function getToolSchema(tool3) {
|
|
4840
|
+
if (tool3.inputSchemaJson) {
|
|
4841
|
+
return tool3.inputSchemaJson;
|
|
4848
4842
|
}
|
|
4849
4843
|
try {
|
|
4850
|
-
if (
|
|
4851
|
-
const schema =
|
|
4844
|
+
if (tool3.inputSchema && typeof tool3.inputSchema === "object") {
|
|
4845
|
+
const schema = tool3.inputSchema;
|
|
4852
4846
|
if (schema._def && schema._def.typeName) {
|
|
4853
|
-
return zodToJsonSchema(
|
|
4847
|
+
return zodToJsonSchema(tool3.inputSchema);
|
|
4854
4848
|
}
|
|
4855
4849
|
}
|
|
4856
4850
|
} catch {
|
|
4857
4851
|
}
|
|
4858
4852
|
return { type: "object", properties: {} };
|
|
4859
4853
|
}
|
|
4860
|
-
function toAISDKTool(
|
|
4854
|
+
function toAISDKTool(tool3) {
|
|
4861
4855
|
return {
|
|
4862
4856
|
type: "function",
|
|
4863
4857
|
function: {
|
|
4864
|
-
name:
|
|
4865
|
-
description:
|
|
4866
|
-
parameters: getToolSchema(
|
|
4858
|
+
name: tool3.id,
|
|
4859
|
+
description: tool3.description,
|
|
4860
|
+
parameters: getToolSchema(tool3)
|
|
4867
4861
|
}
|
|
4868
4862
|
};
|
|
4869
4863
|
}
|
|
4870
4864
|
function toAISDKTools(tools) {
|
|
4871
4865
|
const aiTools = {};
|
|
4872
|
-
for (const [name,
|
|
4866
|
+
for (const [name, tool3] of Object.entries(tools)) {
|
|
4873
4867
|
aiTools[name] = {
|
|
4874
|
-
description:
|
|
4875
|
-
parameters: getToolSchema(
|
|
4876
|
-
execute:
|
|
4868
|
+
description: tool3.description,
|
|
4869
|
+
parameters: getToolSchema(tool3),
|
|
4870
|
+
execute: tool3.execute
|
|
4877
4871
|
};
|
|
4878
4872
|
}
|
|
4879
4873
|
return aiTools;
|
|
@@ -4902,9 +4896,9 @@ async function setupAI(options = {}) {
|
|
|
4902
4896
|
try {
|
|
4903
4897
|
const manifest = await fs.readTextFile(manifestPath).then(JSON.parse);
|
|
4904
4898
|
if (manifest.tools) {
|
|
4905
|
-
for (const [id,
|
|
4906
|
-
tools.set(id,
|
|
4907
|
-
toolRegistry.register(id,
|
|
4899
|
+
for (const [id, tool3] of Object.entries(manifest.tools)) {
|
|
4900
|
+
tools.set(id, tool3);
|
|
4901
|
+
toolRegistry.register(id, tool3);
|
|
4908
4902
|
}
|
|
4909
4903
|
}
|
|
4910
4904
|
if (manifest.agents) {
|
|
@@ -4943,8 +4937,8 @@ async function setupAI(options = {}) {
|
|
|
4943
4937
|
};
|
|
4944
4938
|
try {
|
|
4945
4939
|
const discovered = await discoverAll(discoveryConfig);
|
|
4946
|
-
for (const [id,
|
|
4947
|
-
tools.set(id,
|
|
4940
|
+
for (const [id, tool3] of discovered.tools) {
|
|
4941
|
+
tools.set(id, tool3);
|
|
4948
4942
|
}
|
|
4949
4943
|
for (const [id, agent2] of discovered.agents) {
|
|
4950
4944
|
agents.set(id, agent2);
|
|
@@ -4965,9 +4959,9 @@ async function setupAI(options = {}) {
|
|
|
4965
4959
|
}
|
|
4966
4960
|
}
|
|
4967
4961
|
}
|
|
4968
|
-
for (const [id,
|
|
4969
|
-
tools.set(id,
|
|
4970
|
-
toolRegistry.register(id,
|
|
4962
|
+
for (const [id, tool3] of Object.entries(manualTools)) {
|
|
4963
|
+
tools.set(id, tool3);
|
|
4964
|
+
toolRegistry.register(id, tool3);
|
|
4971
4965
|
}
|
|
4972
4966
|
for (const [id, agent2] of Object.entries(manualAgents)) {
|
|
4973
4967
|
agents.set(id, agent2);
|
|
@@ -5001,8 +4995,8 @@ async function setupAI(options = {}) {
|
|
|
5001
4995
|
},
|
|
5002
4996
|
toAISDKTools() {
|
|
5003
4997
|
const toolsRecord = {};
|
|
5004
|
-
for (const [id,
|
|
5005
|
-
toolsRecord[id] =
|
|
4998
|
+
for (const [id, tool3] of tools) {
|
|
4999
|
+
toolsRecord[id] = tool3;
|
|
5006
5000
|
}
|
|
5007
5001
|
return toAISDKTools(toolsRecord);
|
|
5008
5002
|
}
|
|
@@ -5012,6 +5006,7 @@ async function setupAI(options = {}) {
|
|
|
5012
5006
|
|
|
5013
5007
|
// src/ai/mcp/server.ts
|
|
5014
5008
|
var MCPServer = class {
|
|
5009
|
+
config;
|
|
5015
5010
|
constructor(config) {
|
|
5016
5011
|
this.config = config;
|
|
5017
5012
|
}
|
|
@@ -5086,12 +5081,12 @@ var MCPServer = class {
|
|
|
5086
5081
|
listTools() {
|
|
5087
5082
|
const registry = getMCPRegistry();
|
|
5088
5083
|
const tools = [];
|
|
5089
|
-
for (const [id,
|
|
5090
|
-
if (
|
|
5091
|
-
const inputSchema =
|
|
5084
|
+
for (const [id, tool3] of registry.tools.entries()) {
|
|
5085
|
+
if (tool3.mcp?.enabled !== false) {
|
|
5086
|
+
const inputSchema = tool3.inputSchemaJson || zodToJsonSchema(tool3.inputSchema);
|
|
5092
5087
|
tools.push({
|
|
5093
5088
|
name: id,
|
|
5094
|
-
description:
|
|
5089
|
+
description: tool3.description,
|
|
5095
5090
|
inputSchema
|
|
5096
5091
|
});
|
|
5097
5092
|
}
|
|
@@ -5301,14 +5296,31 @@ function createMCPServer(config) {
|
|
|
5301
5296
|
}
|
|
5302
5297
|
|
|
5303
5298
|
// src/ai/index.ts
|
|
5304
|
-
import {
|
|
5299
|
+
import {
|
|
5300
|
+
convertToModelMessages,
|
|
5301
|
+
cosineSimilarity,
|
|
5302
|
+
createIdGenerator,
|
|
5303
|
+
embed,
|
|
5304
|
+
embedMany,
|
|
5305
|
+
experimental_createMCPClient,
|
|
5306
|
+
experimental_generateImage,
|
|
5307
|
+
experimental_generateSpeech,
|
|
5308
|
+
experimental_transcribe,
|
|
5309
|
+
generateObject,
|
|
5310
|
+
generateText,
|
|
5311
|
+
smoothStream,
|
|
5312
|
+
streamObject,
|
|
5313
|
+
streamText,
|
|
5314
|
+
tool as tool2
|
|
5315
|
+
} from "ai";
|
|
5305
5316
|
import { openai } from "@ai-sdk/openai";
|
|
5306
5317
|
import { anthropic } from "@ai-sdk/anthropic";
|
|
5307
5318
|
|
|
5308
5319
|
// src/ai/production/rate-limit/limiter.ts
|
|
5309
5320
|
var FixedWindowLimiter = class {
|
|
5321
|
+
requests = /* @__PURE__ */ new Map();
|
|
5322
|
+
config;
|
|
5310
5323
|
constructor(config) {
|
|
5311
|
-
this.requests = /* @__PURE__ */ new Map();
|
|
5312
5324
|
this.config = config;
|
|
5313
5325
|
}
|
|
5314
5326
|
check(identifier) {
|
|
@@ -5349,8 +5361,10 @@ var FixedWindowLimiter = class {
|
|
|
5349
5361
|
}
|
|
5350
5362
|
};
|
|
5351
5363
|
var TokenBucketLimiter = class {
|
|
5364
|
+
buckets = /* @__PURE__ */ new Map();
|
|
5365
|
+
config;
|
|
5366
|
+
refillRate;
|
|
5352
5367
|
constructor(config) {
|
|
5353
|
-
this.buckets = /* @__PURE__ */ new Map();
|
|
5354
5368
|
this.config = config;
|
|
5355
5369
|
this.refillRate = config.maxRequests / config.windowMs;
|
|
5356
5370
|
}
|
|
@@ -5453,9 +5467,7 @@ function rateLimitMiddleware(config) {
|
|
|
5453
5467
|
|
|
5454
5468
|
// src/ai/production/cache/cache.ts
|
|
5455
5469
|
var MemoryCache = class {
|
|
5456
|
-
|
|
5457
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
5458
|
-
}
|
|
5470
|
+
cache = /* @__PURE__ */ new Map();
|
|
5459
5471
|
set(key, response) {
|
|
5460
5472
|
this.cache.set(key, {
|
|
5461
5473
|
response,
|
|
@@ -5486,8 +5498,9 @@ var MemoryCache = class {
|
|
|
5486
5498
|
}
|
|
5487
5499
|
};
|
|
5488
5500
|
var LRUCache = class {
|
|
5501
|
+
cache = /* @__PURE__ */ new Map();
|
|
5502
|
+
maxSize;
|
|
5489
5503
|
constructor(maxSize = 100) {
|
|
5490
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
5491
5504
|
this.maxSize = maxSize;
|
|
5492
5505
|
}
|
|
5493
5506
|
set(key, response) {
|
|
@@ -5531,9 +5544,10 @@ var LRUCache = class {
|
|
|
5531
5544
|
}
|
|
5532
5545
|
};
|
|
5533
5546
|
var TTLCache = class {
|
|
5547
|
+
cache = /* @__PURE__ */ new Map();
|
|
5548
|
+
ttl;
|
|
5549
|
+
cleanupInterval = null;
|
|
5534
5550
|
constructor(ttl = 3e5) {
|
|
5535
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
5536
|
-
this.cleanupInterval = null;
|
|
5537
5551
|
this.ttl = ttl;
|
|
5538
5552
|
this.startCleanup();
|
|
5539
5553
|
}
|
|
@@ -5687,13 +5701,14 @@ function cacheMiddleware(config) {
|
|
|
5687
5701
|
|
|
5688
5702
|
// src/ai/production/cost-tracking/tracker.ts
|
|
5689
5703
|
var CostTracker = class {
|
|
5704
|
+
records = [];
|
|
5705
|
+
config;
|
|
5706
|
+
dailyTotal = 0;
|
|
5707
|
+
monthlyTotal = 0;
|
|
5708
|
+
lastDayReset = Date.now();
|
|
5709
|
+
lastMonthReset = Date.now();
|
|
5710
|
+
resetInterval = null;
|
|
5690
5711
|
constructor(config) {
|
|
5691
|
-
this.records = [];
|
|
5692
|
-
this.dailyTotal = 0;
|
|
5693
|
-
this.monthlyTotal = 0;
|
|
5694
|
-
this.lastDayReset = Date.now();
|
|
5695
|
-
this.lastMonthReset = Date.now();
|
|
5696
|
-
this.resetInterval = null;
|
|
5697
5712
|
this.config = config;
|
|
5698
5713
|
this.startPeriodicReset();
|
|
5699
5714
|
}
|
|
@@ -5956,6 +5971,7 @@ var PII_PATTERNS = {
|
|
|
5956
5971
|
creditCard: /\b\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}\b/g
|
|
5957
5972
|
};
|
|
5958
5973
|
var InputValidator = class {
|
|
5974
|
+
config;
|
|
5959
5975
|
constructor(config) {
|
|
5960
5976
|
this.config = config || {};
|
|
5961
5977
|
}
|
|
@@ -6015,6 +6031,7 @@ var InputValidator = class {
|
|
|
6015
6031
|
}
|
|
6016
6032
|
};
|
|
6017
6033
|
var OutputFilter = class {
|
|
6034
|
+
config;
|
|
6018
6035
|
constructor(config) {
|
|
6019
6036
|
this.config = config || {};
|
|
6020
6037
|
}
|
|
@@ -6288,12 +6305,13 @@ function hasLockSupport(backend) {
|
|
|
6288
6305
|
// src/ai/workflow/backends/memory.ts
|
|
6289
6306
|
var DEFAULT_MAX_QUEUE_SIZE = 1e4;
|
|
6290
6307
|
var MemoryBackend = class {
|
|
6308
|
+
runs = /* @__PURE__ */ new Map();
|
|
6309
|
+
checkpoints = /* @__PURE__ */ new Map();
|
|
6310
|
+
approvals = /* @__PURE__ */ new Map();
|
|
6311
|
+
queue = [];
|
|
6312
|
+
locks = /* @__PURE__ */ new Map();
|
|
6313
|
+
config;
|
|
6291
6314
|
constructor(config = {}) {
|
|
6292
|
-
this.runs = /* @__PURE__ */ new Map();
|
|
6293
|
-
this.checkpoints = /* @__PURE__ */ new Map();
|
|
6294
|
-
this.approvals = /* @__PURE__ */ new Map();
|
|
6295
|
-
this.queue = [];
|
|
6296
|
-
this.locks = /* @__PURE__ */ new Map();
|
|
6297
6315
|
this.config = {
|
|
6298
6316
|
prefix: "wf:",
|
|
6299
6317
|
debug: false,
|
|
@@ -6624,6 +6642,7 @@ var MemoryBackend = class {
|
|
|
6624
6642
|
|
|
6625
6643
|
// src/ai/workflow/executor/dag-executor.ts
|
|
6626
6644
|
var DAGExecutor = class {
|
|
6645
|
+
config;
|
|
6627
6646
|
constructor(config) {
|
|
6628
6647
|
this.config = {
|
|
6629
6648
|
maxConcurrency: 10,
|
|
@@ -7165,6 +7184,7 @@ var DAGExecutor = class {
|
|
|
7165
7184
|
|
|
7166
7185
|
// src/ai/workflow/executor/checkpoint-manager.ts
|
|
7167
7186
|
var CheckpointManager = class {
|
|
7187
|
+
config;
|
|
7168
7188
|
constructor(config) {
|
|
7169
7189
|
this.config = {
|
|
7170
7190
|
debug: false,
|
|
@@ -7322,6 +7342,7 @@ var CheckpointManager = class {
|
|
|
7322
7342
|
// src/ai/workflow/executor/step-executor.ts
|
|
7323
7343
|
var DEFAULT_STEP_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
7324
7344
|
var StepExecutor = class {
|
|
7345
|
+
config;
|
|
7325
7346
|
constructor(config = {}) {
|
|
7326
7347
|
this.config = {
|
|
7327
7348
|
defaultTimeout: DEFAULT_STEP_TIMEOUT_MS,
|
|
@@ -7429,8 +7450,8 @@ var StepExecutor = class {
|
|
|
7429
7450
|
/**
|
|
7430
7451
|
* Execute a tool
|
|
7431
7452
|
*/
|
|
7432
|
-
async executeTool(
|
|
7433
|
-
const resolvedTool = typeof
|
|
7453
|
+
async executeTool(tool3, input) {
|
|
7454
|
+
const resolvedTool = typeof tool3 === "string" ? this.getTool(tool3) : tool3;
|
|
7434
7455
|
const result = await resolvedTool.execute(
|
|
7435
7456
|
input,
|
|
7436
7457
|
{
|
|
@@ -7466,13 +7487,13 @@ var StepExecutor = class {
|
|
|
7466
7487
|
`Tool registry not configured. Cannot resolve tool "${id}"`
|
|
7467
7488
|
);
|
|
7468
7489
|
}
|
|
7469
|
-
const
|
|
7470
|
-
if (!
|
|
7490
|
+
const tool3 = this.config.toolRegistry.get(id);
|
|
7491
|
+
if (!tool3) {
|
|
7471
7492
|
const available = this.config.toolRegistry.list?.() ?? [];
|
|
7472
7493
|
const suggestion = available.length > 0 ? ` Available tools: ${available.slice(0, 5).join(", ")}${available.length > 5 ? "..." : ""}` : " No tools are registered.";
|
|
7473
7494
|
throw new Error(`Tool not found: "${id}".${suggestion}`);
|
|
7474
7495
|
}
|
|
7475
|
-
return
|
|
7496
|
+
return tool3;
|
|
7476
7497
|
}
|
|
7477
7498
|
/**
|
|
7478
7499
|
* Check if a step should be skipped
|
|
@@ -7543,8 +7564,15 @@ var StepExecutor = class {
|
|
|
7543
7564
|
|
|
7544
7565
|
// src/ai/workflow/executor/workflow-executor.ts
|
|
7545
7566
|
var WorkflowExecutor = class _WorkflowExecutor {
|
|
7567
|
+
config;
|
|
7568
|
+
stepExecutor;
|
|
7569
|
+
checkpointManager;
|
|
7570
|
+
dagExecutor;
|
|
7571
|
+
workflows = /* @__PURE__ */ new Map();
|
|
7572
|
+
blobResolver;
|
|
7573
|
+
/** Default lock duration: 30 seconds */
|
|
7574
|
+
static DEFAULT_LOCK_DURATION = 3e4;
|
|
7546
7575
|
constructor(config) {
|
|
7547
|
-
this.workflows = /* @__PURE__ */ new Map();
|
|
7548
7576
|
this.config = {
|
|
7549
7577
|
maxConcurrency: 10,
|
|
7550
7578
|
debug: false,
|
|
@@ -7580,10 +7608,6 @@ var WorkflowExecutor = class _WorkflowExecutor {
|
|
|
7580
7608
|
};
|
|
7581
7609
|
}
|
|
7582
7610
|
}
|
|
7583
|
-
static {
|
|
7584
|
-
/** Default lock duration: 30 seconds */
|
|
7585
|
-
this.DEFAULT_LOCK_DURATION = 3e4;
|
|
7586
|
-
}
|
|
7587
7611
|
/**
|
|
7588
7612
|
* Register a workflow definition
|
|
7589
7613
|
*/
|
|
@@ -7938,8 +7962,10 @@ var WorkflowExecutor = class _WorkflowExecutor {
|
|
|
7938
7962
|
|
|
7939
7963
|
// src/ai/workflow/runtime/approval-manager.ts
|
|
7940
7964
|
var ApprovalManager = class {
|
|
7965
|
+
config;
|
|
7966
|
+
expirationTimer;
|
|
7967
|
+
destroyed = false;
|
|
7941
7968
|
constructor(config) {
|
|
7942
|
-
this.destroyed = false;
|
|
7943
7969
|
this.config = {
|
|
7944
7970
|
expirationCheckInterval: 6e4,
|
|
7945
7971
|
// Check every minute
|
|
@@ -8166,6 +8192,10 @@ var ApprovalManager = class {
|
|
|
8166
8192
|
|
|
8167
8193
|
// src/ai/workflow/api/workflow-client.ts
|
|
8168
8194
|
var WorkflowClient = class {
|
|
8195
|
+
backend;
|
|
8196
|
+
executor;
|
|
8197
|
+
approvalManager;
|
|
8198
|
+
debug;
|
|
8169
8199
|
constructor(config = {}) {
|
|
8170
8200
|
this.debug = config.debug ?? false;
|
|
8171
8201
|
this.backend = config.backend ?? new MemoryBackend({ debug: this.debug });
|
|
@@ -8357,12 +8387,16 @@ export {
|
|
|
8357
8387
|
agentAsTool,
|
|
8358
8388
|
agentRegistry,
|
|
8359
8389
|
aiSDKModel,
|
|
8390
|
+
tool2 as aiTool,
|
|
8360
8391
|
anthropic,
|
|
8361
8392
|
branch,
|
|
8362
8393
|
cacheMiddleware,
|
|
8394
|
+
convertToModelMessages,
|
|
8395
|
+
cosineSimilarity,
|
|
8363
8396
|
costTrackingMiddleware,
|
|
8364
8397
|
createCache,
|
|
8365
8398
|
createCostTracker,
|
|
8399
|
+
createIdGenerator,
|
|
8366
8400
|
createMCPServer,
|
|
8367
8401
|
createMemory,
|
|
8368
8402
|
createRateLimiter,
|
|
@@ -8370,6 +8404,12 @@ export {
|
|
|
8370
8404
|
createWorkflowClient,
|
|
8371
8405
|
detectPlatform,
|
|
8372
8406
|
discoverAll,
|
|
8407
|
+
embed,
|
|
8408
|
+
embedMany,
|
|
8409
|
+
experimental_createMCPClient,
|
|
8410
|
+
experimental_generateImage,
|
|
8411
|
+
experimental_generateSpeech,
|
|
8412
|
+
experimental_transcribe,
|
|
8373
8413
|
generateObject,
|
|
8374
8414
|
generateText,
|
|
8375
8415
|
getAgent,
|
|
@@ -8396,7 +8436,9 @@ export {
|
|
|
8396
8436
|
resourceRegistry,
|
|
8397
8437
|
securityMiddleware,
|
|
8398
8438
|
setupAI,
|
|
8439
|
+
smoothStream,
|
|
8399
8440
|
step,
|
|
8441
|
+
streamObject,
|
|
8400
8442
|
streamText,
|
|
8401
8443
|
supportsCapability,
|
|
8402
8444
|
toAISDKTool,
|