@get-bb/plugin-sdk 0.6.169 → 0.6.179

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.
@@ -5,10 +5,86 @@
5
5
  // Confused by the API, or need a symbol that isn't here? Clone the BB repo
6
6
  // and read the real source: https://github.com/get-bb/bb
7
7
 
8
+ import { StandardSchemaV1 as StandardSchemaV1$1, StandardSchemaV1InferOutput as StandardSchemaV1InferOutput$1, PluginMachineValidateDecision, JsonValue as JsonValue$2, PluginEnvironmentProviderRequirements as PluginEnvironmentProviderRequirements$1, PluginEnvironmentValidateDecision as PluginEnvironmentValidateDecision$1 } from '@get-bb/plugin-sdk';
8
9
  import { z } from 'zod';
9
- import { StandardSchemaV1 as StandardSchemaV1$1, PluginEnvironmentProviderRequirements as PluginEnvironmentProviderRequirements$1, StandardSchemaV1InferOutput as StandardSchemaV1InferOutput$1, PluginEnvironmentValidateDecision, JsonValue as JsonValue$2, PluginMachineValidateDecision } from '@get-bb/plugin-sdk';
10
10
  import Database from 'better-sqlite3';
11
11
 
12
+ type PluginMachineProviderResource = Exclude<JsonValue$2, null>;
13
+ type PluginMachineProviderInputsSchema = StandardSchemaV1$1 | undefined;
14
+ type InputsValue$1<S> = S extends StandardSchemaV1$1 ? StandardSchemaV1InferOutput$1<S> : null;
15
+ interface PluginMachineProviderProgress {
16
+ step(text: string): void;
17
+ log(text: string): void;
18
+ }
19
+ type PluginMachineProviderAvailability = {
20
+ status: "available";
21
+ } | {
22
+ status: "setup-required";
23
+ message: string;
24
+ } | {
25
+ status: "unavailable";
26
+ message: string;
27
+ };
28
+ type PluginMachineProviderValidateContext<S extends PluginMachineProviderInputsSchema = PluginMachineProviderInputsSchema> = {
29
+ inputs: InputsValue$1<S>;
30
+ };
31
+ interface PluginMachineProviderLifecycleContext {
32
+ checkpoint(resource: PluginMachineProviderResource): Promise<void>;
33
+ report: PluginMachineProviderProgress;
34
+ signal: AbortSignal;
35
+ }
36
+ type PluginMachineProviderCreateContext<S extends PluginMachineProviderInputsSchema = PluginMachineProviderInputsSchema> = PluginMachineProviderValidateContext<S> & PluginMachineProviderLifecycleContext & {
37
+ key: string;
38
+ attempt: number;
39
+ };
40
+ type PluginMachineProviderCreateResult = {
41
+ status: "created";
42
+ name: string;
43
+ resource: PluginMachineProviderResource;
44
+ } | {
45
+ status: "failed";
46
+ message: string;
47
+ };
48
+ type PluginMachineProviderResourceLifecycleContext = PluginMachineProviderLifecycleContext & {
49
+ hostId: string;
50
+ resource: PluginMachineProviderResource;
51
+ };
52
+ type PluginMachineProviderRemoveContext = Omit<PluginMachineProviderResourceLifecycleContext, "checkpoint">;
53
+ interface PluginMachineProviderResourceResult {
54
+ resource: PluginMachineProviderResource;
55
+ }
56
+ type PluginMachineProviderRemoveResult = {
57
+ status: "removed";
58
+ } | {
59
+ status: "failed";
60
+ message: string;
61
+ };
62
+ interface PluginMachineProviderDefinition<S extends PluginMachineProviderInputsSchema = PluginMachineProviderInputsSchema> {
63
+ id: string;
64
+ displayName: string;
65
+ /** One line telling a user what choosing this provider gets them, shown wherever a machine is added. */
66
+ description: string;
67
+ /** Provider glyph, declared icon, or plugin-relative icon path. */
68
+ icon: string;
69
+ ephemeral?: boolean;
70
+ /** Persisted and readable by every plugin. Store secret references, never secrets. */
71
+ inputs?: S;
72
+ availability?(): PluginMachineProviderAvailability | Promise<PluginMachineProviderAvailability>;
73
+ validate?(context: PluginMachineProviderValidateContext<S>): PluginMachineValidateDecision | Promise<PluginMachineValidateDecision>;
74
+ create(context: PluginMachineProviderCreateContext<S>): Promise<PluginMachineProviderCreateResult>;
75
+ /** Reconcile and remove an uncertain allocation by durable key without creating or bootstrapping. Return failed while allocation intent remains unresolved. */
76
+ reconcileCleanup(context: {
77
+ key: string;
78
+ report: PluginMachineProviderProgress;
79
+ signal: AbortSignal;
80
+ }): Promise<PluginMachineProviderRemoveResult>;
81
+ /** Idempotent: preserve saved state when compute is already stopped; save and stop any remaining compute, including during reconciliation of a suspended machine. */
82
+ suspend?(context: PluginMachineProviderResourceLifecycleContext): Promise<PluginMachineProviderResourceResult>;
83
+ /** Idempotent: reuse existing running compute instead of allocating a duplicate. */
84
+ resume?(context: PluginMachineProviderResourceLifecycleContext): Promise<PluginMachineProviderResourceResult>;
85
+ remove(context: PluginMachineProviderRemoveContext): Promise<PluginMachineProviderRemoveResult>;
86
+ }
87
+
12
88
  /** Input-form entry: a path, or a path with options. */
13
89
  declare const providerNativeRootInputSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
14
90
  ancestors: z.ZodOptional<z.ZodBoolean>;
@@ -84,6 +160,7 @@ declare const environmentSchema: z.ZodObject<{
84
160
  type: z.ZodLiteral<"new">;
85
161
  }, z.core.$strip>], "type">;
86
162
  }, z.core.$strip>>;
163
+ heldBy: z.ZodNullable<z.ZodLiteral<"user">>;
87
164
  hostId: z.ZodString;
88
165
  hostLifecycle: z.ZodEnum<{
89
166
  "cleanup-failed": "cleanup-failed";
@@ -125,6 +202,7 @@ declare const environmentSchema: z.ZodObject<{
125
202
  provisioning: "provisioning";
126
203
  ready: "ready";
127
204
  }>;
205
+ statusMessage: z.ZodNullable<z.ZodString>;
128
206
  updatedAt: z.ZodNumber;
129
207
  workspaceProvisionType: z.ZodNullable<z.ZodEnum<{
130
208
  "managed-worktree": "managed-worktree";
@@ -547,80 +625,19 @@ declare const threadQueuedMessageSchema: z.ZodObject<{
547
625
  }, z.core.$strip>;
548
626
  type ThreadQueuedMessage = z.infer<typeof threadQueuedMessageSchema>;
549
627
 
550
- type ExecutionInputFieldSource = CallerExecutionInputSource;
551
- declare const threadResponseSchema: z.ZodObject<{
552
- activeBackgroundAgentCount: z.ZodNumber;
553
- archivedAt: z.ZodNullable<z.ZodNumber>;
554
- canEditMessages: z.ZodBoolean;
555
- canRestoreEnvironment: z.ZodBoolean;
556
- canSpawnChild: z.ZodBoolean;
557
- createdAt: z.ZodNumber;
558
- deletedAt: z.ZodNullable<z.ZodNumber>;
559
- environmentId: z.ZodNullable<z.ZodString>;
560
- id: z.ZodString;
561
- lastReadAt: z.ZodNullable<z.ZodNumber>;
562
- latestAttentionAt: z.ZodNumber;
563
- lifecycleOwnerThreadId: z.ZodNullable<z.ZodString>;
564
- originKind: z.ZodNullable<z.ZodEnum<{
565
- fork: "fork";
566
- }>>;
567
- originPluginId: z.ZodNullable<z.ZodString>;
568
- parentNotifications: z.ZodEnum<{
569
- auto: "auto";
570
- off: "off";
571
- stuck: "stuck";
572
- }>;
573
- parentThreadId: z.ZodNullable<z.ZodString>;
574
- pinnedAt: z.ZodNullable<z.ZodNumber>;
575
- projectId: z.ZodString;
576
- providerId: z.ZodString;
577
- queuedMessageCount: z.ZodNumber;
578
- runtime: z.ZodObject<{
579
- displayStatus: z.ZodEnum<{
580
- "waiting-for-host": "waiting-for-host";
581
- active: "active";
582
- error: "error";
583
- idle: "idle";
584
- pending: "pending";
585
- provisioning: "provisioning";
586
- starting: "starting";
587
- stopping: "stopping";
588
- }>;
589
- }, z.core.$strip>;
590
- sectionId: z.ZodNullable<z.ZodString>;
591
- sourceThreadId: z.ZodNullable<z.ZodString>;
592
- status: z.ZodEnum<{
593
- active: "active";
594
- error: "error";
595
- idle: "idle";
596
- pending: "pending";
597
- starting: "starting";
598
- stopping: "stopping";
599
- }>;
600
- title: z.ZodNullable<z.ZodString>;
601
- titleFallback: z.ZodNullable<z.ZodString>;
602
- updatedAt: z.ZodNumber;
603
- visibility: z.ZodEnum<{
604
- hidden: "hidden";
605
- visible: "visible";
606
- }>;
607
- }, z.core.$strip>;
608
- type ThreadResponse = z.infer<typeof threadResponseSchema>;
609
-
610
628
  type PluginEnvironmentProviderInputsSchema = StandardSchemaV1$1 | undefined;
611
629
  type Fact<R, K extends PropertyKey, T> = R extends Record<K, true> ? T : T | null;
630
+ /** `ownsPath`: bb cloned this checkout, so a provider may own work there. */
631
+ interface ProjectCheckout {
632
+ path: string;
633
+ ownsPath: boolean;
634
+ }
612
635
  type Checkout<R> = R extends {
613
636
  projectCheckout: true;
614
637
  } | {
615
638
  gitCheckout: true;
616
- } ? {
617
- path: string;
618
- experimental_ownsPath: boolean;
619
- } : {
620
- path: string;
621
- experimental_ownsPath: boolean;
622
- } | null;
623
- type InputsValue$1<S> = S extends StandardSchemaV1$1 ? StandardSchemaV1InferOutput$1<S> : null;
639
+ } ? ProjectCheckout : ProjectCheckout | null;
640
+ type InputsValue<S> = S extends StandardSchemaV1$1 ? StandardSchemaV1InferOutput$1<S> : null;
624
641
  /** Attempt-scoped updates; core persists each update before this call returns. */
625
642
  interface PluginEnvironmentProviderProgress {
626
643
  step(text: string): void;
@@ -631,7 +648,16 @@ interface PluginEnvironmentProviderValidateContext<R extends PluginEnvironmentPr
631
648
  host: Host;
632
649
  projectCheckout: Checkout<R>;
633
650
  gitRemote: Fact<R, "gitRemote", string>;
634
- inputs: InputsValue$1<S>;
651
+ inputs: InputsValue<S>;
652
+ }
653
+ interface PluginEnvironmentProviderLocation {
654
+ path: string;
655
+ reuse: boolean;
656
+ }
657
+ interface PluginEnvironmentProviderLocateContext<R extends PluginEnvironmentProviderRequirements$1 = PluginEnvironmentProviderRequirements$1, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> {
658
+ host: Host;
659
+ projectCheckout: Checkout<R>;
660
+ inputs: InputsValue<S>;
635
661
  }
636
662
  interface PluginEnvironmentProviderAvailabilityContext {
637
663
  project: Project;
@@ -650,28 +676,46 @@ type PluginEnvironmentProviderAvailability = {
650
676
  status: "unavailable";
651
677
  message: string;
652
678
  };
653
- interface PluginEnvironmentProviderCreateContext<R extends PluginEnvironmentProviderRequirements$1 = PluginEnvironmentProviderRequirements$1, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> extends PluginEnvironmentProviderValidateContext<R, S> {
654
- thread: ThreadResponse;
655
- suggestedBranchName: string;
679
+ /** The environment a create or restore produces a workspace for. */
680
+ interface PluginEnvironmentProviderEnvironment {
681
+ id: string;
682
+ name: string | null;
683
+ projectId: string;
684
+ }
685
+ /** Core's create steps, which a provider calls in the order it needs. */
686
+ interface PluginEnvironmentProviderSteps {
687
+ /**
688
+ * The name for a branch this operation makes. A thread's environment
689
+ * resolves to `<prefix><slug(title)>-<threadId>` once the thread's title
690
+ * settles (generated, provided, or the fallback); a thread-less one resolves
691
+ * at once to `<prefix><slug(name)>-<id>`, or `<prefix><id>` without a name.
692
+ * Core generates the title while create runs, so await it as late as
693
+ * possible. Repeated calls return the same name.
694
+ */
695
+ branchName(): Promise<string>;
696
+ /**
697
+ * Claims `path` as this environment's provider-owned workspace and asks core
698
+ * to run setup there; resolves once the request is recorded, while setup
699
+ * runs alongside the rest of create. The environment becomes ready only
700
+ * after create returns `created` with the same path and `ownsPath: true`.
701
+ * Without a call, core runs setup after create returns.
702
+ */
703
+ setup(path: string): Promise<void>;
704
+ }
705
+ interface PluginEnvironmentProviderCreateContext<R extends PluginEnvironmentProviderRequirements$1 = PluginEnvironmentProviderRequirements$1, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> extends PluginEnvironmentProviderValidateContext<R, S>, PluginEnvironmentProviderSteps {
706
+ environment: PluginEnvironmentProviderEnvironment;
656
707
  attempt: number;
657
708
  pathKey: string;
658
- experimental_claimPath(path: string): Promise<boolean>;
659
709
  report: PluginEnvironmentProviderProgress;
660
710
  signal: AbortSignal;
661
711
  }
662
712
  /** Rebuilds a thread's destroyed environment; `inputs` are the ones it was created with. */
663
- interface PluginEnvironmentProviderRestoreContext<R extends PluginEnvironmentProviderRequirements$1 = PluginEnvironmentProviderRequirements$1, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> extends PluginEnvironmentProviderValidateContext<R, S> {
664
- thread: ThreadResponse;
665
- attempt: number;
666
- pathKey: string;
667
- experimental_claimPath(path: string): Promise<boolean>;
713
+ interface PluginEnvironmentProviderRestoreContext<R extends PluginEnvironmentProviderRequirements$1 = PluginEnvironmentProviderRequirements$1, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> extends PluginEnvironmentProviderCreateContext<R, S> {
668
714
  /** Resource is private to this provider; null after completed removal. */
669
715
  previous: {
670
716
  environment: Environment;
671
717
  resource: JsonValue$2 | null;
672
718
  };
673
- report: PluginEnvironmentProviderProgress;
674
- signal: AbortSignal;
675
719
  }
676
720
  type PluginEnvironmentProviderCreateResult = {
677
721
  status: "created";
@@ -704,11 +748,25 @@ type PluginEnvironmentProviderRemoveResult = {
704
748
  interface PluginEnvironmentProviderPolicy {
705
749
  /** Default five minutes; null keeps the environment indefinitely. */
706
750
  retireGraceMs: number | null;
707
- /** Default per-thread; replacement environments use a fresh key to avoid dead paths. */
708
- pathKeys: "per-attempt" | "per-thread";
751
+ /**
752
+ * Default per-environment: one key for the environment's workspace, stable
753
+ * across retries. Core derives it from the driving thread when there is one
754
+ * and from the environment otherwise, so thread workspaces keep their
755
+ * names. Replacement environments use a fresh key to avoid dead paths.
756
+ */
757
+ pathKeys: "per-attempt" | "per-environment";
709
758
  }
710
- /** Resource operations only. Core owns durable launches, retries and retirement. */
759
+ /**
760
+ * Resource operations only. Core owns durable launches, retries and
761
+ * retirement. Contexts carry the `environment` being created rather than a
762
+ * thread, so core can also create environments before any thread exists.
763
+ */
711
764
  interface PluginEnvironmentProviderDefinition<R extends PluginEnvironmentProviderRequirements$1 = PluginEnvironmentProviderRequirements$1, S extends PluginEnvironmentProviderInputsSchema = PluginEnvironmentProviderInputsSchema> {
765
+ /**
766
+ * The context shape `create` and `restore` receive. Required: bb still runs
767
+ * providers built before it with the earlier, thread-based contexts.
768
+ */
769
+ apiVersion: 2;
712
770
  id: string;
713
771
  displayName: string;
714
772
  /** Short explanation shown in environment choices. */
@@ -720,98 +778,82 @@ interface PluginEnvironmentProviderDefinition<R extends PluginEnvironmentProvide
720
778
  policy?: Partial<PluginEnvironmentProviderPolicy>;
721
779
  /** Experimental per-machine availability, probed in the background for pickers and again at thread creation: see docs/api_to_audit.md. */
722
780
  availability?(context: PluginEnvironmentProviderAvailabilityContext): PluginEnvironmentProviderAvailability | Promise<PluginEnvironmentProviderAvailability>;
723
- validate?(context: PluginEnvironmentProviderValidateContext<R, S>): PluginEnvironmentValidateDecision | Promise<PluginEnvironmentValidateDecision>;
724
- /** Pure path selection from parsed inputs. Core reuses a recorded environment on the selected host before calling create; null requests normal creation. */
725
- experimental_existingPath?(inputs: InputsValue$1<S>): string | null;
781
+ validate?(context: PluginEnvironmentProviderValidateContext<R, S>): PluginEnvironmentValidateDecision$1 | Promise<PluginEnvironmentValidateDecision$1>;
782
+ /**
783
+ * Where an environment for these inputs lives, if the provider knows before
784
+ * creating anything; null asks for a new environment. Core claims the path
785
+ * for the operation. With `reuse: true`, a thread joins the environment
786
+ * recorded at `path` as it is. Otherwise create runs on a fresh
787
+ * reservation, which core refuses while another live thread uses an
788
+ * environment at `path`, and core folds the result into that environment
789
+ * when create returns the same path.
790
+ */
791
+ locate?(context: PluginEnvironmentProviderLocateContext<R, S>): PluginEnvironmentProviderLocation | null | Promise<PluginEnvironmentProviderLocation | null>;
726
792
  create(context: PluginEnvironmentProviderCreateContext<R, S>): Promise<PluginEnvironmentProviderCreateResult>;
727
- /** Experimental: rebuild a destroyed environment when its thread asks for it back. Without it, core never rebuilds this provider's destroyed environments: see docs/api_to_audit.md. */
793
+ /** Experimental: rebuild a destroyed environment when a thread asks for it back. Without it, core never rebuilds this provider's destroyed environments: see docs/api_to_audit.md. */
728
794
  restore?(context: PluginEnvironmentProviderRestoreContext<R, S>): Promise<PluginEnvironmentProviderCreateResult>;
729
795
  remove(context: PluginEnvironmentProviderRemoveContext): Promise<PluginEnvironmentProviderRemoveResult>;
730
796
  }
731
797
 
732
- interface ContractTagDeclarations<Input, Output> {
733
- tags?(input: Input, output: Output): readonly string[];
734
- keyTags?(key: string, value: Output extends Readonly<Record<string, infer Value>> ? Value : unknown): readonly string[];
735
- invalidates?(input: Input, output: Output): readonly string[];
736
- }
737
-
738
- declare const RESERVED_BB_CLI_COMMANDS: readonly string[];
739
-
740
- type PluginMachineProviderResource = Exclude<JsonValue$2, null>;
741
- type PluginMachineProviderInputsSchema = StandardSchemaV1$1 | undefined;
742
- type InputsValue<S> = S extends StandardSchemaV1$1 ? StandardSchemaV1InferOutput$1<S> : null;
743
- interface PluginMachineProviderProgress {
744
- step(text: string): void;
745
- log(text: string): void;
746
- }
747
- type PluginMachineProviderAvailability = {
748
- status: "available";
749
- } | {
750
- status: "setup-required";
751
- message: string;
752
- } | {
753
- status: "unavailable";
754
- message: string;
755
- };
756
- type PluginMachineProviderValidateContext<S extends PluginMachineProviderInputsSchema = PluginMachineProviderInputsSchema> = {
757
- inputs: InputsValue<S>;
758
- };
759
- interface PluginMachineProviderLifecycleContext {
760
- checkpoint(resource: PluginMachineProviderResource): Promise<void>;
761
- report: PluginMachineProviderProgress;
762
- signal: AbortSignal;
763
- }
764
- type PluginMachineProviderCreateContext<S extends PluginMachineProviderInputsSchema = PluginMachineProviderInputsSchema> = PluginMachineProviderValidateContext<S> & PluginMachineProviderLifecycleContext & {
765
- key: string;
766
- attempt: number;
767
- };
768
- type PluginMachineProviderCreateResult = {
769
- status: "created";
770
- name: string;
771
- resource: PluginMachineProviderResource;
772
- } | {
773
- status: "failed";
774
- message: string;
775
- };
776
- type PluginMachineProviderResourceLifecycleContext = PluginMachineProviderLifecycleContext & {
777
- hostId: string;
778
- resource: PluginMachineProviderResource;
779
- };
780
- type PluginMachineProviderRemoveContext = Omit<PluginMachineProviderResourceLifecycleContext, "checkpoint">;
781
- interface PluginMachineProviderResourceResult {
782
- resource: PluginMachineProviderResource;
783
- }
784
- type PluginMachineProviderRemoveResult = {
785
- status: "removed";
786
- } | {
787
- status: "failed";
788
- message: string;
789
- };
790
- interface PluginMachineProviderDefinition<S extends PluginMachineProviderInputsSchema = PluginMachineProviderInputsSchema> {
791
- id: string;
792
- displayName: string;
793
- /** One line telling a user what choosing this provider gets them, shown wherever a machine is added. */
794
- description: string;
795
- /** Provider glyph, declared icon, or plugin-relative icon path. */
796
- icon: string;
797
- ephemeral?: boolean;
798
- /** Persisted and readable by every plugin. Store secret references, never secrets. */
799
- inputs?: S;
800
- availability?(): PluginMachineProviderAvailability | Promise<PluginMachineProviderAvailability>;
801
- validate?(context: PluginMachineProviderValidateContext<S>): PluginMachineValidateDecision | Promise<PluginMachineValidateDecision>;
802
- create(context: PluginMachineProviderCreateContext<S>): Promise<PluginMachineProviderCreateResult>;
803
- /** Reconcile and remove an uncertain allocation by durable key without creating or bootstrapping. Return failed while allocation intent remains unresolved. */
804
- reconcileCleanup(context: {
805
- key: string;
806
- report: PluginMachineProviderProgress;
807
- signal: AbortSignal;
808
- }): Promise<PluginMachineProviderRemoveResult>;
809
- /** Idempotent: preserve saved state when compute is already stopped; save and stop any remaining compute, including during reconciliation of a suspended machine. */
810
- suspend?(context: PluginMachineProviderResourceLifecycleContext): Promise<PluginMachineProviderResourceResult>;
811
- /** Idempotent: reuse existing running compute instead of allocating a duplicate. */
812
- resume?(context: PluginMachineProviderResourceLifecycleContext): Promise<PluginMachineProviderResourceResult>;
813
- remove(context: PluginMachineProviderRemoveContext): Promise<PluginMachineProviderRemoveResult>;
814
- }
798
+ type ExecutionInputFieldSource = CallerExecutionInputSource;
799
+ declare const threadResponseSchema: z.ZodObject<{
800
+ activeBackgroundAgentCount: z.ZodNumber;
801
+ archivedAt: z.ZodNullable<z.ZodNumber>;
802
+ canEditMessages: z.ZodBoolean;
803
+ canRestoreEnvironment: z.ZodBoolean;
804
+ canSpawnChild: z.ZodBoolean;
805
+ createdAt: z.ZodNumber;
806
+ deletedAt: z.ZodNullable<z.ZodNumber>;
807
+ environmentId: z.ZodNullable<z.ZodString>;
808
+ id: z.ZodString;
809
+ lastReadAt: z.ZodNullable<z.ZodNumber>;
810
+ latestAttentionAt: z.ZodNumber;
811
+ lifecycleOwnerThreadId: z.ZodNullable<z.ZodString>;
812
+ originKind: z.ZodNullable<z.ZodEnum<{
813
+ fork: "fork";
814
+ }>>;
815
+ originPluginId: z.ZodNullable<z.ZodString>;
816
+ parentNotifications: z.ZodEnum<{
817
+ auto: "auto";
818
+ off: "off";
819
+ stuck: "stuck";
820
+ }>;
821
+ parentThreadId: z.ZodNullable<z.ZodString>;
822
+ pinnedAt: z.ZodNullable<z.ZodNumber>;
823
+ projectId: z.ZodString;
824
+ providerId: z.ZodString;
825
+ queuedMessageCount: z.ZodNumber;
826
+ runtime: z.ZodObject<{
827
+ displayStatus: z.ZodEnum<{
828
+ "waiting-for-host": "waiting-for-host";
829
+ active: "active";
830
+ error: "error";
831
+ idle: "idle";
832
+ pending: "pending";
833
+ provisioning: "provisioning";
834
+ starting: "starting";
835
+ stopping: "stopping";
836
+ }>;
837
+ }, z.core.$strip>;
838
+ sectionId: z.ZodNullable<z.ZodString>;
839
+ sourceThreadId: z.ZodNullable<z.ZodString>;
840
+ status: z.ZodEnum<{
841
+ active: "active";
842
+ error: "error";
843
+ idle: "idle";
844
+ pending: "pending";
845
+ starting: "starting";
846
+ stopping: "stopping";
847
+ }>;
848
+ title: z.ZodNullable<z.ZodString>;
849
+ titleFallback: z.ZodNullable<z.ZodString>;
850
+ updatedAt: z.ZodNumber;
851
+ visibility: z.ZodEnum<{
852
+ hidden: "hidden";
853
+ visible: "visible";
854
+ }>;
855
+ }, z.core.$strip>;
856
+ type ThreadResponse = z.infer<typeof threadResponseSchema>;
815
857
 
816
858
  /**
817
859
  * A value that survives a JSON round trip without coercion or data loss.
@@ -823,6 +865,12 @@ type JsonValue = string | number | boolean | null | JsonValue[] | {
823
865
  [key: string]: JsonValue;
824
866
  };
825
867
 
868
+ interface ContractTagDeclarations<Input, Output> {
869
+ tags?(input: Input, output: Output): readonly string[];
870
+ keyTags?(key: string, value: Output extends Readonly<Record<string, infer Value>> ? Value : unknown): readonly string[];
871
+ invalidates?(input: Input, output: Output): readonly string[];
872
+ }
873
+
826
874
  /** A JSON-safe path segment reported by a Standard Schema validation issue. */
827
875
  type PluginRpcIssuePathSegment = string | number;
828
876
  /** Validator-neutral validation detail carried by an RPC error envelope. */
@@ -984,6 +1032,16 @@ interface PluginEnvironmentProviderRequirements {
984
1032
  gitRemote?: boolean;
985
1033
  projectless?: boolean;
986
1034
  }
1035
+ /**
1036
+ * What `validate` answers. `refuse` fails the create request with `message`
1037
+ * as the caller's error, before a thread or an environment row exists.
1038
+ */
1039
+ type PluginEnvironmentValidateDecision = {
1040
+ action: "accept";
1041
+ } | {
1042
+ action: "refuse";
1043
+ message: string;
1044
+ };
987
1045
  /**
988
1046
  * Resource operations for one place a thread can run. Core persists progress,
989
1047
  * retries, cancellation and retirement. Operations must be idempotent for the
@@ -1048,12 +1106,14 @@ type PluginDispatchEnvironmentIntent = {
1048
1106
  *
1049
1107
  * `proceed` lets the attempt continue. `wait` QUEUES the message as a row
1050
1108
  * whose `waitingOn` names this plugin and carries `reason` verbatim; the
1051
- * row stays queued until `sendAt` comes due, capacity frees, the user sends
1109
+ * row stays queued until `recheckAt` comes due, capacity frees, the user sends
1052
1110
  * it now, or the orphan sweep clears it because this plugin is no longer
1053
- * running. `sendAt` (epoch ms) sets the row's own `sendAt`, so core's due sweep
1054
- * re-attempts at that instant without the plugin holding a timer of its own —
1055
- * which is what a rate-limit window wants. `reject` refuses the attempt
1056
- * outright: `message` is shown to the user verbatim.
1111
+ * running. `recheckAt` (epoch ms) is when core's due sweep re-asks, without
1112
+ * the plugin holding a timer of its own — which is what a rate-limit window
1113
+ * wants. It is not the message's schedule: the row's `sendAt` stays the
1114
+ * sender's time, and a message the sender scheduled never dispatches before
1115
+ * that time, even when this hook proceeds earlier. `reject` refuses the attempt outright:
1116
+ * `message` is shown to the user verbatim.
1057
1117
  *
1058
1118
  * There is deliberately no "handled it myself" answer and no amendment arm —
1059
1119
  * a hook is a decision, never an owner or an author of the work.
@@ -1063,7 +1123,7 @@ type MessageDispatchHookDecision = {
1063
1123
  } | {
1064
1124
  action: "wait";
1065
1125
  reason: string;
1066
- sendAt?: number | null;
1126
+ recheckAt?: number | null;
1067
1127
  } | {
1068
1128
  action: "reject";
1069
1129
  message: string;
@@ -1904,6 +1964,8 @@ interface PluginAiServiceDeclaration {
1904
1964
  readonly status?: () => Promise<PluginAiServiceStatus>;
1905
1965
  }
1906
1966
 
1967
+ declare const RESERVED_BB_CLI_COMMANDS: readonly string[];
1968
+
1907
1969
  declare function pluginCliCollisionWarning(pluginId: string, commandName: string): string | null;
1908
1970
  /**
1909
1971
  * Built-in dynamic tool names plugins may not shadow. Maintained by hand —
@@ -2027,6 +2089,16 @@ declare function parsePluginRowPresentation(subject: string, value: unknown): Pl
2027
2089
  /** Compact issue summary from a (possibly foreign-instance) zod error. */
2028
2090
  declare function summarizeStandardIssues(issues: readonly StandardSchemaV1Issue[]): string;
2029
2091
  declare function enforcePluginCliOutputLimit(result: Omit<PluginCliExecutionResult, "error">, jsonOutput: boolean): PluginCliExecutionResult;
2092
+ /**
2093
+ * The result for a plugin CLI invocation the host could not complete: the
2094
+ * plugin is unknown, not running, registers no CLI, or its command threw.
2095
+ * Carries the same `{ ok: false, error: { code, message } }` envelope on
2096
+ * stdout under `--json` as core commands and `defineCli` usage errors.
2097
+ */
2098
+ declare function pluginCliFailureResult(failure: {
2099
+ code: string;
2100
+ message: string;
2101
+ }, jsonOutput: boolean): PluginCliExecutionResult;
2030
2102
  /**
2031
2103
  * Adopt the value a plugin HTTP route handler returned.
2032
2104
  *
@@ -2103,7 +2175,7 @@ declare const environmentCompositionSchema: z.ZodObject<{
2103
2175
  machineProviderId: z.ZodString;
2104
2176
  }, z.core.$strict>;
2105
2177
  type NormalizedPluginEnvironmentComposition = z.infer<typeof environmentCompositionSchema>;
2106
- interface NormalizedPluginEnvironmentProvider {
2178
+ interface NormalizedPluginEnvironmentProviderCommon {
2107
2179
  id: string;
2108
2180
  displayName: string;
2109
2181
  description: string | null;
@@ -2112,14 +2184,65 @@ interface NormalizedPluginEnvironmentProvider {
2112
2184
  inputs: StandardSchemaV1 | null;
2113
2185
  inputsJsonSchema: JsonValue | null;
2114
2186
  availability: NonNullable<PluginEnvironmentProviderDeclaration["availability"]> | null;
2115
- validate: NonNullable<PluginEnvironmentProviderDeclaration["validate"]> | null;
2116
- experimental_existingPath: NonNullable<PluginEnvironmentProviderDeclaration["experimental_existingPath"]> | null;
2117
- create: PluginEnvironmentProviderDeclaration["create"];
2118
- restore: NonNullable<PluginEnvironmentProviderDeclaration["restore"]> | null;
2187
+ /** Version 2's own, or version 1's `experimental_existingPath` as a reusing location. */
2188
+ locate: NonNullable<PluginEnvironmentProviderDeclaration["locate"]> | null;
2119
2189
  remove: PluginEnvironmentProviderDeclaration["remove"];
2190
+ }
2191
+ type ProviderModule = PluginEnvironmentProviderDefinition;
2192
+ type V2ValidateContext = PluginEnvironmentProviderValidateContext;
2193
+ type V2CreateContext = PluginEnvironmentProviderCreateContext;
2194
+ type V2RestoreContext = PluginEnvironmentProviderRestoreContext;
2195
+ type CreateResult = PluginEnvironmentProviderCreateResult;
2196
+ /**
2197
+ * The contexts of a provider declared without `apiVersion` (version 1). The
2198
+ * public types offer only version 2; core still runs version-1 providers
2199
+ * built against earlier SDKs through this adapter.
2200
+ */
2201
+ type PluginEnvironmentProviderV1ValidateContext = Omit<V2ValidateContext, "projectCheckout"> & {
2202
+ projectCheckout: {
2203
+ path: string;
2204
+ experimental_ownsPath: boolean;
2205
+ } | null;
2206
+ };
2207
+ type V1OperationContext = PluginEnvironmentProviderV1ValidateContext & Pick<V2CreateContext, "attempt" | "pathKey" | "report" | "signal"> & {
2208
+ thread: ThreadResponse;
2209
+ experimental_claimPath(path: string): Promise<boolean>;
2210
+ };
2211
+ type PluginEnvironmentProviderV1CreateContext = V1OperationContext & {
2212
+ suggestedBranchName: string;
2213
+ };
2214
+ type PluginEnvironmentProviderV1RestoreContext = V1OperationContext & Pick<V2RestoreContext, "previous">;
2215
+ interface PluginEnvironmentProviderV1Policy {
2216
+ retireGraceMs: number | null;
2217
+ pathKeys: "per-attempt" | "per-thread";
2218
+ }
2219
+ interface PluginEnvironmentProviderV1Declaration extends Omit<ProviderModule, "apiVersion" | "create" | "policy" | "restore" | "validate"> {
2220
+ apiVersion?: 1;
2221
+ policy?: Partial<PluginEnvironmentProviderV1Policy>;
2222
+ validate?(context: PluginEnvironmentProviderV1ValidateContext): PluginEnvironmentValidateDecision | Promise<PluginEnvironmentValidateDecision>;
2223
+ experimental_existingPath?(inputs: V2ValidateContext["inputs"]): string | null;
2224
+ create(context: PluginEnvironmentProviderV1CreateContext): Promise<CreateResult>;
2225
+ restore?(context: PluginEnvironmentProviderV1RestoreContext): Promise<CreateResult>;
2226
+ }
2227
+ interface NormalizedPluginEnvironmentProviderV1 {
2228
+ apiVersion: 1;
2229
+ validate: NonNullable<PluginEnvironmentProviderV1Declaration["validate"]> | null;
2230
+ create: PluginEnvironmentProviderV1Declaration["create"];
2231
+ restore: NonNullable<PluginEnvironmentProviderV1Declaration["restore"]> | null;
2232
+ policy: PluginEnvironmentProviderV1Policy;
2233
+ }
2234
+ interface NormalizedPluginEnvironmentProviderV2 {
2235
+ apiVersion: 2;
2236
+ validate: NonNullable<ProviderModule["validate"]> | null;
2237
+ create: ProviderModule["create"];
2238
+ restore: NonNullable<ProviderModule["restore"]> | null;
2120
2239
  policy: PluginEnvironmentProviderPolicy;
2121
2240
  }
2122
- declare function validatePluginEnvironmentProviderDeclaration(declaration: PluginEnvironmentProviderDeclaration): NormalizedPluginEnvironmentProvider;
2241
+ /** Normalized once at registration; `apiVersion` selects the context shape core builds for create and restore. */
2242
+ type NormalizedPluginEnvironmentProvider = NormalizedPluginEnvironmentProviderCommon & (NormalizedPluginEnvironmentProviderV1 | NormalizedPluginEnvironmentProviderV2);
2243
+ /** Either context version; `apiVersion` tells them apart at runtime. */
2244
+ type AnyPluginEnvironmentProviderDeclaration = PluginEnvironmentProviderDeclaration | PluginEnvironmentProviderV1Declaration;
2245
+ declare function validatePluginEnvironmentProviderDeclaration(declaration: AnyPluginEnvironmentProviderDeclaration): NormalizedPluginEnvironmentProvider;
2123
2246
  declare const MACHINE_PROVIDER_DESCRIPTION_MAX_CHARS = 200;
2124
2247
  interface NormalizedPluginMachineProvider {
2125
2248
  id: string;
@@ -2252,5 +2375,5 @@ declare function readPluginRpcRefusal(error: unknown): PluginRpcError | null;
2252
2375
  declare function validateRpcValue(schema: StandardSchemaV1, value: unknown, phase: "input" | "output", fail: (error: PluginRpcError) => never): Promise<unknown>;
2253
2376
  declare function normalizeRpcJsonResult(value: unknown, fail: (error: PluginRpcError) => never): JsonValue;
2254
2377
 
2255
- export { ENVIRONMENT_PROVIDER_DESCRIPTION_MAX_CHARS, ENVIRONMENT_PROVIDER_DISPLAY_NAME_MAX_CHARS, ENVIRONMENT_PROVIDER_ID_PATTERN, ENVIRONMENT_PROVIDER_REQUIREMENT_NAMES, KV_VALUE_MAX_BYTES, MACHINE_PROVIDER_DESCRIPTION_MAX_CHARS, PLUGIN_AGENT_STATUS_LABEL_MAX_CHARS, PLUGIN_DYNAMIC_INSTRUCTIONS_MAX_CHARS, PLUGIN_MENTION_TRIGGER_VALUES, PLUGIN_PROVIDER_BRIDGE_OPTIONS_MAX_BYTES, PLUGIN_PROVIDER_COMPOSER_ACTION_VALUES, PLUGIN_PROVIDER_DISPLAY_NAME_MAX_CHARS, PLUGIN_PROVIDER_ENV_MAX_ENTRIES, PLUGIN_PROVIDER_ENV_NAME_PATTERN, PLUGIN_PROVIDER_PERMISSION_MODE_VALUES, PLUGIN_PROVIDER_REASONING_LEVEL_VALUES, PROVIDER_ID_PATTERN, RESERVED_AGENT_TOOL_NAMES, RESERVED_BB_CLI_COMMANDS, SETTING_KEY_PATTERN, adoptHttpRouteResponse, aiServiceAlreadyRegisteredMessage, coerceStoredPluginSettingValue, deriveValidatedProviderOptions, enforcePluginCliOutputLimit, environmentCompositionSchema, isPluginMentionTrigger, isStandardSchema, normalizeAgentToolRegistration, normalizeCliRegistration, normalizeHttpRouteRegistration, normalizeInteractionRequest, normalizeMentionProviderRegistration, normalizePluginAgentConfiguration, normalizeRealtimePayload, normalizeRpcJsonResult, normalizeRpcRegistration, normalizeWebSocketRouteRegistration, parsePluginRowPresentation, pluginCliCollisionWarning, pluginHookAlreadyRegisteredMessage, providerAlreadyRegisteredMessage, providerDeclarationIconRefusal, providerIconRefusalMessage, providerWithoutBridgeMessage, publishRpcMethod, readPluginRpcRefusal, readRpcPublicationOptions, registerSettingDescriptors, runPluginStorageMigrations, storePluginHook, summarizeStandardIssues, undeclaredIconProblem, validateBackgroundServiceRegistration, validatePluginAiServiceDeclaration, validatePluginEnvironmentProviderDeclaration, validatePluginMachineProviderDeclaration, validatePluginProviderDeclaration, validatePluginProviderEnvEntries, validateProviderEnvContribution, validateRpcValue, validateScheduleRegistration, validateServerAccessProviderDeclaration, validateSettingsUpdate };
2256
- export type { NormalizedPluginAiService, NormalizedPluginEnvironmentComposition, NormalizedPluginEnvironmentProvider, NormalizedPluginEnvironmentProviderRequirements, NormalizedPluginInteractionRequest, NormalizedPluginMachineProvider, NormalizedPluginProviderDeclaration };
2378
+ export { ENVIRONMENT_PROVIDER_DESCRIPTION_MAX_CHARS, ENVIRONMENT_PROVIDER_DISPLAY_NAME_MAX_CHARS, ENVIRONMENT_PROVIDER_ID_PATTERN, ENVIRONMENT_PROVIDER_REQUIREMENT_NAMES, KV_VALUE_MAX_BYTES, MACHINE_PROVIDER_DESCRIPTION_MAX_CHARS, PLUGIN_AGENT_STATUS_LABEL_MAX_CHARS, PLUGIN_DYNAMIC_INSTRUCTIONS_MAX_CHARS, PLUGIN_MENTION_TRIGGER_VALUES, PLUGIN_PROVIDER_BRIDGE_OPTIONS_MAX_BYTES, PLUGIN_PROVIDER_COMPOSER_ACTION_VALUES, PLUGIN_PROVIDER_DISPLAY_NAME_MAX_CHARS, PLUGIN_PROVIDER_ENV_MAX_ENTRIES, PLUGIN_PROVIDER_ENV_NAME_PATTERN, PLUGIN_PROVIDER_PERMISSION_MODE_VALUES, PLUGIN_PROVIDER_REASONING_LEVEL_VALUES, PROVIDER_ID_PATTERN, RESERVED_AGENT_TOOL_NAMES, RESERVED_BB_CLI_COMMANDS, SETTING_KEY_PATTERN, adoptHttpRouteResponse, aiServiceAlreadyRegisteredMessage, coerceStoredPluginSettingValue, deriveValidatedProviderOptions, enforcePluginCliOutputLimit, environmentCompositionSchema, isPluginMentionTrigger, isStandardSchema, normalizeAgentToolRegistration, normalizeCliRegistration, normalizeHttpRouteRegistration, normalizeInteractionRequest, normalizeMentionProviderRegistration, normalizePluginAgentConfiguration, normalizeRealtimePayload, normalizeRpcJsonResult, normalizeRpcRegistration, normalizeWebSocketRouteRegistration, parsePluginRowPresentation, pluginCliCollisionWarning, pluginCliFailureResult, pluginHookAlreadyRegisteredMessage, providerAlreadyRegisteredMessage, providerDeclarationIconRefusal, providerIconRefusalMessage, providerWithoutBridgeMessage, publishRpcMethod, readPluginRpcRefusal, readRpcPublicationOptions, registerSettingDescriptors, runPluginStorageMigrations, storePluginHook, summarizeStandardIssues, undeclaredIconProblem, validateBackgroundServiceRegistration, validatePluginAiServiceDeclaration, validatePluginEnvironmentProviderDeclaration, validatePluginMachineProviderDeclaration, validatePluginProviderDeclaration, validatePluginProviderEnvEntries, validateProviderEnvContribution, validateRpcValue, validateScheduleRegistration, validateServerAccessProviderDeclaration, validateSettingsUpdate };
2379
+ export type { AnyPluginEnvironmentProviderDeclaration, NormalizedPluginAiService, NormalizedPluginEnvironmentComposition, NormalizedPluginEnvironmentProvider, NormalizedPluginEnvironmentProviderRequirements, NormalizedPluginInteractionRequest, NormalizedPluginMachineProvider, NormalizedPluginProviderDeclaration, PluginEnvironmentProviderV1CreateContext, PluginEnvironmentProviderV1Declaration, PluginEnvironmentProviderV1Policy, PluginEnvironmentProviderV1RestoreContext, PluginEnvironmentProviderV1ValidateContext };
@@ -497,6 +497,7 @@ interface AcpDialect {
497
497
  handleClientRequest?(method: string, params: unknown): AcpClientRequestOutcome | undefined;
498
498
  maintenance?: AcpMaintenanceDialect;
499
499
  presentModel?(model: AvailableModel): AvailableModel;
500
+ readonly elicitationDescriptionIsHeading?: boolean;
500
501
  }
501
502
  interface AcpClientRequestOutcome {
502
503
  result: Record<string, unknown>;