@tencent-ai/cloud-agent-sdk 0.3.7 → 0.3.8
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.cjs +94 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +164 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +164 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +94 -9
- package/dist/index.mjs.map +1 -1
- package/dist/tencent-ai-cloud-agent-sdk-0.3.8.tgz +0 -0
- package/package.json +4 -4
- package/dist/tencent-ai-cloud-agent-sdk-0.3.7.tgz +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,51 @@
|
|
|
1
1
|
|
|
2
|
+
//#region src/v1/agent.ts
|
|
3
|
+
var Agent = class {
|
|
4
|
+
/** @internal */
|
|
5
|
+
constructor(restClient, info) {
|
|
6
|
+
this.versions = {
|
|
7
|
+
list: async (opts) => {
|
|
8
|
+
const params = {};
|
|
9
|
+
if (opts?.page !== void 0) params.page = String(opts.page);
|
|
10
|
+
if (opts?.pageSize !== void 0) params.pageSize = String(opts.pageSize);
|
|
11
|
+
return this._restClient.get(`/agents/${this.id}/versions`, params, opts);
|
|
12
|
+
},
|
|
13
|
+
get: async (versionId, opts) => this._restClient.get(`/agents/${this.id}/versions/${versionId}`, void 0, opts),
|
|
14
|
+
publish: async (req, opts) => this._restClient.post(`/agents/${this.id}/versions`, req, opts),
|
|
15
|
+
delete: async (versionId, opts) => {
|
|
16
|
+
await this._restClient.delete(`/agents/${this.id}/versions/${versionId}`, opts);
|
|
17
|
+
},
|
|
18
|
+
setCurrent: async (versionId, opts) => {
|
|
19
|
+
await this._restClient.put(`/agents/${this.id}/versions/current`, { versionId }, opts);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
this.draft = {
|
|
23
|
+
save: async (req, opts) => this._restClient.put(`/agents/${this.id}/draft`, req, opts),
|
|
24
|
+
get: async (opts) => this._restClient.get(`/agents/${this.id}/draft`, void 0, opts),
|
|
25
|
+
publish: async (description, opts) => this._restClient.post(`/agents/${this.id}/draft/publish`, { description }, opts)
|
|
26
|
+
};
|
|
27
|
+
this.id = info.id;
|
|
28
|
+
this._info = info;
|
|
29
|
+
this._restClient = restClient;
|
|
30
|
+
}
|
|
31
|
+
get agentInfo() {
|
|
32
|
+
return this._info;
|
|
33
|
+
}
|
|
34
|
+
get agentName() {
|
|
35
|
+
return this._info.agentName;
|
|
36
|
+
}
|
|
37
|
+
get description() {
|
|
38
|
+
return this._info.description;
|
|
39
|
+
}
|
|
40
|
+
get model() {
|
|
41
|
+
return this._info.model;
|
|
42
|
+
}
|
|
43
|
+
get enabled() {
|
|
44
|
+
return this._info.enabled;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
2
49
|
//#region src/v1/internal/log.ts
|
|
3
50
|
/** 级别数值:越大越详细;方法级别 > 当前级别时,该方法变成 noop。 */
|
|
4
51
|
const LEVEL_NUMBER = {
|
|
@@ -271,6 +318,11 @@ var RestClient = class {
|
|
|
271
318
|
const url = this.buildUrl(path);
|
|
272
319
|
return this.request("POST", url, body, opts);
|
|
273
320
|
}
|
|
321
|
+
/** PUT 请求。 */
|
|
322
|
+
async put(path, body, opts) {
|
|
323
|
+
const url = this.buildUrl(path);
|
|
324
|
+
return this.request("PUT", url, body, opts);
|
|
325
|
+
}
|
|
274
326
|
/** PATCH 请求。 */
|
|
275
327
|
async patch(path, body, opts) {
|
|
276
328
|
const url = this.buildUrl(path);
|
|
@@ -963,6 +1015,9 @@ const KNOWN_EXTENSIONS = [
|
|
|
963
1015
|
//#endregion
|
|
964
1016
|
//#region src/v1/acp/vendor/constants.ts
|
|
965
1017
|
/**
|
|
1018
|
+
* Protocol constants for Streamable HTTP ACP Client
|
|
1019
|
+
*/
|
|
1020
|
+
/**
|
|
966
1021
|
* Default timeout for initialize operation
|
|
967
1022
|
*/
|
|
968
1023
|
const DEFAULT_INITIALIZE_TIMEOUT = 3e4;
|
|
@@ -1868,7 +1923,7 @@ var StreamableHttpClient = class {
|
|
|
1868
1923
|
async setSessionModel(params) {
|
|
1869
1924
|
this.ensureInitialized("setSessionModel");
|
|
1870
1925
|
this.options.logger?.debug(`Setting session model: ${params.sessionId} -> ${params.modelId}`);
|
|
1871
|
-
return this.connection.
|
|
1926
|
+
return await this.connection.extMethod("session/set_model", params);
|
|
1872
1927
|
}
|
|
1873
1928
|
/**
|
|
1874
1929
|
* Send a prompt to the agent
|
|
@@ -2596,17 +2651,27 @@ var Runtime = class {
|
|
|
2596
2651
|
constructor(restClient, connectionOpts, info) {
|
|
2597
2652
|
this.sessions = {
|
|
2598
2653
|
create: async (opts) => {
|
|
2599
|
-
const
|
|
2600
|
-
sessionId: opts.sessionId,
|
|
2601
|
-
sessionName: opts.sessionName,
|
|
2602
|
-
agentManifest: opts.agentManifest
|
|
2603
|
-
};
|
|
2604
|
-
return new Session((await this._restClient.post(`/runtimes/${this.id}/sessions`, body, {
|
|
2654
|
+
const reqOpts = {
|
|
2605
2655
|
timeoutMs: opts.timeoutMs,
|
|
2606
2656
|
headers: opts.headers,
|
|
2607
2657
|
signal: opts.signal,
|
|
2608
2658
|
requestId: opts.requestId
|
|
2609
|
-
}
|
|
2659
|
+
};
|
|
2660
|
+
let info;
|
|
2661
|
+
if (opts.agentId) info = await this._restClient.post("/agents/sessions", {
|
|
2662
|
+
agentId: opts.agentId,
|
|
2663
|
+
runtimeId: this.id,
|
|
2664
|
+
sessionName: opts.sessionName
|
|
2665
|
+
}, reqOpts);
|
|
2666
|
+
else {
|
|
2667
|
+
const body = {
|
|
2668
|
+
sessionId: opts.sessionId,
|
|
2669
|
+
sessionName: opts.sessionName,
|
|
2670
|
+
agentManifest: opts.agentManifest
|
|
2671
|
+
};
|
|
2672
|
+
info = await this._restClient.post(`/runtimes/${this.id}/sessions`, body, reqOpts);
|
|
2673
|
+
}
|
|
2674
|
+
return new Session(info.sessionId, this, this._restClient);
|
|
2610
2675
|
},
|
|
2611
2676
|
get: async (sessionId, opts) => {
|
|
2612
2677
|
await this._restClient.get(`/runtimes/${this.id}/sessions/${sessionId}`, void 0, opts);
|
|
@@ -2677,6 +2742,26 @@ const CODEBUDDY_API_KEY = "CODEBUDDY_API_KEY";
|
|
|
2677
2742
|
var CloudAgentClient = class CloudAgentClient {
|
|
2678
2743
|
/** 构造(同步,不发网络请求) */
|
|
2679
2744
|
constructor(opts = {}) {
|
|
2745
|
+
this.agents = {
|
|
2746
|
+
create: async (req, opts) => {
|
|
2747
|
+
const info = await this._restClient.post("/agents", req, opts);
|
|
2748
|
+
return new Agent(this._restClient, info);
|
|
2749
|
+
},
|
|
2750
|
+
get: async (agentId, opts) => {
|
|
2751
|
+
const info = await this._restClient.get(`/agents/${agentId}`, void 0, opts);
|
|
2752
|
+
return new Agent(this._restClient, info);
|
|
2753
|
+
},
|
|
2754
|
+
list: async (opts) => {
|
|
2755
|
+
const params = {};
|
|
2756
|
+
if (opts?.page !== void 0) params.page = String(opts.page);
|
|
2757
|
+
if (opts?.pageSize !== void 0) params.pageSize = String(opts.pageSize);
|
|
2758
|
+
if (opts?.keyword) params.keyword = opts.keyword;
|
|
2759
|
+
return this._restClient.get("/agents", params, opts);
|
|
2760
|
+
},
|
|
2761
|
+
delete: async (agentId, opts) => {
|
|
2762
|
+
await this._restClient.delete(`/agents/${agentId}`, opts);
|
|
2763
|
+
}
|
|
2764
|
+
};
|
|
2680
2765
|
this.runtimes = {
|
|
2681
2766
|
create: async (opts) => {
|
|
2682
2767
|
const agentManifest = withInjectedApiKeySecret(opts.agentManifest, this.opts.apiKey, this.opts);
|
|
@@ -2875,6 +2960,7 @@ var ManifestBuilder = class {
|
|
|
2875
2960
|
|
|
2876
2961
|
//#endregion
|
|
2877
2962
|
exports.AcpProtocolError = AcpProtocolError;
|
|
2963
|
+
exports.Agent = Agent;
|
|
2878
2964
|
exports.AuthError = AuthError;
|
|
2879
2965
|
exports.CloudAgentClient = CloudAgentClient;
|
|
2880
2966
|
exports.CloudAgentError = CloudAgentError;
|