@opengeni/sdk 0.4.0 → 0.6.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/README.md CHANGED
@@ -101,6 +101,40 @@ const file = await client.uploadFile(workspaceId, {
101
101
  const { url } = await client.createFileDownloadUrl(workspaceId, file.id);
102
102
  ```
103
103
 
104
+ ## Connected Machines (bring-your-own-compute)
105
+
106
+ A session can run on an enrolled **Connected Machine** — a user's own computer —
107
+ instead of a platform-managed sandbox. Two `createSession` fields target one:
108
+
109
+ - **`targetSandboxId`** (uuid) — the machine to run on (a `MachineView.sandboxId`
110
+ from `listMachines`). It seeds the session's active-sandbox pointer at
111
+ creation, so the first turn lands on that machine.
112
+ - **`workingDir`** (host path) — the directory the agent runs under on that
113
+ machine. **Only valid together with `targetSandboxId`** — `workingDir` alone is
114
+ a **422**. Omit it and the session runs under the machine's default workspace
115
+ root. Repos attached to a machine session are **not cloned** (the machine uses
116
+ its own git auth).
117
+
118
+ ```ts
119
+ const { machines } = await client.listMachines(workspaceId);
120
+ const box = machines.find((m) => m.kind === "selfhosted" && m.state === "online");
121
+
122
+ const session = await client.createSession(workspaceId, {
123
+ initialMessage: "Run the test suite and fix what's red",
124
+ targetSandboxId: box!.sandboxId, // seeds the active-sandbox pointer at create
125
+ workingDir: "/home/me/projects/app", // requires targetSandboxId, else 422
126
+ });
127
+
128
+ // Re-point a running session's active sandbox (or "session"/"default" to swap
129
+ // back to its own managed box):
130
+ await client.swapActiveSandbox(workspaceId, session.id, { target: box!.sandboxId });
131
+ ```
132
+
133
+ Discovery (`listMachines`, `machineMetricsSeries`), the active-sandbox swap, and
134
+ the enrollment methods (`mintEnrollToken`, `lookupDeviceEnrollment`,
135
+ `approveDeviceEnrollment`, `denyDeviceEnrollment`) are covered in the
136
+ [Connected Machines guide](../../docs/connected-machines.md).
137
+
104
138
  ## Full API coverage
105
139
 
106
140
  Every public endpoint group has typed methods:
@@ -108,7 +142,8 @@ Every public endpoint group has typed methods:
108
142
  | Group | Methods |
109
143
  | --- | --- |
110
144
  | Access + workspaces | `getAccessContext`, `listWorkspaces`, `createWorkspace`, `getWorkspace`, `updateWorkspace` |
111
- | Sessions + events | `createSession`, `listSessions`, `getSession`, `listEvents`, `sendEvent`, `sendMessage`, `steerMessage`, `interrupt`, `sendApprovalDecision`, `streamEvents`, `openEventStream` |
145
+ | Sessions + events | `createSession`, `listSessions`, `getSession`, `updateSession`, `listEvents`, `sendEvent`, `sendMessage`, `steerMessage`, `interrupt`, `sendApprovalDecision`, `streamEvents`, `openEventStream` |
146
+ | Machines (bring-your-own-compute) | `listMachines`, `machineMetricsSeries`, `swapActiveSandbox`, `mintEnrollToken`, `lookupDeviceEnrollment`, `approveDeviceEnrollment`, `denyDeviceEnrollment` |
112
147
  | Turn queue | `listTurns`, `updateQueuedTurn`, `reorderQueuedTurns`, `deleteQueuedTurn` |
113
148
  | Goal | `getGoal`, `updateGoal`, `pauseGoal`, `resumeGoal` |
114
149
  | Scheduled tasks | `createScheduledTask`, `listScheduledTasks`, `getScheduledTask`, `updateScheduledTask`, `pauseScheduledTask`, `resumeScheduledTask`, `triggerScheduledTask`, `deleteScheduledTask`, `listScheduledTaskRuns` |
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  type SessionStatus = "queued" | "running" | "idle" | "requires_action" | "failed" | "cancelled";
2
- type SandboxBackend = "docker" | "modal" | "local" | "none" | "daytona" | "runloop" | "e2b" | "blaxel" | "cloudflare" | "vercel";
2
+ type SandboxBackend = "docker" | "modal" | "local" | "none" | "daytona" | "runloop" | "e2b" | "blaxel" | "cloudflare" | "vercel" | "selfhosted";
3
3
  type SandboxOs = "linux" | "macos" | "windows";
4
4
  type SandboxCapabilityName = "FileSystem" | "Terminal" | "Git" | "DesktopStream" | "Recording";
5
- type CapabilityUnavailableReason = "backend_unsupported" | "os_unsupported" | "not_provisioned" | "disabled_by_policy" | "lease_cold" | "tier_headless";
5
+ type CapabilityUnavailableReason = "backend_unsupported" | "os_unsupported" | "not_provisioned" | "disabled_by_policy" | "lease_cold" | "tier_headless" | "agent_offline" | "agent_reconnecting" | "consent_required" | "display_unavailable";
6
6
  type SessionCapabilities = {
7
7
  sessionId: string;
8
8
  backend: SandboxBackend;
@@ -32,8 +32,8 @@ type SessionCapabilities = {
32
32
  reason: CapabilityUnavailableReason | null;
33
33
  };
34
34
  DesktopStream: {
35
- transport: "vnc-ws" | "rdp-ws" | "webrtc" | null;
36
- client: "novnc" | "web-rdp" | null;
35
+ transport: "vnc-ws" | "rdp-ws" | "webrtc" | "relay-frames" | null;
36
+ client: "novnc" | "web-rdp" | "frames" | null;
37
37
  mode: "read-only" | "interactive";
38
38
  url: string | null;
39
39
  token: string | null;
@@ -154,6 +154,8 @@ type Session = {
154
154
  accountId: string;
155
155
  status: SessionStatus;
156
156
  initialMessage: string;
157
+ title: string | null;
158
+ titleSource: "user" | "agent" | null;
157
159
  resources: ResourceRef[];
158
160
  tools: ToolRef[];
159
161
  metadata: Record<string, unknown>;
@@ -165,6 +167,10 @@ type Session = {
165
167
  temporalWorkflowId: string | null;
166
168
  activeTurnId: string | null;
167
169
  lastSequence: number;
170
+ /** Multi-account Codex (P1): the account this session is pinned to (null ⇒ follow workspace active). */
171
+ codexPinnedCredentialId?: string | null;
172
+ /** Multi-account Codex (P1): the account the most recent turn ran on (the "Running on:" indicator). */
173
+ codexLastCredentialId?: string | null;
168
174
  createdAt: string;
169
175
  updatedAt: string;
170
176
  };
@@ -191,7 +197,7 @@ type SessionTurn = {
191
197
  createdAt: string;
192
198
  updatedAt: string;
193
199
  };
194
- declare const SESSION_EVENT_TYPES: readonly ["session.created", "session.status.changed", "session.requiresAction", "session.context.compacted", "session.context.cleared", "user.message", "user.interrupt", "user.approvalDecision", "turn.queued", "turn.updated", "turn.started", "turn.completed", "turn.failed", "turn.cancelled", "turn.preempted", "agent.message.delta", "agent.message.completed", "agent.reasoning.delta", "agent.toolCall.created", "agent.toolCall.output", "agent.updated", "sandbox.operation.started", "sandbox.operation.completed", "sandbox.operation.failed", "sandbox.command.output.delta", "artifact.created", "goal.set", "goal.updated", "goal.completed", "goal.paused", "goal.resumed", "goal.continuation", "stream.url.rotated", "stream.opened", "stream.closed", "stream.revoked", "recording.started", "recording.available", "recording.failed", "fs.changed", "git.changed", "terminal.pty.started", "terminal.pty.output.delta", "terminal.pty.exited"];
200
+ declare const SESSION_EVENT_TYPES: readonly ["session.created", "session.status.changed", "session.requiresAction", "session.context.compacted", "session.context.cleared", "user.message", "user.interrupt", "user.approvalDecision", "turn.queued", "turn.updated", "turn.started", "turn.completed", "turn.failed", "turn.cancelled", "turn.preempted", "agent.message.delta", "agent.message.completed", "agent.reasoning.delta", "agent.toolCall.created", "agent.toolCall.output", "agent.updated", "sandbox.operation.started", "sandbox.operation.completed", "sandbox.operation.failed", "sandbox.command.output.delta", "artifact.created", "goal.set", "goal.updated", "goal.completed", "goal.paused", "goal.resumed", "goal.continuation", "stream.url.rotated", "stream.opened", "stream.closed", "stream.revoked", "recording.started", "recording.available", "recording.failed", "fs.changed", "git.changed", "terminal.pty.started", "terminal.pty.output.delta", "terminal.pty.exited", "session.title_set", "codex.account.switched"];
195
201
  type KnownSessionEventType = (typeof SESSION_EVENT_TYPES)[number];
196
202
  /**
197
203
  * Event types the SDK knows about today, kept open so a newer OpenGeni server
@@ -597,13 +603,18 @@ type CreateSessionRequest = {
597
603
  model?: string | undefined;
598
604
  reasoningEffort?: ReasoningEffort | undefined;
599
605
  sandboxBackend?: SandboxBackend | undefined;
606
+ targetSandboxId?: string | undefined;
607
+ workingDir?: string | undefined;
600
608
  environmentId?: string | undefined;
601
609
  goal?: GoalSpec | undefined;
602
610
  clientEventId?: string | undefined;
603
611
  idempotencyKey?: string | undefined;
604
612
  firstPartyMcpPermissions?: string[] | undefined;
613
+ sandbox?: "shared" | "new" | {
614
+ groupId: string;
615
+ } | undefined;
605
616
  };
606
- declare const KNOWN_PERMISSIONS: readonly ["account:read", "account:admin", "members:manage", "workspace:create", "billing:read", "billing:manage", "workspace:read", "workspace:admin", "sessions:create", "sessions:read", "sessions:control", "stream:view", "stream:control", "stream:acknowledge", "files:upload", "files:read", "files:write", "terminal:attach", "documents:manage", "documents:search", "scheduled_tasks:manage", "scheduled_tasks:run", "github:manage", "github:use", "api_keys:manage", "environments:manage", "environments:use", "goals:manage"];
617
+ declare const KNOWN_PERMISSIONS: readonly ["account:read", "account:admin", "members:manage", "workspace:create", "billing:read", "billing:manage", "workspace:read", "workspace:admin", "sessions:create", "sessions:read", "sessions:control", "stream:view", "stream:control", "stream:acknowledge", "files:upload", "files:read", "files:write", "terminal:attach", "documents:manage", "documents:search", "scheduled_tasks:manage", "scheduled_tasks:run", "github:manage", "github:use", "api_keys:manage", "environments:manage", "environments:use", "goals:manage", "enrollments:read", "enrollments:manage"];
607
618
  type KnownPermission = (typeof KNOWN_PERMISSIONS)[number];
608
619
  /**
609
620
  * Permissions the SDK knows about today, kept open so a newer OpenGeni server
@@ -626,6 +637,129 @@ type ClientModel = {
626
637
  api: "responses" | "chat";
627
638
  contextWindowTokens?: number | undefined;
628
639
  };
640
+ /**
641
+ * Connection state of a workspace's Codex (ChatGPT) subscription, returned by
642
+ * `GET /v1/workspaces/:id/codex/status`. `models` are the codex models the
643
+ * workspace can select (projected as ClientModel under their own "no credits"
644
+ * provider group), present only while connected.
645
+ */
646
+ type CodexConnectionStatus = {
647
+ connected: boolean;
648
+ plan?: string | null;
649
+ valid?: boolean;
650
+ expiresAt?: string | null;
651
+ lastError?: string | null;
652
+ models?: ClientModel[];
653
+ /** The account a session runs on when unpinned (label for the in-session indicator). */
654
+ activeAccount?: {
655
+ id: string;
656
+ label?: string | null;
657
+ chatgptAccountId?: string | null;
658
+ } | null;
659
+ /** How many Codex accounts the workspace has connected. */
660
+ accountCount?: number;
661
+ };
662
+ /**
663
+ * One normalized Codex usage window (5h or weekly), camelCase end-to-end (the
664
+ * route normalizes server-side; the web layer never re-hand-types snake_case).
665
+ * `percent` is authoritative; used/limit/remaining are a synthesized 0–100 scale
666
+ * (limit = 100) because the provider gives only a percentage. `remaining =
667
+ * 100 - percent` is the P3 rotation key. Identify the window by `limitWindowSeconds`
668
+ * (18000 ⇒ 5h, 604800 ⇒ weekly), never by position.
669
+ */
670
+ type CodexUsageWindow = {
671
+ used: number;
672
+ limit: number;
673
+ remaining: number;
674
+ percent: number;
675
+ resetAt: string | null;
676
+ resetAfterSeconds: number | null;
677
+ limitWindowSeconds: number;
678
+ };
679
+ /** The normalized usage payload for one account — the P2/P3 contract. */
680
+ type CodexUsagePayload = {
681
+ status: "ok" | "limit_reached" | "error" | "no-data";
682
+ planType: string | null;
683
+ fiveHour: CodexUsageWindow | null;
684
+ weekly: CodexUsageWindow | null;
685
+ limitReached: boolean;
686
+ fetchedAt: string;
687
+ /** Present only on an auth/refresh failure path. */
688
+ reason?: "needs_relogin";
689
+ additionalLimits?: Array<{
690
+ limitName: string;
691
+ meteredFeature: string;
692
+ fiveHour: CodexUsageWindow | null;
693
+ weekly: CodexUsageWindow | null;
694
+ }>;
695
+ credits?: {
696
+ hasCredits: boolean;
697
+ unlimited: boolean;
698
+ overageLimitReached: boolean;
699
+ balance: string;
700
+ };
701
+ };
702
+ /** One connected Codex (ChatGPT) account in a workspace (multi-account P1). Metadata only. */
703
+ type CodexAccount = {
704
+ id: string;
705
+ chatgptAccountId?: string | null;
706
+ label?: string | null;
707
+ email?: string | null;
708
+ plan?: string | null;
709
+ status: "active" | "needs_relogin" | "error";
710
+ active: boolean;
711
+ expiresAt?: string | null;
712
+ lastRefreshAt?: string | null;
713
+ lastError?: string | null;
714
+ fiveHour?: CodexUsageWindow | null;
715
+ weekly?: CodexUsageWindow | null;
716
+ usageCheckedAt?: string | null;
717
+ exhaustedUntil?: string | null;
718
+ };
719
+ /** Per-workspace Codex rotation/active settings. P1: rotation inert, only activeCredentialId loads. */
720
+ type CodexRotationSettings = {
721
+ rotationEnabled: boolean;
722
+ rotationStrategy: "most_remaining" | "round_robin" | "drain_then_next";
723
+ activeCredentialId: string | null;
724
+ };
725
+ /** GET /codex/accounts — the accounts list + the workspace active pointer + settings. */
726
+ type CodexAccountsResponse = {
727
+ accounts: CodexAccount[];
728
+ activeAccountId: string | null;
729
+ settings: CodexRotationSettings;
730
+ };
731
+ /** Payload of a `codex.account.switched` session event. */
732
+ type CodexAccountSwitchedPayload = {
733
+ fromAccountId: string | null;
734
+ toAccountId: string;
735
+ reason: "manual" | "exhausted" | "rotation";
736
+ droppedConnectors?: string[];
737
+ };
738
+ /** Device-code start: show `userCode` at `verificationUri`, then poll with `state`. */
739
+ type CodexConnectStart = {
740
+ userCode: string;
741
+ verificationUri: string;
742
+ intervalSeconds: number;
743
+ state: string;
744
+ };
745
+ /** Poll result: keep polling on `pending`, restart on `expired`, done on `connected`. */
746
+ type CodexConnectPoll = {
747
+ status: "pending";
748
+ } | {
749
+ status: "expired";
750
+ } | {
751
+ status: "connected";
752
+ plan?: string | null;
753
+ accountId?: string;
754
+ isActive?: boolean;
755
+ };
756
+ /** Remaining usage/limits for one account. `usage` is the normalized P2 payload. */
757
+ type CodexUsage = {
758
+ status: "ok" | "limit_reached" | "error" | "no-data";
759
+ usage: CodexUsagePayload | null;
760
+ };
761
+ /** Batched live-refresh response, keyed by credential id; each entry independently statused. */
762
+ type CodexUsageMap = Record<string, CodexUsage>;
629
763
  /**
630
764
  * How a deployment expects clients to authenticate to it, surfaced so a UI can
631
765
  * wire up the right header/cookie without prior knowledge of the host setup.
@@ -795,6 +929,9 @@ type UpdateSessionGoalRequest = {
795
929
  status: "paused" | "active";
796
930
  rationale?: string | undefined;
797
931
  };
932
+ type UpdateSessionRequest = {
933
+ title: string;
934
+ };
798
935
  /** Outcome of a manual /compact trigger. */
799
936
  type CompactSessionContextResult = {
800
937
  /**
@@ -1322,6 +1459,153 @@ type UserApprovalDecisionEventInput = {
1322
1459
  };
1323
1460
  /** Control/user events a client may POST to a session's event log. */
1324
1461
  type ClientSessionEventInput = UserMessageEventInput | UserInterruptEventInput | UserApprovalDecisionEventInput;
1462
+ /** A point-in-time machine metrics sample. `gpuUtilPct`/`gpuMemBytes` are null
1463
+ * when no GPU was present (not-reported, never a real zero); the bytes/load are
1464
+ * numbers; `sampledAt` is an ISO-8601 instant. */
1465
+ type MetricSample = {
1466
+ cpuPct: number;
1467
+ load1: number;
1468
+ load5: number;
1469
+ load15: number;
1470
+ memUsedBytes: number;
1471
+ memTotalBytes: number;
1472
+ diskUsedBytes: number;
1473
+ diskTotalBytes: number;
1474
+ gpuUtilPct: number | null;
1475
+ gpuMemBytes: number | null;
1476
+ runQueue: number;
1477
+ sampledAt: string;
1478
+ };
1479
+ /** The derived dashboard state of a machine (M3 liveness + consent/display
1480
+ * reasons + the in-flight device-flow). */
1481
+ type MachineState = "online" | "reconnecting" | "offline" | "consent_required" | "display_unavailable" | "enrolling";
1482
+ type MachineKind = "modal" | "selfhosted";
1483
+ /** A machine as the Machines dashboard renders it (an enrolled selfhosted machine
1484
+ * or the session's synthetic Modal group box, `isSessionGroup: true`). */
1485
+ type MachineView = {
1486
+ sandboxId: string;
1487
+ enrollmentId: string | null;
1488
+ name: string;
1489
+ kind: MachineKind;
1490
+ state: MachineState;
1491
+ active: boolean;
1492
+ isSessionGroup: boolean;
1493
+ os: string;
1494
+ arch: string;
1495
+ hasDisplay: boolean;
1496
+ allowScreenControl: boolean;
1497
+ sharedSessionCount: number;
1498
+ lastSeenAt: string | null;
1499
+ metrics: MetricSample | null;
1500
+ };
1501
+ /** GET /v1/workspaces/:ws/machines — the dashboard list + the active-sandbox
1502
+ * pointer (null activeSandboxId == the session's own group box is active). */
1503
+ type MachinesResponse = {
1504
+ activeSandboxId: string | null;
1505
+ activeEpoch: number;
1506
+ machines: MachineView[];
1507
+ };
1508
+ /** GET /v1/workspaces/:ws/machines/:enrollmentId/metrics/series — the downsampled
1509
+ * (~1/min) history the dashboard time-range reads. */
1510
+ type MachineMetricsSeriesResponse = {
1511
+ samples: MetricSample[];
1512
+ };
1513
+ /** POST /v1/workspaces/:ws/sessions/:sessionId/active-sandbox — swap a session's
1514
+ * active sandbox. `target` is a `MachineView.sandboxId`, or "session"/"default"
1515
+ * to swap back to the session's own group box. */
1516
+ type SwapActiveSandboxRequest = {
1517
+ target: string;
1518
+ };
1519
+ /** The swap outcome (mirrors the server `FleetSwapResult`). `swapped` is true on a
1520
+ * successful repoint OR a no-op (already there); `reason` carries the failure
1521
+ * detail (unowned/offline target, or a lost epoch fence) when false. */
1522
+ type SwapActiveSandboxResponse = {
1523
+ swapped: boolean;
1524
+ activeSandboxId: string | null;
1525
+ activeEpoch: number;
1526
+ reason?: string;
1527
+ };
1528
+ /** Mirror of `@opengeni/contracts` EnrollmentOs. */
1529
+ type EnrollmentOs = "linux" | "macos" | "windows";
1530
+ /** POST /v1/enrollments/device/lookup body. */
1531
+ type DeviceEnrollmentLookupRequest = {
1532
+ userCode: string;
1533
+ };
1534
+ /** The presentational machine details the consent screen renders. */
1535
+ type DeviceEnrollmentLookupMachine = {
1536
+ machineName: string | null;
1537
+ os: EnrollmentOs;
1538
+ arch: string;
1539
+ canOfferDisplay: boolean;
1540
+ requestsScreenControl: boolean;
1541
+ };
1542
+ /** POST /v1/enrollments/device/lookup response (no secrets, no device_code). */
1543
+ type DeviceEnrollmentLookupResponse = {
1544
+ workspaceId: string;
1545
+ userCode: string;
1546
+ machine: DeviceEnrollmentLookupMachine;
1547
+ expiresAt: string;
1548
+ };
1549
+ /** POST /v1/workspaces/:ws/enrollments/device/approve body. */
1550
+ type DeviceEnrollmentApproveRequest = {
1551
+ userCode: string;
1552
+ allowScreenControl?: boolean;
1553
+ };
1554
+ /** POST /v1/workspaces/:ws/enrollments/device/approve response. */
1555
+ type DeviceEnrollmentApproveResponse = {
1556
+ approved: boolean;
1557
+ enrollmentId: string;
1558
+ sandboxId: string;
1559
+ allowScreenControl: boolean;
1560
+ };
1561
+ /** POST /v1/workspaces/:ws/enrollments/device/deny body. */
1562
+ type DeviceEnrollmentDenyRequest = {
1563
+ userCode: string;
1564
+ };
1565
+ /** POST /v1/workspaces/:ws/enrollments/device/deny response. */
1566
+ type DeviceEnrollmentDenyResponse = {
1567
+ denied: boolean;
1568
+ };
1569
+ /** POST /v1/workspaces/:ws/enrollments/token body. */
1570
+ type MintEnrollTokenRequest = {
1571
+ allowScreenControl?: boolean;
1572
+ };
1573
+ /** POST /v1/workspaces/:ws/enrollments/token response. The `token` is SECRET. */
1574
+ type MintEnrollTokenResponse = {
1575
+ token: string;
1576
+ expiresAt: string;
1577
+ expiresInSeconds: number;
1578
+ };
1579
+ /** The credential payload the headless exchange returns (a subset of the agent's
1580
+ * EnrollmentCredentials — IDENTICAL to the device-flow poll authorized branch). */
1581
+ type EnrollmentCredentials = {
1582
+ agentId: string;
1583
+ workspaceId: string;
1584
+ bearer: string;
1585
+ subjectPrefix: string;
1586
+ natsUrls: string[];
1587
+ relayUrl: string;
1588
+ relayToken: string;
1589
+ natsAccountCreds: string;
1590
+ updatePublicKey: string;
1591
+ consentedWholeMachine: boolean;
1592
+ consentedScreenControl: boolean;
1593
+ };
1594
+ /** POST /v1/enrollments/token/exchange body (the headless / fleet enroll path). */
1595
+ type EnrollTokenExchangeRequest = {
1596
+ token: string;
1597
+ publicKey: string;
1598
+ os?: EnrollmentOs;
1599
+ arch?: string;
1600
+ machineName?: string;
1601
+ exposure?: "whole-machine";
1602
+ canOfferDisplay?: boolean;
1603
+ requestsScreenControl?: boolean;
1604
+ };
1605
+ /** POST /v1/enrollments/token/exchange response (wraps the credential shape). */
1606
+ type EnrollTokenExchangeResponse = {
1607
+ credentials: EnrollmentCredentials;
1608
+ };
1325
1609
 
1326
1610
  /**
1327
1611
  * Transport boundary for the streaming core. The client implements it with
@@ -1412,12 +1696,70 @@ declare class OpenGeniClient {
1412
1696
  constructor(options: OpenGeniClientOptions);
1413
1697
  createSession(workspaceId: string, request: CreateSessionRequest): Promise<Session>;
1414
1698
  getSession(workspaceId: string, sessionId: string): Promise<Session>;
1699
+ updateSession(workspaceId: string, sessionId: string, request: UpdateSessionRequest): Promise<Session>;
1415
1700
  listSessions(workspaceId: string, options?: {
1416
1701
  limit?: number;
1417
1702
  }): Promise<Session[]>;
1418
1703
  listTurns(workspaceId: string, sessionId: string, options?: {
1419
1704
  limit?: number;
1420
1705
  }): Promise<SessionTurn[]>;
1706
+ /**
1707
+ * List the workspace's machines (the Machines dashboard). Each enrolled
1708
+ * selfhosted machine carries its derived state + latest metrics +
1709
+ * sharedSessionCount. Pass `sessionId` for an in-session view, which adds the
1710
+ * session's synthetic Modal group box + the active-sandbox pointer.
1711
+ */
1712
+ listMachines(workspaceId: string, options?: {
1713
+ sessionId?: string;
1714
+ }): Promise<MachinesResponse>;
1715
+ /**
1716
+ * Read the downsampled (~1/min) metrics series for ONE machine over a time
1717
+ * window (default 1h). The samples are oldest-first (a left-to-right chart).
1718
+ */
1719
+ machineMetricsSeries(workspaceId: string, enrollmentId: string, options?: {
1720
+ window?: "15m" | "1h" | "6h" | "24h";
1721
+ }): Promise<MetricSample[]>;
1722
+ /**
1723
+ * Resolve a pending device-enrollment flow by its user_code for the click-Grant
1724
+ * approve page (EnrollmentConsent). NO workspace in the path — the server
1725
+ * resolves the workspace from the (globally-unique-among-pending) code, then
1726
+ * authorizes the caller against it (enrollments:read). Rejects (404) when the
1727
+ * code is unknown/expired OR the caller lacks the grant — the two are
1728
+ * indistinguishable by design (no cross-workspace disclosure). Does not consume
1729
+ * the request.
1730
+ */
1731
+ lookupDeviceEnrollment(userCode: string): Promise<DeviceEnrollmentLookupResponse>;
1732
+ /**
1733
+ * Approve a pending device-enrollment flow (the LOUD consent step). `allowScreenControl`
1734
+ * is the authoritative screen-control consent (whole-machine is mandatory/implicit).
1735
+ * Lands an enrollment + a selfhosted sandbox and unblocks the agent's poll.
1736
+ */
1737
+ approveDeviceEnrollment(workspaceId: string, request: {
1738
+ userCode: string;
1739
+ allowScreenControl?: boolean;
1740
+ }): Promise<DeviceEnrollmentApproveResponse>;
1741
+ /** Deny a pending device-enrollment flow (the explicit "no" at the approve page). */
1742
+ denyDeviceEnrollment(workspaceId: string, request: {
1743
+ userCode: string;
1744
+ }): Promise<DeviceEnrollmentDenyResponse>;
1745
+ /**
1746
+ * Mint a short-TTL headless enroll token (the `oget_` token) for the fleet /
1747
+ * non-interactive enroll path. The returned `token` is SECRET — surface it once
1748
+ * with a copy-now warning; it cannot be re-read. `allowScreenControl` bakes the
1749
+ * screen-control consent into the token.
1750
+ */
1751
+ mintEnrollToken(workspaceId: string, request?: {
1752
+ allowScreenControl?: boolean;
1753
+ }): Promise<MintEnrollTokenResponse>;
1754
+ /**
1755
+ * Swap a session's active sandbox (the user-authenticated equivalent of the
1756
+ * M7 `sandbox_swap` MCP tool). `target` is a `MachineView.sandboxId` from
1757
+ * `listMachines`, or "session"/"default" to swap back to the session's own
1758
+ * group box. Validation (ownership/liveness/epoch fence) is server-side; the
1759
+ * result echoes the resulting pointer (`swapped: false` + `reason` on a
1760
+ * rejected target or a lost epoch fence).
1761
+ */
1762
+ swapActiveSandbox(workspaceId: string, sessionId: string, request: SwapActiveSandboxRequest): Promise<SwapActiveSandboxResponse>;
1421
1763
  listScheduledTasks(workspaceId: string, options?: {
1422
1764
  limit?: number;
1423
1765
  }): Promise<ScheduledTask[]>;
@@ -1699,6 +2041,47 @@ declare class OpenGeniClient {
1699
2041
  createBillingCheckout(request: CreateCheckoutRequest): Promise<CreateCheckoutResponse>;
1700
2042
  private headers;
1701
2043
  private url;
2044
+ /** Connection state + the codex models the workspace may select (empty until connected). */
2045
+ codexStatus(workspaceId: string): Promise<CodexConnectionStatus>;
2046
+ /** Begin device-code login: show `userCode` at `verificationUri`, then poll with `state`. */
2047
+ codexConnectStart(workspaceId: string): Promise<CodexConnectStart>;
2048
+ /** Poll device-code authorization with the `state` from {@link codexConnectStart}. */
2049
+ codexConnectPoll(workspaceId: string, state: string): Promise<CodexConnectPoll>;
2050
+ /** Remaining usage / limits for the connected (ACTIVE) subscription. Back-compat. */
2051
+ codexUsage(workspaceId: string): Promise<CodexUsage>;
2052
+ /** Live per-account usage read (refreshes THIS account's bearer; writes the cache). */
2053
+ codexAccountUsage(workspaceId: string, accountId: string): Promise<CodexUsage>;
2054
+ /** Batched live refresh across every connected account, keyed by credential id. */
2055
+ refreshCodexUsage(workspaceId: string): Promise<{
2056
+ usage: CodexUsageMap;
2057
+ }>;
2058
+ /** Disconnect ALL accounts (legacy workspace-wide). Prefer `disconnectCodexAccount`. */
2059
+ codexDisconnect(workspaceId: string): Promise<{
2060
+ disconnected: boolean;
2061
+ }>;
2062
+ /** List every connected Codex account + the workspace active pointer + settings. */
2063
+ listCodexAccounts(workspaceId: string): Promise<CodexAccountsResponse>;
2064
+ /** Switch the workspace ACTIVE Codex account (the one unpinned sessions use). */
2065
+ activateCodexAccount(workspaceId: string, accountId: string): Promise<{
2066
+ activated: boolean;
2067
+ accountId: string;
2068
+ }>;
2069
+ /** P3: enable/disable Codex auto-rotation and/or pick the strategy. Returns the effective settings. */
2070
+ setCodexRotationSettings(workspaceId: string, patch: {
2071
+ rotationEnabled?: boolean;
2072
+ rotationStrategy?: CodexRotationSettings["rotationStrategy"];
2073
+ }): Promise<CodexRotationSettings>;
2074
+ /** Disconnect ONE Codex account by id (re-picks active when the removed one was active). */
2075
+ disconnectCodexAccount(workspaceId: string, accountId: string): Promise<{
2076
+ disconnected: boolean;
2077
+ newActiveId: string | null;
2078
+ }>;
2079
+ /** Rename a Codex account (label only in P1). */
2080
+ renameCodexAccount(workspaceId: string, accountId: string, label: string | null): Promise<CodexAccount>;
2081
+ /** Pin (or unpin via "auto") a session's Codex account. Applies on the next turn. */
2082
+ pinSessionCodexAccount(workspaceId: string, sessionId: string, target: string): Promise<{
2083
+ pinned: string;
2084
+ }>;
1702
2085
  private requestJson;
1703
2086
  /** Like `requestJson` for endpoints that respond with no body (204). */
1704
2087
  private requestVoid;
@@ -1919,4 +2302,4 @@ declare function ttydInputFrame(data: string): string;
1919
2302
  /** Build a client→server RESIZE frame: "1" + JSON.stringify({ columns, rows }). */
1920
2303
  declare function ttydResizeFrame(columns: number, rows: number): string;
1921
2304
 
1922
- export { type AccessContext, type AccessGrant, type AccountGrant, type AccountRole, type AcknowledgeStreamRequest, type AcknowledgeStreamResponse, type AddWorkspaceMemberRequest, type AgentMessageCompletedPayload, type AgentTextDeltaPayload, type AgentToolCallCreatedPayload, type AgentToolCallOutputPayload, type ApiKey, type AttachViewerRequest, type AttachViewerResponse, type BillingBalance, type BillingEntitlementsResponse, type BillingMode, type BillingSummary, type BillingUsageResponse, type CapabilityCatalogItem, type CapabilityCatalogResponse, type CapabilityInstallation, type CapabilityInstallationStatus, type CapabilityKind, type CapabilityPack, type CapabilityPackConnector, type CapabilityPackConnectorAuthModel, type CapabilityPackEnvironmentSpec, type CapabilityPackKnowledge, type CapabilityPackScheduledTaskTemplate, type CapabilityPackSkill, type CapabilityPackSkillFile, type CapabilityRuntime, type CapabilitySource, type CapabilityUnavailableReason, type ClientAuthConfig, type ClientConfig, type ClientModel, type ClientSessionEventInput, type CompactSessionContextResult, type CompleteFileUploadResponse, type ComputerUseCapability, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateCapabilityCatalogItemRequest, type CreateCheckoutRequest, type CreateCheckoutResponse, type CreateDocumentBaseRequest, type CreateFileUploadRequest, type CreateFileUploadResponse, type CreateGitHubAppManifestRequest, type CreateGitHubAppManifestResponse, type CreateScheduledTaskRequest, type CreateSessionRequest, type CreateWorkspaceEnvironmentRequest, type CreateWorkspaceRequest, type DesktopConnectionState, type DesktopRfbFactory, type DesktopRfbLike, type DesktopStreamCapability, type DesktopStreamEvent, type DiscoverMcpCapabilitiesResponse, type Document, type DocumentBase, type DocumentSearchRequest, type DocumentSearchResponse, type DocumentSearchResult, type DocumentStatus, type EnableCapabilityRequest, type EnablePackRequest, type EntitlementValue, type Entitlements, type EntitlementsMode, type FetchLike, type FileAsset, type FileDownloadUrlResponse, type FileResourceRef, type FileStatus, type FileSystemCapability, type FileUploadData, type FsChangeKind, type FsChangedPayload, type FsDeleteRequest, type FsDeleteResponse, type FsEncoding, type FsListRequest, type FsListResponse, type FsMkdirRequest, type FsMkdirResponse, type FsMoveRequest, type FsMoveResponse, type FsNodeType, type FsReadRequest, type FsReadResponse, type FsTreeNode, type FsWriteRequest, type FsWriteResponse, type GetPackResponse, type GitCapability, type GitChangedPayload, type GitCommit, type GitDiffHunk, type GitDiffLine, type GitDiffLineType, type GitDiffRequest, type GitDiffResponse, type GitFileDiff, type GitFileStatus, type GitFileStatusCode, type GitHubAppInfo, type GitHubRepositoriesResponse, type GitHubRepository, type GitLogRequest, type GitLogResponse, type GitShowRequest, type GitShowResponse, type GitStatusRequest, type GitStatusResponse, type GoalSpec, KNOWN_PERMISSIONS, KNOWN_USAGE_EVENT_TYPES, type KnownPermission, type KnownSessionEventType, type KnownUsageEventType, type ListApiKeysResponse, type ListPacksResponse, type ListWorkspaceMembersResponse, OpenGeniApiError, OpenGeniClient, type OpenGeniClientOptions, OpenGeniStreamError, type PackInstallation, type PackInstallationStatus, type Permission, type ProductAccessMode, type ProxySessionEventStreamOptions, type PtyCloseRequest, type PtyOpenRequest, type PtyOpenResponse, type PtyResizeRequest, type PtyWriteRequest, type ReasoningEffort, type RecordingAvailablePayload, type RecordingCapability, type RecordingCodec, type RecordingContentType, type RecordingFailedPayload, type RecordingFailedReason, type RecordingMode, type RecordingStartedPayload, type RegisterCapabilityPackRequest, type RepositoryResourceRef, type ResourceRef, SESSION_EVENT_TYPES, type SandboxBackend, type SandboxCapabilityName, type SandboxCommandOutputDeltaPayload, type SandboxOs, type ScheduledTask, type ScheduledTaskAgentConfig, type ScheduledTaskAgentConfigInput, type ScheduledTaskDayOfWeek, type ScheduledTaskOverlapPolicy, type ScheduledTaskRun, type ScheduledTaskRunMode, type ScheduledTaskRunStatus, type ScheduledTaskScheduleSpec, type ScheduledTaskStatus, type ScheduledTaskTriggerType, type SendMessageInput, type Session, type SessionCapabilities, type SessionEvent, type SessionEventStreamTransport, type SessionEventType, type SessionGoal, type SessionGoalCreatedBy, type SessionGoalStatus, type SessionStatus, type SessionStatusChangedPayload, type SessionStructuredCapabilities, type SessionTurn, type SessionTurnSource, type SessionTurnStatus, type SseMessage, type SseReStreamOptions, type SteerMessageResult, type StreamClosedPayload, type StreamConnectionState, type StreamOpenedPayload, type StreamRevokedPayload, type StreamSessionEventsOptions, type StreamUrlRotatedPayload, TTYD_SUBPROTOCOL, type TerminalCapability, type TerminalExecRequest, type TerminalExecResponse, type TerminalPtyExitedPayload, type TerminalPtyOutputDeltaPayload, type TerminalPtyStartedPayload, type ToolRef, TtydClientCommand, TtydServerCommand, type UpdateScheduledTaskRequest, type UpdateSessionGoalRequest, type UpdateSessionTurnRequest, type UpdateWorkspaceEnvironmentRequest, type UpdateWorkspaceMemberRequest, type UpdateWorkspaceRequest, type UploadFileInput, type UsageEvent, type UsageEventType, type UserApprovalDecisionEventInput, type UserInterruptEventInput, type UserMessageEventInput, type ViewerHeartbeatRequest, type ViewerHeartbeatResponse, type ViewerHolder, type Workspace, type WorkspaceEnvironment, type WorkspaceEnvironmentVariableMetadata, type WorkspaceMember, type WorkspaceRegisteredPack, applyUrlRotation, desktopSocketUrl, formatSseEvent, isRetryableStreamError, nextDesktopState, parseSseStream, proxySessionEventStream, resumeSequenceFromRequest, sessionEventsToSseResponse, sessionEventsToSseStream, streamSessionEvents, terminalSocketUrl, ttydAuthFrame, ttydInputFrame, ttydResizeFrame };
2305
+ export { type AccessContext, type AccessGrant, type AccountGrant, type AccountRole, type AcknowledgeStreamRequest, type AcknowledgeStreamResponse, type AddWorkspaceMemberRequest, type AgentMessageCompletedPayload, type AgentTextDeltaPayload, type AgentToolCallCreatedPayload, type AgentToolCallOutputPayload, type ApiKey, type AttachViewerRequest, type AttachViewerResponse, type BillingBalance, type BillingEntitlementsResponse, type BillingMode, type BillingSummary, type BillingUsageResponse, type CapabilityCatalogItem, type CapabilityCatalogResponse, type CapabilityInstallation, type CapabilityInstallationStatus, type CapabilityKind, type CapabilityPack, type CapabilityPackConnector, type CapabilityPackConnectorAuthModel, type CapabilityPackEnvironmentSpec, type CapabilityPackKnowledge, type CapabilityPackScheduledTaskTemplate, type CapabilityPackSkill, type CapabilityPackSkillFile, type CapabilityRuntime, type CapabilitySource, type CapabilityUnavailableReason, type ClientAuthConfig, type ClientConfig, type ClientModel, type ClientSessionEventInput, type CodexAccount, type CodexAccountSwitchedPayload, type CodexAccountsResponse, type CodexConnectPoll, type CodexConnectStart, type CodexConnectionStatus, type CodexRotationSettings, type CodexUsage, type CodexUsageMap, type CodexUsagePayload, type CodexUsageWindow, type CompactSessionContextResult, type CompleteFileUploadResponse, type ComputerUseCapability, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateCapabilityCatalogItemRequest, type CreateCheckoutRequest, type CreateCheckoutResponse, type CreateDocumentBaseRequest, type CreateFileUploadRequest, type CreateFileUploadResponse, type CreateGitHubAppManifestRequest, type CreateGitHubAppManifestResponse, type CreateScheduledTaskRequest, type CreateSessionRequest, type CreateWorkspaceEnvironmentRequest, type CreateWorkspaceRequest, type DesktopConnectionState, type DesktopRfbFactory, type DesktopRfbLike, type DesktopStreamCapability, type DesktopStreamEvent, type DeviceEnrollmentApproveRequest, type DeviceEnrollmentApproveResponse, type DeviceEnrollmentDenyRequest, type DeviceEnrollmentDenyResponse, type DeviceEnrollmentLookupMachine, type DeviceEnrollmentLookupRequest, type DeviceEnrollmentLookupResponse, type DiscoverMcpCapabilitiesResponse, type Document, type DocumentBase, type DocumentSearchRequest, type DocumentSearchResponse, type DocumentSearchResult, type DocumentStatus, type EnableCapabilityRequest, type EnablePackRequest, type EnrollTokenExchangeRequest, type EnrollTokenExchangeResponse, type EnrollmentCredentials, type EnrollmentOs, type EntitlementValue, type Entitlements, type EntitlementsMode, type FetchLike, type FileAsset, type FileDownloadUrlResponse, type FileResourceRef, type FileStatus, type FileSystemCapability, type FileUploadData, type FsChangeKind, type FsChangedPayload, type FsDeleteRequest, type FsDeleteResponse, type FsEncoding, type FsListRequest, type FsListResponse, type FsMkdirRequest, type FsMkdirResponse, type FsMoveRequest, type FsMoveResponse, type FsNodeType, type FsReadRequest, type FsReadResponse, type FsTreeNode, type FsWriteRequest, type FsWriteResponse, type GetPackResponse, type GitCapability, type GitChangedPayload, type GitCommit, type GitDiffHunk, type GitDiffLine, type GitDiffLineType, type GitDiffRequest, type GitDiffResponse, type GitFileDiff, type GitFileStatus, type GitFileStatusCode, type GitHubAppInfo, type GitHubRepositoriesResponse, type GitHubRepository, type GitLogRequest, type GitLogResponse, type GitShowRequest, type GitShowResponse, type GitStatusRequest, type GitStatusResponse, type GoalSpec, KNOWN_PERMISSIONS, KNOWN_USAGE_EVENT_TYPES, type KnownPermission, type KnownSessionEventType, type KnownUsageEventType, type ListApiKeysResponse, type ListPacksResponse, type ListWorkspaceMembersResponse, type MachineKind, type MachineMetricsSeriesResponse, type MachineState, type MachineView, type MachinesResponse, type MetricSample, type MintEnrollTokenRequest, type MintEnrollTokenResponse, OpenGeniApiError, OpenGeniClient, type OpenGeniClientOptions, OpenGeniStreamError, type PackInstallation, type PackInstallationStatus, type Permission, type ProductAccessMode, type ProxySessionEventStreamOptions, type PtyCloseRequest, type PtyOpenRequest, type PtyOpenResponse, type PtyResizeRequest, type PtyWriteRequest, type ReasoningEffort, type RecordingAvailablePayload, type RecordingCapability, type RecordingCodec, type RecordingContentType, type RecordingFailedPayload, type RecordingFailedReason, type RecordingMode, type RecordingStartedPayload, type RegisterCapabilityPackRequest, type RepositoryResourceRef, type ResourceRef, SESSION_EVENT_TYPES, type SandboxBackend, type SandboxCapabilityName, type SandboxCommandOutputDeltaPayload, type SandboxOs, type ScheduledTask, type ScheduledTaskAgentConfig, type ScheduledTaskAgentConfigInput, type ScheduledTaskDayOfWeek, type ScheduledTaskOverlapPolicy, type ScheduledTaskRun, type ScheduledTaskRunMode, type ScheduledTaskRunStatus, type ScheduledTaskScheduleSpec, type ScheduledTaskStatus, type ScheduledTaskTriggerType, type SendMessageInput, type Session, type SessionCapabilities, type SessionEvent, type SessionEventStreamTransport, type SessionEventType, type SessionGoal, type SessionGoalCreatedBy, type SessionGoalStatus, type SessionStatus, type SessionStatusChangedPayload, type SessionStructuredCapabilities, type SessionTurn, type SessionTurnSource, type SessionTurnStatus, type SseMessage, type SseReStreamOptions, type SteerMessageResult, type StreamClosedPayload, type StreamConnectionState, type StreamOpenedPayload, type StreamRevokedPayload, type StreamSessionEventsOptions, type StreamUrlRotatedPayload, type SwapActiveSandboxRequest, type SwapActiveSandboxResponse, TTYD_SUBPROTOCOL, type TerminalCapability, type TerminalExecRequest, type TerminalExecResponse, type TerminalPtyExitedPayload, type TerminalPtyOutputDeltaPayload, type TerminalPtyStartedPayload, type ToolRef, TtydClientCommand, TtydServerCommand, type UpdateScheduledTaskRequest, type UpdateSessionGoalRequest, type UpdateSessionRequest, type UpdateSessionTurnRequest, type UpdateWorkspaceEnvironmentRequest, type UpdateWorkspaceMemberRequest, type UpdateWorkspaceRequest, type UploadFileInput, type UsageEvent, type UsageEventType, type UserApprovalDecisionEventInput, type UserInterruptEventInput, type UserMessageEventInput, type ViewerHeartbeatRequest, type ViewerHeartbeatResponse, type ViewerHolder, type Workspace, type WorkspaceEnvironment, type WorkspaceEnvironmentVariableMetadata, type WorkspaceMember, type WorkspaceRegisteredPack, applyUrlRotation, desktopSocketUrl, formatSseEvent, isRetryableStreamError, nextDesktopState, parseSseStream, proxySessionEventStream, resumeSequenceFromRequest, sessionEventsToSseResponse, sessionEventsToSseStream, streamSessionEvents, terminalSocketUrl, ttydAuthFrame, ttydInputFrame, ttydResizeFrame };