@lingya-ai/agents-sdk 0.1.2 → 0.4.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/README.md +50 -25
- package/dist/bound.d.ts +472 -0
- package/dist/bound.js +625 -0
- package/dist/client.d.ts +37 -20
- package/dist/client.js +46 -66
- package/dist/esm/bound.d.ts +472 -0
- package/dist/esm/bound.js +622 -0
- package/dist/esm/client.d.ts +37 -20
- package/dist/esm/client.js +45 -62
- package/dist/esm/events.d.ts +9 -5
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/events.d.ts +9 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -2
- package/package.json +6 -4
package/dist/esm/client.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Configuration } from './runtime';
|
|
2
|
-
import { ChatApi, ConfigurationApi, ConversationsApi, EventsApi, FilesApi, InteractionsApi, KnowledgeApi, MessagesApi, SQLApi, WorkspaceApi } from './apis';
|
|
3
2
|
import { type OpenApiCredentials } from './hmac';
|
|
4
|
-
import { type
|
|
3
|
+
import { type AiChatBriefEvent } from './events';
|
|
4
|
+
import { AgentsLowLevelApis, ChatApi as BoundChatApi, ConfigurationApi as BoundConfigurationApi, ConversationsApi as BoundConversationsApi, EventsApi as BoundEventsApi, FilesApi as BoundFilesApi, InteractionsApi as BoundInteractionsApi, KnowledgeApi as BoundKnowledgeApi, MessagesApi as BoundMessagesApi, SqlApi, WorkspaceApi as BoundWorkspaceApi } from './bound';
|
|
5
5
|
/**
|
|
6
6
|
* Lingya Agents SDK 入口,仅适用于可信服务端。 / Server-side Lingya Agents SDK entry point.
|
|
7
7
|
*
|
|
8
8
|
* 客户端保存 channel 范围的凭证,但只有 [forUser] 创建的用户客户端可以发起请求。
|
|
9
9
|
*/
|
|
10
|
-
export declare class
|
|
10
|
+
export declare class AgentsClient {
|
|
11
11
|
private readonly baseUrl;
|
|
12
12
|
readonly channelId: string;
|
|
13
13
|
private readonly credentials;
|
|
@@ -25,33 +25,39 @@ export declare class LingyaAgentsClient {
|
|
|
25
25
|
* @param externalUserId - 调用方系统的稳定用户 ID,UTF-8 编码后为 1..256 字节且不能含 NUL。
|
|
26
26
|
* @returns 注入用户身份并可调用全部契约 API 的客户端。
|
|
27
27
|
*/
|
|
28
|
-
forUser(externalUserId: string):
|
|
28
|
+
forUser(externalUserId: string): AgentsUserClient;
|
|
29
29
|
}
|
|
30
30
|
/** 已绑定外部用户的强类型 API 集合。 / Strongly typed API collection bound to one external user. */
|
|
31
|
-
export declare class
|
|
31
|
+
export declare class AgentsUserClient {
|
|
32
32
|
readonly channelId: string;
|
|
33
33
|
private readonly signedFetch;
|
|
34
34
|
private readonly baseUrl;
|
|
35
35
|
/** 发起新聊天和流探针。 / Starts chats and stream probes. */
|
|
36
|
-
readonly chat:
|
|
36
|
+
readonly chat: BoundChatApi;
|
|
37
37
|
/** 读取 Agent 与会话配置。 / Reads Agent and conversation configuration. */
|
|
38
|
-
readonly configuration:
|
|
38
|
+
readonly configuration: BoundConfigurationApi;
|
|
39
39
|
/** 管理会话、状态、分享和异步任务。 / Manages conversations, status, shares, and async tasks. */
|
|
40
|
-
readonly conversations:
|
|
40
|
+
readonly conversations: BoundConversationsApi;
|
|
41
41
|
/** 查询已持久化事件。 / Reads persisted events. */
|
|
42
|
-
readonly events:
|
|
42
|
+
readonly events: BoundEventsApi;
|
|
43
43
|
/** 管理附件与预签名 URL。 / Manages attachments and pre-signed URLs. */
|
|
44
|
-
readonly files:
|
|
44
|
+
readonly files: BoundFilesApi;
|
|
45
45
|
/** 回答用户问题并处理计划审批。 / Handles user answers and plan approval. */
|
|
46
|
-
readonly interactions:
|
|
46
|
+
readonly interactions: BoundInteractionsApi;
|
|
47
47
|
/** 查询引用元数据。 / Reads citation metadata. */
|
|
48
|
-
readonly knowledge:
|
|
48
|
+
readonly knowledge: BoundKnowledgeApi;
|
|
49
49
|
/** 查询消息并控制排队消息。 / Reads messages and controls queued messages. */
|
|
50
|
-
readonly messages:
|
|
50
|
+
readonly messages: BoundMessagesApi;
|
|
51
51
|
/** 查询、导出 SQL 结果与图表数据。 / Reads and exports SQL results and chart data. */
|
|
52
|
-
readonly sql:
|
|
52
|
+
readonly sql: SqlApi;
|
|
53
53
|
/** 查询工作区文件及预览。 / Reads workspace files and previews. */
|
|
54
|
-
readonly workspace:
|
|
54
|
+
readonly workspace: BoundWorkspaceApi;
|
|
55
|
+
/**
|
|
56
|
+
* 兼容旧版本的原始生成 API;正常业务调用应使用绑定门面。 / Raw generated APIs retained for migration only.
|
|
57
|
+
*
|
|
58
|
+
* @deprecated 将在 1.0 移除。 / Scheduled for removal in 1.0.
|
|
59
|
+
*/
|
|
60
|
+
readonly lowLevel: AgentsLowLevelApis;
|
|
55
61
|
constructor(channelId: string, configuration: Configuration, signedFetch: typeof fetch, baseUrl: string);
|
|
56
62
|
/**
|
|
57
63
|
* 调用契约端点并按指定类型返回 JSON;优先使用上方生成的强类型 API。 / Calls a contract endpoint and decodes typed JSON.
|
|
@@ -61,8 +67,9 @@ export declare class LingyaAgentsUserClient {
|
|
|
61
67
|
* @param bodyJson - 最终发送并参与签名的 UTF-8 JSON 字符串;无请求体时省略。
|
|
62
68
|
* @param query - 已按最终顺序组装的查询参数,允许重复键。
|
|
63
69
|
* @returns 调用方指定的响应类型。
|
|
64
|
-
* @throws [
|
|
70
|
+
* @throws [ApiError] 当服务端返回非 2xx 状态。
|
|
65
71
|
*/
|
|
72
|
+
/** @deprecated 使用对应的业务分组方法。 / Use the matching grouped facade operation. */
|
|
66
73
|
request<T>(method: string, suffix: string, bodyJson?: string, query?: URLSearchParams): Promise<T>;
|
|
67
74
|
/**
|
|
68
75
|
* 调用无响应正文的契约端点。 / Calls a contract endpoint that has no response body.
|
|
@@ -73,6 +80,7 @@ export declare class LingyaAgentsUserClient {
|
|
|
73
80
|
* @param query - 保留顺序的查询参数。
|
|
74
81
|
* @returns 2xx HTTP 状态码。
|
|
75
82
|
*/
|
|
83
|
+
/** @deprecated 使用对应的业务分组方法。 / Use the matching grouped facade operation. */
|
|
76
84
|
requestStatus(method: string, suffix: string, bodyJson?: string, query?: URLSearchParams): Promise<number>;
|
|
77
85
|
/**
|
|
78
86
|
* 下载二进制响应,返回精确响应字节。 / Downloads an exact binary response.
|
|
@@ -82,6 +90,7 @@ export declare class LingyaAgentsUserClient {
|
|
|
82
90
|
* @param query - 保留顺序的查询参数。
|
|
83
91
|
* @returns 未经文本转换的响应字节。
|
|
84
92
|
*/
|
|
93
|
+
/** @deprecated 使用对应的业务分组方法。 / Use the matching grouped facade operation. */
|
|
85
94
|
requestBinary(method: string, suffix: string, query?: URLSearchParams): Promise<Uint8Array>;
|
|
86
95
|
/**
|
|
87
96
|
* 订阅对话 SSE,事件按契约判别联合返回。 / Streams SSE as the contract discriminated union.
|
|
@@ -90,7 +99,8 @@ export declare class LingyaAgentsUserClient {
|
|
|
90
99
|
* @param messageId - 触发本次生成的消息 ID。
|
|
91
100
|
* @returns 支持取消的异步事件序列;未知 type 保留 `rawJson`。
|
|
92
101
|
*/
|
|
93
|
-
streamChatEvents(conversationId
|
|
102
|
+
/** @deprecated 使用 `chat.streamChatEvents(conversationId, { messageId })`。 / Use the channel-bound chat facade. */
|
|
103
|
+
streamChatEvents(conversationId: string, messageId: string): AsyncGenerator<AiChatBriefEvent>;
|
|
94
104
|
/**
|
|
95
105
|
* 发送底层受控请求;调用前固定最终 path、query、Content-Type 与 body 字节。 / Sends an exactly signed low-level request.
|
|
96
106
|
*
|
|
@@ -102,15 +112,22 @@ export declare class LingyaAgentsUserClient {
|
|
|
102
112
|
* @param query - 最终查询参数;顺序和重复键均参与签名。
|
|
103
113
|
* @param accept - 精确的 Accept 值,例如 `application/json`、`text/event-stream` 或 `text/csv`。
|
|
104
114
|
* @returns 成功的原始 Fetch Response。
|
|
105
|
-
* @throws [
|
|
115
|
+
* @throws [ApiError] 当服务端返回非 2xx 状态。
|
|
106
116
|
*/
|
|
107
|
-
|
|
117
|
+
/** @deprecated 使用 `lowLevel`,或使用对应的业务分组方法。 / Use `lowLevel` or a grouped facade operation. */
|
|
118
|
+
rawRequest(method: string, suffix: string, bodyJson?: string, query?: URLSearchParams, accept?: string, requestId?: string): Promise<Response>;
|
|
108
119
|
}
|
|
109
120
|
/** 不含凭证的 HTTP 错误。 / HTTP failure that never includes credentials. */
|
|
110
|
-
export declare class
|
|
121
|
+
export declare class ApiError extends Error {
|
|
111
122
|
readonly method: string;
|
|
112
123
|
readonly path: string;
|
|
113
124
|
readonly status: number;
|
|
114
125
|
readonly responseBody: string;
|
|
115
126
|
constructor(method: string, path: string, status: number, responseBody: string);
|
|
116
127
|
}
|
|
128
|
+
/** @deprecated Use [AgentsClient]. */
|
|
129
|
+
export { AgentsClient as LingyaAgentsClient };
|
|
130
|
+
/** @deprecated Use [AgentsUserClient]. */
|
|
131
|
+
export { AgentsUserClient as LingyaAgentsUserClient };
|
|
132
|
+
/** @deprecated Use [ApiError]. */
|
|
133
|
+
export { ApiError as LingyaApiError };
|
package/dist/esm/client.js
CHANGED
|
@@ -7,37 +7,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
11
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
-
var m = o[Symbol.asyncIterator], i;
|
|
14
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
-
};
|
|
18
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
19
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
20
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
21
|
-
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
22
|
-
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
23
|
-
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
24
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
25
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
26
|
-
function fulfill(value) { resume("next", value); }
|
|
27
|
-
function reject(value) { resume("throw", value); }
|
|
28
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
29
|
-
};
|
|
30
10
|
import { Configuration } from './runtime';
|
|
31
11
|
import { ChatApi, ConfigurationApi, ConversationsApi, EventsApi, FilesApi, InteractionsApi, KnowledgeApi, MessagesApi, SQLApi, WorkspaceApi } from './apis';
|
|
32
12
|
import { createSignedFetch } from './hmac';
|
|
33
|
-
import {
|
|
34
|
-
import { decodeAiChatBriefEvent } from './events';
|
|
13
|
+
import { AgentsLowLevelApis, ChatApi as BoundChatApi, ConfigurationApi as BoundConfigurationApi, ConversationsApi as BoundConversationsApi, EventsApi as BoundEventsApi, FilesApi as BoundFilesApi, InteractionsApi as BoundInteractionsApi, KnowledgeApi as BoundKnowledgeApi, MessagesApi as BoundMessagesApi, SqlApi, WorkspaceApi as BoundWorkspaceApi, } from './bound';
|
|
35
14
|
/**
|
|
36
15
|
* Lingya Agents SDK 入口,仅适用于可信服务端。 / Server-side Lingya Agents SDK entry point.
|
|
37
16
|
*
|
|
38
17
|
* 客户端保存 channel 范围的凭证,但只有 [forUser] 创建的用户客户端可以发起请求。
|
|
39
18
|
*/
|
|
40
|
-
export class
|
|
19
|
+
export class AgentsClient {
|
|
41
20
|
/**
|
|
42
21
|
* 创建 channel 范围的客户端。 / Creates a channel-scoped client.
|
|
43
22
|
*
|
|
@@ -61,25 +40,37 @@ export class LingyaAgentsClient {
|
|
|
61
40
|
forUser(externalUserId) {
|
|
62
41
|
const signedFetch = createSignedFetch(this.credentials, externalUserId);
|
|
63
42
|
const configuration = new Configuration({ basePath: this.baseUrl.replace(/\/+$/, ''), fetchApi: signedFetch });
|
|
64
|
-
return new
|
|
43
|
+
return new AgentsUserClient(this.channelId, configuration, signedFetch, this.baseUrl);
|
|
65
44
|
}
|
|
66
45
|
}
|
|
67
46
|
/** 已绑定外部用户的强类型 API 集合。 / Strongly typed API collection bound to one external user. */
|
|
68
|
-
export class
|
|
47
|
+
export class AgentsUserClient {
|
|
69
48
|
constructor(channelId, configuration, signedFetch, baseUrl) {
|
|
70
49
|
this.channelId = channelId;
|
|
71
50
|
this.signedFetch = signedFetch;
|
|
72
51
|
this.baseUrl = baseUrl;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
52
|
+
const chat = new ChatApi(configuration);
|
|
53
|
+
const configurationApi = new ConfigurationApi(configuration);
|
|
54
|
+
const conversations = new ConversationsApi(configuration);
|
|
55
|
+
const events = new EventsApi(configuration);
|
|
56
|
+
const files = new FilesApi(configuration);
|
|
57
|
+
const interactions = new InteractionsApi(configuration);
|
|
58
|
+
const knowledge = new KnowledgeApi(configuration);
|
|
59
|
+
const messages = new MessagesApi(configuration);
|
|
60
|
+
const sql = new SQLApi(configuration);
|
|
61
|
+
const workspace = new WorkspaceApi(configuration);
|
|
62
|
+
this.lowLevel = new AgentsLowLevelApis(configurationApi, chat, conversations, sql, messages, events, interactions, files, knowledge, workspace);
|
|
63
|
+
const rawRequest = this.rawRequest.bind(this);
|
|
64
|
+
this.chat = new BoundChatApi(channelId, chat, rawRequest);
|
|
65
|
+
this.configuration = new BoundConfigurationApi(channelId, configurationApi);
|
|
66
|
+
this.conversations = new BoundConversationsApi(channelId, conversations);
|
|
67
|
+
this.events = new BoundEventsApi(channelId, events);
|
|
68
|
+
this.files = new BoundFilesApi(channelId, files);
|
|
69
|
+
this.interactions = new BoundInteractionsApi(channelId, interactions);
|
|
70
|
+
this.knowledge = new BoundKnowledgeApi(channelId, knowledge);
|
|
71
|
+
this.messages = new BoundMessagesApi(channelId, messages);
|
|
72
|
+
this.sql = new SqlApi(channelId, sql);
|
|
73
|
+
this.workspace = new BoundWorkspaceApi(channelId, workspace);
|
|
83
74
|
}
|
|
84
75
|
/**
|
|
85
76
|
* 调用契约端点并按指定类型返回 JSON;优先使用上方生成的强类型 API。 / Calls a contract endpoint and decodes typed JSON.
|
|
@@ -89,8 +80,9 @@ export class LingyaAgentsUserClient {
|
|
|
89
80
|
* @param bodyJson - 最终发送并参与签名的 UTF-8 JSON 字符串;无请求体时省略。
|
|
90
81
|
* @param query - 已按最终顺序组装的查询参数,允许重复键。
|
|
91
82
|
* @returns 调用方指定的响应类型。
|
|
92
|
-
* @throws [
|
|
83
|
+
* @throws [ApiError] 当服务端返回非 2xx 状态。
|
|
93
84
|
*/
|
|
85
|
+
/** @deprecated 使用对应的业务分组方法。 / Use the matching grouped facade operation. */
|
|
94
86
|
request(method, suffix, bodyJson, query) {
|
|
95
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
96
88
|
const response = yield this.rawRequest(method, suffix, bodyJson, query, 'application/json');
|
|
@@ -106,6 +98,7 @@ export class LingyaAgentsUserClient {
|
|
|
106
98
|
* @param query - 保留顺序的查询参数。
|
|
107
99
|
* @returns 2xx HTTP 状态码。
|
|
108
100
|
*/
|
|
101
|
+
/** @deprecated 使用对应的业务分组方法。 / Use the matching grouped facade operation. */
|
|
109
102
|
requestStatus(method, suffix, bodyJson, query) {
|
|
110
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
104
|
return (yield this.rawRequest(method, suffix, bodyJson, query, 'application/json')).status;
|
|
@@ -119,6 +112,7 @@ export class LingyaAgentsUserClient {
|
|
|
119
112
|
* @param query - 保留顺序的查询参数。
|
|
120
113
|
* @returns 未经文本转换的响应字节。
|
|
121
114
|
*/
|
|
115
|
+
/** @deprecated 使用对应的业务分组方法。 / Use the matching grouped facade operation. */
|
|
122
116
|
requestBinary(method, suffix, query) {
|
|
123
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
118
|
const response = yield this.rawRequest(method, suffix, undefined, query, 'application/octet-stream');
|
|
@@ -132,27 +126,9 @@ export class LingyaAgentsUserClient {
|
|
|
132
126
|
* @param messageId - 触发本次生成的消息 ID。
|
|
133
127
|
* @returns 支持取消的异步事件序列;未知 type 保留 `rawJson`。
|
|
134
128
|
*/
|
|
129
|
+
/** @deprecated 使用 `chat.streamChatEvents(conversationId, { messageId })`。 / Use the channel-bound chat facade. */
|
|
135
130
|
streamChatEvents(conversationId, messageId) {
|
|
136
|
-
return
|
|
137
|
-
var _a, e_1, _b, _c;
|
|
138
|
-
const suffix = `/conversations/${encodeURIComponent(conversationId)}/stream`;
|
|
139
|
-
const response = yield __await(this.rawRequest('POST', suffix, JSON.stringify({ messageId }), undefined, 'text/event-stream'));
|
|
140
|
-
try {
|
|
141
|
-
for (var _d = true, _e = __asyncValues(decodeSse(response)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
|
|
142
|
-
_c = _f.value;
|
|
143
|
-
_d = false;
|
|
144
|
-
const data = _c;
|
|
145
|
-
yield yield __await(decodeAiChatBriefEvent(data));
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
149
|
-
finally {
|
|
150
|
-
try {
|
|
151
|
-
if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
|
|
152
|
-
}
|
|
153
|
-
finally { if (e_1) throw e_1.error; }
|
|
154
|
-
}
|
|
155
|
-
});
|
|
131
|
+
return this.chat.streamChatEvents(conversationId, { messageId });
|
|
156
132
|
}
|
|
157
133
|
/**
|
|
158
134
|
* 发送底层受控请求;调用前固定最终 path、query、Content-Type 与 body 字节。 / Sends an exactly signed low-level request.
|
|
@@ -165,31 +141,38 @@ export class LingyaAgentsUserClient {
|
|
|
165
141
|
* @param query - 最终查询参数;顺序和重复键均参与签名。
|
|
166
142
|
* @param accept - 精确的 Accept 值,例如 `application/json`、`text/event-stream` 或 `text/csv`。
|
|
167
143
|
* @returns 成功的原始 Fetch Response。
|
|
168
|
-
* @throws [
|
|
144
|
+
* @throws [ApiError] 当服务端返回非 2xx 状态。
|
|
169
145
|
*/
|
|
146
|
+
/** @deprecated 使用 `lowLevel`,或使用对应的业务分组方法。 / Use `lowLevel` or a grouped facade operation. */
|
|
170
147
|
rawRequest(method_1, suffix_1, bodyJson_1, query_1) {
|
|
171
|
-
return __awaiter(this, arguments, void 0, function* (method, suffix, bodyJson, query, accept = 'application/json') {
|
|
148
|
+
return __awaiter(this, arguments, void 0, function* (method, suffix, bodyJson, query, accept = 'application/json', requestId) {
|
|
172
149
|
const root = `${this.baseUrl.replace(/\/+$/, '')}/api/agents/channel/openapi/v1/${encodeURIComponent(this.channelId)}/chat`;
|
|
173
150
|
const url = `${root}${suffix}${query === undefined || query.size === 0 ? '' : `?${query.toString()}`}`;
|
|
174
151
|
const response = yield this.signedFetch(url, {
|
|
175
152
|
method,
|
|
176
|
-
headers: Object.assign({ Accept: accept }, (bodyJson === undefined ? {} : { 'Content-Type': 'application/json' })),
|
|
153
|
+
headers: Object.assign(Object.assign({ Accept: accept }, (bodyJson === undefined ? {} : { 'Content-Type': 'application/json' })), (requestId === undefined ? {} : { 'X-Request-ID': requestId })),
|
|
177
154
|
body: bodyJson,
|
|
178
155
|
});
|
|
179
156
|
if (!response.ok)
|
|
180
|
-
throw new
|
|
157
|
+
throw new ApiError(method, suffix, response.status, yield response.text());
|
|
181
158
|
return response;
|
|
182
159
|
});
|
|
183
160
|
}
|
|
184
161
|
}
|
|
185
162
|
/** 不含凭证的 HTTP 错误。 / HTTP failure that never includes credentials. */
|
|
186
|
-
export class
|
|
163
|
+
export class ApiError extends Error {
|
|
187
164
|
constructor(method, path, status, responseBody) {
|
|
188
165
|
super(`${method} ${path} returned HTTP ${status}`);
|
|
189
166
|
this.method = method;
|
|
190
167
|
this.path = path;
|
|
191
168
|
this.status = status;
|
|
192
169
|
this.responseBody = responseBody;
|
|
193
|
-
this.name = '
|
|
170
|
+
this.name = 'ApiError';
|
|
194
171
|
}
|
|
195
172
|
}
|
|
173
|
+
/** @deprecated Use [AgentsClient]. */
|
|
174
|
+
export { AgentsClient as LingyaAgentsClient };
|
|
175
|
+
/** @deprecated Use [AgentsUserClient]. */
|
|
176
|
+
export { AgentsUserClient as LingyaAgentsUserClient };
|
|
177
|
+
/** @deprecated Use [ApiError]. */
|
|
178
|
+
export { ApiError as LingyaApiError };
|
package/dist/esm/events.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { AiChatBriefEvent, ToolExtension, UnknownAiChatBriefEvent, UnknownToolExtension } from './models';
|
|
1
|
+
import type { AiChatBriefEvent as GeneratedAiChatBriefEvent, ToolExtension as GeneratedToolExtension, UnknownAiChatBriefEvent, UnknownToolExtension } from './models';
|
|
2
2
|
/** 包含全部已知事件以及携带原始 JSON 的未知事件。 / All known events plus a raw-JSON fallback for future event types. */
|
|
3
|
-
export type
|
|
3
|
+
export type AiChatBriefEvent = GeneratedAiChatBriefEvent | UnknownAiChatBriefEvent;
|
|
4
4
|
/** 包含全部已知工具扩展以及携带原始 JSON 的未知扩展。 / All known tool extensions plus a raw-JSON fallback. */
|
|
5
|
-
export type
|
|
5
|
+
export type ToolExtension = GeneratedToolExtension | UnknownToolExtension;
|
|
6
6
|
/**
|
|
7
7
|
* 按 type 判别事件;未知值只暴露 type 与 rawJson。 / Decodes by type with an exact JSON fallback.
|
|
8
8
|
*
|
|
@@ -10,7 +10,7 @@ export type LingyaToolExtension = ToolExtension | UnknownToolExtension;
|
|
|
10
10
|
* @returns 已知事件联合,或保存输入原文的未知事件。
|
|
11
11
|
* @throws SyntaxError 当输入不是有效 JSON。
|
|
12
12
|
*/
|
|
13
|
-
export declare function decodeAiChatBriefEvent(rawJson: string):
|
|
13
|
+
export declare function decodeAiChatBriefEvent(rawJson: string): AiChatBriefEvent;
|
|
14
14
|
/**
|
|
15
15
|
* 按 category 判别工具扩展。 / Decodes a tool extension by category.
|
|
16
16
|
*
|
|
@@ -18,4 +18,8 @@ export declare function decodeAiChatBriefEvent(rawJson: string): LingyaAiChatBri
|
|
|
18
18
|
* @returns 12 种已知扩展之一,或保存输入原文的未知扩展。
|
|
19
19
|
* @throws SyntaxError 当输入不是有效 JSON。
|
|
20
20
|
*/
|
|
21
|
-
export declare function decodeToolExtension(rawJson: string):
|
|
21
|
+
export declare function decodeToolExtension(rawJson: string): ToolExtension;
|
|
22
|
+
/** @deprecated Use [AiChatBriefEvent]. */
|
|
23
|
+
export type LingyaAiChatBriefEvent = AiChatBriefEvent;
|
|
24
|
+
/** @deprecated Use [ToolExtension]. */
|
|
25
|
+
export type LingyaToolExtension = ToolExtension;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './runtime';
|
|
2
|
-
export * from './apis/index';
|
|
3
2
|
export * from './models/index';
|
|
4
3
|
export * from './client';
|
|
4
|
+
export * from './bound';
|
|
5
5
|
export * from './hmac';
|
|
6
6
|
export * from './sse';
|
|
7
|
-
export
|
|
7
|
+
export { decodeAiChatBriefEvent, decodeToolExtension, type AiChatBriefEvent, type ToolExtension, type LingyaAiChatBriefEvent, type LingyaToolExtension, } from './events';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export * from './runtime';
|
|
4
|
-
export * from './apis/index';
|
|
5
4
|
export * from './models/index';
|
|
6
5
|
export * from './client';
|
|
6
|
+
export * from './bound';
|
|
7
7
|
export * from './hmac';
|
|
8
8
|
export * from './sse';
|
|
9
|
-
export
|
|
9
|
+
export { decodeAiChatBriefEvent, decodeToolExtension, } from './events';
|
package/dist/events.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { AiChatBriefEvent, ToolExtension, UnknownAiChatBriefEvent, UnknownToolExtension } from './models';
|
|
1
|
+
import type { AiChatBriefEvent as GeneratedAiChatBriefEvent, ToolExtension as GeneratedToolExtension, UnknownAiChatBriefEvent, UnknownToolExtension } from './models';
|
|
2
2
|
/** 包含全部已知事件以及携带原始 JSON 的未知事件。 / All known events plus a raw-JSON fallback for future event types. */
|
|
3
|
-
export type
|
|
3
|
+
export type AiChatBriefEvent = GeneratedAiChatBriefEvent | UnknownAiChatBriefEvent;
|
|
4
4
|
/** 包含全部已知工具扩展以及携带原始 JSON 的未知扩展。 / All known tool extensions plus a raw-JSON fallback. */
|
|
5
|
-
export type
|
|
5
|
+
export type ToolExtension = GeneratedToolExtension | UnknownToolExtension;
|
|
6
6
|
/**
|
|
7
7
|
* 按 type 判别事件;未知值只暴露 type 与 rawJson。 / Decodes by type with an exact JSON fallback.
|
|
8
8
|
*
|
|
@@ -10,7 +10,7 @@ export type LingyaToolExtension = ToolExtension | UnknownToolExtension;
|
|
|
10
10
|
* @returns 已知事件联合,或保存输入原文的未知事件。
|
|
11
11
|
* @throws SyntaxError 当输入不是有效 JSON。
|
|
12
12
|
*/
|
|
13
|
-
export declare function decodeAiChatBriefEvent(rawJson: string):
|
|
13
|
+
export declare function decodeAiChatBriefEvent(rawJson: string): AiChatBriefEvent;
|
|
14
14
|
/**
|
|
15
15
|
* 按 category 判别工具扩展。 / Decodes a tool extension by category.
|
|
16
16
|
*
|
|
@@ -18,4 +18,8 @@ export declare function decodeAiChatBriefEvent(rawJson: string): LingyaAiChatBri
|
|
|
18
18
|
* @returns 12 种已知扩展之一,或保存输入原文的未知扩展。
|
|
19
19
|
* @throws SyntaxError 当输入不是有效 JSON。
|
|
20
20
|
*/
|
|
21
|
-
export declare function decodeToolExtension(rawJson: string):
|
|
21
|
+
export declare function decodeToolExtension(rawJson: string): ToolExtension;
|
|
22
|
+
/** @deprecated Use [AiChatBriefEvent]. */
|
|
23
|
+
export type LingyaAiChatBriefEvent = AiChatBriefEvent;
|
|
24
|
+
/** @deprecated Use [ToolExtension]. */
|
|
25
|
+
export type LingyaToolExtension = ToolExtension;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './runtime';
|
|
2
|
-
export * from './apis/index';
|
|
3
2
|
export * from './models/index';
|
|
4
3
|
export * from './client';
|
|
4
|
+
export * from './bound';
|
|
5
5
|
export * from './hmac';
|
|
6
6
|
export * from './sse';
|
|
7
|
-
export
|
|
7
|
+
export { decodeAiChatBriefEvent, decodeToolExtension, type AiChatBriefEvent, type ToolExtension, type LingyaAiChatBriefEvent, type LingyaToolExtension, } from './events';
|
package/dist/index.js
CHANGED
|
@@ -14,12 +14,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.decodeToolExtension = exports.decodeAiChatBriefEvent = void 0;
|
|
17
18
|
/* tslint:disable */
|
|
18
19
|
/* eslint-disable */
|
|
19
20
|
__exportStar(require("./runtime"), exports);
|
|
20
|
-
__exportStar(require("./apis/index"), exports);
|
|
21
21
|
__exportStar(require("./models/index"), exports);
|
|
22
22
|
__exportStar(require("./client"), exports);
|
|
23
|
+
__exportStar(require("./bound"), exports);
|
|
23
24
|
__exportStar(require("./hmac"), exports);
|
|
24
25
|
__exportStar(require("./sse"), exports);
|
|
25
|
-
|
|
26
|
+
var events_1 = require("./events");
|
|
27
|
+
Object.defineProperty(exports, "decodeAiChatBriefEvent", { enumerable: true, get: function () { return events_1.decodeAiChatBriefEvent; } });
|
|
28
|
+
Object.defineProperty(exports, "decodeToolExtension", { enumerable: true, get: function () { return events_1.decodeToolExtension; } });
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingya-ai/agents-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Strongly typed server-side TypeScript SDK for Lingya Agents OpenAPI",
|
|
5
5
|
"author": "Lingya AI",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/lingya-ai/lingya-agents-sdk-typescript.git"
|
|
9
|
+
"url": "git+https://github.com/lingya-ai/lingya-agents-sdk-typescript.git"
|
|
10
10
|
},
|
|
11
11
|
"homepage": "https://github.com/lingya-ai/lingya-agents-sdk-typescript#readme",
|
|
12
12
|
"bugs": {
|
|
@@ -40,8 +40,10 @@
|
|
|
40
40
|
"registry": "https://registry.npmjs.org"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
|
-
"
|
|
44
|
-
"
|
|
43
|
+
"generate:bound": "node scripts/generate-bound-api.mjs",
|
|
44
|
+
"build": "npm run generate:bound && tsc && tsc -p tsconfig.esm.json",
|
|
45
|
+
"check": "npm run build && npm run typecheck && npm run test && npm run audit:models && npm run package:smoke",
|
|
46
|
+
"typecheck": "tsc -p tsconfig.types.json",
|
|
45
47
|
"test": "tsx --test test/*.test.ts",
|
|
46
48
|
"test:live": "tsx --test test/live.test.ts",
|
|
47
49
|
"audit:models": "node scripts/audit-models.mjs",
|