@primero.ai/temporal-graph-tools 1.1.1 → 1.2.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/README.md +23 -3
- package/dist/examples/mastra-ai-workflow/activities/classify-outage-with-ai.d.ts +13 -0
- package/dist/examples/mastra-ai-workflow/activities/classify-outage-with-ai.d.ts.map +1 -0
- package/dist/examples/mastra-ai-workflow/activities/classify-outage-with-ai.js +109 -0
- package/dist/examples/mastra-ai-workflow/activities/draft-response-with-ai.d.ts +12 -0
- package/dist/examples/mastra-ai-workflow/activities/draft-response-with-ai.d.ts.map +1 -0
- package/dist/examples/mastra-ai-workflow/activities/draft-response-with-ai.js +69 -0
- package/dist/examples/mastra-ai-workflow/activities/enrich-outage-description.d.ts +8 -0
- package/dist/examples/mastra-ai-workflow/activities/enrich-outage-description.d.ts.map +1 -0
- package/dist/examples/mastra-ai-workflow/activities/enrich-outage-description.js +37 -0
- package/dist/examples/mastra-ai-workflow/activities/index.d.ts +11 -0
- package/dist/examples/mastra-ai-workflow/activities/index.d.ts.map +1 -0
- package/dist/examples/mastra-ai-workflow/activities/index.js +5 -0
- package/dist/examples/mastra-ai-workflow/activities/submit-response.d.ts +7 -0
- package/dist/examples/mastra-ai-workflow/activities/submit-response.d.ts.map +1 -0
- package/dist/examples/mastra-ai-workflow/activities/submit-response.js +15 -0
- package/dist/examples/mastra-ai-workflow/activities/take-ticket.d.ts +16 -0
- package/dist/examples/mastra-ai-workflow/activities/take-ticket.d.ts.map +1 -0
- package/dist/examples/mastra-ai-workflow/activities/take-ticket.js +16 -0
- package/dist/examples/mastra-ai-workflow/workflows.d.ts +2 -0
- package/dist/examples/mastra-ai-workflow/workflows.d.ts.map +1 -0
- package/dist/examples/mastra-ai-workflow/workflows.js +11 -0
- package/dist/examples/mastra-example.d.ts +2 -0
- package/dist/examples/mastra-example.d.ts.map +1 -0
- package/dist/examples/mastra-example.js +103 -0
- package/dist/examples/normal-workflow/activities.d.ts.map +1 -0
- package/dist/examples/{bundle → normal-workflow}/activities.js +6 -3
- package/dist/examples/normal-workflow/workflows.d.ts.map +1 -0
- package/dist/examples/trigger-mastra-workflow.d.ts +2 -0
- package/dist/examples/trigger-mastra-workflow.d.ts.map +1 -0
- package/dist/examples/trigger-mastra-workflow.js +42 -0
- package/dist/examples/trigger-normal-workflow.d.ts +2 -0
- package/dist/examples/trigger-normal-workflow.d.ts.map +1 -0
- package/dist/examples/{trigger-workflows.js → trigger-normal-workflow.js} +1 -1
- package/dist/examples/worker.d.ts.map +1 -1
- package/dist/examples/worker.js +17 -3
- package/dist/src/bundler.d.ts +1 -0
- package/dist/src/bundler.d.ts.map +1 -1
- package/dist/src/bundler.js +125 -41
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/mastra/agent-wrapper.d.ts +16 -0
- package/dist/src/mastra/agent-wrapper.d.ts.map +1 -0
- package/dist/src/mastra/agent-wrapper.js +13 -0
- package/dist/src/mastra/create-activity-with-mastra.d.ts +31 -0
- package/dist/src/mastra/create-activity-with-mastra.d.ts.map +1 -0
- package/dist/src/mastra/create-activity-with-mastra.js +39 -0
- package/dist/src/types.d.ts +24 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +29 -0
- package/dist/src/utils/deep-equal.d.ts.map +1 -1
- package/dist/src/utils/deep-equal.js +40 -13
- package/dist/src/workflow/builder.d.ts +2 -0
- package/dist/src/workflow/builder.d.ts.map +1 -1
- package/dist/src/workflow/builder.js +52 -8
- package/dist/src/workflow/collection.d.ts.map +1 -1
- package/dist/src/workflow/collection.js +20 -11
- package/dist/src/workflow-bundler.d.ts +3 -3
- package/dist/src/workflow-bundler.d.ts.map +1 -1
- package/dist/src/workflow-bundler.js +39 -28
- package/package.json +22 -11
- package/dist/examples/bundle/activities.d.ts.map +0 -1
- package/dist/examples/bundle/workflows.d.ts.map +0 -1
- package/dist/examples/trigger-workflows.d.ts +0 -2
- package/dist/examples/trigger-workflows.d.ts.map +0 -1
- /package/dist/examples/{bundle → normal-workflow}/activities.d.ts +0 -0
- /package/dist/examples/{bundle → normal-workflow}/workflows.d.ts +0 -0
- /package/dist/examples/{bundle → normal-workflow}/workflows.js +0 -0
package/README.md
CHANGED
|
@@ -37,15 +37,22 @@ import {
|
|
|
37
37
|
bundleWorkflows,
|
|
38
38
|
createActivity,
|
|
39
39
|
createWorkflowBuilder,
|
|
40
|
+
wrapActivityWithMastraContext,
|
|
40
41
|
} from '@primero.ai/temporal-graph-tools'
|
|
41
42
|
|
|
42
43
|
type FetchUserInput = { userId: string }
|
|
43
44
|
type FetchUserOutput = { profile: { id: string; name: string } }
|
|
44
45
|
|
|
45
46
|
const fetchUserProfile = createActivity(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
wrapActivityWithMastraContext(
|
|
48
|
+
async ({ userId }: FetchUserInput): Promise<FetchUserOutput> => {
|
|
49
|
+
return { profile: { id: userId, name: `User ${userId}` } }
|
|
50
|
+
},
|
|
51
|
+
async ({ context, execute }) => {
|
|
52
|
+
console.log(`[mastra] node=${context?.node.key} stage=${context?.node.stageIndex}`)
|
|
53
|
+
return execute()
|
|
54
|
+
},
|
|
55
|
+
),
|
|
49
56
|
{ id: 'fetchUserProfile' },
|
|
50
57
|
)
|
|
51
58
|
|
|
@@ -140,6 +147,19 @@ object is provided its `id` becomes the activity key; without options the
|
|
|
140
147
|
function name (or an auto-incremented fallback) is used. The helper is also
|
|
141
148
|
re-exported as `createActivity` for codebases that prefer plural naming.
|
|
142
149
|
|
|
150
|
+
### `wrapActivityWithMastraContext(activityFn, wrapper)`
|
|
151
|
+
|
|
152
|
+
Wraps an activity with a Mastra-style execution hook. The generated workflow now
|
|
153
|
+
passes a second argument to each node with:
|
|
154
|
+
|
|
155
|
+
- `workflow.name`
|
|
156
|
+
- `graph.totalStages`
|
|
157
|
+
- `node` (`key`, `stageIndex`, `stageType`, optional `branchIndex`)
|
|
158
|
+
- `previousNode`
|
|
159
|
+
|
|
160
|
+
Use this wrapper to add tracing, logging, metrics, or custom context plumbing
|
|
161
|
+
before and after calling `execute()`.
|
|
162
|
+
|
|
143
163
|
## Workflow bundler utilities
|
|
144
164
|
|
|
145
165
|
### `bundleWorkflows(plans, options?)`
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TicketIntake } from './take-ticket';
|
|
2
|
+
export type TicketIntent = 'connectivity' | 'billing' | 'account';
|
|
3
|
+
export type TicketUrgency = 'low' | 'medium' | 'high';
|
|
4
|
+
export type AiClassification = {
|
|
5
|
+
provider: string;
|
|
6
|
+
model: string;
|
|
7
|
+
intent: TicketIntent;
|
|
8
|
+
urgency: TicketUrgency;
|
|
9
|
+
summary: string;
|
|
10
|
+
recommendedFix: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const classifyOutageWithAi: import("@primero.ai/temporal-graph-tools").ConfiguredActivityReference<TicketIntake, AiClassification, "classifyOutageWithAi">;
|
|
13
|
+
//# sourceMappingURL=classify-outage-with-ai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classify-outage-with-ai.d.ts","sourceRoot":"","sources":["../../../../examples/mastra-ai-workflow/activities/classify-outage-with-ai.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,SAAS,GAAG,SAAS,CAAA;AACjE,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;AAErD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,YAAY,CAAA;IACpB,OAAO,EAAE,aAAa,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AA8ED,eAAO,MAAM,oBAAoB,gIAqDhC,CAAA"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { createActivityWithMastra, } from '@primero.ai/temporal-graph-tools';
|
|
3
|
+
import { openai } from '@ai-sdk/openai';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
function logMastraContext(context) {
|
|
6
|
+
var _a, _b, _c, _d, _e;
|
|
7
|
+
if (!(context === null || context === void 0 ? void 0 : context.node)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
console.log(`[mastra-ai] node=${(_a = context.node.key) !== null && _a !== void 0 ? _a : 'unknown'} stage=${(_b = context.node.stageIndex) !== null && _b !== void 0 ? _b : -1} type=${(_c = context.node.stageType) !== null && _c !== void 0 ? _c : 'unknown'} previous=${(_e = (_d = context.previousNode) === null || _d === void 0 ? void 0 : _d.key) !== null && _e !== void 0 ? _e : 'none'}`);
|
|
11
|
+
}
|
|
12
|
+
function inferIntent(message) {
|
|
13
|
+
const normalized = message.toLowerCase();
|
|
14
|
+
if (normalized.includes('invoice') || normalized.includes('refund') || normalized.includes('charge')) {
|
|
15
|
+
return 'billing';
|
|
16
|
+
}
|
|
17
|
+
if (normalized.includes('password') || normalized.includes('login') || normalized.includes('2fa')) {
|
|
18
|
+
return 'account';
|
|
19
|
+
}
|
|
20
|
+
return 'connectivity';
|
|
21
|
+
}
|
|
22
|
+
function inferUrgency(message) {
|
|
23
|
+
const normalized = message.toLowerCase();
|
|
24
|
+
if (normalized.includes('urgent') || normalized.includes('down') || normalized.includes('cannot work')) {
|
|
25
|
+
return 'high';
|
|
26
|
+
}
|
|
27
|
+
if (normalized.includes('soon') || normalized.includes('today')) {
|
|
28
|
+
return 'medium';
|
|
29
|
+
}
|
|
30
|
+
return 'low';
|
|
31
|
+
}
|
|
32
|
+
function inferRootCause(message) {
|
|
33
|
+
const normalized = message.toLowerCase();
|
|
34
|
+
const providerOutage = /provider outage|isp outage|service outage/.test(normalized);
|
|
35
|
+
const localIssue = /router|wifi|internet not working|local network|modem/.test(normalized);
|
|
36
|
+
if (localIssue && !providerOutage) {
|
|
37
|
+
return 'local-network';
|
|
38
|
+
}
|
|
39
|
+
if (providerOutage) {
|
|
40
|
+
return 'provider-outage';
|
|
41
|
+
}
|
|
42
|
+
return 'unknown';
|
|
43
|
+
}
|
|
44
|
+
const modelId = (_a = process.env.MASTRA_AI_MODEL) !== null && _a !== void 0 ? _a : 'gpt-4o-mini';
|
|
45
|
+
const classificationOutputSchema = z.object({
|
|
46
|
+
intent: z.enum(['connectivity', 'billing', 'account']),
|
|
47
|
+
urgency: z.enum(['low', 'medium', 'high']),
|
|
48
|
+
summary: z.string(),
|
|
49
|
+
recommendedFix: z.string(),
|
|
50
|
+
});
|
|
51
|
+
const classificationAgentContext = {};
|
|
52
|
+
const classificationMastraInput = {
|
|
53
|
+
agentInput: {
|
|
54
|
+
id: 'mastra-outage-classifier',
|
|
55
|
+
name: 'Mastra Outage Classifier',
|
|
56
|
+
instructions: [
|
|
57
|
+
'You classify support tickets and propose precise remediation.',
|
|
58
|
+
'If the outage seems local-network and no provider outage is reported, recommend restarting the router.',
|
|
59
|
+
'Return concise and operational output.',
|
|
60
|
+
].join(' '),
|
|
61
|
+
model: openai(modelId),
|
|
62
|
+
},
|
|
63
|
+
agentContext: classificationAgentContext,
|
|
64
|
+
};
|
|
65
|
+
export const classifyOutageWithAi = createActivityWithMastra({
|
|
66
|
+
id: 'classifyOutageWithAi',
|
|
67
|
+
onMastraContext: logMastraContext,
|
|
68
|
+
mastraInput: classificationMastraInput,
|
|
69
|
+
}, async ({ input: ticket, agent }) => {
|
|
70
|
+
var _a;
|
|
71
|
+
const provider = (_a = process.env.MASTRA_AI_PROVIDER) !== null && _a !== void 0 ? _a : 'openai';
|
|
72
|
+
const fallbackIntent = inferIntent(ticket.outageDescription);
|
|
73
|
+
const fallbackUrgency = inferUrgency(ticket.outageDescription);
|
|
74
|
+
const fallbackSummary = ticket.outageDescription.slice(0, 180);
|
|
75
|
+
const fallbackRootCause = inferRootCause(ticket.outageDescription);
|
|
76
|
+
const fallbackFix = fallbackRootCause === 'local-network'
|
|
77
|
+
? 'Restart the router and wait 2 minutes before reconnecting devices.'
|
|
78
|
+
: 'Collect diagnostics and continue support triage.';
|
|
79
|
+
try {
|
|
80
|
+
const parsed = await agent({
|
|
81
|
+
prompt: [
|
|
82
|
+
`Ticket ID: ${ticket.ticketId}`,
|
|
83
|
+
`Client: ${ticket.client.name} (${ticket.client.accountId}) at ${ticket.client.site}`,
|
|
84
|
+
`Outage Description: ${ticket.outageDescription}`,
|
|
85
|
+
'Classify and provide recommended fix.',
|
|
86
|
+
].join('\n'),
|
|
87
|
+
schema: classificationOutputSchema,
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
provider,
|
|
91
|
+
model: modelId,
|
|
92
|
+
intent: parsed.intent,
|
|
93
|
+
urgency: parsed.urgency,
|
|
94
|
+
summary: parsed.summary,
|
|
95
|
+
recommendedFix: parsed.recommendedFix,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
console.warn('[mastra-ai] classifyOutageWithAi fallback:', error);
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
provider,
|
|
103
|
+
model: modelId,
|
|
104
|
+
intent: fallbackIntent,
|
|
105
|
+
urgency: fallbackUrgency,
|
|
106
|
+
summary: fallbackSummary,
|
|
107
|
+
recommendedFix: fallbackFix,
|
|
108
|
+
};
|
|
109
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AiClassification } from './classify-outage-with-ai';
|
|
2
|
+
import type { EnrichedDescription } from './enrich-outage-description';
|
|
3
|
+
export type ParallelAnalysis = {
|
|
4
|
+
classifyOutageWithAi: AiClassification;
|
|
5
|
+
enrichOutageDescription: EnrichedDescription;
|
|
6
|
+
};
|
|
7
|
+
export type DraftResponse = {
|
|
8
|
+
subject: string;
|
|
9
|
+
body: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const draftResponseWithAi: import("@primero.ai/temporal-graph-tools").ConfiguredActivityReference<ParallelAnalysis, DraftResponse, "draftResponseWithAi">;
|
|
12
|
+
//# sourceMappingURL=draft-response-with-ai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draft-response-with-ai.d.ts","sourceRoot":"","sources":["../../../../examples/mastra-ai-workflow/activities/draft-response-with-ai.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAEtE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,oBAAoB,EAAE,gBAAgB,CAAA;IACtC,uBAAuB,EAAE,mBAAmB,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AA+BD,eAAO,MAAM,mBAAmB,gIAgD/B,CAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { createActivityWithMastra, } from '@primero.ai/temporal-graph-tools';
|
|
3
|
+
import { openai } from '@ai-sdk/openai';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
function logMastraContext(context) {
|
|
6
|
+
var _a, _b, _c, _d, _e;
|
|
7
|
+
if (!(context === null || context === void 0 ? void 0 : context.node)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
console.log(`[mastra-ai] node=${(_a = context.node.key) !== null && _a !== void 0 ? _a : 'unknown'} stage=${(_b = context.node.stageIndex) !== null && _b !== void 0 ? _b : -1} type=${(_c = context.node.stageType) !== null && _c !== void 0 ? _c : 'unknown'} previous=${(_e = (_d = context.previousNode) === null || _d === void 0 ? void 0 : _d.key) !== null && _e !== void 0 ? _e : 'none'}`);
|
|
11
|
+
}
|
|
12
|
+
const modelId = (_a = process.env.MASTRA_AI_MODEL) !== null && _a !== void 0 ? _a : 'gpt-4o-mini';
|
|
13
|
+
const responseOutputSchema = z.object({
|
|
14
|
+
subject: z.string(),
|
|
15
|
+
body: z.string(),
|
|
16
|
+
});
|
|
17
|
+
const responseAgentContext = {};
|
|
18
|
+
const responseMastraInput = {
|
|
19
|
+
agentInput: {
|
|
20
|
+
id: 'mastra-response-writer',
|
|
21
|
+
name: 'Mastra Response Writer',
|
|
22
|
+
instructions: [
|
|
23
|
+
'You write short, professional customer responses for internet incidents.',
|
|
24
|
+
'If evidence indicates local-network issue without provider outage, explicitly instruct router restart.',
|
|
25
|
+
].join(' '),
|
|
26
|
+
model: openai(modelId),
|
|
27
|
+
},
|
|
28
|
+
agentContext: responseAgentContext,
|
|
29
|
+
};
|
|
30
|
+
export const draftResponseWithAi = createActivityWithMastra({
|
|
31
|
+
id: 'draftResponseWithAi',
|
|
32
|
+
onMastraContext: logMastraContext,
|
|
33
|
+
mastraInput: responseMastraInput,
|
|
34
|
+
}, async ({ input: analysis, agent }) => {
|
|
35
|
+
const { classifyOutageWithAi: ai, enrichOutageDescription: enriched } = analysis;
|
|
36
|
+
const fallbackSubject = `[${ai.intent.toUpperCase()}][${ai.urgency}] Internet Incident`;
|
|
37
|
+
const fallbackBody = [
|
|
38
|
+
`Hi ${enriched.client.name},`,
|
|
39
|
+
'',
|
|
40
|
+
`We analyzed your report: ${ai.summary}`,
|
|
41
|
+
`Enriched context: ${enriched.rewrittenDescription}`,
|
|
42
|
+
'',
|
|
43
|
+
`Recommended action: ${ai.recommendedFix}`,
|
|
44
|
+
'',
|
|
45
|
+
'Please confirm once the router has restarted and devices are reconnected.',
|
|
46
|
+
].join('\n');
|
|
47
|
+
try {
|
|
48
|
+
const parsed = await agent({
|
|
49
|
+
prompt: [
|
|
50
|
+
`Client: ${enriched.client.name} (${enriched.client.accountId}) at ${enriched.client.site}`,
|
|
51
|
+
`Classification Intent: ${ai.intent}`,
|
|
52
|
+
`Classification Urgency: ${ai.urgency}`,
|
|
53
|
+
`Classification Summary: ${ai.summary}`,
|
|
54
|
+
`Enriched Description: ${enriched.rewrittenDescription}`,
|
|
55
|
+
`Required Recommendation: ${ai.recommendedFix}`,
|
|
56
|
+
'Generate a support response for the client.',
|
|
57
|
+
].join('\n'),
|
|
58
|
+
schema: responseOutputSchema,
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
subject: parsed.subject,
|
|
62
|
+
body: parsed.body,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.warn('[mastra-ai] draftResponseWithAi fallback:', error);
|
|
67
|
+
}
|
|
68
|
+
return { subject: fallbackSubject, body: fallbackBody };
|
|
69
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TicketIntake } from './take-ticket';
|
|
2
|
+
export type EnrichedDescription = {
|
|
3
|
+
client: TicketIntake['client'];
|
|
4
|
+
rewrittenDescription: string;
|
|
5
|
+
inferredRootCause: 'local-network' | 'provider-outage' | 'unknown';
|
|
6
|
+
};
|
|
7
|
+
export declare const enrichOutageDescription: import("@primero.ai/temporal-graph-tools").ConfiguredActivityReference<TicketIntake, EnrichedDescription, "enrichOutageDescription">;
|
|
8
|
+
//# sourceMappingURL=enrich-outage-description.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrich-outage-description.d.ts","sourceRoot":"","sources":["../../../../examples/mastra-ai-workflow/activities/enrich-outage-description.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAA;IAC9B,oBAAoB,EAAE,MAAM,CAAA;IAC5B,iBAAiB,EAAE,eAAe,GAAG,iBAAiB,GAAG,SAAS,CAAA;CACnE,CAAA;AA4BD,eAAO,MAAM,uBAAuB,sIAwBnC,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createActivityWithMastra } from '@primero.ai/temporal-graph-tools';
|
|
2
|
+
function logMastraContext(context) {
|
|
3
|
+
var _a, _b, _c, _d, _e;
|
|
4
|
+
if (!(context === null || context === void 0 ? void 0 : context.node)) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
console.log(`[mastra-ai] node=${(_a = context.node.key) !== null && _a !== void 0 ? _a : 'unknown'} stage=${(_b = context.node.stageIndex) !== null && _b !== void 0 ? _b : -1} type=${(_c = context.node.stageType) !== null && _c !== void 0 ? _c : 'unknown'} previous=${(_e = (_d = context.previousNode) === null || _d === void 0 ? void 0 : _d.key) !== null && _e !== void 0 ? _e : 'none'}`);
|
|
8
|
+
}
|
|
9
|
+
function inferRootCause(message) {
|
|
10
|
+
const normalized = message.toLowerCase();
|
|
11
|
+
const providerOutage = /provider outage|isp outage|service outage/.test(normalized);
|
|
12
|
+
const localIssue = /router|wifi|internet not working|local network|modem/.test(normalized);
|
|
13
|
+
if (localIssue && !providerOutage) {
|
|
14
|
+
return 'local-network';
|
|
15
|
+
}
|
|
16
|
+
if (providerOutage) {
|
|
17
|
+
return 'provider-outage';
|
|
18
|
+
}
|
|
19
|
+
return 'unknown';
|
|
20
|
+
}
|
|
21
|
+
export const enrichOutageDescription = createActivityWithMastra({
|
|
22
|
+
id: 'enrichOutageDescription',
|
|
23
|
+
onMastraContext: logMastraContext,
|
|
24
|
+
}, async ({ input: ticket }) => {
|
|
25
|
+
const rootCause = inferRootCause(ticket.outageDescription);
|
|
26
|
+
const rewrittenDescription = [
|
|
27
|
+
`Client ${ticket.client.name} (${ticket.client.accountId}) at ${ticket.client.site} reports internet connectivity failure.`,
|
|
28
|
+
`Raw report: ${ticket.outageDescription}`,
|
|
29
|
+
`AI enrichment indicates likely cause: ${rootCause}.`,
|
|
30
|
+
'No broad service outage is reported by the client.',
|
|
31
|
+
].join(' ');
|
|
32
|
+
return {
|
|
33
|
+
client: ticket.client,
|
|
34
|
+
rewrittenDescription,
|
|
35
|
+
inferredRootCause: rootCause,
|
|
36
|
+
};
|
|
37
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { classifyOutageWithAi } from './classify-outage-with-ai';
|
|
2
|
+
export { draftResponseWithAi } from './draft-response-with-ai';
|
|
3
|
+
export { enrichOutageDescription } from './enrich-outage-description';
|
|
4
|
+
export { submitResponse } from './submit-response';
|
|
5
|
+
export { takeTicket } from './take-ticket';
|
|
6
|
+
export type { AiClassification, TicketIntent, TicketUrgency } from './classify-outage-with-ai';
|
|
7
|
+
export type { DraftResponse, ParallelAnalysis } from './draft-response-with-ai';
|
|
8
|
+
export type { EnrichedDescription } from './enrich-outage-description';
|
|
9
|
+
export type { SubmittedResponse } from './submit-response';
|
|
10
|
+
export type { SupportTicketInput, TicketIntake } from './take-ticket';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../examples/mastra-ai-workflow/activities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9F,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC/E,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACtE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { classifyOutageWithAi } from './classify-outage-with-ai';
|
|
2
|
+
export { draftResponseWithAi } from './draft-response-with-ai';
|
|
3
|
+
export { enrichOutageDescription } from './enrich-outage-description';
|
|
4
|
+
export { submitResponse } from './submit-response';
|
|
5
|
+
export { takeTicket } from './take-ticket';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DraftResponse } from './draft-response-with-ai';
|
|
2
|
+
export type SubmittedResponse = {
|
|
3
|
+
ready: true;
|
|
4
|
+
response: DraftResponse;
|
|
5
|
+
};
|
|
6
|
+
export declare const submitResponse: import("@primero.ai/temporal-graph-tools").ConfiguredActivityReference<DraftResponse, SubmittedResponse, "submitResponse">;
|
|
7
|
+
//# sourceMappingURL=submit-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submit-response.d.ts","sourceRoot":"","sources":["../../../../examples/mastra-ai-workflow/activities/submit-response.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE7D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,IAAI,CAAA;IACX,QAAQ,EAAE,aAAa,CAAA;CACxB,CAAA;AAYD,eAAO,MAAM,cAAc,4HAS1B,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createActivityWithMastra } from '@primero.ai/temporal-graph-tools';
|
|
2
|
+
function logMastraContext(context) {
|
|
3
|
+
var _a, _b, _c, _d, _e;
|
|
4
|
+
if (!(context === null || context === void 0 ? void 0 : context.node)) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
console.log(`[mastra-ai] node=${(_a = context.node.key) !== null && _a !== void 0 ? _a : 'unknown'} stage=${(_b = context.node.stageIndex) !== null && _b !== void 0 ? _b : -1} type=${(_c = context.node.stageType) !== null && _c !== void 0 ? _c : 'unknown'} previous=${(_e = (_d = context.previousNode) === null || _d === void 0 ? void 0 : _d.key) !== null && _e !== void 0 ? _e : 'none'}`);
|
|
8
|
+
}
|
|
9
|
+
export const submitResponse = createActivityWithMastra({
|
|
10
|
+
id: 'submitResponse',
|
|
11
|
+
onMastraContext: logMastraContext,
|
|
12
|
+
}, async ({ input: draft }) => ({
|
|
13
|
+
ready: true,
|
|
14
|
+
response: draft,
|
|
15
|
+
}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type SupportTicketInput = {
|
|
2
|
+
ticketId: string;
|
|
3
|
+
client: {
|
|
4
|
+
name: string;
|
|
5
|
+
accountId: string;
|
|
6
|
+
site: string;
|
|
7
|
+
};
|
|
8
|
+
outageDescription: string;
|
|
9
|
+
};
|
|
10
|
+
export type TicketIntake = {
|
|
11
|
+
ticketId: string;
|
|
12
|
+
client: SupportTicketInput['client'];
|
|
13
|
+
outageDescription: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const takeTicket: import("@primero.ai/temporal-graph-tools").ConfiguredActivityReference<SupportTicketInput, TicketIntake, "takeTicket">;
|
|
16
|
+
//# sourceMappingURL=take-ticket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"take-ticket.d.ts","sourceRoot":"","sources":["../../../../examples/mastra-ai-workflow/activities/take-ticket.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAA;QACZ,SAAS,EAAE,MAAM,CAAA;QACjB,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;IACD,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAA;IACpC,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA;AAYD,eAAO,MAAM,UAAU,wHAUtB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createActivityWithMastra } from '@primero.ai/temporal-graph-tools';
|
|
2
|
+
function logMastraContext(context) {
|
|
3
|
+
var _a, _b, _c, _d, _e;
|
|
4
|
+
if (!(context === null || context === void 0 ? void 0 : context.node)) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
console.log(`[mastra-ai] node=${(_a = context.node.key) !== null && _a !== void 0 ? _a : 'unknown'} stage=${(_b = context.node.stageIndex) !== null && _b !== void 0 ? _b : -1} type=${(_c = context.node.stageType) !== null && _c !== void 0 ? _c : 'unknown'} previous=${(_e = (_d = context.previousNode) === null || _d === void 0 ? void 0 : _d.key) !== null && _e !== void 0 ? _e : 'none'}`);
|
|
8
|
+
}
|
|
9
|
+
export const takeTicket = createActivityWithMastra({
|
|
10
|
+
id: 'takeTicket',
|
|
11
|
+
onMastraContext: logMastraContext,
|
|
12
|
+
}, async ({ input }) => ({
|
|
13
|
+
ticketId: input.ticketId,
|
|
14
|
+
client: input.client,
|
|
15
|
+
outageDescription: input.outageDescription.trim(),
|
|
16
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../../examples/mastra-ai-workflow/workflows.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,8BAA8B,gEAQhC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createWorkflowBuilder } from '@primero.ai/temporal-graph-tools';
|
|
2
|
+
import { classifyOutageWithAi, draftResponseWithAi, enrichOutageDescription, submitResponse, takeTicket, } from './activities';
|
|
3
|
+
export const builderMastraAiSupportWorkflow = createWorkflowBuilder({
|
|
4
|
+
workflowName: 'mastraAiSupportWorkflow',
|
|
5
|
+
proxyOptions: { startToCloseTimeout: '2 minutes' },
|
|
6
|
+
})
|
|
7
|
+
.then(takeTicket)
|
|
8
|
+
.parallel([classifyOutageWithAi, enrichOutageDescription])
|
|
9
|
+
.then(draftResponseWithAi)
|
|
10
|
+
.then(submitResponse)
|
|
11
|
+
.commit();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mastra-example.d.ts","sourceRoot":"","sources":["../../examples/mastra-example.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { createActivity, createWorkflowBuilder, wrapActivityWithMastraContext, } from '@primero.ai/temporal-graph-tools';
|
|
2
|
+
function withMastraLogging(id, activity) {
|
|
3
|
+
return createActivity(wrapActivityWithMastraContext(activity, async ({ context, execute }) => {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
if (context) {
|
|
6
|
+
console.log(`[mastra] workflow=${context.workflow.name} node=${context.node.key} type=${context.node.stageType} stage=${context.node.stageIndex} previous=${(_b = (_a = context.previousNode) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : 'none'}`);
|
|
7
|
+
}
|
|
8
|
+
return execute();
|
|
9
|
+
}), { id });
|
|
10
|
+
}
|
|
11
|
+
const normalizeLead = withMastraLogging('normalizeLead', async (input) => {
|
|
12
|
+
const normalizedEmail = input.email.trim().toLowerCase();
|
|
13
|
+
return {
|
|
14
|
+
id: normalizedEmail.split('@')[0],
|
|
15
|
+
name: input.name.trim(),
|
|
16
|
+
email: normalizedEmail,
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
const scoreLead = withMastraLogging('scoreLead', async (lead) => {
|
|
20
|
+
const score = lead.email.endsWith('.edu') ? 82 : 64;
|
|
21
|
+
return { lead, score };
|
|
22
|
+
});
|
|
23
|
+
const createCrmTask = withMastraLogging('createCrmTask', async ({ lead, score }) => {
|
|
24
|
+
return { taskId: `crm-${lead.id}-${score}`, queued: true };
|
|
25
|
+
});
|
|
26
|
+
const notifySales = withMastraLogging('notifySales', async ({ lead, score }) => {
|
|
27
|
+
console.log(`[sales] lead=${lead.email} score=${score}`);
|
|
28
|
+
return { channel: 'slack', sent: true };
|
|
29
|
+
});
|
|
30
|
+
const finalizeLead = withMastraLogging('finalizeLead', async (result) => {
|
|
31
|
+
console.log(`[finalize] task=${result.createCrmTask.taskId} notify=${result.notifySales.sent}`);
|
|
32
|
+
return { completed: true };
|
|
33
|
+
});
|
|
34
|
+
const builderMastra = createWorkflowBuilder({
|
|
35
|
+
workflowName: 'mastraLeadWorkflow',
|
|
36
|
+
proxyOptions: { startToCloseTimeout: '2 minutes' },
|
|
37
|
+
})
|
|
38
|
+
.then(normalizeLead)
|
|
39
|
+
.then(scoreLead)
|
|
40
|
+
.parallel([createCrmTask, notifySales])
|
|
41
|
+
.then(finalizeLead)
|
|
42
|
+
.commit();
|
|
43
|
+
function makeContext(workflowName, totalStages, node, previousNode) {
|
|
44
|
+
return {
|
|
45
|
+
workflow: { name: workflowName },
|
|
46
|
+
graph: { totalStages },
|
|
47
|
+
node,
|
|
48
|
+
previousNode,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
async function runLocalDryRun() {
|
|
52
|
+
console.log(`Workflow: ${builderMastra.workflowName}`);
|
|
53
|
+
console.log('\nGenerated workflow source:\n');
|
|
54
|
+
console.log(builderMastra.workflowSource);
|
|
55
|
+
const totalStages = 4;
|
|
56
|
+
const workflowName = builderMastra.workflowName;
|
|
57
|
+
const input = { name: ' Ada Lovelace ', email: 'Ada@Example.com ' };
|
|
58
|
+
const step0Node = {
|
|
59
|
+
key: 'normalizeLead',
|
|
60
|
+
stageIndex: 0,
|
|
61
|
+
stageType: 'step',
|
|
62
|
+
};
|
|
63
|
+
const normalized = await normalizeLead.activity(input, makeContext(workflowName, totalStages, step0Node, null));
|
|
64
|
+
const step1Node = {
|
|
65
|
+
key: 'scoreLead',
|
|
66
|
+
stageIndex: 1,
|
|
67
|
+
stageType: 'step',
|
|
68
|
+
};
|
|
69
|
+
const scored = await scoreLead.activity(normalized, makeContext(workflowName, totalStages, step1Node, step0Node));
|
|
70
|
+
const parallelNodeA = {
|
|
71
|
+
key: 'createCrmTask',
|
|
72
|
+
stageIndex: 2,
|
|
73
|
+
stageType: 'parallel',
|
|
74
|
+
branchIndex: 0,
|
|
75
|
+
};
|
|
76
|
+
const parallelNodeB = {
|
|
77
|
+
key: 'notifySales',
|
|
78
|
+
stageIndex: 2,
|
|
79
|
+
stageType: 'parallel',
|
|
80
|
+
branchIndex: 1,
|
|
81
|
+
};
|
|
82
|
+
const [crmTask, salesMessage] = await Promise.all([
|
|
83
|
+
createCrmTask.activity(scored, makeContext(workflowName, totalStages, parallelNodeA, step1Node)),
|
|
84
|
+
notifySales.activity(scored, makeContext(workflowName, totalStages, parallelNodeB, step1Node)),
|
|
85
|
+
]);
|
|
86
|
+
const step3Node = {
|
|
87
|
+
key: 'finalizeLead',
|
|
88
|
+
stageIndex: 3,
|
|
89
|
+
stageType: 'step',
|
|
90
|
+
};
|
|
91
|
+
const parallelAggregateNode = {
|
|
92
|
+
key: 'parallel_2',
|
|
93
|
+
stageIndex: 2,
|
|
94
|
+
stageType: 'parallel',
|
|
95
|
+
};
|
|
96
|
+
const finalResult = await finalizeLead.activity({ createCrmTask: crmTask, notifySales: salesMessage }, makeContext(workflowName, totalStages, step3Node, parallelAggregateNode));
|
|
97
|
+
console.log('\nDry run result:');
|
|
98
|
+
console.log(finalResult);
|
|
99
|
+
}
|
|
100
|
+
runLocalDryRun().catch((error) => {
|
|
101
|
+
console.error('Mastra example failed:', error);
|
|
102
|
+
process.exitCode = 1;
|
|
103
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activities.d.ts","sourceRoot":"","sources":["../../../examples/normal-workflow/activities.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,cAAc,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAE/C,eAAO,MAAM,gBAAgB,6HA0B5B,CAAA;AAED,eAAO,MAAM,gBAAgB;UAC2B,OAAO;mBAAiB,MAAM;sBAOrF,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AACpE,MAAM,MAAM,eAAe,GAAG;IAAE,OAAO,EAAE,WAAW,CAAA;CAAE,CAAA;AAEtD,eAAO,MAAM,aAAa;YACgC,OAAO;gBAAc,MAAM;mBAOpF,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,gBAAgB,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1D,aAAa,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAA;CACvD,CAAA;AAED,eAAO,MAAM,aAAa,+GASzB,CAAA;AACD,eAAO,MAAM,UAAU,qGAA0E,CAAA;AACjG,eAAO,MAAM,QAAQ,mGAAuE,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import kebabCase from 'lodash/kebabCase.js';
|
|
2
|
-
import { createActivity, } from '@primero.ai/temporal-graph-tools';
|
|
3
|
-
export const fetchUserProfile = createActivity(async (input) => {
|
|
2
|
+
import { createActivity, wrapActivityWithMastraContext, } from '@primero.ai/temporal-graph-tools';
|
|
3
|
+
export const fetchUserProfile = createActivity(wrapActivityWithMastraContext(async (input) => {
|
|
4
4
|
const profileName = `User ${input.userId.slice(0, 6)}`;
|
|
5
5
|
const slug = kebabCase(profileName);
|
|
6
6
|
console.log(`[fetchUserProfile] fetching ${input.userId} as ${slug}`);
|
|
@@ -11,7 +11,10 @@ export const fetchUserProfile = createActivity(async (input) => {
|
|
|
11
11
|
slug,
|
|
12
12
|
},
|
|
13
13
|
};
|
|
14
|
-
}, {
|
|
14
|
+
}, async ({ context, execute }) => {
|
|
15
|
+
console.log(`[mastra] workflow=${context === null || context === void 0 ? void 0 : context.workflow.name} node=${context === null || context === void 0 ? void 0 : context.node.key} stage=${context === null || context === void 0 ? void 0 : context.node.stageIndex}`);
|
|
16
|
+
return execute();
|
|
17
|
+
}), {
|
|
15
18
|
id: 'fetchUserProfile',
|
|
16
19
|
});
|
|
17
20
|
export const sendWelcomeEmail = createActivity(async ({ profile }) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../../examples/normal-workflow/workflows.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,iBAAiB,gEAOnB,CAAA;AAEX,eAAO,MAAM,iBAAiB,gEAGnB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigger-mastra-workflow.d.ts","sourceRoot":"","sources":["../../examples/trigger-mastra-workflow.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Connection, WorkflowClient } from '@temporalio/client';
|
|
2
|
+
import { builderMastraAiSupportWorkflow } from './mastra-ai-workflow/workflows';
|
|
3
|
+
const DEFAULT_NAMESPACE = 'default';
|
|
4
|
+
const DEFAULT_TASK_QUEUE = 'default';
|
|
5
|
+
async function run() {
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
const connection = await Connection.connect({
|
|
8
|
+
address: (_a = process.env.TEMPORAL_ADDRESS) !== null && _a !== void 0 ? _a : 'localhost:7233',
|
|
9
|
+
tls: process.env.TEMPORAL_API_KEY ? {} : undefined,
|
|
10
|
+
apiKey: process.env.TEMPORAL_API_KEY,
|
|
11
|
+
});
|
|
12
|
+
const client = new WorkflowClient({
|
|
13
|
+
connection,
|
|
14
|
+
namespace: (_b = process.env.TEMPORAL_NAMESPACE) !== null && _b !== void 0 ? _b : DEFAULT_NAMESPACE,
|
|
15
|
+
});
|
|
16
|
+
const handle = await client.start(builderMastraAiSupportWorkflow.workflowName, {
|
|
17
|
+
taskQueue: (_c = process.env.TEMPORAL_TASK_QUEUE) !== null && _c !== void 0 ? _c : DEFAULT_TASK_QUEUE,
|
|
18
|
+
workflowId: `mastra-ai-support-${Date.now()}`,
|
|
19
|
+
args: [
|
|
20
|
+
{
|
|
21
|
+
ticketId: `ticket-${Date.now()}`,
|
|
22
|
+
client: {
|
|
23
|
+
name: 'Acme Ops',
|
|
24
|
+
accountId: 'acct-2048',
|
|
25
|
+
site: 'HQ - 3rd Floor',
|
|
26
|
+
},
|
|
27
|
+
outageDescription: 'Internet is not working on our office floor Wi-Fi. ISP status page is green and there is no service outage. Looks like a local router issue.',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
console.log('Mastra AI Workflow started:', {
|
|
32
|
+
workflowId: handle.workflowId,
|
|
33
|
+
runId: handle.firstExecutionRunId,
|
|
34
|
+
});
|
|
35
|
+
const result = await handle.result();
|
|
36
|
+
console.log('Mastra AI Workflow completed with result:', result);
|
|
37
|
+
await connection.close();
|
|
38
|
+
}
|
|
39
|
+
run().catch((error) => {
|
|
40
|
+
console.error('Failed to run mastra workflow trigger:', error);
|
|
41
|
+
process.exitCode = 1;
|
|
42
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigger-normal-workflow.d.ts","sourceRoot":"","sources":["../../examples/trigger-normal-workflow.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Connection, WorkflowClient } from '@temporalio/client';
|
|
2
|
-
import { builderHelloWorld, builderOnboarding } from './
|
|
2
|
+
import { builderHelloWorld, builderOnboarding } from './normal-workflow/workflows';
|
|
3
3
|
const DEFAULT_NAMESPACE = 'default';
|
|
4
4
|
const DEFAULT_TASK_QUEUE = 'default';
|
|
5
5
|
async function run() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../examples/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,uBAAuB,EAAU,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../examples/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,uBAAuB,EAAU,MAAM,oBAAoB,CAAA;AAKtF,wBAAgB,oBAAoB,IAAI,uBAAuB,CAM9D"}
|