@mastra/inngest 1.9.0 → 1.9.1
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/dist/{connect-TUP1s9EP.cjs → connect-B5ShyCfq.cjs} +6 -4
- package/dist/{connect-TUP1s9EP.cjs.map → connect-B5ShyCfq.cjs.map} +1 -1
- package/dist/{connect-BNxXqMuc.js → connect-DbsoIp0h.js} +6 -4
- package/dist/{connect-BNxXqMuc.js.map → connect-DbsoIp0h.js.map} +1 -1
- package/dist/connect.cjs +1 -1
- package/dist/connect.js +1 -1
- package/dist/durable-agent/create-inngest-agent.d.ts +40 -4
- package/dist/durable-agent/create-inngest-agent.d.ts.map +1 -1
- package/dist/durable-agent/create-inngest-agentic-workflow.d.ts +3 -0
- package/dist/durable-agent/create-inngest-agentic-workflow.d.ts.map +1 -1
- package/dist/index.cjs +51 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +51 -4
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/workflow.d.ts +1 -0
- package/dist/workflow.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as buildDurableResumeEventData, c as InngestPubSub, i as InngestRun, l as InngestExecutionEngine, n as collectInngestFunctions, o as buildDurableTriggerEventData, r as InngestWorkflow, s as mergeResumeRequestContext, t as connect } from "./connect-
|
|
1
|
+
import { a as buildDurableResumeEventData, c as InngestPubSub, i as InngestRun, l as InngestExecutionEngine, n as collectInngestFunctions, o as buildDurableTriggerEventData, r as InngestWorkflow, s as mergeResumeRequestContext, t as connect } from "./connect-DbsoIp0h.js";
|
|
2
2
|
import { Agent, MessageList, TripWire } from "@mastra/core/agent";
|
|
3
3
|
import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
|
|
4
4
|
import { EntityType, InternalSpans, SpanType } from "@mastra/core/observability";
|
|
@@ -140,7 +140,7 @@ const InngestDurableStepIds = {
|
|
|
140
140
|
AGENTIC_LOOP: `${INNGEST_ENGINE_PREFIX}:${DurableStepIds.AGENTIC_LOOP}`
|
|
141
141
|
};
|
|
142
142
|
function createInngestDurableAgenticWorkflow(options) {
|
|
143
|
-
const { inngest, maxSteps = DurableAgentDefaults.MAX_STEPS } = options;
|
|
143
|
+
const { inngest, maxSteps = DurableAgentDefaults.MAX_STEPS, retries } = options;
|
|
144
144
|
const { createWorkflow } = init(inngest);
|
|
145
145
|
const llmExecutionStep = createDurableLLMExecutionStep();
|
|
146
146
|
const toolCallStep = createDurableToolCallStep();
|
|
@@ -148,6 +148,7 @@ function createInngestDurableAgenticWorkflow(options) {
|
|
|
148
148
|
const backgroundTaskCheckStep = createDurableBackgroundTaskCheckStep();
|
|
149
149
|
const singleIterationWorkflow = createWorkflow({
|
|
150
150
|
id: InngestDurableStepIds.AGENTIC_EXECUTION,
|
|
151
|
+
retries,
|
|
151
152
|
inputSchema: iterationStateSchema,
|
|
152
153
|
outputSchema: iterationStateSchema,
|
|
153
154
|
options: {
|
|
@@ -213,6 +214,7 @@ function createInngestDurableAgenticWorkflow(options) {
|
|
|
213
214
|
}, { id: "update-iteration-state" }).commit();
|
|
214
215
|
return createWorkflow({
|
|
215
216
|
id: InngestDurableStepIds.AGENTIC_LOOP,
|
|
217
|
+
retries,
|
|
216
218
|
inputSchema: durableAgenticInputSchema,
|
|
217
219
|
outputSchema: durableAgenticOutputSchema,
|
|
218
220
|
options: {
|
|
@@ -364,14 +366,17 @@ const STREAM_CLEANUP = Symbol("mastra.durable.inngest.streamCleanup");
|
|
|
364
366
|
* ```
|
|
365
367
|
*/
|
|
366
368
|
function createInngestAgent(options) {
|
|
367
|
-
const { agent, inngest, id: idOverride, name: nameOverride, pubsub: customPubsub, cache, mastra: mastraOption, shouldPersistSnapshot } = options;
|
|
369
|
+
const { agent, inngest, id: idOverride, name: nameOverride, pubsub: customPubsub, cache, mastra: mastraOption, shouldPersistSnapshot, retries } = options;
|
|
368
370
|
if (shouldPersistSnapshot) console.warn(`InngestAgent '${idOverride ?? agent.id}': ignoring the shouldPersistSnapshot option. Inngest's step memoization/replay owns durability, so InngestAgent always persists 'suspended' snapshots only (for human-in-the-loop resume).`);
|
|
369
371
|
const agentId = idOverride ?? agent.id;
|
|
370
372
|
const agentName = nameOverride ?? agent.name;
|
|
371
373
|
let mastra = mastraOption;
|
|
372
374
|
const activeStreamUntilIdle = /* @__PURE__ */ new Map();
|
|
373
375
|
let proxyRef;
|
|
374
|
-
const workflow = createInngestDurableAgenticWorkflow({
|
|
376
|
+
const workflow = createInngestDurableAgenticWorkflow({
|
|
377
|
+
inngest,
|
|
378
|
+
retries
|
|
379
|
+
});
|
|
375
380
|
let _customCache = cache;
|
|
376
381
|
let innerPubsub = customPubsub ?? new InngestPubSub(inngest, InngestDurableStepIds.AGENTIC_LOOP);
|
|
377
382
|
let _cachingPubsub = null;
|
|
@@ -835,6 +840,48 @@ function createInngestAgent(options) {
|
|
|
835
840
|
} else result.cleanup();
|
|
836
841
|
}
|
|
837
842
|
},
|
|
843
|
+
async resumeStream(resumeData, streamOptions) {
|
|
844
|
+
const runId = streamOptions?.runId;
|
|
845
|
+
if (!runId) throw new Error("resumeStream() on InngestAgent requires a runId in streamOptions.");
|
|
846
|
+
const { runId: _runId, ...resumeOptions } = streamOptions;
|
|
847
|
+
return (await proxyRef.resume(runId, resumeData, {
|
|
848
|
+
...resumeOptions,
|
|
849
|
+
[CLOSE_ON_SUSPEND]: true
|
|
850
|
+
})).output;
|
|
851
|
+
},
|
|
852
|
+
async approveToolCall(options) {
|
|
853
|
+
return proxyRef.resumeStream({ approved: true }, options);
|
|
854
|
+
},
|
|
855
|
+
async declineToolCall(options) {
|
|
856
|
+
const { reason, ...resumeOptions } = options;
|
|
857
|
+
return proxyRef.resumeStream({
|
|
858
|
+
approved: false,
|
|
859
|
+
...reason !== void 0 ? { reason } : {}
|
|
860
|
+
}, resumeOptions);
|
|
861
|
+
},
|
|
862
|
+
async approveToolCallGenerate(options) {
|
|
863
|
+
const { runId, ...resumeOptions } = options;
|
|
864
|
+
if (!runId) throw new Error("approveToolCallGenerate() on InngestAgent requires a runId.");
|
|
865
|
+
return proxyRef.resumeGenerate(runId, { approved: true }, resumeOptions);
|
|
866
|
+
},
|
|
867
|
+
async declineToolCallGenerate(options) {
|
|
868
|
+
const { runId, reason, ...resumeOptions } = options;
|
|
869
|
+
if (!runId) throw new Error("declineToolCallGenerate() on InngestAgent requires a runId.");
|
|
870
|
+
return proxyRef.resumeGenerate(runId, {
|
|
871
|
+
approved: false,
|
|
872
|
+
...reason !== void 0 ? { reason } : {}
|
|
873
|
+
}, resumeOptions);
|
|
874
|
+
},
|
|
875
|
+
__fork() {
|
|
876
|
+
const { shouldPersistSnapshot: _ignored, ...forkOptions } = options;
|
|
877
|
+
return createInngestAgent({
|
|
878
|
+
...forkOptions,
|
|
879
|
+
agent: agent.__fork(),
|
|
880
|
+
pubsub: innerPubsub,
|
|
881
|
+
cache: _customCache,
|
|
882
|
+
mastra
|
|
883
|
+
});
|
|
884
|
+
},
|
|
838
885
|
getDurableWorkflows() {
|
|
839
886
|
return [workflow];
|
|
840
887
|
},
|