@agentscope-ai/agentscope 0.0.2

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 (136) hide show
  1. package/dist/agent/index.d.mts +234 -0
  2. package/dist/agent/index.d.ts +234 -0
  3. package/dist/agent/index.js +1412 -0
  4. package/dist/agent/index.js.map +1 -0
  5. package/dist/agent/index.mjs +1375 -0
  6. package/dist/agent/index.mjs.map +1 -0
  7. package/dist/base-BOx3UzOl.d.mts +41 -0
  8. package/dist/base-BoIps2RL.d.ts +41 -0
  9. package/dist/base-C7jwyH4Z.d.mts +52 -0
  10. package/dist/base-Cwi4bjze.d.ts +127 -0
  11. package/dist/base-DYlBMCy_.d.mts +127 -0
  12. package/dist/base-NX-knWOv.d.ts +52 -0
  13. package/dist/block-VsnHrllL.d.mts +48 -0
  14. package/dist/block-VsnHrllL.d.ts +48 -0
  15. package/dist/event/index.d.mts +181 -0
  16. package/dist/event/index.d.ts +181 -0
  17. package/dist/event/index.js +58 -0
  18. package/dist/event/index.js.map +1 -0
  19. package/dist/event/index.mjs +33 -0
  20. package/dist/event/index.mjs.map +1 -0
  21. package/dist/formatter/index.d.mts +187 -0
  22. package/dist/formatter/index.d.ts +187 -0
  23. package/dist/formatter/index.js +647 -0
  24. package/dist/formatter/index.js.map +1 -0
  25. package/dist/formatter/index.mjs +616 -0
  26. package/dist/formatter/index.mjs.map +1 -0
  27. package/dist/index-BTJDlKvQ.d.mts +195 -0
  28. package/dist/index-BcatlwXQ.d.ts +195 -0
  29. package/dist/index-CAxQAkiP.d.mts +21 -0
  30. package/dist/index-CAxQAkiP.d.ts +21 -0
  31. package/dist/mcp/index.d.mts +9 -0
  32. package/dist/mcp/index.d.ts +9 -0
  33. package/dist/mcp/index.js +432 -0
  34. package/dist/mcp/index.js.map +1 -0
  35. package/dist/mcp/index.mjs +408 -0
  36. package/dist/mcp/index.mjs.map +1 -0
  37. package/dist/message/index.d.mts +10 -0
  38. package/dist/message/index.d.ts +10 -0
  39. package/dist/message/index.js +67 -0
  40. package/dist/message/index.js.map +1 -0
  41. package/dist/message/index.mjs +37 -0
  42. package/dist/message/index.mjs.map +1 -0
  43. package/dist/message-CkN21KaY.d.mts +99 -0
  44. package/dist/message-CzLeTlua.d.ts +99 -0
  45. package/dist/model/index.d.mts +377 -0
  46. package/dist/model/index.d.ts +377 -0
  47. package/dist/model/index.js +1880 -0
  48. package/dist/model/index.js.map +1 -0
  49. package/dist/model/index.mjs +1849 -0
  50. package/dist/model/index.mjs.map +1 -0
  51. package/dist/storage/index.d.mts +68 -0
  52. package/dist/storage/index.d.ts +68 -0
  53. package/dist/storage/index.js +250 -0
  54. package/dist/storage/index.js.map +1 -0
  55. package/dist/storage/index.mjs +212 -0
  56. package/dist/storage/index.mjs.map +1 -0
  57. package/dist/tool/index.d.mts +311 -0
  58. package/dist/tool/index.d.ts +311 -0
  59. package/dist/tool/index.js +1494 -0
  60. package/dist/tool/index.js.map +1 -0
  61. package/dist/tool/index.mjs +1447 -0
  62. package/dist/tool/index.mjs.map +1 -0
  63. package/dist/toolkit-CEpulFi0.d.ts +99 -0
  64. package/dist/toolkit-CGEZSZPa.d.mts +99 -0
  65. package/jest.config.js +11 -0
  66. package/package.json +92 -0
  67. package/src/_utils/common.ts +104 -0
  68. package/src/_utils/index.ts +1 -0
  69. package/src/agent/agent-base.ts +0 -0
  70. package/src/agent/agent.test.ts +1028 -0
  71. package/src/agent/agent.ts +1032 -0
  72. package/src/agent/index.ts +2 -0
  73. package/src/agent/interfaces.ts +23 -0
  74. package/src/agent/test-compression.ts +72 -0
  75. package/src/event/index.ts +250 -0
  76. package/src/formatter/base.ts +133 -0
  77. package/src/formatter/dashscope-chat-formatter.test.ts +372 -0
  78. package/src/formatter/dashscope-chat-formatter.ts +163 -0
  79. package/src/formatter/deepseek-chat-formatter.ts +130 -0
  80. package/src/formatter/index.ts +5 -0
  81. package/src/formatter/ollama-chat-formatter.ts +67 -0
  82. package/src/formatter/openai-chat-formatter.test.ts +263 -0
  83. package/src/formatter/openai-chat-formatter.ts +301 -0
  84. package/src/formatter/openai.md +767 -0
  85. package/src/mcp/base.ts +114 -0
  86. package/src/mcp/http.test.ts +303 -0
  87. package/src/mcp/http.ts +224 -0
  88. package/src/mcp/index.ts +2 -0
  89. package/src/mcp/stdio.test.ts +91 -0
  90. package/src/mcp/stdio.ts +119 -0
  91. package/src/message/block.ts +60 -0
  92. package/src/message/enums.ts +4 -0
  93. package/src/message/index.ts +12 -0
  94. package/src/message/message.test.ts +80 -0
  95. package/src/message/message.ts +131 -0
  96. package/src/model/base.ts +226 -0
  97. package/src/model/dashscope-model.test.ts +335 -0
  98. package/src/model/dashscope-model.ts +441 -0
  99. package/src/model/deepseek-model.test.ts +279 -0
  100. package/src/model/deepseek-model.ts +401 -0
  101. package/src/model/index.ts +7 -0
  102. package/src/model/ollama-model.test.ts +307 -0
  103. package/src/model/ollama-model.ts +356 -0
  104. package/src/model/openai-model.ts +327 -0
  105. package/src/model/response.ts +22 -0
  106. package/src/model/usage.ts +12 -0
  107. package/src/storage/base.ts +52 -0
  108. package/src/storage/file-system.test.ts +587 -0
  109. package/src/storage/file-system.ts +269 -0
  110. package/src/storage/index.ts +2 -0
  111. package/src/tool/base.ts +23 -0
  112. package/src/tool/bash.test.ts +174 -0
  113. package/src/tool/bash.ts +152 -0
  114. package/src/tool/edit.test.ts +83 -0
  115. package/src/tool/edit.ts +95 -0
  116. package/src/tool/glob.test.ts +63 -0
  117. package/src/tool/glob.ts +166 -0
  118. package/src/tool/grep.test.ts +74 -0
  119. package/src/tool/grep.ts +256 -0
  120. package/src/tool/index.ts +10 -0
  121. package/src/tool/read.test.ts +77 -0
  122. package/src/tool/read.ts +117 -0
  123. package/src/tool/response.ts +82 -0
  124. package/src/tool/task.test.ts +299 -0
  125. package/src/tool/task.ts +399 -0
  126. package/src/tool/toolkit.test.ts +636 -0
  127. package/src/tool/toolkit.ts +601 -0
  128. package/src/tool/write.test.ts +52 -0
  129. package/src/tool/write.ts +57 -0
  130. package/src/type/index.ts +52 -0
  131. package/tsconfig.build.json +4 -0
  132. package/tsconfig.cjs.json +11 -0
  133. package/tsconfig.esm.json +10 -0
  134. package/tsconfig.json +14 -0
  135. package/tsup.config.ts +20 -0
  136. package/typedoc.json +52 -0
@@ -0,0 +1,181 @@
1
+ import { b as ToolCallBlock, c as ToolResultBlock } from '../block-VsnHrllL.js';
2
+
3
+ declare enum EventType {
4
+ RUN_STARTED = "RUN_STARTED",
5
+ RUN_FINISHED = "RUN_FINISHED",
6
+ MODEL_CALL_STARTED = "MODEL_CALL_STARTED",
7
+ MODEL_CALL_ENDED = "MODEL_CALL_ENDED",
8
+ TEXT_BLOCK_START = "TEXT_BLOCK_START",
9
+ TEXT_BLOCK_DELTA = "TEXT_BLOCK_DELTA",
10
+ TEXT_BLOCK_END = "TEXT_BLOCK_END",
11
+ BINARY_BLOCK_START = "BINARY_BLOCK_START",
12
+ BINARY_BLOCK_DELTA = "BINARY_BLOCK_DELTA",
13
+ BINARY_BLOCK_END = "BINARY_BLOCK_END",
14
+ THINKING_BLOCK_START = "THINKING_BLOCK_START",
15
+ THINKING_BLOCK_DELTA = "THINKING_BLOCK_DELTA",
16
+ THINKING_BLOCK_END = "THINKING_BLOCK_END",
17
+ TOOL_CALL_START = "TOOL_CALL_START",
18
+ TOOL_CALL_DELTA = "TOOL_CALL_DELTA",
19
+ TOOL_CALL_END = "TOOL_CALL_END",
20
+ TOOL_RESULT_START = "TOOL_RESULT_START",
21
+ TOOL_RESULT_TEXT_DELTA = "TOOL_RESULT_TEXT_DELTA",
22
+ TOOL_RESULT_BINARY_DELTA = "TOOL_RESULT_BINARY_DELTA",
23
+ TOOL_RESULT_END = "TOOL_RESULT_END",
24
+ EXCEED_MAX_ITERS = "EXCEED_MAX_ITERS",
25
+ REQUIRE_USER_CONFIRM = "REQUIRE_USER_CONFIRM",
26
+ REQUIRE_EXTERNAL_EXECUTION = "REQUIRE_EXTERNAL_EXECUTION",
27
+ USER_CONFIRM_RESULT = "USER_CONFIRM_RESULT",
28
+ EXTERNAL_EXECUTION_RESULT = "EXTERNAL_EXECUTION_RESULT"
29
+ }
30
+ interface EventBase {
31
+ id: string;
32
+ createdAt: string;
33
+ }
34
+ interface RunStartedEvent extends EventBase {
35
+ type: EventType.RUN_STARTED;
36
+ sessionId: string;
37
+ replyId: string;
38
+ name: string;
39
+ role: 'user' | 'assistant' | 'system';
40
+ }
41
+ interface RunFinishedEvent extends EventBase {
42
+ type: EventType.RUN_FINISHED;
43
+ sessionId: string;
44
+ replyId: string;
45
+ }
46
+ interface ModelCallStartedEvent extends EventBase {
47
+ type: EventType.MODEL_CALL_STARTED;
48
+ replyId: string;
49
+ modelName: string;
50
+ }
51
+ interface ModelCallEndedEvent extends EventBase {
52
+ type: EventType.MODEL_CALL_ENDED;
53
+ replyId: string;
54
+ inputTokens: number;
55
+ outputTokens: number;
56
+ }
57
+ interface TextBlockStartEvent extends EventBase {
58
+ type: EventType.TEXT_BLOCK_START;
59
+ blockId: string;
60
+ replyId: string;
61
+ }
62
+ interface TextBlockDeltaEvent extends EventBase {
63
+ type: EventType.TEXT_BLOCK_DELTA;
64
+ replyId: string;
65
+ blockId: string;
66
+ delta: string;
67
+ }
68
+ interface TextBlockEndEvent extends EventBase {
69
+ type: EventType.TEXT_BLOCK_END;
70
+ replyId: string;
71
+ blockId: string;
72
+ }
73
+ interface BinaryBlockStartEvent extends EventBase {
74
+ type: EventType.BINARY_BLOCK_START;
75
+ replyId: string;
76
+ blockId: string;
77
+ mediaType: string;
78
+ }
79
+ interface BinaryBlockDeltaEvent extends EventBase {
80
+ type: EventType.BINARY_BLOCK_DELTA;
81
+ replyId: string;
82
+ blockId: string;
83
+ data: string;
84
+ mediaType: string;
85
+ }
86
+ interface BinaryBlockEndEvent extends EventBase {
87
+ type: EventType.BINARY_BLOCK_END;
88
+ replyId: string;
89
+ blockId: string;
90
+ }
91
+ interface ThinkingBlockStartEvent extends EventBase {
92
+ type: EventType.THINKING_BLOCK_START;
93
+ replyId: string;
94
+ blockId: string;
95
+ }
96
+ interface ThinkingBlockDeltaEvent extends EventBase {
97
+ type: EventType.THINKING_BLOCK_DELTA;
98
+ replyId: string;
99
+ blockId: string;
100
+ delta: string;
101
+ }
102
+ interface ThinkingBlockEndEvent extends EventBase {
103
+ type: EventType.THINKING_BLOCK_END;
104
+ replyId: string;
105
+ blockId: string;
106
+ }
107
+ interface ToolCallStartEvent extends EventBase {
108
+ type: EventType.TOOL_CALL_START;
109
+ replyId: string;
110
+ toolCallId: string;
111
+ toolCallName: string;
112
+ }
113
+ interface ToolCallDeltaEvent extends EventBase {
114
+ type: EventType.TOOL_CALL_DELTA;
115
+ replyId: string;
116
+ toolCallId: string;
117
+ delta: string;
118
+ }
119
+ interface ToolCallEndEvent extends EventBase {
120
+ type: EventType.TOOL_CALL_END;
121
+ replyId: string;
122
+ toolCallId: string;
123
+ }
124
+ interface ToolResultStartEvent extends EventBase {
125
+ type: EventType.TOOL_RESULT_START;
126
+ replyId: string;
127
+ toolCallId: string;
128
+ toolCallName: string;
129
+ }
130
+ interface ToolResultTextDeltaEvent extends EventBase {
131
+ type: EventType.TOOL_RESULT_TEXT_DELTA;
132
+ replyId: string;
133
+ toolCallId: string;
134
+ delta: string;
135
+ }
136
+ interface ToolResultBinaryDeltaEvent extends EventBase {
137
+ type: EventType.TOOL_RESULT_BINARY_DELTA;
138
+ replyId: string;
139
+ toolCallId: string;
140
+ mediaType: string;
141
+ data?: string;
142
+ url?: string;
143
+ }
144
+ interface ToolResultEndEvent extends EventBase {
145
+ type: EventType.TOOL_RESULT_END;
146
+ replyId: string;
147
+ toolCallId: string;
148
+ state: ToolResultBlock['state'];
149
+ }
150
+ interface ExceedMaxItersEvent extends EventBase {
151
+ type: EventType.EXCEED_MAX_ITERS;
152
+ replyId: string;
153
+ agentId: string;
154
+ name: string;
155
+ }
156
+ interface RequireUserConfirmEvent extends EventBase {
157
+ type: EventType.REQUIRE_USER_CONFIRM;
158
+ replyId: string;
159
+ toolCalls: ToolCallBlock[];
160
+ }
161
+ interface RequireExternalExecutionEvent extends EventBase {
162
+ type: EventType.REQUIRE_EXTERNAL_EXECUTION;
163
+ replyId: string;
164
+ toolCalls: ToolCallBlock[];
165
+ }
166
+ interface UserConfirmResultEvent extends EventBase {
167
+ type: EventType.USER_CONFIRM_RESULT;
168
+ replyId: string;
169
+ confirmResults: {
170
+ confirmed: boolean;
171
+ toolCall: ToolCallBlock;
172
+ }[];
173
+ }
174
+ interface ExternalExecutionResultEvent extends EventBase {
175
+ type: EventType.EXTERNAL_EXECUTION_RESULT;
176
+ replyId: string;
177
+ executionResults: ToolResultBlock[];
178
+ }
179
+ type AgentEvent = RunStartedEvent | RunFinishedEvent | ExceedMaxItersEvent | RequireUserConfirmEvent | RequireExternalExecutionEvent | ModelCallStartedEvent | ModelCallEndedEvent | TextBlockStartEvent | TextBlockDeltaEvent | TextBlockEndEvent | BinaryBlockStartEvent | BinaryBlockDeltaEvent | BinaryBlockEndEvent | ThinkingBlockStartEvent | ThinkingBlockDeltaEvent | ThinkingBlockEndEvent | ToolCallStartEvent | ToolCallDeltaEvent | ToolCallEndEvent | ToolResultStartEvent | ToolResultTextDeltaEvent | ToolResultBinaryDeltaEvent | ToolResultEndEvent | UserConfirmResultEvent | ExternalExecutionResultEvent;
180
+
181
+ export { type AgentEvent, type BinaryBlockDeltaEvent, type BinaryBlockEndEvent, type BinaryBlockStartEvent, type EventBase, EventType, type ExceedMaxItersEvent, type ExternalExecutionResultEvent, type ModelCallEndedEvent, type ModelCallStartedEvent, type RequireExternalExecutionEvent, type RequireUserConfirmEvent, type RunFinishedEvent, type RunStartedEvent, type TextBlockDeltaEvent, type TextBlockEndEvent, type TextBlockStartEvent, type ThinkingBlockDeltaEvent, type ThinkingBlockEndEvent, type ThinkingBlockStartEvent, type ToolCallDeltaEvent, type ToolCallEndEvent, type ToolCallStartEvent, type ToolResultBinaryDeltaEvent, type ToolResultEndEvent, type ToolResultStartEvent, type ToolResultTextDeltaEvent, type UserConfirmResultEvent };
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/event/index.ts
21
+ var event_exports = {};
22
+ __export(event_exports, {
23
+ EventType: () => EventType
24
+ });
25
+ module.exports = __toCommonJS(event_exports);
26
+ var EventType = /* @__PURE__ */ ((EventType2) => {
27
+ EventType2["RUN_STARTED"] = "RUN_STARTED";
28
+ EventType2["RUN_FINISHED"] = "RUN_FINISHED";
29
+ EventType2["MODEL_CALL_STARTED"] = "MODEL_CALL_STARTED";
30
+ EventType2["MODEL_CALL_ENDED"] = "MODEL_CALL_ENDED";
31
+ EventType2["TEXT_BLOCK_START"] = "TEXT_BLOCK_START";
32
+ EventType2["TEXT_BLOCK_DELTA"] = "TEXT_BLOCK_DELTA";
33
+ EventType2["TEXT_BLOCK_END"] = "TEXT_BLOCK_END";
34
+ EventType2["BINARY_BLOCK_START"] = "BINARY_BLOCK_START";
35
+ EventType2["BINARY_BLOCK_DELTA"] = "BINARY_BLOCK_DELTA";
36
+ EventType2["BINARY_BLOCK_END"] = "BINARY_BLOCK_END";
37
+ EventType2["THINKING_BLOCK_START"] = "THINKING_BLOCK_START";
38
+ EventType2["THINKING_BLOCK_DELTA"] = "THINKING_BLOCK_DELTA";
39
+ EventType2["THINKING_BLOCK_END"] = "THINKING_BLOCK_END";
40
+ EventType2["TOOL_CALL_START"] = "TOOL_CALL_START";
41
+ EventType2["TOOL_CALL_DELTA"] = "TOOL_CALL_DELTA";
42
+ EventType2["TOOL_CALL_END"] = "TOOL_CALL_END";
43
+ EventType2["TOOL_RESULT_START"] = "TOOL_RESULT_START";
44
+ EventType2["TOOL_RESULT_TEXT_DELTA"] = "TOOL_RESULT_TEXT_DELTA";
45
+ EventType2["TOOL_RESULT_BINARY_DELTA"] = "TOOL_RESULT_BINARY_DELTA";
46
+ EventType2["TOOL_RESULT_END"] = "TOOL_RESULT_END";
47
+ EventType2["EXCEED_MAX_ITERS"] = "EXCEED_MAX_ITERS";
48
+ EventType2["REQUIRE_USER_CONFIRM"] = "REQUIRE_USER_CONFIRM";
49
+ EventType2["REQUIRE_EXTERNAL_EXECUTION"] = "REQUIRE_EXTERNAL_EXECUTION";
50
+ EventType2["USER_CONFIRM_RESULT"] = "USER_CONFIRM_RESULT";
51
+ EventType2["EXTERNAL_EXECUTION_RESULT"] = "EXTERNAL_EXECUTION_RESULT";
52
+ return EventType2;
53
+ })(EventType || {});
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ EventType
57
+ });
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/event/index.ts"],"sourcesContent":["import { ToolCallBlock, ToolResultBlock } from '../message';\n\nexport enum EventType {\n RUN_STARTED = 'RUN_STARTED',\n RUN_FINISHED = 'RUN_FINISHED',\n\n MODEL_CALL_STARTED = 'MODEL_CALL_STARTED',\n MODEL_CALL_ENDED = 'MODEL_CALL_ENDED',\n\n TEXT_BLOCK_START = 'TEXT_BLOCK_START',\n TEXT_BLOCK_DELTA = 'TEXT_BLOCK_DELTA',\n TEXT_BLOCK_END = 'TEXT_BLOCK_END',\n\n BINARY_BLOCK_START = 'BINARY_BLOCK_START',\n BINARY_BLOCK_DELTA = 'BINARY_BLOCK_DELTA',\n BINARY_BLOCK_END = 'BINARY_BLOCK_END',\n\n THINKING_BLOCK_START = 'THINKING_BLOCK_START',\n THINKING_BLOCK_DELTA = 'THINKING_BLOCK_DELTA',\n THINKING_BLOCK_END = 'THINKING_BLOCK_END',\n\n TOOL_CALL_START = 'TOOL_CALL_START',\n TOOL_CALL_DELTA = 'TOOL_CALL_DELTA',\n TOOL_CALL_END = 'TOOL_CALL_END',\n\n TOOL_RESULT_START = 'TOOL_RESULT_START',\n TOOL_RESULT_TEXT_DELTA = 'TOOL_RESULT_TEXT_DELTA',\n TOOL_RESULT_BINARY_DELTA = 'TOOL_RESULT_BINARY_DELTA',\n TOOL_RESULT_END = 'TOOL_RESULT_END',\n\n EXCEED_MAX_ITERS = 'EXCEED_MAX_ITERS',\n\n REQUIRE_USER_CONFIRM = 'REQUIRE_USER_CONFIRM',\n REQUIRE_EXTERNAL_EXECUTION = 'REQUIRE_EXTERNAL_EXECUTION',\n\n USER_CONFIRM_RESULT = 'USER_CONFIRM_RESULT',\n EXTERNAL_EXECUTION_RESULT = 'EXTERNAL_EXECUTION_RESULT',\n}\n\nexport interface EventBase {\n id: string;\n createdAt: string;\n}\n\nexport interface RunStartedEvent extends EventBase {\n type: EventType.RUN_STARTED;\n sessionId: string;\n replyId: string;\n\n // Extra fields for AG-UI protocol\n name: string;\n role: 'user' | 'assistant' | 'system';\n}\n\nexport interface RunFinishedEvent extends EventBase {\n type: EventType.RUN_FINISHED;\n sessionId: string;\n replyId: string;\n}\n\nexport interface ModelCallStartedEvent extends EventBase {\n type: EventType.MODEL_CALL_STARTED;\n replyId: string;\n modelName: string;\n}\n\nexport interface ModelCallEndedEvent extends EventBase {\n type: EventType.MODEL_CALL_ENDED;\n replyId: string;\n inputTokens: number;\n outputTokens: number;\n}\n\nexport interface TextBlockStartEvent extends EventBase {\n type: EventType.TEXT_BLOCK_START;\n blockId: string;\n replyId: string;\n}\n\nexport interface TextBlockDeltaEvent extends EventBase {\n type: EventType.TEXT_BLOCK_DELTA;\n replyId: string;\n blockId: string;\n delta: string;\n}\n\nexport interface TextBlockEndEvent extends EventBase {\n type: EventType.TEXT_BLOCK_END;\n replyId: string;\n blockId: string;\n}\n\nexport interface BinaryBlockStartEvent extends EventBase {\n type: EventType.BINARY_BLOCK_START;\n replyId: string;\n blockId: string;\n mediaType: string;\n}\n\nexport interface BinaryBlockDeltaEvent extends EventBase {\n type: EventType.BINARY_BLOCK_DELTA;\n replyId: string;\n blockId: string;\n data: string;\n mediaType: string;\n}\n\nexport interface BinaryBlockEndEvent extends EventBase {\n type: EventType.BINARY_BLOCK_END;\n replyId: string;\n blockId: string;\n}\n\nexport interface ThinkingBlockStartEvent extends EventBase {\n type: EventType.THINKING_BLOCK_START;\n replyId: string;\n blockId: string;\n}\n\nexport interface ThinkingBlockDeltaEvent extends EventBase {\n type: EventType.THINKING_BLOCK_DELTA;\n replyId: string;\n blockId: string;\n delta: string;\n}\n\nexport interface ThinkingBlockEndEvent extends EventBase {\n type: EventType.THINKING_BLOCK_END;\n replyId: string;\n blockId: string;\n}\n\nexport interface ToolCallStartEvent extends EventBase {\n type: EventType.TOOL_CALL_START;\n replyId: string;\n toolCallId: string;\n toolCallName: string;\n}\n\nexport interface ToolCallDeltaEvent extends EventBase {\n type: EventType.TOOL_CALL_DELTA;\n replyId: string;\n toolCallId: string;\n delta: string;\n}\n\nexport interface ToolCallEndEvent extends EventBase {\n type: EventType.TOOL_CALL_END;\n replyId: string;\n toolCallId: string;\n}\n\nexport interface ToolResultStartEvent extends EventBase {\n type: EventType.TOOL_RESULT_START;\n replyId: string;\n toolCallId: string;\n toolCallName: string;\n}\n\nexport interface ToolResultTextDeltaEvent extends EventBase {\n type: EventType.TOOL_RESULT_TEXT_DELTA;\n replyId: string;\n toolCallId: string;\n delta: string;\n}\n\nexport interface ToolResultBinaryDeltaEvent extends EventBase {\n type: EventType.TOOL_RESULT_BINARY_DELTA;\n replyId: string;\n toolCallId: string;\n mediaType: string;\n data?: string;\n url?: string;\n}\n\nexport interface ToolResultEndEvent extends EventBase {\n type: EventType.TOOL_RESULT_END;\n replyId: string;\n toolCallId: string;\n state: ToolResultBlock['state'];\n}\n\nexport interface ExceedMaxItersEvent extends EventBase {\n type: EventType.EXCEED_MAX_ITERS;\n\n replyId: string;\n agentId: string;\n name: string;\n}\n\nexport interface RequireUserConfirmEvent extends EventBase {\n type: EventType.REQUIRE_USER_CONFIRM;\n\n replyId: string;\n toolCalls: ToolCallBlock[];\n}\n\nexport interface RequireExternalExecutionEvent extends EventBase {\n type: EventType.REQUIRE_EXTERNAL_EXECUTION;\n\n replyId: string;\n toolCalls: ToolCallBlock[];\n}\n\nexport interface UserConfirmResultEvent extends EventBase {\n type: EventType.USER_CONFIRM_RESULT;\n\n replyId: string;\n confirmResults: {\n confirmed: boolean;\n toolCall: ToolCallBlock;\n }[];\n}\n\nexport interface ExternalExecutionResultEvent extends EventBase {\n type: EventType.EXTERNAL_EXECUTION_RESULT;\n\n replyId: string;\n executionResults: ToolResultBlock[];\n}\n\nexport type AgentEvent =\n // The control events for the whole run\n | RunStartedEvent\n | RunFinishedEvent\n | ExceedMaxItersEvent\n | RequireUserConfirmEvent\n | RequireExternalExecutionEvent\n | ModelCallStartedEvent\n | ModelCallEndedEvent\n // The data events for different block types\n | TextBlockStartEvent\n | TextBlockDeltaEvent\n | TextBlockEndEvent\n | BinaryBlockStartEvent\n | BinaryBlockDeltaEvent\n | BinaryBlockEndEvent\n | ThinkingBlockStartEvent\n | ThinkingBlockDeltaEvent\n | ThinkingBlockEndEvent\n | ToolCallStartEvent\n | ToolCallDeltaEvent\n | ToolCallEndEvent\n | ToolResultStartEvent\n | ToolResultTextDeltaEvent\n | ToolResultBinaryDeltaEvent\n | ToolResultEndEvent\n // The events from the external execution or user confirmation\n | UserConfirmResultEvent\n | ExternalExecutionResultEvent;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAK,YAAL,kBAAKA,eAAL;AACH,EAAAA,WAAA,iBAAc;AACd,EAAAA,WAAA,kBAAe;AAEf,EAAAA,WAAA,wBAAqB;AACrB,EAAAA,WAAA,sBAAmB;AAEnB,EAAAA,WAAA,sBAAmB;AACnB,EAAAA,WAAA,sBAAmB;AACnB,EAAAA,WAAA,oBAAiB;AAEjB,EAAAA,WAAA,wBAAqB;AACrB,EAAAA,WAAA,wBAAqB;AACrB,EAAAA,WAAA,sBAAmB;AAEnB,EAAAA,WAAA,0BAAuB;AACvB,EAAAA,WAAA,0BAAuB;AACvB,EAAAA,WAAA,wBAAqB;AAErB,EAAAA,WAAA,qBAAkB;AAClB,EAAAA,WAAA,qBAAkB;AAClB,EAAAA,WAAA,mBAAgB;AAEhB,EAAAA,WAAA,uBAAoB;AACpB,EAAAA,WAAA,4BAAyB;AACzB,EAAAA,WAAA,8BAA2B;AAC3B,EAAAA,WAAA,qBAAkB;AAElB,EAAAA,WAAA,sBAAmB;AAEnB,EAAAA,WAAA,0BAAuB;AACvB,EAAAA,WAAA,gCAA6B;AAE7B,EAAAA,WAAA,yBAAsB;AACtB,EAAAA,WAAA,+BAA4B;AAlCpB,SAAAA;AAAA,GAAA;","names":["EventType"]}
@@ -0,0 +1,33 @@
1
+ // src/event/index.ts
2
+ var EventType = /* @__PURE__ */ ((EventType2) => {
3
+ EventType2["RUN_STARTED"] = "RUN_STARTED";
4
+ EventType2["RUN_FINISHED"] = "RUN_FINISHED";
5
+ EventType2["MODEL_CALL_STARTED"] = "MODEL_CALL_STARTED";
6
+ EventType2["MODEL_CALL_ENDED"] = "MODEL_CALL_ENDED";
7
+ EventType2["TEXT_BLOCK_START"] = "TEXT_BLOCK_START";
8
+ EventType2["TEXT_BLOCK_DELTA"] = "TEXT_BLOCK_DELTA";
9
+ EventType2["TEXT_BLOCK_END"] = "TEXT_BLOCK_END";
10
+ EventType2["BINARY_BLOCK_START"] = "BINARY_BLOCK_START";
11
+ EventType2["BINARY_BLOCK_DELTA"] = "BINARY_BLOCK_DELTA";
12
+ EventType2["BINARY_BLOCK_END"] = "BINARY_BLOCK_END";
13
+ EventType2["THINKING_BLOCK_START"] = "THINKING_BLOCK_START";
14
+ EventType2["THINKING_BLOCK_DELTA"] = "THINKING_BLOCK_DELTA";
15
+ EventType2["THINKING_BLOCK_END"] = "THINKING_BLOCK_END";
16
+ EventType2["TOOL_CALL_START"] = "TOOL_CALL_START";
17
+ EventType2["TOOL_CALL_DELTA"] = "TOOL_CALL_DELTA";
18
+ EventType2["TOOL_CALL_END"] = "TOOL_CALL_END";
19
+ EventType2["TOOL_RESULT_START"] = "TOOL_RESULT_START";
20
+ EventType2["TOOL_RESULT_TEXT_DELTA"] = "TOOL_RESULT_TEXT_DELTA";
21
+ EventType2["TOOL_RESULT_BINARY_DELTA"] = "TOOL_RESULT_BINARY_DELTA";
22
+ EventType2["TOOL_RESULT_END"] = "TOOL_RESULT_END";
23
+ EventType2["EXCEED_MAX_ITERS"] = "EXCEED_MAX_ITERS";
24
+ EventType2["REQUIRE_USER_CONFIRM"] = "REQUIRE_USER_CONFIRM";
25
+ EventType2["REQUIRE_EXTERNAL_EXECUTION"] = "REQUIRE_EXTERNAL_EXECUTION";
26
+ EventType2["USER_CONFIRM_RESULT"] = "USER_CONFIRM_RESULT";
27
+ EventType2["EXTERNAL_EXECUTION_RESULT"] = "EXTERNAL_EXECUTION_RESULT";
28
+ return EventType2;
29
+ })(EventType || {});
30
+ export {
31
+ EventType
32
+ };
33
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/event/index.ts"],"sourcesContent":["import { ToolCallBlock, ToolResultBlock } from '../message';\n\nexport enum EventType {\n RUN_STARTED = 'RUN_STARTED',\n RUN_FINISHED = 'RUN_FINISHED',\n\n MODEL_CALL_STARTED = 'MODEL_CALL_STARTED',\n MODEL_CALL_ENDED = 'MODEL_CALL_ENDED',\n\n TEXT_BLOCK_START = 'TEXT_BLOCK_START',\n TEXT_BLOCK_DELTA = 'TEXT_BLOCK_DELTA',\n TEXT_BLOCK_END = 'TEXT_BLOCK_END',\n\n BINARY_BLOCK_START = 'BINARY_BLOCK_START',\n BINARY_BLOCK_DELTA = 'BINARY_BLOCK_DELTA',\n BINARY_BLOCK_END = 'BINARY_BLOCK_END',\n\n THINKING_BLOCK_START = 'THINKING_BLOCK_START',\n THINKING_BLOCK_DELTA = 'THINKING_BLOCK_DELTA',\n THINKING_BLOCK_END = 'THINKING_BLOCK_END',\n\n TOOL_CALL_START = 'TOOL_CALL_START',\n TOOL_CALL_DELTA = 'TOOL_CALL_DELTA',\n TOOL_CALL_END = 'TOOL_CALL_END',\n\n TOOL_RESULT_START = 'TOOL_RESULT_START',\n TOOL_RESULT_TEXT_DELTA = 'TOOL_RESULT_TEXT_DELTA',\n TOOL_RESULT_BINARY_DELTA = 'TOOL_RESULT_BINARY_DELTA',\n TOOL_RESULT_END = 'TOOL_RESULT_END',\n\n EXCEED_MAX_ITERS = 'EXCEED_MAX_ITERS',\n\n REQUIRE_USER_CONFIRM = 'REQUIRE_USER_CONFIRM',\n REQUIRE_EXTERNAL_EXECUTION = 'REQUIRE_EXTERNAL_EXECUTION',\n\n USER_CONFIRM_RESULT = 'USER_CONFIRM_RESULT',\n EXTERNAL_EXECUTION_RESULT = 'EXTERNAL_EXECUTION_RESULT',\n}\n\nexport interface EventBase {\n id: string;\n createdAt: string;\n}\n\nexport interface RunStartedEvent extends EventBase {\n type: EventType.RUN_STARTED;\n sessionId: string;\n replyId: string;\n\n // Extra fields for AG-UI protocol\n name: string;\n role: 'user' | 'assistant' | 'system';\n}\n\nexport interface RunFinishedEvent extends EventBase {\n type: EventType.RUN_FINISHED;\n sessionId: string;\n replyId: string;\n}\n\nexport interface ModelCallStartedEvent extends EventBase {\n type: EventType.MODEL_CALL_STARTED;\n replyId: string;\n modelName: string;\n}\n\nexport interface ModelCallEndedEvent extends EventBase {\n type: EventType.MODEL_CALL_ENDED;\n replyId: string;\n inputTokens: number;\n outputTokens: number;\n}\n\nexport interface TextBlockStartEvent extends EventBase {\n type: EventType.TEXT_BLOCK_START;\n blockId: string;\n replyId: string;\n}\n\nexport interface TextBlockDeltaEvent extends EventBase {\n type: EventType.TEXT_BLOCK_DELTA;\n replyId: string;\n blockId: string;\n delta: string;\n}\n\nexport interface TextBlockEndEvent extends EventBase {\n type: EventType.TEXT_BLOCK_END;\n replyId: string;\n blockId: string;\n}\n\nexport interface BinaryBlockStartEvent extends EventBase {\n type: EventType.BINARY_BLOCK_START;\n replyId: string;\n blockId: string;\n mediaType: string;\n}\n\nexport interface BinaryBlockDeltaEvent extends EventBase {\n type: EventType.BINARY_BLOCK_DELTA;\n replyId: string;\n blockId: string;\n data: string;\n mediaType: string;\n}\n\nexport interface BinaryBlockEndEvent extends EventBase {\n type: EventType.BINARY_BLOCK_END;\n replyId: string;\n blockId: string;\n}\n\nexport interface ThinkingBlockStartEvent extends EventBase {\n type: EventType.THINKING_BLOCK_START;\n replyId: string;\n blockId: string;\n}\n\nexport interface ThinkingBlockDeltaEvent extends EventBase {\n type: EventType.THINKING_BLOCK_DELTA;\n replyId: string;\n blockId: string;\n delta: string;\n}\n\nexport interface ThinkingBlockEndEvent extends EventBase {\n type: EventType.THINKING_BLOCK_END;\n replyId: string;\n blockId: string;\n}\n\nexport interface ToolCallStartEvent extends EventBase {\n type: EventType.TOOL_CALL_START;\n replyId: string;\n toolCallId: string;\n toolCallName: string;\n}\n\nexport interface ToolCallDeltaEvent extends EventBase {\n type: EventType.TOOL_CALL_DELTA;\n replyId: string;\n toolCallId: string;\n delta: string;\n}\n\nexport interface ToolCallEndEvent extends EventBase {\n type: EventType.TOOL_CALL_END;\n replyId: string;\n toolCallId: string;\n}\n\nexport interface ToolResultStartEvent extends EventBase {\n type: EventType.TOOL_RESULT_START;\n replyId: string;\n toolCallId: string;\n toolCallName: string;\n}\n\nexport interface ToolResultTextDeltaEvent extends EventBase {\n type: EventType.TOOL_RESULT_TEXT_DELTA;\n replyId: string;\n toolCallId: string;\n delta: string;\n}\n\nexport interface ToolResultBinaryDeltaEvent extends EventBase {\n type: EventType.TOOL_RESULT_BINARY_DELTA;\n replyId: string;\n toolCallId: string;\n mediaType: string;\n data?: string;\n url?: string;\n}\n\nexport interface ToolResultEndEvent extends EventBase {\n type: EventType.TOOL_RESULT_END;\n replyId: string;\n toolCallId: string;\n state: ToolResultBlock['state'];\n}\n\nexport interface ExceedMaxItersEvent extends EventBase {\n type: EventType.EXCEED_MAX_ITERS;\n\n replyId: string;\n agentId: string;\n name: string;\n}\n\nexport interface RequireUserConfirmEvent extends EventBase {\n type: EventType.REQUIRE_USER_CONFIRM;\n\n replyId: string;\n toolCalls: ToolCallBlock[];\n}\n\nexport interface RequireExternalExecutionEvent extends EventBase {\n type: EventType.REQUIRE_EXTERNAL_EXECUTION;\n\n replyId: string;\n toolCalls: ToolCallBlock[];\n}\n\nexport interface UserConfirmResultEvent extends EventBase {\n type: EventType.USER_CONFIRM_RESULT;\n\n replyId: string;\n confirmResults: {\n confirmed: boolean;\n toolCall: ToolCallBlock;\n }[];\n}\n\nexport interface ExternalExecutionResultEvent extends EventBase {\n type: EventType.EXTERNAL_EXECUTION_RESULT;\n\n replyId: string;\n executionResults: ToolResultBlock[];\n}\n\nexport type AgentEvent =\n // The control events for the whole run\n | RunStartedEvent\n | RunFinishedEvent\n | ExceedMaxItersEvent\n | RequireUserConfirmEvent\n | RequireExternalExecutionEvent\n | ModelCallStartedEvent\n | ModelCallEndedEvent\n // The data events for different block types\n | TextBlockStartEvent\n | TextBlockDeltaEvent\n | TextBlockEndEvent\n | BinaryBlockStartEvent\n | BinaryBlockDeltaEvent\n | BinaryBlockEndEvent\n | ThinkingBlockStartEvent\n | ThinkingBlockDeltaEvent\n | ThinkingBlockEndEvent\n | ToolCallStartEvent\n | ToolCallDeltaEvent\n | ToolCallEndEvent\n | ToolResultStartEvent\n | ToolResultTextDeltaEvent\n | ToolResultBinaryDeltaEvent\n | ToolResultEndEvent\n // The events from the external execution or user confirmation\n | UserConfirmResultEvent\n | ExternalExecutionResultEvent;\n"],"mappings":";AAEO,IAAK,YAAL,kBAAKA,eAAL;AACH,EAAAA,WAAA,iBAAc;AACd,EAAAA,WAAA,kBAAe;AAEf,EAAAA,WAAA,wBAAqB;AACrB,EAAAA,WAAA,sBAAmB;AAEnB,EAAAA,WAAA,sBAAmB;AACnB,EAAAA,WAAA,sBAAmB;AACnB,EAAAA,WAAA,oBAAiB;AAEjB,EAAAA,WAAA,wBAAqB;AACrB,EAAAA,WAAA,wBAAqB;AACrB,EAAAA,WAAA,sBAAmB;AAEnB,EAAAA,WAAA,0BAAuB;AACvB,EAAAA,WAAA,0BAAuB;AACvB,EAAAA,WAAA,wBAAqB;AAErB,EAAAA,WAAA,qBAAkB;AAClB,EAAAA,WAAA,qBAAkB;AAClB,EAAAA,WAAA,mBAAgB;AAEhB,EAAAA,WAAA,uBAAoB;AACpB,EAAAA,WAAA,4BAAyB;AACzB,EAAAA,WAAA,8BAA2B;AAC3B,EAAAA,WAAA,qBAAkB;AAElB,EAAAA,WAAA,sBAAmB;AAEnB,EAAAA,WAAA,0BAAuB;AACvB,EAAAA,WAAA,gCAA6B;AAE7B,EAAAA,WAAA,yBAAsB;AACtB,EAAAA,WAAA,+BAA4B;AAlCpB,SAAAA;AAAA,GAAA;","names":["EventType"]}
@@ -0,0 +1,187 @@
1
+ import { F as FormatterBase } from '../base-BOx3UzOl.mjs';
2
+ import { M as Msg } from '../message-CkN21KaY.mjs';
3
+ import { T as TextBlock, D as DataBlock } from '../block-VsnHrllL.mjs';
4
+ import '../index-CAxQAkiP.mjs';
5
+
6
+ interface DashScopeFormatterOptions {
7
+ /**
8
+ * Since DashScope API doesn't support multimodal tool outputs, this option indicates whether to
9
+ * promote the multimodal tool results to the prompt messages, so that LLMs can see them.
10
+ * Note you should ensure your model supports the corresponding modalities.
11
+ */
12
+ promoteMultimodalToolResult?: {
13
+ image?: boolean;
14
+ audio?: boolean;
15
+ video?: boolean;
16
+ } | boolean;
17
+ }
18
+ /**
19
+ *
20
+ */
21
+ declare class DashScopeChatFormatter extends FormatterBase {
22
+ private promoteMultimodalToolResult;
23
+ /**
24
+ * Initialize a DashScopeChatFormatter instance.
25
+ *
26
+ * @param promoteMultimodalToolResult - Since DashScope API doesn't support multimodal tool outputs, this option
27
+ * indicates whether to promote the multimodal tool results to the prompt messages, so that LLMs can see them.
28
+ * Note you should ensure your model supports the corresponding modalities.
29
+ * @param promoteMultimodalToolResult.promoteMultimodalToolResult
30
+ */
31
+ constructor({ promoteMultimodalToolResult }?: DashScopeFormatterOptions);
32
+ /**
33
+ * Format the input message objects into the required format by DashScope API.
34
+ *
35
+ * @param msgs - An array of Msg instances to be formatted.
36
+ * @param msgs.msgs
37
+ * @returns A promise that resolves to an array of formatted message objects.
38
+ */
39
+ format({ msgs }: {
40
+ msgs: Array<Msg>;
41
+ }): Promise<Record<string, unknown>[]>;
42
+ /**
43
+ * Format a text content block into the required format.
44
+ *
45
+ * @param block - The text content block to format.
46
+ * @returns An object representing the formatted text content.
47
+ */
48
+ _formatTextBlock(block: TextBlock): {
49
+ text: string;
50
+ };
51
+ /**
52
+ * Format a multimodal data block into the required format.
53
+ * In DashScope API, the local file paths should be prefixed with "file://". URLs are kept unchanged.
54
+ *
55
+ * @param block - The multimodal content block to format.
56
+ * @returns An object representing the formatted multimodal content.
57
+ */
58
+ _formatMultimodalBlock(block: DataBlock): {
59
+ [x: string]: string;
60
+ }[];
61
+ }
62
+
63
+ interface DeepSeekFormatterOptions {
64
+ /**
65
+ * Most LLM APIs don't support multimodal tool outputs, this option controls whether to
66
+ * promote multimodal tool results to follow-up user messages.
67
+ */
68
+ promoteMultimodalToolResult?: {
69
+ image?: boolean;
70
+ audio?: boolean;
71
+ video?: boolean;
72
+ } | boolean;
73
+ }
74
+ /**
75
+ * Format AgentScope message objects into DeepSeek Chat Completions message format.
76
+ */
77
+ declare class DeepSeekChatFormatter extends FormatterBase {
78
+ private promoteMultimodalToolResult;
79
+ /**
80
+ * Initializes a new instance of the DeepSeekChatFormatter class.
81
+ * @param root0
82
+ * @param root0.promoteMultimodalToolResult
83
+ */
84
+ constructor({ promoteMultimodalToolResult }?: DeepSeekFormatterOptions);
85
+ /**
86
+ * Format the input messages into the structure expected by DeepSeek Chat Completions API.
87
+ * @param root0
88
+ * @param root0.msgs
89
+ * @returns An array of formatted message objects ready to be sent to the DeepSeek API.
90
+ */
91
+ format({ msgs }: {
92
+ msgs: Array<Msg>;
93
+ }): Promise<Record<string, unknown>[]>;
94
+ }
95
+
96
+ /**
97
+ * Format AgentScope message objects into Ollama Chat message format.
98
+ * Ollama expects simple string content, not the multimodal array format.
99
+ */
100
+ declare class OllamaChatFormatter extends FormatterBase {
101
+ /**
102
+ * Format messages for Ollama API
103
+ * @param root0
104
+ * @param root0.msgs
105
+ */
106
+ format({ msgs }: {
107
+ msgs: Array<Msg>;
108
+ }): Promise<Record<string, unknown>[]>;
109
+ }
110
+
111
+ interface OpenAIFormatterOptions {
112
+ /**
113
+ * Most LLM APIs don't support multimodal tool outputs, this option controls whether to
114
+ * promote multimodal tool results to follow-up user messages.
115
+ */
116
+ promoteMultimodalToolResult?: {
117
+ image?: boolean;
118
+ audio?: boolean;
119
+ video?: boolean;
120
+ } | boolean;
121
+ }
122
+ /**
123
+ * Format AgentScope message objects into OpenAI Chat Completions message format.
124
+ */
125
+ declare class OpenAIChatFormatter extends FormatterBase {
126
+ private promoteMultimodalToolResult;
127
+ /**
128
+ * Initializes a new instance of the OpenAIChatFormatter class.
129
+ * @param root0
130
+ * @param root0.promoteMultimodalToolResult
131
+ */
132
+ constructor({ promoteMultimodalToolResult }?: OpenAIFormatterOptions);
133
+ /**
134
+ * Format the input messages into OpenAI Chat Completions message format.
135
+ * @param root0
136
+ * @param root0.msgs
137
+ * @returns An array of formatted messages compatible with OpenAI Chat Completions API.
138
+ */
139
+ format({ msgs }: {
140
+ msgs: Array<Msg>;
141
+ }): Promise<Record<string, unknown>[]>;
142
+ /**
143
+ * Format a text block into OpenAI Chat Completions message content format.
144
+ * @param block
145
+ * @returns An object representing the formatted text block.
146
+ */
147
+ _formatTextBlock(block: TextBlock): {
148
+ type: string;
149
+ text: string;
150
+ };
151
+ /**
152
+ * Format a multimodal data block into OpenAI Chat Completions message content format.
153
+ * @param root0
154
+ * @param root0.block
155
+ * @param root0.role
156
+ * @returns The formatted content blocks
157
+ */
158
+ _formatMultimodalBlock({ block, role, }: {
159
+ block: DataBlock;
160
+ role: Msg['role'];
161
+ }): Promise<Record<string, unknown>[]>;
162
+ /**
163
+ * Convert the data block to an OpenAI compatible image URL.
164
+ * @param block
165
+ * @returns A promise that resolves to a string representing the image URL in a format compatible with OpenAI Chat Completions API.
166
+ */
167
+ protected _toOpenAIImageURL(block: DataBlock): Promise<string>;
168
+ /**
169
+ * Converts a data block to OpenAI compatible audio data format.
170
+ *
171
+ * @param block - The data block containing audio information.
172
+ * @returns A promise that resolves to an object with audio data and format.
173
+ */
174
+ protected _toOpenAIAudioData(block: DataBlock): Promise<{
175
+ data: string;
176
+ format: 'wav' | 'mp3';
177
+ }>;
178
+ /**
179
+ * Converts a URL or path to a local file path.
180
+ *
181
+ * @param urlOrPath - The URL or path to convert.
182
+ * @returns The local file path, or null if not a local path.
183
+ */
184
+ protected _toLocalPath(urlOrPath: string): string | null;
185
+ }
186
+
187
+ export { DashScopeChatFormatter, DeepSeekChatFormatter, FormatterBase, OllamaChatFormatter, OpenAIChatFormatter };
@@ -0,0 +1,187 @@
1
+ import { F as FormatterBase } from '../base-BoIps2RL.js';
2
+ import { M as Msg } from '../message-CzLeTlua.js';
3
+ import { T as TextBlock, D as DataBlock } from '../block-VsnHrllL.js';
4
+ import '../index-CAxQAkiP.js';
5
+
6
+ interface DashScopeFormatterOptions {
7
+ /**
8
+ * Since DashScope API doesn't support multimodal tool outputs, this option indicates whether to
9
+ * promote the multimodal tool results to the prompt messages, so that LLMs can see them.
10
+ * Note you should ensure your model supports the corresponding modalities.
11
+ */
12
+ promoteMultimodalToolResult?: {
13
+ image?: boolean;
14
+ audio?: boolean;
15
+ video?: boolean;
16
+ } | boolean;
17
+ }
18
+ /**
19
+ *
20
+ */
21
+ declare class DashScopeChatFormatter extends FormatterBase {
22
+ private promoteMultimodalToolResult;
23
+ /**
24
+ * Initialize a DashScopeChatFormatter instance.
25
+ *
26
+ * @param promoteMultimodalToolResult - Since DashScope API doesn't support multimodal tool outputs, this option
27
+ * indicates whether to promote the multimodal tool results to the prompt messages, so that LLMs can see them.
28
+ * Note you should ensure your model supports the corresponding modalities.
29
+ * @param promoteMultimodalToolResult.promoteMultimodalToolResult
30
+ */
31
+ constructor({ promoteMultimodalToolResult }?: DashScopeFormatterOptions);
32
+ /**
33
+ * Format the input message objects into the required format by DashScope API.
34
+ *
35
+ * @param msgs - An array of Msg instances to be formatted.
36
+ * @param msgs.msgs
37
+ * @returns A promise that resolves to an array of formatted message objects.
38
+ */
39
+ format({ msgs }: {
40
+ msgs: Array<Msg>;
41
+ }): Promise<Record<string, unknown>[]>;
42
+ /**
43
+ * Format a text content block into the required format.
44
+ *
45
+ * @param block - The text content block to format.
46
+ * @returns An object representing the formatted text content.
47
+ */
48
+ _formatTextBlock(block: TextBlock): {
49
+ text: string;
50
+ };
51
+ /**
52
+ * Format a multimodal data block into the required format.
53
+ * In DashScope API, the local file paths should be prefixed with "file://". URLs are kept unchanged.
54
+ *
55
+ * @param block - The multimodal content block to format.
56
+ * @returns An object representing the formatted multimodal content.
57
+ */
58
+ _formatMultimodalBlock(block: DataBlock): {
59
+ [x: string]: string;
60
+ }[];
61
+ }
62
+
63
+ interface DeepSeekFormatterOptions {
64
+ /**
65
+ * Most LLM APIs don't support multimodal tool outputs, this option controls whether to
66
+ * promote multimodal tool results to follow-up user messages.
67
+ */
68
+ promoteMultimodalToolResult?: {
69
+ image?: boolean;
70
+ audio?: boolean;
71
+ video?: boolean;
72
+ } | boolean;
73
+ }
74
+ /**
75
+ * Format AgentScope message objects into DeepSeek Chat Completions message format.
76
+ */
77
+ declare class DeepSeekChatFormatter extends FormatterBase {
78
+ private promoteMultimodalToolResult;
79
+ /**
80
+ * Initializes a new instance of the DeepSeekChatFormatter class.
81
+ * @param root0
82
+ * @param root0.promoteMultimodalToolResult
83
+ */
84
+ constructor({ promoteMultimodalToolResult }?: DeepSeekFormatterOptions);
85
+ /**
86
+ * Format the input messages into the structure expected by DeepSeek Chat Completions API.
87
+ * @param root0
88
+ * @param root0.msgs
89
+ * @returns An array of formatted message objects ready to be sent to the DeepSeek API.
90
+ */
91
+ format({ msgs }: {
92
+ msgs: Array<Msg>;
93
+ }): Promise<Record<string, unknown>[]>;
94
+ }
95
+
96
+ /**
97
+ * Format AgentScope message objects into Ollama Chat message format.
98
+ * Ollama expects simple string content, not the multimodal array format.
99
+ */
100
+ declare class OllamaChatFormatter extends FormatterBase {
101
+ /**
102
+ * Format messages for Ollama API
103
+ * @param root0
104
+ * @param root0.msgs
105
+ */
106
+ format({ msgs }: {
107
+ msgs: Array<Msg>;
108
+ }): Promise<Record<string, unknown>[]>;
109
+ }
110
+
111
+ interface OpenAIFormatterOptions {
112
+ /**
113
+ * Most LLM APIs don't support multimodal tool outputs, this option controls whether to
114
+ * promote multimodal tool results to follow-up user messages.
115
+ */
116
+ promoteMultimodalToolResult?: {
117
+ image?: boolean;
118
+ audio?: boolean;
119
+ video?: boolean;
120
+ } | boolean;
121
+ }
122
+ /**
123
+ * Format AgentScope message objects into OpenAI Chat Completions message format.
124
+ */
125
+ declare class OpenAIChatFormatter extends FormatterBase {
126
+ private promoteMultimodalToolResult;
127
+ /**
128
+ * Initializes a new instance of the OpenAIChatFormatter class.
129
+ * @param root0
130
+ * @param root0.promoteMultimodalToolResult
131
+ */
132
+ constructor({ promoteMultimodalToolResult }?: OpenAIFormatterOptions);
133
+ /**
134
+ * Format the input messages into OpenAI Chat Completions message format.
135
+ * @param root0
136
+ * @param root0.msgs
137
+ * @returns An array of formatted messages compatible with OpenAI Chat Completions API.
138
+ */
139
+ format({ msgs }: {
140
+ msgs: Array<Msg>;
141
+ }): Promise<Record<string, unknown>[]>;
142
+ /**
143
+ * Format a text block into OpenAI Chat Completions message content format.
144
+ * @param block
145
+ * @returns An object representing the formatted text block.
146
+ */
147
+ _formatTextBlock(block: TextBlock): {
148
+ type: string;
149
+ text: string;
150
+ };
151
+ /**
152
+ * Format a multimodal data block into OpenAI Chat Completions message content format.
153
+ * @param root0
154
+ * @param root0.block
155
+ * @param root0.role
156
+ * @returns The formatted content blocks
157
+ */
158
+ _formatMultimodalBlock({ block, role, }: {
159
+ block: DataBlock;
160
+ role: Msg['role'];
161
+ }): Promise<Record<string, unknown>[]>;
162
+ /**
163
+ * Convert the data block to an OpenAI compatible image URL.
164
+ * @param block
165
+ * @returns A promise that resolves to a string representing the image URL in a format compatible with OpenAI Chat Completions API.
166
+ */
167
+ protected _toOpenAIImageURL(block: DataBlock): Promise<string>;
168
+ /**
169
+ * Converts a data block to OpenAI compatible audio data format.
170
+ *
171
+ * @param block - The data block containing audio information.
172
+ * @returns A promise that resolves to an object with audio data and format.
173
+ */
174
+ protected _toOpenAIAudioData(block: DataBlock): Promise<{
175
+ data: string;
176
+ format: 'wav' | 'mp3';
177
+ }>;
178
+ /**
179
+ * Converts a URL or path to a local file path.
180
+ *
181
+ * @param urlOrPath - The URL or path to convert.
182
+ * @returns The local file path, or null if not a local path.
183
+ */
184
+ protected _toLocalPath(urlOrPath: string): string | null;
185
+ }
186
+
187
+ export { DashScopeChatFormatter, DeepSeekChatFormatter, FormatterBase, OllamaChatFormatter, OpenAIChatFormatter };