@bolloon/bolloon-agent 0.3.29 → 0.3.31
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/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/llm/config-store.js +39 -28
- package/dist/llm/pi-ai.js +83 -36
- package/dist/security/tool-gate.js +4 -18
- 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/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,25 +288,59 @@ 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
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
'
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
298
|
+
let statusCode = 0;
|
|
299
|
+
let body;
|
|
300
|
+
try {
|
|
301
|
+
const reqInit = {
|
|
302
|
+
method: 'POST',
|
|
303
|
+
headers: {
|
|
304
|
+
'Content-Type': 'application/json',
|
|
305
|
+
'Authorization': `Bearer ${apiKey}`
|
|
306
|
+
},
|
|
307
|
+
body: JSON.stringify(requestBody),
|
|
308
|
+
signal: this.combinedSignal(signal),
|
|
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;
|
|
315
|
+
}
|
|
316
|
+
catch (err) {
|
|
317
|
+
// 网络层瞬时错误 (undici "terminated" / "other side closed" / ECONNRESET / socket hang up / fetch failed 等)
|
|
318
|
+
// 退避重试最多 3 次 (1s/2s/4s), 每次用全新 Agent 新连接 — 之前直接抛给 chat()
|
|
319
|
+
// 变成 "[AI 服务调用失败] terminated" 打断 agent 流程.
|
|
320
|
+
// abort (用户主动 / 120s 超时) 不重试, 原样抛出.
|
|
321
|
+
if (err?.name === 'AbortError' || signal?.aborted)
|
|
322
|
+
throw err;
|
|
323
|
+
const netMsg = String(err?.message || err?.cause?.message || '');
|
|
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 } });
|
|
330
|
+
await new Promise(resolve => setTimeout(resolve, backoff));
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
throw err;
|
|
334
|
+
}
|
|
294
335
|
const _tResp = Date.now();
|
|
295
|
-
if (
|
|
296
|
-
const errBody = await
|
|
297
|
-
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)}`);
|
|
298
339
|
console.log(`[pi-ai DEBUG] 请求体: model=${requestBody.model}, messages=${requestBody.messages?.length}, max_tokens=${requestBody.max_tokens}, baseUrl=${this.getBaseUrl()}`);
|
|
299
|
-
|
|
340
|
+
retryAgent?.destroy().catch(() => { });
|
|
341
|
+
throw new Error(`OpenAI API error: ${statusCode} ${String(errBody).slice(0, 300)}`);
|
|
300
342
|
}
|
|
301
|
-
const data = await
|
|
343
|
+
const data = await body.json();
|
|
302
344
|
const _tParse = Date.now();
|
|
303
345
|
const choice = data.choices?.[0];
|
|
304
346
|
const content = choice?.message?.content || '';
|
|
@@ -312,6 +354,7 @@ export class PiAIModel {
|
|
|
312
354
|
const _tAfter = Date.now();
|
|
313
355
|
const promptBytes = JSON.stringify(messages).length;
|
|
314
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(() => { });
|
|
315
358
|
return { reply: content, toolCalls: toolCalls && toolCalls.length > 0 ? toolCalls : undefined };
|
|
316
359
|
}
|
|
317
360
|
console.warn(`[pi-ai] attempt ${attempt + 1}/3: 空 content (finish_reason=${lastFinishReason}), 退避 1.5s 重试`);
|
|
@@ -320,6 +363,7 @@ export class PiAIModel {
|
|
|
320
363
|
console.log(`[pi-ai timing] attempt=${attempt + 1} empty; backoff=${Date.now() - _tSleep}ms; total=${Date.now() - _t0}ms so far`);
|
|
321
364
|
}
|
|
322
365
|
console.warn(`[pi-ai] 3 次重试都返回空 content (finish_reason=${lastFinishReason})`);
|
|
366
|
+
retryAgent?.destroy().catch(() => { });
|
|
323
367
|
return { reply: '' };
|
|
324
368
|
}
|
|
325
369
|
async callAnthropic(messages, temperature, maxTokens, signal) {
|
|
@@ -580,24 +624,27 @@ function detectProvider() {
|
|
|
580
624
|
return 'qwen';
|
|
581
625
|
if (process.env.MIMO_API_KEY)
|
|
582
626
|
return 'mimo';
|
|
627
|
+
if (process.env.XAI_API_KEY)
|
|
628
|
+
return 'grok';
|
|
583
629
|
return 'openai';
|
|
584
630
|
}
|
|
585
631
|
function detectModel(provider) {
|
|
586
632
|
const defaults = {
|
|
587
|
-
openai: 'gpt-
|
|
588
|
-
anthropic: 'claude-sonnet-
|
|
589
|
-
ollama: '
|
|
590
|
-
openrouter: 'anthropic/claude-sonnet-
|
|
591
|
-
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',
|
|
592
638
|
minimax: 'MiniMax-M3',
|
|
593
639
|
// 2026-07-17: V3 官方下线, 迁 V4
|
|
594
640
|
deepseek: 'deepseek-v4-flash',
|
|
595
|
-
kimi: '
|
|
596
|
-
glm: 'glm-
|
|
597
|
-
qwen: '
|
|
641
|
+
kimi: 'kimi-k3',
|
|
642
|
+
glm: 'glm-5.2',
|
|
643
|
+
qwen: 'qwen3-max',
|
|
598
644
|
// 小米 MiMo 默认走最新旗舰版 (v2.5-Pro); 2026-06 当前公开版
|
|
599
645
|
mimo: 'mimo-v2.5-pro',
|
|
600
|
-
|
|
646
|
+
grok: 'grok-4.5',
|
|
647
|
+
local: 'llama4'
|
|
601
648
|
};
|
|
602
649
|
return defaults[provider];
|
|
603
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
|
]);
|
|
@@ -202,23 +204,7 @@ export function checkOutput(output) {
|
|
|
202
204
|
};
|
|
203
205
|
}
|
|
204
206
|
// ============================================================
|
|
205
|
-
// Gate 7:
|
|
206
|
-
// ============================================================
|
|
207
|
-
const MAX_TOOL_CALLS_PER_TURN = 5;
|
|
208
|
-
export function checkChain(ctx) {
|
|
209
|
-
const count = ctx.toolCallCountInTurn ?? 0;
|
|
210
|
-
if (count >= MAX_TOOL_CALLS_PER_TURN) {
|
|
211
|
-
return {
|
|
212
|
-
gate: 'chain',
|
|
213
|
-
allowed: false,
|
|
214
|
-
reason: `单轮已调 ${count} 个 tool (上限 ${MAX_TOOL_CALLS_PER_TURN})`,
|
|
215
|
-
evidence: `当前轮 tool 调用次数: ${count}`,
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
return { gate: 'chain', allowed: true };
|
|
219
|
-
}
|
|
220
|
-
// ============================================================
|
|
221
|
-
// Gate 8: 黑名单 (复用 PreToolUse hook 已有 6 条规则, 重新实现于此)
|
|
207
|
+
// Gate 7: 黑名单 (复用 PreToolUse hook 已有 6 条规则, 重新实现于此)
|
|
222
208
|
// ============================================================
|
|
223
209
|
const DANGEROUS_CMD_PATTERNS = [
|
|
224
210
|
{ re: /\brm\s+(-[a-z]*f[a-z]*\s+)?-[a-z]*r[a-z]*\s+\//, reason: '禁止递归删除根目录' },
|
|
@@ -245,7 +231,7 @@ const TOOL_GATES = [
|
|
|
245
231
|
checkChannel,
|
|
246
232
|
checkRate,
|
|
247
233
|
checkInject,
|
|
248
|
-
checkChain
|
|
234
|
+
// 2026-08-04: 移除 checkChain — 单轮 5 工具上限会打断 agent 长流程 (MCP 多步测试被反复拦), 用户要求去掉
|
|
249
235
|
checkBlacklist,
|
|
250
236
|
// checkOutput 不在 tool.execute 前
|
|
251
237
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolloon/bolloon-agent",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.31",
|
|
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",
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Polymarket CLOB 下单/查单/撤单 共享依赖
|
|
3
|
-
*
|
|
4
|
-
* 真实实现基于 @polymarket/clob-client (ClobClient):
|
|
5
|
-
* - 签名用 viem WalletClient (privateKeyToAccount + polygon + http transport)
|
|
6
|
-
* - 下单前需 ApiKeyCreds (key/secret/passphrase), 由 createOrDeriveApiKey() 从签名派生
|
|
7
|
-
* - tokenID / tickSize / negRisk 来自 Gamma 市场元数据 (https://gamma-api.polymarket.com/markets/:id)
|
|
8
|
-
*
|
|
9
|
-
* chainId = 137 (Polygon), host = https://clob.polymarket.com
|
|
10
|
-
*/
|
|
11
|
-
import { ClobClient, OrderType, Side } from '@polymarket/clob-client';
|
|
12
|
-
import { createWalletClient, http } from 'viem';
|
|
13
|
-
import { privateKeyToAccount } from 'viem/accounts';
|
|
14
|
-
import { polygon } from 'viem/chains';
|
|
15
|
-
export const CLOB_HOST = 'https://clob.polymarket.com';
|
|
16
|
-
export const CHAIN_ID = 137;
|
|
17
|
-
export function normalizePrivateKey(pk) {
|
|
18
|
-
const s = pk.startsWith('0x') ? pk : `0x${pk}`;
|
|
19
|
-
return s;
|
|
20
|
-
}
|
|
21
|
-
function safeParseArray(v) {
|
|
22
|
-
if (Array.isArray(v))
|
|
23
|
-
return v;
|
|
24
|
-
if (typeof v === 'string') {
|
|
25
|
-
try {
|
|
26
|
-
const parsed = JSON.parse(v);
|
|
27
|
-
return Array.isArray(parsed) ? parsed : [];
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* 从 Gamma 取市场元数据: clobTokenIds / outcomes / tickSize / negRisk.
|
|
37
|
-
* 优先用 Gamma 路径端点 (带 tickSize/negRisk), 失败回退 polymarket-sdk listMarkets({id}).
|
|
38
|
-
*/
|
|
39
|
-
export async function fetchMarketMeta(marketId) {
|
|
40
|
-
try {
|
|
41
|
-
const res = await fetch(`https://gamma-api.polymarket.com/markets/${encodeURIComponent(marketId)}`);
|
|
42
|
-
if (res.ok) {
|
|
43
|
-
const m = await res.json();
|
|
44
|
-
return {
|
|
45
|
-
clobTokenIds: safeParseArray(m.clobTokenIds),
|
|
46
|
-
outcomes: safeParseArray(m.outcomes),
|
|
47
|
-
tickSize: typeof m.tickSize === 'string' ? m.tickSize : '0.01',
|
|
48
|
-
negRisk: !!m.negRisk,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
// fall through to sdk
|
|
54
|
-
}
|
|
55
|
-
const { listMarkets } = await import('polymarket-sdk').catch(() => ({ listMarkets: async () => [] }));
|
|
56
|
-
const ms = await listMarkets({ id: marketId });
|
|
57
|
-
const m = ms?.[0];
|
|
58
|
-
if (!m)
|
|
59
|
-
throw new Error(`未找到市场: ${marketId}`);
|
|
60
|
-
return {
|
|
61
|
-
clobTokenIds: safeParseArray(m.clobTokenIds),
|
|
62
|
-
outcomes: safeParseArray(m.outcomes),
|
|
63
|
-
tickSize: '0.01',
|
|
64
|
-
negRisk: false,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* 由 outcome (如 "Yes"/"No" 或索引 0/1) 或显式 tokenId 解析出要交易的 tokenID.
|
|
69
|
-
* 都不给 → 默认取第一个 clobTokenId (通常是 "Yes").
|
|
70
|
-
*/
|
|
71
|
-
export function resolveTokenId(meta, tokenId, outcome) {
|
|
72
|
-
if (tokenId)
|
|
73
|
-
return tokenId;
|
|
74
|
-
if (!meta.clobTokenIds || meta.clobTokenIds.length === 0)
|
|
75
|
-
return undefined;
|
|
76
|
-
if (outcome === undefined || outcome === null)
|
|
77
|
-
return meta.clobTokenIds[0];
|
|
78
|
-
if (typeof outcome === 'number')
|
|
79
|
-
return meta.clobTokenIds[outcome];
|
|
80
|
-
const idx = meta.outcomes.findIndex((o) => String(o).toLowerCase() === String(outcome).toLowerCase());
|
|
81
|
-
return idx >= 0 ? meta.clobTokenIds[idx] : undefined;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* 构造已鉴权的 ClobClient.
|
|
85
|
-
* - 若提供完整 apiKey/apiSecret/apiPassphrase → 直接用
|
|
86
|
-
* - 否则用签名派生 ApiKey (createOrDeriveApiKey, 需联网)
|
|
87
|
-
* signatureType = 0 (EOA / 浏览器钱包, 对应原始私钥签名)
|
|
88
|
-
*/
|
|
89
|
-
export async function buildClobClient(params) {
|
|
90
|
-
const account = privateKeyToAccount(normalizePrivateKey(params.privateKey));
|
|
91
|
-
const signer = createWalletClient({ account, chain: polygon, transport: http() });
|
|
92
|
-
const address = account.address;
|
|
93
|
-
let creds;
|
|
94
|
-
if (params.creds?.apiKey && params.creds?.apiSecret && params.creds?.apiPassphrase) {
|
|
95
|
-
creds = { key: params.creds.apiKey, secret: params.creds.apiSecret, passphrase: params.creds.apiPassphrase };
|
|
96
|
-
}
|
|
97
|
-
if (!creds) {
|
|
98
|
-
const tmp = new ClobClient(CLOB_HOST, CHAIN_ID, signer);
|
|
99
|
-
creds = await tmp.createOrDeriveApiKey();
|
|
100
|
-
}
|
|
101
|
-
const client = new ClobClient(CLOB_HOST, CHAIN_ID, signer, creds, 0, params.funder ?? address);
|
|
102
|
-
return { client, address };
|
|
103
|
-
}
|
|
104
|
-
export { OrderType, Side };
|