@opengeni/worker-bundle 0.23.4 → 0.24.2-canary.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 (84) hide show
  1. package/dist/activities/agent-turn/admission.d.ts +17 -2
  2. package/dist/activities/agent-turn/claim.d.ts +1 -0
  3. package/dist/activities/agent-turn/codex.d.ts +2 -2
  4. package/dist/activities/agent-turn/list-models.d.ts +16 -0
  5. package/dist/activities/agent-turn/model-usage.d.ts +15 -1
  6. package/dist/activities/agent-turn/quiescence.d.ts +2 -0
  7. package/dist/activities/agent-turn/run.d.ts +9 -0
  8. package/dist/activities/agent-turn/sandbox-runtime.d.ts +15 -0
  9. package/dist/activities/agent-turn/session-title.d.ts +21 -0
  10. package/dist/activities/agent-turn/stream-attempt.d.ts +4 -0
  11. package/dist/activities/agent-turn/tool-environment.d.ts +2 -0
  12. package/dist/activities/agent-turn/tool-policy.d.ts +36 -5
  13. package/dist/activities/agent-turn/turn-context.d.ts +4 -1
  14. package/dist/activities/agent-turn.d.ts +1 -1
  15. package/dist/activities/automations.d.ts +1 -0
  16. package/dist/activities/capabilities.d.ts +3 -1
  17. package/dist/activities/context-compaction.d.ts +2 -0
  18. package/dist/activities/goals.d.ts +11 -0
  19. package/dist/activities/image-generation-references.d.ts +2 -1
  20. package/dist/activities/scheduled-tasks.d.ts +1 -0
  21. package/dist/activities/types.d.ts +8 -0
  22. package/dist/{activities-control-52W5IDWM.js → activities-control-ZWH7J4KZ.js} +297 -180
  23. package/dist/activities-control-ZWH7J4KZ.js.map +1 -0
  24. package/dist/activities-control.d.ts +2 -0
  25. package/dist/{activities-turn-A2G2KLSY.js → activities-turn-I4OPLQLS.js} +898 -333
  26. package/dist/activities-turn-I4OPLQLS.js.map +1 -0
  27. package/dist/activities.d.ts +2 -0
  28. package/dist/{chunk-GFNXVZVQ.js → chunk-65JEWP2Q.js} +107 -7
  29. package/dist/chunk-65JEWP2Q.js.map +1 -0
  30. package/dist/{chunk-GRFQTTSQ.js → chunk-GDCLDKSH.js} +7 -3
  31. package/dist/{chunk-GRFQTTSQ.js.map → chunk-GDCLDKSH.js.map} +1 -1
  32. package/dist/{chunk-IPVMCAW5.js → chunk-RQNH6CGR.js} +111 -62
  33. package/dist/chunk-RQNH6CGR.js.map +1 -0
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.js +43 -7
  36. package/dist/index.js.map +1 -1
  37. package/dist/observability-metrics.d.ts +34 -7
  38. package/dist/sandbox-reaper-timeout.d.ts +2 -2
  39. package/dist/sandbox-resume.d.ts +6 -1
  40. package/dist/workflow-bundle.js +26 -3
  41. package/dist/workflows/activities.d.ts +5 -0
  42. package/dist/workflows/automations.d.ts +5 -0
  43. package/package.json +17 -17
  44. package/src/activities/agent-run-admission.ts +7 -1
  45. package/src/activities/agent-turn/admission.ts +47 -6
  46. package/src/activities/agent-turn/claim.ts +33 -5
  47. package/src/activities/agent-turn/codex.ts +2 -2
  48. package/src/activities/agent-turn/compaction-prep.ts +8 -1
  49. package/src/activities/agent-turn/finalization.ts +31 -17
  50. package/src/activities/agent-turn/list-models.ts +101 -0
  51. package/src/activities/agent-turn/model-usage.ts +120 -45
  52. package/src/activities/agent-turn/quiescence.ts +11 -2
  53. package/src/activities/agent-turn/run.ts +80 -4
  54. package/src/activities/agent-turn/sandbox-runtime.ts +78 -81
  55. package/src/activities/agent-turn/session-title.ts +55 -2
  56. package/src/activities/agent-turn/stream-attempt.ts +266 -135
  57. package/src/activities/agent-turn/tool-environment.ts +102 -7
  58. package/src/activities/agent-turn/tool-policy.ts +58 -5
  59. package/src/activities/agent-turn/turn-context.ts +8 -2
  60. package/src/activities/agent-turn.ts +5 -1
  61. package/src/activities/api-integrations.ts +11 -1
  62. package/src/activities/automations.ts +122 -67
  63. package/src/activities/capabilities.ts +129 -2
  64. package/src/activities/context-compaction.ts +3 -0
  65. package/src/activities/goals.ts +108 -31
  66. package/src/activities/image-generation-references.ts +9 -9
  67. package/src/activities/mcp-credentials.ts +53 -0
  68. package/src/activities/rig-verification.ts +5 -3
  69. package/src/activities/scheduled-tasks.ts +217 -110
  70. package/src/activities/site-auth-maintenance.ts +12 -12
  71. package/src/activities/types.ts +6 -0
  72. package/src/activities.ts +1 -0
  73. package/src/activity-services.ts +4 -1
  74. package/src/github-rest-mcp.ts +2 -1
  75. package/src/index.ts +34 -4
  76. package/src/observability-metrics.ts +154 -14
  77. package/src/sandbox-reaper-timeout.ts +10 -4
  78. package/src/sandbox-resume.ts +58 -8
  79. package/src/workflows/activities.ts +15 -0
  80. package/src/workflows/automations.ts +21 -2
  81. package/dist/activities-control-52W5IDWM.js.map +0 -1
  82. package/dist/activities-turn-A2G2KLSY.js.map +0 -1
  83. package/dist/chunk-GFNXVZVQ.js.map +0 -1
  84. package/dist/chunk-IPVMCAW5.js.map +0 -1
@@ -4,7 +4,7 @@ import {
4
4
  SANDBOX_REAPER_CHILD_DISPATCH_LIMIT,
5
5
  assertSandboxDrainInputTiming,
6
6
  sandboxDrainTiming
7
- } from "./chunk-GRFQTTSQ.js";
7
+ } from "./chunk-GDCLDKSH.js";
8
8
  import {
9
9
  INCIDENT_TELEMETRY_AUTHORITY_FENCE_LINEAGE_KEY,
10
10
  MAX_AUTOMATIC_PROVIDER_RECOVERIES,
@@ -32,7 +32,7 @@ import {
32
32
  scheduledUserMessagePayload,
33
33
  withFirstPartyTools,
34
34
  workflowIdForSession
35
- } from "./chunk-IPVMCAW5.js";
35
+ } from "./chunk-RQNH6CGR.js";
36
36
  import {
37
37
  inspectOpenSandboxKubernetesInventory,
38
38
  recordCreditBalanceGauges,
@@ -52,7 +52,7 @@ import {
52
52
  recordTurnsQueuedGauge,
53
53
  recordWorkerDeathRecoveryMetrics,
54
54
  runtimeMetricsHooksForObservability
55
- } from "./chunk-GFNXVZVQ.js";
55
+ } from "./chunk-65JEWP2Q.js";
56
56
 
57
57
  // src/activities/browser-state-artifact-reaper.ts
58
58
  import {
@@ -139,12 +139,18 @@ function cleanupErrorCategory(error) {
139
139
  }
140
140
 
141
141
  // src/activities/automations.ts
142
- import { resolveTurnExecutionPolicyV1 } from "@opengeni/config";
142
+ import {
143
+ resolveTurnExecutionPolicyV1,
144
+ WORKSPACE_GATEWAY_MODEL_ID_PREFIX,
145
+ WORKSPACE_OPENROUTER_MODEL_ID_PREFIX
146
+ } from "@opengeni/config";
143
147
  import {
144
148
  assertWorkspaceModelPolicyAllows,
145
149
  canonicalConfiguredModel,
146
150
  createAndStartSessionWithOutcome,
147
- recordWorkspaceUsage
151
+ recordWorkspaceUsage,
152
+ resolveCatalogSettings,
153
+ resolveWorkspaceCatalogSettings
148
154
  } from "@opengeni/core";
149
155
  import {
150
156
  AutomationAuthorityRevokedError,
@@ -155,14 +161,20 @@ import {
155
161
 
156
162
  // src/activities/agent-run-admission.ts
157
163
  import { configuredStaticUsageLimits } from "@opengeni/config";
164
+ import { modelFundingForAdmission } from "@opengeni/core";
158
165
  import { getBillingBalance, isCodexBilledTurn, sumUsageQuantity } from "@opengeni/db";
159
166
  async function agentRunAdmissionDenial(services, input) {
160
- const externallyBilled = await isCodexBilledTurn({
167
+ const codexBilled = await isCodexBilledTurn({
161
168
  db: services.db,
162
169
  settings: services.settings,
163
170
  workspaceId: input.workspaceId,
164
171
  model: input.model
165
172
  });
173
+ const externallyBilled = modelFundingForAdmission(
174
+ services.settings,
175
+ input.model,
176
+ codexBilled
177
+ ).fundedWithoutCredits;
166
178
  if (!externallyBilled && (services.settings.billingMode === "stripe" || services.settings.usageLimitsMode === "managed")) {
167
179
  if (services.entitlements) {
168
180
  const decision = await services.entitlements.admitRun({
@@ -218,8 +230,19 @@ function createAutomationActivities(services, options = {}) {
218
230
  const assertModelPolicy = options.assertModelPolicy ?? assertWorkspaceModelPolicyAllows;
219
231
  const recordUsage = options.recordUsage ?? recordWorkspaceUsage;
220
232
  return {
233
+ settleAutomationRunFailure: async (input) => {
234
+ const service = await services();
235
+ await settle(service.db, {
236
+ workspaceId: input.workspaceId,
237
+ runId: input.runId,
238
+ status: "failed",
239
+ errorCode: "dispatch_failed"
240
+ });
241
+ },
221
242
  dispatchAutomationRun: async (input) => {
222
243
  const service = await services();
244
+ const catalogSourceSettings = service.catalogSourceSettings ?? service.settings;
245
+ const deploymentCatalogSettings = (await resolveCatalogSettings(service.db, catalogSourceSettings)).settings;
223
246
  const run = await claim(service.db, input);
224
247
  if (!run) return { action: "not_found" };
225
248
  if (run.status === "dispatched") {
@@ -227,61 +250,87 @@ function createAutomationActivities(services, options = {}) {
227
250
  return { action: "already_dispatched", sessionId: run.sessionId };
228
251
  }
229
252
  if (run.status === "skipped") {
230
- return { action: "skipped", reason: run.errorCode ?? "authority_revoked" };
253
+ return {
254
+ action: "skipped",
255
+ reason: run.errorCode ?? "authority_revoked"
256
+ };
231
257
  }
232
- const accepted = run.acceptedExecution;
233
- if (accepted.accountId !== input.accountId || accepted.workspaceId !== input.workspaceId || accepted.sourceId !== run.sourceId || accepted.triggerId !== run.triggerId || accepted.triggerRevision !== run.triggerRevision || accepted.eventId !== run.eventId) {
234
- await settle(service.db, {
235
- workspaceId: input.workspaceId,
236
- runId: run.id,
237
- status: "skipped",
238
- errorCode: "accepted_execution_mismatch"
239
- });
240
- return { action: "skipped", reason: "accepted_execution_mismatch" };
258
+ if (run.status === "failed") {
259
+ return { action: "failed", reason: run.errorCode ?? "dispatch_failed" };
241
260
  }
242
- const template = accepted.sessionTemplate;
243
- const model = canonicalConfiguredModel(
244
- service.settings,
245
- template.model ?? service.settings.openaiModel
246
- );
247
- if (!model) throw new Error("automation has no configured model");
248
- await assertModelPolicy(service.db, service.settings, input.workspaceId, model);
249
- const denial = await admit(service, {
250
- accountId: input.accountId,
251
- workspaceId: input.workspaceId,
252
- model,
253
- requestedAgentRuns: 1
254
- });
255
- if (denial) {
256
- await settle(service.db, {
261
+ try {
262
+ const accepted = run.acceptedExecution;
263
+ if (accepted.accountId !== input.accountId || accepted.workspaceId !== input.workspaceId || accepted.sourceId !== run.sourceId || accepted.triggerId !== run.triggerId || accepted.triggerRevision !== run.triggerRevision || accepted.eventId !== run.eventId) {
264
+ await settle(service.db, {
265
+ workspaceId: input.workspaceId,
266
+ runId: run.id,
267
+ status: "skipped",
268
+ errorCode: "accepted_execution_mismatch"
269
+ });
270
+ return { action: "skipped", reason: "accepted_execution_mismatch" };
271
+ }
272
+ const template = accepted.sessionTemplate;
273
+ const requestedModel = template.model ?? deploymentCatalogSettings.openaiModel;
274
+ const catalogSettings = requestedModel.startsWith(WORKSPACE_GATEWAY_MODEL_ID_PREFIX) || requestedModel.startsWith(WORKSPACE_OPENROUTER_MODEL_ID_PREFIX) ? (await resolveWorkspaceCatalogSettings(service.db, catalogSourceSettings, {
275
+ accountId: input.accountId,
257
276
  workspaceId: input.workspaceId,
258
- runId: run.id,
259
- status: "failed",
260
- errorCode: denial
261
- });
262
- throw new Error(`automation admission denied: ${denial}`);
263
- }
264
- const reasoningEffort = template.reasoningEffort ?? service.settings.openaiReasoningEffort;
265
- const sandboxBackend = template.sandboxBackend ?? service.settings.sandboxBackend;
266
- if (sandboxBackend === "selfhosted") {
267
- await settle(service.db, {
277
+ retainedProductModelId: requestedModel
278
+ })).settings : deploymentCatalogSettings;
279
+ const catalogService = { ...service, settings: catalogSettings };
280
+ let model;
281
+ try {
282
+ const configuredModel = canonicalConfiguredModel(catalogSettings, requestedModel);
283
+ if (!configuredModel) throw new Error("automation has no configured model");
284
+ await assertModelPolicy(service.db, catalogSettings, input.workspaceId, configuredModel);
285
+ model = configuredModel;
286
+ } catch (error) {
287
+ if (!isUnprocessableEntity(error)) throw error;
288
+ await settle(service.db, {
289
+ workspaceId: input.workspaceId,
290
+ runId: run.id,
291
+ status: "failed",
292
+ errorCode: "dispatch_failed"
293
+ });
294
+ return { action: "failed", reason: "dispatch_failed" };
295
+ }
296
+ const denial = await admit(catalogService, {
297
+ accountId: input.accountId,
268
298
  workspaceId: input.workspaceId,
269
- runId: run.id,
270
- status: "skipped",
271
- errorCode: "interactive_compute_not_allowed"
299
+ model,
300
+ requestedAgentRuns: 1
301
+ });
302
+ if (denial) {
303
+ await settle(service.db, {
304
+ workspaceId: input.workspaceId,
305
+ runId: run.id,
306
+ status: "failed",
307
+ errorCode: denial
308
+ });
309
+ return { action: "failed", reason: denial };
310
+ }
311
+ const reasoningEffort = template.reasoningEffort ?? catalogSettings.openaiReasoningEffort;
312
+ const sandboxBackend = template.sandboxBackend ?? catalogSettings.sandboxBackend;
313
+ if (sandboxBackend === "selfhosted") {
314
+ await settle(service.db, {
315
+ workspaceId: input.workspaceId,
316
+ runId: run.id,
317
+ status: "skipped",
318
+ errorCode: "interactive_compute_not_allowed"
319
+ });
320
+ return {
321
+ action: "skipped",
322
+ reason: "interactive_compute_not_allowed"
323
+ };
324
+ }
325
+ const turnExecutionPolicy = resolveTurnExecutionPolicyV1(catalogSettings, {
326
+ modelId: model,
327
+ requestedModelId: template.model,
328
+ modelSource: template.model ? "explicit" : "deployment",
329
+ reasoningEffort,
330
+ reasoningSource: template.reasoningEffort ? "explicit" : "deployment",
331
+ latencyMode: "standard",
332
+ latencyModeSource: "deployment"
272
333
  });
273
- return { action: "skipped", reason: "interactive_compute_not_allowed" };
274
- }
275
- const turnExecutionPolicy = resolveTurnExecutionPolicyV1(service.settings, {
276
- modelId: model,
277
- requestedModelId: template.model,
278
- modelSource: template.model ? "explicit" : "deployment",
279
- reasoningEffort,
280
- reasoningSource: template.reasoningEffort ? "explicit" : "deployment",
281
- latencyMode: "standard",
282
- latencyModeSource: "deployment"
283
- });
284
- try {
285
334
  const created = await createSession2({
286
335
  db: service.db,
287
336
  bus: service.bus,
@@ -329,11 +378,12 @@ function createAutomationActivities(services, options = {}) {
329
378
  policyRole: template.policyRole,
330
379
  firstPartyMcpPermissions: template.firstPartyMcpPermissions,
331
380
  firstPartyMcpTools: template.firstPartyMcpTools,
381
+ retainWorkspaceCustomModel: model.startsWith(WORKSPACE_GATEWAY_MODEL_ID_PREFIX) || model.startsWith(WORKSPACE_OPENROUTER_MODEL_ID_PREFIX),
332
382
  createIdempotencyKey: `automation-run:${run.id}`,
333
383
  subjectId: accepted.serviceSubjectId
334
384
  });
335
385
  await recordUsage(
336
- { db: service.db, settings: service.settings },
386
+ { db: service.db, settings: catalogSettings },
337
387
  {
338
388
  accountId: input.accountId,
339
389
  workspaceId: input.workspaceId,
@@ -367,17 +417,14 @@ function createAutomationActivities(services, options = {}) {
367
417
  });
368
418
  return { action: "skipped", reason: "authority_revoked" };
369
419
  }
370
- await settle(service.db, {
371
- workspaceId: input.workspaceId,
372
- runId: run.id,
373
- status: "failed",
374
- errorCode: "dispatch_failed"
375
- });
376
420
  throw error;
377
421
  }
378
422
  }
379
423
  };
380
424
  }
425
+ function isUnprocessableEntity(error) {
426
+ return error instanceof Error && "status" in error && error.status === 422;
427
+ }
381
428
 
382
429
  // src/activities/documents.ts
383
430
  import { configuredStaticUsageLimits as configuredStaticUsageLimits2 } from "@opengeni/config";
@@ -3885,11 +3932,13 @@ function rigPlatformChecksForSettings(settings) {
3885
3932
  'test -x "$__og_browser_engine"',
3886
3933
  '__og_browser_token="$(mktemp)"',
3887
3934
  `trap 'opengeni-browserd-down >/dev/null 2>&1 || true; rm -f "$__og_browser_token"' EXIT`,
3888
- `printf '%s\\n' 'rig-platform-check' > "$__og_browser_token"`,
3935
+ `__og_browser_token_value="$(od -An -N32 -tx1 /dev/urandom | tr -d '[:space:]')"`,
3936
+ 'test "${#__og_browser_token_value}" -eq 64',
3937
+ `printf '%s\\n' "$__og_browser_token_value" > "$__og_browser_token"`,
3889
3938
  'chmod 0600 "$__og_browser_token"',
3890
3939
  'OPENGENI_BROWSERD_ADMIN_TOKEN_FILE="$__og_browser_token" OPENGENI_BROWSERD_PORT=7682 OPENGENI_BROWSERD_ALLOWED_ORIGINS= opengeni-browserd-up',
3891
3940
  "curl --noproxy '*' -fsS http://127.0.0.1:7682/healthz >/dev/null",
3892
- "curl --noproxy '*' -fsS -H 'Authorization: Bearer rig-platform-check' http://127.0.0.1:7682/v1/browser-sessions >/dev/null"
3941
+ `curl --noproxy '*' -fsS -H "Authorization: Bearer $__og_browser_token_value" http://127.0.0.1:7682/v1/browser-sessions >/dev/null`
3893
3942
  ].join("\n")
3894
3943
  }
3895
3944
  ];
@@ -3916,7 +3965,7 @@ function rigPlatformChecksForSettings(settings) {
3916
3965
  "test -x /usr/local/bin/opengeni-desktop-down",
3917
3966
  "command -v Xvfb >/dev/null",
3918
3967
  "command -v x11vnc >/dev/null",
3919
- "command -v websockify >/dev/null",
3968
+ "test -x /opt/noVNC/utils/novnc_proxy",
3920
3969
  "command -v scrot >/dev/null",
3921
3970
  "command -v xdotool >/dev/null",
3922
3971
  '__og_desktop_home="$(mktemp -d)"',
@@ -7229,13 +7278,17 @@ import {
7229
7278
  ScheduledTaskRunAcceptedExecution,
7230
7279
  normalizeAutomaticSessionTitle,
7231
7280
  scheduledOccurrencePayloadUtf8Bytes,
7232
- stableJson
7281
+ stableJson,
7282
+ TurnExecutionPolicyV1
7233
7283
  } from "@opengeni/contracts";
7234
7284
  import {
7235
7285
  defaultSessionMcpServerIds,
7236
7286
  openGeniSlackBotMetadata,
7237
7287
  requireOpenGeniSlackBotConnection,
7288
+ resolveWorkspaceCatalogSettings as resolveWorkspaceCatalogSettings2,
7238
7289
  resolveSessionToolPolicy,
7290
+ workspaceCustomModelReference,
7291
+ lockActiveCustomModelForAdmission,
7239
7292
  scheduledSlackBotConnectionId,
7240
7293
  swapActiveSandbox
7241
7294
  } from "@opengeni/core";
@@ -7283,8 +7336,9 @@ import {
7283
7336
  withSessionActivityRlsContext
7284
7337
  } from "@opengeni/db";
7285
7338
  import { publishDurableSessionEvents } from "@opengeni/events";
7286
- import { resolveFirstPartyMcpToolPolicy } from "@opengeni/config";
7339
+ import { resolveFirstPartyMcpToolPolicy, resolveTurnExecutionPolicyV1 as resolveTurnExecutionPolicyV12 } from "@opengeni/config";
7287
7340
  import { Context as Context2 } from "@temporalio/activity";
7341
+ import { createHash as createHash5 } from "crypto";
7288
7342
 
7289
7343
  // src/scheduled-alert-occurrence.ts
7290
7344
  import { createHash as createHash4 } from "crypto";
@@ -7420,6 +7474,10 @@ function scheduledTaskRunProducerKey(input, suppliedActivityIdentity) {
7420
7474
  workflowId: info.workflowExecution.workflowId
7421
7475
  })}`;
7422
7476
  }
7477
+ function scheduledTaskGeneratedSessionCreateIdempotencyKey(producerKey) {
7478
+ const digest = createHash5("sha256").update("scheduled-task-run\0", "utf8").update(producerKey, "utf8").digest("hex");
7479
+ return `scheduled-task-run:${digest}`;
7480
+ }
7423
7481
  function scheduledTaskSessionTitle(taskName) {
7424
7482
  return normalizeAutomaticSessionTitle(taskName) ?? "Scheduled run";
7425
7483
  }
@@ -7440,11 +7498,20 @@ async function stampScheduledSessionTitle(db, input) {
7440
7498
  function createScheduledTaskActivities(services) {
7441
7499
  return {
7442
7500
  dispatchScheduledTaskRun: async (input) => {
7443
- const service = await services();
7444
- const { settings, db, bus, wakeSessionWorkflow } = service;
7501
+ const baseService = await services();
7445
7502
  if (input.triggerType !== "scheduled" && !input.initiator) {
7446
7503
  return { action: "blocked", reason: "malformed_manual_trigger" };
7447
7504
  }
7505
+ const { db, bus, wakeSessionWorkflow } = baseService;
7506
+ const settingsForTask = async (task2, retainedProductModelId) => (await resolveWorkspaceCatalogSettings2(
7507
+ db,
7508
+ baseService.catalogSourceSettings ?? baseService.settings,
7509
+ {
7510
+ accountId: task2.accountId,
7511
+ workspaceId: task2.workspaceId,
7512
+ ...retainedProductModelId !== void 0 ? { retainedProductModelId } : {}
7513
+ }
7514
+ )).settings;
7448
7515
  const stableProducerKey = scheduledTaskRunProducerKey(input);
7449
7516
  const priorRun = await getScheduledTaskRunByProducerKey(db, {
7450
7517
  workspaceId: input.workspaceId,
@@ -7474,11 +7541,16 @@ function createScheduledTaskActivities(services) {
7474
7541
  });
7475
7542
  }
7476
7543
  if (priorRun.status === "queued") {
7544
+ const acceptedPolicy = acceptedExecution.turnExecutionPolicy ? TurnExecutionPolicyV1.parse(acceptedExecution.turnExecutionPolicy) : null;
7545
+ const settings2 = await settingsForTask(
7546
+ acceptedExecution.task,
7547
+ acceptedPolicy?.productModelId ?? acceptedExecution.targetSessionExecution?.model ?? acceptedExecution.resolvedModel
7548
+ );
7477
7549
  try {
7478
7550
  return await recoverBoundScheduledTaskDispatch({
7479
7551
  db,
7480
7552
  bus,
7481
- settings,
7553
+ settings: settings2,
7482
7554
  wakeSessionWorkflow,
7483
7555
  run: priorRun,
7484
7556
  acceptedExecution,
@@ -7629,6 +7701,14 @@ function createScheduledTaskActivities(services) {
7629
7701
  throw new Error("scheduled authority classes have different causal humans");
7630
7702
  }
7631
7703
  const taskAuthoritySubjectId = taskRevisionAuthority?.subjectId ?? taskPersonalResourceAuthoritySubjectId ?? taskConnectionAuthoritySubjectId;
7704
+ const acceptedTargetSessionId = task.runMode === "existing_session" ? task.targetSessionId : task.runMode === "reusable_session" ? task.reusableSessionId : null;
7705
+ const targetSessionExecutionBase = acceptedTargetSessionId ? await getScheduledTargetSessionExecution(
7706
+ db,
7707
+ task.workspaceId,
7708
+ acceptedTargetSessionId,
7709
+ taskAuthoritySubjectId
7710
+ ) : null;
7711
+ const settings = await settingsForTask(task, targetSessionExecutionBase?.model);
7632
7712
  const model = task.agentConfig.model ?? settings.openaiModel;
7633
7713
  const reasoningEffort = task.agentConfig.reasoningEffort ?? settings.openaiReasoningEffort;
7634
7714
  let sandboxBackend = task.agentConfig.sandboxBackend ?? settings.sandboxBackend;
@@ -7678,13 +7758,6 @@ function createScheduledTaskActivities(services) {
7678
7758
  codexCompactionMode: isCodexBilledModel(model) ? resolveWorkspaceCodexCompactionDefault(workspace.settings) : "portable"
7679
7759
  };
7680
7760
  })() : null;
7681
- const acceptedTargetSessionId = generatedTarget ? null : task.runMode === "existing_session" ? task.targetSessionId : task.reusableSessionId;
7682
- const targetSessionExecutionBase = acceptedTargetSessionId ? await getScheduledTargetSessionExecution(
7683
- db,
7684
- task.workspaceId,
7685
- acceptedTargetSessionId,
7686
- taskAuthoritySubjectId
7687
- ) : null;
7688
7761
  const targetSessionExecution = targetSessionExecutionBase ? await (async () => {
7689
7762
  const [capabilityServerIds, apiIntegrationServerIds] = await Promise.all([
7690
7763
  listEnabledMcpCapabilityServerIds(db, task.workspaceId),
@@ -7839,20 +7912,49 @@ function createScheduledTaskActivities(services) {
7839
7912
  if ((acceptedVariableSet?.scope === "user" || acceptedRig?.scope === "user") && !causalHumanSubjectId) {
7840
7913
  throw new Error("scheduled personal-resource execution has no causal human");
7841
7914
  }
7842
- const admissionDenial = await agentRunAdmissionDenial(service, {
7843
- accountId: task.accountId,
7844
- workspaceId: task.workspaceId,
7845
- model: targetSessionExecution?.model ?? model,
7846
- requestedAgentRuns: input.agentRunUsageIdempotencyKey ? 0 : 1
7847
- });
7915
+ const admissionDenial = await agentRunAdmissionDenial(
7916
+ { ...baseService, settings },
7917
+ {
7918
+ accountId: task.accountId,
7919
+ workspaceId: task.workspaceId,
7920
+ model: targetSessionExecution?.model ?? model,
7921
+ requestedAgentRuns: input.agentRunUsageIdempotencyKey ? 0 : 1
7922
+ }
7923
+ );
7848
7924
  if (admissionDenial) {
7849
7925
  return { action: "blocked", reason: admissionDenial };
7850
7926
  }
7927
+ const acceptedModel = targetSessionExecution?.model ?? model;
7928
+ const acceptedReasoningEffort = targetSessionExecution?.reasoningEffort ?? reasoningEffort;
7929
+ const acceptedLatencyMode = targetSessionExecution?.latencyMode ?? "standard";
7930
+ const acceptedCustomModel = generatedTarget ? workspaceCustomModelReference(settings, acceptedModel) : null;
7931
+ const beforeFreshAgentRunCommit = acceptedCustomModel ? async (tx) => {
7932
+ const active = await lockActiveCustomModelForAdmission(tx, {
7933
+ accountId: task.accountId,
7934
+ workspaceId: task.workspaceId,
7935
+ reference: acceptedCustomModel
7936
+ });
7937
+ if (!active) {
7938
+ throw new ScheduledRunTerminalAuthorityError(
7939
+ "scheduled_model_unavailable",
7940
+ `model is not available: ${acceptedModel}`
7941
+ );
7942
+ }
7943
+ } : void 0;
7944
+ const turnExecutionPolicy = resolveTurnExecutionPolicyV12(settings, {
7945
+ modelId: acceptedModel,
7946
+ requestedModelId: generatedTarget && task.agentConfig.model ? task.agentConfig.model : null,
7947
+ modelSource: generatedTarget ? task.agentConfig.model ? "explicit" : "deployment" : "session",
7948
+ reasoningEffort: acceptedReasoningEffort,
7949
+ reasoningSource: generatedTarget ? task.agentConfig.reasoningEffort ? "explicit" : "deployment" : "session",
7950
+ latencyMode: acceptedLatencyMode,
7951
+ latencyModeSource: generatedTarget ? "deployment" : "session"
7952
+ });
7851
7953
  const deferredEvents = [];
7852
7954
  const executeDispatch = async (dispatchDb, deferPublications) => {
7853
7955
  const admittedRunId = crypto.randomUUID();
7854
7956
  const generatedSessionBinding = generatedTarget ? {
7855
- createIdempotencyKey: alertResponderSessionCreateIdempotencyKey ?? (task.runMode === "reusable_session" ? `scheduled-task-reusable:${task.id}:${task.authorityRevision}:${task.executionDigest}` : `scheduled-task-run:${admittedRunId}`),
7957
+ createIdempotencyKey: alertResponderSessionCreateIdempotencyKey ?? (task.runMode === "reusable_session" ? `scheduled-task-reusable:${task.id}:${task.authorityRevision}:${task.executionDigest}` : scheduledTaskGeneratedSessionCreateIdempotencyKey(stableProducerKey)),
7856
7958
  effectiveMaxNestedAgentDepth: generatedSessionDepthPolicy.effectiveMaxNestedAgentDepth,
7857
7959
  nestedAgentDepthPolicySource: generatedSessionDepthPolicy.nestedAgentDepthPolicySource,
7858
7960
  codexCompactionMode: generatedSessionDepthPolicy.codexCompactionMode
@@ -7863,6 +7965,7 @@ function createScheduledTaskActivities(services) {
7863
7965
  resolvedModel: model,
7864
7966
  resolvedReasoningEffort: reasoningEffort,
7865
7967
  resolvedLatencyMode: "standard",
7968
+ turnExecutionPolicy,
7866
7969
  resolvedSandboxBackend: sandboxBackend,
7867
7970
  resolvedSandboxOs: sandboxOs,
7868
7971
  resolvedTools: taskTools,
@@ -7917,7 +8020,8 @@ function createScheduledTaskActivities(services) {
7917
8020
  triggerType: input.triggerType,
7918
8021
  producerKey: stableProducerKey,
7919
8022
  scheduledAt: null,
7920
- acceptedExecutionSnapshot: acceptedExecution
8023
+ acceptedExecutionSnapshot: acceptedExecution,
8024
+ ...beforeFreshAgentRunCommit ? { beforeFreshAgentRunCommit } : {}
7921
8025
  });
7922
8026
  await recordScheduledTaskFiredUsage(dispatchDb, acceptedExecution, run);
7923
8027
  if (run.status === "failed" && run.error === "scheduled_authority_exhausted") {
@@ -8326,15 +8430,16 @@ function createScheduledTaskActivities(services) {
8326
8430
  xaiProviderAccountAuthoritySnapshot: taskXaiProviderAccountAuthoritySnapshot,
8327
8431
  scheduledTaskRunId: run.id
8328
8432
  },
8329
- async (tx, wakeEventId) => {
8433
+ async (tx, wakeEventId, _updateId, rejectionReason) => {
8330
8434
  if (!wakeEventId) {
8435
+ const error = scheduledSessionRejectionError(rejectionReason);
8331
8436
  await settleScheduledTaskRunInTransaction(tx, {
8332
8437
  workspaceId: task.workspaceId,
8333
8438
  runId: scheduledRun.id,
8334
8439
  sessionId: session.id,
8335
8440
  triggerEventId: null,
8336
8441
  status: "skipped",
8337
- error: "session_cancelled"
8442
+ error
8338
8443
  });
8339
8444
  return;
8340
8445
  }
@@ -8346,23 +8451,27 @@ function createScheduledTaskActivities(services) {
8346
8451
  status: "dispatched"
8347
8452
  });
8348
8453
  },
8349
- incidentPreflightRequired ? {
8350
- prepareSource: async (tx, sessionId) => await prepareIncidentTelemetrySource({
8351
- tx,
8352
- settings,
8353
- taskId: task.id,
8354
- workspaceId: task.workspaceId,
8355
- sessionId,
8356
- alertOccurrenceLabels: structuredAlertOccurrence?.labels ?? null,
8357
- acceptedExecution
8358
- })
8359
- } : void 0
8454
+ {
8455
+ requireIdleSession: task.overlapPolicy === "skip" && !sessionCreated,
8456
+ ...incidentPreflightRequired ? {
8457
+ prepareSource: async (tx, sessionId) => await prepareIncidentTelemetrySource({
8458
+ tx,
8459
+ settings,
8460
+ taskId: task.id,
8461
+ workspaceId: task.workspaceId,
8462
+ sessionId,
8463
+ alertOccurrenceLabels: structuredAlertOccurrence?.labels ?? null,
8464
+ acceptedExecution
8465
+ })
8466
+ } : {}
8467
+ }
8360
8468
  );
8361
- if (scheduledUpdate.reason === "session_cancelled") {
8469
+ if (scheduledUpdate.reason === "session_cancelled" || scheduledUpdate.reason === "session_not_idle") {
8470
+ const error = scheduledSessionRejectionError(scheduledUpdate.reason);
8362
8471
  return {
8363
8472
  kind: "blocked",
8364
8473
  result: { action: "blocked", reason: "scheduled_run_terminal" },
8365
- run: { ...run, status: "skipped", error: "session_cancelled" }
8474
+ run: { ...run, status: "skipped", error }
8366
8475
  };
8367
8476
  }
8368
8477
  if (scheduledUpdate.added && scheduledUpdate.events.length > 0) {
@@ -8401,26 +8510,6 @@ function createScheduledTaskActivities(services) {
8401
8510
  });
8402
8511
  assertReusableSessionRevivable(session.status);
8403
8512
  assertReusableSessionBindingMatches(session, task);
8404
- const goalEvents = task.runMode === "reusable_session" && goalSpec && run.status === "queued" ? await upsertScheduledSessionGoalForRun(dispatchDb, {
8405
- accountId: task.accountId,
8406
- workspaceId: task.workspaceId,
8407
- sessionId: session.id,
8408
- runId: run.id,
8409
- text: goalSpec.text,
8410
- successCriteria: goalSpec.successCriteria ?? null,
8411
- maxAutoContinuations: goalSpec.maxAutoContinuations ?? null,
8412
- ...goalSpec.mutationPolicy ? { mutationPolicy: goalSpec.mutationPolicy } : {}
8413
- }) : [];
8414
- if (goalEvents.length > 0) {
8415
- if (deferPublications) {
8416
- deferredEvents.push({
8417
- sessionId: session.id,
8418
- events: goalEvents
8419
- });
8420
- } else {
8421
- await publishDurableSessionEvents(bus, task.workspaceId, session.id, goalEvents);
8422
- }
8423
- }
8424
8513
  const bundled = await addSessionSystemUpdateWithSourceMutation(
8425
8514
  dispatchDb,
8426
8515
  {
@@ -8450,15 +8539,16 @@ function createScheduledTaskActivities(services) {
8450
8539
  xaiProviderAccountAuthoritySnapshot: taskXaiProviderAccountAuthoritySnapshot,
8451
8540
  scheduledTaskRunId: run.id
8452
8541
  },
8453
- async (tx, wakeEventId) => {
8542
+ async (tx, wakeEventId, _updateId, rejectionReason) => {
8454
8543
  if (!wakeEventId) {
8544
+ const error = scheduledSessionRejectionError(rejectionReason);
8455
8545
  await settleScheduledTaskRunInTransaction(tx, {
8456
8546
  workspaceId: task.workspaceId,
8457
8547
  runId: scheduledRun.id,
8458
8548
  sessionId: session.id,
8459
8549
  triggerEventId: null,
8460
8550
  status: "skipped",
8461
- error: "session_cancelled"
8551
+ error
8462
8552
  });
8463
8553
  return;
8464
8554
  }
@@ -8470,23 +8560,41 @@ function createScheduledTaskActivities(services) {
8470
8560
  status: "dispatched"
8471
8561
  });
8472
8562
  },
8473
- incidentPreflightRequired ? {
8474
- prepareSource: async (tx, sessionId) => await prepareIncidentTelemetrySource({
8475
- tx,
8476
- settings,
8477
- taskId: task.id,
8478
- workspaceId: task.workspaceId,
8479
- sessionId,
8480
- alertOccurrenceLabels: structuredAlertOccurrence?.labels ?? null,
8481
- acceptedExecution
8482
- })
8483
- } : void 0
8563
+ {
8564
+ requireIdleSession: task.overlapPolicy === "skip",
8565
+ prepareSource: async (tx, sessionId) => {
8566
+ const goalEvents = task.runMode === "reusable_session" && goalSpec && run.status === "queued" ? await upsertScheduledSessionGoalForRun(tx, {
8567
+ accountId: task.accountId,
8568
+ workspaceId: task.workspaceId,
8569
+ sessionId,
8570
+ runId: run.id,
8571
+ text: goalSpec.text,
8572
+ successCriteria: goalSpec.successCriteria ?? null,
8573
+ maxAutoContinuations: goalSpec.maxAutoContinuations ?? null,
8574
+ ...goalSpec.mutationPolicy ? { mutationPolicy: goalSpec.mutationPolicy } : {}
8575
+ }) : [];
8576
+ const incidentSource = incidentPreflightRequired ? await prepareIncidentTelemetrySource({
8577
+ tx,
8578
+ settings,
8579
+ taskId: task.id,
8580
+ workspaceId: task.workspaceId,
8581
+ sessionId,
8582
+ alertOccurrenceLabels: structuredAlertOccurrence?.labels ?? null,
8583
+ acceptedExecution
8584
+ }) : void 0;
8585
+ return {
8586
+ ...incidentSource ?? {},
8587
+ ...goalEvents.length > 0 ? { events: goalEvents } : {}
8588
+ };
8589
+ }
8590
+ }
8484
8591
  );
8485
- if (bundled.reason === "session_cancelled") {
8592
+ if (bundled.reason === "session_cancelled" || bundled.reason === "session_not_idle") {
8593
+ const error = scheduledSessionRejectionError(bundled.reason);
8486
8594
  return {
8487
8595
  kind: "blocked",
8488
8596
  result: { action: "blocked", reason: "scheduled_run_terminal" },
8489
- run: { ...run, status: "skipped", error: "session_cancelled" }
8597
+ run: { ...run, status: "skipped", error }
8490
8598
  };
8491
8599
  }
8492
8600
  if (bundled.added && bundled.events.length > 0) {
@@ -8562,6 +8670,10 @@ function createScheduledTaskActivities(services) {
8562
8670
  if (error instanceof IncidentTelemetryPreflightBlockedError) {
8563
8671
  return { action: "blocked", reason: error.reason };
8564
8672
  }
8673
+ const terminalError = scheduledRunRecoveryTerminalError(error);
8674
+ if (terminalError?.code === "scheduled_model_unavailable") {
8675
+ return scheduledRunTerminalResult(terminalError.code);
8676
+ }
8565
8677
  throw error;
8566
8678
  }
8567
8679
  if (dispatchOutcome.kind === "replay") {
@@ -8674,6 +8786,9 @@ function scheduledRunTerminalResult(error) {
8674
8786
  }
8675
8787
  return { action: "blocked", reason: "scheduled_run_terminal" };
8676
8788
  }
8789
+ function scheduledSessionRejectionError(rejectionReason) {
8790
+ return rejectionReason === "session_not_idle" ? "scheduled_session_not_idle" : "session_cancelled";
8791
+ }
8677
8792
  async function prepareIncidentTelemetrySource(input) {
8678
8793
  const session = await requireSession(input.tx, input.workspaceId, input.sessionId);
8679
8794
  const { task, personalConnectionDelegations } = input.acceptedExecution ? {
@@ -9061,21 +9176,6 @@ async function recoverBoundScheduledTaskDispatch(input) {
9061
9176
  await publishDurableSessionEvents(input.bus, task.workspaceId, session.id, titleEvents);
9062
9177
  }
9063
9178
  }
9064
- if (!generatedSession && task.runMode === "reusable_session" && task.agentConfig.goal) {
9065
- const goalEvents = await upsertScheduledSessionGoalForRun(input.db, {
9066
- accountId: task.accountId,
9067
- workspaceId: task.workspaceId,
9068
- sessionId: session.id,
9069
- runId: input.run.id,
9070
- text: task.agentConfig.goal.text,
9071
- successCriteria: task.agentConfig.goal.successCriteria ?? null,
9072
- maxAutoContinuations: task.agentConfig.goal.maxAutoContinuations ?? null,
9073
- ...task.agentConfig.goal.mutationPolicy ? { mutationPolicy: task.agentConfig.goal.mutationPolicy } : {}
9074
- });
9075
- if (goalEvents.length > 0) {
9076
- await publishDurableSessionEvents(input.bus, task.workspaceId, session.id, goalEvents);
9077
- }
9078
- }
9079
9179
  const scheduledUpdate = await addSessionSystemUpdateWithSourceMutation(
9080
9180
  input.db,
9081
9181
  {
@@ -9107,15 +9207,16 @@ async function recoverBoundScheduledTaskDispatch(input) {
9107
9207
  xaiProviderAccountAuthoritySnapshot: input.acceptedExecution.xaiProviderAccountAuthoritySnapshot,
9108
9208
  scheduledTaskRunId: input.run.id
9109
9209
  },
9110
- async (tx, wakeEventId) => {
9210
+ async (tx, wakeEventId, _updateId, rejectionReason) => {
9111
9211
  if (!wakeEventId) {
9212
+ const error = scheduledSessionRejectionError(rejectionReason);
9112
9213
  await settleScheduledTaskRunInTransaction(tx, {
9113
9214
  workspaceId: task.workspaceId,
9114
9215
  runId: input.run.id,
9115
9216
  sessionId: session.id,
9116
9217
  triggerEventId: null,
9117
9218
  status: "skipped",
9118
- error: "session_cancelled"
9219
+ error
9119
9220
  });
9120
9221
  return;
9121
9222
  }
@@ -9127,19 +9228,37 @@ async function recoverBoundScheduledTaskDispatch(input) {
9127
9228
  status: "dispatched"
9128
9229
  });
9129
9230
  },
9130
- input.acceptedExecution.incidentPreflightRequired ? {
9131
- prepareSource: async (tx, sessionId) => await prepareIncidentTelemetrySource({
9132
- tx,
9133
- settings: input.settings,
9134
- taskId: task.id,
9135
- workspaceId: task.workspaceId,
9136
- sessionId,
9137
- alertOccurrenceLabels: input.acceptedExecution.alertOccurrenceLabels,
9138
- acceptedExecution: input.acceptedExecution
9139
- })
9140
- } : void 0
9231
+ {
9232
+ requireIdleSession: task.overlapPolicy === "skip" && !generatedSession,
9233
+ prepareSource: async (tx, sessionId) => {
9234
+ const goal = task.agentConfig.goal;
9235
+ const goalEvents = !generatedSession && task.runMode === "reusable_session" && goal ? await upsertScheduledSessionGoalForRun(tx, {
9236
+ accountId: task.accountId,
9237
+ workspaceId: task.workspaceId,
9238
+ sessionId,
9239
+ runId: input.run.id,
9240
+ text: goal.text,
9241
+ successCriteria: goal.successCriteria ?? null,
9242
+ maxAutoContinuations: goal.maxAutoContinuations ?? null,
9243
+ ...goal.mutationPolicy ? { mutationPolicy: goal.mutationPolicy } : {}
9244
+ }) : [];
9245
+ const incidentSource = input.acceptedExecution.incidentPreflightRequired ? await prepareIncidentTelemetrySource({
9246
+ tx,
9247
+ settings: input.settings,
9248
+ taskId: task.id,
9249
+ workspaceId: task.workspaceId,
9250
+ sessionId,
9251
+ alertOccurrenceLabels: input.acceptedExecution.alertOccurrenceLabels,
9252
+ acceptedExecution: input.acceptedExecution
9253
+ }) : void 0;
9254
+ return {
9255
+ ...incidentSource ?? {},
9256
+ ...goalEvents.length > 0 ? { events: goalEvents } : {}
9257
+ };
9258
+ }
9259
+ }
9141
9260
  );
9142
- if (scheduledUpdate.reason === "session_cancelled") {
9261
+ if (scheduledUpdate.reason === "session_cancelled" || scheduledUpdate.reason === "session_not_idle") {
9143
9262
  return { action: "blocked", reason: "scheduled_run_terminal" };
9144
9263
  }
9145
9264
  if (scheduledUpdate.added && scheduledUpdate.events.length > 0) {
@@ -9252,7 +9371,7 @@ function knowledgeSourceSyncEffectivelyPaused(task) {
9252
9371
  }
9253
9372
 
9254
9373
  // src/activities/site-auth-maintenance.ts
9255
- import { resolveTurnExecutionPolicyV1 as resolveTurnExecutionPolicyV12 } from "@opengeni/config";
9374
+ import { resolveTurnExecutionPolicyV1 as resolveTurnExecutionPolicyV13 } from "@opengeni/config";
9256
9375
  import {
9257
9376
  DEFAULT_FIRST_PARTY_MCP_PERMISSIONS as DEFAULT_FIRST_PARTY_MCP_PERMISSIONS2,
9258
9377
  SITE_AUTH_MAINTENANCE_CONNECTION_CONTEXT_KEY,
@@ -9262,7 +9381,8 @@ import {
9262
9381
  assertWorkspaceModelPolicyAllows as assertWorkspaceModelPolicyAllows2,
9263
9382
  canonicalConfiguredModel as canonicalConfiguredModel2,
9264
9383
  createAndStartSessionWithOutcome as createAndStartSessionWithOutcome2,
9265
- recordWorkspaceUsage as recordWorkspaceUsage2
9384
+ recordWorkspaceUsage as recordWorkspaceUsage2,
9385
+ resolveCatalogSettings as resolveCatalogSettings2
9266
9386
  } from "@opengeni/core";
9267
9387
  import {
9268
9388
  claimSiteAuthMaintenance,
@@ -9338,23 +9458,20 @@ function createSiteAuthMaintenanceActivities(services, options = {}) {
9338
9458
  return { maintainSiteAuthConnections };
9339
9459
  }
9340
9460
  async function dispatchMaintenanceSession(service, maintenance, dependencies) {
9341
- const model = canonicalConfiguredModel2(service.settings, service.settings.openaiModel);
9461
+ const catalogSettings = (await resolveCatalogSettings2(service.db, service.catalogSourceSettings ?? service.settings)).settings;
9462
+ const catalogService = { ...service, settings: catalogSettings };
9463
+ const model = canonicalConfiguredModel2(catalogSettings, catalogSettings.openaiModel);
9342
9464
  if (!model) throw new Error("site auth maintenance has no configured model");
9343
- await dependencies.assertModelPolicy(
9344
- service.db,
9345
- service.settings,
9346
- maintenance.workspaceId,
9347
- model
9348
- );
9349
- const denial = await dependencies.admit(service, {
9465
+ await dependencies.assertModelPolicy(service.db, catalogSettings, maintenance.workspaceId, model);
9466
+ const denial = await dependencies.admit(catalogService, {
9350
9467
  accountId: maintenance.accountId,
9351
9468
  workspaceId: maintenance.workspaceId,
9352
9469
  model,
9353
9470
  requestedAgentRuns: 1
9354
9471
  });
9355
9472
  if (denial) throw new Error(`site auth maintenance admission denied: ${denial}`);
9356
- const reasoningEffort = service.settings.openaiReasoningEffort;
9357
- const turnExecutionPolicy = resolveTurnExecutionPolicyV12(service.settings, {
9473
+ const reasoningEffort = catalogSettings.openaiReasoningEffort;
9474
+ const turnExecutionPolicy = resolveTurnExecutionPolicyV13(catalogSettings, {
9358
9475
  modelId: model,
9359
9476
  requestedModelId: null,
9360
9477
  modelSource: "deployment",
@@ -9391,7 +9508,7 @@ async function dispatchMaintenanceSession(service, maintenance, dependencies) {
9391
9508
  model,
9392
9509
  reasoningEffort,
9393
9510
  turnExecutionPolicy,
9394
- sandboxBackend: service.settings.sandboxBackend,
9511
+ sandboxBackend: catalogSettings.sandboxBackend,
9395
9512
  metadata: {
9396
9513
  role: "site_auth_maintenance",
9397
9514
  [SITE_AUTH_MAINTENANCE_CONNECTION_CONTEXT_KEY]: maintenance.siteAuthConnectionId,
@@ -9415,7 +9532,7 @@ async function dispatchMaintenanceSession(service, maintenance, dependencies) {
9415
9532
  });
9416
9533
  try {
9417
9534
  await dependencies.recordUsage(
9418
- { db: service.db, settings: service.settings },
9535
+ { db: service.db, settings: catalogSettings },
9419
9536
  {
9420
9537
  accountId: maintenance.accountId,
9421
9538
  workspaceId: maintenance.workspaceId,
@@ -9937,4 +10054,4 @@ export {
9937
10054
  createControlActivities,
9938
10055
  createControlActivitiesFromServices
9939
10056
  };
9940
- //# sourceMappingURL=activities-control-52W5IDWM.js.map
10057
+ //# sourceMappingURL=activities-control-ZWH7J4KZ.js.map