@defrex/autobuild 1.15.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/SPEC.md +110 -10
- package/docs/answering-blocked-builds.md +34 -1
- package/docs/architecture.md +41 -7
- package/docs/configuration.md +41 -7
- package/docs/dispatcher-hosting.md +3 -0
- package/docs/operator-api.md +15 -5
- package/docs/plugin-authoring.md +1 -0
- package/docs/remote-store-protocol.md +13 -3
- package/docs/remote-ticket-protocol.md +3 -1
- package/docs/restacking.md +41 -1
- package/docs/setup.md +15 -6
- package/docs/troubleshooting.md +51 -3
- package/docs/workspaces.md +4 -1
- package/package.json +3 -3
- package/packages/core/src/cli/accounts.ts +3 -0
- package/packages/core/src/cli/binary-direct.ts +14 -1
- package/packages/core/src/cli/binary.ts +10 -7
- package/packages/core/src/cli/dispatch.ts +610 -356
- package/packages/core/src/cli/secrets.ts +2 -0
- package/packages/core/src/config/schema.ts +15 -2
- package/packages/core/src/events/payloads.ts +8 -5
- package/packages/core/src/events/repository.ts +12 -6
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/e28c68e63cbd265f.json +108 -0
- package/packages/core/src/kernel/engine.ts +118 -0
- package/packages/core/src/kernel/reconcile-restack.ts +72 -9
- package/packages/core/src/kernel/reducer-revisions.ts +1 -0
- package/packages/core/src/kernel/tracked-dirt.ts +173 -0
- package/packages/core/src/ontology.ts +1 -0
- package/packages/core/src/operator/index.ts +10 -0
- package/packages/core/src/operator/merged-builds.ts +51 -0
- package/packages/core/src/operator/registry.ts +190 -101
- package/packages/core/src/operator/repo-argument.ts +43 -0
- package/packages/core/src/ports/tickets/grants.ts +2 -0
- package/packages/core/src/ports/tickets/remote.ts +2 -0
- package/packages/core/src/ports/types.ts +25 -4
- package/packages/core/src/ports/workspace/vercel-command-diagnostics.ts +144 -0
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +811 -169
- package/packages/core/src/processes/build-child.ts +15 -1
- package/packages/core/src/processes/build-runner.ts +349 -20
- package/packages/core/src/processes/dispatcher.ts +509 -104
- package/packages/core/src/processes/harvest-child.ts +21 -1
- package/packages/core/src/processes/harvest-runner.ts +82 -35
- package/packages/core/src/processes/invocation-budget.ts +6 -0
- package/packages/core/src/processes/launch-cut.ts +37 -0
- package/packages/core/src/processes/phase-failure-budget.ts +1 -0
- package/packages/core/src/processes/provisioning-progress.ts +23 -0
- package/packages/core/src/processes/repo-view.ts +25 -4
- package/packages/core/src/processes/workspace-preparation.ts +1 -0
- package/packages/core/src/store/adapter.ts +34 -5
- package/packages/core/src/store/build-feed.ts +148 -22
- package/packages/core/src/store/build-scope.ts +12 -3
- package/packages/core/src/store/caller-attribution.ts +170 -0
- package/packages/core/src/store/contract.ts +1038 -165
- package/packages/core/src/store/local/schema.ts +12 -1
- package/packages/core/src/store/local/store.ts +260 -25
- package/packages/core/src/store/memory.ts +156 -9
- package/packages/core/src/store/phase-session.ts +23 -3
- package/packages/core/src/store/reducer-value-shapes.json +5351 -5338
- package/packages/core/src/store/remote/client.ts +90 -11
- package/packages/core/src/store/remote/credentials.ts +2 -0
- package/packages/core/src/store/remote/index.ts +31 -5
- package/packages/core/src/store/remote/protocol.ts +45 -8
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.16.0.json +36358 -0
- package/packages/core/src/store/remote/released-reducer-values/1.17.0.json +36367 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
- package/packages/core/src/store/remote/released-value-policy.ts +7 -0
- package/packages/core/src/store/session-handle.ts +12 -3
- package/packages/core/src/store/types.ts +48 -3
- package/packages/core/src/testing/reduced-read-budget.ts +310 -12
- package/skills/guide/SKILL.md +58 -9
- package/skills/guide/references/operator-api.md +15 -5
- package/skills/guide/references/plugin-authoring.md +1 -0
- package/skills/guide/references/remote-store-protocol.md +13 -3
- package/skills/guide/references/remote-ticket-protocol.md +3 -1
- package/skills/guide/references/restacking.md +41 -1
- package/skills/guide/references/setup.md +15 -6
- package/skills/operate/SKILL.md +31 -7
- package/templates/hosted-service/package.json +2 -2
|
@@ -42,6 +42,13 @@ import { TicketAssigneesUnsupported } from '../ports/tickets/assignees'
|
|
|
42
42
|
* every mutator, and — for constrained bindings — repository targeting.
|
|
43
43
|
*/
|
|
44
44
|
import { z } from 'zod'
|
|
45
|
+
import { listOperatorMergedBuilds } from './merged-builds'
|
|
46
|
+
import {
|
|
47
|
+
hasRepositoryArgument,
|
|
48
|
+
missingRepoIssue,
|
|
49
|
+
REPOSITORY_ARGUMENT_MESSAGE,
|
|
50
|
+
repoArgumentIssue,
|
|
51
|
+
} from './repo-argument'
|
|
45
52
|
import {
|
|
46
53
|
controlBuild,
|
|
47
54
|
BuildControlError,
|
|
@@ -51,6 +58,7 @@ import {
|
|
|
51
58
|
import type { Via } from '../events/envelope'
|
|
52
59
|
import { bulkControlRepository, BulkWalkError } from '../cli/bulk-control'
|
|
53
60
|
import { systemClock, type BuildStore, type Clock } from '../store/types'
|
|
61
|
+
import { BuildFeedUnsupportedError, BuildFeedValidationError } from '../store/build-feed'
|
|
54
62
|
import { TicketOperationError } from '../ports/tickets/operations'
|
|
55
63
|
import { TicketSearchCursorInvalid, TicketSearchUnsupported } from '../ports/tickets/search'
|
|
56
64
|
import { controlTicketStart } from './ticket-start'
|
|
@@ -256,16 +264,25 @@ function extendUnion(schema: z.ZodType, extra: z.ZodRawShape): z.ZodType {
|
|
|
256
264
|
if (!Array.isArray(options) || options.length === 0) {
|
|
257
265
|
throw new Error('extendUnion requires a union schema with options')
|
|
258
266
|
}
|
|
259
|
-
return z.union(
|
|
267
|
+
return z.union(
|
|
268
|
+
options.map((option) => option.extend(extra)),
|
|
269
|
+
{ error: repoArgumentIssue },
|
|
270
|
+
)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** A tool's top-level input: a strict object whose issues for an input
|
|
274
|
+
* carrying `repository` state the `repo` contract. */
|
|
275
|
+
function toolInput<Shape extends z.ZodRawShape>(shape: Shape) {
|
|
276
|
+
return z.strictObject(shape, { error: repoArgumentIssue })
|
|
260
277
|
}
|
|
261
278
|
|
|
262
279
|
// ── Shared input fields ──────────────────────────────────────────────────────
|
|
263
280
|
|
|
264
281
|
const repoField = z
|
|
265
|
-
.string()
|
|
282
|
+
.string({ error: missingRepoIssue })
|
|
266
283
|
.min(1)
|
|
267
284
|
.describe(
|
|
268
|
-
'Repository identity as the store keys it: the checkout’s normalized origin URL (e.g. "https://github.com/acme/widgets").',
|
|
285
|
+
'Repository identity as the store keys it: the checkout’s normalized origin URL (e.g. "https://github.com/acme/widgets"). The argument is `repo`, never `repository`; a repository-scoped MCP endpoint binds the repository from its URL and takes no `repo`.',
|
|
269
286
|
)
|
|
270
287
|
const slugField = z.string().min(1).describe('Build slug identifying one build in the store.')
|
|
271
288
|
const ticketIdField = z
|
|
@@ -273,22 +290,59 @@ const ticketIdField = z
|
|
|
273
290
|
.min(1)
|
|
274
291
|
.describe('Ticket id in the configured ticket source (e.g. "AUT-8").')
|
|
275
292
|
|
|
276
|
-
const
|
|
293
|
+
const MERGED_ONLY_FIELDS = ['since', 'until', 'limit', 'cursor'] as const
|
|
294
|
+
|
|
295
|
+
const buildListInput = toolInput({
|
|
277
296
|
repo: repoField,
|
|
278
297
|
scope: z
|
|
279
|
-
.enum(['active', 'queued', 'all'])
|
|
298
|
+
.enum(['active', 'queued', 'all', 'merged'])
|
|
280
299
|
.default('active')
|
|
281
300
|
.describe(
|
|
282
|
-
'Which builds to include: "active" (running, paused, or blocked — the default), "queued", or "
|
|
301
|
+
'Which builds to include: "active" (running, paused, or blocked — the default), "queued", "all", or "merged" (most recently merged first, paged; the call for a "what shipped since T" digest — use "active" and "queued" for what lands next).',
|
|
302
|
+
),
|
|
303
|
+
since: z
|
|
304
|
+
.string()
|
|
305
|
+
.optional()
|
|
306
|
+
.describe(
|
|
307
|
+
'Scope "merged" only: an ISO-8601 instant with a zone; include builds merged at or after it.',
|
|
308
|
+
),
|
|
309
|
+
until: z
|
|
310
|
+
.string()
|
|
311
|
+
.optional()
|
|
312
|
+
.describe(
|
|
313
|
+
'Scope "merged" only: an ISO-8601 instant with a zone; include builds merged before it (exclusive).',
|
|
314
|
+
),
|
|
315
|
+
limit: z
|
|
316
|
+
.number()
|
|
317
|
+
.int()
|
|
318
|
+
.min(1)
|
|
319
|
+
.max(100)
|
|
320
|
+
.optional()
|
|
321
|
+
.describe('Scope "merged" only: page size, 1 to 100; default 25.'),
|
|
322
|
+
cursor: z
|
|
323
|
+
.string()
|
|
324
|
+
.min(1)
|
|
325
|
+
.optional()
|
|
326
|
+
.describe(
|
|
327
|
+
'Scope "merged" only: the `next` value from the previous page, requested with the same since and until.',
|
|
283
328
|
),
|
|
329
|
+
}).superRefine((value, ctx) => {
|
|
330
|
+
if (value.scope === 'merged') return
|
|
331
|
+
for (const field of MERGED_ONLY_FIELDS)
|
|
332
|
+
if (value[field] !== undefined)
|
|
333
|
+
ctx.addIssue({
|
|
334
|
+
code: 'custom',
|
|
335
|
+
path: [field],
|
|
336
|
+
message: 'since, until, limit and cursor apply only to scope "merged"',
|
|
337
|
+
})
|
|
284
338
|
})
|
|
285
339
|
|
|
286
|
-
const buildDetailInput =
|
|
340
|
+
const buildDetailInput = toolInput({ repo: repoField, slug: slugField })
|
|
287
341
|
|
|
288
|
-
const ticketDetailInput =
|
|
342
|
+
const ticketDetailInput = toolInput({ repo: repoField, id: ticketIdField })
|
|
289
343
|
|
|
290
|
-
const contextListInput =
|
|
291
|
-
const contextReadInput =
|
|
344
|
+
const contextListInput = toolInput({ repo: repoField })
|
|
345
|
+
const contextReadInput = toolInput({
|
|
292
346
|
repo: repoField,
|
|
293
347
|
path: z
|
|
294
348
|
.string()
|
|
@@ -347,7 +401,7 @@ const assetNameField = z
|
|
|
347
401
|
.string()
|
|
348
402
|
.min(1)
|
|
349
403
|
.describe('Asset name, unique per kind on the ticket (e.g. "checkout-canvas").')
|
|
350
|
-
const ticketAssetAttachInput =
|
|
404
|
+
const ticketAssetAttachInput = toolInput({
|
|
351
405
|
repo: repoField,
|
|
352
406
|
id: ticketIdField,
|
|
353
407
|
kind: assetKindField,
|
|
@@ -377,7 +431,7 @@ const ticketAssetAttachInput = z.strictObject({
|
|
|
377
431
|
)
|
|
378
432
|
.describe('The asset’s files and explicit directories.'),
|
|
379
433
|
})
|
|
380
|
-
const ticketAssetGetInput =
|
|
434
|
+
const ticketAssetGetInput = toolInput({
|
|
381
435
|
repo: repoField,
|
|
382
436
|
id: ticketIdField,
|
|
383
437
|
kind: assetKindField,
|
|
@@ -392,39 +446,37 @@ const ticketAssetGetInput = z.strictObject({
|
|
|
392
446
|
'Exact revision to read. Omit for the latest; a removed asset is readable only by revision.',
|
|
393
447
|
),
|
|
394
448
|
})
|
|
395
|
-
const ticketAssetRemoveInput =
|
|
449
|
+
const ticketAssetRemoveInput = toolInput({
|
|
396
450
|
repo: repoField,
|
|
397
451
|
id: ticketIdField,
|
|
398
452
|
kind: assetKindField,
|
|
399
453
|
name: assetNameField,
|
|
400
454
|
})
|
|
401
455
|
|
|
402
|
-
const objectiveReviseInput =
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
})
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
'revise at least one field',
|
|
425
|
-
)
|
|
456
|
+
const objectiveReviseInput = toolInput({
|
|
457
|
+
repo: repoField,
|
|
458
|
+
slug: slugField,
|
|
459
|
+
threshold: z.number().optional().describe('Stop when the node head reaches this value.'),
|
|
460
|
+
epsilon: objectiveEpsilonSchema
|
|
461
|
+
.optional()
|
|
462
|
+
.describe('The smallest gain that counts: {absolute: n} or {relative: 0 < n < 1}.'),
|
|
463
|
+
maxAttempts: z.number().int().min(1).optional(),
|
|
464
|
+
maxHours: z.number().gt(0).optional(),
|
|
465
|
+
plateau: z
|
|
466
|
+
.number()
|
|
467
|
+
.int()
|
|
468
|
+
.min(1)
|
|
469
|
+
.optional()
|
|
470
|
+
.describe('Consecutive no-improvement or declined attempts that stop the node.'),
|
|
471
|
+
stopMode: z.enum(['abort', 'drain']).optional(),
|
|
472
|
+
concurrency: z.number().int().min(1).optional().describe('Attempts in flight.'),
|
|
473
|
+
}).refine(
|
|
474
|
+
({ repo: _repo, slug: _slug, ...changes }) =>
|
|
475
|
+
Object.values(changes).some((value) => value !== undefined),
|
|
476
|
+
'revise at least one field',
|
|
477
|
+
)
|
|
426
478
|
|
|
427
|
-
const objectiveStopInput =
|
|
479
|
+
const objectiveStopInput = toolInput({
|
|
428
480
|
repo: repoField,
|
|
429
481
|
slug: slugField,
|
|
430
482
|
mode: z
|
|
@@ -435,7 +487,7 @@ const objectiveStopInput = z.strictObject({
|
|
|
435
487
|
),
|
|
436
488
|
})
|
|
437
489
|
|
|
438
|
-
const objectiveSettleUnmeasuredInput =
|
|
490
|
+
const objectiveSettleUnmeasuredInput = toolInput({
|
|
439
491
|
repo: repoField,
|
|
440
492
|
slug: slugField,
|
|
441
493
|
attempt: z
|
|
@@ -448,7 +500,7 @@ const objectiveSettleUnmeasuredInput = z.strictObject({
|
|
|
448
500
|
note: z.string().max(4000).optional().describe('A note recorded with the settlement.'),
|
|
449
501
|
})
|
|
450
502
|
|
|
451
|
-
const buildEventsInput =
|
|
503
|
+
const buildEventsInput = toolInput({
|
|
452
504
|
repo: repoField,
|
|
453
505
|
slug: slugField,
|
|
454
506
|
cursor: z
|
|
@@ -470,7 +522,7 @@ const buildEventsInput = z.strictObject({
|
|
|
470
522
|
),
|
|
471
523
|
})
|
|
472
524
|
|
|
473
|
-
const buildArtifactInput =
|
|
525
|
+
const buildArtifactInput = toolInput({
|
|
474
526
|
repo: repoField,
|
|
475
527
|
slug: slugField,
|
|
476
528
|
kind: z.string().min(1).describe('Artifact kind to download (e.g. "spec", "plan", "notes").'),
|
|
@@ -482,7 +534,7 @@ const buildArtifactInput = z.strictObject({
|
|
|
482
534
|
.describe('Artifact revision to fetch; omit for the latest revision of the kind.'),
|
|
483
535
|
})
|
|
484
536
|
|
|
485
|
-
const buildControlInput =
|
|
537
|
+
const buildControlInput = toolInput({
|
|
486
538
|
head: z
|
|
487
539
|
.string()
|
|
488
540
|
.min(1)
|
|
@@ -526,7 +578,7 @@ const buildControlInput = z.strictObject({
|
|
|
526
578
|
),
|
|
527
579
|
})
|
|
528
580
|
|
|
529
|
-
const repositoryEventsInput =
|
|
581
|
+
const repositoryEventsInput = toolInput({
|
|
530
582
|
repo: repoField,
|
|
531
583
|
cursor: z
|
|
532
584
|
.number()
|
|
@@ -554,7 +606,7 @@ const repositoryEventsInput = z.strictObject({
|
|
|
554
606
|
),
|
|
555
607
|
})
|
|
556
608
|
|
|
557
|
-
const repositoryAttentionInput =
|
|
609
|
+
const repositoryAttentionInput = toolInput({
|
|
558
610
|
repo: repoField,
|
|
559
611
|
cursor: z
|
|
560
612
|
.number()
|
|
@@ -569,11 +621,15 @@ const repositoryAttentionInput = z.strictObject({
|
|
|
569
621
|
|
|
570
622
|
const buildsAnswerInput = extendUnion(answerRequestSchema, { repo: repoField, slug: slugField })
|
|
571
623
|
|
|
572
|
-
const buildsReopenInput =
|
|
624
|
+
const buildsReopenInput = toolInput({
|
|
625
|
+
...reopenRequestSchema.shape,
|
|
626
|
+
repo: repoField,
|
|
627
|
+
slug: slugField,
|
|
628
|
+
})
|
|
573
629
|
|
|
574
|
-
const repositoryStatusInput =
|
|
630
|
+
const repositoryStatusInput = toolInput({ repo: repoField })
|
|
575
631
|
|
|
576
|
-
const repositorySettingsInput =
|
|
632
|
+
const repositorySettingsInput = toolInput({
|
|
577
633
|
repo: repoField,
|
|
578
634
|
setting: z.enum(['intake']).describe('"intake" gates whether new tickets may be claimed.'),
|
|
579
635
|
enabled: z
|
|
@@ -582,7 +638,7 @@ const repositorySettingsInput = z.strictObject({
|
|
|
582
638
|
.describe('Set the value explicitly; omit to toggle the current durable value.'),
|
|
583
639
|
})
|
|
584
640
|
|
|
585
|
-
const bulkControlInput =
|
|
641
|
+
const bulkControlInput = toolInput({
|
|
586
642
|
repo: repoField,
|
|
587
643
|
action: z
|
|
588
644
|
.enum(['pause', 'resume'])
|
|
@@ -591,11 +647,11 @@ const bulkControlInput = z.strictObject({
|
|
|
591
647
|
),
|
|
592
648
|
})
|
|
593
649
|
|
|
594
|
-
const harvestStatusInput =
|
|
650
|
+
const harvestStatusInput = toolInput({ repo: repoField })
|
|
595
651
|
|
|
596
652
|
const harvestControlInput = extendUnion(harvestControlRequestSchema, { repo: repoField })
|
|
597
653
|
|
|
598
|
-
const ticketsListInput =
|
|
654
|
+
const ticketsListInput = toolInput({
|
|
599
655
|
repo: repoField,
|
|
600
656
|
state: z
|
|
601
657
|
.string()
|
|
@@ -624,7 +680,7 @@ const ticketsListInput = z.strictObject({
|
|
|
624
680
|
),
|
|
625
681
|
})
|
|
626
682
|
|
|
627
|
-
const ticketsSearchInput =
|
|
683
|
+
const ticketsSearchInput = toolInput({
|
|
628
684
|
repo: repoField,
|
|
629
685
|
query: z
|
|
630
686
|
.string()
|
|
@@ -651,24 +707,27 @@ const ticketsSearchInput = z.strictObject({
|
|
|
651
707
|
.describe('The `cursor` from the previous page of the same search.'),
|
|
652
708
|
})
|
|
653
709
|
|
|
654
|
-
const ticketsCreateInput =
|
|
655
|
-
|
|
656
|
-
const ticketsUpdateInput = ticketUpdateRequestSchema
|
|
657
|
-
.extend({ repo: repoField, id: ticketIdField })
|
|
658
|
-
.refine(
|
|
659
|
-
(value) =>
|
|
660
|
-
value.title !== undefined ||
|
|
661
|
-
value.body !== undefined ||
|
|
662
|
-
value.labels !== undefined ||
|
|
663
|
-
value.issueLinks !== undefined ||
|
|
664
|
-
value.priority !== undefined ||
|
|
665
|
-
value.assignees !== undefined ||
|
|
666
|
-
value.kind !== undefined ||
|
|
667
|
-
value.target !== undefined,
|
|
668
|
-
'update must name at least one field',
|
|
669
|
-
)
|
|
710
|
+
const ticketsCreateInput = toolInput({ ...ticketCreateRequestSchema.shape, repo: repoField })
|
|
670
711
|
|
|
671
|
-
const
|
|
712
|
+
const ticketsUpdateInput = toolInput({
|
|
713
|
+
...ticketUpdateRequestSchema.shape,
|
|
714
|
+
repo: repoField,
|
|
715
|
+
id: ticketIdField,
|
|
716
|
+
}).refine(
|
|
717
|
+
(value) =>
|
|
718
|
+
value.title !== undefined ||
|
|
719
|
+
value.body !== undefined ||
|
|
720
|
+
value.labels !== undefined ||
|
|
721
|
+
value.issueLinks !== undefined ||
|
|
722
|
+
value.priority !== undefined ||
|
|
723
|
+
value.assignees !== undefined ||
|
|
724
|
+
value.kind !== undefined ||
|
|
725
|
+
value.target !== undefined,
|
|
726
|
+
'update must name at least one field',
|
|
727
|
+
)
|
|
728
|
+
|
|
729
|
+
const ticketsBlockersInput = toolInput({
|
|
730
|
+
...ticketBlockerRequestSchema.shape,
|
|
672
731
|
repo: repoField,
|
|
673
732
|
id: ticketIdField,
|
|
674
733
|
blockerIds: z
|
|
@@ -679,7 +738,7 @@ const ticketsBlockersInput = ticketBlockerRequestSchema.extend({
|
|
|
679
738
|
),
|
|
680
739
|
})
|
|
681
740
|
|
|
682
|
-
const ticketsStartInput =
|
|
741
|
+
const ticketsStartInput = toolInput({
|
|
683
742
|
repo: repoField,
|
|
684
743
|
id: ticketIdField,
|
|
685
744
|
priority: z
|
|
@@ -694,23 +753,22 @@ const ticketsStartInput = z.strictObject({
|
|
|
694
753
|
.describe('Cancel the pending start request for this ticket instead of requesting one.'),
|
|
695
754
|
})
|
|
696
755
|
|
|
697
|
-
const ticketsMoveInput =
|
|
698
|
-
.
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
.refine(exactlyOneMoveTarget, MOVE_TARGET_MESSAGE)
|
|
756
|
+
const ticketsMoveInput = toolInput({
|
|
757
|
+
...ticketMoveRequestShape.shape,
|
|
758
|
+
repo: repoField,
|
|
759
|
+
id: ticketIdField,
|
|
760
|
+
state: z
|
|
761
|
+
.string()
|
|
762
|
+
.min(1)
|
|
763
|
+
.optional()
|
|
764
|
+
.describe(
|
|
765
|
+
'Provider state to move the ticket into; give this or `role`, not both. Destructive: moving a ticket into the repository’s configured ready state queues it for dispatch.',
|
|
766
|
+
),
|
|
767
|
+
}).refine(exactlyOneMoveTarget, MOVE_TARGET_MESSAGE)
|
|
710
768
|
|
|
711
|
-
const notesReadInput =
|
|
769
|
+
const notesReadInput = toolInput({ repo: repoField })
|
|
712
770
|
|
|
713
|
-
const notesWriteInput =
|
|
771
|
+
const notesWriteInput = toolInput({
|
|
714
772
|
repo: repoField,
|
|
715
773
|
document: z
|
|
716
774
|
.string()
|
|
@@ -719,7 +777,7 @@ const notesWriteInput = z.strictObject({
|
|
|
719
777
|
),
|
|
720
778
|
})
|
|
721
779
|
|
|
722
|
-
const sandboxExecInput =
|
|
780
|
+
const sandboxExecInput = toolInput({
|
|
723
781
|
repo: repoField,
|
|
724
782
|
command: z.string().min(1).describe('Shell command to run inside the operator sandbox.'),
|
|
725
783
|
cwd: z
|
|
@@ -739,7 +797,7 @@ const sandboxExecInput = z.strictObject({
|
|
|
739
797
|
),
|
|
740
798
|
})
|
|
741
799
|
|
|
742
|
-
const sandboxStartInput =
|
|
800
|
+
const sandboxStartInput = toolInput({
|
|
743
801
|
repo: repoField,
|
|
744
802
|
command: z
|
|
745
803
|
.string()
|
|
@@ -753,7 +811,7 @@ const sandboxStartInput = z.strictObject({
|
|
|
753
811
|
),
|
|
754
812
|
})
|
|
755
813
|
|
|
756
|
-
const sandboxWaitInput =
|
|
814
|
+
const sandboxWaitInput = toolInput({
|
|
757
815
|
repo: repoField,
|
|
758
816
|
commandId: z.string().min(1).describe('Command id returned by a previous sandbox.start.'),
|
|
759
817
|
waitSeconds: z
|
|
@@ -766,7 +824,7 @@ const sandboxWaitInput = z.strictObject({
|
|
|
766
824
|
),
|
|
767
825
|
})
|
|
768
826
|
|
|
769
|
-
const sandboxReadFileInput =
|
|
827
|
+
const sandboxReadFileInput = toolInput({
|
|
770
828
|
repo: repoField,
|
|
771
829
|
path: z
|
|
772
830
|
.string()
|
|
@@ -774,7 +832,7 @@ const sandboxReadFileInput = z.strictObject({
|
|
|
774
832
|
.describe('File path relative to the checkout. Absolute paths and ".." escapes are refused.'),
|
|
775
833
|
})
|
|
776
834
|
|
|
777
|
-
const sandboxWriteFileInput =
|
|
835
|
+
const sandboxWriteFileInput = toolInput({
|
|
778
836
|
repo: repoField,
|
|
779
837
|
path: z
|
|
780
838
|
.string()
|
|
@@ -787,13 +845,13 @@ const sandboxWriteFileInput = z.strictObject({
|
|
|
787
845
|
.describe('How to decode `content`: "utf8" (default) or "base64".'),
|
|
788
846
|
})
|
|
789
847
|
|
|
790
|
-
const sandboxResetInput =
|
|
791
|
-
const sandboxOpenInput =
|
|
792
|
-
const sandboxStatusInput =
|
|
793
|
-
const sandboxCloseInput =
|
|
794
|
-
const sandboxRefreshInput =
|
|
848
|
+
const sandboxResetInput = toolInput({ repo: repoField })
|
|
849
|
+
const sandboxOpenInput = toolInput({ repo: repoField })
|
|
850
|
+
const sandboxStatusInput = toolInput({ repo: repoField })
|
|
851
|
+
const sandboxCloseInput = toolInput({ repo: repoField })
|
|
852
|
+
const sandboxRefreshInput = toolInput({ repo: repoField })
|
|
795
853
|
|
|
796
|
-
const sandboxPublishInput =
|
|
854
|
+
const sandboxPublishInput = toolInput({
|
|
797
855
|
repo: repoField,
|
|
798
856
|
title: z.string().min(1).max(200).describe('Pull-request title, 1-200 characters.'),
|
|
799
857
|
body: z
|
|
@@ -869,11 +927,20 @@ export const TOOLS: readonly ToolEntry[] = [
|
|
|
869
927
|
),
|
|
870
928
|
defineTool(
|
|
871
929
|
'builds.list',
|
|
872
|
-
'List one repository’s builds, newest first, with effective status derived from the build log.',
|
|
930
|
+
'List one repository’s builds, newest first, with effective status derived from the build log; or, with scope "merged", the builds merged in a time window, most recently merged first, one page at a time.',
|
|
873
931
|
buildListInput,
|
|
874
|
-
'JSON array of build summaries: slug, ticket ref, effective status, phase/round/attempt, PR number/url/state, updatedAt, lease health, durable-event progress, any ticket wait (`wait` with its state and tickets; `waitOnly` when the wait is the only open escalation), an optimization node’s objective progress (`objective`), and each nonterminal build’s slot state (`slot`: `{state: "held"}`, `{state: "requested", request, priority?: "urgent" | "high" | "low"}` or `{state: "none"}`; absent means unknown, never none).',
|
|
932
|
+
'Scope "merged": {builds, next}, where each build is {slug, mergedAt, kind: "leaf" | "node", ticket?: {source, id, title?, url?}, pr?: {number, url}, target?: {build, ticket}} (`mergedAt` is when it merged, never a later cleanup; `target` is the node a child build targets), and `next` is a cursor to pass back with the same since and until, or null on the last page. Other scopes: a JSON array of build summaries: slug, ticket ref, effective status, phase/round/attempt, PR number/url/state, updatedAt, lease health, durable-event progress, any ticket wait (`wait` with its state and tickets; `waitOnly` when the wait is the only open escalation), an optimization node’s objective progress (`objective`), and each nonterminal build’s slot state (`slot`: `{state: "held"}`, `{state: "requested", request, priority?: "urgent" | "high" | "low"}` or `{state: "none"}`; absent means unknown, never none).',
|
|
875
933
|
async (raw, ctx) => {
|
|
876
934
|
const input = raw as z.infer<typeof buildListInput>
|
|
935
|
+
if (input.scope === 'merged')
|
|
936
|
+
return listOperatorMergedBuilds({
|
|
937
|
+
store: ctx.store,
|
|
938
|
+
repo: input.repo,
|
|
939
|
+
...(input.since !== undefined ? { since: input.since } : {}),
|
|
940
|
+
...(input.until !== undefined ? { until: input.until } : {}),
|
|
941
|
+
...(input.limit !== undefined ? { limit: input.limit } : {}),
|
|
942
|
+
...(input.cursor !== undefined ? { cursor: input.cursor } : {}),
|
|
943
|
+
})
|
|
877
944
|
return listOperatorBuilds({
|
|
878
945
|
store: ctx.store,
|
|
879
946
|
repo: input.repo,
|
|
@@ -1136,8 +1203,8 @@ export const TOOLS: readonly ToolEntry[] = [
|
|
|
1136
1203
|
defineTool(
|
|
1137
1204
|
'repository.forge_clear',
|
|
1138
1205
|
'Explicitly clear erroneous forge cooldown state with an audited reason; does not prove provider recovery.',
|
|
1139
|
-
|
|
1140
|
-
repo:
|
|
1206
|
+
toolInput({
|
|
1207
|
+
repo: repoField,
|
|
1141
1208
|
forge: z.string().trim().min(1).describe('Forge adapter name.'),
|
|
1142
1209
|
reason: z.string().trim().min(1).describe('Reason for the operator override.'),
|
|
1143
1210
|
}),
|
|
@@ -1273,7 +1340,7 @@ export const TOOLS: readonly ToolEntry[] = [
|
|
|
1273
1340
|
defineTool(
|
|
1274
1341
|
'tickets.states',
|
|
1275
1342
|
'List all ticket states with ticket counts and optional purposes.',
|
|
1276
|
-
|
|
1343
|
+
toolInput({ repo: repoField }),
|
|
1277
1344
|
'Array of {name,tickets,about?}.',
|
|
1278
1345
|
async (raw, ctx) => {
|
|
1279
1346
|
const input = raw as { repo: string }
|
|
@@ -1287,7 +1354,7 @@ export const TOOLS: readonly ToolEntry[] = [
|
|
|
1287
1354
|
defineTool(
|
|
1288
1355
|
'tickets.state.create',
|
|
1289
1356
|
'Create a custom ticket state with an optional one-line purpose. Hosted duplicates are refused.',
|
|
1290
|
-
|
|
1357
|
+
toolInput({ repo: repoField, name: z.string(), about: z.string().optional() }),
|
|
1291
1358
|
'{state: {name,tickets,about?},created}.',
|
|
1292
1359
|
async (raw, ctx) => {
|
|
1293
1360
|
const input = raw as { repo: string; name: string; about?: string }
|
|
@@ -1833,6 +1900,18 @@ function mapDomainError(error: unknown): RegistryError {
|
|
|
1833
1900
|
...(error.state !== undefined ? { state: error.state } : {}),
|
|
1834
1901
|
})
|
|
1835
1902
|
}
|
|
1903
|
+
if (error instanceof BuildFeedValidationError)
|
|
1904
|
+
return new RegistryError('domain', error.message, {
|
|
1905
|
+
kind: 'validation',
|
|
1906
|
+
error: error.message,
|
|
1907
|
+
code: 'invalid-page',
|
|
1908
|
+
})
|
|
1909
|
+
if (error instanceof BuildFeedUnsupportedError)
|
|
1910
|
+
return new RegistryError('domain', error.message, {
|
|
1911
|
+
kind: 'conflict',
|
|
1912
|
+
error: error.message,
|
|
1913
|
+
code: 'store-unsupported',
|
|
1914
|
+
})
|
|
1836
1915
|
if (error instanceof OperatorQueryError) {
|
|
1837
1916
|
return new RegistryError('domain', error.message, {
|
|
1838
1917
|
kind: error.code === 'not-found' ? 'not-found' : 'conflict',
|
|
@@ -1882,6 +1961,16 @@ export function buildRegistry(options: RegistryOptions): OperatorToolRegistry {
|
|
|
1882
1961
|
error: `unknown tool "${name}"`,
|
|
1883
1962
|
})
|
|
1884
1963
|
}
|
|
1964
|
+
// The repository argument's name is a contract every binding states the
|
|
1965
|
+
// same way, before any other validation.
|
|
1966
|
+
if (hasRepositoryArgument(input)) {
|
|
1967
|
+
const error = `invalid input for tool "${name}": ${REPOSITORY_ARGUMENT_MESSAGE}`
|
|
1968
|
+
throw new RegistryError('validation', error, {
|
|
1969
|
+
kind: 'validation',
|
|
1970
|
+
error,
|
|
1971
|
+
code: 'repo-argument',
|
|
1972
|
+
})
|
|
1973
|
+
}
|
|
1885
1974
|
const parsed = entry.inputSchema.safeParse(input)
|
|
1886
1975
|
if (!parsed.success) {
|
|
1887
1976
|
throw new RegistryError(
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The operator tools' repository-argument contract, stated once for every
|
|
3
|
+
* binding: the registry's validation, the deployment-wide `/mcp` endpoint
|
|
4
|
+
* (whose SDK validation renders the same zod messages), the repository-scoped
|
|
5
|
+
* `/mcp/<host>/<path>` endpoints and the operator HTTP tool route.
|
|
6
|
+
*/
|
|
7
|
+
import type { z } from 'zod'
|
|
8
|
+
|
|
9
|
+
export const REPO_ARGUMENT_CONTRACT =
|
|
10
|
+
'Operator tools name the repository with `repo`, never `repository`. The deployment-wide /mcp endpoint requires `repo` (call repositories.list for the identities it serves); a repository-scoped /mcp/<host>/<path> endpoint binds the repository from its URL and takes no `repo` argument.'
|
|
11
|
+
|
|
12
|
+
function isObject(input: unknown): input is object {
|
|
13
|
+
return input !== null && typeof input === 'object' && !Array.isArray(input)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** True when `input` is an object carrying its own `repository` key. */
|
|
17
|
+
export function hasRepositoryArgument(input: unknown): boolean {
|
|
18
|
+
return isObject(input) && Object.hasOwn(input, 'repository')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const REPOSITORY_ARGUMENT_MESSAGE = `unexpected argument \`repository\`: ${REPO_ARGUMENT_CONTRACT}`
|
|
22
|
+
const MISSING_REPO_MESSAGE = `missing \`repo\`: ${REPO_ARGUMENT_CONTRACT}`
|
|
23
|
+
|
|
24
|
+
/** A zod error customizer for a tool's top-level input: an input carrying
|
|
25
|
+
* `repository` reports the contract; any other issue keeps zod's message. */
|
|
26
|
+
export function repoArgumentIssue(issue: z.core.$ZodRawIssue): string | undefined {
|
|
27
|
+
if (hasRepositoryArgument(issue.input)) return REPOSITORY_ARGUMENT_MESSAGE
|
|
28
|
+
// A union reports one issue for every member; name the missing `repo`
|
|
29
|
+
// rather than zod's bare "Invalid input".
|
|
30
|
+
if (
|
|
31
|
+
issue.code === 'invalid_union' &&
|
|
32
|
+
isObject(issue.input) &&
|
|
33
|
+
!Object.hasOwn(issue.input, 'repo')
|
|
34
|
+
)
|
|
35
|
+
return MISSING_REPO_MESSAGE
|
|
36
|
+
return undefined
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** A zod error customizer for the `repo` field itself: a missing `repo`
|
|
40
|
+
* reports the contract. */
|
|
41
|
+
export function missingRepoIssue(issue: z.core.$ZodRawIssue): string | undefined {
|
|
42
|
+
return issue.input === undefined ? MISSING_REPO_MESSAGE : undefined
|
|
43
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { storeCallerHeaders } from '../../store/caller-attribution'
|
|
1
2
|
import {
|
|
2
3
|
AUTOBUILD_VERSION,
|
|
3
4
|
AUTOBUILD_VERSION_HEADER,
|
|
@@ -19,6 +20,7 @@ export async function ticketGrantRequest(
|
|
|
19
20
|
headers: {
|
|
20
21
|
authorization: `Bearer ${token}`,
|
|
21
22
|
'content-type': 'application/json',
|
|
23
|
+
...storeCallerHeaders(),
|
|
22
24
|
[AUTOBUILD_VERSION_HEADER]: AUTOBUILD_VERSION,
|
|
23
25
|
[REMOTE_STORE_PROTOCOL_VERSION_HEADER]: REMOTE_STORE_PROTOCOL_VERSION,
|
|
24
26
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { storeCallerHeaders } from '../../store/caller-attribution'
|
|
1
2
|
import { normalizeTicket } from './tree'
|
|
2
3
|
import { hostedRequestedIds } from './requested-id'
|
|
3
4
|
import { TicketRevisionConflict } from './revision'
|
|
@@ -306,6 +307,7 @@ export class HostedTicketSource implements TicketSource {
|
|
|
306
307
|
[TICKET_TARGETING_HEADER]: TICKET_TARGETING_CAPABILITY,
|
|
307
308
|
[TICKET_PAGING_HEADER]: TICKET_PAGING_CAPABILITY,
|
|
308
309
|
[TICKET_SEARCH_HEADER]: TICKET_SEARCH_CAPABILITY,
|
|
310
|
+
...storeCallerHeaders(),
|
|
309
311
|
[AUTOBUILD_VERSION_HEADER]: AUTOBUILD_VERSION,
|
|
310
312
|
[REMOTE_STORE_PROTOCOL_VERSION_HEADER]: REMOTE_STORE_PROTOCOL_VERSION,
|
|
311
313
|
},
|
|
@@ -665,14 +665,26 @@ export interface WorkspaceReapOutcome {
|
|
|
665
665
|
}
|
|
666
666
|
|
|
667
667
|
export interface WorkspaceRecovery {
|
|
668
|
-
/** Stops execution without deleting the workspace or its snapshots.
|
|
669
|
-
|
|
668
|
+
/** Stops execution without deleting the workspace or its snapshots.
|
|
669
|
+
* `teardown`: the dispatcher calls it during a bounded invocation's
|
|
670
|
+
* teardown, after the work deadline, to settle a launch that deadline cut.
|
|
671
|
+
* Bound the calls by the provider's own operation timeout and the ambient
|
|
672
|
+
* teardown scope, not by the invocation's work deadline. */
|
|
673
|
+
fence?(handle: WorkspaceHandle, opts?: { teardown?: boolean }): Promise<WorkspaceFenceOutcome>
|
|
670
674
|
|
|
671
675
|
/** Fence an unavailable environment. Unknown outcomes must reject so the
|
|
672
676
|
* dispatcher retains the lease/workspace fact and retries after its fence. */
|
|
673
677
|
reap(handle: WorkspaceHandle): Promise<WorkspaceReapOutcome>
|
|
674
678
|
}
|
|
675
679
|
|
|
680
|
+
/** The provisioning stage a provider is about to run, such as
|
|
681
|
+
* `{ stage: 'system provisioning step', step: 'browser-deps' }`. Process-local
|
|
682
|
+
* teardown diagnostics only; never persisted as state. */
|
|
683
|
+
export interface WorkspaceProvisionProgress {
|
|
684
|
+
stage: string
|
|
685
|
+
step?: string
|
|
686
|
+
}
|
|
687
|
+
|
|
676
688
|
export interface WorkspaceProvider {
|
|
677
689
|
/** Local adapters may provide the same boundary capability without becoming
|
|
678
690
|
* a remote-publication provider. */
|
|
@@ -746,8 +758,10 @@ export interface WorkspaceProvider {
|
|
|
746
758
|
generation?: number
|
|
747
759
|
/** The previous attempt at this exact generation was abandoned at a
|
|
748
760
|
* recorded dispatcher teardown and its lease is gone. A provider that can
|
|
749
|
-
* verify the partial environment may finish it in place
|
|
750
|
-
*
|
|
761
|
+
* verify the partial environment may finish it in place, resuming from
|
|
762
|
+
* its own verified progress and keeping the commit the environment
|
|
763
|
+
* already holds, which the restack later advances. Otherwise, or on any
|
|
764
|
+
* doubt, it throws `WorkspaceCleanupRequired` as for any incomplete
|
|
751
765
|
* environment. Never expose an unverified environment. */
|
|
752
766
|
adoptAbandoned?: boolean
|
|
753
767
|
/** The leaf build has no prior `workspace.provisioned` or cleanup-required
|
|
@@ -758,6 +772,13 @@ export interface WorkspaceProvider {
|
|
|
758
772
|
* `baseBranch` and keeps the old tip under a private ref (#1261).
|
|
759
773
|
* Providers that cannot honor it rely on claim-time deduplication. */
|
|
760
774
|
fresh?: { owner: string }
|
|
775
|
+
/** The invocation's teardown token: abort in-flight provisioning
|
|
776
|
+
* promptly. The dispatcher records the abandonment; the provider must
|
|
777
|
+
* not record a failure. Providers that ignore it may still complete. */
|
|
778
|
+
signal?: AbortSignal
|
|
779
|
+
/** Report the stage about to run, for teardown diagnostics; must never
|
|
780
|
+
* block or throw into provisioning. */
|
|
781
|
+
onProgress?: (progress: WorkspaceProvisionProgress) => void
|
|
761
782
|
}): Promise<WorkspaceProvisionResult>
|
|
762
783
|
release(handle: WorkspaceHandle): Promise<void>
|
|
763
784
|
}
|