@monoes/monomindcli 2.7.12 → 2.7.14
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/.claude/commands/mastermind/createorg.md +2 -0
- package/.claude/commands/mastermind/okf-import.md +6 -1
- package/.claude/helpers/handlers/route-handler.cjs +40 -7
- package/.claude/helpers/handlers/session-restore-handler.cjs +24 -6
- package/.claude/skills/mastermind-createorg/SKILL.md +11 -4
- package/README.md +12 -6
- package/dist/src/capabilities/index.d.ts.map +1 -1
- package/dist/src/capabilities/index.js +17 -0
- package/dist/src/capabilities/index.js.map +1 -1
- package/dist/src/capabilities/types.d.ts +0 -11
- package/dist/src/capabilities/types.d.ts.map +1 -1
- package/dist/src/commands/doc.d.ts.map +1 -1
- package/dist/src/commands/doc.js +251 -8
- package/dist/src/commands/doc.js.map +1 -1
- package/dist/src/commands/doctor-project-checks.d.ts +25 -3
- package/dist/src/commands/doctor-project-checks.d.ts.map +1 -1
- package/dist/src/commands/doctor-project-checks.js +111 -8
- package/dist/src/commands/doctor-project-checks.js.map +1 -1
- package/dist/src/commands/doctor.d.ts.map +1 -1
- package/dist/src/commands/doctor.js +18 -2
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +32 -3
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/monograph.d.ts.map +1 -1
- package/dist/src/commands/monograph.js +26 -3
- package/dist/src/commands/monograph.js.map +1 -1
- package/dist/src/commands/org.d.ts +15 -0
- package/dist/src/commands/org.d.ts.map +1 -1
- package/dist/src/commands/org.js +251 -6
- package/dist/src/commands/org.js.map +1 -1
- package/dist/src/init/claudemd-generator.d.ts.map +1 -1
- package/dist/src/init/claudemd-generator.js +4 -1
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/knowledge/document-pipeline.d.ts +77 -4
- package/dist/src/knowledge/document-pipeline.d.ts.map +1 -1
- package/dist/src/knowledge/document-pipeline.js +261 -15
- package/dist/src/knowledge/document-pipeline.js.map +1 -1
- package/dist/src/knowledge/eval/corpus.d.ts +56 -0
- package/dist/src/knowledge/eval/corpus.d.ts.map +1 -0
- package/dist/src/knowledge/eval/corpus.js +126 -0
- package/dist/src/knowledge/eval/corpus.js.map +1 -0
- package/dist/src/knowledge/eval/golden-set.d.ts +62 -0
- package/dist/src/knowledge/eval/golden-set.d.ts.map +1 -0
- package/dist/src/knowledge/eval/golden-set.js +331 -0
- package/dist/src/knowledge/eval/golden-set.js.map +1 -0
- package/dist/src/knowledge/eval/harness.d.ts +221 -0
- package/dist/src/knowledge/eval/harness.d.ts.map +1 -0
- package/dist/src/knowledge/eval/harness.js +610 -0
- package/dist/src/knowledge/eval/harness.js.map +1 -0
- package/dist/src/knowledge/eval/metrics.d.ts +120 -0
- package/dist/src/knowledge/eval/metrics.d.ts.map +1 -0
- package/dist/src/knowledge/eval/metrics.js +243 -0
- package/dist/src/knowledge/eval/metrics.js.map +1 -0
- package/dist/src/knowledge/eval/model-presence.d.ts +48 -0
- package/dist/src/knowledge/eval/model-presence.d.ts.map +1 -0
- package/dist/src/knowledge/eval/model-presence.js +128 -0
- package/dist/src/knowledge/eval/model-presence.js.map +1 -0
- package/dist/src/knowledge/eval/network-guard.d.ts +46 -0
- package/dist/src/knowledge/eval/network-guard.d.ts.map +1 -0
- package/dist/src/knowledge/eval/network-guard.js +112 -0
- package/dist/src/knowledge/eval/network-guard.js.map +1 -0
- package/dist/src/knowledge/eval/retrievers.d.ts +65 -0
- package/dist/src/knowledge/eval/retrievers.d.ts.map +1 -0
- package/dist/src/knowledge/eval/retrievers.js +180 -0
- package/dist/src/knowledge/eval/retrievers.js.map +1 -0
- package/dist/src/knowledge/eval/signals.d.ts +111 -0
- package/dist/src/knowledge/eval/signals.d.ts.map +1 -0
- package/dist/src/knowledge/eval/signals.js +232 -0
- package/dist/src/knowledge/eval/signals.js.map +1 -0
- package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +7 -34
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/knowledge-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/knowledge-tools.js +88 -6
- package/dist/src/mcp-tools/knowledge-tools.js.map +1 -1
- package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.d.ts +44 -144
- package/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.d.ts.map +1 -1
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts +30 -38
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts.map +1 -1
- package/dist/src/mcp-tools/task-tools.d.ts +1 -0
- package/dist/src/mcp-tools/task-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/task-tools.js +76 -111
- package/dist/src/mcp-tools/task-tools.js.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.js +3 -28
- package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
- package/dist/src/memory/bm25-index.d.ts +137 -0
- package/dist/src/memory/bm25-index.d.ts.map +1 -0
- package/dist/src/memory/bm25-index.js +219 -0
- package/dist/src/memory/bm25-index.js.map +1 -0
- package/dist/src/memory/embedding-operations.d.ts.map +1 -1
- package/dist/src/memory/embedding-operations.js +8 -7
- package/dist/src/memory/embedding-operations.js.map +1 -1
- package/dist/src/memory/ewc-consolidation.d.ts.map +1 -1
- package/dist/src/memory/ewc-consolidation.js +2 -1
- package/dist/src/memory/ewc-consolidation.js.map +1 -1
- package/dist/src/memory/hnsw-operations.d.ts.map +1 -1
- package/dist/src/memory/hnsw-operations.js +4 -3
- package/dist/src/memory/hnsw-operations.js.map +1 -1
- package/dist/src/memory/intelligence.d.ts.map +1 -1
- package/dist/src/memory/intelligence.js +2 -1
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.d.ts +34 -0
- package/dist/src/memory/memory-bridge.d.ts.map +1 -1
- package/dist/src/memory/memory-bridge.js +184 -26
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/memory-initializer.d.ts.map +1 -1
- package/dist/src/memory/memory-initializer.js +4 -3
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/memory-schema.d.ts +1 -1
- package/dist/src/memory/memory-schema.js +1 -1
- package/dist/src/memory/text-tokens.d.ts +10 -0
- package/dist/src/memory/text-tokens.d.ts.map +1 -0
- package/dist/src/memory/text-tokens.js +37 -0
- package/dist/src/memory/text-tokens.js.map +1 -0
- package/dist/src/orgrt/daemon.d.ts +16 -1
- package/dist/src/orgrt/daemon.d.ts.map +1 -1
- package/dist/src/orgrt/daemon.js +65 -9
- package/dist/src/orgrt/daemon.js.map +1 -1
- package/dist/src/orgrt/scheduler.d.ts +14 -1
- package/dist/src/orgrt/scheduler.d.ts.map +1 -1
- package/dist/src/orgrt/scheduler.js +51 -5
- package/dist/src/orgrt/scheduler.js.map +1 -1
- package/dist/src/orgrt/session.js +12 -0
- package/dist/src/orgrt/session.js.map +1 -1
- package/dist/src/orgrt/types.d.ts +61 -831
- package/dist/src/orgrt/types.d.ts.map +1 -1
- package/dist/src/orgrt/types.js +7 -1
- package/dist/src/orgrt/types.js.map +1 -1
- package/dist/src/services/crash-reporter.d.ts.map +1 -1
- package/dist/src/services/crash-reporter.js +7 -0
- package/dist/src/services/crash-reporter.js.map +1 -1
- package/dist/src/ui/dashboard.html +57 -25
- package/dist/src/ui/orgs.html +30 -13
- package/dist/src/ui/routes-monograph.mjs +929 -0
- package/dist/src/ui/routes-org.mjs +2513 -0
- package/dist/src/ui/server.mjs +726 -4117
- package/dist/src/utils/json-file.d.ts +11 -0
- package/dist/src/utils/json-file.d.ts.map +1 -1
- package/dist/src/utils/json-file.js +27 -0
- package/dist/src/utils/json-file.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -6
|
@@ -8,25 +8,24 @@ import { z } from 'zod';
|
|
|
8
8
|
export declare const PrioritizeGapsInputSchema: z.ZodObject<{
|
|
9
9
|
gaps: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
10
10
|
id: z.ZodString;
|
|
11
|
-
type: z.ZodEnum<
|
|
11
|
+
type: z.ZodEnum<{
|
|
12
|
+
branch: "branch";
|
|
13
|
+
function: "function";
|
|
14
|
+
line: "line";
|
|
15
|
+
}>;
|
|
12
16
|
file: z.ZodString;
|
|
13
17
|
startLine: z.ZodNumber;
|
|
14
18
|
endLine: z.ZodNumber;
|
|
15
|
-
},
|
|
16
|
-
id: string;
|
|
17
|
-
type: "branch" | "function" | "line";
|
|
18
|
-
file: string;
|
|
19
|
-
startLine: number;
|
|
20
|
-
endLine: number;
|
|
21
|
-
}, {
|
|
22
|
-
id: string;
|
|
23
|
-
type: "branch" | "function" | "line";
|
|
24
|
-
file: string;
|
|
25
|
-
startLine: number;
|
|
26
|
-
endLine: number;
|
|
27
|
-
}>, "many">>;
|
|
19
|
+
}, z.core.$strip>>>;
|
|
28
20
|
targetPath: z.ZodOptional<z.ZodString>;
|
|
29
|
-
factors: z.ZodDefault<z.ZodArray<z.ZodEnum<
|
|
21
|
+
factors: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
22
|
+
"business-critical": "business-critical";
|
|
23
|
+
"change-frequency": "change-frequency";
|
|
24
|
+
complexity: "complexity";
|
|
25
|
+
"defect-history": "defect-history";
|
|
26
|
+
"dependency-count": "dependency-count";
|
|
27
|
+
"test-difficulty": "test-difficulty";
|
|
28
|
+
}>>>;
|
|
30
29
|
weights: z.ZodOptional<z.ZodObject<{
|
|
31
30
|
complexity: z.ZodDefault<z.ZodNumber>;
|
|
32
31
|
changeFrequency: z.ZodDefault<z.ZodNumber>;
|
|
@@ -34,64 +33,15 @@ export declare const PrioritizeGapsInputSchema: z.ZodObject<{
|
|
|
34
33
|
businessCritical: z.ZodDefault<z.ZodNumber>;
|
|
35
34
|
dependencyCount: z.ZodDefault<z.ZodNumber>;
|
|
36
35
|
testDifficulty: z.ZodDefault<z.ZodNumber>;
|
|
37
|
-
},
|
|
38
|
-
complexity: number;
|
|
39
|
-
changeFrequency: number;
|
|
40
|
-
defectHistory: number;
|
|
41
|
-
businessCritical: number;
|
|
42
|
-
dependencyCount: number;
|
|
43
|
-
testDifficulty: number;
|
|
44
|
-
}, {
|
|
45
|
-
complexity?: number | undefined;
|
|
46
|
-
changeFrequency?: number | undefined;
|
|
47
|
-
defectHistory?: number | undefined;
|
|
48
|
-
businessCritical?: number | undefined;
|
|
49
|
-
dependencyCount?: number | undefined;
|
|
50
|
-
testDifficulty?: number | undefined;
|
|
51
|
-
}>>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
52
37
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
53
|
-
groupBy: z.ZodDefault<z.ZodEnum<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
type: "
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
endLine: number;
|
|
61
|
-
}[] | undefined;
|
|
62
|
-
targetPath?: string | undefined;
|
|
63
|
-
factors: ("business-critical" | "change-frequency" | "complexity" | "defect-history" | "dependency-count" | "test-difficulty")[];
|
|
64
|
-
weights?: {
|
|
65
|
-
complexity: number;
|
|
66
|
-
changeFrequency: number;
|
|
67
|
-
defectHistory: number;
|
|
68
|
-
businessCritical: number;
|
|
69
|
-
dependencyCount: number;
|
|
70
|
-
testDifficulty: number;
|
|
71
|
-
} | undefined;
|
|
72
|
-
limit: number;
|
|
73
|
-
groupBy: "file" | "none" | "risk" | "type";
|
|
74
|
-
}, {
|
|
75
|
-
gaps?: {
|
|
76
|
-
id: string;
|
|
77
|
-
type: "branch" | "function" | "line";
|
|
78
|
-
file: string;
|
|
79
|
-
startLine: number;
|
|
80
|
-
endLine: number;
|
|
81
|
-
}[] | undefined;
|
|
82
|
-
targetPath?: string | undefined;
|
|
83
|
-
factors?: ("business-critical" | "change-frequency" | "complexity" | "defect-history" | "dependency-count" | "test-difficulty")[] | undefined;
|
|
84
|
-
weights?: {
|
|
85
|
-
complexity?: number | undefined;
|
|
86
|
-
changeFrequency?: number | undefined;
|
|
87
|
-
defectHistory?: number | undefined;
|
|
88
|
-
businessCritical?: number | undefined;
|
|
89
|
-
dependencyCount?: number | undefined;
|
|
90
|
-
testDifficulty?: number | undefined;
|
|
91
|
-
} | undefined;
|
|
92
|
-
limit?: number | undefined;
|
|
93
|
-
groupBy?: "file" | "none" | "risk" | "type" | undefined;
|
|
94
|
-
}>;
|
|
38
|
+
groupBy: z.ZodDefault<z.ZodEnum<{
|
|
39
|
+
file: "file";
|
|
40
|
+
none: "none";
|
|
41
|
+
risk: "risk";
|
|
42
|
+
type: "type";
|
|
43
|
+
}>>;
|
|
44
|
+
}, z.core.$strip>;
|
|
95
45
|
export type PrioritizeGapsInput = z.infer<typeof PrioritizeGapsInputSchema>;
|
|
96
46
|
export interface PrioritizeGapsOutput {
|
|
97
47
|
success: boolean;
|
|
@@ -171,25 +121,24 @@ export declare const toolDefinition: {
|
|
|
171
121
|
inputSchema: z.ZodObject<{
|
|
172
122
|
gaps: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
173
123
|
id: z.ZodString;
|
|
174
|
-
type: z.ZodEnum<
|
|
124
|
+
type: z.ZodEnum<{
|
|
125
|
+
branch: "branch";
|
|
126
|
+
function: "function";
|
|
127
|
+
line: "line";
|
|
128
|
+
}>;
|
|
175
129
|
file: z.ZodString;
|
|
176
130
|
startLine: z.ZodNumber;
|
|
177
131
|
endLine: z.ZodNumber;
|
|
178
|
-
},
|
|
179
|
-
id: string;
|
|
180
|
-
type: "branch" | "function" | "line";
|
|
181
|
-
file: string;
|
|
182
|
-
startLine: number;
|
|
183
|
-
endLine: number;
|
|
184
|
-
}, {
|
|
185
|
-
id: string;
|
|
186
|
-
type: "branch" | "function" | "line";
|
|
187
|
-
file: string;
|
|
188
|
-
startLine: number;
|
|
189
|
-
endLine: number;
|
|
190
|
-
}>, "many">>;
|
|
132
|
+
}, z.core.$strip>>>;
|
|
191
133
|
targetPath: z.ZodOptional<z.ZodString>;
|
|
192
|
-
factors: z.ZodDefault<z.ZodArray<z.ZodEnum<
|
|
134
|
+
factors: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
135
|
+
"business-critical": "business-critical";
|
|
136
|
+
"change-frequency": "change-frequency";
|
|
137
|
+
complexity: "complexity";
|
|
138
|
+
"defect-history": "defect-history";
|
|
139
|
+
"dependency-count": "dependency-count";
|
|
140
|
+
"test-difficulty": "test-difficulty";
|
|
141
|
+
}>>>;
|
|
193
142
|
weights: z.ZodOptional<z.ZodObject<{
|
|
194
143
|
complexity: z.ZodDefault<z.ZodNumber>;
|
|
195
144
|
changeFrequency: z.ZodDefault<z.ZodNumber>;
|
|
@@ -197,64 +146,15 @@ export declare const toolDefinition: {
|
|
|
197
146
|
businessCritical: z.ZodDefault<z.ZodNumber>;
|
|
198
147
|
dependencyCount: z.ZodDefault<z.ZodNumber>;
|
|
199
148
|
testDifficulty: z.ZodDefault<z.ZodNumber>;
|
|
200
|
-
},
|
|
201
|
-
complexity: number;
|
|
202
|
-
changeFrequency: number;
|
|
203
|
-
defectHistory: number;
|
|
204
|
-
businessCritical: number;
|
|
205
|
-
dependencyCount: number;
|
|
206
|
-
testDifficulty: number;
|
|
207
|
-
}, {
|
|
208
|
-
complexity?: number | undefined;
|
|
209
|
-
changeFrequency?: number | undefined;
|
|
210
|
-
defectHistory?: number | undefined;
|
|
211
|
-
businessCritical?: number | undefined;
|
|
212
|
-
dependencyCount?: number | undefined;
|
|
213
|
-
testDifficulty?: number | undefined;
|
|
214
|
-
}>>;
|
|
149
|
+
}, z.core.$strip>>;
|
|
215
150
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
216
|
-
groupBy: z.ZodDefault<z.ZodEnum<
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
type: "
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
endLine: number;
|
|
224
|
-
}[] | undefined;
|
|
225
|
-
targetPath?: string | undefined;
|
|
226
|
-
factors: ("business-critical" | "change-frequency" | "complexity" | "defect-history" | "dependency-count" | "test-difficulty")[];
|
|
227
|
-
weights?: {
|
|
228
|
-
complexity: number;
|
|
229
|
-
changeFrequency: number;
|
|
230
|
-
defectHistory: number;
|
|
231
|
-
businessCritical: number;
|
|
232
|
-
dependencyCount: number;
|
|
233
|
-
testDifficulty: number;
|
|
234
|
-
} | undefined;
|
|
235
|
-
limit: number;
|
|
236
|
-
groupBy: "file" | "none" | "risk" | "type";
|
|
237
|
-
}, {
|
|
238
|
-
gaps?: {
|
|
239
|
-
id: string;
|
|
240
|
-
type: "branch" | "function" | "line";
|
|
241
|
-
file: string;
|
|
242
|
-
startLine: number;
|
|
243
|
-
endLine: number;
|
|
244
|
-
}[] | undefined;
|
|
245
|
-
targetPath?: string | undefined;
|
|
246
|
-
factors?: ("business-critical" | "change-frequency" | "complexity" | "defect-history" | "dependency-count" | "test-difficulty")[] | undefined;
|
|
247
|
-
weights?: {
|
|
248
|
-
complexity?: number | undefined;
|
|
249
|
-
changeFrequency?: number | undefined;
|
|
250
|
-
defectHistory?: number | undefined;
|
|
251
|
-
businessCritical?: number | undefined;
|
|
252
|
-
dependencyCount?: number | undefined;
|
|
253
|
-
testDifficulty?: number | undefined;
|
|
254
|
-
} | undefined;
|
|
255
|
-
limit?: number | undefined;
|
|
256
|
-
groupBy?: "file" | "none" | "risk" | "type" | undefined;
|
|
257
|
-
}>;
|
|
151
|
+
groupBy: z.ZodDefault<z.ZodEnum<{
|
|
152
|
+
file: "file";
|
|
153
|
+
none: "none";
|
|
154
|
+
risk: "risk";
|
|
155
|
+
type: "type";
|
|
156
|
+
}>>;
|
|
157
|
+
}, z.core.$strip>;
|
|
258
158
|
handler: typeof handler;
|
|
259
159
|
};
|
|
260
160
|
export default toolDefinition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prioritize-gaps.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-tools/quality/coverage-analysis/prioritize-gaps.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,yBAAyB
|
|
1
|
+
{"version":3,"file":"prioritize-gaps.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-tools/quality/coverage-analysis/prioritize-gaps.ts"],"names":[],"mappings":"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"}
|
|
@@ -7,29 +7,25 @@
|
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
export declare const DetectSecretsInputSchema: z.ZodObject<{
|
|
9
9
|
targetPath: z.ZodString;
|
|
10
|
-
secretTypes: z.ZodDefault<z.ZodArray<z.ZodEnum<
|
|
11
|
-
|
|
10
|
+
secretTypes: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
11
|
+
"api-key": "api-key";
|
|
12
|
+
"aws-key": "aws-key";
|
|
13
|
+
"aws-secret": "aws-secret";
|
|
14
|
+
"azure-key": "azure-key";
|
|
15
|
+
certificate: "certificate";
|
|
16
|
+
"connection-string": "connection-string";
|
|
17
|
+
"gcp-key": "gcp-key";
|
|
18
|
+
generic: "generic";
|
|
19
|
+
password: "password";
|
|
20
|
+
"private-key": "private-key";
|
|
21
|
+
token: "token";
|
|
22
|
+
}>>>;
|
|
23
|
+
excludePatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
12
24
|
includeEntropy: z.ZodDefault<z.ZodBoolean>;
|
|
13
25
|
entropyThreshold: z.ZodDefault<z.ZodNumber>;
|
|
14
26
|
verifySecrets: z.ZodDefault<z.ZodBoolean>;
|
|
15
27
|
scanHistory: z.ZodDefault<z.ZodBoolean>;
|
|
16
|
-
},
|
|
17
|
-
targetPath: string;
|
|
18
|
-
secretTypes: ("api-key" | "aws-key" | "aws-secret" | "azure-key" | "certificate" | "connection-string" | "gcp-key" | "generic" | "password" | "private-key" | "token")[];
|
|
19
|
-
excludePatterns: string[];
|
|
20
|
-
includeEntropy: boolean;
|
|
21
|
-
entropyThreshold: number;
|
|
22
|
-
verifySecrets: boolean;
|
|
23
|
-
scanHistory: boolean;
|
|
24
|
-
}, {
|
|
25
|
-
targetPath: string;
|
|
26
|
-
secretTypes?: ("api-key" | "aws-key" | "aws-secret" | "azure-key" | "certificate" | "connection-string" | "gcp-key" | "generic" | "password" | "private-key" | "token")[] | undefined;
|
|
27
|
-
excludePatterns?: string[] | undefined;
|
|
28
|
-
includeEntropy?: boolean | undefined;
|
|
29
|
-
entropyThreshold?: number | undefined;
|
|
30
|
-
verifySecrets?: boolean | undefined;
|
|
31
|
-
scanHistory?: boolean | undefined;
|
|
32
|
-
}>;
|
|
28
|
+
}, z.core.$strip>;
|
|
33
29
|
export type DetectSecretsInput = z.infer<typeof DetectSecretsInputSchema>;
|
|
34
30
|
export interface DetectSecretsOutput {
|
|
35
31
|
success: boolean;
|
|
@@ -108,29 +104,25 @@ export declare const toolDefinition: {
|
|
|
108
104
|
version: string;
|
|
109
105
|
inputSchema: z.ZodObject<{
|
|
110
106
|
targetPath: z.ZodString;
|
|
111
|
-
secretTypes: z.ZodDefault<z.ZodArray<z.ZodEnum<
|
|
112
|
-
|
|
107
|
+
secretTypes: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
108
|
+
"api-key": "api-key";
|
|
109
|
+
"aws-key": "aws-key";
|
|
110
|
+
"aws-secret": "aws-secret";
|
|
111
|
+
"azure-key": "azure-key";
|
|
112
|
+
certificate: "certificate";
|
|
113
|
+
"connection-string": "connection-string";
|
|
114
|
+
"gcp-key": "gcp-key";
|
|
115
|
+
generic: "generic";
|
|
116
|
+
password: "password";
|
|
117
|
+
"private-key": "private-key";
|
|
118
|
+
token: "token";
|
|
119
|
+
}>>>;
|
|
120
|
+
excludePatterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
113
121
|
includeEntropy: z.ZodDefault<z.ZodBoolean>;
|
|
114
122
|
entropyThreshold: z.ZodDefault<z.ZodNumber>;
|
|
115
123
|
verifySecrets: z.ZodDefault<z.ZodBoolean>;
|
|
116
124
|
scanHistory: z.ZodDefault<z.ZodBoolean>;
|
|
117
|
-
},
|
|
118
|
-
targetPath: string;
|
|
119
|
-
secretTypes: ("api-key" | "aws-key" | "aws-secret" | "azure-key" | "certificate" | "connection-string" | "gcp-key" | "generic" | "password" | "private-key" | "token")[];
|
|
120
|
-
excludePatterns: string[];
|
|
121
|
-
includeEntropy: boolean;
|
|
122
|
-
entropyThreshold: number;
|
|
123
|
-
verifySecrets: boolean;
|
|
124
|
-
scanHistory: boolean;
|
|
125
|
-
}, {
|
|
126
|
-
targetPath: string;
|
|
127
|
-
secretTypes?: ("api-key" | "aws-key" | "aws-secret" | "azure-key" | "certificate" | "connection-string" | "gcp-key" | "generic" | "password" | "private-key" | "token")[] | undefined;
|
|
128
|
-
excludePatterns?: string[] | undefined;
|
|
129
|
-
includeEntropy?: boolean | undefined;
|
|
130
|
-
entropyThreshold?: number | undefined;
|
|
131
|
-
verifySecrets?: boolean | undefined;
|
|
132
|
-
scanHistory?: boolean | undefined;
|
|
133
|
-
}>;
|
|
125
|
+
}, z.core.$strip>;
|
|
134
126
|
handler: typeof handler;
|
|
135
127
|
};
|
|
136
128
|
export default toolDefinition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect-secrets.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-tools/quality/security-compliance/detect-secrets.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,wBAAwB
|
|
1
|
+
{"version":3,"file":"detect-secrets.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-tools/quality/security-compliance/detect-secrets.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;iBA4BnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAG1E,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,eAAe,EAAE,oBAAoB,EAAE,CAAC;IACxC,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACjD,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACjD,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IAClC,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;CACzB;AAGD,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;CACpC;AAwDD;;GAEG;AACH,wBAAsB,OAAO,CAC3B,KAAK,EAAE,kBAAkB,EACzB,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAyE7D;AAoQD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;CAO1B,CAAC;eAEa,cAAc"}
|
|
@@ -22,6 +22,7 @@ interface TaskStore {
|
|
|
22
22
|
tasks: Record<string, TaskRecord>;
|
|
23
23
|
version: string;
|
|
24
24
|
}
|
|
25
|
+
export declare function loadTaskStoreOrNull(): TaskStore | null;
|
|
25
26
|
export declare function loadTaskStore(): TaskStore;
|
|
26
27
|
export declare const taskTools: MCPTool[];
|
|
27
28
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-tools.d.ts","sourceRoot":"","sources":["../../../src/mcp-tools/task-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,KAAK,OAAO,EAAuB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"task-tools.d.ts","sourceRoot":"","sources":["../../../src/mcp-tools/task-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,KAAK,OAAO,EAAuB,MAAM,YAAY,CAAC;AAO/D,UAAU,UAAU;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IACjD,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;IACzE,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,UAAU,SAAS;IACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;CACjB;AAiBD,wBAAgB,mBAAmB,IAAI,SAAS,GAAG,IAAI,CAEtD;AAED,wBAAgB,aAAa,IAAI,SAAS,CAEzC;AASD,eAAO,MAAM,SAAS,EAAE,OAAO,EA4c9B,CAAC"}
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Tool definitions for task management with file persistence.
|
|
5
5
|
*/
|
|
6
|
-
import { existsSync,
|
|
6
|
+
import { existsSync, mkdirSync } from 'node:fs';
|
|
7
7
|
import { join } from 'node:path';
|
|
8
8
|
import { randomBytes } from 'node:crypto';
|
|
9
9
|
import { getMonomindDataRoot } from './types.js';
|
|
10
|
+
import { readJsonStoreOrNull, writeJsonFileAtomic } from '../utils/json-file.js';
|
|
10
11
|
// Storage paths — relative to the git-safe data root
|
|
11
12
|
const TASK_DIR = 'tasks';
|
|
12
13
|
const TASK_FILE = 'store.json';
|
|
@@ -22,34 +23,15 @@ function ensureTaskDir() {
|
|
|
22
23
|
mkdirSync(dir, { recursive: true });
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
export function loadTaskStoreOrNull() {
|
|
27
|
+
return readJsonStoreOrNull(getTaskPath(), { tasks: {}, version: '3.0.0' }, 'loadTaskStore');
|
|
28
|
+
}
|
|
26
29
|
export function loadTaskStore() {
|
|
27
|
-
|
|
28
|
-
const path = getTaskPath();
|
|
29
|
-
if (existsSync(path)) {
|
|
30
|
-
if (statSync(path).size > MAX_TASK_STORE_BYTES)
|
|
31
|
-
return { tasks: {}, version: '3.0.0' };
|
|
32
|
-
const data = readFileSync(path, 'utf-8');
|
|
33
|
-
const parsed = JSON.parse(data);
|
|
34
|
-
if (parsed && typeof parsed === 'object' && Object.prototype.hasOwnProperty.call(parsed, '__proto__'))
|
|
35
|
-
return { tasks: {}, version: '3.0.0' };
|
|
36
|
-
return parsed;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch (e) {
|
|
40
|
-
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
41
|
-
console.error('[loadTaskStore] failed to read/parse task store:', e);
|
|
42
|
-
}
|
|
43
|
-
return { tasks: {}, version: '3.0.0' };
|
|
30
|
+
return loadTaskStoreOrNull() ?? { tasks: {}, version: '3.0.0' };
|
|
44
31
|
}
|
|
45
32
|
function saveTaskStore(store) {
|
|
46
33
|
ensureTaskDir();
|
|
47
|
-
|
|
48
|
-
// Unique tmp filename — concurrent task_assign/complete calls would
|
|
49
|
-
// otherwise race on the same .tmp file.
|
|
50
|
-
const tmpPath = `${taskPath}.${process.pid}.${Date.now()}.tmp`;
|
|
51
|
-
writeFileSync(tmpPath, JSON.stringify(store, null, 2), 'utf-8');
|
|
52
|
-
renameSync(tmpPath, taskPath);
|
|
34
|
+
writeJsonFileAtomic(getTaskPath(), store);
|
|
53
35
|
}
|
|
54
36
|
const FORBIDDEN_TASK_IDS = new Set(['__proto__', 'constructor', 'prototype']);
|
|
55
37
|
export const taskTools = [
|
|
@@ -69,7 +51,9 @@ export const taskTools = [
|
|
|
69
51
|
required: ['type', 'description'],
|
|
70
52
|
},
|
|
71
53
|
handler: async (input) => {
|
|
72
|
-
const store =
|
|
54
|
+
const store = loadTaskStoreOrNull();
|
|
55
|
+
if (!store)
|
|
56
|
+
return { success: false, error: 'Task store is corrupt or unreadable — refusing to overwrite' };
|
|
73
57
|
const taskId = `task-${Date.now()}-${randomBytes(4).toString('hex')}`;
|
|
74
58
|
// Cap all string fields: they are persisted verbatim to the task JSON store.
|
|
75
59
|
const MAX_TASK_TYPE_LEN = 128;
|
|
@@ -240,7 +224,9 @@ export const taskTools = [
|
|
|
240
224
|
required: ['taskId'],
|
|
241
225
|
},
|
|
242
226
|
handler: async (input) => {
|
|
243
|
-
const store =
|
|
227
|
+
const store = loadTaskStoreOrNull();
|
|
228
|
+
if (!store)
|
|
229
|
+
return { success: false, error: 'Task store is corrupt or unreadable — refusing to overwrite' };
|
|
244
230
|
const taskId = input.taskId;
|
|
245
231
|
if (FORBIDDEN_TASK_IDS.has(taskId))
|
|
246
232
|
return { taskId, status: 'not_found', error: 'Task not found' };
|
|
@@ -255,29 +241,20 @@ export const taskTools = [
|
|
|
255
241
|
if (task.assignedTo.length > 0) {
|
|
256
242
|
const agentStorePath = join(getMonomindDataRoot(), 'agents', 'store.json');
|
|
257
243
|
try {
|
|
258
|
-
|
|
259
|
-
if (
|
|
260
|
-
const agentRaw = JSON.parse(readFileSync(agentStorePath, 'utf-8'));
|
|
261
|
-
if (agentRaw && typeof agentRaw === 'object' && !Object.prototype.hasOwnProperty.call(agentRaw, '__proto__')) {
|
|
262
|
-
agentStore = agentRaw;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
for (const agentId of task.assignedTo) {
|
|
244
|
+
const agentStore = readJsonStoreOrNull(agentStorePath, { agents: {} }, 'task_complete/agent-sync');
|
|
245
|
+
if (agentStore) {
|
|
266
246
|
const FORBIDDEN_AGENT_IDS_TC = new Set(['__proto__', 'constructor', 'prototype']);
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
247
|
+
for (const agentId of task.assignedTo) {
|
|
248
|
+
if (typeof agentId === 'string' && agentId.length > 0 && agentId.length <= 128 &&
|
|
249
|
+
!FORBIDDEN_AGENT_IDS_TC.has(agentId) && Object.hasOwn(agentStore.agents, agentId)) {
|
|
250
|
+
agentStore.agents[agentId].status = 'idle';
|
|
251
|
+
agentStore.agents[agentId].currentTask = null;
|
|
252
|
+
agentStore.agents[agentId].taskCount =
|
|
253
|
+
(agentStore.agents[agentId].taskCount || 0) + 1;
|
|
254
|
+
}
|
|
273
255
|
}
|
|
256
|
+
writeJsonFileAtomic(agentStorePath, agentStore);
|
|
274
257
|
}
|
|
275
|
-
const agentDir = join(getMonomindDataRoot(), 'agents');
|
|
276
|
-
if (!existsSync(agentDir))
|
|
277
|
-
mkdirSync(agentDir, { recursive: true });
|
|
278
|
-
const tmpAgent1 = `${agentStorePath}.${process.pid}.${Date.now()}.tmp`;
|
|
279
|
-
writeFileSync(tmpAgent1, JSON.stringify(agentStore, null, 2), 'utf-8');
|
|
280
|
-
renameSync(tmpAgent1, agentStorePath);
|
|
281
258
|
}
|
|
282
259
|
catch (e) {
|
|
283
260
|
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
@@ -313,7 +290,9 @@ export const taskTools = [
|
|
|
313
290
|
required: ['taskId'],
|
|
314
291
|
},
|
|
315
292
|
handler: async (input) => {
|
|
316
|
-
const store =
|
|
293
|
+
const store = loadTaskStoreOrNull();
|
|
294
|
+
if (!store)
|
|
295
|
+
return { success: false, error: 'Task store is corrupt or unreadable — refusing to overwrite' };
|
|
317
296
|
const taskId = input.taskId;
|
|
318
297
|
if (FORBIDDEN_TASK_IDS.has(taskId))
|
|
319
298
|
return { success: false, taskId, error: 'Task not found' };
|
|
@@ -370,7 +349,9 @@ export const taskTools = [
|
|
|
370
349
|
required: ['taskId'],
|
|
371
350
|
},
|
|
372
351
|
handler: async (input) => {
|
|
373
|
-
const store =
|
|
352
|
+
const store = loadTaskStoreOrNull();
|
|
353
|
+
if (!store)
|
|
354
|
+
return { success: false, error: 'Task store is corrupt or unreadable — refusing to overwrite' };
|
|
374
355
|
const taskId = input.taskId;
|
|
375
356
|
if (FORBIDDEN_TASK_IDS.has(taskId))
|
|
376
357
|
return { taskId, error: 'Task not found' };
|
|
@@ -381,80 +362,62 @@ export const taskTools = [
|
|
|
381
362
|
const previouslyAssigned = [...task.assignedTo];
|
|
382
363
|
// Load agent store to sync worker state. Distinguish "file doesn't
|
|
383
364
|
// exist yet" (safe to proceed with an empty store) from "file exists
|
|
384
|
-
// but failed to read/parse" (a real store that's momentarily corrupt
|
|
385
|
-
// or oversized) — the latter must NOT fall through to the unconditional
|
|
386
|
-
// write-back below, or a transient read failure silently wipes out
|
|
387
|
-
// every agent's real on-disk state.
|
|
388
365
|
const agentStorePath = join(getMonomindDataRoot(), 'agents', 'store.json');
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
try {
|
|
392
|
-
if (existsSync(agentStorePath)) {
|
|
393
|
-
if (statSync(agentStorePath).size <= MAX_TASK_STORE_BYTES) {
|
|
394
|
-
agentStore = JSON.parse(readFileSync(agentStorePath, 'utf-8'));
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
agentStoreReadFailed = true;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
catch (e) {
|
|
402
|
-
agentStoreReadFailed = true;
|
|
403
|
-
if (process.env.DEBUG || process.env.MONOMIND_DEBUG)
|
|
404
|
-
console.error('[task_assign] failed to read agent store — skipping agent-store sync to avoid overwriting it with an empty one:', e);
|
|
405
|
-
}
|
|
406
|
-
// Reject IDs that would mutate Object.prototype when used as a key in
|
|
407
|
-
// the JSON-loaded plain object `agentStore.agents`.
|
|
366
|
+
const agentStore = readJsonStoreOrNull(agentStorePath, { agents: {} }, 'task_assign/agent-sync');
|
|
367
|
+
const agentStoreReadFailed = agentStore === null;
|
|
408
368
|
const FORBIDDEN_AGENT_IDS = new Set(['__proto__', 'constructor', 'prototype']);
|
|
409
369
|
const isValidAgentId = (id) => typeof id === 'string' && id.length > 0 && id.length <= 128 && !FORBIDDEN_AGENT_IDS.has(id);
|
|
410
|
-
if (
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
370
|
+
if (!agentStoreReadFailed) {
|
|
371
|
+
if (input.unassign) {
|
|
372
|
+
for (const agentId of previouslyAssigned) {
|
|
373
|
+
if (isValidAgentId(agentId) && Object.hasOwn(agentStore.agents, agentId)) {
|
|
374
|
+
agentStore.agents[agentId].status = 'idle';
|
|
375
|
+
agentStore.agents[agentId].currentTask = null;
|
|
376
|
+
}
|
|
416
377
|
}
|
|
378
|
+
task.assignedTo = [];
|
|
417
379
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
agentStore.agents[agentId].status = 'idle';
|
|
427
|
-
agentStore.agents[agentId].currentTask = null;
|
|
380
|
+
else {
|
|
381
|
+
const rawIds = input.agentIds || [];
|
|
382
|
+
const agentIds = rawIds.filter(isValidAgentId);
|
|
383
|
+
for (const agentId of previouslyAssigned) {
|
|
384
|
+
if (isValidAgentId(agentId) && !agentIds.includes(agentId) && Object.hasOwn(agentStore.agents, agentId)) {
|
|
385
|
+
agentStore.agents[agentId].status = 'idle';
|
|
386
|
+
agentStore.agents[agentId].currentTask = null;
|
|
387
|
+
}
|
|
428
388
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
389
|
+
for (const agentId of agentIds) {
|
|
390
|
+
if (Object.hasOwn(agentStore.agents, agentId)) {
|
|
391
|
+
agentStore.agents[agentId].status = 'busy';
|
|
392
|
+
agentStore.agents[agentId].currentTask = taskId;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
task.assignedTo = agentIds;
|
|
396
|
+
if (task.status === 'pending' && agentIds.length > 0) {
|
|
397
|
+
task.status = 'in_progress';
|
|
398
|
+
if (!task.startedAt) {
|
|
399
|
+
task.startedAt = new Date().toISOString();
|
|
400
|
+
}
|
|
435
401
|
}
|
|
436
402
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
// Agent store corrupt — still update task assignments from input
|
|
406
|
+
if (input.unassign) {
|
|
407
|
+
task.assignedTo = [];
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
task.assignedTo = (input.agentIds || []).filter(isValidAgentId);
|
|
411
|
+
if (task.status === 'pending' && task.assignedTo.length > 0) {
|
|
412
|
+
task.status = 'in_progress';
|
|
413
|
+
if (!task.startedAt)
|
|
414
|
+
task.startedAt = new Date().toISOString();
|
|
443
415
|
}
|
|
444
416
|
}
|
|
445
417
|
}
|
|
446
418
|
saveTaskStore(store);
|
|
447
|
-
// Save agent store — skipped when the read above failed, so a
|
|
448
|
-
// transient corrupt/oversized store.json is left alone instead of
|
|
449
|
-
// being overwritten with an empty one.
|
|
450
419
|
if (!agentStoreReadFailed) {
|
|
451
|
-
|
|
452
|
-
if (!existsSync(agentDir)) {
|
|
453
|
-
mkdirSync(agentDir, { recursive: true });
|
|
454
|
-
}
|
|
455
|
-
const tmpAgent2 = `${agentStorePath}.${process.pid}.${Date.now()}.tmp`;
|
|
456
|
-
writeFileSync(tmpAgent2, JSON.stringify(agentStore, null, 2), 'utf-8');
|
|
457
|
-
renameSync(tmpAgent2, agentStorePath);
|
|
420
|
+
writeJsonFileAtomic(agentStorePath, agentStore);
|
|
458
421
|
}
|
|
459
422
|
return {
|
|
460
423
|
taskId: task.taskId,
|
|
@@ -478,7 +441,9 @@ export const taskTools = [
|
|
|
478
441
|
required: ['taskId'],
|
|
479
442
|
},
|
|
480
443
|
handler: async (input) => {
|
|
481
|
-
const store =
|
|
444
|
+
const store = loadTaskStoreOrNull();
|
|
445
|
+
if (!store)
|
|
446
|
+
return { success: false, error: 'Task store is corrupt or unreadable — refusing to overwrite' };
|
|
482
447
|
const taskId = input.taskId;
|
|
483
448
|
if (FORBIDDEN_TASK_IDS.has(taskId))
|
|
484
449
|
return { success: false, taskId, error: 'Task not found' };
|