@bolloon/bolloon-agent 0.3.38 → 0.3.41
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/README.md +135 -135
- package/bin/bolloon-cli.cjs +183 -183
- package/bin/bolloon.cjs +0 -0
- package/bin/bolloon.js +157 -0
- package/dist/agents/constraint-layer.js +19 -19
- package/dist/agents/judgment-protocol.js +14 -14
- package/dist/agents/loop-review.js +58 -0
- package/dist/agents/pi-sdk-types.js +12 -12
- package/dist/agents/pi-sdk.js +113 -89
- package/dist/agents/workflow-pivot-loop.js +2 -2
- package/dist/bollharness/src/scripts/deploy-guard.js +8 -8
- package/dist/bollharness-integration/context-router-judgment.js +4 -4
- package/dist/bollharness-integration/context-router.js +292 -292
- package/dist/bollharness-integration/gate-state-machine.js +13 -13
- package/dist/bollharness-integration/llm-judgment-engine.js +134 -134
- package/dist/bollharness-integration/skill-adapter.js +21 -21
- package/dist/bootstrap/bootstrap.js +19 -1
- package/dist/bootstrap/chat-archiver.js +14 -14
- package/dist/bootstrap/context-os.js +21 -21
- package/dist/bootstrap/memory-compressor.js +13 -13
- package/dist/cli/mention-data.js +2 -1
- package/dist/cli-entry.js +36 -36
- package/dist/constraint-runtime/setup.js +1 -1
- package/dist/constraint-runtime/tools/PolymarketSDK/cancelOrder.d.ts +3 -13
- package/dist/constraint-runtime/tools/PolymarketSDK/cancelOrder.js +4 -16
- package/dist/constraint-runtime/tools/PolymarketSDK/createOrder.d.ts +3 -24
- package/dist/constraint-runtime/tools/PolymarketSDK/createOrder.js +4 -31
- package/dist/constraint-runtime/tools/PolymarketSDK/getMarket.d.ts +0 -1
- package/dist/constraint-runtime/tools/PolymarketSDK/getMarket.js +3 -14
- package/dist/constraint-runtime/tools/PolymarketSDK/getOrders.d.ts +2 -11
- package/dist/constraint-runtime/tools/PolymarketSDK/getOrders.js +4 -23
- package/dist/constraint-runtime/tools/PolymarketSDK/listMarkets.d.ts +0 -4
- package/dist/constraint-runtime/tools/PolymarketSDK/listMarkets.js +2 -22
- package/dist/context-compaction/auto-compact.js +7 -7
- package/dist/electron/first-run.js +54 -54
- package/dist/electron-build/electron/first-run.js +54 -54
- package/dist/electron-preload.js.map +1 -1
- package/dist/electron.js.map +1 -1
- package/dist/index.js +112 -112
- package/dist/llm/llm-judgment-client.js +102 -102
- package/dist/llm/pi-ai.js +48 -48
- package/dist/llm/system-prompt/layers/channel/human-async.md +41 -41
- package/dist/llm/system-prompt/layers/channel/local.md +14 -14
- package/dist/llm/system-prompt/layers/channel/p2p-agent.md +18 -18
- package/dist/llm/system-prompt/layers/channel/p2p-peer-sync.md +51 -51
- package/dist/llm/system-prompt/layers/channel/p2p-proactive.md +43 -43
- package/dist/llm/system-prompt/layers/channel/p2p-visitor.md +19 -19
- package/dist/llm/system-prompt/layers/channel/session-handoff.md +61 -61
- package/dist/llm/system-prompt/layers/core/artifacts_storage.md +89 -89
- package/dist/llm/system-prompt/layers/core/evenhandedness.md +21 -21
- package/dist/llm/system-prompt/layers/core/external-engagement.md +73 -73
- package/dist/llm/system-prompt/layers/core/hibs_reminders.md +15 -15
- package/dist/llm/system-prompt/layers/core/identity.md +48 -48
- package/dist/llm/system-prompt/layers/core/knowledge.md +17 -17
- package/dist/llm/system-prompt/layers/core/memory_system.md +12 -12
- package/dist/llm/system-prompt/layers/core/network_filesystem.md +28 -28
- package/dist/llm/system-prompt/layers/core/refusal.md +37 -37
- package/dist/llm/system-prompt/layers/core/tone.md +31 -31
- package/dist/llm/system-prompt/layers/core/tools.thin.md +13 -13
- package/dist/llm/system-prompt/layers/core/wellbeing.md +41 -41
- package/dist/llm/system-prompt/layers/role/architect.md +20 -20
- package/dist/llm/system-prompt/layers/role/expert.md +19 -19
- package/dist/llm/system-prompt/layers/role/implementer.md +15 -15
- package/dist/llm/system-prompt/layers/role/security.md +15 -15
- package/dist/llm/system-prompt/layers/tool/artifacts.md +72 -72
- package/dist/llm/system-prompt/layers/tool/bash.md +25 -25
- package/dist/llm/system-prompt/layers/tool/goal_handoff.md +77 -77
- package/dist/llm/system-prompt/layers/tool/hibs_api.md +171 -171
- package/dist/llm/system-prompt/layers/tool/image_search.md +70 -70
- package/dist/llm/system-prompt/layers/tool/manifest.md +89 -89
- package/dist/llm/system-prompt/layers/tool/mcp_apps.md +53 -53
- package/dist/llm/system-prompt/layers/tool/p2p_request.md +61 -61
- package/dist/llm/system-prompt/layers/tool/web_search.md +83 -83
- package/dist/llm/tool-manifest/ask_user_input.js +1 -1
- package/dist/llm/tool-manifest/bash.js +3 -3
- package/dist/llm/tool-manifest/create_file.js +4 -4
- package/dist/llm/tool-manifest/fetch_sports_data.js +3 -3
- package/dist/llm/tool-manifest/image_search.js +2 -2
- package/dist/llm/tool-manifest/index.js +0 -59
- package/dist/llm/tool-manifest/mcp.js +2 -2
- package/dist/llm/tool-manifest/message_compose.js +3 -3
- package/dist/llm/tool-manifest/places.js +2 -2
- package/dist/llm/tool-manifest/present_files.js +1 -1
- package/dist/llm/tool-manifest/recipe.js +2 -2
- package/dist/llm/tool-manifest/str_replace.js +5 -5
- package/dist/llm/tool-manifest/view.js +3 -3
- package/dist/llm/tool-manifest/weather.js +4 -4
- package/dist/llm/tool-manifest/web.js +4 -4
- package/dist/migration/external-agent-migrator.js +405 -0
- package/dist/pi-ecosystem-colony/index.js +365 -0
- package/dist/pi-ecosystem-judgment/causal-judge.js +51 -51
- package/dist/pi-ecosystem-judgment/distill-prompt.js +42 -42
- package/dist/pi-ecosystem-judgment/distillation.js +14 -14
- package/dist/pi-ecosystem-judgment/monitor-gate.js +28 -28
- package/dist/pi-ecosystem-judgment/value-injection.js +102 -102
- package/dist/security/context-router-tool.js +15 -15
- package/dist/social/ant-colony/AdaptiveHeartbeat.js +101 -0
- package/dist/social/ant-colony/PheromoneEngine.js +227 -0
- package/dist/social/ant-colony/index.js +6 -0
- package/dist/social/ant-colony/types.js +24 -0
- package/dist/test/ai-judgment-test.js +80 -0
- package/dist/test/bollharness-integration.test.js +318 -0
- package/dist/test/channel-agent-multi-dialogue.js +205 -0
- package/dist/test/channel-heartbeat-agent-test.js +201 -0
- package/dist/test/constraint-layer.test.js +164 -0
- package/dist/test/diap-identity-test.js +172 -0
- package/dist/test/diap-quick-test.js +62 -0
- package/dist/test/global-shared-context.test.js +315 -0
- package/dist/test/harness-judgment-injection.test.js +246 -0
- package/dist/test/harness-workflow-integrator-test.js +228 -0
- package/dist/test/human-value-store.test.js +243 -0
- package/dist/test/hybrid-integration-test.js +118 -0
- package/dist/test/hybrid-messenger-verify.js +55 -0
- package/dist/test/iroh-bistream-debug.js +38 -0
- package/dist/test/iroh-communication.test.js +66 -0
- package/dist/test/iroh-debug-test.js +57 -0
- package/dist/test/iroh-diap-test.js +71 -0
- package/dist/test/iroh-direct-connect.js +55 -0
- package/dist/test/iroh-e2e-fixed.js +89 -0
- package/dist/test/iroh-e2e-same-process.js +63 -0
- package/dist/test/iroh-e2e.js +66 -0
- package/dist/test/iroh-final-e2e.js +72 -0
- package/dist/test/iroh-relay-test.js +37 -0
- package/dist/test/iroh-simple-test.js +41 -0
- package/dist/test/iroh-transport-verify.js +54 -0
- package/dist/test/iroh-transport.test.js +37 -0
- package/dist/test/iroh-two-nodes.js +70 -0
- package/dist/test/iroh-verify.js +44 -0
- package/dist/test/judgment-decision.test.js +219 -0
- package/dist/test/llm-judgment-integration.test.js +220 -0
- package/dist/test/p2p-agent-complex-dialogue.js +385 -0
- package/dist/test/p2p-agent-dialogue.js +341 -0
- package/dist/test/p2p-agent-full-bidirectional.js +510 -0
- package/dist/test/p2p-agent-harness-flow.js +437 -0
- package/dist/test/p2p-agent-harness-single.js +143 -0
- package/dist/test/p2p-ai-dialogue-test.js +318 -0
- package/dist/test/p2p-cid-connect-test.js +195 -0
- package/dist/test/p2p-connect-receiver.js +69 -0
- package/dist/test/p2p-doc-transfer.js +110 -0
- package/dist/test/p2p-identity-page-test.js +77 -0
- package/dist/test/p2p-iroh-test.js +171 -0
- package/dist/test/p2p-minimal-test.js +241 -0
- package/dist/test/p2p-node-1.js +148 -0
- package/dist/test/p2p-node-2.js +148 -0
- package/dist/test/p2p-server.js +281 -0
- package/dist/test/p2p-two-nodes-test.js +438 -0
- package/dist/test/pi-sdk.test.js +44 -0
- package/dist/test/set-persona.js +40 -0
- package/dist/test/simple.test.js +9 -0
- package/dist/test/storage-integration.test.js +150 -0
- package/dist/test/subagent-manager.test.js +276 -0
- package/dist/test/test-gate-flow.test.js +81 -0
- package/dist/test/workflow-engine.test.js +87 -0
- package/dist/test/workflow-pivot-loop.test.js +246 -0
- package/dist/web/api-config.html +779 -779
- package/dist/web/client-hearth.js +10 -10
- package/dist/web/components/wallet-viem.mjs +118 -118
- package/dist/web/index.html +424 -424
- package/dist/web/manifest.json +20 -20
- package/dist/web/server.js +13 -13
- package/dist/web/style.css +4914 -4914
- package/package.json +193 -193
- package/scripts/build-cli.js +215 -215
- package/scripts/build-web.ts +130 -130
- package/scripts/postinstall.js +152 -152
- package/bin/bolloon-daemon.sh +0 -207
- package/dist/constraint-runtime/reference_data/archive_surface_snapshot.json +0 -63
- package/dist/constraint-runtime/reference_data/commands_snapshot.json +0 -1037
- package/dist/constraint-runtime/reference_data/subsystems/assistant.json +0 -8
- package/dist/constraint-runtime/reference_data/subsystems/bootstrap.json +0 -8
- package/dist/constraint-runtime/reference_data/subsystems/bridge.json +0 -32
- package/dist/constraint-runtime/reference_data/subsystems/buddy.json +0 -13
- package/dist/constraint-runtime/reference_data/subsystems/cli.json +0 -26
- package/dist/constraint-runtime/reference_data/subsystems/components.json +0 -32
- package/dist/constraint-runtime/reference_data/subsystems/constants.json +0 -28
- package/dist/constraint-runtime/reference_data/subsystems/coordinator.json +0 -8
- package/dist/constraint-runtime/reference_data/subsystems/entrypoints.json +0 -15
- package/dist/constraint-runtime/reference_data/subsystems/hooks.json +0 -32
- package/dist/constraint-runtime/reference_data/subsystems/keybindings.json +0 -21
- package/dist/constraint-runtime/reference_data/subsystems/memdir.json +0 -15
- package/dist/constraint-runtime/reference_data/subsystems/migrations.json +0 -18
- package/dist/constraint-runtime/reference_data/subsystems/moreright.json +0 -8
- package/dist/constraint-runtime/reference_data/subsystems/native_ts.json +0 -11
- package/dist/constraint-runtime/reference_data/subsystems/outputStyles.json +0 -8
- package/dist/constraint-runtime/reference_data/subsystems/plugins.json +0 -9
- package/dist/constraint-runtime/reference_data/subsystems/remote.json +0 -11
- package/dist/constraint-runtime/reference_data/subsystems/schemas.json +0 -8
- package/dist/constraint-runtime/reference_data/subsystems/screens.json +0 -10
- package/dist/constraint-runtime/reference_data/subsystems/server.json +0 -10
- package/dist/constraint-runtime/reference_data/subsystems/services.json +0 -32
- package/dist/constraint-runtime/reference_data/subsystems/skills.json +0 -27
- package/dist/constraint-runtime/reference_data/subsystems/state.json +0 -13
- package/dist/constraint-runtime/reference_data/subsystems/types.json +0 -18
- package/dist/constraint-runtime/reference_data/subsystems/upstreamproxy.json +0 -9
- package/dist/constraint-runtime/reference_data/subsystems/utils.json +0 -32
- package/dist/constraint-runtime/reference_data/subsystems/vim.json +0 -12
- package/dist/constraint-runtime/reference_data/subsystems/voice.json +0 -8
- package/dist/constraint-runtime/reference_data/tools_snapshot.json +0 -922
- package/dist/constraint-runtime/tools/PolymarketSDK/clobShared.d.ts +0 -50
- package/dist/constraint-runtime/tools/PolymarketSDK/clobShared.js +0 -78
- package/dist/electron/config.js.map +0 -1
- package/dist/electron/dialogs.js.map +0 -1
- package/dist/electron/first-run.js.map +0 -1
- package/dist/electron/ipc.js.map +0 -1
- package/dist/electron/logger.js.map +0 -1
- package/dist/electron/main.js.map +0 -1
- package/dist/electron/menu.js.map +0 -1
- package/dist/electron/paths.js.map +0 -1
- package/dist/electron/server.js.map +0 -1
- package/dist/electron/tray.js.map +0 -1
- package/dist/electron/window.js.map +0 -1
- package/dist/utils/auto-update.js.map +0 -1
- package/dist/web/client.js.map +0 -7
package/bin/bolloon.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const { spawn } = require("child_process");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
|
|
6
|
+
const RESET = "\x1b[0m";
|
|
7
|
+
const BOLD = "\x1b[1m";
|
|
8
|
+
const CYAN = "\x1b[36m";
|
|
9
|
+
const GREEN = "\x1b[32m";
|
|
10
|
+
const MAGENTA = "\x1b[35m";
|
|
11
|
+
|
|
12
|
+
function log(msg, color) {
|
|
13
|
+
console.log((color || RESET) + msg + RESET);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function printBanner() {
|
|
17
|
+
console.log("\n" + CYAN + BOLD + [
|
|
18
|
+
" ╔═══════════════════════════════════════════╗",
|
|
19
|
+
" ║ 🤖 Bolloon Agent ║",
|
|
20
|
+
" ║ P2P AI Document Processor ║",
|
|
21
|
+
" ╚═══════════════════════════════════════════╝"
|
|
22
|
+
].join("\n") + RESET + "\n");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getMainEntry() {
|
|
26
|
+
const distDir = path.dirname(require.main.filename);
|
|
27
|
+
const distIndex = path.join(distDir, "index.js");
|
|
28
|
+
if (fs.existsSync(distIndex)) {
|
|
29
|
+
return distIndex;
|
|
30
|
+
}
|
|
31
|
+
return path.join(process.cwd(), "src", "index.ts");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function parseArgs() {
|
|
35
|
+
const args = process.argv.slice(2);
|
|
36
|
+
if (args.length === 0) {
|
|
37
|
+
return { mode: "gui", args: [] };
|
|
38
|
+
}
|
|
39
|
+
const first = args[0];
|
|
40
|
+
switch (first) {
|
|
41
|
+
case "-v":
|
|
42
|
+
case "--version":
|
|
43
|
+
return { mode: "version", args: [] };
|
|
44
|
+
case "-h":
|
|
45
|
+
case "--help":
|
|
46
|
+
return { mode: "help", args: [] };
|
|
47
|
+
case "-g":
|
|
48
|
+
case "--gui":
|
|
49
|
+
return { mode: "gui", args: args.slice(1) };
|
|
50
|
+
case "-w":
|
|
51
|
+
case "--web":
|
|
52
|
+
return { mode: "web", args: args.slice(1) };
|
|
53
|
+
case "-c":
|
|
54
|
+
case "--cli":
|
|
55
|
+
return { mode: "cli", args: args.slice(1) };
|
|
56
|
+
default:
|
|
57
|
+
return { mode: "passthrough", args };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function startElectron(additionalArgs) {
|
|
62
|
+
try {
|
|
63
|
+
const electron = require("electron");
|
|
64
|
+
const distDir = path.dirname(require.main.filename);
|
|
65
|
+
let mainPath = path.join(distDir, "electron.js");
|
|
66
|
+
if (!fs.existsSync(mainPath)) {
|
|
67
|
+
mainPath = path.join(process.cwd(), "src", "electron.ts");
|
|
68
|
+
}
|
|
69
|
+
log("启动 Electron...", CYAN);
|
|
70
|
+
const child = spawn(electron, [mainPath, ...additionalArgs], {
|
|
71
|
+
stdio: "inherit",
|
|
72
|
+
env: { ...process.env, NODE_ENV: "development" }
|
|
73
|
+
});
|
|
74
|
+
child.on("error", (err) => {
|
|
75
|
+
log("Electron 启动失败: " + err.message, MAGENTA);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
});
|
|
78
|
+
child.on("exit", (code) => process.exit(code || 0));
|
|
79
|
+
} catch (err) {
|
|
80
|
+
log("Electron 不可用,切换到 Web 模式...", CYAN);
|
|
81
|
+
await startWebServer(additionalArgs);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function startWebServer(additionalArgs) {
|
|
86
|
+
const mainPath = getMainEntry();
|
|
87
|
+
const webArgs = ["--web", ...additionalArgs];
|
|
88
|
+
log("启动 Web 服务...", CYAN);
|
|
89
|
+
const child = spawn(process.execPath, [mainPath, ...webArgs], { stdio: "inherit" });
|
|
90
|
+
child.on("error", (err) => {
|
|
91
|
+
log("Web 服务启动失败: " + err.message, MAGENTA);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
});
|
|
94
|
+
child.on("exit", (code) => process.exit(code || 0));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function startCLI(additionalArgs) {
|
|
98
|
+
const mainPath = getMainEntry();
|
|
99
|
+
log("启动命令行界面...", CYAN);
|
|
100
|
+
const child = spawn(process.execPath, [mainPath, ...additionalArgs], { stdio: "inherit" });
|
|
101
|
+
child.on("error", (err) => {
|
|
102
|
+
log("CLI 启动失败: " + err.message, MAGENTA);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
});
|
|
105
|
+
child.on("exit", (code) => process.exit(code || 0));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function main() {
|
|
109
|
+
const { mode, args } = parseArgs();
|
|
110
|
+
switch (mode) {
|
|
111
|
+
case "version":
|
|
112
|
+
console.log("Bolloon Agent v0.1.1");
|
|
113
|
+
break;
|
|
114
|
+
case "help":
|
|
115
|
+
printBanner();
|
|
116
|
+
console.log(BOLD + "用法:" + RESET + " bolloon [选项] [命令] [参数]");
|
|
117
|
+
console.log(BOLD + "选项:" + RESET + " --gui, -g 启动图形界面");
|
|
118
|
+
console.log(" --web, -w 启动 Web UI");
|
|
119
|
+
console.log(" --cli, -c 启动命令行界面");
|
|
120
|
+
console.log(" --version, -v 显示版本");
|
|
121
|
+
console.log(" --help, -h 显示帮助");
|
|
122
|
+
console.log(BOLD + "示例:" + RESET + " bolloon # 启动图形界面");
|
|
123
|
+
console.log(" bolloon --web # 启动 Web UI");
|
|
124
|
+
console.log(" bolloon --read file # 读取文档");
|
|
125
|
+
break;
|
|
126
|
+
case "gui":
|
|
127
|
+
printBanner();
|
|
128
|
+
await startElectron(args);
|
|
129
|
+
break;
|
|
130
|
+
case "web":
|
|
131
|
+
printBanner();
|
|
132
|
+
await startWebServer(args);
|
|
133
|
+
break;
|
|
134
|
+
case "cli":
|
|
135
|
+
await startCLI(args);
|
|
136
|
+
break;
|
|
137
|
+
case "passthrough":
|
|
138
|
+
const mainPath = getMainEntry();
|
|
139
|
+
const child = spawn(process.execPath, [mainPath, ...args], { stdio: "inherit" });
|
|
140
|
+
child.on("error", (err) => {
|
|
141
|
+
log("执行失败: " + err.message, MAGENTA);
|
|
142
|
+
process.exit(1);
|
|
143
|
+
});
|
|
144
|
+
child.on("exit", (code) => process.exit(code || 0));
|
|
145
|
+
break;
|
|
146
|
+
default:
|
|
147
|
+
log("未知模式: " + mode, MAGENTA);
|
|
148
|
+
printBanner();
|
|
149
|
+
console.log("输入 --help 查看帮助");
|
|
150
|
+
process.exit(1);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
main().catch((err) => {
|
|
155
|
+
console.error("Fatal error:", err);
|
|
156
|
+
process.exit(1);
|
|
157
|
+
});
|
|
@@ -7,25 +7,25 @@ import { ToolPermissionContext, BudgetTracker } from '@bolloon/constraint-runtim
|
|
|
7
7
|
* System prompt for constraint layer
|
|
8
8
|
* Defines boundaries and autonomous permissions
|
|
9
9
|
*/
|
|
10
|
-
export const SYSTEM_PROMPT = `
|
|
11
|
-
你是一个文档处理Agent,在以下规则下运行:
|
|
12
|
-
|
|
13
|
-
【边界规则】
|
|
14
|
-
1. 只处理:txt, md, pdf, docx 格式文档
|
|
15
|
-
2. 不修改原始文件,只输出改进版本
|
|
16
|
-
3. 发送前必须记录操作日志
|
|
17
|
-
|
|
18
|
-
【自主权限】
|
|
19
|
-
- ✅ 自主决定:摘要详细程度、chunk分块策略
|
|
20
|
-
- ✅ 自主决定:重试次数(最多3次)
|
|
21
|
-
- ✅ 自主决定:是否需要补充信息
|
|
22
|
-
- ❌ 必须确认:首次向新对等节点发送文档
|
|
23
|
-
- ❌ 必须确认:删除操作
|
|
24
|
-
|
|
25
|
-
【敏感操作拦截】
|
|
26
|
-
if (操作 === '发送文档' && 对等节点不在已知列表) {
|
|
27
|
-
拦截 → 记录 → 等待确认
|
|
28
|
-
}
|
|
10
|
+
export const SYSTEM_PROMPT = `
|
|
11
|
+
你是一个文档处理Agent,在以下规则下运行:
|
|
12
|
+
|
|
13
|
+
【边界规则】
|
|
14
|
+
1. 只处理:txt, md, pdf, docx 格式文档
|
|
15
|
+
2. 不修改原始文件,只输出改进版本
|
|
16
|
+
3. 发送前必须记录操作日志
|
|
17
|
+
|
|
18
|
+
【自主权限】
|
|
19
|
+
- ✅ 自主决定:摘要详细程度、chunk分块策略
|
|
20
|
+
- ✅ 自主决定:重试次数(最多3次)
|
|
21
|
+
- ✅ 自主决定:是否需要补充信息
|
|
22
|
+
- ❌ 必须确认:首次向新对等节点发送文档
|
|
23
|
+
- ❌ 必须确认:删除操作
|
|
24
|
+
|
|
25
|
+
【敏感操作拦截】
|
|
26
|
+
if (操作 === '发送文档' && 对等节点不在已知列表) {
|
|
27
|
+
拦截 → 记录 → 等待确认
|
|
28
|
+
}
|
|
29
29
|
`;
|
|
30
30
|
/**
|
|
31
31
|
* Actions that can be executed autonomously without confirmation
|
|
@@ -148,20 +148,20 @@ export async function distillDissent(ask) {
|
|
|
148
148
|
.slice(-10)
|
|
149
149
|
.flatMap((j) => j.reasons || [])
|
|
150
150
|
.slice(0, 20);
|
|
151
|
-
const prompt = `你是用户的判断力代理. 用户发起了一个决定: "${ask.decision}"
|
|
152
|
-
${ask.context ? `\n补充: ${ask.context}` : ''}
|
|
153
|
-
|
|
154
|
-
[用户价值画像] ${valueHint}
|
|
155
|
-
[相关历史判断 (${relevant.length} 条)] ${relevant.slice(0, 3).map((j) => j.decision || '').join(' | ').slice(0, 300)}
|
|
156
|
-
[历史理由样本] ${recentReasons.join(' | ').slice(0, 400) || '(无)'}
|
|
157
|
-
|
|
158
|
-
请基于上述判断力, 生成正好 3 个"反方观点" (用户应该考虑但可能忽略的风险/盲点).
|
|
159
|
-
要求:
|
|
160
|
-
- 每个反方 1-2 句, 总长 < 80 字
|
|
161
|
-
- 必须是这个特定决定的"反对声音", 不是通用建议
|
|
162
|
-
- 第 1 个: 历史/经验类风险
|
|
163
|
-
- 第 2 个: 关系/信任类风险
|
|
164
|
-
- 第 3 个: 隐藏代价/时间类风险
|
|
151
|
+
const prompt = `你是用户的判断力代理. 用户发起了一个决定: "${ask.decision}"
|
|
152
|
+
${ask.context ? `\n补充: ${ask.context}` : ''}
|
|
153
|
+
|
|
154
|
+
[用户价值画像] ${valueHint}
|
|
155
|
+
[相关历史判断 (${relevant.length} 条)] ${relevant.slice(0, 3).map((j) => j.decision || '').join(' | ').slice(0, 300)}
|
|
156
|
+
[历史理由样本] ${recentReasons.join(' | ').slice(0, 400) || '(无)'}
|
|
157
|
+
|
|
158
|
+
请基于上述判断力, 生成正好 3 个"反方观点" (用户应该考虑但可能忽略的风险/盲点).
|
|
159
|
+
要求:
|
|
160
|
+
- 每个反方 1-2 句, 总长 < 80 字
|
|
161
|
+
- 必须是这个特定决定的"反对声音", 不是通用建议
|
|
162
|
+
- 第 1 个: 历史/经验类风险
|
|
163
|
+
- 第 2 个: 关系/信任类风险
|
|
164
|
+
- 第 3 个: 隐藏代价/时间类风险
|
|
165
165
|
- 用 JSON 数组返回: ["反方1", "反方2", "反方3"]`;
|
|
166
166
|
// LLM 调用 (OpenAI 兼容, 复用 p2p-chat-tools 的方式)
|
|
167
167
|
let dissents = [];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* loop-review.ts — "ReAct loop end" review 续跑决策门
|
|
3
|
+
*
|
|
4
|
+
* 动机 (2026-08-08, v0.3.39):
|
|
5
|
+
* - LLM 经常"潦草收尾": 达成上一轮成果就输出 <final gen>, 不深挖目标的更多可能.
|
|
6
|
+
* - 需求: 每次循环结束前 (LLM 想输出 <final gen> 时), 跑 1-2 次「目标对齐 + 需求深挖」,
|
|
7
|
+
* 吐出阶段性成果后再启动 review, 判断"是否还有可能继续触发".
|
|
8
|
+
* - 天花板: 逻辑上循环能持续最强 (不潦草终止), 时长上限的长循环由迭代上限兜底;
|
|
9
|
+
* 用户明确"结束指标以用户需求为准, 不过度深挖" — 达成用户需求就放行结束.
|
|
10
|
+
* - 工具调用次数无限制 (不在这里限, 由上层 MAX_REACT_ITERATIONS 兜底).
|
|
11
|
+
*
|
|
12
|
+
* 本模块是纯判定 + 提示文本生成, 不调 LLM. 由 pi-sdk 的 final gen 分支使用:
|
|
13
|
+
* 1. decideAfterReview — 判定 final 前该"续跑 review"还是"真正结束"
|
|
14
|
+
* 2. buildReviewHint — 构造注入 system 的续跑提示
|
|
15
|
+
* 3. shouldReviewAgain — 布尔门 (测试/消融用)
|
|
16
|
+
*
|
|
17
|
+
* 设计范式: 与 react-loop.ts 一致 (纯函数), 便于 claude code 独立单测消融边界.
|
|
18
|
+
*/
|
|
19
|
+
/** 每轮最多续跑 review 次数 — "运行一两次目标对齐和深挖" (用户明确) */
|
|
20
|
+
export const DEFAULT_MAX_REVIEWS = 2;
|
|
21
|
+
/**
|
|
22
|
+
* 判定: LLM 想 <final gen> 时, 该续跑一次 review 还是真正结束.
|
|
23
|
+
*
|
|
24
|
+
* 结束条件 (以下任一 → finish):
|
|
25
|
+
* - 没有明确用户需求 (无深挖对象, 不硬挖)
|
|
26
|
+
* - 已触发 maxReviews 次 review 续跑 (# 不无限续)
|
|
27
|
+
* 否则 → 续跑一次 (提示 LLM 对齐需求深挖).
|
|
28
|
+
*
|
|
29
|
+
* 注意: 续跑不是无限. 达上限即结束, 保证"不过度深挖".
|
|
30
|
+
*/
|
|
31
|
+
export function decideAfterReview(state, maxReviews = DEFAULT_MAX_REVIEWS) {
|
|
32
|
+
const intent = (state.userIntent || '').trim();
|
|
33
|
+
if (!intent) {
|
|
34
|
+
return { kind: 'finish', reason: 'no-user-intent' };
|
|
35
|
+
}
|
|
36
|
+
if (state.reviewsDone >= maxReviews) {
|
|
37
|
+
return { kind: 'finish', reason: `max-reviews-${maxReviews}` };
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
kind: 'continue-review',
|
|
41
|
+
reason: `${state.reviewsDone + 1}/${maxReviews} 目标对齐`,
|
|
42
|
+
hint: buildReviewHint(state, maxReviews),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** 构造 review 提示文本 (注入 system context, 让 LLM 深挖或确认完成) */
|
|
46
|
+
export function buildReviewHint(state, maxReviews = DEFAULT_MAX_REVIEWS) {
|
|
47
|
+
const intent = (state.userIntent || '').trim() || '(无)';
|
|
48
|
+
const tools = state.completedTools.length ? state.completedTools.join(', ') : '(尚未执行工具)';
|
|
49
|
+
return (`[目标对齐 review ${state.reviewsDone + 1}/${maxReviews}]\n` +
|
|
50
|
+
`用户需求: ${intent.slice(0, 300)}\n` +
|
|
51
|
+
`本轮已完成工具: ${tools}\n` +
|
|
52
|
+
`请对照需求自查: 是否还有未完成/可深挖的子目标? 若有 → 继续调用工具推进; ` +
|
|
53
|
+
`若已满足用户原始需求 → 直接输出 <final gen> 结束. 不要再重复已完成的动作.`);
|
|
54
|
+
}
|
|
55
|
+
/** 布尔门: 是否该继续 review (测试/消融快速断言) */
|
|
56
|
+
export function shouldReviewAgain(state, maxReviews = DEFAULT_MAX_REVIEWS) {
|
|
57
|
+
return decideAfterReview(state, maxReviews).kind === 'continue-review';
|
|
58
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export const TOOL_DEFINITIONS = `
|
|
2
|
-
可用工具:
|
|
3
|
-
1. read_document(path) - 读取文档内容,支持 .txt, .md, .pdf, .docx
|
|
4
|
-
2. summarize_document(path, context?) - 总结文档内容,可选提供上下文
|
|
5
|
-
3. improve_document(path, requirements) - 改进文档,需提供文件路径和改进要求
|
|
6
|
-
4. list_peers() - 列出已连接的对等节点
|
|
7
|
-
5. send_message(peer_id, message) - 向指定对等节点发送消息
|
|
8
|
-
6. broadcast_message(message) - 向所有对等节点广播消息
|
|
9
|
-
7. get_identity() - 获取当前智能体身份信息
|
|
10
|
-
8. set_persona(persona_json) - 更新智能体 persona,包含 name、description、personality、greeting 等
|
|
11
|
-
9. run_workflow(steps) - 执行预定义工作流
|
|
12
|
-
10. get_operation_logs() - 获取操作日志
|
|
1
|
+
export const TOOL_DEFINITIONS = `
|
|
2
|
+
可用工具:
|
|
3
|
+
1. read_document(path) - 读取文档内容,支持 .txt, .md, .pdf, .docx
|
|
4
|
+
2. summarize_document(path, context?) - 总结文档内容,可选提供上下文
|
|
5
|
+
3. improve_document(path, requirements) - 改进文档,需提供文件路径和改进要求
|
|
6
|
+
4. list_peers() - 列出已连接的对等节点
|
|
7
|
+
5. send_message(peer_id, message) - 向指定对等节点发送消息
|
|
8
|
+
6. broadcast_message(message) - 向所有对等节点广播消息
|
|
9
|
+
7. get_identity() - 获取当前智能体身份信息
|
|
10
|
+
8. set_persona(persona_json) - 更新智能体 persona,包含 name、description、personality、greeting 等
|
|
11
|
+
9. run_workflow(steps) - 执行预定义工作流
|
|
12
|
+
10. get_operation_logs() - 获取操作日志
|
|
13
13
|
`;
|
package/dist/agents/pi-sdk.js
CHANGED
|
@@ -53,6 +53,7 @@ import { buildObservation, buildReflection, formatObservationWithReflection } fr
|
|
|
53
53
|
import { sessionStore as defaultSessionStore } from './session-store.js';
|
|
54
54
|
import { ToolRegistry } from './tool-registry.js';
|
|
55
55
|
import { decideMaxIterations, decideContextOverflow, shouldCompactBeforeIteration } from './react-loop.js';
|
|
56
|
+
import { decideAfterReview, DEFAULT_MAX_REVIEWS } from './loop-review.js';
|
|
56
57
|
// PiSessionManager 已抽到 ./pi-sdk-session-manager.ts (2026-07-06)
|
|
57
58
|
// Tool / ToolResult / Message / StreamCallback / StreamEvent / HeartbeatConfig / AgentSession / TOOL_DEFINITIONS
|
|
58
59
|
// 已抽到 ./pi-sdk-types.ts (2026-07-06)
|
|
@@ -962,38 +963,38 @@ export class PiAgentSession {
|
|
|
962
963
|
}
|
|
963
964
|
// M2.4: persona 缓存
|
|
964
965
|
if (!this.cachedPersonaSection && this.persona) {
|
|
965
|
-
this.cachedPersonaSection = `
|
|
966
|
-
角色描述: ${this.persona.description || '无'}
|
|
967
|
-
性格特点: ${this.persona.personality || '无'}
|
|
968
|
-
问候语: ${this.persona.greeting || '无'}
|
|
966
|
+
this.cachedPersonaSection = `
|
|
967
|
+
角色描述: ${this.persona.description || '无'}
|
|
968
|
+
性格特点: ${this.persona.personality || '无'}
|
|
969
|
+
问候语: ${this.persona.greeting || '无'}
|
|
969
970
|
`;
|
|
970
971
|
}
|
|
971
|
-
const systemPrompt = `${this.bootstrapAddition}你是 ${this.identity.name},基于ReAct (Reasoning + Acting)模式工作。${this.cachedPersonaSection}
|
|
972
|
-
当前工作目录: ${this.cwd}
|
|
973
|
-
当前身份: ${this.identity.name} (${this.identity.did})
|
|
974
|
-
${this.currentIntentHint}
|
|
975
|
-
|
|
976
|
-
${this.getToolDefinitions()}
|
|
977
|
-
|
|
978
|
-
工作模式:
|
|
979
|
-
1. 理解用户自然语言请求
|
|
980
|
-
2. 分析需要哪些工具来完成
|
|
981
|
-
3. 按顺序调用工具并观察结果
|
|
982
|
-
4. 根据观察结果决定下一步
|
|
983
|
-
5. 最终给出完整回答
|
|
984
|
-
|
|
985
|
-
重要 (一次命中要求):
|
|
986
|
-
- 每次只调用一个工具
|
|
987
|
-
- 仔细分析工具返回结果
|
|
988
|
-
- 当任务完成时,必须在回答末尾添加 <final gen> 标记表示结束
|
|
989
|
-
- 如果需要更多信息,继续调用工具
|
|
990
|
-
|
|
991
|
-
【工具调用格式 (严格遵守, 否则系统无法解析)】
|
|
992
|
-
- 你只能输出**一个**工具调用, 不要堆叠多个 invoke
|
|
993
|
-
- 工具调用格式: {"name":"<tool_name>","input":{"arg1":"value1"}}
|
|
994
|
-
- 用 markdown json code block 包裹: \`\`\`json\n{"name":"X","input":{...}}\n\`\`\`
|
|
995
|
-
- 工具调用前可以简短思考 (1-2 句话), 但**不要写长篇 thinking** (会撞 max_tokens)
|
|
996
|
-
- 工具调用后必须等结果, 不要在同一个回复里继续输出
|
|
972
|
+
const systemPrompt = `${this.bootstrapAddition}你是 ${this.identity.name},基于ReAct (Reasoning + Acting)模式工作。${this.cachedPersonaSection}
|
|
973
|
+
当前工作目录: ${this.cwd}
|
|
974
|
+
当前身份: ${this.identity.name} (${this.identity.did})
|
|
975
|
+
${this.currentIntentHint}
|
|
976
|
+
|
|
977
|
+
${this.getToolDefinitions()}
|
|
978
|
+
|
|
979
|
+
工作模式:
|
|
980
|
+
1. 理解用户自然语言请求
|
|
981
|
+
2. 分析需要哪些工具来完成
|
|
982
|
+
3. 按顺序调用工具并观察结果
|
|
983
|
+
4. 根据观察结果决定下一步
|
|
984
|
+
5. 最终给出完整回答
|
|
985
|
+
|
|
986
|
+
重要 (一次命中要求):
|
|
987
|
+
- 每次只调用一个工具
|
|
988
|
+
- 仔细分析工具返回结果
|
|
989
|
+
- 当任务完成时,必须在回答末尾添加 <final gen> 标记表示结束
|
|
990
|
+
- 如果需要更多信息,继续调用工具
|
|
991
|
+
|
|
992
|
+
【工具调用格式 (严格遵守, 否则系统无法解析)】
|
|
993
|
+
- 你只能输出**一个**工具调用, 不要堆叠多个 invoke
|
|
994
|
+
- 工具调用格式: {"name":"<tool_name>","input":{"arg1":"value1"}}
|
|
995
|
+
- 用 markdown json code block 包裹: \`\`\`json\n{"name":"X","input":{...}}\n\`\`\`
|
|
996
|
+
- 工具调用前可以简短思考 (1-2 句话), 但**不要写长篇 thinking** (会撞 max_tokens)
|
|
997
|
+
- 工具调用后必须等结果, 不要在同一个回复里继续输出
|
|
997
998
|
- <final gen> 只在**真完成所有任务**时输出, 不要在工具调用前/中输出${this.judgmentGateAddition}${this.contextHintAddition}`;
|
|
998
999
|
// 2026-06-15: 把 currentOnStream 传给 loop, 让 step-timeline 在 pivot 循环里也能 emit step_start/done
|
|
999
1000
|
// 之前 loop.execute() 不接 streamCallback, 导致 step-timeline 只能看到老 runReActLoop 路径
|
|
@@ -1055,6 +1056,11 @@ ${this.getToolDefinitions()}
|
|
|
1055
1056
|
const MAX_TOOL_CALLS_PER_LOOP = 25; // 单轮循环总工具调用上限 → 注入 hint
|
|
1056
1057
|
let totalToolCallsThisLoop = 0;
|
|
1057
1058
|
const lastNTools = []; // 最近 MAX_IDEMPOTENT_TOOL 次工具名, 检测重复
|
|
1059
|
+
// 2026-08-08: final 前 review 续跑 — 目标对齐 + 需求深挖 (见 loop-review.ts)
|
|
1060
|
+
// 不潦草收尾: LLM 想 <final gen> 时先跑 1-2 次 review, 达成用户需求才放行.
|
|
1061
|
+
// 上限=2 次 (用户要求"运行一两次"), 结束后按用户需求为准.
|
|
1062
|
+
let loopReviewCount = 0;
|
|
1063
|
+
const loopReviewCompletedTools = new Set();
|
|
1058
1064
|
// 发送循环开始的事件
|
|
1059
1065
|
if (onStream) {
|
|
1060
1066
|
onStream({ type: 'status', content: '🔄 开始 ReAct 循环...', tool: 'system' });
|
|
@@ -1171,32 +1177,32 @@ ${this.getToolDefinitions()}
|
|
|
1171
1177
|
}
|
|
1172
1178
|
// M2.4: persona section 缓存 — persona 在 loadPersona() 时一次设定, 此后不变
|
|
1173
1179
|
if (!this.cachedPersonaSection && this.persona) {
|
|
1174
|
-
this.cachedPersonaSection = `
|
|
1175
|
-
角色描述: ${this.persona.description || '无'}
|
|
1176
|
-
性格特点: ${this.persona.personality || '无'}
|
|
1177
|
-
问候语: ${this.persona.greeting || '无'}
|
|
1180
|
+
this.cachedPersonaSection = `
|
|
1181
|
+
角色描述: ${this.persona.description || '无'}
|
|
1182
|
+
性格特点: ${this.persona.personality || '无'}
|
|
1183
|
+
问候语: ${this.persona.greeting || '无'}
|
|
1178
1184
|
`;
|
|
1179
1185
|
}
|
|
1180
1186
|
const personaSection = this.cachedPersonaSection;
|
|
1181
|
-
const systemPrompt = `${this.bootstrapAddition}你是 ${this.identity.name},基于ReAct (Reasoning + Acting)模式工作。${personaSection}
|
|
1182
|
-
当前工作目录: ${this.cwd}
|
|
1183
|
-
当前身份: ${this.identity.name} (${this.identity.did})
|
|
1184
|
-
${refineContext}
|
|
1185
|
-
${this.currentIntentHint}
|
|
1186
|
-
|
|
1187
|
-
${toolDefs}
|
|
1188
|
-
|
|
1189
|
-
工作模式:
|
|
1190
|
-
1. 理解用户自然语言请求
|
|
1191
|
-
2. 分析需要哪些工具来完成
|
|
1192
|
-
3. 按顺序调用工具并观察结果
|
|
1193
|
-
4. 根据观察结果决定下一步
|
|
1194
|
-
5. 最终给出完整回答
|
|
1195
|
-
|
|
1196
|
-
重要:
|
|
1197
|
-
- 每次只调用一个工具
|
|
1198
|
-
- 仔细分析工具返回结果
|
|
1199
|
-
- 当任务完成时,必须在回答末尾添加 <final gen> 标记表示结束
|
|
1187
|
+
const systemPrompt = `${this.bootstrapAddition}你是 ${this.identity.name},基于ReAct (Reasoning + Acting)模式工作。${personaSection}
|
|
1188
|
+
当前工作目录: ${this.cwd}
|
|
1189
|
+
当前身份: ${this.identity.name} (${this.identity.did})
|
|
1190
|
+
${refineContext}
|
|
1191
|
+
${this.currentIntentHint}
|
|
1192
|
+
|
|
1193
|
+
${toolDefs}
|
|
1194
|
+
|
|
1195
|
+
工作模式:
|
|
1196
|
+
1. 理解用户自然语言请求
|
|
1197
|
+
2. 分析需要哪些工具来完成
|
|
1198
|
+
3. 按顺序调用工具并观察结果
|
|
1199
|
+
4. 根据观察结果决定下一步
|
|
1200
|
+
5. 最终给出完整回答
|
|
1201
|
+
|
|
1202
|
+
重要:
|
|
1203
|
+
- 每次只调用一个工具
|
|
1204
|
+
- 仔细分析工具返回结果
|
|
1205
|
+
- 当任务完成时,必须在回答末尾添加 <final gen> 标记表示结束
|
|
1200
1206
|
- 如果需要更多信息,继续调用工具${this.judgmentGateAddition}${this.contextHintAddition}`;
|
|
1201
1207
|
// 3 个恢复机制 (Claude Code 论文 9-step pipeline 内部):
|
|
1202
1208
|
// 1. max output token 升级 (最多 3 次, 每次 maxOutputTokens 翻倍)
|
|
@@ -1539,6 +1545,7 @@ ${toolDefs}
|
|
|
1539
1545
|
else {
|
|
1540
1546
|
this.successfulToolResults.push({ tool: toolCall.name, outputPreview: '(无输出)' });
|
|
1541
1547
|
}
|
|
1548
|
+
loopReviewCompletedTools.add(toolCall.name);
|
|
1542
1549
|
lastQualityScore = this.estimateToolResultQuality(result);
|
|
1543
1550
|
if (lastQualityScore < this.QUALITY_THRESHOLD && refineAttempts < this.MAX_REFINE_ATTEMPTS) {
|
|
1544
1551
|
refineAttempts++;
|
|
@@ -1638,6 +1645,23 @@ ${toolDefs}
|
|
|
1638
1645
|
refineAttempts++;
|
|
1639
1646
|
continue;
|
|
1640
1647
|
}
|
|
1648
|
+
// 2026-08-08: final 前目标对齐 review — 不潦草收尾 (见 loop-review.ts)
|
|
1649
|
+
// LLM 想 <final gen> 时, 先跑 1-2 次「目标对齐 + 需求深挖」review;
|
|
1650
|
+
// 达成用户需求才放行真正结束. 达上限或无需深挖则以用户需求为准结束.
|
|
1651
|
+
const reviewDecision = decideAfterReview({
|
|
1652
|
+
reviewsDone: loopReviewCount,
|
|
1653
|
+
userIntent: this.currentIntentHint,
|
|
1654
|
+
completedTools: Array.from(loopReviewCompletedTools),
|
|
1655
|
+
}, DEFAULT_MAX_REVIEWS);
|
|
1656
|
+
if (reviewDecision.kind === 'continue-review') {
|
|
1657
|
+
loopReviewCount++;
|
|
1658
|
+
console.log(`[PiAgent] review ${loopReviewCount}/${DEFAULT_MAX_REVIEWS}: LLM 想 final 但先对齐需求深挖一次`);
|
|
1659
|
+
this.messageHistory.push({ role: 'system', content: reviewDecision.hint });
|
|
1660
|
+
if (onStream) {
|
|
1661
|
+
onStream({ type: 'status', content: `🔄 目标对齐 review ${loopReviewCount}/${DEFAULT_MAX_REVIEWS}: 深挖续跑`, tool: 'system' });
|
|
1662
|
+
}
|
|
1663
|
+
continue; // 让 LLM 看到 hint, 深挖或确认完成后再次 final
|
|
1664
|
+
}
|
|
1641
1665
|
finalResponse = this.extractFinalAnswer(reply);
|
|
1642
1666
|
break;
|
|
1643
1667
|
}
|
|
@@ -2215,37 +2239,37 @@ ${toolDefs}
|
|
|
2215
2239
|
getDefaultResponse(input) {
|
|
2216
2240
|
const operationsRef = PiAgentSession.getOperationsReference();
|
|
2217
2241
|
if (operationsRef) {
|
|
2218
|
-
return `收到了: "${input}"
|
|
2219
|
-
|
|
2220
|
-
我是一个判断力处理智能体,支持自然语言交互。
|
|
2221
|
-
|
|
2222
|
-
可用操作(直接说出即可):
|
|
2223
|
-
${this.extractOperationsFromRef(operationsRef)}
|
|
2224
|
-
|
|
2225
|
-
示例请求:
|
|
2226
|
-
- "读取 src/index.ts 文件"
|
|
2227
|
-
- "总结一下 README.md"
|
|
2228
|
-
- "查看当前连接了哪些节点"
|
|
2242
|
+
return `收到了: "${input}"
|
|
2243
|
+
|
|
2244
|
+
我是一个判断力处理智能体,支持自然语言交互。
|
|
2245
|
+
|
|
2246
|
+
可用操作(直接说出即可):
|
|
2247
|
+
${this.extractOperationsFromRef(operationsRef)}
|
|
2248
|
+
|
|
2249
|
+
示例请求:
|
|
2250
|
+
- "读取 src/index.ts 文件"
|
|
2251
|
+
- "总结一下 README.md"
|
|
2252
|
+
- "查看当前连接了哪些节点"
|
|
2229
2253
|
- "向 QmABC... 发送测试消息"`;
|
|
2230
2254
|
}
|
|
2231
|
-
return `收到了: "${input}"
|
|
2232
|
-
|
|
2233
|
-
我是一个判断力处理智能体,支持自然语言交互。
|
|
2234
|
-
|
|
2235
|
-
可用操作(直接说出即可):
|
|
2236
|
-
- "读取 README.md" - 读取并分析文档
|
|
2237
|
-
- "总结文档" - 总结文档内容
|
|
2238
|
-
- "改进文档,按照X要求" - 改进文档
|
|
2239
|
-
- "查看节点" - 查看已连接的对等节点
|
|
2240
|
-
- "向X发送消息Y" - 向对等节点发送消息
|
|
2241
|
-
- "广播消息X" - 广播消息到所有节点
|
|
2242
|
-
- "查看身份" - 查看当前智能体身份
|
|
2243
|
-
- "查看日志" - 查看最近操作日志
|
|
2244
|
-
|
|
2245
|
-
示例请求:
|
|
2246
|
-
- "读取 src/index.ts 文件"
|
|
2247
|
-
- "总结一下 README.md"
|
|
2248
|
-
- "查看当前连接了哪些节点"
|
|
2255
|
+
return `收到了: "${input}"
|
|
2256
|
+
|
|
2257
|
+
我是一个判断力处理智能体,支持自然语言交互。
|
|
2258
|
+
|
|
2259
|
+
可用操作(直接说出即可):
|
|
2260
|
+
- "读取 README.md" - 读取并分析文档
|
|
2261
|
+
- "总结文档" - 总结文档内容
|
|
2262
|
+
- "改进文档,按照X要求" - 改进文档
|
|
2263
|
+
- "查看节点" - 查看已连接的对等节点
|
|
2264
|
+
- "向X发送消息Y" - 向对等节点发送消息
|
|
2265
|
+
- "广播消息X" - 广播消息到所有节点
|
|
2266
|
+
- "查看身份" - 查看当前智能体身份
|
|
2267
|
+
- "查看日志" - 查看最近操作日志
|
|
2268
|
+
|
|
2269
|
+
示例请求:
|
|
2270
|
+
- "读取 src/index.ts 文件"
|
|
2271
|
+
- "总结一下 README.md"
|
|
2272
|
+
- "查看当前连接了哪些节点"
|
|
2249
2273
|
- "向 QmABC... 发送测试消息"`;
|
|
2250
2274
|
}
|
|
2251
2275
|
extractOperationsFromRef(ref) {
|
|
@@ -2270,13 +2294,13 @@ ${this.extractOperationsFromRef(operationsRef)}
|
|
|
2270
2294
|
}
|
|
2271
2295
|
}
|
|
2272
2296
|
return operationLines.length > 0 ? operationLines.join('\n') :
|
|
2273
|
-
` - "读取 README.md" - 读取并分析文档
|
|
2274
|
-
- "总结文档" - 总结文档内容
|
|
2275
|
-
- "改进文档,按照X要求" - 改进文档
|
|
2276
|
-
- "查看节点" - 查看已连接的对等节点
|
|
2277
|
-
- "向X发送消息Y" - 向对等节点发送消息
|
|
2278
|
-
- "广播消息X" - 广播消息到所有节点
|
|
2279
|
-
- "查看身份" - 查看当前智能体身份
|
|
2297
|
+
` - "读取 README.md" - 读取并分析文档
|
|
2298
|
+
- "总结文档" - 总结文档内容
|
|
2299
|
+
- "改进文档,按照X要求" - 改进文档
|
|
2300
|
+
- "查看节点" - 查看已连接的对等节点
|
|
2301
|
+
- "向X发送消息Y" - 向对等节点发送消息
|
|
2302
|
+
- "广播消息X" - 广播消息到所有节点
|
|
2303
|
+
- "查看身份" - 查看当前智能体身份
|
|
2280
2304
|
- "查看日志" - 查看最近操作日志`;
|
|
2281
2305
|
}
|
|
2282
2306
|
async suggestRename(messages) {
|
|
@@ -778,8 +778,8 @@ export class WorkflowPivotLoop {
|
|
|
778
778
|
// 完整重装只在 iter=1 和 compact 之后两次
|
|
779
779
|
const lines = fullSystemPrompt.split('\n');
|
|
780
780
|
const identityLine = lines.find((l) => l.includes('你是') && !l.includes('(续)')) ?? '';
|
|
781
|
-
return `[continuation] 你的 persona + tools + judgments 已在首轮 messageHistory 中.
|
|
782
|
-
${identityLine ? identityLine + '\n' : ''}当前 step 别再读 persona 全文, 继续推进任务即可.
|
|
781
|
+
return `[continuation] 你的 persona + tools + judgments 已在首轮 messageHistory 中.
|
|
782
|
+
${identityLine ? identityLine + '\n' : ''}当前 step 别再读 persona 全文, 继续推进任务即可.
|
|
783
783
|
> <final gen> 只在真完成时输出.`;
|
|
784
784
|
}
|
|
785
785
|
/**
|
|
@@ -104,17 +104,17 @@ function checkRsync(cmd) {
|
|
|
104
104
|
function block(reason, host = null) {
|
|
105
105
|
let guidance;
|
|
106
106
|
if (host === PROD_IP) {
|
|
107
|
-
guidance = `请使用标准部署流程:
|
|
108
|
-
后端: bash scripts/deploy.sh --yes
|
|
109
|
-
Demo 正式: bash scripts/deploy-demo.sh <name> --channel prod --yes
|
|
110
|
-
Demo 内测: bash scripts/deploy-demo.sh <name> --channel preview --yes
|
|
111
|
-
Edge/Nginx: bash scripts/deploy-edge.sh --yes
|
|
107
|
+
guidance = `请使用标准部署流程:
|
|
108
|
+
后端: bash scripts/deploy.sh --yes
|
|
109
|
+
Demo 正式: bash scripts/deploy-demo.sh <name> --channel prod --yes
|
|
110
|
+
Demo 内测: bash scripts/deploy-demo.sh <name> --channel preview --yes
|
|
111
|
+
Edge/Nginx: bash scripts/deploy-edge.sh --yes
|
|
112
112
|
详见 Bolloon.md Development Commands。`;
|
|
113
113
|
}
|
|
114
114
|
else if (BRIDGE_VPS_HOSTS.includes(host ?? "")) {
|
|
115
|
-
guidance = `Bridge VPS 必须走 git pull 更新路径:
|
|
116
|
-
ssh root@${host} 'sudo -u boll git -C /opt/boll pull --ff-only'
|
|
117
|
-
scp/rsync 直传会重新制造 orphan worktree。
|
|
115
|
+
guidance = `Bridge VPS 必须走 git pull 更新路径:
|
|
116
|
+
ssh root@${host} 'sudo -u boll git -C /opt/boll pull --ff-only'
|
|
117
|
+
scp/rsync 直传会重新制造 orphan worktree。
|
|
118
118
|
详见 docs/issues/guard-20260408-0445-bridge-vps-orphan-worktree.md。`;
|
|
119
119
|
}
|
|
120
120
|
else {
|
|
@@ -253,9 +253,9 @@ export async function generateJudgmentInjection(filePath, gate, options = {}) {
|
|
|
253
253
|
const header = gate === 3
|
|
254
254
|
? '# Plan Freeze - Decision Principles'
|
|
255
255
|
: `# Gate ${gate} - Active Judgments`;
|
|
256
|
-
return `${header}
|
|
257
|
-
# Path: ${filePath}
|
|
258
|
-
# Confidence: ${(result.confidence * 100).toFixed(0)}%
|
|
259
|
-
|
|
256
|
+
return `${header}
|
|
257
|
+
# Path: ${filePath}
|
|
258
|
+
# Confidence: ${(result.confidence * 100).toFixed(0)}%
|
|
259
|
+
|
|
260
260
|
${result.contextYaml}`;
|
|
261
261
|
}
|