agentdev 0.1.8 → 0.1.10
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/BasicAgent-R7DYGTHF.js +13 -0
- package/dist/ExplorerAgent-DXY3OQ5U.js +13 -0
- package/dist/{chunk-OBOU27DM.js → chunk-3AR3JBW6.js} +6701 -1730
- package/dist/chunk-3AR3JBW6.js.map +1 -0
- package/dist/{chunk-F3PR7UTL.js → chunk-72H6A6NB.js} +5 -3
- package/dist/{chunk-F3PR7UTL.js.map → chunk-72H6A6NB.js.map} +1 -1
- package/dist/{chunk-TSASFMRF.js → chunk-BAP2GCYH.js} +1 -1
- package/dist/chunk-BAP2GCYH.js.map +1 -0
- package/dist/{chunk-3BPSNNK3.js → chunk-EECW6PYP.js} +11 -9
- package/dist/chunk-EECW6PYP.js.map +1 -0
- package/dist/chunk-G5ECPY4K.js +551 -0
- package/dist/chunk-G5ECPY4K.js.map +1 -0
- package/dist/{chunk-LLV3W326.js → chunk-NORTAQIL.js} +67 -20
- package/dist/chunk-NORTAQIL.js.map +1 -0
- package/dist/{chunk-LQTEETML.js → chunk-REOJZCSZ.js} +12 -7
- package/dist/chunk-REOJZCSZ.js.map +1 -0
- package/dist/cli/server.js +2 -2
- package/dist/cli/viewer.js +2 -2
- package/dist/create-feature-cli.js +26 -7
- package/dist/features/shell/templates/bash.render.d.ts +1 -1
- package/dist/features/websearch/templates/web-fetch.render.d.ts +1 -1
- package/dist/index.d.ts +1755 -497
- package/dist/index.js +30 -8
- package/dist/index.js.map +1 -1
- package/dist/{notification-3VEAP7YF.js → notification-NWVOS2WR.js} +3 -3
- package/dist/tools-LDR3LIJP.js +14 -0
- package/dist/tools-LDR3LIJP.js.map +1 -0
- package/dist/{types-DUKIIntb.d.ts → types-CF5UsxD9.d.ts} +3 -0
- package/node_modules/@sliverp/qqbot/LICENSE +21 -0
- package/node_modules/@sliverp/qqbot/README.md +427 -0
- package/node_modules/@sliverp/qqbot/README.standalone.zh.md +77 -0
- package/node_modules/@sliverp/qqbot/README.zh.md +423 -0
- package/node_modules/@sliverp/qqbot/bin/qqbot-cli.js +227 -0
- package/node_modules/@sliverp/qqbot/clawdbot.plugin.json +16 -0
- package/node_modules/@sliverp/qqbot/dist/index.d.ts +20 -0
- package/node_modules/@sliverp/qqbot/dist/index.js +25 -0
- package/node_modules/@sliverp/qqbot/dist/src/agent.d.ts +76 -0
- package/node_modules/@sliverp/qqbot/dist/src/agent.js +36 -0
- package/node_modules/@sliverp/qqbot/dist/src/api.d.ts +138 -0
- package/node_modules/@sliverp/qqbot/dist/src/api.js +523 -0
- package/node_modules/@sliverp/qqbot/dist/src/channel.d.ts +3 -0
- package/node_modules/@sliverp/qqbot/dist/src/channel.js +349 -0
- package/node_modules/@sliverp/qqbot/dist/src/config.d.ts +25 -0
- package/node_modules/@sliverp/qqbot/dist/src/config.js +156 -0
- package/node_modules/@sliverp/qqbot/dist/src/demo-standalone.d.ts +1 -0
- package/node_modules/@sliverp/qqbot/dist/src/demo-standalone.js +125 -0
- package/node_modules/@sliverp/qqbot/dist/src/gateway.d.ts +20 -0
- package/node_modules/@sliverp/qqbot/dist/src/gateway.js +2156 -0
- package/node_modules/@sliverp/qqbot/dist/src/image-server.d.ts +62 -0
- package/node_modules/@sliverp/qqbot/dist/src/image-server.js +401 -0
- package/node_modules/@sliverp/qqbot/dist/src/known-users.d.ts +100 -0
- package/node_modules/@sliverp/qqbot/dist/src/known-users.js +263 -0
- package/node_modules/@sliverp/qqbot/dist/src/onboarding.d.ts +10 -0
- package/node_modules/@sliverp/qqbot/dist/src/onboarding.js +203 -0
- package/node_modules/@sliverp/qqbot/dist/src/openclaw-agent-adapter.d.ts +2 -0
- package/node_modules/@sliverp/qqbot/dist/src/openclaw-agent-adapter.js +155 -0
- package/node_modules/@sliverp/qqbot/dist/src/outbound.d.ts +150 -0
- package/node_modules/@sliverp/qqbot/dist/src/outbound.js +1175 -0
- package/node_modules/@sliverp/qqbot/dist/src/proactive.d.ts +170 -0
- package/node_modules/@sliverp/qqbot/dist/src/proactive.js +399 -0
- package/node_modules/@sliverp/qqbot/dist/src/runtime.d.ts +5 -0
- package/node_modules/@sliverp/qqbot/dist/src/runtime.js +16 -0
- package/node_modules/@sliverp/qqbot/dist/src/session-store.d.ts +52 -0
- package/node_modules/@sliverp/qqbot/dist/src/session-store.js +254 -0
- package/node_modules/@sliverp/qqbot/dist/src/types.d.ts +145 -0
- package/node_modules/@sliverp/qqbot/dist/src/types.js +1 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/audio-convert.d.ts +73 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/audio-convert.js +645 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/file-utils.d.ts +46 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/file-utils.js +107 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/image-size.d.ts +51 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/image-size.js +234 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/media-tags.d.ts +14 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/media-tags.js +120 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/payload.d.ts +112 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/payload.js +186 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/platform.d.ts +126 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/platform.js +358 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/upload-cache.d.ts +34 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/upload-cache.js +93 -0
- package/node_modules/@sliverp/qqbot/dist/standalone.d.ts +6 -0
- package/node_modules/@sliverp/qqbot/dist/standalone.js +6 -0
- package/node_modules/@sliverp/qqbot/index.ts +30 -0
- package/node_modules/@sliverp/qqbot/moltbot.plugin.json +16 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/LICENSE +201 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/README.md +134 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/browser.js +17 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/cjs/browser.js +16 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/cjs/node.js +219 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/index.d.ts +4 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/node.js +223 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/package.json +54 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/index.js +5 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/package.json +36 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/WASMAudioDecoderCommon.js +231 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/WASMAudioDecoderWorker.js +129 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/README +67 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/build_puff.js +31 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/puff.c +863 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/puff.h +35 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/utilities.js +3 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/types.d.ts +7 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/README.md +265 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/dist/mpg123-decoder.min.js +185 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/dist/mpg123-decoder.min.js.map +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/index.js +8 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/package.json +58 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/src/EmscriptenWasm.js +464 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/src/MPEGDecoder.js +200 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/src/MPEGDecoderWebWorker.js +21 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/types.d.ts +30 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/LICENSE +21 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/README.md +85 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/index.cjs +16 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/index.d.ts +70 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/index.mjs +16 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/silk.wasm +0 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/utils.d.ts +4 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/package.json +39 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/.github/FUNDING.yml +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/.prettierignore +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/LICENSE +7 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/README.md +163 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/dist/esm.js +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/dist/index.js +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/package.json +50 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/rollup.config.js +27 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/src/simple-yenc.js +302 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/LICENSE +20 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/README.md +548 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/browser.js +8 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/index.js +13 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/constants.js +19 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/receiver.js +706 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/sender.js +602 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/websocket-server.js +554 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/websocket.js +1393 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/package.json +69 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/wrapper.mjs +8 -0
- package/node_modules/@sliverp/qqbot/openclaw.plugin.json +16 -0
- package/node_modules/@sliverp/qqbot/package.json +81 -0
- package/node_modules/@sliverp/qqbot/skills/qqbot-cron/SKILL.md +513 -0
- package/node_modules/@sliverp/qqbot/skills/qqbot-media/SKILL.md +194 -0
- package/node_modules/@sliverp/qqbot/src/agent.ts +133 -0
- package/node_modules/@sliverp/qqbot/src/api.ts +704 -0
- package/node_modules/@sliverp/qqbot/src/channel.ts +380 -0
- package/node_modules/@sliverp/qqbot/src/config.ts +182 -0
- package/node_modules/@sliverp/qqbot/src/demo-standalone.ts +144 -0
- package/node_modules/@sliverp/qqbot/src/gateway.ts +2285 -0
- package/node_modules/@sliverp/qqbot/src/image-server.ts +474 -0
- package/node_modules/@sliverp/qqbot/src/known-users.ts +353 -0
- package/node_modules/@sliverp/qqbot/src/onboarding.ts +274 -0
- package/node_modules/@sliverp/qqbot/src/openclaw-agent-adapter.ts +168 -0
- package/node_modules/@sliverp/qqbot/src/openclaw-plugin-sdk.d.ts +483 -0
- package/node_modules/@sliverp/qqbot/src/outbound.ts +1301 -0
- package/node_modules/@sliverp/qqbot/src/proactive.ts +530 -0
- package/node_modules/@sliverp/qqbot/src/runtime.ts +22 -0
- package/node_modules/@sliverp/qqbot/src/session-store.ts +303 -0
- package/node_modules/@sliverp/qqbot/src/types.ts +153 -0
- package/node_modules/@sliverp/qqbot/src/utils/audio-convert.ts +738 -0
- package/node_modules/@sliverp/qqbot/src/utils/file-utils.ts +122 -0
- package/node_modules/@sliverp/qqbot/src/utils/image-size.ts +266 -0
- package/node_modules/@sliverp/qqbot/src/utils/media-tags.ts +134 -0
- package/node_modules/@sliverp/qqbot/src/utils/payload.ts +265 -0
- package/node_modules/@sliverp/qqbot/src/utils/platform.ts +404 -0
- package/node_modules/@sliverp/qqbot/src/utils/upload-cache.ts +128 -0
- package/node_modules/@sliverp/qqbot/standalone.ts +6 -0
- package/node_modules/@sliverp/qqbot/tsconfig.json +16 -0
- package/package.json +10 -2
- package/dist/BasicAgent-QWEYCLV5.js +0 -12
- package/dist/ExplorerAgent-4IT22VB7.js +0 -12
- package/dist/chunk-3BPSNNK3.js.map +0 -1
- package/dist/chunk-LLV3W326.js.map +0 -1
- package/dist/chunk-LQTEETML.js.map +0 -1
- package/dist/chunk-OBOU27DM.js.map +0 -1
- package/dist/chunk-TSASFMRF.js.map +0 -1
- /package/dist/{BasicAgent-QWEYCLV5.js.map → BasicAgent-R7DYGTHF.js.map} +0 -0
- /package/dist/{ExplorerAgent-4IT22VB7.js.map → ExplorerAgent-DXY3OQ5U.js.map} +0 -0
- /package/dist/{notification-3VEAP7YF.js.map → notification-NWVOS2WR.js.map} +0 -0
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
createLLM,
|
|
8
8
|
getDefaultMCPConfigDir,
|
|
9
9
|
loadConfigSync
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-3AR3JBW6.js";
|
|
11
11
|
|
|
12
12
|
// src/agents/system/BasicAgent.ts
|
|
13
13
|
import { existsSync } from "fs";
|
|
14
14
|
import { cwd, platform } from "process";
|
|
15
|
-
var BasicAgent = class extends AgentBase {
|
|
15
|
+
var BasicAgent = class _BasicAgent extends AgentBase {
|
|
16
16
|
_systemContext;
|
|
17
17
|
_mcpServer;
|
|
18
18
|
_mcpContext;
|
|
@@ -25,9 +25,10 @@ var BasicAgent = class extends AgentBase {
|
|
|
25
25
|
* @param config 基础配置(全部可选,不传则使用默认配置)
|
|
26
26
|
*/
|
|
27
27
|
constructor(config = {}) {
|
|
28
|
+
const workspaceDir = config.workspaceDir ?? cwd();
|
|
28
29
|
const systemContext = {
|
|
29
|
-
SYSTEM_WORKING_DIR:
|
|
30
|
-
SYSTEM_IS_GIT_REPOSITORY: existsSync(
|
|
30
|
+
SYSTEM_WORKING_DIR: workspaceDir,
|
|
31
|
+
SYSTEM_IS_GIT_REPOSITORY: existsSync(workspaceDir + "/.git"),
|
|
31
32
|
SYSTEM_PLATFORM: platform,
|
|
32
33
|
SYSTEM_DATE: (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
|
|
33
34
|
// YYYY-MM-DD
|
|
@@ -48,7 +49,9 @@ var BasicAgent = class extends AgentBase {
|
|
|
48
49
|
tools: config.tools ?? [],
|
|
49
50
|
maxTurns: Infinity,
|
|
50
51
|
systemMessage: config.systemMessage,
|
|
51
|
-
name: config.name
|
|
52
|
+
name: config.name,
|
|
53
|
+
projectRoot: config.projectRoot,
|
|
54
|
+
workspaceDir
|
|
52
55
|
};
|
|
53
56
|
super(agentConfig);
|
|
54
57
|
this._systemContext = systemContext;
|
|
@@ -66,11 +69,13 @@ var BasicAgent = class extends AgentBase {
|
|
|
66
69
|
}
|
|
67
70
|
this.use(this._mcpFeature);
|
|
68
71
|
}
|
|
69
|
-
this.use(new OpencodeBasicFeature());
|
|
72
|
+
this.use(new OpencodeBasicFeature({ workspaceDir }));
|
|
70
73
|
this.use(new SkillFeature(config.skillsDir));
|
|
71
74
|
this.use(new SubAgentFeature());
|
|
72
75
|
this.getTools().disable("list_agents");
|
|
73
76
|
this.getTools().disable("close_agent");
|
|
77
|
+
this.registerAgentType("BasicAgent", () => new _BasicAgent({ llm: this.llm }));
|
|
78
|
+
this.registerAgentType("ExplorerAgent", () => import("./ExplorerAgent-DXY3OQ5U.js").then((m) => new m.ExplorerAgent({ llm: this.llm })));
|
|
74
79
|
}
|
|
75
80
|
/**
|
|
76
81
|
* 获取系统环境信息
|
|
@@ -95,4 +100,4 @@ var BasicAgent = class extends AgentBase {
|
|
|
95
100
|
export {
|
|
96
101
|
BasicAgent
|
|
97
102
|
};
|
|
98
|
-
//# sourceMappingURL=chunk-
|
|
103
|
+
//# sourceMappingURL=chunk-REOJZCSZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agents/system/BasicAgent.ts"],"sourcesContent":["/**\r\n * BasicAgent - 基础 Agent 类\r\n *\r\n * 集成了常用 Feature 和系统环境信息\r\n * 适用于大多数 Agent 场景\r\n *\r\n * 默认自动加载配置文件,开箱即用\r\n */\r\n\r\nimport { Agent } from '../../core/agent.js';\r\nimport { MCPFeature, SkillFeature, SubAgentFeature, OpencodeBasicFeature } from '../../features/index.js';\r\nimport type { AgentConfig, LLMClient, Tool } from '../../core/types.js';\r\nimport type { AgentConfigFile } from '../../core/config.js';\r\nimport { loadConfigSync } from '../../core/config.js';\r\nimport { createLLM } from '../../llm/index.js';\r\nimport { existsSync } from 'fs';\r\nimport { cwd, platform } from 'process';\r\nimport { getDefaultMCPConfigDir } from '../../mcp/config.js';\r\n\r\n/**\r\n * 系统环境信息上下文\r\n */\r\nexport interface SystemContext {\r\n /** 当前工作目录 */\r\n SYSTEM_WORKING_DIR: string;\r\n /** 是否是 Git 仓库 */\r\n SYSTEM_IS_GIT_REPOSITORY: boolean;\r\n /** 操作系统平台 */\r\n SYSTEM_PLATFORM: NodeJS.Platform;\r\n /** 当前日期 (YYYY-MM-DD) */\r\n SYSTEM_DATE: string;\r\n /** 当前使用的模型名称 */\r\n SYSTEM_CURRENT_MODEL: string;\r\n /** 索引签名,允许作为 PlaceholderContext 使用 */\r\n [key: string]: any;\r\n}\r\n\r\n/**\r\n * BasicAgent 配置选项\r\n *\r\n * 所有参数都是可选的,默认会自动同步加载配置文件\r\n */\r\nexport interface BasicAgentConfig {\n /** LLM 客户端(可选,不传则自动同步加载配置创建) */\r\n llm?: LLMClient;\r\n /** 配置文件名(可选,默认 'default') */\r\n configName?: string;\r\n /** Agent 显示名称(可选) */\r\n name?: string;\r\n /** 系统提示词(可选,后续可通过 setPrompt() 设置) */\r\n systemMessage?: string;\r\n /** MCP 配置:传字符串时加载指定配置;传 false 时禁用自动加载;不传时若 .agentdev/mcps 存在则自动加载全部 */\r\n mcpServer?: string | false;\r\n /** MCP 运行时上下文(可选,如 GitHub Token) */\r\n mcpContext?: Record<string, unknown>;\r\n /** 自动扫描 MCP 时排除的 serverId 列表 */\r\n excludeMcpServers?: string[];\r\n /** 自定义工具集(可选,默认使用 Feature 提供的工具) */\r\n tools?: Tool[];\r\n /** Skills 目录(可选,默认使用 .agentdev/skills) */\n skillsDir?: string;\n /** 调试器和模板解析使用的项目根目录 */\n projectRoot?: string;\n /** 工具默认操作的工作目录 */\n workspaceDir?: string;\n}\n\r\n/**\r\n * 基础 Agent 类\r\n *\r\n * 集成常用 Feature 和系统环境信息,开箱即用\r\n * 构造函数不传任何参数时,会自动同步加载配置文件创建 LLM\r\n */\r\nexport class BasicAgent extends Agent {\r\n protected _systemContext: SystemContext;\r\n protected _mcpServer?: string | false;\r\n protected _mcpContext?: Record<string, unknown>;\r\n protected _config?: AgentConfigFile;\r\n protected _skillsDir?: string;\r\n protected _mcpFeature?: MCPFeature;\r\n\r\n /**\r\n * 构造函数\r\n *\r\n * @param config 基础配置(全部可选,不传则使用默认配置)\r\n */\r\n constructor(config: BasicAgentConfig = {}) {\n const workspaceDir = config.workspaceDir ?? cwd();\n // 建立系统环境信息\n const systemContext: SystemContext = {\n SYSTEM_WORKING_DIR: workspaceDir,\n SYSTEM_IS_GIT_REPOSITORY: existsSync(workspaceDir + '/.git'),\n SYSTEM_PLATFORM: platform,\n SYSTEM_DATE: new Date().toISOString().split('T')[0], // YYYY-MM-DD\r\n SYSTEM_CURRENT_MODEL: 'unknown', // 稍后更新\r\n };\r\n\r\n // 准备 LLM:如果没传入,同步加载配置\r\n let llm = config.llm;\r\n let fileConfig: AgentConfigFile | undefined;\r\n if (!llm) {\r\n const configName = config.configName ?? 'default';\r\n fileConfig = loadConfigSync(configName);\r\n llm = createLLM(fileConfig);\r\n systemContext.SYSTEM_CURRENT_MODEL = fileConfig.defaultModel.model;\r\n console.log(`[BasicAgent] 已加载配置: ${configName}, 模型: ${fileConfig.defaultModel.model}`);\r\n }\r\n\r\n // 构建完整的 Agent 配置\r\n const agentConfig: AgentConfig = {\r\n llm: llm!,\r\n tools: config.tools ?? [],\r\n maxTurns: Infinity,\n systemMessage: config.systemMessage,\n name: config.name,\n projectRoot: config.projectRoot,\n workspaceDir,\n };\n\r\n super(agentConfig);\r\n\r\n // 保存配置(必须在 super() 之后)\r\n this._systemContext = systemContext;\r\n this._config = fileConfig;\r\n this._mcpServer = config.mcpServer;\r\n this._mcpContext = config.mcpContext;\r\n this._skillsDir = config.skillsDir;\r\n this.setSystemContext(systemContext);\r\n\r\n const hasDefaultMCPConfigs = existsSync(getDefaultMCPConfigDir());\r\n const shouldEnableMCP = config.mcpServer !== false && (typeof config.mcpServer === 'string' || hasDefaultMCPConfigs);\r\n if (shouldEnableMCP) {\r\n this._mcpFeature = typeof config.mcpServer === 'string'\r\n ? new MCPFeature(config.mcpServer)\r\n : new MCPFeature(undefined, { excludeServers: config.excludeMcpServers });\r\n if (config.mcpContext) {\r\n this._mcpFeature.setMCPContext(config.mcpContext);\r\n }\r\n this.use(this._mcpFeature);\r\n }\r\n\r\n // 注册 OpencodeBasicFeature(文件操作工具集)\r\n this.use(new OpencodeBasicFeature({ workspaceDir }));\n\r\n // 注册 SkillFeature(invokeSkill 工具和 skills 上下文注入)\r\n this.use(new SkillFeature(config.skillsDir));\r\n\r\n // 注册 SubAgentFeature(子代理工具和消息处理)\r\n this.use(new SubAgentFeature());\r\n\r\n // 预禁用不需要的子代理工具,确保首次快照与运行时一致\r\n this.getTools().disable('list_agents');\r\n this.getTools().disable('close_agent');\r\n\r\n // 注册可创建的子代理类型\r\n this.registerAgentType('BasicAgent', () => new BasicAgent({ llm: this.llm }));\r\n this.registerAgentType('ExplorerAgent', () => import('./ExplorerAgent.js').then(m => new m.ExplorerAgent({ llm: this.llm })));\r\n }\r\n\r\n /**\r\n * 获取系统环境信息\r\n */\r\n getSystemContext(): SystemContext {\r\n return this._systemContext;\r\n }\r\n\r\n /**\r\n * 获取 MCP 服务器配置\r\n */\r\n getMcpServer(): string | false | undefined {\r\n return this._mcpServer;\r\n }\r\n\r\n /**\r\n * 获取 MCP 上下文\r\n */\r\n getMcpContext(): Record<string, unknown> | undefined {\r\n return this._mcpContext;\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAeA,SAAS,kBAAkB;AAC3B,SAAS,KAAK,gBAAgB;AAyDvB,IAAM,aAAN,MAAM,oBAAmB,UAAM;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOV,YAAY,SAA2B,CAAC,GAAG;AACzC,UAAM,eAAe,OAAO,gBAAgB,IAAI;AAEhD,UAAM,gBAA+B;AAAA,MACnC,oBAAoB;AAAA,MACpB,0BAA0B,WAAW,eAAe,OAAO;AAAA,MAC3D,iBAAiB;AAAA,MACjB,cAAa,oBAAI,KAAK,GAAE,YAAY,EAAE,MAAM,GAAG,EAAE,CAAC;AAAA;AAAA,MAClD,sBAAsB;AAAA;AAAA,IACxB;AAGA,QAAI,MAAM,OAAO;AACjB,QAAI;AACJ,QAAI,CAAC,KAAK;AACR,YAAM,aAAa,OAAO,cAAc;AACxC,mBAAa,eAAe,UAAU;AACtC,YAAM,UAAU,UAAU;AAC1B,oBAAc,uBAAuB,WAAW,aAAa;AAC7D,cAAQ,IAAI,gDAAuB,UAAU,mBAAS,WAAW,aAAa,KAAK,EAAE;AAAA,IACvF;AAGA,UAAM,cAA2B;AAAA,MAC/B;AAAA,MACA,OAAO,OAAO,SAAS,CAAC;AAAA,MACxB,UAAU;AAAA,MACV,eAAe,OAAO;AAAA,MACtB,MAAM,OAAO;AAAA,MACb,aAAa,OAAO;AAAA,MACpB;AAAA,IACF;AAEA,UAAM,WAAW;AAGjB,SAAK,iBAAiB;AACtB,SAAK,UAAU;AACf,SAAK,aAAa,OAAO;AACzB,SAAK,cAAc,OAAO;AAC1B,SAAK,aAAa,OAAO;AACzB,SAAK,iBAAiB,aAAa;AAEnC,UAAM,uBAAuB,WAAW,uBAAuB,CAAC;AAChE,UAAM,kBAAkB,OAAO,cAAc,UAAU,OAAO,OAAO,cAAc,YAAY;AAC/F,QAAI,iBAAiB;AACnB,WAAK,cAAc,OAAO,OAAO,cAAc,WAC3C,IAAI,WAAW,OAAO,SAAS,IAC/B,IAAI,WAAW,QAAW,EAAE,gBAAgB,OAAO,kBAAkB,CAAC;AAC1E,UAAI,OAAO,YAAY;AACrB,aAAK,YAAY,cAAc,OAAO,UAAU;AAAA,MAClD;AACA,WAAK,IAAI,KAAK,WAAW;AAAA,IAC3B;AAGA,SAAK,IAAI,IAAI,qBAAqB,EAAE,aAAa,CAAC,CAAC;AAGnD,SAAK,IAAI,IAAI,aAAa,OAAO,SAAS,CAAC;AAG3C,SAAK,IAAI,IAAI,gBAAgB,CAAC;AAG9B,SAAK,SAAS,EAAE,QAAQ,aAAa;AACrC,SAAK,SAAS,EAAE,QAAQ,aAAa;AAGrC,SAAK,kBAAkB,cAAc,MAAM,IAAI,YAAW,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC;AAC5E,SAAK,kBAAkB,iBAAiB,MAAM,OAAO,6BAAoB,EAAE,KAAK,OAAK,IAAI,EAAE,cAAc,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC;AAAA,EAC9H;AAAA;AAAA;AAAA;AAAA,EAKA,mBAAkC;AAChC,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,eAA2C;AACzC,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAqD;AACnD,WAAO,KAAK;AAAA,EACd;AACF;","names":[]}
|
package/dist/cli/server.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ViewerWorker
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-NORTAQIL.js";
|
|
5
5
|
import {
|
|
6
6
|
getDefaultUDSPath
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-BAP2GCYH.js";
|
|
8
8
|
import "../chunk-BDS2QGZ5.js";
|
|
9
9
|
|
|
10
10
|
// src/cli/server.ts
|
package/dist/cli/viewer.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ViewerWorker
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-NORTAQIL.js";
|
|
5
5
|
import {
|
|
6
6
|
getDefaultUDSPath
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-BAP2GCYH.js";
|
|
8
8
|
import "../chunk-BDS2QGZ5.js";
|
|
9
9
|
|
|
10
10
|
// src/cli/viewer.ts
|
|
@@ -20,6 +20,7 @@ async function createFeature(featureName2) {
|
|
|
20
20
|
mkdirSync(join(targetDir, "scripts"), { recursive: true });
|
|
21
21
|
generatePackageJson(targetDir, packageName, featureSlug);
|
|
22
22
|
generateTsConfig(targetDir);
|
|
23
|
+
generateTsupConfig(targetDir);
|
|
23
24
|
generateCopyAssetsScript(targetDir);
|
|
24
25
|
generateMinimalFeatureClass(targetDir, featureClass);
|
|
25
26
|
generateMinimalReadme(targetDir, packageName, featureSlug);
|
|
@@ -45,13 +46,6 @@ function generatePackageJson(targetDir, packageName, featureSlug) {
|
|
|
45
46
|
"copy-assets": "node scripts/copy-assets.mjs",
|
|
46
47
|
prepublishOnly: "npm run build"
|
|
47
48
|
},
|
|
48
|
-
tsup: {
|
|
49
|
-
entry: ["src/index.ts", "src/templates/*.render.ts"],
|
|
50
|
-
format: "esm",
|
|
51
|
-
dts: true,
|
|
52
|
-
clean: true,
|
|
53
|
-
sourcemap: true
|
|
54
|
-
},
|
|
55
49
|
peerDependencies: {
|
|
56
50
|
agentdev: ">=0.1.0"
|
|
57
51
|
},
|
|
@@ -88,6 +82,31 @@ function generateTsConfig(targetDir) {
|
|
|
88
82
|
};
|
|
89
83
|
writeFileSync(join(targetDir, "tsconfig.json"), JSON.stringify(tsConfig, null, 2));
|
|
90
84
|
}
|
|
85
|
+
function generateTsupConfig(targetDir) {
|
|
86
|
+
const content = `import { existsSync, readdirSync } from 'fs';
|
|
87
|
+
import { defineConfig } from 'tsup';
|
|
88
|
+
|
|
89
|
+
function getTemplateEntries(): string[] {
|
|
90
|
+
const templateDir = 'src/templates';
|
|
91
|
+
if (!existsSync(templateDir)) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return readdirSync(templateDir)
|
|
96
|
+
.filter((name) => name.endsWith('.render.ts'))
|
|
97
|
+
.map((name) => \`\${templateDir}/\${name}\`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default defineConfig({
|
|
101
|
+
entry: ['src/index.ts', ...getTemplateEntries()],
|
|
102
|
+
format: ['esm'],
|
|
103
|
+
dts: true,
|
|
104
|
+
clean: true,
|
|
105
|
+
sourcemap: true,
|
|
106
|
+
});
|
|
107
|
+
`;
|
|
108
|
+
writeFileSync(join(targetDir, "tsup.config.ts"), content);
|
|
109
|
+
}
|
|
91
110
|
function generateMinimalFeatureClass(targetDir, featureClass) {
|
|
92
111
|
const className = toCamelCase(featureClass);
|
|
93
112
|
const content = `/**
|