@voltro/ai 0.87.0 → 0.88.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +169 -6
  2. package/THIRD-PARTY-NOTICES.md +649 -53
  3. package/dist/agent.js +1 -2
  4. package/dist/agentConstants.js +1 -2
  5. package/dist/agentExecutor.js +1 -2
  6. package/dist/aiSettings.js +1 -2
  7. package/dist/api.js +1 -2
  8. package/dist/appTools.js +1 -2
  9. package/dist/budget.js +1 -2
  10. package/dist/callEvidence.js +1 -2
  11. package/dist/copilot.js +1 -2
  12. package/dist/cost.js +1 -2
  13. package/dist/embed.js +1 -2
  14. package/dist/embeddingProvider.js +1 -2
  15. package/dist/eval.js +1 -2
  16. package/dist/events.js +1 -2
  17. package/dist/executableModalities.js +1 -2
  18. package/dist/gateway.js +1 -2
  19. package/dist/gatewayCatalog.js +1 -2
  20. package/dist/gatewayMedia.js +1 -2
  21. package/dist/inferenceDispatch.js +1 -2
  22. package/dist/inferenceQueue.js +1 -2
  23. package/dist/jsonOutputValidation.js +1 -2
  24. package/dist/mcpClient.js +1 -2
  25. package/dist/mcpTools.js +1 -2
  26. package/dist/media.js +1 -2
  27. package/dist/mediaBytes.js +1 -2
  28. package/dist/mediaCall.js +1 -2
  29. package/dist/mediaTaskProvider.js +1 -2
  30. package/dist/middleware.js +1 -2
  31. package/dist/observe.js +1 -2
  32. package/dist/prompts.js +1 -2
  33. package/dist/provider.js +1 -2
  34. package/dist/realtimeEvent.js +1 -2
  35. package/dist/realtimeSession.js +1 -2
  36. package/dist/rerank.js +1 -2
  37. package/dist/resumableStream.js +1 -2
  38. package/dist/retrieveReranked.js +1 -2
  39. package/dist/runAndPersist.js +1 -2
  40. package/dist/semanticCache.js +1 -2
  41. package/dist/speechProvider.js +1 -2
  42. package/dist/streamRegistry.js +1 -2
  43. package/dist/streamText.js +1 -2
  44. package/dist/streamTranscribe.js +1 -2
  45. package/dist/streamWakeups.js +1 -2
  46. package/dist/structuredEvidence.js +1 -2
  47. package/dist/test.js +1 -2
  48. package/dist/threads.js +1 -2
  49. package/dist/tools.js +1 -2
  50. package/dist/transcribe.js +1 -2
  51. package/dist/transcriptionEvent.js +1 -2
  52. package/dist/workflow.js +1 -2
  53. package/package.json +13 -13
package/dist/agent.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AGENT_MESSAGES_TABLE as e } from "./agentConstants.js";
2
2
  import { Schema as t } from "effect";
3
3
  import { defineAction as n, defineQuery as r } from "@voltro/protocol";
4
- //#region src/agentDescriptor.ts
4
+ // src/agentDescriptor.ts
5
5
  var i = t.Struct({ prompt: t.String }), a = "@voltro/ai/AgentDescriptor", o = class extends t.TaggedError()("AgentThreadAccessDenied", { threadId: t.String }) {
6
6
  get message() {
7
7
  return `agent thread '${this.threadId}' belongs to another subject`;
@@ -60,5 +60,4 @@ var i = t.Struct({ prompt: t.String }), a = "@voltro/ai/AgentDescriptor", o = cl
60
60
  })
61
61
  };
62
62
  };
63
- //#endregion
64
63
  export { o as AgentThreadAccessDenied, l as agentInputSchema, d as agentMessageSchema, p as agentRouteDescriptors, s as defineAgent, c as isAgentDescriptor };
@@ -1,4 +1,3 @@
1
- //#region src/agentConstants.ts
1
+ // src/agentConstants.ts
2
2
  var e = "_voltro_agent_threads", t = "_voltro_agent_messages";
3
- //#endregion
4
3
  export { t as AGENT_MESSAGES_TABLE, e as AGENT_THREADS_TABLE };
@@ -3,7 +3,7 @@ import { AgentThreadAccessDenied as t } from "./agent.js";
3
3
  import { appendMessage as n, ensureThreadOwned as r, getMessages as i, getThread as a } from "./threads.js";
4
4
  import { historyToModelMessages as o, runAssistant as s } from "./runAndPersist.js";
5
5
  import { Effect as c } from "effect";
6
- //#region src/agentExecutor.ts
6
+ // src/agentExecutor.ts
7
7
  var l = "@voltro/ai/AgentExecutor", u = (e, t) => ({
8
8
  _brand: l,
9
9
  descriptor: e,
@@ -51,5 +51,4 @@ var l = "@voltro/ai/AgentExecutor", u = (e, t) => ({
51
51
  let o = yield* a(e, n);
52
52
  return o !== null && o.subjectId !== null && o.subjectId !== r ? yield* c.fail(new t({ threadId: n })) : yield* i(e, n);
53
53
  });
54
- //#endregion
55
54
  export { u as defineAgentExecutor, d as isAgentExecutor, h as loadAgentMessages, p as resolveAgentModel, f as resolveSystem, m as runAgentTurn };
@@ -1,5 +1,5 @@
1
1
  import { readEnvValue as e } from "@voltro/env";
2
- //#region src/aiSettings.ts
2
+ // src/aiSettings.ts
3
3
  var t = (t, n) => {
4
4
  let r = e(t);
5
5
  if (typeof r == "string" && r !== "") return r;
@@ -7,5 +7,4 @@ var t = (t, n) => {
7
7
  let i = n[t];
8
8
  return i === void 0 || i === "" ? void 0 : i;
9
9
  }, n = (e) => e.NODE_ENV === "production";
10
- //#endregion
11
10
  export { t as aiSetting, n as isProductionEnv };
package/dist/api.js CHANGED
@@ -7,7 +7,7 @@ import { captureStructuredEvidence as c } from "./structuredEvidence.js";
7
7
  import { NoObjectGeneratedError as l, Output as u, generateObject as d, generateText as f, jsonSchema as p, stepCountIs as m } from "ai";
8
8
  import { Context as h, Effect as g, Schema as _ } from "effect";
9
9
  import { jsonSchemaOf as v } from "@voltro/protocol";
10
- //#region src/api.ts
10
+ // src/api.ts
11
11
  var y = class extends _.TaggedError()("AiError", {
12
12
  reason: _.Literals(["generation", "decode"]),
13
13
  message: _.String,
@@ -195,5 +195,4 @@ var y = class extends _.TaggedError()("AiError", {
195
195
  generateText: (e) => C(e),
196
196
  generateObject: (e) => D(e)
197
197
  };
198
- //#endregion
199
198
  export { y as AiError, k as AiService, b as aiGenerationError, A as defaultAiService, D as generateObject, E as generateObjectJson, O as generateObjectWithTools, C as generateText, T as outputJsonSchema };
package/dist/appTools.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineTool as e } from "./tools.js";
2
- //#region src/appTools.ts
2
+ // src/appTools.ts
3
3
  var t = /* @__PURE__ */ new Map(), n = (e) => {
4
4
  let n = t.get(e);
5
5
  if (n !== void 0) return n;
@@ -76,5 +76,4 @@ var t = /* @__PURE__ */ new Map(), n = (e) => {
76
76
  ...t.descriptor.output === void 0 ? {} : { output: t.descriptor.output },
77
77
  handler: (e) => Promise.resolve(t.invoke(e))
78
78
  }));
79
- //#endregion
80
79
  export { s as agentActor, l as appToolDecision, d as appTools, a as passesPolicy, u as synthesizeToolSpecs };
package/dist/budget.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Effect as e, Schema as t } from "effect";
2
2
  import { and as n, bigint as r, eq as i, generateId as a, id as o, isNull as s, queryFor as c, registerRetention as l, retentionTtlMsFromEnv as u, table as d, text as f, timestamp as p } from "@voltro/database";
3
- //#region src/budget.ts
3
+ // src/budget.ts
4
4
  var m = class extends t.TaggedError()("AiBudgetExceeded", {
5
5
  tenantId: t.NullOr(t.String),
6
6
  limitUsd: t.Number,
@@ -197,5 +197,4 @@ var m = class extends t.TaggedError()("AiBudgetExceeded", {
197
197
  return "released";
198
198
  }));
199
199
  });
200
- //#endregion
201
200
  export { v as AI_BUDGET_RESERVATIONS_TABLE, _ as AI_BUDGET_TABLE, m as AiBudgetExceeded, h as AiBudgetInvalidInput, g as AiBudgetReservationConflict, b as aiBudgetReservationsTable, y as aiBudgetTable, A as releaseAiBudget, k as requireAiBudget };
@@ -1,6 +1,6 @@
1
1
  import { gatewayCostUsd as e } from "./cost.js";
2
2
  import { Schema as t } from "effect";
3
- //#region src/callEvidence.ts
3
+ // src/callEvidence.ts
4
4
  var n = t.Number.pipe(t.check(t.isInt()), t.check(t.isGreaterThanOrEqualTo(0)), t.check(t.isLessThanOrEqualTo(2 ** 53 - 1))), r = t.Struct({
5
5
  provider: t.String,
6
6
  model: t.String,
@@ -47,5 +47,4 @@ var n = t.Number.pipe(t.check(t.isInt()), t.check(t.isGreaterThanOrEqualTo(0)),
47
47
  }
48
48
  };
49
49
  };
50
- //#endregion
51
50
  export { r as AiCallEvidenceSchema, a as normalizeAiCallEvidence };
package/dist/copilot.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Schema as e } from "effect";
2
2
  import { and as t, contains as n, eq as r, gt as i, gte as a, inSet as o, lt as s, lte as c, neq as l } from "@voltro/database";
3
- //#region src/copilot.ts
3
+ // src/copilot.ts
4
4
  var u = class extends e.TaggedError()("CopilotRejected", {
5
5
  reason: e.Literals([
6
6
  "unknown-table",
@@ -122,5 +122,4 @@ var u = class extends e.TaggedError()("CopilotRejected", {
122
122
  prompt: e
123
123
  }), t);
124
124
  };
125
- //#endregion
126
125
  export { d as COPILOT_MAX_LIMIT, _ as CopilotProposalSchema, u as CopilotRejected, v as buildCopilotSystemPrompt, y as runDataCopilot, g as validateCopilotProposal };
package/dist/cost.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AI_BUDGET_RESERVATIONS_TABLE as e, AI_BUDGET_TABLE as t, AiBudgetExceeded as n, AiBudgetInvalidInput as r, AiBudgetReservationConflict as i, aiBudgetReservationsTable as a, aiBudgetTable as o, releaseAiBudget as s, requireAiBudget as c } from "./budget.js";
2
2
  import { Data as l, Effect as u } from "effect";
3
3
  import { and as d, eq as f, generateId as p, gte as m, id as h, integer as g, queryFor as _, registerRetention as v, retentionTtlMsFromEnv as y, table as b, text as x, timestamp as S } from "@voltro/database";
4
- //#region src/cost.ts
4
+ // src/cost.ts
5
5
  var C = {
6
6
  "claude-opus-4-8": {
7
7
  inputPer1M: 15,
@@ -238,5 +238,4 @@ var C = {
238
238
  ], r = _(M), i = n.length === 0 ? r : r.where(n.length === 1 ? n[0] : d(...n));
239
239
  return (await e.query(i.descriptor)).reduce((e, t) => e + (Number(t.costMicroUsd) || 0), 0) / 1e6;
240
240
  });
241
- //#endregion
242
241
  export { e as AI_BUDGET_RESERVATIONS_TABLE, t as AI_BUDGET_TABLE, j as AI_USAGE_TABLE, n as AiBudgetExceeded, r as AiBudgetInvalidInput, i as AiBudgetReservationConflict, I as AiUsageLedgerError, F as AiUsageReceiptConflict, C as MODEL_PRICING_DEFAULTS, a as aiBudgetReservationsTable, o as aiBudgetTable, V as aiSpendUsd, M as aiUsageTable, A as estimateCostUsd, P as gatewayCostUsd, O as isMeteredUsage, E as modelPricing, k as normaliseUsage, D as priceForModel, R as recordAiUsage, B as recordAiUsageBestEffort, s as releaseAiBudget, c as requireAiBudget, T as setModelPricing };
package/dist/embed.js CHANGED
@@ -2,7 +2,7 @@ import { aiGenerationError as e } from "./api.js";
2
2
  import { embeddingProviderFromEnv as t, resolveEmbeddingModel as n } from "./embeddingProvider.js";
3
3
  import { cosineSimilarity as r, embed as i, embedMany as a } from "ai";
4
4
  import { Effect as o } from "effect";
5
- //#region src/embed.ts
5
+ // src/embed.ts
6
6
  var s = (r, a) => o.tryPromise({
7
7
  try: async (e) => {
8
8
  let o = a ?? t();
@@ -37,5 +37,4 @@ var s = (r, a) => o.tryPromise({
37
37
  if (t !== void 0 && e.length !== t) throw Error(`embedding ${n}: expected ${t} dimensions, received ${e.length}`);
38
38
  if (e.length === 0 || e.some((e) => !Number.isFinite(e))) throw Error(`embedding ${n}: expected a non-empty vector of finite numbers`);
39
39
  }, d = (e, t) => r([...e], [...t]);
40
- //#endregion
41
40
  export { d as cosineSimilarity, s as embed, c as embedMany };
@@ -1,6 +1,6 @@
1
1
  import { aiSetting as e, isProductionEnv as t } from "./aiSettings.js";
2
2
  import { createGateway as n, gateway as r } from "@ai-sdk/gateway";
3
- //#region src/embeddingProvider.ts
3
+ // src/embeddingProvider.ts
4
4
  var i = (e, t) => ({
5
5
  specificationVersion: "v4",
6
6
  provider: "mock",
@@ -65,5 +65,4 @@ var i = (e, t) => ({
65
65
  ...c !== void 0 && Number.isFinite(c) ? { mockDim: c } : {}
66
66
  };
67
67
  };
68
- //#endregion
69
68
  export { l as embeddingProviderChoice, u as embeddingProviderFromEnv, c as embeddingProviderKeyEnvVar, a as hashToVector, o as resolveEmbeddingModel };
package/dist/eval.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { providerFromEnv as e } from "./provider.js";
2
2
  import { generateObject as t } from "./api.js";
3
3
  import { Effect as n, Schema as r } from "effect";
4
- //#region src/eval.ts
4
+ // src/eval.ts
5
5
  var i = (e) => {
6
6
  if (e.name.trim() === "") throw Error("defineEval: name must be non-empty");
7
7
  if (e.cases.length === 0) throw Error(`defineEval "${e.name}": at least one case is required`);
@@ -126,5 +126,4 @@ var i = (e) => {
126
126
  score: 0,
127
127
  reason: `judge failed: ${e.message}`
128
128
  }))));
129
- //#endregion
130
129
  export { s as DEFAULT_JUDGE_THRESHOLD, i as defineEval, o as evaluateAssertions, a as isEvalDefinition, f as llmJudge, l as runEval, c as scoreCase };
package/dist/events.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { TranscriptionStreamError as e, TranscriptionStreamEvent as t } from "./transcriptionEvent.js";
2
2
  import { RealtimeClientEvent as n, RealtimeServerEvent as r } from "./realtimeEvent.js";
3
3
  import { Schema as i } from "effect";
4
- //#region src/agentEvent.ts
4
+ // src/agentEvent.ts
5
5
  var a = i.Literals([
6
6
  "provider",
7
7
  "tool",
@@ -77,5 +77,4 @@ var a = i.Literals([
77
77
  seq: i.Number,
78
78
  event: s
79
79
  });
80
- //#endregion
81
80
  export { a as AgentErrorCode, s as AgentEvent, n as RealtimeClientEvent, r as RealtimeServerEvent, c as SeqEvent, e as TranscriptionStreamError, t as TranscriptionStreamEvent };
@@ -1,4 +1,4 @@
1
- //#region src/executableModalities.ts
1
+ // src/executableModalities.ts
2
2
  var e = {
3
3
  language: "generateText / generateObject / streamText",
4
4
  embedding: "embed / embedMany",
@@ -9,5 +9,4 @@ var e = {
9
9
  transcription: "transcribe",
10
10
  realtime: "defineRealtimeSession / resolveRealtimeModel"
11
11
  }, t = () => new Set(Object.keys(e)), n = (e) => t().has(e.modality);
12
- //#endregion
13
12
  export { e as MODALITY_PRIMITIVE, n as canExecute, t as executableModalities };
package/dist/gateway.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { capabilitiesOf as e, contextWindowOf as t, dataPolicyOf as n, knowledgeCutoffOf as r, maxOutputTokensOf as i, modalitiesOf as a, modalityOf as o, releasedAtOf as s } from "./gatewayCatalog.js";
2
2
  import { createGateway as c, gateway as l } from "@ai-sdk/gateway";
3
- //#region src/gateway.ts
3
+ // src/gateway.ts
4
4
  var u = (e) => {
5
5
  if (e === void 0) return;
6
6
  let t = Number(e);
@@ -54,5 +54,4 @@ var u = (e) => {
54
54
  raw: c
55
55
  };
56
56
  };
57
- //#endregion
58
57
  export { h as fromRaw, f as getAvailableModels, m as readGatewayCatalog, d as toModelInfo };
@@ -1,4 +1,4 @@
1
- //#region src/gatewayCatalog.ts
1
+ // src/gatewayCatalog.ts
2
2
  var e = (e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : [], t = (e) => typeof e == "number" && Number.isFinite(e) ? e : void 0, n = (e) => e === "all" || e === "some" ? e : "none", r = (e) => {
3
3
  let n = t(e);
4
4
  if (n === void 0) return;
@@ -43,5 +43,4 @@ var e = (e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : [], t
43
43
  "evaluation"
44
44
  ].includes(t) ? t : "unknown";
45
45
  };
46
- //#endregion
47
46
  export { i as capabilitiesOf, s as contextWindowOf, o as dataPolicyOf, u as knowledgeCutoffOf, c as maxOutputTokensOf, a as modalitiesOf, d as modalityOf, l as releasedAtOf };
@@ -1,5 +1,5 @@
1
1
  import { createGateway as e } from "@ai-sdk/gateway";
2
- //#region src/gatewayMedia.ts
2
+ // src/gatewayMedia.ts
3
3
  var t = (e, t) => {
4
4
  let n = Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0));
5
5
  return {
@@ -84,5 +84,4 @@ var t = (e, t) => {
84
84
  ...e,
85
85
  fetch: async (n, r) => l(await (e.fetch ?? globalThis.fetch)(n, r), t)
86
86
  });
87
- //#endregion
88
87
  export { a as DEFAULT_MEDIA_MAX_RESPONSE_BYTES, u as boundedGatewaySettings, r as gatewayImageModel, i as gatewayVideoModel, o as mediaResponseBudget, s as mediaResponseTooLargeMessage };
@@ -6,7 +6,7 @@ import { transcribe as c } from "./transcribe.js";
6
6
  import { mediaTaskProvider as l } from "./mediaTaskProvider.js";
7
7
  import { AI_INFERENCES_TABLE as u, decideInferenceFailure as d, toQueuedInference as f } from "./inferenceQueue.js";
8
8
  import { and as p, eq as m, gt as h, gte as g, lt as _, lte as v, or as y, registerRetention as b, retentionTtlMsFromEnv as x } from "@voltro/database";
9
- //#region src/inferenceDispatch.ts
9
+ // src/inferenceDispatch.ts
10
10
  var S = 4, C = 250, w = 5e3, T = 36e5, E = {
11
11
  examined: !1,
12
12
  claimed: 0,
@@ -489,5 +489,4 @@ var S = 4, C = 250, w = 5e3, T = 36e5, E = {
489
489
  } } : {}
490
490
  }));
491
491
  };
492
- //#endregion
493
492
  export { S as DEFAULT_INFERENCE_CONCURRENCY, C as DEFAULT_INFERENCE_POLL_MS, j as DEFAULT_INFERENCE_RETENTION_HOURS, w as DEFAULT_MEDIA_TASK_POLL_MS, T as DEFAULT_MEDIA_TASK_TIMEOUT_MS, N as dispatchInferences };
@@ -1,6 +1,6 @@
1
1
  import { id as e, integer as t, json as n, table as r, text as i, timestamp as a } from "@voltro/database";
2
2
  import { createHash as o } from "node:crypto";
3
- //#region src/inferenceQueue.ts
3
+ // src/inferenceQueue.ts
4
4
  var s = "_voltro_ai_inferences", c = r(s, {
5
5
  id: e({ prefix: "aiinf" }),
6
6
  tenantId: i().nullable(),
@@ -92,5 +92,4 @@ var s = "_voltro_ai_inferences", c = r(s, {
92
92
  delayMs: e.retryAfterMs !== void 0 && e.retryAfterMs > 0 ? e.retryAfterMs : Math.min(e.baseDelayMs * 2 ** (t - 1), e.maxDelayMs)
93
93
  };
94
94
  }, g = (e) => `voltro.ai.infer:${e}`, _ = (e, t) => `aiinf_${o("sha256").update(`${e}\u0000${t}`).digest("hex").slice(0, 40)}`;
95
- //#endregion
96
95
  export { s as AI_INFERENCES_TABLE, u as DEFAULT_INFERENCE_ATTEMPTS, l as DEFAULT_INFERENCE_LEASE_MS, c as aiInferencesTable, h as decideInferenceFailure, g as inferenceSignalName, _ as offloadedInferenceId, m as toQueuedInference };
@@ -3,7 +3,7 @@ import { Ajv as t } from "ajv";
3
3
  import { Ajv2019 as n } from "ajv/dist/2019.js";
4
4
  import { Ajv2020 as r } from "ajv/dist/2020.js";
5
5
  import i from "ajv-formats";
6
- //#region src/jsonOutputValidation.ts
6
+ // src/jsonOutputValidation.ts
7
7
  var a = (a) => {
8
8
  let o = structuredClone(a), s = {
9
9
  strict: !0,
@@ -23,5 +23,4 @@ var a = (a) => {
23
23
  error: /* @__PURE__ */ Error("model output does not satisfy the declared JSON Schema")
24
24
  } });
25
25
  };
26
- //#endregion
27
26
  export { a as validatedOutputSchema };
package/dist/mcpClient.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Effect as e, Schema as t } from "effect";
2
- //#region src/mcpClient.ts
2
+ // src/mcpClient.ts
3
3
  var n = "2025-06-18", r = {
4
4
  name: "voltro-ai",
5
5
  version: "0.0.0"
@@ -328,5 +328,4 @@ var n = "2025-06-18", r = {
328
328
  }), n), o = x(e, a.maxResultBytes);
329
329
  return e.isError === !0 ? `Error: ${o}` : o;
330
330
  });
331
- //#endregion
332
331
  export { a as MCP_BOUNDS_DEFAULTS, r as MCP_CLIENT_INFO, n as MCP_CLIENT_PROTOCOL_VERSION, i as McpError, x as flattenMcpContent, g as httpMcpTransport, d as isUsableMcpToolName, S as mcpCallTool, y as mcpInitialize, b as mcpListTools, h as parseHttpMcpBody, s as resolveMcpBounds, l as sanitizeExternalText, f as sanitizeInputSchema, _ as stdioMcpTransport };
package/dist/mcpTools.js CHANGED
@@ -2,7 +2,7 @@ import { defineTool as e } from "./tools.js";
2
2
  import { passesPolicy as t } from "./appTools.js";
3
3
  import { McpError as n, mcpCallTool as r, mcpInitialize as i, mcpListTools as a, resolveMcpBounds as o } from "./mcpClient.js";
4
4
  import { Effect as s, Schema as c } from "effect";
5
- //#region src/mcpTools.ts
5
+ // src/mcpTools.ts
6
6
  var l = (e) => RegExp("^" + e.split("*").map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*") + "$"), u = (e, t) => t instanceof RegExp ? t.test(e) : t.some((t) => l(t).test(e)), d = (e, t) => `${e}.${t}`, f = (e, t, n) => {
7
7
  let r = d(t, e.name);
8
8
  return !(n.readOnly !== void 0 && u(r, n.readOnly) || n.trustToolHints === !0 && e.annotations?.readOnlyHint === !0);
@@ -76,5 +76,4 @@ var l = (e) => RegExp("^" + e.split("*").map((e) => e.replace(/[.*+?^${}()|[\]\\
76
76
  close: () => e.transport.close()
77
77
  };
78
78
  }), v = (e, t) => _(e, t).pipe(s.map((e) => e.tools)), y = (e, t) => _(e, t);
79
- //#endregion
80
79
  export { m as describeExternalTool, f as isExternalWrite, g as makeMcpTool, p as mcpToolDecision, d as mcpToolTag, v as mcpTools, _ as mcpToolset, y as refreshMcpToolset };
package/dist/media.js CHANGED
@@ -6,7 +6,7 @@ import { decodeInlineVideo as d, inlineVideoByteLimit as f } from "./mediaBytes.
6
6
  import { mediaCall as p } from "./mediaCall.js";
7
7
  import { generateImage as m, generateSpeech as h } from "ai";
8
8
  import { Effect as g } from "effect";
9
- //#region src/media.ts
9
+ // src/media.ts
10
10
  var _ = (e) => e === void 0 ? {} : { providerOptions: e }, v = (e) => s(e), y = (e) => {
11
11
  let t = async (t) => {
12
12
  let n = await e.doGenerate(t);
@@ -178,5 +178,4 @@ var _ = (e) => e === void 0 ? {} : { providerOptions: e }, v = (e) => s(e), y =
178
178
  catch: v
179
179
  }), t.abortSignal));
180
180
  };
181
- //#endregion
182
181
  export { x as generateImage, C as generateSpeech, T as generateVideo };
@@ -1,4 +1,4 @@
1
- //#region src/mediaBytes.ts
1
+ // src/mediaBytes.ts
2
2
  var e = 67108864, t = (t = e) => {
3
3
  if (!Number.isSafeInteger(t) || t < 0) throw RangeError("generateVideo: maxInlineBytes must be a non-negative safe integer.");
4
4
  return t;
@@ -15,5 +15,4 @@ var e = 67108864, t = (t = e) => {
15
15
  if (r > 0 && (i.length === 0 || a & (r === 2 ? 15 : 3))) throw Error("generateVideo: provider returned invalid canonical base64.");
16
16
  return Buffer.from(e, "base64");
17
17
  };
18
- //#endregion
19
18
  export { e as DEFAULT_INLINE_VIDEO_BYTES, n as decodeInlineVideo, t as inlineVideoByteLimit };
package/dist/mediaCall.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Effect as e } from "effect";
2
- //#region src/mediaCall.ts
2
+ // src/mediaCall.ts
3
3
  var t = (t, n) => e.suspend(() => n?.aborted ? e.interrupt : e.acquireUseRelease(e.sync(() => new AbortController()), (r) => {
4
4
  let i = e.suspend(() => t(r.signal));
5
5
  if (n === void 0) return i;
@@ -9,5 +9,4 @@ var t = (t, n) => e.suspend(() => n?.aborted ? e.interrupt : e.acquireUseRelease
9
9
  });
10
10
  return e.raceFirst(i, a);
11
11
  }, (t) => e.sync(() => t.abort())));
12
- //#endregion
13
12
  export { t as mediaCall };
@@ -1,4 +1,4 @@
1
- //#region src/mediaTaskProvider.ts
1
+ // src/mediaTaskProvider.ts
2
2
  var e = Symbol.for("@voltro/ai/mediaTaskProviders"), t = globalThis, n = () => t[e] ?? (t[e] = /* @__PURE__ */ new Map()), r = [
3
3
  "mock",
4
4
  "openai",
@@ -12,5 +12,4 @@ var e = Symbol.for("@voltro/ai/mediaTaskProviders"), t = globalThis, n = () => t
12
12
  }, a = (e) => n().get(e), o = () => [...n().keys()].sort(), s = () => {
13
13
  n().clear();
14
14
  };
15
- //#endregion
16
15
  export { r as BUILTIN_MEDIA_PROVIDERS, s as clearMediaTaskProviders, a as mediaTaskProvider, i as registerMediaTaskProvider, o as registeredMediaTaskProviders };
@@ -1,5 +1,5 @@
1
1
  import { defaultSettingsMiddleware as e, extractReasoningMiddleware as t, simulateStreamingMiddleware as n, wrapLanguageModel as r } from "ai";
2
- //#region src/middleware.ts
2
+ // src/middleware.ts
3
3
  var i = [], a = (...e) => {
4
4
  let t = i;
5
5
  return i = e, t;
@@ -28,5 +28,4 @@ var i = [], a = (...e) => {
28
28
  }), e())
29
29
  };
30
30
  };
31
- //#endregion
32
31
  export { c as applyMiddleware, s as clearAiMiddleware, e as defaultSettingsMiddleware, t as extractReasoningMiddleware, o as getAiMiddleware, l as loggingMiddleware, a as setAiMiddleware, n as simulateStreamingMiddleware };
package/dist/observe.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { estimateCostUsd as e } from "./cost.js";
2
2
  import { Effect as t, Metric as n, Stream as r } from "effect";
3
- //#region src/observe.ts
3
+ // src/observe.ts
4
4
  var i = Array.from({ length: 16 }, (e, t) => .001 * 2 ** t), a = n.counter("voltro_ai_calls_total", { description: "Total AI provider calls (generate + stream)." }), o = n.counter("voltro_ai_call_errors_total", { description: "AI provider calls that errored." }), s = n.histogram("voltro_ai_call_duration_seconds", {
5
5
  boundaries: i,
6
6
  description: "AI provider call duration in seconds."
@@ -48,5 +48,4 @@ var i = Array.from({ length: 16 }, (e, t) => .001 * 2 ** t), a = n.counter("volt
48
48
  "ai.operation": e.operation
49
49
  } }));
50
50
  };
51
- //#endregion
52
51
  export { d as aiCallAttributes, h as observeStream, m as withAiCallSpan };
package/dist/prompts.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Effect as e, Schema as t } from "effect";
2
2
  import { and as n, eq as r, generateId as i, id as a, integer as o, queryFor as s, registerRetention as c, retentionTtlMsFromEnv as l, table as u, text as d, timestamp as f } from "@voltro/database";
3
3
  import { createHash as p } from "node:crypto";
4
- //#region src/prompts.ts
4
+ // src/prompts.ts
5
5
  var m = (e) => `sha256:${p("sha256").update(e).digest("hex").slice(0, 16)}`, h = class extends t.TaggedError()("PromptRenderError", {
6
6
  promptId: t.String,
7
7
  missing: t.Array(t.String),
@@ -99,5 +99,4 @@ var m = (e) => `sha256:${p("sha256").update(e).digest("hex").slice(0, 16)}`, h =
99
99
  let e = (await t.query(s(S).where(r("digest", n)).descriptor))[0];
100
100
  return e === void 0 ? null : T(e);
101
101
  }), O = (t, n) => e.promise(async () => [...await t.query(s(S).where(r("promptId", n)).orderBy("revision", "desc").descriptor)].sort((e, t) => (Number(t.revision) || 0) - (Number(e.revision) || 0)).map(T));
102
- //#endregion
103
102
  export { C as DEFAULT_PROMPT_RETENTION_HOURS, x as PROMPTS_TABLE, h as PromptRenderError, y as definePrompt, b as isRenderedPrompt, m as promptDigest, D as promptVersionByDigest, v as promptVersionDigest, O as promptVersionsFor, S as promptsTable, E as recordPromptVersion };
package/dist/provider.js CHANGED
@@ -4,7 +4,7 @@ import { boundedGatewaySettings as r, gatewayImageModel as i, gatewayVideoModel
4
4
  import { anthropic as s, createAnthropic as c } from "@ai-sdk/anthropic";
5
5
  import { createOpenAI as l, openai as u } from "@ai-sdk/openai";
6
6
  import { createGateway as d, gateway as f } from "@ai-sdk/gateway";
7
- //#region src/provider.ts
7
+ // src/provider.ts
8
8
  var p = {
9
9
  inputTokens: {
10
10
  total: 0,
@@ -315,5 +315,4 @@ var p = {
315
315
  default: throw Error(`Unknown AI_PROVIDER '${i}'. Expected one of: mock, anthropic, openai, gateway.`);
316
316
  }
317
317
  };
318
- //#endregion
319
318
  export { h as MockScript, z as getProviderOverride, V as providerChoice, H as providerFromEnv, B as providerKeyEnvVar, N as resolveImageModel, M as resolveModel, P as resolveSpeechModel, F as resolveTranscriptionModel, I as resolveVideoModel, R as setProviderOverride };
@@ -1,5 +1,5 @@
1
1
  import { Schema as e } from "effect";
2
- //#region src/realtimeEvent.ts
2
+ // src/realtimeEvent.ts
3
3
  var t = e.String.pipe(e.check(e.isPattern(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/))), n = e.Number.pipe(e.check(e.isFinite()), e.check(e.isGreaterThanOrEqualTo(0))), r = e.Union([
4
4
  e.Struct({
5
5
  type: e.Literal("input-audio-append"),
@@ -93,5 +93,4 @@ var t = e.String.pipe(e.check(e.isPattern(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/
93
93
  transcript: e.optional(e.String)
94
94
  })
95
95
  ]);
96
- //#endregion
97
96
  export { r as RealtimeClientEvent, o as RealtimeServerEvent };
@@ -4,7 +4,7 @@ import { createGateway as r } from "@ai-sdk/gateway";
4
4
  import { Effect as i, Queue as a, Result as o, Schema as s } from "effect";
5
5
  import { defineWebSocket as c } from "@voltro/protocol";
6
6
  import { WebSocket as l } from "ws";
7
- //#region src/realtimeSession.ts
7
+ // src/realtimeSession.ts
8
8
  var u = (e) => {
9
9
  if (e.name !== "gateway" && e.name !== "openai") throw TypeError(`Provider '${e.name}' does not support realtime sessions. Use 'gateway' or 'openai'.`);
10
10
  let t = {
@@ -150,5 +150,4 @@ var u = (e) => {
150
150
  let i = JSON.stringify(t);
151
151
  return i === void 0 || Buffer.byteLength(i) > n.maxMessageBytes || e.bufferedAmount + Buffer.byteLength(i) > n.maxPendingBytes ? Promise.reject(new p(4409, "Realtime buffer limit exceeded")) : new Promise((t, n) => e.send(i, (e) => e ? n(new p(4502, "Realtime provider failed")) : t()));
152
152
  };
153
- //#endregion
154
153
  export { h as defineRealtimeSession, u as resolveRealtimeModel };
package/dist/rerank.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { aiGenerationError as e } from "./api.js";
2
2
  import { rerank as t } from "ai";
3
3
  import { Effect as n } from "effect";
4
- //#region src/rerank.ts
4
+ // src/rerank.ts
5
5
  var r = (t) => n.tryPromise({
6
6
  try: async () => {
7
7
  let e = t.getText ?? ((e) => String(e)), n = t.provider ?? "mock", r = [...typeof n == "string" ? n === "mock" ? i(t.query, t.documents, e) : await o(n, t.query, t.documents, e, t.model) : await s(n, t.query, t.documents, e, t.model)].sort((e, t) => t.score - e.score);
@@ -57,5 +57,4 @@ var r = (t) => n.tryPromise({
57
57
  score: e.score
58
58
  }));
59
59
  };
60
- //#endregion
61
60
  export { r as rerank };
@@ -2,7 +2,7 @@ import { streamText as e } from "./streamText.js";
2
2
  import { awaitStreamChange as t, hasStreamReaders as n, watchStream as r, withStreamWakeups as i } from "./streamWakeups.js";
3
3
  import { Cause as a, Clock as o, Duration as s, Effect as c, Exit as l, Option as u, Stream as d } from "effect";
4
4
  import { and as f, boolean as p, eq as m, generateId as h, gt as g, id as _, inSet as v, integer as y, json as b, lt as x, registerRetention as S, retentionTtlMsFromEnv as C, table as w, text as T, timestamp as E } from "@voltro/database";
5
- //#region src/resumableStream.ts
5
+ // src/resumableStream.ts
6
6
  var D = (e) => e._tag === "done" || e._tag === "error", O = (e, n, i = {}) => {
7
7
  let a = i.pollMs ?? 50, l = Math.max(a, i.maxPollMs ?? 1e3);
8
8
  if (!Number.isFinite(a) || a <= 0 || !Number.isFinite(l)) throw RangeError("Stream poll intervals must be finite positive milliseconds");
@@ -317,5 +317,4 @@ var D = (e) => e._tag === "done" || e._tag === "error", O = (e, n, i = {}) => {
317
317
  isDone: (t) => c.promise(() => e.exists(s(t)))
318
318
  });
319
319
  };
320
- //#endregion
321
320
  export { L as DEFAULT_STREAM_LOG_RETENTION_HOURS, N as STREAM_EVENTS_TABLE, P as STREAM_STATE_TABLE, O as consumeResumableStream, V as dataStoreResumableStreamStore, H as gcResumableStreams, M as memoryResumableStreamStore, U as redisResumableStreamStore, A as resumableStream, j as resumableStreamText, k as startResumableProducer, F as streamEventsTable, I as streamStateTable };
@@ -1,6 +1,6 @@
1
1
  import { rerank as e } from "./rerank.js";
2
2
  import { Effect as t } from "effect";
3
- //#region src/retrieveReranked.ts
3
+ // src/retrieveReranked.ts
4
4
  var n = (n) => t.gen(function* () {
5
5
  let t = n.candidates ?? 50, r = n.topN ?? 8, i = yield* n.search(t);
6
6
  return i.length === 0 ? i : (yield* e({
@@ -12,5 +12,4 @@ var n = (n) => t.gen(function* () {
12
12
  ...n.model === void 0 ? {} : { model: n.model }
13
13
  })).map((e) => e.document);
14
14
  });
15
- //#endregion
16
15
  export { n as retrieveReranked };
@@ -3,7 +3,7 @@ import { recordAiUsageBestEffort as t } from "./cost.js";
3
3
  import { streamText as n } from "./streamText.js";
4
4
  import { AGENT_MESSAGES_TABLE as r, AGENT_THREADS_TABLE as i } from "./agentConstants.js";
5
5
  import { Effect as a, Stream as o } from "effect";
6
- //#region src/runAndPersist.ts
6
+ // src/runAndPersist.ts
7
7
  var s = (e) => [...e].sort((e, t) => e.order - t.order || e.stepOrder - t.stepOrder).filter((e) => !e.streaming && e.content.length > 0 && (e.role === "user" || e.role === "assistant")).map((e) => e.role === "user" ? {
8
8
  role: "user",
9
9
  content: e.content
@@ -143,5 +143,4 @@ var s = (e) => [...e].sort((e, t) => e.order - t.order || e.stepOrder - t.stepOr
143
143
  }
144
144
  })), b ? yield* a.fail(Error(b)) : u(T);
145
145
  });
146
- //#endregion
147
146
  export { c as appendStreamingMessage, s as historyToModelMessages, l as patchStreamingMessage, d as runAssistant };
@@ -2,7 +2,7 @@ import { generateObject as e, generateText as t } from "./api.js";
2
2
  import { embed as n } from "./embed.js";
3
3
  import { Effect as r, Option as i } from "effect";
4
4
  import { rowDep as a, tableDep as o } from "@voltro/cache";
5
- //#region src/semanticCache.ts
5
+ // src/semanticCache.ts
6
6
  var s = {
7
7
  inputTokens: 0,
8
8
  outputTokens: 0,
@@ -62,5 +62,4 @@ var s = {
62
62
  reset: () => t.clear()
63
63
  };
64
64
  };
65
- //#endregion
66
65
  export { m as recordReads, p as semanticGenerateObject, f as semanticGenerateText };
@@ -1,4 +1,4 @@
1
- //#region src/speechProvider.ts
1
+ // src/speechProvider.ts
2
2
  var e = Symbol.for("@voltro/ai/speechProviders"), t = globalThis, n = () => t[e] ?? (t[e] = /* @__PURE__ */ new Map()), r = [
3
3
  "mock",
4
4
  "openai",
@@ -12,5 +12,4 @@ var e = Symbol.for("@voltro/ai/speechProviders"), t = globalThis, n = () => t[e]
12
12
  }, a = (e) => r.includes(e) && n().has(e), o = (e) => n().get(e), s = () => [...n().keys()].sort(), c = () => {
13
13
  n().clear();
14
14
  };
15
- //#endregion
16
15
  export { r as BUILTIN_SPEECH_PROVIDERS, c as clearSpeechProviders, i as registerSpeechProvider, s as registeredSpeechProviders, a as replacesBuiltinSpeechProvider, o as speechProvider };
@@ -1,4 +1,4 @@
1
- //#region src/streamRegistry.ts
1
+ // src/streamRegistry.ts
2
2
  var e = /* @__PURE__ */ new Map(), t = (t) => {
3
3
  let n = e.get(t);
4
4
  if (n) return n;
@@ -10,5 +10,4 @@ var e = /* @__PURE__ */ new Map(), t = (t) => {
10
10
  }, r = (t) => e.has(t), i = (t) => {
11
11
  e.delete(t);
12
12
  }, a = () => e.size;
13
- //#endregion
14
13
  export { a as activeStreamCount, n as cancelStream, r as isStreamActive, t as registerStream, i as unregisterStream };
@@ -4,7 +4,7 @@ import { aiCallAttributes as r, observeStream as i } from "./observe.js";
4
4
  import { registerStream as a, unregisterStream as o } from "./streamRegistry.js";
5
5
  import { smoothStream as s, stepCountIs as c, streamText as l } from "ai";
6
6
  import { Duration as u, Effect as d, Stream as f } from "effect";
7
- //#region src/streamText.ts
7
+ // src/streamText.ts
8
8
  var p = (e) => {
9
9
  let t = e?.name, n = String(e?.message ?? e ?? "");
10
10
  return t === "AbortError" || t === "TimeoutError" || /\babort(ed)?\b/i.test(n);
@@ -166,5 +166,4 @@ var p = (e) => {
166
166
  };
167
167
  return n(0);
168
168
  };
169
- //#endregion
170
169
  export { _ as streamText, x as streamTextWithFallback, b as streamTextWithRetry };
@@ -2,7 +2,7 @@ import { providerFromEnv as e, resolveTranscriptionModel as t } from "./provider
2
2
  import { TranscriptionStreamError as n, TranscriptionStreamEvent as r } from "./transcriptionEvent.js";
3
3
  import { experimental_streamTranscribe as i } from "ai";
4
4
  import { Effect as a, Schema as o, Stream as s } from "effect";
5
- //#region src/streamTranscribe.ts
5
+ // src/streamTranscribe.ts
6
6
  var c = (c) => s.unwrap(a.gen(function* () {
7
7
  let l = yield* a.acquireRelease(a.sync(() => new AbortController()), (e) => a.promise(async () => {
8
8
  e.abort(), c.audio.locked || await c.audio.cancel().catch(() => {});
@@ -70,5 +70,4 @@ var c = (c) => s.unwrap(a.gen(function* () {
70
70
  }));
71
71
  return s.concat(h, g);
72
72
  }));
73
- //#endregion
74
73
  export { n as TranscriptionStreamError, r as TranscriptionStreamEvent, c as streamTranscribe };
@@ -1,5 +1,5 @@
1
1
  import { Effect as e } from "effect";
2
- //#region src/streamWakeups.ts
2
+ // src/streamWakeups.ts
3
3
  var t = /* @__PURE__ */ new WeakMap(), n = (e, n) => (t.get(e)?.get(n)?.readers ?? 0) > 0, r = (n, r) => e.acquireRelease(e.sync(() => {
4
4
  let e = t.get(n);
5
5
  e === void 0 && (e = /* @__PURE__ */ new Map(), t.set(n, e));
@@ -40,5 +40,4 @@ var t = /* @__PURE__ */ new WeakMap(), n = (e, n) => (t.get(e)?.get(n)?.readers
40
40
  };
41
41
  return i;
42
42
  };
43
- //#endregion
44
43
  export { i as awaitStreamChange, n as hasStreamReaders, r as watchStream, a as withStreamWakeups };