@vercel/factory 0.0.11 → 0.0.13

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.
Files changed (33) hide show
  1. package/dist/approval-CwhTP1XB.mjs +269 -0
  2. package/dist/approval-CwhTP1XB.mjs.map +1 -0
  3. package/dist/blob/index.d.mts +1 -1
  4. package/dist/build-factory.d.mts +1 -1
  5. package/dist/build-factory.mjs +1 -1
  6. package/dist/change-CzEAoFVE.mjs +620 -0
  7. package/dist/change-CzEAoFVE.mjs.map +1 -0
  8. package/dist/connectors/slack.d.mts +4 -4
  9. package/dist/connectors/slack.mjs +81 -30
  10. package/dist/connectors/slack.mjs.map +1 -1
  11. package/dist/{approval-CDiBco2V.d.mts → dispatch-B77cuPxh.d.mts} +293 -99
  12. package/dist/{driver-CrZsy7sm.d.mts → driver-BJutB0PE.d.mts} +2 -2
  13. package/dist/driver-Bbd25rNM.mjs.map +1 -1
  14. package/dist/eve/index.d.mts +546 -120
  15. package/dist/eve/index.mjs +358 -82
  16. package/dist/eve/index.mjs.map +1 -1
  17. package/dist/{factory-config-ifd3JxiU.mjs → factory-config-BJcjsPKl.mjs} +42 -5
  18. package/dist/factory-config-BJcjsPKl.mjs.map +1 -0
  19. package/dist/{factory-config-Bu4mklm9.d.mts → factory-config-D2yU3G0c.d.mts} +21 -2
  20. package/dist/{github-wThBfbm-.d.mts → github-DXsxboUL.d.mts} +25 -2
  21. package/dist/github.d.mts +2 -2
  22. package/dist/github.mjs +47 -1
  23. package/dist/github.mjs.map +1 -1
  24. package/dist/index.d.mts +129 -59
  25. package/dist/index.mjs +336 -333
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/postgres/index.d.mts +1 -1
  28. package/package.json +1 -1
  29. package/dist/approval-DdvEKLiE.mjs +0 -132
  30. package/dist/approval-DdvEKLiE.mjs.map +0 -1
  31. package/dist/change-BPYhWKuL.mjs +0 -230
  32. package/dist/change-BPYhWKuL.mjs.map +0 -1
  33. package/dist/factory-config-ifd3JxiU.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { A as FactoryStores, P as Task, 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";
1
+ import { H as FactoryStores, f as ApprovalPolicy, l as AgentRouteRegistry, r as DispatchBudget, s as AgentRoute, y as Finding, zt as Task } from "../dispatch-B77cuPxh.mjs";
2
+ import { O as PullRequestReviewComment, P as SubmittedPullRequestReview, S as GitHubReviewComment } from "../github-DXsxboUL.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. */
@@ -38,6 +38,10 @@ type FetchPullRequestResult = {
38
38
  prUrl: string;
39
39
  branch: string;
40
40
  headSha: string;
41
+ baseBranch: string;
42
+ baseSha: string;
43
+ mergeBaseSha: string;
44
+ diffCommand: string;
41
45
  };
42
46
  /**
43
47
  * The verifier's way in to the change under review. The sandbox has no
@@ -342,6 +346,19 @@ interface InvokeAgentOptions {
342
346
  token?: () => Promise<string | undefined>;
343
347
  /** Extra headers for the session request, e.g. a deployment protection bypass. */
344
348
  headers?: (task: Task) => Record<string, string> | Promise<Record<string, string>>;
349
+ /**
350
+ * Reserve-before-execution limits for the handoff dispatch, resolved at
351
+ * call time. Without it, handoff tasks run outside the budget.
352
+ */
353
+ budget?: () => DispatchBudget | undefined;
354
+ fetch?: typeof fetch;
355
+ }
356
+ interface DelegateAgentOptions {
357
+ routes: AgentRouteRegistry;
358
+ targetUrl: (route: AgentRoute) => string;
359
+ token?: (route: AgentRoute) => Promise<string | undefined>;
360
+ headers?: (task: Task, route: AgentRoute) => Record<string, string> | Promise<Record<string, string>>;
361
+ budget?: (route: AgentRoute) => DispatchBudget | undefined;
345
362
  fetch?: typeof fetch;
346
363
  }
347
364
  /**
@@ -362,7 +379,7 @@ declare function invokeAgentTool(stores: FactoryStores, options: InvokeAgentOpti
362
379
  }, {
363
380
  taskId: string;
364
381
  kind: string;
365
- state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
382
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
366
383
  }> & {
367
384
  execute(input: {
368
385
  repositoryIds: string[];
@@ -374,23 +391,83 @@ declare function invokeAgentTool(stores: FactoryStores, options: InvokeAgentOpti
374
391
  }, ctx: import("eve/tools").ToolContext): Promise<{
375
392
  taskId: string;
376
393
  kind: string;
377
- state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
394
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
395
+ }>;
396
+ };
397
+ /**
398
+ * Give a conversational agent one bounded delegation surface backed by the
399
+ * application's route registry. The caller selects a declared route; trusted
400
+ * code owns task creation, budget enforcement, and the fresh target session.
401
+ */
402
+ declare function delegateAgentTool(stores: FactoryStores, options: DelegateAgentOptions): import("eve/tools").ToolDefinition<{
403
+ routeId: string;
404
+ repositoryIds: string[];
405
+ channel: string;
406
+ address: string;
407
+ brief: string;
408
+ signalId?: string | undefined;
409
+ parentTaskId?: string | undefined;
410
+ changeId?: string | undefined;
411
+ }, {
412
+ taskId: string;
413
+ childTaskIds: string[];
414
+ routeId: string;
415
+ agent: string;
416
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
417
+ } | {
418
+ taskId: string;
419
+ routeId: string;
420
+ agent: string;
421
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
422
+ childTaskIds?: undefined;
423
+ }> & {
424
+ execute(input: {
425
+ routeId: string;
426
+ repositoryIds: string[];
427
+ channel: string;
428
+ address: string;
429
+ brief: string;
430
+ signalId?: string | undefined;
431
+ parentTaskId?: string | undefined;
432
+ changeId?: string | undefined;
433
+ }, ctx: import("eve/tools").ToolContext): Promise<{
434
+ taskId: string;
435
+ childTaskIds: string[];
436
+ routeId: string;
437
+ agent: string;
438
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
439
+ } | {
440
+ taskId: string;
441
+ routeId: string;
442
+ agent: string;
443
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
444
+ childTaskIds?: undefined;
378
445
  }>;
379
446
  };
380
447
  //#endregion
381
448
  //#region src/eve/post-review.d.ts
382
- interface PublishedReview {
449
+ interface CompletedReview {
383
450
  taskId: string;
384
451
  changeId: string;
385
452
  repository: string;
453
+ pullRequestNumber: number;
386
454
  headSha: string;
387
455
  verdict: "approve" | "request_changes" | "comment";
388
456
  summary: string;
389
- comments: readonly PullRequestReviewComment[];
457
+ comments: readonly CompletedReviewFinding[];
458
+ }
459
+ interface CompletedReviewFinding extends PullRequestReviewComment {
460
+ fingerprint: string;
461
+ key: string;
462
+ title: string;
463
+ }
464
+ interface PublishedReview extends CompletedReview {
390
465
  review: SubmittedPullRequestReview;
391
466
  }
392
467
  interface PostReviewToolOptions {
393
468
  tokenForRepository: (repository: string) => Promise<string>;
469
+ publishReviews?: boolean;
470
+ onCompleted?: (completed: CompletedReview) => Promise<void>;
394
471
  onPublished?: (published: PublishedReview) => Promise<void>;
395
472
  fetch?: typeof globalThis.fetch;
396
473
  }
@@ -408,18 +485,18 @@ declare function postReviewTool(stores: FactoryStores, options: PostReviewToolOp
408
485
  path: string;
409
486
  line: number;
410
487
  body: string;
488
+ key?: string | undefined;
489
+ title?: string | undefined;
411
490
  }[];
412
491
  }, {
413
492
  recorded: false;
414
493
  reason: string;
415
- verdict?: undefined;
416
- review?: undefined;
417
- taskState?: undefined;
418
494
  } | {
495
+ taskState: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
496
+ review?: SubmittedPullRequestReview | undefined;
419
497
  recorded: true;
420
498
  verdict: "approve" | "request_changes" | "comment";
421
- review: SubmittedPullRequestReview;
422
- taskState: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
499
+ published: boolean;
423
500
  reason?: undefined;
424
501
  }> & {
425
502
  execute(input: {
@@ -432,18 +509,18 @@ declare function postReviewTool(stores: FactoryStores, options: PostReviewToolOp
432
509
  path: string;
433
510
  line: number;
434
511
  body: string;
512
+ key?: string | undefined;
513
+ title?: string | undefined;
435
514
  }[];
436
515
  }, ctx: import("eve/tools").ToolContext): Promise<{
437
516
  recorded: false;
438
517
  reason: string;
439
- verdict?: undefined;
440
- review?: undefined;
441
- taskState?: undefined;
442
518
  } | {
519
+ taskState: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
520
+ review?: SubmittedPullRequestReview | undefined;
443
521
  recorded: true;
444
522
  verdict: "approve" | "request_changes" | "comment";
445
- review: SubmittedPullRequestReview;
446
- taskState: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
523
+ published: boolean;
447
524
  reason?: undefined;
448
525
  }>;
449
526
  };
@@ -521,6 +598,14 @@ declare function reviewCommentTools<S extends CommandSandbox>(stores: FactorySto
521
598
  };
522
599
  //#endregion
523
600
  //#region src/eve/verification.d.ts
601
+ interface RecordVerificationOptions {
602
+ presentResult?: (input: {
603
+ taskId: string;
604
+ changeId: string;
605
+ verdict: "pass" | "fail";
606
+ summary: string;
607
+ }) => Promise<void>;
608
+ }
524
609
  /**
525
610
  * The verifier's outcome tool. Writes evidence onto the change and moves it
526
611
  * to ready only when the verdict is pass; a failed verdict leaves the change
@@ -531,7 +616,7 @@ declare function reviewCommentTools<S extends CommandSandbox>(stores: FactorySto
531
616
  * as still in progress. Fail closed: the agent cannot mark a change ready
532
617
  * without supplying every evidence field.
533
618
  */
534
- declare function recordVerificationTool(stores: FactoryStores): import("eve/tools").ToolDefinition<{
619
+ declare function recordVerificationTool(stores: FactoryStores, options?: RecordVerificationOptions): import("eve/tools").ToolDefinition<{
535
620
  taskId: string;
536
621
  changeId: string;
537
622
  verdict: "pass" | "fail";
@@ -555,7 +640,7 @@ declare function recordVerificationTool(stores: FactoryStores): import("eve/tool
555
640
  recorded: true;
556
641
  verdict: "pass" | "fail";
557
642
  changeState: "verifying" | "ready" | "merged" | "deployed" | "rolled_out" | "rolled_back" | "closed";
558
- taskState: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
643
+ taskState: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
559
644
  reason?: undefined;
560
645
  }> & {
561
646
  execute(input: {
@@ -582,7 +667,7 @@ declare function recordVerificationTool(stores: FactoryStores): import("eve/tool
582
667
  recorded: true;
583
668
  verdict: "pass" | "fail";
584
669
  changeState: "verifying" | "ready" | "merged" | "deployed" | "rolled_out" | "rolled_back" | "closed";
585
- taskState: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
670
+ taskState: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
586
671
  reason?: undefined;
587
672
  }>;
588
673
  };
@@ -619,7 +704,19 @@ interface FactoryToolsOptions {
619
704
  * Gates must fail closed: when they cannot verify, they refuse.
620
705
  */
621
706
  recordChangeGate?: (input: RecordChangeInput) => Promise<GateVerdict>;
707
+ /** Whether recorded code changes wait for an independent verification task. Default: required. */
708
+ verification?: "required" | "disabled";
709
+ /** Present the pull request after record_change persists its durable state. */
710
+ presentChange?: (input: {
711
+ taskId: string;
712
+ changeId: string;
713
+ verification: "required" | "disabled";
714
+ summary: string;
715
+ }) => Promise<void>;
716
+ /** Present a persisted human question through the application's Foreman communication boundary. */
717
+ presentQuestion?: (task: Task) => Promise<void>;
622
718
  }
719
+ type PresentQuestion = NonNullable<FactoryToolsOptions["presentQuestion"]>;
623
720
  /**
624
721
  * The factory's store operations wrapped as eve tools. Expose a tool to an
625
722
  * agent by re-exporting it from a file under agent/tools/, e.g.
@@ -634,7 +731,7 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
634
731
  id: string;
635
732
  repositoryIds: string[];
636
733
  kind: string;
637
- state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
734
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
638
735
  origin: {
639
736
  signalId?: string | undefined;
640
737
  parentTaskId?: string | undefined;
@@ -650,12 +747,26 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
650
747
  area?: string | undefined;
651
748
  approval?: "required" | "granted" | "denied" | undefined;
652
749
  dependsOn?: string[] | undefined;
653
- devbox?: {
654
- devboxId: string;
655
- remoteId: string;
656
- harness: string;
750
+ execution?: {
751
+ provider: string;
752
+ sessionId: string;
753
+ environmentId?: string | undefined;
754
+ harness?: string | undefined;
755
+ traceId?: string | undefined;
657
756
  } | undefined;
757
+ lastProgressAt?: string | undefined;
758
+ stalledAt?: string | undefined;
759
+ stalledReason?: string | undefined;
658
760
  reservedUsd?: number | undefined;
761
+ reservedAt?: string | undefined;
762
+ usage?: {
763
+ costUsd: number;
764
+ inputTokens: number;
765
+ outputTokens: number;
766
+ cacheReadTokens: number;
767
+ cacheWriteTokens: number;
768
+ steps: Record<string, number>;
769
+ } | undefined;
659
770
  settledUsd?: number | undefined;
660
771
  question?: {
661
772
  text: string;
@@ -676,7 +787,7 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
676
787
  id: string;
677
788
  repositoryIds: string[];
678
789
  kind: string;
679
- state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
790
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
680
791
  origin: {
681
792
  signalId?: string | undefined;
682
793
  parentTaskId?: string | undefined;
@@ -692,12 +803,26 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
692
803
  area?: string | undefined;
693
804
  approval?: "required" | "granted" | "denied" | undefined;
694
805
  dependsOn?: string[] | undefined;
695
- devbox?: {
696
- devboxId: string;
697
- remoteId: string;
698
- harness: string;
806
+ execution?: {
807
+ provider: string;
808
+ sessionId: string;
809
+ environmentId?: string | undefined;
810
+ harness?: string | undefined;
811
+ traceId?: string | undefined;
699
812
  } | undefined;
813
+ lastProgressAt?: string | undefined;
814
+ stalledAt?: string | undefined;
815
+ stalledReason?: string | undefined;
700
816
  reservedUsd?: number | undefined;
817
+ reservedAt?: string | undefined;
818
+ usage?: {
819
+ costUsd: number;
820
+ inputTokens: number;
821
+ outputTokens: number;
822
+ cacheReadTokens: number;
823
+ cacheWriteTokens: number;
824
+ steps: Record<string, number>;
825
+ } | undefined;
701
826
  settledUsd?: number | undefined;
702
827
  question?: {
703
828
  text: string;
@@ -796,7 +921,7 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
796
921
  id: string;
797
922
  repositoryIds: string[];
798
923
  kind: string;
799
- state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
924
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
800
925
  origin: {
801
926
  signalId?: string | undefined;
802
927
  parentTaskId?: string | undefined;
@@ -812,12 +937,26 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
812
937
  area?: string | undefined;
813
938
  approval?: "required" | "granted" | "denied" | undefined;
814
939
  dependsOn?: string[] | undefined;
815
- devbox?: {
816
- devboxId: string;
817
- remoteId: string;
818
- harness: string;
940
+ execution?: {
941
+ provider: string;
942
+ sessionId: string;
943
+ environmentId?: string | undefined;
944
+ harness?: string | undefined;
945
+ traceId?: string | undefined;
819
946
  } | undefined;
947
+ lastProgressAt?: string | undefined;
948
+ stalledAt?: string | undefined;
949
+ stalledReason?: string | undefined;
820
950
  reservedUsd?: number | undefined;
951
+ reservedAt?: string | undefined;
952
+ usage?: {
953
+ costUsd: number;
954
+ inputTokens: number;
955
+ outputTokens: number;
956
+ cacheReadTokens: number;
957
+ cacheWriteTokens: number;
958
+ steps: Record<string, number>;
959
+ } | undefined;
821
960
  settledUsd?: number | undefined;
822
961
  question?: {
823
962
  text: string;
@@ -868,7 +1007,7 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
868
1007
  id: string;
869
1008
  repositoryIds: string[];
870
1009
  kind: string;
871
- state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
1010
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
872
1011
  origin: {
873
1012
  signalId?: string | undefined;
874
1013
  parentTaskId?: string | undefined;
@@ -884,12 +1023,26 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
884
1023
  area?: string | undefined;
885
1024
  approval?: "required" | "granted" | "denied" | undefined;
886
1025
  dependsOn?: string[] | undefined;
887
- devbox?: {
888
- devboxId: string;
889
- remoteId: string;
890
- harness: string;
1026
+ execution?: {
1027
+ provider: string;
1028
+ sessionId: string;
1029
+ environmentId?: string | undefined;
1030
+ harness?: string | undefined;
1031
+ traceId?: string | undefined;
891
1032
  } | undefined;
1033
+ lastProgressAt?: string | undefined;
1034
+ stalledAt?: string | undefined;
1035
+ stalledReason?: string | undefined;
892
1036
  reservedUsd?: number | undefined;
1037
+ reservedAt?: string | undefined;
1038
+ usage?: {
1039
+ costUsd: number;
1040
+ inputTokens: number;
1041
+ outputTokens: number;
1042
+ cacheReadTokens: number;
1043
+ cacheWriteTokens: number;
1044
+ steps: Record<string, number>;
1045
+ } | undefined;
893
1046
  settledUsd?: number | undefined;
894
1047
  question?: {
895
1048
  text: string;
@@ -911,7 +1064,7 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
911
1064
  taskState?: undefined;
912
1065
  } | {
913
1066
  finished: true;
914
- taskState: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
1067
+ taskState: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
915
1068
  reason?: undefined;
916
1069
  }> & {
917
1070
  execute(input: {
@@ -923,19 +1076,22 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
923
1076
  taskState?: undefined;
924
1077
  } | {
925
1078
  finished: true;
926
- taskState: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
1079
+ taskState: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
927
1080
  reason?: undefined;
928
1081
  }>;
929
1082
  };
930
- report_blocked: import("eve/tools").ToolDefinition<{
931
- taskId: string;
932
- reason: string;
1083
+ request_human_input: import("eve/tools").ToolDefinition<{
1084
+ parentTaskId: string;
1085
+ question: {
1086
+ text: string;
1087
+ options: string[];
1088
+ };
933
1089
  }, {
934
1090
  schemaVersion: 1;
935
1091
  id: string;
936
1092
  repositoryIds: string[];
937
1093
  kind: string;
938
- state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
1094
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
939
1095
  origin: {
940
1096
  signalId?: string | undefined;
941
1097
  parentTaskId?: string | undefined;
@@ -951,12 +1107,26 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
951
1107
  area?: string | undefined;
952
1108
  approval?: "required" | "granted" | "denied" | undefined;
953
1109
  dependsOn?: string[] | undefined;
954
- devbox?: {
955
- devboxId: string;
956
- remoteId: string;
957
- harness: string;
1110
+ execution?: {
1111
+ provider: string;
1112
+ sessionId: string;
1113
+ environmentId?: string | undefined;
1114
+ harness?: string | undefined;
1115
+ traceId?: string | undefined;
958
1116
  } | undefined;
1117
+ lastProgressAt?: string | undefined;
1118
+ stalledAt?: string | undefined;
1119
+ stalledReason?: string | undefined;
959
1120
  reservedUsd?: number | undefined;
1121
+ reservedAt?: string | undefined;
1122
+ usage?: {
1123
+ costUsd: number;
1124
+ inputTokens: number;
1125
+ outputTokens: number;
1126
+ cacheReadTokens: number;
1127
+ cacheWriteTokens: number;
1128
+ steps: Record<string, number>;
1129
+ } | undefined;
960
1130
  settledUsd?: number | undefined;
961
1131
  question?: {
962
1132
  text: string;
@@ -968,14 +1138,17 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
968
1138
  reportRef?: string | undefined;
969
1139
  }> & {
970
1140
  execute(input: {
971
- taskId: string;
972
- reason: string;
1141
+ parentTaskId: string;
1142
+ question: {
1143
+ text: string;
1144
+ options: string[];
1145
+ };
973
1146
  }, ctx: import("eve/tools").ToolContext): Promise<{
974
1147
  schemaVersion: 1;
975
1148
  id: string;
976
1149
  repositoryIds: string[];
977
1150
  kind: string;
978
- state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
1151
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
979
1152
  origin: {
980
1153
  signalId?: string | undefined;
981
1154
  parentTaskId?: string | undefined;
@@ -991,12 +1164,26 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
991
1164
  area?: string | undefined;
992
1165
  approval?: "required" | "granted" | "denied" | undefined;
993
1166
  dependsOn?: string[] | undefined;
994
- devbox?: {
995
- devboxId: string;
996
- remoteId: string;
997
- harness: string;
1167
+ execution?: {
1168
+ provider: string;
1169
+ sessionId: string;
1170
+ environmentId?: string | undefined;
1171
+ harness?: string | undefined;
1172
+ traceId?: string | undefined;
998
1173
  } | undefined;
1174
+ lastProgressAt?: string | undefined;
1175
+ stalledAt?: string | undefined;
1176
+ stalledReason?: string | undefined;
999
1177
  reservedUsd?: number | undefined;
1178
+ reservedAt?: string | undefined;
1179
+ usage?: {
1180
+ costUsd: number;
1181
+ inputTokens: number;
1182
+ outputTokens: number;
1183
+ cacheReadTokens: number;
1184
+ cacheWriteTokens: number;
1185
+ steps: Record<string, number>;
1186
+ } | undefined;
1000
1187
  settledUsd?: number | undefined;
1001
1188
  question?: {
1002
1189
  text: string;
@@ -1008,67 +1195,120 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
1008
1195
  reportRef?: string | undefined;
1009
1196
  }>;
1010
1197
  };
1011
- ask_question: import("eve/tools").ToolDefinition<{
1012
- repositoryIds: string[];
1013
- channel: string;
1014
- address: string;
1015
- question: {
1016
- text: string;
1017
- options: string[];
1018
- };
1019
- parentTaskId?: string | undefined;
1198
+ answer_question: import("eve/tools").ToolDefinition<{
1199
+ questionTaskId: string;
1200
+ answer: string;
1020
1201
  }, {
1021
- schemaVersion: 1;
1022
- id: string;
1023
- repositoryIds: string[];
1024
- kind: string;
1025
- state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
1026
- origin: {
1027
- signalId?: string | undefined;
1028
- parentTaskId?: string | undefined;
1029
- operator?: string | undefined;
1030
- };
1031
- replyTo: {
1032
- channel: string;
1033
- address: string;
1034
- };
1035
- attempt: number;
1036
- createdAt: string;
1037
- updatedAt: string;
1038
- area?: string | undefined;
1039
- approval?: "required" | "granted" | "denied" | undefined;
1040
- dependsOn?: string[] | undefined;
1041
- devbox?: {
1042
- devboxId: string;
1043
- remoteId: string;
1044
- harness: string;
1045
- } | undefined;
1046
- reservedUsd?: number | undefined;
1047
- settledUsd?: number | undefined;
1048
- question?: {
1049
- text: string;
1050
- options: string[];
1051
- answer?: string | undefined;
1052
- answeredBy?: string | undefined;
1053
- } | undefined;
1054
- changeId?: string | undefined;
1055
- reportRef?: string | undefined;
1056
- }> & {
1057
- execute(input: {
1202
+ questionTask: {
1203
+ schemaVersion: 1;
1204
+ id: string;
1058
1205
  repositoryIds: string[];
1059
- channel: string;
1060
- address: string;
1061
- question: {
1206
+ kind: string;
1207
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
1208
+ origin: {
1209
+ signalId?: string | undefined;
1210
+ parentTaskId?: string | undefined;
1211
+ operator?: string | undefined;
1212
+ };
1213
+ replyTo: {
1214
+ channel: string;
1215
+ address: string;
1216
+ };
1217
+ attempt: number;
1218
+ createdAt: string;
1219
+ updatedAt: string;
1220
+ area?: string | undefined;
1221
+ approval?: "required" | "granted" | "denied" | undefined;
1222
+ dependsOn?: string[] | undefined;
1223
+ execution?: {
1224
+ provider: string;
1225
+ sessionId: string;
1226
+ environmentId?: string | undefined;
1227
+ harness?: string | undefined;
1228
+ traceId?: string | undefined;
1229
+ } | undefined;
1230
+ lastProgressAt?: string | undefined;
1231
+ stalledAt?: string | undefined;
1232
+ stalledReason?: string | undefined;
1233
+ reservedUsd?: number | undefined;
1234
+ reservedAt?: string | undefined;
1235
+ usage?: {
1236
+ costUsd: number;
1237
+ inputTokens: number;
1238
+ outputTokens: number;
1239
+ cacheReadTokens: number;
1240
+ cacheWriteTokens: number;
1241
+ steps: Record<string, number>;
1242
+ } | undefined;
1243
+ settledUsd?: number | undefined;
1244
+ question?: {
1062
1245
  text: string;
1063
1246
  options: string[];
1247
+ answer?: string | undefined;
1248
+ answeredBy?: string | undefined;
1249
+ } | undefined;
1250
+ changeId?: string | undefined;
1251
+ reportRef?: string | undefined;
1252
+ };
1253
+ parentTask: null;
1254
+ } | {
1255
+ questionTask: {
1256
+ schemaVersion: 1;
1257
+ id: string;
1258
+ repositoryIds: string[];
1259
+ kind: string;
1260
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
1261
+ origin: {
1262
+ signalId?: string | undefined;
1263
+ parentTaskId?: string | undefined;
1264
+ operator?: string | undefined;
1064
1265
  };
1065
- parentTaskId?: string | undefined;
1066
- }, ctx: import("eve/tools").ToolContext): Promise<{
1266
+ replyTo: {
1267
+ channel: string;
1268
+ address: string;
1269
+ };
1270
+ attempt: number;
1271
+ createdAt: string;
1272
+ updatedAt: string;
1273
+ area?: string | undefined;
1274
+ approval?: "required" | "granted" | "denied" | undefined;
1275
+ dependsOn?: string[] | undefined;
1276
+ execution?: {
1277
+ provider: string;
1278
+ sessionId: string;
1279
+ environmentId?: string | undefined;
1280
+ harness?: string | undefined;
1281
+ traceId?: string | undefined;
1282
+ } | undefined;
1283
+ lastProgressAt?: string | undefined;
1284
+ stalledAt?: string | undefined;
1285
+ stalledReason?: string | undefined;
1286
+ reservedUsd?: number | undefined;
1287
+ reservedAt?: string | undefined;
1288
+ usage?: {
1289
+ costUsd: number;
1290
+ inputTokens: number;
1291
+ outputTokens: number;
1292
+ cacheReadTokens: number;
1293
+ cacheWriteTokens: number;
1294
+ steps: Record<string, number>;
1295
+ } | undefined;
1296
+ settledUsd?: number | undefined;
1297
+ question?: {
1298
+ text: string;
1299
+ options: string[];
1300
+ answer?: string | undefined;
1301
+ answeredBy?: string | undefined;
1302
+ } | undefined;
1303
+ changeId?: string | undefined;
1304
+ reportRef?: string | undefined;
1305
+ };
1306
+ parentTask: {
1067
1307
  schemaVersion: 1;
1068
1308
  id: string;
1069
1309
  repositoryIds: string[];
1070
1310
  kind: string;
1071
- state: "queued" | "running" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
1311
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
1072
1312
  origin: {
1073
1313
  signalId?: string | undefined;
1074
1314
  parentTaskId?: string | undefined;
@@ -1084,12 +1324,26 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
1084
1324
  area?: string | undefined;
1085
1325
  approval?: "required" | "granted" | "denied" | undefined;
1086
1326
  dependsOn?: string[] | undefined;
1087
- devbox?: {
1088
- devboxId: string;
1089
- remoteId: string;
1090
- harness: string;
1327
+ execution?: {
1328
+ provider: string;
1329
+ sessionId: string;
1330
+ environmentId?: string | undefined;
1331
+ harness?: string | undefined;
1332
+ traceId?: string | undefined;
1091
1333
  } | undefined;
1334
+ lastProgressAt?: string | undefined;
1335
+ stalledAt?: string | undefined;
1336
+ stalledReason?: string | undefined;
1092
1337
  reservedUsd?: number | undefined;
1338
+ reservedAt?: string | undefined;
1339
+ usage?: {
1340
+ costUsd: number;
1341
+ inputTokens: number;
1342
+ outputTokens: number;
1343
+ cacheReadTokens: number;
1344
+ cacheWriteTokens: number;
1345
+ steps: Record<string, number>;
1346
+ } | undefined;
1093
1347
  settledUsd?: number | undefined;
1094
1348
  question?: {
1095
1349
  text: string;
@@ -1099,6 +1353,167 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
1099
1353
  } | undefined;
1100
1354
  changeId?: string | undefined;
1101
1355
  reportRef?: string | undefined;
1356
+ };
1357
+ }> & {
1358
+ execute(input: {
1359
+ questionTaskId: string;
1360
+ answer: string;
1361
+ }, ctx: import("eve/tools").ToolContext): Promise<{
1362
+ questionTask: {
1363
+ schemaVersion: 1;
1364
+ id: string;
1365
+ repositoryIds: string[];
1366
+ kind: string;
1367
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
1368
+ origin: {
1369
+ signalId?: string | undefined;
1370
+ parentTaskId?: string | undefined;
1371
+ operator?: string | undefined;
1372
+ };
1373
+ replyTo: {
1374
+ channel: string;
1375
+ address: string;
1376
+ };
1377
+ attempt: number;
1378
+ createdAt: string;
1379
+ updatedAt: string;
1380
+ area?: string | undefined;
1381
+ approval?: "required" | "granted" | "denied" | undefined;
1382
+ dependsOn?: string[] | undefined;
1383
+ execution?: {
1384
+ provider: string;
1385
+ sessionId: string;
1386
+ environmentId?: string | undefined;
1387
+ harness?: string | undefined;
1388
+ traceId?: string | undefined;
1389
+ } | undefined;
1390
+ lastProgressAt?: string | undefined;
1391
+ stalledAt?: string | undefined;
1392
+ stalledReason?: string | undefined;
1393
+ reservedUsd?: number | undefined;
1394
+ reservedAt?: string | undefined;
1395
+ usage?: {
1396
+ costUsd: number;
1397
+ inputTokens: number;
1398
+ outputTokens: number;
1399
+ cacheReadTokens: number;
1400
+ cacheWriteTokens: number;
1401
+ steps: Record<string, number>;
1402
+ } | undefined;
1403
+ settledUsd?: number | undefined;
1404
+ question?: {
1405
+ text: string;
1406
+ options: string[];
1407
+ answer?: string | undefined;
1408
+ answeredBy?: string | undefined;
1409
+ } | undefined;
1410
+ changeId?: string | undefined;
1411
+ reportRef?: string | undefined;
1412
+ };
1413
+ parentTask: null;
1414
+ } | {
1415
+ questionTask: {
1416
+ schemaVersion: 1;
1417
+ id: string;
1418
+ repositoryIds: string[];
1419
+ kind: string;
1420
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
1421
+ origin: {
1422
+ signalId?: string | undefined;
1423
+ parentTaskId?: string | undefined;
1424
+ operator?: string | undefined;
1425
+ };
1426
+ replyTo: {
1427
+ channel: string;
1428
+ address: string;
1429
+ };
1430
+ attempt: number;
1431
+ createdAt: string;
1432
+ updatedAt: string;
1433
+ area?: string | undefined;
1434
+ approval?: "required" | "granted" | "denied" | undefined;
1435
+ dependsOn?: string[] | undefined;
1436
+ execution?: {
1437
+ provider: string;
1438
+ sessionId: string;
1439
+ environmentId?: string | undefined;
1440
+ harness?: string | undefined;
1441
+ traceId?: string | undefined;
1442
+ } | undefined;
1443
+ lastProgressAt?: string | undefined;
1444
+ stalledAt?: string | undefined;
1445
+ stalledReason?: string | undefined;
1446
+ reservedUsd?: number | undefined;
1447
+ reservedAt?: string | undefined;
1448
+ usage?: {
1449
+ costUsd: number;
1450
+ inputTokens: number;
1451
+ outputTokens: number;
1452
+ cacheReadTokens: number;
1453
+ cacheWriteTokens: number;
1454
+ steps: Record<string, number>;
1455
+ } | undefined;
1456
+ settledUsd?: number | undefined;
1457
+ question?: {
1458
+ text: string;
1459
+ options: string[];
1460
+ answer?: string | undefined;
1461
+ answeredBy?: string | undefined;
1462
+ } | undefined;
1463
+ changeId?: string | undefined;
1464
+ reportRef?: string | undefined;
1465
+ };
1466
+ parentTask: {
1467
+ schemaVersion: 1;
1468
+ id: string;
1469
+ repositoryIds: string[];
1470
+ kind: string;
1471
+ state: "queued" | "running" | "stalled" | "verifying" | "succeeded" | "failed" | "needs_human" | "cancelled";
1472
+ origin: {
1473
+ signalId?: string | undefined;
1474
+ parentTaskId?: string | undefined;
1475
+ operator?: string | undefined;
1476
+ };
1477
+ replyTo: {
1478
+ channel: string;
1479
+ address: string;
1480
+ };
1481
+ attempt: number;
1482
+ createdAt: string;
1483
+ updatedAt: string;
1484
+ area?: string | undefined;
1485
+ approval?: "required" | "granted" | "denied" | undefined;
1486
+ dependsOn?: string[] | undefined;
1487
+ execution?: {
1488
+ provider: string;
1489
+ sessionId: string;
1490
+ environmentId?: string | undefined;
1491
+ harness?: string | undefined;
1492
+ traceId?: string | undefined;
1493
+ } | undefined;
1494
+ lastProgressAt?: string | undefined;
1495
+ stalledAt?: string | undefined;
1496
+ stalledReason?: string | undefined;
1497
+ reservedUsd?: number | undefined;
1498
+ reservedAt?: string | undefined;
1499
+ usage?: {
1500
+ costUsd: number;
1501
+ inputTokens: number;
1502
+ outputTokens: number;
1503
+ cacheReadTokens: number;
1504
+ cacheWriteTokens: number;
1505
+ steps: Record<string, number>;
1506
+ } | undefined;
1507
+ settledUsd?: number | undefined;
1508
+ question?: {
1509
+ text: string;
1510
+ options: string[];
1511
+ answer?: string | undefined;
1512
+ answeredBy?: string | undefined;
1513
+ } | undefined;
1514
+ changeId?: string | undefined;
1515
+ reportRef?: string | undefined;
1516
+ };
1102
1517
  }>;
1103
1518
  };
1104
1519
  append_receipt: import("eve/tools").ToolDefinition<{
@@ -1154,20 +1569,31 @@ declare function factoryTools(stores: FactoryStores, options?: FactoryToolsOptio
1154
1569
  };
1155
1570
  };
1156
1571
  type FactoryTools = ReturnType<typeof factoryTools>;
1572
+ interface FactoryHooksOptions {
1573
+ /** Session auth attribute naming the task a dispatched session works on. Default `factoryTaskId`. */
1574
+ taskIdAttribute?: string;
1575
+ /** Present the recovery question created when a task turn ends without an outcome. */
1576
+ presentQuestion: PresentQuestion;
1577
+ }
1157
1578
  /**
1158
1579
  * Observe-only eve hooks that keep the ledger honest about session outcomes.
1159
1580
  * Mount by re-exporting from agent/hooks/, e.g.
1160
- * `export default factoryHooks(stores).factory;`.
1581
+ * `export default factoryHooks(stores, { presentQuestion }).factory;`.
1582
+ *
1583
+ * step.completed: records the step's tokens and AI Gateway cost on the bound
1584
+ * task. Delivery is at least once; recordUsage dedupes by (turnId, stepIndex).
1585
+ *
1586
+ * turn.completed: settles the bound task's recorded usage if the task is
1587
+ * already terminal (the sweep handles tasks that end later), then moves any
1588
+ * still-running task at this session's reply address behind a surfaced human
1589
+ * question, because the agent finished talking without recording an outcome.
1161
1590
  *
1162
- * turn.completed: a turn that ends while its task is still running means the
1163
- * agent finished talking without recording an outcome; the task moves to
1164
- * needs_human instead of rotting. The task is found by the session's
1165
- * channel address, which dispatch set from the task's replyTo.
1591
+ * Every store call is swallowed: a hook throw fails the turn.
1166
1592
  */
1167
- declare function factoryHooks(stores: FactoryStores): {
1168
- factory: import("eve/hooks").HookDefinition<"turn.completed">;
1593
+ declare function factoryHooks(stores: FactoryStores, options: FactoryHooksOptions): {
1594
+ factory: import("eve/hooks").HookDefinition<"step.completed" | "turn.completed">;
1169
1595
  };
1170
1596
  type FactoryHooks = ReturnType<typeof factoryHooks>;
1171
1597
  //#endregion
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 };
1598
+ export { type CommandSandbox, type CompletedReview, type CompletedReviewFinding, type DeepsecScanOptions, type DelegateAgentOptions, FactoryHooks, FactoryHooksOptions, FactoryTools, FactoryToolsOptions, type FetchPullRequestOptions, type FetchPullRequestResult, GateVerdict, type InvokeAgentOptions, type MergeConflictPayload, type MergeConflictToolOptions, type PostReviewToolOptions, type PublishedReview, RecordChangeInput, type RecordFindingOptions, type RecordFindingResult, type RecordVerificationOptions, type ReviewCommentToolOptions, deepsecScanTool, delegateAgentTool, factoryHooks, factoryTools, fetchPullRequestTool, findingFromDeepsec, invokeAgentTool, mergeConflictPayloadSchema, mergeConflictTools, postReviewTool, recordFinding, recordFindingTool, recordVerificationTool, reviewCommentTools };
1173
1599
  //# sourceMappingURL=index.d.mts.map