@builder.io/ai-utils 0.99.0 → 0.100.1
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 +75 -22
- package/src/codegen.js +42 -16
- package/src/events.d.ts +58 -2
- package/src/events.js +20 -0
- package/src/projects.d.ts +1300 -8
- package/src/projects.js +145 -11
- package/src/projects.test.js +76 -1
- package/src/publish-agent.d.ts +13 -0
- package/src/publish-agent.js +20 -0
- package/src/realtime.d.ts +118 -3
- package/src/realtime.js +70 -3
- package/src/realtime.spec.js +53 -5
package/src/realtime.spec.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { BUILDER_REALTIME_MAX_SDP_LENGTH, BuilderRealtimeSessionRequestSchema, OpenAIRealtimeSessionConfigSchema, } from "./realtime.js";
|
|
2
|
+
import { BUILDER_REALTIME_MAX_SDP_LENGTH, BuilderRealtimeSessionRequestSchema, OpenAILiveSessionConfigSchema, OpenAIRealtimeSessionConfigSchema, } from "./realtime.js";
|
|
3
3
|
const validSession = {
|
|
4
4
|
type: "realtime",
|
|
5
5
|
model: "gpt-realtime-2.1",
|
|
@@ -7,6 +7,38 @@ const validSession = {
|
|
|
7
7
|
instructions: "Help the user operate their Builder app.",
|
|
8
8
|
};
|
|
9
9
|
describe("BuilderRealtimeSessionRequestSchema", () => {
|
|
10
|
+
it("accepts a GPT-Live WebRTC session with Responses delegation", () => {
|
|
11
|
+
const result = BuilderRealtimeSessionRequestSchema.parse({
|
|
12
|
+
sdp: "v=0\r\no=- 1 1 IN IP4 127.0.0.1",
|
|
13
|
+
session: {
|
|
14
|
+
model: "gpt-live-1",
|
|
15
|
+
instructions: "Help the user operate their Builder app.",
|
|
16
|
+
audio: { output: { voice: "marin" } },
|
|
17
|
+
delegation: {
|
|
18
|
+
type: "responses",
|
|
19
|
+
responses: {
|
|
20
|
+
model: "gpt-5.6-luna",
|
|
21
|
+
tools: [
|
|
22
|
+
{
|
|
23
|
+
type: "function",
|
|
24
|
+
name: "navigate",
|
|
25
|
+
parameters: { type: "object", properties: {} },
|
|
26
|
+
},
|
|
27
|
+
{ type: "web_search" },
|
|
28
|
+
],
|
|
29
|
+
reasoning: { effort: "minimal" },
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
expect(result.session).toMatchObject({
|
|
35
|
+
model: "gpt-live-1",
|
|
36
|
+
delegation: {
|
|
37
|
+
type: "responses",
|
|
38
|
+
responses: { model: "gpt-5.6-luna" },
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
});
|
|
10
42
|
it("accepts a bounded audio session with tools", () => {
|
|
11
43
|
var _a;
|
|
12
44
|
const result = BuilderRealtimeSessionRequestSchema.parse({
|
|
@@ -39,10 +71,13 @@ describe("BuilderRealtimeSessionRequestSchema", () => {
|
|
|
39
71
|
},
|
|
40
72
|
});
|
|
41
73
|
expect(result.session.model).toBe("gpt-realtime-2.1");
|
|
42
|
-
expect(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
74
|
+
expect("tools" in result.session).toBe(true);
|
|
75
|
+
if ("tools" in result.session) {
|
|
76
|
+
expect((_a = result.session.tools) === null || _a === void 0 ? void 0 : _a[0]).toMatchObject({
|
|
77
|
+
type: "function",
|
|
78
|
+
name: "navigate",
|
|
79
|
+
});
|
|
80
|
+
}
|
|
46
81
|
});
|
|
47
82
|
it("strips unknown request, session, and known nested config keys", () => {
|
|
48
83
|
const sdp = " v=0\r\n";
|
|
@@ -86,6 +121,19 @@ describe("BuilderRealtimeSessionRequestSchema", () => {
|
|
|
86
121
|
},
|
|
87
122
|
}).success).toBe(false);
|
|
88
123
|
});
|
|
124
|
+
it("rejects unsupported GPT-Live delegation types", () => {
|
|
125
|
+
expect(OpenAILiveSessionConfigSchema.safeParse({
|
|
126
|
+
model: "gpt-live-1",
|
|
127
|
+
delegation: { type: "unknown" },
|
|
128
|
+
}).success).toBe(false);
|
|
129
|
+
expect(OpenAILiveSessionConfigSchema.safeParse({
|
|
130
|
+
model: "gpt-live-1",
|
|
131
|
+
delegation: {
|
|
132
|
+
type: "responses",
|
|
133
|
+
responses: { model: "gpt-5.6" },
|
|
134
|
+
},
|
|
135
|
+
}).success).toBe(false);
|
|
136
|
+
});
|
|
89
137
|
it("rejects empty and oversized SDP offers", () => {
|
|
90
138
|
expect(BuilderRealtimeSessionRequestSchema.safeParse({
|
|
91
139
|
sdp: " ",
|