@bolloon/bolloon-agent 0.2.9 → 0.2.11
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 +467 -467
- package/bin/bolloon-cli.cjs +183 -183
- package/bin/bolloon.cjs +0 -0
- package/bin/bolloon.js +157 -0
- package/dist/agents/agent-manifest-protocol.js +0 -52
- package/dist/agents/constraint-layer.js +19 -19
- package/dist/agents/pi-sdk.js +287 -1213
- package/dist/agents/shell-guard.js +2 -2
- package/dist/agents/workflow-pivot-loop.js +2 -81
- 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 -26
- package/dist/bollharness-integration/integration.js +0 -71
- package/dist/bollharness-integration/llm-judgment-engine.js +134 -134
- package/dist/bollharness-integration/skill-adapter.js +127 -52
- package/dist/bootstrap/context-collector.js +3 -6
- package/dist/bootstrap/lifecycle-hooks.js +1 -15
- package/dist/cli-entry.js +35 -39
- package/dist/constraint-runtime/src/_archive_helper.js +9 -0
- package/dist/constraint-runtime/src/agent/coordinator.js +48 -0
- package/dist/constraint-runtime/src/agent/index.js +1 -0
- package/dist/constraint-runtime/src/assistant/index.js +12 -0
- package/dist/constraint-runtime/src/bootstrap/index.js +12 -0
- package/dist/constraint-runtime/src/bootstrap_graph.js +13 -0
- package/dist/constraint-runtime/src/bridge/index.js +12 -0
- package/dist/constraint-runtime/src/buddy/index.js +12 -0
- package/dist/constraint-runtime/src/cli/index.js +12 -0
- package/dist/constraint-runtime/src/command_graph.js +10 -0
- package/dist/constraint-runtime/src/commands.js +60 -0
- package/dist/constraint-runtime/src/components/index.js +12 -0
- package/dist/constraint-runtime/src/constants/index.js +12 -0
- package/dist/constraint-runtime/src/constraint/budget.js +22 -0
- package/dist/constraint-runtime/src/constraint/index.js +2 -0
- package/dist/constraint-runtime/src/constraint/permission.js +20 -0
- package/dist/constraint-runtime/src/context.js +30 -0
- package/dist/constraint-runtime/src/coordinator/index.js +12 -0
- package/dist/constraint-runtime/src/cost_hook.js +4 -0
- package/dist/constraint-runtime/src/cost_tracker.js +8 -0
- package/dist/constraint-runtime/src/deferred_init.js +10 -0
- package/dist/constraint-runtime/src/direct_modes.js +6 -0
- package/dist/constraint-runtime/src/dynamic-tool-loader.js +85 -0
- package/dist/constraint-runtime/src/entrypoints/index.js +12 -0
- package/dist/constraint-runtime/src/execution_registry.js +44 -0
- package/dist/constraint-runtime/src/history.js +9 -0
- package/dist/constraint-runtime/src/hooks/index.js +12 -0
- package/dist/constraint-runtime/src/index.js +26 -0
- package/dist/constraint-runtime/src/ink.js +4 -0
- package/dist/constraint-runtime/src/keybindings/index.js +12 -0
- package/dist/constraint-runtime/src/memdir/index.js +12 -0
- package/dist/constraint-runtime/src/migrations/index.js +12 -0
- package/dist/constraint-runtime/src/models.js +1 -0
- package/dist/constraint-runtime/src/moreright/index.js +12 -0
- package/dist/constraint-runtime/src/native_ts/index.js +12 -0
- package/dist/constraint-runtime/src/output_styles/index.js +12 -0
- package/dist/constraint-runtime/src/parity_audit.js +12 -0
- package/dist/constraint-runtime/src/plugins/index.js +12 -0
- package/dist/constraint-runtime/src/port_manifest.js +11 -0
- package/dist/constraint-runtime/src/prefetch.js +9 -0
- package/dist/constraint-runtime/src/query.js +1 -0
- package/dist/constraint-runtime/src/remote/index.js +12 -0
- package/dist/constraint-runtime/src/remote_runtime.js +9 -0
- package/dist/constraint-runtime/src/runtime/index.js +1 -0
- package/dist/constraint-runtime/src/runtime/session.js +35 -0
- package/dist/constraint-runtime/src/schemas/index.js +12 -0
- package/dist/constraint-runtime/src/screens/index.js +12 -0
- package/dist/constraint-runtime/src/server/index.js +12 -0
- package/dist/constraint-runtime/src/services/index.js +12 -0
- package/dist/constraint-runtime/src/session_store.js +22 -0
- package/dist/constraint-runtime/src/setup.js +30 -0
- package/dist/constraint-runtime/src/skills/index.js +1 -0
- package/dist/constraint-runtime/src/skills/skill-registry.js +28 -0
- package/dist/constraint-runtime/src/state/index.js +12 -0
- package/dist/constraint-runtime/src/system_init.js +20 -0
- package/dist/constraint-runtime/src/thinking/engine.js +42 -0
- package/dist/constraint-runtime/src/thinking/index.js +1 -0
- package/dist/constraint-runtime/src/tool_pool.js +8 -0
- package/dist/constraint-runtime/src/tools/OpenCLI/execAdapter.js +7 -0
- package/dist/constraint-runtime/src/tools/OpenCLI/listAdapters.js +7 -0
- package/dist/constraint-runtime/src/tools/OpenCLI/runCommand.js +7 -0
- package/dist/constraint-runtime/src/tools/SafeSDK/confirmTransaction.js +6 -0
- package/dist/constraint-runtime/src/tools/SafeSDK/createTransaction.js +8 -0
- package/dist/constraint-runtime/src/tools/SafeSDK/executeTransaction.js +6 -0
- package/dist/constraint-runtime/src/tools/SafeSDK/getBalance.js +6 -0
- package/dist/constraint-runtime/src/tools/SafeSDK/getPendingTransactions.js +6 -0
- package/dist/constraint-runtime/src/tools/SafeSDK/proposeTransaction.js +6 -0
- package/dist/constraint-runtime/src/tools.js +80 -0
- package/dist/constraint-runtime/src/transcript.js +19 -0
- package/dist/constraint-runtime/src/types/index.js +12 -0
- package/dist/constraint-runtime/src/upstream_proxy/index.js +12 -0
- package/dist/constraint-runtime/src/utils/index.js +12 -0
- package/dist/constraint-runtime/src/vim/index.js +12 -0
- package/dist/constraint-runtime/src/voice/index.js +12 -0
- package/dist/constraint-runtime/tests/agent.test.js +16 -0
- package/dist/constraint-runtime/tests/constraint.test.js +41 -0
- package/dist/constraint-runtime/tests/skill.test.js +19 -0
- package/dist/constraint-runtime/tests/thinking.test.js +22 -0
- package/dist/context-compaction/auto-compact.js +7 -7
- package/dist/electron-preload.js +1 -18
- package/dist/electron-preload.js.map +1 -1
- package/dist/electron.js +168 -3
- package/dist/electron.js.map +1 -1
- package/dist/index.js +116 -136
- package/dist/llm/config-store.js +8 -24
- package/dist/llm/llm-judgment-client.js +102 -102
- package/dist/llm/pi-ai.js +85 -126
- 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-visitor.md +19 -19
- 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/hibs_reminders.md +15 -15
- package/dist/llm/system-prompt/layers/core/identity.md +37 -37
- 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/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/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/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/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/security/tool-gate.js +0 -11
- 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 +520 -520
- package/dist/web/client.js +2917 -3791
- package/dist/web/components/p2p/index.js +234 -276
- package/dist/web/components/wallet-viem.mjs +118 -118
- package/dist/web/index.html +374 -373
- package/dist/web/manifest.json +20 -20
- package/dist/web/server.js +23 -775
- package/dist/web/style.css +4737 -4737
- package/dist/web/ui/message-renderer.js +373 -451
- package/dist/web/ui/step-timeline.js +255 -351
- package/package.json +160 -160
- package/scripts/build-cli.js +215 -215
- package/scripts/build-web.ts +125 -125
- package/scripts/postinstall.js +152 -152
- package/bin/bolloon-daemon.sh +0 -207
- package/bin/ipfs +0 -0
- package/dist/agents/chat-segmenter.js +0 -298
- package/dist/agents/judgment-protocol.js +0 -479
- package/dist/agents/parse-tool-call.js +0 -304
- package/dist/agents/peer-manifest-loader.js +0 -210
- package/dist/agents/react-loop.js +0 -120
- package/dist/agents/session-store.js +0 -171
- package/dist/agents/tool-registry.js +0 -136
- package/dist/bootstrap/chat-archiver.js +0 -276
- package/dist/bootstrap/memory-compressor.js +0 -170
- package/dist/bootstrap/persona-loader.js +0 -94
- package/dist/electron/config.js +0 -16
- package/dist/electron/config.js.map +0 -1
- package/dist/electron/dialogs.js +0 -71
- package/dist/electron/dialogs.js.map +0 -1
- package/dist/electron/first-run.js +0 -129
- package/dist/electron/first-run.js.map +0 -1
- package/dist/electron/ipc.js +0 -16
- package/dist/electron/ipc.js.map +0 -1
- package/dist/electron/logger.js +0 -77
- package/dist/electron/logger.js.map +0 -1
- package/dist/electron/main.js +0 -60
- package/dist/electron/main.js.map +0 -1
- package/dist/electron/menu.js +0 -140
- package/dist/electron/menu.js.map +0 -1
- package/dist/electron/paths.js +0 -33
- package/dist/electron/paths.js.map +0 -1
- package/dist/electron/server.js +0 -74
- package/dist/electron/server.js.map +0 -1
- package/dist/electron/tray.js +0 -73
- package/dist/electron/tray.js.map +0 -1
- package/dist/electron/window.js +0 -69
- package/dist/electron/window.js.map +0 -1
- package/dist/network/local-inbox-bus.js +0 -73
- package/dist/network/p2p-outbox.js +0 -161
- package/dist/network/peer-fs.js +0 -420
- package/dist/network/peer-resource-bridge.js +0 -216
- package/dist/web/components/p2p/P2PModal.js +0 -188
- package/dist/web/components/p2p/p2p-modal.js +0 -664
- package/dist/web/components/p2p/p2p-tools.js +0 -248
- package/dist/web/input-validator.js +0 -103
- package/dist/web/util/safe-name.js +0 -32
package/bin/bolloon-cli.cjs
CHANGED
|
@@ -1,183 +1,183 @@
|
|
|
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
|
-
// bin is in: node_modules/.bin/bolloon
|
|
27
|
-
// package is in: node_modules/@bolloon/bolloon-agent/
|
|
28
|
-
// dist is in: node_modules/@bolloon/bolloon-agent/dist/
|
|
29
|
-
const binPath = require.main.filename; // /tmp/node_modules/.bin/bolloon
|
|
30
|
-
const binDir = path.dirname(binPath); // /tmp/node_modules/.bin
|
|
31
|
-
const packageDir = path.dirname(binDir); // /tmp/node_modules/@bolloon/bolloon-agent
|
|
32
|
-
// 优先用 package.json 'main' 字段 (v0.2.3+ 指向 dist/cli-entry.js).
|
|
33
|
-
// 真实 npm 安装用户拿到的是编译后的 dist, 不该再依赖 tsx.
|
|
34
|
-
const pkgJsonPath = path.join(packageDir, "package.json");
|
|
35
|
-
if (fs.existsSync(pkgJsonPath)) {
|
|
36
|
-
try {
|
|
37
|
-
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
38
|
-
if (pkg.main) {
|
|
39
|
-
const mainPath = path.join(packageDir, pkg.main);
|
|
40
|
-
if (fs.existsSync(mainPath)) return mainPath;
|
|
41
|
-
}
|
|
42
|
-
} catch {}
|
|
43
|
-
}
|
|
44
|
-
// fallback: 兼容老版本 (dist/index.js 是之前默认)
|
|
45
|
-
const distIndex = path.join(packageDir, "dist", "index.js");
|
|
46
|
-
if (fs.existsSync(distIndex)) return distIndex;
|
|
47
|
-
// 最后才 fallback 到 src (开发环境)
|
|
48
|
-
return path.join(packageDir, "src", "index.ts");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function parseArgs() {
|
|
52
|
-
const args = process.argv.slice(2);
|
|
53
|
-
if (args.length === 0) {
|
|
54
|
-
return { mode: "gui", args: [] };
|
|
55
|
-
}
|
|
56
|
-
const first = args[0];
|
|
57
|
-
switch (first) {
|
|
58
|
-
case "-v":
|
|
59
|
-
case "--version":
|
|
60
|
-
return { mode: "version", args: [] };
|
|
61
|
-
case "-h":
|
|
62
|
-
case "--help":
|
|
63
|
-
return { mode: "help", args: [] };
|
|
64
|
-
case "-g":
|
|
65
|
-
case "--gui":
|
|
66
|
-
return { mode: "gui", args: args.slice(1) };
|
|
67
|
-
case "-w":
|
|
68
|
-
case "--web":
|
|
69
|
-
return { mode: "web", args: args.slice(1) };
|
|
70
|
-
case "-c":
|
|
71
|
-
case "--cli":
|
|
72
|
-
return { mode: "cli", args: args.slice(1) };
|
|
73
|
-
default:
|
|
74
|
-
return { mode: "passthrough", args };
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
async function startElectron(additionalArgs) {
|
|
79
|
-
try {
|
|
80
|
-
const electron = require("electron");
|
|
81
|
-
const binPath = require.main.filename;
|
|
82
|
-
const binDir = path.dirname(binPath);
|
|
83
|
-
const packageDir = path.dirname(binDir);
|
|
84
|
-
let mainPath = path.join(packageDir, "dist", "electron.js");
|
|
85
|
-
if (!fs.existsSync(mainPath)) {
|
|
86
|
-
mainPath = path.join(packageDir, "src", "electron.ts");
|
|
87
|
-
}
|
|
88
|
-
log("启动 Electron...", CYAN);
|
|
89
|
-
const child = spawn(electron, [mainPath, ...additionalArgs], {
|
|
90
|
-
stdio: "inherit",
|
|
91
|
-
env: { ...process.env, NODE_ENV: "development" }
|
|
92
|
-
});
|
|
93
|
-
child.on("error", (err) => {
|
|
94
|
-
log("Electron 启动失败: " + err.message, MAGENTA);
|
|
95
|
-
process.exit(1);
|
|
96
|
-
});
|
|
97
|
-
child.on("exit", (code) => process.exit(code || 0));
|
|
98
|
-
} catch (err) {
|
|
99
|
-
log("Electron 不可用,切换到 Web 模式...", CYAN);
|
|
100
|
-
await startWebServer(additionalArgs);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async function startWebServer(additionalArgs) {
|
|
105
|
-
const mainPath = getMainEntry();
|
|
106
|
-
const webArgs = ["--web", ...additionalArgs];
|
|
107
|
-
log("启动 Web 服务...", CYAN);
|
|
108
|
-
const child = spawn(process.execPath, [mainPath, ...webArgs], { stdio: "inherit" });
|
|
109
|
-
child.on("error", (err) => {
|
|
110
|
-
log("Web 服务启动失败: " + err.message, MAGENTA);
|
|
111
|
-
process.exit(1);
|
|
112
|
-
});
|
|
113
|
-
child.on("exit", (code) => process.exit(code || 0));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async function startCLI(additionalArgs) {
|
|
117
|
-
const mainPath = getMainEntry();
|
|
118
|
-
log("启动命令行界面...", CYAN);
|
|
119
|
-
const child = spawn(process.execPath, [mainPath, ...additionalArgs], { stdio: "inherit" });
|
|
120
|
-
child.on("error", (err) => {
|
|
121
|
-
log("CLI 启动失败: " + err.message, MAGENTA);
|
|
122
|
-
process.exit(1);
|
|
123
|
-
});
|
|
124
|
-
child.on("exit", (code) => process.exit(code || 0));
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async function main() {
|
|
128
|
-
// Get version from package.json
|
|
129
|
-
const binPath = require.main.filename;
|
|
130
|
-
const binDir = path.dirname(binPath);
|
|
131
|
-
const packageDir = path.dirname(binDir);
|
|
132
|
-
const packageJson = JSON.parse(fs.readFileSync(path.join(packageDir, "package.json"), "utf-8"));
|
|
133
|
-
const version = packageJson.version;
|
|
134
|
-
|
|
135
|
-
const { mode, args } = parseArgs();
|
|
136
|
-
switch (mode) {
|
|
137
|
-
case "version":
|
|
138
|
-
console.log("Bolloon Agent v" + version);
|
|
139
|
-
break;
|
|
140
|
-
case "help":
|
|
141
|
-
printBanner();
|
|
142
|
-
console.log(BOLD + "用法:" + RESET + " bolloon [选项] [命令] [参数]");
|
|
143
|
-
console.log(BOLD + "选项:" + RESET + " --gui, -g 启动图形界面");
|
|
144
|
-
console.log(" --web, -w 启动 Web UI");
|
|
145
|
-
console.log(" --cli, -c 启动命令行界面");
|
|
146
|
-
console.log(" --version, -v 显示版本");
|
|
147
|
-
console.log(" --help, -h 显示帮助");
|
|
148
|
-
console.log(BOLD + "示例:" + RESET + " bolloon # 启动图形界面");
|
|
149
|
-
console.log(" bolloon --web # 启动 Web UI");
|
|
150
|
-
console.log(" bolloon --read file # 读取文档");
|
|
151
|
-
break;
|
|
152
|
-
case "gui":
|
|
153
|
-
printBanner();
|
|
154
|
-
await startElectron(args);
|
|
155
|
-
break;
|
|
156
|
-
case "web":
|
|
157
|
-
printBanner();
|
|
158
|
-
await startWebServer(args);
|
|
159
|
-
break;
|
|
160
|
-
case "cli":
|
|
161
|
-
await startCLI(args);
|
|
162
|
-
break;
|
|
163
|
-
case "passthrough":
|
|
164
|
-
const mainPath = getMainEntry();
|
|
165
|
-
const child = spawn(process.execPath, [mainPath, ...args], { stdio: "inherit" });
|
|
166
|
-
child.on("error", (err) => {
|
|
167
|
-
log("执行失败: " + err.message, MAGENTA);
|
|
168
|
-
process.exit(1);
|
|
169
|
-
});
|
|
170
|
-
child.on("exit", (code) => process.exit(code || 0));
|
|
171
|
-
break;
|
|
172
|
-
default:
|
|
173
|
-
log("未知模式: " + mode, MAGENTA);
|
|
174
|
-
printBanner();
|
|
175
|
-
console.log("输入 --help 查看帮助");
|
|
176
|
-
process.exit(1);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
main().catch((err) => {
|
|
181
|
-
console.error("Fatal error:", err);
|
|
182
|
-
process.exit(1);
|
|
183
|
-
});
|
|
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
|
+
// bin is in: node_modules/.bin/bolloon
|
|
27
|
+
// package is in: node_modules/@bolloon/bolloon-agent/
|
|
28
|
+
// dist is in: node_modules/@bolloon/bolloon-agent/dist/
|
|
29
|
+
const binPath = require.main.filename; // /tmp/node_modules/.bin/bolloon
|
|
30
|
+
const binDir = path.dirname(binPath); // /tmp/node_modules/.bin
|
|
31
|
+
const packageDir = path.dirname(binDir); // /tmp/node_modules/@bolloon/bolloon-agent
|
|
32
|
+
// 优先用 package.json 'main' 字段 (v0.2.3+ 指向 dist/cli-entry.js).
|
|
33
|
+
// 真实 npm 安装用户拿到的是编译后的 dist, 不该再依赖 tsx.
|
|
34
|
+
const pkgJsonPath = path.join(packageDir, "package.json");
|
|
35
|
+
if (fs.existsSync(pkgJsonPath)) {
|
|
36
|
+
try {
|
|
37
|
+
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
38
|
+
if (pkg.main) {
|
|
39
|
+
const mainPath = path.join(packageDir, pkg.main);
|
|
40
|
+
if (fs.existsSync(mainPath)) return mainPath;
|
|
41
|
+
}
|
|
42
|
+
} catch {}
|
|
43
|
+
}
|
|
44
|
+
// fallback: 兼容老版本 (dist/index.js 是之前默认)
|
|
45
|
+
const distIndex = path.join(packageDir, "dist", "index.js");
|
|
46
|
+
if (fs.existsSync(distIndex)) return distIndex;
|
|
47
|
+
// 最后才 fallback 到 src (开发环境)
|
|
48
|
+
return path.join(packageDir, "src", "index.ts");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function parseArgs() {
|
|
52
|
+
const args = process.argv.slice(2);
|
|
53
|
+
if (args.length === 0) {
|
|
54
|
+
return { mode: "gui", args: [] };
|
|
55
|
+
}
|
|
56
|
+
const first = args[0];
|
|
57
|
+
switch (first) {
|
|
58
|
+
case "-v":
|
|
59
|
+
case "--version":
|
|
60
|
+
return { mode: "version", args: [] };
|
|
61
|
+
case "-h":
|
|
62
|
+
case "--help":
|
|
63
|
+
return { mode: "help", args: [] };
|
|
64
|
+
case "-g":
|
|
65
|
+
case "--gui":
|
|
66
|
+
return { mode: "gui", args: args.slice(1) };
|
|
67
|
+
case "-w":
|
|
68
|
+
case "--web":
|
|
69
|
+
return { mode: "web", args: args.slice(1) };
|
|
70
|
+
case "-c":
|
|
71
|
+
case "--cli":
|
|
72
|
+
return { mode: "cli", args: args.slice(1) };
|
|
73
|
+
default:
|
|
74
|
+
return { mode: "passthrough", args };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function startElectron(additionalArgs) {
|
|
79
|
+
try {
|
|
80
|
+
const electron = require("electron");
|
|
81
|
+
const binPath = require.main.filename;
|
|
82
|
+
const binDir = path.dirname(binPath);
|
|
83
|
+
const packageDir = path.dirname(binDir);
|
|
84
|
+
let mainPath = path.join(packageDir, "dist", "electron.js");
|
|
85
|
+
if (!fs.existsSync(mainPath)) {
|
|
86
|
+
mainPath = path.join(packageDir, "src", "electron.ts");
|
|
87
|
+
}
|
|
88
|
+
log("启动 Electron...", CYAN);
|
|
89
|
+
const child = spawn(electron, [mainPath, ...additionalArgs], {
|
|
90
|
+
stdio: "inherit",
|
|
91
|
+
env: { ...process.env, NODE_ENV: "development" }
|
|
92
|
+
});
|
|
93
|
+
child.on("error", (err) => {
|
|
94
|
+
log("Electron 启动失败: " + err.message, MAGENTA);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
});
|
|
97
|
+
child.on("exit", (code) => process.exit(code || 0));
|
|
98
|
+
} catch (err) {
|
|
99
|
+
log("Electron 不可用,切换到 Web 模式...", CYAN);
|
|
100
|
+
await startWebServer(additionalArgs);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function startWebServer(additionalArgs) {
|
|
105
|
+
const mainPath = getMainEntry();
|
|
106
|
+
const webArgs = ["--web", ...additionalArgs];
|
|
107
|
+
log("启动 Web 服务...", CYAN);
|
|
108
|
+
const child = spawn(process.execPath, [mainPath, ...webArgs], { stdio: "inherit" });
|
|
109
|
+
child.on("error", (err) => {
|
|
110
|
+
log("Web 服务启动失败: " + err.message, MAGENTA);
|
|
111
|
+
process.exit(1);
|
|
112
|
+
});
|
|
113
|
+
child.on("exit", (code) => process.exit(code || 0));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function startCLI(additionalArgs) {
|
|
117
|
+
const mainPath = getMainEntry();
|
|
118
|
+
log("启动命令行界面...", CYAN);
|
|
119
|
+
const child = spawn(process.execPath, [mainPath, ...additionalArgs], { stdio: "inherit" });
|
|
120
|
+
child.on("error", (err) => {
|
|
121
|
+
log("CLI 启动失败: " + err.message, MAGENTA);
|
|
122
|
+
process.exit(1);
|
|
123
|
+
});
|
|
124
|
+
child.on("exit", (code) => process.exit(code || 0));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function main() {
|
|
128
|
+
// Get version from package.json
|
|
129
|
+
const binPath = require.main.filename;
|
|
130
|
+
const binDir = path.dirname(binPath);
|
|
131
|
+
const packageDir = path.dirname(binDir);
|
|
132
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(packageDir, "package.json"), "utf-8"));
|
|
133
|
+
const version = packageJson.version;
|
|
134
|
+
|
|
135
|
+
const { mode, args } = parseArgs();
|
|
136
|
+
switch (mode) {
|
|
137
|
+
case "version":
|
|
138
|
+
console.log("Bolloon Agent v" + version);
|
|
139
|
+
break;
|
|
140
|
+
case "help":
|
|
141
|
+
printBanner();
|
|
142
|
+
console.log(BOLD + "用法:" + RESET + " bolloon [选项] [命令] [参数]");
|
|
143
|
+
console.log(BOLD + "选项:" + RESET + " --gui, -g 启动图形界面");
|
|
144
|
+
console.log(" --web, -w 启动 Web UI");
|
|
145
|
+
console.log(" --cli, -c 启动命令行界面");
|
|
146
|
+
console.log(" --version, -v 显示版本");
|
|
147
|
+
console.log(" --help, -h 显示帮助");
|
|
148
|
+
console.log(BOLD + "示例:" + RESET + " bolloon # 启动图形界面");
|
|
149
|
+
console.log(" bolloon --web # 启动 Web UI");
|
|
150
|
+
console.log(" bolloon --read file # 读取文档");
|
|
151
|
+
break;
|
|
152
|
+
case "gui":
|
|
153
|
+
printBanner();
|
|
154
|
+
await startElectron(args);
|
|
155
|
+
break;
|
|
156
|
+
case "web":
|
|
157
|
+
printBanner();
|
|
158
|
+
await startWebServer(args);
|
|
159
|
+
break;
|
|
160
|
+
case "cli":
|
|
161
|
+
await startCLI(args);
|
|
162
|
+
break;
|
|
163
|
+
case "passthrough":
|
|
164
|
+
const mainPath = getMainEntry();
|
|
165
|
+
const child = spawn(process.execPath, [mainPath, ...args], { stdio: "inherit" });
|
|
166
|
+
child.on("error", (err) => {
|
|
167
|
+
log("执行失败: " + err.message, MAGENTA);
|
|
168
|
+
process.exit(1);
|
|
169
|
+
});
|
|
170
|
+
child.on("exit", (code) => process.exit(code || 0));
|
|
171
|
+
break;
|
|
172
|
+
default:
|
|
173
|
+
log("未知模式: " + mode, MAGENTA);
|
|
174
|
+
printBanner();
|
|
175
|
+
console.log("输入 --help 查看帮助");
|
|
176
|
+
process.exit(1);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
main().catch((err) => {
|
|
181
|
+
console.error("Fatal error:", err);
|
|
182
|
+
process.exit(1);
|
|
183
|
+
});
|
package/bin/bolloon.cjs
CHANGED
|
File without changes
|
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
|
+
});
|
|
@@ -44,16 +44,6 @@ const localManifest = {
|
|
|
44
44
|
};
|
|
45
45
|
export function setLocalManifest(m) {
|
|
46
46
|
Object.assign(localManifest, m, { publishedAt: Date.now() });
|
|
47
|
-
// 2026-07-05: 显式重置 v2 数组字段 — Partial merge 不会清空未提供的 key,
|
|
48
|
-
// 但调用者通常期望"整片替换", 所以这里强制对齐 (避免测试间泄漏).
|
|
49
|
-
if (!('groups' in m))
|
|
50
|
-
localManifest.groups = [];
|
|
51
|
-
if (!('functions' in m))
|
|
52
|
-
localManifest.functions = [];
|
|
53
|
-
if (!('exportments' in m))
|
|
54
|
-
localManifest.exportments = [];
|
|
55
|
-
if (!('sciences' in m))
|
|
56
|
-
localManifest.sciences = [];
|
|
57
47
|
return localManifest;
|
|
58
48
|
}
|
|
59
49
|
export function getLocalManifest() {
|
|
@@ -68,48 +58,6 @@ export function addLocalAgent(agent) {
|
|
|
68
58
|
localManifest.publishedAt = Date.now();
|
|
69
59
|
return localManifest;
|
|
70
60
|
}
|
|
71
|
-
// ============== 2026-07-05: 4 类资源 setter (groups/function/exportment/science) ==============
|
|
72
|
-
// 默认 localManifest 不带这些字段; 一旦调用就 patch 进去. 不强制覆盖旧值.
|
|
73
|
-
export function addLocalGroup(g) {
|
|
74
|
-
localManifest.groups = localManifest.groups || [];
|
|
75
|
-
const idx = localManifest.groups.findIndex((x) => x.id === g.id);
|
|
76
|
-
if (idx >= 0)
|
|
77
|
-
localManifest.groups[idx] = { ...localManifest.groups[idx], ...g };
|
|
78
|
-
else
|
|
79
|
-
localManifest.groups.push(g);
|
|
80
|
-
localManifest.publishedAt = Date.now();
|
|
81
|
-
return localManifest;
|
|
82
|
-
}
|
|
83
|
-
export function addLocalFunction(f) {
|
|
84
|
-
localManifest.functions = localManifest.functions || [];
|
|
85
|
-
const idx = localManifest.functions.findIndex((x) => x.capability === f.capability);
|
|
86
|
-
if (idx >= 0)
|
|
87
|
-
localManifest.functions[idx] = { ...localManifest.functions[idx], ...f };
|
|
88
|
-
else
|
|
89
|
-
localManifest.functions.push(f);
|
|
90
|
-
localManifest.publishedAt = Date.now();
|
|
91
|
-
return localManifest;
|
|
92
|
-
}
|
|
93
|
-
export function addLocalExportment(e) {
|
|
94
|
-
localManifest.exportments = localManifest.exportments || [];
|
|
95
|
-
const idx = localManifest.exportments.findIndex((x) => x.name === e.name);
|
|
96
|
-
if (idx >= 0)
|
|
97
|
-
localManifest.exportments[idx] = { ...localManifest.exportments[idx], ...e };
|
|
98
|
-
else
|
|
99
|
-
localManifest.exportments.push(e);
|
|
100
|
-
localManifest.publishedAt = Date.now();
|
|
101
|
-
return localManifest;
|
|
102
|
-
}
|
|
103
|
-
export function addLocalScience(s) {
|
|
104
|
-
localManifest.sciences = localManifest.sciences || [];
|
|
105
|
-
const idx = localManifest.sciences.findIndex((x) => x.id === s.id);
|
|
106
|
-
if (idx >= 0)
|
|
107
|
-
localManifest.sciences[idx] = { ...localManifest.sciences[idx], ...s };
|
|
108
|
-
else
|
|
109
|
-
localManifest.sciences.push(s);
|
|
110
|
-
localManifest.publishedAt = Date.now();
|
|
111
|
-
return localManifest;
|
|
112
|
-
}
|
|
113
61
|
// ============== 远端 manifest 缓存 ==============
|
|
114
62
|
const remoteManifests = new Map(); // key = ownerPublicKey
|
|
115
63
|
export function cacheRemoteManifest(m) {
|
|
@@ -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
|