@opengeni/worker-bundle 2.3.1-canary.37062299158001 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/activities/agent-turn/claude-usage-observer.d.ts +6 -30
  2. package/dist/activities/agent-turn/credential-leases.d.ts +32 -5
  3. package/dist/activities/agent-turn/errors.d.ts +0 -3
  4. package/dist/activities/agent-turn/finalization-monitor.d.ts +1 -1
  5. package/dist/activities/agent-turn/finalization.d.ts +0 -2
  6. package/dist/activities/agent-turn/quiescence.d.ts +4 -3
  7. package/dist/activities/agent-turn/turn-context.d.ts +1 -1
  8. package/dist/activities/session-state.d.ts +2 -2
  9. package/dist/activities/types.d.ts +0 -7
  10. package/dist/{activities-control-TTGQGLCJ.js → activities-control-3HAH4FMG.js} +32 -83
  11. package/dist/activities-control-3HAH4FMG.js.map +1 -0
  12. package/dist/activities-control.d.ts +4 -4
  13. package/dist/{activities-turn-TTNAVGKN.js → activities-turn-KU25J3VQ.js} +308 -263
  14. package/dist/activities-turn-KU25J3VQ.js.map +1 -0
  15. package/dist/activities.d.ts +4 -4
  16. package/dist/{chunk-PA7Z55P4.js → chunk-3K3ULWEE.js} +17 -242
  17. package/dist/chunk-3K3ULWEE.js.map +1 -0
  18. package/dist/{chunk-YOI3Z3GF.js → chunk-YG27NEMX.js} +1 -9
  19. package/dist/chunk-YG27NEMX.js.map +1 -0
  20. package/dist/http.d.ts +1 -1
  21. package/dist/index.d.ts +2 -5
  22. package/dist/index.js +16 -82
  23. package/dist/index.js.map +1 -1
  24. package/dist/observability-metrics.d.ts +1 -6
  25. package/dist/sandbox-resume.d.ts +0 -3
  26. package/dist/worker-service-lifecycle.d.ts +0 -12
  27. package/dist/workflow-bundle.js +2 -2
  28. package/package.json +21 -21
  29. package/src/activities/agent-turn/claim.ts +0 -13
  30. package/src/activities/agent-turn/claude-usage-observer.ts +8 -99
  31. package/src/activities/agent-turn/credential-leases.ts +213 -86
  32. package/src/activities/agent-turn/errors.ts +1 -61
  33. package/src/activities/agent-turn/failure-settlement.ts +5 -59
  34. package/src/activities/agent-turn/finalization-monitor.ts +4 -3
  35. package/src/activities/agent-turn/finalization.ts +3 -8
  36. package/src/activities/agent-turn/quiescence.ts +4 -3
  37. package/src/activities/agent-turn/run.ts +20 -24
  38. package/src/activities/agent-turn/sandbox-establish.ts +0 -2
  39. package/src/activities/agent-turn/sandbox-runtime.ts +1 -5
  40. package/src/activities/agent-turn/skill-selection.ts +0 -2
  41. package/src/activities/agent-turn/turn-context.ts +4 -1
  42. package/src/activities/codex-rotation.ts +12 -2
  43. package/src/activities/sandbox-lease.ts +8 -59
  44. package/src/activities/session-state.ts +4 -29
  45. package/src/activities/types.ts +0 -7
  46. package/src/activities-turn.ts +0 -5
  47. package/src/activities.ts +0 -6
  48. package/src/http.ts +2 -4
  49. package/src/index.ts +9 -39
  50. package/src/observability-metrics.ts +0 -27
  51. package/src/sandbox-resume.ts +0 -9
  52. package/src/sandbox-routing.ts +0 -77
  53. package/src/worker-service-lifecycle.ts +0 -53
  54. package/src/workflows/session.ts +1 -6
  55. package/dist/activities/agent-turn/subscription-lease.d.ts +0 -38
  56. package/dist/activities-control-TTGQGLCJ.js.map +0 -1
  57. package/dist/activities-turn-TTNAVGKN.js.map +0 -1
  58. package/dist/chunk-PA7Z55P4.js.map +0 -1
  59. package/dist/chunk-YOI3Z3GF.js.map +0 -1
  60. package/dist/session-event-fanout.d.ts +0 -6
  61. package/src/activities/agent-turn/subscription-lease.ts +0 -115
  62. package/src/session-event-fanout.ts +0 -23
@@ -185,8 +185,8 @@ export declare function createActivityTestHarness(dependencies?: ActivityDepende
185
185
  admissionFence?: import("@opengeni/db").SessionAdmissionFence;
186
186
  } | {
187
187
  kind: "admission-blocked";
188
- reason?: "sandbox_setup_outcome_unknown" | "sandbox_setup_recovery_exhausted";
189
- ref?: import("@opengeni/db").SandboxSetupOutcomeUnknown | import("@opengeni/db").SandboxSetupRecoveryExhausted;
188
+ reason?: "sandbox_setup_outcome_unknown";
189
+ ref?: import("@opengeni/db").SandboxSetupOutcomeUnknown;
190
190
  } | {
191
191
  kind: "sandbox-lifecycle-wait";
192
192
  ref: import("@opengeni/db").SandboxLifecycleWait;
@@ -319,8 +319,8 @@ export declare const peekSessionWork: (input: import("./activities/types.js").Pe
319
319
  admissionFence?: import("@opengeni/db").SessionAdmissionFence;
320
320
  } | {
321
321
  kind: "admission-blocked";
322
- reason?: "sandbox_setup_outcome_unknown" | "sandbox_setup_recovery_exhausted";
323
- ref?: import("@opengeni/db").SandboxSetupOutcomeUnknown | import("@opengeni/db").SandboxSetupRecoveryExhausted;
322
+ reason?: "sandbox_setup_outcome_unknown";
323
+ ref?: import("@opengeni/db").SandboxSetupOutcomeUnknown;
324
324
  } | {
325
325
  kind: "sandbox-lifecycle-wait";
326
326
  ref: import("@opengeni/db").SandboxLifecycleWait;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  observabilityEventBusOptions
3
- } from "./chunk-YOI3Z3GF.js";
3
+ } from "./chunk-YG27NEMX.js";
4
4
 
5
5
  // src/activity-services.ts
6
6
  import {
@@ -579,7 +579,6 @@ async function refreshExhaustedXaiQuota(input) {
579
579
  }
580
580
 
581
581
  // src/activities/codex-rotation.ts
582
- import { subscriptionAccountShardIndex } from "@opengeni/config";
583
582
  import { codexPlanExcludesModel, connectionModelAllowed } from "@opengeni/db";
584
583
  function codexAccountServesModel(account, modelId, now) {
585
584
  return connectionModelAllowed(account.allowedModelIds, modelId) && !codexPlanExcludesModel(account, modelId, now);
@@ -631,13 +630,21 @@ function isCodexCredentialHealthy(acct, now) {
631
630
  function isCodexCredentialEligible(acct, now) {
632
631
  return acct.allocatorEnabled && isCodexCredentialHealthy(acct, now);
633
632
  }
633
+ function fnv1a32(input) {
634
+ let hash = 2166136261;
635
+ for (let i = 0; i < input.length; i++) {
636
+ hash ^= input.charCodeAt(i);
637
+ hash = Math.imul(hash, 16777619);
638
+ }
639
+ return hash >>> 0;
640
+ }
634
641
  function shardCredentialForSession(args) {
635
642
  const { sessionId, accounts, now } = args;
636
643
  const eligibles = accounts.filter((acct) => isCodexCredentialEligible(acct, now));
637
644
  if (eligibles.length === 0) {
638
645
  return null;
639
646
  }
640
- const index = subscriptionAccountShardIndex(sessionId, eligibles.length);
647
+ const index = fnv1a32(sessionId) % eligibles.length;
641
648
  return eligibles[index].id;
642
649
  }
643
650
  function chooseShardedHome(args) {
@@ -4946,18 +4953,6 @@ function warnDrainSnapshotFailure(observability, message, error, lease) {
4946
4953
  }
4947
4954
  }
4948
4955
 
4949
- // src/session-event-fanout.ts
4950
- async function publishDurableSessionEvents2(bus, workspaceId, events, onError = () => void 0) {
4951
- if (!bus || !events?.length) return;
4952
- for (const sessionId of new Set(events.map((event) => event.sessionId))) {
4953
- await bus.publish(
4954
- workspaceId,
4955
- sessionId,
4956
- events.filter((event) => event.sessionId === sessionId)
4957
- ).catch(onError);
4958
- }
4959
- }
4960
-
4961
4956
  // src/sandbox-archive-storage.ts
4962
4957
  import { uploadWorkspaceArchiveSpool } from "@opengeni/storage";
4963
4958
  import { randomUUID as randomUUID2 } from "crypto";
@@ -5091,7 +5086,6 @@ async function deleteUnpublishedWorkspaceArchiveObject(objectStorage, ref, metri
5091
5086
  }
5092
5087
 
5093
5088
  // src/sandbox-routing.ts
5094
- import { isDeepStrictEqual as isDeepStrictEqual3 } from "util";
5095
5089
  import { sandboxLifecycleTransitionWaitMs as sandboxLifecycleTransitionWaitMs2 } from "@opengeni/config";
5096
5090
  import {
5097
5091
  createProviderCommandRetainer,
@@ -6482,11 +6476,6 @@ async function resumeBoxForTurnOnce(services, ids, kind, holderId) {
6482
6476
  expectedBackend: ids.backend
6483
6477
  });
6484
6478
  if (marked.status === "marked") {
6485
- await publishDurableSessionEvents2(
6486
- services.bus,
6487
- ids.workspaceId,
6488
- marked.backgroundCommandEvents
6489
- );
6490
6479
  await services.onSandboxLost?.({
6491
6480
  sandboxGroupId: ids.sandboxGroupId,
6492
6481
  instanceId: live.instanceId,
@@ -6658,11 +6647,6 @@ async function resolveCurrentHomeBackend(services, ids, established) {
6658
6647
  diagnostic: "provider_not_found_during_home_route_rebind"
6659
6648
  });
6660
6649
  if (marked.status === "marked") {
6661
- await publishDurableSessionEvents2(
6662
- services.bus,
6663
- ids.workspaceId,
6664
- marked.backgroundCommandEvents
6665
- );
6666
6650
  await services.onHomeSandboxLost?.({
6667
6651
  sandboxGroupId: ids.sandboxGroupId,
6668
6652
  instanceId: lease.instanceId,
@@ -6908,33 +6892,6 @@ function settleRetainedProcessForTurn(services, ids) {
6908
6892
  }
6909
6893
  };
6910
6894
  }
6911
- function isRetainedProcessSettledForTurn(services, ids) {
6912
- const fence = ids.workspaceMutationFence;
6913
- if (!fence) return void 0;
6914
- return async ({
6915
- backend,
6916
- process: process2
6917
- }) => {
6918
- const durable = await getRetainedProcess(services.db, {
6919
- workspaceId: ids.workspaceId,
6920
- sessionId: ids.sessionId,
6921
- processId: process2.id
6922
- });
6923
- if (!durable || durable.state === "active" || durable.providerSessionId !== process2.providerSessionId || durable.providerBackend !== (sandboxBackendForSdkBackendId(backend.kind) ?? backend.kind) || durable.providerInstanceId !== backend.providerInstanceId || durable.leaseEpoch !== backend.leaseEpoch || durable.routeKind !== (backend.sandboxId === null ? "home" : "active") || durable.routeTargetId !== backend.sandboxId || durable.routeEpoch !== backend.activeEpoch)
6924
- return false;
6925
- if (process2.providerCommand) {
6926
- const command = await retainedProviderCommandPersistence(services.db, {
6927
- accountId: fence.accountId,
6928
- workspaceId: ids.workspaceId,
6929
- sessionId: ids.sessionId,
6930
- processId: process2.id
6931
- }).load();
6932
- if (!command || command.kind !== process2.providerCommand.kind || command.execId !== process2.providerCommand.execId || command.taskId !== process2.providerCommand.taskId || command.sandboxId !== process2.providerCommand.sandboxId || Boolean(command.pty) !== Boolean(process2.providerCommand.pty) || command.kind === "modal-router-v1" && process2.providerCommand.kind === "modal-router-v1" && !isDeepStrictEqual3(command.supervision, process2.providerCommand.supervision))
6933
- return false;
6934
- }
6935
- return true;
6936
- };
6937
- }
6938
6895
  function adoptRetainedProcessAsBackgroundCommandForTurn(services, ids) {
6939
6896
  const fence = ids.workspaceMutationFence;
6940
6897
  if (!fence) return void 0;
@@ -6977,7 +6934,6 @@ function wrapTurnBoxWithRouting(services, ids, established) {
6977
6934
  const beforeProcessMutation = beforeRetainedProcessMutation(services, ids);
6978
6935
  const afterProcessMutation = afterRetainedProcessMutation(services, ids);
6979
6936
  const settleProcess = settleRetainedProcessForTurn(services, ids);
6980
- const isProcessSettled = isRetainedProcessSettledForTurn(services, ids);
6981
6937
  const adoptProcessAsBackgroundCommand = adoptRetainedProcessAsBackgroundCommandForTurn(
6982
6938
  services,
6983
6939
  ids
@@ -7150,7 +7106,6 @@ function wrapTurnBoxWithRouting(services, ids, established) {
7150
7106
  ...beforeProcessMutation ? { beforeProcessMutation } : {},
7151
7107
  ...afterProcessMutation ? { afterProcessMutation } : {},
7152
7108
  ...settleProcess ? { settleProcess } : {},
7153
- ...isProcessSettled ? { isProcessSettled } : {},
7154
7109
  ...ids.workspaceMutationFence ? { observeProcessTerminal: observeRetainedProcessTerminalForTurn(services, ids) } : {},
7155
7110
  ...ids.workspaceMutationFence ? { captureProcessOutput: captureRetainedProcessOutputForTurn(services, ids) } : {},
7156
7111
  ...adoptProcessAsBackgroundCommand ? { adoptProcessAsBackgroundCommand } : {},
@@ -7173,11 +7128,6 @@ function wrapTurnBoxWithRouting(services, ids, established) {
7173
7128
  diagnostic: "provider_not_found_during_routed_operation"
7174
7129
  });
7175
7130
  if (marked.status === "marked") {
7176
- await publishDurableSessionEvents2(
7177
- services.bus,
7178
- ids.workspaceId,
7179
- marked.backgroundCommandEvents
7180
- );
7181
7131
  await services.onHomeSandboxLost?.({
7182
7132
  sandboxGroupId: home.sandboxGroupId,
7183
7133
  instanceId: expectedInstanceId,
@@ -7204,7 +7154,6 @@ function wrapLazyTurnBoxWithRouting(services, ids, args) {
7204
7154
  const beforeProcessMutation = beforeRetainedProcessMutation(services, ids);
7205
7155
  const afterProcessMutation = afterRetainedProcessMutation(services, ids);
7206
7156
  const settleProcess = settleRetainedProcessForTurn(services, ids);
7207
- const isProcessSettled = isRetainedProcessSettledForTurn(services, ids);
7208
7157
  const adoptProcessAsBackgroundCommand = adoptRetainedProcessAsBackgroundCommandForTurn(
7209
7158
  services,
7210
7159
  ids
@@ -7361,7 +7310,6 @@ function wrapLazyTurnBoxWithRouting(services, ids, args) {
7361
7310
  ...beforeProcessMutation ? { beforeProcessMutation } : {},
7362
7311
  ...afterProcessMutation ? { afterProcessMutation } : {},
7363
7312
  ...settleProcess ? { settleProcess } : {},
7364
- ...isProcessSettled ? { isProcessSettled } : {},
7365
7313
  ...ids.workspaceMutationFence ? { observeProcessTerminal: observeRetainedProcessTerminalForTurn(services, ids) } : {},
7366
7314
  ...ids.workspaceMutationFence ? { captureProcessOutput: captureRetainedProcessOutputForTurn(services, ids) } : {},
7367
7315
  ...adoptProcessAsBackgroundCommand ? { adoptProcessAsBackgroundCommand } : {},
@@ -7385,11 +7333,6 @@ function wrapLazyTurnBoxWithRouting(services, ids, args) {
7385
7333
  diagnostic: "provider_not_found_during_routed_operation"
7386
7334
  });
7387
7335
  if (marked.status === "marked") {
7388
- await publishDurableSessionEvents2(
7389
- services.bus,
7390
- ids.workspaceId,
7391
- marked.backgroundCommandEvents
7392
- );
7393
7336
  await services.onHomeSandboxLost?.({
7394
7337
  sandboxGroupId: home.sandboxGroupId,
7395
7338
  instanceId: backend.providerInstanceId,
@@ -7958,7 +7901,7 @@ import {
7958
7901
  stableJson
7959
7902
  } from "@opengeni/contracts";
7960
7903
  import { createHash as createHash3 } from "crypto";
7961
- import { isDeepStrictEqual as isDeepStrictEqual4 } from "util";
7904
+ import { isDeepStrictEqual as isDeepStrictEqual3 } from "util";
7962
7905
  var INCIDENT_TELEMETRY_AUTHORITY_FENCE_LINEAGE_KEY = "incidentTelemetryAuthorityFence";
7963
7906
  function incidentTelemetryPreflightDeclaration(agentConfig, incidentTriggered) {
7964
7907
  const rawConfig = agentConfig;
@@ -7991,7 +7934,7 @@ function evaluateIncidentTelemetryPreflight(input) {
7991
7934
  return blocked("incident_preflight_metadata_missing");
7992
7935
  }
7993
7936
  if (preflight.requiredResources.some(
7994
- (required) => !input.responder.resources.some((selected) => isDeepStrictEqual4(selected, required))
7937
+ (required) => !input.responder.resources.some((selected) => isDeepStrictEqual3(selected, required))
7995
7938
  )) {
7996
7939
  return blocked("incident_responder_under_capable");
7997
7940
  }
@@ -8383,127 +8326,6 @@ async function checkpointHistoryBeforeProviderDispatch(historySink, route) {
8383
8326
  }
8384
8327
  }
8385
8328
 
8386
- // src/activities/agent-turn/claude-usage-observer.ts
8387
- import { createHash as createHash4 } from "crypto";
8388
- import {
8389
- emptyClaudeUsage,
8390
- mergeClaudeUsage,
8391
- parseClaudeUsageHeaders
8392
- } from "@opengeni/config";
8393
- var ClaudeSubscriptionConnectionUnavailable = class extends Error {
8394
- status = 409;
8395
- code = "claude_subscription_connection_changed";
8396
- constructor() {
8397
- super(
8398
- "Claude connection changed or was disconnected. Start a new turn with the current connection."
8399
- );
8400
- }
8401
- };
8402
- async function createClaudeUsageObserver(providers, latest, readCredential) {
8403
- const managedProviderIds = new Set(
8404
- providers.filter(
8405
- (provider) => provider.kind === "claude-subscription-workspace" || provider.kind === "claude-subscription-organization"
8406
- ).map((provider) => provider.id)
8407
- );
8408
- const bindings = await Promise.all(
8409
- providers.filter(
8410
- (provider) => provider.kind === "claude-subscription-workspace" || provider.kind === "claude-subscription-organization"
8411
- ).map(async (provider) => {
8412
- const scope = provider.kind === "claude-subscription-workspace" ? "workspace" : "organization";
8413
- const binding = provider.anthropic?.credentialBinding;
8414
- if (binding && provider.apiKey)
8415
- return [
8416
- provider.id,
8417
- {
8418
- scope,
8419
- token: provider.apiKey,
8420
- expectedConnectionId: binding.connectionId,
8421
- expectedCredentialVersion: binding.credentialVersion
8422
- }
8423
- ];
8424
- const credential = await readCredential(scope).catch(() => null);
8425
- if (!credential || credential.token !== provider.apiKey) return null;
8426
- return [
8427
- provider.id,
8428
- {
8429
- scope,
8430
- token: credential.token,
8431
- expectedConnectionId: credential.connectionId,
8432
- expectedCredentialVersion: credential.credentialVersion
8433
- }
8434
- ];
8435
- })
8436
- );
8437
- const captured = new Map(bindings.filter((binding) => binding !== null));
8438
- const observeBinding = (binding, response, upstreamModelId, requestToken) => {
8439
- if (requestToken === null) return;
8440
- if (!binding) return;
8441
- const { scope, ...capturedIdentity } = binding;
8442
- const identity = { ...capturedIdentity, token: requestToken ?? capturedIdentity.token };
8443
- const tokenKey = createHash4("sha256").update(identity.token).digest("hex");
8444
- const captureKey = `${scope}:${identity.expectedConnectionId}:${identity.expectedCredentialVersion}:${tokenKey}`;
8445
- const previous = latest.get(captureKey);
8446
- let observation = parseClaudeUsageHeaders(response.headers, /* @__PURE__ */ new Date(), upstreamModelId);
8447
- if (observation && previous?.observation) {
8448
- const merged = mergeClaudeUsage(
8449
- mergeClaudeUsage(emptyClaudeUsage(binding.expectedCredentialVersion), previous.observation),
8450
- observation
8451
- );
8452
- observation = {
8453
- windows: merged.windows,
8454
- observedAt: merged.observedAt,
8455
- source: merged.source,
8456
- requestStatus: merged.requestStatus ?? null,
8457
- requestRestrictions: merged.requestRestrictions ?? []
8458
- };
8459
- }
8460
- if (observation || response.status === 401)
8461
- latest.set(captureKey, {
8462
- scope,
8463
- ...identity,
8464
- ...previous?.observation && !observation ? { observation: previous.observation } : {},
8465
- ...observation ? { observation } : {},
8466
- ...response.status === 401 ? { refresh: { status: "reconnect", checkedAt: (/* @__PURE__ */ new Date()).toISOString() } } : {}
8467
- });
8468
- };
8469
- const observe = (providerId, response, upstreamModelId, requestToken) => observeBinding(captured.get(providerId), response, upstreamModelId, requestToken);
8470
- const prepareRequestWithObserver = async (providerId, headers, resolve) => {
8471
- if (!managedProviderIds.has(providerId)) return { headers, observe };
8472
- const binding = captured.get(providerId);
8473
- if (!binding) throw new ClaudeSubscriptionConnectionUnavailable();
8474
- const credential = await resolve({
8475
- scope: binding.scope,
8476
- expectedConnectionId: binding.expectedConnectionId,
8477
- expectedCredentialVersion: binding.expectedCredentialVersion
8478
- });
8479
- if (!credential || credential.connectionId !== binding.expectedConnectionId || credential.credentialVersion !== binding.expectedCredentialVersion)
8480
- throw new ClaudeSubscriptionConnectionUnavailable();
8481
- const dispatched = Object.freeze({ ...binding, token: credential.token });
8482
- captured.set(providerId, dispatched);
8483
- headers.set("authorization", `Bearer ${credential.token}`);
8484
- headers.delete("x-api-key");
8485
- return {
8486
- headers,
8487
- observe: (_providerId, response, upstreamModelId, requestToken) => observeBinding(dispatched, response, upstreamModelId, requestToken)
8488
- };
8489
- };
8490
- return Object.assign(observe, {
8491
- prepareRequestWithObserver,
8492
- async prepareRequest(...args) {
8493
- return (await prepareRequestWithObserver(...args)).headers;
8494
- },
8495
- binding(providerId) {
8496
- const binding = captured.get(providerId);
8497
- return binding ? { ...binding } : void 0;
8498
- },
8499
- renew(providerId, credential) {
8500
- const binding = captured.get(providerId);
8501
- if (binding && binding.expectedConnectionId === credential.connectionId && binding.expectedCredentialVersion === credential.credentialVersion)
8502
- captured.set(providerId, { ...binding, token: credential.token });
8503
- }
8504
- });
8505
- }
8506
-
8507
8329
  // src/activities/agent-turn/sandbox-provision.ts
8508
8330
  import {
8509
8331
  SandboxLeaseRecoveryBlockedError as SandboxLeaseRecoveryBlockedError2,
@@ -9132,7 +8954,6 @@ import {
9132
8954
  } from "@opengeni/db";
9133
8955
  import {
9134
8956
  ActiveBackendUnresolvableError as ActiveBackendUnresolvableError2,
9135
- AnthropicProviderRejection,
9136
8957
  CompactionProviderResponseError,
9137
8958
  EmptyCompactionSummaryError,
9138
8959
  compactionProviderRejection,
@@ -9141,7 +8962,6 @@ import {
9141
8962
  isMcpTransportConnectivityError,
9142
8963
  isModalTaskExecStartPreDispatchUnavailableError,
9143
8964
  isModalCommandStartOutcomeUnknownError,
9144
- isProviderCommandObservationUnavailableError,
9145
8965
  isRoutingMutationOutcomeUnknownError,
9146
8966
  RoutingWorkspaceRootChangedError,
9147
8967
  ResponsesStreamingTerminalError,
@@ -9151,8 +8971,7 @@ import {
9151
8971
  classifyProviderQuotaError,
9152
8972
  providerQuotaExhaustedMessage,
9153
8973
  SelfhostedWorkspaceRootChangedError,
9154
- UNKNOWN_MODEL_FINISH_REASON_CODE,
9155
- AnthropicRequestError
8974
+ UNKNOWN_MODEL_FINISH_REASON_CODE
9156
8975
  } from "@opengeni/runtime";
9157
8976
  import {
9158
8977
  mcpTransportRequestFailureDiagnostic
@@ -9166,7 +8985,7 @@ import {
9166
8985
  FileResourceRef,
9167
8986
  resourceMountPath
9168
8987
  } from "@opengeni/contracts";
9169
- import { createHash as createHash5 } from "crypto";
8988
+ import { createHash as createHash4 } from "crypto";
9170
8989
  import {
9171
8990
  getActiveSessionHistoryItemsPaged,
9172
8991
  getFilesForSubject,
@@ -9284,7 +9103,7 @@ async function modelAttachmentContentForFiles(files, readFileBytes, options = {}
9284
9103
  });
9285
9104
  continue;
9286
9105
  }
9287
- if (createHash5("sha256").update(bytes).digest("hex") !== checksum) {
9106
+ if (createHash4("sha256").update(bytes).digest("hex") !== checksum) {
9288
9107
  console.error("model attachment checksum did not match finalized metadata", {
9289
9108
  fileId: file.id
9290
9109
  });
@@ -9953,9 +9772,7 @@ function retryableDatabaseFailureCode(error) {
9953
9772
  function postClaimDatabaseRecoveryFailure(input) {
9954
9773
  const code = retryableDatabaseFailureCode(input.error);
9955
9774
  if (!code || input.executionGeneration < 1) return null;
9956
- if (input.sandboxSetupOutcomeUnknown && input.sandboxSetupRecoveryExhausted || (input.sandboxSetupOutcomeUnknown || input.sandboxSetupRecoveryExhausted) && input.providerRecovery) {
9957
- return null;
9958
- }
9775
+ if (input.sandboxSetupOutcomeUnknown && input.providerRecovery) return null;
9959
9776
  if (input.providerRecovery && (!Number.isSafeInteger(input.providerRecovery.providerRecoveryCount) || input.providerRecovery.providerRecoveryCount <= 0 || input.providerRecovery.providerRecoveryCount > MAX_AUTOMATIC_PROVIDER_RECOVERIES || !/^[a-z][a-z0-9_]{0,63}$/.test(input.providerRecovery.failureCode))) {
9960
9777
  return null;
9961
9778
  }
@@ -9965,7 +9782,6 @@ function postClaimDatabaseRecoveryFailure(input) {
9965
9782
  executionGeneration: input.executionGeneration,
9966
9783
  code,
9967
9784
  ...input.sandboxSetupOutcomeUnknown ? { sandboxSetupOutcomeUnknown: true } : {},
9968
- ...input.sandboxSetupRecoveryExhausted ? { sandboxSetupRecoveryExhausted: true } : {},
9969
9785
  ...input.providerRecovery ? {
9970
9786
  providerFailureCode: input.providerRecovery.failureCode,
9971
9787
  providerRecoveryCount: input.providerRecovery.providerRecoveryCount
@@ -10285,31 +10101,11 @@ function findPostgresDriverError(error) {
10285
10101
  function isRawDatabaseQueryError(error) {
10286
10102
  return error instanceof Error && "query" in error && typeof error.query === "string" && "params" in error && Array.isArray(error.params);
10287
10103
  }
10288
- function anthropicRequestDiagnostic(error) {
10289
- if (error instanceof AnthropicRequestError) return error;
10290
- return error instanceof Error && error.cause instanceof AnthropicRequestError ? error.cause : void 0;
10291
- }
10292
10104
  function agentRunFailurePayload(error, options = {}) {
10293
10105
  const failure = baseAgentRunFailurePayload(error, options);
10294
10106
  const diagnostic = materializationVerificationDiagnostic(error);
10295
- const anthropic = anthropicRequestDiagnostic(error);
10296
- if (anthropic) {
10297
- return {
10298
- ...failure,
10299
- code: failure.code ?? anthropic.code,
10300
- retryable: failure.retryable ?? false,
10301
- ...anthropic.detail ? { detail: anthropic.detail } : {},
10302
- ...anthropic.request_id ? { requestId: anthropic.request_id } : {}
10303
- };
10304
- }
10305
10107
  return diagnostic ? { ...failure, materializationDiagnostic: diagnostic } : failure;
10306
10108
  }
10307
- function agentRunRecoveryFailurePayload(error, failure) {
10308
- if (!anthropicRequestDiagnostic(error)) return failure;
10309
- const recovery = { ...failure };
10310
- delete recovery.detail;
10311
- return recovery;
10312
- }
10313
10109
  function baseAgentRunFailurePayload(error, options = {}) {
10314
10110
  if (error instanceof SandboxMaterializationVerificationError) {
10315
10111
  return {
@@ -10344,17 +10140,6 @@ function baseAgentRunFailurePayload(error, options = {}) {
10344
10140
  ...Object.keys(database).length > 0 ? { database } : {}
10345
10141
  };
10346
10142
  }
10347
- if (error instanceof ClaudeSubscriptionConnectionUnavailable) {
10348
- return { error: error.message, code: error.code, retryable: false };
10349
- }
10350
- if (error instanceof AnthropicProviderRejection) {
10351
- return {
10352
- error: error.message,
10353
- code: error.code === "content_policy_violation" ? "provider_safety_refusal" : error.code,
10354
- retryable: false,
10355
- ...error.request_id ? { requestId: error.request_id } : {}
10356
- };
10357
- }
10358
10143
  const safetyRefusalDiagnostic = providerSafetyRefusalDiagnostic(error);
10359
10144
  if (safetyRefusalDiagnostic !== void 0) {
10360
10145
  return {
@@ -10414,13 +10199,6 @@ function baseAgentRunFailurePayload(error, options = {}) {
10414
10199
  retryable: true
10415
10200
  };
10416
10201
  }
10417
- if (isProviderCommandObservationUnavailableError(error)) {
10418
- return {
10419
- error: "A managed sandbox command cannot be observed. Its exact invocation and writer remain retained; setup is blocked without replay until the incomplete operation can be reconciled.",
10420
- code: "sandbox_command_observation_unavailable",
10421
- retryable: false
10422
- };
10423
- }
10424
10202
  if (isModalCommandStartOutcomeUnknownError(error)) {
10425
10203
  return {
10426
10204
  error: "A managed sandbox command has an unknown outcome. Its original invocation remains fenced; setup is blocked without replay until the incomplete operation can be reconciled.",
@@ -10705,7 +10483,6 @@ export {
10705
10483
  startActivityHeartbeat,
10706
10484
  nextStreamEvent,
10707
10485
  warnDrainSnapshotFailure,
10708
- publishDurableSessionEvents2 as publishDurableSessionEvents,
10709
10486
  persistWorkspaceArchiveCandidate,
10710
10487
  putVersion1TarArchiveOrInline,
10711
10488
  sandboxLeaseHolderIdForAttempt,
@@ -10736,7 +10513,6 @@ export {
10736
10513
  resolveIncidentTelemetryResponderMetadata,
10737
10514
  validateIncidentTelemetrySystemUpdateAuthority,
10738
10515
  checkpointHistoryBeforeProviderDispatch,
10739
- createClaudeUsageObserver,
10740
10516
  projectRejectedProviderArtifacts,
10741
10517
  createModelHistoryAttachmentProjector,
10742
10518
  turnInput,
@@ -10794,10 +10570,9 @@ export {
10794
10570
  classifyContextWindowOverflowError,
10795
10571
  classifyXaiCredentialFailure,
10796
10572
  agentRunFailurePayload,
10797
- agentRunRecoveryFailurePayload,
10798
10573
  codexCredentialCooldownUntil,
10799
10574
  classifyCodexCredentialFailure,
10800
10575
  codexUsageLimitFailurePayload,
10801
10576
  CODEX_USAGE_LIMIT_MAX_RESUME_MS
10802
10577
  };
10803
- //# sourceMappingURL=chunk-PA7Z55P4.js.map
10578
+ //# sourceMappingURL=chunk-3K3ULWEE.js.map