@opengeni/sdk 4.0.2 → 5.0.3-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 (48) hide show
  1. package/README.md +58 -9
  2. package/dist/artifact-client.d.ts +18 -8
  3. package/dist/artifacts.js +4 -4
  4. package/dist/browser.js +2 -2
  5. package/dist/chat/ids.d.ts +3 -3
  6. package/dist/chat/index.js +38 -51
  7. package/dist/chat/index.js.map +1 -1
  8. package/dist/chat/opengeni.d.ts +10 -12
  9. package/dist/chat/types.d.ts +7 -3
  10. package/dist/{chunk-O23OOWJK.js → chunk-4YAL54F3.js} +2 -2
  11. package/dist/{chunk-UW22XVCT.js → chunk-ARGX7UY4.js} +97 -2
  12. package/dist/chunk-ARGX7UY4.js.map +1 -0
  13. package/dist/chunk-J5USCWPE.js +195 -0
  14. package/dist/chunk-J5USCWPE.js.map +1 -0
  15. package/dist/{chunk-WNEGCYCE.js → chunk-TARU5CD2.js} +1 -1
  16. package/dist/chunk-TARU5CD2.js.map +1 -0
  17. package/dist/{chunk-3IZMCD2K.js → chunk-TOB3B4ZJ.js} +28 -41
  18. package/dist/chunk-TOB3B4ZJ.js.map +1 -0
  19. package/dist/{chunk-2H7P45YQ.js → chunk-UQGHX4DI.js} +173 -7
  20. package/dist/chunk-UQGHX4DI.js.map +1 -0
  21. package/dist/client.d.ts +39 -4
  22. package/dist/core.js +3 -3
  23. package/dist/document-authority.js +3 -3
  24. package/dist/editable-artifacts.js +1 -1
  25. package/dist/embedding-client.d.ts +72 -0
  26. package/dist/index.d.ts +4 -1
  27. package/dist/index.js +13 -8
  28. package/dist/index.js.map +1 -1
  29. package/dist/site-tool-bridge.d.ts +39 -0
  30. package/dist/site.d.ts +2 -0
  31. package/dist/site.js +7 -3
  32. package/dist/types.d.ts +23 -12
  33. package/package.json +3 -2
  34. package/src/artifact-client.ts +38 -63
  35. package/src/chat/ids.ts +3 -3
  36. package/src/chat/opengeni.ts +41 -57
  37. package/src/chat/types.ts +7 -3
  38. package/src/client.ts +253 -12
  39. package/src/embedding-client.ts +308 -0
  40. package/src/index.ts +16 -1
  41. package/src/site-tool-bridge.ts +141 -0
  42. package/src/site.ts +7 -0
  43. package/src/types.ts +18 -6
  44. package/dist/chunk-2H7P45YQ.js.map +0 -1
  45. package/dist/chunk-3IZMCD2K.js.map +0 -1
  46. package/dist/chunk-UW22XVCT.js.map +0 -1
  47. package/dist/chunk-WNEGCYCE.js.map +0 -1
  48. /package/dist/{chunk-O23OOWJK.js.map → chunk-4YAL54F3.js.map} +0 -0
package/src/client.ts CHANGED
@@ -1,3 +1,11 @@
1
+ import type {
2
+ RollbackWorkspaceArtifactRequest,
3
+ SetWorkspaceArtifactStatusRequest,
4
+ WorkspaceArtifactDetailResponse,
5
+ WorkspaceArtifactListOptions,
6
+ WorkspaceArtifactListResponse,
7
+ WorkspaceArtifactMutationResponse,
8
+ } from "./workspace-artifacts";
1
9
  import type { CreateFeedbackRequest, Feedback, FeedbackSubmissionResponse } from "./feedback";
2
10
  import {
3
11
  OpenGeniApiContractMismatchError,
@@ -380,7 +388,7 @@ import type {
380
388
  UpdateSessionVisibilityResponse,
381
389
  UninstallPackRequest,
382
390
  UninstallPackResult,
383
- SessionEndUser,
391
+ SessionScopeSubjectId,
384
392
  SessionEvent,
385
393
  SessionEventCompactResult,
386
394
  SessionEventCompactResultOptions,
@@ -593,14 +601,14 @@ function sessionListQuery(options: {
593
601
  originSiteId?: string;
594
602
  limit?: number;
595
603
  parentSessionId?: string | null;
596
- endUser?: SessionEndUser;
604
+ scopeSubjectId?: SessionScopeSubjectId;
597
605
  }): Record<string, string> {
598
- const { limit, parentSessionId, endUser } = options;
606
+ const { limit, parentSessionId, scopeSubjectId } = options;
599
607
  return {
600
608
  ...(options.originSiteId ? { originSiteId: options.originSiteId } : {}),
601
609
  ...(limit === undefined ? {} : { limit: String(limit) }),
602
610
  ...(parentSessionId === undefined ? {} : { parentSessionId: parentSessionId ?? "null" }),
603
- ...(endUser === undefined ? {} : { endUserSource: endUser.source, endUserId: endUser.id }),
611
+ ...(scopeSubjectId === undefined ? {} : { scopeSubjectId }),
604
612
  };
605
613
  }
606
614
 
@@ -610,7 +618,7 @@ export type SessionListPageOptions = {
610
618
  limit?: number;
611
619
  parentSessionId?: string | null;
612
620
  /** Only sessions carrying this exact opaque end-user label. */
613
- endUser?: SessionEndUser;
621
+ scopeSubjectId?: SessionScopeSubjectId;
614
622
  cursor?: string;
615
623
  search?: string;
616
624
  /** Restrict rows to one workspace project; null selects unfiled rows. */
@@ -878,8 +886,9 @@ function createLazyToolsFacade(transport: OpenGeniToolTransport): OpenGeniToolsF
878
886
  }
879
887
 
880
888
  export class OpenGeniClient {
889
+ protected externalActorHeader?: string;
881
890
  private readonly baseUrl: string;
882
- private readonly options: OpenGeniClientOptions;
891
+ protected readonly options: OpenGeniClientOptions;
883
892
  private readonly fetchImpl: FetchLike;
884
893
  private readonly sessionCommandTimeoutMs: number;
885
894
  private readonly active = new Map<string, SingleFlightReadEntry>();
@@ -1128,7 +1137,7 @@ export class OpenGeniClient {
1128
1137
  ): Promise<CreateSessionResponse> {
1129
1138
  return await this.requestJson<CreateSessionResponse>(
1130
1139
  "POST",
1131
- `/v1/workspaces/${workspaceId}/sessions`,
1140
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/sessions`,
1132
1141
  request,
1133
1142
  );
1134
1143
  }
@@ -1304,7 +1313,7 @@ export class OpenGeniClient {
1304
1313
  parentSessionId?: string | null;
1305
1314
  search?: string;
1306
1315
  /** Only sessions carrying this exact opaque end-user label. */
1307
- endUser?: SessionEndUser;
1316
+ scopeSubjectId?: SessionScopeSubjectId;
1308
1317
  } = {},
1309
1318
  ): Promise<Session[]> {
1310
1319
  // Search and Site filtering use the pin-aware page endpoint. An older API silently
@@ -4820,6 +4829,152 @@ export class OpenGeniClient {
4820
4829
  return await this.requestJson<Workspace[]>("GET", "/v1/workspaces");
4821
4830
  }
4822
4831
 
4832
+ /** Uses this client's fixed actor and standard contract/error/abort handling.
4833
+ * Disconnect revokes OpenGeni connection access, not upstream provider consent. */
4834
+
4835
+ connectTransport(): import("@opengeni/connect").ConnectTransport {
4836
+ const root = (workspaceId: string) =>
4837
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/connect`;
4838
+ return {
4839
+ catalog: (workspaceId, options) =>
4840
+ this.requestJson("GET", `${root(workspaceId)}/catalog`, undefined, undefined, options),
4841
+ accounts: (workspaceId, options) =>
4842
+ this.requestJson("GET", `${root(workspaceId)}/accounts`, undefined, undefined, options),
4843
+ pending: (workspaceId, options) =>
4844
+ this.requestJson("GET", `${root(workspaceId)}/attempts`, undefined, undefined, options),
4845
+ begin: (workspaceId, input, options) =>
4846
+ this.requestJson("POST", `${root(workspaceId)}/attempts`, input, undefined, options),
4847
+ get: (workspaceId, id, options) =>
4848
+ this.requestJson(
4849
+ "GET",
4850
+ `${root(workspaceId)}/attempts/${encodeURIComponent(id)}`,
4851
+ undefined,
4852
+ undefined,
4853
+ options,
4854
+ ),
4855
+ advance: (workspaceId, id, input, options) =>
4856
+ this.requestJson(
4857
+ "POST",
4858
+ `${root(workspaceId)}/attempts/${encodeURIComponent(id)}/advance`,
4859
+ input,
4860
+ undefined,
4861
+ options,
4862
+ ),
4863
+ cancel: (workspaceId, id, input, options) =>
4864
+ this.requestJson(
4865
+ "POST",
4866
+ `${root(workspaceId)}/attempts/${encodeURIComponent(id)}/cancel`,
4867
+ input,
4868
+ undefined,
4869
+ options,
4870
+ ),
4871
+ disconnect: async (workspaceId, id, options) => {
4872
+ if (id.startsWith("social:")) {
4873
+ const connectionId = id.slice("social:".length);
4874
+ if (!/^[0-9a-f-]{36}$/i.test(connectionId)) throw new Error("Invalid social account ID");
4875
+ await this.disconnectSocialConnection(workspaceId, connectionId);
4876
+ return;
4877
+ }
4878
+ if (id.startsWith("lens-registration:")) {
4879
+ const registrationId = id.slice("lens-registration:".length);
4880
+ if (
4881
+ !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(registrationId)
4882
+ )
4883
+ throw new Error("Invalid Lens registration ID");
4884
+ await this.requestJson(
4885
+ "DELETE",
4886
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/pr-review/registrations/${registrationId}`,
4887
+ undefined,
4888
+ undefined,
4889
+ options,
4890
+ );
4891
+ return;
4892
+ }
4893
+ if (id.startsWith("github-installation:")) {
4894
+ const installationId = id.slice("github-installation:".length);
4895
+ if (
4896
+ !/^[1-9][0-9]*$/.test(installationId) ||
4897
+ !Number.isSafeInteger(Number(installationId))
4898
+ )
4899
+ throw new Error("Invalid GitHub installation ID");
4900
+ await this.requestJson(
4901
+ "DELETE",
4902
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/github/installations/${installationId}`,
4903
+ undefined,
4904
+ undefined,
4905
+ options,
4906
+ );
4907
+ return;
4908
+ }
4909
+ const expectedVersion = options?.expectedVersion;
4910
+ if (
4911
+ expectedVersion !== undefined &&
4912
+ (!Number.isSafeInteger(expectedVersion) || expectedVersion < 1)
4913
+ ) {
4914
+ throw new Error("invalid expected connection version");
4915
+ }
4916
+ const query = expectedVersion === undefined ? "" : `?expectedVersion=${expectedVersion}`;
4917
+ await this.requestJson(
4918
+ "DELETE",
4919
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/connections/${encodeURIComponent(id)}${query}`,
4920
+ undefined,
4921
+ undefined,
4922
+ options,
4923
+ );
4924
+ },
4925
+ };
4926
+ }
4927
+
4928
+ /** Browse first-party Atlassian sources without choosing or starting sync. */
4929
+ async browseAtlassianSources(
4930
+ workspaceId: string,
4931
+ connectionId: string,
4932
+ ): Promise<import("@opengeni/contracts/atlassian").AtlassianBrowseResponse> {
4933
+ return this.requestJson(
4934
+ "GET",
4935
+ `/v1/workspaces/${workspaceId}/connections/atlassian/${connectionId}/browse`,
4936
+ );
4937
+ }
4938
+
4939
+ async saveAtlassianSources(
4940
+ workspaceId: string,
4941
+ connectionId: string,
4942
+ request: import("@opengeni/contracts/atlassian").SaveAtlassianSourcesRequest,
4943
+ ): Promise<import("./types").ConnectionResponse> {
4944
+ return this.requestJson(
4945
+ "POST",
4946
+ `/v1/workspaces/${workspaceId}/connections/atlassian/${connectionId}/source`,
4947
+ request,
4948
+ );
4949
+ }
4950
+
4951
+ async setAtlassianLifecycle(
4952
+ workspaceId: string,
4953
+ connectionId: string,
4954
+ request: import("@opengeni/contracts/atlassian").AtlassianLifecycleActionRequest,
4955
+ ): Promise<import("./types").ConnectionResponse> {
4956
+ return this.requestJson(
4957
+ "PATCH",
4958
+ `/v1/workspaces/${workspaceId}/connections/atlassian/${connectionId}/lifecycle`,
4959
+ request,
4960
+ );
4961
+ }
4962
+
4963
+ /** Begin durable setup. Completion requirements are provider-specific. */
4964
+ async beginConnect(
4965
+ workspaceId: string,
4966
+ request: {
4967
+ providerId: string;
4968
+ ownership: "personal" | "workspace";
4969
+ returnUrl: string;
4970
+ idempotencyKey: string;
4971
+ reconnectAccountId?: string;
4972
+ installationTarget?: import("@opengeni/contracts/connect").ConnectInstallationTarget;
4973
+ },
4974
+ ): Promise<import("@opengeni/contracts/connect").ConnectAttempt> {
4975
+ return this.requestJson("POST", `/v1/workspaces/${workspaceId}/connect/attempts`, request);
4976
+ }
4977
+
4823
4978
  async createWorkspace(request: CreateWorkspaceRequest): Promise<Workspace> {
4824
4979
  return await this.requestJson<Workspace>("POST", "/v1/workspaces", request);
4825
4980
  }
@@ -6634,6 +6789,84 @@ export class OpenGeniClient {
6634
6789
  );
6635
6790
  }
6636
6791
 
6792
+ async listWorkspaceArtifacts(
6793
+ workspaceId: string,
6794
+ options: WorkspaceArtifactListOptions & { signal?: AbortSignal } = {},
6795
+ ): Promise<WorkspaceArtifactListResponse> {
6796
+ const query = new URLSearchParams();
6797
+ if (options.limit !== undefined) query.set("limit", String(options.limit));
6798
+ if (options.cursor) query.set("cursor", options.cursor);
6799
+ if (options.status) query.set("status", options.status);
6800
+ if (options.sourceSessionId) query.set("sourceSessionId", options.sourceSessionId);
6801
+ const suffix = query.size > 0 ? `?${query.toString()}` : "";
6802
+ return await this.requestJson<WorkspaceArtifactListResponse>(
6803
+ "GET",
6804
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/published-artifacts${suffix}`,
6805
+ undefined,
6806
+ undefined,
6807
+ options,
6808
+ );
6809
+ }
6810
+
6811
+ async getWorkspaceArtifact(
6812
+ workspaceId: string,
6813
+ artifactId: string,
6814
+ options: { signal?: AbortSignal } = {},
6815
+ ): Promise<WorkspaceArtifactDetailResponse> {
6816
+ return await this.requestJson<WorkspaceArtifactDetailResponse>(
6817
+ "GET",
6818
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/published-artifacts/${encodeURIComponent(artifactId)}`,
6819
+ undefined,
6820
+ undefined,
6821
+ options,
6822
+ );
6823
+ }
6824
+
6825
+ /** Display-only HTML delivery: do not download the retained source bundle to render a Site. */
6826
+ async getWorkspaceArtifactHtml(
6827
+ workspaceId: string,
6828
+ artifactId: string,
6829
+ options: { versionId: string; signal?: AbortSignal },
6830
+ ): Promise<string> {
6831
+ const response = await this.requestResponse(
6832
+ "GET",
6833
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/published-artifacts/${encodeURIComponent(artifactId)}/html`,
6834
+ { versionId: options.versionId },
6835
+ options,
6836
+ );
6837
+ return response.text();
6838
+ }
6839
+
6840
+ async rollbackWorkspaceArtifact(
6841
+ workspaceId: string,
6842
+ artifactId: string,
6843
+ request: RollbackWorkspaceArtifactRequest,
6844
+ options: { signal?: AbortSignal } = {},
6845
+ ): Promise<WorkspaceArtifactMutationResponse> {
6846
+ return await this.requestJson<WorkspaceArtifactMutationResponse>(
6847
+ "POST",
6848
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/published-artifacts/${encodeURIComponent(artifactId)}/rollback`,
6849
+ request,
6850
+ undefined,
6851
+ options,
6852
+ );
6853
+ }
6854
+
6855
+ async setWorkspaceArtifactStatus(
6856
+ workspaceId: string,
6857
+ artifactId: string,
6858
+ request: SetWorkspaceArtifactStatusRequest,
6859
+ options: { signal?: AbortSignal } = {},
6860
+ ): Promise<WorkspaceArtifactMutationResponse> {
6861
+ return await this.requestJson<WorkspaceArtifactMutationResponse>(
6862
+ "PATCH",
6863
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/published-artifacts/${encodeURIComponent(artifactId)}/status`,
6864
+ request,
6865
+ undefined,
6866
+ options,
6867
+ );
6868
+ }
6869
+
6637
6870
  /** Search the official MCP registry for installable capabilities. */
6638
6871
  async discoverMcpCapabilities(
6639
6872
  workspaceId: string,
@@ -7474,9 +7707,7 @@ export class OpenGeniClient {
7474
7707
  {
7475
7708
  ...(options.limit === undefined ? {} : { limit: String(options.limit) }),
7476
7709
  ...(options.cursor === undefined ? {} : { cursor: options.cursor }),
7477
- ...(options.endUser
7478
- ? { endUserSource: options.endUser.source, endUserId: options.endUser.id }
7479
- : {}),
7710
+ ...(options.scopeSubjectId ? { scopeSubjectId: options.scopeSubjectId } : {}),
7480
7711
  ...(options.status === undefined ? {} : { status: options.status }),
7481
7712
  },
7482
7713
  { signal: options.signal },
@@ -7577,12 +7808,19 @@ export class OpenGeniClient {
7577
7808
  private headers(correlationId?: string): Record<string, string> {
7578
7809
  const extra =
7579
7810
  typeof this.options.headers === "function" ? this.options.headers() : this.options.headers;
7580
- return {
7811
+ const headers: Record<string, string> = {
7581
7812
  ...(this.options.apiKey ? { Authorization: `Bearer ${this.options.apiKey}` } : {}),
7582
7813
  ...extra,
7583
7814
  [OPENGENI_API_CONTRACT_HEADER]: OPENGENI_API_CONTRACT_REVISION,
7584
7815
  ...(correlationId ? { [OPENGENI_CORRELATION_HEADER]: correlationId } : {}),
7585
7816
  };
7817
+ if (this.externalActorHeader) {
7818
+ for (const key of Object.keys(headers)) {
7819
+ if (key.toLowerCase() === "x-opengeni-external-actor") delete headers[key];
7820
+ }
7821
+ headers["x-opengeni-external-actor"] = this.externalActorHeader;
7822
+ }
7823
+ return headers;
7586
7824
  }
7587
7825
 
7588
7826
  private url(path: string, query: Record<string, string> = {}): string {
@@ -7989,6 +8227,9 @@ export class OpenGeniClient {
7989
8227
  const correlationId = crypto.randomUUID();
7990
8228
  const abort = requestAbortSignal(options);
7991
8229
  try {
8230
+ if (abort.signal?.aborted) {
8231
+ throw abort.signal.reason ?? new DOMException("Request aborted", "AbortError");
8232
+ }
7992
8233
  let response: FetchResponse;
7993
8234
  try {
7994
8235
  response = await awaitWithAbort(
@@ -0,0 +1,308 @@
1
+ import { OpenGeniClient as OpenGeniArtifactClient } from "./artifact-client";
2
+ import type { OpenGeniClientOptions, OpenGeniRequestOptions } from "./client";
3
+ import type { AddWorkspaceMemberRequest } from "./types";
4
+ import type {
5
+ ExternalIdentityLink,
6
+ BeginExternalIdentityLinkRequest,
7
+ BeginExternalIdentityLinkResponse,
8
+ ConfirmExternalIdentityLinkRequest,
9
+ ExternalIdentityLinkPreview,
10
+ ExternalIdentityLinkPage,
11
+ } from "@opengeni/contracts/external-identities";
12
+
13
+ /** Public product embedding administration, kept out of the native browser client. */
14
+ export class OpenGeniEmbeddingClient extends OpenGeniArtifactClient {
15
+ /** Server-side organization-key client scoped to one host-authenticated user.
16
+ * Does not mutate this client, provision workspace membership, or link native
17
+ * identities. The API verifies key and membership authority on each request. */
18
+ asUser(externalId: string, options: { source?: string } = {}): this {
19
+ if (typeof window !== "undefined")
20
+ throw new Error("asUser is a server-side API; keep organization keys on your backend");
21
+ const source = options.source ?? "default";
22
+ const validOpaqueText = (value: unknown, maxBytes: number): value is string =>
23
+ typeof value === "string" &&
24
+ value.length > 0 &&
25
+ value.length <= maxBytes &&
26
+ !value.includes("\0") &&
27
+ !/[\uD800-\uDFFF]/u.test(value) &&
28
+ new TextEncoder().encode(value).byteLength <= maxBytes;
29
+ if (!validOpaqueText(externalId, 1024) || !validOpaqueText(source, 200)) {
30
+ throw new Error("Invalid external identity reference");
31
+ }
32
+ const Client = this.constructor as new (options: OpenGeniClientOptions) => this;
33
+ const client = new Client({ ...this.options });
34
+ client.externalActorHeader = encodeURIComponent(
35
+ JSON.stringify({ mode: "external", identity: { externalId, source } }),
36
+ );
37
+ return client;
38
+ }
39
+
40
+ /** Explicitly use a confirmed native delegation. Unlike asUser, new resources
41
+ * belong to the native user. Existing external resources are never reassigned.
42
+ * A stale, expired or revoked link is rejected by the server on every request. */
43
+ asLinkedUser(
44
+ externalId: string,
45
+ options: { source?: string; linkId: string; expectedLinkRevision: number },
46
+ ): this {
47
+ if (
48
+ !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(options.linkId) ||
49
+ !Number.isSafeInteger(options.expectedLinkRevision) ||
50
+ options.expectedLinkRevision < 1
51
+ )
52
+ throw new Error("A confirmed identity link and its exact revision are required");
53
+ const client = this.asUser(
54
+ externalId,
55
+ options.source === undefined ? {} : { source: options.source },
56
+ );
57
+ const identity = JSON.parse(decodeURIComponent(client.externalActorHeader!)).identity;
58
+ client.externalActorHeader = encodeURIComponent(
59
+ JSON.stringify({
60
+ mode: "linked_native",
61
+ identity,
62
+ linkId: options.linkId,
63
+ expectedLinkRevision: options.expectedLinkRevision,
64
+ }),
65
+ );
66
+ return client;
67
+ }
68
+
69
+ /** Optional native-account delegation. Invoke on a server-side asUser client.
70
+ * Pass the one-time challenge to the native consent screen, never a URL query
71
+ * or analytics event. Ordinary external embedding needs none of this. */
72
+ async beginIdentityLink(
73
+ workspaceId: string,
74
+ input: BeginExternalIdentityLinkRequest,
75
+ ): Promise<BeginExternalIdentityLinkResponse> {
76
+ return this.requestJson(
77
+ "POST",
78
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links`,
79
+ input,
80
+ );
81
+ }
82
+
83
+ async getIdentityLink(workspaceId: string, linkId: string): Promise<ExternalIdentityLink> {
84
+ return this.requestJson(
85
+ "GET",
86
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links/${encodeURIComponent(linkId)}`,
87
+ );
88
+ }
89
+
90
+ /** Only links belonging to the effective participant; no organization-wide directory. */
91
+ async listIdentityLinks(workspaceId: string, cursor?: string): Promise<ExternalIdentityLinkPage> {
92
+ return this.requestJson(
93
+ "GET",
94
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links${cursor ? `?cursor=${encodeURIComponent(cursor)}` : ""}`,
95
+ );
96
+ }
97
+
98
+ /** Requires a canonical native browser session, not an organization API key. */
99
+ async previewIdentityLink(
100
+ workspaceId: string,
101
+ linkId: string,
102
+ challenge: string,
103
+ ): Promise<ExternalIdentityLinkPreview> {
104
+ return this.requestJson(
105
+ "POST",
106
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links/${encodeURIComponent(linkId)}/preview`,
107
+ { challenge },
108
+ );
109
+ }
110
+
111
+ async confirmIdentityLink(
112
+ workspaceId: string,
113
+ linkId: string,
114
+ input: ConfirmExternalIdentityLinkRequest,
115
+ ): Promise<ExternalIdentityLink> {
116
+ return this.requestJson(
117
+ "POST",
118
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links/${encodeURIComponent(linkId)}/confirm`,
119
+ input,
120
+ );
121
+ }
122
+
123
+ async revokeIdentityLink(
124
+ workspaceId: string,
125
+ linkId: string,
126
+ expectedRevision: number,
127
+ ): Promise<ExternalIdentityLink> {
128
+ return this.requestJson(
129
+ "POST",
130
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/identity-links/${encodeURIComponent(linkId)}/revoke`,
131
+ { expectedRevision },
132
+ );
133
+ }
134
+
135
+ /** Service-only lifecycle for an external actor's organization membership.
136
+ * A successful reactivation does not restore revoked workspace grants. */
137
+ async updateExternalIdentityMembership(
138
+ organizationId: string,
139
+ membershipId: string,
140
+ request: import("@opengeni/contracts/external-identities").UpdateExternalIdentityMembershipRequest,
141
+ options: { signal?: AbortSignal } = {},
142
+ ): Promise<import("@opengeni/contracts").OrganizationMember> {
143
+ return this.requestJson(
144
+ "PATCH",
145
+ `/v1/organizations/${encodeURIComponent(organizationId)}/external-members/${encodeURIComponent(membershipId)}`,
146
+ request,
147
+ undefined,
148
+ options,
149
+ );
150
+ }
151
+
152
+ async listConnectProviders(
153
+ workspaceId: string,
154
+ ): Promise<import("@opengeni/contracts/connect").ConnectProvider[]> {
155
+ return this.requestJson("GET", `/v1/workspaces/${workspaceId}/connect/catalog`);
156
+ }
157
+
158
+ /** Register credential-free, external-owner host authority. Does not itself
159
+ * authorize an execution or install MCP tools. */
160
+ async createHostMcpBinding(
161
+ workspaceId: string,
162
+ request: import("@opengeni/contracts/host-mcp-bindings").CreateHostMcpBindingRequest,
163
+ options: OpenGeniRequestOptions = {},
164
+ ): Promise<import("@opengeni/contracts/host-mcp-bindings").HostMcpBinding> {
165
+ return this.requestJson(
166
+ "POST",
167
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-bindings`,
168
+ request,
169
+ {},
170
+ options,
171
+ );
172
+ }
173
+
174
+ async getHostMcpBinding(
175
+ workspaceId: string,
176
+ bindingId: string,
177
+ options: OpenGeniRequestOptions = {},
178
+ ): Promise<import("@opengeni/contracts/host-mcp-bindings").HostMcpBinding> {
179
+ return this.requestJson(
180
+ "GET",
181
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-bindings/${encodeURIComponent(bindingId)}`,
182
+ undefined,
183
+ {},
184
+ options,
185
+ );
186
+ }
187
+
188
+ async revokeHostMcpBinding(
189
+ workspaceId: string,
190
+ bindingId: string,
191
+ request: { expectedGeneration: number },
192
+ options: OpenGeniRequestOptions = {},
193
+ ): Promise<import("@opengeni/contracts/host-mcp-bindings").HostMcpBinding> {
194
+ return this.requestJson(
195
+ "POST",
196
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-bindings/${encodeURIComponent(bindingId)}/revoke`,
197
+ request,
198
+ {},
199
+ options,
200
+ );
201
+ }
202
+
203
+ /** Issue owner-scoped grant metadata; accepted execution must separately admit it. */
204
+ async issueHostMcpDelegation(
205
+ workspaceId: string,
206
+ request: import("@opengeni/contracts/host-mcp-bindings").IssueHostMcpDelegationRequest,
207
+ options: OpenGeniRequestOptions = {},
208
+ ): Promise<import("@opengeni/contracts/host-mcp-bindings").HostMcpDelegation> {
209
+ return this.requestJson(
210
+ "POST",
211
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-delegations`,
212
+ request,
213
+ {},
214
+ options,
215
+ );
216
+ }
217
+
218
+ async getHostMcpDelegation(
219
+ workspaceId: string,
220
+ delegationId: string,
221
+ options: OpenGeniRequestOptions = {},
222
+ ): Promise<import("@opengeni/contracts/host-mcp-bindings").HostMcpDelegation> {
223
+ return this.requestJson(
224
+ "GET",
225
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-delegations/${encodeURIComponent(delegationId)}`,
226
+ undefined,
227
+ {},
228
+ options,
229
+ );
230
+ }
231
+
232
+ async revokeHostMcpDelegation(
233
+ workspaceId: string,
234
+ delegationId: string,
235
+ request: { expectedGeneration: number },
236
+ options: OpenGeniRequestOptions = {},
237
+ ): Promise<import("@opengeni/contracts/host-mcp-bindings").HostMcpDelegation> {
238
+ return this.requestJson(
239
+ "POST",
240
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/host-mcp-delegations/${encodeURIComponent(delegationId)}/revoke`,
241
+ request,
242
+ {},
243
+ options,
244
+ );
245
+ }
246
+
247
+ async listConnectAccounts(
248
+ workspaceId: string,
249
+ ): Promise<import("@opengeni/contracts/connect").ConnectAccount[]> {
250
+ return this.requestJson("GET", `/v1/workspaces/${workspaceId}/connect/accounts`);
251
+ }
252
+
253
+ async getConnectAttempt(
254
+ workspaceId: string,
255
+ attemptId: string,
256
+ ): Promise<import("@opengeni/contracts/connect").ConnectAttempt> {
257
+ return this.requestJson("GET", `/v1/workspaces/${workspaceId}/connect/attempts/${attemptId}`);
258
+ }
259
+
260
+ async listPendingConnectAttempts(
261
+ workspaceId: string,
262
+ ): Promise<import("@opengeni/contracts/connect").ConnectAttempt[]> {
263
+ return this.requestJson("GET", `/v1/workspaces/${workspaceId}/connect/attempts`);
264
+ }
265
+
266
+ async advanceConnectAttempt(
267
+ workspaceId: string,
268
+ attemptId: string,
269
+ request: {
270
+ expectedRevision: number;
271
+ idempotencyKey: string;
272
+ action: import("@opengeni/contracts/connect").ConnectAdvance;
273
+ },
274
+ ): Promise<import("@opengeni/contracts/connect").ConnectAttempt> {
275
+ return this.requestJson(
276
+ "POST",
277
+ `/v1/workspaces/${workspaceId}/connect/attempts/${attemptId}/advance`,
278
+ request,
279
+ );
280
+ }
281
+
282
+ /** Stops setup; does not revoke already committed provider credentials. */
283
+ async cancelConnectAttempt(
284
+ workspaceId: string,
285
+ attemptId: string,
286
+ request: {
287
+ expectedRevision: number;
288
+ idempotencyKey: string;
289
+ },
290
+ ): Promise<import("@opengeni/contracts/connect").ConnectAttempt> {
291
+ return this.requestJson(
292
+ "POST",
293
+ `/v1/workspaces/${workspaceId}/connect/attempts/${attemptId}/cancel`,
294
+ request,
295
+ );
296
+ }
297
+
298
+ /** Explicit organization-service-key onboarding; asUser never grants membership. */
299
+ async addExternalWorkspaceMember(
300
+ workspaceId: string,
301
+ request: {
302
+ identity: { externalId: string; source?: string };
303
+ permissions: AddWorkspaceMemberRequest["permissions"];
304
+ },
305
+ ): Promise<import("@opengeni/contracts/external-identities").ExternalIdentity> {
306
+ return this.requestJson("POST", `/v1/workspaces/${workspaceId}/external-members`, request);
307
+ }
308
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,20 @@
1
+ export { OpenGeniEmbeddingClient as OpenGeniClient } from "./embedding-client";
2
+ export { createSiteToolBridge, isSiteCatalogStaleError } from "./site-tool-bridge";
3
+ export type {
4
+ SiteToolBridge,
5
+ SiteToolCaller,
6
+ SiteToolCallRequest,
7
+ CreateSiteToolBridgeOptions,
8
+ } from "./site-tool-bridge";
9
+ export type {
10
+ ExternalIdentityLink,
11
+ BeginExternalIdentityLinkRequest,
12
+ BeginExternalIdentityLinkResponse,
13
+ ConfirmExternalIdentityLinkRequest,
14
+ ExternalIdentityLinkPreview,
15
+ ExternalIdentityLinkPage,
16
+ } from "@opengeni/contracts/external-identities";
1
17
  export type { ModelConnectionAccessPolicy, ModelConnectionAccessResponse } from "./types";
2
- export { OpenGeniClient } from "./artifact-client";
3
18
  export {
4
19
  OpenGeniToolCallError,
5
20
  OpenGeniToolReapprovalRequiredError,