@spotpatch/shared 1.12.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/annotation-Cz-NNgR4.d.cts +102 -0
- package/dist/annotation-Cz-NNgR4.d.ts +102 -0
- package/dist/chunk-CLQ6MIJB.js +586 -0
- package/dist/chunk-CLQ6MIJB.js.map +1 -0
- package/dist/chunk-EWJTKNL4.js +90 -0
- package/dist/chunk-EWJTKNL4.js.map +1 -0
- package/dist/{chunk-JGOIBOFI.js → chunk-FPDSZDP2.js} +16 -2
- package/dist/chunk-FPDSZDP2.js.map +1 -0
- package/dist/{chunk-2LVIH7OA.js → chunk-IX6MSCK6.js} +6 -2
- package/dist/chunk-IX6MSCK6.js.map +1 -0
- package/dist/{chunk-JU5HIWX7.js → chunk-JTZFOTPT.js} +9 -174
- package/dist/chunk-JTZFOTPT.js.map +1 -0
- package/dist/chunk-R6QJFNT2.js +195 -0
- package/dist/chunk-R6QJFNT2.js.map +1 -0
- package/dist/contextual-ask-BpbkpFFf.d.cts +1476 -0
- package/dist/contextual-ask-BpbkpFFf.d.ts +1476 -0
- package/dist/contextual-ask-browser.cjs +201 -0
- package/dist/contextual-ask-browser.cjs.map +1 -0
- package/dist/contextual-ask-browser.d.cts +31 -0
- package/dist/contextual-ask-browser.d.ts +31 -0
- package/dist/contextual-ask-browser.js +66 -0
- package/dist/contextual-ask-browser.js.map +1 -0
- package/dist/contextual-ask-node.cjs +971 -0
- package/dist/contextual-ask-node.cjs.map +1 -0
- package/dist/contextual-ask-node.d.cts +14 -0
- package/dist/contextual-ask-node.d.ts +14 -0
- package/dist/contextual-ask-node.js +122 -0
- package/dist/contextual-ask-node.js.map +1 -0
- package/dist/{data-flow-runtime-BelOgo8s.d.ts → data-flow-runtime-DhWpQoik.d.ts} +26 -13
- package/dist/{data-flow-runtime-oq9m21IP.d.cts → data-flow-runtime-w43iwvGA.d.cts} +26 -13
- package/dist/data-flow-runtime.cjs +2 -0
- package/dist/data-flow-runtime.cjs.map +1 -1
- package/dist/data-flow-runtime.d.cts +2 -2
- package/dist/data-flow-runtime.d.ts +2 -2
- package/dist/data-flow-runtime.js +1 -1
- package/dist/{endpoints-GedF44M2.d.cts → endpoints-O3ohYyAo.d.cts} +7 -1
- package/dist/{endpoints-GedF44M2.d.ts → endpoints-O3ohYyAo.d.ts} +7 -1
- package/dist/error-code-DRz2eqcB.d.cts +63 -0
- package/dist/error-code-DRz2eqcB.d.ts +63 -0
- package/dist/external-agent-node.cjs +320 -141
- package/dist/external-agent-node.cjs.map +1 -1
- package/dist/external-agent-node.d.cts +43 -27
- package/dist/external-agent-node.d.ts +43 -27
- package/dist/external-agent-node.js +174 -20
- package/dist/external-agent-node.js.map +1 -1
- package/dist/{external-handoff-BNUyMfNb.d.ts → external-handoff-5zHu-fz2.d.ts} +41 -131
- package/dist/{external-handoff-BNUyMfNb.d.cts → external-handoff-DeiIvR-2.d.cts} +41 -131
- package/dist/external-handoff-browser.cjs +7 -1
- package/dist/external-handoff-browser.cjs.map +1 -1
- package/dist/external-handoff-browser.d.cts +4 -3
- package/dist/external-handoff-browser.d.ts +4 -3
- package/dist/external-handoff-browser.js +2 -2
- package/dist/index.cjs +1170 -426
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +138 -178
- package/dist/index.d.ts +138 -178
- package/dist/index.js +116 -20
- package/dist/index.js.map +1 -1
- package/package.json +29 -2
- package/dist/chunk-2LVIH7OA.js.map +0 -1
- package/dist/chunk-JGOIBOFI.js.map +0 -1
- package/dist/chunk-JU5HIWX7.js.map +0 -1
- package/dist/{external-agent-control-BMoSq_xI.d.cts → external-agent-control-C79Nl85y.d.cts} +49 -49
- package/dist/{external-agent-control-BMoSq_xI.d.ts → external-agent-control-C79Nl85y.d.ts} +49 -49
package/dist/index.cjs
CHANGED
|
@@ -27,6 +27,18 @@ __export(index_exports, {
|
|
|
27
27
|
AGENT_JOB_STATUSES: () => AGENT_JOB_STATUSES,
|
|
28
28
|
AGENT_WORKSPACE_SNAPSHOT_LIMITS: () => AGENT_WORKSPACE_SNAPSHOT_LIMITS,
|
|
29
29
|
AGENT_WORKSPACE_STATES: () => AGENT_WORKSPACE_STATES,
|
|
30
|
+
ASK_ANSWER_WARNING_CODES: () => ASK_ANSWER_WARNING_CODES,
|
|
31
|
+
ASK_EXECUTOR_ANSWER_WARNING_CODES: () => ASK_EXECUTOR_ANSWER_WARNING_CODES,
|
|
32
|
+
ASK_FILE_COUNT_BUCKETS: () => ASK_FILE_COUNT_BUCKETS,
|
|
33
|
+
ASK_JOB_STATUSES: () => ASK_JOB_STATUSES,
|
|
34
|
+
ASK_READ_ACTIVITY_STATES: () => ASK_READ_ACTIVITY_STATES,
|
|
35
|
+
ASK_SOURCE_CONFIDENCES: () => ASK_SOURCE_CONFIDENCES,
|
|
36
|
+
CONTEXTUAL_ASK_ERROR_CODES: () => CONTEXTUAL_ASK_ERROR_CODES,
|
|
37
|
+
CONTEXTUAL_ASK_EXECUTOR_KINDS: () => CONTEXTUAL_ASK_EXECUTOR_KINDS,
|
|
38
|
+
CONTEXTUAL_ASK_EXECUTOR_STATES: () => CONTEXTUAL_ASK_EXECUTOR_STATES,
|
|
39
|
+
CONTEXTUAL_ASK_LIMITS: () => CONTEXTUAL_ASK_LIMITS,
|
|
40
|
+
CONTEXTUAL_ASK_PERMISSION_PROFILE: () => CONTEXTUAL_ASK_PERMISSION_PROFILE,
|
|
41
|
+
CONTEXTUAL_ASK_SCHEMA_VERSION: () => CONTEXTUAL_ASK_SCHEMA_VERSION,
|
|
30
42
|
DATA_FLOW_ASSOCIATION_KINDS: () => DATA_FLOW_ASSOCIATION_KINDS,
|
|
31
43
|
DATA_FLOW_DIAGNOSTIC_CODES: () => DATA_FLOW_DIAGNOSTIC_CODES,
|
|
32
44
|
DATA_FLOW_EXECUTION_STATES: () => DATA_FLOW_EXECUTION_STATES,
|
|
@@ -97,7 +109,26 @@ __export(index_exports, {
|
|
|
97
109
|
agentJobSnapshotSchema: () => agentJobSnapshotSchema,
|
|
98
110
|
agentWorkspaceHealthRequestSchema: () => agentWorkspaceHealthRequestSchema,
|
|
99
111
|
agentWorkspaceHealthSnapshotSchema: () => agentWorkspaceHealthSnapshotSchema,
|
|
112
|
+
askAnswerBlockSchema: () => askAnswerBlockSchema,
|
|
113
|
+
askAnswerDraftBlockSchema: () => askAnswerDraftBlockSchema,
|
|
114
|
+
askAnswerDraftSchema: () => askAnswerDraftSchema,
|
|
115
|
+
askAnswerResultSchema: () => askAnswerResultSchema,
|
|
116
|
+
askAnswerWarningSchema: () => askAnswerWarningSchema,
|
|
117
|
+
askDraftCitationSchema: () => askDraftCitationSchema,
|
|
118
|
+
askDraftOriginSchema: () => askDraftOriginSchema,
|
|
119
|
+
askJobActionRequestSchema: () => askJobActionRequestSchema,
|
|
120
|
+
askJobCreateRequestSchema: () => askJobCreateRequestSchema,
|
|
121
|
+
askJobEventSchema: () => askJobEventSchema,
|
|
122
|
+
askJobEventsRequestSchema: () => askJobEventsRequestSchema,
|
|
123
|
+
askJobResultResponseSchema: () => askJobResultResponseSchema,
|
|
124
|
+
askJobSnapshotSchema: () => askJobSnapshotSchema,
|
|
125
|
+
askSourceReferenceSchema: () => askSourceReferenceSchema,
|
|
100
126
|
componentDataFlowReportSchema: () => componentDataFlowReportSchema,
|
|
127
|
+
contextualAskCapabilityRequestSchema: () => contextualAskCapabilityRequestSchema,
|
|
128
|
+
contextualAskCapabilitySchema: () => contextualAskCapabilitySchema,
|
|
129
|
+
contextualAskExecutorCapabilitySchema: () => contextualAskExecutorCapabilitySchema,
|
|
130
|
+
contextualAskExecutorPreferenceSchema: () => contextualAskExecutorPreferenceSchema,
|
|
131
|
+
contextualAskOptionsSchema: () => contextualAskOptionsSchema,
|
|
101
132
|
dataDependencySchema: () => dataDependencySchema,
|
|
102
133
|
dataFlowComponentReportRequestSchema: () => dataFlowComponentReportRequestSchema,
|
|
103
134
|
dataFlowPageReportRequestSchema: () => dataFlowPageReportRequestSchema,
|
|
@@ -125,6 +156,7 @@ __export(index_exports, {
|
|
|
125
156
|
externalHandoffSummarySchema: () => externalHandoffSummarySchema,
|
|
126
157
|
formatSourceMarker: () => formatSourceMarker,
|
|
127
158
|
getAgentJobEndpoint: () => getAgentJobEndpoint,
|
|
159
|
+
getAskJobEndpoint: () => getAskJobEndpoint,
|
|
128
160
|
isErrorCode: () => isErrorCode,
|
|
129
161
|
isSensitiveName: () => isSensitiveName,
|
|
130
162
|
limitDataFlowReportCollections: () => limitDataFlowReportCollections,
|
|
@@ -142,8 +174,13 @@ __export(index_exports, {
|
|
|
142
174
|
runtimeDataFlowConfigSchema: () => runtimeDataFlowConfigSchema,
|
|
143
175
|
sanitizeUrl: () => sanitizeUrl,
|
|
144
176
|
sourceContextRequestSchema: () => sourceContextRequestSchema,
|
|
145
|
-
spotAnnotationRequestSchema: () =>
|
|
146
|
-
|
|
177
|
+
spotAnnotationRequestSchema: () => spotAnnotationSchema,
|
|
178
|
+
spotAskTaskEnvelopeSchema: () => spotAskTaskEnvelopeSchema,
|
|
179
|
+
spotChangeTaskEnvelopeSchema: () => spotChangeTaskEnvelopeSchema,
|
|
180
|
+
spotSelectionContextSchema: () => spotSelectionContextSchema,
|
|
181
|
+
spotSelectionTargetSchema: () => spotSelectionTargetSchema,
|
|
182
|
+
spotTargetContextRequestSchema: () => spotTargetContextSchema,
|
|
183
|
+
spotTaskEnvelopeSchema: () => spotTaskEnvelopeSchema
|
|
147
184
|
});
|
|
148
185
|
module.exports = __toCommonJS(index_exports);
|
|
149
186
|
|
|
@@ -214,6 +251,24 @@ var ERROR_CODES = {
|
|
|
214
251
|
APPLY_CONFLICT: "APPLY_CONFLICT",
|
|
215
252
|
INTERNAL_ERROR: "INTERNAL_ERROR"
|
|
216
253
|
};
|
|
254
|
+
var CONTEXTUAL_ASK_ERROR_CODES = Object.freeze([
|
|
255
|
+
"ASK_DISABLED",
|
|
256
|
+
"ASK_SELECTION_REQUIRED",
|
|
257
|
+
"ASK_SELECTION_STALE",
|
|
258
|
+
"ASK_QUESTION_INVALID",
|
|
259
|
+
"ASK_EXECUTOR_UNAVAILABLE",
|
|
260
|
+
"ASK_TIMEOUT",
|
|
261
|
+
"ASK_CONSENT_REQUIRED",
|
|
262
|
+
"ASK_BUSY",
|
|
263
|
+
"ASK_IDEMPOTENCY_CONFLICT",
|
|
264
|
+
"ASK_SOURCE_SCOPE_DENIED",
|
|
265
|
+
"ASK_LIMIT_EXCEEDED",
|
|
266
|
+
"ASK_ANSWER_INVALID",
|
|
267
|
+
"ASK_WRITE_ATTEMPTED",
|
|
268
|
+
"ASK_CANCELLED",
|
|
269
|
+
"ASK_RESULT_EXPIRED",
|
|
270
|
+
"ASK_PROTOCOL_INCOMPATIBLE"
|
|
271
|
+
]);
|
|
217
272
|
var ERROR_CODE_VALUES = Object.freeze(Object.values(ERROR_CODES));
|
|
218
273
|
function isErrorCode(value) {
|
|
219
274
|
return typeof value === "string" && ERROR_CODE_VALUES.includes(value);
|
|
@@ -298,6 +353,536 @@ var SPOTPATCH_LOCALE_PREFERENCES = Object.freeze([
|
|
|
298
353
|
...SPOTPATCH_LOCALES
|
|
299
354
|
]);
|
|
300
355
|
|
|
356
|
+
// src/model/contextual-ask.ts
|
|
357
|
+
var import_zod2 = require("zod");
|
|
358
|
+
|
|
359
|
+
// src/protocol/contextual-ask-constants.ts
|
|
360
|
+
var CONTEXTUAL_ASK_SCHEMA_VERSION = 1;
|
|
361
|
+
var CONTEXTUAL_ASK_LIMITS = Object.freeze({
|
|
362
|
+
maximumTargets: 20,
|
|
363
|
+
maximumQuestionCharacters: 4e3,
|
|
364
|
+
maximumAnswerCharacters: 4e4,
|
|
365
|
+
maximumAnswerBlocks: 40,
|
|
366
|
+
maximumSources: 64,
|
|
367
|
+
maximumReadFiles: 32,
|
|
368
|
+
maximumReadBytesPerFile: 64 * 1024,
|
|
369
|
+
maximumReadBytesTotal: 512 * 1024,
|
|
370
|
+
maximumToolCalls: 48,
|
|
371
|
+
maximumModelTurns: 12,
|
|
372
|
+
jobTimeoutMs: 3e5,
|
|
373
|
+
resultTtlMs: 9e5,
|
|
374
|
+
maximumActiveJobsPerSession: 1,
|
|
375
|
+
maximumRetainedResultsPerSession: 1,
|
|
376
|
+
maximumRetainedEvents: 256,
|
|
377
|
+
maximumEventSubscribers: 4,
|
|
378
|
+
eventHeartbeatMs: 15e3,
|
|
379
|
+
maximumRequestBodyBytes: 256 * 1024,
|
|
380
|
+
maximumSearchQueryCharacters: 256,
|
|
381
|
+
maximumSearchResults: 64,
|
|
382
|
+
maximumSearchPreviewCharacters: 500,
|
|
383
|
+
capabilityTimeoutMs: 3e4,
|
|
384
|
+
maximumIdCharacters: 128,
|
|
385
|
+
maximumProfileIdCharacters: 64,
|
|
386
|
+
maximumLabelCharacters: 256,
|
|
387
|
+
maximumRelativePathCharacters: 1024,
|
|
388
|
+
maximumLanguageCharacters: 64,
|
|
389
|
+
maximumPhaseMessageCharacters: 1024,
|
|
390
|
+
maximumExecutors: 32,
|
|
391
|
+
maximumModels: 800,
|
|
392
|
+
contentHashHexCharacters: 64
|
|
393
|
+
});
|
|
394
|
+
var CONTEXTUAL_ASK_EXECUTOR_KINDS = Object.freeze([
|
|
395
|
+
"configured-key",
|
|
396
|
+
"managed-codex"
|
|
397
|
+
]);
|
|
398
|
+
var CONTEXTUAL_ASK_EXECUTOR_STATES = Object.freeze([
|
|
399
|
+
"ready",
|
|
400
|
+
"degraded",
|
|
401
|
+
"unavailable"
|
|
402
|
+
]);
|
|
403
|
+
var ASK_JOB_STATUSES = Object.freeze([
|
|
404
|
+
"queued",
|
|
405
|
+
"authorizing",
|
|
406
|
+
"running",
|
|
407
|
+
"cancelling",
|
|
408
|
+
"answered",
|
|
409
|
+
"cancelled",
|
|
410
|
+
"failed"
|
|
411
|
+
]);
|
|
412
|
+
var ASK_ANSWER_WARNING_CODES = Object.freeze([
|
|
413
|
+
"insufficient-evidence",
|
|
414
|
+
"partial-context",
|
|
415
|
+
"source-truncated",
|
|
416
|
+
"source-stale"
|
|
417
|
+
]);
|
|
418
|
+
var ASK_EXECUTOR_ANSWER_WARNING_CODES = Object.freeze([
|
|
419
|
+
"insufficient-evidence",
|
|
420
|
+
"partial-context"
|
|
421
|
+
]);
|
|
422
|
+
var ASK_READ_ACTIVITY_STATES = Object.freeze([
|
|
423
|
+
"started",
|
|
424
|
+
"succeeded",
|
|
425
|
+
"failed"
|
|
426
|
+
]);
|
|
427
|
+
var ASK_FILE_COUNT_BUCKETS = Object.freeze(["one", "few", "many"]);
|
|
428
|
+
var ASK_SOURCE_CONFIDENCES = Object.freeze([
|
|
429
|
+
"exact",
|
|
430
|
+
"probable",
|
|
431
|
+
"approximate"
|
|
432
|
+
]);
|
|
433
|
+
var CONTEXTUAL_ASK_PERMISSION_PROFILE = "spotpatch-ask-readonly";
|
|
434
|
+
|
|
435
|
+
// src/model/context-schema.ts
|
|
436
|
+
var import_zod = require("zod");
|
|
437
|
+
var boundedString = (maximum) => import_zod.z.string().max(maximum);
|
|
438
|
+
var sourceRefSchema = import_zod.z.strictObject({
|
|
439
|
+
fileId: boundedString(128).optional(),
|
|
440
|
+
relativePath: boundedString(1024).optional(),
|
|
441
|
+
line: import_zod.z.number().int().positive().optional(),
|
|
442
|
+
column: import_zod.z.number().int().positive().optional(),
|
|
443
|
+
origin: import_zod.z.enum(["jsx-host", "astro-host", "react-fiber", "dom-ancestor", "none"]),
|
|
444
|
+
confidence: import_zod.z.enum(["exact", "probable", "approximate", "unknown"])
|
|
445
|
+
});
|
|
446
|
+
var matchedStyleRuleSchema = import_zod.z.strictObject({
|
|
447
|
+
selector: boundedString(2048),
|
|
448
|
+
declarations: boundedString(8192),
|
|
449
|
+
source: boundedString(1024).optional(),
|
|
450
|
+
media: boundedString(1024).optional()
|
|
451
|
+
});
|
|
452
|
+
var codeContextSchema = import_zod.z.strictObject({
|
|
453
|
+
relativePath: boundedString(1024),
|
|
454
|
+
language: import_zod.z.enum(["tsx", "jsx", "astro"]),
|
|
455
|
+
startLine: import_zod.z.number().int().positive(),
|
|
456
|
+
endLine: import_zod.z.number().int().positive(),
|
|
457
|
+
excerpt: boundedString(16e3),
|
|
458
|
+
boundary: import_zod.z.enum(["component", "nearby-lines"])
|
|
459
|
+
});
|
|
460
|
+
var pageContextSchema = import_zod.z.strictObject({
|
|
461
|
+
url: boundedString(2048),
|
|
462
|
+
pathname: boundedString(2048),
|
|
463
|
+
title: boundedString(1024),
|
|
464
|
+
viewportWidth: import_zod.z.number().nonnegative(),
|
|
465
|
+
viewportHeight: import_zod.z.number().nonnegative(),
|
|
466
|
+
devicePixelRatio: import_zod.z.number().positive()
|
|
467
|
+
});
|
|
468
|
+
var spotTargetContextSchema = import_zod.z.strictObject({
|
|
469
|
+
instruction: import_zod.z.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),
|
|
470
|
+
page: pageContextSchema.optional(),
|
|
471
|
+
source: sourceRefSchema,
|
|
472
|
+
react: import_zod.z.strictObject({
|
|
473
|
+
supported: import_zod.z.boolean(),
|
|
474
|
+
version: boundedString(64).optional(),
|
|
475
|
+
componentName: boundedString(256).optional(),
|
|
476
|
+
componentSourceId: boundedString(128).optional(),
|
|
477
|
+
sourceVersion: boundedString(128).optional(),
|
|
478
|
+
componentStack: import_zod.z.array(boundedString(256)).max(64),
|
|
479
|
+
source: sourceRefSchema.optional()
|
|
480
|
+
}),
|
|
481
|
+
element: import_zod.z.strictObject({
|
|
482
|
+
tagName: boundedString(128),
|
|
483
|
+
selector: boundedString(2048),
|
|
484
|
+
sanitizedHtml: boundedString(8192),
|
|
485
|
+
textPreview: boundedString(2048).optional(),
|
|
486
|
+
role: boundedString(256).optional(),
|
|
487
|
+
rect: import_zod.z.strictObject({
|
|
488
|
+
x: import_zod.z.number(),
|
|
489
|
+
y: import_zod.z.number(),
|
|
490
|
+
width: import_zod.z.number().nonnegative(),
|
|
491
|
+
height: import_zod.z.number().nonnegative()
|
|
492
|
+
})
|
|
493
|
+
}),
|
|
494
|
+
styles: import_zod.z.strictObject({
|
|
495
|
+
classNames: import_zod.z.array(boundedString(512)).max(256),
|
|
496
|
+
inlineStyle: boundedString(8192).optional(),
|
|
497
|
+
matchedRules: import_zod.z.array(matchedStyleRuleSchema).max(256),
|
|
498
|
+
computed: import_zod.z.record(boundedString(256), boundedString(2048)),
|
|
499
|
+
warnings: import_zod.z.array(boundedString(1024)).max(64)
|
|
500
|
+
}),
|
|
501
|
+
code: codeContextSchema.optional(),
|
|
502
|
+
warnings: import_zod.z.array(boundedString(1024)).max(64)
|
|
503
|
+
});
|
|
504
|
+
var spotAnnotationSchema = import_zod.z.strictObject({
|
|
505
|
+
schemaVersion: import_zod.z.literal(3),
|
|
506
|
+
id: boundedString(128),
|
|
507
|
+
locale: import_zod.z.enum(SPOTPATCH_LOCALES),
|
|
508
|
+
page: pageContextSchema,
|
|
509
|
+
targets: import_zod.z.array(spotTargetContextSchema).min(1).max(MAX_ANNOTATION_TARGETS),
|
|
510
|
+
createdAt: import_zod.z.iso.datetime()
|
|
511
|
+
}).superRefine((annotation, context) => {
|
|
512
|
+
const total = annotation.targets.reduce(
|
|
513
|
+
(characters, target) => characters + target.instruction.length,
|
|
514
|
+
0
|
|
515
|
+
);
|
|
516
|
+
if (total > MAX_ANNOTATION_INSTRUCTION_CHARACTERS) {
|
|
517
|
+
context.addIssue({
|
|
518
|
+
code: "custom",
|
|
519
|
+
message: "Combined target instructions exceed the annotation limit.",
|
|
520
|
+
path: ["targets"]
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
// src/model/contextual-ask.ts
|
|
526
|
+
var limits = CONTEXTUAL_ASK_LIMITS;
|
|
527
|
+
var contextualAskBoundedText = (maximum) => import_zod2.z.string().trim().min(1).max(maximum);
|
|
528
|
+
var contextualAskOpaqueIdSchema = import_zod2.z.string().min(1).max(limits.maximumIdCharacters).regex(/^[A-Za-z0-9_-]+$/u);
|
|
529
|
+
var profileIdSchema = import_zod2.z.string().min(1).max(limits.maximumProfileIdCharacters).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u);
|
|
530
|
+
var contentHashSchema = import_zod2.z.string().length(limits.contentHashHexCharacters).regex(/^[a-f0-9]+$/u);
|
|
531
|
+
var contextualAskRelativePathSchema = import_zod2.z.string().min(1).max(limits.maximumRelativePathCharacters).refine(
|
|
532
|
+
(value) => !value.startsWith("/") && !value.includes("\\") && !Array.from(value).some((character) => {
|
|
533
|
+
const codePoint = character.codePointAt(0);
|
|
534
|
+
return codePoint !== void 0 && (codePoint <= 31 || codePoint === 127);
|
|
535
|
+
}) && !/^[A-Za-z]:/u.test(value) && value.split("/").every((segment) => segment !== "" && segment !== "." && segment !== ".."),
|
|
536
|
+
{ message: "Expected a safe project-relative POSIX path." }
|
|
537
|
+
);
|
|
538
|
+
var contextualAskExecutorPreferenceSchema = import_zod2.z.discriminatedUnion("kind", [
|
|
539
|
+
import_zod2.z.strictObject({
|
|
540
|
+
kind: import_zod2.z.literal("configured-key"),
|
|
541
|
+
providerProfileId: profileIdSchema,
|
|
542
|
+
modelProfileId: profileIdSchema
|
|
543
|
+
}),
|
|
544
|
+
import_zod2.z.strictObject({ kind: import_zod2.z.literal("managed-codex") })
|
|
545
|
+
]);
|
|
546
|
+
var contextualAskOptionsSchema = import_zod2.z.union([
|
|
547
|
+
import_zod2.z.boolean(),
|
|
548
|
+
import_zod2.z.strictObject({
|
|
549
|
+
defaultExecutor: contextualAskExecutorPreferenceSchema.optional()
|
|
550
|
+
})
|
|
551
|
+
]);
|
|
552
|
+
var spotSelectionTargetSchema = spotTargetContextSchema.omit({ instruction: true, page: true }).extend({
|
|
553
|
+
targetId: contextualAskOpaqueIdSchema,
|
|
554
|
+
page: pageContextSchema
|
|
555
|
+
}).strict();
|
|
556
|
+
var spotSelectionContextSchema = import_zod2.z.strictObject({
|
|
557
|
+
schemaVersion: import_zod2.z.literal(CONTEXTUAL_ASK_SCHEMA_VERSION),
|
|
558
|
+
selectionId: contextualAskOpaqueIdSchema,
|
|
559
|
+
locale: import_zod2.z.enum(SPOTPATCH_LOCALES),
|
|
560
|
+
targets: import_zod2.z.array(spotSelectionTargetSchema).min(1).max(limits.maximumTargets),
|
|
561
|
+
createdAt: import_zod2.z.iso.datetime()
|
|
562
|
+
}).superRefine((selection, context) => {
|
|
563
|
+
const targetIds = selection.targets.map((target) => target.targetId);
|
|
564
|
+
if (new Set(targetIds).size !== targetIds.length) {
|
|
565
|
+
context.addIssue({
|
|
566
|
+
code: "custom",
|
|
567
|
+
message: "Selection target IDs must be unique.",
|
|
568
|
+
path: ["targets"]
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
var askDraftOriginSchema = import_zod2.z.strictObject({
|
|
573
|
+
kind: import_zod2.z.literal("contextual-ask"),
|
|
574
|
+
askJobId: contextualAskOpaqueIdSchema,
|
|
575
|
+
question: contextualAskBoundedText(limits.maximumQuestionCharacters),
|
|
576
|
+
answerDigest: contextualAskBoundedText(limits.maximumQuestionCharacters),
|
|
577
|
+
sourceIds: import_zod2.z.array(contextualAskOpaqueIdSchema).max(limits.maximumSources)
|
|
578
|
+
}).superRefine((origin, context) => {
|
|
579
|
+
if (new Set(origin.sourceIds).size !== origin.sourceIds.length) {
|
|
580
|
+
context.addIssue({
|
|
581
|
+
code: "custom",
|
|
582
|
+
message: "Ask origin source IDs must be unique.",
|
|
583
|
+
path: ["sourceIds"]
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
var askTaskSchema = import_zod2.z.strictObject({
|
|
588
|
+
kind: import_zod2.z.literal("ask"),
|
|
589
|
+
question: contextualAskBoundedText(limits.maximumQuestionCharacters)
|
|
590
|
+
});
|
|
591
|
+
var changeInstructionSchema = import_zod2.z.strictObject({
|
|
592
|
+
targetId: contextualAskOpaqueIdSchema,
|
|
593
|
+
instruction: contextualAskBoundedText(MAX_TARGET_INSTRUCTION_CHARACTERS)
|
|
594
|
+
});
|
|
595
|
+
var changeTaskSchema = import_zod2.z.strictObject({
|
|
596
|
+
kind: import_zod2.z.literal("change"),
|
|
597
|
+
instructions: import_zod2.z.array(changeInstructionSchema).min(1).max(limits.maximumTargets),
|
|
598
|
+
origin: askDraftOriginSchema.optional()
|
|
599
|
+
});
|
|
600
|
+
var envelopeBaseShape = {
|
|
601
|
+
schemaVersion: import_zod2.z.literal(CONTEXTUAL_ASK_SCHEMA_VERSION),
|
|
602
|
+
taskId: contextualAskOpaqueIdSchema,
|
|
603
|
+
selection: spotSelectionContextSchema,
|
|
604
|
+
createdAt: import_zod2.z.iso.datetime()
|
|
605
|
+
};
|
|
606
|
+
var spotAskTaskEnvelopeSchema = import_zod2.z.strictObject({
|
|
607
|
+
...envelopeBaseShape,
|
|
608
|
+
task: askTaskSchema
|
|
609
|
+
});
|
|
610
|
+
var spotChangeTaskEnvelopeSchema = import_zod2.z.strictObject({
|
|
611
|
+
...envelopeBaseShape,
|
|
612
|
+
task: changeTaskSchema
|
|
613
|
+
}).superRefine((envelope, context) => {
|
|
614
|
+
const targetIds = envelope.selection.targets.map((target) => target.targetId);
|
|
615
|
+
const instructionIds = envelope.task.instructions.map(
|
|
616
|
+
(instruction) => instruction.targetId
|
|
617
|
+
);
|
|
618
|
+
if (new Set(instructionIds).size !== instructionIds.length || instructionIds.length !== targetIds.length || targetIds.some((targetId) => !instructionIds.includes(targetId))) {
|
|
619
|
+
context.addIssue({
|
|
620
|
+
code: "custom",
|
|
621
|
+
message: "Change instructions must map one-to-one to selection targets.",
|
|
622
|
+
path: ["task", "instructions"]
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
const total = envelope.task.instructions.reduce(
|
|
626
|
+
(characters, instruction) => characters + instruction.instruction.length,
|
|
627
|
+
0
|
|
628
|
+
);
|
|
629
|
+
if (total > MAX_ANNOTATION_INSTRUCTION_CHARACTERS) {
|
|
630
|
+
context.addIssue({
|
|
631
|
+
code: "custom",
|
|
632
|
+
message: "Combined change instructions exceed the task limit.",
|
|
633
|
+
path: ["task", "instructions"]
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
var spotTaskEnvelopeSchema = import_zod2.z.union([
|
|
638
|
+
spotAskTaskEnvelopeSchema,
|
|
639
|
+
spotChangeTaskEnvelopeSchema
|
|
640
|
+
]);
|
|
641
|
+
var askAnswerWarningSchema = import_zod2.z.strictObject({
|
|
642
|
+
code: import_zod2.z.enum(ASK_ANSWER_WARNING_CODES)
|
|
643
|
+
});
|
|
644
|
+
var askExecutorAnswerWarningSchema = import_zod2.z.strictObject({
|
|
645
|
+
code: import_zod2.z.enum(ASK_EXECUTOR_ANSWER_WARNING_CODES)
|
|
646
|
+
});
|
|
647
|
+
var askDraftCitationSchema = import_zod2.z.strictObject({
|
|
648
|
+
handleId: contextualAskOpaqueIdSchema,
|
|
649
|
+
startLine: import_zod2.z.number().int().positive(),
|
|
650
|
+
endLine: import_zod2.z.number().int().positive()
|
|
651
|
+
}).refine((citation) => citation.endLine >= citation.startLine, {
|
|
652
|
+
message: "Citation endLine must not precede startLine."
|
|
653
|
+
});
|
|
654
|
+
var draftCitationListSchema = import_zod2.z.array(askDraftCitationSchema).max(limits.maximumSources);
|
|
655
|
+
var draftParagraphBlockSchema = import_zod2.z.strictObject({
|
|
656
|
+
kind: import_zod2.z.literal("paragraph"),
|
|
657
|
+
text: contextualAskBoundedText(limits.maximumAnswerCharacters),
|
|
658
|
+
citations: draftCitationListSchema
|
|
659
|
+
});
|
|
660
|
+
var draftListBlockSchema = import_zod2.z.strictObject({
|
|
661
|
+
kind: import_zod2.z.literal("list"),
|
|
662
|
+
items: import_zod2.z.array(
|
|
663
|
+
import_zod2.z.strictObject({
|
|
664
|
+
text: contextualAskBoundedText(limits.maximumAnswerCharacters),
|
|
665
|
+
citations: draftCitationListSchema
|
|
666
|
+
})
|
|
667
|
+
).min(1).max(limits.maximumAnswerBlocks)
|
|
668
|
+
});
|
|
669
|
+
var draftCodeBlockSchema = import_zod2.z.strictObject({
|
|
670
|
+
kind: import_zod2.z.literal("code"),
|
|
671
|
+
code: import_zod2.z.string().min(1).max(limits.maximumAnswerCharacters),
|
|
672
|
+
language: contextualAskBoundedText(limits.maximumLanguageCharacters).optional(),
|
|
673
|
+
citations: draftCitationListSchema
|
|
674
|
+
});
|
|
675
|
+
var askAnswerDraftBlockSchema = import_zod2.z.discriminatedUnion("kind", [
|
|
676
|
+
draftParagraphBlockSchema,
|
|
677
|
+
draftListBlockSchema,
|
|
678
|
+
draftCodeBlockSchema
|
|
679
|
+
]);
|
|
680
|
+
function draftCharacters(blocks) {
|
|
681
|
+
return blocks.reduce((total, block) => {
|
|
682
|
+
if (block.kind === "paragraph") return total + block.text.length;
|
|
683
|
+
if (block.kind === "code") return total + block.code.length;
|
|
684
|
+
return total + block.items.reduce((itemTotal, item) => itemTotal + item.text.length, 0);
|
|
685
|
+
}, 0);
|
|
686
|
+
}
|
|
687
|
+
var askAnswerDraftSchema = import_zod2.z.strictObject({
|
|
688
|
+
blocks: import_zod2.z.array(askAnswerDraftBlockSchema).min(1).max(limits.maximumAnswerBlocks),
|
|
689
|
+
warnings: import_zod2.z.array(askExecutorAnswerWarningSchema).max(limits.maximumAnswerBlocks)
|
|
690
|
+
}).superRefine((answer, context) => {
|
|
691
|
+
if (draftCharacters(answer.blocks) > limits.maximumAnswerCharacters) {
|
|
692
|
+
context.addIssue({
|
|
693
|
+
code: "custom",
|
|
694
|
+
message: "Combined answer text exceeds the answer limit.",
|
|
695
|
+
path: ["blocks"]
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
const citations = answer.blocks.flatMap(
|
|
699
|
+
(block) => block.kind === "list" ? block.items.flatMap((item) => item.citations) : block.citations
|
|
700
|
+
);
|
|
701
|
+
if (citations.length === 0 && !answer.warnings.some((warning) => warning.code === "insufficient-evidence")) {
|
|
702
|
+
context.addIssue({
|
|
703
|
+
code: "custom",
|
|
704
|
+
message: "An uncited answer draft must declare insufficient evidence.",
|
|
705
|
+
path: ["warnings"]
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
const distinct = new Set(
|
|
709
|
+
citations.map(
|
|
710
|
+
(citation) => `${citation.handleId}:${String(citation.startLine)}:${String(citation.endLine)}`
|
|
711
|
+
)
|
|
712
|
+
);
|
|
713
|
+
if (distinct.size > limits.maximumSources) {
|
|
714
|
+
context.addIssue({
|
|
715
|
+
code: "custom",
|
|
716
|
+
message: "Answer references exceed the source limit.",
|
|
717
|
+
path: ["blocks"]
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
});
|
|
721
|
+
var sourceIdListSchema = import_zod2.z.array(contextualAskOpaqueIdSchema).max(limits.maximumSources);
|
|
722
|
+
var paragraphBlockSchema = import_zod2.z.strictObject({
|
|
723
|
+
kind: import_zod2.z.literal("paragraph"),
|
|
724
|
+
text: contextualAskBoundedText(limits.maximumAnswerCharacters),
|
|
725
|
+
sourceIds: sourceIdListSchema
|
|
726
|
+
});
|
|
727
|
+
var listBlockSchema = import_zod2.z.strictObject({
|
|
728
|
+
kind: import_zod2.z.literal("list"),
|
|
729
|
+
items: import_zod2.z.array(
|
|
730
|
+
import_zod2.z.strictObject({
|
|
731
|
+
text: contextualAskBoundedText(limits.maximumAnswerCharacters),
|
|
732
|
+
sourceIds: sourceIdListSchema
|
|
733
|
+
})
|
|
734
|
+
).min(1).max(limits.maximumAnswerBlocks)
|
|
735
|
+
});
|
|
736
|
+
var codeBlockSchema = import_zod2.z.strictObject({
|
|
737
|
+
kind: import_zod2.z.literal("code"),
|
|
738
|
+
code: import_zod2.z.string().min(1).max(limits.maximumAnswerCharacters),
|
|
739
|
+
language: contextualAskBoundedText(limits.maximumLanguageCharacters).optional(),
|
|
740
|
+
sourceIds: sourceIdListSchema
|
|
741
|
+
});
|
|
742
|
+
var askAnswerBlockSchema = import_zod2.z.discriminatedUnion("kind", [
|
|
743
|
+
paragraphBlockSchema,
|
|
744
|
+
listBlockSchema,
|
|
745
|
+
codeBlockSchema
|
|
746
|
+
]);
|
|
747
|
+
var askSourceReferenceSchema = import_zod2.z.strictObject({
|
|
748
|
+
sourceId: contextualAskOpaqueIdSchema,
|
|
749
|
+
label: contextualAskBoundedText(limits.maximumLabelCharacters),
|
|
750
|
+
relativePath: contextualAskRelativePathSchema,
|
|
751
|
+
fileId: contextualAskOpaqueIdSchema,
|
|
752
|
+
startLine: import_zod2.z.number().int().positive(),
|
|
753
|
+
endLine: import_zod2.z.number().int().positive(),
|
|
754
|
+
confidence: import_zod2.z.enum(ASK_SOURCE_CONFIDENCES),
|
|
755
|
+
targetIds: import_zod2.z.array(contextualAskOpaqueIdSchema).min(1).max(limits.maximumTargets),
|
|
756
|
+
sourceVersion: contextualAskBoundedText(limits.maximumIdCharacters).optional(),
|
|
757
|
+
contentHash: contentHashSchema
|
|
758
|
+
}).superRefine((source, context) => {
|
|
759
|
+
if (source.endLine < source.startLine) {
|
|
760
|
+
context.addIssue({
|
|
761
|
+
code: "custom",
|
|
762
|
+
message: "Source endLine must not precede startLine.",
|
|
763
|
+
path: ["endLine"]
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
if (new Set(source.targetIds).size !== source.targetIds.length) {
|
|
767
|
+
context.addIssue({
|
|
768
|
+
code: "custom",
|
|
769
|
+
message: "Source target IDs must be unique.",
|
|
770
|
+
path: ["targetIds"]
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
});
|
|
774
|
+
function resultBlockCharacters(blocks) {
|
|
775
|
+
return blocks.reduce((total, block) => {
|
|
776
|
+
if (block.kind === "paragraph") return total + block.text.length;
|
|
777
|
+
if (block.kind === "code") return total + block.code.length;
|
|
778
|
+
return total + block.items.reduce((itemTotal, item) => itemTotal + item.text.length, 0);
|
|
779
|
+
}, 0);
|
|
780
|
+
}
|
|
781
|
+
var askAnswerResultSchema = import_zod2.z.strictObject({
|
|
782
|
+
schemaVersion: import_zod2.z.literal(CONTEXTUAL_ASK_SCHEMA_VERSION),
|
|
783
|
+
jobId: contextualAskOpaqueIdSchema,
|
|
784
|
+
selectionId: contextualAskOpaqueIdSchema,
|
|
785
|
+
contextHash: contentHashSchema,
|
|
786
|
+
executor: import_zod2.z.strictObject({
|
|
787
|
+
executorId: contextualAskOpaqueIdSchema,
|
|
788
|
+
kind: import_zod2.z.enum(CONTEXTUAL_ASK_EXECUTOR_KINDS),
|
|
789
|
+
label: contextualAskBoundedText(limits.maximumLabelCharacters),
|
|
790
|
+
modelLabel: contextualAskBoundedText(limits.maximumLabelCharacters)
|
|
791
|
+
}),
|
|
792
|
+
blocks: import_zod2.z.array(askAnswerBlockSchema).min(1).max(limits.maximumAnswerBlocks),
|
|
793
|
+
sources: import_zod2.z.array(askSourceReferenceSchema).max(limits.maximumSources),
|
|
794
|
+
warnings: import_zod2.z.array(askAnswerWarningSchema).max(limits.maximumAnswerBlocks),
|
|
795
|
+
createdAt: import_zod2.z.iso.datetime(),
|
|
796
|
+
expiresAt: import_zod2.z.iso.datetime()
|
|
797
|
+
}).superRefine((answer, context) => {
|
|
798
|
+
if (Date.parse(answer.expiresAt) <= Date.parse(answer.createdAt)) {
|
|
799
|
+
context.addIssue({
|
|
800
|
+
code: "custom",
|
|
801
|
+
message: "Answer expiry must follow creation.",
|
|
802
|
+
path: ["expiresAt"]
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
if (resultBlockCharacters(answer.blocks) > limits.maximumAnswerCharacters) {
|
|
806
|
+
context.addIssue({
|
|
807
|
+
code: "custom",
|
|
808
|
+
message: "Combined answer text exceeds the answer limit.",
|
|
809
|
+
path: ["blocks"]
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
const sourceIds = answer.sources.map((source) => source.sourceId);
|
|
813
|
+
if (new Set(sourceIds).size !== sourceIds.length) {
|
|
814
|
+
context.addIssue({
|
|
815
|
+
code: "custom",
|
|
816
|
+
message: "Answer source IDs must be unique.",
|
|
817
|
+
path: ["sources"]
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
const available = new Set(sourceIds);
|
|
821
|
+
const references = answer.blocks.flatMap(
|
|
822
|
+
(block) => block.kind === "list" ? block.items.flatMap((item) => item.sourceIds) : block.sourceIds
|
|
823
|
+
);
|
|
824
|
+
if (references.length === 0 && !answer.warnings.some((warning) => warning.code === "insufficient-evidence")) {
|
|
825
|
+
context.addIssue({
|
|
826
|
+
code: "custom",
|
|
827
|
+
message: "An uncited answer must declare insufficient evidence.",
|
|
828
|
+
path: ["warnings"]
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
if (references.some((sourceId) => !available.has(sourceId))) {
|
|
832
|
+
context.addIssue({
|
|
833
|
+
code: "custom",
|
|
834
|
+
message: "Answer blocks reference an unknown source ID.",
|
|
835
|
+
path: ["blocks"]
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
if (sourceIds.some((sourceId) => !references.includes(sourceId))) {
|
|
839
|
+
context.addIssue({
|
|
840
|
+
code: "custom",
|
|
841
|
+
message: "Answer sources must be referenced by at least one block.",
|
|
842
|
+
path: ["sources"]
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
var contextualAskExecutorCapabilitySchema = import_zod2.z.strictObject({
|
|
847
|
+
executorId: contextualAskOpaqueIdSchema,
|
|
848
|
+
kind: import_zod2.z.enum(CONTEXTUAL_ASK_EXECUTOR_KINDS),
|
|
849
|
+
label: contextualAskBoundedText(limits.maximumLabelCharacters),
|
|
850
|
+
requestedModelLabel: contextualAskBoundedText(limits.maximumLabelCharacters),
|
|
851
|
+
effectiveModelLabel: contextualAskBoundedText(limits.maximumLabelCharacters),
|
|
852
|
+
models: import_zod2.z.array(contextualAskBoundedText(limits.maximumLabelCharacters)).min(1).max(limits.maximumModels).refine((models) => new Set(models).size === models.length).optional(),
|
|
853
|
+
state: import_zod2.z.enum(CONTEXTUAL_ASK_EXECUTOR_STATES),
|
|
854
|
+
providerDataConsentRequired: import_zod2.z.boolean(),
|
|
855
|
+
readOnlyProven: import_zod2.z.boolean(),
|
|
856
|
+
errorCode: import_zod2.z.enum(CONTEXTUAL_ASK_ERROR_CODES).optional()
|
|
857
|
+
}).superRefine((executor, context) => {
|
|
858
|
+
if (executor.state === "ready" && (!executor.readOnlyProven || executor.errorCode !== void 0) || executor.state !== "ready" && executor.errorCode === void 0) {
|
|
859
|
+
context.addIssue({
|
|
860
|
+
code: "custom",
|
|
861
|
+
message: "Executor capability fields are inconsistent."
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
});
|
|
865
|
+
var contextualAskCapabilitySchema = import_zod2.z.strictObject({
|
|
866
|
+
schemaVersion: import_zod2.z.literal(CONTEXTUAL_ASK_SCHEMA_VERSION),
|
|
867
|
+
enabled: import_zod2.z.boolean(),
|
|
868
|
+
executors: import_zod2.z.array(contextualAskExecutorCapabilitySchema).max(limits.maximumExecutors),
|
|
869
|
+
safety: import_zod2.z.strictObject({
|
|
870
|
+
selectionRequired: import_zod2.z.literal(true),
|
|
871
|
+
singleTurn: import_zod2.z.literal(true),
|
|
872
|
+
writesAllowed: import_zod2.z.literal(false),
|
|
873
|
+
historyStored: import_zod2.z.literal(false)
|
|
874
|
+
}),
|
|
875
|
+
checkedAt: import_zod2.z.iso.datetime()
|
|
876
|
+
}).superRefine((capability, context) => {
|
|
877
|
+
if (!capability.enabled && capability.executors.length > 0 || new Set(capability.executors.map((executor) => executor.executorId)).size !== capability.executors.length) {
|
|
878
|
+
context.addIssue({
|
|
879
|
+
code: "custom",
|
|
880
|
+
message: "Contextual Ask capability fields are inconsistent.",
|
|
881
|
+
path: ["executors"]
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
});
|
|
885
|
+
|
|
301
886
|
// src/model/data-flow-adapters.ts
|
|
302
887
|
var DATA_FLOW_QUERY_ADAPTER_MODULES = Object.freeze([
|
|
303
888
|
"@tanstack/react-query",
|
|
@@ -341,7 +926,7 @@ var DATA_FLOW_TRPC_REQUEST_METHODS = Object.freeze([
|
|
|
341
926
|
]);
|
|
342
927
|
|
|
343
928
|
// src/model/data-flow.ts
|
|
344
|
-
var
|
|
929
|
+
var import_zod3 = require("zod");
|
|
345
930
|
|
|
346
931
|
// src/model/data-flow-limits.ts
|
|
347
932
|
var DEFAULT_DATA_FLOW_LIMITS = Object.freeze({
|
|
@@ -412,24 +997,24 @@ var DATA_FLOW_DIAGNOSTIC_CODES = Object.freeze([
|
|
|
412
997
|
"DATA_FLOW_REDACTION_APPLIED",
|
|
413
998
|
"DATA_FLOW_AI_DISABLED"
|
|
414
999
|
]);
|
|
415
|
-
var boundedText = (maximum) =>
|
|
1000
|
+
var boundedText = (maximum) => import_zod3.z.string().trim().min(1).max(maximum);
|
|
416
1001
|
var opaqueIdSchema = boundedText(128).regex(/^[A-Za-z0-9_-]+$/u);
|
|
417
|
-
var diagnosticCodeSchema =
|
|
418
|
-
var evidenceSourceSchema =
|
|
1002
|
+
var diagnosticCodeSchema = import_zod3.z.enum(DATA_FLOW_DIAGNOSTIC_CODES);
|
|
1003
|
+
var evidenceSourceSchema = import_zod3.z.strictObject({
|
|
419
1004
|
fileId: opaqueIdSchema,
|
|
420
1005
|
displayPath: boundedText(1024),
|
|
421
|
-
line:
|
|
422
|
-
column:
|
|
1006
|
+
line: import_zod3.z.number().int().positive(),
|
|
1007
|
+
column: import_zod3.z.number().int().positive(),
|
|
423
1008
|
sourceVersion: opaqueIdSchema
|
|
424
1009
|
});
|
|
425
|
-
var sanitizedObservedUrlSchema =
|
|
1010
|
+
var sanitizedObservedUrlSchema = import_zod3.z.strictObject({
|
|
426
1011
|
origin: boundedText(512).optional(),
|
|
427
1012
|
pathname: boundedText(2048),
|
|
428
|
-
queryKeys:
|
|
1013
|
+
queryKeys: import_zod3.z.array(boundedText(256)).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxFields)
|
|
429
1014
|
});
|
|
430
|
-
var dataParameterSchema =
|
|
1015
|
+
var dataParameterSchema = import_zod3.z.strictObject({
|
|
431
1016
|
path: boundedText(1024),
|
|
432
|
-
position:
|
|
1017
|
+
position: import_zod3.z.enum([
|
|
433
1018
|
"path",
|
|
434
1019
|
"query",
|
|
435
1020
|
"body",
|
|
@@ -442,34 +1027,34 @@ var dataParameterSchema = import_zod.z.strictObject({
|
|
|
442
1027
|
type: boundedText(512).optional(),
|
|
443
1028
|
source: boundedText(1024).optional(),
|
|
444
1029
|
condition: boundedText(1024).optional(),
|
|
445
|
-
sensitive:
|
|
446
|
-
valueState:
|
|
447
|
-
evidenceIds:
|
|
1030
|
+
sensitive: import_zod3.z.boolean(),
|
|
1031
|
+
valueState: import_zod3.z.literal("not-collected"),
|
|
1032
|
+
evidenceIds: import_zod3.z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence)
|
|
448
1033
|
});
|
|
449
|
-
var dataResponseSchema =
|
|
450
|
-
consumedFields:
|
|
1034
|
+
var dataResponseSchema = import_zod3.z.strictObject({
|
|
1035
|
+
consumedFields: import_zod3.z.array(boundedText(1024)).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxFields)
|
|
451
1036
|
});
|
|
452
|
-
var requestOriginSchema =
|
|
1037
|
+
var requestOriginSchema = import_zod3.z.strictObject({
|
|
453
1038
|
componentSourceId: opaqueIdSchema.optional(),
|
|
454
1039
|
triggerCallsiteId: opaqueIdSchema.optional(),
|
|
455
1040
|
requestCallsiteId: opaqueIdSchema,
|
|
456
1041
|
sourceVersion: opaqueIdSchema
|
|
457
1042
|
});
|
|
458
|
-
var capabilityReasonSchema =
|
|
1043
|
+
var capabilityReasonSchema = import_zod3.z.strictObject({
|
|
459
1044
|
code: diagnosticCodeSchema,
|
|
460
|
-
retryable:
|
|
1045
|
+
retryable: import_zod3.z.boolean()
|
|
461
1046
|
});
|
|
462
|
-
var capabilitySchema =
|
|
463
|
-
enabled:
|
|
464
|
-
staticAnalysis:
|
|
465
|
-
runtimeObservation:
|
|
466
|
-
responseShape:
|
|
467
|
-
aiAssistance:
|
|
468
|
-
reasons:
|
|
1047
|
+
var capabilitySchema = import_zod3.z.strictObject({
|
|
1048
|
+
enabled: import_zod3.z.boolean(),
|
|
1049
|
+
staticAnalysis: import_zod3.z.enum(["available", "partial", "unavailable"]),
|
|
1050
|
+
runtimeObservation: import_zod3.z.literal("dispatch-only"),
|
|
1051
|
+
responseShape: import_zod3.z.literal("consumed-fields-only"),
|
|
1052
|
+
aiAssistance: import_zod3.z.literal("disabled"),
|
|
1053
|
+
reasons: import_zod3.z.array(capabilityReasonSchema).max(DEFAULT_DATA_FLOW_LIMITS.capabilityMaxReasons)
|
|
469
1054
|
});
|
|
470
|
-
var evidenceSchema =
|
|
1055
|
+
var evidenceSchema = import_zod3.z.strictObject({
|
|
471
1056
|
id: opaqueIdSchema,
|
|
472
|
-
kind:
|
|
1057
|
+
kind: import_zod3.z.enum([
|
|
473
1058
|
"source-anchor",
|
|
474
1059
|
"import-resolution",
|
|
475
1060
|
"symbol-edge",
|
|
@@ -482,49 +1067,50 @@ var evidenceSchema = import_zod.z.strictObject({
|
|
|
482
1067
|
"diagnostic"
|
|
483
1068
|
]),
|
|
484
1069
|
source: evidenceSourceSchema.optional(),
|
|
485
|
-
adapter:
|
|
1070
|
+
adapter: import_zod3.z.strictObject({ id: boundedText(128), version: boundedText(64) }).optional(),
|
|
486
1071
|
summaryKey: boundedText(256)
|
|
487
1072
|
});
|
|
488
|
-
var diagnosticSchema =
|
|
1073
|
+
var diagnosticSchema = import_zod3.z.strictObject({
|
|
489
1074
|
id: opaqueIdSchema,
|
|
490
1075
|
code: diagnosticCodeSchema,
|
|
491
|
-
severity:
|
|
492
|
-
retryable:
|
|
493
|
-
evidenceIds:
|
|
1076
|
+
severity: import_zod3.z.enum(["info", "warning", "error"]),
|
|
1077
|
+
retryable: import_zod3.z.boolean(),
|
|
1078
|
+
evidenceIds: import_zod3.z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence)
|
|
494
1079
|
});
|
|
495
|
-
var baselineSchema =
|
|
1080
|
+
var baselineSchema = import_zod3.z.strictObject({
|
|
496
1081
|
registryEpoch: opaqueIdSchema,
|
|
497
1082
|
analyzerVersion: boundedText(64),
|
|
498
1083
|
adapterSetHash: boundedText(128),
|
|
499
|
-
analyzedSourceVersions:
|
|
1084
|
+
analyzedSourceVersions: import_zod3.z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxModules)
|
|
500
1085
|
});
|
|
501
|
-
var completenessSchema =
|
|
502
|
-
complete:
|
|
503
|
-
visitedModules:
|
|
504
|
-
visitedCallsites:
|
|
505
|
-
frontierCount:
|
|
506
|
-
truncatedBy:
|
|
1086
|
+
var completenessSchema = import_zod3.z.strictObject({
|
|
1087
|
+
complete: import_zod3.z.boolean(),
|
|
1088
|
+
visitedModules: import_zod3.z.number().int().nonnegative(),
|
|
1089
|
+
visitedCallsites: import_zod3.z.number().int().nonnegative(),
|
|
1090
|
+
frontierCount: import_zod3.z.number().int().nonnegative(),
|
|
1091
|
+
truncatedBy: import_zod3.z.enum(["depth", "modules", "callsites", "bytes", "timeout"]).optional()
|
|
507
1092
|
});
|
|
508
|
-
var dataDependencySchema =
|
|
1093
|
+
var dataDependencySchema = import_zod3.z.strictObject({
|
|
509
1094
|
id: opaqueIdSchema,
|
|
510
|
-
kind:
|
|
511
|
-
direction:
|
|
512
|
-
execution:
|
|
513
|
-
|
|
514
|
-
|
|
1095
|
+
kind: import_zod3.z.enum(["http", "graphql", "rpc", "server-action", "unknown"]),
|
|
1096
|
+
direction: import_zod3.z.enum(["read", "write", "read-write", "unknown"]),
|
|
1097
|
+
execution: import_zod3.z.enum(DATA_FLOW_EXECUTION_STATES),
|
|
1098
|
+
environment: import_zod3.z.enum(["server", "client"]).optional(),
|
|
1099
|
+
proof: import_zod3.z.enum(DATA_FLOW_PROOF_STATES),
|
|
1100
|
+
association: import_zod3.z.enum(DATA_FLOW_ASSOCIATION_KINDS),
|
|
515
1101
|
method: boundedText(32).optional(),
|
|
516
1102
|
operation: boundedText(512).optional(),
|
|
517
1103
|
url: sanitizedObservedUrlSchema.optional(),
|
|
518
|
-
parameters:
|
|
1104
|
+
parameters: import_zod3.z.array(dataParameterSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxFields),
|
|
519
1105
|
response: dataResponseSchema,
|
|
520
1106
|
origin: requestOriginSchema.optional(),
|
|
521
|
-
suppliedBindings:
|
|
522
|
-
locationIds:
|
|
523
|
-
evidenceIds:
|
|
524
|
-
observationIds:
|
|
1107
|
+
suppliedBindings: import_zod3.z.array(boundedText(1024)).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites),
|
|
1108
|
+
locationIds: import_zod3.z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites),
|
|
1109
|
+
evidenceIds: import_zod3.z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence),
|
|
1110
|
+
observationIds: import_zod3.z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.observationMaxEntries)
|
|
525
1111
|
});
|
|
526
|
-
var networkObservationSchema =
|
|
527
|
-
schemaVersion:
|
|
1112
|
+
var networkObservationSchema = import_zod3.z.strictObject({
|
|
1113
|
+
schemaVersion: import_zod3.z.literal(DATA_FLOW_SCHEMA_VERSION),
|
|
528
1114
|
id: opaqueIdSchema,
|
|
529
1115
|
pageEpoch: opaqueIdSchema,
|
|
530
1116
|
routeEpoch: opaqueIdSchema,
|
|
@@ -533,48 +1119,48 @@ var networkObservationSchema = import_zod.z.strictObject({
|
|
|
533
1119
|
componentSourceId: opaqueIdSchema.optional(),
|
|
534
1120
|
triggerCallsiteId: opaqueIdSchema.optional(),
|
|
535
1121
|
sourceVersion: opaqueIdSchema.optional(),
|
|
536
|
-
transport:
|
|
1122
|
+
transport: import_zod3.z.enum(["fetch", "trpc", "xhr"]),
|
|
537
1123
|
method: boundedText(32),
|
|
538
1124
|
operation: boundedText(512).optional(),
|
|
539
1125
|
url: sanitizedObservedUrlSchema,
|
|
540
|
-
outcome:
|
|
541
|
-
freshness:
|
|
542
|
-
diagnosticIds:
|
|
1126
|
+
outcome: import_zod3.z.literal("dispatched"),
|
|
1127
|
+
freshness: import_zod3.z.enum(DATA_FLOW_FRESHNESS_STATES),
|
|
1128
|
+
diagnosticIds: import_zod3.z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence)
|
|
543
1129
|
});
|
|
544
|
-
var componentIdentitySchema =
|
|
1130
|
+
var componentIdentitySchema = import_zod3.z.strictObject({
|
|
545
1131
|
componentSourceId: opaqueIdSchema.optional(),
|
|
546
1132
|
displayName: boundedText(256).optional(),
|
|
547
1133
|
source: evidenceSourceSchema
|
|
548
1134
|
});
|
|
549
|
-
var componentDataFlowReportSchema =
|
|
550
|
-
schemaVersion:
|
|
1135
|
+
var componentDataFlowReportSchema = import_zod3.z.strictObject({
|
|
1136
|
+
schemaVersion: import_zod3.z.literal(DATA_FLOW_SCHEMA_VERSION),
|
|
551
1137
|
reportId: opaqueIdSchema,
|
|
552
1138
|
baseline: baselineSchema,
|
|
553
1139
|
capability: capabilitySchema,
|
|
554
1140
|
component: componentIdentitySchema,
|
|
555
|
-
dependencies:
|
|
556
|
-
evidence:
|
|
557
|
-
diagnostics:
|
|
1141
|
+
dependencies: import_zod3.z.array(dataDependencySchema).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites),
|
|
1142
|
+
evidence: import_zod3.z.array(evidenceSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence),
|
|
1143
|
+
diagnostics: import_zod3.z.array(diagnosticSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxDiagnostics),
|
|
558
1144
|
completeness: completenessSchema
|
|
559
1145
|
});
|
|
560
|
-
var pageDataFlowReportSchema =
|
|
561
|
-
schemaVersion:
|
|
1146
|
+
var pageDataFlowReportSchema = import_zod3.z.strictObject({
|
|
1147
|
+
schemaVersion: import_zod3.z.literal(DATA_FLOW_SCHEMA_VERSION),
|
|
562
1148
|
reportId: opaqueIdSchema,
|
|
563
1149
|
baseline: baselineSchema,
|
|
564
1150
|
capability: capabilitySchema,
|
|
565
|
-
dependencies:
|
|
566
|
-
evidence:
|
|
567
|
-
diagnostics:
|
|
1151
|
+
dependencies: import_zod3.z.array(dataDependencySchema).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites),
|
|
1152
|
+
evidence: import_zod3.z.array(evidenceSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence),
|
|
1153
|
+
diagnostics: import_zod3.z.array(diagnosticSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxDiagnostics),
|
|
568
1154
|
completeness: completenessSchema
|
|
569
1155
|
});
|
|
570
|
-
var runtimeDataFlowConfigSchema =
|
|
571
|
-
enabled:
|
|
572
|
-
runtime:
|
|
573
|
-
limits:
|
|
574
|
-
observationMaxEntries:
|
|
575
|
-
observationMaxBytes:
|
|
576
|
-
observationTtlMs:
|
|
577
|
-
reportMaxBytes:
|
|
1156
|
+
var runtimeDataFlowConfigSchema = import_zod3.z.strictObject({
|
|
1157
|
+
enabled: import_zod3.z.boolean(),
|
|
1158
|
+
runtime: import_zod3.z.literal("dispatch"),
|
|
1159
|
+
limits: import_zod3.z.strictObject({
|
|
1160
|
+
observationMaxEntries: import_zod3.z.number().int().positive(),
|
|
1161
|
+
observationMaxBytes: import_zod3.z.number().int().positive(),
|
|
1162
|
+
observationTtlMs: import_zod3.z.number().int().positive(),
|
|
1163
|
+
reportMaxBytes: import_zod3.z.number().int().positive()
|
|
578
1164
|
})
|
|
579
1165
|
});
|
|
580
1166
|
|
|
@@ -776,7 +1362,7 @@ function limitDataFlowReportCollections(report, options = {}) {
|
|
|
776
1362
|
}
|
|
777
1363
|
|
|
778
1364
|
// src/model/runtime-config.ts
|
|
779
|
-
var
|
|
1365
|
+
var import_zod4 = require("zod");
|
|
780
1366
|
|
|
781
1367
|
// src/protocol/endpoints.ts
|
|
782
1368
|
var SPOTPATCH_API_BASE = "/__spotpatch/v1";
|
|
@@ -790,6 +1376,8 @@ var SPOTPATCH_ENDPOINTS = Object.freeze({
|
|
|
790
1376
|
agentCapability: `${SPOTPATCH_API_BASE}/agent/capability`,
|
|
791
1377
|
agentWorkspaceHealth: `${SPOTPATCH_API_BASE}/agent/workspace-health`,
|
|
792
1378
|
agentJobs: `${SPOTPATCH_API_BASE}/agent/jobs`,
|
|
1379
|
+
askCapability: `${SPOTPATCH_API_BASE}/ask/capability`,
|
|
1380
|
+
askJobs: `${SPOTPATCH_API_BASE}/ask/jobs`,
|
|
793
1381
|
externalHandoffCapability: `${SPOTPATCH_API_BASE}/external-handoff/capability`,
|
|
794
1382
|
externalHandoffPublish: `${SPOTPATCH_API_BASE}/external-handoff/publish`,
|
|
795
1383
|
externalHandoffStatus: `${SPOTPATCH_API_BASE}/external-handoff/status`,
|
|
@@ -804,6 +1392,17 @@ var SPOTPATCH_ENDPOINTS = Object.freeze({
|
|
|
804
1392
|
function getAgentJobEndpoint(jobId, action) {
|
|
805
1393
|
return `${SPOTPATCH_ENDPOINTS.agentJobs}/${encodeURIComponent(jobId)}/${action}`;
|
|
806
1394
|
}
|
|
1395
|
+
function getAskJobEndpoint(jobId, action, options = {}) {
|
|
1396
|
+
const endpoint = `${SPOTPATCH_ENDPOINTS.askJobs}/${encodeURIComponent(jobId)}/${action}`;
|
|
1397
|
+
if (action !== "events" && options.afterSequence !== void 0) {
|
|
1398
|
+
throw new RangeError("afterSequence is only valid for the events endpoint.");
|
|
1399
|
+
}
|
|
1400
|
+
if (options.afterSequence === void 0) return endpoint;
|
|
1401
|
+
if (!Number.isSafeInteger(options.afterSequence) || options.afterSequence < 0) {
|
|
1402
|
+
throw new RangeError("afterSequence must be a non-negative safe integer.");
|
|
1403
|
+
}
|
|
1404
|
+
return `${endpoint}?afterSequence=${String(options.afterSequence)}`;
|
|
1405
|
+
}
|
|
807
1406
|
|
|
808
1407
|
// src/model/editor.ts
|
|
809
1408
|
var SPOTPATCH_EDITOR_PREFERENCES = ["auto", "vscode", "cursor"];
|
|
@@ -878,39 +1477,39 @@ var SPOTPATCH_NEXT_ROUTER_KINDS = Object.freeze([
|
|
|
878
1477
|
"pages",
|
|
879
1478
|
"hybrid"
|
|
880
1479
|
]);
|
|
881
|
-
var boundedText2 = (maximum) =>
|
|
882
|
-
var
|
|
883
|
-
var runtimeAiModelSchema =
|
|
884
|
-
id:
|
|
1480
|
+
var boundedText2 = (maximum) => import_zod4.z.string().trim().min(1).max(maximum);
|
|
1481
|
+
var profileIdSchema2 = import_zod4.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u);
|
|
1482
|
+
var runtimeAiModelSchema = import_zod4.z.strictObject({
|
|
1483
|
+
id: profileIdSchema2,
|
|
885
1484
|
label: boundedText2(100)
|
|
886
1485
|
});
|
|
887
|
-
var runtimeAiProviderSchema =
|
|
888
|
-
id:
|
|
1486
|
+
var runtimeAiProviderSchema = import_zod4.z.strictObject({
|
|
1487
|
+
id: profileIdSchema2,
|
|
889
1488
|
label: boundedText2(100),
|
|
890
|
-
protocol:
|
|
891
|
-
models:
|
|
892
|
-
defaultModel:
|
|
1489
|
+
protocol: import_zod4.z.enum(["responses", "chat-completions"]),
|
|
1490
|
+
models: import_zod4.z.array(runtimeAiModelSchema).min(1).max(64),
|
|
1491
|
+
defaultModel: profileIdSchema2
|
|
893
1492
|
}).refine(
|
|
894
1493
|
({ defaultModel, models }) => models.some(({ id }) => id === defaultModel) && new Set(models.map(({ id }) => id)).size === models.length,
|
|
895
1494
|
{ message: "Runtime AI model profiles are inconsistent." }
|
|
896
1495
|
);
|
|
897
|
-
var runtimeAiConfigSchema =
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
enabled:
|
|
901
|
-
providers:
|
|
902
|
-
defaultProvider:
|
|
903
|
-
applyMode:
|
|
1496
|
+
var runtimeAiConfigSchema = import_zod4.z.discriminatedUnion("enabled", [
|
|
1497
|
+
import_zod4.z.strictObject({ enabled: import_zod4.z.literal(false) }),
|
|
1498
|
+
import_zod4.z.strictObject({
|
|
1499
|
+
enabled: import_zod4.z.literal(true),
|
|
1500
|
+
providers: import_zod4.z.array(runtimeAiProviderSchema).min(1).max(32),
|
|
1501
|
+
defaultProvider: profileIdSchema2,
|
|
1502
|
+
applyMode: import_zod4.z.enum(AGENT_APPLY_MODES)
|
|
904
1503
|
}).refine(
|
|
905
1504
|
({ defaultProvider, providers }) => providers.some(({ id }) => id === defaultProvider) && new Set(providers.map(({ id }) => id)).size === providers.length,
|
|
906
1505
|
{ message: "Runtime AI provider profiles are inconsistent." }
|
|
907
1506
|
)
|
|
908
1507
|
]);
|
|
909
|
-
var positiveInteger =
|
|
1508
|
+
var positiveInteger = import_zod4.z.number().int().positive();
|
|
910
1509
|
var runtimeConfigBaseShape = {
|
|
911
|
-
apiBase:
|
|
1510
|
+
apiBase: import_zod4.z.literal(SPOTPATCH_API_BASE),
|
|
912
1511
|
ai: runtimeAiConfigSchema,
|
|
913
|
-
budget:
|
|
1512
|
+
budget: import_zod4.z.strictObject({
|
|
914
1513
|
totalCharacters: positiveInteger,
|
|
915
1514
|
domCharacters: positiveInteger,
|
|
916
1515
|
cssCharacters: positiveInteger,
|
|
@@ -918,37 +1517,47 @@ var runtimeConfigBaseShape = {
|
|
|
918
1517
|
maxCodeLines: positiveInteger,
|
|
919
1518
|
maxComponentDepth: positiveInteger
|
|
920
1519
|
}),
|
|
921
|
-
|
|
1520
|
+
contextualAsk: import_zod4.z.strictObject({ enabled: import_zod4.z.boolean() }),
|
|
1521
|
+
debug: import_zod4.z.boolean(),
|
|
922
1522
|
dataFlow: runtimeDataFlowConfigSchema,
|
|
923
|
-
editor:
|
|
924
|
-
externalAgent:
|
|
1523
|
+
editor: import_zod4.z.enum(SPOTPATCH_EDITOR_PREFERENCES),
|
|
1524
|
+
externalAgent: import_zod4.z.strictObject({ enabled: import_zod4.z.boolean() }),
|
|
925
1525
|
frameworkVersion: boundedText2(64),
|
|
926
|
-
locale:
|
|
927
|
-
maxTargets:
|
|
928
|
-
redact:
|
|
929
|
-
sessionId:
|
|
930
|
-
sessionToken:
|
|
1526
|
+
locale: import_zod4.z.enum(SPOTPATCH_LOCALE_PREFERENCES),
|
|
1527
|
+
maxTargets: import_zod4.z.number().int().min(1).max(MAX_ANNOTATION_TARGETS),
|
|
1528
|
+
redact: import_zod4.z.boolean(),
|
|
1529
|
+
sessionId: import_zod4.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
|
|
1530
|
+
sessionToken: import_zod4.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
|
|
931
1531
|
shortcut: boundedText2(128),
|
|
932
1532
|
spotPatchVersion: boundedText2(64)
|
|
933
1533
|
};
|
|
934
|
-
var runtimeConfigSchema =
|
|
935
|
-
|
|
1534
|
+
var runtimeConfigSchema = import_zod4.z.discriminatedUnion("framework", [
|
|
1535
|
+
import_zod4.z.strictObject({
|
|
936
1536
|
...runtimeConfigBaseShape,
|
|
937
|
-
framework:
|
|
1537
|
+
framework: import_zod4.z.literal("astro")
|
|
938
1538
|
}),
|
|
939
|
-
|
|
1539
|
+
import_zod4.z.strictObject({
|
|
1540
|
+
...runtimeConfigBaseShape,
|
|
1541
|
+
framework: import_zod4.z.literal("vite")
|
|
1542
|
+
}),
|
|
1543
|
+
import_zod4.z.strictObject({
|
|
940
1544
|
...runtimeConfigBaseShape,
|
|
941
|
-
bundler:
|
|
942
|
-
framework:
|
|
943
|
-
routerKind:
|
|
1545
|
+
bundler: import_zod4.z.enum(SPOTPATCH_NEXT_BUNDLERS),
|
|
1546
|
+
framework: import_zod4.z.literal("next"),
|
|
1547
|
+
routerKind: import_zod4.z.enum(SPOTPATCH_NEXT_ROUTER_KINDS)
|
|
944
1548
|
})
|
|
945
1549
|
]);
|
|
946
1550
|
|
|
947
1551
|
// src/model/source-marker.ts
|
|
948
1552
|
var SOURCE_MARKER_ATTRIBUTE = "data-spotpatch-source";
|
|
949
|
-
var SOURCE_MARKER_PATTERN = /^([A-Za-z0-9_-]+):([1-9]\d*):([1-9]\d*)
|
|
1553
|
+
var SOURCE_MARKER_PATTERN = /^([A-Za-z0-9_-]+):([1-9]\d*):([1-9]\d*)(:astro)?$/;
|
|
950
1554
|
function formatSourceMarker(marker) {
|
|
951
|
-
return [
|
|
1555
|
+
return [
|
|
1556
|
+
marker.fileId,
|
|
1557
|
+
String(marker.line),
|
|
1558
|
+
String(marker.column),
|
|
1559
|
+
...marker.kind === void 0 ? [] : [marker.kind]
|
|
1560
|
+
].join(":");
|
|
952
1561
|
}
|
|
953
1562
|
function parseSourceMarker(value) {
|
|
954
1563
|
if (value === null) {
|
|
@@ -964,11 +1573,16 @@ function parseSourceMarker(value) {
|
|
|
964
1573
|
if (fileId === void 0 || !Number.isSafeInteger(line) || !Number.isSafeInteger(column)) {
|
|
965
1574
|
return void 0;
|
|
966
1575
|
}
|
|
967
|
-
return Object.freeze({
|
|
1576
|
+
return Object.freeze({
|
|
1577
|
+
fileId,
|
|
1578
|
+
line,
|
|
1579
|
+
column,
|
|
1580
|
+
...match[4] === void 0 ? {} : { kind: "astro" }
|
|
1581
|
+
});
|
|
968
1582
|
}
|
|
969
1583
|
|
|
970
1584
|
// src/protocol/external-agent-control.ts
|
|
971
|
-
var
|
|
1585
|
+
var import_zod5 = require("zod");
|
|
972
1586
|
var EXTERNAL_AGENT_CONTROL_SCHEMA_VERSION = 1;
|
|
973
1587
|
var EXTERNAL_AGENT_MANAGED_ADAPTER_KINDS = Object.freeze(["codex"]);
|
|
974
1588
|
var EXTERNAL_AGENT_MODES = Object.freeze(["inbox", "managed"]);
|
|
@@ -1093,9 +1707,9 @@ var EXTERNAL_AGENT_CONTROL_LIMITS = Object.freeze({
|
|
|
1093
1707
|
maximumEventLineBytes: 64 * 1024,
|
|
1094
1708
|
maximumResultDiffBytes: DEFAULT_AGENT_LIMITS.maxDiffBytes
|
|
1095
1709
|
});
|
|
1096
|
-
var isoTimestampSchema =
|
|
1097
|
-
var requestIdSchema =
|
|
1098
|
-
var safeRelativePathSchema =
|
|
1710
|
+
var isoTimestampSchema = import_zod5.z.iso.datetime();
|
|
1711
|
+
var requestIdSchema = import_zod5.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u);
|
|
1712
|
+
var safeRelativePathSchema = import_zod5.z.string().min(1).max(4096).superRefine((value, context) => {
|
|
1099
1713
|
const segments = value.split("/");
|
|
1100
1714
|
if (value.startsWith("/") || value.includes("\\") || segments.some(
|
|
1101
1715
|
(segment) => segment.length === 0 || segment === "." || segment === ".."
|
|
@@ -1103,237 +1717,150 @@ var safeRelativePathSchema = import_zod3.z.string().min(1).max(4096).superRefine
|
|
|
1103
1717
|
context.addIssue({ code: "custom", message: "Expected a safe relative path." });
|
|
1104
1718
|
}
|
|
1105
1719
|
});
|
|
1106
|
-
var externalAgentErrorSchema =
|
|
1107
|
-
code:
|
|
1108
|
-
stage:
|
|
1109
|
-
recoverability:
|
|
1110
|
-
action:
|
|
1720
|
+
var externalAgentErrorSchema = import_zod5.z.strictObject({
|
|
1721
|
+
code: import_zod5.z.enum(EXTERNAL_AGENT_ERROR_CODES),
|
|
1722
|
+
stage: import_zod5.z.enum(EXTERNAL_AGENT_ERROR_STAGES),
|
|
1723
|
+
recoverability: import_zod5.z.enum(EXTERNAL_AGENT_ERROR_RECOVERABILITY),
|
|
1724
|
+
action: import_zod5.z.enum(EXTERNAL_AGENT_ACTIONS)
|
|
1111
1725
|
});
|
|
1112
|
-
var managedFileSummarySchema =
|
|
1726
|
+
var managedFileSummarySchema = import_zod5.z.strictObject({
|
|
1113
1727
|
path: safeRelativePathSchema,
|
|
1114
|
-
additions:
|
|
1115
|
-
deletions:
|
|
1116
|
-
});
|
|
1117
|
-
var managedCheckSummarySchema =
|
|
1118
|
-
id:
|
|
1119
|
-
outcome:
|
|
1120
|
-
durationMs:
|
|
1121
|
-
exitCode:
|
|
1122
|
-
});
|
|
1123
|
-
var managedTimingSummarySchema =
|
|
1124
|
-
preparing:
|
|
1125
|
-
agent:
|
|
1126
|
-
auditing:
|
|
1127
|
-
validating:
|
|
1128
|
-
applying:
|
|
1129
|
-
total:
|
|
1130
|
-
});
|
|
1131
|
-
var managedTaskStatusSchema =
|
|
1132
|
-
revision:
|
|
1133
|
-
deliveryStatus:
|
|
1134
|
-
executionStatus:
|
|
1135
|
-
managedPhase:
|
|
1136
|
-
validationOutcome:
|
|
1137
|
-
files:
|
|
1138
|
-
checks:
|
|
1728
|
+
additions: import_zod5.z.number().int().nonnegative(),
|
|
1729
|
+
deletions: import_zod5.z.number().int().nonnegative()
|
|
1730
|
+
});
|
|
1731
|
+
var managedCheckSummarySchema = import_zod5.z.strictObject({
|
|
1732
|
+
id: import_zod5.z.string().min(1).max(128).regex(/^[A-Za-z0-9._-]+$/u),
|
|
1733
|
+
outcome: import_zod5.z.enum(EXTERNAL_AGENT_CHECK_OUTCOMES),
|
|
1734
|
+
durationMs: import_zod5.z.number().int().nonnegative(),
|
|
1735
|
+
exitCode: import_zod5.z.number().int().optional()
|
|
1736
|
+
});
|
|
1737
|
+
var managedTimingSummarySchema = import_zod5.z.strictObject({
|
|
1738
|
+
preparing: import_zod5.z.number().int().nonnegative().optional(),
|
|
1739
|
+
agent: import_zod5.z.number().int().nonnegative().optional(),
|
|
1740
|
+
auditing: import_zod5.z.number().int().nonnegative().optional(),
|
|
1741
|
+
validating: import_zod5.z.number().int().nonnegative().optional(),
|
|
1742
|
+
applying: import_zod5.z.number().int().nonnegative().optional(),
|
|
1743
|
+
total: import_zod5.z.number().int().nonnegative().optional()
|
|
1744
|
+
});
|
|
1745
|
+
var managedTaskStatusSchema = import_zod5.z.strictObject({
|
|
1746
|
+
revision: import_zod5.z.number().int().positive(),
|
|
1747
|
+
deliveryStatus: import_zod5.z.enum(EXTERNAL_AGENT_DELIVERY_STATUSES),
|
|
1748
|
+
executionStatus: import_zod5.z.enum(EXTERNAL_AGENT_EXECUTION_STATUSES),
|
|
1749
|
+
managedPhase: import_zod5.z.enum(EXTERNAL_AGENT_MANAGED_PHASES),
|
|
1750
|
+
validationOutcome: import_zod5.z.enum(EXTERNAL_AGENT_VALIDATION_OUTCOMES).optional(),
|
|
1751
|
+
files: import_zod5.z.array(managedFileSummarySchema).max(EXTERNAL_AGENT_CONTROL_LIMITS.maximumChangedFiles),
|
|
1752
|
+
checks: import_zod5.z.array(managedCheckSummarySchema).max(EXTERNAL_AGENT_CONTROL_LIMITS.maximumChecks),
|
|
1139
1753
|
timings: managedTimingSummarySchema,
|
|
1140
1754
|
resultExpiresAt: isoTimestampSchema.optional()
|
|
1141
1755
|
});
|
|
1142
|
-
var externalAgentControlStatusSchema =
|
|
1143
|
-
schemaVersion:
|
|
1144
|
-
sequence:
|
|
1145
|
-
mode:
|
|
1146
|
-
adapter:
|
|
1147
|
-
kind:
|
|
1148
|
-
maturity:
|
|
1149
|
-
availability:
|
|
1756
|
+
var externalAgentControlStatusSchema = import_zod5.z.strictObject({
|
|
1757
|
+
schemaVersion: import_zod5.z.literal(EXTERNAL_AGENT_CONTROL_SCHEMA_VERSION),
|
|
1758
|
+
sequence: import_zod5.z.number().int().nonnegative(),
|
|
1759
|
+
mode: import_zod5.z.enum(EXTERNAL_AGENT_MODES),
|
|
1760
|
+
adapter: import_zod5.z.strictObject({
|
|
1761
|
+
kind: import_zod5.z.enum(EXTERNAL_AGENT_MANAGED_ADAPTER_KINDS),
|
|
1762
|
+
maturity: import_zod5.z.literal("experimental"),
|
|
1763
|
+
availability: import_zod5.z.enum(["available", "unavailable"])
|
|
1150
1764
|
}),
|
|
1151
|
-
connectionState:
|
|
1152
|
-
authReadiness:
|
|
1153
|
-
grantState:
|
|
1154
|
-
requestedModel:
|
|
1155
|
-
effectiveModel:
|
|
1765
|
+
connectionState: import_zod5.z.enum(EXTERNAL_AGENT_CONNECTION_STATES),
|
|
1766
|
+
authReadiness: import_zod5.z.enum(EXTERNAL_AGENT_AUTH_READINESS),
|
|
1767
|
+
grantState: import_zod5.z.enum(EXTERNAL_AGENT_GRANT_STATES),
|
|
1768
|
+
requestedModel: import_zod5.z.string().min(1).max(128).optional(),
|
|
1769
|
+
effectiveModel: import_zod5.z.string().min(1).max(128).optional(),
|
|
1156
1770
|
task: managedTaskStatusSchema.optional(),
|
|
1157
1771
|
error: externalAgentErrorSchema.optional(),
|
|
1158
1772
|
updatedAt: isoTimestampSchema
|
|
1159
1773
|
});
|
|
1160
|
-
var externalAgentControlStatusRequestSchema =
|
|
1161
|
-
var externalAgentControlConnectRequestSchema =
|
|
1774
|
+
var externalAgentControlStatusRequestSchema = import_zod5.z.strictObject({});
|
|
1775
|
+
var externalAgentControlConnectRequestSchema = import_zod5.z.strictObject({
|
|
1162
1776
|
requestId: requestIdSchema,
|
|
1163
|
-
adapterKind:
|
|
1164
|
-
profile:
|
|
1777
|
+
adapterKind: import_zod5.z.literal("codex"),
|
|
1778
|
+
profile: import_zod5.z.literal(EXTERNAL_AGENT_MANAGED_PROFILE)
|
|
1165
1779
|
});
|
|
1166
|
-
var externalAgentControlDisconnectRequestSchema =
|
|
1780
|
+
var externalAgentControlDisconnectRequestSchema = import_zod5.z.strictObject({
|
|
1167
1781
|
requestId: requestIdSchema,
|
|
1168
|
-
adapterKind:
|
|
1169
|
-
revokeGrant:
|
|
1782
|
+
adapterKind: import_zod5.z.literal("codex"),
|
|
1783
|
+
revokeGrant: import_zod5.z.boolean()
|
|
1170
1784
|
});
|
|
1171
|
-
var externalAgentControlCancelRequestSchema =
|
|
1785
|
+
var externalAgentControlCancelRequestSchema = import_zod5.z.strictObject({
|
|
1172
1786
|
requestId: requestIdSchema,
|
|
1173
|
-
revision:
|
|
1787
|
+
revision: import_zod5.z.number().int().positive()
|
|
1174
1788
|
});
|
|
1175
|
-
var externalAgentEventsRequestSchema =
|
|
1176
|
-
afterSequence:
|
|
1789
|
+
var externalAgentEventsRequestSchema = import_zod5.z.strictObject({
|
|
1790
|
+
afterSequence: import_zod5.z.number().int().nonnegative().optional()
|
|
1177
1791
|
});
|
|
1178
|
-
var externalAgentEventSchema =
|
|
1179
|
-
|
|
1180
|
-
type:
|
|
1792
|
+
var externalAgentEventSchema = import_zod5.z.discriminatedUnion("type", [
|
|
1793
|
+
import_zod5.z.strictObject({
|
|
1794
|
+
type: import_zod5.z.literal("status"),
|
|
1181
1795
|
data: externalAgentControlStatusSchema
|
|
1182
1796
|
}),
|
|
1183
|
-
|
|
1184
|
-
type:
|
|
1185
|
-
sequence:
|
|
1797
|
+
import_zod5.z.strictObject({
|
|
1798
|
+
type: import_zod5.z.literal("heartbeat"),
|
|
1799
|
+
sequence: import_zod5.z.number().int().nonnegative(),
|
|
1186
1800
|
emittedAt: isoTimestampSchema
|
|
1187
1801
|
})
|
|
1188
1802
|
]);
|
|
1189
|
-
var externalAgentResultRequestSchema =
|
|
1190
|
-
revision:
|
|
1191
|
-
});
|
|
1192
|
-
var externalAgentManagedResultSchema =
|
|
1193
|
-
revision:
|
|
1194
|
-
diff:
|
|
1195
|
-
files:
|
|
1196
|
-
checks:
|
|
1803
|
+
var externalAgentResultRequestSchema = import_zod5.z.strictObject({
|
|
1804
|
+
revision: import_zod5.z.number().int().positive()
|
|
1805
|
+
});
|
|
1806
|
+
var externalAgentManagedResultSchema = import_zod5.z.strictObject({
|
|
1807
|
+
revision: import_zod5.z.number().int().positive(),
|
|
1808
|
+
diff: import_zod5.z.string().max(EXTERNAL_AGENT_CONTROL_LIMITS.maximumResultDiffBytes),
|
|
1809
|
+
files: import_zod5.z.array(managedFileSummarySchema).max(EXTERNAL_AGENT_CONTROL_LIMITS.maximumChangedFiles),
|
|
1810
|
+
checks: import_zod5.z.array(managedCheckSummarySchema).max(EXTERNAL_AGENT_CONTROL_LIMITS.maximumChecks),
|
|
1197
1811
|
timings: managedTimingSummarySchema,
|
|
1198
|
-
validationOutcome:
|
|
1812
|
+
validationOutcome: import_zod5.z.enum(EXTERNAL_AGENT_VALIDATION_OUTCOMES),
|
|
1199
1813
|
expiresAt: isoTimestampSchema
|
|
1200
1814
|
});
|
|
1201
1815
|
|
|
1202
1816
|
// src/protocol/external-handoff.ts
|
|
1203
|
-
var
|
|
1817
|
+
var import_zod7 = require("zod");
|
|
1204
1818
|
|
|
1205
1819
|
// src/protocol/requests.ts
|
|
1206
|
-
var
|
|
1207
|
-
var runtimeBootstrapRequestSchema =
|
|
1208
|
-
var sourceCoordinatesSchema =
|
|
1209
|
-
fileId:
|
|
1210
|
-
line:
|
|
1211
|
-
column:
|
|
1820
|
+
var import_zod6 = require("zod");
|
|
1821
|
+
var runtimeBootstrapRequestSchema = import_zod6.z.strictObject({});
|
|
1822
|
+
var sourceCoordinatesSchema = import_zod6.z.strictObject({
|
|
1823
|
+
fileId: import_zod6.z.string().min(1).max(128),
|
|
1824
|
+
line: import_zod6.z.number().int().positive(),
|
|
1825
|
+
column: import_zod6.z.number().int().positive()
|
|
1212
1826
|
});
|
|
1213
1827
|
var sourceContextRequestSchema = sourceCoordinatesSchema.extend({
|
|
1214
|
-
maxLines:
|
|
1828
|
+
maxLines: import_zod6.z.number().int().positive()
|
|
1215
1829
|
}).strict();
|
|
1216
1830
|
var openEditorRequestSchema = sourceCoordinatesSchema.strict();
|
|
1217
1831
|
var dataFlowSourceCoordinatesRequestSchema = sourceCoordinatesSchema.extend({
|
|
1218
|
-
schemaVersion:
|
|
1219
|
-
sourceVersion:
|
|
1832
|
+
schemaVersion: import_zod6.z.literal(1),
|
|
1833
|
+
sourceVersion: import_zod6.z.string().min(1).max(128).optional()
|
|
1220
1834
|
}).strict();
|
|
1221
|
-
var dataFlowComponentIdentityRequestSchema =
|
|
1222
|
-
schemaVersion:
|
|
1223
|
-
componentSourceId:
|
|
1224
|
-
sourceVersion:
|
|
1835
|
+
var dataFlowComponentIdentityRequestSchema = import_zod6.z.strictObject({
|
|
1836
|
+
schemaVersion: import_zod6.z.literal(1),
|
|
1837
|
+
componentSourceId: import_zod6.z.string().min(1).max(128),
|
|
1838
|
+
sourceVersion: import_zod6.z.string().min(1).max(128)
|
|
1225
1839
|
});
|
|
1226
|
-
var dataFlowComponentReportRequestSchema =
|
|
1840
|
+
var dataFlowComponentReportRequestSchema = import_zod6.z.union([
|
|
1227
1841
|
dataFlowSourceCoordinatesRequestSchema,
|
|
1228
1842
|
dataFlowComponentIdentityRequestSchema
|
|
1229
1843
|
]);
|
|
1230
|
-
var dataFlowPageReportRequestSchema =
|
|
1231
|
-
schemaVersion:
|
|
1232
|
-
targets:
|
|
1233
|
-
});
|
|
1234
|
-
var profileIdSchema2 = import_zod4.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
1235
|
-
var boundedString = (maximum) => import_zod4.z.string().max(maximum);
|
|
1236
|
-
var sourceRefSchema = import_zod4.z.strictObject({
|
|
1237
|
-
fileId: boundedString(128).optional(),
|
|
1238
|
-
relativePath: boundedString(1024).optional(),
|
|
1239
|
-
line: import_zod4.z.number().int().positive().optional(),
|
|
1240
|
-
column: import_zod4.z.number().int().positive().optional(),
|
|
1241
|
-
origin: import_zod4.z.enum(["jsx-host", "react-fiber", "dom-ancestor", "none"]),
|
|
1242
|
-
confidence: import_zod4.z.enum(["exact", "probable", "approximate", "unknown"])
|
|
1243
|
-
});
|
|
1244
|
-
var matchedStyleRuleSchema = import_zod4.z.strictObject({
|
|
1245
|
-
selector: boundedString(2048),
|
|
1246
|
-
declarations: boundedString(8192),
|
|
1247
|
-
source: boundedString(1024).optional(),
|
|
1248
|
-
media: boundedString(1024).optional()
|
|
1249
|
-
});
|
|
1250
|
-
var codeContextSchema = import_zod4.z.strictObject({
|
|
1251
|
-
relativePath: boundedString(1024),
|
|
1252
|
-
language: import_zod4.z.enum(["tsx", "jsx"]),
|
|
1253
|
-
startLine: import_zod4.z.number().int().positive(),
|
|
1254
|
-
endLine: import_zod4.z.number().int().positive(),
|
|
1255
|
-
excerpt: boundedString(16e3),
|
|
1256
|
-
boundary: import_zod4.z.enum(["component", "nearby-lines"])
|
|
1257
|
-
});
|
|
1258
|
-
var pageContextSchema = import_zod4.z.strictObject({
|
|
1259
|
-
url: boundedString(2048),
|
|
1260
|
-
pathname: boundedString(2048),
|
|
1261
|
-
title: boundedString(1024),
|
|
1262
|
-
viewportWidth: import_zod4.z.number().nonnegative(),
|
|
1263
|
-
viewportHeight: import_zod4.z.number().nonnegative(),
|
|
1264
|
-
devicePixelRatio: import_zod4.z.number().positive()
|
|
1844
|
+
var dataFlowPageReportRequestSchema = import_zod6.z.strictObject({
|
|
1845
|
+
schemaVersion: import_zod6.z.literal(1),
|
|
1846
|
+
targets: import_zod6.z.array(dataFlowComponentReportRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS)
|
|
1265
1847
|
});
|
|
1266
|
-
var
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
react: import_zod4.z.strictObject({
|
|
1271
|
-
supported: import_zod4.z.boolean(),
|
|
1272
|
-
version: boundedString(64).optional(),
|
|
1273
|
-
componentName: boundedString(256).optional(),
|
|
1274
|
-
componentSourceId: boundedString(128).optional(),
|
|
1275
|
-
sourceVersion: boundedString(128).optional(),
|
|
1276
|
-
componentStack: import_zod4.z.array(boundedString(256)).max(64),
|
|
1277
|
-
source: sourceRefSchema.optional()
|
|
1278
|
-
}),
|
|
1279
|
-
element: import_zod4.z.strictObject({
|
|
1280
|
-
tagName: boundedString(128),
|
|
1281
|
-
selector: boundedString(2048),
|
|
1282
|
-
sanitizedHtml: boundedString(8192),
|
|
1283
|
-
textPreview: boundedString(2048).optional(),
|
|
1284
|
-
role: boundedString(256).optional(),
|
|
1285
|
-
rect: import_zod4.z.strictObject({
|
|
1286
|
-
x: import_zod4.z.number(),
|
|
1287
|
-
y: import_zod4.z.number(),
|
|
1288
|
-
width: import_zod4.z.number().nonnegative(),
|
|
1289
|
-
height: import_zod4.z.number().nonnegative()
|
|
1290
|
-
})
|
|
1291
|
-
}),
|
|
1292
|
-
styles: import_zod4.z.strictObject({
|
|
1293
|
-
classNames: import_zod4.z.array(boundedString(512)).max(256),
|
|
1294
|
-
inlineStyle: boundedString(8192).optional(),
|
|
1295
|
-
matchedRules: import_zod4.z.array(matchedStyleRuleSchema).max(256),
|
|
1296
|
-
computed: import_zod4.z.record(boundedString(256), boundedString(2048)),
|
|
1297
|
-
warnings: import_zod4.z.array(boundedString(1024)).max(64)
|
|
1298
|
-
}),
|
|
1299
|
-
code: codeContextSchema.optional(),
|
|
1300
|
-
warnings: import_zod4.z.array(boundedString(1024)).max(64)
|
|
1848
|
+
var profileIdSchema3 = import_zod6.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
1849
|
+
var agentCapabilityRequestSchema = import_zod6.z.strictObject({
|
|
1850
|
+
providerProfileId: profileIdSchema3,
|
|
1851
|
+
modelProfileId: profileIdSchema3
|
|
1301
1852
|
});
|
|
1302
|
-
var
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
(characters, target) => characters + target.instruction.length,
|
|
1312
|
-
0
|
|
1313
|
-
);
|
|
1314
|
-
if (total > MAX_ANNOTATION_INSTRUCTION_CHARACTERS) {
|
|
1315
|
-
context.addIssue({
|
|
1316
|
-
code: "custom",
|
|
1317
|
-
message: "Combined target instructions exceed the annotation limit.",
|
|
1318
|
-
path: ["targets"]
|
|
1319
|
-
});
|
|
1320
|
-
}
|
|
1853
|
+
var agentWorkspaceHealthRequestSchema = import_zod6.z.strictObject({});
|
|
1854
|
+
var agentJobCreateRequestSchema = import_zod6.z.strictObject({
|
|
1855
|
+
annotation: spotAnnotationSchema,
|
|
1856
|
+
applyMode: import_zod6.z.enum(AGENT_APPLY_MODES).optional(),
|
|
1857
|
+
providerProfileId: profileIdSchema3,
|
|
1858
|
+
modelProfileId: profileIdSchema3,
|
|
1859
|
+
providerDataConsent: import_zod6.z.literal(true),
|
|
1860
|
+
trustedFastModeConsent: import_zod6.z.literal(true).optional(),
|
|
1861
|
+
workingTreeMode: import_zod6.z.enum(["require-clean", "include-local-changes"]).default("require-clean")
|
|
1321
1862
|
});
|
|
1322
|
-
var
|
|
1323
|
-
providerProfileId: profileIdSchema2,
|
|
1324
|
-
modelProfileId: profileIdSchema2
|
|
1325
|
-
});
|
|
1326
|
-
var agentWorkspaceHealthRequestSchema = import_zod4.z.strictObject({});
|
|
1327
|
-
var agentJobCreateRequestSchema = import_zod4.z.strictObject({
|
|
1328
|
-
annotation: spotAnnotationRequestSchema,
|
|
1329
|
-
applyMode: import_zod4.z.enum(AGENT_APPLY_MODES).optional(),
|
|
1330
|
-
providerProfileId: profileIdSchema2,
|
|
1331
|
-
modelProfileId: profileIdSchema2,
|
|
1332
|
-
providerDataConsent: import_zod4.z.literal(true),
|
|
1333
|
-
trustedFastModeConsent: import_zod4.z.literal(true).optional(),
|
|
1334
|
-
workingTreeMode: import_zod4.z.enum(["require-clean", "include-local-changes"]).default("require-clean")
|
|
1335
|
-
});
|
|
1336
|
-
var agentJobActionRequestSchema = import_zod4.z.strictObject({});
|
|
1863
|
+
var agentJobActionRequestSchema = import_zod6.z.strictObject({});
|
|
1337
1864
|
|
|
1338
1865
|
// src/protocol/external-handoff-constants.ts
|
|
1339
1866
|
var EXTERNAL_HANDOFF_SNAPSHOT_SCHEMA_VERSION = 1;
|
|
@@ -1343,7 +1870,11 @@ var EXTERNAL_HANDOFF_STATES = Object.freeze([
|
|
|
1343
1870
|
"expired",
|
|
1344
1871
|
"superseded"
|
|
1345
1872
|
]);
|
|
1346
|
-
var EXTERNAL_HANDOFF_FRAMEWORKS = Object.freeze([
|
|
1873
|
+
var EXTERNAL_HANDOFF_FRAMEWORKS = Object.freeze([
|
|
1874
|
+
"vite",
|
|
1875
|
+
"next",
|
|
1876
|
+
"astro"
|
|
1877
|
+
]);
|
|
1347
1878
|
var EXTERNAL_HANDOFF_ACTIVE_ADAPTER_KINDS = Object.freeze([
|
|
1348
1879
|
"claude-channel",
|
|
1349
1880
|
"codex-app-server"
|
|
@@ -1399,44 +1930,44 @@ var EXTERNAL_HANDOFF_LIMITS = Object.freeze({
|
|
|
1399
1930
|
});
|
|
1400
1931
|
|
|
1401
1932
|
// src/protocol/external-handoff.ts
|
|
1402
|
-
var opaqueIdSchema2 =
|
|
1403
|
-
var isoTimestampSchema2 =
|
|
1404
|
-
var externalHandoffReportableDispatchPhaseSchema =
|
|
1933
|
+
var opaqueIdSchema2 = import_zod7.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u);
|
|
1934
|
+
var isoTimestampSchema2 = import_zod7.z.iso.datetime();
|
|
1935
|
+
var externalHandoffReportableDispatchPhaseSchema = import_zod7.z.enum(
|
|
1405
1936
|
EXTERNAL_HANDOFF_REPORTABLE_DISPATCH_PHASES
|
|
1406
1937
|
);
|
|
1407
|
-
var externalHandoffPageSummarySchema =
|
|
1408
|
-
origin:
|
|
1409
|
-
pathname:
|
|
1938
|
+
var externalHandoffPageSummarySchema = import_zod7.z.strictObject({
|
|
1939
|
+
origin: import_zod7.z.string().min(1).max(2048),
|
|
1940
|
+
pathname: import_zod7.z.string().min(1).max(2048)
|
|
1410
1941
|
});
|
|
1411
|
-
var externalHandoffSummarySchema =
|
|
1942
|
+
var externalHandoffSummarySchema = import_zod7.z.strictObject({
|
|
1412
1943
|
sessionId: opaqueIdSchema2,
|
|
1413
|
-
framework:
|
|
1414
|
-
revision:
|
|
1944
|
+
framework: import_zod7.z.enum(EXTERNAL_HANDOFF_FRAMEWORKS),
|
|
1945
|
+
revision: import_zod7.z.number().int().positive(),
|
|
1415
1946
|
cursor: opaqueIdSchema2,
|
|
1416
|
-
targetCount:
|
|
1947
|
+
targetCount: import_zod7.z.number().int().positive(),
|
|
1417
1948
|
page: externalHandoffPageSummarySchema,
|
|
1418
1949
|
publishedAt: isoTimestampSchema2,
|
|
1419
1950
|
expiresAt: isoTimestampSchema2,
|
|
1420
|
-
state:
|
|
1421
|
-
pickupCount:
|
|
1951
|
+
state: import_zod7.z.enum(EXTERNAL_HANDOFF_STATES),
|
|
1952
|
+
pickupCount: import_zod7.z.number().int().nonnegative().max(EXTERNAL_HANDOFF_LIMITS.maximumConnectorReceipts),
|
|
1422
1953
|
pickedUpAt: isoTimestampSchema2.optional()
|
|
1423
1954
|
});
|
|
1424
|
-
var externalHandoffSnapshotSchema =
|
|
1425
|
-
schemaVersion:
|
|
1955
|
+
var externalHandoffSnapshotSchema = import_zod7.z.strictObject({
|
|
1956
|
+
schemaVersion: import_zod7.z.literal(EXTERNAL_HANDOFF_SNAPSHOT_SCHEMA_VERSION),
|
|
1426
1957
|
cursor: opaqueIdSchema2,
|
|
1427
|
-
session:
|
|
1958
|
+
session: import_zod7.z.strictObject({
|
|
1428
1959
|
id: opaqueIdSchema2,
|
|
1429
|
-
framework:
|
|
1960
|
+
framework: import_zod7.z.enum(EXTERNAL_HANDOFF_FRAMEWORKS)
|
|
1430
1961
|
}),
|
|
1431
|
-
revision:
|
|
1962
|
+
revision: import_zod7.z.number().int().positive(),
|
|
1432
1963
|
publishedAt: isoTimestampSchema2,
|
|
1433
1964
|
expiresAt: isoTimestampSchema2,
|
|
1434
|
-
annotation:
|
|
1965
|
+
annotation: spotAnnotationSchema
|
|
1435
1966
|
});
|
|
1436
|
-
var activeAdapterSummarySchema =
|
|
1437
|
-
kind:
|
|
1438
|
-
state:
|
|
1439
|
-
canDispatch:
|
|
1967
|
+
var activeAdapterSummarySchema = import_zod7.z.strictObject({
|
|
1968
|
+
kind: import_zod7.z.enum(EXTERNAL_HANDOFF_ACTIVE_ADAPTER_KINDS),
|
|
1969
|
+
state: import_zod7.z.enum(EXTERNAL_HANDOFF_ACTIVE_ADAPTER_STATES),
|
|
1970
|
+
canDispatch: import_zod7.z.boolean(),
|
|
1440
1971
|
connectedAt: isoTimestampSchema2,
|
|
1441
1972
|
updatedAt: isoTimestampSchema2
|
|
1442
1973
|
}).superRefine((value, context) => {
|
|
@@ -1448,83 +1979,259 @@ var activeAdapterSummarySchema = import_zod5.z.strictObject({
|
|
|
1448
1979
|
});
|
|
1449
1980
|
}
|
|
1450
1981
|
});
|
|
1451
|
-
var dispatchSummarySchema =
|
|
1452
|
-
adapterKind:
|
|
1453
|
-
revision:
|
|
1454
|
-
phase:
|
|
1982
|
+
var dispatchSummarySchema = import_zod7.z.strictObject({
|
|
1983
|
+
adapterKind: import_zod7.z.enum(EXTERNAL_HANDOFF_ACTIVE_ADAPTER_KINDS),
|
|
1984
|
+
revision: import_zod7.z.number().int().positive(),
|
|
1985
|
+
phase: import_zod7.z.enum(EXTERNAL_HANDOFF_DISPATCH_PHASES),
|
|
1455
1986
|
updatedAt: isoTimestampSchema2
|
|
1456
1987
|
});
|
|
1457
|
-
var externalHandoffCapabilityRequestSchema =
|
|
1458
|
-
var externalHandoffPublishRequestSchema =
|
|
1988
|
+
var externalHandoffCapabilityRequestSchema = import_zod7.z.strictObject({});
|
|
1989
|
+
var externalHandoffPublishRequestSchema = import_zod7.z.strictObject({
|
|
1459
1990
|
requestId: opaqueIdSchema2,
|
|
1460
|
-
annotation:
|
|
1991
|
+
annotation: spotAnnotationSchema
|
|
1461
1992
|
});
|
|
1462
|
-
var externalHandoffStatusRequestSchema =
|
|
1993
|
+
var externalHandoffStatusRequestSchema = import_zod7.z.strictObject({
|
|
1463
1994
|
cursor: opaqueIdSchema2.optional()
|
|
1464
1995
|
});
|
|
1465
|
-
var externalHandoffResolveDeliveryRequestSchema =
|
|
1996
|
+
var externalHandoffResolveDeliveryRequestSchema = import_zod7.z.strictObject({
|
|
1466
1997
|
cursor: opaqueIdSchema2,
|
|
1467
|
-
confirmation:
|
|
1468
|
-
});
|
|
1469
|
-
var externalHandoffCapabilitySchema =
|
|
1470
|
-
enabled:
|
|
1471
|
-
brokerReady:
|
|
1472
|
-
activeWaitCount:
|
|
1473
|
-
snapshotSchemaVersion:
|
|
1474
|
-
brokerProtocolVersion:
|
|
1998
|
+
confirmation: import_zod7.z.literal("workspace-reviewed")
|
|
1999
|
+
});
|
|
2000
|
+
var externalHandoffCapabilitySchema = import_zod7.z.strictObject({
|
|
2001
|
+
enabled: import_zod7.z.literal(true),
|
|
2002
|
+
brokerReady: import_zod7.z.boolean(),
|
|
2003
|
+
activeWaitCount: import_zod7.z.number().int().nonnegative().max(EXTERNAL_HANDOFF_LIMITS.maximumWaiters),
|
|
2004
|
+
snapshotSchemaVersion: import_zod7.z.literal(EXTERNAL_HANDOFF_SNAPSHOT_SCHEMA_VERSION),
|
|
2005
|
+
brokerProtocolVersion: import_zod7.z.literal(EXTERNAL_HANDOFF_BROKER_PROTOCOL_VERSION),
|
|
1475
2006
|
activeAdapter: activeAdapterSummarySchema.nullable(),
|
|
1476
2007
|
dispatch: dispatchSummarySchema.nullable()
|
|
1477
2008
|
});
|
|
1478
|
-
var externalHandoffPublishDeliverySchema =
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
mode:
|
|
2009
|
+
var externalHandoffPublishDeliverySchema = import_zod7.z.discriminatedUnion("mode", [
|
|
2010
|
+
import_zod7.z.strictObject({ mode: import_zod7.z.literal("inbox") }),
|
|
2011
|
+
import_zod7.z.strictObject({
|
|
2012
|
+
mode: import_zod7.z.literal("active"),
|
|
1482
2013
|
adapter: activeAdapterSummarySchema,
|
|
1483
2014
|
dispatch: dispatchSummarySchema
|
|
1484
2015
|
})
|
|
1485
2016
|
]);
|
|
1486
|
-
var externalHandoffPublishResultSchema =
|
|
2017
|
+
var externalHandoffPublishResultSchema = import_zod7.z.strictObject({
|
|
1487
2018
|
handoff: externalHandoffSummarySchema,
|
|
1488
2019
|
delivery: externalHandoffPublishDeliverySchema,
|
|
1489
|
-
replayed:
|
|
2020
|
+
replayed: import_zod7.z.boolean()
|
|
1490
2021
|
});
|
|
1491
|
-
var externalHandoffStatusResultSchema =
|
|
2022
|
+
var externalHandoffStatusResultSchema = import_zod7.z.strictObject({
|
|
1492
2023
|
handoff: externalHandoffSummarySchema,
|
|
1493
2024
|
activeAdapter: activeAdapterSummarySchema.nullable(),
|
|
1494
2025
|
dispatch: dispatchSummarySchema.nullable()
|
|
1495
2026
|
});
|
|
1496
2027
|
|
|
2028
|
+
// src/protocol/contextual-ask.ts
|
|
2029
|
+
var import_zod8 = require("zod");
|
|
2030
|
+
var limits2 = CONTEXTUAL_ASK_LIMITS;
|
|
2031
|
+
var timestampSchema = import_zod8.z.iso.datetime();
|
|
2032
|
+
var contextualAskCapabilityRequestSchema = import_zod8.z.strictObject({});
|
|
2033
|
+
var askJobCreateRequestSchema = import_zod8.z.strictObject({
|
|
2034
|
+
schemaVersion: import_zod8.z.literal(CONTEXTUAL_ASK_SCHEMA_VERSION),
|
|
2035
|
+
requestId: contextualAskOpaqueIdSchema,
|
|
2036
|
+
envelope: spotAskTaskEnvelopeSchema,
|
|
2037
|
+
executorId: contextualAskOpaqueIdSchema,
|
|
2038
|
+
model: contextualAskBoundedText(limits2.maximumLabelCharacters).optional(),
|
|
2039
|
+
providerDataConsent: import_zod8.z.literal(true)
|
|
2040
|
+
});
|
|
2041
|
+
var askJobActionRequestSchema = import_zod8.z.strictObject({});
|
|
2042
|
+
var askJobEventsRequestSchema = import_zod8.z.strictObject({
|
|
2043
|
+
afterSequence: import_zod8.z.number().int().nonnegative().optional()
|
|
2044
|
+
});
|
|
2045
|
+
var askJobExecutorSnapshotSchema = import_zod8.z.strictObject({
|
|
2046
|
+
executorId: contextualAskOpaqueIdSchema,
|
|
2047
|
+
kind: import_zod8.z.enum(CONTEXTUAL_ASK_EXECUTOR_KINDS),
|
|
2048
|
+
label: contextualAskBoundedText(limits2.maximumLabelCharacters),
|
|
2049
|
+
modelLabel: contextualAskBoundedText(limits2.maximumLabelCharacters)
|
|
2050
|
+
});
|
|
2051
|
+
var askJobSnapshotSchema = import_zod8.z.strictObject({
|
|
2052
|
+
schemaVersion: import_zod8.z.literal(CONTEXTUAL_ASK_SCHEMA_VERSION),
|
|
2053
|
+
jobId: contextualAskOpaqueIdSchema,
|
|
2054
|
+
selectionId: contextualAskOpaqueIdSchema,
|
|
2055
|
+
status: import_zod8.z.enum(ASK_JOB_STATUSES),
|
|
2056
|
+
executor: askJobExecutorSnapshotSchema,
|
|
2057
|
+
phaseMessage: contextualAskBoundedText(
|
|
2058
|
+
limits2.maximumPhaseMessageCharacters
|
|
2059
|
+
).optional(),
|
|
2060
|
+
createdAt: timestampSchema,
|
|
2061
|
+
updatedAt: timestampSchema,
|
|
2062
|
+
canCancel: import_zod8.z.boolean(),
|
|
2063
|
+
errorCode: import_zod8.z.enum(CONTEXTUAL_ASK_ERROR_CODES).optional()
|
|
2064
|
+
}).superRefine((snapshot, context) => {
|
|
2065
|
+
if (Date.parse(snapshot.updatedAt) < Date.parse(snapshot.createdAt)) {
|
|
2066
|
+
context.addIssue({
|
|
2067
|
+
code: "custom",
|
|
2068
|
+
message: "Job updatedAt must not precede createdAt.",
|
|
2069
|
+
path: ["updatedAt"]
|
|
2070
|
+
});
|
|
2071
|
+
}
|
|
2072
|
+
const cancellable = ["queued", "authorizing", "running"].includes(snapshot.status);
|
|
2073
|
+
if (snapshot.canCancel !== cancellable) {
|
|
2074
|
+
context.addIssue({
|
|
2075
|
+
code: "custom",
|
|
2076
|
+
message: "Job canCancel does not match its status.",
|
|
2077
|
+
path: ["canCancel"]
|
|
2078
|
+
});
|
|
2079
|
+
}
|
|
2080
|
+
if (snapshot.status === "failed" && snapshot.errorCode === void 0 || snapshot.status === "failed" && snapshot.errorCode === "ASK_CANCELLED" || snapshot.status === "cancelled" && snapshot.errorCode !== "ASK_CANCELLED" || snapshot.status !== "failed" && snapshot.status !== "cancelled" && snapshot.errorCode !== void 0) {
|
|
2081
|
+
context.addIssue({
|
|
2082
|
+
code: "custom",
|
|
2083
|
+
message: "Job errorCode does not match its terminal status.",
|
|
2084
|
+
path: ["errorCode"]
|
|
2085
|
+
});
|
|
2086
|
+
}
|
|
2087
|
+
});
|
|
2088
|
+
var askJobResultResponseSchema = import_zod8.z.strictObject({
|
|
2089
|
+
snapshot: askJobSnapshotSchema,
|
|
2090
|
+
result: askAnswerResultSchema.optional()
|
|
2091
|
+
}).superRefine((response, context) => {
|
|
2092
|
+
const answered = response.snapshot.status === "answered";
|
|
2093
|
+
if (answered !== (response.result !== void 0)) {
|
|
2094
|
+
context.addIssue({
|
|
2095
|
+
code: "custom",
|
|
2096
|
+
message: "Only an answered job must contain an answer result.",
|
|
2097
|
+
path: ["result"]
|
|
2098
|
+
});
|
|
2099
|
+
return;
|
|
2100
|
+
}
|
|
2101
|
+
if (response.result !== void 0 && (response.result.jobId !== response.snapshot.jobId || response.result.selectionId !== response.snapshot.selectionId || response.result.executor.executorId !== response.snapshot.executor.executorId)) {
|
|
2102
|
+
context.addIssue({
|
|
2103
|
+
code: "custom",
|
|
2104
|
+
message: "Answer result identity does not match the job snapshot.",
|
|
2105
|
+
path: ["result"]
|
|
2106
|
+
});
|
|
2107
|
+
}
|
|
2108
|
+
});
|
|
2109
|
+
var askJobEventBaseShape = {
|
|
2110
|
+
schemaVersion: import_zod8.z.literal(CONTEXTUAL_ASK_SCHEMA_VERSION),
|
|
2111
|
+
sequence: import_zod8.z.number().int().positive(),
|
|
2112
|
+
jobId: contextualAskOpaqueIdSchema,
|
|
2113
|
+
status: import_zod8.z.enum(ASK_JOB_STATUSES),
|
|
2114
|
+
timestamp: timestampSchema
|
|
2115
|
+
};
|
|
2116
|
+
var askJobSnapshotEventSchema = import_zod8.z.strictObject({
|
|
2117
|
+
...askJobEventBaseShape,
|
|
2118
|
+
type: import_zod8.z.literal("snapshot"),
|
|
2119
|
+
snapshot: askJobSnapshotSchema
|
|
2120
|
+
});
|
|
2121
|
+
var askJobPhaseEventSchema = import_zod8.z.strictObject({
|
|
2122
|
+
...askJobEventBaseShape,
|
|
2123
|
+
type: import_zod8.z.literal("phase"),
|
|
2124
|
+
message: contextualAskBoundedText(limits2.maximumPhaseMessageCharacters)
|
|
2125
|
+
});
|
|
2126
|
+
var askReadSourceActivitySchema = import_zod8.z.strictObject({
|
|
2127
|
+
kind: import_zod8.z.literal("source"),
|
|
2128
|
+
sourceId: contextualAskOpaqueIdSchema,
|
|
2129
|
+
relativePath: contextualAskRelativePathSchema
|
|
2130
|
+
});
|
|
2131
|
+
var askReadFileCountActivitySchema = import_zod8.z.strictObject({
|
|
2132
|
+
kind: import_zod8.z.literal("file-count"),
|
|
2133
|
+
bucket: import_zod8.z.enum(ASK_FILE_COUNT_BUCKETS)
|
|
2134
|
+
});
|
|
2135
|
+
var askJobReadActivityEventSchema = import_zod8.z.strictObject({
|
|
2136
|
+
...askJobEventBaseShape,
|
|
2137
|
+
type: import_zod8.z.literal("read-activity"),
|
|
2138
|
+
activity: import_zod8.z.discriminatedUnion("kind", [
|
|
2139
|
+
askReadSourceActivitySchema,
|
|
2140
|
+
askReadFileCountActivitySchema
|
|
2141
|
+
]),
|
|
2142
|
+
state: import_zod8.z.enum(ASK_READ_ACTIVITY_STATES)
|
|
2143
|
+
});
|
|
2144
|
+
var askJobAnswerReadyEventSchema = import_zod8.z.strictObject({
|
|
2145
|
+
...askJobEventBaseShape,
|
|
2146
|
+
type: import_zod8.z.literal("answer-ready")
|
|
2147
|
+
});
|
|
2148
|
+
var askJobErrorEventSchema = import_zod8.z.strictObject({
|
|
2149
|
+
...askJobEventBaseShape,
|
|
2150
|
+
type: import_zod8.z.literal("error"),
|
|
2151
|
+
errorCode: import_zod8.z.enum(CONTEXTUAL_ASK_ERROR_CODES)
|
|
2152
|
+
});
|
|
2153
|
+
var askJobEventSchema = import_zod8.z.discriminatedUnion("type", [
|
|
2154
|
+
askJobSnapshotEventSchema,
|
|
2155
|
+
askJobPhaseEventSchema,
|
|
2156
|
+
askJobReadActivityEventSchema,
|
|
2157
|
+
askJobAnswerReadyEventSchema,
|
|
2158
|
+
askJobErrorEventSchema
|
|
2159
|
+
]).superRefine((event, context) => {
|
|
2160
|
+
if (event.type === "snapshot" && (event.snapshot.jobId !== event.jobId || event.snapshot.status !== event.status)) {
|
|
2161
|
+
context.addIssue({
|
|
2162
|
+
code: "custom",
|
|
2163
|
+
message: "Snapshot event identity does not match its envelope.",
|
|
2164
|
+
path: ["snapshot"]
|
|
2165
|
+
});
|
|
2166
|
+
}
|
|
2167
|
+
if (event.type === "read-activity" && event.status !== "running") {
|
|
2168
|
+
context.addIssue({
|
|
2169
|
+
code: "custom",
|
|
2170
|
+
message: "Read activity is only valid while a job is running.",
|
|
2171
|
+
path: ["status"]
|
|
2172
|
+
});
|
|
2173
|
+
}
|
|
2174
|
+
if (event.type === "phase" && ["answered", "cancelled", "failed"].includes(event.status)) {
|
|
2175
|
+
context.addIssue({
|
|
2176
|
+
code: "custom",
|
|
2177
|
+
message: "Phase events cannot report a terminal state.",
|
|
2178
|
+
path: ["status"]
|
|
2179
|
+
});
|
|
2180
|
+
}
|
|
2181
|
+
if (event.type === "answer-ready" && event.status !== "answered") {
|
|
2182
|
+
context.addIssue({
|
|
2183
|
+
code: "custom",
|
|
2184
|
+
message: "Answer-ready must report the answered state.",
|
|
2185
|
+
path: ["status"]
|
|
2186
|
+
});
|
|
2187
|
+
}
|
|
2188
|
+
if (event.type === "error" && !["failed", "cancelled"].includes(event.status)) {
|
|
2189
|
+
context.addIssue({
|
|
2190
|
+
code: "custom",
|
|
2191
|
+
message: "Error events must report a terminal error state.",
|
|
2192
|
+
path: ["status"]
|
|
2193
|
+
});
|
|
2194
|
+
}
|
|
2195
|
+
if (event.type === "error" && (event.status === "cancelled" && event.errorCode !== "ASK_CANCELLED" || event.status === "failed" && event.errorCode === "ASK_CANCELLED")) {
|
|
2196
|
+
context.addIssue({
|
|
2197
|
+
code: "custom",
|
|
2198
|
+
message: "Error event code does not match its status.",
|
|
2199
|
+
path: ["errorCode"]
|
|
2200
|
+
});
|
|
2201
|
+
}
|
|
2202
|
+
});
|
|
2203
|
+
|
|
1497
2204
|
// src/protocol/agent-schemas.ts
|
|
1498
|
-
var
|
|
1499
|
-
var
|
|
1500
|
-
var boundedString2 = (maximum) =>
|
|
1501
|
-
var errorCodeSchema =
|
|
1502
|
-
var agentCapabilitySnapshotSchema =
|
|
1503
|
-
providerProfileId:
|
|
2205
|
+
var import_zod9 = require("zod");
|
|
2206
|
+
var profileIdSchema4 = import_zod9.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
2207
|
+
var boundedString2 = (maximum) => import_zod9.z.string().max(maximum);
|
|
2208
|
+
var errorCodeSchema = import_zod9.z.enum(ERROR_CODES);
|
|
2209
|
+
var agentCapabilitySnapshotSchema = import_zod9.z.strictObject({
|
|
2210
|
+
providerProfileId: profileIdSchema4,
|
|
1504
2211
|
providerLabel: boundedString2(100),
|
|
1505
|
-
modelProfileId:
|
|
2212
|
+
modelProfileId: profileIdSchema4,
|
|
1506
2213
|
modelLabel: boundedString2(100),
|
|
1507
|
-
protocol:
|
|
1508
|
-
state:
|
|
1509
|
-
authenticated:
|
|
1510
|
-
modelAvailable:
|
|
1511
|
-
toolCalling:
|
|
1512
|
-
toolResultContinuation:
|
|
1513
|
-
streaming:
|
|
1514
|
-
checkedAt:
|
|
2214
|
+
protocol: import_zod9.z.enum(["responses", "chat-completions"]),
|
|
2215
|
+
state: import_zod9.z.enum(AGENT_CAPABILITY_STATES),
|
|
2216
|
+
authenticated: import_zod9.z.boolean(),
|
|
2217
|
+
modelAvailable: import_zod9.z.boolean(),
|
|
2218
|
+
toolCalling: import_zod9.z.boolean(),
|
|
2219
|
+
toolResultContinuation: import_zod9.z.boolean(),
|
|
2220
|
+
streaming: import_zod9.z.boolean(),
|
|
2221
|
+
checkedAt: import_zod9.z.iso.datetime().optional(),
|
|
1515
2222
|
errorCode: errorCodeSchema.optional()
|
|
1516
2223
|
});
|
|
1517
|
-
var agentWorkspaceHealthSnapshotSchema =
|
|
1518
|
-
state:
|
|
1519
|
-
checkedAt:
|
|
1520
|
-
changes:
|
|
1521
|
-
staged:
|
|
1522
|
-
unstaged:
|
|
1523
|
-
untracked:
|
|
1524
|
-
conflicted:
|
|
1525
|
-
total:
|
|
2224
|
+
var agentWorkspaceHealthSnapshotSchema = import_zod9.z.strictObject({
|
|
2225
|
+
state: import_zod9.z.enum(AGENT_WORKSPACE_STATES),
|
|
2226
|
+
checkedAt: import_zod9.z.iso.datetime(),
|
|
2227
|
+
changes: import_zod9.z.strictObject({
|
|
2228
|
+
staged: import_zod9.z.number().int().nonnegative(),
|
|
2229
|
+
unstaged: import_zod9.z.number().int().nonnegative(),
|
|
2230
|
+
untracked: import_zod9.z.number().int().nonnegative(),
|
|
2231
|
+
conflicted: import_zod9.z.number().int().nonnegative(),
|
|
2232
|
+
total: import_zod9.z.number().int().nonnegative()
|
|
1526
2233
|
}),
|
|
1527
|
-
canIncludeLocalChanges:
|
|
2234
|
+
canIncludeLocalChanges: import_zod9.z.boolean(),
|
|
1528
2235
|
errorCode: errorCodeSchema.optional()
|
|
1529
2236
|
}).refine(
|
|
1530
2237
|
({ state, changes, canIncludeLocalChanges, errorCode }) => {
|
|
@@ -1542,42 +2249,42 @@ var agentWorkspaceHealthSnapshotSchema = import_zod6.z.strictObject({
|
|
|
1542
2249
|
},
|
|
1543
2250
|
{ message: "Agent workspace health fields are inconsistent." }
|
|
1544
2251
|
);
|
|
1545
|
-
var agentChangedFileSchema =
|
|
2252
|
+
var agentChangedFileSchema = import_zod9.z.strictObject({
|
|
1546
2253
|
relativePath: boundedString2(1024),
|
|
1547
|
-
kind:
|
|
1548
|
-
additions:
|
|
1549
|
-
deletions:
|
|
2254
|
+
kind: import_zod9.z.enum(AGENT_FILE_CHANGE_KINDS),
|
|
2255
|
+
additions: import_zod9.z.number().int().nonnegative(),
|
|
2256
|
+
deletions: import_zod9.z.number().int().nonnegative()
|
|
1550
2257
|
});
|
|
1551
|
-
var agentCheckResultSchema =
|
|
1552
|
-
checkId:
|
|
2258
|
+
var agentCheckResultSchema = import_zod9.z.strictObject({
|
|
2259
|
+
checkId: profileIdSchema4,
|
|
1553
2260
|
label: boundedString2(100),
|
|
1554
|
-
status:
|
|
1555
|
-
durationMs:
|
|
2261
|
+
status: import_zod9.z.enum(AGENT_CHECK_STATUSES),
|
|
2262
|
+
durationMs: import_zod9.z.number().int().nonnegative(),
|
|
1556
2263
|
output: boundedString2(8e4)
|
|
1557
2264
|
});
|
|
1558
|
-
var agentJobSnapshotSchema =
|
|
1559
|
-
jobId:
|
|
1560
|
-
status:
|
|
1561
|
-
providerProfileId:
|
|
2265
|
+
var agentJobSnapshotSchema = import_zod9.z.strictObject({
|
|
2266
|
+
jobId: import_zod9.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
|
|
2267
|
+
status: import_zod9.z.enum(AGENT_JOB_STATUSES),
|
|
2268
|
+
providerProfileId: profileIdSchema4,
|
|
1562
2269
|
providerLabel: boundedString2(100),
|
|
1563
|
-
modelProfileId:
|
|
2270
|
+
modelProfileId: profileIdSchema4,
|
|
1564
2271
|
modelLabel: boundedString2(100),
|
|
1565
2272
|
phaseMessage: boundedString2(1024),
|
|
1566
|
-
createdAt:
|
|
1567
|
-
updatedAt:
|
|
1568
|
-
canCancel:
|
|
1569
|
-
canApply:
|
|
1570
|
-
canRevert:
|
|
2273
|
+
createdAt: import_zod9.z.iso.datetime(),
|
|
2274
|
+
updatedAt: import_zod9.z.iso.datetime(),
|
|
2275
|
+
canCancel: import_zod9.z.boolean(),
|
|
2276
|
+
canApply: import_zod9.z.boolean(),
|
|
2277
|
+
canRevert: import_zod9.z.boolean(),
|
|
1571
2278
|
errorCode: errorCodeSchema.optional()
|
|
1572
2279
|
});
|
|
1573
|
-
var agentJobResultSchema =
|
|
1574
|
-
jobId:
|
|
2280
|
+
var agentJobResultSchema = import_zod9.z.strictObject({
|
|
2281
|
+
jobId: import_zod9.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
|
|
1575
2282
|
summary: boundedString2(8e4),
|
|
1576
2283
|
diff: boundedString2(1e6),
|
|
1577
|
-
files:
|
|
1578
|
-
checks:
|
|
2284
|
+
files: import_zod9.z.array(agentChangedFileSchema).max(100),
|
|
2285
|
+
checks: import_zod9.z.array(agentCheckResultSchema).max(100)
|
|
1579
2286
|
});
|
|
1580
|
-
var agentJobResultResponseSchema =
|
|
2287
|
+
var agentJobResultResponseSchema = import_zod9.z.strictObject({
|
|
1581
2288
|
snapshot: agentJobSnapshotSchema,
|
|
1582
2289
|
result: agentJobResultSchema.optional()
|
|
1583
2290
|
}).superRefine((value, context) => {
|
|
@@ -1589,44 +2296,44 @@ var agentJobResultResponseSchema = import_zod6.z.strictObject({
|
|
|
1589
2296
|
});
|
|
1590
2297
|
}
|
|
1591
2298
|
});
|
|
1592
|
-
var agentJobEventBaseSchema =
|
|
1593
|
-
schemaVersion:
|
|
1594
|
-
sequence:
|
|
1595
|
-
jobId:
|
|
1596
|
-
status:
|
|
1597
|
-
timestamp:
|
|
2299
|
+
var agentJobEventBaseSchema = import_zod9.z.strictObject({
|
|
2300
|
+
schemaVersion: import_zod9.z.literal(2),
|
|
2301
|
+
sequence: import_zod9.z.number().int().positive(),
|
|
2302
|
+
jobId: import_zod9.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
|
|
2303
|
+
status: import_zod9.z.enum(AGENT_JOB_STATUSES),
|
|
2304
|
+
timestamp: import_zod9.z.iso.datetime()
|
|
1598
2305
|
});
|
|
1599
|
-
var agentJobEventSchema =
|
|
2306
|
+
var agentJobEventSchema = import_zod9.z.discriminatedUnion("type", [
|
|
1600
2307
|
agentJobEventBaseSchema.extend({
|
|
1601
|
-
type:
|
|
1602
|
-
data:
|
|
2308
|
+
type: import_zod9.z.literal("snapshot"),
|
|
2309
|
+
data: import_zod9.z.strictObject({ snapshot: agentJobSnapshotSchema })
|
|
1603
2310
|
}),
|
|
1604
2311
|
agentJobEventBaseSchema.extend({
|
|
1605
|
-
type:
|
|
1606
|
-
data:
|
|
2312
|
+
type: import_zod9.z.literal("phase"),
|
|
2313
|
+
data: import_zod9.z.strictObject({ message: boundedString2(1024) })
|
|
1607
2314
|
}),
|
|
1608
2315
|
agentJobEventBaseSchema.extend({
|
|
1609
|
-
type:
|
|
1610
|
-
data:
|
|
1611
|
-
turn:
|
|
2316
|
+
type: import_zod9.z.literal("tool"),
|
|
2317
|
+
data: import_zod9.z.strictObject({
|
|
2318
|
+
turn: import_zod9.z.number().int().positive(),
|
|
1612
2319
|
toolCallId: boundedString2(256),
|
|
1613
2320
|
toolName: boundedString2(100),
|
|
1614
|
-
state:
|
|
2321
|
+
state: import_zod9.z.enum(["started", "succeeded", "failed"]),
|
|
1615
2322
|
relativePath: boundedString2(1024).optional(),
|
|
1616
2323
|
checkLabel: boundedString2(100).optional()
|
|
1617
2324
|
})
|
|
1618
2325
|
}),
|
|
1619
2326
|
agentJobEventBaseSchema.extend({
|
|
1620
|
-
type:
|
|
1621
|
-
data:
|
|
2327
|
+
type: import_zod9.z.literal("check"),
|
|
2328
|
+
data: import_zod9.z.strictObject({ result: agentCheckResultSchema })
|
|
1622
2329
|
}),
|
|
1623
2330
|
agentJobEventBaseSchema.extend({
|
|
1624
|
-
type:
|
|
1625
|
-
data:
|
|
2331
|
+
type: import_zod9.z.literal("result-ready"),
|
|
2332
|
+
data: import_zod9.z.strictObject({ hasResult: import_zod9.z.literal(true) })
|
|
1626
2333
|
}),
|
|
1627
2334
|
agentJobEventBaseSchema.extend({
|
|
1628
|
-
type:
|
|
1629
|
-
data:
|
|
2335
|
+
type: import_zod9.z.literal("error"),
|
|
2336
|
+
data: import_zod9.z.strictObject({
|
|
1630
2337
|
code: errorCodeSchema,
|
|
1631
2338
|
message: boundedString2(1024)
|
|
1632
2339
|
})
|
|
@@ -1662,6 +2369,18 @@ var SPOTPATCH_REPOSITORY_URL = "https://github.com/huanglvjing/spotpatch";
|
|
|
1662
2369
|
AGENT_JOB_STATUSES,
|
|
1663
2370
|
AGENT_WORKSPACE_SNAPSHOT_LIMITS,
|
|
1664
2371
|
AGENT_WORKSPACE_STATES,
|
|
2372
|
+
ASK_ANSWER_WARNING_CODES,
|
|
2373
|
+
ASK_EXECUTOR_ANSWER_WARNING_CODES,
|
|
2374
|
+
ASK_FILE_COUNT_BUCKETS,
|
|
2375
|
+
ASK_JOB_STATUSES,
|
|
2376
|
+
ASK_READ_ACTIVITY_STATES,
|
|
2377
|
+
ASK_SOURCE_CONFIDENCES,
|
|
2378
|
+
CONTEXTUAL_ASK_ERROR_CODES,
|
|
2379
|
+
CONTEXTUAL_ASK_EXECUTOR_KINDS,
|
|
2380
|
+
CONTEXTUAL_ASK_EXECUTOR_STATES,
|
|
2381
|
+
CONTEXTUAL_ASK_LIMITS,
|
|
2382
|
+
CONTEXTUAL_ASK_PERMISSION_PROFILE,
|
|
2383
|
+
CONTEXTUAL_ASK_SCHEMA_VERSION,
|
|
1665
2384
|
DATA_FLOW_ASSOCIATION_KINDS,
|
|
1666
2385
|
DATA_FLOW_DIAGNOSTIC_CODES,
|
|
1667
2386
|
DATA_FLOW_EXECUTION_STATES,
|
|
@@ -1732,7 +2451,26 @@ var SPOTPATCH_REPOSITORY_URL = "https://github.com/huanglvjing/spotpatch";
|
|
|
1732
2451
|
agentJobSnapshotSchema,
|
|
1733
2452
|
agentWorkspaceHealthRequestSchema,
|
|
1734
2453
|
agentWorkspaceHealthSnapshotSchema,
|
|
2454
|
+
askAnswerBlockSchema,
|
|
2455
|
+
askAnswerDraftBlockSchema,
|
|
2456
|
+
askAnswerDraftSchema,
|
|
2457
|
+
askAnswerResultSchema,
|
|
2458
|
+
askAnswerWarningSchema,
|
|
2459
|
+
askDraftCitationSchema,
|
|
2460
|
+
askDraftOriginSchema,
|
|
2461
|
+
askJobActionRequestSchema,
|
|
2462
|
+
askJobCreateRequestSchema,
|
|
2463
|
+
askJobEventSchema,
|
|
2464
|
+
askJobEventsRequestSchema,
|
|
2465
|
+
askJobResultResponseSchema,
|
|
2466
|
+
askJobSnapshotSchema,
|
|
2467
|
+
askSourceReferenceSchema,
|
|
1735
2468
|
componentDataFlowReportSchema,
|
|
2469
|
+
contextualAskCapabilityRequestSchema,
|
|
2470
|
+
contextualAskCapabilitySchema,
|
|
2471
|
+
contextualAskExecutorCapabilitySchema,
|
|
2472
|
+
contextualAskExecutorPreferenceSchema,
|
|
2473
|
+
contextualAskOptionsSchema,
|
|
1736
2474
|
dataDependencySchema,
|
|
1737
2475
|
dataFlowComponentReportRequestSchema,
|
|
1738
2476
|
dataFlowPageReportRequestSchema,
|
|
@@ -1760,6 +2498,7 @@ var SPOTPATCH_REPOSITORY_URL = "https://github.com/huanglvjing/spotpatch";
|
|
|
1760
2498
|
externalHandoffSummarySchema,
|
|
1761
2499
|
formatSourceMarker,
|
|
1762
2500
|
getAgentJobEndpoint,
|
|
2501
|
+
getAskJobEndpoint,
|
|
1763
2502
|
isErrorCode,
|
|
1764
2503
|
isSensitiveName,
|
|
1765
2504
|
limitDataFlowReportCollections,
|
|
@@ -1778,6 +2517,11 @@ var SPOTPATCH_REPOSITORY_URL = "https://github.com/huanglvjing/spotpatch";
|
|
|
1778
2517
|
sanitizeUrl,
|
|
1779
2518
|
sourceContextRequestSchema,
|
|
1780
2519
|
spotAnnotationRequestSchema,
|
|
1781
|
-
|
|
2520
|
+
spotAskTaskEnvelopeSchema,
|
|
2521
|
+
spotChangeTaskEnvelopeSchema,
|
|
2522
|
+
spotSelectionContextSchema,
|
|
2523
|
+
spotSelectionTargetSchema,
|
|
2524
|
+
spotTargetContextRequestSchema,
|
|
2525
|
+
spotTaskEnvelopeSchema
|
|
1782
2526
|
});
|
|
1783
2527
|
//# sourceMappingURL=index.cjs.map
|