@opengeni/worker-bundle 0.16.29 → 0.20.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 +12 -0
- package/dist/activities/agent-turn.d.ts +110 -19
- package/dist/activities/api-integrations.d.ts +21 -0
- package/dist/activities/browser-state-artifact-reaper.d.ts +29 -0
- package/dist/activities/capabilities.d.ts +6 -0
- package/dist/activities/codemode-dispatcher.d.ts +35 -0
- package/dist/activities/codemode-token-renewal.d.ts +23 -0
- package/dist/activities/codex-capacity.d.ts +6 -5
- package/dist/activities/codex-image-generation.d.ts +21 -0
- package/dist/activities/context-compaction.d.ts +1 -0
- package/dist/activities/documents.d.ts +3 -2
- package/dist/activities/environment.d.ts +17 -8
- package/dist/activities/expiring-material-renewal.d.ts +1 -1
- package/dist/activities/file-upload-reaper.d.ts +7 -2
- package/dist/activities/gateway-image-generation.d.ts +39 -0
- package/dist/activities/gateway-video-generation.d.ts +53 -0
- package/dist/activities/generated-images.d.ts +112 -0
- package/dist/activities/git-credential-renewal.d.ts +1 -1
- package/dist/activities/goals.d.ts +2 -2
- package/dist/activities/google-drive-changes.d.ts +99 -0
- package/dist/activities/image-generation-operation.d.ts +74 -0
- package/dist/activities/image-generation-references.d.ts +25 -0
- package/dist/activities/knowledge-source-sync-driver.d.ts +23 -0
- package/dist/activities/knowledge-source-sync.d.ts +75 -0
- package/dist/activities/packs.d.ts +21 -36
- package/dist/activities/parent-wake.d.ts +1 -1
- package/dist/activities/retained-screenshot-reaper.d.ts +2 -2
- package/dist/activities/retained-screenshots.d.ts +36 -0
- package/dist/activities/rig-verification.d.ts +82 -5
- package/dist/activities/run-credential-renewal.d.ts +1 -1
- package/dist/activities/run-input.d.ts +3 -1
- package/dist/activities/sandbox-images.d.ts +14 -0
- package/dist/activities/sandbox-lease.d.ts +47 -9
- package/dist/activities/scheduled-tasks.d.ts +2 -2
- package/dist/activities/session-state.d.ts +7 -5
- package/dist/activities/site-auth-maintenance.d.ts +27 -0
- package/dist/activities/streaming.d.ts +1 -1
- package/dist/activities/types.d.ts +87 -5
- package/dist/activities/video-generation-admission.d.ts +43 -0
- package/dist/activities/video-generation-credential.d.ts +24 -0
- package/dist/activities/video-generation-reconciliation.d.ts +13 -0
- package/dist/activities/video-media-validation.d.ts +34 -0
- package/dist/activities/video-output-retention.d.ts +36 -0
- package/dist/activities/video-reference-staging.d.ts +55 -0
- package/dist/activities/workflow-wake.d.ts +2 -2
- package/dist/activities/workspace-capture.d.ts +10 -1
- package/dist/activities/xai-auth.d.ts +23 -0
- package/dist/activities/xai-image-generation.d.ts +26 -0
- package/dist/activities/xai-video-generation.d.ts +18 -0
- package/dist/activities-control-XURE4VKN.js +7221 -0
- package/dist/activities-control-XURE4VKN.js.map +1 -0
- package/dist/activities-control.d.ts +297 -0
- package/dist/activities-turn-6EBXGGLS.js +16036 -0
- package/dist/activities-turn-6EBXGGLS.js.map +1 -0
- package/dist/activities-turn.d.ts +17 -0
- package/dist/activities.d.ts +138 -150
- package/dist/activity-services.d.ts +10 -0
- package/dist/artifact-materializer-entry.d.ts +6 -0
- package/dist/artifact-materializer-entry.js +2662 -0
- package/dist/artifact-materializer-entry.js.map +1 -0
- package/dist/artifact-outbox-entry.d.ts +2 -0
- package/dist/artifact-outbox-entry.js +681 -0
- package/dist/artifact-outbox-entry.js.map +1 -0
- package/dist/chunk-5GRJIP5H.js +3092 -0
- package/dist/chunk-5GRJIP5H.js.map +1 -0
- package/dist/chunk-GRFQTTSQ.js +448 -0
- package/dist/chunk-GRFQTTSQ.js.map +1 -0
- package/dist/chunk-TYNPCG4U.js +906 -0
- package/dist/chunk-TYNPCG4U.js.map +1 -0
- package/dist/concurrency.d.ts +108 -5
- package/dist/editable-artifact-hint-broker.d.ts +49 -0
- package/dist/editable-artifact-materializer-launcher.d.ts +49 -0
- package/dist/editable-artifact-materializer-service.d.ts +108 -0
- package/dist/editable-artifact-materializer-storage.d.ts +12 -0
- package/dist/editable-artifact-materializer-subprocess.d.ts +50 -0
- package/dist/editable-artifact-materializer.d.ts +262 -0
- package/dist/editable-artifact-outbox-dispatcher.d.ts +44 -0
- package/dist/editable-artifact-outbox-service.d.ts +70 -0
- package/dist/host-export.d.ts +1 -1
- package/dist/index.d.ts +189 -10
- package/dist/index.js +715 -17380
- package/dist/index.js.map +1 -1
- package/dist/memory-pressure-guard.d.ts +57 -0
- package/dist/model-checkpoint-memory-collector.d.ts +23 -0
- package/dist/model-context-contributions.d.ts +40 -0
- package/dist/observability-metrics.d.ts +53 -1
- package/dist/sandbox-reaper-contract.d.ts +40 -0
- package/dist/sandbox-reaper-timeout.d.ts +14 -0
- package/dist/sandbox-resume.d.ts +34 -7
- package/dist/sandbox-routing.d.ts +6 -0
- package/dist/worker-service-lifecycle.d.ts +6 -2
- package/dist/workflow-bundle.js +1094 -370
- package/dist/workflows/activities.d.ts +8 -2
- package/dist/workflows/document-index.d.ts +1 -1
- package/dist/workflows/knowledge-source-sync.d.ts +13 -0
- package/dist/workflows/rig-verification.d.ts +1 -1
- package/dist/workflows/sandbox-reaper.d.ts +8 -0
- package/dist/workflows/scheduled-tasks.d.ts +1 -1
- package/dist/workflows/session.d.ts +2 -2
- package/dist/workflows/site-auth-maintenance.d.ts +2 -0
- package/dist/workflows/video-generation.d.ts +10 -0
- package/dist/workflows/workflow-wake.d.ts +1 -1
- package/dist/workflows.d.ts +10 -7
- package/package.json +35 -15
- package/src/activities/agent-run-admission.ts +76 -0
- package/src/activities/agent-turn.ts +2600 -340
- package/src/activities/api-integrations.ts +138 -0
- package/src/activities/browser-state-artifact-reaper.ts +120 -0
- package/src/activities/capabilities.ts +10 -0
- package/src/activities/codemode-dispatcher.ts +335 -0
- package/src/activities/codemode-token-renewal.ts +64 -0
- package/src/activities/codex-capacity.ts +54 -7
- package/src/activities/codex-image-generation.ts +56 -0
- package/src/activities/context-compaction.ts +38 -3
- package/src/activities/documents.ts +14 -4
- package/src/activities/environment.ts +54 -45
- package/src/activities/expiring-material-renewal.ts +1 -1
- package/src/activities/file-upload-reaper.ts +34 -3
- package/src/activities/gateway-image-generation.ts +146 -0
- package/src/activities/gateway-video-generation.ts +298 -0
- package/src/activities/generated-images.ts +860 -0
- package/src/activities/goals.ts +8 -3
- package/src/activities/google-drive-changes.ts +454 -0
- package/src/activities/image-generation-operation.ts +333 -0
- package/src/activities/image-generation-references.ts +118 -0
- package/src/activities/knowledge-source-sync-driver.ts +27 -0
- package/src/activities/knowledge-source-sync.ts +2840 -0
- package/src/activities/mcp-credentials.ts +1 -0
- package/src/activities/packs.ts +75 -152
- package/src/activities/parent-wake.ts +13 -1
- package/src/activities/retained-screenshot-reaper.ts +2 -2
- package/src/activities/retained-screenshots.ts +453 -28
- package/src/activities/rig-verification.ts +554 -43
- package/src/activities/run-input.ts +22 -6
- package/src/activities/sandbox-images.ts +167 -0
- package/src/activities/sandbox-lease.ts +1065 -483
- package/src/activities/scheduled-tasks.ts +104 -74
- package/src/activities/session-state.ts +22 -4
- package/src/activities/site-auth-maintenance.ts +269 -0
- package/src/activities/streaming.ts +42 -3
- package/src/activities/types.ts +104 -5
- package/src/activities/video-generation-admission.ts +303 -0
- package/src/activities/video-generation-credential.ts +112 -0
- package/src/activities/video-generation-reconciliation.ts +771 -0
- package/src/activities/video-media-validation.ts +332 -0
- package/src/activities/video-output-retention.ts +314 -0
- package/src/activities/video-reference-staging.ts +350 -0
- package/src/activities/workflow-wake.ts +2 -2
- package/src/activities/workspace-capture.ts +44 -10
- package/src/activities/xai-auth.ts +122 -0
- package/src/activities/xai-image-generation.ts +86 -0
- package/src/activities/xai-video-generation.ts +69 -0
- package/src/activities-control.ts +58 -0
- package/src/activities-turn.ts +40 -0
- package/src/activities.ts +53 -124
- package/src/activity-services.ts +62 -0
- package/src/artifact-materializer-entry.ts +35 -0
- package/src/artifact-outbox-entry.ts +29 -0
- package/src/concurrency.ts +484 -6
- package/src/editable-artifact-hint-broker.ts +235 -0
- package/src/editable-artifact-materializer-launcher.ts +515 -0
- package/src/editable-artifact-materializer-service.ts +787 -0
- package/src/editable-artifact-materializer-storage.ts +413 -0
- package/src/editable-artifact-materializer-subprocess.ts +956 -0
- package/src/editable-artifact-materializer.ts +1289 -0
- package/src/editable-artifact-outbox-dispatcher.ts +244 -0
- package/src/editable-artifact-outbox-service.ts +438 -0
- package/src/index.ts +328 -72
- package/src/memory-pressure-guard.ts +489 -0
- package/src/model-checkpoint-memory-collector.ts +123 -0
- package/src/model-context-contributions.ts +159 -0
- package/src/observability-metrics.ts +297 -13
- package/src/sandbox-reaper-contract.ts +73 -0
- package/src/sandbox-reaper-timeout.ts +79 -0
- package/src/sandbox-resume.ts +294 -153
- package/src/sandbox-routing.ts +32 -24
- package/src/worker-service-lifecycle.ts +80 -14
- package/src/workflows/activities.ts +31 -0
- package/src/workflows/file-upload-reaper.ts +9 -1
- package/src/workflows/knowledge-source-sync.ts +83 -0
- package/src/workflows/sandbox-reaper.ts +183 -21
- package/src/workflows/scheduled-tasks.ts +42 -6
- package/src/workflows/session.ts +20 -6
- package/src/workflows/site-auth-maintenance.ts +14 -0
- package/src/workflows/video-generation.ts +36 -0
- package/src/workflows.ts +18 -1
- package/dist/activities/toolspace-token-renewal.d.ts +0 -23
- package/src/activities/toolspace-token-renewal.ts +0 -64
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Settings } from "@opengeni/config";
|
|
2
|
+
import type { Observability } from "@opengeni/observability";
|
|
3
|
+
export type TurnWorkerMemoryScope = "host" | "cgroup";
|
|
4
|
+
export type TurnWorkerMemoryScopeSnapshot = {
|
|
5
|
+
scope: TurnWorkerMemoryScope;
|
|
6
|
+
usedBytes: number;
|
|
7
|
+
limitBytes: number;
|
|
8
|
+
};
|
|
9
|
+
export type TurnWorkerMemoryPressureSnapshot = {
|
|
10
|
+
processRssBytes: number;
|
|
11
|
+
processHeapUsedBytes: number;
|
|
12
|
+
processExternalBytes: number;
|
|
13
|
+
processArrayBuffersBytes: number;
|
|
14
|
+
scopes: TurnWorkerMemoryScopeSnapshot[];
|
|
15
|
+
};
|
|
16
|
+
export type TurnWorkerMemoryPressureGuard = {
|
|
17
|
+
sampleNow(): void;
|
|
18
|
+
close(): void;
|
|
19
|
+
};
|
|
20
|
+
type GuardSettings = Pick<Settings, "turnWorkerConcurrencyMode" | "turnWorkerTargetMemoryUsage" | "turnWorkerEmergencyMemoryUsage" | "turnWorkerMemoryGuardIntervalMs" | "turnWorkerMemoryGuardSustainMs">;
|
|
21
|
+
type GuardDependencies = {
|
|
22
|
+
now?: () => number;
|
|
23
|
+
sample?: () => TurnWorkerMemoryPressureSnapshot;
|
|
24
|
+
setInterval?: typeof setInterval;
|
|
25
|
+
clearInterval?: typeof clearInterval;
|
|
26
|
+
gc?: () => void;
|
|
27
|
+
};
|
|
28
|
+
type SnapshotDependencies = {
|
|
29
|
+
readText?: (path: string) => string | null;
|
|
30
|
+
hostTotalBytes?: () => number;
|
|
31
|
+
hostAvailableBytes?: () => number;
|
|
32
|
+
processMemoryUsage?: () => Pick<NodeJS.MemoryUsage, "rss" | "heapUsed" | "external" | "arrayBuffers">;
|
|
33
|
+
};
|
|
34
|
+
export type ProcessCgroupMembership = {
|
|
35
|
+
v2Path: string | null;
|
|
36
|
+
v1MemoryPath: string | null;
|
|
37
|
+
};
|
|
38
|
+
export type CgroupMemoryFilePair = {
|
|
39
|
+
currentPath: string;
|
|
40
|
+
maxPath: string;
|
|
41
|
+
};
|
|
42
|
+
export declare function parseLinuxMeminfo(value: string): {
|
|
43
|
+
totalBytes: number;
|
|
44
|
+
availableBytes: number;
|
|
45
|
+
} | null;
|
|
46
|
+
export declare function parseFiniteCgroupMemoryLimit(value: string): number | null;
|
|
47
|
+
export declare function parseProcessCgroupMembership(value: string): ProcessCgroupMembership;
|
|
48
|
+
export declare function cgroupMemoryFilePairs(membership: ProcessCgroupMembership): CgroupMemoryFilePair[];
|
|
49
|
+
export declare function readTurnWorkerMemoryPressureSnapshot(dependencies?: SnapshotDependencies): TurnWorkerMemoryPressureSnapshot;
|
|
50
|
+
export declare function turnWorkerMemoryPressureGuardEnabled(role: "control" | "turn", settings: Pick<Settings, "turnWorkerConcurrencyMode">): boolean;
|
|
51
|
+
export declare function createTurnWorkerMemoryPressureGuard(input: {
|
|
52
|
+
settings: GuardSettings;
|
|
53
|
+
observability: Observability;
|
|
54
|
+
drain: () => void;
|
|
55
|
+
dependencies?: GuardDependencies;
|
|
56
|
+
}): TurnWorkerMemoryPressureGuard;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Observability } from "@opengeni/observability";
|
|
2
|
+
export declare const MODEL_CHECKPOINT_GC_PRESSURE_BYTES: number;
|
|
3
|
+
export declare const MODEL_CHECKPOINT_GC_COOLDOWN_MS = 30000;
|
|
4
|
+
type ProcessMemory = Pick<NodeJS.MemoryUsage, "heapUsed" | "external">;
|
|
5
|
+
type ModelCheckpointMemoryCollectorDependencies = {
|
|
6
|
+
now?: () => number;
|
|
7
|
+
memoryUsage?: () => ProcessMemory;
|
|
8
|
+
gc?: () => void;
|
|
9
|
+
setTimeout?: typeof setTimeout;
|
|
10
|
+
};
|
|
11
|
+
export type ModelCheckpointMemoryCollector = {
|
|
12
|
+
schedule(observability: Observability): void;
|
|
13
|
+
};
|
|
14
|
+
export declare function modelCheckpointPressureBytes(memory: ProcessMemory): number;
|
|
15
|
+
/**
|
|
16
|
+
* Reclaim request serialization and stream buffers only after one model
|
|
17
|
+
* response has crossed the durable conversation checkpoint. The callback runs
|
|
18
|
+
* on a later task so the completed response's stack can unwind first. Active
|
|
19
|
+
* turns and their exact model context remain strongly reachable and are never
|
|
20
|
+
* shortened, restarted, or rewritten by this process-local collection.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createModelCheckpointMemoryCollector(dependencies?: ModelCheckpointMemoryCollectorDependencies): ModelCheckpointMemoryCollector;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { PreferenceRegistrySnapshot, ResolvedCompanyProfileSnapshot, ResolvedWorkspaceInstructionPolicySnapshot, WorkspaceMemoryPromptMode } from "@opengeni/contracts";
|
|
2
|
+
import { type RuntimeSkillActivation } from "@opengeni/runtime";
|
|
3
|
+
export type CompanyBrainContributionCategory = "mandatory_rule" | "skill_guide_descriptor" | "retrieved_knowledge" | "task_note";
|
|
4
|
+
export type CompanyBrainContribution = Readonly<{
|
|
5
|
+
category: CompanyBrainContributionCategory;
|
|
6
|
+
source: "workspace_instruction_policy" | "legacy_workspace_instructions" | "preference_registry_descriptor" | "company_profile" | "legacy_memory_v1" | "runtime_skill_catalog";
|
|
7
|
+
inclusionReason: "active_instruction_policy" | "legacy_instruction_fallback" | "active_preference_descriptor" | "active_company_profile_root" | "legacy_standing_working_set" | "authorized_skill_descriptor";
|
|
8
|
+
authorityScope: "organization" | "workspace" | "user" | "session";
|
|
9
|
+
utf8Bytes: number;
|
|
10
|
+
estimatedTokens: number;
|
|
11
|
+
}>;
|
|
12
|
+
export type CompanyBrainContributionReceipt = Readonly<{
|
|
13
|
+
attemptId: string;
|
|
14
|
+
turnId: string;
|
|
15
|
+
sessionRole: "root" | "child";
|
|
16
|
+
memoryPromptMode: WorkspaceMemoryPromptMode;
|
|
17
|
+
instructionPolicySnapshotId: string;
|
|
18
|
+
preferenceSnapshotId: string | null;
|
|
19
|
+
companyProfileSnapshotId: string;
|
|
20
|
+
contributions: readonly CompanyBrainContribution[];
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Build a content-free exact-attempt receipt for the Company Brain material
|
|
24
|
+
* selected before inference. Token counts are deliberately estimates (UTF-8
|
|
25
|
+
* bytes / 4); provider-accounted total input tokens remain the separate source
|
|
26
|
+
* of truth for billing and context pressure.
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildCompanyBrainContributionReceipt(input: {
|
|
29
|
+
attemptId: string;
|
|
30
|
+
turnId: string;
|
|
31
|
+
nestedAgentDepth: number;
|
|
32
|
+
memoryPromptMode: WorkspaceMemoryPromptMode;
|
|
33
|
+
instructionPolicy: ResolvedWorkspaceInstructionPolicySnapshot;
|
|
34
|
+
workspaceAgentInstructions: string | null;
|
|
35
|
+
preferences: PreferenceRegistrySnapshot | null;
|
|
36
|
+
companyProfile: ResolvedCompanyProfileSnapshot;
|
|
37
|
+
companyProfileIncluded: boolean;
|
|
38
|
+
workspaceMemory: string | null;
|
|
39
|
+
skillActivations: readonly RuntimeSkillActivation[];
|
|
40
|
+
}): CompanyBrainContributionReceipt;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type SessionEventType } from "@opengeni/contracts";
|
|
2
2
|
import type { EventLogger } from "@opengeni/events";
|
|
3
3
|
import type { Observability } from "@opengeni/observability";
|
|
4
|
+
import type { CompanyBrainContributionReceipt } from "./model-context-contributions.js";
|
|
4
5
|
import { type RuntimeMetricsHooks, type SelfhostedOpObservation, type SelfhostedOpObserver } from "@opengeni/runtime";
|
|
5
6
|
export type TurnOutcome = "completed" | "failed" | "cancelled" | "recovering";
|
|
6
7
|
export type CreditMicrosKind = "usage" | "grant" | "topup" | "refund";
|
|
@@ -9,6 +10,22 @@ export type CreditBalanceGauge = {
|
|
|
9
10
|
accountId: string;
|
|
10
11
|
balanceMicros: number;
|
|
11
12
|
};
|
|
13
|
+
export type TurnTaskQueueStats = {
|
|
14
|
+
/** Temporal activity tasks ready for a turn worker to accept. */
|
|
15
|
+
eligibleBacklog: number;
|
|
16
|
+
oldestBacklogAgeSeconds: number;
|
|
17
|
+
tasksAddRate: number;
|
|
18
|
+
tasksDispatchRate: number;
|
|
19
|
+
};
|
|
20
|
+
export type TemporalTurnTaskQueueStats = {
|
|
21
|
+
approximateBacklogCount?: unknown;
|
|
22
|
+
approximateBacklogAge?: {
|
|
23
|
+
seconds?: unknown;
|
|
24
|
+
nanos?: unknown;
|
|
25
|
+
} | null;
|
|
26
|
+
tasksAddRate?: unknown;
|
|
27
|
+
tasksDispatchRate?: unknown;
|
|
28
|
+
} | null;
|
|
12
29
|
export declare function observabilityEventLogger(observability: Observability): EventLogger;
|
|
13
30
|
export declare function runtimeMetricsHooksForObservability(observability: Observability): RuntimeMetricsHooks;
|
|
14
31
|
/**
|
|
@@ -49,22 +66,41 @@ export declare function turnLifecycleMetricsFor(observability: Observability): T
|
|
|
49
66
|
export declare class TurnLifecycleMetrics {
|
|
50
67
|
private readonly observability;
|
|
51
68
|
private readonly options;
|
|
52
|
-
private readonly
|
|
69
|
+
private readonly turns;
|
|
53
70
|
private timer;
|
|
54
71
|
constructor(observability: Observability, options?: {
|
|
55
72
|
now?: () => number;
|
|
56
73
|
refreshIntervalMs?: number;
|
|
57
74
|
});
|
|
58
75
|
start(turnId: string): void;
|
|
76
|
+
progress(turnId: string): void;
|
|
59
77
|
finish(turnId: string, outcome: TurnOutcome | null, durationSeconds?: number): void;
|
|
60
78
|
refreshGauges(): void;
|
|
61
79
|
stop(): void;
|
|
62
80
|
private oldestInflightAgeSeconds;
|
|
81
|
+
private oldestNoProgressAgeSeconds;
|
|
63
82
|
private ensureTimer;
|
|
64
83
|
private stopTimer;
|
|
65
84
|
private now;
|
|
66
85
|
}
|
|
67
86
|
export declare function recordTurnsQueuedGauge(observability: Observability, value: number): void;
|
|
87
|
+
/**
|
|
88
|
+
* Record the authoritative turn activity queue rather than aggregate Postgres
|
|
89
|
+
* prompts. A paused human prompt is durable queue truth but is not runnable and
|
|
90
|
+
* never reaches this Temporal task queue. DescribeTaskQueue's approximate
|
|
91
|
+
* backlog count and age are explicitly documented by Temporal as autoscaling
|
|
92
|
+
* signals.
|
|
93
|
+
*/
|
|
94
|
+
export declare function recordTurnTaskQueueStats(observability: Observability, stats: TurnTaskQueueStats): void;
|
|
95
|
+
export declare function normalizeTurnTaskQueueStats(stats: TemporalTurnTaskQueueStats | undefined): TurnTaskQueueStats;
|
|
96
|
+
export declare function startTurnCapacityMonitor(input: {
|
|
97
|
+
observability: Observability;
|
|
98
|
+
read: () => Promise<TurnTaskQueueStats>;
|
|
99
|
+
intervalMs?: number;
|
|
100
|
+
now?: () => number;
|
|
101
|
+
}): {
|
|
102
|
+
close: () => Promise<void>;
|
|
103
|
+
};
|
|
68
104
|
export declare function recordSandboxLeaseGauges(observability: Observability, counts: Partial<Record<SandboxLeaseLiveness, number>>): void;
|
|
69
105
|
export declare const SANDBOX_INVENTORY_PROJECTION_DOMAINS: readonly ["leases", "checkpoint_artifacts", "rotation_backlog", "retained_processes", "expired_drains"];
|
|
70
106
|
export type SandboxInventoryProjectionDomain = (typeof SANDBOX_INVENTORY_PROJECTION_DOMAINS)[number];
|
|
@@ -100,6 +136,17 @@ export declare const RETAINED_PROCESS_RECONCILIATION_OUTCOMES: readonly ["claim_
|
|
|
100
136
|
export type RetainedProcessReconciliationOutcome = (typeof RETAINED_PROCESS_RECONCILIATION_OUTCOMES)[number];
|
|
101
137
|
export declare function recordRetainedProcessReconciliation(observability: Observability, outcome: RetainedProcessReconciliationOutcome): void;
|
|
102
138
|
export declare function recordCreditMicros(observability: Observability | undefined, kind: CreditMicrosKind, amountMicros: number): void;
|
|
139
|
+
/**
|
|
140
|
+
* Record provider lifecycle diagnostics from the synchronous transport observer.
|
|
141
|
+
* Provider ids come from the resolved provider registry; phase/outcome are closed
|
|
142
|
+
* enums. This function never performs I/O outside the in-memory metrics registry.
|
|
143
|
+
*/
|
|
144
|
+
export declare function recordModelRequestPhase(observability: Observability, input: {
|
|
145
|
+
provider: string;
|
|
146
|
+
phase: "headers" | "first_byte" | "terminal";
|
|
147
|
+
outcome?: "completed" | "failed" | "timed_out";
|
|
148
|
+
durationSeconds: number;
|
|
149
|
+
}): void;
|
|
103
150
|
export type StreamDeltaClass = "message" | "reasoning";
|
|
104
151
|
/**
|
|
105
152
|
* Per-turn stream-timing tracker fed every normalized runtime event in push order.
|
|
@@ -155,6 +202,11 @@ export declare function recordModelInputTokens(observability: Observability, pro
|
|
|
155
202
|
* | auto). The rate of this — against the input-tokens histogram above — is how an
|
|
156
203
|
* operator sees compaction working (or silently not). */
|
|
157
204
|
export declare function recordContextCompaction(observability: Observability, trigger: string): void;
|
|
205
|
+
/**
|
|
206
|
+
* Metadata-only Company Brain exposure telemetry. Labels are closed enums and
|
|
207
|
+
* never include tenant ids, record ids, titles, descriptions, or content.
|
|
208
|
+
*/
|
|
209
|
+
export declare function recordCompanyBrainContributions(observability: Observability, receipt: CompanyBrainContributionReceipt): void;
|
|
158
210
|
/**
|
|
159
211
|
* Prompt-cache efficiency of one model response, by provider. Reads from the SAME
|
|
160
212
|
* usage frame that feeds input-token accounting, so the two are always consistent:
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare const SANDBOX_REAPER_SCAN_ACTIVITY_TIMEOUT_MS: number;
|
|
2
|
+
export declare const SANDBOX_DRAIN_FAST_ACTIVITY_TIMEOUT_MS: number;
|
|
3
|
+
export declare const SANDBOX_DRAIN_EXTENDED_ACTIVITY_TIMEOUT_MS: number;
|
|
4
|
+
export declare const SANDBOX_DRAIN_SETTLEMENT_MARGIN_MS = 60000;
|
|
5
|
+
export declare const SANDBOX_REAPER_ACTIVITY_HEARTBEAT_TIMEOUT_MS = 20000;
|
|
6
|
+
export declare const SANDBOX_REAPER_ACTIVITY_HEARTBEAT_INTERVAL_MS = 5000;
|
|
7
|
+
export declare const SANDBOX_REAPER_CHILD_DISPATCH_LIMIT = 500;
|
|
8
|
+
export declare const SANDBOX_REAPER_V2_WORKFLOW_ID = "opengeni-sandbox-lease-reaper-v2";
|
|
9
|
+
export declare const SANDBOX_REAPER_MAINTENANCE_WORKFLOW_ID = "opengeni-sandbox-lease-maintenance-v1";
|
|
10
|
+
export declare const SANDBOX_LIFECYCLE_TASK_QUEUE_SUFFIX = "-sandbox-lifecycle-v1";
|
|
11
|
+
export declare function sandboxLifecycleTaskQueue(baseTaskQueue: string): string;
|
|
12
|
+
export type SandboxDrainTimeoutClass = "fast" | "extended";
|
|
13
|
+
export type SandboxDrainTarget = {
|
|
14
|
+
workspaceId: string;
|
|
15
|
+
sandboxGroupId: string;
|
|
16
|
+
instanceId: string | null;
|
|
17
|
+
leaseEpoch: number;
|
|
18
|
+
};
|
|
19
|
+
export type SandboxDrainActivityInput = {
|
|
20
|
+
target: SandboxDrainTarget;
|
|
21
|
+
timeoutClass: SandboxDrainTimeoutClass;
|
|
22
|
+
/** Provider operation budget frozen when the durable child is created. A
|
|
23
|
+
* rolling config change cannot make an existing fast child retry forever. */
|
|
24
|
+
snapshotTimeoutMs: number;
|
|
25
|
+
captureTimeoutMs: number;
|
|
26
|
+
/** Stable logical teardown operation; every Temporal activity retry keeps it
|
|
27
|
+
* while receiving a distinct exact capture-attempt id. */
|
|
28
|
+
operationId: string;
|
|
29
|
+
};
|
|
30
|
+
export type SandboxDrainWorkflowInput = Omit<SandboxDrainActivityInput, "operationId">;
|
|
31
|
+
export type SandboxLeaseSweepMaintenanceInput = {
|
|
32
|
+
examined: number;
|
|
33
|
+
started: number;
|
|
34
|
+
alreadyRunning: number;
|
|
35
|
+
startFailed: number;
|
|
36
|
+
rotationsRequested: number;
|
|
37
|
+
};
|
|
38
|
+
export declare function sandboxDrainTimeoutClass(captureTimeoutMs: number): SandboxDrainTimeoutClass;
|
|
39
|
+
export declare function sandboxDrainActivityTimeoutMs(timeoutClass: SandboxDrainTimeoutClass): number;
|
|
40
|
+
export declare function sandboxDrainWorkflowId(target: SandboxDrainTarget): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Settings } from "@opengeni/config";
|
|
2
|
+
import { type SandboxDrainTimeoutClass } from "./sandbox-reaper-contract.js";
|
|
3
|
+
export declare function sandboxDrainTiming(settings: Pick<Settings, "sandboxSnapshotTimeoutMs">): {
|
|
4
|
+
snapshotTimeoutMs: number;
|
|
5
|
+
captureTimeoutMs: number;
|
|
6
|
+
timeoutClass: SandboxDrainTimeoutClass;
|
|
7
|
+
activityTimeoutMs: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function assertSandboxReaperActivityTimeout(settings: Pick<Settings, "sandboxSnapshotTimeoutMs">): void;
|
|
10
|
+
export declare function assertSandboxDrainInputTiming(input: {
|
|
11
|
+
timeoutClass: SandboxDrainTimeoutClass;
|
|
12
|
+
snapshotTimeoutMs: number;
|
|
13
|
+
captureTimeoutMs: number;
|
|
14
|
+
}): void;
|
package/dist/sandbox-resume.d.ts
CHANGED
|
@@ -19,6 +19,10 @@ export declare function isRetryableDegradedRestore(restore: {
|
|
|
19
19
|
export type SandboxResumeServices = {
|
|
20
20
|
db: Database;
|
|
21
21
|
settings: Settings;
|
|
22
|
+
/** Exact settings before a verified rig provider image overlaid the logical
|
|
23
|
+
* pack/deployment image. Fresh-create NotFound fallback must preserve an
|
|
24
|
+
* ID-only logical base instead of selecting the provider default. */
|
|
25
|
+
logicalFallbackSettings?: Settings;
|
|
22
26
|
sandboxMetrics?: RuntimeMetricsHooks;
|
|
23
27
|
/**
|
|
24
28
|
* The logical turn-attempt lifetime, not merely the provider request lifetime.
|
|
@@ -88,15 +92,36 @@ export type ResumedTurnSandbox = {
|
|
|
88
92
|
established: EstablishedSandboxSession;
|
|
89
93
|
/** The lease_epoch this turn holds; the heartbeat/fence token. */
|
|
90
94
|
leaseEpoch: number;
|
|
91
|
-
/**
|
|
92
|
-
*
|
|
93
|
-
|
|
95
|
+
/** Staged idempotent release. The ordinary form immediately prevents a
|
|
96
|
+
* holder/timer leak. The quiesced form may be called later—even after the
|
|
97
|
+
* ordinary form—to repair null-outcome admissions only after every exact
|
|
98
|
+
* attempt-owned workspace writer has physically drained. NEVER stops the box. */
|
|
99
|
+
release: (options?: {
|
|
100
|
+
workspaceWritersQuiesced?: boolean;
|
|
101
|
+
}) => Promise<void>;
|
|
94
102
|
};
|
|
95
|
-
export declare class SandboxWarmingTimeoutError extends Error {
|
|
103
|
+
export declare abstract class SandboxWarmingTimeoutError extends Error {
|
|
96
104
|
readonly backend: string;
|
|
97
105
|
readonly timeoutMs: number;
|
|
98
|
-
readonly
|
|
99
|
-
|
|
106
|
+
readonly stage: "exec_readiness" | "sibling_warming";
|
|
107
|
+
readonly sandboxGroupId: string | null;
|
|
108
|
+
readonly instanceId: string | null;
|
|
109
|
+
abstract readonly code: "sandbox_exec_readiness_timeout" | "sandbox_sibling_warming_timeout";
|
|
110
|
+
protected constructor(backend: string, timeoutMs: number, stage: "exec_readiness" | "sibling_warming", sandboxGroupId: string | null, instanceId: string | null);
|
|
111
|
+
}
|
|
112
|
+
export declare class SandboxExecReadinessTimeoutError extends SandboxWarmingTimeoutError {
|
|
113
|
+
readonly code: "sandbox_exec_readiness_timeout";
|
|
114
|
+
constructor(backend: string, timeoutMs: number, identity?: {
|
|
115
|
+
sandboxGroupId?: string | null;
|
|
116
|
+
instanceId?: string | null;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
export declare class SandboxSiblingWarmingTimeoutError extends SandboxWarmingTimeoutError {
|
|
120
|
+
readonly code: "sandbox_sibling_warming_timeout";
|
|
121
|
+
constructor(backend: string, timeoutMs: number, identity: {
|
|
122
|
+
sandboxGroupId: string;
|
|
123
|
+
instanceId?: string | null;
|
|
124
|
+
});
|
|
100
125
|
}
|
|
101
126
|
/** The exact attached caller that won warm->cold after proving the provider
|
|
102
127
|
* instance gone. It is a lease supersession (the same logical turn recovers),
|
|
@@ -111,7 +136,9 @@ export declare class SandboxLeaseInstanceLostError extends SandboxLeaseSupersede
|
|
|
111
136
|
* returns, so it cannot bound that initial RPC. Probe it before publishing the
|
|
112
137
|
* lease as warm and enforce our own wall-clock deadline.
|
|
113
138
|
*/
|
|
114
|
-
export declare function waitForSandboxExecReadiness(established: EstablishedSandboxSession, timeoutMs?: number
|
|
139
|
+
export declare function waitForSandboxExecReadiness(established: EstablishedSandboxSession, timeoutMs?: number, identity?: {
|
|
140
|
+
sandboxGroupId?: string | null;
|
|
141
|
+
}): Promise<void>;
|
|
115
142
|
export declare function safeSnapshotError(error: unknown): {
|
|
116
143
|
errorClass: "SnapshotOperationError";
|
|
117
144
|
errorCode: "snapshot_operation_failed";
|
|
@@ -31,6 +31,8 @@ export type RoutingWiringServices = {
|
|
|
31
31
|
established: EstablishedSandboxSession;
|
|
32
32
|
leaseEpoch: number;
|
|
33
33
|
}) => void;
|
|
34
|
+
/** Cancel bounded capture waits with the owning turn activity. */
|
|
35
|
+
waitSignal?: AbortSignal;
|
|
34
36
|
};
|
|
35
37
|
/** Worker-turn routing may final-ack streamed command output, so it must always
|
|
36
38
|
* carry the turn's durable frontier journal. Non-turn helpers may still omit it
|
|
@@ -66,6 +68,8 @@ export type RoutingWiringIds = {
|
|
|
66
68
|
* manifest environment variables." Optional → the resolver defaults to `{}`.
|
|
67
69
|
*/
|
|
68
70
|
environment?: Record<string, string>;
|
|
71
|
+
/** Attempt-local values projected only onto Connected Machine child execs. */
|
|
72
|
+
transientExecEnvironment?: () => Readonly<Record<string, string>>;
|
|
69
73
|
/**
|
|
70
74
|
* Stage D machine-primary: PIN the already-established turn SelfhostedSession
|
|
71
75
|
* (the `established` arg's session) for THIS machine pointer `(sandboxId, epoch)`
|
|
@@ -146,6 +150,8 @@ export type SelfhostedTurnSessionArgs = {
|
|
|
146
150
|
* the manifest), threaded so the SDK's per-turn provided-session env delta is
|
|
147
151
|
* empty. */
|
|
148
152
|
environment: Record<string, string>;
|
|
153
|
+
/** Attempt-local values projected only onto this machine's child execs. */
|
|
154
|
+
transientExecEnvironment?: () => Readonly<Record<string, string>>;
|
|
149
155
|
/** The session working directory (per-session pointer). Null ⇒ workspace_root. */
|
|
150
156
|
workingDir: string | null;
|
|
151
157
|
};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import type { Observability } from "@opengeni/observability";
|
|
2
|
-
import type { WorkerLifecycleState } from "./http";
|
|
2
|
+
import type { WorkerLifecycleState } from "./http.js";
|
|
3
3
|
export declare function constructWithOwnedConnection<Connection, Result>(connect: () => Promise<Connection>, construct: (connection: Connection) => Promise<Result>, close: (connection: Connection) => Promise<void>): Promise<Result>;
|
|
4
4
|
export type WorkerRunTarget = {
|
|
5
5
|
run(): Promise<void>;
|
|
6
6
|
shutdown(): void;
|
|
7
7
|
};
|
|
8
|
+
/** One process may poll several disjoint Temporal queues, but it still has one
|
|
9
|
+
* host lifecycle. Start and stop every poller as a unit; a failed poller drains
|
|
10
|
+
* its siblings and preserves the original failure. */
|
|
11
|
+
export declare function combineWorkerRunTargets(targets: readonly WorkerRunTarget[]): WorkerRunTarget;
|
|
8
12
|
export type WorkerServiceLifecycle = {
|
|
9
13
|
state(): WorkerLifecycleState;
|
|
10
14
|
run(): Promise<void>;
|
|
11
|
-
drain(reason?: string):
|
|
15
|
+
drain(reason?: string): boolean;
|
|
12
16
|
close(): Promise<void>;
|
|
13
17
|
};
|
|
14
18
|
export declare function createWorkerServiceLifecycle(input: {
|