@mastra/inngest 1.8.9-alpha.0 → 1.8.9
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 +32 -0
- package/dist/durable-agent/create-inngest-agentic-workflow.d.ts.map +1 -1
- package/dist/index.cjs +6 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -55
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @mastra/inngest
|
|
2
|
+
|
|
3
|
+
`@mastra/inngest` connects Mastra workflows and agents to Inngest for durable execution, retries, and step memoization. Use `init()` to create Inngest-backed workflow primitives, or `createInngestAgent()` when an agent run must survive process restarts and transient failures.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @mastra/inngest
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Inngest } from 'inngest';
|
|
15
|
+
import { init } from '@mastra/inngest';
|
|
16
|
+
|
|
17
|
+
const inngest = new Inngest({ id: 'my-app' });
|
|
18
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Documentation
|
|
22
|
+
|
|
23
|
+
- [Deploy Mastra with Inngest](https://mastra.ai/integrations/deploy/inngest)
|
|
24
|
+
- [Reference: createInngestAgent()](https://mastra.ai/reference/agents/inngest-agent)
|
|
25
|
+
|
|
26
|
+
## Changelog
|
|
27
|
+
|
|
28
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/workflows/inngest/CHANGELOG.md) for version history and release notes.
|
|
29
|
+
|
|
30
|
+
## Support
|
|
31
|
+
|
|
32
|
+
We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-inngest-agentic-workflow.d.ts","sourceRoot":"","sources":["../../src/durable-agent/create-inngest-agentic-workflow.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AA+BvC;;GAEG;AACH,MAAM,WAAW,oCAAoC;IACnD,8BAA8B;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAuCD,oCAAoC;AACpC,eAAO,MAAM,qBAAqB;aAChC,iBAAiB;aACjB,YAAY;CACJ,CAAC;AAEX,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"create-inngest-agentic-workflow.d.ts","sourceRoot":"","sources":["../../src/durable-agent/create-inngest-agentic-workflow.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AA+BvC;;GAEG;AACH,MAAM,WAAW,oCAAoC;IACnD,8BAA8B;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAuCD,oCAAoC;AACpC,eAAO,MAAM,qBAAqB;aAChC,iBAAiB;aACjB,YAAY;CACJ,CAAC;AAEX,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAsThG"}
|
package/dist/index.cjs
CHANGED
|
@@ -175,7 +175,11 @@ function createInngestDurableAgenticWorkflow(options) {
|
|
|
175
175
|
stepIndex: state.stepIndex
|
|
176
176
|
};
|
|
177
177
|
}, { id: "map-to-llm-input" }).then(llmExecutionStep).map(async ({ inputData }) => {
|
|
178
|
-
|
|
178
|
+
const llmOutput = inputData;
|
|
179
|
+
return (llmOutput.toolCalls ?? []).map((toolCall) => ({
|
|
180
|
+
...toolCall,
|
|
181
|
+
stepSpanData: llmOutput.stepSpanData
|
|
182
|
+
}));
|
|
179
183
|
}, { id: "extract-tool-calls" }).foreach(toolCallStep, { concurrency: ({ inputData, getInitData }) => {
|
|
180
184
|
const state = getInitData();
|
|
181
185
|
return (0, _mastra_core_agent_durable.resolveDurableToolCallConcurrency)({
|
|
@@ -183,63 +187,10 @@ function createInngestDurableAgenticWorkflow(options) {
|
|
|
183
187
|
toolsMetadata: state?.toolsMetadata,
|
|
184
188
|
toolCalls: inputData
|
|
185
189
|
});
|
|
186
|
-
} }).map(async ({ inputData, getStepResult, getInitData
|
|
190
|
+
} }).map(async ({ inputData, getStepResult, getInitData }) => {
|
|
187
191
|
const toolResults = inputData;
|
|
188
192
|
const llmOutput = getStepResult(llmExecutionStep.id);
|
|
189
193
|
const initData = getInitData();
|
|
190
|
-
const observability = mastra?.observability?.getSelectedInstance({});
|
|
191
|
-
const modelSpanData = llmOutput?.modelSpanData;
|
|
192
|
-
const stepSpanData = llmOutput?.stepSpanData;
|
|
193
|
-
const modelSpan = modelSpanData ? observability?.rebuildSpan(modelSpanData) : void 0;
|
|
194
|
-
const stepSpan = stepSpanData ? observability?.rebuildSpan(stepSpanData) : void 0;
|
|
195
|
-
const agentSpan = initData.agentSpanData ? observability?.rebuildSpan(initData.agentSpanData) : void 0;
|
|
196
|
-
const toolParentSpan = stepSpan ?? modelSpan ?? agentSpan;
|
|
197
|
-
for (const tr of toolResults) {
|
|
198
|
-
const toolSpan = toolParentSpan?.createChildSpan({
|
|
199
|
-
type: _mastra_core_observability.SpanType.TOOL_CALL,
|
|
200
|
-
name: `tool: '${tr.toolName}'`,
|
|
201
|
-
entityType: _mastra_core_observability.EntityType.TOOL,
|
|
202
|
-
entityId: tr.toolName,
|
|
203
|
-
entityName: tr.toolName,
|
|
204
|
-
input: tr.args,
|
|
205
|
-
attributes: { toolCallId: tr.toolCallId }
|
|
206
|
-
});
|
|
207
|
-
if (tr.error) toolSpan?.error({ error: new Error(tr.error.message) });
|
|
208
|
-
else toolSpan?.end({ output: tr.result });
|
|
209
|
-
if (!tr.error) stepSpan?.createEventSpan({
|
|
210
|
-
type: _mastra_core_observability.SpanType.MODEL_CHUNK,
|
|
211
|
-
name: `chunk: 'tool-result'`,
|
|
212
|
-
output: {
|
|
213
|
-
toolCallId: tr.toolCallId,
|
|
214
|
-
toolName: tr.toolName,
|
|
215
|
-
result: tr.result
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
const toolCalls = llmOutput?.toolCalls ?? [];
|
|
220
|
-
if (stepSpan) {
|
|
221
|
-
const stepFinishPayload = llmOutput.stepFinishPayload;
|
|
222
|
-
stepSpan.end({
|
|
223
|
-
output: {
|
|
224
|
-
toolCalls: toolCalls.map((tc) => ({
|
|
225
|
-
toolCallId: tc.toolCallId,
|
|
226
|
-
toolName: tc.toolName,
|
|
227
|
-
args: tc.args
|
|
228
|
-
})),
|
|
229
|
-
toolResults: toolResults.map((tr) => ({
|
|
230
|
-
toolCallId: tr.toolCallId,
|
|
231
|
-
toolName: tr.toolName,
|
|
232
|
-
result: tr.result,
|
|
233
|
-
error: tr.error
|
|
234
|
-
}))
|
|
235
|
-
},
|
|
236
|
-
attributes: {
|
|
237
|
-
usage: stepFinishPayload?.output?.usage,
|
|
238
|
-
finishReason: stepFinishPayload?.stepResult?.reason,
|
|
239
|
-
isContinued: stepFinishPayload?.stepResult?.isContinued
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
194
|
return {
|
|
244
195
|
llmOutput,
|
|
245
196
|
toolResults,
|