@opengeni/worker-bundle 1.0.0-canary.1 → 1.0.1-canary.1

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 (26) hide show
  1. package/dist/activities/agent-turn/errors.d.ts +6 -0
  2. package/dist/activities/agent-turn/finalization-monitor.d.ts +17 -0
  3. package/dist/activities/agent-turn/finalization.d.ts +1 -1
  4. package/dist/activities/agent-turn/quiescence.d.ts +1 -0
  5. package/dist/activities/agent-turn/turn-context.d.ts +2 -0
  6. package/dist/{activities-control-HMFGSKC5.js → activities-control-O5U6OLT2.js} +4 -19
  7. package/dist/{activities-control-HMFGSKC5.js.map → activities-control-O5U6OLT2.js.map} +1 -1
  8. package/dist/{activities-turn-AP67JADS.js → activities-turn-OAPNO2IH.js} +167 -116
  9. package/dist/activities-turn-OAPNO2IH.js.map +1 -0
  10. package/dist/{chunk-CYITU5UH.js → chunk-GENYJQ5B.js} +18 -1
  11. package/dist/{chunk-CYITU5UH.js.map → chunk-GENYJQ5B.js.map} +1 -1
  12. package/dist/index.js +1 -1
  13. package/package.json +19 -19
  14. package/src/activities/agent-turn/claim.ts +1 -0
  15. package/src/activities/agent-turn/errors.ts +21 -0
  16. package/src/activities/agent-turn/finalization-monitor.ts +121 -0
  17. package/src/activities/agent-turn/finalization.ts +52 -17
  18. package/src/activities/agent-turn/quiescence.ts +3 -0
  19. package/src/activities/agent-turn/run.ts +1 -39
  20. package/src/activities/agent-turn/skill-selection.ts +1 -0
  21. package/src/activities/agent-turn/tool-environment.ts +10 -2
  22. package/src/activities/agent-turn/turn-context.ts +3 -0
  23. package/src/activities/workflow-wake.ts +2 -17
  24. package/dist/activities/agent-turn/knowledge-sources.d.ts +0 -20
  25. package/dist/activities-turn-AP67JADS.js.map +0 -1
  26. package/src/activities/agent-turn/knowledge-sources.ts +0 -86
@@ -1,3 +1,4 @@
1
+ import { type MaterializationVerificationDiagnostic } from "@opengeni/runtime";
1
2
  import { type McpTransportRequestFailureDiagnostic } from "@opengeni/runtime/mcp-network";
2
3
  import { ApplicationFailure } from "@temporalio/activity";
3
4
  import type { CodexAccountStatus } from "@opengeni/db";
@@ -227,6 +228,9 @@ export type XaiCredentialFailure = {
227
228
  export declare function classifyXaiCredentialFailure(error: unknown): XaiCredentialFailure | null;
228
229
  export declare function agentRunFailurePayload(error: unknown, options?: {
229
230
  isCodexTurn?: boolean;
231
+ }): ReturnType<typeof baseAgentRunFailurePayload>;
232
+ declare function baseAgentRunFailurePayload(error: unknown, options?: {
233
+ isCodexTurn?: boolean;
230
234
  }): {
231
235
  error: string;
232
236
  code?: string;
@@ -246,6 +250,7 @@ export declare function agentRunFailurePayload(error: unknown, options?: {
246
250
  database?: Record<string, string>;
247
251
  historyPersistenceStage?: MandatoryHistoryPersistenceStage;
248
252
  mcpTransportDiagnostic?: McpTransportRequestFailureDiagnostic;
253
+ materializationDiagnostic?: MaterializationVerificationDiagnostic;
249
254
  };
250
255
  export type CodexCredentialFailure = {
251
256
  kind: "auth" | "forbidden" | "rate_limit" | "quota";
@@ -285,3 +290,4 @@ export declare function codexUsageLimitFailurePayload(info: {
285
290
  detail?: string;
286
291
  };
287
292
  export declare const CODEX_USAGE_LIMIT_MAX_RESUME_MS: number;
293
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { Observability } from "@opengeni/observability";
2
+ import type { TurnHeartbeatDetails } from "../../op-journal.js";
3
+ export declare const TURN_FINALIZATION_STAGES: readonly ["tool_writers", "credential_renewals", "credential_cleanup", "quiescence_receipt", "event_flush", "provider_leases", "workspace_capture", "tool_close", "sandbox_provisioning", "sandbox_rotation", "workspace_snapshot", "sandbox_release"];
4
+ export type TurnFinalizationStage = (typeof TURN_FINALIZATION_STAGES)[number];
5
+ /** Starts only after agent execution ends. A cleanup-stage deadline never caps
6
+ * agent work and never detaches a physical writer to manufacture quiescence. */
7
+ export declare function startTurnFinalizationMonitor(input: {
8
+ observability: Observability;
9
+ details: TurnHeartbeatDetails;
10
+ heartbeat: (details: TurnHeartbeatDetails) => void;
11
+ terminateWorker: () => void;
12
+ timeoutMs?: number;
13
+ slowAfterMs?: number;
14
+ }): {
15
+ enter(next: TurnFinalizationStage): void;
16
+ stop(): void;
17
+ };
@@ -1,5 +1,5 @@
1
1
  import type { Settings } from "@opengeni/config";
2
- import type { currentActivityContext } from "../streaming.js";
2
+ import { type currentActivityContext } from "../streaming.js";
3
3
  import type { RunAgentTurnInput, TurnActivityServices as ActivityServices } from "../types.js";
4
4
  import { createModelCheckpointMemoryCollector } from "../../model-checkpoint-memory-collector.js";
5
5
  import { makeMachineOpObserver } from "../../observability-metrics.js";
@@ -88,6 +88,7 @@ export declare function drainAttemptOwnedSandboxWriters(input: {
88
88
  gitCredentialRenewals: readonly Pick<GitCredentialRenewalController, "stop">[];
89
89
  codemodeTokenRenewal: Pick<CodemodeTokenRenewalController, "stop"> | null;
90
90
  runCredentialRenewal: Pick<RunCredentialRenewalController, "stop"> | null;
91
+ onStage?: (stage: "tool_writers" | "credential_renewals") => void;
91
92
  }): Promise<void>;
92
93
  /** Persist the exact turn's second-stage release only after the caller has
93
94
  * crossed the physical writer boundary. This wait is intentionally independent
@@ -1,3 +1,4 @@
1
+ import type { TurnHeartbeatDetails } from "../../op-journal.js";
1
2
  import type { Settings } from "@opengeni/config";
2
3
  import type { CodexUsageHeaderSnapshot } from "@opengeni/codex";
3
4
  import type { AppendEventInput, ApplySessionTurnSettlementInput } from "@opengeni/db";
@@ -89,6 +90,7 @@ export type RenewalState = {
89
90
  publishedRunCredentialNotices: Set<string>;
90
91
  };
91
92
  export type EventingState = {
93
+ heartbeatDetails: TurnHeartbeatDetails | null;
92
94
  heartbeatTimer: ReturnType<typeof startActivityHeartbeat> | undefined;
93
95
  batcher: ReturnType<typeof createRuntimeBatcher> | null;
94
96
  preparedTools: Awaited<ReturnType<OpenGeniRuntime["prepareTools"]>> | null;
@@ -33,7 +33,7 @@ import {
33
33
  scheduledUserMessagePayload,
34
34
  withFirstPartyTools,
35
35
  workflowIdForSession
36
- } from "./chunk-CYITU5UH.js";
36
+ } from "./chunk-GENYJQ5B.js";
37
37
  import {
38
38
  inspectOpenSandboxKubernetesInventory,
39
39
  recordCreditBalanceGauges,
@@ -7173,6 +7173,7 @@ import {
7173
7173
  getWorkspaceControlEvent
7174
7174
  } from "@opengeni/db";
7175
7175
  import { publishDurableWorkspaceControlEvent } from "@opengeni/events";
7176
+ import { recordWorkflowWakeReconciliation } from "@opengeni/observability";
7176
7177
  var BATCH_SIZE = 1e3;
7177
7178
  var MAX_DELIVERIES_PER_ACTIVITY = 1e4;
7178
7179
  var MAX_TITLE_FANOUT_PER_ACTIVITY = 1e3;
@@ -7258,23 +7259,7 @@ function createWorkflowWakeActivities(services) {
7258
7259
  pendingAdmissionBlockers,
7259
7260
  exhaustedBatchLimit
7260
7261
  };
7261
- if (claimed > 0) {
7262
- service.observability.info("session workflow wake delivery reconciled", {
7263
- claimed,
7264
- signaled,
7265
- delivered,
7266
- pendingAdmission,
7267
- unconfirmed,
7268
- failed,
7269
- exhaustedBatchLimit,
7270
- ...Object.fromEntries(
7271
- Object.entries(pendingAdmissionBlockers).map(([blocker, count]) => [
7272
- `pendingAdmissionBlockers.${blocker}`,
7273
- count
7274
- ])
7275
- )
7276
- });
7277
- }
7262
+ recordWorkflowWakeReconciliation(service.observability, result);
7278
7263
  return result;
7279
7264
  }
7280
7265
  };
@@ -7319,4 +7304,4 @@ export {
7319
7304
  createControlActivities,
7320
7305
  createControlActivitiesFromServices
7321
7306
  };
7322
- //# sourceMappingURL=activities-control-HMFGSKC5.js.map
7307
+ //# sourceMappingURL=activities-control-O5U6OLT2.js.map