@opengeni/worker-bundle 6.8.0 → 6.9.1-canary.41937124785001

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 (69) hide show
  1. package/dist/activities/agent-turn/agent-build.d.ts +4 -0
  2. package/dist/activities/agent-turn/compaction-prep.d.ts +5 -0
  3. package/dist/activities/agent-turn/governance-model.d.ts +9 -0
  4. package/dist/activities/agent-turn/sandbox-route.d.ts +19 -6
  5. package/dist/activities/agent-turn/secret-resolver.d.ts +0 -7
  6. package/dist/activities/agent-turn/tool-environment.d.ts +8 -0
  7. package/dist/activities/agent-turn/tool-router-expectation.d.ts +35 -0
  8. package/dist/activities/rig-provider-image-refresh.d.ts +36 -0
  9. package/dist/activities/rig-verification.d.ts +6 -2
  10. package/dist/activities/types.d.ts +13 -0
  11. package/dist/{activities-control-6HEEWPLL.js → activities-control-ZPHHBN6R.js} +52 -26
  12. package/dist/activities-control-ZPHHBN6R.js.map +1 -0
  13. package/dist/{activities-turn-E6VP3XVJ.js → activities-turn-FVLZRJMZ.js} +219 -359
  14. package/dist/activities-turn-FVLZRJMZ.js.map +1 -0
  15. package/dist/artifact-materializer-entry.js +0 -0
  16. package/dist/artifact-outbox-entry.js +0 -0
  17. package/dist/{chunk-UQAMEFZB.js → chunk-RK33AG2K.js} +1 -15
  18. package/dist/chunk-RK33AG2K.js.map +1 -0
  19. package/dist/chunk-VFL7V45S.js +320 -0
  20. package/dist/chunk-VFL7V45S.js.map +1 -0
  21. package/dist/{chunk-WLNVZWDL.js → chunk-VMFKTW4V.js} +2 -2
  22. package/dist/{chunk-ZEGN4DC4.js → chunk-WIYJK366.js} +4 -3
  23. package/dist/chunk-WIYJK366.js.map +1 -0
  24. package/dist/chunk-YTPJJBDP.js +31 -0
  25. package/dist/chunk-YTPJJBDP.js.map +1 -0
  26. package/dist/index.d.ts +2 -1
  27. package/dist/index.js +40 -307
  28. package/dist/index.js.map +1 -1
  29. package/dist/observability-metrics.d.ts +1 -1
  30. package/dist/{sandbox-lease-SWS4WQWO.js → sandbox-lease-BV4ADQG6.js} +3 -3
  31. package/dist/workflow-bundle.js +59 -9
  32. package/dist/workflows/session.d.ts +22 -0
  33. package/package.json +31 -30
  34. package/src/activities/agent-turn/admission.ts +4 -0
  35. package/src/activities/agent-turn/agent-build.ts +18 -20
  36. package/src/activities/agent-turn/compaction-prep.ts +17 -0
  37. package/src/activities/agent-turn/errors.ts +5 -1
  38. package/src/activities/agent-turn/governance-model.ts +31 -2
  39. package/src/activities/agent-turn/run-credentials.ts +0 -26
  40. package/src/activities/agent-turn/run.ts +7 -9
  41. package/src/activities/agent-turn/sandbox-establish.ts +26 -17
  42. package/src/activities/agent-turn/sandbox-route.ts +54 -43
  43. package/src/activities/agent-turn/secret-resolver.ts +17 -50
  44. package/src/activities/agent-turn/stream-attempt.ts +1 -12
  45. package/src/activities/agent-turn/tool-environment.ts +56 -40
  46. package/src/activities/agent-turn/tool-result-spill.ts +1 -6
  47. package/src/activities/agent-turn/tool-router-expectation.ts +84 -0
  48. package/src/activities/codemode-dispatcher.ts +1 -19
  49. package/src/activities/context-compaction.ts +3 -15
  50. package/src/activities/independent-session-title.ts +15 -1
  51. package/src/activities/meeting-summary.ts +11 -2
  52. package/src/activities/recordings.ts +10 -1
  53. package/src/activities/rig-provider-image-refresh.ts +56 -0
  54. package/src/activities/rig-verification.ts +20 -19
  55. package/src/activities/scheduled-tasks.ts +7 -0
  56. package/src/activities/session-state.ts +5 -1
  57. package/src/activities/types.ts +14 -0
  58. package/src/activity-services.ts +1 -0
  59. package/src/index.ts +26 -0
  60. package/src/observability-metrics.ts +0 -15
  61. package/src/workflows/session.ts +51 -8
  62. package/dist/activities/agent-turn/secret-values.d.ts +0 -98
  63. package/dist/activities-control-6HEEWPLL.js.map +0 -1
  64. package/dist/activities-turn-E6VP3XVJ.js.map +0 -1
  65. package/dist/chunk-UQAMEFZB.js.map +0 -1
  66. package/dist/chunk-ZEGN4DC4.js.map +0 -1
  67. package/src/activities/agent-turn/secret-values.ts +0 -293
  68. /package/dist/{chunk-WLNVZWDL.js.map → chunk-VMFKTW4V.js.map} +0 -0
  69. /package/dist/{sandbox-lease-SWS4WQWO.js.map → sandbox-lease-BV4ADQG6.js.map} +0 -0
@@ -78,6 +78,10 @@ export type BuildTurnAgentDeps = {
78
78
  * sessions without an agent configuration. Rendering input only.
79
79
  */
80
80
  promptToolAvailability?: AgentPromptToolAvailability | undefined;
81
+ /** Durable router use, read once with the tool runtime. */
82
+ toolRouterInHistory: boolean;
83
+ /** False when nothing this attempt attaches is deferred (see turnToolRouterExpected). */
84
+ toolRouterExpected: boolean;
81
85
  videoGenerationAcceptancesByCallId: Map<string, {
82
86
  operationId: string;
83
87
  requestDigest: string;
@@ -60,6 +60,7 @@ export type CompactionPrepDeps = {
60
60
  workspaceAgentIdentity: GovernanceModelOk["workspaceAgentIdentity"];
61
61
  structuredWorkspacePolicyActive: GovernanceModelOk["structuredWorkspacePolicyActive"];
62
62
  workspaceMemory: GovernanceModelOk["workspaceMemory"];
63
+ lazyToolTransport: GovernanceModelOk["lazyToolTransport"];
63
64
  rigVersion: GovernanceModelOk["rigVersion"];
64
65
  rigName: GovernanceModelOk["rigName"];
65
66
  compactionModelHistoryProjector: GovernanceModelOk["compactionModelHistoryProjector"];
@@ -121,6 +122,10 @@ export declare function standaloneCompactionInstructions(input: {
121
122
  name: string;
122
123
  version: number;
123
124
  } | undefined;
125
+ /** The turn's search-router transport and router history: without them the
126
+ * composer would assume no router and leave out Tool discovery. */
127
+ lazyToolTransport?: GovernanceModelOk["lazyToolTransport"];
128
+ toolRouterInHistory?: boolean;
124
129
  }): string;
125
130
  export declare function prepareCompaction(deps: CompactionPrepDeps): Promise<CompactionPrepOutcome>;
126
131
  export declare function runPostAgentCompaction(deps: PostAgentCompactionDeps): Promise<PostAgentCompactionOutcome>;
@@ -1,6 +1,7 @@
1
1
  import { materializeRigVersionForAttempt, freezeAgentLearningPolicy } from "@opengeni/db";
2
2
  import { renderWorkspaceGovernanceContext, type OpenGeniRuntime } from "@opengeni/runtime";
3
3
  import { type Settings } from "@opengeni/config";
4
+ import type { StartRigProviderImageRefresh } from "../types.js";
4
5
  import { createModelHistoryAttachmentProjector } from "../run-input.js";
5
6
  import { type TurnSearchRecords } from "../search-record-form.js";
6
7
  import type { TurnActivityServices as ActivityServices, RunAgentTurnInput, RunAgentTurnResult } from "../types.js";
@@ -36,6 +37,8 @@ export type GovernanceModelDeps = {
36
37
  sha256: string;
37
38
  filename: string;
38
39
  }>;
40
+ /** Optional background rebuild of a stale sandbox environment image. */
41
+ startRigProviderImageRefresh?: StartRigProviderImageRefresh | null;
39
42
  };
40
43
  export type GovernanceModelOk = {
41
44
  runtimePreparationStartedAt: number;
@@ -92,4 +95,10 @@ export declare function preferenceSnapshotHumanSubjectId(turn: PreferenceSnapsho
92
95
  */
93
96
  export declare function preferenceSnapshotForTurn<T>(turn: PreferenceSnapshotTurn, load: () => Promise<T>): Promise<T | null>;
94
97
  export declare function prepareGovernanceAndModel(deps: GovernanceModelDeps): Promise<GovernanceModelOutcome>;
98
+ /**
99
+ * Whether the agent has any learning tool the frozen learning policy governs:
100
+ * Knowledge (Knowledge, task notes and instructions) or Skill management.
101
+ * Sessions without an agent configuration keep every tool.
102
+ */
103
+ export declare function agentCanLearn(agent: ClaimTurnOk["session"]["agent"]): boolean;
95
104
  export {};
@@ -23,6 +23,18 @@ export declare function assertTurnSandboxBackendServed(deploymentSettings: Setti
23
23
  export declare function resolveActiveSandboxBackend(routingOn: boolean, loadPointer: () => Promise<{
24
24
  activeSandboxId: string | null;
25
25
  } | null>, loadSandboxKind: (sandboxId: string) => Promise<string | null>): Promise<Settings["sandboxBackend"] | undefined>;
26
+ /** Short pauses before re-reading a turn-start route fact after a failed read. */
27
+ export declare const TURN_ROUTE_READ_RETRY_DELAYS_MS: readonly number[];
28
+ /**
29
+ * Read one fact that decides WHICH sandbox this turn starts on (the session's
30
+ * active pointer, or the row it names). A failed read is never treated as an
31
+ * absent route: it is retried briefly (a connection dropped by a restart or a
32
+ * redeploy usually recovers within this window) and then rethrown unchanged, so
33
+ * the attempt stops before any box is touched and the database recovery lane
34
+ * retries it. Starting on the managed home instead would run setup, credential
35
+ * seeding and file downloads on a box the chat did not choose.
36
+ */
37
+ export declare function readTurnRouteFact<T>(read: () => Promise<T>, delaysMs?: readonly number[]): Promise<T>;
26
38
  /**
27
39
  * Managed-sandbox ownership exists only when this turn actually uses the
28
40
  * managed home. A Connected Machine is fenced by its active-route epoch and
@@ -112,12 +124,13 @@ export type LoadedActivePointer = {
112
124
  * higher epoch, so re-read + honor it rather than clobber a newer, user-directed pointer. The
113
125
  * event publish is best-effort — a publish failure never fails the turn.
114
126
  *
115
- * FAIL-OPEN on a lookup failure (issue #341 review): the sandbox row is fetched HERE via the
116
- * caller's NON-swallowing `loadRecord`, so a null decision means the row is genuinely absent,
117
- * never a suppressed transient DB error. If `loadRecord` THROWS, reconciliation is skipped
118
- * entirely this turn — the pointer is left UNTOUCHED (record null → the turn runs
119
- * machinePrimary:false on the group box exactly as before reconcile existed), no CAS, no
120
- * event — and the next turn retries. A TRANSIENT LOOKUP FAILURE MUST NEVER MUTATE THE POINTER.
127
+ * FAIL-CLOSED on a lookup failure: the sandbox row is fetched HERE via the caller's
128
+ * NON-swallowing `loadRecord`, so a null decision means the row is genuinely absent, never a
129
+ * suppressed transient DB error. If `loadRecord`, the reset CAS or the re-read THROWS, the
130
+ * error propagates: the pointer is left UNTOUCHED (no CAS, no event) AND the turn does not
131
+ * start on the group box while its pointer still names another sandbox. The attempt stops
132
+ * before any box is touched and is retried. A TRANSIENT LOOKUP FAILURE MUST NEVER MUTATE THE
133
+ * POINTER, AND MUST NEVER PICK THE ROUTE.
121
134
  */
122
135
  export declare function reconcileActiveSandboxPointer(db: ActivityServices["db"], ids: {
123
136
  accountId: string;
@@ -15,13 +15,6 @@ import { type ProviderCallBudget, type VaultProvider, type VaultProviderRegistry
15
15
  * contracts parse fills it); legacy null-config sessions get secrets on.
16
16
  */
17
17
  export declare function secretsCapabilityEnabled(agentConfig: ResolvedAgentConfig | null | undefined): boolean;
18
- /**
19
- * Whether secret-shaped values found in tool output are saved into the task
20
- * vault (and replaced by a reference) rather than only masked. Saving needs
21
- * the `secrets` capability and an agent allowed to use secrets; otherwise the
22
- * values keep their `[masked <kind>]` marker without a failing vault write.
23
- */
24
- export declare function taskVaultSecretCaptureEnabled(agentConfig: ResolvedAgentConfig | null | undefined, firstPartyMcpPermissions: readonly string[] | null | undefined): boolean;
25
18
  /**
26
19
  * Connected-vault access for one attempt: the provider registry (1Password
27
20
  * tokens load for the acting human, host vaults use the embedder port) and a
@@ -236,6 +236,8 @@ export declare function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps)
236
236
  preparationIndependentToolNames: string[];
237
237
  codeSearchAvailable: boolean;
238
238
  promptToolAvailability: import("@opengeni/runtime").AgentPromptToolAvailability | undefined;
239
+ toolRouterInHistory: boolean;
240
+ toolRouterExpected: boolean;
239
241
  skillCatalog: {
240
242
  id: string;
241
243
  name: string;
@@ -244,3 +246,9 @@ export declare function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps)
244
246
  }>;
245
247
  export type PrepareTurnToolPolicyOk = Awaited<ReturnType<typeof prepareTurnToolPolicy>>;
246
248
  export type PrepareTurnToolRuntimeOk = Awaited<ReturnType<typeof prepareTurnToolRuntime>>;
249
+ /**
250
+ * Whether a person can answer this turn: the same subjects the session inbox
251
+ * delivers to (`user:` and `external_user:`), or the local-mode person
252
+ * (`dev`), frozen with the turn.
253
+ */
254
+ export declare function turnHasHumanRecipient(subjectId: string | null | undefined): boolean;
@@ -0,0 +1,35 @@
1
+ import type { FirstPartyMcpToolName, ResolvedAgentConfig, ToolRef } from "@opengeni/contracts";
2
+ /**
3
+ * Whether a configured attempt may defer any tool behind search, decided from
4
+ * frozen per-turn facts before the first request. `false` is a proof that
5
+ * every attached tool is in the first request: then the search router and the
6
+ * tool discovery instructions are left out, and `set_session_title` (deferred
7
+ * on every turn after the session has a title, while Opengeni titles the
8
+ * session itself) is not attached on its own, so it never brings the router
9
+ * back. Any doubt answers `true`, which keeps today's behaviour. A wrong
10
+ * `false` can hide tools: the router stays out while deferred preparation is
11
+ * pending, so every server whose tools might arrive after the first request
12
+ * must answer `true`. That includes an `eager: true` server the runtime
13
+ * prepares best effort (optional, connection-backed, or Codex Apps), whose
14
+ * connect and list work joins deferred preparation.
15
+ */
16
+ export declare function turnToolRouterExpected(input: {
17
+ agentConfig: ResolvedAgentConfig | null | undefined;
18
+ /** Durable router use: once exposed, the router stays. */
19
+ routerInHistory: boolean;
20
+ /** The attempt's MCP refs as prepared (ToolRef.eager decides first-request visibility). */
21
+ toolRefs: readonly ToolRef[];
22
+ /** The attempt's MCP server registry, to find best-effort servers. */
23
+ mcpServers: readonly {
24
+ id: string;
25
+ connectionRef?: unknown;
26
+ }[];
27
+ /** First-party tools the prepared `opengeni` server lists, before the title rule. */
28
+ remoteFirstPartyTools: readonly FirstPartyMcpToolName[];
29
+ /** Model names of the attempt's function tools (already capability filtered). */
30
+ functionToolNames: readonly string[];
31
+ /** Tools the host keeps in the first request regardless of origin. */
32
+ preparationIndependentToolNames: readonly string[];
33
+ /** Media tools (image and video generation) are built by the runtime and searchable. */
34
+ mediaTools: boolean;
35
+ }): boolean;
@@ -0,0 +1,36 @@
1
+ import type { RigProviderImageSelectionReason } from "@opengeni/core";
2
+ import type { StartRigProviderImageRefresh } from "./types.js";
3
+ /**
4
+ * Deterministic Temporal workflow id for an automatic provider-image rebuild:
5
+ * at most one start per version, expected content and UTC day.
6
+ */
7
+ export declare function rigProviderImageRefreshWorkflowId(input: {
8
+ versionId: string;
9
+ contentHash: string;
10
+ now?: Date;
11
+ }): string;
12
+ /**
13
+ * A ready, cold-boot-proven provider image whose content no longer matches is
14
+ * stale: the deployment base image (or the content identity protocol) moved
15
+ * after it was built. The turn still uses the ordinary setup path, and asks
16
+ * once in the background for a rebuild on the current base so later fresh
17
+ * sandboxes start from a prebuilt image again. Never awaited by the turn.
18
+ */
19
+ export declare function requestStaleRigProviderImageRefresh(input: {
20
+ selection: {
21
+ reason: RigProviderImageSelectionReason;
22
+ contentHash: string | null;
23
+ };
24
+ /**
25
+ * Verification always builds on the deployment base. A turn on a
26
+ * workspace-selected base could never be served by that rebuild.
27
+ */
28
+ turnUsesDeploymentBase: boolean;
29
+ workspaceId: string;
30
+ versionId: string | null;
31
+ start: StartRigProviderImageRefresh | null | undefined;
32
+ warn: (message: string, context: {
33
+ versionId: string;
34
+ error: string;
35
+ }) => void;
36
+ }): boolean;
@@ -86,6 +86,12 @@ export declare class RigVerificationLeaseUnavailableError extends Error {
86
86
  /**
87
87
  * Run one verifier against one exactly attributed standalone sandbox.
88
88
  *
89
+ * Every run owns a brand-new lease group. A verification must prove a clean
90
+ * box, so it can never reuse an earlier run's lease: keying the lease by the
91
+ * change, version or build request left a cold lease behind after the first
92
+ * run, and every later verification of the same target then failed at once
93
+ * as `rearmed`/`attached` instead of creating a fresh sandbox.
94
+ *
89
95
  * Ordering is deliberate and source-of-truth safe:
90
96
  * acquire spawner -> create callback -> warming instance record -> warm commit
91
97
  * -> setup/checks. The canonical sandbox lease, not provider tags, is durable
@@ -103,7 +109,6 @@ export declare function runWithOwnedRigVerificationSandbox<T>(input: {
103
109
  observability: ControlActivityServices["observability"];
104
110
  accountId: string;
105
111
  workspaceId: string;
106
- sandboxGroupId: string;
107
112
  rigVersionId: string;
108
113
  sessionIdPrefix: string;
109
114
  lifecycle?: RigVerificationActivityLifecycle;
@@ -120,7 +125,6 @@ export declare function verifyRigProviderImageColdBoot(input: {
120
125
  observability: ControlActivityServices["observability"];
121
126
  accountId: string;
122
127
  workspaceId: string;
123
- buildRequestId: string;
124
128
  rigVersionId: string;
125
129
  sessionIdPrefix: string;
126
130
  imageId: string;
@@ -47,6 +47,18 @@ export type StartRecordingWorkflow = (input: {
47
47
  versionId: string | null;
48
48
  ownerSubjectId: string;
49
49
  }) => Promise<"started" | "already_running">;
50
+ /**
51
+ * Start the clean-replay verification that rebuilds a sandbox environment
52
+ * version's provider image for the deployment's current base image. The
53
+ * start is deduplicated per version, expected content and UTC day, so every
54
+ * turn that meets the stale image may ask without starting more than one
55
+ * rebuild a day.
56
+ */
57
+ export type StartRigProviderImageRefresh = (input: {
58
+ workspaceId: string;
59
+ versionId: string;
60
+ contentHash: string;
61
+ }) => Promise<"started" | "already_running">;
50
62
  /** Exact activity-owned proof that the hard sandbox/tool fence physically
51
63
  * drained. This is delivery evidence only: the workflow still validates the
52
64
  * persisted attempt dispatch and commits the authoritative Postgres receipt. */
@@ -93,6 +105,7 @@ export type SharedActivityServices = {
93
105
  startVideoGenerationWorkflow?: StartVideoGenerationWorkflow | null;
94
106
  startSessionTitleWorkflow?: StartSessionTitleWorkflow | null;
95
107
  startRecordingWorkflow?: StartRecordingWorkflow | null;
108
+ startRigProviderImageRefresh?: StartRigProviderImageRefresh | null;
96
109
  entitlements?: EntitlementsPort | null;
97
110
  connectionCredentials?: VaultConnectionCredentialsPort | null;
98
111
  /**
@@ -20,7 +20,10 @@ import {
20
20
  withFirstPartyTools,
21
21
  workflowIdForSession,
22
22
  writeSessionUsageReceipts
23
- } from "./chunk-ZEGN4DC4.js";
23
+ } from "./chunk-WIYJK366.js";
24
+ import {
25
+ resolveWorkerShutdownTiming
26
+ } from "./chunk-VFL7V45S.js";
24
27
  import "./chunk-5E7CLEQM.js";
25
28
  import {
26
29
  createSiteAuthMaintenanceActivities
@@ -28,13 +31,13 @@ import {
28
31
  import {
29
32
  createBrowserDeadlineCheckpointActivities,
30
33
  createSandboxLeaseActivities
31
- } from "./chunk-WLNVZWDL.js";
34
+ } from "./chunk-VMFKTW4V.js";
32
35
  import "./chunk-YJDTWP6V.js";
33
36
  import "./chunk-BKPKTXFV.js";
34
37
  import {
35
38
  recordTurnsQueuedGauge,
36
39
  recordWorkerDeathRecoveryMetrics
37
- } from "./chunk-UQAMEFZB.js";
40
+ } from "./chunk-RK33AG2K.js";
38
41
  import {
39
42
  deliverFailedChildTurnToParent,
40
43
  notifyParentOfChildIdle,
@@ -779,6 +782,7 @@ import {
779
782
  } from "@opengeni/core/transcription-service";
780
783
  import {
781
784
  beginRecordingAudioExpiry,
785
+ withCreditDebitAttribution,
782
786
  claimRecordingTranscriptVersion,
783
787
  completeRecordingAudioExpiry,
784
788
  completeRecordingTranscriptVersion,
@@ -1598,7 +1602,8 @@ import {
1598
1602
  MEETING_SUMMARY_SUBJECT_ID,
1599
1603
  MEETING_SUMMARY_TOOLS,
1600
1604
  meetingSummaryCandidate,
1601
- requireWorkspace
1605
+ requireWorkspace,
1606
+ chargeBillingOrigin
1602
1607
  } from "@opengeni/db";
1603
1608
  function meetingSummaryModel(input) {
1604
1609
  const selections = input.settings.requiredModelGeography === "eu" ? input.selections.map(
@@ -1669,7 +1674,13 @@ async function startMeetingSummary(service, input) {
1669
1674
  settings,
1670
1675
  creator: "automation",
1671
1676
  request: {
1672
- capabilities: { from: "none", knowledge: true, humanInput: false, skills: false }
1677
+ capabilities: {
1678
+ from: "none",
1679
+ knowledge: true,
1680
+ humanInput: false,
1681
+ skills: false,
1682
+ privacyFacts: true
1683
+ }
1673
1684
  },
1674
1685
  instructions,
1675
1686
  workspaceSettings,
@@ -1712,6 +1723,7 @@ async function startMeetingSummary(service, input) {
1712
1723
  titleSource: recording.titleSource
1713
1724
  }),
1714
1725
  surface: "system",
1726
+ billingOrigin: chargeBillingOrigin(),
1715
1727
  metrics: service.observability,
1716
1728
  resources: [],
1717
1729
  tools: written.tools,
@@ -2315,7 +2327,10 @@ function createRecordingActivities(services, options = {}) {
2315
2327
  let finishing = false;
2316
2328
  try {
2317
2329
  finished = await withRecordingUsage(usage, () => {
2318
- const work = transcribeClaimed();
2330
+ const work = withCreditDebitAttribution(
2331
+ job.creditAttribution ?? { kind: "unknown" },
2332
+ transcribeClaimed
2333
+ );
2319
2334
  work.catch(() => void 0);
2320
2335
  const outOfTime = new Promise((resolve, reject) => {
2321
2336
  const timedOut = () => (finishing ? work : fail("timed_out", budget.signal.reason)).then(resolve, reject);
@@ -2400,6 +2415,10 @@ function createRecordingActivities(services, options = {}) {
2400
2415
  })) {
2401
2416
  throw new PermanentRecordingFailure("region_restricted");
2402
2417
  }
2418
+ await deployment.assertEligible?.(job.version.providerId, {
2419
+ accountId: input.accountId,
2420
+ workspaceId: input.workspaceId
2421
+ });
2403
2422
  const resolved = await deployment.credentials(job.version.providerId, {
2404
2423
  accountId: input.accountId,
2405
2424
  workspaceId: input.workspaceId
@@ -2731,6 +2750,7 @@ function createRecordingActivities(services, options = {}) {
2731
2750
  }
2732
2751
  if (error instanceof TranscriptionBillingRefusedError) return await fail(error.code, error);
2733
2752
  if (error instanceof TranscriptionServiceError) {
2753
+ if (error.subscriptionCode) return await fail(error.subscriptionCode, error);
2734
2754
  if (!error.retryable) return await fail(`voice_${error.code}`, error);
2735
2755
  throw ApplicationFailure.retryable(error.message, `voice_${error.code}`);
2736
2756
  }
@@ -4025,6 +4045,7 @@ async function runWithOwnedRigVerificationSandbox(input, run, dependencies = def
4025
4045
  throw new Error(RIG_VERIFICATION_OWNERS_DISABLED_MESSAGE);
4026
4046
  }
4027
4047
  const holderId = `rig-verification:${dependencies.randomUUID()}`;
4048
+ const sandboxGroupId = dependencies.randomUUID();
4028
4049
  const fallbackController = new AbortController();
4029
4050
  const signal = input.lifecycle?.signal ?? fallbackController.signal;
4030
4051
  const commandController = dependencies.createCancellationController(signal);
@@ -4060,7 +4081,7 @@ async function runWithOwnedRigVerificationSandbox(input, run, dependencies = def
4060
4081
  () => dependencies.markWarmLost(input.db, {
4061
4082
  accountId: input.accountId,
4062
4083
  workspaceId: input.workspaceId,
4063
- sandboxGroupId: input.sandboxGroupId,
4084
+ sandboxGroupId,
4064
4085
  expectedEpoch: cleanupEpoch + 1,
4065
4086
  expectedInstanceId: instanceId
4066
4087
  })
@@ -4069,7 +4090,7 @@ async function runWithOwnedRigVerificationSandbox(input, run, dependencies = def
4069
4090
  () => dependencies.failWarming(input.db, {
4070
4091
  accountId: input.accountId,
4071
4092
  workspaceId: input.workspaceId,
4072
- sandboxGroupId: input.sandboxGroupId,
4093
+ sandboxGroupId,
4073
4094
  expectedEpoch: cleanupEpoch
4074
4095
  })
4075
4096
  )
@@ -4107,7 +4128,7 @@ async function runWithOwnedRigVerificationSandbox(input, run, dependencies = def
4107
4128
  const lease = await dependencies.acquire(input.db, {
4108
4129
  accountId: input.accountId,
4109
4130
  workspaceId: input.workspaceId,
4110
- sandboxGroupId: input.sandboxGroupId,
4131
+ sandboxGroupId,
4111
4132
  kind: "turn",
4112
4133
  holderId,
4113
4134
  subjectId: null,
@@ -4125,7 +4146,7 @@ async function runWithOwnedRigVerificationSandbox(input, run, dependencies = def
4125
4146
  void dependencies.touchHolder(input.db, {
4126
4147
  accountId: input.accountId,
4127
4148
  workspaceId: input.workspaceId,
4128
- sandboxGroupId: input.sandboxGroupId,
4149
+ sandboxGroupId,
4129
4150
  kind: "turn",
4130
4151
  holderId
4131
4152
  }).catch(() => void 0);
@@ -4134,7 +4155,7 @@ async function runWithOwnedRigVerificationSandbox(input, run, dependencies = def
4134
4155
  holderLivenessTimer.unref();
4135
4156
  }
4136
4157
  if (lease.role !== "spawner") {
4137
- throw new RigVerificationLeaseUnavailableError(input.sandboxGroupId, lease.role);
4158
+ throw new RigVerificationLeaseUnavailableError(sandboxGroupId, lease.role);
4138
4159
  }
4139
4160
  ownsWarmingEpoch = true;
4140
4161
  establishmentPromise = Promise.resolve().then(
@@ -4144,7 +4165,7 @@ async function runWithOwnedRigVerificationSandbox(input, run, dependencies = def
4144
4165
  createIdentity: {
4145
4166
  accountId: input.accountId,
4146
4167
  workspaceId: input.workspaceId,
4147
- sandboxGroupId: input.sandboxGroupId
4168
+ sandboxGroupId
4148
4169
  },
4149
4170
  environment: {},
4150
4171
  onSandboxCreated: async (created) => {
@@ -4153,7 +4174,7 @@ async function runWithOwnedRigVerificationSandbox(input, run, dependencies = def
4153
4174
  const recorded = await dependencies.recordCreated(input.db, {
4154
4175
  accountId: input.accountId,
4155
4176
  workspaceId: input.workspaceId,
4156
- sandboxGroupId: input.sandboxGroupId,
4177
+ sandboxGroupId,
4157
4178
  expectedEpoch: lease.lease.leaseEpoch,
4158
4179
  instanceId: created.instanceId,
4159
4180
  resumeBackendId: created.backendId,
@@ -4162,7 +4183,7 @@ async function runWithOwnedRigVerificationSandbox(input, run, dependencies = def
4162
4183
  warmingLeaseTtlMs: RIG_VERIFICATION_OWNER_TTL_MS
4163
4184
  });
4164
4185
  if (!recorded.recorded) {
4165
- throw new RigVerificationLeaseUnavailableError(input.sandboxGroupId, "fenced");
4186
+ throw new RigVerificationLeaseUnavailableError(sandboxGroupId, "fenced");
4166
4187
  }
4167
4188
  if (created.backendId === "modal" && !signal.aborted) {
4168
4189
  try {
@@ -4170,7 +4191,7 @@ async function runWithOwnedRigVerificationSandbox(input, run, dependencies = def
4170
4191
  dependencies.tag(input.settings, created.instanceId, {
4171
4192
  leaseId: lease.lease.id,
4172
4193
  workspaceId: input.workspaceId,
4173
- sandboxGroupId: input.sandboxGroupId
4194
+ sandboxGroupId
4174
4195
  }),
4175
4196
  signal
4176
4197
  );
@@ -4210,7 +4231,7 @@ async function runWithOwnedRigVerificationSandbox(input, run, dependencies = def
4210
4231
  const committed = await dependencies.commitWarm(input.db, {
4211
4232
  accountId: input.accountId,
4212
4233
  workspaceId: input.workspaceId,
4213
- sandboxGroupId: input.sandboxGroupId,
4234
+ sandboxGroupId,
4214
4235
  expectedEpoch: lease.lease.leaseEpoch,
4215
4236
  instanceId: established.instanceId,
4216
4237
  dataPlaneUrl: null,
@@ -4219,7 +4240,7 @@ async function runWithOwnedRigVerificationSandbox(input, run, dependencies = def
4219
4240
  leaseTtlMs: RIG_VERIFICATION_OWNER_TTL_MS
4220
4241
  });
4221
4242
  if (!committed.committed || !committed.lease) {
4222
- throw new RigVerificationLeaseUnavailableError(input.sandboxGroupId, "fenced");
4243
+ throw new RigVerificationLeaseUnavailableError(sandboxGroupId, "fenced");
4223
4244
  }
4224
4245
  const result = await run(established, {
4225
4246
  signal,
@@ -4263,7 +4284,7 @@ async function runWithOwnedRigVerificationSandbox(input, run, dependencies = def
4263
4284
  await dependencies.failWarming(input.db, {
4264
4285
  accountId: input.accountId,
4265
4286
  workspaceId: input.workspaceId,
4266
- sandboxGroupId: input.sandboxGroupId,
4287
+ sandboxGroupId,
4267
4288
  expectedEpoch
4268
4289
  });
4269
4290
  }
@@ -4290,7 +4311,7 @@ async function runWithOwnedRigVerificationSandbox(input, run, dependencies = def
4290
4311
  () => dependencies.releaseHolder(input.db, {
4291
4312
  accountId: input.accountId,
4292
4313
  workspaceId: input.workspaceId,
4293
- sandboxGroupId: input.sandboxGroupId,
4314
+ sandboxGroupId,
4294
4315
  kind: "turn",
4295
4316
  holderId,
4296
4317
  idleGraceMs: RIG_VERIFICATION_RELEASE_GRACE_MS
@@ -4406,7 +4427,6 @@ async function verifyRigProviderImageColdBoot(input, dependencies = defaultRigPr
4406
4427
  observability: input.observability,
4407
4428
  accountId: input.accountId,
4408
4429
  workspaceId: input.workspaceId,
4409
- sandboxGroupId: input.buildRequestId,
4410
4430
  rigVersionId: input.rigVersionId,
4411
4431
  sessionIdPrefix: input.sessionIdPrefix,
4412
4432
  lifecycle: input.lifecycle
@@ -4612,7 +4632,6 @@ async function buildVerifiedRigProviderImage(input) {
4612
4632
  observability: input.observability,
4613
4633
  accountId: input.accountId,
4614
4634
  workspaceId: input.workspaceId,
4615
- buildRequestId: building.buildRequestId,
4616
4635
  rigVersionId: input.target.id,
4617
4636
  sessionIdPrefix: `rig-provider-image-${input.target.id}`,
4618
4637
  imageId: built.imageId,
@@ -4765,7 +4784,6 @@ function createRigVerificationActivities(services) {
4765
4784
  observability,
4766
4785
  accountId: rig.accountId,
4767
4786
  workspaceId: input.workspaceId,
4768
- sandboxGroupId: change.id,
4769
4787
  rigVersionId: candidateVersion.id,
4770
4788
  sessionIdPrefix: `rig-verification-${change.id}`,
4771
4789
  lifecycle
@@ -4950,7 +4968,6 @@ function createRigVerificationActivities(services) {
4950
4968
  observability,
4951
4969
  accountId: rig.accountId,
4952
4970
  workspaceId: input.workspaceId,
4953
- sandboxGroupId: version.id,
4954
4971
  rigVersionId: version.id,
4955
4972
  sessionIdPrefix: `rig-version-verification-${version.id}`,
4956
4973
  lifecycle
@@ -6050,6 +6067,13 @@ function createScheduledTaskActivities(services) {
6050
6067
  }
6051
6068
  );
6052
6069
  if (admissionDenial) {
6070
+ if (admissionDenial === "subscription_api_unavailable") {
6071
+ return await refuseAdmission(
6072
+ "scheduled_model_unavailable",
6073
+ false,
6074
+ "Connected subscriptions are unavailable for API use; choose a credit-billed model."
6075
+ );
6076
+ }
6053
6077
  return await refuseAdmission(
6054
6078
  admissionDenial === "api_credits_required" || admissionDenial === "byok_paid_credit_required" || admissionDenial === "byok_upgrade_required" || admissionDenial === "subscription_plan_required" ? "insufficient_credits" : admissionDenial,
6055
6079
  true,
@@ -8129,7 +8153,7 @@ function createSessionStateActivities(services, overrides = {}) {
8129
8153
  }
8130
8154
  }
8131
8155
  async function reconcileSessionAttemptQuiescenceActivity(input) {
8132
- const { db, bus, inspectSessionAttemptActivity } = await services();
8156
+ const { db, bus, inspectSessionAttemptActivity, settings } = await services();
8133
8157
  const activityRef = await getSessionAttemptActivityRefFn(db, {
8134
8158
  ...input,
8135
8159
  temporalWorkflowId: input.workflowId
@@ -8148,7 +8172,9 @@ function createSessionStateActivities(services, overrides = {}) {
8148
8172
  temporalWorkflowId: input.workflowId,
8149
8173
  temporalWorkflowRunId: activityRef.workflowRunId,
8150
8174
  temporalActivityId: activityRef.activityId,
8151
- activitySettled: true
8175
+ activitySettled: true,
8176
+ // A worker-shutdown closure's process has exited once this has passed.
8177
+ workerProcessExitDeadlineMs: resolveWorkerShutdownTiming("turn", settings).processExitDeadlineMs
8152
8178
  });
8153
8179
  if (result.events.length > 0) {
8154
8180
  await publishDurableSessionEventsFn(
@@ -8961,4 +8987,4 @@ export {
8961
8987
  createControlActivities,
8962
8988
  createControlActivitiesFromServices
8963
8989
  };
8964
- //# sourceMappingURL=activities-control-6HEEWPLL.js.map
8990
+ //# sourceMappingURL=activities-control-ZPHHBN6R.js.map