@almyty/acp-server 1.0.4 → 1.0.5

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 (2) hide show
  1. package/dist/index.js +41 -32
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -25,25 +25,16 @@ if (args.some((a) => HELP_FLAGS.includes(a)) || args.length === 0) {
25
25
  @almyty/acp-server — Expose any almyty agent via the Agent Client Protocol
26
26
 
27
27
  Usage:
28
- npx @almyty/acp-server <agent-name>
28
+ almyty-acp <agent>
29
+ almyty-acp my-agent
30
+ almyty-acp acme/my-agent
29
31
 
30
32
  Authentication:
31
33
  npx @almyty/auth login
32
34
 
33
35
  Environment:
34
- ALMYTY_URL Backend URL (default: https://api.almyty.com)
35
- ALMYTY_TOKEN API key (or auto-read from ~/.almyty/credentials.json)
36
-
37
- Zed (add to settings.json → agent_servers):
38
- {
39
- "agent_servers": {
40
- "almyty": {
41
- "type": "custom",
42
- "command": "npx",
43
- "args": ["-y", "@almyty/acp-server", "<agent-name>"]
44
- }
45
- }
46
- }
36
+ ALMYTY_URL Backend URL (default: https://api.almyty.com)
37
+ ALMYTY_TOKEN API key (or auto-read from ~/.almyty/credentials.json)
47
38
 
48
39
  Docs: https://docs.almyty.com/cli/acp-server
49
40
  `;
@@ -54,7 +45,7 @@ Docs: https://docs.almyty.com/cli/acp-server
54
45
  // Filter out any flags, take the first positional arg as the agent identifier
55
46
  const agentArg = args.find((a) => !a.startsWith('-'));
56
47
  if (!agentArg) {
57
- process.stderr.write('Error: Agent name or ID is required.\nUsage: npx @almyty/acp-server <agent>\n');
48
+ process.stderr.write('Error: Agent name or slug is required.\nUsage: almyty-acp <agent>\n');
58
49
  process.exit(1);
59
50
  }
60
51
  // ── Main ─────────────────────────────────────────────────────────
@@ -67,33 +58,51 @@ async function main() {
67
58
  process.exit(1);
68
59
  }
69
60
  const proxy = new AlmytyProxy(creds.url, creds.token);
70
- // Resolve agent: try as ID first, then search by name/slug
71
- let agentId = agentArg;
72
- try {
73
- const agent = await proxy.getAgent(agentId);
74
- agentId = agent.id;
75
- process.stderr.write(`[acp] Agent resolved: ${agent.name} (${agent.id}, mode: ${agent.mode})\n`);
61
+ // Resolve agent. Accepts:
62
+ // my-agent slug
63
+ // acme/my-agent org/slug
64
+ // My Agent display name
65
+ // 550e8400-... UUID
66
+ let agentId;
67
+ const ref = agentArg;
68
+ const hasSlash = ref.includes('/');
69
+ const orgPrefix = hasSlash ? ref.split('/')[0] : undefined;
70
+ const agentRef = hasSlash ? ref.split('/').slice(1).join('/') : ref;
71
+ // 1. Try UUID direct lookup
72
+ const isUUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(agentRef);
73
+ if (isUUID) {
74
+ try {
75
+ const agent = await proxy.getAgent(agentRef);
76
+ agentId = agent.id;
77
+ process.stderr.write(`[acp] ${agent.name} (${agent.mode})\n`);
78
+ }
79
+ catch {
80
+ process.stderr.write(`Error: Agent not found: ${agentRef}\n`);
81
+ process.exit(1);
82
+ }
76
83
  }
77
- catch {
78
- // If direct lookup fails, try listing agents and matching by name/slug
84
+ // 2. List agents and match by slug, name, or slug-ified name
85
+ if (!agentId) {
79
86
  try {
80
87
  const agents = await proxy.listAgents();
81
- const match = agents.find((a) => a.name === agentArg ||
82
- a.slug === agentArg ||
83
- a.name.toLowerCase() === agentArg.toLowerCase() ||
84
- a.slug?.toLowerCase() === agentArg.toLowerCase());
88
+ const slugify = (s) => s.toLowerCase().replace(/\s+/g, '-');
89
+ const needle = slugify(agentRef);
90
+ const match = agents.find((a) => {
91
+ const aSlug = a.slug || slugify(a.name);
92
+ return aSlug === needle || a.name === agentRef || slugify(a.name) === needle || a.id === agentRef;
93
+ });
85
94
  if (match) {
86
95
  agentId = match.id;
87
- process.stderr.write(`[acp] Agent resolved by name: ${match.name} (${match.id}, mode: ${match.mode})\n`);
96
+ process.stderr.write(`[acp] ${match.name} (${match.mode})\n`);
88
97
  }
89
98
  else {
90
- process.stderr.write(`Error: Agent "${agentArg}" not found.\n` +
91
- `Available agents: ${agents.map((a) => a.name).join(', ') || '(none)'}\n`);
99
+ const available = agents.map((a) => a.slug || a.name.toLowerCase().replace(/\s+/g, '-')).join(', ');
100
+ process.stderr.write(`Error: Agent "${ref}" not found.\nAvailable: ${available || '(none)'}\n`);
92
101
  process.exit(1);
93
102
  }
94
103
  }
95
- catch (listErr) {
96
- process.stderr.write(`Error: Could not resolve agent "${agentArg}": ${listErr}\n`);
104
+ catch (err) {
105
+ process.stderr.write(`Error: Could not resolve agent "${ref}": ${err}\n`);
97
106
  process.exit(1);
98
107
  }
99
108
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almyty/acp-server",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "ACP agent server for almyty — expose any almyty agent via the Agent Client Protocol",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",