@w6w/embed 0.2.22 → 0.2.24
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/{ModelRoutesManager-BUw_sm-M.js → ModelRoutesManager-Bv6qefnq.js} +2 -2
- package/dist/{ModelRoutesManager-BUw_sm-M.js.map → ModelRoutesManager-Bv6qefnq.js.map} +1 -1
- package/dist/forms.mjs +22 -22
- package/dist/index.mjs +1 -1
- package/dist/lib/workflow-blank.d.ts +12 -2
- package/dist/lib.mjs +41 -39
- package/dist/lists.mjs +446 -444
- package/dist/lists.mjs.map +1 -1
- package/dist/{models-bAayQPJ_.js → models-CK1KHd39.js} +146 -105
- package/dist/models-CK1KHd39.js.map +1 -0
- package/dist/repos/agents-studio-agents.d.ts +46 -2
- package/dist/repos/models.d.ts +85 -0
- package/dist/repos.mjs +466 -449
- package/dist/repos.mjs.map +1 -1
- package/dist/workflow-blank-BJFLdGyE.js +37 -0
- package/dist/workflow-blank-BJFLdGyE.js.map +1 -0
- package/package.json +3 -3
- package/dist/models-bAayQPJ_.js.map +0 -1
- package/dist/workflow-blank-DFpGObrn.js +0 -14
- package/dist/workflow-blank-DFpGObrn.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useQuery as
|
|
1
|
+
import { useQuery as i, useMutation as c, useQueryClient as l } from "@tanstack/react-query";
|
|
2
2
|
import { path as m } from "@w6w/sdk";
|
|
3
3
|
import { u as n } from "./client-context-CX61Bgw-.js";
|
|
4
|
-
const h = (e = {}) => ["model-catalog", e], M = ["model-providers"], K = (e) => ["model-routes", e], Q = (e) => ["model-budgets", e],
|
|
4
|
+
const h = (e = {}) => ["model-catalog", e], M = ["model-providers"], K = (e) => ["model-routes", e], Q = (e) => ["model-budgets", e], w = (e, t) => ["model-budget-usage", e, t], C = (e, t = {}) => ["model-usage", e, t];
|
|
5
5
|
async function b(e, t = {}) {
|
|
6
6
|
return (await e.request({
|
|
7
7
|
method: "GET",
|
|
@@ -10,48 +10,48 @@ async function b(e, t = {}) {
|
|
|
10
10
|
})).body;
|
|
11
11
|
}
|
|
12
12
|
function F(e) {
|
|
13
|
-
var
|
|
14
|
-
const t = (
|
|
13
|
+
var r;
|
|
14
|
+
const t = (r = e.operations) == null ? void 0 : r.complete, o = e.adapter === null, s = (t == null ? void 0 : t.supported) === !0 && !o, u = [...e.reasons ?? []];
|
|
15
15
|
return !s && u.length === 0 && u.push({
|
|
16
16
|
code: o || (t == null ? void 0 : t.supported) === !0 || e.installed ? "no_adapter" : "not_installed",
|
|
17
17
|
message: (t == null ? void 0 : t.reason) ?? "Not supported for this provider"
|
|
18
18
|
}), { supported: s, features: (t == null ? void 0 : t.features) ?? {}, reasons: u };
|
|
19
19
|
}
|
|
20
|
-
async function
|
|
20
|
+
async function P(e, t = {}) {
|
|
21
21
|
const o = t.maxPages ?? 50, s = [];
|
|
22
22
|
let u;
|
|
23
|
-
for (let
|
|
24
|
-
const
|
|
25
|
-
if (s.push(...
|
|
26
|
-
u =
|
|
23
|
+
for (let r = 0; r < o; r++) {
|
|
24
|
+
const y = await e(u);
|
|
25
|
+
if (s.push(...y.models), !y.nextCursor) return { models: s, truncated: !1 };
|
|
26
|
+
u = y.nextCursor;
|
|
27
27
|
}
|
|
28
28
|
return { models: s, truncated: !0 };
|
|
29
29
|
}
|
|
30
|
-
async function
|
|
30
|
+
async function E(e) {
|
|
31
31
|
const o = (await e.request({
|
|
32
32
|
method: "GET",
|
|
33
33
|
path: "/models/providers"
|
|
34
34
|
})).body;
|
|
35
35
|
return Array.isArray(o) ? o : (o == null ? void 0 : o.providers) ?? [];
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
var
|
|
37
|
+
function H(e, t, o) {
|
|
38
|
+
var r, y;
|
|
39
39
|
const s = /* @__PURE__ */ new Map();
|
|
40
40
|
for (const d of t) d.designation && s.set(d.appId, d);
|
|
41
41
|
const u = [];
|
|
42
42
|
for (const d of e) {
|
|
43
43
|
const p = s.get(d.appId);
|
|
44
44
|
if (!p) continue;
|
|
45
|
-
const
|
|
45
|
+
const a = (r = p.operations) == null ? void 0 : r[o], q = { id: d.id, appId: d.appId, displayName: d.displayName };
|
|
46
46
|
if (o === "complete") {
|
|
47
47
|
const f = F(p);
|
|
48
|
-
f.supported || (
|
|
49
|
-
} else
|
|
50
|
-
u.push(
|
|
48
|
+
f.supported || (q.disabledReason = (a == null ? void 0 : a.reason) ?? ((y = f.reasons[0]) == null ? void 0 : y.message) ?? "Not supported for this provider");
|
|
49
|
+
} else a != null && a.supported || (q.disabledReason = (a == null ? void 0 : a.reason) ?? "Not supported for this provider");
|
|
50
|
+
u.push(q);
|
|
51
51
|
}
|
|
52
52
|
return u;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function g(e) {
|
|
55
55
|
const t = (e.fallbacks ?? []).map((o) => {
|
|
56
56
|
const s = o;
|
|
57
57
|
return { model: s.model ?? s.modelId ?? "", connection: s.connection ?? s.connectionId ?? "" };
|
|
@@ -63,7 +63,7 @@ async function R(e, t) {
|
|
|
63
63
|
method: "GET",
|
|
64
64
|
path: "/model-routes",
|
|
65
65
|
query: { project: t }
|
|
66
|
-
})).body.routes.map(
|
|
66
|
+
})).body.routes.map(g);
|
|
67
67
|
}
|
|
68
68
|
async function T(e, t, o) {
|
|
69
69
|
const s = await e.request({
|
|
@@ -72,18 +72,26 @@ async function T(e, t, o) {
|
|
|
72
72
|
query: { project: t },
|
|
73
73
|
body: o
|
|
74
74
|
});
|
|
75
|
-
return
|
|
75
|
+
return g(s.body.route);
|
|
76
76
|
}
|
|
77
|
-
async function
|
|
77
|
+
async function v(e, t, o, s) {
|
|
78
78
|
const u = await e.request({
|
|
79
79
|
method: "PATCH",
|
|
80
80
|
path: m`/model-routes/${o}`,
|
|
81
81
|
query: { project: t },
|
|
82
82
|
body: s
|
|
83
83
|
});
|
|
84
|
-
return
|
|
84
|
+
return g(u.body.route);
|
|
85
85
|
}
|
|
86
|
-
async function
|
|
86
|
+
async function B(e, t, o, s) {
|
|
87
|
+
return (await e.request({
|
|
88
|
+
method: "POST",
|
|
89
|
+
path: m`/model-routes/${o}/complete`,
|
|
90
|
+
query: { project: t, response: "output" },
|
|
91
|
+
body: s
|
|
92
|
+
})).body;
|
|
93
|
+
}
|
|
94
|
+
async function S(e, t, o) {
|
|
87
95
|
await e.request({
|
|
88
96
|
method: "DELETE",
|
|
89
97
|
path: m`/model-routes/${o}`,
|
|
@@ -97,7 +105,7 @@ async function A(e, t) {
|
|
|
97
105
|
query: { project: t }
|
|
98
106
|
})).body.budgets;
|
|
99
107
|
}
|
|
100
|
-
async function
|
|
108
|
+
async function U(e, t, o) {
|
|
101
109
|
return (await e.request({
|
|
102
110
|
method: "POST",
|
|
103
111
|
path: "/model-budgets",
|
|
@@ -105,7 +113,7 @@ async function S(e, t, o) {
|
|
|
105
113
|
body: o
|
|
106
114
|
})).body;
|
|
107
115
|
}
|
|
108
|
-
async function
|
|
116
|
+
async function x(e, t, o, s) {
|
|
109
117
|
return (await e.request({
|
|
110
118
|
method: "PATCH",
|
|
111
119
|
path: m`/model-budgets/${o}`,
|
|
@@ -113,109 +121,138 @@ async function U(e, t, o, s) {
|
|
|
113
121
|
body: s
|
|
114
122
|
})).body;
|
|
115
123
|
}
|
|
116
|
-
async function
|
|
124
|
+
async function G(e, t, o) {
|
|
117
125
|
await e.request({
|
|
118
126
|
method: "DELETE",
|
|
119
127
|
path: m`/model-budgets/${o}`,
|
|
120
128
|
query: { project: t }
|
|
121
129
|
});
|
|
122
130
|
}
|
|
123
|
-
async function
|
|
131
|
+
async function D(e, t, o) {
|
|
124
132
|
return (await e.request({
|
|
125
133
|
method: "GET",
|
|
126
134
|
path: m`/model-budgets/${o}/usage`,
|
|
127
135
|
query: { project: t }
|
|
128
136
|
})).body;
|
|
129
137
|
}
|
|
130
|
-
async function
|
|
138
|
+
async function $(e, t, o = {}) {
|
|
131
139
|
return (await e.request({
|
|
132
140
|
method: "GET",
|
|
133
141
|
path: "/model-usage",
|
|
134
142
|
query: { project: t, ...o }
|
|
135
143
|
})).body;
|
|
136
144
|
}
|
|
137
|
-
function
|
|
145
|
+
async function N(e, t) {
|
|
146
|
+
return (await e.request({
|
|
147
|
+
method: "POST",
|
|
148
|
+
path: "/models/discover",
|
|
149
|
+
body: { connection: t }
|
|
150
|
+
})).body;
|
|
151
|
+
}
|
|
152
|
+
function L(e = {}) {
|
|
138
153
|
const t = n();
|
|
139
|
-
return
|
|
154
|
+
return i({
|
|
140
155
|
queryKey: h(e),
|
|
141
156
|
queryFn: () => b(t, e)
|
|
142
157
|
});
|
|
143
158
|
}
|
|
144
|
-
function
|
|
159
|
+
function z(e = {}) {
|
|
145
160
|
const t = n();
|
|
146
|
-
return
|
|
161
|
+
return i({
|
|
147
162
|
queryKey: ["model-catalog-all", e],
|
|
148
|
-
queryFn: () =>
|
|
163
|
+
queryFn: () => P((o) => b(t, { ...e, cursor: o }))
|
|
149
164
|
});
|
|
150
165
|
}
|
|
151
|
-
function
|
|
166
|
+
function J() {
|
|
152
167
|
const e = n();
|
|
153
|
-
return
|
|
168
|
+
return i({ queryKey: M, queryFn: () => E(e) });
|
|
154
169
|
}
|
|
155
|
-
function
|
|
170
|
+
function j(e) {
|
|
156
171
|
const t = n();
|
|
157
|
-
return
|
|
172
|
+
return i({
|
|
158
173
|
queryKey: K(e),
|
|
159
174
|
enabled: e != null,
|
|
160
175
|
queryFn: () => R(t, e)
|
|
161
176
|
});
|
|
162
177
|
}
|
|
163
|
-
function
|
|
178
|
+
function V(e) {
|
|
164
179
|
const t = n();
|
|
165
|
-
return
|
|
180
|
+
return i({
|
|
166
181
|
queryKey: Q(e),
|
|
167
182
|
enabled: e != null,
|
|
168
183
|
queryFn: () => A(t, e)
|
|
169
184
|
});
|
|
170
185
|
}
|
|
171
|
-
function
|
|
186
|
+
function W(e, t) {
|
|
172
187
|
const o = n();
|
|
173
|
-
return
|
|
174
|
-
queryKey:
|
|
188
|
+
return i({
|
|
189
|
+
queryKey: w(e, t),
|
|
175
190
|
enabled: t != null,
|
|
176
|
-
queryFn: () =>
|
|
191
|
+
queryFn: () => D(o, t, e)
|
|
177
192
|
});
|
|
178
193
|
}
|
|
179
|
-
function
|
|
194
|
+
function X(e, t = {}) {
|
|
180
195
|
const o = n();
|
|
181
|
-
return
|
|
182
|
-
queryKey:
|
|
196
|
+
return i({
|
|
197
|
+
queryKey: C(e, t),
|
|
183
198
|
enabled: e != null,
|
|
184
|
-
queryFn: () =>
|
|
199
|
+
queryFn: () => $(o, e, t)
|
|
185
200
|
});
|
|
186
201
|
}
|
|
187
|
-
function
|
|
188
|
-
const e = n(), t =
|
|
189
|
-
return
|
|
202
|
+
function Y() {
|
|
203
|
+
const e = n(), t = l();
|
|
204
|
+
return c({
|
|
205
|
+
mutationFn: (o) => N(e, o),
|
|
206
|
+
onSuccess: async () => {
|
|
207
|
+
await Promise.all([
|
|
208
|
+
t.invalidateQueries({ queryKey: ["model-catalog"] }),
|
|
209
|
+
t.invalidateQueries({ queryKey: ["model-catalog-all"] })
|
|
210
|
+
]);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
function Z() {
|
|
215
|
+
const e = n(), t = l();
|
|
216
|
+
return c({
|
|
190
217
|
mutationFn: (o) => T(e, o.project, o.input),
|
|
191
|
-
|
|
218
|
+
// The agent editor lists routes under its own key; a new route belongs in both lists.
|
|
219
|
+
onSuccess: () => Promise.all([
|
|
220
|
+
t.invalidateQueries({ queryKey: ["model-routes"] }),
|
|
221
|
+
t.invalidateQueries({ queryKey: ["agents", "model-routes"] })
|
|
222
|
+
])
|
|
192
223
|
});
|
|
193
224
|
}
|
|
194
|
-
function
|
|
195
|
-
const e = n(), t =
|
|
196
|
-
return
|
|
197
|
-
mutationFn: (o) =>
|
|
225
|
+
function I() {
|
|
226
|
+
const e = n(), t = l();
|
|
227
|
+
return c({
|
|
228
|
+
mutationFn: (o) => v(e, o.project, o.name, o.patch),
|
|
198
229
|
onSuccess: () => t.invalidateQueries({ queryKey: ["model-routes"] })
|
|
199
230
|
});
|
|
200
231
|
}
|
|
201
|
-
function
|
|
202
|
-
const e = n()
|
|
203
|
-
return
|
|
204
|
-
mutationFn: (
|
|
232
|
+
function ee() {
|
|
233
|
+
const e = n();
|
|
234
|
+
return c({
|
|
235
|
+
mutationFn: (t) => B(e, t.project, t.name, t.input)
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function te() {
|
|
239
|
+
const e = n(), t = l();
|
|
240
|
+
return c({
|
|
241
|
+
mutationFn: (o) => S(e, o.project, o.name),
|
|
205
242
|
onSuccess: () => t.invalidateQueries({ queryKey: ["model-routes"] })
|
|
206
243
|
});
|
|
207
244
|
}
|
|
208
|
-
function
|
|
209
|
-
const e = n(), t =
|
|
210
|
-
return
|
|
211
|
-
mutationFn: (o) =>
|
|
245
|
+
function oe() {
|
|
246
|
+
const e = n(), t = l();
|
|
247
|
+
return c({
|
|
248
|
+
mutationFn: (o) => U(e, o.project, o.input),
|
|
212
249
|
onSuccess: () => t.invalidateQueries({ queryKey: ["model-budgets"] })
|
|
213
250
|
});
|
|
214
251
|
}
|
|
215
|
-
function
|
|
216
|
-
const e = n(), t =
|
|
217
|
-
return
|
|
218
|
-
mutationFn: (o) =>
|
|
252
|
+
function se() {
|
|
253
|
+
const e = n(), t = l();
|
|
254
|
+
return c({
|
|
255
|
+
mutationFn: (o) => x(e, o.project, o.id, o.patch),
|
|
219
256
|
// The row meter reads its limit from the per-budget usage query, so refresh it too.
|
|
220
257
|
onSuccess: (o, s) => Promise.all([
|
|
221
258
|
t.invalidateQueries({ queryKey: ["model-budgets"] }),
|
|
@@ -223,48 +260,52 @@ function I() {
|
|
|
223
260
|
])
|
|
224
261
|
});
|
|
225
262
|
}
|
|
226
|
-
function
|
|
227
|
-
const e = n(), t =
|
|
228
|
-
return
|
|
229
|
-
mutationFn: (o) =>
|
|
263
|
+
function ne() {
|
|
264
|
+
const e = n(), t = l();
|
|
265
|
+
return c({
|
|
266
|
+
mutationFn: (o) => G(e, o.project, o.id),
|
|
230
267
|
onSuccess: () => t.invalidateQueries({ queryKey: ["model-budgets"] })
|
|
231
268
|
});
|
|
232
269
|
}
|
|
233
270
|
export {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
I,
|
|
243
|
-
|
|
244
|
-
L as
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
271
|
+
C as A,
|
|
272
|
+
g as B,
|
|
273
|
+
x as C,
|
|
274
|
+
v as D,
|
|
275
|
+
ee as E,
|
|
276
|
+
oe as F,
|
|
277
|
+
ne as G,
|
|
278
|
+
Y as H,
|
|
279
|
+
W as I,
|
|
280
|
+
V as J,
|
|
281
|
+
L as K,
|
|
282
|
+
X as L,
|
|
283
|
+
se as M,
|
|
284
|
+
te as a,
|
|
285
|
+
z as b,
|
|
286
|
+
J as c,
|
|
287
|
+
H as d,
|
|
288
|
+
Z as e,
|
|
289
|
+
I as f,
|
|
290
|
+
B as g,
|
|
291
|
+
F as h,
|
|
292
|
+
U as i,
|
|
293
|
+
T as j,
|
|
294
|
+
G as k,
|
|
254
295
|
R as l,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
296
|
+
S as m,
|
|
297
|
+
N as n,
|
|
298
|
+
D as o,
|
|
299
|
+
$ as p,
|
|
300
|
+
A as q,
|
|
301
|
+
b as r,
|
|
302
|
+
E as s,
|
|
303
|
+
P as t,
|
|
304
|
+
j as u,
|
|
305
|
+
w as v,
|
|
306
|
+
Q as w,
|
|
307
|
+
h as x,
|
|
308
|
+
M as y,
|
|
309
|
+
K as z
|
|
269
310
|
};
|
|
270
|
-
//# sourceMappingURL=models-
|
|
311
|
+
//# sourceMappingURL=models-CK1KHd39.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models-CK1KHd39.js","sources":["../src/repos/models.ts"],"sourcesContent":["/**\n * The model-registry repo — catalog, routes, budgets and usage over `W6WClient.request()`\n * (the stable ops for these land in the SDK separately; `request()` is the public escape hatch,\n * same as `vars.ts`). Shapes are the server's pinned wire shapes (project plan §Wire shapes).\n *\n * Scope: the catalog is tenant-wide and NEVER sends `project`. Routes, budgets and usage are\n * project-scoped, so their hooks are `enabled: projectId != null` and every fetcher sends\n * `?project=`; a project-scoped page therefore never queries before the project resolves.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport type { W6WClient } from \"@w6w/sdk\";\nimport { path } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\nexport interface ModelRates {\n input?: number;\n output?: number;\n cachedInput?: number;\n cacheWrite?: number;\n perRequest?: number;\n currency?: string;\n}\nexport interface ModelRate {\n id: string;\n modelId: string;\n effectiveFrom: string;\n rates: ModelRates;\n source: \"seed\" | \"tenant\";\n}\nexport interface Model {\n id: string;\n providerAppId: string;\n provider: string;\n nativeId: string;\n displayName: string;\n capabilities: unknown;\n limits: { maxInputTokens?: number; maxOutputTokens?: number };\n status: \"active\" | \"deprecated\" | \"blocked\";\n source: \"discovered\" | \"manual\";\n currentRate: ModelRate | null;\n discoveredAt: string | null;\n createdAt: string;\n updatedAt: string;\n}\nexport interface ModelFallback {\n model: string;\n connection: string;\n}\nexport interface ModelRoute {\n id: string;\n name: string;\n project: string;\n modelId: string;\n connectionId: string;\n fallbacks: ModelFallback[];\n defaults: Record<string, unknown>;\n status: \"active\" | \"broken\";\n createdAt: string;\n updatedAt: string;\n}\nexport interface ModelRouteInput {\n name: string;\n model: string;\n connection: string;\n fallbacks?: ModelFallback[];\n defaults?: Record<string, unknown>;\n}\nexport type ModelRoutePatch = Partial<Omit<ModelRouteInput, \"name\">>;\nexport interface ModelBudgetLimits {\n requests?: number;\n tokens?: number;\n costMinor?: number;\n currency?: string;\n}\nexport interface ModelBudget {\n id: string;\n scopeKind: string;\n scopeId: string | null;\n window: string;\n limits: ModelBudgetLimits;\n onBreach: \"block\" | \"warn\";\n}\nexport interface ModelBudgetInput {\n scopeKind: string;\n scopeId?: string;\n window: string;\n limits: ModelBudgetLimits;\n onBreach: \"block\" | \"warn\";\n}\nexport type ModelBudgetPatch = Partial<Omit<ModelBudgetInput, \"scopeKind\" | \"scopeId\">>;\nexport interface ModelBudgetUsageCounts {\n requests: number;\n tokens: number;\n costMinor: number;\n}\nexport interface ModelBudgetUsage {\n budgetId: string;\n window: string;\n windowStart: string;\n limits: ModelBudgetLimits;\n used: ModelBudgetUsageCounts;\n reserved: ModelBudgetUsageCounts;\n}\nexport interface ModelCost {\n currency: string;\n amountMinor: number;\n}\nexport interface ModelUsageGroup {\n key: string;\n requests: number;\n totalTokens: number;\n cost: ModelCost[];\n}\nexport interface ModelUsageTotals {\n requests: number;\n inputTokens: number;\n outputTokens: number;\n cachedInputTokens: number;\n cacheWriteTokens: number;\n totalTokens: number;\n cost: ModelCost[];\n unpriced: number;\n}\nexport interface ModelUsageItem {\n id: string;\n routeId: string | null;\n modelId: string;\n connectionId: string;\n provider: string;\n nativeId: string;\n inputTokens: number;\n outputTokens: number;\n cachedInputTokens: number;\n cacheWriteTokens: number;\n totalTokens: number;\n costMinor: number | null;\n currency: string | null;\n rateVersion: string | null;\n durationMs: number;\n ok: boolean;\n errorCode: string | null;\n invocationId: string | null;\n runId: string | null;\n occurredAt: string;\n}\nexport interface ModelUsageReport {\n totals: ModelUsageTotals;\n totalsTruncated?: boolean | null;\n groups?: ModelUsageGroup[];\n items: ModelUsageItem[];\n nextCursor: string | null;\n}\nexport interface ModelUsageFilter {\n route?: string;\n model?: string;\n from?: string;\n to?: string;\n groupBy?: \"route\" | \"model\" | \"day\";\n limit?: number;\n cursor?: string;\n}\nexport interface ModelCatalogFilter {\n provider?: string;\n status?: string;\n limit?: number;\n cursor?: string;\n}\nexport interface ModelCatalogPage {\n models: Model[];\n nextCursor: string | null;\n}\n\nexport const modelCatalogKey = (filter: ModelCatalogFilter = {}) =>\n [\"model-catalog\", filter] as const;\nexport const modelProvidersKey = [\"model-providers\"] as const;\nexport const modelRoutesKey = (projectId?: string) => [\"model-routes\", projectId] as const;\nexport const modelBudgetsKey = (projectId?: string) => [\"model-budgets\", projectId] as const;\nexport const modelBudgetUsageKey = (id: string, projectId?: string) =>\n [\"model-budget-usage\", id, projectId] as const;\nexport const modelUsageKey = (projectId?: string, filter: ModelUsageFilter = {}) =>\n [\"model-usage\", projectId, filter] as const;\n\nexport async function listModelCatalog(\n client: W6WClient,\n filter: ModelCatalogFilter = {},\n): Promise<ModelCatalogPage> {\n // Tenant-wide: deliberately no `project` here.\n const res = await client.request<ModelCatalogPage>({\n method: \"GET\",\n path: \"/models\",\n query: { ...filter },\n });\n return res.body;\n}\n\n/** One row of `GET /models/providers` — the descriptor the model pickers are driven by. */\nexport interface ModelProviderRow {\n appId: string;\n provider: string | null;\n installed: boolean;\n designation?: { modelTypes: string[]; modelFamilies?: string[] } | null;\n operations?: {\n discover: { supported: boolean; reason?: string };\n complete: {\n supported: boolean;\n reason?: string;\n features?: Partial<Record<ModelFeature, ModelFeatureState>>;\n };\n };\n /** A2 (optional): the bridge adapter serving this app; `null` = none. */\n adapter?: { provider: string; contractVersion: number } | null;\n /** A2 (optional): why this app cannot serve the caller right now. */\n reasons?: ModelProviderReason[];\n}\nexport type ModelFeature = \"toolCalls\" | \"structuredOutput\" | \"streaming\";\nexport type ModelFeatureState = \"supported\" | \"unsupported\" | \"unknown\";\nexport type ModelProviderReasonCode =\n | \"not_installed\"\n | \"no_adapter\"\n | \"not_entitled\"\n | \"no_connection\";\nexport interface ModelProviderReason {\n code: ModelProviderReasonCode;\n message: string;\n}\nexport interface CompleteSupport {\n supported: boolean;\n features: Partial<Record<ModelFeature, ModelFeatureState>>;\n reasons: ModelProviderReason[];\n}\n\n/**\n * THE support policy for `operations.complete`. Unsupported when the descriptor says so or the\n * row names no adapter (`adapter: null`); a pre-A2 row (no `adapter`/`features`/`reasons`) falls\n * back to `operations.complete.supported`. Unsupported rows always carry a reason.\n */\nexport function completeSupport(row: ModelProviderRow): CompleteSupport {\n const op = row.operations?.complete;\n const noAdapter = row.adapter === null;\n const supported = op?.supported === true && !noAdapter;\n const reasons = [...(row.reasons ?? [])];\n if (!supported && reasons.length === 0) {\n reasons.push({\n code:\n noAdapter || op?.supported === true\n ? \"no_adapter\"\n : row.installed\n ? \"no_adapter\"\n : \"not_installed\",\n message: op?.reason ?? \"Not supported for this provider\",\n });\n }\n return { supported, features: op?.features ?? {}, reasons };\n}\n\n/** Follow `nextCursor` until null (or `maxPages`), concatenating `models`. */\nexport async function loadAllModelCatalogPages(\n fetchPage: (cursor?: string) => Promise<ModelCatalogPage>,\n opts: { maxPages?: number } = {},\n): Promise<{ models: Model[]; truncated: boolean }> {\n const maxPages = opts.maxPages ?? 50;\n const models: Model[] = [];\n let cursor: string | undefined;\n for (let i = 0; i < maxPages; i++) {\n const page = await fetchPage(cursor);\n models.push(...page.models);\n if (!page.nextCursor) return { models, truncated: false };\n cursor = page.nextCursor;\n }\n return { models, truncated: true };\n}\nexport type ModelOperation = \"discover\" | \"complete\";\nexport interface ConnectionChoice {\n id: string;\n appId: string;\n displayName: string;\n /** Present only when the descriptor says the operation is unsupported for this provider. */\n disabledReason?: string;\n}\n\nexport async function listModelProviders(client: W6WClient): Promise<ModelProviderRow[]> {\n const res = await client.request<{ providers?: ModelProviderRow[] } | ModelProviderRow[]>({\n method: \"GET\",\n path: \"/models/providers\",\n });\n const b = res.body;\n return Array.isArray(b) ? b : (b?.providers ?? []);\n}\n\n/**\n * The connections a model picker may offer for `operation`, decided by the descriptor alone:\n * a connection whose app has no designated provider row never appears (an `ai`-category app is\n * not a provider); a designated row whose `discover` is unsupported appears disabled with the\n * descriptor's reason; for `complete` the shared `completeSupport` policy decides (unsupported => disabled, never selectable).\n */\nexport function connectionChoices<C extends { id: string; appId: string; displayName: string }>(\n connections: C[],\n providers: ModelProviderRow[],\n operation: ModelOperation,\n): ConnectionChoice[] {\n const byApp = new Map<string, ModelProviderRow>();\n for (const p of providers) if (p.designation) byApp.set(p.appId, p);\n const out: ConnectionChoice[] = [];\n for (const c of connections) {\n const row = byApp.get(c.appId);\n if (!row) continue;\n const op = row.operations?.[operation];\n const choice: ConnectionChoice = { id: c.id, appId: c.appId, displayName: c.displayName };\n if (operation === \"complete\") {\n const sup = completeSupport(row);\n if (!sup.supported) {\n choice.disabledReason =\n op?.reason ?? sup.reasons[0]?.message ?? \"Not supported for this provider\";\n }\n } else if (!op?.supported) {\n choice.disabledReason = op?.reason ?? \"Not supported for this provider\";\n }\n out.push(choice);\n }\n return out;\n}\n\n/** The server answers fallbacks as `{modelId, connectionId}`; the editor works in `{model, connection}`. */\nexport function normaliseRoute(r: ModelRoute): ModelRoute {\n const fallbacks = (r.fallbacks ?? []).map((f) => {\n const x = f as ModelFallback & { modelId?: string; connectionId?: string };\n return { model: x.model ?? x.modelId ?? \"\", connection: x.connection ?? x.connectionId ?? \"\" };\n });\n return { ...r, fallbacks };\n}\n\nexport async function listModelRoutes(client: W6WClient, project: string): Promise<ModelRoute[]> {\n const res = await client.request<{ routes: ModelRoute[] }>({\n method: \"GET\",\n path: \"/model-routes\",\n query: { project },\n });\n return res.body.routes.map(normaliseRoute);\n}\nexport async function createModelRoute(\n client: W6WClient,\n project: string,\n input: ModelRouteInput,\n): Promise<ModelRoute> {\n const res = await client.request<{ route: ModelRoute }>({\n method: \"POST\",\n path: \"/model-routes\",\n query: { project },\n body: input,\n });\n return normaliseRoute(res.body.route);\n}\nexport async function updateModelRoute(\n client: W6WClient,\n project: string,\n name: string,\n patch: ModelRoutePatch,\n): Promise<ModelRoute> {\n const res = await client.request<{ route: ModelRoute }>({\n method: \"PATCH\",\n path: path`/model-routes/${name}`,\n query: { project },\n body: patch,\n });\n return normaliseRoute(res.body.route);\n}\n/**\n * One content block (the bridge dialect): text, or a `tool-call` the model made, or the\n * `tool-result` sent back for it. Other block kinds pass through untyped.\n */\nexport type ModelCompletionBlock =\n | { type: \"text\"; text: string }\n | { type: \"tool-call\"; id: string; name: string; input: unknown; arguments?: string }\n | { type: \"tool-result\"; id: string; content: string | ModelCompletionBlock[] }\n | { type: string; [key: string]: unknown };\n/** One chat message for a route completion (the bridge dialect). */\nexport interface ModelCompletionMessage {\n role: \"system\" | \"user\" | \"assistant\";\n content: string | unknown[];\n}\n/** A function the model may call: a name, what it is for, and a JSON Schema for its input. */\nexport interface ModelCompletionTool {\n type: \"function\";\n name: string;\n description?: string;\n /** A JSON Schema object (`{ type: \"object\", properties, required? }`). */\n inputSchema: object;\n}\n/** A route completion request: the messages plus the agent's model options and tools. */\nexport interface ModelCompletionInput {\n messages: ModelCompletionMessage[];\n temperature?: number;\n topP?: number;\n maxOutputTokens?: number;\n stop?: string[];\n tools?: ModelCompletionTool[];\n toolChoice?: \"auto\" | \"none\" | \"required\" | { name: string };\n}\n/** The parts of the completion envelope a caller reads (`response=output`, no raw). */\nexport interface ModelCompletionResult {\n provider: string;\n model: string;\n route: string | null;\n output?: {\n choices?: {\n message?: { content?: string | ModelCompletionBlock[] };\n finishReason?: string;\n }[];\n };\n usageSummary?: { inclusiveInputTokens?: number; outputTokens?: number; totalTokens?: number };\n durationMs?: number;\n}\n/** `POST /model-routes/{name}/complete` — calls the route's model once (billed like any call). */\nexport async function completeModelRoute(\n client: W6WClient,\n project: string,\n name: string,\n input: ModelCompletionInput,\n): Promise<ModelCompletionResult> {\n const res = await client.request<ModelCompletionResult>({\n method: \"POST\",\n path: path`/model-routes/${name}/complete`,\n query: { project, response: \"output\" },\n body: input,\n });\n return res.body;\n}\nexport async function deleteModelRoute(\n client: W6WClient,\n project: string,\n name: string,\n): Promise<void> {\n await client.request<{ ok: true }>({\n method: \"DELETE\",\n path: path`/model-routes/${name}`,\n query: { project },\n });\n}\n\nexport async function listModelBudgets(client: W6WClient, project: string): Promise<ModelBudget[]> {\n const res = await client.request<{ budgets: ModelBudget[] }>({\n method: \"GET\",\n path: \"/model-budgets\",\n query: { project },\n });\n return res.body.budgets;\n}\nexport async function createModelBudget(\n client: W6WClient,\n project: string,\n input: ModelBudgetInput,\n): Promise<ModelBudget> {\n // The server answers with the budget row itself (201), not a `{ budget }` wrapper.\n const res = await client.request<ModelBudget>({\n method: \"POST\",\n path: \"/model-budgets\",\n query: { project },\n body: input,\n });\n return res.body;\n}\nexport async function updateModelBudget(\n client: W6WClient,\n project: string,\n id: string,\n patch: ModelBudgetPatch,\n): Promise<ModelBudget> {\n // The server answers with the updated budget row itself, not a `{ budget }` wrapper.\n const res = await client.request<ModelBudget>({\n method: \"PATCH\",\n path: path`/model-budgets/${id}`,\n query: { project },\n body: patch,\n });\n return res.body;\n}\nexport async function deleteModelBudget(\n client: W6WClient,\n project: string,\n id: string,\n): Promise<void> {\n await client.request<{ ok: true }>({\n method: \"DELETE\",\n path: path`/model-budgets/${id}`,\n query: { project },\n });\n}\nexport async function getModelBudgetUsage(\n client: W6WClient,\n project: string,\n id: string,\n): Promise<ModelBudgetUsage> {\n const res = await client.request<ModelBudgetUsage>({\n method: \"GET\",\n path: path`/model-budgets/${id}/usage`,\n query: { project },\n });\n return res.body;\n}\nexport async function getModelUsage(\n client: W6WClient,\n project: string,\n filter: ModelUsageFilter = {},\n): Promise<ModelUsageReport> {\n const res = await client.request<ModelUsageReport>({\n method: \"GET\",\n path: \"/model-usage\",\n query: { project, ...filter },\n });\n return res.body;\n}\n\n/** What `POST /models/discover` changed in the tenant catalog — model ids per bucket. */\nexport interface ModelDiscoverResult {\n added: string[];\n updated: string[];\n deprecated: string[];\n}\n/**\n * Ask the provider behind `connection` for its model list and fold it into the tenant catalog.\n * Tenant administration only: anyone else gets a 403 `forbidden`.\n */\nexport async function discoverModels(\n client: W6WClient,\n connection: string,\n): Promise<ModelDiscoverResult> {\n const res = await client.request<ModelDiscoverResult>({\n method: \"POST\",\n path: \"/models/discover\",\n body: { connection },\n });\n return res.body;\n}\n\nexport function useModelCatalogQuery(filter: ModelCatalogFilter = {}) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: modelCatalogKey(filter),\n queryFn: () => listModelCatalog(client, filter),\n });\n}\nexport function useAllModelCatalogQuery(filter: Omit<ModelCatalogFilter, \"cursor\"> = {}) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: [\"model-catalog-all\", filter] as const,\n queryFn: () =>\n loadAllModelCatalogPages((cursor) => listModelCatalog(client, { ...filter, cursor })),\n });\n}\nexport function useModelProvidersQuery() {\n const client = useEmbedClient();\n return useQuery({ queryKey: modelProvidersKey, queryFn: () => listModelProviders(client) });\n}\nexport function useModelRoutesQuery(projectId?: string) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: modelRoutesKey(projectId),\n enabled: projectId != null,\n queryFn: () => listModelRoutes(client, projectId as string),\n });\n}\nexport function useModelBudgetsQuery(projectId?: string) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: modelBudgetsKey(projectId),\n enabled: projectId != null,\n queryFn: () => listModelBudgets(client, projectId as string),\n });\n}\nexport function useModelBudgetUsageQuery(id: string, projectId?: string) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: modelBudgetUsageKey(id, projectId),\n enabled: projectId != null,\n queryFn: () => getModelBudgetUsage(client, projectId as string, id),\n });\n}\nexport function useModelUsageQuery(projectId?: string, filter: ModelUsageFilter = {}) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: modelUsageKey(projectId, filter),\n enabled: projectId != null,\n queryFn: () => getModelUsage(client, projectId as string, filter),\n });\n}\n\nexport function useDiscoverModelsMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (connection: string) => discoverModels(client, connection),\n onSuccess: async () => {\n await Promise.all([\n qc.invalidateQueries({ queryKey: [\"model-catalog\"] }),\n qc.invalidateQueries({ queryKey: [\"model-catalog-all\"] }),\n ]);\n },\n });\n}\nexport function useCreateModelRouteMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: { project: string; input: ModelRouteInput }) =>\n createModelRoute(client, v.project, v.input),\n // The agent editor lists routes under its own key; a new route belongs in both lists.\n onSuccess: () =>\n Promise.all([\n qc.invalidateQueries({ queryKey: [\"model-routes\"] }),\n qc.invalidateQueries({ queryKey: [\"agents\", \"model-routes\"] }),\n ]),\n });\n}\nexport function useUpdateModelRouteMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: { project: string; name: string; patch: ModelRoutePatch }) =>\n updateModelRoute(client, v.project, v.name, v.patch),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"model-routes\"] }),\n });\n}\nexport function useCompleteModelRouteMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (v: { project: string; name: string; input: ModelCompletionInput }) =>\n completeModelRoute(client, v.project, v.name, v.input),\n });\n}\nexport function useDeleteModelRouteMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: { project: string; name: string }) =>\n deleteModelRoute(client, v.project, v.name),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"model-routes\"] }),\n });\n}\nexport function useCreateModelBudgetMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: { project: string; input: ModelBudgetInput }) =>\n createModelBudget(client, v.project, v.input),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"model-budgets\"] }),\n });\n}\nexport function useUpdateModelBudgetMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: { project: string; id: string; patch: ModelBudgetPatch }) =>\n updateModelBudget(client, v.project, v.id, v.patch),\n // The row meter reads its limit from the per-budget usage query, so refresh it too.\n onSuccess: (_b, v) =>\n Promise.all([\n qc.invalidateQueries({ queryKey: [\"model-budgets\"] }),\n qc.invalidateQueries({ queryKey: [\"model-budget-usage\", v.id] }),\n ]),\n });\n}\nexport function useDeleteModelBudgetMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: { project: string; id: string }) => deleteModelBudget(client, v.project, v.id),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"model-budgets\"] }),\n });\n}\n"],"names":["modelCatalogKey","filter","modelProvidersKey","modelRoutesKey","projectId","modelBudgetsKey","modelBudgetUsageKey","id","modelUsageKey","listModelCatalog","client","completeSupport","row","op","_a","noAdapter","supported","reasons","loadAllModelCatalogPages","fetchPage","opts","maxPages","models","cursor","i","page","listModelProviders","b","connectionChoices","connections","providers","operation","byApp","p","out","c","choice","sup","_b","normaliseRoute","r","fallbacks","f","x","listModelRoutes","project","createModelRoute","input","res","updateModelRoute","name","patch","path","completeModelRoute","deleteModelRoute","listModelBudgets","createModelBudget","updateModelBudget","deleteModelBudget","getModelBudgetUsage","getModelUsage","discoverModels","connection","useModelCatalogQuery","useEmbedClient","useQuery","useAllModelCatalogQuery","useModelProvidersQuery","useModelRoutesQuery","useModelBudgetsQuery","useModelBudgetUsageQuery","useModelUsageQuery","useDiscoverModelsMutation","qc","useQueryClient","useMutation","useCreateModelRouteMutation","v","useUpdateModelRouteMutation","useCompleteModelRouteMutation","useDeleteModelRouteMutation","useCreateModelBudgetMutation","useUpdateModelBudgetMutation","useDeleteModelBudgetMutation"],"mappings":";;;AA4KO,MAAMA,IAAkB,CAACC,IAA6B,OAC3D,CAAC,iBAAiBA,CAAM,GACbC,IAAoB,CAAC,iBAAiB,GACtCC,IAAiB,CAACC,MAAuB,CAAC,gBAAgBA,CAAS,GACnEC,IAAkB,CAACD,MAAuB,CAAC,iBAAiBA,CAAS,GACrEE,IAAsB,CAACC,GAAYH,MAC9C,CAAC,sBAAsBG,GAAIH,CAAS,GACzBI,IAAgB,CAACJ,GAAoBH,IAA2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
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Agent, ApiError, ContextEntry, ContextPin, CreateAgentInput, SkillPin, SkillVersion, UpdateAgentInput, W6WClient } from '@w6w/sdk';
|
|
2
|
-
export type { Agent, ContextEntry, ContextPin, CreateAgentInput, SkillPin, SkillVersion, UpdateAgentInput, };
|
|
1
|
+
import { Agent, AgentTool, ApiError, ContextEntry, ContextPin, CreateAgentInput, SkillPin, SkillVersion, UpdateAgentInput, W6WClient } from '@w6w/sdk';
|
|
2
|
+
export type { Agent, AgentTool, ContextEntry, ContextPin, CreateAgentInput, SkillPin, SkillVersion, UpdateAgentInput, };
|
|
3
3
|
/** Thrown by {@linkcode updateAgent} on a 409: the draft changed elsewhere. Never overwrites. */
|
|
4
4
|
export declare class AgentConflictError extends Error {
|
|
5
5
|
readonly kind: "conflict";
|
|
@@ -50,3 +50,47 @@ export declare function useAgentModelRoutesQuery(projectId?: string): import('@t
|
|
|
50
50
|
export declare function useAgentSettingsQuery(): import('@tanstack/react-query').UseQueryResult<NoInfer<import('@w6w/sdk/console').AgentSettings>, Error>;
|
|
51
51
|
export declare function usePatchAgentSettings(): import('@tanstack/react-query').UseMutationResult<import('@w6w/sdk/console').AgentSettings, Error, Partial<import('@w6w/sdk/console').AgentSettingsValues>, unknown>;
|
|
52
52
|
export declare function useStorageBindingsQuery(): import('@tanstack/react-query').UseQueryResult<NoInfer<import('@w6w/sdk/console').StorageBinding[]>, Error>;
|
|
53
|
+
/** One message of a Test conversation, as the model contract has it. */
|
|
54
|
+
export interface AgentTestTurn {
|
|
55
|
+
role: "user" | "assistant";
|
|
56
|
+
content: unknown;
|
|
57
|
+
}
|
|
58
|
+
export interface AgentTestRequest {
|
|
59
|
+
project: string;
|
|
60
|
+
message: string;
|
|
61
|
+
/** The `turns` of earlier answers, so a follow-up keeps the conversation. */
|
|
62
|
+
history?: AgentTestTurn[];
|
|
63
|
+
/** Unsaved form state laid over the stored agent. */
|
|
64
|
+
draft?: {
|
|
65
|
+
instructions?: string;
|
|
66
|
+
modelRouteId?: string | null;
|
|
67
|
+
modelOptions?: Record<string, unknown>;
|
|
68
|
+
tools?: AgentTool[];
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export interface AgentTestToolCall {
|
|
72
|
+
tool: string;
|
|
73
|
+
input: Record<string, unknown>;
|
|
74
|
+
ok: boolean;
|
|
75
|
+
/** The tool's output, or the error message when `ok` is false. */
|
|
76
|
+
output: unknown;
|
|
77
|
+
}
|
|
78
|
+
export interface AgentTestResult {
|
|
79
|
+
text: string;
|
|
80
|
+
turns: AgentTestTurn[];
|
|
81
|
+
toolCalls: AgentTestToolCall[];
|
|
82
|
+
model: string | null;
|
|
83
|
+
rounds: number;
|
|
84
|
+
usage: {
|
|
85
|
+
inputTokens: number;
|
|
86
|
+
outputTokens: number;
|
|
87
|
+
};
|
|
88
|
+
finishReason: string | null;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Run the agent once on a message through the server's agent runtime — the same one a workflow's
|
|
92
|
+
* "Run agent" step uses, so tools run there (fixed values resolved server-side, only the AI fields
|
|
93
|
+
* passed on). Real, billed model and tool calls. Through `client.request` (Studio-internal route).
|
|
94
|
+
*/
|
|
95
|
+
export declare function testAgent(client: W6WClient, id: string, body: AgentTestRequest): Promise<AgentTestResult>;
|
|
96
|
+
export declare function useTestAgentMutation(id: string): import('@tanstack/react-query').UseMutationResult<AgentTestResult, Error, AgentTestRequest, unknown>;
|
package/dist/repos/models.d.ts
CHANGED
|
@@ -244,6 +244,74 @@ export declare function normaliseRoute(r: ModelRoute): ModelRoute;
|
|
|
244
244
|
export declare function listModelRoutes(client: W6WClient, project: string): Promise<ModelRoute[]>;
|
|
245
245
|
export declare function createModelRoute(client: W6WClient, project: string, input: ModelRouteInput): Promise<ModelRoute>;
|
|
246
246
|
export declare function updateModelRoute(client: W6WClient, project: string, name: string, patch: ModelRoutePatch): Promise<ModelRoute>;
|
|
247
|
+
/**
|
|
248
|
+
* One content block (the bridge dialect): text, or a `tool-call` the model made, or the
|
|
249
|
+
* `tool-result` sent back for it. Other block kinds pass through untyped.
|
|
250
|
+
*/
|
|
251
|
+
export type ModelCompletionBlock = {
|
|
252
|
+
type: "text";
|
|
253
|
+
text: string;
|
|
254
|
+
} | {
|
|
255
|
+
type: "tool-call";
|
|
256
|
+
id: string;
|
|
257
|
+
name: string;
|
|
258
|
+
input: unknown;
|
|
259
|
+
arguments?: string;
|
|
260
|
+
} | {
|
|
261
|
+
type: "tool-result";
|
|
262
|
+
id: string;
|
|
263
|
+
content: string | ModelCompletionBlock[];
|
|
264
|
+
} | {
|
|
265
|
+
type: string;
|
|
266
|
+
[key: string]: unknown;
|
|
267
|
+
};
|
|
268
|
+
/** One chat message for a route completion (the bridge dialect). */
|
|
269
|
+
export interface ModelCompletionMessage {
|
|
270
|
+
role: "system" | "user" | "assistant";
|
|
271
|
+
content: string | unknown[];
|
|
272
|
+
}
|
|
273
|
+
/** A function the model may call: a name, what it is for, and a JSON Schema for its input. */
|
|
274
|
+
export interface ModelCompletionTool {
|
|
275
|
+
type: "function";
|
|
276
|
+
name: string;
|
|
277
|
+
description?: string;
|
|
278
|
+
/** A JSON Schema object (`{ type: "object", properties, required? }`). */
|
|
279
|
+
inputSchema: object;
|
|
280
|
+
}
|
|
281
|
+
/** A route completion request: the messages plus the agent's model options and tools. */
|
|
282
|
+
export interface ModelCompletionInput {
|
|
283
|
+
messages: ModelCompletionMessage[];
|
|
284
|
+
temperature?: number;
|
|
285
|
+
topP?: number;
|
|
286
|
+
maxOutputTokens?: number;
|
|
287
|
+
stop?: string[];
|
|
288
|
+
tools?: ModelCompletionTool[];
|
|
289
|
+
toolChoice?: "auto" | "none" | "required" | {
|
|
290
|
+
name: string;
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
/** The parts of the completion envelope a caller reads (`response=output`, no raw). */
|
|
294
|
+
export interface ModelCompletionResult {
|
|
295
|
+
provider: string;
|
|
296
|
+
model: string;
|
|
297
|
+
route: string | null;
|
|
298
|
+
output?: {
|
|
299
|
+
choices?: {
|
|
300
|
+
message?: {
|
|
301
|
+
content?: string | ModelCompletionBlock[];
|
|
302
|
+
};
|
|
303
|
+
finishReason?: string;
|
|
304
|
+
}[];
|
|
305
|
+
};
|
|
306
|
+
usageSummary?: {
|
|
307
|
+
inclusiveInputTokens?: number;
|
|
308
|
+
outputTokens?: number;
|
|
309
|
+
totalTokens?: number;
|
|
310
|
+
};
|
|
311
|
+
durationMs?: number;
|
|
312
|
+
}
|
|
313
|
+
/** `POST /model-routes/{name}/complete` — calls the route's model once (billed like any call). */
|
|
314
|
+
export declare function completeModelRoute(client: W6WClient, project: string, name: string, input: ModelCompletionInput): Promise<ModelCompletionResult>;
|
|
247
315
|
export declare function deleteModelRoute(client: W6WClient, project: string, name: string): Promise<void>;
|
|
248
316
|
export declare function listModelBudgets(client: W6WClient, project: string): Promise<ModelBudget[]>;
|
|
249
317
|
export declare function createModelBudget(client: W6WClient, project: string, input: ModelBudgetInput): Promise<ModelBudget>;
|
|
@@ -251,6 +319,17 @@ export declare function updateModelBudget(client: W6WClient, project: string, id
|
|
|
251
319
|
export declare function deleteModelBudget(client: W6WClient, project: string, id: string): Promise<void>;
|
|
252
320
|
export declare function getModelBudgetUsage(client: W6WClient, project: string, id: string): Promise<ModelBudgetUsage>;
|
|
253
321
|
export declare function getModelUsage(client: W6WClient, project: string, filter?: ModelUsageFilter): Promise<ModelUsageReport>;
|
|
322
|
+
/** What `POST /models/discover` changed in the tenant catalog — model ids per bucket. */
|
|
323
|
+
export interface ModelDiscoverResult {
|
|
324
|
+
added: string[];
|
|
325
|
+
updated: string[];
|
|
326
|
+
deprecated: string[];
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Ask the provider behind `connection` for its model list and fold it into the tenant catalog.
|
|
330
|
+
* Tenant administration only: anyone else gets a 403 `forbidden`.
|
|
331
|
+
*/
|
|
332
|
+
export declare function discoverModels(client: W6WClient, connection: string): Promise<ModelDiscoverResult>;
|
|
254
333
|
export declare function useModelCatalogQuery(filter?: ModelCatalogFilter): import('@tanstack/react-query').UseQueryResult<NoInfer<ModelCatalogPage>, Error>;
|
|
255
334
|
export declare function useAllModelCatalogQuery(filter?: Omit<ModelCatalogFilter, "cursor">): import('@tanstack/react-query').UseQueryResult<NoInfer<{
|
|
256
335
|
models: Model[];
|
|
@@ -261,6 +340,7 @@ export declare function useModelRoutesQuery(projectId?: string): import('@tansta
|
|
|
261
340
|
export declare function useModelBudgetsQuery(projectId?: string): import('@tanstack/react-query').UseQueryResult<NoInfer<ModelBudget[]>, Error>;
|
|
262
341
|
export declare function useModelBudgetUsageQuery(id: string, projectId?: string): import('@tanstack/react-query').UseQueryResult<NoInfer<ModelBudgetUsage>, Error>;
|
|
263
342
|
export declare function useModelUsageQuery(projectId?: string, filter?: ModelUsageFilter): import('@tanstack/react-query').UseQueryResult<NoInfer<ModelUsageReport>, Error>;
|
|
343
|
+
export declare function useDiscoverModelsMutation(): import('@tanstack/react-query').UseMutationResult<ModelDiscoverResult, Error, string, unknown>;
|
|
264
344
|
export declare function useCreateModelRouteMutation(): import('@tanstack/react-query').UseMutationResult<ModelRoute, Error, {
|
|
265
345
|
project: string;
|
|
266
346
|
input: ModelRouteInput;
|
|
@@ -270,6 +350,11 @@ export declare function useUpdateModelRouteMutation(): import('@tanstack/react-q
|
|
|
270
350
|
name: string;
|
|
271
351
|
patch: ModelRoutePatch;
|
|
272
352
|
}, unknown>;
|
|
353
|
+
export declare function useCompleteModelRouteMutation(): import('@tanstack/react-query').UseMutationResult<ModelCompletionResult, Error, {
|
|
354
|
+
project: string;
|
|
355
|
+
name: string;
|
|
356
|
+
input: ModelCompletionInput;
|
|
357
|
+
}, unknown>;
|
|
273
358
|
export declare function useDeleteModelRouteMutation(): import('@tanstack/react-query').UseMutationResult<void, Error, {
|
|
274
359
|
project: string;
|
|
275
360
|
name: string;
|