@w6w/embed 0.2.22 → 0.2.23

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.
@@ -1,7 +1,7 @@
1
- import { useQuery as c, useQueryClient as i, useMutation as y } from "@tanstack/react-query";
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], C = (e, t) => ["model-budget-usage", e, t], E = (e, t = {}) => ["model-usage", e, t];
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 a;
14
- const t = (a = e.operations) == null ? void 0 : a.complete, o = e.adapter === null, s = (t == null ? void 0 : t.supported) === !0 && !o, u = [...e.reasons ?? []];
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 w(e, t = {}) {
20
+ async function P(e, t = {}) {
21
21
  const o = t.maxPages ?? 50, s = [];
22
22
  let u;
23
- for (let a = 0; a < o; a++) {
24
- const l = await e(u);
25
- if (s.push(...l.models), !l.nextCursor) return { models: s, truncated: !1 };
26
- u = l.nextCursor;
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 B(e) {
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 k(e, t, o) {
38
- var a, l;
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 r = (a = p.operations) == null ? void 0 : a[o], g = { id: d.id, appId: d.appId, displayName: d.displayName };
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 || (g.disabledReason = (r == null ? void 0 : r.reason) ?? ((l = f.reasons[0]) == null ? void 0 : l.message) ?? "Not supported for this provider");
49
- } else r != null && r.supported || (g.disabledReason = (r == null ? void 0 : r.reason) ?? "Not supported for this provider");
50
- u.push(g);
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 q(e) {
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(q);
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 q(s.body.route);
75
+ return g(s.body.route);
76
76
  }
77
- async function P(e, t, o, s) {
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 q(u.body.route);
84
+ return g(u.body.route);
85
85
  }
86
- async function v(e, t, o) {
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 S(e, t, o) {
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 U(e, t, o, s) {
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 x(e, t, o) {
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 G(e, t, o) {
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 D(e, t, o = {}) {
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 H(e = {}) {
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 c({
154
+ return i({
140
155
  queryKey: h(e),
141
156
  queryFn: () => b(t, e)
142
157
  });
143
158
  }
144
- function L(e = {}) {
159
+ function z(e = {}) {
145
160
  const t = n();
146
- return c({
161
+ return i({
147
162
  queryKey: ["model-catalog-all", e],
148
- queryFn: () => w((o) => b(t, { ...e, cursor: o }))
163
+ queryFn: () => P((o) => b(t, { ...e, cursor: o }))
149
164
  });
150
165
  }
151
- function O() {
166
+ function J() {
152
167
  const e = n();
153
- return c({ queryKey: M, queryFn: () => B(e) });
168
+ return i({ queryKey: M, queryFn: () => E(e) });
154
169
  }
155
- function z(e) {
170
+ function j(e) {
156
171
  const t = n();
157
- return c({
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 J(e) {
178
+ function V(e) {
164
179
  const t = n();
165
- return c({
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 V(e, t) {
186
+ function W(e, t) {
172
187
  const o = n();
173
- return c({
174
- queryKey: C(e, t),
188
+ return i({
189
+ queryKey: w(e, t),
175
190
  enabled: t != null,
176
- queryFn: () => G(o, t, e)
191
+ queryFn: () => D(o, t, e)
177
192
  });
178
193
  }
179
- function W(e, t = {}) {
194
+ function X(e, t = {}) {
180
195
  const o = n();
181
- return c({
182
- queryKey: E(e, t),
196
+ return i({
197
+ queryKey: C(e, t),
183
198
  enabled: e != null,
184
- queryFn: () => D(o, e, t)
199
+ queryFn: () => $(o, e, t)
185
200
  });
186
201
  }
187
- function X() {
188
- const e = n(), t = i();
189
- return y({
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
- onSuccess: () => t.invalidateQueries({ queryKey: ["model-routes"] })
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 Y() {
195
- const e = n(), t = i();
196
- return y({
197
- mutationFn: (o) => P(e, o.project, o.name, o.patch),
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 Z() {
202
- const e = n(), t = i();
203
- return y({
204
- mutationFn: (o) => v(e, o.project, o.name),
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 j() {
209
- const e = n(), t = i();
210
- return y({
211
- mutationFn: (o) => S(e, o.project, o.input),
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 I() {
216
- const e = n(), t = i();
217
- return y({
218
- mutationFn: (o) => U(e, o.project, o.id, o.patch),
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 ee() {
227
- const e = n(), t = i();
228
- return y({
229
- mutationFn: (o) => x(e, o.project, o.id),
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
- U as A,
235
- P as B,
236
- j as C,
237
- ee as D,
238
- V as E,
239
- J as F,
240
- H as G,
241
- W as H,
242
- I,
243
- Z as a,
244
- L as b,
245
- O as c,
246
- k as d,
247
- X as e,
248
- Y as f,
249
- F as g,
250
- S as h,
251
- T as i,
252
- x as j,
253
- v as k,
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
- G as m,
256
- D as n,
257
- A as o,
258
- b as p,
259
- B as q,
260
- w as r,
261
- C as s,
262
- Q as t,
263
- z as u,
264
- h as v,
265
- M as w,
266
- K as x,
267
- E as y,
268
- q as z
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-bAayQPJ_.js.map
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/** One chat message for a route completion (the bridge dialect). */\nexport interface ModelCompletionMessage {\n role: \"system\" | \"user\" | \"assistant\";\n content: string;\n}\n/** A route completion request: the messages plus the agent's model options. */\nexport interface ModelCompletionInput {\n messages: ModelCompletionMessage[];\n temperature?: number;\n topP?: number;\n maxOutputTokens?: number;\n stop?: 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 | { type: string; text?: string }[] };\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,IAA2B,CAAA,MAC3E,CAAC,eAAeG,GAAWH,CAAM;AAEnC,eAAsBQ,EACpBC,GACAT,IAA6B,IACF;AAO3B,UALY,MAAMS,EAAO,QAA0B;AAAA,IACjD,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO,EAAE,GAAGT,EAAA;AAAA,EAAO,CACpB,GACU;AACb;AA2CO,SAASU,EAAgBC,GAAwC;;AACtE,QAAMC,KAAKC,IAAAF,EAAI,eAAJ,gBAAAE,EAAgB,UACrBC,IAAYH,EAAI,YAAY,MAC5BI,KAAYH,KAAA,gBAAAA,EAAI,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X,SAAOC,EAAY;AAAA,IACjB,YAAY,CAACE,MACXrB,EAAkB9C,GAAQmE,EAAE,SAASA,EAAE,KAAK;AAAA,IAC9C,WAAW,MAAMJ,EAAG,kBAAkB,EAAE,UAAU,CAAC,eAAe,EAAA,CAAG;AAAA,EAAA,CACtE;AACH;AACO,SAASS,KAA+B;AAC7C,QAAMxE,IAASsD,EAAA,GACTS,IAAKC,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAACE,MACXpB,EAAkB/C,GAAQmE,EAAE,SAASA,EAAE,IAAIA,EAAE,KAAK;AAAA;AAAA,IAEpD,WAAW,CAACvC,GAAIuC,MACd,QAAQ,IAAI;AAAA,MACVJ,EAAG,kBAAkB,EAAE,UAAU,CAAC,eAAe,GAAG;AAAA,MACpDA,EAAG,kBAAkB,EAAE,UAAU,CAAC,sBAAsBI,EAAE,EAAE,EAAA,CAAG;AAAA,IAAA,CAChE;AAAA,EAAA,CACJ;AACH;AACO,SAASM,KAA+B;AAC7C,QAAMzE,IAASsD,EAAA,GACTS,IAAKC,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAACE,MAAuCnB,EAAkBhD,GAAQmE,EAAE,SAASA,EAAE,EAAE;AAAA,IAC7F,WAAW,MAAMJ,EAAG,kBAAkB,EAAE,UAAU,CAAC,eAAe,EAAA,CAAG;AAAA,EAAA,CACtE;AACH;"}
@@ -244,6 +244,44 @@ 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
+ /** One chat message for a route completion (the bridge dialect). */
248
+ export interface ModelCompletionMessage {
249
+ role: "system" | "user" | "assistant";
250
+ content: string;
251
+ }
252
+ /** A route completion request: the messages plus the agent's model options. */
253
+ export interface ModelCompletionInput {
254
+ messages: ModelCompletionMessage[];
255
+ temperature?: number;
256
+ topP?: number;
257
+ maxOutputTokens?: number;
258
+ stop?: string[];
259
+ }
260
+ /** The parts of the completion envelope a caller reads (`response=output`, no raw). */
261
+ export interface ModelCompletionResult {
262
+ provider: string;
263
+ model: string;
264
+ route: string | null;
265
+ output?: {
266
+ choices?: {
267
+ message?: {
268
+ content?: string | {
269
+ type: string;
270
+ text?: string;
271
+ }[];
272
+ };
273
+ finishReason?: string;
274
+ }[];
275
+ };
276
+ usageSummary?: {
277
+ inclusiveInputTokens?: number;
278
+ outputTokens?: number;
279
+ totalTokens?: number;
280
+ };
281
+ durationMs?: number;
282
+ }
283
+ /** `POST /model-routes/{name}/complete` — calls the route's model once (billed like any call). */
284
+ export declare function completeModelRoute(client: W6WClient, project: string, name: string, input: ModelCompletionInput): Promise<ModelCompletionResult>;
247
285
  export declare function deleteModelRoute(client: W6WClient, project: string, name: string): Promise<void>;
248
286
  export declare function listModelBudgets(client: W6WClient, project: string): Promise<ModelBudget[]>;
249
287
  export declare function createModelBudget(client: W6WClient, project: string, input: ModelBudgetInput): Promise<ModelBudget>;
@@ -251,6 +289,17 @@ export declare function updateModelBudget(client: W6WClient, project: string, id
251
289
  export declare function deleteModelBudget(client: W6WClient, project: string, id: string): Promise<void>;
252
290
  export declare function getModelBudgetUsage(client: W6WClient, project: string, id: string): Promise<ModelBudgetUsage>;
253
291
  export declare function getModelUsage(client: W6WClient, project: string, filter?: ModelUsageFilter): Promise<ModelUsageReport>;
292
+ /** What `POST /models/discover` changed in the tenant catalog — model ids per bucket. */
293
+ export interface ModelDiscoverResult {
294
+ added: string[];
295
+ updated: string[];
296
+ deprecated: string[];
297
+ }
298
+ /**
299
+ * Ask the provider behind `connection` for its model list and fold it into the tenant catalog.
300
+ * Tenant administration only: anyone else gets a 403 `forbidden`.
301
+ */
302
+ export declare function discoverModels(client: W6WClient, connection: string): Promise<ModelDiscoverResult>;
254
303
  export declare function useModelCatalogQuery(filter?: ModelCatalogFilter): import('@tanstack/react-query').UseQueryResult<NoInfer<ModelCatalogPage>, Error>;
255
304
  export declare function useAllModelCatalogQuery(filter?: Omit<ModelCatalogFilter, "cursor">): import('@tanstack/react-query').UseQueryResult<NoInfer<{
256
305
  models: Model[];
@@ -261,6 +310,7 @@ export declare function useModelRoutesQuery(projectId?: string): import('@tansta
261
310
  export declare function useModelBudgetsQuery(projectId?: string): import('@tanstack/react-query').UseQueryResult<NoInfer<ModelBudget[]>, Error>;
262
311
  export declare function useModelBudgetUsageQuery(id: string, projectId?: string): import('@tanstack/react-query').UseQueryResult<NoInfer<ModelBudgetUsage>, Error>;
263
312
  export declare function useModelUsageQuery(projectId?: string, filter?: ModelUsageFilter): import('@tanstack/react-query').UseQueryResult<NoInfer<ModelUsageReport>, Error>;
313
+ export declare function useDiscoverModelsMutation(): import('@tanstack/react-query').UseMutationResult<ModelDiscoverResult, Error, string, unknown>;
264
314
  export declare function useCreateModelRouteMutation(): import('@tanstack/react-query').UseMutationResult<ModelRoute, Error, {
265
315
  project: string;
266
316
  input: ModelRouteInput;
@@ -270,6 +320,11 @@ export declare function useUpdateModelRouteMutation(): import('@tanstack/react-q
270
320
  name: string;
271
321
  patch: ModelRoutePatch;
272
322
  }, unknown>;
323
+ export declare function useCompleteModelRouteMutation(): import('@tanstack/react-query').UseMutationResult<ModelCompletionResult, Error, {
324
+ project: string;
325
+ name: string;
326
+ input: ModelCompletionInput;
327
+ }, unknown>;
273
328
  export declare function useDeleteModelRouteMutation(): import('@tanstack/react-query').UseMutationResult<void, Error, {
274
329
  project: string;
275
330
  name: string;