@evandu/super-pi-server 0.0.0-stage → 0.1.259
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +248 -3
- package/agents/code-auditor.md +64 -0
- package/agents/code-designer.md +64 -0
- package/agents/coder.md +24 -0
- package/agents/critic.md +24 -0
- package/agents/document-organizer.md +48 -0
- package/agents/patcher.md +27 -0
- package/agents/planner.md +30 -0
- package/agents/project-leader.md +28 -0
- package/agents/reviewer.md +27 -0
- package/agents/scout.md +27 -0
- package/agents/solution-designer.md +62 -0
- package/agents/super-pi-documents/index.ts +92 -0
- package/agents/super-pi-feishu/index.ts +88 -0
- package/agents/super-pi-knowledge/index.ts +70 -0
- package/agents/super-pi-managed-model/index.ts +9 -0
- package/agents/super-pi-memory/index.ts +75 -0
- package/agents/super-pi-native-tools/index.ts +1 -0
- package/agents/super-pi-task/core.ts +2262 -0
- package/agents/super-pi-task/index.ts +814 -0
- package/agents/super-pi-task/workflow-schema.ts +34 -0
- package/agents/super-pi-web/index.ts +32 -0
- package/agents/verifier.md +25 -0
- package/assets/fonts/LICENSE +92 -0
- package/assets/fonts/NotoSansSC-Bold.otf +0 -0
- package/assets/fonts/NotoSansSC-Regular.otf +0 -0
- package/assets/knowledge-model/README.md +37 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/config.json +31 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/onnx/model_quantized.onnx +0 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/special_tokens_map.json +7 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/tokenizer.json +21278 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/tokenizer_config.json +15 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/vocab.txt +21128 -0
- package/bin/npm-prefix.d.ts +1 -0
- package/bin/npm-prefix.js +10 -0
- package/bin/super-pi.js +349 -0
- package/dist/client/.super-pi-client-sources.json +82 -0
- package/dist/client/assets/CodeMirrorEditor-mi9rGUce.js +2 -0
- package/dist/client/assets/GitDiffEditor-CpoDDQrA.css +1 -0
- package/dist/client/assets/GitDiffEditor-FQBfGxOY.js +29 -0
- package/dist/client/assets/diff-ChtP43wD.js +1 -0
- package/dist/client/assets/dist-AW5lyI3I.js +1 -0
- package/dist/client/assets/dist-B3-a6uF0.js +7 -0
- package/dist/client/assets/dist-BGxkyh6e.js +1 -0
- package/dist/client/assets/dist-BJxfd7yb.js +11 -0
- package/dist/client/assets/dist-BRVQKlcp.js +1 -0
- package/dist/client/assets/dist-BV64A9Ji.js +1 -0
- package/dist/client/assets/dist-BXAOrsjq.js +1 -0
- package/dist/client/assets/dist-CKF2Jksy.js +1 -0
- package/dist/client/assets/dist-CX_Hm4GS.js +1 -0
- package/dist/client/assets/dist-Cus6_oaF.js +2 -0
- package/dist/client/assets/dist-Cx00EZKR.js +23 -0
- package/dist/client/assets/dist-D71y2EI1.js +1 -0
- package/dist/client/assets/dist-D978o95T.js +5 -0
- package/dist/client/assets/dist-Dc1MBGAG.js +1 -0
- package/dist/client/assets/dist-Dds-qLxY.js +9 -0
- package/dist/client/assets/dist-DeD9copn.js +1 -0
- package/dist/client/assets/dist-DuvGReu-.js +6 -0
- package/dist/client/assets/dist-Dvb0SqcK.js +2 -0
- package/dist/client/assets/dist-J6XWqRpB.js +3 -0
- package/dist/client/assets/dist-QzbOCAU6.js +1 -0
- package/dist/client/assets/dist-moiMRpw_.js +1 -0
- package/dist/client/assets/dist-scBkrwv-.js +2 -0
- package/dist/client/assets/dockerfile-BDePf5PZ.js +1 -0
- package/dist/client/assets/index-Cn7hdrDw.js +350 -0
- package/dist/client/assets/index-UfzqdECL.css +1 -0
- package/dist/client/assets/powershell-D8WpQPaX.js +1 -0
- package/dist/client/assets/properties-C357ku5U.js +1 -0
- package/dist/client/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/dist/client/assets/ruby-ChfNwlCY.js +1 -0
- package/dist/client/assets/shell-DwuoZtxw.js +1 -0
- package/dist/client/assets/swift-DKB6_1j6.js +1 -0
- package/dist/client/assets/toml-BPTmHmyx.js +1 -0
- package/dist/client/favicon.ico +0 -0
- package/dist/client/favicon.png +0 -0
- package/dist/client/favicon.svg +10 -0
- package/dist/client/index.html +18 -0
- package/dist/extension.d.ts +15 -0
- package/dist/extension.js +126 -0
- package/dist/server/active-memory.d.ts +247 -0
- package/dist/server/active-memory.js +669 -0
- package/dist/server/agents.d.ts +245 -0
- package/dist/server/agents.js +701 -0
- package/dist/server/application/catalog-service.d.ts +98 -0
- package/dist/server/application/catalog-service.js +245 -0
- package/dist/server/application/conversation-service.d.ts +245 -0
- package/dist/server/application/conversation-service.js +654 -0
- package/dist/server/application/document-service.d.ts +68 -0
- package/dist/server/application/document-service.js +120 -0
- package/dist/server/application/extension-ui-service.d.ts +44 -0
- package/dist/server/application/extension-ui-service.js +135 -0
- package/dist/server/application/feishu-service.d.ts +179 -0
- package/dist/server/application/feishu-service.js +358 -0
- package/dist/server/application/group-chat-service.d.ts +75 -0
- package/dist/server/application/group-chat-service.js +953 -0
- package/dist/server/application/group-execution.d.ts +15 -0
- package/dist/server/application/group-execution.js +77 -0
- package/dist/server/application/project-service.d.ts +464 -0
- package/dist/server/application/project-service.js +2523 -0
- package/dist/server/application/provider-service.d.ts +174 -0
- package/dist/server/application/provider-service.js +510 -0
- package/dist/server/application/run-service.d.ts +547 -0
- package/dist/server/application/run-service.js +2683 -0
- package/dist/server/application/scheduled-task-service.d.ts +184 -0
- package/dist/server/application/scheduled-task-service.js +391 -0
- package/dist/server/application/session-orchestrator-service.d.ts +388 -0
- package/dist/server/application/session-orchestrator-service.js +1146 -0
- package/dist/server/application/session-reminder-service.d.ts +59 -0
- package/dist/server/application/session-reminder-service.js +141 -0
- package/dist/server/application/session-watchdog.d.ts +171 -0
- package/dist/server/application/session-watchdog.js +284 -0
- package/dist/server/application/workspace-service.d.ts +52 -0
- package/dist/server/application/workspace-service.js +186 -0
- package/dist/server/application/worktree-service.d.ts +13 -0
- package/dist/server/application/worktree-service.js +76 -0
- package/dist/server/browser-access.d.ts +34 -0
- package/dist/server/browser-access.js +89 -0
- package/dist/server/capability.d.ts +105 -0
- package/dist/server/capability.js +170 -0
- package/dist/server/command-handler.d.ts +93 -0
- package/dist/server/command-handler.js +540 -0
- package/dist/server/content-search.d.ts +16 -0
- package/dist/server/content-search.js +235 -0
- package/dist/server/conversation-usage.d.ts +22 -0
- package/dist/server/conversation-usage.js +43 -0
- package/dist/server/documents.d.ts +152 -0
- package/dist/server/documents.js +998 -0
- package/dist/server/engineering-learning.d.ts +30 -0
- package/dist/server/engineering-learning.js +106 -0
- package/dist/server/exec-service.d.ts +45 -0
- package/dist/server/exec-service.js +167 -0
- package/dist/server/explicit-file-open.d.ts +34 -0
- package/dist/server/explicit-file-open.js +105 -0
- package/dist/server/failure-text.d.ts +18 -0
- package/dist/server/failure-text.js +44 -0
- package/dist/server/feishu-cli.d.ts +223 -0
- package/dist/server/feishu-cli.js +464 -0
- package/dist/server/file-changes.d.ts +119 -0
- package/dist/server/file-changes.js +280 -0
- package/dist/server/file-diff.d.ts +41 -0
- package/dist/server/file-diff.js +97 -0
- package/dist/server/file-index.d.ts +100 -0
- package/dist/server/file-index.js +296 -0
- package/dist/server/file-name-index.d.ts +160 -0
- package/dist/server/file-name-index.js +411 -0
- package/dist/server/files.d.ts +269 -0
- package/dist/server/files.js +748 -0
- package/dist/server/git.d.ts +245 -0
- package/dist/server/git.js +903 -0
- package/dist/server/http-server.d.ts +45 -0
- package/dist/server/http-server.js +3830 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +485 -0
- package/dist/server/inline-thinking.d.ts +90 -0
- package/dist/server/inline-thinking.js +181 -0
- package/dist/server/json-comments.d.ts +14 -0
- package/dist/server/json-comments.js +71 -0
- package/dist/server/knowledge-embedding-worker.d.ts +1 -0
- package/dist/server/knowledge-embedding-worker.js +27 -0
- package/dist/server/knowledge-vectors.d.ts +150 -0
- package/dist/server/knowledge-vectors.js +385 -0
- package/dist/server/knowledge.d.ts +273 -0
- package/dist/server/knowledge.js +848 -0
- package/dist/server/length-continuation.d.ts +83 -0
- package/dist/server/length-continuation.js +118 -0
- package/dist/server/logging.d.ts +32 -0
- package/dist/server/logging.js +185 -0
- package/dist/server/managed-http-tunnel.d.ts +6 -0
- package/dist/server/managed-http-tunnel.js +85 -0
- package/dist/server/managed-http.d.ts +4 -0
- package/dist/server/managed-http.js +85 -0
- package/dist/server/managed-model-adapter.d.ts +17 -0
- package/dist/server/managed-model-adapter.js +75 -0
- package/dist/server/managed-model-gateway.d.ts +49 -0
- package/dist/server/managed-model-gateway.js +73 -0
- package/dist/server/managed-servers.d.ts +55 -0
- package/dist/server/managed-servers.js +392 -0
- package/dist/server/managed-ssh.d.ts +26 -0
- package/dist/server/managed-ssh.js +73 -0
- package/dist/server/manager-vault.d.ts +11 -0
- package/dist/server/manager-vault.js +67 -0
- package/dist/server/memory-recall.d.ts +25 -0
- package/dist/server/memory-recall.js +45 -0
- package/dist/server/memory.d.ts +67 -0
- package/dist/server/memory.js +216 -0
- package/dist/server/message-media.d.ts +7 -0
- package/dist/server/message-media.js +54 -0
- package/dist/server/model-context-window.d.ts +186 -0
- package/dist/server/model-context-window.js +444 -0
- package/dist/server/model-filter.d.ts +23 -0
- package/dist/server/model-filter.js +48 -0
- package/dist/server/models-store.d.ts +36 -0
- package/dist/server/models-store.js +132 -0
- package/dist/server/native-tool-settings.d.ts +25 -0
- package/dist/server/native-tool-settings.js +41 -0
- package/dist/server/native-tools-extension.d.ts +2 -0
- package/dist/server/native-tools-extension.js +39 -0
- package/dist/server/native-tools-service.d.ts +39 -0
- package/dist/server/native-tools-service.js +240 -0
- package/dist/server/persistence/app-state-repository.d.ts +65 -0
- package/dist/server/persistence/app-state-repository.js +1 -0
- package/dist/server/persistence/json-state-repository.d.ts +14 -0
- package/dist/server/persistence/json-state-repository.js +43 -0
- package/dist/server/persistence/open-state-store.d.ts +3 -0
- package/dist/server/persistence/open-state-store.js +35 -0
- package/dist/server/persistence/rename.d.ts +22 -0
- package/dist/server/persistence/rename.js +44 -0
- package/dist/server/persistence/sqlite-state-repository.d.ts +12 -0
- package/dist/server/persistence/sqlite-state-repository.js +264 -0
- package/dist/server/pi-command.d.ts +94 -0
- package/dist/server/pi-command.js +265 -0
- package/dist/server/pi-native.d.ts +12 -0
- package/dist/server/pi-native.js +16 -0
- package/dist/server/pi-session-events.d.ts +158 -0
- package/dist/server/pi-session-events.js +373 -0
- package/dist/server/pi-session-pool.d.ts +233 -0
- package/dist/server/pi-session-pool.js +382 -0
- package/dist/server/pi-session.d.ts +642 -0
- package/dist/server/pi-session.js +655 -0
- package/dist/server/presentations/schema.d.ts +120 -0
- package/dist/server/presentations/schema.js +128 -0
- package/dist/server/provider-network.d.ts +16 -0
- package/dist/server/provider-network.js +106 -0
- package/dist/server/provider-proxy.d.ts +18 -0
- package/dist/server/provider-proxy.js +200 -0
- package/dist/server/providers.d.ts +333 -0
- package/dist/server/providers.js +989 -0
- package/dist/server/remote-bootstrap.d.ts +17 -0
- package/dist/server/remote-bootstrap.js +119 -0
- package/dist/server/rpc-channel.d.ts +131 -0
- package/dist/server/rpc-channel.js +135 -0
- package/dist/server/runtime.d.ts +1393 -0
- package/dist/server/runtime.js +3286 -0
- package/dist/server/scheduled-tasks.d.ts +101 -0
- package/dist/server/scheduled-tasks.js +138 -0
- package/dist/server/server-context.d.ts +119 -0
- package/dist/server/server-context.js +1 -0
- package/dist/server/session-cwd.d.ts +19 -0
- package/dist/server/session-cwd.js +58 -0
- package/dist/server/session-ledger.d.ts +67 -0
- package/dist/server/session-ledger.js +76 -0
- package/dist/server/session-memory-scope.d.ts +4 -0
- package/dist/server/session-memory-scope.js +30 -0
- package/dist/server/session-repository.d.ts +100 -0
- package/dist/server/session-repository.js +246 -0
- package/dist/server/session-tree-scope.d.ts +125 -0
- package/dist/server/session-tree-scope.js +337 -0
- package/dist/server/skills.d.ts +23 -0
- package/dist/server/skills.js +190 -0
- package/dist/server/store.d.ts +1062 -0
- package/dist/server/store.js +3305 -0
- package/dist/server/subagent-runs.d.ts +185 -0
- package/dist/server/subagent-runs.js +383 -0
- package/dist/server/subagents.d.ts +200 -0
- package/dist/server/subagents.js +619 -0
- package/dist/server/task-tool.d.ts +282 -0
- package/dist/server/task-tool.js +507 -0
- package/dist/server/tavily.d.ts +32 -0
- package/dist/server/tavily.js +136 -0
- package/dist/server/team-context.d.ts +12 -0
- package/dist/server/team-context.js +180 -0
- package/dist/server/terminal.d.ts +163 -0
- package/dist/server/terminal.js +557 -0
- package/dist/server/thinking-level-discovery.d.ts +38 -0
- package/dist/server/thinking-level-discovery.js +183 -0
- package/dist/server/time-zone.d.ts +20 -0
- package/dist/server/time-zone.js +32 -0
- package/dist/server/tool-calls.d.ts +130 -0
- package/dist/server/tool-calls.js +341 -0
- package/dist/server/tool-llm.d.ts +72 -0
- package/dist/server/tool-llm.js +146 -0
- package/dist/server/tool-registry.d.ts +129 -0
- package/dist/server/tool-registry.js +249 -0
- package/dist/server/tool-runner.d.ts +112 -0
- package/dist/server/tool-runner.js +306 -0
- package/dist/server/turn-failure.d.ts +48 -0
- package/dist/server/turn-failure.js +148 -0
- package/dist/server/types.d.ts +2315 -0
- package/dist/server/types.js +11 -0
- package/dist/server/update-status.d.ts +14 -0
- package/dist/server/update-status.js +69 -0
- package/dist/server/update.d.ts +46 -0
- package/dist/server/update.js +104 -0
- package/dist/server/upload.d.ts +35 -0
- package/dist/server/upload.js +177 -0
- package/dist/server/version.d.ts +33 -0
- package/dist/server/version.js +111 -0
- package/dist/server/web.d.ts +27 -0
- package/dist/server/web.js +183 -0
- package/dist/server/workflow-engine.d.ts +47 -0
- package/dist/server/workflow-engine.js +255 -0
- package/dist/server/workflow.d.ts +329 -0
- package/dist/server/workflow.js +469 -0
- package/dist/server/workspace-file-indexes.d.ts +2 -0
- package/dist/server/workspace-file-indexes.js +61 -0
- package/dist/server/workspace-file-operations.d.ts +36 -0
- package/dist/server/workspace-file-operations.js +281 -0
- package/dist/server/workspace-file-response.d.ts +7 -0
- package/dist/server/workspace-file-response.js +79 -0
- package/dist/server/ws-server.d.ts +149 -0
- package/dist/server/ws-server.js +640 -0
- package/dist/shared/agent-order.d.ts +44 -0
- package/dist/shared/agent-order.js +50 -0
- package/dist/shared/archive-decisions.d.ts +44 -0
- package/dist/shared/archive-decisions.js +98 -0
- package/dist/shared/background-task.d.ts +25 -0
- package/dist/shared/background-task.js +183 -0
- package/dist/shared/child-session-lock.d.ts +37 -0
- package/dist/shared/child-session-lock.js +59 -0
- package/dist/shared/content-search.d.ts +22 -0
- package/dist/shared/content-search.js +1 -0
- package/dist/shared/conversation-title.d.ts +4 -0
- package/dist/shared/conversation-title.js +4 -0
- package/dist/shared/file-mentions.d.ts +17 -0
- package/dist/shared/file-mentions.js +91 -0
- package/dist/shared/git-commit.d.ts +11 -0
- package/dist/shared/git-commit.js +1 -0
- package/dist/shared/git-graph.d.ts +42 -0
- package/dist/shared/git-graph.js +30 -0
- package/dist/shared/group-chat.d.ts +132 -0
- package/dist/shared/group-chat.js +6 -0
- package/dist/shared/managed-servers.d.ts +36 -0
- package/dist/shared/managed-servers.js +1 -0
- package/dist/shared/message-media.d.ts +12 -0
- package/dist/shared/message-media.js +27 -0
- package/dist/shared/model-window-label.d.ts +39 -0
- package/dist/shared/model-window-label.js +55 -0
- package/dist/shared/native-tools.d.ts +43 -0
- package/dist/shared/native-tools.js +1 -0
- package/dist/shared/pi-cache-warming.d.ts +9 -0
- package/dist/shared/pi-cache-warming.js +4 -0
- package/dist/shared/project-overview.d.ts +107 -0
- package/dist/shared/project-overview.js +92 -0
- package/dist/shared/project-presentation.d.ts +55 -0
- package/dist/shared/project-presentation.js +111 -0
- package/dist/shared/provider-network.d.ts +30 -0
- package/dist/shared/provider-network.js +1 -0
- package/dist/shared/session-reporting.d.ts +40 -0
- package/dist/shared/session-reporting.js +97 -0
- package/dist/shared/session-search.d.ts +14 -0
- package/dist/shared/session-search.js +1 -0
- package/dist/shared/team-context-view.d.ts +33 -0
- package/dist/shared/team-context-view.js +49 -0
- package/dist/shared/team-context.d.ts +59 -0
- package/dist/shared/team-context.js +3 -0
- package/dist/shared/terminal-protocol.d.ts +71 -0
- package/dist/shared/terminal-protocol.js +1 -0
- package/dist/shared/thinking-levels.d.ts +53 -0
- package/dist/shared/thinking-levels.js +85 -0
- package/dist/shared/tool-glyph.d.ts +7 -0
- package/dist/shared/tool-glyph.js +19 -0
- package/dist/shared/transcript-order.d.ts +7 -0
- package/dist/shared/transcript-order.js +12 -0
- package/dist/shared/update-status.d.ts +28 -0
- package/dist/shared/update-status.js +1 -0
- package/dist/shared/workspace-file-preview.d.ts +4 -0
- package/dist/shared/workspace-file-preview.js +28 -0
- package/package.json +448 -4
- package/scripts/diagnose.mjs +603 -0
- package/scripts/patch-brace-expansion.mjs +260 -0
- package/scripts/restart-server.mjs +104 -0
- package/skills/presentation/SKILL.md +30 -0
- package/skills/presentation/references/data.md +10 -0
- package/skills/presentation/references/quality.md +12 -0
- package/skills/presentation/references/story.md +12 -0
- package/skills/presentation/references/templates-and-editing.md +11 -0
- package/skills/presentation/references/visual-system.md +10 -0
- package/skills/super-pi-agent-development/SKILL.md +25 -0
- package/skills/super-pi-development/SKILL.md +31 -0
- package/skills/super-pi-tool-development/SKILL.md +39 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import type { DiscoveredModel, PublicProvider } from "./types.js";
|
|
2
|
+
import type { SharedProviderProxySettings } from "../shared/provider-network.js";
|
|
3
|
+
import { type ThinkingLevelMap } from "../shared/thinking-levels.js";
|
|
4
|
+
/**
|
|
5
|
+
* THE PROVIDERS A PERSON ADDED, and the two files that make Pi know about them.
|
|
6
|
+
*
|
|
7
|
+
* WHAT THIS REPLACES. Pi's own answer to "I want to use a model that is not in your list" is a
|
|
8
|
+
* hand-written `~/.pi/agent/models.json` (the provider and model definitions) plus a key in
|
|
9
|
+
* `~/.pi/agent/auth.json`. There is no command for it and no UI for it - the files are the interface.
|
|
10
|
+
* This module is that interface, in a form: the settings window collects the same fields and writes
|
|
11
|
+
* the same files.
|
|
12
|
+
*
|
|
13
|
+
* WHY THE FILES AND NOT A RUNTIME REGISTRATION. Pi's SDK can register a provider in memory
|
|
14
|
+
* (`ModelRuntime.registerProvider`) and hold a key in memory (`setRuntimeApiKey`), and both are
|
|
15
|
+
* tempting - they touch nothing of the user's. They do not work here, for two reasons that are
|
|
16
|
+
* facts about this codebase rather than opinions:
|
|
17
|
+
*
|
|
18
|
+
* 1. `ModelRuntime` is created PER SESSION here (`pi-session.ts:498`), so a provider registered on
|
|
19
|
+
* one instance is invisible to the next conversation.
|
|
20
|
+
* 2. A spawned Pi (`pi --mode rpc`, the one-shot mode) has no provider-registration command at all
|
|
21
|
+
* - its RPC surface is `set_model` and `get_available_models` and nothing that defines a
|
|
22
|
+
* provider. A provider that exists only in this process's memory cannot reach it.
|
|
23
|
+
*
|
|
24
|
+
* The files, by contrast, are read by BOTH paths: the SDK's `ModelRuntime.create()` loads
|
|
25
|
+
* `models.json` and `auth.json` from Pi's agent dir, and a spawned Pi does the same. So writing them
|
|
26
|
+
* is the only way one setting works everywhere - including in the terminal, where `pi` sees the same
|
|
27
|
+
* provider the person just added here.
|
|
28
|
+
*
|
|
29
|
+
* THE TRUTH SOURCE IS OURS, THE FILES ARE DERIVED. `<dataDir>/providers.json` (0600, holds the key)
|
|
30
|
+
* says which providers Super Pi manages. Pi's two files are rewritten from it after every change, by
|
|
31
|
+
* MERGING: only the provider ids we manage are touched, everything else in those files is left alone.
|
|
32
|
+
* That is what makes "delete the provider I added" safe, and it is why a person who hand-wrote their
|
|
33
|
+
* own provider keeps it.
|
|
34
|
+
*
|
|
35
|
+
* THE KEY NEVER REACHES THE BROWSER. It lives in two files with restrictive permissions - ours and
|
|
36
|
+
* Pi's `auth.json` - and in neither the state snapshot nor any event. What the browser gets is
|
|
37
|
+
* `hasKey: true`.
|
|
38
|
+
*/
|
|
39
|
+
/** One model of a provider, as the settings window collects it. */
|
|
40
|
+
export type ProviderModelDefinition = {
|
|
41
|
+
id: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
reasoning?: boolean;
|
|
44
|
+
imageInput?: boolean;
|
|
45
|
+
contextWindow?: number;
|
|
46
|
+
maxTokens?: number;
|
|
47
|
+
/**
|
|
48
|
+
* The two compatibility switches an OpenAI-compatible server sometimes needs.
|
|
49
|
+
*
|
|
50
|
+
* `supportsDeveloperRole: false` makes Pi send the system prompt as a `system` message instead of
|
|
51
|
+
* a `developer` one, which is what relays and local servers that predate the `developer` role need.
|
|
52
|
+
* `supportsReasoningEffort: false` stops Pi from sending `reasoning_effort` to a server that does
|
|
53
|
+
* not know the field. Both are per-provider in Pi's schema and per-model here, because a server can
|
|
54
|
+
* be one and not the other.
|
|
55
|
+
*/
|
|
56
|
+
supportsDeveloperRole?: boolean;
|
|
57
|
+
supportsReasoningEffort?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The thinking levels this model really offers, and what each one is sent as.
|
|
60
|
+
*
|
|
61
|
+
* THREE STATES, and the difference between them is the whole point:
|
|
62
|
+
* - ABSENT: nobody said anything about the levels. Whatever was saved for this model stays -
|
|
63
|
+
* a hand-written map in Pi's own file is not this form's to delete.
|
|
64
|
+
* - `null`: this model has NO map. The levels that were saved described an endpoint this model
|
|
65
|
+
* is no longer served by, so they go rather than travel to the new address.
|
|
66
|
+
* - A map: these are the levels, and every one of Pi's seven is named - `null` for the ones the
|
|
67
|
+
* model does not have, because Pi enables the ordinary ones when the map is silent.
|
|
68
|
+
*/
|
|
69
|
+
thinkingLevelMap?: ThinkingLevelMap | null;
|
|
70
|
+
};
|
|
71
|
+
/** One provider, as the settings window collects it. */
|
|
72
|
+
export type ProviderDefinition = {
|
|
73
|
+
id: string;
|
|
74
|
+
name?: string;
|
|
75
|
+
baseUrl: string;
|
|
76
|
+
api: string;
|
|
77
|
+
/** The API key. Stored, never broadcast. */
|
|
78
|
+
apiKey?: string;
|
|
79
|
+
hasAuthKey?: boolean;
|
|
80
|
+
models: ProviderModelDefinition[];
|
|
81
|
+
/**
|
|
82
|
+
* The fields in this provider's `models.json` entry that Pi's own schema refuses - today, an
|
|
83
|
+
* empty string where Pi asks for at least one character.
|
|
84
|
+
*
|
|
85
|
+
* WHY THE PANEL CARES. Pi validates the WHOLE file, so one bad entry takes every custom
|
|
86
|
+
* provider out of every picker, while this panel - which reads the file leniently - still lists
|
|
87
|
+
* them all. Naming the field is what turns "my provider is gone" into "your file has an empty
|
|
88
|
+
* baseUrl".
|
|
89
|
+
*/
|
|
90
|
+
invalidFields?: string[];
|
|
91
|
+
/**
|
|
92
|
+
* The key is written into `models.json` itself rather than into `auth.json`.
|
|
93
|
+
*
|
|
94
|
+
* Pi's own documentation leads with it (`"apiKey": "$MY_KEY"`), and it is the only way to point a
|
|
95
|
+
* provider at a key that lives in the environment. It matters here because such a provider IS
|
|
96
|
+
* offered by Pi when the variable is set - so the panel must not tell the person it has no
|
|
97
|
+
* credential, and must not warn that Pi will not offer it.
|
|
98
|
+
*/
|
|
99
|
+
keyInModelsJson?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* TRUE when the provider is one of Pi's own, with no entry in `models.json`.
|
|
102
|
+
*
|
|
103
|
+
* Its models come from Pi itself and the only thing a person has configured for it is the
|
|
104
|
+
* credential, so it can be switched off but has no address to edit.
|
|
105
|
+
*/
|
|
106
|
+
builtin?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* TRUE when the provider is switched OFF: Pi does not offer it, and switching it back on restores
|
|
109
|
+
* exactly what was there.
|
|
110
|
+
*/
|
|
111
|
+
disabled?: boolean;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* A provider that was switched OFF, and everything needed to switch it back on.
|
|
115
|
+
*
|
|
116
|
+
* WHY THIS EXISTS AT ALL. Turning a provider off means taking it out of Pi's files - the
|
|
117
|
+
* `models.json` entry and the `auth.json` credential - because that is the only thing Pi honours
|
|
118
|
+
* (a provider is offered exactly when it has a working credential, and `ModelRuntime.getAvailable()`
|
|
119
|
+
* is what the picker reads). Taking something out of a file is not the same as throwing it away, so
|
|
120
|
+
* what was taken out is written down HERE, in Super Pi's own directory, with the same restrictive
|
|
121
|
+
* permissions the registry already has. Switching it back on is then a matter of putting those two
|
|
122
|
+
* pieces back where Pi reads them.
|
|
123
|
+
*
|
|
124
|
+
* THE CREDENTIAL IS IN HERE, and that is deliberate. A provider that is switched off is one a person
|
|
125
|
+
* may well switch back on - a coding plan that was renewed, a proxy that was moved - and a
|
|
126
|
+
* credential that cannot be recovered cannot be restored. The file is 0600, it lives in Super Pi's own
|
|
127
|
+
* data directory, and nothing in it is ever broadcast: the browser is told only that a key exists.
|
|
128
|
+
*/
|
|
129
|
+
export type DisabledProvider = {
|
|
130
|
+
id: string;
|
|
131
|
+
/** The provider's name, as it was. */
|
|
132
|
+
name?: string;
|
|
133
|
+
/** The `models.json` entry, verbatim, when the provider had one. */
|
|
134
|
+
modelsEntry?: Record<string, unknown>;
|
|
135
|
+
/** The `auth.json` entry, verbatim, when the provider had a credential. */
|
|
136
|
+
credential?: Record<string, unknown>;
|
|
137
|
+
/** The models the provider offered, so the panel can show what switching it back on brings. */
|
|
138
|
+
models: ProviderModelDefinition[];
|
|
139
|
+
};
|
|
140
|
+
/** One model, as the browser sees it. No key, no nothing secret - there is nothing secret here. */
|
|
141
|
+
export type { PublicProvider, PublicProviderModel } from "./types.js";
|
|
142
|
+
/**
|
|
143
|
+
* The API adapters Pi ships, as the ids a provider may name.
|
|
144
|
+
*
|
|
145
|
+
* Taken from Pi's own `KnownApi` union (`pi-ai/dist/types.d.ts`) rather than invented: the id ends
|
|
146
|
+
* up in `models.json` and Pi looks the adapter up by exactly this string, and an unknown one fails
|
|
147
|
+
* at REQUEST time ("No API provider registered for api: ...") rather than at load time. Offering the
|
|
148
|
+
* list in the form is the difference between a person finding the right value and guessing.
|
|
149
|
+
*/
|
|
150
|
+
export declare const KNOWN_APIS: readonly ["openai-completions", "anthropic-messages", "openai-responses", "azure-openai-responses", "openai-codex-responses", "mistral-conversations", "google-generative-ai", "google-vertex", "bedrock-converse-stream", "pi-messages"];
|
|
151
|
+
/**
|
|
152
|
+
* Pi's global configuration directory - where `models.json` and `auth.json` live.
|
|
153
|
+
*
|
|
154
|
+
* `PI_CODING_AGENT_DIR` wins, because that is Pi's own rule (`core/config.js:getAgentDir`) and a
|
|
155
|
+
* person who set it expects Pi to read its config from there. The fallback is Pi's own default,
|
|
156
|
+
* `~/.pi/agent`, with the home directory taken from the environment rather than from `os.homedir()`
|
|
157
|
+
* - on Windows the two disagree often enough to matter.
|
|
158
|
+
*/
|
|
159
|
+
export declare function piAgentDir(): string;
|
|
160
|
+
/** Pi's provider and model definitions. */
|
|
161
|
+
export declare function piModelsPath(agentDir?: string): string;
|
|
162
|
+
/** Pi's credential store. */
|
|
163
|
+
export declare function piAuthPath(agentDir?: string): string;
|
|
164
|
+
/**
|
|
165
|
+
* Strips JSONC comments, the way Pi's own parser does.
|
|
166
|
+
*
|
|
167
|
+
* Pi reads `models.json` with comments allowed, so a person may well have written comments in it -
|
|
168
|
+
* and Super Pi has to be able to READ that file to merge into it. A naive strip would corrupt a
|
|
169
|
+
* string that contains `//` (a base URL with a path, an api key with a slash), so this walks the
|
|
170
|
+
* text and tracks whether it is inside a string.
|
|
171
|
+
*/
|
|
172
|
+
export declare function stripJsonComments(text: string): string;
|
|
173
|
+
/**
|
|
174
|
+
* The providers Super Pi manages, and the writes that make Pi know about them.
|
|
175
|
+
*
|
|
176
|
+
* The class owns three files: its own registry, Pi's `models.json` and Pi's `auth.json`. Only the
|
|
177
|
+
* first is a truth source; the other two are rewritten from it.
|
|
178
|
+
*/
|
|
179
|
+
export declare class ProviderRegistry {
|
|
180
|
+
private readonly dataDir;
|
|
181
|
+
private readonly piDir;
|
|
182
|
+
/**
|
|
183
|
+
* `piDir` is Pi's own configuration directory, and it is a PARAMETER rather than a lookup at
|
|
184
|
+
* write time for one reason: a test that forgets to set `PI_CODING_AGENT_DIR` would then write to
|
|
185
|
+
* the developer's real `~/.pi/agent`. With the directory in hand, a test cannot reach it by
|
|
186
|
+
* accident - it has to be given one.
|
|
187
|
+
*/
|
|
188
|
+
constructor(dataDir: string, piDir?: string);
|
|
189
|
+
private networkQueue;
|
|
190
|
+
private sharedNetworkRecord;
|
|
191
|
+
sharedNetwork(known: ReadonlyArray<{
|
|
192
|
+
id: string;
|
|
193
|
+
api: string;
|
|
194
|
+
}>): Promise<SharedProviderProxySettings>;
|
|
195
|
+
setSharedNetwork(input: unknown, known: ReadonlyArray<{
|
|
196
|
+
id: string;
|
|
197
|
+
api: string;
|
|
198
|
+
}>): Promise<SharedProviderProxySettings>;
|
|
199
|
+
clearNetworkOverride(providerId: string): Promise<void>;
|
|
200
|
+
/** Super Pi's own registry: the providers it manages, with their keys. */
|
|
201
|
+
private get registryPath();
|
|
202
|
+
/** The registry file as one object: the managed providers AND the ones turned off. */
|
|
203
|
+
private readRegistry;
|
|
204
|
+
/** Writes one half of the registry file without losing the other. */
|
|
205
|
+
private writeRegistry;
|
|
206
|
+
/**
|
|
207
|
+
* Reads all configured providers directly from Pi's models.json and auth.json.
|
|
208
|
+
* Super Pi acts as the direct visual management plane for Pi's model configurations.
|
|
209
|
+
*
|
|
210
|
+
* PROVIDERS THAT ARE TURNED OFF ARE NOT IN HERE. They have been taken out of Pi's files - that is
|
|
211
|
+
* what "off" means - so this list is exactly what Pi would offer, which is what the write path
|
|
212
|
+
* (`set`, `remove`, `applyToPi`) has to reason about. `loadDisabled()` is the other half, for the
|
|
213
|
+
* panel that has to be able to switch them back on.
|
|
214
|
+
*/
|
|
215
|
+
load(): Promise<ProviderDefinition[]>;
|
|
216
|
+
/**
|
|
217
|
+
* Pi's OWN providers: the ones that exist because they have a credential in `auth.json` and no
|
|
218
|
+
* entry in `models.json`.
|
|
219
|
+
*
|
|
220
|
+
* WHY THIS IS A SEPARATE READ. A built-in such as `kimi-coding` is defined inside Pi, not in a
|
|
221
|
+
* file - the only thing a person has configured for it is the credential. Those providers are
|
|
222
|
+
* invisible to `load()`, which reads `models.json`, and that is correct for the WRITE path:
|
|
223
|
+
* writing an empty `models.json` entry for a built-in would shadow Pi's own definition with a
|
|
224
|
+
* broken one. But they are exactly what a person wants to switch off ("I stopped paying for this
|
|
225
|
+
* plan"), so the panel has to see them. This returns the ids and the fact of a credential; the
|
|
226
|
+
* models come from Pi's catalogue, which this file layer cannot see.
|
|
227
|
+
*/
|
|
228
|
+
loadCredentialOnly(): Promise<ProviderDefinition[]>;
|
|
229
|
+
/** The providers that are switched off, as the panel needs to see them. */
|
|
230
|
+
loadDisabled(): Promise<DisabledProvider[]>;
|
|
231
|
+
/**
|
|
232
|
+
* Takes a provider out of Pi's configuration and remembers exactly what was taken out.
|
|
233
|
+
*
|
|
234
|
+
* TWO FILES, and both are needed. `models.json` is where a custom provider's models are defined;
|
|
235
|
+
* `auth.json` is where its credential is. Pi offers a provider's models only when its auth is
|
|
236
|
+
* configured (`ModelRuntime.getAvailable()` filters on exactly that), so removing the credential
|
|
237
|
+
* is what makes a BUILT-IN stop being offered - it has no `models.json` entry to remove - while
|
|
238
|
+
* removing both is what makes a custom one disappear completely.
|
|
239
|
+
*
|
|
240
|
+
* NOTHING IS THROWN AWAY. Both pieces are written into Super Pi's own registry, which is how
|
|
241
|
+
* `enable` can put them back byte for byte. A person switching off a lapsed subscription provider
|
|
242
|
+
* is not asking to forget their endpoint and their models.
|
|
243
|
+
*/
|
|
244
|
+
disable(providerId: string, models?: ProviderModelDefinition[]): Promise<void>;
|
|
245
|
+
/**
|
|
246
|
+
* Puts a provider back exactly where `disable` took it from.
|
|
247
|
+
*
|
|
248
|
+
* AN EXISTING ENTRY IS NOT OVERWRITTEN. The person may have re-created the provider (or written a
|
|
249
|
+
* new `models.json` entry for the same id) while it was off; the newer entry is theirs and wins,
|
|
250
|
+
* and only the missing piece is restored. Refusing would be worse: the switch says "back on", and
|
|
251
|
+
* the credential is what makes it usable.
|
|
252
|
+
*/
|
|
253
|
+
enable(providerId: string): Promise<void>;
|
|
254
|
+
/**
|
|
255
|
+
* Deletes a BUILT-IN provider's credential from Pi's `auth.json`.
|
|
256
|
+
*
|
|
257
|
+
* THE ONLY THING THERE IS TO DELETE. A built-in's models live in Pi itself; what a person has
|
|
258
|
+
* configured for it is the credential, and removing that is what makes Pi stop offering it. This
|
|
259
|
+
* is the PERMANENT version: unlike `disable`, nothing is remembered, so switching it back on means
|
|
260
|
+
* logging in to that provider again (which is what re-subscribing to the plan involves anyway).
|
|
261
|
+
*/
|
|
262
|
+
removeCredential(providerId: string): Promise<void>;
|
|
263
|
+
/** Forgets a disabled provider without restoring anything: the permanent form of "off". */
|
|
264
|
+
forgetDisabled(providerId: string): Promise<void>;
|
|
265
|
+
/**
|
|
266
|
+
* Removes the empty fields Pi's schema refuses, so the file is accepted again.
|
|
267
|
+
*
|
|
268
|
+
* WHY THIS IS A REPAIR AND NOT A DELETE. An empty `baseUrl` is not a provider with no address -
|
|
269
|
+
* it is a value Pi refuses, and Pi refuses the WHOLE FILE when it sees one. The fix is to drop
|
|
270
|
+
* the empty field (leaving the provider exactly as it was otherwise), NOT to remove the provider:
|
|
271
|
+
* the person wrote it, and an override-only entry - one that only adds models to a built-in - has
|
|
272
|
+
* no address at all, which is legal as long as the field is ABSENT rather than empty.
|
|
273
|
+
*
|
|
274
|
+
* NOTHING ELSE IN THE FILE IS TOUCHED. The entries are read as raw JSON and written back with
|
|
275
|
+
* only the offending fields removed, so a comment-free copy of a hand-written file stays a
|
|
276
|
+
* hand-written file.
|
|
277
|
+
*/
|
|
278
|
+
repairModelsConfig(): Promise<{
|
|
279
|
+
fixed: string[];
|
|
280
|
+
changed: boolean;
|
|
281
|
+
}>;
|
|
282
|
+
/** Writes the registry. The key lives here, so the file is 0600. */
|
|
283
|
+
save(providers: ProviderDefinition[]): Promise<void>;
|
|
284
|
+
/**
|
|
285
|
+
* Directly updates Pi's models.json and auth.json to match the new set of providers.
|
|
286
|
+
* Full visual editor semantics: any provider in models.json is editable and removable.
|
|
287
|
+
*/
|
|
288
|
+
applyToPi(previous: ProviderDefinition[], next: ProviderDefinition[]): Promise<void>;
|
|
289
|
+
/**
|
|
290
|
+
* Writes the keys into Pi's `auth.json`.
|
|
291
|
+
*/
|
|
292
|
+
private applyKeysToPi;
|
|
293
|
+
}
|
|
294
|
+
/** The provider list as the browser sees it: the key becomes a fact. */
|
|
295
|
+
export declare function publicProviders(providers: ProviderDefinition[]): PublicProvider[];
|
|
296
|
+
/**
|
|
297
|
+
* Checks what the form collected and returns it in the shape the registry stores.
|
|
298
|
+
*
|
|
299
|
+
* EVERY RULE HERE SAYS WHY, because a message a person reads is the only validation they get: the
|
|
300
|
+
* server cannot ask a follow-up question, so a refusal has to name the field and the reason.
|
|
301
|
+
*/
|
|
302
|
+
export declare function validateProvider(input: unknown): ProviderDefinition;
|
|
303
|
+
/**
|
|
304
|
+
* Probes the provider's remote endpoint (OpenAI /models or Ollama /api/tags)
|
|
305
|
+
* and returns the list of available models with inferred metadata.
|
|
306
|
+
*/
|
|
307
|
+
export declare function fetchRemoteModels(input: {
|
|
308
|
+
baseUrl: string;
|
|
309
|
+
proxyEnv?: Record<string, string>;
|
|
310
|
+
apiKey?: string;
|
|
311
|
+
api?: string;
|
|
312
|
+
}): Promise<DiscoveredModel[]>;
|
|
313
|
+
/**
|
|
314
|
+
* THE ANSWER, READ.
|
|
315
|
+
*
|
|
316
|
+
* Split out of `fetchRemoteModels` so that the part worth asserting - what a provider's answer MEANS -
|
|
317
|
+
* can be tested without a network in between. A remote provider answers in three shapes (a bare array,
|
|
318
|
+
* `{data: [...]}` for OpenAI, `{models: [...]}` for Ollama), and each entry names itself with `id`,
|
|
319
|
+
* `name` or `model`; what the panel shows next to it - whether the model reasons, whether it takes
|
|
320
|
+
* images - is inferred from the name, because that is all most providers tell us.
|
|
321
|
+
*
|
|
322
|
+
* `fetchRemoteModels` is the transport; this is the reading. Keeping them apart means the reading can
|
|
323
|
+
* be pinned exactly, and a slow machine can never turn a parsing question into a timeout.
|
|
324
|
+
*
|
|
325
|
+
* THE CONTEXT IS THE ENDPOINT THAT ANSWERED, and it matters for exactly one thing: the thinking
|
|
326
|
+
* levels. A level is only true of the endpoint that published it, so the rules that depend on the
|
|
327
|
+
* address need it - and the rules that do not (a model that declares its own levels) work without
|
|
328
|
+
* it, which is why the context is optional.
|
|
329
|
+
*/
|
|
330
|
+
export declare function parseRemoteModels(payload: unknown, context?: {
|
|
331
|
+
baseUrl?: string;
|
|
332
|
+
api?: string;
|
|
333
|
+
}): DiscoveredModel[];
|