@vercel/factory 0.0.8 → 0.0.10

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.
@@ -1,5 +1,5 @@
1
- import { c as Finding, k as FactoryStores, t as ApprovalPolicy } from "../approval-qkxww0wJ.mjs";
2
- import { d as GitHubReviewComment } from "../github-BdWWueJP.mjs";
1
+ import { A as FactoryStores, c as Finding, t as ApprovalPolicy } from "../approval-CDiBco2V.mjs";
2
+ import { T as PullRequestReviewComment, b as GitHubReviewComment, j as SubmittedPullRequestReview } from "../github-wThBfbm-.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/eve/fetch.d.ts
5
5
  /** The subset of the eve sandbox handle a credentialed git operation needs. */
@@ -362,7 +362,7 @@ declare function invokeAgentTool(stores: FactoryStores, options: InvokeAgentOpti
362
362
  }, {
363
363
  taskId: string;
364
364
  kind: string;
365
- state: "succeeded" | "failed" | "needs_human" | "queued" | "running" | "verifying" | "cancelled";
365
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
366
366
  }> & {
367
367
  execute(input: {
368
368
  repositoryIds: string[];
@@ -374,7 +374,77 @@ declare function invokeAgentTool(stores: FactoryStores, options: InvokeAgentOpti
374
374
  }, ctx: import("eve/tools").ToolContext): Promise<{
375
375
  taskId: string;
376
376
  kind: string;
377
- state: "succeeded" | "failed" | "needs_human" | "queued" | "running" | "verifying" | "cancelled";
377
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
378
+ }>;
379
+ };
380
+ //#endregion
381
+ //#region src/eve/post-review.d.ts
382
+ interface PublishedReview {
383
+ taskId: string;
384
+ changeId: string;
385
+ repository: string;
386
+ headSha: string;
387
+ verdict: "approve" | "request_changes" | "comment";
388
+ summary: string;
389
+ comments: readonly PullRequestReviewComment[];
390
+ review: SubmittedPullRequestReview;
391
+ }
392
+ interface PostReviewToolOptions {
393
+ tokenForRepository: (repository: string) => Promise<string>;
394
+ onPublished?: (published: PublishedReview) => Promise<void>;
395
+ fetch?: typeof globalThis.fetch;
396
+ }
397
+ /**
398
+ * Publish an independent review of an existing pull request and finish the
399
+ * review task without changing the pull request's factory lifecycle.
400
+ */
401
+ declare function postReviewTool(stores: FactoryStores, options: PostReviewToolOptions): import("eve/tools").ToolDefinition<{
402
+ taskId: string;
403
+ changeId: string;
404
+ verdict: "approve" | "request_changes" | "comment";
405
+ headSha: string;
406
+ summary: string;
407
+ comments: {
408
+ path: string;
409
+ line: number;
410
+ body: string;
411
+ }[];
412
+ }, {
413
+ recorded: false;
414
+ reason: string;
415
+ verdict?: undefined;
416
+ review?: undefined;
417
+ taskState?: undefined;
418
+ } | {
419
+ recorded: true;
420
+ verdict: "approve" | "request_changes" | "comment";
421
+ review: SubmittedPullRequestReview;
422
+ taskState: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
423
+ reason?: undefined;
424
+ }> & {
425
+ execute(input: {
426
+ taskId: string;
427
+ changeId: string;
428
+ verdict: "approve" | "request_changes" | "comment";
429
+ headSha: string;
430
+ summary: string;
431
+ comments: {
432
+ path: string;
433
+ line: number;
434
+ body: string;
435
+ }[];
436
+ }, ctx: import("eve/tools").ToolContext): Promise<{
437
+ recorded: false;
438
+ reason: string;
439
+ verdict?: undefined;
440
+ review?: undefined;
441
+ taskState?: undefined;
442
+ } | {
443
+ recorded: true;
444
+ verdict: "approve" | "request_changes" | "comment";
445
+ review: SubmittedPullRequestReview;
446
+ taskState: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
447
+ reason?: undefined;
378
448
  }>;
379
449
  };
380
450
  //#endregion
@@ -484,8 +554,8 @@ declare function recordVerificationTool(stores: FactoryStores): import("eve/tool
484
554
  } | {
485
555
  recorded: true;
486
556
  verdict: "pass" | "fail";
487
- changeState: "rolled_back" | "verifying" | "ready" | "merged" | "deployed" | "rolled_out" | "closed";
488
- taskState: "succeeded" | "failed" | "needs_human" | "queued" | "running" | "verifying" | "cancelled";
557
+ changeState: "verifying" | "ready" | "merged" | "deployed" | "rolled_out" | "rolled_back" | "closed";
558
+ taskState: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
489
559
  reason?: undefined;
490
560
  }> & {
491
561
  execute(input: {
@@ -511,8 +581,8 @@ declare function recordVerificationTool(stores: FactoryStores): import("eve/tool
511
581
  } | {
512
582
  recorded: true;
513
583
  verdict: "pass" | "fail";
514
- changeState: "rolled_back" | "verifying" | "ready" | "merged" | "deployed" | "rolled_out" | "closed";
515
- taskState: "succeeded" | "failed" | "needs_human" | "queued" | "running" | "verifying" | "cancelled";
584
+ changeState: "verifying" | "ready" | "merged" | "deployed" | "rolled_out" | "rolled_back" | "closed";
585
+ taskState: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
516
586
  reason?: undefined;
517
587
  }>;
518
588
  };
@@ -562,8 +632,9 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
562
632
  }, {
563
633
  schemaVersion: 1;
564
634
  id: string;
635
+ repositoryIds: string[];
565
636
  kind: string;
566
- state: "succeeded" | "failed" | "needs_human" | "queued" | "running" | "verifying" | "cancelled";
637
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
567
638
  origin: {
568
639
  signalId?: string | undefined;
569
640
  parentTaskId?: string | undefined;
@@ -576,7 +647,6 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
576
647
  attempt: number;
577
648
  createdAt: string;
578
649
  updatedAt: string;
579
- repositoryIds?: string[] | undefined;
580
650
  area?: string | undefined;
581
651
  approval?: "required" | "granted" | "denied" | undefined;
582
652
  dependsOn?: string[] | undefined;
@@ -604,8 +674,9 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
604
674
  }, ctx: import("eve/tools").ToolContext): Promise<{
605
675
  schemaVersion: 1;
606
676
  id: string;
677
+ repositoryIds: string[];
607
678
  kind: string;
608
- state: "succeeded" | "failed" | "needs_human" | "queued" | "running" | "verifying" | "cancelled";
679
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
609
680
  origin: {
610
681
  signalId?: string | undefined;
611
682
  parentTaskId?: string | undefined;
@@ -618,7 +689,6 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
618
689
  attempt: number;
619
690
  createdAt: string;
620
691
  updatedAt: string;
621
- repositoryIds?: string[] | undefined;
622
692
  area?: string | undefined;
623
693
  approval?: "required" | "granted" | "denied" | undefined;
624
694
  dependsOn?: string[] | undefined;
@@ -713,7 +783,7 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
713
783
  scopeMatches: boolean;
714
784
  previewUrl?: string | undefined;
715
785
  };
716
- state: "rolled_back" | "verifying" | "ready" | "merged" | "deployed" | "rolled_out" | "closed";
786
+ state: "verifying" | "ready" | "merged" | "deployed" | "rolled_out" | "rolled_back" | "closed";
717
787
  createdAt: string;
718
788
  updatedAt: string;
719
789
  taskId?: string | undefined;
@@ -724,8 +794,9 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
724
794
  task: {
725
795
  schemaVersion: 1;
726
796
  id: string;
797
+ repositoryIds: string[];
727
798
  kind: string;
728
- state: "succeeded" | "failed" | "needs_human" | "queued" | "running" | "verifying" | "cancelled";
799
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
729
800
  origin: {
730
801
  signalId?: string | undefined;
731
802
  parentTaskId?: string | undefined;
@@ -738,7 +809,6 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
738
809
  attempt: number;
739
810
  createdAt: string;
740
811
  updatedAt: string;
741
- repositoryIds?: string[] | undefined;
742
812
  area?: string | undefined;
743
813
  approval?: "required" | "granted" | "denied" | undefined;
744
814
  dependsOn?: string[] | undefined;
@@ -785,7 +855,7 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
785
855
  scopeMatches: boolean;
786
856
  previewUrl?: string | undefined;
787
857
  };
788
- state: "rolled_back" | "verifying" | "ready" | "merged" | "deployed" | "rolled_out" | "closed";
858
+ state: "verifying" | "ready" | "merged" | "deployed" | "rolled_out" | "rolled_back" | "closed";
789
859
  createdAt: string;
790
860
  updatedAt: string;
791
861
  taskId?: string | undefined;
@@ -796,8 +866,9 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
796
866
  task: {
797
867
  schemaVersion: 1;
798
868
  id: string;
869
+ repositoryIds: string[];
799
870
  kind: string;
800
- state: "succeeded" | "failed" | "needs_human" | "queued" | "running" | "verifying" | "cancelled";
871
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
801
872
  origin: {
802
873
  signalId?: string | undefined;
803
874
  parentTaskId?: string | undefined;
@@ -810,7 +881,6 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
810
881
  attempt: number;
811
882
  createdAt: string;
812
883
  updatedAt: string;
813
- repositoryIds?: string[] | undefined;
814
884
  area?: string | undefined;
815
885
  approval?: "required" | "granted" | "denied" | undefined;
816
886
  dependsOn?: string[] | undefined;
@@ -841,7 +911,7 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
841
911
  taskState?: undefined;
842
912
  } | {
843
913
  finished: true;
844
- taskState: "succeeded" | "failed" | "needs_human" | "queued" | "running" | "verifying" | "cancelled";
914
+ taskState: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
845
915
  reason?: undefined;
846
916
  }> & {
847
917
  execute(input: {
@@ -853,7 +923,7 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
853
923
  taskState?: undefined;
854
924
  } | {
855
925
  finished: true;
856
- taskState: "succeeded" | "failed" | "needs_human" | "queued" | "running" | "verifying" | "cancelled";
926
+ taskState: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
857
927
  reason?: undefined;
858
928
  }>;
859
929
  };
@@ -863,8 +933,9 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
863
933
  }, {
864
934
  schemaVersion: 1;
865
935
  id: string;
936
+ repositoryIds: string[];
866
937
  kind: string;
867
- state: "succeeded" | "failed" | "needs_human" | "queued" | "running" | "verifying" | "cancelled";
938
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
868
939
  origin: {
869
940
  signalId?: string | undefined;
870
941
  parentTaskId?: string | undefined;
@@ -877,7 +948,6 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
877
948
  attempt: number;
878
949
  createdAt: string;
879
950
  updatedAt: string;
880
- repositoryIds?: string[] | undefined;
881
951
  area?: string | undefined;
882
952
  approval?: "required" | "granted" | "denied" | undefined;
883
953
  dependsOn?: string[] | undefined;
@@ -903,8 +973,9 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
903
973
  }, ctx: import("eve/tools").ToolContext): Promise<{
904
974
  schemaVersion: 1;
905
975
  id: string;
976
+ repositoryIds: string[];
906
977
  kind: string;
907
- state: "succeeded" | "failed" | "needs_human" | "queued" | "running" | "verifying" | "cancelled";
978
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
908
979
  origin: {
909
980
  signalId?: string | undefined;
910
981
  parentTaskId?: string | undefined;
@@ -917,7 +988,6 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
917
988
  attempt: number;
918
989
  createdAt: string;
919
990
  updatedAt: string;
920
- repositoryIds?: string[] | undefined;
921
991
  area?: string | undefined;
922
992
  approval?: "required" | "granted" | "denied" | undefined;
923
993
  dependsOn?: string[] | undefined;
@@ -950,8 +1020,9 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
950
1020
  }, {
951
1021
  schemaVersion: 1;
952
1022
  id: string;
1023
+ repositoryIds: string[];
953
1024
  kind: string;
954
- state: "succeeded" | "failed" | "needs_human" | "queued" | "running" | "verifying" | "cancelled";
1025
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
955
1026
  origin: {
956
1027
  signalId?: string | undefined;
957
1028
  parentTaskId?: string | undefined;
@@ -964,7 +1035,6 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
964
1035
  attempt: number;
965
1036
  createdAt: string;
966
1037
  updatedAt: string;
967
- repositoryIds?: string[] | undefined;
968
1038
  area?: string | undefined;
969
1039
  approval?: "required" | "granted" | "denied" | undefined;
970
1040
  dependsOn?: string[] | undefined;
@@ -996,8 +1066,9 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
996
1066
  }, ctx: import("eve/tools").ToolContext): Promise<{
997
1067
  schemaVersion: 1;
998
1068
  id: string;
1069
+ repositoryIds: string[];
999
1070
  kind: string;
1000
- state: "succeeded" | "failed" | "needs_human" | "queued" | "running" | "verifying" | "cancelled";
1071
+ state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
1001
1072
  origin: {
1002
1073
  signalId?: string | undefined;
1003
1074
  parentTaskId?: string | undefined;
@@ -1010,7 +1081,6 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
1010
1081
  attempt: number;
1011
1082
  createdAt: string;
1012
1083
  updatedAt: string;
1013
- repositoryIds?: string[] | undefined;
1014
1084
  area?: string | undefined;
1015
1085
  approval?: "required" | "granted" | "denied" | undefined;
1016
1086
  dependsOn?: string[] | undefined;
@@ -1099,5 +1169,5 @@ declare function factoryHooks(stores: FactoryStores): {
1099
1169
  };
1100
1170
  type FactoryHooks = ReturnType<typeof factoryHooks>;
1101
1171
  //#endregion
1102
- export { type CommandSandbox, type DeepsecScanOptions, FactoryHooks, FactoryTools, FactoryToolsOptions, type FetchPullRequestOptions, type FetchPullRequestResult, GateVerdict, type InvokeAgentOptions, type MergeConflictPayload, type MergeConflictToolOptions, RecordChangeInput, type RecordFindingOptions, type RecordFindingResult, type ReviewCommentToolOptions, deepsecScanTool, factoryHooks, factoryTools, fetchPullRequestTool, findingFromDeepsec, invokeAgentTool, mergeConflictPayloadSchema, mergeConflictTools, recordFinding, recordFindingTool, recordVerificationTool, reviewCommentTools };
1172
+ export { type CommandSandbox, type DeepsecScanOptions, FactoryHooks, FactoryTools, FactoryToolsOptions, type FetchPullRequestOptions, type FetchPullRequestResult, GateVerdict, type InvokeAgentOptions, type MergeConflictPayload, type MergeConflictToolOptions, type PostReviewToolOptions, type PublishedReview, RecordChangeInput, type RecordFindingOptions, type RecordFindingResult, type ReviewCommentToolOptions, deepsecScanTool, factoryHooks, factoryTools, fetchPullRequestTool, findingFromDeepsec, invokeAgentTool, mergeConflictPayloadSchema, mergeConflictTools, postReviewTool, recordFinding, recordFindingTool, recordVerificationTool, reviewCommentTools };
1103
1173
  //# sourceMappingURL=index.d.mts.map
@@ -1,6 +1,7 @@
1
1
  import { i as repositoryIdSchema, o as signalIdSchema, p as vocabularySchema, s as taskIdSchema, t as changeIdSchema } from "../id-DwCihQr4.mjs";
2
- import { S as findingFingerprint, b as requiresApproval, g as dispatchTask, p as levelSchema, s as taskQuestionSchema, u as changeEvidenceSchema, w as findingSchema, y as defaultApprovalPolicy } from "../task-BxTU3MJb.mjs";
3
- import { answerReviewComment, readPullRequestHead, readReviewComment } from "../github.mjs";
2
+ import { c as findingSchema, i as requiresApproval, o as findingFingerprint, r as defaultApprovalPolicy } from "../approval-DdvEKLiE.mjs";
3
+ import { g as taskQuestionSchema, i as levelSchema, s as dispatchTask, t as changeEvidenceSchema } from "../change-BPYhWKuL.mjs";
4
+ import { answerReviewComment, readPullRequestHead, readReviewComment, submitPullRequestReview } from "../github.mjs";
4
5
  import { z } from "zod";
5
6
  import { defineHook } from "eve/hooks";
6
7
  import { defineTool } from "eve/tools";
@@ -474,6 +475,86 @@ function invokeAgentTool(stores, options) {
474
475
  });
475
476
  }
476
477
  //#endregion
478
+ //#region src/eve/post-review.ts
479
+ const reviewCommentSchema = z.strictObject({
480
+ path: z.string().min(1).max(500).describe("Repository-relative file path."),
481
+ line: z.number().int().min(1).describe("Line in the pull request's new version."),
482
+ body: z.string().min(1).max(5e3).describe("Markdown explaining the finding and a concrete fix.")
483
+ });
484
+ /**
485
+ * Publish an independent review of an existing pull request and finish the
486
+ * review task without changing the pull request's factory lifecycle.
487
+ */
488
+ function postReviewTool(stores, options) {
489
+ return defineTool({
490
+ description: "Publish a completed code review to the existing pull request and finish your code_review task. Use request_changes only for blocking findings.",
491
+ inputSchema: z.object({
492
+ taskId: taskIdSchema.describe("Your code_review task."),
493
+ changeId: changeIdSchema.describe("The pull request change from your starting message."),
494
+ verdict: z.enum([
495
+ "approve",
496
+ "request_changes",
497
+ "comment"
498
+ ]),
499
+ headSha: z.string().regex(/^[0-9a-f]{40}$/).describe("Commit returned by fetch_pull_request."),
500
+ summary: z.string().min(1).max(5e3).describe("Markdown summary of what you reviewed and found."),
501
+ comments: z.array(reviewCommentSchema).max(50).default([])
502
+ }),
503
+ async execute({ taskId, changeId, verdict, headSha, summary, comments }) {
504
+ const task = await stores.tasks.get(taskId);
505
+ if (task === null || task.kind !== "code_review") return {
506
+ recorded: false,
507
+ reason: `${taskId} is not a code_review task`
508
+ };
509
+ if (task.state !== "running") return {
510
+ recorded: false,
511
+ reason: `task is ${task.state}, not running`
512
+ };
513
+ const change = await stores.changes.get(changeId);
514
+ if (change === null) return {
515
+ recorded: false,
516
+ reason: `change ${changeId} does not exist`
517
+ };
518
+ if (change.state !== "verifying" && change.state !== "ready") return {
519
+ recorded: false,
520
+ reason: `change is ${change.state}, not open for review`
521
+ };
522
+ const repository = await stores.repositories.get(change.repositoryId);
523
+ if (repository === null) return {
524
+ recorded: false,
525
+ reason: `repository ${change.repositoryId} does not exist`
526
+ };
527
+ const review = await submitPullRequestReview({
528
+ repository: repository.slug,
529
+ token: await options.tokenForRepository(repository.slug),
530
+ fetch: options.fetch,
531
+ pullRequestNumber: change.prNumber,
532
+ commitId: headSha,
533
+ event: verdict === "approve" ? "APPROVE" : verdict === "request_changes" ? "REQUEST_CHANGES" : "COMMENT",
534
+ body: summary,
535
+ comments
536
+ });
537
+ await options.onPublished?.({
538
+ taskId,
539
+ changeId,
540
+ repository: repository.slug,
541
+ headSha,
542
+ verdict,
543
+ summary,
544
+ comments,
545
+ review
546
+ });
547
+ await stores.tasks.transition(taskId, "verifying", { reason: summary });
548
+ return {
549
+ recorded: true,
550
+ verdict,
551
+ review,
552
+ taskState: (await stores.tasks.transition(taskId, "succeeded")).state
553
+ };
554
+ }
555
+ });
556
+ }
557
+ //#endregion
477
558
  //#region src/eve/review.ts
478
559
  function reviewCommentTools(stores, options) {
479
560
  const repoPath = options.repoPath ?? "repo";
@@ -848,6 +929,6 @@ function factoryHooks(stores) {
848
929
  } } }) };
849
930
  }
850
931
  //#endregion
851
- export { deepsecScanTool, factoryHooks, factoryTools, fetchPullRequestTool, findingFromDeepsec, invokeAgentTool, mergeConflictPayloadSchema, mergeConflictTools, recordFinding, recordFindingTool, recordVerificationTool, reviewCommentTools };
932
+ export { deepsecScanTool, factoryHooks, factoryTools, fetchPullRequestTool, findingFromDeepsec, invokeAgentTool, mergeConflictPayloadSchema, mergeConflictTools, postReviewTool, recordFinding, recordFindingTool, recordVerificationTool, reviewCommentTools };
852
933
 
853
934
  //# sourceMappingURL=index.mjs.map