@mastra/temporal 0.0.0-ag-example-20260516005230
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/CHANGELOG.md +366 -0
- package/LICENSE.md +30 -0
- package/README.md +107 -0
- package/dist/chunk-BF6TR7JX.js +9 -0
- package/dist/chunk-BF6TR7JX.js.map +1 -0
- package/dist/chunk-DYBSPLCJ.cjs +11 -0
- package/dist/chunk-DYBSPLCJ.cjs.map +1 -0
- package/dist/index.cjs +132 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +130 -0
- package/dist/index.js.map +1 -0
- package/dist/mastra-deployer-UCBGECM5.js +39 -0
- package/dist/mastra-deployer-UCBGECM5.js.map +1 -0
- package/dist/mastra-deployer-YVT5GB5G.cjs +41 -0
- package/dist/mastra-deployer-YVT5GB5G.cjs.map +1 -0
- package/dist/mastra-deployer.d.ts +16 -0
- package/dist/mastra-deployer.d.ts.map +1 -0
- package/dist/plugin.d.ts +16 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/run.d.ts +24 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/temporal-workflow-runtime.mjs +295 -0
- package/dist/transforms/activities.d.ts +11 -0
- package/dist/transforms/activities.d.ts.map +1 -0
- package/dist/transforms/shared.d.ts +23 -0
- package/dist/transforms/shared.d.ts.map +1 -0
- package/dist/transforms/temporal-workflow-runtime.d.mts +92 -0
- package/dist/transforms/temporal-workflow-runtime.d.mts.map +1 -0
- package/dist/transforms/workflows.d.ts +20 -0
- package/dist/transforms/workflows.d.ts.map +1 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/worker.cjs +1336 -0
- package/dist/worker.cjs.map +1 -0
- package/dist/worker.d.ts +2 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +1310 -0
- package/dist/worker.js.map +1 -0
- package/dist/workflow.d.ts +27 -0
- package/dist/workflow.d.ts.map +1 -0
- package/package.json +95 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkDYBSPLCJ_cjs = require('./chunk-DYBSPLCJ.cjs');
|
|
4
|
+
var workflows = require('@mastra/core/workflows');
|
|
5
|
+
|
|
6
|
+
var TemporalRun = class extends workflows.Run {
|
|
7
|
+
client;
|
|
8
|
+
taskQueue;
|
|
9
|
+
constructor(params, temporalParams) {
|
|
10
|
+
super(params);
|
|
11
|
+
this.client = temporalParams.client;
|
|
12
|
+
this.taskQueue = temporalParams.taskQueue;
|
|
13
|
+
}
|
|
14
|
+
async start(args = {}) {
|
|
15
|
+
const input = await this._validateInput(args.inputData);
|
|
16
|
+
const initialState = await this._validateInitialState(args.initialState);
|
|
17
|
+
await this._validateRequestContext(args.requestContext);
|
|
18
|
+
try {
|
|
19
|
+
const handle = await this.client.workflow.start(chunkDYBSPLCJ_cjs.toWorkflowType(this.workflowId), {
|
|
20
|
+
taskQueue: this.taskQueue,
|
|
21
|
+
workflowId: this.runId,
|
|
22
|
+
args: [
|
|
23
|
+
{
|
|
24
|
+
inputData: input,
|
|
25
|
+
initialState,
|
|
26
|
+
requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},
|
|
27
|
+
runId: this.runId,
|
|
28
|
+
resourceId: this.resourceId,
|
|
29
|
+
outputOptions: args.outputOptions,
|
|
30
|
+
tracingOptions: args.tracingOptions,
|
|
31
|
+
perStep: args.perStep
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
const result = await handle.result();
|
|
36
|
+
return {
|
|
37
|
+
status: "success",
|
|
38
|
+
input,
|
|
39
|
+
result,
|
|
40
|
+
state: initialState,
|
|
41
|
+
steps: {}
|
|
42
|
+
};
|
|
43
|
+
} catch (error) {
|
|
44
|
+
return {
|
|
45
|
+
status: "failed",
|
|
46
|
+
input,
|
|
47
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
48
|
+
state: initialState,
|
|
49
|
+
steps: {}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async startAsync(args = {}) {
|
|
54
|
+
const input = await this._validateInput(args.inputData);
|
|
55
|
+
const initialState = await this._validateInitialState(args.initialState);
|
|
56
|
+
await this._validateRequestContext(args.requestContext);
|
|
57
|
+
await this.client.workflow.start(chunkDYBSPLCJ_cjs.toWorkflowType(this.workflowId), {
|
|
58
|
+
taskQueue: this.taskQueue,
|
|
59
|
+
workflowId: this.runId,
|
|
60
|
+
args: [
|
|
61
|
+
{
|
|
62
|
+
inputData: input,
|
|
63
|
+
initialState,
|
|
64
|
+
requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},
|
|
65
|
+
runId: this.runId,
|
|
66
|
+
resourceId: this.resourceId,
|
|
67
|
+
outputOptions: args.outputOptions,
|
|
68
|
+
tracingOptions: args.tracingOptions,
|
|
69
|
+
perStep: args.perStep
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
return { runId: this.runId };
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// src/workflow.ts
|
|
78
|
+
var TemporalWorkflow = class extends workflows.Workflow {
|
|
79
|
+
temporalClient;
|
|
80
|
+
taskQueue;
|
|
81
|
+
startToCloseTimeout;
|
|
82
|
+
constructor(params, temporalParams) {
|
|
83
|
+
super(params);
|
|
84
|
+
this.engineType = "temporal";
|
|
85
|
+
this.temporalClient = temporalParams.client;
|
|
86
|
+
this.taskQueue = temporalParams.taskQueue;
|
|
87
|
+
this.startToCloseTimeout = temporalParams.startToCloseTimeout ?? "1 minute";
|
|
88
|
+
}
|
|
89
|
+
async createRun(options) {
|
|
90
|
+
const runId = options?.runId ?? crypto.randomUUID();
|
|
91
|
+
const run = new TemporalRun(
|
|
92
|
+
{
|
|
93
|
+
workflowId: this.id,
|
|
94
|
+
runId,
|
|
95
|
+
resourceId: options?.resourceId,
|
|
96
|
+
stateSchema: this.stateSchema,
|
|
97
|
+
inputSchema: this.inputSchema,
|
|
98
|
+
requestContextSchema: this.requestContextSchema,
|
|
99
|
+
executionEngine: this.executionEngine,
|
|
100
|
+
executionGraph: this.executionGraph,
|
|
101
|
+
mastra: this.mastra,
|
|
102
|
+
retryConfig: this.retryConfig,
|
|
103
|
+
serializedStepGraph: this.serializedStepGraph,
|
|
104
|
+
disableScorers: options?.disableScorers,
|
|
105
|
+
tracingPolicy: this.options.tracingPolicy,
|
|
106
|
+
workflowSteps: this.steps,
|
|
107
|
+
validateInputs: this.options.validateInputs,
|
|
108
|
+
workflowEngineType: this.engineType,
|
|
109
|
+
cleanup: void 0
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
client: this.temporalClient,
|
|
113
|
+
taskQueue: this.taskQueue
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
this.runs.set(runId, run);
|
|
117
|
+
return run;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
function createWorkflow(config, temporal) {
|
|
121
|
+
return new TemporalWorkflow(config, temporal);
|
|
122
|
+
}
|
|
123
|
+
function init(temporalParams) {
|
|
124
|
+
return {
|
|
125
|
+
createWorkflow: (config) => createWorkflow(config, temporalParams),
|
|
126
|
+
createStep: workflows.createStep
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
exports.init = init;
|
|
131
|
+
//# sourceMappingURL=index.cjs.map
|
|
132
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/run.ts","../src/workflow.ts"],"names":["Run","toWorkflowType","Workflow","createStep"],"mappings":";;;;;AAaO,IAAM,WAAA,GAAN,cAcGA,aAAA,CAA0E;AAAA,EACjE,MAAA;AAAA,EACA,SAAA;AAAA,EAEjB,WAAA,CAC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,OACX;AAAA,MACA;AAAA,QACE,QAAQ,IAAA,CAAK,cAAA;AAAA,QACb,WAAW,IAAA,CAAK;AAAA;AAClB,KACF;AAEA,IAAA,IAAA,CAAK,IAAA,CAAK,GAAA,CAAI,KAAA,EAAO,GAAG,CAAA;AACxB,IAAA,OAAO,GAAA;AAAA,EACT;AACF,CAAA;AAEO,SAAS,cAAA,CAgBd,QACA,QAAA,EACA;AACA,EAAA,OAAO,IAAI,gBAAA,CAAwF,MAAA,EAAQ,QAAQ,CAAA;AACrH;AAEO,SAAS,KAAK,cAAA,EAAwC;AAC3D,EAAA,OAAO;AAAA,IACL,cAAA,EAAgB,CAQd,MAAA,KACG,cAAA,CAA8E,QAAQ,cAAc,CAAA;AAAA,gBACzGC;AAAA,GACF;AACF","file":"index.cjs","sourcesContent":["import type { RequestContext } from '@mastra/core/di';\nimport { Run } from '@mastra/core/workflows';\nimport type { Step, WorkflowResult, WorkflowRunStartOptions } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { TemporalEngineType } from './types';\nimport { toWorkflowType } from './utils';\n\ntype TemporalRunStartArgs<TState, TInput, TRequestContext> = {\n inputData?: TInput;\n initialState?: TState;\n requestContext?: RequestContext<TRequestContext>;\n} & WorkflowRunStartOptions;\n\nexport class TemporalRun<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext> {\n private readonly client: Client;\n private readonly taskQueue: string;\n\n constructor(\n params: ConstructorParameters<typeof Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>>[0],\n temporalParams: {\n client: Client;\n taskQueue: string;\n },\n ) {\n super(params);\n\n this.client = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n }\n\n async start(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n try {\n const handle = await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n },\n ],\n });\n const result = await handle.result();\n\n return {\n status: 'success',\n input: input as TInput,\n result: result as TOutput,\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n } catch (error) {\n return {\n status: 'failed',\n input: input as TInput,\n error: error instanceof Error ? error : new Error(String(error)),\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n }\n\n async startAsync(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n },\n ],\n });\n\n return { runId: this.runId };\n }\n}\n","import { Workflow, createStep } from '@mastra/core/workflows';\nimport type { Step, WorkflowConfig } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport { TemporalRun } from './run';\nimport type { TemporalEngineType } from './types';\n\nexport type TemporalWorkflowParams = {\n client: Client;\n taskQueue: string;\n startToCloseTimeout?: string;\n};\n\nexport class TemporalWorkflow<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TWorkflowId extends string = string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TPrevSchema = TInput,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Workflow<TemporalEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TPrevSchema, TRequestContext> {\n private readonly temporalClient: Client;\n readonly taskQueue: string;\n readonly startToCloseTimeout: string;\n\n constructor(\n params: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n temporalParams: TemporalWorkflowParams,\n ) {\n super(params);\n\n this.engineType = 'temporal';\n this.temporalClient = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n this.startToCloseTimeout = temporalParams.startToCloseTimeout ?? '1 minute';\n }\n\n async createRun(options?: { runId?: string; resourceId?: string; disableScorers?: boolean }) {\n const runId = options?.runId ?? crypto.randomUUID();\n const run = new TemporalRun<TSteps, TState, TInput, TOutput, TRequestContext>(\n {\n workflowId: this.id,\n runId,\n resourceId: options?.resourceId,\n stateSchema: this.stateSchema,\n inputSchema: this.inputSchema,\n requestContextSchema: this.requestContextSchema,\n executionEngine: this.executionEngine,\n executionGraph: this.executionGraph,\n mastra: this.mastra,\n retryConfig: this.retryConfig,\n serializedStepGraph: this.serializedStepGraph,\n disableScorers: options?.disableScorers,\n tracingPolicy: this.options.tracingPolicy,\n workflowSteps: this.steps,\n validateInputs: this.options.validateInputs,\n workflowEngineType: this.engineType,\n cleanup: undefined,\n },\n {\n client: this.temporalClient,\n taskQueue: this.taskQueue,\n },\n );\n\n this.runs.set(runId, run);\n return run;\n }\n}\n\nexport function createWorkflow<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TWorkflowId extends string = string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n>(\n config: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n temporal: TemporalWorkflowParams,\n) {\n return new TemporalWorkflow<TSteps, TWorkflowId, TState, TInput, TOutput, TInput, TRequestContext>(config, temporal);\n}\n\nexport function init(temporalParams: TemporalWorkflowParams) {\n return {\n createWorkflow: <\n TWorkflowId extends string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TSteps extends Step[] = Step[],\n TRequestContext extends Record<string, any> | unknown = unknown,\n >(\n config: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n ) => createWorkflow<TSteps, TWorkflowId, TState, TInput, TOutput, TRequestContext>(config, temporalParams),\n createStep,\n };\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { toWorkflowType } from './chunk-BF6TR7JX.js';
|
|
2
|
+
import { createStep, Workflow, Run } from '@mastra/core/workflows';
|
|
3
|
+
|
|
4
|
+
var TemporalRun = class extends Run {
|
|
5
|
+
client;
|
|
6
|
+
taskQueue;
|
|
7
|
+
constructor(params, temporalParams) {
|
|
8
|
+
super(params);
|
|
9
|
+
this.client = temporalParams.client;
|
|
10
|
+
this.taskQueue = temporalParams.taskQueue;
|
|
11
|
+
}
|
|
12
|
+
async start(args = {}) {
|
|
13
|
+
const input = await this._validateInput(args.inputData);
|
|
14
|
+
const initialState = await this._validateInitialState(args.initialState);
|
|
15
|
+
await this._validateRequestContext(args.requestContext);
|
|
16
|
+
try {
|
|
17
|
+
const handle = await this.client.workflow.start(toWorkflowType(this.workflowId), {
|
|
18
|
+
taskQueue: this.taskQueue,
|
|
19
|
+
workflowId: this.runId,
|
|
20
|
+
args: [
|
|
21
|
+
{
|
|
22
|
+
inputData: input,
|
|
23
|
+
initialState,
|
|
24
|
+
requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},
|
|
25
|
+
runId: this.runId,
|
|
26
|
+
resourceId: this.resourceId,
|
|
27
|
+
outputOptions: args.outputOptions,
|
|
28
|
+
tracingOptions: args.tracingOptions,
|
|
29
|
+
perStep: args.perStep
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
const result = await handle.result();
|
|
34
|
+
return {
|
|
35
|
+
status: "success",
|
|
36
|
+
input,
|
|
37
|
+
result,
|
|
38
|
+
state: initialState,
|
|
39
|
+
steps: {}
|
|
40
|
+
};
|
|
41
|
+
} catch (error) {
|
|
42
|
+
return {
|
|
43
|
+
status: "failed",
|
|
44
|
+
input,
|
|
45
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
46
|
+
state: initialState,
|
|
47
|
+
steps: {}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async startAsync(args = {}) {
|
|
52
|
+
const input = await this._validateInput(args.inputData);
|
|
53
|
+
const initialState = await this._validateInitialState(args.initialState);
|
|
54
|
+
await this._validateRequestContext(args.requestContext);
|
|
55
|
+
await this.client.workflow.start(toWorkflowType(this.workflowId), {
|
|
56
|
+
taskQueue: this.taskQueue,
|
|
57
|
+
workflowId: this.runId,
|
|
58
|
+
args: [
|
|
59
|
+
{
|
|
60
|
+
inputData: input,
|
|
61
|
+
initialState,
|
|
62
|
+
requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},
|
|
63
|
+
runId: this.runId,
|
|
64
|
+
resourceId: this.resourceId,
|
|
65
|
+
outputOptions: args.outputOptions,
|
|
66
|
+
tracingOptions: args.tracingOptions,
|
|
67
|
+
perStep: args.perStep
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
});
|
|
71
|
+
return { runId: this.runId };
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// src/workflow.ts
|
|
76
|
+
var TemporalWorkflow = class extends Workflow {
|
|
77
|
+
temporalClient;
|
|
78
|
+
taskQueue;
|
|
79
|
+
startToCloseTimeout;
|
|
80
|
+
constructor(params, temporalParams) {
|
|
81
|
+
super(params);
|
|
82
|
+
this.engineType = "temporal";
|
|
83
|
+
this.temporalClient = temporalParams.client;
|
|
84
|
+
this.taskQueue = temporalParams.taskQueue;
|
|
85
|
+
this.startToCloseTimeout = temporalParams.startToCloseTimeout ?? "1 minute";
|
|
86
|
+
}
|
|
87
|
+
async createRun(options) {
|
|
88
|
+
const runId = options?.runId ?? crypto.randomUUID();
|
|
89
|
+
const run = new TemporalRun(
|
|
90
|
+
{
|
|
91
|
+
workflowId: this.id,
|
|
92
|
+
runId,
|
|
93
|
+
resourceId: options?.resourceId,
|
|
94
|
+
stateSchema: this.stateSchema,
|
|
95
|
+
inputSchema: this.inputSchema,
|
|
96
|
+
requestContextSchema: this.requestContextSchema,
|
|
97
|
+
executionEngine: this.executionEngine,
|
|
98
|
+
executionGraph: this.executionGraph,
|
|
99
|
+
mastra: this.mastra,
|
|
100
|
+
retryConfig: this.retryConfig,
|
|
101
|
+
serializedStepGraph: this.serializedStepGraph,
|
|
102
|
+
disableScorers: options?.disableScorers,
|
|
103
|
+
tracingPolicy: this.options.tracingPolicy,
|
|
104
|
+
workflowSteps: this.steps,
|
|
105
|
+
validateInputs: this.options.validateInputs,
|
|
106
|
+
workflowEngineType: this.engineType,
|
|
107
|
+
cleanup: void 0
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
client: this.temporalClient,
|
|
111
|
+
taskQueue: this.taskQueue
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
this.runs.set(runId, run);
|
|
115
|
+
return run;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
function createWorkflow(config, temporal) {
|
|
119
|
+
return new TemporalWorkflow(config, temporal);
|
|
120
|
+
}
|
|
121
|
+
function init(temporalParams) {
|
|
122
|
+
return {
|
|
123
|
+
createWorkflow: (config) => createWorkflow(config, temporalParams),
|
|
124
|
+
createStep
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export { init };
|
|
129
|
+
//# sourceMappingURL=index.js.map
|
|
130
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/run.ts","../src/workflow.ts"],"names":[],"mappings":";;;AAaO,IAAM,WAAA,GAAN,cAcG,GAAA,CAA0E;AAAA,EACjE,MAAA;AAAA,EACA,SAAA;AAAA,EAEjB,WAAA,CACE,QACA,cAAA,EAIA;AACA,IAAA,KAAA,CAAM,MAAM,CAAA;AAEZ,IAAA,IAAA,CAAK,SAAS,cAAA,CAAe,MAAA;AAC7B,IAAA,IAAA,CAAK,YAAY,cAAA,CAAe,SAAA;AAAA,EAClC;AAAA,EAEA,MAAM,KAAA,CAAM,IAAA,GAA8D,EAAC,EAAG;AAC5E,IAAA,MAAM,KAAA,GAAQ,MAAM,IAAA,CAAK,cAAA,CAAe,KAAK,SAAS,CAAA;AACtD,IAAA,MAAM,YAAA,GAAe,MAAM,IAAA,CAAK,qBAAA,CAAsB,KAAK,YAAY,CAAA;AACvE,IAAA,MAAM,IAAA,CAAK,uBAAA,CAAwB,IAAA,CAAK,cAAqD,CAAA;AAE7F,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,MAAA,CAAO,SAAS,KAAA,CAAM,cAAA,CAAe,IAAA,CAAK,UAAU,CAAA,EAAG;AAAA,QAC/E,WAAW,IAAA,CAAK,SAAA;AAAA,QAChB,YAAY,IAAA,CAAK,KAAA;AAAA,QACjB,IAAA,EAAM;A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,aAAa,IAAA,CAAK,WAAA;AAAA,QAClB,aAAa,IAAA,CAAK,WAAA;AAAA,QAClB,sBAAsB,IAAA,CAAK,oBAAA;AAAA,QAC3B,iBAAiB,IAAA,CAAK,eAAA;AAAA,QACtB,gBAAgB,IAAA,CAAK,cAAA;AAAA,QACrB,QAAQ,IAAA,CAAK,MAAA;AAAA,QACb,aAAa,IAAA,CAAK,WAAA;AAAA,QAClB,qBAAqB,IAAA,CAAK,mBAAA;AAAA,QAC1B,gBAAgB,OAAA,EAAS,cAAA;AAAA,QACzB,aAAA,EAAe,KAAK,OAAA,CAAQ,aAAA;AAAA,QAC5B,eAAe,IAAA,CAAK,KAAA;AAAA,QACpB,cAAA,EAAgB,KAAK,OAAA,CAAQ,cAAA;AAAA,QAC7B,oBAAoB,IAAA,CAAK,UAAA;AAAA,QACzB,OAAA,EAAS;AAAA,OACX;AAAA,MACA;AAAA,QACE,QAAQ,IAAA,CAAK,cAAA;AAAA,QACb,WAAW,IAAA,CAAK;AAAA;AAClB,KACF;AAEA,IAAA,IAAA,CAAK,IAAA,CAAK,GAAA,CAAI,KAAA,EAAO,GAAG,CAAA;AACxB,IAAA,OAAO,GAAA;AAAA,EACT;AACF,CAAA;AAEO,SAAS,cAAA,CAgBd,QACA,QAAA,EACA;AACA,EAAA,OAAO,IAAI,gBAAA,CAAwF,MAAA,EAAQ,QAAQ,CAAA;AACrH;AAEO,SAAS,KAAK,cAAA,EAAwC;AAC3D,EAAA,OAAO;AAAA,IACL,cAAA,EAAgB,CAQd,MAAA,KACG,cAAA,CAA8E,QAAQ,cAAc,CAAA;AAAA,IACzG;AAAA,GACF;AACF","file":"index.js","sourcesContent":["import type { RequestContext } from '@mastra/core/di';\nimport { Run } from '@mastra/core/workflows';\nimport type { Step, WorkflowResult, WorkflowRunStartOptions } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { TemporalEngineType } from './types';\nimport { toWorkflowType } from './utils';\n\ntype TemporalRunStartArgs<TState, TInput, TRequestContext> = {\n inputData?: TInput;\n initialState?: TState;\n requestContext?: RequestContext<TRequestContext>;\n} & WorkflowRunStartOptions;\n\nexport class TemporalRun<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext> {\n private readonly client: Client;\n private readonly taskQueue: string;\n\n constructor(\n params: ConstructorParameters<typeof Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>>[0],\n temporalParams: {\n client: Client;\n taskQueue: string;\n },\n ) {\n super(params);\n\n this.client = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n }\n\n async start(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n try {\n const handle = await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n },\n ],\n });\n const result = await handle.result();\n\n return {\n status: 'success',\n input: input as TInput,\n result: result as TOutput,\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n } catch (error) {\n return {\n status: 'failed',\n input: input as TInput,\n error: error instanceof Error ? error : new Error(String(error)),\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n }\n\n async startAsync(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n },\n ],\n });\n\n return { runId: this.runId };\n }\n}\n","import { Workflow, createStep } from '@mastra/core/workflows';\nimport type { Step, WorkflowConfig } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport { TemporalRun } from './run';\nimport type { TemporalEngineType } from './types';\n\nexport type TemporalWorkflowParams = {\n client: Client;\n taskQueue: string;\n startToCloseTimeout?: string;\n};\n\nexport class TemporalWorkflow<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TWorkflowId extends string = string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TPrevSchema = TInput,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Workflow<TemporalEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TPrevSchema, TRequestContext> {\n private readonly temporalClient: Client;\n readonly taskQueue: string;\n readonly startToCloseTimeout: string;\n\n constructor(\n params: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n temporalParams: TemporalWorkflowParams,\n ) {\n super(params);\n\n this.engineType = 'temporal';\n this.temporalClient = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n this.startToCloseTimeout = temporalParams.startToCloseTimeout ?? '1 minute';\n }\n\n async createRun(options?: { runId?: string; resourceId?: string; disableScorers?: boolean }) {\n const runId = options?.runId ?? crypto.randomUUID();\n const run = new TemporalRun<TSteps, TState, TInput, TOutput, TRequestContext>(\n {\n workflowId: this.id,\n runId,\n resourceId: options?.resourceId,\n stateSchema: this.stateSchema,\n inputSchema: this.inputSchema,\n requestContextSchema: this.requestContextSchema,\n executionEngine: this.executionEngine,\n executionGraph: this.executionGraph,\n mastra: this.mastra,\n retryConfig: this.retryConfig,\n serializedStepGraph: this.serializedStepGraph,\n disableScorers: options?.disableScorers,\n tracingPolicy: this.options.tracingPolicy,\n workflowSteps: this.steps,\n validateInputs: this.options.validateInputs,\n workflowEngineType: this.engineType,\n cleanup: undefined,\n },\n {\n client: this.temporalClient,\n taskQueue: this.taskQueue,\n },\n );\n\n this.runs.set(runId, run);\n return run;\n }\n}\n\nexport function createWorkflow<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TWorkflowId extends string = string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n>(\n config: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n temporal: TemporalWorkflowParams,\n) {\n return new TemporalWorkflow<TSteps, TWorkflowId, TState, TInput, TOutput, TInput, TRequestContext>(config, temporal);\n}\n\nexport function init(temporalParams: TemporalWorkflowParams) {\n return {\n createWorkflow: <\n TWorkflowId extends string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TSteps extends Step[] = Step[],\n TRequestContext extends Record<string, any> | unknown = unknown,\n >(\n config: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n ) => createWorkflow<TSteps, TWorkflowId, TState, TInput, TOutput, TRequestContext>(config, temporalParams),\n createStep,\n };\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Bundler } from '@mastra/deployer/bundler';
|
|
2
|
+
|
|
3
|
+
// src/mastra-deployer.ts
|
|
4
|
+
var BuildBundler = class extends Bundler {
|
|
5
|
+
constructor() {
|
|
6
|
+
super("Temporal");
|
|
7
|
+
this.platform = process.versions?.bun ? "neutral" : "node";
|
|
8
|
+
}
|
|
9
|
+
async getUserBundlerOptions(mastraEntryFile, outputDirectory) {
|
|
10
|
+
const bundlerOptions = await super.getUserBundlerOptions(mastraEntryFile, outputDirectory);
|
|
11
|
+
return {
|
|
12
|
+
...bundlerOptions,
|
|
13
|
+
externals: true,
|
|
14
|
+
sourcemap: true
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
getEnvFiles() {
|
|
18
|
+
return Promise.resolve([]);
|
|
19
|
+
}
|
|
20
|
+
installDependencies() {
|
|
21
|
+
return Promise.resolve();
|
|
22
|
+
}
|
|
23
|
+
copyPublic() {
|
|
24
|
+
return Promise.resolve();
|
|
25
|
+
}
|
|
26
|
+
writePackageJson() {
|
|
27
|
+
return Promise.resolve();
|
|
28
|
+
}
|
|
29
|
+
async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
|
|
30
|
+
return this._bundle(entryFile, entryFile, { outputDirectory, projectRoot }, toolsPaths);
|
|
31
|
+
}
|
|
32
|
+
async lint(entryFile, outputDirectory, toolsPaths) {
|
|
33
|
+
await super.lint(entryFile, outputDirectory, toolsPaths);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { BuildBundler };
|
|
38
|
+
//# sourceMappingURL=mastra-deployer-UCBGECM5.js.map
|
|
39
|
+
//# sourceMappingURL=mastra-deployer-UCBGECM5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mastra-deployer.ts"],"names":[],"mappings":";;;AAGO,IAAM,YAAA,GAAN,cAA2B,OAAA,CAAQ;AAAA,EACxC,WAAA,GAAc;AACZ,IAAA,KAAA,CAAM,UAAU,CAAA;AAChB,IAAA,IAAA,CAAK,QAAA,GAAW,OAAA,CAAQ,QAAA,EAAU,GAAA,GAAM,SAAA,GAAY,MAAA;AAAA,EACtD;AAAA,EAEA,MAAgB,qBAAA,CACd,eAAA,EACA,eAAA,EACyC;AACzC,IAAA,MAAM,cAAA,GAAiB,MAAM,KAAA,CAAM,qBAAA,CAAsB,iBAAiB,eAAe,CAAA;AAEzF,IAAA,OAAO;AAAA,MACL,GAAG,cAAA;AAAA,MACH,SAAA,EAAW,IAAA;AAAA,MACX,SAAA,EAAW;AAAA,KACb;AAAA,EACF;AAAA,EAEA,WAAA,GAAiC;AAC/B,IAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,EAAE,CAAA;AAAA,EAC3B;AAAA,EAEU,mBAAA,GAAqC;AAC7C,IAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,EACzB;AAAA,EAEU,UAAA,GAA4B;AACpC,IAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,EACzB;AAAA,EAEA,gBAAA,GAAkC;AAChC,IAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,EACzB;AAAA,EAEA,MAAM,MAAA,CACJ,SAAA,EACA,iBACA,EAAE,UAAA,EAAY,aAAY,EACX;AACf,IAAA,OAAO,IAAA,CAAK,QAAQ,SAAA,EAAW,SAAA,EAAW,EAAE,eAAA,EAAiB,WAAA,IAAe,UAAU,CAAA;AAAA,EACxF;AAAA,EAEA,MAAM,IAAA,CAAK,SAAA,EAAmB,eAAA,EAAyB,UAAA,EAAkD;AACvG,IAAA,MAAM,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,eAAA,EAAiB,UAAU,CAAA;AAAA,EACzD;AACF","file":"mastra-deployer-UCBGECM5.js","sourcesContent":["import type { Config } from '@mastra/core/mastra';\nimport { Bundler } from '@mastra/deployer/bundler';\n\nexport class BuildBundler extends Bundler {\n constructor() {\n super('Temporal');\n this.platform = process.versions?.bun ? 'neutral' : 'node';\n }\n\n protected async getUserBundlerOptions(\n mastraEntryFile: string,\n outputDirectory: string,\n ): Promise<NonNullable<Config['bundler']>> {\n const bundlerOptions = await super.getUserBundlerOptions(mastraEntryFile, outputDirectory);\n\n return {\n ...bundlerOptions,\n externals: true,\n sourcemap: true,\n };\n }\n\n getEnvFiles(): Promise<string[]> {\n return Promise.resolve([]);\n }\n\n protected installDependencies(): Promise<void> {\n return Promise.resolve();\n }\n\n protected copyPublic(): Promise<void> {\n return Promise.resolve();\n }\n\n writePackageJson(): Promise<void> {\n return Promise.resolve();\n }\n\n async bundle(\n entryFile: string,\n outputDirectory: string,\n { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void> {\n return this._bundle(entryFile, entryFile, { outputDirectory, projectRoot }, toolsPaths);\n }\n\n async lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n await super.lint(entryFile, outputDirectory, toolsPaths);\n }\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var bundler = require('@mastra/deployer/bundler');
|
|
4
|
+
|
|
5
|
+
// src/mastra-deployer.ts
|
|
6
|
+
var BuildBundler = class extends bundler.Bundler {
|
|
7
|
+
constructor() {
|
|
8
|
+
super("Temporal");
|
|
9
|
+
this.platform = process.versions?.bun ? "neutral" : "node";
|
|
10
|
+
}
|
|
11
|
+
async getUserBundlerOptions(mastraEntryFile, outputDirectory) {
|
|
12
|
+
const bundlerOptions = await super.getUserBundlerOptions(mastraEntryFile, outputDirectory);
|
|
13
|
+
return {
|
|
14
|
+
...bundlerOptions,
|
|
15
|
+
externals: true,
|
|
16
|
+
sourcemap: true
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
getEnvFiles() {
|
|
20
|
+
return Promise.resolve([]);
|
|
21
|
+
}
|
|
22
|
+
installDependencies() {
|
|
23
|
+
return Promise.resolve();
|
|
24
|
+
}
|
|
25
|
+
copyPublic() {
|
|
26
|
+
return Promise.resolve();
|
|
27
|
+
}
|
|
28
|
+
writePackageJson() {
|
|
29
|
+
return Promise.resolve();
|
|
30
|
+
}
|
|
31
|
+
async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
|
|
32
|
+
return this._bundle(entryFile, entryFile, { outputDirectory, projectRoot }, toolsPaths);
|
|
33
|
+
}
|
|
34
|
+
async lint(entryFile, outputDirectory, toolsPaths) {
|
|
35
|
+
await super.lint(entryFile, outputDirectory, toolsPaths);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.BuildBundler = BuildBundler;
|
|
40
|
+
//# sourceMappingURL=mastra-deployer-YVT5GB5G.cjs.map
|
|
41
|
+
//# sourceMappingURL=mastra-deployer-YVT5GB5G.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mastra-deployer.ts"],"names":["Bundler"],"mappings":";;;;;AAGO,IAAM,YAAA,GAAN,cAA2BA,eAAA,CAAQ;AAAA,EACxC,WAAA,GAAc;AACZ,IAAA,KAAA,CAAM,UAAU,CAAA;AAChB,IAAA,IAAA,CAAK,QAAA,GAAW,OAAA,CAAQ,QAAA,EAAU,GAAA,GAAM,SAAA,GAAY,MAAA;AAAA,EACtD;AAAA,EAEA,MAAgB,qBAAA,CACd,eAAA,EACA,eAAA,EACyC;AACzC,IAAA,MAAM,cAAA,GAAiB,MAAM,KAAA,CAAM,qBAAA,CAAsB,iBAAiB,eAAe,CAAA;AAEzF,IAAA,OAAO;AAAA,MACL,GAAG,cAAA;AAAA,MACH,SAAA,EAAW,IAAA;AAAA,MACX,SAAA,EAAW;AAAA,KACb;AAAA,EACF;AAAA,EAEA,WAAA,GAAiC;AAC/B,IAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,EAAE,CAAA;AAAA,EAC3B;AAAA,EAEU,mBAAA,GAAqC;AAC7C,IAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,EACzB;AAAA,EAEU,UAAA,GAA4B;AACpC,IAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,EACzB;AAAA,EAEA,gBAAA,GAAkC;AAChC,IAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,EACzB;AAAA,EAEA,MAAM,MAAA,CACJ,SAAA,EACA,iBACA,EAAE,UAAA,EAAY,aAAY,EACX;AACf,IAAA,OAAO,IAAA,CAAK,QAAQ,SAAA,EAAW,SAAA,EAAW,EAAE,eAAA,EAAiB,WAAA,IAAe,UAAU,CAAA;AAAA,EACxF;AAAA,EAEA,MAAM,IAAA,CAAK,SAAA,EAAmB,eAAA,EAAyB,UAAA,EAAkD;AACvG,IAAA,MAAM,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,eAAA,EAAiB,UAAU,CAAA;AAAA,EACzD;AACF","file":"mastra-deployer-YVT5GB5G.cjs","sourcesContent":["import type { Config } from '@mastra/core/mastra';\nimport { Bundler } from '@mastra/deployer/bundler';\n\nexport class BuildBundler extends Bundler {\n constructor() {\n super('Temporal');\n this.platform = process.versions?.bun ? 'neutral' : 'node';\n }\n\n protected async getUserBundlerOptions(\n mastraEntryFile: string,\n outputDirectory: string,\n ): Promise<NonNullable<Config['bundler']>> {\n const bundlerOptions = await super.getUserBundlerOptions(mastraEntryFile, outputDirectory);\n\n return {\n ...bundlerOptions,\n externals: true,\n sourcemap: true,\n };\n }\n\n getEnvFiles(): Promise<string[]> {\n return Promise.resolve([]);\n }\n\n protected installDependencies(): Promise<void> {\n return Promise.resolve();\n }\n\n protected copyPublic(): Promise<void> {\n return Promise.resolve();\n }\n\n writePackageJson(): Promise<void> {\n return Promise.resolve();\n }\n\n async bundle(\n entryFile: string,\n outputDirectory: string,\n { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void> {\n return this._bundle(entryFile, entryFile, { outputDirectory, projectRoot }, toolsPaths);\n }\n\n async lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n await super.lint(entryFile, outputDirectory, toolsPaths);\n }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Config } from '@mastra/core/mastra';
|
|
2
|
+
import { Bundler } from '@mastra/deployer/bundler';
|
|
3
|
+
export declare class BuildBundler extends Bundler {
|
|
4
|
+
constructor();
|
|
5
|
+
protected getUserBundlerOptions(mastraEntryFile: string, outputDirectory: string): Promise<NonNullable<Config['bundler']>>;
|
|
6
|
+
getEnvFiles(): Promise<string[]>;
|
|
7
|
+
protected installDependencies(): Promise<void>;
|
|
8
|
+
protected copyPublic(): Promise<void>;
|
|
9
|
+
writePackageJson(): Promise<void>;
|
|
10
|
+
bundle(entryFile: string, outputDirectory: string, { toolsPaths, projectRoot }: {
|
|
11
|
+
toolsPaths: (string | string[])[];
|
|
12
|
+
projectRoot: string;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=mastra-deployer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mastra-deployer.d.ts","sourceRoot":"","sources":["../src/mastra-deployer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,qBAAa,YAAa,SAAQ,OAAO;;cAMvB,qBAAqB,CACnC,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAU1C,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIhC,SAAS,CAAC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9C,SAAS,CAAC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrC,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,MAAM,CACV,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE;QAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GACtF,OAAO,CAAC,IAAI,CAAC;IAIV,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAGzG"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { WorkerOptions, WorkerPlugin } from '@temporalio/worker';
|
|
2
|
+
export declare class MastraPlugin implements WorkerPlugin {
|
|
3
|
+
#private;
|
|
4
|
+
name: string;
|
|
5
|
+
constructor();
|
|
6
|
+
prebuild({ entryFile, projectRoot, }: {
|
|
7
|
+
entryFile: string;
|
|
8
|
+
projectRoot?: string;
|
|
9
|
+
}): Promise<ReturnType<typeof this.getTemporalWorkerOptions>>;
|
|
10
|
+
getTemporalWorkerOptions(temporalOutputDir: string): {
|
|
11
|
+
workflowsPath: WorkerOptions['workflowsPath'];
|
|
12
|
+
activities: WorkerOptions['activities'];
|
|
13
|
+
};
|
|
14
|
+
configureWorker(options: WorkerOptions): WorkerOptions;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAsBtE,qBAAa,YAAa,YAAW,YAAY;;IAG/C,IAAI,SAAY;;IAiBV,QAAQ,CAAC,EACb,SAAS,EACT,WAA2B,GAC5B,EAAE;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAoE7D,wBAAwB,CAAC,iBAAiB,EAAE,MAAM,GAAG;QAEnD,aAAa,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;QAC9C,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;KACzC;IAeD,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa;CAYvD"}
|
package/dist/run.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RequestContext } from '@mastra/core/di';
|
|
2
|
+
import { Run } from '@mastra/core/workflows';
|
|
3
|
+
import type { Step, WorkflowResult, WorkflowRunStartOptions } from '@mastra/core/workflows';
|
|
4
|
+
import type { Client } from '@temporalio/client';
|
|
5
|
+
import type { TemporalEngineType } from './types.js';
|
|
6
|
+
type TemporalRunStartArgs<TState, TInput, TRequestContext> = {
|
|
7
|
+
inputData?: TInput;
|
|
8
|
+
initialState?: TState;
|
|
9
|
+
requestContext?: RequestContext<TRequestContext>;
|
|
10
|
+
} & WorkflowRunStartOptions;
|
|
11
|
+
export declare class TemporalRun<TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<string, unknown, unknown, unknown, unknown, unknown, TemporalEngineType>[], TState = unknown, TInput = unknown, TOutput = unknown, TRequestContext extends Record<string, any> | unknown = unknown> extends Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext> {
|
|
12
|
+
private readonly client;
|
|
13
|
+
private readonly taskQueue;
|
|
14
|
+
constructor(params: ConstructorParameters<typeof Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>>[0], temporalParams: {
|
|
15
|
+
client: Client;
|
|
16
|
+
taskQueue: string;
|
|
17
|
+
});
|
|
18
|
+
start(args?: TemporalRunStartArgs<TState, TInput, TRequestContext>): Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>;
|
|
19
|
+
startAsync(args?: TemporalRunStartArgs<TState, TInput, TRequestContext>): Promise<{
|
|
20
|
+
runId: string;
|
|
21
|
+
}>;
|
|
22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