@agentscope-ai/agentscope 0.0.2 → 0.0.3

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.
Files changed (77) hide show
  1. package/LICENSE +202 -0
  2. package/dist/agent/index.d.mts +10 -10
  3. package/dist/agent/index.d.ts +10 -10
  4. package/dist/agent/index.js +94 -90
  5. package/dist/agent/index.js.map +1 -1
  6. package/dist/agent/index.mjs +94 -90
  7. package/dist/agent/index.mjs.map +1 -1
  8. package/dist/{base-BOx3UzOl.d.mts → base-Bo8TzBQq.d.mts} +2 -2
  9. package/dist/{base-NX-knWOv.d.ts → base-Co-MzdN5.d.ts} +1 -1
  10. package/dist/{base-DYlBMCy_.d.mts → base-D9uCcDjZ.d.mts} +3 -3
  11. package/dist/{base-C7jwyH4Z.d.mts → base-Dh5vEBQD.d.mts} +1 -1
  12. package/dist/{base-Cwi4bjze.d.ts → base-TYjCCv7T.d.ts} +3 -3
  13. package/dist/{base-BoIps2RL.d.ts → base-t7G4uaR_.d.ts} +2 -2
  14. package/dist/{block-VsnHrllL.d.mts → block-7fd6byyN.d.mts} +2 -2
  15. package/dist/{block-VsnHrllL.d.ts → block-7fd6byyN.d.ts} +2 -2
  16. package/dist/event/index.d.mts +105 -89
  17. package/dist/event/index.d.ts +105 -89
  18. package/dist/event/index.js +8 -8
  19. package/dist/event/index.js.map +1 -1
  20. package/dist/event/index.mjs +8 -8
  21. package/dist/event/index.mjs.map +1 -1
  22. package/dist/formatter/index.d.mts +3 -3
  23. package/dist/formatter/index.d.ts +3 -3
  24. package/dist/formatter/index.js +17 -17
  25. package/dist/formatter/index.js.map +1 -1
  26. package/dist/formatter/index.mjs +17 -17
  27. package/dist/formatter/index.mjs.map +1 -1
  28. package/dist/{index-BTJDlKvQ.d.mts → index-BVNbIN62.d.mts} +1 -1
  29. package/dist/{index-BcatlwXQ.d.ts → index-DaopL-Vp.d.ts} +1 -1
  30. package/dist/mcp/index.d.mts +2 -2
  31. package/dist/mcp/index.d.ts +2 -2
  32. package/dist/mcp/index.js +1 -1
  33. package/dist/mcp/index.js.map +1 -1
  34. package/dist/mcp/index.mjs +1 -1
  35. package/dist/mcp/index.mjs.map +1 -1
  36. package/dist/message/index.d.mts +2 -2
  37. package/dist/message/index.d.ts +2 -2
  38. package/dist/message/index.js +39 -5
  39. package/dist/message/index.js.map +1 -1
  40. package/dist/message/index.mjs +36 -5
  41. package/dist/message/index.mjs.map +1 -1
  42. package/dist/{message-CkN21KaY.d.mts → message-CYnHiEVt.d.mts} +66 -43
  43. package/dist/{message-CzLeTlua.d.ts → message-DZN7LetB.d.ts} +66 -43
  44. package/dist/model/index.d.mts +5 -5
  45. package/dist/model/index.d.ts +5 -5
  46. package/dist/model/index.js +17 -17
  47. package/dist/model/index.js.map +1 -1
  48. package/dist/model/index.mjs +17 -17
  49. package/dist/model/index.mjs.map +1 -1
  50. package/dist/storage/index.d.mts +3 -3
  51. package/dist/storage/index.d.ts +3 -3
  52. package/dist/storage/index.js +4 -4
  53. package/dist/storage/index.js.map +1 -1
  54. package/dist/storage/index.mjs +4 -4
  55. package/dist/storage/index.mjs.map +1 -1
  56. package/dist/tool/index.d.mts +4 -4
  57. package/dist/tool/index.d.ts +4 -4
  58. package/dist/{toolkit-CEpulFi0.d.ts → toolkit-BuMTkbGg.d.ts} +2 -2
  59. package/dist/{toolkit-CGEZSZPa.d.mts → toolkit-CH9qKAy9.d.mts} +2 -2
  60. package/package.json +87 -87
  61. package/src/agent/agent.test.ts +63 -63
  62. package/src/agent/agent.ts +101 -99
  63. package/src/agent/test-compression.ts +1 -1
  64. package/src/event/index.ts +96 -98
  65. package/src/formatter/base.ts +3 -3
  66. package/src/formatter/dashscope-chat-formatter.test.ts +8 -8
  67. package/src/formatter/dashscope-chat-formatter.ts +3 -3
  68. package/src/formatter/openai-chat-formatter.test.ts +4 -4
  69. package/src/formatter/openai-chat-formatter.ts +6 -6
  70. package/src/mcp/base.ts +1 -1
  71. package/src/message/block.ts +2 -2
  72. package/src/message/index.ts +9 -1
  73. package/src/message/message.test.ts +1 -1
  74. package/src/message/message.ts +101 -47
  75. package/src/permission/index.ts +13 -0
  76. package/src/storage/file-system.test.ts +3 -3
  77. package/src/storage/file-system.ts +4 -4
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Alibaba
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -1,13 +1,13 @@
1
1
  import { z } from 'zod';
2
- import { M as Msg } from '../message-CkN21KaY.mjs';
3
- import { b as ToolCallBlock, C as ContentBlock, c as ToolResultBlock } from '../block-VsnHrllL.mjs';
4
- import { C as ChatModelBase, a as ChatUsage, b as ChatResponse } from '../base-DYlBMCy_.mjs';
5
- import { a as ToolResponse } from '../index-BTJDlKvQ.mjs';
6
- import { T as Toolkit } from '../toolkit-CGEZSZPa.mjs';
7
- import { UserConfirmResultEvent, ExternalExecutionResultEvent, AgentEvent, EventType, ToolResultTextDeltaEvent, ToolResultBinaryDeltaEvent, ToolResultEndEvent } from '../event/index.mjs';
2
+ import { M as Msg } from '../message-CYnHiEVt.mjs';
3
+ import { b as ToolCallBlock, C as ContentBlock, c as ToolResultBlock } from '../block-7fd6byyN.mjs';
4
+ import { C as ChatModelBase, a as ChatUsage, b as ChatResponse } from '../base-D9uCcDjZ.mjs';
5
+ import { a as ToolResponse } from '../index-BVNbIN62.mjs';
6
+ import { T as Toolkit } from '../toolkit-CH9qKAy9.mjs';
7
+ import { UserConfirmResultEvent, ExternalExecutionResultEvent, AgentEvent, EventType, ToolResultTextDeltaEvent, ToolResultDataDeltaEvent, ToolResultEndEvent } from '../event/index.mjs';
8
8
  import { a as ToolChoice } from '../index-CAxQAkiP.mjs';
9
- import { S as StorageBase } from '../base-C7jwyH4Z.mjs';
10
- import '../base-BOx3UzOl.mjs';
9
+ import { S as StorageBase } from '../base-Dh5vEBQD.mjs';
10
+ import '../base-Bo8TzBQq.mjs';
11
11
  import '@modelcontextprotocol/sdk/client/index.js';
12
12
  import '@modelcontextprotocol/sdk/client/sse.js';
13
13
  import '@modelcontextprotocol/sdk/client/streamableHttp.js';
@@ -207,13 +207,13 @@ declare class Agent {
207
207
  * @param toolRes - The tool response containing result content blocks.
208
208
  * @returns An async generator that yields tool result events.
209
209
  */
210
- protected convertToolResponseToEvent(toolCall: ToolCallBlock, toolRes: ToolResponse): AsyncGenerator<ToolResultTextDeltaEvent | ToolResultBinaryDeltaEvent | ToolResultEndEvent, void, unknown>;
210
+ protected convertToolResponseToEvent(toolCall: ToolCallBlock, toolRes: ToolResponse): AsyncGenerator<ToolResultTextDeltaEvent | ToolResultDataDeltaEvent | ToolResultEndEvent, void, unknown>;
211
211
  /**
212
212
  * Convert the agent instance to a JSON-serializable object.
213
213
  * @returns An object containing the agent's name and system prompt.
214
214
  */
215
215
  toJSON(): Promise<{
216
- replyId: string;
216
+ reply_id: string;
217
217
  confirmedToolCallIds: string[];
218
218
  curIter: number;
219
219
  }>;
@@ -1,13 +1,13 @@
1
1
  import { z } from 'zod';
2
- import { M as Msg } from '../message-CzLeTlua.js';
3
- import { b as ToolCallBlock, C as ContentBlock, c as ToolResultBlock } from '../block-VsnHrllL.js';
4
- import { C as ChatModelBase, a as ChatUsage, b as ChatResponse } from '../base-Cwi4bjze.js';
5
- import { a as ToolResponse } from '../index-BcatlwXQ.js';
6
- import { T as Toolkit } from '../toolkit-CEpulFi0.js';
7
- import { UserConfirmResultEvent, ExternalExecutionResultEvent, AgentEvent, EventType, ToolResultTextDeltaEvent, ToolResultBinaryDeltaEvent, ToolResultEndEvent } from '../event/index.js';
2
+ import { M as Msg } from '../message-DZN7LetB.js';
3
+ import { b as ToolCallBlock, C as ContentBlock, c as ToolResultBlock } from '../block-7fd6byyN.js';
4
+ import { C as ChatModelBase, a as ChatUsage, b as ChatResponse } from '../base-TYjCCv7T.js';
5
+ import { a as ToolResponse } from '../index-DaopL-Vp.js';
6
+ import { T as Toolkit } from '../toolkit-BuMTkbGg.js';
7
+ import { UserConfirmResultEvent, ExternalExecutionResultEvent, AgentEvent, EventType, ToolResultTextDeltaEvent, ToolResultDataDeltaEvent, ToolResultEndEvent } from '../event/index.js';
8
8
  import { a as ToolChoice } from '../index-CAxQAkiP.js';
9
- import { S as StorageBase } from '../base-NX-knWOv.js';
10
- import '../base-BoIps2RL.js';
9
+ import { S as StorageBase } from '../base-Co-MzdN5.js';
10
+ import '../base-t7G4uaR_.js';
11
11
  import '@modelcontextprotocol/sdk/client/index.js';
12
12
  import '@modelcontextprotocol/sdk/client/sse.js';
13
13
  import '@modelcontextprotocol/sdk/client/streamableHttp.js';
@@ -207,13 +207,13 @@ declare class Agent {
207
207
  * @param toolRes - The tool response containing result content blocks.
208
208
  * @returns An async generator that yields tool result events.
209
209
  */
210
- protected convertToolResponseToEvent(toolCall: ToolCallBlock, toolRes: ToolResponse): AsyncGenerator<ToolResultTextDeltaEvent | ToolResultBinaryDeltaEvent | ToolResultEndEvent, void, unknown>;
210
+ protected convertToolResponseToEvent(toolCall: ToolCallBlock, toolRes: ToolResponse): AsyncGenerator<ToolResultTextDeltaEvent | ToolResultDataDeltaEvent | ToolResultEndEvent, void, unknown>;
211
211
  /**
212
212
  * Convert the agent instance to a JSON-serializable object.
213
213
  * @returns An object containing the agent's name and system prompt.
214
214
  */
215
215
  toJSON(): Promise<{
216
- replyId: string;
216
+ reply_id: string;
217
217
  confirmedToolCallIds: string[];
218
218
  curIter: number;
219
219
  }>;
@@ -44,10 +44,12 @@ function createMsg({
44
44
  role,
45
45
  metadata = {},
46
46
  id = crypto.randomUUID(),
47
- timestamp = (/* @__PURE__ */ new Date()).toISOString(),
47
+ created_at = (/* @__PURE__ */ new Date()).toISOString(),
48
+ finished_at,
48
49
  usage
49
50
  }) {
50
- return { id, name, role, content, metadata, timestamp, usage };
51
+ const contentBlocks = typeof content === "string" ? [{ id: crypto.randomUUID(), type: "text", text: content }] : content;
52
+ return { id, name, role, content: contentBlocks, metadata, created_at, finished_at, usage };
51
53
  }
52
54
  function getContentBlocks(msg, blockType) {
53
55
  if (!blockType) return msg.content;
@@ -706,7 +708,7 @@ var Agent = class {
706
708
  agentId: this.name,
707
709
  context: this.context,
708
710
  metadata: {
709
- replyId: this.replyId,
711
+ reply_id: this.replyId,
710
712
  curIter: this.curIter,
711
713
  curSummary: this.curSummary
712
714
  }
@@ -862,46 +864,46 @@ var Agent = class {
862
864
  }
863
865
  const event = options.event;
864
866
  if (event.type === "EXTERNAL_EXECUTION_RESULT" /* EXTERNAL_EXECUTION_RESULT */) {
865
- this._saveToContext(event.executionResults);
867
+ this._saveToContext(event.execution_results);
866
868
  } else if (event.type === "USER_CONFIRM_RESULT" /* USER_CONFIRM_RESULT */) {
867
- for (const result of event.confirmResults) {
869
+ for (const result of event.confirm_results) {
868
870
  if (result.confirmed) {
869
- this.confirmedToolCallIds.push(result.toolCall.id);
871
+ this.confirmedToolCallIds.push(result.tool_call.id);
870
872
  } else {
871
- const rejectionRes = `<system-info>**Note** the user rejected the execution of tool "${result.toolCall.name}"!</system-info>`;
873
+ const rejectionRes = `<system-info>**Note** the user rejected the execution of tool "${result.tool_call.name}"!</system-info>`;
872
874
  yield {
873
875
  id: crypto.randomUUID(),
874
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
876
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
875
877
  type: "TOOL_RESULT_START" /* TOOL_RESULT_START */,
876
- replyId: this.replyId,
877
- toolCallId: result.toolCall.id
878
+ reply_id: this.replyId,
879
+ tool_call_id: result.tool_call.id
878
880
  };
879
881
  yield {
880
882
  id: crypto.randomUUID(),
881
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
883
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
882
884
  type: "TOOL_RESULT_TEXT_DELTA" /* TOOL_RESULT_TEXT_DELTA */,
883
- replyId: this.replyId,
884
- toolCallId: result.toolCall.id,
885
+ reply_id: this.replyId,
886
+ tool_call_id: result.tool_call.id,
885
887
  delta: rejectionRes
886
888
  };
887
889
  yield {
888
890
  id: crypto.randomUUID(),
889
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
891
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
890
892
  type: "TOOL_RESULT_END" /* TOOL_RESULT_END */,
891
- replyId: this.replyId,
892
- toolCallId: result.toolCall.id,
893
+ reply_id: this.replyId,
894
+ tool_call_id: result.tool_call.id,
893
895
  state: "interrupted"
894
896
  };
895
897
  this._saveToContext([
896
898
  {
897
899
  type: "tool_result",
898
- id: result.toolCall.id,
899
- name: result.toolCall.name,
900
+ id: result.tool_call.id,
901
+ name: result.tool_call.name,
900
902
  output: [
901
903
  {
902
904
  id: crypto.randomUUID(),
903
905
  type: "text",
904
- text: `<system-info>**Note** the user rejected the execution of tool "${result.toolCall.name}"!</system-info>`
906
+ text: `<system-info>**Note** the user rejected the execution of tool "${result.tool_call.name}"!</system-info>`
905
907
  }
906
908
  ],
907
909
  state: "interrupted"
@@ -909,7 +911,9 @@ var Agent = class {
909
911
  ]);
910
912
  }
911
913
  }
912
- const processedToolCallIds = event.confirmResults.map((result) => result.toolCall.id);
914
+ const processedToolCallIds = event.confirm_results.map(
915
+ (result) => result.tool_call.id
916
+ );
913
917
  this.context.at(-1)?.content.forEach((content) => {
914
918
  if (content.type === "tool_call" && processedToolCallIds.includes(content.id)) {
915
919
  delete content.awaitUserConfirmation;
@@ -922,10 +926,10 @@ var Agent = class {
922
926
  this.confirmedToolCallIds = [];
923
927
  yield {
924
928
  id: crypto.randomUUID(),
925
- type: "RUN_STARTED" /* RUN_STARTED */,
926
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
927
- sessionId: "",
928
- replyId: this.replyId,
929
+ type: "REPLY_START" /* REPLY_START */,
930
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
931
+ session_id: "",
932
+ reply_id: this.replyId,
929
933
  name: this.name,
930
934
  role: "assistant"
931
935
  };
@@ -953,10 +957,10 @@ var Agent = class {
953
957
  if (awaitingType) {
954
958
  yield {
955
959
  id: crypto.randomUUID(),
956
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
960
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
957
961
  type: awaitingType,
958
- replyId: this.replyId,
959
- toolCalls: awaitingToolCalls
962
+ reply_id: this.replyId,
963
+ tool_calls: awaitingToolCalls
960
964
  };
961
965
  return createMsg({
962
966
  name: this.name,
@@ -979,10 +983,10 @@ var Agent = class {
979
983
  }
980
984
  yield {
981
985
  id: crypto.randomUUID(),
982
- type: "RUN_FINISHED" /* RUN_FINISHED */,
983
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
984
- sessionId: "",
985
- replyId: this.replyId
986
+ type: "REPLY_END" /* REPLY_END */,
987
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
988
+ session_id: "",
989
+ reply_id: this.replyId
986
990
  };
987
991
  return createMsg({
988
992
  id: this.replyId,
@@ -1004,10 +1008,10 @@ var Agent = class {
1004
1008
  const tools = this.toolkit.getJSONSchemas();
1005
1009
  yield {
1006
1010
  id: crypto.randomUUID(),
1007
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1008
- type: "MODEL_CALL_STARTED" /* MODEL_CALL_STARTED */,
1009
- replyId: this.replyId,
1010
- modelName: this.model.modelName
1011
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1012
+ type: "MODEL_CALL_START" /* MODEL_CALL_START */,
1013
+ reply_id: this.replyId,
1014
+ model_name: this.model.modelName
1011
1015
  };
1012
1016
  const res = await this.model.call({
1013
1017
  messages: [
@@ -1053,39 +1057,39 @@ var Agent = class {
1053
1057
  if (blockIds.textBlockId) {
1054
1058
  yield {
1055
1059
  id: crypto.randomUUID(),
1056
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1060
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1057
1061
  type: "TEXT_BLOCK_END" /* TEXT_BLOCK_END */,
1058
- replyId: this.replyId,
1059
- blockId: blockIds.textBlockId
1062
+ reply_id: this.replyId,
1063
+ block_id: blockIds.textBlockId
1060
1064
  };
1061
1065
  }
1062
1066
  if (blockIds.thinkingBlockId) {
1063
1067
  yield {
1064
1068
  id: crypto.randomUUID(),
1065
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1069
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1066
1070
  type: "THINKING_BLOCK_END" /* THINKING_BLOCK_END */,
1067
- replyId: this.replyId,
1068
- blockId: blockIds.thinkingBlockId
1071
+ reply_id: this.replyId,
1072
+ block_id: blockIds.thinkingBlockId
1069
1073
  };
1070
1074
  }
1071
1075
  if (blockIds.toolCallIds.length > 0) {
1072
- for (const toolCallId of blockIds.toolCallIds) {
1076
+ for (const tool_call_id of blockIds.toolCallIds) {
1073
1077
  yield {
1074
1078
  id: crypto.randomUUID(),
1075
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1079
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1076
1080
  type: "TOOL_CALL_END" /* TOOL_CALL_END */,
1077
- replyId: this.replyId,
1078
- toolCallId
1081
+ reply_id: this.replyId,
1082
+ tool_call_id
1079
1083
  };
1080
1084
  }
1081
1085
  }
1082
1086
  yield {
1083
1087
  id: crypto.randomUUID(),
1084
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1085
- type: "MODEL_CALL_ENDED" /* MODEL_CALL_ENDED */,
1086
- replyId: this.replyId,
1087
- inputTokens: completedResponse.usage?.inputTokens || 0,
1088
- outputTokens: completedResponse.usage?.outputTokens || 0
1088
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1089
+ type: "MODEL_CALL_END" /* MODEL_CALL_END */,
1090
+ reply_id: this.replyId,
1091
+ input_tokens: completedResponse.usage?.inputTokens || 0,
1092
+ output_tokens: completedResponse.usage?.outputTokens || 0
1089
1093
  };
1090
1094
  return completedResponse;
1091
1095
  }
@@ -1101,10 +1105,10 @@ var Agent = class {
1101
1105
  yield {
1102
1106
  type: "TOOL_RESULT_START" /* TOOL_RESULT_START */,
1103
1107
  id: crypto.randomUUID(),
1104
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1105
- replyId: this.replyId,
1106
- toolCallId: options.toolCall.id,
1107
- toolCallName: options.toolCall.name
1108
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1109
+ reply_id: this.replyId,
1110
+ tool_call_id: options.toolCall.id,
1111
+ tool_call_name: options.toolCall.name
1108
1112
  };
1109
1113
  while (true) {
1110
1114
  const { value, done } = await res.next();
@@ -1156,18 +1160,18 @@ var Agent = class {
1156
1160
  responseId.textBlockId = crypto.randomUUID();
1157
1161
  yield {
1158
1162
  id: crypto.randomUUID(),
1159
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1163
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1160
1164
  type: "TEXT_BLOCK_START" /* TEXT_BLOCK_START */,
1161
- replyId: this.replyId,
1162
- blockId: responseId.textBlockId
1165
+ reply_id: this.replyId,
1166
+ block_id: responseId.textBlockId
1163
1167
  };
1164
1168
  }
1165
1169
  yield {
1166
1170
  id: crypto.randomUUID(),
1167
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1171
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1168
1172
  type: "TEXT_BLOCK_DELTA" /* TEXT_BLOCK_DELTA */,
1169
- replyId: this.replyId,
1170
- blockId: responseId.textBlockId,
1173
+ reply_id: this.replyId,
1174
+ block_id: responseId.textBlockId,
1171
1175
  delta: block.text
1172
1176
  };
1173
1177
  break;
@@ -1176,18 +1180,18 @@ var Agent = class {
1176
1180
  responseId.thinkingBlockId = crypto.randomUUID();
1177
1181
  yield {
1178
1182
  id: crypto.randomUUID(),
1179
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1183
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1180
1184
  type: "THINKING_BLOCK_START" /* THINKING_BLOCK_START */,
1181
- replyId: this.replyId,
1182
- blockId: responseId.thinkingBlockId
1185
+ reply_id: this.replyId,
1186
+ block_id: responseId.thinkingBlockId
1183
1187
  };
1184
1188
  }
1185
1189
  yield {
1186
1190
  id: crypto.randomUUID(),
1187
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1191
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1188
1192
  type: "THINKING_BLOCK_DELTA" /* THINKING_BLOCK_DELTA */,
1189
- replyId: this.replyId,
1190
- blockId: responseId.thinkingBlockId,
1193
+ reply_id: this.replyId,
1194
+ block_id: responseId.thinkingBlockId,
1191
1195
  delta: block.thinking
1192
1196
  };
1193
1197
  break;
@@ -1197,19 +1201,19 @@ var Agent = class {
1197
1201
  yield {
1198
1202
  id: crypto.randomUUID(),
1199
1203
  type: "TOOL_CALL_START" /* TOOL_CALL_START */,
1200
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1201
- replyId: this.replyId,
1202
- toolCallId: block.id,
1203
- toolCallName: block.name
1204
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1205
+ reply_id: this.replyId,
1206
+ tool_call_id: block.id,
1207
+ tool_call_name: block.name
1204
1208
  };
1205
1209
  }
1206
1210
  yield {
1207
1211
  id: crypto.randomUUID(),
1208
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1212
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1209
1213
  type: "TOOL_CALL_DELTA" /* TOOL_CALL_DELTA */,
1210
1214
  delta: block.input,
1211
- replyId: this.replyId,
1212
- toolCallId: block.id
1215
+ reply_id: this.replyId,
1216
+ tool_call_id: block.id
1213
1217
  };
1214
1218
  }
1215
1219
  }
@@ -1228,10 +1232,10 @@ var Agent = class {
1228
1232
  case "text":
1229
1233
  yield {
1230
1234
  id: crypto.randomUUID(),
1231
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1235
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1232
1236
  type: "TOOL_RESULT_TEXT_DELTA" /* TOOL_RESULT_TEXT_DELTA */,
1233
- replyId: this.replyId,
1234
- toolCallId: toolCall.id,
1237
+ reply_id: this.replyId,
1238
+ tool_call_id: toolCall.id,
1235
1239
  delta: block.text
1236
1240
  };
1237
1241
  break;
@@ -1239,21 +1243,21 @@ var Agent = class {
1239
1243
  if (block.source.type === "base64") {
1240
1244
  yield {
1241
1245
  id: crypto.randomUUID(),
1242
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1243
- type: "TOOL_RESULT_BINARY_DELTA" /* TOOL_RESULT_BINARY_DELTA */,
1244
- replyId: this.replyId,
1245
- toolCallId: toolCall.id,
1246
- mediaType: block.source.mediaType,
1246
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1247
+ type: "TOOL_RESULT_DATA_DELTA" /* TOOL_RESULT_DATA_DELTA */,
1248
+ reply_id: this.replyId,
1249
+ tool_call_id: toolCall.id,
1250
+ media_type: block.source.media_type,
1247
1251
  data: block.source.data
1248
1252
  };
1249
1253
  } else if (block.source.type === "url") {
1250
1254
  yield {
1251
1255
  id: crypto.randomUUID(),
1252
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1253
- type: "TOOL_RESULT_BINARY_DELTA" /* TOOL_RESULT_BINARY_DELTA */,
1254
- replyId: this.replyId,
1255
- toolCallId: toolCall.id,
1256
- mediaType: block.source.mediaType,
1256
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1257
+ type: "TOOL_RESULT_DATA_DELTA" /* TOOL_RESULT_DATA_DELTA */,
1258
+ reply_id: this.replyId,
1259
+ tool_call_id: toolCall.id,
1260
+ media_type: block.source.media_type,
1257
1261
  url: block.source.url
1258
1262
  };
1259
1263
  }
@@ -1262,10 +1266,10 @@ var Agent = class {
1262
1266
  }
1263
1267
  yield {
1264
1268
  id: crypto.randomUUID(),
1265
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1269
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
1266
1270
  type: "TOOL_RESULT_END" /* TOOL_RESULT_END */,
1267
- replyId: this.replyId,
1268
- toolCallId: toolCall.id,
1271
+ reply_id: this.replyId,
1272
+ tool_call_id: toolCall.id,
1269
1273
  state: toolRes.state
1270
1274
  };
1271
1275
  }
@@ -1275,7 +1279,7 @@ var Agent = class {
1275
1279
  */
1276
1280
  async toJSON() {
1277
1281
  return {
1278
- replyId: this.replyId,
1282
+ reply_id: this.replyId,
1279
1283
  confirmedToolCallIds: this.confirmedToolCallIds,
1280
1284
  curIter: this.curIter
1281
1285
  };