@awcp/sdk 0.0.0-dev-202601300724
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/dist/delegator/admission.d.ts +49 -0
- package/dist/delegator/admission.d.ts.map +1 -0
- package/dist/delegator/admission.js +117 -0
- package/dist/delegator/admission.js.map +1 -0
- package/dist/delegator/bin/client.d.ts +102 -0
- package/dist/delegator/bin/client.d.ts.map +1 -0
- package/dist/delegator/bin/client.js +116 -0
- package/dist/delegator/bin/client.js.map +1 -0
- package/dist/delegator/bin/daemon.d.ts +78 -0
- package/dist/delegator/bin/daemon.d.ts.map +1 -0
- package/dist/delegator/bin/daemon.js +245 -0
- package/dist/delegator/bin/daemon.js.map +1 -0
- package/dist/delegator/config.d.ts +168 -0
- package/dist/delegator/config.d.ts.map +1 -0
- package/dist/delegator/config.js +54 -0
- package/dist/delegator/config.js.map +1 -0
- package/dist/delegator/executor-client.d.ts +36 -0
- package/dist/delegator/executor-client.d.ts.map +1 -0
- package/dist/delegator/executor-client.js +77 -0
- package/dist/delegator/executor-client.js.map +1 -0
- package/dist/delegator/export-view.d.ts +43 -0
- package/dist/delegator/export-view.d.ts.map +1 -0
- package/dist/delegator/export-view.js +108 -0
- package/dist/delegator/export-view.js.map +1 -0
- package/dist/delegator/index.d.ts +8 -0
- package/dist/delegator/index.d.ts.map +1 -0
- package/dist/delegator/index.js +11 -0
- package/dist/delegator/index.js.map +1 -0
- package/dist/delegator/service.d.ts +120 -0
- package/dist/delegator/service.d.ts.map +1 -0
- package/dist/delegator/service.js +323 -0
- package/dist/delegator/service.js.map +1 -0
- package/dist/executor/config.d.ts +126 -0
- package/dist/executor/config.d.ts.map +1 -0
- package/dist/executor/config.js +38 -0
- package/dist/executor/config.js.map +1 -0
- package/dist/executor/delegator-client.d.ts +18 -0
- package/dist/executor/delegator-client.d.ts.map +1 -0
- package/dist/executor/delegator-client.js +37 -0
- package/dist/executor/delegator-client.js.map +1 -0
- package/dist/executor/index.d.ts +5 -0
- package/dist/executor/index.d.ts.map +1 -0
- package/dist/executor/index.js +7 -0
- package/dist/executor/index.js.map +1 -0
- package/dist/executor/policy.d.ts +55 -0
- package/dist/executor/policy.d.ts.map +1 -0
- package/dist/executor/policy.js +100 -0
- package/dist/executor/policy.js.map +1 -0
- package/dist/executor/service.d.ts +84 -0
- package/dist/executor/service.d.ts.map +1 -0
- package/dist/executor/service.js +322 -0
- package/dist/executor/service.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/server/express/awcp-delegator-handler.d.ts +67 -0
- package/dist/server/express/awcp-delegator-handler.d.ts.map +1 -0
- package/dist/server/express/awcp-delegator-handler.js +99 -0
- package/dist/server/express/awcp-delegator-handler.js.map +1 -0
- package/dist/server/express/awcp-executor-handler.d.ts +47 -0
- package/dist/server/express/awcp-executor-handler.d.ts.map +1 -0
- package/dist/server/express/awcp-executor-handler.js +104 -0
- package/dist/server/express/awcp-executor-handler.js.map +1 -0
- package/dist/server/express/index.d.ts +6 -0
- package/dist/server/express/index.d.ts.map +1 -0
- package/dist/server/express/index.js +8 -0
- package/dist/server/express/index.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { mkdir, rm, symlink, readdir } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Default export base directory
|
|
5
|
+
*/
|
|
6
|
+
const DEFAULT_EXPORT_BASE = '/tmp/awcp/exports';
|
|
7
|
+
/**
|
|
8
|
+
* Export View Manager
|
|
9
|
+
*
|
|
10
|
+
* Creates isolated export views for each delegation.
|
|
11
|
+
* This prevents exposing real paths and enables cleanup.
|
|
12
|
+
*/
|
|
13
|
+
export class ExportViewManager {
|
|
14
|
+
config;
|
|
15
|
+
exports = new Map();
|
|
16
|
+
constructor(config) {
|
|
17
|
+
this.config = config ?? {};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create an export view for a delegation
|
|
21
|
+
*
|
|
22
|
+
* @returns The path to the export view (with trailing slash for SSHFS symlink compatibility)
|
|
23
|
+
*/
|
|
24
|
+
async create(delegationId, localDir) {
|
|
25
|
+
const baseDir = this.config.baseDir ?? DEFAULT_EXPORT_BASE;
|
|
26
|
+
const exportPath = join(baseDir, delegationId, 'workspace');
|
|
27
|
+
// Create export directory structure
|
|
28
|
+
await mkdir(join(baseDir, delegationId), { recursive: true });
|
|
29
|
+
// Create the export view based on strategy
|
|
30
|
+
const strategy = this.config.strategy ?? 'symlink';
|
|
31
|
+
switch (strategy) {
|
|
32
|
+
case 'symlink':
|
|
33
|
+
await symlink(localDir, exportPath);
|
|
34
|
+
break;
|
|
35
|
+
case 'bind':
|
|
36
|
+
// Bind mount - requires root/sudo
|
|
37
|
+
console.warn('Bind mount not implemented, falling back to symlink');
|
|
38
|
+
await symlink(localDir, exportPath);
|
|
39
|
+
break;
|
|
40
|
+
case 'worktree':
|
|
41
|
+
// Git worktree - requires git repo
|
|
42
|
+
console.warn('Git worktree not implemented, falling back to symlink');
|
|
43
|
+
await symlink(localDir, exportPath);
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
this.exports.set(delegationId, exportPath);
|
|
47
|
+
// Return path with trailing slash for SSHFS symlink compatibility
|
|
48
|
+
// See: https://github.com/libfuse/sshfs/issues/312
|
|
49
|
+
return exportPath + '/';
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Cleanup an export view
|
|
53
|
+
*/
|
|
54
|
+
async cleanup(delegationId) {
|
|
55
|
+
const exportPath = this.exports.get(delegationId);
|
|
56
|
+
if (!exportPath) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const baseDir = this.config.baseDir ?? DEFAULT_EXPORT_BASE;
|
|
61
|
+
const delegationDir = join(baseDir, delegationId);
|
|
62
|
+
await rm(delegationDir, { recursive: true, force: true });
|
|
63
|
+
this.exports.delete(delegationId);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.error(`Failed to cleanup export view for ${delegationId}:`, error);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get the export path for a delegation
|
|
71
|
+
*/
|
|
72
|
+
getExportPath(delegationId) {
|
|
73
|
+
return this.exports.get(delegationId);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Cleanup all export views
|
|
77
|
+
*/
|
|
78
|
+
async cleanupAll() {
|
|
79
|
+
for (const delegationId of this.exports.keys()) {
|
|
80
|
+
await this.cleanup(delegationId);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Cleanup stale export directories from previous runs
|
|
85
|
+
*/
|
|
86
|
+
async cleanupStaleExports() {
|
|
87
|
+
const baseDir = this.config.baseDir ?? DEFAULT_EXPORT_BASE;
|
|
88
|
+
let cleaned = 0;
|
|
89
|
+
try {
|
|
90
|
+
const entries = await readdir(baseDir, { withFileTypes: true });
|
|
91
|
+
for (const entry of entries) {
|
|
92
|
+
if (entry.isDirectory()) {
|
|
93
|
+
const delegationId = entry.name;
|
|
94
|
+
// Only clean directories not currently tracked
|
|
95
|
+
if (!this.exports.has(delegationId)) {
|
|
96
|
+
await rm(join(baseDir, delegationId), { recursive: true, force: true });
|
|
97
|
+
cleaned++;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// Base directory may not exist yet
|
|
104
|
+
}
|
|
105
|
+
return cleaned;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=export-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-view.js","sourceRoot":"","sources":["../../src/delegator/export-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,OAA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B,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;YAChE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC5B,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;oBACxB,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC;oBAChC,+CAA+C;oBAC/C,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;wBACpC,MAAM,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;wBACxE,OAAO,EAAE,CAAC;oBACZ,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,mCAAmC;QACrC,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { DelegatorService, type DelegatorServiceOptions, type DelegateParams, type DelegatorServiceStatus, } from './service.js';
|
|
2
|
+
export { type DelegatorConfig, type ExportConfig, type SshConfig, type AdmissionConfig as DelegatorAdmissionConfig, type DelegationDefaults, type DelegatorHooks, type ResolvedDelegatorConfig, DEFAULT_DELEGATOR_CONFIG, resolveDelegatorConfig, } from './config.js';
|
|
3
|
+
export { startDelegatorDaemon, type DaemonConfig, type DaemonInstance, } from './bin/daemon.js';
|
|
4
|
+
export { DelegatorDaemonClient, type DelegateRequest, type DelegateResponse, type ListDelegationsResponse, } from './bin/client.js';
|
|
5
|
+
export { AdmissionController, type AdmissionConfig, type AdmissionResult, type WorkspaceStats } from './admission.js';
|
|
6
|
+
export { ExportViewManager } from './export-view.js';
|
|
7
|
+
export { ExecutorClient, type InviteResponse } from './executor-client.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/delegator/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,sBAAsB,GAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,eAAe,IAAI,wBAAwB,EAChD,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,oBAAoB,EACpB,KAAK,YAAY,EACjB,KAAK,cAAc,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,GAC7B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACtH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// High-level API
|
|
2
|
+
export { DelegatorService, } from './service.js';
|
|
3
|
+
export { DEFAULT_DELEGATOR_CONFIG, resolveDelegatorConfig, } from './config.js';
|
|
4
|
+
// Daemon mode (for running as independent process)
|
|
5
|
+
export { startDelegatorDaemon, } from './bin/daemon.js';
|
|
6
|
+
export { DelegatorDaemonClient, } from './bin/client.js';
|
|
7
|
+
// Utilities (can be used independently)
|
|
8
|
+
export { AdmissionController } from './admission.js';
|
|
9
|
+
export { ExportViewManager } from './export-view.js';
|
|
10
|
+
export { ExecutorClient } from './executor-client.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/delegator/index.ts"],"names":[],"mappings":"AAAA,iBAAiB;AACjB,OAAO,EACL,gBAAgB,GAIjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAQL,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAErB,mDAAmD;AACnD,OAAO,EACL,oBAAoB,GAGrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qBAAqB,GAItB,MAAM,iBAAiB,CAAC;AAEzB,wCAAwC;AACxC,OAAO,EAAE,mBAAmB,EAAmE,MAAM,gBAAgB,CAAC;AACtH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAuB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWCP Delegator Service
|
|
3
|
+
*
|
|
4
|
+
* Manages the AWCP delegation protocol on the Delegator side.
|
|
5
|
+
* Integrates credential management and export view creation.
|
|
6
|
+
*/
|
|
7
|
+
import { type Delegation, type TaskSpec, type AcceptMessage, type DoneMessage, type ErrorMessage, type AwcpMessage, type AccessMode, type AuthCredential } from '@awcp/core';
|
|
8
|
+
import { type DelegatorConfig } from './config.js';
|
|
9
|
+
/**
|
|
10
|
+
* Parameters for creating a delegation
|
|
11
|
+
*/
|
|
12
|
+
export interface DelegateParams {
|
|
13
|
+
/** URL of the Executor's AWCP endpoint */
|
|
14
|
+
executorUrl: string;
|
|
15
|
+
/** Local directory to delegate */
|
|
16
|
+
localDir: string;
|
|
17
|
+
/** Task specification */
|
|
18
|
+
task: TaskSpec;
|
|
19
|
+
/** TTL in seconds (uses default if not specified) */
|
|
20
|
+
ttlSeconds?: number;
|
|
21
|
+
/** Access mode (uses default if not specified) */
|
|
22
|
+
accessMode?: AccessMode;
|
|
23
|
+
/**
|
|
24
|
+
* Optional authentication for paid/restricted Executor services.
|
|
25
|
+
* This will be included in the INVITE message.
|
|
26
|
+
*/
|
|
27
|
+
auth?: AuthCredential;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Service status
|
|
31
|
+
*/
|
|
32
|
+
export interface DelegatorServiceStatus {
|
|
33
|
+
activeDelegations: number;
|
|
34
|
+
delegations: Array<{
|
|
35
|
+
id: string;
|
|
36
|
+
state: string;
|
|
37
|
+
executorUrl: string;
|
|
38
|
+
localDir: string;
|
|
39
|
+
createdAt: string;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Options for creating the service
|
|
44
|
+
*/
|
|
45
|
+
export interface DelegatorServiceOptions {
|
|
46
|
+
/** AWCP Delegator configuration */
|
|
47
|
+
config: DelegatorConfig;
|
|
48
|
+
/** Callback URL where Executor will send ACCEPT/DONE/ERROR */
|
|
49
|
+
callbackUrl: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* AWCP Delegator Service
|
|
53
|
+
*
|
|
54
|
+
* Manages the AWCP delegation lifecycle from the Delegator side:
|
|
55
|
+
* 1. Creates export view for workspace
|
|
56
|
+
* 2. Sends INVITE to Executor
|
|
57
|
+
* 3. Receives ACCEPT, generates credentials
|
|
58
|
+
* 4. Sends START with credentials
|
|
59
|
+
* 5. Receives DONE/ERROR, cleans up
|
|
60
|
+
*/
|
|
61
|
+
export declare class DelegatorService {
|
|
62
|
+
private config;
|
|
63
|
+
private callbackUrl;
|
|
64
|
+
private admissionController;
|
|
65
|
+
private exportManager;
|
|
66
|
+
private credentialManager;
|
|
67
|
+
private executorClient;
|
|
68
|
+
private delegations;
|
|
69
|
+
private stateMachines;
|
|
70
|
+
private executorUrls;
|
|
71
|
+
constructor(options: DelegatorServiceOptions);
|
|
72
|
+
/**
|
|
73
|
+
* Create a new delegation
|
|
74
|
+
*
|
|
75
|
+
* This sends an INVITE to the Executor and waits for ACCEPT.
|
|
76
|
+
* After ACCEPT, it automatically sends START with credentials.
|
|
77
|
+
*
|
|
78
|
+
* @returns The delegation ID
|
|
79
|
+
*/
|
|
80
|
+
delegate(params: DelegateParams): Promise<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Handle ACCEPT message from Executor
|
|
83
|
+
*
|
|
84
|
+
* This is called internally after INVITE, or externally via the Express handler.
|
|
85
|
+
*/
|
|
86
|
+
handleAccept(message: AcceptMessage): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Handle DONE message from Executor
|
|
89
|
+
*/
|
|
90
|
+
handleDone(message: DoneMessage): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Handle ERROR message from Executor
|
|
93
|
+
*/
|
|
94
|
+
handleError(message: ErrorMessage): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Handle incoming message from Executor
|
|
97
|
+
*/
|
|
98
|
+
handleMessage(message: AwcpMessage): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Cancel a delegation
|
|
101
|
+
*/
|
|
102
|
+
cancel(delegationId: string): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Get delegation status
|
|
105
|
+
*/
|
|
106
|
+
getDelegation(delegationId: string): Delegation | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Wait for delegation to complete
|
|
109
|
+
*/
|
|
110
|
+
waitForCompletion(delegationId: string, timeoutMs?: number): Promise<Delegation>;
|
|
111
|
+
/**
|
|
112
|
+
* Get service status
|
|
113
|
+
*/
|
|
114
|
+
getStatus(): DelegatorServiceStatus;
|
|
115
|
+
/**
|
|
116
|
+
* Cleanup resources for a delegation
|
|
117
|
+
*/
|
|
118
|
+
private cleanup;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/delegator/service.ts"],"names":[],"mappings":"AAAA;;;;;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WAAW,CAAiC;IACpD,OAAO,CAAC,aAAa,CAA6C;IAClE,OAAO,CAAC,YAAY,CAA6B;gBAErC,OAAO,EAAE,uBAAuB;IA2B5C;;;;;;;OAOG;IACG,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAwFvD;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IA+DzD;;OAEG;IACG,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAgCrD;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IA4BvD;;OAEG;IACG,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBxD;;OAEG;IACG,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBjD;;OAEG;IACH,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAI3D;;OAEG;IACG,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,GAAE,MAAc,GAAG,OAAO,CAAC,UAAU,CAAC;IA6B7F;;OAEG;IACH,SAAS,IAAI,sBAAsB;IAanC;;OAEG;YACW,OAAO;CAKtB"}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWCP Delegator Service
|
|
3
|
+
*
|
|
4
|
+
* Manages the AWCP delegation protocol on the Delegator side.
|
|
5
|
+
* Integrates credential management and export view creation.
|
|
6
|
+
*/
|
|
7
|
+
import { randomUUID } from 'node:crypto';
|
|
8
|
+
import { CredentialManager } from '@awcp/transport-sshfs';
|
|
9
|
+
import { DelegationStateMachine, createDelegation, applyMessageToDelegation, PROTOCOL_VERSION, AwcpError, WorkspaceTooLargeError, } from '@awcp/core';
|
|
10
|
+
import { resolveDelegatorConfig } from './config.js';
|
|
11
|
+
import { AdmissionController } from './admission.js';
|
|
12
|
+
import { ExportViewManager } from './export-view.js';
|
|
13
|
+
import { ExecutorClient } from './executor-client.js';
|
|
14
|
+
/**
|
|
15
|
+
* AWCP Delegator Service
|
|
16
|
+
*
|
|
17
|
+
* Manages the AWCP delegation lifecycle from the Delegator side:
|
|
18
|
+
* 1. Creates export view for workspace
|
|
19
|
+
* 2. Sends INVITE to Executor
|
|
20
|
+
* 3. Receives ACCEPT, generates credentials
|
|
21
|
+
* 4. Sends START with credentials
|
|
22
|
+
* 5. Receives DONE/ERROR, cleans up
|
|
23
|
+
*/
|
|
24
|
+
export class DelegatorService {
|
|
25
|
+
config;
|
|
26
|
+
callbackUrl;
|
|
27
|
+
admissionController;
|
|
28
|
+
exportManager;
|
|
29
|
+
credentialManager;
|
|
30
|
+
executorClient;
|
|
31
|
+
delegations = new Map();
|
|
32
|
+
stateMachines = new Map();
|
|
33
|
+
executorUrls = new Map(); // delegationId -> executorUrl
|
|
34
|
+
constructor(options) {
|
|
35
|
+
this.config = resolveDelegatorConfig(options.config);
|
|
36
|
+
this.callbackUrl = options.callbackUrl;
|
|
37
|
+
this.admissionController = new AdmissionController({
|
|
38
|
+
maxTotalBytes: this.config.admission.maxTotalBytes,
|
|
39
|
+
maxFileCount: this.config.admission.maxFileCount,
|
|
40
|
+
maxSingleFileBytes: this.config.admission.maxSingleFileBytes,
|
|
41
|
+
});
|
|
42
|
+
this.exportManager = new ExportViewManager({
|
|
43
|
+
baseDir: this.config.export.baseDir,
|
|
44
|
+
strategy: this.config.export.strategy,
|
|
45
|
+
});
|
|
46
|
+
this.credentialManager = new CredentialManager({
|
|
47
|
+
keyDir: this.config.ssh.keyDir,
|
|
48
|
+
sshHost: this.config.ssh.host,
|
|
49
|
+
sshPort: this.config.ssh.port,
|
|
50
|
+
sshUser: this.config.ssh.user,
|
|
51
|
+
});
|
|
52
|
+
this.executorClient = new ExecutorClient({
|
|
53
|
+
callbackUrl: this.callbackUrl,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create a new delegation
|
|
58
|
+
*
|
|
59
|
+
* This sends an INVITE to the Executor and waits for ACCEPT.
|
|
60
|
+
* After ACCEPT, it automatically sends START with credentials.
|
|
61
|
+
*
|
|
62
|
+
* @returns The delegation ID
|
|
63
|
+
*/
|
|
64
|
+
async delegate(params) {
|
|
65
|
+
const delegationId = randomUUID();
|
|
66
|
+
// Step 1: Admission Control
|
|
67
|
+
const admissionResult = await this.admissionController.check(params.localDir);
|
|
68
|
+
if (!admissionResult.allowed) {
|
|
69
|
+
throw new WorkspaceTooLargeError(admissionResult.stats ?? {}, admissionResult.hint, delegationId);
|
|
70
|
+
}
|
|
71
|
+
// Step 2: Create delegation record
|
|
72
|
+
const ttlSeconds = params.ttlSeconds ?? this.config.defaults.ttlSeconds;
|
|
73
|
+
const accessMode = params.accessMode ?? this.config.defaults.accessMode;
|
|
74
|
+
const delegation = createDelegation({
|
|
75
|
+
id: delegationId,
|
|
76
|
+
peerUrl: params.executorUrl,
|
|
77
|
+
localDir: params.localDir,
|
|
78
|
+
task: params.task,
|
|
79
|
+
leaseConfig: { ttlSeconds, accessMode },
|
|
80
|
+
});
|
|
81
|
+
// Step 3: Create export view
|
|
82
|
+
const exportPath = await this.exportManager.create(delegationId, params.localDir);
|
|
83
|
+
delegation.exportPath = exportPath;
|
|
84
|
+
// Step 4: Initialize state machine
|
|
85
|
+
const stateMachine = new DelegationStateMachine();
|
|
86
|
+
// Step 5: Store delegation
|
|
87
|
+
this.delegations.set(delegationId, delegation);
|
|
88
|
+
this.stateMachines.set(delegationId, stateMachine);
|
|
89
|
+
this.executorUrls.set(delegationId, params.executorUrl);
|
|
90
|
+
// Step 6: Build and send INVITE
|
|
91
|
+
const inviteMessage = {
|
|
92
|
+
version: PROTOCOL_VERSION,
|
|
93
|
+
type: 'INVITE',
|
|
94
|
+
delegationId,
|
|
95
|
+
task: params.task,
|
|
96
|
+
lease: { ttlSeconds, accessMode },
|
|
97
|
+
workspace: {
|
|
98
|
+
exportName: `awcp/${delegationId}`,
|
|
99
|
+
},
|
|
100
|
+
requirements: {
|
|
101
|
+
transport: 'sshfs',
|
|
102
|
+
},
|
|
103
|
+
// Include auth if provided (for paid/restricted Executor services)
|
|
104
|
+
...(params.auth && { auth: params.auth }),
|
|
105
|
+
};
|
|
106
|
+
// Transition state
|
|
107
|
+
stateMachine.transition({ type: 'SEND_INVITE', message: inviteMessage });
|
|
108
|
+
delegation.state = stateMachine.getState();
|
|
109
|
+
delegation.updatedAt = new Date().toISOString();
|
|
110
|
+
try {
|
|
111
|
+
// Send INVITE and get response (ACCEPT or ERROR)
|
|
112
|
+
const response = await this.executorClient.sendInvite(params.executorUrl, inviteMessage);
|
|
113
|
+
if (response.type === 'ERROR') {
|
|
114
|
+
// Executor rejected
|
|
115
|
+
await this.handleError(response);
|
|
116
|
+
throw new AwcpError(response.code, response.message, response.hint, delegationId);
|
|
117
|
+
}
|
|
118
|
+
// Got ACCEPT - process it
|
|
119
|
+
await this.handleAccept(response);
|
|
120
|
+
// Call hook
|
|
121
|
+
this.config.hooks.onDelegationCreated?.(delegation);
|
|
122
|
+
return delegationId;
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
// Cleanup on error
|
|
126
|
+
await this.cleanup(delegationId);
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Handle ACCEPT message from Executor
|
|
132
|
+
*
|
|
133
|
+
* This is called internally after INVITE, or externally via the Express handler.
|
|
134
|
+
*/
|
|
135
|
+
async handleAccept(message) {
|
|
136
|
+
const delegation = this.delegations.get(message.delegationId);
|
|
137
|
+
if (!delegation) {
|
|
138
|
+
console.warn(`[AWCP Delegator] Unknown delegation for ACCEPT: ${message.delegationId}`);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const stateMachine = this.stateMachines.get(message.delegationId);
|
|
142
|
+
const executorUrl = this.executorUrls.get(message.delegationId);
|
|
143
|
+
// Transition state
|
|
144
|
+
const result = stateMachine.transition({ type: 'RECEIVE_ACCEPT', message });
|
|
145
|
+
if (!result.success) {
|
|
146
|
+
console.error(`[AWCP Delegator] State transition failed: ${result.error}`);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
// Update delegation
|
|
150
|
+
const updated = applyMessageToDelegation(delegation, message);
|
|
151
|
+
updated.state = stateMachine.getState();
|
|
152
|
+
this.delegations.set(delegation.id, updated);
|
|
153
|
+
// Generate credentials
|
|
154
|
+
const { credential, endpoint } = await this.credentialManager.generateCredential(delegation.id, delegation.leaseConfig.ttlSeconds);
|
|
155
|
+
const expiresAt = new Date(Date.now() + delegation.leaseConfig.ttlSeconds * 1000).toISOString();
|
|
156
|
+
// Build START message
|
|
157
|
+
const startMessage = {
|
|
158
|
+
version: PROTOCOL_VERSION,
|
|
159
|
+
type: 'START',
|
|
160
|
+
delegationId: delegation.id,
|
|
161
|
+
lease: {
|
|
162
|
+
expiresAt,
|
|
163
|
+
accessMode: delegation.leaseConfig.accessMode,
|
|
164
|
+
},
|
|
165
|
+
mount: {
|
|
166
|
+
transport: 'sshfs',
|
|
167
|
+
endpoint,
|
|
168
|
+
exportLocator: updated.exportPath,
|
|
169
|
+
credential,
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
// Transition to started
|
|
173
|
+
stateMachine.transition({ type: 'SEND_START', message: startMessage });
|
|
174
|
+
updated.state = stateMachine.getState();
|
|
175
|
+
updated.activeLease = startMessage.lease;
|
|
176
|
+
updated.updatedAt = new Date().toISOString();
|
|
177
|
+
this.delegations.set(delegation.id, updated);
|
|
178
|
+
// Send START
|
|
179
|
+
await this.executorClient.sendStart(executorUrl, startMessage);
|
|
180
|
+
// Call hook
|
|
181
|
+
this.config.hooks.onDelegationStarted?.(updated);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Handle DONE message from Executor
|
|
185
|
+
*/
|
|
186
|
+
async handleDone(message) {
|
|
187
|
+
const delegation = this.delegations.get(message.delegationId);
|
|
188
|
+
if (!delegation) {
|
|
189
|
+
console.warn(`[AWCP Delegator] Unknown delegation for DONE: ${message.delegationId}`);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const stateMachine = this.stateMachines.get(message.delegationId);
|
|
193
|
+
// Transition through 'running' if needed
|
|
194
|
+
if (stateMachine.getState() === 'started') {
|
|
195
|
+
stateMachine.transition({ type: 'MOUNT_COMPLETE' });
|
|
196
|
+
}
|
|
197
|
+
const result = stateMachine.transition({ type: 'RECEIVE_DONE', message });
|
|
198
|
+
if (!result.success) {
|
|
199
|
+
console.error(`[AWCP Delegator] State transition failed: ${result.error}`);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
// Update delegation
|
|
203
|
+
const updated = applyMessageToDelegation(delegation, message);
|
|
204
|
+
updated.state = stateMachine.getState();
|
|
205
|
+
this.delegations.set(delegation.id, updated);
|
|
206
|
+
// Cleanup
|
|
207
|
+
await this.cleanup(delegation.id);
|
|
208
|
+
// Call hook
|
|
209
|
+
this.config.hooks.onDelegationCompleted?.(updated);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Handle ERROR message from Executor
|
|
213
|
+
*/
|
|
214
|
+
async handleError(message) {
|
|
215
|
+
const delegation = this.delegations.get(message.delegationId);
|
|
216
|
+
if (!delegation) {
|
|
217
|
+
console.warn(`[AWCP Delegator] Unknown delegation for ERROR: ${message.delegationId}`);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const stateMachine = this.stateMachines.get(message.delegationId);
|
|
221
|
+
stateMachine.transition({ type: 'RECEIVE_ERROR', message });
|
|
222
|
+
// Update delegation
|
|
223
|
+
const updated = applyMessageToDelegation(delegation, message);
|
|
224
|
+
updated.state = stateMachine.getState();
|
|
225
|
+
this.delegations.set(delegation.id, updated);
|
|
226
|
+
// Cleanup
|
|
227
|
+
await this.cleanup(delegation.id);
|
|
228
|
+
// Call hook
|
|
229
|
+
const error = new AwcpError(message.code, message.message, message.hint, delegation.id);
|
|
230
|
+
this.config.hooks.onError?.(delegation.id, error);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Handle incoming message from Executor
|
|
234
|
+
*/
|
|
235
|
+
async handleMessage(message) {
|
|
236
|
+
switch (message.type) {
|
|
237
|
+
case 'ACCEPT':
|
|
238
|
+
await this.handleAccept(message);
|
|
239
|
+
break;
|
|
240
|
+
case 'DONE':
|
|
241
|
+
await this.handleDone(message);
|
|
242
|
+
break;
|
|
243
|
+
case 'ERROR':
|
|
244
|
+
await this.handleError(message);
|
|
245
|
+
break;
|
|
246
|
+
default:
|
|
247
|
+
console.warn(`[AWCP Delegator] Unexpected message type: ${message.type}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Cancel a delegation
|
|
252
|
+
*/
|
|
253
|
+
async cancel(delegationId) {
|
|
254
|
+
const delegation = this.delegations.get(delegationId);
|
|
255
|
+
if (!delegation) {
|
|
256
|
+
throw new Error(`Unknown delegation: ${delegationId}`);
|
|
257
|
+
}
|
|
258
|
+
const stateMachine = this.stateMachines.get(delegationId);
|
|
259
|
+
const executorUrl = this.executorUrls.get(delegationId);
|
|
260
|
+
const result = stateMachine.transition({ type: 'CANCEL' });
|
|
261
|
+
if (!result.success) {
|
|
262
|
+
throw new Error(`Cannot cancel delegation in state ${delegation.state}`);
|
|
263
|
+
}
|
|
264
|
+
// Request Executor to cancel (unmount) before we revoke keys
|
|
265
|
+
await this.executorClient.sendCancel(executorUrl, delegationId).catch(console.error);
|
|
266
|
+
// Now safe to cleanup (revoke SSH keys)
|
|
267
|
+
await this.cleanup(delegationId);
|
|
268
|
+
delegation.state = stateMachine.getState();
|
|
269
|
+
delegation.updatedAt = new Date().toISOString();
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Get delegation status
|
|
273
|
+
*/
|
|
274
|
+
getDelegation(delegationId) {
|
|
275
|
+
return this.delegations.get(delegationId);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Wait for delegation to complete
|
|
279
|
+
*/
|
|
280
|
+
async waitForCompletion(delegationId, timeoutMs = 60000) {
|
|
281
|
+
const startTime = Date.now();
|
|
282
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
283
|
+
const delegation = this.delegations.get(delegationId);
|
|
284
|
+
if (!delegation) {
|
|
285
|
+
throw new Error(`Unknown delegation: ${delegationId}`);
|
|
286
|
+
}
|
|
287
|
+
const stateMachine = this.stateMachines.get(delegationId);
|
|
288
|
+
if (stateMachine.isTerminal()) {
|
|
289
|
+
if (delegation.error) {
|
|
290
|
+
throw new AwcpError(delegation.error.code, delegation.error.message, delegation.error.hint, delegationId);
|
|
291
|
+
}
|
|
292
|
+
return delegation;
|
|
293
|
+
}
|
|
294
|
+
// Wait a bit before checking again
|
|
295
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
296
|
+
}
|
|
297
|
+
throw new Error('Timeout waiting for delegation to complete');
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Get service status
|
|
301
|
+
*/
|
|
302
|
+
getStatus() {
|
|
303
|
+
return {
|
|
304
|
+
activeDelegations: this.delegations.size,
|
|
305
|
+
delegations: Array.from(this.delegations.values()).map((d) => ({
|
|
306
|
+
id: d.id,
|
|
307
|
+
state: d.state,
|
|
308
|
+
executorUrl: d.peerUrl,
|
|
309
|
+
localDir: d.localDir,
|
|
310
|
+
createdAt: d.createdAt,
|
|
311
|
+
})),
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Cleanup resources for a delegation
|
|
316
|
+
*/
|
|
317
|
+
async cleanup(delegationId) {
|
|
318
|
+
await this.credentialManager.revokeCredential(delegationId);
|
|
319
|
+
await this.exportManager.cleanup(delegationId);
|
|
320
|
+
this.executorUrls.delete(delegationId);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
//# source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