@opengeni/worker-bundle 0.12.10 → 0.13.5

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 (72) hide show
  1. package/dist/activities/agent-turn.d.ts +778 -0
  2. package/dist/activities/capabilities.d.ts +18 -0
  3. package/dist/activities/codex-auth.d.ts +1 -0
  4. package/dist/activities/codex-capacity.d.ts +31 -0
  5. package/dist/activities/codex-fleet-shadow.d.ts +74 -0
  6. package/dist/activities/codex-rotation.d.ts +261 -0
  7. package/dist/activities/common.d.ts +17 -0
  8. package/dist/activities/context-compaction.d.ts +81 -0
  9. package/dist/activities/documents.d.ts +39 -0
  10. package/dist/activities/environment.d.ts +97 -0
  11. package/dist/activities/expiring-material-renewal.d.ts +38 -0
  12. package/dist/activities/file-upload-reaper.d.ts +25 -0
  13. package/dist/activities/git-credential-renewal.d.ts +41 -0
  14. package/dist/activities/goals.d.ts +16 -0
  15. package/dist/activities/mcp-credentials.d.ts +14 -0
  16. package/dist/activities/packs.d.ts +77 -0
  17. package/dist/activities/parent-wake.d.ts +54 -0
  18. package/dist/activities/recording.d.ts +90 -0
  19. package/dist/activities/redaction.d.ts +1 -0
  20. package/dist/activities/rig-verification.d.ts +131 -0
  21. package/dist/activities/run-credential-renewal.d.ts +28 -0
  22. package/dist/activities/run-credentials.d.ts +36 -0
  23. package/dist/activities/run-input.d.ts +106 -0
  24. package/dist/activities/sandbox-lease.d.ts +128 -0
  25. package/dist/activities/scheduled-tasks.d.ts +4 -0
  26. package/dist/activities/session-state.d.ts +39 -0
  27. package/dist/activities/streaming.d.ts +24 -0
  28. package/dist/activities/toolspace-token-renewal.d.ts +23 -0
  29. package/dist/activities/turn-attempt-fenced.d.ts +11 -0
  30. package/dist/activities/types.d.ts +240 -0
  31. package/dist/activities/workflow-wake.d.ts +15 -0
  32. package/dist/activities/workspace-capture.d.ts +105 -0
  33. package/dist/activities.d.ts +312 -0
  34. package/dist/concurrency.d.ts +19 -0
  35. package/dist/host-export-pump.d.ts +66 -0
  36. package/dist/host-export.d.ts +6 -67
  37. package/dist/http.d.ts +32 -0
  38. package/dist/index.d.ts +27 -388
  39. package/dist/index.js +2729 -1208
  40. package/dist/index.js.map +1 -1
  41. package/dist/observability-metrics.d.ts +200 -0
  42. package/dist/op-journal.d.ts +10 -0
  43. package/dist/sandbox-resume.d.ts +152 -0
  44. package/dist/sandbox-routing.d.ts +159 -0
  45. package/dist/worker-service-lifecycle.d.ts +20 -0
  46. package/dist/workflow-bundle.js +88 -20
  47. package/dist/workflows/activities.d.ts +27 -0
  48. package/dist/workflows/document-index.d.ts +41 -0
  49. package/dist/workflows/file-upload-reaper.d.ts +2 -0
  50. package/dist/workflows/rig-verification.d.ts +3 -0
  51. package/dist/workflows/sandbox-reaper.d.ts +1 -0
  52. package/dist/workflows/scheduled-tasks.d.ts +17 -0
  53. package/dist/workflows/session.d.ts +58 -0
  54. package/dist/workflows/workflow-wake.d.ts +3 -0
  55. package/dist/workflows.d.ts +7 -0
  56. package/package.json +13 -13
  57. package/src/activities/agent-turn.ts +873 -131
  58. package/src/activities/context-compaction.ts +265 -76
  59. package/src/activities/environment.ts +1 -0
  60. package/src/activities/goals.ts +14 -0
  61. package/src/activities/rig-verification.ts +2 -0
  62. package/src/activities/run-input.ts +18 -4
  63. package/src/activities/sandbox-lease.ts +787 -133
  64. package/src/activities/session-state.ts +56 -0
  65. package/src/activities/types.ts +21 -0
  66. package/src/activities/workspace-capture.ts +95 -4
  67. package/src/activities.ts +3 -0
  68. package/src/observability-metrics.ts +94 -0
  69. package/src/sandbox-resume.ts +383 -90
  70. package/src/sandbox-routing.ts +32 -10
  71. package/src/workflows/activities.ts +1 -0
  72. package/src/workflows/session.ts +70 -0
@@ -0,0 +1,105 @@
1
+ import type { Settings } from "@opengeni/config";
2
+ import type { Database } from "@opengeni/db";
3
+ import type { ObjectStorage } from "@opengeni/storage";
4
+ import type { Observability } from "@opengeni/observability";
5
+ import { SandboxChannelAService, type ChannelASession } from "@opengeni/runtime/sandbox";
6
+ import type { SessionEvent } from "@opengeni/contracts";
7
+ export declare const CAPTURE_TIMEOUT_MS = 120000;
8
+ export declare const PER_FILE_CONTENT_GUARD_BYTES: number;
9
+ export declare const PER_FILE_DIFF_GUARD_BYTES: number;
10
+ export declare const WHOLE_CAPTURE_GUARD_BYTES: number;
11
+ export declare const KEEP_LATEST_REVISIONS = 10;
12
+ export declare const RESIDUE_DIRS: readonly string[];
13
+ /**
14
+ * True when a workspace-relative FILE path lives INSIDE a residue dir — i.e. a
15
+ * residue dir is one of its ANCESTOR segments (not the leaf), so the file is
16
+ * churn/machine content never worth an after-image. `.config/xfce4/xfconf/…` and
17
+ * `.config/mimeapps.list` → true; a root FILE literally named `.config` (a user
18
+ * config the seed edits) → false (single segment, no residue ancestor); and
19
+ * `.github/x.yml`, `.gitignore` → false (`.github`/`.gitignore` are not residue).
20
+ * Matches the tree-BFS collapse (which collapses residue DIR nodes) so the
21
+ * Changes tab and the tree agree on what is workspace content.
22
+ */
23
+ export declare function isUnderResidueDir(wsPath: string): boolean;
24
+ /**
25
+ * The box is being torn down under us (Modal reclaim / reaper drain / terminate)
26
+ * — NOT a single file vanishing. Every subsequent op will fail too, so the
27
+ * capture must ABORT (throw) rather than skip-and-continue, so it never commits a
28
+ * bogus empty/partial revision for a dead box. Matched loosely so a provider
29
+ * wording tweak still classifies. (The real fix for this is keeping the box
30
+ * pinned through the capture window — sandbox-resume / agent-turn lease
31
+ * heartbeat; this classifier only guarantees we fail HONESTLY if it still races.)
32
+ */
33
+ export declare function isBoxExitingError(error: unknown): boolean;
34
+ /** Marker thrown when the box died mid-capture — aborts cleanly (no partial row). */
35
+ export declare class BoxExitingError extends Error {
36
+ constructor(message: string);
37
+ }
38
+ export type CaptureEventPublisher = (events: SessionEvent[]) => Promise<void>;
39
+ export type CaptureWorkspaceRevisionInput = {
40
+ db: Database;
41
+ objectStorage: ObjectStorage | null;
42
+ settings: Settings;
43
+ publish: CaptureEventPublisher | null;
44
+ /** The un-proxied setupBoxSession (NOT the routing veneer). */
45
+ session: ChannelASession;
46
+ /**
47
+ * Reopen the exact live provider instance as a fresh, non-owning read handle.
48
+ * Modal sessions keep mutable exec-process bookkeeping; reusing the handle
49
+ * that just drove model tools can strand a later capture command behind stale
50
+ * provider state. The lease still owns the box. Capture drops this handle
51
+ * without calling close(), which would terminate Modal's sandbox.
52
+ */
53
+ openReadSession?: () => Promise<ChannelASession>;
54
+ leaseEpoch: number;
55
+ sandboxGroupId: string;
56
+ accountId: string;
57
+ workspaceId: string;
58
+ sessionId: string;
59
+ turnId: string;
60
+ attemptId: string;
61
+ observability: Observability;
62
+ /**
63
+ * The owning turn activity's cancellation signal. Pause/Steer must preempt
64
+ * review-cache housekeeping immediately; correctness still comes from the
65
+ * activity plus the capture's transaction-level attempt/control/lease fences.
66
+ */
67
+ signal?: AbortSignal;
68
+ /** Test-only: override keep-latest-N GC threshold (default 10). */
69
+ keepLatest?: number;
70
+ };
71
+ type CaptureRepositoryReadResult = {
72
+ complete: true;
73
+ status: Awaited<ReturnType<SandboxChannelAService["gitStatus"]>>;
74
+ diff: Awaited<ReturnType<SandboxChannelAService["gitDiff"]>>;
75
+ } | {
76
+ complete: false;
77
+ degradedReason: "repository_read_unavailable";
78
+ };
79
+ /**
80
+ * Reattach a clean SDK handle to the exact already-live Modal sandbox. Modal's
81
+ * resume contract is a pure from-id reattach. Other providers keep the original
82
+ * session because their generic resume contract may restore or replace a dead
83
+ * instance, which capture does not own.
84
+ */
85
+ export declare function openFreshWorkspaceCaptureSession(input: {
86
+ backendId: string;
87
+ client: unknown;
88
+ session: ChannelASession;
89
+ expectedInstanceId: string;
90
+ }): Promise<ChannelASession>;
91
+ /** One discovered repository is all-or-nothing capture authority. A provider
92
+ * transport failure must never be represented as an authoritative empty diff. */
93
+ export declare function readCaptureRepository(svc: Pick<SandboxChannelAService, "gitStatus" | "gitDiff">, root: string): Promise<CaptureRepositoryReadResult>;
94
+ /**
95
+ * Turn-end entrypoint. Gates on the flag + configured object storage, races the
96
+ * whole capture against a 120s cap, and swallows every failure ("turn outcome
97
+ * unaffected"). Returns void — the caller awaits it (it self-caps) and moves on
98
+ * to release() regardless.
99
+ */
100
+ export declare function captureWorkspaceRevision(input: CaptureWorkspaceRevisionInput): Promise<void>;
101
+ /** Join a repo-root-relative path onto its workspace-relative repo root. */
102
+ export declare function joinRepoPath(repoRoot: string, repoRelPath: string): string;
103
+ /** Content-addressed after-image blob key (shared across revisions → GC input). */
104
+ export declare function blobKey(workspaceId: string, sessionId: string, sha256Hex: string): string;
105
+ export {};
@@ -0,0 +1,312 @@
1
+ import type { ActivityDependencies } from "./activities/types";
2
+ export type { ActivityDependencies, DispatchScheduledTaskRunInput, DispatchScheduledTaskRunResult, ExpireSessionHumanInputInput, ExpireSessionHumanInputResult, IndexDocumentInput, MaybeContinueGoalInput, MaybeContinueGoalResult, CodexCapacityWaitRef, GetCodexCapacityWaitInput, ReconcileCodexCapacityWaitInput, ReconcileCodexCapacityWaitResult, RecoverDispatchInput, RecoverDispatchResult, RecoverEscapedMcpTimeoutInput, RecoverEscapedMcpTimeoutResult, PersistSessionAttemptQuiescenceInput, ReconcileSessionAttemptQuiescenceInput, ReconcileSessionAttemptQuiescenceResult, RunAgentTurnInput, RunAgentTurnResult, SessionAttemptQuiescenceProof, } from "./activities/types";
3
+ export declare function createControlActivities(dependencies?: ActivityDependencies): {
4
+ getCodexCapacityWait: (input: import("./activities").GetCodexCapacityWaitInput) => Promise<{
5
+ waiterId: string;
6
+ generation: number;
7
+ nextCheckAt: string;
8
+ wakeRevision: number;
9
+ } | null>;
10
+ reconcileCodexCapacityWait: (input: import("./activities").ReconcileCodexCapacityWaitInput) => Promise<import("./activities").ReconcileCodexCapacityWaitResult>;
11
+ enqueueGoalRetryWake: (input: import("./activities").MaybeContinueGoalInput) => Promise<void>;
12
+ maybeContinueGoal: (input: import("./activities").MaybeContinueGoalInput) => Promise<import("./activities").MaybeContinueGoalResult>;
13
+ indexDocument: (input: import("./activities").IndexDocumentInput) => Promise<{
14
+ id: string;
15
+ workspaceId: string;
16
+ baseId: string;
17
+ fileId: string;
18
+ status: "failed" | "indexing" | "queued" | "ready";
19
+ title: string;
20
+ parser: string;
21
+ chunkCount: number;
22
+ error: string | null;
23
+ sourceKind: "chat" | "document" | "email" | "manual_upload" | "meeting_transcript" | "other" | "repository" | "web";
24
+ sourceUri: string | null;
25
+ sourceExternalId: string | null;
26
+ sourceTitle: string | null;
27
+ sourceAuthor: string | null;
28
+ sourceCreatedAt: string | null;
29
+ sourceUpdatedAt: string | null;
30
+ sourceVersion: string | null;
31
+ aclTags: string[];
32
+ visibility: "private" | "workspace";
33
+ createdBy: string | null;
34
+ agentAccess: boolean;
35
+ summary: string | null;
36
+ topics: string[];
37
+ curationStatus: "auto_filed" | "failed" | "none" | "pending" | "suggested";
38
+ curation: {
39
+ suggestedBaseId: string | null;
40
+ suggestedBaseName: string | null;
41
+ confidence: number;
42
+ reason: string | null;
43
+ originalTitle: string | null;
44
+ model: string | null;
45
+ } | null;
46
+ createdAt: string;
47
+ updatedAt: string;
48
+ }>;
49
+ reapExpiredFileUploads: () => Promise<import("./activities/file-upload-reaper").ReapExpiredFileUploadsResult>;
50
+ reapSandboxLeases: () => Promise<import("./activities/sandbox-lease").ReapSandboxLeasesResult>;
51
+ dispatchScheduledTaskRun: (input: import("./activities").DispatchScheduledTaskRunInput) => Promise<import("./activities").DispatchScheduledTaskRunResult>;
52
+ failSessionAttempt: (input: import("./activities/types").FailSessionAttemptInput) => Promise<void>;
53
+ settleSessionInterruptions: (input: import("./activities/types").SettleSessionInterruptionsInput) => Promise<{
54
+ action: "paused" | "continue" | "stale";
55
+ }>;
56
+ persistSessionAttemptQuiescence: (input: import("./activities").PersistSessionAttemptQuiescenceInput) => Promise<void>;
57
+ reconcileSessionAttemptQuiescence: (input: import("./activities").ReconcileSessionAttemptQuiescenceInput) => Promise<import("./activities").ReconcileSessionAttemptQuiescenceResult>;
58
+ recoverDispatch: (input: import("./activities").RecoverDispatchInput) => Promise<import("./activities").RecoverDispatchResult>;
59
+ recoverEscapedMcpTimeout: (input: import("./activities").RecoverEscapedMcpTimeoutInput) => Promise<import("./activities").RecoverEscapedMcpTimeoutResult>;
60
+ peekSessionWork: (input: import("./activities/types").PeekSessionWorkInput) => Promise<import("@opengeni/db").SessionWorkPeek>;
61
+ expireSessionHumanInput: (input: import("./activities").ExpireSessionHumanInputInput) => Promise<import("./activities").ExpireSessionHumanInputResult>;
62
+ markSessionIdle: (input: import("./activities/types").MarkSessionIdleInput) => Promise<void>;
63
+ dispatchSessionWorkflowWakes(): Promise<import("./activities/workflow-wake").DispatchSessionWorkflowWakesResult>;
64
+ verifyRigChange: (input: {
65
+ workspaceId: string;
66
+ changeId: string;
67
+ }) => Promise<{
68
+ id: string;
69
+ rigId: string;
70
+ baseVersionId: string | null;
71
+ kind: "definition_edit" | "setup_append";
72
+ payload: Record<string, unknown>;
73
+ status: "failed" | "merged" | "proposed" | "rejected" | "verifying";
74
+ proposedBy: string | null;
75
+ verification: {
76
+ [x: string]: unknown;
77
+ startedAt?: string | undefined;
78
+ finishedAt?: string | undefined;
79
+ log?: string | undefined;
80
+ checkResults?: {
81
+ name: string;
82
+ command: string;
83
+ exitCode: number | null;
84
+ output?: string | undefined;
85
+ }[] | undefined;
86
+ } | null;
87
+ resultVersionId: string | null;
88
+ createdAt: string;
89
+ updatedAt: string;
90
+ }>;
91
+ verifyRigVersion: (input: {
92
+ workspaceId: string;
93
+ versionId: string;
94
+ }) => Promise<{
95
+ versionId: string;
96
+ passed: boolean;
97
+ checkResults: {
98
+ exitCode: number | null;
99
+ output: string;
100
+ name: string;
101
+ command: string;
102
+ }[];
103
+ }>;
104
+ };
105
+ export declare function createTurnActivities(dependencies?: ActivityDependencies): {
106
+ runAgentTurn: (input: import("./activities").RunAgentTurnInput) => Promise<import("./activities").RunAgentTurnResult>;
107
+ };
108
+ /** Direct activity harness for tests; production workers always choose one role. */
109
+ export declare function createActivityTestHarness(dependencies?: ActivityDependencies): {
110
+ getCodexCapacityWait: (input: import("./activities").GetCodexCapacityWaitInput) => Promise<{
111
+ waiterId: string;
112
+ generation: number;
113
+ nextCheckAt: string;
114
+ wakeRevision: number;
115
+ } | null>;
116
+ reconcileCodexCapacityWait: (input: import("./activities").ReconcileCodexCapacityWaitInput) => Promise<import("./activities").ReconcileCodexCapacityWaitResult>;
117
+ enqueueGoalRetryWake: (input: import("./activities").MaybeContinueGoalInput) => Promise<void>;
118
+ maybeContinueGoal: (input: import("./activities").MaybeContinueGoalInput) => Promise<import("./activities").MaybeContinueGoalResult>;
119
+ indexDocument: (input: import("./activities").IndexDocumentInput) => Promise<{
120
+ id: string;
121
+ workspaceId: string;
122
+ baseId: string;
123
+ fileId: string;
124
+ status: "failed" | "indexing" | "queued" | "ready";
125
+ title: string;
126
+ parser: string;
127
+ chunkCount: number;
128
+ error: string | null;
129
+ sourceKind: "chat" | "document" | "email" | "manual_upload" | "meeting_transcript" | "other" | "repository" | "web";
130
+ sourceUri: string | null;
131
+ sourceExternalId: string | null;
132
+ sourceTitle: string | null;
133
+ sourceAuthor: string | null;
134
+ sourceCreatedAt: string | null;
135
+ sourceUpdatedAt: string | null;
136
+ sourceVersion: string | null;
137
+ aclTags: string[];
138
+ visibility: "private" | "workspace";
139
+ createdBy: string | null;
140
+ agentAccess: boolean;
141
+ summary: string | null;
142
+ topics: string[];
143
+ curationStatus: "auto_filed" | "failed" | "none" | "pending" | "suggested";
144
+ curation: {
145
+ suggestedBaseId: string | null;
146
+ suggestedBaseName: string | null;
147
+ confidence: number;
148
+ reason: string | null;
149
+ originalTitle: string | null;
150
+ model: string | null;
151
+ } | null;
152
+ createdAt: string;
153
+ updatedAt: string;
154
+ }>;
155
+ reapExpiredFileUploads: () => Promise<import("./activities/file-upload-reaper").ReapExpiredFileUploadsResult>;
156
+ reapSandboxLeases: () => Promise<import("./activities/sandbox-lease").ReapSandboxLeasesResult>;
157
+ dispatchScheduledTaskRun: (input: import("./activities").DispatchScheduledTaskRunInput) => Promise<import("./activities").DispatchScheduledTaskRunResult>;
158
+ failSessionAttempt: (input: import("./activities/types").FailSessionAttemptInput) => Promise<void>;
159
+ settleSessionInterruptions: (input: import("./activities/types").SettleSessionInterruptionsInput) => Promise<{
160
+ action: "paused" | "continue" | "stale";
161
+ }>;
162
+ persistSessionAttemptQuiescence: (input: import("./activities").PersistSessionAttemptQuiescenceInput) => Promise<void>;
163
+ reconcileSessionAttemptQuiescence: (input: import("./activities").ReconcileSessionAttemptQuiescenceInput) => Promise<import("./activities").ReconcileSessionAttemptQuiescenceResult>;
164
+ recoverDispatch: (input: import("./activities").RecoverDispatchInput) => Promise<import("./activities").RecoverDispatchResult>;
165
+ recoverEscapedMcpTimeout: (input: import("./activities").RecoverEscapedMcpTimeoutInput) => Promise<import("./activities").RecoverEscapedMcpTimeoutResult>;
166
+ peekSessionWork: (input: import("./activities/types").PeekSessionWorkInput) => Promise<import("@opengeni/db").SessionWorkPeek>;
167
+ expireSessionHumanInput: (input: import("./activities").ExpireSessionHumanInputInput) => Promise<import("./activities").ExpireSessionHumanInputResult>;
168
+ markSessionIdle: (input: import("./activities/types").MarkSessionIdleInput) => Promise<void>;
169
+ dispatchSessionWorkflowWakes(): Promise<import("./activities/workflow-wake").DispatchSessionWorkflowWakesResult>;
170
+ verifyRigChange: (input: {
171
+ workspaceId: string;
172
+ changeId: string;
173
+ }) => Promise<{
174
+ id: string;
175
+ rigId: string;
176
+ baseVersionId: string | null;
177
+ kind: "definition_edit" | "setup_append";
178
+ payload: Record<string, unknown>;
179
+ status: "failed" | "merged" | "proposed" | "rejected" | "verifying";
180
+ proposedBy: string | null;
181
+ verification: {
182
+ [x: string]: unknown;
183
+ startedAt?: string | undefined;
184
+ finishedAt?: string | undefined;
185
+ log?: string | undefined;
186
+ checkResults?: {
187
+ name: string;
188
+ command: string;
189
+ exitCode: number | null;
190
+ output?: string | undefined;
191
+ }[] | undefined;
192
+ } | null;
193
+ resultVersionId: string | null;
194
+ createdAt: string;
195
+ updatedAt: string;
196
+ }>;
197
+ verifyRigVersion: (input: {
198
+ workspaceId: string;
199
+ versionId: string;
200
+ }) => Promise<{
201
+ versionId: string;
202
+ passed: boolean;
203
+ checkResults: {
204
+ exitCode: number | null;
205
+ output: string;
206
+ name: string;
207
+ command: string;
208
+ }[];
209
+ }>;
210
+ runAgentTurn: (input: import("./activities").RunAgentTurnInput) => Promise<import("./activities").RunAgentTurnResult>;
211
+ };
212
+ export declare const runAgentTurn: (input: import("./activities").RunAgentTurnInput) => Promise<import("./activities").RunAgentTurnResult>;
213
+ export declare const indexDocument: (input: import("./activities").IndexDocumentInput) => Promise<{
214
+ id: string;
215
+ workspaceId: string;
216
+ baseId: string;
217
+ fileId: string;
218
+ status: "failed" | "indexing" | "queued" | "ready";
219
+ title: string;
220
+ parser: string;
221
+ chunkCount: number;
222
+ error: string | null;
223
+ sourceKind: "chat" | "document" | "email" | "manual_upload" | "meeting_transcript" | "other" | "repository" | "web";
224
+ sourceUri: string | null;
225
+ sourceExternalId: string | null;
226
+ sourceTitle: string | null;
227
+ sourceAuthor: string | null;
228
+ sourceCreatedAt: string | null;
229
+ sourceUpdatedAt: string | null;
230
+ sourceVersion: string | null;
231
+ aclTags: string[];
232
+ visibility: "private" | "workspace";
233
+ createdBy: string | null;
234
+ agentAccess: boolean;
235
+ summary: string | null;
236
+ topics: string[];
237
+ curationStatus: "auto_filed" | "failed" | "none" | "pending" | "suggested";
238
+ curation: {
239
+ suggestedBaseId: string | null;
240
+ suggestedBaseName: string | null;
241
+ confidence: number;
242
+ reason: string | null;
243
+ originalTitle: string | null;
244
+ model: string | null;
245
+ } | null;
246
+ createdAt: string;
247
+ updatedAt: string;
248
+ }>;
249
+ export declare const failSessionAttempt: (input: import("./activities/types").FailSessionAttemptInput) => Promise<void>;
250
+ export declare const settleSessionInterruptions: (input: import("./activities/types").SettleSessionInterruptionsInput) => Promise<{
251
+ action: "paused" | "continue" | "stale";
252
+ }>;
253
+ export declare const persistSessionAttemptQuiescence: (input: import("./activities").PersistSessionAttemptQuiescenceInput) => Promise<void>;
254
+ export declare const reconcileSessionAttemptQuiescence: (input: import("./activities").ReconcileSessionAttemptQuiescenceInput) => Promise<import("./activities").ReconcileSessionAttemptQuiescenceResult>;
255
+ export declare const recoverDispatch: (input: import("./activities").RecoverDispatchInput) => Promise<import("./activities").RecoverDispatchResult>;
256
+ export declare const recoverEscapedMcpTimeout: (input: import("./activities").RecoverEscapedMcpTimeoutInput) => Promise<import("./activities").RecoverEscapedMcpTimeoutResult>;
257
+ export declare const peekSessionWork: (input: import("./activities/types").PeekSessionWorkInput) => Promise<import("@opengeni/db").SessionWorkPeek>;
258
+ export declare const expireSessionHumanInput: (input: import("./activities").ExpireSessionHumanInputInput) => Promise<import("./activities").ExpireSessionHumanInputResult>;
259
+ export declare const markSessionIdle: (input: import("./activities/types").MarkSessionIdleInput) => Promise<void>;
260
+ export declare const dispatchScheduledTaskRun: (input: import("./activities").DispatchScheduledTaskRunInput) => Promise<import("./activities").DispatchScheduledTaskRunResult>;
261
+ export declare const enqueueGoalRetryWake: (input: import("./activities").MaybeContinueGoalInput) => Promise<void>;
262
+ export declare const maybeContinueGoal: (input: import("./activities").MaybeContinueGoalInput) => Promise<import("./activities").MaybeContinueGoalResult>;
263
+ export declare const getCodexCapacityWait: (input: import("./activities").GetCodexCapacityWaitInput) => Promise<{
264
+ waiterId: string;
265
+ generation: number;
266
+ nextCheckAt: string;
267
+ wakeRevision: number;
268
+ } | null>;
269
+ export declare const reconcileCodexCapacityWait: (input: import("./activities").ReconcileCodexCapacityWaitInput) => Promise<import("./activities").ReconcileCodexCapacityWaitResult>;
270
+ export declare const reapSandboxLeases: () => Promise<import("./activities/sandbox-lease").ReapSandboxLeasesResult>;
271
+ export declare const reapExpiredFileUploads: () => Promise<import("./activities/file-upload-reaper").ReapExpiredFileUploadsResult>;
272
+ export declare const dispatchSessionWorkflowWakes: () => Promise<import("./activities/workflow-wake").DispatchSessionWorkflowWakesResult>;
273
+ export declare const verifyRigChange: (input: {
274
+ workspaceId: string;
275
+ changeId: string;
276
+ }) => Promise<{
277
+ id: string;
278
+ rigId: string;
279
+ baseVersionId: string | null;
280
+ kind: "definition_edit" | "setup_append";
281
+ payload: Record<string, unknown>;
282
+ status: "failed" | "merged" | "proposed" | "rejected" | "verifying";
283
+ proposedBy: string | null;
284
+ verification: {
285
+ [x: string]: unknown;
286
+ startedAt?: string | undefined;
287
+ finishedAt?: string | undefined;
288
+ log?: string | undefined;
289
+ checkResults?: {
290
+ name: string;
291
+ command: string;
292
+ exitCode: number | null;
293
+ output?: string | undefined;
294
+ }[] | undefined;
295
+ } | null;
296
+ resultVersionId: string | null;
297
+ createdAt: string;
298
+ updatedAt: string;
299
+ }>;
300
+ export declare const verifyRigVersion: (input: {
301
+ workspaceId: string;
302
+ versionId: string;
303
+ }) => Promise<{
304
+ versionId: string;
305
+ passed: boolean;
306
+ checkResults: {
307
+ exitCode: number | null;
308
+ output: string;
309
+ name: string;
310
+ command: string;
311
+ }[];
312
+ }>;
@@ -0,0 +1,19 @@
1
+ import type { Settings } from "@opengeni/config";
2
+ import type { WorkerOptions } from "@temporalio/worker";
3
+ export type TurnWorkerConcurrencySettings = Pick<Settings, "turnWorkerConcurrencyMode" | "turnWorkerMaxConcurrentTurns" | "turnWorkerTargetCpuUsage" | "turnWorkerTargetMemoryUsage">;
4
+ export type TurnWorkerConcurrencyOptions = Pick<WorkerOptions, "maxConcurrentActivityTaskExecutions" | "tuner">;
5
+ /**
6
+ * Ordinary multi-worker deployments keep a fixed per-process ceiling so HPA or
7
+ * an operator owns horizontal capacity. The single-machine profile selects the
8
+ * resource tuner instead: Temporal admits activity slots while whole-system CPU
9
+ * and memory remain below the configured targets, then stops polling more work.
10
+ */
11
+ export declare function turnWorkerConcurrencyOptions(settings: TurnWorkerConcurrencySettings): TurnWorkerConcurrencyOptions;
12
+ export declare function turnWorkerConcurrencyLogFields(settings: TurnWorkerConcurrencySettings): {
13
+ concurrencyMode: "fixed" | "resource-based";
14
+ maxConcurrentTurns: number;
15
+ targetCpuUsage: number | null;
16
+ targetMemoryUsage: number | null;
17
+ };
18
+ export declare const CONTROL_WORKER_MAX_CONCURRENT_ACTIVITIES = 32;
19
+ export declare const CONTROL_WORKER_MAX_CONCURRENT_WORKFLOW_TASKS = 40;
@@ -0,0 +1,66 @@
1
+ import type { HostEventSink, HostUsageSink } from "@opengeni/contracts";
2
+ import { type Database, type HostExportConsumerStatus, type HostExportKind } from "@opengeni/db";
3
+ import type { Observability } from "@opengeni/observability";
4
+ export type HostExportDrainResult = {
5
+ kind: HostExportKind;
6
+ outcome: "not_configured" | "idle";
7
+ } | {
8
+ kind: HostExportKind;
9
+ outcome: "blocked";
10
+ failures: number;
11
+ } | {
12
+ kind: HostExportKind;
13
+ outcome: "delivered";
14
+ count: number;
15
+ throughCursor: string;
16
+ } | {
17
+ kind: HostExportKind;
18
+ outcome: "failed";
19
+ failures: number;
20
+ blocked: boolean;
21
+ };
22
+ export type HostExportPumpOptions = {
23
+ /** A handle authenticated as the separately provisioned host-export role. */
24
+ db: Database;
25
+ eventSink?: HostEventSink;
26
+ usageSink?: HostUsageSink;
27
+ observability?: Observability;
28
+ instanceId?: string;
29
+ pollIntervalMs?: number;
30
+ leaseSeconds?: number;
31
+ batchLimit?: number;
32
+ batchMaxBytes?: number;
33
+ maxFailures?: number;
34
+ /** Maximum catch-up batches per poll tick; bounds one iteration's work. */
35
+ maxBatchesPerPoll?: number;
36
+ /** Acked rows younger than this remain available for replay. */
37
+ pruneGraceSeconds?: number;
38
+ /** Maximum rows pruned after one successful acknowledgement. */
39
+ pruneLimit?: number;
40
+ };
41
+ export type HostExportPump = {
42
+ /** Register configured consumers and start the non-overlapping poll loop. */
43
+ start: () => Promise<void>;
44
+ /** Stop polling and wait for the currently executing sink call, if any. */
45
+ stop: () => Promise<void>;
46
+ /** Execute at most one bounded batch for each configured sink. */
47
+ drainOnce: () => Promise<HostExportDrainResult[]>;
48
+ /**
49
+ * Disable this named consumer while retaining its replay checkpoint. If it is
50
+ * the last enabled consumer of the kind, capture stops and that interval is
51
+ * intentionally unrecoverable. Normal process shutdown must not call this.
52
+ */
53
+ disable: (kind: HostExportKind) => Promise<void>;
54
+ /** Permanently remove a stopped consumer and release its retention floor. */
55
+ retire: (kind: HostExportKind) => Promise<void>;
56
+ status: (kind: HostExportKind) => Promise<HostExportConsumerStatus | null>;
57
+ };
58
+ /**
59
+ * Build the durable delivery loop used by embedded hosts.
60
+ *
61
+ * The source transaction writes the outbox; this pump only leases, delivers,
62
+ * and checkpoints it. Delivery is intentionally at least once: a process death
63
+ * after sink success but before acknowledgement repeats the same idempotency
64
+ * keys. Sink implementations must therefore deduplicate those keys.
65
+ */
66
+ export declare function createHostExportPump(options: HostExportPumpOptions): HostExportPump;
@@ -1,70 +1,9 @@
1
- import { HostEventSink, HostUsageSink } from '@opengeni/contracts';
2
- export { HostEventExport, HostEventExportBatch, HostEventSink, HostUsageExport, HostUsageExportBatch, HostUsageSink } from '@opengeni/contracts';
3
- import { HostExportKind, HostExportConsumerStatus, Database } from '@opengeni/db';
4
- import { Observability } from '@opengeni/observability';
5
-
6
- type HostExportDrainResult = {
7
- kind: HostExportKind;
8
- outcome: "not_configured" | "idle";
9
- } | {
10
- kind: HostExportKind;
11
- outcome: "blocked";
12
- failures: number;
13
- } | {
14
- kind: HostExportKind;
15
- outcome: "delivered";
16
- count: number;
17
- throughCursor: string;
18
- } | {
19
- kind: HostExportKind;
20
- outcome: "failed";
21
- failures: number;
22
- blocked: boolean;
23
- };
24
- type HostExportPumpOptions = {
25
- /** A handle authenticated as the separately provisioned host-export role. */
26
- db: Database;
27
- eventSink?: HostEventSink;
28
- usageSink?: HostUsageSink;
29
- observability?: Observability;
30
- instanceId?: string;
31
- pollIntervalMs?: number;
32
- leaseSeconds?: number;
33
- batchLimit?: number;
34
- batchMaxBytes?: number;
35
- maxFailures?: number;
36
- /** Maximum catch-up batches per poll tick; bounds one iteration's work. */
37
- maxBatchesPerPoll?: number;
38
- /** Acked rows younger than this remain available for replay. */
39
- pruneGraceSeconds?: number;
40
- /** Maximum rows pruned after one successful acknowledgement. */
41
- pruneLimit?: number;
42
- };
43
- type HostExportPump = {
44
- /** Register configured consumers and start the non-overlapping poll loop. */
45
- start: () => Promise<void>;
46
- /** Stop polling and wait for the currently executing sink call, if any. */
47
- stop: () => Promise<void>;
48
- /** Execute at most one bounded batch for each configured sink. */
49
- drainOnce: () => Promise<HostExportDrainResult[]>;
50
- /**
51
- * Disable this named consumer while retaining its replay checkpoint. If it is
52
- * the last enabled consumer of the kind, capture stops and that interval is
53
- * intentionally unrecoverable. Normal process shutdown must not call this.
54
- */
55
- disable: (kind: HostExportKind) => Promise<void>;
56
- /** Permanently remove a stopped consumer and release its retention floor. */
57
- retire: (kind: HostExportKind) => Promise<void>;
58
- status: (kind: HostExportKind) => Promise<HostExportConsumerStatus | null>;
59
- };
60
1
  /**
61
- * Build the durable delivery loop used by embedded hosts.
2
+ * Lightweight host-export entrypoint for embedded API processes.
62
3
  *
63
- * The source transaction writes the outbox; this pump only leases, delivers,
64
- * and checkpoints it. Delivery is intentionally at least once: a process death
65
- * after sink success but before acknowledgement repeats the same idempotency
66
- * keys. Sink implementations must therefore deduplicate those keys.
4
+ * Importing the worker package root initializes Temporal's native worker
5
+ * dependency graph. Host applications that only project durable OpenGeni
6
+ * events or usage must not need that native runtime (or its libc contract).
67
7
  */
68
- declare function createHostExportPump(options: HostExportPumpOptions): HostExportPump;
69
-
70
- export { type HostExportDrainResult, type HostExportPump, type HostExportPumpOptions, createHostExportPump };
8
+ export { createHostExportPump, type HostExportDrainResult, type HostExportPump, type HostExportPumpOptions, } from "./host-export-pump";
9
+ export type { HostEventExport, HostEventExportBatch, HostEventSink, HostUsageExport, HostUsageExportBatch, HostUsageSink, } from "@opengeni/contracts";
package/dist/http.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ import type { Settings } from "@opengeni/config";
2
+ import { type Database, type RuntimeDatabasePostureOptions } from "@opengeni/db";
3
+ import type { EventBus } from "@opengeni/events";
4
+ import type { Observability } from "@opengeni/observability";
5
+ export type ReadinessCheckName = "db" | "nats" | "temporal";
6
+ export type ReadinessChecks = Record<ReadinessCheckName, () => Promise<void> | void>;
7
+ export type ReadinessResult = {
8
+ ok: boolean;
9
+ state?: WorkerLifecycleState;
10
+ checks: Record<ReadinessCheckName, {
11
+ ok: boolean;
12
+ error?: string;
13
+ }>;
14
+ };
15
+ export type WorkerLifecycleState = "starting" | "ready" | "draining" | "stopped" | "failed";
16
+ export type WorkerHttpLifecycle = {
17
+ role: "control" | "turn";
18
+ state: () => WorkerLifecycleState;
19
+ };
20
+ export type WorkerHttpServerInput = {
21
+ settings: Settings;
22
+ observability: Observability;
23
+ checks: ReadinessChecks;
24
+ timeoutMs?: number;
25
+ lifecycle?: WorkerHttpLifecycle;
26
+ };
27
+ export declare function createWorkerHttpHandler(input: WorkerHttpServerInput): (request: Request) => Promise<Response>;
28
+ export declare function startWorkerHttpServer(input: WorkerHttpServerInput): ReturnType<typeof Bun.serve>;
29
+ export declare function runReadinessChecks(checks: ReadinessChecks, timeoutMs?: number): Promise<ReadinessResult>;
30
+ export declare function dbReadyCheck(db: Database, posture?: RuntimeDatabasePostureOptions): () => Promise<void>;
31
+ export declare function natsReadyCheck(bus: EventBus): () => void;
32
+ export declare function temporalReadyCheck(connection: Pick<import("@temporalio/worker").NativeConnection, "workflowService" | "withDeadline">): () => Promise<void>;