@adhisang/minecraft-modding-mcp 2.1.0 → 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/CHANGELOG.md +18 -0
- package/README.md +33 -4
- package/dist/cache-registry.d.ts +95 -0
- package/dist/cache-registry.js +541 -0
- package/dist/entry-tools/analyze-mod-service.d.ts +207 -0
- package/dist/entry-tools/analyze-mod-service.js +253 -0
- package/dist/entry-tools/analyze-symbol-service.d.ts +209 -0
- package/dist/entry-tools/analyze-symbol-service.js +304 -0
- package/dist/entry-tools/compare-minecraft-service.d.ts +210 -0
- package/dist/entry-tools/compare-minecraft-service.js +397 -0
- package/dist/entry-tools/entry-tool-schema.d.ts +6 -0
- package/dist/entry-tools/entry-tool-schema.js +10 -0
- package/dist/entry-tools/inspect-minecraft-service.d.ts +1953 -0
- package/dist/entry-tools/inspect-minecraft-service.js +876 -0
- package/dist/entry-tools/manage-cache-service.d.ts +130 -0
- package/dist/entry-tools/manage-cache-service.js +229 -0
- package/dist/entry-tools/request-normalizers.d.ts +10 -0
- package/dist/entry-tools/request-normalizers.js +36 -0
- package/dist/entry-tools/response-contract.d.ts +44 -0
- package/dist/entry-tools/response-contract.js +96 -0
- package/dist/entry-tools/validate-project-service.d.ts +543 -0
- package/dist/entry-tools/validate-project-service.js +381 -0
- package/dist/index.js +103 -9
- package/package.json +1 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type CacheRegistry } from "../cache-registry.js";
|
|
3
|
+
export declare const manageCacheShape: {
|
|
4
|
+
action: z.ZodEnum<["summary", "list", "inspect", "delete", "prune", "rebuild", "verify"]>;
|
|
5
|
+
cacheKinds: z.ZodOptional<z.ZodArray<z.ZodEnum<["artifact-index", "downloads", "mapping", "registry", "decompiled-source", "mod-remap"]>, "many">>;
|
|
6
|
+
selector: z.ZodOptional<z.ZodObject<{
|
|
7
|
+
artifactId: z.ZodOptional<z.ZodString>;
|
|
8
|
+
version: z.ZodOptional<z.ZodString>;
|
|
9
|
+
jarPath: z.ZodOptional<z.ZodString>;
|
|
10
|
+
entryId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
status: z.ZodOptional<z.ZodEnum<["healthy", "partial", "stale", "orphaned", "corrupt", "in_use"]>>;
|
|
12
|
+
olderThan: z.ZodOptional<z.ZodString>;
|
|
13
|
+
mapping: z.ZodOptional<z.ZodString>;
|
|
14
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
15
|
+
projectPath: z.ZodOptional<z.ZodString>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
mapping?: string | undefined;
|
|
18
|
+
jarPath?: string | undefined;
|
|
19
|
+
projectPath?: string | undefined;
|
|
20
|
+
entryId?: string | undefined;
|
|
21
|
+
artifactId?: string | undefined;
|
|
22
|
+
status?: "healthy" | "partial" | "stale" | "orphaned" | "corrupt" | "in_use" | undefined;
|
|
23
|
+
version?: string | undefined;
|
|
24
|
+
scope?: string | undefined;
|
|
25
|
+
olderThan?: string | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
mapping?: string | undefined;
|
|
28
|
+
jarPath?: string | undefined;
|
|
29
|
+
projectPath?: string | undefined;
|
|
30
|
+
entryId?: string | undefined;
|
|
31
|
+
artifactId?: string | undefined;
|
|
32
|
+
status?: "healthy" | "partial" | "stale" | "orphaned" | "corrupt" | "in_use" | undefined;
|
|
33
|
+
version?: string | undefined;
|
|
34
|
+
scope?: string | undefined;
|
|
35
|
+
olderThan?: string | undefined;
|
|
36
|
+
}>>;
|
|
37
|
+
detail: z.ZodOptional<z.ZodEnum<["summary", "standard", "full"]>>;
|
|
38
|
+
include: z.ZodOptional<z.ZodArray<z.ZodEnum<[string, ...string[]]>, "many">>;
|
|
39
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
41
|
+
executionMode: z.ZodOptional<z.ZodEnum<["preview", "apply"]>>;
|
|
42
|
+
};
|
|
43
|
+
export declare const manageCacheSchema: z.ZodObject<{
|
|
44
|
+
action: z.ZodEnum<["summary", "list", "inspect", "delete", "prune", "rebuild", "verify"]>;
|
|
45
|
+
cacheKinds: z.ZodOptional<z.ZodArray<z.ZodEnum<["artifact-index", "downloads", "mapping", "registry", "decompiled-source", "mod-remap"]>, "many">>;
|
|
46
|
+
selector: z.ZodOptional<z.ZodObject<{
|
|
47
|
+
artifactId: z.ZodOptional<z.ZodString>;
|
|
48
|
+
version: z.ZodOptional<z.ZodString>;
|
|
49
|
+
jarPath: z.ZodOptional<z.ZodString>;
|
|
50
|
+
entryId: z.ZodOptional<z.ZodString>;
|
|
51
|
+
status: z.ZodOptional<z.ZodEnum<["healthy", "partial", "stale", "orphaned", "corrupt", "in_use"]>>;
|
|
52
|
+
olderThan: z.ZodOptional<z.ZodString>;
|
|
53
|
+
mapping: z.ZodOptional<z.ZodString>;
|
|
54
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
55
|
+
projectPath: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
mapping?: string | undefined;
|
|
58
|
+
jarPath?: string | undefined;
|
|
59
|
+
projectPath?: string | undefined;
|
|
60
|
+
entryId?: string | undefined;
|
|
61
|
+
artifactId?: string | undefined;
|
|
62
|
+
status?: "healthy" | "partial" | "stale" | "orphaned" | "corrupt" | "in_use" | undefined;
|
|
63
|
+
version?: string | undefined;
|
|
64
|
+
scope?: string | undefined;
|
|
65
|
+
olderThan?: string | undefined;
|
|
66
|
+
}, {
|
|
67
|
+
mapping?: string | undefined;
|
|
68
|
+
jarPath?: string | undefined;
|
|
69
|
+
projectPath?: string | undefined;
|
|
70
|
+
entryId?: string | undefined;
|
|
71
|
+
artifactId?: string | undefined;
|
|
72
|
+
status?: "healthy" | "partial" | "stale" | "orphaned" | "corrupt" | "in_use" | undefined;
|
|
73
|
+
version?: string | undefined;
|
|
74
|
+
scope?: string | undefined;
|
|
75
|
+
olderThan?: string | undefined;
|
|
76
|
+
}>>;
|
|
77
|
+
detail: z.ZodOptional<z.ZodEnum<["summary", "standard", "full"]>>;
|
|
78
|
+
include: z.ZodOptional<z.ZodArray<z.ZodEnum<[string, ...string[]]>, "many">>;
|
|
79
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
81
|
+
executionMode: z.ZodOptional<z.ZodEnum<["preview", "apply"]>>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
action: "list" | "summary" | "inspect" | "verify" | "delete" | "prune" | "rebuild";
|
|
84
|
+
limit?: number | undefined;
|
|
85
|
+
cursor?: string | undefined;
|
|
86
|
+
detail?: "full" | "summary" | "standard" | undefined;
|
|
87
|
+
include?: string[] | undefined;
|
|
88
|
+
executionMode?: "preview" | "apply" | undefined;
|
|
89
|
+
cacheKinds?: ("artifact-index" | "downloads" | "mapping" | "registry" | "decompiled-source" | "mod-remap")[] | undefined;
|
|
90
|
+
selector?: {
|
|
91
|
+
mapping?: string | undefined;
|
|
92
|
+
jarPath?: string | undefined;
|
|
93
|
+
projectPath?: string | undefined;
|
|
94
|
+
entryId?: string | undefined;
|
|
95
|
+
artifactId?: string | undefined;
|
|
96
|
+
status?: "healthy" | "partial" | "stale" | "orphaned" | "corrupt" | "in_use" | undefined;
|
|
97
|
+
version?: string | undefined;
|
|
98
|
+
scope?: string | undefined;
|
|
99
|
+
olderThan?: string | undefined;
|
|
100
|
+
} | undefined;
|
|
101
|
+
}, {
|
|
102
|
+
action: "list" | "summary" | "inspect" | "verify" | "delete" | "prune" | "rebuild";
|
|
103
|
+
limit?: number | undefined;
|
|
104
|
+
cursor?: string | undefined;
|
|
105
|
+
detail?: "full" | "summary" | "standard" | undefined;
|
|
106
|
+
include?: string[] | undefined;
|
|
107
|
+
executionMode?: "preview" | "apply" | undefined;
|
|
108
|
+
cacheKinds?: ("artifact-index" | "downloads" | "mapping" | "registry" | "decompiled-source" | "mod-remap")[] | undefined;
|
|
109
|
+
selector?: {
|
|
110
|
+
mapping?: string | undefined;
|
|
111
|
+
jarPath?: string | undefined;
|
|
112
|
+
projectPath?: string | undefined;
|
|
113
|
+
entryId?: string | undefined;
|
|
114
|
+
artifactId?: string | undefined;
|
|
115
|
+
status?: "healthy" | "partial" | "stale" | "orphaned" | "corrupt" | "in_use" | undefined;
|
|
116
|
+
version?: string | undefined;
|
|
117
|
+
scope?: string | undefined;
|
|
118
|
+
olderThan?: string | undefined;
|
|
119
|
+
} | undefined;
|
|
120
|
+
}>;
|
|
121
|
+
export type ManageCacheInput = z.infer<typeof manageCacheSchema>;
|
|
122
|
+
export declare class ManageCacheService {
|
|
123
|
+
private readonly deps;
|
|
124
|
+
constructor(deps: {
|
|
125
|
+
registry: CacheRegistry;
|
|
126
|
+
});
|
|
127
|
+
execute(input: ManageCacheInput): Promise<Record<string, unknown> & {
|
|
128
|
+
warnings?: string[];
|
|
129
|
+
}>;
|
|
130
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { PUBLIC_CACHE_KINDS } from "../cache-registry.js";
|
|
3
|
+
import { createError, ERROR_CODES } from "../errors.js";
|
|
4
|
+
import { buildIncludeSchema, detailSchema, executionModeSchema, positiveIntSchema } from "./entry-tool-schema.js";
|
|
5
|
+
import { buildEntryToolResult } from "./response-contract.js";
|
|
6
|
+
import { normalizeReadOnlyExecutionMode, requireNonEmptyObject, resolveDetail, resolveInclude } from "./request-normalizers.js";
|
|
7
|
+
const nonEmptyString = z.string().trim().min(1);
|
|
8
|
+
const INCLUDE_GROUPS = ["warnings", "cacheEntries", "paths", "owners", "health", "preview", "timings"];
|
|
9
|
+
export const manageCacheShape = {
|
|
10
|
+
action: z.enum(["summary", "list", "inspect", "delete", "prune", "rebuild", "verify"]),
|
|
11
|
+
cacheKinds: z.array(z.enum(PUBLIC_CACHE_KINDS)).optional(),
|
|
12
|
+
selector: z.object({
|
|
13
|
+
artifactId: nonEmptyString.optional(),
|
|
14
|
+
version: nonEmptyString.optional(),
|
|
15
|
+
jarPath: nonEmptyString.optional(),
|
|
16
|
+
entryId: nonEmptyString.optional(),
|
|
17
|
+
status: z.enum(["healthy", "partial", "stale", "orphaned", "corrupt", "in_use"]).optional(),
|
|
18
|
+
olderThan: nonEmptyString.optional(),
|
|
19
|
+
mapping: nonEmptyString.optional(),
|
|
20
|
+
scope: nonEmptyString.optional(),
|
|
21
|
+
projectPath: nonEmptyString.optional()
|
|
22
|
+
}).optional(),
|
|
23
|
+
detail: detailSchema.optional(),
|
|
24
|
+
include: buildIncludeSchema(INCLUDE_GROUPS),
|
|
25
|
+
limit: positiveIntSchema.optional(),
|
|
26
|
+
cursor: nonEmptyString.optional(),
|
|
27
|
+
executionMode: executionModeSchema.optional()
|
|
28
|
+
};
|
|
29
|
+
export const manageCacheSchema = z.object(manageCacheShape);
|
|
30
|
+
export class ManageCacheService {
|
|
31
|
+
deps;
|
|
32
|
+
constructor(deps) {
|
|
33
|
+
this.deps = deps;
|
|
34
|
+
}
|
|
35
|
+
async execute(input) {
|
|
36
|
+
const detail = resolveDetail(input.detail);
|
|
37
|
+
const include = resolveInclude(input.include);
|
|
38
|
+
const executionMode = normalizeReadOnlyExecutionMode(input.action, input.executionMode);
|
|
39
|
+
const cacheKinds = input.cacheKinds?.length ? input.cacheKinds : [...PUBLIC_CACHE_KINDS];
|
|
40
|
+
if (executionMode === "apply" &&
|
|
41
|
+
(input.action === "delete" || input.action === "prune" || input.action === "rebuild")) {
|
|
42
|
+
requireNonEmptyObject(input.selector, `${input.action} apply requires a non-empty selector.`);
|
|
43
|
+
}
|
|
44
|
+
switch (input.action) {
|
|
45
|
+
case "summary": {
|
|
46
|
+
const summary = await this.deps.registry.summarize({
|
|
47
|
+
cacheKinds,
|
|
48
|
+
selector: input.selector
|
|
49
|
+
});
|
|
50
|
+
const hasUnhealthyKinds = Object.values(summary.kinds).some((item) => item && item.status !== "healthy");
|
|
51
|
+
const entryCount = Object.values(summary.kinds).reduce((total, item) => total + (item?.entryCount ?? 0), 0);
|
|
52
|
+
const totalBytes = Object.values(summary.kinds).reduce((total, item) => total + (item?.totalBytes ?? 0), 0);
|
|
53
|
+
return {
|
|
54
|
+
...buildEntryToolResult({
|
|
55
|
+
task: "summary",
|
|
56
|
+
detail,
|
|
57
|
+
include,
|
|
58
|
+
summary: {
|
|
59
|
+
status: hasUnhealthyKinds ? "partial" : "ok",
|
|
60
|
+
headline: `Summarized ${cacheKinds.length} cache kind(s).`,
|
|
61
|
+
counts: {
|
|
62
|
+
entries: entryCount,
|
|
63
|
+
bytes: totalBytes
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
blocks: {
|
|
67
|
+
stats: summary.kinds,
|
|
68
|
+
operation: {
|
|
69
|
+
executionMode
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
alwaysBlocks: ["operation"]
|
|
73
|
+
}),
|
|
74
|
+
warnings: []
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
case "list":
|
|
78
|
+
case "inspect": {
|
|
79
|
+
const page = input.action === "list"
|
|
80
|
+
? await this.deps.registry.listEntries({
|
|
81
|
+
cacheKinds,
|
|
82
|
+
selector: input.selector,
|
|
83
|
+
limit: input.limit,
|
|
84
|
+
cursor: input.cursor
|
|
85
|
+
})
|
|
86
|
+
: {
|
|
87
|
+
entries: await this.deps.registry.inspectEntries({
|
|
88
|
+
cacheKinds,
|
|
89
|
+
selector: input.selector,
|
|
90
|
+
limit: input.limit
|
|
91
|
+
}),
|
|
92
|
+
nextCursor: undefined
|
|
93
|
+
};
|
|
94
|
+
const hasUnhealthyEntries = page.entries.some((entry) => entry.status !== "healthy");
|
|
95
|
+
return {
|
|
96
|
+
...buildEntryToolResult({
|
|
97
|
+
task: input.action,
|
|
98
|
+
detail,
|
|
99
|
+
include,
|
|
100
|
+
summary: {
|
|
101
|
+
status: hasUnhealthyEntries ? "partial" : "ok",
|
|
102
|
+
headline: `${input.action === "list" ? "Listed" : "Inspected"} ${page.entries.length} cache entr${page.entries.length === 1 ? "y" : "ies"}.`,
|
|
103
|
+
counts: {
|
|
104
|
+
entries: page.entries.length
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
blocks: {
|
|
108
|
+
cacheEntries: page.entries,
|
|
109
|
+
operation: {
|
|
110
|
+
executionMode
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
alwaysBlocks: ["operation"]
|
|
114
|
+
}),
|
|
115
|
+
warnings: [],
|
|
116
|
+
...(input.action === "list" && page.nextCursor
|
|
117
|
+
? {
|
|
118
|
+
meta: {
|
|
119
|
+
pagination: {
|
|
120
|
+
nextCursor: page.nextCursor
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
: {})
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
case "verify": {
|
|
128
|
+
const output = await this.deps.registry.verifyEntries({
|
|
129
|
+
cacheKinds,
|
|
130
|
+
selector: input.selector
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
...buildEntryToolResult({
|
|
134
|
+
task: "verify",
|
|
135
|
+
detail,
|
|
136
|
+
include,
|
|
137
|
+
summary: {
|
|
138
|
+
status: output.unhealthyEntries > 0 ? "partial" : "ok",
|
|
139
|
+
headline: `Verified ${output.checkedEntries} cache entr${output.checkedEntries === 1 ? "y" : "ies"}.`,
|
|
140
|
+
counts: {
|
|
141
|
+
checkedEntries: output.checkedEntries,
|
|
142
|
+
unhealthyEntries: output.unhealthyEntries
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
blocks: {
|
|
146
|
+
operation: {
|
|
147
|
+
executionMode
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
alwaysBlocks: ["operation"]
|
|
151
|
+
}),
|
|
152
|
+
warnings: output.warnings
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
case "delete":
|
|
156
|
+
case "prune": {
|
|
157
|
+
const output = input.action === "delete"
|
|
158
|
+
? await this.deps.registry.deleteEntries({
|
|
159
|
+
cacheKinds,
|
|
160
|
+
selector: input.selector,
|
|
161
|
+
executionMode
|
|
162
|
+
})
|
|
163
|
+
: await this.deps.registry.pruneEntries({
|
|
164
|
+
cacheKinds,
|
|
165
|
+
selector: input.selector,
|
|
166
|
+
executionMode
|
|
167
|
+
});
|
|
168
|
+
return {
|
|
169
|
+
...buildEntryToolResult({
|
|
170
|
+
task: input.action,
|
|
171
|
+
detail,
|
|
172
|
+
include,
|
|
173
|
+
summary: {
|
|
174
|
+
status: output.deletedEntries > 0 && executionMode === "apply" ? "changed" : "unchanged",
|
|
175
|
+
headline: `${executionMode === "apply" ? "Applied" : "Previewed"} ${input.action} across ${cacheKinds.length} cache kind(s).`,
|
|
176
|
+
counts: {
|
|
177
|
+
deletedEntries: output.deletedEntries,
|
|
178
|
+
deletedBytes: output.deletedBytes
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
blocks: {
|
|
182
|
+
operation: {
|
|
183
|
+
executionMode,
|
|
184
|
+
deletedEntries: output.deletedEntries,
|
|
185
|
+
deletedBytes: output.deletedBytes
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
alwaysBlocks: ["operation"]
|
|
189
|
+
}),
|
|
190
|
+
warnings: output.warnings
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
case "rebuild": {
|
|
194
|
+
const output = await this.deps.registry.rebuildEntries({
|
|
195
|
+
cacheKinds,
|
|
196
|
+
selector: input.selector,
|
|
197
|
+
executionMode
|
|
198
|
+
});
|
|
199
|
+
return {
|
|
200
|
+
...buildEntryToolResult({
|
|
201
|
+
task: "rebuild",
|
|
202
|
+
detail,
|
|
203
|
+
include,
|
|
204
|
+
summary: {
|
|
205
|
+
status: output.rebuiltEntries > 0 && executionMode === "apply" ? "changed" : "unchanged",
|
|
206
|
+
headline: `${executionMode === "apply" ? "Applied" : "Previewed"} rebuild for ${cacheKinds.length} cache kind(s).`,
|
|
207
|
+
counts: {
|
|
208
|
+
rebuiltEntries: output.rebuiltEntries
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
blocks: {
|
|
212
|
+
operation: {
|
|
213
|
+
executionMode,
|
|
214
|
+
rebuiltEntries: output.rebuiltEntries
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
alwaysBlocks: ["operation"]
|
|
218
|
+
}),
|
|
219
|
+
warnings: output.warnings
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
throw createError({
|
|
224
|
+
code: ERROR_CODES.INVALID_INPUT,
|
|
225
|
+
message: `Unsupported manage-cache action "${input.action}".`
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=manage-cache-service.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DetailLevel, NextAction } from "./response-contract.js";
|
|
2
|
+
export declare function resolveDetail(detail: DetailLevel | undefined): DetailLevel;
|
|
3
|
+
export declare function resolveInclude(include: readonly string[] | undefined): string[];
|
|
4
|
+
export declare function normalizeReadOnlyExecutionMode(action: string, executionMode: "preview" | "apply" | undefined): "preview" | "apply";
|
|
5
|
+
export declare function capArray<T>(values: readonly T[], maxItems: number): {
|
|
6
|
+
items: T[];
|
|
7
|
+
truncated: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function requireNonEmptyObject(selector: Record<string, unknown> | undefined, message: string): Record<string, unknown>;
|
|
10
|
+
export declare function nextActionsOrUndefined(actions: NextAction[]): NextAction[] | undefined;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createError, ERROR_CODES } from "../errors.js";
|
|
2
|
+
import { normalizeIncludeGroups } from "./response-contract.js";
|
|
3
|
+
export function resolveDetail(detail) {
|
|
4
|
+
return detail ?? "summary";
|
|
5
|
+
}
|
|
6
|
+
export function resolveInclude(include) {
|
|
7
|
+
return normalizeIncludeGroups(include);
|
|
8
|
+
}
|
|
9
|
+
export function normalizeReadOnlyExecutionMode(action, executionMode) {
|
|
10
|
+
if (action === "summary" || action === "list" || action === "inspect" || action === "verify") {
|
|
11
|
+
return "preview";
|
|
12
|
+
}
|
|
13
|
+
return executionMode ?? "preview";
|
|
14
|
+
}
|
|
15
|
+
export function capArray(values, maxItems) {
|
|
16
|
+
if (values.length <= maxItems) {
|
|
17
|
+
return { items: [...values], truncated: false };
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
items: [...values.slice(0, maxItems)],
|
|
21
|
+
truncated: true
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function requireNonEmptyObject(selector, message) {
|
|
25
|
+
if (!selector || Object.keys(selector).length === 0) {
|
|
26
|
+
throw createError({
|
|
27
|
+
code: ERROR_CODES.INVALID_INPUT,
|
|
28
|
+
message
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return selector;
|
|
32
|
+
}
|
|
33
|
+
export function nextActionsOrUndefined(actions) {
|
|
34
|
+
return actions.length > 0 ? actions : undefined;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=request-normalizers.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const DETAIL_LEVELS: readonly ["summary", "standard", "full"];
|
|
2
|
+
export type DetailLevel = (typeof DETAIL_LEVELS)[number];
|
|
3
|
+
export declare const CANONICAL_INCLUDE_GROUPS: readonly ["warnings", "provenance", "candidates", "members", "source", "files", "samples", "diff", "issues", "timeline", "matrix", "entries", "workspace", "health", "recovery", "paths", "owners", "preview", "cacheEntries", "timings", "artifact", "classes", "registry"];
|
|
4
|
+
export type IncludeGroup = (typeof CANONICAL_INCLUDE_GROUPS)[number];
|
|
5
|
+
export type SummaryStatus = "ok" | "partial" | "ambiguous" | "not_found" | "invalid" | "blocked" | "changed" | "unchanged";
|
|
6
|
+
export type NextAction = {
|
|
7
|
+
tool: string;
|
|
8
|
+
params: Record<string, unknown>;
|
|
9
|
+
};
|
|
10
|
+
export type Summary = {
|
|
11
|
+
status: SummaryStatus;
|
|
12
|
+
headline: string;
|
|
13
|
+
subject?: Record<string, unknown>;
|
|
14
|
+
counts?: Record<string, number>;
|
|
15
|
+
nextActions?: NextAction[];
|
|
16
|
+
notes?: string[];
|
|
17
|
+
};
|
|
18
|
+
export type TruncationMeta = {
|
|
19
|
+
didTruncate: true;
|
|
20
|
+
reason: "limit";
|
|
21
|
+
omittedGroups?: string[];
|
|
22
|
+
nextActions?: NextAction[];
|
|
23
|
+
};
|
|
24
|
+
export declare function normalizeIncludeGroups(include: readonly string[] | undefined): string[];
|
|
25
|
+
export declare function createNextAction(tool: string, params: Record<string, unknown>): NextAction;
|
|
26
|
+
export declare function createTruncationMeta(input: {
|
|
27
|
+
omittedGroups?: string[];
|
|
28
|
+
nextActions?: NextAction[];
|
|
29
|
+
}): TruncationMeta;
|
|
30
|
+
export declare function buildEntryToolMeta(input: {
|
|
31
|
+
detail: DetailLevel;
|
|
32
|
+
include?: readonly string[];
|
|
33
|
+
warnings?: readonly string[];
|
|
34
|
+
truncated?: TruncationMeta;
|
|
35
|
+
pagination?: Record<string, unknown>;
|
|
36
|
+
}): Record<string, unknown>;
|
|
37
|
+
export declare function buildEntryToolResult(input: {
|
|
38
|
+
task: string;
|
|
39
|
+
summary: Summary;
|
|
40
|
+
detail: DetailLevel;
|
|
41
|
+
include?: readonly string[];
|
|
42
|
+
blocks?: Record<string, unknown>;
|
|
43
|
+
alwaysBlocks?: readonly string[];
|
|
44
|
+
}): Record<string, unknown>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export const DETAIL_LEVELS = ["summary", "standard", "full"];
|
|
2
|
+
export const CANONICAL_INCLUDE_GROUPS = [
|
|
3
|
+
"warnings",
|
|
4
|
+
"provenance",
|
|
5
|
+
"candidates",
|
|
6
|
+
"members",
|
|
7
|
+
"source",
|
|
8
|
+
"files",
|
|
9
|
+
"samples",
|
|
10
|
+
"diff",
|
|
11
|
+
"issues",
|
|
12
|
+
"timeline",
|
|
13
|
+
"matrix",
|
|
14
|
+
"entries",
|
|
15
|
+
"workspace",
|
|
16
|
+
"health",
|
|
17
|
+
"recovery",
|
|
18
|
+
"paths",
|
|
19
|
+
"owners",
|
|
20
|
+
"preview",
|
|
21
|
+
"cacheEntries",
|
|
22
|
+
"timings",
|
|
23
|
+
"artifact",
|
|
24
|
+
"classes",
|
|
25
|
+
"registry"
|
|
26
|
+
];
|
|
27
|
+
const INCLUDE_ORDER = new Map(CANONICAL_INCLUDE_GROUPS.map((group, index) => [group, index]));
|
|
28
|
+
export function normalizeIncludeGroups(include) {
|
|
29
|
+
if (!include || include.length === 0) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
const seen = new Set();
|
|
33
|
+
const deduped = [];
|
|
34
|
+
for (const group of include) {
|
|
35
|
+
if (!group || seen.has(group)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
seen.add(group);
|
|
39
|
+
deduped.push(group);
|
|
40
|
+
}
|
|
41
|
+
deduped.sort((left, right) => {
|
|
42
|
+
const leftIndex = INCLUDE_ORDER.get(left);
|
|
43
|
+
const rightIndex = INCLUDE_ORDER.get(right);
|
|
44
|
+
if (leftIndex == null && rightIndex == null) {
|
|
45
|
+
return left.localeCompare(right);
|
|
46
|
+
}
|
|
47
|
+
if (leftIndex == null) {
|
|
48
|
+
return 1;
|
|
49
|
+
}
|
|
50
|
+
if (rightIndex == null) {
|
|
51
|
+
return -1;
|
|
52
|
+
}
|
|
53
|
+
return leftIndex - rightIndex;
|
|
54
|
+
});
|
|
55
|
+
return deduped;
|
|
56
|
+
}
|
|
57
|
+
export function createNextAction(tool, params) {
|
|
58
|
+
return { tool, params };
|
|
59
|
+
}
|
|
60
|
+
export function createTruncationMeta(input) {
|
|
61
|
+
return {
|
|
62
|
+
didTruncate: true,
|
|
63
|
+
reason: "limit",
|
|
64
|
+
...(input.omittedGroups?.length ? { omittedGroups: [...input.omittedGroups] } : {}),
|
|
65
|
+
...(input.nextActions?.length ? { nextActions: [...input.nextActions] } : {})
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export function buildEntryToolMeta(input) {
|
|
69
|
+
return {
|
|
70
|
+
warnings: [...(input.warnings ?? [])],
|
|
71
|
+
detailApplied: input.detail,
|
|
72
|
+
...(input.include && input.include.length > 0
|
|
73
|
+
? { includeApplied: normalizeIncludeGroups(input.include) }
|
|
74
|
+
: {}),
|
|
75
|
+
...(input.truncated ? { truncated: input.truncated } : {}),
|
|
76
|
+
...(input.pagination ? { pagination: input.pagination } : {})
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export function buildEntryToolResult(input) {
|
|
80
|
+
const result = {
|
|
81
|
+
task: input.task,
|
|
82
|
+
summary: input.summary
|
|
83
|
+
};
|
|
84
|
+
const include = new Set(normalizeIncludeGroups(input.include));
|
|
85
|
+
const alwaysBlocks = new Set(input.alwaysBlocks ?? []);
|
|
86
|
+
for (const [key, value] of Object.entries(input.blocks ?? {})) {
|
|
87
|
+
if (value === undefined) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (alwaysBlocks.has(key) || input.detail !== "summary" || include.has(key)) {
|
|
91
|
+
result[key] = value;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=response-contract.js.map
|