@lingya-ai/agents-sdk 0.3.0 → 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/dist/bound.js CHANGED
@@ -33,12 +33,12 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
33
33
  function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
34
34
  };
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.LingyaWorkspaceApi = exports.LingyaKnowledgeApi = exports.LingyaFilesApi = exports.LingyaInteractionsApi = exports.LingyaEventsApi = exports.LingyaMessagesApi = exports.LingyaSqlApi = exports.LingyaConversationsApi = exports.LingyaChatApi = exports.LingyaConfigurationApi = exports.LingyaAgentsLowLevelApis = void 0;
36
+ exports.LingyaWorkspaceApi = exports.LingyaKnowledgeApi = exports.LingyaFilesApi = exports.LingyaInteractionsApi = exports.LingyaEventsApi = exports.LingyaMessagesApi = exports.LingyaSqlApi = exports.LingyaConversationsApi = exports.LingyaChatApi = exports.LingyaConfigurationApi = exports.LingyaAgentsLowLevelApis = exports.WorkspaceApi = exports.KnowledgeApi = exports.FilesApi = exports.InteractionsApi = exports.EventsApi = exports.MessagesApi = exports.SqlApi = exports.ConversationsApi = exports.ChatApi = exports.ConfigurationApi = exports.AgentsLowLevelApis = void 0;
37
37
  const ChatStreamProbeEvent_1 = require("./models/ChatStreamProbeEvent");
38
38
  const events_1 = require("./events");
39
39
  const sse_1 = require("./sse");
40
40
  /** Generated APIs retained as an explicit compatibility escape hatch until 1.0. */
41
- class LingyaAgentsLowLevelApis {
41
+ class AgentsLowLevelApis {
42
42
  constructor(configuration, chat, conversations, sql, messages, events, interactions, files, knowledge, workspace) {
43
43
  this.configuration = configuration;
44
44
  this.chat = chat;
@@ -52,9 +52,10 @@ class LingyaAgentsLowLevelApis {
52
52
  this.workspace = workspace;
53
53
  }
54
54
  }
55
- exports.LingyaAgentsLowLevelApis = LingyaAgentsLowLevelApis;
55
+ exports.AgentsLowLevelApis = AgentsLowLevelApis;
56
+ exports.LingyaAgentsLowLevelApis = AgentsLowLevelApis;
56
57
  /** Channel-bound configuration operations for one external user. */
57
- class LingyaConfigurationApi {
58
+ class ConfigurationApi {
58
59
  constructor(channelId, delegate) {
59
60
  this.channelId = channelId;
60
61
  this.delegate = delegate;
@@ -77,9 +78,10 @@ class LingyaConfigurationApi {
77
78
  return this.delegate.getConversationConfig({ channelId: this.channelId, conversationId });
78
79
  }
79
80
  }
80
- exports.LingyaConfigurationApi = LingyaConfigurationApi;
81
+ exports.ConfigurationApi = ConfigurationApi;
82
+ exports.LingyaConfigurationApi = ConfigurationApi;
81
83
  /** Channel-bound chat operations for one external user. */
82
- class LingyaChatApi {
84
+ class ChatApi {
83
85
  constructor(channelId, delegate, rawRequest) {
84
86
  this.channelId = channelId;
85
87
  this.delegate = delegate;
@@ -183,9 +185,10 @@ class LingyaChatApi {
183
185
  return this.delegate.compactConversation(Object.assign({ channelId: this.channelId, conversationId }, options));
184
186
  }
185
187
  }
186
- exports.LingyaChatApi = LingyaChatApi;
188
+ exports.ChatApi = ChatApi;
189
+ exports.LingyaChatApi = ChatApi;
187
190
  /** Channel-bound conversations operations for one external user. */
188
- class LingyaConversationsApi {
191
+ class ConversationsApi {
189
192
  constructor(channelId, delegate) {
190
193
  this.channelId = channelId;
191
194
  this.delegate = delegate;
@@ -319,9 +322,10 @@ class LingyaConversationsApi {
319
322
  return this.delegate.revokeConversationShare({ channelId: this.channelId, conversationId, shareId });
320
323
  }
321
324
  }
322
- exports.LingyaConversationsApi = LingyaConversationsApi;
325
+ exports.ConversationsApi = ConversationsApi;
326
+ exports.LingyaConversationsApi = ConversationsApi;
323
327
  /** Channel-bound sql operations for one external user. */
324
- class LingyaSqlApi {
328
+ class SqlApi {
325
329
  constructor(channelId, delegate) {
326
330
  this.channelId = channelId;
327
331
  this.delegate = delegate;
@@ -362,9 +366,10 @@ class LingyaSqlApi {
362
366
  });
363
367
  }
364
368
  }
365
- exports.LingyaSqlApi = LingyaSqlApi;
369
+ exports.SqlApi = SqlApi;
370
+ exports.LingyaSqlApi = SqlApi;
366
371
  /** Channel-bound messages operations for one external user. */
367
- class LingyaMessagesApi {
372
+ class MessagesApi {
368
373
  constructor(channelId, delegate) {
369
374
  this.channelId = channelId;
370
375
  this.delegate = delegate;
@@ -420,9 +425,10 @@ class LingyaMessagesApi {
420
425
  return this.delegate.cancelQueuedMessage({ channelId: this.channelId, conversationId, messageId });
421
426
  }
422
427
  }
423
- exports.LingyaMessagesApi = LingyaMessagesApi;
428
+ exports.MessagesApi = MessagesApi;
429
+ exports.LingyaMessagesApi = MessagesApi;
424
430
  /** Channel-bound events operations for one external user. */
425
- class LingyaEventsApi {
431
+ class EventsApi {
426
432
  constructor(channelId, delegate) {
427
433
  this.channelId = channelId;
428
434
  this.delegate = delegate;
@@ -446,9 +452,10 @@ class LingyaEventsApi {
446
452
  return this.delegate.getChatEventsBatch({ channelId: this.channelId, aiChatEventsBatchInput: input });
447
453
  }
448
454
  }
449
- exports.LingyaEventsApi = LingyaEventsApi;
455
+ exports.EventsApi = EventsApi;
456
+ exports.LingyaEventsApi = EventsApi;
450
457
  /** Channel-bound interactions operations for one external user. */
451
- class LingyaInteractionsApi {
458
+ class InteractionsApi {
452
459
  constructor(channelId, delegate) {
453
460
  this.channelId = channelId;
454
461
  this.delegate = delegate;
@@ -491,9 +498,10 @@ class LingyaInteractionsApi {
491
498
  return this.delegate.answerUserInput({ channelId: this.channelId, userInputAnswerInput: input });
492
499
  }
493
500
  }
494
- exports.LingyaInteractionsApi = LingyaInteractionsApi;
501
+ exports.InteractionsApi = InteractionsApi;
502
+ exports.LingyaInteractionsApi = InteractionsApi;
495
503
  /** Channel-bound files operations for one external user. */
496
- class LingyaFilesApi {
504
+ class FilesApi {
497
505
  constructor(channelId, delegate) {
498
506
  this.channelId = channelId;
499
507
  this.delegate = delegate;
@@ -556,9 +564,10 @@ class LingyaFilesApi {
556
564
  return this.delegate.getPlanIntermediateFilePreview({ channelId: this.channelId, conversationId, messageId, fileId });
557
565
  }
558
566
  }
559
- exports.LingyaFilesApi = LingyaFilesApi;
567
+ exports.FilesApi = FilesApi;
568
+ exports.LingyaFilesApi = FilesApi;
560
569
  /** Channel-bound knowledge operations for one external user. */
561
- class LingyaKnowledgeApi {
570
+ class KnowledgeApi {
562
571
  constructor(channelId, delegate) {
563
572
  this.channelId = channelId;
564
573
  this.delegate = delegate;
@@ -583,9 +592,10 @@ class LingyaKnowledgeApi {
583
592
  return this.delegate.getCitationMetadata({ channelId: this.channelId, citationType, referenceId });
584
593
  }
585
594
  }
586
- exports.LingyaKnowledgeApi = LingyaKnowledgeApi;
595
+ exports.KnowledgeApi = KnowledgeApi;
596
+ exports.LingyaKnowledgeApi = KnowledgeApi;
587
597
  /** Channel-bound workspace operations for one external user. */
588
- class LingyaWorkspaceApi {
598
+ class WorkspaceApi {
589
599
  constructor(channelId, delegate) {
590
600
  this.channelId = channelId;
591
601
  this.delegate = delegate;
@@ -611,4 +621,5 @@ class LingyaWorkspaceApi {
611
621
  return this.delegate.getWorkspaceFilePreview(Object.assign({ channelId: this.channelId, conversationId }, options));
612
622
  }
613
623
  }
614
- exports.LingyaWorkspaceApi = LingyaWorkspaceApi;
624
+ exports.WorkspaceApi = WorkspaceApi;
625
+ exports.LingyaWorkspaceApi = WorkspaceApi;
package/dist/client.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { Configuration } from './runtime';
2
2
  import { type OpenApiCredentials } from './hmac';
3
- import { type LingyaAiChatBriefEvent } from './events';
4
- import { LingyaAgentsLowLevelApis, LingyaChatApi, LingyaConfigurationApi, LingyaConversationsApi, LingyaEventsApi, LingyaFilesApi, LingyaInteractionsApi, LingyaKnowledgeApi, LingyaMessagesApi, LingyaSqlApi, LingyaWorkspaceApi } from './bound';
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 LingyaAgentsClient {
10
+ export declare class AgentsClient {
11
11
  private readonly baseUrl;
12
12
  readonly channelId: string;
13
13
  private readonly credentials;
@@ -25,39 +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): LingyaAgentsUserClient;
28
+ forUser(externalUserId: string): AgentsUserClient;
29
29
  }
30
30
  /** 已绑定外部用户的强类型 API 集合。 / Strongly typed API collection bound to one external user. */
31
- export declare class LingyaAgentsUserClient {
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: LingyaChatApi;
36
+ readonly chat: BoundChatApi;
37
37
  /** 读取 Agent 与会话配置。 / Reads Agent and conversation configuration. */
38
- readonly configuration: LingyaConfigurationApi;
38
+ readonly configuration: BoundConfigurationApi;
39
39
  /** 管理会话、状态、分享和异步任务。 / Manages conversations, status, shares, and async tasks. */
40
- readonly conversations: LingyaConversationsApi;
40
+ readonly conversations: BoundConversationsApi;
41
41
  /** 查询已持久化事件。 / Reads persisted events. */
42
- readonly events: LingyaEventsApi;
42
+ readonly events: BoundEventsApi;
43
43
  /** 管理附件与预签名 URL。 / Manages attachments and pre-signed URLs. */
44
- readonly files: LingyaFilesApi;
44
+ readonly files: BoundFilesApi;
45
45
  /** 回答用户问题并处理计划审批。 / Handles user answers and plan approval. */
46
- readonly interactions: LingyaInteractionsApi;
46
+ readonly interactions: BoundInteractionsApi;
47
47
  /** 查询引用元数据。 / Reads citation metadata. */
48
- readonly knowledge: LingyaKnowledgeApi;
48
+ readonly knowledge: BoundKnowledgeApi;
49
49
  /** 查询消息并控制排队消息。 / Reads messages and controls queued messages. */
50
- readonly messages: LingyaMessagesApi;
50
+ readonly messages: BoundMessagesApi;
51
51
  /** 查询、导出 SQL 结果与图表数据。 / Reads and exports SQL results and chart data. */
52
- readonly sql: LingyaSqlApi;
52
+ readonly sql: SqlApi;
53
53
  /** 查询工作区文件及预览。 / Reads workspace files and previews. */
54
- readonly workspace: LingyaWorkspaceApi;
54
+ readonly workspace: BoundWorkspaceApi;
55
55
  /**
56
56
  * 兼容旧版本的原始生成 API;正常业务调用应使用绑定门面。 / Raw generated APIs retained for migration only.
57
57
  *
58
58
  * @deprecated 将在 1.0 移除。 / Scheduled for removal in 1.0.
59
59
  */
60
- readonly lowLevel: LingyaAgentsLowLevelApis;
60
+ readonly lowLevel: AgentsLowLevelApis;
61
61
  constructor(channelId: string, configuration: Configuration, signedFetch: typeof fetch, baseUrl: string);
62
62
  /**
63
63
  * 调用契约端点并按指定类型返回 JSON;优先使用上方生成的强类型 API。 / Calls a contract endpoint and decodes typed JSON.
@@ -67,7 +67,7 @@ export declare class LingyaAgentsUserClient {
67
67
  * @param bodyJson - 最终发送并参与签名的 UTF-8 JSON 字符串;无请求体时省略。
68
68
  * @param query - 已按最终顺序组装的查询参数,允许重复键。
69
69
  * @returns 调用方指定的响应类型。
70
- * @throws [LingyaApiError] 当服务端返回非 2xx 状态。
70
+ * @throws [ApiError] 当服务端返回非 2xx 状态。
71
71
  */
72
72
  /** @deprecated 使用对应的业务分组方法。 / Use the matching grouped facade operation. */
73
73
  request<T>(method: string, suffix: string, bodyJson?: string, query?: URLSearchParams): Promise<T>;
@@ -100,7 +100,7 @@ export declare class LingyaAgentsUserClient {
100
100
  * @returns 支持取消的异步事件序列;未知 type 保留 `rawJson`。
101
101
  */
102
102
  /** @deprecated 使用 `chat.streamChatEvents(conversationId, { messageId })`。 / Use the channel-bound chat facade. */
103
- streamChatEvents(conversationId: string, messageId: string): AsyncGenerator<LingyaAiChatBriefEvent>;
103
+ streamChatEvents(conversationId: string, messageId: string): AsyncGenerator<AiChatBriefEvent>;
104
104
  /**
105
105
  * 发送底层受控请求;调用前固定最终 path、query、Content-Type 与 body 字节。 / Sends an exactly signed low-level request.
106
106
  *
@@ -112,16 +112,22 @@ export declare class LingyaAgentsUserClient {
112
112
  * @param query - 最终查询参数;顺序和重复键均参与签名。
113
113
  * @param accept - 精确的 Accept 值,例如 `application/json`、`text/event-stream` 或 `text/csv`。
114
114
  * @returns 成功的原始 Fetch Response。
115
- * @throws [LingyaApiError] 当服务端返回非 2xx 状态。
115
+ * @throws [ApiError] 当服务端返回非 2xx 状态。
116
116
  */
117
117
  /** @deprecated 使用 `lowLevel`,或使用对应的业务分组方法。 / Use `lowLevel` or a grouped facade operation. */
118
118
  rawRequest(method: string, suffix: string, bodyJson?: string, query?: URLSearchParams, accept?: string, requestId?: string): Promise<Response>;
119
119
  }
120
120
  /** 不含凭证的 HTTP 错误。 / HTTP failure that never includes credentials. */
121
- export declare class LingyaApiError extends Error {
121
+ export declare class ApiError extends Error {
122
122
  readonly method: string;
123
123
  readonly path: string;
124
124
  readonly status: number;
125
125
  readonly responseBody: string;
126
126
  constructor(method: string, path: string, status: number, responseBody: string);
127
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/client.js CHANGED
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.LingyaApiError = exports.LingyaAgentsUserClient = exports.LingyaAgentsClient = void 0;
12
+ exports.LingyaApiError = exports.LingyaAgentsUserClient = exports.LingyaAgentsClient = exports.ApiError = exports.AgentsUserClient = exports.AgentsClient = void 0;
13
13
  const runtime_1 = require("./runtime");
14
14
  const apis_1 = require("./apis");
15
15
  const hmac_1 = require("./hmac");
@@ -19,7 +19,7 @@ const bound_1 = require("./bound");
19
19
  *
20
20
  * 客户端保存 channel 范围的凭证,但只有 [forUser] 创建的用户客户端可以发起请求。
21
21
  */
22
- class LingyaAgentsClient {
22
+ class AgentsClient {
23
23
  /**
24
24
  * 创建 channel 范围的客户端。 / Creates a channel-scoped client.
25
25
  *
@@ -43,12 +43,13 @@ class LingyaAgentsClient {
43
43
  forUser(externalUserId) {
44
44
  const signedFetch = (0, hmac_1.createSignedFetch)(this.credentials, externalUserId);
45
45
  const configuration = new runtime_1.Configuration({ basePath: this.baseUrl.replace(/\/+$/, ''), fetchApi: signedFetch });
46
- return new LingyaAgentsUserClient(this.channelId, configuration, signedFetch, this.baseUrl);
46
+ return new AgentsUserClient(this.channelId, configuration, signedFetch, this.baseUrl);
47
47
  }
48
48
  }
49
- exports.LingyaAgentsClient = LingyaAgentsClient;
49
+ exports.AgentsClient = AgentsClient;
50
+ exports.LingyaAgentsClient = AgentsClient;
50
51
  /** 已绑定外部用户的强类型 API 集合。 / Strongly typed API collection bound to one external user. */
51
- class LingyaAgentsUserClient {
52
+ class AgentsUserClient {
52
53
  constructor(channelId, configuration, signedFetch, baseUrl) {
53
54
  this.channelId = channelId;
54
55
  this.signedFetch = signedFetch;
@@ -63,18 +64,18 @@ class LingyaAgentsUserClient {
63
64
  const messages = new apis_1.MessagesApi(configuration);
64
65
  const sql = new apis_1.SQLApi(configuration);
65
66
  const workspace = new apis_1.WorkspaceApi(configuration);
66
- this.lowLevel = new bound_1.LingyaAgentsLowLevelApis(configurationApi, chat, conversations, sql, messages, events, interactions, files, knowledge, workspace);
67
+ this.lowLevel = new bound_1.AgentsLowLevelApis(configurationApi, chat, conversations, sql, messages, events, interactions, files, knowledge, workspace);
67
68
  const rawRequest = this.rawRequest.bind(this);
68
- this.chat = new bound_1.LingyaChatApi(channelId, chat, rawRequest);
69
- this.configuration = new bound_1.LingyaConfigurationApi(channelId, configurationApi);
70
- this.conversations = new bound_1.LingyaConversationsApi(channelId, conversations);
71
- this.events = new bound_1.LingyaEventsApi(channelId, events);
72
- this.files = new bound_1.LingyaFilesApi(channelId, files);
73
- this.interactions = new bound_1.LingyaInteractionsApi(channelId, interactions);
74
- this.knowledge = new bound_1.LingyaKnowledgeApi(channelId, knowledge);
75
- this.messages = new bound_1.LingyaMessagesApi(channelId, messages);
76
- this.sql = new bound_1.LingyaSqlApi(channelId, sql);
77
- this.workspace = new bound_1.LingyaWorkspaceApi(channelId, workspace);
69
+ this.chat = new bound_1.ChatApi(channelId, chat, rawRequest);
70
+ this.configuration = new bound_1.ConfigurationApi(channelId, configurationApi);
71
+ this.conversations = new bound_1.ConversationsApi(channelId, conversations);
72
+ this.events = new bound_1.EventsApi(channelId, events);
73
+ this.files = new bound_1.FilesApi(channelId, files);
74
+ this.interactions = new bound_1.InteractionsApi(channelId, interactions);
75
+ this.knowledge = new bound_1.KnowledgeApi(channelId, knowledge);
76
+ this.messages = new bound_1.MessagesApi(channelId, messages);
77
+ this.sql = new bound_1.SqlApi(channelId, sql);
78
+ this.workspace = new bound_1.WorkspaceApi(channelId, workspace);
78
79
  }
79
80
  /**
80
81
  * 调用契约端点并按指定类型返回 JSON;优先使用上方生成的强类型 API。 / Calls a contract endpoint and decodes typed JSON.
@@ -84,7 +85,7 @@ class LingyaAgentsUserClient {
84
85
  * @param bodyJson - 最终发送并参与签名的 UTF-8 JSON 字符串;无请求体时省略。
85
86
  * @param query - 已按最终顺序组装的查询参数,允许重复键。
86
87
  * @returns 调用方指定的响应类型。
87
- * @throws [LingyaApiError] 当服务端返回非 2xx 状态。
88
+ * @throws [ApiError] 当服务端返回非 2xx 状态。
88
89
  */
89
90
  /** @deprecated 使用对应的业务分组方法。 / Use the matching grouped facade operation. */
90
91
  request(method, suffix, bodyJson, query) {
@@ -145,7 +146,7 @@ class LingyaAgentsUserClient {
145
146
  * @param query - 最终查询参数;顺序和重复键均参与签名。
146
147
  * @param accept - 精确的 Accept 值,例如 `application/json`、`text/event-stream` 或 `text/csv`。
147
148
  * @returns 成功的原始 Fetch Response。
148
- * @throws [LingyaApiError] 当服务端返回非 2xx 状态。
149
+ * @throws [ApiError] 当服务端返回非 2xx 状态。
149
150
  */
150
151
  /** @deprecated 使用 `lowLevel`,或使用对应的业务分组方法。 / Use `lowLevel` or a grouped facade operation. */
151
152
  rawRequest(method_1, suffix_1, bodyJson_1, query_1) {
@@ -158,21 +159,23 @@ class LingyaAgentsUserClient {
158
159
  body: bodyJson,
159
160
  });
160
161
  if (!response.ok)
161
- throw new LingyaApiError(method, suffix, response.status, yield response.text());
162
+ throw new ApiError(method, suffix, response.status, yield response.text());
162
163
  return response;
163
164
  });
164
165
  }
165
166
  }
166
- exports.LingyaAgentsUserClient = LingyaAgentsUserClient;
167
+ exports.AgentsUserClient = AgentsUserClient;
168
+ exports.LingyaAgentsUserClient = AgentsUserClient;
167
169
  /** 不含凭证的 HTTP 错误。 / HTTP failure that never includes credentials. */
168
- class LingyaApiError extends Error {
170
+ class ApiError extends Error {
169
171
  constructor(method, path, status, responseBody) {
170
172
  super(`${method} ${path} returned HTTP ${status}`);
171
173
  this.method = method;
172
174
  this.path = path;
173
175
  this.status = status;
174
176
  this.responseBody = responseBody;
175
- this.name = 'LingyaApiError';
177
+ this.name = 'ApiError';
176
178
  }
177
179
  }
178
- exports.LingyaApiError = LingyaApiError;
180
+ exports.ApiError = ApiError;
181
+ exports.LingyaApiError = ApiError;