@mossbear/protocol 0.1.0-alpha.114 → 0.1.0-alpha.115
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/dist/comments.d.ts +1405 -0
- package/dist/comments.d.ts.map +1 -0
- package/dist/comments.js +683 -0
- package/dist/comments.js.map +1 -0
- package/dist/comments.test.d.ts +2 -0
- package/dist/comments.test.d.ts.map +1 -0
- package/dist/comments.test.js +64 -0
- package/dist/comments.test.js.map +1 -0
- package/dist/pairing.d.ts +1 -1
- package/dist/schemas.d.ts +160 -4720
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +7 -1417
- package/dist/schemas.js.map +1 -1
- package/dist/search.d.ts +1222 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +474 -0
- package/dist/search.js.map +1 -0
- package/dist/search.test.d.ts +2 -0
- package/dist/search.test.d.ts.map +1 -0
- package/dist/search.test.js +64 -0
- package/dist/search.test.js.map +1 -0
- package/dist/sessionContracts.test.d.ts +2 -0
- package/dist/sessionContracts.test.d.ts.map +1 -0
- package/dist/sessionContracts.test.js +75 -0
- package/dist/sessionContracts.test.js.map +1 -0
- package/dist/sessionDigest.d.ts +149 -0
- package/dist/sessionDigest.d.ts.map +1 -0
- package/dist/sessionDigest.js +57 -0
- package/dist/sessionDigest.js.map +1 -0
- package/dist/sessionGrade.d.ts +184 -0
- package/dist/sessionGrade.d.ts.map +1 -0
- package/dist/sessionGrade.js +130 -0
- package/dist/sessionGrade.js.map +1 -0
- package/dist/usageOnly.d.ts +5 -5
- package/dist/wirePrimitives.d.ts +86 -0
- package/dist/wirePrimitives.d.ts.map +1 -0
- package/dist/wirePrimitives.js +89 -0
- package/dist/wirePrimitives.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS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CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEvE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEhD"}
|
package/dist/search.js
ADDED
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { NonEmptyStringSchema, CommentAuthorKindSchema, GuideHistoryUntrustedSchema, SessionGuideVerdictValueSchema, } from './wirePrimitives.js';
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Search — one term across the caller's evidence (`GET /api/v1/search`)
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
/**
|
|
7
|
+
* The corpora a search can reach today.
|
|
8
|
+
*
|
|
9
|
+
* `guides` is guide bodies and their author-written eval criteria; `verdicts`
|
|
10
|
+
* is the grader's reasoning for why a session did or did not follow a guide;
|
|
11
|
+
* `content` is the name and body of the documents saved in bundles; `comments`
|
|
12
|
+
* is the text of comments left on guides and documents and, for a caller that
|
|
13
|
+
* reads them (`SearchRequest.sessionComments`), on its own sessions; `turns` is what the
|
|
14
|
+
* caller themself said to their agents, redacted; `sessions` is the grader's
|
|
15
|
+
* summary of the caller's own sessions and the agent's closing report. One
|
|
16
|
+
* registry on the server declares how each is matched and scoped; this list is
|
|
17
|
+
* only what a caller may name.
|
|
18
|
+
*/
|
|
19
|
+
export const SEARCH_CORPUS_IDS = [
|
|
20
|
+
'guides',
|
|
21
|
+
'verdicts',
|
|
22
|
+
'content',
|
|
23
|
+
'comments',
|
|
24
|
+
'turns',
|
|
25
|
+
'sessions',
|
|
26
|
+
];
|
|
27
|
+
export const SearchCorpusIdSchema = v.picklist(SEARCH_CORPUS_IDS);
|
|
28
|
+
/**
|
|
29
|
+
* Every stored text no search reaches yet — the actions and their narration.
|
|
30
|
+
* Every response names them, so "nothing found" can never be read as covering
|
|
31
|
+
* them. (Earlier wordings of a guide are deliberately never searched, which is a
|
|
32
|
+
* different thing from not yet.)
|
|
33
|
+
*/
|
|
34
|
+
export const SEARCH_UNIMPLEMENTED_CORPORA = ['actions'];
|
|
35
|
+
/**
|
|
36
|
+
* What a response still names as not searched for a caller that did not say it
|
|
37
|
+
* reads session comments (`SearchRequest.sessionComments`): they were left out
|
|
38
|
+
* of its `comments`, so saying otherwise would read a zero as covering them.
|
|
39
|
+
*/
|
|
40
|
+
export const SEARCH_SESSION_COMMENTS_UNSEARCHED = 'session-comments';
|
|
41
|
+
export const SearchUnimplementedCorpusSchema = v.picklist(SEARCH_UNIMPLEMENTED_CORPORA);
|
|
42
|
+
/** Hits returned per corpus when the caller does not say. */
|
|
43
|
+
export const SEARCH_DEFAULT_LIMIT = 10;
|
|
44
|
+
/** The most hits one corpus returns. Totals are counted past it. */
|
|
45
|
+
export const SEARCH_MAX_LIMIT = 25;
|
|
46
|
+
/**
|
|
47
|
+
* The term. Literal, case-insensitive, with `*` and `?` as the only wildcards —
|
|
48
|
+
* not a regex, which an unindexed shared database cannot afford.
|
|
49
|
+
*
|
|
50
|
+
* At least two characters after trimming, not counting wildcards: every row
|
|
51
|
+
* matches one character (or `**`), so a shorter term is a scan with no question
|
|
52
|
+
* behind it.
|
|
53
|
+
*/
|
|
54
|
+
export const SearchTermSchema = v.pipe(v.string(), v.trim(), v.minLength(2, 'q must be at least 2 characters'), v.maxLength(200, 'q must be at most 200 characters'), v.check((value) => !/[\u0000-\u001f\u007f]/.test(value), 'q must not contain control characters'),
|
|
55
|
+
// Wildcards do not count toward the two: `**` is a pattern that matches
|
|
56
|
+
// every row, which is the scan the minimum exists to refuse.
|
|
57
|
+
v.check((value) => value.replace(/[*?]/g, '').length >= 2, 'q must contain at least 2 characters besides * and ?'));
|
|
58
|
+
/**
|
|
59
|
+
* How much of each guide hit to return — progressive disclosure, so a search
|
|
60
|
+
* costs an agent little context until it asks for more.
|
|
61
|
+
*
|
|
62
|
+
* - `excerpt` (the default): a short window around the match, kept inside the
|
|
63
|
+
* match's Markdown section, plus the section's heading path. A short section
|
|
64
|
+
* comes back whole, and a longer one says how long it is (`sectionChars`).
|
|
65
|
+
* - `section`: the whole section that holds the match, capped. Meant for one
|
|
66
|
+
* hit at a time — pass the hit's `fileId` in `fileIds`.
|
|
67
|
+
*/
|
|
68
|
+
export const SEARCH_DETAILS = ['excerpt', 'section'];
|
|
69
|
+
export const SearchDetailSchema = v.picklist(SEARCH_DETAILS);
|
|
70
|
+
/** Frontmatter filters a `content` search accepts at once. */
|
|
71
|
+
export const SEARCH_MAX_FRONTMATTER_FILTERS = 3;
|
|
72
|
+
/**
|
|
73
|
+
* One top-level frontmatter field a `content` item must carry, by exact scalar
|
|
74
|
+
* value (`type: recipe`). The key is a plain YAML key so it can be matched
|
|
75
|
+
* without being interpreted; the value is literal text, compared
|
|
76
|
+
* case-insensitively.
|
|
77
|
+
*/
|
|
78
|
+
export const SearchFrontmatterSchema = v.pipe(v.record(v.pipe(v.string(), v.regex(/^[A-Za-z][\w-]{0,39}$/, 'frontmatter keys are plain names')), v.pipe(v.string(), v.trim(), v.minLength(1, 'a frontmatter value must not be empty'), v.maxLength(100, 'a frontmatter value must be at most 100 characters'), v.check((value) => !/[\u0000-\u001f\u007f]/.test(value), 'a frontmatter value must not contain control characters'))), v.check((fields) => {
|
|
79
|
+
const count = Object.keys(fields).length;
|
|
80
|
+
return count >= 1 && count <= SEARCH_MAX_FRONTMATTER_FILTERS;
|
|
81
|
+
}, `frontmatter takes between 1 and ${SEARCH_MAX_FRONTMATTER_FILTERS} fields`));
|
|
82
|
+
/** Who wrote a comment: a person, an agent, or Mossbear itself. */
|
|
83
|
+
export const SEARCH_COMMENT_AUTHOR_KINDS = CommentAuthorKindSchema.options;
|
|
84
|
+
export const SearchCommentAuthorKindSchema = CommentAuthorKindSchema;
|
|
85
|
+
/**
|
|
86
|
+
* What a comment is attached to. `artifact` is a guide or a document; `session`
|
|
87
|
+
* is a run the caller made. Session comments are the caller's own and never reach
|
|
88
|
+
* a workspace-mate.
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* The subject kinds a client names in a search: `artifact`, never its older
|
|
92
|
+
* name `item`.
|
|
93
|
+
*/
|
|
94
|
+
export const SEARCH_COMMENT_SUBJECT_KIND_NAMES = ['artifact', 'session'];
|
|
95
|
+
export const SearchCommentSubjectKindFilterSchema = v.picklist(SEARCH_COMMENT_SUBJECT_KIND_NAMES);
|
|
96
|
+
/**
|
|
97
|
+
* What a user turn was, as the session classifier labels it. The same
|
|
98
|
+
* vocabulary the classifier writes; a `turns` search may keep only some.
|
|
99
|
+
*/
|
|
100
|
+
export const SEARCH_STEERING_LABELS = [
|
|
101
|
+
'correction',
|
|
102
|
+
'steering',
|
|
103
|
+
'new request',
|
|
104
|
+
'acknowledgement',
|
|
105
|
+
'insufficient evidence',
|
|
106
|
+
];
|
|
107
|
+
export const SearchSteeringLabelSchema = v.picklist(SEARCH_STEERING_LABELS);
|
|
108
|
+
/**
|
|
109
|
+
* One exact value a `sessions` search filters on — a head sha, a branch name or
|
|
110
|
+
* a repo digest. Compared as written, so it is trimmed and bounded but never
|
|
111
|
+
* case-folded or treated as a pattern.
|
|
112
|
+
*/
|
|
113
|
+
export const SearchSessionFilterValueSchema = v.pipe(v.string(), v.trim(), v.minLength(1, 'a session filter must not be empty'), v.maxLength(200, 'a session filter must be at most 200 characters'), v.check((value) => !/[\u0000-\u001f\u007f]/.test(value), 'a session filter must not contain control characters'));
|
|
114
|
+
export const SearchRequestObjectSchema = v.object({
|
|
115
|
+
/**
|
|
116
|
+
* The term. Optional only for a `sessions` search that names a filter (`headSha`,
|
|
117
|
+
* `branch` or `repoId`): "which session ended at this commit" has no words to match.
|
|
118
|
+
*/
|
|
119
|
+
q: v.optional(SearchTermSchema),
|
|
120
|
+
/** Which corpora to search; every one when absent. */
|
|
121
|
+
corpora: v.optional(v.pipe(v.array(SearchCorpusIdSchema), v.minLength(1))),
|
|
122
|
+
/**
|
|
123
|
+
* The bundles a scoped caller may read content from — `mossbear mcp
|
|
124
|
+
* --bundles` resolved to ids by the CLI, since the server never sees that
|
|
125
|
+
* flag. **Present means narrowed**, even when empty: an allowlist that
|
|
126
|
+
* reaches no bundle narrows the content corpora to nothing, never to
|
|
127
|
+
* everything. Absent means the caller is not bundle-scoped.
|
|
128
|
+
*/
|
|
129
|
+
bundleIds: v.optional(v.pipe(v.array(NonEmptyStringSchema), v.maxLength(200))),
|
|
130
|
+
limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(SEARCH_MAX_LIMIT))),
|
|
131
|
+
/** How much of each guide hit to return; `excerpt` when absent. */
|
|
132
|
+
detail: v.optional(SearchDetailSchema),
|
|
133
|
+
/**
|
|
134
|
+
* Restrict the guides corpus to these guide files — the `fileId`s of earlier
|
|
135
|
+
* hits, to expand them. Narrows within the caller's scope, never past it: an
|
|
136
|
+
* id the caller cannot read matches nothing. Does not touch other corpora.
|
|
137
|
+
*/
|
|
138
|
+
fileIds: v.optional(v.pipe(v.array(NonEmptyStringSchema), v.minLength(1), v.maxLength(SEARCH_MAX_LIMIT))),
|
|
139
|
+
/**
|
|
140
|
+
* Restrict the `content` corpus to items whose frontmatter carries every one
|
|
141
|
+
* of these fields. Does not touch other corpora.
|
|
142
|
+
*/
|
|
143
|
+
frontmatter: v.optional(SearchFrontmatterSchema),
|
|
144
|
+
/**
|
|
145
|
+
* Restrict the `comments` corpus to comments written by these kinds of
|
|
146
|
+
* author. Does not touch other corpora.
|
|
147
|
+
*/
|
|
148
|
+
authorKinds: v.optional(v.pipe(v.array(SearchCommentAuthorKindSchema), v.minLength(1))),
|
|
149
|
+
/**
|
|
150
|
+
* Restrict the `comments` corpus to comments on these kinds of subject. Does
|
|
151
|
+
* not touch other corpora.
|
|
152
|
+
*/
|
|
153
|
+
subjectKinds: v.optional(v.pipe(v.array(SearchCommentSubjectKindFilterSchema), v.minLength(1))),
|
|
154
|
+
/**
|
|
155
|
+
* Restrict the `turns` corpus to turns the classifier gave one of these
|
|
156
|
+
* labels. A turn with no label never matches. Does not touch other corpora.
|
|
157
|
+
*/
|
|
158
|
+
steeringLabels: v.optional(v.pipe(v.array(SearchSteeringLabelSchema), v.minLength(1))),
|
|
159
|
+
/**
|
|
160
|
+
* Restrict the `sessions` corpus to sessions whose recorded head was exactly
|
|
161
|
+
* this commit when they closed. A commit made mid-session matches nothing:
|
|
162
|
+
* the head is the one observed at close. Does not touch other corpora.
|
|
163
|
+
*/
|
|
164
|
+
headSha: v.optional(SearchSessionFilterValueSchema),
|
|
165
|
+
/** Restrict the `sessions` corpus to sessions that closed on exactly this branch. Does not touch other corpora. */
|
|
166
|
+
branch: v.optional(SearchSessionFilterValueSchema),
|
|
167
|
+
/** Restrict the `sessions` corpus to sessions recorded under exactly this repo id. Does not touch other corpora. */
|
|
168
|
+
repoId: v.optional(SearchSessionFilterValueSchema),
|
|
169
|
+
/**
|
|
170
|
+
* Whether the caller can read a `comments` hit on a session. A client from
|
|
171
|
+
* before session comments were searchable validates the whole response
|
|
172
|
+
* strictly and would reject one, so the server returns them only to a caller
|
|
173
|
+
* that says it can, and tells every other caller they were not searched.
|
|
174
|
+
* Absent means it cannot.
|
|
175
|
+
*/
|
|
176
|
+
sessionComments: v.optional(v.boolean()),
|
|
177
|
+
});
|
|
178
|
+
/**
|
|
179
|
+
* A request with no term searches the caller's sessions by filter alone, so it
|
|
180
|
+
* must name one, and must not name another corpus (which has nothing to match).
|
|
181
|
+
*/
|
|
182
|
+
export const SearchRequestSchema = v.pipe(SearchRequestObjectSchema, v.forward(v.check((request) => request.q !== undefined ||
|
|
183
|
+
request.headSha !== undefined ||
|
|
184
|
+
request.branch !== undefined ||
|
|
185
|
+
request.repoId !== undefined, 'q must be at least 2 characters (or filter sessions by headSha, branch or repoId)'), ['q']), v.forward(v.check((request) => request.q !== undefined ||
|
|
186
|
+
request.corpora === undefined ||
|
|
187
|
+
request.corpora.every((id) => id === 'sessions'), 'without q only the sessions corpus can be searched'), ['corpora']));
|
|
188
|
+
/**
|
|
189
|
+
* Why a corpus was not searched. Codes, never prose: each caller writes its own
|
|
190
|
+
* sentence, and the dashboard's has to be a translatable one.
|
|
191
|
+
*/
|
|
192
|
+
export const SearchSkipReasonSchema = v.picklist([
|
|
193
|
+
'excluded-by-caller',
|
|
194
|
+
'timed-out',
|
|
195
|
+
// The caller's token is limited to certain bundles, and grading results, the
|
|
196
|
+
// caller's turns and sessions, and comments on their sessions are never among
|
|
197
|
+
// what such a token reaches.
|
|
198
|
+
'not-granted',
|
|
199
|
+
// A filter named only kinds of subject this caller cannot be given: `session`
|
|
200
|
+
// from a client that did not say it reads session comments, which is also what
|
|
201
|
+
// a server from before they were searchable said to every caller.
|
|
202
|
+
'not-yet-searchable',
|
|
203
|
+
]);
|
|
204
|
+
/** Why a searched corpus covered less than the caller's whole scope. */
|
|
205
|
+
export const SearchNarrowingSchema = v.picklist(['narrowed-by-bundle-allowlist']);
|
|
206
|
+
/** A guide file whose text matched. The excerpt is wrapped in `untrusted`'s markers. */
|
|
207
|
+
export const SearchGuideHitSchema = v.object({
|
|
208
|
+
guideId: NonEmptyStringSchema,
|
|
209
|
+
/** Wrapped in `untrusted`'s markers; null when nothing names the guide. */
|
|
210
|
+
guideTitle: v.nullable(v.string()),
|
|
211
|
+
fileId: NonEmptyStringSchema,
|
|
212
|
+
path: v.nullable(v.string()),
|
|
213
|
+
/** The guide's own body, or its author-written eval criteria. */
|
|
214
|
+
part: v.picklist(['body', 'criteria']),
|
|
215
|
+
/**
|
|
216
|
+
* The heading path of the Markdown section that holds the match, joined with
|
|
217
|
+
* `SECTION_PATH_SEPARATOR` and wrapped in `untrusted`'s markers — a heading is
|
|
218
|
+
* file text. Null when the match sits above the first heading. Optional
|
|
219
|
+
* because a server that predates sections does not send it.
|
|
220
|
+
*/
|
|
221
|
+
section: v.optional(v.nullable(v.string())),
|
|
222
|
+
/**
|
|
223
|
+
* The whole section's length in characters, present only when `excerpt` is
|
|
224
|
+
* less than all of it — what expanding the hit would add. Null when the
|
|
225
|
+
* excerpt is the whole section. Optional for the same reason as `section`.
|
|
226
|
+
*/
|
|
227
|
+
sectionChars: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),
|
|
228
|
+
/**
|
|
229
|
+
* Around the match, cut with `…`, never past its section. By default a short
|
|
230
|
+
* window, or the whole section when that is short too; for `detail:
|
|
231
|
+
* 'section'`, the whole section, capped.
|
|
232
|
+
*/
|
|
233
|
+
excerpt: v.string(),
|
|
234
|
+
});
|
|
235
|
+
/** One session's verdict on one guide whose reasoning matched, wrapped in markers. */
|
|
236
|
+
export const SearchVerdictHitSchema = v.object({
|
|
237
|
+
sessionId: NonEmptyStringSchema,
|
|
238
|
+
guideId: NonEmptyStringSchema,
|
|
239
|
+
/**
|
|
240
|
+
* Wrapped in `untrusted`'s markers. Null when the guide is no longer one the
|
|
241
|
+
* caller can read, or nothing names it.
|
|
242
|
+
*/
|
|
243
|
+
guideTitle: v.nullable(v.string()),
|
|
244
|
+
verdict: SessionGuideVerdictValueSchema,
|
|
245
|
+
occurredAt: v.string(),
|
|
246
|
+
reasoning: v.string(),
|
|
247
|
+
});
|
|
248
|
+
/**
|
|
249
|
+
* A saved document whose name or body matched — an artifact `read_artifact`
|
|
250
|
+
* reads by its `itemId`. The name, workspace name and excerpt are wrapped in
|
|
251
|
+
* `untrusted`'s markers.
|
|
252
|
+
*/
|
|
253
|
+
export const SearchContentHitSchema = v.object({
|
|
254
|
+
itemId: NonEmptyStringSchema,
|
|
255
|
+
/** Wrapped in `untrusted`'s markers; null when the item has no name. */
|
|
256
|
+
name: v.nullable(v.string()),
|
|
257
|
+
workspaceId: NonEmptyStringSchema,
|
|
258
|
+
/** Wrapped in `untrusted`'s markers. */
|
|
259
|
+
workspaceName: v.string(),
|
|
260
|
+
/**
|
|
261
|
+
* Slugs of the bundles that hold the item and that the caller may read — the
|
|
262
|
+
* `bundle` argument `pull_artifacts` takes to read the bundle. Never more than
|
|
263
|
+
* a scoped caller's allowlist reaches.
|
|
264
|
+
*/
|
|
265
|
+
bundles: v.array(v.string()),
|
|
266
|
+
updatedAt: v.string(),
|
|
267
|
+
/**
|
|
268
|
+
* Where the item opens on the dashboard. Added by the CLI, which knows the
|
|
269
|
+
* dashboard's address; the server does not send it.
|
|
270
|
+
*/
|
|
271
|
+
url: v.optional(v.string()),
|
|
272
|
+
/** A window around the match, wrapped in `untrusted`'s markers. */
|
|
273
|
+
excerpt: v.string(),
|
|
274
|
+
});
|
|
275
|
+
/** What every matched comment carries, whatever it is attached to. */
|
|
276
|
+
const searchCommentHitFields = {
|
|
277
|
+
commentId: NonEmptyStringSchema,
|
|
278
|
+
/** The thread's root; equal to `commentId` for a root comment. */
|
|
279
|
+
threadId: NonEmptyStringSchema,
|
|
280
|
+
authorKind: SearchCommentAuthorKindSchema,
|
|
281
|
+
/** Whether the thread has been resolved — a resolved thread is answered, not open. */
|
|
282
|
+
resolved: v.boolean(),
|
|
283
|
+
createdAt: v.string(),
|
|
284
|
+
/**
|
|
285
|
+
* Where the comment's subject opens on the dashboard. Added by the CLI, which
|
|
286
|
+
* knows the dashboard's address; the server does not send it.
|
|
287
|
+
*/
|
|
288
|
+
url: v.optional(v.string()),
|
|
289
|
+
/** A window around the match, wrapped in `untrusted`'s markers. */
|
|
290
|
+
excerpt: v.string(),
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* A comment on a guide or document that matched. `body` and `itemName` and
|
|
294
|
+
* `workspaceName` are wrapped in `untrusted`'s markers.
|
|
295
|
+
*/
|
|
296
|
+
export const SearchArtifactCommentHitSchema = v.object({
|
|
297
|
+
...searchCommentHitFields,
|
|
298
|
+
subjectKind: v.literal('artifact'),
|
|
299
|
+
itemId: NonEmptyStringSchema,
|
|
300
|
+
/**
|
|
301
|
+
* The guide the item belongs to, or null for a standalone document. A comment
|
|
302
|
+
* on a guide sits on its body file, so this is the id the dashboard's guide
|
|
303
|
+
* page takes; `itemId` is the one a document page takes.
|
|
304
|
+
*/
|
|
305
|
+
guideId: v.nullable(NonEmptyStringSchema),
|
|
306
|
+
/** Wrapped in `untrusted`'s markers; null when the item has no name. */
|
|
307
|
+
itemName: v.nullable(v.string()),
|
|
308
|
+
workspaceId: NonEmptyStringSchema,
|
|
309
|
+
/** Wrapped in `untrusted`'s markers. */
|
|
310
|
+
workspaceName: v.string(),
|
|
311
|
+
/** Whether the item has been edited since the comment was written. */
|
|
312
|
+
itemChangedSince: v.boolean(),
|
|
313
|
+
/**
|
|
314
|
+
* Where the match is. A current server always says `body`; `suggestion` is
|
|
315
|
+
* what an older one said for a match in a comment's suggested edit, accepted
|
|
316
|
+
* so a CLI talking to one mid-rollout still parses the report. Nothing reads
|
|
317
|
+
* the difference.
|
|
318
|
+
*/
|
|
319
|
+
matchedIn: v.picklist(['body', 'suggestion']),
|
|
320
|
+
/**
|
|
321
|
+
* Whether a Mossbear finding's owner handed it to their agents. Nothing hands
|
|
322
|
+
* one over any more, so a current server sends `false`. It does not say
|
|
323
|
+
* whether an agent may act on it: every open finding is ready unless
|
|
324
|
+
* dismissed. Absent on a person's or an agent's comment and on a reply.
|
|
325
|
+
*/
|
|
326
|
+
approved: v.optional(v.boolean()),
|
|
327
|
+
});
|
|
328
|
+
/**
|
|
329
|
+
* A comment on one of the caller's own sessions that matched. It has no
|
|
330
|
+
* workspace and no item: `sessionId` is the id the dashboard's session page
|
|
331
|
+
* takes. The excerpt is wrapped in `untrusted`'s markers.
|
|
332
|
+
*/
|
|
333
|
+
export const SearchSessionCommentHitSchema = v.object({
|
|
334
|
+
...searchCommentHitFields,
|
|
335
|
+
subjectKind: v.literal('session'),
|
|
336
|
+
sessionId: NonEmptyStringSchema,
|
|
337
|
+
matchedIn: v.literal('body'),
|
|
338
|
+
});
|
|
339
|
+
export const SearchCommentHitSchema = v.variant('subjectKind', [
|
|
340
|
+
SearchArtifactCommentHitSchema,
|
|
341
|
+
SearchSessionCommentHitSchema,
|
|
342
|
+
]);
|
|
343
|
+
/**
|
|
344
|
+
* One thing the caller said to an agent, redacted at the source. `excerpt` and
|
|
345
|
+
* `projectId` and `branch` are wrapped in `untrusted`'s markers: a turn is text a
|
|
346
|
+
* person typed (or pasted) and a branch name is whatever git was told.
|
|
347
|
+
*/
|
|
348
|
+
export const SearchTurnHitSchema = v.object({
|
|
349
|
+
/** The agent's own session id — the key a session digest takes. */
|
|
350
|
+
agentSessionId: NonEmptyStringSchema,
|
|
351
|
+
/**
|
|
352
|
+
* The dashboard's id for the session, which its session page takes. Null when
|
|
353
|
+
* the session has not been recorded as a run yet.
|
|
354
|
+
*/
|
|
355
|
+
sessionId: v.nullable(NonEmptyStringSchema),
|
|
356
|
+
/** Which turn of the session this was, counting from 1. */
|
|
357
|
+
ordinal: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
358
|
+
/** Null when the classifier has not labelled the turn. */
|
|
359
|
+
steeringLabel: v.nullable(SearchSteeringLabelSchema),
|
|
360
|
+
/** Wrapped in `untrusted`'s markers; null where the session recorded none. */
|
|
361
|
+
projectId: v.nullable(v.string()),
|
|
362
|
+
/** Wrapped in `untrusted`'s markers; null where the session recorded none. */
|
|
363
|
+
branch: v.nullable(v.string()),
|
|
364
|
+
createdAt: v.string(),
|
|
365
|
+
/**
|
|
366
|
+
* Where the session opens on the dashboard. Added by the CLI, which knows the
|
|
367
|
+
* dashboard's address; the server does not send it.
|
|
368
|
+
*/
|
|
369
|
+
url: v.optional(v.string()),
|
|
370
|
+
/** A window around the match, wrapped in `untrusted`'s markers. */
|
|
371
|
+
excerpt: v.string(),
|
|
372
|
+
});
|
|
373
|
+
/** Which of a session's stored texts a `sessions` hit matched. */
|
|
374
|
+
export const SEARCH_SESSION_MATCH_FIELDS = ['grade', 'self_report'];
|
|
375
|
+
export const SearchSessionMatchFieldSchema = v.picklist(SEARCH_SESSION_MATCH_FIELDS);
|
|
376
|
+
/**
|
|
377
|
+
* One of the caller's own sessions, found by what the grader said about it or
|
|
378
|
+
* what the agent reported at the end. `repoId`, `projectId`, `branch`,
|
|
379
|
+
* `headSha` and `excerpt` are wrapped in `untrusted`'s markers: the first four
|
|
380
|
+
* are whatever a checkout reported, and the excerpt is model-authored or
|
|
381
|
+
* written by an agent.
|
|
382
|
+
*/
|
|
383
|
+
export const SearchSessionHitSchema = v.object({
|
|
384
|
+
/** The agent's own session id — the key a session digest takes. */
|
|
385
|
+
agentSessionId: NonEmptyStringSchema,
|
|
386
|
+
/** The dashboard's id for the session, which its session page takes. */
|
|
387
|
+
sessionId: NonEmptyStringSchema,
|
|
388
|
+
/** Wrapped in `untrusted`'s markers; null where the session recorded none. */
|
|
389
|
+
repoId: v.nullable(v.string()),
|
|
390
|
+
/** Wrapped in `untrusted`'s markers; null where the session recorded none. */
|
|
391
|
+
projectId: v.nullable(v.string()),
|
|
392
|
+
/** Wrapped in `untrusted`'s markers; null where the session recorded none. */
|
|
393
|
+
branch: v.nullable(v.string()),
|
|
394
|
+
/**
|
|
395
|
+
* The head observed when the session closed, wrapped in `untrusted`'s
|
|
396
|
+
* markers; null where none was observed. A commit made mid-session is not it.
|
|
397
|
+
*/
|
|
398
|
+
headSha: v.nullable(v.string()),
|
|
399
|
+
startedAt: v.string(),
|
|
400
|
+
/** Null when the search named no term, only filters. */
|
|
401
|
+
matchedIn: v.nullable(SearchSessionMatchFieldSchema),
|
|
402
|
+
/**
|
|
403
|
+
* Where the session opens on the dashboard. Added by the CLI, which knows the
|
|
404
|
+
* dashboard's address; the server does not send it.
|
|
405
|
+
*/
|
|
406
|
+
url: v.optional(v.string()),
|
|
407
|
+
/** A window around the match, wrapped in `untrusted`'s markers; null when the search named no term. */
|
|
408
|
+
excerpt: v.nullable(v.string()),
|
|
409
|
+
});
|
|
410
|
+
function searchCorpusReportSchema(hit) {
|
|
411
|
+
return v.variant('status', [
|
|
412
|
+
v.object({
|
|
413
|
+
status: v.literal('searched'),
|
|
414
|
+
/** Every match in scope, counted past the returned page. */
|
|
415
|
+
total: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
416
|
+
narrowedBy: v.nullable(SearchNarrowingSchema),
|
|
417
|
+
/** Newest first, at most the request's limit. */
|
|
418
|
+
hits: v.array(hit),
|
|
419
|
+
}),
|
|
420
|
+
v.object({
|
|
421
|
+
status: v.literal('skipped'),
|
|
422
|
+
reason: SearchSkipReasonSchema,
|
|
423
|
+
}),
|
|
424
|
+
]);
|
|
425
|
+
}
|
|
426
|
+
export const SearchGuidesReportSchema = searchCorpusReportSchema(SearchGuideHitSchema);
|
|
427
|
+
export const SearchVerdictsReportSchema = searchCorpusReportSchema(SearchVerdictHitSchema);
|
|
428
|
+
export const SearchContentReportSchema = searchCorpusReportSchema(SearchContentHitSchema);
|
|
429
|
+
export const SearchCommentsReportSchema = searchCorpusReportSchema(SearchCommentHitSchema);
|
|
430
|
+
export const SearchTurnsReportSchema = searchCorpusReportSchema(SearchTurnHitSchema);
|
|
431
|
+
export const SearchSessionsReportSchema = searchCorpusReportSchema(SearchSessionHitSchema);
|
|
432
|
+
/**
|
|
433
|
+
* A search's answer: **a report per corpus, never a bare list.**
|
|
434
|
+
*
|
|
435
|
+
* Keyed by corpus so every corpus is always accounted for — searched with its
|
|
436
|
+
* total, or skipped with its reason — and `notYetSearchable` names the ones no
|
|
437
|
+
* search reaches. A caller reading zero hits therefore always knows what the
|
|
438
|
+
* zero covers, which is the difference between "nothing matched here" and "you
|
|
439
|
+
* never said this".
|
|
440
|
+
*/
|
|
441
|
+
export const SearchResponseSchema = v.object({
|
|
442
|
+
corpora: v.object({
|
|
443
|
+
guides: SearchGuidesReportSchema,
|
|
444
|
+
verdicts: SearchVerdictsReportSchema,
|
|
445
|
+
/**
|
|
446
|
+
* Optional because a server that predates the `content` corpus does not
|
|
447
|
+
* send it — and then did not search it, which a caller must say rather
|
|
448
|
+
* than read as zero hits.
|
|
449
|
+
*/
|
|
450
|
+
content: v.optional(SearchContentReportSchema),
|
|
451
|
+
/** Optional for the same reason as `content`. Covers comments on guides and documents, and the caller's own comments on their sessions. */
|
|
452
|
+
comments: v.optional(SearchCommentsReportSchema),
|
|
453
|
+
/** Optional for the same reason as `content`. The caller's own turns, never a workspace-mate's. */
|
|
454
|
+
turns: v.optional(SearchTurnsReportSchema),
|
|
455
|
+
/** Optional for the same reason as `content`. The caller's own sessions, never a workspace-mate's. */
|
|
456
|
+
sessions: v.optional(SearchSessionsReportSchema),
|
|
457
|
+
}),
|
|
458
|
+
// `comments` is what a server from before session comments were told apart
|
|
459
|
+
// from item comments still sends; a newer client must read that response, not
|
|
460
|
+
// refuse it. `session-comments`, `turns` and `sessions` are what servers sent
|
|
461
|
+
// before those corpora were searchable.
|
|
462
|
+
notYetSearchable: v.array(v.picklist([
|
|
463
|
+
...SEARCH_UNIMPLEMENTED_CORPORA,
|
|
464
|
+
'comments',
|
|
465
|
+
'session-comments',
|
|
466
|
+
'turns',
|
|
467
|
+
'sessions',
|
|
468
|
+
])),
|
|
469
|
+
untrusted: GuideHistoryUntrustedSchema,
|
|
470
|
+
});
|
|
471
|
+
export function parseSearchResponse(data) {
|
|
472
|
+
return v.parse(SearchResponseSchema, data);
|
|
473
|
+
}
|
|
474
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,2BAA2B,EAC3B,8BAA8B,GAC/B,MAAM,qBAAqB,CAAA;AAE5B,8EAA8E;AAC9E,wEAAwE;AACxE,8EAA8E;AAE9E;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,QAAQ;IACR,UAAU;IACV,SAAS;IACT,UAAU;IACV,OAAO;IACP,UAAU;CACF,CAAA;AAEV,MAAM,CAAC,MAAM,oBA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C;QAC1C,sGAAsG;QACtG,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,0BAA0B,CAAC;KACjD,CAAC;IACF,2EAA2E;IAC3E,8EAA8E;IAC9E,8EAA8E;IAC9E,wCAAwC;IACxC,gBAAgB,EAAE,CAAC,CAAC,KAAK,CACvB,CAAC,CAAC,QAAQ,CAAC;QACT,GAAG,4BAA4B;QAC/B,UAAU;QACV,kBAAkB;QAClB,OAAO;QACP,UAAU;KACF,CAAC,CACZ;IACD,SAAS,EAAE,2BAA2B;CACvC,CAAC,CAAA;AAIF,MAAM,UAAU,mBAAmB,CAAC,IAAa;IAC/C,OAAO,CAAC,CAAC,KAAK,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAA;AAC5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.test.d.ts","sourceRoot":"","sources":["../src/search.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import * as protocol from './index.js';
|
|
4
|
+
import * as schemas from './schemas.js';
|
|
5
|
+
import * as search from './search.js';
|
|
6
|
+
// Consumers keep using the existing package and aggregate schema surfaces.
|
|
7
|
+
describe('search domain compatibility', () => {
|
|
8
|
+
it('keeps every search runtime export on the existing surfaces', () => {
|
|
9
|
+
for (const [name, value] of Object.entries(search)) {
|
|
10
|
+
expect(Reflect.get(schemas, name), name).toBe(value);
|
|
11
|
+
expect(Reflect.get(protocol, name), name).toBe(value);
|
|
12
|
+
}
|
|
13
|
+
expect(search.SearchCommentAuthorKindSchema).toBe(schemas.CommentAuthorKindSchema);
|
|
14
|
+
expect(search.SEARCH_COMMENT_AUTHOR_KINDS).toBe(schemas.CommentAuthorKindSchema.options);
|
|
15
|
+
expect(search.SearchVerdictHitSchema.entries.verdict).toBe(schemas.SessionGuideVerdictValueSchema);
|
|
16
|
+
expect(search.SearchResponseSchema.entries.untrusted).toBe(schemas.GuideHistoryUntrustedSchema);
|
|
17
|
+
});
|
|
18
|
+
it('leaves absent request options absent and trims the term', () => {
|
|
19
|
+
expect(v.parse(search.SearchRequestSchema, { q: ' quince ' })).toEqual({
|
|
20
|
+
q: 'quince',
|
|
21
|
+
});
|
|
22
|
+
expect(v.parse(search.SearchRequestSchema, { branch: ' main ' })).toEqual({
|
|
23
|
+
branch: 'main',
|
|
24
|
+
});
|
|
25
|
+
expect(v.safeParse(search.SearchRequestSchema, { q: 'quince', limit: null }).success).toBe(false);
|
|
26
|
+
expect(v.safeParse(search.SearchRequestSchema, { q: '**' }).success).toBe(false);
|
|
27
|
+
expect(v.safeParse(search.SearchRequestSchema, { branch: 'main', corpora: ['guides'] })
|
|
28
|
+
.success).toBe(false);
|
|
29
|
+
});
|
|
30
|
+
it('reads an older response without adding corpora or optional fields', () => {
|
|
31
|
+
const response = {
|
|
32
|
+
corpora: {
|
|
33
|
+
guides: {
|
|
34
|
+
status: 'searched',
|
|
35
|
+
total: 1,
|
|
36
|
+
narrowedBy: null,
|
|
37
|
+
hits: [
|
|
38
|
+
{
|
|
39
|
+
guideId: 'g',
|
|
40
|
+
guideTitle: null,
|
|
41
|
+
fileId: 'f',
|
|
42
|
+
path: null,
|
|
43
|
+
part: 'body',
|
|
44
|
+
excerpt: '',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
verdicts: { status: 'skipped', reason: 'not-granted' },
|
|
49
|
+
},
|
|
50
|
+
notYetSearchable: ['actions', 'comments', 'session-comments', 'turns', 'sessions'],
|
|
51
|
+
untrusted: { token: 't', startMarker: 's', endMarker: 'e', note: '' },
|
|
52
|
+
};
|
|
53
|
+
expect(protocol.parseSearchResponse(response)).toEqual(response);
|
|
54
|
+
expect(() => protocol.parseSearchResponse({
|
|
55
|
+
...response,
|
|
56
|
+
corpora: { ...response.corpora, content: null },
|
|
57
|
+
})).toThrow(v.ValiError);
|
|
58
|
+
const hit = response.corpora.guides.hits[0];
|
|
59
|
+
expect(v.parse(search.SearchGuideHitSchema, { ...hit, section: null, sectionChars: null })).toEqual({ ...hit, section: null, sectionChars: null });
|
|
60
|
+
const { guideTitle: _title, ...missingNullable } = hit;
|
|
61
|
+
expect(v.safeParse(search.SearchGuideHitSchema, missingNullable).success).toBe(false);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=search.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.test.js","sourceRoot":"","sources":["../src/search.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAA;AACtC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,2EAA2E;AAC3E,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACnD,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACpD,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACvD,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,6BAA6B,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAA;QAClF,MAAM,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC,IAAI,CAC7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