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.mjs CHANGED
@@ -1812,8 +1812,12 @@ async function request(config, method, path, body, extraHeaders, options) {
1812
1812
  });
1813
1813
  if (!response.ok) {
1814
1814
  const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
1815
- const message = typeof errorData.error === "string" ? errorData.error : errorData.error?.message || response.statusText;
1815
+ const message = typeof errorData.error === "string" ? errorData.error : errorData.error?.message ?? (typeof errorData.message === "string" ? errorData.message : null) ?? response.statusText;
1816
1816
  const details = typeof errorData.error === "object" ? errorData.error : null;
1817
+ const topCode = typeof errorData.code === "string" ? errorData.code : null;
1818
+ const topRequestId = typeof errorData.request_id === "string" ? errorData.request_id : typeof errorData.requestId === "string" ? errorData.requestId : null;
1819
+ const topType = typeof errorData.type === "string" ? errorData.type : null;
1820
+ const topParam = typeof errorData.param === "string" ? errorData.param : null;
1817
1821
  let retryAfterSeconds = parseRetryAfterSeconds(response.headers.get("Retry-After") ?? response.headers.get("retry-after"));
1818
1822
  if (retryAfterSeconds == null) {
1819
1823
  const secHint = details?.retry_after_seconds ?? errorData.retry_after_seconds ?? details?.retry_after ?? errorData.retry_after;
@@ -1826,7 +1830,7 @@ async function request(config, method, path, body, extraHeaders, options) {
1826
1830
  }
1827
1831
  }
1828
1832
  }
1829
- 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);
1833
+ 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);
1830
1834
  }
1831
1835
  if (response.status === 204) return void 0;
1832
1836
  return response.json();
@@ -1890,7 +1894,7 @@ var ModelsNamespace = class {
1890
1894
  this.config = config;
1891
1895
  }
1892
1896
  list(params) {
1893
- 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 })}`);
1897
+ 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 })}`);
1894
1898
  }
1895
1899
  };
1896
1900
  var ProviderConnectionsNamespace = class {
@@ -1973,8 +1977,8 @@ var InstallationsNamespace = class {
1973
1977
  create(params) {
1974
1978
  return request(this.config, "POST", "/v1/agent-installations", params);
1975
1979
  }
1976
- list(tenantId) {
1977
- return request(this.config, "GET", `/v1/agent-installations${qs({ tenant_id: tenantId })}`);
1980
+ list(tenantId, params) {
1981
+ return request(this.config, "GET", `/v1/agent-installations${qs({ tenant_id: tenantId, agent_id: params?.agent_id, limit: params?.limit, cursor: params?.cursor })}`);
1978
1982
  }
1979
1983
  get(installationId) {
1980
1984
  return request(this.config, "GET", `/v1/agent-installations/${installationId}`);
@@ -1999,6 +2003,9 @@ var RunsNamespace = class {
1999
2003
  create(agentId, params, idempotencyKey, options) {
2000
2004
  return request(this.config, "POST", `/v1/agents/${agentId}/runs`, params, idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0, options);
2001
2005
  }
2006
+ history(agentId, params) {
2007
+ return request(this.config, "GET", `/v1/agents/${agentId}/runs${qs({ limit: params?.limit, cursor: params?.cursor })}`);
2008
+ }
2002
2009
  get(runId, options) {
2003
2010
  return request(this.config, "GET", `/v1/runs/${runId}`, void 0, void 0, options);
2004
2011
  }
@@ -2195,6 +2202,20 @@ var McpServersNamespace = class {
2195
2202
  return request(this.config, "POST", `/v1/mcp/servers/${serverId}/refresh-tools`, {});
2196
2203
  }
2197
2204
  };
2205
+ var MarketplaceNamespace = class {
2206
+ constructor(config) {
2207
+ this.config = config;
2208
+ }
2209
+ list(params) {
2210
+ return request(this.config, "GET", `/v1/marketplace/agents${qs({ limit: params?.limit, cursor: params?.cursor })}`);
2211
+ }
2212
+ get(versionId) {
2213
+ return request(this.config, "GET", `/v1/marketplace/agents/${versionId}`);
2214
+ }
2215
+ install(params) {
2216
+ return request(this.config, "POST", "/v1/marketplace/installations", params);
2217
+ }
2218
+ };
2198
2219
  var WebhooksNamespace = class {
2199
2220
  constructor(config) {
2200
2221
  this.config = config;
@@ -2223,10 +2244,10 @@ var UsageNamespace = class {
2223
2244
  this.config = config;
2224
2245
  }
2225
2246
  summary(params) {
2226
- return request(this.config, "GET", `/v1/usage${qs({ days: params?.days, tenant_id: params?.tenant_id, agent_id: params?.agent_id })}`);
2247
+ 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 })}`);
2227
2248
  }
2228
2249
  events(params) {
2229
- 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 })}`);
2250
+ 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 })}`);
2230
2251
  }
2231
2252
  async exportCsv(params) {
2232
2253
  const search = new URLSearchParams({ format: "csv" });
@@ -2379,6 +2400,7 @@ var Cencori = class {
2379
2400
  this.knowledge = new KnowledgeNamespace2(this.config);
2380
2401
  this.connections = new ConnectionsNamespace(this.config);
2381
2402
  this.mcpServers = new McpServersNamespace(this.config);
2403
+ this.marketplace = new MarketplaceNamespace(this.config);
2382
2404
  this.skills = new SkillsNamespace(this.config);
2383
2405
  this.skillImports = new SkillImportsNamespace(this.config);
2384
2406
  this.webhooks = new WebhooksNamespace(this.config);
@@ -2469,6 +2491,45 @@ var Cencori = class {
2469
2491
  }
2470
2492
  };
2471
2493
 
2494
+ // src/catalog/index.ts
2495
+ var DEFAULT_CATALOG_BASE_URL = "https://cencori.com";
2496
+ function baseUrlOf(options) {
2497
+ return (options?.baseUrl ?? DEFAULT_CATALOG_BASE_URL).replace(/\/$/, "");
2498
+ }
2499
+ function modelQuery(filters) {
2500
+ const search = new URLSearchParams();
2501
+ if (filters?.provider) search.set("provider", filters.provider);
2502
+ if (filters?.type) search.set("type", filters.type);
2503
+ if (filters?.search) search.set("search", filters.search);
2504
+ const caps = filters?.capability ? Array.isArray(filters.capability) ? filters.capability : [filters.capability] : [];
2505
+ for (const cap of caps) search.append("capability", cap);
2506
+ const s = search.toString();
2507
+ return s ? `?${s}` : "";
2508
+ }
2509
+ async function getJson(url, signal) {
2510
+ const response = await fetch(url, { signal });
2511
+ if (!response.ok) {
2512
+ const body = await response.text().catch(() => "");
2513
+ throw new Error(`Catalog request failed (${response.status} ${url})${body ? `: ${body.slice(0, 200)}` : ""}`);
2514
+ }
2515
+ return response.json();
2516
+ }
2517
+ function listCatalogModels(filters, options) {
2518
+ return getJson(
2519
+ `${baseUrlOf(options)}/api/models${modelQuery(filters)}`,
2520
+ options?.signal
2521
+ );
2522
+ }
2523
+ function listCatalogProviders(options) {
2524
+ return getJson(
2525
+ `${baseUrlOf(options)}/api/providers`,
2526
+ options?.signal
2527
+ );
2528
+ }
2529
+ function providerLogoUrl(providerId, baseUrl = DEFAULT_CATALOG_BASE_URL) {
2530
+ return `${baseUrl.replace(/\/$/, "")}/api/providers/${encodeURIComponent(providerId)}/logo`;
2531
+ }
2532
+
2472
2533
  // src/vercel/cencori-chat-model.ts
2473
2534
  var CencoriChatLanguageModel = class {
2474
2535
  constructor(modelId, settings) {
@@ -2820,6 +2881,7 @@ export {
2820
2881
  ClientTokensNamespace,
2821
2882
  ComputeNamespace,
2822
2883
  ConnectionsNamespace,
2884
+ DEFAULT_CATALOG_BASE_URL,
2823
2885
  DocumentsNamespace,
2824
2886
  EndUsersNamespace,
2825
2887
  InstallationsNamespace,
@@ -2850,6 +2912,9 @@ export {
2850
2912
  cencori,
2851
2913
  createCencori,
2852
2914
  Cencori as default,
2853
- fetchWithRetry
2915
+ fetchWithRetry,
2916
+ listCatalogModels,
2917
+ listCatalogProviders,
2918
+ providerLogoUrl
2854
2919
  };
2855
2920
  //# sourceMappingURL=index.mjs.map