@builder.io/ai-utils 0.27.1 → 0.27.4
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 +44 -0
- package/src/claw.js +16 -0
- package/src/codegen.d.ts +62 -6
- package/src/events.d.ts +15 -1
- package/src/events.js +4 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/projects.d.ts +191 -3
- package/src/projects.js +21 -0
package/package.json
CHANGED
package/src/claw.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { NewBranch, Project, MemorySummary } from "./projects";
|
|
2
|
+
export interface OrgTreeUser {
|
|
3
|
+
userId: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
email?: string;
|
|
6
|
+
role?: string;
|
|
7
|
+
jobFunctions?: string;
|
|
8
|
+
githubUsername?: string;
|
|
9
|
+
gitlabUsername?: string;
|
|
10
|
+
bitbucketUsername?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface OrgTreeEnvironmentVariable {
|
|
13
|
+
key: string;
|
|
14
|
+
value: string;
|
|
15
|
+
isSecret: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface OrgTreeResult {
|
|
18
|
+
projects: Project[];
|
|
19
|
+
branches: NewBranch[];
|
|
20
|
+
users: OrgTreeUser[];
|
|
21
|
+
memories: MemorySummary[];
|
|
22
|
+
environmentVariables?: OrgTreeEnvironmentVariable[];
|
|
23
|
+
}
|
|
24
|
+
export interface ClawMessageContext {
|
|
25
|
+
channelId: string;
|
|
26
|
+
sender: {
|
|
27
|
+
userId?: string;
|
|
28
|
+
displayName?: string;
|
|
29
|
+
};
|
|
30
|
+
timestamp: number;
|
|
31
|
+
}
|
|
32
|
+
export interface ParsedChannelId {
|
|
33
|
+
platform: string;
|
|
34
|
+
type: string;
|
|
35
|
+
ids: string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Parses a URI-style channelId into its components.
|
|
39
|
+
*
|
|
40
|
+
* Examples:
|
|
41
|
+
* "slack/thread/T01234/C56789/1234567890.123456" → { platform: "slack", type: "thread", ids: ["T01234", "C56789", "1234567890.123456"] }
|
|
42
|
+
* "jira/comment/cloud-id/PROJ-123" → { platform: "jira", type: "comment", ids: ["cloud-id", "PROJ-123"] }
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseChannelId(channelId: string): ParsedChannelId;
|
package/src/claw.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// ── Org Tree types (shared between service endpoint and CLI) ──
|
|
2
|
+
/**
|
|
3
|
+
* Parses a URI-style channelId into its components.
|
|
4
|
+
*
|
|
5
|
+
* Examples:
|
|
6
|
+
* "slack/thread/T01234/C56789/1234567890.123456" → { platform: "slack", type: "thread", ids: ["T01234", "C56789", "1234567890.123456"] }
|
|
7
|
+
* "jira/comment/cloud-id/PROJ-123" → { platform: "jira", type: "comment", ids: ["cloud-id", "PROJ-123"] }
|
|
8
|
+
*/
|
|
9
|
+
export function parseChannelId(channelId) {
|
|
10
|
+
const parts = channelId.split("/");
|
|
11
|
+
if (parts.length < 2) {
|
|
12
|
+
throw new Error(`Invalid channelId format: ${channelId}`);
|
|
13
|
+
}
|
|
14
|
+
const [platform, type, ...ids] = parts;
|
|
15
|
+
return { platform, type, ids };
|
|
16
|
+
}
|
package/src/codegen.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Options as PrettierOptions } from "prettier";
|
|
|
4
4
|
import type { UserContext } from "./mapping";
|
|
5
5
|
import type { ForcedBackup, SetupDependency, GitDiagnostics } from "./projects";
|
|
6
6
|
import type { Feature } from "./features";
|
|
7
|
-
import type { CpuKind } from "./projects";
|
|
7
|
+
import type { CpuKind, BranchType } from "./projects";
|
|
8
8
|
export type GitSnapshot = unknown;
|
|
9
9
|
export type ImportType = "named" | "default";
|
|
10
10
|
export interface ESMImport {
|
|
@@ -31,6 +31,7 @@ export interface CustomInstruction {
|
|
|
31
31
|
description?: string;
|
|
32
32
|
allowedTools?: string[];
|
|
33
33
|
hideUI?: boolean;
|
|
34
|
+
isSkill?: boolean;
|
|
34
35
|
}
|
|
35
36
|
export interface CustomAgentInfo {
|
|
36
37
|
name: string;
|
|
@@ -42,11 +43,16 @@ export interface CustomAgentDefinition {
|
|
|
42
43
|
systemPrompt?: string;
|
|
43
44
|
tools?: string[];
|
|
44
45
|
model?: string;
|
|
46
|
+
mode?: CodeGenMode;
|
|
45
47
|
position?: string;
|
|
46
48
|
needDevServer?: boolean;
|
|
47
49
|
needValidation?: boolean;
|
|
48
50
|
includeMemories?: boolean;
|
|
49
51
|
resetAfterRun?: boolean;
|
|
52
|
+
mcpServers?: boolean;
|
|
53
|
+
asyncSubAgents?: boolean;
|
|
54
|
+
queueMode?: QueueMode;
|
|
55
|
+
filePath?: string;
|
|
50
56
|
}
|
|
51
57
|
export type CodeGenFramework = "react" | "html" | "mitosis" | "react-native" | "angular" | "vue" | "svelte" | "qwik" | "solid" | "marko" | "swiftui" | "jetpack-compose" | "flutter";
|
|
52
58
|
export type CodeGenStyleLibrary = "tailwind" | "tailwind-precise" | "emotion" | "styled-components" | "styled-jsx" | "react-native" | undefined;
|
|
@@ -180,6 +186,8 @@ export interface RevertToolInput {
|
|
|
180
186
|
}
|
|
181
187
|
export interface TodoReadToolInput {
|
|
182
188
|
}
|
|
189
|
+
export interface RunningAgentsToolInput {
|
|
190
|
+
}
|
|
183
191
|
export interface TodoWriteToolInput {
|
|
184
192
|
mode: "replace" | "patch";
|
|
185
193
|
todos: {
|
|
@@ -200,6 +208,9 @@ export interface GetScreenshotToolInput {
|
|
|
200
208
|
width?: number;
|
|
201
209
|
height?: number;
|
|
202
210
|
}
|
|
211
|
+
export interface NavigatePreviewToolInput {
|
|
212
|
+
href: string;
|
|
213
|
+
}
|
|
203
214
|
export interface WebFetchToolInput {
|
|
204
215
|
url: string;
|
|
205
216
|
prompt?: string;
|
|
@@ -301,11 +312,14 @@ export interface ExitToolInput {
|
|
|
301
312
|
question: string;
|
|
302
313
|
context: string;
|
|
303
314
|
header?: string;
|
|
315
|
+
/** Question type: "select" for single-choice, "multi-select" for multiple choices, "text" for free-form input. Defaults to "select" if options are present, "text" if not. */
|
|
316
|
+
type?: "select" | "multi-select" | "text";
|
|
317
|
+
/** Placeholder text for text-type questions (e.g., "Enter your API key", "https://localhost:3000") */
|
|
318
|
+
placeholder?: string;
|
|
304
319
|
options?: Array<{
|
|
305
320
|
label: string;
|
|
306
321
|
description: string;
|
|
307
322
|
}>;
|
|
308
|
-
multiSelect?: boolean;
|
|
309
323
|
}>;
|
|
310
324
|
isMonorepo?: boolean;
|
|
311
325
|
isMicrofrontend?: boolean;
|
|
@@ -329,11 +343,14 @@ export interface ProposedConfig {
|
|
|
329
343
|
context: string;
|
|
330
344
|
whatYouTried?: string;
|
|
331
345
|
header?: string;
|
|
346
|
+
/** Question type: "select" for single-choice, "multi-select" for multiple choices, "text" for free-form input */
|
|
347
|
+
type?: "select" | "multi-select" | "text";
|
|
348
|
+
/** Placeholder text for text-type questions */
|
|
349
|
+
placeholder?: string;
|
|
332
350
|
options?: Array<{
|
|
333
351
|
label: string;
|
|
334
352
|
description: string;
|
|
335
353
|
}>;
|
|
336
|
-
multiSelect?: boolean;
|
|
337
354
|
}>;
|
|
338
355
|
configuration: {
|
|
339
356
|
setupCommand: {
|
|
@@ -461,6 +478,27 @@ export interface SetEnvVariableToolInput {
|
|
|
461
478
|
placeholder?: boolean;
|
|
462
479
|
explanation?: string;
|
|
463
480
|
}
|
|
481
|
+
export interface SendMessageToolInput {
|
|
482
|
+
channelId: string;
|
|
483
|
+
markdown: string;
|
|
484
|
+
status: "starting" | "question" | "done:success" | "done:error";
|
|
485
|
+
}
|
|
486
|
+
export interface SpawnBranchToolInput {
|
|
487
|
+
projectId: string;
|
|
488
|
+
message: string;
|
|
489
|
+
builderUserId?: string;
|
|
490
|
+
hidden?: boolean;
|
|
491
|
+
}
|
|
492
|
+
export interface SendMessageToBranchToolInput {
|
|
493
|
+
projectId: string;
|
|
494
|
+
branchName: string;
|
|
495
|
+
message: string;
|
|
496
|
+
builderUserId?: string;
|
|
497
|
+
}
|
|
498
|
+
export interface ReadBranchToolInput {
|
|
499
|
+
projectId: string;
|
|
500
|
+
branchName: string;
|
|
501
|
+
}
|
|
464
502
|
/** Comment for PR review - used by both SubmitPRReview and SubmitRecording */
|
|
465
503
|
export interface PRReviewComment {
|
|
466
504
|
file_path: string;
|
|
@@ -521,6 +559,7 @@ export interface CodeGenToolMap {
|
|
|
521
559
|
ReadRule: GetRuleToolInput;
|
|
522
560
|
GetStyleInspiration: GetStyleInspirationToolInput;
|
|
523
561
|
GetScreenshot: GetScreenshotToolInput;
|
|
562
|
+
NavigatePreview: NavigatePreviewToolInput;
|
|
524
563
|
MultiEdit: MultiSearchReplaceInput;
|
|
525
564
|
FindMedia: FindMediaToolInput;
|
|
526
565
|
Media: MediaToolInput;
|
|
@@ -561,11 +600,17 @@ export interface CodeGenToolMap {
|
|
|
561
600
|
VerifyValidateCommand: VerifyValidateCommandToolInput;
|
|
562
601
|
VerifyRuntimeDependency: VerifyRuntimeDependencyToolInput;
|
|
563
602
|
SetEnvVariable: SetEnvVariableToolInput;
|
|
603
|
+
SendMessage: SendMessageToolInput;
|
|
604
|
+
SpawnBranch: SpawnBranchToolInput;
|
|
605
|
+
SendMessageToBranch: SendMessageToBranchToolInput;
|
|
606
|
+
ReadBranch: ReadBranchToolInput;
|
|
607
|
+
RunningAgents: RunningAgentsToolInput;
|
|
564
608
|
}
|
|
565
609
|
export type CodeGenTools = keyof CodeGenToolMap;
|
|
566
610
|
export type AllCodeGenTools = CodeGenTools | "web_search";
|
|
567
611
|
export type SessionMode = "planning" | "normal" | "auto-planning" | "deep-research";
|
|
568
612
|
export type CodeGenMode = "quality" | "quality-v3" | "quality-v4" | "quality-v4-agent";
|
|
613
|
+
export type QueueMode = "next-turn" | "until-idle";
|
|
569
614
|
export type BaseCodeGenPosition = "fusion" | "editor-ai" | "repo-indexing" | "cli" | "create-app-firebase" | "create-app-lovable" | "builder-code-panel" | "dsi-mcp";
|
|
570
615
|
export type CodeGenPosition = BaseCodeGenPosition | `${BaseCodeGenPosition}-agent`;
|
|
571
616
|
export interface RepoIndexingConfig {
|
|
@@ -1017,6 +1062,7 @@ export interface CustomInstructionDefinition {
|
|
|
1017
1062
|
description: string;
|
|
1018
1063
|
type: "agent-mode" | "always";
|
|
1019
1064
|
glob?: string;
|
|
1065
|
+
isSkill?: boolean;
|
|
1020
1066
|
}
|
|
1021
1067
|
export interface GenerateCompletionStepSession {
|
|
1022
1068
|
type: "session";
|
|
@@ -1387,7 +1433,7 @@ export interface CheckBackupDataResultStale {
|
|
|
1387
1433
|
}
|
|
1388
1434
|
export interface CheckBackupDataResultInvalid {
|
|
1389
1435
|
state: "invalid";
|
|
1390
|
-
outcome: "no-backup" | "error" | "not-completed" | "no-session-id" | "no-last-commit-hash" | "no-backup-file" | "empty-full-backup" | "no-vcpCodeGenEvent" | "commits-not-in-repo" | "no-after-commit" | "no-signed-url" | "no-git-branch-name" | "repo-url-mismatch" | "branch-uninitialized" | "unexpected-partial-backup" | "unexpected-full-backup";
|
|
1436
|
+
outcome: "no-backup" | "error" | "not-completed" | "no-session-id" | "no-last-commit-hash" | "no-backup-file" | "empty-full-backup" | "no-vcpCodeGenEvent" | "commits-not-in-repo" | "no-after-commit" | "no-signed-url" | "no-git-branch-name" | "repo-url-mismatch" | "branch-uninitialized" | "unexpected-partial-backup" | "unexpected-full-backup" | "no-backup-keys";
|
|
1391
1437
|
message: string;
|
|
1392
1438
|
backup: BranchBackup | undefined;
|
|
1393
1439
|
}
|
|
@@ -1395,6 +1441,13 @@ export type CheckBackupDataResult = CheckBackupDataResultValid | CheckBackupData
|
|
|
1395
1441
|
export interface BackupMetadata {
|
|
1396
1442
|
check: CheckBackupDataResultValid | CheckBackupDataResultStale | CheckBackupDataResultForcedBackup;
|
|
1397
1443
|
downloadUrl: GitBackupDownloadUrlResult | undefined;
|
|
1444
|
+
downloadUrlError?: string;
|
|
1445
|
+
}
|
|
1446
|
+
export interface AllBackupsCheckResult {
|
|
1447
|
+
/** true only if ALL folders have valid/stale/forced-backup state */
|
|
1448
|
+
allValid: boolean;
|
|
1449
|
+
/** Per-folder check results keyed by backup key ("code", repoHash, etc.) */
|
|
1450
|
+
results: Record<string, CheckBackupDataResult>;
|
|
1398
1451
|
}
|
|
1399
1452
|
export interface WorkspaceFolder {
|
|
1400
1453
|
enableGit?: boolean;
|
|
@@ -1424,8 +1477,10 @@ export interface GitRepoContext {
|
|
|
1424
1477
|
path: string;
|
|
1425
1478
|
/** Feature branch name */
|
|
1426
1479
|
branchName: string;
|
|
1427
|
-
/**
|
|
1480
|
+
/** Authenticated repo URL (may contain ephemeral token) */
|
|
1428
1481
|
repoUrl?: string;
|
|
1482
|
+
/** Clean repo URL without auth tokens, for stable storage and refs */
|
|
1483
|
+
originalRepoUrl?: string;
|
|
1429
1484
|
/** Repo name (e.g., owner/repo) */
|
|
1430
1485
|
repoName?: string;
|
|
1431
1486
|
/**
|
|
@@ -1468,6 +1523,7 @@ export interface AccessResult {
|
|
|
1468
1523
|
message: string;
|
|
1469
1524
|
}
|
|
1470
1525
|
export interface RemoteMachineConfig {
|
|
1526
|
+
environment: "cloud" | "cloud-v2" | "containerized" | "container-less" | "unknown";
|
|
1471
1527
|
cpus: number;
|
|
1472
1528
|
memory: number;
|
|
1473
1529
|
region: string;
|
|
@@ -1557,7 +1613,7 @@ export interface FusionConfig {
|
|
|
1557
1613
|
sessionId?: string;
|
|
1558
1614
|
browserAutomationInstructions?: string;
|
|
1559
1615
|
/** Whether this branch is for a code review - affects enabled agents and tools */
|
|
1560
|
-
branchType?:
|
|
1616
|
+
branchType?: BranchType;
|
|
1561
1617
|
featureBranch?: string;
|
|
1562
1618
|
aiBranch?: string;
|
|
1563
1619
|
/** Whether this is a fork PR - affects git operations (read-only, can't push) */
|
package/src/events.d.ts
CHANGED
|
@@ -519,7 +519,21 @@ export declare const ForceSetupAgentV1: {
|
|
|
519
519
|
eventName: "fusion.setup.force";
|
|
520
520
|
version: "1";
|
|
521
521
|
};
|
|
522
|
-
export type
|
|
522
|
+
export type ClawMessageSentV1 = FusionEventVariant<"claw.message.sent", {
|
|
523
|
+
branchName: string;
|
|
524
|
+
messageType: "text" | "task-result" | "cron-trigger";
|
|
525
|
+
content: string;
|
|
526
|
+
senderType: "user" | "sub-agent" | "system";
|
|
527
|
+
senderId?: string;
|
|
528
|
+
correlationId?: string;
|
|
529
|
+
channelId?: string;
|
|
530
|
+
senderDisplayName?: string;
|
|
531
|
+
}, {}, 1>;
|
|
532
|
+
export declare const ClawMessageSentV1: {
|
|
533
|
+
eventName: "claw.message.sent";
|
|
534
|
+
version: "1";
|
|
535
|
+
};
|
|
536
|
+
export type FusionEvent = AiTaskCompletedEvent | AiTaskFailedEvent | GitPrCreatedEvent | ClientDevtoolsSessionStartedEvent | FusionProjectCreatedV1 | SetupAgentCompletedV1 | ForceSetupAgentV1 | ClawMessageSentV1;
|
|
523
537
|
export interface ModelPermissionRequiredEvent {
|
|
524
538
|
type: "assistant.model.permission.required";
|
|
525
539
|
data: {
|
package/src/events.js
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ export * from "./repo-indexing.js";
|
|
|
9
9
|
export * from "./organization.js";
|
|
10
10
|
export * from "./features.js";
|
|
11
11
|
export * from "./vscode-tunnel.js";
|
|
12
|
+
export * from "./claw.js";
|
|
12
13
|
export * from "./connectivity/types.js";
|
|
13
14
|
export { connectivityErrorCodeToLikelyCause, mapConnectivityErrorMessage, } from "./connectivity/error-codes.js";
|
package/src/index.js
CHANGED
|
@@ -9,5 +9,6 @@ export * from "./repo-indexing.js";
|
|
|
9
9
|
export * from "./organization.js";
|
|
10
10
|
export * from "./features.js";
|
|
11
11
|
export * from "./vscode-tunnel.js";
|
|
12
|
+
export * from "./claw.js";
|
|
12
13
|
export * from "./connectivity/types.js";
|
|
13
14
|
export { connectivityErrorCodeToLikelyCause, mapConnectivityErrorMessage, } from "./connectivity/error-codes.js";
|
package/src/projects.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConnectivityErrorCode, CheckType, LikelyCause } from "./connectivity/types.js";
|
|
2
|
-
import type { FileOverride, EnvironmentVariable, LaunchServerState, LaunchServerStatus, BranchBackup, CommitMode, CustomInstruction, CustomAgentDefinition, GitSnapshot, AutoPushMode } from "./codegen";
|
|
2
|
+
import type { FileOverride, EnvironmentVariable, LaunchServerState, LaunchServerStatus, BranchBackup, CommitMode, CustomInstruction, CustomAgentDefinition, GitSnapshot, AutoPushMode, GenerateUserMessage, CodeGenToolMap, GenerateCompletionStep } from "./codegen";
|
|
3
3
|
import type { FallbackTokensPrivate } from "./organization";
|
|
4
4
|
/**
|
|
5
5
|
* Temporary type for date fields during migration.
|
|
@@ -275,6 +275,8 @@ export interface RecordScreenshotOptions {
|
|
|
275
275
|
}
|
|
276
276
|
export type GitBackupRecordBody = GitBackupRecordOptions | {
|
|
277
277
|
backups: GitBackupRecordOptions[];
|
|
278
|
+
elapsedTime: number;
|
|
279
|
+
error?: string;
|
|
278
280
|
};
|
|
279
281
|
export interface GitBackupRecordResult {
|
|
280
282
|
success: boolean;
|
|
@@ -300,6 +302,7 @@ export interface BackupGitRepoResultValid {
|
|
|
300
302
|
empty: boolean;
|
|
301
303
|
lastCommitHash: string;
|
|
302
304
|
backupRef: string | undefined;
|
|
305
|
+
backupEntry: GitBackupRecordOptions;
|
|
303
306
|
}
|
|
304
307
|
export interface BackupGitRepoResultInvalid {
|
|
305
308
|
success: false;
|
|
@@ -335,7 +338,7 @@ export interface SetupScriptDependency {
|
|
|
335
338
|
script: string;
|
|
336
339
|
}
|
|
337
340
|
export type FusionExecutionEnvironment = "containerized" | "container-less" | "cloud" | "cloud-v2";
|
|
338
|
-
export type AgentType = "setup-project" | "project-configuration";
|
|
341
|
+
export type AgentType = "setup-project" | "project-configuration" | "org-agent";
|
|
339
342
|
export interface PartialBranchData {
|
|
340
343
|
name?: string;
|
|
341
344
|
createdBy: string;
|
|
@@ -395,6 +398,8 @@ export interface BranchMetadata {
|
|
|
395
398
|
slackThreadTs?: string;
|
|
396
399
|
/** User-provided description of what reviewers should focus on */
|
|
397
400
|
description?: string;
|
|
401
|
+
/** Whether the branch is a cloned branch */
|
|
402
|
+
isClonedBranch?: boolean;
|
|
398
403
|
[key: string]: unknown;
|
|
399
404
|
}
|
|
400
405
|
export type PRStatus = "open" | "closed" | "merged" | "draft" | "approved";
|
|
@@ -405,7 +410,13 @@ export interface BranchReview {
|
|
|
405
410
|
createdAt: number;
|
|
406
411
|
updatedAt: number;
|
|
407
412
|
}
|
|
408
|
-
export
|
|
413
|
+
export interface OrgAgentConfig {
|
|
414
|
+
maxSubAgents: number;
|
|
415
|
+
syncIntervalMinutes: number;
|
|
416
|
+
enabledTools: string[];
|
|
417
|
+
longLived: boolean;
|
|
418
|
+
}
|
|
419
|
+
export type BranchType = "code-review" | "setup-project" | "org-agent" | "default";
|
|
409
420
|
export interface BranchSharedData {
|
|
410
421
|
appName?: string | null;
|
|
411
422
|
prNumber?: number | null;
|
|
@@ -542,6 +553,7 @@ export interface Project {
|
|
|
542
553
|
repoFullName: string | undefined;
|
|
543
554
|
repoProvider: string;
|
|
544
555
|
repoProtocol: string | undefined;
|
|
556
|
+
description?: string;
|
|
545
557
|
repoDescription?: string;
|
|
546
558
|
repoPrivate: boolean;
|
|
547
559
|
repoUrl: string | undefined;
|
|
@@ -672,6 +684,12 @@ export interface Project {
|
|
|
672
684
|
useBranchesCollection?: boolean;
|
|
673
685
|
/** When true, the project is in code-only mode */
|
|
674
686
|
codeOnlyMode?: boolean;
|
|
687
|
+
/** When true, this project is an org-level Claw agent */
|
|
688
|
+
isOrgAgent?: boolean;
|
|
689
|
+
/** Configuration for the org agent */
|
|
690
|
+
orgAgentConfig?: OrgAgentConfig;
|
|
691
|
+
/** When true, the project is hidden from normal project listings */
|
|
692
|
+
hidden?: boolean;
|
|
675
693
|
}
|
|
676
694
|
/**
|
|
677
695
|
* Get the state of a branch, checking `state` first and falling back to `deleted` for backwards compatibility.
|
|
@@ -735,4 +753,174 @@ export interface BuilderMyContext {
|
|
|
735
753
|
};
|
|
736
754
|
error?: string;
|
|
737
755
|
}
|
|
756
|
+
export interface WebhookConfig {
|
|
757
|
+
url: string;
|
|
758
|
+
secret?: string;
|
|
759
|
+
timeout?: number;
|
|
760
|
+
}
|
|
761
|
+
export interface CreateBranchOptions {
|
|
762
|
+
projectId: string;
|
|
763
|
+
userMessage: GenerateUserMessage;
|
|
764
|
+
devToolsVersion?: string;
|
|
765
|
+
webhook?: WebhookConfig;
|
|
766
|
+
branchFriendlyName?: string;
|
|
767
|
+
agentType?: AgentType;
|
|
768
|
+
actor: string;
|
|
769
|
+
hidden?: boolean;
|
|
770
|
+
featureFlags?: Record<string, boolean>;
|
|
771
|
+
checkoutBranch?: string | null;
|
|
772
|
+
canHandleTools?: (keyof CodeGenToolMap)[];
|
|
773
|
+
useKube?: boolean;
|
|
774
|
+
fireAndForget?: boolean;
|
|
775
|
+
/** PR number for QA bot branches */
|
|
776
|
+
prNumber?: number;
|
|
777
|
+
/** Whether this branch is for a fork PR - affects git operations */
|
|
778
|
+
isFork?: boolean;
|
|
779
|
+
type?: BranchType;
|
|
780
|
+
/** Optional suffix to append to generated branch names (e.g., model short name for parallel branches) */
|
|
781
|
+
branchNameSuffix?: string;
|
|
782
|
+
}
|
|
783
|
+
interface BaseCreateBranchMessage {
|
|
784
|
+
}
|
|
785
|
+
export interface ValidatingProjectMessage extends BaseCreateBranchMessage {
|
|
786
|
+
type: "validating-project";
|
|
787
|
+
message: string;
|
|
788
|
+
projectId: string;
|
|
789
|
+
projectName?: string;
|
|
790
|
+
branchName: string;
|
|
791
|
+
}
|
|
792
|
+
export interface CreatingBranchMessage extends BaseCreateBranchMessage {
|
|
793
|
+
type: "creating-branch";
|
|
794
|
+
message: string;
|
|
795
|
+
projectId: string;
|
|
796
|
+
projectName: string;
|
|
797
|
+
branchName: string;
|
|
798
|
+
branchFriendlyName: string | undefined;
|
|
799
|
+
}
|
|
800
|
+
export interface SettingUpContainerMessage extends BaseCreateBranchMessage {
|
|
801
|
+
type: "setting-up-container";
|
|
802
|
+
message: string;
|
|
803
|
+
projectId: string;
|
|
804
|
+
projectName: string;
|
|
805
|
+
branchName: string;
|
|
806
|
+
branchFriendlyName: string | undefined;
|
|
807
|
+
}
|
|
808
|
+
export interface ContainerReadyMessage extends BaseCreateBranchMessage {
|
|
809
|
+
type: "container-ready";
|
|
810
|
+
message: string;
|
|
811
|
+
projectId: string;
|
|
812
|
+
projectName: string;
|
|
813
|
+
branchName: string;
|
|
814
|
+
url: string;
|
|
815
|
+
}
|
|
816
|
+
export interface SendingInitialMessageMessage extends BaseCreateBranchMessage {
|
|
817
|
+
type: "sending-initial-message";
|
|
818
|
+
message: string;
|
|
819
|
+
projectId: string;
|
|
820
|
+
projectName: string;
|
|
821
|
+
branchName: string;
|
|
822
|
+
}
|
|
823
|
+
export interface BranchCreatedMessage extends BaseCreateBranchMessage {
|
|
824
|
+
type: "branch-created";
|
|
825
|
+
message: string;
|
|
826
|
+
projectId: string;
|
|
827
|
+
projectName: string;
|
|
828
|
+
branchName: string;
|
|
829
|
+
url: string;
|
|
830
|
+
}
|
|
831
|
+
export interface CreateBranchErrorMessage extends BaseCreateBranchMessage {
|
|
832
|
+
type: "error";
|
|
833
|
+
message: string;
|
|
834
|
+
error: string;
|
|
835
|
+
projectId: string;
|
|
836
|
+
projectName?: string;
|
|
837
|
+
branchName?: string;
|
|
838
|
+
}
|
|
839
|
+
export interface EnsureContainerMessage extends BaseCreateBranchMessage {
|
|
840
|
+
type: "ensure-container";
|
|
841
|
+
event: ProjectsChunkMessage;
|
|
842
|
+
}
|
|
843
|
+
export interface AiMessage extends BaseCreateBranchMessage {
|
|
844
|
+
type: "ai";
|
|
845
|
+
event: GenerateCompletionStep;
|
|
846
|
+
}
|
|
847
|
+
export type CreateBranchChunkMessage = ValidatingProjectMessage | CreatingBranchMessage | SettingUpContainerMessage | SendingInitialMessageMessage | BranchCreatedMessage | CreateBranchErrorMessage | EnsureContainerMessage | ContainerReadyMessage | AiMessage;
|
|
848
|
+
export interface CreateBranchResponse {
|
|
849
|
+
success: boolean;
|
|
850
|
+
branchName?: string;
|
|
851
|
+
projectId: string;
|
|
852
|
+
projectName?: string;
|
|
853
|
+
url?: string;
|
|
854
|
+
error?: string;
|
|
855
|
+
messageResponse?: string;
|
|
856
|
+
sentryId?: string;
|
|
857
|
+
branchId?: string;
|
|
858
|
+
sessionId?: string;
|
|
859
|
+
}
|
|
860
|
+
export interface SendMessageOptions {
|
|
861
|
+
projectId: string;
|
|
862
|
+
branchName: string;
|
|
863
|
+
userMessage: GenerateUserMessage;
|
|
864
|
+
devToolsVersion?: string;
|
|
865
|
+
featureFlags?: Record<string, boolean>;
|
|
866
|
+
webhook?: WebhookConfig;
|
|
867
|
+
fireAndForget?: boolean;
|
|
868
|
+
canHandleTools?: (keyof CodeGenToolMap)[];
|
|
869
|
+
}
|
|
870
|
+
export interface MemoryData {
|
|
871
|
+
completionId: string;
|
|
872
|
+
sessionId: string;
|
|
873
|
+
id: string;
|
|
874
|
+
scope: "global" | "user" | "project";
|
|
875
|
+
memory: string;
|
|
876
|
+
when: string;
|
|
877
|
+
commit: string | null;
|
|
878
|
+
category: string;
|
|
879
|
+
/** Glob pattern for file-based memory retrieval. Should be specific (e.g., "src/components/Button.tsx") rather than broad (e.g., "*.tsx"). */
|
|
880
|
+
glob: string | null;
|
|
881
|
+
importance?: number;
|
|
882
|
+
glob_auto_include?: boolean;
|
|
883
|
+
ownerId: string;
|
|
884
|
+
projectId: string | null;
|
|
885
|
+
branchName: string | null;
|
|
886
|
+
repoHash: string | null;
|
|
887
|
+
userId: string | null;
|
|
888
|
+
createdAt: number;
|
|
889
|
+
updatedAt: number;
|
|
890
|
+
modelOverride: string | null;
|
|
891
|
+
approved: boolean;
|
|
892
|
+
needsConsolidation: boolean;
|
|
893
|
+
embedding: any | null;
|
|
894
|
+
embeddingModel: string | null;
|
|
895
|
+
position: string;
|
|
896
|
+
/** Number of memories merged into this one (default: 1). Acts as importance signal (myelin analogy). */
|
|
897
|
+
mergeCount: number;
|
|
898
|
+
/** Array of memory IDs that were archived to create this consolidated memory. Used for audit trail and rollback. */
|
|
899
|
+
mergedMemoryIds: string[];
|
|
900
|
+
/** Memory ID that archived this memory. Set when this memory gets consolidated into a new one. */
|
|
901
|
+
archivedBy: string | undefined;
|
|
902
|
+
archived: boolean;
|
|
903
|
+
/** Schema version for consolidation process (for future algorithm changes). */
|
|
904
|
+
consolidationVersion: number | undefined;
|
|
905
|
+
/** Timestamp of last consolidation processing */
|
|
906
|
+
lastConsolidatedAt: number | undefined;
|
|
907
|
+
reads: number;
|
|
908
|
+
/** Times memory led to positive outcome (default: 0) */
|
|
909
|
+
successCount: number;
|
|
910
|
+
/** Times memory was misleading (default: 0) */
|
|
911
|
+
failureCount: number;
|
|
912
|
+
/** Times memory was partially helpful (default: 0) */
|
|
913
|
+
partialCount: number;
|
|
914
|
+
/** Total times memory was scored (successCount + failureCount + partialCount) */
|
|
915
|
+
totalUses: number;
|
|
916
|
+
/** Timestamp of last scoring */
|
|
917
|
+
lastScoredAt: number | undefined;
|
|
918
|
+
}
|
|
919
|
+
export declare const MEMORY_PICKED_FIELDS: readonly ["id", "updatedAt", "category", "successCount", "partialCount", "failureCount", "totalUses", "when", "glob", "memory"];
|
|
920
|
+
export declare const MEMORY_SUMMARY_FIELDS: readonly ["id", "category", "projectId", "memory", "when", "glob", "updatedAt"];
|
|
921
|
+
export interface MemorySummary extends Pick<MemoryData, (typeof MEMORY_SUMMARY_FIELDS)[number]> {
|
|
922
|
+
}
|
|
923
|
+
export interface GetProjectMemoriesResult {
|
|
924
|
+
memories: MemorySummary[];
|
|
925
|
+
}
|
|
738
926
|
export {};
|
package/src/projects.js
CHANGED
|
@@ -71,3 +71,24 @@ export const isBranchArchived = (branch) => {
|
|
|
71
71
|
export const isProjectDeleted = (project) => {
|
|
72
72
|
return getProjectState(project) === "deleted";
|
|
73
73
|
};
|
|
74
|
+
export const MEMORY_PICKED_FIELDS = [
|
|
75
|
+
"id",
|
|
76
|
+
"updatedAt",
|
|
77
|
+
"category",
|
|
78
|
+
"successCount",
|
|
79
|
+
"partialCount",
|
|
80
|
+
"failureCount",
|
|
81
|
+
"totalUses",
|
|
82
|
+
"when",
|
|
83
|
+
"glob",
|
|
84
|
+
"memory",
|
|
85
|
+
];
|
|
86
|
+
export const MEMORY_SUMMARY_FIELDS = [
|
|
87
|
+
"id",
|
|
88
|
+
"category",
|
|
89
|
+
"projectId",
|
|
90
|
+
"memory",
|
|
91
|
+
"when",
|
|
92
|
+
"glob",
|
|
93
|
+
"updatedAt",
|
|
94
|
+
];
|