@kb-labs/mind-contracts 2.93.0 → 2.96.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -167
- package/dist/index.d.ts +1920 -68
- package/dist/index.js +421 -352
- package/dist/index.js.map +1 -1
- package/package.json +7 -18
- package/dist/contract-D29vlhme.d.ts +0 -96
- package/dist/contract.d.ts +0 -1
- package/dist/contract.js +0 -57
- package/dist/contract.js.map +0 -1
- package/dist/schema.d.ts +0 -1820
- package/dist/schema.js +0 -286
- package/dist/schema.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,359 +1,428 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var contractsSchemaId = "@kb-labs/mind-contracts/schema";
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineFlags } from '@kb-labs/sdk';
|
|
4
3
|
|
|
5
|
-
// src/
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"mind:verify": {
|
|
22
|
-
id: "mind:verify",
|
|
23
|
-
description: "Validate Mind indexes and surface inconsistencies.",
|
|
24
|
-
input: {
|
|
25
|
-
ref: "@kb-labs/mind-contracts/schema#MindVerifyCommandInputSchema",
|
|
26
|
-
format: "zod"
|
|
27
|
-
},
|
|
28
|
-
output: {
|
|
29
|
-
ref: "@kb-labs/mind-contracts/schema#MindVerifyCommandOutputSchema",
|
|
30
|
-
format: "zod"
|
|
31
|
-
},
|
|
32
|
-
examples: ["kb mind verify", "kb mind verify --json"]
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
workflows: {},
|
|
36
|
-
api: {
|
|
37
|
-
rest: {
|
|
38
|
-
basePath: "/v1/plugins/mind",
|
|
39
|
-
routes: {
|
|
40
|
-
"mind.rest.verify": {
|
|
41
|
-
id: "mind.rest.verify",
|
|
42
|
-
method: "GET",
|
|
43
|
-
path: "/verify",
|
|
44
|
-
description: "Summarise index verification status for Studio dashboards.",
|
|
45
|
-
response: {
|
|
46
|
-
ref: "@kb-labs/mind-contracts/schema#MindVerifyResponseSchema",
|
|
47
|
-
format: "zod"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
4
|
+
// src/routes.ts
|
|
5
|
+
var MIND_BASE_PATH = "/v1/plugins/mind";
|
|
6
|
+
var MIND_ROUTES = {
|
|
7
|
+
INDEX: "/index",
|
|
8
|
+
SEARCH: "/search",
|
|
9
|
+
QUERY: "/query",
|
|
10
|
+
EXPLORE: "/explore",
|
|
11
|
+
DROP: "/index",
|
|
12
|
+
SYNC_ADD: "/sync/add",
|
|
13
|
+
SYNC_UPDATE: "/sync/update",
|
|
14
|
+
SYNC_DELETE: "/sync/delete",
|
|
15
|
+
SYNC_LIST: "/sync/list",
|
|
16
|
+
SYNC_STATUS: "/sync/status",
|
|
17
|
+
STATUS: "/status",
|
|
18
|
+
HEALTH: "/health",
|
|
19
|
+
REINDEX: "/reindex"
|
|
53
20
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
batch: {
|
|
69
|
-
maxSize: 100
|
|
70
|
-
}
|
|
21
|
+
var MIND_FULL_ROUTES = {
|
|
22
|
+
INDEX: `${MIND_BASE_PATH}${MIND_ROUTES.INDEX}`,
|
|
23
|
+
SEARCH: `${MIND_BASE_PATH}${MIND_ROUTES.SEARCH}`,
|
|
24
|
+
QUERY: `${MIND_BASE_PATH}${MIND_ROUTES.QUERY}`,
|
|
25
|
+
EXPLORE: `${MIND_BASE_PATH}${MIND_ROUTES.EXPLORE}`,
|
|
26
|
+
DROP: `${MIND_BASE_PATH}${MIND_ROUTES.DROP}`,
|
|
27
|
+
SYNC_ADD: `${MIND_BASE_PATH}${MIND_ROUTES.SYNC_ADD}`,
|
|
28
|
+
SYNC_UPDATE: `${MIND_BASE_PATH}${MIND_ROUTES.SYNC_UPDATE}`,
|
|
29
|
+
SYNC_DELETE: `${MIND_BASE_PATH}${MIND_ROUTES.SYNC_DELETE}`,
|
|
30
|
+
SYNC_LIST: `${MIND_BASE_PATH}${MIND_ROUTES.SYNC_LIST}`,
|
|
31
|
+
SYNC_STATUS: `${MIND_BASE_PATH}${MIND_ROUTES.SYNC_STATUS}`,
|
|
32
|
+
STATUS: `${MIND_BASE_PATH}${MIND_ROUTES.STATUS}`,
|
|
33
|
+
HEALTH: `${MIND_BASE_PATH}${MIND_ROUTES.HEALTH}`,
|
|
34
|
+
REINDEX: `${MIND_BASE_PATH}${MIND_ROUTES.REINDEX}`
|
|
71
35
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
format: z.enum(["zod", "json-schema", "openapi"]).optional(),
|
|
81
|
-
description: z.string().optional()
|
|
82
|
-
});
|
|
83
|
-
var restRouteContractSchema = z.object({
|
|
84
|
-
id: z.string().min(1),
|
|
85
|
-
method: z.string().min(1),
|
|
86
|
-
path: z.string().min(1),
|
|
87
|
-
description: z.string().optional(),
|
|
88
|
-
request: schemaReferenceSchema.optional(),
|
|
89
|
-
response: schemaReferenceSchema.optional(),
|
|
90
|
-
produces: z.array(z.string().min(1)).optional(),
|
|
91
|
-
consumes: z.array(z.string().min(1)).optional()
|
|
92
|
-
});
|
|
93
|
-
var restApiContractSchema = z.object({
|
|
94
|
-
basePath: z.string().min(1),
|
|
95
|
-
routes: z.record(restRouteContractSchema)
|
|
96
|
-
});
|
|
97
|
-
var apiContractSchema = z.object({
|
|
98
|
-
rest: restApiContractSchema.optional()
|
|
36
|
+
var MIND_NAMESPACE_PREFIX = "mind:";
|
|
37
|
+
var ChunkConfigSchema = z.object({
|
|
38
|
+
/** Target chunk size in tokens. */
|
|
39
|
+
maxTokens: z.number().int().positive().default(400),
|
|
40
|
+
/** Overlap between adjacent chunks, in tokens. */
|
|
41
|
+
overlapTokens: z.number().int().nonnegative().default(50),
|
|
42
|
+
/** Use AST-aware chunking where a parser exists (falls back to sliding window). */
|
|
43
|
+
ast: z.boolean().default(true)
|
|
99
44
|
});
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
|
|
45
|
+
var ModeBudgetSchema = z.object({
|
|
46
|
+
/** Max chunks fed into the answer stage. */
|
|
47
|
+
maxChunks: z.number().int().positive(),
|
|
48
|
+
/** Max sub-queries from decomposition (0 = no decomposition). */
|
|
49
|
+
maxSubqueries: z.number().int().nonnegative(),
|
|
50
|
+
/** Completeness-check iterations. */
|
|
51
|
+
maxIterations: z.number().int().nonnegative(),
|
|
52
|
+
/** Whether the synthesize stage calls the LLM. */
|
|
53
|
+
useLLM: z.boolean()
|
|
54
|
+
});
|
|
55
|
+
var ModesConfigSchema = z.object({
|
|
56
|
+
instant: ModeBudgetSchema.default({
|
|
57
|
+
maxChunks: 5,
|
|
58
|
+
maxSubqueries: 0,
|
|
59
|
+
maxIterations: 0,
|
|
60
|
+
useLLM: false
|
|
61
|
+
}),
|
|
62
|
+
auto: ModeBudgetSchema.default({
|
|
63
|
+
maxChunks: 8,
|
|
64
|
+
maxSubqueries: 3,
|
|
65
|
+
maxIterations: 1,
|
|
66
|
+
useLLM: true
|
|
67
|
+
}),
|
|
68
|
+
thinking: ModeBudgetSchema.default({
|
|
69
|
+
maxChunks: 12,
|
|
70
|
+
maxSubqueries: 5,
|
|
71
|
+
maxIterations: 3,
|
|
72
|
+
useLLM: true
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
var RetrievalConfigSchema = z.object({
|
|
76
|
+
/** Default number of results returned by `search`. */
|
|
77
|
+
limit: z.number().int().positive().default(10),
|
|
78
|
+
/** Reciprocal-rank-fusion constant. */
|
|
79
|
+
rrfK: z.number().int().positive().default(60),
|
|
80
|
+
/** Enable heuristic reranking of fused candidates. */
|
|
81
|
+
rerank: z.boolean().default(true),
|
|
82
|
+
/** Enable semantic dedup of retrieved chunks. */
|
|
83
|
+
dedup: z.boolean().default(true),
|
|
84
|
+
/**
|
|
85
|
+
* HyDE (Hypothetical Document Embeddings): embed an LLM-generated hypothetical
|
|
86
|
+
* answer instead of the raw query for the vector search (BM25 still uses the
|
|
87
|
+
* raw query). Trades one LLM call per query for better concept-query recall.
|
|
88
|
+
* Off by default — enable only where the bench A/B shows a lift.
|
|
89
|
+
*/
|
|
90
|
+
hyde: z.boolean().default(false),
|
|
91
|
+
/**
|
|
92
|
+
* Query expansion: ask the LLM for related identifiers/synonyms and append
|
|
93
|
+
* them to the BM25 (lexical) query, so vocabulary mismatch between the query
|
|
94
|
+
* wording and the code/doc terms still surfaces lexical hits. Orthogonal to
|
|
95
|
+
* HyDE (which bridges the vector side). Trades one LLM call per query.
|
|
96
|
+
* Off by default — enable only where the bench A/B shows a lift.
|
|
97
|
+
*/
|
|
98
|
+
expand: z.boolean().default(false)
|
|
99
|
+
});
|
|
100
|
+
var ConfidenceConfigSchema = z.object({
|
|
101
|
+
/** Below this, agent answers abstain in strict mode. */
|
|
102
|
+
floor: z.number().min(0).max(1).default(0.3)
|
|
103
|
+
});
|
|
104
|
+
var IndexScopeSchema = z.union([
|
|
105
|
+
z.string(),
|
|
106
|
+
z.object({
|
|
107
|
+
include: z.array(z.string()).optional(),
|
|
108
|
+
exclude: z.array(z.string()).optional()
|
|
109
|
+
}).strict()
|
|
110
|
+
]);
|
|
111
|
+
function resolveScope(scope) {
|
|
112
|
+
if (scope === void 0) {
|
|
113
|
+
return { include: ["."], exclude: [] };
|
|
114
|
+
}
|
|
115
|
+
if (typeof scope === "string") {
|
|
116
|
+
return { include: [scope], exclude: [] };
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
include: scope.include && scope.include.length > 0 ? scope.include : ["."],
|
|
120
|
+
exclude: scope.exclude ?? []
|
|
121
|
+
};
|
|
161
122
|
}
|
|
123
|
+
var IndexConfigSchema = z.object({
|
|
124
|
+
/** Path/glob or include/exclude set indexed into this index (CLI `--scope` overrides). */
|
|
125
|
+
scope: IndexScopeSchema.optional(),
|
|
126
|
+
/** Human label (optional, for status/UX). */
|
|
127
|
+
label: z.string().optional(),
|
|
128
|
+
/** Per-index chunk overrides; unset fields fall back to the global `chunk`. */
|
|
129
|
+
chunk: ChunkConfigSchema.partial().optional(),
|
|
130
|
+
/** Per-index retrieval overrides; unset fields fall back to global `retrieval`. */
|
|
131
|
+
retrieval: RetrievalConfigSchema.partial().optional()
|
|
132
|
+
});
|
|
133
|
+
var MindConfigSchema = z.object({
|
|
134
|
+
/** Default index used when a command omits `--index`. */
|
|
135
|
+
defaultIndex: z.string().default("default"),
|
|
136
|
+
/** Named indexes with per-index scope + overrides. */
|
|
137
|
+
indexes: z.record(z.string(), IndexConfigSchema).default({}),
|
|
138
|
+
chunk: ChunkConfigSchema.default({}),
|
|
139
|
+
retrieval: RetrievalConfigSchema.default({}),
|
|
140
|
+
modes: ModesConfigSchema.default({}),
|
|
141
|
+
confidence: ConfidenceConfigSchema.default({})
|
|
142
|
+
});
|
|
143
|
+
function effectiveIndexConfig(config, indexId) {
|
|
144
|
+
const idx = config.indexes[indexId];
|
|
145
|
+
return {
|
|
146
|
+
scope: resolveScope(idx?.scope),
|
|
147
|
+
chunk: { ...config.chunk, ...idx?.chunk },
|
|
148
|
+
retrieval: { ...config.retrieval, ...idx?.retrieval }
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function resolveMindConfig(input) {
|
|
152
|
+
return MindConfigSchema.parse(input ?? {});
|
|
153
|
+
}
|
|
154
|
+
var StageTraceSchema = z.object({
|
|
155
|
+
/** Stage name, e.g. 'retrieve', 'fuse', 'rerank', 'verify', 'synthesize'. */
|
|
156
|
+
stage: z.string(),
|
|
157
|
+
/** Wall-clock duration of the stage, in milliseconds. */
|
|
158
|
+
durationMs: z.number(),
|
|
159
|
+
/** Number of items the stage produced (chunks, candidates, …). */
|
|
160
|
+
outputCount: z.number().optional(),
|
|
161
|
+
/** Free-form, stage-specific detail (scores, weights, decisions). */
|
|
162
|
+
detail: z.record(z.unknown()).optional()
|
|
163
|
+
});
|
|
164
|
+
var TraceSchema = z.object({
|
|
165
|
+
requestId: z.string(),
|
|
166
|
+
mode: z.string(),
|
|
167
|
+
totalMs: z.number(),
|
|
168
|
+
stages: z.array(StageTraceSchema)
|
|
169
|
+
});
|
|
170
|
+
var JSON_DESC = "Output JSON";
|
|
171
|
+
var INDEX_DESC = "Index/corpus id";
|
|
172
|
+
var FORMAT_DESC = "Output format";
|
|
173
|
+
var SNIPPET_DESC = "How much source text per result";
|
|
174
|
+
var indexFlags = defineFlags({
|
|
175
|
+
index: { type: "string", description: INDEX_DESC, examples: ["code", "docs"] },
|
|
176
|
+
scope: { type: "string", description: "Glob/path scope to index", examples: ["src/**", "docs/**"] },
|
|
177
|
+
root: { type: "string", description: "Project root to index (default: cwd)", examples: ["/path/to/repo"] },
|
|
178
|
+
full: { type: "boolean", description: "Full rebuild instead of incremental delta", default: false },
|
|
179
|
+
json: { type: "boolean", description: JSON_DESC, default: false }
|
|
180
|
+
});
|
|
181
|
+
var searchFlags = defineFlags({
|
|
182
|
+
text: { type: "string", description: "Query text", required: true },
|
|
183
|
+
index: { type: "string", description: `${INDEX_DESC} to search` },
|
|
184
|
+
intent: { type: "string", description: "Query intent hint", examples: ["lookup", "concept", "architecture"] },
|
|
185
|
+
limit: { type: "number", description: "Max results" },
|
|
186
|
+
snippet: { type: "string", description: SNIPPET_DESC, examples: ["none", "line", "full"] },
|
|
187
|
+
format: { type: "string", description: FORMAT_DESC, examples: ["text", "json"] },
|
|
188
|
+
json: { type: "boolean", description: `${JSON_DESC} (alias for --format json)`, default: false }
|
|
189
|
+
});
|
|
190
|
+
var askFlags = defineFlags({
|
|
191
|
+
text: { type: "string", description: "Question to answer", required: true },
|
|
192
|
+
index: { type: "string", description: `${INDEX_DESC} to query` },
|
|
193
|
+
mode: { type: "string", description: "Answer depth", examples: ["instant", "auto", "thinking"] },
|
|
194
|
+
snippet: { type: "string", description: SNIPPET_DESC, examples: ["none", "line", "full"] },
|
|
195
|
+
format: { type: "string", description: FORMAT_DESC, examples: ["text", "json"] },
|
|
196
|
+
agent: { type: "boolean", description: "Emit machine-readable agent JSON (alias for --format json)", default: false },
|
|
197
|
+
json: { type: "boolean", description: JSON_DESC, default: false }
|
|
198
|
+
});
|
|
199
|
+
var exploreFlags = defineFlags({
|
|
200
|
+
task: { type: "string", description: "The task to orient around", required: true },
|
|
201
|
+
index: { type: "string", description: `${INDEX_DESC} to explore` },
|
|
202
|
+
limit: { type: "number", description: "Max files in the map" },
|
|
203
|
+
format: { type: "string", description: FORMAT_DESC, examples: ["text", "json"] },
|
|
204
|
+
json: { type: "boolean", description: `${JSON_DESC} (alias for --format json)`, default: false }
|
|
205
|
+
});
|
|
206
|
+
var syncPathsFlags = defineFlags({
|
|
207
|
+
index: { type: "string", description: INDEX_DESC },
|
|
208
|
+
json: { type: "boolean", description: JSON_DESC, default: false }
|
|
209
|
+
});
|
|
210
|
+
var syncDeleteFlags = defineFlags({
|
|
211
|
+
index: { type: "string", description: INDEX_DESC },
|
|
212
|
+
yes: { type: "boolean", description: "Confirm deletion (recoverable via `kb mind sync add`)", default: false },
|
|
213
|
+
json: { type: "boolean", description: JSON_DESC, default: false }
|
|
214
|
+
});
|
|
215
|
+
var syncListFlags = defineFlags({
|
|
216
|
+
index: { type: "string", description: INDEX_DESC },
|
|
217
|
+
json: { type: "boolean", description: JSON_DESC, default: false }
|
|
218
|
+
});
|
|
219
|
+
var reindexFlags = defineFlags({
|
|
220
|
+
index: { type: "string", description: INDEX_DESC },
|
|
221
|
+
full: { type: "boolean", description: "Full rebuild", default: false },
|
|
222
|
+
json: { type: "boolean", description: JSON_DESC, default: false }
|
|
223
|
+
});
|
|
224
|
+
var statusFlags = defineFlags({
|
|
225
|
+
index: { type: "string", description: "Limit to a single index" },
|
|
226
|
+
json: { type: "boolean", description: JSON_DESC, default: false }
|
|
227
|
+
});
|
|
228
|
+
var dropFlags = defineFlags({
|
|
229
|
+
index: { type: "string", description: "Index to drop (vectors + manifest)", required: true },
|
|
230
|
+
yes: { type: "boolean", description: "Skip the confirmation prompt", default: false },
|
|
231
|
+
json: { type: "boolean", description: JSON_DESC, default: false }
|
|
232
|
+
});
|
|
233
|
+
var AgentQueryModeSchema = z.enum(["instant", "auto", "thinking"]);
|
|
234
|
+
var AgentSourceKindSchema = z.enum(["file", "doc", "adr", "repo", "code", "config", "external"]);
|
|
235
|
+
var MatchedBySchema = z.enum(["lexical", "semantic", "both"]);
|
|
236
|
+
var AgentWarningSchema = z.object({
|
|
237
|
+
code: z.string(),
|
|
238
|
+
message: z.string(),
|
|
239
|
+
details: z.record(z.unknown()).optional()
|
|
240
|
+
});
|
|
241
|
+
var AgentSourceSchema = z.object({
|
|
242
|
+
file: z.string(),
|
|
243
|
+
lines: z.tuple([z.number(), z.number()]),
|
|
244
|
+
kind: AgentSourceKindSchema,
|
|
245
|
+
matchedBy: MatchedBySchema,
|
|
246
|
+
/** On-disk content drifted from the index → agent should re-read the live file. */
|
|
247
|
+
stale: z.boolean(),
|
|
248
|
+
snippet: z.string().optional()
|
|
249
|
+
});
|
|
250
|
+
var AgentMetaSchema = z.object({
|
|
251
|
+
requestId: z.string(),
|
|
252
|
+
mode: AgentQueryModeSchema,
|
|
253
|
+
timingMs: z.number(),
|
|
254
|
+
indexId: z.string()
|
|
255
|
+
}).passthrough();
|
|
256
|
+
var AgentResponseSchema = z.object({
|
|
257
|
+
answer: z.string(),
|
|
258
|
+
confidence: z.number(),
|
|
259
|
+
/** True when confidence is below floor / no usable sources — do not trust the answer. */
|
|
260
|
+
abstained: z.boolean(),
|
|
261
|
+
sources: z.array(AgentSourceSchema),
|
|
262
|
+
warnings: z.array(AgentWarningSchema).optional(),
|
|
263
|
+
meta: AgentMetaSchema
|
|
264
|
+
});
|
|
265
|
+
var AgentErrorResponseSchema = z.object({
|
|
266
|
+
error: z.object({ code: z.string(), message: z.string(), recoverable: z.boolean() }),
|
|
267
|
+
meta: AgentMetaSchema
|
|
268
|
+
});
|
|
269
|
+
var CONFIDENCE_THRESHOLDS = { high: 0.8, medium: 0.6, low: 0.3 };
|
|
270
|
+
var SnippetModeSchema = z.enum(["none", "line", "full"]);
|
|
271
|
+
var SearchRequestSchema = z.object({
|
|
272
|
+
text: z.string().min(1),
|
|
273
|
+
indexId: z.string().optional(),
|
|
274
|
+
/** Optional query-intent hint for adaptive fusion weights. */
|
|
275
|
+
intent: z.enum(["lookup", "concept", "architecture"]).optional(),
|
|
276
|
+
limit: z.coerce.number().int().positive().optional(),
|
|
277
|
+
// CLI passes strings; REST passes numbers
|
|
278
|
+
snippet: SnippetModeSchema.optional()
|
|
279
|
+
});
|
|
280
|
+
var SearchResultSchema = z.object({
|
|
281
|
+
file: z.string(),
|
|
282
|
+
lines: z.tuple([z.number(), z.number()]),
|
|
283
|
+
kind: AgentSourceKindSchema,
|
|
284
|
+
matchedBy: MatchedBySchema,
|
|
285
|
+
stale: z.boolean(),
|
|
286
|
+
snippet: z.string().optional()
|
|
287
|
+
});
|
|
288
|
+
var SearchMetaSchema = z.object({
|
|
289
|
+
requestId: z.string(),
|
|
290
|
+
timingMs: z.number(),
|
|
291
|
+
/** Share of results found semantic-only (grep would miss) — proof of value. */
|
|
292
|
+
semanticWinRate: z.number(),
|
|
293
|
+
/** How many returned results have drifted on disk since indexing. */
|
|
294
|
+
staleCount: z.number()
|
|
295
|
+
}).passthrough();
|
|
296
|
+
var SearchResponseSchema = z.object({
|
|
297
|
+
results: z.array(SearchResultSchema),
|
|
298
|
+
// ordered by rank
|
|
299
|
+
/** Overall retrieval relevance (0..1) — "did this index have anything for me". */
|
|
300
|
+
confidence: z.number(),
|
|
301
|
+
indexId: z.string(),
|
|
302
|
+
meta: SearchMetaSchema
|
|
303
|
+
});
|
|
304
|
+
var IndexRequestSchema = z.object({
|
|
305
|
+
/** Index/corpus id; defaults to config.defaultIndex. */
|
|
306
|
+
indexId: z.string().optional(),
|
|
307
|
+
/** Glob/path scope to index; defaults to the whole workspace. */
|
|
308
|
+
scope: z.string().optional(),
|
|
309
|
+
/** Full rebuild instead of incremental delta. */
|
|
310
|
+
full: z.boolean().optional()
|
|
311
|
+
});
|
|
312
|
+
var IndexResponseSchema = z.object({
|
|
313
|
+
indexId: z.string(),
|
|
314
|
+
filesIndexed: z.number(),
|
|
315
|
+
chunks: z.number(),
|
|
316
|
+
durationMs: z.number()
|
|
317
|
+
});
|
|
318
|
+
var ReindexRequestSchema = z.object({
|
|
319
|
+
indexId: z.string().optional(),
|
|
320
|
+
full: z.boolean().optional()
|
|
321
|
+
});
|
|
322
|
+
var QueryRequestSchema = z.object({
|
|
323
|
+
text: z.string().min(1),
|
|
324
|
+
indexId: z.string().optional(),
|
|
325
|
+
mode: AgentQueryModeSchema.optional(),
|
|
326
|
+
snippet: SnippetModeSchema.optional()
|
|
327
|
+
});
|
|
328
|
+
var ExploreRequestSchema = z.object({
|
|
329
|
+
task: z.string().min(1),
|
|
330
|
+
indexId: z.string().optional(),
|
|
331
|
+
limit: z.coerce.number().int().positive().optional()
|
|
332
|
+
});
|
|
333
|
+
var ExploreEntrySchema = z.object({
|
|
334
|
+
file: z.string(),
|
|
335
|
+
lines: z.tuple([z.number(), z.number()]),
|
|
336
|
+
/** What was matched here — the representative line (from retrieval, not rules). */
|
|
337
|
+
why: z.string(),
|
|
338
|
+
matchedBy: MatchedBySchema,
|
|
339
|
+
stale: z.boolean()
|
|
340
|
+
});
|
|
341
|
+
var ExploreMetaSchema = z.object({
|
|
342
|
+
requestId: z.string(),
|
|
343
|
+
timingMs: z.number(),
|
|
344
|
+
/** Distinct files in the map. */
|
|
345
|
+
filesTouched: z.number(),
|
|
346
|
+
/** Distinct directories the files span — a structural "how spread out" hint. */
|
|
347
|
+
spread: z.number()
|
|
348
|
+
}).passthrough();
|
|
349
|
+
var ExploreResponseSchema = z.object({
|
|
350
|
+
task: z.string(),
|
|
351
|
+
indexId: z.string(),
|
|
352
|
+
confidence: z.number(),
|
|
353
|
+
/** Model-synthesized orientation: where to start + how involved (empty if no LLM). */
|
|
354
|
+
summary: z.string(),
|
|
355
|
+
/** Relevant files, best-ranked first. */
|
|
356
|
+
files: z.array(ExploreEntrySchema),
|
|
357
|
+
meta: ExploreMetaSchema
|
|
358
|
+
});
|
|
359
|
+
var DropRequestSchema = z.object({
|
|
360
|
+
indexId: z.string().min(1)
|
|
361
|
+
});
|
|
362
|
+
var DropResponseSchema = z.object({
|
|
363
|
+
indexId: z.string(),
|
|
364
|
+
/** Vectors removed from the store. */
|
|
365
|
+
droppedChunks: z.number(),
|
|
366
|
+
/** Documents that were in the manifest. */
|
|
367
|
+
droppedFiles: z.number()
|
|
368
|
+
});
|
|
369
|
+
var indexIdField = z.string().optional();
|
|
370
|
+
var SyncAddRequestSchema = z.object({
|
|
371
|
+
paths: z.array(z.string()).min(1),
|
|
372
|
+
indexId: indexIdField
|
|
373
|
+
});
|
|
374
|
+
var SyncUpdateRequestSchema = z.object({
|
|
375
|
+
paths: z.array(z.string()).min(1),
|
|
376
|
+
indexId: indexIdField
|
|
377
|
+
});
|
|
378
|
+
var SyncDeleteRequestSchema = z.object({
|
|
379
|
+
paths: z.array(z.string()).min(1),
|
|
380
|
+
indexId: indexIdField
|
|
381
|
+
});
|
|
382
|
+
var SyncResponseSchema = z.object({
|
|
383
|
+
indexId: z.string(),
|
|
384
|
+
added: z.number(),
|
|
385
|
+
updated: z.number(),
|
|
386
|
+
deleted: z.number()
|
|
387
|
+
});
|
|
388
|
+
var SyncedDocumentSchema = z.object({
|
|
389
|
+
path: z.string(),
|
|
390
|
+
chunks: z.number(),
|
|
391
|
+
indexedAt: z.string()
|
|
392
|
+
});
|
|
393
|
+
var SyncListResponseSchema = z.object({
|
|
394
|
+
indexId: z.string(),
|
|
395
|
+
documents: z.array(SyncedDocumentSchema)
|
|
396
|
+
});
|
|
397
|
+
var SyncStatusResponseSchema = z.object({
|
|
398
|
+
indexId: z.string(),
|
|
399
|
+
documents: z.number(),
|
|
400
|
+
chunks: z.number(),
|
|
401
|
+
lastIndexedAt: z.string().nullable(),
|
|
402
|
+
stale: z.boolean()
|
|
403
|
+
});
|
|
404
|
+
var IndexSummarySchema = z.object({
|
|
405
|
+
indexId: z.string(),
|
|
406
|
+
/** Human label + what the index covers (scope) — lets an agent pick the right corpus. */
|
|
407
|
+
label: z.string().optional(),
|
|
408
|
+
coverage: z.string().optional(),
|
|
409
|
+
documents: z.number(),
|
|
410
|
+
chunks: z.number(),
|
|
411
|
+
lastIndexedAt: z.string().nullable(),
|
|
412
|
+
/** How many indexed files have drifted on disk since indexing. */
|
|
413
|
+
staleCount: z.number()
|
|
414
|
+
});
|
|
415
|
+
var StatusResponseSchema = z.object({
|
|
416
|
+
indexes: z.array(IndexSummarySchema),
|
|
417
|
+
healthy: z.boolean()
|
|
418
|
+
});
|
|
419
|
+
var HealthResponseSchema = z.object({
|
|
420
|
+
ok: z.boolean(),
|
|
421
|
+
vectorStore: z.boolean(),
|
|
422
|
+
embeddings: z.boolean(),
|
|
423
|
+
llm: z.boolean()
|
|
424
|
+
});
|
|
162
425
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
var commandCommonFlags = z6.object({
|
|
166
|
-
cwd: z6.string().min(1).optional(),
|
|
167
|
-
json: z6.boolean().optional(),
|
|
168
|
-
quiet: z6.boolean().optional(),
|
|
169
|
-
verbose: z6.boolean().optional()
|
|
170
|
-
});
|
|
171
|
-
var budgetEnvelopeSchema = z6.object({
|
|
172
|
-
usedMs: z6.number().nonnegative().optional(),
|
|
173
|
-
limitMs: z6.number().nonnegative().optional()
|
|
174
|
-
});
|
|
175
|
-
var MindInitCommandInputSchema = commandCommonFlags.extend({
|
|
176
|
-
force: z6.boolean().optional()
|
|
177
|
-
});
|
|
178
|
-
var MindUpdateCommandInputSchema = commandCommonFlags.extend({
|
|
179
|
-
since: z6.string().optional(),
|
|
180
|
-
"time-budget": z6.number().int().positive().optional(),
|
|
181
|
-
"no-cache": z6.boolean().optional()
|
|
182
|
-
});
|
|
183
|
-
var MindUpdateCommandOutputSchema = z6.object({
|
|
184
|
-
ok: z6.boolean(),
|
|
185
|
-
delta: z6.unknown().optional(),
|
|
186
|
-
budget: budgetEnvelopeSchema.optional(),
|
|
187
|
-
timing: z6.number().nonnegative().optional(),
|
|
188
|
-
code: z6.string().optional(),
|
|
189
|
-
message: z6.string().optional(),
|
|
190
|
-
hint: z6.string().optional()
|
|
191
|
-
});
|
|
192
|
-
var packIntentSchema = z6.object({
|
|
193
|
-
intent: z6.string().min(1),
|
|
194
|
-
product: z6.string().optional(),
|
|
195
|
-
preset: z6.string().optional(),
|
|
196
|
-
budget: z6.number().int().positive().optional(),
|
|
197
|
-
"with-bundle": z6.boolean().optional(),
|
|
198
|
-
out: z6.string().optional(),
|
|
199
|
-
seed: z6.number().int().optional()
|
|
200
|
-
});
|
|
201
|
-
var MindPackCommandInputSchema = commandCommonFlags.merge(packIntentSchema);
|
|
202
|
-
var MindPackCommandOutputSchema = z6.object({
|
|
203
|
-
ok: z6.boolean(),
|
|
204
|
-
intent: z6.string().optional(),
|
|
205
|
-
product: z6.string().nullable().optional(),
|
|
206
|
-
tokensEstimate: z6.number().optional(),
|
|
207
|
-
sectionUsage: z6.record(z6.unknown()).optional(),
|
|
208
|
-
"with-bundle": z6.boolean().optional(),
|
|
209
|
-
seed: z6.number().optional(),
|
|
210
|
-
deterministic: z6.boolean().optional(),
|
|
211
|
-
timing: z6.number().nonnegative().optional(),
|
|
212
|
-
"pack-output": z6.string().optional(),
|
|
213
|
-
code: z6.string().optional(),
|
|
214
|
-
message: z6.string().optional(),
|
|
215
|
-
hint: z6.string().optional()
|
|
216
|
-
});
|
|
217
|
-
var MindFeedCommandInputSchema = commandCommonFlags.merge(packIntentSchema).extend({
|
|
218
|
-
"no-update": z6.boolean().optional(),
|
|
219
|
-
since: z6.string().optional(),
|
|
220
|
-
"time-budget": z6.number().int().positive().optional()
|
|
221
|
-
});
|
|
222
|
-
var MindFeedCommandOutputSchema = z6.object({
|
|
223
|
-
ok: z6.boolean(),
|
|
224
|
-
mode: z6.enum(["update-and-pack", "pack-only"]).optional(),
|
|
225
|
-
intent: z6.string().optional(),
|
|
226
|
-
product: z6.string().nullable().optional(),
|
|
227
|
-
tokensEstimate: z6.number().optional(),
|
|
228
|
-
out: z6.string().nullable().optional(),
|
|
229
|
-
update: z6.object({
|
|
230
|
-
delta: z6.unknown().optional(),
|
|
231
|
-
budget: budgetEnvelopeSchema.optional()
|
|
232
|
-
}).nullable().optional(),
|
|
233
|
-
pack: z6.object({
|
|
234
|
-
sectionUsage: z6.record(z6.unknown()).optional(),
|
|
235
|
-
deterministic: z6.boolean().optional()
|
|
236
|
-
}).optional(),
|
|
237
|
-
ignoredFlags: z6.array(z6.string()).optional(),
|
|
238
|
-
timing: z6.number().nonnegative().optional(),
|
|
239
|
-
"pack-output": z6.string().optional(),
|
|
240
|
-
code: z6.string().optional(),
|
|
241
|
-
message: z6.string().optional(),
|
|
242
|
-
hint: z6.string().optional()
|
|
243
|
-
});
|
|
244
|
-
var MindQueryCommandInputSchema = commandCommonFlags.extend({
|
|
245
|
-
query: z6.enum(["impact", "scope", "exports", "externals", "chain", "meta", "docs"]),
|
|
246
|
-
file: z6.string().optional(),
|
|
247
|
-
path: z6.string().optional(),
|
|
248
|
-
scope: z6.string().optional(),
|
|
249
|
-
limit: z6.number().int().positive().optional(),
|
|
250
|
-
depth: z6.number().int().positive().optional(),
|
|
251
|
-
"cache-ttl": z6.number().int().nonnegative().optional(),
|
|
252
|
-
"cache-mode": z6.enum(["ci", "local"]).optional(),
|
|
253
|
-
"no-cache": z6.boolean().optional(),
|
|
254
|
-
paths: z6.enum(["id", "absolute"]).optional(),
|
|
255
|
-
compact: z6.boolean().optional(),
|
|
256
|
-
"ai-mode": z6.boolean().optional(),
|
|
257
|
-
toon: z6.boolean().optional(),
|
|
258
|
-
"toon-sidecar": z6.boolean().optional(),
|
|
259
|
-
product: z6.string().optional(),
|
|
260
|
-
tag: z6.string().optional(),
|
|
261
|
-
type: z6.string().optional(),
|
|
262
|
-
filter: z6.string().optional()
|
|
263
|
-
});
|
|
264
|
-
var MindQueryCommandOutputSchema = z6.object({
|
|
265
|
-
ok: z6.boolean().optional(),
|
|
266
|
-
format: z6.enum(["json", "toon"]).optional(),
|
|
267
|
-
content: z6.union([z6.string(), z6.record(z6.unknown())]).optional(),
|
|
268
|
-
error: z6.string().optional()
|
|
269
|
-
});
|
|
270
|
-
var MindVerifyCommandInputSchema = commandCommonFlags.extend({
|
|
271
|
-
cwd: z6.string().optional()
|
|
272
|
-
});
|
|
273
|
-
var MindVerifyCommandOutputSchema = z6.object({
|
|
274
|
-
ok: z6.boolean(),
|
|
275
|
-
code: z6.string().nullable().optional(),
|
|
276
|
-
inconsistencies: z6.array(
|
|
277
|
-
z6.object({
|
|
278
|
-
file: z6.string().optional(),
|
|
279
|
-
expected: z6.string().optional(),
|
|
280
|
-
actual: z6.string().optional(),
|
|
281
|
-
type: z6.string().optional()
|
|
282
|
-
})
|
|
283
|
-
).optional(),
|
|
284
|
-
hint: z6.string().optional(),
|
|
285
|
-
schemaVersion: z6.string().optional(),
|
|
286
|
-
meta: z6.object({
|
|
287
|
-
cwd: z6.string().optional(),
|
|
288
|
-
filesChecked: z6.number().optional(),
|
|
289
|
-
timingMs: z6.number().optional()
|
|
290
|
-
}).optional()
|
|
291
|
-
});
|
|
292
|
-
var MindQueryRequestSchema = z6.object({
|
|
293
|
-
query: z6.string().min(1),
|
|
294
|
-
params: z6.record(z6.unknown()).optional().default({}),
|
|
295
|
-
options: z6.object({
|
|
296
|
-
cwd: z6.string().optional(),
|
|
297
|
-
limit: z6.number().optional(),
|
|
298
|
-
depth: z6.number().optional(),
|
|
299
|
-
cacheTtl: z6.number().optional(),
|
|
300
|
-
cacheMode: z6.enum(["local", "ci"]).optional(),
|
|
301
|
-
noCache: z6.boolean().optional(),
|
|
302
|
-
pathMode: z6.enum(["id", "absolute"]).optional(),
|
|
303
|
-
aiMode: z6.boolean().optional()
|
|
304
|
-
}).optional()
|
|
305
|
-
});
|
|
306
|
-
var MindQueryResponseSchema = z6.object({
|
|
307
|
-
sections: z6.array(
|
|
308
|
-
z6.object({
|
|
309
|
-
title: z6.string(),
|
|
310
|
-
format: z6.string().optional(),
|
|
311
|
-
data: z6.unknown(),
|
|
312
|
-
collapsible: z6.boolean().optional()
|
|
313
|
-
})
|
|
314
|
-
)
|
|
315
|
-
});
|
|
316
|
-
var MindVerifyResponseSchema = z6.object({
|
|
317
|
-
cards: z6.array(
|
|
318
|
-
z6.object({
|
|
319
|
-
title: z6.string(),
|
|
320
|
-
content: z6.string(),
|
|
321
|
-
status: z6.string().optional()
|
|
322
|
-
})
|
|
323
|
-
)
|
|
324
|
-
});
|
|
325
|
-
export {
|
|
326
|
-
MindFeedCommandInputSchema,
|
|
327
|
-
MindFeedCommandOutputSchema,
|
|
328
|
-
MindInitCommandInputSchema,
|
|
329
|
-
MindPackCommandInputSchema,
|
|
330
|
-
MindPackCommandOutputSchema,
|
|
331
|
-
MindQueryCommandInputSchema,
|
|
332
|
-
MindQueryCommandOutputSchema,
|
|
333
|
-
MindQueryRequestSchema,
|
|
334
|
-
MindQueryResponseSchema,
|
|
335
|
-
MindUpdateCommandInputSchema,
|
|
336
|
-
MindUpdateCommandOutputSchema,
|
|
337
|
-
MindVerifyCommandInputSchema,
|
|
338
|
-
MindVerifyCommandOutputSchema,
|
|
339
|
-
MindVerifyResponseSchema,
|
|
340
|
-
apiContractSchema,
|
|
341
|
-
artifactContractSchema,
|
|
342
|
-
artifactExampleSchema,
|
|
343
|
-
artifactsContractMapSchema,
|
|
344
|
-
commandContractMapSchema,
|
|
345
|
-
commandContractSchema,
|
|
346
|
-
contractsSchemaId,
|
|
347
|
-
contractsVersion,
|
|
348
|
-
defaultMindSyncConfig,
|
|
349
|
-
parsePluginContracts,
|
|
350
|
-
pluginContractsManifest,
|
|
351
|
-
pluginContractsSchema,
|
|
352
|
-
restApiContractSchema,
|
|
353
|
-
restRouteContractSchema,
|
|
354
|
-
schemaReferenceSchema,
|
|
355
|
-
workflowContractMapSchema,
|
|
356
|
-
workflowContractSchema,
|
|
357
|
-
workflowStepSchema
|
|
358
|
-
};
|
|
426
|
+
export { AgentErrorResponseSchema, AgentMetaSchema, AgentQueryModeSchema, AgentResponseSchema, AgentSourceKindSchema, AgentSourceSchema, AgentWarningSchema, CONFIDENCE_THRESHOLDS, ChunkConfigSchema, ConfidenceConfigSchema, DropRequestSchema, DropResponseSchema, ExploreEntrySchema, ExploreMetaSchema, ExploreRequestSchema, ExploreResponseSchema, HealthResponseSchema, IndexConfigSchema, IndexRequestSchema, IndexResponseSchema, IndexScopeSchema, IndexSummarySchema, MIND_BASE_PATH, MIND_FULL_ROUTES, MIND_NAMESPACE_PREFIX, MIND_ROUTES, MatchedBySchema, MindConfigSchema, ModeBudgetSchema, ModesConfigSchema, QueryRequestSchema, ReindexRequestSchema, RetrievalConfigSchema, SearchMetaSchema, SearchRequestSchema, SearchResponseSchema, SearchResultSchema, SnippetModeSchema, StageTraceSchema, StatusResponseSchema, SyncAddRequestSchema, SyncDeleteRequestSchema, SyncListResponseSchema, SyncResponseSchema, SyncStatusResponseSchema, SyncUpdateRequestSchema, SyncedDocumentSchema, TraceSchema, askFlags, dropFlags, effectiveIndexConfig, exploreFlags, indexFlags, reindexFlags, resolveMindConfig, resolveScope, searchFlags, statusFlags, syncDeleteFlags, syncListFlags, syncPathsFlags };
|
|
427
|
+
//# sourceMappingURL=index.js.map
|
|
359
428
|
//# sourceMappingURL=index.js.map
|