@ultrst-armada/kloks 2.2.4 → 2.2.6

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 (80) hide show
  1. package/.krusbl-release-attestation.json +8 -0
  2. package/package.json +7 -2
  3. package/packages/aiko/dist/index.d.ts +37 -1
  4. package/packages/aiko/dist/index.js +101 -3
  5. package/packages/backend/dist/ai-inference/index.js +1 -1
  6. package/packages/backend/dist/ai-inference/inferenceExecutor.test.d.ts +1 -0
  7. package/packages/backend/dist/ai-models/index.js +2 -2
  8. package/packages/backend/dist/ai-routing/index.js +3 -3
  9. package/packages/backend/dist/auth/OidcBff.d.ts +50 -0
  10. package/packages/backend/dist/auth/OidcBff.test.d.ts +1 -0
  11. package/packages/backend/dist/auth/OidcBffEnv.d.ts +23 -0
  12. package/packages/backend/dist/auth/index.d.ts +2 -0
  13. package/packages/backend/dist/auth/index.js +6 -1
  14. package/packages/backend/dist/{chunk-F6CHRGJ6.js → chunk-2DVRZKOK.js} +2 -2
  15. package/packages/backend/dist/{chunk-YZNQA3FU.js → chunk-3V5B2BOP.js} +1 -1
  16. package/packages/backend/dist/{chunk-UVNKDM7N.js → chunk-4BCTI7BL.js} +1 -1
  17. package/packages/backend/dist/{chunk-WPN3SMIT.js → chunk-4LRMJIJ4.js} +1 -1
  18. package/packages/backend/dist/{chunk-DMBDZHJF.js → chunk-4NTZRTRY.js} +1 -1
  19. package/packages/backend/dist/{chunk-X57LLCAQ.js → chunk-5S5CDQXD.js} +5 -1
  20. package/packages/backend/dist/{chunk-PECE5QKV.js → chunk-5SKQBVYU.js} +2 -2
  21. package/packages/backend/dist/{chunk-NIP22V2G.js → chunk-E2I7D52V.js} +22 -1
  22. package/packages/backend/dist/chunk-FFYTCLFC.js +93 -0
  23. package/packages/backend/dist/{chunk-SR3DALCH.js → chunk-FGZA6PDX.js} +4 -4
  24. package/packages/backend/dist/{chunk-7RSTNQT2.js → chunk-H47NEPYG.js} +7 -7
  25. package/packages/backend/dist/{chunk-5E6JRFUH.js → chunk-HX5TN27Y.js} +294 -4
  26. package/packages/backend/dist/{chunk-PT6J6UEU.js → chunk-LMAU62ZG.js} +4 -4
  27. package/packages/backend/dist/{chunk-FKK23J2A.js → chunk-LN274IE5.js} +63 -12
  28. package/packages/backend/dist/{chunk-GCTQY24J.js → chunk-MK4ZRBFI.js} +7 -6
  29. package/packages/backend/dist/{chunk-K5LKAEBJ.js → chunk-OJCSPAFE.js} +1 -1
  30. package/packages/backend/dist/chunk-SEKPSCWP.js +350 -0
  31. package/packages/backend/dist/{chunk-N7OUR5R5.js → chunk-YDGW7PXM.js} +1 -1
  32. package/packages/backend/dist/{chunk-KQ6IWV3F.js → chunk-YTJTF7LS.js} +2 -2
  33. package/packages/backend/dist/client/index.js +2 -2
  34. package/packages/backend/dist/{client-5SGUJCV5.js → client-S4R4MZ6K.js} +2 -2
  35. package/packages/backend/dist/connectivity/FrontendSession.d.ts +1 -0
  36. package/packages/backend/dist/connectivity/FrontendSession.dispose.test.d.ts +1 -0
  37. package/packages/backend/dist/connectivity/HTTPTransport.d.ts +1 -0
  38. package/packages/backend/dist/connectivity/HTTPTransport.operation.test.d.ts +1 -0
  39. package/packages/backend/dist/connectivity/InProcessExecutor.session.test.d.ts +1 -0
  40. package/packages/backend/dist/connectivity/RemoteExecutor.error.test.d.ts +1 -0
  41. package/packages/backend/dist/connectivity/facadeInvocation.adversarial_replay.test.d.ts +1 -0
  42. package/packages/backend/dist/connectivity/facadeInvocation.d.ts +101 -0
  43. package/packages/backend/dist/connectivity/facadeInvocation.oneUseLuthContract.test.d.ts +1 -0
  44. package/packages/backend/dist/connectivity/facadeInvocation.test.d.ts +1 -0
  45. package/packages/backend/dist/connectivity/index.d.ts +2 -0
  46. package/packages/backend/dist/connectivity/index.js +8 -4
  47. package/packages/backend/dist/index.js +26 -14
  48. package/packages/backend/dist/krnl-ai-services.js +6 -6
  49. package/packages/backend/dist/krnl-services.js +2 -2
  50. package/packages/backend/dist/node.js +66 -57
  51. package/packages/backend/dist/provider-services/compute-operations.d.ts +24 -0
  52. package/packages/backend/dist/provider-services/compute-operations.test.d.ts +1 -0
  53. package/packages/backend/dist/provider-services/google/cloud-run.js +1 -1
  54. package/packages/backend/dist/provider-services/google/cloud-shell.js +1 -1
  55. package/packages/backend/dist/provider-services/google/cloud-storage.js +1 -1
  56. package/packages/backend/dist/provider-services/google/drive.js +1 -1
  57. package/packages/backend/dist/provider-services/google/gemini.js +3 -3
  58. package/packages/backend/dist/provider-services/google/index.js +3 -3
  59. package/packages/backend/dist/provider-services/google/vertex-ai.js +1 -1
  60. package/packages/backend/dist/provider-services/index.d.ts +1 -0
  61. package/packages/backend/dist/provider-services/index.js +19 -11
  62. package/packages/backend/dist/provider-services/node.js +11 -11
  63. package/packages/backend/dist/provider-services/storage/dropbox.js +4 -4
  64. package/packages/backend/dist/provider-services/storage/github.js +4 -4
  65. package/packages/backend/dist/provider-services/storage/node.js +7 -7
  66. package/packages/backend/dist/provider-services/storage.js +6 -6
  67. package/packages/backend/package.json +1 -1
  68. package/packages/client/dist/auth.d.ts +1 -1
  69. package/packages/client/dist/auth.js +5 -1
  70. package/packages/client/dist/{chunk-ATLIA7AJ.js → chunk-WYC7RG32.js} +5 -1
  71. package/packages/client/dist/index.d.ts +1 -1
  72. package/packages/client/dist/index.js +5 -1
  73. package/packages/client/package.json +1 -1
  74. package/packages/state-graph/dist/browser.js +24 -24
  75. package/packages/state-graph/dist/index.js +24 -24
  76. package/packages/backend/dist/chunk-5SXOQAAX.js +0 -41
  77. package/packages/backend/dist/chunk-JQKKMUCT.js +0 -0
  78. package/packages/backend/dist/{chunk-R4B3KPHY.js → chunk-5CZUAEAD.js} +5 -5
  79. package/packages/backend/dist/{chunk-LMWXONZG.js → chunk-EREYT3WJ.js} +3 -3
  80. package/packages/state-graph/dist/{chunk-UKTICGGV.js → chunk-YUJC367F.js} +3 -3
@@ -0,0 +1,8 @@
1
+ {
2
+ "schema": 1,
3
+ "packageName": "@ultrst-armada/kloks",
4
+ "version": "2.2.6",
5
+ "sourceCommit": "e9312af60cc6b89368a867625ab0516fd43411bd",
6
+ "releaseWorkflow": "npm Release",
7
+ "workflowRunId": "44681800978"
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultrst-armada/kloks",
3
- "version": "2.2.4",
3
+ "version": "2.2.6",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -340,6 +340,11 @@
340
340
  "types": "./packages/fod/dist/quickjs-node.d.ts",
341
341
  "import": "./packages/fod/dist/quickjs-node.js",
342
342
  "default": "./packages/fod/dist/quickjs-node.js"
343
+ },
344
+ "./backend/auth": {
345
+ "types": "./packages/backend/dist/auth/index.d.ts",
346
+ "import": "./packages/backend/dist/auth/index.js",
347
+ "default": "./packages/backend/dist/auth/index.js"
343
348
  }
344
349
  },
345
350
  "scripts": {
@@ -356,7 +361,7 @@
356
361
  "verify:package-exports": "node scripts/verify-package-exports.mjs"
357
362
  },
358
363
  "dependencies": {
359
- "@dinilmusick/gutts": "2.2.2",
364
+ "@dinilmusick/gutts": "2.2.3",
360
365
  "@jitl/quickjs-wasmfile-release-sync": "0.32.0",
361
366
  "@webcontainer/api": "^1.6.4",
362
367
  "quickjs-emscripten-core": "0.32.0",
@@ -159,4 +159,40 @@ declare function createCentralAikoIntelligenceResolver(options: CentralAikoIntel
159
159
  resolve(specId?: string): Promise<CentralAikoIntelligenceSpec>;
160
160
  };
161
161
 
162
- export { type AikoAgentDefinition, type AikoCapability, type AikoIntelligenceResolver, type AikoIntelligenceSpec, type AikoKey, type AikoKeyRuntime, type AikoNaturalLanguageCandidate, type AikoNaturalLanguageResult, type AikoNaturalLanguageTarget, AikoRuntime, type AikoRuntimeOptions, type AikoSourceKind, type AikoTool, type CentralAikoIntelligenceOptions, type CentralAikoIntelligenceSpec, createCentralAikoIntelligenceResolver };
162
+ type AikoDirectoryAgentKind = 'app' | 'endpoint' | 'workflow';
163
+ interface AikoDirectoryCaller {
164
+ readonly userId: string;
165
+ readonly appId: string;
166
+ readonly workspaceId: string;
167
+ }
168
+ interface AikoDirectoryEntry {
169
+ /** Immutable ID from the canonical Aiko runtime; aliases never replace it. */
170
+ readonly id: string;
171
+ readonly kind: AikoDirectoryAgentKind;
172
+ readonly sourceId: string;
173
+ /** Workspace alias when unique, otherwise the canonical name. */
174
+ readonly name: string;
175
+ readonly canonicalName: string;
176
+ readonly description: string;
177
+ readonly alias?: string;
178
+ }
179
+ interface AikoAgentDirectoryOptions {
180
+ /** Resolve the current caller from the server-side Luth session; never accept request-body identity. */
181
+ readonly resolveCaller: () => Promise<AikoDirectoryCaller | null> | AikoDirectoryCaller | null;
182
+ /** The canonical request-time Aiko registry projection. No directory catalog is persisted. */
183
+ readonly listAgents: () => Promise<readonly AikoAgentDefinition[]> | readonly AikoAgentDefinition[];
184
+ /** Must authorize the current caller against each current agent on every list request. */
185
+ readonly authorize: (caller: AikoDirectoryCaller, agent: AikoAgentDefinition) => Promise<boolean> | boolean;
186
+ /** Workspace-scoped display metadata only. It must never grant or imply agent access. */
187
+ readonly getWorkspaceAlias?: (workspaceId: string, stableAgentId: string) => Promise<string | null | undefined> | string | null | undefined;
188
+ }
189
+ /**
190
+ * A caller-scoped projection over the canonical Aiko runtime.
191
+ * Authorization is evaluated before aliases are read, and again on every list.
192
+ * The projection never persists an agent catalog or turns a display alias into authority.
193
+ */
194
+ declare function createAikoAgentDirectory(options: AikoAgentDirectoryOptions): {
195
+ list(): Promise<readonly AikoDirectoryEntry[]>;
196
+ };
197
+
198
+ export { type AikoAgentDefinition, type AikoAgentDirectoryOptions, type AikoCapability, type AikoDirectoryAgentKind, type AikoDirectoryCaller, type AikoDirectoryEntry, type AikoIntelligenceResolver, type AikoIntelligenceSpec, type AikoKey, type AikoKeyRuntime, type AikoNaturalLanguageCandidate, type AikoNaturalLanguageResult, type AikoNaturalLanguageTarget, AikoRuntime, type AikoRuntimeOptions, type AikoSourceKind, type AikoTool, type CentralAikoIntelligenceOptions, type CentralAikoIntelligenceSpec, createAikoAgentDirectory, createCentralAikoIntelligenceResolver };
@@ -156,7 +156,12 @@ var AikoRuntime = class {
156
156
  };
157
157
 
158
158
  // src/centralIntelligence.ts
159
- function parseDocument(value, specId) {
159
+ async function contentVersion(content) {
160
+ const bytes = new TextEncoder().encode(JSON.stringify(content));
161
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
162
+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
163
+ }
164
+ async function parseDocument(value, specId) {
160
165
  const invalid = new Error("Central Aiko returned an invalid IntelligenceSpec.");
161
166
  if (!value || typeof value !== "object") throw invalid;
162
167
  const document = value;
@@ -164,10 +169,9 @@ function parseDocument(value, specId) {
164
169
  if (document.schemaVersion !== 1 || document.specId !== specId || typeof version !== "string" || !/^[0-9a-f]{64}$/.test(version) || !spec || typeof spec !== "object" || Array.isArray(spec) || !Object.keys(spec).length || Object.values(spec).some((value2) => typeof value2 !== "number" || !Number.isFinite(value2)) || !routingPolicy || typeof routingPolicy.prioritiseReasoning !== "boolean" || typeof routingPolicy.prioritiseDeterminism !== "boolean" || typeof routingPolicy.avoidPaidProviders !== "boolean") {
165
170
  throw invalid;
166
171
  }
167
- return {
172
+ const content = {
168
173
  schemaVersion: 1,
169
174
  specId,
170
- version,
171
175
  spec,
172
176
  routingPolicy: {
173
177
  prioritiseReasoning: routingPolicy.prioritiseReasoning,
@@ -175,6 +179,12 @@ function parseDocument(value, specId) {
175
179
  avoidPaidProviders: routingPolicy.avoidPaidProviders
176
180
  }
177
181
  };
182
+ try {
183
+ if (await contentVersion(content) !== version) throw invalid;
184
+ } catch {
185
+ throw invalid;
186
+ }
187
+ return { ...content, version };
178
188
  }
179
189
  function createCentralAikoIntelligenceResolver(options) {
180
190
  const url = new URL(options.origin);
@@ -212,7 +222,95 @@ function createCentralAikoIntelligenceResolver(options) {
212
222
  }
213
223
  };
214
224
  }
225
+
226
+ // src/agentDirectory.ts
227
+ function requiredText(value, field) {
228
+ if (typeof value !== "string" || !value.trim()) throw new Error("Aiko directory agent " + field + " is required.");
229
+ return value.trim();
230
+ }
231
+ function directoryKind(agent) {
232
+ if (agent.agentType === "ENDPOINT" || agent.sourceKind === "endpoint") return "endpoint";
233
+ if (agent.sourceKind === "fod-flow") return "workflow";
234
+ return "app";
235
+ }
236
+ function canonicalAgentName(agent, kind, sourceId) {
237
+ const name = typeof agent.name === "string" ? agent.name.trim() : "";
238
+ if (name) return name;
239
+ const prefix = kind === "endpoint" ? "Endpoint" : kind === "workflow" ? "Workflow" : "App";
240
+ return prefix + " " + sourceId;
241
+ }
242
+ function safeAlias(value) {
243
+ if (typeof value !== "string") return void 0;
244
+ const alias = value.trim();
245
+ if (!alias || alias.length > 80 || /[\u0000-\u001f\u007f]/.test(alias)) return void 0;
246
+ return alias;
247
+ }
248
+ function collisionKey(value) {
249
+ return value.normalize("NFKC").toLocaleLowerCase("en-US");
250
+ }
251
+ function createAikoAgentDirectory(options) {
252
+ return {
253
+ async list() {
254
+ const caller = await options.resolveCaller();
255
+ if (!caller) throw new Error("A verified Luth caller and active workspace are required.");
256
+ const trustedCaller = Object.freeze({
257
+ userId: requiredText(caller.userId, "caller user ID"),
258
+ appId: requiredText(caller.appId, "caller app ID"),
259
+ workspaceId: requiredText(caller.workspaceId, "caller workspace ID")
260
+ });
261
+ const agents = await options.listAgents();
262
+ if (!Array.isArray(agents)) throw new Error("The canonical Aiko registry returned an invalid agent collection.");
263
+ const seen = /* @__PURE__ */ new Set();
264
+ for (const agent of agents) {
265
+ const id = requiredText(agent?.id, "stable ID");
266
+ if (seen.has(id)) throw new Error("The canonical Aiko registry returned a duplicate agent ID: " + id);
267
+ seen.add(id);
268
+ requiredText(agent.sourceId, "source ID");
269
+ }
270
+ const authorized = (await Promise.all(agents.map(
271
+ async (agent) => await options.authorize(trustedCaller, agent) ? agent : null
272
+ ))).filter((agent) => agent !== null);
273
+ const candidates = await Promise.all(authorized.map(async (agent) => {
274
+ const kind = directoryKind(agent);
275
+ const sourceId = requiredText(agent.sourceId, "source ID");
276
+ const canonicalName = canonicalAgentName(agent, kind, sourceId);
277
+ let alias;
278
+ if (options.getWorkspaceAlias) {
279
+ try {
280
+ alias = safeAlias(await options.getWorkspaceAlias(trustedCaller.workspaceId, agent.id));
281
+ } catch {
282
+ alias = void 0;
283
+ }
284
+ }
285
+ return {
286
+ id: agent.id,
287
+ kind,
288
+ sourceId,
289
+ canonicalName,
290
+ description: typeof agent.description === "string" ? agent.description.trim() : "",
291
+ alias
292
+ };
293
+ }));
294
+ const names = candidates.map((candidate) => candidate.alias ?? candidate.canonicalName);
295
+ const counts = /* @__PURE__ */ new Map();
296
+ for (const name of names) counts.set(collisionKey(name), (counts.get(collisionKey(name)) ?? 0) + 1);
297
+ return Object.freeze(candidates.map((candidate) => {
298
+ const alias = candidate.alias && counts.get(collisionKey(candidate.alias)) === 1 ? candidate.alias : void 0;
299
+ return Object.freeze({
300
+ id: candidate.id,
301
+ kind: candidate.kind,
302
+ sourceId: candidate.sourceId,
303
+ canonicalName: candidate.canonicalName,
304
+ name: alias ?? candidate.canonicalName,
305
+ description: candidate.description,
306
+ ...alias ? { alias } : {}
307
+ });
308
+ }));
309
+ }
310
+ };
311
+ }
215
312
  export {
216
313
  AikoRuntime,
314
+ createAikoAgentDirectory,
217
315
  createCentralAikoIntelligenceResolver
218
316
  };
@@ -8,7 +8,7 @@ import {
8
8
  inferenceExecutor,
9
9
  parseErrorJson,
10
10
  performInference
11
- } from "../chunk-GCTQY24J.js";
11
+ } from "../chunk-MK4ZRBFI.js";
12
12
  import "../chunk-MAMK4GDH.js";
13
13
  export {
14
14
  DeterministicEndpointExecutor,
@@ -7,9 +7,9 @@ import {
7
7
  endpointRefresher,
8
8
  modelCatalog,
9
9
  modelHealthService
10
- } from "../chunk-LMWXONZG.js";
11
- import "../chunk-P7H6TIEA.js";
10
+ } from "../chunk-EREYT3WJ.js";
12
11
  import "../chunk-MAMK4GDH.js";
12
+ import "../chunk-P7H6TIEA.js";
13
13
  import "../chunk-JSQZAFBU.js";
14
14
  export {
15
15
  EndpointRefresher,
@@ -6,11 +6,11 @@ import {
6
6
  failoverExecutionEngine,
7
7
  healthCheckService,
8
8
  metricsLogger
9
- } from "../chunk-PT6J6UEU.js";
10
- import "../chunk-LMWXONZG.js";
11
- import "../chunk-P7H6TIEA.js";
9
+ } from "../chunk-LMAU62ZG.js";
12
10
  import "../chunk-SLR6SIEU.js";
11
+ import "../chunk-EREYT3WJ.js";
13
12
  import "../chunk-MAMK4GDH.js";
13
+ import "../chunk-P7H6TIEA.js";
14
14
  import "../chunk-JSQZAFBU.js";
15
15
  export {
16
16
  FailoverExecutionEngine,
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Canonical application-side OAuth 2.1 backend-for-frontend (BFF).
3
+ *
4
+ * Luth is the single Better Auth authorization server. Applications never
5
+ * receive Luth bearer/refresh tokens in JavaScript or redirect URLs. The BFF
6
+ * owns PKCE, the code exchange, encrypted server-side tokens and an opaque,
7
+ * first-party HttpOnly session cookie. Mount the same handler in every app.
8
+ */
9
+ export interface OAuthBffDatabase {
10
+ query(statement: string, values: readonly unknown[]): Promise<{
11
+ rows: any[];
12
+ }>;
13
+ }
14
+ export interface OAuthBffConfig {
15
+ /** Luth's exact Better Auth issuer, including /api/auth. */
16
+ issuer: string;
17
+ /** Exact, administratively verified Luth OAuth client and callback binding. */
18
+ clientId: string;
19
+ clientSecret: string;
20
+ appId: string;
21
+ redirectUri: string;
22
+ /** Stable server-side secret, never serialized to a browser or log. */
23
+ encryptionSecret: string;
24
+ database: OAuthBffDatabase;
25
+ fetcher?: typeof fetch;
26
+ now?: () => number;
27
+ }
28
+ export interface OAuthBffUser {
29
+ id: string;
30
+ email: string;
31
+ name: string;
32
+ image?: string | null;
33
+ }
34
+ export interface OAuthBffSession {
35
+ authenticated: true;
36
+ user: OAuthBffUser;
37
+ session: {
38
+ id: string;
39
+ expiresAt: string;
40
+ };
41
+ }
42
+ /** The storage contract is in db/migrations/006_kloks_oidc_bff.sql. */
43
+ export declare function createOAuthBff(config: OAuthBffConfig): {
44
+ start: (request: Request) => Promise<Response>;
45
+ callback: (request: Request) => Promise<Response>;
46
+ getSession: (request: Request) => Promise<OAuthBffSession | null>;
47
+ session: (request: Request) => Promise<Response>;
48
+ signOut: (request: Request) => Promise<Response>;
49
+ handle: (request: Request) => Promise<Response | null>;
50
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ export interface CanonicalApplicationAuthEnvironment {
2
+ APP_URL?: unknown;
3
+ SYSTEM_DATABASE_URL?: unknown;
4
+ SYSTEM_DATABASE_URL_2?: unknown;
5
+ SYSTEM_DATABASE_URL_3?: unknown;
6
+ LUTH_OAUTH_CLIENT_ID?: unknown;
7
+ LUTH_OAUTH_CLIENT_SECRET?: unknown;
8
+ LUTH_OAUTH_BFF_SECRET?: unknown;
9
+ [key: string]: unknown;
10
+ }
11
+ /**
12
+ * Single authoritative adapter from a verified application deployment to
13
+ * Kloks' OAuth 2.1 BFF. App code must supply its compile-time canonical app ID
14
+ * and trusted deployment bindings; never accept these from request JSON.
15
+ */
16
+ export declare function createCanonicalApplicationOAuthBff(request: Request, env: CanonicalApplicationAuthEnvironment, applicationId: string): {
17
+ start: (request: Request) => Promise<Response>;
18
+ callback: (request: Request) => Promise<Response>;
19
+ getSession: (request: Request) => Promise<import("./OidcBff.js").OAuthBffSession | null>;
20
+ session: (request: Request) => Promise<Response>;
21
+ signOut: (request: Request) => Promise<Response>;
22
+ handle: (request: Request) => Promise<Response | null>;
23
+ };
@@ -1,2 +1,4 @@
1
1
  export * from './CanonicalAuthClient.js';
2
2
  export * from './UnifiedAuthCore.js';
3
+ export * from './OidcBff.js';
4
+ export * from './OidcBffEnv.js';
@@ -1,4 +1,7 @@
1
- import "../chunk-JQKKMUCT.js";
1
+ import {
2
+ createCanonicalApplicationOAuthBff,
3
+ createOAuthBff
4
+ } from "../chunk-SEKPSCWP.js";
2
5
  import {
3
6
  LuthAuthClient,
4
7
  LuthAuthClient2,
@@ -16,8 +19,10 @@ export {
16
19
  LuthAuthClient2 as CanonicalAuthClient,
17
20
  LuthAuthClient,
18
21
  LuthAuthError,
22
+ createCanonicalApplicationOAuthBff,
19
23
  createLuthAuthClient2 as createCanonicalAuthClient,
20
24
  createLuthAuthClient,
25
+ createOAuthBff,
21
26
  loginSystemUser,
22
27
  resolveClientEnvironment,
23
28
  resolveClientOrigin,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  continueDropboxFolder,
3
3
  listDropboxFolder
4
- } from "./chunk-PECE5QKV.js";
4
+ } from "./chunk-5SKQBVYU.js";
5
5
  import {
6
6
  normalizeStoragePath
7
7
  } from "./chunk-HJE4CVKY.js";
@@ -59,7 +59,7 @@ function createDropboxStorageService(connection, transport = fetch) {
59
59
  async delete(path) {
60
60
  const target = toDropboxPath(path);
61
61
  if (!target) throw new Error("Refusing to delete the Dropbox root");
62
- const { createProviderClient } = await import("./client-5SGUJCV5.js");
62
+ const { createProviderClient } = await import("./client-S4R4MZ6K.js");
63
63
  await createProviderClient(connection, transport).request({
64
64
  path: "/2/files/delete_v2",
65
65
  method: "POST",
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createProviderClient
3
- } from "./chunk-X57LLCAQ.js";
3
+ } from "./chunk-5S5CDQXD.js";
4
4
 
5
5
  // src/provider-services/cloudflare.ts
6
6
  var QUERY = `query WorkersToday($account: string, $start: string, $end: string) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createProviderClient
3
- } from "./chunk-X57LLCAQ.js";
3
+ } from "./chunk-5S5CDQXD.js";
4
4
 
5
5
  // src/provider-services/operations.ts
6
6
  async function cfGet(connection, path, transport = fetch) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  listGitHubRepositories,
3
3
  listGitHubRepositoryContents
4
- } from "./chunk-PECE5QKV.js";
4
+ } from "./chunk-5SKQBVYU.js";
5
5
  import {
6
6
  UnsupportedStorageOperation,
7
7
  normalizeStoragePath
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createProviderClient
3
- } from "./chunk-X57LLCAQ.js";
3
+ } from "./chunk-5S5CDQXD.js";
4
4
 
5
5
  // src/provider-services/gemini.ts
6
6
  async function listGeminiModels(connection, transport = fetch) {
@@ -1,13 +1,17 @@
1
1
  import {
2
2
  getProviderService,
3
3
  resolveProviderServiceId
4
- } from "./chunk-FKK23J2A.js";
4
+ } from "./chunk-LN274IE5.js";
5
5
 
6
6
  // src/provider-services/client.ts
7
7
  import { resolveTrustedApiUrl } from "@dinilmusick/gutts/urls/safety";
8
8
  var origins = {
9
9
  cloudflare: "https://api.cloudflare.com",
10
10
  vercel: "https://api.vercel.com",
11
+ railway: "https://backboard.railway.com",
12
+ fly: "https://api.machines.dev",
13
+ render: "https://api.render.com",
14
+ "google-cloud-run": "https://run.googleapis.com",
11
15
  google: "https://www.googleapis.com",
12
16
  "google-gemini": "https://generativelanguage.googleapis.com",
13
17
  "google-drive": "https://www.googleapis.com",
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createProviderClient
3
- } from "./chunk-X57LLCAQ.js";
3
+ } from "./chunk-5S5CDQXD.js";
4
4
  import {
5
5
  resolveProviderServiceId
6
- } from "./chunk-FKK23J2A.js";
6
+ } from "./chunk-LN274IE5.js";
7
7
 
8
8
  // src/provider-services/storage-providers.ts
9
9
  import { encodeSafePathSegments } from "@dinilmusick/gutts/urls/safety";
@@ -268,7 +268,14 @@ var HTTPTransport = class {
268
268
  isConnected() {
269
269
  return this.connected;
270
270
  }
271
+ operationEndpoint(operation) {
272
+ if (typeof operation !== "string" || !operation || operation.trim() !== operation || /[\/\\?#%\x00-\x1f\x7f]/.test(operation) || operation.split(".").some((segment) => !segment || segment.trim() !== segment)) {
273
+ throw new Error("[HTTPTransport] Invalid remote operation identifier.");
274
+ }
275
+ return `${this.baseUrl}/api/${operation.split(".").map(encodeURIComponent).join("/")}`;
276
+ }
271
277
  async request(message) {
278
+ const endpoint = this.operationEndpoint(message.operation);
272
279
  const controller = new AbortController();
273
280
  const timer = setTimeout(() => controller.abort(), this.timeoutMs);
274
281
  const headers = {
@@ -279,7 +286,6 @@ var HTTPTransport = class {
279
286
  if (message.sessionId) headers["x-session-id"] = message.sessionId;
280
287
  if (message.correlationId) headers["x-correlation-id"] = message.correlationId;
281
288
  try {
282
- const endpoint = `${this.baseUrl}/api/${message.operation.replace(/\./g, "/")}`;
283
289
  const res = await fetch(endpoint, {
284
290
  method: message.type === "QUERY" ? "POST" : "POST",
285
291
  headers,
@@ -657,6 +663,7 @@ var FrontendSession = class {
657
663
  callbackRegistry;
658
664
  sequenceTracker;
659
665
  subscriptions = /* @__PURE__ */ new Set();
666
+ disposed = false;
660
667
  constructor(options = {}) {
661
668
  this.sessionId = options.sessionId || `session-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
662
669
  this.credentials = { ...options.credentials || {} };
@@ -665,6 +672,7 @@ var FrontendSession = class {
665
672
  this.sequenceTracker = options.sequenceTracker || new SequenceTracker();
666
673
  }
667
674
  setCredential(key, value) {
675
+ if (this.disposed) throw new Error("[FrontendSession] Cannot update a disposed session.");
668
676
  this.credentials[key] = value;
669
677
  return this;
670
678
  }
@@ -675,6 +683,7 @@ var FrontendSession = class {
675
683
  return { ...this.credentials };
676
684
  }
677
685
  grantCapability(capability) {
686
+ if (this.disposed) throw new Error("[FrontendSession] Cannot update a disposed session.");
678
687
  this.capabilities.add(capability);
679
688
  return this;
680
689
  }
@@ -682,6 +691,14 @@ var FrontendSession = class {
682
691
  return this.capabilities.has(capability) || this.capabilities.has("*");
683
692
  }
684
693
  trackSubscription(cleanup) {
694
+ if (this.disposed) {
695
+ try {
696
+ cleanup();
697
+ } catch {
698
+ }
699
+ return () => {
700
+ };
701
+ }
685
702
  this.subscriptions.add(cleanup);
686
703
  return () => {
687
704
  this.subscriptions.delete(cleanup);
@@ -698,6 +715,10 @@ var FrontendSession = class {
698
715
  this.subscriptions.clear();
699
716
  }
700
717
  dispose() {
718
+ if (this.disposed) return;
719
+ this.disposed = true;
720
+ this.credentials = {};
721
+ this.capabilities.clear();
701
722
  this.clearSubscriptions();
702
723
  this.callbackRegistry.clear();
703
724
  this.sequenceTracker.reset();
@@ -0,0 +1,93 @@
1
+ import {
2
+ createProviderClient
3
+ } from "./chunk-5S5CDQXD.js";
4
+
5
+ // src/provider-services/capacity.ts
6
+ function calculateProviderCapacity(snapshot, now = /* @__PURE__ */ new Date(), maxAgeMs = 10 * 6e4) {
7
+ const checkedAt = now.toISOString();
8
+ const unknown = (reason) => ({ status: "unknown", weight: 0, percentRemaining: null, bottleneck: null, reason, checkedAt });
9
+ const timestamp = Date.parse(snapshot.capturedAt);
10
+ if (!Number.isFinite(timestamp) || now.getTime() < timestamp - 3e4 || now.getTime() - timestamp > maxAgeMs) return unknown("Telemetry is stale or undated");
11
+ if (snapshot.error || snapshot.coverage === "unavailable") {
12
+ return unknown(snapshot.error || "Provider quota telemetry unavailable");
13
+ }
14
+ const enforced = snapshot.metrics.filter((m) => m.enforceable);
15
+ if (!enforced.length) return unknown("No provider-confirmed renewable quota windows");
16
+ if (snapshot.coverage !== "complete") return unknown("Required quota coverage is incomplete");
17
+ let bottleneck = null;
18
+ let minimum = 1;
19
+ for (const metric of enforced) {
20
+ if (metric.source !== "provider" || !validQuota(metric) || !metric.resetAt || Date.parse(metric.resetAt) <= now.getTime()) {
21
+ return unknown("Quota metric missing, estimated, or outside its reset window: " + metric.id);
22
+ }
23
+ const remaining = Math.max(0, Math.min(1, (metric.limit - metric.used) / metric.limit));
24
+ if (!bottleneck || remaining < minimum) {
25
+ minimum = remaining;
26
+ bottleneck = metric;
27
+ }
28
+ }
29
+ const status = minimum === 0 ? "exhausted" : "eligible";
30
+ return {
31
+ status,
32
+ weight: status === "eligible" ? Number(minimum.toFixed(4)) : 0,
33
+ percentRemaining: Math.round(minimum * 100),
34
+ bottleneck: bottleneck?.id ?? null,
35
+ reason: status === "eligible" ? "Provider-measured quota remaining" : "A required quota is exhausted",
36
+ checkedAt
37
+ };
38
+ }
39
+ function validQuota(metric) {
40
+ return metric.used !== null && metric.limit !== null && Number.isFinite(metric.used) && Number.isFinite(metric.limit) && metric.used >= 0 && metric.limit > 0 && typeof metric.resetAt === "string" && Number.isFinite(Date.parse(metric.resetAt));
41
+ }
42
+
43
+ // src/provider-services/compute-operations.ts
44
+ function connectionFor(input, expected) {
45
+ if (input.providerId !== expected) throw new Error("Credential/provider mismatch");
46
+ return input;
47
+ }
48
+ function requiredProject(input, name, pattern) {
49
+ if (!pattern.test(input)) throw new Error("Invalid " + name);
50
+ return input;
51
+ }
52
+ async function getRailwayAccount(connection, transport = fetch) {
53
+ const client = createProviderClient(connectionFor(connection, "railway"), transport);
54
+ const { data } = await client.request({
55
+ path: "/graphql/v2",
56
+ method: "POST",
57
+ body: { query: "query FrnesIdentity { me { name email } }" }
58
+ });
59
+ if (data.errors?.length || !data.data?.me || typeof data.data.me !== "object" || !(typeof data.data.me.email === "string" && data.data.me.email.trim() || typeof data.data.me.name === "string" && data.data.me.name.trim()))
60
+ throw new Error("Railway account token could not be authorized");
61
+ return data.data.me;
62
+ }
63
+ async function listFlyApps(connection, transport = fetch) {
64
+ const client = createProviderClient(connectionFor(connection, "fly"), transport);
65
+ const { data } = await client.request({ path: "/v1/apps" });
66
+ if (!Array.isArray(data?.apps) || data.apps.some((item) => typeof item.name !== "string" || !item.name))
67
+ throw new Error("Invalid Fly Machines app listing");
68
+ return data.apps;
69
+ }
70
+ async function listRenderServices(connection, transport = fetch) {
71
+ const client = createProviderClient(connectionFor(connection, "render"), transport);
72
+ const { data } = await client.request({ path: "/v1/services", query: { limit: 20 } });
73
+ if (!Array.isArray(data) || data.some((item) => typeof item.service?.id !== "string" || !item.service.id || typeof item.service.name !== "string" || !item.service.name))
74
+ throw new Error("Invalid Render services response");
75
+ return data;
76
+ }
77
+ async function listGoogleCloudRunServices(connection, project, region, transport = fetch) {
78
+ connectionFor(connection, "google-cloud-run");
79
+ const projectId = requiredProject(project, "Google project ID", /^[a-z][a-z0-9-]{4,61}[a-z0-9]$/);
80
+ const location = requiredProject(region, "Google Cloud location", /^[a-z][a-z0-9-]{1,40}$/);
81
+ const { data } = await createProviderClient(connection, transport).request({ path: `/v2/projects/${projectId}/locations/${location}/services` });
82
+ if (!data || data.services !== void 0 && (!Array.isArray(data.services) || data.services.some((item) => typeof item.name !== "string" || !item.name)))
83
+ throw new Error("Invalid Cloud Run service listing");
84
+ return data.services || [];
85
+ }
86
+
87
+ export {
88
+ calculateProviderCapacity,
89
+ getRailwayAccount,
90
+ listFlyApps,
91
+ listRenderServices,
92
+ listGoogleCloudRunServices
93
+ };
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  fetchCloudflareCapacity,
3
3
  fetchVercelCapacity
4
- } from "./chunk-YZNQA3FU.js";
4
+ } from "./chunk-3V5B2BOP.js";
5
5
  import {
6
6
  getGeminiQuotaStatus,
7
7
  listGeminiModels
8
- } from "./chunk-DMBDZHJF.js";
8
+ } from "./chunk-4NTZRTRY.js";
9
9
  import {
10
10
  getGoogleAccountProfile,
11
11
  listCloudflareAccounts,
@@ -13,7 +13,7 @@ import {
13
13
  listCloudflareWorkers,
14
14
  listVercelDeployments,
15
15
  listVercelProjects
16
- } from "./chunk-UVNKDM7N.js";
16
+ } from "./chunk-4BCTI7BL.js";
17
17
  import {
18
18
  continueDropboxFolder,
19
19
  listDropboxFolder,
@@ -21,7 +21,7 @@ import {
21
21
  listGitHubRepositoryContents,
22
22
  listGitLabProjects,
23
23
  listGitLabRepositoryTree
24
- } from "./chunk-PECE5QKV.js";
24
+ } from "./chunk-5SKQBVYU.js";
25
25
  import {
26
26
  b2ListBuckets,
27
27
  b2ListFileNames