@opengeni/worker-bundle 2.0.3 → 2.1.0-canary.36239117573001

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 (51) 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/governance-model.d.ts +2 -0
  6. package/dist/activities/agent-turn/session-title.d.ts +32 -2
  7. package/dist/activities/agent-turn/tool-environment.d.ts +4 -0
  8. package/dist/activities/context-compaction.d.ts +10 -2
  9. package/dist/activities/knowledge-indexing.d.ts +19 -0
  10. package/dist/{activities-control-IVTL723D.js → activities-control-I72CRMAE.js} +81 -14
  11. package/dist/activities-control-I72CRMAE.js.map +1 -0
  12. package/dist/{activities-turn-EZEDZTEZ.js → activities-turn-CSDKK4N3.js} +425 -46
  13. package/dist/activities-turn-CSDKK4N3.js.map +1 -0
  14. package/dist/artifact-outbox-entry.js +3 -0
  15. package/dist/artifact-outbox-entry.js.map +1 -1
  16. package/dist/{chunk-JMO5ZUW3.js → chunk-7M6G2SCF.js} +159 -11
  17. package/dist/chunk-7M6G2SCF.js.map +1 -0
  18. package/dist/{chunk-I7HKKMUJ.js → chunk-DSPP6CZL.js} +48 -3
  19. package/dist/chunk-DSPP6CZL.js.map +1 -0
  20. package/dist/index.js +4 -4
  21. package/dist/index.js.map +1 -1
  22. package/dist/observability-metrics.d.ts +11 -1
  23. package/dist/sandbox-resume.d.ts +46 -0
  24. package/dist/workflow-bundle.js +77 -2
  25. package/dist/workflows/session.d.ts +30 -0
  26. package/package.json +20 -19
  27. package/src/activities/agent-turn/agent-build.ts +4 -0
  28. package/src/activities/agent-turn/code-search.ts +275 -0
  29. package/src/activities/agent-turn/codex-capacity.ts +37 -2
  30. package/src/activities/agent-turn/compaction-prep.ts +52 -16
  31. package/src/activities/agent-turn/errors.ts +59 -1
  32. package/src/activities/agent-turn/governance-model.ts +17 -1
  33. package/src/activities/agent-turn/run.ts +4 -0
  34. package/src/activities/agent-turn/sandbox-establish.ts +12 -1
  35. package/src/activities/agent-turn/session-title.ts +73 -3
  36. package/src/activities/agent-turn/stream-attempt.ts +14 -13
  37. package/src/activities/agent-turn/tool-environment.ts +65 -0
  38. package/src/activities/context-compaction.ts +49 -14
  39. package/src/activities/knowledge-indexing.ts +107 -9
  40. package/src/activities/scheduled-tasks.ts +18 -2
  41. package/src/activity-services.ts +16 -4
  42. package/src/editable-artifact-hint-broker.ts +3 -0
  43. package/src/index.ts +2 -2
  44. package/src/observability-metrics.ts +70 -1
  45. package/src/personal-github-git-credentials.ts +2 -0
  46. package/src/sandbox-resume.ts +205 -5
  47. package/src/workflows/session.ts +102 -6
  48. package/dist/activities-control-IVTL723D.js.map +0 -1
  49. package/dist/activities-turn-EZEDZTEZ.js.map +0 -1
  50. package/dist/chunk-I7HKKMUJ.js.map +0 -1
  51. package/dist/chunk-JMO5ZUW3.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { type SessionEventType } from "@opengeni/contracts";
2
2
  import type { SessionEventAppendPhaseObservation } from "@opengeni/db";
3
- import type { EventLogger } from "@opengeni/events";
3
+ import { type EventBusOptions, type EventLogger } from "@opengeni/events";
4
4
  import type { Observability } from "@opengeni/observability";
5
5
  import type { CompanyBrainContributionReceipt } from "./model-context-contributions.js";
6
6
  import { type OpenSandboxKubernetesInventory } from "./opensandbox-kubernetes-inventory.js";
@@ -39,6 +39,8 @@ export type TemporalTurnTaskQueueStats = {
39
39
  } | null;
40
40
  declare const CONTEXT_COMPACTION_TRIGGERS: readonly ["auto", "operator", "proactive", "overflow"];
41
41
  export type ContextCompactionTrigger = (typeof CONTEXT_COMPACTION_TRIGGERS)[number];
42
+ /** Logger plus the closed-label subscription-termination counter for NATS connections. */
43
+ export declare function observabilityEventBusOptions(observability: Observability): Pick<EventBusOptions, "logger" | "onSubscriptionTerminated">;
42
44
  export declare function observabilityEventLogger(observability: Observability): EventLogger;
43
45
  export declare function runtimeMetricsHooksForObservability(observability: Observability): RuntimeMetricsHooks;
44
46
  /**
@@ -422,4 +424,12 @@ export declare function modelCallAccountContext(input: {
422
424
  servingAccountHash: string;
423
425
  accountChangedFromPrevCall: boolean;
424
426
  };
427
+ export type CodeSearchCallOutcome = "completed" | "jev_unavailable" | "jev_rejected" | "workspace_unavailable" | "invalid_arguments" | "breaker_open" | "cancelled" | "failed";
428
+ /** One `code_search` tool call: outcome, wall time and the Jev work it used. */
429
+ export declare function recordCodeSearchCall(observability: Observability, input: {
430
+ outcome: CodeSearchCallOutcome;
431
+ durationSeconds: number;
432
+ jevRequests: number;
433
+ jevCostUsd: number;
434
+ }): void;
425
435
  export {};
@@ -43,6 +43,23 @@ export type SandboxResumeServices = {
43
43
  /** Test seam for the bounded command-readiness proof performed before an
44
44
  * attached provider box is handed to the agent. */
45
45
  verifyAttachedSandboxReadiness?: (established: EstablishedSandboxSession) => Promise<void>;
46
+ /** Test seam for the bounded command-readiness proof the elected spawner runs
47
+ * on its freshly created box before publishing the lease warm. Production
48
+ * uses {@link waitForSandboxExecReadiness} with the shared 60 s budget. */
49
+ verifySpawnedSandboxReadiness?: (established: EstablishedSandboxSession, identity: {
50
+ sandboxGroupId: string;
51
+ }) => Promise<void>;
52
+ /** Test seam for the jittered pause before the single fresh-box readiness
53
+ * replacement. Production uses {@link freshSandboxReadinessReplacementDelayMs}.
54
+ * It may be async so a test can observe the rolled-back lease in between. */
55
+ freshSandboxReadinessReplacementDelayMs?: () => number | Promise<number>;
56
+ /**
57
+ * The turn attempt's fresh-box readiness replacement budget. The lazy
58
+ * provisioner may call resumeBoxForTurn again after a typed lease
59
+ * supersession, so the turn creates the budget once and shares it with every
60
+ * call. Absent, the call gets its own single replacement.
61
+ */
62
+ freshSandboxReadinessReplacementBudget?: FreshSandboxReadinessReplacementBudget;
46
63
  /** Called only by the observer that wins the exact warm->cold loss CAS. */
47
64
  onSandboxLost?: (input: {
48
65
  sandboxGroupId: string;
@@ -145,6 +162,23 @@ export declare class SandboxSiblingWarmingTimeoutError extends SandboxWarmingTim
145
162
  instanceId?: string | null;
146
163
  });
147
164
  }
165
+ /** True only for a spawner readiness timeout whose unready fresh box is proven gone. */
166
+ export declare function isReplaceableFreshSandboxReadinessTimeout(error: unknown): boolean;
167
+ /**
168
+ * A burst of simultaneous turn starts can leave many freshly created provider
169
+ * boxes command-unready at once. The single replacement re-enters admission
170
+ * after a jittered pause so the replacement creates do not re-synchronize into
171
+ * the same burst. Bounded to [2 s, 10 s).
172
+ */
173
+ export declare const FRESH_SANDBOX_READINESS_REPLACEMENT_BASE_DELAY_MS = 2000;
174
+ export declare const FRESH_SANDBOX_READINESS_REPLACEMENT_JITTER_MS = 8000;
175
+ export declare function freshSandboxReadinessReplacementDelayMs(random?: () => number): number;
176
+ /** Replacements allowed per turn attempt, across every resumeBoxForTurn call. */
177
+ export declare const FRESH_SANDBOX_READINESS_REPLACEMENTS_PER_TURN_ATTEMPT = 1;
178
+ export type FreshSandboxReadinessReplacementBudget = {
179
+ remaining: number;
180
+ };
181
+ export declare function createFreshSandboxReadinessReplacementBudget(): FreshSandboxReadinessReplacementBudget;
148
182
  /** The exact attached caller that won warm->cold after proving the provider
149
183
  * instance gone. It is a lease supersession (the same logical turn recovers),
150
184
  * plus the lost id needed for one durable observability event. */
@@ -235,5 +269,17 @@ export declare function maybePersistWarmWorkspaceSnapshot(services: SandboxResum
235
269
  * holderId is the globally unique durable turn-attempt id. It must not be a
236
270
  * Temporal activity id, because activity ids are only workflow-local and
237
271
  * collide when sibling sessions share one sandbox group.
272
+ *
273
+ * A freshly created box that misses its bounded command-readiness budget is
274
+ * replaced at most once per turn attempt (the budget is shared by every call
275
+ * the turn's provisioner makes). The first establish has already terminated that exact
276
+ * unpublished box, rolled its exact warming epoch back to cold (advancing the
277
+ * epoch), and released its holder, so the replacement is an ordinary new
278
+ * admission: it re-runs the cold->warming CAS, persists its own provider
279
+ * instance before readiness, and may instead attach to a sibling that won the
280
+ * CAS first. Nothing model- or tool-visible ran on the discarded box, so no
281
+ * side effect is replayed. A second readiness timeout fails the turn exactly
282
+ * as before; attached/resumed boxes and unconfirmed terminations never
283
+ * replace.
238
284
  */
239
285
  export declare function resumeBoxForTurn(services: SandboxResumeServices, ids: ResumeBoxIds, kind: "turn", holderId: TurnSandboxLeaseHolderId): Promise<ResumedTurnSandbox>;