@voltro/ai 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/agent.d.ts +0 -3
- package/dist/agent.js +1 -1
- package/dist/{agentDescriptor-DCd4F9zj.js → agentDescriptor-Dwj24V48.js} +10 -11
- package/dist/index.d.ts +0 -6
- package/dist/index.js +42 -43
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -39,6 +39,25 @@ _Changes staged for the next release accumulate here (rolled up from
|
|
|
39
39
|
|
|
40
40
|
---
|
|
41
41
|
|
|
42
|
+
## [0.1.1] — 2026-07-15
|
|
43
|
+
|
|
44
|
+
### Fixed
|
|
45
|
+
|
|
46
|
+
- **@voltro/ai** — `AgentDescriptor` / `AgentExecutor` no longer carry a `unique
|
|
47
|
+
symbol` type brand (only the portable string `_brand`). A d.ts bundler
|
|
48
|
+
duplicates a `unique symbol` per entry point, so a descriptor built with
|
|
49
|
+
`defineAgent` (from the browser-safe `@voltro/ai/agent` subpath) was not
|
|
50
|
+
assignable to `defineAgentExecutor` (from the main entry) when the package is
|
|
51
|
+
consumed from npm — the canonical agent pattern failed to typecheck for every
|
|
52
|
+
published-package consumer. Type-only; the runtime brand was never read.
|
|
53
|
+
- **@voltro/cli** — the `voltro` bin resolves the `tsx` loader relative to
|
|
54
|
+
`@voltro/cli` (via `import.meta.resolve`) instead of a bare `--import tsx`
|
|
55
|
+
resolved from the consuming app's CWD, so a standalone (non-monorepo) install
|
|
56
|
+
no longer fails with "Cannot find package 'tsx'" at `voltro dev` / `voltro
|
|
57
|
+
build`.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
42
61
|
## [0.1.0]
|
|
43
62
|
|
|
44
63
|
Initial pre-release baseline. This is the starting point the changelog tracks
|
package/dist/agent.d.ts
CHANGED
|
@@ -4,10 +4,7 @@ import { Schema } from 'effect';
|
|
|
4
4
|
|
|
5
5
|
declare const AGENT_DESCRIPTOR_BRAND: "@voltro/ai/AgentDescriptor";
|
|
6
6
|
|
|
7
|
-
declare const AGENT_DESCRIPTOR_SYMBOL: unique symbol;
|
|
8
|
-
|
|
9
7
|
export declare interface AgentDescriptor<S extends Schema.Schema.Any = DefaultAgentInputSchema> {
|
|
10
|
-
readonly [AGENT_DESCRIPTOR_SYMBOL]: true;
|
|
11
8
|
readonly _brand: typeof AGENT_DESCRIPTOR_BRAND;
|
|
12
9
|
/** Wire id → rpc tags `<name>.send` / `<name>.messages`. */
|
|
13
10
|
readonly name: string;
|
package/dist/agent.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, i as t, n, r, t as i } from "./agentDescriptor-
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./agentDescriptor-Dwj24V48.js";
|
|
2
2
|
export { i as agentInputSchema, n as agentMessageSchema, r as agentRouteDescriptors, t as defineAgent, e as isAgentDescriptor };
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { Schema as e } from "effect";
|
|
2
2
|
import { defineAction as t, defineQuery as n } from "@voltro/protocol";
|
|
3
3
|
//#region src/agentConstants.ts
|
|
4
|
-
var r = "agent_threads", i = "agent_messages", a = e.Struct({ prompt: e.String }), o = "@voltro/ai/AgentDescriptor", s =
|
|
5
|
-
[s]: !0,
|
|
4
|
+
var r = "agent_threads", i = "agent_messages", a = e.Struct({ prompt: e.String }), o = "@voltro/ai/AgentDescriptor", s = (e) => ({
|
|
6
5
|
_brand: o,
|
|
7
6
|
name: e.name,
|
|
8
7
|
...e.input === void 0 ? {} : { input: e.input }
|
|
9
|
-
}),
|
|
8
|
+
}), c = (e) => typeof e == "object" && !!e && e._brand === o, l = (e) => e.input ?? a, u = e.Struct({ type: e.String }, {
|
|
10
9
|
key: e.String,
|
|
11
10
|
value: e.Unknown
|
|
12
|
-
}),
|
|
11
|
+
}), d = e.Struct({
|
|
13
12
|
id: e.String,
|
|
14
13
|
threadId: e.String,
|
|
15
14
|
role: e.String,
|
|
@@ -17,9 +16,9 @@ var r = "agent_threads", i = "agent_messages", a = e.Struct({ prompt: e.String }
|
|
|
17
16
|
streaming: e.Boolean,
|
|
18
17
|
order: e.Number,
|
|
19
18
|
stepOrder: e.Number,
|
|
20
|
-
parts: e.Array(
|
|
21
|
-
}),
|
|
22
|
-
let n =
|
|
19
|
+
parts: e.Array(u)
|
|
20
|
+
}), f = (t) => {
|
|
21
|
+
let n = l(t), r = e.Struct({
|
|
23
22
|
threadId: e.String,
|
|
24
23
|
order: e.Number
|
|
25
24
|
});
|
|
@@ -28,18 +27,18 @@ var r = "agent_threads", i = "agent_messages", a = e.Struct({ prompt: e.String }
|
|
|
28
27
|
} catch {
|
|
29
28
|
return r;
|
|
30
29
|
}
|
|
31
|
-
},
|
|
30
|
+
}, p = (r) => ({
|
|
32
31
|
send: t({
|
|
33
32
|
name: `${r.name}.send`,
|
|
34
|
-
input:
|
|
33
|
+
input: f(r),
|
|
35
34
|
output: e.Struct({ text: e.String })
|
|
36
35
|
}),
|
|
37
36
|
messages: n({
|
|
38
37
|
name: `${r.name}.messages`,
|
|
39
38
|
input: e.Struct({ threadId: e.String }),
|
|
40
|
-
output: e.Array(
|
|
39
|
+
output: e.Array(d),
|
|
41
40
|
source: i
|
|
42
41
|
})
|
|
43
42
|
});
|
|
44
43
|
//#endregion
|
|
45
|
-
export {
|
|
44
|
+
export { c as a, s as i, d as n, i as o, p as r, r as s, l as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -27,8 +27,6 @@ export declare const activeStreamCount: () => number;
|
|
|
27
27
|
|
|
28
28
|
declare const AGENT_DESCRIPTOR_BRAND: "@voltro/ai/AgentDescriptor";
|
|
29
29
|
|
|
30
|
-
declare const AGENT_DESCRIPTOR_SYMBOL: unique symbol;
|
|
31
|
-
|
|
32
30
|
/** Per-turn message table — the `source` of the reactive `<name>.messages`
|
|
33
31
|
* query, and what `runAssistant` delta-patches as it streams. */
|
|
34
32
|
export declare const AGENT_MESSAGES_TABLE = "agent_messages";
|
|
@@ -45,7 +43,6 @@ export declare const agentActor: (subjectId: string | null) => {
|
|
|
45
43
|
};
|
|
46
44
|
|
|
47
45
|
export declare interface AgentDescriptor<S extends Schema.Schema.Any = DefaultAgentInputSchema> {
|
|
48
|
-
readonly [AGENT_DESCRIPTOR_SYMBOL]: true;
|
|
49
46
|
readonly _brand: typeof AGENT_DESCRIPTOR_BRAND;
|
|
50
47
|
/** Wire id → rpc tags `<name>.send` / `<name>.messages`. */
|
|
51
48
|
readonly name: string;
|
|
@@ -110,7 +107,6 @@ export declare const AgentEvent: Schema.Union<[Schema.Struct<{
|
|
|
110
107
|
export declare type AgentEvent = typeof AgentEvent.Type;
|
|
111
108
|
|
|
112
109
|
export declare interface AgentExecutor<S extends Schema.Schema.Any = DefaultAgentInputSchema> {
|
|
113
|
-
readonly [EXECUTOR_SYMBOL]: true;
|
|
114
110
|
readonly _brand: typeof EXECUTOR_BRAND;
|
|
115
111
|
readonly descriptor: AgentDescriptor<S>;
|
|
116
112
|
readonly config: AgentExecutorConfig<AgentInput<S>>;
|
|
@@ -766,8 +762,6 @@ export declare const estimateCostUsd: (usage: AiUsage, opts: {
|
|
|
766
762
|
|
|
767
763
|
declare const EXECUTOR_BRAND: "@voltro/ai/AgentExecutor";
|
|
768
764
|
|
|
769
|
-
declare const EXECUTOR_SYMBOL: unique symbol;
|
|
770
|
-
|
|
771
765
|
/** The `exposeAsTool` annotation shape (mirrors @voltro/protocol's, structural
|
|
772
766
|
* so @voltro/ai needs no protocol dep). `true` alone can't expose — a tool
|
|
773
767
|
* needs a description, so only the object form (with `description`) exposes. */
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as e, c as t, d as n, f as r, g as i, h as a, i as o, l as s, m as c, n as l, o as u, p as d, r as f, s as p, t as ee, u as te } from "./provider-BOC5wBxx.js";
|
|
2
2
|
import { AgentErrorCode as ne, AgentEvent as re, SeqEvent as ie } from "./events.js";
|
|
3
|
-
import { a as ae, i as oe, n as se, o as m, r as ce, s as h, t as le } from "./agentDescriptor-
|
|
3
|
+
import { a as ae, i as oe, n as se, o as m, r as ce, s as h, t as le } from "./agentDescriptor-Dwj24V48.js";
|
|
4
4
|
import { createGateway as ue, gateway as de } from "@ai-sdk/gateway";
|
|
5
5
|
import { Output as fe, cosineSimilarity as pe, embed as me, embedMany as he, generateImage as ge, generateObject as _e, generateSpeech as ve, generateText as ye, jsonSchema as g, rerank as be, stepCountIs as xe, streamText as Se, tool as Ce } from "ai";
|
|
6
6
|
import { Chunk as _, Context as we, Duration as Te, Effect as v, JSONSchema as Ee, Metric as y, MetricBoundaries as De, Option as b, Runtime as Oe, Schema as x, Stream as S } from "effect";
|
|
@@ -1002,19 +1002,18 @@ var He = (e, t) => e(t), Ue = Symbol.for("@voltro/ai/Tool"), We = (e) => ({
|
|
|
1002
1002
|
content: Z(p),
|
|
1003
1003
|
streaming: !1
|
|
1004
1004
|
})), l ? yield* v.fail(Error(l)) : Z(p);
|
|
1005
|
-
}), pn = "@voltro/ai/AgentExecutor", mn =
|
|
1006
|
-
[mn]: !0,
|
|
1005
|
+
}), pn = "@voltro/ai/AgentExecutor", mn = (e, t) => ({
|
|
1007
1006
|
_brand: pn,
|
|
1008
1007
|
descriptor: e,
|
|
1009
1008
|
config: t
|
|
1010
|
-
}),
|
|
1009
|
+
}), hn = (e) => typeof e == "object" && !!e && e._brand === pn, gn = (e, t) => {
|
|
1011
1010
|
let n = e.config.system;
|
|
1012
1011
|
if (n !== void 0) return typeof n == "function" ? n(t) : n;
|
|
1013
|
-
},
|
|
1012
|
+
}, _n = (e, t) => {
|
|
1014
1013
|
let n = e.config.model;
|
|
1015
1014
|
return typeof n == "function" ? n(t) : n;
|
|
1016
|
-
},
|
|
1017
|
-
let r = n.promptOf ? n.promptOf(n.input) : String(n.input?.prompt ?? ""), i =
|
|
1015
|
+
}, vn = (e, t, n) => v.gen(function* () {
|
|
1016
|
+
let r = n.promptOf ? n.promptOf(n.input) : String(n.input?.prompt ?? ""), i = gn(e, n.input), a = _n(e, n.input);
|
|
1018
1017
|
yield* sn(t, {
|
|
1019
1018
|
threadId: n.threadId,
|
|
1020
1019
|
role: "user",
|
|
@@ -1037,18 +1036,18 @@ var He = (e, t) => e(t), Ue = Symbol.for("@voltro/ai/Tool"), We = (e) => ({
|
|
|
1037
1036
|
order: n.order + 1,
|
|
1038
1037
|
...n.throttleMs === void 0 ? {} : { throttleMs: n.throttleMs }
|
|
1039
1038
|
});
|
|
1040
|
-
}),
|
|
1039
|
+
}), yn = (e, t) => X(e, t), bn = (e, t) => ({
|
|
1041
1040
|
specificationVersion: "v4",
|
|
1042
1041
|
provider: "mock",
|
|
1043
1042
|
modelId: e,
|
|
1044
1043
|
maxEmbeddingsPerCall: 2048,
|
|
1045
1044
|
supportsParallelCalls: !0,
|
|
1046
1045
|
doEmbed: async ({ values: e }) => ({
|
|
1047
|
-
embeddings: e.map((e) =>
|
|
1046
|
+
embeddings: e.map((e) => xn(e, t)),
|
|
1048
1047
|
usage: { tokens: e.reduce((e, t) => e + t.length, 0) },
|
|
1049
1048
|
warnings: []
|
|
1050
1049
|
})
|
|
1051
|
-
}),
|
|
1050
|
+
}), xn = (e, t) => {
|
|
1052
1051
|
let n = Array(t);
|
|
1053
1052
|
for (let r = 0; r < t; r++) {
|
|
1054
1053
|
let t = 2166136261 ^ r * 16777619;
|
|
@@ -1056,14 +1055,14 @@ var He = (e, t) => e(t), Ue = Symbol.for("@voltro/ai/Tool"), We = (e) => ({
|
|
|
1056
1055
|
n[r] = (t >>> 0) / 4294967295 * 2 - 1;
|
|
1057
1056
|
}
|
|
1058
1057
|
return n;
|
|
1059
|
-
},
|
|
1058
|
+
}, Sn = async (e) => {
|
|
1060
1059
|
switch (e.name) {
|
|
1061
|
-
case "mock": return
|
|
1062
|
-
case "openai": return (await
|
|
1063
|
-
case "voyage": return (await
|
|
1064
|
-
case "cohere": return (await
|
|
1060
|
+
case "mock": return bn(e.model, e.mockDim ?? 8);
|
|
1061
|
+
case "openai": return (await Cn("@ai-sdk/openai", "openai")).openai.textEmbeddingModel(e.model);
|
|
1062
|
+
case "voyage": return (await Cn("voyage-ai-provider", "voyage")).voyage.textEmbeddingModel(e.model);
|
|
1063
|
+
case "cohere": return (await Cn("@ai-sdk/cohere", "cohere")).cohere.textEmbeddingModel(e.model);
|
|
1065
1064
|
}
|
|
1066
|
-
},
|
|
1065
|
+
}, Cn = async (e, t) => {
|
|
1067
1066
|
try {
|
|
1068
1067
|
return await import(
|
|
1069
1068
|
/* @vite-ignore */
|
|
@@ -1072,51 +1071,51 @@ var He = (e, t) => e(t), Ue = Symbol.for("@voltro/ai/Tool"), We = (e) => ({
|
|
|
1072
1071
|
} catch {
|
|
1073
1072
|
throw Error(`embedding provider '${t}' needs the '${e}' package — install it (pnpm add ${e}) or use AI_EMBED_PROVIDER=mock for tests/demos.`);
|
|
1074
1073
|
}
|
|
1075
|
-
},
|
|
1074
|
+
}, wn = (e = process.env) => {
|
|
1076
1075
|
let t = (e.AI_EMBED_PROVIDER ?? "mock").toLowerCase(), n = t === "openai" ? "text-embedding-3-small" : t === "voyage" ? "voyage-3" : t === "cohere" ? "embed-english-v3.0" : "mock", r = e.AI_EMBED_MODEL ?? n, i = e.AI_EMBED_MOCK_DIM === void 0 ? void 0 : Number(e.AI_EMBED_MOCK_DIM);
|
|
1077
1076
|
return {
|
|
1078
1077
|
name: t,
|
|
1079
1078
|
model: r,
|
|
1080
1079
|
...i !== void 0 && Number.isFinite(i) ? { mockDim: i } : {}
|
|
1081
1080
|
};
|
|
1082
|
-
},
|
|
1081
|
+
}, Tn = (e, t) => v.tryPromise({
|
|
1083
1082
|
try: async () => (await me({
|
|
1084
|
-
model: await
|
|
1083
|
+
model: await Sn(t ?? wn()),
|
|
1085
1084
|
value: e
|
|
1086
1085
|
})).embedding,
|
|
1087
1086
|
catch: (e) => new B({
|
|
1088
1087
|
reason: "generation",
|
|
1089
1088
|
message: String(e?.message ?? e)
|
|
1090
1089
|
})
|
|
1091
|
-
}),
|
|
1090
|
+
}), En = (e, t) => v.tryPromise({
|
|
1092
1091
|
try: async () => (await he({
|
|
1093
|
-
model: await
|
|
1092
|
+
model: await Sn(t ?? wn()),
|
|
1094
1093
|
values: [...e]
|
|
1095
1094
|
})).embeddings,
|
|
1096
1095
|
catch: (e) => new B({
|
|
1097
1096
|
reason: "generation",
|
|
1098
1097
|
message: String(e?.message ?? e)
|
|
1099
1098
|
})
|
|
1100
|
-
}),
|
|
1099
|
+
}), Dn = (e, t) => pe([...e], [...t]), On = (e) => v.tryPromise({
|
|
1101
1100
|
try: async () => {
|
|
1102
|
-
let t = e.getText ?? ((e) => String(e)), n = e.provider ?? "mock", r = [...n === "mock" ?
|
|
1101
|
+
let t = e.getText ?? ((e) => String(e)), n = e.provider ?? "mock", r = [...n === "mock" ? kn(e.query, e.documents, t) : await jn(n, e.query, e.documents, t, e.model)].sort((e, t) => t.score - e.score);
|
|
1103
1102
|
return e.topN === void 0 ? r : r.slice(0, e.topN);
|
|
1104
1103
|
},
|
|
1105
1104
|
catch: (e) => new B({
|
|
1106
1105
|
reason: "generation",
|
|
1107
1106
|
message: String(e?.message ?? e)
|
|
1108
1107
|
})
|
|
1109
|
-
}),
|
|
1110
|
-
let r =
|
|
1108
|
+
}), kn = (e, t, n) => {
|
|
1109
|
+
let r = An(e), i = new Set(r);
|
|
1111
1110
|
return t.map((e) => {
|
|
1112
|
-
let t = new Set(
|
|
1111
|
+
let t = new Set(An(n(e))), r = 0;
|
|
1113
1112
|
for (let e of i) t.has(e) && r++;
|
|
1114
1113
|
return {
|
|
1115
1114
|
document: e,
|
|
1116
1115
|
score: i.size === 0 ? 0 : r / i.size
|
|
1117
1116
|
};
|
|
1118
1117
|
});
|
|
1119
|
-
},
|
|
1118
|
+
}, An = (e) => e.toLowerCase().split(/[^a-z0-9]+/).filter((e) => e.length > 0), jn = async (e, t, n, r, i) => {
|
|
1120
1119
|
let a = e === "cohere" ? "@ai-sdk/cohere" : "voyage-ai-provider", o;
|
|
1121
1120
|
try {
|
|
1122
1121
|
o = await import(
|
|
@@ -1140,7 +1139,7 @@ var He = (e, t) => e(t), Ue = Symbol.for("@voltro/ai/Tool"), We = (e) => ({
|
|
|
1140
1139
|
if (e === void 0) return;
|
|
1141
1140
|
let t = Number(e);
|
|
1142
1141
|
return Number.isFinite(t) ? t * 1e6 : void 0;
|
|
1143
|
-
},
|
|
1142
|
+
}, Mn = (e) => {
|
|
1144
1143
|
let t = Q(e.pricing?.input), n = Q(e.pricing?.output), r = Q(e.pricing?.cachedInputTokens ?? void 0);
|
|
1145
1144
|
return {
|
|
1146
1145
|
id: e.id,
|
|
@@ -1153,16 +1152,16 @@ var He = (e, t) => e(t), Ue = Symbol.for("@voltro/ai/Tool"), We = (e) => ({
|
|
|
1153
1152
|
...r === void 0 ? {} : { cachedInputPer1M: r }
|
|
1154
1153
|
} } : {}
|
|
1155
1154
|
};
|
|
1156
|
-
},
|
|
1155
|
+
}, Nn = async (e = {}) => {
|
|
1157
1156
|
let t = (await (e.gatewayProvider ?? (e.apiKey !== void 0 || e.baseURL !== void 0 ? ue({
|
|
1158
1157
|
...e.apiKey === void 0 ? {} : { apiKey: e.apiKey },
|
|
1159
1158
|
...e.baseURL === void 0 ? {} : { baseURL: e.baseURL }
|
|
1160
|
-
}) : de)).getAvailableModels()).models.map(
|
|
1159
|
+
}) : de)).getAvailableModels()).models.map(Mn);
|
|
1161
1160
|
return e.modality === void 0 ? t : t.filter((t) => t.modality === e.modality);
|
|
1162
|
-
},
|
|
1161
|
+
}, Pn = class extends x.TaggedError()("CopilotRejected", {
|
|
1163
1162
|
reason: x.Literal("unknown-table", "unknown-column", "bad-op", "bad-aggregate", "empty"),
|
|
1164
1163
|
detail: x.String
|
|
1165
|
-
}) {},
|
|
1164
|
+
}) {}, Fn = 200, In = 50, Ln = /* @__PURE__ */ new Set([
|
|
1166
1165
|
"eq",
|
|
1167
1166
|
"neq",
|
|
1168
1167
|
"gt",
|
|
@@ -1171,7 +1170,7 @@ var He = (e, t) => e(t), Ue = Symbol.for("@voltro/ai/Tool"), We = (e) => ({
|
|
|
1171
1170
|
"lte",
|
|
1172
1171
|
"contains",
|
|
1173
1172
|
"in"
|
|
1174
|
-
]),
|
|
1173
|
+
]), Rn = (e) => {
|
|
1175
1174
|
switch (e.op) {
|
|
1176
1175
|
case "eq": return w(e.column, e.value);
|
|
1177
1176
|
case "neq": return Re(e.column, e.value);
|
|
@@ -1184,17 +1183,17 @@ var He = (e, t) => e(t), Ue = Symbol.for("@voltro/ai/Tool"), We = (e) => ({
|
|
|
1184
1183
|
}
|
|
1185
1184
|
}, $ = (e, t) => ({
|
|
1186
1185
|
ok: !1,
|
|
1187
|
-
rejection: new
|
|
1186
|
+
rejection: new Pn({
|
|
1188
1187
|
reason: e,
|
|
1189
1188
|
detail: t
|
|
1190
1189
|
})
|
|
1191
|
-
}),
|
|
1190
|
+
}), zn = (e, t) => {
|
|
1192
1191
|
let n = t.tables.find((t) => t.name === e.table);
|
|
1193
1192
|
if (n === void 0) return $("unknown-table", e.table);
|
|
1194
1193
|
let r = new Set(n.columns.map((e) => e.name));
|
|
1195
1194
|
for (let t of e.columns ?? []) if (!r.has(t)) return $("unknown-column", `${e.table}.${t}`);
|
|
1196
1195
|
for (let t of e.filters ?? []) {
|
|
1197
|
-
if (!
|
|
1196
|
+
if (!Ln.has(t.op)) return $("bad-op", String(t.op));
|
|
1198
1197
|
if (!r.has(t.column)) return $("unknown-column", `${e.table}.${t.column}`);
|
|
1199
1198
|
}
|
|
1200
1199
|
if (e.orderBy !== void 0 && !r.has(e.orderBy.column)) return $("unknown-column", `${e.table}.${e.orderBy.column}`);
|
|
@@ -1202,7 +1201,7 @@ var He = (e, t) => e(t), Ue = Symbol.for("@voltro/ai/Tool"), We = (e) => ({
|
|
|
1202
1201
|
let { fn: t, column: n } = e.aggregate;
|
|
1203
1202
|
if (t !== "count" && (n === void 0 || !r.has(n))) return $("bad-aggregate", `${t}(${n ?? "∅"})`);
|
|
1204
1203
|
}
|
|
1205
|
-
let i = e.filters ?? [], a = i.length === 0 ? void 0 : i.length === 1 ?
|
|
1204
|
+
let i = e.filters ?? [], a = i.length === 0 ? void 0 : i.length === 1 ? Rn(i[0]) : C(...i.map(Rn)), o = Math.min(Math.max(1, e.limit ?? In), 200), s = {
|
|
1206
1205
|
table: e.table,
|
|
1207
1206
|
predicate: a,
|
|
1208
1207
|
order: e.orderBy ? [{
|
|
@@ -1223,7 +1222,7 @@ var He = (e, t) => e(t), Ue = Symbol.for("@voltro/ai/Tool"), We = (e) => ({
|
|
|
1223
1222
|
descriptor: s,
|
|
1224
1223
|
table: e.table
|
|
1225
1224
|
};
|
|
1226
|
-
},
|
|
1225
|
+
}, Bn = x.Struct({
|
|
1227
1226
|
table: x.String,
|
|
1228
1227
|
columns: x.optional(x.Array(x.String)),
|
|
1229
1228
|
filters: x.optional(x.Array(x.Struct({
|
|
@@ -1240,7 +1239,7 @@ var He = (e, t) => e(t), Ue = Symbol.for("@voltro/ai/Tool"), We = (e) => ({
|
|
|
1240
1239
|
fn: x.Literal("count", "sum", "avg", "min", "max"),
|
|
1241
1240
|
column: x.optional(x.String)
|
|
1242
1241
|
}))
|
|
1243
|
-
}),
|
|
1242
|
+
}), Vn = (e) => [
|
|
1244
1243
|
"You are a data copilot. Translate the user question into a JSON query proposal.",
|
|
1245
1244
|
"",
|
|
1246
1245
|
"You may ONLY reference these tables and columns:",
|
|
@@ -1252,12 +1251,12 @@ var He = (e, t) => e(t), Ue = Symbol.for("@voltro/ai/Tool"), We = (e) => ({
|
|
|
1252
1251
|
"- NEVER invent a table or column. If the question cannot be answered from the listed schema, pick the closest table and leave filters empty.",
|
|
1253
1252
|
"- The query is READ-ONLY. You cannot insert, update, or delete.",
|
|
1254
1253
|
"- Keep the result small (limit ≤ 200)."
|
|
1255
|
-
].join("\n"),
|
|
1256
|
-
let r =
|
|
1257
|
-
return
|
|
1254
|
+
].join("\n"), Hn = async (e, t, n) => {
|
|
1255
|
+
let r = Vn(t);
|
|
1256
|
+
return zn(await n.propose({
|
|
1258
1257
|
system: r,
|
|
1259
1258
|
prompt: e
|
|
1260
1259
|
}), t);
|
|
1261
1260
|
};
|
|
1262
1261
|
//#endregion
|
|
1263
|
-
export { m as AGENT_MESSAGES_TABLE, h as AGENT_THREADS_TABLE, P as AI_BUDGET_TABLE, N as AI_USAGE_TABLE, ne as AgentErrorCode, re as AgentEvent, at as AiBudgetExceeded, B as AiError, xt as AiService,
|
|
1262
|
+
export { m as AGENT_MESSAGES_TABLE, h as AGENT_THREADS_TABLE, P as AI_BUDGET_TABLE, N as AI_USAGE_TABLE, ne as AgentErrorCode, re as AgentEvent, at as AiBudgetExceeded, B as AiError, xt as AiService, Fn as COPILOT_MAX_LIMIT, Bn as CopilotProposalSchema, Pn as CopilotRejected, Ze as MODEL_PRICING_DEFAULTS, ee as MockScript, J as STREAM_EVENTS_TABLE, Y as STREAM_STATE_TABLE, ie as SeqEvent, Rt as activeStreamCount, jt as agentActor, le as agentInputSchema, se as agentMessageSchema, an as agentMessagesTable, ce as agentRouteDescriptors, rn as agentThreadsTable, ot as aiBudgetTable, L as aiCallAttributes, it as aiSpendUsd, tt as aiUsageTable, Nt as appTools, sn as appendMessage, un as appendStreamingMessage, s as applyMiddleware, Vn as buildCopilotSystemPrompt, A as buildSdkTools, Ft as cancelStream, te as clearAiMiddleware, Gt as consumeResumableStream, Dn as cosineSimilarity, on as createThread, en as dataStoreResumableStreamStore, St as defaultAiService, n as defaultSettingsMiddleware, oe as defineAgent, mn as defineAgentExecutor, We as defineTool, Tn as embed, En as embedMany, wn as embeddingProviderFromEnv, M as estimateCostUsd, r as extractReasoningMiddleware, nt as gatewayCostUsd, tn as gcResumableStreams, wt as generateImage, yt as generateObject, bt as generateObjectWithTools, Tt as generateSpeech, _t as generateText, Ot as generateVideo, d as getAiMiddleware, Nn as getAvailableModels, X as getMessages, l as getProviderOverride, cn as getThread, xn as hashToVector, ln as historyToModelMessages, ae as isAgentDescriptor, hn as isAgentExecutor, It as isStreamActive, Ge as isTool, yn as loadAgentMessages, c as loggingMiddleware, Yt as memoryResumableStreamStore, $e as modelPricing, gt as observeStream, U as passesPolicy, dn as patchStreamingMessage, et as priceForModel, f as providerFromEnv, rt as recordAiUsage, nn as redisResumableStreamStore, Pt as registerStream, lt as requireAiBudget, On as rerank, _n as resolveAgentModel, Sn as resolveEmbeddingModel, o as resolveImageModel, e as resolveModel, u as resolveSpeechModel, gn as resolveSystem, Ke as resolveToolModuleHandlers, p as resolveVideoModel, qt as resumableStream, Jt as resumableStreamText, vn as runAgentTurn, fn as runAssistant, Hn as runDataCopilot, a as setAiMiddleware, Qe as setModelPricing, t as setProviderOverride, i as simulateStreamingMiddleware, Kt as startResumableProducer, Xt as streamEventsTable, Zt as streamStateTable, q as streamText, Wt as streamTextWithFallback, Ut as streamTextWithRetry, Mt as synthesizeToolSpecs, Mn as toModelInfo, Lt as unregisterStream, zn as validateCopilotProposal, z as withAiCallSpan };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/ai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Effect-native AI primitives — generateText / generateObject / streamText, tools, agents, media generation, cost tracking + budgets, and provider fallback.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voltro",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"@ai-sdk/gateway": "^4.0.16",
|
|
52
52
|
"@ai-sdk/openai": "^4.0.11",
|
|
53
53
|
"@ai-sdk/provider": "^4.0.3",
|
|
54
|
-
"@voltro/database": "0.1.
|
|
55
|
-
"@voltro/protocol": "0.1.
|
|
54
|
+
"@voltro/database": "0.1.2",
|
|
55
|
+
"@voltro/protocol": "0.1.2",
|
|
56
56
|
"ai": "^7.0.22"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|