@builder.io/ai-utils 0.83.0 → 0.84.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 +1 -1
- package/src/claw.d.ts +1 -0
- package/src/claw.js +9 -0
- package/src/claw.spec.js +11 -1
- package/src/codegen.d.ts +11 -0
- package/src/codegen.js +21 -1
- package/src/design-systems.d.ts +160 -60
- package/src/design-systems.js +91 -39
- package/src/events.d.ts +4 -0
- package/src/projects.d.ts +3 -2
- package/src/projects.js +2 -0
- package/src/repo-indexing.d.ts +12 -0
package/package.json
CHANGED
package/src/claw.d.ts
CHANGED
|
@@ -101,6 +101,7 @@ export type ChannelType<P extends KnownPlatform> = (typeof CHANNEL_TYPES)[P][num
|
|
|
101
101
|
/** Union of every channel sub-type across all platforms. */
|
|
102
102
|
export type AnyChannelType = ChannelType<KnownPlatform>;
|
|
103
103
|
export declare function isChannelType<P extends KnownPlatform>(platform: P, type: string): type is ChannelType<P>;
|
|
104
|
+
export declare function isBuilderBranchChannelId(channelId: string): boolean;
|
|
104
105
|
/** Platform recorded on a logged message; "unknown" when the channelId fails to parse. */
|
|
105
106
|
export type ChannelSource = KnownPlatform | "unknown";
|
|
106
107
|
/** Channel sub-type recorded on a logged message; "unknown" when parsing fails. */
|
package/src/claw.js
CHANGED
|
@@ -81,6 +81,15 @@ export const CHANNEL_TYPES = {
|
|
|
81
81
|
export function isChannelType(platform, type) {
|
|
82
82
|
return CHANNEL_TYPES[platform].includes(type);
|
|
83
83
|
}
|
|
84
|
+
export function isBuilderBranchChannelId(channelId) {
|
|
85
|
+
try {
|
|
86
|
+
const channel = parseChannelId(channelId);
|
|
87
|
+
return channel.platform === "builder" && channel.type === "branch";
|
|
88
|
+
}
|
|
89
|
+
catch (_a) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
84
93
|
/**
|
|
85
94
|
* Converts a Builder channel_id URI to a clickable URL for the
|
|
86
95
|
* corresponding platform (Slack, Jira, etc.).
|
package/src/claw.spec.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { convertChannelIdToUrl, formatIncomingMessage, formatWorkerMessage, formatWorkerReport, } from "./claw";
|
|
2
|
+
import { convertChannelIdToUrl, formatIncomingMessage, formatWorkerMessage, formatWorkerReport, isBuilderBranchChannelId, } from "./claw";
|
|
3
|
+
describe("isBuilderBranchChannelId", () => {
|
|
4
|
+
it("recognizes Builder branch channel IDs", () => {
|
|
5
|
+
expect(isBuilderBranchChannelId("builder/branch/proj-id/my-branch")).toBe(true);
|
|
6
|
+
});
|
|
7
|
+
it("rejects other and invalid channel IDs", () => {
|
|
8
|
+
expect(isBuilderBranchChannelId("slack/channel/team/channel")).toBe(false);
|
|
9
|
+
expect(isBuilderBranchChannelId("builder/project/proj-id")).toBe(false);
|
|
10
|
+
expect(isBuilderBranchChannelId("invalid")).toBe(false);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
3
13
|
describe("convertChannelIdToUrl", () => {
|
|
4
14
|
describe("slack/thread format", () => {
|
|
5
15
|
it("converts a thread channel ID to a Slack app_redirect URL", () => {
|
package/src/codegen.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { type EnvironmentVariable, type SetupDependency } from "./common-schemas
|
|
|
6
6
|
import type { ForcedBackup, GitDiagnostics, ProjectSkill } from "./projects";
|
|
7
7
|
import type { Feature } from "./features";
|
|
8
8
|
import type { CpuKind, BranchType } from "./projects";
|
|
9
|
+
import type { FullLibrarySourceInput } from "./design-systems";
|
|
9
10
|
export declare const GitSnapshotSchema: z.ZodString;
|
|
10
11
|
export type GitSnapshot = z.infer<typeof GitSnapshotSchema>;
|
|
11
12
|
export declare const ImportTypeSchema: z.ZodEnum<{
|
|
@@ -229,6 +230,10 @@ export declare const DevServerLogsInputSchema: z.ZodObject<{}, z.core.$strip>;
|
|
|
229
230
|
export type DevServerLogsInput = z.infer<typeof DevServerLogsInputSchema>;
|
|
230
231
|
export declare const GenerateDesignSystemAgentMdInputSchema: z.ZodObject<{}, z.core.$strip>;
|
|
231
232
|
export type GenerateDesignSystemAgentMdInput = z.infer<typeof GenerateDesignSystemAgentMdInputSchema>;
|
|
233
|
+
export declare const ComputeDocHashInputSchema: z.ZodObject<{
|
|
234
|
+
relevantFiles: z.ZodArray<z.ZodString>;
|
|
235
|
+
}, z.core.$strip>;
|
|
236
|
+
export type ComputeDocHashInput = z.infer<typeof ComputeDocHashInputSchema>;
|
|
232
237
|
export declare const DevServerRestartInputSchema: z.ZodObject<{}, z.core.$strip>;
|
|
233
238
|
export type DevServerRestartInput = z.infer<typeof DevServerRestartInputSchema>;
|
|
234
239
|
export declare const BashToolInputSchema: z.ZodObject<{
|
|
@@ -1974,6 +1979,9 @@ export declare const CodeGenToolMapSchema: z.ZodObject<{
|
|
|
1974
1979
|
purpose: z.ZodOptional<z.ZodString>;
|
|
1975
1980
|
}, z.core.$strip>;
|
|
1976
1981
|
GenerateDesignSystemAgentMd: z.ZodObject<{}, z.core.$strip>;
|
|
1982
|
+
ComputeDocHash: z.ZodObject<{
|
|
1983
|
+
relevantFiles: z.ZodArray<z.ZodString>;
|
|
1984
|
+
}, z.core.$strip>;
|
|
1977
1985
|
}, z.core.$strip>;
|
|
1978
1986
|
export type CodeGenToolMap = z.infer<typeof CodeGenToolMapSchema>;
|
|
1979
1987
|
export declare const CodeGenToolsSchema: z.ZodEnum<{
|
|
@@ -1984,6 +1992,7 @@ export declare const CodeGenToolsSchema: z.ZodEnum<{
|
|
|
1984
1992
|
AskUserQuestion: "AskUserQuestion";
|
|
1985
1993
|
Bash: "Bash";
|
|
1986
1994
|
BuilderEdit: "BuilderEdit";
|
|
1995
|
+
ComputeDocHash: "ComputeDocHash";
|
|
1987
1996
|
ConnectMCP: "ConnectMCP";
|
|
1988
1997
|
CreateProject: "CreateProject";
|
|
1989
1998
|
DevServerControl: "DevServerControl";
|
|
@@ -2708,6 +2717,7 @@ export declare const CodeGenInputOptionsSchema: z.ZodObject<{
|
|
|
2708
2717
|
AskUserQuestion: "AskUserQuestion";
|
|
2709
2718
|
Bash: "Bash";
|
|
2710
2719
|
BuilderEdit: "BuilderEdit";
|
|
2720
|
+
ComputeDocHash: "ComputeDocHash";
|
|
2711
2721
|
ConnectMCP: "ConnectMCP";
|
|
2712
2722
|
CreateProject: "CreateProject";
|
|
2713
2723
|
DevServerControl: "DevServerControl";
|
|
@@ -4235,6 +4245,7 @@ export interface FusionConfig {
|
|
|
4235
4245
|
* `branchType === "design-system-indexing"` branches.
|
|
4236
4246
|
*/
|
|
4237
4247
|
figmaDecodeJobId?: string;
|
|
4248
|
+
designSystemIndexSources?: FullLibrarySourceInput[];
|
|
4238
4249
|
featureBranch?: string;
|
|
4239
4250
|
/** When set, init checks out this exact git commit after cloning featureBranch. */
|
|
4240
4251
|
checkoutCommit?: string;
|
package/src/codegen.js
CHANGED
|
@@ -211,6 +211,25 @@ export const GenerateDesignSystemAgentMdInputSchema = z.object({}).meta({
|
|
|
211
211
|
" globs `.builder/output/tokens/components/*.css` for component slugs." +
|
|
212
212
|
" Call this as the final step after all CSS files have been written.",
|
|
213
213
|
});
|
|
214
|
+
export const ComputeDocHashInputSchema = z
|
|
215
|
+
.object({
|
|
216
|
+
relevantFiles: z
|
|
217
|
+
.array(z.string())
|
|
218
|
+
.min(1)
|
|
219
|
+
.meta({
|
|
220
|
+
description: "Workspace-relative paths of the source files that define this doc" +
|
|
221
|
+
" (the same `relevantFiles` recorded in the doc's meta.json). The" +
|
|
222
|
+
" hash is computed deterministically from these files' contents.",
|
|
223
|
+
}),
|
|
224
|
+
})
|
|
225
|
+
.meta({
|
|
226
|
+
title: "ComputeDocHashInput",
|
|
227
|
+
description: "Deterministically computes the content hash for an indexed design-system" +
|
|
228
|
+
" doc from its `relevantFiles`, using the exact algorithm the repo-indexing" +
|
|
229
|
+
" CLI uses (sorted files, BOM-stripped contents joined with newlines," +
|
|
230
|
+
" SHA-256). Use this to fill the `hash` field of a component/token/icon" +
|
|
231
|
+
" meta.json — never invent a hash yourself.",
|
|
232
|
+
});
|
|
214
233
|
export const DevServerRestartInputSchema = z.object({}).meta({
|
|
215
234
|
title: "DevServerRestartInput",
|
|
216
235
|
description: "Restarts the dev server with current configuration.",
|
|
@@ -1229,7 +1248,7 @@ export const SendMessageToolInputSchema = z
|
|
|
1229
1248
|
description: "When true, send the response as a voice message using text-to-speech. Only supported for Telegram channels. Only set to true when the user's original message was a voice/audio message (look for '[Voice message transcription]' or '[Audio' markers), the channel is Telegram, and the response is short and conversational with no URLs, code, lists, or other content that doesn't translate to audio. Default to false (text) for all text-originated messages.",
|
|
1230
1249
|
}),
|
|
1231
1250
|
from_user_id: z.string().optional().meta({
|
|
1232
|
-
description: "Builder.io user ID this message is from / should be attributed to. Only allowed when channel_id is 'builder/branch/{project_id}/{branch_name}'. When set, the message is delivered to the target branch as coming from this user (role 'user') instead of from the agent.
|
|
1251
|
+
description: "Builder.io user ID this message is from / should be attributed to. Only allowed when channel_id is 'builder/branch/{project_id}/{branch_name}'. When set, the message is delivered to the target branch as coming from this user (role 'user') instead of from the agent. Defaults to the current requester when omitted. Set this explicitly when relaying a message on behalf of someone other than the person who sent the current message — even if it was composed, summarized, or merged from multiple people.",
|
|
1233
1252
|
}),
|
|
1234
1253
|
})
|
|
1235
1254
|
.meta({ title: "SendMessageToolInput" });
|
|
@@ -1587,6 +1606,7 @@ export const CodeGenToolMapSchema = z.object({
|
|
|
1587
1606
|
EnsurePR: EnsurePRToolInputSchema,
|
|
1588
1607
|
EnableDatabase: EnableDatabaseToolInputSchema,
|
|
1589
1608
|
GenerateDesignSystemAgentMd: GenerateDesignSystemAgentMdInputSchema,
|
|
1609
|
+
ComputeDocHash: ComputeDocHashInputSchema,
|
|
1590
1610
|
});
|
|
1591
1611
|
export const CodeGenToolsSchema = CodeGenToolMapSchema.keyof().meta({
|
|
1592
1612
|
title: "CodeGenTools",
|
package/src/design-systems.d.ts
CHANGED
|
@@ -11,64 +11,21 @@ export interface FigmaHydrationResponse {
|
|
|
11
11
|
manifest: import("./events.js").FigmaFrameManifest | null;
|
|
12
12
|
files: FigmaHydrationFile[];
|
|
13
13
|
}
|
|
14
|
-
export type GenerateDesignSystemAttachmentKind = "fig" | "image" | "pdf" | "text";
|
|
15
|
-
export interface GenerateDesignSystemFormFields {
|
|
16
|
-
/**
|
|
17
|
-
* Human-friendly project name. If omitted, the server generates one from
|
|
18
|
-
* the uploaded `.fig` filenames.
|
|
19
|
-
*/
|
|
20
|
-
projectName?: string;
|
|
21
|
-
devToolsVersion?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Optional map of filename → page/frame GUIDs to restrict indexing.
|
|
24
|
-
* GUIDs are file-local, so they must be scoped per attachment.
|
|
25
|
-
*/
|
|
26
|
-
selection?: Record<string, string[]>;
|
|
27
|
-
githubRepoUrl?: string;
|
|
28
|
-
/** Id of a connected Fusion project whose repo is cloned as supplementary context. Takes precedence over `githubRepoUrl`. */
|
|
29
|
-
connectedProjectId?: string;
|
|
30
|
-
}
|
|
31
14
|
/**
|
|
32
15
|
* Accepts `https://github.com/<owner>/<repo>` (optionally with a trailing
|
|
33
|
-
* `.git` or path segments). Used to gate
|
|
34
|
-
* `/design-systems/v1/generate` endpoint.
|
|
16
|
+
* `.git` or path segments). Used to gate public-repo inputs before cloning.
|
|
35
17
|
*/
|
|
36
18
|
export declare const GITHUB_REPO_URL_REGEX: RegExp;
|
|
37
|
-
export interface GenerateDesignSystemRequest extends GenerateDesignSystemFormFields {
|
|
38
|
-
attachments: File[];
|
|
39
|
-
}
|
|
40
|
-
export interface GenerateDesignSystemResponse {
|
|
41
|
-
projectId: string;
|
|
42
|
-
/**
|
|
43
|
-
* Decode job id. Attachments are processed asynchronously in the
|
|
44
|
-
* `ai-queue-subscribers` worker. Clients should listen on the
|
|
45
|
-
* `figmaDecodeJobs/{jobId}` Firestore document for progress and the
|
|
46
|
-
* resolved `branchName` / `branchUrl`.
|
|
47
|
-
*/
|
|
48
|
-
jobId: string;
|
|
49
|
-
designSystemId: string;
|
|
50
|
-
}
|
|
51
|
-
export interface GenerateDesignSystemErrorResponse {
|
|
52
|
-
error: string | Record<string, unknown>;
|
|
53
|
-
}
|
|
54
19
|
export declare const GENERATE_DESIGN_SYSTEM_MAX_FILE_BYTES: number;
|
|
55
20
|
export declare const GENERATE_DESIGN_SYSTEM_MAX_ATTACHMENTS = 50;
|
|
56
21
|
export declare const GENERATE_DESIGN_SYSTEM_MIN_ATTACHMENTS = 0;
|
|
57
|
-
export declare const generateDesignSystemBodySchema: z.ZodObject<{
|
|
58
|
-
projectName: z.ZodOptional<z.ZodString>;
|
|
59
|
-
devToolsVersion: z.ZodOptional<z.ZodString>;
|
|
60
|
-
selection: z.ZodOptional<z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>>;
|
|
61
|
-
githubRepoUrl: z.ZodOptional<z.ZodString>;
|
|
62
|
-
connectedProjectId: z.ZodOptional<z.ZodString>;
|
|
63
|
-
}, z.core.$strip>;
|
|
64
|
-
export type GenerateDesignSystemBody = z.infer<typeof generateDesignSystemBodySchema>;
|
|
65
22
|
/**
|
|
66
23
|
* Signed-URL upload flow.
|
|
67
24
|
*
|
|
68
25
|
* Clients no longer post `.fig` bytes through the service (Cloud Run caps
|
|
69
26
|
* request bodies at 32 MiB). Instead they call `upload/start` to get a
|
|
70
27
|
* temporary signed resumable-upload URL per attachment, stream the bytes
|
|
71
|
-
* directly to GCS, then call `/
|
|
28
|
+
* directly to GCS, then call `/index` with the returned upload tokens.
|
|
72
29
|
* See `tech-specs/signed-url-figma-upload`.
|
|
73
30
|
*/
|
|
74
31
|
/** A single attachment the client declares when starting an upload. */
|
|
@@ -89,7 +46,7 @@ export declare const uploadStartBodySchema: z.ZodObject<{
|
|
|
89
46
|
export type UploadStartBody = z.infer<typeof uploadStartBodySchema>;
|
|
90
47
|
/**
|
|
91
48
|
* Claims encoded inside a signed `uploadToken`. Bound to the GCS object at
|
|
92
|
-
* `upload/start` and verified at `/
|
|
49
|
+
* `upload/start` and verified at `/index`, so a client cannot point the
|
|
93
50
|
* decode worker at an object it did not upload.
|
|
94
51
|
*/
|
|
95
52
|
export declare const uploadTokenPayloadSchema: z.ZodObject<{
|
|
@@ -106,24 +63,167 @@ export interface UploadStartResponseItem {
|
|
|
106
63
|
idx: number;
|
|
107
64
|
/** Signed URL the client POSTs to (with `x-goog-resumable: start`) to begin the resumable upload. */
|
|
108
65
|
uploadUrl: string;
|
|
109
|
-
/** Opaque signed token the client passes back to `/
|
|
66
|
+
/** Opaque signed token the client passes back to `/index`. */
|
|
110
67
|
uploadToken: string;
|
|
111
68
|
}
|
|
112
69
|
export interface UploadStartResponse {
|
|
113
70
|
jobId: string;
|
|
114
71
|
uploads: UploadStartResponseItem[];
|
|
115
72
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
export
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
73
|
+
export declare const indexDesignSystemScopeSchema: z.ZodEnum<{
|
|
74
|
+
global: "global";
|
|
75
|
+
organization: "organization";
|
|
76
|
+
space: "space";
|
|
77
|
+
}>;
|
|
78
|
+
export type IndexDesignSystemScope = z.infer<typeof indexDesignSystemScopeSchema>;
|
|
79
|
+
export declare const fullLibrarySourceKindSchema: z.ZodEnum<{
|
|
80
|
+
"connected-repo": "connected-repo";
|
|
81
|
+
package: "package";
|
|
82
|
+
"public-repo": "public-repo";
|
|
83
|
+
}>;
|
|
84
|
+
export type FullLibrarySourceKind = z.infer<typeof fullLibrarySourceKindSchema>;
|
|
85
|
+
export declare const fullLibrarySourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
86
|
+
kind: z.ZodLiteral<"connected-repo">;
|
|
87
|
+
fusionProjectId: z.ZodString;
|
|
88
|
+
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
89
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
90
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
91
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
92
|
+
kind: z.ZodLiteral<"public-repo">;
|
|
93
|
+
repoUrl: z.ZodString;
|
|
94
|
+
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
95
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
96
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
97
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
98
|
+
kind: z.ZodLiteral<"package">;
|
|
99
|
+
package: z.ZodString;
|
|
100
|
+
registry: z.ZodOptional<z.ZodString>;
|
|
101
|
+
token: z.ZodOptional<z.ZodString>;
|
|
102
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
103
|
+
}, z.core.$strip>], "kind">;
|
|
104
|
+
export type FullLibrarySourceInput = z.infer<typeof fullLibrarySourceSchema>;
|
|
105
|
+
export type ConnectedRepoSourceInput = Extract<FullLibrarySourceInput, {
|
|
106
|
+
kind: "connected-repo";
|
|
107
|
+
}>;
|
|
108
|
+
export type PublicRepoSourceInput = Extract<FullLibrarySourceInput, {
|
|
109
|
+
kind: "public-repo";
|
|
110
|
+
}>;
|
|
111
|
+
export type PackageSourceInput = Extract<FullLibrarySourceInput, {
|
|
112
|
+
kind: "package";
|
|
113
|
+
}>;
|
|
114
|
+
export declare const fileSourceSchema: z.ZodObject<{
|
|
115
|
+
kind: z.ZodLiteral<"file">;
|
|
116
|
+
uploadToken: z.ZodOptional<z.ZodString>;
|
|
117
|
+
uploadGcsPath: z.ZodOptional<z.ZodString>;
|
|
118
|
+
selection: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
119
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
export type FileSourceInput = z.infer<typeof fileSourceSchema>;
|
|
122
|
+
export declare const designSystemSourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
123
|
+
kind: z.ZodLiteral<"connected-repo">;
|
|
124
|
+
fusionProjectId: z.ZodString;
|
|
125
|
+
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
126
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
127
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
128
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
129
|
+
kind: z.ZodLiteral<"public-repo">;
|
|
130
|
+
repoUrl: z.ZodString;
|
|
131
|
+
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
132
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
133
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
134
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
135
|
+
kind: z.ZodLiteral<"package">;
|
|
136
|
+
package: z.ZodString;
|
|
137
|
+
registry: z.ZodOptional<z.ZodString>;
|
|
138
|
+
token: z.ZodOptional<z.ZodString>;
|
|
139
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
140
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
141
|
+
kind: z.ZodLiteral<"file">;
|
|
142
|
+
uploadToken: z.ZodOptional<z.ZodString>;
|
|
143
|
+
uploadGcsPath: z.ZodOptional<z.ZodString>;
|
|
144
|
+
selection: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
145
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
146
|
+
}, z.core.$strip>], "kind">;
|
|
147
|
+
export type DesignSystemSourceInput = z.infer<typeof designSystemSourceSchema>;
|
|
148
|
+
export declare const resolvePackageOptionsSchema: z.ZodObject<{
|
|
149
|
+
package: z.ZodString;
|
|
150
|
+
registry: z.ZodOptional<z.ZodString>;
|
|
151
|
+
token: z.ZodOptional<z.ZodString>;
|
|
152
|
+
specifier: z.ZodOptional<z.ZodString>;
|
|
153
|
+
}, z.core.$strip>;
|
|
154
|
+
export type ResolvePackageOptions = z.infer<typeof resolvePackageOptionsSchema>;
|
|
155
|
+
export interface ResolvePackageResult {
|
|
156
|
+
/** Whether the package resolved successfully from the registry. */
|
|
157
|
+
ok: boolean;
|
|
158
|
+
package: string;
|
|
159
|
+
/** Registry actually queried (defaults to the public npm registry). */
|
|
160
|
+
registry: string;
|
|
161
|
+
/** Specifier requested (defaults to "latest"). */
|
|
162
|
+
specifier: string;
|
|
163
|
+
/** Concrete version the specifier resolved to, when ok. */
|
|
164
|
+
version?: string;
|
|
165
|
+
/** Tarball URL for the resolved version, when ok. */
|
|
166
|
+
tarball?: string;
|
|
167
|
+
/** Human-readable failure reason, when not ok. */
|
|
168
|
+
error?: string;
|
|
169
|
+
}
|
|
170
|
+
export declare const indexDesignSystemBodySchema: z.ZodObject<{
|
|
171
|
+
designSystemName: z.ZodOptional<z.ZodString>;
|
|
172
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
173
|
+
global: "global";
|
|
174
|
+
organization: "organization";
|
|
175
|
+
space: "space";
|
|
176
|
+
}>>;
|
|
177
|
+
sources: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
178
|
+
kind: z.ZodLiteral<"connected-repo">;
|
|
179
|
+
fusionProjectId: z.ZodString;
|
|
180
|
+
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
181
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
182
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
183
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
184
|
+
kind: z.ZodLiteral<"public-repo">;
|
|
185
|
+
repoUrl: z.ZodString;
|
|
186
|
+
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
187
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
188
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
189
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
190
|
+
kind: z.ZodLiteral<"package">;
|
|
191
|
+
package: z.ZodString;
|
|
192
|
+
registry: z.ZodOptional<z.ZodString>;
|
|
193
|
+
token: z.ZodOptional<z.ZodString>;
|
|
194
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
195
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
196
|
+
kind: z.ZodLiteral<"file">;
|
|
197
|
+
uploadToken: z.ZodOptional<z.ZodString>;
|
|
198
|
+
uploadGcsPath: z.ZodOptional<z.ZodString>;
|
|
199
|
+
selection: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
200
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
201
|
+
}, z.core.$strip>], "kind">>;
|
|
202
|
+
}, z.core.$strip>;
|
|
203
|
+
export type IndexDesignSystemBody = z.infer<typeof indexDesignSystemBodySchema>;
|
|
204
|
+
export declare const sourceFileEntrySchema: z.ZodObject<{
|
|
205
|
+
name: z.ZodString;
|
|
206
|
+
path: z.ZodString;
|
|
207
|
+
type: z.ZodEnum<{
|
|
208
|
+
dir: "dir";
|
|
209
|
+
file: "file";
|
|
210
|
+
}>;
|
|
211
|
+
}, z.core.$strip>;
|
|
212
|
+
export type SourceFileEntry = z.infer<typeof sourceFileEntrySchema>;
|
|
213
|
+
export declare const listSourceFilesQuerySchema: z.ZodObject<{
|
|
214
|
+
projectId: z.ZodString;
|
|
215
|
+
path: z.ZodOptional<z.ZodString>;
|
|
216
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
217
|
+
}, z.core.$strip>;
|
|
218
|
+
export type ListSourceFilesQuery = z.infer<typeof listSourceFilesQuerySchema>;
|
|
219
|
+
export interface ListSourceFilesResponse {
|
|
220
|
+
/** The directory that was listed (repo-relative; "" for root). */
|
|
221
|
+
path: string;
|
|
222
|
+
entries: SourceFileEntry[];
|
|
223
|
+
}
|
|
224
|
+
export declare const listPublicSourceFilesQuerySchema: z.ZodObject<{
|
|
225
|
+
repoUrl: z.ZodString;
|
|
226
|
+
path: z.ZodOptional<z.ZodString>;
|
|
227
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
128
228
|
}, z.core.$strip>;
|
|
129
|
-
export type
|
|
229
|
+
export type ListPublicSourceFilesQuery = z.infer<typeof listPublicSourceFilesQuerySchema>;
|
package/src/design-systems.js
CHANGED
|
@@ -1,45 +1,19 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
/**
|
|
3
3
|
* Accepts `https://github.com/<owner>/<repo>` (optionally with a trailing
|
|
4
|
-
* `.git` or path segments). Used to gate
|
|
5
|
-
* `/design-systems/v1/generate` endpoint.
|
|
4
|
+
* `.git` or path segments). Used to gate public-repo inputs before cloning.
|
|
6
5
|
*/
|
|
7
6
|
export const GITHUB_REPO_URL_REGEX = /^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?:\.git)?\/?$/;
|
|
8
7
|
export const GENERATE_DESIGN_SYSTEM_MAX_FILE_BYTES = 2 * 1024 * 1024 * 1024;
|
|
9
8
|
export const GENERATE_DESIGN_SYSTEM_MAX_ATTACHMENTS = 50;
|
|
10
9
|
export const GENERATE_DESIGN_SYSTEM_MIN_ATTACHMENTS = 0;
|
|
11
|
-
export const generateDesignSystemBodySchema = z.object({
|
|
12
|
-
projectName: z.string().trim().min(1).max(200).optional(),
|
|
13
|
-
devToolsVersion: z.string().trim().min(1).max(64).optional(),
|
|
14
|
-
selection: z
|
|
15
|
-
.preprocess((v) => {
|
|
16
|
-
if (typeof v !== "string")
|
|
17
|
-
return v;
|
|
18
|
-
const trimmed = v.trim();
|
|
19
|
-
if (!trimmed)
|
|
20
|
-
return undefined;
|
|
21
|
-
try {
|
|
22
|
-
return JSON.parse(trimmed);
|
|
23
|
-
}
|
|
24
|
-
catch (_a) {
|
|
25
|
-
return v;
|
|
26
|
-
}
|
|
27
|
-
}, z.record(z.string(), z.array(z.string().min(1)).max(10000)))
|
|
28
|
-
.optional(),
|
|
29
|
-
githubRepoUrl: z
|
|
30
|
-
.string()
|
|
31
|
-
.trim()
|
|
32
|
-
.regex(GITHUB_REPO_URL_REGEX, "must be a public github.com repo URL")
|
|
33
|
-
.optional(),
|
|
34
|
-
connectedProjectId: z.string().trim().min(1).max(128).optional(),
|
|
35
|
-
});
|
|
36
10
|
/**
|
|
37
11
|
* Signed-URL upload flow.
|
|
38
12
|
*
|
|
39
13
|
* Clients no longer post `.fig` bytes through the service (Cloud Run caps
|
|
40
14
|
* request bodies at 32 MiB). Instead they call `upload/start` to get a
|
|
41
15
|
* temporary signed resumable-upload URL per attachment, stream the bytes
|
|
42
|
-
* directly to GCS, then call `/
|
|
16
|
+
* directly to GCS, then call `/index` with the returned upload tokens.
|
|
43
17
|
* See `tech-specs/signed-url-figma-upload`.
|
|
44
18
|
*/
|
|
45
19
|
/** A single attachment the client declares when starting an upload. */
|
|
@@ -61,7 +35,7 @@ export const uploadStartBodySchema = z.object({
|
|
|
61
35
|
});
|
|
62
36
|
/**
|
|
63
37
|
* Claims encoded inside a signed `uploadToken`. Bound to the GCS object at
|
|
64
|
-
* `upload/start` and verified at `/
|
|
38
|
+
* `upload/start` and verified at `/index`, so a client cannot point the
|
|
65
39
|
* decode worker at an object it did not upload.
|
|
66
40
|
*/
|
|
67
41
|
export const uploadTokenPayloadSchema = z.object({
|
|
@@ -73,15 +47,93 @@ export const uploadTokenPayloadSchema = z.object({
|
|
|
73
47
|
idx: z.number().int().nonnegative(),
|
|
74
48
|
declaredSize: z.number().int().nonnegative().optional(),
|
|
75
49
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
export const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
50
|
+
export const indexDesignSystemScopeSchema = z.enum([
|
|
51
|
+
"space",
|
|
52
|
+
"organization",
|
|
53
|
+
"global",
|
|
54
|
+
]);
|
|
55
|
+
export const fullLibrarySourceKindSchema = z.enum([
|
|
56
|
+
"connected-repo",
|
|
57
|
+
"public-repo",
|
|
58
|
+
"package",
|
|
59
|
+
]);
|
|
60
|
+
const connectedRepoSourceSchema = z.object({
|
|
61
|
+
kind: z.literal("connected-repo"),
|
|
62
|
+
fusionProjectId: z.string().min(1),
|
|
63
|
+
include: z.array(z.string()).optional(),
|
|
64
|
+
exclude: z.array(z.string()).optional(),
|
|
65
|
+
instructions: z.string().optional(),
|
|
66
|
+
});
|
|
67
|
+
const publicRepoSourceSchema = z.object({
|
|
68
|
+
kind: z.literal("public-repo"),
|
|
69
|
+
repoUrl: z.string().url(),
|
|
70
|
+
include: z.array(z.string()).optional(),
|
|
71
|
+
exclude: z.array(z.string()).optional(),
|
|
72
|
+
instructions: z.string().optional(),
|
|
73
|
+
});
|
|
74
|
+
const packageSourceSchema = z.object({
|
|
75
|
+
kind: z.literal("package"),
|
|
76
|
+
package: z.string().min(1),
|
|
77
|
+
registry: z.string().optional(),
|
|
78
|
+
token: z.string().optional(),
|
|
79
|
+
instructions: z.string().optional(),
|
|
80
|
+
});
|
|
81
|
+
export const fullLibrarySourceSchema = z.discriminatedUnion("kind", [
|
|
82
|
+
connectedRepoSourceSchema,
|
|
83
|
+
publicRepoSourceSchema,
|
|
84
|
+
packageSourceSchema,
|
|
85
|
+
]);
|
|
86
|
+
export const fileSourceSchema = z.object({
|
|
87
|
+
kind: z.literal("file"),
|
|
88
|
+
uploadToken: z.string().min(1).optional(),
|
|
89
|
+
uploadGcsPath: z.string().min(1).optional(),
|
|
90
|
+
/** Optional map of filename → page/frame GUIDs to restrict Figma indexing. */
|
|
91
|
+
selection: z.record(z.string(), z.array(z.string().min(1))).optional(),
|
|
92
|
+
instructions: z.string().optional(),
|
|
93
|
+
});
|
|
94
|
+
export const designSystemSourceSchema = z
|
|
95
|
+
.discriminatedUnion("kind", [
|
|
96
|
+
connectedRepoSourceSchema,
|
|
97
|
+
publicRepoSourceSchema,
|
|
98
|
+
packageSourceSchema,
|
|
99
|
+
fileSourceSchema,
|
|
100
|
+
])
|
|
101
|
+
.refine((s) => s.kind !== "file" || !!s.uploadToken || !!s.uploadGcsPath, {
|
|
102
|
+
message: "File sources require either uploadToken or uploadGcsPath.",
|
|
103
|
+
});
|
|
104
|
+
export const resolvePackageOptionsSchema = z.object({
|
|
105
|
+
/** Package name, optionally with an embedded version ("@ionic/core@7.0.0"). */
|
|
106
|
+
package: z.string().min(1),
|
|
107
|
+
registry: z.string().optional(),
|
|
108
|
+
token: z.string().optional(),
|
|
109
|
+
specifier: z.string().optional(),
|
|
110
|
+
});
|
|
111
|
+
export const indexDesignSystemBodySchema = z.object({
|
|
112
|
+
designSystemName: z.string().optional(),
|
|
113
|
+
scope: indexDesignSystemScopeSchema.optional(),
|
|
114
|
+
sources: z
|
|
115
|
+
.array(designSystemSourceSchema)
|
|
116
|
+
.min(1)
|
|
86
117
|
.max(GENERATE_DESIGN_SYSTEM_MAX_ATTACHMENTS),
|
|
87
118
|
});
|
|
119
|
+
export const sourceFileEntrySchema = z.object({
|
|
120
|
+
name: z.string(),
|
|
121
|
+
/** Repo-relative path (POSIX separators). */
|
|
122
|
+
path: z.string(),
|
|
123
|
+
type: z.enum(["dir", "file"]),
|
|
124
|
+
});
|
|
125
|
+
export const listSourceFilesQuerySchema = z.object({
|
|
126
|
+
projectId: z.string().min(1),
|
|
127
|
+
/** Directory to list, repo-relative. Empty/omitted → repo root. */
|
|
128
|
+
path: z.string().optional(),
|
|
129
|
+
/** Git ref (branch or sha). Omitted → the repo's default branch. */
|
|
130
|
+
ref: z.string().optional(),
|
|
131
|
+
});
|
|
132
|
+
export const listPublicSourceFilesQuerySchema = z.object({
|
|
133
|
+
/** Full repo URL (e.g. https://github.com/owner/repo). GitHub only. */
|
|
134
|
+
repoUrl: z.string().url(),
|
|
135
|
+
/** Directory to list, repo-relative. Empty/omitted → repo root. */
|
|
136
|
+
path: z.string().optional(),
|
|
137
|
+
/** Git ref (branch or sha). Omitted → the repo's default branch. */
|
|
138
|
+
ref: z.string().optional(),
|
|
139
|
+
});
|
package/src/events.d.ts
CHANGED
|
@@ -1071,6 +1071,8 @@ export type FigmaDecodeJobV1 = FusionEventVariant<"figma.decode.job", {
|
|
|
1071
1071
|
* file-local, so they must be scoped per attachment.
|
|
1072
1072
|
*/
|
|
1073
1073
|
selection?: Record<string, string[]>;
|
|
1074
|
+
/** Freeform notes to guide indexing, forwarded to the indexer agent. */
|
|
1075
|
+
instructions?: string;
|
|
1074
1076
|
}, {}, 1>;
|
|
1075
1077
|
export declare const FigmaDecodeJobV1: {
|
|
1076
1078
|
eventName: "figma.decode.job";
|
|
@@ -1157,6 +1159,8 @@ export interface FigmaFrameManifest {
|
|
|
1157
1159
|
githubRepo?: FigmaGithubRepoSource;
|
|
1158
1160
|
/** True if one or more frame chunk uploads failed; some frames may be missing. */
|
|
1159
1161
|
partialFailure?: boolean;
|
|
1162
|
+
/** Freeform notes from the caller to guide indexing. */
|
|
1163
|
+
instructions?: string;
|
|
1160
1164
|
}
|
|
1161
1165
|
export type PrReviewRequestedV1 = FusionEventVariant<"pr.review.requested", {
|
|
1162
1166
|
repoFullName: string;
|
package/src/projects.d.ts
CHANGED
|
@@ -229,6 +229,7 @@ export type GitConfigs = Record<string, GitConfig>;
|
|
|
229
229
|
export declare const EXAMPLE_REPOS: string[];
|
|
230
230
|
export declare const STARTER_REPO = "BuilderIO/fusion-starter";
|
|
231
231
|
export declare const DSI_PREVIEW_REPO = "BuilderIO/dsi-starter";
|
|
232
|
+
export declare const DSI_PLACEHOLDER_REPO = "BuilderIO/dsi-placeholder";
|
|
232
233
|
export declare const AGENT_NATIVE_STARTER_REPO = "BuilderIO/builder-agent-native-starter";
|
|
233
234
|
export declare const EXAMPLE_OR_STARTER_REPOS: string[];
|
|
234
235
|
export declare const EXAMPLE_OR_STARTER_REPOS_URLS: string[];
|
|
@@ -378,7 +379,7 @@ export interface ProjectSkillUrl extends ProjectSkillBase {
|
|
|
378
379
|
}
|
|
379
380
|
export type ProjectSkill = ProjectSkillSource | ProjectSkillNpm | ProjectSkillGithub | ProjectSkillUrl;
|
|
380
381
|
export type FusionExecutionEnvironment = "containerized" | "container-less" | "cloud" | "cloud-v2";
|
|
381
|
-
export type AgentType = "setup-project" | "project-configuration" | "org-agent" | "code-review-orchestrator" | "design-system-indexer" | "builder-publish-integration";
|
|
382
|
+
export type AgentType = "setup-project" | "project-configuration" | "org-agent" | "code-review-orchestrator" | "design-system-indexer" | "repo-indexer" | "builder-publish-integration";
|
|
382
383
|
export interface PartialBranchData {
|
|
383
384
|
name?: string;
|
|
384
385
|
createdBy: string;
|
|
@@ -489,7 +490,7 @@ export interface OrgAgentConfig {
|
|
|
489
490
|
}
|
|
490
491
|
export type BranchType = "code-review" | "setup-project"
|
|
491
492
|
/** Hidden branch the webapp creates when the user picks manual setup. */
|
|
492
|
-
| "manual-setup" | "org-agent" | "snapshot-build" | "design-system-indexing" | "deploy" | "default";
|
|
493
|
+
| "manual-setup" | "org-agent" | "snapshot-build" | "design-system-indexing" | "repo-indexing" | "deploy" | "default";
|
|
493
494
|
/** Category of work a branch represents, auto-assigned during prompt analysis. */
|
|
494
495
|
export type BranchCategory = "feature" | "fix" | "research" | "other";
|
|
495
496
|
export interface BranchSharedData {
|
package/src/projects.js
CHANGED
|
@@ -36,11 +36,13 @@ export const EXAMPLE_REPOS = [
|
|
|
36
36
|
];
|
|
37
37
|
export const STARTER_REPO = "BuilderIO/fusion-starter";
|
|
38
38
|
export const DSI_PREVIEW_REPO = "BuilderIO/dsi-starter";
|
|
39
|
+
export const DSI_PLACEHOLDER_REPO = "BuilderIO/dsi-placeholder";
|
|
39
40
|
export const AGENT_NATIVE_STARTER_REPO = "BuilderIO/builder-agent-native-starter";
|
|
40
41
|
export const EXAMPLE_OR_STARTER_REPOS = [
|
|
41
42
|
...EXAMPLE_REPOS,
|
|
42
43
|
STARTER_REPO,
|
|
43
44
|
DSI_PREVIEW_REPO,
|
|
45
|
+
DSI_PLACEHOLDER_REPO,
|
|
44
46
|
AGENT_NATIVE_STARTER_REPO,
|
|
45
47
|
];
|
|
46
48
|
export const EXAMPLE_OR_STARTER_REPOS_URLS = EXAMPLE_OR_STARTER_REPOS.map((repo) => `https://github.com/${repo}`);
|
package/src/repo-indexing.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { FullLibrarySourceInput } from "./design-systems.js";
|
|
1
2
|
export type StoreComponentDocsInput = StoreComponentDocsInputV1 | StoreComponentDocsInputV2 | IndexDocumentV1;
|
|
3
|
+
export type ComponentDocSource = "full" | "approximation";
|
|
2
4
|
export interface ManualDocumentV1 {
|
|
3
5
|
document: IndexDocumentV1;
|
|
4
6
|
filePath: string;
|
|
@@ -46,6 +48,7 @@ export interface DocumentBase {
|
|
|
46
48
|
designSystemVersion?: string;
|
|
47
49
|
tokens?: number;
|
|
48
50
|
sessionId?: string;
|
|
51
|
+
source?: ComponentDocSource;
|
|
49
52
|
}
|
|
50
53
|
export declare const isAgentDocument: (doc: IndexDocumentV1) => doc is AgentDocument;
|
|
51
54
|
export declare const isIconDocument: (doc: IndexDocumentV1) => doc is IconDocument;
|
|
@@ -117,6 +120,13 @@ export interface UpdateDesignSystemInput {
|
|
|
117
120
|
status?: "in-progress" | "completed" | "failed";
|
|
118
121
|
source?: "auto" | "custom";
|
|
119
122
|
}
|
|
123
|
+
export type LastIndexInput = {
|
|
124
|
+
mode: "full-library";
|
|
125
|
+
sources: FullLibrarySourceInput[];
|
|
126
|
+
} | {
|
|
127
|
+
mode: "designs-only";
|
|
128
|
+
uploadGcsPaths: string[];
|
|
129
|
+
};
|
|
120
130
|
export interface DesignSystem {
|
|
121
131
|
id: string;
|
|
122
132
|
spaceId: string;
|
|
@@ -137,6 +147,8 @@ export interface DesignSystem {
|
|
|
137
147
|
source: "custom" | "auto";
|
|
138
148
|
projectId?: string;
|
|
139
149
|
branchName?: string;
|
|
150
|
+
lastIndexInput?: LastIndexInput;
|
|
151
|
+
lastIndexedAt?: string;
|
|
140
152
|
}
|
|
141
153
|
export interface DisplayDesignSystem extends DesignSystem {
|
|
142
154
|
docCount: number;
|