@bolloon/bolloon-agent 0.3.30 → 0.3.32
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/agents/pi-sdk-tools.js +128 -0
- package/dist/cli/ink-app.js +345 -2
- package/dist/cli/mention-data.js +238 -0
- package/dist/constraint-runtime/_archive_helper.d.ts +1 -0
- package/dist/constraint-runtime/_archive_helper.js +9 -0
- package/dist/constraint-runtime/agent/coordinator.d.ts +19 -0
- package/dist/constraint-runtime/agent/coordinator.js +48 -0
- package/dist/constraint-runtime/agent/index.d.ts +1 -0
- package/dist/constraint-runtime/agent/index.js +1 -0
- package/dist/constraint-runtime/assistant/index.d.ts +11 -0
- package/dist/constraint-runtime/assistant/index.js +12 -0
- package/dist/constraint-runtime/bootstrap/index.d.ts +11 -0
- package/dist/constraint-runtime/bootstrap/index.js +12 -0
- package/dist/constraint-runtime/bootstrap_graph.d.ts +4 -0
- package/dist/constraint-runtime/bootstrap_graph.js +13 -0
- package/dist/constraint-runtime/bridge/index.d.ts +11 -0
- package/dist/constraint-runtime/bridge/index.js +12 -0
- package/dist/constraint-runtime/buddy/index.d.ts +11 -0
- package/dist/constraint-runtime/buddy/index.js +12 -0
- package/dist/constraint-runtime/cli/index.d.ts +11 -0
- package/dist/constraint-runtime/cli/index.js +12 -0
- package/dist/constraint-runtime/command_graph.d.ts +7 -0
- package/dist/constraint-runtime/command_graph.js +10 -0
- package/dist/constraint-runtime/commands.d.ts +15 -0
- package/dist/constraint-runtime/commands.js +60 -0
- package/dist/constraint-runtime/components/index.d.ts +11 -0
- package/dist/constraint-runtime/components/index.js +12 -0
- package/dist/constraint-runtime/constants/index.d.ts +11 -0
- package/dist/constraint-runtime/constants/index.js +12 -0
- package/dist/constraint-runtime/constraint/budget.d.ts +11 -0
- package/dist/constraint-runtime/constraint/budget.js +22 -0
- package/dist/constraint-runtime/constraint/index.d.ts +3 -0
- package/dist/constraint-runtime/constraint/index.js +2 -0
- package/dist/constraint-runtime/constraint/permission.d.ts +9 -0
- package/dist/constraint-runtime/constraint/permission.js +20 -0
- package/dist/constraint-runtime/context.d.ts +12 -0
- package/dist/constraint-runtime/context.js +30 -0
- package/dist/constraint-runtime/coordinator/index.d.ts +11 -0
- package/dist/constraint-runtime/coordinator/index.js +12 -0
- package/dist/constraint-runtime/cost_hook.d.ts +2 -0
- package/dist/constraint-runtime/cost_hook.js +4 -0
- package/dist/constraint-runtime/cost_tracker.d.ts +5 -0
- package/dist/constraint-runtime/cost_tracker.js +8 -0
- package/dist/constraint-runtime/deferred_init.d.ts +8 -0
- package/dist/constraint-runtime/deferred_init.js +10 -0
- package/dist/constraint-runtime/direct_modes.d.ts +7 -0
- package/dist/constraint-runtime/direct_modes.js +6 -0
- package/dist/constraint-runtime/dynamic-tool-loader.d.ts +13 -0
- package/dist/constraint-runtime/dynamic-tool-loader.js +85 -0
- package/dist/constraint-runtime/entrypoints/index.d.ts +11 -0
- package/dist/constraint-runtime/entrypoints/index.js +12 -0
- package/dist/constraint-runtime/execution_registry.d.ts +20 -0
- package/dist/constraint-runtime/execution_registry.js +44 -0
- package/dist/constraint-runtime/history.d.ts +9 -0
- package/dist/constraint-runtime/history.js +9 -0
- package/dist/constraint-runtime/hooks/index.d.ts +11 -0
- package/dist/constraint-runtime/hooks/index.js +12 -0
- package/dist/constraint-runtime/index.d.ts +26 -0
- package/dist/constraint-runtime/index.js +26 -0
- package/dist/constraint-runtime/ink.d.ts +1 -0
- package/dist/constraint-runtime/ink.js +4 -0
- package/dist/constraint-runtime/keybindings/index.d.ts +11 -0
- package/dist/constraint-runtime/keybindings/index.js +12 -0
- package/dist/constraint-runtime/memdir/index.d.ts +11 -0
- package/dist/constraint-runtime/memdir/index.js +12 -0
- package/dist/constraint-runtime/migrations/index.d.ts +11 -0
- package/dist/constraint-runtime/migrations/index.js +12 -0
- package/dist/constraint-runtime/models.d.ts +42 -0
- package/dist/constraint-runtime/models.js +1 -0
- package/dist/constraint-runtime/moreright/index.d.ts +11 -0
- package/dist/constraint-runtime/moreright/index.js +12 -0
- package/dist/constraint-runtime/native_ts/index.d.ts +11 -0
- package/dist/constraint-runtime/native_ts/index.js +12 -0
- package/dist/constraint-runtime/output_styles/index.d.ts +11 -0
- package/dist/constraint-runtime/output_styles/index.js +12 -0
- package/dist/constraint-runtime/parity_audit.d.ts +11 -0
- package/dist/constraint-runtime/parity_audit.js +12 -0
- package/dist/constraint-runtime/plugins/index.d.ts +11 -0
- package/dist/constraint-runtime/plugins/index.js +12 -0
- package/dist/constraint-runtime/port_manifest.d.ts +7 -0
- package/dist/constraint-runtime/port_manifest.js +11 -0
- package/dist/constraint-runtime/prefetch.d.ts +8 -0
- package/dist/constraint-runtime/prefetch.js +9 -0
- package/dist/constraint-runtime/query.d.ts +6 -0
- package/dist/constraint-runtime/query.js +1 -0
- package/dist/constraint-runtime/reference_data/archive_surface_snapshot.json +63 -0
- package/dist/constraint-runtime/reference_data/commands_snapshot.json +1037 -0
- package/dist/constraint-runtime/reference_data/subsystems/assistant.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/bootstrap.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/bridge.json +32 -0
- package/dist/constraint-runtime/reference_data/subsystems/buddy.json +13 -0
- package/dist/constraint-runtime/reference_data/subsystems/cli.json +26 -0
- package/dist/constraint-runtime/reference_data/subsystems/components.json +32 -0
- package/dist/constraint-runtime/reference_data/subsystems/constants.json +28 -0
- package/dist/constraint-runtime/reference_data/subsystems/coordinator.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/entrypoints.json +15 -0
- package/dist/constraint-runtime/reference_data/subsystems/hooks.json +32 -0
- package/dist/constraint-runtime/reference_data/subsystems/keybindings.json +21 -0
- package/dist/constraint-runtime/reference_data/subsystems/memdir.json +15 -0
- package/dist/constraint-runtime/reference_data/subsystems/migrations.json +18 -0
- package/dist/constraint-runtime/reference_data/subsystems/moreright.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/native_ts.json +11 -0
- package/dist/constraint-runtime/reference_data/subsystems/outputStyles.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/plugins.json +9 -0
- package/dist/constraint-runtime/reference_data/subsystems/remote.json +11 -0
- package/dist/constraint-runtime/reference_data/subsystems/schemas.json +8 -0
- package/dist/constraint-runtime/reference_data/subsystems/screens.json +10 -0
- package/dist/constraint-runtime/reference_data/subsystems/server.json +10 -0
- package/dist/constraint-runtime/reference_data/subsystems/services.json +32 -0
- package/dist/constraint-runtime/reference_data/subsystems/skills.json +27 -0
- package/dist/constraint-runtime/reference_data/subsystems/state.json +13 -0
- package/dist/constraint-runtime/reference_data/subsystems/types.json +18 -0
- package/dist/constraint-runtime/reference_data/subsystems/upstreamproxy.json +9 -0
- package/dist/constraint-runtime/reference_data/subsystems/utils.json +32 -0
- package/dist/constraint-runtime/reference_data/subsystems/vim.json +12 -0
- package/dist/constraint-runtime/reference_data/subsystems/voice.json +8 -0
- package/dist/constraint-runtime/reference_data/tools_snapshot.json +922 -0
- package/dist/constraint-runtime/remote/index.d.ts +11 -0
- package/dist/constraint-runtime/remote/index.js +12 -0
- package/dist/constraint-runtime/remote_runtime.d.ts +8 -0
- package/dist/constraint-runtime/remote_runtime.js +9 -0
- package/dist/constraint-runtime/runtime/index.d.ts +1 -0
- package/dist/constraint-runtime/runtime/index.js +1 -0
- package/dist/constraint-runtime/runtime/session.d.ts +22 -0
- package/dist/constraint-runtime/runtime/session.js +35 -0
- package/dist/constraint-runtime/schemas/index.d.ts +11 -0
- package/dist/constraint-runtime/schemas/index.js +12 -0
- package/dist/constraint-runtime/screens/index.d.ts +11 -0
- package/dist/constraint-runtime/screens/index.js +12 -0
- package/dist/constraint-runtime/server/index.d.ts +11 -0
- package/dist/constraint-runtime/server/index.js +12 -0
- package/dist/constraint-runtime/services/index.d.ts +11 -0
- package/dist/constraint-runtime/services/index.js +12 -0
- package/dist/constraint-runtime/session_store.d.ts +8 -0
- package/dist/constraint-runtime/session_store.js +22 -0
- package/dist/constraint-runtime/setup.d.ts +19 -0
- package/dist/constraint-runtime/setup.js +30 -0
- package/dist/constraint-runtime/skills/index.d.ts +1 -0
- package/dist/constraint-runtime/skills/index.js +1 -0
- package/dist/constraint-runtime/skills/skill-registry.d.ts +14 -0
- package/dist/constraint-runtime/skills/skill-registry.js +28 -0
- package/dist/constraint-runtime/state/index.d.ts +11 -0
- package/dist/constraint-runtime/state/index.js +12 -0
- package/dist/constraint-runtime/system_init.d.ts +1 -0
- package/dist/constraint-runtime/system_init.js +20 -0
- package/dist/constraint-runtime/thinking/engine.d.ts +20 -0
- package/dist/constraint-runtime/thinking/engine.js +42 -0
- package/dist/constraint-runtime/thinking/index.d.ts +1 -0
- package/dist/constraint-runtime/thinking/index.js +1 -0
- package/dist/constraint-runtime/tool_pool.d.ts +8 -0
- package/dist/constraint-runtime/tool_pool.js +8 -0
- package/dist/constraint-runtime/tools/OpenCLI/execAdapter.d.ts +9 -0
- package/dist/constraint-runtime/tools/OpenCLI/execAdapter.js +7 -0
- package/dist/constraint-runtime/tools/OpenCLI/listAdapters.d.ts +5 -0
- package/dist/constraint-runtime/tools/OpenCLI/listAdapters.js +7 -0
- package/dist/constraint-runtime/tools/OpenCLI/runCommand.d.ts +10 -0
- package/dist/constraint-runtime/tools/OpenCLI/runCommand.js +7 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/cancelOrder.d.ts +17 -0
- package/dist/constraint-runtime/{src/tools → tools}/PolymarketSDK/cancelOrder.js +4 -7
- package/dist/constraint-runtime/tools/PolymarketSDK/clobShared.d.ts +50 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/clobShared.js +78 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/createOrder.d.ts +31 -0
- package/dist/constraint-runtime/{src/tools → tools}/PolymarketSDK/createOrder.js +9 -12
- package/dist/constraint-runtime/tools/PolymarketSDK/getMarket.d.ts +10 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/getMarket.js +16 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/getOrders.d.ts +16 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/getOrders.js +25 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/listMarkets.d.ts +23 -0
- package/dist/constraint-runtime/tools/PolymarketSDK/listMarkets.js +24 -0
- package/dist/constraint-runtime/tools/SafeSDK/confirmTransaction.d.ts +10 -0
- package/dist/constraint-runtime/tools/SafeSDK/confirmTransaction.js +6 -0
- package/dist/constraint-runtime/tools/SafeSDK/createTransaction.d.ts +14 -0
- package/dist/constraint-runtime/tools/SafeSDK/createTransaction.js +8 -0
- package/dist/constraint-runtime/tools/SafeSDK/deploySafe.d.ts +10 -0
- package/dist/constraint-runtime/tools/SafeSDK/executeTransaction.d.ts +9 -0
- package/dist/constraint-runtime/tools/SafeSDK/executeTransaction.js +6 -0
- package/dist/constraint-runtime/tools/SafeSDK/getBalance.d.ts +7 -0
- package/dist/constraint-runtime/tools/SafeSDK/getBalance.js +6 -0
- package/dist/constraint-runtime/tools/SafeSDK/getPendingTransactions.d.ts +7 -0
- package/dist/constraint-runtime/tools/SafeSDK/getPendingTransactions.js +6 -0
- package/dist/constraint-runtime/tools/SafeSDK/proposeTransaction.d.ts +11 -0
- package/dist/constraint-runtime/tools/SafeSDK/proposeTransaction.js +6 -0
- package/dist/constraint-runtime/tools/WalletTools/autoPay.d.ts +26 -0
- package/dist/constraint-runtime/tools/WalletTools/createWallet.d.ts +7 -0
- package/dist/constraint-runtime/tools/WalletTools/getBalance.d.ts +11 -0
- package/dist/constraint-runtime/tools/WalletTools/importWallet.d.ts +10 -0
- package/dist/constraint-runtime/tools/WalletTools/sendTransaction.d.ts +20 -0
- package/dist/constraint-runtime/tools/WalletTools/signMessage.d.ts +10 -0
- package/dist/constraint-runtime/tools/WalletTools/transferToken.d.ts +17 -0
- package/dist/constraint-runtime/tools.d.ts +14 -0
- package/dist/constraint-runtime/tools.js +80 -0
- package/dist/constraint-runtime/transcript.d.ts +8 -0
- package/dist/constraint-runtime/transcript.js +19 -0
- package/dist/constraint-runtime/types/index.d.ts +11 -0
- package/dist/constraint-runtime/types/index.js +12 -0
- package/dist/constraint-runtime/upstream_proxy/index.d.ts +11 -0
- package/dist/constraint-runtime/upstream_proxy/index.js +12 -0
- package/dist/constraint-runtime/utils/index.d.ts +11 -0
- package/dist/constraint-runtime/utils/index.js +12 -0
- package/dist/constraint-runtime/vim/index.d.ts +11 -0
- package/dist/constraint-runtime/vim/index.js +12 -0
- package/dist/constraint-runtime/voice/index.d.ts +11 -0
- package/dist/constraint-runtime/voice/index.js +12 -0
- package/dist/index.js +7 -4
- package/dist/llm/config-store.js +39 -28
- package/dist/llm/pi-ai.js +64 -36
- package/dist/security/tool-gate.js +2 -0
- package/package.json +3 -2
- package/dist/constraint-runtime/src/tools/PolymarketSDK/clobShared.js +0 -104
- package/dist/constraint-runtime/src/tools/PolymarketSDK/getMarket.js +0 -5
- package/dist/constraint-runtime/src/tools/PolymarketSDK/getOrders.js +0 -19
- package/dist/constraint-runtime/src/tools/PolymarketSDK/listMarkets.js +0 -4
- /package/dist/constraint-runtime/{src/tools → tools}/SafeSDK/deploySafe.js +0 -0
- /package/dist/constraint-runtime/{src/tools → tools}/WalletTools/autoPay.js +0 -0
- /package/dist/constraint-runtime/{src/tools → tools}/WalletTools/createWallet.js +0 -0
- /package/dist/constraint-runtime/{src/tools → tools}/WalletTools/getBalance.js +0 -0
- /package/dist/constraint-runtime/{src/tools → tools}/WalletTools/importWallet.js +0 -0
- /package/dist/constraint-runtime/{src/tools → tools}/WalletTools/sendTransaction.js +0 -0
- /package/dist/constraint-runtime/{src/tools → tools}/WalletTools/signMessage.js +0 -0
- /package/dist/constraint-runtime/{src/tools → tools}/WalletTools/transferToken.js +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const ARCHIVE_NAME: string;
|
|
2
|
+
export declare const MODULE_COUNT: number;
|
|
3
|
+
export declare const SAMPLE_FILES: string[];
|
|
4
|
+
export declare const PORTING_NOTE: string;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
ARCHIVE_NAME: string;
|
|
7
|
+
MODULE_COUNT: number;
|
|
8
|
+
PORTING_NOTE: string;
|
|
9
|
+
SAMPLE_FILES: string[];
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { loadArchiveMetadata } from '../_archive_helper.js';
|
|
2
|
+
const SNAPSHOT = loadArchiveMetadata('upstream_proxy');
|
|
3
|
+
export const ARCHIVE_NAME = SNAPSHOT['archive_name'];
|
|
4
|
+
export const MODULE_COUNT = SNAPSHOT['module_count'];
|
|
5
|
+
export const SAMPLE_FILES = SNAPSHOT['sample_files'];
|
|
6
|
+
export const PORTING_NOTE = `Python placeholder package for '${ARCHIVE_NAME}' with ${MODULE_COUNT} archived module references.`;
|
|
7
|
+
export default {
|
|
8
|
+
ARCHIVE_NAME,
|
|
9
|
+
MODULE_COUNT,
|
|
10
|
+
PORTING_NOTE,
|
|
11
|
+
SAMPLE_FILES,
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const ARCHIVE_NAME: string;
|
|
2
|
+
export declare const MODULE_COUNT: number;
|
|
3
|
+
export declare const SAMPLE_FILES: string[];
|
|
4
|
+
export declare const PORTING_NOTE: string;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
ARCHIVE_NAME: string;
|
|
7
|
+
MODULE_COUNT: number;
|
|
8
|
+
PORTING_NOTE: string;
|
|
9
|
+
SAMPLE_FILES: string[];
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { loadArchiveMetadata } from '../_archive_helper.js';
|
|
2
|
+
const SNAPSHOT = loadArchiveMetadata('utils');
|
|
3
|
+
export const ARCHIVE_NAME = SNAPSHOT['archive_name'];
|
|
4
|
+
export const MODULE_COUNT = SNAPSHOT['module_count'];
|
|
5
|
+
export const SAMPLE_FILES = SNAPSHOT['sample_files'];
|
|
6
|
+
export const PORTING_NOTE = `Python placeholder package for '${ARCHIVE_NAME}' with ${MODULE_COUNT} archived module references.`;
|
|
7
|
+
export default {
|
|
8
|
+
ARCHIVE_NAME,
|
|
9
|
+
MODULE_COUNT,
|
|
10
|
+
PORTING_NOTE,
|
|
11
|
+
SAMPLE_FILES,
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const ARCHIVE_NAME: string;
|
|
2
|
+
export declare const MODULE_COUNT: number;
|
|
3
|
+
export declare const SAMPLE_FILES: string[];
|
|
4
|
+
export declare const PORTING_NOTE: string;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
ARCHIVE_NAME: string;
|
|
7
|
+
MODULE_COUNT: number;
|
|
8
|
+
PORTING_NOTE: string;
|
|
9
|
+
SAMPLE_FILES: string[];
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { loadArchiveMetadata } from '../_archive_helper.js';
|
|
2
|
+
const SNAPSHOT = loadArchiveMetadata('vim');
|
|
3
|
+
export const ARCHIVE_NAME = SNAPSHOT['archive_name'];
|
|
4
|
+
export const MODULE_COUNT = SNAPSHOT['module_count'];
|
|
5
|
+
export const SAMPLE_FILES = SNAPSHOT['sample_files'];
|
|
6
|
+
export const PORTING_NOTE = `Python placeholder package for '${ARCHIVE_NAME}' with ${MODULE_COUNT} archived module references.`;
|
|
7
|
+
export default {
|
|
8
|
+
ARCHIVE_NAME,
|
|
9
|
+
MODULE_COUNT,
|
|
10
|
+
PORTING_NOTE,
|
|
11
|
+
SAMPLE_FILES,
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const ARCHIVE_NAME: string;
|
|
2
|
+
export declare const MODULE_COUNT: number;
|
|
3
|
+
export declare const SAMPLE_FILES: string[];
|
|
4
|
+
export declare const PORTING_NOTE: string;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
ARCHIVE_NAME: string;
|
|
7
|
+
MODULE_COUNT: number;
|
|
8
|
+
PORTING_NOTE: string;
|
|
9
|
+
SAMPLE_FILES: string[];
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { loadArchiveMetadata } from '../_archive_helper.js';
|
|
2
|
+
const SNAPSHOT = loadArchiveMetadata('voice');
|
|
3
|
+
export const ARCHIVE_NAME = SNAPSHOT['archive_name'];
|
|
4
|
+
export const MODULE_COUNT = SNAPSHOT['module_count'];
|
|
5
|
+
export const SAMPLE_FILES = SNAPSHOT['sample_files'];
|
|
6
|
+
export const PORTING_NOTE = `Python placeholder package for '${ARCHIVE_NAME}' with ${MODULE_COUNT} archived module references.`;
|
|
7
|
+
export default {
|
|
8
|
+
ARCHIVE_NAME,
|
|
9
|
+
MODULE_COUNT,
|
|
10
|
+
PORTING_NOTE,
|
|
11
|
+
SAMPLE_FILES,
|
|
12
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -415,11 +415,10 @@ async function startCLI(comm) {
|
|
|
415
415
|
// 进入 Ink TUI 输入循环
|
|
416
416
|
const initialStatus = `${C_ACCENT}${cliModelName}\x1b[0m\x1b[90m │\x1b[0m ${cliAgentName} \x1b[90m│\x1b[0m ⏱ 0s`;
|
|
417
417
|
const getStatus = () => {
|
|
418
|
-
const dur = Math.floor((Date.now() - cliStartTime) / 1000);
|
|
419
418
|
const barLen = 12;
|
|
420
419
|
const filled = Math.round((cliContextPct / 100) * barLen);
|
|
421
420
|
const bar = '█'.repeat(filled) + '░'.repeat(barLen - filled);
|
|
422
|
-
return `${C_ACCENT}${cliModelName}\x1b[0m\x1b[90m │\x1b[0m ${cliAgentName} \x1b[90m│\x1b[0m ⏱ ${
|
|
421
|
+
return `${C_ACCENT}${cliModelName}\x1b[0m\x1b[90m │\x1b[0m ${cliAgentName} \x1b[90m│\x1b[0m ⏱ ${fmtDuration(Date.now() - cliStartTime)}\x1b[90m │\x1b[0m ${bar} ${cliContextPct}%`;
|
|
423
422
|
};
|
|
424
423
|
startInk((text) => { processInput(text, comm); }, initialStatus, getStatus);
|
|
425
424
|
// Wait on a promise that resolves on Ctrl+C / 双击 Esc
|
|
@@ -494,6 +493,11 @@ async function processInput(input, comm) {
|
|
|
494
493
|
appendLine(` ${C_ACCENT}!<cmd>${RESET} 执行终端命令 ${C_DIM}如 !ls -la${RESET}`);
|
|
495
494
|
appendLine(` ${C_ACCENT}/queue${RESET} 切换队列模式 ${C_DIM}输入排队, 当前结束后自动执行${RESET}`);
|
|
496
495
|
appendLine(` ${C_ACCENT}/dequeue${RESET} 出队一条`);
|
|
496
|
+
appendLine(` ${C_ACCENT}@名字${RESET} @ 命中智能体 ${C_DIM}弹出窗选择后发送给智能体${RESET}`);
|
|
497
|
+
appendLine(` ${C_ACCENT}/名字${RESET} / 命中命令/技能/插件 ${C_DIM}输入 / 自动弹出${RESET}`);
|
|
498
|
+
appendLine(` ${C_ACCENT}#路径${RESET} # 命中文件 ${C_DIM}输入 # 自动弹出文件列表${RESET}`);
|
|
499
|
+
appendLine(` ${C_ACCENT}Tab${RESET} 补齐命令 ${C_DIM}普通输入也能 Tab 补 /命令 use_skill 技能 @智能体 #文件${RESET}`);
|
|
500
|
+
appendLine(` ${C_ACCENT}↑/↓${RESET} 切换历史输入 ${C_DIM}↑ 翻上一条, ↓ 回下一条/草稿${RESET}`);
|
|
497
501
|
appendLine(` ${C_ACCENT}peers${RESET} 查看 P2P 节点`);
|
|
498
502
|
appendLine(` ${C_ACCENT}iroh${RESET} 查看 iroh 状态`);
|
|
499
503
|
appendLine(` ${C_ACCENT}add_friend${RESET} 添加好友`);
|
|
@@ -617,11 +621,10 @@ async function processInput(input, comm) {
|
|
|
617
621
|
try {
|
|
618
622
|
const msgLen = JSON.stringify(a.messageHistory ?? []).length;
|
|
619
623
|
cliContextPct = Math.min(100, Math.round((msgLen / 240_000) * 100));
|
|
620
|
-
const dur = Math.floor((Date.now() - cliStartTime) / 1000);
|
|
621
624
|
const barLen = 12;
|
|
622
625
|
const filled = Math.round((cliContextPct / 100) * barLen);
|
|
623
626
|
const bar = '█'.repeat(filled) + '░'.repeat(barLen - filled);
|
|
624
|
-
const statusText = `${C_ACCENT}${cliModelName}\x1b[0m\x1b[90m │\x1b[0m ${cliAgentName} \x1b[90m│\x1b[0m ⏱ ${
|
|
627
|
+
const statusText = `${C_ACCENT}${cliModelName}\x1b[0m\x1b[90m │\x1b[0m ${cliAgentName} \x1b[90m│\x1b[0m ⏱ ${fmtDuration(Date.now() - cliStartTime)} \x1b[90m│\x1b[0m ${msgLen.toLocaleString()}B/240K │ ${bar} ${cliContextPct}%`;
|
|
625
628
|
inkSetStatus(statusText);
|
|
626
629
|
}
|
|
627
630
|
catch { /* 降级容忍 */ }
|
package/dist/llm/config-store.js
CHANGED
|
@@ -11,46 +11,46 @@ export const DEFAULT_PROVIDER_CONFIGS = {
|
|
|
11
11
|
enabled: false,
|
|
12
12
|
apiKey: '',
|
|
13
13
|
baseUrl: 'https://api.openai.com/v1',
|
|
14
|
-
model: 'gpt-5.
|
|
14
|
+
model: 'gpt-5.6',
|
|
15
15
|
temperature: 0.7,
|
|
16
16
|
maxTokens: 4096,
|
|
17
|
-
requiresApiKey: true
|
|
17
|
+
requiresApiKey: true,
|
|
18
18
|
},
|
|
19
19
|
anthropic: {
|
|
20
20
|
enabled: false,
|
|
21
21
|
apiKey: '',
|
|
22
22
|
baseUrl: 'https://api.anthropic.com/v1',
|
|
23
|
-
model: 'claude-sonnet-
|
|
23
|
+
model: 'claude-sonnet-5',
|
|
24
24
|
temperature: 0.7,
|
|
25
25
|
maxTokens: 4096,
|
|
26
|
-
requiresApiKey: true
|
|
26
|
+
requiresApiKey: true,
|
|
27
27
|
},
|
|
28
28
|
openrouter: {
|
|
29
29
|
enabled: false,
|
|
30
30
|
apiKey: '',
|
|
31
31
|
baseUrl: 'https://openrouter.ai/api/v1',
|
|
32
|
-
model: 'anthropic/claude-sonnet-
|
|
32
|
+
model: 'anthropic/claude-sonnet-5',
|
|
33
33
|
temperature: 0.7,
|
|
34
34
|
maxTokens: 4096,
|
|
35
|
-
requiresApiKey: true
|
|
35
|
+
requiresApiKey: true,
|
|
36
36
|
},
|
|
37
37
|
gemini: {
|
|
38
38
|
enabled: false,
|
|
39
39
|
apiKey: '',
|
|
40
40
|
baseUrl: 'https://generativelanguage.googleapis.com/v1beta',
|
|
41
|
-
model: 'gemini-
|
|
41
|
+
model: 'gemini-3.5-flash',
|
|
42
42
|
temperature: 0.7,
|
|
43
43
|
maxTokens: 4096,
|
|
44
|
-
requiresApiKey: true
|
|
44
|
+
requiresApiKey: true,
|
|
45
45
|
},
|
|
46
46
|
ollama: {
|
|
47
47
|
enabled: true,
|
|
48
48
|
apiKey: '',
|
|
49
49
|
baseUrl: 'http://localhost:11434',
|
|
50
|
-
model: '
|
|
50
|
+
model: 'llama4',
|
|
51
51
|
temperature: 0.7,
|
|
52
52
|
maxTokens: 4096,
|
|
53
|
-
requiresApiKey:
|
|
53
|
+
requiresApiKey: true,
|
|
54
54
|
},
|
|
55
55
|
minimax: {
|
|
56
56
|
enabled: false,
|
|
@@ -59,7 +59,7 @@ export const DEFAULT_PROVIDER_CONFIGS = {
|
|
|
59
59
|
model: 'MiniMax-M3',
|
|
60
60
|
temperature: 0.7,
|
|
61
61
|
maxTokens: 4096,
|
|
62
|
-
requiresApiKey: true
|
|
62
|
+
requiresApiKey: true,
|
|
63
63
|
},
|
|
64
64
|
deepseek: {
|
|
65
65
|
enabled: false,
|
|
@@ -70,34 +70,34 @@ export const DEFAULT_PROVIDER_CONFIGS = {
|
|
|
70
70
|
model: 'deepseek-v4-flash',
|
|
71
71
|
temperature: 0.7,
|
|
72
72
|
maxTokens: 4096,
|
|
73
|
-
requiresApiKey: true
|
|
73
|
+
requiresApiKey: true,
|
|
74
74
|
},
|
|
75
75
|
kimi: {
|
|
76
76
|
enabled: false,
|
|
77
77
|
apiKey: '',
|
|
78
78
|
baseUrl: 'https://api.moonshot.cn/v1',
|
|
79
|
-
model: '
|
|
79
|
+
model: 'kimi-k3',
|
|
80
80
|
temperature: 0.7,
|
|
81
81
|
maxTokens: 4096,
|
|
82
|
-
requiresApiKey: true
|
|
82
|
+
requiresApiKey: true,
|
|
83
83
|
},
|
|
84
84
|
glm: {
|
|
85
85
|
enabled: false,
|
|
86
86
|
apiKey: '',
|
|
87
87
|
baseUrl: 'https://open.bigmodel.cn/api/paas/v4',
|
|
88
|
-
model: 'glm-
|
|
88
|
+
model: 'glm-5.2',
|
|
89
89
|
temperature: 0.7,
|
|
90
90
|
maxTokens: 4096,
|
|
91
|
-
requiresApiKey: true
|
|
91
|
+
requiresApiKey: true,
|
|
92
92
|
},
|
|
93
93
|
qwen: {
|
|
94
94
|
enabled: false,
|
|
95
95
|
apiKey: '',
|
|
96
96
|
baseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
|
97
|
-
model: '
|
|
97
|
+
model: 'qwen3-max',
|
|
98
98
|
temperature: 0.7,
|
|
99
99
|
maxTokens: 4096,
|
|
100
|
-
requiresApiKey: true
|
|
100
|
+
requiresApiKey: true,
|
|
101
101
|
},
|
|
102
102
|
// 小米 MiMo (openai 兼容) — 默认 base URL https://api.xiaomi.com/v1
|
|
103
103
|
mimo: {
|
|
@@ -107,29 +107,39 @@ export const DEFAULT_PROVIDER_CONFIGS = {
|
|
|
107
107
|
model: 'mimo-v2.5-pro',
|
|
108
108
|
temperature: 0.7,
|
|
109
109
|
maxTokens: 4096,
|
|
110
|
-
requiresApiKey: true
|
|
110
|
+
requiresApiKey: true,
|
|
111
111
|
},
|
|
112
112
|
local: {
|
|
113
113
|
enabled: false,
|
|
114
114
|
apiKey: '',
|
|
115
115
|
baseUrl: 'http://localhost:11434',
|
|
116
|
-
model: '
|
|
116
|
+
model: 'llama4',
|
|
117
117
|
temperature: 0.7,
|
|
118
118
|
maxTokens: 4096,
|
|
119
|
-
requiresApiKey: false
|
|
119
|
+
requiresApiKey: false,
|
|
120
|
+
},
|
|
121
|
+
// xAI Grok (openai 兼容) — 2026-08-04 新增
|
|
122
|
+
grok: {
|
|
123
|
+
enabled: false,
|
|
124
|
+
apiKey: '',
|
|
125
|
+
baseUrl: 'https://api.x.ai/v1',
|
|
126
|
+
model: 'grok-4.5',
|
|
127
|
+
temperature: 0.7,
|
|
128
|
+
maxTokens: 4096,
|
|
129
|
+
requiresApiKey: true
|
|
120
130
|
}
|
|
121
131
|
};
|
|
122
132
|
export const PROVIDER_INFO = {
|
|
123
|
-
openai: { name: 'OpenAI', description: 'GPT
|
|
124
|
-
anthropic: { name: 'Anthropic', description: 'Claude
|
|
125
|
-
openrouter: { name: 'OpenRouter', description: '聚合多个 AI 供应商', requiresApiKey: true, models: ['anthropic/claude-sonnet-
|
|
133
|
+
openai: { name: 'OpenAI', description: 'GPT 系列模型', requiresApiKey: true, models: ['gpt-5.6', 'gpt-5.6-sol', 'gpt-5.6-terra', 'gpt-5.6-luna', 'gpt-4.1', 'gpt-4o'] },
|
|
134
|
+
anthropic: { name: 'Anthropic', description: 'Claude 5 系列模型', requiresApiKey: true, models: ['claude-sonnet-5', 'claude-opus-5', 'claude-fable-5', 'claude-haiku-4.5', 'claude-sonnet-4-5-20250929'] },
|
|
135
|
+
openrouter: { name: 'OpenRouter', description: '聚合多个 AI 供应商', requiresApiKey: true, models: ['anthropic/claude-sonnet-5', 'openai/gpt-5.6', 'google/gemini-3.5-flash', 'x-ai/grok-4.5'] },
|
|
126
136
|
gemini: { name: 'Google Gemini', description: 'Gemini 系列模型', requiresApiKey: true, models: [
|
|
127
137
|
'gemini-3.5-flash', // 2026-06 官方推荐 stable 旗舰 (https://ai.google.dev/gemini-api/docs/models)
|
|
128
138
|
'gemini-2.5-pro', // 高级推理, 仍为 GA
|
|
129
139
|
'gemini-3.1-flash-lite', // 成本敏感场景
|
|
130
140
|
'gemini-flash-latest', // 滚动 alias → 当前 stable Flash
|
|
131
141
|
] },
|
|
132
|
-
ollama: { name: 'Ollama', description: '本地 LLM 运行框架', requiresApiKey: false },
|
|
142
|
+
ollama: { name: 'Ollama', description: '本地 LLM 运行框架', requiresApiKey: false, },
|
|
133
143
|
minimax: {
|
|
134
144
|
name: 'MiniMax',
|
|
135
145
|
description: '国产大模型服务',
|
|
@@ -138,10 +148,11 @@ export const PROVIDER_INFO = {
|
|
|
138
148
|
},
|
|
139
149
|
// 2026-07-17: V3 系列 (deepseek-chat / deepseek-reasoner) 官方已下线, 改 V4
|
|
140
150
|
deepseek: { name: 'DeepSeek', description: '深度求索大模型 (V4)', requiresApiKey: true, models: ['deepseek-v4-flash', 'deepseek-v4-pro'] },
|
|
141
|
-
kimi: { name: 'Kimi (月之暗面)', description: 'Moonshot
|
|
142
|
-
glm: { name: 'GLM (智谱)', description: '智谱
|
|
143
|
-
qwen: { name: 'Qwen (通义千问)', description: '阿里云通义千问系列', requiresApiKey: true, models: ['
|
|
151
|
+
kimi: { name: 'Kimi (月之暗面)', description: 'Moonshot Kimi K 系列模型', requiresApiKey: true, models: ['kimi-k3', 'kimi-k2-0905', 'moonshot-v1-128k', 'moonshot-v1-32k'] },
|
|
152
|
+
glm: { name: 'GLM (智谱)', description: '智谱 GLM 系列模型', requiresApiKey: true, models: ['glm-5.2', 'glm-4.6', 'glm-4.5', 'glm-4-flash', 'glm-4'] },
|
|
153
|
+
qwen: { name: 'Qwen (通义千问)', description: '阿里云通义千问系列', requiresApiKey: true, models: ['qwen3-max', 'qwen-max', 'qwen-plus', 'qwen-turbo'] },
|
|
144
154
|
mimo: { name: 'MiMo (小米)', description: '小米 MiMo V2 系列 (openai 兼容)', requiresApiKey: true, models: ['mimo-v2.5-pro', 'mimo-v2-pro', 'mimo-v2-omni', 'mimo-v2-flash', 'mimo-v2.5-pro-ultraspeed'] },
|
|
155
|
+
grok: { name: 'Grok (xAI)', description: 'xAI Grok 系列模型 (openai 兼容)', requiresApiKey: true, models: ['grok-4.5', 'grok-4', 'grok-4-fast'] },
|
|
145
156
|
local: { name: '本地模型', description: '本地部署的模型服务', requiresApiKey: false }
|
|
146
157
|
};
|
|
147
158
|
function getDefaultConfig() {
|
package/dist/llm/pi-ai.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
|
+
import { request, Agent } from 'undici';
|
|
3
4
|
/**
|
|
4
5
|
* 外部 system 注入钩子.
|
|
5
6
|
* 调用方 (e.g. auto-evolve-loop) 用 setSystemPrependProvider() 注册一个返回字符串的函数,
|
|
@@ -107,7 +108,9 @@ export class PiAIModel {
|
|
|
107
108
|
// 旧版: "抱歉,AI服务暂时不可用。" → LLM 看到 isTooShort=false(< 50 但 > 0),
|
|
108
109
|
// needsMoreWork 不会触发, 但 hasError 模式 (含 "error" / "失败") 会判定要继续修
|
|
109
110
|
// 新版: 让 LLM 立即停止循环, 直接展示给用户
|
|
110
|
-
|
|
111
|
+
// 2026-08-04: 带上 error.cause (undici 网络错误根因如 "other side closed" 在 cause 里)
|
|
112
|
+
const causeMsg = error?.cause?.message ? ` (cause: ${String(error.cause.message).slice(0, 150)})` : '';
|
|
113
|
+
const errMsg = ((error?.message || '') + causeMsg).slice(0, 300);
|
|
111
114
|
return {
|
|
112
115
|
reply: `[AI 服务调用失败] ${errMsg}\n\n这是一个**底层 API 错误**(401 / 鉴权失败 / 网络中断 / 配额耗尽等),不是你的任务有问题。**请直接把这个错误消息回复给用户,不要再循环尝试。**`,
|
|
113
116
|
};
|
|
@@ -184,6 +187,7 @@ export class PiAIModel {
|
|
|
184
187
|
case 'glm':
|
|
185
188
|
case 'qwen':
|
|
186
189
|
case 'mimo':
|
|
190
|
+
case 'grok':
|
|
187
191
|
return this.callOpenAI(finalMessages, temperature, maxTokens, signal, openaiTools);
|
|
188
192
|
case 'anthropic':
|
|
189
193
|
return this.callAnthropic(finalMessages, temperature, maxTokens, signal);
|
|
@@ -215,6 +219,7 @@ export class PiAIModel {
|
|
|
215
219
|
glm: process.env.GLM_API_KEY || process.env.ZHIPU_API_KEY || '',
|
|
216
220
|
qwen: process.env.QWEN_API_KEY || process.env.DASHSCOPE_API_KEY || '',
|
|
217
221
|
mimo: process.env.MIMO_API_KEY || '',
|
|
222
|
+
grok: process.env.XAI_API_KEY || '',
|
|
218
223
|
local: ''
|
|
219
224
|
};
|
|
220
225
|
return envVars[this.provider] || '';
|
|
@@ -237,28 +242,31 @@ export class PiAIModel {
|
|
|
237
242
|
qwen: process.env.QWEN_BASE_URL || process.env.DASHSCOPE_BASE_URL || 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
|
238
243
|
// 小米 MiMo: 走 OpenAI 兼容 API, 官方 endpoint
|
|
239
244
|
mimo: process.env.MIMO_BASE_URL || 'https://api.xiaomi.com/v1',
|
|
245
|
+
grok: process.env.XAI_BASE_URL || 'https://api.x.ai/v1',
|
|
240
246
|
local: 'http://localhost:11434'
|
|
241
247
|
};
|
|
242
248
|
return baseUrls[this.provider];
|
|
243
249
|
}
|
|
244
250
|
mapModel() {
|
|
251
|
+
// 2026-08-04: 型号全面更新 (官方文档确认):
|
|
252
|
+
// OpenAI gpt-5.6 (alias→Sol) / Anthropic claude-sonnet-5 / Gemini gemini-3.5-flash (pro 线最新, 3.5 仅 flash)
|
|
253
|
+
// Grok grok-4.5 / Kimi kimi-k3 / GLM glm-5.2 / Qwen qwen3-max
|
|
245
254
|
const modelMap = {
|
|
246
|
-
openai: this.config.model || process.env.OPENAI_MODEL || 'gpt-
|
|
247
|
-
anthropic: this.config.model || 'claude-sonnet-
|
|
248
|
-
ollama: this.config.model || '
|
|
249
|
-
openrouter: this.config.model || 'anthropic/claude-sonnet-
|
|
250
|
-
|
|
251
|
-
// The 3.x line ships as `-flash` only — there is no `gemini-3.x-pro`.
|
|
252
|
-
gemini: this.config.model || 'gemini-2.5-pro',
|
|
255
|
+
openai: this.config.model || process.env.OPENAI_MODEL || 'gpt-5.6',
|
|
256
|
+
anthropic: this.config.model || process.env.ANTHROPIC_MODEL || 'claude-sonnet-5',
|
|
257
|
+
ollama: this.config.model || 'llama4',
|
|
258
|
+
openrouter: this.config.model || process.env.OPENROUTER_MODEL || 'anthropic/claude-sonnet-5',
|
|
259
|
+
gemini: this.config.model || process.env.GEMINI_MODEL || 'gemini-3.5-flash',
|
|
253
260
|
minimax: this.config.model || process.env.MINIMAX_MODEL || 'MiniMax-M3',
|
|
254
261
|
// 2026-07-17: deepseek-chat (V3) 官方已下线, 迁 deepseek-v4-flash
|
|
255
262
|
deepseek: this.config.model || process.env.DEEPSEEK_MODEL || 'deepseek-v4-flash',
|
|
256
|
-
kimi: this.config.model || process.env.KIMI_MODEL || process.env.MOONSHOT_MODEL || '
|
|
257
|
-
glm: this.config.model || process.env.GLM_MODEL || process.env.ZHIPU_MODEL || 'glm-
|
|
258
|
-
qwen: this.config.model || process.env.QWEN_MODEL || process.env.DASHSCOPE_MODEL || '
|
|
263
|
+
kimi: this.config.model || process.env.KIMI_MODEL || process.env.MOONSHOT_MODEL || 'kimi-k3',
|
|
264
|
+
glm: this.config.model || process.env.GLM_MODEL || process.env.ZHIPU_MODEL || 'glm-5.2',
|
|
265
|
+
qwen: this.config.model || process.env.QWEN_MODEL || process.env.DASHSCOPE_MODEL || 'qwen3-max',
|
|
259
266
|
// 小米 MiMo (openai 兼容) — env override 优先, 默认 mimo-v2.5-pro
|
|
260
267
|
mimo: this.config.model || process.env.MIMO_MODEL || 'mimo-v2.5-pro',
|
|
261
|
-
|
|
268
|
+
grok: this.config.model || process.env.XAI_MODEL || 'grok-4.5',
|
|
269
|
+
local: this.config.model || 'llama4'
|
|
262
270
|
};
|
|
263
271
|
return modelMap[this.provider];
|
|
264
272
|
}
|
|
@@ -280,11 +288,17 @@ export class PiAIModel {
|
|
|
280
288
|
}
|
|
281
289
|
let lastFinishReason = '';
|
|
282
290
|
const _t0 = Date.now();
|
|
283
|
-
|
|
291
|
+
// 2026-08-04 (二修): 弃用全局 fetch — node 内置 fetch 的 keep-alive 连接池会积累"僵尸连接"
|
|
292
|
+
// (被对端关闭后仍留在池里), 后续请求复用即 "other side closed"; 且 node 内置 fetch
|
|
293
|
+
// 会静默忽略 npm undici Agent 的 dispatcher (实测 localPort 不变), 导致重试仍在复用坏连接.
|
|
294
|
+
// 改用 npm undici 的 request(): 独立连接池 + 重试传 dispatcher 真正生效 (新 TCP 连接).
|
|
295
|
+
let retryAgent = null;
|
|
296
|
+
for (let attempt = 0; attempt < 4; attempt++) {
|
|
284
297
|
const _tFetch = Date.now();
|
|
285
|
-
let
|
|
298
|
+
let statusCode = 0;
|
|
299
|
+
let body;
|
|
286
300
|
try {
|
|
287
|
-
|
|
301
|
+
const reqInit = {
|
|
288
302
|
method: 'POST',
|
|
289
303
|
headers: {
|
|
290
304
|
'Content-Type': 'application/json',
|
|
@@ -292,32 +306,41 @@ export class PiAIModel {
|
|
|
292
306
|
},
|
|
293
307
|
body: JSON.stringify(requestBody),
|
|
294
308
|
signal: this.combinedSignal(signal),
|
|
295
|
-
}
|
|
309
|
+
};
|
|
310
|
+
if (retryAgent)
|
|
311
|
+
reqInit.dispatcher = retryAgent;
|
|
312
|
+
const res = await request(`${this.getBaseUrl()}/chat/completions`, reqInit);
|
|
313
|
+
statusCode = res.statusCode;
|
|
314
|
+
body = res.body;
|
|
296
315
|
}
|
|
297
316
|
catch (err) {
|
|
298
|
-
//
|
|
299
|
-
// 退避重试最多
|
|
317
|
+
// 网络层瞬时错误 (undici "terminated" / "other side closed" / ECONNRESET / socket hang up / fetch failed 等)
|
|
318
|
+
// 退避重试最多 3 次 (1s/2s/4s), 每次用全新 Agent 新连接 — 之前直接抛给 chat()
|
|
319
|
+
// 变成 "[AI 服务调用失败] terminated" 打断 agent 流程.
|
|
300
320
|
// abort (用户主动 / 120s 超时) 不重试, 原样抛出.
|
|
301
321
|
if (err?.name === 'AbortError' || signal?.aborted)
|
|
302
322
|
throw err;
|
|
303
323
|
const netMsg = String(err?.message || err?.cause?.message || '');
|
|
304
|
-
const isNetworkErr = /terminated|ECONNRESET|socket hang up|fetch failed|network|ETIMEDOUT|ECONNREFUSED|UND_ERR/i.test(netMsg);
|
|
305
|
-
if (attempt <
|
|
306
|
-
const backoff =
|
|
307
|
-
console.warn(`[pi-ai] 网络错误 attempt ${attempt + 1}/
|
|
324
|
+
const isNetworkErr = /terminated|other side closed|ECONNRESET|socket hang up|fetch failed|network|ETIMEDOUT|ECONNREFUSED|UND_ERR/i.test(netMsg);
|
|
325
|
+
if (attempt < 3 && isNetworkErr) {
|
|
326
|
+
const backoff = 1000 * (2 ** attempt);
|
|
327
|
+
console.warn(`[pi-ai] 网络错误 attempt ${attempt + 1}/4: ${netMsg.slice(0, 120)}, 退避 ${backoff}ms 重试 (新连接)`);
|
|
328
|
+
retryAgent?.destroy().catch(() => { });
|
|
329
|
+
retryAgent = new Agent({ connect: { timeout: 30_000 } });
|
|
308
330
|
await new Promise(resolve => setTimeout(resolve, backoff));
|
|
309
331
|
continue;
|
|
310
332
|
}
|
|
311
333
|
throw err;
|
|
312
334
|
}
|
|
313
335
|
const _tResp = Date.now();
|
|
314
|
-
if (
|
|
315
|
-
const errBody = await
|
|
316
|
-
console.log(`[pi-ai DEBUG] OpenAI 错误 ${
|
|
336
|
+
if (statusCode < 200 || statusCode >= 300) {
|
|
337
|
+
const errBody = await body.text().catch(() => '(no body)');
|
|
338
|
+
console.log(`[pi-ai DEBUG] OpenAI 错误 ${statusCode}: ${String(errBody).slice(0, 500)}`);
|
|
317
339
|
console.log(`[pi-ai DEBUG] 请求体: model=${requestBody.model}, messages=${requestBody.messages?.length}, max_tokens=${requestBody.max_tokens}, baseUrl=${this.getBaseUrl()}`);
|
|
318
|
-
|
|
340
|
+
retryAgent?.destroy().catch(() => { });
|
|
341
|
+
throw new Error(`OpenAI API error: ${statusCode} ${String(errBody).slice(0, 300)}`);
|
|
319
342
|
}
|
|
320
|
-
const data = await
|
|
343
|
+
const data = await body.json();
|
|
321
344
|
const _tParse = Date.now();
|
|
322
345
|
const choice = data.choices?.[0];
|
|
323
346
|
const content = choice?.message?.content || '';
|
|
@@ -331,6 +354,7 @@ export class PiAIModel {
|
|
|
331
354
|
const _tAfter = Date.now();
|
|
332
355
|
const promptBytes = JSON.stringify(messages).length;
|
|
333
356
|
console.log(`[pi-ai timing] total=${_tAfter - _t0}ms attempt=${attempt + 1} fetch=${_tResp - _tFetch}ms parse=${_tParse - _tResp}ms reply=${content.length}B toolCalls=${toolCalls?.length ?? 0} model=${this.mapModel()} prompt=${promptBytes}B`);
|
|
357
|
+
retryAgent?.destroy().catch(() => { });
|
|
334
358
|
return { reply: content, toolCalls: toolCalls && toolCalls.length > 0 ? toolCalls : undefined };
|
|
335
359
|
}
|
|
336
360
|
console.warn(`[pi-ai] attempt ${attempt + 1}/3: 空 content (finish_reason=${lastFinishReason}), 退避 1.5s 重试`);
|
|
@@ -339,6 +363,7 @@ export class PiAIModel {
|
|
|
339
363
|
console.log(`[pi-ai timing] attempt=${attempt + 1} empty; backoff=${Date.now() - _tSleep}ms; total=${Date.now() - _t0}ms so far`);
|
|
340
364
|
}
|
|
341
365
|
console.warn(`[pi-ai] 3 次重试都返回空 content (finish_reason=${lastFinishReason})`);
|
|
366
|
+
retryAgent?.destroy().catch(() => { });
|
|
342
367
|
return { reply: '' };
|
|
343
368
|
}
|
|
344
369
|
async callAnthropic(messages, temperature, maxTokens, signal) {
|
|
@@ -599,24 +624,27 @@ function detectProvider() {
|
|
|
599
624
|
return 'qwen';
|
|
600
625
|
if (process.env.MIMO_API_KEY)
|
|
601
626
|
return 'mimo';
|
|
627
|
+
if (process.env.XAI_API_KEY)
|
|
628
|
+
return 'grok';
|
|
602
629
|
return 'openai';
|
|
603
630
|
}
|
|
604
631
|
function detectModel(provider) {
|
|
605
632
|
const defaults = {
|
|
606
|
-
openai: 'gpt-
|
|
607
|
-
anthropic: 'claude-sonnet-
|
|
608
|
-
ollama: '
|
|
609
|
-
openrouter: 'anthropic/claude-sonnet-
|
|
610
|
-
gemini: 'gemini-
|
|
633
|
+
openai: 'gpt-5.6',
|
|
634
|
+
anthropic: 'claude-sonnet-5',
|
|
635
|
+
ollama: 'llama4',
|
|
636
|
+
openrouter: 'anthropic/claude-sonnet-5',
|
|
637
|
+
gemini: 'gemini-3.5-flash',
|
|
611
638
|
minimax: 'MiniMax-M3',
|
|
612
639
|
// 2026-07-17: V3 官方下线, 迁 V4
|
|
613
640
|
deepseek: 'deepseek-v4-flash',
|
|
614
|
-
kimi: '
|
|
615
|
-
glm: 'glm-
|
|
616
|
-
qwen: '
|
|
641
|
+
kimi: 'kimi-k3',
|
|
642
|
+
glm: 'glm-5.2',
|
|
643
|
+
qwen: 'qwen3-max',
|
|
617
644
|
// 小米 MiMo 默认走最新旗舰版 (v2.5-Pro); 2026-06 当前公开版
|
|
618
645
|
mimo: 'mimo-v2.5-pro',
|
|
619
|
-
|
|
646
|
+
grok: 'grok-4.5',
|
|
647
|
+
local: 'llama4'
|
|
620
648
|
};
|
|
621
649
|
return defaults[provider];
|
|
622
650
|
}
|
|
@@ -56,6 +56,8 @@ const TOOL_WHITELIST = new Set([
|
|
|
56
56
|
'publish_did',
|
|
57
57
|
// 2026-08-04: IPFS/IPNS 通用查询 + 发布 (pi-sdk-tools.ts)
|
|
58
58
|
'ipfs_add', 'ipfs_cat', 'ipfs_ls', 'ipns_publish', 'ipns_resolve',
|
|
59
|
+
// 2026-08-04: Web 上网工具 (pi-sdk-tools.ts)
|
|
60
|
+
'fetch_url', 'web_search',
|
|
59
61
|
// 2026-08-02: 远端 channel 工具 (本地智能体 @ 远程交流)
|
|
60
62
|
'list_remote_channels', 'send_to_remote_channel',
|
|
61
63
|
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolloon/bolloon-agent",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.32",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "P2P AI Document Agent - 全局安装后执行 `bolloon` 启动产品",
|
|
6
6
|
"main": "dist/cli-entry.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "npm run build --workspaces --if-present",
|
|
29
|
-
"build:main": "tsc",
|
|
29
|
+
"build:main": "tsc && node scripts/copy-constraint-runtime.mjs",
|
|
30
30
|
"build:cli": "node scripts/build-cli.js",
|
|
31
31
|
"build:web": "npx tsx scripts/build-web.ts",
|
|
32
32
|
"build:electron": "tsc -p tsconfig.electron.json",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"@libp2p/upnp-nat": "^4.0.20",
|
|
69
69
|
"@multiformats/multiaddr": "^13.0.3",
|
|
70
70
|
"@noble/hashes": "^1.3.0",
|
|
71
|
+
"@polymarket/client": "^0.2.0",
|
|
71
72
|
"@rayhanadev/iroh": "^0.1.1",
|
|
72
73
|
"@x402/aptos": "^2.20.0",
|
|
73
74
|
"@x402/avm": "^2.20.0",
|