@mastra/core 0.10.13 → 0.10.14
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/a2a.d.ts +1 -0
- package/agent.d.ts +1 -0
- package/base.d.ts +1 -0
- package/bundler.d.ts +1 -0
- package/deployer.d.ts +1 -0
- package/di.d.ts +1 -0
- package/dist/a2a/index.cjs +79 -0
- package/dist/a2a/index.d.cts +780 -0
- package/dist/a2a/index.d.ts +780 -0
- package/dist/a2a/index.js +68 -0
- package/dist/agent/index.cjs +15 -0
- package/dist/agent/index.d.cts +29 -0
- package/dist/agent/index.d.ts +29 -0
- package/dist/agent/index.js +2 -0
- package/dist/base-B_y9sMg0.d.cts +162 -0
- package/dist/base-CS5eSXbL.d.cts +4117 -0
- package/dist/base-ClrXcCRx.d.ts +162 -0
- package/dist/base-DBhKcre4.d.ts +4117 -0
- package/dist/base.cjs +10 -0
- package/dist/base.d.cts +6 -0
- package/dist/base.d.ts +6 -0
- package/dist/base.js +1 -0
- package/dist/bundler/index.cjs +10 -0
- package/dist/bundler/index.d.cts +30 -0
- package/dist/bundler/index.d.ts +30 -0
- package/dist/bundler/index.js +1 -0
- package/dist/chunk-2GRYVZ2O.cjs +244 -0
- package/dist/chunk-2HDFKWFU.js +2249 -0
- package/dist/chunk-32C7JDIZ.js +1 -0
- package/dist/chunk-4UBOJFSL.js +989 -0
- package/dist/chunk-4UWPFBC6.js +88 -0
- package/dist/chunk-4Z3OU5RY.cjs +31 -0
- package/dist/chunk-5HTMDAXP.js +359 -0
- package/dist/chunk-5IEKR756.js +53 -0
- package/dist/chunk-5YDTZN2X.js +114 -0
- package/dist/chunk-6UNGH46J.js +75 -0
- package/dist/chunk-6Y4UL5Z6.cjs +94 -0
- package/dist/chunk-7F6BQXE2.cjs +425 -0
- package/dist/chunk-7H2GET5Z.cjs +668 -0
- package/dist/chunk-7HZ6NIAF.cjs +2 -0
- package/dist/chunk-7MZNOW6W.cjs +2263 -0
- package/dist/chunk-7XQIPES3.js +668 -0
- package/dist/chunk-AKYTYALY.js +70 -0
- package/dist/chunk-ATXBSEFT.js +22 -0
- package/dist/chunk-B6TOBUS6.cjs +80 -0
- package/dist/chunk-B7SQOKEC.cjs +91 -0
- package/dist/chunk-BB4KXGBU.js +83 -0
- package/dist/chunk-BB6DPGIV.cjs +6 -0
- package/dist/chunk-C4LMN2IR.js +27 -0
- package/dist/chunk-DFFVEKIG.js +407 -0
- package/dist/chunk-E7AX3U6M.cjs +659 -0
- package/dist/chunk-EWCOOO3H.js +5007 -0
- package/dist/chunk-F2WMR75C.cjs +183 -0
- package/dist/chunk-FBKJ3652.cjs +5034 -0
- package/dist/chunk-FEYYOBBG.cjs +24 -0
- package/dist/chunk-FL5SZ2XU.js +181 -0
- package/dist/chunk-GH2KM66J.js +37 -0
- package/dist/chunk-GWFS5DAR.cjs +37 -0
- package/dist/chunk-HNEE7IF4.js +60 -0
- package/dist/chunk-HSVOEWAM.cjs +2 -0
- package/dist/chunk-J52TXHZV.cjs +73 -0
- package/dist/chunk-JNMQKJH4.js +10 -0
- package/dist/chunk-JQOMTERC.js +89 -0
- package/dist/chunk-LABUWBKX.cjs +71 -0
- package/dist/chunk-LXFZUKP3.cjs +34 -0
- package/dist/chunk-MP2QBLUJ.cjs +70 -0
- package/dist/chunk-MUNFCOMB.cjs +62 -0
- package/dist/chunk-NH5WJNNS.js +1 -0
- package/dist/chunk-P3Q73CAW.cjs +55 -0
- package/dist/chunk-PA2YIVIT.js +61 -0
- package/dist/chunk-QFTBW7ZZ.cjs +2 -0
- package/dist/chunk-QQ5K5TZE.cjs +619 -0
- package/dist/chunk-QUSEDVYI.cjs +991 -0
- package/dist/chunk-R4V75T7J.js +1 -0
- package/dist/chunk-SGGPJWRQ.js +69 -0
- package/dist/chunk-ST5RMVLG.cjs +87 -0
- package/dist/chunk-TC2SCOTE.js +605 -0
- package/dist/chunk-U64IJDC5.cjs +109 -0
- package/dist/chunk-UX3B6S2I.cjs +65 -0
- package/dist/chunk-V5D2LIF5.js +68 -0
- package/dist/chunk-VG4OPO2R.js +240 -0
- package/dist/chunk-WQNOATKB.js +103 -0
- package/dist/chunk-Y7D2JLKS.js +4 -0
- package/dist/chunk-YJEHXYK5.js +657 -0
- package/dist/chunk-YOQP5T77.js +32 -0
- package/dist/chunk-ZIZ3CVHN.cjs +120 -0
- package/dist/chunk-ZPOUMTTH.cjs +362 -0
- package/dist/chunk-ZZLBNB3U.cjs +12 -0
- package/dist/deployer/index.cjs +10 -0
- package/dist/deployer/index.d.cts +19 -0
- package/dist/deployer/index.d.ts +19 -0
- package/dist/deployer/index.js +1 -0
- package/dist/di/index.cjs +10 -0
- package/dist/di/index.d.cts +1 -0
- package/dist/di/index.d.ts +1 -0
- package/dist/di/index.js +1 -0
- package/dist/error/index.cjs +22 -0
- package/dist/error/index.d.cts +86 -0
- package/dist/error/index.d.ts +86 -0
- package/dist/error/index.js +1 -0
- package/dist/eval/index.cjs +14 -0
- package/dist/eval/index.d.cts +43 -0
- package/dist/eval/index.d.ts +43 -0
- package/dist/eval/index.js +1 -0
- package/dist/hooks/index.cjs +18 -0
- package/dist/hooks/index.d.cts +33 -0
- package/dist/hooks/index.d.ts +33 -0
- package/dist/hooks/index.js +1 -0
- package/dist/index.cjs +281 -0
- package/dist/index.d.cts +92 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.js +112 -0
- package/dist/integration/index.cjs +14 -0
- package/dist/integration/index.d.cts +65 -0
- package/dist/integration/index.d.ts +65 -0
- package/dist/integration/index.js +1 -0
- package/dist/llm/index.cjs +10 -0
- package/dist/llm/index.d.cts +29 -0
- package/dist/llm/index.d.ts +29 -0
- package/dist/llm/index.js +1 -0
- package/dist/logger/index.cjs +43 -0
- package/dist/logger/index.d.cts +96 -0
- package/dist/logger/index.d.ts +96 -0
- package/dist/logger/index.js +2 -0
- package/dist/logger-B8XXh6ya.d.cts +159 -0
- package/dist/logger-Bpa2oLL4.d.ts +159 -0
- package/dist/mastra/index.cjs +10 -0
- package/dist/mastra/index.d.cts +29 -0
- package/dist/mastra/index.d.ts +29 -0
- package/dist/mastra/index.js +1 -0
- package/dist/mcp/index.cjs +106 -0
- package/dist/mcp/index.d.cts +29 -0
- package/dist/mcp/index.d.ts +29 -0
- package/dist/mcp/index.js +100 -0
- package/dist/memory/index.cjs +18 -0
- package/dist/memory/index.d.cts +29 -0
- package/dist/memory/index.d.ts +29 -0
- package/dist/memory/index.js +1 -0
- package/dist/network/index.cjs +311 -0
- package/dist/network/index.d.cts +29 -0
- package/dist/network/index.d.ts +29 -0
- package/dist/network/index.js +309 -0
- package/dist/network/vNext/index.cjs +873 -0
- package/dist/network/vNext/index.d.cts +29 -0
- package/dist/network/vNext/index.d.ts +29 -0
- package/dist/network/vNext/index.js +871 -0
- package/dist/relevance/index.cjs +18 -0
- package/dist/relevance/index.d.cts +49 -0
- package/dist/relevance/index.d.ts +49 -0
- package/dist/relevance/index.js +1 -0
- package/dist/runtime-context/index.cjs +10 -0
- package/dist/runtime-context/index.d.cts +52 -0
- package/dist/runtime-context/index.d.ts +52 -0
- package/dist/runtime-context/index.js +1 -0
- package/dist/server/index.cjs +62 -0
- package/dist/server/index.d.cts +52 -0
- package/dist/server/index.d.ts +52 -0
- package/dist/server/index.js +59 -0
- package/dist/storage/index.cjs +336 -0
- package/dist/storage/index.d.cts +149 -0
- package/dist/storage/index.d.ts +149 -0
- package/dist/storage/index.js +303 -0
- package/dist/telemetry/index.cjs +30 -0
- package/dist/telemetry/index.d.cts +75 -0
- package/dist/telemetry/index.d.ts +75 -0
- package/dist/telemetry/index.js +1 -0
- package/dist/telemetry/otel-vendor.cjs +103 -0
- package/dist/telemetry/otel-vendor.d.cts +20 -0
- package/dist/telemetry/otel-vendor.d.ts +20 -0
- package/dist/telemetry/otel-vendor.js +57 -0
- package/dist/tools/index.cjs +18 -0
- package/dist/tools/index.d.cts +41 -0
- package/dist/tools/index.d.ts +41 -0
- package/dist/tools/index.js +1 -0
- package/dist/tts/index.cjs +10 -0
- package/dist/tts/index.d.cts +28 -0
- package/dist/tts/index.d.ts +28 -0
- package/dist/tts/index.js +1 -0
- package/dist/types-Bo1uigWx.d.cts +17 -0
- package/dist/types-Bo1uigWx.d.ts +17 -0
- package/dist/utils.cjs +58 -0
- package/dist/utils.d.cts +149 -0
- package/dist/utils.d.ts +149 -0
- package/dist/utils.js +1 -0
- package/dist/vector/filter/index.cjs +192 -0
- package/dist/vector/filter/index.d.cts +128 -0
- package/dist/vector/filter/index.d.ts +128 -0
- package/dist/vector/filter/index.js +190 -0
- package/dist/vector/index.cjs +10 -0
- package/dist/vector/index.d.cts +77 -0
- package/dist/vector/index.d.ts +77 -0
- package/dist/vector/index.js +1 -0
- package/dist/voice/index.cjs +18 -0
- package/dist/voice/index.d.cts +29 -0
- package/dist/voice/index.d.ts +29 -0
- package/dist/voice/index.js +1 -0
- package/dist/workflows/constants.cjs +10 -0
- package/dist/workflows/constants.d.cts +3 -0
- package/dist/workflows/constants.d.ts +3 -0
- package/dist/workflows/constants.js +1 -0
- package/dist/workflows/index.cjs +42 -0
- package/dist/workflows/index.d.cts +282 -0
- package/dist/workflows/index.d.ts +282 -0
- package/dist/workflows/index.js +1 -0
- package/dist/workflows/legacy/index.cjs +90 -0
- package/dist/workflows/legacy/index.d.cts +91 -0
- package/dist/workflows/legacy/index.d.ts +91 -0
- package/dist/workflows/legacy/index.js +1 -0
- package/error.d.ts +1 -0
- package/eval.d.ts +1 -0
- package/hooks.d.ts +1 -0
- package/integration.d.ts +1 -0
- package/llm.d.ts +1 -0
- package/logger.d.ts +1 -0
- package/mastra.d.ts +1 -0
- package/mcp.d.ts +1 -0
- package/memory.d.ts +1 -0
- package/network/vNext.d.ts +1 -0
- package/network.d.ts +1 -0
- package/package.json +1 -1
- package/relevance.d.ts +1 -0
- package/runtime-context.d.ts +1 -0
- package/server.d.ts +1 -0
- package/storage.d.ts +1 -0
- package/telemetry/otel-vendor.d.ts +1 -0
- package/telemetry.d.ts +1 -0
- package/tools.d.ts +1 -0
- package/tts.d.ts +1 -0
- package/utils.d.ts +1 -0
- package/vector/filter.d.ts +1 -0
- package/vector.d.ts +1 -0
- package/voice.d.ts +1 -0
- package/workflows/_constants.d.ts +1 -0
- package/workflows/legacy.d.ts +1 -0
- package/workflows.d.ts +1 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { executeHook } from './chunk-BB4KXGBU.js';
|
|
2
|
+
import { MastraError } from './chunk-6UNGH46J.js';
|
|
3
|
+
|
|
4
|
+
// src/eval/metric.ts
|
|
5
|
+
var Metric = class {
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// src/eval/evaluation.ts
|
|
9
|
+
async function evaluate({
|
|
10
|
+
agentName,
|
|
11
|
+
input,
|
|
12
|
+
metric,
|
|
13
|
+
output,
|
|
14
|
+
runId,
|
|
15
|
+
globalRunId,
|
|
16
|
+
testInfo,
|
|
17
|
+
instructions
|
|
18
|
+
}) {
|
|
19
|
+
const runIdToUse = runId || crypto.randomUUID();
|
|
20
|
+
let metricResult;
|
|
21
|
+
let metricName = metric.constructor.name;
|
|
22
|
+
try {
|
|
23
|
+
metricResult = await metric.measure(input.toString(), output);
|
|
24
|
+
} catch (e) {
|
|
25
|
+
throw new MastraError(
|
|
26
|
+
{
|
|
27
|
+
id: "EVAL_METRIC_MEASURE_EXECUTION_FAILED",
|
|
28
|
+
domain: "EVAL" /* EVAL */,
|
|
29
|
+
category: "USER" /* USER */,
|
|
30
|
+
details: {
|
|
31
|
+
agentName,
|
|
32
|
+
metricName,
|
|
33
|
+
globalRunId
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
e
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
const traceObject = {
|
|
40
|
+
input: input.toString(),
|
|
41
|
+
output,
|
|
42
|
+
result: metricResult,
|
|
43
|
+
agentName,
|
|
44
|
+
metricName,
|
|
45
|
+
instructions,
|
|
46
|
+
globalRunId,
|
|
47
|
+
runId: runIdToUse,
|
|
48
|
+
testInfo
|
|
49
|
+
};
|
|
50
|
+
try {
|
|
51
|
+
executeHook("onEvaluation" /* ON_EVALUATION */, traceObject);
|
|
52
|
+
} catch (e) {
|
|
53
|
+
throw new MastraError(
|
|
54
|
+
{
|
|
55
|
+
id: "EVAL_HOOK_EXECUTION_FAILED",
|
|
56
|
+
domain: "EVAL" /* EVAL */,
|
|
57
|
+
category: "USER" /* USER */,
|
|
58
|
+
details: {
|
|
59
|
+
agentName,
|
|
60
|
+
metricName,
|
|
61
|
+
globalRunId
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
e
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return { ...metricResult, output };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { Metric, evaluate };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MastraBase } from './chunk-5IEKR756.js';
|
|
2
|
+
import { readFile } from 'fs/promises';
|
|
3
|
+
import { parse } from 'dotenv';
|
|
4
|
+
|
|
5
|
+
var MastraBundler = class extends MastraBase {
|
|
6
|
+
constructor({ name, component = "BUNDLER" }) {
|
|
7
|
+
super({ component, name });
|
|
8
|
+
}
|
|
9
|
+
async loadEnvVars() {
|
|
10
|
+
const envVars = /* @__PURE__ */ new Map();
|
|
11
|
+
for (const file of await this.getEnvFiles()) {
|
|
12
|
+
const content = await readFile(file, "utf-8");
|
|
13
|
+
const config = parse(content);
|
|
14
|
+
Object.entries(config).forEach(([key, value]) => {
|
|
15
|
+
envVars.set(key, value);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return envVars;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { MastraBundler };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/error/index.ts
|
|
4
|
+
var ErrorDomain = /* @__PURE__ */ ((ErrorDomain2) => {
|
|
5
|
+
ErrorDomain2["TOOL"] = "TOOL";
|
|
6
|
+
ErrorDomain2["AGENT"] = "AGENT";
|
|
7
|
+
ErrorDomain2["MCP"] = "MCP";
|
|
8
|
+
ErrorDomain2["AGENT_NETWORK"] = "AGENT_NETWORK";
|
|
9
|
+
ErrorDomain2["MASTRA_SERVER"] = "MASTRA_SERVER";
|
|
10
|
+
ErrorDomain2["MASTRA_TELEMETRY"] = "MASTRA_TELEMETRY";
|
|
11
|
+
ErrorDomain2["MASTRA_WORKFLOW"] = "MASTRA_WORKFLOW";
|
|
12
|
+
ErrorDomain2["MASTRA_VOICE"] = "MASTRA_VOICE";
|
|
13
|
+
ErrorDomain2["MASTRA_VECTOR"] = "MASTRA_VECTOR";
|
|
14
|
+
ErrorDomain2["LLM"] = "LLM";
|
|
15
|
+
ErrorDomain2["EVAL"] = "EVAL";
|
|
16
|
+
ErrorDomain2["A2A"] = "A2A";
|
|
17
|
+
ErrorDomain2["MASTRA_INSTANCE"] = "MASTRA_INSTANCE";
|
|
18
|
+
ErrorDomain2["MASTRA"] = "MASTRA";
|
|
19
|
+
ErrorDomain2["DEPLOYER"] = "DEPLOYER";
|
|
20
|
+
ErrorDomain2["STORAGE"] = "STORAGE";
|
|
21
|
+
return ErrorDomain2;
|
|
22
|
+
})(ErrorDomain || {});
|
|
23
|
+
var ErrorCategory = /* @__PURE__ */ ((ErrorCategory2) => {
|
|
24
|
+
ErrorCategory2["UNKNOWN"] = "UNKNOWN";
|
|
25
|
+
ErrorCategory2["USER"] = "USER";
|
|
26
|
+
ErrorCategory2["SYSTEM"] = "SYSTEM";
|
|
27
|
+
ErrorCategory2["THIRD_PARTY"] = "THIRD_PARTY";
|
|
28
|
+
return ErrorCategory2;
|
|
29
|
+
})(ErrorCategory || {});
|
|
30
|
+
var MastraBaseError = class extends Error {
|
|
31
|
+
id;
|
|
32
|
+
domain;
|
|
33
|
+
category;
|
|
34
|
+
details = {};
|
|
35
|
+
message;
|
|
36
|
+
constructor(errorDefinition, originalError) {
|
|
37
|
+
let error;
|
|
38
|
+
if (originalError instanceof Error) {
|
|
39
|
+
error = originalError;
|
|
40
|
+
} else if (originalError) {
|
|
41
|
+
error = new Error(String(originalError));
|
|
42
|
+
}
|
|
43
|
+
const message = errorDefinition.text ?? error?.message ?? "Unknown error";
|
|
44
|
+
super(message, { cause: error });
|
|
45
|
+
this.id = errorDefinition.id;
|
|
46
|
+
this.domain = errorDefinition.domain;
|
|
47
|
+
this.category = errorDefinition.category;
|
|
48
|
+
this.details = errorDefinition.details ?? {};
|
|
49
|
+
this.message = message;
|
|
50
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Returns a structured representation of the error, useful for logging or API responses.
|
|
54
|
+
*/
|
|
55
|
+
toJSONDetails() {
|
|
56
|
+
return {
|
|
57
|
+
message: this.message,
|
|
58
|
+
domain: this.domain,
|
|
59
|
+
category: this.category,
|
|
60
|
+
details: this.details
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
toJSON() {
|
|
64
|
+
return {
|
|
65
|
+
message: this.message,
|
|
66
|
+
details: this.toJSONDetails(),
|
|
67
|
+
code: this.id
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
toString() {
|
|
71
|
+
return JSON.stringify(this.toJSON());
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var MastraError = class extends MastraBaseError {
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
exports.ErrorCategory = ErrorCategory;
|
|
78
|
+
exports.ErrorDomain = ErrorDomain;
|
|
79
|
+
exports.MastraBaseError = MastraBaseError;
|
|
80
|
+
exports.MastraError = MastraError;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk4Z3OU5RY_cjs = require('./chunk-4Z3OU5RY.cjs');
|
|
4
|
+
var zod = require('zod');
|
|
5
|
+
|
|
6
|
+
// src/integration/integration.ts
|
|
7
|
+
var Integration = class {
|
|
8
|
+
name = "Integration";
|
|
9
|
+
workflows;
|
|
10
|
+
constructor() {
|
|
11
|
+
this.workflows = {};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Workflows
|
|
15
|
+
*/
|
|
16
|
+
registerWorkflow(name, fn) {
|
|
17
|
+
if (this.workflows[name]) {
|
|
18
|
+
throw new Error(`Sync function "${name}" already registered`);
|
|
19
|
+
}
|
|
20
|
+
this.workflows[name] = fn;
|
|
21
|
+
}
|
|
22
|
+
getWorkflows({ serialized }) {
|
|
23
|
+
if (serialized) {
|
|
24
|
+
return Object.entries(this.workflows).reduce((acc, [k, v]) => {
|
|
25
|
+
return {
|
|
26
|
+
...acc,
|
|
27
|
+
[k]: {
|
|
28
|
+
name: v.name
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}, {});
|
|
32
|
+
}
|
|
33
|
+
return this.workflows;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* TOOLS
|
|
37
|
+
*/
|
|
38
|
+
getStaticTools(_params) {
|
|
39
|
+
throw new Error("Method not implemented.");
|
|
40
|
+
}
|
|
41
|
+
async getTools(_params) {
|
|
42
|
+
throw new Error("Method not implemented.");
|
|
43
|
+
}
|
|
44
|
+
async getApiClient() {
|
|
45
|
+
throw new Error("Method not implemented");
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var OpenAPIToolset = class {
|
|
49
|
+
authType = "API_KEY";
|
|
50
|
+
constructor() {
|
|
51
|
+
}
|
|
52
|
+
get toolSchemas() {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
get toolDocumentations() {
|
|
56
|
+
return {};
|
|
57
|
+
}
|
|
58
|
+
get baseClient() {
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
async getApiClient() {
|
|
62
|
+
throw new Error("API not implemented");
|
|
63
|
+
}
|
|
64
|
+
_generateIntegrationTools() {
|
|
65
|
+
const { client: _client, ...clientMethods } = this.baseClient;
|
|
66
|
+
const schemas = this.toolSchemas;
|
|
67
|
+
const documentations = this.toolDocumentations;
|
|
68
|
+
const tools = Object.keys(clientMethods).reduce((acc, key) => {
|
|
69
|
+
const comment = documentations[key]?.comment;
|
|
70
|
+
const fallbackComment = `Execute ${key}`;
|
|
71
|
+
const tool = chunk4Z3OU5RY_cjs.createTool({
|
|
72
|
+
id: key,
|
|
73
|
+
inputSchema: schemas[key] || zod.z.object({}),
|
|
74
|
+
description: comment || fallbackComment,
|
|
75
|
+
// documentation: doc || fallbackComment,
|
|
76
|
+
execute: async ({ context }) => {
|
|
77
|
+
const client = await this.getApiClient();
|
|
78
|
+
const value = client[key];
|
|
79
|
+
return value({
|
|
80
|
+
...context
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return { ...acc, [key]: tool };
|
|
85
|
+
}, {});
|
|
86
|
+
return tools;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
exports.Integration = Integration;
|
|
91
|
+
exports.OpenAPIToolset = OpenAPIToolset;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// src/hooks/mitt.ts
|
|
2
|
+
function mitt(all) {
|
|
3
|
+
all = all || /* @__PURE__ */ new Map();
|
|
4
|
+
return {
|
|
5
|
+
/**
|
|
6
|
+
* A Map of event names to registered handler functions.
|
|
7
|
+
*/
|
|
8
|
+
all,
|
|
9
|
+
/**
|
|
10
|
+
* Register an event handler for the given type.
|
|
11
|
+
* @param {string|symbol} type Type of event to listen for, or `'*'` for all events
|
|
12
|
+
* @param {Function} handler Function to call in response to given event
|
|
13
|
+
* @memberOf mitt
|
|
14
|
+
*/
|
|
15
|
+
on(type, handler) {
|
|
16
|
+
const handlers = all.get(type);
|
|
17
|
+
if (handlers) {
|
|
18
|
+
handlers.push(handler);
|
|
19
|
+
} else {
|
|
20
|
+
all.set(type, [handler]);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Remove an event handler for the given type.
|
|
25
|
+
* If `handler` is omitted, all handlers of the given type are removed.
|
|
26
|
+
* @param {string|symbol} type Type of event to unregister `handler` from (`'*'` to remove a wildcard handler)
|
|
27
|
+
* @param {Function} [handler] Handler function to remove
|
|
28
|
+
* @memberOf mitt
|
|
29
|
+
*/
|
|
30
|
+
off(type, handler) {
|
|
31
|
+
const handlers = all.get(type);
|
|
32
|
+
if (handlers) {
|
|
33
|
+
if (handler) {
|
|
34
|
+
handlers.splice(handlers.indexOf(handler) >>> 0, 1);
|
|
35
|
+
} else {
|
|
36
|
+
all.set(type, []);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* Invoke all handlers for the given type.
|
|
42
|
+
* If present, `'*'` handlers are invoked after type-matched handlers.
|
|
43
|
+
*
|
|
44
|
+
* Note: Manually firing '*' handlers is not supported.
|
|
45
|
+
*
|
|
46
|
+
* @param {string|symbol} type The event type to invoke
|
|
47
|
+
* @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
|
|
48
|
+
* @memberOf mitt
|
|
49
|
+
*/
|
|
50
|
+
emit(type, evt) {
|
|
51
|
+
let handlers = all.get(type);
|
|
52
|
+
if (handlers) {
|
|
53
|
+
handlers.slice().map((handler) => {
|
|
54
|
+
handler(evt);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
handlers = all.get("*");
|
|
58
|
+
if (handlers) {
|
|
59
|
+
handlers.slice().map((handler) => {
|
|
60
|
+
handler(type, evt);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/hooks/index.ts
|
|
68
|
+
var AvailableHooks = /* @__PURE__ */ ((AvailableHooks2) => {
|
|
69
|
+
AvailableHooks2["ON_EVALUATION"] = "onEvaluation";
|
|
70
|
+
AvailableHooks2["ON_GENERATION"] = "onGeneration";
|
|
71
|
+
return AvailableHooks2;
|
|
72
|
+
})(AvailableHooks || {});
|
|
73
|
+
var hooks = mitt();
|
|
74
|
+
function registerHook(hook, action) {
|
|
75
|
+
hooks.on(hook, action);
|
|
76
|
+
}
|
|
77
|
+
function executeHook(hook, data) {
|
|
78
|
+
setImmediate(() => {
|
|
79
|
+
hooks.emit(hook, data);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { AvailableHooks, executeHook, registerHook };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/tools/tool.ts
|
|
2
|
+
var Tool = class {
|
|
3
|
+
id;
|
|
4
|
+
description;
|
|
5
|
+
inputSchema;
|
|
6
|
+
outputSchema;
|
|
7
|
+
execute;
|
|
8
|
+
mastra;
|
|
9
|
+
constructor(opts) {
|
|
10
|
+
this.id = opts.id;
|
|
11
|
+
this.description = opts.description;
|
|
12
|
+
this.inputSchema = opts.inputSchema;
|
|
13
|
+
this.outputSchema = opts.outputSchema;
|
|
14
|
+
this.execute = opts.execute;
|
|
15
|
+
this.mastra = opts.mastra;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
function createTool(opts) {
|
|
19
|
+
return new Tool(opts);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// src/tools/toolchecks.ts
|
|
23
|
+
function isVercelTool(tool) {
|
|
24
|
+
return !!(tool && !(tool instanceof Tool) && "parameters" in tool);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { Tool, createTool, isVercelTool };
|