@agent-commons/sdk 0.4.0 → 0.6.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/LICENSE +21 -0
- package/README.md +230 -0
- package/dist/index.cjs +726 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1115 -15
- package/dist/index.d.ts +1115 -15
- package/dist/index.mjs +726 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +27 -3
package/dist/index.mjs
CHANGED
|
@@ -5,29 +5,91 @@ var CommonsClient = class {
|
|
|
5
5
|
/\/$/,
|
|
6
6
|
""
|
|
7
7
|
);
|
|
8
|
+
this.identityUrl = (config.identityUrl ?? "https://auth.agentcommons.io").replace(/\/api\/auth\/?$/, "").replace(/\/$/, "");
|
|
9
|
+
this.identityToken = config.identityToken;
|
|
8
10
|
this.apiKey = config.apiKey;
|
|
9
11
|
this.initiator = config.initiator;
|
|
10
12
|
this._fetch = config.fetch ?? fetch;
|
|
11
13
|
}
|
|
12
14
|
// ── Helpers ───────────────────────────────────────────────────────────────
|
|
13
|
-
headers(extra) {
|
|
14
|
-
const h = {
|
|
15
|
+
headers(extra, json = true) {
|
|
16
|
+
const h = {};
|
|
17
|
+
if (json) h["Content-Type"] = "application/json";
|
|
15
18
|
if (this.apiKey) h["Authorization"] = `Bearer ${this.apiKey}`;
|
|
16
19
|
if (this.initiator) h["x-initiator"] = this.initiator;
|
|
17
20
|
return { ...h, ...extra };
|
|
18
21
|
}
|
|
19
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Call an API route that is not yet represented by a resource namespace.
|
|
24
|
+
* Most applications should use the typed helpers below.
|
|
25
|
+
*/
|
|
26
|
+
async request(method, path, body, options = {}) {
|
|
27
|
+
const isFormData = typeof FormData !== "undefined" && body instanceof FormData;
|
|
20
28
|
const res = await this._fetch(`${this.baseUrl}${path}`, {
|
|
21
29
|
method,
|
|
22
|
-
headers: this.headers(),
|
|
23
|
-
body: body
|
|
30
|
+
headers: this.headers(options.headers, !isFormData),
|
|
31
|
+
body: body === void 0 ? void 0 : isFormData ? body : JSON.stringify(body),
|
|
32
|
+
signal: options.signal
|
|
24
33
|
});
|
|
25
34
|
if (!res.ok) {
|
|
26
|
-
const err = await
|
|
27
|
-
throw new CommonsError(
|
|
35
|
+
const err = await this.errorPayload(res);
|
|
36
|
+
throw new CommonsError(
|
|
37
|
+
this.errorMessage(err, res.statusText),
|
|
38
|
+
res.status,
|
|
39
|
+
err
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
if (res.status === 204) return void 0;
|
|
43
|
+
const contentType = res.headers.get("content-type") ?? "";
|
|
44
|
+
if (!contentType.includes("json")) {
|
|
45
|
+
return await res.text();
|
|
28
46
|
}
|
|
29
47
|
return res.json();
|
|
30
48
|
}
|
|
49
|
+
async errorPayload(res) {
|
|
50
|
+
const contentType = res.headers.get("content-type") ?? "";
|
|
51
|
+
if (contentType.includes("json")) {
|
|
52
|
+
return res.json().catch(() => ({ message: res.statusText }));
|
|
53
|
+
}
|
|
54
|
+
const message = await res.text().catch(() => "");
|
|
55
|
+
return { message: message || res.statusText };
|
|
56
|
+
}
|
|
57
|
+
errorMessage(error, fallback) {
|
|
58
|
+
if (!error || typeof error !== "object") return fallback;
|
|
59
|
+
if ("message" in error && typeof error.message === "string") {
|
|
60
|
+
return error.message;
|
|
61
|
+
}
|
|
62
|
+
if ("error" in error) {
|
|
63
|
+
if (typeof error.error === "string") return error.error;
|
|
64
|
+
if (error.error && typeof error.error === "object" && "message" in error.error && typeof error.error.message === "string") {
|
|
65
|
+
return error.error.message;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return fallback;
|
|
69
|
+
}
|
|
70
|
+
async identityRequest(method, path, body) {
|
|
71
|
+
const headers = {};
|
|
72
|
+
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
73
|
+
if (this.identityToken) {
|
|
74
|
+
headers.Authorization = `Bearer ${this.identityToken}`;
|
|
75
|
+
}
|
|
76
|
+
const response = await this._fetch(`${this.identityUrl}${path}`, {
|
|
77
|
+
method,
|
|
78
|
+
headers,
|
|
79
|
+
credentials: "include",
|
|
80
|
+
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
81
|
+
});
|
|
82
|
+
if (!response.ok) {
|
|
83
|
+
const error = await this.errorPayload(response);
|
|
84
|
+
throw new CommonsError(
|
|
85
|
+
this.errorMessage(error, response.statusText),
|
|
86
|
+
response.status,
|
|
87
|
+
error
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
if (response.status === 204) return void 0;
|
|
91
|
+
return response.json();
|
|
92
|
+
}
|
|
31
93
|
// ── Models ────────────────────────────────────────────────────────────────
|
|
32
94
|
get models() {
|
|
33
95
|
return {
|
|
@@ -42,17 +104,40 @@ var CommonsClient = class {
|
|
|
42
104
|
list: (owner) => this.request("GET", `/v1/agents${owner ? `?owner=${owner}` : ""}`),
|
|
43
105
|
get: (agentId) => this.request("GET", `/v1/agents/${agentId}`),
|
|
44
106
|
update: (agentId, params) => this.request("PUT", `/v1/agents/${agentId}`, params),
|
|
107
|
+
/**
|
|
108
|
+
* Generate durable image assets for this agent without routing a
|
|
109
|
+
* deterministic image operation through an LLM tool-selection turn.
|
|
110
|
+
*/
|
|
111
|
+
generateImage: (agentId, params) => this.request(
|
|
112
|
+
"POST",
|
|
113
|
+
`/v1/agents/${encodeURIComponent(agentId)}/assets/images`,
|
|
114
|
+
params
|
|
115
|
+
),
|
|
45
116
|
getRuntime: (agentId) => this.request("GET", `/v1/agents/${agentId}/runtime`),
|
|
46
117
|
configureRuntime: (agentId, params) => this.request("PUT", `/v1/agents/${agentId}/runtime`, params),
|
|
47
118
|
deployRuntime: (agentId) => this.request("POST", `/v1/agents/${agentId}/runtime/deploy`),
|
|
48
119
|
sleepRuntime: (agentId) => this.request("POST", `/v1/agents/${agentId}/runtime/sleep`),
|
|
49
120
|
restartRuntime: (agentId) => this.request("POST", `/v1/agents/${agentId}/runtime/restart`),
|
|
121
|
+
manageRuntimeChannel: (agentId, channel, action, params = {}) => this.request(
|
|
122
|
+
"POST",
|
|
123
|
+
`/v1/agents/${encodeURIComponent(agentId)}/runtime/channels/${encodeURIComponent(channel)}/${encodeURIComponent(action)}`,
|
|
124
|
+
params
|
|
125
|
+
),
|
|
50
126
|
/** List tools assigned to an agent. */
|
|
51
127
|
listTools: (agentId) => this.request("GET", `/v1/agents/${agentId}/tools`),
|
|
52
128
|
/** Assign a tool to an agent. */
|
|
53
129
|
addTool: (agentId, params) => this.request("POST", `/v1/agents/${agentId}/tools`, params),
|
|
130
|
+
/** Update an agent tool assignment. */
|
|
131
|
+
updateTool: (assignmentId, params) => this.request(
|
|
132
|
+
"PATCH",
|
|
133
|
+
`/v1/agents/tools/${encodeURIComponent(assignmentId)}`,
|
|
134
|
+
params
|
|
135
|
+
),
|
|
54
136
|
/** Remove a tool assignment from an agent. */
|
|
55
|
-
removeTool: (assignmentId) => this.request(
|
|
137
|
+
removeTool: (assignmentId) => this.request(
|
|
138
|
+
"DELETE",
|
|
139
|
+
`/v1/agents/tools/${encodeURIComponent(assignmentId)}`
|
|
140
|
+
),
|
|
56
141
|
/** Create a liaison agent for an external agent. */
|
|
57
142
|
createLiaison: (params) => this.request("POST", "/v1/liaison", params),
|
|
58
143
|
/**
|
|
@@ -65,6 +150,11 @@ var CommonsClient = class {
|
|
|
65
150
|
* }
|
|
66
151
|
*/
|
|
67
152
|
stream: (params) => this._streamAgentRun(params),
|
|
153
|
+
/** Resume a streamed run after executing a caller-owned CLI tool. */
|
|
154
|
+
submitCliToolResult: (requestId, result) => this.request("POST", "/v1/agents/cli-tool-result", {
|
|
155
|
+
requestId,
|
|
156
|
+
result
|
|
157
|
+
}),
|
|
68
158
|
// ── Heartbeat ─────────────────────────────────────────────────────────
|
|
69
159
|
/** Get the current heartbeat status for an agent. */
|
|
70
160
|
getAutonomy: (agentId) => this.request("GET", `/v1/agents/${agentId}/autonomy`),
|
|
@@ -115,6 +205,11 @@ var CommonsClient = class {
|
|
|
115
205
|
`/v1/agents/${agentId}/computer/files/read?path=${encodeURIComponent(path)}`
|
|
116
206
|
);
|
|
117
207
|
},
|
|
208
|
+
writeComputerFile: (agentId, params) => this.request(
|
|
209
|
+
"POST",
|
|
210
|
+
`/v1/agents/${encodeURIComponent(agentId)}/computer/files/write`,
|
|
211
|
+
params
|
|
212
|
+
),
|
|
118
213
|
openComputerBrowser: (agentId, paramsOrLegacyComputerId, legacyParams) => {
|
|
119
214
|
const params = typeof paramsOrLegacyComputerId === "string" ? legacyParams : paramsOrLegacyComputerId;
|
|
120
215
|
if (!params) {
|
|
@@ -126,6 +221,11 @@ var CommonsClient = class {
|
|
|
126
221
|
params
|
|
127
222
|
);
|
|
128
223
|
},
|
|
224
|
+
testComputerBrowser: (agentId) => this.request(
|
|
225
|
+
"POST",
|
|
226
|
+
`/v1/agents/${encodeURIComponent(agentId)}/computer/browser/test`,
|
|
227
|
+
{}
|
|
228
|
+
),
|
|
129
229
|
listComputerEvents: (agentId, limitOrLegacyComputerId, legacyLimit) => {
|
|
130
230
|
const limit = typeof limitOrLegacyComputerId === "number" ? limitOrLegacyComputerId : legacyLimit;
|
|
131
231
|
return this.request(
|
|
@@ -183,6 +283,26 @@ var CommonsClient = class {
|
|
|
183
283
|
}
|
|
184
284
|
};
|
|
185
285
|
}
|
|
286
|
+
get copilot() {
|
|
287
|
+
return {
|
|
288
|
+
get: () => this.request("GET", "/v1/copilot"),
|
|
289
|
+
updateSettings: (params) => this.request("PUT", "/v1/copilot/settings", params),
|
|
290
|
+
listChanges: (filter) => {
|
|
291
|
+
const query = new URLSearchParams();
|
|
292
|
+
if (filter?.status) query.set("status", filter.status);
|
|
293
|
+
if (filter?.resourceType)
|
|
294
|
+
query.set("resourceType", filter.resourceType);
|
|
295
|
+
if (filter?.resourceId) query.set("resourceId", filter.resourceId);
|
|
296
|
+
return this.request(
|
|
297
|
+
"GET",
|
|
298
|
+
`/v1/copilot/changes${query.size ? `?${query}` : ""}`
|
|
299
|
+
);
|
|
300
|
+
},
|
|
301
|
+
acceptChange: (changeId) => this.request("POST", `/v1/copilot/changes/${changeId}/accept`),
|
|
302
|
+
rejectChange: (changeId) => this.request("POST", `/v1/copilot/changes/${changeId}/reject`),
|
|
303
|
+
revertChange: (changeId) => this.request("POST", `/v1/copilot/changes/${changeId}/revert`)
|
|
304
|
+
};
|
|
305
|
+
}
|
|
186
306
|
// ── Run (non-streaming) ───────────────────────────────────────────────────
|
|
187
307
|
get run() {
|
|
188
308
|
return {
|
|
@@ -197,9 +317,45 @@ var CommonsClient = class {
|
|
|
197
317
|
"GET",
|
|
198
318
|
`/v1/workflows?ownerId=${ownerId}&ownerType=${ownerType}`
|
|
199
319
|
),
|
|
320
|
+
discoverPublic: (filter) => {
|
|
321
|
+
const query = new URLSearchParams();
|
|
322
|
+
if (filter?.category) query.set("category", filter.category);
|
|
323
|
+
if (filter?.tags?.length) query.set("tags", filter.tags.join(","));
|
|
324
|
+
if (filter?.limit) query.set("limit", String(filter.limit));
|
|
325
|
+
return this.request(
|
|
326
|
+
"GET",
|
|
327
|
+
`/v1/workflows/public${query.size ? `?${query}` : ""}`
|
|
328
|
+
);
|
|
329
|
+
},
|
|
200
330
|
get: (workflowId) => this.request("GET", `/v1/workflows/${workflowId}`),
|
|
201
331
|
update: (workflowId, updates) => this.request("PUT", `/v1/workflows/${workflowId}`, updates),
|
|
202
332
|
delete: (workflowId) => this.request("DELETE", `/v1/workflows/${workflowId}`),
|
|
333
|
+
fork: (workflowId, params) => this.request(
|
|
334
|
+
"POST",
|
|
335
|
+
`/v1/workflows/${encodeURIComponent(workflowId)}/fork`,
|
|
336
|
+
params
|
|
337
|
+
),
|
|
338
|
+
getWebhook: (workflowId) => this.request(
|
|
339
|
+
"GET",
|
|
340
|
+
`/v1/workflows/${encodeURIComponent(workflowId)}/webhook`
|
|
341
|
+
),
|
|
342
|
+
rotateWebhookToken: (workflowId) => this.request(
|
|
343
|
+
"POST",
|
|
344
|
+
`/v1/workflows/${encodeURIComponent(workflowId)}/webhook-token`,
|
|
345
|
+
{}
|
|
346
|
+
),
|
|
347
|
+
disableWebhook: (workflowId) => this.request(
|
|
348
|
+
"DELETE",
|
|
349
|
+
`/v1/workflows/${encodeURIComponent(workflowId)}/webhook-token`
|
|
350
|
+
),
|
|
351
|
+
executeWebhook: (token, payload, query) => {
|
|
352
|
+
const search = query ? new URLSearchParams(query).toString() : "";
|
|
353
|
+
return this.request(
|
|
354
|
+
"POST",
|
|
355
|
+
`/v1/workflows/webhooks/${encodeURIComponent(token)}${search ? `?${search}` : ""}`,
|
|
356
|
+
payload
|
|
357
|
+
);
|
|
358
|
+
},
|
|
203
359
|
execute: (workflowId, params) => this.request("POST", `/v1/workflows/${workflowId}/execute`, params),
|
|
204
360
|
getExecution: (workflowId, executionId) => this.request(
|
|
205
361
|
"GET",
|
|
@@ -265,7 +421,23 @@ var CommonsClient = class {
|
|
|
265
421
|
create: (params) => this.request("POST", "/v1/sessions", params),
|
|
266
422
|
get: (sessionId) => this.request("GET", `/v1/sessions/${sessionId}`),
|
|
267
423
|
/** Get full session with history, tasks, childSessions, and spaces. */
|
|
268
|
-
getFull: (sessionId) => this.request("GET", `/v1/sessions/${sessionId}/full`)
|
|
424
|
+
getFull: (sessionId) => this.request("GET", `/v1/sessions/${sessionId}/full`),
|
|
425
|
+
/** Rename a session. */
|
|
426
|
+
rename: (sessionId, title) => this.request(
|
|
427
|
+
"PATCH",
|
|
428
|
+
`/v1/sessions/${encodeURIComponent(sessionId)}`,
|
|
429
|
+
{ title }
|
|
430
|
+
),
|
|
431
|
+
/** Delete a session and its owned session data. */
|
|
432
|
+
delete: (sessionId) => this.request(
|
|
433
|
+
"DELETE",
|
|
434
|
+
`/v1/sessions/${encodeURIComponent(sessionId)}`
|
|
435
|
+
),
|
|
436
|
+
/** Get the full chat transcript for a session. */
|
|
437
|
+
getChat: (sessionId) => this.request(
|
|
438
|
+
"GET",
|
|
439
|
+
`/v1/agents/sessions/${encodeURIComponent(sessionId)}/chat`
|
|
440
|
+
)
|
|
269
441
|
};
|
|
270
442
|
}
|
|
271
443
|
// ── Tools ─────────────────────────────────────────────────────────────────
|
|
@@ -301,39 +473,123 @@ var CommonsClient = class {
|
|
|
301
473
|
const q = params ? new URLSearchParams(params).toString() : "";
|
|
302
474
|
return this.request("GET", `/v1/oauth/connections${q ? `?${q}` : ""}`);
|
|
303
475
|
},
|
|
476
|
+
/** Get one OAuth connection. */
|
|
477
|
+
getConnection: (connectionId) => this.request(
|
|
478
|
+
"GET",
|
|
479
|
+
`/v1/oauth/connections/${encodeURIComponent(connectionId)}`
|
|
480
|
+
),
|
|
481
|
+
/** Update connection metadata or its active status. */
|
|
482
|
+
updateConnection: (connectionId, params) => this.request(
|
|
483
|
+
"PUT",
|
|
484
|
+
`/v1/oauth/connections/${encodeURIComponent(connectionId)}`,
|
|
485
|
+
params
|
|
486
|
+
),
|
|
304
487
|
/**
|
|
305
488
|
* Start an OAuth connect flow. Returns the authorization URL the user
|
|
306
489
|
* must open in a browser to grant access.
|
|
307
490
|
*/
|
|
308
491
|
connect: (params) => this.request("POST", "/v1/oauth/connect", params),
|
|
309
492
|
/** Refresh a connection's access token now. */
|
|
310
|
-
refresh: (connectionId) => this.request(
|
|
493
|
+
refresh: (connectionId) => this.request(
|
|
494
|
+
"POST",
|
|
495
|
+
`/v1/oauth/connections/${encodeURIComponent(connectionId)}/refresh`
|
|
496
|
+
),
|
|
311
497
|
/** Check whether a connection's token is valid. */
|
|
312
|
-
test: (connectionId) => this.request(
|
|
498
|
+
test: (connectionId) => this.request(
|
|
499
|
+
"GET",
|
|
500
|
+
`/v1/oauth/connections/${encodeURIComponent(connectionId)}/test`
|
|
501
|
+
),
|
|
313
502
|
/** Revoke a connection and delete its tokens. */
|
|
314
|
-
revoke: (connectionId) => this.request(
|
|
503
|
+
revoke: (connectionId) => this.request(
|
|
504
|
+
"DELETE",
|
|
505
|
+
`/v1/oauth/connections/${encodeURIComponent(connectionId)}`
|
|
506
|
+
)
|
|
315
507
|
};
|
|
316
508
|
}
|
|
317
509
|
// ── Tool Keys ─────────────────────────────────────────────────────────────
|
|
318
510
|
get toolKeys() {
|
|
319
511
|
return {
|
|
320
|
-
list: (
|
|
321
|
-
const q = new URLSearchParams(filter).toString();
|
|
322
|
-
return this.request("GET", `/v1/tool-keys${q ? `?${q}` : ""}`);
|
|
323
|
-
},
|
|
512
|
+
list: () => this.request("GET", "/v1/tool-keys"),
|
|
324
513
|
create: (params) => this.request("POST", "/v1/tool-keys", params),
|
|
325
|
-
|
|
514
|
+
get: (keyId) => this.request(
|
|
515
|
+
"GET",
|
|
516
|
+
`/v1/tool-keys/${encodeURIComponent(keyId)}`
|
|
517
|
+
),
|
|
518
|
+
updateMetadata: (keyId, params) => this.request(
|
|
519
|
+
"PUT",
|
|
520
|
+
`/v1/tool-keys/${encodeURIComponent(keyId)}/metadata`,
|
|
521
|
+
params
|
|
522
|
+
),
|
|
523
|
+
updateValue: (keyId, value) => this.request(
|
|
524
|
+
"PUT",
|
|
525
|
+
`/v1/tool-keys/${encodeURIComponent(keyId)}/value`,
|
|
526
|
+
{ value }
|
|
527
|
+
),
|
|
528
|
+
test: (keyId) => this.request(
|
|
529
|
+
"POST",
|
|
530
|
+
`/v1/tool-keys/${encodeURIComponent(keyId)}/test`,
|
|
531
|
+
{}
|
|
532
|
+
),
|
|
533
|
+
mapToTool: (params) => this.request("POST", "/v1/tool-keys/map", params),
|
|
534
|
+
removeMapping: (mappingId) => this.request(
|
|
535
|
+
"DELETE",
|
|
536
|
+
`/v1/tool-keys/map/${encodeURIComponent(mappingId)}`
|
|
537
|
+
),
|
|
538
|
+
delete: (keyId) => this.request(
|
|
539
|
+
"DELETE",
|
|
540
|
+
`/v1/tool-keys/${encodeURIComponent(keyId)}`
|
|
541
|
+
)
|
|
326
542
|
};
|
|
327
543
|
}
|
|
328
544
|
// ── Tool Permissions ──────────────────────────────────────────────────────
|
|
329
545
|
get toolPermissions() {
|
|
330
546
|
return {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
547
|
+
/** @deprecated Use listForTool with a tool ID. */
|
|
548
|
+
list: (toolId) => this.request(
|
|
549
|
+
"GET",
|
|
550
|
+
`/v1/tool-permissions/tool/${encodeURIComponent(toolId)}`
|
|
551
|
+
),
|
|
552
|
+
listForTool: (toolId) => this.request(
|
|
553
|
+
"GET",
|
|
554
|
+
`/v1/tool-permissions/tool/${encodeURIComponent(toolId)}`
|
|
555
|
+
),
|
|
556
|
+
listForSubject: (subjectId, subjectType) => {
|
|
557
|
+
const query = new URLSearchParams({ subjectId, subjectType });
|
|
558
|
+
return this.request(
|
|
559
|
+
"GET",
|
|
560
|
+
`/v1/tool-permissions/subject?${query}`
|
|
561
|
+
);
|
|
562
|
+
},
|
|
563
|
+
accessibleTools: (subjectId, subjectType) => {
|
|
564
|
+
const query = new URLSearchParams({ subjectId, subjectType });
|
|
565
|
+
return this.request(
|
|
566
|
+
"GET",
|
|
567
|
+
`/v1/tool-permissions/accessible-tools?${query}`
|
|
568
|
+
);
|
|
334
569
|
},
|
|
335
570
|
grant: (params) => this.request("POST", "/v1/tool-permissions/grant", params),
|
|
336
|
-
|
|
571
|
+
batchGrant: (params) => this.request("POST", "/v1/tool-permissions/batch-grant", params),
|
|
572
|
+
revoke: (permissionId) => this.request(
|
|
573
|
+
"DELETE",
|
|
574
|
+
`/v1/tool-permissions/${encodeURIComponent(permissionId)}`
|
|
575
|
+
),
|
|
576
|
+
check: (params) => this.request(
|
|
577
|
+
"GET",
|
|
578
|
+
`/v1/tool-permissions/check?${new URLSearchParams(params)}`
|
|
579
|
+
),
|
|
580
|
+
checkAgentAccess: (toolId, agentId, userId) => {
|
|
581
|
+
const query = new URLSearchParams({ toolId, agentId });
|
|
582
|
+
if (userId) query.set("userId", userId);
|
|
583
|
+
return this.request(
|
|
584
|
+
"GET",
|
|
585
|
+
`/v1/tool-permissions/check-agent-access?${query}`
|
|
586
|
+
);
|
|
587
|
+
},
|
|
588
|
+
transferOwnership: (params) => this.request(
|
|
589
|
+
"POST",
|
|
590
|
+
"/v1/tool-permissions/transfer-ownership",
|
|
591
|
+
params
|
|
592
|
+
)
|
|
337
593
|
};
|
|
338
594
|
}
|
|
339
595
|
// ── Skills ────────────────────────────────────────────────────────────────
|
|
@@ -348,14 +604,71 @@ var CommonsClient = class {
|
|
|
348
604
|
const qs = params.toString();
|
|
349
605
|
return this.request("GET", `/v1/skills${qs ? `?${qs}` : ""}`);
|
|
350
606
|
},
|
|
351
|
-
get: (skillIdOrSlug) => this.request("GET", `/v1/skills/${skillIdOrSlug}`),
|
|
607
|
+
get: (skillIdOrSlug) => this.request("GET", `/v1/skills/${encodeURIComponent(skillIdOrSlug)}`),
|
|
352
608
|
getIndex: (ownerId) => {
|
|
353
609
|
const qs = ownerId ? `?ownerId=${ownerId}` : "";
|
|
354
610
|
return this.request("GET", `/v1/skills/index${qs}`);
|
|
355
611
|
},
|
|
612
|
+
listForAgent: (agentId) => this.request("GET", `/v1/skills/agents/${encodeURIComponent(agentId)}`),
|
|
613
|
+
setAgentAvailability: (skillIdOrSlug, agentId, isEnabled) => this.request(
|
|
614
|
+
"PUT",
|
|
615
|
+
`/v1/skills/${encodeURIComponent(skillIdOrSlug)}/agents/${encodeURIComponent(agentId)}`,
|
|
616
|
+
{ isEnabled }
|
|
617
|
+
),
|
|
356
618
|
create: (params) => this.request("POST", "/v1/skills", params),
|
|
357
|
-
update: (skillIdOrSlug, updates) => this.request(
|
|
358
|
-
|
|
619
|
+
update: (skillIdOrSlug, updates) => this.request(
|
|
620
|
+
"PUT",
|
|
621
|
+
`/v1/skills/${encodeURIComponent(skillIdOrSlug)}`,
|
|
622
|
+
updates
|
|
623
|
+
),
|
|
624
|
+
delete: (skillIdOrSlug) => this.request(
|
|
625
|
+
"DELETE",
|
|
626
|
+
`/v1/skills/${encodeURIComponent(skillIdOrSlug)}`
|
|
627
|
+
),
|
|
628
|
+
import: (file, options) => {
|
|
629
|
+
const body = new FormData();
|
|
630
|
+
body.append("file", file, options?.fileName || "SKILL.md");
|
|
631
|
+
if (options?.agentId) body.set("agentId", options.agentId);
|
|
632
|
+
return this.request("POST", "/v1/skills/import", body);
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
// ── Capability providers ─────────────────────────────────────────────────
|
|
637
|
+
get providers() {
|
|
638
|
+
return {
|
|
639
|
+
list: () => this.request("GET", "/v1/providers"),
|
|
640
|
+
configure: (capability, input) => this.request(
|
|
641
|
+
"PUT",
|
|
642
|
+
`/v1/providers/${encodeURIComponent(capability)}`,
|
|
643
|
+
input
|
|
644
|
+
),
|
|
645
|
+
remove: (capability) => this.request(
|
|
646
|
+
"DELETE",
|
|
647
|
+
`/v1/providers/${encodeURIComponent(capability)}`
|
|
648
|
+
)
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
// ── Sandboxed UI plugins ─────────────────────────────────────────────────
|
|
652
|
+
get uiPlugins() {
|
|
653
|
+
return {
|
|
654
|
+
list: (activeOnly = false) => this.request(
|
|
655
|
+
"GET",
|
|
656
|
+
`/v1/ui-plugins${activeOnly ? "?active=true" : ""}`
|
|
657
|
+
),
|
|
658
|
+
getBySlug: (slug) => this.request(
|
|
659
|
+
"GET",
|
|
660
|
+
`/v1/ui-plugins/slug/${encodeURIComponent(slug)}`
|
|
661
|
+
),
|
|
662
|
+
create: (input) => this.request("PUT", "/v1/ui-plugins", input),
|
|
663
|
+
setStatus: (pluginId, status) => this.request(
|
|
664
|
+
"PUT",
|
|
665
|
+
`/v1/ui-plugins/${encodeURIComponent(pluginId)}/status`,
|
|
666
|
+
{ status }
|
|
667
|
+
),
|
|
668
|
+
delete: (pluginId) => this.request(
|
|
669
|
+
"DELETE",
|
|
670
|
+
`/v1/ui-plugins/${encodeURIComponent(pluginId)}`
|
|
671
|
+
)
|
|
359
672
|
};
|
|
360
673
|
}
|
|
361
674
|
// ── Wallets ───────────────────────────────────────────────────────────────
|
|
@@ -396,7 +709,34 @@ var CommonsClient = class {
|
|
|
396
709
|
me: () => this.request("GET", "/v1/auth/me")
|
|
397
710
|
};
|
|
398
711
|
}
|
|
399
|
-
// ── API
|
|
712
|
+
// ── Developer projects and project API keys ──────────────────────────────
|
|
713
|
+
get developer() {
|
|
714
|
+
return {
|
|
715
|
+
scopes: () => this.identityRequest("GET", "/api/platform/scopes"),
|
|
716
|
+
listProjects: () => this.identityRequest("GET", "/api/platform/projects"),
|
|
717
|
+
createProject: (params) => this.identityRequest("POST", "/api/platform/projects", params),
|
|
718
|
+
listApiKeys: (projectId) => this.identityRequest(
|
|
719
|
+
"GET",
|
|
720
|
+
`/api/platform/projects/${encodeURIComponent(projectId)}/api-keys`
|
|
721
|
+
),
|
|
722
|
+
createApiKey: (projectId, params) => this.identityRequest(
|
|
723
|
+
"POST",
|
|
724
|
+
`/api/platform/projects/${encodeURIComponent(projectId)}/api-keys`,
|
|
725
|
+
params
|
|
726
|
+
),
|
|
727
|
+
revokeApiKey: (keyId) => this.identityRequest(
|
|
728
|
+
"DELETE",
|
|
729
|
+
`/api/platform/api-keys/${encodeURIComponent(keyId)}`
|
|
730
|
+
)
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
// ── Legacy principal API keys ─────────────────────────────────────────────
|
|
734
|
+
/**
|
|
735
|
+
* Legacy per-principal keys (`sk-ac-*`).
|
|
736
|
+
*
|
|
737
|
+
* New developer integrations should use `client.developer`, which creates
|
|
738
|
+
* project-scoped `csk_*` keys with explicit environments and scopes.
|
|
739
|
+
*/
|
|
400
740
|
get apiKeys() {
|
|
401
741
|
return {
|
|
402
742
|
/**
|
|
@@ -614,6 +954,332 @@ var CommonsClient = class {
|
|
|
614
954
|
getSessionUsage: (sessionId) => this.request("GET", `/v1/usage/sessions/${sessionId}`)
|
|
615
955
|
};
|
|
616
956
|
}
|
|
957
|
+
// ── Activity and logs ────────────────────────────────────────────────────
|
|
958
|
+
get activity() {
|
|
959
|
+
return {
|
|
960
|
+
list: (filter) => {
|
|
961
|
+
const query = new URLSearchParams();
|
|
962
|
+
if (filter?.actorId) query.set("actorId", filter.actorId);
|
|
963
|
+
if (filter?.eventType) query.set("eventType", filter.eventType);
|
|
964
|
+
if (filter?.since) query.set("since", filter.since);
|
|
965
|
+
if (filter?.limit) query.set("limit", String(filter.limit));
|
|
966
|
+
return this.request(
|
|
967
|
+
"GET",
|
|
968
|
+
`/v1/activity/events${query.size ? `?${query}` : ""}`
|
|
969
|
+
);
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
get logs() {
|
|
974
|
+
return {
|
|
975
|
+
list: (agentId, filter) => {
|
|
976
|
+
const query = new URLSearchParams();
|
|
977
|
+
if (filter?.sessionId) query.set("sessionId", filter.sessionId);
|
|
978
|
+
if (filter?.limit) query.set("limit", String(filter.limit));
|
|
979
|
+
return this.request(
|
|
980
|
+
"GET",
|
|
981
|
+
`/v1/logs/agents/${encodeURIComponent(agentId)}${query.size ? `?${query}` : ""}`
|
|
982
|
+
);
|
|
983
|
+
},
|
|
984
|
+
observability: (agentId, filter) => {
|
|
985
|
+
const query = new URLSearchParams();
|
|
986
|
+
if (filter?.from) query.set("from", filter.from);
|
|
987
|
+
if (filter?.to) query.set("to", filter.to);
|
|
988
|
+
if (filter?.limit) query.set("limit", String(filter.limit));
|
|
989
|
+
return this.request(
|
|
990
|
+
"GET",
|
|
991
|
+
`/v1/logs/agents/${encodeURIComponent(agentId)}/observability${query.size ? `?${query}` : ""}`
|
|
992
|
+
);
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
// ── Files and library ────────────────────────────────────────────────────
|
|
997
|
+
get files() {
|
|
998
|
+
return {
|
|
999
|
+
upload: (files, params) => {
|
|
1000
|
+
const body = new FormData();
|
|
1001
|
+
for (const file of files) {
|
|
1002
|
+
body.append("files", file.data, file.name);
|
|
1003
|
+
}
|
|
1004
|
+
if (params?.agentId) body.set("agentId", params.agentId);
|
|
1005
|
+
if (params?.sessionId) body.set("sessionId", params.sessionId);
|
|
1006
|
+
if (params?.workspaceId) body.set("workspaceId", params.workspaceId);
|
|
1007
|
+
if (params?.storageProvider)
|
|
1008
|
+
body.set("storageProvider", params.storageProvider);
|
|
1009
|
+
return this.request("POST", "/v1/files/upload", body);
|
|
1010
|
+
},
|
|
1011
|
+
get: (fileId, context) => {
|
|
1012
|
+
const query = new URLSearchParams();
|
|
1013
|
+
if (context?.agentId) query.set("agentId", context.agentId);
|
|
1014
|
+
if (context?.sessionId) query.set("sessionId", context.sessionId);
|
|
1015
|
+
return this.request(
|
|
1016
|
+
"GET",
|
|
1017
|
+
`/v1/files/${encodeURIComponent(fileId)}${query.size ? `?${query}` : ""}`
|
|
1018
|
+
);
|
|
1019
|
+
},
|
|
1020
|
+
content: (fileId, options) => {
|
|
1021
|
+
const query = new URLSearchParams();
|
|
1022
|
+
if (options?.agentId) query.set("agentId", options.agentId);
|
|
1023
|
+
if (options?.sessionId) query.set("sessionId", options.sessionId);
|
|
1024
|
+
if (options?.offset !== void 0)
|
|
1025
|
+
query.set("offset", String(options.offset));
|
|
1026
|
+
if (options?.maxChars !== void 0)
|
|
1027
|
+
query.set("maxChars", String(options.maxChars));
|
|
1028
|
+
if (options?.includeImageUrls !== void 0)
|
|
1029
|
+
query.set("includeImageUrls", String(options.includeImageUrls));
|
|
1030
|
+
if (options?.includeDownloadUrl !== void 0)
|
|
1031
|
+
query.set("includeDownloadUrl", String(options.includeDownloadUrl));
|
|
1032
|
+
return this.request(
|
|
1033
|
+
"GET",
|
|
1034
|
+
`/v1/files/${encodeURIComponent(fileId)}/content${query.size ? `?${query}` : ""}`
|
|
1035
|
+
);
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
get library() {
|
|
1040
|
+
return {
|
|
1041
|
+
list: (filter) => {
|
|
1042
|
+
const query = new URLSearchParams();
|
|
1043
|
+
if (filter?.query) query.set("query", filter.query);
|
|
1044
|
+
if (filter?.view) query.set("view", filter.view);
|
|
1045
|
+
if (filter?.source) query.set("source", filter.source);
|
|
1046
|
+
if (filter?.favorite !== void 0)
|
|
1047
|
+
query.set("favorite", String(filter.favorite));
|
|
1048
|
+
if (filter?.sessionId) query.set("sessionId", filter.sessionId);
|
|
1049
|
+
if (filter?.agentId) query.set("agentId", filter.agentId);
|
|
1050
|
+
if (filter?.limit !== void 0)
|
|
1051
|
+
query.set("limit", String(filter.limit));
|
|
1052
|
+
if (filter?.offset !== void 0)
|
|
1053
|
+
query.set("offset", String(filter.offset));
|
|
1054
|
+
return this.request(
|
|
1055
|
+
"GET",
|
|
1056
|
+
`/v1/library${query.size ? `?${query}` : ""}`
|
|
1057
|
+
);
|
|
1058
|
+
},
|
|
1059
|
+
get: (itemId) => this.request(
|
|
1060
|
+
"GET",
|
|
1061
|
+
`/v1/library/${encodeURIComponent(itemId)}`
|
|
1062
|
+
),
|
|
1063
|
+
download: (itemId) => this.request(
|
|
1064
|
+
"GET",
|
|
1065
|
+
`/v1/library/${encodeURIComponent(itemId)}/download`
|
|
1066
|
+
),
|
|
1067
|
+
preview: (itemId) => this.request(
|
|
1068
|
+
"GET",
|
|
1069
|
+
`/v1/library/${encodeURIComponent(itemId)}/preview`
|
|
1070
|
+
),
|
|
1071
|
+
update: (itemId, params) => this.request(
|
|
1072
|
+
"PATCH",
|
|
1073
|
+
`/v1/library/${encodeURIComponent(itemId)}`,
|
|
1074
|
+
params
|
|
1075
|
+
),
|
|
1076
|
+
delete: (itemId) => this.request(
|
|
1077
|
+
"DELETE",
|
|
1078
|
+
`/v1/library/${encodeURIComponent(itemId)}`
|
|
1079
|
+
),
|
|
1080
|
+
storagePreference: () => this.request("GET", "/v1/library/preferences/storage"),
|
|
1081
|
+
setStoragePreference: (defaultStorageProvider) => this.request("PATCH", "/v1/library/preferences/storage", {
|
|
1082
|
+
defaultStorageProvider
|
|
1083
|
+
}),
|
|
1084
|
+
grant: (itemId, params) => this.request(
|
|
1085
|
+
"POST",
|
|
1086
|
+
`/v1/library/${encodeURIComponent(itemId)}/grants`,
|
|
1087
|
+
params
|
|
1088
|
+
),
|
|
1089
|
+
revokeGrant: (itemId, grantId) => this.request(
|
|
1090
|
+
"DELETE",
|
|
1091
|
+
`/v1/library/${encodeURIComponent(itemId)}/grants/${encodeURIComponent(grantId)}`
|
|
1092
|
+
),
|
|
1093
|
+
createShareLink: (itemId, expiresAt) => this.request(
|
|
1094
|
+
"POST",
|
|
1095
|
+
`/v1/library/${encodeURIComponent(itemId)}/share-links`,
|
|
1096
|
+
{ expiresAt }
|
|
1097
|
+
),
|
|
1098
|
+
revokeShareLink: (itemId, shareId) => this.request(
|
|
1099
|
+
"DELETE",
|
|
1100
|
+
`/v1/library/${encodeURIComponent(itemId)}/share-links/${encodeURIComponent(shareId)}`
|
|
1101
|
+
),
|
|
1102
|
+
resolveShare: (token) => this.request(
|
|
1103
|
+
"GET",
|
|
1104
|
+
`/v1/shared/artifacts/${encodeURIComponent(token)}`
|
|
1105
|
+
)
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
// ── Spaces, projects, and goals ──────────────────────────────────────────
|
|
1109
|
+
get spaces() {
|
|
1110
|
+
return {
|
|
1111
|
+
list: (filter) => {
|
|
1112
|
+
const query = new URLSearchParams();
|
|
1113
|
+
if (filter?.memberId) query.set("memberId", filter.memberId);
|
|
1114
|
+
if (filter?.memberType) query.set("memberType", filter.memberType);
|
|
1115
|
+
if (filter?.agentIds?.length)
|
|
1116
|
+
query.set("agentIds", filter.agentIds.join(","));
|
|
1117
|
+
if (filter?.publicOnly !== void 0)
|
|
1118
|
+
query.set("publicOnly", String(filter.publicOnly));
|
|
1119
|
+
if (filter?.search) query.set("search", filter.search);
|
|
1120
|
+
if (filter?.includeMembers !== void 0)
|
|
1121
|
+
query.set("includeMembers", String(filter.includeMembers));
|
|
1122
|
+
if (filter?.limit !== void 0)
|
|
1123
|
+
query.set("limit", String(filter.limit));
|
|
1124
|
+
if (filter?.offset !== void 0)
|
|
1125
|
+
query.set("offset", String(filter.offset));
|
|
1126
|
+
return this.request(
|
|
1127
|
+
"GET",
|
|
1128
|
+
`/v1/spaces${query.size ? `?${query}` : ""}`
|
|
1129
|
+
);
|
|
1130
|
+
},
|
|
1131
|
+
create: (params, creator) => this.request("POST", "/v1/spaces", params, {
|
|
1132
|
+
headers: {
|
|
1133
|
+
"x-creator-id": creator.id,
|
|
1134
|
+
"x-creator-type": creator.type
|
|
1135
|
+
}
|
|
1136
|
+
}),
|
|
1137
|
+
get: (spaceId) => this.request(
|
|
1138
|
+
"GET",
|
|
1139
|
+
`/v1/spaces/${encodeURIComponent(spaceId)}`
|
|
1140
|
+
),
|
|
1141
|
+
getFull: (spaceId) => this.request(
|
|
1142
|
+
"GET",
|
|
1143
|
+
`/v1/spaces/${encodeURIComponent(spaceId)}/full`
|
|
1144
|
+
),
|
|
1145
|
+
update: (spaceId, params) => this.request(
|
|
1146
|
+
"PUT",
|
|
1147
|
+
`/v1/spaces/${encodeURIComponent(spaceId)}`,
|
|
1148
|
+
params
|
|
1149
|
+
),
|
|
1150
|
+
delete: (spaceId) => this.request(
|
|
1151
|
+
"DELETE",
|
|
1152
|
+
`/v1/spaces/${encodeURIComponent(spaceId)}`
|
|
1153
|
+
),
|
|
1154
|
+
issueRtcTicket: (spaceId) => this.request(
|
|
1155
|
+
"POST",
|
|
1156
|
+
`/v1/spaces/${encodeURIComponent(spaceId)}/rtc-ticket`,
|
|
1157
|
+
{}
|
|
1158
|
+
),
|
|
1159
|
+
listMembers: (spaceId) => this.request(
|
|
1160
|
+
"GET",
|
|
1161
|
+
`/v1/spaces/${encodeURIComponent(spaceId)}/members`
|
|
1162
|
+
),
|
|
1163
|
+
addMember: (spaceId, params) => this.request(
|
|
1164
|
+
"POST",
|
|
1165
|
+
`/v1/spaces/${encodeURIComponent(spaceId)}/members`,
|
|
1166
|
+
params
|
|
1167
|
+
),
|
|
1168
|
+
updateMember: (spaceId, memberId, memberType, params) => this.request(
|
|
1169
|
+
"PUT",
|
|
1170
|
+
`/v1/spaces/${encodeURIComponent(spaceId)}/members/${encodeURIComponent(memberId)}?memberType=${memberType}`,
|
|
1171
|
+
params
|
|
1172
|
+
),
|
|
1173
|
+
removeMember: (spaceId, memberId, memberType) => this.request(
|
|
1174
|
+
"DELETE",
|
|
1175
|
+
`/v1/spaces/${encodeURIComponent(spaceId)}/members/${encodeURIComponent(memberId)}?memberType=${memberType}`
|
|
1176
|
+
),
|
|
1177
|
+
listMessages: (spaceId, filter) => {
|
|
1178
|
+
const query = new URLSearchParams();
|
|
1179
|
+
if (filter?.limit !== void 0)
|
|
1180
|
+
query.set("limit", String(filter.limit));
|
|
1181
|
+
if (filter?.offset !== void 0)
|
|
1182
|
+
query.set("offset", String(filter.offset));
|
|
1183
|
+
if (filter?.memberId) query.set("memberId", filter.memberId);
|
|
1184
|
+
return this.request(
|
|
1185
|
+
"GET",
|
|
1186
|
+
`/v1/spaces/${encodeURIComponent(spaceId)}/messages${query.size ? `?${query}` : ""}`
|
|
1187
|
+
);
|
|
1188
|
+
},
|
|
1189
|
+
sendMessage: (spaceId, params, sender) => this.request(
|
|
1190
|
+
"POST",
|
|
1191
|
+
`/v1/spaces/${encodeURIComponent(spaceId)}/messages`,
|
|
1192
|
+
params,
|
|
1193
|
+
{
|
|
1194
|
+
headers: {
|
|
1195
|
+
"x-sender-id": sender.id,
|
|
1196
|
+
"x-sender-type": sender.type
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
),
|
|
1200
|
+
updateMessage: (spaceId, messageId, params) => this.request(
|
|
1201
|
+
"PUT",
|
|
1202
|
+
`/v1/spaces/${encodeURIComponent(spaceId)}/messages/${encodeURIComponent(messageId)}`,
|
|
1203
|
+
params
|
|
1204
|
+
),
|
|
1205
|
+
deleteMessage: (spaceId, messageId) => this.request(
|
|
1206
|
+
"DELETE",
|
|
1207
|
+
`/v1/spaces/${encodeURIComponent(spaceId)}/messages/${encodeURIComponent(messageId)}`
|
|
1208
|
+
)
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
get projects() {
|
|
1212
|
+
const base = (agentId) => `/v1/agents/${encodeURIComponent(agentId)}/projects`;
|
|
1213
|
+
return {
|
|
1214
|
+
list: (agentId) => this.request("GET", base(agentId)),
|
|
1215
|
+
create: (agentId, params) => this.request("POST", base(agentId), params),
|
|
1216
|
+
get: (agentId, projectId) => this.request(
|
|
1217
|
+
"GET",
|
|
1218
|
+
`${base(agentId)}/${encodeURIComponent(projectId)}`
|
|
1219
|
+
),
|
|
1220
|
+
writeFiles: (agentId, projectId, files, replace = false) => this.request(
|
|
1221
|
+
"PUT",
|
|
1222
|
+
`${base(agentId)}/${encodeURIComponent(projectId)}/files`,
|
|
1223
|
+
{ files, replace }
|
|
1224
|
+
),
|
|
1225
|
+
publish: (agentId, projectId) => this.request(
|
|
1226
|
+
"POST",
|
|
1227
|
+
`${base(agentId)}/${encodeURIComponent(projectId)}/publish`,
|
|
1228
|
+
{}
|
|
1229
|
+
),
|
|
1230
|
+
verify: (agentId, projectId, actions) => this.request(
|
|
1231
|
+
"POST",
|
|
1232
|
+
`${base(agentId)}/${encodeURIComponent(projectId)}/verify`,
|
|
1233
|
+
{ actions }
|
|
1234
|
+
),
|
|
1235
|
+
exportToComputer: (agentId, projectId, params) => this.request(
|
|
1236
|
+
"POST",
|
|
1237
|
+
`${base(agentId)}/${encodeURIComponent(projectId)}/export`,
|
|
1238
|
+
params ?? {}
|
|
1239
|
+
),
|
|
1240
|
+
exportToGitHub: (agentId, projectId, params) => this.request(
|
|
1241
|
+
"POST",
|
|
1242
|
+
`${base(agentId)}/${encodeURIComponent(projectId)}/github`,
|
|
1243
|
+
params ?? {}
|
|
1244
|
+
)
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
get goals() {
|
|
1248
|
+
return {
|
|
1249
|
+
create: (params) => this.request("POST", "/v1/goals", params),
|
|
1250
|
+
get: (goalId) => this.request("GET", `/v1/goals/${encodeURIComponent(goalId)}`),
|
|
1251
|
+
updateProgress: (goalId, progress, status) => this.request(
|
|
1252
|
+
"PUT",
|
|
1253
|
+
`/v1/goals/${encodeURIComponent(goalId)}`,
|
|
1254
|
+
{ progress, status }
|
|
1255
|
+
)
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
// ── Audio and liaison agents ─────────────────────────────────────────────
|
|
1259
|
+
get audio() {
|
|
1260
|
+
return {
|
|
1261
|
+
transcribe: (file, options) => {
|
|
1262
|
+
const body = new FormData();
|
|
1263
|
+
body.append("file", file.data, file.name);
|
|
1264
|
+
if (options?.durationMs !== void 0)
|
|
1265
|
+
body.set("durationMs", String(options.durationMs));
|
|
1266
|
+
return this.request("POST", "/v1/audio/transcriptions", body, {
|
|
1267
|
+
headers: options?.idempotencyKey ? { "x-idempotency-key": options.idempotencyKey } : void 0
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
get liaisons() {
|
|
1273
|
+
return {
|
|
1274
|
+
create: (params) => this.request("POST", "/v1/liaison", params),
|
|
1275
|
+
interact: (liaisonAgentId, liaisonKey, message) => this.request(
|
|
1276
|
+
"POST",
|
|
1277
|
+
"/v1/liaison/interact",
|
|
1278
|
+
{ liaisonAgentId, message },
|
|
1279
|
+
{ headers: { "x-api-key": liaisonKey } }
|
|
1280
|
+
)
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
617
1283
|
// ── Credits ──────────────────────────────────────────────────────────────
|
|
618
1284
|
get credits() {
|
|
619
1285
|
return {
|
|
@@ -632,10 +1298,45 @@ var CommonsClient = class {
|
|
|
632
1298
|
const qs = params.toString();
|
|
633
1299
|
return this.request("GET", `/v1/credits/ledger${qs ? `?${qs}` : ""}`);
|
|
634
1300
|
},
|
|
1301
|
+
summary: () => this.request("GET", "/v1/credits/summary"),
|
|
1302
|
+
campaigns: () => this.request("GET", "/v1/credits/campaigns"),
|
|
1303
|
+
claimCampaign: (params) => this.request("POST", "/v1/credits/campaigns/claim", params),
|
|
1304
|
+
transfers: () => this.request("GET", "/v1/credits/transfers"),
|
|
1305
|
+
gift: (params) => this.request("POST", "/v1/credits/gifts", params),
|
|
635
1306
|
grant: (params) => this.request("POST", "/v1/credits/grants", params),
|
|
636
1307
|
debit: (params) => this.request("POST", "/v1/credits/debits", params)
|
|
637
1308
|
};
|
|
638
1309
|
}
|
|
1310
|
+
// ── Billing ────────────────────────────────────────────────────────────────
|
|
1311
|
+
get billing() {
|
|
1312
|
+
return {
|
|
1313
|
+
/** Public product catalog served from the backend source of truth. */
|
|
1314
|
+
catalog: () => this.request("GET", "/v1/billing/catalog"),
|
|
1315
|
+
/** Current plan, status, and entitlements for the caller. */
|
|
1316
|
+
subscription: () => this.request("GET", "/v1/billing/subscription"),
|
|
1317
|
+
/** Entitlements only (what paid features the caller may use). */
|
|
1318
|
+
entitlements: () => this.request("GET", "/v1/billing/entitlements"),
|
|
1319
|
+
/** Stripe invoice history for the caller. */
|
|
1320
|
+
invoices: () => this.request("GET", "/v1/billing/invoices"),
|
|
1321
|
+
/** Saved Stripe payment methods for the caller. */
|
|
1322
|
+
paymentMethods: () => this.request("GET", "/v1/billing/payment-methods"),
|
|
1323
|
+
/** Create a Stripe Checkout session for a subscription plan. */
|
|
1324
|
+
subscribe: (planKey) => this.request("POST", "/v1/billing/checkout/subscription", { planKey }),
|
|
1325
|
+
/** Create a Stripe Checkout session for a one-time credit top-up. */
|
|
1326
|
+
topup: (packKey) => this.request("POST", "/v1/billing/checkout/topup", { packKey }),
|
|
1327
|
+
/** Open the Stripe billing portal. */
|
|
1328
|
+
portal: () => this.request("POST", "/v1/billing/portal", {})
|
|
1329
|
+
};
|
|
1330
|
+
}
|
|
1331
|
+
// ── Feature flags ────────────────────────────────────────────────────────
|
|
1332
|
+
get flags() {
|
|
1333
|
+
return {
|
|
1334
|
+
/** Evaluate all active flags for the caller (call once at boot). */
|
|
1335
|
+
all: () => this.request("GET", "/v1/flags"),
|
|
1336
|
+
/** Evaluate a single flag for the caller. */
|
|
1337
|
+
evaluate: (key) => this.request("GET", `/v1/flags/${encodeURIComponent(key)}`)
|
|
1338
|
+
};
|
|
1339
|
+
}
|
|
639
1340
|
};
|
|
640
1341
|
var CommonsError = class extends Error {
|
|
641
1342
|
constructor(message, status, data) {
|