@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
package/dist/schemas.js
CHANGED
|
@@ -10,10 +10,17 @@
|
|
|
10
10
|
import * as v from 'valibot';
|
|
11
11
|
import { DISPLAY_NAME_REFUSED_CHARACTERS } from './bundleSlug.js';
|
|
12
12
|
import { isBundleSlug } from './bundleSlug.js';
|
|
13
|
+
import { ArtifactCommentSchema, MAX_ITEM_THREAD_ENTRIES_ON_WIRE } from './comments.js';
|
|
13
14
|
import { CONTEXT_CONTENT_KINDS, CONTEXT_ITEM_TYPES, CONTEXT_ITEM_TYPE_FILTER_VALUES, contextItemTypeOf, CAPTURE_CONTENT_TYPES, } from './contextKinds.js';
|
|
14
15
|
import { MAX_ARTIFACT_DESCRIPTION_CHARS, MAX_ARTIFACT_NAME_CHARS, MAX_CONTEXT_CONTENT_BYTES, MAX_RAW_GUIDE_CONTENT_BYTES, } from './limits.js';
|
|
15
16
|
import { MachineIdSchema } from './pairing.js';
|
|
16
17
|
import { PhotoAssetSchema } from './photos.js';
|
|
18
|
+
import { NonEmptyStringSchema, GuideHistoryUntrustedSchema, HarnessIdSchema, RepositoryNameSchema, ProjectIdSchema, MAX_ARTIFACT_FEEDBACK_BATCH, } from './wirePrimitives.js';
|
|
19
|
+
export { HarnessIdSchema, MAX_REPOSITORY_NAME_LENGTH, RepositoryNameSchema, ProjectIdSchema, MAX_ARTIFACT_FEEDBACK_BATCH, CommentAuthorKindSchema, GuideHistoryUntrustedSchema, SESSION_GUIDE_VERDICTS, SessionGuideVerdictValueSchema, } from './wirePrimitives.js';
|
|
20
|
+
export * from './comments.js';
|
|
21
|
+
export * from './search.js';
|
|
22
|
+
export { SessionGradeRequestSchema, SessionGradeStateSchema, SessionGradeGuideSchema, SessionGradeSchema, GradedSessionSchema, SessionGradeResponseSchema, parseRunGradeRequest, parseSessionGradeResponse, } from './sessionGrade.js';
|
|
23
|
+
export * from './sessionDigest.js';
|
|
17
24
|
// ---------------------------------------------------------------------------
|
|
18
25
|
// Core enum schemas
|
|
19
26
|
// ---------------------------------------------------------------------------
|
|
@@ -31,31 +38,6 @@ export const PlatformKindSchema = v.picklist([
|
|
|
31
38
|
'copilot',
|
|
32
39
|
'other',
|
|
33
40
|
]);
|
|
34
|
-
/**
|
|
35
|
-
* Which agent harness produced a run — the CLI's harness registry, on the wire.
|
|
36
|
-
*
|
|
37
|
-
* **Deliberately not {@link PlatformKindSchema}, and not a widening of it.**
|
|
38
|
-
* That picklist answers a different question — which transcript format a
|
|
39
|
-
* *suggestion* was extracted from — over a set that includes harnesses
|
|
40
|
-
* `mossbear init` cannot wire (`cursor`, `copilot`) and excludes one it can
|
|
41
|
-
* (`antigravity`). Two questions, two sets; collapsing them would need both a
|
|
42
|
-
* new member and an overloaded meaning.
|
|
43
|
-
*
|
|
44
|
-
* Declared here rather than in the CLI so there is exactly one list: the CLI's
|
|
45
|
-
* `HarnessId` is `v.InferOutput` of this, imported as a type, so a manifest for
|
|
46
|
-
* a harness this schema does not name fails typecheck instead of failing at the
|
|
47
|
-
* sync boundary. The import is type-only on purpose — `mossbear-hook` runs once
|
|
48
|
-
* per agent tool call, and nothing here may enter its runtime import graph.
|
|
49
|
-
*
|
|
50
|
-
* Rides `metadata.harness` on each action (see {@link ActionMetadataSchema});
|
|
51
|
-
* the server reduces a session's actions to one value and writes `runs.harness`.
|
|
52
|
-
*/
|
|
53
|
-
export const HarnessIdSchema = v.picklist([
|
|
54
|
-
'claude_code',
|
|
55
|
-
'codex',
|
|
56
|
-
'antigravity',
|
|
57
|
-
'opencode',
|
|
58
|
-
]);
|
|
59
41
|
/**
|
|
60
42
|
* Where a session ran, recorded only when the hook can see it ran in a cloud
|
|
61
43
|
* container: a claude.ai/code session, a Codespace, a CI runner.
|
|
@@ -74,24 +56,6 @@ export const HarnessIdSchema = v.picklist([
|
|
|
74
56
|
* The server writes `cloud` onto a session when any of its actions carry it.
|
|
75
57
|
*/
|
|
76
58
|
export const SessionEnvironmentSchema = v.picklist(['cloud']);
|
|
77
|
-
/** Longest accepted repository name. An `owner/repo` path is far shorter; this bounds a folder name. */
|
|
78
|
-
export const MAX_REPOSITORY_NAME_LENGTH = 200;
|
|
79
|
-
/**
|
|
80
|
-
* The name of the repository a session ran in, as a person would recognise it:
|
|
81
|
-
* the `owner/repo` path of the checkout's git remote, or the checkout's folder
|
|
82
|
-
* name when it has no remote the CLI can read a path from.
|
|
83
|
-
*
|
|
84
|
-
* A display name, not an identity. Two forks share a name, and a folder name
|
|
85
|
-
* says nothing beyond itself; `projectId` and `repoId` stay the keys a reader
|
|
86
|
-
* joins on. The CLI keeps only the path of a remote: never its scheme,
|
|
87
|
-
* credentials, host, port or query, so a URL carrying a token does not leave
|
|
88
|
-
* the machine.
|
|
89
|
-
*
|
|
90
|
-
* Rides `metadata.repository` on each action (see {@link ActionMetadataSchema}).
|
|
91
|
-
* The server reduces a session's stamps to one value; absent is "unnamed",
|
|
92
|
-
* which is every session a CLI predating the field recorded.
|
|
93
|
-
*/
|
|
94
|
-
export const RepositoryNameSchema = v.pipe(v.string(), v.minLength(1), v.maxLength(MAX_REPOSITORY_NAME_LENGTH), v.check((value) => value.trim() === value && !/\p{Cc}/u.test(value), 'repository must be trimmed and hold no control characters'));
|
|
95
59
|
export const GuideFileFormatSchema = v.picklist([
|
|
96
60
|
'agents-md',
|
|
97
61
|
'agents-dir',
|
|
@@ -101,7 +65,6 @@ export const GuideFileFormatSchema = v.picklist([
|
|
|
101
65
|
'cursor-rules',
|
|
102
66
|
'skill-md',
|
|
103
67
|
]);
|
|
104
|
-
const NonEmptyStringSchema = v.pipe(v.string(), v.minLength(1));
|
|
105
68
|
const Sha256HexSchema = v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/i));
|
|
106
69
|
// No eval-provider schemas here. They described the LLM credentials the CLI
|
|
107
70
|
// needed to grade on-device; grading is server-side and the CLI holds no
|
|
@@ -297,14 +260,6 @@ v.check((payload) => payload.members === undefined ||
|
|
|
297
260
|
export const MAX_RULES_IMPORT_BATCH = 100;
|
|
298
261
|
/** Opaque checkout digest shared by run logs, manifests, and `runs.repo_id`. */
|
|
299
262
|
export const RepoIdSchema = v.pipe(v.string(), v.regex(/^repo_[0-9a-f]{32}$/, 'repoId must be repo_ followed by 32 hex chars'));
|
|
300
|
-
/** Longest accepted `projectId`. Generated ids are far shorter; this bounds a hand-declared one. */
|
|
301
|
-
const MAX_PROJECT_ID_LENGTH = 128;
|
|
302
|
-
/**
|
|
303
|
-
* A repo's declared portable identity. See `RulesImportRequestSchema.projectId`
|
|
304
|
-
* for why this is looser than {@link RepoIdSchema} — a declared id is
|
|
305
|
-
* human-authored and predates any prefix rule.
|
|
306
|
-
*/
|
|
307
|
-
export const ProjectIdSchema = v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(MAX_PROJECT_ID_LENGTH), v.regex(/^[A-Za-z0-9_.-]+$/, 'projectId must contain only letters, digits, underscore, dot or hyphen'));
|
|
308
263
|
/**
|
|
309
264
|
* A checkout's committed `project.id` as a context write declares it: trimmed
|
|
310
265
|
* and non-empty, exactly the rule the CLI's config reader applies — and no
|
|
@@ -1142,223 +1097,6 @@ export const GuideAliasSchema = v.object({
|
|
|
1142
1097
|
root: GuideDiscoveryRootSchema,
|
|
1143
1098
|
path: SafeRelativePosixPathSchema,
|
|
1144
1099
|
});
|
|
1145
|
-
/**
|
|
1146
|
-
* The markers every untrusted block in a response is wrapped in, plus a
|
|
1147
|
-
* statement of what they mean.
|
|
1148
|
-
*
|
|
1149
|
-
* Generated per response from the content itself, so no marker-like text
|
|
1150
|
-
* inside a block can end it early — a property `deriveDelimiterToken` checks
|
|
1151
|
-
* rather than assumes.
|
|
1152
|
-
*
|
|
1153
|
-
* Named for the guide-history response it was written for and shared by every
|
|
1154
|
-
* payload that places somebody else's words in front of an agent: a grade's
|
|
1155
|
-
* reasoning, and now an item's comments. One marker scheme, not one per payload —
|
|
1156
|
-
* a second scheme is a second thing a reader has to be taught to respect.
|
|
1157
|
-
* Declared here, above its first user, rather than beside that response.
|
|
1158
|
-
*/
|
|
1159
|
-
export const GuideHistoryUntrustedSchema = v.object({
|
|
1160
|
-
token: NonEmptyStringSchema,
|
|
1161
|
-
startMarker: NonEmptyStringSchema,
|
|
1162
|
-
endMarker: NonEmptyStringSchema,
|
|
1163
|
-
note: v.string(),
|
|
1164
|
-
});
|
|
1165
|
-
/**
|
|
1166
|
-
* How many open comments one item carries on the wire, newest first.
|
|
1167
|
-
*
|
|
1168
|
-
* A wire bound, not a product limit: the write side refuses the comment that
|
|
1169
|
-
* would exceed it *by name* (see the dashboard's note mutator), so this cap is
|
|
1170
|
-
* never the thing that silently drops a comment a person left.
|
|
1171
|
-
*/
|
|
1172
|
-
export const MAX_ITEM_COMMENTS_ON_WIRE = 20;
|
|
1173
|
-
/**
|
|
1174
|
-
* How many replies one delivered thread carries, the newest kept. A thread past
|
|
1175
|
-
* it says how many it held back (`repliesWithheld`), so a cut is never silent.
|
|
1176
|
-
*/
|
|
1177
|
-
export const MAX_REPLIES_PER_THREAD_ON_WIRE = 10;
|
|
1178
|
-
/**
|
|
1179
|
-
* The most entries one item's `comments` can hold once threads ride it: a
|
|
1180
|
-
* person's allowance of roots plus an agent's own, each followed by its replies.
|
|
1181
|
-
* A client that does not render threads is sent roots alone, which stay within
|
|
1182
|
-
* `MAX_ITEM_COMMENTS_ON_WIRE`.
|
|
1183
|
-
*/
|
|
1184
|
-
export const MAX_ITEM_THREAD_ENTRIES_ON_WIRE = 2 * MAX_ITEM_COMMENTS_ON_WIRE * (1 + MAX_REPLIES_PER_THREAD_ON_WIRE);
|
|
1185
|
-
/**
|
|
1186
|
-
* Who wrote a comment. An agent writes under its person's account, so the
|
|
1187
|
-
* author's name alone cannot tell a person's answer from an agent's message.
|
|
1188
|
-
*/
|
|
1189
|
-
export const CommentAuthorKindSchema = v.picklist(['person', 'agent', 'mossbear']);
|
|
1190
|
-
/** What a finding rests on: graded sessions, how loads read a skill, or the rubric alone. */
|
|
1191
|
-
export const FindingTierSchema = v.picklist(['observed', 'usage', 'practice']);
|
|
1192
|
-
/**
|
|
1193
|
-
* What a Mossbear finding carries on the comment read, besides its claim.
|
|
1194
|
-
*
|
|
1195
|
-
* `tierLine` and `blindSpot` are written by the server from data it holds —
|
|
1196
|
-
* the cited sessions, the load counts, the rubric check — never by a model, so
|
|
1197
|
-
* they sit outside the response's untrusted markers. `prediction` is
|
|
1198
|
-
* model-authored and arrives inside them. A finding never carries replacement
|
|
1199
|
-
* text: the reader's agent has the repository and writes the fix.
|
|
1200
|
-
*/
|
|
1201
|
-
export const CommentFindingSchema = v.object({
|
|
1202
|
-
tier: FindingTierSchema,
|
|
1203
|
-
/** How the finding is known, in one line: "Seen in 3 sessions (2026-09-15 – 2026-10-03)". */
|
|
1204
|
-
tierLine: v.pipe(v.string(), v.maxLength(300)),
|
|
1205
|
-
/** What the drafter did not read, fixed per tier. */
|
|
1206
|
-
blindSpot: v.pipe(v.string(), v.maxLength(300)),
|
|
1207
|
-
/** What should change in later sessions if the finding is fixed, wrapped in the untrusted markers. */
|
|
1208
|
-
prediction: v.nullable(v.string()),
|
|
1209
|
-
});
|
|
1210
|
-
/** Whether an open Mossbear finding is the agent's to act on (`ArtifactComment.findingState`). */
|
|
1211
|
-
export const CommentFindingStateSchema = v.picklist(['ready', 'waiting']);
|
|
1212
|
-
/** Where a commented artifact is published from (`ArtifactComment.publishedFrom`). */
|
|
1213
|
-
export const CommentPublishedFromSchema = v.object({
|
|
1214
|
-
repository: v.optional(RepositoryNameSchema),
|
|
1215
|
-
projectId: NonEmptyStringSchema,
|
|
1216
|
-
branch: v.nullable(v.pipe(v.string(), v.maxLength(255))),
|
|
1217
|
-
thisRepo: v.optional(v.boolean()),
|
|
1218
|
-
});
|
|
1219
|
-
/**
|
|
1220
|
-
* One comment a **person** left about a context item, riding the item it is about.
|
|
1221
|
-
*
|
|
1222
|
-
* A comment is not an item: it is not a member, not projected, not versioned and
|
|
1223
|
-
* not capturable. It travels on the item so that it inherits every delivery
|
|
1224
|
-
* decision the item already went through — workspace scope, the archived drop,
|
|
1225
|
-
* the response limit, the subscriber's mute — rather than restating them.
|
|
1226
|
-
*
|
|
1227
|
-
* **Every `body` here is already wrapped in the response's untrusted markers**
|
|
1228
|
-
* (`ContextItemsResponseSchema.untrusted`). A reader emits the bytes as it
|
|
1229
|
-
* received them and never re-wraps them: the markers are derived against the
|
|
1230
|
-
* bodies the server sent, so a second wrapping cannot claim the same guarantee.
|
|
1231
|
-
*/
|
|
1232
|
-
export const ArtifactCommentSchema = v.object({
|
|
1233
|
-
id: NonEmptyStringSchema,
|
|
1234
|
-
state: v.optional(v.picklist(['open', 'resolved'])),
|
|
1235
|
-
/** Current source location of an anchored passage, or its lost quote. */
|
|
1236
|
-
passage: v.optional(v.object({
|
|
1237
|
-
quote: v.string(),
|
|
1238
|
-
status: v.picklist(['located', 'changed', 'orphaned']),
|
|
1239
|
-
lines: v.nullable(v.object({ start: v.number(), end: v.number() })),
|
|
1240
|
-
/**
|
|
1241
|
-
* Where the passage sits in an `html` page as the reader saw it: a CSS
|
|
1242
|
-
* selector, the tag, and the nearest `aria-label` or heading. Sent when
|
|
1243
|
-
* the passage has no source lines, so an agent can find a block the
|
|
1244
|
-
* page's script built.
|
|
1245
|
-
*/
|
|
1246
|
-
element: v.optional(v.object({
|
|
1247
|
-
selector: v.string(),
|
|
1248
|
-
tag: v.string(),
|
|
1249
|
-
label: v.optional(v.string()),
|
|
1250
|
-
})),
|
|
1251
|
-
})),
|
|
1252
|
-
/** The comment's text, already wrapped in the response's untrusted markers. */
|
|
1253
|
-
body: v.string(),
|
|
1254
|
-
/**
|
|
1255
|
-
* What a comment Mossbear wrote is: a finding about the item, never an edit.
|
|
1256
|
-
* Present only on a Mossbear comment. The comment's `body` begins with the
|
|
1257
|
-
* claim (what goes wrong); this carries what the claim rests on.
|
|
1258
|
-
*/
|
|
1259
|
-
finding: v.optional(CommentFindingSchema),
|
|
1260
|
-
/**
|
|
1261
|
-
* Whether the person handed a comment Mossbear drafted to their agent. Nothing
|
|
1262
|
-
* hands one over any more, so a current server sends `false` on every Mossbear
|
|
1263
|
-
* comment and omits it on a person's or an agent's; the field stays for
|
|
1264
|
-
* readers that predate `findingState`. It does not say whether the agent may
|
|
1265
|
-
* act: read `findingState` for that, and fall back to `approved: false`
|
|
1266
|
-
* meaning "not yet accepted" only when `findingState` is absent, from a server
|
|
1267
|
-
* that predates it. Only a client that reports a version able to mark drafts
|
|
1268
|
-
* is listed a finding at all, so an older reader that strips this field never
|
|
1269
|
-
* receives one it would misread.
|
|
1270
|
-
*/
|
|
1271
|
-
approved: v.optional(v.boolean()),
|
|
1272
|
-
/**
|
|
1273
|
-
* Whether an open Mossbear finding is the agent's to act on. A current server
|
|
1274
|
-
* sends `ready` on every open finding: it is the agent's unless the person
|
|
1275
|
-
* dismisses it, and a dismissed finding is resolved. `waiting`, sent only by
|
|
1276
|
-
* an older server, means it waits on the person: show it to the user and
|
|
1277
|
-
* change nothing unless they say so. Present only on an open Mossbear
|
|
1278
|
-
* comment. A server that predates the field omits it, and a reader then
|
|
1279
|
-
* falls back to `approved`. This is a new name rather than a new meaning for
|
|
1280
|
-
* `state`, which already says open or resolved.
|
|
1281
|
-
*/
|
|
1282
|
-
findingState: v.optional(CommentFindingStateSchema),
|
|
1283
|
-
/**
|
|
1284
|
-
* Where the artifact is published from, when Mossbear records one: the
|
|
1285
|
-
* committed `project.id` of the repository whose commits own it, and the
|
|
1286
|
-
* branch it was published from (null when none was recorded). `thisRepo` is
|
|
1287
|
-
* true when that is the repo the read declared, false when it is another repo,
|
|
1288
|
-
* and absent when the read declared no repo. The field is absent when Mossbear
|
|
1289
|
-
* records no publishing repo, which is not a claim that the artifact is
|
|
1290
|
-
* Mossbear-owned.
|
|
1291
|
-
*/
|
|
1292
|
-
publishedFrom: v.optional(CommentPublishedFromSchema),
|
|
1293
|
-
/** The author's display name as the workspace shows it, or null. Never an email. */
|
|
1294
|
-
authorName: v.nullable(v.string()),
|
|
1295
|
-
/**
|
|
1296
|
-
* Who wrote it. Optional because a server that predates the field omits it;
|
|
1297
|
-
* a reader that meets a reply without it cannot tell whose it is, and a
|
|
1298
|
-
* server never sends a reply to a client too old to read this.
|
|
1299
|
-
*/
|
|
1300
|
-
authorKind: v.optional(CommentAuthorKindSchema),
|
|
1301
|
-
/** ISO timestamp, machine format. */
|
|
1302
|
-
createdAt: v.string(),
|
|
1303
|
-
/** The item's content version the comment was written against. */
|
|
1304
|
-
itemVersion: v.number(),
|
|
1305
|
-
/** True when the item's current version is greater than `itemVersion`. */
|
|
1306
|
-
itemChangedSince: v.boolean(),
|
|
1307
|
-
/**
|
|
1308
|
-
* How many agent reads were handed this comment **before** this one — so a
|
|
1309
|
-
* comment reaching an agent for the first time reports `0`.
|
|
1310
|
-
*
|
|
1311
|
-
* It is the stored count as it read at the moment the response was built;
|
|
1312
|
-
* the serve this response *is* has not been counted yet. Excluded rather
|
|
1313
|
-
* than included because the count is recorded best-effort: a response that
|
|
1314
|
-
* claimed to include itself would be wrong whenever that record failed, and
|
|
1315
|
-
* a number that is sometimes off by one is worse than one that is
|
|
1316
|
-
* consistently the prior total.
|
|
1317
|
-
*
|
|
1318
|
-
* So `deliveredCount > 0` means an earlier read was handed this comment, and
|
|
1319
|
-
* `0` means this read is the first. Neither says a model took it in — only
|
|
1320
|
-
* that the server handed it over.
|
|
1321
|
-
*/
|
|
1322
|
-
deliveredCount: v.number(),
|
|
1323
|
-
/**
|
|
1324
|
-
* On a root: true when the item changed after an earlier read was last
|
|
1325
|
-
* handed this comment. For a guide that is any change to its body or its
|
|
1326
|
-
* files, so a fix in a supporting file counts. A reader should check whether
|
|
1327
|
-
* the change addressed the comment, and resolve it with a note if so.
|
|
1328
|
-
*
|
|
1329
|
-
* Computed before this read is counted, so the read that carries `true` is
|
|
1330
|
-
* the one that uses it up; the next read says `false` unless the item
|
|
1331
|
-
* changes again. A comment never handed over before is never flagged.
|
|
1332
|
-
* Optional because a server that predates the field omits it, and absent on
|
|
1333
|
-
* a reply.
|
|
1334
|
-
*/
|
|
1335
|
-
guideChangedSinceRead: v.optional(v.boolean()),
|
|
1336
|
-
/**
|
|
1337
|
-
* This comment's thread root: its own id on a root, the root's id on a reply.
|
|
1338
|
-
*
|
|
1339
|
-
* **Replies ride the same flat array**, each straight after its root, oldest
|
|
1340
|
-
* first. Only a client that reports a version able to render threads is
|
|
1341
|
-
* sent them; any other reader gets roots alone, as it always did. A person's
|
|
1342
|
-
* reply is part of the thread's request. An agent's reply is context: an
|
|
1343
|
-
* earlier message on the thread, never something to act on. A root an agent
|
|
1344
|
-
* wrote is delivered only once a person has replied to it, and is then the
|
|
1345
|
-
* question that reply answers, not a request of its own.
|
|
1346
|
-
*/
|
|
1347
|
-
threadId: NonEmptyStringSchema,
|
|
1348
|
-
/**
|
|
1349
|
-
* `null` on a root; the root's id on a reply. Threads are one level deep, so
|
|
1350
|
-
* a reply's parent is always its root.
|
|
1351
|
-
*/
|
|
1352
|
-
replyToId: v.nullable(NonEmptyStringSchema),
|
|
1353
|
-
/**
|
|
1354
|
-
* On a root whose thread held more replies than
|
|
1355
|
-
* `MAX_REPLIES_PER_THREAD_ON_WIRE`: how many older ones were not sent.
|
|
1356
|
-
* Absent when the whole thread was sent.
|
|
1357
|
-
*/
|
|
1358
|
-
repliesWithheld: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1))),
|
|
1359
|
-
});
|
|
1360
|
-
/** The item routes' name for `ArtifactCommentSchema`, kept while those routes are served. */
|
|
1361
|
-
export const ContextItemCommentSchema = ArtifactCommentSchema;
|
|
1362
1100
|
const MAX_SOURCE_BRANCH_LENGTH = 255;
|
|
1363
1101
|
/**
|
|
1364
1102
|
* The revision published bytes were read from — 40 hex characters for a sha1
|
|
@@ -1663,433 +1401,6 @@ export const BundleArtifactsResponseSchema = v.object({
|
|
|
1663
1401
|
*/
|
|
1664
1402
|
next: v.optional(v.nullable(v.string())),
|
|
1665
1403
|
});
|
|
1666
|
-
/**
|
|
1667
|
-
* How many bundles one comments read may name.
|
|
1668
|
-
*
|
|
1669
|
-
* A repo's delivery set is the union of its committed subscriptions and the
|
|
1670
|
-
* reader's account ones, so this bounds a request, not a product limit: a
|
|
1671
|
-
* reader subscribing to more bundles than this asks in two calls rather than
|
|
1672
|
-
* losing the tail silently.
|
|
1673
|
-
*/
|
|
1674
|
-
export const MAX_COMMENT_BUNDLE_IDS = 100;
|
|
1675
|
-
/**
|
|
1676
|
-
* The agent session behind a comment, a reply or a resolution note, as the
|
|
1677
|
-
* caller's harness reported it. Stored on the row so the reply is named after
|
|
1678
|
-
* that session; it is the caller's claim, read only among its own comments.
|
|
1679
|
-
*/
|
|
1680
|
-
export const AgentIdentitySchema = v.object({
|
|
1681
|
-
sessionId: v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(128)),
|
|
1682
|
-
harness: HarnessIdSchema,
|
|
1683
|
-
/** The agent's own statement of its model, when it knows it. */
|
|
1684
|
-
model: v.optional(v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(100))),
|
|
1685
|
-
cliVersion: v.optional(v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(64))),
|
|
1686
|
-
});
|
|
1687
|
-
/**
|
|
1688
|
-
* `POST /api/v1/context/comments/resolve`: close one open comment and leave the
|
|
1689
|
-
* agent's note as a reply in its thread.
|
|
1690
|
-
*
|
|
1691
|
-
* **Two ways to find the comment, never both at once.** Without `artifactId`,
|
|
1692
|
-
* the id is looked up among the comments the named bundles deliver, which is
|
|
1693
|
-
* what `list_comments` listed. With it, the id is looked up among that one
|
|
1694
|
-
* artifact's open comments, which is what its feedback read listed, after the
|
|
1695
|
-
* same read check that read makes. A request with `artifactId` does not fall
|
|
1696
|
-
* back to the bundles when the id is not on that artifact.
|
|
1697
|
-
*/
|
|
1698
|
-
export const ResolveItemCommentRequestSchema = v.object({
|
|
1699
|
-
/** The comment's id, or a unique prefix of it as a read printed it. */
|
|
1700
|
-
id: v.pipe(v.string(), v.minLength(1), v.maxLength(128)),
|
|
1701
|
-
/** One line, kept in the thread as the agent's reply. */
|
|
1702
|
-
note: v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(500), v.regex(/^[^\r\n]+$/)),
|
|
1703
|
-
/** The bundles this repo receives. Ignored when `artifactId` is sent. */
|
|
1704
|
-
bundleIds: v.optional(v.pipe(v.array(NonEmptyStringSchema), v.maxLength(MAX_COMMENT_BUNDLE_IDS)), []),
|
|
1705
|
-
/** The artifact the comment is on, as its feedback read was asked for it. */
|
|
1706
|
-
artifactId: v.optional(v.pipe(v.string(), v.minLength(1), v.maxLength(128))),
|
|
1707
|
-
/**
|
|
1708
|
-
* The reader's repo, as its committed `project.id`. A comment drafted from
|
|
1709
|
-
* one repo's corrections is listed only to a read that declares that repo,
|
|
1710
|
-
* so it is resolvable only by one that declares it too.
|
|
1711
|
-
*/
|
|
1712
|
-
projectId: v.optional(ProjectIdSchema),
|
|
1713
|
-
/** The CLI's version, so a draft resolves only for a client that marks drafts. */
|
|
1714
|
-
cliVersion: v.optional(v.pipe(v.string(), v.maxLength(64))),
|
|
1715
|
-
/**
|
|
1716
|
-
* The agent session resolving it, stored on the note so the thread names
|
|
1717
|
-
* who closed it. Optional: releases before it was sent resolve without one,
|
|
1718
|
-
* and their notes read as an unnamed agent.
|
|
1719
|
-
*/
|
|
1720
|
-
agent: v.optional(AgentIdentitySchema),
|
|
1721
|
-
});
|
|
1722
|
-
/** A resolve the server carried out. Every refusal is an error response instead. */
|
|
1723
|
-
export const ResolveItemCommentResponseSchema = v.object({
|
|
1724
|
-
resolved: v.literal(true),
|
|
1725
|
-
});
|
|
1726
|
-
/**
|
|
1727
|
-
* How many times one subscriber is told, in one repo, that a given comment is
|
|
1728
|
-
* waiting before the hook falls silent about it.
|
|
1729
|
-
*
|
|
1730
|
-
* **A cap on the interruption, never on the comment.** After it is reached the
|
|
1731
|
-
* comment is still open, still on the item page, and still returned in full by
|
|
1732
|
-
* the on-demand read — it simply stops being announced in front of the first
|
|
1733
|
-
* turn of every session. So silence here means "nothing new to interrupt you
|
|
1734
|
-
* about", never "nobody left anything".
|
|
1735
|
-
*
|
|
1736
|
-
* Three rather than one, for the reason the announcement exists: the first
|
|
1737
|
-
* session in a repo is often doing unrelated work, so a one-shot announcement
|
|
1738
|
-
* would routinely spend itself on the session least likely to act. Three is a
|
|
1739
|
-
* judgement, named so replacing it is one edit — the same discipline the live
|
|
1740
|
-
* session window is held to.
|
|
1741
|
-
*/
|
|
1742
|
-
export const MAX_COMMENT_ANNOUNCEMENTS_PER_REPO = 3;
|
|
1743
|
-
/**
|
|
1744
|
-
* Ask which comments are waiting for this reader in this repo, and be counted as
|
|
1745
|
-
* told.
|
|
1746
|
-
*
|
|
1747
|
-
* **A write, because being told is a fact the server has to keep.** The count
|
|
1748
|
-
* cannot be `item_comments.delivered_count` — that is one global number across
|
|
1749
|
-
* every subscriber and every repo, so one reader's fill of a comment would
|
|
1750
|
-
* silence it for everyone — and it cannot live in the checkout, because the
|
|
1751
|
-
* disposable environments this exists for rebuild the clone every session and
|
|
1752
|
-
* a counter there resets with it, announcing every unresolved comment as new
|
|
1753
|
-
* forever.
|
|
1754
|
-
*/
|
|
1755
|
-
export const AnnounceItemCommentsRequestSchema = v.object({
|
|
1756
|
-
/**
|
|
1757
|
-
* The repo, as its committed config declares it. Required: it is the scope
|
|
1758
|
-
* the count is kept under, and a request with nothing to key on could only
|
|
1759
|
-
* be answered by an uncapped announcement — which is the repeating broadcast
|
|
1760
|
-
* this route exists to end.
|
|
1761
|
-
*/
|
|
1762
|
-
projectId: ProjectIdSchema,
|
|
1763
|
-
/**
|
|
1764
|
-
* The bundles this repo receives — the union the caller already resolved.
|
|
1765
|
-
*
|
|
1766
|
-
* Sent rather than derived, because only half of it is the server's to know:
|
|
1767
|
-
* a repo-scoped subscription lives in the committed config and travels by
|
|
1768
|
-
* `git clone`. Declaring a bundle grants nothing: every one of them is still
|
|
1769
|
-
* filtered by the caller's own workspace membership.
|
|
1770
|
-
*/
|
|
1771
|
-
bundleIds: v.pipe(v.array(NonEmptyStringSchema), v.maxLength(MAX_COMMENT_BUNDLE_IDS)),
|
|
1772
|
-
/**
|
|
1773
|
-
* The release asking. A person's reply on a thread counts as waiting only
|
|
1774
|
-
* for a release that renders threads; without it the answer is the roots-only
|
|
1775
|
-
* count every older release was given.
|
|
1776
|
-
*/
|
|
1777
|
-
cliVersion: v.optional(v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(64))),
|
|
1778
|
-
});
|
|
1779
|
-
/**
|
|
1780
|
-
* What an announcement answers: how many comments are waiting, and how many of
|
|
1781
|
-
* them this call was counted as announcing.
|
|
1782
|
-
*
|
|
1783
|
-
* **Two numbers because they answer two questions and a reader needs both.**
|
|
1784
|
-
* `open` is the true state of this repo's comments and is what a caller shows a
|
|
1785
|
-
* person — a number that is sometimes a subset of the truth would be worse
|
|
1786
|
-
* than the silence it replaced. `announced` is how many of those were still
|
|
1787
|
-
* under the cap, and it is the one that decides whether to speak at all: zero
|
|
1788
|
-
* means this reader has already been told about every one of them as often as
|
|
1789
|
-
* the cap allows.
|
|
1790
|
-
*/
|
|
1791
|
-
export const AnnounceItemCommentsResponseSchema = v.object({
|
|
1792
|
-
/** Open, unmuted comments about the items these bundles deliver to this reader. */
|
|
1793
|
-
open: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
1794
|
-
/** How many of those were under the cap and have now been counted as announced. */
|
|
1795
|
-
announced: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
1796
|
-
});
|
|
1797
|
-
/**
|
|
1798
|
-
* How many comments one agent session may leave on one subject, not counting its
|
|
1799
|
-
* whole-subject comment. Anchored comments and replies share it.
|
|
1800
|
-
*/
|
|
1801
|
-
export const MAX_AGENT_COMMENTS_PER_SUBJECT = 50;
|
|
1802
|
-
/** The longest an agent comment's text may be, in characters. */
|
|
1803
|
-
export const MAX_AGENT_COMMENT_BODY_CHARS = 4000;
|
|
1804
|
-
/**
|
|
1805
|
-
* Why an agent comment was refused, as the `code` on the error body. A caller
|
|
1806
|
-
* branches on these; the message beside one is for a person.
|
|
1807
|
-
*/
|
|
1808
|
-
export const AGENT_COMMENT_ERROR_CODES = [
|
|
1809
|
-
/** The request named no agent session. The CLI never makes one up. */
|
|
1810
|
-
'agent_session_required',
|
|
1811
|
-
/** This agent session has used its comments on the subject. */
|
|
1812
|
-
'agent_comment_limit_reached',
|
|
1813
|
-
/** An agent comment is text only: it may not carry replacement text. */
|
|
1814
|
-
'agent_comment_text_only',
|
|
1815
|
-
/** The subject or comment is not one this account can comment on. */
|
|
1816
|
-
'agent_comment_target_missing',
|
|
1817
|
-
/** A comment names a passage that is not whole lines of the item as it is now. */
|
|
1818
|
-
'agent_comment_passage_not_found',
|
|
1819
|
-
/** The passage appears more than once, so which one is meant is unknown. */
|
|
1820
|
-
'agent_comment_passage_ambiguous',
|
|
1821
|
-
/** The item already carries as many open comments as it may. */
|
|
1822
|
-
'item_comment_limit_reached',
|
|
1823
|
-
];
|
|
1824
|
-
export const AgentCommentErrorCodeSchema = v.picklist(AGENT_COMMENT_ERROR_CODES);
|
|
1825
|
-
const AgentCommentTargetIdSchema = v.pipe(v.string(), v.minLength(1), v.maxLength(128));
|
|
1826
|
-
/**
|
|
1827
|
-
* Leave a comment, or reply to one, as an agent (`POST /api/v1/context/comments`).
|
|
1828
|
-
*
|
|
1829
|
-
* **`target` names what the comment is about, one way.** `artifact` is the id
|
|
1830
|
-
* a bundle read gave for a guide or document, and `item` is its older name for
|
|
1831
|
-
* the same thing, accepted until every client sends `artifact`. `session` is an
|
|
1832
|
-
* agent session id of the caller's own (the key a search hit and the session digest hand out), and
|
|
1833
|
-
* `reply` is the id of a comment to answer. A reply joins that comment's thread
|
|
1834
|
-
* and the subject it is about.
|
|
1835
|
-
*
|
|
1836
|
-
* **Who the agent is comes from `agent`, and `sessionId` is the harness's own
|
|
1837
|
-
* id as the CLI read it.** A request without one is refused with
|
|
1838
|
-
* `agent_session_required`, and the CLI and tool offer no way to type one. The
|
|
1839
|
-
* server cannot check it against the harness, so it is a claim by the holder of
|
|
1840
|
-
* the token: the comment is always written under that token's account, and the
|
|
1841
|
-
* handle shown for it names a session only as far as the claim is true.
|
|
1842
|
-
*
|
|
1843
|
-
* **Text only.** There is no replacement-text field, and a request that carries
|
|
1844
|
-
* one is refused with `agent_comment_text_only` rather than having it dropped.
|
|
1845
|
-
*/
|
|
1846
|
-
export const AgentCommentRequestSchema = v.object({
|
|
1847
|
-
target: v.variant('kind', [
|
|
1848
|
-
v.object({ kind: v.literal('artifact'), id: AgentCommentTargetIdSchema }),
|
|
1849
|
-
v.object({ kind: v.literal('session'), id: AgentCommentTargetIdSchema }),
|
|
1850
|
-
v.object({ kind: v.literal('reply'), id: AgentCommentTargetIdSchema }),
|
|
1851
|
-
]),
|
|
1852
|
-
body: v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(MAX_AGENT_COMMENT_BODY_CHARS)),
|
|
1853
|
-
/**
|
|
1854
|
-
* The passage an item comment is about, as the exact text of one or more whole
|
|
1855
|
-
* lines of the item (a paragraph, a heading, a list). None means the item as a
|
|
1856
|
-
* whole. The server finds the lines; a passage that is not in the item as it is
|
|
1857
|
-
* now is refused with `agent_comment_passage_not_found`.
|
|
1858
|
-
*/
|
|
1859
|
-
passage: v.optional(v.pipe(v.string(), v.minLength(1), v.maxLength(8000))),
|
|
1860
|
-
agent: AgentIdentitySchema,
|
|
1861
|
-
/**
|
|
1862
|
-
* The reader's repo, as its committed `project.id`. A reply may name a
|
|
1863
|
-
* comment by the unique id prefix `list_comments` printed, and a comment
|
|
1864
|
-
* drafted from one repo's corrections is listed only to a read that declares
|
|
1865
|
-
* that repo, so it is matched only by a reply that declares it too.
|
|
1866
|
-
*/
|
|
1867
|
-
projectId: v.optional(ProjectIdSchema),
|
|
1868
|
-
/**
|
|
1869
|
-
* The bundles the reader's `list_comments` was scoped to, so an id prefix
|
|
1870
|
-
* printed there is matched among exactly those bundles. Without it the prefix
|
|
1871
|
-
* is matched among every bundle the caller can reach.
|
|
1872
|
-
*/
|
|
1873
|
-
bundleIds: v.optional(v.pipe(v.array(NonEmptyStringSchema), v.maxLength(MAX_COMMENT_BUNDLE_IDS))),
|
|
1874
|
-
});
|
|
1875
|
-
/** A batch may cover findings across several guides without one write per finding. */
|
|
1876
|
-
export const MAX_FINDING_DISMISSALS_PER_REQUEST = 100;
|
|
1877
|
-
export const FindingDismissalInputSchema = v.object({
|
|
1878
|
-
id: v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(128)),
|
|
1879
|
-
reason: v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(1000), v.check((reason) => !/[\r\n]/.test(reason), 'Use one line for the reason.')),
|
|
1880
|
-
});
|
|
1881
|
-
export const FindingDismissalInputsSchema = v.pipe(v.array(FindingDismissalInputSchema), v.minLength(1), v.maxLength(MAX_FINDING_DISMISSALS_PER_REQUEST), v.check((rows) => new Set(rows.map((row) => row.id)).size === rows.length, 'Name each finding only once.'));
|
|
1882
|
-
export const SuggestFindingDismissalsRequestSchema = v.object({
|
|
1883
|
-
suggestions: FindingDismissalInputsSchema,
|
|
1884
|
-
agent: AgentCommentRequestSchema.entries.agent,
|
|
1885
|
-
});
|
|
1886
|
-
/** Recommendations are separate from the finding's open/resolved state. */
|
|
1887
|
-
export const FindingDismissalSuggestionSchema = v.object({
|
|
1888
|
-
id: NonEmptyStringSchema,
|
|
1889
|
-
commentId: NonEmptyStringSchema,
|
|
1890
|
-
reason: NonEmptyStringSchema,
|
|
1891
|
-
agent: AgentCommentRequestSchema.entries.agent,
|
|
1892
|
-
guideVersion: v.number(),
|
|
1893
|
-
createdAt: v.string(),
|
|
1894
|
-
});
|
|
1895
|
-
export const SuggestFindingDismissalsResponseSchema = v.object({
|
|
1896
|
-
results: v.array(v.object({
|
|
1897
|
-
suggestion: FindingDismissalSuggestionSchema,
|
|
1898
|
-
created: v.boolean(),
|
|
1899
|
-
valid: v.boolean(),
|
|
1900
|
-
})),
|
|
1901
|
-
});
|
|
1902
|
-
export const FindingDismissalSuggestionsCursorSchema = v.object({
|
|
1903
|
-
id: v.pipe(v.string(), v.minLength(1), v.maxLength(128)),
|
|
1904
|
-
createdAt: v.pipe(v.string(), v.isoTimestamp()),
|
|
1905
|
-
});
|
|
1906
|
-
export const FindingDismissalSuggestionsResponseSchema = v.object({
|
|
1907
|
-
suggestions: v.array(FindingDismissalSuggestionSchema),
|
|
1908
|
-
nextCursor: v.nullable(FindingDismissalSuggestionsCursorSchema),
|
|
1909
|
-
});
|
|
1910
|
-
/**
|
|
1911
|
-
* The comment a create settled on. `created` is false when this agent session
|
|
1912
|
-
* already had a whole-subject comment on the subject: that comment comes back
|
|
1913
|
-
* unchanged and nothing was written.
|
|
1914
|
-
*/
|
|
1915
|
-
export const AgentCommentResponseSchema = v.object({
|
|
1916
|
-
created: v.boolean(),
|
|
1917
|
-
comment: v.object({
|
|
1918
|
-
id: v.string(),
|
|
1919
|
-
threadId: v.string(),
|
|
1920
|
-
subject: v.object({
|
|
1921
|
-
kind: v.picklist(['artifact', 'session']),
|
|
1922
|
-
id: v.string(),
|
|
1923
|
-
}),
|
|
1924
|
-
body: v.string(),
|
|
1925
|
-
createdAt: v.string(),
|
|
1926
|
-
}),
|
|
1927
|
-
});
|
|
1928
|
-
/**
|
|
1929
|
-
* One comment on the on-demand read, with the item it is about named on the comment.
|
|
1930
|
-
*
|
|
1931
|
-
* The item is named here rather than the comments riding an item, because this
|
|
1932
|
-
* read answers "what has been left for me" rather than "what is in this
|
|
1933
|
-
* bundle": there is no item payload to hang them off, and an agent that has to
|
|
1934
|
-
* ask for every item to find out whether one carries a comment is the round trip
|
|
1935
|
-
* the announcement exists to avoid.
|
|
1936
|
-
*/
|
|
1937
|
-
export const ItemCommentWithSubjectSchema = v.object({
|
|
1938
|
-
...ContextItemCommentSchema.entries,
|
|
1939
|
-
/** The item the comment is about, as the wire names it. */
|
|
1940
|
-
itemName: v.string(),
|
|
1941
|
-
/** The item's declared repo-relative path, or null when it has none. */
|
|
1942
|
-
itemPath: v.nullable(v.string()),
|
|
1943
|
-
});
|
|
1944
|
-
/**
|
|
1945
|
-
* Every open comment waiting for this reader across the bundles they named.
|
|
1946
|
-
*
|
|
1947
|
-
* **This read is a delivery and is counted as one**, exactly as comments riding
|
|
1948
|
-
* an item are: a body reached an agent. What it is *not* is an announcement —
|
|
1949
|
-
* nothing here touches the per-repo announcement count, so asking to read your
|
|
1950
|
-
* comments never spends the interruptions the hook is allowed.
|
|
1951
|
-
*
|
|
1952
|
-
* **Never capped.** The announcement cap governs whether a hook speaks; a
|
|
1953
|
-
* reader who asked is owed every open comment, and hiding one here would retire a
|
|
1954
|
-
* person's request without anybody deciding to.
|
|
1955
|
-
*/
|
|
1956
|
-
export const ItemCommentsResponseSchema = v.object({
|
|
1957
|
-
comments: v.array(ItemCommentWithSubjectSchema),
|
|
1958
|
-
cursor: v.optional(v.string()),
|
|
1959
|
-
/**
|
|
1960
|
-
* The markers every `body` above is wrapped in, plus a statement of what
|
|
1961
|
-
* they mean. Present exactly when at least one comment came back.
|
|
1962
|
-
*/
|
|
1963
|
-
untrusted: v.optional(v.nullable(GuideHistoryUntrustedSchema)),
|
|
1964
|
-
});
|
|
1965
|
-
/**
|
|
1966
|
-
* The evidence behind one Mossbear finding an agent was handed
|
|
1967
|
-
* (`GET /api/v1/context/comments/evidence`).
|
|
1968
|
-
*
|
|
1969
|
-
* `list_comments` carries the claim and a one-line tier; this is the finding
|
|
1970
|
-
* in full: the claim, the change it predicts in future sessions, what the
|
|
1971
|
-
* drafter did not read, and the evidence for its tier. Readable only through a
|
|
1972
|
-
* comment the comment read itself would deliver to this reader, so another
|
|
1973
|
-
* person's finding, one drafted from another repo, or a draft listed only to a
|
|
1974
|
-
* newer client has no evidence here either. A draft the reader was listed
|
|
1975
|
-
* does: an agent can say why it was raised before the person approves it.
|
|
1976
|
-
*
|
|
1977
|
-
* Citations (observed and usage findings) are reduced to what the reader may
|
|
1978
|
-
* see: their own sessions, with a date and a short excerpt of the grader's
|
|
1979
|
-
* reasoning or of their own redacted correction turn. A `navigation` citation
|
|
1980
|
-
* has an empty excerpt: it is dated evidence that a session loaded the skill,
|
|
1981
|
-
* and nothing more. `citationsWithheld` counts any that were dropped, so a
|
|
1982
|
-
* short list is never mistaken for the whole of it.
|
|
1983
|
-
*/
|
|
1984
|
-
export const CommentEvidenceCitationSchema = v.object({
|
|
1985
|
-
/**
|
|
1986
|
-
* `navigation` is a skill load counted when a finding was drafted from how
|
|
1987
|
-
* the skill's files were read: evidence of how a skill was used, not of a
|
|
1988
|
-
* failure. `action` is a recorded step of a workflow repeated across
|
|
1989
|
-
* sessions. `discrepancy` is a grader's note that a session's closing report
|
|
1990
|
-
* contradicted its recorded actions; its excerpt is the agent's quoted claim
|
|
1991
|
-
* and the record. `artifact_comment` is a person's comment on an artifact the
|
|
1992
|
-
* cited session wrote; its excerpt is the comment. A server sends `action`,
|
|
1993
|
-
* `discrepancy` and `artifact_comment` only to a client that names a version
|
|
1994
|
-
* new enough to parse them.
|
|
1995
|
-
*/
|
|
1996
|
-
kind: v.picklist([
|
|
1997
|
-
'verdict',
|
|
1998
|
-
'turn',
|
|
1999
|
-
'navigation',
|
|
2000
|
-
'action',
|
|
2001
|
-
'discrepancy',
|
|
2002
|
-
'artifact_comment',
|
|
2003
|
-
]),
|
|
2004
|
-
sessionId: NonEmptyStringSchema,
|
|
2005
|
-
/** ISO, when the verdict was graded, the turn was said, the skill loaded, or the action was recorded. */
|
|
2006
|
-
at: v.string(),
|
|
2007
|
-
/** Wrapped in the response's untrusted markers. */
|
|
2008
|
-
excerpt: v.string(),
|
|
2009
|
-
});
|
|
2010
|
-
/** What a usage finding adds to its citations: the counts for one reference file. */
|
|
2011
|
-
export const CommentEvidenceUsageSchema = v.object({
|
|
2012
|
-
/** The reference's skill-relative path, wrapped in the response's untrusted markers. */
|
|
2013
|
-
path: v.string(),
|
|
2014
|
-
/** Eligible loads of the skill. */
|
|
2015
|
-
loads: v.pipe(v.number(), v.integer()),
|
|
2016
|
-
/** Distinct sessions those loads span. */
|
|
2017
|
-
sessions: v.pipe(v.number(), v.integer()),
|
|
2018
|
-
/** Loads followed by a successful read of the reference. */
|
|
2019
|
-
loadsWithRead: v.pipe(v.number(), v.integer()),
|
|
2020
|
-
});
|
|
2021
|
-
/**
|
|
2022
|
-
* What a practice finding adds: the rubric check it answers and the rubric's
|
|
2023
|
-
* version, the practice lines it weighs with their sources, the facts measured
|
|
2024
|
-
* from the file, and the answer to each item of evidence the check asks for.
|
|
2025
|
-
* `answers[].answer` is model-written, so it travels wrapped in the response's
|
|
2026
|
-
* untrusted markers.
|
|
2027
|
-
*/
|
|
2028
|
-
export const CommentEvidencePracticeSchema = v.object({
|
|
2029
|
-
check: v.object({ id: v.string(), name: v.string() }),
|
|
2030
|
-
rubricVersion: v.pipe(v.number(), v.integer()),
|
|
2031
|
-
// Optional, so a CLI reads a dashboard that has not shipped these fields yet:
|
|
2032
|
-
// the two release independently.
|
|
2033
|
-
practices: v.optional(v.array(v.object({
|
|
2034
|
-
text: v.string(),
|
|
2035
|
-
source: v.object({ title: v.string(), url: v.string() }),
|
|
2036
|
-
})), []),
|
|
2037
|
-
facts: v.optional(v.array(v.string()), []),
|
|
2038
|
-
answers: v.optional(v.array(v.object({ item: v.string(), answer: v.string() })), []),
|
|
2039
|
-
});
|
|
2040
|
-
/**
|
|
2041
|
-
* A comment the person (or Mossbear) left on one of the sessions a finding
|
|
2042
|
-
* cites — the person's own account of what the agent should have known, set
|
|
2043
|
-
* beside the grader's excerpt (`guide-findings-plan.md` → Your note on a
|
|
2044
|
-
* session).
|
|
2045
|
-
*
|
|
2046
|
-
* **Reachable only here.** A comment about a session is never listed by
|
|
2047
|
-
* `list_comments` or announced at session start: it is context for a finding,
|
|
2048
|
-
* found by following the finding's citation, not a request.
|
|
2049
|
-
*/
|
|
2050
|
-
export const CommentEvidenceSessionCommentSchema = v.object({
|
|
2051
|
-
sessionId: NonEmptyStringSchema,
|
|
2052
|
-
/** Only the person's own notes are sent today; `mossbear` is reserved. */
|
|
2053
|
-
authorKind: v.picklist(['person', 'mossbear']),
|
|
2054
|
-
/** ISO, when the comment was written. */
|
|
2055
|
-
at: v.string(),
|
|
2056
|
-
/** Wrapped in the response's untrusted markers. */
|
|
2057
|
-
body: v.string(),
|
|
2058
|
-
});
|
|
2059
|
-
export const CommentEvidenceResponseSchema = v.object({
|
|
2060
|
-
/** The comment's full id, even when the request named a prefix. */
|
|
2061
|
-
commentId: NonEmptyStringSchema,
|
|
2062
|
-
itemName: v.string(),
|
|
2063
|
-
itemPath: v.nullable(v.string()),
|
|
2064
|
-
tier: FindingTierSchema,
|
|
2065
|
-
/** One line saying how the finding is known; server-written, outside the markers. */
|
|
2066
|
-
tierLine: v.string(),
|
|
2067
|
-
/** What the drafter did not read; server-written, outside the markers. */
|
|
2068
|
-
blindSpot: v.string(),
|
|
2069
|
-
/** What goes wrong, wrapped in the response's untrusted markers. */
|
|
2070
|
-
claim: v.string(),
|
|
2071
|
-
/** What future sessions should show if the finding is fixed, wrapped; null if none. */
|
|
2072
|
-
prediction: v.nullable(v.string()),
|
|
2073
|
-
/** A usage finding's counts; null on every other tier. */
|
|
2074
|
-
usage: v.nullable(CommentEvidenceUsageSchema),
|
|
2075
|
-
/** A practice finding's rubric check; null on every other tier. */
|
|
2076
|
-
practice: v.nullable(CommentEvidencePracticeSchema),
|
|
2077
|
-
citations: v.array(CommentEvidenceCitationSchema),
|
|
2078
|
-
citationsWithheld: v.pipe(v.number(), v.integer()),
|
|
2079
|
-
/**
|
|
2080
|
-
* Comments on the cited sessions, newest first, wrapped in the untrusted
|
|
2081
|
-
* markers. Defaulted so a response from a server that predates the field
|
|
2082
|
-
* still parses.
|
|
2083
|
-
*/
|
|
2084
|
-
sessionComments: v.optional(v.array(CommentEvidenceSessionCommentSchema), []),
|
|
2085
|
-
/**
|
|
2086
|
-
* Comments on the cited sessions that were left out to keep the response
|
|
2087
|
-
* bounded (the newest few per session are sent), so a short list is never
|
|
2088
|
-
* mistaken for the whole of it. Zero when none were.
|
|
2089
|
-
*/
|
|
2090
|
-
sessionCommentsWithheld: v.optional(v.pipe(v.number(), v.integer()), 0),
|
|
2091
|
-
untrusted: GuideHistoryUntrustedSchema,
|
|
2092
|
-
});
|
|
2093
1404
|
// A capture id the *client* minted, so a capture has a name before it has a
|
|
2094
1405
|
// server — `offline-doc-editing-plan.md` → slice 4.
|
|
2095
1406
|
//
|
|
@@ -4325,8 +3636,6 @@ export const ArtifactFeedbackResponseSchema = v.object({
|
|
|
4325
3636
|
/** Present exactly when `grading` is null. */
|
|
4326
3637
|
gradingUnavailable: v.optional(ArtifactGradingUnavailableSchema),
|
|
4327
3638
|
});
|
|
4328
|
-
/** Most artifacts one batch feedback read may name. */
|
|
4329
|
-
export const MAX_ARTIFACT_FEEDBACK_BATCH = 25;
|
|
4330
3639
|
/**
|
|
4331
3640
|
* `POST /api/v1/artifacts/feedback` body: several artifacts read at once, each
|
|
4332
3641
|
* paged as `GET .../:id/feedback` pages it (`cursor` is that artifact's own
|
|
@@ -4354,692 +3663,6 @@ export const ArtifactFeedbackBatchResponseSchema = v.object({
|
|
|
4354
3663
|
unavailable: v.optional(v.literal(true)),
|
|
4355
3664
|
})),
|
|
4356
3665
|
});
|
|
4357
|
-
/**
|
|
4358
|
-
* How many artifacts one prompt-time announcement names. The rest are counted
|
|
4359
|
-
* in one line and named on a later prompt, so a session that wrote many
|
|
4360
|
-
* artifacts prints a few lines in front of a turn rather than a list.
|
|
4361
|
-
*/
|
|
4362
|
-
export const MAX_SESSION_COMMENT_ANNOUNCEMENT_ARTIFACTS = 5;
|
|
4363
|
-
/**
|
|
4364
|
-
* Ask which artifacts this agent session wrote carry open comments, and which
|
|
4365
|
-
* (`agent-hears-new-artifact-comments` slice 3).
|
|
4366
|
-
*
|
|
4367
|
-
* **A read, not a write.** Which of those comments the session has already been
|
|
4368
|
-
* told about is kept beside the session, by comment id. Not by creation time:
|
|
4369
|
-
* a comment can become readable long after it was created (a finding its owner
|
|
4370
|
-
* approves, an artifact restored from the Trash), and a time cursor would have
|
|
4371
|
-
* passed it by. The session-start announcement's per-repo count is a different
|
|
4372
|
-
* question and is not touched.
|
|
4373
|
-
*/
|
|
4374
|
-
export const AnnounceSessionCommentsRequestSchema = v.object({
|
|
4375
|
-
/**
|
|
4376
|
-
* The harness's own id for the session, as artifact writes record it in a
|
|
4377
|
-
* version's metadata. Matched only against versions the caller's account
|
|
4378
|
-
* wrote, so naming another account's session finds nothing.
|
|
4379
|
-
*/
|
|
4380
|
-
agentSessionId: v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(256)),
|
|
4381
|
-
/** The repo asking, as its committed config declares it, for repo-scoped findings. */
|
|
4382
|
-
projectId: v.optional(ProjectIdSchema),
|
|
4383
|
-
});
|
|
4384
|
-
export const AnnounceSessionCommentsResponseSchema = v.object({
|
|
4385
|
-
/**
|
|
4386
|
-
* The session's artifacts that carry open comments, most recently commented
|
|
4387
|
-
* first; at most as many as one batch feedback read takes.
|
|
4388
|
-
*/
|
|
4389
|
-
artifacts: v.pipe(v.array(v.object({
|
|
4390
|
-
id: NonEmptyStringSchema,
|
|
4391
|
-
name: v.string(),
|
|
4392
|
-
/** Its open comments, newest first, at most one wire allowance of them. */
|
|
4393
|
-
commentIds: v.pipe(v.array(NonEmptyStringSchema), v.minLength(1), v.maxLength(MAX_ITEM_COMMENTS_ON_WIRE)),
|
|
4394
|
-
})), v.maxLength(MAX_ARTIFACT_FEEDBACK_BATCH)),
|
|
4395
|
-
});
|
|
4396
|
-
// ---------------------------------------------------------------------------
|
|
4397
|
-
// Run grade — one run's verdict, for the terminal (`GET /api/v1/runs/grade`)
|
|
4398
|
-
// ---------------------------------------------------------------------------
|
|
4399
|
-
/**
|
|
4400
|
-
* One session's grade, read by the MCP `session_digest` tool.
|
|
4401
|
-
*
|
|
4402
|
-
* The loop this closes: a session ends with "synced N item(s) to the
|
|
4403
|
-
* dashboard." and the verdict exists only in the dashboard. This is the read
|
|
4404
|
-
* that brings it back to the terminal the work happened in.
|
|
4405
|
-
*
|
|
4406
|
-
* **Evidence out, never instructions out** — the same contract as the guide
|
|
4407
|
-
* history read above. It returns data and never a directive; nothing on the
|
|
4408
|
-
* server writes as a result of it.
|
|
4409
|
-
*/
|
|
4410
|
-
/**
|
|
4411
|
-
* How the caller names the run. Exactly one of the two.
|
|
4412
|
-
*
|
|
4413
|
-
* The CLI only ever knows an *agent session* id — the `SessionEnd` hook
|
|
4414
|
-
* payload's `session_id`, which `mossbear complete` reports — so
|
|
4415
|
-
* the `agent_session` form is the one it uses. The session id is for a caller
|
|
4416
|
-
* that already has one, from a dashboard URL say. Both are opaque and both
|
|
4417
|
-
* reach a SQL predicate, so they are bounded and shape-checked here.
|
|
4418
|
-
*/
|
|
4419
|
-
const SessionGradeIdentifierSchema = v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(256), v.check((value) => !/[\u0000-\u001f\u007f]/.test(value), 'identifier must not contain control characters'));
|
|
4420
|
-
export const SessionGradeRequestSchema = v.pipe(v.object({
|
|
4421
|
-
session: v.optional(SessionGradeIdentifierSchema),
|
|
4422
|
-
agent_session: v.optional(SessionGradeIdentifierSchema),
|
|
4423
|
-
/**
|
|
4424
|
-
* Opt in to the session digest: the grade plus the turns, self-report and
|
|
4425
|
-
* git position of the session. Omitted, the small grade payload is
|
|
4426
|
-
* returned unchanged.
|
|
4427
|
-
*/
|
|
4428
|
-
detail: v.optional(v.literal('digest')),
|
|
4429
|
-
}), v.check((request) => (request.session !== undefined) !== (request.agent_session !== undefined), 'Pass exactly one of session or agent_session'));
|
|
4430
|
-
/**
|
|
4431
|
-
* Which of four states the run's grade is in — a required field rather than
|
|
4432
|
-
* something a reader infers from a null `grade`.
|
|
4433
|
-
*
|
|
4434
|
-
* These states need different sentences, and the absence of a grade is never
|
|
4435
|
-
* one of them on its own:
|
|
4436
|
-
*
|
|
4437
|
-
* - `pending` — no grade yet, and the grading sweep can still pick the run
|
|
4438
|
-
* up (it is open, or closed inside the grading window). "Not graded yet"
|
|
4439
|
-
* is honest here and only here — unless `gradeFailedAttempts` is above
|
|
4440
|
-
* zero, when grading has been tried and has not finished.
|
|
4441
|
-
* - `graded` — a grader judged it; `grade` carries what it said.
|
|
4442
|
-
* - `nothing_to_grade` — a grader ran and found nothing to judge: no
|
|
4443
|
-
* gradeable actions, or no guides in the agent's context. The record
|
|
4444
|
-
* cannot tell those two apart, so neither can the sentence.
|
|
4445
|
-
* - `expired` — no grade, and the run closed too long ago for the sweep to
|
|
4446
|
-
* select it. It will never be graded, and telling a reader to wait would
|
|
4447
|
-
* promise work the system does not do.
|
|
4448
|
-
* - `grading_off` — only usage was synced; no behavioral grade is requested.
|
|
4449
|
-
*/
|
|
4450
|
-
export const SessionGradeStateSchema = v.picklist([
|
|
4451
|
-
'pending',
|
|
4452
|
-
'graded',
|
|
4453
|
-
'nothing_to_grade',
|
|
4454
|
-
'expired',
|
|
4455
|
-
'grading_off',
|
|
4456
|
-
]);
|
|
4457
|
-
/**
|
|
4458
|
-
* The run-level verdict vocabulary — `aligned | misaligned | not_applicable`.
|
|
4459
|
-
* `not_applicable` is a guide that was in the agent's context and that the
|
|
4460
|
-
* session never engaged. It is not `unguided`, which is an action-level word,
|
|
4461
|
-
* and neither is ever restated in terms of the other.
|
|
4462
|
-
*/
|
|
4463
|
-
export const SESSION_GUIDE_VERDICTS = ['aligned', 'misaligned', 'not_applicable'];
|
|
4464
|
-
export const SessionGuideVerdictValueSchema = v.picklist(SESSION_GUIDE_VERDICTS);
|
|
4465
|
-
/** One guide's verdict for the run, with the grader's reasoning wrapped. */
|
|
4466
|
-
export const SessionGradeGuideSchema = v.object({
|
|
4467
|
-
guideId: NonEmptyStringSchema,
|
|
4468
|
-
title: v.string(),
|
|
4469
|
-
verdict: SessionGuideVerdictValueSchema,
|
|
4470
|
-
/**
|
|
4471
|
-
* The grader's reasoning, **already wrapped in the response's untrusted
|
|
4472
|
-
* markers** — model-authored text derived from a transcript, delimited at the
|
|
4473
|
-
* source so a consumer cannot skip the markers. Empty between the markers
|
|
4474
|
-
* when the row recorded none.
|
|
4475
|
-
*/
|
|
4476
|
-
reasoning: v.string(),
|
|
4477
|
-
});
|
|
4478
|
-
export const SessionGradeSchema = v.object({
|
|
4479
|
-
/** The grader's one-paragraph judgment of the run, wrapped like `reasoning`; null when the record carries none. */
|
|
4480
|
-
summary: v.nullable(v.string()),
|
|
4481
|
-
/** ISO timestamp, machine format — display formatting is the reader's job. */
|
|
4482
|
-
gradedAt: v.string(),
|
|
4483
|
-
/** The model that produced the judgment, or null when the record does not say. */
|
|
4484
|
-
model: v.nullable(v.string()),
|
|
4485
|
-
/**
|
|
4486
|
-
* True when the run grew after this grade was written — a later sync
|
|
4487
|
-
* attached more actions — so the judgment describes a smaller run than the
|
|
4488
|
-
* one on record. A superseded grade is real and is still reported; it is
|
|
4489
|
-
* labelled rather than hidden.
|
|
4490
|
-
*/
|
|
4491
|
-
superseded: v.boolean(),
|
|
4492
|
-
guides: v.array(SessionGradeGuideSchema),
|
|
4493
|
-
});
|
|
4494
|
-
export const GradedSessionSchema = v.object({
|
|
4495
|
-
id: NonEmptyStringSchema,
|
|
4496
|
-
agentSessionId: NonEmptyStringSchema,
|
|
4497
|
-
startedAt: v.string(),
|
|
4498
|
-
endedAt: v.nullable(v.string()),
|
|
4499
|
-
status: v.picklist(['open', 'closed']),
|
|
4500
|
-
});
|
|
4501
|
-
/**
|
|
4502
|
-
* Grading passes on the run's current content that ended without a grade:
|
|
4503
|
-
* a provider error, quota spent, a response that did not parse. It sits
|
|
4504
|
-
* beside `state` rather than adding one, because the sweep keeps retrying
|
|
4505
|
-
* such a run, so it is still `pending` (or `expired` once the window closes),
|
|
4506
|
-
* and a new `state` value would fail every installed client's parse. Above
|
|
4507
|
-
* zero beside `pending`, "not graded yet" is no longer the whole answer:
|
|
4508
|
-
* grading was tried, did not finish, and is still being retried. Beside a
|
|
4509
|
-
* superseded `graded`, it counts failed re-grades of the newer content.
|
|
4510
|
-
* Absent from a server that predates it, which means "not reported", never 0.
|
|
4511
|
-
*/
|
|
4512
|
-
const GradeFailedAttemptsSchema = v.optional(v.pipe(v.number(), v.integer(), v.minValue(0)));
|
|
4513
|
-
export const SessionGradeResponseSchema = v.object({
|
|
4514
|
-
run: GradedSessionSchema,
|
|
4515
|
-
state: SessionGradeStateSchema,
|
|
4516
|
-
gradeFailedAttempts: GradeFailedAttemptsSchema,
|
|
4517
|
-
/** Present exactly when `state` is `graded`. */
|
|
4518
|
-
grade: v.nullable(SessionGradeSchema),
|
|
4519
|
-
/**
|
|
4520
|
-
* The markers every `summary` and `reasoning` in this response is wrapped in.
|
|
4521
|
-
* Present exactly when `grade` is — there is nothing to delimit otherwise.
|
|
4522
|
-
*/
|
|
4523
|
-
untrusted: v.nullable(GuideHistoryUntrustedSchema),
|
|
4524
|
-
});
|
|
4525
|
-
// ---------------------------------------------------------------------------
|
|
4526
|
-
// Session digest — `GET /api/v1/runs/grade?detail=digest`
|
|
4527
|
-
// ---------------------------------------------------------------------------
|
|
4528
|
-
/** Most turns one digest returns; `turnsTotal` says how many the session has. */
|
|
4529
|
-
export const SESSION_DIGEST_MAX_TURNS = 50;
|
|
4530
|
-
/** What the digest cannot carry yet, named so an absence is never read as "none". */
|
|
4531
|
-
export const SESSION_DIGEST_UNAVAILABLE = [
|
|
4532
|
-
'comments',
|
|
4533
|
-
'resumeCommand',
|
|
4534
|
-
'cloudUrl',
|
|
4535
|
-
];
|
|
4536
|
-
export const SessionDigestUnavailableSchema = v.picklist(SESSION_DIGEST_UNAVAILABLE);
|
|
4537
|
-
export const SessionDigestTurnSchema = v.object({
|
|
4538
|
-
ordinal: v.number(),
|
|
4539
|
-
/** What the user said, **wrapped in the response's untrusted markers** and bounded. */
|
|
4540
|
-
text: v.string(),
|
|
4541
|
-
/** The steering classifier's label, or null when the turn was never classified. */
|
|
4542
|
-
steeringLabel: v.nullable(v.string()),
|
|
4543
|
-
});
|
|
4544
|
-
export const SessionDigestSchema = v.object({
|
|
4545
|
-
/** The agent's own closing account of the session, wrapped and bounded; null when it gave none. */
|
|
4546
|
-
selfReport: v.nullable(v.string()),
|
|
4547
|
-
/** The user's turns in order, at most `SESSION_DIGEST_MAX_TURNS`. */
|
|
4548
|
-
turns: v.array(SessionDigestTurnSchema),
|
|
4549
|
-
/** Every turn the session recorded, so a cut list is not read as the whole. */
|
|
4550
|
-
turnsTotal: v.number(),
|
|
4551
|
-
/** The repository's identity digest, or null when the session recorded none. */
|
|
4552
|
-
repoId: v.nullable(v.string()),
|
|
4553
|
-
/** The branch observed at close, wrapped like any text taken from the repo; null when unrecorded. */
|
|
4554
|
-
branch: v.nullable(v.string()),
|
|
4555
|
-
/** The head commit observed at close, or null. A commit made mid-session is not it. */
|
|
4556
|
-
headSha: v.nullable(v.string()),
|
|
4557
|
-
/** The session's page on the dashboard, as a path; the client prefixes the dashboard address. */
|
|
4558
|
-
dashboardPath: v.string(),
|
|
4559
|
-
/** Absolute dashboard link, added by the client that knows the address. */
|
|
4560
|
-
dashboardUrl: v.optional(v.string()),
|
|
4561
|
-
/** Comments on this session, wrapped; empty until sessions can be commented on. */
|
|
4562
|
-
comments: v.array(v.string()),
|
|
4563
|
-
/** The parts of a digest no session carries yet. */
|
|
4564
|
-
notYetAvailable: v.array(SessionDigestUnavailableSchema),
|
|
4565
|
-
});
|
|
4566
|
-
export const SessionDigestResponseSchema = v.object({
|
|
4567
|
-
run: GradedSessionSchema,
|
|
4568
|
-
state: SessionGradeStateSchema,
|
|
4569
|
-
gradeFailedAttempts: GradeFailedAttemptsSchema,
|
|
4570
|
-
grade: v.nullable(SessionGradeSchema),
|
|
4571
|
-
digest: SessionDigestSchema,
|
|
4572
|
-
/** One marker pair over every wrapped block in the response, present always. */
|
|
4573
|
-
untrusted: GuideHistoryUntrustedSchema,
|
|
4574
|
-
});
|
|
4575
|
-
// ---------------------------------------------------------------------------
|
|
4576
|
-
// Search — one term across the caller's evidence (`GET /api/v1/search`)
|
|
4577
|
-
// ---------------------------------------------------------------------------
|
|
4578
|
-
/**
|
|
4579
|
-
* The corpora a search can reach today.
|
|
4580
|
-
*
|
|
4581
|
-
* `guides` is guide bodies and their author-written eval criteria; `verdicts`
|
|
4582
|
-
* is the grader's reasoning for why a session did or did not follow a guide;
|
|
4583
|
-
* `content` is the name and body of the documents saved in bundles; `comments`
|
|
4584
|
-
* is the text of comments left on guides and documents and, for a caller that
|
|
4585
|
-
* reads them (`SearchRequest.sessionComments`), on its own sessions; `turns` is what the
|
|
4586
|
-
* caller themself said to their agents, redacted; `sessions` is the grader's
|
|
4587
|
-
* summary of the caller's own sessions and the agent's closing report. One
|
|
4588
|
-
* registry on the server declares how each is matched and scoped; this list is
|
|
4589
|
-
* only what a caller may name.
|
|
4590
|
-
*/
|
|
4591
|
-
export const SEARCH_CORPUS_IDS = [
|
|
4592
|
-
'guides',
|
|
4593
|
-
'verdicts',
|
|
4594
|
-
'content',
|
|
4595
|
-
'comments',
|
|
4596
|
-
'turns',
|
|
4597
|
-
'sessions',
|
|
4598
|
-
];
|
|
4599
|
-
export const SearchCorpusIdSchema = v.picklist(SEARCH_CORPUS_IDS);
|
|
4600
|
-
/**
|
|
4601
|
-
* Every stored text no search reaches yet — the actions and their narration.
|
|
4602
|
-
* Every response names them, so "nothing found" can never be read as covering
|
|
4603
|
-
* them. (Earlier wordings of a guide are deliberately never searched, which is a
|
|
4604
|
-
* different thing from not yet.)
|
|
4605
|
-
*/
|
|
4606
|
-
export const SEARCH_UNIMPLEMENTED_CORPORA = ['actions'];
|
|
4607
|
-
/**
|
|
4608
|
-
* What a response still names as not searched for a caller that did not say it
|
|
4609
|
-
* reads session comments (`SearchRequest.sessionComments`): they were left out
|
|
4610
|
-
* of its `comments`, so saying otherwise would read a zero as covering them.
|
|
4611
|
-
*/
|
|
4612
|
-
export const SEARCH_SESSION_COMMENTS_UNSEARCHED = 'session-comments';
|
|
4613
|
-
export const SearchUnimplementedCorpusSchema = v.picklist(SEARCH_UNIMPLEMENTED_CORPORA);
|
|
4614
|
-
/** Hits returned per corpus when the caller does not say. */
|
|
4615
|
-
export const SEARCH_DEFAULT_LIMIT = 10;
|
|
4616
|
-
/** The most hits one corpus returns. Totals are counted past it. */
|
|
4617
|
-
export const SEARCH_MAX_LIMIT = 25;
|
|
4618
|
-
/**
|
|
4619
|
-
* The term. Literal, case-insensitive, with `*` and `?` as the only wildcards —
|
|
4620
|
-
* not a regex, which an unindexed shared database cannot afford.
|
|
4621
|
-
*
|
|
4622
|
-
* At least two characters after trimming, not counting wildcards: every row
|
|
4623
|
-
* matches one character (or `**`), so a shorter term is a scan with no question
|
|
4624
|
-
* behind it.
|
|
4625
|
-
*/
|
|
4626
|
-
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'),
|
|
4627
|
-
// Wildcards do not count toward the two: `**` is a pattern that matches
|
|
4628
|
-
// every row, which is the scan the minimum exists to refuse.
|
|
4629
|
-
v.check((value) => value.replace(/[*?]/g, '').length >= 2, 'q must contain at least 2 characters besides * and ?'));
|
|
4630
|
-
/**
|
|
4631
|
-
* How much of each guide hit to return — progressive disclosure, so a search
|
|
4632
|
-
* costs an agent little context until it asks for more.
|
|
4633
|
-
*
|
|
4634
|
-
* - `excerpt` (the default): a short window around the match, kept inside the
|
|
4635
|
-
* match's Markdown section, plus the section's heading path. A short section
|
|
4636
|
-
* comes back whole, and a longer one says how long it is (`sectionChars`).
|
|
4637
|
-
* - `section`: the whole section that holds the match, capped. Meant for one
|
|
4638
|
-
* hit at a time — pass the hit's `fileId` in `fileIds`.
|
|
4639
|
-
*/
|
|
4640
|
-
export const SEARCH_DETAILS = ['excerpt', 'section'];
|
|
4641
|
-
export const SearchDetailSchema = v.picklist(SEARCH_DETAILS);
|
|
4642
|
-
/** Frontmatter filters a `content` search accepts at once. */
|
|
4643
|
-
export const SEARCH_MAX_FRONTMATTER_FILTERS = 3;
|
|
4644
|
-
/**
|
|
4645
|
-
* One top-level frontmatter field a `content` item must carry, by exact scalar
|
|
4646
|
-
* value (`type: recipe`). The key is a plain YAML key so it can be matched
|
|
4647
|
-
* without being interpreted; the value is literal text, compared
|
|
4648
|
-
* case-insensitively.
|
|
4649
|
-
*/
|
|
4650
|
-
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) => {
|
|
4651
|
-
const count = Object.keys(fields).length;
|
|
4652
|
-
return count >= 1 && count <= SEARCH_MAX_FRONTMATTER_FILTERS;
|
|
4653
|
-
}, `frontmatter takes between 1 and ${SEARCH_MAX_FRONTMATTER_FILTERS} fields`));
|
|
4654
|
-
/** Who wrote a comment: a person, an agent, or Mossbear itself. */
|
|
4655
|
-
export const SEARCH_COMMENT_AUTHOR_KINDS = CommentAuthorKindSchema.options;
|
|
4656
|
-
export const SearchCommentAuthorKindSchema = CommentAuthorKindSchema;
|
|
4657
|
-
/**
|
|
4658
|
-
* What a comment is attached to. `artifact` is a guide or a document; `session`
|
|
4659
|
-
* is a run the caller made. Session comments are the caller's own and never reach
|
|
4660
|
-
* a workspace-mate.
|
|
4661
|
-
*/
|
|
4662
|
-
/**
|
|
4663
|
-
* The subject kinds a client names in a search: `artifact`, never its older
|
|
4664
|
-
* name `item`.
|
|
4665
|
-
*/
|
|
4666
|
-
export const SEARCH_COMMENT_SUBJECT_KIND_NAMES = ['artifact', 'session'];
|
|
4667
|
-
export const SearchCommentSubjectKindFilterSchema = v.picklist(SEARCH_COMMENT_SUBJECT_KIND_NAMES);
|
|
4668
|
-
/**
|
|
4669
|
-
* What a user turn was, as the session classifier labels it. The same
|
|
4670
|
-
* vocabulary the classifier writes; a `turns` search may keep only some.
|
|
4671
|
-
*/
|
|
4672
|
-
export const SEARCH_STEERING_LABELS = [
|
|
4673
|
-
'correction',
|
|
4674
|
-
'steering',
|
|
4675
|
-
'new request',
|
|
4676
|
-
'acknowledgement',
|
|
4677
|
-
'insufficient evidence',
|
|
4678
|
-
];
|
|
4679
|
-
export const SearchSteeringLabelSchema = v.picklist(SEARCH_STEERING_LABELS);
|
|
4680
|
-
/**
|
|
4681
|
-
* One exact value a `sessions` search filters on — a head sha, a branch name or
|
|
4682
|
-
* a repo digest. Compared as written, so it is trimmed and bounded but never
|
|
4683
|
-
* case-folded or treated as a pattern.
|
|
4684
|
-
*/
|
|
4685
|
-
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'));
|
|
4686
|
-
export const SearchRequestObjectSchema = v.object({
|
|
4687
|
-
/**
|
|
4688
|
-
* The term. Optional only for a `sessions` search that names a filter (`headSha`,
|
|
4689
|
-
* `branch` or `repoId`): "which session ended at this commit" has no words to match.
|
|
4690
|
-
*/
|
|
4691
|
-
q: v.optional(SearchTermSchema),
|
|
4692
|
-
/** Which corpora to search; every one when absent. */
|
|
4693
|
-
corpora: v.optional(v.pipe(v.array(SearchCorpusIdSchema), v.minLength(1))),
|
|
4694
|
-
/**
|
|
4695
|
-
* The bundles a scoped caller may read content from — `mossbear mcp
|
|
4696
|
-
* --bundles` resolved to ids by the CLI, since the server never sees that
|
|
4697
|
-
* flag. **Present means narrowed**, even when empty: an allowlist that
|
|
4698
|
-
* reaches no bundle narrows the content corpora to nothing, never to
|
|
4699
|
-
* everything. Absent means the caller is not bundle-scoped.
|
|
4700
|
-
*/
|
|
4701
|
-
bundleIds: v.optional(v.pipe(v.array(NonEmptyStringSchema), v.maxLength(200))),
|
|
4702
|
-
limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(SEARCH_MAX_LIMIT))),
|
|
4703
|
-
/** How much of each guide hit to return; `excerpt` when absent. */
|
|
4704
|
-
detail: v.optional(SearchDetailSchema),
|
|
4705
|
-
/**
|
|
4706
|
-
* Restrict the guides corpus to these guide files — the `fileId`s of earlier
|
|
4707
|
-
* hits, to expand them. Narrows within the caller's scope, never past it: an
|
|
4708
|
-
* id the caller cannot read matches nothing. Does not touch other corpora.
|
|
4709
|
-
*/
|
|
4710
|
-
fileIds: v.optional(v.pipe(v.array(NonEmptyStringSchema), v.minLength(1), v.maxLength(SEARCH_MAX_LIMIT))),
|
|
4711
|
-
/**
|
|
4712
|
-
* Restrict the `content` corpus to items whose frontmatter carries every one
|
|
4713
|
-
* of these fields. Does not touch other corpora.
|
|
4714
|
-
*/
|
|
4715
|
-
frontmatter: v.optional(SearchFrontmatterSchema),
|
|
4716
|
-
/**
|
|
4717
|
-
* Restrict the `comments` corpus to comments written by these kinds of
|
|
4718
|
-
* author. Does not touch other corpora.
|
|
4719
|
-
*/
|
|
4720
|
-
authorKinds: v.optional(v.pipe(v.array(SearchCommentAuthorKindSchema), v.minLength(1))),
|
|
4721
|
-
/**
|
|
4722
|
-
* Restrict the `comments` corpus to comments on these kinds of subject. Does
|
|
4723
|
-
* not touch other corpora.
|
|
4724
|
-
*/
|
|
4725
|
-
subjectKinds: v.optional(v.pipe(v.array(SearchCommentSubjectKindFilterSchema), v.minLength(1))),
|
|
4726
|
-
/**
|
|
4727
|
-
* Restrict the `turns` corpus to turns the classifier gave one of these
|
|
4728
|
-
* labels. A turn with no label never matches. Does not touch other corpora.
|
|
4729
|
-
*/
|
|
4730
|
-
steeringLabels: v.optional(v.pipe(v.array(SearchSteeringLabelSchema), v.minLength(1))),
|
|
4731
|
-
/**
|
|
4732
|
-
* Restrict the `sessions` corpus to sessions whose recorded head was exactly
|
|
4733
|
-
* this commit when they closed. A commit made mid-session matches nothing:
|
|
4734
|
-
* the head is the one observed at close. Does not touch other corpora.
|
|
4735
|
-
*/
|
|
4736
|
-
headSha: v.optional(SearchSessionFilterValueSchema),
|
|
4737
|
-
/** Restrict the `sessions` corpus to sessions that closed on exactly this branch. Does not touch other corpora. */
|
|
4738
|
-
branch: v.optional(SearchSessionFilterValueSchema),
|
|
4739
|
-
/** Restrict the `sessions` corpus to sessions recorded under exactly this repo id. Does not touch other corpora. */
|
|
4740
|
-
repoId: v.optional(SearchSessionFilterValueSchema),
|
|
4741
|
-
/**
|
|
4742
|
-
* Whether the caller can read a `comments` hit on a session. A client from
|
|
4743
|
-
* before session comments were searchable validates the whole response
|
|
4744
|
-
* strictly and would reject one, so the server returns them only to a caller
|
|
4745
|
-
* that says it can, and tells every other caller they were not searched.
|
|
4746
|
-
* Absent means it cannot.
|
|
4747
|
-
*/
|
|
4748
|
-
sessionComments: v.optional(v.boolean()),
|
|
4749
|
-
});
|
|
4750
|
-
/**
|
|
4751
|
-
* A request with no term searches the caller's sessions by filter alone, so it
|
|
4752
|
-
* must name one, and must not name another corpus (which has nothing to match).
|
|
4753
|
-
*/
|
|
4754
|
-
export const SearchRequestSchema = v.pipe(SearchRequestObjectSchema, v.forward(v.check((request) => request.q !== undefined ||
|
|
4755
|
-
request.headSha !== undefined ||
|
|
4756
|
-
request.branch !== undefined ||
|
|
4757
|
-
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 ||
|
|
4758
|
-
request.corpora === undefined ||
|
|
4759
|
-
request.corpora.every((id) => id === 'sessions'), 'without q only the sessions corpus can be searched'), ['corpora']));
|
|
4760
|
-
/**
|
|
4761
|
-
* Why a corpus was not searched. Codes, never prose: each caller writes its own
|
|
4762
|
-
* sentence, and the dashboard's has to be a translatable one.
|
|
4763
|
-
*/
|
|
4764
|
-
export const SearchSkipReasonSchema = v.picklist([
|
|
4765
|
-
'excluded-by-caller',
|
|
4766
|
-
'timed-out',
|
|
4767
|
-
// The caller's token is limited to certain bundles, and grading results, the
|
|
4768
|
-
// caller's turns and sessions, and comments on their sessions are never among
|
|
4769
|
-
// what such a token reaches.
|
|
4770
|
-
'not-granted',
|
|
4771
|
-
// A filter named only kinds of subject this caller cannot be given: `session`
|
|
4772
|
-
// from a client that did not say it reads session comments, which is also what
|
|
4773
|
-
// a server from before they were searchable said to every caller.
|
|
4774
|
-
'not-yet-searchable',
|
|
4775
|
-
]);
|
|
4776
|
-
/** Why a searched corpus covered less than the caller's whole scope. */
|
|
4777
|
-
export const SearchNarrowingSchema = v.picklist(['narrowed-by-bundle-allowlist']);
|
|
4778
|
-
/** A guide file whose text matched. The excerpt is wrapped in `untrusted`'s markers. */
|
|
4779
|
-
export const SearchGuideHitSchema = v.object({
|
|
4780
|
-
guideId: NonEmptyStringSchema,
|
|
4781
|
-
/** Wrapped in `untrusted`'s markers; null when nothing names the guide. */
|
|
4782
|
-
guideTitle: v.nullable(v.string()),
|
|
4783
|
-
fileId: NonEmptyStringSchema,
|
|
4784
|
-
path: v.nullable(v.string()),
|
|
4785
|
-
/** The guide's own body, or its author-written eval criteria. */
|
|
4786
|
-
part: v.picklist(['body', 'criteria']),
|
|
4787
|
-
/**
|
|
4788
|
-
* The heading path of the Markdown section that holds the match, joined with
|
|
4789
|
-
* `SECTION_PATH_SEPARATOR` and wrapped in `untrusted`'s markers — a heading is
|
|
4790
|
-
* file text. Null when the match sits above the first heading. Optional
|
|
4791
|
-
* because a server that predates sections does not send it.
|
|
4792
|
-
*/
|
|
4793
|
-
section: v.optional(v.nullable(v.string())),
|
|
4794
|
-
/**
|
|
4795
|
-
* The whole section's length in characters, present only when `excerpt` is
|
|
4796
|
-
* less than all of it — what expanding the hit would add. Null when the
|
|
4797
|
-
* excerpt is the whole section. Optional for the same reason as `section`.
|
|
4798
|
-
*/
|
|
4799
|
-
sectionChars: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),
|
|
4800
|
-
/**
|
|
4801
|
-
* Around the match, cut with `…`, never past its section. By default a short
|
|
4802
|
-
* window, or the whole section when that is short too; for `detail:
|
|
4803
|
-
* 'section'`, the whole section, capped.
|
|
4804
|
-
*/
|
|
4805
|
-
excerpt: v.string(),
|
|
4806
|
-
});
|
|
4807
|
-
/** One session's verdict on one guide whose reasoning matched, wrapped in markers. */
|
|
4808
|
-
export const SearchVerdictHitSchema = v.object({
|
|
4809
|
-
sessionId: NonEmptyStringSchema,
|
|
4810
|
-
guideId: NonEmptyStringSchema,
|
|
4811
|
-
/**
|
|
4812
|
-
* Wrapped in `untrusted`'s markers. Null when the guide is no longer one the
|
|
4813
|
-
* caller can read, or nothing names it.
|
|
4814
|
-
*/
|
|
4815
|
-
guideTitle: v.nullable(v.string()),
|
|
4816
|
-
verdict: SessionGuideVerdictValueSchema,
|
|
4817
|
-
occurredAt: v.string(),
|
|
4818
|
-
reasoning: v.string(),
|
|
4819
|
-
});
|
|
4820
|
-
/**
|
|
4821
|
-
* A saved document whose name or body matched — an artifact `read_artifact`
|
|
4822
|
-
* reads by its `itemId`. The name, workspace name and excerpt are wrapped in
|
|
4823
|
-
* `untrusted`'s markers.
|
|
4824
|
-
*/
|
|
4825
|
-
export const SearchContentHitSchema = v.object({
|
|
4826
|
-
itemId: NonEmptyStringSchema,
|
|
4827
|
-
/** Wrapped in `untrusted`'s markers; null when the item has no name. */
|
|
4828
|
-
name: v.nullable(v.string()),
|
|
4829
|
-
workspaceId: NonEmptyStringSchema,
|
|
4830
|
-
/** Wrapped in `untrusted`'s markers. */
|
|
4831
|
-
workspaceName: v.string(),
|
|
4832
|
-
/**
|
|
4833
|
-
* Slugs of the bundles that hold the item and that the caller may read — the
|
|
4834
|
-
* `bundle` argument `pull_artifacts` takes to read the bundle. Never more than
|
|
4835
|
-
* a scoped caller's allowlist reaches.
|
|
4836
|
-
*/
|
|
4837
|
-
bundles: v.array(v.string()),
|
|
4838
|
-
updatedAt: v.string(),
|
|
4839
|
-
/**
|
|
4840
|
-
* Where the item opens on the dashboard. Added by the CLI, which knows the
|
|
4841
|
-
* dashboard's address; the server does not send it.
|
|
4842
|
-
*/
|
|
4843
|
-
url: v.optional(v.string()),
|
|
4844
|
-
/** A window around the match, wrapped in `untrusted`'s markers. */
|
|
4845
|
-
excerpt: v.string(),
|
|
4846
|
-
});
|
|
4847
|
-
/** What every matched comment carries, whatever it is attached to. */
|
|
4848
|
-
const searchCommentHitFields = {
|
|
4849
|
-
commentId: NonEmptyStringSchema,
|
|
4850
|
-
/** The thread's root; equal to `commentId` for a root comment. */
|
|
4851
|
-
threadId: NonEmptyStringSchema,
|
|
4852
|
-
authorKind: SearchCommentAuthorKindSchema,
|
|
4853
|
-
/** Whether the thread has been resolved — a resolved thread is answered, not open. */
|
|
4854
|
-
resolved: v.boolean(),
|
|
4855
|
-
createdAt: v.string(),
|
|
4856
|
-
/**
|
|
4857
|
-
* Where the comment's subject opens on the dashboard. Added by the CLI, which
|
|
4858
|
-
* knows the dashboard's address; the server does not send it.
|
|
4859
|
-
*/
|
|
4860
|
-
url: v.optional(v.string()),
|
|
4861
|
-
/** A window around the match, wrapped in `untrusted`'s markers. */
|
|
4862
|
-
excerpt: v.string(),
|
|
4863
|
-
};
|
|
4864
|
-
/**
|
|
4865
|
-
* A comment on a guide or document that matched. `body` and `itemName` and
|
|
4866
|
-
* `workspaceName` are wrapped in `untrusted`'s markers.
|
|
4867
|
-
*/
|
|
4868
|
-
export const SearchArtifactCommentHitSchema = v.object({
|
|
4869
|
-
...searchCommentHitFields,
|
|
4870
|
-
subjectKind: v.literal('artifact'),
|
|
4871
|
-
itemId: NonEmptyStringSchema,
|
|
4872
|
-
/**
|
|
4873
|
-
* The guide the item belongs to, or null for a standalone document. A comment
|
|
4874
|
-
* on a guide sits on its body file, so this is the id the dashboard's guide
|
|
4875
|
-
* page takes; `itemId` is the one a document page takes.
|
|
4876
|
-
*/
|
|
4877
|
-
guideId: v.nullable(NonEmptyStringSchema),
|
|
4878
|
-
/** Wrapped in `untrusted`'s markers; null when the item has no name. */
|
|
4879
|
-
itemName: v.nullable(v.string()),
|
|
4880
|
-
workspaceId: NonEmptyStringSchema,
|
|
4881
|
-
/** Wrapped in `untrusted`'s markers. */
|
|
4882
|
-
workspaceName: v.string(),
|
|
4883
|
-
/** Whether the item has been edited since the comment was written. */
|
|
4884
|
-
itemChangedSince: v.boolean(),
|
|
4885
|
-
/**
|
|
4886
|
-
* Where the match is. A current server always says `body`; `suggestion` is
|
|
4887
|
-
* what an older one said for a match in a comment's suggested edit, accepted
|
|
4888
|
-
* so a CLI talking to one mid-rollout still parses the report. Nothing reads
|
|
4889
|
-
* the difference.
|
|
4890
|
-
*/
|
|
4891
|
-
matchedIn: v.picklist(['body', 'suggestion']),
|
|
4892
|
-
/**
|
|
4893
|
-
* Whether a Mossbear finding's owner handed it to their agents. Nothing hands
|
|
4894
|
-
* one over any more, so a current server sends `false`. It does not say
|
|
4895
|
-
* whether an agent may act on it: every open finding is ready unless
|
|
4896
|
-
* dismissed. Absent on a person's or an agent's comment and on a reply.
|
|
4897
|
-
*/
|
|
4898
|
-
approved: v.optional(v.boolean()),
|
|
4899
|
-
});
|
|
4900
|
-
/**
|
|
4901
|
-
* A comment on one of the caller's own sessions that matched. It has no
|
|
4902
|
-
* workspace and no item: `sessionId` is the id the dashboard's session page
|
|
4903
|
-
* takes. The excerpt is wrapped in `untrusted`'s markers.
|
|
4904
|
-
*/
|
|
4905
|
-
export const SearchSessionCommentHitSchema = v.object({
|
|
4906
|
-
...searchCommentHitFields,
|
|
4907
|
-
subjectKind: v.literal('session'),
|
|
4908
|
-
sessionId: NonEmptyStringSchema,
|
|
4909
|
-
matchedIn: v.literal('body'),
|
|
4910
|
-
});
|
|
4911
|
-
export const SearchCommentHitSchema = v.variant('subjectKind', [
|
|
4912
|
-
SearchArtifactCommentHitSchema,
|
|
4913
|
-
SearchSessionCommentHitSchema,
|
|
4914
|
-
]);
|
|
4915
|
-
/**
|
|
4916
|
-
* One thing the caller said to an agent, redacted at the source. `excerpt` and
|
|
4917
|
-
* `projectId` and `branch` are wrapped in `untrusted`'s markers: a turn is text a
|
|
4918
|
-
* person typed (or pasted) and a branch name is whatever git was told.
|
|
4919
|
-
*/
|
|
4920
|
-
export const SearchTurnHitSchema = v.object({
|
|
4921
|
-
/** The agent's own session id — the key a session digest takes. */
|
|
4922
|
-
agentSessionId: NonEmptyStringSchema,
|
|
4923
|
-
/**
|
|
4924
|
-
* The dashboard's id for the session, which its session page takes. Null when
|
|
4925
|
-
* the session has not been recorded as a run yet.
|
|
4926
|
-
*/
|
|
4927
|
-
sessionId: v.nullable(NonEmptyStringSchema),
|
|
4928
|
-
/** Which turn of the session this was, counting from 1. */
|
|
4929
|
-
ordinal: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
4930
|
-
/** Null when the classifier has not labelled the turn. */
|
|
4931
|
-
steeringLabel: v.nullable(SearchSteeringLabelSchema),
|
|
4932
|
-
/** Wrapped in `untrusted`'s markers; null where the session recorded none. */
|
|
4933
|
-
projectId: v.nullable(v.string()),
|
|
4934
|
-
/** Wrapped in `untrusted`'s markers; null where the session recorded none. */
|
|
4935
|
-
branch: v.nullable(v.string()),
|
|
4936
|
-
createdAt: v.string(),
|
|
4937
|
-
/**
|
|
4938
|
-
* Where the session opens on the dashboard. Added by the CLI, which knows the
|
|
4939
|
-
* dashboard's address; the server does not send it.
|
|
4940
|
-
*/
|
|
4941
|
-
url: v.optional(v.string()),
|
|
4942
|
-
/** A window around the match, wrapped in `untrusted`'s markers. */
|
|
4943
|
-
excerpt: v.string(),
|
|
4944
|
-
});
|
|
4945
|
-
/** Which of a session's stored texts a `sessions` hit matched. */
|
|
4946
|
-
export const SEARCH_SESSION_MATCH_FIELDS = ['grade', 'self_report'];
|
|
4947
|
-
export const SearchSessionMatchFieldSchema = v.picklist(SEARCH_SESSION_MATCH_FIELDS);
|
|
4948
|
-
/**
|
|
4949
|
-
* One of the caller's own sessions, found by what the grader said about it or
|
|
4950
|
-
* what the agent reported at the end. `repoId`, `projectId`, `branch`,
|
|
4951
|
-
* `headSha` and `excerpt` are wrapped in `untrusted`'s markers: the first four
|
|
4952
|
-
* are whatever a checkout reported, and the excerpt is model-authored or
|
|
4953
|
-
* written by an agent.
|
|
4954
|
-
*/
|
|
4955
|
-
export const SearchSessionHitSchema = v.object({
|
|
4956
|
-
/** The agent's own session id — the key a session digest takes. */
|
|
4957
|
-
agentSessionId: NonEmptyStringSchema,
|
|
4958
|
-
/** The dashboard's id for the session, which its session page takes. */
|
|
4959
|
-
sessionId: NonEmptyStringSchema,
|
|
4960
|
-
/** Wrapped in `untrusted`'s markers; null where the session recorded none. */
|
|
4961
|
-
repoId: v.nullable(v.string()),
|
|
4962
|
-
/** Wrapped in `untrusted`'s markers; null where the session recorded none. */
|
|
4963
|
-
projectId: v.nullable(v.string()),
|
|
4964
|
-
/** Wrapped in `untrusted`'s markers; null where the session recorded none. */
|
|
4965
|
-
branch: v.nullable(v.string()),
|
|
4966
|
-
/**
|
|
4967
|
-
* The head observed when the session closed, wrapped in `untrusted`'s
|
|
4968
|
-
* markers; null where none was observed. A commit made mid-session is not it.
|
|
4969
|
-
*/
|
|
4970
|
-
headSha: v.nullable(v.string()),
|
|
4971
|
-
startedAt: v.string(),
|
|
4972
|
-
/** Null when the search named no term, only filters. */
|
|
4973
|
-
matchedIn: v.nullable(SearchSessionMatchFieldSchema),
|
|
4974
|
-
/**
|
|
4975
|
-
* Where the session opens on the dashboard. Added by the CLI, which knows the
|
|
4976
|
-
* dashboard's address; the server does not send it.
|
|
4977
|
-
*/
|
|
4978
|
-
url: v.optional(v.string()),
|
|
4979
|
-
/** A window around the match, wrapped in `untrusted`'s markers; null when the search named no term. */
|
|
4980
|
-
excerpt: v.nullable(v.string()),
|
|
4981
|
-
});
|
|
4982
|
-
function searchCorpusReportSchema(hit) {
|
|
4983
|
-
return v.variant('status', [
|
|
4984
|
-
v.object({
|
|
4985
|
-
status: v.literal('searched'),
|
|
4986
|
-
/** Every match in scope, counted past the returned page. */
|
|
4987
|
-
total: v.pipe(v.number(), v.integer(), v.minValue(0)),
|
|
4988
|
-
narrowedBy: v.nullable(SearchNarrowingSchema),
|
|
4989
|
-
/** Newest first, at most the request's limit. */
|
|
4990
|
-
hits: v.array(hit),
|
|
4991
|
-
}),
|
|
4992
|
-
v.object({
|
|
4993
|
-
status: v.literal('skipped'),
|
|
4994
|
-
reason: SearchSkipReasonSchema,
|
|
4995
|
-
}),
|
|
4996
|
-
]);
|
|
4997
|
-
}
|
|
4998
|
-
export const SearchGuidesReportSchema = searchCorpusReportSchema(SearchGuideHitSchema);
|
|
4999
|
-
export const SearchVerdictsReportSchema = searchCorpusReportSchema(SearchVerdictHitSchema);
|
|
5000
|
-
export const SearchContentReportSchema = searchCorpusReportSchema(SearchContentHitSchema);
|
|
5001
|
-
export const SearchCommentsReportSchema = searchCorpusReportSchema(SearchCommentHitSchema);
|
|
5002
|
-
export const SearchTurnsReportSchema = searchCorpusReportSchema(SearchTurnHitSchema);
|
|
5003
|
-
export const SearchSessionsReportSchema = searchCorpusReportSchema(SearchSessionHitSchema);
|
|
5004
|
-
/**
|
|
5005
|
-
* A search's answer: **a report per corpus, never a bare list.**
|
|
5006
|
-
*
|
|
5007
|
-
* Keyed by corpus so every corpus is always accounted for — searched with its
|
|
5008
|
-
* total, or skipped with its reason — and `notYetSearchable` names the ones no
|
|
5009
|
-
* search reaches. A caller reading zero hits therefore always knows what the
|
|
5010
|
-
* zero covers, which is the difference between "nothing matched here" and "you
|
|
5011
|
-
* never said this".
|
|
5012
|
-
*/
|
|
5013
|
-
export const SearchResponseSchema = v.object({
|
|
5014
|
-
corpora: v.object({
|
|
5015
|
-
guides: SearchGuidesReportSchema,
|
|
5016
|
-
verdicts: SearchVerdictsReportSchema,
|
|
5017
|
-
/**
|
|
5018
|
-
* Optional because a server that predates the `content` corpus does not
|
|
5019
|
-
* send it — and then did not search it, which a caller must say rather
|
|
5020
|
-
* than read as zero hits.
|
|
5021
|
-
*/
|
|
5022
|
-
content: v.optional(SearchContentReportSchema),
|
|
5023
|
-
/** Optional for the same reason as `content`. Covers comments on guides and documents, and the caller's own comments on their sessions. */
|
|
5024
|
-
comments: v.optional(SearchCommentsReportSchema),
|
|
5025
|
-
/** Optional for the same reason as `content`. The caller's own turns, never a workspace-mate's. */
|
|
5026
|
-
turns: v.optional(SearchTurnsReportSchema),
|
|
5027
|
-
/** Optional for the same reason as `content`. The caller's own sessions, never a workspace-mate's. */
|
|
5028
|
-
sessions: v.optional(SearchSessionsReportSchema),
|
|
5029
|
-
}),
|
|
5030
|
-
// `comments` is what a server from before session comments were told apart
|
|
5031
|
-
// from item comments still sends; a newer client must read that response, not
|
|
5032
|
-
// refuse it. `session-comments`, `turns` and `sessions` are what servers sent
|
|
5033
|
-
// before those corpora were searchable.
|
|
5034
|
-
notYetSearchable: v.array(v.picklist([
|
|
5035
|
-
...SEARCH_UNIMPLEMENTED_CORPORA,
|
|
5036
|
-
'comments',
|
|
5037
|
-
'session-comments',
|
|
5038
|
-
'turns',
|
|
5039
|
-
'sessions',
|
|
5040
|
-
])),
|
|
5041
|
-
untrusted: GuideHistoryUntrustedSchema,
|
|
5042
|
-
});
|
|
5043
3666
|
// ---------------------------------------------------------------------------
|
|
5044
3667
|
// Parse wrappers (throw ValiError on invalid input)
|
|
5045
3668
|
// ---------------------------------------------------------------------------
|
|
@@ -5155,37 +3778,4 @@ export function parseGuideHistoryRequest(data) {
|
|
|
5155
3778
|
export function parseGuideHistoryResponse(data) {
|
|
5156
3779
|
return v.parse(GuideHistoryResponseSchema, data);
|
|
5157
3780
|
}
|
|
5158
|
-
export function parseAnnounceItemCommentsRequest(data) {
|
|
5159
|
-
return v.parse(AnnounceItemCommentsRequestSchema, data);
|
|
5160
|
-
}
|
|
5161
|
-
export function parseResolveItemCommentResponse(data) {
|
|
5162
|
-
return v.parse(ResolveItemCommentResponseSchema, data);
|
|
5163
|
-
}
|
|
5164
|
-
export function parseAnnounceItemCommentsResponse(data) {
|
|
5165
|
-
return v.parse(AnnounceItemCommentsResponseSchema, data);
|
|
5166
|
-
}
|
|
5167
|
-
export function parseAnnounceSessionCommentsResponse(data) {
|
|
5168
|
-
return v.parse(AnnounceSessionCommentsResponseSchema, data);
|
|
5169
|
-
}
|
|
5170
|
-
export function parseAgentCommentResponse(data) {
|
|
5171
|
-
return v.parse(AgentCommentResponseSchema, data);
|
|
5172
|
-
}
|
|
5173
|
-
export function parseItemCommentsResponse(data) {
|
|
5174
|
-
return v.parse(ItemCommentsResponseSchema, data);
|
|
5175
|
-
}
|
|
5176
|
-
export function parseCommentEvidenceResponse(data) {
|
|
5177
|
-
return v.parse(CommentEvidenceResponseSchema, data);
|
|
5178
|
-
}
|
|
5179
|
-
export function parseRunGradeRequest(data) {
|
|
5180
|
-
return v.parse(SessionGradeRequestSchema, data);
|
|
5181
|
-
}
|
|
5182
|
-
export function parseSessionGradeResponse(data) {
|
|
5183
|
-
return v.parse(SessionGradeResponseSchema, data);
|
|
5184
|
-
}
|
|
5185
|
-
export function parseSessionDigestResponse(data) {
|
|
5186
|
-
return v.parse(SessionDigestResponseSchema, data);
|
|
5187
|
-
}
|
|
5188
|
-
export function parseSearchResponse(data) {
|
|
5189
|
-
return v.parse(SearchResponseSchema, data);
|
|
5190
|
-
}
|
|
5191
3781
|
//# sourceMappingURL=schemas.js.map
|