@poolzin/pool-bot 2026.3.25 → 2026.3.27
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/model-fallback.js +5 -4
- package/dist/agents/tools/common.js +16 -201
- package/dist/auto-reply/auto-reply/reply/agent-runner-execution.js +502 -0
- package/dist/auto-reply/auto-reply/reply/agent-runner-helpers.js +65 -0
- package/dist/auto-reply/auto-reply/reply/agent-runner-memory.js +160 -0
- package/dist/auto-reply/auto-reply/reply/agent-runner-payloads.js +85 -0
- package/dist/auto-reply/auto-reply/reply/agent-runner-utils.js +101 -0
- package/dist/auto-reply/auto-reply/reply/bash-command.js +338 -0
- package/dist/auto-reply/auto-reply/reply/block-streaming.js +91 -0
- package/dist/auto-reply/auto-reply/reply/commands-approve.js +88 -0
- package/dist/auto-reply/auto-reply/reply/commands-bash.js +26 -0
- package/dist/auto-reply/auto-reply/reply/commands-compact.js +107 -0
- package/dist/auto-reply/auto-reply/reply/commands-config.js +241 -0
- package/dist/auto-reply/auto-reply/reply/commands-context-report.js +295 -0
- package/dist/auto-reply/auto-reply/reply/commands-context.js +30 -0
- package/dist/auto-reply/auto-reply/reply/commands-core.js +151 -0
- package/dist/auto-reply/auto-reply/reply/commands-export-session.js +163 -0
- package/dist/auto-reply/auto-reply/reply/commands-info.js +184 -0
- package/dist/auto-reply/auto-reply/reply/commands-models.js +299 -0
- package/dist/auto-reply/auto-reply/reply/commands-plugin.js +35 -0
- package/dist/auto-reply/auto-reply/reply/commands-ptt.js +171 -0
- package/dist/auto-reply/auto-reply/reply/commands-setunset-standard.js +13 -0
- package/dist/auto-reply/auto-reply/reply/commands-setunset.js +73 -0
- package/dist/auto-reply/auto-reply/reply/commands-slash-parse.js +31 -0
- package/dist/auto-reply/auto-reply/reply/commands-status.js +178 -0
- package/dist/auto-reply/auto-reply/reply/commands-subagents.js +73 -0
- package/dist/auto-reply/auto-reply/reply/commands-system-prompt.js +117 -0
- package/dist/auto-reply/auto-reply/reply/commands-tts.js +231 -0
- package/dist/auto-reply/auto-reply/reply/directive-handling.impl.js +380 -0
- package/dist/auto-reply/auto-reply/reply/followup-runner.js +227 -0
- package/dist/auto-reply/auto-reply/reply/get-reply-directives-apply.js +201 -0
- package/dist/auto-reply/auto-reply/reply/get-reply-directives-utils.js +54 -0
- package/dist/auto-reply/auto-reply/reply/get-reply-directives.js +332 -0
- package/dist/auto-reply/auto-reply/reply/get-reply-inline-actions.js +258 -0
- package/dist/auto-reply/auto-reply/reply/get-reply-run.js +297 -0
- package/dist/auto-reply/auto-reply/reply/groups.js +102 -0
- package/dist/auto-reply/auto-reply/reply/mentions.js +129 -0
- package/dist/auto-reply/auto-reply/reply/reply-delivery.js +92 -0
- package/dist/auto-reply/auto-reply/reply/reply-directives.js +30 -0
- package/dist/auto-reply/auto-reply/reply/reply-dispatcher.js +152 -0
- package/dist/auto-reply/auto-reply/reply/reply-elevated.js +166 -0
- package/dist/auto-reply/auto-reply/reply/reply-inline.js +28 -0
- package/dist/auto-reply/auto-reply/reply/reply-payloads.js +114 -0
- package/dist/auto-reply/auto-reply/reply/reply-reference.js +36 -0
- package/dist/auto-reply/auto-reply/reply/reply-tags.js +13 -0
- package/dist/auto-reply/auto-reply/reply/reply-threading.js +41 -0
- package/dist/auto-reply/auto-reply/reply/session-updates.js +233 -0
- package/dist/auto-reply/auto-reply/reply/stage-sandbox-media.js +146 -0
- package/dist/build-info.json +3 -3
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/canvas-host/a2ui/a2ui.bundle.js +2 -17772
- package/dist/canvas-host/a2ui/index.html +1 -307
- package/dist/channels/channels/directory-config.js +185 -0
- package/dist/channels/channels/discord/handle-action.guild-admin.js +332 -0
- package/dist/channels/channels/discord/handle-action.js +165 -0
- package/dist/channels/channels/discord.js +413 -0
- package/dist/channels/channels/dock.js +436 -0
- package/dist/channels/channels/index.js +51 -0
- package/dist/channels/channels/plugins/outbound/discord.js +101 -0
- package/dist/channels/channels/whatsapp.js +17 -0
- package/dist/channels/plugins/types.js +1 -1
- package/dist/channels/run-state-machine.js +7 -0
- package/dist/commands/models/auth.js +47 -1
- package/dist/commands-subagents/action-agents.js +44 -0
- package/dist/commands-subagents/action-focus.js +64 -0
- package/dist/commands-subagents/action-help.js +4 -0
- package/dist/commands-subagents/action-info.js +45 -0
- package/dist/commands-subagents/action-kill.js +60 -0
- package/dist/commands-subagents/action-list.js +44 -0
- package/dist/commands-subagents/action-log.js +29 -0
- package/dist/commands-subagents/action-send.js +119 -0
- package/dist/commands-subagents/action-spawn.js +52 -0
- package/dist/commands-subagents/action-unfocus.js +30 -0
- package/dist/commands-subagents/shared.js +303 -0
- package/dist/config/config.js +1 -8
- package/dist/config/types.secrets.js +61 -0
- package/dist/control-ui/assets/{index-D7shnQwQ.js → index-umCsvrWy.js} +884 -741
- package/dist/control-ui/assets/index-umCsvrWy.js.map +1 -0
- package/dist/control-ui/assets/pt-BR-DedEVAvY.js +2 -0
- package/dist/control-ui/assets/pt-BR-DedEVAvY.js.map +1 -0
- package/dist/control-ui/assets/zh-CN-CDzeklK-.js +2 -0
- package/dist/control-ui/assets/zh-CN-CDzeklK-.js.map +1 -0
- package/dist/control-ui/assets/zh-TW-BJCRYNWH.js +2 -0
- package/dist/control-ui/assets/zh-TW-BJCRYNWH.js.map +1 -0
- package/dist/control-ui/index.html +1 -1
- package/dist/gateway/method-scopes.js +9 -1
- package/dist/gateway/node-pending-work.js +142 -0
- package/dist/gateway/protocol/index.js +5 -1
- package/dist/gateway/protocol/schema/nodes.js +18 -0
- package/dist/gateway/server-methods/nodes-pending.js +96 -0
- package/dist/gateway/server-methods-list.js +4 -0
- package/dist/gateway/server-methods.js +2 -0
- package/dist/imessage/channel.js +253 -0
- package/dist/imessage/monitor/echo-cache.js +70 -0
- package/dist/imessage/monitor/loop-rate-limiter.js +51 -0
- package/dist/imessage/monitor/reflection-guard.js +50 -0
- package/dist/imessage/monitor/sanitize-outbound.js +25 -0
- package/dist/imessage/monitor/self-chat-cache.js +75 -0
- package/dist/imessage/runtime.js +3 -0
- package/dist/infra/exec-approval-reply.js +7 -0
- package/dist/infra/tmp-openclaw-dir.js +84 -0
- package/dist/pairing/pairing-challenge.js +15 -0
- package/dist/plugin-sdk/account-id.d.ts +1 -0
- package/dist/plugin-sdk/agent-media-payload.d.ts +12 -0
- package/dist/plugin-sdk/allow-from.d.ts +27 -0
- package/dist/plugin-sdk/command-auth.d.ts +25 -0
- package/dist/plugin-sdk/command-auth.js +3 -1
- package/dist/plugin-sdk/config-paths.d.ts +6 -0
- package/dist/plugin-sdk/file-lock.d.ts +16 -0
- package/dist/plugin-sdk/index.d.ts +428 -0
- package/dist/plugin-sdk/index.js +237 -103
- package/dist/plugin-sdk/json-store.d.ts +5 -0
- package/dist/plugin-sdk/keyed-async-queue.d.ts +12 -0
- package/dist/plugin-sdk/onboarding.d.ts +11 -0
- package/dist/plugin-sdk/provider-auth-result.d.ts +14 -0
- package/dist/plugin-sdk/slack-message-actions.d.ts +11 -0
- package/dist/plugin-sdk/status-helpers.d.ts +25 -0
- package/dist/plugin-sdk/temp-path.d.ts +12 -0
- package/dist/plugin-sdk/text-chunking.d.ts +1 -0
- package/dist/plugin-sdk/tool-send.d.ts +4 -0
- package/dist/plugin-sdk/webhook-path.d.ts +6 -0
- package/dist/plugin-sdk/webhook-targets.d.ts +23 -0
- package/dist/plugin-sdk/windows-spawn.d.ts +39 -0
- package/dist/plugin-sdk-internal/accounts.js +6 -0
- package/dist/plugin-sdk-internal/discord.js +23 -0
- package/dist/plugin-sdk-internal/imessage.js +13 -0
- package/dist/plugin-sdk-internal/setup.js +9 -0
- package/dist/plugin-sdk-internal/signal.js +13 -0
- package/dist/plugin-sdk-internal/slack.js +22 -0
- package/dist/plugin-sdk-internal/telegram.js +32 -0
- package/dist/plugin-sdk-internal/whatsapp.js +29 -0
- package/dist/routing/session-key.js +4 -185
- package/dist/shared/pid-alive.js +2 -61
- package/dist/shared/process-scoped-map.js +5 -7
- package/dist/signal/channel.js +264 -0
- package/dist/signal/monitor/access-policy.js +60 -0
- package/dist/signal/runtime.js +3 -0
- package/dist/slack/account-inspect.js +135 -0
- package/dist/slack/blocks-input.js +7 -38
- package/dist/slack/channel.js +394 -0
- package/dist/slack/interactive-replies.js +28 -0
- package/dist/slack/monitor/channel-type.js +31 -0
- package/dist/slack/monitor/dm-auth.js +49 -0
- package/dist/slack/monitor/events/interactions.modal.js +137 -0
- package/dist/slack/monitor/events/message-subtype-handlers.js +68 -0
- package/dist/slack/monitor/events/system-event-context.js +29 -0
- package/dist/slack/monitor/events/system-event-test-harness.js +41 -0
- package/dist/slack/monitor/external-arg-menu-store.js +46 -0
- package/dist/slack/monitor/message-handler/prepare-content.js +69 -0
- package/dist/slack/monitor/message-handler/prepare-thread-context.js +91 -0
- package/dist/slack/monitor/message-handler/prepare.test-helpers.js +55 -0
- package/dist/slack/monitor/reconnect-policy.js +78 -0
- package/dist/slack/monitor/slash-commands.runtime.js +1 -0
- package/dist/slack/monitor/slash-dispatch.runtime.js +9 -0
- package/dist/slack/monitor/slash-skill-commands.runtime.js +1 -0
- package/dist/slack/resolve-allowlist-common.js +36 -0
- package/dist/slack/runtime.js +3 -0
- package/dist/slack/sent-thread-cache.js +61 -0
- package/dist/slack/truncate.js +10 -0
- package/dist/telegram/account-inspect.js +175 -0
- package/dist/telegram/allow-from.js +10 -0
- package/dist/telegram/api-fetch.js +18 -0
- package/dist/telegram/approval-buttons.js +30 -0
- package/dist/telegram/audit-membership-runtime.js +61 -0
- package/dist/telegram/bot/delivery.replies.js +508 -0
- package/dist/telegram/bot/delivery.resolve-media.js +227 -0
- package/dist/telegram/bot/delivery.send.js +132 -0
- package/dist/telegram/bot/reply-threading.js +46 -0
- package/dist/telegram/bot-message-context.body.js +186 -0
- package/dist/telegram/bot-message-context.session.js +207 -0
- package/dist/telegram/bot-message-context.types.js +1 -0
- package/dist/telegram/bot-native-commands.test-helpers.js +117 -0
- package/dist/telegram/bot.media.e2e-harness.js +81 -0
- package/dist/telegram/bot.media.test-utils.js +81 -0
- package/dist/telegram/channel-actions.js +225 -0
- package/dist/telegram/channel.js +515 -0
- package/dist/telegram/conversation-route.js +107 -0
- package/dist/telegram/delivery.js +2 -0
- package/dist/telegram/delivery.replies.js +508 -0
- package/dist/telegram/dm-access.js +86 -0
- package/dist/telegram/draft-stream.test-helpers.js +62 -0
- package/dist/telegram/exec-approvals-handler.js +281 -0
- package/dist/telegram/exec-approvals.js +62 -0
- package/dist/telegram/forum-service-message.js +22 -0
- package/dist/telegram/group-config-helpers.js +10 -0
- package/dist/telegram/lane-delivery-state.js +19 -0
- package/dist/telegram/lane-delivery-text-deliverer.js +357 -0
- package/dist/telegram/lane-delivery.js +2 -0
- package/dist/telegram/normalize.js +37 -0
- package/dist/telegram/onboarding.js +192 -0
- package/dist/telegram/outbound-adapter.js +100 -0
- package/dist/telegram/polling-session.js +275 -0
- package/dist/telegram/runtime.js +3 -0
- package/dist/telegram/sendchataction-401-backoff.js +71 -0
- package/dist/telegram/sequential-key.js +46 -0
- package/dist/telegram/status-issues.js +105 -0
- package/dist/telegram/target-writeback.js +165 -0
- package/dist/telegram/thread-bindings.js +560 -0
- package/dist/utils.js +32 -257
- package/dist/wizard/prompts.js +5 -5
- package/extensions/feishu/src/policy.ts +1 -1
- package/extensions/firecrawl/index.test.ts +82 -0
- package/extensions/firecrawl/index.ts +20 -0
- package/extensions/firecrawl/openclaw.plugin.json +8 -0
- package/extensions/firecrawl/package.json +12 -0
- package/extensions/firecrawl/src/config.ts +159 -0
- package/extensions/firecrawl/src/firecrawl-client.ts +446 -0
- package/extensions/firecrawl/src/firecrawl-scrape-tool.ts +89 -0
- package/extensions/firecrawl/src/firecrawl-search-provider.ts +63 -0
- package/extensions/firecrawl/src/firecrawl-search-tool.ts +76 -0
- package/package.json +1 -1
- package/dist/.buildstamp +0 -1
- package/dist/acp/bindings-store.js +0 -209
- package/dist/acp/control-plane/runtime-cache.js +0 -54
- package/dist/acp/control-plane/runtime-options.js +0 -215
- package/dist/acp/control-plane/session-actor-queue.js +0 -36
- package/dist/acp/index.js +0 -2
- package/dist/acp/runtime/errors.js +0 -47
- package/dist/acp/runtime/registry.js +0 -86
- package/dist/acp/secret-file.js +0 -22
- package/dist/agents/auth-profiles.resolve-auth-profile-order.fixtures.js +0 -23
- package/dist/agents/bash-process-registry.test-helpers.js +0 -29
- package/dist/agents/bash-tools.exec-approval-request.js +0 -20
- package/dist/agents/bash-tools.exec-host-gateway.js +0 -240
- package/dist/agents/bash-tools.exec-host-node.js +0 -235
- package/dist/agents/checkpoint-manager.js +0 -290
- package/dist/agents/claude-cli-runner.js +0 -3
- package/dist/agents/error-classifier.js +0 -251
- package/dist/agents/live-model-filter.js +0 -84
- package/dist/agents/nvidia-models.js +0 -228
- package/dist/agents/pi-embedded-runner/run.overflow-compaction.fixture.js +0 -34
- package/dist/agents/pi-embedded-runner/run.overflow-compaction.mocks.shared.js +0 -156
- package/dist/agents/pi-embedded-subscribe.handlers.tools.media.test-helpers.js +0 -30
- package/dist/agents/provider/config-loader.js +0 -76
- package/dist/agents/provider/index.js +0 -15
- package/dist/agents/provider/models-dev.js +0 -129
- package/dist/agents/provider/session-binding.js +0 -376
- package/dist/agents/queued-file-writer.js +0 -22
- package/dist/agents/skills/bundled-context.js +0 -23
- package/dist/agents/skills/security.js +0 -211
- package/dist/agents/skills/tools-dir.js +0 -9
- package/dist/agents/skills-install-download.js +0 -290
- package/dist/agents/skills-install-output.js +0 -30
- package/dist/agents/skills-install.download-test-utils.js +0 -36
- package/dist/agents/skills.test-helpers.js +0 -13
- package/dist/agents/subagent-announce-reliability.js +0 -160
- package/dist/agents/subagent-registry.mocks.shared.js +0 -12
- package/dist/agents/test-helpers/assistant-message-fixtures.js +0 -29
- package/dist/agents/test-helpers/fast-coding-tools.js +0 -1
- package/dist/agents/test-helpers/fast-core-tools.js +0 -8
- package/dist/agents/test-helpers/fast-tool-stubs.js +0 -18
- package/dist/agents/test-helpers/host-sandbox-fs-bridge.js +0 -74
- package/dist/agents/test-helpers/pi-tools-sandbox-context.js +0 -27
- package/dist/agents/tool-display-common.js +0 -915
- package/dist/agents/tool-policy-shared.js +0 -108
- package/dist/agents/tool-policy.conformance.js +0 -14
- package/dist/agents/tool-result-truncation.js +0 -299
- package/dist/agents/tools/cron-tool.test-helpers.js +0 -12
- package/dist/agents/tools/discord-actions-moderation-shared.js +0 -27
- package/dist/agents/tools/discord-actions-presence.js +0 -78
- package/dist/control-ui/assets/index-D7shnQwQ.js.map +0 -1
- package/dist/discord/discord-improvements.js +0 -167
- package/dist/discord/index.js +0 -2
- package/dist/hooks/bundled/boot-md/HOOK.md +0 -19
- package/dist/hooks/bundled/command-logger/HOOK.md +0 -122
- package/dist/hooks/bundled/session-memory/HOOK.md +0 -86
- package/dist/hooks/bundled/soul-evil/HOOK.md +0 -71
- package/dist/whatsapp/normalize.js +0 -66
- package/dist/whatsapp/resolve-outbound-target.js +0 -42
- /package/dist/{acp/runtime/types.js → auto-reply/auto-reply/reply/commands-types.js} +0 -0
- /package/dist/{agents/pi-embedded-payloads.js → slack/account-surface-fields.js} +0 -0
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
export const NVIDIA_BASE_URL = "https://integrate.api.nvidia.com/v1";
|
|
2
|
-
export const NVIDIA_DEFAULT_MODEL_ID = "llama-3.1-nemotron-ultra-253b-v1";
|
|
3
|
-
// NVIDIA free-tier models have no per-token cost.
|
|
4
|
-
export const NVIDIA_DEFAULT_COST = {
|
|
5
|
-
input: 0,
|
|
6
|
-
output: 0,
|
|
7
|
-
cacheRead: 0,
|
|
8
|
-
cacheWrite: 0,
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Static catalog of popular NVIDIA NIM free-tier models.
|
|
12
|
-
*
|
|
13
|
-
* NVIDIA's `integrate.api.nvidia.com` hosts 50+ models via OpenAI-compatible
|
|
14
|
-
* `/v1/chat/completions`. This catalog acts as a fallback when the `/v1/models`
|
|
15
|
-
* endpoint is unreachable or the API key isn't valid for discovery.
|
|
16
|
-
*
|
|
17
|
-
* Model IDs match what NVIDIA's API returns — some use `org/model` format,
|
|
18
|
-
* others use bare IDs.
|
|
19
|
-
*/
|
|
20
|
-
export const NVIDIA_MODEL_CATALOG = [
|
|
21
|
-
// ── Flagship ──────────────────────────────────────────
|
|
22
|
-
{
|
|
23
|
-
id: "llama-3.1-nemotron-ultra-253b-v1",
|
|
24
|
-
name: "Nemotron Ultra 253B",
|
|
25
|
-
reasoning: true,
|
|
26
|
-
input: ["text"],
|
|
27
|
-
contextWindow: 131072,
|
|
28
|
-
maxTokens: 8192,
|
|
29
|
-
},
|
|
30
|
-
// ── Meta Llama ────────────────────────────────────────
|
|
31
|
-
{
|
|
32
|
-
id: "meta/llama-3.3-70b-instruct",
|
|
33
|
-
name: "Llama 3.3 70B Instruct",
|
|
34
|
-
reasoning: false,
|
|
35
|
-
input: ["text"],
|
|
36
|
-
contextWindow: 131072,
|
|
37
|
-
maxTokens: 8192,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
id: "meta/llama-3.1-405b-instruct",
|
|
41
|
-
name: "Llama 3.1 405B Instruct",
|
|
42
|
-
reasoning: false,
|
|
43
|
-
input: ["text"],
|
|
44
|
-
contextWindow: 131072,
|
|
45
|
-
maxTokens: 4096,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
id: "meta/llama-3.1-8b-instruct",
|
|
49
|
-
name: "Llama 3.1 8B Instruct",
|
|
50
|
-
reasoning: false,
|
|
51
|
-
input: ["text"],
|
|
52
|
-
contextWindow: 131072,
|
|
53
|
-
maxTokens: 8192,
|
|
54
|
-
},
|
|
55
|
-
// ── DeepSeek ──────────────────────────────────────────
|
|
56
|
-
{
|
|
57
|
-
id: "deepseek-ai/deepseek-r1",
|
|
58
|
-
name: "DeepSeek R1",
|
|
59
|
-
reasoning: true,
|
|
60
|
-
input: ["text"],
|
|
61
|
-
contextWindow: 65536,
|
|
62
|
-
maxTokens: 8192,
|
|
63
|
-
},
|
|
64
|
-
// ── Mistral ───────────────────────────────────────────
|
|
65
|
-
{
|
|
66
|
-
id: "mistralai/mistral-large-2-instruct",
|
|
67
|
-
name: "Mistral Large 2 Instruct",
|
|
68
|
-
reasoning: false,
|
|
69
|
-
input: ["text"],
|
|
70
|
-
contextWindow: 131072,
|
|
71
|
-
maxTokens: 8192,
|
|
72
|
-
},
|
|
73
|
-
// ── Qwen ──────────────────────────────────────────────
|
|
74
|
-
{
|
|
75
|
-
id: "qwen/qwen2.5-72b-instruct",
|
|
76
|
-
name: "Qwen 2.5 72B Instruct",
|
|
77
|
-
reasoning: false,
|
|
78
|
-
input: ["text"],
|
|
79
|
-
contextWindow: 131072,
|
|
80
|
-
maxTokens: 8192,
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
id: "qwen/qwq-32b",
|
|
84
|
-
name: "QwQ 32B",
|
|
85
|
-
reasoning: true,
|
|
86
|
-
input: ["text"],
|
|
87
|
-
contextWindow: 131072,
|
|
88
|
-
maxTokens: 8192,
|
|
89
|
-
},
|
|
90
|
-
// ── Vision models ─────────────────────────────────────
|
|
91
|
-
{
|
|
92
|
-
id: "microsoft/phi-3.5-vision-instruct",
|
|
93
|
-
name: "Phi 3.5 Vision Instruct",
|
|
94
|
-
reasoning: false,
|
|
95
|
-
input: ["text", "image"],
|
|
96
|
-
contextWindow: 131072,
|
|
97
|
-
maxTokens: 4096,
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
id: "nvidia/llama-3.2-nv-vision-instruct-v1",
|
|
101
|
-
name: "Llama 3.2 NV Vision Instruct",
|
|
102
|
-
reasoning: false,
|
|
103
|
-
input: ["text", "image"],
|
|
104
|
-
contextWindow: 131072,
|
|
105
|
-
maxTokens: 4096,
|
|
106
|
-
},
|
|
107
|
-
// ── Code ──────────────────────────────────────────────
|
|
108
|
-
{
|
|
109
|
-
id: "nvidia/llama-3.1-nemotron-70b-instruct",
|
|
110
|
-
name: "Nemotron 70B Instruct",
|
|
111
|
-
reasoning: false,
|
|
112
|
-
input: ["text"],
|
|
113
|
-
contextWindow: 131072,
|
|
114
|
-
maxTokens: 8192,
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
id: "ibm/granite-3.1-8b-instruct",
|
|
118
|
-
name: "Granite 3.1 8B Instruct",
|
|
119
|
-
reasoning: false,
|
|
120
|
-
input: ["text"],
|
|
121
|
-
contextWindow: 131072,
|
|
122
|
-
maxTokens: 8192,
|
|
123
|
-
},
|
|
124
|
-
];
|
|
125
|
-
/**
|
|
126
|
-
* Build a ModelDefinitionConfig from a static catalog entry.
|
|
127
|
-
*/
|
|
128
|
-
export function buildNvidiaModelDefinition(entry) {
|
|
129
|
-
return {
|
|
130
|
-
id: entry.id,
|
|
131
|
-
name: entry.name,
|
|
132
|
-
reasoning: entry.reasoning,
|
|
133
|
-
input: [...entry.input],
|
|
134
|
-
cost: NVIDIA_DEFAULT_COST,
|
|
135
|
-
contextWindow: entry.contextWindow,
|
|
136
|
-
maxTokens: entry.maxTokens,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
// Model IDs known to be embedding/reranking/image-gen — not chat-compatible.
|
|
140
|
-
const NON_CHAT_PATTERNS = [
|
|
141
|
-
"embed",
|
|
142
|
-
"rerank",
|
|
143
|
-
"nv-rerankqa",
|
|
144
|
-
"sdxl",
|
|
145
|
-
"stable-diffusion",
|
|
146
|
-
"consistory",
|
|
147
|
-
"shutterstock",
|
|
148
|
-
"image",
|
|
149
|
-
"usearch",
|
|
150
|
-
"parakeet",
|
|
151
|
-
"canary",
|
|
152
|
-
"whisper",
|
|
153
|
-
"speech",
|
|
154
|
-
"audio",
|
|
155
|
-
"tts",
|
|
156
|
-
"asr",
|
|
157
|
-
];
|
|
158
|
-
function isLikelyChatModel(id) {
|
|
159
|
-
const lower = id.toLowerCase();
|
|
160
|
-
return !NON_CHAT_PATTERNS.some((p) => lower.includes(p));
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Discover models from NVIDIA's OpenAI-compatible `/v1/models` endpoint.
|
|
164
|
-
*
|
|
165
|
-
* Requires a valid API key (unlike Venice which is public).
|
|
166
|
-
* Falls back to the static catalog on any failure.
|
|
167
|
-
*/
|
|
168
|
-
export async function discoverNvidiaModels(apiKey) {
|
|
169
|
-
// Skip API discovery in test environments
|
|
170
|
-
if (process.env.NODE_ENV === "test" || process.env.VITEST) {
|
|
171
|
-
return NVIDIA_MODEL_CATALOG.map(buildNvidiaModelDefinition);
|
|
172
|
-
}
|
|
173
|
-
try {
|
|
174
|
-
const response = await fetch(`${NVIDIA_BASE_URL}/models`, {
|
|
175
|
-
headers: { Authorization: `Bearer ${apiKey}` },
|
|
176
|
-
signal: AbortSignal.timeout(5000),
|
|
177
|
-
});
|
|
178
|
-
if (!response.ok) {
|
|
179
|
-
console.warn(`[nvidia-models] Discovery failed: HTTP ${response.status}, using static catalog`);
|
|
180
|
-
return NVIDIA_MODEL_CATALOG.map(buildNvidiaModelDefinition);
|
|
181
|
-
}
|
|
182
|
-
const data = (await response.json());
|
|
183
|
-
if (!Array.isArray(data.data) || data.data.length === 0) {
|
|
184
|
-
console.warn("[nvidia-models] No models returned from API, using static catalog");
|
|
185
|
-
return NVIDIA_MODEL_CATALOG.map(buildNvidiaModelDefinition);
|
|
186
|
-
}
|
|
187
|
-
// Build lookup from static catalog for enrichment
|
|
188
|
-
const catalogById = new Map(NVIDIA_MODEL_CATALOG.map((m) => [m.id, m]));
|
|
189
|
-
const models = [];
|
|
190
|
-
for (const apiModel of data.data) {
|
|
191
|
-
if (!isLikelyChatModel(apiModel.id))
|
|
192
|
-
continue;
|
|
193
|
-
const catalogEntry = catalogById.get(apiModel.id);
|
|
194
|
-
if (catalogEntry) {
|
|
195
|
-
// Use curated metadata for known models
|
|
196
|
-
models.push(buildNvidiaModelDefinition(catalogEntry));
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
// Create a best-effort definition for newly discovered models
|
|
200
|
-
const lower = apiModel.id.toLowerCase();
|
|
201
|
-
const isReasoning = lower.includes("r1") ||
|
|
202
|
-
lower.includes("reasoning") ||
|
|
203
|
-
lower.includes("thinking") ||
|
|
204
|
-
lower.includes("nemotron-ultra");
|
|
205
|
-
const hasVision = lower.includes("vision") || lower.includes("-vl-") || lower.includes("nvlm");
|
|
206
|
-
// Derive a human-friendly name from the model ID
|
|
207
|
-
const name = apiModel.id
|
|
208
|
-
.replace(/^[^/]+\//, "") // strip org/ prefix
|
|
209
|
-
.replace(/-/g, " ")
|
|
210
|
-
.replace(/\b\w/g, (c) => c.toUpperCase());
|
|
211
|
-
models.push({
|
|
212
|
-
id: apiModel.id,
|
|
213
|
-
name,
|
|
214
|
-
reasoning: isReasoning,
|
|
215
|
-
input: hasVision ? ["text", "image"] : ["text"],
|
|
216
|
-
cost: NVIDIA_DEFAULT_COST,
|
|
217
|
-
contextWindow: 131072, // safe default for NIM models
|
|
218
|
-
maxTokens: 8192,
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
return models.length > 0 ? models : NVIDIA_MODEL_CATALOG.map(buildNvidiaModelDefinition);
|
|
223
|
-
}
|
|
224
|
-
catch (error) {
|
|
225
|
-
console.warn(`[nvidia-models] Discovery failed: ${String(error)}, using static catalog`);
|
|
226
|
-
return NVIDIA_MODEL_CATALOG.map(buildNvidiaModelDefinition);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export function makeAttemptResult(overrides = {}) {
|
|
2
|
-
return {
|
|
3
|
-
aborted: false,
|
|
4
|
-
timedOut: false,
|
|
5
|
-
timedOutDuringCompaction: false,
|
|
6
|
-
promptError: null,
|
|
7
|
-
sessionIdUsed: "test-session",
|
|
8
|
-
assistantTexts: ["Hello!"],
|
|
9
|
-
toolMetas: [],
|
|
10
|
-
lastAssistant: undefined,
|
|
11
|
-
messagesSnapshot: [],
|
|
12
|
-
didSendViaMessagingTool: false,
|
|
13
|
-
messagingToolSentTexts: [],
|
|
14
|
-
messagingToolSentMediaUrls: [],
|
|
15
|
-
messagingToolSentTargets: [],
|
|
16
|
-
cloudCodeAssistFormatError: false,
|
|
17
|
-
...overrides,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
export function mockOverflowRetrySuccess(params) {
|
|
21
|
-
const overflowError = new Error(params.overflowMessage ?? "request_too_large: Request size exceeds model context window");
|
|
22
|
-
params.runEmbeddedAttempt.mockResolvedValueOnce(makeAttemptResult({ promptError: overflowError }));
|
|
23
|
-
params.runEmbeddedAttempt.mockResolvedValueOnce(makeAttemptResult({ promptError: null }));
|
|
24
|
-
params.compactDirect.mockResolvedValueOnce({
|
|
25
|
-
ok: true,
|
|
26
|
-
compacted: true,
|
|
27
|
-
result: {
|
|
28
|
-
summary: "Compacted session",
|
|
29
|
-
firstKeptEntryId: "entry-5",
|
|
30
|
-
tokensBefore: 150000,
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
return overflowError;
|
|
34
|
-
}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { vi } from "vitest";
|
|
2
|
-
export const mockedGlobalHookRunner = {
|
|
3
|
-
hasHooks: vi.fn((_hookName) => false),
|
|
4
|
-
runBeforeAgentStart: vi.fn(async (_event, _ctx) => undefined),
|
|
5
|
-
runBeforePromptBuild: vi.fn(async (_event, _ctx) => undefined),
|
|
6
|
-
runBeforeModelResolve: vi.fn(async (_event, _ctx) => undefined),
|
|
7
|
-
};
|
|
8
|
-
vi.mock("../../plugins/hook-runner-global.js", () => ({
|
|
9
|
-
getGlobalHookRunner: vi.fn(() => mockedGlobalHookRunner),
|
|
10
|
-
}));
|
|
11
|
-
vi.mock("../auth-profiles.js", () => ({
|
|
12
|
-
isProfileInCooldown: vi.fn(() => false),
|
|
13
|
-
markAuthProfileFailure: vi.fn(async () => { }),
|
|
14
|
-
markAuthProfileGood: vi.fn(async () => { }),
|
|
15
|
-
markAuthProfileUsed: vi.fn(async () => { }),
|
|
16
|
-
}));
|
|
17
|
-
vi.mock("../usage.js", () => ({
|
|
18
|
-
normalizeUsage: vi.fn((usage) => usage && typeof usage === "object" ? usage : undefined),
|
|
19
|
-
derivePromptTokens: vi.fn((usage) => {
|
|
20
|
-
if (!usage) {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
const input = usage.input ?? 0;
|
|
24
|
-
const cacheRead = usage.cacheRead ?? 0;
|
|
25
|
-
const cacheWrite = usage.cacheWrite ?? 0;
|
|
26
|
-
const sum = input + cacheRead + cacheWrite;
|
|
27
|
-
return sum > 0 ? sum : undefined;
|
|
28
|
-
}),
|
|
29
|
-
hasNonzeroUsage: vi.fn(() => false),
|
|
30
|
-
}));
|
|
31
|
-
vi.mock("../workspace-run.js", () => ({
|
|
32
|
-
resolveRunWorkspaceDir: vi.fn((params) => ({
|
|
33
|
-
workspaceDir: params.workspaceDir,
|
|
34
|
-
usedFallback: false,
|
|
35
|
-
fallbackReason: undefined,
|
|
36
|
-
agentId: "main",
|
|
37
|
-
})),
|
|
38
|
-
redactRunIdentifier: vi.fn((value) => value ?? ""),
|
|
39
|
-
}));
|
|
40
|
-
vi.mock("../pi-embedded-helpers.js", () => ({
|
|
41
|
-
formatBillingErrorMessage: vi.fn(() => ""),
|
|
42
|
-
classifyFailoverReason: vi.fn(() => null),
|
|
43
|
-
formatAssistantErrorText: vi.fn(() => ""),
|
|
44
|
-
isAuthAssistantError: vi.fn(() => false),
|
|
45
|
-
isBillingAssistantError: vi.fn(() => false),
|
|
46
|
-
isCompactionFailureError: vi.fn(() => false),
|
|
47
|
-
isLikelyContextOverflowError: vi.fn((msg) => {
|
|
48
|
-
const lower = (msg ?? "").toLowerCase();
|
|
49
|
-
return lower.includes("request_too_large") || lower.includes("context window exceeded");
|
|
50
|
-
}),
|
|
51
|
-
isFailoverAssistantError: vi.fn(() => false),
|
|
52
|
-
isFailoverErrorMessage: vi.fn(() => false),
|
|
53
|
-
parseImageSizeError: vi.fn(() => null),
|
|
54
|
-
parseImageDimensionError: vi.fn(() => null),
|
|
55
|
-
isRateLimitAssistantError: vi.fn(() => false),
|
|
56
|
-
isTimeoutErrorMessage: vi.fn(() => false),
|
|
57
|
-
pickFallbackThinkingLevel: vi.fn(() => null),
|
|
58
|
-
}));
|
|
59
|
-
vi.mock("./run/attempt.js", () => ({
|
|
60
|
-
runEmbeddedAttempt: vi.fn(),
|
|
61
|
-
}));
|
|
62
|
-
vi.mock("./compact.js", () => ({
|
|
63
|
-
compactEmbeddedPiSessionDirect: vi.fn(),
|
|
64
|
-
}));
|
|
65
|
-
vi.mock("./model.js", () => ({
|
|
66
|
-
resolveModel: vi.fn(() => ({
|
|
67
|
-
model: {
|
|
68
|
-
id: "test-model",
|
|
69
|
-
provider: "anthropic",
|
|
70
|
-
contextWindow: 200000,
|
|
71
|
-
api: "messages",
|
|
72
|
-
},
|
|
73
|
-
error: null,
|
|
74
|
-
authStorage: {
|
|
75
|
-
setRuntimeApiKey: vi.fn(),
|
|
76
|
-
},
|
|
77
|
-
modelRegistry: {},
|
|
78
|
-
})),
|
|
79
|
-
}));
|
|
80
|
-
vi.mock("../model-auth.js", () => ({
|
|
81
|
-
ensureAuthProfileStore: vi.fn(() => ({})),
|
|
82
|
-
getApiKeyForModel: vi.fn(async () => ({
|
|
83
|
-
apiKey: "test-key",
|
|
84
|
-
profileId: "test-profile",
|
|
85
|
-
source: "test",
|
|
86
|
-
})),
|
|
87
|
-
resolveAuthProfileOrder: vi.fn(() => []),
|
|
88
|
-
}));
|
|
89
|
-
vi.mock("../models-config.js", () => ({
|
|
90
|
-
ensurePoolBotModelsJson: vi.fn(async () => { }),
|
|
91
|
-
}));
|
|
92
|
-
vi.mock("../context-window-guard.js", () => ({
|
|
93
|
-
CONTEXT_WINDOW_HARD_MIN_TOKENS: 1000,
|
|
94
|
-
CONTEXT_WINDOW_WARN_BELOW_TOKENS: 5000,
|
|
95
|
-
evaluateContextWindowGuard: vi.fn(() => ({
|
|
96
|
-
shouldWarn: false,
|
|
97
|
-
shouldBlock: false,
|
|
98
|
-
tokens: 200000,
|
|
99
|
-
source: "model",
|
|
100
|
-
})),
|
|
101
|
-
resolveContextWindowInfo: vi.fn(() => ({
|
|
102
|
-
tokens: 200000,
|
|
103
|
-
source: "model",
|
|
104
|
-
})),
|
|
105
|
-
}));
|
|
106
|
-
vi.mock("../../process/command-queue.js", () => ({
|
|
107
|
-
enqueueCommandInLane: vi.fn((_lane, task) => task()),
|
|
108
|
-
}));
|
|
109
|
-
vi.mock("../../utils/message-channel.js", () => ({
|
|
110
|
-
isMarkdownCapableMessageChannel: vi.fn(() => true),
|
|
111
|
-
}));
|
|
112
|
-
vi.mock("../agent-paths.js", () => ({
|
|
113
|
-
resolvePoolBotAgentDir: vi.fn(() => "/tmp/agent-dir"),
|
|
114
|
-
}));
|
|
115
|
-
vi.mock("../defaults.js", () => ({
|
|
116
|
-
DEFAULT_CONTEXT_TOKENS: 200000,
|
|
117
|
-
DEFAULT_MODEL: "test-model",
|
|
118
|
-
DEFAULT_PROVIDER: "anthropic",
|
|
119
|
-
}));
|
|
120
|
-
vi.mock("../failover-error.js", () => ({
|
|
121
|
-
FailoverError: class extends Error {
|
|
122
|
-
},
|
|
123
|
-
resolveFailoverStatus: vi.fn(),
|
|
124
|
-
}));
|
|
125
|
-
vi.mock("./lanes.js", () => ({
|
|
126
|
-
resolveSessionLane: vi.fn(() => "session-lane"),
|
|
127
|
-
resolveGlobalLane: vi.fn(() => "global-lane"),
|
|
128
|
-
}));
|
|
129
|
-
vi.mock("./logger.js", () => ({
|
|
130
|
-
log: {
|
|
131
|
-
debug: vi.fn(),
|
|
132
|
-
info: vi.fn(),
|
|
133
|
-
warn: vi.fn(),
|
|
134
|
-
error: vi.fn(),
|
|
135
|
-
isEnabled: vi.fn(() => false),
|
|
136
|
-
},
|
|
137
|
-
}));
|
|
138
|
-
vi.mock("./run/payloads.js", () => ({
|
|
139
|
-
buildEmbeddedRunPayloads: vi.fn(() => []),
|
|
140
|
-
}));
|
|
141
|
-
vi.mock("./tool-result-truncation.js", () => ({
|
|
142
|
-
truncateOversizedToolResultsInSession: vi.fn(async () => ({
|
|
143
|
-
truncated: false,
|
|
144
|
-
truncatedCount: 0,
|
|
145
|
-
reason: "no oversized tool results",
|
|
146
|
-
})),
|
|
147
|
-
sessionLikelyHasOversizedToolResults: vi.fn(() => false),
|
|
148
|
-
}));
|
|
149
|
-
vi.mock("./utils.js", () => ({
|
|
150
|
-
describeUnknownError: vi.fn((err) => {
|
|
151
|
-
if (err instanceof Error) {
|
|
152
|
-
return err.message;
|
|
153
|
-
}
|
|
154
|
-
return String(err);
|
|
155
|
-
}),
|
|
156
|
-
}));
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { handleToolExecutionEnd, handleToolExecutionStart, } from "./pi-embedded-subscribe.handlers.tools.js";
|
|
2
|
-
/** Type-safe bridge: narrows parameter type so callers avoid assertions. */
|
|
3
|
-
function asFullContext(ctx) {
|
|
4
|
-
return ctx;
|
|
5
|
-
}
|
|
6
|
-
/** Typed wrapper around {@link handleToolExecutionStart}. */
|
|
7
|
-
export function callToolExecutionStart(ctx, evt) {
|
|
8
|
-
return handleToolExecutionStart(asFullContext(ctx), evt);
|
|
9
|
-
}
|
|
10
|
-
/** Typed wrapper around {@link handleToolExecutionEnd}. */
|
|
11
|
-
export async function callToolExecutionEnd(ctx, evt) {
|
|
12
|
-
return handleToolExecutionEnd(asFullContext(ctx), evt);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Check whether a mock-call argument is an object containing `mediaUrls`
|
|
16
|
-
* but NOT `text` (i.e. a "direct media" emission).
|
|
17
|
-
*/
|
|
18
|
-
export function isDirectMediaCall(call) {
|
|
19
|
-
const arg = call[0];
|
|
20
|
-
if (!arg || typeof arg !== "object") {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
return "mediaUrls" in arg && !("text" in arg);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Filter a vi.fn() mock's call log to only direct-media emissions.
|
|
27
|
-
*/
|
|
28
|
-
export function filterDirectMediaCalls(mock) {
|
|
29
|
-
return mock.mock.calls.filter(isDirectMediaCall);
|
|
30
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Provider Pool — Config Loader
|
|
3
|
-
*
|
|
4
|
-
* Reads pool configuration from `models.providers.<id>.pool` in the
|
|
5
|
-
* PoolBot config and initializes the TokenPool with the configured tokens.
|
|
6
|
-
*
|
|
7
|
-
* Called once during gateway/agent startup. Idempotent — clears
|
|
8
|
-
* existing pool state before loading.
|
|
9
|
-
*
|
|
10
|
-
* @module provider/config-loader
|
|
11
|
-
*/
|
|
12
|
-
import { createSubsystemLogger } from "../../logging/subsystem.js";
|
|
13
|
-
import { TokenPool } from "./token-pool.js";
|
|
14
|
-
const log = createSubsystemLogger("provider/config-loader");
|
|
15
|
-
/**
|
|
16
|
-
* Load token pool configuration from the PoolBot config.
|
|
17
|
-
*
|
|
18
|
-
* Reads `models.providers.<providerID>.pool` entries and calls
|
|
19
|
-
* `TokenPool.addToken()` for each configured token.
|
|
20
|
-
*
|
|
21
|
-
* @returns Number of providers with pool configuration loaded
|
|
22
|
-
*/
|
|
23
|
-
export function loadPoolConfig(cfg) {
|
|
24
|
-
const providers = cfg.models?.providers;
|
|
25
|
-
if (!providers)
|
|
26
|
-
return 0;
|
|
27
|
-
let loadedProviders = 0;
|
|
28
|
-
for (const [providerID, providerCfg] of Object.entries(providers)) {
|
|
29
|
-
const pool = providerCfg.pool;
|
|
30
|
-
if (!pool?.tokens?.length)
|
|
31
|
-
continue;
|
|
32
|
-
// Configure pool scheduling before adding tokens
|
|
33
|
-
if (pool.scheduling || pool.maxWaitMs || pool.autoDisable !== undefined) {
|
|
34
|
-
TokenPool.configure(providerID, {
|
|
35
|
-
scheduling: pool.scheduling,
|
|
36
|
-
maxWaitMs: pool.maxWaitMs,
|
|
37
|
-
autoDisable: pool.autoDisable,
|
|
38
|
-
autoDisableThreshold: pool.autoDisableThreshold,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
let tokenCount = 0;
|
|
42
|
-
for (const tokenCfg of pool.tokens) {
|
|
43
|
-
if (!tokenCfg.id || !tokenCfg.key) {
|
|
44
|
-
log.info("skipped-invalid-token", { providerID, tokenID: tokenCfg.id ?? "(missing)" });
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
TokenPool.addToken(providerID, tokenCfg.id, tokenCfg.key, {
|
|
49
|
-
tier: (tokenCfg.tier ?? "paid"),
|
|
50
|
-
label: tokenCfg.label,
|
|
51
|
-
enabled: tokenCfg.enabled ?? true,
|
|
52
|
-
});
|
|
53
|
-
tokenCount++;
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
log.info("token-add-failed", {
|
|
57
|
-
providerID,
|
|
58
|
-
tokenID: tokenCfg.id,
|
|
59
|
-
error: String(e),
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (tokenCount > 0) {
|
|
64
|
-
loadedProviders++;
|
|
65
|
-
log.info("pool-loaded", {
|
|
66
|
-
providerID,
|
|
67
|
-
tokens: tokenCount,
|
|
68
|
-
scheduling: pool.scheduling ?? "priority",
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (loadedProviders > 0) {
|
|
73
|
-
log.info("config-loaded", { providers: loadedProviders });
|
|
74
|
-
}
|
|
75
|
-
return loadedProviders;
|
|
76
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Provider Infrastructure
|
|
3
|
-
*
|
|
4
|
-
* Operational modules for token rotation, rate limiting,
|
|
5
|
-
* request monitoring, session management, and model catalog.
|
|
6
|
-
*
|
|
7
|
-
* @module provider
|
|
8
|
-
*/
|
|
9
|
-
export { RateLimits } from "./rate-limits.js";
|
|
10
|
-
export { RequestMonitor } from "./request-monitor.js";
|
|
11
|
-
export { SessionManager } from "./session-binding.js";
|
|
12
|
-
export { TokenPool } from "./token-pool.js";
|
|
13
|
-
export { ModelsDev } from "./models-dev.js";
|
|
14
|
-
export { resolveTokenFromPool, isProviderRateLimited, recordRequestOutcome, recordFallbackError, } from "./integration.js";
|
|
15
|
-
export { loadPoolConfig } from "./config-loader.js";
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Models.dev Catalog
|
|
3
|
-
*
|
|
4
|
-
* Fetches and caches the model catalog from https://models.dev/api.json.
|
|
5
|
-
* Provides typed schemas for providers and models via Zod.
|
|
6
|
-
*
|
|
7
|
-
* @module provider/models-dev
|
|
8
|
-
*/
|
|
9
|
-
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
10
|
-
import path from "node:path";
|
|
11
|
-
import z from "zod";
|
|
12
|
-
import { createSubsystemLogger } from "../../logging/subsystem.js";
|
|
13
|
-
import { resolveStateDir } from "../../config/paths.js";
|
|
14
|
-
export var ModelsDev;
|
|
15
|
-
(function (ModelsDev) {
|
|
16
|
-
const log = createSubsystemLogger("provider/models-dev");
|
|
17
|
-
/** Cache directory: ~/.poolbot/cache/ */
|
|
18
|
-
const cacheDir = path.join(resolveStateDir(), "cache");
|
|
19
|
-
const filepath = path.join(cacheDir, "models.json");
|
|
20
|
-
/** User-Agent for fetching */
|
|
21
|
-
const USER_AGENT = "pool-bot";
|
|
22
|
-
ModelsDev.Model = z.object({
|
|
23
|
-
id: z.string(),
|
|
24
|
-
name: z.string(),
|
|
25
|
-
family: z.string().optional(),
|
|
26
|
-
release_date: z.string(),
|
|
27
|
-
attachment: z.boolean(),
|
|
28
|
-
reasoning: z.boolean(),
|
|
29
|
-
temperature: z.boolean(),
|
|
30
|
-
tool_call: z.boolean(),
|
|
31
|
-
interleaved: z
|
|
32
|
-
.union([
|
|
33
|
-
z.literal(true),
|
|
34
|
-
z
|
|
35
|
-
.object({
|
|
36
|
-
field: z.enum(["reasoning_content", "reasoning_details"]),
|
|
37
|
-
})
|
|
38
|
-
.strict(),
|
|
39
|
-
])
|
|
40
|
-
.optional(),
|
|
41
|
-
cost: z
|
|
42
|
-
.object({
|
|
43
|
-
input: z.number(),
|
|
44
|
-
output: z.number(),
|
|
45
|
-
cache_read: z.number().optional(),
|
|
46
|
-
cache_write: z.number().optional(),
|
|
47
|
-
context_over_200k: z
|
|
48
|
-
.object({
|
|
49
|
-
input: z.number(),
|
|
50
|
-
output: z.number(),
|
|
51
|
-
cache_read: z.number().optional(),
|
|
52
|
-
cache_write: z.number().optional(),
|
|
53
|
-
})
|
|
54
|
-
.optional(),
|
|
55
|
-
})
|
|
56
|
-
.optional(),
|
|
57
|
-
limit: z.object({
|
|
58
|
-
context: z.number(),
|
|
59
|
-
output: z.number(),
|
|
60
|
-
}),
|
|
61
|
-
modalities: z
|
|
62
|
-
.object({
|
|
63
|
-
input: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
|
|
64
|
-
output: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
|
|
65
|
-
})
|
|
66
|
-
.optional(),
|
|
67
|
-
experimental: z.boolean().optional(),
|
|
68
|
-
status: z.enum(["alpha", "beta", "deprecated"]).optional(),
|
|
69
|
-
options: z.record(z.string(), z.any()),
|
|
70
|
-
headers: z.record(z.string(), z.string()).optional(),
|
|
71
|
-
provider: z.object({ npm: z.string() }).optional(),
|
|
72
|
-
});
|
|
73
|
-
ModelsDev.Provider = z.object({
|
|
74
|
-
api: z.string().optional(),
|
|
75
|
-
name: z.string(),
|
|
76
|
-
env: z.array(z.string()),
|
|
77
|
-
id: z.string(),
|
|
78
|
-
npm: z.string().optional(),
|
|
79
|
-
models: z.record(z.string(), ModelsDev.Model),
|
|
80
|
-
});
|
|
81
|
-
/**
|
|
82
|
-
* Gets the cached model catalog, triggering a background refresh.
|
|
83
|
-
* Returns empty object if no cached data is available.
|
|
84
|
-
*/
|
|
85
|
-
async function get() {
|
|
86
|
-
// Fire-and-forget background refresh
|
|
87
|
-
refresh().catch((e) => log.error("background refresh failed", { error: String(e) }));
|
|
88
|
-
// Try reading from cache
|
|
89
|
-
try {
|
|
90
|
-
const content = await readFile(filepath, "utf-8");
|
|
91
|
-
const result = JSON.parse(content);
|
|
92
|
-
return result;
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
// No cached file yet — return empty catalog
|
|
96
|
-
return {};
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
ModelsDev.get = get;
|
|
100
|
-
/**
|
|
101
|
-
* Fetches the latest model catalog from models.dev and caches it.
|
|
102
|
-
*/
|
|
103
|
-
async function refresh() {
|
|
104
|
-
if (process.env.POOLBOT_DISABLE_MODELS_FETCH)
|
|
105
|
-
return;
|
|
106
|
-
log.info("refreshing", { filepath });
|
|
107
|
-
const result = await fetch("https://models.dev/api.json", {
|
|
108
|
-
headers: {
|
|
109
|
-
"User-Agent": USER_AGENT,
|
|
110
|
-
},
|
|
111
|
-
signal: AbortSignal.timeout(10 * 1000),
|
|
112
|
-
}).catch((e) => {
|
|
113
|
-
log.error("failed to fetch models.dev", { error: String(e) });
|
|
114
|
-
});
|
|
115
|
-
if (!result || !result.ok)
|
|
116
|
-
return;
|
|
117
|
-
try {
|
|
118
|
-
const text = await result.text();
|
|
119
|
-
await mkdir(cacheDir, { recursive: true });
|
|
120
|
-
await writeFile(filepath, text, "utf-8");
|
|
121
|
-
}
|
|
122
|
-
catch (e) {
|
|
123
|
-
log.error("failed to write models.json", { error: String(e) });
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
ModelsDev.refresh = refresh;
|
|
127
|
-
})(ModelsDev || (ModelsDev = {}));
|
|
128
|
-
// Background refresh every hour
|
|
129
|
-
setInterval(() => ModelsDev.refresh().catch(() => { }), 60 * 60 * 1000).unref();
|