@zhixuan92/multi-model-agent 3.0.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/LICENSE +21 -0
- package/README.md +217 -0
- package/dist/cli/index.d.ts +61 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +252 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/install-skill.d.ts +158 -0
- package/dist/cli/install-skill.d.ts.map +1 -0
- package/dist/cli/install-skill.js +425 -0
- package/dist/cli/install-skill.js.map +1 -0
- package/dist/cli/print-token.d.ts +18 -0
- package/dist/cli/print-token.d.ts.map +1 -0
- package/dist/cli/print-token.js +60 -0
- package/dist/cli/print-token.js.map +1 -0
- package/dist/cli/serve.d.ts +44 -0
- package/dist/cli/serve.d.ts.map +1 -0
- package/dist/cli/serve.js +61 -0
- package/dist/cli/serve.js.map +1 -0
- package/dist/cli/status.d.ts +49 -0
- package/dist/cli/status.d.ts.map +1 -0
- package/dist/cli/status.js +155 -0
- package/dist/cli/status.js.map +1 -0
- package/dist/http/async-dispatch.d.ts +32 -0
- package/dist/http/async-dispatch.d.ts.map +1 -0
- package/dist/http/async-dispatch.js +53 -0
- package/dist/http/async-dispatch.js.map +1 -0
- package/dist/http/auth.d.ts +26 -0
- package/dist/http/auth.d.ts.map +1 -0
- package/dist/http/auth.js +64 -0
- package/dist/http/auth.js.map +1 -0
- package/dist/http/cwd-validator.d.ts +11 -0
- package/dist/http/cwd-validator.d.ts.map +1 -0
- package/dist/http/cwd-validator.js +115 -0
- package/dist/http/cwd-validator.js.map +1 -0
- package/dist/http/errors.d.ts +4 -0
- package/dist/http/errors.d.ts.map +1 -0
- package/dist/http/errors.js +9 -0
- package/dist/http/errors.js.map +1 -0
- package/dist/http/execution-context.d.ts +15 -0
- package/dist/http/execution-context.d.ts.map +1 -0
- package/dist/http/execution-context.js +35 -0
- package/dist/http/execution-context.js.map +1 -0
- package/dist/http/handler-deps.d.ts +16 -0
- package/dist/http/handler-deps.d.ts.map +1 -0
- package/dist/http/handler-deps.js +2 -0
- package/dist/http/handler-deps.js.map +1 -0
- package/dist/http/handlers/control/batch.d.ts +24 -0
- package/dist/http/handlers/control/batch.d.ts.map +1 -0
- package/dist/http/handlers/control/batch.js +81 -0
- package/dist/http/handlers/control/batch.js.map +1 -0
- package/dist/http/handlers/control/clarifications.d.ts +19 -0
- package/dist/http/handlers/control/clarifications.d.ts.map +1 -0
- package/dist/http/handlers/control/clarifications.js +58 -0
- package/dist/http/handlers/control/clarifications.js.map +1 -0
- package/dist/http/handlers/control/context-blocks.d.ts +22 -0
- package/dist/http/handlers/control/context-blocks.d.ts.map +1 -0
- package/dist/http/handlers/control/context-blocks.js +88 -0
- package/dist/http/handlers/control/context-blocks.js.map +1 -0
- package/dist/http/handlers/introspection/health.d.ts +13 -0
- package/dist/http/handlers/introspection/health.d.ts.map +1 -0
- package/dist/http/handlers/introspection/health.js +17 -0
- package/dist/http/handlers/introspection/health.js.map +1 -0
- package/dist/http/handlers/introspection/status.d.ts +26 -0
- package/dist/http/handlers/introspection/status.d.ts.map +1 -0
- package/dist/http/handlers/introspection/status.js +136 -0
- package/dist/http/handlers/introspection/status.js.map +1 -0
- package/dist/http/handlers/introspection/tools-list.d.ts +9 -0
- package/dist/http/handlers/introspection/tools-list.d.ts.map +1 -0
- package/dist/http/handlers/introspection/tools-list.js +28 -0
- package/dist/http/handlers/introspection/tools-list.js.map +1 -0
- package/dist/http/handlers/tools/audit.d.ts +4 -0
- package/dist/http/handlers/tools/audit.d.ts.map +1 -0
- package/dist/http/handlers/tools/audit.js +39 -0
- package/dist/http/handlers/tools/audit.js.map +1 -0
- package/dist/http/handlers/tools/debug.d.ts +4 -0
- package/dist/http/handlers/tools/debug.d.ts.map +1 -0
- package/dist/http/handlers/tools/debug.js +39 -0
- package/dist/http/handlers/tools/debug.js.map +1 -0
- package/dist/http/handlers/tools/delegate.d.ts +4 -0
- package/dist/http/handlers/tools/delegate.d.ts.map +1 -0
- package/dist/http/handlers/tools/delegate.js +57 -0
- package/dist/http/handlers/tools/delegate.js.map +1 -0
- package/dist/http/handlers/tools/execute-plan.d.ts +4 -0
- package/dist/http/handlers/tools/execute-plan.d.ts.map +1 -0
- package/dist/http/handlers/tools/execute-plan.js +39 -0
- package/dist/http/handlers/tools/execute-plan.js.map +1 -0
- package/dist/http/handlers/tools/retry.d.ts +4 -0
- package/dist/http/handlers/tools/retry.d.ts.map +1 -0
- package/dist/http/handlers/tools/retry.js +52 -0
- package/dist/http/handlers/tools/retry.js.map +1 -0
- package/dist/http/handlers/tools/review.d.ts +4 -0
- package/dist/http/handlers/tools/review.d.ts.map +1 -0
- package/dist/http/handlers/tools/review.js +39 -0
- package/dist/http/handlers/tools/review.js.map +1 -0
- package/dist/http/handlers/tools/verify.d.ts +4 -0
- package/dist/http/handlers/tools/verify.d.ts.map +1 -0
- package/dist/http/handlers/tools/verify.js +39 -0
- package/dist/http/handlers/tools/verify.js.map +1 -0
- package/dist/http/loopback.d.ts +17 -0
- package/dist/http/loopback.d.ts.map +1 -0
- package/dist/http/loopback.js +43 -0
- package/dist/http/loopback.js.map +1 -0
- package/dist/http/middleware/body-reader.d.ts +16 -0
- package/dist/http/middleware/body-reader.d.ts.map +1 -0
- package/dist/http/middleware/body-reader.js +44 -0
- package/dist/http/middleware/body-reader.js.map +1 -0
- package/dist/http/project-registry.d.ts +54 -0
- package/dist/http/project-registry.d.ts.map +1 -0
- package/dist/http/project-registry.js +132 -0
- package/dist/http/project-registry.js.map +1 -0
- package/dist/http/router.d.ts +14 -0
- package/dist/http/router.d.ts.map +1 -0
- package/dist/http/router.js +41 -0
- package/dist/http/router.js.map +1 -0
- package/dist/http/server.d.ts +16 -0
- package/dist/http/server.d.ts.map +1 -0
- package/dist/http/server.js +235 -0
- package/dist/http/server.js.map +1 -0
- package/dist/http/types.d.ts +9 -0
- package/dist/http/types.d.ts.map +1 -0
- package/dist/http/types.js +2 -0
- package/dist/http/types.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/install/claude-code.d.ts +43 -0
- package/dist/install/claude-code.d.ts.map +1 -0
- package/dist/install/claude-code.js +65 -0
- package/dist/install/claude-code.js.map +1 -0
- package/dist/install/codex-cli.d.ts +39 -0
- package/dist/install/codex-cli.d.ts.map +1 -0
- package/dist/install/codex-cli.js +318 -0
- package/dist/install/codex-cli.js.map +1 -0
- package/dist/install/cursor.d.ts +72 -0
- package/dist/install/cursor.d.ts.map +1 -0
- package/dist/install/cursor.js +81 -0
- package/dist/install/cursor.js.map +1 -0
- package/dist/install/gemini-cli.d.ts +66 -0
- package/dist/install/gemini-cli.d.ts.map +1 -0
- package/dist/install/gemini-cli.js +111 -0
- package/dist/install/gemini-cli.js.map +1 -0
- package/dist/install/include-utils.d.ts +27 -0
- package/dist/install/include-utils.d.ts.map +1 -0
- package/dist/install/include-utils.js +90 -0
- package/dist/install/include-utils.js.map +1 -0
- package/dist/install/manifest.d.ts +90 -0
- package/dist/install/manifest.d.ts.map +1 -0
- package/dist/install/manifest.js +200 -0
- package/dist/install/manifest.js.map +1 -0
- package/dist/openapi.d.ts +15 -0
- package/dist/openapi.d.ts.map +1 -0
- package/dist/openapi.js +314 -0
- package/dist/openapi.js.map +1 -0
- package/dist/skills/_shared/auth.md +32 -0
- package/dist/skills/_shared/error-handling.md +31 -0
- package/dist/skills/_shared/polling.md +40 -0
- package/dist/skills/_shared/response-shape.md +46 -0
- package/dist/skills/mma-audit/SKILL.md +55 -0
- package/dist/skills/mma-clarifications/SKILL.md +68 -0
- package/dist/skills/mma-context-blocks/SKILL.md +69 -0
- package/dist/skills/mma-debug/SKILL.md +59 -0
- package/dist/skills/mma-delegate/SKILL.md +63 -0
- package/dist/skills/mma-execute-plan/SKILL.md +63 -0
- package/dist/skills/mma-retry/SKILL.md +54 -0
- package/dist/skills/mma-review/SKILL.md +55 -0
- package/dist/skills/mma-verify/SKILL.md +57 -0
- package/dist/skills/multi-model-agent/SKILL.md +55 -0
- package/package.json +60 -0
package/dist/openapi.js
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
// packages/server/src/openapi.ts
|
|
2
|
+
//
|
|
3
|
+
// Builds the OpenAPI 3.0 document that describes all endpoints of the
|
|
4
|
+
// multi-model-agent HTTP server.
|
|
5
|
+
//
|
|
6
|
+
// Uses @asteasolutions/zod-to-openapi to convert each tool's Zod inputSchema
|
|
7
|
+
// directly into OpenAPI request body schemas.
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import { extendZodWithOpenApi, OpenAPIRegistry, OpenApiGeneratorV3, } from '@asteasolutions/zod-to-openapi';
|
|
10
|
+
import * as delegate from '@zhixuan92/multi-model-agent-core/tool-schemas/delegate';
|
|
11
|
+
import * as audit from '@zhixuan92/multi-model-agent-core/tool-schemas/audit';
|
|
12
|
+
import * as review from '@zhixuan92/multi-model-agent-core/tool-schemas/review';
|
|
13
|
+
import * as verify from '@zhixuan92/multi-model-agent-core/tool-schemas/verify';
|
|
14
|
+
import * as debug from '@zhixuan92/multi-model-agent-core/tool-schemas/debug';
|
|
15
|
+
import * as executePlan from '@zhixuan92/multi-model-agent-core/tool-schemas/execute-plan';
|
|
16
|
+
import * as retry from '@zhixuan92/multi-model-agent-core/tool-schemas/retry';
|
|
17
|
+
// Extend Zod once with openapi support.
|
|
18
|
+
extendZodWithOpenApi(z);
|
|
19
|
+
/** Sort an object's keys recursively for deterministic JSON serialization. */
|
|
20
|
+
function sortKeys(obj) {
|
|
21
|
+
if (obj === null || typeof obj !== 'object')
|
|
22
|
+
return obj;
|
|
23
|
+
if (Array.isArray(obj))
|
|
24
|
+
return obj.map(sortKeys);
|
|
25
|
+
const sorted = {};
|
|
26
|
+
for (const key of Object.keys(obj).sort()) {
|
|
27
|
+
sorted[key] = sortKeys(obj[key]);
|
|
28
|
+
}
|
|
29
|
+
return sorted;
|
|
30
|
+
}
|
|
31
|
+
/** Shared 202 response for async tool endpoints. */
|
|
32
|
+
const asyncResponse202 = {
|
|
33
|
+
description: 'Accepted — batch created',
|
|
34
|
+
content: {
|
|
35
|
+
'application/json': {
|
|
36
|
+
schema: z.object({
|
|
37
|
+
batchId: z.string().describe('Unique batch identifier for polling via GET /batch/:batchId'),
|
|
38
|
+
statusUrl: z.string().describe('Full URL to poll for this batch'),
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
/** Shared `cwd` query parameter (required by all tool endpoints). */
|
|
44
|
+
const cwdQueryParam = {
|
|
45
|
+
name: 'cwd',
|
|
46
|
+
in: 'query',
|
|
47
|
+
required: true,
|
|
48
|
+
description: 'Absolute path to the project working directory',
|
|
49
|
+
schema: { type: 'string' },
|
|
50
|
+
};
|
|
51
|
+
/** Standard 401 error response. */
|
|
52
|
+
const response401 = { description: 'Missing or invalid Bearer token' };
|
|
53
|
+
/** Standard 403 error response. */
|
|
54
|
+
const response403 = { description: 'Forbidden (loopback-only or path traversal)' };
|
|
55
|
+
/** Standard 404 error response. */
|
|
56
|
+
const response404 = { description: 'Resource not found' };
|
|
57
|
+
export function buildOpenApiDoc() {
|
|
58
|
+
const registry = new OpenAPIRegistry();
|
|
59
|
+
// ── Tool endpoints (POST, require cwd + auth) ───────────────────────────────
|
|
60
|
+
registry.registerPath({
|
|
61
|
+
method: 'post',
|
|
62
|
+
path: '/delegate',
|
|
63
|
+
summary: 'Dispatch tasks to sub-agents',
|
|
64
|
+
tags: ['Tools'],
|
|
65
|
+
request: {
|
|
66
|
+
query: z.object({ cwd: z.string().describe('Project working directory') }),
|
|
67
|
+
body: {
|
|
68
|
+
required: true,
|
|
69
|
+
content: { 'application/json': { schema: delegate.inputSchema } },
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
responses: {
|
|
73
|
+
202: asyncResponse202,
|
|
74
|
+
400: { description: 'Request validation error' },
|
|
75
|
+
401: response401,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
registry.registerPath({
|
|
79
|
+
method: 'post',
|
|
80
|
+
path: '/audit',
|
|
81
|
+
summary: 'Audit documents or files',
|
|
82
|
+
tags: ['Tools'],
|
|
83
|
+
request: {
|
|
84
|
+
query: z.object({ cwd: z.string().describe('Project working directory') }),
|
|
85
|
+
body: {
|
|
86
|
+
required: true,
|
|
87
|
+
content: { 'application/json': { schema: audit.inputSchema } },
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
responses: {
|
|
91
|
+
202: asyncResponse202,
|
|
92
|
+
400: { description: 'Request validation error' },
|
|
93
|
+
401: response401,
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
registry.registerPath({
|
|
97
|
+
method: 'post',
|
|
98
|
+
path: '/review',
|
|
99
|
+
summary: 'Review code for quality and security',
|
|
100
|
+
tags: ['Tools'],
|
|
101
|
+
request: {
|
|
102
|
+
query: z.object({ cwd: z.string().describe('Project working directory') }),
|
|
103
|
+
body: {
|
|
104
|
+
required: true,
|
|
105
|
+
content: { 'application/json': { schema: review.inputSchema } },
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
responses: {
|
|
109
|
+
202: asyncResponse202,
|
|
110
|
+
400: { description: 'Request validation error' },
|
|
111
|
+
401: response401,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
registry.registerPath({
|
|
115
|
+
method: 'post',
|
|
116
|
+
path: '/verify',
|
|
117
|
+
summary: 'Verify work against a checklist',
|
|
118
|
+
tags: ['Tools'],
|
|
119
|
+
request: {
|
|
120
|
+
query: z.object({ cwd: z.string().describe('Project working directory') }),
|
|
121
|
+
body: {
|
|
122
|
+
required: true,
|
|
123
|
+
content: { 'application/json': { schema: verify.inputSchema } },
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
responses: {
|
|
127
|
+
202: asyncResponse202,
|
|
128
|
+
400: { description: 'Request validation error' },
|
|
129
|
+
401: response401,
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
registry.registerPath({
|
|
133
|
+
method: 'post',
|
|
134
|
+
path: '/debug',
|
|
135
|
+
summary: 'Debug a problem with sub-agent assistance',
|
|
136
|
+
tags: ['Tools'],
|
|
137
|
+
request: {
|
|
138
|
+
query: z.object({ cwd: z.string().describe('Project working directory') }),
|
|
139
|
+
body: {
|
|
140
|
+
required: true,
|
|
141
|
+
content: { 'application/json': { schema: debug.inputSchema } },
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
responses: {
|
|
145
|
+
202: asyncResponse202,
|
|
146
|
+
400: { description: 'Request validation error' },
|
|
147
|
+
401: response401,
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
registry.registerPath({
|
|
151
|
+
method: 'post',
|
|
152
|
+
path: '/execute-plan',
|
|
153
|
+
summary: 'Execute tasks from a plan file',
|
|
154
|
+
tags: ['Tools'],
|
|
155
|
+
request: {
|
|
156
|
+
query: z.object({ cwd: z.string().describe('Project working directory') }),
|
|
157
|
+
body: {
|
|
158
|
+
required: true,
|
|
159
|
+
content: { 'application/json': { schema: executePlan.inputSchema } },
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
responses: {
|
|
163
|
+
202: asyncResponse202,
|
|
164
|
+
400: { description: 'Request validation error' },
|
|
165
|
+
401: response401,
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
registry.registerPath({
|
|
169
|
+
method: 'post',
|
|
170
|
+
path: '/retry',
|
|
171
|
+
summary: 'Retry failed tasks from a previous batch',
|
|
172
|
+
tags: ['Tools'],
|
|
173
|
+
request: {
|
|
174
|
+
query: z.object({ cwd: z.string().describe('Project working directory') }),
|
|
175
|
+
body: {
|
|
176
|
+
required: true,
|
|
177
|
+
content: { 'application/json': { schema: retry.inputSchema } },
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
responses: {
|
|
181
|
+
202: asyncResponse202,
|
|
182
|
+
400: { description: 'Request validation error' },
|
|
183
|
+
401: response401,
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
// ── Control endpoints ───────────────────────────────────────────────────────
|
|
187
|
+
registry.registerPath({
|
|
188
|
+
method: 'get',
|
|
189
|
+
path: '/batch/{batchId}',
|
|
190
|
+
summary: 'Poll batch status',
|
|
191
|
+
tags: ['Control'],
|
|
192
|
+
request: {
|
|
193
|
+
params: z.object({ batchId: z.string().describe('Batch identifier') }),
|
|
194
|
+
query: z.object({
|
|
195
|
+
taskIndex: z.string().optional().describe('Zero-based task index for result slicing'),
|
|
196
|
+
}),
|
|
197
|
+
},
|
|
198
|
+
responses: {
|
|
199
|
+
200: { description: 'Batch state (pending | awaiting_clarification | complete | failed | expired)' },
|
|
200
|
+
401: response401,
|
|
201
|
+
404: response404,
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
registry.registerPath({
|
|
205
|
+
method: 'post',
|
|
206
|
+
path: '/context-blocks',
|
|
207
|
+
summary: 'Register a context block',
|
|
208
|
+
tags: ['Control'],
|
|
209
|
+
request: {
|
|
210
|
+
query: z.object({ cwd: z.string().describe('Project working directory') }),
|
|
211
|
+
body: {
|
|
212
|
+
required: true,
|
|
213
|
+
content: {
|
|
214
|
+
'application/json': {
|
|
215
|
+
schema: z.object({
|
|
216
|
+
content: z.string().describe('Block content (plain text or markdown)'),
|
|
217
|
+
label: z.string().optional().describe('Human-readable label'),
|
|
218
|
+
}),
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
responses: {
|
|
224
|
+
201: { description: 'Block created' },
|
|
225
|
+
400: { description: 'Validation error or content too large' },
|
|
226
|
+
401: response401,
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
registry.registerPath({
|
|
230
|
+
method: 'delete',
|
|
231
|
+
path: '/context-blocks/{blockId}',
|
|
232
|
+
summary: 'Delete a context block',
|
|
233
|
+
tags: ['Control'],
|
|
234
|
+
request: {
|
|
235
|
+
params: z.object({ blockId: z.string().describe('Context block identifier') }),
|
|
236
|
+
query: z.object({ cwd: z.string().describe('Project working directory') }),
|
|
237
|
+
},
|
|
238
|
+
responses: {
|
|
239
|
+
200: { description: 'Block deleted (or was already absent)' },
|
|
240
|
+
401: response401,
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
registry.registerPath({
|
|
244
|
+
method: 'post',
|
|
245
|
+
path: '/clarifications/confirm',
|
|
246
|
+
summary: 'Confirm a proposed interpretation to unblock an awaiting_clarification batch',
|
|
247
|
+
tags: ['Control'],
|
|
248
|
+
request: {
|
|
249
|
+
body: {
|
|
250
|
+
required: true,
|
|
251
|
+
content: {
|
|
252
|
+
'application/json': {
|
|
253
|
+
schema: z.object({
|
|
254
|
+
batchId: z.string(),
|
|
255
|
+
interpretation: z.string(),
|
|
256
|
+
}),
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
responses: {
|
|
262
|
+
200: { description: 'Clarification accepted' },
|
|
263
|
+
400: { description: 'Invalid batch state' },
|
|
264
|
+
401: response401,
|
|
265
|
+
404: response404,
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
// ── Introspection endpoints ─────────────────────────────────────────────────
|
|
269
|
+
registry.registerPath({
|
|
270
|
+
method: 'get',
|
|
271
|
+
path: '/health',
|
|
272
|
+
summary: 'Liveness probe — no auth required',
|
|
273
|
+
tags: ['Introspection'],
|
|
274
|
+
responses: {
|
|
275
|
+
200: {
|
|
276
|
+
description: 'Server is alive',
|
|
277
|
+
content: {
|
|
278
|
+
'application/json': {
|
|
279
|
+
schema: z.object({ ok: z.literal(true) }),
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
registry.registerPath({
|
|
286
|
+
method: 'get',
|
|
287
|
+
path: '/status',
|
|
288
|
+
summary: 'Operator status — loopback + auth required',
|
|
289
|
+
tags: ['Introspection'],
|
|
290
|
+
responses: {
|
|
291
|
+
200: { description: 'Server status object (§5.10)' },
|
|
292
|
+
401: response401,
|
|
293
|
+
403: response403,
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
// ── Generate ────────────────────────────────────────────────────────────────
|
|
297
|
+
const generator = new OpenApiGeneratorV3(registry.definitions);
|
|
298
|
+
const doc = generator.generateDocument({
|
|
299
|
+
openapi: '3.0.3',
|
|
300
|
+
info: {
|
|
301
|
+
title: 'multi-model-agent',
|
|
302
|
+
version: '3.0.0',
|
|
303
|
+
},
|
|
304
|
+
});
|
|
305
|
+
// Return a key-sorted version for deterministic golden comparisons
|
|
306
|
+
return sortKeys(doc);
|
|
307
|
+
}
|
|
308
|
+
/** Utility: serialize the OpenAPI doc with sorted keys for golden snapshots. */
|
|
309
|
+
export function serializeOpenApiDoc(doc) {
|
|
310
|
+
return JSON.stringify(doc, null, 2);
|
|
311
|
+
}
|
|
312
|
+
// Re-export cwdQueryParam for tests / external use
|
|
313
|
+
export { cwdQueryParam };
|
|
314
|
+
//# sourceMappingURL=openapi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.js","sourceRoot":"","sources":["../src/openapi.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,6EAA6E;AAC7E,8CAA8C;AAC9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,kBAAkB,GACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,yDAAyD,CAAC;AACpF,OAAO,KAAK,KAAK,MAAM,sDAAsD,CAAC;AAC9E,OAAO,KAAK,MAAM,MAAM,uDAAuD,CAAC;AAChF,OAAO,KAAK,MAAM,MAAM,uDAAuD,CAAC;AAChF,OAAO,KAAK,KAAK,MAAM,sDAAsD,CAAC;AAC9E,OAAO,KAAK,WAAW,MAAM,6DAA6D,CAAC;AAC3F,OAAO,K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E,WAAW;SACjB;KACF,CAAC,CAAC;IAEH,+EAA+E;IAE/E,MAAM,SAAS,GAAG,IAAI,kBAAkB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC/D,MAAM,GAAG,GAAG,SAAS,CAAC,gBAAgB,CAAC;QACrC,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE;YACJ,KAAK,EAAE,mBAAmB;YAC1B,OAAO,EAAE,OAAO;SACjB;KACF,CAAC,CAAC;IAEH,mEAAmE;IACnE,OAAO,QAAQ,CAAC,GAAG,CAA4B,CAAC;AAClD,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,mBAAmB,CAAC,GAA4B;IAC9D,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACtC,CAAC;AAED,mDAAmD;AACnD,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
## Authentication
|
|
2
|
+
|
|
3
|
+
Every request to the multi-model-agent server requires a Bearer token.
|
|
4
|
+
|
|
5
|
+
### Obtain the token
|
|
6
|
+
|
|
7
|
+
**From environment variable** (preferred):
|
|
8
|
+
```
|
|
9
|
+
MMAGENT_AUTH_TOKEN=<token>
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
**From CLI**:
|
|
13
|
+
```bash
|
|
14
|
+
mmagent print-token
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Use the token
|
|
18
|
+
|
|
19
|
+
Add to every request as an HTTP header:
|
|
20
|
+
```
|
|
21
|
+
Authorization: Bearer <token>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Shell helper
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
TOKEN="${MMAGENT_AUTH_TOKEN:-$(mmagent print-token)}"
|
|
28
|
+
curl -H "Authorization: Bearer $TOKEN" ...
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If the server returns `401 unauthorized`, re-run `mmagent print-token` —
|
|
32
|
+
the token may have changed after a server restart.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
## Error handling
|
|
2
|
+
|
|
3
|
+
### HTTP status decision table
|
|
4
|
+
|
|
5
|
+
| Status | Code | Action |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `400` | `invalid_request` | Fix the request body or query params |
|
|
8
|
+
| `401` | `unauthorized` | Re-fetch token; check `MMAGENT_AUTH_TOKEN` |
|
|
9
|
+
| `403` | `forbidden` | `cwd` query param missing or out of scope |
|
|
10
|
+
| `404` | `not_found` | Wrong `batchId` or resource does not exist |
|
|
11
|
+
| `409` | `invalid_batch_state` / `pinned` | Batch in wrong state; check current state first |
|
|
12
|
+
| `413` | `payload_too_large` | Reduce content size (context block or body) |
|
|
13
|
+
| `429` | `rate_limited` | Wait `Retry-After` seconds, then retry |
|
|
14
|
+
| `503` | `project_cap_exceeded` | Too many concurrent projects; wait and retry |
|
|
15
|
+
| `5xx` | server error | Retry once after 2 s; escalate if it persists |
|
|
16
|
+
|
|
17
|
+
### Network failures
|
|
18
|
+
|
|
19
|
+
Retry up to 3 times with exponential backoff (1 s → 2 s → 4 s).
|
|
20
|
+
If the server is unreachable, check that `mmagent serve` is running:
|
|
21
|
+
```bash
|
|
22
|
+
curl -s http://localhost:$PORT/health # expects { ok: true }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Auth errors (401)
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
export MMAGENT_AUTH_TOKEN=$(mmagent print-token)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The token changes on every server restart. Re-export before retrying.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
## Polling for batch completion
|
|
2
|
+
|
|
3
|
+
After a tool call returns a `batchId`, poll `GET /batch/:id` until the batch
|
|
4
|
+
reaches a terminal state.
|
|
5
|
+
|
|
6
|
+
### Terminal states
|
|
7
|
+
|
|
8
|
+
| State | Meaning |
|
|
9
|
+
|---|---|
|
|
10
|
+
| `complete` | All tasks finished — read results |
|
|
11
|
+
| `failed` | Batch failed — read error details |
|
|
12
|
+
| `expired` | Batch TTL exceeded — retry if needed |
|
|
13
|
+
|
|
14
|
+
### Awaiting clarification
|
|
15
|
+
|
|
16
|
+
If `GET /batch/:id` returns `state: 'awaiting_clarification'`, the service
|
|
17
|
+
needs your confirmation before it can continue. Read `proposedInterpretation`
|
|
18
|
+
from the response, then call `POST /clarifications/confirm` with your chosen
|
|
19
|
+
`interpretation` (accept or correct the proposal).
|
|
20
|
+
|
|
21
|
+
### Poll loop (shell)
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
DELAY=1
|
|
25
|
+
while true; do
|
|
26
|
+
RESP=$(curl -sf -H "Authorization: Bearer $TOKEN" \
|
|
27
|
+
"http://localhost:$PORT/batch/$BATCH_ID")
|
|
28
|
+
STATE=$(echo "$RESP" | jq -r '.state')
|
|
29
|
+
case "$STATE" in
|
|
30
|
+
complete|failed|expired) echo "$RESP"; break ;;
|
|
31
|
+
awaiting_clarification)
|
|
32
|
+
# Invoke mma-clarifications to confirm interpretation, then continue
|
|
33
|
+
break ;;
|
|
34
|
+
*) sleep $DELAY; DELAY=$(( DELAY < 5 ? DELAY * 2 : 5 )) ;;
|
|
35
|
+
esac
|
|
36
|
+
done
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Start at 1 s, double each iteration, cap at 5 s. Most batches complete in
|
|
40
|
+
under 60 s; long tasks may take several minutes.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
## Response shapes
|
|
2
|
+
|
|
3
|
+
### POST /<tool>?cwd=<abs> — dispatch response (202)
|
|
4
|
+
|
|
5
|
+
```json
|
|
6
|
+
{
|
|
7
|
+
"batchId": "<uuid>",
|
|
8
|
+
"state": "pending"
|
|
9
|
+
}
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### GET /batch/:id — polling response
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"batchId": "<uuid>",
|
|
17
|
+
"state": "pending | running | awaiting_clarification | complete | failed | expired",
|
|
18
|
+
"proposedInterpretation": "<string>",
|
|
19
|
+
"results": [ ... ],
|
|
20
|
+
"headline": "<string>",
|
|
21
|
+
"batchTimings": { ... },
|
|
22
|
+
"costSummary": { ... }
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`proposedInterpretation` is only present when `state` is `awaiting_clarification`.
|
|
27
|
+
|
|
28
|
+
`results`, `headline`, `batchTimings`, and `costSummary` are only present
|
|
29
|
+
when `state` is `complete` or `failed`.
|
|
30
|
+
|
|
31
|
+
### GET /batch/:id?taskIndex=N — single task slice
|
|
32
|
+
|
|
33
|
+
Returns the same shape but `results` contains only the task at index `N`.
|
|
34
|
+
|
|
35
|
+
### Error response (4xx / 5xx)
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"error": "<code>",
|
|
40
|
+
"message": "<human-readable>",
|
|
41
|
+
"details": { ... }
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`details` is optional and present only when the server has structured
|
|
46
|
+
additional context (e.g. `fieldErrors` for validation failures).
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mma-audit
|
|
3
|
+
description: Audit a document for security, performance, correctness, or style issues. Sub-agents run in parallel per file.
|
|
4
|
+
when_to_use: When you need to audit a spec, design doc, or configuration file for correctness, security, style, or performance issues.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## mma-audit
|
|
8
|
+
|
|
9
|
+
Send a document or set of files to sub-agents for structured auditing. Each
|
|
10
|
+
file is audited independently in parallel; results are indexed by file.
|
|
11
|
+
|
|
12
|
+
### Endpoint
|
|
13
|
+
|
|
14
|
+
`POST /audit?cwd=<abs-path>`
|
|
15
|
+
|
|
16
|
+
@include _shared/auth.md
|
|
17
|
+
|
|
18
|
+
### Request body
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"document": "inline content to audit (optional if filePaths given)",
|
|
23
|
+
"auditType": "correctness",
|
|
24
|
+
"filePaths": ["/project/docs/spec.md"],
|
|
25
|
+
"contextBlockIds": []
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
| Field | Type | Required | Notes |
|
|
30
|
+
|---|---|---|---|
|
|
31
|
+
| `document` | string | no | Inline document content |
|
|
32
|
+
| `auditType` | string \| string[] | yes | `security`, `performance`, `correctness`, `style`, or `general`; or an array of the first four |
|
|
33
|
+
| `filePaths` | string[] | no | Files to audit (parallel) |
|
|
34
|
+
| `contextBlockIds` | string[] | no | IDs from `mma-context-blocks` |
|
|
35
|
+
|
|
36
|
+
Either `document` or `filePaths` (or both) must be provided.
|
|
37
|
+
|
|
38
|
+
### Full example
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
BATCH=$(curl -sf -X POST \
|
|
42
|
+
-H "Authorization: Bearer $TOKEN" \
|
|
43
|
+
-H "Content-Type: application/json" \
|
|
44
|
+
-d '{"auditType":"correctness","filePaths":["/project/docs/api-spec.md"]}' \
|
|
45
|
+
"http://localhost:$PORT/audit?cwd=/project")
|
|
46
|
+
BATCH_ID=$(echo "$BATCH" | jq -r '.batchId')
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Then poll until complete:
|
|
50
|
+
|
|
51
|
+
@include _shared/polling.md
|
|
52
|
+
|
|
53
|
+
@include _shared/response-shape.md
|
|
54
|
+
|
|
55
|
+
@include _shared/error-handling.md
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mma-clarifications
|
|
3
|
+
description: Confirm or correct the service's proposed interpretation when a batch is awaiting clarification before it can proceed.
|
|
4
|
+
when_to_use: When polling GET /batch/:id returns state 'awaiting_clarification'. Read proposedInterpretation, then call this skill to confirm or correct it.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## mma-clarifications
|
|
8
|
+
|
|
9
|
+
When a batch pauses with `state: 'awaiting_clarification'`, the service has
|
|
10
|
+
proposed an interpretation of the task and is waiting for your decision.
|
|
11
|
+
Read the proposal, then call `POST /clarifications/confirm` to either accept
|
|
12
|
+
or correct it. The batch resumes immediately after confirmation.
|
|
13
|
+
|
|
14
|
+
### Endpoint
|
|
15
|
+
|
|
16
|
+
`POST /clarifications/confirm`
|
|
17
|
+
|
|
18
|
+
Auth required. Not cwd-gated (operates on a `batchId`).
|
|
19
|
+
|
|
20
|
+
@include _shared/auth.md
|
|
21
|
+
|
|
22
|
+
### Request body
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"batchId": "550e8400-e29b-41d4-a716-446655440000",
|
|
27
|
+
"interpretation": "Refactor only the auth module, leaving the user module unchanged"
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
| Field | Type | Required | Notes |
|
|
32
|
+
|---|---|---|---|
|
|
33
|
+
| `batchId` | string (UUID) | yes | Batch in `awaiting_clarification` state |
|
|
34
|
+
| `interpretation` | string | yes | Accept proposal verbatim or provide a corrected version |
|
|
35
|
+
|
|
36
|
+
### Response (200)
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{ "batchId": "...", "state": "pending" }
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`state` is usually `pending` (batch resumes). It may be `complete` if the
|
|
43
|
+
executor was already waiting and finishes immediately.
|
|
44
|
+
|
|
45
|
+
### Full flow
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# 1. Poll until awaiting_clarification
|
|
49
|
+
STATE=$(curl -sf -H "Authorization: Bearer $TOKEN" \
|
|
50
|
+
"http://localhost:$PORT/batch/$BATCH_ID" | jq -r '.state')
|
|
51
|
+
|
|
52
|
+
# 2. Read the proposal
|
|
53
|
+
PROPOSAL=$(curl -sf -H "Authorization: Bearer $TOKEN" \
|
|
54
|
+
"http://localhost:$PORT/batch/$BATCH_ID" | jq -r '.proposedInterpretation')
|
|
55
|
+
|
|
56
|
+
# 3. Confirm (accept proposal or supply corrected text)
|
|
57
|
+
curl -sf -X POST \
|
|
58
|
+
-H "Authorization: Bearer $TOKEN" \
|
|
59
|
+
-H "Content-Type: application/json" \
|
|
60
|
+
-d "{\"batchId\":\"$BATCH_ID\",\"interpretation\":\"$PROPOSAL\"}" \
|
|
61
|
+
"http://localhost:$PORT/clarifications/confirm"
|
|
62
|
+
|
|
63
|
+
# 4. Resume polling
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
@include _shared/polling.md
|
|
67
|
+
|
|
68
|
+
@include _shared/error-handling.md
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mma-context-blocks
|
|
3
|
+
description: Register large reused documents as context blocks and reference them by ID across multiple tool calls. Avoids re-sending the same content repeatedly.
|
|
4
|
+
when_to_use: When the same large document (spec, plan, codebase summary) needs to be referenced by multiple mma-* calls. Register once, reference by ID.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## mma-context-blocks
|
|
8
|
+
|
|
9
|
+
Store large documents once; reference them by ID in subsequent `mma-*` calls
|
|
10
|
+
via `contextBlockIds`. The service prepends the block content to each task
|
|
11
|
+
prompt that references it.
|
|
12
|
+
|
|
13
|
+
### Register a context block
|
|
14
|
+
|
|
15
|
+
`POST /context-blocks?cwd=<abs-path>`
|
|
16
|
+
|
|
17
|
+
@include _shared/auth.md
|
|
18
|
+
|
|
19
|
+
#### Request body
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"content": "# Project spec\n...",
|
|
24
|
+
"ttlMs": 3600000
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
| Field | Type | Required | Notes |
|
|
29
|
+
|---|---|---|---|
|
|
30
|
+
| `content` | string | yes | Document content (min 1 char) |
|
|
31
|
+
| `ttlMs` | number | no | Time-to-live in ms; omit for session-scoped |
|
|
32
|
+
|
|
33
|
+
#### Response (201)
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{ "id": "cb_abc123" }
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Use this `id` as a `contextBlockIds` entry in `mma-delegate`, `mma-audit`,
|
|
40
|
+
`mma-review`, `mma-verify`, `mma-debug`, or `mma-execute-plan`.
|
|
41
|
+
|
|
42
|
+
### Delete a context block
|
|
43
|
+
|
|
44
|
+
`DELETE /context-blocks/:id?cwd=<abs-path>`
|
|
45
|
+
|
|
46
|
+
Returns `200 { ok: true }` on success.
|
|
47
|
+
|
|
48
|
+
Returns `409 pinned` if the block is held by one or more active batches —
|
|
49
|
+
wait for those batches to complete before deleting.
|
|
50
|
+
|
|
51
|
+
### Example
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Register spec document
|
|
55
|
+
ID=$(curl -sf -X POST \
|
|
56
|
+
-H "Authorization: Bearer $TOKEN" \
|
|
57
|
+
-H "Content-Type: application/json" \
|
|
58
|
+
-d "{\"content\":$(jq -Rs . < /project/docs/spec.md)}" \
|
|
59
|
+
"http://localhost:$PORT/context-blocks?cwd=/project" | jq -r '.id')
|
|
60
|
+
|
|
61
|
+
# Use in a delegate call
|
|
62
|
+
curl -sf -X POST \
|
|
63
|
+
-H "Authorization: Bearer $TOKEN" \
|
|
64
|
+
-H "Content-Type: application/json" \
|
|
65
|
+
-d "{\"tasks\":[{\"prompt\":\"Implement per spec\",\"contextBlockIds\":[\"$ID\"]}]}" \
|
|
66
|
+
"http://localhost:$PORT/delegate?cwd=/project"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
@include _shared/error-handling.md
|