@primero.ai/temporal-graph-tools 1.4.0 → 1.4.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-model.d.ts","sourceRoot":"","sources":["../../../src/mastra/ai-model.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAGvC,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAA;AAElG,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,eAAe,CAAC,EAAE,mBAAmB,CAAA;IACrC,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;
|
|
1
|
+
{"version":3,"file":"ai-model.d.ts","sourceRoot":"","sources":["../../../src/mastra/ai-model.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAGvC,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAA;AAElG,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,eAAe,CAAC,EAAE,mBAAmB,CAAA;IACrC,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAqCD,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,IAAI,CAAC,uBAAuB,EAAE,UAAU,GAAG,iBAAiB,CAAM,GAC1E,mBAAmB,CAuBrB;AAED,wBAAgB,cAAc,CAC5B,OAAO,GAAE,IAAI,CAAC,uBAAuB,EAAE,OAAO,GAAG,cAAc,CAAM,GACpE,MAAM,CAeR;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,uBAA4B,GAAG;IACzE,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,KAAK,EAAE,MAAM,CAAA;CACd,CAKA;AAED,wBAAgB,aAAa,CAAC,OAAO,GAAE,uBAA4B,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CA4B9F"}
|
|
@@ -16,11 +16,28 @@ function normalizeString(value) {
|
|
|
16
16
|
const normalized = value.trim();
|
|
17
17
|
return normalized.length > 0 ? normalized : undefined;
|
|
18
18
|
}
|
|
19
|
+
function readDagAiConfig() {
|
|
20
|
+
const raw = process.env.PRIMERO_DAG_AI_CONFIG;
|
|
21
|
+
if (!raw) {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const parsed = JSON.parse(raw);
|
|
26
|
+
return {
|
|
27
|
+
provider: typeof parsed.provider === 'string' ? parsed.provider : undefined,
|
|
28
|
+
model: typeof parsed.model === 'string' ? parsed.model : undefined,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
19
35
|
export function resolveAiProvider(options = {}) {
|
|
20
|
-
var _a, _b, _c, _d;
|
|
21
|
-
const
|
|
36
|
+
var _a, _b, _c, _d, _e;
|
|
37
|
+
const dagAiConfig = readDagAiConfig();
|
|
38
|
+
const candidate = (_d = (_c = (_b = (_a = normalizeString(options.provider)) !== null && _a !== void 0 ? _a : normalizeString(dagAiConfig.provider)) !== null && _b !== void 0 ? _b : normalizeString(process.env.AI_PROVIDER)) !== null && _c !== void 0 ? _c : options.defaultProvider) !== null && _d !== void 0 ? _d : DEFAULT_PROVIDER;
|
|
22
39
|
const lowered = candidate.toLowerCase();
|
|
23
|
-
const resolved = (
|
|
40
|
+
const resolved = (_e = PROVIDER_ALIASES[lowered]) !== null && _e !== void 0 ? _e : lowered;
|
|
24
41
|
if (resolved === 'openai' ||
|
|
25
42
|
resolved === 'anthropic' ||
|
|
26
43
|
resolved === 'google' ||
|
|
@@ -32,10 +49,11 @@ export function resolveAiProvider(options = {}) {
|
|
|
32
49
|
throw new Error(`Unsupported AI provider '${candidate}'.`);
|
|
33
50
|
}
|
|
34
51
|
export function resolveAiModel(options = {}) {
|
|
35
|
-
var _a, _b;
|
|
36
|
-
const
|
|
52
|
+
var _a, _b, _c;
|
|
53
|
+
const dagAiConfig = readDagAiConfig();
|
|
54
|
+
const model = (_c = (_b = (_a = normalizeString(options.model)) !== null && _a !== void 0 ? _a : normalizeString(dagAiConfig.model)) !== null && _b !== void 0 ? _b : normalizeString(process.env.AI_MODEL)) !== null && _c !== void 0 ? _c : normalizeString(options.defaultModel);
|
|
37
55
|
if (!model) {
|
|
38
|
-
throw new Error('No AI model configured. Pass a model option or set
|
|
56
|
+
throw new Error('No AI model configured. Pass a model option, set PRIMERO_DAG_AI_CONFIG, or set AI_MODEL in the environment.');
|
|
39
57
|
}
|
|
40
58
|
return model;
|
|
41
59
|
}
|
|
@@ -65,5 +83,5 @@ export function selectAiModel(options = {}) {
|
|
|
65
83
|
if (provider === 'azure') {
|
|
66
84
|
return azure(model);
|
|
67
85
|
}
|
|
68
|
-
throw new Error(
|
|
86
|
+
throw new Error('Unsupported AI provider.');
|
|
69
87
|
}
|
|
@@ -3,6 +3,8 @@ export type MastraWorkflowLike = {
|
|
|
3
3
|
id?: string;
|
|
4
4
|
engineType?: string;
|
|
5
5
|
stepGraph: Array<Record<string, unknown>>;
|
|
6
|
+
steps?: Record<string, unknown>;
|
|
7
|
+
stepById?: Record<string, unknown>;
|
|
6
8
|
};
|
|
7
9
|
export type CompileMastraWorkflowOptions = Omit<TemporalWorkflowBuildOptions, 'workflowName'> & {
|
|
8
10
|
workflowName?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-compiler.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflow-compiler.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,4BAA4B,EACjC,KAAK,mBAAmB,EACzB,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"workflow-compiler.d.ts","sourceRoot":"","sources":["../../../src/mastra/workflow-compiler.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,4BAA4B,EACjC,KAAK,mBAAmB,EACzB,MAAM,aAAa,CAAA;AAYpB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAAC,4BAA4B,EAAE,cAAc,CAAC,GAAG;IAC9F,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACxC;;;;;OAKG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAA;CACzC,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,OAAO,CAAC,EAAE,4BAA4B,CAAA;CACvC,CAAA;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,GAAE,4BAAiC,GACzC,mBAAmB,CAwFrB"}
|
|
@@ -13,8 +13,16 @@ export function compileMastraWorkflow(workflow, options = {}) {
|
|
|
13
13
|
...(options.proxyOptions ? { proxyOptions: options.proxyOptions } : {}),
|
|
14
14
|
});
|
|
15
15
|
workflow.stepGraph.forEach((entry, stageIndex) => {
|
|
16
|
-
if (entry.type === 'step'
|
|
17
|
-
const
|
|
16
|
+
if (entry.type === 'step') {
|
|
17
|
+
const step = resolveMastraStep(entry.step, workflow);
|
|
18
|
+
if (!step) {
|
|
19
|
+
const stepId = getMastraStepId(entry.step);
|
|
20
|
+
throw new Error(stepId
|
|
21
|
+
? `Unable to resolve Mastra step '${stepId}' at stage ${stageIndex}. ` +
|
|
22
|
+
`Ensure workflow.steps/workflow.stepById includes executable steps or pass stepActivities explicitly.`
|
|
23
|
+
: `Unsupported Mastra step entry at stage ${stageIndex}. Expected an executable step or step id.`);
|
|
24
|
+
}
|
|
25
|
+
const reference = resolveStepReference(workflow, step, options.stepActivities, options.allowUnsafeStepExecuteFallback === true);
|
|
18
26
|
builder = builder.then(reference);
|
|
19
27
|
return;
|
|
20
28
|
}
|
|
@@ -22,14 +30,21 @@ export function compileMastraWorkflow(workflow, options = {}) {
|
|
|
22
30
|
const references = entry.steps.map((child, branchIndex) => {
|
|
23
31
|
if (typeof child !== 'object' ||
|
|
24
32
|
child === null ||
|
|
25
|
-
child.type !== 'step'
|
|
26
|
-
!isMastraStepLike(child.step)) {
|
|
33
|
+
child.type !== 'step') {
|
|
27
34
|
const childType = typeof child === 'object' && child !== null
|
|
28
35
|
? String(child.type)
|
|
29
36
|
: typeof child;
|
|
30
37
|
throw new Error(`Unsupported Mastra parallel child type '${childType}' at stage ${stageIndex}, branch ${branchIndex}.`);
|
|
31
38
|
}
|
|
32
|
-
|
|
39
|
+
const step = resolveMastraStep(child.step, workflow);
|
|
40
|
+
if (!step) {
|
|
41
|
+
const stepId = getMastraStepId(child.step);
|
|
42
|
+
throw new Error(stepId
|
|
43
|
+
? `Unable to resolve Mastra parallel step '${stepId}' at stage ${stageIndex}, branch ${branchIndex}. ` +
|
|
44
|
+
`Ensure workflow.steps/workflow.stepById includes executable steps or pass stepActivities explicitly.`
|
|
45
|
+
: `Unsupported Mastra parallel step at stage ${stageIndex}, branch ${branchIndex}.`);
|
|
46
|
+
}
|
|
47
|
+
return resolveStepReference(workflow, step, options.stepActivities, options.allowUnsafeStepExecuteFallback === true);
|
|
33
48
|
});
|
|
34
49
|
builder = builder.parallel(references);
|
|
35
50
|
return;
|
|
@@ -45,6 +60,38 @@ function isMastraStepLike(value) {
|
|
|
45
60
|
const step = value;
|
|
46
61
|
return typeof step.id === 'string' && typeof step.execute === 'function';
|
|
47
62
|
}
|
|
63
|
+
function isMastraStepIdentifier(value) {
|
|
64
|
+
if (typeof value !== 'object' || value === null) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
const step = value;
|
|
68
|
+
return typeof step.id === 'string' && step.id.trim().length > 0;
|
|
69
|
+
}
|
|
70
|
+
function resolveMastraStep(stepCandidate, workflow) {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
if (isMastraStepLike(stepCandidate)) {
|
|
73
|
+
return stepCandidate;
|
|
74
|
+
}
|
|
75
|
+
if (!isMastraStepIdentifier(stepCandidate)) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const { id } = stepCandidate;
|
|
79
|
+
const fromSteps = (_a = workflow.steps) === null || _a === void 0 ? void 0 : _a[id];
|
|
80
|
+
if (isMastraStepLike(fromSteps)) {
|
|
81
|
+
return fromSteps;
|
|
82
|
+
}
|
|
83
|
+
const fromStepById = (_b = workflow.stepById) === null || _b === void 0 ? void 0 : _b[id];
|
|
84
|
+
if (isMastraStepLike(fromStepById)) {
|
|
85
|
+
return fromStepById;
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
function getMastraStepId(stepCandidate) {
|
|
90
|
+
if (!isMastraStepIdentifier(stepCandidate)) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
return stepCandidate.id;
|
|
94
|
+
}
|
|
48
95
|
function resolveWorkflowName(workflow, explicitName) {
|
|
49
96
|
const explicit = typeof explicitName === 'string' ? explicitName.trim() : '';
|
|
50
97
|
if (explicit.length > 0) {
|
package/package.json
CHANGED