@opengeni/sdk 1.0.2 → 1.2.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 (54) hide show
  1. package/dist/adapters/next.js +2 -2
  2. package/dist/artifact-catalog.d.ts +7 -0
  3. package/dist/artifacts.js +5 -4
  4. package/dist/browser.js +3 -2
  5. package/dist/chat/index.js +9 -7
  6. package/dist/chat/index.js.map +1 -1
  7. package/dist/{chunk-AH5D5Q5V.js → chunk-2NIR4WBR.js} +2 -2
  8. package/dist/{chunk-DUVIYER4.js → chunk-2ULNDOLD.js} +2 -2
  9. package/dist/{chunk-HMGADJGZ.js → chunk-2VPO6IQC.js} +2 -2
  10. package/dist/{chunk-FG3OO5LM.js → chunk-5AN2FLNC.js} +45 -2
  11. package/dist/chunk-5AN2FLNC.js.map +1 -0
  12. package/dist/{chunk-RWKB6YZG.js → chunk-66AKEWV6.js} +2 -2
  13. package/dist/{chunk-ZKPY6YAJ.js → chunk-6Z5QRYHG.js} +12 -1
  14. package/dist/chunk-6Z5QRYHG.js.map +1 -0
  15. package/dist/{chunk-MOTJYIYL.js → chunk-TZFJUYCT.js} +2 -2
  16. package/dist/chunk-VPVMLM7Q.js +15 -0
  17. package/dist/chunk-VPVMLM7Q.js.map +1 -0
  18. package/dist/{chunk-YIKA2QT4.js → chunk-WIYAB33K.js} +1 -1
  19. package/dist/chunk-WIYAB33K.js.map +1 -0
  20. package/dist/client.d.ts +17 -1
  21. package/dist/core.js +4 -3
  22. package/dist/document-authority.js +4 -3
  23. package/dist/editable-artifacts.js +1 -1
  24. package/dist/index.d.ts +2 -2
  25. package/dist/index.js +9 -8
  26. package/dist/index.js.map +1 -1
  27. package/dist/insights-usage.d.ts +33 -0
  28. package/dist/insights-usage.js +7 -0
  29. package/dist/insights-usage.js.map +1 -0
  30. package/dist/model-display.d.ts +1 -1
  31. package/dist/model-display.js +3 -1
  32. package/dist/session-proxy.js +2 -2
  33. package/dist/site-browser-runtime.gen.d.ts +1 -1
  34. package/dist/site-document.js +1 -1
  35. package/dist/site-document.js.map +1 -1
  36. package/dist/site.js +4 -3
  37. package/dist/types.d.ts +17 -1
  38. package/package.json +9 -4
  39. package/src/artifact-catalog.ts +8 -0
  40. package/src/chat/opengeni.ts +3 -2
  41. package/src/client.ts +92 -1
  42. package/src/index.ts +3 -0
  43. package/src/insights-usage.ts +61 -0
  44. package/src/model-display.ts +1 -0
  45. package/src/site-browser-runtime.gen.ts +1 -1
  46. package/src/types.ts +40 -0
  47. package/dist/chunk-FG3OO5LM.js.map +0 -1
  48. package/dist/chunk-YIKA2QT4.js.map +0 -1
  49. package/dist/chunk-ZKPY6YAJ.js.map +0 -1
  50. /package/dist/{chunk-AH5D5Q5V.js.map → chunk-2NIR4WBR.js.map} +0 -0
  51. /package/dist/{chunk-DUVIYER4.js.map → chunk-2ULNDOLD.js.map} +0 -0
  52. /package/dist/{chunk-HMGADJGZ.js.map → chunk-2VPO6IQC.js.map} +0 -0
  53. /package/dist/{chunk-RWKB6YZG.js.map → chunk-66AKEWV6.js.map} +0 -0
  54. /package/dist/{chunk-MOTJYIYL.js.map → chunk-TZFJUYCT.js.map} +0 -0
package/dist/site.js CHANGED
@@ -18,11 +18,12 @@ import {
18
18
  sanitizeOpenGeniSiteToolCallRequest,
19
19
  serveSiteHttp,
20
20
  siteSessionPath
21
- } from "./chunk-DUVIYER4.js";
21
+ } from "./chunk-2ULNDOLD.js";
22
22
  import "./chunk-4SMEOV3P.js";
23
- import "./chunk-FG3OO5LM.js";
23
+ import "./chunk-5AN2FLNC.js";
24
+ import "./chunk-VPVMLM7Q.js";
24
25
  import "./chunk-APXVSSSY.js";
25
- import "./chunk-YIKA2QT4.js";
26
+ import "./chunk-WIYAB33K.js";
26
27
  import "./chunk-NC57YMUO.js";
27
28
  import "./chunk-V6GIY62B.js";
28
29
  export {
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { WorkspaceTranscriptionPolicy } from "./transcription.js";
2
+ export type { InsightsUsageRange, InsightsUsageGroupBy, InsightsUsagePayer, InsightsUsageSource, InsightsUsageTokens, InsightsUsageClassMicros, InsightsUsageMeasures, InsightsUsageScope, InsightsUsageGroup, InsightsUsageSeriesPoint, InsightsUsageFacets, InsightsUsageResponse, InsightsCall, InsightsCallsResponse, InsightsUsageWindowOptions, WorkspaceInsightsUsageOptions, OrganizationInsightsUsageOptions, WorkspaceInsightsCallsOptions, OrganizationInsightsCallsOptions, InsightsCallsScope, } from "./insights-usage.js";
2
3
  export type { ClaudeSubscriptionOAuthStartResponse, ClaudeSubscriptionOAuthCompleteRequest, ClaudeSubscriptionOAuthCompleteResponse, } from "@opengeni/contracts";
3
4
  export type { SessionMessageSearchRequest, SessionMessageSearchMatch, SessionMessageSearchResponse, SessionMessagePreview, SessionMessagePreviewReference, } from "./session-message-search.js";
4
5
  export type BundledSkillId = "builtin:opengeni-help" | "builtin:opengeni-client" | "builtin:opengeni-visualize" | "builtin:document-parsing" | "builtin:opengeni-skills" | "builtin:opengeni-projects" | "builtin:opengeni-schedules" | "builtin:opengeni-documents" | "builtin:opengeni-spreadsheets" | "builtin:opengeni-presentations" | "builtin:opengeni-sites" | "builtin:opengeni-video-generation";
@@ -2736,6 +2737,8 @@ export type ClientModel = {
2736
2737
  label: string;
2737
2738
  /** Optional curated compact label for dense UI (e.g. mobile composer). */
2738
2739
  shortLabel?: string | undefined;
2740
+ /** Optional HTTPS maker logo supplied by the model catalog. */
2741
+ logoUrl?: string | undefined;
2739
2742
  /** Provider id (e.g. `openai`, `azure`, or a registry provider id). */
2740
2743
  provider: string;
2741
2744
  providerLabel: string;
@@ -2775,6 +2778,7 @@ export type ModelCredentialReadinessV1 = {
2775
2778
  };
2776
2779
  export type WorkspaceModelCatalogModel = ClientModel & {
2777
2780
  credentialReadiness: ModelCredentialReadinessV1;
2781
+ creditFunding?: "promotional" | "general" | "unavailable" | undefined;
2778
2782
  /** Exact workspace-policy verdict without exposing provider identity. */
2779
2783
  policyAllowed?: boolean | undefined;
2780
2784
  availability: ModelAvailabilityV1;
@@ -4976,7 +4980,7 @@ export type ScheduledTaskRunAwaitingHuman = {
4976
4980
  };
4977
4981
  export type ScheduledTaskAdmissionRefusal = {
4978
4982
  version: 1;
4979
- reason: "scheduled_authority_unavailable" | "machine_target_unavailable" | "machine_enrollment_inactive" | "variable_set_unavailable" | "rig_version_unavailable" | "insufficient_credits" | "monthly_model_cost_limit" | "monthly_agent_run_limit" | (string & {});
4983
+ reason: "scheduled_authority_unavailable" | "machine_target_unavailable" | "machine_enrollment_inactive" | "variable_set_unavailable" | "rig_version_unavailable" | "scheduled_model_unavailable" | "insufficient_credits" | "monthly_model_cost_limit" | "monthly_agent_run_limit" | (string & {});
4980
4984
  retryable: boolean;
4981
4985
  };
4982
4986
  export type ScheduledTaskAccessFailureReason = "missing_connection" | "expired" | "insufficient_scope" | "refresh_failed" | "personal_authority_unavailable" | "unsupported_auth" | "resource_scope_unavailable";
@@ -6651,11 +6655,21 @@ export type CreateGitHubAppManifestResponse = {
6651
6655
  };
6652
6656
  export type BillingMode = "disabled" | "stripe";
6653
6657
  export type EntitlementsMode = "none" | "static" | "managed";
6658
+ export type PromotionalCreditScope = {
6659
+ label: string;
6660
+ eligibleModelIds: string[];
6661
+ };
6662
+ export type PromotionalCreditBalance = PromotionalCreditScope & {
6663
+ grantId: string;
6664
+ remainingMicros: number;
6665
+ };
6654
6666
  export type BillingBalance = {
6655
6667
  accountId: string;
6656
6668
  balanceMicros: number;
6657
6669
  currency: "usd";
6658
6670
  updatedAt: string;
6671
+ generalBalanceMicros?: number | undefined;
6672
+ promotionalCredits?: PromotionalCreditBalance[] | undefined;
6659
6673
  };
6660
6674
  export declare const KNOWN_USAGE_EVENT_TYPES: readonly ["agent_run.created", "agent_run.completed", "model.tokens", "model.cost", "file.uploaded", "file.deleted", "document.indexed", "scheduled_task.fired", "knowledge_source_sync.fired", "knowledge_source_sync.completed", "knowledge_source_sync.items", "knowledge_source_sync.bytes", "api_key.request", "sandbox.warm_seconds", "sandbox.warm_cost"];
6661
6675
  export type KnownUsageEventType = (typeof KNOWN_USAGE_EVENT_TYPES)[number];
@@ -6948,6 +6962,7 @@ export type CreateCheckoutResponse = {
6948
6962
  url: string;
6949
6963
  /** The credits this checkout grants once it completes. */
6950
6964
  amountUsd?: number | undefined;
6965
+ promotionalScope?: PromotionalCreditScope | undefined;
6951
6966
  };
6952
6967
  /** Where one checkout stands, and whether its credits reached the balance. */
6953
6968
  export type BillingCheckoutStatus = {
@@ -6959,6 +6974,7 @@ export type BillingCheckoutStatus = {
6959
6974
  currency: "usd";
6960
6975
  /** True when a coupon covered the whole checkout, so nothing was charged. */
6961
6976
  free: boolean;
6977
+ promotionalScope?: PromotionalCreditScope | undefined;
6962
6978
  };
6963
6979
  balance: BillingBalance | null;
6964
6980
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/sdk",
3
- "version": "1.0.2",
3
+ "version": "1.2.0",
4
4
  "description": "Framework-agnostic TypeScript SDK for the OpenGeni API: typed client, session lifecycle, SSE event streaming with reconnect + replay-by-sequence, and proxy re-streaming helpers.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -58,6 +58,10 @@
58
58
  "types": "./dist/usage-allowances.d.ts",
59
59
  "import": "./dist/usage-allowances.js"
60
60
  },
61
+ "./insights-usage": {
62
+ "types": "./dist/insights-usage.d.ts",
63
+ "import": "./dist/insights-usage.js"
64
+ },
61
65
  "./workspace-integrations": {
62
66
  "types": "./dist/workspace-integrations.d.ts",
63
67
  "import": "./dist/workspace-integrations.js"
@@ -165,7 +169,8 @@
165
169
  "./session-list-entries": {
166
170
  "types": "./dist/session-list-entries.d.ts",
167
171
  "import": "./dist/session-list-entries.js"
168
- }
172
+ },
173
+ "./package.json": "./package.json"
169
174
  },
170
175
  "publishConfig": {
171
176
  "access": "public",
@@ -177,8 +182,8 @@
177
182
  "prepublishOnly": "bash ../../scripts/prepublish-guard"
178
183
  },
179
184
  "dependencies": {
180
- "@opengeni/connect": "1.0.2",
181
- "@opengeni/contracts": "1.0.2"
185
+ "@opengeni/connect": "1.2.0",
186
+ "@opengeni/contracts": "1.2.0"
182
187
  },
183
188
  "engines": {
184
189
  "node": ">=18"
@@ -16,6 +16,8 @@ export type ArtifactCatalogItem = {
16
16
  createdAt: string;
17
17
  updatedAt: string;
18
18
  status: "active" | "archived";
19
+ /** Shared workspace pin; absent on older servers. Never grants content access. */
20
+ pinned?: boolean;
19
21
  /** Present only when the viewer can read this session. */
20
22
  sourceSessionId?: string;
21
23
  versionId?: string;
@@ -39,3 +41,9 @@ export type ArtifactCatalogListResponse = {
39
41
  items: ArtifactCatalogItem[];
40
42
  nextCursor: string | null;
41
43
  };
44
+
45
+ export type ArtifactPinResponse = {
46
+ kind: ArtifactCatalogKind;
47
+ artifactId: string;
48
+ pinned: boolean;
49
+ };
@@ -76,11 +76,12 @@ export class OpenGeni {
76
76
  constructor(options: OpenGeniOptions) {
77
77
  if (!options.apiKey) throw new TypeError("Opengeni requires an apiKey.");
78
78
  this.client = new OpenGeniClient({
79
- baseUrl: options.baseUrl ?? DEFAULT_OPENGENI_BASE_URL,
79
+ // An empty value (a blank `OPENGENI_API_BASE_URL=` in .env) means the default.
80
+ baseUrl: options.baseUrl?.trim() || DEFAULT_OPENGENI_BASE_URL,
80
81
  apiKey: options.apiKey,
81
82
  ...(options.fetch ? { fetch: options.fetch } : {}),
82
83
  });
83
- this.organizationId = options.organizationId ?? "";
84
+ this.organizationId = options.organizationId?.trim() ?? "";
84
85
  this.source = options.source ?? DEFAULT_CHAT_SOURCE;
85
86
  this.resolveWorkspaceId = createWorkspaceIdResolver(this.client, {
86
87
  organizationId: () => this.resolveOrganizationId(),
package/src/client.ts CHANGED
@@ -5,7 +5,22 @@ import type {
5
5
  ClaudeSubscriptionSetupTokenRequest,
6
6
  SubscriptionPoolSettings,
7
7
  } from "@opengeni/contracts";
8
- import type { ArtifactCatalogListOptions, ArtifactCatalogListResponse } from "./artifact-catalog";
8
+ import {
9
+ insightsUsageQueryString,
10
+ type WorkspaceInsightsUsageOptions,
11
+ type OrganizationInsightsUsageOptions,
12
+ type WorkspaceInsightsCallsOptions,
13
+ type OrganizationInsightsCallsOptions,
14
+ type InsightsCallsScope,
15
+ type InsightsUsageResponse,
16
+ type InsightsCallsResponse,
17
+ } from "./insights-usage";
18
+ import type {
19
+ ArtifactCatalogKind,
20
+ ArtifactCatalogListOptions,
21
+ ArtifactCatalogListResponse,
22
+ ArtifactPinResponse,
23
+ } from "./artifact-catalog";
9
24
  import type {
10
25
  SessionMessageSearchRequest,
11
26
  SessionMessageSearchResponse,
@@ -7589,6 +7604,23 @@ export class OpenGeniClient {
7589
7604
  );
7590
7605
  }
7591
7606
 
7607
+ /** Idempotently set a workspace-shared pin; refresh the catalog after completion. */
7608
+ async updateArtifactPin(
7609
+ workspaceId: string,
7610
+ kind: ArtifactCatalogKind,
7611
+ artifactId: string,
7612
+ pinned: boolean,
7613
+ options: { signal?: AbortSignal } = {},
7614
+ ): Promise<ArtifactPinResponse> {
7615
+ return this.requestJson<ArtifactPinResponse>(
7616
+ "PUT",
7617
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/artifact-catalog/${encodeURIComponent(kind)}/${encodeURIComponent(artifactId)}/pin`,
7618
+ { pinned },
7619
+ undefined,
7620
+ options,
7621
+ );
7622
+ }
7623
+
7592
7624
  async listWorkspaceArtifacts(
7593
7625
  workspaceId: string,
7594
7626
  options: WorkspaceArtifactListOptions & { signal?: AbortSignal } = {},
@@ -8867,6 +8899,65 @@ export class OpenGeniClient {
8867
8899
  );
8868
8900
  }
8869
8901
 
8902
+ /** Shared usage under the existing workspace access gate. */
8903
+ async getWorkspaceInsightsUsage(
8904
+ workspaceId: string,
8905
+ options: WorkspaceInsightsUsageOptions = {},
8906
+ requestOptions: OpenGeniRequestOptions = {},
8907
+ ): Promise<InsightsUsageResponse> {
8908
+ return await this.requestJson(
8909
+ "GET",
8910
+ `/v1/workspaces/${encodeURIComponent(workspaceId)}/insights/usage${insightsUsageQueryString(options)}`,
8911
+ undefined,
8912
+ {},
8913
+ requestOptions,
8914
+ );
8915
+ }
8916
+
8917
+ /** Shared usage under the existing organization access gate. */
8918
+ async getOrganizationInsightsUsage(
8919
+ accountId: string,
8920
+ options: OrganizationInsightsUsageOptions = {},
8921
+ requestOptions: OpenGeniRequestOptions = {},
8922
+ ): Promise<InsightsUsageResponse> {
8923
+ return await this.requestJson(
8924
+ "GET",
8925
+ `/v1/organizations/${encodeURIComponent(accountId)}/insights/usage${insightsUsageQueryString(options)}`,
8926
+ undefined,
8927
+ {},
8928
+ requestOptions,
8929
+ );
8930
+ }
8931
+
8932
+ /** Visible calls only; a filter never grants access to hidden call facts. */
8933
+ async listInsightsCalls(
8934
+ scope: Extract<InsightsCallsScope, { kind: "workspace" }>,
8935
+ options?: WorkspaceInsightsCallsOptions,
8936
+ requestOptions?: OpenGeniRequestOptions,
8937
+ ): Promise<InsightsCallsResponse>;
8938
+ async listInsightsCalls(
8939
+ scope: Extract<InsightsCallsScope, { kind: "organization" }>,
8940
+ options?: OrganizationInsightsCallsOptions,
8941
+ requestOptions?: OpenGeniRequestOptions,
8942
+ ): Promise<InsightsCallsResponse>;
8943
+ async listInsightsCalls(
8944
+ scope: InsightsCallsScope,
8945
+ options: OrganizationInsightsCallsOptions = {},
8946
+ requestOptions: OpenGeniRequestOptions = {},
8947
+ ): Promise<InsightsCallsResponse> {
8948
+ const path =
8949
+ scope.kind === "workspace"
8950
+ ? `/v1/workspaces/${encodeURIComponent(scope.workspaceId)}/insights/calls`
8951
+ : `/v1/organizations/${encodeURIComponent(scope.accountId)}/insights/calls`;
8952
+ return await this.requestJson(
8953
+ "GET",
8954
+ `${path}${insightsUsageQueryString(options)}`,
8955
+ undefined,
8956
+ {},
8957
+ requestOptions,
8958
+ );
8959
+ }
8960
+
8870
8961
  async getBillingEntitlements(
8871
8962
  options: { accountId?: string } = {},
8872
8963
  ): Promise<BillingEntitlementsResponse> {
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ export type {
7
7
  ClaudeSubscriptionAccountsResponse,
8
8
  } from "@opengeni/contracts";
9
9
  export type {
10
+ ArtifactPinResponse,
10
11
  ArtifactCatalogKind,
11
12
  ArtifactCatalogItem,
12
13
  ArtifactCatalogListOptions,
@@ -621,6 +622,8 @@ export type {
621
622
  AgentToolCallOutputPayload,
622
623
  ApiKey,
623
624
  BillingBalance,
625
+ PromotionalCreditScope,
626
+ PromotionalCreditBalance,
624
627
  BillingEntitlementsResponse,
625
628
  BillingMode,
626
629
  BillingSummary,
@@ -0,0 +1,61 @@
1
+ // Type-only references keep this opt-in SDK leaf free of zod/root contracts.
2
+ import type {
3
+ OrganizationInsightsUsageQueryInput,
4
+ OrganizationInsightsCallsQueryInput,
5
+ InsightsUsageRange,
6
+ InsightsUsagePayer,
7
+ InsightsUsageSource,
8
+ } from "@opengeni/contracts/insights-usage";
9
+
10
+ export type {
11
+ InsightsUsageRange,
12
+ InsightsUsageGroupBy,
13
+ InsightsUsagePayer,
14
+ InsightsUsageSource,
15
+ InsightsUsageTokens,
16
+ InsightsUsageClassMicros,
17
+ InsightsUsageMeasures,
18
+ InsightsUsageScope,
19
+ InsightsUsageGroup,
20
+ InsightsUsageSeriesPoint,
21
+ InsightsUsageFacets,
22
+ InsightsUsageResponse,
23
+ InsightsCall,
24
+ InsightsCallsResponse,
25
+ } from "@opengeni/contracts/insights-usage";
26
+
27
+ /** Custom selections require both inclusive UTC calendar days. */
28
+ export type InsightsUsageWindowOptions =
29
+ | { range?: Exclude<InsightsUsageRange, "custom">; from?: never; to?: never }
30
+ | { range: "custom"; from: string; to: string };
31
+
32
+ type FilterOptions<T> = Omit<T, "range" | "from" | "to" | "limit" | "payer" | "source"> &
33
+ InsightsUsageWindowOptions & {
34
+ limit?: number;
35
+ payer?: InsightsUsagePayer | InsightsUsagePayer[];
36
+ source?: InsightsUsageSource | InsightsUsageSource[];
37
+ };
38
+
39
+ export type OrganizationInsightsUsageOptions = FilterOptions<
40
+ Omit<OrganizationInsightsUsageQueryInput, "seriesGroups">
41
+ > & { seriesGroups?: boolean };
42
+ /** workspaceId is intersected with the path workspace by the existing server gate. */
43
+ export type WorkspaceInsightsUsageOptions = OrganizationInsightsUsageOptions;
44
+ export type OrganizationInsightsCallsOptions = FilterOptions<OrganizationInsightsCallsQueryInput>;
45
+ export type WorkspaceInsightsCallsOptions = OrganizationInsightsCallsOptions;
46
+ export type InsightsCallsScope =
47
+ | { kind: "workspace"; workspaceId: string }
48
+ | { kind: "organization"; accountId: string };
49
+
50
+ /** Arrays repeat; comma strings, false and opaque values round-trip unchanged. */
51
+ export function insightsUsageQueryString(
52
+ options: OrganizationInsightsUsageOptions | OrganizationInsightsCallsOptions,
53
+ ): string {
54
+ const params = new URLSearchParams();
55
+ for (const [key, value] of Object.entries(options)) {
56
+ if (value === undefined) continue;
57
+ for (const item of Array.isArray(value) ? value : [value]) params.append(key, String(item));
58
+ }
59
+ const query = params.toString();
60
+ return query ? `?${query}` : "";
61
+ }
@@ -3,6 +3,7 @@ export {
3
3
  humanizeModelSlug,
4
4
  isRawModelLabel,
5
5
  modelDisplayName,
6
+ modelLogoUrl,
6
7
  modelSlug,
7
8
  modelVendor,
8
9
  type ModelDisplayInput,