@builder.io/ai-utils 0.96.1 → 0.97.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/ai-utils",
3
- "version": "0.96.1",
3
+ "version": "0.97.0",
4
4
  "description": "Builder.io AI utils",
5
5
  "files": [
6
6
  "src"
package/src/codegen.d.ts CHANGED
@@ -384,6 +384,18 @@ export declare const GetScreenshotToolInputSchema: z.ZodObject<{
384
384
  height: z.ZodOptional<z.ZodNumber>;
385
385
  }, z.core.$strip>;
386
386
  export type GetScreenshotToolInput = z.infer<typeof GetScreenshotToolInputSchema>;
387
+ export declare const JudgeCommandSafetyInputSchema: z.ZodObject<{
388
+ command: z.ZodString;
389
+ }, z.core.$strip>;
390
+ export type JudgeCommandSafetyInput = z.infer<typeof JudgeCommandSafetyInputSchema>;
391
+ export declare const JudgeCommandSafetyResultSchema: z.ZodObject<{
392
+ verdict: z.ZodEnum<{
393
+ destructive: "destructive";
394
+ safe: "safe";
395
+ }>;
396
+ reason: z.ZodOptional<z.ZodString>;
397
+ }, z.core.$strip>;
398
+ export type JudgeCommandSafetyResult = z.infer<typeof JudgeCommandSafetyResultSchema>;
387
399
  export declare const NavigatePreviewToolInputSchema: z.ZodObject<{
388
400
  href: z.ZodString;
389
401
  }, z.core.$strip>;
@@ -2694,6 +2706,7 @@ export declare const CodeGenInputOptionsSchema: z.ZodObject<{
2694
2706
  v1: "v1";
2695
2707
  v2: "v2";
2696
2708
  v3: "v3";
2709
+ v4: "v4";
2697
2710
  }>>;
2698
2711
  reasoning: z.ZodOptional<z.ZodEnum<{
2699
2712
  auto: "auto";
@@ -4563,6 +4576,14 @@ export interface FusionConfig {
4563
4576
  * This is a dangerous setting that removes safety guardrails - equivalent to full shell access.
4564
4577
  */
4565
4578
  skipCommandSecurity?: boolean;
4579
+ /**
4580
+ * LaunchDarkly `command-safety-judge-enabled` flag, resolved server-side at
4581
+ * session start and threaded down since the sandbox has no LaunchDarkly
4582
+ * access of its own. When true, `executeShellCommand` routes Tier 2
4583
+ * judgment-requiring commands to the `JudgeCommandSafety` endpoint instead
4584
+ * of hard-blocking them.
4585
+ */
4586
+ commandSafetyJudgeEnabled?: boolean;
4566
4587
  /** @deprecated use devCommand */
4567
4588
  command?: string;
4568
4589
  }
package/src/codegen.js CHANGED
@@ -580,6 +580,26 @@ export const GetScreenshotToolInputSchema = z
580
580
  height: z.number().optional(),
581
581
  })
582
582
  .meta({ title: "GetScreenshotToolInput" });
583
+ export const JudgeCommandSafetyInputSchema = z
584
+ .object({
585
+ // Bounded so a caller can't force multi-megabyte payloads through this
586
+ // directly-callable, AI-credit-exempt endpoint into every completionLLM
587
+ // call — real shell commands are nowhere near this size.
588
+ command: z.string().max(20000).meta({
589
+ description: "The shell command to classify.",
590
+ }),
591
+ })
592
+ .meta({ title: "JudgeCommandSafetyInput" });
593
+ export const JudgeCommandSafetyResultSchema = z
594
+ .object({
595
+ verdict: z.enum(["safe", "destructive"]).meta({
596
+ description: "Whether the command is safe to run in this ephemeral, fully-writable sandbox, or destructive and should be denied.",
597
+ }),
598
+ reason: z.string().optional().meta({
599
+ description: "Required when verdict is destructive: a short, non-scary explanation shown to the user. Omit when safe.",
600
+ }),
601
+ })
602
+ .meta({ title: "JudgeCommandSafetyResult" });
583
603
  export const NavigatePreviewToolInputSchema = z
584
604
  .object({
585
605
  href: z.string().meta({
@@ -1962,7 +1982,7 @@ export const CodeGenInputOptionsSchema = z
1962
1982
  modelOverride: z.string().optional(),
1963
1983
  errorIfHadCompaction: z.boolean().optional(),
1964
1984
  softContextWindow: z.number().optional(),
1965
- promptVersion: z.enum(["v1", "v2", "v3"]).optional(),
1985
+ promptVersion: z.enum(["v1", "v2", "v3", "v4"]).optional(),
1966
1986
  reasoning: ReasoningEffortSchema.optional(),
1967
1987
  redactUserMessages: z.boolean().optional(),
1968
1988
  redactLLMMessages: z.boolean().optional(),
package/src/projects.d.ts CHANGED
@@ -767,6 +767,140 @@ export interface ListBranchesResult {
767
767
  }
768
768
  export type CpuKind = "performance" | "standard" | "shared";
769
769
  export type MachineAutoStop = "stop" | "off" | "suspend";
770
+ export declare const ShapeEffectSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
771
+ kind: z.ZodLiteral<"remove-env">;
772
+ scope: z.ZodLiteral<"hosting-prod">;
773
+ key: z.ZodString;
774
+ }, z.core.$strip>, z.ZodObject<{
775
+ kind: z.ZodLiteral<"attach-design-system">;
776
+ designSystemId: z.ZodString;
777
+ }, z.core.$strip>], "kind">;
778
+ export type ShapeEffect = z.infer<typeof ShapeEffectSchema>;
779
+ export declare const ShapeOptionEffectSchema: z.ZodObject<{
780
+ instruction: z.ZodOptional<z.ZodString>;
781
+ effects: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
782
+ kind: z.ZodLiteral<"remove-env">;
783
+ scope: z.ZodLiteral<"hosting-prod">;
784
+ key: z.ZodString;
785
+ }, z.core.$strip>, z.ZodObject<{
786
+ kind: z.ZodLiteral<"attach-design-system">;
787
+ designSystemId: z.ZodString;
788
+ }, z.core.$strip>], "kind">>>;
789
+ }, z.core.$strip>;
790
+ export type ShapeOptionEffect = z.infer<typeof ShapeOptionEffectSchema>;
791
+ export declare const ShapeOptionSchema: z.ZodObject<{
792
+ id: z.ZodString;
793
+ label: z.ZodString;
794
+ effect: z.ZodOptional<z.ZodObject<{
795
+ instruction: z.ZodOptional<z.ZodString>;
796
+ effects: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
797
+ kind: z.ZodLiteral<"remove-env">;
798
+ scope: z.ZodLiteral<"hosting-prod">;
799
+ key: z.ZodString;
800
+ }, z.core.$strip>, z.ZodObject<{
801
+ kind: z.ZodLiteral<"attach-design-system">;
802
+ designSystemId: z.ZodString;
803
+ }, z.core.$strip>], "kind">>>;
804
+ }, z.core.$strip>>;
805
+ }, z.core.$strip>;
806
+ export type ShapeOption = z.infer<typeof ShapeOptionSchema>;
807
+ export declare const ShapeQuestionSchema: z.ZodObject<{
808
+ id: z.ZodString;
809
+ question: z.ZodString;
810
+ kind: z.ZodEnum<{
811
+ "figma-upload": "figma-upload";
812
+ select: "select";
813
+ }>;
814
+ options: z.ZodArray<z.ZodObject<{
815
+ id: z.ZodString;
816
+ label: z.ZodString;
817
+ effect: z.ZodOptional<z.ZodObject<{
818
+ instruction: z.ZodOptional<z.ZodString>;
819
+ effects: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
820
+ kind: z.ZodLiteral<"remove-env">;
821
+ scope: z.ZodLiteral<"hosting-prod">;
822
+ key: z.ZodString;
823
+ }, z.core.$strip>, z.ZodObject<{
824
+ kind: z.ZodLiteral<"attach-design-system">;
825
+ designSystemId: z.ZodString;
826
+ }, z.core.$strip>], "kind">>>;
827
+ }, z.core.$strip>>;
828
+ }, z.core.$strip>>;
829
+ guessOptionId: z.ZodOptional<z.ZodString>;
830
+ }, z.core.$strip>;
831
+ export type ShapeQuestion = z.infer<typeof ShapeQuestionSchema>;
832
+ export declare const ShapeAnswerSchema: z.ZodObject<{
833
+ questionId: z.ZodString;
834
+ optionId: z.ZodOptional<z.ZodString>;
835
+ designSystemId: z.ZodOptional<z.ZodString>;
836
+ skipped: z.ZodBoolean;
837
+ delegated: z.ZodBoolean;
838
+ resolvedFrom: z.ZodEnum<{
839
+ llm: "llm";
840
+ user: "user";
841
+ }>;
842
+ llmOptionId: z.ZodOptional<z.ZodString>;
843
+ guessOptionId: z.ZodOptional<z.ZodString>;
844
+ }, z.core.$strip>;
845
+ export type ShapeAnswer = z.infer<typeof ShapeAnswerSchema>;
846
+ export declare const ShapeSessionSchema: z.ZodObject<{
847
+ questionnaireId: z.ZodString;
848
+ catalogVersion: z.ZodString;
849
+ source: z.ZodEnum<{
850
+ agent: "agent";
851
+ static: "static";
852
+ }>;
853
+ status: z.ZodEnum<{
854
+ assembling: "assembling";
855
+ pending: "pending";
856
+ resolved: "resolved";
857
+ }>;
858
+ selection: z.ZodEnum<{
859
+ fallback: "fallback";
860
+ llm: "llm";
861
+ }>;
862
+ questions: z.ZodArray<z.ZodObject<{
863
+ id: z.ZodString;
864
+ question: z.ZodString;
865
+ kind: z.ZodEnum<{
866
+ "figma-upload": "figma-upload";
867
+ select: "select";
868
+ }>;
869
+ options: z.ZodArray<z.ZodObject<{
870
+ id: z.ZodString;
871
+ label: z.ZodString;
872
+ effect: z.ZodOptional<z.ZodObject<{
873
+ instruction: z.ZodOptional<z.ZodString>;
874
+ effects: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
875
+ kind: z.ZodLiteral<"remove-env">;
876
+ scope: z.ZodLiteral<"hosting-prod">;
877
+ key: z.ZodString;
878
+ }, z.core.$strip>, z.ZodObject<{
879
+ kind: z.ZodLiteral<"attach-design-system">;
880
+ designSystemId: z.ZodString;
881
+ }, z.core.$strip>], "kind">>>;
882
+ }, z.core.$strip>>;
883
+ }, z.core.$strip>>;
884
+ guessOptionId: z.ZodOptional<z.ZodString>;
885
+ }, z.core.$strip>>;
886
+ initialPromptId: z.ZodString;
887
+ answers: z.ZodOptional<z.ZodArray<z.ZodObject<{
888
+ questionId: z.ZodString;
889
+ optionId: z.ZodOptional<z.ZodString>;
890
+ designSystemId: z.ZodOptional<z.ZodString>;
891
+ skipped: z.ZodBoolean;
892
+ delegated: z.ZodBoolean;
893
+ resolvedFrom: z.ZodEnum<{
894
+ llm: "llm";
895
+ user: "user";
896
+ }>;
897
+ llmOptionId: z.ZodOptional<z.ZodString>;
898
+ guessOptionId: z.ZodOptional<z.ZodString>;
899
+ }, z.core.$strip>>>;
900
+ assembledAt: z.ZodOptional<z.ZodString>;
901
+ resolvedAt: z.ZodOptional<z.ZodString>;
902
+ }, z.core.$strip>;
903
+ export type ShapeSession = z.infer<typeof ShapeSessionSchema>;
770
904
  export declare const ProjectRolePermissionsSchema: z.ZodObject<{
771
905
  view: z.ZodOptional<z.ZodBoolean>;
772
906
  editCode: z.ZodOptional<z.ZodBoolean>;
@@ -1171,6 +1305,63 @@ export declare const ProjectSettingsSchema: z.ZodObject<{
1171
1305
  enabled: z.ZodBoolean;
1172
1306
  password: z.ZodOptional<z.ZodString>;
1173
1307
  }, z.core.$strip>>;
1308
+ shapeSession: z.ZodOptional<z.ZodObject<{
1309
+ questionnaireId: z.ZodString;
1310
+ catalogVersion: z.ZodString;
1311
+ source: z.ZodEnum<{
1312
+ agent: "agent";
1313
+ static: "static";
1314
+ }>;
1315
+ status: z.ZodEnum<{
1316
+ assembling: "assembling";
1317
+ pending: "pending";
1318
+ resolved: "resolved";
1319
+ }>;
1320
+ selection: z.ZodEnum<{
1321
+ fallback: "fallback";
1322
+ llm: "llm";
1323
+ }>;
1324
+ questions: z.ZodArray<z.ZodObject<{
1325
+ id: z.ZodString;
1326
+ question: z.ZodString;
1327
+ kind: z.ZodEnum<{
1328
+ "figma-upload": "figma-upload";
1329
+ select: "select";
1330
+ }>;
1331
+ options: z.ZodArray<z.ZodObject<{
1332
+ id: z.ZodString;
1333
+ label: z.ZodString;
1334
+ effect: z.ZodOptional<z.ZodObject<{
1335
+ instruction: z.ZodOptional<z.ZodString>;
1336
+ effects: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1337
+ kind: z.ZodLiteral<"remove-env">;
1338
+ scope: z.ZodLiteral<"hosting-prod">;
1339
+ key: z.ZodString;
1340
+ }, z.core.$strip>, z.ZodObject<{
1341
+ kind: z.ZodLiteral<"attach-design-system">;
1342
+ designSystemId: z.ZodString;
1343
+ }, z.core.$strip>], "kind">>>;
1344
+ }, z.core.$strip>>;
1345
+ }, z.core.$strip>>;
1346
+ guessOptionId: z.ZodOptional<z.ZodString>;
1347
+ }, z.core.$strip>>;
1348
+ initialPromptId: z.ZodString;
1349
+ answers: z.ZodOptional<z.ZodArray<z.ZodObject<{
1350
+ questionId: z.ZodString;
1351
+ optionId: z.ZodOptional<z.ZodString>;
1352
+ designSystemId: z.ZodOptional<z.ZodString>;
1353
+ skipped: z.ZodBoolean;
1354
+ delegated: z.ZodBoolean;
1355
+ resolvedFrom: z.ZodEnum<{
1356
+ llm: "llm";
1357
+ user: "user";
1358
+ }>;
1359
+ llmOptionId: z.ZodOptional<z.ZodString>;
1360
+ guessOptionId: z.ZodOptional<z.ZodString>;
1361
+ }, z.core.$strip>>>;
1362
+ assembledAt: z.ZodOptional<z.ZodString>;
1363
+ resolvedAt: z.ZodOptional<z.ZodString>;
1364
+ }, z.core.$strip>>;
1174
1365
  }, z.core.$strip>;
1175
1366
  export type ProjectSettings = z.infer<typeof ProjectSettingsSchema>;
1176
1367
  /**
@@ -1935,6 +2126,7 @@ export interface CreateBranchOptions {
1935
2126
  branchFriendlyName?: string;
1936
2127
  agentType?: AgentType;
1937
2128
  actor: string;
2129
+ isPublic?: boolean;
1938
2130
  hidden?: boolean;
1939
2131
  featureFlags?: Record<string, boolean>;
1940
2132
  checkoutBranch?: string | null;
@@ -1992,6 +2184,7 @@ export interface CreateBranchOptions {
1992
2184
  */
1993
2185
  sessionId?: string;
1994
2186
  }
2187
+ export declare function resolveBranchIsPublic(isPublic: boolean | undefined, defaultBranchType: "shared" | "private" | undefined): boolean;
1995
2188
  interface BaseCreateBranchMessage {
1996
2189
  }
1997
2190
  export interface CreatingBranchMessage extends BaseCreateBranchMessage {
@@ -3444,6 +3637,20 @@ export declare const CloneProjectOptionsSchema: z.ZodObject<{
3444
3637
  useKube: z.ZodDefault<z.ZodBoolean>;
3445
3638
  }, z.core.$strip>;
3446
3639
  export type CloneProjectOptions = z.infer<typeof CloneProjectOptionsSchema>;
3640
+ export declare const GetPreferredProjectForRepoOptionsSchema: z.ZodObject<{
3641
+ repoUrl: z.ZodString;
3642
+ repoFullName: z.ZodOptional<z.ZodString>;
3643
+ }, z.core.$strip>;
3644
+ export type GetPreferredProjectForRepoOptions = z.infer<typeof GetPreferredProjectForRepoOptionsSchema>;
3645
+ /** Identity only — this powers a "currently preferred: X" label, not a project read. */
3646
+ export declare const GetPreferredProjectForRepoResultSchema: z.ZodObject<{
3647
+ status: z.ZodLiteral<"success">;
3648
+ project: z.ZodNullable<z.ZodObject<{
3649
+ id: z.ZodString;
3650
+ name: z.ZodString;
3651
+ }, z.core.$strip>>;
3652
+ }, z.core.$strip>;
3653
+ export type GetPreferredProjectForRepoResult = z.infer<typeof GetPreferredProjectForRepoResultSchema>;
3447
3654
  /**
3448
3655
  * Write-time contract for a single hosted-site access rule. Mirrors the stored
3449
3656
  * {@link SiteAccessRule} in `organization.ts`, except a password rule carries a
@@ -3972,6 +4179,63 @@ export declare const ProjectTemplateSchema: z.ZodObject<{
3972
4179
  enabled: z.ZodBoolean;
3973
4180
  password: z.ZodOptional<z.ZodString>;
3974
4181
  }, z.core.$strip>>>;
4182
+ shapeSession: z.ZodOptional<z.ZodOptional<z.ZodObject<{
4183
+ questionnaireId: z.ZodString;
4184
+ catalogVersion: z.ZodString;
4185
+ source: z.ZodEnum<{
4186
+ agent: "agent";
4187
+ static: "static";
4188
+ }>;
4189
+ status: z.ZodEnum<{
4190
+ assembling: "assembling";
4191
+ pending: "pending";
4192
+ resolved: "resolved";
4193
+ }>;
4194
+ selection: z.ZodEnum<{
4195
+ fallback: "fallback";
4196
+ llm: "llm";
4197
+ }>;
4198
+ questions: z.ZodArray<z.ZodObject<{
4199
+ id: z.ZodString;
4200
+ question: z.ZodString;
4201
+ kind: z.ZodEnum<{
4202
+ "figma-upload": "figma-upload";
4203
+ select: "select";
4204
+ }>;
4205
+ options: z.ZodArray<z.ZodObject<{
4206
+ id: z.ZodString;
4207
+ label: z.ZodString;
4208
+ effect: z.ZodOptional<z.ZodObject<{
4209
+ instruction: z.ZodOptional<z.ZodString>;
4210
+ effects: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
4211
+ kind: z.ZodLiteral<"remove-env">;
4212
+ scope: z.ZodLiteral<"hosting-prod">;
4213
+ key: z.ZodString;
4214
+ }, z.core.$strip>, z.ZodObject<{
4215
+ kind: z.ZodLiteral<"attach-design-system">;
4216
+ designSystemId: z.ZodString;
4217
+ }, z.core.$strip>], "kind">>>;
4218
+ }, z.core.$strip>>;
4219
+ }, z.core.$strip>>;
4220
+ guessOptionId: z.ZodOptional<z.ZodString>;
4221
+ }, z.core.$strip>>;
4222
+ initialPromptId: z.ZodString;
4223
+ answers: z.ZodOptional<z.ZodArray<z.ZodObject<{
4224
+ questionId: z.ZodString;
4225
+ optionId: z.ZodOptional<z.ZodString>;
4226
+ designSystemId: z.ZodOptional<z.ZodString>;
4227
+ skipped: z.ZodBoolean;
4228
+ delegated: z.ZodBoolean;
4229
+ resolvedFrom: z.ZodEnum<{
4230
+ llm: "llm";
4231
+ user: "user";
4232
+ }>;
4233
+ llmOptionId: z.ZodOptional<z.ZodString>;
4234
+ guessOptionId: z.ZodOptional<z.ZodString>;
4235
+ }, z.core.$strip>>>;
4236
+ assembledAt: z.ZodOptional<z.ZodString>;
4237
+ resolvedAt: z.ZodOptional<z.ZodString>;
4238
+ }, z.core.$strip>>>;
3975
4239
  }, z.core.$strip>;
3976
4240
  hosting: z.ZodOptional<z.ZodObject<{
3977
4241
  enabled: z.ZodOptional<z.ZodBoolean>;
@@ -4077,36 +4341,13 @@ export declare const ProjectTemplateOverridesSchema: z.ZodObject<{
4077
4341
  containerized: "containerized";
4078
4342
  }>>>;
4079
4343
  devServerPort: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
4080
- devServerUrl: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4081
- refreshPreview: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4082
4344
  installCommand: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4083
4345
  installNpmrc: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
4084
- validateCommand: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4085
- proxyOrigin: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4086
- proxyDefaultOrigin: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4087
- defaultAutoPush: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
4088
- "ff-push": "ff-push";
4089
- "force-push": "force-push";
4090
- "merge-push": "merge-push";
4091
- none: "none";
4092
- "safe-push": "safe-push";
4093
- }>>>;
4094
4346
  gitBranchNamingStrategy: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
4095
4347
  "ai-session": "ai-session";
4096
4348
  "branch-name": "branch-name";
4097
4349
  custom: "custom";
4098
4350
  }>>>;
4099
- setupDependencies: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
4100
- key: z.ZodString;
4101
- type: z.ZodLiteral<"mise">;
4102
- tool: z.ZodString;
4103
- version: z.ZodOptional<z.ZodString>;
4104
- }, z.core.$strip>, z.ZodObject<{
4105
- key: z.ZodString;
4106
- type: z.ZodLiteral<"script">;
4107
- name: z.ZodString;
4108
- script: z.ZodString;
4109
- }, z.core.$strip>], "type">>>>;
4110
4351
  hostRequirements: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
4111
4352
  name: z.ZodString;
4112
4353
  checkScript: z.ZodString;
@@ -4169,7 +4410,6 @@ export declare const ProjectTemplateOverridesSchema: z.ZodObject<{
4169
4410
  mainBranchName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4170
4411
  minMachinesRunning: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
4171
4412
  volumeSize: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<5>, z.ZodLiteral<10>, z.ZodLiteral<12>, z.ZodLiteral<15>, z.ZodLiteral<20>, z.ZodLiteral<25>, z.ZodLiteral<30>, z.ZodLiteral<50>]>>>;
4172
- includePath: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4173
4413
  includePatterns: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
4174
4414
  errorIgnorePatterns: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
4175
4415
  environmentVariables: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -4337,7 +4577,6 @@ export declare const ProjectTemplateOverridesSchema: z.ZodObject<{
4337
4577
  "draft-prs": "draft-prs";
4338
4578
  prs: "prs";
4339
4579
  }>>>;
4340
- autoCloseBranchOnMerge: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4341
4580
  enableMergePR: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4342
4581
  minRequiredApprovals: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
4343
4582
  requireApprovalBeforePR: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
@@ -4354,7 +4593,6 @@ export declare const ProjectTemplateOverridesSchema: z.ZodObject<{
4354
4593
  designSystems: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
4355
4594
  designTokenStrictMode: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4356
4595
  designModeSelector: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4357
- useNI: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4358
4596
  folders: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
4359
4597
  name: z.ZodString;
4360
4598
  remoteUrl: z.ZodString;
@@ -4367,8 +4605,6 @@ export declare const ProjectTemplateOverridesSchema: z.ZodObject<{
4367
4605
  }, z.core.$strip>>>>;
4368
4606
  agentsMD: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4369
4607
  initializationCommand: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4370
- repoSubpath: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4371
- recommendedRoot: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4372
4608
  https: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4373
4609
  localHttpsDomain: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4374
4610
  browserAutomation: z.ZodOptional<z.ZodOptional<z.ZodObject<{
@@ -4390,7 +4626,6 @@ export declare const ProjectTemplateOverridesSchema: z.ZodObject<{
4390
4626
  }, z.core.$strip>>>;
4391
4627
  enableSnapshots: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4392
4628
  postMergeMemories: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4393
- commitInstructions: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4394
4629
  maxAgentCompletions: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
4395
4630
  enableAgentMode: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4396
4631
  allowPreviewAutoSubmit: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
@@ -4402,7 +4637,6 @@ export declare const ProjectTemplateOverridesSchema: z.ZodObject<{
4402
4637
  timestamp: z.ZodNumber;
4403
4638
  starred: z.ZodBoolean;
4404
4639
  }, z.core.$strip>>>>;
4405
- skipCommandSecurity: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4406
4640
  httpsServerKeyPath: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4407
4641
  httpsServerCertPath: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4408
4642
  httpsServerCaPath: z.ZodOptional<z.ZodOptional<z.ZodString>>;
@@ -4484,36 +4718,13 @@ export declare const CreateProjectTemplateFromProjectOptionsSchema: z.ZodObject<
4484
4718
  containerized: "containerized";
4485
4719
  }>>>;
4486
4720
  devServerPort: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
4487
- devServerUrl: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4488
- refreshPreview: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4489
4721
  installCommand: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4490
4722
  installNpmrc: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
4491
- validateCommand: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4492
- proxyOrigin: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4493
- proxyDefaultOrigin: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4494
- defaultAutoPush: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
4495
- "ff-push": "ff-push";
4496
- "force-push": "force-push";
4497
- "merge-push": "merge-push";
4498
- none: "none";
4499
- "safe-push": "safe-push";
4500
- }>>>;
4501
4723
  gitBranchNamingStrategy: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
4502
4724
  "ai-session": "ai-session";
4503
4725
  "branch-name": "branch-name";
4504
4726
  custom: "custom";
4505
4727
  }>>>;
4506
- setupDependencies: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
4507
- key: z.ZodString;
4508
- type: z.ZodLiteral<"mise">;
4509
- tool: z.ZodString;
4510
- version: z.ZodOptional<z.ZodString>;
4511
- }, z.core.$strip>, z.ZodObject<{
4512
- key: z.ZodString;
4513
- type: z.ZodLiteral<"script">;
4514
- name: z.ZodString;
4515
- script: z.ZodString;
4516
- }, z.core.$strip>], "type">>>>;
4517
4728
  hostRequirements: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
4518
4729
  name: z.ZodString;
4519
4730
  checkScript: z.ZodString;
@@ -4576,7 +4787,6 @@ export declare const CreateProjectTemplateFromProjectOptionsSchema: z.ZodObject<
4576
4787
  mainBranchName: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4577
4788
  minMachinesRunning: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
4578
4789
  volumeSize: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<5>, z.ZodLiteral<10>, z.ZodLiteral<12>, z.ZodLiteral<15>, z.ZodLiteral<20>, z.ZodLiteral<25>, z.ZodLiteral<30>, z.ZodLiteral<50>]>>>;
4579
- includePath: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4580
4790
  includePatterns: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
4581
4791
  errorIgnorePatterns: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
4582
4792
  environmentVariables: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -4744,7 +4954,6 @@ export declare const CreateProjectTemplateFromProjectOptionsSchema: z.ZodObject<
4744
4954
  "draft-prs": "draft-prs";
4745
4955
  prs: "prs";
4746
4956
  }>>>;
4747
- autoCloseBranchOnMerge: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4748
4957
  enableMergePR: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4749
4958
  minRequiredApprovals: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
4750
4959
  requireApprovalBeforePR: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
@@ -4761,7 +4970,6 @@ export declare const CreateProjectTemplateFromProjectOptionsSchema: z.ZodObject<
4761
4970
  designSystems: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
4762
4971
  designTokenStrictMode: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4763
4972
  designModeSelector: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4764
- useNI: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4765
4973
  folders: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
4766
4974
  name: z.ZodString;
4767
4975
  remoteUrl: z.ZodString;
@@ -4774,8 +4982,6 @@ export declare const CreateProjectTemplateFromProjectOptionsSchema: z.ZodObject<
4774
4982
  }, z.core.$strip>>>>;
4775
4983
  agentsMD: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4776
4984
  initializationCommand: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4777
- repoSubpath: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4778
- recommendedRoot: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4779
4985
  https: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4780
4986
  localHttpsDomain: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4781
4987
  browserAutomation: z.ZodOptional<z.ZodOptional<z.ZodObject<{
@@ -4797,7 +5003,6 @@ export declare const CreateProjectTemplateFromProjectOptionsSchema: z.ZodObject<
4797
5003
  }, z.core.$strip>>>;
4798
5004
  enableSnapshots: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4799
5005
  postMergeMemories: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4800
- commitInstructions: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4801
5006
  maxAgentCompletions: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
4802
5007
  enableAgentMode: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4803
5008
  allowPreviewAutoSubmit: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
@@ -4809,7 +5014,6 @@ export declare const CreateProjectTemplateFromProjectOptionsSchema: z.ZodObject<
4809
5014
  timestamp: z.ZodNumber;
4810
5015
  starred: z.ZodBoolean;
4811
5016
  }, z.core.$strip>>>>;
4812
- skipCommandSecurity: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
4813
5017
  httpsServerKeyPath: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4814
5018
  httpsServerCertPath: z.ZodOptional<z.ZodOptional<z.ZodString>>;
4815
5019
  httpsServerCaPath: z.ZodOptional<z.ZodOptional<z.ZodString>>;
package/src/projects.js CHANGED
@@ -271,6 +271,55 @@ export const ListBranchesOptionsSchema = z.object({
271
271
  description: "Superuser-only: list branches for a different owner/org.",
272
272
  }),
273
273
  });
274
+ export const ShapeEffectSchema = z.discriminatedUnion("kind", [
275
+ z.object({
276
+ kind: z.literal("remove-env"),
277
+ scope: z.literal("hosting-prod"),
278
+ key: z.string(),
279
+ }),
280
+ z.object({
281
+ kind: z.literal("attach-design-system"),
282
+ designSystemId: z.string(),
283
+ }),
284
+ ]);
285
+ export const ShapeOptionEffectSchema = z.object({
286
+ instruction: z.string().optional(),
287
+ effects: z.array(ShapeEffectSchema).optional(),
288
+ });
289
+ export const ShapeOptionSchema = z.object({
290
+ id: z.string(),
291
+ label: z.string(),
292
+ effect: ShapeOptionEffectSchema.optional(),
293
+ });
294
+ export const ShapeQuestionSchema = z.object({
295
+ id: z.string(),
296
+ question: z.string(),
297
+ kind: z.enum(["select", "figma-upload"]),
298
+ options: z.array(ShapeOptionSchema),
299
+ guessOptionId: z.string().optional(),
300
+ });
301
+ export const ShapeAnswerSchema = z.object({
302
+ questionId: z.string(),
303
+ optionId: z.string().optional(),
304
+ designSystemId: z.string().optional(),
305
+ skipped: z.boolean(),
306
+ delegated: z.boolean(),
307
+ resolvedFrom: z.enum(["user", "llm"]),
308
+ llmOptionId: z.string().optional(),
309
+ guessOptionId: z.string().optional(),
310
+ });
311
+ export const ShapeSessionSchema = z.object({
312
+ questionnaireId: z.string(),
313
+ catalogVersion: z.string().regex(/^\d{4}-\d{2}-\d{2}\.\d+$/),
314
+ source: z.enum(["static", "agent"]),
315
+ status: z.enum(["assembling", "pending", "resolved"]),
316
+ selection: z.enum(["llm", "fallback"]),
317
+ questions: z.array(ShapeQuestionSchema),
318
+ initialPromptId: z.string(),
319
+ answers: z.array(ShapeAnswerSchema).optional(),
320
+ assembledAt: z.string().optional(),
321
+ resolvedAt: z.string().optional(),
322
+ });
274
323
  export const ProjectRolePermissionsSchema = z
275
324
  .object({
276
325
  view: z.boolean().optional(),
@@ -758,6 +807,9 @@ export const ProjectSettingsSchema = z
758
807
  })
759
808
  .optional()
760
809
  .meta({ description: "Password-protect the preview URL." }),
810
+ shapeSession: ShapeSessionSchema.optional().meta({
811
+ description: "@internal Guided-onboarding questionnaire issued for this project.",
812
+ }),
761
813
  })
762
814
  .meta({ title: "ProjectSettings" });
763
815
  /**
@@ -781,6 +833,7 @@ const INTERNAL_PROJECT_SETTINGS_MASK = {
781
833
  commitInstructions: true,
782
834
  skipCommandSecurity: true,
783
835
  autoCloseBranchOnMerge: true,
836
+ shapeSession: true,
784
837
  };
785
838
  /**
786
839
  * Runtime schema for the client-writable subset of {@link Project.settings},
@@ -885,6 +938,13 @@ export const CreateProjectRequestSchema = z.object({
885
938
  /** Design system ids to seed into project settings at creation. */
886
939
  designSystems: z.array(z.string()).optional(),
887
940
  });
941
+ export function resolveBranchIsPublic(isPublic, defaultBranchType) {
942
+ if (isPublic !== undefined)
943
+ return isPublic;
944
+ if (defaultBranchType === undefined)
945
+ return true;
946
+ return defaultBranchType === "shared";
947
+ }
888
948
  export const MEMORY_PICKED_FIELDS = [
889
949
  "id",
890
950
  "updatedAt",
@@ -1897,6 +1957,24 @@ export const CloneProjectOptionsSchema = z.object({
1897
1957
  description: "Whether to provision on cloud-v2 (Kubernetes). Defaults to false.",
1898
1958
  }),
1899
1959
  });
1960
+ export const GetPreferredProjectForRepoOptionsSchema = z.object({
1961
+ repoUrl: z.string().min(1).meta({
1962
+ description: "Full clone URL of the repository to look up.",
1963
+ }),
1964
+ repoFullName: z.string().optional().meta({
1965
+ description: 'Repo in "owner/repo" form; derived from `repoUrl` when omitted.',
1966
+ }),
1967
+ });
1968
+ /** Identity only — this powers a "currently preferred: X" label, not a project read. */
1969
+ export const GetPreferredProjectForRepoResultSchema = z.object({
1970
+ status: z.literal("success"),
1971
+ project: z
1972
+ .object({
1973
+ id: z.string(),
1974
+ name: z.string(),
1975
+ })
1976
+ .nullable(),
1977
+ });
1900
1978
  /**
1901
1979
  * Write-time contract for a single hosted-site access rule. Mirrors the stored
1902
1980
  * {@link SiteAccessRule} in `organization.ts`, except a password rule carries a
@@ -2039,6 +2117,7 @@ export const ProjectTemplateOverridesSchema = z.object({
2039
2117
  sourceProjectId: true,
2040
2118
  sourceBranchName: true,
2041
2119
  }).partial().shape,
2120
+ settings: ProjectSettingsExternalSchema.partial().optional(),
2042
2121
  hosting: ProjectHostingExternalSchema.optional(),
2043
2122
  });
2044
2123
  export const CreateProjectTemplateFromProjectOptionsSchema = z.object({
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { AGENT_NATIVE_STARTER_REPO, getAgentNativeRootPackageJsonWriteError, getManagedDatabasePackageJsonError, matchesAgentNativeStarter, ProjectHostingExternalSchema, ProjectHostingSchema, } from "./projects";
2
+ import { AGENT_NATIVE_STARTER_REPO, getAgentNativeRootPackageJsonWriteError, getManagedDatabasePackageJsonError, matchesAgentNativeStarter, ProjectHostingExternalSchema, ProjectHostingSchema, ProjectSettingsExternalSchema, ProjectSettingsSchema, ProjectTemplateOverridesSchema, ShapeSessionSchema, } from "./projects";
3
3
  describe("project hosting schemas", () => {
4
4
  it("accepts the canonical published branch route", () => {
5
5
  expect(ProjectHostingSchema.parse({ publishedBranchId: "branch-live" })).toEqual({ publishedBranchId: "branch-live" });
@@ -11,6 +11,55 @@ describe("project hosting schemas", () => {
11
11
  })).toEqual({ enabled: true });
12
12
  });
13
13
  });
14
+ describe("guided onboarding project settings", () => {
15
+ const shapeSession = {
16
+ questionnaireId: "questionnaire-1",
17
+ catalogVersion: "2026-09-03.1",
18
+ source: "static",
19
+ status: "pending",
20
+ selection: "llm",
21
+ questions: [
22
+ {
23
+ id: "authentication",
24
+ question: "Will users need to login to use your app?",
25
+ kind: "select",
26
+ options: [
27
+ {
28
+ id: "required",
29
+ label: "Yes",
30
+ effect: {
31
+ instruction: "Require users to sign in.",
32
+ effects: [
33
+ {
34
+ kind: "remove-env",
35
+ scope: "hosting-prod",
36
+ key: "AUTH_DISABLED",
37
+ },
38
+ ],
39
+ },
40
+ },
41
+ ],
42
+ },
43
+ ],
44
+ initialPromptId: "prompt-1",
45
+ };
46
+ it("parses a snapshotted questionnaire session", () => {
47
+ expect(ShapeSessionSchema.parse(shapeSession)).toEqual(shapeSession);
48
+ expect(ProjectSettingsSchema.parse({ shapeSession })).toEqual({
49
+ shapeSession,
50
+ });
51
+ });
52
+ it("requires a dated catalog version", () => {
53
+ expect(() => ShapeSessionSchema.parse({
54
+ ...shapeSession,
55
+ catalogVersion: "v1",
56
+ })).toThrow();
57
+ });
58
+ it("does not allow clients to write a shape session", () => {
59
+ expect(ProjectSettingsExternalSchema.parse({ shapeSession })).toEqual({});
60
+ expect(ProjectTemplateOverridesSchema.parse({ settings: { shapeSession } })).toEqual({ settings: {} });
61
+ });
62
+ });
14
63
  describe("matchesAgentNativeStarter", () => {
15
64
  it("matches when repoName is the starter", () => {
16
65
  expect(matchesAgentNativeStarter({ repoName: AGENT_NATIVE_STARTER_REPO })).toBe(true);