veryfront 0.0.31 → 0.0.33

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/index.js CHANGED
@@ -865,9 +865,6 @@ var GoogleProvider = class extends BaseProvider {
865
865
  }
866
866
  };
867
867
 
868
- // src/platform/compat/process.ts
869
- import process from "node:process";
870
-
871
868
  // src/platform/compat/runtime.ts
872
869
  var isDeno = typeof Deno !== "undefined";
873
870
  var isNode = typeof globalThis.process !== "undefined" && globalThis.process?.versions?.node !== void 0;
@@ -875,17 +872,25 @@ var isBun = typeof globalThis.Bun !== "undefined";
875
872
  var isCloudflare = typeof globalThis !== "undefined" && "caches" in globalThis && "WebSocketPair" in globalThis;
876
873
 
877
874
  // src/platform/compat/process.ts
875
+ var nodeProcess = globalThis.process;
876
+ var hasNodeProcess2 = !!nodeProcess?.versions?.node;
878
877
  function cwd() {
879
878
  if (isDeno) {
880
879
  return process.cwd();
881
880
  }
882
- return process.cwd();
881
+ if (hasNodeProcess2) {
882
+ return nodeProcess.cwd();
883
+ }
884
+ throw new Error("cwd() is not supported in this runtime");
883
885
  }
884
886
  function getEnv(key) {
885
887
  if (isDeno) {
886
888
  return process.env(key);
887
889
  }
888
- return process.env[key];
890
+ if (hasNodeProcess2) {
891
+ return nodeProcess.env[key];
892
+ }
893
+ return void 0;
889
894
  }
890
895
 
891
896
  // src/ai/providers/factory.ts
@@ -1038,7 +1043,9 @@ var ProviderRegistry = class {
1038
1043
  this.config = {};
1039
1044
  }
1040
1045
  };
1041
- var providerRegistry = new ProviderRegistry();
1046
+ var PROVIDER_REGISTRY_KEY = "__veryfront_provider_registry__";
1047
+ var _globalProvider = globalThis;
1048
+ var providerRegistry = _globalProvider[PROVIDER_REGISTRY_KEY] ||= new ProviderRegistry();
1042
1049
  function initializeProviders(config) {
1043
1050
  providerRegistry.initialize(config);
1044
1051
  }
@@ -1308,7 +1315,9 @@ var ToolRegistryClass = class {
1308
1315
  return Array.from(this.tools.values()).map(toolToProviderDefinition);
1309
1316
  }
1310
1317
  };
1311
- var toolRegistry = new ToolRegistryClass();
1318
+ var TOOL_REGISTRY_KEY = "__veryfront_tool_registry__";
1319
+ var _globalTool = globalThis;
1320
+ var toolRegistry = _globalTool[TOOL_REGISTRY_KEY] ||= new ToolRegistryClass();
1312
1321
  function toolToProviderDefinition(tool2) {
1313
1322
  const jsonSchema = tool2.inputSchemaJson || zodToJsonSchema(tool2.inputSchema);
1314
1323
  agentLogger.info(
@@ -1709,8 +1718,15 @@ var BYTES_PER_MB = 1024 * 1024;
1709
1718
  // deno.json
1710
1719
  var deno_default = {
1711
1720
  name: "veryfront",
1712
- version: "0.0.31",
1713
- nodeModulesDir: "auto",
1721
+ version: "0.0.33",
1722
+ exclude: [
1723
+ "npm/",
1724
+ "dist/",
1725
+ "coverage/",
1726
+ "scripts/",
1727
+ "examples/",
1728
+ "tests/"
1729
+ ],
1714
1730
  exports: {
1715
1731
  ".": "./src/index.ts",
1716
1732
  "./cli": "./src/cli/main.ts",
@@ -1804,11 +1820,13 @@ var deno_default = {
1804
1820
  unified: "https://esm.sh/unified@11.0.5?dts",
1805
1821
  ai: "https://esm.sh/ai@5.0.76?deps=react@18.3.1,react-dom@18.3.1",
1806
1822
  "ai/react": "https://esm.sh/@ai-sdk/react@2.0.59?deps=react@18.3.1,react-dom@18.3.1",
1823
+ "@ai-sdk/react": "https://esm.sh/@ai-sdk/react@2.0.59?deps=react@18.3.1,react-dom@18.3.1",
1807
1824
  "@ai-sdk/openai": "https://esm.sh/@ai-sdk/openai@2.0.1",
1808
1825
  "@ai-sdk/anthropic": "https://esm.sh/@ai-sdk/anthropic@2.0.4",
1809
1826
  unocss: "https://esm.sh/unocss@0.59.0",
1810
1827
  "@unocss/core": "https://esm.sh/@unocss/core@0.59.0",
1811
- "@unocss/preset-wind": "https://esm.sh/@unocss/preset-wind@0.59.0"
1828
+ "@unocss/preset-wind": "https://esm.sh/@unocss/preset-wind@0.59.0",
1829
+ redis: "npm:redis"
1812
1830
  },
1813
1831
  compilerOptions: {
1814
1832
  jsx: "react-jsx",
@@ -1834,8 +1852,6 @@ var deno_default = {
1834
1852
  test: "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --unstable-worker-options --unstable-net",
1835
1853
  "test:unit": "DENO_JOBS=1 deno test --parallel --allow-all --v8-flags=--max-old-space-size=8192 --ignore=tests --unstable-worker-options --unstable-net",
1836
1854
  "test:integration": "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all tests --unstable-worker-options --unstable-net",
1837
- "test:batches": "deno run --allow-all scripts/test-batches.ts",
1838
- "test:unsafe": "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --unstable-worker-options --unstable-net",
1839
1855
  "test:coverage": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --unstable-worker-options --unstable-net || exit 1",
1840
1856
  "test:coverage:unit": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --ignore=tests --unstable-worker-options --unstable-net || exit 1",
1841
1857
  "test:coverage:integration": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage tests --unstable-worker-options --unstable-net || exit 1",
@@ -1849,6 +1865,7 @@ var deno_default = {
1849
1865
  "lint:ban-deep-imports": "deno run --allow-read scripts/ban-deep-imports.ts",
1850
1866
  "lint:ban-internal-root-imports": "deno run --allow-read scripts/ban-internal-root-imports.ts",
1851
1867
  "lint:check-awaits": "deno run --allow-read scripts/check-unawaited-promises.ts",
1868
+ "lint:platform": "deno run --allow-read scripts/lint-platform-agnostic.ts",
1852
1869
  "check:circular": "deno run -A jsr:@cunarist/deno-circular-deps src/index.ts"
1853
1870
  },
1854
1871
  lint: {
@@ -2030,13 +2047,10 @@ function applyEnvFromAdapter(config, envAdapter) {
2030
2047
  }
2031
2048
  function applyEnvFromDeno(config) {
2032
2049
  try {
2033
- const denoEnv = globalThis.Deno?.env;
2034
- if (!denoEnv)
2035
- return;
2036
- config.enabled = denoEnv.get("OTEL_TRACES_ENABLED") === "true" || denoEnv.get("VERYFRONT_OTEL") === "1" || config.enabled;
2037
- config.serviceName = denoEnv.get("OTEL_SERVICE_NAME") || config.serviceName;
2038
- config.endpoint = denoEnv.get("OTEL_EXPORTER_OTLP_ENDPOINT") || denoEnv.get("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") || config.endpoint;
2039
- const exporterType = denoEnv.get("OTEL_TRACES_EXPORTER");
2050
+ config.enabled = getEnv("OTEL_TRACES_ENABLED") === "true" || getEnv("VERYFRONT_OTEL") === "1" || config.enabled;
2051
+ config.serviceName = getEnv("OTEL_SERVICE_NAME") || config.serviceName;
2052
+ config.endpoint = getEnv("OTEL_EXPORTER_OTLP_ENDPOINT") || getEnv("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") || config.endpoint;
2053
+ const exporterType = getEnv("OTEL_TRACES_EXPORTER");
2040
2054
  if (isValidExporter(exporterType)) {
2041
2055
  config.exporter = exporterType;
2042
2056
  }
@@ -2590,7 +2604,7 @@ var AgentRuntime = class {
2590
2604
  * Execute agent loop with streaming
2591
2605
  * Uses Vercel AI SDK Data Stream Protocol format
2592
2606
  */
2593
- async executeAgentLoopStreaming(provider, model, systemPrompt, messages, controller, encoder, callbacks, messageId) {
2607
+ async executeAgentLoopStreaming(provider, model, systemPrompt, messages, controller, encoder, callbacks, _messageId) {
2594
2608
  const capabilities = getPlatformCapabilities();
2595
2609
  const maxSteps = this.getMaxSteps(capabilities.maxAgentSteps);
2596
2610
  const toolCalls = [];
@@ -3081,7 +3095,9 @@ var ResourceRegistryClass = class {
3081
3095
  this.resources.clear();
3082
3096
  }
3083
3097
  };
3084
- var resourceRegistry = new ResourceRegistryClass();
3098
+ var RESOURCE_REGISTRY_KEY = "__veryfront_resource_registry__";
3099
+ var _globalResource = globalThis;
3100
+ var resourceRegistry = _globalResource[RESOURCE_REGISTRY_KEY] ||= new ResourceRegistryClass();
3085
3101
 
3086
3102
  // src/ai/mcp/prompt.ts
3087
3103
  function prompt(config) {
@@ -3158,7 +3174,9 @@ var PromptRegistryClass = class {
3158
3174
  this.prompts.clear();
3159
3175
  }
3160
3176
  };
3161
- var promptRegistry = new PromptRegistryClass();
3177
+ var PROMPT_REGISTRY_KEY = "__veryfront_prompt_registry__";
3178
+ var _globalPrompt = globalThis;
3179
+ var promptRegistry = _globalPrompt[PROMPT_REGISTRY_KEY] ||= new PromptRegistryClass();
3162
3180
 
3163
3181
  // src/ai/mcp/registry.ts
3164
3182
  function getMCPRegistry() {
@@ -3187,7 +3205,62 @@ function getMCPStats() {
3187
3205
  };
3188
3206
  }
3189
3207
 
3190
- // src/ai/agent/registry.ts
3208
+ // src/ai/agent/composition.ts
3209
+ import { z as z5 } from "zod";
3210
+ function agentAsTool(agent2, description) {
3211
+ return {
3212
+ id: `agent_${agent2.id}`,
3213
+ description,
3214
+ inputSchema: z5.object({
3215
+ input: z5.string().describe("Input for the agent")
3216
+ }),
3217
+ async execute({ input }) {
3218
+ const response = await agent2.generate({ input });
3219
+ return {
3220
+ text: response.text,
3221
+ toolCalls: response.toolCalls.length,
3222
+ status: response.status
3223
+ };
3224
+ }
3225
+ };
3226
+ }
3227
+ function createWorkflow(config) {
3228
+ return {
3229
+ async execute(input) {
3230
+ const result = {
3231
+ output: input,
3232
+ steps: [],
3233
+ context: { ...config.initialContext }
3234
+ };
3235
+ for (const step2 of config.steps) {
3236
+ if (step2.skip && await step2.skip(result.context)) {
3237
+ result.steps.push({
3238
+ name: step2.name,
3239
+ output: "",
3240
+ skipped: true
3241
+ });
3242
+ continue;
3243
+ }
3244
+ const response = await step2.agent.generate({
3245
+ input: result.output,
3246
+ context: result.context
3247
+ });
3248
+ let output = response.text;
3249
+ if (step2.transform) {
3250
+ output = await step2.transform(output);
3251
+ }
3252
+ result.output = output;
3253
+ result.steps.push({
3254
+ name: step2.name,
3255
+ output,
3256
+ skipped: false
3257
+ });
3258
+ result.context[step2.name] = output;
3259
+ }
3260
+ return result;
3261
+ }
3262
+ };
3263
+ }
3191
3264
  var AgentRegistryClass = class {
3192
3265
  constructor() {
3193
3266
  this.agents = /* @__PURE__ */ new Map();
@@ -3195,11 +3268,11 @@ var AgentRegistryClass = class {
3195
3268
  /**
3196
3269
  * Register an agent
3197
3270
  */
3198
- register(id, agentInstance) {
3271
+ register(id, agent2) {
3199
3272
  if (this.agents.has(id)) {
3200
3273
  agentLogger.warn(`Agent "${id}" is already registered. Overwriting.`);
3201
3274
  }
3202
- this.agents.set(id, agentInstance);
3275
+ this.agents.set(id, agent2);
3203
3276
  agentLogger.debug(`Registered agent: ${id}`);
3204
3277
  }
3205
3278
  /**
@@ -3221,7 +3294,7 @@ var AgentRegistryClass = class {
3221
3294
  return Array.from(this.agents.keys());
3222
3295
  }
3223
3296
  /**
3224
- * Get all agents
3297
+ * Get all agents as a Map
3225
3298
  */
3226
3299
  getAll() {
3227
3300
  return new Map(this.agents);
@@ -3233,7 +3306,26 @@ var AgentRegistryClass = class {
3233
3306
  this.agents.clear();
3234
3307
  }
3235
3308
  };
3236
- var agentRegistry = new AgentRegistryClass();
3309
+ var AGENT_REGISTRY_KEY = "__veryfront_agent_registry__";
3310
+ var _globalAgent = globalThis;
3311
+ var agentRegistry = _globalAgent[AGENT_REGISTRY_KEY] ||= new AgentRegistryClass();
3312
+ function registerAgent(id, agent2) {
3313
+ agentRegistry.register(id, agent2);
3314
+ }
3315
+ function getAgent(id) {
3316
+ return agentRegistry.get(id);
3317
+ }
3318
+ function getAllAgentIds() {
3319
+ return agentRegistry.getAllIds();
3320
+ }
3321
+ function getAgentsAsTools(descriptions) {
3322
+ const tools = {};
3323
+ for (const [id, agent2] of agentRegistry.getAll()) {
3324
+ const description = descriptions?.[id] || `Call ${id} agent`;
3325
+ tools[id] = agentAsTool(agent2, description);
3326
+ }
3327
+ return tools;
3328
+ }
3237
3329
 
3238
3330
  // src/ai/agent/factory.ts
3239
3331
  function createAgentStreamResult(stream) {
@@ -3332,92 +3424,6 @@ function generateAgentId() {
3332
3424
  return `agent_${Date.now()}_${agentIdCounter++}`;
3333
3425
  }
3334
3426
 
3335
- // src/ai/agent/composition.ts
3336
- import { z as z5 } from "zod";
3337
- function agentAsTool(agent2, description) {
3338
- return {
3339
- id: `agent_${agent2.id}`,
3340
- description,
3341
- inputSchema: z5.object({
3342
- input: z5.string().describe("Input for the agent")
3343
- }),
3344
- async execute({ input }) {
3345
- const response = await agent2.generate({ input });
3346
- return {
3347
- text: response.text,
3348
- toolCalls: response.toolCalls.length,
3349
- status: response.status
3350
- };
3351
- }
3352
- };
3353
- }
3354
- function createWorkflow(config) {
3355
- return {
3356
- async execute(input) {
3357
- const result = {
3358
- output: input,
3359
- steps: [],
3360
- context: { ...config.initialContext }
3361
- };
3362
- for (const step2 of config.steps) {
3363
- if (step2.skip && await step2.skip(result.context)) {
3364
- result.steps.push({
3365
- name: step2.name,
3366
- output: "",
3367
- skipped: true
3368
- });
3369
- continue;
3370
- }
3371
- const response = await step2.agent.generate({
3372
- input: result.output,
3373
- context: result.context
3374
- });
3375
- let output = response.text;
3376
- if (step2.transform) {
3377
- output = await step2.transform(output);
3378
- }
3379
- result.output = output;
3380
- result.steps.push({
3381
- name: step2.name,
3382
- output,
3383
- skipped: false
3384
- });
3385
- result.context[step2.name] = output;
3386
- }
3387
- return result;
3388
- }
3389
- };
3390
- }
3391
- var AgentRegistryClass2 = class {
3392
- constructor() {
3393
- this.agents = /* @__PURE__ */ new Map();
3394
- }
3395
- register(id, agent2) {
3396
- this.agents.set(id, agent2);
3397
- }
3398
- get(id) {
3399
- return this.agents.get(id);
3400
- }
3401
- getAll() {
3402
- return new Map(this.agents);
3403
- }
3404
- clear() {
3405
- this.agents.clear();
3406
- }
3407
- };
3408
- var agentRegistry2 = new AgentRegistryClass2();
3409
- function registerAgent(id, agent2) {
3410
- agentRegistry2.register(id, agent2);
3411
- }
3412
- function getAgentsAsTools(descriptions) {
3413
- const tools = {};
3414
- for (const [id, agent2] of agentRegistry2.getAll()) {
3415
- const description = descriptions?.[id] || `Call ${id} agent`;
3416
- tools[id] = agentAsTool(agent2, description);
3417
- }
3418
- return tools;
3419
- }
3420
-
3421
3427
  // src/core/config/schema.ts
3422
3428
  import { z as z6 } from "zod";
3423
3429
  var corsSchema = z6.union([z6.boolean(), z6.object({ origin: z6.string().optional() }).strict()]);
@@ -3603,7 +3609,7 @@ function findUnknownTopLevelKeys(input) {
3603
3609
  }
3604
3610
 
3605
3611
  // src/core/config/loader.ts
3606
- import { join } from "path";
3612
+ import { join } from "node:path";
3607
3613
  function getDefaultImportMapForConfig() {
3608
3614
  return { imports: getReactImportMap(REACT_DEFAULT_VERSION) };
3609
3615
  }
@@ -4041,6 +4047,7 @@ async function discoverAgents(dir, result, context, verbose) {
4041
4047
  const id = agent2.id || filenameToId(file);
4042
4048
  registerAgent(id, agent2);
4043
4049
  result.agents.set(id, agent2);
4050
+ trackAgentPath(id, file);
4044
4051
  if (verbose) {
4045
4052
  agentLogger.info(`[Discovery] Registered agent: ${id}`);
4046
4053
  }
@@ -4196,6 +4203,10 @@ function filePathToPattern(filePath, baseDir) {
4196
4203
  pattern = "/" + pattern;
4197
4204
  return pattern;
4198
4205
  }
4206
+ var discoveredAgentPaths = /* @__PURE__ */ new Map();
4207
+ function trackAgentPath(id, filePath) {
4208
+ discoveredAgentPaths.set(id, filePath);
4209
+ }
4199
4210
 
4200
4211
  // src/ai/adapters/ai-sdk.ts
4201
4212
  var MODEL_BRAND = "ai-sdk-model";
@@ -5812,7 +5823,7 @@ var pathMod = null;
5812
5823
  if (typeof Deno === "undefined") {
5813
5824
  pathMod = nodePath;
5814
5825
  } else {
5815
- import("path").then((mod) => {
5826
+ import("node:path").then((mod) => {
5816
5827
  pathMod = mod;
5817
5828
  });
5818
5829
  }
@@ -7893,7 +7904,7 @@ export {
7893
7904
  WorkflowClient,
7894
7905
  agent,
7895
7906
  agentAsTool,
7896
- agentRegistry2 as agentRegistry,
7907
+ agentRegistry,
7897
7908
  aiSDKModel,
7898
7909
  anthropic,
7899
7910
  branch,
@@ -7910,7 +7921,9 @@ export {
7910
7921
  discoverAll,
7911
7922
  generateObject,
7912
7923
  generateText,
7924
+ getAgent,
7913
7925
  getAgentsAsTools,
7926
+ getAllAgentIds,
7914
7927
  getMCPRegistry,
7915
7928
  getMCPStats,
7916
7929
  getPlatformCapabilities,