@agentscope-ai/agentscope 0.0.3 → 0.0.4

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 (65) hide show
  1. package/dist/agent/index.d.mts +7 -7
  2. package/dist/agent/index.d.ts +7 -7
  3. package/dist/agent/index.js +14 -7
  4. package/dist/agent/index.js.map +1 -1
  5. package/dist/agent/index.mjs +14 -7
  6. package/dist/agent/index.mjs.map +1 -1
  7. package/dist/{base-Bo8TzBQq.d.mts → base-1YVBgB4n.d.mts} +2 -2
  8. package/dist/{base-D9uCcDjZ.d.mts → base-B_MQMHWr.d.mts} +3 -3
  9. package/dist/{base-TYjCCv7T.d.ts → base-BherSLRs.d.ts} +3 -3
  10. package/dist/{base-Co-MzdN5.d.ts → base-CY4DMBH1.d.ts} +1 -1
  11. package/dist/{base-t7G4uaR_.d.ts → base-ChWjyzPL.d.ts} +2 -2
  12. package/dist/{base-Dh5vEBQD.d.mts → base-ClilytRZ.d.mts} +1 -1
  13. package/dist/{block-7fd6byyN.d.mts → block-B72uPF1H.d.mts} +5 -3
  14. package/dist/{block-7fd6byyN.d.ts → block-B72uPF1H.d.ts} +5 -3
  15. package/dist/event/index.d.mts +1 -1
  16. package/dist/event/index.d.ts +1 -1
  17. package/dist/formatter/index.d.mts +4 -3
  18. package/dist/formatter/index.d.ts +4 -3
  19. package/dist/formatter/index.js.map +1 -1
  20. package/dist/formatter/index.mjs.map +1 -1
  21. package/dist/{index-DaopL-Vp.d.ts → index-BNfyKbQN.d.ts} +1 -1
  22. package/dist/{index-BVNbIN62.d.mts → index-UQCwdfet.d.mts} +1 -1
  23. package/dist/mcp/index.d.mts +2 -2
  24. package/dist/mcp/index.d.ts +2 -2
  25. package/dist/message/index.d.mts +3 -2
  26. package/dist/message/index.d.ts +3 -2
  27. package/dist/message/index.js +165 -0
  28. package/dist/message/index.js.map +1 -1
  29. package/dist/message/index.mjs +164 -0
  30. package/dist/message/index.mjs.map +1 -1
  31. package/dist/{message-DZN7LetB.d.ts → message-CPZd0NIc.d.ts} +13 -2
  32. package/dist/{message-CYnHiEVt.d.mts → message-DgpfAaHK.d.mts} +13 -2
  33. package/dist/model/index.d.mts +6 -5
  34. package/dist/model/index.d.ts +6 -5
  35. package/dist/model/index.js +22 -11
  36. package/dist/model/index.js.map +1 -1
  37. package/dist/model/index.mjs +22 -11
  38. package/dist/model/index.mjs.map +1 -1
  39. package/dist/storage/index.d.mts +4 -3
  40. package/dist/storage/index.d.ts +4 -3
  41. package/dist/tool/index.d.mts +4 -4
  42. package/dist/tool/index.d.ts +4 -4
  43. package/dist/{toolkit-BuMTkbGg.d.ts → toolkit-DeOlul5Y.d.ts} +2 -2
  44. package/dist/{toolkit-CH9qKAy9.d.mts → toolkit-jwe7NmVJ.d.mts} +2 -2
  45. package/package.json +1 -1
  46. package/src/agent/agent.test.ts +41 -8
  47. package/src/agent/agent.ts +15 -9
  48. package/src/formatter/dashscope-chat-formatter.test.ts +3 -0
  49. package/src/formatter/openai-chat-formatter.test.ts +9 -1
  50. package/src/mcp/http.test.ts +2 -0
  51. package/src/mcp/stdio.test.ts +1 -0
  52. package/src/message/append-event.test.ts +783 -0
  53. package/src/message/block.ts +6 -2
  54. package/src/message/index.ts +3 -0
  55. package/src/message/message.test.ts +2 -0
  56. package/src/message/message.ts +209 -0
  57. package/src/model/dashscope-model.test.ts +4 -0
  58. package/src/model/dashscope-model.ts +3 -0
  59. package/src/model/deepseek-model.test.ts +2 -0
  60. package/src/model/deepseek-model.ts +3 -0
  61. package/src/model/ollama-model.test.ts +1 -0
  62. package/src/model/ollama-model.ts +2 -0
  63. package/src/model/openai-model.ts +3 -0
  64. package/src/storage/file-system.test.ts +1 -0
  65. package/src/tool/toolkit.test.ts +12 -0
@@ -1,13 +1,13 @@
1
1
  import { z } from 'zod';
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';
2
+ import { M as Msg } from '../message-DgpfAaHK.mjs';
3
+ import { b as ToolCallBlock, C as ContentBlock, d as ToolResultBlock } from '../block-B72uPF1H.mjs';
4
+ import { C as ChatModelBase, a as ChatUsage, b as ChatResponse } from '../base-B_MQMHWr.mjs';
5
+ import { a as ToolResponse } from '../index-UQCwdfet.mjs';
6
+ import { T as Toolkit } from '../toolkit-jwe7NmVJ.mjs';
7
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-Dh5vEBQD.mjs';
10
- import '../base-Bo8TzBQq.mjs';
9
+ import { S as StorageBase } from '../base-ClilytRZ.mjs';
10
+ import '../base-1YVBgB4n.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';
@@ -1,13 +1,13 @@
1
1
  import { z } from 'zod';
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';
2
+ import { M as Msg } from '../message-CPZd0NIc.js';
3
+ import { b as ToolCallBlock, C as ContentBlock, d as ToolResultBlock } from '../block-B72uPF1H.js';
4
+ import { C as ChatModelBase, a as ChatUsage, b as ChatResponse } from '../base-BherSLRs.js';
5
+ import { a as ToolResponse } from '../index-BNfyKbQN.js';
6
+ import { T as Toolkit } from '../toolkit-DeOlul5Y.js';
7
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-Co-MzdN5.js';
10
- import '../base-t7G4uaR_.js';
9
+ import { S as StorageBase } from '../base-CY4DMBH1.js';
10
+ import '../base-ChWjyzPL.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';
@@ -708,7 +708,7 @@ var Agent = class {
708
708
  agentId: this.name,
709
709
  context: this.context,
710
710
  metadata: {
711
- reply_id: this.replyId,
711
+ replyId: this.replyId,
712
712
  curIter: this.curIter,
713
713
  curSummary: this.curSummary
714
714
  }
@@ -815,13 +815,13 @@ var Agent = class {
815
815
  const preToolCalls = [];
816
816
  for (const [index, toolCall] of pendingToolCalls.entries()) {
817
817
  if (this.toolkit.requireUserConfirm(toolCall.name) && !this.confirmedToolCallIds.includes(toolCall.id)) {
818
- toolCall.awaitUserConfirmation = true;
818
+ toolCall.state = "asking";
819
819
  let i = index + 1;
820
820
  for (; i < pendingToolCalls.length; i++) {
821
821
  const nextToolCall = pendingToolCalls[i];
822
822
  if (!this.toolkit.requireUserConfirm(nextToolCall.name) || this.confirmedToolCallIds.includes(nextToolCall.id))
823
823
  break;
824
- nextToolCall.awaitUserConfirmation = true;
824
+ nextToolCall.state = "asking";
825
825
  }
826
826
  return {
827
827
  awaitingType: "REQUIRE_USER_CONFIRM" /* REQUIRE_USER_CONFIRM */,
@@ -911,12 +911,19 @@ var Agent = class {
911
911
  ]);
912
912
  }
913
913
  }
914
- const processedToolCallIds = event.confirm_results.map(
915
- (result) => result.tool_call.id
914
+ const confirmedIds = new Set(
915
+ event.confirm_results.filter((r) => r.confirmed).map((r) => r.tool_call.id)
916
+ );
917
+ const deniedIds = new Set(
918
+ event.confirm_results.filter((r) => !r.confirmed).map((r) => r.tool_call.id)
916
919
  );
917
920
  this.context.at(-1)?.content.forEach((content) => {
918
- if (content.type === "tool_call" && processedToolCallIds.includes(content.id)) {
919
- delete content.awaitUserConfirmation;
921
+ if (content.type === "tool_call") {
922
+ if (confirmedIds.has(content.id)) {
923
+ content.state = "allowed";
924
+ } else if (deniedIds.has(content.id)) {
925
+ content.state = "finished";
926
+ }
920
927
  }
921
928
  });
922
929
  }