@ultrst-armada/kloks 1.26.1 → 1.26.3
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 +12 -3
- package/packages/backend/dist/chunk-3S2NSIFA.js +80 -0
- package/packages/backend/dist/{chunk-JRNH5KPV.js → chunk-EDKCP5CQ.js} +2 -2
- package/packages/backend/dist/{chunk-3W4TN6XB.js → chunk-FU6TYLI2.js} +5 -5
- package/packages/backend/dist/chunk-KPZQUA7R.js +406 -0
- package/packages/backend/dist/{chunk-IB5SLBHT.js → chunk-U4UI6KK4.js} +1 -1
- package/packages/backend/dist/{chunk-QXIMZLGS.js → chunk-WAQDOIGQ.js} +1 -1
- package/packages/backend/dist/development/index.js +5 -5
- package/packages/backend/dist/index.js +19 -17
- package/packages/backend/dist/krnl-ai-services.js +2 -2
- package/packages/backend/dist/krnl-services.js +4 -4
- package/packages/backend/dist/services/index.js +3 -3
- package/packages/backend/dist/storage/GoogleDriveAdapter.d.ts +23 -1
- package/packages/backend/dist/storage/GoogleDriveOAuth.d.ts +20 -2
- package/packages/backend/dist/storage/GoogleDriveStorageService.d.ts +7 -1
- package/packages/backend/dist/storage/GoogleDriveWorkspaceService.d.ts +69 -0
- package/packages/backend/dist/storage/GoogleDriveWorkspaceService.test.d.ts +1 -0
- package/packages/backend/dist/storage/StorageAdapterFactory.d.ts +6 -1
- package/packages/backend/dist/storage/googleDriveSdk.d.ts +7 -0
- package/packages/backend/dist/storage/index.js +5 -3
- package/packages/backend/dist/storage/types.d.ts +13 -0
- package/packages/backend/dist/storage-workspace.d.ts +2 -0
- package/packages/backend/dist/storage-workspace.js +339 -0
- package/packages/backend/dist/workspace/index.js +2 -2
- package/packages/backend/package.json +6 -1
- package/packages/state-graph/dist/browser.d.ts +28 -0
- package/packages/state-graph/dist/browser.js +302 -0
- package/packages/state-graph/dist/chunk-2CQQGFMF.js +7339 -0
- package/packages/state-graph/dist/index.js +283 -7260
- package/packages/state-graph/dist/runtime-entrypoint.test.d.ts +1 -0
- package/packages/state-graph/dist/store/CommandApi.d.ts +4 -4
- package/packages/state-graph/package.json +2 -1
- package/packages/backend/dist/chunk-52M4L74T.js +0 -247
- package/packages/backend/dist/chunk-GZD5A54P.js +0 -67
- package/packages/backend/dist/{chunk-M45KQRPR.js → chunk-GWCLYVJT.js} +3 -3
- /package/packages/state-graph/dist/{dist-es-OECEAUXH.js → dist-es-QZ6GKMM7.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -38,14 +38,14 @@ export declare class CommandApi {
|
|
|
38
38
|
create: (num: number, name: string, camera: {
|
|
39
39
|
x: number;
|
|
40
40
|
y: number;
|
|
41
|
-
}, zoom: number) => import("../
|
|
41
|
+
}, zoom: number) => import("../browser.js").Landmark;
|
|
42
42
|
delete: (id: string) => boolean;
|
|
43
|
-
list: () => import("../
|
|
43
|
+
list: () => import("../browser.js").Landmark[];
|
|
44
44
|
};
|
|
45
45
|
get viewWindows(): {
|
|
46
46
|
create: (params: Parameters<typeof this.store.viewWindows.createWindow>[0]) => {
|
|
47
|
-
window: import("../
|
|
48
|
-
link: import("../
|
|
47
|
+
window: import("../browser.js").BaseViewWindow;
|
|
48
|
+
link: import("../browser.js").ViewLink;
|
|
49
49
|
};
|
|
50
50
|
close: (id: string) => boolean;
|
|
51
51
|
select: (id: string) => void;
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"types": "./dist/spatial/index.d.ts",
|
|
39
39
|
"default": "./dist/spatial/index.js"
|
|
40
40
|
},
|
|
41
|
+
"./browser": {"import": "./dist/browser.js","types": "./dist/browser.d.ts","default": "./dist/browser.js"},
|
|
41
42
|
"./store": {
|
|
42
43
|
"import": "./dist/store/index.js",
|
|
43
44
|
"types": "./dist/store/index.d.ts",
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
}
|
|
46
47
|
},
|
|
47
48
|
"scripts": {
|
|
48
|
-
"build": "tsup src/index.ts src/state/index.ts src/domain/index.ts src/rules/index.ts src/spatial/index.ts src/store/index.ts --format esm --clean --external zustand --external react --external ws && tsc --emitDeclarationOnly --declaration --project tsconfig.json",
|
|
49
|
+
"build": "tsup src/index.ts src/browser.ts src/state/index.ts src/domain/index.ts src/rules/index.ts src/spatial/index.ts src/store/index.ts --format esm --clean --external zustand --external react --external ws && tsc --emitDeclarationOnly --declaration --project tsconfig.json",
|
|
49
50
|
"typecheck": "tsc --noEmit",
|
|
50
51
|
"clean": "rm -rf dist"
|
|
51
52
|
},
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
// src/storage/BaseStorageAdapter.ts
|
|
2
|
-
import { SkipoBase } from "@ultrst-armada/kloks/functions";
|
|
3
|
-
var BaseStorageAdapter = class extends SkipoBase {
|
|
4
|
-
config;
|
|
5
|
-
constructor(config) {
|
|
6
|
-
super({ name: "BaseStorageAdapter" });
|
|
7
|
-
this.config = config;
|
|
8
|
-
}
|
|
9
|
-
async deleteFolder(pathStr) {
|
|
10
|
-
const items = await this.list(pathStr);
|
|
11
|
-
let count = 0;
|
|
12
|
-
for (const item of items) {
|
|
13
|
-
await this.delete(item.path);
|
|
14
|
-
count++;
|
|
15
|
-
}
|
|
16
|
-
return { success: true, deletedCount: count };
|
|
17
|
-
}
|
|
18
|
-
async renameFolder(oldPath, newPath) {
|
|
19
|
-
const items = await this.list(oldPath);
|
|
20
|
-
let count = 0;
|
|
21
|
-
for (const item of items) {
|
|
22
|
-
const rel = item.path.startsWith(oldPath) ? item.path.slice(oldPath.length).replace(/^\/+/, "") : item.path;
|
|
23
|
-
const target = `${newPath.replace(/\/+$/, "")}/${rel}`;
|
|
24
|
-
const data = await this.read(item.path);
|
|
25
|
-
await this.write(target, data);
|
|
26
|
-
await this.delete(item.path);
|
|
27
|
-
count++;
|
|
28
|
-
}
|
|
29
|
-
return { success: true, movedCount: count };
|
|
30
|
-
}
|
|
31
|
-
async ensureDirectory(pathStr) {
|
|
32
|
-
await this.mkdir(pathStr);
|
|
33
|
-
}
|
|
34
|
-
async testConnection() {
|
|
35
|
-
const start = performance.now();
|
|
36
|
-
try {
|
|
37
|
-
await this.list("");
|
|
38
|
-
return { ok: true, latencyMs: Math.round(performance.now() - start) };
|
|
39
|
-
} catch (e) {
|
|
40
|
-
return { ok: false, latencyMs: Math.round(performance.now() - start), error: e.message };
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
normalizePath(p) {
|
|
44
|
-
return p.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
45
|
-
}
|
|
46
|
-
getExtension(p) {
|
|
47
|
-
const parts = p.split(".");
|
|
48
|
-
return parts.length > 1 ? parts[parts.length - 1] : "";
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// src/storage/GoogleDriveAdapter.ts
|
|
53
|
-
import { google } from "@dinilmusick/gutts/storage";
|
|
54
|
-
import { Readable } from "stream";
|
|
55
|
-
var GoogleDriveAdapter = class extends BaseStorageAdapter {
|
|
56
|
-
client;
|
|
57
|
-
auth;
|
|
58
|
-
getAuth() {
|
|
59
|
-
if (this.auth) return this.auth;
|
|
60
|
-
const client = new google.auth.OAuth2(
|
|
61
|
-
this.config.googleClientId,
|
|
62
|
-
void 0,
|
|
63
|
-
this.config.googleRedirectUri
|
|
64
|
-
);
|
|
65
|
-
const accessToken = this.config.googleAccessToken;
|
|
66
|
-
const refreshToken = this.config.googleRefreshToken;
|
|
67
|
-
const expiresAt = Number(this.config.googleAccessTokenExpiresAt || 0);
|
|
68
|
-
if (accessToken) {
|
|
69
|
-
client.setCredentials({
|
|
70
|
-
access_token: accessToken,
|
|
71
|
-
...expiresAt ? { expiry_date: expiresAt } : {},
|
|
72
|
-
...refreshToken ? { refresh_token: refreshToken } : {}
|
|
73
|
-
});
|
|
74
|
-
} else if (refreshToken) {
|
|
75
|
-
client.setCredentials({ refresh_token: refreshToken });
|
|
76
|
-
} else {
|
|
77
|
-
throw new Error("Google Drive OAuth credentials are incomplete.");
|
|
78
|
-
}
|
|
79
|
-
this.auth = client;
|
|
80
|
-
return client;
|
|
81
|
-
}
|
|
82
|
-
async getClient() {
|
|
83
|
-
if (this.client) return this.client;
|
|
84
|
-
const auth = this.getAuth();
|
|
85
|
-
const token = await auth.getAccessToken();
|
|
86
|
-
if (!token.token) throw new Error("Google Drive authorization returned no access token.");
|
|
87
|
-
this.config.googleAccessToken = token.token;
|
|
88
|
-
if (auth.credentials.expiry_date) {
|
|
89
|
-
this.config.googleAccessTokenExpiresAt = auth.credentials.expiry_date;
|
|
90
|
-
}
|
|
91
|
-
this.client = google.drive({ version: "v3", auth });
|
|
92
|
-
return this.client;
|
|
93
|
-
}
|
|
94
|
-
async findChild(parentId, name) {
|
|
95
|
-
const drive = await this.getClient();
|
|
96
|
-
const escapedName = name.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
97
|
-
const response = await drive.files.list({
|
|
98
|
-
q: `'${parentId}' in parents and name = '${escapedName}' and trashed = false`,
|
|
99
|
-
fields: "files(id,name,size,modifiedTime,mimeType)",
|
|
100
|
-
pageSize: 10
|
|
101
|
-
});
|
|
102
|
-
return response.data.files?.[0] || null;
|
|
103
|
-
}
|
|
104
|
-
async resolveParent(relativeDir, create = false) {
|
|
105
|
-
let parent = this.config.googleRootFolderId || "root";
|
|
106
|
-
for (const part of this.normalizePath(relativeDir).split("/").filter(Boolean)) {
|
|
107
|
-
let child = await this.findChild(parent, part);
|
|
108
|
-
if (!child && create) {
|
|
109
|
-
const drive = await this.getClient();
|
|
110
|
-
const response = await drive.files.create({
|
|
111
|
-
requestBody: {
|
|
112
|
-
name: part,
|
|
113
|
-
mimeType: "application/vnd.google-apps.folder",
|
|
114
|
-
parents: [parent]
|
|
115
|
-
},
|
|
116
|
-
fields: "id,name,mimeType"
|
|
117
|
-
});
|
|
118
|
-
child = response.data;
|
|
119
|
-
}
|
|
120
|
-
if (!child?.id) {
|
|
121
|
-
throw new Error(`Google Drive directory not found: ${part}`);
|
|
122
|
-
}
|
|
123
|
-
parent = child.id;
|
|
124
|
-
}
|
|
125
|
-
return parent;
|
|
126
|
-
}
|
|
127
|
-
split(pathStr) {
|
|
128
|
-
const key = this.normalizePath(pathStr);
|
|
129
|
-
const i = key.lastIndexOf("/");
|
|
130
|
-
return i < 0 ? { dir: "", name: key } : { dir: key.slice(0, i), name: key.slice(i + 1) };
|
|
131
|
-
}
|
|
132
|
-
async read(pathStr) {
|
|
133
|
-
const { dir, name } = this.split(pathStr);
|
|
134
|
-
const parent = await this.resolveParent(dir);
|
|
135
|
-
const file = await this.findChild(parent, name);
|
|
136
|
-
if (!file?.id) throw new Error(`Google Drive file not found: ${pathStr}`);
|
|
137
|
-
const drive = await this.getClient();
|
|
138
|
-
const response = await drive.files.get(
|
|
139
|
-
{ fileId: file.id, alt: "media" },
|
|
140
|
-
{ responseType: "arraybuffer" }
|
|
141
|
-
);
|
|
142
|
-
return new Uint8Array(response.data);
|
|
143
|
-
}
|
|
144
|
-
async write(pathStr, data, contentType = "application/octet-stream") {
|
|
145
|
-
const { dir, name } = this.split(pathStr);
|
|
146
|
-
const parent = await this.resolveParent(dir, true);
|
|
147
|
-
const existing = await this.findChild(parent, name);
|
|
148
|
-
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
149
|
-
const drive = await this.getClient();
|
|
150
|
-
if (existing?.id) {
|
|
151
|
-
await drive.files.update({
|
|
152
|
-
fileId: existing.id,
|
|
153
|
-
requestBody: { name, mimeType: contentType },
|
|
154
|
-
media: { mimeType: contentType, body: Readable.from(bytes) },
|
|
155
|
-
fields: "id"
|
|
156
|
-
});
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
await drive.files.create({
|
|
160
|
-
requestBody: { name, mimeType: contentType, parents: [parent] },
|
|
161
|
-
media: { mimeType: contentType, body: Readable.from(bytes) },
|
|
162
|
-
fields: "id"
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
async delete(pathStr) {
|
|
166
|
-
const { dir, name } = this.split(pathStr);
|
|
167
|
-
const parent = await this.resolveParent(dir);
|
|
168
|
-
const file = await this.findChild(parent, name);
|
|
169
|
-
if (!file?.id) return;
|
|
170
|
-
const drive = await this.getClient();
|
|
171
|
-
try {
|
|
172
|
-
await drive.files.delete({ fileId: file.id });
|
|
173
|
-
} catch (error) {
|
|
174
|
-
if (error?.response?.status !== 404) throw error;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
async exists(pathStr) {
|
|
178
|
-
try {
|
|
179
|
-
await this.stat(pathStr);
|
|
180
|
-
return true;
|
|
181
|
-
} catch (error) {
|
|
182
|
-
if (error?.response?.status === 404) return false;
|
|
183
|
-
throw error;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
async list(pathStr = "") {
|
|
187
|
-
const parent = await this.resolveParent(pathStr);
|
|
188
|
-
const drive = await this.getClient();
|
|
189
|
-
const results = [];
|
|
190
|
-
let pageToken;
|
|
191
|
-
do {
|
|
192
|
-
const response = await drive.files.list({
|
|
193
|
-
q: `'${parent}' in parents and trashed = false`,
|
|
194
|
-
fields: "nextPageToken,files(id,name,size,modifiedTime,mimeType)",
|
|
195
|
-
pageSize: 1e3,
|
|
196
|
-
...pageToken ? { pageToken } : {}
|
|
197
|
-
});
|
|
198
|
-
for (const file of response.data.files || []) {
|
|
199
|
-
if (!file.name) continue;
|
|
200
|
-
results.push({
|
|
201
|
-
path: this.normalizePath(pathStr ? `${pathStr}/${file.name}` : file.name),
|
|
202
|
-
size: Number(file.size || 0),
|
|
203
|
-
modifiedAt: file.modifiedTime ? Date.parse(file.modifiedTime) : 0
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
pageToken = response.data.nextPageToken || void 0;
|
|
207
|
-
} while (pageToken);
|
|
208
|
-
return results;
|
|
209
|
-
}
|
|
210
|
-
async stat(pathStr) {
|
|
211
|
-
const { dir, name } = this.split(pathStr);
|
|
212
|
-
const parent = await this.resolveParent(dir);
|
|
213
|
-
const file = await this.findChild(parent, name);
|
|
214
|
-
if (!file?.id) throw new Error(`Google Drive file not found: ${pathStr}`);
|
|
215
|
-
return {
|
|
216
|
-
path: pathStr,
|
|
217
|
-
size: Number(file.size || 0),
|
|
218
|
-
modifiedAt: file.modifiedTime ? Date.parse(file.modifiedTime) : 0
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
async mkdir(pathStr) {
|
|
222
|
-
await this.resolveParent(pathStr, true);
|
|
223
|
-
}
|
|
224
|
-
async testConnection() {
|
|
225
|
-
const start = performance.now();
|
|
226
|
-
try {
|
|
227
|
-
const drive = await this.getClient();
|
|
228
|
-
const response = await drive.about.get({ fields: "user(emailAddress)" });
|
|
229
|
-
return {
|
|
230
|
-
ok: true,
|
|
231
|
-
latencyMs: Math.round(performance.now() - start),
|
|
232
|
-
details: { email: response.data.user?.emailAddress }
|
|
233
|
-
};
|
|
234
|
-
} catch (error) {
|
|
235
|
-
return {
|
|
236
|
-
ok: false,
|
|
237
|
-
latencyMs: Math.round(performance.now() - start),
|
|
238
|
-
error: error?.message || "Google Drive authorization failed."
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
export {
|
|
245
|
-
BaseStorageAdapter,
|
|
246
|
-
GoogleDriveAdapter
|
|
247
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// src/storage/GoogleDriveOAuth.ts
|
|
2
|
-
import { google } from "@dinilmusick/gutts/storage";
|
|
3
|
-
var GOOGLE_DRIVE_FILE_SCOPE = "https://www.googleapis.com/auth/drive.file";
|
|
4
|
-
function createGoogleDriveAuthorizationUrl(config, state, codeChallenge) {
|
|
5
|
-
const client = new google.auth.OAuth2(
|
|
6
|
-
config.clientId,
|
|
7
|
-
config.clientSecret,
|
|
8
|
-
config.redirectUri
|
|
9
|
-
);
|
|
10
|
-
const url = client.generateAuthUrl({
|
|
11
|
-
access_type: "offline",
|
|
12
|
-
prompt: "consent",
|
|
13
|
-
scope: config.scopes?.length ? config.scopes : [GOOGLE_DRIVE_FILE_SCOPE],
|
|
14
|
-
state,
|
|
15
|
-
...codeChallenge ? { code_challenge: codeChallenge, code_challenge_method: "S256" } : {}
|
|
16
|
-
});
|
|
17
|
-
return url;
|
|
18
|
-
}
|
|
19
|
-
async function exchangeGoogleDriveCode(config, code, codeVerifier) {
|
|
20
|
-
const client = new google.auth.OAuth2(
|
|
21
|
-
config.clientId,
|
|
22
|
-
config.clientSecret,
|
|
23
|
-
config.redirectUri
|
|
24
|
-
);
|
|
25
|
-
const { tokens } = await client.getToken({
|
|
26
|
-
code,
|
|
27
|
-
...codeVerifier ? { codeVerifier } : {}
|
|
28
|
-
});
|
|
29
|
-
if (!tokens.access_token) {
|
|
30
|
-
throw new Error("Google OAuth token exchange returned no access token.");
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
accessToken: tokens.access_token,
|
|
34
|
-
...tokens.refresh_token ? { refreshToken: tokens.refresh_token } : {},
|
|
35
|
-
...tokens.expiry_date ? { expiresAt: tokens.expiry_date } : {},
|
|
36
|
-
...tokens.token_type ? { tokenType: tokens.token_type } : {}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
async function refreshGoogleDriveAccessToken(clientId, refreshToken, clientSecret, _redirectUri) {
|
|
40
|
-
const body = new URLSearchParams({
|
|
41
|
-
client_id: clientId,
|
|
42
|
-
refresh_token: refreshToken,
|
|
43
|
-
grant_type: "refresh_token"
|
|
44
|
-
});
|
|
45
|
-
if (clientSecret) body.set("client_secret", clientSecret);
|
|
46
|
-
const response = await fetch("https://oauth2.googleapis.com/token", {
|
|
47
|
-
method: "POST",
|
|
48
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
49
|
-
body
|
|
50
|
-
});
|
|
51
|
-
if (!response.ok) {
|
|
52
|
-
throw new Error(`Google OAuth refresh failed: ${response.status}`);
|
|
53
|
-
}
|
|
54
|
-
const data = await response.json();
|
|
55
|
-
return {
|
|
56
|
-
accessToken: data.access_token,
|
|
57
|
-
expiresAt: data.expires_in ? Date.now() + Number(data.expires_in) * 1e3 : void 0,
|
|
58
|
-
tokenType: data.token_type
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export {
|
|
63
|
-
GOOGLE_DRIVE_FILE_SCOPE,
|
|
64
|
-
createGoogleDriveAuthorizationUrl,
|
|
65
|
-
exchangeGoogleDriveCode,
|
|
66
|
-
refreshGoogleDriveAccessToken
|
|
67
|
-
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
failoverExecutionEngine
|
|
3
|
+
} from "./chunk-PT6J6UEU.js";
|
|
1
4
|
import {
|
|
2
5
|
toolManagerService
|
|
3
6
|
} from "./chunk-U4HUGPRH.js";
|
|
@@ -8,9 +11,6 @@ import {
|
|
|
8
11
|
import {
|
|
9
12
|
inferenceExecutor
|
|
10
13
|
} from "./chunk-GCTQY24J.js";
|
|
11
|
-
import {
|
|
12
|
-
failoverExecutionEngine
|
|
13
|
-
} from "./chunk-PT6J6UEU.js";
|
|
14
14
|
import {
|
|
15
15
|
modelCatalog
|
|
16
16
|
} from "./chunk-LMWXONZG.js";
|
|
File without changes
|