@primero.ai/temporal-graph-tools 1.2.1 → 1.3.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.
Files changed (57) hide show
  1. package/dist/examples/mastra-ai-workflow/activities/classify-outage-with-ai.d.ts +1 -1
  2. package/dist/examples/mastra-ai-workflow/activities/classify-outage-with-ai.d.ts.map +1 -1
  3. package/dist/examples/mastra-ai-workflow/activities/classify-outage-with-ai.js +12 -26
  4. package/dist/examples/mastra-ai-workflow/activities/draft-response-with-ai.d.ts +1 -1
  5. package/dist/examples/mastra-ai-workflow/activities/draft-response-with-ai.d.ts.map +1 -1
  6. package/dist/examples/mastra-ai-workflow/activities/draft-response-with-ai.js +11 -25
  7. package/dist/examples/mastra-ai-workflow/activities/enrich-outage-description.d.ts +1 -1
  8. package/dist/examples/mastra-ai-workflow/activities/enrich-outage-description.d.ts.map +1 -1
  9. package/dist/examples/mastra-ai-workflow/activities/enrich-outage-description.js +2 -13
  10. package/dist/examples/mastra-ai-workflow/activities/index.d.ts +2 -2
  11. package/dist/examples/mastra-ai-workflow/activities/index.d.ts.map +1 -1
  12. package/dist/examples/mastra-ai-workflow/activities/submit-response.d.ts +1 -1
  13. package/dist/examples/mastra-ai-workflow/activities/submit-response.d.ts.map +1 -1
  14. package/dist/examples/mastra-ai-workflow/activities/submit-response.js +5 -14
  15. package/dist/examples/mastra-ai-workflow/activities/take-ticket.d.ts +1 -1
  16. package/dist/examples/mastra-ai-workflow/activities/take-ticket.d.ts.map +1 -1
  17. package/dist/examples/mastra-ai-workflow/activities/take-ticket.js +6 -15
  18. package/dist/examples/mastra-ai-workflow/workflow.d.ts +3 -0
  19. package/dist/examples/mastra-ai-workflow/workflow.d.ts.map +1 -0
  20. package/dist/examples/mastra-ai-workflow/workflow.js +95 -0
  21. package/dist/examples/trigger-mastra-workflow.js +11 -16
  22. package/dist/examples/worker.d.ts.map +1 -1
  23. package/dist/examples/worker.js +25 -16
  24. package/dist/src/bundler.d.ts +9 -2
  25. package/dist/src/bundler.d.ts.map +1 -1
  26. package/dist/src/bundler.js +82 -6
  27. package/dist/src/index.d.ts +2 -0
  28. package/dist/src/index.d.ts.map +1 -1
  29. package/dist/src/index.js +2 -0
  30. package/dist/src/mastra/agent-wrapper.d.ts +2 -2
  31. package/dist/src/mastra/agent-wrapper.d.ts.map +1 -1
  32. package/dist/src/mastra/agent-wrapper.js +1 -1
  33. package/dist/src/mastra/create-activity-with-mastra.d.ts +1 -0
  34. package/dist/src/mastra/create-activity-with-mastra.d.ts.map +1 -1
  35. package/dist/src/mastra/create-activity-with-mastra.js +8 -6
  36. package/dist/src/mastra/with-mastra-agent.d.ts +12 -0
  37. package/dist/src/mastra/with-mastra-agent.d.ts.map +1 -0
  38. package/dist/src/mastra/with-mastra-agent.js +4 -0
  39. package/dist/src/mastra/workflow-compiler.d.ts +23 -0
  40. package/dist/src/mastra/workflow-compiler.d.ts.map +1 -0
  41. package/dist/src/mastra/workflow-compiler.js +132 -0
  42. package/package.json +1 -2
  43. package/dist/examples/mastra-ai-workflow/workflows.d.ts +0 -2
  44. package/dist/examples/mastra-ai-workflow/workflows.d.ts.map +0 -1
  45. package/dist/examples/mastra-ai-workflow/workflows.js +0 -11
  46. package/dist/examples/mastra-example.d.ts +0 -2
  47. package/dist/examples/mastra-example.d.ts.map +0 -1
  48. package/dist/examples/mastra-example.js +0 -103
  49. package/dist/examples/normal-workflow/activities.d.ts +0 -34
  50. package/dist/examples/normal-workflow/activities.d.ts.map +0 -1
  51. package/dist/examples/normal-workflow/activities.js +0 -38
  52. package/dist/examples/normal-workflow/workflows.d.ts +0 -3
  53. package/dist/examples/normal-workflow/workflows.d.ts.map +0 -1
  54. package/dist/examples/normal-workflow/workflows.js +0 -14
  55. package/dist/examples/trigger-normal-workflow.d.ts +0 -2
  56. package/dist/examples/trigger-normal-workflow.d.ts.map +0 -1
  57. package/dist/examples/trigger-normal-workflow.js +0 -43
@@ -1,38 +0,0 @@
1
- import kebabCase from 'lodash/kebabCase.js';
2
- import { createActivity, wrapActivityWithMastraContext, } from '@primero.ai/temporal-graph-tools';
3
- export const fetchUserProfile = createActivity(wrapActivityWithMastraContext(async (input) => {
4
- const profileName = `User ${input.userId.slice(0, 6)}`;
5
- const slug = kebabCase(profileName);
6
- console.log(`[fetchUserProfile] fetching ${input.userId} as ${slug}`);
7
- return {
8
- profile: {
9
- id: input.userId,
10
- name: profileName,
11
- slug,
12
- },
13
- };
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
- }), {
18
- id: 'fetchUserProfile',
19
- });
20
- export const sendWelcomeEmail = createActivity(async ({ profile }) => {
21
- console.log(`[sendWelcomeEmail] sent email to ${profile.name} (${profile.slug})`);
22
- return { sent: true, recipientSlug: profile.slug };
23
- }, {
24
- id: 'sendWelcomeEmail',
25
- });
26
- export const syncCrmRecord = createActivity(async ({ profile }) => {
27
- console.log(`[syncCrmRecord] synced record ${profile.id} (${profile.slug})`);
28
- return { synced: true, recordSlug: profile.slug };
29
- }, {
30
- id: 'syncCrmRecord',
31
- });
32
- export const logCompletion = createActivity(async (result) => {
33
- console.log(`[logCompletion] email sent=${result.sendWelcomeEmail.sent} (slug=${result.sendWelcomeEmail.recipientSlug}), crm synced=${result.syncCrmRecord.synced}`);
34
- }, {
35
- id: 'logCompletion',
36
- });
37
- export const startGreet = createActivity(async () => console.log('Hello '), { id: 'startGreet' });
38
- export const endGreet = createActivity(async () => console.log('World'), { id: 'endGreet' });
@@ -1,3 +0,0 @@
1
- export declare const builderOnboarding: import("@primero.ai/temporal-graph-tools").WorkflowBuildResult;
2
- export declare const builderHelloWorld: import("@primero.ai/temporal-graph-tools").WorkflowBuildResult;
3
- //# sourceMappingURL=workflows.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,14 +0,0 @@
1
- import { createWorkflowBuilder } from '@primero.ai/temporal-graph-tools';
2
- import { endGreet, fetchUserProfile, logCompletion, sendWelcomeEmail, startGreet, syncCrmRecord, } from './activities';
3
- export const builderOnboarding = createWorkflowBuilder({
4
- workflowName: 'customerOnboardingWorkflow',
5
- proxyOptions: { startToCloseTimeout: '2 minutes' },
6
- })
7
- .then(fetchUserProfile)
8
- .parallel([sendWelcomeEmail, syncCrmRecord])
9
- .then(logCompletion)
10
- .commit();
11
- export const builderHelloWorld = createWorkflowBuilder({ workflowName: 'greetWorkflow' })
12
- .then(startGreet)
13
- .then(endGreet)
14
- .commit();
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=trigger-normal-workflow.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trigger-normal-workflow.d.ts","sourceRoot":"","sources":["../../examples/trigger-normal-workflow.ts"],"names":[],"mappings":""}
@@ -1,43 +0,0 @@
1
- import { Connection, WorkflowClient } from '@temporalio/client';
2
- import { builderHelloWorld, builderOnboarding } from './normal-workflow/workflows';
3
- const DEFAULT_NAMESPACE = 'default';
4
- const DEFAULT_TASK_QUEUE = 'default';
5
- async function run() {
6
- var _a, _b, _c, _d;
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 [onboardingHandle, greetHandle] = await Promise.all([
17
- client.start(builderOnboarding.workflowName, {
18
- taskQueue: (_c = process.env.TEMPORAL_TASK_QUEUE) !== null && _c !== void 0 ? _c : DEFAULT_TASK_QUEUE,
19
- workflowId: `customer-onboarding-${Date.now()}`,
20
- args: [{ userId: 'user-123' }],
21
- }),
22
- client.start(builderHelloWorld.workflowName, {
23
- taskQueue: (_d = process.env.TEMPORAL_TASK_QUEUE) !== null && _d !== void 0 ? _d : DEFAULT_TASK_QUEUE,
24
- workflowId: `greet-${Date.now()}`,
25
- args: [{ userId: 'user-123' }],
26
- }),
27
- ]);
28
- console.log('Onboarding Workflow started:', {
29
- workflowId: onboardingHandle.workflowId,
30
- runId: onboardingHandle.firstExecutionRunId,
31
- });
32
- console.log('Greet Workflow started:', {
33
- workflowId: greetHandle.workflowId,
34
- runId: greetHandle.firstExecutionRunId,
35
- });
36
- const result = await Promise.all([onboardingHandle.result(), greetHandle.result()]);
37
- console.log('Workflows completed with result:', result);
38
- await connection.close();
39
- }
40
- run().catch((error) => {
41
- console.error('Failed to run workflow example:', error);
42
- process.exitCode = 1;
43
- });