@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,8 +1,8 @@
|
|
|
1
|
-
import type { ProviderCommandPersistence } from "@opengeni/runtime";
|
|
1
|
+
import type { ProviderCommandPersistence, ProviderCommandSession } from "@opengeni/runtime";
|
|
2
2
|
import { type OpStatus } from "@opengeni/agent-proto";
|
|
3
3
|
import { listLiveModalSandboxLeaseAttributions, readLease, type ReapDrainable, type RetainedProcessProviderProof, type SandboxRetainedProcess, type LeaseSnapshot } from "@opengeni/db";
|
|
4
4
|
import { type ConnectedMachineBackgroundCommandClaim, type ConnectedMachineBackgroundCommandProof } from "@opengeni/db/session-background-commands";
|
|
5
|
-
import { type VerifiedHostWorkspaceArchive, createSandboxClientForBackend, inspectModalSandboxLifecycle, resolveModalCheckpointProviderBindingForSession, terminateModalSandboxById, type ModalOrphanSweepTermination, type ModalCheckpointProviderBinding, type ProviderWorkspaceCapturePolicy, type WorkspaceArchiveDescriptor, type ControlRpc } from "@opengeni/runtime/sandbox";
|
|
5
|
+
import { type VerifiedHostWorkspaceArchive, createSandboxClientForBackend, inspectModalSandboxLifecycle, OpStreamExecClient, findModalProviderCreateReceipt, resolveModalCheckpointProviderBindingForSession, terminateModalSandboxById, type ModalOrphanSweepTermination, type ModalCheckpointProviderBinding, type ProviderWorkspaceCapturePolicy, type WorkspaceArchiveDescriptor, type ControlRpc } from "@opengeni/runtime/sandbox";
|
|
6
6
|
import { type SandboxDrainActivityInput, type SandboxLeaseSweepMaintenanceInput } from "../sandbox-reaper-contract.js";
|
|
7
7
|
import type { ControlActivityServices as ActivityServices } from "./types.js";
|
|
8
8
|
import { type RetainedProcessReconciliationOutcome } from "../observability-metrics.js";
|
|
@@ -20,8 +20,7 @@ export type ReapSandboxLeasesResult = {
|
|
|
20
20
|
skipped: number;
|
|
21
21
|
/** Warm viewer-only leases that accrued warm-seconds this tick (P2.1). */
|
|
22
22
|
metered: number;
|
|
23
|
-
/**
|
|
24
|
-
* (0 balance / over the warm cap) — turn-held boxes are never drained (P2.1). */
|
|
23
|
+
/** Holderless boxes accelerated to draining by the optional warm cap. */
|
|
25
24
|
forceDrained: number;
|
|
26
25
|
/** Provider-side Modal orphan sandboxes terminated by the defensive sweep. */
|
|
27
26
|
modalOrphansTerminated: number;
|
|
@@ -60,7 +59,7 @@ export type DrainCaptureDisposition = "capture_required" | "archive_published";
|
|
|
60
59
|
* Test seams may return the legacy boolean shorthand. Production returns the
|
|
61
60
|
* typed outcome so the cold commit can distinguish a clean stop from definitive
|
|
62
61
|
* provider disappearance before capture. */
|
|
63
|
-
export type TerminateBoxFn = (settings: ActivityServices["settings"], lease: NonNullable<Awaited<ReturnType<typeof readLease>>>, observability: ActivityServices["observability"], persistArchive: PersistArchiveFn, providerCaptureRequestId?: string, captureDisposition?: DrainCaptureDisposition, capturePolicy?: ProviderWorkspaceCapturePolicy | null, diskBackedArchives?: boolean, releaseFailedCapture?: () => Promise<void>) => Promise<boolean | ProviderTerminationOutcome>;
|
|
62
|
+
export type TerminateBoxFn = (settings: ActivityServices["settings"], lease: NonNullable<Awaited<ReturnType<typeof readLease>>>, observability: ActivityServices["observability"], persistArchive: PersistArchiveFn, providerCaptureRequestId?: string, captureDisposition?: DrainCaptureDisposition, capturePolicy?: ProviderWorkspaceCapturePolicy | null, diskBackedArchives?: boolean, releaseFailedCapture?: () => Promise<void>, workspaceId?: string, beforeProviderStop?: () => Promise<void>) => Promise<boolean | ProviderTerminationOutcome>;
|
|
64
63
|
export type SweepModalOrphansFn = (settings: ActivityServices["settings"], db: ActivityServices["db"], observability: ActivityServices["observability"]) => Promise<number>;
|
|
65
64
|
export type InspectOpenSandboxKubernetesInventoryFn = (input: {
|
|
66
65
|
namespace: string;
|
|
@@ -72,6 +71,8 @@ export type SandboxLeaseActivityOptions = {
|
|
|
72
71
|
/** Override the provider-side Modal orphan sweep (tests spy this; defaults to
|
|
73
72
|
* Modal list+tag comparison when Modal is configured). */
|
|
74
73
|
sweepModalOrphans?: SweepModalOrphansFn;
|
|
74
|
+
/** Only provider discovery is injected; durable recovery remains real. */
|
|
75
|
+
findModalProviderCreateReceipt?: typeof findModalProviderCreateReceipt;
|
|
75
76
|
/** Override the read-only bounded OpenSandbox Kubernetes projection. */
|
|
76
77
|
inspectOpenSandboxKubernetesInventory?: InspectOpenSandboxKubernetesInventoryFn;
|
|
77
78
|
/** Override only the read-only provider process probe. The canonical DB
|
|
@@ -94,13 +95,29 @@ export type RetainedProcessProbeResult = {
|
|
|
94
95
|
} | {
|
|
95
96
|
status: "deferred";
|
|
96
97
|
reason: "identity_mismatch" | "resume_state_missing" | "backend_unsupported" | "provider_running" | "provider_unknown" | "provider_timeout" | "provider_error" | "provider_binding_missing" | "provider_binding_mismatch" | "process_observation_unavailable";
|
|
98
|
+
/** A running command whose last read still returned a large backlog. */
|
|
99
|
+
outputBacklog?: boolean;
|
|
100
|
+
};
|
|
101
|
+
export type RetainedProcessProbeFn = (settings: ActivityServices["settings"], lease: LeaseSnapshot, process: SandboxRetainedProcess, mode?: "observe" | "cancel", captureOutput?: (result: unknown, chunkId: string, stream?: "stdout" | "stderr", streamFidelity?: "separate" | "merged") => Promise<void>, providerPersistence?: ProviderCommandPersistence, drainBudget?: RetainedProcessDrainBudget) => Promise<RetainedProcessProbeResult>;
|
|
102
|
+
/** Shared wall-clock bound on output draining within one reconciliation sweep. */
|
|
103
|
+
export type RetainedProcessDrainBudget = {
|
|
104
|
+
until: number;
|
|
97
105
|
};
|
|
98
|
-
export type RetainedProcessProbeFn = (settings: ActivityServices["settings"], lease: LeaseSnapshot, process: SandboxRetainedProcess, mode?: "observe" | "cancel", captureOutput?: (result: unknown, chunkId: string, stream?: "stdout" | "stderr", streamFidelity?: "separate" | "merged") => Promise<void>, providerPersistence?: ProviderCommandPersistence) => Promise<RetainedProcessProbeResult>;
|
|
99
106
|
export type HistoricalModalSandboxLifecycleProbeFn = typeof inspectModalSandboxLifecycle;
|
|
100
107
|
export type DrainableProviderProbeFn = (settings: ActivityServices["settings"], lease: LeaseSnapshot) => Promise<"ready" | "missing">;
|
|
101
108
|
export declare const RETAINED_PROCESS_RECONCILIATION_LIMIT = 20;
|
|
102
109
|
export declare const RETAINED_PROCESS_RECONCILIATION_CLAIM_TTL_MS: number;
|
|
103
110
|
export declare const RETAINED_PROCESS_PROVIDER_PROBE_TIMEOUT_MS = 5000;
|
|
111
|
+
/** Bounds on reading a command's output backlog: per claim, and across one
|
|
112
|
+
* reconciliation sweep so the reaper activity stays well inside its timeout.
|
|
113
|
+
* Each read returns up to one provider page per stream. */
|
|
114
|
+
export declare const RETAINED_PROCESS_OUTPUT_DRAIN_MAX_READS = 8;
|
|
115
|
+
export declare const RETAINED_PROCESS_OUTPUT_DRAIN_BUDGET_MS = 10000;
|
|
116
|
+
export declare const RETAINED_PROCESS_OUTPUT_DRAIN_SWEEP_BUDGET_MS = 60000;
|
|
117
|
+
/** A live process whose read returned at least this much output left a backlog
|
|
118
|
+
* behind it. A server or watcher that only trickles output stays on ordinary
|
|
119
|
+
* backoff; a process the provider reports exited is always read to EOF. */
|
|
120
|
+
export declare const RETAINED_PROCESS_OUTPUT_BACKLOG_BYTES: number;
|
|
104
121
|
export declare const RETAINED_PROCESS_BINDING_QUARANTINE_AFTER_ATTEMPTS = 5;
|
|
105
122
|
export declare const RETAINED_PROCESS_BINDING_QUARANTINE_RETRY_MS: number;
|
|
106
123
|
export declare const CONNECTED_COMMAND_RECONCILIATION_LIMIT = 20;
|
|
@@ -154,22 +171,43 @@ export declare function createSandboxLeaseActivities(services: () => Promise<Act
|
|
|
154
171
|
* adoption. A successor enrollment connection is intentionally irrelevant: no
|
|
155
172
|
* query or cancellation is ever rebound to it. */
|
|
156
173
|
export declare function reconcileConnectedMachineBackgroundCommands(db: ActivityServices["db"], settings: ActivityServices["settings"], observability: ActivityServices["observability"], bus: ActivityServices["bus"], controlRpcOverride?: ControlRpc): Promise<void>;
|
|
174
|
+
export declare function replayConnectedCommandOutput(client: Pick<OpStreamExecClient, "readExisting">, opId: string, terminalKnown: boolean, capture: Parameters<OpStreamExecClient["readExisting"]>[2]): Promise<Awaited<ReturnType<OpStreamExecClient["readExisting"]>>>;
|
|
175
|
+
/** Drain the durable terminal-output obligation independently of the launching
|
|
176
|
+
* attempt or model completion notice. Existing terminal rows receive no inferred
|
|
177
|
+
* receipt: they must replay and capture all retained bytes before any final ACK. */
|
|
178
|
+
export declare function reconcileConnectedCommandOutputReleases(db: ActivityServices["db"], settings: ActivityServices["settings"], observability: ActivityServices["observability"], bus: ActivityServices["bus"], controlRpcOverride?: ControlRpc): Promise<void>;
|
|
157
179
|
export declare function probeConnectedMachineBackgroundCommand(claim: ConnectedMachineBackgroundCommandClaim, controlRpc: ControlRpc, controlTimeoutMs: number, observedAt?: Date): Promise<ConnectedMachineBackgroundCommandProof | null>;
|
|
158
180
|
export declare function connectedCommandProofFromStatus(status: OpStatus, observedAt: Date): ConnectedMachineBackgroundCommandProof | null;
|
|
159
181
|
type RetainedProcessDeferralOutcome = Extract<RetainedProcessProbeResult, {
|
|
160
182
|
status: "deferred";
|
|
161
183
|
}>["reason"] | "settlement_failed";
|
|
162
|
-
export declare function retainedProcessReconciliationDeferral(settings: Pick<ActivityServices["settings"], "sandboxLeaseReaperPeriodMs">, process: Pick<SandboxRetainedProcess, "reconcileAttempts">, outcome: RetainedProcessDeferralOutcome): {
|
|
184
|
+
export declare function retainedProcessReconciliationDeferral(settings: Pick<ActivityServices["settings"], "sandboxLeaseReaperPeriodMs">, process: Pick<SandboxRetainedProcess, "reconcileAttempts">, outcome: RetainedProcessDeferralOutcome, outputBacklog?: boolean): {
|
|
163
185
|
durableOutcome: string;
|
|
164
186
|
metricOutcome: RetainedProcessReconciliationOutcome;
|
|
165
187
|
retryAfterMs: number;
|
|
166
188
|
quarantined: boolean;
|
|
167
189
|
};
|
|
190
|
+
type RetainedProcessProbeSession = ProviderCommandSession & {
|
|
191
|
+
acknowledgeCommandOutput?: (result: string) => Promise<void>;
|
|
192
|
+
writeStdin?: (args: {
|
|
193
|
+
sessionId: number;
|
|
194
|
+
chars: string;
|
|
195
|
+
yieldTimeMs: number;
|
|
196
|
+
maxOutputTokens: number;
|
|
197
|
+
}) => Promise<unknown>;
|
|
198
|
+
};
|
|
199
|
+
/** A command's exit is reported only after both output streams reach EOF, so a
|
|
200
|
+
* finished command with a large backlog looks running until it is read. While a
|
|
201
|
+
* backlog remains, keep reading within the per-claim and per-sweep budgets, so
|
|
202
|
+
* it settles in this claim instead of one page per backoff step. Every page,
|
|
203
|
+
* including `first`, is captured here. */
|
|
204
|
+
export declare function drainRetainedCommandBacklog(session: RetainedProcessProbeSession, providerSessionId: number, first: unknown, capturePage: (value: unknown) => Promise<void>, budget?: RetainedProcessDrainBudget): Promise<RetainedProcessProbeResult>;
|
|
168
205
|
export declare function captureRetainedProbeOutput(processId: string, result: unknown, capture: (result: unknown, chunkId: string) => Promise<void>): Promise<void>;
|
|
169
|
-
export declare function probeRetainedProcessAtProvider(settings: ActivityServices["settings"], lease: LeaseSnapshot, process: SandboxRetainedProcess, mode?: "observe" | "cancel", captureOutput?: (result: unknown, chunkId: string, stream?: "stdout" | "stderr", streamFidelity?: "separate" | "merged") => Promise<void>, providerPersistence?: ProviderCommandPersistence): Promise<RetainedProcessProbeResult>;
|
|
206
|
+
export declare function probeRetainedProcessAtProvider(settings: ActivityServices["settings"], lease: LeaseSnapshot, process: SandboxRetainedProcess, mode?: "observe" | "cancel", captureOutput?: (result: unknown, chunkId: string, stream?: "stdout" | "stderr", streamFidelity?: "separate" | "merged") => Promise<void>, providerPersistence?: ProviderCommandPersistence, drainBudget?: RetainedProcessDrainBudget): Promise<RetainedProcessProbeResult>;
|
|
170
207
|
/** Classify only exact SDK control banners. Arbitrary output, malformed text,
|
|
171
208
|
* and a running marker are observations to retry; none is physical exit proof. */
|
|
172
209
|
export declare function classifyRetainedProcessPollResult(result: unknown, providerSessionId: number, source?: object): RetainedProcessProbeResult;
|
|
210
|
+
export declare function reconcileModalProviderCreates(db: ActivityServices["db"], settings: ActivityServices["settings"], observability: ActivityServices["observability"], discover?: typeof findModalProviderCreateReceipt): Promise<void>;
|
|
173
211
|
export declare function modalOrphanTerminationStillEligible(latest: Awaited<ReturnType<typeof listLiveModalSandboxLeaseAttributions>>, candidate: ModalOrphanSweepTermination): boolean;
|
|
174
212
|
export type SandboxDrainReason = "idle" | "provider_deadline" | "operator" | "teardown_claim" | "rotation_requested";
|
|
175
213
|
/** The bounded drain reason carried on `sandbox.box.terminated`: the lease's
|
|
@@ -207,4 +245,4 @@ export declare function sandboxDrainReason(lease: Pick<LeaseSnapshot, "rotationR
|
|
|
207
245
|
* draining until its adapter can prove termination. A truly instance-less or
|
|
208
246
|
* `none`-backed row is a no-op.
|
|
209
247
|
*/
|
|
210
|
-
export declare function terminateProviderBox(settings: ActivityServices["settings"], lease: NonNullable<Awaited<ReturnType<typeof readLease>>>, observability: ActivityServices["observability"], persistArchive: PersistArchiveFn, createClientForBackend?: CreateSandboxClientForBackendFn, terminateModalById?: typeof terminateModalSandboxById, providerCaptureRequestId?: string, captureDisposition?: DrainCaptureDisposition, claimedCapturePolicy?: ProviderWorkspaceCapturePolicy | null, diskBackedArchives?: boolean, releaseFailedCapture?: () => Promise<void>): Promise<ProviderTerminationOutcome>;
|
|
248
|
+
export declare function terminateProviderBox(settings: ActivityServices["settings"], lease: NonNullable<Awaited<ReturnType<typeof readLease>>>, observability: ActivityServices["observability"], persistArchive: PersistArchiveFn, createClientForBackend?: CreateSandboxClientForBackendFn, terminateModalById?: typeof terminateModalSandboxById, providerCaptureRequestId?: string, captureDisposition?: DrainCaptureDisposition, claimedCapturePolicy?: ProviderWorkspaceCapturePolicy | null, diskBackedArchives?: boolean, releaseFailedCapture?: () => Promise<void>, workspaceId?: string, beforeProviderStop?: () => Promise<void>): Promise<ProviderTerminationOutcome>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TurnExecutionPolicyV1 } from "@opengeni/contracts";
|
|
1
2
|
import { updateSessionTitleWithEvent } from "@opengeni/db";
|
|
2
3
|
import type { ControlActivityServices, DispatchScheduledTaskRunInput, DispatchScheduledTaskRunResult } from "./types.js";
|
|
3
4
|
import type { Database } from "@opengeni/db";
|
|
@@ -9,43 +10,11 @@ type ScheduledTemporalActivityIdentity = {
|
|
|
9
10
|
};
|
|
10
11
|
activityId: string;
|
|
11
12
|
};
|
|
13
|
+
export declare function scheduledTaskRunExecutionPolicy(policy: TurnExecutionPolicyV1, input: DispatchScheduledTaskRunInput, creatorRestriction?: "developer_setup"): TurnExecutionPolicyV1;
|
|
14
|
+
/** Only a creator ceiling is standing; a manual caller ceiling is per-run. */
|
|
15
|
+
export declare function scheduledSessionExecutionPolicyMetadata(policy: unknown, creatorRestriction?: "developer_setup"): Record<string, unknown>;
|
|
12
16
|
export declare function scheduledTaskRunProducerKey(input: DispatchScheduledTaskRunInput, suppliedActivityIdentity?: ScheduledTemporalActivityIdentity): string;
|
|
13
17
|
export declare function scheduledTaskGeneratedSessionCreateIdempotencyKey(producerKey: string): string;
|
|
14
|
-
/**
|
|
15
|
-
* Display title for a session the scheduler generates for a task.
|
|
16
|
-
*
|
|
17
|
-
* A scheduled session's `initialMessage` is the task prompt, byte-identical for
|
|
18
|
-
* every run. The task name is the short human-chosen label that actually
|
|
19
|
-
* identifies it, so that is the title.
|
|
20
|
-
*
|
|
21
|
-
* The title is the task name and NOTHING else. It deliberately does not name the
|
|
22
|
-
* run's fire instant, for two independent reasons:
|
|
23
|
-
*
|
|
24
|
-
* - No run mode guarantees one run per session. `reusable_session` generates
|
|
25
|
-
* its session on the first fire and then reuses it forever, and even under
|
|
26
|
-
* `new_session_per_run` alert-occurrence redelivery converges several runs
|
|
27
|
-
* onto one canonical responder session. `existing_session` never generates a
|
|
28
|
-
* session at all, so the scheduler never titles one. A run-specific fact
|
|
29
|
-
* frozen into the title is therefore right for the generating run and a lie
|
|
30
|
-
* for every run that lands in the same session afterwards.
|
|
31
|
-
* - A title is one stored string shown to every viewer, while every surface
|
|
32
|
-
* that renders a run's fire instant renders it viewer-local: the rail row
|
|
33
|
-
* prints the title beside `relativeTimeLabel(session.updatedAt)`, and the
|
|
34
|
-
* Schedules run list prints `formatTimestamp(run.firedAt)`, which is
|
|
35
|
-
* `toLocaleString()`. A wall clock stored in the title therefore disagrees
|
|
36
|
-
* with the time printed next to it for every viewer outside whichever zone
|
|
37
|
-
* it was rendered in. The task's own `timeZone` is no escape: it labels the
|
|
38
|
-
* schedule rule ("Mon Wed 09:00 Europe/Oslo"), not the rendering of a run,
|
|
39
|
-
* which stays viewer-local. No stored clock can agree with a viewer-local
|
|
40
|
-
* one, so the title carries none and the instant stays on the surfaces that
|
|
41
|
-
* already render it correctly.
|
|
42
|
-
*
|
|
43
|
-
* Dropping the clock settles the determinism constraint outright rather than
|
|
44
|
-
* working around it: the same run titled by the normal dispatch or by a later
|
|
45
|
-
* recovery in a different worker process derives one string from `task.name`
|
|
46
|
-
* alone, with no Intl call and so no host ICU or tzdata build to make the two
|
|
47
|
-
* texts differ.
|
|
48
|
-
*/
|
|
49
18
|
export declare function scheduledTaskSessionTitle(taskName: string): string;
|
|
50
19
|
/**
|
|
51
20
|
* Title a session the scheduler generated, and emit the same `session.title_set`
|
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
import { settleSessionAttemptInterruptions, applySessionTurnSettlement, enqueueSessionWorkflowWake, failSessionWorkBeforeAttemptClaim, requestSessionTurnRecovery, recoverSessionDispatch, reconcileSessionAttemptQuiescence, peekSessionWork as peekSessionWorkDb, settleSessionInputWait as settleSessionInputWaitDb, countQueuedTurns, getSessionAttemptActivityRef, getSessionEvent, getSessionTurnForAttempt, expireSessionInteractionIntervention as expireSessionInteractionInterventionDb, expireSessionHumanInputRequest, markSessionAttemptQuiesced, requireSession, settleSessionIdleWithParentOutbox } from "@opengeni/db";
|
|
1
|
+
import { settleSessionAttemptInterruptions, applySessionTurnSettlement, enqueueSessionWorkflowWake, failSessionWorkBeforeAttemptClaim, blockSessionWorkBeforeAttemptClaim, requestSessionTurnRecovery, recoverSessionDispatch, reconcileSettledSessionAttempt, reconcileSessionAttemptQuiescence, reconcileCompletedSandboxSetup, peekSessionWork as peekSessionWorkDb, settleSessionInputWait as settleSessionInputWaitDb, countQueuedTurns, getSessionAttemptActivityRef, getSessionEvent, getSessionTurnForAttempt, getWorkspace, expireSessionInteractionIntervention as expireSessionInteractionInterventionDb, expireScheduledRunHumanWait as expireScheduledRunHumanWaitDb, expireSessionHumanInputRequest, markSessionAttemptQuiesced, requireSession, settleSessionIdleWithParentOutbox } from "@opengeni/db";
|
|
2
2
|
import { publishDurableSessionEvents } from "@opengeni/events";
|
|
3
3
|
import { deliverFailedChildTurnToParent, notifyParentOfChildIdle } from "./parent-wake.js";
|
|
4
4
|
import { recordTurnsQueuedGauge, recordWorkerDeathRecoveryMetrics } from "../observability-metrics.js";
|
|
5
|
-
import type { ControlActivityServices, ExpireSessionHumanInputInput, ExpireSessionHumanInputResult, ExpireSessionInteractionInterventionInput, ExpireSessionInteractionInterventionResult, PeekSessionWorkInput, FailSessionAttemptInput, FailSessionAttemptResult, SettleSessionInterruptionsInput, MarkSessionIdleInput, PersistSessionAttemptQuiescenceInput, ReconcileSessionAttemptQuiescenceInput, ReconcileSessionAttemptQuiescenceResult, RecoverDispatchInput, RecoverDispatchResult, RecoverEscapedMcpTimeoutInput, RecoverEscapedMcpTimeoutResult, SettleSessionInputWaitInput, SettleSessionInputWaitResult } from "./types.js";
|
|
5
|
+
import type { ControlActivityServices, ExpireSessionHumanInputInput, ExpireSessionHumanInputResult, ExpireSessionInteractionInterventionInput, ExpireScheduledRunHumanWaitInput, ExpireScheduledRunHumanWaitResult, ExpireSessionInteractionInterventionResult, PeekSessionWorkInput, FailSessionAttemptInput, FailSessionAttemptResult, SettleSessionInterruptionsInput, MarkSessionIdleInput, PersistSessionAttemptQuiescenceInput, ReconcileSessionAttemptQuiescenceInput, ReconcileSessionAttemptQuiescenceResult, ReconcileSettledSessionAttemptInput, ReconcileSettledSessionAttemptResult, RecoverDispatchInput, RecoverDispatchResult, RecoverEscapedMcpTimeoutInput, RecoverEscapedMcpTimeoutResult, SettleSessionInputWaitInput, SettleSessionInputWaitResult } from "./types.js";
|
|
6
6
|
export type SessionStateActivityOverrides = Partial<{
|
|
7
7
|
settleSessionAttemptInterruptions: typeof settleSessionAttemptInterruptions;
|
|
8
8
|
applySessionTurnSettlement: typeof applySessionTurnSettlement;
|
|
9
9
|
enqueueSessionWorkflowWake: typeof enqueueSessionWorkflowWake;
|
|
10
10
|
failSessionWorkBeforeAttemptClaim: typeof failSessionWorkBeforeAttemptClaim;
|
|
11
|
+
blockSessionWorkBeforeAttemptClaim: typeof blockSessionWorkBeforeAttemptClaim;
|
|
11
12
|
requestSessionTurnRecovery: typeof requestSessionTurnRecovery;
|
|
12
13
|
recoverSessionDispatch: typeof recoverSessionDispatch;
|
|
14
|
+
reconcileSettledSessionAttempt: typeof reconcileSettledSessionAttempt;
|
|
13
15
|
reconcileSessionAttemptQuiescence: typeof reconcileSessionAttemptQuiescence;
|
|
16
|
+
reconcileCompletedSandboxSetup: typeof reconcileCompletedSandboxSetup;
|
|
14
17
|
peekSessionWork: typeof peekSessionWorkDb;
|
|
15
18
|
settleSessionInputWait: typeof settleSessionInputWaitDb;
|
|
16
19
|
countQueuedTurns: typeof countQueuedTurns;
|
|
17
20
|
getSessionAttemptActivityRef: typeof getSessionAttemptActivityRef;
|
|
18
21
|
getSessionEvent: typeof getSessionEvent;
|
|
19
22
|
getSessionTurnForAttempt: typeof getSessionTurnForAttempt;
|
|
23
|
+
getWorkspace: typeof getWorkspace;
|
|
20
24
|
expireSessionHumanInputRequest: typeof expireSessionHumanInputRequest;
|
|
21
25
|
expireSessionInteractionIntervention: typeof expireSessionInteractionInterventionDb;
|
|
26
|
+
expireScheduledRunHumanWait: typeof expireScheduledRunHumanWaitDb;
|
|
22
27
|
requireSession: typeof requireSession;
|
|
23
28
|
settleSessionIdleWithParentOutbox: typeof settleSessionIdleWithParentOutbox;
|
|
24
29
|
markSessionAttemptQuiesced: typeof markSessionAttemptQuiesced;
|
|
@@ -36,11 +41,73 @@ export declare function createSessionStateActivities(services: () => Promise<Con
|
|
|
36
41
|
}>;
|
|
37
42
|
persistSessionAttemptQuiescence: (input: PersistSessionAttemptQuiescenceInput) => Promise<void>;
|
|
38
43
|
reconcileSessionAttemptQuiescence: (input: ReconcileSessionAttemptQuiescenceInput) => Promise<ReconcileSessionAttemptQuiescenceResult>;
|
|
44
|
+
reconcileSettledSessionAttempt: (input: ReconcileSettledSessionAttemptInput) => Promise<ReconcileSettledSessionAttemptResult>;
|
|
39
45
|
recoverDispatch: (input: RecoverDispatchInput) => Promise<RecoverDispatchResult>;
|
|
40
46
|
recoverEscapedMcpTimeout: (input: RecoverEscapedMcpTimeoutInput) => Promise<RecoverEscapedMcpTimeoutResult>;
|
|
41
|
-
peekSessionWork: (input: PeekSessionWorkInput) => Promise<
|
|
47
|
+
peekSessionWork: (input: PeekSessionWorkInput) => Promise<{
|
|
48
|
+
kind: "unavailable";
|
|
49
|
+
} | {
|
|
50
|
+
kind: "attempt-owned";
|
|
51
|
+
turnId: string;
|
|
52
|
+
attemptId: string;
|
|
53
|
+
executionGeneration: number;
|
|
54
|
+
activityRef: import("@opengeni/db").SessionAttemptActivityRef;
|
|
55
|
+
} | {
|
|
56
|
+
kind: "runnable";
|
|
57
|
+
admissionFence?: import("@opengeni/db").SessionAdmissionFence;
|
|
58
|
+
} | {
|
|
59
|
+
kind: "admission-blocked";
|
|
60
|
+
reason?: "sandbox_setup_outcome_unknown" | "sandbox_setup_recovery_exhausted";
|
|
61
|
+
ref?: import("@opengeni/db").SandboxSetupOutcomeUnknown | import("@opengeni/db").SandboxSetupRecoveryExhausted;
|
|
62
|
+
} | {
|
|
63
|
+
kind: "sandbox-lifecycle-wait";
|
|
64
|
+
ref: import("@opengeni/db").SandboxLifecycleWait;
|
|
65
|
+
} | {
|
|
66
|
+
kind: "approval-pending";
|
|
67
|
+
triggerEventId: string;
|
|
68
|
+
admissionFence?: import("@opengeni/db").SessionAdmissionFence;
|
|
69
|
+
} | {
|
|
70
|
+
kind: "approval-wait";
|
|
71
|
+
humanInputRequestId?: string;
|
|
72
|
+
interactionInterventionId?: string;
|
|
73
|
+
scheduledRunTimeout?: {
|
|
74
|
+
runId: string;
|
|
75
|
+
turnId: string;
|
|
76
|
+
};
|
|
77
|
+
expiresAt?: string;
|
|
78
|
+
} | {
|
|
79
|
+
kind: "capacity-wait";
|
|
80
|
+
ref: {
|
|
81
|
+
provider?: "codex" | "xai" | "claude";
|
|
82
|
+
waiterId: string;
|
|
83
|
+
generation: number;
|
|
84
|
+
nextCheckAt: string;
|
|
85
|
+
wakeRevision: number;
|
|
86
|
+
};
|
|
87
|
+
} | {
|
|
88
|
+
kind: "interruption-pending";
|
|
89
|
+
attemptId: string;
|
|
90
|
+
} | {
|
|
91
|
+
kind: "cancellation-wait";
|
|
92
|
+
attemptId: string;
|
|
93
|
+
} | {
|
|
94
|
+
kind: "input-wait";
|
|
95
|
+
disposition: "held" | "timeout" | "superseded";
|
|
96
|
+
waitTurnId: string;
|
|
97
|
+
deadlineAt: string;
|
|
98
|
+
} | {
|
|
99
|
+
kind: "idle";
|
|
100
|
+
} | {
|
|
101
|
+
kind: "attempt-owned";
|
|
102
|
+
turnId: string;
|
|
103
|
+
attemptId: string;
|
|
104
|
+
executionGeneration: number;
|
|
105
|
+
activityRef: import("@opengeni/db").SessionAttemptActivityRef;
|
|
106
|
+
ownerActivityState: "pending" | "settled" | "unknown";
|
|
107
|
+
}>;
|
|
42
108
|
settleSessionInputWait: (input: SettleSessionInputWaitInput) => Promise<SettleSessionInputWaitResult>;
|
|
43
109
|
expireSessionHumanInput: (input: ExpireSessionHumanInputInput) => Promise<ExpireSessionHumanInputResult>;
|
|
44
110
|
expireSessionInteractionIntervention: (input: ExpireSessionInteractionInterventionInput) => Promise<ExpireSessionInteractionInterventionResult>;
|
|
111
|
+
expireScheduledRunHumanWait: (input: ExpireScheduledRunHumanWaitInput) => Promise<ExpireScheduledRunHumanWaitResult>;
|
|
45
112
|
markSessionIdle: (input: MarkSessionIdleInput) => Promise<void>;
|
|
46
113
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Settings } from "@opengeni/config";
|
|
2
2
|
import type { ConnectionCredentialsPort, DocumentAuthorityKind, EntitlementsPort, KnowledgeSourceSyncRunSummary, ScheduledTaskTriggerType, TurnInitiator } from "@opengeni/contracts";
|
|
3
|
-
import type { Database, SessionWorkflowWakeDeliveryResult } from "@opengeni/db";
|
|
3
|
+
import type { Database, SessionWorkflowWakeDeliveryResult, SessionAdmissionFence } from "@opengeni/db";
|
|
4
4
|
import type { DocumentServices } from "@opengeni/documents";
|
|
5
5
|
import type { EventBus } from "@opengeni/events";
|
|
6
6
|
import type { Observability } from "@opengeni/observability";
|
|
@@ -87,6 +87,11 @@ export type SharedActivityServices = {
|
|
|
87
87
|
export type ControlActivityServices = SharedActivityServices;
|
|
88
88
|
/** Turn workers own the model loop and never construct document parsers. */
|
|
89
89
|
export type TurnActivityServices = SharedActivityServices & {
|
|
90
|
+
/** Host-owned containment: stop polling and checkpoint peer turns before exit.
|
|
91
|
+
* Bare activity embedders must provide their own worker lifecycle edge. */
|
|
92
|
+
requestWorkerDrain: () => void;
|
|
93
|
+
/** Deterministic test clock for the cleanup-only monitor. */
|
|
94
|
+
turnFinalizationTimeoutMs?: number | undefined;
|
|
90
95
|
runtime: OpenGeniRuntime;
|
|
91
96
|
/** Provider-free test/profiling seam; production injects the real runtime summarizer. */
|
|
92
97
|
summarizeContextForCompaction: typeof import("@opengeni/runtime").summarizeForCompaction;
|
|
@@ -97,7 +102,7 @@ export type ActivityServices = ControlActivityServices & TurnActivityServices &
|
|
|
97
102
|
};
|
|
98
103
|
export type CodexCapacityWaitRef = {
|
|
99
104
|
/** Absent only for Temporal histories written before provider-tagged waits. */
|
|
100
|
-
provider?: "codex" | "xai";
|
|
105
|
+
provider?: "codex" | "xai" | "claude";
|
|
101
106
|
waiterId: string;
|
|
102
107
|
generation: number;
|
|
103
108
|
nextCheckAt: string;
|
|
@@ -118,7 +123,7 @@ export type ReconcileCodexCapacityWaitInput = {
|
|
|
118
123
|
generation: number;
|
|
119
124
|
cause: "timer" | "signal" | "queue" | "recovery";
|
|
120
125
|
/** Absent only for Codex waits and pre-provider-tagged workflow histories. */
|
|
121
|
-
provider?: "codex" | "xai";
|
|
126
|
+
provider?: "codex" | "xai" | "claude";
|
|
122
127
|
};
|
|
123
128
|
export type ReconcileCodexCapacityWaitResult = ({
|
|
124
129
|
action: "waiting";
|
|
@@ -174,6 +179,20 @@ export type ReconcileSessionAttemptQuiescenceInput = {
|
|
|
174
179
|
export type ReconcileSessionAttemptQuiescenceResult = {
|
|
175
180
|
action: "quiesced" | "pending" | "stale";
|
|
176
181
|
};
|
|
182
|
+
export type ReconcileSettledSessionAttemptInput = {
|
|
183
|
+
accountId: string;
|
|
184
|
+
workspaceId: string;
|
|
185
|
+
sessionId: string;
|
|
186
|
+
turnId: string;
|
|
187
|
+
attemptId: string;
|
|
188
|
+
executionGeneration: number;
|
|
189
|
+
workflowId: string;
|
|
190
|
+
workflowRunId: string;
|
|
191
|
+
activityId: string;
|
|
192
|
+
};
|
|
193
|
+
export type ReconcileSettledSessionAttemptResult = {
|
|
194
|
+
action: "recovering" | "exceeded" | "pending" | "stale";
|
|
195
|
+
};
|
|
177
196
|
export type FailSessionAttemptInput = {
|
|
178
197
|
accountId: string;
|
|
179
198
|
workspaceId: string;
|
|
@@ -191,6 +210,7 @@ export type FailSessionAttemptInput = {
|
|
|
191
210
|
* committed claim discovered by the control lane can recover the exact
|
|
192
211
|
* attempt instead of terminally failing it. */
|
|
193
212
|
preClaimFailure?: PreClaimFailureDetail;
|
|
213
|
+
admissionFence?: SessionAdmissionFence;
|
|
194
214
|
/** Added in v4. A claimed attempt that lost operational database access
|
|
195
215
|
* before turn-start completion carries its exact immutable turn identity so
|
|
196
216
|
* the DB-only control lane can recover it instead of terminally failing it. */
|
|
@@ -201,6 +221,8 @@ export type FailSessionAttemptInput = {
|
|
|
201
221
|
error?: string;
|
|
202
222
|
};
|
|
203
223
|
export type FailSessionAttemptResult = {
|
|
224
|
+
action: "blocked";
|
|
225
|
+
} | {
|
|
204
226
|
action: "failed";
|
|
205
227
|
} | {
|
|
206
228
|
action: "recovering";
|
|
@@ -211,10 +233,13 @@ export type FailSessionAttemptResult = {
|
|
|
211
233
|
} | {
|
|
212
234
|
action: "stale";
|
|
213
235
|
};
|
|
214
|
-
export type PreClaimFailureDisposition = "retryable" | "permanent";
|
|
236
|
+
export type PreClaimFailureDisposition = "retryable" | "permanent" | "blocked";
|
|
215
237
|
export type PreClaimFailureDetail = {
|
|
216
238
|
disposition: PreClaimFailureDisposition;
|
|
217
239
|
code: "db_deadlock" | "db_serialization_failure" | "db_failure" | "claim_invariant";
|
|
240
|
+
sqlState?: string | null;
|
|
241
|
+
reason?: "database_claim_rejected" | "initiator_membership_required" | "personal_resource_grant_required";
|
|
242
|
+
retryPolicy?: "explicit_recheck";
|
|
218
243
|
};
|
|
219
244
|
export declare const PRE_CLAIM_FAILURE_TYPE = "OpenGeniPreClaimFailure";
|
|
220
245
|
export declare const PRE_CLAIM_FAILURE_MESSAGE = "Agent turn admission failed before attempt claim.";
|
|
@@ -229,6 +254,10 @@ export type PostClaimDatabaseRecoveryDetail = {
|
|
|
229
254
|
providerRecoveryCount?: number;
|
|
230
255
|
/** Safe classified provider cause paired with providerRecoveryCount. */
|
|
231
256
|
providerFailureCode?: string;
|
|
257
|
+
/** Persist the no-replay setup marker, not a new provider/setup attempt. */
|
|
258
|
+
sandboxSetupOutcomeUnknown?: true;
|
|
259
|
+
/** Preserve the exhausted budget for a command proven not dispatched. */
|
|
260
|
+
sandboxSetupRecoveryExhausted?: true;
|
|
232
261
|
};
|
|
233
262
|
export declare const POST_CLAIM_DATABASE_RECOVERY_FAILURE_TYPE = "OpenGeniPostClaimDatabaseRecovery";
|
|
234
263
|
export declare const POST_CLAIM_DATABASE_RECOVERY_FAILURE_MESSAGE = "Agent turn database recovery required after attempt claim.";
|
|
@@ -273,6 +302,9 @@ export type RecoverEscapedMcpTimeoutResult = {
|
|
|
273
302
|
export type PeekSessionWorkInput = {
|
|
274
303
|
workspaceId: string;
|
|
275
304
|
sessionId: string;
|
|
305
|
+
includeAdmissionFence?: boolean;
|
|
306
|
+
/** Versioned workflow observer opt-in, never a caller authorization grant. */
|
|
307
|
+
observerAccountId?: string;
|
|
276
308
|
};
|
|
277
309
|
export type SettleSessionInputWaitInput = {
|
|
278
310
|
accountId: string;
|
|
@@ -302,6 +334,16 @@ export type ExpireSessionInteractionInterventionInput = {
|
|
|
302
334
|
export type ExpireSessionInteractionInterventionResult = {
|
|
303
335
|
action: "expired" | "stale" | "not_found";
|
|
304
336
|
};
|
|
337
|
+
export type ExpireScheduledRunHumanWaitInput = {
|
|
338
|
+
accountId: string;
|
|
339
|
+
workspaceId: string;
|
|
340
|
+
sessionId: string;
|
|
341
|
+
turnId: string;
|
|
342
|
+
runId: string;
|
|
343
|
+
};
|
|
344
|
+
export type ExpireScheduledRunHumanWaitResult = {
|
|
345
|
+
action: "expired" | "stale" | "not_found";
|
|
346
|
+
};
|
|
305
347
|
export type MarkSessionIdleInput = {
|
|
306
348
|
workspaceId: string;
|
|
307
349
|
sessionId: string;
|
|
@@ -324,17 +366,24 @@ export type DispatchScheduledTaskRunInput = {
|
|
|
324
366
|
triggerType: Extract<ScheduledTaskTriggerType, "scheduled">;
|
|
325
367
|
agentRunUsageIdempotencyKey?: never;
|
|
326
368
|
initiator?: never;
|
|
369
|
+
credentialRestriction?: never;
|
|
327
370
|
} | {
|
|
328
371
|
triggerType: Extract<ScheduledTaskTriggerType, "manual" | "initial" | "provider_event" | "retry" | "repair">;
|
|
329
372
|
agentRunUsageIdempotencyKey: string;
|
|
330
373
|
/** Exact identity used by the API-side charge for this same trigger. */
|
|
331
374
|
initiator: TurnInitiator;
|
|
375
|
+
/** Trusted API-side caller ceiling for this occurrence, not the schedule. */
|
|
376
|
+
credentialRestriction?: "developer_setup";
|
|
332
377
|
});
|
|
333
378
|
export type DispatchScheduledTaskRunResult = {
|
|
334
379
|
action: "deleted";
|
|
335
380
|
} | {
|
|
336
381
|
action: "blocked";
|
|
337
|
-
|
|
382
|
+
runId?: string;
|
|
383
|
+
diagnostic?: import("@opengeni/contracts").ConnectionAccountSelectionDiagnostic;
|
|
384
|
+
/** Present when the occurrence was refused as a visible run receipt. */
|
|
385
|
+
refusal?: import("@opengeni/contracts").ScheduledTaskAdmissionRefusal;
|
|
386
|
+
reason: "insufficient_credits" | "allowance_exhausted" | "monthly_model_cost_limit" | "monthly_agent_run_limit" | "malformed_manual_trigger" | "scheduled_task_paused" | "scheduled_authority_exhausted" | "scheduled_run_terminal" | "scheduled_execution_unrepresentable" | "connection_account_unavailable" | "scheduled_authority_unavailable" | "machine_target_unavailable" | "machine_enrollment_inactive" | "variable_set_unavailable" | "rig_version_unavailable" | "knowledge_source_paused" | "legacy_source_schedule_requires_migration" | "atlassian_native_retired" | "incident_preflight_metadata_missing" | "incident_responder_under_capable" | "incident_data_source_unsuitable";
|
|
338
387
|
} | {
|
|
339
388
|
action: "start" | "signal";
|
|
340
389
|
accountId: string;
|
|
@@ -427,6 +476,6 @@ type ClaimedRunAgentTurnResult = {
|
|
|
427
476
|
};
|
|
428
477
|
export type RunAgentTurnResult = ClaimedRunAgentTurnResult | {
|
|
429
478
|
status: "unclaimed";
|
|
430
|
-
reason: "gate-closed" | "no-work" | "stale-approval" | "control-pending";
|
|
479
|
+
reason: "gate-closed" | "no-work" | "stale-approval" | "control-pending" | "dispatch-expired";
|
|
431
480
|
};
|
|
432
481
|
export {};
|
|
@@ -108,6 +108,8 @@ export declare function captureWhileIdle(input: {
|
|
|
108
108
|
* to release() regardless.
|
|
109
109
|
*/
|
|
110
110
|
export declare function captureWorkspaceRevision(input: CaptureWorkspaceRevisionInput): Promise<void>;
|
|
111
|
+
/** Count one committed logical capture and observe its end-to-end duration. */
|
|
112
|
+
export declare function recordWorkspaceCaptureCompleted(observability: Pick<Observability, "incrementCounter" | "observeHistogram">, durationMs: number): void;
|
|
111
113
|
/**
|
|
112
114
|
* sha256 over the CHANGE SURFACE only — per-file (path, status, hash, deleted,
|
|
113
115
|
* tooLarge), exact HEAD identity, the working diff summary, and exact committed
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type Settings } from "@opengeni/config";
|
|
2
|
+
import { CredentialProviderResponse, type CredentialProviderRequest, type RunCredentialsRequest, type RunCredentialsResolution } from "@opengeni/contracts";
|
|
3
|
+
import { resolveWorkspaceCredentialProvider, resolveInitiatingHuman, type Database } from "@opengeni/db";
|
|
4
|
+
import { pinnedFetch } from "@opengeni/network";
|
|
5
|
+
export declare const GIT_CREDENTIALS_FILE = "git/credentials";
|
|
6
|
+
export declare const GIT_CREDENTIALS_FILE_ENV = "OPENGENI_GIT_CREDENTIALS_FILE";
|
|
7
|
+
export declare class CredentialProviderError extends Error {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
export type WorkspaceRunCredentialResolver = (input: RunCredentialsRequest) => Promise<RunCredentialsResolution>;
|
|
11
|
+
type ProviderOk = Extract<CredentialProviderResponse, {
|
|
12
|
+
status: "ok";
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Turn the provider's `git` sugar into ordinary run-credential material: one
|
|
16
|
+
* renewable credential-store file plus a read-only helper configured through
|
|
17
|
+
* GIT_CONFIG_* environment entries appended after any the host already set.
|
|
18
|
+
*/
|
|
19
|
+
export declare function withGitCredentialHelper(response: ProviderOk): ProviderOk;
|
|
20
|
+
export declare function credentialProviderRequestBody(input: RunCredentialsRequest, initiatingHumanSubjectId: string | null, initiatingHuman?: CredentialProviderRequest["initiatingHuman"], selection?: Pick<CredentialProviderRequest, "lane" | "mcpServers">): CredentialProviderRequest;
|
|
21
|
+
export declare function toRunCredentialsResolution(response: CredentialProviderResponse, scope: {
|
|
22
|
+
accountId: string;
|
|
23
|
+
workspaceId: string;
|
|
24
|
+
sessionId: string;
|
|
25
|
+
}): RunCredentialsResolution;
|
|
26
|
+
export type WorkspaceCredentialProviderDeps = {
|
|
27
|
+
fetch?: typeof pinnedFetch;
|
|
28
|
+
resolveProvider?: typeof resolveWorkspaceCredentialProvider;
|
|
29
|
+
resolveHuman?: typeof resolveInitiatingHuman;
|
|
30
|
+
/** Trusted selected session-attached remote targets, frozen by the worker. */
|
|
31
|
+
mcpServers?: readonly {
|
|
32
|
+
id: string;
|
|
33
|
+
url: string;
|
|
34
|
+
}[];
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Resolve the workspace's configured HTTP credential provider, if any. The
|
|
38
|
+
* returned resolver has the same contract as a host `runCredentials` port, so
|
|
39
|
+
* provisioning, file materialization, renewal, and reconnect notices reuse the
|
|
40
|
+
* existing run-credential lifecycle unchanged.
|
|
41
|
+
*/
|
|
42
|
+
export declare function workspaceCredentialProviderResolver(db: Database, settings: Settings, scope: {
|
|
43
|
+
accountId: string;
|
|
44
|
+
workspaceId: string;
|
|
45
|
+
}, initiatingHumanSubjectId: string | null, deps?: WorkspaceCredentialProviderDeps): Promise<WorkspaceRunCredentialResolver | null>;
|
|
46
|
+
export {};
|