@1agents/acp-service 0.10.11 → 0.11.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.
Files changed (126) hide show
  1. package/README.md +26 -0
  2. package/dist/bin/acp-service.js +6 -0
  3. package/dist/bin/dsh.d.ts +21 -0
  4. package/dist/bin/dsh.js +171 -0
  5. package/dist/src/catalog.js +13 -3
  6. package/dist/src/dsh-archive.d.ts +123 -0
  7. package/dist/src/dsh-archive.js +99 -0
  8. package/dist/src/dsh-host-client.d.ts +97 -0
  9. package/dist/src/dsh-host-client.js +275 -0
  10. package/dist/src/dsh-registry-file.d.ts +22 -0
  11. package/dist/src/dsh-registry-file.js +55 -0
  12. package/dist/src/dsh-session-files.d.ts +7 -0
  13. package/dist/src/dsh-session-files.js +63 -0
  14. package/dist/src/dsh.js +1 -1
  15. package/package.json +4 -4
  16. package/skills/acp-service/SKILL.md +1 -1
  17. package/vendor/dsh/README.md +1 -20
  18. package/vendor/dsh/index.d.ts +1 -4
  19. package/vendor/dsh/index.js +0 -17
  20. package/vendor/runtime/README.md +36 -11
  21. package/vendor/runtime/dist/{agent-registry-DxcyXXqb.js → agent-registry-CsdsVpJb.js} +209 -177
  22. package/vendor/runtime/dist/agent-registry-CsdsVpJb.js.map +1 -0
  23. package/vendor/runtime/dist/agent-registry.d.ts +0 -2
  24. package/vendor/runtime/dist/agent-registry.d.ts.map +1 -1
  25. package/vendor/runtime/dist/agent-registry.js +1 -1
  26. package/vendor/runtime/dist/{cli-BKmMxgix.js → cli-B5gQOSDl.js} +33 -14
  27. package/vendor/runtime/dist/cli-B5gQOSDl.js.map +1 -0
  28. package/vendor/runtime/dist/cli.d.ts +2 -6
  29. package/vendor/runtime/dist/cli.d.ts.map +1 -1
  30. package/vendor/runtime/dist/cli.js +189 -164
  31. package/vendor/runtime/dist/cli.js.map +1 -1
  32. package/vendor/runtime/dist/{client-C5zneoBs.d.ts → client-D5y4RXME.d.ts} +4 -12
  33. package/vendor/runtime/dist/client-D5y4RXME.d.ts.map +1 -0
  34. package/vendor/runtime/dist/docs-site/CLI.html +19 -21
  35. package/vendor/runtime/dist/docs-site/VISION.html +3 -2
  36. package/vendor/runtime/dist/docs-site/agents.html +10 -15
  37. package/vendor/runtime/dist/docs-site/assets/agents/Apache-2.0.txt +202 -0
  38. package/vendor/runtime/dist/docs-site/assets/agents/LobeHub-MIT.txt +21 -0
  39. package/vendor/runtime/dist/docs-site/assets/agents/Mux-AGPL-3.0.txt +661 -0
  40. package/vendor/runtime/dist/docs-site/assets/agents/README.md +41 -0
  41. package/vendor/runtime/dist/docs-site/assets/agents/ante.png +0 -0
  42. package/vendor/runtime/dist/docs-site/assets/agents/antigravity.png +0 -0
  43. package/vendor/runtime/dist/docs-site/assets/agents/claude.png +0 -0
  44. package/vendor/runtime/dist/docs-site/assets/agents/codex.png +0 -0
  45. package/vendor/runtime/dist/docs-site/assets/agents/copilot.png +0 -0
  46. package/vendor/runtime/dist/docs-site/assets/agents/cursor.png +0 -0
  47. package/vendor/runtime/dist/docs-site/assets/agents/deepseek-harness.png +0 -0
  48. package/vendor/runtime/dist/docs-site/assets/agents/devin.png +0 -0
  49. package/vendor/runtime/dist/docs-site/assets/agents/droid.png +0 -0
  50. package/vendor/runtime/dist/docs-site/assets/agents/fast-agent.png +0 -0
  51. package/vendor/runtime/dist/docs-site/assets/agents/fx.png +0 -0
  52. package/vendor/runtime/dist/docs-site/assets/agents/gemini.png +0 -0
  53. package/vendor/runtime/dist/docs-site/assets/agents/goose.png +0 -0
  54. package/vendor/runtime/dist/docs-site/assets/agents/grok-build.png +0 -0
  55. package/vendor/runtime/dist/docs-site/assets/agents/iflow.png +0 -0
  56. package/vendor/runtime/dist/docs-site/assets/agents/junie.png +0 -0
  57. package/vendor/runtime/dist/docs-site/assets/agents/kilocode.png +0 -0
  58. package/vendor/runtime/dist/docs-site/assets/agents/kimi.png +0 -0
  59. package/vendor/runtime/dist/docs-site/assets/agents/kiro.png +0 -0
  60. package/vendor/runtime/dist/docs-site/assets/agents/mcode.png +0 -0
  61. package/vendor/runtime/dist/docs-site/assets/agents/mux.png +0 -0
  62. package/vendor/runtime/dist/docs-site/assets/agents/octomind.png +0 -0
  63. package/vendor/runtime/dist/docs-site/assets/agents/openclaw.png +0 -0
  64. package/vendor/runtime/dist/docs-site/assets/agents/opencode.png +0 -0
  65. package/vendor/runtime/dist/docs-site/assets/agents/pi.png +0 -0
  66. package/vendor/runtime/dist/docs-site/assets/agents/pool.png +0 -0
  67. package/vendor/runtime/dist/docs-site/assets/agents/qoder.png +0 -0
  68. package/vendor/runtime/dist/docs-site/assets/agents/qwen.png +0 -0
  69. package/vendor/runtime/dist/docs-site/assets/agents/trae.png +0 -0
  70. package/vendor/runtime/dist/docs-site/assets/agents/zeroclaw.png +0 -0
  71. package/vendor/runtime/dist/docs-site/compare.html +8 -7
  72. package/vendor/runtime/dist/docs-site/config.html +5 -4
  73. package/vendor/runtime/dist/docs-site/custom-agents.html +13 -13
  74. package/vendor/runtime/dist/docs-site/exit-codes.html +4 -3
  75. package/vendor/runtime/dist/docs-site/flows.html +21 -8
  76. package/vendor/runtime/dist/docs-site/index.html +7 -6
  77. package/vendor/runtime/dist/docs-site/install.html +7 -6
  78. package/vendor/runtime/dist/docs-site/llms.txt +6 -6
  79. package/vendor/runtime/dist/docs-site/output-formats.html +9 -8
  80. package/vendor/runtime/dist/docs-site/permissions.html +5 -4
  81. package/vendor/runtime/dist/docs-site/prompting.html +9 -7
  82. package/vendor/runtime/dist/docs-site/quickstart.html +5 -4
  83. package/vendor/runtime/dist/docs-site/releasing.html +9 -8
  84. package/vendor/runtime/dist/docs-site/runtime-environment.html +28 -5
  85. package/vendor/runtime/dist/docs-site/runtime-process-lifecycle.html +13 -7
  86. package/vendor/runtime/dist/docs-site/safe-errors.html +3 -2
  87. package/vendor/runtime/dist/docs-site/session-control.html +7 -6
  88. package/vendor/runtime/dist/docs-site/session-watch.html +6 -5
  89. package/vendor/runtime/dist/docs-site/sessions.html +13 -10
  90. package/vendor/runtime/dist/docs-site/shared-sessions.html +7 -4
  91. package/vendor/runtime/dist/{flows-VrII9VKZ.js → flows-CDj5YcTh.js} +136 -68
  92. package/vendor/runtime/dist/flows-CDj5YcTh.js.map +1 -0
  93. package/vendor/runtime/dist/flows.d.ts +28 -19
  94. package/vendor/runtime/dist/flows.d.ts.map +1 -1
  95. package/vendor/runtime/dist/flows.js +1 -1
  96. package/vendor/runtime/dist/{invocation-options-DHMZ5Rrb.js → input-file-BsfVGZgn.js} +30 -15
  97. package/vendor/runtime/dist/input-file-BsfVGZgn.js.map +1 -0
  98. package/vendor/runtime/dist/{ipc-CNNM5DP_.js → ipc-DfqJsbk6.js} +114 -146
  99. package/vendor/runtime/dist/ipc-DfqJsbk6.js.map +1 -0
  100. package/vendor/runtime/dist/{output-DtzXtiBc.js → output-DOIF4iFc.js} +20 -47
  101. package/vendor/runtime/dist/output-DOIF4iFc.js.map +1 -0
  102. package/vendor/runtime/dist/{queue-owner-runtime-ehuh3SQU.js → queue-owner-runtime-DHBQbjXo.js} +394 -258
  103. package/vendor/runtime/dist/queue-owner-runtime-DHBQbjXo.js.map +1 -0
  104. package/vendor/runtime/dist/runtime.d.ts +37 -36
  105. package/vendor/runtime/dist/runtime.d.ts.map +1 -1
  106. package/vendor/runtime/dist/runtime.js +117 -172
  107. package/vendor/runtime/dist/runtime.js.map +1 -1
  108. package/vendor/runtime/dist/{session-options-NjpFwf-c.d.ts → session-options-Ci4aw1oD.d.ts} +13 -16
  109. package/vendor/runtime/dist/session-options-Ci4aw1oD.d.ts.map +1 -0
  110. package/vendor/runtime/dist/{session-watch-CbKfGRkZ.js → session-watch-DRwFHcWw.js} +5 -6
  111. package/vendor/runtime/dist/{session-watch-CbKfGRkZ.js.map → session-watch-DRwFHcWw.js.map} +1 -1
  112. package/vendor/runtime/dist/{watch-BGt4kcE6.js → watch-CUDGkljG.js} +3 -4
  113. package/vendor/runtime/dist/{watch-BGt4kcE6.js.map → watch-CUDGkljG.js.map} +1 -1
  114. package/vendor/runtime/package.json +3 -3
  115. package/vendor/runtime/skills/acpx/SKILL.md +42 -11
  116. package/vendor/dsh/auto-archive.d.ts +0 -103
  117. package/vendor/dsh/auto-archive.js +0 -175
  118. package/vendor/runtime/dist/agent-registry-DxcyXXqb.js.map +0 -1
  119. package/vendor/runtime/dist/cli-BKmMxgix.js.map +0 -1
  120. package/vendor/runtime/dist/client-C5zneoBs.d.ts.map +0 -1
  121. package/vendor/runtime/dist/flows-VrII9VKZ.js.map +0 -1
  122. package/vendor/runtime/dist/invocation-options-DHMZ5Rrb.js.map +0 -1
  123. package/vendor/runtime/dist/ipc-CNNM5DP_.js.map +0 -1
  124. package/vendor/runtime/dist/output-DtzXtiBc.js.map +0 -1
  125. package/vendor/runtime/dist/queue-owner-runtime-ehuh3SQU.js.map +0 -1
  126. package/vendor/runtime/dist/session-options-NjpFwf-c.d.ts.map +0 -1
@@ -0,0 +1,275 @@
1
+ /**
2
+ * Talking to a running DSH Host over its Typert RPC.
3
+ *
4
+ * The Host exposes its business services under `/api/<namespace>/<method>`
5
+ * with a JSON envelope. A browser session authenticates with a signed cookie;
6
+ * this module mints the same cookie from the local credential store, so the
7
+ * CLI acts as the Host's owner on the same machine that owns the Host.
8
+ */
9
+ import { createHash, createHmac } from 'node:crypto';
10
+ import { readFileSync } from 'node:fs';
11
+ import { execFileSync } from 'node:child_process';
12
+ import { staleArchiveIds } from './dsh-registry-file.js';
13
+ /** The credential record holding the browser-session signing secret. */
14
+ const BROWSER_SESSION_RECORD = 'client-connection/browser-session';
15
+ /** The cookie prefix the Host expects. */
16
+ const COOKIE_PREFIX = 'dsh-auth-';
17
+ /** Cookie lifetime the CLI mints. */
18
+ const COOKIE_LIFETIME_MS = 24 * 60 * 60 * 1000;
19
+ /**
20
+ * The id the CLI passes when it only wants the registry's current sets.
21
+ *
22
+ * Session ids are UUIDs or `session-<uuid>` forms, so this can never name a
23
+ * real session; `unarchiveSession` and `unpinSession` therefore return the
24
+ * complete sets without changing anything.
25
+ */
26
+ const REGISTRY_PROBE_ID = 'acp-service-cli-registry-probe';
27
+ /** An RPC failure reported by the Host. */
28
+ export class DshRpcError extends Error {
29
+ code;
30
+ constructor(code, message) {
31
+ super(message);
32
+ this.code = code;
33
+ this.name = 'DshRpcError';
34
+ }
35
+ }
36
+ const base64url = (bytes) => bytes.toString('base64').replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');
37
+ /**
38
+ * Read the browser-session signing secret from the local credential store.
39
+ *
40
+ * The store is a YAML document; this reads the one field it needs rather than
41
+ * taking a YAML dependency, and never returns the secret to the caller.
42
+ *
43
+ * @param credentialsPath - path to the credential document.
44
+ * @returns the signing secret.
45
+ */
46
+ export function readBrowserSessionSecret(credentialsPath) {
47
+ let text;
48
+ try {
49
+ text = readFileSync(credentialsPath, 'utf8');
50
+ }
51
+ catch (error) {
52
+ throw new Error(`cannot read ${credentialsPath}: ${error instanceof Error ? error.message : String(error)}`);
53
+ }
54
+ const start = text.indexOf(BROWSER_SESSION_RECORD);
55
+ if (start < 0)
56
+ throw new Error(`${credentialsPath} has no ${BROWSER_SESSION_RECORD} record`);
57
+ const secret = text.slice(start, start + 2048).match(/secret:\s*([A-Za-z0-9_-]+)/);
58
+ if (!secret)
59
+ throw new Error(`${credentialsPath} has no browser-session secret`);
60
+ return Buffer.from(secret[1], 'base64url');
61
+ }
62
+ /**
63
+ * Mint the signed browser-session cookie for one authority.
64
+ *
65
+ * @param secret - the signing secret from the credential store.
66
+ * @param authority - the host:port the cookie is scoped to.
67
+ * @returns the cookie header value.
68
+ */
69
+ export function mintSessionCookie(secret, authority) {
70
+ const issuedAt = Date.now();
71
+ const payload = { version: 1, authority, issuedAt, expiresAt: issuedAt + COOKIE_LIFETIME_MS };
72
+ const body = base64url(Buffer.from(JSON.stringify(payload), 'utf8'));
73
+ const signature = base64url(createHmac('sha256', secret).update(body).digest());
74
+ const name = COOKIE_PREFIX + createHash('sha256').update(authority).digest('base64url');
75
+ return `${name}=v1.${body}.${signature}`;
76
+ }
77
+ /**
78
+ * List the loopback TCP ports this machine is listening on.
79
+ *
80
+ * The desktop app binds an ephemeral port, so the CLI discovers the Host by
81
+ * probing local listeners rather than by a configured address.
82
+ *
83
+ * @returns the loopback ports, ascending.
84
+ */
85
+ export function listLoopbackPorts() {
86
+ let output = '';
87
+ try {
88
+ output = execFileSync('lsof', ['-nP', '-iTCP', '-sTCP:LISTEN'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
89
+ }
90
+ catch {
91
+ return [];
92
+ }
93
+ const ports = new Set();
94
+ for (const line of output.split('\n').slice(1)) {
95
+ // The NAME column holds the bound address, such as `127.0.0.1:51971` or
96
+ // `*:51971`, followed by the connection state.
97
+ const match = line.match(/TCP\s+\S*?:(\d+)\s+\(LISTEN\)\s*$/);
98
+ if (!match)
99
+ continue;
100
+ const port = Number.parseInt(match[1], 10);
101
+ if (Number.isInteger(port) && port > 0)
102
+ ports.add(port);
103
+ }
104
+ return [...ports].sort((left, right) => left - right);
105
+ }
106
+ /**
107
+ * Ask one origin whether it is a DSH Host that answers the session API.
108
+ *
109
+ * @param origin - the origin to probe.
110
+ * @param cookie - the minted cookie for that origin's authority.
111
+ * @returns whether the origin answered a session list.
112
+ */
113
+ export async function probeHost(origin, cookie) {
114
+ try {
115
+ const response = await fetch(`${origin}/api/session/list`, {
116
+ method: 'POST',
117
+ headers: { 'content-type': 'application/json', cookie },
118
+ body: JSON.stringify({ type: 'client-request', rpcId: 'probe', method: 'session/list', payload: { args: { _request: {} } } }),
119
+ signal: AbortSignal.timeout(5_000),
120
+ });
121
+ if (!response.ok)
122
+ return false;
123
+ const body = await response.json();
124
+ return body?.result?.ok === true;
125
+ }
126
+ catch {
127
+ return false;
128
+ }
129
+ }
130
+ /**
131
+ * Find a reachable DSH Host.
132
+ *
133
+ * An explicit origin is authoritative: the CLI uses the first named origin
134
+ * that answers, so a caller can target one instance on purpose. Without one
135
+ * the CLI probes the machine's loopback listeners, because the desktop app
136
+ * binds an ephemeral port that nothing else records; there it prefers a Host
137
+ * whose registry already holds every archived id, since two Hosts can share
138
+ * one DSH home and the older one's copy would drop the newer archives on its
139
+ * next write.
140
+ *
141
+ * @param origins - explicit origins from the command line.
142
+ * @param secret - the browser-session signing secret.
143
+ * @param documentArchived - archive ids the durable document records, when known.
144
+ * @returns the chosen origin.
145
+ */
146
+ export async function discoverHost(origins, secret, documentArchived) {
147
+ const explicit = [];
148
+ for (const origin of origins) {
149
+ const normalized = origin.replace(/\/+$/, '');
150
+ if (!explicit.includes(normalized))
151
+ explicit.push(normalized);
152
+ }
153
+ const probe = async (origin) => {
154
+ const authority = new URL(origin).host;
155
+ return await probeHost(origin, mintSessionCookie(secret, authority)) ? { origin, authority } : undefined;
156
+ };
157
+ if (explicit.length > 0) {
158
+ for (const origin of explicit) {
159
+ const endpoint = await probe(origin);
160
+ if (endpoint)
161
+ return endpoint;
162
+ }
163
+ throw new Error(`none of the given --url origins answered as a DSH Host: ${explicit.join(', ')}`);
164
+ }
165
+ const candidates = listLoopbackPorts().map(port => `http://127.0.0.1:${port}`);
166
+ const answering = [];
167
+ // Probe in small batches so one unresponsive listener cannot stall discovery.
168
+ for (let index = 0; index < candidates.length; index += 8) {
169
+ const batch = candidates.slice(index, index + 8);
170
+ const results = await Promise.all(batch.map(probe));
171
+ for (const result of results)
172
+ if (result)
173
+ answering.push(result);
174
+ }
175
+ if (answering.length === 0) {
176
+ throw new Error(`no reachable DSH Host found (tried ${candidates.length} local endpoint(s)); pass --url with the Host origin`);
177
+ }
178
+ if (documentArchived === undefined || documentArchived.length === 0)
179
+ return answering[0];
180
+ for (const endpoint of answering) {
181
+ const client = new DshHostClient(endpoint, mintSessionCookie(secret, endpoint.authority));
182
+ try {
183
+ const registry = await client.readRegistry();
184
+ if (staleArchiveIds(registry.archivedSessionIds, documentArchived).length === 0)
185
+ return endpoint;
186
+ }
187
+ catch {
188
+ // A Host that cannot report its registry is not preferred, but it still
189
+ // answered; it stays in the fallback set.
190
+ }
191
+ }
192
+ return answering[0];
193
+ }
194
+ /** A live DSH Host reached over RPC. */
195
+ export class DshHostClient {
196
+ endpoint;
197
+ cookie;
198
+ rpcId = 0;
199
+ /** The archive set this Host most recently reported, for the freshness check. */
200
+ lastArchivedSessionIds = [];
201
+ constructor(endpoint, cookie) {
202
+ this.endpoint = endpoint;
203
+ this.cookie = cookie;
204
+ }
205
+ /**
206
+ * Call one Host method.
207
+ *
208
+ * @param method - the `namespace/method` endpoint.
209
+ * @param args - the method's arguments.
210
+ * @returns the decoded result value.
211
+ */
212
+ async call(method, args) {
213
+ this.rpcId += 1;
214
+ const response = await fetch(`${this.endpoint.origin}/api/${method}`, {
215
+ method: 'POST',
216
+ headers: { 'content-type': 'application/json', cookie: this.cookie },
217
+ body: JSON.stringify({
218
+ type: 'client-request',
219
+ rpcId: `acp-service-${this.rpcId}`,
220
+ method,
221
+ payload: { args },
222
+ }),
223
+ signal: AbortSignal.timeout(60_000),
224
+ });
225
+ if (!response.ok)
226
+ throw new DshRpcError(`http/${response.status}`, `${method} returned HTTP ${response.status}`);
227
+ const body = await response.json();
228
+ if (body?.result?.ok !== true) {
229
+ const error = body?.result?.error;
230
+ throw new DshRpcError(error?.code ?? 'gateway/unknown', error?.message ?? `${method} failed`);
231
+ }
232
+ return body.result.value;
233
+ }
234
+ async listSessions() {
235
+ const value = await this.call('session/list', { _request: {} });
236
+ return value.items ?? [];
237
+ }
238
+ async readRegistry() {
239
+ // `unarchiveSession` and `unpinSession` are documented no-ops for an id
240
+ // that is not in the set, and each returns the complete resulting set.
241
+ // The sentinel is not a session id, so neither call can change anything.
242
+ const archived = await this.call('workspace/unarchiveSession', {
243
+ request: { sessionId: REGISTRY_PROBE_ID },
244
+ });
245
+ const pinned = await this.call('workspace/unpinSession', {
246
+ request: { sessionId: REGISTRY_PROBE_ID },
247
+ });
248
+ this.lastArchivedSessionIds = archived.archivedSessionIds ?? [];
249
+ return {
250
+ archivedSessionIds: this.lastArchivedSessionIds,
251
+ pinnedSessionIds: pinned.pinnedSessionIds ?? [],
252
+ };
253
+ }
254
+ async archiveSession(sessionId, options) {
255
+ await this.call('workspace/archiveSession', { request: { sessionId, stopActivity: options.stopActivity } });
256
+ }
257
+ /**
258
+ * Refuse to write through a Host whose registry is behind the document.
259
+ *
260
+ * The Host holds the registry in memory and rewrites the whole document on
261
+ * every change, so a Host that started before another Host wrote the
262
+ * document would drop the newer archive entries. The command reports this
263
+ * instead of silently undoing someone else's archives.
264
+ *
265
+ * @param documentArchived - the archive set the durable document records.
266
+ * @throws DshRpcError when the Host is behind the document.
267
+ */
268
+ async assertRegistryFresh(documentArchived) {
269
+ const stale = staleArchiveIds(this.lastArchivedSessionIds, documentArchived);
270
+ if (stale.length > 0) {
271
+ throw new DshRpcError('dsh/registry-stale', `this DSH instance is behind the durable registry: it is missing ${stale.length} archived session(s) that are recorded on disk. `
272
+ + 'Restart this DSH instance so it reloads the registry, then run the command again.');
273
+ }
274
+ }
275
+ }
@@ -0,0 +1,22 @@
1
+ /** The archive and pin sets as the document records them. */
2
+ export interface RegistryFileState {
3
+ readonly archivedSessionIds: readonly string[];
4
+ readonly pinnedSessionIds: readonly string[];
5
+ /** Whether the document was read at all. */
6
+ readonly found: boolean;
7
+ }
8
+ /**
9
+ * Read the durable registry document.
10
+ *
11
+ * @param dshHome - the DSH home directory.
12
+ * @returns the recorded sets, or an empty result when the document is absent.
13
+ */
14
+ export declare function readRegistryFile(dshHome: string): Promise<RegistryFileState>;
15
+ /**
16
+ * How far a Host's registry is behind the durable document.
17
+ *
18
+ * @param hostArchived - the archive set the running Host reported.
19
+ * @param fileArchived - the archive set the document records.
20
+ * @returns the ids the document holds and the Host does not.
21
+ */
22
+ export declare function staleArchiveIds(hostArchived: readonly string[], fileArchived: readonly string[]): string[];
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Reading the durable workspace registry from disk.
3
+ *
4
+ * The registry keeps its state in memory inside the running Host and writes
5
+ * the whole document on every change. When two Hosts share one DSH home — a
6
+ * `dsh web` instance and the desktop app, for example — the older one keeps a
7
+ * stale copy and would overwrite the newer one's archive set on its next
8
+ * write. The document on disk is therefore the record the CLI plans against,
9
+ * and the Host's own copy is checked against it before anything is written.
10
+ */
11
+ import { readFile } from 'node:fs/promises';
12
+ import { join } from 'node:path';
13
+ /** The registry document the workspace domain stores. */
14
+ const REGISTRY_FILENAME = 'workspace.json';
15
+ /**
16
+ * Read the durable registry document.
17
+ *
18
+ * @param dshHome - the DSH home directory.
19
+ * @returns the recorded sets, or an empty result when the document is absent.
20
+ */
21
+ export async function readRegistryFile(dshHome) {
22
+ const empty = { archivedSessionIds: [], pinnedSessionIds: [], found: false };
23
+ let text;
24
+ try {
25
+ text = await readFile(join(dshHome, 'storages', REGISTRY_FILENAME), 'utf8');
26
+ }
27
+ catch {
28
+ return empty;
29
+ }
30
+ try {
31
+ const document = JSON.parse(text);
32
+ const archived = document.global?.archivedSessionIds;
33
+ const pinned = document.global?.pinnedSessionIds;
34
+ return {
35
+ archivedSessionIds: Array.isArray(archived) ? archived.filter((id) => typeof id === 'string') : [],
36
+ pinnedSessionIds: Array.isArray(pinned) ? pinned.filter((id) => typeof id === 'string') : [],
37
+ found: true,
38
+ };
39
+ }
40
+ catch {
41
+ // A document that cannot be parsed is not a basis for a write decision.
42
+ return empty;
43
+ }
44
+ }
45
+ /**
46
+ * How far a Host's registry is behind the durable document.
47
+ *
48
+ * @param hostArchived - the archive set the running Host reported.
49
+ * @param fileArchived - the archive set the document records.
50
+ * @returns the ids the document holds and the Host does not.
51
+ */
52
+ export function staleArchiveIds(hostArchived, fileArchived) {
53
+ const host = new Set(hostArchived);
54
+ return fileArchived.filter(id => !host.has(id));
55
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Collect the newest modification time of every stored session.
3
+ *
4
+ * @param sessionsRoot - the directory holding one subdirectory per working directory.
5
+ * @returns modification times by session id, in epoch milliseconds.
6
+ */
7
+ export declare function readSessionFileMtimes(sessionsRoot: string): Promise<Map<string, number>>;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Reading the modification times of durable DSH session logs.
3
+ *
4
+ * A session's own record of its last activity stops at its last message, but
5
+ * its file keeps changing afterwards: a tool result, a title rewrite, a
6
+ * compaction. The file's mtime is therefore the other half of "when was this
7
+ * session last active", and the archive pass takes the later of the two.
8
+ */
9
+ import { readdir, stat } from 'node:fs/promises';
10
+ import { join } from 'node:path';
11
+ /** The session log files a session directory holds. */
12
+ const LOG_PREFIX = 'session.';
13
+ const LOG_SUFFIX = '.jsonl';
14
+ /**
15
+ * Collect the newest modification time of every stored session.
16
+ *
17
+ * @param sessionsRoot - the directory holding one subdirectory per working directory.
18
+ * @returns modification times by session id, in epoch milliseconds.
19
+ */
20
+ export async function readSessionFileMtimes(sessionsRoot) {
21
+ const mtimes = new Map();
22
+ let workspaces;
23
+ try {
24
+ workspaces = await readdir(sessionsRoot, { withFileTypes: true });
25
+ }
26
+ catch {
27
+ return mtimes;
28
+ }
29
+ await Promise.all(workspaces.filter(entry => entry.isDirectory()).map(async (workspace) => {
30
+ const workspaceDir = join(sessionsRoot, workspace.name);
31
+ let sessions;
32
+ try {
33
+ sessions = await readdir(workspaceDir, { withFileTypes: true });
34
+ }
35
+ catch {
36
+ return;
37
+ }
38
+ await Promise.all(sessions.filter(entry => entry.isDirectory()).map(async (session) => {
39
+ const sessionDir = join(workspaceDir, session.name);
40
+ let files;
41
+ try {
42
+ files = await readdir(sessionDir);
43
+ }
44
+ catch {
45
+ return;
46
+ }
47
+ const logs = files.filter(name => name.startsWith(LOG_PREFIX) && name.includes(LOG_SUFFIX));
48
+ let latest = 0;
49
+ for (const log of logs) {
50
+ try {
51
+ const info = await stat(join(sessionDir, log));
52
+ latest = Math.max(latest, info.mtimeMs);
53
+ }
54
+ catch {
55
+ // A log that vanished mid-read simply does not contribute.
56
+ }
57
+ }
58
+ if (latest > 0)
59
+ mtimes.set(session.name, Math.max(mtimes.get(session.name) ?? 0, latest));
60
+ }));
61
+ }));
62
+ return mtimes;
63
+ }
package/dist/src/dsh.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /** Host services are requested only when DSH activates this package as a plugin. */
2
2
  export const name = 'oneagents-acp';
3
- export const inject = ['llm', 'agents', 'approval', 'userQuestions', 'commands', 'sessionProjections', 'webServer', 'sessionController', 'agentPresets', 'sessions', 'sessionPersistence', 'workspaceRegistry', 'tools', 'connection', 'timer'];
3
+ export const inject = ['llm', 'agents', 'approval', 'userQuestions', 'commands', 'sessionProjections', 'webServer', 'sessionController', 'agentPresets', 'sessions', 'sessionPersistence', 'workspaceRegistry', 'tools', 'connection'];
4
4
  /** Keep the service API usable without loading plugin code or DSH declarations.
5
5
  * The fully typed plugin entry is available from /dsh. */
6
6
  export async function apply(ctx, input = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1agents/acp-service",
3
- "version": "0.10.11",
3
+ "version": "0.11.0",
4
4
  "description": "agent-workflow ACP runtime, CLI, HTTP/WebSocket service and DeepSeek Harness ACP/A2A plugins in one package. Part of 一芥天地 (DreamMate World).",
5
5
  "keywords": [
6
6
  "dreammate",
@@ -91,18 +91,18 @@
91
91
  "node": ">=22.13.0"
92
92
  },
93
93
  "dependencies": {
94
- "@1agents/acp-runtime-sdk": "npm:@agentclientprotocol/sdk@^1.5.0",
94
+ "@1agents/acp-runtime-sdk": "npm:@agentclientprotocol/sdk@^1.9.0",
95
95
  "@1agents/dreammate-network": "^0.5.0",
96
96
  "@1agents/dreammate-node": "^0.15.0",
97
97
  "@a2a-js/sdk": "1.3.0",
98
98
  "@agentclientprotocol/sdk": "1.4.0",
99
- "@openclaw/fs-safe": "^0.26.7",
99
+ "@openclaw/fs-safe": "^0.28.0",
100
100
  "commander": "^15.0.0",
101
101
  "dsh-zod": "npm:zod@4.4.3",
102
102
  "skillflag": "^0.2.1",
103
103
  "tsx": "^4.23.15",
104
104
  "ws": "^8.18.0",
105
- "zod": "^4.6.5"
105
+ "zod": "^4.6.7"
106
106
  },
107
107
  "devDependencies": {
108
108
  "@1agents/chat-view": "0.1.0",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: acp-service
3
- version: 0.10.6
3
+ version: 0.11.0
4
4
  description: 使用 @1agents/acp-service 管理 ACP 会话与 DSH 插件,通过 A2A 调用固定角色、派发临时任务、查询父子任务和执行轮次、记录业务验收及处理通知,并回投 Codex/DSH 原会话。也用于把已记录产物交给另一个角色(handoff_propose、handoff_decide、handoff_offer)、登记共享产物空间、项目/角色候选探查、目标登记和网络技能更新。用户说交接、下一跳、交给另一个角色、共享产物或 caseId 时使用。不用于无关的系统巡检或模型配置;执行中的 ACP 会话没有 handoff 工具。
5
5
  ---
6
6
 
@@ -101,26 +101,7 @@ This plugin supports **text prompts**. Attachments and specialized external-tool
101
101
 
102
102
  The bundle's `oneagents-acp` row accepts `serviceUrl`, `serviceMode`, `serviceStartupTimeoutMs`, `serviceShutdownTimeoutMs`, `agents`, `stateDirectory`, `diagnosticsDirectory`, `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.
103
103
 
104
- ### Automatic session archiving
105
-
106
- The plugin can periodically archive silent DSH sessions. It is **off by default**; enable it through the same plugin row in `cordis.patch.yml`:
107
-
108
- ```yaml
109
- - insert:
110
- - id: oneagents-acp
111
- name: '@1agents/acp-service'
112
- config:
113
- autoArchive:
114
- enabled: true
115
- # Defaults; all intervals are positive integer milliseconds.
116
- inactivityMs: 604800000 # 7 days
117
- scanIntervalMs: 86400000 # once a day
118
- initialDelayMs: 60000 # first sweep one minute after startup
119
- ```
120
-
121
- A session is silent when its last DSH activity is older than `inactivityMs`. Last activity is the later of DSH's own recency (creation time or last real user message) and the modification time of its durable session log, so a cold session with a recently written log is still considered active. The sweep uses DSH's own `workspaceRegistry.archiveSession(..., { stopActivity: true })`: the archive is durable, any running turn or background work is stopped the same way a user stop does, and archived sessions cannot wake or run model steps until restored.
122
-
123
- **Pinned sessions are exempt.** A pinned session is never auto-archived; pinning remains the explicit signal that you want to keep a conversation visible, so it must be archived manually. Already archived sessions and sessions whose turn started after a sweep began are skipped as well. A session is checked against the current DSH summary and stored-session listings, so the feature works for both open and cold sessions and does not itself open a session's event log.
104
+ Silent-session archiving is **not** part of the plugin. It runs as a manual command, `acp-service dsh archive`, so nothing periodic is installed into DSH; see the [service README](../../service/README.md#archiving-silent-dsh-sessions). The plugin row has no archive configuration and installs no timer.
124
105
 
125
106
  Explicitly authorized unattended work can declare `sessionPolicies`, with an exact absolute `cwd`, ACP registry `agent`, and optional `initialModeId`. A policy matches only that workspace and Agent; wildcards and duplicate scopes are rejected. New sessions select the advertised native mode before sending any prompt; an unavailable mode fails without prompting. A stored ACP 设置 record for the same workspace and Agent is applied on that new session, and its mode replaces `initialModeId`. Existing sessions keep their native mode and any ACP settings already selected or imported. `permissionMode` (`approve-reads`, `approve-all`, `deny-all`) may still appear in older configs and is ignored: the bridge does not apply that three-state shield. Mode and reasoning effort come from ACP 设置 (`session/set_mode`, `session/set_config_option`) or from the native session an import resumes. For example, an authorized Codex video workspace can use `initialModeId: "agent-full-access"` without changing the host's global model or other workspaces. Remove the declaration when the authorized batch ends; existing native sessions retain their own stored mode.
126
107
 
@@ -2,12 +2,9 @@ import type { Context } from '@deepseek-ai/cordis';
2
2
  import { type Config } from './adapter.js';
3
3
  import { type ServiceOptions } from './service-process.js';
4
4
  import { type DshA2AOptions } from './a2a.js';
5
- import { type AutoArchiveConfig } from './auto-archive.js';
6
5
  export type { DshA2AOptions } from './a2a.js';
7
6
  export { name, inject } from '@1agents/acp-service';
8
- export declare function apply(ctx: Context, input?: Partial<Config & ServiceOptions & {
9
- autoArchive?: Partial<AutoArchiveConfig>;
10
- }> & {
7
+ export declare function apply(ctx: Context, input?: Partial<Config & ServiceOptions> & {
11
8
  a2a?: DshA2AOptions;
12
9
  diagnosticsDirectory?: string;
13
10
  }): Promise<void>;
@@ -17,7 +17,6 @@ import { HANDOFF_PATH } from './handoff-spec.js';
17
17
  import { handoffTools } from './handoff-tools.js';
18
18
  import { runHandoffTool } from './handoff-executor.js';
19
19
  import { TICKET_PATH } from './ticket-spec.js';
20
- import { installAutoArchiveTimer, resolveAutoArchiveConfig, sweepAutoArchive } from './auto-archive.js';
21
20
  export { name, inject } from '@1agents/acp-service';
22
21
  export async function apply(ctx, input = {}) {
23
22
  const homePath = ctx.get('dshHomePath');
@@ -38,22 +37,6 @@ export async function apply(ctx, input = {}) {
38
37
  throw new Error('agents must contain ACP registry names');
39
38
  if (!Number.isSafeInteger(config.reconnectAttempts) || config.reconnectAttempts < 0 || !Number.isSafeInteger(config.reconnectDelayMs) || config.reconnectDelayMs < 1)
40
39
  throw new Error('Invalid ACP reconnect policy');
41
- const autoArchive = resolveAutoArchiveConfig(input.autoArchive);
42
- installAutoArchiveTimer(ctx, autoArchive, () => {
43
- void (async () => {
44
- const result = await sweepAutoArchive({
45
- listSummaries: async (signal) => (await ctx.sessionController.list({}, signal ?? new AbortController().signal)).items,
46
- listStored: () => ctx.sessionPersistence.list(),
47
- pinnedSessionIds: () => ctx.workspaceRegistry.pinnedSessionIds,
48
- archivedSessionIds: () => ctx.workspaceRegistry.archivedSessionIds,
49
- isActive: sessionId => ctx.agents.get(sessionId)?.status === 'running',
50
- archive: sessionId => ctx.workspaceRegistry.archiveSession(sessionId, { stopActivity: true }),
51
- log: message => ctx.logger.warn(message),
52
- }, Date.now(), autoArchive.inactivityMs);
53
- if (result.archived.length > 0)
54
- ctx.logger.info('auto-archive: archived %d silent session(s)', result.archived.length);
55
- })().catch(error => ctx.logger.warn('auto-archive: sweep failed: %s', error));
56
- });
57
40
  const diagnosticOwner = await openDiagnostics(resolve(input.diagnosticsDirectory ?? join(config.stateDirectory, 'diagnostics')), { onConflict: 'readonly' });
58
41
  const { diagnostics } = diagnosticOwner;
59
42
  if (diagnosticOwner.mode === 'read-only')
@@ -49,17 +49,42 @@ The session is scoped to the current repository and persists across invocations.
49
49
 
50
50
  ## Choose an agent
51
51
 
52
- Common launch examples use the same command shape:
53
-
54
- | Agent | Command |
55
- | ----------------- | ---------------------------- |
56
- | Pi | `acpx pi …` |
57
- | OpenClaw | `acpx openclaw …` |
58
- | Codex | `acpx codex …` |
59
- | Claude Code | `acpx claude …` |
60
- | Custom ACP server | `acpx --agent '<command>' …` |
61
-
62
- The upstream agent must be installed and authenticated when its adapter does not provide that itself. See [built-in agents](docs/agents.md) for every supported profile and [custom agents](docs/custom-agents.md) for registry configuration.
52
+ These 30 built-in launch profiles share one command shape. Each guide covers the required CLI or adapter, authentication, and capability limits. Ante is experimental.
53
+
54
+ | | Agent | Command |
55
+ | ----------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------- |
56
+ | ![Pi](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/pi.png) | [Pi](https://github.com/openclaw/acpx/blob/main/agents/Pi.md) | `acpx pi …` |
57
+ | ![OpenClaw](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/openclaw.png) | [OpenClaw](https://github.com/openclaw/acpx/blob/main/agents/OpenClaw.md) | `acpx openclaw …` |
58
+ | ![Codex](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/codex.png) | [Codex](https://github.com/openclaw/acpx/blob/main/agents/Codex.md) | `acpx codex …` |
59
+ | ![Claude Code](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/claude.png) | [Claude Code](https://github.com/openclaw/acpx/blob/main/agents/Claude.md) | `acpx claude …` |
60
+ | ![Gemini CLI](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/gemini.png) | [Gemini CLI](https://github.com/openclaw/acpx/blob/main/agents/Gemini.md) | `acpx gemini …` |
61
+ | ![Cursor](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/cursor.png) | [Cursor](https://github.com/openclaw/acpx/blob/main/agents/Cursor.md) | `acpx cursor …` |
62
+ | ![GitHub Copilot](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/copilot.png) | [GitHub Copilot](https://github.com/openclaw/acpx/blob/main/agents/Copilot.md) | `acpx copilot …` |
63
+ | ![Ante](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/ante.png) | [Ante](https://github.com/openclaw/acpx/blob/main/agents/Ante.md) | `acpx ante …` |
64
+ | ![Antigravity](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/antigravity.png) | [Antigravity](https://github.com/openclaw/acpx/blob/main/agents/Antigravity.md) | `acpx antigravity …` |
65
+ | ![DeepSeek Harness](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/deepseek-harness.png) | [DeepSeek Harness](https://github.com/openclaw/acpx/blob/main/agents/DeepSeekHarness.md) | `acpx deepseek-harness …` |
66
+ | ![Devin](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/devin.png) | [Devin](https://github.com/openclaw/acpx/blob/main/agents/Devin.md) | `acpx devin …` |
67
+ | ![Factory Droid](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/droid.png) | [Factory Droid](https://github.com/openclaw/acpx/blob/main/agents/Droid.md) | `acpx droid …` |
68
+ | ![fast-agent](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/fast-agent.png) | [fast-agent](https://github.com/openclaw/acpx/blob/main/agents/FastAgent.md) | `acpx fast-agent …` |
69
+ | ![fx](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/fx.png) | [fx](https://github.com/openclaw/acpx/blob/main/agents/Fx.md) | `acpx fx …` |
70
+ | ![Grok Build](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/grok-build.png) | [Grok Build](https://github.com/openclaw/acpx/blob/main/agents/GrokBuild.md) | `acpx grok-build …` |
71
+ | ![Goose](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/goose.png) | [Goose](https://github.com/openclaw/acpx/blob/main/agents/Goose.md) | `acpx goose …` |
72
+ | ![iFlow](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/iflow.png) | [iFlow](https://github.com/openclaw/acpx/blob/main/agents/Iflow.md) | `acpx iflow …` |
73
+ | ![Junie](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/junie.png) | [Junie](https://github.com/openclaw/acpx/blob/main/agents/Junie.md) | `acpx junie …` |
74
+ | ![Kilocode](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/kilocode.png) | [Kilocode](https://github.com/openclaw/acpx/blob/main/agents/Kilocode.md) | `acpx kilocode …` |
75
+ | ![Kimi](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/kimi.png) | [Kimi](https://github.com/openclaw/acpx/blob/main/agents/Kimi.md) | `acpx kimi …` |
76
+ | ![Kiro](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/kiro.png) | [Kiro](https://github.com/openclaw/acpx/blob/main/agents/Kiro.md) | `acpx kiro …` |
77
+ | ![MCode](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/mcode.png) | [MCode](https://github.com/openclaw/acpx/blob/main/agents/MCode.md) | `acpx mcode …` |
78
+ | ![Mux](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/mux.png) | [Mux](https://github.com/openclaw/acpx/blob/main/agents/Mux.md) | `acpx mux …` |
79
+ | ![Octomind](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/octomind.png) | [Octomind](https://github.com/openclaw/acpx/blob/main/agents/Octomind.md) | `acpx octomind …` |
80
+ | ![OpenCode](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/opencode.png) | [OpenCode](https://github.com/openclaw/acpx/blob/main/agents/OpenCode.md) | `acpx opencode …` |
81
+ | ![Poolside](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/pool.png) | [Poolside](https://github.com/openclaw/acpx/blob/main/agents/Pool.md) | `acpx pool …` |
82
+ | ![Qoder](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/qoder.png) | [Qoder](https://github.com/openclaw/acpx/blob/main/agents/Qoder.md) | `acpx qoder …` |
83
+ | ![Qwen Code](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/qwen.png) | [Qwen Code](https://github.com/openclaw/acpx/blob/main/agents/Qwen.md) | `acpx qwen …` |
84
+ | ![Trae](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/trae.png) | [Trae](https://github.com/openclaw/acpx/blob/main/agents/Trae.md) | `acpx trae …` |
85
+ | ![ZeroClaw](https://raw.githubusercontent.com/openclaw/acpx/main/docs/assets/agents/zeroclaw.png) | [ZeroClaw](https://github.com/openclaw/acpx/blob/main/agents/ZeroClaw.md) | `acpx zeroclaw …` |
86
+
87
+ Need another ACP server? Use `acpx --agent '<command>' …` or configure a [custom agent](docs/custom-agents.md). See the [agent registry](docs/agents.md) for adapter commands and aliases. [Logo credits](docs/assets/agents/README.md).
63
88
 
64
89
  ## Sessions and one-shot runs
65
90