@onkernel/cua-ai 0.0.1 → 0.2.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/CHANGELOG.md +96 -0
- package/README.md +341 -65
- package/dist/chunk-D7D4PA-g.js +13 -0
- package/dist/index.d.ts +576 -10
- package/dist/index.js +1992 -11
- package/docs/supported-models.md +76 -0
- package/examples/quickstart.ts +28 -22
- package/package.json +10 -6
- package/dist/api-keys.d.ts +0 -8
- package/dist/api-keys.d.ts.map +0 -1
- package/dist/api-keys.js +0 -48
- package/dist/api-keys.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/models.d.ts +0 -33
- package/dist/models.d.ts.map +0 -1
- package/dist/models.js +0 -159
- package/dist/models.js.map +0 -1
- package/dist/providers/anthropic/index.d.ts +0 -10
- package/dist/providers/anthropic/index.d.ts.map +0 -1
- package/dist/providers/anthropic/index.js +0 -16
- package/dist/providers/anthropic/index.js.map +0 -1
- package/dist/providers/common.d.ts +0 -111
- package/dist/providers/common.d.ts.map +0 -1
- package/dist/providers/common.js +0 -138
- package/dist/providers/common.js.map +0 -1
- package/dist/providers/gemini/index.d.ts +0 -11
- package/dist/providers/gemini/index.d.ts.map +0 -1
- package/dist/providers/gemini/index.js +0 -14
- package/dist/providers/gemini/index.js.map +0 -1
- package/dist/providers/openai/index.d.ts +0 -8
- package/dist/providers/openai/index.d.ts.map +0 -1
- package/dist/providers/openai/index.js +0 -22
- package/dist/providers/openai/index.js.map +0 -1
- package/dist/providers/tzafon/index.d.ts +0 -12
- package/dist/providers/tzafon/index.d.ts.map +0 -1
- package/dist/providers/tzafon/index.js +0 -18
- package/dist/providers/tzafon/index.js.map +0 -1
- package/dist/providers/tzafon/provider.d.ts +0 -8
- package/dist/providers/tzafon/provider.d.ts.map +0 -1
- package/dist/providers/tzafon/provider.js +0 -234
- package/dist/providers/tzafon/provider.js.map +0 -1
- package/dist/providers/yutori/index.d.ts +0 -12
- package/dist/providers/yutori/index.d.ts.map +0 -1
- package/dist/providers/yutori/index.js +0 -23
- package/dist/providers/yutori/index.js.map +0 -1
- package/dist/providers/yutori/provider.d.ts +0 -9
- package/dist/providers/yutori/provider.d.ts.map +0 -1
- package/dist/providers/yutori/provider.js +0 -307
- package/dist/providers/yutori/provider.js.map +0 -1
- package/dist/providers.d.ts +0 -6
- package/dist/providers.d.ts.map +0 -1
- package/dist/providers.js +0 -26
- package/dist/providers.js.map +0 -1
- package/dist/runtime-spec.d.ts +0 -29
- package/dist/runtime-spec.d.ts.map +0 -1
- package/dist/runtime-spec.js +0 -58
- package/dist/runtime-spec.js.map +0 -1
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
import OpenAI from "openai";
|
|
2
|
-
import { createAssistantMessageEventStream, } from "@earendil-works/pi-ai";
|
|
3
|
-
import { CUA_ACTION_TYPES, CUA_BATCH_TOOL_NAME } from "../common.js";
|
|
4
|
-
export const YUTORI_CHAT_COMPLETIONS_API = "yutori-chat-completions";
|
|
5
|
-
const YUTORI_BUILTIN_TOOL_NAMES = new Set(CUA_ACTION_TYPES);
|
|
6
|
-
export const streamYutori = (model, context, options) => {
|
|
7
|
-
const stream = createAssistantMessageEventStream();
|
|
8
|
-
void runYutoriStream(stream, model, context, options);
|
|
9
|
-
return stream;
|
|
10
|
-
};
|
|
11
|
-
export const streamSimpleYutori = (model, context, options) => streamYutori(model, context, options);
|
|
12
|
-
export function yutoriBuiltinToolsOnPayload(payload) {
|
|
13
|
-
if (!payload || typeof payload !== "object")
|
|
14
|
-
return undefined;
|
|
15
|
-
const current = payload;
|
|
16
|
-
if (!Array.isArray(current.tools))
|
|
17
|
-
return undefined;
|
|
18
|
-
const tools = current.tools.filter((tool) => {
|
|
19
|
-
const name = readToolName(tool);
|
|
20
|
-
return !name || !YUTORI_BUILTIN_TOOL_NAMES.has(name);
|
|
21
|
-
});
|
|
22
|
-
return {
|
|
23
|
-
...payload,
|
|
24
|
-
...(tools.length > 0 ? { tools } : { tools: undefined }),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
async function runYutoriStream(stream, model, context, options) {
|
|
28
|
-
const output = initialAssistantMessage(model);
|
|
29
|
-
try {
|
|
30
|
-
const apiKey = options?.apiKey || process.env.YUTORI_API_KEY;
|
|
31
|
-
if (!apiKey)
|
|
32
|
-
throw new Error("missing Yutori API key");
|
|
33
|
-
const client = new OpenAI({
|
|
34
|
-
apiKey,
|
|
35
|
-
baseURL: model.baseUrl || "https://api.yutori.com/v1",
|
|
36
|
-
defaultHeaders: model.headers,
|
|
37
|
-
});
|
|
38
|
-
let payload = {
|
|
39
|
-
model: model.id,
|
|
40
|
-
messages: convertMessages(context),
|
|
41
|
-
max_completion_tokens: options?.maxTokens ?? model.maxTokens,
|
|
42
|
-
temperature: options?.temperature ?? 0.3,
|
|
43
|
-
};
|
|
44
|
-
const tools = convertTools(context);
|
|
45
|
-
if (tools.length > 0)
|
|
46
|
-
payload.tools = tools;
|
|
47
|
-
const nextPayload = await options?.onPayload?.(payload, model);
|
|
48
|
-
if (nextPayload !== undefined)
|
|
49
|
-
payload = nextPayload;
|
|
50
|
-
const { data: response, response: rawResponse } = await client.chat.completions
|
|
51
|
-
.create(payload, { signal: options?.signal })
|
|
52
|
-
.withResponse();
|
|
53
|
-
const completion = response;
|
|
54
|
-
await options?.onResponse?.({ status: rawResponse.status, headers: headersToRecord(rawResponse.headers) }, model);
|
|
55
|
-
stream.push({ type: "start", partial: output });
|
|
56
|
-
const choice = completion.choices?.[0];
|
|
57
|
-
const message = choice?.message;
|
|
58
|
-
output.responseId = completion.id;
|
|
59
|
-
output.usage = usageFromYutori(completion.usage);
|
|
60
|
-
if (choice?.finish_reason === "tool_calls")
|
|
61
|
-
output.stopReason = "toolUse";
|
|
62
|
-
else if (choice?.finish_reason === "length")
|
|
63
|
-
output.stopReason = "length";
|
|
64
|
-
const text = typeof message?.content === "string" ? message.content : "";
|
|
65
|
-
if (text)
|
|
66
|
-
emitText(stream, output, text);
|
|
67
|
-
const wantsBatch = (context.tools ?? []).some((tool) => tool.name === CUA_BATCH_TOOL_NAME);
|
|
68
|
-
const batchActions = [];
|
|
69
|
-
let firstBatchCallId;
|
|
70
|
-
for (const call of message?.tool_calls ?? []) {
|
|
71
|
-
if (call.type !== "function")
|
|
72
|
-
continue;
|
|
73
|
-
const args = parseArguments(call.function.arguments);
|
|
74
|
-
const canonical = wantsBatch ? toCanonicalAction(call.function.name, args) : undefined;
|
|
75
|
-
if (canonical) {
|
|
76
|
-
batchActions.push(...canonical);
|
|
77
|
-
firstBatchCallId ??= call.id;
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
const contentIndex = output.content.length;
|
|
81
|
-
const toolCall = {
|
|
82
|
-
type: "toolCall",
|
|
83
|
-
id: call.id,
|
|
84
|
-
name: call.function.name,
|
|
85
|
-
arguments: args,
|
|
86
|
-
};
|
|
87
|
-
output.content.push(toolCall);
|
|
88
|
-
stream.push({ type: "toolcall_start", contentIndex, partial: output });
|
|
89
|
-
stream.push({ type: "toolcall_delta", contentIndex, delta: call.function.arguments ?? "", partial: output });
|
|
90
|
-
stream.push({ type: "toolcall_end", contentIndex, toolCall, partial: output });
|
|
91
|
-
}
|
|
92
|
-
if (batchActions.length > 0) {
|
|
93
|
-
const contentIndex = output.content.length;
|
|
94
|
-
const toolCall = {
|
|
95
|
-
type: "toolCall",
|
|
96
|
-
id: firstBatchCallId ?? `yutori_batch_${Date.now()}`,
|
|
97
|
-
name: CUA_BATCH_TOOL_NAME,
|
|
98
|
-
arguments: { actions: batchActions },
|
|
99
|
-
};
|
|
100
|
-
output.content.push(toolCall);
|
|
101
|
-
output.stopReason = "toolUse";
|
|
102
|
-
stream.push({ type: "toolcall_start", contentIndex, partial: output });
|
|
103
|
-
stream.push({ type: "toolcall_delta", contentIndex, delta: JSON.stringify(toolCall.arguments), partial: output });
|
|
104
|
-
stream.push({ type: "toolcall_end", contentIndex, toolCall, partial: output });
|
|
105
|
-
}
|
|
106
|
-
stream.push({ type: "done", reason: output.stopReason, message: output });
|
|
107
|
-
stream.end();
|
|
108
|
-
}
|
|
109
|
-
catch (err) {
|
|
110
|
-
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
111
|
-
output.errorMessage = err instanceof Error ? err.message : String(err);
|
|
112
|
-
stream.push({ type: "error", reason: output.stopReason, error: output });
|
|
113
|
-
stream.end();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function initialAssistantMessage(model) {
|
|
117
|
-
return {
|
|
118
|
-
role: "assistant",
|
|
119
|
-
content: [],
|
|
120
|
-
api: model.api,
|
|
121
|
-
provider: model.provider,
|
|
122
|
-
model: model.id,
|
|
123
|
-
usage: {
|
|
124
|
-
input: 0,
|
|
125
|
-
output: 0,
|
|
126
|
-
cacheRead: 0,
|
|
127
|
-
cacheWrite: 0,
|
|
128
|
-
totalTokens: 0,
|
|
129
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
130
|
-
},
|
|
131
|
-
stopReason: "stop",
|
|
132
|
-
timestamp: Date.now(),
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function convertMessages(context) {
|
|
136
|
-
const messages = [];
|
|
137
|
-
if (context.systemPrompt)
|
|
138
|
-
messages.push({ role: "system", content: context.systemPrompt });
|
|
139
|
-
for (const message of context.messages) {
|
|
140
|
-
if (message.role === "user") {
|
|
141
|
-
messages.push({
|
|
142
|
-
role: "user",
|
|
143
|
-
content: typeof message.content === "string" ? message.content : message.content.map(toOpenAIContentPart),
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
else if (message.role === "assistant") {
|
|
147
|
-
const text = message.content
|
|
148
|
-
.filter((part) => part.type === "text")
|
|
149
|
-
.map((part) => part.text)
|
|
150
|
-
.join("");
|
|
151
|
-
const toolCalls = message.content
|
|
152
|
-
.filter((part) => part.type === "toolCall")
|
|
153
|
-
.map((part) => ({
|
|
154
|
-
id: part.id,
|
|
155
|
-
type: "function",
|
|
156
|
-
function: { name: part.name, arguments: JSON.stringify(part.arguments ?? {}) },
|
|
157
|
-
}));
|
|
158
|
-
messages.push({
|
|
159
|
-
role: "assistant",
|
|
160
|
-
content: text || null,
|
|
161
|
-
...(toolCalls.length > 0 ? { tool_calls: toolCalls } : {}),
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
else if (message.role === "toolResult") {
|
|
165
|
-
messages.push({
|
|
166
|
-
role: "tool",
|
|
167
|
-
tool_call_id: message.toolCallId,
|
|
168
|
-
content: message.content.map(toOpenAIContentPart),
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
return messages;
|
|
173
|
-
}
|
|
174
|
-
function convertTools(context) {
|
|
175
|
-
return (context.tools ?? [])
|
|
176
|
-
.filter((tool) => !YUTORI_BUILTIN_TOOL_NAMES.has(tool.name))
|
|
177
|
-
.map((tool) => ({
|
|
178
|
-
type: "function",
|
|
179
|
-
function: {
|
|
180
|
-
name: tool.name,
|
|
181
|
-
description: tool.description,
|
|
182
|
-
parameters: tool.parameters,
|
|
183
|
-
},
|
|
184
|
-
}));
|
|
185
|
-
}
|
|
186
|
-
function emitText(stream, output, text) {
|
|
187
|
-
const contentIndex = output.content.length;
|
|
188
|
-
const content = { type: "text", text };
|
|
189
|
-
output.content.push(content);
|
|
190
|
-
stream.push({ type: "text_start", contentIndex, partial: output });
|
|
191
|
-
stream.push({ type: "text_delta", contentIndex, delta: text, partial: output });
|
|
192
|
-
stream.push({ type: "text_end", contentIndex, content: text, partial: output });
|
|
193
|
-
}
|
|
194
|
-
function toOpenAIContentPart(part) {
|
|
195
|
-
if (part.type === "text")
|
|
196
|
-
return { type: "text", text: part.text };
|
|
197
|
-
return { type: "image_url", image_url: { url: `data:${part.mimeType};base64,${part.data}` } };
|
|
198
|
-
}
|
|
199
|
-
function parseArguments(value) {
|
|
200
|
-
if (!value?.trim())
|
|
201
|
-
return {};
|
|
202
|
-
return JSON.parse(value);
|
|
203
|
-
}
|
|
204
|
-
const SCROLL_AMOUNT_PER_NOTCH = 120;
|
|
205
|
-
function readPoint(value) {
|
|
206
|
-
if (!Array.isArray(value) || value.length < 2)
|
|
207
|
-
return undefined;
|
|
208
|
-
const x = Number(value[0]);
|
|
209
|
-
const y = Number(value[1]);
|
|
210
|
-
if (!Number.isFinite(x) || !Number.isFinite(y))
|
|
211
|
-
return undefined;
|
|
212
|
-
return { x, y };
|
|
213
|
-
}
|
|
214
|
-
function toCanonicalAction(name, args) {
|
|
215
|
-
const coords = readPoint(args.coordinates);
|
|
216
|
-
switch (name) {
|
|
217
|
-
case "left_click":
|
|
218
|
-
return coords ? [{ type: "click", x: coords.x, y: coords.y }] : undefined;
|
|
219
|
-
case "right_click":
|
|
220
|
-
return coords ? [{ type: "click", x: coords.x, y: coords.y, button: "right" }] : undefined;
|
|
221
|
-
case "middle_click":
|
|
222
|
-
return coords ? [{ type: "click", x: coords.x, y: coords.y, button: "middle" }] : undefined;
|
|
223
|
-
case "double_click":
|
|
224
|
-
return coords ? [{ type: "double_click", x: coords.x, y: coords.y }] : undefined;
|
|
225
|
-
case "mouse_move":
|
|
226
|
-
case "hover":
|
|
227
|
-
return coords ? [{ type: "move", x: coords.x, y: coords.y }] : undefined;
|
|
228
|
-
case "mouse_down":
|
|
229
|
-
return coords ? [{ type: "mouse_down", x: coords.x, y: coords.y }] : undefined;
|
|
230
|
-
case "mouse_up":
|
|
231
|
-
return coords ? [{ type: "mouse_up", x: coords.x, y: coords.y }] : undefined;
|
|
232
|
-
case "type": {
|
|
233
|
-
const text = typeof args.text === "string" ? args.text : undefined;
|
|
234
|
-
return text !== undefined ? [{ type: "type", text }] : undefined;
|
|
235
|
-
}
|
|
236
|
-
case "key_press":
|
|
237
|
-
case "hold_key": {
|
|
238
|
-
const key = typeof args.key === "string" ? args.key : undefined;
|
|
239
|
-
return key ? [{ type: "keypress", keys: [key] }] : undefined;
|
|
240
|
-
}
|
|
241
|
-
case "scroll": {
|
|
242
|
-
if (!coords)
|
|
243
|
-
return undefined;
|
|
244
|
-
const amount = typeof args.amount === "number" ? args.amount : 1;
|
|
245
|
-
const direction = typeof args.direction === "string" ? args.direction : "down";
|
|
246
|
-
const ticks = amount * SCROLL_AMOUNT_PER_NOTCH;
|
|
247
|
-
const dx = direction === "left" ? -ticks : direction === "right" ? ticks : 0;
|
|
248
|
-
const dy = direction === "up" ? -ticks : direction === "down" ? ticks : 0;
|
|
249
|
-
return [{ type: "scroll", x: coords.x, y: coords.y, scroll_x: dx, scroll_y: dy }];
|
|
250
|
-
}
|
|
251
|
-
case "drag": {
|
|
252
|
-
const start = readPoint(args.start_coordinates);
|
|
253
|
-
if (!start || !coords)
|
|
254
|
-
return undefined;
|
|
255
|
-
return [{ type: "drag", path: [start, coords] }];
|
|
256
|
-
}
|
|
257
|
-
case "wait":
|
|
258
|
-
return [{ type: "wait" }];
|
|
259
|
-
case "go_back":
|
|
260
|
-
return [{ type: "back" }];
|
|
261
|
-
case "go_forward":
|
|
262
|
-
return [{ type: "forward" }];
|
|
263
|
-
case "goto_url": {
|
|
264
|
-
const url = typeof args.url === "string" ? args.url : undefined;
|
|
265
|
-
return url ? [{ type: "goto", url }] : undefined;
|
|
266
|
-
}
|
|
267
|
-
default:
|
|
268
|
-
return undefined;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
function usageFromYutori(usage) {
|
|
272
|
-
const input = readNumber(usage, "prompt_tokens");
|
|
273
|
-
const output = readNumber(usage, "completion_tokens");
|
|
274
|
-
const totalTokens = readNumber(usage, "total_tokens") || input + output;
|
|
275
|
-
return {
|
|
276
|
-
input,
|
|
277
|
-
output,
|
|
278
|
-
cacheRead: 0,
|
|
279
|
-
cacheWrite: 0,
|
|
280
|
-
totalTokens,
|
|
281
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
function readToolName(tool) {
|
|
285
|
-
if (!tool || typeof tool !== "object")
|
|
286
|
-
return undefined;
|
|
287
|
-
const obj = tool;
|
|
288
|
-
if (typeof obj.function?.name === "string")
|
|
289
|
-
return obj.function.name;
|
|
290
|
-
if (typeof obj.name === "string")
|
|
291
|
-
return obj.name;
|
|
292
|
-
return undefined;
|
|
293
|
-
}
|
|
294
|
-
function readNumber(value, key) {
|
|
295
|
-
if (!value || typeof value !== "object")
|
|
296
|
-
return 0;
|
|
297
|
-
const n = value[key];
|
|
298
|
-
return typeof n === "number" && Number.isFinite(n) ? n : 0;
|
|
299
|
-
}
|
|
300
|
-
function headersToRecord(headers) {
|
|
301
|
-
const out = {};
|
|
302
|
-
headers.forEach((value, key) => {
|
|
303
|
-
out[key] = value;
|
|
304
|
-
});
|
|
305
|
-
return out;
|
|
306
|
-
}
|
|
307
|
-
//# sourceMappingURL=provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/providers/yutori/provider.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EACN,iCAAiC,GAWjC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAkB,MAAM,WAAW,CAAC;AAElF,MAAM,CAAC,MAAM,2BAA2B,GAAG,yBAAyB,CAAC;AAErE,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAS,gBAAgB,CAAC,CAAC;AAMpE,MAAM,CAAC,MAAM,YAAY,GAAsE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IAC1H,MAAM,MAAM,GAAG,iCAAiC,EAAE,CAAC;IACnD,KAAK,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACtD,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAA4E,CAC1G,KAAK,EACL,OAAO,EACP,OAAO,EACN,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E,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;KACpE,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,IAAa;IAClC,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACxD,MAAM,GAAG,GAAG,IAAyD,CAAC;IACtE,IAAI,OAAO,GAAG,CAAC,QAAQ,EAAE,IAAI,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;IACrE,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC,IAAI,CAAC;IAClD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,SAAS,UAAU,CAAC,KAAc,EAAE,GAAW;IAC9C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC;IAClD,MAAM,CAAC,GAAI,KAAiC,CAAC,GAAG,CAAC,CAAC;IAClD,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,eAAe,CAAC,OAAgB;IACxC,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC9B,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAClB,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
package/dist/providers.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { streamSimpleTzafonResponses, streamTzafonResponses, TZAFON_RESPONSES_API } from "./providers/tzafon/provider.js";
|
|
2
|
-
import { streamSimpleYutori, streamYutori, YUTORI_CHAT_COMPLETIONS_API } from "./providers/yutori/provider.js";
|
|
3
|
-
export declare function registerCuaProviders(): void;
|
|
4
|
-
export { TZAFON_RESPONSES_API, streamSimpleTzafonResponses, streamTzafonResponses };
|
|
5
|
-
export { YUTORI_CHAT_COMPLETIONS_API, streamSimpleYutori, streamYutori };
|
|
6
|
-
//# sourceMappingURL=providers.d.ts.map
|
package/dist/providers.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACvH,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAQ5G,wBAAgB,oBAAoB,IAAI,IAAI,CAa3C;AAED,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,CAAC;AACpF,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,YAAY,EAAE,CAAC"}
|
package/dist/providers.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { registerApiProvider } from "@earendil-works/pi-ai";
|
|
2
|
-
import { streamSimpleTzafonResponses, streamTzafonResponses, TZAFON_RESPONSES_API } from "./providers/tzafon/provider.js";
|
|
3
|
-
import { streamSimpleYutori, streamYutori, YUTORI_CHAT_COMPLETIONS_API } from "./providers/yutori/provider.js";
|
|
4
|
-
let registered = false;
|
|
5
|
-
// pi-ai eagerly registers openai-responses, anthropic-messages, and
|
|
6
|
-
// google-generative-ai when its index module loads (see
|
|
7
|
-
// node_modules/@earendil-works/pi-ai/dist/providers/register-builtins.js).
|
|
8
|
-
// CUA only needs to add the providers pi-ai does not ship: Tzafon and Yutori.
|
|
9
|
-
export function registerCuaProviders() {
|
|
10
|
-
if (registered)
|
|
11
|
-
return;
|
|
12
|
-
registerApiProvider({
|
|
13
|
-
api: YUTORI_CHAT_COMPLETIONS_API,
|
|
14
|
-
stream: streamYutori,
|
|
15
|
-
streamSimple: streamSimpleYutori,
|
|
16
|
-
});
|
|
17
|
-
registerApiProvider({
|
|
18
|
-
api: TZAFON_RESPONSES_API,
|
|
19
|
-
stream: streamTzafonResponses,
|
|
20
|
-
streamSimple: streamSimpleTzafonResponses,
|
|
21
|
-
});
|
|
22
|
-
registered = true;
|
|
23
|
-
}
|
|
24
|
-
export { TZAFON_RESPONSES_API, streamSimpleTzafonResponses, streamTzafonResponses };
|
|
25
|
-
export { YUTORI_CHAT_COMPLETIONS_API, streamSimpleYutori, streamYutori };
|
|
26
|
-
//# sourceMappingURL=providers.js.map
|
package/dist/providers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACvH,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAE5G,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB,oEAAoE;AACpE,wDAAwD;AACxD,2EAA2E;AAC3E,8EAA8E;AAC9E,MAAM,UAAU,oBAAoB;IACnC,IAAI,UAAU;QAAE,OAAO;IACvB,mBAAmB,CAAC;QACnB,GAAG,EAAE,2BAA2B;QAChC,MAAM,EAAE,YAAY;QACpB,YAAY,EAAE,kBAAkB;KAChC,CAAC,CAAC;IACH,mBAAmB,CAAC;QACnB,GAAG,EAAE,oBAAoB;QACzB,MAAM,EAAE,qBAAqB;QAC7B,YAAY,EAAE,2BAA2B;KACzC,CAAC,CAAC;IACH,UAAU,GAAG,IAAI,CAAC;AACnB,CAAC;AAED,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,CAAC;AACpF,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,YAAY,EAAE,CAAC"}
|
package/dist/runtime-spec.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Api, Model, SimpleStreamOptions, Tool } from "@earendil-works/pi-ai";
|
|
2
|
-
import { type CuaModelRef, type CuaProvider } from "./models.js";
|
|
3
|
-
/**
|
|
4
|
-
* Provider-resolved runtime defaults for CUA execution.
|
|
5
|
-
*
|
|
6
|
-
* `@onkernel/cua-agent` consumes this shape so it can stay provider-neutral:
|
|
7
|
-
* it only needs model, tool definitions, and optional payload middleware,
|
|
8
|
-
* without branching on provider-specific quirks.
|
|
9
|
-
*/
|
|
10
|
-
export interface CuaRuntimeSpec {
|
|
11
|
-
model: Model<Api>;
|
|
12
|
-
provider: CuaProvider;
|
|
13
|
-
/** Canonical CUA tool definitions exposed to the model. */
|
|
14
|
-
toolDefinitions: Tool[];
|
|
15
|
-
/** Provider-tuned baseline prompt for browser control behavior. */
|
|
16
|
-
defaultSystemPrompt: string;
|
|
17
|
-
/** Optional provider middleware for request payload adaptation. */
|
|
18
|
-
onPayload?: SimpleStreamOptions["onPayload"];
|
|
19
|
-
}
|
|
20
|
-
export type CuaRuntimeSpecInput = CuaModelRef | Model<Api>;
|
|
21
|
-
/**
|
|
22
|
-
* Resolve provider-owned policy from either a CUA model ref or a concrete model.
|
|
23
|
-
*
|
|
24
|
-
* This is intentionally the only place where provider-specific defaults are
|
|
25
|
-
* selected. Callers should consume the returned spec and avoid branching on
|
|
26
|
-
* provider names directly.
|
|
27
|
-
*/
|
|
28
|
-
export declare function resolveCuaRuntimeSpec(input: CuaRuntimeSpecInput): CuaRuntimeSpec;
|
|
29
|
-
//# sourceMappingURL=runtime-spec.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-spec.d.ts","sourceRoot":"","sources":["../src/runtime-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAiC,MAAM,UAAU,CAAC;AAO7F;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAClB,QAAQ,EAAE,WAAW,CAAC;IACtB,2DAA2D;IAC3D,eAAe,EAAE,IAAI,EAAE,CAAC;IACxB,mEAAmE;IACnE,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mEAAmE;IACnE,SAAS,CAAC,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;CAC7C;AAED,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;AAE3D;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,mBAAmB,GAAG,cAAc,CA2ChF"}
|
package/dist/runtime-spec.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { getCuaModel, providerForModel } from "./models";
|
|
2
|
-
import * as anthropic from "./providers/anthropic/index";
|
|
3
|
-
import * as gemini from "./providers/gemini/index";
|
|
4
|
-
import * as openai from "./providers/openai/index";
|
|
5
|
-
import * as tzafon from "./providers/tzafon/index";
|
|
6
|
-
import * as yutori from "./providers/yutori/index";
|
|
7
|
-
/**
|
|
8
|
-
* Resolve provider-owned policy from either a CUA model ref or a concrete model.
|
|
9
|
-
*
|
|
10
|
-
* This is intentionally the only place where provider-specific defaults are
|
|
11
|
-
* selected. Callers should consume the returned spec and avoid branching on
|
|
12
|
-
* provider names directly.
|
|
13
|
-
*/
|
|
14
|
-
export function resolveCuaRuntimeSpec(input) {
|
|
15
|
-
const model = typeof input === "string" ? getCuaModel(input) : input;
|
|
16
|
-
const provider = providerForModel(model);
|
|
17
|
-
switch (provider) {
|
|
18
|
-
case "anthropic":
|
|
19
|
-
return {
|
|
20
|
-
model,
|
|
21
|
-
provider,
|
|
22
|
-
toolDefinitions: anthropic.createComputerToolDefinitions(),
|
|
23
|
-
defaultSystemPrompt: anthropic.buildAnthropicSystemPrompt(),
|
|
24
|
-
};
|
|
25
|
-
case "google":
|
|
26
|
-
return {
|
|
27
|
-
model,
|
|
28
|
-
provider,
|
|
29
|
-
toolDefinitions: gemini.createComputerToolDefinitions(),
|
|
30
|
-
defaultSystemPrompt: gemini.buildGeminiSystemPrompt(),
|
|
31
|
-
};
|
|
32
|
-
case "tzafon":
|
|
33
|
-
return {
|
|
34
|
-
model,
|
|
35
|
-
provider,
|
|
36
|
-
toolDefinitions: tzafon.createComputerToolDefinitions(),
|
|
37
|
-
defaultSystemPrompt: tzafon.buildTzafonSystemPrompt(),
|
|
38
|
-
};
|
|
39
|
-
case "yutori":
|
|
40
|
-
return {
|
|
41
|
-
model,
|
|
42
|
-
provider,
|
|
43
|
-
toolDefinitions: yutori.createComputerToolDefinitions(),
|
|
44
|
-
defaultSystemPrompt: yutori.buildYutoriSystemPrompt(),
|
|
45
|
-
onPayload: yutori.yutoriBuiltinToolsOnPayload,
|
|
46
|
-
};
|
|
47
|
-
case "openai":
|
|
48
|
-
default:
|
|
49
|
-
return {
|
|
50
|
-
model,
|
|
51
|
-
provider,
|
|
52
|
-
toolDefinitions: openai.createComputerToolDefinitions(),
|
|
53
|
-
defaultSystemPrompt: openai.OPENAI_BATCH_INSTRUCTIONS,
|
|
54
|
-
onPayload: openai.openaiResponsesStoreOnPayload,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=runtime-spec.js.map
|
package/dist/runtime-spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-spec.js","sourceRoot":"","sources":["../src/runtime-spec.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC7F,OAAO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