@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.
- package/dist/agent/index.d.mts +234 -0
- package/dist/agent/index.d.ts +234 -0
- package/dist/agent/index.js +1412 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/index.mjs +1375 -0
- package/dist/agent/index.mjs.map +1 -0
- package/dist/base-BOx3UzOl.d.mts +41 -0
- package/dist/base-BoIps2RL.d.ts +41 -0
- package/dist/base-C7jwyH4Z.d.mts +52 -0
- package/dist/base-Cwi4bjze.d.ts +127 -0
- package/dist/base-DYlBMCy_.d.mts +127 -0
- package/dist/base-NX-knWOv.d.ts +52 -0
- package/dist/block-VsnHrllL.d.mts +48 -0
- package/dist/block-VsnHrllL.d.ts +48 -0
- package/dist/event/index.d.mts +181 -0
- package/dist/event/index.d.ts +181 -0
- package/dist/event/index.js +58 -0
- package/dist/event/index.js.map +1 -0
- package/dist/event/index.mjs +33 -0
- package/dist/event/index.mjs.map +1 -0
- package/dist/formatter/index.d.mts +187 -0
- package/dist/formatter/index.d.ts +187 -0
- package/dist/formatter/index.js +647 -0
- package/dist/formatter/index.js.map +1 -0
- package/dist/formatter/index.mjs +616 -0
- package/dist/formatter/index.mjs.map +1 -0
- package/dist/index-BTJDlKvQ.d.mts +195 -0
- package/dist/index-BcatlwXQ.d.ts +195 -0
- package/dist/index-CAxQAkiP.d.mts +21 -0
- package/dist/index-CAxQAkiP.d.ts +21 -0
- package/dist/mcp/index.d.mts +9 -0
- package/dist/mcp/index.d.ts +9 -0
- package/dist/mcp/index.js +432 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/index.mjs +408 -0
- package/dist/mcp/index.mjs.map +1 -0
- package/dist/message/index.d.mts +10 -0
- package/dist/message/index.d.ts +10 -0
- package/dist/message/index.js +67 -0
- package/dist/message/index.js.map +1 -0
- package/dist/message/index.mjs +37 -0
- package/dist/message/index.mjs.map +1 -0
- package/dist/message-CkN21KaY.d.mts +99 -0
- package/dist/message-CzLeTlua.d.ts +99 -0
- package/dist/model/index.d.mts +377 -0
- package/dist/model/index.d.ts +377 -0
- package/dist/model/index.js +1880 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/index.mjs +1849 -0
- package/dist/model/index.mjs.map +1 -0
- package/dist/storage/index.d.mts +68 -0
- package/dist/storage/index.d.ts +68 -0
- package/dist/storage/index.js +250 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/index.mjs +212 -0
- package/dist/storage/index.mjs.map +1 -0
- package/dist/tool/index.d.mts +311 -0
- package/dist/tool/index.d.ts +311 -0
- package/dist/tool/index.js +1494 -0
- package/dist/tool/index.js.map +1 -0
- package/dist/tool/index.mjs +1447 -0
- package/dist/tool/index.mjs.map +1 -0
- package/dist/toolkit-CEpulFi0.d.ts +99 -0
- package/dist/toolkit-CGEZSZPa.d.mts +99 -0
- package/jest.config.js +11 -0
- package/package.json +92 -0
- package/src/_utils/common.ts +104 -0
- package/src/_utils/index.ts +1 -0
- package/src/agent/agent-base.ts +0 -0
- package/src/agent/agent.test.ts +1028 -0
- package/src/agent/agent.ts +1032 -0
- package/src/agent/index.ts +2 -0
- package/src/agent/interfaces.ts +23 -0
- package/src/agent/test-compression.ts +72 -0
- package/src/event/index.ts +250 -0
- package/src/formatter/base.ts +133 -0
- package/src/formatter/dashscope-chat-formatter.test.ts +372 -0
- package/src/formatter/dashscope-chat-formatter.ts +163 -0
- package/src/formatter/deepseek-chat-formatter.ts +130 -0
- package/src/formatter/index.ts +5 -0
- package/src/formatter/ollama-chat-formatter.ts +67 -0
- package/src/formatter/openai-chat-formatter.test.ts +263 -0
- package/src/formatter/openai-chat-formatter.ts +301 -0
- package/src/formatter/openai.md +767 -0
- package/src/mcp/base.ts +114 -0
- package/src/mcp/http.test.ts +303 -0
- package/src/mcp/http.ts +224 -0
- package/src/mcp/index.ts +2 -0
- package/src/mcp/stdio.test.ts +91 -0
- package/src/mcp/stdio.ts +119 -0
- package/src/message/block.ts +60 -0
- package/src/message/enums.ts +4 -0
- package/src/message/index.ts +12 -0
- package/src/message/message.test.ts +80 -0
- package/src/message/message.ts +131 -0
- package/src/model/base.ts +226 -0
- package/src/model/dashscope-model.test.ts +335 -0
- package/src/model/dashscope-model.ts +441 -0
- package/src/model/deepseek-model.test.ts +279 -0
- package/src/model/deepseek-model.ts +401 -0
- package/src/model/index.ts +7 -0
- package/src/model/ollama-model.test.ts +307 -0
- package/src/model/ollama-model.ts +356 -0
- package/src/model/openai-model.ts +327 -0
- package/src/model/response.ts +22 -0
- package/src/model/usage.ts +12 -0
- package/src/storage/base.ts +52 -0
- package/src/storage/file-system.test.ts +587 -0
- package/src/storage/file-system.ts +269 -0
- package/src/storage/index.ts +2 -0
- package/src/tool/base.ts +23 -0
- package/src/tool/bash.test.ts +174 -0
- package/src/tool/bash.ts +152 -0
- package/src/tool/edit.test.ts +83 -0
- package/src/tool/edit.ts +95 -0
- package/src/tool/glob.test.ts +63 -0
- package/src/tool/glob.ts +166 -0
- package/src/tool/grep.test.ts +74 -0
- package/src/tool/grep.ts +256 -0
- package/src/tool/index.ts +10 -0
- package/src/tool/read.test.ts +77 -0
- package/src/tool/read.ts +117 -0
- package/src/tool/response.ts +82 -0
- package/src/tool/task.test.ts +299 -0
- package/src/tool/task.ts +399 -0
- package/src/tool/toolkit.test.ts +636 -0
- package/src/tool/toolkit.ts +601 -0
- package/src/tool/write.test.ts +52 -0
- package/src/tool/write.ts +57 -0
- package/src/type/index.ts +52 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.cjs.json +11 -0
- package/tsconfig.esm.json +10 -0
- package/tsconfig.json +14 -0
- package/tsup.config.ts +20 -0
- package/typedoc.json +52 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Tool for writing files to the local filesystem.
|
|
8
|
+
* Creates parent directories as needed and overwrites existing files.
|
|
9
|
+
*
|
|
10
|
+
* @returns A Tool object for writing files, with a call method that performs the write operation.
|
|
11
|
+
*/
|
|
12
|
+
export function Write() {
|
|
13
|
+
return {
|
|
14
|
+
name: 'Write',
|
|
15
|
+
description: `Writes a file to the local filesystem.
|
|
16
|
+
|
|
17
|
+
Usage:
|
|
18
|
+
- This tool will overwrite the existing file if there is one at the provided path.
|
|
19
|
+
- If this is an existing file, you MUST use the Read tool first to read the file's contents. This tool will fail if you did not read the file first.
|
|
20
|
+
- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.
|
|
21
|
+
- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.
|
|
22
|
+
- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.`,
|
|
23
|
+
inputSchema: z.object({
|
|
24
|
+
file_path: z
|
|
25
|
+
.string()
|
|
26
|
+
.describe(
|
|
27
|
+
'The absolute path to the file to write (must be absolute, not relative)'
|
|
28
|
+
),
|
|
29
|
+
content: z.string().describe('The content to write to the file'),
|
|
30
|
+
}),
|
|
31
|
+
requireUserConfirm: true,
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Writes content to a file, creating parent directories if necessary.
|
|
35
|
+
*
|
|
36
|
+
* @param root0 - The parameters object
|
|
37
|
+
* @param root0.file_path - Absolute path to the file to write
|
|
38
|
+
* @param root0.content - The content to write to the file
|
|
39
|
+
* @returns A success message including the number of lines written
|
|
40
|
+
* @throws If the path is not absolute
|
|
41
|
+
*/
|
|
42
|
+
call({ file_path, content }: { file_path: string; content: string }): string {
|
|
43
|
+
if (!path.isAbsolute(file_path)) {
|
|
44
|
+
throw new Error(`file_path must be an absolute path, got: ${file_path}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const dir = path.dirname(file_path);
|
|
48
|
+
if (!fs.existsSync(dir)) {
|
|
49
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fs.writeFileSync(file_path, content, 'utf-8');
|
|
53
|
+
const lineCount = content.split('\n').length;
|
|
54
|
+
return `The file ${file_path} has been written successfully (${lineCount} lines).`;
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ToolResponse } from '../tool';
|
|
2
|
+
|
|
3
|
+
export type JSONSerializableObject =
|
|
4
|
+
| string
|
|
5
|
+
| number
|
|
6
|
+
| boolean
|
|
7
|
+
| null
|
|
8
|
+
| JSONSerializableObject[]
|
|
9
|
+
| { [key: string]: JSONSerializableObject };
|
|
10
|
+
|
|
11
|
+
export type ToolName = string;
|
|
12
|
+
export type ToolChoice = 'auto' | 'none' | 'required' | ToolName;
|
|
13
|
+
|
|
14
|
+
export interface ToolInputSchema {
|
|
15
|
+
type: 'object';
|
|
16
|
+
properties?: Record<string, object>;
|
|
17
|
+
required?: string[];
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ToolSchema {
|
|
22
|
+
type: 'function';
|
|
23
|
+
function: {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
parameters: ToolInputSchema;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Defines the possible function types for a tool function:
|
|
32
|
+
* - Synchronous: string
|
|
33
|
+
* - Asynchronous: Promise<string>
|
|
34
|
+
* - Synchronous Generator: Generator<string>
|
|
35
|
+
* - Asynchronous Generator: AsyncGenerator<string>
|
|
36
|
+
* - Synchronous: ToolResponse
|
|
37
|
+
* - Asynchronous: Promise<ToolResponse>
|
|
38
|
+
* - Synchronous Generator: Generator<ToolResponse>
|
|
39
|
+
* - Asynchronous Generator: AsyncGenerator<ToolResponse>
|
|
40
|
+
*/
|
|
41
|
+
export type ToolFunction = (
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
input: any
|
|
44
|
+
) =>
|
|
45
|
+
| string
|
|
46
|
+
| Promise<string>
|
|
47
|
+
| Generator<string>
|
|
48
|
+
| AsyncGenerator<string>
|
|
49
|
+
| ToolResponse
|
|
50
|
+
| Promise<ToolResponse>
|
|
51
|
+
| Generator<ToolResponse>
|
|
52
|
+
| AsyncGenerator<ToolResponse>;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2022",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"forceConsistentCasingInFileNames": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"outDir": "dist",
|
|
10
|
+
"declaration": true
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/**/*", "tsup.config.ts"],
|
|
13
|
+
"exclude": ["node_modules", "dist"]
|
|
14
|
+
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: {
|
|
5
|
+
'message/index': 'src/message/index.ts',
|
|
6
|
+
'model/index': 'src/model/index.ts',
|
|
7
|
+
'tool/index': 'src/tool/index.ts',
|
|
8
|
+
'agent/index': 'src/agent/index.ts',
|
|
9
|
+
'formatter/index': 'src/formatter/index.ts',
|
|
10
|
+
'event/index': 'src/event/index.ts',
|
|
11
|
+
'mcp/index': 'src/mcp/index.ts',
|
|
12
|
+
'storage/index': 'src/storage/index.ts',
|
|
13
|
+
},
|
|
14
|
+
format: ['cjs', 'esm'],
|
|
15
|
+
dts: true,
|
|
16
|
+
splitting: false,
|
|
17
|
+
clean: true,
|
|
18
|
+
outDir: 'dist',
|
|
19
|
+
sourcemap: true,
|
|
20
|
+
});
|
package/typedoc.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://typedoc.org/schema.json",
|
|
3
|
+
"entryPoints": [
|
|
4
|
+
"src/agent/index.ts",
|
|
5
|
+
"src/event/index.ts",
|
|
6
|
+
"src/formatter/index.ts",
|
|
7
|
+
"src/mcp/index.ts",
|
|
8
|
+
"src/message/index.ts",
|
|
9
|
+
"src/model/index.ts",
|
|
10
|
+
"src/storage/index.ts",
|
|
11
|
+
"src/tool/index.ts"
|
|
12
|
+
],
|
|
13
|
+
"entryPointStrategy": "expand",
|
|
14
|
+
"out": "../../docs/api-reference/generated",
|
|
15
|
+
"plugin": ["typedoc-plugin-markdown"],
|
|
16
|
+
"readme": "none",
|
|
17
|
+
"hideGenerator": true,
|
|
18
|
+
"excludePrivate": true,
|
|
19
|
+
"excludeProtected": true,
|
|
20
|
+
"excludeInternal": true,
|
|
21
|
+
"excludeExternals": true,
|
|
22
|
+
"skipErrorChecking": true,
|
|
23
|
+
"sort": ["source-order"],
|
|
24
|
+
"kindSortOrder": ["Interface", "Class", "Function", "TypeAlias", "Variable"],
|
|
25
|
+
"categorizeByGroup": true,
|
|
26
|
+
"categoryOrder": [
|
|
27
|
+
"Agent",
|
|
28
|
+
"Model",
|
|
29
|
+
"Tool",
|
|
30
|
+
"Event",
|
|
31
|
+
"Message",
|
|
32
|
+
"Storage",
|
|
33
|
+
"MCP",
|
|
34
|
+
"Formatter",
|
|
35
|
+
"*"
|
|
36
|
+
],
|
|
37
|
+
"groupOrder": ["Classes", "Interfaces", "Type Aliases", "Functions", "*"],
|
|
38
|
+
"outputFileStrategy": "modules",
|
|
39
|
+
"flattenOutputFiles": false,
|
|
40
|
+
"useCodeBlocks": true,
|
|
41
|
+
"expandObjects": true,
|
|
42
|
+
"parametersFormat": "table",
|
|
43
|
+
"propertiesFormat": "table",
|
|
44
|
+
"enumMembersFormat": "table",
|
|
45
|
+
"typeDeclarationFormat": "table",
|
|
46
|
+
"excludeNotDocumented": false,
|
|
47
|
+
"hideBreadcrumbs": true,
|
|
48
|
+
"hidePageTitle": true,
|
|
49
|
+
"hidePageHeader": true,
|
|
50
|
+
"disableSources": true,
|
|
51
|
+
"customCss": "../../docs/assets/api.css"
|
|
52
|
+
}
|