@positronic/client-vercel 0.0.56 → 0.0.58
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/dist/src/index.js +213 -90
- package/dist/types/index.d.ts +12 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/src/index.js
CHANGED
|
@@ -6,6 +6,9 @@ function _array_like_to_array(arr, len) {
|
|
|
6
6
|
function _array_with_holes(arr) {
|
|
7
7
|
if (Array.isArray(arr)) return arr;
|
|
8
8
|
}
|
|
9
|
+
function _array_without_holes(arr) {
|
|
10
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
|
+
}
|
|
9
12
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
13
|
try {
|
|
11
14
|
var info = gen[key](arg);
|
|
@@ -67,6 +70,9 @@ function _define_property(obj, key, value) {
|
|
|
67
70
|
}
|
|
68
71
|
return obj;
|
|
69
72
|
}
|
|
73
|
+
function _iterable_to_array(iter) {
|
|
74
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
75
|
+
}
|
|
70
76
|
function _iterable_to_array_limit(arr, i) {
|
|
71
77
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
72
78
|
if (_i == null) return;
|
|
@@ -94,9 +100,15 @@ function _iterable_to_array_limit(arr, i) {
|
|
|
94
100
|
function _non_iterable_rest() {
|
|
95
101
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
96
102
|
}
|
|
103
|
+
function _non_iterable_spread() {
|
|
104
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
105
|
+
}
|
|
97
106
|
function _sliced_to_array(arr, i) {
|
|
98
107
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
99
108
|
}
|
|
109
|
+
function _to_consumable_array(arr) {
|
|
110
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
111
|
+
}
|
|
100
112
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
101
113
|
if (!o) return;
|
|
102
114
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -197,6 +209,31 @@ function _ts_generator(thisArg, body) {
|
|
|
197
209
|
}
|
|
198
210
|
}
|
|
199
211
|
import { generateObject, generateText, streamText as vercelStreamText, stepCountIs } from 'ai';
|
|
212
|
+
/**
|
|
213
|
+
* Creates a tool result message in SDK-native format.
|
|
214
|
+
* Use this to append tool results to responseMessages before the next generateText call.
|
|
215
|
+
*
|
|
216
|
+
* Note: The Vercel AI SDK expects tool outputs to be wrapped in a discriminated union format
|
|
217
|
+
* with a `type` field. We use `{ type: 'text', value: ... }` for compatibility.
|
|
218
|
+
*/ export function createToolResultMessage(toolCallId, toolName, result) {
|
|
219
|
+
// Wrap the result in the SDK-expected format
|
|
220
|
+
// The SDK validates output against a discriminated union requiring a `type` field
|
|
221
|
+
var outputValue = typeof result === 'string' ? result : JSON.stringify(result);
|
|
222
|
+
return {
|
|
223
|
+
role: 'tool',
|
|
224
|
+
content: [
|
|
225
|
+
{
|
|
226
|
+
type: 'tool-result',
|
|
227
|
+
toolCallId: toolCallId,
|
|
228
|
+
toolName: toolName,
|
|
229
|
+
output: {
|
|
230
|
+
type: 'text',
|
|
231
|
+
value: outputValue
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
};
|
|
236
|
+
}
|
|
200
237
|
export var VercelClient = /*#__PURE__*/ function() {
|
|
201
238
|
"use strict";
|
|
202
239
|
function VercelClient(model) {
|
|
@@ -205,6 +242,12 @@ export var VercelClient = /*#__PURE__*/ function() {
|
|
|
205
242
|
this.model = model;
|
|
206
243
|
}
|
|
207
244
|
_create_class(VercelClient, [
|
|
245
|
+
{
|
|
246
|
+
key: "createToolResultMessage",
|
|
247
|
+
value: function createToolResultMessage1(toolCallId, toolName, result) {
|
|
248
|
+
return createToolResultMessage(toolCallId, toolName, result);
|
|
249
|
+
}
|
|
250
|
+
},
|
|
208
251
|
{
|
|
209
252
|
key: "generateObject",
|
|
210
253
|
value: function generateObject1(params) {
|
|
@@ -287,86 +330,121 @@ export var VercelClient = /*#__PURE__*/ function() {
|
|
|
287
330
|
key: "generateText",
|
|
288
331
|
value: function generateText1(params) {
|
|
289
332
|
return _async_to_generator(function() {
|
|
290
|
-
var _result_toolCalls, _result_usage, system, messages, tools, modelMessages, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, msg,
|
|
333
|
+
var _result_toolCalls, _result_usage, system, messages, responseMessages, tools, modelMessages, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, msg, contentParts, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, tc, aiTools, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _step_value, name, tool, result, updatedMessages, _result_usage_totalTokens;
|
|
291
334
|
return _ts_generator(this, function(_state) {
|
|
292
335
|
switch(_state.label){
|
|
293
336
|
case 0:
|
|
294
|
-
system = params.system, messages = params.messages, tools = params.tools;
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
337
|
+
system = params.system, messages = params.messages, responseMessages = params.responseMessages, tools = params.tools;
|
|
338
|
+
if (responseMessages && responseMessages.length > 0) {
|
|
339
|
+
// Use the SDK-native messages directly (preserves providerOptions/thoughtSignature)
|
|
340
|
+
modelMessages = responseMessages;
|
|
341
|
+
} else {
|
|
342
|
+
// First call - convert our ToolMessage format to SDK format
|
|
343
|
+
modelMessages = [];
|
|
344
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
345
|
+
try {
|
|
346
|
+
for(_iterator = messages[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
347
|
+
msg = _step.value;
|
|
348
|
+
if (msg.role === 'user') {
|
|
349
|
+
modelMessages.push({
|
|
350
|
+
role: 'user',
|
|
351
|
+
content: msg.content
|
|
352
|
+
});
|
|
353
|
+
} else if (msg.role === 'assistant') {
|
|
354
|
+
contentParts = [];
|
|
355
|
+
if (msg.content) {
|
|
356
|
+
contentParts.push({
|
|
357
|
+
type: 'text',
|
|
358
|
+
text: msg.content
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
if (msg.toolCalls && msg.toolCalls.length > 0) {
|
|
362
|
+
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
363
|
+
try {
|
|
364
|
+
for(_iterator1 = msg.toolCalls[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
365
|
+
tc = _step1.value;
|
|
366
|
+
contentParts.push({
|
|
367
|
+
type: 'tool-call',
|
|
368
|
+
toolCallId: tc.toolCallId,
|
|
369
|
+
toolName: tc.toolName,
|
|
370
|
+
input: tc.args
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
} catch (err) {
|
|
374
|
+
_didIteratorError1 = true;
|
|
375
|
+
_iteratorError1 = err;
|
|
376
|
+
} finally{
|
|
377
|
+
try {
|
|
378
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
379
|
+
_iterator1.return();
|
|
380
|
+
}
|
|
381
|
+
} finally{
|
|
382
|
+
if (_didIteratorError1) {
|
|
383
|
+
throw _iteratorError1;
|
|
384
|
+
}
|
|
328
385
|
}
|
|
329
386
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
387
|
+
}
|
|
388
|
+
if (contentParts.length > 0) {
|
|
389
|
+
modelMessages.push({
|
|
390
|
+
role: 'assistant',
|
|
391
|
+
content: contentParts
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
} else if (msg.role === 'tool') {
|
|
395
|
+
modelMessages.push({
|
|
396
|
+
role: 'tool',
|
|
397
|
+
content: [
|
|
398
|
+
{
|
|
399
|
+
type: 'tool-result',
|
|
400
|
+
toolCallId: msg.toolCallId,
|
|
401
|
+
toolName: msg.toolName,
|
|
402
|
+
output: {
|
|
403
|
+
type: 'text',
|
|
404
|
+
value: msg.content
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
]
|
|
408
|
+
});
|
|
409
|
+
}
|
|
341
410
|
}
|
|
411
|
+
} catch (err) {
|
|
412
|
+
_didIteratorError = true;
|
|
413
|
+
_iteratorError = err;
|
|
342
414
|
} finally{
|
|
343
|
-
|
|
344
|
-
|
|
415
|
+
try {
|
|
416
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
417
|
+
_iterator.return();
|
|
418
|
+
}
|
|
419
|
+
} finally{
|
|
420
|
+
if (_didIteratorError) {
|
|
421
|
+
throw _iteratorError;
|
|
422
|
+
}
|
|
345
423
|
}
|
|
346
424
|
}
|
|
347
425
|
}
|
|
348
426
|
// Convert our tool format to Vercel AI SDK format
|
|
349
427
|
aiTools = {};
|
|
350
|
-
|
|
428
|
+
_iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
|
|
351
429
|
try {
|
|
352
|
-
for(
|
|
353
|
-
_step_value = _sliced_to_array(
|
|
430
|
+
for(_iterator2 = Object.entries(tools)[Symbol.iterator](); !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
|
|
431
|
+
_step_value = _sliced_to_array(_step2.value, 2), name = _step_value[0], tool = _step_value[1];
|
|
354
432
|
aiTools[name] = {
|
|
355
433
|
description: tool.description,
|
|
356
434
|
inputSchema: tool.inputSchema
|
|
357
435
|
};
|
|
358
436
|
}
|
|
359
437
|
} catch (err) {
|
|
360
|
-
|
|
361
|
-
|
|
438
|
+
_didIteratorError2 = true;
|
|
439
|
+
_iteratorError2 = err;
|
|
362
440
|
} finally{
|
|
363
441
|
try {
|
|
364
|
-
if (!
|
|
365
|
-
|
|
442
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
443
|
+
_iterator2.return();
|
|
366
444
|
}
|
|
367
445
|
} finally{
|
|
368
|
-
if (
|
|
369
|
-
throw
|
|
446
|
+
if (_didIteratorError2) {
|
|
447
|
+
throw _iteratorError2;
|
|
370
448
|
}
|
|
371
449
|
}
|
|
372
450
|
}
|
|
@@ -374,12 +452,16 @@ export var VercelClient = /*#__PURE__*/ function() {
|
|
|
374
452
|
4,
|
|
375
453
|
generateText({
|
|
376
454
|
model: this.model,
|
|
455
|
+
system: system,
|
|
377
456
|
messages: modelMessages,
|
|
378
457
|
tools: aiTools
|
|
379
458
|
})
|
|
380
459
|
];
|
|
381
460
|
case 1:
|
|
382
461
|
result = _state.sent();
|
|
462
|
+
// Return the updated conversation (input messages + new response messages)
|
|
463
|
+
// The response.messages contain proper providerOptions for Gemini thoughtSignature etc.
|
|
464
|
+
updatedMessages = _to_consumable_array(modelMessages).concat(_to_consumable_array(result.response.messages));
|
|
383
465
|
return [
|
|
384
466
|
2,
|
|
385
467
|
{
|
|
@@ -393,7 +475,8 @@ export var VercelClient = /*#__PURE__*/ function() {
|
|
|
393
475
|
}),
|
|
394
476
|
usage: {
|
|
395
477
|
totalTokens: (_result_usage_totalTokens = (_result_usage = result.usage) === null || _result_usage === void 0 ? void 0 : _result_usage.totalTokens) !== null && _result_usage_totalTokens !== void 0 ? _result_usage_totalTokens : 0
|
|
396
|
-
}
|
|
478
|
+
},
|
|
479
|
+
responseMessages: updatedMessages
|
|
397
480
|
}
|
|
398
481
|
];
|
|
399
482
|
}
|
|
@@ -405,7 +488,7 @@ export var VercelClient = /*#__PURE__*/ function() {
|
|
|
405
488
|
key: "streamText",
|
|
406
489
|
value: function streamText(params) {
|
|
407
490
|
return _async_to_generator(function() {
|
|
408
|
-
var system, prompt, messages, tools, _params_maxSteps, maxSteps, modelMessages, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, msg,
|
|
491
|
+
var system, prompt, messages, tools, _params_maxSteps, maxSteps, modelMessages, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, msg, contentParts, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, tc, aiTools, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _step_value, name, tool, stream, _ref, steps, text, usage, allToolCalls, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, step, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _loop, _iterator4, _step4, _usage_totalTokens;
|
|
409
492
|
return _ts_generator(this, function(_state) {
|
|
410
493
|
switch(_state.label){
|
|
411
494
|
case 0:
|
|
@@ -430,10 +513,50 @@ export var VercelClient = /*#__PURE__*/ function() {
|
|
|
430
513
|
content: msg.content
|
|
431
514
|
});
|
|
432
515
|
} else if (msg.role === 'assistant') {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
516
|
+
// Build content array for assistant message
|
|
517
|
+
contentParts = [];
|
|
518
|
+
// Add text if present
|
|
519
|
+
if (msg.content) {
|
|
520
|
+
contentParts.push({
|
|
521
|
+
type: 'text',
|
|
522
|
+
text: msg.content
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
// Add tool calls if present (using 'input' as Vercel SDK expects)
|
|
526
|
+
if (msg.toolCalls && msg.toolCalls.length > 0) {
|
|
527
|
+
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
528
|
+
try {
|
|
529
|
+
for(_iterator1 = msg.toolCalls[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
530
|
+
tc = _step1.value;
|
|
531
|
+
contentParts.push({
|
|
532
|
+
type: 'tool-call',
|
|
533
|
+
toolCallId: tc.toolCallId,
|
|
534
|
+
toolName: tc.toolName,
|
|
535
|
+
input: tc.args
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
} catch (err) {
|
|
539
|
+
_didIteratorError1 = true;
|
|
540
|
+
_iteratorError1 = err;
|
|
541
|
+
} finally{
|
|
542
|
+
try {
|
|
543
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
544
|
+
_iterator1.return();
|
|
545
|
+
}
|
|
546
|
+
} finally{
|
|
547
|
+
if (_didIteratorError1) {
|
|
548
|
+
throw _iteratorError1;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
// Push message with content array or string
|
|
554
|
+
if (contentParts.length > 0) {
|
|
555
|
+
modelMessages.push({
|
|
556
|
+
role: 'assistant',
|
|
557
|
+
content: contentParts
|
|
558
|
+
});
|
|
559
|
+
}
|
|
437
560
|
} else if (msg.role === 'tool') {
|
|
438
561
|
modelMessages.push({
|
|
439
562
|
role: 'tool',
|
|
@@ -473,10 +596,10 @@ export var VercelClient = /*#__PURE__*/ function() {
|
|
|
473
596
|
});
|
|
474
597
|
// Convert tools to Vercel AI SDK format (with execute functions)
|
|
475
598
|
aiTools = {};
|
|
476
|
-
|
|
599
|
+
_iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
|
|
477
600
|
try {
|
|
478
|
-
for(
|
|
479
|
-
_step_value = _sliced_to_array(
|
|
601
|
+
for(_iterator2 = Object.entries(tools)[Symbol.iterator](); !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
|
|
602
|
+
_step_value = _sliced_to_array(_step2.value, 2), name = _step_value[0], tool = _step_value[1];
|
|
480
603
|
aiTools[name] = {
|
|
481
604
|
description: tool.description,
|
|
482
605
|
inputSchema: tool.inputSchema,
|
|
@@ -484,16 +607,16 @@ export var VercelClient = /*#__PURE__*/ function() {
|
|
|
484
607
|
};
|
|
485
608
|
}
|
|
486
609
|
} catch (err) {
|
|
487
|
-
|
|
488
|
-
|
|
610
|
+
_didIteratorError2 = true;
|
|
611
|
+
_iteratorError2 = err;
|
|
489
612
|
} finally{
|
|
490
613
|
try {
|
|
491
|
-
if (!
|
|
492
|
-
|
|
614
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
615
|
+
_iterator2.return();
|
|
493
616
|
}
|
|
494
617
|
} finally{
|
|
495
|
-
if (
|
|
496
|
-
throw
|
|
618
|
+
if (_didIteratorError2) {
|
|
619
|
+
throw _iteratorError2;
|
|
497
620
|
}
|
|
498
621
|
}
|
|
499
622
|
}
|
|
@@ -519,14 +642,14 @@ export var VercelClient = /*#__PURE__*/ function() {
|
|
|
519
642
|
]), steps = _ref[0], text = _ref[1], usage = _ref[2];
|
|
520
643
|
// Collect all tool calls across all steps with their results
|
|
521
644
|
allToolCalls = [];
|
|
522
|
-
|
|
645
|
+
_iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = undefined;
|
|
523
646
|
try {
|
|
524
|
-
for(
|
|
525
|
-
step =
|
|
526
|
-
|
|
647
|
+
for(_iterator3 = steps[Symbol.iterator](); !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true){
|
|
648
|
+
step = _step3.value;
|
|
649
|
+
_iteratorNormalCompletion4 = true, _didIteratorError4 = false, _iteratorError4 = undefined;
|
|
527
650
|
try {
|
|
528
651
|
_loop = function() {
|
|
529
|
-
var toolCall =
|
|
652
|
+
var toolCall = _step4.value;
|
|
530
653
|
var toolResult = step.toolResults.find(function(tr) {
|
|
531
654
|
return tr.toolCallId === toolCall.toolCallId;
|
|
532
655
|
});
|
|
@@ -538,33 +661,33 @@ export var VercelClient = /*#__PURE__*/ function() {
|
|
|
538
661
|
});
|
|
539
662
|
};
|
|
540
663
|
// Match tool calls with their results
|
|
541
|
-
for(
|
|
664
|
+
for(_iterator4 = step.toolCalls[Symbol.iterator](); !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true)_loop();
|
|
542
665
|
} catch (err) {
|
|
543
|
-
|
|
544
|
-
|
|
666
|
+
_didIteratorError4 = true;
|
|
667
|
+
_iteratorError4 = err;
|
|
545
668
|
} finally{
|
|
546
669
|
try {
|
|
547
|
-
if (!
|
|
548
|
-
|
|
670
|
+
if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
|
|
671
|
+
_iterator4.return();
|
|
549
672
|
}
|
|
550
673
|
} finally{
|
|
551
|
-
if (
|
|
552
|
-
throw
|
|
674
|
+
if (_didIteratorError4) {
|
|
675
|
+
throw _iteratorError4;
|
|
553
676
|
}
|
|
554
677
|
}
|
|
555
678
|
}
|
|
556
679
|
}
|
|
557
680
|
} catch (err) {
|
|
558
|
-
|
|
559
|
-
|
|
681
|
+
_didIteratorError3 = true;
|
|
682
|
+
_iteratorError3 = err;
|
|
560
683
|
} finally{
|
|
561
684
|
try {
|
|
562
|
-
if (!
|
|
563
|
-
|
|
685
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
686
|
+
_iterator3.return();
|
|
564
687
|
}
|
|
565
688
|
} finally{
|
|
566
|
-
if (
|
|
567
|
-
throw
|
|
689
|
+
if (_didIteratorError3) {
|
|
690
|
+
throw _iteratorError3;
|
|
568
691
|
}
|
|
569
692
|
}
|
|
570
693
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import type { ObjectGenerator, Message, ToolMessage } from '@positronic/core';
|
|
1
|
+
import type { ObjectGenerator, Message, ToolMessage, ResponseMessage } from '@positronic/core';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import type { LanguageModel } from 'ai';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a tool result message in SDK-native format.
|
|
6
|
+
* Use this to append tool results to responseMessages before the next generateText call.
|
|
7
|
+
*
|
|
8
|
+
* Note: The Vercel AI SDK expects tool outputs to be wrapped in a discriminated union format
|
|
9
|
+
* with a `type` field. We use `{ type: 'text', value: ... }` for compatibility.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createToolResultMessage(toolCallId: string, toolName: string, result: unknown): ResponseMessage;
|
|
4
12
|
export declare class VercelClient implements ObjectGenerator {
|
|
5
13
|
private model;
|
|
6
14
|
constructor(model: LanguageModel);
|
|
15
|
+
createToolResultMessage(toolCallId: string, toolName: string, result: unknown): ResponseMessage;
|
|
7
16
|
generateObject<T extends z.AnyZodObject>(params: {
|
|
8
17
|
schema: T;
|
|
9
18
|
schemaName: string;
|
|
@@ -15,6 +24,7 @@ export declare class VercelClient implements ObjectGenerator {
|
|
|
15
24
|
generateText(params: {
|
|
16
25
|
system?: string;
|
|
17
26
|
messages: ToolMessage[];
|
|
27
|
+
responseMessages?: ResponseMessage[];
|
|
18
28
|
tools: Record<string, {
|
|
19
29
|
description: string;
|
|
20
30
|
inputSchema: z.ZodSchema;
|
|
@@ -29,6 +39,7 @@ export declare class VercelClient implements ObjectGenerator {
|
|
|
29
39
|
usage: {
|
|
30
40
|
totalTokens: number;
|
|
31
41
|
};
|
|
42
|
+
responseMessages: ResponseMessage[];
|
|
32
43
|
}>;
|
|
33
44
|
streamText(params: {
|
|
34
45
|
system?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAO/F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,IAAI,CAAC;AAEtD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,GACd,eAAe,CAgBjB;AAED,qBAAa,YAAa,YAAW,eAAe;IAClD,OAAO,CAAC,KAAK,CAAgB;gBAEjB,KAAK,EAAE,aAAa;IAIhC,uBAAuB,CACrB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,GACd,eAAe;IAIZ,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,YAAY,EAAE,MAAM,EAAE;QACrD,MAAM,EAAE,CAAC,CAAC;QACV,UAAU,EAAE,MAAM,CAAC;QACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;QACrB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IA8CjB,YAAY,CAAC,MAAM,EAAE;QACzB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,WAAW,EAAE,CAAC;QACxB,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;QACrC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,WAAW,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,CAAC,CAAC,SAAS,CAAA;SAAE,CAAC,CAAC;KAC1E,GAAG,OAAO,CAAC;QACV,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,KAAK,CAAC;YAAE,UAAU,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,OAAO,CAAA;SAAE,CAAC,CAAC;QAC3E,KAAK,EAAE;YAAE,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC;QAC/B,gBAAgB,EAAE,eAAe,EAAE,CAAC;KACrC,CAAC;IA4FI,UAAU,CAAC,MAAM,EAAE;QACvB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;QACzB,KAAK,EAAE,MAAM,CACX,MAAM,EACN;YACE,WAAW,EAAE,MAAM,CAAC;YACpB,WAAW,EAAE,CAAC,CAAC,SAAS,CAAC;YACzB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;SACzD,CACF,CAAC;QACF,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QACV,SAAS,EAAE,KAAK,CAAC;YACf,UAAU,EAAE,MAAM,CAAC;YACnB,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,OAAO,CAAC;YACd,MAAM,EAAE,OAAO,CAAC;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,EAAE;YAAE,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC;KAChC,CAAC;CA6HH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@positronic/client-vercel",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.58",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"ai": "^6.0.0"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@positronic/core": "^0.0.
|
|
26
|
+
"@positronic/core": "^0.0.58",
|
|
27
27
|
"zod": "^3.24.1"
|
|
28
28
|
}
|
|
29
29
|
}
|