@ultrst-armada/kloks 1.3.0 → 1.4.1
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 +45 -2
- package/packages/audio-midi/dist/index.js +1 -2
- package/packages/audio-midi/package.json +1 -1
- package/packages/backend/dist/{chunk-IPP4VURQ.js → chunk-7KNGX522.js} +1 -2
- package/packages/backend/dist/chunk-DZ4ZGIZM.js +1323 -0
- package/packages/backend/dist/{chunk-CU7RZBMF.js → chunk-FO6WYLW4.js} +1 -1
- package/packages/backend/dist/{chunk-BM4QMVPA.js → chunk-XTWHEZWS.js} +1 -1
- package/packages/backend/dist/index.d.ts +1 -1
- package/packages/backend/dist/index.js +390 -1372
- package/packages/backend/dist/krnl-services.js +2 -2
- package/packages/backend/dist/services/index.js +2 -2
- package/packages/backend/dist/workspace/index.d.ts +119 -1
- package/packages/backend/dist/workspace/index.js +11 -3
- package/packages/backend/package.json +1 -1
- package/packages/client/dist/index.d.ts +154 -0
- package/packages/client/dist/index.js +62 -0
- package/packages/client/package.json +41 -0
- package/packages/contracts/package.json +1 -1
- package/packages/functions/dist/index.js +1 -2
- package/packages/functions/package.json +1 -1
- package/packages/orchestrations/package.json +1 -1
- package/packages/services/dist/index.js +1 -2
- package/packages/services/package.json +1 -1
- package/packages/state-graph/dist/index.js +11 -12
- package/packages/state-graph/package.json +1 -1
- package/packages/backend/dist/chunk-KTLD7Z4L.js +0 -124
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
StorageServiceFacade,
|
|
14
14
|
WorkspaceServiceDefinition,
|
|
15
15
|
WorkspaceServiceFacade
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-FO6WYLW4.js";
|
|
17
|
+
import "./chunk-7KNGX522.js";
|
|
18
18
|
import "./chunk-J2J24JVC.js";
|
|
19
19
|
import "./chunk-FZKBTF34.js";
|
|
20
20
|
import "./chunk-25Y7AVTP.js";
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
nodeGraphPersistence,
|
|
12
12
|
parseGraphJsonFile,
|
|
13
13
|
validateGraphDocument
|
|
14
|
-
} from "../chunk-
|
|
15
|
-
import "../chunk-
|
|
14
|
+
} from "../chunk-XTWHEZWS.js";
|
|
15
|
+
import "../chunk-7KNGX522.js";
|
|
16
16
|
export {
|
|
17
17
|
CompositeBackend,
|
|
18
18
|
EndpointGenerator,
|
|
@@ -108,4 +108,122 @@ declare class WorkspaceCloneSyncEngine extends SkipoBase {
|
|
|
108
108
|
}>;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
/**
|
|
112
|
+
* @file WorkspaceService.ts
|
|
113
|
+
* @description Canonical WorkspaceService interface contract for Kloks backend.
|
|
114
|
+
* Governs remote-first (DEPM) and local working-workspace (QWNSR) architectures.
|
|
115
|
+
* Conforms to Skipo Governance (< 200 lines).
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
interface WorkspaceFileEntry {
|
|
119
|
+
path: string;
|
|
120
|
+
name: string;
|
|
121
|
+
sizeBytes?: number;
|
|
122
|
+
updatedAt?: string | number;
|
|
123
|
+
isFolder?: boolean;
|
|
124
|
+
}
|
|
125
|
+
interface WorkspaceLookupResult {
|
|
126
|
+
user?: any;
|
|
127
|
+
workspace: any;
|
|
128
|
+
connection?: any;
|
|
129
|
+
}
|
|
130
|
+
interface WorkspaceListResult {
|
|
131
|
+
success: boolean;
|
|
132
|
+
workspaces: any[];
|
|
133
|
+
activeWorkspaceId?: string | null;
|
|
134
|
+
storage_connections?: any[];
|
|
135
|
+
}
|
|
136
|
+
interface WorkspaceMutationResult {
|
|
137
|
+
success: boolean;
|
|
138
|
+
workspace?: any;
|
|
139
|
+
workspaces?: any[];
|
|
140
|
+
}
|
|
141
|
+
interface WorkspaceService {
|
|
142
|
+
readonly type: 'remote' | 'working';
|
|
143
|
+
findWorkspace(workspaceId: string, env?: Record<string, unknown>): Promise<WorkspaceLookupResult>;
|
|
144
|
+
listWorkspaces(userId?: string, env?: Record<string, unknown>): Promise<WorkspaceListResult>;
|
|
145
|
+
createWorkspace(userId: string, data: any, env?: Record<string, unknown>): Promise<WorkspaceMutationResult>;
|
|
146
|
+
updateWorkspace(userId: string, params: any, env?: Record<string, unknown>): Promise<WorkspaceMutationResult>;
|
|
147
|
+
deleteWorkspace(userId: string, workspaceId: string, env?: Record<string, unknown>): Promise<{
|
|
148
|
+
success: boolean;
|
|
149
|
+
workspaces?: any[];
|
|
150
|
+
}>;
|
|
151
|
+
readFile(workspaceId: string, filePath: string, env?: Record<string, unknown>): Promise<Uint8Array | string>;
|
|
152
|
+
writeFile(workspaceId: string, filePath: string, content: Uint8Array | string, env?: Record<string, unknown>): Promise<{
|
|
153
|
+
success: boolean;
|
|
154
|
+
path: string;
|
|
155
|
+
sizeBytes?: number;
|
|
156
|
+
}>;
|
|
157
|
+
deleteFile(workspaceId: string, filePath: string, env?: Record<string, unknown>): Promise<{
|
|
158
|
+
success: boolean;
|
|
159
|
+
}>;
|
|
160
|
+
listFiles(workspaceId: string, subfolder?: string, env?: Record<string, unknown>): Promise<WorkspaceFileEntry[]>;
|
|
161
|
+
sync?(workspaceId: string, options?: any, env?: Record<string, unknown>): Promise<WorkspaceSyncSummary>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* @file RemoteWorkspaceService.ts
|
|
166
|
+
* @description Remote-first WorkspaceService implementation for Kloks.
|
|
167
|
+
* Directly mediates with authoritative remote storage (Backblaze B2/S3/DB) without requiring local working files.
|
|
168
|
+
* Canonical choice for DEPM. Conforms to Skipo Governance (< 200 lines).
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
declare class RemoteWorkspaceService implements WorkspaceService {
|
|
172
|
+
readonly type: "remote";
|
|
173
|
+
findWorkspace(workspaceId: string, env?: Record<string, unknown>): Promise<WorkspaceLookupResult>;
|
|
174
|
+
listWorkspaces(userId?: string, env?: Record<string, unknown>): Promise<WorkspaceListResult>;
|
|
175
|
+
createWorkspace(userId: string, data: any, env?: Record<string, unknown>): Promise<WorkspaceMutationResult>;
|
|
176
|
+
updateWorkspace(userId: string, params: any, env?: Record<string, unknown>): Promise<WorkspaceMutationResult>;
|
|
177
|
+
deleteWorkspace(userId: string, workspaceId: string, env?: Record<string, unknown>): Promise<{
|
|
178
|
+
success: boolean;
|
|
179
|
+
workspaces?: any[];
|
|
180
|
+
}>;
|
|
181
|
+
readFile(workspaceId: string, filePath: string, env?: Record<string, unknown>): Promise<Uint8Array | string>;
|
|
182
|
+
writeFile(workspaceId: string, filePath: string, content: Uint8Array | string, env?: Record<string, unknown>): Promise<{
|
|
183
|
+
success: boolean;
|
|
184
|
+
path: string;
|
|
185
|
+
sizeBytes?: number;
|
|
186
|
+
}>;
|
|
187
|
+
deleteFile(workspaceId: string, filePath: string, env?: Record<string, unknown>): Promise<{
|
|
188
|
+
success: boolean;
|
|
189
|
+
}>;
|
|
190
|
+
listFiles(workspaceId: string, subfolder?: string, env?: Record<string, unknown>): Promise<WorkspaceFileEntry[]>;
|
|
191
|
+
}
|
|
192
|
+
declare const remoteWorkspaceService: RemoteWorkspaceService;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* @file WorkingWorkspaceService.ts
|
|
196
|
+
* @description Local Working-Workspace implementation for Kloks.
|
|
197
|
+
* Operates on a local working directory for fast low-latency I/O and explicitly
|
|
198
|
+
* synchronizes with authoritative remote storage (Backblaze B2/S3/DB).
|
|
199
|
+
* Canonical choice for QWNSR. Conforms to Skipo Governance (< 200 lines).
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
declare class WorkingWorkspaceService implements WorkspaceService {
|
|
203
|
+
private workingDirResolver?;
|
|
204
|
+
readonly type: "working";
|
|
205
|
+
constructor(workingDirResolver?: () => string);
|
|
206
|
+
getWorkingDir(): string;
|
|
207
|
+
findWorkspace(workspaceId: string, env?: Record<string, unknown>): Promise<WorkspaceLookupResult>;
|
|
208
|
+
listWorkspaces(userId?: string, env?: Record<string, unknown>): Promise<WorkspaceListResult>;
|
|
209
|
+
createWorkspace(userId: string, data: any, env?: Record<string, unknown>): Promise<WorkspaceMutationResult>;
|
|
210
|
+
updateWorkspace(userId: string, params: any, env?: Record<string, unknown>): Promise<WorkspaceMutationResult>;
|
|
211
|
+
deleteWorkspace(userId: string, workspaceId: string, env?: Record<string, unknown>): Promise<{
|
|
212
|
+
success: boolean;
|
|
213
|
+
workspaces?: any[];
|
|
214
|
+
}>;
|
|
215
|
+
readFile(_workspaceId: string, filePath: string): Promise<Uint8Array | string>;
|
|
216
|
+
writeFile(_workspaceId: string, filePath: string, content: Uint8Array | string): Promise<{
|
|
217
|
+
success: boolean;
|
|
218
|
+
path: string;
|
|
219
|
+
sizeBytes?: number;
|
|
220
|
+
}>;
|
|
221
|
+
deleteFile(_workspaceId: string, filePath: string): Promise<{
|
|
222
|
+
success: boolean;
|
|
223
|
+
}>;
|
|
224
|
+
listFiles(_workspaceId: string, subfolder?: string): Promise<WorkspaceFileEntry[]>;
|
|
225
|
+
sync(workspaceId: string, _options?: any, _env?: Record<string, unknown>): Promise<WorkspaceSyncSummary>;
|
|
226
|
+
}
|
|
227
|
+
declare const workingWorkspaceService: WorkingWorkspaceService;
|
|
228
|
+
|
|
229
|
+
export { type CloneReplicationResult, type ConflictPolicy, RemoteWorkspaceService, SyncEngine, type SyncState, WorkingWorkspaceService, WorkspaceCloneSyncEngine, type WorkspaceConfig, type WorkspaceDescriptor, WorkspaceFS, type WorkspaceFileEntry, type WorkspaceListResult, type WorkspaceLookupResult, type WorkspaceMutationResult, type WorkspaceSecondaryClone, type WorkspaceService, type WorkspaceSyncSummary, formatCanonicalWorkspaceFolderName, remoteWorkspaceService, sanitizeWorkspaceName, workingWorkspaceService };
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
+
RemoteWorkspaceService,
|
|
2
3
|
SyncEngine,
|
|
4
|
+
WorkingWorkspaceService,
|
|
3
5
|
WorkspaceCloneSyncEngine,
|
|
4
|
-
WorkspaceFS
|
|
5
|
-
|
|
6
|
+
WorkspaceFS,
|
|
7
|
+
remoteWorkspaceService,
|
|
8
|
+
workingWorkspaceService
|
|
9
|
+
} from "../chunk-DZ4ZGIZM.js";
|
|
6
10
|
import {
|
|
7
11
|
formatCanonicalWorkspaceFolderName,
|
|
8
12
|
sanitizeWorkspaceName
|
|
9
13
|
} from "../chunk-FZKBTF34.js";
|
|
10
14
|
export {
|
|
15
|
+
RemoteWorkspaceService,
|
|
11
16
|
SyncEngine,
|
|
17
|
+
WorkingWorkspaceService,
|
|
12
18
|
WorkspaceCloneSyncEngine,
|
|
13
19
|
WorkspaceFS,
|
|
14
20
|
formatCanonicalWorkspaceFolderName,
|
|
15
|
-
|
|
21
|
+
remoteWorkspaceService,
|
|
22
|
+
sanitizeWorkspaceName,
|
|
23
|
+
workingWorkspaceService
|
|
16
24
|
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file queueContracts.ts
|
|
3
|
+
* @description Pure browser-safe command, job, queue, and execution contracts.
|
|
4
|
+
* ZERO Node/server/BullMQ dependency closure.
|
|
5
|
+
* Conforms to Skipo Governance (< 200 lines).
|
|
6
|
+
*/
|
|
7
|
+
interface CorrelationMetadata {
|
|
8
|
+
correlationId: string;
|
|
9
|
+
idempotencyKey?: string;
|
|
10
|
+
timestamp: number;
|
|
11
|
+
source?: string;
|
|
12
|
+
traceId?: string;
|
|
13
|
+
}
|
|
14
|
+
interface BackendCommand<TPayload = unknown> {
|
|
15
|
+
id: string;
|
|
16
|
+
type: string;
|
|
17
|
+
payload: TPayload;
|
|
18
|
+
metadata?: Record<string, unknown>;
|
|
19
|
+
correlationId: string;
|
|
20
|
+
idempotencyKey?: string;
|
|
21
|
+
createdAt: number;
|
|
22
|
+
}
|
|
23
|
+
type JobStatus = 'QUEUED' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'RETRYING';
|
|
24
|
+
type JobPriority = 'LOW' | 'NORMAL' | 'HIGH' | 'CRITICAL';
|
|
25
|
+
interface RetryPolicy {
|
|
26
|
+
maxAttempts: number;
|
|
27
|
+
backoffMs: number;
|
|
28
|
+
}
|
|
29
|
+
interface ExecutionJob<TPayload = unknown> {
|
|
30
|
+
id: string;
|
|
31
|
+
correlationId: string;
|
|
32
|
+
command: BackendCommand<TPayload>;
|
|
33
|
+
status: JobStatus;
|
|
34
|
+
priority: JobPriority;
|
|
35
|
+
retryPolicy?: RetryPolicy;
|
|
36
|
+
attemptsMade: number;
|
|
37
|
+
createdAt: number;
|
|
38
|
+
completedAt?: number;
|
|
39
|
+
}
|
|
40
|
+
interface NormalizedResult<TData = unknown> {
|
|
41
|
+
correlationId: string;
|
|
42
|
+
status: 'COMPLETED' | 'FAILED';
|
|
43
|
+
data?: TData;
|
|
44
|
+
error?: string;
|
|
45
|
+
executionTimestamp: number;
|
|
46
|
+
}
|
|
47
|
+
interface QueueTransportOptions {
|
|
48
|
+
gatewayUrl?: string;
|
|
49
|
+
headers?: Record<string, string>;
|
|
50
|
+
timeoutMs?: number;
|
|
51
|
+
}
|
|
52
|
+
interface QueueGatewayContract {
|
|
53
|
+
enqueue<T = unknown>(command: BackendCommand<T>): Promise<{
|
|
54
|
+
jobId: string;
|
|
55
|
+
correlationId: string;
|
|
56
|
+
}>;
|
|
57
|
+
checkStatus(jobId: string): Promise<NormalizedResult>;
|
|
58
|
+
}
|
|
59
|
+
interface WorkspaceDescriptor {
|
|
60
|
+
id: string;
|
|
61
|
+
name: string;
|
|
62
|
+
ownerId: string;
|
|
63
|
+
createdAt: number;
|
|
64
|
+
updatedAt: number;
|
|
65
|
+
}
|
|
66
|
+
interface WorkspaceSyncSummary {
|
|
67
|
+
success: boolean;
|
|
68
|
+
workspaceId: string;
|
|
69
|
+
folderKey: string;
|
|
70
|
+
workingDir?: string;
|
|
71
|
+
persistenceType: string;
|
|
72
|
+
targetLocation: string;
|
|
73
|
+
syncedFiles: Array<{
|
|
74
|
+
fileName: string;
|
|
75
|
+
action: string;
|
|
76
|
+
sizeBytes?: number;
|
|
77
|
+
}>;
|
|
78
|
+
uploadedCount: number;
|
|
79
|
+
downloadedCount: number;
|
|
80
|
+
syncedAt: string;
|
|
81
|
+
error?: string;
|
|
82
|
+
}
|
|
83
|
+
interface WorkspaceLookupResult {
|
|
84
|
+
user?: any;
|
|
85
|
+
workspace: any;
|
|
86
|
+
connection?: any;
|
|
87
|
+
}
|
|
88
|
+
interface WorkspaceListResult {
|
|
89
|
+
success: boolean;
|
|
90
|
+
workspaces: any[];
|
|
91
|
+
activeWorkspaceId?: string | null;
|
|
92
|
+
storage_connections?: any[];
|
|
93
|
+
}
|
|
94
|
+
interface WorkspaceMutationResult {
|
|
95
|
+
success: boolean;
|
|
96
|
+
workspace?: any;
|
|
97
|
+
workspaces?: any[];
|
|
98
|
+
}
|
|
99
|
+
interface WorkspaceFileEntry {
|
|
100
|
+
path: string;
|
|
101
|
+
name: string;
|
|
102
|
+
sizeBytes?: number;
|
|
103
|
+
updatedAt?: string | number;
|
|
104
|
+
isFolder?: boolean;
|
|
105
|
+
}
|
|
106
|
+
interface WorkspaceServiceContract {
|
|
107
|
+
readonly type: 'remote' | 'working';
|
|
108
|
+
findWorkspace(workspaceId: string): Promise<WorkspaceLookupResult>;
|
|
109
|
+
listWorkspaces(userId?: string): Promise<WorkspaceListResult>;
|
|
110
|
+
createWorkspace(userId: string, data: any): Promise<WorkspaceMutationResult>;
|
|
111
|
+
updateWorkspace(userId: string, params: any): Promise<WorkspaceMutationResult>;
|
|
112
|
+
deleteWorkspace(userId: string, workspaceId: string): Promise<{
|
|
113
|
+
success: boolean;
|
|
114
|
+
workspaces?: any[];
|
|
115
|
+
}>;
|
|
116
|
+
readFile(workspaceId: string, filePath: string): Promise<Uint8Array | string>;
|
|
117
|
+
writeFile(workspaceId: string, filePath: string, content: Uint8Array | string): Promise<{
|
|
118
|
+
success: boolean;
|
|
119
|
+
path: string;
|
|
120
|
+
sizeBytes?: number;
|
|
121
|
+
}>;
|
|
122
|
+
deleteFile(workspaceId: string, filePath: string): Promise<{
|
|
123
|
+
success: boolean;
|
|
124
|
+
}>;
|
|
125
|
+
listFiles(workspaceId: string, subfolder?: string): Promise<WorkspaceFileEntry[]>;
|
|
126
|
+
sync?(workspaceId: string, options?: any): Promise<WorkspaceSyncSummary>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @file browserExecutionClient.ts
|
|
131
|
+
* @description Browser-safe execution client for SKIPO applications.
|
|
132
|
+
* Dispatches commands across the queue transport boundary to the backend queue gateway.
|
|
133
|
+
* Conforms to Skipo Governance (< 200 lines).
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
declare class BrowserExecutionClient implements QueueGatewayContract {
|
|
137
|
+
private gatewayUrl;
|
|
138
|
+
private headers;
|
|
139
|
+
private timeoutMs;
|
|
140
|
+
constructor(options?: QueueTransportOptions);
|
|
141
|
+
createCommand<T = unknown>(type: string, payload: T, options?: {
|
|
142
|
+
correlationId?: string;
|
|
143
|
+
idempotencyKey?: string;
|
|
144
|
+
metadata?: Record<string, unknown>;
|
|
145
|
+
}): BackendCommand<T>;
|
|
146
|
+
enqueue<T = unknown>(command: BackendCommand<T>): Promise<{
|
|
147
|
+
jobId: string;
|
|
148
|
+
correlationId: string;
|
|
149
|
+
}>;
|
|
150
|
+
checkStatus(jobId: string): Promise<NormalizedResult>;
|
|
151
|
+
}
|
|
152
|
+
declare function createBrowserExecutionClient(options?: QueueTransportOptions): BrowserExecutionClient;
|
|
153
|
+
|
|
154
|
+
export { type BackendCommand, BrowserExecutionClient, type CorrelationMetadata, type ExecutionJob, type JobPriority, type JobStatus, type NormalizedResult, type QueueGatewayContract, type QueueTransportOptions, type RetryPolicy, type WorkspaceDescriptor, type WorkspaceFileEntry, type WorkspaceListResult, type WorkspaceLookupResult, type WorkspaceMutationResult, type WorkspaceServiceContract, type WorkspaceSyncSummary, createBrowserExecutionClient };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// src/browserExecutionClient.ts
|
|
2
|
+
var BrowserExecutionClient = class {
|
|
3
|
+
gatewayUrl;
|
|
4
|
+
headers;
|
|
5
|
+
timeoutMs;
|
|
6
|
+
constructor(options = {}) {
|
|
7
|
+
this.gatewayUrl = options.gatewayUrl || "/api/queue";
|
|
8
|
+
this.headers = options.headers || { "Content-Type": "application/json" };
|
|
9
|
+
this.timeoutMs = options.timeoutMs || 15e3;
|
|
10
|
+
}
|
|
11
|
+
createCommand(type, payload, options = {}) {
|
|
12
|
+
const correlationId = options.correlationId || `corr_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
13
|
+
return {
|
|
14
|
+
id: `cmd_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
|
|
15
|
+
type,
|
|
16
|
+
payload,
|
|
17
|
+
metadata: options.metadata,
|
|
18
|
+
correlationId,
|
|
19
|
+
idempotencyKey: options.idempotencyKey,
|
|
20
|
+
createdAt: Date.now()
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async enqueue(command) {
|
|
24
|
+
const controller = new AbortController();
|
|
25
|
+
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
26
|
+
try {
|
|
27
|
+
const res = await fetch(`${this.gatewayUrl}/enqueue`, {
|
|
28
|
+
method: "POST",
|
|
29
|
+
headers: this.headers,
|
|
30
|
+
body: JSON.stringify(command),
|
|
31
|
+
signal: controller.signal
|
|
32
|
+
});
|
|
33
|
+
if (!res.ok) {
|
|
34
|
+
throw new Error(`[BrowserExecutionClient] Enqueue failed: HTTP ${res.status}`);
|
|
35
|
+
}
|
|
36
|
+
const data = await res.json();
|
|
37
|
+
return {
|
|
38
|
+
jobId: data.jobId || command.id,
|
|
39
|
+
correlationId: command.correlationId
|
|
40
|
+
};
|
|
41
|
+
} finally {
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async checkStatus(jobId) {
|
|
46
|
+
const res = await fetch(`${this.gatewayUrl}/status/${encodeURIComponent(jobId)}`, {
|
|
47
|
+
method: "GET",
|
|
48
|
+
headers: this.headers
|
|
49
|
+
});
|
|
50
|
+
if (!res.ok) {
|
|
51
|
+
throw new Error(`[BrowserExecutionClient] Check status failed: HTTP ${res.status}`);
|
|
52
|
+
}
|
|
53
|
+
return await res.json();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
function createBrowserExecutionClient(options) {
|
|
57
|
+
return new BrowserExecutionClient(options);
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
BrowserExecutionClient,
|
|
61
|
+
createBrowserExecutionClient
|
|
62
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kloks/client",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Kloks Browser-Safe Execution Client & Shared Contracts with Zero Server Closure",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": false,
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public",
|
|
9
|
+
"registry": "https://registry.npmjs.org/"
|
|
10
|
+
},
|
|
11
|
+
"skipoManifest": "./kloks.manifest.json",
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"module": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsup src/index.ts --format esm --dts --clean --external react --external zod",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"clean": "rm -rf dist"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"zod": "^3.24.1"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependenciesMeta": {
|
|
34
|
+
"react": {
|
|
35
|
+
"optional": true
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@ultrst-armada/krnl": "^1.0.2"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
// ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.
|
|
2
|
-
import { WebSocketServer, WebSocket } from "ws";
|
|
1
|
+
// ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.2/node_modules/@ultrst-armada/krnl/packages/core/dist/index.js
|
|
3
2
|
var ServiceStateStore = class {
|
|
4
3
|
state;
|
|
5
4
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.
|
|
1
|
+
// ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.2/node_modules/@ultrst-armada/krnl/packages/core/dist/index.js
|
|
2
2
|
import http from "http";
|
|
3
|
-
import { WebSocketServer, WebSocket } from "ws";
|
|
4
3
|
var ServiceStateStore = class {
|
|
5
4
|
state;
|
|
6
5
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -13,6 +13,16 @@ import {
|
|
|
13
13
|
SkipoExecutionEngine,
|
|
14
14
|
useCommand
|
|
15
15
|
} from "./chunk-ZTHBPV24.js";
|
|
16
|
+
import "./chunk-Q5I42UX7.js";
|
|
17
|
+
import {
|
|
18
|
+
LifecycleCycleError,
|
|
19
|
+
LifecycleGraph,
|
|
20
|
+
SKIPO_STATE,
|
|
21
|
+
SkipoStateEngine,
|
|
22
|
+
useLifecycleScope,
|
|
23
|
+
useSkipoBind,
|
|
24
|
+
useSkipoState
|
|
25
|
+
} from "./chunk-SHIBCPGQ.js";
|
|
16
26
|
import {
|
|
17
27
|
AttractionEngine,
|
|
18
28
|
GhostInferenceEngine,
|
|
@@ -29,16 +39,6 @@ import {
|
|
|
29
39
|
WireTypeRegistry,
|
|
30
40
|
initializeDefaultGraphRules
|
|
31
41
|
} from "./chunk-TZOL3RN7.js";
|
|
32
|
-
import "./chunk-Q5I42UX7.js";
|
|
33
|
-
import {
|
|
34
|
-
LifecycleCycleError,
|
|
35
|
-
LifecycleGraph,
|
|
36
|
-
SKIPO_STATE,
|
|
37
|
-
SkipoStateEngine,
|
|
38
|
-
useLifecycleScope,
|
|
39
|
-
useSkipoBind,
|
|
40
|
-
useSkipoState
|
|
41
|
-
} from "./chunk-SHIBCPGQ.js";
|
|
42
42
|
import {
|
|
43
43
|
CommandApi,
|
|
44
44
|
GhostStore,
|
|
@@ -68,8 +68,7 @@ import {
|
|
|
68
68
|
} from "./chunk-ISFNY7EZ.js";
|
|
69
69
|
import "./chunk-3RG5ZIWI.js";
|
|
70
70
|
|
|
71
|
-
// ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.
|
|
72
|
-
import { WebSocketServer, WebSocket } from "ws";
|
|
71
|
+
// ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.2/node_modules/@ultrst-armada/krnl/packages/core/dist/index.js
|
|
73
72
|
var ServiceStateStore = class {
|
|
74
73
|
state;
|
|
75
74
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
// src/workspace/WorkspaceFS.ts
|
|
2
|
-
import { SkipoBase } from "@ultrst-armada/kloks/functions";
|
|
3
|
-
var WorkspaceFS = class extends SkipoBase {
|
|
4
|
-
primary;
|
|
5
|
-
syncEngine;
|
|
6
|
-
config;
|
|
7
|
-
constructor(primary, config, syncEngine) {
|
|
8
|
-
super();
|
|
9
|
-
this.primary = primary;
|
|
10
|
-
this.config = config;
|
|
11
|
-
this.syncEngine = syncEngine;
|
|
12
|
-
}
|
|
13
|
-
setPrimary(newPrimary) {
|
|
14
|
-
this.primary = newPrimary;
|
|
15
|
-
}
|
|
16
|
-
setSyncEngine(engine) {
|
|
17
|
-
this.syncEngine = engine;
|
|
18
|
-
}
|
|
19
|
-
async exists(pathStr) {
|
|
20
|
-
return this.primary.exists(pathStr);
|
|
21
|
-
}
|
|
22
|
-
async stat(pathStr) {
|
|
23
|
-
return this.primary.stat(pathStr);
|
|
24
|
-
}
|
|
25
|
-
async list(pathStr = "") {
|
|
26
|
-
return this.primary.list(pathStr);
|
|
27
|
-
}
|
|
28
|
-
async read(pathStr) {
|
|
29
|
-
return this.primary.read(pathStr);
|
|
30
|
-
}
|
|
31
|
-
async readText(pathStr) {
|
|
32
|
-
const data = await this.read(pathStr);
|
|
33
|
-
return Buffer.from(data).toString("utf8");
|
|
34
|
-
}
|
|
35
|
-
async write(pathStr, data) {
|
|
36
|
-
await this.primary.write(pathStr, data);
|
|
37
|
-
if (this.syncEngine && this.config.sync?.enabled && this.config.sync.mode === "on_write") {
|
|
38
|
-
this.syncEngine.syncFile(pathStr).catch((err) => {
|
|
39
|
-
console.warn(`[WorkspaceFS] Async backup sync warning for '${pathStr}':`, err.message);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
async mkdir(pathStr) {
|
|
44
|
-
await this.primary.mkdir(pathStr);
|
|
45
|
-
}
|
|
46
|
-
async delete(pathStr) {
|
|
47
|
-
await this.primary.delete(pathStr);
|
|
48
|
-
if (this.syncEngine && this.config.sync?.enabled && this.config.sync.deletePropagation) {
|
|
49
|
-
this.syncEngine.deleteFile(pathStr).catch((err) => {
|
|
50
|
-
console.warn(`[WorkspaceFS] Async delete sync warning for '${pathStr}':`, err.message);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// src/workspace/SyncEngine.ts
|
|
57
|
-
import { SkipoBase as SkipoBase2 } from "@ultrst-armada/kloks/functions";
|
|
58
|
-
var SyncEngine = class extends SkipoBase2 {
|
|
59
|
-
primary;
|
|
60
|
-
backups;
|
|
61
|
-
config;
|
|
62
|
-
constructor(primary, backups, config) {
|
|
63
|
-
super({ name: "SyncEngine" });
|
|
64
|
-
this.primary = primary;
|
|
65
|
-
this.backups = backups;
|
|
66
|
-
this.config = config;
|
|
67
|
-
}
|
|
68
|
-
async syncFile(pathStr) {
|
|
69
|
-
const data = await this.primary.read(pathStr);
|
|
70
|
-
for (const backup of this.backups) {
|
|
71
|
-
try {
|
|
72
|
-
await backup.write(pathStr, data);
|
|
73
|
-
} catch (e) {
|
|
74
|
-
console.error(`[SyncEngine] Failed to sync ${pathStr} to backup:`, e.message);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
async deleteFile(pathStr) {
|
|
79
|
-
for (const backup of this.backups) {
|
|
80
|
-
try {
|
|
81
|
-
await backup.delete(pathStr);
|
|
82
|
-
} catch (e) {
|
|
83
|
-
console.error(`[SyncEngine] Failed to delete ${pathStr} on backup:`, e.message);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// src/workspace/WorkspaceCloneSyncEngine.ts
|
|
90
|
-
import { SkipoBase as SkipoBase3 } from "@ultrst-armada/kloks/functions";
|
|
91
|
-
var WorkspaceCloneSyncEngine = class extends SkipoBase3 {
|
|
92
|
-
constructor() {
|
|
93
|
-
super({ name: "WorkspaceCloneSyncEngine" });
|
|
94
|
-
}
|
|
95
|
-
async replicateToClones(files, clones, uploadFn) {
|
|
96
|
-
const results = [];
|
|
97
|
-
let totalSynced = 0;
|
|
98
|
-
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
99
|
-
for (const clone of clones) {
|
|
100
|
-
try {
|
|
101
|
-
let count = 0;
|
|
102
|
-
for (const file of files) {
|
|
103
|
-
await uploadFn(clone, file.relPath, file.content, file.contentType);
|
|
104
|
-
count++;
|
|
105
|
-
}
|
|
106
|
-
clone.lastSyncedAt = nowIso;
|
|
107
|
-
clone.filesSynced = count;
|
|
108
|
-
clone.status = "SYNCED";
|
|
109
|
-
results.push({ cloneId: clone.id, label: clone.label, provider: clone.provider, filesSynced: count, status: "SYNCED" });
|
|
110
|
-
totalSynced += count;
|
|
111
|
-
} catch (err) {
|
|
112
|
-
clone.status = "ERROR";
|
|
113
|
-
results.push({ cloneId: clone.id, label: clone.label, provider: clone.provider, filesSynced: 0, status: "ERROR", error: err.message });
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return { results, totalSynced };
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
export {
|
|
121
|
-
WorkspaceFS,
|
|
122
|
-
SyncEngine,
|
|
123
|
-
WorkspaceCloneSyncEngine
|
|
124
|
-
};
|