@agentscope-ai/agentscope 0.0.3 → 0.0.5
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/agent/index.d.mts +7 -7
- package/dist/agent/index.d.ts +7 -7
- package/dist/agent/index.js +14 -7
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/index.mjs +14 -7
- package/dist/agent/index.mjs.map +1 -1
- package/dist/{base-Dh5vEBQD.d.mts → base-BB9eTlit.d.mts} +1 -1
- package/dist/{base-D9uCcDjZ.d.mts → base-BDyDUIhj.d.mts} +3 -3
- package/dist/{base-Bo8TzBQq.d.mts → base-BI5s2ksj.d.mts} +2 -2
- package/dist/{base-t7G4uaR_.d.ts → base-CFDeoJRe.d.ts} +2 -2
- package/dist/{base-Co-MzdN5.d.ts → base-DHtZCg94.d.ts} +1 -1
- package/dist/{base-TYjCCv7T.d.ts → base-qmU135_k.d.ts} +3 -3
- package/dist/{block-7fd6byyN.d.mts → block-BqWf-Qcb.d.mts} +19 -3
- package/dist/{block-7fd6byyN.d.ts → block-BqWf-Qcb.d.ts} +19 -3
- package/dist/event/index.d.mts +1 -14
- package/dist/event/index.d.ts +1 -14
- package/dist/formatter/index.d.mts +4 -3
- package/dist/formatter/index.d.ts +4 -3
- package/dist/formatter/index.js.map +1 -1
- package/dist/formatter/index.mjs.map +1 -1
- package/dist/{index-DaopL-Vp.d.ts → index-9YC8onn7.d.ts} +1 -1
- package/dist/{index-BVNbIN62.d.mts → index-DpRGxYeT.d.mts} +1 -1
- package/dist/mcp/index.d.mts +2 -2
- package/dist/mcp/index.d.ts +2 -2
- package/dist/message/index.d.mts +3 -2
- package/dist/message/index.d.ts +3 -2
- package/dist/message/index.js +181 -0
- package/dist/message/index.js.map +1 -1
- package/dist/message/index.mjs +180 -0
- package/dist/message/index.mjs.map +1 -1
- package/dist/{message-CYnHiEVt.d.mts → message-D-LObC06.d.mts} +13 -2
- package/dist/{message-DZN7LetB.d.ts → message-DU0_qm3u.d.ts} +13 -2
- package/dist/model/index.d.mts +6 -5
- package/dist/model/index.d.ts +6 -5
- package/dist/model/index.js +22 -11
- package/dist/model/index.js.map +1 -1
- package/dist/model/index.mjs +22 -11
- package/dist/model/index.mjs.map +1 -1
- package/dist/storage/index.d.mts +4 -3
- package/dist/storage/index.d.ts +4 -3
- package/dist/tool/index.d.mts +4 -4
- package/dist/tool/index.d.ts +4 -4
- package/dist/{toolkit-BuMTkbGg.d.ts → toolkit-CLGa-xW0.d.ts} +2 -2
- package/dist/{toolkit-CH9qKAy9.d.mts → toolkit-DvER4yhm.d.mts} +2 -2
- package/package.json +1 -1
- package/src/agent/agent.test.ts +41 -8
- package/src/agent/agent.ts +15 -9
- package/src/formatter/dashscope-chat-formatter.test.ts +3 -0
- package/src/formatter/openai-chat-formatter.test.ts +9 -1
- package/src/mcp/http.test.ts +2 -0
- package/src/mcp/stdio.test.ts +1 -0
- package/src/message/append-event.test.ts +783 -0
- package/src/message/block.ts +9 -2
- package/src/message/index.ts +3 -0
- package/src/message/message.test.ts +2 -0
- package/src/message/message.ts +227 -0
- package/src/model/dashscope-model.test.ts +4 -0
- package/src/model/dashscope-model.ts +3 -0
- package/src/model/deepseek-model.test.ts +2 -0
- package/src/model/deepseek-model.ts +3 -0
- package/src/model/ollama-model.test.ts +1 -0
- package/src/model/ollama-model.ts +2 -0
- package/src/model/openai-model.ts +3 -0
- package/src/storage/file-system.test.ts +1 -0
- package/src/tool/toolkit.test.ts +12 -0
package/dist/storage/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { S as StorageBase, A as AgentState } from '../base-
|
|
2
|
-
import { M as Msg } from '../message-
|
|
1
|
+
import { S as StorageBase, A as AgentState } from '../base-BB9eTlit.mjs';
|
|
2
|
+
import { M as Msg } from '../message-D-LObC06.mjs';
|
|
3
3
|
import '../index-CAxQAkiP.mjs';
|
|
4
|
-
import '../block-
|
|
4
|
+
import '../block-BqWf-Qcb.mjs';
|
|
5
|
+
import '../event/index.mjs';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Local file system storage implementation.
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { S as StorageBase, A as AgentState } from '../base-
|
|
2
|
-
import { M as Msg } from '../message-
|
|
1
|
+
import { S as StorageBase, A as AgentState } from '../base-DHtZCg94.js';
|
|
2
|
+
import { M as Msg } from '../message-DU0_qm3u.js';
|
|
3
3
|
import '../index-CAxQAkiP.js';
|
|
4
|
-
import '../block-
|
|
4
|
+
import '../block-BqWf-Qcb.js';
|
|
5
|
+
import '../event/index.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Local file system storage implementation.
|
package/dist/tool/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { a as ToolResponse } from '../index-
|
|
2
|
-
export { T as Tool } from '../index-
|
|
3
|
-
export { T as Toolkit } from '../toolkit-
|
|
1
|
+
import { a as ToolResponse } from '../index-DpRGxYeT.mjs';
|
|
2
|
+
export { T as Tool } from '../index-DpRGxYeT.mjs';
|
|
3
|
+
export { T as Toolkit } from '../toolkit-DvER4yhm.mjs';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import '@modelcontextprotocol/sdk/client/index.js';
|
|
6
6
|
import '@modelcontextprotocol/sdk/client/sse.js';
|
|
7
7
|
import '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
8
8
|
import '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
9
9
|
import '../index-CAxQAkiP.mjs';
|
|
10
|
-
import '../block-
|
|
10
|
+
import '../block-BqWf-Qcb.mjs';
|
|
11
11
|
import '@modelcontextprotocol/sdk/client/stdio.js';
|
|
12
12
|
|
|
13
13
|
/**
|
package/dist/tool/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { a as ToolResponse } from '../index-
|
|
2
|
-
export { T as Tool } from '../index-
|
|
3
|
-
export { T as Toolkit } from '../toolkit-
|
|
1
|
+
import { a as ToolResponse } from '../index-9YC8onn7.js';
|
|
2
|
+
export { T as Tool } from '../index-9YC8onn7.js';
|
|
3
|
+
export { T as Toolkit } from '../toolkit-CLGa-xW0.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import '@modelcontextprotocol/sdk/client/index.js';
|
|
6
6
|
import '@modelcontextprotocol/sdk/client/sse.js';
|
|
7
7
|
import '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
8
8
|
import '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
9
9
|
import '../index-CAxQAkiP.js';
|
|
10
|
-
import '../block-
|
|
10
|
+
import '../block-BqWf-Qcb.js';
|
|
11
11
|
import '@modelcontextprotocol/sdk/client/stdio.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { T as Tool, H as HTTPMCPClient, S as StdioMCPClient, a as ToolResponse } from './index-
|
|
1
|
+
import { T as Tool, H as HTTPMCPClient, S as StdioMCPClient, a as ToolResponse } from './index-9YC8onn7.js';
|
|
2
2
|
import { T as ToolSchema } from './index-CAxQAkiP.js';
|
|
3
|
-
import { b as ToolCallBlock } from './block-
|
|
3
|
+
import { b as ToolCallBlock } from './block-BqWf-Qcb.js';
|
|
4
4
|
|
|
5
5
|
interface RegisteredTool extends Tool {
|
|
6
6
|
type: 'function' | 'mcp';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { T as Tool, H as HTTPMCPClient, S as StdioMCPClient, a as ToolResponse } from './index-
|
|
1
|
+
import { T as Tool, H as HTTPMCPClient, S as StdioMCPClient, a as ToolResponse } from './index-DpRGxYeT.mjs';
|
|
2
2
|
import { T as ToolSchema } from './index-CAxQAkiP.mjs';
|
|
3
|
-
import { b as ToolCallBlock } from './block-
|
|
3
|
+
import { b as ToolCallBlock } from './block-BqWf-Qcb.mjs';
|
|
4
4
|
|
|
5
5
|
interface RegisteredTool extends Tool {
|
|
6
6
|
type: 'function' | 'mcp';
|
package/package.json
CHANGED
package/src/agent/agent.test.ts
CHANGED
|
@@ -76,12 +76,14 @@ describe('Human-in-the-loop', () => {
|
|
|
76
76
|
id: '1',
|
|
77
77
|
name: 'Bash',
|
|
78
78
|
input: `{"command": "echo Hello"}`,
|
|
79
|
+
state: 'pending',
|
|
79
80
|
},
|
|
80
81
|
{
|
|
81
82
|
type: 'tool_call',
|
|
82
83
|
id: '2',
|
|
83
84
|
name: 'Bash',
|
|
84
85
|
input: `{"command": "echo World"}`,
|
|
86
|
+
state: 'pending',
|
|
85
87
|
},
|
|
86
88
|
];
|
|
87
89
|
|
|
@@ -99,14 +101,14 @@ describe('Human-in-the-loop', () => {
|
|
|
99
101
|
id: '1',
|
|
100
102
|
name: 'Bash',
|
|
101
103
|
input: '{"command": "echo Hello"}',
|
|
102
|
-
|
|
104
|
+
state: 'asking',
|
|
103
105
|
},
|
|
104
106
|
{
|
|
105
107
|
type: 'tool_call',
|
|
106
108
|
id: '2',
|
|
107
109
|
name: 'Bash',
|
|
108
110
|
input: '{"command": "echo World"}',
|
|
109
|
-
|
|
111
|
+
state: 'asking',
|
|
110
112
|
},
|
|
111
113
|
],
|
|
112
114
|
});
|
|
@@ -126,14 +128,14 @@ describe('Human-in-the-loop', () => {
|
|
|
126
128
|
input: '{"command": "echo Hello"}',
|
|
127
129
|
name: 'Bash',
|
|
128
130
|
type: 'tool_call',
|
|
129
|
-
|
|
131
|
+
state: 'asking',
|
|
130
132
|
},
|
|
131
133
|
{
|
|
132
134
|
id: '2',
|
|
133
135
|
input: '{"command": "echo World"}',
|
|
134
136
|
name: 'Bash',
|
|
135
137
|
type: 'tool_call',
|
|
136
|
-
|
|
138
|
+
state: 'asking',
|
|
137
139
|
},
|
|
138
140
|
],
|
|
139
141
|
id: expect.any(String),
|
|
@@ -159,6 +161,7 @@ describe('Human-in-the-loop', () => {
|
|
|
159
161
|
id: '1',
|
|
160
162
|
name: 'Bash',
|
|
161
163
|
input: '{"command": "echo Hello"}',
|
|
164
|
+
state: 'pending',
|
|
162
165
|
},
|
|
163
166
|
},
|
|
164
167
|
],
|
|
@@ -177,6 +180,7 @@ describe('Human-in-the-loop', () => {
|
|
|
177
180
|
id: '2',
|
|
178
181
|
name: 'Bash',
|
|
179
182
|
input: '{"command": "echo World"}',
|
|
183
|
+
state: 'asking',
|
|
180
184
|
},
|
|
181
185
|
],
|
|
182
186
|
});
|
|
@@ -189,13 +193,14 @@ describe('Human-in-the-loop', () => {
|
|
|
189
193
|
input: '{"command": "echo Hello"}',
|
|
190
194
|
name: 'Bash',
|
|
191
195
|
type: 'tool_call',
|
|
196
|
+
state: 'allowed',
|
|
192
197
|
},
|
|
193
198
|
{
|
|
194
199
|
id: '2',
|
|
195
200
|
input: '{"command": "echo World"}',
|
|
196
201
|
name: 'Bash',
|
|
197
202
|
type: 'tool_call',
|
|
198
|
-
|
|
203
|
+
state: 'asking',
|
|
199
204
|
},
|
|
200
205
|
{
|
|
201
206
|
id: '1',
|
|
@@ -230,6 +235,7 @@ describe('Human-in-the-loop', () => {
|
|
|
230
235
|
id: '2',
|
|
231
236
|
name: 'Bash',
|
|
232
237
|
input: '{"command": "echo World"}',
|
|
238
|
+
state: 'pending',
|
|
233
239
|
},
|
|
234
240
|
},
|
|
235
241
|
],
|
|
@@ -312,12 +318,14 @@ describe('Human-in-the-loop', () => {
|
|
|
312
318
|
id: '1',
|
|
313
319
|
name: 'ExternalTool1',
|
|
314
320
|
input: `{"query": "test query"}`,
|
|
321
|
+
state: 'pending',
|
|
315
322
|
},
|
|
316
323
|
{
|
|
317
324
|
type: 'tool_call',
|
|
318
325
|
id: '2',
|
|
319
326
|
name: 'ExternalTool2',
|
|
320
327
|
input: `{"data": "test data"}`,
|
|
328
|
+
state: 'pending',
|
|
321
329
|
},
|
|
322
330
|
];
|
|
323
331
|
|
|
@@ -336,12 +344,14 @@ describe('Human-in-the-loop', () => {
|
|
|
336
344
|
id: '1',
|
|
337
345
|
name: 'ExternalTool1',
|
|
338
346
|
input: '{"query": "test query"}',
|
|
347
|
+
state: 'pending',
|
|
339
348
|
},
|
|
340
349
|
{
|
|
341
350
|
type: 'tool_call',
|
|
342
351
|
id: '2',
|
|
343
352
|
name: 'ExternalTool2',
|
|
344
353
|
input: '{"data": "test data"}',
|
|
354
|
+
state: 'pending',
|
|
345
355
|
},
|
|
346
356
|
],
|
|
347
357
|
});
|
|
@@ -362,12 +372,14 @@ describe('Human-in-the-loop', () => {
|
|
|
362
372
|
input: '{"query": "test query"}',
|
|
363
373
|
name: 'ExternalTool1',
|
|
364
374
|
type: 'tool_call',
|
|
375
|
+
state: 'pending',
|
|
365
376
|
},
|
|
366
377
|
{
|
|
367
378
|
id: '2',
|
|
368
379
|
input: '{"data": "test data"}',
|
|
369
380
|
name: 'ExternalTool2',
|
|
370
381
|
type: 'tool_call',
|
|
382
|
+
state: 'pending',
|
|
371
383
|
},
|
|
372
384
|
],
|
|
373
385
|
id: expect.any(String),
|
|
@@ -375,6 +387,7 @@ describe('Human-in-the-loop', () => {
|
|
|
375
387
|
name: 'Friday',
|
|
376
388
|
role: 'assistant',
|
|
377
389
|
created_at: expect.any(String),
|
|
390
|
+
finished_at: undefined,
|
|
378
391
|
},
|
|
379
392
|
]);
|
|
380
393
|
|
|
@@ -415,6 +428,7 @@ describe('Human-in-the-loop', () => {
|
|
|
415
428
|
id: '2',
|
|
416
429
|
name: 'ExternalTool2',
|
|
417
430
|
input: '{"data": "test data"}',
|
|
431
|
+
state: 'pending',
|
|
418
432
|
},
|
|
419
433
|
],
|
|
420
434
|
});
|
|
@@ -427,12 +441,14 @@ describe('Human-in-the-loop', () => {
|
|
|
427
441
|
input: '{"query": "test query"}',
|
|
428
442
|
name: 'ExternalTool1',
|
|
429
443
|
type: 'tool_call',
|
|
444
|
+
state: 'pending',
|
|
430
445
|
},
|
|
431
446
|
{
|
|
432
447
|
id: '2',
|
|
433
448
|
input: '{"data": "test data"}',
|
|
434
449
|
name: 'ExternalTool2',
|
|
435
450
|
type: 'tool_call',
|
|
451
|
+
state: 'pending',
|
|
436
452
|
},
|
|
437
453
|
{
|
|
438
454
|
id: '1',
|
|
@@ -578,18 +594,21 @@ describe('Human-in-the-loop', () => {
|
|
|
578
594
|
id: '1',
|
|
579
595
|
name: 'ExternalTool',
|
|
580
596
|
input: `{"query": "external query"}`,
|
|
597
|
+
state: 'pending',
|
|
581
598
|
},
|
|
582
599
|
{
|
|
583
600
|
type: 'tool_call',
|
|
584
601
|
id: '2',
|
|
585
602
|
name: 'ConfirmTool',
|
|
586
603
|
input: `{"action": "delete file"}`,
|
|
604
|
+
state: 'pending',
|
|
587
605
|
},
|
|
588
606
|
{
|
|
589
607
|
type: 'tool_call',
|
|
590
608
|
id: '3',
|
|
591
609
|
name: 'NormalTool',
|
|
592
610
|
input: `{"data": "normal data"}`,
|
|
611
|
+
state: 'pending',
|
|
593
612
|
},
|
|
594
613
|
];
|
|
595
614
|
|
|
@@ -608,6 +627,7 @@ describe('Human-in-the-loop', () => {
|
|
|
608
627
|
id: '1',
|
|
609
628
|
name: 'ExternalTool',
|
|
610
629
|
input: '{"query": "external query"}',
|
|
630
|
+
state: 'pending',
|
|
611
631
|
},
|
|
612
632
|
],
|
|
613
633
|
});
|
|
@@ -656,7 +676,7 @@ describe('Human-in-the-loop', () => {
|
|
|
656
676
|
id: '2',
|
|
657
677
|
name: 'ConfirmTool',
|
|
658
678
|
input: '{"action": "delete file"}',
|
|
659
|
-
|
|
679
|
+
state: 'asking',
|
|
660
680
|
},
|
|
661
681
|
],
|
|
662
682
|
});
|
|
@@ -692,6 +712,7 @@ describe('Human-in-the-loop', () => {
|
|
|
692
712
|
id: '2',
|
|
693
713
|
name: 'ConfirmTool',
|
|
694
714
|
input: '{"action": "delete file"}',
|
|
715
|
+
state: 'pending',
|
|
695
716
|
},
|
|
696
717
|
},
|
|
697
718
|
],
|
|
@@ -716,18 +737,21 @@ describe('Human-in-the-loop', () => {
|
|
|
716
737
|
input: '{"query": "external query"}',
|
|
717
738
|
name: 'ExternalTool',
|
|
718
739
|
type: 'tool_call',
|
|
740
|
+
state: 'pending',
|
|
719
741
|
},
|
|
720
742
|
{
|
|
721
743
|
id: '2',
|
|
722
744
|
input: '{"action": "delete file"}',
|
|
723
745
|
name: 'ConfirmTool',
|
|
724
746
|
type: 'tool_call',
|
|
747
|
+
state: 'allowed',
|
|
725
748
|
},
|
|
726
749
|
{
|
|
727
750
|
id: '3',
|
|
728
751
|
input: '{"data": "normal data"}',
|
|
729
752
|
name: 'NormalTool',
|
|
730
753
|
type: 'tool_call',
|
|
754
|
+
state: 'pending',
|
|
731
755
|
},
|
|
732
756
|
{
|
|
733
757
|
id: '1',
|
|
@@ -823,12 +847,14 @@ describe('Human-in-the-loop', () => {
|
|
|
823
847
|
id: '1',
|
|
824
848
|
name: 'ExternalAndConfirmTool',
|
|
825
849
|
input: `{"command": "rm -rf /"}`,
|
|
850
|
+
state: 'pending',
|
|
826
851
|
},
|
|
827
852
|
{
|
|
828
853
|
type: 'tool_call',
|
|
829
854
|
id: '2',
|
|
830
855
|
name: 'ConfirmOnlyTool',
|
|
831
856
|
input: `{"action": "delete database"}`,
|
|
857
|
+
state: 'pending',
|
|
832
858
|
},
|
|
833
859
|
];
|
|
834
860
|
|
|
@@ -847,14 +873,14 @@ describe('Human-in-the-loop', () => {
|
|
|
847
873
|
id: '1',
|
|
848
874
|
name: 'ExternalAndConfirmTool',
|
|
849
875
|
input: '{"command": "rm -rf /"}',
|
|
850
|
-
|
|
876
|
+
state: 'asking',
|
|
851
877
|
},
|
|
852
878
|
{
|
|
853
879
|
type: 'tool_call',
|
|
854
880
|
id: '2',
|
|
855
881
|
name: 'ConfirmOnlyTool',
|
|
856
882
|
input: '{"action": "delete database"}',
|
|
857
|
-
|
|
883
|
+
state: 'asking',
|
|
858
884
|
},
|
|
859
885
|
],
|
|
860
886
|
});
|
|
@@ -881,6 +907,7 @@ describe('Human-in-the-loop', () => {
|
|
|
881
907
|
id: '1',
|
|
882
908
|
name: 'ExternalAndConfirmTool',
|
|
883
909
|
input: '{"command": "rm -rf /"}',
|
|
910
|
+
state: 'pending',
|
|
884
911
|
},
|
|
885
912
|
},
|
|
886
913
|
{
|
|
@@ -890,6 +917,7 @@ describe('Human-in-the-loop', () => {
|
|
|
890
917
|
id: '2',
|
|
891
918
|
name: 'ConfirmOnlyTool',
|
|
892
919
|
input: '{"action": "delete database"}',
|
|
920
|
+
state: 'pending',
|
|
893
921
|
},
|
|
894
922
|
},
|
|
895
923
|
],
|
|
@@ -908,6 +936,7 @@ describe('Human-in-the-loop', () => {
|
|
|
908
936
|
id: '1',
|
|
909
937
|
name: 'ExternalAndConfirmTool',
|
|
910
938
|
input: '{"command": "rm -rf /"}',
|
|
939
|
+
state: 'allowed',
|
|
911
940
|
},
|
|
912
941
|
],
|
|
913
942
|
});
|
|
@@ -927,12 +956,14 @@ describe('Human-in-the-loop', () => {
|
|
|
927
956
|
input: '{"command": "rm -rf /"}',
|
|
928
957
|
name: 'ExternalAndConfirmTool',
|
|
929
958
|
type: 'tool_call',
|
|
959
|
+
state: 'allowed',
|
|
930
960
|
},
|
|
931
961
|
{
|
|
932
962
|
id: '2',
|
|
933
963
|
input: '{"action": "delete database"}',
|
|
934
964
|
name: 'ConfirmOnlyTool',
|
|
935
965
|
type: 'tool_call',
|
|
966
|
+
state: 'allowed',
|
|
936
967
|
},
|
|
937
968
|
],
|
|
938
969
|
]);
|
|
@@ -984,12 +1015,14 @@ describe('Human-in-the-loop', () => {
|
|
|
984
1015
|
input: '{"command": "rm -rf /"}',
|
|
985
1016
|
name: 'ExternalAndConfirmTool',
|
|
986
1017
|
type: 'tool_call',
|
|
1018
|
+
state: 'allowed',
|
|
987
1019
|
},
|
|
988
1020
|
{
|
|
989
1021
|
id: '2',
|
|
990
1022
|
input: '{"action": "delete database"}',
|
|
991
1023
|
name: 'ConfirmOnlyTool',
|
|
992
1024
|
type: 'tool_call',
|
|
1025
|
+
state: 'allowed',
|
|
993
1026
|
},
|
|
994
1027
|
{
|
|
995
1028
|
id: '1',
|
package/src/agent/agent.ts
CHANGED
|
@@ -194,7 +194,7 @@ export class Agent {
|
|
|
194
194
|
agentId: this.name,
|
|
195
195
|
context: this.context,
|
|
196
196
|
metadata: {
|
|
197
|
-
|
|
197
|
+
replyId: this.replyId,
|
|
198
198
|
curIter: this.curIter,
|
|
199
199
|
curSummary: this.curSummary,
|
|
200
200
|
},
|
|
@@ -322,7 +322,7 @@ export class Agent {
|
|
|
322
322
|
this.toolkit.requireUserConfirm(toolCall.name) &&
|
|
323
323
|
!this.confirmedToolCallIds.includes(toolCall.id)
|
|
324
324
|
) {
|
|
325
|
-
toolCall.
|
|
325
|
+
toolCall.state = 'asking';
|
|
326
326
|
// Find the continuous tool calls that require user confirmation
|
|
327
327
|
let i = index + 1;
|
|
328
328
|
for (; i < pendingToolCalls.length; i++) {
|
|
@@ -332,7 +332,7 @@ export class Agent {
|
|
|
332
332
|
this.confirmedToolCallIds.includes(nextToolCall.id)
|
|
333
333
|
)
|
|
334
334
|
break;
|
|
335
|
-
nextToolCall.
|
|
335
|
+
nextToolCall.state = 'asking';
|
|
336
336
|
}
|
|
337
337
|
return {
|
|
338
338
|
awaitingType: EventType.REQUIRE_USER_CONFIRM,
|
|
@@ -431,14 +431,20 @@ export class Agent {
|
|
|
431
431
|
]);
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
|
-
//
|
|
435
|
-
const
|
|
436
|
-
|
|
434
|
+
// Update tool call states based on confirm results
|
|
435
|
+
const confirmedIds = new Set(
|
|
436
|
+
event.confirm_results.filter(r => r.confirmed).map(r => r.tool_call.id)
|
|
437
|
+
);
|
|
438
|
+
const deniedIds = new Set(
|
|
439
|
+
event.confirm_results.filter(r => !r.confirmed).map(r => r.tool_call.id)
|
|
437
440
|
);
|
|
438
|
-
// Set the awaitingUserConfirmation flag to undefined for UI update
|
|
439
441
|
this.context.at(-1)?.content.forEach(content => {
|
|
440
|
-
if (content.type === 'tool_call'
|
|
441
|
-
|
|
442
|
+
if (content.type === 'tool_call') {
|
|
443
|
+
if (confirmedIds.has(content.id)) {
|
|
444
|
+
content.state = 'allowed';
|
|
445
|
+
} else if (deniedIds.has(content.id)) {
|
|
446
|
+
content.state = 'finished';
|
|
447
|
+
}
|
|
442
448
|
}
|
|
443
449
|
});
|
|
444
450
|
}
|
|
@@ -63,12 +63,14 @@ describe('DashScopeChatFormatter', () => {
|
|
|
63
63
|
id: '1',
|
|
64
64
|
name: 'google_search',
|
|
65
65
|
input: '{"query": "example1"}',
|
|
66
|
+
state: 'pending',
|
|
66
67
|
},
|
|
67
68
|
{
|
|
68
69
|
type: 'tool_call',
|
|
69
70
|
id: '2',
|
|
70
71
|
name: 'bing_search',
|
|
71
72
|
input: '{"query": "example2"}',
|
|
73
|
+
state: 'pending',
|
|
72
74
|
},
|
|
73
75
|
{
|
|
74
76
|
type: 'tool_result',
|
|
@@ -263,6 +265,7 @@ describe('DashScopeChatFormatter', () => {
|
|
|
263
265
|
id: '1',
|
|
264
266
|
name: 'google_search',
|
|
265
267
|
input: '{\"query\": \"example1\"}',
|
|
268
|
+
state: 'pending',
|
|
266
269
|
},
|
|
267
270
|
{
|
|
268
271
|
type: 'tool_result',
|
|
@@ -54,12 +54,14 @@ describe('OpenAIChatFormatter', () => {
|
|
|
54
54
|
id: '1',
|
|
55
55
|
name: 'google_search',
|
|
56
56
|
input: '{"query": "example1"}',
|
|
57
|
+
state: 'pending',
|
|
57
58
|
},
|
|
58
59
|
{
|
|
59
60
|
type: 'tool_call',
|
|
60
61
|
id: '2',
|
|
61
62
|
name: 'bing_search',
|
|
62
63
|
input: '{"query": "example2"}',
|
|
64
|
+
state: 'pending',
|
|
63
65
|
},
|
|
64
66
|
{
|
|
65
67
|
type: 'tool_result',
|
|
@@ -195,7 +197,13 @@ describe('OpenAIChatFormatter', () => {
|
|
|
195
197
|
createMsg({
|
|
196
198
|
name: 'assistant',
|
|
197
199
|
content: [
|
|
198
|
-
{
|
|
200
|
+
{
|
|
201
|
+
type: 'tool_call',
|
|
202
|
+
id: '1',
|
|
203
|
+
name: 'google_search',
|
|
204
|
+
input: '{"query": "A"}',
|
|
205
|
+
state: 'pending',
|
|
206
|
+
},
|
|
199
207
|
{
|
|
200
208
|
type: 'tool_result',
|
|
201
209
|
id: '1',
|
package/src/mcp/http.test.ts
CHANGED
|
@@ -215,6 +215,7 @@ describe('HTTPStatefulMCPClient', () => {
|
|
|
215
215
|
name: 'add',
|
|
216
216
|
type: 'tool_call',
|
|
217
217
|
input: `{"a": 10, "b": 20}`,
|
|
218
|
+
state: 'pending',
|
|
218
219
|
});
|
|
219
220
|
for await (const item of res) {
|
|
220
221
|
expect(item.content.length).toBeGreaterThan(0);
|
|
@@ -288,6 +289,7 @@ describe('HTTPStatelessMCPClient', () => {
|
|
|
288
289
|
name: 'add',
|
|
289
290
|
type: 'tool_call',
|
|
290
291
|
input: `{"a": 15, "b": 25}`,
|
|
292
|
+
state: 'pending',
|
|
291
293
|
});
|
|
292
294
|
const collectedRes: ToolResponse[] = [];
|
|
293
295
|
for await (const item of res) {
|
package/src/mcp/stdio.test.ts
CHANGED