@opengeni/core 2.5.3 → 2.6.4-canary.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.
Files changed (46) hide show
  1. package/dist/access/index.d.ts +24 -0
  2. package/dist/billing/limits.d.ts +5 -0
  3. package/dist/canonical-human-identities.js +2 -2
  4. package/dist/{chunk-ZVZJTMSV.js → chunk-OF65T3PM.js} +2 -2
  5. package/dist/{chunk-YGOMUGYS.js → chunk-QO5GVFFO.js} +17 -8
  6. package/dist/{chunk-YGOMUGYS.js.map → chunk-QO5GVFFO.js.map} +1 -1
  7. package/dist/dependencies.d.ts +10 -1
  8. package/dist/domain/company-brain-governed-writes.d.ts +15 -6
  9. package/dist/domain/company-profile-agent-admin.d.ts +3 -2
  10. package/dist/domain/environments.d.ts +1 -1
  11. package/dist/domain/memory-slack-delivery.d.ts +4 -1
  12. package/dist/domain/personal-connection-delegations.d.ts +1 -0
  13. package/dist/domain/pr-review.d.ts +1 -1
  14. package/dist/domain/scheduled-tasks.d.ts +12 -0
  15. package/dist/domain/sessions.d.ts +37 -11
  16. package/dist/domain/workspace-members.d.ts +8 -1
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.js +1706 -667
  19. package/dist/index.js.map +1 -1
  20. package/dist/managed-auth-session-sets.d.ts +18 -0
  21. package/dist/managed-auth-session-sets.js +3 -1
  22. package/dist/model-catalog.d.ts +89 -0
  23. package/dist/sandbox/fleet.d.ts +6 -4
  24. package/dist/sandbox/routing.d.ts +7 -2
  25. package/dist/sandbox/runtime-settings.d.ts +17 -1
  26. package/package.json +10 -10
  27. package/src/access/index.ts +140 -5
  28. package/src/application/user-resource-grants.ts +31 -2
  29. package/src/billing/limits.ts +57 -24
  30. package/src/dependencies.ts +15 -1
  31. package/src/domain/company-brain-governed-writes.ts +29 -13
  32. package/src/domain/company-profile-agent-admin.ts +3 -2
  33. package/src/domain/environments.ts +6 -34
  34. package/src/domain/memory-slack-delivery.ts +30 -0
  35. package/src/domain/personal-connection-delegations.ts +40 -7
  36. package/src/domain/remember.ts +5 -6
  37. package/src/domain/scheduled-tasks.ts +146 -1
  38. package/src/domain/sessions.ts +912 -358
  39. package/src/domain/workspace-members.ts +34 -2
  40. package/src/index.ts +1 -0
  41. package/src/managed-auth-session-sets.ts +38 -11
  42. package/src/model-catalog.ts +565 -0
  43. package/src/sandbox/fleet.ts +20 -17
  44. package/src/sandbox/routing.ts +18 -4
  45. package/src/sandbox/runtime-settings.ts +32 -0
  46. /package/dist/{chunk-ZVZJTMSV.js.map → chunk-OF65T3PM.js.map} +0 -0
@@ -26,6 +26,7 @@ import {
26
26
  verifyDirectWorkspaceMutationSettlement,
27
27
  verifyRetainedProcessMutationSettlement,
28
28
  type Database,
29
+ type SandboxRetainedProcess,
29
30
  type SandboxWorkspaceMutationAdmission,
30
31
  } from "@opengeni/db";
31
32
  import { settleSessionBackgroundCommandForRetainedProcess } from "@opengeni/db/session-background-commands";
@@ -86,6 +87,20 @@ export function directRetainedProcessMatchesBackend(
86
87
  );
87
88
  }
88
89
 
90
+ export function retainedProcessBackgroundSettlement(
91
+ process: Pick<SandboxRetainedProcess, "state" | "exitCode" | "settlementReason">,
92
+ fallback: RoutingRetainedProcessTerminalProof,
93
+ ): { outcome: "exited" | "lost"; exitCode: number | null; reason: string } {
94
+ if (process.state === "active") {
95
+ throw new Error("Retained-process settlement returned an active durable process");
96
+ }
97
+ return {
98
+ outcome: process.state,
99
+ exitCode: process.exitCode,
100
+ reason: process.settlementReason ?? fallback.reason,
101
+ };
102
+ }
103
+
89
104
  export type ChannelARoutingServices = {
90
105
  db: Database;
91
106
  settings: Settings;
@@ -423,7 +438,7 @@ export function wrapChannelABoxWithRouting(
423
438
  "API retained-process settlement lost its exact durable backend identity",
424
439
  );
425
440
  }
426
- await settleRetainedProcess(db, {
441
+ const settlement = await settleRetainedProcess(db, {
427
442
  accountId: ids.accountId,
428
443
  workspaceId: ids.workspaceId,
429
444
  sessionId: ids.sessionId,
@@ -434,14 +449,13 @@ export function wrapChannelABoxWithRouting(
434
449
  reason: proof.reason,
435
450
  idleGraceMs: settings.sandboxIdleGraceMs,
436
451
  });
452
+ const backgroundSettlement = retainedProcessBackgroundSettlement(settlement.process, proof);
437
453
  await settleSessionBackgroundCommandForRetainedProcess(db, {
438
454
  accountId: ids.accountId,
439
455
  workspaceId: ids.workspaceId,
440
456
  sessionId: ids.sessionId,
441
457
  retainedProcessId: process.id,
442
- outcome: proof.outcome,
443
- exitCode: proof.exitCode,
444
- reason: proof.reason,
458
+ ...backgroundSettlement,
445
459
  });
446
460
  }
447
461
  : undefined;
@@ -4,6 +4,7 @@ import {
4
4
  type RigVersion,
5
5
  type Session,
6
6
  type SandboxBackend,
7
+ type SandboxOs,
7
8
  } from "@opengeni/contracts";
8
9
  import {
9
10
  getRigVersion,
@@ -18,6 +19,37 @@ import {
18
19
  rigProviderImageProviderBindingKeyHash,
19
20
  } from "../rigs/provider-images";
20
21
 
22
+ export type ManagedSessionGroupBackend = Exclude<SandboxBackend, "none" | "selfhosted">;
23
+
24
+ /**
25
+ * Resolve the provider backend behind a session's synthetic managed group.
26
+ *
27
+ * A machine-home session keeps `selfhosted` as its durable policy while a
28
+ * non-null active pointer selects the enrolled machine. Clearing that pointer
29
+ * is an explicit switch to the deployment's managed group, so API readiness,
30
+ * viewer attachment, Channel-A, and worker turns must all select the same
31
+ * provider. Deployments configured with `none` or `selfhosted` have no managed
32
+ * fallback to expose.
33
+ */
34
+ export function managedSessionGroupBackend(
35
+ deploymentBackend: SandboxBackend,
36
+ sessionBackend: SandboxBackend,
37
+ ): ManagedSessionGroupBackend | null {
38
+ if (sessionBackend === "none") return null;
39
+ const backend = sessionBackend === "selfhosted" ? deploymentBackend : sessionBackend;
40
+ return backend === "none" || backend === "selfhosted" ? null : backend;
41
+ }
42
+
43
+ /** A machine-home row carries the machine's host OS; its managed group uses the
44
+ * platform's canonical managed-sandbox OS instead. Ordinary sessions preserve
45
+ * their explicitly selected OS. */
46
+ export function managedSessionGroupOs(
47
+ sessionBackend: SandboxBackend,
48
+ sessionOs: SandboxOs,
49
+ ): SandboxOs {
50
+ return sessionBackend === "selfhosted" ? "linux" : sessionOs;
51
+ }
52
+
21
53
  /** Pre-V2 Packs are the sole compatibility path where a Pack can still own a
22
54
  * sandbox image. V2 installations select a Rig instead. Keep this predicate at
23
55
  * the shared runtime boundary so turns, API-direct tools, viewers, Browser and