@opengeni/worker-bundle 1.0.0-canary.0 → 1.0.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.
- package/dist/activities/agent-run-admission.d.ts +3 -1
- package/dist/activities/agent-turn/admission.d.ts +24 -3
- package/dist/activities/agent-turn/agent-build.d.ts +4 -0
- package/dist/activities/agent-turn/claude-usage-observer.d.ts +58 -0
- package/dist/activities/agent-turn/code-search.d.ts +60 -0
- package/dist/activities/agent-turn/codex-capacity.d.ts +13 -0
- package/dist/activities/agent-turn/codex-plan-entitlement.d.ts +105 -0
- package/dist/activities/agent-turn/codex.d.ts +3 -2
- package/dist/activities/agent-turn/compaction-prep.d.ts +21 -5
- package/dist/activities/agent-turn/credential-leases.d.ts +19 -33
- package/dist/activities/agent-turn/credential-restriction.d.ts +3 -0
- package/dist/activities/agent-turn/errors.d.ts +82 -11
- package/dist/activities/agent-turn/failure-settlement.d.ts +6 -3
- package/dist/activities/agent-turn/final-reply.d.ts +18 -0
- package/dist/activities/agent-turn/finalization-monitor.d.ts +17 -0
- package/dist/activities/agent-turn/finalization.d.ts +4 -2
- package/dist/activities/agent-turn/github-repository-bindings.d.ts +2 -0
- package/dist/activities/agent-turn/governance-model.d.ts +9 -2
- package/dist/activities/agent-turn/history-sink.d.ts +2 -0
- package/dist/activities/agent-turn/history.d.ts +2 -0
- package/dist/activities/agent-turn/input-wait-reply.d.ts +41 -0
- package/dist/activities/agent-turn/media-artifacts.d.ts +5 -3
- package/dist/activities/agent-turn/model-call-admission.d.ts +15 -0
- package/dist/activities/agent-turn/model-usage.d.ts +6 -0
- package/dist/activities/agent-turn/model-wire-dispatch.d.ts +15 -0
- package/dist/activities/agent-turn/optional-repositories.d.ts +59 -0
- package/dist/activities/agent-turn/provider-dispatch-barrier.d.ts +12 -1
- package/dist/activities/agent-turn/quiescence.d.ts +7 -7
- package/dist/activities/agent-turn/recovery-warning.d.ts +9 -0
- package/dist/activities/agent-turn/refresh-credentials.d.ts +6 -0
- package/dist/activities/agent-turn/run-credentials.d.ts +8 -3
- package/dist/activities/agent-turn/sandbox-establish.d.ts +2 -1
- package/dist/activities/agent-turn/sandbox-provision.d.ts +3 -1
- package/dist/activities/agent-turn/sandbox-route.d.ts +3 -20
- package/dist/activities/agent-turn/sandbox-runtime.d.ts +2 -2
- package/dist/activities/agent-turn/session-title.d.ts +34 -2
- package/dist/activities/agent-turn/skill-checkout.d.ts +25 -6
- package/dist/activities/agent-turn/skill-read.d.ts +70 -2
- package/dist/activities/agent-turn/skill-remove.d.ts +14 -0
- package/dist/activities/agent-turn/skill-search.d.ts +3 -1
- package/dist/activities/agent-turn/skill-tools.d.ts +15 -2
- package/dist/activities/agent-turn/skill-transfer.d.ts +18 -6
- package/dist/activities/agent-turn/stream-attempt.d.ts +7 -3
- package/dist/activities/agent-turn/subscription-lease.d.ts +38 -0
- package/dist/activities/agent-turn/tool-environment.d.ts +56 -6
- package/dist/activities/agent-turn/tool-policy.d.ts +43 -0
- package/dist/activities/agent-turn/turn-context.d.ts +29 -0
- package/dist/activities/agent-turn/turn-sandbox-access.d.ts +3 -0
- package/dist/activities/agent-turn/xai-capacity.d.ts +2 -1
- package/dist/activities/automations.d.ts +3 -1
- package/dist/activities/browser-deadline-checkpoint.d.ts +29 -0
- package/dist/activities/codemode-dispatcher.d.ts +9 -2
- package/dist/activities/codex-capacity.d.ts +18 -2
- package/dist/activities/codex-rotation.d.ts +7 -1
- package/dist/activities/context-compaction.d.ts +16 -2
- package/dist/activities/gmail-files.d.ts +32 -0
- package/dist/activities/goals.d.ts +8 -0
- package/dist/activities/knowledge-indexing.d.ts +19 -0
- package/dist/activities/mcp-account-routes.d.ts +3 -0
- package/dist/activities/mcp-credentials.d.ts +12 -13
- package/dist/activities/mcp-operation-authority.d.ts +0 -5
- package/dist/activities/model-call-fact-reconciler.d.ts +34 -0
- package/dist/activities/open-suffix-resume.d.ts +13 -0
- package/dist/activities/parent-wake.d.ts +6 -12
- package/dist/activities/retained-screenshots.d.ts +7 -2
- package/dist/activities/rig-verification.d.ts +2 -3
- package/dist/activities/run-credential-renewal.d.ts +1 -0
- package/dist/activities/run-credentials.d.ts +15 -3
- package/dist/activities/sandbox-images.d.ts +1 -1
- package/dist/activities/sandbox-lease.d.ts +47 -9
- package/dist/activities/scheduled-tasks.d.ts +4 -35
- package/dist/activities/session-state.d.ts +70 -3
- package/dist/activities/types.d.ts +55 -6
- package/dist/activities/workspace-capture.d.ts +2 -0
- package/dist/activities/workspace-credential-provider.d.ts +46 -0
- package/dist/{activities-control-HMFGSKC5.js → activities-control-BNPTRTOE.js} +1896 -418
- package/dist/activities-control-BNPTRTOE.js.map +1 -0
- package/dist/activities-control.d.ts +182 -4
- package/dist/{activities-turn-AP67JADS.js → activities-turn-5LGZOSVU.js} +4476 -1327
- package/dist/activities-turn-5LGZOSVU.js.map +1 -0
- package/dist/activities.d.ts +182 -4
- package/dist/artifact-materializer-entry.js +5 -2
- package/dist/artifact-materializer-entry.js.map +1 -1
- package/dist/artifact-outbox-entry.js +5 -2
- package/dist/artifact-outbox-entry.js.map +1 -1
- package/dist/browser-deadline-checkpoint-contract.d.ts +2 -0
- package/dist/{chunk-A4XQWVZK.js → chunk-3ZTRWDMN.js} +307 -4
- package/dist/chunk-3ZTRWDMN.js.map +1 -0
- package/dist/{chunk-RAMNYSAW.js → chunk-4ER3YXOT.js} +22 -4
- package/dist/chunk-4ER3YXOT.js.map +1 -0
- package/dist/{chunk-CYITU5UH.js → chunk-LJX7Z2KP.js} +1445 -343
- package/dist/chunk-LJX7Z2KP.js.map +1 -0
- package/dist/editable-artifact-materializer-service.d.ts +2 -2
- package/dist/editable-artifact-outbox-service.d.ts +2 -2
- package/dist/host-export-pump.d.ts +3 -1
- package/dist/host-export.d.ts +1 -1
- package/dist/host-export.js +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/index.d.ts +95 -3
- package/dist/index.js +137 -43
- package/dist/index.js.map +1 -1
- package/dist/observability-metrics.d.ts +118 -8
- package/dist/retained-process-diagnostics.d.ts +4 -0
- package/dist/retained-process-retry.d.ts +7 -0
- package/dist/sandbox-resume.d.ts +55 -13
- package/dist/sandbox-routing.d.ts +5 -3
- package/dist/sandbox-snapshot-diagnostics.d.ts +20 -0
- package/dist/session-event-fanout.d.ts +6 -0
- package/dist/warm-capture-holder.d.ts +3 -0
- package/dist/worker-service-lifecycle.d.ts +12 -0
- package/dist/workflow-bundle.js +273 -41
- package/dist/workflows/activities.d.ts +1 -1
- package/dist/workflows/browser-deadline-checkpoint.d.ts +9 -0
- package/dist/workflows/scheduled-tasks.d.ts +4 -0
- package/dist/workflows/session.d.ts +36 -0
- package/dist/workflows.d.ts +1 -0
- package/package.json +21 -19
- package/src/activities/agent-run-admission.ts +17 -1
- package/src/activities/agent-turn/admission.ts +66 -3
- package/src/activities/agent-turn/agent-build.ts +84 -10
- package/src/activities/agent-turn/claim.ts +186 -43
- package/src/activities/agent-turn/claude-usage-observer.ts +221 -0
- package/src/activities/agent-turn/code-search.ts +275 -0
- package/src/activities/agent-turn/codex-capacity.ts +172 -8
- package/src/activities/agent-turn/codex-plan-entitlement.ts +254 -0
- package/src/activities/agent-turn/codex.ts +13 -5
- package/src/activities/agent-turn/compaction-prep.ts +170 -102
- package/src/activities/agent-turn/credential-leases.ts +122 -216
- package/src/activities/agent-turn/credential-restriction.ts +14 -0
- package/src/activities/agent-turn/errors.ts +647 -48
- package/src/activities/agent-turn/failure-settlement.ts +682 -130
- package/src/activities/agent-turn/final-reply.ts +46 -0
- package/src/activities/agent-turn/finalization-monitor.ts +120 -0
- package/src/activities/agent-turn/finalization.ts +146 -43
- package/src/activities/agent-turn/github-repository-bindings.ts +3 -1
- package/src/activities/agent-turn/governance-model.ts +69 -28
- package/src/activities/agent-turn/history-sink.ts +16 -2
- package/src/activities/agent-turn/history.ts +38 -11
- package/src/activities/agent-turn/input-wait-reply.ts +103 -0
- package/src/activities/agent-turn/knowledge-source-tools.ts +2 -0
- package/src/activities/agent-turn/media-artifacts.ts +2 -1
- package/src/activities/agent-turn/model-call-admission.ts +94 -0
- package/src/activities/agent-turn/model-usage.ts +64 -3
- package/src/activities/agent-turn/model-wire-dispatch.ts +27 -0
- package/src/activities/agent-turn/optional-repositories.ts +224 -0
- package/src/activities/agent-turn/provider-dispatch-barrier.ts +22 -0
- package/src/activities/agent-turn/quiescence.ts +10 -7
- package/src/activities/agent-turn/recovery-warning.ts +16 -0
- package/src/activities/agent-turn/refresh-credentials.ts +44 -0
- package/src/activities/agent-turn/run-credentials.ts +116 -55
- package/src/activities/agent-turn/run.ts +320 -93
- package/src/activities/agent-turn/sandbox-establish.ts +84 -8
- package/src/activities/agent-turn/sandbox-provision.ts +3 -1
- package/src/activities/agent-turn/sandbox-route.ts +4 -21
- package/src/activities/agent-turn/sandbox-runtime.ts +343 -18
- package/src/activities/agent-turn/session-title.ts +81 -5
- package/src/activities/agent-turn/skill-checkout.ts +111 -24
- package/src/activities/agent-turn/skill-install.ts +1 -1
- package/src/activities/agent-turn/skill-read.ts +374 -28
- package/src/activities/agent-turn/skill-remove.ts +46 -0
- package/src/activities/agent-turn/skill-save.ts +1 -1
- package/src/activities/agent-turn/skill-search.ts +10 -1
- package/src/activities/agent-turn/skill-selection.ts +4 -0
- package/src/activities/agent-turn/skill-tools.ts +112 -18
- package/src/activities/agent-turn/skill-transfer.ts +68 -23
- package/src/activities/agent-turn/stream-attempt.ts +313 -77
- package/src/activities/agent-turn/subscription-lease.ts +115 -0
- package/src/activities/agent-turn/tool-environment.ts +316 -167
- package/src/activities/agent-turn/tool-policy.ts +80 -1
- package/src/activities/agent-turn/turn-context.ts +35 -0
- package/src/activities/agent-turn/turn-sandbox-access.ts +7 -1
- package/src/activities/agent-turn/xai-capacity.ts +94 -51
- package/src/activities/automations.ts +76 -4
- package/src/activities/browser-deadline-checkpoint.ts +279 -0
- package/src/activities/capabilities.ts +108 -11
- package/src/activities/codemode-dispatcher.ts +36 -8
- package/src/activities/codex-capacity.ts +60 -25
- package/src/activities/codex-rotation.ts +39 -17
- package/src/activities/context-compaction.ts +75 -18
- package/src/activities/gmail-files.ts +88 -0
- package/src/activities/goals.ts +116 -121
- package/src/activities/google-drive-publication.ts +1 -3
- package/src/activities/image-generation-operation.ts +1 -1
- package/src/activities/knowledge-indexing.ts +269 -15
- package/src/activities/knowledge-source-sync.ts +10 -0
- package/src/activities/mcp-account-routes.ts +17 -0
- package/src/activities/mcp-credentials.ts +83 -194
- package/src/activities/mcp-operation-authority.ts +16 -41
- package/src/activities/model-call-fact-reconciler.ts +112 -0
- package/src/activities/open-suffix-resume.ts +15 -2
- package/src/activities/parent-wake.ts +46 -21
- package/src/activities/retained-screenshots.ts +82 -11
- package/src/activities/rig-verification.ts +38 -37
- package/src/activities/run-credential-renewal.ts +13 -1
- package/src/activities/run-credentials.ts +59 -17
- package/src/activities/run-input.ts +25 -16
- package/src/activities/sandbox-images.ts +0 -1
- package/src/activities/sandbox-lease.ts +798 -82
- package/src/activities/scheduled-tasks.ts +550 -178
- package/src/activities/session-state.ts +245 -6
- package/src/activities/site-auth-maintenance.ts +3 -0
- package/src/activities/types.ts +72 -5
- package/src/activities/workflow-wake.ts +2 -17
- package/src/activities/workspace-capture.ts +13 -2
- package/src/activities/workspace-credential-provider.ts +283 -0
- package/src/activities-control.ts +4 -0
- package/src/activities-turn.ts +5 -0
- package/src/activities.ts +13 -0
- package/src/activity-services.ts +16 -4
- package/src/browser-deadline-checkpoint-contract.ts +5 -0
- package/src/editable-artifact-hint-broker.ts +3 -0
- package/src/editable-artifact-materializer-service.ts +7 -3
- package/src/editable-artifact-outbox-service.ts +4 -4
- package/src/github-rest-mcp.ts +1 -2
- package/src/host-export-pump.ts +26 -4
- package/src/host-export.ts +3 -0
- package/src/http.ts +4 -2
- package/src/index.ts +99 -37
- package/src/observability-metrics.ts +510 -5
- package/src/personal-github-git-credentials.ts +2 -1
- package/src/pr-review-credentials.ts +1 -3
- package/src/retained-process-diagnostics.ts +50 -0
- package/src/retained-process-retry.ts +36 -0
- package/src/sandbox-resume.ts +388 -101
- package/src/sandbox-routing.ts +150 -25
- package/src/sandbox-snapshot-diagnostics.ts +112 -0
- package/src/session-event-fanout.ts +23 -0
- package/src/warm-capture-holder.ts +15 -0
- package/src/worker-service-lifecycle.ts +53 -0
- package/src/workflows/activities.ts +16 -1
- package/src/workflows/browser-deadline-checkpoint.ts +50 -0
- package/src/workflows/file-upload-reaper.ts +2 -0
- package/src/workflows/scheduled-tasks.ts +26 -13
- package/src/workflows/session.ts +242 -22
- package/src/workflows.ts +4 -0
- package/dist/activities/agent-turn/knowledge-sources.d.ts +0 -20
- package/dist/activities/packs.d.ts +0 -55
- package/dist/activities-control-HMFGSKC5.js.map +0 -1
- package/dist/activities-turn-AP67JADS.js.map +0 -1
- package/dist/chunk-A4XQWVZK.js.map +0 -1
- package/dist/chunk-CYITU5UH.js.map +0 -1
- package/dist/chunk-RAMNYSAW.js.map +0 -1
- package/src/activities/agent-turn/knowledge-sources.ts +0 -86
- package/src/activities/packs.ts +0 -166
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ArtifactMaterializerSettings } from "@opengeni/config";
|
|
2
2
|
import { type Database } from "@opengeni/db";
|
|
3
3
|
import { type Observability } from "@opengeni/observability";
|
|
4
4
|
import { type ObjectStorage } from "@opengeni/storage";
|
|
@@ -36,7 +36,7 @@ export type CreateEditableArtifactMaterializerServiceInput = Readonly<{
|
|
|
36
36
|
}>;
|
|
37
37
|
}>;
|
|
38
38
|
export type ProductionEditableArtifactMaterializerServiceOptions = Readonly<{
|
|
39
|
-
settings:
|
|
39
|
+
settings: ArtifactMaterializerSettings;
|
|
40
40
|
/** Dedicated DSN; never defaults to settings.databaseUrl. */
|
|
41
41
|
databaseUrl: string;
|
|
42
42
|
declaredDatabaseRole: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ArtifactOutboxSettings } from "@opengeni/config";
|
|
2
2
|
import type { EditableArtifactOutboxDispatchSummary } from "@opengeni/core";
|
|
3
3
|
import { type Observability } from "@opengeni/observability";
|
|
4
4
|
import type { EditableArtifactHintNatsAuth } from "./editable-artifact-hint-broker.js";
|
|
@@ -29,7 +29,7 @@ export type CreateEditableArtifactOutboxServiceInput = Readonly<{
|
|
|
29
29
|
readinessTimeoutMs?: number;
|
|
30
30
|
}>;
|
|
31
31
|
export type ProductionEditableArtifactOutboxServiceOptions = Readonly<{
|
|
32
|
-
settings:
|
|
32
|
+
settings: ArtifactOutboxSettings;
|
|
33
33
|
databaseUrl: string;
|
|
34
34
|
declaredDatabaseRole: string;
|
|
35
35
|
natsUrl: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HostEventSink, HostUsageSink } from "@opengeni/contracts";
|
|
1
|
+
import type { HostEventSink, HostLifecycleFactSink, HostUsageSink } from "@opengeni/contracts";
|
|
2
2
|
import { type Database, type HostExportConsumerStatus, type HostExportKind } from "@opengeni/db";
|
|
3
3
|
import type { Observability } from "@opengeni/observability";
|
|
4
4
|
export type HostExportDrainResult = {
|
|
@@ -24,6 +24,8 @@ export type HostExportPumpOptions = {
|
|
|
24
24
|
db: Database;
|
|
25
25
|
eventSink?: HostEventSink;
|
|
26
26
|
usageSink?: HostUsageSink;
|
|
27
|
+
/** Content-free per-person product lifecycle facts (`lifecycle_fact`). */
|
|
28
|
+
lifecycleSink?: HostLifecycleFactSink;
|
|
27
29
|
observability?: Observability;
|
|
28
30
|
instanceId?: string;
|
|
29
31
|
pollIntervalMs?: number;
|
package/dist/host-export.d.ts
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* events or usage must not need that native runtime (or its libc contract).
|
|
7
7
|
*/
|
|
8
8
|
export { createHostExportPump, type HostExportDrainResult, type HostExportPump, type HostExportPumpOptions, } from "./host-export-pump.js";
|
|
9
|
-
export type { HostEventExport, HostEventExportBatch, HostEventSink, HostUsageExport, HostUsageExportBatch, HostUsageSink, } from "@opengeni/contracts";
|
|
9
|
+
export type { HostEventExport, HostEventExportBatch, HostEventSink, HostLifecycleFactExport, HostLifecycleFactExportBatch, HostLifecycleFactSink, HostUsageExport, HostUsageExportBatch, HostUsageSink, } from "@opengeni/contracts";
|
package/dist/host-export.js
CHANGED
package/dist/http.d.ts
CHANGED
|
@@ -27,6 +27,6 @@ export type WorkerHttpServerInput = {
|
|
|
27
27
|
export declare function createWorkerHttpHandler(input: WorkerHttpServerInput): (request: Request) => Promise<Response>;
|
|
28
28
|
export declare function startWorkerHttpServer(input: WorkerHttpServerInput): ReturnType<typeof Bun.serve>;
|
|
29
29
|
export declare function runReadinessChecks(checks: ReadinessChecks, timeoutMs?: number): Promise<ReadinessResult>;
|
|
30
|
-
export declare function dbReadyCheck(db: Database, posture?: RuntimeDatabasePostureOptions): () => Promise<void>;
|
|
30
|
+
export declare function dbReadyCheck(db: Database, posture?: RuntimeDatabasePostureOptions, afterDatabaseReady?: () => Promise<void>): () => Promise<void>;
|
|
31
31
|
export declare function natsReadyCheck(bus: EventBus): () => void;
|
|
32
32
|
export declare function temporalReadyCheck(connection: Pick<import("@temporalio/worker").NativeConnection, "workflowService" | "withDeadline">): () => Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type { InspectSessionAttemptActivity, SignalCodexCapacityWorkflow, Signal
|
|
|
10
10
|
import { type WorkerLifecycleState } from "./http.js";
|
|
11
11
|
import { type TurnTaskQueueStats } from "./observability-metrics.js";
|
|
12
12
|
import { type WorkerRunTarget } from "./worker-service-lifecycle.js";
|
|
13
|
-
export { createHostExportPump, type HostExportDrainResult, type HostExportPump, type HostExportPumpOptions, type HostEventExport, type HostEventExportBatch, type HostEventSink, type HostUsageExport, type HostUsageExportBatch, type HostUsageSink, } from "./host-export.js";
|
|
13
|
+
export { createHostExportPump, type HostExportDrainResult, type HostExportPump, type HostExportPumpOptions, type HostEventExport, type HostEventExportBatch, type HostEventSink, type HostLifecycleFactExport, type HostLifecycleFactExportBatch, type HostLifecycleFactSink, type HostUsageExport, type HostUsageExportBatch, type HostUsageSink, } from "./host-export.js";
|
|
14
14
|
export declare const KNOWLEDGE_INDEXING_SCHEDULE_ID = "opengeni-knowledge-indexing";
|
|
15
15
|
export declare const KNOWLEDGE_INDEXING_PERIOD_MS = 15000;
|
|
16
16
|
export declare const FILE_UPLOAD_REAPER_SCHEDULE_ID = "opengeni-file-upload-reaper";
|
|
@@ -56,7 +56,18 @@ export declare function createDefaultWorkerActivities(role: OpenGeniWorkerRole,
|
|
|
56
56
|
unavailable: number;
|
|
57
57
|
}>;
|
|
58
58
|
getCodexCapacityWait: (input: import("./activities.js").GetCodexCapacityWaitInput) => Promise<{
|
|
59
|
-
provider
|
|
59
|
+
provider: "xai";
|
|
60
|
+
waiterId: string;
|
|
61
|
+
generation: number;
|
|
62
|
+
nextCheckAt: string;
|
|
63
|
+
wakeRevision: number;
|
|
64
|
+
} | {
|
|
65
|
+
provider: "claude";
|
|
66
|
+
waiterId: string;
|
|
67
|
+
generation: number;
|
|
68
|
+
nextCheckAt: string;
|
|
69
|
+
wakeRevision: number;
|
|
70
|
+
} | {
|
|
60
71
|
waiterId: string;
|
|
61
72
|
generation: number;
|
|
62
73
|
nextCheckAt: string;
|
|
@@ -64,6 +75,21 @@ export declare function createDefaultWorkerActivities(role: OpenGeniWorkerRole,
|
|
|
64
75
|
} | null>;
|
|
65
76
|
reconcileCodexCapacityWait: (input: import("./activities.js").ReconcileCodexCapacityWaitInput) => Promise<import("./activities.js").ReconcileCodexCapacityWaitResult>;
|
|
66
77
|
maintainBrowserStateArtifacts: () => Promise<import("./activities/browser-state-artifact-reaper.js").MaintainBrowserStateArtifactsResult>;
|
|
78
|
+
listDueBrowserCheckpoints(): Promise<{
|
|
79
|
+
accountId: string;
|
|
80
|
+
workspaceId: string;
|
|
81
|
+
sandboxGroupId: string;
|
|
82
|
+
leaseId: string;
|
|
83
|
+
leaseEpoch: number;
|
|
84
|
+
instanceId: string;
|
|
85
|
+
browserSessionId: string;
|
|
86
|
+
controllerGeneration: string;
|
|
87
|
+
}[]>;
|
|
88
|
+
checkpointBrowserBeforeDeadline(target: import("@opengeni/db").BrowserDeadlineCheckpointTarget): Promise<{
|
|
89
|
+
status: "skipped";
|
|
90
|
+
} | {
|
|
91
|
+
status: "suspended";
|
|
92
|
+
}>;
|
|
67
93
|
settleAutomationRunFailure: (input: import("./activities.js").DispatchAutomationRunInput) => Promise<void>;
|
|
68
94
|
dispatchAutomationRun: (input: import("./activities.js").DispatchAutomationRunInput) => Promise<import("./activities.js").DispatchAutomationRunResult>;
|
|
69
95
|
indexDocument: (input: import("./activities.js").IndexDocumentInput) => Promise<{
|
|
@@ -114,6 +140,7 @@ export declare function createDefaultWorkerActivities(role: OpenGeniWorkerRole,
|
|
|
114
140
|
}>;
|
|
115
141
|
enqueueGoalRetryWake: (input: import("./activities.js").MaybeContinueGoalInput) => Promise<void>;
|
|
116
142
|
maybeContinueGoal: (input: import("./activities.js").MaybeContinueGoalInput) => Promise<import("./activities.js").MaybeContinueGoalResult>;
|
|
143
|
+
reconcileRecentModelCallFacts: () => Promise<import("./activities/model-call-fact-reconciler.js").ReconcileRecentModelCallFactsResult>;
|
|
117
144
|
runKnowledgeSourceSyncBatch: (input: import("./activities.js").RunKnowledgeSourceSyncBatchInput) => Promise<import("./activities.js").RunKnowledgeSourceSyncBatchResult>;
|
|
118
145
|
maintainRetainedScreenshots: () => Promise<import("./activities/retained-screenshot-reaper.js").MaintainRetainedScreenshotsResult>;
|
|
119
146
|
verifyRigChange: (input: {
|
|
@@ -199,12 +226,74 @@ export declare function createDefaultWorkerActivities(role: OpenGeniWorkerRole,
|
|
|
199
226
|
}>;
|
|
200
227
|
persistSessionAttemptQuiescence: (input: import("./activities.js").PersistSessionAttemptQuiescenceInput) => Promise<void>;
|
|
201
228
|
reconcileSessionAttemptQuiescence: (input: import("./activities.js").ReconcileSessionAttemptQuiescenceInput) => Promise<import("./activities.js").ReconcileSessionAttemptQuiescenceResult>;
|
|
229
|
+
reconcileSettledSessionAttempt: (input: import("./activities/types.js").ReconcileSettledSessionAttemptInput) => Promise<import("./activities/types.js").ReconcileSettledSessionAttemptResult>;
|
|
202
230
|
recoverDispatch: (input: import("./activities.js").RecoverDispatchInput) => Promise<import("./activities.js").RecoverDispatchResult>;
|
|
203
231
|
recoverEscapedMcpTimeout: (input: import("./activities.js").RecoverEscapedMcpTimeoutInput) => Promise<import("./activities.js").RecoverEscapedMcpTimeoutResult>;
|
|
204
|
-
peekSessionWork: (input: import("./activities/types.js").PeekSessionWorkInput) => Promise<
|
|
232
|
+
peekSessionWork: (input: import("./activities/types.js").PeekSessionWorkInput) => Promise<{
|
|
233
|
+
kind: "unavailable";
|
|
234
|
+
} | {
|
|
235
|
+
kind: "attempt-owned";
|
|
236
|
+
turnId: string;
|
|
237
|
+
attemptId: string;
|
|
238
|
+
executionGeneration: number;
|
|
239
|
+
activityRef: import("@opengeni/db").SessionAttemptActivityRef;
|
|
240
|
+
} | {
|
|
241
|
+
kind: "runnable";
|
|
242
|
+
admissionFence?: import("@opengeni/db").SessionAdmissionFence;
|
|
243
|
+
} | {
|
|
244
|
+
kind: "admission-blocked";
|
|
245
|
+
reason?: "sandbox_setup_outcome_unknown" | "sandbox_setup_recovery_exhausted";
|
|
246
|
+
ref?: import("@opengeni/db").SandboxSetupOutcomeUnknown | import("@opengeni/db").SandboxSetupRecoveryExhausted;
|
|
247
|
+
} | {
|
|
248
|
+
kind: "sandbox-lifecycle-wait";
|
|
249
|
+
ref: import("@opengeni/db").SandboxLifecycleWait;
|
|
250
|
+
} | {
|
|
251
|
+
kind: "approval-pending";
|
|
252
|
+
triggerEventId: string;
|
|
253
|
+
admissionFence?: import("@opengeni/db").SessionAdmissionFence;
|
|
254
|
+
} | {
|
|
255
|
+
kind: "approval-wait";
|
|
256
|
+
humanInputRequestId?: string;
|
|
257
|
+
interactionInterventionId?: string;
|
|
258
|
+
scheduledRunTimeout?: {
|
|
259
|
+
runId: string;
|
|
260
|
+
turnId: string;
|
|
261
|
+
};
|
|
262
|
+
expiresAt?: string;
|
|
263
|
+
} | {
|
|
264
|
+
kind: "capacity-wait";
|
|
265
|
+
ref: {
|
|
266
|
+
provider?: "codex" | "xai" | "claude";
|
|
267
|
+
waiterId: string;
|
|
268
|
+
generation: number;
|
|
269
|
+
nextCheckAt: string;
|
|
270
|
+
wakeRevision: number;
|
|
271
|
+
};
|
|
272
|
+
} | {
|
|
273
|
+
kind: "interruption-pending";
|
|
274
|
+
attemptId: string;
|
|
275
|
+
} | {
|
|
276
|
+
kind: "cancellation-wait";
|
|
277
|
+
attemptId: string;
|
|
278
|
+
} | {
|
|
279
|
+
kind: "input-wait";
|
|
280
|
+
disposition: "held" | "timeout" | "superseded";
|
|
281
|
+
waitTurnId: string;
|
|
282
|
+
deadlineAt: string;
|
|
283
|
+
} | {
|
|
284
|
+
kind: "idle";
|
|
285
|
+
} | {
|
|
286
|
+
kind: "attempt-owned";
|
|
287
|
+
turnId: string;
|
|
288
|
+
attemptId: string;
|
|
289
|
+
executionGeneration: number;
|
|
290
|
+
activityRef: import("@opengeni/db").SessionAttemptActivityRef;
|
|
291
|
+
ownerActivityState: "pending" | "settled" | "unknown";
|
|
292
|
+
}>;
|
|
205
293
|
settleSessionInputWait: (input: import("./activities/types.js").SettleSessionInputWaitInput) => Promise<import("./activities/types.js").SettleSessionInputWaitResult>;
|
|
206
294
|
expireSessionHumanInput: (input: import("./activities.js").ExpireSessionHumanInputInput) => Promise<import("./activities.js").ExpireSessionHumanInputResult>;
|
|
207
295
|
expireSessionInteractionIntervention: (input: import("./activities/types.js").ExpireSessionInteractionInterventionInput) => Promise<import("./activities/types.js").ExpireSessionInteractionInterventionResult>;
|
|
296
|
+
expireScheduledRunHumanWait: (input: import("./activities/types.js").ExpireScheduledRunHumanWaitInput) => Promise<import("./activities/types.js").ExpireScheduledRunHumanWaitResult>;
|
|
208
297
|
markSessionIdle: (input: import("./activities/types.js").MarkSessionIdleInput) => Promise<void>;
|
|
209
298
|
dispatchSessionWorkflowWakes(): Promise<import("./activities/workflow-wake.js").DispatchSessionWorkflowWakesResult>;
|
|
210
299
|
} | {
|
|
@@ -304,6 +393,9 @@ export type OpenGeniWorkerServiceOptions = Omit<WorkerOptions, "activityDependen
|
|
|
304
393
|
db: Database;
|
|
305
394
|
bus: EventBus;
|
|
306
395
|
};
|
|
396
|
+
/** Host-owned final containment after a stalled cleanup has drained peers.
|
|
397
|
+
* The standalone process exits; embedded hosts own their termination policy. */
|
|
398
|
+
terminateWorker?: () => void;
|
|
307
399
|
/**
|
|
308
400
|
* Exact catalog posture required by the standalone runtime. Embedded hosts
|
|
309
401
|
* may omit this when they own an equivalent database isolation contract.
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createHostExportPump
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4ER3YXOT.js";
|
|
4
4
|
import {
|
|
5
5
|
CONTROL_WORKER_MAX_CACHED_WORKFLOWS,
|
|
6
6
|
CONTROL_WORKER_MAX_CONCURRENT_ACTIVITIES,
|
|
@@ -15,11 +15,11 @@ import {
|
|
|
15
15
|
initializeContextCompactionMetrics,
|
|
16
16
|
initializeWorkerOutcomeMetrics,
|
|
17
17
|
normalizeTurnTaskQueueStats,
|
|
18
|
-
|
|
18
|
+
observabilityEventBusOptions,
|
|
19
19
|
startContextCompactionPendingMonitor,
|
|
20
20
|
startSessionRecoveryMonitor,
|
|
21
21
|
startTurnCapacityMonitor
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-3ZTRWDMN.js";
|
|
23
23
|
import "./chunk-PZ5AY32C.js";
|
|
24
24
|
|
|
25
25
|
// src/index.ts
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
} from "@opengeni/config";
|
|
34
34
|
import {
|
|
35
35
|
assertRuntimeDatabasePosture as assertRuntimeDatabasePosture2,
|
|
36
|
+
isRetryableRuntimeDatabaseStartupError,
|
|
36
37
|
countSessionRecoveryBacklog,
|
|
37
38
|
createDb,
|
|
38
39
|
getContextCompactionPendingSummary,
|
|
@@ -59,7 +60,12 @@ import { existsSync } from "fs";
|
|
|
59
60
|
import { fileURLToPath } from "url";
|
|
60
61
|
|
|
61
62
|
// src/workflows/activities.ts
|
|
62
|
-
import {
|
|
63
|
+
import {
|
|
64
|
+
ActivityCancellationType,
|
|
65
|
+
ActivityFailure,
|
|
66
|
+
ApplicationFailure,
|
|
67
|
+
proxyActivities
|
|
68
|
+
} from "@temporalio/workflow";
|
|
63
69
|
|
|
64
70
|
// src/knowledge-source-sync-activity-policy.ts
|
|
65
71
|
var KNOWLEDGE_SOURCE_SYNC_ACTIVITY_HEARTBEAT_TIMEOUT_MS = 12e4;
|
|
@@ -209,16 +215,17 @@ async function runReadinessChecks(checks, timeoutMs = 2e3) {
|
|
|
209
215
|
checks: result
|
|
210
216
|
};
|
|
211
217
|
}
|
|
212
|
-
function dbReadyCheck(db, posture) {
|
|
218
|
+
function dbReadyCheck(db, posture, afterDatabaseReady) {
|
|
213
219
|
let inFlight;
|
|
214
220
|
return () => {
|
|
215
221
|
if (inFlight) return inFlight;
|
|
216
222
|
inFlight = (async () => {
|
|
217
223
|
if (posture) {
|
|
218
224
|
await assertRuntimeDatabasePosture(db, posture);
|
|
219
|
-
|
|
225
|
+
} else {
|
|
226
|
+
await db.execute(dbSql`select 1`);
|
|
220
227
|
}
|
|
221
|
-
await
|
|
228
|
+
await afterDatabaseReady?.();
|
|
222
229
|
})().finally(() => {
|
|
223
230
|
inFlight = void 0;
|
|
224
231
|
});
|
|
@@ -408,6 +415,47 @@ function safeLifecycleLog(log) {
|
|
|
408
415
|
} catch {
|
|
409
416
|
}
|
|
410
417
|
}
|
|
418
|
+
function createWorkerCleanupContainment(input) {
|
|
419
|
+
let requested = false;
|
|
420
|
+
let finished = false;
|
|
421
|
+
let timer;
|
|
422
|
+
return {
|
|
423
|
+
request() {
|
|
424
|
+
if (requested || finished) return;
|
|
425
|
+
requested = true;
|
|
426
|
+
if (input.terminate) {
|
|
427
|
+
timer = setTimeout(() => {
|
|
428
|
+
safeLifecycleLog(
|
|
429
|
+
() => input.observability.error("worker cleanup drain exhausted; terminating host", {
|
|
430
|
+
errorClass: "WorkerLifecycleOperationError",
|
|
431
|
+
errorCode: "worker_cleanup_drain_exhausted",
|
|
432
|
+
origin: "worker-lifecycle"
|
|
433
|
+
})
|
|
434
|
+
);
|
|
435
|
+
input.terminate?.();
|
|
436
|
+
}, input.timeoutMs ?? 1e5);
|
|
437
|
+
timer.unref?.();
|
|
438
|
+
}
|
|
439
|
+
let accepted = false;
|
|
440
|
+
try {
|
|
441
|
+
accepted = input.drain();
|
|
442
|
+
} catch {
|
|
443
|
+
}
|
|
444
|
+
if (!accepted)
|
|
445
|
+
safeLifecycleLog(
|
|
446
|
+
() => input.observability.error("worker cleanup drain request failed", {
|
|
447
|
+
errorClass: "WorkerLifecycleOperationError",
|
|
448
|
+
errorCode: "worker_shutdown_request_failed",
|
|
449
|
+
origin: "worker-lifecycle"
|
|
450
|
+
})
|
|
451
|
+
);
|
|
452
|
+
},
|
|
453
|
+
finished() {
|
|
454
|
+
finished = true;
|
|
455
|
+
clearTimeout(timer);
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
}
|
|
411
459
|
|
|
412
460
|
// src/memory-pressure-guard.ts
|
|
413
461
|
import { readFileSync } from "fs";
|
|
@@ -762,6 +810,13 @@ function installWorkerUnhandledRejectionBoundary(runtimeProcess = process, repor
|
|
|
762
810
|
return () => runtimeProcess.off("unhandledRejection", onUnhandledRejection);
|
|
763
811
|
}
|
|
764
812
|
|
|
813
|
+
// src/browser-deadline-checkpoint-contract.ts
|
|
814
|
+
var BROWSER_DEADLINE_CHECKPOINT_SWEEP_ID = "opengeni-browser-deadline-checkpoints-v1";
|
|
815
|
+
var QUEUE_SUFFIX = "-browser-checkpoint-v1";
|
|
816
|
+
function browserDeadlineCheckpointTaskQueue(base) {
|
|
817
|
+
return base.endsWith(QUEUE_SUFFIX) ? base : `${base}${QUEUE_SUFFIX}`;
|
|
818
|
+
}
|
|
819
|
+
|
|
765
820
|
// src/index.ts
|
|
766
821
|
var SANDBOX_REAPER_SCHEDULE_ID = "opengeni-sandbox-lease-reaper";
|
|
767
822
|
var KNOWLEDGE_INDEXING_SCHEDULE_ID = "opengeni-knowledge-indexing";
|
|
@@ -784,7 +839,7 @@ function temporalWorkflowExecutionNotFound(error) {
|
|
|
784
839
|
return isGrpcServiceError(error) && error.code === 5;
|
|
785
840
|
}
|
|
786
841
|
async function createDefaultWorkerActivities(role, dependencies = {}) {
|
|
787
|
-
return role === "control" ? (await import("./activities-control-
|
|
842
|
+
return role === "control" ? (await import("./activities-control-BNPTRTOE.js")).createControlActivities(dependencies) : (await import("./activities-turn-5LGZOSVU.js")).createTurnActivities(dependencies);
|
|
788
843
|
}
|
|
789
844
|
function resolveOpenGeniWorkflowDefinition(moduleUrl = import.meta.url) {
|
|
790
845
|
const modulePath = fileURLToPath(moduleUrl).replaceAll("\\", "/");
|
|
@@ -839,10 +894,18 @@ async function createOpenGeniWorker(options) {
|
|
|
839
894
|
}
|
|
840
895
|
),
|
|
841
896
|
async (connection) => {
|
|
897
|
+
let turnWorker;
|
|
898
|
+
let cleanupDrainRequested = false;
|
|
842
899
|
const activityDependencies = {
|
|
843
900
|
...options.activityDependencies,
|
|
844
901
|
settings,
|
|
845
|
-
observability
|
|
902
|
+
observability,
|
|
903
|
+
requestWorkerDrain: options.activityDependencies?.requestWorkerDrain ?? (() => {
|
|
904
|
+
if (cleanupDrainRequested) return;
|
|
905
|
+
if (!turnWorker) throw new Error("turn worker lifecycle is not initialized");
|
|
906
|
+
turnWorker.shutdown();
|
|
907
|
+
cleanupDrainRequested = true;
|
|
908
|
+
})
|
|
846
909
|
};
|
|
847
910
|
const activities = options.activities ?? await createDefaultWorkerActivities(options.role, activityDependencies);
|
|
848
911
|
const turnConcurrency = options.role === "turn" ? createTurnWorkerConcurrencyPlan(settings, { observability }) : null;
|
|
@@ -876,28 +939,38 @@ async function createOpenGeniWorker(options) {
|
|
|
876
939
|
} : turnConcurrency.options
|
|
877
940
|
});
|
|
878
941
|
if (options.role !== "control") {
|
|
942
|
+
turnWorker = worker;
|
|
879
943
|
turnConcurrency?.admission?.finalizeStartupBaseline();
|
|
880
944
|
return { worker, connection };
|
|
881
945
|
}
|
|
946
|
+
const ownedWorkers = [worker];
|
|
882
947
|
try {
|
|
883
|
-
const
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
948
|
+
for (const taskQueue of [
|
|
949
|
+
sandboxLifecycleTaskQueue(settings.temporalTaskQueue),
|
|
950
|
+
browserDeadlineCheckpointTaskQueue(settings.temporalTaskQueue)
|
|
951
|
+
]) {
|
|
952
|
+
const lifecycleWorker = await Worker.create({
|
|
953
|
+
...sharedWorkerOptions,
|
|
954
|
+
...workflowDefinition,
|
|
955
|
+
taskQueue,
|
|
956
|
+
reuseV8Context: true,
|
|
957
|
+
workflowThreadPoolSize: 1,
|
|
958
|
+
maxCachedWorkflows: CONTROL_WORKER_MAX_CACHED_WORKFLOWS,
|
|
959
|
+
maxConcurrentWorkflowTaskExecutions: CONTROL_WORKER_MAX_CONCURRENT_WORKFLOW_TASKS,
|
|
960
|
+
maxConcurrentActivityTaskExecutions: CONTROL_WORKER_MAX_CONCURRENT_ACTIVITIES
|
|
961
|
+
});
|
|
962
|
+
ownedWorkers.push(lifecycleWorker);
|
|
963
|
+
}
|
|
893
964
|
return {
|
|
894
|
-
worker: combineWorkerRunTargets(
|
|
965
|
+
worker: combineWorkerRunTargets(ownedWorkers),
|
|
895
966
|
connection
|
|
896
967
|
};
|
|
897
968
|
} catch (error) {
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
969
|
+
for (const ownedWorker of ownedWorkers) {
|
|
970
|
+
try {
|
|
971
|
+
ownedWorker.shutdown();
|
|
972
|
+
} catch {
|
|
973
|
+
}
|
|
901
974
|
}
|
|
902
975
|
throw error;
|
|
903
976
|
}
|
|
@@ -1006,20 +1079,26 @@ async function createWorkerWorkflowSignaler(settings, db) {
|
|
|
1006
1079
|
return normalizeTurnTaskQueueStats(response.stats);
|
|
1007
1080
|
},
|
|
1008
1081
|
startSandboxReaperWorkflow: async () => {
|
|
1009
|
-
|
|
1010
|
-
|
|
1082
|
+
const starts = await Promise.allSettled([
|
|
1083
|
+
temporal.workflow.start("sandboxReaperWorkflowV2", {
|
|
1011
1084
|
taskQueue: sandboxLifecycleTaskQueue(settings.temporalTaskQueue),
|
|
1012
1085
|
workflowId: SANDBOX_REAPER_V2_WORKFLOW_ID,
|
|
1013
1086
|
workflowIdReusePolicy: "ALLOW_DUPLICATE",
|
|
1014
1087
|
args: []
|
|
1015
|
-
})
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1088
|
+
}),
|
|
1089
|
+
temporal.workflow.start("browserDeadlineCheckpointSweepWorkflow", {
|
|
1090
|
+
taskQueue: browserDeadlineCheckpointTaskQueue(settings.temporalTaskQueue),
|
|
1091
|
+
workflowId: BROWSER_DEADLINE_CHECKPOINT_SWEEP_ID,
|
|
1092
|
+
workflowIdReusePolicy: "ALLOW_DUPLICATE",
|
|
1093
|
+
args: []
|
|
1094
|
+
})
|
|
1095
|
+
]);
|
|
1096
|
+
for (const start of starts) {
|
|
1097
|
+
if (start.status === "rejected" && !(start.reason instanceof WorkflowExecutionAlreadyStartedError)) {
|
|
1098
|
+
throw start.reason;
|
|
1020
1099
|
}
|
|
1021
|
-
throw error;
|
|
1022
1100
|
}
|
|
1101
|
+
return starts[0].status === "fulfilled" ? "started" : "already_running";
|
|
1023
1102
|
},
|
|
1024
1103
|
startVideoGenerationWorkflow: async ({ accountId, workspaceId, operationId }) => {
|
|
1025
1104
|
try {
|
|
@@ -1271,6 +1350,7 @@ async function createOpenGeniWorkerService(options) {
|
|
|
1271
1350
|
const retryOptions = startupRetryOptions(settings);
|
|
1272
1351
|
const onRetry = (event) => logStartupDependencyRetry(observability, event);
|
|
1273
1352
|
let lifecycle;
|
|
1353
|
+
let cleanupContainment;
|
|
1274
1354
|
let signaler;
|
|
1275
1355
|
let workerBundle;
|
|
1276
1356
|
let turnCapacityMonitor;
|
|
@@ -1321,7 +1401,11 @@ async function createOpenGeniWorkerService(options) {
|
|
|
1321
1401
|
inspectSessionAttemptActivity,
|
|
1322
1402
|
signalCodexCapacityWorkflow,
|
|
1323
1403
|
startSandboxReaperWorkflow,
|
|
1324
|
-
startVideoGenerationWorkflow
|
|
1404
|
+
startVideoGenerationWorkflow,
|
|
1405
|
+
requestWorkerDrain: () => {
|
|
1406
|
+
if (!cleanupContainment) throw new Error("worker cleanup containment is not initialized");
|
|
1407
|
+
cleanupContainment.request();
|
|
1408
|
+
}
|
|
1325
1409
|
}
|
|
1326
1410
|
});
|
|
1327
1411
|
if (options.role === "turn") {
|
|
@@ -1380,18 +1464,15 @@ async function createOpenGeniWorkerService(options) {
|
|
|
1380
1464
|
);
|
|
1381
1465
|
}
|
|
1382
1466
|
if (options.http !== false) {
|
|
1383
|
-
const
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
);
|
|
1467
|
+
const readinessDb = options.http?.readinessDb ?? options.activityDependencies.db;
|
|
1468
|
+
const databaseReady = dbReadyCheck(readinessDb, options.databasePosture, async () => {
|
|
1469
|
+
await resolveCatalogSettings(readinessDb, settings);
|
|
1470
|
+
});
|
|
1387
1471
|
httpServer = startWorkerHttpServer({
|
|
1388
1472
|
settings,
|
|
1389
1473
|
observability,
|
|
1390
1474
|
checks: {
|
|
1391
|
-
db:
|
|
1392
|
-
await databaseReady();
|
|
1393
|
-
await resolveCatalogSettings(options.activityDependencies.db, settings);
|
|
1394
|
-
},
|
|
1475
|
+
db: databaseReady,
|
|
1395
1476
|
nats: natsReadyCheck(options.activityDependencies.bus),
|
|
1396
1477
|
temporal: temporalReadyCheck(workerBundle.connection)
|
|
1397
1478
|
},
|
|
@@ -1416,9 +1497,21 @@ async function createOpenGeniWorkerService(options) {
|
|
|
1416
1497
|
if (!activeWorkerBundle) {
|
|
1417
1498
|
throw new Error("OpenGeni worker service initialization did not complete");
|
|
1418
1499
|
}
|
|
1500
|
+
cleanupContainment = createWorkerCleanupContainment({
|
|
1501
|
+
drain: () => lifecycle?.drain("stalled turn finalization") ?? false,
|
|
1502
|
+
...options.terminateWorker ? { terminate: options.terminateWorker } : {},
|
|
1503
|
+
observability
|
|
1504
|
+
});
|
|
1505
|
+
const activeCleanupContainment = cleanupContainment;
|
|
1419
1506
|
lifecycle = createWorkerServiceLifecycle({
|
|
1420
1507
|
role: options.role,
|
|
1421
|
-
worker:
|
|
1508
|
+
worker: {
|
|
1509
|
+
shutdown: () => activeWorkerBundle.worker.shutdown(),
|
|
1510
|
+
run: async () => {
|
|
1511
|
+
await activeWorkerBundle.worker.run();
|
|
1512
|
+
activeCleanupContainment.finished();
|
|
1513
|
+
}
|
|
1514
|
+
},
|
|
1422
1515
|
observability,
|
|
1423
1516
|
closeOwnedResources: async () => {
|
|
1424
1517
|
memoryPressureGuard?.close();
|
|
@@ -1526,19 +1619,20 @@ async function startWorker() {
|
|
|
1526
1619
|
await retryStartupDependency(
|
|
1527
1620
|
"PostgreSQL runtime posture",
|
|
1528
1621
|
() => assertRuntimeDatabasePosture2(dbClient.db, databasePosture),
|
|
1529
|
-
{ ...retryOptions, onRetry }
|
|
1622
|
+
{ ...retryOptions, onRetry, shouldRetry: isRetryableRuntimeDatabaseStartupError }
|
|
1530
1623
|
);
|
|
1531
1624
|
bus = await retryStartupDependency(
|
|
1532
1625
|
"NATS",
|
|
1533
1626
|
() => createNatsEventBus(
|
|
1534
1627
|
settings.natsUrl,
|
|
1535
1628
|
controlPlaneAuth ? { user: controlPlaneAuth.user, pass: controlPlaneAuth.password } : void 0,
|
|
1536
|
-
|
|
1629
|
+
observabilityEventBusOptions(observability)
|
|
1537
1630
|
),
|
|
1538
1631
|
{ ...retryOptions, onRetry }
|
|
1539
1632
|
);
|
|
1540
1633
|
await runOpenGeniWorker({
|
|
1541
1634
|
role,
|
|
1635
|
+
terminateWorker: () => process.exit(1),
|
|
1542
1636
|
settings,
|
|
1543
1637
|
databasePosture,
|
|
1544
1638
|
http: { readinessDb: readinessDbClient.db },
|