@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/service.js
CHANGED
|
@@ -1,48 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AWCP Executor Service
|
|
3
|
-
*
|
|
4
|
-
* Handles the AWCP delegation protocol on the Executor (Collaborator) side.
|
|
5
|
-
* Integrates with A2A SDK executor for task execution.
|
|
6
3
|
*/
|
|
7
4
|
import { randomUUID } from 'node:crypto';
|
|
8
5
|
import { DefaultExecutionEventBus, } from '@a2a-js/sdk/server';
|
|
9
|
-
import { SshfsMountClient } from '@awcp/transport-sshfs';
|
|
10
6
|
import { PROTOCOL_VERSION, ErrorCodes, AwcpError, } from '@awcp/core';
|
|
11
7
|
import { resolveExecutorConfig } from './config.js';
|
|
12
|
-
import {
|
|
8
|
+
import { WorkspaceManager } from './workspace-manager.js';
|
|
13
9
|
import { DelegatorClient } from './delegator-client.js';
|
|
14
|
-
/**
|
|
15
|
-
* AWCP Executor Service
|
|
16
|
-
*
|
|
17
|
-
* Manages the AWCP delegation lifecycle:
|
|
18
|
-
* 1. Receives INVITE from Delegator
|
|
19
|
-
* 2. Sends ACCEPT back
|
|
20
|
-
* 3. Receives START with credentials
|
|
21
|
-
* 4. Mounts workspace via SSHFS
|
|
22
|
-
* 5. Executes task via A2A executor
|
|
23
|
-
* 6. Unmounts and sends DONE/ERROR
|
|
24
|
-
*/
|
|
25
10
|
export class ExecutorService {
|
|
26
11
|
executor;
|
|
27
12
|
config;
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
transport;
|
|
14
|
+
workspace;
|
|
30
15
|
delegatorClient;
|
|
31
16
|
pendingInvitations = new Map();
|
|
32
17
|
activeDelegations = new Map();
|
|
33
18
|
constructor(options) {
|
|
34
19
|
this.executor = options.executor;
|
|
35
20
|
this.config = resolveExecutorConfig(options.config);
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
maxConcurrent: this.config.policy.maxConcurrentDelegations,
|
|
39
|
-
});
|
|
40
|
-
this.sshfsClient = new SshfsMountClient();
|
|
21
|
+
this.transport = this.config.transport;
|
|
22
|
+
this.workspace = new WorkspaceManager(this.config.workDir);
|
|
41
23
|
this.delegatorClient = new DelegatorClient();
|
|
42
24
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Handle incoming AWCP message from Delegator
|
|
45
|
-
*/
|
|
46
25
|
async handleMessage(message, delegatorUrl) {
|
|
47
26
|
switch (message.type) {
|
|
48
27
|
case 'INVITE':
|
|
@@ -57,31 +36,23 @@ export class ExecutorService {
|
|
|
57
36
|
throw new Error(`Unexpected message type: ${message.type}`);
|
|
58
37
|
}
|
|
59
38
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Handle INVITE message
|
|
62
|
-
*/
|
|
63
39
|
async handleInvite(invite, delegatorUrl) {
|
|
64
40
|
const { delegationId } = invite;
|
|
65
|
-
|
|
66
|
-
if (!this.policy.canAcceptMore()) {
|
|
41
|
+
if (this.activeDelegations.size >= this.config.policy.maxConcurrentDelegations) {
|
|
67
42
|
return this.createErrorMessage(delegationId, ErrorCodes.DECLINED, 'Maximum concurrent delegations reached', 'Try again later when current tasks complete');
|
|
68
43
|
}
|
|
69
|
-
// Check TTL constraints
|
|
70
44
|
const maxTtl = this.config.policy.maxTtlSeconds;
|
|
71
45
|
if (invite.lease.ttlSeconds > maxTtl) {
|
|
72
46
|
return this.createErrorMessage(delegationId, ErrorCodes.DECLINED, `Requested TTL (${invite.lease.ttlSeconds}s) exceeds maximum (${maxTtl}s)`, `Request a shorter TTL (max: ${maxTtl}s)`);
|
|
73
47
|
}
|
|
74
|
-
// Check access mode
|
|
75
48
|
const allowedModes = this.config.policy.allowedAccessModes;
|
|
76
49
|
if (!allowedModes.includes(invite.lease.accessMode)) {
|
|
77
50
|
return this.createErrorMessage(delegationId, ErrorCodes.DECLINED, `Access mode '${invite.lease.accessMode}' not allowed`, `Allowed modes: ${allowedModes.join(', ')}`);
|
|
78
51
|
}
|
|
79
|
-
|
|
80
|
-
const depCheck = await this.sshfsClient.checkDependency();
|
|
52
|
+
const depCheck = await this.transport.checkDependency();
|
|
81
53
|
if (!depCheck.available) {
|
|
82
|
-
return this.createErrorMessage(delegationId, ErrorCodes.DEP_MISSING,
|
|
54
|
+
return this.createErrorMessage(delegationId, ErrorCodes.DEP_MISSING, `Transport ${this.transport.type} is not available`, depCheck.hint);
|
|
83
55
|
}
|
|
84
|
-
// Call onInvite hook if provided
|
|
85
56
|
if (this.config.hooks.onInvite) {
|
|
86
57
|
const accepted = await this.config.hooks.onInvite(invite);
|
|
87
58
|
if (!accepted) {
|
|
@@ -89,48 +60,38 @@ export class ExecutorService {
|
|
|
89
60
|
}
|
|
90
61
|
}
|
|
91
62
|
else if (!this.config.policy.autoAccept) {
|
|
92
|
-
// No hook and not auto-accept - store as pending
|
|
93
63
|
this.pendingInvitations.set(delegationId, {
|
|
94
64
|
invite,
|
|
95
65
|
delegatorUrl,
|
|
96
66
|
receivedAt: new Date(),
|
|
97
67
|
});
|
|
98
|
-
// For now, we'll auto-decline if not auto-accept and no hook
|
|
99
68
|
return this.createErrorMessage(delegationId, ErrorCodes.DECLINED, 'Manual acceptance required but no hook provided', 'Configure autoAccept: true or provide onInvite hook');
|
|
100
69
|
}
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
// Validate mount point
|
|
104
|
-
const validation = await this.policy.validateMountPoint(mountPoint);
|
|
70
|
+
const workPath = this.workspace.allocate(delegationId);
|
|
71
|
+
const validation = this.workspace.validate(workPath);
|
|
105
72
|
if (!validation.valid) {
|
|
106
|
-
await this.
|
|
107
|
-
return this.createErrorMessage(delegationId, ErrorCodes.MOUNTPOINT_DENIED, validation.reason ?? '
|
|
73
|
+
await this.workspace.release(workPath);
|
|
74
|
+
return this.createErrorMessage(delegationId, ErrorCodes.MOUNTPOINT_DENIED, validation.reason ?? 'Workspace validation failed', 'Check workDir configuration');
|
|
108
75
|
}
|
|
109
|
-
// Store pending invitation
|
|
110
76
|
this.pendingInvitations.set(delegationId, {
|
|
111
77
|
invite,
|
|
112
78
|
delegatorUrl,
|
|
113
79
|
receivedAt: new Date(),
|
|
114
80
|
});
|
|
115
|
-
// Build executor constraints
|
|
116
81
|
const executorConstraints = {
|
|
117
82
|
acceptedAccessMode: invite.lease.accessMode,
|
|
118
83
|
maxTtlSeconds: Math.min(invite.lease.ttlSeconds, maxTtl),
|
|
119
84
|
sandboxProfile: this.config.sandbox,
|
|
120
85
|
};
|
|
121
|
-
// Return ACCEPT
|
|
122
86
|
const acceptMessage = {
|
|
123
87
|
version: PROTOCOL_VERSION,
|
|
124
88
|
type: 'ACCEPT',
|
|
125
89
|
delegationId,
|
|
126
|
-
executorMount: { mountPoint },
|
|
90
|
+
executorMount: { mountPoint: workPath },
|
|
127
91
|
executorConstraints,
|
|
128
92
|
};
|
|
129
93
|
return acceptMessage;
|
|
130
94
|
}
|
|
131
|
-
/**
|
|
132
|
-
* Handle START message
|
|
133
|
-
*/
|
|
134
95
|
async handleStart(start, delegatorUrl) {
|
|
135
96
|
const { delegationId } = start;
|
|
136
97
|
const pending = this.pendingInvitations.get(delegationId);
|
|
@@ -138,34 +99,25 @@ export class ExecutorService {
|
|
|
138
99
|
console.warn(`[AWCP] Unknown delegation for START: ${delegationId}`);
|
|
139
100
|
return;
|
|
140
101
|
}
|
|
141
|
-
const
|
|
102
|
+
const workPath = this.workspace.allocate(delegationId);
|
|
142
103
|
this.pendingInvitations.delete(delegationId);
|
|
143
104
|
try {
|
|
144
|
-
|
|
145
|
-
await this.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
exportLocator: start.mount.exportLocator,
|
|
150
|
-
credential: start.mount.credential,
|
|
151
|
-
mountPoint,
|
|
152
|
-
options: start.mount.mountOptions,
|
|
105
|
+
await this.workspace.prepare(workPath);
|
|
106
|
+
const actualPath = await this.transport.setup({
|
|
107
|
+
delegationId,
|
|
108
|
+
mountInfo: start.mount,
|
|
109
|
+
workDir: workPath,
|
|
153
110
|
});
|
|
154
|
-
// Track active delegation
|
|
155
111
|
this.activeDelegations.set(delegationId, {
|
|
156
112
|
id: delegationId,
|
|
157
113
|
delegatorUrl,
|
|
158
|
-
|
|
114
|
+
workPath: actualPath,
|
|
159
115
|
task: pending.invite.task,
|
|
160
116
|
startedAt: new Date(),
|
|
161
117
|
});
|
|
162
|
-
|
|
163
|
-
this.
|
|
164
|
-
|
|
165
|
-
const result = await this.executeViaA2A(mountPoint, pending.invite.task);
|
|
166
|
-
// Unmount
|
|
167
|
-
await this.sshfsClient.unmount(mountPoint);
|
|
168
|
-
// Send DONE
|
|
118
|
+
this.config.hooks.onTaskStart?.(delegationId, actualPath);
|
|
119
|
+
const result = await this.executeViaA2A(actualPath, pending.invite.task);
|
|
120
|
+
await this.transport.teardown({ delegationId, workDir: actualPath });
|
|
169
121
|
const doneMessage = {
|
|
170
122
|
version: PROTOCOL_VERSION,
|
|
171
123
|
type: 'DONE',
|
|
@@ -174,18 +126,14 @@ export class ExecutorService {
|
|
|
174
126
|
highlights: result.highlights,
|
|
175
127
|
};
|
|
176
128
|
await this.delegatorClient.send(delegatorUrl, doneMessage);
|
|
177
|
-
// Call onTaskComplete hook
|
|
178
129
|
this.config.hooks.onTaskComplete?.(delegationId, result.summary);
|
|
179
|
-
// Cleanup
|
|
180
130
|
this.activeDelegations.delete(delegationId);
|
|
181
|
-
await this.
|
|
131
|
+
await this.workspace.release(actualPath);
|
|
182
132
|
}
|
|
183
133
|
catch (error) {
|
|
184
|
-
|
|
185
|
-
await this.sshfsClient.unmount(mountPoint).catch(() => { });
|
|
134
|
+
await this.transport.teardown({ delegationId, workDir: workPath }).catch(() => { });
|
|
186
135
|
this.activeDelegations.delete(delegationId);
|
|
187
|
-
await this.
|
|
188
|
-
// Send ERROR
|
|
136
|
+
await this.workspace.release(workPath);
|
|
189
137
|
const errorMessage = {
|
|
190
138
|
version: PROTOCOL_VERSION,
|
|
191
139
|
type: 'ERROR',
|
|
@@ -195,36 +143,26 @@ export class ExecutorService {
|
|
|
195
143
|
hint: 'Check task requirements and try again',
|
|
196
144
|
};
|
|
197
145
|
await this.delegatorClient.send(delegatorUrl, errorMessage).catch(console.error);
|
|
198
|
-
// Call onError hook
|
|
199
146
|
this.config.hooks.onError?.(delegationId, error instanceof Error ? error : new Error(String(error)));
|
|
200
147
|
}
|
|
201
148
|
}
|
|
202
|
-
/**
|
|
203
|
-
* Handle ERROR message from Delegator
|
|
204
|
-
*/
|
|
205
149
|
async handleError(error) {
|
|
206
150
|
const { delegationId } = error;
|
|
207
|
-
// Cleanup if we have an active delegation
|
|
208
151
|
const delegation = this.activeDelegations.get(delegationId);
|
|
209
152
|
if (delegation) {
|
|
210
|
-
await this.
|
|
153
|
+
await this.transport.teardown({ delegationId, workDir: delegation.workPath }).catch(() => { });
|
|
211
154
|
this.activeDelegations.delete(delegationId);
|
|
212
|
-
await this.
|
|
155
|
+
await this.workspace.release(delegation.workPath);
|
|
213
156
|
}
|
|
214
|
-
// Remove pending invitation if any
|
|
215
157
|
this.pendingInvitations.delete(delegationId);
|
|
216
|
-
// Call onError hook
|
|
217
158
|
this.config.hooks.onError?.(delegationId, new AwcpError(error.code, error.message, error.hint, delegationId));
|
|
218
159
|
}
|
|
219
|
-
/**
|
|
220
|
-
* Cancel a delegation (called by Delegator via /cancel endpoint)
|
|
221
|
-
*/
|
|
222
160
|
async cancelDelegation(delegationId) {
|
|
223
161
|
const delegation = this.activeDelegations.get(delegationId);
|
|
224
162
|
if (delegation) {
|
|
225
|
-
await this.
|
|
163
|
+
await this.transport.teardown({ delegationId, workDir: delegation.workPath }).catch(() => { });
|
|
226
164
|
this.activeDelegations.delete(delegationId);
|
|
227
|
-
await this.
|
|
165
|
+
await this.workspace.release(delegation.workPath);
|
|
228
166
|
this.config.hooks.onError?.(delegationId, new AwcpError(ErrorCodes.CANCELLED, 'Delegation cancelled by Delegator', undefined, delegationId));
|
|
229
167
|
return;
|
|
230
168
|
}
|
|
@@ -234,11 +172,7 @@ export class ExecutorService {
|
|
|
234
172
|
}
|
|
235
173
|
throw new Error(`Delegation not found: ${delegationId}`);
|
|
236
174
|
}
|
|
237
|
-
|
|
238
|
-
* Execute task via A2A executor
|
|
239
|
-
*/
|
|
240
|
-
async executeViaA2A(mountPoint, task) {
|
|
241
|
-
// Create synthetic A2A message with task context
|
|
175
|
+
async executeViaA2A(workPath, task) {
|
|
242
176
|
const message = {
|
|
243
177
|
kind: 'message',
|
|
244
178
|
messageId: randomUUID(),
|
|
@@ -247,15 +181,13 @@ export class ExecutorService {
|
|
|
247
181
|
{ kind: 'text', text: task.prompt },
|
|
248
182
|
{
|
|
249
183
|
kind: 'text',
|
|
250
|
-
text: `\n\n[AWCP Context]\nWorking directory: ${
|
|
184
|
+
text: `\n\n[AWCP Context]\nWorking directory: ${workPath}\nTask: ${task.description}`,
|
|
251
185
|
},
|
|
252
186
|
],
|
|
253
187
|
};
|
|
254
|
-
// Create request context
|
|
255
188
|
const taskId = randomUUID();
|
|
256
189
|
const contextId = randomUUID();
|
|
257
190
|
const requestContext = new RequestContextImpl(message, taskId, contextId);
|
|
258
|
-
// Create event bus and collect results
|
|
259
191
|
const eventBus = new DefaultExecutionEventBus();
|
|
260
192
|
const results = [];
|
|
261
193
|
eventBus.on('event', (event) => {
|
|
@@ -263,9 +195,7 @@ export class ExecutorService {
|
|
|
263
195
|
results.push(event);
|
|
264
196
|
}
|
|
265
197
|
});
|
|
266
|
-
// Execute
|
|
267
198
|
await this.executor.execute(requestContext, eventBus);
|
|
268
|
-
// Extract summary from results
|
|
269
199
|
const summary = results
|
|
270
200
|
.flatMap((m) => m.parts)
|
|
271
201
|
.filter((p) => p.kind === 'text')
|
|
@@ -275,23 +205,17 @@ export class ExecutorService {
|
|
|
275
205
|
summary: summary || 'Task completed',
|
|
276
206
|
};
|
|
277
207
|
}
|
|
278
|
-
/**
|
|
279
|
-
* Get service status
|
|
280
|
-
*/
|
|
281
208
|
getStatus() {
|
|
282
209
|
return {
|
|
283
210
|
pendingInvitations: this.pendingInvitations.size,
|
|
284
211
|
activeDelegations: this.activeDelegations.size,
|
|
285
212
|
delegations: Array.from(this.activeDelegations.values()).map((d) => ({
|
|
286
213
|
id: d.id,
|
|
287
|
-
|
|
214
|
+
workPath: d.workPath,
|
|
288
215
|
startedAt: d.startedAt.toISOString(),
|
|
289
216
|
})),
|
|
290
217
|
};
|
|
291
218
|
}
|
|
292
|
-
/**
|
|
293
|
-
* Create an error message
|
|
294
|
-
*/
|
|
295
219
|
createErrorMessage(delegationId, code, message, hint) {
|
|
296
220
|
return {
|
|
297
221
|
version: PROTOCOL_VERSION,
|
|
@@ -303,9 +227,6 @@ export class ExecutorService {
|
|
|
303
227
|
};
|
|
304
228
|
}
|
|
305
229
|
}
|
|
306
|
-
/**
|
|
307
|
-
* Simple RequestContext implementation
|
|
308
|
-
*/
|
|
309
230
|
class RequestContextImpl {
|
|
310
231
|
userMessage;
|
|
311
232
|
taskId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/executor/service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/executor/service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,wBAAwB,GAGzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAUL,gBAAgB,EAChB,UAAU,EACV,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAoD,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AA+BxD,MAAM,OAAO,eAAe;IAClB,QAAQ,CAAgB;IACxB,MAAM,CAAyB;IAC/B,SAAS,CAA2B;IACpC,SAAS,CAAmB;IAC5B,eAAe,CAAkB;IACj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,EAAE;gBACR,QAAQ,EAAE,CAAC,CAAC,QAAQ;gBACpB,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE;aACrC,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC;IAEO,kBAAkB,CACxB,YAAoB,EACpB,IAAY,EACZ,OAAe,EACf,IAAa;QAEb,OAAO;YACL,OAAO,EAAE,gBAAgB;YACzB,IAAI,EAAE,OAAO;YACb,YAAY;YACZ,IAAI;YACJ,OAAO;YACP,IAAI;SACL,CAAC;IACJ,CAAC;CACF;AAED,MAAM,kBAAkB;IACb,WAAW,CAAU;IACrB,MAAM,CAAS;IACf,SAAS,CAAS;IAClB,IAAI,CAAa;IACjB,cAAc,CAAa;IAC3B,OAAO,CAAa;IAE7B,YAAY,WAAoB,EAAE,MAAc,EAAE,SAAiB;QACjE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace Manager - manages workspace directories on Executor side
|
|
3
|
+
*/
|
|
4
|
+
export interface WorkspaceValidation {
|
|
5
|
+
valid: boolean;
|
|
6
|
+
reason?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Manages workspace allocation, preparation, and cleanup.
|
|
10
|
+
*/
|
|
11
|
+
export declare class WorkspaceManager {
|
|
12
|
+
private workDir;
|
|
13
|
+
private allocated;
|
|
14
|
+
constructor(workDir: string);
|
|
15
|
+
/** Allocate a workspace path for a delegation */
|
|
16
|
+
allocate(delegationId: string): string;
|
|
17
|
+
/** Validate that a workspace path is safe to use */
|
|
18
|
+
validate(path: string): WorkspaceValidation;
|
|
19
|
+
/** Prepare a workspace directory */
|
|
20
|
+
prepare(path: string): Promise<void>;
|
|
21
|
+
/** Release a workspace and remove the directory */
|
|
22
|
+
release(path: string): Promise<void>;
|
|
23
|
+
/** Cleanup stale workspace directories from previous runs */
|
|
24
|
+
cleanupStale(): Promise<number>;
|
|
25
|
+
/** Check if a path is currently allocated */
|
|
26
|
+
isAllocated(path: string): boolean;
|
|
27
|
+
/** Get all currently allocated paths */
|
|
28
|
+
getAllocated(): string[];
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=workspace-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-manager.d.ts","sourceRoot":"","sources":["../../src/executor/workspace-manager.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAqB;gBAE1B,OAAO,EAAE,MAAM;IAI3B,iDAAiD;IACjD,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAMtC,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB;IAO3C,oCAAoC;IAC9B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ1C,mDAAmD;IAC7C,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS1C,6DAA6D;IACvD,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAmBrC,6CAA6C;IAC7C,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIlC,wCAAwC;IACxC,YAAY,IAAI,MAAM,EAAE;CAGzB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace Manager - manages workspace directories on Executor side
|
|
3
|
+
*/
|
|
4
|
+
import { mkdir, readdir, rm } from 'node:fs/promises';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
/**
|
|
7
|
+
* Manages workspace allocation, preparation, and cleanup.
|
|
8
|
+
*/
|
|
9
|
+
export class WorkspaceManager {
|
|
10
|
+
workDir;
|
|
11
|
+
allocated = new Set();
|
|
12
|
+
constructor(workDir) {
|
|
13
|
+
this.workDir = workDir;
|
|
14
|
+
}
|
|
15
|
+
/** Allocate a workspace path for a delegation */
|
|
16
|
+
allocate(delegationId) {
|
|
17
|
+
const path = join(this.workDir, delegationId);
|
|
18
|
+
this.allocated.add(path);
|
|
19
|
+
return path;
|
|
20
|
+
}
|
|
21
|
+
/** Validate that a workspace path is safe to use */
|
|
22
|
+
validate(path) {
|
|
23
|
+
if (!path.startsWith(this.workDir)) {
|
|
24
|
+
return { valid: false, reason: `Path must be under ${this.workDir}` };
|
|
25
|
+
}
|
|
26
|
+
return { valid: true };
|
|
27
|
+
}
|
|
28
|
+
/** Prepare a workspace directory */
|
|
29
|
+
async prepare(path) {
|
|
30
|
+
await mkdir(path, { recursive: true });
|
|
31
|
+
const entries = await readdir(path);
|
|
32
|
+
if (entries.length > 0) {
|
|
33
|
+
throw new Error(`Workspace ${path} is not empty`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Release a workspace and remove the directory */
|
|
37
|
+
async release(path) {
|
|
38
|
+
this.allocated.delete(path);
|
|
39
|
+
try {
|
|
40
|
+
await rm(path, { recursive: true, force: true });
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Ignore errors - directory may already be gone
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Cleanup stale workspace directories from previous runs */
|
|
47
|
+
async cleanupStale() {
|
|
48
|
+
let cleaned = 0;
|
|
49
|
+
try {
|
|
50
|
+
const entries = await readdir(this.workDir, { withFileTypes: true });
|
|
51
|
+
for (const entry of entries) {
|
|
52
|
+
if (entry.isDirectory()) {
|
|
53
|
+
const path = join(this.workDir, entry.name);
|
|
54
|
+
if (!this.allocated.has(path)) {
|
|
55
|
+
await rm(path, { recursive: true, force: true });
|
|
56
|
+
cleaned++;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// Root directory may not exist yet
|
|
63
|
+
}
|
|
64
|
+
return cleaned;
|
|
65
|
+
}
|
|
66
|
+
/** Check if a path is currently allocated */
|
|
67
|
+
isAllocated(path) {
|
|
68
|
+
return this.allocated.has(path);
|
|
69
|
+
}
|
|
70
|
+
/** Get all currently allocated paths */
|
|
71
|
+
getAllocated() {
|
|
72
|
+
return Array.from(this.allocated);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=workspace-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-manager.js","sourceRoot":"","sources":["../../src/executor/workspace-manager.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAOjC;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACnB,OAAO,CAAS;IAChB,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IAEtC,YAAY,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,iDAAiD;IACjD,QAAQ,CAAC,YAAoB;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QAC9C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,oDAAoD;IACpD,QAAQ,CAAC,IAAY;QACnB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACnC,OAAO,EAAE,KAAK,EAAE,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BAC9B,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;wBACjD,OAAO,EAAE,CAAC;oBACZ,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,mCAAmC;QACrC,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,6CAA6C;IAC7C,WAAW,CAAC,IAAY;QACtB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,wCAAwC;IACxC,YAAY;QACV,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* AWCP SDK - Delegator and Executor implementations
|
|
5
5
|
*/
|
|
6
|
-
export { DelegatorService, type DelegatorServiceOptions, type DelegateParams, type DelegatorServiceStatus, type DelegatorConfig, type
|
|
7
|
-
export { ExecutorService, type ExecutorServiceOptions, type ExecutorServiceStatus, type ExecutorConfig, type
|
|
6
|
+
export { DelegatorService, type DelegatorServiceOptions, type DelegateParams, type DelegatorServiceStatus, type DelegatorConfig, type DelegationDefaults, type DelegatorHooks, startDelegatorDaemon, DelegatorDaemonClient, type DaemonConfig, type DaemonInstance, type DelegateRequest, type DelegateResponse, type ListDelegationsResponse, AdmissionController, type AdmissionConfig, type AdmissionResult, type WorkspaceStats, ExportManager, ExecutorClient, } from './delegator/index.js';
|
|
7
|
+
export { ExecutorService, type ExecutorServiceOptions, type ExecutorServiceStatus, type ExecutorConfig, type PolicyConstraints, type ExecutorHooks, WorkspaceManager, type WorkspaceValidation, DelegatorClient, } from './executor/index.js';
|
|
8
8
|
export * from '@awcp/core';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAEL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAE3B,KAAK,eAAe,EACpB,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAEL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAE3B,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EAEnB,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAE5B,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,aAAa,EACb,cAAc,GACf,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EAEL,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAE1B,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAElB,gBAAgB,EAChB,KAAK,mBAAmB,EACxB,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAM7B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ DelegatorService,
|
|
|
12
12
|
// Daemon mode
|
|
13
13
|
startDelegatorDaemon, DelegatorDaemonClient,
|
|
14
14
|
// Utilities
|
|
15
|
-
AdmissionController,
|
|
15
|
+
AdmissionController, ExportManager, ExecutorClient, } from './delegator/index.js';
|
|
16
16
|
// ============================================
|
|
17
17
|
// Executor API (for executing delegations)
|
|
18
18
|
// ============================================
|
|
@@ -20,7 +20,7 @@ export {
|
|
|
20
20
|
// Service
|
|
21
21
|
ExecutorService,
|
|
22
22
|
// Utilities
|
|
23
|
-
|
|
23
|
+
WorkspaceManager, DelegatorClient, } from './executor/index.js';
|
|
24
24
|
// ============================================
|
|
25
25
|
// Re-export core types for convenience
|
|
26
26
|
// ============================================
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+CAA+C;AAC/C,2CAA2C;AAC3C,+CAA+C;AAE/C,OAAO;AACL,UAAU;AACV,gBAAgB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+CAA+C;AAC/C,2CAA2C;AAC3C,+CAA+C;AAE/C,OAAO;AACL,UAAU;AACV,gBAAgB;AAQhB,cAAc;AACd,oBAAoB,EACpB,qBAAqB;AAMrB,YAAY;AACZ,mBAAmB,EAInB,aAAa,EACb,cAAc,GACf,MAAM,sBAAsB,CAAC;AAE9B,+CAA+C;AAC/C,2CAA2C;AAC3C,+CAA+C;AAE/C,OAAO;AACL,UAAU;AACV,eAAe;AAOf,YAAY;AACZ,gBAAgB,EAEhB,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAE7B,+CAA+C;AAC/C,uCAAuC;AACvC,+CAA+C;AAE/C,cAAc,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awcp/sdk",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-202601301521",
|
|
4
4
|
"description": "AWCP SDK - Delegator and Executor Daemon implementations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -41,8 +41,7 @@
|
|
|
41
41
|
"test:watch": "vitest"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@awcp/core": "0.0.0-dev-
|
|
45
|
-
"@awcp/transport-sshfs": "0.0.0-dev-202601300724",
|
|
44
|
+
"@awcp/core": "0.0.0-dev-202601301521",
|
|
46
45
|
"@a2a-js/sdk": "^0.3.5"
|
|
47
46
|
},
|
|
48
47
|
"peerDependencies": {
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Local policy configuration
|
|
3
|
-
*/
|
|
4
|
-
export interface PolicyConfig {
|
|
5
|
-
/** Base directory for mount points (default: /tmp/awcp/mounts) */
|
|
6
|
-
mountRoot?: string;
|
|
7
|
-
/** Maximum concurrent delegations */
|
|
8
|
-
maxConcurrent?: number;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Mount point validation result
|
|
12
|
-
*/
|
|
13
|
-
export interface MountPointValidation {
|
|
14
|
-
valid: boolean;
|
|
15
|
-
reason?: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Local Policy - Enforces security constraints on the Executor side.
|
|
19
|
-
*
|
|
20
|
-
* Security: startsWith(root) check prevents path traversal attacks.
|
|
21
|
-
*/
|
|
22
|
-
export declare class LocalPolicy {
|
|
23
|
-
private config;
|
|
24
|
-
private allocatedMounts;
|
|
25
|
-
constructor(config?: PolicyConfig);
|
|
26
|
-
/**
|
|
27
|
-
* Allocate a mount point for a delegation
|
|
28
|
-
*/
|
|
29
|
-
allocateMountPoint(delegationId: string): string;
|
|
30
|
-
/**
|
|
31
|
-
* Validate that a mount point is safe to use
|
|
32
|
-
*/
|
|
33
|
-
validateMountPoint(mountPoint: string): Promise<MountPointValidation>;
|
|
34
|
-
/**
|
|
35
|
-
* Prepare a mount point (create directory, ensure empty)
|
|
36
|
-
*/
|
|
37
|
-
prepareMountPoint(mountPoint: string): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Release a mount point and remove the directory
|
|
40
|
-
*/
|
|
41
|
-
releaseMountPoint(mountPoint: string): Promise<void>;
|
|
42
|
-
/**
|
|
43
|
-
* Cleanup stale mount directories from previous runs
|
|
44
|
-
*/
|
|
45
|
-
cleanupStaleMounts(): Promise<number>;
|
|
46
|
-
/**
|
|
47
|
-
* Check if concurrent limit is reached
|
|
48
|
-
*/
|
|
49
|
-
canAcceptMore(): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Get currently allocated mount points
|
|
52
|
-
*/
|
|
53
|
-
getAllocatedMounts(): string[];
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/executor/policy.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAID;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAOD;;;;GAIG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,eAAe,CAAqB;gBAEhC,MAAM,CAAC,EAAE,YAAY;IAIjC;;OAEG;IACH,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAOhD;;OAEG;IACG,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAa3E;;OAEG;IACG,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS1D;;OAEG;IACG,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS1D;;OAEG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAuB3C;;OAEG;IACH,aAAa,IAAI,OAAO;IAKxB;;OAEG;IACH,kBAAkB,IAAI,MAAM,EAAE;CAG/B"}
|