@builder.io/ai-utils 0.103.0 → 0.105.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/codegen.d.ts +37 -1
- package/src/codegen.js +3 -0
- package/src/design-systems.d.ts +10 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/system-one.d.ts +46 -0
- package/src/system-one.js +95 -0
- package/src/system-one.spec.d.ts +1 -0
- package/src/system-one.spec.js +47 -0
package/package.json
CHANGED
package/src/codegen.d.ts
CHANGED
|
@@ -2317,6 +2317,7 @@ export declare const PublishAgentMessageRequestSchema: z.ZodObject<{
|
|
|
2317
2317
|
tag: z.ZodOptional<z.ZodString>;
|
|
2318
2318
|
ephemeral: z.ZodOptional<z.ZodBoolean>;
|
|
2319
2319
|
}, z.core.$strip>]>>>;
|
|
2320
|
+
requireConfirmation: z.ZodOptional<z.ZodBoolean>;
|
|
2320
2321
|
skippedMCPs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2321
2322
|
}, z.core.$strip>;
|
|
2322
2323
|
export type PublishAgentMessageRequest = z.infer<typeof PublishAgentMessageRequestSchema>;
|
|
@@ -4324,6 +4325,12 @@ export interface WorkspaceFolder {
|
|
|
4324
4325
|
templateRepoUrl?: string;
|
|
4325
4326
|
repoName?: string;
|
|
4326
4327
|
resetGit?: boolean;
|
|
4328
|
+
/**
|
|
4329
|
+
* The project's configured base/default branch (e.g. "main", "master"),
|
|
4330
|
+
* distinct from `branchName` (the feature branch this folder checks out).
|
|
4331
|
+
* Used when seeding or checking the base branch on the real remote.
|
|
4332
|
+
*/
|
|
4333
|
+
mainBranchName?: string;
|
|
4327
4334
|
branchName?: string;
|
|
4328
4335
|
backupMetadata?: BackupMetadata;
|
|
4329
4336
|
initializationCommand?: string;
|
|
@@ -4675,7 +4682,7 @@ export interface LoadHistoryResult {
|
|
|
4675
4682
|
updatedUnixTime: number;
|
|
4676
4683
|
turns: CodegenTurn[];
|
|
4677
4684
|
}
|
|
4678
|
-
export type InitStateStep = "initial" | "init" | "validation" | "check-directories" | "create-directories" | "configure-git-repos" | "check-existing-git" | "update-remote-url" | "clone-repo" | "apply-partial-backup" | "configure-git-user" | "stash-changes" | "collect-repo-info" | "init-success" | "init-command" | "init-failed" | "snapshot-git-sync" | "snapshot-backup-restore" | "git-corruption-recovery";
|
|
4685
|
+
export type InitStateStep = "initial" | "init" | "validation" | "check-directories" | "create-directories" | "configure-git-repos" | "check-existing-git" | "update-remote-url" | "clone-repo" | "apply-partial-backup" | "configure-git-user" | "stash-changes" | "collect-repo-info" | "init-success" | "init-command" | "init-failed" | "snapshot-git-sync" | "snapshot-backup-restore" | "git-corruption-recovery" | "seed-base-branch";
|
|
4679
4686
|
export interface InitStatusLog {
|
|
4680
4687
|
id: number;
|
|
4681
4688
|
timestamp: string;
|
|
@@ -5130,6 +5137,35 @@ export type MessageUpdateOptions = {
|
|
|
5130
5137
|
type: "delete";
|
|
5131
5138
|
idempotencyKey: string;
|
|
5132
5139
|
};
|
|
5140
|
+
/**
|
|
5141
|
+
* Args for the `writeFile` launch-server RPC.
|
|
5142
|
+
*
|
|
5143
|
+
* A named-args object because the RPC applies arguments by position and the
|
|
5144
|
+
* container's pinned `dev-tools` rarely matches the caller's, so new fields
|
|
5145
|
+
* have to be additive rather than order-sensitive.
|
|
5146
|
+
*/
|
|
5147
|
+
export interface WriteFileOptions {
|
|
5148
|
+
/** Workspace-relative, e.g. `docs/NOTES.md`. */
|
|
5149
|
+
path: string;
|
|
5150
|
+
contents: string;
|
|
5151
|
+
}
|
|
5152
|
+
/**
|
|
5153
|
+
* Discriminated rather than a nullable path, so a caller that gates behaviour
|
|
5154
|
+
* on the write can tell a refusal from a write that never happened, instead of
|
|
5155
|
+
* reading `null` as both.
|
|
5156
|
+
*
|
|
5157
|
+
* Gate on `success`, not on parsing `error`. Only an ACL denial is reported
|
|
5158
|
+
* distinctly; a blocked `package.json`, a path outside the workspace and a
|
|
5159
|
+
* filesystem error all share one generic message, their reason reaching only
|
|
5160
|
+
* Sentry.
|
|
5161
|
+
*/
|
|
5162
|
+
export type WriteFileResult = {
|
|
5163
|
+
success: true;
|
|
5164
|
+
path: string;
|
|
5165
|
+
} | {
|
|
5166
|
+
success: false;
|
|
5167
|
+
error: string;
|
|
5168
|
+
};
|
|
5133
5169
|
export interface LaunchInitializeSessionOptions {
|
|
5134
5170
|
sessionId?: string;
|
|
5135
5171
|
customInstructions?: CustomInstruction[];
|
package/src/codegen.js
CHANGED
|
@@ -1818,6 +1818,9 @@ export const PublishAgentMessageRequestSchema = z
|
|
|
1818
1818
|
attachments: z.array(AttachmentSchema).optional(),
|
|
1819
1819
|
toolResults: z.array(ContentMessageItemToolResultSchema).optional(),
|
|
1820
1820
|
systemReminders: z.array(SystemReminderSchema).optional(),
|
|
1821
|
+
requireConfirmation: z.boolean().optional().meta({
|
|
1822
|
+
description: "Ask before high-impact MCP tool calls; the turn emits confirmation_required and waits.",
|
|
1823
|
+
}),
|
|
1821
1824
|
skippedMCPs: z.array(z.string()).optional().meta({
|
|
1822
1825
|
description: "Per-message denylist of MCP server ids to skip, e.g. a 'disable for this session' UI toggle.",
|
|
1823
1826
|
}),
|
package/src/design-systems.d.ts
CHANGED
|
@@ -266,3 +266,13 @@ export declare const listPublicSourceFilesQuerySchema: z.ZodObject<{
|
|
|
266
266
|
ref: z.ZodOptional<z.ZodString>;
|
|
267
267
|
}, z.core.$strip>;
|
|
268
268
|
export type ListPublicSourceFilesQuery = z.infer<typeof listPublicSourceFilesQuerySchema>;
|
|
269
|
+
export type DSITier = "free" | "pro" | "team" | "enterprise";
|
|
270
|
+
export interface DSITierLimitResponse {
|
|
271
|
+
tier: DSITier;
|
|
272
|
+
/** Whether this org can index via the web (Figma/.md) flow at its tier. */
|
|
273
|
+
enabled: boolean;
|
|
274
|
+
/** Every active design system the org has, regardless of how it was created. */
|
|
275
|
+
current: number;
|
|
276
|
+
/** `null` is unlimited. */
|
|
277
|
+
max: number | null;
|
|
278
|
+
}
|
package/src/index.d.ts
CHANGED
|
@@ -23,5 +23,6 @@ export * from "./design-systems.js";
|
|
|
23
23
|
export * from "./editor-ai.js";
|
|
24
24
|
export * from "./realtime.js";
|
|
25
25
|
export * from "./embeddings.js";
|
|
26
|
+
export * from "./system-one.js";
|
|
26
27
|
export * from "./mcp-servers.js";
|
|
27
28
|
export { connectivityErrorCodeToLikelyCause, mapConnectivityErrorMessage, } from "./connectivity/error-codes.js";
|
package/src/index.js
CHANGED
|
@@ -23,5 +23,6 @@ export * from "./design-systems.js";
|
|
|
23
23
|
export * from "./editor-ai.js";
|
|
24
24
|
export * from "./realtime.js";
|
|
25
25
|
export * from "./embeddings.js";
|
|
26
|
+
export * from "./system-one.js";
|
|
26
27
|
export * from "./mcp-servers.js";
|
|
27
28
|
export { connectivityErrorCodeToLikelyCause, mapConnectivityErrorMessage, } from "./connectivity/error-codes.js";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const SYSTEM_ONE_DEFAULT_MODEL = "jev-latest";
|
|
3
|
+
export declare const SystemOneRequestSchema: z.ZodObject<{
|
|
4
|
+
state: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodUnknown>]>;
|
|
5
|
+
model: z.ZodDefault<z.ZodString>;
|
|
6
|
+
questions: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
7
|
+
type: z.ZodLiteral<"noul">;
|
|
8
|
+
instructions: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodUnknown>]>;
|
|
9
|
+
criteria: z.ZodOptional<z.ZodObject<{
|
|
10
|
+
true: z.ZodOptional<z.ZodString>;
|
|
11
|
+
false: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>>;
|
|
13
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
14
|
+
type: z.ZodLiteral<"choice">;
|
|
15
|
+
instructions: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodUnknown>]>;
|
|
16
|
+
criteria: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>;
|
|
17
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
18
|
+
type: z.ZodLiteral<"score">;
|
|
19
|
+
instructions: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodUnknown>]>;
|
|
20
|
+
criteria: z.ZodArray<z.ZodString>;
|
|
21
|
+
}, z.core.$loose>], "type">>;
|
|
22
|
+
}, z.core.$loose>;
|
|
23
|
+
export declare const SystemOneResponseSchema: z.ZodObject<{
|
|
24
|
+
model: z.ZodString;
|
|
25
|
+
answers: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
26
|
+
type: z.ZodLiteral<"noul">;
|
|
27
|
+
noul: z.ZodNumber;
|
|
28
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
29
|
+
type: z.ZodLiteral<"choice">;
|
|
30
|
+
choice: z.ZodString;
|
|
31
|
+
probabilities: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
32
|
+
confidence: z.ZodNumber;
|
|
33
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
34
|
+
type: z.ZodLiteral<"score">;
|
|
35
|
+
score: z.ZodNumber;
|
|
36
|
+
legend: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
37
|
+
probabilities: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
38
|
+
confidence: z.ZodNumber;
|
|
39
|
+
}, z.core.$loose>], "type">>;
|
|
40
|
+
usage: z.ZodObject<{
|
|
41
|
+
input_tokens: z.ZodNumber;
|
|
42
|
+
output_tokens: z.ZodNumber;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
}, z.core.$loose>;
|
|
45
|
+
export type SystemOneRequest = z.output<typeof SystemOneRequestSchema>;
|
|
46
|
+
export type SystemOneResponse = z.infer<typeof SystemOneResponseSchema>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const SYSTEM_ONE_DEFAULT_MODEL = "jev-latest";
|
|
3
|
+
const SystemOneValueSchema = z.union([
|
|
4
|
+
z.string(),
|
|
5
|
+
z.record(z.string(), z.unknown()),
|
|
6
|
+
z.array(z.unknown()),
|
|
7
|
+
]);
|
|
8
|
+
const NoulQuestionSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
type: z.literal("noul"),
|
|
11
|
+
instructions: SystemOneValueSchema,
|
|
12
|
+
criteria: z
|
|
13
|
+
.object({
|
|
14
|
+
true: z.string().optional(),
|
|
15
|
+
false: z.string().optional(),
|
|
16
|
+
})
|
|
17
|
+
.optional(),
|
|
18
|
+
})
|
|
19
|
+
.passthrough();
|
|
20
|
+
const ChoiceQuestionSchema = z
|
|
21
|
+
.object({
|
|
22
|
+
type: z.literal("choice"),
|
|
23
|
+
instructions: SystemOneValueSchema,
|
|
24
|
+
criteria: z
|
|
25
|
+
.record(z.string(), z.string().nullable())
|
|
26
|
+
.refine((criteria) => Object.keys(criteria).length > 0, {
|
|
27
|
+
message: "At least one choice is required.",
|
|
28
|
+
}),
|
|
29
|
+
})
|
|
30
|
+
.passthrough();
|
|
31
|
+
const ScoreQuestionSchema = z
|
|
32
|
+
.object({
|
|
33
|
+
type: z.literal("score"),
|
|
34
|
+
instructions: SystemOneValueSchema,
|
|
35
|
+
criteria: z.array(z.string()).min(2),
|
|
36
|
+
})
|
|
37
|
+
.passthrough();
|
|
38
|
+
const SystemOneQuestionSchema = z.discriminatedUnion("type", [
|
|
39
|
+
NoulQuestionSchema,
|
|
40
|
+
ChoiceQuestionSchema,
|
|
41
|
+
ScoreQuestionSchema,
|
|
42
|
+
]);
|
|
43
|
+
export const SystemOneRequestSchema = z
|
|
44
|
+
.object({
|
|
45
|
+
state: SystemOneValueSchema,
|
|
46
|
+
model: z.string().trim().min(1).default(SYSTEM_ONE_DEFAULT_MODEL),
|
|
47
|
+
questions: z
|
|
48
|
+
.record(z.string().min(1), SystemOneQuestionSchema)
|
|
49
|
+
.refine((questions) => Object.keys(questions).length > 0, {
|
|
50
|
+
message: "At least one question is required.",
|
|
51
|
+
}),
|
|
52
|
+
})
|
|
53
|
+
.passthrough()
|
|
54
|
+
.meta({
|
|
55
|
+
description: "Request body for POST /agent-native/jev/v1/system-one.",
|
|
56
|
+
});
|
|
57
|
+
const ProbabilitySchema = z.number().finite().min(0).max(1);
|
|
58
|
+
const NoulAnswerSchema = z
|
|
59
|
+
.object({
|
|
60
|
+
type: z.literal("noul"),
|
|
61
|
+
noul: ProbabilitySchema,
|
|
62
|
+
})
|
|
63
|
+
.passthrough();
|
|
64
|
+
const ChoiceAnswerSchema = z
|
|
65
|
+
.object({
|
|
66
|
+
type: z.literal("choice"),
|
|
67
|
+
choice: z.string(),
|
|
68
|
+
probabilities: z.record(z.string(), ProbabilitySchema),
|
|
69
|
+
confidence: ProbabilitySchema,
|
|
70
|
+
})
|
|
71
|
+
.passthrough();
|
|
72
|
+
const ScoreAnswerSchema = z
|
|
73
|
+
.object({
|
|
74
|
+
type: z.literal("score"),
|
|
75
|
+
score: z.number().finite(),
|
|
76
|
+
legend: z.record(z.string(), z.string()),
|
|
77
|
+
probabilities: z.record(z.string(), ProbabilitySchema),
|
|
78
|
+
confidence: ProbabilitySchema,
|
|
79
|
+
})
|
|
80
|
+
.passthrough();
|
|
81
|
+
const SystemOneAnswerSchema = z.discriminatedUnion("type", [
|
|
82
|
+
NoulAnswerSchema,
|
|
83
|
+
ChoiceAnswerSchema,
|
|
84
|
+
ScoreAnswerSchema,
|
|
85
|
+
]);
|
|
86
|
+
export const SystemOneResponseSchema = z
|
|
87
|
+
.object({
|
|
88
|
+
model: z.string(),
|
|
89
|
+
answers: z.record(z.string(), SystemOneAnswerSchema),
|
|
90
|
+
usage: z.object({
|
|
91
|
+
input_tokens: z.number().int().nonnegative(),
|
|
92
|
+
output_tokens: z.number().int().nonnegative(),
|
|
93
|
+
}),
|
|
94
|
+
})
|
|
95
|
+
.passthrough();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { SYSTEM_ONE_DEFAULT_MODEL, SystemOneRequestSchema, SystemOneResponseSchema, } from "./system-one";
|
|
3
|
+
describe("System One schemas", () => {
|
|
4
|
+
it("defaults the model and validates each question type", () => {
|
|
5
|
+
const request = SystemOneRequestSchema.parse({
|
|
6
|
+
state: { ticket: "export failed" },
|
|
7
|
+
questions: {
|
|
8
|
+
urgent: {
|
|
9
|
+
type: "noul",
|
|
10
|
+
instructions: "Is this urgent?",
|
|
11
|
+
},
|
|
12
|
+
team: {
|
|
13
|
+
type: "choice",
|
|
14
|
+
instructions: "Who owns this?",
|
|
15
|
+
criteria: { support: "Customer issue", engineering: null },
|
|
16
|
+
},
|
|
17
|
+
severity: {
|
|
18
|
+
type: "score",
|
|
19
|
+
instructions: "How severe is this?",
|
|
20
|
+
criteria: ["low", "high"],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
expect(request.model).toBe(SYSTEM_ONE_DEFAULT_MODEL);
|
|
25
|
+
});
|
|
26
|
+
it("rejects a score question without two levels", () => {
|
|
27
|
+
expect(() => SystemOneRequestSchema.parse({
|
|
28
|
+
state: "ticket",
|
|
29
|
+
questions: {
|
|
30
|
+
severity: {
|
|
31
|
+
type: "score",
|
|
32
|
+
instructions: "How severe?",
|
|
33
|
+
criteria: ["low"],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
})).toThrow();
|
|
37
|
+
});
|
|
38
|
+
it("validates the structured response", () => {
|
|
39
|
+
expect(SystemOneResponseSchema.parse({
|
|
40
|
+
model: "jev-1.13.0",
|
|
41
|
+
answers: {
|
|
42
|
+
urgent: { type: "noul", noul: 0.8 },
|
|
43
|
+
},
|
|
44
|
+
usage: { input_tokens: 10, output_tokens: 2 },
|
|
45
|
+
}).usage.input_tokens).toBe(10);
|
|
46
|
+
});
|
|
47
|
+
});
|