@ultrst-armada/kloks 2.0.4 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +76 -1
- package/packages/backend/dist/api/index.js +2 -1
- package/packages/backend/dist/chunk-23LS4LWC.js +746 -0
- package/packages/backend/dist/chunk-3UZFKB4M.js +28 -0
- package/packages/backend/dist/chunk-5GW5PJWQ.js +96 -0
- package/packages/backend/dist/chunk-5SXOQAAX.js +41 -0
- package/packages/backend/dist/chunk-5UVJDX7Q.js +44 -0
- package/packages/backend/dist/{chunk-5F5V7NAG.js → chunk-5Y7K7HAT.js} +4 -1
- package/packages/backend/dist/chunk-6BL5DXFZ.js +43 -0
- package/packages/backend/dist/{chunk-OXEP3AP6.js → chunk-6I7I4C6H.js} +158 -1
- package/packages/backend/dist/{chunk-SQKG3S6P.js → chunk-AUNIGE6Q.js} +2 -2
- package/packages/backend/dist/{chunk-NY2SQOXI.js → chunk-CDRHYO44.js} +4 -1
- package/packages/backend/dist/{chunk-ZBNSK26X.js → chunk-CV55JMT7.js} +6 -5
- package/packages/backend/dist/{chunk-KPLDYX5Z.js → chunk-DJ457D5D.js} +33 -26
- package/packages/backend/dist/{chunk-FK3OAUXM.js → chunk-DTPCWHQJ.js} +4 -2
- package/packages/backend/dist/{chunk-OWMQLML7.js → chunk-EMSSTOOK.js} +33 -2
- package/packages/backend/dist/{chunk-Z6G32NQQ.js → chunk-ENMIBY2V.js} +12 -9
- package/packages/backend/dist/chunk-EQFZX3JT.js +63 -0
- package/packages/backend/dist/chunk-FKK23J2A.js +363 -0
- package/packages/backend/dist/chunk-GTKW4IGC.js +197 -0
- package/packages/backend/dist/chunk-GVMVYC6C.js +0 -0
- package/packages/backend/dist/chunk-HRJCGJTR.js +261 -0
- package/packages/backend/dist/chunk-I6T64MLT.js +171 -0
- package/packages/backend/dist/chunk-IKDYKRVH.js +51 -0
- package/packages/backend/dist/chunk-IP6XWQU2.js +48 -0
- package/packages/backend/dist/chunk-JGR6BJVX.js +74 -0
- package/packages/backend/dist/{chunk-POLVHTHJ.js → chunk-KCPQWJBO.js} +4 -1
- package/packages/backend/dist/chunk-LC6ULEM2.js +125 -0
- package/packages/backend/dist/{chunk-NTKUQVCQ.js → chunk-LMUMMVTU.js} +14 -2
- package/packages/backend/dist/chunk-LMY6MGFD.js +78 -0
- package/packages/backend/dist/chunk-NFK6YFTA.js +157 -0
- package/packages/backend/dist/chunk-NZWCPJDJ.js +82 -0
- package/packages/backend/dist/chunk-OT2PSPBK.js +74 -0
- package/packages/backend/dist/chunk-QYWVZBI6.js +54 -0
- package/packages/backend/dist/chunk-TOLAWKAY.js +1132 -0
- package/packages/backend/dist/{chunk-OQRQCDS6.js → chunk-TRJVVNO7.js} +2 -2
- package/packages/backend/dist/chunk-U7T65YUP.js +889 -0
- package/packages/backend/dist/chunk-YFMHT77Z.js +58 -0
- package/packages/backend/dist/client-JXGCPWEA.js +7 -0
- package/packages/backend/dist/control-plane/index.js +3 -1
- package/packages/backend/dist/core/b2DirectCore.test.d.ts +1 -0
- package/packages/backend/dist/core/cloudflareIntegrationCore.test.d.ts +1 -0
- package/packages/backend/dist/core/googleDriveOAuthCore.d.ts +51 -0
- package/packages/backend/dist/core/googleDriveOAuthCore.test.d.ts +1 -0
- package/packages/backend/dist/core/index.d.ts +3 -0
- package/packages/backend/dist/core/storageConnectionCore.d.ts +136 -0
- package/packages/backend/dist/core/storageConnectionCore.test.d.ts +1 -0
- package/packages/backend/dist/core/storageConnectionRuntimeCore.d.ts +57 -0
- package/packages/backend/dist/core/storageConnectionRuntimeCore.test.d.ts +1 -0
- package/packages/backend/dist/core/storageContracts.d.ts +77 -0
- package/packages/backend/dist/core/storageProviderRegistry.d.ts +7 -0
- package/packages/backend/dist/core/systemCredentialsCore.d.ts +46 -0
- package/packages/backend/dist/core/unifiedDb.d.ts +12 -2
- package/packages/backend/dist/core/unifiedDb.errors.test.d.ts +1 -0
- package/packages/backend/dist/core/unifiedDbNodeAdapter.d.ts +6 -0
- package/packages/backend/dist/core/workspaceBucketSyncCore.d.ts +3 -4
- package/packages/backend/dist/core/workspaceBucketSyncCore.test.d.ts +1 -0
- package/packages/backend/dist/core/workspaceCore.d.ts +25 -6
- package/packages/backend/dist/core/workspaceDataCore.test.d.ts +1 -0
- package/packages/backend/dist/core/workspaceFileCore.d.ts +25 -7
- package/packages/backend/dist/core/workspaceFileCore.test.d.ts +1 -0
- package/packages/backend/dist/core/workspaceFileNodeAdapter.d.ts +6 -0
- package/packages/backend/dist/core/workspaceStorageDetailsCore.d.ts +4 -8
- package/packages/backend/dist/core/workspaceStorageDetailsCore.test.d.ts +1 -0
- package/packages/backend/dist/development/index.js +1 -1
- package/packages/backend/dist/development/playwrightInspectionService.js +1 -1
- package/packages/backend/dist/development/playwrightInspectionSupport.d.ts +1 -0
- package/packages/backend/dist/index.d.ts +1 -0
- package/packages/backend/dist/index.js +130 -15
- package/packages/backend/dist/krnl-services.d.ts +0 -22
- package/packages/backend/dist/krnl-services.js +8 -19
- package/packages/backend/dist/krnl-services.node.d.ts +28 -0
- package/packages/backend/dist/node.d.ts +4 -0
- package/packages/backend/dist/node.js +670 -454
- package/packages/backend/dist/provider-services/capacity.d.ts +2 -0
- package/packages/backend/dist/provider-services/client.d.ts +18 -0
- package/packages/backend/dist/provider-services/cloudflare.d.ts +6 -0
- package/packages/backend/dist/provider-services/facades.d.ts +44 -0
- package/packages/backend/dist/provider-services/gemini.d.ts +8 -0
- package/packages/backend/dist/provider-services/google/cloud-run.d.ts +1 -0
- package/packages/backend/dist/provider-services/google/cloud-run.js +9 -0
- package/packages/backend/dist/provider-services/google/cloud-shell.d.ts +1 -0
- package/packages/backend/dist/provider-services/google/cloud-shell.js +9 -0
- package/packages/backend/dist/provider-services/google/cloud-storage.d.ts +1 -0
- package/packages/backend/dist/provider-services/google/cloud-storage.js +9 -0
- package/packages/backend/dist/provider-services/google/drive.d.ts +4 -0
- package/packages/backend/dist/provider-services/google/drive.js +20 -0
- package/packages/backend/dist/provider-services/google/gemini.d.ts +2 -0
- package/packages/backend/dist/provider-services/google/gemini.js +10 -0
- package/packages/backend/dist/provider-services/google/index.d.ts +3 -0
- package/packages/backend/dist/provider-services/google/index.js +17 -0
- package/packages/backend/dist/provider-services/google/vertex-ai.d.ts +1 -0
- package/packages/backend/dist/provider-services/google/vertex-ai.js +9 -0
- package/packages/backend/dist/provider-services/index.d.ts +11 -0
- package/packages/backend/dist/provider-services/index.js +118 -0
- package/packages/backend/dist/provider-services/node.d.ts +4 -0
- package/packages/backend/dist/provider-services/node.js +40 -0
- package/packages/backend/dist/provider-services/operations.d.ts +28 -0
- package/packages/backend/dist/provider-services/operations.test.d.ts +1 -0
- package/packages/backend/dist/provider-services/provider-services.test.d.ts +1 -0
- package/packages/backend/dist/provider-services/registry.d.ts +16 -0
- package/packages/backend/dist/provider-services/storage/backblaze-b2.d.ts +7 -0
- package/packages/backend/dist/provider-services/storage/backblaze-b2.js +8 -0
- package/packages/backend/dist/provider-services/storage/contract.d.ts +45 -0
- package/packages/backend/dist/provider-services/storage/dropbox.d.ts +3 -0
- package/packages/backend/dist/provider-services/storage/dropbox.js +12 -0
- package/packages/backend/dist/provider-services/storage/github.d.ts +4 -0
- package/packages/backend/dist/provider-services/storage/github.js +12 -0
- package/packages/backend/dist/provider-services/storage/google-drive.d.ts +4 -0
- package/packages/backend/dist/provider-services/storage/index.d.ts +7 -0
- package/packages/backend/dist/provider-services/storage/node.d.ts +2 -0
- package/packages/backend/dist/provider-services/storage/node.js +17 -0
- package/packages/backend/dist/provider-services/storage/service.d.ts +27 -0
- package/packages/backend/dist/provider-services/storage/storage-contract.test.d.ts +1 -0
- package/packages/backend/dist/provider-services/storage-facades.d.ts +55 -0
- package/packages/backend/dist/provider-services/storage-node.d.ts +11 -0
- package/packages/backend/dist/provider-services/storage-providers.d.ts +30 -0
- package/packages/backend/dist/provider-services/storage-providers.test.d.ts +1 -0
- package/packages/backend/dist/provider-services/storage.d.ts +3 -0
- package/packages/backend/dist/provider-services/storage.js +29 -0
- package/packages/backend/dist/provider-services/types.d.ts +61 -0
- package/packages/backend/dist/provider-services/vercel.d.ts +13 -0
- package/packages/backend/dist/resolver/index.js +13 -0
- package/packages/backend/dist/resolver/systemDatabaseUrl.d.ts +16 -12
- package/packages/backend/dist/services/node.js +12 -10
- package/packages/backend/dist/srkl/index.js +6 -4
- package/packages/backend/dist/storage/B2DirectClient.d.ts +7 -13
- package/packages/backend/dist/storage/B2DirectClient.test.d.ts +1 -0
- package/packages/backend/dist/storage/GoogleDriveWorkspaceService.d.ts +5 -0
- package/packages/backend/dist/storage/index.js +4 -3
- package/packages/backend/dist/storage/node.js +7 -6
- package/packages/backend/dist/storage-workspace.js +1 -1
- package/packages/backend/dist/workspace/index.js +2 -1
- package/packages/backend/dist/workspace/node.js +12 -7
- package/packages/backend/dist/workspaceFileCore-RQO7YMRD.js +28 -0
- package/packages/backend/package.json +78 -3
- package/packages/services/dist/index.js +8 -2
- package/packages/backend/dist/chunk-4QEMALXF.js +0 -90
- package/packages/backend/dist/chunk-AOZSDRNY.js +0 -159
- package/packages/backend/dist/chunk-GYSZ6CAX.js +0 -19
- package/packages/backend/dist/chunk-JCMB7BIM.js +0 -211
- package/packages/backend/dist/chunk-JGUWYVOL.js +0 -570
- package/packages/backend/dist/chunk-LMOM7CST.js +0 -427
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toCamelCase,
|
|
3
|
+
toKebabCase,
|
|
4
|
+
toPascalCase
|
|
5
|
+
} from "./chunk-LMY6MGFD.js";
|
|
6
|
+
|
|
7
|
+
// ../functions/dist/chunk-6EHIZHO4.js
|
|
8
|
+
function deepClone(obj, seen = /* @__PURE__ */ new Map()) {
|
|
9
|
+
if (obj === null || typeof obj !== "object") {
|
|
10
|
+
return obj;
|
|
11
|
+
}
|
|
12
|
+
if (seen.has(obj)) {
|
|
13
|
+
return seen.get(obj);
|
|
14
|
+
}
|
|
15
|
+
if (obj instanceof Date) {
|
|
16
|
+
return new Date(obj.getTime());
|
|
17
|
+
}
|
|
18
|
+
if (obj instanceof RegExp) {
|
|
19
|
+
return new RegExp(obj.source, obj.flags);
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(obj)) {
|
|
22
|
+
const cloneArr = [];
|
|
23
|
+
seen.set(obj, cloneArr);
|
|
24
|
+
for (const item of obj) {
|
|
25
|
+
cloneArr.push(deepClone(item, seen));
|
|
26
|
+
}
|
|
27
|
+
return cloneArr;
|
|
28
|
+
}
|
|
29
|
+
const cloneObj = Object.create(Object.getPrototypeOf(obj));
|
|
30
|
+
seen.set(obj, cloneObj);
|
|
31
|
+
for (const key of Reflect.ownKeys(obj)) {
|
|
32
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(obj, key);
|
|
33
|
+
if (descriptor) {
|
|
34
|
+
descriptor.value = deepClone(descriptor.value, seen);
|
|
35
|
+
Object.defineProperty(cloneObj, key, descriptor);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return cloneObj;
|
|
39
|
+
}
|
|
40
|
+
function deepMerge(base, ...overrides) {
|
|
41
|
+
let result = deepClone(base);
|
|
42
|
+
for (const override of overrides) {
|
|
43
|
+
if (override === null || typeof override !== "object") {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
for (const key of Object.keys(override)) {
|
|
47
|
+
const val = override[key];
|
|
48
|
+
if (val === void 0) {
|
|
49
|
+
delete result[key];
|
|
50
|
+
} else if (val && typeof val === "object" && !Array.isArray(val)) {
|
|
51
|
+
if (result[key] && typeof result[key] === "object" && !Array.isArray(result[key])) {
|
|
52
|
+
result[key] = deepMerge(result[key], val);
|
|
53
|
+
} else {
|
|
54
|
+
result[key] = deepClone(val);
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
result[key] = deepClone(val);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
var globalStore = globalThis;
|
|
64
|
+
if (!globalStore.__skipo_realtime_store) {
|
|
65
|
+
globalStore.__skipo_realtime_store = {
|
|
66
|
+
buffer: [],
|
|
67
|
+
listeners: /* @__PURE__ */ new Set()
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
var store = globalStore.__skipo_realtime_store;
|
|
71
|
+
|
|
72
|
+
// ../functions/dist/index.js
|
|
73
|
+
import {
|
|
74
|
+
createService,
|
|
75
|
+
createServiceDefinition
|
|
76
|
+
} from "@ultrst-armada/krnl";
|
|
77
|
+
var FunctionsServiceDefinition = createServiceDefinition({
|
|
78
|
+
id: "kloks.functions.core",
|
|
79
|
+
name: "FunctionsService",
|
|
80
|
+
version: "1.0.0",
|
|
81
|
+
operations: {
|
|
82
|
+
toKebabCase: {
|
|
83
|
+
id: "FunctionsService.toKebabCase",
|
|
84
|
+
name: "toKebabCase",
|
|
85
|
+
handler: async (input) => toKebabCase(input.value)
|
|
86
|
+
},
|
|
87
|
+
toCamelCase: {
|
|
88
|
+
id: "FunctionsService.toCamelCase",
|
|
89
|
+
name: "toCamelCase",
|
|
90
|
+
handler: async (input) => toCamelCase(input.value)
|
|
91
|
+
},
|
|
92
|
+
toPascalCase: {
|
|
93
|
+
id: "FunctionsService.toPascalCase",
|
|
94
|
+
name: "toPascalCase",
|
|
95
|
+
handler: async (input) => toPascalCase(input.value)
|
|
96
|
+
},
|
|
97
|
+
deepClone: {
|
|
98
|
+
id: "FunctionsService.deepClone",
|
|
99
|
+
name: "deepClone",
|
|
100
|
+
handler: async (input) => deepClone(input.value)
|
|
101
|
+
},
|
|
102
|
+
deepMerge: {
|
|
103
|
+
id: "FunctionsService.deepMerge",
|
|
104
|
+
name: "deepMerge",
|
|
105
|
+
handler: async (input) => deepMerge(input.target, input.source)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
var defaultFunctionsService = createService(FunctionsServiceDefinition);
|
|
110
|
+
var FunctionsServiceFacade = {
|
|
111
|
+
id: FunctionsServiceDefinition.id,
|
|
112
|
+
name: FunctionsServiceDefinition.name,
|
|
113
|
+
version: FunctionsServiceDefinition.version,
|
|
114
|
+
runtime: "server",
|
|
115
|
+
deployment: "local",
|
|
116
|
+
definition: FunctionsServiceDefinition,
|
|
117
|
+
get telemetry() {
|
|
118
|
+
return defaultFunctionsService.telemetry;
|
|
119
|
+
},
|
|
120
|
+
createInstance: () => createService(FunctionsServiceDefinition),
|
|
121
|
+
execute: async (op, input) => {
|
|
122
|
+
await defaultFunctionsService.start();
|
|
123
|
+
return defaultFunctionsService.call(op, input);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
@@ -10,11 +10,19 @@ import {
|
|
|
10
10
|
// src/development/playwrightInspectionSupport.ts
|
|
11
11
|
import { createRequire } from "module";
|
|
12
12
|
import { existsSync } from "fs";
|
|
13
|
-
var require2 = createRequire(import.meta.url);
|
|
14
13
|
function findSystemChromiumExecutable() {
|
|
15
14
|
if (process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH && existsSync(process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH)) {
|
|
16
15
|
return process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH;
|
|
17
16
|
}
|
|
17
|
+
const runtimeRoot = process.env.PLAYWRIGHT_RUNTIME_PATH;
|
|
18
|
+
if (runtimeRoot) {
|
|
19
|
+
try {
|
|
20
|
+
const runtimeRequire = createRequire(`${runtimeRoot}/package.json`);
|
|
21
|
+
const executable = runtimeRequire("playwright").chromium.executablePath?.();
|
|
22
|
+
if (typeof executable === "string" && existsSync(executable)) return executable;
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
18
26
|
const candidates = [
|
|
19
27
|
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
20
28
|
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
@@ -31,8 +39,10 @@ function findSystemChromiumExecutable() {
|
|
|
31
39
|
return void 0;
|
|
32
40
|
}
|
|
33
41
|
function loadPlaywright() {
|
|
42
|
+
const runtimeRoot = process.env.PLAYWRIGHT_RUNTIME_PATH;
|
|
43
|
+
const requireFromRuntime = runtimeRoot ? createRequire(`${runtimeRoot}/package.json`) : createRequire(import.meta.url);
|
|
34
44
|
try {
|
|
35
|
-
return
|
|
45
|
+
return requireFromRuntime("playwright");
|
|
36
46
|
} catch {
|
|
37
47
|
throw new Error('Playwright is required for browser inspection. Install the optional "playwright" package and Chromium browser.');
|
|
38
48
|
}
|
|
@@ -68,8 +78,10 @@ var PlaywrightInspectionRuntime = class {
|
|
|
68
78
|
let browser;
|
|
69
79
|
try {
|
|
70
80
|
const executablePath = request.executablePath ?? findSystemChromiumExecutable();
|
|
81
|
+
const chromiumArgs = typeof process.getuid === "function" && process.getuid() === 0 ? ["--no-sandbox", "--disable-dev-shm-usage"] : [];
|
|
71
82
|
browser = await loadPlaywright().chromium.launch({
|
|
72
83
|
headless: true,
|
|
84
|
+
...chromiumArgs.length ? { args: chromiumArgs } : {},
|
|
73
85
|
...executablePath ? { executablePath } : {}
|
|
74
86
|
});
|
|
75
87
|
} catch (cause) {
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// ../functions/dist/chunk-Z4LM5TOJ.js
|
|
2
|
+
function toCamelCase(str) {
|
|
3
|
+
return str.replace(/[-_]+/g, " ").replace(/[^\w\s]/g, "").replace(
|
|
4
|
+
/(?:^\w|[A-Z]|\b\w)/g,
|
|
5
|
+
(word, index) => index === 0 ? word.toLowerCase() : word.toUpperCase()
|
|
6
|
+
).replace(/\s+/g, "");
|
|
7
|
+
}
|
|
8
|
+
function toPascalCase(str) {
|
|
9
|
+
const camel = toCamelCase(str);
|
|
10
|
+
return camel.charAt(0).toUpperCase() + camel.slice(1);
|
|
11
|
+
}
|
|
12
|
+
function toKebabCase(str) {
|
|
13
|
+
return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`).replace(/[-_\s]+/g, "-").replace(/^[-_\s]+|[-_\s]+$/g, "").toLowerCase();
|
|
14
|
+
}
|
|
15
|
+
function shortId(length = 8) {
|
|
16
|
+
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
17
|
+
let result = "";
|
|
18
|
+
for (let i = 0; i < length; i++) {
|
|
19
|
+
result += chars.charAt(Math.random() * chars.length | 0);
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
var SkipoBase = class {
|
|
24
|
+
/** Unique instance identifier */
|
|
25
|
+
instanceId;
|
|
26
|
+
/** Human-readable component name */
|
|
27
|
+
name;
|
|
28
|
+
/** Logger instance */
|
|
29
|
+
logger;
|
|
30
|
+
/** Whether this component has been initialized */
|
|
31
|
+
initialized = false;
|
|
32
|
+
/** Whether this component has been disposed */
|
|
33
|
+
disposed = false;
|
|
34
|
+
constructor(config = { name: "SkipoComponent" }) {
|
|
35
|
+
this.instanceId = shortId();
|
|
36
|
+
this.name = config?.name ?? "SkipoComponent";
|
|
37
|
+
this.logger = config?.logger ?? console;
|
|
38
|
+
}
|
|
39
|
+
/** Initialize the component. Call before use. */
|
|
40
|
+
async initialize() {
|
|
41
|
+
if (this.initialized) return;
|
|
42
|
+
this.logger.log(`[${this.name}:${this.instanceId}] Initializing`);
|
|
43
|
+
await this.onInitialize();
|
|
44
|
+
this.initialized = true;
|
|
45
|
+
}
|
|
46
|
+
/** Override to add custom initialization logic */
|
|
47
|
+
async onInitialize() {
|
|
48
|
+
}
|
|
49
|
+
/** Dispose the component and release resources */
|
|
50
|
+
async dispose() {
|
|
51
|
+
if (this.disposed) return;
|
|
52
|
+
this.logger.log(`[${this.name}:${this.instanceId}] Disposing`);
|
|
53
|
+
await this.onDispose();
|
|
54
|
+
this.disposed = true;
|
|
55
|
+
}
|
|
56
|
+
/** Override to add custom cleanup logic */
|
|
57
|
+
async onDispose() {
|
|
58
|
+
}
|
|
59
|
+
/** Guard: throws if not initialized */
|
|
60
|
+
ensureInitialized() {
|
|
61
|
+
if (!this.initialized) {
|
|
62
|
+
throw new Error(`${this.name} has not been initialized. Call initialize() first.`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Guard: throws if already disposed */
|
|
66
|
+
ensureNotDisposed() {
|
|
67
|
+
if (this.disposed) {
|
|
68
|
+
throw new Error(`${this.name} has been disposed and cannot be used.`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
toCamelCase,
|
|
75
|
+
toPascalCase,
|
|
76
|
+
toKebabCase,
|
|
77
|
+
SkipoBase
|
|
78
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderClient
|
|
3
|
+
} from "./chunk-YFMHT77Z.js";
|
|
4
|
+
|
|
5
|
+
// src/provider-services/cloudflare.ts
|
|
6
|
+
var QUERY = `query WorkersToday($account: string, $start: string, $end: string) {
|
|
7
|
+
viewer { accounts(filter: { accountTag: $account }) {
|
|
8
|
+
workersInvocationsAdaptive(
|
|
9
|
+
limit: 1000, filter: { datetime_geq: $start, datetime_leq: $end }
|
|
10
|
+
) { sum { requests } }
|
|
11
|
+
} }
|
|
12
|
+
}`;
|
|
13
|
+
function utcBounds(now) {
|
|
14
|
+
const start = new Date(now);
|
|
15
|
+
start.setUTCHours(0, 0, 0, 0);
|
|
16
|
+
return {
|
|
17
|
+
start: start.toISOString(),
|
|
18
|
+
end: now.toISOString(),
|
|
19
|
+
resetAt: new Date(start.getTime() + 864e5).toISOString()
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async function fetchCloudflareCapacity(connection, plan, now = /* @__PURE__ */ new Date(), transport = fetch) {
|
|
23
|
+
const capturedAt = now.toISOString();
|
|
24
|
+
const snapshot = {
|
|
25
|
+
providerId: "cloudflare",
|
|
26
|
+
serviceId: "cloudflare",
|
|
27
|
+
accountId: connection.accountId,
|
|
28
|
+
capturedAt,
|
|
29
|
+
metrics: [],
|
|
30
|
+
coverage: "unavailable"
|
|
31
|
+
};
|
|
32
|
+
if (!/^[a-f0-9]{32}$/i.test(connection.accountScope || "")) {
|
|
33
|
+
return { ...snapshot, error: "A specific Cloudflare account tag is required" };
|
|
34
|
+
}
|
|
35
|
+
if (plan !== "free") {
|
|
36
|
+
return { ...snapshot, error: "Paid usage requires a separately configured spending policy" };
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const { start, end, resetAt } = utcBounds(now);
|
|
40
|
+
const client = createProviderClient(connection, transport);
|
|
41
|
+
const response = await client.request({
|
|
42
|
+
method: "POST",
|
|
43
|
+
path: "/client/v4/graphql",
|
|
44
|
+
body: { query: QUERY, variables: { account: connection.accountScope, start, end } }
|
|
45
|
+
});
|
|
46
|
+
const body = response.data;
|
|
47
|
+
const groups = body?.data?.viewer?.accounts?.[0]?.workersInvocationsAdaptive;
|
|
48
|
+
if (body.errors?.length || !Array.isArray(groups) || groups.length >= 1e3)
|
|
49
|
+
return { ...snapshot, error: "Cloudflare analytics failed or exceeded the query window" };
|
|
50
|
+
const values = groups.map((item) => item.sum?.requests);
|
|
51
|
+
if (values.some((v) => typeof v !== "number" || !Number.isFinite(v) || v < 0))
|
|
52
|
+
return { ...snapshot, error: "Cloudflare analytics request values are malformed" };
|
|
53
|
+
const used = values.reduce((sum, value) => sum + value, 0);
|
|
54
|
+
return {
|
|
55
|
+
...snapshot,
|
|
56
|
+
coverage: "complete",
|
|
57
|
+
metrics: [{
|
|
58
|
+
id: "workers_daily_requests",
|
|
59
|
+
label: "Workers requests / UTC day",
|
|
60
|
+
used,
|
|
61
|
+
limit: 1e5,
|
|
62
|
+
unit: "requests",
|
|
63
|
+
window: "day",
|
|
64
|
+
source: "provider",
|
|
65
|
+
enforceable: true,
|
|
66
|
+
resetAt
|
|
67
|
+
}]
|
|
68
|
+
};
|
|
69
|
+
} catch {
|
|
70
|
+
return { ...snapshot, error: "Cloudflare analytics could not be retrieved" };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/provider-services/vercel.ts
|
|
75
|
+
async function fetchVercelCapacity(connection, options, now = /* @__PURE__ */ new Date(), transport = fetch) {
|
|
76
|
+
const capturedAt = now.toISOString();
|
|
77
|
+
const snapshot = {
|
|
78
|
+
providerId: "vercel",
|
|
79
|
+
serviceId: "vercel",
|
|
80
|
+
accountId: connection.accountId,
|
|
81
|
+
capturedAt,
|
|
82
|
+
metrics: [],
|
|
83
|
+
coverage: "unavailable"
|
|
84
|
+
};
|
|
85
|
+
if (!Number.isFinite(Date.parse(options.windowStart)) || !Number.isFinite(Date.parse(options.windowEnd)) || Date.parse(options.windowEnd) <= Date.parse(options.windowStart)) {
|
|
86
|
+
return { ...snapshot, error: "Valid usage window boundaries are required" };
|
|
87
|
+
}
|
|
88
|
+
if (options.plan !== "hobby")
|
|
89
|
+
return { ...snapshot, error: "Paid plan budgets are account-specific and require provider billing data" };
|
|
90
|
+
try {
|
|
91
|
+
const client = createProviderClient(connection, transport);
|
|
92
|
+
const { data } = await client.request({
|
|
93
|
+
path: "/v2/usage",
|
|
94
|
+
query: {
|
|
95
|
+
type: "requests",
|
|
96
|
+
from: options.windowStart,
|
|
97
|
+
to: options.windowEnd,
|
|
98
|
+
...connection.accountScope ? { teamId: connection.accountScope } : {}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
if (!Array.isArray(data?.data))
|
|
102
|
+
return { ...snapshot, error: "Vercel usage payload did not contain verified daily rows" };
|
|
103
|
+
const rows = data.data;
|
|
104
|
+
const sum = (keys) => {
|
|
105
|
+
if (!rows.every((row) => keys.every((key) => row[key] === void 0 || typeof row[key] === "number" && Number.isFinite(row[key]) && row[key] >= 0)))
|
|
106
|
+
return null;
|
|
107
|
+
if (!rows.some((row) => keys.some((key) => row[key] !== void 0))) return null;
|
|
108
|
+
return rows.reduce((total, row) => total + keys.reduce((n, key) => n + (row[key] || 0), 0), 0);
|
|
109
|
+
};
|
|
110
|
+
const enforced = !!options.billingWindowVerified && !!options.resetAt && Date.parse(options.resetAt) > now.getTime();
|
|
111
|
+
const metric = (id, label, used, limit, unit) => ({
|
|
112
|
+
id,
|
|
113
|
+
label,
|
|
114
|
+
used,
|
|
115
|
+
limit,
|
|
116
|
+
unit,
|
|
117
|
+
window: "billing",
|
|
118
|
+
resetAt: options.resetAt || null,
|
|
119
|
+
enforceable: enforced,
|
|
120
|
+
source: used === null ? "unavailable" : "provider"
|
|
121
|
+
});
|
|
122
|
+
const inv = sum([
|
|
123
|
+
"function_invocation_successful_count",
|
|
124
|
+
"function_invocation_error_count",
|
|
125
|
+
"function_invocation_timeout_count"
|
|
126
|
+
]);
|
|
127
|
+
const memory = sum([
|
|
128
|
+
"function_execution_successful_gb_hours",
|
|
129
|
+
"function_execution_error_gb_hours",
|
|
130
|
+
"function_execution_timeout_gb_hours"
|
|
131
|
+
]);
|
|
132
|
+
const cpuMs = sum(["fluid_active_cpu_ms"]);
|
|
133
|
+
const metrics = [
|
|
134
|
+
metric("function_invocations", "Function invocations", inv, 1e6, "count"),
|
|
135
|
+
metric("provisioned_memory", "Provisioned memory", memory, 360, "GB-hours"),
|
|
136
|
+
metric(
|
|
137
|
+
"active_cpu",
|
|
138
|
+
"Active CPU",
|
|
139
|
+
cpuMs === null ? null : cpuMs / 1e3,
|
|
140
|
+
4 * 3600,
|
|
141
|
+
"seconds"
|
|
142
|
+
)
|
|
143
|
+
];
|
|
144
|
+
return {
|
|
145
|
+
...snapshot,
|
|
146
|
+
metrics,
|
|
147
|
+
coverage: enforced && metrics.every((m) => m.source === "provider") ? "complete" : "partial"
|
|
148
|
+
};
|
|
149
|
+
} catch {
|
|
150
|
+
return { ...snapshot, error: "Vercel usage could not be retrieved" };
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export {
|
|
155
|
+
fetchCloudflareCapacity,
|
|
156
|
+
fetchVercelCapacity
|
|
157
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
listGitHubRepositories,
|
|
3
|
+
listGitHubRepositoryContents
|
|
4
|
+
} from "./chunk-5GW5PJWQ.js";
|
|
5
|
+
import {
|
|
6
|
+
UnsupportedStorageOperation,
|
|
7
|
+
normalizeStoragePath
|
|
8
|
+
} from "./chunk-5UVJDX7Q.js";
|
|
9
|
+
|
|
10
|
+
// src/provider-services/storage/github.ts
|
|
11
|
+
function splitRepo(path) {
|
|
12
|
+
const parts = normalizeStoragePath(path).split("/");
|
|
13
|
+
if (parts.length < 2 || !parts[0] || !parts[1]) throw new Error("GitHub path must start with owner/repository");
|
|
14
|
+
return { owner: parts[0], repo: parts[1], file: parts.slice(2).join("/") };
|
|
15
|
+
}
|
|
16
|
+
function toEntry(value, prefix) {
|
|
17
|
+
return {
|
|
18
|
+
id: value.sha || value.path,
|
|
19
|
+
name: value.name,
|
|
20
|
+
path: "/" + prefix + "/" + value.path,
|
|
21
|
+
kind: value.type === "dir" ? "folder" : "file",
|
|
22
|
+
...typeof value.size === "number" ? { size: value.size } : {}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function createGitHubStorageService(connection, transport = fetch) {
|
|
26
|
+
if (connection.providerId !== "github") throw new Error("GitHub connection required");
|
|
27
|
+
const capabilities = Object.freeze({ list: true, read: true, write: false, delete: false });
|
|
28
|
+
return {
|
|
29
|
+
providerId: "github",
|
|
30
|
+
capabilities,
|
|
31
|
+
async list(path = "", cursor) {
|
|
32
|
+
const normalized = normalizeStoragePath(path);
|
|
33
|
+
if (!normalized) {
|
|
34
|
+
const page = cursor ? Number(cursor) : 1;
|
|
35
|
+
if (!Number.isSafeInteger(page) || page < 1 || page > 1e4) throw new Error("Invalid GitHub cursor");
|
|
36
|
+
const repos = await listGitHubRepositories(connection, transport, page);
|
|
37
|
+
return {
|
|
38
|
+
entries: repos.map((repo2) => ({
|
|
39
|
+
id: String(repo2.id),
|
|
40
|
+
name: repo2.full_name.split("/").pop(),
|
|
41
|
+
path: "/" + repo2.full_name,
|
|
42
|
+
kind: "repository"
|
|
43
|
+
})),
|
|
44
|
+
nextCursor: repos.length === 100 ? String(page + 1) : null,
|
|
45
|
+
complete: repos.length < 100
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (cursor) throw new Error("GitHub directory listings do not support cursors");
|
|
49
|
+
const { owner, repo, file } = splitRepo(normalized);
|
|
50
|
+
const values = await listGitHubRepositoryContents(connection, owner, repo, file, transport);
|
|
51
|
+
if (!Array.isArray(values)) throw new Error("GitHub path is not a directory");
|
|
52
|
+
if (values.length >= 1e3) throw new Error("GitHub directory exceeds contents API limit");
|
|
53
|
+
return {
|
|
54
|
+
entries: values.map((v) => toEntry(v, owner + "/" + repo)),
|
|
55
|
+
nextCursor: null,
|
|
56
|
+
complete: true
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
async read(path) {
|
|
60
|
+
const { owner, repo, file } = splitRepo(path);
|
|
61
|
+
if (!file) throw new Error("GitHub file path required");
|
|
62
|
+
const data = await listGitHubRepositoryContents(connection, owner, repo, file, transport);
|
|
63
|
+
if (!data || typeof data !== "object" || Array.isArray(data))
|
|
64
|
+
throw new Error("GitHub file metadata missing");
|
|
65
|
+
const result = data;
|
|
66
|
+
if (result.type !== "file" || result.encoding !== "base64" || typeof result.content !== "string")
|
|
67
|
+
throw new Error("GitHub contents API did not supply file bytes");
|
|
68
|
+
const binary = atob(result.content.replace(/\s/g, ""));
|
|
69
|
+
return Uint8Array.from(binary, (c) => c.charCodeAt(0));
|
|
70
|
+
},
|
|
71
|
+
async write() {
|
|
72
|
+
throw new UnsupportedStorageOperation("github", "write");
|
|
73
|
+
},
|
|
74
|
+
async delete() {
|
|
75
|
+
throw new UnsupportedStorageOperation("github", "delete");
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export {
|
|
81
|
+
createGitHubStorageService
|
|
82
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
continueDropboxFolder,
|
|
3
|
+
listDropboxFolder
|
|
4
|
+
} from "./chunk-5GW5PJWQ.js";
|
|
5
|
+
import {
|
|
6
|
+
normalizeStoragePath
|
|
7
|
+
} from "./chunk-5UVJDX7Q.js";
|
|
8
|
+
|
|
9
|
+
// src/provider-services/storage/dropbox.ts
|
|
10
|
+
function toDropboxPath(path) {
|
|
11
|
+
const normalized = normalizeStoragePath(path);
|
|
12
|
+
return normalized ? "/" + normalized : "";
|
|
13
|
+
}
|
|
14
|
+
async function contentRequest(connection, path, method, transport, content, mimeType = "application/octet-stream") {
|
|
15
|
+
if (connection.providerId !== "dropbox" || !connection.credential || !connection.accountId)
|
|
16
|
+
throw new Error("Authorized Dropbox connection required");
|
|
17
|
+
const target = toDropboxPath(path);
|
|
18
|
+
if (!target) throw new Error("Dropbox file path required");
|
|
19
|
+
const headers = {
|
|
20
|
+
Authorization: "Bearer " + connection.credential,
|
|
21
|
+
"Dropbox-API-Arg": JSON.stringify(method === "download" ? { path: target } : { path: target, mode: "add", autorename: false, mute: true })
|
|
22
|
+
};
|
|
23
|
+
if (method === "upload") headers["Content-Type"] = mimeType;
|
|
24
|
+
const response = await transport("https://content.dropboxapi.com/2/files/" + method, {
|
|
25
|
+
method: "POST",
|
|
26
|
+
headers,
|
|
27
|
+
body: method === "upload" ? typeof content === "string" ? content : new Uint8Array(content || new Uint8Array()) : void 0,
|
|
28
|
+
redirect: "error",
|
|
29
|
+
signal: AbortSignal.timeout(2e4)
|
|
30
|
+
});
|
|
31
|
+
if (!response.ok) throw new Error("Dropbox " + method + " HTTP " + response.status);
|
|
32
|
+
return response;
|
|
33
|
+
}
|
|
34
|
+
function createDropboxStorageService(connection, transport = fetch) {
|
|
35
|
+
if (connection.providerId !== "dropbox") throw new Error("Dropbox connection required");
|
|
36
|
+
return {
|
|
37
|
+
providerId: "dropbox",
|
|
38
|
+
capabilities: Object.freeze({ list: true, read: true, write: true, delete: true }),
|
|
39
|
+
async list(path = "", cursor) {
|
|
40
|
+
const value = cursor ? await continueDropboxFolder(connection, cursor, transport) : await listDropboxFolder(connection, toDropboxPath(path), transport);
|
|
41
|
+
return {
|
|
42
|
+
entries: value.entries.map((e) => ({
|
|
43
|
+
id: e.id || e.path_lower || e.name,
|
|
44
|
+
name: e.name,
|
|
45
|
+
path: e.path_lower || (toDropboxPath(path) || "") + "/" + e.name,
|
|
46
|
+
kind: e[".tag"] === "folder" ? "folder" : "file"
|
|
47
|
+
})),
|
|
48
|
+
nextCursor: value.has_more ? value.cursor : null,
|
|
49
|
+
complete: !value.has_more
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
async read(path) {
|
|
53
|
+
const response = await contentRequest(connection, path, "download", transport);
|
|
54
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
55
|
+
},
|
|
56
|
+
async write(path, bytes, contentType) {
|
|
57
|
+
await contentRequest(connection, path, "upload", transport, bytes, contentType);
|
|
58
|
+
},
|
|
59
|
+
async delete(path) {
|
|
60
|
+
const target = toDropboxPath(path);
|
|
61
|
+
if (!target) throw new Error("Refusing to delete the Dropbox root");
|
|
62
|
+
const { createProviderClient } = await import("./client-JXGCPWEA.js");
|
|
63
|
+
await createProviderClient(connection, transport).request({
|
|
64
|
+
path: "/2/files/delete_v2",
|
|
65
|
+
method: "POST",
|
|
66
|
+
body: { path: target }
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
createDropboxStorageService
|
|
74
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createCanonicalStorageService
|
|
3
|
+
} from "./chunk-IKDYKRVH.js";
|
|
4
|
+
|
|
5
|
+
// src/provider-services/storage-node.ts
|
|
6
|
+
import { createService, createServiceDefinition } from "@ultrst-armada/krnl";
|
|
7
|
+
var definition = createServiceDefinition({
|
|
8
|
+
id: "kloks.external.storage",
|
|
9
|
+
name: "Canonical Storage Provider Service",
|
|
10
|
+
version: "1.0.0",
|
|
11
|
+
operations: {
|
|
12
|
+
list: {
|
|
13
|
+
id: "storage.list",
|
|
14
|
+
name: "list",
|
|
15
|
+
handler: (input) => createCanonicalStorageService(input.config).list(input.path, input.cursor)
|
|
16
|
+
},
|
|
17
|
+
read: {
|
|
18
|
+
id: "storage.read",
|
|
19
|
+
name: "read",
|
|
20
|
+
handler: (input) => createCanonicalStorageService(input.config).read(input.path)
|
|
21
|
+
},
|
|
22
|
+
write: {
|
|
23
|
+
id: "storage.write",
|
|
24
|
+
name: "write",
|
|
25
|
+
handler: (input) => createCanonicalStorageService(input.config).write(input.path, input.data, input.contentType)
|
|
26
|
+
},
|
|
27
|
+
delete: {
|
|
28
|
+
id: "storage.delete",
|
|
29
|
+
name: "delete",
|
|
30
|
+
handler: (input) => createCanonicalStorageService(input.config).delete(input.path)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
var instance = createService(definition);
|
|
35
|
+
var CanonicalStorageProviderService = {
|
|
36
|
+
id: definition.id,
|
|
37
|
+
name: definition.name,
|
|
38
|
+
version: definition.version,
|
|
39
|
+
runtime: "server",
|
|
40
|
+
deployment: "local",
|
|
41
|
+
definition,
|
|
42
|
+
get telemetry() {
|
|
43
|
+
return instance.telemetry;
|
|
44
|
+
},
|
|
45
|
+
createInstance: () => createService(definition),
|
|
46
|
+
execute: async (operation, input) => {
|
|
47
|
+
await instance.start();
|
|
48
|
+
return instance.call(operation, input);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
CanonicalStorageProviderService
|
|
54
|
+
};
|