cencori 1.7.4 → 1.8.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/dist/index.js CHANGED
@@ -32,6 +32,7 @@ __export(src_exports, {
32
32
  ClientTokensNamespace: () => ClientTokensNamespace,
33
33
  ComputeNamespace: () => ComputeNamespace,
34
34
  ConnectionsNamespace: () => ConnectionsNamespace,
35
+ DEFAULT_CATALOG_BASE_URL: () => DEFAULT_CATALOG_BASE_URL,
35
36
  DocumentsNamespace: () => DocumentsNamespace,
36
37
  EndUsersNamespace: () => EndUsersNamespace,
37
38
  InstallationsNamespace: () => InstallationsNamespace,
@@ -62,7 +63,10 @@ __export(src_exports, {
62
63
  cencori: () => cencori,
63
64
  createCencori: () => createCencori,
64
65
  default: () => Cencori,
65
- fetchWithRetry: () => fetchWithRetry
66
+ fetchWithRetry: () => fetchWithRetry,
67
+ listCatalogModels: () => listCatalogModels,
68
+ listCatalogProviders: () => listCatalogProviders,
69
+ providerLogoUrl: () => providerLogoUrl
66
70
  });
67
71
  module.exports = __toCommonJS(src_exports);
68
72
 
@@ -1880,8 +1884,12 @@ async function request(config, method, path, body, extraHeaders, options) {
1880
1884
  });
1881
1885
  if (!response.ok) {
1882
1886
  const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
1883
- const message = typeof errorData.error === "string" ? errorData.error : errorData.error?.message || response.statusText;
1887
+ const message = typeof errorData.error === "string" ? errorData.error : errorData.error?.message ?? (typeof errorData.message === "string" ? errorData.message : null) ?? response.statusText;
1884
1888
  const details = typeof errorData.error === "object" ? errorData.error : null;
1889
+ const topCode = typeof errorData.code === "string" ? errorData.code : null;
1890
+ const topRequestId = typeof errorData.request_id === "string" ? errorData.request_id : typeof errorData.requestId === "string" ? errorData.requestId : null;
1891
+ const topType = typeof errorData.type === "string" ? errorData.type : null;
1892
+ const topParam = typeof errorData.param === "string" ? errorData.param : null;
1885
1893
  let retryAfterSeconds = parseRetryAfterSeconds(response.headers.get("Retry-After") ?? response.headers.get("retry-after"));
1886
1894
  if (retryAfterSeconds == null) {
1887
1895
  const secHint = details?.retry_after_seconds ?? errorData.retry_after_seconds ?? details?.retry_after ?? errorData.retry_after;
@@ -1894,7 +1902,7 @@ async function request(config, method, path, body, extraHeaders, options) {
1894
1902
  }
1895
1903
  }
1896
1904
  }
1897
- throw new CencoriEmbeddedApiError(message, response.status, details?.code ?? null, details?.request_id ?? response.headers.get("X-Request-Id"), details?.type ?? null, details?.param ?? null, retryAfterSeconds);
1905
+ throw new CencoriEmbeddedApiError(message, response.status, details?.code ?? topCode, details?.request_id ?? topRequestId ?? response.headers.get("X-Request-Id"), details?.type ?? topType, details?.param ?? topParam, retryAfterSeconds);
1898
1906
  }
1899
1907
  if (response.status === 204) return void 0;
1900
1908
  return response.json();
@@ -1958,7 +1966,7 @@ var ModelsNamespace = class {
1958
1966
  this.config = config;
1959
1967
  }
1960
1968
  list(params) {
1961
- return request(this.config, "GET", `/v1/models${qs({ provider: params?.provider, type: params?.type, available: params?.available, source: params?.source, connection_id: params?.connection_id })}`);
1969
+ return request(this.config, "GET", `/v1/models${qs({ provider: params?.provider, type: params?.type, available: params?.available, source: params?.source, connection_id: params?.connection_id, limit: params?.limit, cursor: params?.cursor })}`);
1962
1970
  }
1963
1971
  };
1964
1972
  var ProviderConnectionsNamespace = class {
@@ -2041,8 +2049,8 @@ var InstallationsNamespace = class {
2041
2049
  create(params) {
2042
2050
  return request(this.config, "POST", "/v1/agent-installations", params);
2043
2051
  }
2044
- list(tenantId) {
2045
- return request(this.config, "GET", `/v1/agent-installations${qs({ tenant_id: tenantId })}`);
2052
+ list(tenantId, params) {
2053
+ return request(this.config, "GET", `/v1/agent-installations${qs({ tenant_id: tenantId, agent_id: params?.agent_id, limit: params?.limit, cursor: params?.cursor })}`);
2046
2054
  }
2047
2055
  get(installationId) {
2048
2056
  return request(this.config, "GET", `/v1/agent-installations/${installationId}`);
@@ -2067,6 +2075,9 @@ var RunsNamespace = class {
2067
2075
  create(agentId, params, idempotencyKey, options) {
2068
2076
  return request(this.config, "POST", `/v1/agents/${agentId}/runs`, params, idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0, options);
2069
2077
  }
2078
+ history(agentId, params) {
2079
+ return request(this.config, "GET", `/v1/agents/${agentId}/runs${qs({ limit: params?.limit, cursor: params?.cursor })}`);
2080
+ }
2070
2081
  get(runId, options) {
2071
2082
  return request(this.config, "GET", `/v1/runs/${runId}`, void 0, void 0, options);
2072
2083
  }
@@ -2263,6 +2274,20 @@ var McpServersNamespace = class {
2263
2274
  return request(this.config, "POST", `/v1/mcp/servers/${serverId}/refresh-tools`, {});
2264
2275
  }
2265
2276
  };
2277
+ var MarketplaceNamespace = class {
2278
+ constructor(config) {
2279
+ this.config = config;
2280
+ }
2281
+ list(params) {
2282
+ return request(this.config, "GET", `/v1/marketplace/agents${qs({ limit: params?.limit, cursor: params?.cursor })}`);
2283
+ }
2284
+ get(versionId) {
2285
+ return request(this.config, "GET", `/v1/marketplace/agents/${versionId}`);
2286
+ }
2287
+ install(params) {
2288
+ return request(this.config, "POST", "/v1/marketplace/installations", params);
2289
+ }
2290
+ };
2266
2291
  var WebhooksNamespace = class {
2267
2292
  constructor(config) {
2268
2293
  this.config = config;
@@ -2291,10 +2316,10 @@ var UsageNamespace = class {
2291
2316
  this.config = config;
2292
2317
  }
2293
2318
  summary(params) {
2294
- return request(this.config, "GET", `/v1/usage${qs({ days: params?.days, tenant_id: params?.tenant_id, agent_id: params?.agent_id })}`);
2319
+ return request(this.config, "GET", `/v1/usage${qs({ days: params?.days, since: params?.since, until: params?.until, tenant_id: params?.tenant_id, agent_id: params?.agent_id, installation_id: params?.installation_id, model: params?.model })}`);
2295
2320
  }
2296
2321
  events(params) {
2297
- return request(this.config, "GET", `/v1/usage/events${qs({ days: params?.days, tenant_id: params?.tenant_id, agent_id: params?.agent_id, limit: params?.limit, cursor: params?.cursor })}`);
2322
+ return request(this.config, "GET", `/v1/usage/events${qs({ days: params?.days, since: params?.since, until: params?.until, tenant_id: params?.tenant_id, agent_id: params?.agent_id, installation_id: params?.installation_id, model: params?.model, limit: params?.limit, cursor: params?.cursor })}`);
2298
2323
  }
2299
2324
  async exportCsv(params) {
2300
2325
  const search = new URLSearchParams({ format: "csv" });
@@ -2447,6 +2472,7 @@ var Cencori = class {
2447
2472
  this.knowledge = new KnowledgeNamespace2(this.config);
2448
2473
  this.connections = new ConnectionsNamespace(this.config);
2449
2474
  this.mcpServers = new McpServersNamespace(this.config);
2475
+ this.marketplace = new MarketplaceNamespace(this.config);
2450
2476
  this.skills = new SkillsNamespace(this.config);
2451
2477
  this.skillImports = new SkillImportsNamespace(this.config);
2452
2478
  this.webhooks = new WebhooksNamespace(this.config);
@@ -2537,6 +2563,45 @@ var Cencori = class {
2537
2563
  }
2538
2564
  };
2539
2565
 
2566
+ // src/catalog/index.ts
2567
+ var DEFAULT_CATALOG_BASE_URL = "https://cencori.com";
2568
+ function baseUrlOf(options) {
2569
+ return (options?.baseUrl ?? DEFAULT_CATALOG_BASE_URL).replace(/\/$/, "");
2570
+ }
2571
+ function modelQuery(filters) {
2572
+ const search = new URLSearchParams();
2573
+ if (filters?.provider) search.set("provider", filters.provider);
2574
+ if (filters?.type) search.set("type", filters.type);
2575
+ if (filters?.search) search.set("search", filters.search);
2576
+ const caps = filters?.capability ? Array.isArray(filters.capability) ? filters.capability : [filters.capability] : [];
2577
+ for (const cap of caps) search.append("capability", cap);
2578
+ const s = search.toString();
2579
+ return s ? `?${s}` : "";
2580
+ }
2581
+ async function getJson(url, signal) {
2582
+ const response = await fetch(url, { signal });
2583
+ if (!response.ok) {
2584
+ const body = await response.text().catch(() => "");
2585
+ throw new Error(`Catalog request failed (${response.status} ${url})${body ? `: ${body.slice(0, 200)}` : ""}`);
2586
+ }
2587
+ return response.json();
2588
+ }
2589
+ function listCatalogModels(filters, options) {
2590
+ return getJson(
2591
+ `${baseUrlOf(options)}/api/models${modelQuery(filters)}`,
2592
+ options?.signal
2593
+ );
2594
+ }
2595
+ function listCatalogProviders(options) {
2596
+ return getJson(
2597
+ `${baseUrlOf(options)}/api/providers`,
2598
+ options?.signal
2599
+ );
2600
+ }
2601
+ function providerLogoUrl(providerId, baseUrl = DEFAULT_CATALOG_BASE_URL) {
2602
+ return `${baseUrl.replace(/\/$/, "")}/api/providers/${encodeURIComponent(providerId)}/logo`;
2603
+ }
2604
+
2540
2605
  // src/vercel/cencori-chat-model.ts
2541
2606
  var CencoriChatLanguageModel = class {
2542
2607
  constructor(modelId, settings) {
@@ -2889,6 +2954,7 @@ cencori.chat = cencori;
2889
2954
  ClientTokensNamespace,
2890
2955
  ComputeNamespace,
2891
2956
  ConnectionsNamespace,
2957
+ DEFAULT_CATALOG_BASE_URL,
2892
2958
  DocumentsNamespace,
2893
2959
  EndUsersNamespace,
2894
2960
  InstallationsNamespace,
@@ -2918,6 +2984,9 @@ cencori.chat = cencori;
2918
2984
  WorkflowNamespace,
2919
2985
  cencori,
2920
2986
  createCencori,
2921
- fetchWithRetry
2987
+ fetchWithRetry,
2988
+ listCatalogModels,
2989
+ listCatalogProviders,
2990
+ providerLogoUrl
2922
2991
  });
2923
2992
  //# sourceMappingURL=index.js.map