@opengeni/sdk 3.1.0 → 3.3.2

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 (41) hide show
  1. package/README.md +60 -8
  2. package/dist/accounts.d.ts +5 -1
  3. package/dist/accounts.js +13 -1
  4. package/dist/accounts.js.map +1 -1
  5. package/dist/artifacts.js +5 -5
  6. package/dist/browser.js +3 -3
  7. package/dist/{chunk-YTAWBDO2.js → chunk-JUS2UYRP.js} +2 -1
  8. package/dist/chunk-JUS2UYRP.js.map +1 -0
  9. package/dist/{chunk-GW3EJ2GP.js → chunk-KKRO2VCP.js} +27 -2
  10. package/dist/{chunk-GW3EJ2GP.js.map → chunk-KKRO2VCP.js.map} +1 -1
  11. package/dist/{chunk-VUQZAB3O.js → chunk-QT3KFVDP.js} +2 -2
  12. package/dist/{chunk-7ZXBPJZP.js → chunk-TRNI7KEO.js} +213 -42
  13. package/dist/chunk-TRNI7KEO.js.map +1 -0
  14. package/dist/{chunk-TX3EIENU.js → chunk-YXQX7RQT.js} +2 -2
  15. package/dist/client.d.ts +35 -11
  16. package/dist/company-profile.d.ts +13 -0
  17. package/dist/core.js +4 -4
  18. package/dist/document-authority.js +4 -4
  19. package/dist/editable-artifacts.js +1 -1
  20. package/dist/index.d.ts +4 -2
  21. package/dist/index.js +215 -5
  22. package/dist/index.js.map +1 -1
  23. package/dist/interaction.d.ts +3 -0
  24. package/dist/interaction.js +3 -1
  25. package/dist/realtime.d.ts +3 -1
  26. package/dist/realtime.js.map +1 -1
  27. package/dist/session-titles.d.ts +28 -0
  28. package/dist/types.d.ts +58 -2
  29. package/package.json +2 -2
  30. package/src/accounts.ts +18 -0
  31. package/src/client.ts +291 -35
  32. package/src/company-profile.ts +13 -0
  33. package/src/index.ts +18 -0
  34. package/src/interaction.ts +32 -0
  35. package/src/realtime.ts +1 -0
  36. package/src/session-titles.ts +84 -0
  37. package/src/types.ts +64 -1
  38. package/dist/chunk-7ZXBPJZP.js.map +0 -1
  39. package/dist/chunk-YTAWBDO2.js.map +0 -1
  40. /package/dist/{chunk-VUQZAB3O.js.map → chunk-QT3KFVDP.js.map} +0 -0
  41. /package/dist/{chunk-TX3EIENU.js.map → chunk-YXQX7RQT.js.map} +0 -0
package/src/index.ts CHANGED
@@ -30,6 +30,12 @@ export {
30
30
  OpenGeniStreamError,
31
31
  isRetryableStreamError,
32
32
  } from "./errors";
33
+ export {
34
+ AUTOMATIC_SESSION_TITLE_FALLBACK,
35
+ deriveSessionDisplayTitle,
36
+ sessionTitleIsPending,
37
+ } from "./session-titles";
38
+ export type { SessionDisplayTitleInput, SessionDisplayTitleOptions } from "./session-titles";
33
39
  export {
34
40
  formatSseEvent,
35
41
  proxySessionEventStream,
@@ -188,6 +194,8 @@ export {
188
194
  } from "./company-profile";
189
195
  export type {
190
196
  ActivateCompanyProfileRevisionRequest,
197
+ CompanyProfileAgentPolicy,
198
+ CompanyProfileAgentPolicyMode,
191
199
  CompanyProfileActivationEvent,
192
200
  CompanyProfileContent,
193
201
  CompanyProfileDiffRequest,
@@ -201,6 +209,7 @@ export type {
201
209
  CompanyProfileRevisionIdentity,
202
210
  RollbackCompanyProfileRequest,
203
211
  UpdateCompanyProfileRequest,
212
+ UpdateCompanyProfileAgentPolicyRequest,
204
213
  } from "./company-profile";
205
214
  export type {
206
215
  ActivateWorkspaceInstructionPolicyRequest,
@@ -490,6 +499,7 @@ export type {
490
499
  CodexAccount,
491
500
  CodexAccountOverview,
492
501
  CodexAccountsResponse,
502
+ OrganizationCodexAccountsResponse,
493
503
  CodexAllocatorUpdate,
494
504
  CodexAccountSwitchedPayload,
495
505
  CodexConnectionStatus,
@@ -514,6 +524,8 @@ export type {
514
524
  CodexRotationSettings,
515
525
  CodexUsage,
516
526
  CodexUsageMap,
527
+ WorkspaceCodexSubscriptionMode,
528
+ WorkspaceCodexSubscriptionSource,
517
529
  CodexUsagePayload,
518
530
  CodexUsageWindow,
519
531
  CompactSessionContextResult,
@@ -521,6 +533,7 @@ export type {
521
533
  CompleteFileUploadResponse,
522
534
  ConnectionKind,
523
535
  ConnectionMetadata,
536
+ McpConnectionAuthoritySelection,
524
537
  ConnectionOwnership,
525
538
  ConnectionResponse,
526
539
  ConnectionStatus,
@@ -549,6 +562,7 @@ export type {
549
562
  AddDocumentRequest,
550
563
  CreateApiKeyRequest,
551
564
  CreateApiKeyResponse,
565
+ CreateOrganizationApiKeyRequest,
552
566
  CreateCapabilityCatalogItemRequest,
553
567
  OpenGeniSlackBotInstallRequest,
554
568
  OpenGeniSlackBotInstallStart,
@@ -577,6 +591,8 @@ export type {
577
591
  CreateVariableSetRequest,
578
592
  CreateWorkspaceEnvironmentRequest,
579
593
  CreateWorkspaceRequest,
594
+ EnsureWorkspaceRequest,
595
+ EnsureWorkspaceResponse,
580
596
  DiscoverMcpCapabilitiesResponse,
581
597
  InstallSkillRequest,
582
598
  InstallLibrarySkillRequest,
@@ -677,6 +693,7 @@ export type {
677
693
  ListConnectionsResponse,
678
694
  ListPacksResponse,
679
695
  ListSlackUserLinkAccessRequestsResponse,
696
+ ListWorkspaceMemberCandidatesResponse,
680
697
  ListWorkspaceMembersResponse,
681
698
  McpServerConnectionRef,
682
699
  McpPersonalConnectionDelegation,
@@ -995,6 +1012,7 @@ export type {
995
1012
  WorkspaceEnvironment,
996
1013
  WorkspaceEnvironmentVariableMetadata,
997
1014
  WorkspaceMember,
1015
+ WorkspaceMemberCandidate,
998
1016
  PreviewSkillImportRequest,
999
1017
  ApiIntegrationAuthPreview,
1000
1018
  ApiIntegrationInstallationSummary,
@@ -1558,6 +1558,12 @@ export interface InteractionTransport {
1558
1558
  targetId: string,
1559
1559
  options?: OpenGeniRequestOptions,
1560
1560
  ): Promise<ComputerObservation>;
1561
+ captureComputerTarget(
1562
+ workspaceId: string,
1563
+ computerSessionId: string,
1564
+ targetId: string,
1565
+ options?: OpenGeniRequestOptions,
1566
+ ): Promise<ComputerFrame>;
1561
1567
  actInComputer(
1562
1568
  workspaceId: string,
1563
1569
  computerSessionId: string,
@@ -2402,6 +2408,10 @@ export class ComputerSessionResource {
2402
2408
  return await this.transport.observeComputerTarget(this.workspaceId, this.id, targetId, options);
2403
2409
  }
2404
2410
 
2411
+ async capture(targetId: string, options: OpenGeniRequestOptions = {}): Promise<ComputerFrame> {
2412
+ return await this.transport.captureComputerTarget(this.workspaceId, this.id, targetId, options);
2413
+ }
2414
+
2405
2415
  async act(
2406
2416
  request: ComputerActionRequest,
2407
2417
  options: OpenGeniRequestOptions = {},
@@ -2791,6 +2801,28 @@ export function parseComputerFrameMetadata(value: unknown): ComputerFrameMetadat
2791
2801
  return metadata;
2792
2802
  }
2793
2803
 
2804
+ export function decodeComputerFrameMetadataHeader(value: string): ComputerFrameMetadata {
2805
+ if (!value || value.length > 32 * 1024 || !/^[A-Za-z0-9_-]+$/u.test(value)) {
2806
+ throw new Error("computer frame metadata header is invalid");
2807
+ }
2808
+ const normalized = value.replace(/-/gu, "+").replace(/_/gu, "/");
2809
+ const padded = normalized.padEnd(Math.ceil(normalized.length / 4) * 4, "=");
2810
+ let decoded: string;
2811
+ try {
2812
+ decoded = atob(padded);
2813
+ } catch {
2814
+ throw new Error("computer frame metadata header is invalid");
2815
+ }
2816
+ const bytes = Uint8Array.from(decoded, (character) => character.charCodeAt(0));
2817
+ let metadata: unknown;
2818
+ try {
2819
+ metadata = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
2820
+ } catch {
2821
+ throw new Error("computer frame metadata header is invalid");
2822
+ }
2823
+ return parseComputerFrameMetadata(metadata);
2824
+ }
2825
+
2794
2826
  function newestRelevantBrowser(
2795
2827
  sessions: readonly BrowserSession[],
2796
2828
  associationSessionId: string,
package/src/realtime.ts CHANGED
@@ -30,6 +30,7 @@ import type { SessionRealtimeModel, WorkspaceRealtimeModelCatalogResponse } from
30
30
  export type SessionRealtimeClientLike = CodexRealtimeControllerClient & {
31
31
  getWorkspaceRealtimeModelCatalog(
32
32
  workspaceId: string,
33
+ options?: { signal?: AbortSignal | undefined },
33
34
  ): Promise<WorkspaceRealtimeModelCatalogResponse>;
34
35
  };
35
36
 
@@ -0,0 +1,84 @@
1
+ import {
2
+ AUTOMATIC_SESSION_TITLE_FALLBACK,
3
+ boundAutomaticSessionTitle,
4
+ containsSensitiveAutomaticSessionTitleValue,
5
+ } from "@opengeni/contracts/session-titles";
6
+ import type { Session } from "./types";
7
+
8
+ export { AUTOMATIC_SESSION_TITLE_FALLBACK };
9
+
10
+ // Session creation accepts a body far larger than a navigation label. Bound
11
+ // the source before any replace/split/normalization so a persisted large prompt
12
+ // cannot amplify memory or CPU on every browser render.
13
+ const PROMPT_PREVIEW_SCAN_MAX_CODE_UNITS = 4_096;
14
+
15
+ function deriveOpeningPromptPreview(value: unknown): string | null {
16
+ if (typeof value !== "string") return null;
17
+
18
+ const firstLine = value
19
+ .slice(0, PROMPT_PREVIEW_SCAN_MAX_CODE_UNITS)
20
+ .replace(/[\u0000-\u001f\u007f-\u009f]+/gu, "\n")
21
+ .split(/\n+/u)
22
+ .map((line) => line.trim())
23
+ .find(Boolean);
24
+ if (!firstLine) return null;
25
+ if (containsSensitiveAutomaticSessionTitleValue(firstLine)) return null;
26
+
27
+ const preview = boundAutomaticSessionTitle(firstLine.replace(/\s+/gu, " "))
28
+ .replace(/[\s.!?,;:\-–—]+$/u, "")
29
+ .trim();
30
+ if (!preview) return null;
31
+ return preview;
32
+ }
33
+
34
+ export type SessionDisplayTitleInput = {
35
+ title?: Session["title"] | undefined;
36
+ titleSource?: Session["titleSource"] | undefined;
37
+ initialMessage?: Session["initialMessage"] | null | undefined;
38
+ metadata?: Readonly<Record<string, unknown>> | undefined;
39
+ };
40
+
41
+ export type SessionDisplayTitleOptions = {
42
+ /** Optional metadata fields to try before the opening-prompt preview. */
43
+ metadataKeys?: readonly string[] | undefined;
44
+ };
45
+
46
+ /**
47
+ * Whether the durable title still represents the automatic-title pending state.
48
+ * A user-authored title always wins, even when its literal value is the fallback.
49
+ */
50
+ export function sessionTitleIsPending(input: SessionDisplayTitleInput): boolean {
51
+ const title = input.title?.trim() ?? "";
52
+ return input.titleSource !== "user" && (!title || title === AUTOMATIC_SESSION_TITLE_FALLBACK);
53
+ }
54
+
55
+ /**
56
+ * Derive the title a client should display for a session.
57
+ *
58
+ * A semantic agent title or human rename wins. While automatic naming is still
59
+ * pending, clients show a short, sensitive-safe preview of the opening prompt;
60
+ * the preview is never persisted as title metadata and is replaced naturally
61
+ * when `session.title_set` arrives. Obvious credential-, URL-, or identifier-
62
+ * shaped prompt prefixes retain the generic fallback.
63
+ */
64
+ export function deriveSessionDisplayTitle(
65
+ input: SessionDisplayTitleInput,
66
+ options: SessionDisplayTitleOptions = {},
67
+ ): string {
68
+ const title = input.title?.trim() ?? "";
69
+ if (input.titleSource === "user") {
70
+ return title || AUTOMATIC_SESSION_TITLE_FALLBACK;
71
+ }
72
+ if (title && !sessionTitleIsPending(input)) {
73
+ return title;
74
+ }
75
+
76
+ for (const key of options.metadataKeys ?? []) {
77
+ const value = input.metadata?.[key];
78
+ if (typeof value === "string" && value.trim().length > 0) {
79
+ return value.trim();
80
+ }
81
+ }
82
+
83
+ return deriveOpeningPromptPreview(input.initialMessage) ?? AUTOMATIC_SESSION_TITLE_FALLBACK;
84
+ }
package/src/types.ts CHANGED
@@ -329,6 +329,7 @@ export type SessionCapabilities = {
329
329
  codecs: ("h264-mp4" | "vp9-webm")[];
330
330
  reason: CapabilityUnavailableReason | null;
331
331
  };
332
+ /** @deprecated Use the managed ComputerSession interaction tools. */
332
333
  ComputerUse: {
333
334
  available: boolean;
334
335
  readOnly: boolean;
@@ -345,6 +346,7 @@ export type TerminalCapability = SessionCapabilities["Terminal"];
345
346
  export type GitCapability = SessionCapabilities["Git"];
346
347
  export type DesktopStreamCapability = SessionCapabilities["DesktopStream"];
347
348
  export type RecordingCapability = SessionCapabilities["Recording"];
349
+ /** @deprecated Use the managed ComputerSession interaction tools. */
348
350
  export type ComputerUseCapability = SessionCapabilities["ComputerUse"];
349
351
 
350
352
  // ── Stream-surfacing client surface (Phase 5) ───────────────────────────────
@@ -637,6 +639,7 @@ export type McpPersonalConnectionSummary = Pick<
637
639
 
638
640
  export type ConnectionMetadata = {
639
641
  id: string;
642
+ authorityId?: string | undefined;
640
643
  accountId: string;
641
644
  workspaceId: string;
642
645
  subjectId: string | null;
@@ -1354,6 +1357,7 @@ export type Session = {
1354
1357
  pausedDescendants: number;
1355
1358
  failedDescendants: number;
1356
1359
  unreadDescendants?: number | undefined;
1360
+ unreadFailedDescendants?: number | undefined;
1357
1361
  activelyWorkingDescendants?: number | undefined;
1358
1362
  /**
1359
1363
  * Earliest moment one of the counted `attentionDescendants` entered
@@ -2623,6 +2627,7 @@ export type ScheduledTaskAgentConfig = {
2623
2627
  model?: string | undefined;
2624
2628
  reasoningEffort?: ReasoningEffort | undefined;
2625
2629
  sandboxBackend?: SandboxBackend | undefined;
2630
+ machineTarget?: { targetSandboxId: string; workingDir?: string | undefined } | undefined;
2626
2631
  goal?: GoalSpec | undefined;
2627
2632
  executionClass?: "incident_telemetry" | undefined;
2628
2633
  incidentTelemetryPreflight?: IncidentTelemetryPreflight | undefined;
@@ -2795,6 +2800,7 @@ export const KNOWN_PERMISSIONS = [
2795
2800
  "api_keys:manage",
2796
2801
  "connections:read",
2797
2802
  "connections:write",
2803
+ "capabilities:manage",
2798
2804
  "environments:manage",
2799
2805
  "environments:use",
2800
2806
  "variable-sets:list",
@@ -3156,6 +3162,23 @@ export type CodexConnectionStatus = {
3156
3162
  } | null;
3157
3163
  /** How many Codex accounts the workspace has connected. */
3158
3164
  accountCount?: number;
3165
+ source?: WorkspaceCodexSubscriptionSource;
3166
+ };
3167
+
3168
+ export type WorkspaceCodexSubscriptionMode =
3169
+ | "automatic"
3170
+ | "workspace"
3171
+ | "organization"
3172
+ | "disabled";
3173
+
3174
+ export type WorkspaceCodexSubscriptionSource = {
3175
+ accountId: string;
3176
+ workspaceId: string;
3177
+ workspaceKind: "personal" | "shared";
3178
+ mode: WorkspaceCodexSubscriptionMode;
3179
+ effectiveSource: "workspace" | "organization" | "disabled";
3180
+ workspaceAvailable: boolean;
3181
+ organizationAvailable: boolean;
3159
3182
  };
3160
3183
 
3161
3184
  /**
@@ -3205,6 +3228,7 @@ export type CodexUsagePayload = {
3205
3228
  /** One connected Codex (ChatGPT) account in a workspace (multi-account P1). Metadata only. */
3206
3229
  export type CodexAccount = {
3207
3230
  id: string;
3231
+ source?: "workspace" | "organization";
3208
3232
  chatgptAccountId?: string | null;
3209
3233
  label?: string | null;
3210
3234
  email?: string | null;
@@ -3317,6 +3341,7 @@ export type CodexRotationSettings = {
3317
3341
  export type CodexAccountsResponse = {
3318
3342
  accounts: CodexAccount[];
3319
3343
  activeAccountId: string | null;
3344
+ source?: WorkspaceCodexSubscriptionSource;
3320
3345
  /** Added by Apps-aware servers; absent on older same-major deployments. */
3321
3346
  apps?: {
3322
3347
  available: boolean;
@@ -3328,6 +3353,8 @@ export type CodexAccountsResponse = {
3328
3353
  settings: CodexRotationSettings;
3329
3354
  };
3330
3355
 
3356
+ export type OrganizationCodexAccountsResponse = Omit<CodexAccountsResponse, "apps" | "source">;
3357
+
3331
3358
  export type CodexAppsUpdate = {
3332
3359
  credentialId: string | null;
3333
3360
  version: number;
@@ -3467,6 +3494,8 @@ export type ClientAuthConfig =
3467
3494
  session: "cookie";
3468
3495
  /** Defaults to true when omitted by an older deployment. */
3469
3496
  emailVerificationRequired?: boolean;
3497
+ /** Configured managed sign-in providers; omitted by older deployments. */
3498
+ socialProviders?: ("google" | "github")[];
3470
3499
  };
3471
3500
 
3472
3501
  // Kept value-identical to @opengeni/contracts and pinned by the SDK contract
@@ -3492,6 +3521,7 @@ export type ClientConfig = {
3492
3521
  models: ClientModel[];
3493
3522
  defaultReasoningEffort: ReasoningEffort;
3494
3523
  allowedReasoningEfforts: ReasoningEffort[];
3524
+ defaultSandboxBackend?: SandboxBackend | undefined;
3495
3525
  mcpServers: { id: string; name: string }[];
3496
3526
  /** Deployment defaults and hard maximum for built-in OpenGeni session tools. */
3497
3527
  firstPartyMcpTools?:
@@ -4217,6 +4247,20 @@ export type CreateWorkspaceRequest = {
4217
4247
  agentInstructions?: string | null | undefined;
4218
4248
  };
4219
4249
 
4250
+ export type EnsureWorkspaceRequest = {
4251
+ accountId: string;
4252
+ externalSource: string;
4253
+ externalId: string;
4254
+ name: string;
4255
+ slug?: string | undefined;
4256
+ agentInstructions?: string | null | undefined;
4257
+ };
4258
+
4259
+ export type EnsureWorkspaceResponse = {
4260
+ workspace: Workspace;
4261
+ created: boolean;
4262
+ };
4263
+
4220
4264
  export type UpdateWorkspaceRequest = {
4221
4265
  name?: string | undefined;
4222
4266
  slug?: string | null | undefined;
@@ -4251,6 +4295,12 @@ export type CreateApiKeyResponse = {
4251
4295
  token: string;
4252
4296
  };
4253
4297
 
4298
+ export type CreateOrganizationApiKeyRequest = {
4299
+ name: string;
4300
+ description?: string | undefined;
4301
+ expiresAt?: string | undefined;
4302
+ };
4303
+
4254
4304
  export type ListApiKeysResponse = {
4255
4305
  apiKeys: ApiKey[];
4256
4306
  };
@@ -4270,8 +4320,20 @@ export type ListWorkspaceMembersResponse = {
4270
4320
  members: WorkspaceMember[];
4271
4321
  };
4272
4322
 
4323
+ export type WorkspaceMemberCandidate = {
4324
+ organizationMembershipId: string;
4325
+ subjectId: string;
4326
+ name: string | null;
4327
+ email: string | null;
4328
+ organizationRole: "owner" | "admin" | "member";
4329
+ };
4330
+
4331
+ export type ListWorkspaceMemberCandidatesResponse = {
4332
+ members: WorkspaceMemberCandidate[];
4333
+ };
4334
+
4273
4335
  export type AddWorkspaceMemberRequest = {
4274
- email: string;
4336
+ organizationMembershipId: string;
4275
4337
  role?: string | undefined;
4276
4338
  permissions: Permission[];
4277
4339
  };
@@ -4781,6 +4843,7 @@ export type ScheduledTaskAgentConfigInput = {
4781
4843
  model?: string | undefined;
4782
4844
  reasoningEffort?: ReasoningEffort | undefined;
4783
4845
  sandboxBackend?: SandboxBackend | undefined;
4846
+ machineTarget?: { targetSandboxId: string; workingDir?: string | undefined } | undefined;
4784
4847
  goal?: GoalSpec | undefined;
4785
4848
  executionClass?: "incident_telemetry" | undefined;
4786
4849
  incidentTelemetryPreflight?: IncidentTelemetryPreflightInput | undefined;