@1agents/acp-service 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/bin/a2a.js +10 -2
- package/dist/bin/acp-service.js +6 -0
- package/dist/bin/roles.d.ts +1 -0
- package/dist/bin/roles.js +24 -0
- package/dist/src/a2a/executor.d.ts +16 -1
- package/dist/src/a2a/executor.js +205 -19
- package/dist/src/a2a/gateway.d.ts +77 -0
- package/dist/src/a2a/gateway.js +349 -27
- package/dist/src/a2a/index.d.ts +7 -1
- package/dist/src/a2a/index.js +4 -0
- package/dist/src/a2a/result-metadata.d.ts +3 -0
- package/dist/src/a2a/result-metadata.js +2 -1
- package/dist/src/a2a/server.js +2 -1
- package/dist/src/a2a/store.js +7 -1
- package/dist/src/a2a/types.d.ts +32 -1
- package/dist/src/a2a/types.js +11 -1
- package/dist/src/acp-connection.js +93 -12
- package/dist/src/bridge.js +127 -4
- package/dist/src/capacity-lifecycle.d.ts +5 -0
- package/dist/src/capacity-lifecycle.js +57 -0
- package/dist/src/capacity-queue.d.ts +23 -0
- package/dist/src/capacity-queue.js +251 -0
- package/dist/src/capacity.d.ts +76 -0
- package/dist/src/capacity.js +377 -0
- package/dist/src/execution/human-review.d.ts +103 -0
- package/dist/src/execution/human-review.js +87 -0
- package/dist/src/execution/ledger.d.ts +5 -0
- package/dist/src/execution/ledger.js +39 -8
- package/dist/src/execution/ppt-delivery.d.ts +36 -3
- package/dist/src/execution/ppt-delivery.js +243 -53
- package/dist/src/execution/project-discovery.d.ts +56 -0
- package/dist/src/execution/project-discovery.js +429 -0
- package/dist/src/execution/report-review.d.ts +60 -0
- package/dist/src/execution/report-review.js +173 -0
- package/dist/src/execution/targets.d.ts +5 -0
- package/dist/src/execution/targets.js +1 -0
- package/dist/src/execution/workbench.d.ts +131 -0
- package/dist/src/execution/workbench.js +265 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +3 -0
- package/dist/src/roles/index.d.ts +1 -0
- package/dist/src/roles/index.js +1 -0
- package/dist/src/roles/skills.d.ts +71 -0
- package/dist/src/roles/skills.js +427 -0
- package/package.json +5 -1
- package/skills/acp-service/SKILL.md +21 -7
- package/skills/acp-service/references/a2a.md +9 -5
- package/skills/acp-service/references/async-caller.md +48 -0
- package/skills/acp-service/references/roles-and-tasks.md +120 -0
- package/skills/acp-service/scripts/a2a-caller.py +242 -0
- package/vendor/dsh/README.md +2 -0
- package/vendor/dsh/a2a-executor.d.ts +4 -1
- package/vendor/dsh/a2a-executor.js +46 -2
- package/vendor/dsh/adapter.d.ts +10 -0
- package/vendor/dsh/adapter.js +67 -3
- package/vendor/dsh/client.js +84 -24
- package/vendor/dsh/index.js +2 -1
- package/vendor/runtime/dist/{cli-DeOpE2Xz.js → cli-DXmYwv3U.js} +4 -4
- package/vendor/runtime/dist/{cli-DeOpE2Xz.js.map → cli-DXmYwv3U.js.map} +1 -1
- package/vendor/runtime/dist/cli.js +7 -7
- package/vendor/runtime/dist/client-VQsqcIOJ.d.ts.map +1 -1
- package/vendor/runtime/dist/docs-site/runtime-process-lifecycle.html +1 -0
- package/vendor/runtime/dist/{flows-oaBGn31w.js → flows-DJ17ajbw.js} +3 -3
- package/vendor/runtime/dist/{flows-oaBGn31w.js.map → flows-DJ17ajbw.js.map} +1 -1
- package/vendor/runtime/dist/flows.js +1 -1
- package/vendor/runtime/dist/{invocation-options-CUDEE8vW.js → invocation-options-PBfCgrdi.js} +3 -3
- package/vendor/runtime/dist/{invocation-options-CUDEE8vW.js.map → invocation-options-PBfCgrdi.js.map} +1 -1
- package/vendor/runtime/dist/{output-CFv3jcOQ.js → output-B3MDn7kv.js} +2 -2
- package/vendor/runtime/dist/{output-CFv3jcOQ.js.map → output-B3MDn7kv.js.map} +1 -1
- package/vendor/runtime/dist/{queue-owner-runtime-DvMJiGbP.js → queue-owner-runtime-DXCVngwU.js} +15 -8
- package/vendor/runtime/dist/queue-owner-runtime-DXCVngwU.js.map +1 -0
- package/vendor/runtime/dist/runtime.js +1 -1
- package/vendor/runtime/dist/{session-watch-Di-wIdCH.js → session-watch-DURyCw31.js} +2 -2
- package/vendor/runtime/dist/{session-watch-Di-wIdCH.js.map → session-watch-DURyCw31.js.map} +1 -1
- package/vendor/runtime/dist/queue-owner-runtime-DvMJiGbP.js.map +0 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const roleSkillProfileSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
version: z.ZodString;
|
|
5
|
+
instructionsPath: z.ZodOptional<z.ZodString>;
|
|
6
|
+
network: z.ZodObject<{
|
|
7
|
+
agentUrl: z.ZodString;
|
|
8
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
skills: z.ZodArray<z.ZodObject<{
|
|
11
|
+
key: z.ZodString;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
nodeUrl: z.ZodOptional<z.ZodString>;
|
|
14
|
+
skillId: z.ZodOptional<z.ZodString>;
|
|
15
|
+
sourceId: z.ZodOptional<z.ZodString>;
|
|
16
|
+
assetsManifest: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strict>>;
|
|
18
|
+
entrySkill: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
export type RoleSkillProfile = z.infer<typeof roleSkillProfileSchema>;
|
|
21
|
+
export declare const roleSkillLockSchema: z.ZodObject<{
|
|
22
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
23
|
+
roleId: z.ZodString;
|
|
24
|
+
roleVersion: z.ZodString;
|
|
25
|
+
profilePath: z.ZodString;
|
|
26
|
+
profileSha256: z.ZodString;
|
|
27
|
+
cacheRoot: z.ZodString;
|
|
28
|
+
roleDirectory: z.ZodString;
|
|
29
|
+
createdAt: z.ZodString;
|
|
30
|
+
instructionsPath: z.ZodOptional<z.ZodString>;
|
|
31
|
+
instructionsSha256: z.ZodOptional<z.ZodString>;
|
|
32
|
+
instructionsBytes: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
entrySkill: z.ZodOptional<z.ZodString>;
|
|
34
|
+
entryGuidePath: z.ZodOptional<z.ZodString>;
|
|
35
|
+
skills: z.ZodArray<z.ZodObject<{
|
|
36
|
+
key: z.ZodString;
|
|
37
|
+
nodeUrl: z.ZodString;
|
|
38
|
+
skillId: z.ZodString;
|
|
39
|
+
sourceId: z.ZodString;
|
|
40
|
+
name: z.ZodString;
|
|
41
|
+
revision: z.ZodString;
|
|
42
|
+
cacheDirectory: z.ZodString;
|
|
43
|
+
directory: z.ZodString;
|
|
44
|
+
guidePath: z.ZodString;
|
|
45
|
+
guideResource: z.ZodString;
|
|
46
|
+
files: z.ZodArray<z.ZodObject<{
|
|
47
|
+
path: z.ZodString;
|
|
48
|
+
bytes: z.ZodNumber;
|
|
49
|
+
sha256: z.ZodString;
|
|
50
|
+
}, z.core.$strict>>;
|
|
51
|
+
assets: z.ZodArray<z.ZodObject<{
|
|
52
|
+
path: z.ZodString;
|
|
53
|
+
bytes: z.ZodNumber;
|
|
54
|
+
sha256: z.ZodString;
|
|
55
|
+
url: z.ZodString;
|
|
56
|
+
}, z.core.$strict>>;
|
|
57
|
+
}, z.core.$strict>>;
|
|
58
|
+
}, z.core.$strict>;
|
|
59
|
+
export type RoleSkillLock = z.infer<typeof roleSkillLockSchema>;
|
|
60
|
+
/** Same content revision as Skill Manager: paths sorted by UTF-8 bytes, then path\0length\0 + file bytes. */
|
|
61
|
+
export declare function skillContentRevision(files: {
|
|
62
|
+
path: string;
|
|
63
|
+
bytes: Uint8Array;
|
|
64
|
+
}[]): string;
|
|
65
|
+
/** New lock => latest catalogue revisions; existing lock => checked, fully offline reuse even if the source/profile changed. */
|
|
66
|
+
export declare function resolveRoleSkills(options: {
|
|
67
|
+
profilePath: string;
|
|
68
|
+
cacheRoot: string;
|
|
69
|
+
lockPath: string;
|
|
70
|
+
signal?: AbortSignal;
|
|
71
|
+
}): Promise<RoleSkillLock>;
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
/** Task-pinned skills from a DreamMate catalogue; this module never invokes a model or executes skill code. */
|
|
2
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
3
|
+
import { copyFile, link, lstat, mkdir, readFile, readdir, realpath, rename, rm, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
const hash = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
7
|
+
const identifier = z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/);
|
|
8
|
+
const sha = z.string().regex(/^[a-f0-9]{64}$/);
|
|
9
|
+
const absolute = z.string().refine(isAbsolute, 'Expected an absolute path');
|
|
10
|
+
const endpoint = z.string().url().refine(value => {
|
|
11
|
+
const url = new URL(value);
|
|
12
|
+
return ['http:', 'https:'].includes(url.protocol) && !url.username && !url.password && !url.search && !url.hash;
|
|
13
|
+
}, 'Expected an HTTP(S) URL without credentials, query or fragment');
|
|
14
|
+
const resourcePath = z.string().min(1).max(4096).refine(value => !value.includes('\\') && !value.includes('\0')
|
|
15
|
+
&& !value.startsWith('/') && value.split('/').every(segment => segment !== '' && segment !== '.' && segment !== '..'), 'Invalid relative resource path');
|
|
16
|
+
const requirement = z.object({ key: identifier, name: z.string().min(1), nodeUrl: endpoint.optional(),
|
|
17
|
+
skillId: z.string().min(1).optional(), sourceId: z.string().min(1).optional(), assetsManifest: resourcePath.optional() }).strict();
|
|
18
|
+
export const roleSkillProfileSchema = z.object({ id: identifier, version: z.string().min(1), instructionsPath: z.string().min(1).optional(),
|
|
19
|
+
network: z.object({ agentUrl: endpoint, timeoutMs: z.number().int().min(100).max(120000).default(30000) }).strict(),
|
|
20
|
+
skills: z.array(requirement).min(1).max(100), entrySkill: identifier.optional() }).strict().superRefine((value, ctx) => {
|
|
21
|
+
if (new Set(value.skills.map(skill => skill.key)).size !== value.skills.length)
|
|
22
|
+
ctx.addIssue({ code: 'custom', message: 'Duplicate skill key' });
|
|
23
|
+
if (value.entrySkill && !value.skills.some(skill => skill.key === value.entrySkill))
|
|
24
|
+
ctx.addIssue({ code: 'custom', message: 'Unknown entrySkill' });
|
|
25
|
+
});
|
|
26
|
+
const inventoryEntry = z.object({ path: resourcePath, bytes: z.number().int().nonnegative().max(128 * 1024 * 1024), sha256: sha }).strict();
|
|
27
|
+
const assetEntry = inventoryEntry.extend({ url: endpoint });
|
|
28
|
+
const lockedSkill = z.object({ key: identifier, nodeUrl: endpoint, skillId: z.string().min(1), sourceId: z.string().min(1), name: z.string().min(1),
|
|
29
|
+
revision: sha, cacheDirectory: absolute, directory: absolute, guidePath: absolute, guideResource: resourcePath,
|
|
30
|
+
files: z.array(inventoryEntry).min(1).max(2000), assets: z.array(assetEntry).max(2000) }).strict();
|
|
31
|
+
export const roleSkillLockSchema = z.object({ schemaVersion: z.literal(1), roleId: identifier, roleVersion: z.string().min(1),
|
|
32
|
+
profilePath: absolute, profileSha256: sha, cacheRoot: absolute, roleDirectory: absolute, createdAt: z.string(),
|
|
33
|
+
instructionsPath: absolute.optional(), instructionsSha256: sha.optional(), instructionsBytes: z.number().int().nonnegative().optional(),
|
|
34
|
+
entrySkill: identifier.optional(), entryGuidePath: absolute.optional(), skills: z.array(lockedSkill).min(1).max(100) }).strict();
|
|
35
|
+
const catalogueEntry = z.object({ id: z.string().min(1), source_id: z.string().min(1), name: z.string().min(1), revision: sha }).passthrough();
|
|
36
|
+
const readResult = z.object({ id: z.string().min(1), source_id: z.string().min(1), name: z.string().min(1), revision: sha,
|
|
37
|
+
resource: resourcePath, content: z.string(), encoding: z.enum(['utf8', 'base64']),
|
|
38
|
+
resources: z.array(z.object({ path: resourcePath, bytes: z.number().int().nonnegative().max(8 * 1024 * 1024) }).passthrough()).max(2000).optional() }).passthrough();
|
|
39
|
+
const receiptSchema = z.object({ schemaVersion: z.literal(1), nodeUrl: endpoint, skillId: z.string().min(1), sourceId: z.string().min(1),
|
|
40
|
+
name: z.string().min(1), revision: sha, guideResource: resourcePath, files: z.array(inventoryEntry).min(1).max(2000) }).strict();
|
|
41
|
+
/** Same content revision as Skill Manager: paths sorted by UTF-8 bytes, then path\0length\0 + file bytes. */
|
|
42
|
+
export function skillContentRevision(files) {
|
|
43
|
+
const result = createHash('sha256');
|
|
44
|
+
for (const file of [...files].sort((a, b) => Buffer.compare(Buffer.from(a.path), Buffer.from(b.path)))) {
|
|
45
|
+
result.update(`${file.path}\0${file.bytes.length}\0`).update(file.bytes);
|
|
46
|
+
}
|
|
47
|
+
return result.digest('hex');
|
|
48
|
+
}
|
|
49
|
+
const inside = (root, path) => { const rel = relative(root, path); return rel === '' || (rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel)); };
|
|
50
|
+
function identity(skill) { return hash(JSON.stringify([skill.nodeUrl, skill.skillId])); }
|
|
51
|
+
function snapshotId(lock) {
|
|
52
|
+
return hash(JSON.stringify({ profile: lock.profileSha256, instructions: lock.instructionsSha256,
|
|
53
|
+
skills: lock.skills.map(skill => [skill.key, skill.nodeUrl, skill.skillId, skill.revision, skill.assets]) }));
|
|
54
|
+
}
|
|
55
|
+
async function exists(path) {
|
|
56
|
+
try {
|
|
57
|
+
await lstat(path);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (error.code === 'ENOENT')
|
|
62
|
+
return false;
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async function checkParents(root, target, create = false) {
|
|
67
|
+
if (!inside(root, target))
|
|
68
|
+
throw new Error('Cache path escapes root');
|
|
69
|
+
const segments = relative(root, target).split(sep).filter(Boolean);
|
|
70
|
+
let current = root;
|
|
71
|
+
for (const segment of segments) {
|
|
72
|
+
current = join(current, segment);
|
|
73
|
+
if (create)
|
|
74
|
+
await mkdir(current).catch(error => { if (error.code !== 'EEXIST')
|
|
75
|
+
throw error; });
|
|
76
|
+
const info = await lstat(current);
|
|
77
|
+
if (info.isSymbolicLink() || !info.isDirectory())
|
|
78
|
+
throw new Error('Cache directory contains symlink or non-directory');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function regularBytes(root, path) {
|
|
82
|
+
await checkParents(root, dirname(path));
|
|
83
|
+
const info = await lstat(path);
|
|
84
|
+
if (!info.isFile() || info.isSymbolicLink())
|
|
85
|
+
throw new Error('Cache resource is not a regular file');
|
|
86
|
+
return readFile(path);
|
|
87
|
+
}
|
|
88
|
+
async function verifyFile(root, path, expected) {
|
|
89
|
+
const bytes = await regularBytes(root, path);
|
|
90
|
+
if (bytes.length !== expected.bytes || hash(bytes) !== expected.sha256)
|
|
91
|
+
throw new Error('Cached resource byte/hash mismatch');
|
|
92
|
+
}
|
|
93
|
+
async function listFiles(root, directory = root) {
|
|
94
|
+
const paths = [];
|
|
95
|
+
for (const name of await readdir(directory)) {
|
|
96
|
+
const path = join(directory, name), info = await lstat(path);
|
|
97
|
+
if (info.isSymbolicLink())
|
|
98
|
+
throw new Error('Symlink found in cached skill');
|
|
99
|
+
if (info.isDirectory())
|
|
100
|
+
paths.push(...await listFiles(root, path));
|
|
101
|
+
else if (info.isFile())
|
|
102
|
+
paths.push(relative(root, path).split(sep).join('/'));
|
|
103
|
+
else
|
|
104
|
+
throw new Error('Unsupported cache filesystem entry');
|
|
105
|
+
}
|
|
106
|
+
return paths.sort();
|
|
107
|
+
}
|
|
108
|
+
async function verifyReceipt(root, directory, expected) {
|
|
109
|
+
const receipt = receiptSchema.parse(JSON.parse((await regularBytes(root, join(directory, 'receipt.json'))).toString('utf8')));
|
|
110
|
+
if (expected && JSON.stringify(receipt) !== JSON.stringify(expected))
|
|
111
|
+
throw new Error('Cached skill receipt differs from locked identity');
|
|
112
|
+
const files = join(directory, 'files');
|
|
113
|
+
await checkParents(root, files);
|
|
114
|
+
const inventory = await listFiles(files);
|
|
115
|
+
if (new Set(receipt.files.map(file => file.path)).size !== receipt.files.length || JSON.stringify(inventory) !== JSON.stringify(receipt.files.map(file => file.path).sort()))
|
|
116
|
+
throw new Error('Cached skill inventory mismatch');
|
|
117
|
+
const content = [];
|
|
118
|
+
for (const file of receipt.files) {
|
|
119
|
+
const bytes = await regularBytes(root, join(files, file.path));
|
|
120
|
+
if (bytes.length !== file.bytes || hash(bytes) !== file.sha256)
|
|
121
|
+
throw new Error('Cached skill byte/hash mismatch');
|
|
122
|
+
content.push({ path: file.path, bytes });
|
|
123
|
+
}
|
|
124
|
+
if (skillContentRevision(content) !== receipt.revision)
|
|
125
|
+
throw new Error('Cached skill content revision mismatch');
|
|
126
|
+
return receipt;
|
|
127
|
+
}
|
|
128
|
+
async function bounded(response, limit) {
|
|
129
|
+
if (!response.ok) {
|
|
130
|
+
await response.body?.cancel();
|
|
131
|
+
throw new Error(`Skill network request failed (HTTP ${response.status})`);
|
|
132
|
+
}
|
|
133
|
+
if (Number(response.headers.get('content-length') ?? 0) > limit) {
|
|
134
|
+
await response.body?.cancel();
|
|
135
|
+
throw new Error('Skill network response exceeds byte limit');
|
|
136
|
+
}
|
|
137
|
+
if (!response.body)
|
|
138
|
+
return Buffer.alloc(0);
|
|
139
|
+
const reader = response.body.getReader(), chunks = [];
|
|
140
|
+
let total = 0;
|
|
141
|
+
try {
|
|
142
|
+
while (true) {
|
|
143
|
+
const chunk = await reader.read();
|
|
144
|
+
if (chunk.done)
|
|
145
|
+
break;
|
|
146
|
+
total += chunk.value.length;
|
|
147
|
+
if (total > limit)
|
|
148
|
+
throw new Error('Skill network response exceeds byte limit');
|
|
149
|
+
chunks.push(chunk.value);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
finally {
|
|
153
|
+
await reader.cancel().catch(() => { });
|
|
154
|
+
}
|
|
155
|
+
return Buffer.concat(chunks);
|
|
156
|
+
}
|
|
157
|
+
function networkUrl(base, suffix, params = {}) {
|
|
158
|
+
const url = new URL(base);
|
|
159
|
+
url.pathname = url.pathname.replace(/\/$/, '') + suffix;
|
|
160
|
+
for (const [key, value] of Object.entries(params))
|
|
161
|
+
url.searchParams.set(key, value);
|
|
162
|
+
return url;
|
|
163
|
+
}
|
|
164
|
+
async function networkJson(url, timeout, signal) {
|
|
165
|
+
const response = await fetch(url, { redirect: 'error', signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(timeout)]) : AbortSignal.timeout(timeout) });
|
|
166
|
+
return JSON.parse((await bounded(response, 24 * 1024 * 1024)).toString('utf8'));
|
|
167
|
+
}
|
|
168
|
+
async function selectSkill(base, wanted, timeout, signal) {
|
|
169
|
+
let offset = 0;
|
|
170
|
+
const matches = [];
|
|
171
|
+
for (let page = 0; page < 50; page++) {
|
|
172
|
+
const result = z.object({ skills: z.array(catalogueEntry).max(200), has_more: z.boolean().optional(), next_offset: z.number().int().nonnegative().nullable().optional() }).passthrough()
|
|
173
|
+
.parse(await networkJson(networkUrl(base, '/skills', { limit: '200', offset: String(offset) }), timeout, signal));
|
|
174
|
+
for (const skill of result.skills)
|
|
175
|
+
if (skill.name === wanted.name && (!wanted.skillId || wanted.skillId === skill.id) && (!wanted.sourceId || wanted.sourceId === skill.source_id))
|
|
176
|
+
matches.push(skill);
|
|
177
|
+
if (!result.has_more) {
|
|
178
|
+
if (matches.length !== 1)
|
|
179
|
+
throw new Error(matches.length ? `Ambiguous skill: ${wanted.name}; pin sourceId/skillId` : `Required skill unavailable: ${wanted.name}`);
|
|
180
|
+
return matches[0];
|
|
181
|
+
}
|
|
182
|
+
if (result.next_offset == null || result.next_offset <= offset)
|
|
183
|
+
throw new Error('Invalid skill catalogue pagination');
|
|
184
|
+
offset = result.next_offset;
|
|
185
|
+
}
|
|
186
|
+
throw new Error('Skill catalogue exceeds bounded page limit');
|
|
187
|
+
}
|
|
188
|
+
function decoded(result, expectedBytes) {
|
|
189
|
+
if (result.encoding === 'utf8') {
|
|
190
|
+
const bytes = Buffer.from(result.content, 'utf8');
|
|
191
|
+
// Manager's TextDecoder strips one leading UTF-8 BOM. Restore it only when
|
|
192
|
+
// the byte inventory requires exactly those three bytes; the package hash
|
|
193
|
+
// below still has to match the provider's original revision.
|
|
194
|
+
return bytes.length + 3 === expectedBytes ? Buffer.concat([Buffer.from([239, 187, 191]), bytes]) : bytes;
|
|
195
|
+
}
|
|
196
|
+
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(result.content))
|
|
197
|
+
throw new Error('Invalid base64 skill resource');
|
|
198
|
+
return Buffer.from(result.content, 'base64');
|
|
199
|
+
}
|
|
200
|
+
async function installDirectory(temporary, target) {
|
|
201
|
+
try {
|
|
202
|
+
await rename(temporary, target);
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
if (!['EEXIST', 'ENOTEMPTY'].includes(error.code ?? ''))
|
|
206
|
+
throw error;
|
|
207
|
+
await rm(temporary, { recursive: true, force: true });
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
async function loadSkill(root, base, wanted, timeout, signal) {
|
|
211
|
+
const chosen = await selectSkill(base, wanted, timeout, signal);
|
|
212
|
+
const parent = join(root, 'skills', identity({ nodeUrl: base, skillId: chosen.id }));
|
|
213
|
+
await checkParents(root, parent, true);
|
|
214
|
+
const directory = join(parent, chosen.revision);
|
|
215
|
+
if (await exists(directory)) {
|
|
216
|
+
const receipt = await verifyReceipt(root, directory);
|
|
217
|
+
if (receipt.nodeUrl !== base || receipt.skillId !== chosen.id || receipt.sourceId !== chosen.source_id || receipt.name !== chosen.name || receipt.revision !== chosen.revision)
|
|
218
|
+
throw new Error('Cached skill catalogue identity mismatch');
|
|
219
|
+
return { directory, receipt };
|
|
220
|
+
}
|
|
221
|
+
const read = async (resource) => {
|
|
222
|
+
const result = readResult.parse(await networkJson(networkUrl(base, `/skills/${encodeURIComponent(chosen.id)}`, { revision: chosen.revision, ...(resource ? { resource } : {}) }), timeout, signal));
|
|
223
|
+
if (result.id !== chosen.id || result.source_id !== chosen.source_id || result.name !== chosen.name || result.revision !== chosen.revision || (resource && result.resource !== resource))
|
|
224
|
+
throw new Error('Skill resource identity/revision mismatch');
|
|
225
|
+
return result;
|
|
226
|
+
};
|
|
227
|
+
const main = await read();
|
|
228
|
+
const resources = main.resources;
|
|
229
|
+
if (!resources?.length || new Set(resources.map(file => file.path)).size !== resources.length || !resources.some(file => file.path === main.resource))
|
|
230
|
+
throw new Error('Invalid skill resource inventory');
|
|
231
|
+
if (resources.reduce((total, file) => total + file.bytes, 0) > 32 * 1024 * 1024)
|
|
232
|
+
throw new Error('Skill package exceeds size limit');
|
|
233
|
+
const temporary = join(parent, `.download-${randomUUID()}`);
|
|
234
|
+
await mkdir(temporary, { mode: 0o700 });
|
|
235
|
+
await mkdir(join(temporary, 'files'));
|
|
236
|
+
try {
|
|
237
|
+
const files = [], contents = [];
|
|
238
|
+
for (const file of resources) {
|
|
239
|
+
const result = file.path === main.resource ? main : await read(file.path);
|
|
240
|
+
const bytes = decoded(result, file.bytes);
|
|
241
|
+
if (bytes.length !== file.bytes)
|
|
242
|
+
throw new Error(`Skill resource size differs from inventory: ${chosen.name}/${file.path}; expected ${file.bytes}, received ${bytes.length}`);
|
|
243
|
+
const path = join(temporary, 'files', file.path);
|
|
244
|
+
await checkParents(root, dirname(path), true);
|
|
245
|
+
await writeFile(path, bytes, { flag: 'wx', mode: 0o600 });
|
|
246
|
+
files.push({ path: file.path, bytes: bytes.length, sha256: hash(bytes) });
|
|
247
|
+
contents.push({ path: file.path, bytes });
|
|
248
|
+
}
|
|
249
|
+
if (skillContentRevision(contents) !== chosen.revision)
|
|
250
|
+
throw new Error('Downloaded skill package revision mismatch');
|
|
251
|
+
const receipt = { schemaVersion: 1, nodeUrl: base, skillId: chosen.id, sourceId: chosen.source_id, name: chosen.name, revision: chosen.revision, guideResource: main.resource, files };
|
|
252
|
+
await writeFile(join(temporary, 'receipt.json'), JSON.stringify(receipt), { mode: 0o600, flag: 'wx' });
|
|
253
|
+
await installDirectory(temporary, directory);
|
|
254
|
+
return { directory, receipt: await verifyReceipt(root, directory, receipt) };
|
|
255
|
+
}
|
|
256
|
+
finally {
|
|
257
|
+
await rm(temporary, { recursive: true, force: true });
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
async function loadAssets(root, directory, wanted, timeout, signal) {
|
|
261
|
+
if (!wanted.assetsManifest)
|
|
262
|
+
return [];
|
|
263
|
+
const manifest = z.object({ assets: z.array(assetEntry).max(2000) }).strict().parse(JSON.parse((await regularBytes(root, join(directory, 'files', wanted.assetsManifest))).toString('utf8')));
|
|
264
|
+
if (new Set(manifest.assets.map(asset => asset.path)).size !== manifest.assets.length)
|
|
265
|
+
throw new Error('Duplicate skill asset path');
|
|
266
|
+
if (manifest.assets.reduce((total, asset) => total + asset.bytes, 0) > 1024 * 1024 * 1024)
|
|
267
|
+
throw new Error('Skill assets exceed size budget');
|
|
268
|
+
for (const asset of manifest.assets) {
|
|
269
|
+
if (await exists(join(directory, 'files', asset.path)))
|
|
270
|
+
throw new Error('Asset path collides with skill resource');
|
|
271
|
+
const parent = join(root, 'assets', asset.sha256);
|
|
272
|
+
await checkParents(root, parent, true);
|
|
273
|
+
const blob = join(parent, 'blob');
|
|
274
|
+
if (!(await exists(blob))) {
|
|
275
|
+
const response = await fetch(asset.url, { redirect: 'error', signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(timeout)]) : AbortSignal.timeout(timeout) });
|
|
276
|
+
const bytes = await bounded(response, Math.min(asset.bytes + 1, 128 * 1024 * 1024));
|
|
277
|
+
if (bytes.length !== asset.bytes || hash(bytes) !== asset.sha256)
|
|
278
|
+
throw new Error('Downloaded asset byte/hash mismatch');
|
|
279
|
+
const temporary = join(parent, `.download-${randomUUID()}`);
|
|
280
|
+
await writeFile(temporary, bytes, { flag: 'wx', mode: 0o600 });
|
|
281
|
+
try {
|
|
282
|
+
await link(temporary, blob);
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
if (error.code !== 'EEXIST')
|
|
286
|
+
throw error;
|
|
287
|
+
}
|
|
288
|
+
finally {
|
|
289
|
+
await rm(temporary, { force: true });
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
await verifyFile(root, blob, asset);
|
|
293
|
+
}
|
|
294
|
+
return manifest.assets;
|
|
295
|
+
}
|
|
296
|
+
async function validateLock(trustedRoot, lock) {
|
|
297
|
+
// A migration may preserve the lock's original paths through a root alias.
|
|
298
|
+
// Only that root alias may differ: every descendant keeps the same exact
|
|
299
|
+
// binding and the existing directory/file symlink checks below still apply.
|
|
300
|
+
const root = lock.cacheRoot;
|
|
301
|
+
if (root !== trustedRoot && await realpath(root) !== trustedRoot)
|
|
302
|
+
throw new Error('Role lock cache binding mismatch');
|
|
303
|
+
const roleDirectory = join(root, 'roles', lock.roleId, snapshotId(lock));
|
|
304
|
+
if (lock.roleDirectory !== roleDirectory || new Set(lock.skills.map(skill => skill.key)).size !== lock.skills.length)
|
|
305
|
+
throw new Error('Role lock cache binding mismatch');
|
|
306
|
+
const profileBytes = await regularBytes(root, join(roleDirectory, 'profile.json'));
|
|
307
|
+
if (hash(profileBytes) !== lock.profileSha256)
|
|
308
|
+
throw new Error('Cached role profile byte/hash mismatch');
|
|
309
|
+
const profile = roleSkillProfileSchema.parse(JSON.parse(profileBytes.toString('utf8')));
|
|
310
|
+
if (profile.id !== lock.roleId || profile.version !== lock.roleVersion || profile.entrySkill !== lock.entrySkill
|
|
311
|
+
|| Boolean(profile.instructionsPath) !== Boolean(lock.instructionsPath) || profile.skills.length !== lock.skills.length)
|
|
312
|
+
throw new Error('Role lock profile binding mismatch');
|
|
313
|
+
for (const skill of lock.skills) {
|
|
314
|
+
const wanted = profile.skills.find(wanted => wanted.key === skill.key);
|
|
315
|
+
if (!wanted || wanted.name !== skill.name || (wanted.skillId && wanted.skillId !== skill.skillId)
|
|
316
|
+
|| (wanted.sourceId && wanted.sourceId !== skill.sourceId) || (wanted.nodeUrl ?? profile.network.agentUrl) !== skill.nodeUrl)
|
|
317
|
+
throw new Error('Role lock skill requirement mismatch');
|
|
318
|
+
const directory = join(root, 'skills', identity(skill), skill.revision), materialized = join(roleDirectory, 'skills', skill.key);
|
|
319
|
+
if (skill.cacheDirectory !== directory || skill.directory !== materialized || skill.guidePath !== join(materialized, skill.guideResource))
|
|
320
|
+
throw new Error('Role lock skill path mismatch');
|
|
321
|
+
const receipt = { schemaVersion: 1, nodeUrl: skill.nodeUrl, skillId: skill.skillId, sourceId: skill.sourceId, name: skill.name, revision: skill.revision, guideResource: skill.guideResource, files: skill.files };
|
|
322
|
+
await verifyReceipt(root, directory, receipt);
|
|
323
|
+
if (JSON.stringify((await listFiles(materialized)).sort()) !== JSON.stringify([...skill.files, ...skill.assets].map(file => file.path).sort()))
|
|
324
|
+
throw new Error('Materialized skill inventory mismatch');
|
|
325
|
+
for (const file of skill.files)
|
|
326
|
+
await verifyFile(root, join(materialized, file.path), file);
|
|
327
|
+
for (const asset of skill.assets) {
|
|
328
|
+
await verifyFile(root, join(root, 'assets', asset.sha256, 'blob'), asset);
|
|
329
|
+
await verifyFile(root, join(materialized, asset.path), asset);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (lock.instructionsPath) {
|
|
333
|
+
if (lock.instructionsPath !== join(roleDirectory, 'ROLE.md') || !lock.instructionsSha256 || lock.instructionsBytes === undefined)
|
|
334
|
+
throw new Error('Role instruction binding mismatch');
|
|
335
|
+
await verifyFile(root, lock.instructionsPath, { bytes: lock.instructionsBytes, sha256: lock.instructionsSha256 });
|
|
336
|
+
}
|
|
337
|
+
if (lock.entrySkill && lock.entryGuidePath !== lock.skills.find(skill => skill.key === lock.entrySkill)?.guidePath)
|
|
338
|
+
throw new Error('Role entry skill binding mismatch');
|
|
339
|
+
const snapshotFiles = lock.skills.flatMap(skill => [...skill.files, ...skill.assets].map(file => `skills/${skill.key}/${file.path}`))
|
|
340
|
+
.concat('profile.json', ...(lock.instructionsPath ? ['ROLE.md'] : [])).sort();
|
|
341
|
+
if (JSON.stringify(await listFiles(roleDirectory)) !== JSON.stringify(snapshotFiles))
|
|
342
|
+
throw new Error('Role snapshot inventory mismatch');
|
|
343
|
+
return lock;
|
|
344
|
+
}
|
|
345
|
+
/** New lock => latest catalogue revisions; existing lock => checked, fully offline reuse even if the source/profile changed. */
|
|
346
|
+
export async function resolveRoleSkills(options) {
|
|
347
|
+
const cache = resolve(options.cacheRoot);
|
|
348
|
+
await mkdir(cache, { recursive: true, mode: 0o700 });
|
|
349
|
+
const root = await realpath(cache);
|
|
350
|
+
const lockPath = resolve(options.lockPath), profilePath = resolve(options.profilePath);
|
|
351
|
+
if (await exists(lockPath)) {
|
|
352
|
+
const info = await lstat(lockPath);
|
|
353
|
+
if (!info.isFile() || info.isSymbolicLink())
|
|
354
|
+
throw new Error('Role lock is not a regular file');
|
|
355
|
+
const lock = roleSkillLockSchema.parse(JSON.parse(await readFile(lockPath, 'utf8')));
|
|
356
|
+
if (lock.profilePath !== profilePath && await realpath(lock.profilePath) !== await realpath(profilePath))
|
|
357
|
+
throw new Error('Role lock belongs to another profile');
|
|
358
|
+
return validateLock(root, lock);
|
|
359
|
+
}
|
|
360
|
+
options.signal?.throwIfAborted();
|
|
361
|
+
const bytes = await readFile(profilePath), profile = roleSkillProfileSchema.parse(JSON.parse(bytes.toString('utf8')));
|
|
362
|
+
const instructions = profile.instructionsPath ? await readFile(resolve(dirname(profilePath), profile.instructionsPath)) : undefined;
|
|
363
|
+
const lock = { schemaVersion: 1, roleId: profile.id, roleVersion: profile.version, profilePath,
|
|
364
|
+
profileSha256: hash(bytes), cacheRoot: root, roleDirectory: root, createdAt: new Date().toISOString(),
|
|
365
|
+
...(instructions ? { instructionsSha256: hash(instructions), instructionsBytes: instructions.length } : {}),
|
|
366
|
+
...(profile.entrySkill ? { entrySkill: profile.entrySkill } : {}), skills: [] };
|
|
367
|
+
for (const wanted of profile.skills) {
|
|
368
|
+
const base = wanted.nodeUrl ?? profile.network.agentUrl;
|
|
369
|
+
const { directory, receipt } = await loadSkill(root, base, wanted, profile.network.timeoutMs, options.signal);
|
|
370
|
+
const assets = await loadAssets(root, directory, wanted, profile.network.timeoutMs, options.signal);
|
|
371
|
+
lock.skills.push({ key: wanted.key, nodeUrl: base, skillId: receipt.skillId, sourceId: receipt.sourceId, name: receipt.name,
|
|
372
|
+
revision: receipt.revision, cacheDirectory: directory, directory: root, guidePath: root, guideResource: receipt.guideResource, files: receipt.files, assets });
|
|
373
|
+
}
|
|
374
|
+
lock.roleDirectory = join(root, 'roles', profile.id, snapshotId(lock));
|
|
375
|
+
if (instructions)
|
|
376
|
+
lock.instructionsPath = join(lock.roleDirectory, 'ROLE.md');
|
|
377
|
+
for (const skill of lock.skills) {
|
|
378
|
+
skill.directory = join(lock.roleDirectory, 'skills', skill.key);
|
|
379
|
+
skill.guidePath = join(skill.directory, skill.guideResource);
|
|
380
|
+
}
|
|
381
|
+
if (profile.entrySkill)
|
|
382
|
+
lock.entryGuidePath = lock.skills.find(skill => skill.key === profile.entrySkill).guidePath;
|
|
383
|
+
const parent = dirname(lock.roleDirectory);
|
|
384
|
+
await checkParents(root, parent, true);
|
|
385
|
+
if (!(await exists(lock.roleDirectory))) {
|
|
386
|
+
const temporary = join(parent, `.materialize-${randomUUID()}`);
|
|
387
|
+
await mkdir(temporary, { mode: 0o700 });
|
|
388
|
+
try {
|
|
389
|
+
for (const skill of lock.skills)
|
|
390
|
+
for (const file of [...skill.files, ...skill.assets]) {
|
|
391
|
+
const path = join(temporary, 'skills', skill.key, file.path);
|
|
392
|
+
await checkParents(root, dirname(path), true);
|
|
393
|
+
const source = skill.files.includes(file) ? join(skill.cacheDirectory, 'files', file.path) : join(root, 'assets', file.sha256, 'blob');
|
|
394
|
+
await copyFile(source, path);
|
|
395
|
+
}
|
|
396
|
+
await writeFile(join(temporary, 'profile.json'), bytes, { mode: 0o600 });
|
|
397
|
+
if (instructions)
|
|
398
|
+
await writeFile(join(temporary, 'ROLE.md'), instructions, { mode: 0o600 });
|
|
399
|
+
await installDirectory(temporary, lock.roleDirectory);
|
|
400
|
+
}
|
|
401
|
+
finally {
|
|
402
|
+
await rm(temporary, { recursive: true, force: true });
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
await validateLock(root, lock);
|
|
406
|
+
options.signal?.throwIfAborted();
|
|
407
|
+
await mkdir(dirname(lockPath), { recursive: true, mode: 0o700 });
|
|
408
|
+
const temporary = join(dirname(lockPath), `.role-lock-${randomUUID()}`);
|
|
409
|
+
await writeFile(temporary, JSON.stringify(lock, null, 2) + '\n', { flag: 'wx', mode: 0o600 });
|
|
410
|
+
try {
|
|
411
|
+
await link(temporary, lockPath);
|
|
412
|
+
}
|
|
413
|
+
catch (error) {
|
|
414
|
+
if (error.code !== 'EEXIST')
|
|
415
|
+
throw error;
|
|
416
|
+
}
|
|
417
|
+
finally {
|
|
418
|
+
await rm(temporary, { force: true });
|
|
419
|
+
}
|
|
420
|
+
const storedInfo = await lstat(lockPath);
|
|
421
|
+
if (!storedInfo.isFile() || storedInfo.isSymbolicLink())
|
|
422
|
+
throw new Error('Role lock is not a regular file');
|
|
423
|
+
const stored = roleSkillLockSchema.parse(JSON.parse(await readFile(lockPath, 'utf8')));
|
|
424
|
+
if (stored.profilePath !== profilePath)
|
|
425
|
+
throw new Error('Concurrent role lock belongs to another profile');
|
|
426
|
+
return validateLock(root, stored);
|
|
427
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1agents/acp-service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "ACP runtime, CLI, HTTP/WebSocket service and DeepSeek Harness ACP/A2A plugins in one package.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dreammate",
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
"import": "./dist/src/package.js"
|
|
31
31
|
},
|
|
32
32
|
"./package.json": "./package.json",
|
|
33
|
+
"./roles": {
|
|
34
|
+
"types": "./dist/src/roles/index.d.ts",
|
|
35
|
+
"import": "./dist/src/roles/index.js"
|
|
36
|
+
},
|
|
33
37
|
"./runtime": {
|
|
34
38
|
"types": "./vendor/runtime/dist/runtime.d.ts",
|
|
35
39
|
"import": "./vendor/runtime/dist/runtime.js"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: acp-service
|
|
3
|
-
description: 使用 @1agents/acp-service
|
|
3
|
+
description: 使用 @1agents/acp-service 管理 ACP 会话与 DSH 插件,通过 A2A 调用固定角色、派发临时任务、查询父子任务和执行轮次、记录业务验收及处理通知,并回投 Codex/DSH 原会话。也用于项目/角色候选探查、目标登记、网络技能缓存和更新接口接入;不用于无关的系统巡检或模型配置。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# ACP Service
|
|
@@ -14,12 +14,18 @@ description: 使用 @1agents/acp-service 的 ACP CLI、HTTP/WebSocket 服务和
|
|
|
14
14
|
| 在当前主机运行 Codex、Claude 等 Agent,管理命名会话、队列或流程 | `acp-service <agent> ...` | [ACP CLI 与服务](references/acp.md) |
|
|
15
15
|
| 从客户端连接常驻 Agent 服务,使用标准会话与流式交互 | `acp-service serve`,ACP over WebSocket | [ACP CLI 与服务](references/acp.md) |
|
|
16
16
|
| 在 DSH 界面使用外部 Agent、原生模型和模式控制 | DSH 中安装同一个包,选择 `ACP · Agent` 预设 | [DSH 插件](references/dsh.md) |
|
|
17
|
-
|
|
|
17
|
+
| 手动或定频从本机项目目录发现角色候选 | 可选 Reader CLI 适配,`execution_project_scan/list` 与 `execution_discovery_config_*` | [候选探查](references/roles-and-tasks.md#可选项目与角色候选探查) |
|
|
18
|
+
| 创建或调整固定角色,接入网络技能及版本缓存 | 可用时用 `resident-agent` 完成角色管理;API 登记用 `execution_target_*` | [角色管理与任务调用](references/roles-and-tasks.md) |
|
|
19
|
+
| 调用已登记的固定角色 | `execution_submit`,指定 resident_agent 的 targetId | [角色管理与任务调用](references/roles-and-tasks.md) |
|
|
20
|
+
| 派发一次性临时任务,无需创建角色 | 向 agent_host 目标 `execution_submit`;兼容 `remote_agent_spawn` | [角色管理与任务调用](references/roles-and-tasks.md) |
|
|
21
|
+
| 查询任务/执行轮次、续派、关闭、记录验收、处理通知 | `execution_*`;按通知类型选择 ack | [角色管理与任务调用](references/roles-and-tasks.md) |
|
|
18
22
|
| 把消息或 A2A 完成通知送回已存在的 Codex/DSH 主会话 | 配置 gateway `sessionHosts`,使用 `session_bind`、`session_send` 和投递查询工具 | [原会话排队投递](references/a2a.md#原会话排队投递本次新增) |
|
|
19
23
|
| 为其他 A2A 客户端开放 DSH 能力 | DSH `a2a` 配置、Agent Card、标准 JSON-RPC/SSE | [A2A 调度与收件箱](references/a2a.md) |
|
|
20
24
|
|
|
21
25
|
先检查现有服务和安装版本;服务已经可用时直接复用。需要哪种入口就读对应引用文件。不要为了派发一次远端任务重新安装或重启正常运行的服务。
|
|
22
26
|
|
|
27
|
+
项目探查默认手动,仅读取受控目录元数据和 profile 结构;候选不自动登记为可执行目标,不创建任务、不加载角色代码,也不唤醒主会话。定频由网关后台显式配置,不将主会话轮询作为探查流程。
|
|
28
|
+
|
|
23
29
|
ACP 管理 Agent 会话、交互与工具权限;A2A 管理跨 Agent 的任务、状态、结果及订阅通知。A2A 指向 DSH 后,DSH 的预设决定由标准 Agent 还是外部 ACP Agent 执行。
|
|
24
30
|
|
|
25
31
|
## 安装与技能发现
|
|
@@ -45,16 +51,24 @@ acp-service --skill install acp-service --agent codex --scope repo
|
|
|
45
51
|
|
|
46
52
|
`--skill` 同时保留内嵌 runtime 的 `acpx` 技能。`acp-service` **不带参数会启动 ACP 常驻服务**;查看帮助要显式传 `--help`。
|
|
47
53
|
|
|
54
|
+
## 异步调用纪律
|
|
55
|
+
|
|
56
|
+
常驻角色可由宿主按能力网络加载并锁定技能版本。任务使用宿主回执中的角色/技能锁与缓存入口,不在主会话另行检索、下载或复验;同一任务续派沿用原锁。更新与缓存管理在派单前的独立部署阶段完成,详见项目 `.1agents/README.md`;`acp-service roles sync --help` 可查看显式缓存入口。
|
|
57
|
+
|
|
58
|
+
开发、部署与回归先独立完成。所有任务提交并保存回执后必须立即结束本轮;只有实际通知唤醒后才单次读取回执、记录结论、ack 并答复。禁止主会话主动轮询 get/list/inbox、sleep/wait 等完成、读取子会话日志/进程,或重复文件/hash/图像/事实验收。用户明确要求单次查询/取消时只执行该动作;受理未知不自动重派。此纪律限定主会话调用,不关闭后台网关的状态核对能力。
|
|
59
|
+
|
|
60
|
+
普通固定角色/临时任务按下面及 [API 路由](references/roles-and-tasks.md) 直接提交。`scripts/a2a-caller.py` 是现稿 PPT 独立只验收与 Codex 计步专用入口,仅该场景读取 [只验收计步流程](references/async-caller.md);不要为普通任务伪造 PPT 报告字段或沿用其“不接受原稿”的结论。
|
|
61
|
+
|
|
48
62
|
## 远端任务的最短工作流
|
|
49
63
|
|
|
50
64
|
如果宿主已有 DreamMate 工具,检索服务 `a2a-gateway`,按需查看方法契约,再通过 `dreammate_invoke` 调用。没有 DreamMate 时,使用同名 CLI `a2a invoke`;两者调用同一个 gateway。
|
|
51
65
|
|
|
52
66
|
1. 取得当前主会话的稳定 ID,作为 `originSessionId`;保留真实会话归属,不使用每次随机生成的 ID。
|
|
53
67
|
如需自动回投,先将该 ID 用 `session_bind` 绑定到已配置宿主和真实原会话 ID;未绑定时保留原收件箱/webhook 路径。
|
|
54
|
-
2.
|
|
55
|
-
3.
|
|
56
|
-
4.
|
|
57
|
-
5.
|
|
68
|
+
2. 固定角色使用已登记 target 绑定的执行位置和预设;临时任务明确 agent_host target、远端绝对目录及预设。完整任务说明均需自包含,远端会话不会自动继承主会话上下文。
|
|
69
|
+
3. 调用已登记目标的 `execution_submit`(或兼容 `remote_agent_spawn`),保存 job/attempt/task/context/session 与实际预设;受理不等于完成。随后立即结束本轮。
|
|
70
|
+
4. 真实通知唤醒后,只读取一次交付回执及本次合同要求的新报告,核对身份与版本绑定,保存处理结论,再按通知类型 ack。需要业务接受时另记 `execution_review`。独立角色的验收不由主会话重复执行。
|
|
71
|
+
5. 统一账本任务使用 `execution_continue` 保留 job、新建 attempt;独立工作重新 submit。兼容流程用 `remote_agent_message` 复用远端会话并返回新 taskId。关闭父任务用 `execution_cancel`,需要时指定 cascade,详见 API 路由。
|
|
58
72
|
|
|
59
73
|
```json
|
|
60
74
|
{
|
|
@@ -87,7 +101,7 @@ acp-service --skill install acp-service --agent codex --scope repo
|
|
|
87
101
|
- 网络离线可能返回缓存与 `stale: true`,不等于远端任务失败。SendMessage 响应不明确时先核对,不盲目重发。
|
|
88
102
|
- DSH 的直接 webhook 为尽力投递;gateway 的持久收件箱和后台查询负责补齐,配置宿主通知接收端后还能重试投递。
|
|
89
103
|
- 本次源码新增的 `session_*` 工具通过 Codex 原生 `queue` 或 DSH 宿主 `queue` 投递到原会话;需先配置和绑定,不能假设已安装旧版本或现有部署包含它。普通 MCP 连接本身不提供回投,且此包没有接管 Codex 原生 `spawn_subagent`。
|
|
90
|
-
- 投递 `accepted`
|
|
104
|
+
- 投递 `accepted` 只代表宿主接受排队,不代表模型执行、业务处理或通知已确认。处理完结果后按实际通知类型调用 `remote_agent_ack` 或 `execution_ack`;自动回投不自动记录业务接受。
|
|
91
105
|
- `session_delivery_get` 返回 `unknown` 时先核对宿主是否已入队;`rejected` 表示已明确拒绝,需要先排除阻碍。两者均不自动重发,并阻塞同一 origin 后续投递。`session_delivery_resolve` 只处理这两种状态;`accepted: false` 必须表示确认未受理且可重新尝试,不能表示“还没处理”。
|
|
92
106
|
- 同一 `originSessionId/messageId` 只能对应同一正文;重试复用原 ID。公开 `session_send` 禁止使用保留前缀 `a2a-notice:`。DSH 的稳定 requestId 有助于幂等,不能据此承诺 exactly-once 或跨重启无重复。
|
|
93
107
|
- 宿主传输 ID 稳定派生自 `sha256([originSessionId, messageId])`,隔离不同 origin 的同名消息;工具仍使用原 messageId,`hostReceiptId` 由宿主回执决定。
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# A2A 调度、查询与完成通知
|
|
2
2
|
|
|
3
|
+
## 默认调用边界
|
|
4
|
+
|
|
5
|
+
日常主会话按 [角色与任务路由](roles-and-tasks.md) 选择管理、固定角色或临时任务入口:开发部署先完成,派单保存回执后立即结束本轮;实际通知唤醒后只读一次回执/新报告、保存结论并按通知类型 ack。现稿 PPT 只验收计步才使用 [专用脚本](async-caller.md)。以下 get/list/inbox 示例是接口说明,只用于真实通知后的单次读取或用户明确要求的单次状态查询,不能组成主会话轮询。后台网关核对照常运行,主会话不读子日志、不等待、不重复产物验收。
|
|
6
|
+
|
|
3
7
|
## 链路与入口
|
|
4
8
|
|
|
5
9
|
```text
|
|
@@ -79,9 +83,9 @@ DreamMate 调用参数为 `service_id: "a2a-gateway"`、`method: 方法名`、`p
|
|
|
79
83
|
| 方法 | 参数与用途 |
|
|
80
84
|
| --- | --- |
|
|
81
85
|
| `remote_agent_preflight` | `remote, originSessionId, cwd`;可选任务目录、必需输入和运行时依赖,仅检查、不创建会话 |
|
|
82
|
-
| `remote_agent_spawn` | 必填 `remote, originSessionId, cwd, prompt`;可选 `agentPreset, title, notificationTarget, preflight, resultContract`;新建远端任务/上下文/DSH 会话 |
|
|
86
|
+
| `remote_agent_spawn` | 必填 `remote, originSessionId, cwd, prompt`;可选 `agentPreset, title, notificationTarget, preflight, resultContract, clientRequestId, roleId, roleLockPath`;新建远端任务/上下文/DSH 会话 |
|
|
83
87
|
| `remote_agent_get` | `remote, originSessionId, taskId`;当前状态、结果;离线返回缓存与 stale |
|
|
84
|
-
| `remote_agent_message` | 上述任务定位字段加 `prompt`;复用远端会话,创建新 taskId |
|
|
88
|
+
| `remote_agent_message` | 上述任务定位字段加 `prompt`;可选 `clientRequestId, preflight, resultContract, roleId, roleLockPath`;复用远端会话,创建新 taskId;已有角色/锁不能更换 |
|
|
85
89
|
| `remote_agent_cancel` | 任务定位字段;取消这项任务自己的执行 |
|
|
86
90
|
| `remote_agent_list` | `originSessionId`;列出该主会话派发的任务 |
|
|
87
91
|
| `remote_agent_inbox` | `originSessionId`;读取未确认的完成/需要输入通知 |
|
|
@@ -119,7 +123,7 @@ JSON
|
|
|
119
123
|
|
|
120
124
|
## 原会话排队投递(本次新增)
|
|
121
125
|
|
|
122
|
-
|
|
126
|
+
这是可选 gateway 能力。以当前安装的方法契约和真实绑定为准;没有 `sessionHosts` 和绑定时保留原收件箱/webhook 路径。普通 MCP 连接本身不证明可自动唤醒。
|
|
123
127
|
|
|
124
128
|
gateway 配置中的 `sessionHosts` 按名称定义宿主。`kind: "codex"` 使用原生 `codex queue --thread=<UUID> --message=<原文>`,可配置 `executable`、`remote`、`cwd`、`timeoutMs` 和 `remoteAuthTokenEnv`;进程参数不经 shell。`kind: "dsh"` 使用宿主 origin 的 `/api/session/prompt`,按其 Web Remote envelope 发送 `mode: "queue"` 和稳定 requestId,可配置 `url`、`headers`、`timeoutMs`。这条路径直接使用已有宿主队列,无需另设通知 receiver。
|
|
125
129
|
|
|
@@ -179,9 +183,9 @@ notice 继续保留在 inbox;主 Agent 真正处理结果后才调用 `remote_
|
|
|
179
183
|
}
|
|
180
184
|
```
|
|
181
185
|
|
|
182
|
-
响应在 `result.task`,包含 `id`、`contextId
|
|
186
|
+
响应在 `result.task`,包含 `id`、`contextId` 和已有的 `metadata.1agents.sessionId/cwd/agentPreset`。`returnImmediately: true` 返回受理任务;配置网络角色的冷下载和会话准备可在受理后进行,首回执可能尚无 sessionId。普通无角色任务保持会话准备后返回的时序;省略则默认等待终态或需要输入状态。
|
|
183
187
|
|
|
184
|
-
`metadata.1agents`
|
|
188
|
+
`metadata.1agents` 的调用输入支持 `cwd/workspace/agentPreset/preflight/resultContract/roleId/roleLockPath`。cwd 和 workspace 不可同时传,cwd 为远端现有绝对目录,workspace 为配置别名;省略位置与预设按远端默认值处理。roleId 必须在宿主可信映射中;roleLockPath 仅接受宿主缓存 locks 目录内已存在、身份与字节校验通过的父锁,不能通过任务参数覆盖 profile、网络或缓存根。
|
|
185
189
|
|
|
186
190
|
同一会话的新任务在 `message.contextId` 传已保存 context ID;保存的 cwd/preset 不能改变。已完成 task 不可重新打开。原 task 为 input-required 时可传 `message.taskId`,配合新的 `messageId` 继续;活跃 task 上的 follow-up 被拒绝。
|
|
187
191
|
|