@1agents/acp-service 0.1.4 → 0.2.0
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/README.md +89 -114
- package/dist/bin/acp-service.js +1 -1
- package/dist/src/acp-connection.d.ts +26 -0
- package/dist/src/acp-connection.js +512 -0
- package/dist/src/acp-state.d.ts +19 -0
- package/dist/src/acp-state.js +44 -0
- package/dist/src/bridge.d.ts +12 -3
- package/dist/src/bridge.js +985 -887
- package/dist/src/catalog-descriptors.d.ts +11 -0
- package/dist/src/catalog-descriptors.js +173 -0
- package/dist/src/catalog.d.ts +30 -0
- package/dist/src/catalog.js +132 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +1 -0
- package/dist/src/manifest.d.ts +0 -6
- package/dist/src/manifest.js +4 -0
- package/dist/src/server.d.ts +1 -0
- package/dist/src/server.js +12 -0
- package/package.json +14 -13
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Display and legacy client metadata migrated from 1agents_app. ACP launch support comes from the runtime registry. */
|
|
2
|
+
export declare const catalogDescriptors: {
|
|
3
|
+
type: string;
|
|
4
|
+
label: string;
|
|
5
|
+
binary: string;
|
|
6
|
+
acp_capable: boolean;
|
|
7
|
+
cli_capable: boolean;
|
|
8
|
+
cc_transport: string;
|
|
9
|
+
integrated: boolean;
|
|
10
|
+
install_command: string;
|
|
11
|
+
}[];
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/** Display and legacy client metadata migrated from 1agents_app. ACP launch support comes from the runtime registry. */
|
|
2
|
+
export const catalogDescriptors = [
|
|
3
|
+
{
|
|
4
|
+
"type": "claudecode",
|
|
5
|
+
"label": "Claude Code",
|
|
6
|
+
"binary": "claude",
|
|
7
|
+
"acp_capable": true,
|
|
8
|
+
"cli_capable": true,
|
|
9
|
+
"cc_transport": "cli-stream",
|
|
10
|
+
"integrated": true,
|
|
11
|
+
"install_command": "npm install -g @anthropic-ai/claude-code"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"type": "codex",
|
|
15
|
+
"label": "Codex",
|
|
16
|
+
"binary": "codex",
|
|
17
|
+
"acp_capable": true,
|
|
18
|
+
"cli_capable": true,
|
|
19
|
+
"cc_transport": "cli-stream",
|
|
20
|
+
"integrated": true,
|
|
21
|
+
"install_command": "npm install -g @openai/codex"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"type": "grok-build",
|
|
25
|
+
"label": "Grok",
|
|
26
|
+
"binary": "grok",
|
|
27
|
+
"acp_capable": true,
|
|
28
|
+
"cli_capable": true,
|
|
29
|
+
"cc_transport": "acp",
|
|
30
|
+
"integrated": true,
|
|
31
|
+
"install_command": "curl -fsSL https://x.ai/cli/install.sh | bash"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"type": "deepseek-build",
|
|
35
|
+
"label": "DeepSeek",
|
|
36
|
+
"binary": "grok",
|
|
37
|
+
"acp_capable": true,
|
|
38
|
+
"cli_capable": true,
|
|
39
|
+
"cc_transport": "acp",
|
|
40
|
+
"integrated": true,
|
|
41
|
+
"install_command": "curl -fsSL https://x.ai/cli/install.sh | bash"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"type": "cursor",
|
|
45
|
+
"label": "Cursor Agent",
|
|
46
|
+
"binary": "agent",
|
|
47
|
+
"acp_capable": true,
|
|
48
|
+
"cli_capable": true,
|
|
49
|
+
"cc_transport": "cli-stream",
|
|
50
|
+
"integrated": true,
|
|
51
|
+
"install_command": "curl https://cursor.com/install -fsS | bash"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"type": "gemini",
|
|
55
|
+
"label": "Gemini",
|
|
56
|
+
"binary": "gemini",
|
|
57
|
+
"acp_capable": true,
|
|
58
|
+
"cli_capable": true,
|
|
59
|
+
"cc_transport": "cli-stream",
|
|
60
|
+
"integrated": true,
|
|
61
|
+
"install_command": "npm install -g @google/gemini-cli"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"type": "devin",
|
|
65
|
+
"label": "Devin",
|
|
66
|
+
"binary": "devin",
|
|
67
|
+
"acp_capable": true,
|
|
68
|
+
"cli_capable": true,
|
|
69
|
+
"cc_transport": "acp",
|
|
70
|
+
"integrated": true,
|
|
71
|
+
"install_command": "curl -fsSL https://cli.devin.ai/install.sh | bash"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"type": "iflow",
|
|
75
|
+
"label": "iFlow",
|
|
76
|
+
"binary": "iflow",
|
|
77
|
+
"acp_capable": true,
|
|
78
|
+
"cli_capable": true,
|
|
79
|
+
"cc_transport": "cli-stream",
|
|
80
|
+
"integrated": true,
|
|
81
|
+
"install_command": "npm install -g @iflow-ai/iflow-cli"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"type": "kimi",
|
|
85
|
+
"label": "Kimi",
|
|
86
|
+
"binary": "kimi",
|
|
87
|
+
"acp_capable": true,
|
|
88
|
+
"cli_capable": true,
|
|
89
|
+
"cc_transport": "cli-stream",
|
|
90
|
+
"integrated": true,
|
|
91
|
+
"install_command": "uv tool install --python 3.13 kimi-cli"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"type": "opencode",
|
|
95
|
+
"label": "OpenCode",
|
|
96
|
+
"binary": "opencode",
|
|
97
|
+
"acp_capable": true,
|
|
98
|
+
"cli_capable": true,
|
|
99
|
+
"cc_transport": "cli-stream",
|
|
100
|
+
"integrated": true,
|
|
101
|
+
"install_command": "curl -fsSL https://opencode.ai/install | bash"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"type": "pi",
|
|
105
|
+
"label": "Pi",
|
|
106
|
+
"binary": "pi",
|
|
107
|
+
"acp_capable": true,
|
|
108
|
+
"cli_capable": true,
|
|
109
|
+
"cc_transport": "cli-stream",
|
|
110
|
+
"integrated": true,
|
|
111
|
+
"install_command": "npm install -g @mariozechner/pi-coding-agent"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"type": "qoder",
|
|
115
|
+
"label": "Qoder",
|
|
116
|
+
"binary": "qodercli",
|
|
117
|
+
"acp_capable": true,
|
|
118
|
+
"cli_capable": true,
|
|
119
|
+
"cc_transport": "cli-stream",
|
|
120
|
+
"integrated": true,
|
|
121
|
+
"install_command": "npm install -g @qoder-ai/qodercli"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"type": "antigravity",
|
|
125
|
+
"label": "Antigravity",
|
|
126
|
+
"binary": "agy",
|
|
127
|
+
"acp_capable": false,
|
|
128
|
+
"cli_capable": true,
|
|
129
|
+
"cc_transport": "",
|
|
130
|
+
"integrated": false,
|
|
131
|
+
"install_command": "curl -fsSL https://antigravity.google/cli/install.sh | bash"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"type": "openhands",
|
|
135
|
+
"label": "OpenHands",
|
|
136
|
+
"binary": "openhands",
|
|
137
|
+
"acp_capable": true,
|
|
138
|
+
"cli_capable": true,
|
|
139
|
+
"cc_transport": "",
|
|
140
|
+
"integrated": false,
|
|
141
|
+
"install_command": "uvx --python 3.12 --from openhands-ai openhands"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"type": "trae",
|
|
145
|
+
"label": "Trae",
|
|
146
|
+
"binary": "trae-cli",
|
|
147
|
+
"acp_capable": false,
|
|
148
|
+
"cli_capable": true,
|
|
149
|
+
"cc_transport": "",
|
|
150
|
+
"integrated": false,
|
|
151
|
+
"install_command": "git clone https://github.com/bytedance/trae-agent && cd trae-agent && uv sync --all-extras"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"type": "openclaw",
|
|
155
|
+
"label": "OpenClaw",
|
|
156
|
+
"binary": "openclaw",
|
|
157
|
+
"acp_capable": false,
|
|
158
|
+
"cli_capable": true,
|
|
159
|
+
"cc_transport": "",
|
|
160
|
+
"integrated": false,
|
|
161
|
+
"install_command": "npm install -g openclaw@latest"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"type": "hermes",
|
|
165
|
+
"label": "Hermes",
|
|
166
|
+
"binary": "hermes",
|
|
167
|
+
"acp_capable": true,
|
|
168
|
+
"cli_capable": true,
|
|
169
|
+
"cc_transport": "",
|
|
170
|
+
"integrated": false,
|
|
171
|
+
"install_command": "curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash"
|
|
172
|
+
}
|
|
173
|
+
];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface DiscoveryOptions {
|
|
2
|
+
home?: string;
|
|
3
|
+
env?: NodeJS.ProcessEnv;
|
|
4
|
+
platform?: NodeJS.Platform;
|
|
5
|
+
/** Package search roots, nearest first. Defaults to the runtime's ancestor directories. */
|
|
6
|
+
packageRoots?: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface AgentStatus {
|
|
9
|
+
id: string;
|
|
10
|
+
type: string;
|
|
11
|
+
label: string;
|
|
12
|
+
binary: string;
|
|
13
|
+
installed: boolean;
|
|
14
|
+
path?: string;
|
|
15
|
+
acp_capable: boolean;
|
|
16
|
+
cli_capable: boolean;
|
|
17
|
+
cc_transport: string;
|
|
18
|
+
integrated: boolean;
|
|
19
|
+
install_command?: string;
|
|
20
|
+
chat_ready: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Resolve an executable on PATH, then in user-local harness directories. */
|
|
23
|
+
export declare function findAgentBinary(binary: string, options?: DiscoveryOptions): string | undefined;
|
|
24
|
+
/** Fresh filesystem snapshot. An installed CLI may use the runtime's adapter download fallback on launch; scanning never downloads or authenticates. */
|
|
25
|
+
export declare function discoverAgents(options?: DiscoveryOptions): AgentStatus[];
|
|
26
|
+
/** Use the same resolved local commands as discovery, including binaries outside PATH. Explicit launches retain runtime fallback behavior. */
|
|
27
|
+
export declare function createServiceAgentRegistry(options?: DiscoveryOptions): {
|
|
28
|
+
list: () => string[];
|
|
29
|
+
resolve: (name: string) => string | string[];
|
|
30
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/** Local harness discovery shared by HTTP consumers and the service launcher. No processes or downloads are started by a scan. */
|
|
2
|
+
import { accessSync, closeSync, constants, openSync, readSync, readFileSync, statSync } from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { delimiter, dirname, isAbsolute, join, resolve } from 'node:path';
|
|
6
|
+
import { createAgentRegistry } from '@scottzx/1acp/runtime';
|
|
7
|
+
import { catalogDescriptors } from './catalog-descriptors.js';
|
|
8
|
+
const registry = createAgentRegistry();
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
const runtimeRoot = dirname(require.resolve('@scottzx/1acp/package.json'));
|
|
11
|
+
/** Resolve an executable on PATH, then in user-local harness directories. */
|
|
12
|
+
export function findAgentBinary(binary, options = {}) {
|
|
13
|
+
const env = options.env ?? process.env;
|
|
14
|
+
const platform = options.platform ?? process.platform;
|
|
15
|
+
const home = options.home ?? homedir();
|
|
16
|
+
const dirs = (env.PATH ?? '').split(platform === 'win32' ? ';' : delimiter).filter(Boolean);
|
|
17
|
+
dirs.push(join(home, '.local', 'bin'), join(home, '.grok', 'bin'));
|
|
18
|
+
const extensions = platform === 'win32' ? ['', ...(env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD').split(';')] : [''];
|
|
19
|
+
for (const dir of isAbsolute(binary) ? [''] : dirs) {
|
|
20
|
+
for (const ext of extensions) {
|
|
21
|
+
const candidate = resolve(dir, binary + ext);
|
|
22
|
+
try {
|
|
23
|
+
if (!statSync(candidate).isFile())
|
|
24
|
+
continue;
|
|
25
|
+
accessSync(candidate, platform === 'win32' ? constants.F_OK : constants.X_OK);
|
|
26
|
+
return candidate;
|
|
27
|
+
}
|
|
28
|
+
catch { /* Missing or non-executable candidate: continue the search. */ }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
function packageRoots() {
|
|
34
|
+
const roots = [];
|
|
35
|
+
for (let dir = runtimeRoot;; dir = dirname(dir)) {
|
|
36
|
+
roots.push(dir);
|
|
37
|
+
if (dirname(dir) === dir)
|
|
38
|
+
return roots;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function isNodeLauncher(bin) {
|
|
42
|
+
if (/\.[cm]?js$/.test(bin))
|
|
43
|
+
return true;
|
|
44
|
+
const fd = openSync(bin, 'r');
|
|
45
|
+
try {
|
|
46
|
+
const buffer = Buffer.alloc(200);
|
|
47
|
+
const size = readSync(fd, buffer, 0, buffer.length, 0);
|
|
48
|
+
return /^#!.*\bnode\b/.test(buffer.toString('utf8', 0, size));
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
closeSync(fd);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function packageLaunch(spec, extraArgs, options) {
|
|
55
|
+
const name = spec.replace(/@[^/]*$/, '');
|
|
56
|
+
for (const root of options.packageRoots ?? packageRoots()) {
|
|
57
|
+
try {
|
|
58
|
+
const dir = join(root, 'node_modules', name);
|
|
59
|
+
const manifest = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'));
|
|
60
|
+
if (manifest.name !== name)
|
|
61
|
+
continue;
|
|
62
|
+
const bins = typeof manifest.bin === 'string' ? [manifest.bin] : Object.values(manifest.bin ?? {});
|
|
63
|
+
if (bins.length !== 1 || typeof bins[0] !== 'string')
|
|
64
|
+
continue;
|
|
65
|
+
const bin = resolve(dir, bins[0]);
|
|
66
|
+
if (!statSync(bin).isFile())
|
|
67
|
+
continue;
|
|
68
|
+
// JS launchers need not be executable when run by Node; native bins do.
|
|
69
|
+
if (isNodeLauncher(bin)) {
|
|
70
|
+
return [process.execPath, bin, ...extraArgs];
|
|
71
|
+
}
|
|
72
|
+
const executable = findAgentBinary(bin, options);
|
|
73
|
+
if (executable)
|
|
74
|
+
return [executable, ...extraArgs];
|
|
75
|
+
}
|
|
76
|
+
catch { /* Package absent or incomplete: it is not locally launchable. */ }
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
function localLaunch(id, options) {
|
|
81
|
+
const argv = registry.resolve(id);
|
|
82
|
+
if (!Array.isArray(argv))
|
|
83
|
+
return undefined;
|
|
84
|
+
if (argv[0] === 'npx') {
|
|
85
|
+
const index = argv.findIndex((arg, i) => i > 0 && !arg.startsWith('-'));
|
|
86
|
+
return index < 0 ? undefined : packageLaunch(argv[index], argv.slice(index + 1), options);
|
|
87
|
+
}
|
|
88
|
+
// A package runner alone does not demonstrate an installed harness.
|
|
89
|
+
if (argv[0] === 'uvx')
|
|
90
|
+
return undefined;
|
|
91
|
+
const binary = findAgentBinary(argv[0], options);
|
|
92
|
+
return binary ? [binary, ...argv.slice(1)] : undefined;
|
|
93
|
+
}
|
|
94
|
+
/** Fresh filesystem snapshot. An installed CLI may use the runtime's adapter download fallback on launch; scanning never downloads or authenticates. */
|
|
95
|
+
export function discoverAgents(options = {}) {
|
|
96
|
+
const descriptors = new Map(catalogDescriptors.map(d => [d.type === 'claudecode' ? 'claude' : d.type, d]));
|
|
97
|
+
const supportedAgents = new Set(registry.list());
|
|
98
|
+
return [...new Set([...supportedAgents, ...descriptors.keys()])].map(id => {
|
|
99
|
+
const descriptor = descriptors.get(id);
|
|
100
|
+
const argv = registry.resolve(id);
|
|
101
|
+
const binary = descriptor?.binary ?? (Array.isArray(argv) && !['npx', 'uvx'].includes(argv[0]) ? argv[0] : id);
|
|
102
|
+
const path = findAgentBinary(binary, options);
|
|
103
|
+
const supported = supportedAgents.has(id);
|
|
104
|
+
return {
|
|
105
|
+
id, type: descriptor?.type ?? id, label: descriptor?.label ?? id, binary,
|
|
106
|
+
installed: !!path, ...(path ? { path } : {}),
|
|
107
|
+
acp_capable: supported || descriptor?.acp_capable === true,
|
|
108
|
+
cli_capable: descriptor?.cli_capable ?? true,
|
|
109
|
+
cc_transport: descriptor?.cc_transport ?? '', integrated: descriptor?.integrated ?? false,
|
|
110
|
+
...(descriptor?.install_command ? { install_command: descriptor.install_command } : {}),
|
|
111
|
+
chat_ready: supported && (!!localLaunch(id, options) || (!!path && Array.isArray(argv) && argv[0] === 'npx' && !!findAgentBinary('npx', options))),
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/** Use the same resolved local commands as discovery, including binaries outside PATH. Explicit launches retain runtime fallback behavior. */
|
|
116
|
+
export function createServiceAgentRegistry(options = {}) {
|
|
117
|
+
return {
|
|
118
|
+
list: () => registry.list(),
|
|
119
|
+
resolve: (name) => {
|
|
120
|
+
const local = localLaunch(name, options);
|
|
121
|
+
if (local)
|
|
122
|
+
return local;
|
|
123
|
+
const fallback = registry.resolve(name);
|
|
124
|
+
if (Array.isArray(fallback) && fallback[0] === 'npx') {
|
|
125
|
+
const runner = findAgentBinary('npx', options);
|
|
126
|
+
if (runner)
|
|
127
|
+
return [runner, ...fallback.slice(1)];
|
|
128
|
+
}
|
|
129
|
+
return fallback;
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -8,3 +8,5 @@ export type { AccessDescriptor, NetworkService, NodeIdentity, NodeManifest, Reac
|
|
|
8
8
|
export { createAcpServer, serveAcpService } from './server.js';
|
|
9
9
|
export type { ServerOptions } from './server.js';
|
|
10
10
|
export { attachBridgeServer, activeSessions, sessionBackgroundTasks, killAllManagedAgents } from './bridge.js';
|
|
11
|
+
export { discoverAgents } from './catalog.js';
|
|
12
|
+
export type { AgentStatus, DiscoveryOptions } from './catalog.js';
|
package/dist/src/index.js
CHANGED
|
@@ -6,3 +6,4 @@
|
|
|
6
6
|
export { buildManifest, ACP_CAPABILITIES, DEFAULT_ACP_PORT } from './manifest.js';
|
|
7
7
|
export { createAcpServer, serveAcpService } from './server.js';
|
|
8
8
|
export { attachBridgeServer, activeSessions, sessionBackgroundTasks, killAllManagedAgents } from './bridge.js';
|
|
9
|
+
export { discoverAgents } from './catalog.js';
|
package/dist/src/manifest.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* acp-service 作为 DreamMate Network Service 时的 manifest 构建。
|
|
3
|
-
*
|
|
4
|
-
* 节点身份来自 `@1agents/dreammate-node`(优先 tailnet,回退本地),
|
|
5
|
-
* 保证整台机器上的所有服务共享同一个 node_id 与 name。
|
|
6
|
-
*/
|
|
7
1
|
import { nodeIdentity, type NodeIdentity } from '@1agents/dreammate-node';
|
|
8
2
|
import { PROTOCOL_VERSION, type AccessDescriptor, type NodeManifest, type Reachability, type Service as NetworkService } from '@1agents/dreammate-network';
|
|
9
3
|
export { nodeIdentity, PROTOCOL_VERSION };
|
package/dist/src/manifest.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* 节点身份来自 `@1agents/dreammate-node`(优先 tailnet,回退本地),
|
|
5
5
|
* 保证整台机器上的所有服务共享同一个 node_id 与 name。
|
|
6
6
|
*/
|
|
7
|
+
import { createAgentRegistry } from '@scottzx/1acp/runtime';
|
|
7
8
|
import { nodeIdentity } from '@1agents/dreammate-node';
|
|
8
9
|
import { PROTOCOL_VERSION, } from '@1agents/dreammate-network';
|
|
9
10
|
export { nodeIdentity, PROTOCOL_VERSION };
|
|
@@ -53,6 +54,9 @@ export async function buildManifest(baseUrl) {
|
|
|
53
54
|
protocol_version: PROTOCOL_VERSION,
|
|
54
55
|
identity_source: identity.source,
|
|
55
56
|
service_type: 'agent_runtime',
|
|
57
|
+
acp_protocol_version: 1,
|
|
58
|
+
acp_transport: 'websocket',
|
|
59
|
+
acp_agent_endpoints: Object.fromEntries(createAgentRegistry().list().map(name => [name, `/agents/${encodeURIComponent(name)}`])),
|
|
56
60
|
},
|
|
57
61
|
services: [
|
|
58
62
|
{
|
package/dist/src/server.d.ts
CHANGED
package/dist/src/server.js
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 单端口复用:
|
|
5
5
|
* - GET /health: 供 dreammate-node 与探活方检查运行状态
|
|
6
|
+
* - GET /agents: 返回本机 harness 安装状态与 ACP 可用性
|
|
6
7
|
* - GET /manifest: 返回符合 DreamMate Network 规范的节点能力清单
|
|
7
8
|
* - WebSocket: 处理与客户端(Web Chat、IM 机器人等)的全双工 ACP 会话
|
|
8
9
|
*/
|
|
9
10
|
import http from 'node:http';
|
|
11
|
+
import { discoverAgents } from './catalog.js';
|
|
10
12
|
import { nodeIdentity } from '@1agents/dreammate-node';
|
|
11
13
|
import { reportAndHoldRegistration } from '@1agents/dreammate-node/client';
|
|
12
14
|
import { buildManifest, ACP_CAPABILITIES, DEFAULT_ACP_PORT } from './manifest.js';
|
|
@@ -25,6 +27,10 @@ export function createAcpServer() {
|
|
|
25
27
|
try {
|
|
26
28
|
const url = new URL(req.url ?? '/', `http://${req.headers.host ?? 'localhost'}`);
|
|
27
29
|
const { pathname } = url;
|
|
30
|
+
if (req.method === 'GET' && pathname === '/agents') {
|
|
31
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
32
|
+
return json(res, 200, { agents: discoverAgents().map(({ path: _path, ...agent }) => agent) });
|
|
33
|
+
}
|
|
28
34
|
const identity = await nodeIdentity();
|
|
29
35
|
if (req.method === 'GET' && pathname === '/health') {
|
|
30
36
|
return json(res, 200, {
|
|
@@ -99,6 +105,12 @@ export async function serveAcpService(options = {}) {
|
|
|
99
105
|
: ` 未报备:${reported.reason}(node-agent 未就绪时不影响本服务独立提供能力)`);
|
|
100
106
|
}
|
|
101
107
|
const close = async () => {
|
|
108
|
+
const sockets = bridge.wss;
|
|
109
|
+
if (sockets) {
|
|
110
|
+
for (const client of sockets.clients)
|
|
111
|
+
client.terminate();
|
|
112
|
+
await new Promise((resolve) => sockets.close(() => resolve()));
|
|
113
|
+
}
|
|
102
114
|
await new Promise((resolve) => server.close(() => resolve()));
|
|
103
115
|
try {
|
|
104
116
|
await killAllManagedAgents();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1agents/acp-service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "DreamMate Network ACP Agent Runtime Service: cross-agent execution runtime for Claude Code, Grok, Codex and ACP-compatible agents.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dreammate",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "git+https://github.com/scottzx/
|
|
16
|
+
"url": "git+https://github.com/scottzx/1acp.git",
|
|
17
|
+
"directory": "packages/service"
|
|
17
18
|
},
|
|
18
19
|
"publishConfig": {
|
|
19
20
|
"access": "public",
|
|
@@ -36,26 +37,26 @@
|
|
|
36
37
|
"dist",
|
|
37
38
|
"README.md"
|
|
38
39
|
],
|
|
39
|
-
"scripts": {
|
|
40
|
-
"build": "tsc -p tsconfig.build.json",
|
|
41
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
42
|
-
"test": "npm run build && node --import tsx --test test/*.test.ts",
|
|
43
|
-
"prepack": "npm run build",
|
|
44
|
-
"start": "tsx bin/acp-service.ts"
|
|
45
|
-
},
|
|
46
40
|
"engines": {
|
|
47
|
-
"node": ">=22.
|
|
41
|
+
"node": ">=22.13.0"
|
|
48
42
|
},
|
|
49
43
|
"dependencies": {
|
|
50
44
|
"@1agents/dreammate-network": "^0.3.1",
|
|
51
45
|
"@1agents/dreammate-node": "^0.4.0",
|
|
52
|
-
"@
|
|
53
|
-
"ws": "^8.18.0"
|
|
46
|
+
"@agentclientprotocol/sdk": "1.4.0",
|
|
47
|
+
"ws": "^8.18.0",
|
|
48
|
+
"@scottzx/1acp": "^0.15.1"
|
|
54
49
|
},
|
|
55
50
|
"devDependencies": {
|
|
56
51
|
"@types/node": "^22.10.2",
|
|
57
52
|
"@types/ws": "^8.5.14",
|
|
58
53
|
"tsx": "^4.19.2",
|
|
59
54
|
"typescript": "^5.7.2"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsc -p tsconfig.build.json",
|
|
58
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
59
|
+
"test": "npm run build && node --import tsx --test test/*.test.ts",
|
|
60
|
+
"start": "tsx bin/acp-service.ts"
|
|
60
61
|
}
|
|
61
|
-
}
|
|
62
|
+
}
|