@mastra/core 0.4.3-alpha.3 → 0.4.3
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/agent/index.cjs +73 -20
- package/dist/agent/index.d.cts +1 -1
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +1 -1
- package/dist/{base-BhXOsdEx.d.cts → base-CbCmDLUb.d.cts} +6 -1
- package/dist/{base-CZA3AlwW.d.ts → base-DqRXkxCw.d.ts} +6 -1
- package/dist/{chunk-VRY5N2EB.js → chunk-E7K35ROR.js} +73 -20
- package/dist/{chunk-N4UKSVX4.js → chunk-JXEH6PBQ.js} +1 -1
- package/dist/eval/index.d.cts +1 -1
- package/dist/eval/index.d.ts +1 -1
- package/dist/index.cjs +73 -20
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/integration/index.d.cts +2 -2
- package/dist/integration/index.d.ts +2 -2
- package/dist/llm/index.d.cts +1 -1
- package/dist/llm/index.d.ts +1 -1
- package/dist/mastra/index.d.cts +2 -2
- package/dist/mastra/index.d.ts +2 -2
- package/dist/memory/index.d.cts +1 -1
- package/dist/memory/index.d.ts +1 -1
- package/dist/relevance/index.cjs +73 -20
- package/dist/relevance/index.js +1 -1
- package/dist/storage/index.d.cts +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/libsql/index.d.cts +1 -1
- package/dist/storage/libsql/index.d.ts +1 -1
- package/dist/telemetry/index.d.cts +1 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/tools/index.d.cts +2 -2
- package/dist/tools/index.d.ts +2 -2
- package/dist/{workflow-87-9uPHk.d.cts → workflow-DlRFMI4Q.d.cts} +1 -1
- package/dist/{workflow-BVt16qBd.d.ts → workflow-fGgxPZk4.d.ts} +1 -1
- package/dist/workflows/index.d.cts +3 -3
- package/dist/workflows/index.d.ts +3 -3
- package/package.json +1 -1
package/dist/agent/index.cjs
CHANGED
|
@@ -396,7 +396,9 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
396
396
|
}
|
|
397
397
|
convertTools({
|
|
398
398
|
tools,
|
|
399
|
-
runId
|
|
399
|
+
runId,
|
|
400
|
+
threadId,
|
|
401
|
+
resourceId
|
|
400
402
|
} = {}) {
|
|
401
403
|
this.logger.debug("Starting tool conversion for LLM");
|
|
402
404
|
const converted = Object.entries(tools || {}).reduce((memo, value) => {
|
|
@@ -414,6 +416,8 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
414
416
|
});
|
|
415
417
|
return tool?.execute?.({
|
|
416
418
|
context: props,
|
|
419
|
+
threadId,
|
|
420
|
+
resourceId,
|
|
417
421
|
mastra: this.#mastra,
|
|
418
422
|
runId
|
|
419
423
|
}, options) ?? void 0;
|
|
@@ -421,7 +425,10 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
421
425
|
this.logger.error("Error executing tool", {
|
|
422
426
|
tool: k,
|
|
423
427
|
props,
|
|
424
|
-
error
|
|
428
|
+
error,
|
|
429
|
+
runId,
|
|
430
|
+
threadId,
|
|
431
|
+
resourceId
|
|
425
432
|
});
|
|
426
433
|
throw error;
|
|
427
434
|
}
|
|
@@ -444,6 +451,8 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
444
451
|
onStepFinish,
|
|
445
452
|
experimental_output,
|
|
446
453
|
telemetry,
|
|
454
|
+
threadId,
|
|
455
|
+
resourceId,
|
|
447
456
|
...rest
|
|
448
457
|
}) {
|
|
449
458
|
const model = this.#model;
|
|
@@ -451,11 +460,15 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
451
460
|
runId,
|
|
452
461
|
messages,
|
|
453
462
|
maxSteps,
|
|
463
|
+
threadId,
|
|
464
|
+
resourceId,
|
|
454
465
|
tools: Object.keys(tools || convertedTools || {})
|
|
455
466
|
});
|
|
456
467
|
const finalTools = convertedTools || this.convertTools({
|
|
457
468
|
tools,
|
|
458
|
-
runId
|
|
469
|
+
runId,
|
|
470
|
+
threadId,
|
|
471
|
+
resourceId
|
|
459
472
|
});
|
|
460
473
|
const argsForExecute = {
|
|
461
474
|
model,
|
|
@@ -521,6 +534,8 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
521
534
|
temperature,
|
|
522
535
|
toolChoice = "auto",
|
|
523
536
|
telemetry,
|
|
537
|
+
threadId,
|
|
538
|
+
resourceId,
|
|
524
539
|
...rest
|
|
525
540
|
}) {
|
|
526
541
|
const model = this.#model;
|
|
@@ -529,7 +544,9 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
529
544
|
});
|
|
530
545
|
const finalTools = convertedTools || this.convertTools({
|
|
531
546
|
tools,
|
|
532
|
-
runId
|
|
547
|
+
runId,
|
|
548
|
+
threadId,
|
|
549
|
+
resourceId
|
|
533
550
|
});
|
|
534
551
|
const argsForExecute = {
|
|
535
552
|
model,
|
|
@@ -592,18 +609,24 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
592
609
|
toolChoice = "auto",
|
|
593
610
|
experimental_output,
|
|
594
611
|
telemetry,
|
|
612
|
+
threadId,
|
|
613
|
+
resourceId,
|
|
595
614
|
...rest
|
|
596
615
|
}) {
|
|
597
616
|
const model = this.#model;
|
|
598
617
|
this.logger.debug(`[LLM] - Streaming text`, {
|
|
599
618
|
runId,
|
|
619
|
+
threadId,
|
|
620
|
+
resourceId,
|
|
600
621
|
messages,
|
|
601
622
|
maxSteps,
|
|
602
623
|
tools: Object.keys(tools || convertedTools || {})
|
|
603
624
|
});
|
|
604
625
|
const finalTools = convertedTools || this.convertTools({
|
|
605
626
|
tools,
|
|
606
|
-
runId
|
|
627
|
+
runId,
|
|
628
|
+
threadId,
|
|
629
|
+
resourceId
|
|
607
630
|
});
|
|
608
631
|
const argsForExecute = {
|
|
609
632
|
model,
|
|
@@ -638,7 +661,9 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
638
661
|
toolResults: props?.toolResults,
|
|
639
662
|
finishReason: props?.finishReason,
|
|
640
663
|
usage: props?.usage,
|
|
641
|
-
runId
|
|
664
|
+
runId,
|
|
665
|
+
threadId,
|
|
666
|
+
resourceId
|
|
642
667
|
});
|
|
643
668
|
},
|
|
644
669
|
...rest
|
|
@@ -681,6 +706,8 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
681
706
|
temperature,
|
|
682
707
|
toolChoice = "auto",
|
|
683
708
|
telemetry,
|
|
709
|
+
threadId,
|
|
710
|
+
resourceId,
|
|
684
711
|
...rest
|
|
685
712
|
}) {
|
|
686
713
|
const model = this.#model;
|
|
@@ -692,7 +719,9 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
692
719
|
});
|
|
693
720
|
const finalTools = convertedTools || this.convertTools({
|
|
694
721
|
tools,
|
|
695
|
-
runId
|
|
722
|
+
runId,
|
|
723
|
+
threadId,
|
|
724
|
+
resourceId
|
|
696
725
|
});
|
|
697
726
|
const argsForExecute = {
|
|
698
727
|
model,
|
|
@@ -710,7 +739,9 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
710
739
|
toolResults: props?.toolResults,
|
|
711
740
|
finishReason: props?.finishReason,
|
|
712
741
|
usage: props?.usage,
|
|
713
|
-
runId
|
|
742
|
+
runId,
|
|
743
|
+
threadId,
|
|
744
|
+
resourceId
|
|
714
745
|
});
|
|
715
746
|
if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
|
|
716
747
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", {
|
|
@@ -727,7 +758,9 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
727
758
|
toolResults: props?.toolResults,
|
|
728
759
|
finishReason: props?.finishReason,
|
|
729
760
|
usage: props?.usage,
|
|
730
|
-
runId
|
|
761
|
+
runId,
|
|
762
|
+
threadId,
|
|
763
|
+
resourceId
|
|
731
764
|
});
|
|
732
765
|
},
|
|
733
766
|
...rest
|
|
@@ -1300,11 +1333,14 @@ exports.Agent = class Agent extends (_a = MastraBase) {
|
|
|
1300
1333
|
}
|
|
1301
1334
|
convertTools({
|
|
1302
1335
|
toolsets,
|
|
1303
|
-
|
|
1336
|
+
threadId,
|
|
1337
|
+
resourceId,
|
|
1304
1338
|
runId
|
|
1305
1339
|
}) {
|
|
1306
1340
|
this.logger.debug(`[Agents:${this.name}] - Assigning tools`, {
|
|
1307
|
-
runId
|
|
1341
|
+
runId,
|
|
1342
|
+
threadId,
|
|
1343
|
+
resourceId
|
|
1308
1344
|
});
|
|
1309
1345
|
const converted = Object.entries(this.tools || {}).reduce((memo, value) => {
|
|
1310
1346
|
const k = value[0];
|
|
@@ -1319,17 +1355,23 @@ exports.Agent = class Agent extends (_a = MastraBase) {
|
|
|
1319
1355
|
name: k,
|
|
1320
1356
|
description: tool.description,
|
|
1321
1357
|
args,
|
|
1322
|
-
runId
|
|
1358
|
+
runId,
|
|
1359
|
+
threadId,
|
|
1360
|
+
resourceId
|
|
1323
1361
|
});
|
|
1324
1362
|
return tool?.execute?.({
|
|
1325
1363
|
context: args,
|
|
1326
1364
|
mastra: this.#mastra,
|
|
1327
|
-
runId
|
|
1365
|
+
runId,
|
|
1366
|
+
threadId,
|
|
1367
|
+
resourceId
|
|
1328
1368
|
}, options) ?? void 0;
|
|
1329
1369
|
} catch (err) {
|
|
1330
1370
|
this.logger.error(`[Agent:${this.name}] - Failed execution`, {
|
|
1331
1371
|
error: err,
|
|
1332
|
-
runId
|
|
1372
|
+
runId,
|
|
1373
|
+
threadId,
|
|
1374
|
+
resourceId
|
|
1333
1375
|
});
|
|
1334
1376
|
throw err;
|
|
1335
1377
|
}
|
|
@@ -1358,18 +1400,24 @@ exports.Agent = class Agent extends (_a = MastraBase) {
|
|
|
1358
1400
|
name: toolName,
|
|
1359
1401
|
description: toolObj.description,
|
|
1360
1402
|
args,
|
|
1361
|
-
runId
|
|
1403
|
+
runId,
|
|
1404
|
+
threadId,
|
|
1405
|
+
resourceId
|
|
1362
1406
|
});
|
|
1363
1407
|
return toolObj?.execute?.({
|
|
1364
1408
|
context: args,
|
|
1365
|
-
runId
|
|
1409
|
+
runId,
|
|
1410
|
+
threadId,
|
|
1411
|
+
resourceId
|
|
1366
1412
|
}, options) ?? void 0;
|
|
1367
|
-
} catch (
|
|
1413
|
+
} catch (error) {
|
|
1368
1414
|
this.logger.error(`[Agent:${this.name}] - Failed toolset execution`, {
|
|
1369
|
-
error
|
|
1370
|
-
runId
|
|
1415
|
+
error,
|
|
1416
|
+
runId,
|
|
1417
|
+
threadId,
|
|
1418
|
+
resourceId
|
|
1371
1419
|
});
|
|
1372
|
-
throw
|
|
1420
|
+
throw error;
|
|
1373
1421
|
}
|
|
1374
1422
|
} : void 0
|
|
1375
1423
|
};
|
|
@@ -1464,6 +1512,7 @@ exports.Agent = class Agent extends (_a = MastraBase) {
|
|
|
1464
1512
|
convertedTools = this.convertTools({
|
|
1465
1513
|
toolsets,
|
|
1466
1514
|
threadId: threadIdToUse,
|
|
1515
|
+
resourceId,
|
|
1467
1516
|
runId
|
|
1468
1517
|
});
|
|
1469
1518
|
}
|
|
@@ -1600,6 +1649,8 @@ exports.Agent = class Agent extends (_a = MastraBase) {
|
|
|
1600
1649
|
temperature,
|
|
1601
1650
|
toolChoice: toolChoice || "auto",
|
|
1602
1651
|
experimental_output,
|
|
1652
|
+
threadId,
|
|
1653
|
+
resourceId,
|
|
1603
1654
|
...rest
|
|
1604
1655
|
});
|
|
1605
1656
|
const outputText2 = result2.text;
|
|
@@ -1625,6 +1676,8 @@ exports.Agent = class Agent extends (_a = MastraBase) {
|
|
|
1625
1676
|
temperature,
|
|
1626
1677
|
toolChoice,
|
|
1627
1678
|
telemetry,
|
|
1679
|
+
threadId,
|
|
1680
|
+
resourceId,
|
|
1628
1681
|
...rest
|
|
1629
1682
|
});
|
|
1630
1683
|
const outputText2 = result2.text;
|
package/dist/agent/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Message as AiMessageType } from 'ai';
|
|
2
2
|
import 'json-schema';
|
|
3
3
|
import 'zod';
|
|
4
|
-
export { A as Agent, n as AgentConfig, ao as AgentGenerateOptions, ap as AgentStreamOptions, an as ToolsInput, am as ToolsetsInput } from '../base-
|
|
4
|
+
export { A as Agent, n as AgentConfig, ao as AgentGenerateOptions, ap as AgentStreamOptions, an as ToolsInput, am as ToolsetsInput } from '../base-CbCmDLUb.cjs';
|
|
5
5
|
import '../base-hs9NDAZ2.cjs';
|
|
6
6
|
import '../types-m9RryK9a.cjs';
|
|
7
7
|
import '../voice/index.cjs';
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Message as AiMessageType } from 'ai';
|
|
2
2
|
import 'json-schema';
|
|
3
3
|
import 'zod';
|
|
4
|
-
export { A as Agent, n as AgentConfig, ao as AgentGenerateOptions, ap as AgentStreamOptions, an as ToolsInput, am as ToolsetsInput } from '../base-
|
|
4
|
+
export { A as Agent, n as AgentConfig, ao as AgentGenerateOptions, ap as AgentStreamOptions, an as ToolsInput, am as ToolsetsInput } from '../base-DqRXkxCw.js';
|
|
5
5
|
import '../base-D90KQ4XI.js';
|
|
6
6
|
import '../types-m9RryK9a.js';
|
|
7
7
|
import '../voice/index.js';
|
package/dist/agent/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Agent } from '../chunk-
|
|
1
|
+
export { Agent } from '../chunk-E7K35ROR.js';
|
|
@@ -436,6 +436,8 @@ interface IExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefine
|
|
|
436
436
|
context: TSchemaIn extends z.ZodSchema ? z.infer<TSchemaIn> & TContext : TContext;
|
|
437
437
|
runId?: string;
|
|
438
438
|
mastra?: MastraPrimitives;
|
|
439
|
+
threadId?: string;
|
|
440
|
+
resourceId?: string;
|
|
439
441
|
suspend: () => Promise<void>;
|
|
440
442
|
}
|
|
441
443
|
interface IAction<TId extends string, TSchemaIn extends z.ZodSchema | undefined, TSchemaOut extends z.ZodSchema | undefined, TContext extends IExecutionContext<TSchemaIn>, TOptions extends unknown = unknown> {
|
|
@@ -563,6 +565,8 @@ type MastraCustomLLMOptions<Z extends ZodSchema | JSONSchema7 | undefined = unde
|
|
|
563
565
|
onStepFinish?: (step: string) => void;
|
|
564
566
|
experimental_output?: Z;
|
|
565
567
|
telemetry?: TelemetrySettings;
|
|
568
|
+
threadId?: string;
|
|
569
|
+
resourceId?: string;
|
|
566
570
|
} & Run;
|
|
567
571
|
type LLMTextOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
568
572
|
messages: CoreMessage[];
|
|
@@ -647,9 +651,10 @@ declare class Agent<TTools extends Record<string, ToolAction<any, any, any, any>
|
|
|
647
651
|
memoryConfig: MemoryConfig | undefined;
|
|
648
652
|
}): Promise<void>;
|
|
649
653
|
sanitizeResponseMessages(messages: Array<CoreMessage$1>): Array<CoreMessage$1>;
|
|
650
|
-
convertTools({ toolsets, runId, }: {
|
|
654
|
+
convertTools({ toolsets, threadId, resourceId, runId, }: {
|
|
651
655
|
toolsets?: ToolsetsInput;
|
|
652
656
|
threadId?: string;
|
|
657
|
+
resourceId?: string;
|
|
653
658
|
runId?: string;
|
|
654
659
|
}): Record<string, CoreTool>;
|
|
655
660
|
preExecute({ resourceId, runId, threadId, memoryConfig, messages, }: {
|
|
@@ -436,6 +436,8 @@ interface IExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefine
|
|
|
436
436
|
context: TSchemaIn extends z.ZodSchema ? z.infer<TSchemaIn> & TContext : TContext;
|
|
437
437
|
runId?: string;
|
|
438
438
|
mastra?: MastraPrimitives;
|
|
439
|
+
threadId?: string;
|
|
440
|
+
resourceId?: string;
|
|
439
441
|
suspend: () => Promise<void>;
|
|
440
442
|
}
|
|
441
443
|
interface IAction<TId extends string, TSchemaIn extends z.ZodSchema | undefined, TSchemaOut extends z.ZodSchema | undefined, TContext extends IExecutionContext<TSchemaIn>, TOptions extends unknown = unknown> {
|
|
@@ -563,6 +565,8 @@ type MastraCustomLLMOptions<Z extends ZodSchema | JSONSchema7 | undefined = unde
|
|
|
563
565
|
onStepFinish?: (step: string) => void;
|
|
564
566
|
experimental_output?: Z;
|
|
565
567
|
telemetry?: TelemetrySettings;
|
|
568
|
+
threadId?: string;
|
|
569
|
+
resourceId?: string;
|
|
566
570
|
} & Run;
|
|
567
571
|
type LLMTextOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
568
572
|
messages: CoreMessage[];
|
|
@@ -647,9 +651,10 @@ declare class Agent<TTools extends Record<string, ToolAction<any, any, any, any>
|
|
|
647
651
|
memoryConfig: MemoryConfig | undefined;
|
|
648
652
|
}): Promise<void>;
|
|
649
653
|
sanitizeResponseMessages(messages: Array<CoreMessage$1>): Array<CoreMessage$1>;
|
|
650
|
-
convertTools({ toolsets, runId, }: {
|
|
654
|
+
convertTools({ toolsets, threadId, resourceId, runId, }: {
|
|
651
655
|
toolsets?: ToolsetsInput;
|
|
652
656
|
threadId?: string;
|
|
657
|
+
resourceId?: string;
|
|
653
658
|
runId?: string;
|
|
654
659
|
}): Record<string, CoreTool>;
|
|
655
660
|
preExecute({ resourceId, runId, threadId, memoryConfig, messages, }: {
|
|
@@ -136,7 +136,9 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
136
136
|
}
|
|
137
137
|
convertTools({
|
|
138
138
|
tools,
|
|
139
|
-
runId
|
|
139
|
+
runId,
|
|
140
|
+
threadId,
|
|
141
|
+
resourceId
|
|
140
142
|
} = {}) {
|
|
141
143
|
this.logger.debug("Starting tool conversion for LLM");
|
|
142
144
|
const converted = Object.entries(tools || {}).reduce((memo, value) => {
|
|
@@ -154,6 +156,8 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
154
156
|
});
|
|
155
157
|
return tool?.execute?.({
|
|
156
158
|
context: props,
|
|
159
|
+
threadId,
|
|
160
|
+
resourceId,
|
|
157
161
|
mastra: this.#mastra,
|
|
158
162
|
runId
|
|
159
163
|
}, options) ?? void 0;
|
|
@@ -161,7 +165,10 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
161
165
|
this.logger.error("Error executing tool", {
|
|
162
166
|
tool: k,
|
|
163
167
|
props,
|
|
164
|
-
error
|
|
168
|
+
error,
|
|
169
|
+
runId,
|
|
170
|
+
threadId,
|
|
171
|
+
resourceId
|
|
165
172
|
});
|
|
166
173
|
throw error;
|
|
167
174
|
}
|
|
@@ -184,6 +191,8 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
184
191
|
onStepFinish,
|
|
185
192
|
experimental_output,
|
|
186
193
|
telemetry,
|
|
194
|
+
threadId,
|
|
195
|
+
resourceId,
|
|
187
196
|
...rest
|
|
188
197
|
}) {
|
|
189
198
|
const model = this.#model;
|
|
@@ -191,11 +200,15 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
191
200
|
runId,
|
|
192
201
|
messages,
|
|
193
202
|
maxSteps,
|
|
203
|
+
threadId,
|
|
204
|
+
resourceId,
|
|
194
205
|
tools: Object.keys(tools || convertedTools || {})
|
|
195
206
|
});
|
|
196
207
|
const finalTools = convertedTools || this.convertTools({
|
|
197
208
|
tools,
|
|
198
|
-
runId
|
|
209
|
+
runId,
|
|
210
|
+
threadId,
|
|
211
|
+
resourceId
|
|
199
212
|
});
|
|
200
213
|
const argsForExecute = {
|
|
201
214
|
model,
|
|
@@ -261,6 +274,8 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
261
274
|
temperature,
|
|
262
275
|
toolChoice = "auto",
|
|
263
276
|
telemetry,
|
|
277
|
+
threadId,
|
|
278
|
+
resourceId,
|
|
264
279
|
...rest
|
|
265
280
|
}) {
|
|
266
281
|
const model = this.#model;
|
|
@@ -269,7 +284,9 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
269
284
|
});
|
|
270
285
|
const finalTools = convertedTools || this.convertTools({
|
|
271
286
|
tools,
|
|
272
|
-
runId
|
|
287
|
+
runId,
|
|
288
|
+
threadId,
|
|
289
|
+
resourceId
|
|
273
290
|
});
|
|
274
291
|
const argsForExecute = {
|
|
275
292
|
model,
|
|
@@ -332,18 +349,24 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
332
349
|
toolChoice = "auto",
|
|
333
350
|
experimental_output,
|
|
334
351
|
telemetry,
|
|
352
|
+
threadId,
|
|
353
|
+
resourceId,
|
|
335
354
|
...rest
|
|
336
355
|
}) {
|
|
337
356
|
const model = this.#model;
|
|
338
357
|
this.logger.debug(`[LLM] - Streaming text`, {
|
|
339
358
|
runId,
|
|
359
|
+
threadId,
|
|
360
|
+
resourceId,
|
|
340
361
|
messages,
|
|
341
362
|
maxSteps,
|
|
342
363
|
tools: Object.keys(tools || convertedTools || {})
|
|
343
364
|
});
|
|
344
365
|
const finalTools = convertedTools || this.convertTools({
|
|
345
366
|
tools,
|
|
346
|
-
runId
|
|
367
|
+
runId,
|
|
368
|
+
threadId,
|
|
369
|
+
resourceId
|
|
347
370
|
});
|
|
348
371
|
const argsForExecute = {
|
|
349
372
|
model,
|
|
@@ -378,7 +401,9 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
378
401
|
toolResults: props?.toolResults,
|
|
379
402
|
finishReason: props?.finishReason,
|
|
380
403
|
usage: props?.usage,
|
|
381
|
-
runId
|
|
404
|
+
runId,
|
|
405
|
+
threadId,
|
|
406
|
+
resourceId
|
|
382
407
|
});
|
|
383
408
|
},
|
|
384
409
|
...rest
|
|
@@ -421,6 +446,8 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
421
446
|
temperature,
|
|
422
447
|
toolChoice = "auto",
|
|
423
448
|
telemetry,
|
|
449
|
+
threadId,
|
|
450
|
+
resourceId,
|
|
424
451
|
...rest
|
|
425
452
|
}) {
|
|
426
453
|
const model = this.#model;
|
|
@@ -432,7 +459,9 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
432
459
|
});
|
|
433
460
|
const finalTools = convertedTools || this.convertTools({
|
|
434
461
|
tools,
|
|
435
|
-
runId
|
|
462
|
+
runId,
|
|
463
|
+
threadId,
|
|
464
|
+
resourceId
|
|
436
465
|
});
|
|
437
466
|
const argsForExecute = {
|
|
438
467
|
model,
|
|
@@ -450,7 +479,9 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
450
479
|
toolResults: props?.toolResults,
|
|
451
480
|
finishReason: props?.finishReason,
|
|
452
481
|
usage: props?.usage,
|
|
453
|
-
runId
|
|
482
|
+
runId,
|
|
483
|
+
threadId,
|
|
484
|
+
resourceId
|
|
454
485
|
});
|
|
455
486
|
if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
|
|
456
487
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", {
|
|
@@ -467,7 +498,9 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
467
498
|
toolResults: props?.toolResults,
|
|
468
499
|
finishReason: props?.finishReason,
|
|
469
500
|
usage: props?.usage,
|
|
470
|
-
runId
|
|
501
|
+
runId,
|
|
502
|
+
threadId,
|
|
503
|
+
resourceId
|
|
471
504
|
});
|
|
472
505
|
},
|
|
473
506
|
...rest
|
|
@@ -932,11 +965,14 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
932
965
|
}
|
|
933
966
|
convertTools({
|
|
934
967
|
toolsets,
|
|
935
|
-
|
|
968
|
+
threadId,
|
|
969
|
+
resourceId,
|
|
936
970
|
runId
|
|
937
971
|
}) {
|
|
938
972
|
this.logger.debug(`[Agents:${this.name}] - Assigning tools`, {
|
|
939
|
-
runId
|
|
973
|
+
runId,
|
|
974
|
+
threadId,
|
|
975
|
+
resourceId
|
|
940
976
|
});
|
|
941
977
|
const converted = Object.entries(this.tools || {}).reduce((memo, value) => {
|
|
942
978
|
const k = value[0];
|
|
@@ -951,17 +987,23 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
951
987
|
name: k,
|
|
952
988
|
description: tool.description,
|
|
953
989
|
args,
|
|
954
|
-
runId
|
|
990
|
+
runId,
|
|
991
|
+
threadId,
|
|
992
|
+
resourceId
|
|
955
993
|
});
|
|
956
994
|
return tool?.execute?.({
|
|
957
995
|
context: args,
|
|
958
996
|
mastra: this.#mastra,
|
|
959
|
-
runId
|
|
997
|
+
runId,
|
|
998
|
+
threadId,
|
|
999
|
+
resourceId
|
|
960
1000
|
}, options) ?? void 0;
|
|
961
1001
|
} catch (err) {
|
|
962
1002
|
this.logger.error(`[Agent:${this.name}] - Failed execution`, {
|
|
963
1003
|
error: err,
|
|
964
|
-
runId
|
|
1004
|
+
runId,
|
|
1005
|
+
threadId,
|
|
1006
|
+
resourceId
|
|
965
1007
|
});
|
|
966
1008
|
throw err;
|
|
967
1009
|
}
|
|
@@ -990,18 +1032,24 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
990
1032
|
name: toolName,
|
|
991
1033
|
description: toolObj.description,
|
|
992
1034
|
args,
|
|
993
|
-
runId
|
|
1035
|
+
runId,
|
|
1036
|
+
threadId,
|
|
1037
|
+
resourceId
|
|
994
1038
|
});
|
|
995
1039
|
return toolObj?.execute?.({
|
|
996
1040
|
context: args,
|
|
997
|
-
runId
|
|
1041
|
+
runId,
|
|
1042
|
+
threadId,
|
|
1043
|
+
resourceId
|
|
998
1044
|
}, options) ?? void 0;
|
|
999
|
-
} catch (
|
|
1045
|
+
} catch (error) {
|
|
1000
1046
|
this.logger.error(`[Agent:${this.name}] - Failed toolset execution`, {
|
|
1001
|
-
error
|
|
1002
|
-
runId
|
|
1047
|
+
error,
|
|
1048
|
+
runId,
|
|
1049
|
+
threadId,
|
|
1050
|
+
resourceId
|
|
1003
1051
|
});
|
|
1004
|
-
throw
|
|
1052
|
+
throw error;
|
|
1005
1053
|
}
|
|
1006
1054
|
} : void 0
|
|
1007
1055
|
};
|
|
@@ -1096,6 +1144,7 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1096
1144
|
convertedTools = this.convertTools({
|
|
1097
1145
|
toolsets,
|
|
1098
1146
|
threadId: threadIdToUse,
|
|
1147
|
+
resourceId,
|
|
1099
1148
|
runId
|
|
1100
1149
|
});
|
|
1101
1150
|
}
|
|
@@ -1232,6 +1281,8 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1232
1281
|
temperature,
|
|
1233
1282
|
toolChoice: toolChoice || "auto",
|
|
1234
1283
|
experimental_output,
|
|
1284
|
+
threadId,
|
|
1285
|
+
resourceId,
|
|
1235
1286
|
...rest
|
|
1236
1287
|
});
|
|
1237
1288
|
const outputText2 = result2.text;
|
|
@@ -1257,6 +1308,8 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
1257
1308
|
temperature,
|
|
1258
1309
|
toolChoice,
|
|
1259
1310
|
telemetry,
|
|
1311
|
+
threadId,
|
|
1312
|
+
resourceId,
|
|
1260
1313
|
...rest
|
|
1261
1314
|
});
|
|
1262
1315
|
const outputText2 = result2.text;
|
package/dist/eval/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as Metric, T as TestInfo, M as MetricResult } from '../types-m9RryK9a.cjs';
|
|
2
|
-
import { A as Agent } from '../base-
|
|
2
|
+
import { A as Agent } from '../base-CbCmDLUb.cjs';
|
|
3
3
|
import 'ai';
|
|
4
4
|
import '../base-hs9NDAZ2.cjs';
|
|
5
5
|
import '@opentelemetry/api';
|
package/dist/eval/index.d.ts
CHANGED