veryfront 0.0.71 → 0.0.72

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
@@ -23,6 +23,19 @@ globalThis.Deno = globalThis.Deno || {
23
23
  function getTextFromParts(parts) {
24
24
  return parts.filter((p) => p.type === "text").map((p) => p.text).join("");
25
25
  }
26
+ function getToolArguments(part) {
27
+ if ("args" in part && part.args !== void 0) {
28
+ return part.args;
29
+ }
30
+ if ("input" in part && part.input !== void 0) {
31
+ return part.input;
32
+ }
33
+ const toolName = part.toolName;
34
+ const toolCallId = part.toolCallId;
35
+ throw new Error(
36
+ `Tool call part for "${toolName}" (${toolCallId}) missing both 'args' and 'input' fields`
37
+ );
38
+ }
26
39
 
27
40
  // src/ai/providers/openai.ts
28
41
  import { z as z2 } from "zod";
@@ -179,7 +192,6 @@ var OpenAIStreamChunkSchema = z.object({
179
192
  })).min(1)
180
193
  });
181
194
  var BaseProvider = class {
182
- config;
183
195
  constructor(config) {
184
196
  this.config = config;
185
197
  this.validateConfig();
@@ -394,12 +406,9 @@ var OpenAIResponseSchema = z2.object({
394
406
  }).optional()
395
407
  });
396
408
  var OpenAIProvider = class extends BaseProvider {
397
- name = "openai";
398
- apiKey;
399
- baseURL;
400
- organizationId;
401
409
  constructor(config) {
402
410
  super(config);
411
+ this.name = "openai";
403
412
  this.apiKey = config.apiKey;
404
413
  this.baseURL = config.baseURL || "https://api.openai.com/v1";
405
414
  this.organizationId = config.organizationId;
@@ -501,11 +510,9 @@ var OpenAIProvider = class extends BaseProvider {
501
510
 
502
511
  // src/ai/providers/anthropic.ts
503
512
  var AnthropicProvider = class extends BaseProvider {
504
- name = "anthropic";
505
- apiKey;
506
- baseURL;
507
513
  constructor(config) {
508
514
  super(config);
515
+ this.name = "anthropic";
509
516
  this.apiKey = config.apiKey;
510
517
  this.baseURL = config.baseURL || "https://api.anthropic.com";
511
518
  }
@@ -803,11 +810,9 @@ var GoogleResponseSchema = z3.object({
803
810
  }).optional()
804
811
  });
805
812
  var GoogleProvider = class extends BaseProvider {
806
- name = "google";
807
- apiKey;
808
- baseURL;
809
813
  constructor(config) {
810
814
  super(config);
815
+ this.name = "google";
811
816
  this.apiKey = config.apiKey;
812
817
  this.baseURL = config.baseURL || "https://generativelanguage.googleapis.com/v1beta";
813
818
  }
@@ -929,9 +934,11 @@ function getEnv(key) {
929
934
 
930
935
  // src/ai/providers/factory.ts
931
936
  var ProviderRegistry = class {
932
- providers = /* @__PURE__ */ new Map();
933
- config = {};
934
- autoInitialized = false;
937
+ constructor() {
938
+ this.providers = /* @__PURE__ */ new Map();
939
+ this.config = {};
940
+ this.autoInitialized = false;
941
+ }
935
942
  /**
936
943
  * Auto-initialize providers from environment variables
937
944
  * This is called lazily when a provider is first requested
@@ -1355,7 +1362,9 @@ function generateToolId() {
1355
1362
  return `tool_${Date.now()}_${toolIdCounter++}`;
1356
1363
  }
1357
1364
  var ToolRegistryClass = class {
1358
- tools = /* @__PURE__ */ new Map();
1365
+ constructor() {
1366
+ this.tools = /* @__PURE__ */ new Map();
1367
+ }
1359
1368
  register(id, toolInstance) {
1360
1369
  if (this.tools.has(id)) {
1361
1370
  agentLogger.debug(`Tool "${id}" is already registered. Overwriting.`);
@@ -1615,7 +1624,9 @@ function patternToId(pattern) {
1615
1624
  return pattern.replace(/^\//, "").replace(/\//g, "_").replace(/:/g, "");
1616
1625
  }
1617
1626
  var ResourceRegistryClass = class {
1618
- resources = /* @__PURE__ */ new Map();
1627
+ constructor() {
1628
+ this.resources = /* @__PURE__ */ new Map();
1629
+ }
1619
1630
  /**
1620
1631
  * Register a resource
1621
1632
  */
@@ -1711,7 +1722,9 @@ function interpolateVariables(template, variables) {
1711
1722
  });
1712
1723
  }
1713
1724
  var PromptRegistryClass = class {
1714
- prompts = /* @__PURE__ */ new Map();
1725
+ constructor() {
1726
+ this.prompts = /* @__PURE__ */ new Map();
1727
+ }
1715
1728
  /**
1716
1729
  * Register a prompt
1717
1730
  */
@@ -1842,7 +1855,9 @@ function createWorkflow(config) {
1842
1855
  };
1843
1856
  }
1844
1857
  var AgentRegistryClass = class {
1845
- agents = /* @__PURE__ */ new Map();
1858
+ constructor() {
1859
+ this.agents = /* @__PURE__ */ new Map();
1860
+ }
1846
1861
  /**
1847
1862
  * Register an agent
1848
1863
  */
@@ -2764,10 +2779,12 @@ function createMockAdapter() {
2764
2779
 
2765
2780
  // src/platform/compat/fs.ts
2766
2781
  var NodeFileSystem = class {
2767
- fs = null;
2768
- os = null;
2769
- path = null;
2770
- initialized = false;
2782
+ constructor() {
2783
+ this.fs = null;
2784
+ this.os = null;
2785
+ this.path = null;
2786
+ this.initialized = false;
2787
+ }
2771
2788
  async ensureInitialized() {
2772
2789
  if (this.initialized)
2773
2790
  return;
@@ -3508,9 +3525,8 @@ function generateId(prefix) {
3508
3525
 
3509
3526
  // src/ai/agent/memory.ts
3510
3527
  var ConversationMemory = class {
3511
- messages = [];
3512
- config;
3513
3528
  constructor(config) {
3529
+ this.messages = [];
3514
3530
  this.config = config;
3515
3531
  }
3516
3532
  async add(message) {
@@ -3555,10 +3571,8 @@ var ConversationMemory = class {
3555
3571
  }
3556
3572
  };
3557
3573
  var BufferMemory = class {
3558
- messages = [];
3559
- config;
3560
- bufferSize;
3561
3574
  constructor(config) {
3575
+ this.messages = [];
3562
3576
  this.config = config;
3563
3577
  this.bufferSize = config.maxMessages || 10;
3564
3578
  }
@@ -3592,11 +3606,9 @@ var BufferMemory = class {
3592
3606
  }
3593
3607
  };
3594
3608
  var SummaryMemory = class {
3595
- messages = [];
3596
- summary = "";
3597
- config;
3598
- summaryThreshold;
3599
3609
  constructor(config) {
3610
+ this.messages = [];
3611
+ this.summary = "";
3600
3612
  this.config = config;
3601
3613
  this.summaryThreshold = config.maxMessages || 20;
3602
3614
  }
@@ -3705,9 +3717,11 @@ var VERYFRONT_PATHS = {
3705
3717
 
3706
3718
  // src/core/utils/bundle-manifest.ts
3707
3719
  var InMemoryBundleManifestStore = class {
3708
- metadata = /* @__PURE__ */ new Map();
3709
- code = /* @__PURE__ */ new Map();
3710
- sourceIndex = /* @__PURE__ */ new Map();
3720
+ constructor() {
3721
+ this.metadata = /* @__PURE__ */ new Map();
3722
+ this.code = /* @__PURE__ */ new Map();
3723
+ this.sourceIndex = /* @__PURE__ */ new Map();
3724
+ }
3711
3725
  getBundleMetadata(key) {
3712
3726
  const entry = this.metadata.get(key);
3713
3727
  if (!entry)
@@ -3999,14 +4013,16 @@ var ContextPropagation = class {
3999
4013
 
4000
4014
  // src/observability/tracing/manager.ts
4001
4015
  var TracingManager = class {
4002
- state = {
4003
- initialized: false,
4004
- tracer: null,
4005
- api: null,
4006
- propagator: null
4007
- };
4008
- spanOps = null;
4009
- contextProp = null;
4016
+ constructor() {
4017
+ this.state = {
4018
+ initialized: false,
4019
+ tracer: null,
4020
+ api: null,
4021
+ propagator: null
4022
+ };
4023
+ this.spanOps = null;
4024
+ this.contextProp = null;
4025
+ }
4010
4026
  async initialize(config = {}, adapter) {
4011
4027
  if (this.state.initialized) {
4012
4028
  serverLogger.debug("[tracing] Already initialized");
@@ -4141,7 +4157,7 @@ function convertMessageToProvider(msg) {
4141
4157
  content
4142
4158
  };
4143
4159
  const toolCallParts = msg.parts.filter(
4144
- (p) => p.type === "tool-call"
4160
+ (p) => p.type === "tool-call" || p.type.startsWith("tool-") && p.type !== "tool-result"
4145
4161
  );
4146
4162
  if (toolCallParts.length > 0) {
4147
4163
  providerMsg.tool_calls = toolCallParts.map((tc) => ({
@@ -4149,7 +4165,8 @@ function convertMessageToProvider(msg) {
4149
4165
  type: "function",
4150
4166
  function: {
4151
4167
  name: tc.toolName,
4152
- arguments: JSON.stringify(tc.args)
4168
+ // Use type-safe helper to extract args/input (throws if missing)
4169
+ arguments: JSON.stringify(getToolArguments(tc))
4153
4170
  }
4154
4171
  }));
4155
4172
  }
@@ -4163,11 +4180,8 @@ function convertMessageToProvider(msg) {
4163
4180
  return providerMsg;
4164
4181
  }
4165
4182
  var AgentRuntime = class {
4166
- id;
4167
- config;
4168
- memory;
4169
- status = "idle";
4170
4183
  constructor(id, config) {
4184
+ this.status = "idle";
4171
4185
  this.id = id;
4172
4186
  this.config = config;
4173
4187
  const memoryConfig = config.memory || { type: "conversation", maxTokens: 4e3 };
@@ -4326,7 +4340,7 @@ var AgentRuntime = class {
4326
4340
  if (response.toolCalls) {
4327
4341
  for (const tc of response.toolCalls) {
4328
4342
  assistantParts.push({
4329
- type: "tool-call",
4343
+ type: `tool-${tc.name}`,
4330
4344
  toolCallId: tc.id,
4331
4345
  toolName: tc.name,
4332
4346
  args: tc.arguments
@@ -4637,7 +4651,7 @@ var AgentRuntime = class {
4637
4651
  });
4638
4652
  }
4639
4653
  streamParts.push({
4640
- type: "tool-call",
4654
+ type: `tool-${tc.name}`,
4641
4655
  toolCallId: tc.id,
4642
4656
  toolName: tc.name,
4643
4657
  args
@@ -5151,7 +5165,6 @@ async function setupAI(options = {}) {
5151
5165
 
5152
5166
  // src/ai/mcp/server.ts
5153
5167
  var MCPServer = class {
5154
- config;
5155
5168
  constructor(config) {
5156
5169
  this.config = config;
5157
5170
  }
@@ -5463,9 +5476,8 @@ import { anthropic } from "@ai-sdk/anthropic";
5463
5476
 
5464
5477
  // src/ai/production/rate-limit/limiter.ts
5465
5478
  var FixedWindowLimiter = class {
5466
- requests = /* @__PURE__ */ new Map();
5467
- config;
5468
5479
  constructor(config) {
5480
+ this.requests = /* @__PURE__ */ new Map();
5469
5481
  this.config = config;
5470
5482
  }
5471
5483
  check(identifier) {
@@ -5506,10 +5518,8 @@ var FixedWindowLimiter = class {
5506
5518
  }
5507
5519
  };
5508
5520
  var TokenBucketLimiter = class {
5509
- buckets = /* @__PURE__ */ new Map();
5510
- config;
5511
- refillRate;
5512
5521
  constructor(config) {
5522
+ this.buckets = /* @__PURE__ */ new Map();
5513
5523
  this.config = config;
5514
5524
  this.refillRate = config.maxRequests / config.windowMs;
5515
5525
  }
@@ -5612,7 +5622,9 @@ function rateLimitMiddleware(config) {
5612
5622
 
5613
5623
  // src/ai/production/cache/cache.ts
5614
5624
  var MemoryCache = class {
5615
- cache = /* @__PURE__ */ new Map();
5625
+ constructor() {
5626
+ this.cache = /* @__PURE__ */ new Map();
5627
+ }
5616
5628
  set(key, response) {
5617
5629
  this.cache.set(key, {
5618
5630
  response,
@@ -5643,9 +5655,8 @@ var MemoryCache = class {
5643
5655
  }
5644
5656
  };
5645
5657
  var LRUCache = class {
5646
- cache = /* @__PURE__ */ new Map();
5647
- maxSize;
5648
5658
  constructor(maxSize = 100) {
5659
+ this.cache = /* @__PURE__ */ new Map();
5649
5660
  this.maxSize = maxSize;
5650
5661
  }
5651
5662
  set(key, response) {
@@ -5689,10 +5700,9 @@ var LRUCache = class {
5689
5700
  }
5690
5701
  };
5691
5702
  var TTLCache = class {
5692
- cache = /* @__PURE__ */ new Map();
5693
- ttl;
5694
- cleanupInterval = null;
5695
5703
  constructor(ttl = 3e5) {
5704
+ this.cache = /* @__PURE__ */ new Map();
5705
+ this.cleanupInterval = null;
5696
5706
  this.ttl = ttl;
5697
5707
  this.startCleanup();
5698
5708
  }
@@ -5846,14 +5856,13 @@ function cacheMiddleware(config) {
5846
5856
 
5847
5857
  // src/ai/production/cost-tracking/tracker.ts
5848
5858
  var CostTracker = class {
5849
- records = [];
5850
- config;
5851
- dailyTotal = 0;
5852
- monthlyTotal = 0;
5853
- lastDayReset = Date.now();
5854
- lastMonthReset = Date.now();
5855
- resetInterval = null;
5856
5859
  constructor(config) {
5860
+ this.records = [];
5861
+ this.dailyTotal = 0;
5862
+ this.monthlyTotal = 0;
5863
+ this.lastDayReset = Date.now();
5864
+ this.lastMonthReset = Date.now();
5865
+ this.resetInterval = null;
5857
5866
  this.config = config;
5858
5867
  this.startPeriodicReset();
5859
5868
  }
@@ -6116,7 +6125,6 @@ var PII_PATTERNS = {
6116
6125
  creditCard: /\b\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}\b/g
6117
6126
  };
6118
6127
  var InputValidator = class {
6119
- config;
6120
6128
  constructor(config) {
6121
6129
  this.config = config || {};
6122
6130
  }
@@ -6176,7 +6184,6 @@ var InputValidator = class {
6176
6184
  }
6177
6185
  };
6178
6186
  var OutputFilter = class {
6179
- config;
6180
6187
  constructor(config) {
6181
6188
  this.config = config || {};
6182
6189
  }
@@ -6450,13 +6457,12 @@ function hasLockSupport(backend) {
6450
6457
  // src/ai/workflow/backends/memory.ts
6451
6458
  var DEFAULT_MAX_QUEUE_SIZE = 1e4;
6452
6459
  var MemoryBackend = class {
6453
- runs = /* @__PURE__ */ new Map();
6454
- checkpoints = /* @__PURE__ */ new Map();
6455
- approvals = /* @__PURE__ */ new Map();
6456
- queue = [];
6457
- locks = /* @__PURE__ */ new Map();
6458
- config;
6459
6460
  constructor(config = {}) {
6461
+ this.runs = /* @__PURE__ */ new Map();
6462
+ this.checkpoints = /* @__PURE__ */ new Map();
6463
+ this.approvals = /* @__PURE__ */ new Map();
6464
+ this.queue = [];
6465
+ this.locks = /* @__PURE__ */ new Map();
6460
6466
  this.config = {
6461
6467
  prefix: "wf:",
6462
6468
  debug: false,
@@ -6787,7 +6793,6 @@ var MemoryBackend = class {
6787
6793
 
6788
6794
  // src/ai/workflow/executor/dag-executor.ts
6789
6795
  var DAGExecutor = class {
6790
- config;
6791
6796
  constructor(config) {
6792
6797
  this.config = {
6793
6798
  maxConcurrency: 10,
@@ -7329,7 +7334,6 @@ var DAGExecutor = class {
7329
7334
 
7330
7335
  // src/ai/workflow/executor/checkpoint-manager.ts
7331
7336
  var CheckpointManager = class {
7332
- config;
7333
7337
  constructor(config) {
7334
7338
  this.config = {
7335
7339
  debug: false,
@@ -7487,7 +7491,6 @@ var CheckpointManager = class {
7487
7491
  // src/ai/workflow/executor/step-executor.ts
7488
7492
  var DEFAULT_STEP_TIMEOUT_MS = 5 * 60 * 1e3;
7489
7493
  var StepExecutor = class {
7490
- config;
7491
7494
  constructor(config = {}) {
7492
7495
  this.config = {
7493
7496
  defaultTimeout: DEFAULT_STEP_TIMEOUT_MS,
@@ -7709,15 +7712,8 @@ var StepExecutor = class {
7709
7712
 
7710
7713
  // src/ai/workflow/executor/workflow-executor.ts
7711
7714
  var WorkflowExecutor = class _WorkflowExecutor {
7712
- config;
7713
- stepExecutor;
7714
- checkpointManager;
7715
- dagExecutor;
7716
- workflows = /* @__PURE__ */ new Map();
7717
- blobResolver;
7718
- /** Default lock duration: 30 seconds */
7719
- static DEFAULT_LOCK_DURATION = 3e4;
7720
7715
  constructor(config) {
7716
+ this.workflows = /* @__PURE__ */ new Map();
7721
7717
  this.config = {
7722
7718
  maxConcurrency: 10,
7723
7719
  debug: false,
@@ -7753,6 +7749,10 @@ var WorkflowExecutor = class _WorkflowExecutor {
7753
7749
  };
7754
7750
  }
7755
7751
  }
7752
+ static {
7753
+ /** Default lock duration: 30 seconds */
7754
+ this.DEFAULT_LOCK_DURATION = 3e4;
7755
+ }
7756
7756
  /**
7757
7757
  * Register a workflow definition
7758
7758
  */
@@ -8107,10 +8107,8 @@ var WorkflowExecutor = class _WorkflowExecutor {
8107
8107
 
8108
8108
  // src/ai/workflow/runtime/approval-manager.ts
8109
8109
  var ApprovalManager = class {
8110
- config;
8111
- expirationTimer;
8112
- destroyed = false;
8113
8110
  constructor(config) {
8111
+ this.destroyed = false;
8114
8112
  this.config = {
8115
8113
  expirationCheckInterval: 6e4,
8116
8114
  // Check every minute
@@ -8337,10 +8335,6 @@ var ApprovalManager = class {
8337
8335
 
8338
8336
  // src/ai/workflow/api/workflow-client.ts
8339
8337
  var WorkflowClient = class {
8340
- backend;
8341
- executor;
8342
- approvalManager;
8343
- debug;
8344
8338
  constructor(config = {}) {
8345
8339
  this.debug = config.debug ?? false;
8346
8340
  this.backend = config.backend ?? new MemoryBackend({ debug: this.debug });