@1agents/acp-service 0.4.0 → 0.5.1
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 +14 -2
- package/dist/src/acp-connection.js +11 -6
- package/dist/src/bridge.js +10 -1
- package/dist/src/dsh.d.ts +6 -0
- package/dist/src/dsh.js +9 -0
- package/dist/src/package.d.ts +3 -0
- package/dist/src/package.js +3 -0
- package/package.json +43 -9
- package/vendor/dsh/LICENSE +21 -0
- package/vendor/dsh/README.md +101 -0
- package/vendor/dsh/adapter.d.ts +82 -0
- package/vendor/dsh/adapter.js +460 -0
- package/vendor/dsh/client.js +336 -0
- package/vendor/dsh/cordis.patch.yml +10 -0
- package/vendor/dsh/discovery.d.ts +4 -0
- package/vendor/dsh/discovery.js +20 -0
- package/vendor/dsh/imports.d.ts +54 -0
- package/vendor/dsh/imports.js +133 -0
- package/vendor/dsh/index.d.ts +5 -0
- package/vendor/dsh/index.js +84 -0
- package/vendor/dsh/preset.d.ts +7 -0
- package/vendor/dsh/preset.js +10 -0
- package/vendor/dsh/service-process.d.ts +10 -0
- package/vendor/dsh/service-process.js +150 -0
- package/vendor/dsh/service-worker.d.ts +1 -0
- package/vendor/dsh/service-worker.js +43 -0
- package/vendor/dsh/state.d.ts +22 -0
- package/vendor/dsh/state.js +47 -0
- package/vendor/dsh/tool-events.d.ts +26 -0
- package/vendor/dsh/tool-events.js +13 -0
- package/vendor/dsh/transport.d.ts +18 -0
- package/vendor/dsh/transport.js +71 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ ACP Agent Runtime Service for Codex, Grok Build, Claude Code and other Agents su
|
|
|
4
4
|
|
|
5
5
|
## Run
|
|
6
6
|
|
|
7
|
-
Requires Node.js 22.13 or later.
|
|
7
|
+
Requires Node.js 22.13 or later. Version 0.5 includes the 1ACP runtime, CLI, service, DSH plugin, browser controls, skills and licenses; installing a separate `@scottzx/1acp` package is unnecessary. The runtime and service retain their respective ACP SDK versions.
|
|
8
8
|
|
|
9
9
|
The runtime's per-session launch argv and transient credentials APIs support Provider Profiles. Public runtime APIs and flow authoring are available as `@1agents/acp-service/runtime` and `@1agents/acp-service/flows`. The `acp-service` command forwards runtime commands alongside its `serve` command.
|
|
10
10
|
|
|
@@ -37,6 +37,18 @@ HTTP endpoints:
|
|
|
37
37
|
- `GET /manifest`: DreamMate service discovery, ACP version, custom transport and Agent endpoint paths. Profiles listed here describe registered launch configurations, not a successful installation/authentication probe.
|
|
38
38
|
- `GET /services`: current service/session counts.
|
|
39
39
|
|
|
40
|
+
## DSH installation
|
|
41
|
+
|
|
42
|
+
The same npm package can be installed as a DSH bundle:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
pnpm dsh plugin --profile web add @1agents/acp-service
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
DSH reads the package's bundle patch and browser metadata; the CLI uses its `bin` entry. There is no installation-time mode switch, and both uses can coexist. The package root retains the service API and exposes Cordis metadata plus a lazy `apply`; merely importing it starts no plugin or process. `/service` is the service API, while `/dsh`, `/dsh/preset` and `/dsh/imports` provide the typed plugin interfaces. DSH host dependencies are supplied by DSH rather than installed with the CLI.
|
|
49
|
+
|
|
50
|
+
The plugin starts or reuses a local service when activated. See [DSH plugin usage](vendor/dsh/README.md) for presets, browser controls, configuration and lifecycle. Before migrating, stop DSH and remove `@1agents/dsh-acp`, then add the unified package; keep session bindings and preserve custom row configuration. Plugin and preset IDs are unchanged.
|
|
51
|
+
|
|
40
52
|
## ACP connections
|
|
41
53
|
|
|
42
54
|
Connect to `ws://127.0.0.1:36812/agents/codex`, `/agents/grok-build`, `/agents/claude`, or another registered Agent name. `/` selects Codex. Each WebSocket text message contains one UTF-8 JSON-RPC object. Batch messages and the former `action/event` envelopes are rejected. WebSocket is a custom transport permitted by ACP, not the standard stdio transport.
|
|
@@ -134,7 +146,7 @@ Nonstandard metadata is namespaced; standard `session/update` content is still a
|
|
|
134
146
|
|
|
135
147
|
Upgrade the service and 1agents Go client together. Old `action/event` WebSocket clients are not supported by 0.2. The Go `internal/acpwire` client converts existing chat view messages to standard ACP and negotiated extensions; frontend view state can remain unchanged. It stores the returned service session ID for future reconnects and explicitly imports older native IDs when needed.
|
|
136
148
|
|
|
137
|
-
The npm `@1agents/acp-bridge` launcher must use a dependency range that accepts service 0.
|
|
149
|
+
The npm `@1agents/acp-bridge` launcher must use a dependency range that accepts service 0.5 to adopt this release. There is one public package; the DSH plugin is embedded and needs no separate release. Install from the workspace root with `pnpm install --frozen-lockfile`; build runtime, then service. Development supervision locates `services/1acp/packages/service`.
|
|
138
150
|
|
|
139
151
|
## Verify
|
|
140
152
|
|
|
@@ -104,12 +104,19 @@ function envelope(value) {
|
|
|
104
104
|
const { event: _event, ...fields } = value;
|
|
105
105
|
return { [NS]: fields };
|
|
106
106
|
}
|
|
107
|
-
function updateFor(event) {
|
|
107
|
+
function updateFor(event, toolUpdate = false) {
|
|
108
108
|
const common = { _meta: envelope(event) };
|
|
109
109
|
switch (event.event) {
|
|
110
110
|
case 'text_delta': return { ...common, sessionUpdate: event.type === 'thought' ? 'agent_thought_chunk' : 'agent_message_chunk', content: { type: 'text', text: event.text || '' } };
|
|
111
|
-
case 'tool_call':
|
|
112
|
-
|
|
111
|
+
case 'tool_call': {
|
|
112
|
+
const fields = { ...common, toolCallId: event.toolCallId, title: event.title ?? event.toolName, status: event.status,
|
|
113
|
+
kind: event.kind, rawInput: event.arguments, rawOutput: event.rawOutput, content: event.content, locations: event.locations };
|
|
114
|
+
return toolUpdate ? { ...fields, sessionUpdate: 'tool_call_update' }
|
|
115
|
+
: { ...fields, sessionUpdate: 'tool_call', title: fields.title ?? 'Tool', status: fields.status ?? 'pending' };
|
|
116
|
+
}
|
|
117
|
+
case 'tool_result': return { ...common, sessionUpdate: 'tool_call_update', toolCallId: event.toolCallId, status: event.isError ? 'failed' : 'completed',
|
|
118
|
+
...(event.rawOutput !== undefined ? { rawOutput: event.rawOutput } : event.text ? { rawOutput: event.text } : {}),
|
|
119
|
+
...(event.content !== undefined ? { content: event.content } : event.text ? { content: [{ type: 'content', content: { type: 'text', text: event.text } }] } : {}) };
|
|
113
120
|
case 'mode_changed': return { ...common, sessionUpdate: 'current_mode_update', currentModeId: event.payload.currentModeId };
|
|
114
121
|
case 'available_commands_update': return { ...common, sessionUpdate: 'available_commands_update', availableCommands: event.payload.availableCommands.map((c) => ({ name: c.name, description: c.description || '', ...(c.hasInput ? { input: { hint: c.inputHint || 'Arguments' } } : {}) })) };
|
|
115
122
|
case 'plan': return { ...common, sessionUpdate: 'plan', entries: event.entries || event.payload?.entries || [] };
|
|
@@ -241,11 +248,9 @@ export function attachAcpConnection(ws, req, backend = production, state = new A
|
|
|
241
248
|
const summary = backend.sessions.get(sessionId)?.acpResponsePolicy === 'summary';
|
|
242
249
|
if (event.event === 'text_delta' && event.type !== 'thought')
|
|
243
250
|
answers.set(sessionId, (answers.get(sessionId) || '') + (event.text || ''));
|
|
244
|
-
let update = updateFor(event);
|
|
251
|
+
let update = updateFor(event, event.event === 'tool_call' && toolsSeen.has(`${sessionId}:${event.toolCallId}`));
|
|
245
252
|
if (update?.sessionUpdate === 'tool_call') {
|
|
246
253
|
const key = `${sessionId}:${update.toolCallId}`;
|
|
247
|
-
if (toolsSeen.has(key))
|
|
248
|
-
update = { ...update, sessionUpdate: 'tool_call_update' };
|
|
249
254
|
toolsSeen.add(key);
|
|
250
255
|
}
|
|
251
256
|
if (update) {
|
package/dist/src/bridge.js
CHANGED
|
@@ -2487,10 +2487,17 @@ async function runPromptTurn(session, sessionId, promptItem) {
|
|
|
2487
2487
|
// so the frontend can treat status as authoritative over heuristics.
|
|
2488
2488
|
const rawStatus = typeof event.status === "string" ? event.status : undefined;
|
|
2489
2489
|
const toolStatus = rawStatus === "success" ? "completed" : rawStatus || undefined;
|
|
2490
|
+
// The runtime synthesizes "tool call" for sparse ACP updates.
|
|
2491
|
+
// Do not replace a previously supplied title with that display fallback.
|
|
2492
|
+
const toolTitle = event.tag === "tool_call_update" && event.title === "tool call"
|
|
2493
|
+
? undefined : event.title;
|
|
2490
2494
|
sendRuntimeTurnEvent(targetWs, sessionId, turn, {
|
|
2491
2495
|
event: "tool_call",
|
|
2492
2496
|
content: event.content,
|
|
2493
|
-
toolName
|
|
2497
|
+
...(event.toolName || event.kind || toolTitle
|
|
2498
|
+
? { toolName: resolveToolDisplayName(event) } : {}),
|
|
2499
|
+
...(toolTitle !== undefined ? { title: toolTitle } : {}),
|
|
2500
|
+
...(event.rawOutput !== undefined ? { rawOutput: event.rawOutput } : {}),
|
|
2494
2501
|
toolCallId: event.toolCallId,
|
|
2495
2502
|
...(event.agentTurnId ? { agentTurnId: event.agentTurnId } : {}),
|
|
2496
2503
|
...(event.rawInput !== undefined ? { arguments: event.rawInput } : {}),
|
|
@@ -2519,6 +2526,8 @@ async function runPromptTurn(session, sessionId, promptItem) {
|
|
|
2519
2526
|
toolCallId: event.toolCallId,
|
|
2520
2527
|
toolName: resolveToolDisplayName(event),
|
|
2521
2528
|
text: textContent,
|
|
2529
|
+
...(event.rawOutput !== undefined ? { rawOutput: event.rawOutput } : {}),
|
|
2530
|
+
...(event.content !== undefined ? { content: event.content } : {}),
|
|
2522
2531
|
isError: toolStatus === "failed",
|
|
2523
2532
|
...(event.agentTurnId ? { agentTurnId: event.agentTurnId } : {}),
|
|
2524
2533
|
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Host services are requested only when DSH activates this package as a plugin. */
|
|
2
|
+
export declare const name = "oneagents-acp";
|
|
3
|
+
export declare const inject: string[];
|
|
4
|
+
/** Keep the service API usable without loading plugin code or DSH declarations.
|
|
5
|
+
* The fully typed plugin entry is available from /dsh. */
|
|
6
|
+
export declare function apply(ctx: unknown, input?: Record<string, unknown>): Promise<void>;
|
package/dist/src/dsh.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Host services are requested only when DSH activates this package as a plugin. */
|
|
2
|
+
export const name = 'oneagents-acp';
|
|
3
|
+
export const inject = ['llm', 'agents', 'approval', 'userQuestions', 'commands', 'sessionProjections', 'webServer', 'sessionController', 'agentPresets', 'sessions', 'sessionPersistence', 'workspaceRegistry'];
|
|
4
|
+
/** Keep the service API usable without loading plugin code or DSH declarations.
|
|
5
|
+
* The fully typed plugin entry is available from /dsh. */
|
|
6
|
+
export async function apply(ctx, input = {}) {
|
|
7
|
+
const plugin = await import(new URL('../../vendor/dsh/index.js', import.meta.url).href);
|
|
8
|
+
await plugin.apply(ctx, input);
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1agents/acp-service",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "ACP runtime, CLI, HTTP/WebSocket service and DeepSeek Harness plugin in one package.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dreammate",
|
|
7
7
|
"acp",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"registry": "https://registry.npmjs.org"
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
|
-
"main": "./dist/src/
|
|
25
|
-
"types": "./dist/src/
|
|
24
|
+
"main": "./dist/src/package.js",
|
|
25
|
+
"types": "./dist/src/package.d.ts",
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|
|
28
|
-
"types": "./dist/src/
|
|
29
|
-
"import": "./dist/src/
|
|
28
|
+
"types": "./dist/src/package.d.ts",
|
|
29
|
+
"import": "./dist/src/package.js"
|
|
30
30
|
},
|
|
31
31
|
"./package.json": "./package.json",
|
|
32
32
|
"./runtime": {
|
|
@@ -41,7 +41,25 @@
|
|
|
41
41
|
"./agent-registry": {
|
|
42
42
|
"types": "./vendor/runtime/dist/agent-registry.d.ts",
|
|
43
43
|
"import": "./vendor/runtime/dist/agent-registry.js"
|
|
44
|
-
}
|
|
44
|
+
},
|
|
45
|
+
"./service": {
|
|
46
|
+
"types": "./dist/src/index.d.ts",
|
|
47
|
+
"import": "./dist/src/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./dsh": {
|
|
50
|
+
"types": "./vendor/dsh/index.d.ts",
|
|
51
|
+
"import": "./vendor/dsh/index.js"
|
|
52
|
+
},
|
|
53
|
+
"./dsh/preset": {
|
|
54
|
+
"types": "./vendor/dsh/preset.d.ts",
|
|
55
|
+
"import": "./vendor/dsh/preset.js"
|
|
56
|
+
},
|
|
57
|
+
"./dsh/imports": {
|
|
58
|
+
"types": "./vendor/dsh/imports.d.ts",
|
|
59
|
+
"import": "./vendor/dsh/imports.js"
|
|
60
|
+
},
|
|
61
|
+
"./client": "./vendor/dsh/client.js",
|
|
62
|
+
"./cordis.patch.yml": "./vendor/dsh/cordis.patch.yml"
|
|
45
63
|
},
|
|
46
64
|
"bin": {
|
|
47
65
|
"acp-service": "dist/bin/acp-service.js"
|
|
@@ -72,10 +90,26 @@
|
|
|
72
90
|
"typescript": "^5.7.2",
|
|
73
91
|
"@scottzx/1acp": "0.16.0"
|
|
74
92
|
},
|
|
93
|
+
"dsh": {
|
|
94
|
+
"bundle": {
|
|
95
|
+
"patch": "./vendor/dsh/cordis.patch.yml"
|
|
96
|
+
},
|
|
97
|
+
"client": {
|
|
98
|
+
"platform": "web",
|
|
99
|
+
"inject": [
|
|
100
|
+
"@deepseek-ai/dsh-client-ui-commands",
|
|
101
|
+
"@deepseek-ai/dsh-client-ui-conversation",
|
|
102
|
+
"@deepseek-ai/dsh-client-ui-chat",
|
|
103
|
+
"@deepseek-ai/dsh-client-locale",
|
|
104
|
+
"@deepseek-ai/dsh-api-remotes"
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
},
|
|
75
108
|
"scripts": {
|
|
76
109
|
"build": "node ../../scripts/embed-runtime.mjs && tsc -p tsconfig.build.json",
|
|
77
110
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
78
|
-
"test": "npm run build &&
|
|
79
|
-
"start": "tsx bin/acp-service.ts"
|
|
111
|
+
"test": "npm run build && npm run test:only",
|
|
112
|
+
"start": "tsx bin/acp-service.ts",
|
|
113
|
+
"test:only": "node --import tsx --test test/*.test.ts"
|
|
80
114
|
}
|
|
81
115
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 OpenClaw Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# DSH plugin in @1agents/acp-service
|
|
2
|
+
|
|
3
|
+
An out-of-tree DeepSeek Harness plugin for persistent external ACP Agent sessions. It requires the local DSH plugin and preset APIs available in 0.1.7-rc.2 and is embedded with the runtime and service in the single public `@1agents/acp-service` 0.5 package. This directory is a private source module, not a separately installable npm package. No DSH source files are modified.
|
|
4
|
+
|
|
5
|
+
## Use
|
|
6
|
+
|
|
7
|
+
For an existing `@1agents/dsh-acp` installation, stop DSH, remove that bundle and add `@1agents/acp-service`. Keep existing binding files and copy any custom row configuration. The same plugin and preset IDs preserve session identity. Custom preset rows now load `@1agents/acp-service/dsh/preset`.
|
|
8
|
+
|
|
9
|
+
Install the published bundles from your DSH checkout:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pnpm dsh plugin --profile web add @1agents/acp-service @1agents/session-reader
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
If pnpm pauses the first install for the transitive `esbuild` build script, set `allowBuilds: { esbuild: false }` in that profile's `pnpm-workspace.yaml` and repeat the install. Automatic ACP startup uses published JavaScript and works without running that install script.
|
|
16
|
+
|
|
17
|
+
The package declares `dsh.bundle.patch` and its browser entry, so installation selects the bundle automatically. Restart `pnpm dsh web` after updating packages. If you use an installed `dsh` executable, omit the leading `pnpm`. Replace `web` with `desktop` for the desktop profile.
|
|
18
|
+
|
|
19
|
+
The plugin starts its bundled ACP service on `127.0.0.1:36812` when no service is listening. An existing healthy ACP service is reused. Start DSH normally; no separate service command is needed. To manage the service yourself, set `serviceMode: external` and run:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npx --yes @1agents/acp-service@^0.5.0 serve --host 127.0.0.1 --port 36812 --no-report
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The service requires each native Agent’s CLI and credentials. Installing the package alone starts no process; activating the plugin starts the service. For local development, install the built checkout with `pnpm dsh plugin --profile web add /absolute/path/1acp/packages/service`.
|
|
26
|
+
|
|
27
|
+
Choose a discovered **ACP · Agent** in the new-session Agent preset picker, choose a workspace, then send a message. ACP routes are not listed as ordinary DSH models, and the adapter rejects requests from ordinary presets, including previously saved ACP routes. Before the first turn, switching the Agent preset replaces the discovery connection and its native commands. Once a turn starts, the session keeps its remote Agent and workspace; start a new session to change Agent. Native Agent binaries and authentication belong to acp-service.
|
|
28
|
+
|
|
29
|
+
The bundle registers an ACP adapter through DSH's public streaming extension and routes the ACP presets to it. It sends newly admitted messages whose source is `user` to `session/prompt`, not to `subagent-acp`; there is no coordinating DeepSeek model call. DSH-generated workspace instructions and runtime-context messages are excluded. The external Agent owns its model, prompt, tools and native history, including any project instructions it discovers itself. DSH owns its UI and local user/assistant transcript. External tool progress is preserved as display metadata on empty text blocks in DSH's existing assistant stream records and projected onto expandable ACP tool cards. ACP updates retain previously supplied fields, and replay is deduplicated by the managed turn sequence. These snapshots contain no visible text and never dispatch local tools; they use the existing persisted session format so conversations can reopen normally. Only Agent thought chunks enter the thinking stream.
|
|
30
|
+
|
|
31
|
+
## Continue imported native sessions
|
|
32
|
+
|
|
33
|
+
With `@1agents/session-reader` installed, choose **在 DSH 中继续原会话** on a Claude, Codex or Grok history. The original workspace must still exist. The plugin restores the native session through acp-service's `_1agents/session/import`, creates DSH history under the matching ACP preset, and attaches it to that workspace. Importing sends no prompt. Subsequent messages go to the original Agent; imported messages are never resent, including an unfinished trailing user message. Unsupported sources stay readable in session-reader.
|
|
34
|
+
|
|
35
|
+
Imported bindings use `session/resume` because the service does not own a complete ACP replay of earlier native history. Existing ordinary ACP bindings continue using `session/load`. Endpoint, source provider and native ID identify an import; repeated admission reuses its DSH session without refreshing or replacing history. Old history-only DSH copies are not adopted. Original Agent history can continue changing outside DSH; the imported DSH history is a snapshot.
|
|
36
|
+
|
|
37
|
+
The service ID is saved before DSH creation. A failed local creation or workspace attachment can be retried after restart without importing again. Native restoration and authentication failures are reported, never replaced by a new empty session. If the transport is lost before the import response reaches the plugin, the plugin cannot know the service ID and does not automatically retry that RPC.
|
|
38
|
+
|
|
39
|
+
### Plugin service API
|
|
40
|
+
|
|
41
|
+
`ctx.oneagentsAcpSessions` is a Cordis service owned by this plugin; consumers may declare it optional so history browsing works without ACP. Its TypeScript declarations are exported from `@1agents/acp-service/dsh/imports`. Consumers call the service from the Host and must not instantiate it or write its binding files.
|
|
42
|
+
|
|
43
|
+
- `availability(provider)` returns `{ available, agent?, reason? }` without restoring a session. It checks configuration and the service inventory; successful native restoration remains the final capability/authentication check.
|
|
44
|
+
- `importSession({ provider, nativeSessionId, cwd, events })` accepts current DSH events starting at sequence zero. It returns `{ success: true, dshSessionId, workspace, workspaceId, agent, continuation: 'native' }` only after restoration, DSH creation and workspace attachment succeed.
|
|
45
|
+
|
|
46
|
+
Provider mapping is `claude → claude`, `codex → codex`, `grok → grok-build`. The service validates history through DSH before restoring a new native binding. No DSH Session format changes are required.
|
|
47
|
+
|
|
48
|
+
## Native commands and configuration
|
|
49
|
+
|
|
50
|
+
Opening an ACP session initializes or restores its remote session without sending a prompt. The plugin consumes `available_commands_update`, `config_option_update`, and mode updates. Advertised slash commands with names accepted by DSH (`[a-z][a-z0-9_-]*`) are registered in that session and forwarded verbatim through `session/prompt`, including their arguments. `/model` opens the model options advertised by the remote Agent. Choosing a model or reasoning setting uses `session/set_config_option`; choosing a mode uses `session/set_mode`. Unsupported options are not invented. Configuration changes are rejected while a turn runs.
|
|
51
|
+
|
|
52
|
+
The bundle disables the stock `ui-model-selection` row and supplies a session-aware model selector using DSH's existing UI slot and command contribution APIs. Ordinary sessions still select their DSH provider/model and reasoning effort; ACP sessions select only native Agent options. The Agent's additional options appear under **ACP 设置**. An idle ACP connection is retained so metadata updates and controls share the same session owner. The visible browser refreshes its capability snapshot every five seconds.
|
|
53
|
+
|
|
54
|
+
The bundle registers `oneagents-acp-*` presets with DSH's preset registry. Older filesystem presets remain untouched; DSH 0.1.7 uses registry declarations instead of scanning those files. ACP bindings are stored separately under `$DSH_HOME/plugins/1agents-acp/sessions`.
|
|
55
|
+
|
|
56
|
+
## Interactions and reconnection
|
|
57
|
+
|
|
58
|
+
ACP one-shot tool permissions use DSH's approval UI and policy. Grok questions and plan approval use its question UI. Persistent grants are not synthesized. Read operations follow acp-service's `approve-reads` policy; operations requiring permission are presented to the user.
|
|
59
|
+
|
|
60
|
+
Transport reconnects load the same service session and replay the current managed turn. Stable request IDs prevent duplicate execution, and update sequence numbers suppress duplicate output. A browser refresh leaves the Host request running. Stopping a DSH turn sends ACP cancellation. Provider errors fail the turn without automatic resubmission.
|
|
61
|
+
|
|
62
|
+
This plugin supports **text prompts**. Attachments and specialized external-tool cards are not implemented. Auxiliary DSH title/compaction calls cannot use this adapter; an advertised native compaction command runs in the external Agent. Existing standard-preset sessions that selected an old ACP route must choose a normal DSH model or start a new ACP-preset session.
|
|
63
|
+
|
|
64
|
+
## Configuration
|
|
65
|
+
|
|
66
|
+
The bundle's `oneagents-acp` row accepts `serviceUrl`, `serviceMode`, `serviceStartupTimeoutMs`, `serviceShutdownTimeoutMs`, `agents`, `stateDirectory`, `reconnectAttempts` and `reconnectDelayMs`. Change it through the profile's `cordis.patch.yml`, not the DSH repository. Use a new session after changing endpoint or workspace. When `agents` is omitted, plugin startup fetches `GET /agents` from acp-service and registers presets for entries with `chat_ready: true`, using their service-provided names. Discovery runs on the service host. Restart the plugin after installing or removing a harness. An explicit `agents` list bypasses discovery and preserves manual registry selection; `[]` registers no presets. Service startup, connection errors and invalid inventory responses fail plugin initialization instead of selecting fallback agents.
|
|
67
|
+
|
|
68
|
+
### Local service lifecycle
|
|
69
|
+
|
|
70
|
+
`serviceMode` defaults to `auto`. Only plain HTTP root URLs on `127.0.0.1`, `localhost` or `[::1]` can start a process. Remote URLs, HTTPS and URLs with a path or credentials remain external connections. `external` disables process management for every address. Use a stable nonzero port: native session bindings include the endpoint.
|
|
71
|
+
|
|
72
|
+
Before spawning, the plugin validates `/health`. Connection refusal permits startup; HTTP errors, authentication failures, timeouts and another application occupying the port fail explicitly. Startup waits for the child to listen and pass its health check before discovering Agent presets. `serviceStartupTimeoutMs` defaults to 15000 for each startup/health phase; `serviceShutdownTimeoutMs` defaults to 5000 before forced process exit.
|
|
73
|
+
|
|
74
|
+
Plugin disposal closes ACP connections before shutting down its owned service and awaiting process exit. Concurrent plugin instances in the same DSH process share an owned service until the last instance disposes. An existing service is never stopped. A worker also exits if its DSH parent crashes or is killed. If the worker itself crashes, requests fail through the normal ACP connection errors; restart the plugin to start a replacement. A service shared by separate DSH processes should be managed externally so stopping its owning DSH instance does not interrupt the others.
|
|
75
|
+
|
|
76
|
+
The child inherits DSH's environment, including native Agent configuration and credentials, and uses the service's existing state directory (`ACP_STATE_DIR` or `~/.1agents/acpx-state`). It starts with node reporting disabled. The plugin neither downloads executables at startup nor launches native Agents until a session needs one.
|
|
77
|
+
|
|
78
|
+
## Development and removal
|
|
79
|
+
|
|
80
|
+
Install and build from the repository root:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
pnpm install --frozen-lockfile
|
|
84
|
+
pnpm link:dsh /absolute/path/DSH
|
|
85
|
+
pnpm build
|
|
86
|
+
pnpm test:integration
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The DSH checkout must already have its dependencies installed and declaration outputs built. Development type checking links its matching packages into `node_modules/@deepseek-ai`; generated JavaScript has no runtime imports of those packages and uses the Host's provided services. Tests cover real-WebSocket streaming, permissions, questions, cancellation, reconnection and saved bindings.
|
|
90
|
+
|
|
91
|
+
For manual service debugging on this machine, start it from `../service` with:
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
CODEX_PATH=/Applications/ChatGPT.app/Contents/Resources/codex \
|
|
95
|
+
npm_config_cache="$HOME/.dsh/plugins/1agents-acp/npm-cache" \
|
|
96
|
+
node dist/bin/acp-service.js serve --host 127.0.0.1 --port 36812 --no-report
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
For automatic startup, set these environment variables on the DSH process instead. `CODEX_PATH` selects the installed app's newer Codex runtime; the global CLI on this machine rejects its configured `gpt-6-astra` model. The separate npm cache avoids a broken pre-existing npx cache. Neither setting changes the global Codex configuration.
|
|
100
|
+
|
|
101
|
+
Remove using `pnpm dsh plugin --profile web remove @1agents/acp-service`, then restart DSH; removing the bundle also restores the stock model-selection row. The preset registrations are removed with the bundle. Keep binding files if sessions may be reattached later.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
3
|
+
import type { LlmAdapter, GenerateOptions, StreamChunk, LlmModelInfo } from '@deepseek-ai/dsh-llm';
|
|
4
|
+
import type { SessionConfigOption, SessionModeState, AvailableCommand } from '@agentclientprotocol/sdk';
|
|
5
|
+
import { type Binding } from './state.js';
|
|
6
|
+
export interface Config {
|
|
7
|
+
serviceUrl: string;
|
|
8
|
+
agents: string[];
|
|
9
|
+
stateDirectory: string;
|
|
10
|
+
reconnectAttempts: number;
|
|
11
|
+
reconnectDelayMs: number;
|
|
12
|
+
}
|
|
13
|
+
export interface Capabilities {
|
|
14
|
+
agent: string;
|
|
15
|
+
commands: AvailableCommand[];
|
|
16
|
+
configOptions: SessionConfigOption[];
|
|
17
|
+
modes?: SessionModeState;
|
|
18
|
+
}
|
|
19
|
+
export declare class AcpAdapter implements LlmAdapter {
|
|
20
|
+
private ctx;
|
|
21
|
+
private config;
|
|
22
|
+
private state;
|
|
23
|
+
private controllers;
|
|
24
|
+
private jobs;
|
|
25
|
+
private links;
|
|
26
|
+
private connections;
|
|
27
|
+
private capabilities;
|
|
28
|
+
private commandScopes;
|
|
29
|
+
private commandContexts;
|
|
30
|
+
private commandDisposers;
|
|
31
|
+
private output;
|
|
32
|
+
private lifetime;
|
|
33
|
+
constructor(ctx: Context, config: Config);
|
|
34
|
+
providerInfo(provider: string): {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
};
|
|
38
|
+
providerRetryPolicy(): {
|
|
39
|
+
mode: "normal";
|
|
40
|
+
maxRetries: number;
|
|
41
|
+
retryableCodes: never[];
|
|
42
|
+
initialDelayMs: number;
|
|
43
|
+
maxDelayMs: number;
|
|
44
|
+
jitterRatio: number;
|
|
45
|
+
};
|
|
46
|
+
imageRequestPricing(): undefined;
|
|
47
|
+
listModels(provider: string): Promise<LlmModelInfo[]>;
|
|
48
|
+
resolveModel(provider: string, model: string): Promise<{
|
|
49
|
+
provider: string;
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
inputModalities: "text"[];
|
|
53
|
+
}>;
|
|
54
|
+
prepareCall(provider: string, model: string): Promise<{
|
|
55
|
+
model: {
|
|
56
|
+
provider: string;
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
inputModalities: "text"[];
|
|
60
|
+
};
|
|
61
|
+
stream: (o: GenerateOptions) => AsyncIterable<StreamChunk>;
|
|
62
|
+
}>;
|
|
63
|
+
dispose(): Promise<void>;
|
|
64
|
+
agentName(agent: Agent): string | undefined;
|
|
65
|
+
describe(agent: Agent): Promise<Capabilities | null>;
|
|
66
|
+
configure(agent: Agent, configId: string, value: string): Promise<Capabilities>;
|
|
67
|
+
/** Import native history without prompting; callers persist the returned service identity before creating DSH history.
|
|
68
|
+
* @param name Configured ACP registry identifier.
|
|
69
|
+
* @param cwd Existing original working directory.
|
|
70
|
+
* @param nativeSessionId Original Agent session identifier.
|
|
71
|
+
* @returns Binding using the service’s new identity and resume restoration mode.
|
|
72
|
+
*/
|
|
73
|
+
importNative(name: string, cwd: string, nativeSessionId: string): Promise<Binding>;
|
|
74
|
+
private publishCommands;
|
|
75
|
+
private connection;
|
|
76
|
+
private openConnection;
|
|
77
|
+
stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
|
|
78
|
+
private permission;
|
|
79
|
+
private question;
|
|
80
|
+
private plan;
|
|
81
|
+
private run;
|
|
82
|
+
}
|