@awcp/sdk 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/delegator/bin/daemon.d.ts +0 -45
  2. package/dist/delegator/bin/daemon.d.ts.map +1 -1
  3. package/dist/delegator/bin/daemon.js +1 -85
  4. package/dist/delegator/bin/daemon.js.map +1 -1
  5. package/dist/delegator/config.d.ts +9 -71
  6. package/dist/delegator/config.d.ts.map +1 -1
  7. package/dist/delegator/config.js +1 -12
  8. package/dist/delegator/config.js.map +1 -1
  9. package/dist/delegator/executor-client.d.ts +6 -13
  10. package/dist/delegator/executor-client.d.ts.map +1 -1
  11. package/dist/delegator/executor-client.js +52 -14
  12. package/dist/delegator/executor-client.js.map +1 -1
  13. package/dist/delegator/export-manager.d.ts +27 -0
  14. package/dist/delegator/export-manager.d.ts.map +1 -0
  15. package/dist/delegator/export-manager.js +85 -0
  16. package/dist/delegator/export-manager.js.map +1 -0
  17. package/dist/delegator/index.d.ts +2 -2
  18. package/dist/delegator/index.d.ts.map +1 -1
  19. package/dist/delegator/index.js +3 -3
  20. package/dist/delegator/index.js.map +1 -1
  21. package/dist/delegator/service.d.ts +5 -69
  22. package/dist/delegator/service.d.ts.map +1 -1
  23. package/dist/delegator/service.js +96 -104
  24. package/dist/delegator/service.js.map +1 -1
  25. package/dist/executor/config.d.ts +11 -81
  26. package/dist/executor/config.d.ts.map +1 -1
  27. package/dist/executor/config.js +2 -9
  28. package/dist/executor/config.js.map +1 -1
  29. package/dist/executor/index.d.ts +2 -3
  30. package/dist/executor/index.d.ts.map +1 -1
  31. package/dist/executor/index.js +2 -3
  32. package/dist/executor/index.js.map +1 -1
  33. package/dist/executor/service.d.ts +8 -50
  34. package/dist/executor/service.d.ts.map +1 -1
  35. package/dist/executor/service.js +100 -136
  36. package/dist/executor/service.js.map +1 -1
  37. package/dist/executor/workspace-manager.d.ts +30 -0
  38. package/dist/executor/workspace-manager.d.ts.map +1 -0
  39. package/dist/executor/workspace-manager.js +75 -0
  40. package/dist/executor/workspace-manager.js.map +1 -0
  41. package/dist/index.d.ts +2 -2
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +2 -2
  44. package/dist/index.js.map +1 -1
  45. package/dist/server/express/awcp-delegator-handler.d.ts +0 -41
  46. package/dist/server/express/awcp-delegator-handler.d.ts.map +1 -1
  47. package/dist/server/express/awcp-delegator-handler.js +0 -49
  48. package/dist/server/express/awcp-delegator-handler.js.map +1 -1
  49. package/dist/server/express/awcp-executor-handler.d.ts +0 -27
  50. package/dist/server/express/awcp-executor-handler.d.ts.map +1 -1
  51. package/dist/server/express/awcp-executor-handler.js +23 -38
  52. package/dist/server/express/awcp-executor-handler.js.map +1 -1
  53. package/package.json +6 -3
  54. package/dist/executor/delegator-client.d.ts +0 -18
  55. package/dist/executor/delegator-client.d.ts.map +0 -1
  56. package/dist/executor/delegator-client.js +0 -37
  57. package/dist/executor/delegator-client.js.map +0 -1
  58. package/dist/executor/policy.d.ts +0 -55
  59. package/dist/executor/policy.d.ts.map +0 -1
  60. package/dist/executor/policy.js +0 -100
  61. package/dist/executor/policy.js.map +0 -1
@@ -2,7 +2,6 @@
2
2
  * AWCP Delegator Express Handler
3
3
  *
4
4
  * Express middleware for enabling AWCP Delegator functionality.
5
- * This handler receives ACCEPT/DONE/ERROR messages from Executor.
6
5
  */
7
6
  import { Router } from 'express';
8
7
  import type { DelegatorConfig } from '../../delegator/config.js';
@@ -11,57 +10,17 @@ import { DelegatorService } from '../../delegator/service.js';
11
10
  * Options for the AWCP Delegator Express handler
12
11
  */
13
12
  export interface DelegatorHandlerOptions {
14
- /**
15
- * AWCP Delegator configuration
16
- */
17
13
  config: DelegatorConfig;
18
- /**
19
- * Callback URL where this handler is mounted
20
- *
21
- * This URL is sent to Executor in the X-AWCP-Callback-URL header
22
- * so Executor knows where to send ACCEPT/DONE/ERROR messages.
23
- *
24
- * Example: 'http://localhost:3000/awcp'
25
- */
26
- callbackUrl: string;
27
14
  }
28
15
  /**
29
16
  * Result of creating the handler
30
17
  */
31
18
  export interface DelegatorHandlerResult {
32
- /** Express router to mount */
33
19
  router: Router;
34
- /** Service instance for creating delegations */
35
20
  service: DelegatorService;
36
21
  }
37
22
  /**
38
23
  * Create an Express router that handles AWCP Delegator messages
39
- *
40
- * @example
41
- * ```typescript
42
- * import express from 'express';
43
- * import { delegatorHandler } from '@awcp/sdk/server/express';
44
- *
45
- * const app = express();
46
- *
47
- * const { router, service } = delegatorHandler({
48
- * config: {
49
- * export: { baseDir: '/tmp/awcp/exports' },
50
- * ssh: { host: 'localhost', user: 'myuser' },
51
- * },
52
- * callbackUrl: 'http://localhost:3000/awcp',
53
- * });
54
- *
55
- * // Mount the router
56
- * app.use('/awcp', router);
57
- *
58
- * // Use the service to create delegations
59
- * const delegationId = await service.delegate({
60
- * executorUrl: 'http://executor-agent:4001/awcp',
61
- * localDir: '/path/to/project',
62
- * task: { description: 'Fix bug', prompt: '...' },
63
- * });
64
- * ```
65
24
  */
66
25
  export declare function delegatorHandler(options: DelegatorHandlerOptions): DelegatorHandlerResult;
67
26
  //# sourceMappingURL=awcp-delegator-handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"awcp-delegator-handler.d.ts","sourceRoot":"","sources":["../../../src/server/express/awcp-delegator-handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAQ,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,MAAM,EAAE,eAAe,CAAC;IAExB;;;;;;;OAOG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,sBAAsB,CAkEzF"}
1
+ {"version":3,"file":"awcp-delegator-handler.d.ts","sourceRoot":"","sources":["../../../src/server/express/awcp-delegator-handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAQ,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,eAAe,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,sBAAsB,CA0CzF"}
@@ -2,69 +2,20 @@
2
2
  * AWCP Delegator Express Handler
3
3
  *
4
4
  * Express middleware for enabling AWCP Delegator functionality.
5
- * This handler receives ACCEPT/DONE/ERROR messages from Executor.
6
5
  */
7
6
  import { Router, json } from 'express';
8
7
  import { DelegatorService } from '../../delegator/service.js';
9
8
  /**
10
9
  * Create an Express router that handles AWCP Delegator messages
11
- *
12
- * @example
13
- * ```typescript
14
- * import express from 'express';
15
- * import { delegatorHandler } from '@awcp/sdk/server/express';
16
- *
17
- * const app = express();
18
- *
19
- * const { router, service } = delegatorHandler({
20
- * config: {
21
- * export: { baseDir: '/tmp/awcp/exports' },
22
- * ssh: { host: 'localhost', user: 'myuser' },
23
- * },
24
- * callbackUrl: 'http://localhost:3000/awcp',
25
- * });
26
- *
27
- * // Mount the router
28
- * app.use('/awcp', router);
29
- *
30
- * // Use the service to create delegations
31
- * const delegationId = await service.delegate({
32
- * executorUrl: 'http://executor-agent:4001/awcp',
33
- * localDir: '/path/to/project',
34
- * task: { description: 'Fix bug', prompt: '...' },
35
- * });
36
- * ```
37
10
  */
38
11
  export function delegatorHandler(options) {
39
12
  const router = Router();
40
13
  const service = new DelegatorService({
41
14
  config: options.config,
42
- callbackUrl: options.callbackUrl,
43
15
  });
44
- // Parse JSON bodies
45
16
  router.use(json());
46
- /**
47
- * POST / - Receive AWCP messages from Executor
48
- *
49
- * Executor sends ACCEPT, DONE, and ERROR messages to this endpoint.
50
- */
51
- router.post('/', async (req, res) => {
52
- try {
53
- const message = req.body;
54
- await service.handleMessage(message);
55
- res.json({ ok: true });
56
- }
57
- catch (error) {
58
- console.error('[AWCP Delegator] Error handling message:', error);
59
- res.status(500).json({
60
- error: error instanceof Error ? error.message : 'Internal error',
61
- });
62
- }
63
- });
64
17
  /**
65
18
  * GET /status - Get service status
66
- *
67
- * Returns information about active delegations.
68
19
  */
69
20
  router.get('/status', (_req, res) => {
70
21
  res.json(service.getStatus());
@@ -1 +1 @@
1
- {"version":3,"file":"awcp-delegator-handler.js","sourceRoot":"","sources":["../../../src/server/express/awcp-delegator-handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAgC9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgC;IAC/D,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC;QACnC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,WAAW,EAAE,OAAO,CAAC,WAAW;KACjC,CAAC,CAAC;IAEH,oBAAoB;IACpB,MAAM,CAAC,GAAG,CAAC,IAAI,EAA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OAEG;IACH,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACzC,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC,CAAC;YACxD,OAAO;QACT,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QAClD,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACpC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB;aACnE,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC7B,CAAC"}
@@ -10,38 +10,11 @@ import type { ExecutorConfig } from '../../executor/config.js';
10
10
  * Options for the AWCP Executor Express handler
11
11
  */
12
12
  export interface ExecutorHandlerOptions {
13
- /**
14
- * A2A agent executor
15
- *
16
- * This is the executor that will be called to execute tasks.
17
- * It should be the same executor used by the A2A agent.
18
- */
19
13
  executor: AgentExecutor;
20
- /**
21
- * AWCP Executor configuration
22
- */
23
14
  config: ExecutorConfig;
24
15
  }
25
16
  /**
26
17
  * Create an Express router that handles AWCP messages (Executor side)
27
- *
28
- * @example
29
- * ```typescript
30
- * import express from 'express';
31
- * import { executorHandler } from '@awcp/sdk/server/express';
32
- *
33
- * const app = express();
34
- *
35
- * // ... existing A2A setup ...
36
- *
37
- * // Enable AWCP
38
- * app.use('/awcp', executorHandler({
39
- * executor: myExecutor,
40
- * config: {
41
- * mount: { root: '/tmp/awcp/mounts' },
42
- * },
43
- * }));
44
- * ```
45
18
  */
46
19
  export declare function executorHandler(options: ExecutorHandlerOptions): Router;
47
20
  //# sourceMappingURL=awcp-executor-handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"awcp-executor-handler.d.ts","sourceRoot":"","sources":["../../../src/server/express/awcp-executor-handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAQ,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,QAAQ,EAAE,aAAa,CAAC;IAExB;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,CAgFvE"}
1
+ {"version":3,"file":"awcp-executor-handler.d.ts","sourceRoot":"","sources":["../../../src/server/express/awcp-executor-handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAQ,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,cAAc,CAAC;CACxB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,CAsFvE"}
@@ -7,24 +7,6 @@ import { Router, json } from 'express';
7
7
  import { ExecutorService } from '../../executor/service.js';
8
8
  /**
9
9
  * Create an Express router that handles AWCP messages (Executor side)
10
- *
11
- * @example
12
- * ```typescript
13
- * import express from 'express';
14
- * import { executorHandler } from '@awcp/sdk/server/express';
15
- *
16
- * const app = express();
17
- *
18
- * // ... existing A2A setup ...
19
- *
20
- * // Enable AWCP
21
- * app.use('/awcp', executorHandler({
22
- * executor: myExecutor,
23
- * config: {
24
- * mount: { root: '/tmp/awcp/mounts' },
25
- * },
26
- * }));
27
- * ```
28
10
  */
29
11
  export function executorHandler(options) {
30
12
  const router = Router();
@@ -32,38 +14,21 @@ export function executorHandler(options) {
32
14
  executor: options.executor,
33
15
  config: options.config,
34
16
  });
35
- // Parse JSON bodies
36
17
  router.use(json());
37
18
  /**
38
19
  * POST / - Receive AWCP messages from Delegator
39
- *
40
- * The Delegator sends INVITE and START messages to this endpoint.
41
- * The Delegator URL for sending responses is provided in the
42
- * X-AWCP-Callback-URL header.
43
20
  */
44
21
  router.post('/', async (req, res) => {
45
22
  try {
46
23
  const message = req.body;
47
- const delegatorUrl = req.headers['x-awcp-callback-url'];
48
- if (!delegatorUrl && message.type !== 'ERROR') {
49
- res.status(400).json({
50
- error: 'Missing X-AWCP-Callback-URL header',
51
- });
52
- return;
53
- }
54
- // For START messages, respond immediately and handle async
24
+ // START: wait for delegation setup, then respond (task runs async)
55
25
  if (message.type === 'START') {
26
+ await service.handleMessage(message);
56
27
  res.json({ ok: true });
57
- // Handle START asynchronously (mount + execute task)
58
- service.handleMessage(message, delegatorUrl ?? '').catch((error) => {
59
- console.error('[AWCP Executor] Error handling START:', error);
60
- });
61
28
  return;
62
29
  }
63
- // Other messages (INVITE, ERROR) are handled synchronously
64
- const response = await service.handleMessage(message, delegatorUrl ?? '');
30
+ const response = await service.handleMessage(message);
65
31
  if (response) {
66
- // INVITE returns ACCEPT/ERROR synchronously
67
32
  res.json(response);
68
33
  }
69
34
  else {
@@ -77,6 +42,26 @@ export function executorHandler(options) {
77
42
  });
78
43
  }
79
44
  });
45
+ /**
46
+ * GET /tasks/:taskId/events - SSE endpoint for task events
47
+ */
48
+ router.get('/tasks/:taskId/events', (req, res) => {
49
+ const { taskId } = req.params;
50
+ res.setHeader('Content-Type', 'text/event-stream');
51
+ res.setHeader('Cache-Control', 'no-cache');
52
+ res.setHeader('Connection', 'keep-alive');
53
+ res.setHeader('X-Accel-Buffering', 'no');
54
+ res.flushHeaders();
55
+ const unsubscribe = service.subscribeTask(taskId, (event) => {
56
+ res.write(`data: ${JSON.stringify(event)}\n\n`);
57
+ if (event.type === 'done' || event.type === 'error') {
58
+ res.end();
59
+ }
60
+ });
61
+ req.on('close', () => {
62
+ unsubscribe();
63
+ });
64
+ });
80
65
  /**
81
66
  * GET /status - Get service status
82
67
  */
@@ -1 +1 @@
1
- {"version":3,"file":"awcp-executor-handler.js","sourceRoot":"","sources":["../../../src/server/express/awcp-executor-handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAoB5D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,eAAe,CAAC,OAA+B;IAC7D,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC;QAClC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;IAEH,oBAAoB;IACpB,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAEnB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AC,SAAS,EAAE,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,uBAAuB,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QACtD,IAAI,CAAC;YACH,MAAM,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC;YACpC,MAAM,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;YAC7C,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,8CAA8C,EAAE,KAAK,CAAC,CAAC;YACrE,GAAG,CAAC,MAAM,CAAC,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACzF,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB;aACjE,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awcp/sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "AWCP SDK - Delegator and Executor Daemon implementations",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,6 +18,10 @@
18
18
  "types": "./dist/delegator/bin/client.d.ts",
19
19
  "import": "./dist/delegator/bin/client.js"
20
20
  },
21
+ "./delegator/daemon": {
22
+ "types": "./dist/delegator/bin/daemon.d.ts",
23
+ "import": "./dist/delegator/bin/daemon.js"
24
+ },
21
25
  "./executor": {
22
26
  "types": "./dist/executor/index.d.ts",
23
27
  "import": "./dist/executor/index.js"
@@ -41,8 +45,7 @@
41
45
  "test:watch": "vitest"
42
46
  },
43
47
  "dependencies": {
44
- "@awcp/core": "^0.0.1",
45
- "@awcp/transport-sshfs": "^0.0.1",
48
+ "@awcp/core": "^0.0.3",
46
49
  "@a2a-js/sdk": "^0.3.5"
47
50
  },
48
51
  "peerDependencies": {
@@ -1,18 +0,0 @@
1
- /**
2
- * HTTP Client for sending AWCP messages to Delegator
3
- */
4
- import type { AwcpMessage } from '@awcp/core';
5
- /**
6
- * Client for sending AWCP messages back to the Delegator daemon
7
- */
8
- export declare class DelegatorClient {
9
- private timeout;
10
- constructor(options?: {
11
- timeout?: number;
12
- });
13
- /**
14
- * Send an AWCP message to the Delegator
15
- */
16
- send(delegatorUrl: string, message: AwcpMessage): Promise<void>;
17
- }
18
- //# sourceMappingURL=delegator-client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"delegator-client.d.ts","sourceRoot":"","sources":["../../src/executor/delegator-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAI1C;;OAEG;IACG,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAwBtE"}
@@ -1,37 +0,0 @@
1
- /**
2
- * HTTP Client for sending AWCP messages to Delegator
3
- */
4
- /**
5
- * Client for sending AWCP messages back to the Delegator daemon
6
- */
7
- export class DelegatorClient {
8
- timeout;
9
- constructor(options) {
10
- this.timeout = options?.timeout ?? 30000;
11
- }
12
- /**
13
- * Send an AWCP message to the Delegator
14
- */
15
- async send(delegatorUrl, message) {
16
- const controller = new AbortController();
17
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
18
- try {
19
- const response = await fetch(delegatorUrl, {
20
- method: 'POST',
21
- headers: {
22
- 'Content-Type': 'application/json',
23
- },
24
- body: JSON.stringify(message),
25
- signal: controller.signal,
26
- });
27
- if (!response.ok) {
28
- const text = await response.text().catch(() => '');
29
- throw new Error(`Failed to send ${message.type} to delegator: ${response.status} ${response.statusText}${text ? ` - ${text}` : ''}`);
30
- }
31
- }
32
- finally {
33
- clearTimeout(timeoutId);
34
- }
35
- }
36
- }
37
- //# sourceMappingURL=delegator-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"delegator-client.js","sourceRoot":"","sources":["../../src/executor/delegator-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,MAAM,OAAO,eAAe;IAClB,OAAO,CAAS;IAExB,YAAY,OAA8B;QACxC,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,KAAK,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,YAAoB,EAAE,OAAoB;QACnD,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAErE,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,YAAY,EAAE;gBACzC,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;gBAC7B,MAAM,EAAE,UAAU,CAAC,MAAM;aAC1B,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;gBACnD,MAAM,IAAI,KAAK,CACb,kBAAkB,OAAO,CAAC,IAAI,kBAAkB,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CACpH,CAAC;YACJ,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,SAAS,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;CACF"}
@@ -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"}
@@ -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;;OAEG;IACH,KAAK,CAAC,iBAAiB,CAAC,UAAkB;QACxC,MAAM,KAAK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