@axiom-lattice/client-sdk 8.1.0 → 8.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.
package/dist/index.js CHANGED
@@ -3495,6 +3495,48 @@ var AbstractClient = class {
3495
3495
  return response.data;
3496
3496
  }
3497
3497
  };
3498
+ this.personalMcpServers = {
3499
+ list: async () => {
3500
+ const response = await this.makeRequest("/api/personal-mcp-servers");
3501
+ return response.data.records;
3502
+ },
3503
+ get: async (keyOrId) => {
3504
+ const response = await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}`);
3505
+ if (!response.data)
3506
+ throw new ApiError("Personal MCP server config not found", 404);
3507
+ return response.data;
3508
+ },
3509
+ create: async (data) => {
3510
+ const response = await this.makeRequest("/api/personal-mcp-servers", { method: "POST", body: data });
3511
+ if (!response.data)
3512
+ throw new ApiError("Failed to create personal MCP server config", 500);
3513
+ return response.data;
3514
+ },
3515
+ update: async (keyOrId, data) => {
3516
+ const response = await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}`, { method: "PUT", body: data });
3517
+ if (!response.data)
3518
+ throw new ApiError("Failed to update personal MCP server config", 500);
3519
+ return response.data;
3520
+ },
3521
+ delete: async (keyOrId) => {
3522
+ await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}`, { method: "DELETE" });
3523
+ },
3524
+ test: async (keyOrId) => {
3525
+ return await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}/test`, { method: "POST" });
3526
+ },
3527
+ connect: async (keyOrId) => {
3528
+ const response = await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}/connect`, { method: "POST" });
3529
+ if (!response.data)
3530
+ throw new ApiError("Failed to connect personal MCP server", 500);
3531
+ return response.data;
3532
+ },
3533
+ disconnect: async (keyOrId) => {
3534
+ const response = await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}/disconnect`, { method: "POST" });
3535
+ if (!response.data)
3536
+ throw new ApiError("Failed to disconnect personal MCP server", 500);
3537
+ return response.data;
3538
+ }
3539
+ };
3498
3540
  this.connections = {
3499
3541
  list: async (type) => {
3500
3542
  const response = await this.makeRequest(`/api/connections?type=${encodeURIComponent(type)}`);
@@ -5164,6 +5206,137 @@ function hydrateUser(value) {
5164
5206
  ...typeof value.updatedAt === "string" ? { updatedAt: value.updatedAt } : {}
5165
5207
  };
5166
5208
  }
5209
+ function hydrateAuditInitiator(value) {
5210
+ if (!isRecord5(value) || typeof value.type !== "string") {
5211
+ throw invalidResponse2("Invalid platform audit initiator");
5212
+ }
5213
+ if (value.type === "human") {
5214
+ if (typeof value.userId !== "string" || value.role !== "owner" && value.role !== "admin" && value.role !== "auditor") {
5215
+ throw invalidResponse2("Invalid platform audit human initiator");
5216
+ }
5217
+ return { type: "human", userId: value.userId, role: value.role };
5218
+ }
5219
+ if (value.type === "bootstrap") {
5220
+ return { type: "bootstrap" };
5221
+ }
5222
+ if (value.type === "system") {
5223
+ if (typeof value.component !== "string") {
5224
+ throw invalidResponse2("Invalid platform audit system initiator");
5225
+ }
5226
+ return { type: "system", component: value.component };
5227
+ }
5228
+ throw invalidResponse2("Invalid platform audit initiator");
5229
+ }
5230
+ function hydrateAuditExecutor(value) {
5231
+ if (!isRecord5(value) || typeof value.type !== "string") {
5232
+ throw invalidResponse2("Invalid platform audit executor");
5233
+ }
5234
+ if (value.type === "admin_center") {
5235
+ if (typeof value.route !== "string") {
5236
+ throw invalidResponse2("Invalid platform audit admin center executor");
5237
+ }
5238
+ return { type: "admin_center", route: value.route };
5239
+ }
5240
+ if (value.type === "ops_agent") {
5241
+ if (value.agentId !== "platform-ops" || typeof value.threadId !== "string" || typeof value.runId !== "string" || typeof value.toolName !== "string") {
5242
+ throw invalidResponse2("Invalid platform audit ops agent executor");
5243
+ }
5244
+ return {
5245
+ type: "ops_agent",
5246
+ agentId: "platform-ops",
5247
+ threadId: value.threadId,
5248
+ runId: value.runId,
5249
+ toolName: value.toolName
5250
+ };
5251
+ }
5252
+ if (value.type === "bootstrap") {
5253
+ return { type: "bootstrap" };
5254
+ }
5255
+ if (value.type === "system") {
5256
+ if (typeof value.component !== "string") {
5257
+ throw invalidResponse2("Invalid platform audit system executor");
5258
+ }
5259
+ return { type: "system", component: value.component };
5260
+ }
5261
+ throw invalidResponse2("Invalid platform audit executor");
5262
+ }
5263
+ function hydrateAuditSource(value) {
5264
+ if (value === "admin_center" || value === "ops_agent" || value === "bootstrap" || value === "system") {
5265
+ return value;
5266
+ }
5267
+ throw invalidResponse2("Invalid platform audit source");
5268
+ }
5269
+ function hydrateAuditAction(value) {
5270
+ if (value === "write" || value === "playbook")
5271
+ return value;
5272
+ throw invalidResponse2("Invalid platform audit action");
5273
+ }
5274
+ function hydrateAuditStatus(value) {
5275
+ if (value === "ok" || value === "error" || value === "cancelled") {
5276
+ return value;
5277
+ }
5278
+ throw invalidResponse2("Invalid platform audit status");
5279
+ }
5280
+ function hydratePlatformAudit(value) {
5281
+ if (!isRecord5(value) || typeof value.id !== "string") {
5282
+ throw invalidResponse2("Invalid platform audit record");
5283
+ }
5284
+ const initiator = hydrateAuditInitiator(value.initiator);
5285
+ const executor = hydrateAuditExecutor(value.executor);
5286
+ const source = hydrateAuditSource(value.source);
5287
+ const action = hydrateAuditAction(value.action);
5288
+ const status = hydrateAuditStatus(value.status);
5289
+ const createdAt = new Date(requiredString5(value, "createdAt"));
5290
+ if (Number.isNaN(createdAt.getTime())) {
5291
+ throw invalidResponse2("Invalid platform audit timestamp");
5292
+ }
5293
+ if (!isRecord5(value.summary)) {
5294
+ throw invalidResponse2("Invalid platform audit summary");
5295
+ }
5296
+ if (typeof value.durationMs !== "number" || !Number.isFinite(value.durationMs)) {
5297
+ throw invalidResponse2("Invalid platform audit duration");
5298
+ }
5299
+ const tenantId = optionalString(value, "tenantId");
5300
+ const before = optionalRecord(value, "before");
5301
+ const after = optionalRecord(value, "after");
5302
+ const errorCode = optionalString(value, "errorCode");
5303
+ return {
5304
+ id: value.id,
5305
+ initiator,
5306
+ source,
5307
+ executor,
5308
+ ...tenantId !== void 0 ? { tenantId } : {},
5309
+ action,
5310
+ status,
5311
+ summary: value.summary,
5312
+ ...before !== void 0 ? { before } : {},
5313
+ ...after !== void 0 ? { after } : {},
5314
+ ...errorCode !== void 0 ? { errorCode } : {},
5315
+ durationMs: value.durationMs,
5316
+ createdAt
5317
+ };
5318
+ }
5319
+ function requireRecordValue(value, message) {
5320
+ if (!isRecord5(value))
5321
+ throw invalidResponse2(message);
5322
+ return value;
5323
+ }
5324
+ function hydrateModelCatalog(value) {
5325
+ if (!isRecord5(value) || !Array.isArray(value.providers) || !Array.isArray(value.models)) {
5326
+ throw invalidResponse2("Invalid platform model catalog");
5327
+ }
5328
+ return value;
5329
+ }
5330
+ function hydrateOpsConfig(value) {
5331
+ if (!isRecord5(value) || typeof value.enabled !== "boolean" || typeof value.modelConfigured !== "boolean") {
5332
+ throw invalidResponse2("Invalid platform ops config");
5333
+ }
5334
+ return {
5335
+ enabled: value.enabled,
5336
+ modelKey: requiredString5(value, "modelKey"),
5337
+ modelConfigured: value.modelConfigured
5338
+ };
5339
+ }
5167
5340
  function errorFromEnvelope2(payload, response) {
5168
5341
  const raw = payload?.error;
5169
5342
  if (typeof raw === "string") {
@@ -5190,6 +5363,108 @@ var PlatformClient = class {
5190
5363
  constructor(baseURL, getHeaders) {
5191
5364
  this.baseURL = baseURL;
5192
5365
  this.getHeaders = getHeaders;
5366
+ const providerPath = (providerId) => `/api/platform/model-providers/${encodeURIComponent(providerId)}`;
5367
+ this.ops = {
5368
+ getConfig: async () => {
5369
+ const data = await this.request("/api/platform/ops/config");
5370
+ return hydrateOpsConfig(data);
5371
+ }
5372
+ };
5373
+ this.modelProviders = {
5374
+ list: async () => {
5375
+ const data = await this.request("/api/platform/model-providers");
5376
+ if (!isRecord5(data) || !Array.isArray(data.records)) {
5377
+ throw invalidResponse2("Invalid platform model provider list");
5378
+ }
5379
+ return data.records;
5380
+ },
5381
+ get: async (providerId) => {
5382
+ const data = await this.request(providerPath(providerId));
5383
+ return requireRecordValue(
5384
+ data,
5385
+ "Invalid platform model provider"
5386
+ );
5387
+ },
5388
+ create: async (input) => {
5389
+ const data = await this.request("/api/platform/model-providers", {
5390
+ method: "POST",
5391
+ body: JSON.stringify(input)
5392
+ });
5393
+ return requireRecordValue(
5394
+ data,
5395
+ "Invalid platform model provider"
5396
+ );
5397
+ },
5398
+ update: async (providerId, input) => {
5399
+ const data = await this.request(providerPath(providerId), {
5400
+ method: "PUT",
5401
+ body: JSON.stringify(input)
5402
+ });
5403
+ return requireRecordValue(
5404
+ data,
5405
+ "Invalid platform model provider"
5406
+ );
5407
+ },
5408
+ delete: async (providerId) => {
5409
+ await this.request(providerPath(providerId), { method: "DELETE" });
5410
+ },
5411
+ probe: async (input) => {
5412
+ const data = await this.request(
5413
+ "/api/platform/model-providers/probe",
5414
+ { method: "POST", body: JSON.stringify(input) }
5415
+ );
5416
+ return requireRecordValue(
5417
+ data,
5418
+ "Invalid platform model provider probe"
5419
+ );
5420
+ },
5421
+ setModels: async (providerId, models) => {
5422
+ const data = await this.request(
5423
+ `${providerPath(providerId)}/models`,
5424
+ { method: "PUT", body: JSON.stringify({ models }) }
5425
+ );
5426
+ return requireRecordValue(
5427
+ data,
5428
+ "Invalid platform model provider"
5429
+ );
5430
+ },
5431
+ discover: async (providerId) => {
5432
+ const data = await this.request(
5433
+ `${providerPath(providerId)}/discover`,
5434
+ { method: "POST", body: JSON.stringify({}) }
5435
+ );
5436
+ return requireRecordValue(
5437
+ data,
5438
+ "Invalid platform model discovery result"
5439
+ );
5440
+ },
5441
+ setModelEnabled: async (providerId, modelId, enabled) => {
5442
+ const data = await this.request(
5443
+ `${providerPath(providerId)}/models/enabled`,
5444
+ { method: "POST", body: JSON.stringify({ modelId, enabled }) }
5445
+ );
5446
+ return requireRecordValue(
5447
+ data,
5448
+ "Invalid platform model provider"
5449
+ );
5450
+ }
5451
+ };
5452
+ }
5453
+ /**
5454
+ * Reads the platform-owned model catalog (providers plus visible models).
5455
+ *
5456
+ * This is the platform-scoped counterpart of `client.tenantModels.list()`.
5457
+ */
5458
+ async modelCatalog() {
5459
+ const data = await this.request("/api/platform/model-catalog");
5460
+ return hydrateModelCatalog(data);
5461
+ }
5462
+ async rateLimits() {
5463
+ const data = await this.request("/api/platform/rate-limits");
5464
+ if (!isRecord5(data) || !Array.isArray(data.policies)) {
5465
+ throw invalidResponse2("Invalid platform rate-limit view");
5466
+ }
5467
+ return data;
5193
5468
  }
5194
5469
  async me() {
5195
5470
  const data = await this.request("/api/platform/me");
@@ -5247,6 +5522,40 @@ var PlatformClient = class {
5247
5522
  const data = await this.request("/api/platform/environment");
5248
5523
  return hydrateEnvironment(data);
5249
5524
  }
5525
+ /**
5526
+ * Reads platform audit records, newest first.
5527
+ *
5528
+ * @param query Optional filters and pagination. Undefined values are omitted
5529
+ * from the request.
5530
+ * @returns Hydrated records with `createdAt` as a `Date`.
5531
+ */
5532
+ async listAudit(query = {}) {
5533
+ const search = new URLSearchParams();
5534
+ for (const [key, value] of Object.entries(query)) {
5535
+ if (value !== void 0)
5536
+ search.set(key, String(value));
5537
+ }
5538
+ const suffix = search.toString();
5539
+ const data = await this.request(
5540
+ `/api/platform/audit${suffix ? `?${suffix}` : ""}`
5541
+ );
5542
+ if (!Array.isArray(data)) {
5543
+ throw invalidResponse2("Invalid platform audit list");
5544
+ }
5545
+ return data.map(hydratePlatformAudit);
5546
+ }
5547
+ /**
5548
+ * Reads a single platform audit record by id.
5549
+ *
5550
+ * @param auditId Audit record id.
5551
+ * @returns The hydrated record with `createdAt` as a `Date`.
5552
+ */
5553
+ async getAudit(auditId) {
5554
+ const data = await this.request(
5555
+ `/api/platform/audit/${encodeURIComponent(auditId)}`
5556
+ );
5557
+ return hydratePlatformAudit(data);
5558
+ }
5250
5559
  /**
5251
5560
  * Resolves the public branding for the current gateway host.
5252
5561
  *
@@ -5478,7 +5787,10 @@ var PlatformClient = class {
5478
5787
  return hydrateOidcIdentityClaim(data);
5479
5788
  }
5480
5789
  async request(path, init = {}) {
5481
- const headers = { ...this.getHeaders() };
5790
+ const headers = {
5791
+ ...this.getHeaders(),
5792
+ ...init.headers
5793
+ };
5482
5794
  if (init.body !== void 0) {
5483
5795
  headers["Content-Type"] = "application/json";
5484
5796
  }