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