@awcp/sdk 0.0.0-dev-202601301521 → 0.0.0-dev-202601310829
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 +0 -53
- package/dist/delegator/bin/daemon.d.ts.map +1 -1
- package/dist/delegator/bin/daemon.js +0 -95
- package/dist/delegator/bin/daemon.js.map +1 -1
- package/dist/delegator/executor-client.d.ts +6 -13
- package/dist/delegator/executor-client.d.ts.map +1 -1
- package/dist/delegator/executor-client.js +52 -14
- package/dist/delegator/executor-client.js.map +1 -1
- package/dist/delegator/service.d.ts +6 -2
- package/dist/delegator/service.d.ts.map +1 -1
- package/dist/delegator/service.js +85 -8
- package/dist/delegator/service.js.map +1 -1
- package/dist/executor/index.d.ts +0 -1
- package/dist/executor/index.d.ts.map +1 -1
- package/dist/executor/index.js +0 -1
- package/dist/executor/index.js.map +1 -1
- package/dist/executor/service.d.ts +7 -3
- package/dist/executor/service.d.ts.map +1 -1
- package/dist/executor/service.js +77 -34
- package/dist/executor/service.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/server/express/awcp-delegator-handler.d.ts +0 -41
- package/dist/server/express/awcp-delegator-handler.d.ts.map +1 -1
- package/dist/server/express/awcp-delegator-handler.js +0 -49
- package/dist/server/express/awcp-delegator-handler.js.map +1 -1
- package/dist/server/express/awcp-executor-handler.d.ts +0 -27
- package/dist/server/express/awcp-executor-handler.d.ts.map +1 -1
- package/dist/server/express/awcp-executor-handler.js +23 -38
- package/dist/server/express/awcp-executor-handler.js.map +1 -1
- package/package.json +6 -2
- package/dist/executor/delegator-client.d.ts +0 -18
- package/dist/executor/delegator-client.d.ts.map +0 -1
- package/dist/executor/delegator-client.js +0 -37
- package/dist/executor/delegator-client.js.map +0 -1
|
@@ -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
|
-
|
|
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
|
-
|
|
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,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AAC,CAAC,CAAC;IAEH;;OAEG;IACH,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QAClC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,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.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-202601310829",
|
|
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,7 +45,7 @@
|
|
|
41
45
|
"test:watch": "vitest"
|
|
42
46
|
},
|
|
43
47
|
"dependencies": {
|
|
44
|
-
"@awcp/core": "0.0.0-dev-
|
|
48
|
+
"@awcp/core": "0.0.0-dev-202601310829",
|
|
45
49
|
"@a2a-js/sdk": "^0.3.5"
|
|
46
50
|
},
|
|
47
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"}
|