@awcp/mcp 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.
@@ -4,10 +4,14 @@
4
4
  * Use this to check status or get results from a background delegation.
5
5
  */
6
6
  import { z } from 'zod';
7
+ import { readFileSync } from 'node:fs';
8
+ import { dirname, join } from 'node:path';
9
+ import { fileURLToPath } from 'node:url';
10
+ const __dirname = dirname(fileURLToPath(import.meta.url));
7
11
  export const delegateOutputSchema = z.object({
8
12
  delegation_id: z
9
13
  .string()
10
- .describe('The delegation ID returned from delegate()'),
14
+ .describe('Delegation ID from the background delegation launch'),
11
15
  block: z
12
16
  .boolean()
13
17
  .optional()
@@ -17,28 +21,7 @@ export const delegateOutputSchema = z.object({
17
21
  .int()
18
22
  .positive()
19
23
  .optional()
20
- .describe('Maximum seconds to wait when blocking (default: 60)'),
24
+ .describe('Max seconds to wait (default: 60)'),
21
25
  });
22
- export const delegateOutputDescription = `Retrieve output from a delegation.
23
-
24
- ## Parameters
25
- - **delegation_id** (required): Delegation ID from delegate()
26
- - **block** (optional): Wait for completion if still running
27
- - **timeout** (optional): Maximum seconds to wait (default: 60)
28
-
29
- ## Usage
30
- After launching a background delegation:
31
- \`\`\`
32
- delegate(background: true, ...) → "Delegation ID: dlg_abc123..."
33
- \`\`\`
34
-
35
- Check or retrieve results:
36
- \`\`\`
37
- delegate_output(delegation_id: "dlg_abc123")
38
- \`\`\`
39
-
40
- Wait for completion:
41
- \`\`\`
42
- delegate_output(delegation_id: "dlg_abc123", block: true, timeout: 120)
43
- \`\`\`
44
- `;
26
+ export const delegateOutputDescription = readFileSync(join(__dirname, 'delegate-output.txt'), 'utf-8');
27
+ //# sourceMappingURL=delegate-output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegate-output.js","sourceRoot":"","sources":["../../src/tools/delegate-output.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,aAAa,EAAE,CAAC;SACb,MAAM,EAAE;SACR,QAAQ,CAAC,qDAAqD,CAAC;IAClE,KAAK,EAAE,CAAC;SACL,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,QAAQ,CAAC,sCAAsC,CAAC;IACnD,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,GAAG,EAAE;SACL,QAAQ,EAAE;SACV,QAAQ,EAAE;SACV,QAAQ,CAAC,mCAAmC,CAAC;CACjD,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,yBAAyB,GAAG,YAAY,CACnD,IAAI,CAAC,SAAS,EAAE,qBAAqB,CAAC,EACtC,OAAO,CACR,CAAC"}
@@ -0,0 +1,22 @@
1
+ Retrieve output from a background delegation.
2
+
3
+ ## Parameters
4
+ - **delegation_id** (required): Delegation ID from the background delegation launch
5
+ - **block** (optional): Wait for completion if still running
6
+ - **timeout** (optional): Maximum seconds to wait (default: 60)
7
+
8
+ ## Usage
9
+ After launching a background delegation:
10
+ ```
11
+ delegate(background: true, ...) → "Delegation ID: dlg_abc123..."
12
+ ```
13
+
14
+ Check or retrieve results:
15
+ ```
16
+ delegate_output(delegation_id: "dlg_abc123")
17
+ ```
18
+
19
+ Wait for completion:
20
+ ```
21
+ delegate_output(delegation_id: "dlg_abc123", block: true, timeout: 120)
22
+ ```
@@ -5,6 +5,7 @@
5
5
  * Executor agent for collaborative task execution.
6
6
  */
7
7
  import { z } from 'zod';
8
+ import type { PeersContext } from '../peer-discovery.js';
8
9
  export declare const delegateSchema: z.ZodObject<{
9
10
  description: z.ZodString;
10
11
  prompt: z.ZodString;
@@ -31,5 +32,9 @@ export declare const delegateSchema: z.ZodObject<{
31
32
  background?: boolean | undefined;
32
33
  }>;
33
34
  export type DelegateParams = z.infer<typeof delegateSchema>;
34
- export declare const delegateDescription = "Delegate a local workspace directory to a remote Executor agent.\n\n## Parameters\n- **description** (required): Short task description for logs\n- **prompt** (required): Full task instructions with goals and constraints\n- **workspace_dir** (required): Local directory path to delegate\n- **peer_url** (required): Executor's AWCP endpoint URL\n- **ttl_seconds** (optional): Lease duration (default: 3600)\n- **access_mode** (optional): \"ro\" or \"rw\" (default: \"rw\")\n- **background** (optional): Return immediately if true (default: false)\n\n## Behavior\n- **Sync mode (background=false)**: Waits for task completion, returns final_summary\n- **Async mode (background=true)**: Returns delegation_id immediately\n\n## Example\n```\ndelegate({\n description: \"Fix TypeScript errors\",\n prompt: \"Find and fix all type errors in the src/ directory...\",\n workspace_dir: \"/path/to/project\",\n peer_url: \"http://executor:4001/awcp\",\n background: true\n})\n```\n";
35
+ /**
36
+ * Generate delegate tool description with available executors info
37
+ */
38
+ export declare function generateDelegateDescription(peers?: PeersContext): string;
39
+ export declare const delegateDescription: string;
35
40
  //# sourceMappingURL=delegate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"delegate.d.ts","sourceRoot":"","sources":["../../src/tools/delegate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;EA+BzB,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,eAAO,MAAM,mBAAmB,q9BAyB/B,CAAC"}
1
+ {"version":3,"file":"delegate.d.ts","sourceRoot":"","sources":["../../src/tools/delegate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAKzD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;EA+BzB,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,MAAM,CA6BxE;AAGD,eAAO,MAAM,mBAAmB,QAAgC,CAAC"}
@@ -5,6 +5,11 @@
5
5
  * Executor agent for collaborative task execution.
6
6
  */
7
7
  import { z } from 'zod';
8
+ import { readFileSync } from 'node:fs';
9
+ import { dirname, join } from 'node:path';
10
+ import { fileURLToPath } from 'node:url';
11
+ const __dirname = dirname(fileURLToPath(import.meta.url));
12
+ const DESCRIPTION_TEMPLATE = readFileSync(join(__dirname, 'delegate.txt'), 'utf-8');
8
13
  export const delegateSchema = z.object({
9
14
  description: z
10
15
  .string()
@@ -35,29 +40,33 @@ export const delegateSchema = z.object({
35
40
  .describe('If true, returns immediately with delegation_id. ' +
36
41
  'If false (default), waits for task completion.'),
37
42
  });
38
- export const delegateDescription = `Delegate a local workspace directory to a remote Executor agent.
39
-
40
- ## Parameters
41
- - **description** (required): Short task description for logs
42
- - **prompt** (required): Full task instructions with goals and constraints
43
- - **workspace_dir** (required): Local directory path to delegate
44
- - **peer_url** (required): Executor's AWCP endpoint URL
45
- - **ttl_seconds** (optional): Lease duration (default: 3600)
46
- - **access_mode** (optional): "ro" or "rw" (default: "rw")
47
- - **background** (optional): Return immediately if true (default: false)
48
-
49
- ## Behavior
50
- - **Sync mode (background=false)**: Waits for task completion, returns final_summary
51
- - **Async mode (background=true)**: Returns delegation_id immediately
52
-
53
- ## Example
54
- \`\`\`
55
- delegate({
56
- description: "Fix TypeScript errors",
57
- prompt: "Find and fix all type errors in the src/ directory...",
58
- workspace_dir: "/path/to/project",
59
- peer_url: "http://executor:4001/awcp",
60
- background: true
61
- })
62
- \`\`\`
63
- `;
43
+ /**
44
+ * Generate delegate tool description with available executors info
45
+ */
46
+ export function generateDelegateDescription(peers) {
47
+ let executorsSection = '';
48
+ // Add available executors section if peers are configured
49
+ if (peers && peers.peers.length > 0) {
50
+ const availablePeers = peers.peers.filter(p => p.card);
51
+ if (availablePeers.length > 0) {
52
+ executorsSection = '## Available Executors';
53
+ for (const peer of availablePeers) {
54
+ const card = peer.card;
55
+ executorsSection += `\n\n### ${card.name}`;
56
+ executorsSection += `\n- **URL**: \`${peer.awcpUrl}\``;
57
+ if (card.description) {
58
+ executorsSection += `\n- **Description**: ${card.description}`;
59
+ }
60
+ if (card.skills && card.skills.length > 0) {
61
+ const skillNames = card.skills.map(s => s.name).join(', ');
62
+ executorsSection += `\n- **Skills**: ${skillNames}`;
63
+ }
64
+ }
65
+ }
66
+ }
67
+ // Replace {executors} placeholder with actual content
68
+ return DESCRIPTION_TEMPLATE.replace('{executors}', executorsSection);
69
+ }
70
+ // For backward compatibility - static description without peers
71
+ export const delegateDescription = generateDelegateDescription();
72
+ //# sourceMappingURL=delegate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegate.js","sourceRoot":"","sources":["../../src/tools/delegate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1D,MAAM,oBAAoB,GAAG,YAAY,CAAC,IAAI,CAAC,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AAE,CAAC;gBAClC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAK,CAAC;gBACxB,gBAAgB,IAAI,WAAW,IAAI,CAAC,IAAI,EAAE,CAAC;gBAC3C,gBAAgB,IAAI,kBAAkB,IAAI,CAAC,OAAO,IAAI,CAAC;gBAEvD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;oBACrB,gBAAgB,IAAI,wBAAwB,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjE,CAAC;gBAED,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBAC3D,gBAAgB,IAAI,mBAAmB,UAAU,EAAE,CAAC;gBACtD,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,sDAAsD;IACtD,OAAO,oBAAoB,CAAC,OAAO,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;AACvE,CAAC;AAED,gEAAgE;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAG,2BAA2B,EAAE,CAAC"}
@@ -0,0 +1,46 @@
1
+ Delegate a workspace to a remote Executor for collaborative task execution.
2
+
3
+ ## When to use
4
+
5
+ Use delegation when:
6
+ - Task requires a different environment or specialized toolset
7
+ - You want to parallelize work across multiple agents
8
+ - The remote agent has capabilities you lack (e.g., browser, GPU, specific SDKs)
9
+
10
+ Do NOT use when:
11
+ - Task is trivial and can be done locally
12
+ - You need real-time back-and-forth interaction during execution
13
+
14
+ ## Background mode
15
+
16
+ **Prefer background=true by default.** This lets you launch multiple delegations in parallel and continue working.
17
+
18
+ Use background=false only when you cannot proceed without the result.
19
+
20
+ ## Writing effective prompts
21
+
22
+ Structure your prompt with:
23
+ - **What to do**: Clear, specific goal
24
+ - **Expected outcome**: What success looks like
25
+ - **Context**: Relevant file paths, patterns, constraints
26
+ - **What NOT to do**: Scope boundaries to prevent over-engineering
27
+
28
+ {executors}
29
+
30
+ ## Examples
31
+
32
+ ### Parallel tasks
33
+ ```
34
+ delegate(background: true, description: "Fix linting errors", prompt: "...", workspace_dir: "/project", peer_url: "...")
35
+ delegate(background: true, description: "Add unit tests", prompt: "...", workspace_dir: "/project", peer_url: "...")
36
+ ```
37
+
38
+ ### Synchronous (when result needed immediately)
39
+ ```
40
+ delegate(background: false, description: "Generate config", prompt: "Create tsconfig.json for...", workspace_dir: "/project", peer_url: "...")
41
+ ```
42
+
43
+ ### Read-only analysis
44
+ ```
45
+ delegate(description: "Code review", prompt: "Review the code for security issues...", workspace_dir: "/project", peer_url: "...", access_mode: "ro")
46
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awcp/mcp",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "MCP tools for AWCP delegation",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -15,14 +15,17 @@
15
15
  }
16
16
  },
17
17
  "scripts": {
18
- "build": "tsc",
18
+ "build": "tsc && cp src/tools/*.txt dist/tools/",
19
19
  "dev": "tsc --watch",
20
20
  "test": "vitest run",
21
21
  "test:watch": "vitest"
22
22
  },
23
23
  "dependencies": {
24
- "@awcp/sdk": "^0.0.1",
25
- "@awcp/core": "^0.0.1",
24
+ "@awcp/sdk": "^0.0.3",
25
+ "@awcp/core": "^0.0.3",
26
+ "@awcp/transport-archive": "^0.0.3",
27
+ "@awcp/transport-sshfs": "^0.0.3",
28
+ "@a2a-js/sdk": "^0.3.5",
26
29
  "@modelcontextprotocol/sdk": "^1.0.0",
27
30
  "zod": "^3.23.0"
28
31
  },