@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/dist/model/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { C as ChatModelBase, c as ChatModelOptions, d as ChatModelRequestOptions, b as ChatResponse } from '../base-
|
|
2
|
-
export { a as ChatUsage } from '../base-
|
|
1
|
+
import { C as ChatModelBase, c as ChatModelOptions, d as ChatModelRequestOptions, b as ChatResponse } from '../base-D9uCcDjZ.mjs';
|
|
2
|
+
export { a as ChatUsage } from '../base-D9uCcDjZ.mjs';
|
|
3
3
|
import { a as ToolChoice, T as ToolSchema } from '../index-CAxQAkiP.mjs';
|
|
4
|
-
import { b as ToolCallBlock, T as TextBlock, a as ThinkingBlock } from '../block-
|
|
4
|
+
import { b as ToolCallBlock, T as TextBlock, a as ThinkingBlock } from '../block-7fd6byyN.mjs';
|
|
5
5
|
import { Ollama, AbortableAsyncIterator, ChatResponse as ChatResponse$1 } from 'ollama';
|
|
6
6
|
import { OpenAI } from 'openai';
|
|
7
7
|
import { ChatCompletionMessageParam, ChatCompletionToolChoiceOption } from 'openai/resources/chat/completions';
|
|
8
8
|
import 'zod';
|
|
9
|
-
import '../base-
|
|
10
|
-
import '../message-
|
|
9
|
+
import '../base-Bo8TzBQq.mjs';
|
|
10
|
+
import '../message-CYnHiEVt.mjs';
|
|
11
11
|
|
|
12
12
|
interface DashScopeThinkingConfig {
|
|
13
13
|
/**
|
package/dist/model/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { C as ChatModelBase, c as ChatModelOptions, d as ChatModelRequestOptions, b as ChatResponse } from '../base-
|
|
2
|
-
export { a as ChatUsage } from '../base-
|
|
1
|
+
import { C as ChatModelBase, c as ChatModelOptions, d as ChatModelRequestOptions, b as ChatResponse } from '../base-TYjCCv7T.js';
|
|
2
|
+
export { a as ChatUsage } from '../base-TYjCCv7T.js';
|
|
3
3
|
import { a as ToolChoice, T as ToolSchema } from '../index-CAxQAkiP.js';
|
|
4
|
-
import { b as ToolCallBlock, T as TextBlock, a as ThinkingBlock } from '../block-
|
|
4
|
+
import { b as ToolCallBlock, T as TextBlock, a as ThinkingBlock } from '../block-7fd6byyN.js';
|
|
5
5
|
import { Ollama, AbortableAsyncIterator, ChatResponse as ChatResponse$1 } from 'ollama';
|
|
6
6
|
import { OpenAI } from 'openai';
|
|
7
7
|
import { ChatCompletionMessageParam, ChatCompletionToolChoiceOption } from 'openai/resources/chat/completions';
|
|
8
8
|
import 'zod';
|
|
9
|
-
import '../base-
|
|
10
|
-
import '../message-
|
|
9
|
+
import '../base-t7G4uaR_.js';
|
|
10
|
+
import '../message-DZN7LetB.js';
|
|
11
11
|
|
|
12
12
|
interface DashScopeThinkingConfig {
|
|
13
13
|
/**
|
package/dist/model/index.js
CHANGED
|
@@ -35,16 +35,16 @@ function createMsg({
|
|
|
35
35
|
role,
|
|
36
36
|
metadata = {},
|
|
37
37
|
id = crypto.randomUUID(),
|
|
38
|
-
|
|
38
|
+
created_at = (/* @__PURE__ */ new Date()).toISOString(),
|
|
39
|
+
finished_at,
|
|
39
40
|
usage
|
|
40
41
|
}) {
|
|
41
|
-
|
|
42
|
+
const contentBlocks = typeof content === "string" ? [{ id: crypto.randomUUID(), type: "text", text: content }] : content;
|
|
43
|
+
return { id, name, role, content: contentBlocks, metadata, created_at, finished_at, usage };
|
|
42
44
|
}
|
|
43
45
|
function getTextContent(msg, separator = "\n") {
|
|
44
46
|
const textBlocks = msg.content.filter((block) => block.type === "text");
|
|
45
|
-
if (textBlocks.length === 0)
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
47
|
+
if (textBlocks.length === 0) return null;
|
|
48
48
|
return textBlocks.map((block) => block.text).join(separator);
|
|
49
49
|
}
|
|
50
50
|
function getContentBlocks(msg, blockType) {
|
|
@@ -256,10 +256,10 @@ var FormatterBase = class {
|
|
|
256
256
|
textualOutput.push(block.text);
|
|
257
257
|
break;
|
|
258
258
|
default:
|
|
259
|
-
const type = block.source.
|
|
259
|
+
const type = block.source.media_type.split("/")[0];
|
|
260
260
|
if (type !== "image" && type !== "audio" && type !== "video") {
|
|
261
261
|
console.log(
|
|
262
|
-
`Unsupported media type '${block.source.
|
|
262
|
+
`Unsupported media type '${block.source.media_type}' in tool output. Only image, audio and video are supported.`
|
|
263
263
|
);
|
|
264
264
|
break;
|
|
265
265
|
}
|
|
@@ -283,7 +283,7 @@ var FormatterBase = class {
|
|
|
283
283
|
}
|
|
284
284
|
const promotedBlocks = [];
|
|
285
285
|
promotedData.forEach(({ id, block }) => {
|
|
286
|
-
const type = block.source.
|
|
286
|
+
const type = block.source.media_type.split("/")[0];
|
|
287
287
|
promotedBlocks.push({
|
|
288
288
|
id: crypto.randomUUID(),
|
|
289
289
|
type: "text",
|
|
@@ -429,10 +429,10 @@ var DashScopeChatFormatter = class extends FormatterBase {
|
|
|
429
429
|
* @returns An object representing the formatted multimodal content.
|
|
430
430
|
*/
|
|
431
431
|
_formatMultimodalBlock(block) {
|
|
432
|
-
const type = block.source.
|
|
432
|
+
const type = block.source.media_type.split("/")[0];
|
|
433
433
|
if (!["image", "audio", "video"].includes(type)) {
|
|
434
434
|
console.log(
|
|
435
|
-
`Skip unsupported media type ${block.source.
|
|
435
|
+
`Skip unsupported media type ${block.source.media_type} in DashScopeChatFormatter. Only image, audio and video are supported.`
|
|
436
436
|
);
|
|
437
437
|
return [];
|
|
438
438
|
}
|
|
@@ -441,7 +441,7 @@ var DashScopeChatFormatter = class extends FormatterBase {
|
|
|
441
441
|
}
|
|
442
442
|
return [
|
|
443
443
|
{
|
|
444
|
-
[type]: `data:${block.source.
|
|
444
|
+
[type]: `data:${block.source.media_type};base64,${block.source.data}`
|
|
445
445
|
}
|
|
446
446
|
];
|
|
447
447
|
}
|
|
@@ -692,7 +692,7 @@ var OpenAIChatFormatter = class extends FormatterBase {
|
|
|
692
692
|
block,
|
|
693
693
|
role
|
|
694
694
|
}) {
|
|
695
|
-
const type = block.source.
|
|
695
|
+
const type = block.source.media_type.split("/")[0];
|
|
696
696
|
if (type === "image") {
|
|
697
697
|
return [
|
|
698
698
|
{
|
|
@@ -715,7 +715,7 @@ var OpenAIChatFormatter = class extends FormatterBase {
|
|
|
715
715
|
];
|
|
716
716
|
}
|
|
717
717
|
console.log(
|
|
718
|
-
`Skip unsupported media type ${block.source.
|
|
718
|
+
`Skip unsupported media type ${block.source.media_type} in OpenAIChatFormatter. Only image and audio are supported.`
|
|
719
719
|
);
|
|
720
720
|
return [];
|
|
721
721
|
}
|
|
@@ -726,7 +726,7 @@ var OpenAIChatFormatter = class extends FormatterBase {
|
|
|
726
726
|
*/
|
|
727
727
|
async _toOpenAIImageURL(block) {
|
|
728
728
|
if (block.source.type === "base64") {
|
|
729
|
-
return `data:${block.source.
|
|
729
|
+
return `data:${block.source.media_type};base64,${block.source.data}`;
|
|
730
730
|
}
|
|
731
731
|
const sourceUrl = block.source.url;
|
|
732
732
|
if (sourceUrl.startsWith("http://") || sourceUrl.startsWith("https://")) {
|
|
@@ -747,7 +747,7 @@ var OpenAIChatFormatter = class extends FormatterBase {
|
|
|
747
747
|
);
|
|
748
748
|
}
|
|
749
749
|
const file = await (0, import_promises.readFile)(localPath);
|
|
750
|
-
const mime = block.source.
|
|
750
|
+
const mime = block.source.media_type || `image/${ext.slice(1)}`;
|
|
751
751
|
return `data:${mime};base64,${file.toString("base64")}`;
|
|
752
752
|
}
|
|
753
753
|
/**
|
|
@@ -763,10 +763,10 @@ var OpenAIChatFormatter = class extends FormatterBase {
|
|
|
763
763
|
["audio/mpeg", "mp3"]
|
|
764
764
|
]);
|
|
765
765
|
if (block.source.type === "base64") {
|
|
766
|
-
const format2 = supportedMediaTypes.get(block.source.
|
|
766
|
+
const format2 = supportedMediaTypes.get(block.source.media_type);
|
|
767
767
|
if (!format2) {
|
|
768
768
|
throw new TypeError(
|
|
769
|
-
`Unsupported audio media type: ${block.source.
|
|
769
|
+
`Unsupported audio media type: ${block.source.media_type}, only audio/wav and audio/mp3 are supported.`
|
|
770
770
|
);
|
|
771
771
|
}
|
|
772
772
|
return { data: block.source.data, format: format2 };
|