@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.
- package/LICENSE +202 -0
- package/dist/agent/index.d.mts +10 -10
- package/dist/agent/index.d.ts +10 -10
- package/dist/agent/index.js +94 -90
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/index.mjs +94 -90
- package/dist/agent/index.mjs.map +1 -1
- package/dist/{base-BOx3UzOl.d.mts → base-Bo8TzBQq.d.mts} +2 -2
- package/dist/{base-NX-knWOv.d.ts → base-Co-MzdN5.d.ts} +1 -1
- package/dist/{base-DYlBMCy_.d.mts → base-D9uCcDjZ.d.mts} +3 -3
- package/dist/{base-C7jwyH4Z.d.mts → base-Dh5vEBQD.d.mts} +1 -1
- package/dist/{base-Cwi4bjze.d.ts → base-TYjCCv7T.d.ts} +3 -3
- package/dist/{base-BoIps2RL.d.ts → base-t7G4uaR_.d.ts} +2 -2
- package/dist/{block-VsnHrllL.d.mts → block-7fd6byyN.d.mts} +2 -2
- package/dist/{block-VsnHrllL.d.ts → block-7fd6byyN.d.ts} +2 -2
- package/dist/event/index.d.mts +105 -89
- package/dist/event/index.d.ts +105 -89
- package/dist/event/index.js +8 -8
- package/dist/event/index.js.map +1 -1
- package/dist/event/index.mjs +8 -8
- package/dist/event/index.mjs.map +1 -1
- package/dist/formatter/index.d.mts +3 -3
- package/dist/formatter/index.d.ts +3 -3
- package/dist/formatter/index.js +17 -17
- package/dist/formatter/index.js.map +1 -1
- package/dist/formatter/index.mjs +17 -17
- package/dist/formatter/index.mjs.map +1 -1
- package/dist/{index-BTJDlKvQ.d.mts → index-BVNbIN62.d.mts} +1 -1
- package/dist/{index-BcatlwXQ.d.ts → index-DaopL-Vp.d.ts} +1 -1
- package/dist/mcp/index.d.mts +2 -2
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/index.mjs +1 -1
- package/dist/mcp/index.mjs.map +1 -1
- package/dist/message/index.d.mts +2 -2
- package/dist/message/index.d.ts +2 -2
- package/dist/message/index.js +39 -5
- package/dist/message/index.js.map +1 -1
- package/dist/message/index.mjs +36 -5
- package/dist/message/index.mjs.map +1 -1
- package/dist/{message-CkN21KaY.d.mts → message-CYnHiEVt.d.mts} +66 -43
- package/dist/{message-CzLeTlua.d.ts → message-DZN7LetB.d.ts} +66 -43
- package/dist/model/index.d.mts +5 -5
- package/dist/model/index.d.ts +5 -5
- package/dist/model/index.js +17 -17
- package/dist/model/index.js.map +1 -1
- package/dist/model/index.mjs +17 -17
- package/dist/model/index.mjs.map +1 -1
- package/dist/storage/index.d.mts +3 -3
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.js +4 -4
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/index.mjs +4 -4
- package/dist/storage/index.mjs.map +1 -1
- package/dist/tool/index.d.mts +4 -4
- package/dist/tool/index.d.ts +4 -4
- package/dist/{toolkit-CEpulFi0.d.ts → toolkit-BuMTkbGg.d.ts} +2 -2
- package/dist/{toolkit-CGEZSZPa.d.mts → toolkit-CH9qKAy9.d.mts} +2 -2
- package/package.json +87 -87
- package/src/agent/agent.test.ts +63 -63
- package/src/agent/agent.ts +101 -99
- package/src/agent/test-compression.ts +1 -1
- package/src/event/index.ts +96 -98
- package/src/formatter/base.ts +3 -3
- package/src/formatter/dashscope-chat-formatter.test.ts +8 -8
- package/src/formatter/dashscope-chat-formatter.ts +3 -3
- package/src/formatter/openai-chat-formatter.test.ts +4 -4
- package/src/formatter/openai-chat-formatter.ts +6 -6
- package/src/mcp/base.ts +1 -1
- package/src/message/block.ts +2 -2
- package/src/message/index.ts +9 -1
- package/src/message/message.test.ts +1 -1
- package/src/message/message.ts +101 -47
- package/src/permission/index.ts +13 -0
- package/src/storage/file-system.test.ts +3 -3
- package/src/storage/file-system.ts +4 -4
package/src/agent/agent.test.ts
CHANGED
|
@@ -93,7 +93,7 @@ describe('Human-in-the-loop', () => {
|
|
|
93
93
|
|
|
94
94
|
expect(lastEvent).toMatchObject({
|
|
95
95
|
type: EventType.REQUIRE_USER_CONFIRM,
|
|
96
|
-
|
|
96
|
+
tool_calls: [
|
|
97
97
|
{
|
|
98
98
|
type: 'tool_call',
|
|
99
99
|
id: '1',
|
|
@@ -112,7 +112,7 @@ describe('Human-in-the-loop', () => {
|
|
|
112
112
|
});
|
|
113
113
|
|
|
114
114
|
expect(await agent.toJSON()).toMatchObject({
|
|
115
|
-
|
|
115
|
+
reply_id: expect.any(String),
|
|
116
116
|
confirmedToolCallIds: [],
|
|
117
117
|
curIter: 0,
|
|
118
118
|
});
|
|
@@ -140,7 +140,7 @@ describe('Human-in-the-loop', () => {
|
|
|
140
140
|
metadata: {},
|
|
141
141
|
name: 'Friday',
|
|
142
142
|
role: 'assistant',
|
|
143
|
-
|
|
143
|
+
created_at: expect.any(String),
|
|
144
144
|
},
|
|
145
145
|
]);
|
|
146
146
|
|
|
@@ -148,13 +148,13 @@ describe('Human-in-the-loop', () => {
|
|
|
148
148
|
for await (const event of agent.replyStream({
|
|
149
149
|
event: {
|
|
150
150
|
id: 'xxx',
|
|
151
|
-
|
|
151
|
+
created_at: new Date().toISOString(),
|
|
152
152
|
type: EventType.USER_CONFIRM_RESULT,
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
reply_id: agent.replyId,
|
|
154
|
+
confirm_results: [
|
|
155
155
|
{
|
|
156
156
|
confirmed: true,
|
|
157
|
-
|
|
157
|
+
tool_call: {
|
|
158
158
|
type: 'tool_call',
|
|
159
159
|
id: '1',
|
|
160
160
|
name: 'Bash',
|
|
@@ -170,8 +170,8 @@ describe('Human-in-the-loop', () => {
|
|
|
170
170
|
// Verify the agent still yields user confirmation for the second tool call
|
|
171
171
|
expect(lastEvent).toMatchObject({
|
|
172
172
|
type: EventType.REQUIRE_USER_CONFIRM,
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
reply_id: expect.any(String),
|
|
174
|
+
tool_calls: [
|
|
175
175
|
{
|
|
176
176
|
type: 'tool_call',
|
|
177
177
|
id: '2',
|
|
@@ -219,13 +219,13 @@ describe('Human-in-the-loop', () => {
|
|
|
219
219
|
const res = agent.replyStream({
|
|
220
220
|
event: {
|
|
221
221
|
id: 'xxx',
|
|
222
|
-
|
|
222
|
+
created_at: new Date().toISOString(),
|
|
223
223
|
type: EventType.USER_CONFIRM_RESULT,
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
reply_id: agent.replyId,
|
|
225
|
+
confirm_results: [
|
|
226
226
|
{
|
|
227
227
|
confirmed: false,
|
|
228
|
-
|
|
228
|
+
tool_call: {
|
|
229
229
|
type: 'tool_call',
|
|
230
230
|
id: '2',
|
|
231
231
|
name: 'Bash',
|
|
@@ -249,9 +249,9 @@ describe('Human-in-the-loop', () => {
|
|
|
249
249
|
// Verify the lastEvent
|
|
250
250
|
expect(lastEvent).toMatchObject({
|
|
251
251
|
id: expect.any(String),
|
|
252
|
-
type: EventType.
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
type: EventType.REPLY_END,
|
|
253
|
+
created_at: expect.any(String),
|
|
254
|
+
reply_id: agent.replyId,
|
|
255
255
|
});
|
|
256
256
|
|
|
257
257
|
// Verify the final agent reply msg
|
|
@@ -267,7 +267,7 @@ describe('Human-in-the-loop', () => {
|
|
|
267
267
|
metadata: {},
|
|
268
268
|
name: 'Friday',
|
|
269
269
|
role: 'assistant',
|
|
270
|
-
|
|
270
|
+
created_at: expect.any(String),
|
|
271
271
|
});
|
|
272
272
|
});
|
|
273
273
|
|
|
@@ -330,7 +330,7 @@ describe('Human-in-the-loop', () => {
|
|
|
330
330
|
// Verify the agent emits REQUIRE_EXTERNAL_EXECUTION event
|
|
331
331
|
expect(lastEvent).toMatchObject({
|
|
332
332
|
type: EventType.REQUIRE_EXTERNAL_EXECUTION,
|
|
333
|
-
|
|
333
|
+
tool_calls: [
|
|
334
334
|
{
|
|
335
335
|
type: 'tool_call',
|
|
336
336
|
id: '1',
|
|
@@ -348,7 +348,7 @@ describe('Human-in-the-loop', () => {
|
|
|
348
348
|
|
|
349
349
|
// Verify agent state
|
|
350
350
|
expect(await agent.toJSON()).toMatchObject({
|
|
351
|
-
|
|
351
|
+
reply_id: expect.any(String),
|
|
352
352
|
confirmedToolCallIds: [],
|
|
353
353
|
curIter: 0,
|
|
354
354
|
});
|
|
@@ -374,7 +374,7 @@ describe('Human-in-the-loop', () => {
|
|
|
374
374
|
metadata: {},
|
|
375
375
|
name: 'Friday',
|
|
376
376
|
role: 'assistant',
|
|
377
|
-
|
|
377
|
+
created_at: expect.any(String),
|
|
378
378
|
},
|
|
379
379
|
]);
|
|
380
380
|
|
|
@@ -382,10 +382,10 @@ describe('Human-in-the-loop', () => {
|
|
|
382
382
|
for await (const event of agent.replyStream({
|
|
383
383
|
event: {
|
|
384
384
|
id: 'xxx',
|
|
385
|
-
|
|
385
|
+
created_at: new Date().toISOString(),
|
|
386
386
|
type: EventType.EXTERNAL_EXECUTION_RESULT,
|
|
387
|
-
|
|
388
|
-
|
|
387
|
+
reply_id: agent.replyId,
|
|
388
|
+
execution_results: [
|
|
389
389
|
{
|
|
390
390
|
type: 'tool_result',
|
|
391
391
|
id: '1',
|
|
@@ -408,8 +408,8 @@ describe('Human-in-the-loop', () => {
|
|
|
408
408
|
// Verify the agent still requires external execution for the second tool
|
|
409
409
|
expect(lastEvent).toMatchObject({
|
|
410
410
|
type: EventType.REQUIRE_EXTERNAL_EXECUTION,
|
|
411
|
-
|
|
412
|
-
|
|
411
|
+
reply_id: expect.any(String),
|
|
412
|
+
tool_calls: [
|
|
413
413
|
{
|
|
414
414
|
type: 'tool_call',
|
|
415
415
|
id: '2',
|
|
@@ -456,10 +456,10 @@ describe('Human-in-the-loop', () => {
|
|
|
456
456
|
const res = agent.replyStream({
|
|
457
457
|
event: {
|
|
458
458
|
id: 'xxx',
|
|
459
|
-
|
|
459
|
+
created_at: new Date().toISOString(),
|
|
460
460
|
type: EventType.EXTERNAL_EXECUTION_RESULT,
|
|
461
|
-
|
|
462
|
-
|
|
461
|
+
reply_id: agent.replyId,
|
|
462
|
+
execution_results: [
|
|
463
463
|
{
|
|
464
464
|
type: 'tool_result',
|
|
465
465
|
id: '2',
|
|
@@ -490,9 +490,9 @@ describe('Human-in-the-loop', () => {
|
|
|
490
490
|
// Verify the lastEvent is RUN_FINISHED
|
|
491
491
|
expect(lastEvent).toMatchObject({
|
|
492
492
|
id: expect.any(String),
|
|
493
|
-
type: EventType.
|
|
494
|
-
|
|
495
|
-
|
|
493
|
+
type: EventType.REPLY_END,
|
|
494
|
+
created_at: expect.any(String),
|
|
495
|
+
reply_id: agent.replyId,
|
|
496
496
|
});
|
|
497
497
|
|
|
498
498
|
// Verify the final agent reply msg
|
|
@@ -508,7 +508,7 @@ describe('Human-in-the-loop', () => {
|
|
|
508
508
|
metadata: {},
|
|
509
509
|
name: 'Friday',
|
|
510
510
|
role: 'assistant',
|
|
511
|
-
|
|
511
|
+
created_at: expect.any(String),
|
|
512
512
|
});
|
|
513
513
|
});
|
|
514
514
|
|
|
@@ -602,7 +602,7 @@ describe('Human-in-the-loop', () => {
|
|
|
602
602
|
// Verify the agent emits REQUIRE_EXTERNAL_EXECUTION event for the first tool
|
|
603
603
|
expect(lastEvent).toMatchObject({
|
|
604
604
|
type: EventType.REQUIRE_EXTERNAL_EXECUTION,
|
|
605
|
-
|
|
605
|
+
tool_calls: [
|
|
606
606
|
{
|
|
607
607
|
type: 'tool_call',
|
|
608
608
|
id: '1',
|
|
@@ -614,7 +614,7 @@ describe('Human-in-the-loop', () => {
|
|
|
614
614
|
|
|
615
615
|
// Verify agent state
|
|
616
616
|
expect(await agent.toJSON()).toMatchObject({
|
|
617
|
-
|
|
617
|
+
reply_id: expect.any(String),
|
|
618
618
|
confirmedToolCallIds: [],
|
|
619
619
|
curIter: 0,
|
|
620
620
|
});
|
|
@@ -623,10 +623,10 @@ describe('Human-in-the-loop', () => {
|
|
|
623
623
|
for await (const event of agent.replyStream({
|
|
624
624
|
event: {
|
|
625
625
|
id: 'xxx',
|
|
626
|
-
|
|
626
|
+
created_at: new Date().toISOString(),
|
|
627
627
|
type: EventType.EXTERNAL_EXECUTION_RESULT,
|
|
628
|
-
|
|
629
|
-
|
|
628
|
+
reply_id: agent.replyId,
|
|
629
|
+
execution_results: [
|
|
630
630
|
{
|
|
631
631
|
type: 'tool_result',
|
|
632
632
|
id: '1',
|
|
@@ -649,8 +649,8 @@ describe('Human-in-the-loop', () => {
|
|
|
649
649
|
// Verify the agent now requires user confirmation for the second tool
|
|
650
650
|
expect(lastEvent).toMatchObject({
|
|
651
651
|
type: EventType.REQUIRE_USER_CONFIRM,
|
|
652
|
-
|
|
653
|
-
|
|
652
|
+
reply_id: expect.any(String),
|
|
653
|
+
tool_calls: [
|
|
654
654
|
{
|
|
655
655
|
type: 'tool_call',
|
|
656
656
|
id: '2',
|
|
@@ -663,7 +663,7 @@ describe('Human-in-the-loop', () => {
|
|
|
663
663
|
|
|
664
664
|
// Verify agent state after external execution
|
|
665
665
|
expect(await agent.toJSON()).toMatchObject({
|
|
666
|
-
|
|
666
|
+
reply_id: expect.any(String),
|
|
667
667
|
confirmedToolCallIds: [],
|
|
668
668
|
curIter: 0,
|
|
669
669
|
});
|
|
@@ -681,13 +681,13 @@ describe('Human-in-the-loop', () => {
|
|
|
681
681
|
for await (const event of agent.replyStream({
|
|
682
682
|
event: {
|
|
683
683
|
id: 'xxx',
|
|
684
|
-
|
|
684
|
+
created_at: new Date().toISOString(),
|
|
685
685
|
type: EventType.USER_CONFIRM_RESULT,
|
|
686
|
-
|
|
687
|
-
|
|
686
|
+
reply_id: agent.replyId,
|
|
687
|
+
confirm_results: [
|
|
688
688
|
{
|
|
689
689
|
confirmed: true,
|
|
690
|
-
|
|
690
|
+
tool_call: {
|
|
691
691
|
type: 'tool_call',
|
|
692
692
|
id: '2',
|
|
693
693
|
name: 'ConfirmTool',
|
|
@@ -703,9 +703,9 @@ describe('Human-in-the-loop', () => {
|
|
|
703
703
|
// Verify the lastEvent is RUN_FINISHED
|
|
704
704
|
expect(lastEvent).toMatchObject({
|
|
705
705
|
id: expect.any(String),
|
|
706
|
-
type: EventType.
|
|
707
|
-
|
|
708
|
-
|
|
706
|
+
type: EventType.REPLY_END,
|
|
707
|
+
created_at: expect.any(String),
|
|
708
|
+
reply_id: agent.replyId,
|
|
709
709
|
});
|
|
710
710
|
|
|
711
711
|
// Verify the agent context includes all three tool calls, their results, and the final text
|
|
@@ -841,7 +841,7 @@ describe('Human-in-the-loop', () => {
|
|
|
841
841
|
// Verify the agent emits REQUIRE_USER_CONFIRM event for both tools
|
|
842
842
|
expect(lastEvent).toMatchObject({
|
|
843
843
|
type: EventType.REQUIRE_USER_CONFIRM,
|
|
844
|
-
|
|
844
|
+
tool_calls: [
|
|
845
845
|
{
|
|
846
846
|
type: 'tool_call',
|
|
847
847
|
id: '1',
|
|
@@ -861,7 +861,7 @@ describe('Human-in-the-loop', () => {
|
|
|
861
861
|
|
|
862
862
|
// Verify agent state
|
|
863
863
|
expect(await agent.toJSON()).toMatchObject({
|
|
864
|
-
|
|
864
|
+
reply_id: expect.any(String),
|
|
865
865
|
confirmedToolCallIds: [],
|
|
866
866
|
curIter: 0,
|
|
867
867
|
});
|
|
@@ -870,13 +870,13 @@ describe('Human-in-the-loop', () => {
|
|
|
870
870
|
for await (const event of agent.replyStream({
|
|
871
871
|
event: {
|
|
872
872
|
id: 'xxx',
|
|
873
|
-
|
|
873
|
+
created_at: new Date().toISOString(),
|
|
874
874
|
type: EventType.USER_CONFIRM_RESULT,
|
|
875
|
-
|
|
876
|
-
|
|
875
|
+
reply_id: agent.replyId,
|
|
876
|
+
confirm_results: [
|
|
877
877
|
{
|
|
878
878
|
confirmed: true,
|
|
879
|
-
|
|
879
|
+
tool_call: {
|
|
880
880
|
type: 'tool_call',
|
|
881
881
|
id: '1',
|
|
882
882
|
name: 'ExternalAndConfirmTool',
|
|
@@ -885,7 +885,7 @@ describe('Human-in-the-loop', () => {
|
|
|
885
885
|
},
|
|
886
886
|
{
|
|
887
887
|
confirmed: true,
|
|
888
|
-
|
|
888
|
+
tool_call: {
|
|
889
889
|
type: 'tool_call',
|
|
890
890
|
id: '2',
|
|
891
891
|
name: 'ConfirmOnlyTool',
|
|
@@ -901,8 +901,8 @@ describe('Human-in-the-loop', () => {
|
|
|
901
901
|
// After user confirmation, the first tool requires external execution
|
|
902
902
|
expect(lastEvent).toMatchObject({
|
|
903
903
|
type: EventType.REQUIRE_EXTERNAL_EXECUTION,
|
|
904
|
-
|
|
905
|
-
|
|
904
|
+
reply_id: expect.any(String),
|
|
905
|
+
tool_calls: [
|
|
906
906
|
{
|
|
907
907
|
type: 'tool_call',
|
|
908
908
|
id: '1',
|
|
@@ -914,7 +914,7 @@ describe('Human-in-the-loop', () => {
|
|
|
914
914
|
|
|
915
915
|
// Verify agent state after user confirmation
|
|
916
916
|
expect(await agent.toJSON()).toMatchObject({
|
|
917
|
-
|
|
917
|
+
reply_id: expect.any(String),
|
|
918
918
|
confirmedToolCallIds: ['1', '2'],
|
|
919
919
|
curIter: 0,
|
|
920
920
|
});
|
|
@@ -944,10 +944,10 @@ describe('Human-in-the-loop', () => {
|
|
|
944
944
|
for await (const event of agent.replyStream({
|
|
945
945
|
event: {
|
|
946
946
|
id: 'xxx',
|
|
947
|
-
|
|
947
|
+
created_at: new Date().toISOString(),
|
|
948
948
|
type: EventType.EXTERNAL_EXECUTION_RESULT,
|
|
949
|
-
|
|
950
|
-
|
|
949
|
+
reply_id: agent.replyId,
|
|
950
|
+
execution_results: [
|
|
951
951
|
{
|
|
952
952
|
type: 'tool_result',
|
|
953
953
|
id: '1',
|
|
@@ -971,9 +971,9 @@ describe('Human-in-the-loop', () => {
|
|
|
971
971
|
// because it was already confirmed in the previous step
|
|
972
972
|
expect(lastEvent).toMatchObject({
|
|
973
973
|
id: expect.any(String),
|
|
974
|
-
type: EventType.
|
|
975
|
-
|
|
976
|
-
|
|
974
|
+
type: EventType.REPLY_END,
|
|
975
|
+
created_at: expect.any(String),
|
|
976
|
+
reply_id: agent.replyId,
|
|
977
977
|
});
|
|
978
978
|
|
|
979
979
|
// Verify the final agent context includes all tool calls, their results, and the final text
|