@1agents/acp-service 0.10.0 → 0.10.2
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 +1 -1
- package/dist/src/a2a/index.d.ts +1 -1
- package/dist/src/a2a/index.js +1 -1
- package/dist/src/a2a/lease.d.ts +2 -0
- package/dist/src/a2a/lease.js +3 -0
- package/dist/src/a2a/server.d.ts +6 -0
- package/dist/src/a2a/server.js +13 -12
- package/dist/src/a2a/store.d.ts +9 -2
- package/dist/src/a2a/store.js +37 -11
- package/dist/src/catalog-descriptors.js +5 -5
- package/dist/src/catalog.js +8 -1
- package/package.json +1 -1
- package/vendor/dsh/README.md +1 -1
- package/vendor/dsh/a2a-executor.d.ts +2 -2
- package/vendor/dsh/a2a.d.ts +2 -2
- package/vendor/dsh/a2a.js +4 -1
- package/vendor/dsh/adapter.d.ts +2 -2
- package/vendor/dsh/diagnostics.d.ts +14 -2
- package/vendor/dsh/diagnostics.js +79 -4
- package/vendor/dsh/index.js +3 -1
package/README.md
CHANGED
|
@@ -286,7 +286,7 @@ Tests use the official ACP SDK over real WebSockets, cover session lifecycle and
|
|
|
286
286
|
|
|
287
287
|
`GET /agents` returns `{ "agents": [...] }`, a fresh local filesystem inventory shared by DSH and 1agents_app. Each entry includes the canonical ACP registry `id`, display `label`, native CLI `installed`, and `chat_ready`. Legacy app fields (`type`, capabilities, cc-connect transport, integration status and install guidance) remain available; `claude` uses the legacy app type `claudecode`.
|
|
288
288
|
|
|
289
|
-
Discovery checks PATH, `~/.local/bin`, `~/.grok/bin`, and installed adapter package launch files. A registered native ACP command is ready when its executable exists. Adapter-backed harnesses are ready when the adapter is installed, or when their native CLI and `npx` are installed; the latter uses the runtime's existing adapter download behavior when a session launches. Having `npx` or `uvx` alone does not expose uninstalled harnesses. Scanning neither executes agents nor downloads packages, and readiness does not verify credentials or model access. Detection-only frameworks remain in the inventory with `chat_ready: false`.
|
|
289
|
+
Discovery checks PATH, `~/.local/bin`, `~/.grok/bin`, and installed adapter package launch files. A registered native ACP command is ready when its executable exists. Adapter-backed harnesses are ready when the adapter is installed, or when their native CLI and `npx` are installed; the latter uses the runtime's existing adapter download behavior when a session launches. Having `npx` or `uvx` alone does not expose uninstalled harnesses. Scanning neither executes agents nor downloads packages, and readiness does not verify credentials or model access. Detection-only frameworks remain in the inventory with `chat_ready: false`. Antigravity is ready only when its official ACP runtime is installed (`agy_acp_server.par`, or `agy_acp_server.exe` on Windows), not when the separate `agy` CLI is present. Keep `localharness_external` from the same release beside that runtime, or set `ANTIGRAVITY_HARNESS_PATH` to the helper. Antigravity's fixed-choice questions are still cancelled by the runtime and have to be answered in an interactive client.
|
|
290
290
|
|
|
291
291
|
The service launcher uses the same local command resolution, including absolute paths to user-local binaries. The catalog originates from 1agents_app's former Go detector; consumers no longer probe their own host or maintain separate detection tables. `discoverAgents()` is also exported for embedded service consumers and includes local executable paths; the HTTP response omits these paths.
|
|
292
292
|
|
package/dist/src/a2a/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type { ExecutorTicketArgs, ExecutorTicketChannel, ExecutorTicketScope, Ex
|
|
|
20
20
|
export { ProjectRoleDiscovery, DISCOVERY_METHODS, projectDiscoveryConfigSchema } from '../execution/project-discovery.js';
|
|
21
21
|
export { A2AAutomation } from './automation.js';
|
|
22
22
|
export type { A2AAutomationConfig, AutomationRun, AutomationRunStatus } from './automation.js';
|
|
23
|
-
export { DirectoryLease } from './lease.js';
|
|
23
|
+
export { DirectoryLease, isStorageBusy } from './lease.js';
|
|
24
24
|
export { CapacityGovernor, CapacityError } from '../capacity.js';
|
|
25
25
|
export { CapacityQueue } from '../capacity-queue.js';
|
|
26
26
|
export type { CapacityOptions, CapacityLease, CapacitySnapshot } from '../capacity.js';
|
package/dist/src/a2a/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export { RemoteAgentGateway, serveA2AGateway, REMOTE_AGENT_METHODS } from './gat
|
|
|
11
11
|
export { runExecutorTicket } from '../execution/ticket-executor.js';
|
|
12
12
|
export { ProjectRoleDiscovery, DISCOVERY_METHODS, projectDiscoveryConfigSchema } from '../execution/project-discovery.js';
|
|
13
13
|
export { A2AAutomation } from './automation.js';
|
|
14
|
-
export { DirectoryLease } from './lease.js';
|
|
14
|
+
export { DirectoryLease, isStorageBusy } from './lease.js';
|
|
15
15
|
export { CapacityGovernor, CapacityError } from '../capacity.js';
|
|
16
16
|
export { CapacityQueue } from '../capacity-queue.js';
|
|
17
17
|
export { SessionDelivery } from './session-delivery.js';
|
package/dist/src/a2a/lease.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Single-writer directory lease shared by A2A records and plugin diagnostics. */
|
|
2
|
+
export declare function isStorageBusy(error: unknown): boolean;
|
|
1
3
|
/** Reject a live owner; reclaim only uniquely named markers whose process is demonstrably absent. */
|
|
2
4
|
export declare class DirectoryLease {
|
|
3
5
|
private readonly directory;
|
package/dist/src/a2a/lease.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/** Single-writer directory lease shared by A2A records and plugin diagnostics. */
|
|
2
|
+
export function isStorageBusy(error) {
|
|
3
|
+
return error instanceof Error && error.message === 'A2A storage directory is already in use by another instance';
|
|
4
|
+
}
|
|
2
5
|
import { randomUUID } from 'node:crypto';
|
|
3
6
|
import { closeSync, constants, fstatSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, rmdirSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
4
7
|
import { join, resolve } from 'node:path';
|
package/dist/src/a2a/server.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ export interface A2AServerOptions extends A2AExecutionOptions {
|
|
|
12
12
|
path?: string;
|
|
13
13
|
/** Webhook destinations must belong to one of these exact HTTP(S) origins. */
|
|
14
14
|
pushNotificationOrigins?: string[];
|
|
15
|
+
/** `readonly` keeps a second host up when another live instance already owns the directory. */
|
|
16
|
+
storage?: {
|
|
17
|
+
onConflict?: 'throw' | 'readonly';
|
|
18
|
+
};
|
|
15
19
|
}
|
|
16
20
|
/** Create the A2A 1.0 host without opening a port or importing DSH. */
|
|
17
21
|
export declare function createA2AServer(options: A2AServerOptions): Promise<{
|
|
@@ -28,5 +32,7 @@ export declare function createA2AServer(options: A2AServerOptions): Promise<{
|
|
|
28
32
|
sessionId: string;
|
|
29
33
|
summary: string;
|
|
30
34
|
}) => Promise<A2AResubmission>;
|
|
35
|
+
/** `read-only` when another live instance owns the state directory. */
|
|
36
|
+
mode: 'read-write' | 'read-only';
|
|
31
37
|
close: () => Promise<void>;
|
|
32
38
|
}>;
|
package/dist/src/a2a/server.js
CHANGED
|
@@ -222,18 +222,19 @@ export async function createA2AServer(options) {
|
|
|
222
222
|
securityRequirements: [{ schemes: { bearerAuth: { list: [] } } }],
|
|
223
223
|
defaultInputModes: ['text/plain'], defaultOutputModes: ['text/plain'],
|
|
224
224
|
skills: [{ id: 'dsh-session', name: 'DSH session task', description: 'Create or resume a session using metadata.1agents.cwd, workspace and agentPreset; retain contextId to continue collaboration.', tags: ['dsh', 'project', 'role', 'async'] }] });
|
|
225
|
-
const store =
|
|
225
|
+
const store = FileA2AStore.open(options.stateDirectory, { onConflict: options.storage?.onConflict ?? 'throw' });
|
|
226
226
|
try {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
227
|
+
if (store.mode === 'read-write')
|
|
228
|
+
await store.recoverInterrupted(async (task, context) => {
|
|
229
|
+
const message = task.history.findLast(message => message.role === Role.ROLE_USER);
|
|
230
|
+
const target = store.loadTarget(task.contextId, context);
|
|
231
|
+
if (!message || !target)
|
|
232
|
+
return;
|
|
233
|
+
const requestId = a2aRequestId(task.id, message.messageId);
|
|
234
|
+
const recovered = await options.backend.recover?.(target, { requestId });
|
|
235
|
+
return toSafeError(recovered, { origin: 'a2a', operationId: requestId,
|
|
236
|
+
outcomeUnknown: recovered === undefined });
|
|
237
|
+
});
|
|
237
238
|
}
|
|
238
239
|
catch (error) {
|
|
239
240
|
store.close();
|
|
@@ -481,7 +482,7 @@ export async function createA2AServer(options) {
|
|
|
481
482
|
void pending.then(clean, clean);
|
|
482
483
|
return pending;
|
|
483
484
|
};
|
|
484
|
-
return { path, card, handler, cardHandler,
|
|
485
|
+
return { path, card, handler, cardHandler, mode: store.mode,
|
|
485
486
|
sessionTask: sessionId => a2aSessionTask({ store, executor }, sessionId),
|
|
486
487
|
taskSession: taskId => a2aTaskSession({ store }, taskId),
|
|
487
488
|
resubmit: input => {
|
package/dist/src/a2a/store.d.ts
CHANGED
|
@@ -10,15 +10,21 @@ import type { A2ATarget } from './types.js';
|
|
|
10
10
|
export declare class FileA2AStore {
|
|
11
11
|
readonly taskStore: TaskStore;
|
|
12
12
|
readonly pushStore: PushNotificationStore;
|
|
13
|
+
/** `read-only` loaded another live owner's records and rejects every mutation. */
|
|
14
|
+
readonly mode: 'read-write' | 'read-only';
|
|
13
15
|
private readonly directory;
|
|
14
|
-
private readonly lease
|
|
16
|
+
private readonly lease?;
|
|
15
17
|
private readonly memory;
|
|
16
18
|
private readonly tasks;
|
|
17
19
|
private readonly pushes;
|
|
18
20
|
private readonly targets;
|
|
19
21
|
private readonly ready;
|
|
20
22
|
private closed;
|
|
21
|
-
|
|
23
|
+
/** Exclusive by default. `onConflict: 'readonly'` attaches without a lease when a live owner already holds the directory. */
|
|
24
|
+
static open(directory: string, options?: {
|
|
25
|
+
onConflict?: 'throw' | 'readonly';
|
|
26
|
+
}): FileA2AStore;
|
|
27
|
+
constructor(directory: string, mode?: 'read-write' | 'read-only');
|
|
22
28
|
loadTarget(contextId: string, context: ServerCallContext): A2ATarget | undefined;
|
|
23
29
|
/** The most recently updated task this host ran in one DSH session, within the caller's scope. */
|
|
24
30
|
latestTaskForSession(sessionId: string, context: ServerCallContext): Task | undefined;
|
|
@@ -30,6 +36,7 @@ export declare class FileA2AStore {
|
|
|
30
36
|
close(): void;
|
|
31
37
|
private loadPush;
|
|
32
38
|
private assertOpen;
|
|
39
|
+
private assertWritable;
|
|
33
40
|
private readJson;
|
|
34
41
|
private readEnvelope;
|
|
35
42
|
private writeEnvelope;
|
package/dist/src/a2a/store.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Message, Role, Task, TaskPushNotificationConfig, TaskState } from '@a2a
|
|
|
5
5
|
import { InMemoryTaskStore, resolveUserScope, ServerCallContext, } from '@a2a-js/sdk/server';
|
|
6
6
|
import { RequestMalformedError } from '@a2a-js/sdk/errors';
|
|
7
7
|
import { toSafeError } from '@1agents/acp-service/runtime';
|
|
8
|
-
import { DirectoryLease } from './lease.js';
|
|
8
|
+
import { DirectoryLease, isStorageBusy } from './lease.js';
|
|
9
9
|
import { a2aRoleSkillsSchema } from './types.js';
|
|
10
10
|
import { a2aPreflightReportSchema } from './preflight.js';
|
|
11
11
|
const terminalStates = new Set([
|
|
@@ -183,6 +183,8 @@ function parsePush(value, taskId, scope) {
|
|
|
183
183
|
export class FileA2AStore {
|
|
184
184
|
taskStore;
|
|
185
185
|
pushStore;
|
|
186
|
+
/** `read-only` loaded another live owner's records and rejects every mutation. */
|
|
187
|
+
mode;
|
|
186
188
|
directory;
|
|
187
189
|
lease;
|
|
188
190
|
memory = new InMemoryTaskStore();
|
|
@@ -191,14 +193,29 @@ export class FileA2AStore {
|
|
|
191
193
|
targets = new Map();
|
|
192
194
|
ready;
|
|
193
195
|
closed = false;
|
|
194
|
-
|
|
196
|
+
/** Exclusive by default. `onConflict: 'readonly'` attaches without a lease when a live owner already holds the directory. */
|
|
197
|
+
static open(directory, options) {
|
|
198
|
+
try {
|
|
199
|
+
return new FileA2AStore(directory);
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
if (options?.onConflict === 'readonly' && isStorageBusy(error))
|
|
203
|
+
return new FileA2AStore(directory, 'read-only');
|
|
204
|
+
throw error;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
constructor(directory, mode = 'read-write') {
|
|
208
|
+
this.mode = mode;
|
|
195
209
|
this.directory = resolve(directory);
|
|
196
|
-
|
|
210
|
+
if (mode === 'read-write') {
|
|
211
|
+
mkdirSync(this.directory, { recursive: true, mode: 0o700 });
|
|
212
|
+
chmodSync(this.directory, 0o700);
|
|
213
|
+
}
|
|
197
214
|
const stat = lstatSync(this.directory);
|
|
198
215
|
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
199
216
|
throw new Error('A2A storage directory must be a real directory');
|
|
200
|
-
|
|
201
|
-
|
|
217
|
+
if (mode === 'read-write')
|
|
218
|
+
this.lease = new DirectoryLease(this.directory);
|
|
202
219
|
try {
|
|
203
220
|
const loads = [];
|
|
204
221
|
for (const name of readdirSync(this.directory)) {
|
|
@@ -228,7 +245,7 @@ export class FileA2AStore {
|
|
|
228
245
|
}
|
|
229
246
|
this.taskStore = {
|
|
230
247
|
save: async (task, context) => {
|
|
231
|
-
this.
|
|
248
|
+
this.assertWritable();
|
|
232
249
|
const scope = scopeOf(context);
|
|
233
250
|
// Roundtrip through JSON as well as the SDK codec so cached metadata
|
|
234
251
|
// cannot retain references owned by the caller or non-JSON values.
|
|
@@ -265,7 +282,7 @@ export class FileA2AStore {
|
|
|
265
282
|
};
|
|
266
283
|
this.pushStore = {
|
|
267
284
|
save: async (taskId, context, supplied) => {
|
|
268
|
-
this.
|
|
285
|
+
this.assertWritable();
|
|
269
286
|
text(taskId, 'task ID');
|
|
270
287
|
const scope = scopeOf(context);
|
|
271
288
|
if (supplied.taskId && supplied.taskId !== taskId)
|
|
@@ -299,7 +316,7 @@ export class FileA2AStore {
|
|
|
299
316
|
load: async (taskId, context) => this.loadPush(taskId, context).map(entry => entry.config),
|
|
300
317
|
loadWithMetadata: async (taskId, context) => this.loadPush(taskId, context),
|
|
301
318
|
delete: async (taskId, context, configId) => {
|
|
302
|
-
this.
|
|
319
|
+
this.assertWritable();
|
|
303
320
|
text(taskId, 'task ID');
|
|
304
321
|
const scope = scopeOf(context);
|
|
305
322
|
// Match the SDK default: omitted configId refers to the task ID.
|
|
@@ -342,7 +359,7 @@ export class FileA2AStore {
|
|
|
342
359
|
return typeof sessionId === 'string' ? sessionId : undefined;
|
|
343
360
|
}
|
|
344
361
|
saveTarget(contextId, target, context) {
|
|
345
|
-
this.
|
|
362
|
+
this.assertWritable();
|
|
346
363
|
text(contextId, 'context ID');
|
|
347
364
|
const scope = scopeOf(context);
|
|
348
365
|
const normalized = parseTarget(target);
|
|
@@ -352,6 +369,9 @@ export class FileA2AStore {
|
|
|
352
369
|
/** Persist failure for interrupted executions. A restart never reruns work. */
|
|
353
370
|
async recoverInterrupted(recover) {
|
|
354
371
|
this.assertOpen();
|
|
372
|
+
// A follower must not mark the owner's in-flight tasks as failed.
|
|
373
|
+
if (this.mode === 'read-only')
|
|
374
|
+
return;
|
|
355
375
|
await this.ready;
|
|
356
376
|
for (const { scope, task } of [...this.tasks.values()]) {
|
|
357
377
|
if (task.status && terminalStates.has(task.status.state))
|
|
@@ -378,7 +398,7 @@ export class FileA2AStore {
|
|
|
378
398
|
if (this.closed)
|
|
379
399
|
return;
|
|
380
400
|
this.closed = true;
|
|
381
|
-
this.lease
|
|
401
|
+
this.lease?.close();
|
|
382
402
|
}
|
|
383
403
|
loadPush(taskId, context) {
|
|
384
404
|
this.assertOpen();
|
|
@@ -389,6 +409,11 @@ export class FileA2AStore {
|
|
|
389
409
|
if (this.closed)
|
|
390
410
|
throw new Error('A2A store is closed');
|
|
391
411
|
}
|
|
412
|
+
assertWritable() {
|
|
413
|
+
this.assertOpen();
|
|
414
|
+
if (this.mode === 'read-only')
|
|
415
|
+
throw new Error('A2A storage is read-only because another instance owns it');
|
|
416
|
+
}
|
|
392
417
|
readJson(path) {
|
|
393
418
|
const fd = openSync(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
394
419
|
try {
|
|
@@ -413,7 +438,8 @@ export class FileA2AStore {
|
|
|
413
438
|
const kind = source.kind;
|
|
414
439
|
if (fileName(kind, scope, id) !== name)
|
|
415
440
|
throw new Error('A2A storage record filename does not match its scope');
|
|
416
|
-
|
|
441
|
+
if (this.mode === 'read-write')
|
|
442
|
+
chmodSync(path, 0o600);
|
|
417
443
|
return { version: 1, kind, scope, id, value: source.value };
|
|
418
444
|
}
|
|
419
445
|
writeEnvelope(kind, scope, id, value) {
|
|
@@ -113,12 +113,12 @@ export const catalogDescriptors = [
|
|
|
113
113
|
{
|
|
114
114
|
"type": "antigravity",
|
|
115
115
|
"label": "Antigravity",
|
|
116
|
-
"binary": "
|
|
117
|
-
"acp_capable":
|
|
116
|
+
"binary": "agy_acp_server.par",
|
|
117
|
+
"acp_capable": true,
|
|
118
118
|
"cli_capable": true,
|
|
119
|
-
"cc_transport": "",
|
|
120
|
-
"integrated":
|
|
121
|
-
"install_command": "
|
|
119
|
+
"cc_transport": "acp",
|
|
120
|
+
"integrated": true,
|
|
121
|
+
"install_command": "Install agy_acp_server and localharness_external from the same antigravity-acp release (https://github.com/agentclientprotocol/registry/blob/main/antigravity-acp/agent.json) onto PATH, and point ANTIGRAVITY_HARNESS_PATH at that helper"
|
|
122
122
|
},
|
|
123
123
|
{
|
|
124
124
|
"type": "openhands",
|
package/dist/src/catalog.js
CHANGED
|
@@ -108,14 +108,21 @@ function localLaunch(id, options) {
|
|
|
108
108
|
const binary = findAgentBinary(argv[0], options);
|
|
109
109
|
return binary ? [binary, ...argv.slice(1)] : undefined;
|
|
110
110
|
}
|
|
111
|
+
/** Antigravity's ACP runtime is a separate download from the `agy` CLI. */
|
|
112
|
+
function discoveryBinary(id, descriptor, argv, platform) {
|
|
113
|
+
if (id === 'antigravity')
|
|
114
|
+
return platform === 'win32' ? 'agy_acp_server.exe' : 'agy_acp_server.par';
|
|
115
|
+
return descriptor?.binary ?? (Array.isArray(argv) && !['npx', 'uvx'].includes(argv[0]) ? argv[0] : id);
|
|
116
|
+
}
|
|
111
117
|
/** Fresh filesystem snapshot. An installed CLI may use the runtime's adapter download fallback on launch; scanning never downloads or authenticates. */
|
|
112
118
|
export function discoverAgents(options = {}) {
|
|
113
119
|
const descriptors = new Map(catalogDescriptors.map(d => [d.type === 'claudecode' ? 'claude' : d.type, d]));
|
|
114
120
|
const supportedAgents = new Set(registry.list());
|
|
121
|
+
const platform = options.platform ?? process.platform;
|
|
115
122
|
return [...new Set([...supportedAgents, ...descriptors.keys()])].map(id => {
|
|
116
123
|
const descriptor = descriptors.get(id);
|
|
117
124
|
const argv = registry.resolve(id);
|
|
118
|
-
const binary =
|
|
125
|
+
const binary = discoveryBinary(id, descriptor, argv, platform);
|
|
119
126
|
const path = findAgentBinary(binary, options);
|
|
120
127
|
const supported = supportedAgents.has(id);
|
|
121
128
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1agents/acp-service",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
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",
|
package/vendor/dsh/README.md
CHANGED
|
@@ -103,7 +103,7 @@ The bundle's `oneagents-acp` row accepts `serviceUrl`, `serviceMode`, `serviceSt
|
|
|
103
103
|
|
|
104
104
|
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.
|
|
105
105
|
|
|
106
|
-
Diagnostic storage defaults to `stateDirectory/diagnostics`; `diagnosticsDirectory` selects a separate explicit location. Keep this directory with the A2A state when moving a host. Its version is independent of DSH Session formats. The plugin privately mounts official storage components; it does not require a shared host storage-domain configuration. Only one plugin instance may write the directory at a time.
|
|
106
|
+
Diagnostic storage defaults to `stateDirectory/diagnostics`; `diagnosticsDirectory` selects a separate explicit location. Keep this directory with the A2A state when moving a host. Its version is independent of DSH Session formats. The plugin privately mounts official storage components; it does not require a shared host storage-domain configuration. Only one plugin instance may write the directory at a time. A second DSH process, such as desktop while web already holds the lock, starts instead of failing: A2A reads the owner's records and rejects mutations, and that follower's diagnostics stay in memory so a chat turn is not failed for lack of the lock. The follower does not mark the owner's in-flight tasks failed and does not release the owner's lock. Session binding files in `stateDirectory` are outside that lock.
|
|
107
107
|
|
|
108
108
|
### Local service lifecycle
|
|
109
109
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import type { SessionId } from '@deepseek-ai/dsh-session';
|
|
3
3
|
import { type A2ABackend, type A2AExecutionRef, type A2APreflightInput, type A2APrepareInput, type A2ARunResult, type A2ATarget } from '@1agents/acp-service/a2a';
|
|
4
|
-
import type {
|
|
4
|
+
import type { DiagnosticLog } from './diagnostics.js';
|
|
5
5
|
export interface SessionControl {
|
|
6
6
|
release(sessionId: string): Promise<{
|
|
7
7
|
processReleased: true | 'pending';
|
|
@@ -36,7 +36,7 @@ export declare class DshA2ABackend implements A2ABackend {
|
|
|
36
36
|
private readonly sessions?;
|
|
37
37
|
private readonly executions;
|
|
38
38
|
/** @param ctx DSH plugin context that owns session-controller and execution event registrations. */
|
|
39
|
-
constructor(ctx: Context, diagnostics?:
|
|
39
|
+
constructor(ctx: Context, diagnostics?: DiagnosticLog | undefined, sessions?: SessionControl | undefined);
|
|
40
40
|
close(target: A2ATarget): Promise<{
|
|
41
41
|
processReleased: true | 'pending';
|
|
42
42
|
acp?: boolean;
|
package/vendor/dsh/a2a.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Mount the shared A2A implementation on the current DSH web host. */
|
|
2
2
|
import { createA2AServer, type A2AServerOptions } from '@1agents/acp-service/a2a';
|
|
3
3
|
import type { Context } from '@deepseek-ai/cordis';
|
|
4
|
-
import type {
|
|
4
|
+
import type { DiagnosticLog } from './diagnostics.js';
|
|
5
5
|
import { type SessionControl } from './a2a-executor.js';
|
|
6
6
|
/** Optional host configuration; omitted configuration leaves A2A disabled. */
|
|
7
7
|
export interface DshA2AOptions extends Omit<A2AServerOptions, 'backend' | 'token' | 'stateDirectory' | 'publicUrl'> {
|
|
@@ -23,4 +23,4 @@ export interface DshA2AOptions extends Omit<A2AServerOptions, 'backend' | 'token
|
|
|
23
23
|
/** In-process takeover controls of the mounted host; absent while A2A is disabled or closed. */
|
|
24
24
|
export type A2AHostControls = Pick<Awaited<ReturnType<typeof createA2AServer>>, 'sessionTask' | 'taskSession' | 'resubmit'>;
|
|
25
25
|
/** Routes and in-flight turns are released with the owning Cordis plugin. */
|
|
26
|
-
export declare function mountDshA2A(ctx: Context, options: DshA2AOptions, stateDirectory: string, diagnostics?:
|
|
26
|
+
export declare function mountDshA2A(ctx: Context, options: DshA2AOptions, stateDirectory: string, diagnostics?: DiagnosticLog, sessions?: SessionControl, expose?: (host: A2AHostControls | undefined) => void): Promise<() => Promise<void>>;
|
package/vendor/dsh/a2a.js
CHANGED
|
@@ -13,7 +13,10 @@ export async function mountDshA2A(ctx, options, stateDirectory, diagnostics, ses
|
|
|
13
13
|
const { workbench: _workbench, ...serverOptions } = options;
|
|
14
14
|
const server = await createA2AServer({ ...serverOptions, token, backend: new DshA2ABackend(ctx, diagnostics, sessions),
|
|
15
15
|
stateDirectory: options.stateDirectory ?? stateDirectory,
|
|
16
|
-
publicUrl: options.publicUrl ?? `http://127.0.0.1:${ctx.webServer.port}
|
|
16
|
+
publicUrl: options.publicUrl ?? `http://127.0.0.1:${ctx.webServer.port}`,
|
|
17
|
+
storage: { onConflict: 'readonly' } });
|
|
18
|
+
if (server.mode === 'read-only')
|
|
19
|
+
console.warn('oneagents-acp A2A storage is read-only because another instance owns it');
|
|
17
20
|
const routes = [];
|
|
18
21
|
try {
|
|
19
22
|
routes.push(ctx.webServer.register({ kind: 'exact', path: '/.well-known/agent-card.json', handler: server.cardHandler }));
|
package/vendor/dsh/adapter.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
3
3
|
import type { LlmAdapter, GenerateOptions, StreamChunk, LlmModelInfo } from '@deepseek-ai/dsh-llm';
|
|
4
|
-
import type {
|
|
4
|
+
import type { DiagnosticLog } from './diagnostics.js';
|
|
5
5
|
import type { McpServer, SessionConfigOption, SessionModeState, AvailableCommand } from '@agentclientprotocol/sdk';
|
|
6
6
|
import { type Binding } from './state.js';
|
|
7
7
|
import type { ProcessRequestClient } from './process-requests.js';
|
|
@@ -58,7 +58,7 @@ export declare class AcpAdapter implements LlmAdapter {
|
|
|
58
58
|
private readonly sessionSettings;
|
|
59
59
|
/** MCP servers offered when a session is created or restored, such as the A2A hand-back tool. */
|
|
60
60
|
mcpServersFor?: (sessionId: string) => McpServer[];
|
|
61
|
-
constructor(ctx: Context, config: Config, diagnostics?:
|
|
61
|
+
constructor(ctx: Context, config: Config, diagnostics?: DiagnosticLog | undefined, processRequests?: ProcessRequestClient | undefined);
|
|
62
62
|
providerInfo(provider: string): {
|
|
63
63
|
id: string;
|
|
64
64
|
name: string;
|
|
@@ -11,6 +11,15 @@ declare const identitySchema: z.ZodObject<{
|
|
|
11
11
|
requestIds: z.ZodArray<z.ZodString>;
|
|
12
12
|
}, z.core.$strict>;
|
|
13
13
|
export type DiagnosticIdentity = z.infer<typeof identitySchema>;
|
|
14
|
+
/** Methods the adapter and A2A backend actually call. A follower may implement them in memory. */
|
|
15
|
+
export interface DiagnosticLog {
|
|
16
|
+
begin(identity: DiagnosticIdentity): Promise<string>;
|
|
17
|
+
submitted(id: string): Promise<void>;
|
|
18
|
+
confirmed(id: string): Promise<void>;
|
|
19
|
+
settle(id: string, error?: SafeError): Promise<void>;
|
|
20
|
+
find(sessionId: string, requestId: string, turn?: number, turnStartSeq?: number): SafeError | undefined;
|
|
21
|
+
close(): Promise<void>;
|
|
22
|
+
}
|
|
14
23
|
/** Shared by the owned Adapter and A2A backend; every mutating method awaits durability. */
|
|
15
24
|
export declare class Diagnostics {
|
|
16
25
|
private readonly domain;
|
|
@@ -35,8 +44,11 @@ export declare class Diagnostics {
|
|
|
35
44
|
close(): Promise<void>;
|
|
36
45
|
}
|
|
37
46
|
/** Own the official storage plugins until A2A and native calls have drained. */
|
|
38
|
-
export declare function openDiagnostics(directory: string
|
|
39
|
-
|
|
47
|
+
export declare function openDiagnostics(directory: string, options?: {
|
|
48
|
+
onConflict?: 'throw' | 'readonly';
|
|
49
|
+
}): Promise<{
|
|
50
|
+
diagnostics: DiagnosticLog;
|
|
40
51
|
close: () => Promise<void>;
|
|
52
|
+
mode: 'read-write' | 'read-only';
|
|
41
53
|
}>;
|
|
42
54
|
export {};
|
|
@@ -6,7 +6,7 @@ import * as StorageDomain from '@deepseek-ai/dsh-storage-domain';
|
|
|
6
6
|
import { randomUUID } from 'node:crypto';
|
|
7
7
|
import { z } from 'dsh-zod';
|
|
8
8
|
import { defineDomain, domainTable } from '@deepseek-ai/dsh-storage-domain';
|
|
9
|
-
import { DirectoryLease } from '@1agents/acp-service/a2a';
|
|
9
|
+
import { DirectoryLease, isStorageBusy } from '@1agents/acp-service/a2a';
|
|
10
10
|
import { toSafeError } from '@1agents/acp-service/runtime';
|
|
11
11
|
const identitySchema = z.object({
|
|
12
12
|
sessionId: z.string().min(1).max(256), turn: z.number().int().nonnegative(),
|
|
@@ -137,11 +137,86 @@ export class Diagnostics {
|
|
|
137
137
|
/** Drain writes before unloading; the owner first drains A2A and the Adapter. */
|
|
138
138
|
async close() { this.closed = true; await this.chain; await this.domain.close(); }
|
|
139
139
|
}
|
|
140
|
+
/** Process-local diagnostics. Used when another instance already owns the directory, so chat can continue without writing its files. */
|
|
141
|
+
class MemoryDiagnostics {
|
|
142
|
+
serial = 0;
|
|
143
|
+
records = new Map();
|
|
144
|
+
closed = false;
|
|
145
|
+
begin(identity) {
|
|
146
|
+
if (this.closed)
|
|
147
|
+
return Promise.reject(new Error('ACP diagnostics are closed'));
|
|
148
|
+
const snapshot = identitySchema.parse(identity);
|
|
149
|
+
const serial = this.serial + 1;
|
|
150
|
+
if (!Number.isSafeInteger(serial))
|
|
151
|
+
return Promise.reject(new Error('ACP diagnostic sequence exhausted'));
|
|
152
|
+
const id = randomUUID();
|
|
153
|
+
this.records.set(id, { id, serial, identity: snapshot, phase: 'prepared' });
|
|
154
|
+
this.serial = serial;
|
|
155
|
+
return Promise.resolve(id);
|
|
156
|
+
}
|
|
157
|
+
submitted(id) {
|
|
158
|
+
return this.update(id, record => {
|
|
159
|
+
if (record.phase !== 'prepared' && record.phase !== 'submitted')
|
|
160
|
+
throw new Error('ACP diagnostic attempt already confirmed');
|
|
161
|
+
return { ...record, phase: 'submitted' };
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
confirmed(id) {
|
|
165
|
+
return this.update(id, record => {
|
|
166
|
+
if (record.phase === 'settled')
|
|
167
|
+
throw new Error('ACP diagnostic attempt already settled');
|
|
168
|
+
return { ...record, phase: 'confirmed' };
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
settle(id, error) {
|
|
172
|
+
const safe = error === undefined ? undefined : errorSchema.parse({
|
|
173
|
+
category: error.category, retryable: error.retryable, outcomeUnknown: error.outcomeUnknown, origin: error.origin,
|
|
174
|
+
...(error.providerCode === undefined ? {} : { providerCode: error.providerCode }),
|
|
175
|
+
...(error.code === undefined ? {} : { code: error.code }),
|
|
176
|
+
...(error.detailCode === undefined ? {} : { detailCode: error.detailCode }),
|
|
177
|
+
});
|
|
178
|
+
return this.update(id, record => {
|
|
179
|
+
if (record.phase === 'settled')
|
|
180
|
+
throw new Error('ACP diagnostic attempt already settled');
|
|
181
|
+
return { ...record, phase: 'settled', ...(safe === undefined ? {} : { error: safe }) };
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
find(sessionId, requestId, turn, turnStartSeq) {
|
|
185
|
+
const records = [...this.records.values()].filter(record => record.identity.sessionId === sessionId && record.identity.requestIds.includes(requestId)
|
|
186
|
+
&& (turn === undefined || record.identity.turn === turn)
|
|
187
|
+
&& (turnStartSeq === undefined || record.identity.turnStartSeq === turnStartSeq));
|
|
188
|
+
const record = records.sort((a, b) => b.serial - a.serial)[0];
|
|
189
|
+
if (!record)
|
|
190
|
+
return;
|
|
191
|
+
return record.error ? toSafeError(record.error, { trustedProjection: true, origin: 'dsh', operationId: requestId })
|
|
192
|
+
: toSafeError(undefined, { origin: 'dsh', operationId: requestId, outcomeUnknown: record.phase === 'submitted' });
|
|
193
|
+
}
|
|
194
|
+
async close() { this.closed = true; }
|
|
195
|
+
update(id, change) {
|
|
196
|
+
if (this.closed)
|
|
197
|
+
return Promise.reject(new Error('ACP diagnostics are closed'));
|
|
198
|
+
const current = this.records.get(id);
|
|
199
|
+
if (!current)
|
|
200
|
+
return Promise.reject(new Error('ACP diagnostic attempt is missing'));
|
|
201
|
+
this.records.set(id, change(current));
|
|
202
|
+
return Promise.resolve();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
140
205
|
/** Own the official storage plugins until A2A and native calls have drained. */
|
|
141
|
-
export async function openDiagnostics(directory) {
|
|
206
|
+
export async function openDiagnostics(directory, options) {
|
|
207
|
+
let lease;
|
|
208
|
+
try {
|
|
209
|
+
lease = new DirectoryLease(directory);
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
if (options?.onConflict === 'readonly' && isStorageBusy(error)) {
|
|
213
|
+
const diagnostics = new MemoryDiagnostics();
|
|
214
|
+
return { diagnostics, mode: 'read-only', close: () => diagnostics.close() };
|
|
215
|
+
}
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
142
218
|
// The host's shared facility can close concurrently during root teardown.
|
|
143
219
|
// This private composition gives the consumer an explicit drain-before-close order.
|
|
144
|
-
const lease = new DirectoryLease(directory);
|
|
145
220
|
const storage = new Context();
|
|
146
221
|
try {
|
|
147
222
|
await storage.plugin(Storage);
|
|
@@ -150,7 +225,7 @@ export async function openDiagnostics(directory) {
|
|
|
150
225
|
await mounted.await();
|
|
151
226
|
const diagnostics = await Diagnostics.open(storage.storageDomain);
|
|
152
227
|
let closing;
|
|
153
|
-
return { diagnostics, close: () => closing ??= (async () => {
|
|
228
|
+
return { diagnostics, mode: 'read-write', close: () => closing ??= (async () => {
|
|
154
229
|
try {
|
|
155
230
|
await diagnostics.close();
|
|
156
231
|
}
|
package/vendor/dsh/index.js
CHANGED
|
@@ -36,8 +36,10 @@ export async function apply(ctx, input = {}) {
|
|
|
36
36
|
throw new Error('agents must contain ACP registry names');
|
|
37
37
|
if (!Number.isSafeInteger(config.reconnectAttempts) || config.reconnectAttempts < 0 || !Number.isSafeInteger(config.reconnectDelayMs) || config.reconnectDelayMs < 1)
|
|
38
38
|
throw new Error('Invalid ACP reconnect policy');
|
|
39
|
-
const diagnosticOwner = await openDiagnostics(resolve(input.diagnosticsDirectory ?? join(config.stateDirectory, 'diagnostics')));
|
|
39
|
+
const diagnosticOwner = await openDiagnostics(resolve(input.diagnosticsDirectory ?? join(config.stateDirectory, 'diagnostics')), { onConflict: 'readonly' });
|
|
40
40
|
const { diagnostics } = diagnosticOwner;
|
|
41
|
+
if (diagnosticOwner.mode === 'read-only')
|
|
42
|
+
console.warn('oneagents-acp diagnostics are read-only because another instance owns the storage');
|
|
41
43
|
let closeA2A;
|
|
42
44
|
const processRequests = input.a2a?.workbench ? createWorkbenchProcessClient(input.a2a.workbench) : undefined;
|
|
43
45
|
const adapter = new AcpAdapter(ctx, config, diagnostics, processRequests);
|