@w6w/embed 0.2.26 → 0.2.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/{CreateFunctionModal-DScxp_LN.js → CreateFunctionModal-B3LpcuI9.js} +2 -2
  2. package/dist/{CreateFunctionModal-DScxp_LN.js.map → CreateFunctionModal-B3LpcuI9.js.map} +1 -1
  3. package/dist/DocumentFormModal-DieWYFi4.js +175 -0
  4. package/dist/DocumentFormModal-DieWYFi4.js.map +1 -0
  5. package/dist/{ImportSpecModal-VdYN1QeZ.js → ImportSpecModal-xwTzj4KB.js} +2 -2
  6. package/dist/{ImportSpecModal-VdYN1QeZ.js.map → ImportSpecModal-xwTzj4KB.js.map} +1 -1
  7. package/dist/ModelRoutesManager-DtByS4mE.js +422 -0
  8. package/dist/ModelRoutesManager-DtByS4mE.js.map +1 -0
  9. package/dist/{WorkflowEditor-CGKoeSG7.js → WorkflowEditor-CvWkVmFn.js} +2 -2
  10. package/dist/{WorkflowEditor-CGKoeSG7.js.map → WorkflowEditor-CvWkVmFn.js.map} +1 -1
  11. package/dist/ai-keys-D676ly41.js +53 -0
  12. package/dist/ai-keys-D676ly41.js.map +1 -0
  13. package/dist/credentials-4Nf2GfMc.js +212 -0
  14. package/dist/credentials-4Nf2GfMc.js.map +1 -0
  15. package/dist/{editor-tools-Brw0cv2F.js → editor-tools-CVYTsVFN.js} +326 -326
  16. package/dist/editor-tools-CVYTsVFN.js.map +1 -0
  17. package/dist/editor.mjs +1 -1
  18. package/dist/editors.mjs +7 -7
  19. package/dist/{endpoints-DSRo1Lc5.js → endpoints-DArAqoLT.js} +15 -15
  20. package/dist/endpoints-DArAqoLT.js.map +1 -0
  21. package/dist/forms/ModelRoutesManager.d.ts +8 -0
  22. package/dist/forms.mjs +128 -133
  23. package/dist/forms.mjs.map +1 -1
  24. package/dist/index.mjs +16 -16
  25. package/dist/lib/callable-descriptors.d.ts +1 -1
  26. package/dist/lib/document-upload.d.ts +8 -0
  27. package/dist/lists/MyAiKeys.d.ts +5 -0
  28. package/dist/lists/TagChips.d.ts +4 -0
  29. package/dist/lists.d.ts +2 -0
  30. package/dist/lists.mjs +1589 -1166
  31. package/dist/lists.mjs.map +1 -1
  32. package/dist/models-CI0vLJ6o.js +346 -0
  33. package/dist/models-CI0vLJ6o.js.map +1 -0
  34. package/dist/rail.mjs +1 -1
  35. package/dist/repos/ai-keys.d.ts +14 -0
  36. package/dist/repos/credentials.d.ts +14 -14
  37. package/dist/repos/index.d.ts +1 -0
  38. package/dist/repos/models.d.ts +53 -4
  39. package/dist/repos.mjs +177 -162
  40. package/dist/repos.mjs.map +1 -1
  41. package/dist/{spec-import-SWOonsNr.js → spec-import-0B6oUewa.js} +5 -5
  42. package/dist/{spec-import-SWOonsNr.js.map → spec-import-0B6oUewa.js.map} +1 -1
  43. package/package.json +5 -5
  44. package/src/styles.css +23 -0
  45. package/dist/DocumentFormModal-Br4s8wmi.js +0 -89
  46. package/dist/DocumentFormModal-Br4s8wmi.js.map +0 -1
  47. package/dist/ModelRoutesManager-Bv6qefnq.js +0 -345
  48. package/dist/ModelRoutesManager-Bv6qefnq.js.map +0 -1
  49. package/dist/credentials-CMR_wEvx.js +0 -196
  50. package/dist/credentials-CMR_wEvx.js.map +0 -1
  51. package/dist/editor-tools-Brw0cv2F.js.map +0 -1
  52. package/dist/endpoints-DSRo1Lc5.js.map +0 -1
  53. package/dist/models-CK1KHd39.js +0 -311
  54. package/dist/models-CK1KHd39.js.map +0 -1
@@ -0,0 +1,346 @@
1
+ import { useQuery as c, useMutation as l, useQueryClient as y } from "@tanstack/react-query";
2
+ import { path as m } from "@w6w/sdk";
3
+ import { u } from "./client-context-CX61Bgw-.js";
4
+ const b = (e = {}) => ["model-catalog", e], h = ["model-providers"], K = (e) => ["model-routes", e], Q = (e) => ["model-budgets", e], v = (e, t) => ["model-budget-usage", e, t], R = (e, t) => ["model-route-readiness", e, t], P = (e, t = {}) => ["model-usage", e, t];
5
+ async function M(e, t = {}) {
6
+ return (await e.request({
7
+ method: "GET",
8
+ path: "/models",
9
+ query: { ...t }
10
+ })).body;
11
+ }
12
+ function w(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, n = [...e.reasons ?? []];
15
+ return !s && n.length === 0 && n.push({
16
+ code: o || (t == null ? void 0 : t.supported) === !0 || e.installed ? "no_adapter" : "not_installed",
17
+ message: (t == null ? void 0 : t.reason) ?? "Not supported for this provider"
18
+ }), { supported: s, features: (t == null ? void 0 : t.features) ?? {}, reasons: n };
19
+ }
20
+ async function F(e, t = {}) {
21
+ const o = t.maxPages ?? 50, s = [];
22
+ let n;
23
+ for (let a = 0; a < o; a++) {
24
+ const r = await e(n);
25
+ if (s.push(...r.models), !r.nextCursor) return { models: s, truncated: !1 };
26
+ n = r.nextCursor;
27
+ }
28
+ return { models: s, truncated: !0 };
29
+ }
30
+ async function C(e) {
31
+ const o = (await e.request({
32
+ method: "GET",
33
+ path: "/models/providers"
34
+ })).body;
35
+ return Array.isArray(o) ? o : (o == null ? void 0 : o.providers) ?? [];
36
+ }
37
+ function z(e, t, o) {
38
+ var a, r;
39
+ const s = /* @__PURE__ */ new Map();
40
+ for (const d of t) d.designation && s.set(d.appId, d);
41
+ const n = [];
42
+ for (const d of e) {
43
+ if (d.accessScope !== void 0 && d.accessScope !== "account") continue;
44
+ const p = s.get(d.appId);
45
+ if (!p) continue;
46
+ const i = (a = p.operations) == null ? void 0 : a[o], g = { id: d.id, appId: d.appId, displayName: d.displayName };
47
+ if (o === "complete") {
48
+ const f = w(p);
49
+ f.supported || (g.disabledReason = (i == null ? void 0 : i.reason) ?? ((r = f.reasons[0]) == null ? void 0 : r.message) ?? "Not supported for this provider");
50
+ } else i != null && i.supported || (g.disabledReason = (i == null ? void 0 : i.reason) ?? "Not supported for this provider");
51
+ n.push(g);
52
+ }
53
+ return n;
54
+ }
55
+ function q(e) {
56
+ var n;
57
+ const t = (e.fallbacks ?? []).map((a) => {
58
+ const r = a;
59
+ return {
60
+ model: r.model ?? r.modelId ?? "",
61
+ connection: r.connection ?? r.connectionId ?? ""
62
+ };
63
+ }), o = e, s = o.credentialMode === "invoking_user" || ((n = o.credentialSelection) == null ? void 0 : n.mode) === "invoking_user";
64
+ return { ...e, fallbacks: t, credentialMode: s ? "invoking_user" : "account" };
65
+ }
66
+ function J(e, t) {
67
+ return e === "invoking_user" ? { model: t.model, credentialSelection: { mode: "invoking_user" } } : { model: t.model, connection: t.connection };
68
+ }
69
+ async function S(e, t, o) {
70
+ return (await e.request({
71
+ method: "GET",
72
+ path: m`/model-routes/${o}/readiness`,
73
+ query: { project: t }
74
+ })).body;
75
+ }
76
+ async function T(e, t) {
77
+ return (await e.request({
78
+ method: "GET",
79
+ path: "/model-routes",
80
+ query: { project: t }
81
+ })).body.routes.map(q);
82
+ }
83
+ async function E(e, t, o) {
84
+ const s = await e.request({
85
+ method: "POST",
86
+ path: "/model-routes",
87
+ query: { project: t },
88
+ body: o
89
+ });
90
+ return q(s.body.route);
91
+ }
92
+ async function B(e, t, o, s) {
93
+ const n = await e.request({
94
+ method: "PATCH",
95
+ path: m`/model-routes/${o}`,
96
+ query: { project: t },
97
+ body: s
98
+ });
99
+ return q(n.body.route);
100
+ }
101
+ async function k(e, t, o, s) {
102
+ return (await e.request({
103
+ method: "POST",
104
+ path: m`/model-routes/${o}/complete`,
105
+ query: { project: t, response: "output" },
106
+ body: s
107
+ })).body;
108
+ }
109
+ async function A(e, t, o) {
110
+ await e.request({
111
+ method: "DELETE",
112
+ path: m`/model-routes/${o}`,
113
+ query: { project: t }
114
+ });
115
+ }
116
+ async function _(e, t) {
117
+ return (await e.request({
118
+ method: "GET",
119
+ path: "/model-budgets",
120
+ query: { project: t }
121
+ })).body.budgets;
122
+ }
123
+ async function x(e, t, o) {
124
+ return (await e.request({
125
+ method: "POST",
126
+ path: "/model-budgets",
127
+ query: { project: t },
128
+ body: o
129
+ })).body;
130
+ }
131
+ async function G(e, t, o, s) {
132
+ return (await e.request({
133
+ method: "PATCH",
134
+ path: m`/model-budgets/${o}`,
135
+ query: { project: t },
136
+ body: s
137
+ })).body;
138
+ }
139
+ async function U(e, t, o) {
140
+ await e.request({
141
+ method: "DELETE",
142
+ path: m`/model-budgets/${o}`,
143
+ query: { project: t }
144
+ });
145
+ }
146
+ async function $(e, t, o) {
147
+ return (await e.request({
148
+ method: "GET",
149
+ path: m`/model-budgets/${o}/usage`,
150
+ query: { project: t }
151
+ })).body;
152
+ }
153
+ async function D(e, t, o = {}) {
154
+ return (await e.request({
155
+ method: "GET",
156
+ path: "/model-usage",
157
+ query: { project: t, ...o }
158
+ })).body;
159
+ }
160
+ async function N(e, t) {
161
+ return (await e.request({
162
+ method: "POST",
163
+ path: "/models/discover",
164
+ body: { connection: t }
165
+ })).body;
166
+ }
167
+ function V(e = {}) {
168
+ const t = u();
169
+ return c({
170
+ queryKey: b(e),
171
+ queryFn: () => M(t, e)
172
+ });
173
+ }
174
+ function W(e = {}) {
175
+ const t = u();
176
+ return c({
177
+ queryKey: ["model-catalog-all", e],
178
+ queryFn: () => F((o) => M(t, { ...e, cursor: o }))
179
+ });
180
+ }
181
+ function X() {
182
+ const e = u();
183
+ return c({ queryKey: h, queryFn: () => C(e) });
184
+ }
185
+ function Y(e) {
186
+ const t = u();
187
+ return c({
188
+ queryKey: K(e),
189
+ enabled: e != null,
190
+ queryFn: () => T(t, e)
191
+ });
192
+ }
193
+ function Z(e, t, o = !0) {
194
+ const s = u();
195
+ return c({
196
+ queryKey: R(e, t),
197
+ enabled: o && e != null,
198
+ retry: !1,
199
+ queryFn: () => S(s, e, t)
200
+ });
201
+ }
202
+ function j(e) {
203
+ const t = u();
204
+ return c({
205
+ queryKey: Q(e),
206
+ enabled: e != null,
207
+ queryFn: () => _(t, e)
208
+ });
209
+ }
210
+ function I(e, t) {
211
+ const o = u();
212
+ return c({
213
+ queryKey: v(e, t),
214
+ enabled: t != null,
215
+ queryFn: () => $(o, t, e)
216
+ });
217
+ }
218
+ function ee(e, t = {}) {
219
+ const o = u();
220
+ return c({
221
+ queryKey: P(e, t),
222
+ enabled: e != null,
223
+ queryFn: () => D(o, e, t)
224
+ });
225
+ }
226
+ function te() {
227
+ const e = u(), t = y();
228
+ return l({
229
+ mutationFn: (o) => N(e, o),
230
+ onSuccess: async () => {
231
+ await Promise.all([
232
+ t.invalidateQueries({ queryKey: ["model-catalog"] }),
233
+ t.invalidateQueries({ queryKey: ["model-catalog-all"] })
234
+ ]);
235
+ }
236
+ });
237
+ }
238
+ function oe() {
239
+ const e = u(), t = y();
240
+ return l({
241
+ mutationFn: (o) => E(e, o.project, o.input),
242
+ // The agent editor lists routes under its own key; a new route belongs in both lists.
243
+ onSuccess: () => Promise.all([
244
+ t.invalidateQueries({ queryKey: ["model-routes"] }),
245
+ t.invalidateQueries({ queryKey: ["agents", "model-routes"] }),
246
+ t.invalidateQueries({ queryKey: ["model-route-readiness"] })
247
+ ])
248
+ });
249
+ }
250
+ function se() {
251
+ const e = u(), t = y();
252
+ return l({
253
+ mutationFn: (o) => B(e, o.project, o.name, o.patch),
254
+ onSuccess: () => Promise.all([
255
+ t.invalidateQueries({ queryKey: ["model-routes"] }),
256
+ t.invalidateQueries({ queryKey: ["model-route-readiness"] })
257
+ ])
258
+ });
259
+ }
260
+ function ne() {
261
+ const e = u();
262
+ return l({
263
+ mutationFn: (t) => k(e, t.project, t.name, t.input)
264
+ });
265
+ }
266
+ function ue() {
267
+ const e = u(), t = y();
268
+ return l({
269
+ mutationFn: (o) => A(e, o.project, o.name),
270
+ onSuccess: () => Promise.all([
271
+ t.invalidateQueries({ queryKey: ["model-routes"] }),
272
+ t.invalidateQueries({ queryKey: ["model-route-readiness"] })
273
+ ])
274
+ });
275
+ }
276
+ function re() {
277
+ const e = u(), t = y();
278
+ return l({
279
+ mutationFn: (o) => x(e, o.project, o.input),
280
+ onSuccess: () => t.invalidateQueries({ queryKey: ["model-budgets"] })
281
+ });
282
+ }
283
+ function ae() {
284
+ const e = u(), t = y();
285
+ return l({
286
+ mutationFn: (o) => G(e, o.project, o.id, o.patch),
287
+ // The row meter reads its limit from the per-budget usage query, so refresh it too.
288
+ onSuccess: (o, s) => Promise.all([
289
+ t.invalidateQueries({ queryKey: ["model-budgets"] }),
290
+ t.invalidateQueries({ queryKey: ["model-budget-usage", s.id] })
291
+ ])
292
+ });
293
+ }
294
+ function de() {
295
+ const e = u(), t = y();
296
+ return l({
297
+ mutationFn: (o) => U(e, o.project, o.id),
298
+ onSuccess: () => t.invalidateQueries({ queryKey: ["model-budgets"] })
299
+ });
300
+ }
301
+ export {
302
+ b as A,
303
+ h as B,
304
+ R as C,
305
+ K as D,
306
+ P as E,
307
+ q as F,
308
+ G,
309
+ B as H,
310
+ ne as I,
311
+ re as J,
312
+ de as K,
313
+ te as L,
314
+ I as M,
315
+ j as N,
316
+ V as O,
317
+ ee as P,
318
+ ae as Q,
319
+ ue as a,
320
+ W as b,
321
+ X as c,
322
+ z as d,
323
+ oe as e,
324
+ se as f,
325
+ Z as g,
326
+ k as h,
327
+ w as i,
328
+ x as j,
329
+ E as k,
330
+ T as l,
331
+ U as m,
332
+ A as n,
333
+ N as o,
334
+ $ as p,
335
+ S as q,
336
+ J as r,
337
+ D as s,
338
+ _ as t,
339
+ Y as u,
340
+ M as v,
341
+ C as w,
342
+ F as x,
343
+ v as y,
344
+ Q as z
345
+ };
346
+ //# sourceMappingURL=models-CI0vLJ6o.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models-CI0vLJ6o.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}\n/** The editor's shape of one route target; `connection` is `\"\"` for an invoking-user route. */\nexport interface ModelFallback {\n model: string;\n connection: string;\n}\n/** Which credential a route uses: a fixed account connection, or each caller's own key. */\nexport type ModelRouteCredentialMode = \"account\" | \"invoking_user\";\n/** The wire union for \"each caller's own key\" (`credentialSelection`). */\nexport interface ModelCredentialSelection {\n mode: \"invoking_user\";\n}\n/** One target on the wire: `connection` XOR `credentialSelection`, never both. */\nexport interface ModelRouteTarget {\n model: string;\n connection?: string;\n credentialSelection?: ModelCredentialSelection;\n}\nexport interface ModelRoute {\n id: string;\n name: string;\n project: string;\n modelId: string;\n /** `null` on an invoking-user route (no fixed connection). */\n connectionId: string | null;\n /** Absent from an older server; `normaliseRoute` always fills it. */\n credentialMode: ModelRouteCredentialMode;\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 credentialSelection?: ModelCredentialSelection;\n fallbacks?: ModelRouteTarget[];\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 modelRouteReadinessKey = (projectId: string | undefined, name: string) =>\n [\"model-route-readiness\", projectId, name] 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 * Only ACCOUNT connections are offered (`accessScope` absent or `\"account\"`): a route's fixed\n * connection is shared, so a personal key never appears here. An unknown scope is excluded.\n */\nexport function connectionChoices<\n C extends { id: string; appId: string; displayName: string; accessScope?: string },\n>(connections: C[], providers: ModelProviderRow[], operation: ModelOperation): 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 if (c.accessScope !== undefined && c.accessScope !== \"account\") continue;\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/**\n * The server answers fallbacks as `{modelId, connectionId}` (`connectionId` is `null` on an\n * invoking-user route); the editor works in `{model, connection}` with `null` as `\"\"`. A route is\n * invoking-user iff it says so as `credentialMode` or `credentialSelection.mode`; anything else\n * (including an older server that sends neither) is an account route.\n */\nexport function normaliseRoute(r: ModelRoute): ModelRoute {\n const fallbacks = (r.fallbacks ?? []).map((f) => {\n const x = f as ModelFallback & { modelId?: string; connectionId?: string | null };\n return {\n model: x.model ?? x.modelId ?? \"\",\n connection: x.connection ?? x.connectionId ?? \"\",\n };\n });\n const x = r as ModelRoute & { credentialSelection?: { mode?: string } };\n const invoking =\n x.credentialMode === \"invoking_user\" || x.credentialSelection?.mode === \"invoking_user\";\n return { ...r, fallbacks, credentialMode: invoking ? \"invoking_user\" : \"account\" };\n}\n\n/** One write target for `mode`: the connection id (account) or the invoking-user selection. */\nexport function routeTarget(mode: ModelRouteCredentialMode, t: ModelFallback): ModelRouteTarget {\n return mode === \"invoking_user\"\n ? { model: t.model, credentialSelection: { mode: \"invoking_user\" } }\n : { model: t.model, connection: t.connection };\n}\n\n/** Why a route is not ready for the caller, as the server reports it. */\nexport interface ModelRouteReadinessIssue {\n code: string;\n severity: \"error\" | \"warning\";\n field?: string;\n message: string;\n}\n/** `GET /model-routes/:name/readiness` — per caller, never persisted. */\nexport interface ModelRouteReadiness {\n ready: boolean;\n credentialMode: ModelRouteCredentialMode;\n issues: ModelRouteReadinessIssue[];\n setup?: { action: \"connect_personal_key\"; providerAppId: string; modelId: string };\n}\n\nexport async function getModelRouteReadiness(\n client: W6WClient,\n project: string,\n name: string,\n): Promise<ModelRouteReadiness> {\n const res = await client.request<ModelRouteReadiness>({\n method: \"GET\",\n path: path`/model-routes/${name}/readiness`,\n query: { project },\n });\n return res.body;\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}\n/** Per-caller readiness of one route; only invoking-user routes ask (`enabled`). */\nexport function useModelRouteReadinessQuery(\n projectId: string | undefined,\n name: string,\n enabled = true,\n) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: modelRouteReadinessKey(projectId, name),\n enabled: enabled && projectId != null,\n retry: false,\n queryFn: () => getModelRouteReadiness(client, projectId as string, name),\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 qc.invalidateQueries({ queryKey: [\"model-route-readiness\"] }),\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: () =>\n Promise.all([\n qc.invalidateQueries({ queryKey: [\"model-routes\"] }),\n qc.invalidateQueries({ queryKey: [\"model-route-readiness\"] }),\n ]),\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: () =>\n Promise.all([\n qc.invalidateQueries({ queryKey: [\"model-routes\"] }),\n qc.invalidateQueries({ queryKey: [\"model-route-readiness\"] }),\n ]),\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","modelRouteReadinessKey","name","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","invoking","routeTarget","mode","getModelRouteReadiness","project","path","listModelRoutes","createModelRoute","input","res","updateModelRoute","patch","completeModelRoute","deleteModelRoute","listModelBudgets","createModelBudget","updateModelBudget","deleteModelBudget","getModelBudgetUsage","getModelUsage","discoverModels","connection","useModelCatalogQuery","useEmbedClient","useQuery","useAllModelCatalogQuery","useModelProvidersQuery","useModelRoutesQuery","useModelRouteReadinessQuery","enabled","useModelBudgetsQuery","useModelBudgetUsageQuery","useModelUsageQuery","useDiscoverModelsMutation","qc","useQueryClient","useMutation","useCreateModelRouteMutation","v","useUpdateModelRouteMutation","useCompleteModelRouteMutation","useDeleteModelRouteMutation","useCreateModelBudgetMutation","useUpdateModelBudgetMutation","useDeleteModelBudgetMutation"],"mappings":";;;AA6LO,MAAMA,IAA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AA,GACTW,IAAKC,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAACE,MAAuCrB,EAAkBnD,GAAQwE,EAAE,SAASA,EAAE,EAAE;AAAA,IAC7F,WAAW,MAAMJ,EAAG,kBAAkB,EAAE,UAAU,CAAC,eAAe,EAAA,CAAG;AAAA,EAAA,CACtE;AACH;"}
package/dist/rail.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as r } from "react/jsx-runtime";
3
3
  import { useMemo as u } from "react";
4
- import { W as d, R as p, P as m, u as f, a as v, e as b, b as h } from "./editor-tools-Brw0cv2F.js";
4
+ import { W as d, R as p, P as m, u as f, a as v, e as b, b as h } from "./editor-tools-CVYTsVFN.js";
5
5
  import { r as P, a as j } from "./project-context-Tvp-La7A.js";
6
6
  const R = () => {
7
7
  };
@@ -0,0 +1,14 @@
1
+ import { W6WClient } from '@w6w/sdk';
2
+ import { AiKeyDefault } from '@w6w/sdk/console';
3
+ export type { AiKeyDefault } from '@w6w/sdk/console';
4
+ export declare const meCapabilitiesKey: readonly ["me-capabilities"];
5
+ export declare const aiKeyDefaultsKey: readonly ["ai-key-defaults"];
6
+ export declare function fetchUserScopedCredentialsEnabled(client: W6WClient): Promise<boolean>;
7
+ export declare function useUserScopedCredentialsEnabled(): boolean;
8
+ export declare function listAiKeyDefaults(client: W6WClient): Promise<AiKeyDefault[]>;
9
+ export declare function useAiKeyDefaultsQuery(enabled?: boolean): import('@tanstack/react-query').UseQueryResult<NoInfer<AiKeyDefault[]>, Error>;
10
+ export declare function useSetAiKeyDefaultMutation(): import('@tanstack/react-query').UseMutationResult<AiKeyDefault, Error, {
11
+ providerAppId: string;
12
+ connectionId: string;
13
+ }, unknown>;
14
+ export declare function useClearAiKeyDefaultMutation(): import('@tanstack/react-query').UseMutationResult<void, Error, string, unknown>;
@@ -11,15 +11,20 @@ export declare const credentialDependentsKey: (id: string) => readonly ["credent
11
11
  * reports, so the credential keys AND every cached connection (single and per-app) go stale.
12
12
  */
13
13
  export declare function invalidateAfterCredentialWrite(qc: QueryClient, id: string): void;
14
+ /** Ownership text (R-C11). An absent scope is an older server, so the account's. */
15
+ export declare const accessScopeLabel: (scope: "account" | "user" | undefined) => string;
14
16
  export declare function listCredentials(client: W6WClient, filter?: CredentialListFilter): Promise<CredentialSummary[]>;
15
17
  /** The credential types the server can store and the fields each collects, in server order. */
16
18
  export declare function listCredentialTypes(client: W6WClient): Promise<CredentialTypeDescriptor[]>;
17
19
  export declare function getCredential(client: W6WClient, id: string): Promise<CredentialSummary>;
18
- export declare function createCredential(client: W6WClient, body: {
20
+ /** `accessScope` is present only for "Only me"; an account credential is the omitted-key body. */
21
+ export type CredentialCreateBody = {
19
22
  name: string;
20
23
  contract: string;
21
24
  source: Record<string, unknown>;
22
- }): Promise<CredentialSummary>;
25
+ accessScope?: "user";
26
+ };
27
+ export declare function createCredential(client: W6WClient, body: CredentialCreateBody): Promise<CredentialSummary>;
23
28
  /** Rename. */
24
29
  export declare function updateCredential(client: W6WClient, id: string, body: {
25
30
  name: string;
@@ -42,9 +47,12 @@ export type DeleteCredentialResult = {
42
47
  * Wire (RECONCILE R-11): `{ error: { code, message, dependents: { connections } } }`.
43
48
  */
44
49
  export declare function deleteCredential(client: W6WClient, id: string): Promise<DeleteCredentialResult>;
50
+ /** The fixed sentence for one of the seven ownership codes, or `undefined` for any other error. */
51
+ export declare function ownershipErrorText(e: unknown): string | undefined;
45
52
  /**
46
- * Fixed, secret-free text for a failed credential write, chosen by the server's status / error
47
- * code. The server's own message is never shown: a value the user typed could be echoed in it.
53
+ * Fixed, secret-free text for a failed credential write, chosen by the server's error code first
54
+ * (the seven ownership codes), then by status. The server's own message is never shown: a value
55
+ * the user typed could be echoed in it.
48
56
  */
49
57
  export declare function credentialWriteErrorText(e: unknown, verb: "create" | "rotate"): string;
50
58
  export declare function useCredentialsQuery(filter?: CredentialListFilter): import('@tanstack/react-query').UseQueryResult<NoInfer<CredentialSummary[]>, Error>;
@@ -56,11 +64,7 @@ export declare function useCredentialsQuery(filter?: CredentialListFilter): impo
56
64
  export declare function useCredentialTypesQuery(): import('@tanstack/react-query').UseQueryResult<NoInfer<CredentialTypeDescriptor[]>, Error>;
57
65
  export declare function useCredentialQuery(id: string): import('@tanstack/react-query').UseQueryResult<NoInfer<CredentialSummary>, Error>;
58
66
  export declare function useCredentialDependentsQuery(id: string, enabled?: boolean): import('@tanstack/react-query').UseQueryResult<NoInfer<CredentialDependents>, Error>;
59
- export declare function useCreateCredentialMutation(): import('@tanstack/react-query').UseMutationResult<CredentialSummary, Error, {
60
- name: string;
61
- contract: string;
62
- source: Record<string, unknown>;
63
- }, unknown>;
67
+ export declare function useCreateCredentialMutation(): import('@tanstack/react-query').UseMutationResult<CredentialSummary, Error, CredentialCreateBody, unknown>;
64
68
  /** Rename touches only the credential keys: no connection's state changes. */
65
69
  export declare function useUpdateCredentialMutation(id: string): import('@tanstack/react-query').UseMutationResult<CredentialSummary, Error, {
66
70
  name: string;
@@ -79,11 +83,7 @@ export declare function useDeleteCredentialMutation(): import('@tanstack/react-q
79
83
  */
80
84
  export declare function credentialUiMethods(client: W6WClient): {
81
85
  listCredentials: (filter?: CredentialListFilter) => Promise<CredentialSummary[]>;
82
- createCredential: (body: {
83
- name: string;
84
- contract: string;
85
- source: Record<string, unknown>;
86
- }) => Promise<CredentialSummary>;
86
+ createCredential: (body: CredentialCreateBody) => Promise<CredentialSummary>;
87
87
  getCredential: (id: string) => Promise<CredentialSummary>;
88
88
  rotateCredential: (id: string, body: {
89
89
  source: Record<string, unknown>;
@@ -29,6 +29,7 @@ export * from './spec-export.ts';
29
29
  export * from './apps.ts';
30
30
  export * from './connections.ts';
31
31
  export * from './credentials.ts';
32
+ export * from './ai-keys.ts';
32
33
  export * from './saved-tests.ts';
33
34
  export * from './reliability.ts';
34
35
  export * from './dashboard.ts';
@@ -32,16 +32,32 @@ export interface Model {
32
32
  createdAt: string;
33
33
  updatedAt: string;
34
34
  }
35
+ /** The editor's shape of one route target; `connection` is `""` for an invoking-user route. */
35
36
  export interface ModelFallback {
36
37
  model: string;
37
38
  connection: string;
38
39
  }
40
+ /** Which credential a route uses: a fixed account connection, or each caller's own key. */
41
+ export type ModelRouteCredentialMode = "account" | "invoking_user";
42
+ /** The wire union for "each caller's own key" (`credentialSelection`). */
43
+ export interface ModelCredentialSelection {
44
+ mode: "invoking_user";
45
+ }
46
+ /** One target on the wire: `connection` XOR `credentialSelection`, never both. */
47
+ export interface ModelRouteTarget {
48
+ model: string;
49
+ connection?: string;
50
+ credentialSelection?: ModelCredentialSelection;
51
+ }
39
52
  export interface ModelRoute {
40
53
  id: string;
41
54
  name: string;
42
55
  project: string;
43
56
  modelId: string;
44
- connectionId: string;
57
+ /** `null` on an invoking-user route (no fixed connection). */
58
+ connectionId: string | null;
59
+ /** Absent from an older server; `normaliseRoute` always fills it. */
60
+ credentialMode: ModelRouteCredentialMode;
45
61
  fallbacks: ModelFallback[];
46
62
  defaults: Record<string, unknown>;
47
63
  status: "active" | "broken";
@@ -51,8 +67,9 @@ export interface ModelRoute {
51
67
  export interface ModelRouteInput {
52
68
  name: string;
53
69
  model: string;
54
- connection: string;
55
- fallbacks?: ModelFallback[];
70
+ connection?: string;
71
+ credentialSelection?: ModelCredentialSelection;
72
+ fallbacks?: ModelRouteTarget[];
56
73
  defaults?: Record<string, unknown>;
57
74
  }
58
75
  export type ModelRoutePatch = Partial<Omit<ModelRouteInput, "name">>;
@@ -164,6 +181,7 @@ export declare const modelProvidersKey: readonly ["model-providers"];
164
181
  export declare const modelRoutesKey: (projectId?: string) => readonly ["model-routes", string | undefined];
165
182
  export declare const modelBudgetsKey: (projectId?: string) => readonly ["model-budgets", string | undefined];
166
183
  export declare const modelBudgetUsageKey: (id: string, projectId?: string) => readonly ["model-budget-usage", string, string | undefined];
184
+ export declare const modelRouteReadinessKey: (projectId: string | undefined, name: string) => readonly ["model-route-readiness", string | undefined, string];
167
185
  export declare const modelUsageKey: (projectId?: string, filter?: ModelUsageFilter) => readonly ["model-usage", string | undefined, ModelUsageFilter];
168
186
  export declare function listModelCatalog(client: W6WClient, filter?: ModelCatalogFilter): Promise<ModelCatalogPage>;
169
187
  /** One row of `GET /models/providers` — the descriptor the model pickers are driven by. */
@@ -233,14 +251,43 @@ export declare function listModelProviders(client: W6WClient): Promise<ModelProv
233
251
  * a connection whose app has no designated provider row never appears (an `ai`-category app is
234
252
  * not a provider); a designated row whose `discover` is unsupported appears disabled with the
235
253
  * descriptor's reason; for `complete` the shared `completeSupport` policy decides (unsupported => disabled, never selectable).
254
+ * Only ACCOUNT connections are offered (`accessScope` absent or `"account"`): a route's fixed
255
+ * connection is shared, so a personal key never appears here. An unknown scope is excluded.
236
256
  */
237
257
  export declare function connectionChoices<C extends {
238
258
  id: string;
239
259
  appId: string;
240
260
  displayName: string;
261
+ accessScope?: string;
241
262
  }>(connections: C[], providers: ModelProviderRow[], operation: ModelOperation): ConnectionChoice[];
242
- /** The server answers fallbacks as `{modelId, connectionId}`; the editor works in `{model, connection}`. */
263
+ /**
264
+ * The server answers fallbacks as `{modelId, connectionId}` (`connectionId` is `null` on an
265
+ * invoking-user route); the editor works in `{model, connection}` with `null` as `""`. A route is
266
+ * invoking-user iff it says so as `credentialMode` or `credentialSelection.mode`; anything else
267
+ * (including an older server that sends neither) is an account route.
268
+ */
243
269
  export declare function normaliseRoute(r: ModelRoute): ModelRoute;
270
+ /** One write target for `mode`: the connection id (account) or the invoking-user selection. */
271
+ export declare function routeTarget(mode: ModelRouteCredentialMode, t: ModelFallback): ModelRouteTarget;
272
+ /** Why a route is not ready for the caller, as the server reports it. */
273
+ export interface ModelRouteReadinessIssue {
274
+ code: string;
275
+ severity: "error" | "warning";
276
+ field?: string;
277
+ message: string;
278
+ }
279
+ /** `GET /model-routes/:name/readiness` — per caller, never persisted. */
280
+ export interface ModelRouteReadiness {
281
+ ready: boolean;
282
+ credentialMode: ModelRouteCredentialMode;
283
+ issues: ModelRouteReadinessIssue[];
284
+ setup?: {
285
+ action: "connect_personal_key";
286
+ providerAppId: string;
287
+ modelId: string;
288
+ };
289
+ }
290
+ export declare function getModelRouteReadiness(client: W6WClient, project: string, name: string): Promise<ModelRouteReadiness>;
244
291
  export declare function listModelRoutes(client: W6WClient, project: string): Promise<ModelRoute[]>;
245
292
  export declare function createModelRoute(client: W6WClient, project: string, input: ModelRouteInput): Promise<ModelRoute>;
246
293
  export declare function updateModelRoute(client: W6WClient, project: string, name: string, patch: ModelRoutePatch): Promise<ModelRoute>;
@@ -337,6 +384,8 @@ export declare function useAllModelCatalogQuery(filter?: Omit<ModelCatalogFilter
337
384
  }>, Error>;
338
385
  export declare function useModelProvidersQuery(): import('@tanstack/react-query').UseQueryResult<NoInfer<ModelProviderRow[]>, Error>;
339
386
  export declare function useModelRoutesQuery(projectId?: string): import('@tanstack/react-query').UseQueryResult<NoInfer<ModelRoute[]>, Error>;
387
+ /** Per-caller readiness of one route; only invoking-user routes ask (`enabled`). */
388
+ export declare function useModelRouteReadinessQuery(projectId: string | undefined, name: string, enabled?: boolean): import('@tanstack/react-query').UseQueryResult<NoInfer<ModelRouteReadiness>, Error>;
340
389
  export declare function useModelBudgetsQuery(projectId?: string): import('@tanstack/react-query').UseQueryResult<NoInfer<ModelBudget[]>, Error>;
341
390
  export declare function useModelBudgetUsageQuery(id: string, projectId?: string): import('@tanstack/react-query').UseQueryResult<NoInfer<ModelBudgetUsage>, Error>;
342
391
  export declare function useModelUsageQuery(projectId?: string, filter?: ModelUsageFilter): import('@tanstack/react-query').UseQueryResult<NoInfer<ModelUsageReport>, Error>;