@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/__tests__/platform.test.js +245 -0
- package/dist/__tests__/platform.test.js.map +1 -1
- package/dist/abstract-client.d.ts +18 -0
- package/dist/abstract-client.d.ts.map +1 -1
- package/dist/abstract-client.js +42 -0
- package/dist/abstract-client.js.map +1 -1
- package/dist/index.d.ts +146 -1
- package/dist/index.js +313 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +313 -1
- package/dist/index.mjs.map +1 -1
- package/dist/platform.d.ts +128 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +250 -1
- package/dist/platform.js.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3459,6 +3459,48 @@ var AbstractClient = class {
|
|
|
3459
3459
|
return response.data;
|
|
3460
3460
|
}
|
|
3461
3461
|
};
|
|
3462
|
+
this.personalMcpServers = {
|
|
3463
|
+
list: async () => {
|
|
3464
|
+
const response = await this.makeRequest("/api/personal-mcp-servers");
|
|
3465
|
+
return response.data.records;
|
|
3466
|
+
},
|
|
3467
|
+
get: async (keyOrId) => {
|
|
3468
|
+
const response = await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}`);
|
|
3469
|
+
if (!response.data)
|
|
3470
|
+
throw new ApiError("Personal MCP server config not found", 404);
|
|
3471
|
+
return response.data;
|
|
3472
|
+
},
|
|
3473
|
+
create: async (data) => {
|
|
3474
|
+
const response = await this.makeRequest("/api/personal-mcp-servers", { method: "POST", body: data });
|
|
3475
|
+
if (!response.data)
|
|
3476
|
+
throw new ApiError("Failed to create personal MCP server config", 500);
|
|
3477
|
+
return response.data;
|
|
3478
|
+
},
|
|
3479
|
+
update: async (keyOrId, data) => {
|
|
3480
|
+
const response = await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}`, { method: "PUT", body: data });
|
|
3481
|
+
if (!response.data)
|
|
3482
|
+
throw new ApiError("Failed to update personal MCP server config", 500);
|
|
3483
|
+
return response.data;
|
|
3484
|
+
},
|
|
3485
|
+
delete: async (keyOrId) => {
|
|
3486
|
+
await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}`, { method: "DELETE" });
|
|
3487
|
+
},
|
|
3488
|
+
test: async (keyOrId) => {
|
|
3489
|
+
return await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}/test`, { method: "POST" });
|
|
3490
|
+
},
|
|
3491
|
+
connect: async (keyOrId) => {
|
|
3492
|
+
const response = await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}/connect`, { method: "POST" });
|
|
3493
|
+
if (!response.data)
|
|
3494
|
+
throw new ApiError("Failed to connect personal MCP server", 500);
|
|
3495
|
+
return response.data;
|
|
3496
|
+
},
|
|
3497
|
+
disconnect: async (keyOrId) => {
|
|
3498
|
+
const response = await this.makeRequest(`/api/personal-mcp-servers/${keyOrId}/disconnect`, { method: "POST" });
|
|
3499
|
+
if (!response.data)
|
|
3500
|
+
throw new ApiError("Failed to disconnect personal MCP server", 500);
|
|
3501
|
+
return response.data;
|
|
3502
|
+
}
|
|
3503
|
+
};
|
|
3462
3504
|
this.connections = {
|
|
3463
3505
|
list: async (type) => {
|
|
3464
3506
|
const response = await this.makeRequest(`/api/connections?type=${encodeURIComponent(type)}`);
|
|
@@ -5128,6 +5170,137 @@ function hydrateUser(value) {
|
|
|
5128
5170
|
...typeof value.updatedAt === "string" ? { updatedAt: value.updatedAt } : {}
|
|
5129
5171
|
};
|
|
5130
5172
|
}
|
|
5173
|
+
function hydrateAuditInitiator(value) {
|
|
5174
|
+
if (!isRecord5(value) || typeof value.type !== "string") {
|
|
5175
|
+
throw invalidResponse2("Invalid platform audit initiator");
|
|
5176
|
+
}
|
|
5177
|
+
if (value.type === "human") {
|
|
5178
|
+
if (typeof value.userId !== "string" || value.role !== "owner" && value.role !== "admin" && value.role !== "auditor") {
|
|
5179
|
+
throw invalidResponse2("Invalid platform audit human initiator");
|
|
5180
|
+
}
|
|
5181
|
+
return { type: "human", userId: value.userId, role: value.role };
|
|
5182
|
+
}
|
|
5183
|
+
if (value.type === "bootstrap") {
|
|
5184
|
+
return { type: "bootstrap" };
|
|
5185
|
+
}
|
|
5186
|
+
if (value.type === "system") {
|
|
5187
|
+
if (typeof value.component !== "string") {
|
|
5188
|
+
throw invalidResponse2("Invalid platform audit system initiator");
|
|
5189
|
+
}
|
|
5190
|
+
return { type: "system", component: value.component };
|
|
5191
|
+
}
|
|
5192
|
+
throw invalidResponse2("Invalid platform audit initiator");
|
|
5193
|
+
}
|
|
5194
|
+
function hydrateAuditExecutor(value) {
|
|
5195
|
+
if (!isRecord5(value) || typeof value.type !== "string") {
|
|
5196
|
+
throw invalidResponse2("Invalid platform audit executor");
|
|
5197
|
+
}
|
|
5198
|
+
if (value.type === "admin_center") {
|
|
5199
|
+
if (typeof value.route !== "string") {
|
|
5200
|
+
throw invalidResponse2("Invalid platform audit admin center executor");
|
|
5201
|
+
}
|
|
5202
|
+
return { type: "admin_center", route: value.route };
|
|
5203
|
+
}
|
|
5204
|
+
if (value.type === "ops_agent") {
|
|
5205
|
+
if (value.agentId !== "platform-ops" || typeof value.threadId !== "string" || typeof value.runId !== "string" || typeof value.toolName !== "string") {
|
|
5206
|
+
throw invalidResponse2("Invalid platform audit ops agent executor");
|
|
5207
|
+
}
|
|
5208
|
+
return {
|
|
5209
|
+
type: "ops_agent",
|
|
5210
|
+
agentId: "platform-ops",
|
|
5211
|
+
threadId: value.threadId,
|
|
5212
|
+
runId: value.runId,
|
|
5213
|
+
toolName: value.toolName
|
|
5214
|
+
};
|
|
5215
|
+
}
|
|
5216
|
+
if (value.type === "bootstrap") {
|
|
5217
|
+
return { type: "bootstrap" };
|
|
5218
|
+
}
|
|
5219
|
+
if (value.type === "system") {
|
|
5220
|
+
if (typeof value.component !== "string") {
|
|
5221
|
+
throw invalidResponse2("Invalid platform audit system executor");
|
|
5222
|
+
}
|
|
5223
|
+
return { type: "system", component: value.component };
|
|
5224
|
+
}
|
|
5225
|
+
throw invalidResponse2("Invalid platform audit executor");
|
|
5226
|
+
}
|
|
5227
|
+
function hydrateAuditSource(value) {
|
|
5228
|
+
if (value === "admin_center" || value === "ops_agent" || value === "bootstrap" || value === "system") {
|
|
5229
|
+
return value;
|
|
5230
|
+
}
|
|
5231
|
+
throw invalidResponse2("Invalid platform audit source");
|
|
5232
|
+
}
|
|
5233
|
+
function hydrateAuditAction(value) {
|
|
5234
|
+
if (value === "write" || value === "playbook")
|
|
5235
|
+
return value;
|
|
5236
|
+
throw invalidResponse2("Invalid platform audit action");
|
|
5237
|
+
}
|
|
5238
|
+
function hydrateAuditStatus(value) {
|
|
5239
|
+
if (value === "ok" || value === "error" || value === "cancelled") {
|
|
5240
|
+
return value;
|
|
5241
|
+
}
|
|
5242
|
+
throw invalidResponse2("Invalid platform audit status");
|
|
5243
|
+
}
|
|
5244
|
+
function hydratePlatformAudit(value) {
|
|
5245
|
+
if (!isRecord5(value) || typeof value.id !== "string") {
|
|
5246
|
+
throw invalidResponse2("Invalid platform audit record");
|
|
5247
|
+
}
|
|
5248
|
+
const initiator = hydrateAuditInitiator(value.initiator);
|
|
5249
|
+
const executor = hydrateAuditExecutor(value.executor);
|
|
5250
|
+
const source = hydrateAuditSource(value.source);
|
|
5251
|
+
const action = hydrateAuditAction(value.action);
|
|
5252
|
+
const status = hydrateAuditStatus(value.status);
|
|
5253
|
+
const createdAt = new Date(requiredString5(value, "createdAt"));
|
|
5254
|
+
if (Number.isNaN(createdAt.getTime())) {
|
|
5255
|
+
throw invalidResponse2("Invalid platform audit timestamp");
|
|
5256
|
+
}
|
|
5257
|
+
if (!isRecord5(value.summary)) {
|
|
5258
|
+
throw invalidResponse2("Invalid platform audit summary");
|
|
5259
|
+
}
|
|
5260
|
+
if (typeof value.durationMs !== "number" || !Number.isFinite(value.durationMs)) {
|
|
5261
|
+
throw invalidResponse2("Invalid platform audit duration");
|
|
5262
|
+
}
|
|
5263
|
+
const tenantId = optionalString(value, "tenantId");
|
|
5264
|
+
const before = optionalRecord(value, "before");
|
|
5265
|
+
const after = optionalRecord(value, "after");
|
|
5266
|
+
const errorCode = optionalString(value, "errorCode");
|
|
5267
|
+
return {
|
|
5268
|
+
id: value.id,
|
|
5269
|
+
initiator,
|
|
5270
|
+
source,
|
|
5271
|
+
executor,
|
|
5272
|
+
...tenantId !== void 0 ? { tenantId } : {},
|
|
5273
|
+
action,
|
|
5274
|
+
status,
|
|
5275
|
+
summary: value.summary,
|
|
5276
|
+
...before !== void 0 ? { before } : {},
|
|
5277
|
+
...after !== void 0 ? { after } : {},
|
|
5278
|
+
...errorCode !== void 0 ? { errorCode } : {},
|
|
5279
|
+
durationMs: value.durationMs,
|
|
5280
|
+
createdAt
|
|
5281
|
+
};
|
|
5282
|
+
}
|
|
5283
|
+
function requireRecordValue(value, message) {
|
|
5284
|
+
if (!isRecord5(value))
|
|
5285
|
+
throw invalidResponse2(message);
|
|
5286
|
+
return value;
|
|
5287
|
+
}
|
|
5288
|
+
function hydrateModelCatalog(value) {
|
|
5289
|
+
if (!isRecord5(value) || !Array.isArray(value.providers) || !Array.isArray(value.models)) {
|
|
5290
|
+
throw invalidResponse2("Invalid platform model catalog");
|
|
5291
|
+
}
|
|
5292
|
+
return value;
|
|
5293
|
+
}
|
|
5294
|
+
function hydrateOpsConfig(value) {
|
|
5295
|
+
if (!isRecord5(value) || typeof value.enabled !== "boolean" || typeof value.modelConfigured !== "boolean") {
|
|
5296
|
+
throw invalidResponse2("Invalid platform ops config");
|
|
5297
|
+
}
|
|
5298
|
+
return {
|
|
5299
|
+
enabled: value.enabled,
|
|
5300
|
+
modelKey: requiredString5(value, "modelKey"),
|
|
5301
|
+
modelConfigured: value.modelConfigured
|
|
5302
|
+
};
|
|
5303
|
+
}
|
|
5131
5304
|
function errorFromEnvelope2(payload, response) {
|
|
5132
5305
|
const raw = payload?.error;
|
|
5133
5306
|
if (typeof raw === "string") {
|
|
@@ -5154,6 +5327,108 @@ var PlatformClient = class {
|
|
|
5154
5327
|
constructor(baseURL, getHeaders) {
|
|
5155
5328
|
this.baseURL = baseURL;
|
|
5156
5329
|
this.getHeaders = getHeaders;
|
|
5330
|
+
const providerPath = (providerId) => `/api/platform/model-providers/${encodeURIComponent(providerId)}`;
|
|
5331
|
+
this.ops = {
|
|
5332
|
+
getConfig: async () => {
|
|
5333
|
+
const data = await this.request("/api/platform/ops/config");
|
|
5334
|
+
return hydrateOpsConfig(data);
|
|
5335
|
+
}
|
|
5336
|
+
};
|
|
5337
|
+
this.modelProviders = {
|
|
5338
|
+
list: async () => {
|
|
5339
|
+
const data = await this.request("/api/platform/model-providers");
|
|
5340
|
+
if (!isRecord5(data) || !Array.isArray(data.records)) {
|
|
5341
|
+
throw invalidResponse2("Invalid platform model provider list");
|
|
5342
|
+
}
|
|
5343
|
+
return data.records;
|
|
5344
|
+
},
|
|
5345
|
+
get: async (providerId) => {
|
|
5346
|
+
const data = await this.request(providerPath(providerId));
|
|
5347
|
+
return requireRecordValue(
|
|
5348
|
+
data,
|
|
5349
|
+
"Invalid platform model provider"
|
|
5350
|
+
);
|
|
5351
|
+
},
|
|
5352
|
+
create: async (input) => {
|
|
5353
|
+
const data = await this.request("/api/platform/model-providers", {
|
|
5354
|
+
method: "POST",
|
|
5355
|
+
body: JSON.stringify(input)
|
|
5356
|
+
});
|
|
5357
|
+
return requireRecordValue(
|
|
5358
|
+
data,
|
|
5359
|
+
"Invalid platform model provider"
|
|
5360
|
+
);
|
|
5361
|
+
},
|
|
5362
|
+
update: async (providerId, input) => {
|
|
5363
|
+
const data = await this.request(providerPath(providerId), {
|
|
5364
|
+
method: "PUT",
|
|
5365
|
+
body: JSON.stringify(input)
|
|
5366
|
+
});
|
|
5367
|
+
return requireRecordValue(
|
|
5368
|
+
data,
|
|
5369
|
+
"Invalid platform model provider"
|
|
5370
|
+
);
|
|
5371
|
+
},
|
|
5372
|
+
delete: async (providerId) => {
|
|
5373
|
+
await this.request(providerPath(providerId), { method: "DELETE" });
|
|
5374
|
+
},
|
|
5375
|
+
probe: async (input) => {
|
|
5376
|
+
const data = await this.request(
|
|
5377
|
+
"/api/platform/model-providers/probe",
|
|
5378
|
+
{ method: "POST", body: JSON.stringify(input) }
|
|
5379
|
+
);
|
|
5380
|
+
return requireRecordValue(
|
|
5381
|
+
data,
|
|
5382
|
+
"Invalid platform model provider probe"
|
|
5383
|
+
);
|
|
5384
|
+
},
|
|
5385
|
+
setModels: async (providerId, models) => {
|
|
5386
|
+
const data = await this.request(
|
|
5387
|
+
`${providerPath(providerId)}/models`,
|
|
5388
|
+
{ method: "PUT", body: JSON.stringify({ models }) }
|
|
5389
|
+
);
|
|
5390
|
+
return requireRecordValue(
|
|
5391
|
+
data,
|
|
5392
|
+
"Invalid platform model provider"
|
|
5393
|
+
);
|
|
5394
|
+
},
|
|
5395
|
+
discover: async (providerId) => {
|
|
5396
|
+
const data = await this.request(
|
|
5397
|
+
`${providerPath(providerId)}/discover`,
|
|
5398
|
+
{ method: "POST", body: JSON.stringify({}) }
|
|
5399
|
+
);
|
|
5400
|
+
return requireRecordValue(
|
|
5401
|
+
data,
|
|
5402
|
+
"Invalid platform model discovery result"
|
|
5403
|
+
);
|
|
5404
|
+
},
|
|
5405
|
+
setModelEnabled: async (providerId, modelId, enabled) => {
|
|
5406
|
+
const data = await this.request(
|
|
5407
|
+
`${providerPath(providerId)}/models/enabled`,
|
|
5408
|
+
{ method: "POST", body: JSON.stringify({ modelId, enabled }) }
|
|
5409
|
+
);
|
|
5410
|
+
return requireRecordValue(
|
|
5411
|
+
data,
|
|
5412
|
+
"Invalid platform model provider"
|
|
5413
|
+
);
|
|
5414
|
+
}
|
|
5415
|
+
};
|
|
5416
|
+
}
|
|
5417
|
+
/**
|
|
5418
|
+
* Reads the platform-owned model catalog (providers plus visible models).
|
|
5419
|
+
*
|
|
5420
|
+
* This is the platform-scoped counterpart of `client.tenantModels.list()`.
|
|
5421
|
+
*/
|
|
5422
|
+
async modelCatalog() {
|
|
5423
|
+
const data = await this.request("/api/platform/model-catalog");
|
|
5424
|
+
return hydrateModelCatalog(data);
|
|
5425
|
+
}
|
|
5426
|
+
async rateLimits() {
|
|
5427
|
+
const data = await this.request("/api/platform/rate-limits");
|
|
5428
|
+
if (!isRecord5(data) || !Array.isArray(data.policies)) {
|
|
5429
|
+
throw invalidResponse2("Invalid platform rate-limit view");
|
|
5430
|
+
}
|
|
5431
|
+
return data;
|
|
5157
5432
|
}
|
|
5158
5433
|
async me() {
|
|
5159
5434
|
const data = await this.request("/api/platform/me");
|
|
@@ -5211,6 +5486,40 @@ var PlatformClient = class {
|
|
|
5211
5486
|
const data = await this.request("/api/platform/environment");
|
|
5212
5487
|
return hydrateEnvironment(data);
|
|
5213
5488
|
}
|
|
5489
|
+
/**
|
|
5490
|
+
* Reads platform audit records, newest first.
|
|
5491
|
+
*
|
|
5492
|
+
* @param query Optional filters and pagination. Undefined values are omitted
|
|
5493
|
+
* from the request.
|
|
5494
|
+
* @returns Hydrated records with `createdAt` as a `Date`.
|
|
5495
|
+
*/
|
|
5496
|
+
async listAudit(query = {}) {
|
|
5497
|
+
const search = new URLSearchParams();
|
|
5498
|
+
for (const [key, value] of Object.entries(query)) {
|
|
5499
|
+
if (value !== void 0)
|
|
5500
|
+
search.set(key, String(value));
|
|
5501
|
+
}
|
|
5502
|
+
const suffix = search.toString();
|
|
5503
|
+
const data = await this.request(
|
|
5504
|
+
`/api/platform/audit${suffix ? `?${suffix}` : ""}`
|
|
5505
|
+
);
|
|
5506
|
+
if (!Array.isArray(data)) {
|
|
5507
|
+
throw invalidResponse2("Invalid platform audit list");
|
|
5508
|
+
}
|
|
5509
|
+
return data.map(hydratePlatformAudit);
|
|
5510
|
+
}
|
|
5511
|
+
/**
|
|
5512
|
+
* Reads a single platform audit record by id.
|
|
5513
|
+
*
|
|
5514
|
+
* @param auditId Audit record id.
|
|
5515
|
+
* @returns The hydrated record with `createdAt` as a `Date`.
|
|
5516
|
+
*/
|
|
5517
|
+
async getAudit(auditId) {
|
|
5518
|
+
const data = await this.request(
|
|
5519
|
+
`/api/platform/audit/${encodeURIComponent(auditId)}`
|
|
5520
|
+
);
|
|
5521
|
+
return hydratePlatformAudit(data);
|
|
5522
|
+
}
|
|
5214
5523
|
/**
|
|
5215
5524
|
* Resolves the public branding for the current gateway host.
|
|
5216
5525
|
*
|
|
@@ -5442,7 +5751,10 @@ var PlatformClient = class {
|
|
|
5442
5751
|
return hydrateOidcIdentityClaim(data);
|
|
5443
5752
|
}
|
|
5444
5753
|
async request(path, init = {}) {
|
|
5445
|
-
const headers = {
|
|
5754
|
+
const headers = {
|
|
5755
|
+
...this.getHeaders(),
|
|
5756
|
+
...init.headers
|
|
5757
|
+
};
|
|
5446
5758
|
if (init.body !== void 0) {
|
|
5447
5759
|
headers["Content-Type"] = "application/json";
|
|
5448
5760
|
}
|