@mastra/inngest 1.11.2-alpha.1 → 1.11.2-alpha.2

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.
@@ -40,7 +40,6 @@ let inngest_realtime = require("inngest/realtime");
40
40
  let stream_web = require("stream/web");
41
41
  let _mastra_core_stream = require("@mastra/core/stream");
42
42
  let inngest_hono = require("inngest/hono");
43
- let _mastra_core_cache = require("@mastra/core/cache");
44
43
  let _mastra_core_loop = require("@mastra/core/loop");
45
44
  let _mastra_core_storage = require("@mastra/core/storage");
46
45
  let _mastra_core_utils = require("@mastra/core/utils");
@@ -3045,21 +3044,23 @@ function createInngestAgent(options) {
3045
3044
  retries
3046
3045
  });
3047
3046
  let _customCache = cache;
3048
- let innerPubsub = customPubsub ?? new InngestPubSub(inngest$1, InngestDurableStepIds.AGENTIC_LOOP);
3049
- let _cachingPubsub = null;
3050
- function resolveCache() {
3051
- const resolved = _customCache ?? mastra?.serverCache ?? new _mastra_core_cache.InMemoryServerCache();
3052
- _customCache = resolved;
3053
- return resolved;
3054
- }
3047
+ const innerPubsub = customPubsub ?? new InngestPubSub(inngest$1, InngestDurableStepIds.AGENTIC_LOOP);
3048
+ const streams = new _mastra_core_agent_durable.AgentStreamBus({
3049
+ pubsub: innerPubsub,
3050
+ cache
3051
+ }, {
3052
+ getMastra: () => mastra,
3053
+ usesSharedRunLog: () => false,
3054
+ warn: (message) => console.warn(`InngestAgent '${idOverride ?? agent.id}': ${message}`)
3055
+ });
3056
+ let busResolved = false;
3055
3057
  function getPubsub() {
3056
- if (!_cachingPubsub) {
3057
- if (innerPubsub instanceof _mastra_core_events.CachingPubSub) {
3058
- _cachingPubsub = innerPubsub;
3059
- _customCache = _customCache ?? mastra?.serverCache;
3060
- } else _cachingPubsub = new _mastra_core_events.CachingPubSub(innerPubsub, resolveCache());
3058
+ const pubsub = streams.pubsub;
3059
+ if (!busResolved) {
3060
+ busResolved = true;
3061
+ _customCache ??= innerPubsub instanceof _mastra_core_events.CachingPubSub ? mastra?.serverCache : streams.cache ?? void 0;
3061
3062
  }
3062
- return _cachingPubsub;
3063
+ return pubsub;
3063
3064
  }
3064
3065
  async function getPubsubOffset(runId) {
3065
3066
  return (await getPubsub().getHistory((0, _mastra_core_agent_durable.AGENT_STREAM_TOPIC)(runId))).length;
@@ -3403,15 +3404,6 @@ function createInngestAgent(options) {
3403
3404
  * Best-effort: the local abort has already happened, and a caller asking to
3404
3405
  * stop a run should not get a rejection because the publish failed.
3405
3406
  */
3406
- function forwardExternalAbort(external, controller, runId) {
3407
- const forward = () => {
3408
- controller.abort(external.reason);
3409
- requestRemoteAbort(runId);
3410
- };
3411
- if (external.aborted) forward();
3412
- else external.addEventListener("abort", forward, { once: true });
3413
- return () => external.removeEventListener("abort", forward);
3414
- }
3415
3407
  async function requestRemoteAbort(runId) {
3416
3408
  try {
3417
3409
  await (0, _mastra_core_agent_durable.publishAbortRequest)(getPubsub(), runId);
@@ -3497,8 +3489,7 @@ function createInngestAgent(options) {
3497
3489
  const { runId, messageId, workflowInput, registryEntry, threadId, resourceId } = preparation;
3498
3490
  workflowInput.agentId = agentId;
3499
3491
  workflowInput.agentName = agentName;
3500
- const abortController = new AbortController();
3501
- const stopForwardingAbort = streamOptions?.abortSignal ? forwardExternalAbort(streamOptions.abortSignal, abortController, runId) : void 0;
3492
+ const { controller: abortController, detach: stopForwardingAbort } = (0, _mastra_core_agent_durable.createRunAbortController)(streamOptions?.abortSignal, { onExternalAbort: () => void requestRemoteAbort(runId) });
3502
3493
  registryEntry.abortController = abortController;
3503
3494
  const clearTotalTimeout = armTotalTimeout(registryEntry, abortController, runId, callbackOptions.modelSettings?.timeout?.totalMs);
3504
3495
  registryEntry.messageList = preparation.messageList;
@@ -3747,8 +3738,7 @@ function createInngestAgent(options) {
3747
3738
  assertToolCallResumeNotInFlight(agent.name, runId, toolCallId);
3748
3739
  return proxyRef.resume(runId, resumeData, resumeOptions);
3749
3740
  }
3750
- const abortController = new AbortController();
3751
- const stopForwardingAbort = resumeOptions?.abortSignal ? forwardExternalAbort(resumeOptions.abortSignal, abortController, runId) : void 0;
3741
+ const { controller: abortController, detach: stopForwardingAbort } = (0, _mastra_core_agent_durable.createRunAbortController)(resumeOptions?.abortSignal, { onExternalAbort: () => void requestRemoteAbort(runId) });
3752
3742
  let existingEntry = existingRegistryEntry;
3753
3743
  if (!existingEntry) {
3754
3744
  existingEntry = {
@@ -5103,4 +5093,4 @@ Object.defineProperty(exports, "serve", {
5103
5093
  }
5104
5094
  });
5105
5095
 
5106
- //# sourceMappingURL=src-QjUHaLdm.cjs.map
5096
+ //# sourceMappingURL=src-zS6LvTK1.cjs.map