pi-web-ui 0.116.0 → 0.118.0
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/CHANGELOG.md +83 -3
- package/README.md +69 -138
- package/README.zh-CN.md +70 -179
- package/README.zh-TW.md +3 -1
- package/bin/device-hub-cli.mjs +163 -36
- package/bin/frp-manager.mjs +4 -80
- package/bin/hub-upgrade.mjs +561 -0
- package/bin/pi-device-hub.mjs +0 -1
- package/bin/pi-web-ui.mjs +184 -504
- package/deploy/nginx-subpath.conf +0 -33
- package/deploy/pi-web-ui.service +0 -20
- package/dist/server/agent-formatters.js +4 -38
- package/dist/server/agent-service-daemon.js +203 -371
- package/dist/server/agent-service.js +1281 -3030
- package/dist/server/approval-audit.js +2 -23
- package/dist/server/approval-default-rules.js +0 -6
- package/dist/server/approval-rules.js +7 -105
- package/dist/server/ask-user-question-tool.js +1 -12
- package/dist/server/atomic-file.js +33 -5
- package/dist/server/attachment-store.js +0 -36
- package/dist/server/attachments.js +3 -112
- package/dist/server/auth-cookie.js +0 -21
- package/dist/server/bash-tool.js +1 -32
- package/dist/server/bg-servers.js +0 -96
- package/dist/server/browser-page-tool.js +11 -62
- package/dist/server/builtin-modules.js +7 -0
- package/dist/server/canvas/canvas-agent-tool.js +58 -47
- package/dist/server/canvas/canvas-cards.js +0 -14
- package/dist/server/canvas/canvas-dispatch.js +7 -4
- package/dist/server/canvas/canvas-orchestrator.js +167 -181
- package/dist/server/canvas/canvas-runtime-messages.js +30 -0
- package/dist/server/canvas/canvas-scheduled-task.js +0 -3
- package/dist/server/canvas/canvas-scheduler.js +5 -7
- package/dist/server/canvas/canvas-store.js +24 -35
- package/dist/server/canvas/canvas-validation.js +17 -14
- package/dist/server/canvas/canvas-workspace.js +42 -114
- package/dist/server/canvas/pstack-skills-data.js +0 -5
- package/dist/server/claim-files-tool.js +1 -15
- package/dist/server/claim-store.js +5 -49
- package/dist/server/client-id-utils.js +0 -16
- package/dist/server/client-state.js +36 -214
- package/dist/server/communicate-tool.js +0 -3
- package/dist/server/compact-context-tool.js +0 -30
- package/dist/server/compacted-history.js +0 -35
- package/dist/server/compaction-instructions.js +0 -13
- package/dist/server/compaction-markers.js +38 -92
- package/dist/server/compaction-state.js +0 -21
- package/dist/server/composer-drafts.js +0 -34
- package/dist/server/context-budget-runner.js +0 -11
- package/dist/server/context-budget.js +1 -70
- package/dist/server/context-evidence.js +0 -14
- package/dist/server/context-usage.js +0 -12
- package/dist/server/control-socket.js +4 -48
- package/dist/server/conversation-communication.js +0 -10
- package/dist/server/conversation-identity.js +0 -1
- package/dist/server/conversation-read-tool.js +0 -58
- package/dist/server/conversation-tool-names.js +0 -1
- package/dist/server/conversation-tool.js +0 -1
- package/dist/server/conversation-touches.js +4 -75
- package/dist/server/dangling-tools.js +142 -68
- package/dist/server/delegate-mode.js +0 -36
- package/dist/server/delegate-task.js +2 -28
- package/dist/server/device-center/approval-summary.js +0 -1
- package/dist/server/device-center/bot-catalog.js +0 -3
- package/dist/server/device-center/bot-execution.js +48 -9
- package/dist/server/device-center/bot-presets.js +0 -1
- package/dist/server/device-center/bots.js +0 -1
- package/dist/server/device-center/collab-service.js +27 -11
- package/dist/server/device-center/collab-tool.js +393 -27
- package/dist/server/device-center/connector.js +128 -48
- package/dist/server/device-center/delivery-authority.js +95 -0
- package/dist/server/device-center/delivery-subject.js +29 -0
- package/dist/server/device-center/desktop-linux.js +3 -15
- package/dist/server/device-center/desktop-native.js +1 -10
- package/dist/server/device-center/desktop-page.js +2 -3
- package/dist/server/device-center/desktop-setup.js +1 -3
- package/dist/server/device-center/desktop.js +1 -7
- package/dist/server/device-center/device-integration.js +452 -208
- package/dist/server/device-center/device-lan-access.js +403 -0
- package/dist/server/device-center/device-lan.js +484 -0
- package/dist/server/device-center/device-portals.js +0 -3
- package/dist/server/device-center/execution-failure.js +0 -2
- package/dist/server/device-center/execution-guides.js +15 -6
- package/dist/server/device-center/execution-instructions.js +0 -1
- package/dist/server/device-center/execution-settings.js +0 -1
- package/dist/server/device-center/execution-system-prompt.js +0 -3
- package/dist/server/device-center/execution-workspace.js +1 -4
- package/dist/server/device-center/executor.js +46 -31
- package/dist/server/device-center/file-sync-paths.js +0 -5
- package/dist/server/device-center/file-sync.js +0 -10
- package/dist/server/device-center/group-context-delta.js +0 -8
- package/dist/server/device-center/group-context-message.js +0 -14
- package/dist/server/device-center/group-context.js +0 -19
- package/dist/server/device-center/group-events.js +0 -2
- package/dist/server/device-center/group-plan-guard.js +1 -35
- package/dist/server/device-center/group-router-runtime.js +182 -0
- package/dist/server/device-center/group-router-worker.js +178 -0
- package/dist/server/device-center/group-router.js +359 -0
- package/dist/server/device-center/hub-auth.js +24 -2
- package/dist/server/device-center/hub-conversations.js +13 -15
- package/dist/server/device-center/hub-deliveries.js +119 -15
- package/dist/server/device-center/hub-integration.js +647 -334
- package/dist/server/device-center/hub-locks.js +1 -5
- package/dist/server/device-center/hub-mobile.js +147 -0
- package/dist/server/device-center/hub-orchestration.js +400 -0
- package/dist/server/device-center/hub-page.js +28 -9
- package/dist/server/device-center/hub-setup.js +23 -7
- package/dist/server/device-center/hub-transaction-log.js +175 -0
- package/dist/server/device-center/hub-upgrade.js +162 -0
- package/dist/server/device-center/hub-webhooks.js +1 -3
- package/dist/server/device-center/hub.js +946 -404
- package/dist/server/device-center/human-interaction.js +1 -4
- package/dist/server/device-center/integration-errors.js +0 -2
- package/dist/server/device-center/integration-verification.js +111 -0
- package/dist/server/device-center/local-hub.js +6 -4
- package/dist/server/device-center/local-publication.js +416 -0
- package/dist/server/device-center/local-verification-job.js +95 -0
- package/dist/server/device-center/local-verification.js +273 -0
- package/dist/server/device-center/local.js +341 -18
- package/dist/server/device-center/main.js +18 -2
- package/dist/server/device-center/mobile-notification-forwarder.js +292 -0
- package/dist/server/device-center/native-desktop/macos.js +0 -1
- package/dist/server/device-center/native-desktop/windows.js +0 -1
- package/dist/server/device-center/partition-log.js +52 -46
- package/dist/server/device-center/path-portal.js +42 -12
- package/dist/server/device-center/publication-journal.js +305 -0
- package/dist/server/device-center/publish-intent.js +374 -0
- package/dist/server/device-center/relay.js +217 -52
- package/dist/server/device-center/report-upload.js +0 -1
- package/dist/server/device-center/runtime.js +419 -52
- package/dist/server/device-center/store.js +223 -65
- package/dist/server/device-center/task-context-budget.js +0 -3
- package/dist/server/device-center/task-error.js +0 -1
- package/dist/server/device-center/task-journal.js +6 -23
- package/dist/server/device-center/task-outcome.js +68 -0
- package/dist/server/device-center/task-plan.js +0 -1
- package/dist/server/device-center/task-progress.js +0 -16
- package/dist/server/device-center/task-recovery.js +569 -227
- package/dist/server/device-center/task-report-outbox.js +0 -4
- package/dist/server/device-center/task-report.js +2 -10
- package/dist/server/device-center/task-scheduler.js +1 -35
- package/dist/server/device-center/task-settlement.js +335 -0
- package/dist/server/device-center/task-state.js +0 -12
- package/dist/server/device-center/task-workspace.js +393 -0
- package/dist/server/device-center/transfer-stream.js +5 -45
- package/dist/server/device-center/transfers.js +2 -10
- package/dist/server/device-center/verification-limits.js +9 -0
- package/dist/server/device-center/work-contract.js +923 -0
- package/dist/server/device-center/work-items.js +317 -0
- package/dist/server/device-center/workspaces.js +0 -1
- package/dist/server/dispatch-domain-handlers.js +202 -29
- package/dist/server/dispatch-plugin-handlers.js +2 -19
- package/dist/server/dsh/dsh-agent-service.js +78 -601
- package/dist/server/dsh/dsh-client.js +7 -111
- package/dist/server/dsh/dsh-market-service.js +4 -25
- package/dist/server/dsh/dsh-serialize.js +0 -49
- package/dist/server/dsh/dsh-sessions.js +0 -37
- package/dist/server/dsh/dsh-usage.js +0 -37
- package/dist/server/dsh/preset-clones.js +1 -65
- package/dist/server/dsh/runtime/custom-prompt.mjs +0 -14
- package/dist/server/dsh/runtime/goal-rpc.mjs +7 -176
- package/dist/server/dsh/runtime/launcher.mjs +2 -53
- package/dist/server/dsh/runtime/override.patch.yml +0 -29
- package/dist/server/dsh/runtime/runtime-root.mjs +0 -54
- package/dist/server/durable/durable-agent-service.js +5 -23
- package/dist/server/durable/durable-driver.js +12 -73
- package/dist/server/durable/durable-event-projector.js +1 -50
- package/dist/server/durable/durable-loader.js +0 -12
- package/dist/server/durable/durable-models.js +11 -80
- package/dist/server/durable/durable-storage.js +1 -17
- package/dist/server/durable/durable-tools.js +2 -20
- package/dist/server/durable/index.js +0 -3
- package/dist/server/edit-soft-tool.js +2 -81
- package/dist/server/engine-capabilities.js +0 -13
- package/dist/server/engine-catalog.js +74 -0
- package/dist/server/engine-cli.js +89 -0
- package/dist/server/engine-probe.js +35 -217
- package/dist/server/ensure-bash.js +2 -28
- package/dist/server/eval-tool.js +1 -50
- package/dist/server/evidence-tool-hooks.js +0 -2
- package/dist/server/file-archives.js +0 -10
- package/dist/server/file-save.js +1 -12
- package/dist/server/file-transfer-routes.js +0 -11
- package/dist/server/files-service.js +18 -271
- package/dist/server/global-loader.js +9 -89
- package/dist/server/goal-evidence.js +1 -35
- package/dist/server/goal-review-gate.js +0 -58
- package/dist/server/goal-service.js +19 -422
- package/dist/server/hashline-engine.js +8 -112
- package/dist/server/host-guard.js +0 -24
- package/dist/server/host-metrics.js +0 -6
- package/dist/server/http-proxy.js +1 -7
- package/dist/server/i18n.js +5 -72
- package/dist/server/icon-svg.js +0 -15
- package/dist/server/index.js +199 -677
- package/dist/server/json-utils.js +0 -12
- package/dist/server/launch-origin.js +0 -44
- package/dist/server/left-panel-running.js +0 -9
- package/dist/server/load-timing.js +1 -4
- package/dist/server/load-tools-tool.js +0 -20
- package/dist/server/locales.js +1 -46
- package/dist/server/lsp-tool.js +13 -126
- package/dist/server/managed.js +0 -48
- package/dist/server/marker-service.js +1 -22
- package/dist/server/markers/builtins/action.js +0 -19
- package/dist/server/markers/builtins/notify.js +1 -9
- package/dist/server/markers/builtins/rename.js +0 -13
- package/dist/server/markers/index.js +0 -3
- package/dist/server/markers/marker.js +0 -13
- package/dist/server/markers/registry.js +0 -3
- package/dist/server/markers/store.js +1 -12
- package/dist/server/market-service.js +7 -43
- package/dist/server/mcp-agent-tool.js +0 -10
- package/dist/server/mcp-bridge.js +6 -138
- package/dist/server/mcp-hot-reload.js +0 -25
- package/dist/server/mcp-manager.js +2 -44
- package/dist/server/mcp-oauth-login.js +0 -2
- package/dist/server/mcp-oauth-ui.js +1 -4
- package/dist/server/mcp-oauth.js +5 -79
- package/dist/server/mcp-project-runtime.js +0 -4
- package/dist/server/message-deletion.js +0 -2
- package/dist/server/message-entry-resolver.js +0 -8
- package/dist/server/message-window.js +0 -71
- package/dist/server/mobile-notification-events.js +16 -0
- package/dist/server/mobile-origin.js +79 -0
- package/dist/server/mobile-push.js +523 -0
- package/dist/server/model-admin.js +19 -358
- package/dist/server/model-enrich.js +0 -19
- package/dist/server/model-resolver.js +2 -61
- package/dist/server/native-cli-discovery.js +115 -0
- package/dist/server/native-cli-model.js +71 -0
- package/dist/server/native-cli-references.js +214 -0
- package/dist/server/native-cli-remote-cleanup.js +58 -0
- package/dist/server/native-cli-remote-files.js +282 -0
- package/dist/server/native-cli-routes.js +68 -0
- package/dist/server/native-cli-runtime.js +1 -0
- package/dist/server/native-cli-session-hooks.js +170 -0
- package/dist/server/native-cli-session.js +585 -0
- package/dist/server/native-cli-state.js +82 -0
- package/dist/server/native-cli.js +210 -0
- package/dist/server/net-guard.js +9 -71
- package/dist/server/office-parse.js +0 -50
- package/dist/server/orphan-manager.js +0 -18
- package/dist/server/patch-bash-process.js +0 -4
- package/dist/server/patch-executable-lookup.js +0 -77
- package/dist/server/patch-node-pty.js +6 -45
- package/dist/server/patch-remote-catalog.js +4 -34
- package/dist/server/patch-tool.js +0 -15
- package/dist/server/payload-limits.js +0 -5
- package/dist/server/pending-question.js +0 -5
- package/dist/server/permission-preset.js +4 -33
- package/dist/server/persona-chain.js +0 -26
- package/dist/server/pkg-info.js +1 -17
- package/dist/server/plan-manager.js +2 -49
- package/dist/server/plan-mode.js +0 -97
- package/dist/server/plan-update-tool.js +1 -15
- package/dist/server/plugin-api-catalog.js +6 -4
- package/dist/server/plugin-assets.js +1 -35
- package/dist/server/plugin-bundled.js +68 -0
- package/dist/server/plugin-catalog-sync.js +0 -37
- package/dist/server/plugin-catalog.js +13 -67
- package/dist/server/plugin-chat-attachments.js +0 -1
- package/dist/server/plugin-conversation-view.js +0 -20
- package/dist/server/plugin-dom.js +1 -23
- package/dist/server/plugin-facilities.js +4 -115
- package/dist/server/plugin-grants.js +2 -90
- package/dist/server/plugin-install-spec.js +0 -43
- package/dist/server/plugin-installer.js +34 -75
- package/dist/server/plugin-llm.js +4 -38
- package/dist/server/plugin-manifest-validate.js +0 -31
- package/dist/server/plugin-permissions.js +1 -24
- package/dist/server/plugin-project.js +7 -129
- package/dist/server/plugin-removal.js +1 -8
- package/dist/server/plugin-schedule.js +1 -38
- package/dist/server/plugin-secrets.js +3 -16
- package/dist/server/plugin-tool-guard.js +1 -28
- package/dist/server/plugin-ui-slots.js +0 -4
- package/dist/server/plugin-updater.js +15 -90
- package/dist/server/plugins.js +71 -619
- package/dist/server/present-files-tool.js +0 -57
- package/dist/server/preset-fields.js +24 -61
- package/dist/server/preset-plugin-dependencies.js +0 -2
- package/dist/server/preset-share.js +4 -172
- package/dist/server/process-utils.js +4 -80
- package/dist/server/prompt-assembler.js +2 -30
- package/dist/server/prompt-base-store.js +0 -47
- package/dist/server/prompt-composer.js +21 -98
- package/dist/server/prompt-templates.js +0 -2
- package/dist/server/protocol-version.js +1 -11
- package/dist/server/protocol.js +0 -5
- package/dist/server/queue-modes.js +0 -3
- package/dist/server/queue-utils.js +0 -40
- package/dist/server/quick-ask-context.js +384 -0
- package/dist/server/quick-ask-settings.js +61 -0
- package/dist/server/quick-ask.js +260 -0
- package/dist/server/read-tool.js +0 -65
- package/dist/server/reasoning-registry.js +1 -29
- package/dist/server/remote-cli-persistence.js +373 -0
- package/dist/server/remote-native-cli.js +78 -0
- package/dist/server/remote-ssh-service.js +481 -190
- package/dist/server/request-context.js +0 -9
- package/dist/server/resolve-global-sdk.js +55 -31
- package/dist/server/sandbox-data.js +0 -1
- package/dist/server/sandbox-engines.js +0 -1
- package/dist/server/sandbox-runtime-gate.js +0 -3
- package/dist/server/sandbox-service.js +0 -41
- package/dist/server/sandbox-tool.js +0 -20
- package/dist/server/schedule-agent-tool.js +2 -31
- package/dist/server/scheduler-tasks.js +32 -56
- package/dist/server/scm-commitmsg.js +0 -53
- package/dist/server/scm.js +3 -48
- package/dist/server/sdk-builtin-extensions.js +2 -29
- package/dist/server/sdk-origin.js +0 -45
- package/dist/server/serialize.js +2 -92
- package/dist/server/server-config.js +0 -11
- package/dist/server/session-branch.js +1 -87
- package/dist/server/session-list-scan.js +215 -0
- package/dist/server/session-open.js +69 -0
- package/dist/server/session-parser.js +4 -54
- package/dist/server/session-scan.js +81 -45
- package/dist/server/session-search.js +0 -56
- package/dist/server/settings-service.js +19 -126
- package/dist/server/setup-config.js +0 -2
- package/dist/server/setup-page.js +0 -9
- package/dist/server/skill-content-filler.js +0 -17
- package/dist/server/skill-discovery.js +5 -92
- package/dist/server/skill-maintenance.js +1 -28
- package/dist/server/skill-tool.js +0 -30
- package/dist/server/slash-commands.js +5 -50
- package/dist/server/soft-cap.js +3 -40
- package/dist/server/startup-banner.js +0 -8
- package/dist/server/subagent-handoff.js +0 -11
- package/dist/server/subagent-helpers.js +2 -17
- package/dist/server/subagent-notify.js +0 -19
- package/dist/server/subagent-security-gate.js +0 -50
- package/dist/server/subagent-task.js +0 -9
- package/dist/server/subagent-templates-hant.js +0 -10
- package/dist/server/subagent-templates.js +3 -103
- package/dist/server/subagents.js +1 -87
- package/dist/server/system-screenshot-windows.js +259 -0
- package/dist/server/system-screenshot.js +77 -0
- package/dist/server/tabs.js +3 -48
- package/dist/server/terminals.js +559 -586
- package/dist/server/text-quote.js +0 -12
- package/dist/server/text-sniff.js +2 -52
- package/dist/server/themes.js +2 -41
- package/dist/server/tool-approval.js +0 -47
- package/dist/server/tool-guards.js +0 -90
- package/dist/server/tool-host-factories.js +1 -16
- package/dist/server/tool-info.js +0 -13
- package/dist/server/tool-manager.js +1 -229
- package/dist/server/tool-overrides.js +1 -46
- package/dist/server/tool-prompt-overrides.js +1 -30
- package/dist/server/tool-prompts.js +0 -14
- package/dist/server/tool-signature.js +0 -25
- package/dist/server/transcript-prepare.js +55 -0
- package/dist/server/tts-routes.js +58 -0
- package/dist/server/tts-service.js +106 -0
- package/dist/server/tts-system.js +160 -0
- package/dist/server/turn-timing.js +0 -1
- package/dist/server/unauthorized-page.js +0 -8
- package/dist/server/universal/driver-base.js +2 -31
- package/dist/server/universal/drivers/claude-code.js +98 -194
- package/dist/server/universal/drivers/codex.js +12 -35
- package/dist/server/universal/drivers/mock-driver.js +1 -11
- package/dist/server/universal/index.js +0 -3
- package/dist/server/universal/session-store.js +4 -21
- package/dist/server/universal/universal-attachments.js +2 -36
- package/dist/server/universal/universal-service.js +5 -24
- package/dist/server/universal/universal-session.js +30 -148
- package/dist/server/universal/universal-types.js +0 -3
- package/dist/server/update-check.js +6 -182
- package/dist/server/uploads.js +4 -43
- package/dist/server/virtual-tui.js +2 -27
- package/dist/server/vision-bridge.js +0 -27
- package/dist/server/wait-subscription-scan.js +13 -115
- package/dist/server/webui-context.js +2 -87
- package/dist/server/workspace-handle.js +373 -0
- package/dist/server/workspace-snapshot.js +7 -113
- package/dist/server/worktree-service.js +2 -53
- package/dist/server/worktree-tool.js +0 -11
- package/dist/server/ws-client-id.js +0 -18
- package/dist/server/ws-pending-queue.js +0 -7
- package/dist/server/ws-unknown-types.js +0 -17
- package/docs/README.md +24 -17
- package/docs/architecture-plugins.md +55 -6
- package/docs/device-center.md +57 -23
- package/docs/device-desktop.md +3 -3
- package/docs/group-orchestration.md +142 -0
- package/docs/hub-upgrade-release-testing.md +46 -0
- package/extensions/webui.ts +3 -74
- package/package.json +9 -6
- package/plugin-sdk/README.md +22 -8
- package/plugin-sdk/client-utils.mjs +0 -7
- package/plugin-sdk/client.d.ts +26 -0
- package/plugin-sdk/client.mjs +52 -0
- package/plugin-sdk/import-check.mjs +4 -51
- package/plugin-sdk/index.d.ts +128 -117
- package/plugin-sdk/index.mjs +2 -687
- package/plugin-sdk/package.json +15 -4
- package/plugin-sdk/ssh-host-trust.mjs +0 -12
- package/plugin-sdk/testing.d.ts +9 -0
- package/plugin-sdk/testing.mjs +511 -0
- package/plugins/catalog.json +52 -4
- package/plugins/superagent/README.md +110 -0
- package/plugins/superagent/client/entry.mjs +21 -0
- package/plugins/superagent/index.mjs +8 -0
- package/plugins/superagent/main.mjs +218 -0
- package/plugins/superagent/manifest.json +15 -0
- package/plugins/superagent/server.mjs +572 -0
- package/plugins/superagent/style.css +167 -0
- package/themes/aetheris.css +1 -31
- package/themes/ayu-light.css +0 -1
- package/themes/bases/flow-base.css +2 -83
- package/themes/bases/obsidian-base.css +2 -37
- package/themes/bases/statusbar-flat-base.css +0 -1
- package/themes/bases/zhujian-base.css +0 -63
- package/themes/bases/zhupi-base.css +0 -64
- package/themes/catppuccin-latte.css +0 -1
- package/themes/catppuccin.css +0 -1
- package/themes/claude-code-dark.css +0 -1
- package/themes/codex.css +0 -1
- package/themes/dark-teal.css +22 -54
- package/themes/everforest-light.css +0 -1
- package/themes/flow-cristallo.css +160 -0
- package/themes/flow-ink.css +160 -0
- package/themes/flow-light.css +1 -10
- package/themes/flow-obsidian.css +160 -0
- package/themes/flow-zurich.css +160 -0
- package/themes/flow.css +1 -9
- package/themes/geist.css +0 -1
- package/themes/gruvbox-light.css +0 -1
- package/themes/kanagawa-lotus.css +0 -1
- package/themes/md-preview.css +1 -2
- package/themes/mist.css +0 -1
- package/themes/nord.css +0 -1
- package/themes/one-dark.css +0 -1
- package/themes/paper.css +0 -1
- package/themes/rose-pine-dawn.css +0 -1
- package/themes/sakura.css +0 -1
- package/themes/solarized-light.css +0 -1
- package/themes/tokyo-night.css +0 -1
- package/themes/translucent.css +4 -35
- package/themes/transparent.css +4 -41
- package/themes/vs-code-dark.css +0 -1
- package/themes/wallpaper-flow.css +3 -17
- package/themes/wallpaper-obsidian.css +1 -4
- package/themes/white.css +0 -1
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/{BgTasksModal-BDoOpj-F.js → BgTasksModal-D-x7kA63.js} +1 -1
- package/web/dist/assets/CanvasStudio-CAWcs9tm.js +1579 -0
- package/web/dist/assets/DeviceCenter-Dc0whRcu.js +3 -0
- package/web/dist/assets/DeviceExecutionSettings-BoX7-0h7.js +1 -0
- package/web/dist/assets/DeviceGroups-C_fZMNeK.js +1 -0
- package/web/dist/assets/{Dropdown-C4LIhshN.js → Dropdown-CTgVLUbp.js} +1 -1
- package/web/dist/assets/FilePreview-C6W0PvaK.js +2 -0
- package/web/dist/assets/GlobalSearchModal-HR9LSspC.js +1 -0
- package/web/dist/assets/GroupConversation-C81YjF2C.js +61 -0
- package/web/dist/assets/GroupWorkItems-BIvZtr10.js +1 -0
- package/web/dist/assets/{HintTip-c6d0TJoh.js → HintTip-Da6qc566.js} +1 -1
- package/web/dist/assets/ModelConfigModal-DhSyuIuV.js +2 -0
- package/web/dist/assets/NativeCliPanel-CU1rZmyu.js +5 -0
- package/web/dist/assets/{PiSetupModal-BmMrrgB9.js → PiSetupModal-DZKY5Wiw.js} +1 -1
- package/web/dist/assets/ProviderOAuthControls-CIL85nA7.js +1 -0
- package/web/dist/assets/SCMPanel-CuEgzAlO.js +2 -0
- package/web/dist/assets/SettingsModal-Cdu5h29p.js +33 -0
- package/web/dist/assets/TermXterm-Bt5WKAxP.js +3 -0
- package/web/dist/assets/TerminalPanel-BCIBV8se.js +1 -0
- package/web/dist/assets/TuiOverlayModal-3NDd9T97.js +1 -0
- package/web/dist/assets/app-globals-CZjFtI4F.js +129 -0
- package/web/dist/assets/canvas-client-WkhM55mR.js +1 -0
- package/web/dist/assets/composer-bridge-CImnjDHq.js +1 -0
- package/web/dist/assets/desktop-B8NZ3KW-.js +1 -0
- package/web/dist/assets/index-CQc3VrWa.css +1 -0
- package/web/dist/assets/index-D_AGu4Zv.js +404 -0
- package/web/dist/assets/plugin-host-uqZGpvCs.js +1 -0
- package/web/dist/assets/{remote-ssh-client-CfYSMEZg.js → remote-ssh-client-Cdf-cTUe.js} +1 -1
- package/web/dist/assets/theme-DGL7hLUs.js +1 -0
- package/web/dist/index.html +12 -11
- package/web/dist/sw.js +15 -61
- package/web/public/sw.js +14 -60
- package/dist/gh-comment-781.md +0 -5
- package/dist/server/device-center/local-page.js +0 -17
- package/dist/server/device-center/smoke-preview.js +0 -3
- package/dist/server/durable/durable-capabilities.js +0 -11
- package/dist/server/markers/builtins/services.js +0 -123
- package/dist/server/markers/builtins/todo.js +0 -189
- package/dist/server/markers-list-tool.js +0 -34
- package/dist/server/orchestrator.js +0 -109
- package/dist/server/patch-turn-end-boundary.js +0 -77
- package/dist/server/system-prompt-soul.js +0 -41
- package/dist/server/univer-service.js +0 -448
- package/dist/server/universal/drivers/dsh-driver.js +0 -379
- package/dist/test-artifact.md +0 -9
- package/dist/test-preview-modal.md +0 -11
- package/dist/test-report.html +0 -20
- package/web/dist/assets/BgTasksModal-C0i3O1FT.js +0 -1
- package/web/dist/assets/CanvasStudio-B8thymBN.js +0 -1579
- package/web/dist/assets/CanvasStudio-zSxyIx1R.js +0 -1579
- package/web/dist/assets/DeviceCenter-DfAHKcid.js +0 -3
- package/web/dist/assets/DeviceCenter-ydvOTlzE.js +0 -3
- package/web/dist/assets/DeviceExecutionSettings-q5Ik8oXg.js +0 -1
- package/web/dist/assets/DeviceGroups-CI14_SRb.js +0 -1
- package/web/dist/assets/DeviceGroups-DvsB5IEU.js +0 -1
- package/web/dist/assets/FilePreview-BgGongmv.js +0 -2
- package/web/dist/assets/FilePreview-D4NrhF-U.js +0 -2
- package/web/dist/assets/GlobalSearchModal-BWgU8yPd.js +0 -1
- package/web/dist/assets/GlobalSearchModal-F7fNimKk.js +0 -1
- package/web/dist/assets/GroupConversation-Dh71Pdb-.js +0 -17
- package/web/dist/assets/GroupConversation-ZK3nRmNm.js +0 -17
- package/web/dist/assets/ModelConfigModal-YVEgyy34.js +0 -2
- package/web/dist/assets/ModelConfigModal-vWtg3srp.js +0 -2
- package/web/dist/assets/ProviderOAuthControls-BGSBIKD7.js +0 -1
- package/web/dist/assets/SCMPanel-B8_EDxNr.js +0 -2
- package/web/dist/assets/SCMPanel-BU58qk3T.js +0 -2
- package/web/dist/assets/SettingsModal-CMUybq3J.js +0 -32
- package/web/dist/assets/SettingsModal-OBmGTh-5.js +0 -32
- package/web/dist/assets/TerminalPanel-0CYvD72B.js +0 -3
- package/web/dist/assets/TerminalPanel-DDavKvFr.js +0 -3
- package/web/dist/assets/TuiOverlayModal-BsA-QTvN.js +0 -1
- package/web/dist/assets/TuiOverlayModal-DzoVQBuG.js +0 -1
- package/web/dist/assets/app-globals-CZxzGvIo.js +0 -123
- package/web/dist/assets/canvas-client-CUnXlQYX.js +0 -1
- package/web/dist/assets/desktop-aAKpvKJV.js +0 -1
- package/web/dist/assets/index-C6DwztqE.css +0 -1
- package/web/dist/assets/index-CuN802Sj.js +0 -93
- package/web/dist/assets/index-EH5Fw9fa.js +0 -93
- package/web/dist/assets/plugin-host-BRWib9DF.js +0 -1
- package/web/dist/assets/theme-D2l_mLNo.js +0 -1
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { resolveModelReasoningSpec } from "./reasoning-registry.js";
|
|
2
2
|
const t = (lang, zh, en) => (lang === "zh" ? zh : en);
|
|
3
|
-
/** 反代路由档位后缀(只在精确匹配失败后剥离;-pro/-flash/-lite 等真实
|
|
4
|
-
* 家族区分绝不在此列)。 */
|
|
5
3
|
const TIER_SUFFIXES = ["-thinking", "-high", "-low", "-max", "-preview", "-latest", "-exp"];
|
|
6
|
-
/** 小写 + 下划线转横线 + 去 provider 前缀(a/b → b)。 */
|
|
7
4
|
export function normalizeModelId(id) {
|
|
8
5
|
let s = id.trim().toLowerCase().replace(/_/g, "-");
|
|
9
6
|
const slash = s.lastIndexOf("/");
|
|
@@ -11,7 +8,6 @@ export function normalizeModelId(id) {
|
|
|
11
8
|
s = s.slice(slash + 1);
|
|
12
9
|
return s;
|
|
13
10
|
}
|
|
14
|
-
/** 剥离路由档位与日期后缀(-0813 / -20250929),精确匹配失败后的回退用。 */
|
|
15
11
|
export function stripTierSuffix(id) {
|
|
16
12
|
let s = normalizeModelId(id);
|
|
17
13
|
for (let i = 0; i < 3; i++) {
|
|
@@ -47,7 +43,6 @@ export function buildIndex(models) {
|
|
|
47
43
|
}
|
|
48
44
|
return { byId, byName, all: models };
|
|
49
45
|
}
|
|
50
|
-
/** OpenRouter /api/v1/models → CatalogModel[](缺字段即缺席,不编造)。 */
|
|
51
46
|
export function parseOpenRouterCatalog(json) {
|
|
52
47
|
const data = json?.data;
|
|
53
48
|
if (!Array.isArray(data))
|
|
@@ -59,8 +54,6 @@ export function parseOpenRouterCatalog(json) {
|
|
|
59
54
|
continue;
|
|
60
55
|
const norm = normalizeModelId(r.id);
|
|
61
56
|
const slash = norm.lastIndexOf("/");
|
|
62
|
-
// OpenRouter id 形如 anthropic/claude-sonnet-4-5(normalize 已去前缀,
|
|
63
|
-
// provider 从原始 id 取)。
|
|
64
57
|
const raw = r.id.trim();
|
|
65
58
|
const rawSlash = raw.lastIndexOf("/");
|
|
66
59
|
const provider = rawSlash >= 0 ? raw.slice(0, rawSlash).toLowerCase() : "";
|
|
@@ -87,7 +80,6 @@ export function parseOpenRouterCatalog(json) {
|
|
|
87
80
|
}
|
|
88
81
|
return out;
|
|
89
82
|
}
|
|
90
|
-
/** models.dev /api.json → CatalogModel[]({ provider: { models: {...} } })。 */
|
|
91
83
|
export function parseModelsDevCatalog(json) {
|
|
92
84
|
const root = (json ?? {});
|
|
93
85
|
const out = [];
|
|
@@ -157,9 +149,6 @@ async function fetchJson(fetchFn, url, maxBytes, timeoutMs, signal) {
|
|
|
157
149
|
signal.removeEventListener("abort", onAbort);
|
|
158
150
|
}
|
|
159
151
|
}
|
|
160
|
-
// 手写 TTL 缓存而非通用 memoize:双键(openrouter/modelsdev)共享一个 Map,
|
|
161
|
-
// 且 compute 是 async fetch——单值同步的 memoizeWithTtl 覆盖不了(issue #470 处置说明)。
|
|
162
|
-
/** 目录抓取缓存(24h TTL,进程内;首跑后无感)。 */
|
|
163
152
|
const catalogCache = new Map();
|
|
164
153
|
const CATALOG_TTL_MS = 24 * 3600 * 1000;
|
|
165
154
|
export async function getOpenRouterCatalog(fetchFn = fetch, signal) {
|
|
@@ -178,7 +167,6 @@ export async function getModelsDevCatalog(fetchFn = fetch, signal) {
|
|
|
178
167
|
catalogCache.set("modelsdev", { at: Date.now(), data });
|
|
179
168
|
return data;
|
|
180
169
|
}
|
|
181
|
-
/** 从网页正文提取参数(hint URL 兜底;只认上下文/输出上限/识图,不认推理)。 */
|
|
182
170
|
export function extractParamsFromHtml(html) {
|
|
183
171
|
const text = html
|
|
184
172
|
.replace(/<script[\s\S]*?<\/script>/gi, " ")
|
|
@@ -248,7 +236,6 @@ async function fetchPageText(fetchFn, url, signal) {
|
|
|
248
236
|
signal.removeEventListener("abort", onAbort);
|
|
249
237
|
}
|
|
250
238
|
}
|
|
251
|
-
/** 单个 id 在给定索引里的精确/别名命中(exact → normalized)。 */
|
|
252
239
|
function lookupIndex(norm, index) {
|
|
253
240
|
const exact = index.byId.get(norm);
|
|
254
241
|
if (exact?.length)
|
|
@@ -264,7 +251,6 @@ function lookupIndex(norm, index) {
|
|
|
264
251
|
return { model: nameHit[0], matchType: "exact" };
|
|
265
252
|
return null;
|
|
266
253
|
}
|
|
267
|
-
/** 家族候选(只做建议,不自动填):family 字符串与 id 互含。 */
|
|
268
254
|
function familySuggestions(norm, indexes, cap = 6) {
|
|
269
255
|
const seen = new Set();
|
|
270
256
|
const out = [];
|
|
@@ -304,7 +290,6 @@ function toResult(lang, id, model, source, matchType) {
|
|
|
304
290
|
function isUrl(s) {
|
|
305
291
|
return /^https?:\/\//i.test(s.trim());
|
|
306
292
|
}
|
|
307
|
-
/** 批量补参数:hint(目录 id / URL)优先,否则 OpenRouter → models.dev 自动匹配。 */
|
|
308
293
|
export async function enrichBatch(ids, hints, opts = {}) {
|
|
309
294
|
const lang = opts.lang ?? "en";
|
|
310
295
|
const fetchFn = opts.fetchFn ?? fetch;
|
|
@@ -366,7 +351,6 @@ export async function enrichBatch(ids, hints, opts = {}) {
|
|
|
366
351
|
};
|
|
367
352
|
const indexes = () => (mdIndex ? [orIndex, mdIndex] : [orIndex]);
|
|
368
353
|
if (!opts.catalogs && orModels.length === 0) {
|
|
369
|
-
// 主源不可达时仍试一次辅源;都空才报错。
|
|
370
354
|
await ensureMd();
|
|
371
355
|
if ((mdModels ?? []).length === 0) {
|
|
372
356
|
throw new Error(t(lang, "参考源不可达(OpenRouter / models.dev),请检查网络后重试", "Reference catalogs unreachable (OpenRouter / models.dev); check your network and retry"));
|
|
@@ -385,7 +369,6 @@ export async function enrichBatch(ids, hints, opts = {}) {
|
|
|
385
369
|
});
|
|
386
370
|
const norm = normalizeModelId(id);
|
|
387
371
|
const hint = (hints[id] ?? hints[norm] ?? "").trim();
|
|
388
|
-
// -- 依据分支 ---------------------------------------------------------
|
|
389
372
|
if (hint) {
|
|
390
373
|
if (isUrl(hint)) {
|
|
391
374
|
opts.onProgress?.({
|
|
@@ -448,11 +431,9 @@ export async function enrichBatch(ids, hints, opts = {}) {
|
|
|
448
431
|
});
|
|
449
432
|
continue;
|
|
450
433
|
}
|
|
451
|
-
// -- 自动匹配分支 -----------------------------------------------------
|
|
452
434
|
const orHit = lookupIndex(norm, orIndex);
|
|
453
435
|
if (orHit) {
|
|
454
436
|
const r = toResult(lang, id, orHit.model, "OpenRouter", orHit.matchType);
|
|
455
|
-
// OpenRouter 的推理信号弱;models.dev 有明确布尔值时补上。
|
|
456
437
|
if (!orHit.model.reasoning) {
|
|
457
438
|
const md = await ensureMd();
|
|
458
439
|
const mdHit = md.byId.get(normalizeModelId(orHit.model.id))?.[0];
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* model-resolver.ts — 跨引擎通用模型与服务商凭据解析器。
|
|
3
|
-
*
|
|
4
|
-
* 职责:
|
|
5
|
-
* 作为宿主级模型配置基础层的只读解析器,统一读取与解析:
|
|
6
|
-
* 1. `<agentDir>/models.json`(自定义服务商、BaseURL、API 类型、模型列表与内置覆盖)
|
|
7
|
-
* 2. `<agentDir>/auth.json`(持久化 API 密钥)
|
|
8
|
-
* 3. `<agentDir>/provider-keys.json`(多密钥管理与当前激活密钥)
|
|
9
|
-
* 4. 进程环境变量回退(如 ANTHROPIC_API_KEY, DEEPSEEK_API_KEY 等)
|
|
10
|
-
*
|
|
11
|
-
* 供 Claude Code CLI 驱动、DSH 引擎与 Pi 引擎统一调用,消除各引擎间的配置孤岛。
|
|
12
|
-
*/
|
|
13
1
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
14
2
|
import { homedir } from "node:os";
|
|
15
3
|
import { join } from "node:path";
|
|
@@ -20,7 +8,6 @@ function defaultAgentDir(agentDir) {
|
|
|
20
8
|
}
|
|
21
9
|
import { stripJsonComments, parseJsonWithComments } from "./json-utils.js";
|
|
22
10
|
export { stripJsonComments, parseJsonWithComments };
|
|
23
|
-
/** 读取并解析 models.json(容忍注释) */
|
|
24
11
|
export function readModelsJson(agentDir) {
|
|
25
12
|
const dir = defaultAgentDir(agentDir);
|
|
26
13
|
const filePath = join(dir, "models.json");
|
|
@@ -35,7 +22,6 @@ export function readModelsJson(agentDir) {
|
|
|
35
22
|
return { providers: {} };
|
|
36
23
|
}
|
|
37
24
|
}
|
|
38
|
-
/** 读取并解析 auth.json */
|
|
39
25
|
export function readAuthJson(agentDir) {
|
|
40
26
|
const dir = defaultAgentDir(agentDir);
|
|
41
27
|
const filePath = join(dir, "auth.json");
|
|
@@ -49,7 +35,6 @@ export function readAuthJson(agentDir) {
|
|
|
49
35
|
return {};
|
|
50
36
|
}
|
|
51
37
|
}
|
|
52
|
-
/** 读取并解析 provider-keys.json */
|
|
53
38
|
export function readProviderKeysJson(agentDir) {
|
|
54
39
|
const dir = defaultAgentDir(agentDir);
|
|
55
40
|
const filePath = join(dir, "provider-keys.json");
|
|
@@ -63,10 +48,6 @@ export function readProviderKeysJson(agentDir) {
|
|
|
63
48
|
return {};
|
|
64
49
|
}
|
|
65
50
|
}
|
|
66
|
-
/**
|
|
67
|
-
* 为指定 provider 解析完整凭据(BaseURL、API Key、API 类型、自定义 Headers)。
|
|
68
|
-
* 优先级:models.json 明确定义 > provider-keys.json 激活密钥 > auth.json > 环境变量。
|
|
69
|
-
*/
|
|
70
51
|
export function resolveProviderCredential(agentDir, providerId) {
|
|
71
52
|
const dir = defaultAgentDir(agentDir);
|
|
72
53
|
const pid = providerId.trim();
|
|
@@ -78,7 +59,6 @@ export function resolveProviderCredential(agentDir, providerId) {
|
|
|
78
59
|
const headers = prov?.headers && typeof prov.headers === "object" && !Array.isArray(prov.headers)
|
|
79
60
|
? prov.headers
|
|
80
61
|
: undefined;
|
|
81
|
-
// 1. 若 models.json 未显式配置 apiKey,则从 provider-keys.json 取激活密钥
|
|
82
62
|
if (!apiKey) {
|
|
83
63
|
const multiKeys = readProviderKeysJson(dir);
|
|
84
64
|
const entry = multiKeys[pid];
|
|
@@ -87,7 +67,6 @@ export function resolveProviderCredential(agentDir, providerId) {
|
|
|
87
67
|
apiKey = active?.apiKey ?? entry.keys[0]?.apiKey;
|
|
88
68
|
}
|
|
89
69
|
}
|
|
90
|
-
// 2. 若仍无 apiKey,回落到 auth.json
|
|
91
70
|
if (!apiKey) {
|
|
92
71
|
const auth = readAuthJson(dir);
|
|
93
72
|
const authEntry = auth[pid];
|
|
@@ -100,7 +79,6 @@ export function resolveProviderCredential(agentDir, providerId) {
|
|
|
100
79
|
apiKey = authEntry.trim();
|
|
101
80
|
}
|
|
102
81
|
}
|
|
103
|
-
// 3. 环境变量兜底
|
|
104
82
|
if (!apiKey) {
|
|
105
83
|
const normPid = pid.toLowerCase();
|
|
106
84
|
if (normPid === "anthropic" || normPid.includes("claude")) {
|
|
@@ -139,10 +117,6 @@ export function resolveProviderCredential(agentDir, providerId) {
|
|
|
139
117
|
headers,
|
|
140
118
|
};
|
|
141
119
|
}
|
|
142
|
-
/**
|
|
143
|
-
* 从 models.json 中列出所有自定义模型。
|
|
144
|
-
* 可选 filter 谓词过滤 API 类型(如只挑 Claude 兼容的)。
|
|
145
|
-
*/
|
|
146
120
|
export function listCustomModelsFromConfig(agentDir, filter) {
|
|
147
121
|
const dir = defaultAgentDir(agentDir);
|
|
148
122
|
const { providers } = readModelsJson(dir);
|
|
@@ -178,10 +152,6 @@ export function listCustomModelsFromConfig(agentDir, filter) {
|
|
|
178
152
|
}
|
|
179
153
|
return results;
|
|
180
154
|
}
|
|
181
|
-
/**
|
|
182
|
-
* 依据实际指定的 api 字段(或官方内置 Provider/模型特征)解析真实通信协议类型。
|
|
183
|
-
* 核心原则:优先遵循显式指定的 api 协议;未显式指定时,根据 providerId 与 modelId 特征合理推导默认协议。
|
|
184
|
-
*/
|
|
185
155
|
export function resolveModelProtocol(api, providerId, modelId) {
|
|
186
156
|
const rawApi = (api ?? "").trim().toLowerCase();
|
|
187
157
|
if (rawApi) {
|
|
@@ -198,7 +168,6 @@ export function resolveModelProtocol(api, providerId, modelId) {
|
|
|
198
168
|
}
|
|
199
169
|
const pid = (providerId ?? "").trim().toLowerCase();
|
|
200
170
|
const mid = (modelId ?? "").trim().toLowerCase();
|
|
201
|
-
// 若未显式配置 api,优先根据 providerId 的命名特征识别协议:
|
|
202
171
|
if (pid.includes("openai") ||
|
|
203
172
|
pid.includes("deepseek") ||
|
|
204
173
|
pid.includes("groq") ||
|
|
@@ -218,42 +187,26 @@ export function resolveModelProtocol(api, providerId, modelId) {
|
|
|
218
187
|
return "ollama";
|
|
219
188
|
if (pid === "bedrock")
|
|
220
189
|
return "bedrock";
|
|
221
|
-
// 再次依据 modelId 的前缀特征辅助推导默认协议:
|
|
222
190
|
if (mid.startsWith("claude")) {
|
|
223
191
|
return "anthropic-messages";
|
|
224
192
|
}
|
|
225
193
|
if (mid.startsWith("gemini")) {
|
|
226
194
|
return "google-generative-ai";
|
|
227
195
|
}
|
|
228
|
-
// 其余绝大多数官方及自定义 Provider 均遵循 OpenAI 协议规范
|
|
229
196
|
return "openai-completions";
|
|
230
197
|
}
|
|
231
|
-
/**
|
|
232
|
-
* 严格按照实际的通信协议类型(Protocol Type)判断目标引擎是否支持。
|
|
233
|
-
* 核心原则:按协议本身做过滤,严禁无依据随意过滤。
|
|
234
|
-
*
|
|
235
|
-
* 1. Pi 原生引擎:支持全部协议全集;
|
|
236
|
-
* 2. DSH 引擎:仅支持 OpenAI 兼容协议(openai-completions / openai-responses),严格拒绝 Anthropic Messages 协议等;
|
|
237
|
-
* 3. Claude Code 引擎:仅支持 Anthropic Messages 协议(无论模型名称叫什么,只要走 Anthropic 协议即可);
|
|
238
|
-
* 4. Durable 引擎:由 @earendil-works/pi-ai 驱动,支持主流开放标准协议(OpenAI, Anthropic, Google 等)。
|
|
239
|
-
*/
|
|
240
198
|
export function isProtocolSupportedByEngine(engine, api, providerId, modelId) {
|
|
241
199
|
const normEngine = engine.toLowerCase().trim();
|
|
242
200
|
const protocol = resolveModelProtocol(api, providerId, modelId);
|
|
243
|
-
// 1. Pi 原生引擎支持全协议全集
|
|
244
201
|
if (normEngine === "pi") {
|
|
245
202
|
return true;
|
|
246
203
|
}
|
|
247
|
-
// 2. DSH 引擎:仅支持 OpenAI 兼容协议(openai-completions / openai-responses)
|
|
248
|
-
// 严格不支持 Anthropic Messages 协议、Google Generative AI 协议等!
|
|
249
204
|
if (normEngine === "dsh") {
|
|
250
205
|
return protocol === "openai-completions" || protocol === "openai-responses";
|
|
251
206
|
}
|
|
252
|
-
// 3. Claude Code 引擎:仅支持 Anthropic Messages 协议
|
|
253
207
|
if (normEngine === "claude") {
|
|
254
208
|
return protocol === "anthropic-messages";
|
|
255
209
|
}
|
|
256
|
-
// 4. Durable 引擎:基于 @earendil-works/pi-ai,支持主流标准协议
|
|
257
210
|
if (normEngine === "durable") {
|
|
258
211
|
return (protocol === "openai-completions" ||
|
|
259
212
|
protocol === "openai-responses" ||
|
|
@@ -263,7 +216,6 @@ export function isProtocolSupportedByEngine(engine, api, providerId, modelId) {
|
|
|
263
216
|
}
|
|
264
217
|
return true;
|
|
265
218
|
}
|
|
266
|
-
/** 读取全局 settings.json */
|
|
267
219
|
export function readGlobalSettings(agentDir) {
|
|
268
220
|
const dir = defaultAgentDir(agentDir);
|
|
269
221
|
const filePath = join(dir, "settings.json");
|
|
@@ -277,17 +229,14 @@ export function readGlobalSettings(agentDir) {
|
|
|
277
229
|
return {};
|
|
278
230
|
}
|
|
279
231
|
}
|
|
280
|
-
/** 获取特定模型在 settings.json 中的思考强度记忆或全局默认思考强度 */
|
|
281
232
|
export function getModelThinkingLevelFromSettings(modelId, agentDir) {
|
|
282
233
|
if (!modelId)
|
|
283
234
|
return undefined;
|
|
284
235
|
const settings = readGlobalSettings(agentDir);
|
|
285
236
|
const levels = settings.modelThinkingLevels;
|
|
286
237
|
if (levels && typeof levels === "object") {
|
|
287
|
-
// 1. 尝试全量匹配 "provider/model"
|
|
288
238
|
if (levels[modelId])
|
|
289
239
|
return levels[modelId];
|
|
290
|
-
// 2. 尝试裸 modelId 匹配
|
|
291
240
|
const slashIdx = modelId.indexOf("/");
|
|
292
241
|
const bareId = slashIdx >= 0 ? modelId.slice(slashIdx + 1) : modelId;
|
|
293
242
|
for (const [k, v] of Object.entries(levels)) {
|
|
@@ -298,7 +247,6 @@ export function getModelThinkingLevelFromSettings(modelId, agentDir) {
|
|
|
298
247
|
}
|
|
299
248
|
return settings.defaultThinkingLevel;
|
|
300
249
|
}
|
|
301
|
-
/** 保存特定模型的思考强度到 settings.json */
|
|
302
250
|
export function saveModelThinkingLevelToSettings(modelId, level, agentDir) {
|
|
303
251
|
if (!modelId || !level)
|
|
304
252
|
return;
|
|
@@ -310,9 +258,7 @@ export function saveModelThinkingLevelToSettings(modelId, level, agentDir) {
|
|
|
310
258
|
try {
|
|
311
259
|
current = JSON.parse(stripJsonComments(readFileSync(filePath, "utf8")));
|
|
312
260
|
}
|
|
313
|
-
catch {
|
|
314
|
-
/* start fresh */
|
|
315
|
-
}
|
|
261
|
+
catch { }
|
|
316
262
|
}
|
|
317
263
|
const existingLevels = (current.modelThinkingLevels && typeof current.modelThinkingLevels === "object"
|
|
318
264
|
? { ...current.modelThinkingLevels }
|
|
@@ -322,13 +268,8 @@ export function saveModelThinkingLevelToSettings(modelId, level, agentDir) {
|
|
|
322
268
|
const formatted = JSON.stringify(current, null, 2);
|
|
323
269
|
writeFileSync(filePath, formatted, "utf8");
|
|
324
270
|
}
|
|
325
|
-
catch {
|
|
326
|
-
/* best effort */
|
|
327
|
-
}
|
|
271
|
+
catch { }
|
|
328
272
|
}
|
|
329
|
-
/**
|
|
330
|
-
* 结构化入参的协议校验重载包装(兼容既有调用点)。
|
|
331
|
-
*/
|
|
332
273
|
export function isModelProtocolSupportedByEngine(engine, meta) {
|
|
333
274
|
return isProtocolSupportedByEngine(engine, meta.api, meta.providerId, meta.modelId);
|
|
334
275
|
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { accessSync, constants, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { posix, win32 } from "node:path";
|
|
4
|
+
function versions(directory) {
|
|
5
|
+
try {
|
|
6
|
+
return readdirSync(directory, { withFileTypes: true })
|
|
7
|
+
.filter((entry) => entry.isDirectory() || entry.isSymbolicLink())
|
|
8
|
+
.map((entry) => entry.name)
|
|
9
|
+
.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }));
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function* installDirectories(options) {
|
|
16
|
+
const windows = (options.platform ?? process.platform) === "win32";
|
|
17
|
+
const path = windows ? win32 : posix;
|
|
18
|
+
const env = options.env ?? process.env;
|
|
19
|
+
const get = (name) => windows ? Object.entries(env).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1] : env[name];
|
|
20
|
+
const home = options.homeDir ?? (windows ? get("USERPROFILE") || get("HOME") : get("HOME")) ?? homedir();
|
|
21
|
+
const localData = get("LOCALAPPDATA");
|
|
22
|
+
const roamingData = get("APPDATA");
|
|
23
|
+
const xdgData = get("XDG_DATA_HOME") || path.join(home, ".local", "share");
|
|
24
|
+
const prefix = get("npm_config_prefix") || get("NPM_CONFIG_PREFIX") || get("PREFIX");
|
|
25
|
+
const candidates = [
|
|
26
|
+
path.join(home, ".local", "bin"),
|
|
27
|
+
path.join(home, "bin"),
|
|
28
|
+
path.join(home, ".claude", "local"),
|
|
29
|
+
path.dirname(options.nodeExecutable ?? process.execPath),
|
|
30
|
+
prefix && (windows ? prefix : path.join(prefix, "bin")),
|
|
31
|
+
roamingData && path.join(roamingData, "npm"),
|
|
32
|
+
get("PNPM_HOME"),
|
|
33
|
+
get("NVM_BIN"),
|
|
34
|
+
get("NVM_SYMLINK"),
|
|
35
|
+
get("FNM_MULTISHELL_PATH"),
|
|
36
|
+
path.join(get("VOLTA_HOME") || path.join(home, ".volta"), "bin"),
|
|
37
|
+
path.join(get("BUN_INSTALL") || path.join(home, ".bun"), "bin"),
|
|
38
|
+
path.join(home, ".npm-global", "bin"),
|
|
39
|
+
path.join(home, ".config", "yarn", "global", "node_modules", ".bin"),
|
|
40
|
+
path.join(home, ".yarn", "bin"),
|
|
41
|
+
path.join(home, ".pnpm-global", "bin"),
|
|
42
|
+
path.join(home, "Library", "pnpm"),
|
|
43
|
+
path.join(xdgData, "fnm", "current", "bin"),
|
|
44
|
+
path.join(home, ".cargo", "bin"),
|
|
45
|
+
windows ? path.join(home, "scoop", "shims") : path.join(home, ".local", "share", "pnpm"),
|
|
46
|
+
windows && localData && path.join(localData, "pnpm"),
|
|
47
|
+
windows && path.join(localData || path.join(home, "AppData", "Local"), "agy", "bin"),
|
|
48
|
+
...(!windows ? ["/opt/homebrew/bin", "/usr/local/bin", "/usr/bin", "/bin", "/snap/bin"] : []),
|
|
49
|
+
];
|
|
50
|
+
for (const directory of candidates)
|
|
51
|
+
if (directory)
|
|
52
|
+
yield directory;
|
|
53
|
+
const fnmRoots = new Set([
|
|
54
|
+
get("FNM_DIR"),
|
|
55
|
+
roamingData && path.join(roamingData, "fnm"),
|
|
56
|
+
localData && path.join(localData, "fnm"),
|
|
57
|
+
path.join(xdgData, "fnm"),
|
|
58
|
+
path.join(home, ".fnm"),
|
|
59
|
+
].filter((directory) => !!directory));
|
|
60
|
+
for (const fnm of fnmRoots) {
|
|
61
|
+
const store = path.join(fnm, "node-versions");
|
|
62
|
+
for (const version of versions(store)) {
|
|
63
|
+
const installation = path.join(store, version, "installation");
|
|
64
|
+
yield windows ? installation : path.join(installation, "bin");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const nvm = windows ? get("NVM_HOME") : path.join(get("NVM_DIR") || path.join(home, ".nvm"), "versions", "node");
|
|
68
|
+
if (nvm)
|
|
69
|
+
for (const version of versions(nvm))
|
|
70
|
+
yield windows ? path.join(nvm, version) : path.join(nvm, version, "bin");
|
|
71
|
+
}
|
|
72
|
+
export function findNativeCliExecutable(executable, options = {}) {
|
|
73
|
+
const windows = (options.platform ?? process.platform) === "win32";
|
|
74
|
+
const path = windows ? win32 : posix;
|
|
75
|
+
const cwd = options.cwd ?? process.cwd();
|
|
76
|
+
const env = options.env ?? process.env;
|
|
77
|
+
const pathValue = windows ? Object.entries(env).find(([key]) => key.toLowerCase() === "path")?.[1] : env.PATH;
|
|
78
|
+
const hasPath = path.isAbsolute(executable) || (windows ? /[\\/]/ : /\//).test(executable);
|
|
79
|
+
const extensions = windows && !path.extname(executable) ? [".exe", ".com", ".cmd", ".bat"] : [""];
|
|
80
|
+
const checked = new Set();
|
|
81
|
+
const check = (base) => {
|
|
82
|
+
for (const extension of extensions) {
|
|
83
|
+
const candidate = base + extension;
|
|
84
|
+
const key = windows ? candidate.toLowerCase() : candidate;
|
|
85
|
+
if (checked.has(key))
|
|
86
|
+
continue;
|
|
87
|
+
checked.add(key);
|
|
88
|
+
try {
|
|
89
|
+
if (!statSync(candidate).isFile())
|
|
90
|
+
continue;
|
|
91
|
+
if (!windows)
|
|
92
|
+
accessSync(candidate, constants.X_OK);
|
|
93
|
+
return candidate;
|
|
94
|
+
}
|
|
95
|
+
catch { }
|
|
96
|
+
}
|
|
97
|
+
return undefined;
|
|
98
|
+
};
|
|
99
|
+
if (hasPath)
|
|
100
|
+
return check(path.resolve(cwd, executable));
|
|
101
|
+
for (const entry of (pathValue ?? "").split(windows ? ";" : ":").filter(Boolean)) {
|
|
102
|
+
const directory = windows ? entry.replace(/^"(.*)"$/, "$1") : entry;
|
|
103
|
+
const found = check(path.resolve(cwd, directory, executable));
|
|
104
|
+
if (found)
|
|
105
|
+
return found;
|
|
106
|
+
}
|
|
107
|
+
if (options.autoDetect) {
|
|
108
|
+
for (const directory of installDirectories(options)) {
|
|
109
|
+
const found = check(path.resolve(cwd, directory, executable));
|
|
110
|
+
if (found)
|
|
111
|
+
return found;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { isProtocolSupportedByEngine } from "./model-resolver.js";
|
|
2
|
+
export async function resolveNativeCliModelConnection(config, runtime) {
|
|
3
|
+
if (!runtime || !config.model || (config.preset !== "claude" && config.preset !== "codex"))
|
|
4
|
+
return undefined;
|
|
5
|
+
const model = runtime.getModel(config.model.provider, config.model.id);
|
|
6
|
+
if (!model)
|
|
7
|
+
throw new Error(`Inherited CLI model is unavailable: ${config.model.provider}/${config.model.id}`);
|
|
8
|
+
if (!isProtocolSupportedByEngine(config.preset, model.api))
|
|
9
|
+
throw new Error(`Inherited model protocol is not supported by ${config.preset}: ${model.api}`);
|
|
10
|
+
if (runtime.isUsingOAuth(model.provider))
|
|
11
|
+
return undefined;
|
|
12
|
+
const result = await runtime.getAuth(model);
|
|
13
|
+
const fallback = runtime.getCompatibilityRequestConfig(model);
|
|
14
|
+
const apiKey = result?.auth.apiKey;
|
|
15
|
+
if (!apiKey)
|
|
16
|
+
return undefined;
|
|
17
|
+
return {
|
|
18
|
+
baseUrl: result.auth.baseUrl ?? model.baseUrl,
|
|
19
|
+
apiKey,
|
|
20
|
+
headers: Object.fromEntries(Object.entries({ ...fallback.headers, ...result.auth.headers }).filter((entry) => typeof entry[1] === "string")),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function nativeCliModelLaunch(config, connection, parentEnv) {
|
|
24
|
+
if (!config.model || !connection || (config.preset !== "claude" && config.preset !== "codex"))
|
|
25
|
+
return { args: [] };
|
|
26
|
+
const env = { ...parentEnv };
|
|
27
|
+
if (config.preset === "claude") {
|
|
28
|
+
const authVariables = [
|
|
29
|
+
"ANTHROPIC_API_KEY",
|
|
30
|
+
"ANTHROPIC_AUTH_TOKEN",
|
|
31
|
+
"CLAUDE_CODE_OAUTH_TOKEN",
|
|
32
|
+
"CLAUDE_CODE_USE_BEDROCK",
|
|
33
|
+
"CLAUDE_CODE_USE_VERTEX",
|
|
34
|
+
"CLAUDE_CODE_USE_FOUNDRY",
|
|
35
|
+
"ANTHROPIC_CUSTOM_HEADERS",
|
|
36
|
+
];
|
|
37
|
+
for (const key of authVariables)
|
|
38
|
+
delete env[key];
|
|
39
|
+
env.ANTHROPIC_BASE_URL = connection.baseUrl;
|
|
40
|
+
const official = new URL(connection.baseUrl).hostname === "api.anthropic.com";
|
|
41
|
+
env[official ? "ANTHROPIC_API_KEY" : "ANTHROPIC_AUTH_TOKEN"] = connection.apiKey;
|
|
42
|
+
env.ANTHROPIC_MODEL = config.model.id;
|
|
43
|
+
for (const tier of ["HAIKU", "SONNET", "OPUS"])
|
|
44
|
+
env[`ANTHROPIC_DEFAULT_${tier}_MODEL`] = config.model.id;
|
|
45
|
+
const headers = Object.entries(connection.headers ?? {});
|
|
46
|
+
if (headers.length)
|
|
47
|
+
env.ANTHROPIC_CUSTOM_HEADERS = headers.map(([name, value]) => `${name}: ${value}`).join("\n");
|
|
48
|
+
else
|
|
49
|
+
delete env.ANTHROPIC_CUSTOM_HEADERS;
|
|
50
|
+
return { args: [], env, unsetEnv: authVariables.filter((key) => !Object.hasOwn(env, key)) };
|
|
51
|
+
}
|
|
52
|
+
const provider = "pi_web_ui";
|
|
53
|
+
env.PI_WEB_CLI_API_KEY = connection.apiKey;
|
|
54
|
+
const settings = {
|
|
55
|
+
model_provider: provider,
|
|
56
|
+
[`model_providers.${provider}.name`]: "pi-web-ui",
|
|
57
|
+
[`model_providers.${provider}.base_url`]: connection.baseUrl,
|
|
58
|
+
[`model_providers.${provider}.env_key`]: "PI_WEB_CLI_API_KEY",
|
|
59
|
+
[`model_providers.${provider}.wire_api`]: "responses",
|
|
60
|
+
[`model_providers.${provider}.requires_openai_auth`]: false,
|
|
61
|
+
};
|
|
62
|
+
const envHeaders = Object.entries(connection.headers ?? {}).map(([name, value], index) => {
|
|
63
|
+
const key = `PI_WEB_CLI_HEADER_${index}`;
|
|
64
|
+
env[key] = value;
|
|
65
|
+
return `${JSON.stringify(name)}=${JSON.stringify(key)}`;
|
|
66
|
+
});
|
|
67
|
+
const args = Object.entries(settings).flatMap(([key, value]) => ["-c", `${key}=${JSON.stringify(value)}`]);
|
|
68
|
+
if (envHeaders.length)
|
|
69
|
+
args.push("-c", `model_providers.${provider}.env_http_headers={${envHeaders.join(",")}}`);
|
|
70
|
+
return { args, env };
|
|
71
|
+
}
|