@mastra/core 1.87.0-alpha.13 → 1.87.0-alpha.14

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 (119) hide show
  1. package/dist/agent/durable/index.cjs +1 -1
  2. package/dist/agent/durable/index.js +1 -1
  3. package/dist/agent/index.cjs +2 -2
  4. package/dist/agent/index.js +2 -2
  5. package/dist/agent-builder/ee/index.cjs +1 -1
  6. package/dist/agent-builder/ee/index.js +1 -1
  7. package/dist/agent-controller/index.cjs +1 -1
  8. package/dist/agent-controller/index.js +1 -1
  9. package/dist/{agent-controller-DYwtbG2-.js → agent-controller-FSjSZ_iD.js} +5 -5
  10. package/dist/{agent-controller-DDxEG9Nd.cjs → agent-controller-k4B293tu.cjs} +5 -5
  11. package/dist/background-tasks/index.cjs +1 -1
  12. package/dist/background-tasks/index.js +1 -1
  13. package/dist/{background-tasks-B8Lk1bt5.js → background-tasks-ClI6oF60.js} +1 -1
  14. package/dist/{background-tasks-LfQsDG6J.cjs → background-tasks-D40Y_iLc.cjs} +1 -1
  15. package/dist/browser/index.cjs +1 -1
  16. package/dist/browser/index.js +1 -1
  17. package/dist/{builder-CPgUrTDP.cjs → builder-C_I6l0US.cjs} +2 -2
  18. package/dist/{builder-DLaSPG2u.js → builder-D00XMm41.js} +2 -2
  19. package/dist/channels/index.cjs +2 -2
  20. package/dist/channels/index.js +2 -2
  21. package/dist/{channels-DH9fKqmy.cjs → channels-BU5_kAUO.cjs} +1 -1
  22. package/dist/{channels-BPxJYR70.js → channels-DMSae7xD.js} +1 -1
  23. package/dist/coding-agent/index.cjs +1 -1
  24. package/dist/coding-agent/index.js +1 -1
  25. package/dist/{constants-Bou0hEgY.cjs → constants-CFO8w780.cjs} +8 -0
  26. package/dist/{constants-CFWgIaqA.js → constants-CUv0mU2y.js} +8 -0
  27. package/dist/datasets/index.cjs +2 -2
  28. package/dist/datasets/index.js +2 -2
  29. package/dist/docs/SKILL.md +1 -1
  30. package/dist/docs/assets/SOURCE_MAP.json +751 -741
  31. package/dist/docs/references/docs-harness-schedules.md +34 -0
  32. package/dist/docs/references/reference-workspace-factory-sandbox.md +2 -0
  33. package/dist/evals/index.cjs +2 -2
  34. package/dist/evals/index.js +2 -2
  35. package/dist/evals/scoreTraces/index.cjs +2 -2
  36. package/dist/evals/scoreTraces/index.js +2 -2
  37. package/dist/harness/index.cjs +1 -1
  38. package/dist/harness/index.js +1 -1
  39. package/dist/index.cjs +1 -1
  40. package/dist/index.js +1 -1
  41. package/dist/knowledge/index.cjs +1 -1
  42. package/dist/knowledge/index.js +1 -1
  43. package/dist/llm/index.cjs +3 -3
  44. package/dist/llm/index.js +3 -3
  45. package/dist/{llm-DeOr7BXy.cjs → llm-C1aiWB6O.cjs} +2 -2
  46. package/dist/{llm-DGa7alUy.js → llm-D5rGQSnS.js} +2 -2
  47. package/dist/loop/index.cjs +2 -2
  48. package/dist/loop/index.js +2 -2
  49. package/dist/{manager-B-pQMauy.cjs → manager-B2z5f39G.cjs} +3 -3
  50. package/dist/{manager-BErWwr50.js → manager-DxwPLhYJ.js} +3 -3
  51. package/dist/mastra/index.cjs +1 -1
  52. package/dist/mastra/index.js +1 -1
  53. package/dist/{mastra-B1BKkzX0.js → mastra-CHd7UnbI.js} +16 -16
  54. package/dist/{mastra-CoWxmLQl.cjs → mastra-WMuI7TZD.cjs} +16 -16
  55. package/dist/memory/index.cjs +2 -2
  56. package/dist/memory/index.js +2 -2
  57. package/dist/{model-Bz3zffBv.js → model-B8DlLHex.js} +1 -1
  58. package/dist/{model-CGH6nAvh.cjs → model-C2CTzjMk.cjs} +1 -1
  59. package/dist/{netlify-D7oirBdu.cjs → netlify-Dhs0UJul.cjs} +1 -1
  60. package/dist/{netlify-CzbukKO2.js → netlify-xQFmVbr4.js} +1 -1
  61. package/dist/notifications/index.cjs +1 -1
  62. package/dist/notifications/index.js +1 -1
  63. package/dist/processor-provider/index.cjs +1 -1
  64. package/dist/processor-provider/index.js +1 -1
  65. package/dist/processors/index.cjs +2 -2
  66. package/dist/processors/index.js +2 -2
  67. package/dist/{provider-registry-DTaqnIYP.cjs → provider-registry-CSQPAFzz.cjs} +4 -4
  68. package/dist/{provider-registry-CdCkSE3h.js → provider-registry-FxVHWmht.js} +4 -4
  69. package/dist/{registry-generator-Dbxm-MYh.js → registry-generator-BzsrHxrr.js} +1 -1
  70. package/dist/{registry-generator-CcgFsigf.cjs → registry-generator-Dsh7xcz9.cjs} +1 -1
  71. package/dist/{rehydrate-D7eaaJxI.cjs → rehydrate-8q7KX4rD.cjs} +2 -2
  72. package/dist/{rehydrate-BhmzzvtV.js → rehydrate-DV1iO9eZ.js} +2 -2
  73. package/dist/relevance/index.cjs +2 -2
  74. package/dist/relevance/index.js +2 -2
  75. package/dist/{run-registry-59R9kE8Z.cjs → run-registry-DOlZccsr.cjs} +86 -29
  76. package/dist/{run-registry-Du22tS_D.js → run-registry-sTm40Ecv.js} +86 -29
  77. package/dist/{scheduler-B-VZUvv_.js → scheduler-0ShtMM1I.js} +71 -21
  78. package/dist/{scheduler-D00X03jQ.cjs → scheduler-CMjK0LoQ.cjs} +82 -20
  79. package/dist/storage/constants.cjs +1 -1
  80. package/dist/storage/constants.js +1 -1
  81. package/dist/storage/domains/schedules/base.d.ts +31 -2
  82. package/dist/storage/domains/schedules/inmemory.d.ts +9 -2
  83. package/dist/storage/index.cjs +3 -3
  84. package/dist/storage/index.js +3 -3
  85. package/dist/stream/index.cjs +2 -2
  86. package/dist/stream/index.js +2 -2
  87. package/dist/{stream-mYc-fHPF.cjs → stream-aGuW9AL8.cjs} +1 -1
  88. package/dist/{stream-C_oNulbg.js → stream-k-Q1NLUs.js} +1 -1
  89. package/dist/test-utils/llm-mock.cjs +1 -1
  90. package/dist/test-utils/llm-mock.js +1 -1
  91. package/dist/tool-loop-agent/index.cjs +1 -1
  92. package/dist/tool-loop-agent/index.js +1 -1
  93. package/dist/{tool-loop-agent-Du1BJO8a.js → tool-loop-agent-CJrysPOR.js} +3 -3
  94. package/dist/{tool-loop-agent-Bi09dOW5.cjs → tool-loop-agent-WcRtGJHn.cjs} +3 -3
  95. package/dist/{utils-BGq3p2MX.cjs → utils-DEzQLxWP.cjs} +1 -1
  96. package/dist/{utils-nyjsIsHZ.js → utils-DamF4CfD.js} +1 -1
  97. package/dist/utils.cjs +1 -1
  98. package/dist/utils.js +1 -1
  99. package/dist/{validate-CcE7gP2j.cjs → validate-CDlONK0o.cjs} +1 -1
  100. package/dist/{validate-q0hhKzA4.js → validate-rum3NMFA.js} +1 -1
  101. package/dist/vector/index.cjs +1 -1
  102. package/dist/vector/index.js +1 -1
  103. package/dist/worker/index.cjs +1 -1
  104. package/dist/worker/index.js +1 -1
  105. package/dist/{worker-Dzfx-9D0.cjs → worker-6MiKMAqB.cjs} +3 -3
  106. package/dist/{worker-Wv2nS-Df.js → worker-BnXipQth.js} +2 -2
  107. package/dist/{worker-DmJLbaGI.cjs → worker-rwal1zI8.cjs} +2 -2
  108. package/dist/{worker-Dboi5I9k.js → worker-st16x0my.js} +3 -3
  109. package/dist/{workflow-CFfCkulP.js → workflow-BzhYKgc_.js} +3 -3
  110. package/dist/{workflow-BPf1-mkb.cjs → workflow-D2-gn0U0.cjs} +3 -3
  111. package/dist/workflows/builder/index.cjs +1 -1
  112. package/dist/workflows/builder/index.js +1 -1
  113. package/dist/workflows/evented/index.cjs +1 -1
  114. package/dist/workflows/evented/index.js +1 -1
  115. package/dist/workflows/index.cjs +7 -5
  116. package/dist/workflows/index.js +6 -6
  117. package/dist/workflows/scheduler/claim.d.ts +51 -0
  118. package/dist/workflows/scheduler/index.d.ts +2 -0
  119. package/package.json +8 -8
@@ -1,5 +1,5 @@
1
1
  import { n as __exportAll } from "./rolldown-runtime-tIEjjQTE.js";
2
- import { _ as getCapabilityFileName, d as createOpenRouter, f as createAnthropic, g as shouldEnableGateway, l as GATEWAY_AUTH_HEADER, m as getGatewayId, r as ModelsDevGateway, t as NetlifyGateway, u as MASTRA_USER_AGENT, y as MastraModelGateway } from "./netlify-CzbukKO2.js";
2
+ import { _ as getCapabilityFileName, d as createOpenRouter, f as createAnthropic, g as shouldEnableGateway, l as GATEWAY_AUTH_HEADER, m as getGatewayId, r as ModelsDevGateway, t as NetlifyGateway, u as MASTRA_USER_AGENT, y as MastraModelGateway } from "./netlify-xQFmVbr4.js";
3
3
  import { i as MastraError, n as ErrorDomain, t as ErrorCategory } from "./error-oh2DLsP2.js";
4
4
  import { createRequire } from "module";
5
5
  import fs from "fs";
@@ -25157,10 +25157,10 @@ var GatewayRegistry = class GatewayRegistry {
25157
25157
  if (this.isRefreshing && !forceRefresh) return;
25158
25158
  this.isRefreshing = true;
25159
25159
  try {
25160
- const { ModelsDevGateway } = await import("./netlify-CzbukKO2.js").then((n) => n.i);
25161
- const { NetlifyGateway } = await import("./netlify-CzbukKO2.js").then((n) => n.n);
25160
+ const { ModelsDevGateway } = await import("./netlify-xQFmVbr4.js").then((n) => n.i);
25161
+ const { NetlifyGateway } = await import("./netlify-xQFmVbr4.js").then((n) => n.n);
25162
25162
  const { MastraGateway } = await Promise.resolve().then(() => mastra_exports);
25163
- const { fetchProvidersFromGateways, writeRegistryFiles } = await import("./registry-generator-Dbxm-MYh.js");
25163
+ const { fetchProvidersFromGateways, writeRegistryFiles } = await import("./registry-generator-BzsrHxrr.js");
25164
25164
  const { providers, models, attachmentCapabilities, temperatureCapabilities, structuredOutputCapabilities, reasoningCapabilities, failedGateways } = await fetchProvidersFromGateways([...[
25165
25165
  new ModelsDevGateway({}),
25166
25166
  new NetlifyGateway(),
@@ -1,4 +1,4 @@
1
- import { _ as getCapabilityFileName, g as shouldEnableGateway, m as getGatewayId } from "./netlify-CzbukKO2.js";
1
+ import { _ as getCapabilityFileName, g as shouldEnableGateway, m as getGatewayId } from "./netlify-xQFmVbr4.js";
2
2
  import path from "path";
3
3
  import fs from "fs/promises";
4
4
  // src/llm/model/registry-generator.ts
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-BrhgMLW6.cjs");
2
- const require_netlify = require("./netlify-D7oirBdu.cjs");
2
+ const require_netlify = require("./netlify-Dhs0UJul.cjs");
3
3
  let path = require("path");
4
4
  path = require_rolldown_runtime.__toESM(path, 1);
5
5
  let fs_promises = require("fs/promises");
@@ -1,6 +1,6 @@
1
- const require_run_registry = require("./run-registry-59R9kE8Z.cjs");
1
+ const require_run_registry = require("./run-registry-DOlZccsr.cjs");
2
2
  const require_predicate_index = require("./predicate/index.cjs");
3
- const require_validate = require("./validate-CcE7gP2j.cjs");
3
+ const require_validate = require("./validate-CDlONK0o.cjs");
4
4
  let _mastra_schema_compat_schema = require("@mastra/schema-compat/schema");
5
5
  // src/workflows/dynamic/serialize.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { Gs as createEventedWorkflow, Ks as createWorkflow, Nc as mapVariable, Pc as predicateToCondition, Ws as cloneWorkflow, el as createStepFromAgent, gl as getSingleStepEntryId, nl as createStepFromTool } from "./run-registry-Du22tS_D.js";
1
+ import { Gs as createEventedWorkflow, Ks as createWorkflow, Nc as mapVariable, Pc as predicateToCondition, Ws as cloneWorkflow, el as createStepFromAgent, gl as getSingleStepEntryId, nl as createStepFromTool } from "./run-registry-sTm40Ecv.js";
2
2
  import { derivePredicateLabel } from "./predicate/index.js";
3
- import { a as jsonSchemaToZod, l as parseMapConfig } from "./validate-q0hhKzA4.js";
3
+ import { a as jsonSchemaToZod, l as parseMapConfig } from "./validate-rum3NMFA.js";
4
4
  import { standardSchemaToJSONSchema, toStandardSchema } from "./schema/index.js";
5
5
  // src/workflows/dynamic/serialize.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_run_registry = require("../run-registry-59R9kE8Z.cjs");
3
- const require_stream = require("../stream-mYc-fHPF.cjs");
2
+ const require_run_registry = require("../run-registry-DOlZccsr.cjs");
3
+ const require_stream = require("../stream-aGuW9AL8.cjs");
4
4
  // src/relevance/relevance-score-provider.ts
5
5
  function createSimilarityPrompt(query, text) {
6
6
  return `Rate the semantic similarity between the following the query and the text on a scale from 0 to 1 (decimals allowed), where 1 means exactly the same meaning and 0 means completely different:
@@ -1,5 +1,5 @@
1
- import { F as Agent } from "../run-registry-Du22tS_D.js";
2
- import { un as isSupportedLanguageModel } from "../stream-C_oNulbg.js";
1
+ import { F as Agent } from "../run-registry-sTm40Ecv.js";
2
+ import { un as isSupportedLanguageModel } from "../stream-k-Q1NLUs.js";
3
3
  // src/relevance/relevance-score-provider.ts
4
4
  function createSimilarityPrompt(query, text) {
5
5
  return `Rate the semantic similarity between the following the query and the text on a scale from 0 to 1 (decimals allowed), where 1 means exactly the same meaning and 0 means completely different:
@@ -4,14 +4,14 @@ const require_base = require("./base-BIzR1D3_.cjs");
4
4
  const require_observability = require("./observability-B0R_D1PZ.cjs");
5
5
  const require_error = require("./error-D90lJ6M7.cjs");
6
6
  const require_error$1 = require("./error-L1V4uUbd.cjs");
7
- const require_stream = require("./stream-mYc-fHPF.cjs");
7
+ const require_stream = require("./stream-aGuW9AL8.cjs");
8
8
  const require_request_context = require("./request-context-D9RXYCy8.cjs");
9
9
  const require_output_helpers = require("./output-helpers-DgsH4aTb.cjs");
10
10
  const require_message_list = require("./message-list-C0F2sDNC.cjs");
11
11
  const require_storage = require("./storage-CfG0I2aF.cjs");
12
12
  const require_utils = require("./utils-D-eNsgDM.cjs");
13
13
  const require_error_count = require("./error-count-DeDpeWU2.cjs");
14
- const require_llm = require("./llm-DeOr7BXy.cjs");
14
+ const require_llm = require("./llm-C1aiWB6O.cjs");
15
15
  const require_payload_transform = require("./payload-transform-CWgnsO9w.cjs");
16
16
  const require_utils_safe_stringify = require("./utils/safe-stringify.cjs");
17
17
  const require_signals = require("./signals-CWxAMEmE.cjs");
@@ -23,13 +23,13 @@ const require_tool = require("./tool-CYlT2UA-.cjs");
23
23
  const require_toolchecks = require("./toolchecks-MFU48cit.cjs");
24
24
  const require_fetchWithRetry = require("./fetchWithRetry-f5k4p7_1.cjs");
25
25
  const require_model = require("./model-jBymoqGa.cjs");
26
- const require_provider_registry = require("./provider-registry-DTaqnIYP.cjs");
26
+ const require_provider_registry = require("./provider-registry-CSQPAFzz.cjs");
27
27
  const require_inmemory = require("./inmemory-Dc86VWGB.cjs");
28
28
  const require_dynamic_argument = require("./dynamic-argument-CUc1BBOS.cjs");
29
- const require_model$1 = require("./model-CGH6nAvh.cjs");
30
- const require_utils$1 = require("./utils-BGq3p2MX.cjs");
29
+ const require_model$1 = require("./model-C2CTzjMk.cjs");
30
+ const require_utils$1 = require("./utils-DEzQLxWP.cjs");
31
31
  const require_ee_iTj2bRDt = require("./ee-iTj2bRDt-D3-QLGDF.cjs");
32
- const require_background_tasks = require("./background-tasks-LfQsDG6J.cjs");
32
+ const require_background_tasks = require("./background-tasks-D40Y_iLc.cjs");
33
33
  const require_stream$1 = require("./stream-BGbj9jAU.cjs");
34
34
  const require_predicate_index = require("./predicate/index.cjs");
35
35
  const require_classifier_index = require("./classifier/index.cjs");
@@ -38,7 +38,7 @@ const require_workflows_constants = require("./workflows/constants.cjs");
38
38
  const require_hooks = require("./hooks-D7VDBETj.cjs");
39
39
  const require_schedules = require("./schedules-BZS8McF7.cjs");
40
40
  const require_state_processor = require("./state-processor-kRNZ38Nf.cjs");
41
- const require_constants = require("./constants-Bou0hEgY.cjs");
41
+ const require_constants = require("./constants-CFO8w780.cjs");
42
42
  const require_signal_provider = require("./signal-provider-BFAvh_AJ.cjs");
43
43
  const require_slugify = require("./slugify-B_WzG9IY.cjs");
44
44
  const require_workspace = require("./workspace-CzzrnE6Q.cjs");
@@ -44168,6 +44168,20 @@ var SchedulesStorage = class extends require_filesystem_versioned.StorageDomain
44168
44168
  });
44169
44169
  }
44170
44170
  async dangerouslyClearAll() {}
44171
+ /**
44172
+ * A view of this store holding one tenant's schedules. Ids are unique per
44173
+ * tenant, every read and write is limited to the tenant's rows, and created
44174
+ * rows carry its `tenantId`.
44175
+ *
44176
+ * The store this is called on keeps seeing only rows without a tenant,
44177
+ * except `listDueSchedules`, which spans every tenant so one tick can claim
44178
+ * what's due everywhere; claim a tenant's row through its `forTenant` view.
44179
+ *
44180
+ * Adapters that don't support tenants throw rather than ignore the tenant.
44181
+ */
44182
+ forTenant(_tenantId) {
44183
+ throw new Error(`${this.constructor.name} does not support tenant-scoped schedules`);
44184
+ }
44171
44185
  };
44172
44186
  // src/storage/domains/schedules/inmemory.ts
44173
44187
  function clone(value) {
@@ -44179,28 +44193,57 @@ function cloneRow(row) {
44179
44193
  copy.target = normalizeScheduleTarget(copy.target);
44180
44194
  return copy;
44181
44195
  }
44182
- var InMemorySchedulesStorage = class extends SchedulesStorage {
44196
+ var InMemorySchedulesStorage = class InMemorySchedulesStorage extends SchedulesStorage {
44183
44197
  db;
44184
- constructor({ db }) {
44198
+ #tenantId;
44199
+ constructor({ db, tenantId }) {
44185
44200
  super();
44186
44201
  this.db = db;
44202
+ this.#tenantId = tenantId;
44203
+ }
44204
+ forTenant(tenantId) {
44205
+ return new InMemorySchedulesStorage({
44206
+ db: this.db,
44207
+ tenantId
44208
+ });
44209
+ }
44210
+ /** Map key: root and tenant keys start differently, so neither can reach the other's rows. */
44211
+ #key(id) {
44212
+ return this.#tenantId === void 0 ? `root:${id}` : `tenant:${encodeURIComponent(this.#tenantId)}/${id}`;
44213
+ }
44214
+ #mine(row) {
44215
+ return row.tenantId === this.#tenantId;
44187
44216
  }
44217
+ /** The root store clears everything; a tenant's view clears only that tenant. */
44188
44218
  async dangerouslyClearAll() {
44189
- this.db.schedules.clear();
44190
- this.db.scheduleTriggers.length = 0;
44219
+ if (this.#tenantId === void 0) {
44220
+ this.db.schedules.clear();
44221
+ this.db.scheduleTriggers.length = 0;
44222
+ return;
44223
+ }
44224
+ for (const [key, row] of this.db.schedules) if (this.#mine(row)) this.db.schedules.delete(key);
44225
+ const triggers = this.db.scheduleTriggers;
44226
+ let kept = 0;
44227
+ for (const row of triggers) if (!this.#mine(row)) triggers[kept++] = row;
44228
+ triggers.length = kept;
44191
44229
  }
44192
44230
  async createSchedule(schedule) {
44193
- if (this.db.schedules.has(schedule.id)) throw new Error(`Schedule ${schedule.id} already exists`);
44194
- const stored = clone(schedule);
44195
- this.db.schedules.set(stored.id, stored);
44231
+ const key = this.#key(schedule.id);
44232
+ if (this.db.schedules.has(key)) throw new Error(`Schedule ${schedule.id} already exists`);
44233
+ const { tenantId: _ignored, ...rest } = schedule;
44234
+ const stored = clone(this.#tenantId === void 0 ? rest : {
44235
+ ...rest,
44236
+ tenantId: this.#tenantId
44237
+ });
44238
+ this.db.schedules.set(key, stored);
44196
44239
  return clone(stored);
44197
44240
  }
44198
44241
  async getSchedule(id) {
44199
- const found = this.db.schedules.get(id);
44242
+ const found = this.db.schedules.get(this.#key(id));
44200
44243
  return found ? cloneRow(found) : null;
44201
44244
  }
44202
44245
  async listSchedules(filter) {
44203
- let rows = Array.from(this.db.schedules.values());
44246
+ let rows = Array.from(this.db.schedules.values()).filter((r) => this.#mine(r));
44204
44247
  if (filter?.status) rows = rows.filter((r) => r.status === filter.status);
44205
44248
  if (filter?.workflowId) rows = rows.filter((r) => r.target.type === "workflow" && r.target.workflowId === filter.workflowId);
44206
44249
  if (filter?.ownerType !== void 0) rows = rows.filter((r) => (r.ownerType ?? null) === filter.ownerType);
@@ -44208,28 +44251,37 @@ var InMemorySchedulesStorage = class extends SchedulesStorage {
44208
44251
  rows.sort((a, b) => a.createdAt - b.createdAt);
44209
44252
  return rows.map(cloneRow);
44210
44253
  }
44211
- async listDueSchedules(now, limit) {
44254
+ async listDueSchedules(now, limit, options) {
44212
44255
  const due = [];
44213
- for (const row of this.db.schedules.values()) if (row.status === "active" && row.nextFireAt <= now) due.push(row);
44256
+ for (const row of this.db.schedules.values()) {
44257
+ if (this.#tenantId !== void 0) {
44258
+ if (!this.#mine(row)) continue;
44259
+ } else if (options?.unscoped && row.tenantId !== void 0) continue;
44260
+ else if (options?.tenants && row.tenantId === void 0) continue;
44261
+ if (row.status === "active" && row.nextFireAt <= now) due.push(row);
44262
+ }
44214
44263
  due.sort((a, b) => a.nextFireAt - b.nextFireAt);
44215
44264
  const cap = limit ?? due.length;
44216
44265
  return due.slice(0, cap).map(cloneRow);
44217
44266
  }
44218
44267
  async updateSchedule(id, patch) {
44219
- const existing = this.db.schedules.get(id);
44268
+ const existing = this.db.schedules.get(this.#key(id));
44220
44269
  if (!existing) throw new Error(`Schedule ${id} not found`);
44221
- const stored = clone({
44270
+ const updated = {
44222
44271
  ...existing,
44223
44272
  ...patch,
44224
44273
  target: patch.target !== void 0 ? patch.target : existing.target,
44225
44274
  metadata: patch.metadata !== void 0 ? patch.metadata : existing.metadata,
44226
44275
  updatedAt: Date.now()
44227
- });
44228
- this.db.schedules.set(id, stored);
44276
+ };
44277
+ if (existing.tenantId === void 0) delete updated.tenantId;
44278
+ else updated.tenantId = existing.tenantId;
44279
+ const stored = clone(updated);
44280
+ this.db.schedules.set(this.#key(id), stored);
44229
44281
  return cloneRow(stored);
44230
44282
  }
44231
44283
  async updateScheduleNextFire(id, expectedNextFireAt, newNextFireAt, lastFireAt, lastRunId, newStatus) {
44232
- const existing = this.db.schedules.get(id);
44284
+ const existing = this.db.schedules.get(this.#key(id));
44233
44285
  if (!existing) return false;
44234
44286
  if (existing.nextFireAt !== expectedNextFireAt) return false;
44235
44287
  if (existing.status !== "active") return false;
@@ -44241,23 +44293,28 @@ var InMemorySchedulesStorage = class extends SchedulesStorage {
44241
44293
  ...newStatus ? { status: newStatus } : {},
44242
44294
  updatedAt: Date.now()
44243
44295
  };
44244
- this.db.schedules.set(id, stored);
44296
+ this.db.schedules.set(this.#key(id), stored);
44245
44297
  return true;
44246
44298
  }
44247
44299
  async deleteSchedule(id) {
44248
- this.db.schedules.delete(id);
44249
- for (let i = this.db.scheduleTriggers.length - 1; i >= 0; i--) if (this.db.scheduleTriggers[i].scheduleId === id) this.db.scheduleTriggers.splice(i, 1);
44300
+ this.db.schedules.delete(this.#key(id));
44301
+ for (let i = this.db.scheduleTriggers.length - 1; i >= 0; i--) {
44302
+ const trigger = this.db.scheduleTriggers[i];
44303
+ if (trigger.scheduleId === id && this.#mine(trigger)) this.db.scheduleTriggers.splice(i, 1);
44304
+ }
44250
44305
  }
44251
44306
  async recordTrigger(trigger) {
44307
+ const { tenantId: _ignored, ...rest } = trigger;
44252
44308
  const stored = {
44253
- ...trigger,
44309
+ ...rest,
44310
+ ...this.#tenantId === void 0 ? {} : { tenantId: this.#tenantId },
44254
44311
  id: trigger.id ?? globalThis.crypto.randomUUID(),
44255
44312
  triggerKind: trigger.triggerKind ?? "schedule-fire"
44256
44313
  };
44257
44314
  this.db.scheduleTriggers.push(clone(stored));
44258
44315
  }
44259
44316
  async listTriggers(scheduleId, opts) {
44260
- let rows = this.db.scheduleTriggers.filter((f) => f.scheduleId === scheduleId);
44317
+ let rows = this.db.scheduleTriggers.filter((f) => f.scheduleId === scheduleId && this.#mine(f));
44261
44318
  if (opts?.fromActualFireAt != null) rows = rows.filter((f) => f.actualFireAt >= opts.fromActualFireAt);
44262
44319
  if (opts?.toActualFireAt != null) rows = rows.filter((f) => f.actualFireAt < opts.toActualFireAt);
44263
44320
  rows.sort((a, b) => b.actualFireAt - a.actualFireAt);
@@ -86217,7 +86274,7 @@ async function prepareForDurableExecution(options) {
86217
86274
  });
86218
86275
  let tripwireData;
86219
86276
  if (inputProcessors.length > 0) try {
86220
- const { ProcessorRunner } = await Promise.resolve().then(() => require("./stream-mYc-fHPF.cjs")).then((n) => n.runner_exports);
86277
+ const { ProcessorRunner } = await Promise.resolve().then(() => require("./stream-aGuW9AL8.cjs")).then((n) => n.runner_exports);
86221
86278
  await new ProcessorRunner({
86222
86279
  inputProcessors,
86223
86280
  outputProcessors,
@@ -4,14 +4,14 @@ import { t as MastraBase } from "./base-CKLWBhDo.js";
4
4
  import { A as compactStopReasonContext, D as agentLoopTermination, O as executionFailureTermination, S as resolveObservabilityContext, b as wrapMastra, i as subtractReportedUsage, k as tripwireTermination, n as extractUsageMetrics, r as isUsageIncomplete, t as calculateObservedUsage, x as createObservabilityContext, y as unwrapMastraTracingProxy } from "./observability-D7RNOAPx.js";
5
5
  import { a as MastraNonRetryableError, i as MastraError, n as ErrorDomain, o as getErrorFromUnknown, t as ErrorCategory } from "./error-oh2DLsP2.js";
6
6
  import { a as classifyProviderError, l as describeProviderError, t as recordTerminalErrorMessage, u as readProviderErrorDetails } from "./error-BC9Au-22.js";
7
- import { $ as summarizeToolChoiceForSpan, $t as commitToolResult, A as isSignalChunkExcluded, An as raceAgainstAbort, At as getSnapshotMemoryInfo, B as removeTrailingAssistantGuardContinuations, Bt as stateColumnsWrite, C as stampChunkProducedAt, Cn as DEADLINE_SAVE_WAIT_MS, D as isStructuredOutputError, Dn as guardStreamUntilMatch, Dt as validateTemplate, E as escapeUnescapedControlCharsInJsonStrings, En as getAbortReason, Et as traverseMappingPath, F as endOutputStreamSpanOutsideStep, Fn as safeEnqueue, Ft as latestStepResults, G as FLUSH_HELD_PARTS_KEY, Gt as diffStateAsJson, Ht as unusedStateEntries, I as findOwnModelStepSpan, In as safeError, It as materializeState, J as withoutHeldContent, K as REPROCESS_PART_KEY, Kt as patchState, Ln as createRunScope, Lt as materializeWorkflowRun, M as ProcessorRunner, N as ProcessorState, Nn as MastraModelInput, Nt as applyStateColumnsWrite, O as asJsonSchema, On as guardStreamWithAbort, Ot as getStepResult, P as endOutputStreamSpanAtStepEnd, Pn as safeClose, Pt as isStateCheckpointDue, Q as summarizeProcessorToolsForSpan, R as isTrailingAssistantGuardContinuation, Rn as createRunScopeKey, Rt as pickStateKeys, S as getChunkProducedAt, Sn as DEADLINE_SAVE_CLAIM_HOLD_MS, St as stepRefId, T as createOutputHandler, Tn as createTimeoutAbortSignal, Tt as templateReadsState, Ut as applyStatePatch, V as ProviderHistoryCompat, Vt as summarizeStepResult, X as summarizeProcessorModelForSpan, Y as summarizeActiveToolsForSpan, Yt as isObservationalMemoryEnabled$1, Z as summarizeProcessorResultForSpan, Zt as parseMemoryRequestContext, _ as persistProcessorDataChunk, _t as stubStepResult, a as convertFullStreamChunkToMastra, an as snapshotToolResult, at as PROCESSOR_ABORT_SIGNAL, b as resolveOutputMessageSkippingCompletionChecks, bn as pendingQueueThreadId, bt as predicateReadsState, c as WorkflowRunOutput, cn as validationErrorModelOutput, ct as getHydratedStepResult, d as MastraModelOutput, dn as resolveSuspendedToolRunId, dt as lazyStepResults, en as computeModelOutputProviderMetadata, et as resolveProcessorSpanAttributes, f as clearStepPartIndexes, fn as resolveThreadIdFromArgs, ft as loadStepResults, g as isFeedbackContinuation, gn as applyStateSignal, gt as storageV2StepResultAccessors, h as findStepPartBoundaries, hn as tryStreamWithJsonFallback, ht as residentStepResultsLoader, in as resolveModelOutputAfterToolResultProcessors, it as createProcessorSendSignal, j as OUTPUT_STREAM_HOOK_DURATION_KEY_PREFIX, jn as settledOrElapsed, k as getResponseFormat, kn as isMastraTimeoutError, kt as getStepResultAsync, l as TripWire, ln as isProcessorWorkflow, lt as hydrateStepResults, m as findIterationOffsetInParts, mn as tryGenerateWithJsonFallback, mt as residentStepResults, nn as latestProcessedModelOutput, nt as toProcessorSpanPhase, on as withAgentWorkflowToolMarker, ot as RunJournal, p as createDestructurableOutput, pn as supportedLanguageModelSpecifications, pt as loadedStepResults, q as takeHeldParts, rn as readModelOutput, rt as PROCESSOR_LATE_SIGNAL_SINK, s as MastraAgentNetworkStream, sn as normalizeModelOutput, st as buildStepResultAccessors, tn as hasToolResultProcessor, tt as resolveProcessorSpanName, u as getModelOutputForTripwire, un as isSupportedLanguageModel, ut as isStepResultStub, v as reconcileBufferedStepTexts, vn as assertNotQueueThreadId, vt as collectMappingStepRefs, w as markChunkOutputProcessed, wn as MastraTimeoutError, wt as resolveTemplate, x as resolveProcessorWriterMessageId, xn as takenQueueThreadId, xt as resolveStepOutputs, y as resolveMessageText, yn as isQueueThreadId, yt as collectPredicateStepRefs, z as needsTrailingAssistantGuard, zt as stateBaseOf } from "./stream-C_oNulbg.js";
7
+ import { $ as summarizeToolChoiceForSpan, $t as commitToolResult, A as isSignalChunkExcluded, An as raceAgainstAbort, At as getSnapshotMemoryInfo, B as removeTrailingAssistantGuardContinuations, Bt as stateColumnsWrite, C as stampChunkProducedAt, Cn as DEADLINE_SAVE_WAIT_MS, D as isStructuredOutputError, Dn as guardStreamUntilMatch, Dt as validateTemplate, E as escapeUnescapedControlCharsInJsonStrings, En as getAbortReason, Et as traverseMappingPath, F as endOutputStreamSpanOutsideStep, Fn as safeEnqueue, Ft as latestStepResults, G as FLUSH_HELD_PARTS_KEY, Gt as diffStateAsJson, Ht as unusedStateEntries, I as findOwnModelStepSpan, In as safeError, It as materializeState, J as withoutHeldContent, K as REPROCESS_PART_KEY, Kt as patchState, Ln as createRunScope, Lt as materializeWorkflowRun, M as ProcessorRunner, N as ProcessorState, Nn as MastraModelInput, Nt as applyStateColumnsWrite, O as asJsonSchema, On as guardStreamWithAbort, Ot as getStepResult, P as endOutputStreamSpanAtStepEnd, Pn as safeClose, Pt as isStateCheckpointDue, Q as summarizeProcessorToolsForSpan, R as isTrailingAssistantGuardContinuation, Rn as createRunScopeKey, Rt as pickStateKeys, S as getChunkProducedAt, Sn as DEADLINE_SAVE_CLAIM_HOLD_MS, St as stepRefId, T as createOutputHandler, Tn as createTimeoutAbortSignal, Tt as templateReadsState, Ut as applyStatePatch, V as ProviderHistoryCompat, Vt as summarizeStepResult, X as summarizeProcessorModelForSpan, Y as summarizeActiveToolsForSpan, Yt as isObservationalMemoryEnabled$1, Z as summarizeProcessorResultForSpan, Zt as parseMemoryRequestContext, _ as persistProcessorDataChunk, _t as stubStepResult, a as convertFullStreamChunkToMastra, an as snapshotToolResult, at as PROCESSOR_ABORT_SIGNAL, b as resolveOutputMessageSkippingCompletionChecks, bn as pendingQueueThreadId, bt as predicateReadsState, c as WorkflowRunOutput, cn as validationErrorModelOutput, ct as getHydratedStepResult, d as MastraModelOutput, dn as resolveSuspendedToolRunId, dt as lazyStepResults, en as computeModelOutputProviderMetadata, et as resolveProcessorSpanAttributes, f as clearStepPartIndexes, fn as resolveThreadIdFromArgs, ft as loadStepResults, g as isFeedbackContinuation, gn as applyStateSignal, gt as storageV2StepResultAccessors, h as findStepPartBoundaries, hn as tryStreamWithJsonFallback, ht as residentStepResultsLoader, in as resolveModelOutputAfterToolResultProcessors, it as createProcessorSendSignal, j as OUTPUT_STREAM_HOOK_DURATION_KEY_PREFIX, jn as settledOrElapsed, k as getResponseFormat, kn as isMastraTimeoutError, kt as getStepResultAsync, l as TripWire, ln as isProcessorWorkflow, lt as hydrateStepResults, m as findIterationOffsetInParts, mn as tryGenerateWithJsonFallback, mt as residentStepResults, nn as latestProcessedModelOutput, nt as toProcessorSpanPhase, on as withAgentWorkflowToolMarker, ot as RunJournal, p as createDestructurableOutput, pn as supportedLanguageModelSpecifications, pt as loadedStepResults, q as takeHeldParts, rn as readModelOutput, rt as PROCESSOR_LATE_SIGNAL_SINK, s as MastraAgentNetworkStream, sn as normalizeModelOutput, st as buildStepResultAccessors, tn as hasToolResultProcessor, tt as resolveProcessorSpanName, u as getModelOutputForTripwire, un as isSupportedLanguageModel, ut as isStepResultStub, v as reconcileBufferedStepTexts, vn as assertNotQueueThreadId, vt as collectMappingStepRefs, w as markChunkOutputProcessed, wn as MastraTimeoutError, wt as resolveTemplate, x as resolveProcessorWriterMessageId, xn as takenQueueThreadId, xt as resolveStepOutputs, y as resolveMessageText, yn as isQueueThreadId, yt as collectPredicateStepRefs, z as needsTrailingAssistantGuard, zt as stateBaseOf } from "./stream-k-Q1NLUs.js";
8
8
  import { c as MASTRA_THREAD_ID_KEY, d as isReservedRequestContextKey, f as mergeVersionOverrides$1, l as MASTRA_VERSIONS_KEY, n as MASTRA_AUTH_TOKEN_KEY, o as MASTRA_RESOURCE_ID_KEY, p as withoutLiveRequestKeys, r as MASTRA_INHERITED_MEMORY_KEY, s as MASTRA_SCOPES_KEY, t as MASTRA_CONTINUATION_TOOL_CALL_IDS_KEY, u as RequestContext } from "./request-context-COnZHt2-.js";
9
9
  import { S as withAck, _ as serializeError$1, h as stripModelSnapshots, n as PublisherQueueLimitError, p as slimNestedAgentChunks, r as CachingPubSub, t as DefaultStepResult, u as isRunLocalTopic, v as EventEmitterPubSub, x as isLeaseProvider, y as NoopLeaseProvider } from "./output-helpers-CVzhy1Y0.js";
10
10
  import { A as stableStringify$1, E as removeWorkingMemoryTags, P as embed$3, Z as preserveResponseItemIdsOnMerge, a as isTerminalToolInvocationState, c as withUnavailableAttachmentUrls, d as aiV5UIMessagesToAIV5ModelMessages, f as coreContentToString, i as isClientToolInvocationUpdate, l as isDownloadAssetsError, m as filterMessagesForPersistence, n as MessageList, ot as normalizeToolOutput, p as messagesAreEqual, r as advancesToolInvocationState, s as unavailableAttachmentPlaceholder, t as convertMessages, u as MessageMerger } from "./message-list-RgFlLrxG.js";
11
11
  import { Bt as listScoresArgsSchema, Ft as listLogsArgsSchema, Lt as listMetricsArgsSchema, Nt as listFeedbackArgsSchema, t as EntityType } from "./storage-Cc50aQAp.js";
12
12
  import { a as getOrCreateSpan, f as resolveCurrentSpan, l as getTimeToFirstChunkMs, n as executeWithContextSync, o as getResumeTracingContext, p as resolveExportedSpanId, s as getRootExportSpan, t as executeWithContext, u as getWorkflowResumeTracingContext } from "./utils-DU_pU5SK.js";
13
13
  import { i as setSpanErrorOrigin, n as getSpanErrorOrigin } from "./error-count-BH-rJW7q.js";
14
- import { a as ModelRouterLanguageModel, d as attachModelStreamTransport, f as isDataChunk, i as resolveModelConfig, n as ModelRouterEmbeddingModel, o as resolveApiProviderId, p as readModelStreamTransport } from "./llm-DGa7alUy.js";
14
+ import { a as ModelRouterLanguageModel, d as attachModelStreamTransport, f as isDataChunk, i as resolveModelConfig, n as ModelRouterEmbeddingModel, o as resolveApiProviderId, p as readModelStreamTransport } from "./llm-D5rGQSnS.js";
15
15
  import { a as withToolPayloadTransformMetadata, i as transformToolPayloadForTargets, n as hasTransformedToolPayload, o as withToolPayloadTransformProviderMetadata, r as normalizeToolPayloadTransformPolicy, t as getTransformedToolPayload } from "./payload-transform-Dj3HUeD4.js";
16
16
  import { boundedStringify, ensureSerializable, safeStringify } from "./utils/safe-stringify.js";
17
17
  import { d as signalSpanAttributes, h as signalToXmlMarkup, l as mastraDBMessageToSignal, n as createSignal, o as isMastraSignalMessage, s as isTransientSignalMessage, u as resolveDeliveryAttributes } from "./signals-CqR_iWkg.js";
@@ -24,13 +24,13 @@ import { _ as getRequestContextInputValues, a as getModelFacingValidationError,
24
24
  import { a as isApprovalExempt, c as isProviderDefinedTool, d as markAgentWorkflowTool, f as markApprovalExempt, l as isProviderTool, n as getNeedsApprovalFn, o as isBuiltBeforeApproval, r as getProviderToolName, s as isMastraTool, t as getBeforeApprovalFn } from "./toolchecks-DrsZdc3S.js";
25
25
  import { a as waitDelay, i as getRetryAfterMs, n as DEFAULT_MAX_RETRY_AFTER_MS, r as clampDelayMs } from "./fetchWithRetry-DFSvpYDT.js";
26
26
  import { i as hasFreeFormObject } from "./model-DS-b2R-R.js";
27
- import { c as modelSupportsStructuredOutput, l as modelSupportsTemperature } from "./provider-registry-CdCkSE3h.js";
27
+ import { c as modelSupportsStructuredOutput, l as modelSupportsTemperature } from "./provider-registry-FxVHWmht.js";
28
28
  import { t as InMemoryServerCache } from "./inmemory-BK3zLwvM.js";
29
29
  import { n as resolveDynamicArgument, t as getRequestUser } from "./dynamic-argument-BzPK3qPN.js";
30
- import { t as MastraLLMV1 } from "./model-Bz3zffBv.js";
31
- import { A as eagerToolCallDidNotExecute, D as EagerToolExecutionCoordinator, E as EAGER_TOOL_EXECUTION_MARKER, F as hasRunningRunStep, I as isRunStepActive, L as setRunLeaseFence, M as isEagerlyExecutableToolCall, N as TOOL_ABORT_NOTICE, O as EagerToolExecutionNotRun, P as clearRunLeaseFence, R as startRunStep, S as selectFields, T as EAGER_TOOL_BAILOUT, a as ensureToolProperties, b as removeUndefinedValues, d as makeCoreTool, i as delay$1, j as eagerToolCallSuspensionIntent, k as eagerToolCallAlreadyAnnouncedInput, n as createMastraProxy, o as generateEmptyFromSchema, p as makeProcessorCoreTool, r as deepMerge$1, v as readPositiveIntEnv, w as EAGER_TOOL_ABORT_SIGNAL, y as rebindProcessorTools, z as whenRunStepsSettle } from "./utils-nyjsIsHZ.js";
30
+ import { t as MastraLLMV1 } from "./model-B8DlLHex.js";
31
+ import { A as eagerToolCallDidNotExecute, D as EagerToolExecutionCoordinator, E as EAGER_TOOL_EXECUTION_MARKER, F as hasRunningRunStep, I as isRunStepActive, L as setRunLeaseFence, M as isEagerlyExecutableToolCall, N as TOOL_ABORT_NOTICE, O as EagerToolExecutionNotRun, P as clearRunLeaseFence, R as startRunStep, S as selectFields, T as EAGER_TOOL_BAILOUT, a as ensureToolProperties, b as removeUndefinedValues, d as makeCoreTool, i as delay$1, j as eagerToolCallSuspensionIntent, k as eagerToolCallAlreadyAnnouncedInput, n as createMastraProxy, o as generateEmptyFromSchema, p as makeProcessorCoreTool, r as deepMerge$1, v as readPositiveIntEnv, w as EAGER_TOOL_ABORT_SIGNAL, y as rebindProcessorTools, z as whenRunStepsSettle } from "./utils-DamF4CfD.js";
32
32
  import { h as getWorkflowFGAResourceId, i as MastraFGAPermissions, y as requireFGA } from "./ee-iTj2bRDt-By_B9ngH.js";
33
- import { c as createBackgroundTask, o as resolveBackgroundConfig, s as sanitizeToolArguments, t as generateBackgroundTaskSystemPrompt } from "./background-tasks-B8Lk1bt5.js";
33
+ import { c as createBackgroundTask, o as resolveBackgroundConfig, s as sanitizeToolArguments, t as generateBackgroundTaskSystemPrompt } from "./background-tasks-ClI6oF60.js";
34
34
  import { t as ToolStream } from "./stream-D9JOykz7.js";
35
35
  import { MISSING, collectInvalidPredicatePaths, createPredicateEvaluator, derivePredicateLabel, normalizePredicatePath, walk } from "./predicate/index.js";
36
36
  import { Classifier } from "./classifier/index.js";
@@ -39,7 +39,7 @@ import { HAND_BACK_STATE_SYMBOL, PARENT_STATE_SYMBOL, PUBSUB_SYMBOL, STREAM_FORM
39
39
  import { i as executeHook } from "./hooks-Bth8Cjpj.js";
40
40
  import { o as assertValidScheduleDefinition, v as validateScheduleTiming } from "./schedules-DZfSx-7P.js";
41
41
  import { A as writeObjective, D as readObjective, O as resolveEffectiveGoalSettings, T as formatGoalBudgetPausedReason, _ as clearCachedGoalObjective, b as GOAL_SCORER_ID, g as cacheGoalObjective, k as resolveGoalStore, w as clearObjective, x as GOAL_SCORE_WAITING } from "./state-processor-B9kxpM53.js";
42
- import { An as computeTraceStatus, Cr as extractTrajectory, Dr as saveScorePayloadSchema, It as TABLE_SCHEMAS, Lt as TABLE_SCORERS, Nn as extractBranchSpans, Pn as getBranchArgsSchema, Qn as listTracesArgsSchema, Sr as withBufferedReflectionVerified, Tr as extractWorkflowTrajectory, Yn as listBranchesArgsSchema, _r as isAppendOnlySince, ar as spanRecordSchema, br as maxObservationCursor, cr as toTraceSpans, gn as BRANCH_SPAN_TYPE_SET, gr as compareObservationalMemoryHeadOrder, hr as assertActiveObservationsApplied, or as toLightSpanRecord, pn as matchesExpectedWorkflowStatus, qn as isPreviewTruncated, sr as toTraceSpan, vn as TraceStatus, vr as isBufferedChunkCoveredByCursor, wr as extractTrajectoryFromTrace, xr as planReflectionGenerationText, yr as isBufferedReflectionUnchangedSince } from "./constants-CFWgIaqA.js";
42
+ import { An as computeTraceStatus, Cr as extractTrajectory, Dr as saveScorePayloadSchema, It as TABLE_SCHEMAS, Lt as TABLE_SCORERS, Nn as extractBranchSpans, Pn as getBranchArgsSchema, Qn as listTracesArgsSchema, Sr as withBufferedReflectionVerified, Tr as extractWorkflowTrajectory, Yn as listBranchesArgsSchema, _r as isAppendOnlySince, ar as spanRecordSchema, br as maxObservationCursor, cr as toTraceSpans, gn as BRANCH_SPAN_TYPE_SET, gr as compareObservationalMemoryHeadOrder, hr as assertActiveObservationsApplied, or as toLightSpanRecord, pn as matchesExpectedWorkflowStatus, qn as isPreviewTruncated, sr as toTraceSpan, vn as TraceStatus, vr as isBufferedChunkCoveredByCursor, wr as extractTrajectoryFromTrace, xr as planReflectionGenerationText, yr as isBufferedReflectionUnchangedSince } from "./constants-CUv0mU2y.js";
43
43
  import { t as GoalSignalProvider } from "./signal-provider-BslnAjWG.js";
44
44
  import { t as slugify } from "./slugify-BUNmb-Ga.js";
45
45
  import { F as LocalSandbox, at as evaluateReadRecord, c as Workspace, dt as WORKSPACE_TOOLS, g as resolveToolConfig, gt as shellQuote, h as createWorkspaceTools, ht as sliceByTokens, l as createSkillTools, lt as CompositeFilesystem, mt as estimateTokenCount, ot as normalizeReadTrackerPath, pt as sliceByTokensSafe, st as LocalFilesystem } from "./workspace-Ct2kAiDv.js";
@@ -44162,6 +44162,20 @@ var SchedulesStorage = class extends StorageDomain {
44162
44162
  });
44163
44163
  }
44164
44164
  async dangerouslyClearAll() {}
44165
+ /**
44166
+ * A view of this store holding one tenant's schedules. Ids are unique per
44167
+ * tenant, every read and write is limited to the tenant's rows, and created
44168
+ * rows carry its `tenantId`.
44169
+ *
44170
+ * The store this is called on keeps seeing only rows without a tenant,
44171
+ * except `listDueSchedules`, which spans every tenant so one tick can claim
44172
+ * what's due everywhere; claim a tenant's row through its `forTenant` view.
44173
+ *
44174
+ * Adapters that don't support tenants throw rather than ignore the tenant.
44175
+ */
44176
+ forTenant(_tenantId) {
44177
+ throw new Error(`${this.constructor.name} does not support tenant-scoped schedules`);
44178
+ }
44165
44179
  };
44166
44180
  // src/storage/domains/schedules/inmemory.ts
44167
44181
  function clone(value) {
@@ -44173,28 +44187,57 @@ function cloneRow(row) {
44173
44187
  copy.target = normalizeScheduleTarget(copy.target);
44174
44188
  return copy;
44175
44189
  }
44176
- var InMemorySchedulesStorage = class extends SchedulesStorage {
44190
+ var InMemorySchedulesStorage = class InMemorySchedulesStorage extends SchedulesStorage {
44177
44191
  db;
44178
- constructor({ db }) {
44192
+ #tenantId;
44193
+ constructor({ db, tenantId }) {
44179
44194
  super();
44180
44195
  this.db = db;
44196
+ this.#tenantId = tenantId;
44197
+ }
44198
+ forTenant(tenantId) {
44199
+ return new InMemorySchedulesStorage({
44200
+ db: this.db,
44201
+ tenantId
44202
+ });
44203
+ }
44204
+ /** Map key: root and tenant keys start differently, so neither can reach the other's rows. */
44205
+ #key(id) {
44206
+ return this.#tenantId === void 0 ? `root:${id}` : `tenant:${encodeURIComponent(this.#tenantId)}/${id}`;
44207
+ }
44208
+ #mine(row) {
44209
+ return row.tenantId === this.#tenantId;
44181
44210
  }
44211
+ /** The root store clears everything; a tenant's view clears only that tenant. */
44182
44212
  async dangerouslyClearAll() {
44183
- this.db.schedules.clear();
44184
- this.db.scheduleTriggers.length = 0;
44213
+ if (this.#tenantId === void 0) {
44214
+ this.db.schedules.clear();
44215
+ this.db.scheduleTriggers.length = 0;
44216
+ return;
44217
+ }
44218
+ for (const [key, row] of this.db.schedules) if (this.#mine(row)) this.db.schedules.delete(key);
44219
+ const triggers = this.db.scheduleTriggers;
44220
+ let kept = 0;
44221
+ for (const row of triggers) if (!this.#mine(row)) triggers[kept++] = row;
44222
+ triggers.length = kept;
44185
44223
  }
44186
44224
  async createSchedule(schedule) {
44187
- if (this.db.schedules.has(schedule.id)) throw new Error(`Schedule ${schedule.id} already exists`);
44188
- const stored = clone(schedule);
44189
- this.db.schedules.set(stored.id, stored);
44225
+ const key = this.#key(schedule.id);
44226
+ if (this.db.schedules.has(key)) throw new Error(`Schedule ${schedule.id} already exists`);
44227
+ const { tenantId: _ignored, ...rest } = schedule;
44228
+ const stored = clone(this.#tenantId === void 0 ? rest : {
44229
+ ...rest,
44230
+ tenantId: this.#tenantId
44231
+ });
44232
+ this.db.schedules.set(key, stored);
44190
44233
  return clone(stored);
44191
44234
  }
44192
44235
  async getSchedule(id) {
44193
- const found = this.db.schedules.get(id);
44236
+ const found = this.db.schedules.get(this.#key(id));
44194
44237
  return found ? cloneRow(found) : null;
44195
44238
  }
44196
44239
  async listSchedules(filter) {
44197
- let rows = Array.from(this.db.schedules.values());
44240
+ let rows = Array.from(this.db.schedules.values()).filter((r) => this.#mine(r));
44198
44241
  if (filter?.status) rows = rows.filter((r) => r.status === filter.status);
44199
44242
  if (filter?.workflowId) rows = rows.filter((r) => r.target.type === "workflow" && r.target.workflowId === filter.workflowId);
44200
44243
  if (filter?.ownerType !== void 0) rows = rows.filter((r) => (r.ownerType ?? null) === filter.ownerType);
@@ -44202,28 +44245,37 @@ var InMemorySchedulesStorage = class extends SchedulesStorage {
44202
44245
  rows.sort((a, b) => a.createdAt - b.createdAt);
44203
44246
  return rows.map(cloneRow);
44204
44247
  }
44205
- async listDueSchedules(now, limit) {
44248
+ async listDueSchedules(now, limit, options) {
44206
44249
  const due = [];
44207
- for (const row of this.db.schedules.values()) if (row.status === "active" && row.nextFireAt <= now) due.push(row);
44250
+ for (const row of this.db.schedules.values()) {
44251
+ if (this.#tenantId !== void 0) {
44252
+ if (!this.#mine(row)) continue;
44253
+ } else if (options?.unscoped && row.tenantId !== void 0) continue;
44254
+ else if (options?.tenants && row.tenantId === void 0) continue;
44255
+ if (row.status === "active" && row.nextFireAt <= now) due.push(row);
44256
+ }
44208
44257
  due.sort((a, b) => a.nextFireAt - b.nextFireAt);
44209
44258
  const cap = limit ?? due.length;
44210
44259
  return due.slice(0, cap).map(cloneRow);
44211
44260
  }
44212
44261
  async updateSchedule(id, patch) {
44213
- const existing = this.db.schedules.get(id);
44262
+ const existing = this.db.schedules.get(this.#key(id));
44214
44263
  if (!existing) throw new Error(`Schedule ${id} not found`);
44215
- const stored = clone({
44264
+ const updated = {
44216
44265
  ...existing,
44217
44266
  ...patch,
44218
44267
  target: patch.target !== void 0 ? patch.target : existing.target,
44219
44268
  metadata: patch.metadata !== void 0 ? patch.metadata : existing.metadata,
44220
44269
  updatedAt: Date.now()
44221
- });
44222
- this.db.schedules.set(id, stored);
44270
+ };
44271
+ if (existing.tenantId === void 0) delete updated.tenantId;
44272
+ else updated.tenantId = existing.tenantId;
44273
+ const stored = clone(updated);
44274
+ this.db.schedules.set(this.#key(id), stored);
44223
44275
  return cloneRow(stored);
44224
44276
  }
44225
44277
  async updateScheduleNextFire(id, expectedNextFireAt, newNextFireAt, lastFireAt, lastRunId, newStatus) {
44226
- const existing = this.db.schedules.get(id);
44278
+ const existing = this.db.schedules.get(this.#key(id));
44227
44279
  if (!existing) return false;
44228
44280
  if (existing.nextFireAt !== expectedNextFireAt) return false;
44229
44281
  if (existing.status !== "active") return false;
@@ -44235,23 +44287,28 @@ var InMemorySchedulesStorage = class extends SchedulesStorage {
44235
44287
  ...newStatus ? { status: newStatus } : {},
44236
44288
  updatedAt: Date.now()
44237
44289
  };
44238
- this.db.schedules.set(id, stored);
44290
+ this.db.schedules.set(this.#key(id), stored);
44239
44291
  return true;
44240
44292
  }
44241
44293
  async deleteSchedule(id) {
44242
- this.db.schedules.delete(id);
44243
- for (let i = this.db.scheduleTriggers.length - 1; i >= 0; i--) if (this.db.scheduleTriggers[i].scheduleId === id) this.db.scheduleTriggers.splice(i, 1);
44294
+ this.db.schedules.delete(this.#key(id));
44295
+ for (let i = this.db.scheduleTriggers.length - 1; i >= 0; i--) {
44296
+ const trigger = this.db.scheduleTriggers[i];
44297
+ if (trigger.scheduleId === id && this.#mine(trigger)) this.db.scheduleTriggers.splice(i, 1);
44298
+ }
44244
44299
  }
44245
44300
  async recordTrigger(trigger) {
44301
+ const { tenantId: _ignored, ...rest } = trigger;
44246
44302
  const stored = {
44247
- ...trigger,
44303
+ ...rest,
44304
+ ...this.#tenantId === void 0 ? {} : { tenantId: this.#tenantId },
44248
44305
  id: trigger.id ?? globalThis.crypto.randomUUID(),
44249
44306
  triggerKind: trigger.triggerKind ?? "schedule-fire"
44250
44307
  };
44251
44308
  this.db.scheduleTriggers.push(clone(stored));
44252
44309
  }
44253
44310
  async listTriggers(scheduleId, opts) {
44254
- let rows = this.db.scheduleTriggers.filter((f) => f.scheduleId === scheduleId);
44311
+ let rows = this.db.scheduleTriggers.filter((f) => f.scheduleId === scheduleId && this.#mine(f));
44255
44312
  if (opts?.fromActualFireAt != null) rows = rows.filter((f) => f.actualFireAt >= opts.fromActualFireAt);
44256
44313
  if (opts?.toActualFireAt != null) rows = rows.filter((f) => f.actualFireAt < opts.toActualFireAt);
44257
44314
  rows.sort((a, b) => b.actualFireAt - a.actualFireAt);
@@ -86211,7 +86268,7 @@ async function prepareForDurableExecution(options) {
86211
86268
  });
86212
86269
  let tripwireData;
86213
86270
  if (inputProcessors.length > 0) try {
86214
- const { ProcessorRunner } = await import("./stream-C_oNulbg.js").then((n) => n.L);
86271
+ const { ProcessorRunner } = await import("./stream-k-Q1NLUs.js").then((n) => n.L);
86215
86272
  await new ProcessorRunner({
86216
86273
  inputProcessors,
86217
86274
  outputProcessors,