@awcp/sdk 0.0.0-dev-202601300724 → 0.0.0-dev-202601301521
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/bin/daemon.d.ts +9 -1
- package/dist/delegator/bin/daemon.d.ts.map +1 -1
- package/dist/delegator/bin/daemon.js +18 -7
- package/dist/delegator/bin/daemon.js.map +1 -1
- package/dist/delegator/config.d.ts +9 -71
- package/dist/delegator/config.d.ts.map +1 -1
- package/dist/delegator/config.js +1 -12
- package/dist/delegator/config.js.map +1 -1
- package/dist/delegator/export-manager.d.ts +27 -0
- package/dist/delegator/export-manager.d.ts.map +1 -0
- package/dist/delegator/export-manager.js +85 -0
- package/dist/delegator/export-manager.js.map +1 -0
- package/dist/delegator/index.d.ts +2 -2
- package/dist/delegator/index.d.ts.map +1 -1
- package/dist/delegator/index.js +3 -3
- package/dist/delegator/index.js.map +1 -1
- package/dist/delegator/service.d.ts +1 -69
- package/dist/delegator/service.d.ts.map +1 -1
- package/dist/delegator/service.js +15 -100
- package/dist/delegator/service.js.map +1 -1
- package/dist/executor/config.d.ts +11 -81
- package/dist/executor/config.d.ts.map +1 -1
- package/dist/executor/config.js +2 -9
- package/dist/executor/config.js.map +1 -1
- package/dist/executor/index.d.ts +2 -2
- package/dist/executor/index.d.ts.map +1 -1
- package/dist/executor/index.js +2 -2
- package/dist/executor/index.js.map +1 -1
- package/dist/executor/service.d.ts +3 -49
- package/dist/executor/service.d.ts.map +1 -1
- package/dist/executor/service.js +33 -112
- package/dist/executor/service.js.map +1 -1
- package/dist/executor/workspace-manager.d.ts +30 -0
- package/dist/executor/workspace-manager.d.ts.map +1 -0
- package/dist/executor/workspace-manager.js +75 -0
- package/dist/executor/workspace-manager.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
- package/dist/executor/policy.d.ts +0 -55
- package/dist/executor/policy.d.ts.map +0 -1
- package/dist/executor/policy.js +0 -100
- package/dist/executor/policy.js.map +0 -1
package/dist/executor/policy.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { mkdir, readdir, rm } from 'node:fs/promises';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
/**
|
|
4
|
-
* Default mount root directory
|
|
5
|
-
*/
|
|
6
|
-
const DEFAULT_MOUNT_ROOT = '/tmp/awcp/mounts';
|
|
7
|
-
/**
|
|
8
|
-
* Local Policy - Enforces security constraints on the Executor side.
|
|
9
|
-
*
|
|
10
|
-
* Security: startsWith(root) check prevents path traversal attacks.
|
|
11
|
-
*/
|
|
12
|
-
export class LocalPolicy {
|
|
13
|
-
config;
|
|
14
|
-
allocatedMounts = new Set();
|
|
15
|
-
constructor(config) {
|
|
16
|
-
this.config = config ?? {};
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Allocate a mount point for a delegation
|
|
20
|
-
*/
|
|
21
|
-
allocateMountPoint(delegationId) {
|
|
22
|
-
const root = this.config.mountRoot ?? DEFAULT_MOUNT_ROOT;
|
|
23
|
-
const mountPoint = join(root, delegationId);
|
|
24
|
-
this.allocatedMounts.add(mountPoint);
|
|
25
|
-
return mountPoint;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Validate that a mount point is safe to use
|
|
29
|
-
*/
|
|
30
|
-
async validateMountPoint(mountPoint) {
|
|
31
|
-
const root = this.config.mountRoot ?? DEFAULT_MOUNT_ROOT;
|
|
32
|
-
if (!mountPoint.startsWith(root)) {
|
|
33
|
-
return {
|
|
34
|
-
valid: false,
|
|
35
|
-
reason: `Mount point must be under ${root}`,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
return { valid: true };
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Prepare a mount point (create directory, ensure empty)
|
|
42
|
-
*/
|
|
43
|
-
async prepareMountPoint(mountPoint) {
|
|
44
|
-
await mkdir(mountPoint, { recursive: true });
|
|
45
|
-
const entries = await readdir(mountPoint);
|
|
46
|
-
if (entries.length > 0) {
|
|
47
|
-
throw new Error(`Mount point ${mountPoint} is not empty`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Release a mount point and remove the directory
|
|
52
|
-
*/
|
|
53
|
-
async releaseMountPoint(mountPoint) {
|
|
54
|
-
this.allocatedMounts.delete(mountPoint);
|
|
55
|
-
try {
|
|
56
|
-
await rm(mountPoint, { recursive: true, force: true });
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
// Ignore errors - directory may already be gone
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Cleanup stale mount directories from previous runs
|
|
64
|
-
*/
|
|
65
|
-
async cleanupStaleMounts() {
|
|
66
|
-
const root = this.config.mountRoot ?? DEFAULT_MOUNT_ROOT;
|
|
67
|
-
let cleaned = 0;
|
|
68
|
-
try {
|
|
69
|
-
const entries = await readdir(root, { withFileTypes: true });
|
|
70
|
-
for (const entry of entries) {
|
|
71
|
-
if (entry.isDirectory()) {
|
|
72
|
-
const mountPath = join(root, entry.name);
|
|
73
|
-
// Only clean directories not currently allocated
|
|
74
|
-
if (!this.allocatedMounts.has(mountPath)) {
|
|
75
|
-
await rm(mountPath, { recursive: true, force: true });
|
|
76
|
-
cleaned++;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
// Root directory may not exist yet
|
|
83
|
-
}
|
|
84
|
-
return cleaned;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Check if concurrent limit is reached
|
|
88
|
-
*/
|
|
89
|
-
canAcceptMore() {
|
|
90
|
-
const max = this.config.maxConcurrent ?? Infinity;
|
|
91
|
-
return this.allocatedMounts.size < max;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Get currently allocated mount points
|
|
95
|
-
*/
|
|
96
|
-
getAllocatedMounts() {
|
|
97
|
-
return Array.from(this.allocatedMounts);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=policy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/executor/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAsBjC;;GAEG;AACH,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAE9C;;;;GAIG;AACH,MAAM,OAAO,WAAW;IACd,MAAM,CAAe;IACrB,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAE5C,YAAY,MAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,kBAAkB,CAAC,YAAoB;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,kBAAkB,CAAC;QACzD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC5C,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACrC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB,CAAC,UAAkB;QACzC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,kBAAkB,CAAC;QAEzD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,6BAA6B,IAAI,EAAE;aAC5C,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACzB,CAAC;IAED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