@zhixuan92/multi-model-agent-mcp 2.8.0 → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +11 -207
  2. package/dist/cli.js +6 -599
  3. package/package.json +8 -49
  4. package/dist/cli.d.ts +0 -79
  5. package/dist/cli.d.ts.map +0 -1
  6. package/dist/cli.js.map +0 -1
  7. package/dist/headline.d.ts +0 -25
  8. package/dist/headline.d.ts.map +0 -1
  9. package/dist/headline.js +0 -58
  10. package/dist/headline.js.map +0 -1
  11. package/dist/http/auth.d.ts +0 -8
  12. package/dist/http/auth.d.ts.map +0 -1
  13. package/dist/http/auth.js +0 -43
  14. package/dist/http/auth.js.map +0 -1
  15. package/dist/http/cwd-validator.d.ts +0 -11
  16. package/dist/http/cwd-validator.d.ts.map +0 -1
  17. package/dist/http/cwd-validator.js +0 -31
  18. package/dist/http/cwd-validator.js.map +0 -1
  19. package/dist/http/lifecycle-handlers.d.ts +0 -12
  20. package/dist/http/lifecycle-handlers.d.ts.map +0 -1
  21. package/dist/http/lifecycle-handlers.js +0 -87
  22. package/dist/http/lifecycle-handlers.js.map +0 -1
  23. package/dist/http/loopback.d.ts +0 -10
  24. package/dist/http/loopback.d.ts.map +0 -1
  25. package/dist/http/loopback.js +0 -34
  26. package/dist/http/loopback.js.map +0 -1
  27. package/dist/http/project-registry.d.ts +0 -48
  28. package/dist/http/project-registry.d.ts.map +0 -1
  29. package/dist/http/project-registry.js +0 -119
  30. package/dist/http/project-registry.js.map +0 -1
  31. package/dist/http/session-router.d.ts +0 -33
  32. package/dist/http/session-router.d.ts.map +0 -1
  33. package/dist/http/session-router.js +0 -62
  34. package/dist/http/session-router.js.map +0 -1
  35. package/dist/http/status-endpoint.d.ts +0 -20
  36. package/dist/http/status-endpoint.d.ts.map +0 -1
  37. package/dist/http/status-endpoint.js +0 -85
  38. package/dist/http/status-endpoint.js.map +0 -1
  39. package/dist/http/transport.d.ts +0 -14
  40. package/dist/http/transport.d.ts.map +0 -1
  41. package/dist/http/transport.js +0 -209
  42. package/dist/http/transport.js.map +0 -1
  43. package/dist/index.d.ts +0 -4
  44. package/dist/index.d.ts.map +0 -1
  45. package/dist/index.js +0 -3
  46. package/dist/index.js.map +0 -1
  47. package/dist/routing/render-provider-routing-matrix.d.ts +0 -7
  48. package/dist/routing/render-provider-routing-matrix.d.ts.map +0 -1
  49. package/dist/routing/render-provider-routing-matrix.js +0 -153
  50. package/dist/routing/render-provider-routing-matrix.js.map +0 -1
  51. package/dist/status-cli.d.ts +0 -2
  52. package/dist/status-cli.d.ts.map +0 -1
  53. package/dist/status-cli.js +0 -68
  54. package/dist/status-cli.js.map +0 -1
  55. package/dist/tools/audit-document.d.ts +0 -23
  56. package/dist/tools/audit-document.d.ts.map +0 -1
  57. package/dist/tools/audit-document.js +0 -123
  58. package/dist/tools/audit-document.js.map +0 -1
  59. package/dist/tools/batch-response.d.ts +0 -14
  60. package/dist/tools/batch-response.d.ts.map +0 -1
  61. package/dist/tools/batch-response.js +0 -42
  62. package/dist/tools/batch-response.js.map +0 -1
  63. package/dist/tools/confirm-clarifications.d.ts +0 -15
  64. package/dist/tools/confirm-clarifications.d.ts.map +0 -1
  65. package/dist/tools/confirm-clarifications.js +0 -95
  66. package/dist/tools/confirm-clarifications.js.map +0 -1
  67. package/dist/tools/debug-task.d.ts +0 -13
  68. package/dist/tools/debug-task.d.ts.map +0 -1
  69. package/dist/tools/debug-task.js +0 -63
  70. package/dist/tools/debug-task.js.map +0 -1
  71. package/dist/tools/execute-plan.d.ts +0 -12
  72. package/dist/tools/execute-plan.d.ts.map +0 -1
  73. package/dist/tools/execute-plan.js +0 -123
  74. package/dist/tools/execute-plan.js.map +0 -1
  75. package/dist/tools/review-code.d.ts +0 -17
  76. package/dist/tools/review-code.d.ts.map +0 -1
  77. package/dist/tools/review-code.js +0 -108
  78. package/dist/tools/review-code.js.map +0 -1
  79. package/dist/tools/shared.d.ts +0 -72
  80. package/dist/tools/shared.d.ts.map +0 -1
  81. package/dist/tools/shared.js +0 -160
  82. package/dist/tools/shared.js.map +0 -1
  83. package/dist/tools/truncation.d.ts +0 -18
  84. package/dist/tools/truncation.d.ts.map +0 -1
  85. package/dist/tools/truncation.js +0 -62
  86. package/dist/tools/truncation.js.map +0 -1
  87. package/dist/tools/verify-work.d.ts +0 -12
  88. package/dist/tools/verify-work.d.ts.map +0 -1
  89. package/dist/tools/verify-work.js +0 -85
  90. package/dist/tools/verify-work.js.map +0 -1
@@ -1,95 +0,0 @@
1
- import { z } from 'zod';
2
- import { processConfirmations } from '@zhixuan92/multi-model-agent-core/intake/confirm';
3
- import { runIntakePipeline } from '@zhixuan92/multi-model-agent-core/intake/pipeline';
4
- import { getMaxRoundsPerDraft } from '@zhixuan92/multi-model-agent-core/intake/feature-flag';
5
- import { buildUnifiedResponse, withDiagnostics } from './shared.js';
6
- import { truncateResults } from './truncation.js';
7
- export const confirmClarificationsSchema = z.object({
8
- clarificationId: z.string().describe('ID of the clarification set to resume'),
9
- confirmations: z.record(z.string(), z.object({
10
- prompt: z.string().describe('Confirmed prompt (required)'),
11
- filePaths: z.array(z.string()).optional().describe('Confirmed file scope'),
12
- done: z.string().optional().describe('Confirmed done condition'),
13
- })).describe('Confirmation entries keyed by draftId'),
14
- });
15
- export function registerConfirmClarifications(server, config, logger, clarificationStore, runTasksImpl, rememberBatch) {
16
- server.tool('confirm_clarifications', 'Resume a clarification set by confirming or editing drafted tasks', confirmClarificationsSchema.shape, withDiagnostics('confirm_clarifications', logger, (async (params) => {
17
- const confirmations = new Map(Object.entries(params.confirmations));
18
- const maxRounds = getMaxRoundsPerDraft(config);
19
- const confirmResult = processConfirmations(clarificationStore, params.clarificationId, confirmations, { maxRounds });
20
- if (confirmResult.errors.some(e => e.errorCode === 'clarification_not_found')) {
21
- return {
22
- content: [{
23
- type: 'text',
24
- text: JSON.stringify({
25
- error: confirmResult.errors[0].message,
26
- errorCode: 'clarification_not_found',
27
- }),
28
- }],
29
- isError: true,
30
- };
31
- }
32
- const set = clarificationStore.get(params.clarificationId);
33
- const originalBatchId = set?.originalBatchId ?? '';
34
- const intakeResult = runIntakePipeline(confirmResult.confirmedDrafts, config);
35
- const newBatchId = rememberBatch(intakeResult.ready.length > 0
36
- ? intakeResult.ready.map(r => r.task)
37
- : []);
38
- let results = [];
39
- if (intakeResult.ready.length > 0) {
40
- results = await runTasksImpl(intakeResult.ready.map(r => r.task), config, {});
41
- for (const r of intakeResult.ready) {
42
- clarificationStore.markExecuted(params.clarificationId, r.draftId);
43
- }
44
- }
45
- for (const c of intakeResult.clarifications) {
46
- const storedSet = clarificationStore.get(params.clarificationId);
47
- const stored = storedSet?.drafts.get(c.draftId);
48
- if (stored?.previousReasons) {
49
- const prevSorted = [...stored.previousReasons].sort().join('|');
50
- const newSorted = [...(c.questions || [])].sort().join('|');
51
- if (prevSorted === newSorted) {
52
- confirmResult.errors.push({
53
- draftId: c.draftId,
54
- errorCode: 'draft_refused',
55
- message: `Draft '${c.draftId}' bounced with identical reasons across rounds — unresolvable.`,
56
- });
57
- clarificationStore.removeDraft(params.clarificationId, c.draftId);
58
- intakeResult.clarifications = intakeResult.clarifications.filter(x => x.draftId !== c.draftId);
59
- continue;
60
- }
61
- }
62
- if (stored) {
63
- stored.previousReasons = c.questions || [];
64
- }
65
- clarificationStore.incrementRound(params.clarificationId, c.draftId);
66
- }
67
- clarificationStore.touchForConfirm(params.clarificationId);
68
- intakeResult.intakeProgress.executedDrafts = intakeResult.ready.length;
69
- // Track start time for wall clock measurement
70
- const startMs = Date.now();
71
- clarificationStore.cleanupIfResolved(params.clarificationId);
72
- // Apply same auto-escape truncation as delegate_tasks
73
- const threshold = config.defaults.largeResponseThresholdChars ?? 65_000;
74
- const truncatedResults = truncateResults(results.map(r => ({ status: r.status, output: r.output, filesWritten: r.filesWritten, error: r.error })), newBatchId, threshold);
75
- // Build unified response — only includes remaining clarifications if any
76
- const remainingClarifications = intakeResult.clarifications.length > 0 ? intakeResult.clarifications : undefined;
77
- const remainingClarificationId = intakeResult.clarifications.length > 0 ? params.clarificationId : undefined;
78
- const response = buildUnifiedResponse({
79
- batchId: newBatchId,
80
- results: results.map((r, i) => ({ ...r, output: truncatedResults[i].output })),
81
- tasks: intakeResult.ready.map(r => r.task),
82
- wallClockMs: Date.now() - startMs,
83
- clarificationId: remainingClarificationId,
84
- clarifications: remainingClarifications,
85
- });
86
- const responseObj = {
87
- ...response,
88
- ...(confirmResult.errors.length > 0 ? { confirmationErrors: confirmResult.errors } : {}),
89
- };
90
- return {
91
- content: [{ type: 'text', text: JSON.stringify(responseObj, null, 2) }],
92
- };
93
- })));
94
- }
95
- //# sourceMappingURL=confirm-clarifications.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"confirm-clarifications.js","sourceRoot":"","sources":["../../src/tools/confirm-clarifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,mDAAmD,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uDAAuD,CAAC;AAC7F,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;IAC7E,aAAa,EAAE,CAAC,CAAC,MAAM,CACrB,CAAC,CAAC,MAAM,EAAE,EACV,CAAC,CAAC,MAAM,CAAC;QACP,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;QAC1D,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,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L,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;SACjF,CAAC;IACJ,CAAC,CAAC,CAAC,CACJ,CAAC;AACJ,CAAC"}
@@ -1,13 +0,0 @@
1
- import { z } from 'zod';
2
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
- import type { MultiModelConfig, ContextBlockStore, DiagnosticLogger } from '@zhixuan92/multi-model-agent-core';
4
- export declare const debugTaskSchema: z.ZodObject<{
5
- contextBlockIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
6
- problem: z.ZodString;
7
- context: z.ZodOptional<z.ZodString>;
8
- hypothesis: z.ZodOptional<z.ZodString>;
9
- filePaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
10
- }, z.core.$strip>;
11
- export type DebugTaskParams = z.infer<typeof debugTaskSchema>;
12
- export declare function registerDebugTask(server: McpServer, config: MultiModelConfig, logger: DiagnosticLogger, contextBlockStore?: ContextBlockStore): void;
13
- //# sourceMappingURL=debug-task.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug-task.d.ts","sourceRoot":"","sources":["../../src/tools/debug-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAY,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAYzH,eAAO,MAAM,eAAe;;;;;;iBAS1B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,EAAE,iBAAiB,QAoD7I"}
@@ -1,63 +0,0 @@
1
- import { z } from 'zod';
2
- import { randomUUID } from 'node:crypto';
3
- import { runTasks } from '@zhixuan92/multi-model-agent-core/run-tasks';
4
- import { commonToolFields, buildUnifiedResponse, buildFilePathsPrompt, buildRunTasksOptions, resolveParentModel, autoRegisterContextBlock, withDiagnostics, } from './shared.js';
5
- export const debugTaskSchema = z.object({
6
- problem: z.string().describe('What is broken'),
7
- context: z.string().optional().describe('Background'),
8
- hypothesis: z.string().optional().describe('Initial theory'),
9
- ...commonToolFields,
10
- }).extend({
11
- filePaths: commonToolFields.filePaths.describe('Files the sub-agent should focus on. For debug_task, all provided files are investigated together in a single task.'),
12
- });
13
- export function registerDebugTask(server, config, logger, contextBlockStore) {
14
- server.tool('debug_task', 'Debug a problem with hypothesis-driven investigation. Always single-task. Preset: complex agent, 1 review round.', debugTaskSchema.shape, withDiagnostics('debug_task', logger, (async (params, extra) => {
15
- const runOptions = buildRunTasksOptions(extra);
16
- const parts = [`Debug this problem:\n\n${params.problem}`];
17
- if (params.context)
18
- parts.push(`Context: ${params.context}`);
19
- if (params.hypothesis)
20
- parts.push(`Initial hypothesis: ${params.hypothesis}`);
21
- const fileSection = buildFilePathsPrompt(params.filePaths);
22
- if (fileSection)
23
- parts.push(fileSection);
24
- parts.push('Use hypothesis-driven debugging: identify root cause, propose fix, verify.');
25
- const prompt = parts.join('\n\n');
26
- const taskSpec = {
27
- agentType: 'complex',
28
- reviewPolicy: 'full',
29
- briefQualityPolicy: 'off',
30
- done: 'Identify the root cause with evidence (file, line, mechanism). Propose a fix. Verify the fix resolves the problem.',
31
- maxReviewRounds: 1,
32
- tools: config.defaults?.tools ?? 'full',
33
- timeoutMs: config.defaults?.timeoutMs ?? 1_800_000,
34
- maxCostUSD: config.defaults?.maxCostUSD ?? 10,
35
- sandboxPolicy: config.defaults?.sandboxPolicy ?? 'cwd-only',
36
- cwd: process.cwd(),
37
- contextBlockIds: params.contextBlockIds,
38
- parentModel: resolveParentModel(config),
39
- autoCommit: true,
40
- };
41
- const runtime = contextBlockStore ? { contextBlockStore } : undefined;
42
- const parentModel = taskSpec.parentModel;
43
- try {
44
- const results = await runTasks([{ ...taskSpec, prompt }], config, { ...runOptions, runtime });
45
- const ctxId = autoRegisterContextBlock(results, contextBlockStore);
46
- return buildUnifiedResponse({
47
- batchId: randomUUID(),
48
- results,
49
- tasks: [{ ...taskSpec, prompt }],
50
- wallClockMs: 0,
51
- parentModel,
52
- contextBlockId: ctxId,
53
- });
54
- }
55
- catch (err) {
56
- return {
57
- content: [{ type: 'text', text: `Error: ${err instanceof Error ? err.message : String(err)}` }],
58
- isError: true,
59
- };
60
- }
61
- })));
62
- }
63
- //# sourceMappingURL=debug-task.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug-task.js","sourceRoot":"","sources":["../../src/tools/debug-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAC;AACvE,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;IAC9C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC;IACrD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;IAC5D,GAAG,gBAAgB;CACpB,CAAC,CAAC,MAAM,CAAC;IACR,SAAS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 'zod';
2
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
- import type { MultiModelConfig, ContextBlockStore, DiagnosticLogger } from '@zhixuan92/multi-model-agent-core';
4
- export declare const executePlanSchema: z.ZodObject<{
5
- filePaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
6
- contextBlockIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
7
- tasks: z.ZodArray<z.ZodString>;
8
- context: z.ZodOptional<z.ZodString>;
9
- }, z.core.$strip>;
10
- export type ExecutePlanParams = z.infer<typeof executePlanSchema>;
11
- export declare function registerExecutePlan(server: McpServer, config: MultiModelConfig, logger: DiagnosticLogger, contextBlockStore?: ContextBlockStore): void;
12
- //# sourceMappingURL=execute-plan.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execute-plan.d.ts","sourceRoot":"","sources":["../../src/tools/execute-plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAY,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAWzH,eAAO,MAAM,iBAAiB;;;;;iBAY5B,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AA2BlE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,EAAE,iBAAiB,QAsG/I"}
@@ -1,123 +0,0 @@
1
- import { z } from 'zod';
2
- import { randomUUID } from 'node:crypto';
3
- import { readFile } from 'node:fs/promises';
4
- import { runTasks, extractPlanSection } from '@zhixuan92/multi-model-agent-core/run-tasks';
5
- import { commonToolFields, buildUnifiedResponse, buildRunTasksOptions, resolveParentModel, autoRegisterContextBlock, withDiagnostics, } from './shared.js';
6
- export const executePlanSchema = z.object({
7
- tasks: z.array(z.string().trim().min(1, 'Task descriptor must be non-empty')).min(1, 'At least one task required')
8
- .refine((tasks) => new Set(tasks).size === tasks.length, { message: 'Duplicate task descriptors are not allowed' })
9
- .describe('Descriptive task strings matching plan headings, e.g. "1. Setup database schema". Multiple = parallel.'),
10
- context: z.string().optional()
11
- .describe('Short additional context the plan does not contain, e.g. "Tasks 1-16 are done, files already exist". Injected into the worker prompt.'),
12
- ...commonToolFields,
13
- });
14
- function buildExecutePlanPrompt(fileContents, task, context) {
15
- const parts = [
16
- 'Below are the plan and/or spec documents for this project:',
17
- '',
18
- '---',
19
- fileContents,
20
- '---',
21
- '',
22
- 'Execute the following task from the documents above:',
23
- '',
24
- `Requested task: "${task}"`,
25
- ];
26
- if (context) {
27
- parts.push('', `Additional context: ${context}`);
28
- }
29
- parts.push('', 'Find this task in the plan/spec documents above (not in any preceding context blocks),', 'understand its requirements, and implement it fully.', 'Follow any acceptance criteria, file paths, and constraints specified in the plan.', 'If you cannot find a unique matching task, report that no match was found and do not implement anything.');
30
- return parts.join('\n');
31
- }
32
- export function registerExecutePlan(server, config, logger, contextBlockStore) {
33
- server.tool('execute_plan', 'Execute tasks from a written plan/spec file. Pass task descriptors and file paths — the worker reads the plan, finds the matching task, and implements it. Multiple tasks execute in parallel. Preset: standard agent, full review. Use this when a plan file exists on disk; use delegate_tasks instead when context is inline/ad-hoc with no plan file. Returns contextBlockId in metadata for follow-up calls.', executePlanSchema.shape, withDiagnostics('execute_plan', logger, (async (params, extra) => {
34
- const runOptions = buildRunTasksOptions(extra);
35
- const filePaths = params.filePaths;
36
- const validPaths = (filePaths ?? []).filter(p => p.trim().length > 0);
37
- if (validPaths.length === 0) {
38
- return {
39
- content: [{ type: 'text', text: 'Error: Provide filePaths with at least one plan or spec file' }],
40
- isError: true,
41
- };
42
- }
43
- // Read all plan/spec files
44
- let fileContents;
45
- try {
46
- const contents = await Promise.all(validPaths.map(async (fp) => {
47
- const content = await readFile(fp, 'utf-8');
48
- return `--- ${fp} ---\n${content}`;
49
- }));
50
- fileContents = contents.join('\n\n');
51
- }
52
- catch (err) {
53
- return {
54
- content: [{ type: 'text', text: `Error reading plan files: ${err instanceof Error ? err.message : String(err)}` }],
55
- isError: true,
56
- };
57
- }
58
- const baseTaskSpec = {
59
- agentType: 'standard',
60
- reviewPolicy: 'full',
61
- briefQualityPolicy: 'off',
62
- done: 'Implement the task fully. Report: which task heading you matched, what files were created or modified, and any issues encountered. If no unique matching task was found, report that explicitly and do not implement anything.',
63
- tools: config.defaults?.tools ?? 'full',
64
- timeoutMs: config.defaults?.timeoutMs ?? 1_800_000,
65
- maxCostUSD: config.defaults?.maxCostUSD ?? 10,
66
- sandboxPolicy: config.defaults?.sandboxPolicy ?? 'cwd-only',
67
- cwd: process.cwd(),
68
- contextBlockIds: params.contextBlockIds,
69
- parentModel: resolveParentModel(config),
70
- autoCommit: true,
71
- };
72
- const runtime = contextBlockStore ? { contextBlockStore } : undefined;
73
- const parentModel = baseTaskSpec.parentModel;
74
- try {
75
- const tasks = params.tasks.map(task => ({
76
- ...baseTaskSpec,
77
- prompt: buildExecutePlanPrompt(fileContents, task, params.context),
78
- }));
79
- // Inject plan section context so spec reviewer checks implementation against the plan
80
- for (let i = 0; i < tasks.length; i++) {
81
- const section = await extractPlanSection(validPaths, params.tasks[i], baseTaskSpec.cwd);
82
- if (section) {
83
- tasks[i].planContext = section;
84
- }
85
- }
86
- if (tasks.length === 1) {
87
- const results = await runTasks(tasks, config, { ...runOptions, runtime });
88
- const result = results[0];
89
- if (!result) {
90
- return { content: [{ type: 'text', text: 'Error: task produced no result' }], isError: true };
91
- }
92
- const ctxId = autoRegisterContextBlock(results, contextBlockStore);
93
- return buildUnifiedResponse({
94
- batchId: randomUUID(),
95
- results,
96
- tasks,
97
- wallClockMs: 0,
98
- parentModel,
99
- contextBlockId: ctxId,
100
- });
101
- }
102
- // Multiple tasks = fan out (parallel)
103
- const startMs = Date.now();
104
- const results = await runTasks(tasks, config, { ...runOptions, runtime });
105
- const ctxId = autoRegisterContextBlock(results, contextBlockStore);
106
- return buildUnifiedResponse({
107
- batchId: randomUUID(),
108
- results,
109
- tasks,
110
- wallClockMs: Date.now() - startMs,
111
- parentModel,
112
- contextBlockId: ctxId,
113
- });
114
- }
115
- catch (err) {
116
- return {
117
- content: [{ type: 'text', text: `Error: ${err instanceof Error ? err.message : String(err)}` }],
118
- isError: true,
119
- };
120
- }
121
- })));
122
- }
123
- //# sourceMappingURL=execute-plan.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execute-plan.js","sourceRoot":"","sources":["../../src/tools/execute-plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,KAAK,EAAE,CAAC,CAAC,KAAK,CACZ,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,mCAAmC,CAAC,CAC9D,CAAC,GAAG,CAAC,CAAC,EAAE,4BAA4B,CAAC;SACnC,MAAM,CACL,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,EAC/C,EAAE,OAAO,EAAE,4CAA4C,EAAE,CAC1D;SACA,QAAQ,CAAC,wGAAwG,CAAC;IACrH,OAAO,EAAE,CA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C;gBACD,MAAM,KAAK,GAAG,wBAAwB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;gBACnE,OAAO,oBAAoB,CAAC;oBAC1B,OAAO,EAAE,UAAU,EAAE;oBACrB,OAAO;oBACP,KAAK;oBACL,WAAW,EAAE,CAAC;oBACd,WAAW;oBACX,cAAc,EAAE,KAAK;iBACtB,CAAC,CAAC;YACL,CAAC;YAED,sCAAsC;YACtC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAC3B,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;YAC1E,MAAM,KAAK,GAAG,wBAAwB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;YACnE,OAAO,oBAAoB,CAAC;gBAC1B,OAAO,EAAE,UAAU,EAAE;gBACrB,OAAO;gBACP,KAAK;gBACL,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO;gBACjC,WAAW;gBACX,cAAc,EAAE,KAAK;aACtB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,UAAU,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;gBACxG,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC,CACJ,CAAC;AACJ,CAAC"}
@@ -1,17 +0,0 @@
1
- import { z } from 'zod';
2
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
- import type { MultiModelConfig, ContextBlockStore, DiagnosticLogger } from '@zhixuan92/multi-model-agent-core';
4
- export declare const reviewCodeSchema: z.ZodObject<{
5
- filePaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
6
- contextBlockIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
7
- code: z.ZodOptional<z.ZodString>;
8
- focus: z.ZodOptional<z.ZodArray<z.ZodEnum<{
9
- security: "security";
10
- performance: "performance";
11
- correctness: "correctness";
12
- style: "style";
13
- }>>>;
14
- }, z.core.$strip>;
15
- export type ReviewCodeParams = z.infer<typeof reviewCodeSchema>;
16
- export declare function registerReviewCode(server: McpServer, config: MultiModelConfig, logger: DiagnosticLogger, contextBlockStore?: ContextBlockStore): void;
17
- //# sourceMappingURL=review-code.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"review-code.d.ts","sourceRoot":"","sources":["../../src/tools/review-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAY,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAezH,eAAO,MAAM,gBAAgB;;;;;;;;;;iBAI3B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AA+ChE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,EAAE,iBAAiB,QAyE9I"}
@@ -1,108 +0,0 @@
1
- import { z } from 'zod';
2
- import { randomUUID } from 'node:crypto';
3
- import { runTasks } from '@zhixuan92/multi-model-agent-core/run-tasks';
4
- import { commonToolFields, validateInput, resolveDispatchMode, buildUnifiedResponse, buildFilePathsPrompt, buildPerFilePrompt, buildRunTasksOptions, resolveParentModel, autoRegisterContextBlock, withDiagnostics, } from './shared.js';
5
- export const reviewCodeSchema = z.object({
6
- code: z.string().optional().describe('Inline code to review'),
7
- focus: z.array(z.enum(['security', 'performance', 'correctness', 'style'])).optional(),
8
- ...commonToolFields,
9
- });
10
- const REVIEW_DONE_CONDITIONS = {
11
- security: 'Identify security vulnerabilities with severity, location, and remediation.',
12
- performance: 'Identify performance issues with impact level, location, and fix recommendation.',
13
- correctness: 'Identify logic errors, edge cases, and contract violations with severity and location.',
14
- style: 'Identify style issues, naming inconsistencies, and dead code with location and fix.',
15
- };
16
- const DELTA_REVIEW_SUFFIX = ' Perform a full review (do not reduce thoroughness). Verify each prior finding as addressed or unaddressed. Omit addressed prior findings. Include unaddressed prior findings and new findings. End with a summary of which prior findings were resolved.';
17
- function resolveReviewDoneCondition(focus, hasContextBlocks) {
18
- let base;
19
- if (!focus || focus.length === 0) {
20
- base = 'Review code for correctness, security, performance, and style. Each finding has category, severity, location, and recommendation.';
21
- }
22
- else {
23
- base = focus.map(f => REVIEW_DONE_CONDITIONS[f] ?? '').filter(Boolean).join(' ');
24
- }
25
- return hasContextBlocks ? base + DELTA_REVIEW_SUFFIX : base;
26
- }
27
- function buildReviewPrompt(code, filePaths, focus, hasContextBlocks) {
28
- const parts = ['Review this code:'];
29
- if (code)
30
- parts.push(`\`\`\`\n${code}\n\`\`\``);
31
- const fileSection = buildFilePathsPrompt(filePaths);
32
- if (fileSection)
33
- parts.push(fileSection);
34
- if (focus && focus.length > 0)
35
- parts.push(`Focus areas: ${focus.join(', ')}.`);
36
- if (hasContextBlocks) {
37
- parts.push('Context is provided above (e.g. a diff or prior review). Perform a full review as normal — do not skip areas or reduce thoroughness.', 'If the context contains prior review findings:', '- **Omit** findings that have been addressed — do not re-report them.', '- **Include** findings that are still present (mark as "unfixed from prior review").', '- **Include** any new findings.', '- End with a **Fixed** summary listing which prior findings were resolved.');
38
- }
39
- else {
40
- parts.push('Provide a structured review with findings and recommendations.');
41
- }
42
- return parts.join('\n\n');
43
- }
44
- export function registerReviewCode(server, config, logger, contextBlockStore) {
45
- server.tool('review_code', 'Review code with full quality pipeline. Accepts inline code or file paths (multiple files review in parallel). Preset: complex agent, full review. For diff-scoped reviews, register the git diff or prior review as a context block and pass its id in contextBlockIds — the tool automatically focuses on changes relative to that context.', reviewCodeSchema.shape, withDiagnostics('review_code', logger, (async (params, extra) => {
46
- const runOptions = buildRunTasksOptions(extra);
47
- const validation = validateInput(params.code, params.filePaths);
48
- if (!validation.valid) {
49
- return { content: [{ type: 'text', text: `Error: ${validation.message}` }], isError: true };
50
- }
51
- const hasContextBlocks = Array.isArray(params.contextBlockIds) && params.contextBlockIds.length > 0;
52
- const baseTaskSpec = {
53
- agentType: 'complex',
54
- reviewPolicy: 'full',
55
- briefQualityPolicy: 'off',
56
- done: resolveReviewDoneCondition(params.focus, hasContextBlocks),
57
- tools: config.defaults?.tools ?? 'full',
58
- timeoutMs: config.defaults?.timeoutMs ?? 1_800_000,
59
- maxCostUSD: config.defaults?.maxCostUSD ?? 10,
60
- sandboxPolicy: config.defaults?.sandboxPolicy ?? 'cwd-only',
61
- cwd: process.cwd(),
62
- contextBlockIds: params.contextBlockIds,
63
- parentModel: resolveParentModel(config),
64
- };
65
- const runtime = contextBlockStore ? { contextBlockStore } : undefined;
66
- const parentModel = baseTaskSpec.parentModel;
67
- try {
68
- const mode = resolveDispatchMode(params.code, params.filePaths);
69
- if (mode === 'fan_out') {
70
- const validPaths = params.filePaths.filter(p => p.trim().length > 0);
71
- const promptTemplate = buildReviewPrompt(undefined, undefined, params.focus, hasContextBlocks);
72
- const tasks = validPaths.map(fp => ({
73
- ...baseTaskSpec,
74
- prompt: buildPerFilePrompt(fp, promptTemplate),
75
- }));
76
- const startMs = Date.now();
77
- const results = await runTasks(tasks, config, { ...runOptions, runtime });
78
- const ctxId = autoRegisterContextBlock(results, contextBlockStore);
79
- return buildUnifiedResponse({
80
- batchId: randomUUID(),
81
- results,
82
- tasks,
83
- wallClockMs: Date.now() - startMs,
84
- parentModel,
85
- contextBlockId: ctxId,
86
- });
87
- }
88
- const prompt = buildReviewPrompt(params.code, params.filePaths, params.focus, hasContextBlocks);
89
- const results = await runTasks([{ ...baseTaskSpec, prompt }], config, { ...runOptions, runtime });
90
- const ctxId = autoRegisterContextBlock(results, contextBlockStore);
91
- return buildUnifiedResponse({
92
- batchId: randomUUID(),
93
- results,
94
- tasks: [{ ...baseTaskSpec, prompt }],
95
- wallClockMs: 0,
96
- parentModel,
97
- contextBlockId: ctxId,
98
- });
99
- }
100
- catch (err) {
101
- return {
102
- content: [{ type: 'text', text: `Error: ${err instanceof Error ? err.message : String(err)}` }],
103
- isError: true,
104
- };
105
- }
106
- })));
107
- }
108
- //# sourceMappingURL=review-code.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"review-code.js","sourceRoot":"","sources":["../../src/tools/review-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAC;AACvE,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IAC7D,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACtF,GAAG,gBAAgB;CACpB,CAAC,CAAC;AAIH,MAAM,sBAAsB,GAA2B;IACrD,QAAQ,EAAE,6EAA6E;IACvF,WAAW,EAAE,kFAAkF;IAC/F,WAAW,EAAE,wF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U,EAAE;oBACrB,OAAO;oBACP,KAAK;oBACL,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO;oBACjC,WAAW;oBACX,cAAc,EAAE,KAAK;iBACtB,CAAC,CAAC;YACL,CAAC;YAED,MAAM,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;YAChG,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,CAAC,EAAE,GAAG,YAAY,EAAE,MAAM,EAAc,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;YAC9G,MAAM,KAAK,GAAG,wBAAwB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;YACnE,OAAO,oBAAoB,CAAC;gBAC1B,OAAO,EAAE,UAAU,EAAE;gBACrB,OAAO;gBACP,KAAK,EAAE,CAAC,EAAE,GAAG,YAAY,EAAE,MAAM,EAAc,CAAC;gBAChD,WAAW,EAAE,CAAC;gBACd,WAAW;gBACX,cAAc,EAAE,KAAK;aACtB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,UAAU,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;gBACxG,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC,CACJ,CAAC;AACJ,CAAC"}
@@ -1,72 +0,0 @@
1
- import { z } from 'zod';
2
- import type { RunResult, MultiModelConfig, ContextBlockStore, TaskSpec, DiagnosticLogger } from '@zhixuan92/multi-model-agent-core';
3
- import type { ClarificationEntry } from '@zhixuan92/multi-model-agent-core/intake/types';
4
- import type { RunTasksOptions } from '@zhixuan92/multi-model-agent-core/run-tasks';
5
- export declare const commonToolFields: {
6
- filePaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
7
- contextBlockIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
8
- };
9
- export declare function validateInput(inlineContent: string | undefined, filePaths: string[] | undefined): {
10
- valid: true;
11
- } | {
12
- valid: false;
13
- message: string;
14
- };
15
- export declare function resolveDispatchMode(inlineContent: string | undefined, filePaths: string[] | undefined): 'single' | 'fan_out';
16
- /**
17
- * Auto-register task output(s) as a context block so callers can reference
18
- * the result in follow-up calls (e.g. round 2 of an audit) without manually
19
- * calling register_context_block. Diagnostic outputs are excluded.
20
- */
21
- export declare function autoRegisterContextBlock(results: RunResult[], store: ContextBlockStore | undefined): string | undefined;
22
- export declare function resolveParentModel(config: MultiModelConfig): string | undefined;
23
- export declare function buildFilePathsPrompt(filePaths?: string[]): string;
24
- export declare function buildPerFilePrompt(filePath: string, promptTemplate: string): string;
25
- export declare function buildRunTasksOptions(extra: {
26
- _meta?: Record<string, unknown>;
27
- sendNotification: (...args: any[]) => Promise<void>;
28
- } | undefined): RunTasksOptions;
29
- /**
30
- * Wrap an MCP tool handler so every call is recorded as request_start and
31
- * request_complete in the DiagnosticLogger. The start event is emitted before
32
- * the tool handler runs. The completion event is emitted on both success and
33
- * throw; thrown handlers record status:"error" with responseBytes:0.
34
- */
35
- export declare function withDiagnostics<Args extends unknown[], R>(tool: string, logger: DiagnosticLogger, handler: (...args: Args) => Promise<R>): (...args: Args) => Promise<R>;
36
- /**
37
- * Input interface for buildUnifiedResponse.
38
- */
39
- export interface BuildUnifiedResponseInput {
40
- batchId: string;
41
- results: RunResult[];
42
- tasks: TaskSpec[];
43
- wallClockMs: number;
44
- parentModel?: string;
45
- contextBlockId?: string;
46
- clarificationId?: string;
47
- clarifications?: ClarificationEntry[];
48
- }
49
- export interface UnifiedResponse {
50
- headline: string;
51
- batchId: string;
52
- contextBlockId?: string;
53
- clarificationId?: string;
54
- clarifications?: ClarificationEntry[];
55
- results: {
56
- status: RunResult['status'];
57
- output: string;
58
- filesWritten: string[];
59
- error?: string;
60
- }[];
61
- }
62
- /**
63
- * Build a unified MCP response envelope for delegate_tasks / clarification flows.
64
- * Strips noisy internal fields (escalationLog, usage, turns, agents, models).
65
- */
66
- export declare function buildUnifiedResponse(input: BuildUnifiedResponseInput): {
67
- content: {
68
- type: 'text';
69
- text: string;
70
- }[];
71
- };
72
- //# sourceMappingURL=shared.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/tools/shared.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,gBAAgB,EACjB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAEzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAInF,eAAO,MAAM,gBAAgB;;;CAK5B,CAAC;AAUF,wBAAgB,aAAa,CAC3B,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,GAC9B;IAAE,KAAK,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAKrD;AAED,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,GAC9B,QAAQ,GAAG,SAAS,CAKtB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,SAAS,EAAE,EACpB,KAAK,EAAE,iBAAiB,GAAG,SAAS,GACnC,MAAM,GAAG,SAAS,CAOpB;AAED,wBAAgB,kBA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