@opengeni/worker-bundle 2.0.1 → 2.0.3-canary.36199476632001

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 (63) hide show
  1. package/dist/activities/agent-turn/agent-build.d.ts +2 -0
  2. package/dist/activities/agent-turn/code-search.d.ts +60 -0
  3. package/dist/activities/agent-turn/codex-capacity.d.ts +13 -0
  4. package/dist/activities/agent-turn/errors.d.ts +12 -1
  5. package/dist/activities/agent-turn/failure-settlement.d.ts +1 -1
  6. package/dist/activities/agent-turn/governance-model.d.ts +2 -0
  7. package/dist/activities/agent-turn/history.d.ts +2 -0
  8. package/dist/activities/agent-turn/media-artifacts.d.ts +5 -3
  9. package/dist/activities/agent-turn/session-title.d.ts +32 -2
  10. package/dist/activities/agent-turn/tool-environment.d.ts +4 -0
  11. package/dist/activities/context-compaction.d.ts +10 -2
  12. package/dist/activities/knowledge-indexing.d.ts +19 -0
  13. package/dist/activities/retained-screenshots.d.ts +7 -2
  14. package/dist/activities/sandbox-lease.d.ts +3 -4
  15. package/dist/{activities-control-QA6OLRQY.js → activities-control-I72CRMAE.js} +283 -35
  16. package/dist/activities-control-I72CRMAE.js.map +1 -0
  17. package/dist/{activities-turn-YVVKCGAK.js → activities-turn-CSDKK4N3.js} +531 -77
  18. package/dist/activities-turn-CSDKK4N3.js.map +1 -0
  19. package/dist/artifact-outbox-entry.js +3 -0
  20. package/dist/artifact-outbox-entry.js.map +1 -1
  21. package/dist/{chunk-M3NVMF2V.js → chunk-7M6G2SCF.js} +172 -17
  22. package/dist/chunk-7M6G2SCF.js.map +1 -0
  23. package/dist/{chunk-I7HKKMUJ.js → chunk-DSPP6CZL.js} +48 -3
  24. package/dist/chunk-DSPP6CZL.js.map +1 -0
  25. package/dist/index.js +10 -5
  26. package/dist/index.js.map +1 -1
  27. package/dist/observability-metrics.d.ts +11 -1
  28. package/dist/sandbox-resume.d.ts +46 -0
  29. package/dist/workflow-bundle.js +80 -2
  30. package/dist/workflows/session.d.ts +30 -0
  31. package/package.json +20 -19
  32. package/src/activities/agent-turn/agent-build.ts +4 -0
  33. package/src/activities/agent-turn/code-search.ts +275 -0
  34. package/src/activities/agent-turn/codex-capacity.ts +37 -2
  35. package/src/activities/agent-turn/compaction-prep.ts +52 -16
  36. package/src/activities/agent-turn/errors.ts +67 -4
  37. package/src/activities/agent-turn/failure-settlement.ts +40 -8
  38. package/src/activities/agent-turn/governance-model.ts +17 -1
  39. package/src/activities/agent-turn/history.ts +14 -1
  40. package/src/activities/agent-turn/media-artifacts.ts +2 -1
  41. package/src/activities/agent-turn/run.ts +4 -0
  42. package/src/activities/agent-turn/sandbox-establish.ts +12 -1
  43. package/src/activities/agent-turn/sandbox-runtime.ts +25 -9
  44. package/src/activities/agent-turn/session-title.ts +73 -3
  45. package/src/activities/agent-turn/stream-attempt.ts +27 -15
  46. package/src/activities/agent-turn/tool-environment.ts +65 -0
  47. package/src/activities/context-compaction.ts +49 -14
  48. package/src/activities/knowledge-indexing.ts +240 -15
  49. package/src/activities/retained-screenshots.ts +82 -11
  50. package/src/activities/sandbox-lease.ts +141 -21
  51. package/src/activities/scheduled-tasks.ts +18 -2
  52. package/src/activity-services.ts +16 -4
  53. package/src/editable-artifact-hint-broker.ts +3 -0
  54. package/src/index.ts +2 -2
  55. package/src/observability-metrics.ts +70 -1
  56. package/src/personal-github-git-credentials.ts +2 -0
  57. package/src/sandbox-resume.ts +211 -5
  58. package/src/workflows/activities.ts +14 -1
  59. package/src/workflows/session.ts +102 -6
  60. package/dist/activities-control-QA6OLRQY.js.map +0 -1
  61. package/dist/activities-turn-YVVKCGAK.js.map +0 -1
  62. package/dist/chunk-I7HKKMUJ.js.map +0 -1
  63. package/dist/chunk-M3NVMF2V.js.map +0 -1
@@ -63,6 +63,8 @@ export type BuildTurnAgentDeps = {
63
63
  connectorActionPolicy: ConnectorActionPolicyHooks;
64
64
  trigger: ClaimTurnOk["trigger"];
65
65
  preparationIndependentToolNames: readonly string[];
66
+ /** The attempt's tool catalog includes the Jev-backed code_search tool. */
67
+ codeSearchAvailable: boolean;
66
68
  videoGenerationAcceptancesByCallId: Map<string, {
67
69
  operationId: string;
68
70
  requestDigest: string;
@@ -0,0 +1,60 @@
1
+ import type { AttemptToolDefinition } from "@opengeni/codemode";
2
+ import { type Settings } from "@opengeni/config";
3
+ import { JevCircuitBreaker, type CodeSearchWorkspace } from "@opengeni/jev";
4
+ import type { Observability } from "@opengeni/observability";
5
+ import { type SandboxChannelAService } from "@opengeni/runtime/sandbox";
6
+ /**
7
+ * One breaker per worker process. Repeated Jev outages (including an exhausted
8
+ * account) make `code_search` calls on this worker fail at once for a cooldown
9
+ * instead of each running a full retry cycle. The breaker never changes which
10
+ * tools a turn is offered: the tool list and instructions are the start of the
11
+ * model's cached prompt, and sessions move between workers whose breakers
12
+ * disagree.
13
+ */
14
+ export declare const codeSearchCircuitBreaker: JevCircuitBreaker;
15
+ type CodeSearchChannel = Pick<SandboxChannelAService, "codeSearchRipgrep" | "codeSearchPathKinds" | "fsRead">;
16
+ /** Adapt the turn's sandbox or Connected Machine to the code search engine. */
17
+ export declare function codeSearchWorkspaceFromChannel(channel: CodeSearchChannel): CodeSearchWorkspace;
18
+ /** Jev work done by one completed `code_search` call, for per-workspace usage records. */
19
+ export type CodeSearchUsage = {
20
+ operationId: string;
21
+ jevRequests: number;
22
+ jevInputTokens: number;
23
+ jevCostUsd: number;
24
+ };
25
+ /**
26
+ * The model-facing `code_search` tool. Jev scores candidates inside the worker;
27
+ * the sandbox only runs read-only ripgrep and file reads, so the Jev key never
28
+ * leaves this process. A Jev failure is reported to the model instead of
29
+ * degrading to keyword-only ranking, which lowered answer quality in testing.
30
+ */
31
+ export declare function createCodeSearchAttemptToolDefinition(input: {
32
+ settings: Pick<Settings, "jevApiKey" | "jevBaseUrl" | "jevModel" | "jevRequestTimeoutMs">;
33
+ apiKey: string;
34
+ workspace: () => Promise<CodeSearchWorkspace>;
35
+ observability: Observability;
36
+ /** Records Jev usage against the workspace. Failures are logged, never surfaced. */
37
+ recordUsage?: (usage: CodeSearchUsage) => Promise<void>;
38
+ breaker?: JevCircuitBreaker;
39
+ fetch?: typeof fetch;
40
+ }): AttemptToolDefinition;
41
+ /**
42
+ * The `code_search` definition for one turn, or none. It is offered only when
43
+ * the session's frozen decision and the deployment enable it, a usable Jev key
44
+ * exists, and the turn has compute that can run its POSIX shell commands (not
45
+ * a Windows Connected Machine). Every input is durable, so the tool list stays
46
+ * the same from turn to turn and on every worker. Transient Jev health never
47
+ * hides the tool; the breaker only refuses calls.
48
+ */
49
+ export declare function codeSearchToolDefinitions(input: {
50
+ enabled: boolean;
51
+ settings: Pick<Settings, "jevApiKey" | "jevBaseUrl" | "jevModel" | "jevRequestTimeoutMs">;
52
+ backend: Settings["sandboxBackend"];
53
+ /** The turn's Connected Machine workspace root, when a machine is primary. */
54
+ machineWorkspaceRoot?: string | null;
55
+ observability: Observability;
56
+ workspace: () => Promise<CodeSearchWorkspace>;
57
+ recordUsage?: (usage: CodeSearchUsage) => Promise<void>;
58
+ breaker?: JevCircuitBreaker;
59
+ }): AttemptToolDefinition[];
60
+ export {};
@@ -1,8 +1,21 @@
1
1
  import { type Settings } from "@opengeni/config";
2
2
  import type { TurnActivityServices as ActivityServices, RunAgentTurnInput, RunAgentTurnResult } from "../types.js";
3
3
  import { createTurnCredentialLeases } from "./credential-leases.js";
4
+ import { type LogThrottle } from "@opengeni/observability";
4
5
  import type { ClaimTurnOk } from "./claim.js";
5
6
  import type { AttemptIdentityState, BillingState, ClaimedResult, EventingState, ProviderTurnState, TurnControlState } from "./turn-context.js";
7
+ /** The eligible-pool gauge and `opengeni_codex_pool_low_total` stay per turn;
8
+ * the warning line is the first observation per workspace pool depth, then at
9
+ * most one per interval with the count it hid. The public log projection drops
10
+ * the identifiers and counts, so the closed `reason` keeps the depth visible. */
11
+ export declare const CODEX_POOL_LOW_WARNING_INTERVAL_MS: number;
12
+ export declare function warnCodexPoolLow(observability: Pick<ActivityServices["observability"], "warn">, input: {
13
+ workspaceKey: string;
14
+ workspaceId: string;
15
+ eligibleCount: number;
16
+ connectedCount: number;
17
+ depth: "zero" | "one";
18
+ }, throttle?: LogThrottle): void;
6
19
  export type CapacityPhaseDeps = {
7
20
  input: RunAgentTurnInput;
8
21
  settings: Settings;
@@ -1,4 +1,4 @@
1
- import { type CompactionProviderRejection, type MaterializationVerificationDiagnostic } from "@opengeni/runtime";
1
+ import { type CompactionProviderRejection, type MaterializationVerificationDiagnostic, type ProviderQuotaExhaustion, type ProviderQuotaScope } from "@opengeni/runtime";
2
2
  import { type McpTransportRequestFailureDiagnostic } from "@opengeni/runtime/mcp-network";
3
3
  import { ApplicationFailure } from "@temporalio/activity";
4
4
  import type { CodexAccountStatus } from "@opengeni/db";
@@ -168,6 +168,7 @@ export declare function compactionFailureTurnEventPayload(error: unknown, overri
168
168
  recovery: "user_message";
169
169
  compacted: false;
170
170
  providerRejection?: CompactionProviderRejection;
171
+ quotaScope?: ProviderQuotaScope;
171
172
  };
172
173
  export declare function isCompactionSummaryFailure(error: unknown): boolean;
173
174
  export declare function shouldRecoverCompactionProviderFailure(error: unknown): boolean;
@@ -235,6 +236,15 @@ export declare function collectErrorStrings(value: unknown, seen?: WeakSet<objec
235
236
  export declare const STATUSLESS_UPSTREAM_CONNECTIVITY_MESSAGE = "unable to connect. is the computer able to access the url?";
236
237
  export declare function isExactStatuslessUpstreamConnectivityMessage(message: string): boolean;
237
238
  export declare function isTransientProviderError(error: unknown): boolean;
239
+ /**
240
+ * Recognize an exhausted API-key provider quota (a daily or monthly allowance,
241
+ * a free-tier day cap, or an account out of credits) as distinct from an
242
+ * ordinary per-minute rate limit. Retrying within the bounded same-turn budget
243
+ * cannot succeed, so the turn fails promptly instead. Subscription transports
244
+ * own their quota semantics through credential rotation and durable capacity
245
+ * waits, so a Codex or SuperGrok transport error never classifies here.
246
+ */
247
+ export declare function classifyProviderQuotaExhaustionError(error: unknown): ProviderQuotaExhaustion | null;
238
248
  export type XaiCredentialFailure = {
239
249
  kind: "auth" | "forbidden" | "rate_limit";
240
250
  cooldownMs: number | null;
@@ -271,6 +281,7 @@ declare function baseAgentRunFailurePayload(error: unknown, options?: {
271
281
  historyPersistenceStage?: MandatoryHistoryPersistenceStage;
272
282
  mcpTransportDiagnostic?: McpTransportRequestFailureDiagnostic;
273
283
  materializationDiagnostic?: MaterializationVerificationDiagnostic;
284
+ quotaScope?: ProviderQuotaScope;
274
285
  };
275
286
  export type CodexCredentialFailure = {
276
287
  kind: "auth" | "forbidden" | "rate_limit" | "quota";
@@ -1,4 +1,4 @@
1
- import type { Settings } from "@opengeni/config";
1
+ import { type Settings } from "@opengeni/config";
2
2
  import type { TurnActivityServices as ActivityServices, RunAgentTurnInput, RunAgentTurnResult } from "../types.js";
3
3
  import { createTurnCredentialLeases } from "./credential-leases.js";
4
4
  import { createTurnHistorySink } from "./history-sink.js";
@@ -37,6 +37,8 @@ export type GovernanceModelOk = {
37
37
  rigVersion: NonNullable<Awaited<ReturnType<typeof materializeRigVersionForAttempt>>>["version"] | null;
38
38
  rigName: string | null;
39
39
  agentHumanInputEnabled: boolean;
40
+ /** Deployment and workspace allow the Jev-backed code_search tool. */
41
+ codeSearchEnabled: boolean;
40
42
  workspaceAgentInstructions: string | null | undefined;
41
43
  workspaceGovernance: ReturnType<typeof renderWorkspaceGovernanceContext>;
42
44
  structuredWorkspacePolicyActive: boolean;
@@ -49,6 +49,8 @@ export declare function pendingToolCallFromSdkEvent(event: unknown): {
49
49
  } | null;
50
50
  /** Tools whose intentional visual result must survive inline-media sanitization. */
51
51
  export declare function toolCallProducesRetainableSessionImage(name: string | null): boolean;
52
+ /** Browser interactions can carry an image block, including opt-in observe frames. */
53
+ export declare function retainableBrowserScreenshotToolCall(name: string | null): boolean;
52
54
  export declare function completedToolCallFromSdkEvent(event: unknown): {
53
55
  callId: string;
54
56
  resultItem: Record<string, unknown>;
@@ -1,5 +1,6 @@
1
1
  import { type CodemodeTokenWriterSession, type RetainableSessionImageOutputHook, type TurnToolCancellationFence } from "@opengeni/runtime";
2
2
  import type { Settings } from "@opengeni/config";
3
+ import type { RetainedSessionScreenshotKind } from "@opengeni/contracts";
3
4
  import type { ResumedTurnSandbox } from "../../sandbox-resume.js";
4
5
  import type { SharedActivityServices } from "../types.js";
5
6
  import { type GeneratedImageOutput, type GeneratedImageReceipt } from "../generated-images.js";
@@ -35,7 +36,7 @@ export declare class TurnMediaArtifacts {
35
36
  readonly retainedScreenshotReceiptsByCallId: Map<string, {
36
37
  available: true;
37
38
  artifactId: string;
38
- kind: "assistant_completion" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
39
+ kind: "assistant_completion" | "browser_screenshot" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
39
40
  contentType: string;
40
41
  originalBytes: number;
41
42
  sha256: string;
@@ -68,7 +69,7 @@ export declare class TurnMediaArtifacts {
68
69
  artifact: {
69
70
  available: true;
70
71
  artifactId: string;
71
- kind: "assistant_completion" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
72
+ kind: "assistant_completion" | "browser_screenshot" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
72
73
  contentType: string;
73
74
  originalBytes: number;
74
75
  sha256: string;
@@ -98,7 +99,7 @@ export declare class TurnMediaArtifacts {
98
99
  artifact: {
99
100
  available: true;
100
101
  artifactId: string;
101
- kind: "assistant_completion" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
102
+ kind: "assistant_completion" | "browser_screenshot" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
102
103
  contentType: string;
103
104
  originalBytes: number;
104
105
  sha256: string;
@@ -128,6 +129,7 @@ export declare class TurnMediaArtifacts {
128
129
  sandboxFileDownloadBackend: Settings["sandboxBackend"];
129
130
  nativeImageGenerationRetention: NativeImageGenerationRetention | null;
130
131
  readonly retainedSessionImageCallIds: Set<string>;
132
+ readonly retainedSessionImageKindsByCallId: Map<string, RetainedSessionScreenshotKind>;
131
133
  constructor(deps: TurnMediaArtifactDeps);
132
134
  rememberGeneratedImageCreatedThisTurn: (receipt: GeneratedImageReceipt) => void;
133
135
  private prepareGeneratedImageDownload;
@@ -1,6 +1,7 @@
1
1
  import type { AttemptToolDefinition } from "@opengeni/codemode";
2
- import type { GeneratedSessionTitle } from "@opengeni/runtime";
3
- import { type FirstPartyMcpToolName, type Permission, type ToolRef } from "@opengeni/contracts";
2
+ import { type ModelCapabilitiesV1 } from "@opengeni/config";
3
+ import type { GeneratedSessionTitle, GenerateSessionTitleOptions, OpenGeniRuntime } from "@opengeni/runtime";
4
+ import { ReasoningEffort, type FirstPartyMcpToolName, type Permission, type ToolRef } from "@opengeni/contracts";
4
5
  export declare const SESSION_TITLE_MODEL_TOOL_NAME = "opengeni__set_session_title";
5
6
  export declare function shouldRequestMissingSessionTitle(input: {
6
7
  title: string | null;
@@ -8,11 +9,21 @@ export declare function shouldRequestMissingSessionTitle(input: {
8
9
  firstPartyMcpTools: readonly FirstPartyMcpToolName[];
9
10
  firstPartyMcpPermissions: readonly Permission[] | null;
10
11
  }): boolean;
12
+ /**
13
+ * Whether the turn's route can afford a model request spent only on a title.
14
+ * The managed OpenRouter free route draws on one deployment-wide per-minute
15
+ * and per-day request quota that users' turns need, so an untitled session on
16
+ * it gets no title sidecar and no title tool (whose call would cost a
17
+ * follow-up request). Clients keep showing the prompt preview, and a later
18
+ * turn on another route titles the session.
19
+ */
20
+ export declare function routeAllowsSessionTitleRequests(resolvedModel: ReturnType<OpenGeniRuntime["resolveTurnModel"]>): boolean;
11
21
  export declare function sessionTitleToolPlan(input: {
12
22
  tools: readonly ToolRef[];
13
23
  selectedFirstPartyMcpTools: readonly FirstPartyMcpToolName[];
14
24
  shouldRequestTitle: boolean;
15
25
  parallelGenerationAvailable: boolean;
26
+ routeAllowsTitleRequests: boolean;
16
27
  }): {
17
28
  promoteTitleTool: boolean;
18
29
  generateTitleInParallel: boolean;
@@ -20,6 +31,25 @@ export declare function sessionTitleToolPlan(input: {
20
31
  preparationIndependentToolNames: string[];
21
32
  };
22
33
  export declare const PARALLEL_SESSION_TITLE_TIMEOUT_MS = 15000;
34
+ /**
35
+ * The lowest reasoning effort the resolved model can run, for the auxiliary
36
+ * title request only. A title needs no deliberation, and a provider default
37
+ * effort can use most of the output budget before any visible text. Returns
38
+ * undefined when the model declares no runnable reasoning control, so the
39
+ * request carries no reasoning parameter.
40
+ */
41
+ export declare function sessionTitleReasoningEffort(capabilities: Pick<ModelCapabilitiesV1, "reasoning"> | undefined): ReasoningEffort | undefined;
42
+ /**
43
+ * Options for the parallel title request. It uses the turn's resolved
44
+ * provider and credential authority, but its own lowest runnable reasoning
45
+ * effort rather than the turn's effort.
46
+ */
47
+ export declare function sessionTitleGenerationOptions(input: {
48
+ resolvedModel: ReturnType<OpenGeniRuntime["resolveTurnModel"]>;
49
+ modelName: string;
50
+ serviceTier: GenerateSessionTitleOptions["serviceTier"] | null | undefined;
51
+ signal: AbortSignal;
52
+ }): GenerateSessionTitleOptions;
23
53
  export type ParallelSessionTitleGeneration = {
24
54
  finish: () => Promise<GeneratedSessionTitle | null>;
25
55
  cancel: () => Promise<void>;
@@ -46,6 +46,7 @@ export type PrepareTurnToolRuntimeDeps = {
46
46
  turnExecutionPolicy: ClaimTurnOk["turnExecutionPolicy"];
47
47
  trigger: ClaimTurnOk["trigger"];
48
48
  runSettings: GovernanceModelOk["runSettings"];
49
+ resolvedModel: GovernanceModelOk["resolvedModel"];
49
50
  lazyToolTransport: GovernanceModelOk["lazyToolTransport"];
50
51
  turnTools: ReturnType<typeof withFirstPartyTools>;
51
52
  connectionScope: {
@@ -60,6 +61,8 @@ export type PrepareTurnToolRuntimeDeps = {
60
61
  credentialSubjectId: ClaimTurnOk["credentialSubjectId"];
61
62
  interactionInterventionResume: ClaimTurnOk["interactionInterventionResume"];
62
63
  runWorkspaceMutationForSandbox: SandboxTurnRuntime["runWorkspaceMutationForSandbox"];
64
+ /** Deployment and workspace allow the Jev-backed code_search tool. */
65
+ codeSearchEnabled: boolean;
63
66
  throwIfWorkerShuttingDown: () => void;
64
67
  throwIfTurnCancelled: () => void;
65
68
  };
@@ -162,6 +165,7 @@ export declare function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps)
162
165
  generateSessionTitleInParallel: boolean;
163
166
  postToolPreparationStartedAt: number;
164
167
  preparationIndependentToolNames: string[];
168
+ codeSearchAvailable: boolean;
165
169
  skillCatalog: {
166
170
  id: string;
167
171
  name: string;
@@ -1,5 +1,5 @@
1
1
  import { type Database } from "@opengeni/db";
2
- import { type CompactionItem, type CompactionProviderRejection } from "@opengeni/runtime";
2
+ import { prepareCompactionPromptInput, type CompactionItem, type CompactionProviderRejection } from "@opengeni/runtime";
3
3
  import { type Settings } from "@opengeni/config";
4
4
  import type { SessionEvent } from "@opengeni/contracts";
5
5
  export type MaybeCompactResult = {
@@ -28,7 +28,10 @@ export type MaybeCompactResult = {
28
28
  * Codex, call Codex `/codex/responses` with `compaction_trigger` and persist the
29
29
  * opaque compaction item. Fail closed — never silently fall back to portable.
30
30
  */
31
- export type CompactionSummarizer = (settings: Settings, input: CompactionItem[]) => Promise<string>;
31
+ export type CompactionSummarizer = ((settings: Settings, input: CompactionItem[]) => Promise<string>) & {
32
+ /** Model-visible instructions and tool schemas outside the history estimate. */
33
+ estimatePrefixTokens?: () => number;
34
+ };
32
35
  /** Returns the opaque Codex remote compaction v2 item. */
33
36
  export type RemoteCompactionV2Requester = (settings: Settings, input: CompactionItem[]) => Promise<CompactionItem>;
34
37
  export declare function maybeCompactContext(db: Database, settings: Settings, scope: {
@@ -86,5 +89,10 @@ export declare function settleFailedContextCompactionLandmark(db: Database, scop
86
89
  }): Promise<Extract<MaybeCompactResult, {
87
90
  compacted: false;
88
91
  }>>;
92
+ export declare function summarizeWithCodexOverflowTrimming(summarize: CompactionSummarizer, settings: Settings, activeHistory: CompactionItem[]): Promise<{
93
+ summaryBody: string;
94
+ preparation: ReturnType<typeof prepareCompactionPromptInput>;
95
+ providerCalls: number;
96
+ }>;
89
97
  export declare function isContextWindowExceeded(error: unknown, seen?: WeakSet<object>): boolean;
90
98
  export declare function isExactContextLengthExceeded(error: unknown, seen?: WeakSet<object>): boolean;
@@ -1,5 +1,24 @@
1
1
  import type { DocumentServices } from "@opengeni/documents";
2
2
  import type { ControlActivityServices } from "./types.js";
3
+ /** The configured monthly indexed-chunk limit, not a provider failure. */
4
+ export declare class KnowledgeIndexUsageLimitError extends Error {
5
+ constructor();
6
+ }
7
+ export type KnowledgeIndexFailureStage = "embedding" | "processing";
8
+ /**
9
+ * Content-free classification for a deferred Knowledge index batch. Only
10
+ * protocol constants, an HTTP status, and a PostgreSQL SQLSTATE are retained;
11
+ * provider messages, bodies, SQL, and identifiers never leave the process.
12
+ * Outside the embedding call, only a PostgreSQL error in the cause chain is
13
+ * attributed to the database; any other failure stays a worker failure.
14
+ */
15
+ export declare function knowledgeIndexFailureDiagnostic(stage: KnowledgeIndexFailureStage, error: unknown): {
16
+ errorClass: "KnowledgeIndexOperationError";
17
+ errorCode: "knowledge_index_usage_limit_reached" | "knowledge_index_embedding_failed" | "knowledge_index_persistence_failed" | "knowledge_index_failed";
18
+ origin: "worker" | "db";
19
+ status?: number;
20
+ sqlState?: string;
21
+ };
3
22
  export declare function createKnowledgeIndexingActivities(services: () => Promise<ControlActivityServices>, resolveDocumentServices?: () => Promise<DocumentServices>): {
4
23
  indexKnowledge: () => Promise<{
5
24
  completed: number;
@@ -1,4 +1,4 @@
1
- import { type RetainedArtifactMetadata, type RetainedOutputUnavailableReason } from "@opengeni/contracts";
1
+ import { type RetainedArtifactMetadata, type RetainedOutputUnavailableReason, type RetainedSessionScreenshotKind } from "@opengeni/contracts";
2
2
  import { type Database } from "@opengeni/db";
3
3
  import { type ObjectStorage } from "@opengeni/storage";
4
4
  export type TypedScreenshotToolOutput = {
@@ -68,6 +68,7 @@ export declare function retainedScreenshotIdentity(input: {
68
68
  attemptId: string;
69
69
  toolCallId: string;
70
70
  toolOutputId: string;
71
+ kind?: RetainedSessionScreenshotKind | undefined;
71
72
  }): {
72
73
  artifactId: string;
73
74
  settlementKey: string;
@@ -80,8 +81,9 @@ export declare function unavailableRetainedSessionImage(input: {
80
81
  toolCallId: string;
81
82
  toolOutputId: string;
82
83
  reason: RetainedOutputUnavailableReason;
84
+ kind?: RetainedSessionScreenshotKind | undefined;
83
85
  }): RetainedArtifactMetadata;
84
- export declare function retainComputerScreenshot(input: {
86
+ export declare function retainSessionScreenshot(input: {
85
87
  db: Database;
86
88
  objectStorage: ObjectStorage | null;
87
89
  accountId: string;
@@ -90,10 +92,13 @@ export declare function retainComputerScreenshot(input: {
90
92
  turnId: string;
91
93
  attemptId: string;
92
94
  output: TypedScreenshotToolOutput;
95
+ kind?: RetainedSessionScreenshotKind | undefined;
93
96
  now?: Date;
94
97
  retentionMs?: number;
95
98
  workspaceQuotaBytes?: number;
96
99
  }): Promise<RetainedArtifactMetadata>;
100
+ /** Existing computer callers keep their stable entry point. */
101
+ export declare const retainComputerScreenshot: typeof retainSessionScreenshot;
97
102
  /** Replace only new screenshot bytes with a compact receipt before first persistence. */
98
103
  export declare function compactRetainedScreenshotHistory(history: Array<Record<string, unknown>>, receiptsByCallId: ReadonlyMap<string, RetainedArtifactMetadata>): Array<Record<string, unknown>>;
99
104
  /** Collect durable screenshot receipts before their provider-only expansion. */
@@ -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
- /** Viewer-only boxes force-drained because their workspace is over a limit
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>, workspaceId?: string) => 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;
@@ -208,4 +207,4 @@ export declare function sandboxDrainReason(lease: Pick<LeaseSnapshot, "rotationR
208
207
  * draining until its adapter can prove termination. A truly instance-less or
209
208
  * `none`-backed row is a no-op.
210
209
  */
211
- 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): Promise<ProviderTerminationOutcome>;
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>, workspaceId?: string, beforeProviderStop?: () => Promise<void>): Promise<ProviderTerminationOutcome>;