@mastra/core 0.2.0 → 0.2.1-alpha.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/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +1 -15
- package/dist/{base-Bpb7Dmwe.d.ts → base-C7R9FwZ6.d.ts} +7 -7
- package/dist/base.js +0 -2
- package/dist/bundler/index.js +0 -3
- package/dist/{chunk-FGZVE4CM.js → chunk-4ZRHVG25.js} +2 -4
- package/dist/chunk-55GTEVHJ.js +1 -1
- package/dist/{chunk-U6J2FOU4.js → chunk-5HXXWLRX.js} +103 -101
- package/dist/{chunk-SB37QG7O.js → chunk-6TCTOQ3G.js} +38 -37
- package/dist/{chunk-OJ26F3J4.js → chunk-AN562ICT.js} +2 -0
- package/dist/chunk-AWEACB2T.js +1 -1
- package/dist/{chunk-MLWGYRJR.js → chunk-BB4KXGBU.js} +1 -5
- package/dist/chunk-C6A6W6XS.js +48 -20
- package/dist/{chunk-K4DFI76V.js → chunk-CUIUUULJ.js} +313 -204
- package/dist/{chunk-SDBM53G4.js → chunk-HT63PEVD.js} +10 -5
- package/dist/{chunk-VB7CO5ND.js → chunk-NUDAZEOG.js} +6 -2
- package/dist/{chunk-MEISIZMP.js → chunk-PNZK456O.js} +1 -1
- package/dist/chunk-SIFBBGY6.js +2 -2
- package/dist/{chunk-2JL6DQMZ.js → chunk-V4WSAQOP.js} +14 -14
- package/dist/{chunk-65VPTVVP.js → chunk-V5UMPUKC.js} +2 -2
- package/dist/{chunk-J3W3IHDO.js → chunk-VE4JJJSW.js} +43 -21
- package/dist/{chunk-3HBFW3Q7.js → chunk-ZINPRHAN.js} +0 -2
- package/dist/chunk-ZJOXJFJI.js +1 -2
- package/dist/deployer/index.d.ts +1 -1
- package/dist/deployer/index.js +0 -4
- package/dist/eval/index.d.ts +1 -1
- package/dist/eval/index.js +1 -3
- package/dist/filter/index.js +0 -1
- package/dist/hooks/index.js +1 -2
- package/dist/index.d.ts +5 -5
- package/dist/index.js +18 -22
- package/dist/integration/index.d.ts +2 -2
- package/dist/integration/index.js +1 -6
- package/dist/llm/index.d.ts +1 -1
- package/dist/llm/index.js +1 -1
- package/dist/logger/index.js +0 -1
- package/dist/mastra/index.d.ts +15 -14
- package/dist/mastra/index.js +1 -20
- package/dist/memory/index.d.ts +1 -1
- package/dist/memory/index.js +1 -11
- package/dist/relevance/index.js +1 -16
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.js +2 -7
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.js +1 -3
- package/dist/telemetry/otel-vendor.js +0 -1
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.js +1 -2
- package/dist/tts/index.js +1 -6
- package/dist/utils.js +0 -1
- package/dist/vector/index.d.ts +1 -1
- package/dist/vector/index.js +0 -3
- package/dist/vector/libsql/index.js +1 -6
- package/dist/{workflow-Cy8UTGCt.d.ts → workflow-7xHmmFH5.d.ts} +1 -1
- package/dist/workflows/index.d.ts +3 -3
- package/dist/workflows/index.js +1 -4
- package/package.json +10 -10
- package/dist/chunk-2SAHBQEF.js +0 -3
- /package/dist/{chunk-VDOJTUYY.js → chunk-ZDWFBE5L.js} +0 -0
package/dist/agent/index.d.ts
CHANGED
package/dist/agent/index.js
CHANGED
|
@@ -1,15 +1 @@
|
|
|
1
|
-
export { Agent } from '../chunk-
|
|
2
|
-
import '../chunk-FGZVE4CM.js';
|
|
3
|
-
import '../chunk-2SAHBQEF.js';
|
|
4
|
-
import '../chunk-65VPTVVP.js';
|
|
5
|
-
import '../chunk-U6J2FOU4.js';
|
|
6
|
-
import '../chunk-RG66XEJT.js';
|
|
7
|
-
import '../chunk-OJ26F3J4.js';
|
|
8
|
-
import '../chunk-ZJOXJFJI.js';
|
|
9
|
-
import '../chunk-55GTEVHJ.js';
|
|
10
|
-
import '../chunk-AWEACB2T.js';
|
|
11
|
-
import '../chunk-O2VP5JBC.js';
|
|
12
|
-
import '../chunk-VB7CO5ND.js';
|
|
13
|
-
import '../chunk-MLWGYRJR.js';
|
|
14
|
-
import '../chunk-SIFBBGY6.js';
|
|
15
|
-
import '../chunk-C6A6W6XS.js';
|
|
1
|
+
export { Agent } from '../chunk-CUIUUULJ.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
|
-
import { EmbeddingModel, CoreMessage as CoreMessage$1, Message, UserContent, AssistantContent, LanguageModelV1, CoreSystemMessage as CoreSystemMessage$1, CoreAssistantMessage as CoreAssistantMessage$1, CoreUserMessage as CoreUserMessage$1, CoreToolMessage as CoreToolMessage$1, EmbedResult as EmbedResult$1, EmbedManyResult as EmbedManyResult$1,
|
|
2
|
+
import { EmbeddingModel, CoreMessage as CoreMessage$1, Message, UserContent, AssistantContent, LanguageModelV1, GenerateTextResult, GenerateObjectResult, StreamTextResult, StreamObjectResult, CoreSystemMessage as CoreSystemMessage$1, CoreAssistantMessage as CoreAssistantMessage$1, CoreUserMessage as CoreUserMessage$1, CoreToolMessage as CoreToolMessage$1, EmbedResult as EmbedResult$1, EmbedManyResult as EmbedManyResult$1, LanguageModel as LanguageModel$1, DeepPartial, ToolContent } from 'ai';
|
|
3
3
|
import { M as MastraBase, T as Telemetry } from './base-BbtPAA6f.js';
|
|
4
4
|
import { a as Metric, M as MetricResult, T as TestInfo } from './types-m9RryK9a.js';
|
|
5
5
|
import { Query } from 'sift';
|
|
@@ -481,8 +481,8 @@ interface AgentStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = und
|
|
|
481
481
|
threadId?: string;
|
|
482
482
|
memoryOptions?: MemoryConfig;
|
|
483
483
|
runId?: string;
|
|
484
|
-
onFinish?: (result: string) =>
|
|
485
|
-
onStepFinish?: (step: string) =>
|
|
484
|
+
onFinish?: (result: string) => unknown;
|
|
485
|
+
onStepFinish?: (step: string) => unknown;
|
|
486
486
|
maxSteps?: number;
|
|
487
487
|
output?: OutputType | Z;
|
|
488
488
|
temperature?: number;
|
|
@@ -545,8 +545,8 @@ type LLMInnerStreamOptions = {
|
|
|
545
545
|
tools?: ToolsInput;
|
|
546
546
|
convertedTools?: Record<string, CoreTool>;
|
|
547
547
|
messages: CoreMessage[];
|
|
548
|
-
onStepFinish?: (step: string) =>
|
|
549
|
-
onFinish?: (result: string) =>
|
|
548
|
+
onStepFinish?: (step: string) => unknown;
|
|
549
|
+
onFinish?: (result: string) => unknown;
|
|
550
550
|
maxSteps?: number;
|
|
551
551
|
temperature?: number;
|
|
552
552
|
toolChoice?: 'auto' | 'required';
|
|
@@ -764,7 +764,7 @@ declare abstract class MastraStorage extends MastraBase {
|
|
|
764
764
|
static readonly TABLE_THREADS = "mastra_threads";
|
|
765
765
|
/** @deprecated import { TABLE_TRACES } from '@mastra/core/storage' instead */
|
|
766
766
|
static readonly TABLE_TRACES = "mastra_traces";
|
|
767
|
-
|
|
767
|
+
protected hasInitialized: null | Promise<boolean>;
|
|
768
768
|
constructor({ name }: {
|
|
769
769
|
name: string;
|
|
770
770
|
});
|
|
@@ -860,4 +860,4 @@ declare abstract class MastraStorage extends MastraBase {
|
|
|
860
860
|
__getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
861
861
|
}
|
|
862
862
|
|
|
863
|
-
export { type WorkflowContext as $, Agent as A, type BaseStructuredOutputType as B, type CoreMessage as C, type LLMInnerStreamOptions as D, type EvalRow as E, type LLMStreamObjectOptions as F, type GenerateReturn as G, type MessageType as H, type IAction as I, type StorageThreadType as J, type MessageResponse as K, type LanguageModel as L,
|
|
863
|
+
export { type WorkflowContext as $, Agent as A, type BaseStructuredOutputType as B, type CoreMessage as C, type LLMInnerStreamOptions as D, type EvalRow as E, type LLMStreamObjectOptions as F, type GenerateReturn as G, type MessageType as H, type IAction as I, type StorageThreadType as J, type MessageResponse as K, type LanguageModel as L, MastraMemory as M, type MemoryConfig as N, type OutputType as O, type SharedMemoryConfig as P, type CoreTool as Q, type RetryConfig as R, type StepExecutionContext as S, type ToolAction as T, type StepNode as U, type VariableReference as V, type WorkflowOptions as W, type BaseCondition as X, type ActionContext as Y, type StepDef as Z, type StepCondition as _, MastraStorage as a, type WorkflowLogMessage as a0, type WorkflowEvent as a1, type ResolverFunctionInput as a2, type ResolverFunctionOutput as a3, type SubscriberFunctionOutput as a4, type DependencyCheckOutput as a5, type WorkflowActors as a6, type WorkflowActionParams as a7, type WorkflowActions as a8, type WorkflowState as a9, type StepId as aa, type ExtractSchemaFromStep as ab, type ExtractStepResult as ac, type StepInputType as ad, type ExtractSchemaType as ae, type PathsToStringProps as af, type TABLE_NAMES as ag, TABLE_WORKFLOW_SNAPSHOT as ah, TABLE_EVALS as ai, TABLE_MESSAGES as aj, TABLE_THREADS as ak, TABLE_TRACES as al, type StepAction as b, type MastraPrimitives as c, type StepVariableType as d, type StepConfig as e, type StepResult as f, type WorkflowRunState as g, type StepGraph as h, type AgentConfig as i, type ToolExecutionContext as j, type StorageColumn as k, type WorkflowRow as l, type StorageGetMessagesArg as m, type CoreSystemMessage as n, type CoreAssistantMessage as o, type CoreUserMessage as p, type CoreToolMessage as q, type EmbedResult as r, type EmbedManyResult as s, type StructuredOutputType as t, type StructuredOutputArrayItem as u, type StructuredOutput as v, type StreamReturn as w, type LLMStreamOptions as x, type LLMTextOptions as y, type LLMTextObjectOptions as z };
|
package/dist/base.js
CHANGED
package/dist/bundler/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import { TABLE_TRACES } from './chunk-RG66XEJT.js';
|
|
|
2
2
|
import { trace, context, propagation, SpanStatusCode, SpanKind } from '@opentelemetry/api';
|
|
3
3
|
import { ExportResultCode } from '@opentelemetry/core';
|
|
4
4
|
import { JsonTraceSerializer } from '@opentelemetry/otlp-transformer';
|
|
5
|
-
import '@opentelemetry/sdk-trace-base';
|
|
6
5
|
|
|
7
6
|
function hasActiveTelemetry(tracerName = "default-tracer") {
|
|
8
7
|
try {
|
|
@@ -116,7 +115,7 @@ var OTLPTraceExporter = class {
|
|
|
116
115
|
queue = [];
|
|
117
116
|
serializer;
|
|
118
117
|
logger;
|
|
119
|
-
activeFlush =
|
|
118
|
+
activeFlush = void 0;
|
|
120
119
|
constructor({ logger, storage }) {
|
|
121
120
|
this.storage = storage;
|
|
122
121
|
this.serializer = JsonTraceSerializer;
|
|
@@ -199,7 +198,7 @@ var OTLPTraceExporter = class {
|
|
|
199
198
|
error: e
|
|
200
199
|
});
|
|
201
200
|
}).finally(() => {
|
|
202
|
-
this.activeFlush =
|
|
201
|
+
this.activeFlush = void 0;
|
|
203
202
|
});
|
|
204
203
|
}
|
|
205
204
|
async forceFlush() {
|
|
@@ -316,7 +315,6 @@ var Telemetry = class _Telemetry {
|
|
|
316
315
|
span.end();
|
|
317
316
|
return res;
|
|
318
317
|
};
|
|
319
|
-
var recordResult = recordResult2;
|
|
320
318
|
if (context3.attributes) {
|
|
321
319
|
span.setAttributes(context3.attributes);
|
|
322
320
|
}
|
package/dist/chunk-55GTEVHJ.js
CHANGED
|
@@ -90,7 +90,7 @@ function deepMerge(target, source) {
|
|
|
90
90
|
output[key] = sourceValue;
|
|
91
91
|
} else if (sourceValue instanceof Object && targetValue instanceof Object && !Array.isArray(sourceValue) && !Array.isArray(targetValue)) {
|
|
92
92
|
output[key] = deepMerge(targetValue, sourceValue);
|
|
93
|
-
} else if (sourceValue !==
|
|
93
|
+
} else if (sourceValue !== void 0) {
|
|
94
94
|
output[key] = sourceValue;
|
|
95
95
|
}
|
|
96
96
|
});
|
|
@@ -15,7 +15,7 @@ var MastraStorage = class extends MastraBase {
|
|
|
15
15
|
static TABLE_THREADS = TABLE_THREADS;
|
|
16
16
|
/** @deprecated import { TABLE_TRACES } from '@mastra/core/storage' instead */
|
|
17
17
|
static TABLE_TRACES = TABLE_TRACES;
|
|
18
|
-
|
|
18
|
+
hasInitialized = null;
|
|
19
19
|
constructor({ name }) {
|
|
20
20
|
super({
|
|
21
21
|
component: "STORAGE",
|
|
@@ -71,107 +71,109 @@ var MastraStorage = class extends MastraBase {
|
|
|
71
71
|
return this.getTraces({ scope, page, perPage, attributes });
|
|
72
72
|
}
|
|
73
73
|
async init() {
|
|
74
|
-
if (this.
|
|
74
|
+
if (await this.hasInitialized) {
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
77
|
+
this.hasInitialized = Promise.all([
|
|
78
|
+
this.createTable({
|
|
79
|
+
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
80
|
+
schema: {
|
|
81
|
+
workflow_name: {
|
|
82
|
+
type: "text"
|
|
83
|
+
},
|
|
84
|
+
run_id: {
|
|
85
|
+
type: "text"
|
|
86
|
+
},
|
|
87
|
+
snapshot: {
|
|
88
|
+
type: "text"
|
|
89
|
+
},
|
|
90
|
+
createdAt: {
|
|
91
|
+
type: "timestamp"
|
|
92
|
+
},
|
|
93
|
+
updatedAt: {
|
|
94
|
+
type: "timestamp"
|
|
95
|
+
}
|
|
94
96
|
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
97
|
+
}),
|
|
98
|
+
this.createTable({
|
|
99
|
+
tableName: TABLE_EVALS,
|
|
100
|
+
schema: {
|
|
101
|
+
input: {
|
|
102
|
+
type: "text"
|
|
103
|
+
},
|
|
104
|
+
output: {
|
|
105
|
+
type: "text"
|
|
106
|
+
},
|
|
107
|
+
result: {
|
|
108
|
+
type: "jsonb"
|
|
109
|
+
},
|
|
110
|
+
agent_name: {
|
|
111
|
+
type: "text"
|
|
112
|
+
},
|
|
113
|
+
metric_name: {
|
|
114
|
+
type: "text"
|
|
115
|
+
},
|
|
116
|
+
instructions: {
|
|
117
|
+
type: "text"
|
|
118
|
+
},
|
|
119
|
+
test_info: {
|
|
120
|
+
type: "jsonb",
|
|
121
|
+
nullable: true
|
|
122
|
+
},
|
|
123
|
+
global_run_id: {
|
|
124
|
+
type: "text"
|
|
125
|
+
},
|
|
126
|
+
run_id: {
|
|
127
|
+
type: "text"
|
|
128
|
+
},
|
|
129
|
+
created_at: {
|
|
130
|
+
type: "timestamp"
|
|
131
|
+
}
|
|
130
132
|
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
this.
|
|
133
|
+
}),
|
|
134
|
+
this.createTable({
|
|
135
|
+
tableName: TABLE_THREADS,
|
|
136
|
+
schema: {
|
|
137
|
+
id: { type: "text", nullable: false, primaryKey: true },
|
|
138
|
+
resourceId: { type: "text", nullable: false },
|
|
139
|
+
title: { type: "text", nullable: false },
|
|
140
|
+
metadata: { type: "text", nullable: true },
|
|
141
|
+
createdAt: { type: "timestamp", nullable: false },
|
|
142
|
+
updatedAt: { type: "timestamp", nullable: false }
|
|
143
|
+
}
|
|
144
|
+
}),
|
|
145
|
+
this.createTable({
|
|
146
|
+
tableName: TABLE_MESSAGES,
|
|
147
|
+
schema: {
|
|
148
|
+
id: { type: "text", nullable: false, primaryKey: true },
|
|
149
|
+
thread_id: { type: "text", nullable: false },
|
|
150
|
+
content: { type: "text", nullable: false },
|
|
151
|
+
role: { type: "text", nullable: false },
|
|
152
|
+
type: { type: "text", nullable: false },
|
|
153
|
+
createdAt: { type: "timestamp", nullable: false }
|
|
154
|
+
}
|
|
155
|
+
}),
|
|
156
|
+
this.createTable({
|
|
157
|
+
tableName: TABLE_TRACES,
|
|
158
|
+
schema: {
|
|
159
|
+
id: { type: "text", nullable: false, primaryKey: true },
|
|
160
|
+
parentSpanId: { type: "text", nullable: true },
|
|
161
|
+
name: { type: "text", nullable: false },
|
|
162
|
+
traceId: { type: "text", nullable: false },
|
|
163
|
+
scope: { type: "text", nullable: false },
|
|
164
|
+
kind: { type: "integer", nullable: false },
|
|
165
|
+
attributes: { type: "jsonb", nullable: true },
|
|
166
|
+
status: { type: "jsonb", nullable: true },
|
|
167
|
+
events: { type: "jsonb", nullable: true },
|
|
168
|
+
links: { type: "jsonb", nullable: true },
|
|
169
|
+
other: { type: "text", nullable: true },
|
|
170
|
+
startTime: { type: "bigint", nullable: false },
|
|
171
|
+
endTime: { type: "bigint", nullable: false },
|
|
172
|
+
createdAt: { type: "timestamp", nullable: false }
|
|
173
|
+
}
|
|
174
|
+
})
|
|
175
|
+
]).then(() => true);
|
|
176
|
+
await this.hasInitialized;
|
|
175
177
|
}
|
|
176
178
|
async persistWorkflowSnapshot({
|
|
177
179
|
workflowName,
|
|
@@ -196,7 +198,7 @@ var MastraStorage = class extends MastraBase {
|
|
|
196
198
|
workflowName,
|
|
197
199
|
runId
|
|
198
200
|
}) {
|
|
199
|
-
if (!this.
|
|
201
|
+
if (!this.hasInitialized) {
|
|
200
202
|
await this.init();
|
|
201
203
|
}
|
|
202
204
|
this.logger.debug("Loading workflow snapshot", { workflowName, runId });
|
|
@@ -214,7 +216,7 @@ var MastraStorage = class extends MastraBase {
|
|
|
214
216
|
function safelyParseJSON(jsonString) {
|
|
215
217
|
try {
|
|
216
218
|
return JSON.parse(jsonString);
|
|
217
|
-
} catch
|
|
219
|
+
} catch {
|
|
218
220
|
return {};
|
|
219
221
|
}
|
|
220
222
|
}
|
|
@@ -522,7 +524,7 @@ var DefaultStorage = class extends MastraStorage {
|
|
|
522
524
|
}
|
|
523
525
|
transformEvalRow(row) {
|
|
524
526
|
const resultValue = JSON.parse(row.result);
|
|
525
|
-
const testInfoValue = row.test_info ? JSON.parse(row.test_info) :
|
|
527
|
+
const testInfoValue = row.test_info ? JSON.parse(row.test_info) : void 0;
|
|
526
528
|
if (!resultValue || typeof resultValue !== "object" || !("score" in resultValue)) {
|
|
527
529
|
throw new Error(`Invalid MetricResult format: ${JSON.stringify(resultValue)}`);
|
|
528
530
|
}
|
|
@@ -3,38 +3,6 @@ import { context, trace } from '@opentelemetry/api';
|
|
|
3
3
|
import { get } from 'radash';
|
|
4
4
|
import sift from 'sift';
|
|
5
5
|
import { setup, createActor, assign, fromPromise } from 'xstate';
|
|
6
|
-
import 'zod';
|
|
7
|
-
|
|
8
|
-
var Step = class {
|
|
9
|
-
id;
|
|
10
|
-
description;
|
|
11
|
-
inputSchema;
|
|
12
|
-
outputSchema;
|
|
13
|
-
payload;
|
|
14
|
-
execute;
|
|
15
|
-
retryConfig;
|
|
16
|
-
mastra;
|
|
17
|
-
constructor({
|
|
18
|
-
id,
|
|
19
|
-
description,
|
|
20
|
-
execute,
|
|
21
|
-
payload,
|
|
22
|
-
outputSchema,
|
|
23
|
-
inputSchema,
|
|
24
|
-
retryConfig
|
|
25
|
-
}) {
|
|
26
|
-
this.id = id;
|
|
27
|
-
this.description = description ?? "";
|
|
28
|
-
this.inputSchema = inputSchema;
|
|
29
|
-
this.payload = payload;
|
|
30
|
-
this.outputSchema = outputSchema;
|
|
31
|
-
this.execute = execute;
|
|
32
|
-
this.retryConfig = retryConfig;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
function createStep(opts) {
|
|
36
|
-
return new Step(opts);
|
|
37
|
-
}
|
|
38
6
|
|
|
39
7
|
// src/workflows/utils.ts
|
|
40
8
|
function isErrorEvent(stateEvent) {
|
|
@@ -48,7 +16,7 @@ function isVariableReference(value) {
|
|
|
48
16
|
}
|
|
49
17
|
function getStepResult(result) {
|
|
50
18
|
if (result?.status === "success") return result.output;
|
|
51
|
-
return
|
|
19
|
+
return void 0;
|
|
52
20
|
}
|
|
53
21
|
|
|
54
22
|
// src/workflows/workflow.ts
|
|
@@ -223,7 +191,7 @@ var Workflow = class extends MastraBase {
|
|
|
223
191
|
const actorSnapshot = snapshot ? {
|
|
224
192
|
...snapshot,
|
|
225
193
|
context: machineInput
|
|
226
|
-
} :
|
|
194
|
+
} : void 0;
|
|
227
195
|
this.logger.debug(`Creating actor with configuration`, {
|
|
228
196
|
machineInput,
|
|
229
197
|
actorSnapshot,
|
|
@@ -264,6 +232,7 @@ var Workflow = class extends MastraBase {
|
|
|
264
232
|
context: state.context,
|
|
265
233
|
activePaths: this.#getActivePathsAndStatus(state.value),
|
|
266
234
|
timestamp: Date.now()
|
|
235
|
+
})?.catch(() => {
|
|
267
236
|
});
|
|
268
237
|
});
|
|
269
238
|
}
|
|
@@ -698,7 +667,7 @@ var Workflow = class extends MastraBase {
|
|
|
698
667
|
if (!isTransitionEvent(event)) return context.attempts;
|
|
699
668
|
const { stepId } = params;
|
|
700
669
|
const attemptCount = context.attempts[stepId];
|
|
701
|
-
if (attemptCount ===
|
|
670
|
+
if (attemptCount === void 0) return context.attempts;
|
|
702
671
|
return { ...context.attempts, [stepId]: attemptCount - 1 };
|
|
703
672
|
}
|
|
704
673
|
})
|
|
@@ -907,7 +876,7 @@ var Workflow = class extends MastraBase {
|
|
|
907
876
|
if (result && result.status === "success") {
|
|
908
877
|
return result.output;
|
|
909
878
|
}
|
|
910
|
-
return
|
|
879
|
+
return void 0;
|
|
911
880
|
}
|
|
912
881
|
};
|
|
913
882
|
for (const [key, variable] of Object.entries(stepConfig.data)) {
|
|
@@ -921,7 +890,7 @@ var Workflow = class extends MastraBase {
|
|
|
921
890
|
}
|
|
922
891
|
);
|
|
923
892
|
if (!sourceData && variable.step !== "trigger") {
|
|
924
|
-
resolvedData[key] =
|
|
893
|
+
resolvedData[key] = void 0;
|
|
925
894
|
continue;
|
|
926
895
|
}
|
|
927
896
|
const value = variable.path === "" || variable.path === "." ? sourceData : get(sourceData, variable.path);
|
|
@@ -1200,4 +1169,36 @@ var Workflow = class extends MastraBase {
|
|
|
1200
1169
|
}
|
|
1201
1170
|
};
|
|
1202
1171
|
|
|
1172
|
+
// src/workflows/step.ts
|
|
1173
|
+
var Step = class {
|
|
1174
|
+
id;
|
|
1175
|
+
description;
|
|
1176
|
+
inputSchema;
|
|
1177
|
+
outputSchema;
|
|
1178
|
+
payload;
|
|
1179
|
+
execute;
|
|
1180
|
+
retryConfig;
|
|
1181
|
+
mastra;
|
|
1182
|
+
constructor({
|
|
1183
|
+
id,
|
|
1184
|
+
description,
|
|
1185
|
+
execute,
|
|
1186
|
+
payload,
|
|
1187
|
+
outputSchema,
|
|
1188
|
+
inputSchema,
|
|
1189
|
+
retryConfig
|
|
1190
|
+
}) {
|
|
1191
|
+
this.id = id;
|
|
1192
|
+
this.description = description ?? "";
|
|
1193
|
+
this.inputSchema = inputSchema;
|
|
1194
|
+
this.payload = payload;
|
|
1195
|
+
this.outputSchema = outputSchema;
|
|
1196
|
+
this.execute = execute;
|
|
1197
|
+
this.retryConfig = retryConfig;
|
|
1198
|
+
}
|
|
1199
|
+
};
|
|
1200
|
+
function createStep(opts) {
|
|
1201
|
+
return new Step(opts);
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1203
1204
|
export { Step, Workflow, createStep, getStepResult, isErrorEvent, isTransitionEvent, isVariableReference };
|
package/dist/chunk-AWEACB2T.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// src/eval/metric.ts
|
|
2
|
-
var Metric = class {
|
|
3
|
-
};
|
|
4
|
-
|
|
5
1
|
// src/hooks/mitt.ts
|
|
6
2
|
function mitt(all) {
|
|
7
3
|
all = all || /* @__PURE__ */ new Map();
|
|
@@ -84,4 +80,4 @@ function executeHook(hook, data) {
|
|
|
84
80
|
});
|
|
85
81
|
}
|
|
86
82
|
|
|
87
|
-
export { AvailableHooks,
|
|
83
|
+
export { AvailableHooks, executeHook, registerHook };
|
package/dist/chunk-C6A6W6XS.js
CHANGED
|
@@ -2,41 +2,69 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
5
|
-
var __typeError =
|
|
5
|
+
var __typeError = msg => {
|
|
6
6
|
throw TypeError(msg);
|
|
7
7
|
};
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value
|
|
13
|
+
}) : obj[key] = value;
|
|
14
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
15
|
+
value,
|
|
16
|
+
configurable: true
|
|
17
|
+
});
|
|
18
|
+
var __decoratorStart = base => [,,, __create(base?.[__knownSymbol("metadata")] ?? null)];
|
|
11
19
|
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
12
|
-
var __expectFn =
|
|
13
|
-
var __decoratorContext = (kind, name, done, metadata, fns) => ({
|
|
20
|
+
var __expectFn = fn => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
21
|
+
var __decoratorContext = (kind, name, done, metadata, fns) => ({
|
|
22
|
+
kind: __decoratorStrings[kind],
|
|
23
|
+
name,
|
|
24
|
+
metadata,
|
|
25
|
+
addInitializer: fn => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null))
|
|
26
|
+
});
|
|
14
27
|
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
15
28
|
var __runInitializers = (array, flags, self, value) => {
|
|
16
29
|
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
17
30
|
return value;
|
|
18
31
|
};
|
|
19
32
|
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
20
|
-
var fn,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
var fn,
|
|
34
|
+
it,
|
|
35
|
+
done,
|
|
36
|
+
ctx,
|
|
37
|
+
access,
|
|
38
|
+
k = flags & 7,
|
|
39
|
+
s = !!(flags & 8),
|
|
40
|
+
p = !!(flags & 16);
|
|
41
|
+
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0,
|
|
42
|
+
key = __decoratorStrings[k + 5];
|
|
43
|
+
var initializers = k > 3 && (array[j - 1] = []),
|
|
44
|
+
extraInitializers = array[j] || (array[j] = []);
|
|
45
|
+
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : {
|
|
46
|
+
get [name]() {
|
|
47
|
+
return __privateGet(this, extra);
|
|
48
|
+
},
|
|
49
|
+
set [name](x) {
|
|
50
|
+
return __privateSet(this, extra, x);
|
|
51
|
+
}
|
|
52
|
+
}, name));
|
|
28
53
|
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
29
54
|
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
30
55
|
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
31
56
|
if (k) {
|
|
32
|
-
ctx.static = s, ctx.private = p, access = ctx.access = {
|
|
33
|
-
|
|
57
|
+
ctx.static = s, ctx.private = p, access = ctx.access = {
|
|
58
|
+
has: p ? x => __privateIn(target, x) : x => name in x
|
|
59
|
+
};
|
|
60
|
+
if (k ^ 3) access.get = p ? x => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : x => x[name];
|
|
34
61
|
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
35
62
|
}
|
|
36
|
-
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ?
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
63
|
+
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : {
|
|
64
|
+
get: desc.get,
|
|
65
|
+
set: desc.set
|
|
66
|
+
} : target, ctx), done._ = 1;
|
|
67
|
+
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);else if (typeof it !== "object" || it === null) __typeError("Object expected");else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
40
68
|
}
|
|
41
69
|
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
42
70
|
};
|