@ljwei-stak/dsh-model-route-bot 0.66.3 → 0.67.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/.dsh-plugin/bot-product.mjs +81 -5
- package/.dsh-plugin/client.js +17490 -1791
- package/README.i18n.yaml +4 -4
- package/README.md +409 -364
- package/README.zh.md +409 -364
- package/apps/integration-client/README.md +31 -7
- package/apps/integration-client/api.mjs +14 -3
- package/apps/integration-client/binding-editor.jsx +308 -109
- package/apps/integration-client/binding-model.mjs +262 -0
- package/apps/integration-client/binding.css +144 -0
- package/apps/integration-client/bot-model-status.mjs +18 -0
- package/apps/integration-client/bot-profile-identity.jsx +197 -0
- package/apps/integration-client/bot-profile.css +57 -0
- package/apps/integration-client/bot-profile.mjs +97 -0
- package/apps/integration-client/bot-settings-dialog.css +18 -0
- package/apps/integration-client/bot-settings-dialog.jsx +111 -0
- package/apps/integration-client/bot-thread-header-bridge.css +20 -0
- package/apps/integration-client/bot-thread-header.jsx +278 -0
- package/apps/integration-client/bot-threads-panel.jsx +378 -0
- package/apps/integration-client/bot-threads.css +169 -0
- package/apps/integration-client/chat-design.mjs +250 -0
- package/apps/integration-client/chat-ui.jsx +175 -0
- package/apps/integration-client/chat.css +477 -0
- package/apps/integration-client/composer-draft-binding.mjs +50 -0
- package/apps/integration-client/composer-draft-bound.jsx +14 -0
- package/apps/integration-client/composer-draft-host.jsx +142 -0
- package/apps/integration-client/composer-draft-session.jsx +287 -0
- package/apps/integration-client/composer-draft-witness.mjs +115 -0
- package/apps/integration-client/composer-draft.css +4 -0
- package/apps/integration-client/composer-draft.mjs +322 -0
- package/apps/integration-client/contact-attention.jsx +54 -0
- package/apps/integration-client/data-panel.jsx +439 -0
- package/apps/integration-client/data.css +69 -0
- package/apps/integration-client/desktop-bridge.mjs +1 -0
- package/apps/integration-client/desktop-http-socket.mjs +49 -0
- package/apps/integration-client/desktop-keyboard.mjs +32 -0
- package/apps/integration-client/desktop-pane.jsx +99 -30
- package/apps/integration-client/desktop-stream.mjs +13 -3
- package/apps/integration-client/desktop-tools.jsx +19 -0
- package/apps/integration-client/desktop-touch.mjs +27 -0
- package/apps/integration-client/desktop.css +41 -0
- package/apps/integration-client/independent-chat-controller.mjs +224 -0
- package/apps/integration-client/independent-chat-entry.jsx +61 -0
- package/apps/integration-client/independent-chat-navigation.mjs +21 -0
- package/apps/integration-client/independent-chat-page.jsx +148 -0
- package/apps/integration-client/independent-chat-rich.jsx +64 -0
- package/apps/integration-client/independent-chat-rich.mjs +30 -0
- package/apps/integration-client/independent-chat.css +73 -0
- package/apps/integration-client/index.jsx +24 -16
- package/apps/integration-client/library-panel.jsx +4 -1
- package/apps/integration-client/licenses/jsqr-1.4.0-LICENSE.txt +202 -0
- package/apps/integration-client/main-route-editor.jsx +94 -0
- package/apps/integration-client/main-route-model.mjs +100 -0
- package/apps/integration-client/model-picker.css +37 -0
- package/apps/integration-client/model-picker.jsx +83 -0
- package/apps/integration-client/native-activity.css +141 -0
- package/apps/integration-client/native-activity.jsx +276 -0
- package/apps/integration-client/native-activity.mjs +384 -0
- package/apps/integration-client/notifications-panel.jsx +186 -0
- package/apps/integration-client/notifications.css +126 -0
- package/apps/integration-client/pairing-qr.jsx +79 -0
- package/apps/integration-client/panels.jsx +126 -115
- package/apps/integration-client/product-slots.jsx +46 -0
- package/apps/integration-client/routine-recorder.mjs +23 -2
- package/apps/integration-client/secure-pairing.jsx +84 -0
- package/apps/integration-client/tasks-panel.jsx +32 -10
- package/apps/integration-client/ui-icons.jsx +17 -0
- package/apps/integration-client/usage-explorer.jsx +43 -0
- package/apps/integration-client/usage-report.mjs +71 -0
- package/apps/integration-client/usage.css +34 -0
- package/apps/integration-client/web-panel-model.mjs +140 -0
- package/apps/integration-client/web-panel-page.jsx +221 -0
- package/apps/integration-client/web-panel-pins-live.jsx +28 -0
- package/apps/integration-client/web-panel.css +139 -0
- package/apps/integration-client/workspace-model.mjs +67 -0
- package/apps/integration-client/workspace-navigation.mjs +56 -0
- package/apps/integration-client/workspace-ui.jsx +173 -0
- package/apps/integration-client/workspace.css +332 -0
- package/modules/bot-runtime/SOURCE.json +176 -50
- package/modules/bot-runtime/index.mjs +169 -13
- package/modules/bot-runtime/product-overlay/OVERLAY.json +128 -2
- package/modules/bot-runtime/product-overlay/base/src/client/header.js +244 -0
- package/modules/bot-runtime/product-overlay/base/src/client/learning-card.js +202 -0
- package/modules/bot-runtime/product-overlay/base/src/client/model-menu.js +371 -0
- package/modules/bot-runtime/product-overlay/base/src/client/secret-card.js +363 -0
- package/modules/bot-runtime/product-overlay/base/src/client/sources.js +68 -0
- package/modules/bot-runtime/product-overlay/base/src/client/turn-error.js +260 -0
- package/modules/bot-runtime/product-overlay/base/src/host/channel.js +647 -0
- package/modules/bot-runtime/product-overlay/base/src/host/memory.js +2050 -0
- package/modules/bot-runtime/product-overlay/base/src/host/models.js +314 -0
- package/modules/bot-runtime/product-overlay/base/src/host/parts.js +1473 -0
- package/modules/bot-runtime/product-overlay/base/src/host/privacy.js +368 -0
- package/modules/bot-runtime/product-overlay/base/src/host/roster.js +776 -0
- package/modules/bot-runtime/product-overlay/base/src/host/store.js +512 -0
- package/modules/bot-runtime/product-overlay/base/src/host/usage.js +653 -0
- package/modules/bot-runtime/product-overlay/patches/src/client/details-drawer.js.patch +48 -2
- package/modules/bot-runtime/product-overlay/patches/src/client/header.js.patch +41 -0
- package/modules/bot-runtime/product-overlay/patches/src/client/index.js.patch +33 -1
- package/modules/bot-runtime/product-overlay/patches/src/client/learning-card.js.patch +20 -0
- package/modules/bot-runtime/product-overlay/patches/src/client/model-menu.js.patch +24 -0
- package/modules/bot-runtime/product-overlay/patches/src/client/secret-card.js.patch +25 -0
- package/modules/bot-runtime/product-overlay/patches/src/client/sources.js.patch +52 -0
- package/modules/bot-runtime/product-overlay/patches/src/client/turn-error.js.patch +23 -0
- package/modules/bot-runtime/product-overlay/patches/src/host/channel.js.patch +46 -0
- package/modules/bot-runtime/product-overlay/patches/src/host/memory.js.patch +11 -0
- package/modules/bot-runtime/product-overlay/patches/src/host/models.js.patch +16 -0
- package/modules/bot-runtime/product-overlay/patches/src/host/parts.js.patch +95 -0
- package/modules/bot-runtime/product-overlay/patches/src/host/privacy.js.patch +11 -0
- package/modules/bot-runtime/product-overlay/patches/src/host/roster.js.patch +145 -0
- package/modules/bot-runtime/product-overlay/patches/src/host/store.js.patch +68 -0
- package/modules/bot-runtime/product-overlay/patches/src/host/usage.js.patch +11 -0
- package/modules/bot-runtime/read-model.mjs +19 -4
- package/modules/bot-runtime/vendor/ds-bot/src/client/details-drawer.js +15 -5
- package/modules/bot-runtime/vendor/ds-bot/src/client/header.js +9 -2
- package/modules/bot-runtime/vendor/ds-bot/src/client/index.js +9 -2
- package/modules/bot-runtime/vendor/ds-bot/src/client/learning-card.js +2 -2
- package/modules/bot-runtime/vendor/ds-bot/src/client/model-menu.js +5 -3
- package/modules/bot-runtime/vendor/ds-bot/src/client/secret-card.js +3 -3
- package/modules/bot-runtime/vendor/ds-bot/src/client/sources.js +25 -2
- package/modules/bot-runtime/vendor/ds-bot/src/client/turn-error.js +3 -2
- package/modules/bot-runtime/vendor/ds-bot/src/host/channel.js +14 -2
- package/modules/bot-runtime/vendor/ds-bot/src/host/memory.js +1 -1
- package/modules/bot-runtime/vendor/ds-bot/src/host/models.js +7 -0
- package/modules/bot-runtime/vendor/ds-bot/src/host/parts.js +26 -9
- package/modules/bot-runtime/vendor/ds-bot/src/host/privacy.js +1 -1
- package/modules/bot-runtime/vendor/ds-bot/src/host/roster.js +112 -3
- package/modules/bot-runtime/vendor/ds-bot/src/host/store.js +34 -1
- package/modules/bot-runtime/vendor/ds-bot/src/host/usage.js +1 -1
- package/modules/independent-runtime/index.mjs +152 -62
- package/modules/independent-runtime/remote-tools.mjs +8 -5
- package/modules/openmaus-protocol/NOTICE +10 -0
- package/modules/openmaus-protocol/README.md +15 -0
- package/modules/openmaus-protocol/SOURCE.json +68 -0
- package/modules/openmaus-protocol/dist/protocol.mjs +1203 -0
- package/modules/openmaus-protocol/index.mjs +1 -0
- package/modules/openmaus-protocol/transport.mjs +77 -0
- package/modules/openmaus-protocol/vendor/LICENSE +202 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/README.md +405 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/credentials.ts +128 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/descriptor.ts +84 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/noise.ts +456 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/phone.ts +104 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/session.ts +417 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/vectors/v1.json +2565 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/vectors/v1.sha256 +1 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/yamux.ts +335 -0
- package/package.json +20 -6
- package/packages/bot-acp/README.md +156 -0
- package/packages/bot-acp/licenses/LICENSE-OpenMausBot +202 -0
- package/packages/bot-acp/licenses/NOTICE.md +27 -0
- package/packages/bot-acp/src/acp-adapter.mjs +795 -0
- package/packages/bot-acp/src/acp-host.mjs +148 -0
- package/packages/bot-acp/src/native-launch.mjs +121 -0
- package/packages/bot-acp/src/permission-policy.mjs +283 -0
- package/packages/bot-acp/src/rpc-codec.mjs +265 -0
- package/packages/bot-acp/src/session-core.mjs +581 -0
- package/packages/bot-acp/src/stdio-rpc.mjs +329 -0
- package/packages/bot-engines/README.md +281 -0
- package/packages/bot-engines/licenses/LICENSE-OpenMausBot +202 -0
- package/packages/bot-engines/licenses/NOTICE.md +32 -0
- package/packages/bot-engines/src/claude-engine.mjs +772 -0
- package/packages/bot-engines/src/claude-llm-adapter.mjs +797 -0
- package/packages/bot-engines/src/claude-llm-turn.mjs +292 -0
- package/packages/bot-engines/src/claude-permission-broker.mjs +130 -0
- package/packages/bot-engines/src/claude-permission-proxy.mjs +87 -0
- package/packages/bot-engines/src/claude-protocol.mjs +177 -0
- package/packages/bot-engines/src/driver-catalog.mjs +334 -0
- package/packages/bot-engines/src/host-loop-request.mjs +95 -0
- package/packages/bot-engines/src/host-registrations.mjs +105 -0
- package/packages/capability-broker/src/cli-bootstrap.mjs +86 -16
- package/packages/capability-broker/src/cli-bridge-response.mjs +80 -0
- package/packages/capability-broker/src/cli-stdio-bridge.mjs +21 -8
- package/packages/cli-runtime/src/codex-session-core.mjs +4 -0
- package/packages/cli-runtime/src/native-cli-output.mjs +57 -0
- package/packages/cli-runtime/src/native-peer.ps1 +51 -3
- package/packages/cli-runtime/src/native-process.mjs +77 -14
- package/packages/model-router-plugin/README.md +3 -3
- package/packages/model-router-plugin/package.json +1 -1
- package/packages/orchestration/src/binding-product.mjs +19 -0
- package/packages/orchestration/src/bot-data-actions.mjs +45 -0
- package/packages/orchestration/src/bot-data-chart.mjs +109 -0
- package/packages/orchestration/src/bot-data-context.mjs +44 -0
- package/packages/orchestration/src/bot-data-engine.mjs +809 -0
- package/packages/orchestration/src/bot-data-io.mjs +186 -0
- package/packages/orchestration/src/bot-data-sql.mjs +195 -0
- package/packages/orchestration/src/bot-data-surface.mjs +144 -0
- package/packages/orchestration/src/bot-data-tools.mjs +68 -0
- package/packages/orchestration/src/bot-data-worker.mjs +228 -0
- package/packages/orchestration/src/bot-independent-execution.mjs +195 -0
- package/packages/orchestration/src/bot-independent-stream.mjs +74 -0
- package/packages/orchestration/src/bot-loop.mjs +152 -19
- package/packages/orchestration/src/bot-notifications.mjs +159 -0
- package/packages/orchestration/src/bot-policy.mjs +43 -4
- package/packages/orchestration/src/bot-profile.mjs +171 -0
- package/packages/orchestration/src/bot-routine.mjs +4 -4
- package/packages/orchestration/src/bot-runtime-assembly.mjs +255 -8
- package/packages/orchestration/src/bot-runtime-switch.mjs +13 -2
- package/packages/orchestration/src/bot-serving.mjs +164 -0
- package/packages/orchestration/src/bot-session-store.mjs +105 -9
- package/packages/orchestration/src/bot-settings.mjs +50 -11
- package/packages/orchestration/src/bot-thread-admission.mjs +84 -0
- package/packages/orchestration/src/bot-thread-host.mjs +187 -0
- package/packages/orchestration/src/bot-threads.mjs +790 -0
- package/packages/orchestration/src/data-product-access.mjs +37 -0
- package/packages/orchestration/src/data-tool-contract.mjs +291 -0
- package/packages/orchestration/src/desktop-http-carrier.mjs +120 -0
- package/packages/orchestration/src/desktop-proxy.mjs +311 -0
- package/packages/orchestration/src/desktop-sessions.mjs +43 -9
- package/packages/orchestration/src/ds-lifecycle.mjs +31 -4
- package/packages/orchestration/src/grant-refresh-queue.mjs +17 -0
- package/packages/orchestration/src/independent-chat-page.mjs +39 -0
- package/packages/orchestration/src/independent-chat-service.mjs +308 -0
- package/packages/orchestration/src/independent-context-state.mjs +44 -0
- package/packages/orchestration/src/independent-message-wire.mjs +84 -0
- package/packages/orchestration/src/independent-tool-catalog.mjs +175 -0
- package/packages/orchestration/src/independent-tool-families.mjs +73 -0
- package/packages/orchestration/src/independent-tool-host.mjs +344 -0
- package/packages/orchestration/src/main-bot-grant.mjs +15 -0
- package/packages/orchestration/src/main-model-routes.mjs +208 -0
- package/packages/orchestration/src/model-accounting.mjs +99 -35
- package/packages/orchestration/src/model-auxiliary-dispatch.mjs +187 -0
- package/packages/orchestration/src/model-loop-frame.mjs +179 -0
- package/packages/orchestration/src/model-prepared-generation.mjs +175 -0
- package/packages/orchestration/src/model-request-bounds.mjs +111 -0
- package/packages/orchestration/src/native-activity-contract.mjs +491 -0
- package/packages/orchestration/src/native-activity-service.mjs +102 -0
- package/packages/orchestration/src/native-activity-store.mjs +249 -0
- package/packages/orchestration/src/native-conversation-tools.mjs +78 -0
- package/packages/orchestration/src/native-data-tools.mjs +100 -0
- package/packages/orchestration/src/native-remote-actions.mjs +742 -0
- package/packages/orchestration/src/native-team-tools.mjs +73 -0
- package/packages/orchestration/src/pairing-invite.mjs +37 -0
- package/packages/orchestration/src/product-composition.mjs +1559 -1001
- package/packages/orchestration/src/remote-machines.mjs +82 -14
- package/packages/orchestration/src/routine-execution.mjs +5 -3
- package/packages/orchestration/src/routine-session.mjs +19 -13
- package/packages/orchestration/src/secure-pairing-host.mjs +112 -0
- package/packages/orchestration/src/task-journal.mjs +29 -0
- package/packages/orchestration/src/task-product.mjs +17 -0
- package/packages/orchestration/src/team-assignment-store.mjs +120 -0
- package/packages/orchestration/src/team-bridge.mjs +282 -0
- package/packages/orchestration/src/team-scheduler.mjs +83 -0
- package/packages/orchestration/src/team-sdk-tools.mjs +84 -0
- package/packages/orchestration/src/team-tool-contract.mjs +284 -0
- package/packages/orchestration/src/ui-host-namespace.mjs +23 -0
- package/packages/orchestration/src/web-panel-actions.mjs +103 -0
- package/packages/orchestration/src/web-panel-framing.mjs +227 -0
- package/packages/orchestration/src/web-panel-store.mjs +206 -0
- package/remote-computer-agent/README.md +39 -29
- package/remote-computer-agent/build.mjs +3 -0
- package/remote-computer-agent/dist/OPENMAUSBOT_LICENSE +202 -0
- package/remote-computer-agent/dist/OPENMAUSBOT_NOTICE +10 -0
- package/remote-computer-agent/dist/OPENMAUSBOT_SOURCE.json +68 -0
- package/remote-computer-agent/dist/cli-stdio-bridge.mjs +215 -25
- package/remote-computer-agent/dist/cli-stdio-bridge.mjs.map +4 -4
- package/remote-computer-agent/dist/cli.mjs +1688 -168
- package/remote-computer-agent/dist/cli.mjs.map +4 -4
- package/remote-computer-agent/dist/index.mjs +1579 -122
- package/remote-computer-agent/dist/index.mjs.map +4 -4
- package/remote-computer-agent/dist/native-peer.ps1 +51 -3
- package/remote-computer-agent/package-lock.json +308 -2
- package/remote-computer-agent/package.json +2 -1
- package/remote-computer-agent/pair-device.ps1 +20 -0
- package/remote-computer-agent/setup.ps1 +38 -16
- package/remote-computer-agent/src/cli.ts +24 -3
- package/remote-computer-agent/src/desktop-session.ts +11 -3
- package/remote-computer-agent/src/e2e-server.ts +81 -0
- package/remote-computer-agent/src/pairing-page.ts +35 -0
- package/remote-computer-agent/src/protocol.ts +25 -25
- package/remote-computer-agent/src/secure-pairing.ts +105 -0
- package/remote-computer-agent/src/store.ts +20 -5
- package/remote-computer-agent/src/transport.ts +39 -15
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
body[data-bot-product-ui] .ic-shell{height:100%;min-height:0;display:flex;background:var(--bp-chat-canvas);color:var(--bp-chat-ink);font:14px/1.55 system-ui,-apple-system,"Segoe UI",sans-serif;overflow:hidden}
|
|
2
|
+
.ic-context-boundary{display:flex;align-items:center;gap:12px;color:var(--bp-chat-muted);font-size:11px}.ic-context-boundary:before,.ic-context-boundary:after{content:"";height:1px;background:var(--bp-chat-line);flex:1}
|
|
3
|
+
.ic-request.ic-request-working{display:flex;align-items:center;justify-content:space-between;gap:12px}.ic-request-working .ic-request-actions{margin:0;flex:none}.ic-request-working>span{min-width:0}
|
|
4
|
+
.ic-streaming{align-self:flex-start;max-width:90%;min-width:0;overflow-wrap:anywhere}.ic-streaming-caption{display:flex;align-items:center;gap:7px;color:var(--bp-chat-muted);font-size:11px;margin-bottom:8px}.ic-streaming-dot{width:6px;height:6px;border-radius:50%;background:var(--bp-chat-accent);flex:none}.ic-streaming-text{white-space:pre-wrap;line-height:1.8;color:var(--bp-chat-ink)}.ic-streaming small{display:block;color:var(--bp-chat-muted);font-size:11px;margin-top:8px}
|
|
5
|
+
.ic-shell *{box-sizing:border-box}.ic-shell button,.ic-native-entry{font:inherit;cursor:pointer}.ic-shell button:disabled{cursor:default;opacity:.5}.ic-shell button:focus-visible,.ic-shell textarea:focus-visible,.ic-native-entry:focus-visible{outline:2px solid var(--bp-chat-focus);outline-offset:3px}
|
|
6
|
+
.ic-contacts{width:234px;flex:none;background:var(--bp-chat-sidebar);border-right:1px solid var(--bp-chat-line);padding:18px 10px;display:flex;flex-direction:column;min-height:0}.ic-contact-title{display:flex;align-items:center;gap:9px;padding:0 12px 20px}.ic-contacts nav{flex:1;min-height:0;overflow:auto}.ic-contacts nav button{border:0;color:var(--bp-chat-ink);display:flex;align-items:center;gap:10px;text-align:left;width:100%;background:transparent;padding:12px 10px;border-radius:12px;margin:3px 0}.ic-contacts nav button:hover,.ic-contacts nav button[aria-current=page]{background:var(--bp-chat-hover)}.ic-contacts nav button>span:last-child{min-width:0}.ic-contacts strong{font-weight:600}.ic-contacts small{display:block;color:var(--bp-chat-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:155px;font-size:12px}.ic-team-link{background:transparent;border:0;border-top:1px solid var(--bp-chat-line);padding:15px 12px 0;color:var(--bp-chat-muted);display:flex;justify-content:space-between;align-items:center}
|
|
7
|
+
.ic-avatar{width:38px;height:38px;border-radius:13px;display:inline-flex;align-items:center;justify-content:center;background:var(--bp-chat-inset);color:var(--bp-chat-accent);flex:none}.ic-avatar-large{width:64px;height:64px;border-radius:23px}.ic-conversation{flex:1;min-width:0;min-height:0;position:relative;display:flex;flex-direction:column}.ic-header{height:78px;flex:none;padding:12px 28px;display:flex;align-items:center;gap:12px;border-bottom:1px solid var(--bp-chat-line)}.ic-heading{min-width:0;flex:1}.ic-heading strong{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:16px}.ic-heading small{font-size:12px;color:var(--bp-chat-muted)}.ic-header-actions{display:flex;gap:4px}.ic-header-actions button{width:34px;height:34px;display:grid;place-items:center;background:transparent;color:var(--bp-chat-muted);border:0;border-radius:9px}.ic-header-actions button:hover{background:var(--bp-chat-inset)}
|
|
8
|
+
.ic-transcript{min-height:0;flex:1;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;padding:22px 26px}.ic-message-column{max-width:790px;margin:0 auto;min-height:100%;display:flex;flex-direction:column;gap:22px}.ic-message{max-width:90%;align-self:flex-start;min-width:0;overflow-wrap:anywhere}.ic-message-user{align-self:flex-end;max-width:78%}.ic-message-meta{display:flex;align-items:center;gap:9px;color:var(--bp-chat-muted);font-size:11px;padding:0 3px 6px}.ic-message-meta strong{font-weight:500}.ic-message-user .ic-message-meta{justify-content:flex-end}.ic-bubble{white-space:pre-wrap;font-size:14px;line-height:1.8;color:var(--bp-chat-ink)}.ic-message-user .ic-bubble{background:var(--bp-chat-user);color:var(--bp-chat-on-user);padding:10px 16px;border-radius:17px 17px 5px 17px}.ic-message-source{display:block;color:var(--bp-chat-muted);font-size:10px;margin-top:7px}.ic-message-tool,.ic-message-system{color:var(--bp-chat-muted);border-left:2px solid var(--bp-chat-line);padding-left:12px}.ic-message-tool .ic-bubble,.ic-message-system .ic-bubble{color:var(--bp-chat-muted);font-size:12px}.ic-tool-detail{font-size:12px;color:var(--bp-chat-muted);margin-top:8px}.ic-tool-detail p{margin:7px 0}.ic-tool-detail small{overflow-wrap:anywhere}.ic-empty{flex:1;display:flex;min-height:200px;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:12px;color:var(--bp-chat-muted)}.ic-empty strong{font-size:17px;color:var(--bp-chat-ink)}.ic-empty p{max-width:360px;margin:0}.ic-load-older{align-self:center;background:transparent;border:1px solid var(--bp-chat-line);border-radius:18px;padding:6px 14px;color:var(--bp-chat-muted)}
|
|
9
|
+
.ic-composer-area{flex:none;padding:8px 28px 12px;max-height:53%;overflow:auto}.ic-composer-area>*{max-width:790px;margin-left:auto;margin-right:auto}.ic-composer{border:1px solid var(--bp-chat-line-strong);border-radius:19px;background:var(--bp-chat-surface);padding:12px 14px 10px;box-shadow:var(--bp-chat-shadow)}.ic-composer textarea{display:block;width:100%;max-height:160px;min-height:54px;resize:vertical;border:0;background:transparent;color:var(--bp-chat-ink);padding:0 2px;font:14px/1.65 inherit;font-family:inherit}.ic-composer textarea::placeholder{color:var(--bp-chat-muted)}.ic-composer-footer{display:flex;align-items:center;justify-content:space-between;gap:10px;padding-top:8px}.ic-composer-footer>span{font-size:11px;color:var(--bp-chat-muted)}.ic-composer-footer button{display:flex;align-items:center;gap:7px;flex:none;border:0;border-radius:12px;background:var(--bp-chat-user);color:var(--bp-chat-on-user);padding:8px 13px;min-height:36px}.ic-capability-note{display:flex;align-items:center;justify-content:center;gap:8px;flex-wrap:wrap;font-size:10px;color:var(--bp-chat-muted);margin-top:8px;margin-bottom:0}.ic-capability-note button{font:inherit;color:inherit;background:transparent;border:0;text-decoration:underline;padding:0}.ic-request{border-radius:11px;background:var(--bp-chat-inset);padding:10px 13px;margin-bottom:10px;font-size:12px;overflow-wrap:anywhere}.ic-request>small{display:block;font-size:10px;color:var(--bp-chat-muted);margin-top:4px}.ic-request-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:7px}.ic-request button,.ic-alert button,.ic-placeholder button{background:var(--bp-chat-surface);color:var(--bp-chat-ink);border:1px solid var(--bp-chat-line-strong);border-radius:8px;padding:5px 9px;font-size:12px;display:inline-flex;align-items:center;gap:5px;min-height:32px}.ic-stop{margin-left:auto}.ic-alert{margin:8px 16px;padding:11px 13px;border-radius:10px;color:var(--bp-chat-danger);background:var(--bp-chat-danger-bg);font-size:12px;display:flex;align-items:center;flex-wrap:wrap;gap:9px;overflow-wrap:anywhere}.ic-composer-area .ic-alert{margin:0 auto 9px}.ic-placeholder{margin:auto;padding:28px;text-align:center;color:var(--bp-chat-muted)}.ic-scroll-latest{position:absolute;right:25px;bottom:220px;display:flex;align-items:center;gap:5px;z-index:2;border:1px solid var(--bp-chat-line-strong);border-radius:20px;padding:7px 12px;background:var(--bp-chat-surface);color:var(--bp-chat-ink);box-shadow:var(--bp-chat-shadow)}.ic-sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}
|
|
10
|
+
.ic-native-entry{display:inline-flex;align-items:center;gap:6px;color:var(--bp-chat-ink);background:var(--bp-chat-inset);border:1px solid var(--bp-chat-line-strong);border-radius:12px;padding:7px 10px;white-space:nowrap;max-width:100%;font-size:12px}
|
|
11
|
+
.ic-heading .ic-model{display:flex;align-items:center;gap:5px;max-width:100%;border:0;background:transparent;color:var(--bp-chat-muted);font-size:12px;padding:2px 0;line-height:1.5}.ic-model span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ic-model svg{flex:none}.ic-heading .ic-model:hover{color:var(--bp-chat-ink)}.ic-model[data-model-different] span:after{content:' · 已选与最近应用不同'}.ic-composer textarea{font-size:14px;line-height:1.65}
|
|
12
|
+
/* The public Markdown primitive reads the Host token vocabulary. These local
|
|
13
|
+
aliases keep it on the same contact/chat palette, including user bubbles. */
|
|
14
|
+
.ic-rich-body {
|
|
15
|
+
--dsw-alias-label-primary: var(--bp-chat-ink);
|
|
16
|
+
--dsw-alias-label-secondary: var(--bp-chat-muted);
|
|
17
|
+
--dsw-alias-label-tertiary: var(--bp-chat-muted);
|
|
18
|
+
--dsw-alias-label-caption: var(--bp-chat-muted);
|
|
19
|
+
--dsw-alias-link: var(--bp-chat-accent);
|
|
20
|
+
--dsw-alias-bg-base: var(--bp-chat-canvas);
|
|
21
|
+
--dsw-alias-border-l1: var(--bp-chat-line-strong);
|
|
22
|
+
--dsw-alias-border-l2: var(--bp-chat-line);
|
|
23
|
+
--dsw-alias-border-l3: var(--bp-chat-line);
|
|
24
|
+
--dsw-alias-markdown-inline-code: var(--bp-chat-inset);
|
|
25
|
+
--dsw-alias-markdown-code-block: var(--bp-chat-inset);
|
|
26
|
+
--dsw-alias-markdown-code-block-banner: var(--bp-chat-hover);
|
|
27
|
+
--dsw-focus-ring-color: var(--bp-chat-focus);
|
|
28
|
+
--dsw-radius-lg: 12px;
|
|
29
|
+
--dsw-radius-md: 8px;
|
|
30
|
+
--dsw-radius-sm: 5px;
|
|
31
|
+
--dsw-radius-xs: 3px;
|
|
32
|
+
--dsw-font-family: system-ui,-apple-system,"Segoe UI",sans-serif;
|
|
33
|
+
--ds-font-family-code: Consolas,"SFMono-Regular",monospace;
|
|
34
|
+
--dsw-font-markdown-base: 14px/1.8 var(--dsw-font-family);
|
|
35
|
+
--dsw-font-markdown-base-strong: 600 14px/1.8 var(--dsw-font-family);
|
|
36
|
+
--dsw-font-markdown-h1: 600 21px/1.5 var(--dsw-font-family);
|
|
37
|
+
--dsw-font-markdown-h2: 600 18px/1.5 var(--dsw-font-family);
|
|
38
|
+
--dsw-font-markdown-h3: 600 16px/1.5 var(--dsw-font-family);
|
|
39
|
+
--dsw-font-markdown-h4: 600 14px/1.5 var(--dsw-font-family);
|
|
40
|
+
--dsw-font-markdown-code: 12px/1.6 var(--ds-font-family-code);
|
|
41
|
+
--dsw-font-markdown-code-block: 12px/1.7 var(--ds-font-family-code);
|
|
42
|
+
--dsw-font-markdown-table: 12px/1.6 var(--dsw-font-family);
|
|
43
|
+
--dsw-font-markdown-table-head: 600 12px/1.6 var(--dsw-font-family);
|
|
44
|
+
--shiki-foreground: var(--bp-chat-ink);
|
|
45
|
+
--shiki-background: var(--bp-chat-inset);
|
|
46
|
+
--shiki-token-comment: var(--bp-chat-muted);
|
|
47
|
+
--shiki-token-string: var(--bp-chat-accent);
|
|
48
|
+
--shiki-token-constant: var(--bp-chat-accent);
|
|
49
|
+
--shiki-token-keyword: var(--bp-chat-accent);
|
|
50
|
+
--shiki-token-function: var(--bp-chat-ink);
|
|
51
|
+
--shiki-token-parameter: var(--bp-chat-ink);
|
|
52
|
+
--shiki-token-punctuation: var(--bp-chat-muted);
|
|
53
|
+
--shiki-token-string-expression: var(--bp-chat-accent);
|
|
54
|
+
--shiki-token-link: var(--bp-chat-accent);
|
|
55
|
+
min-width:0; max-width:100%; white-space:normal;
|
|
56
|
+
}
|
|
57
|
+
.ic-message-user .ic-rich-body{--dsw-alias-label-primary:var(--bp-chat-on-user);--dsw-alias-label-secondary:var(--bp-chat-on-user);--dsw-alias-label-tertiary:var(--bp-chat-on-user);--dsw-alias-label-caption:var(--bp-chat-on-user);--dsw-alias-link:var(--bp-chat-on-user)}
|
|
58
|
+
.ic-rich-body .md-code-block{--dsw-alias-label-primary:var(--bp-chat-ink);--dsw-alias-label-tertiary:var(--bp-chat-muted);min-width:0;max-width:100%;overflow:clip;border:1px solid var(--bp-chat-line);color:var(--bp-chat-ink)}
|
|
59
|
+
.ic-rich-body .md-code-block pre{max-width:100%;overflow-x:auto;white-space:pre!important;word-break:normal!important;overflow-wrap:normal!important;overscroll-behavior-x:contain}
|
|
60
|
+
.ic-rich-body .md-code-block pre code{white-space:pre!important;word-break:normal!important;overflow-wrap:normal!important}
|
|
61
|
+
.ic-rich-body .md-code-block [data-code-block-banner]{flex-wrap:wrap;position:relative;gap:8px;min-height:36px}
|
|
62
|
+
.ic-rich-body .md-code-block [data-code-block-banner] button{min-height:28px;font-size:11px;color:var(--bp-chat-ink)}
|
|
63
|
+
.ic-rich-body .md-table-wide{width:100%;max-width:100%;overflow-x:auto!important;overscroll-behavior-x:contain}
|
|
64
|
+
.ic-rich-body table{color:inherit}.ic-rich-body a{overflow-wrap:anywhere;text-decoration:underline}.ic-rich-body :where(img,svg){max-width:100%}.ic-rich-body .katex-display{overflow-x:auto;overflow-y:hidden;max-width:100%;padding:3px 0}
|
|
65
|
+
.ic-rich-message-actions{display:flex;align-items:center;flex-wrap:wrap;gap:10px;margin-top:7px;font-size:11px;color:var(--bp-chat-muted);max-width:100%}
|
|
66
|
+
.ic-message-user .ic-rich-message-actions{justify-content:flex-end}.ic-rich-message-actions>button{background:transparent;border:0;color:inherit;font-size:11px;padding:3px 0;min-height:28px}.ic-rich-message-actions>button:hover{text-decoration:underline}
|
|
67
|
+
.ic-rich-message-actions>span[data-copy-ok=false],.ic-rich-code-feedback[data-copy-ok=false]{color:var(--bp-chat-danger)}
|
|
68
|
+
.ic-rich-code-feedback{font:11px/1.5 system-ui,sans-serif;color:var(--bp-chat-muted);flex-basis:100%;overflow-wrap:anywhere}
|
|
69
|
+
.ic-rich-raw summary{cursor:pointer;min-height:28px;display:flex;align-items:center}.ic-rich-raw summary:hover{text-decoration:underline}.ic-rich-raw[open]{width:100%;flex-basis:100%}.ic-rich-raw textarea{width:100%;min-height:120px;max-height:250px;border:1px solid var(--bp-chat-line-strong);border-radius:8px;background:var(--bp-chat-surface);color:var(--bp-chat-ink);font:12px/1.6 Consolas,monospace;resize:vertical;padding:10px;white-space:pre}
|
|
70
|
+
.ic-rich-tool-calls,.ic-rich-tool-result,.ic-rich-context{font-size:12px;max-width:100%;min-width:0;color:var(--bp-chat-muted)}
|
|
71
|
+
.ic-rich-tool-calls{margin-top:8px;border:1px solid var(--bp-chat-line);border-radius:11px;padding:9px 12px;background:var(--bp-chat-sidebar)}
|
|
72
|
+
.ic-rich-tool-calls summary,.ic-rich-tool-result summary,.ic-rich-context summary{cursor:pointer;overflow-wrap:anywhere}.ic-rich-tool-calls h4{font-size:12px;margin:13px 0 6px;color:var(--bp-chat-ink)}.ic-rich-tool-calls dl{margin:0}.ic-rich-tool-calls dt{font-size:10px;margin:8px 0 3px}.ic-rich-tool-calls dd{margin:0;overflow-wrap:anywhere}.ic-rich-tool-calls pre,.ic-rich-tool-result pre,.ic-rich-context pre{max-width:100%;overflow:auto;padding:10px;border-radius:7px;background:var(--bp-chat-inset);color:var(--bp-chat-ink);white-space:pre;overscroll-behavior-x:contain;font:11px/1.65 Consolas,monospace}.ic-rich-tool-note{font-size:10px;margin:7px 0;color:var(--bp-chat-muted)}.ic-rich-tool-error{color:var(--bp-chat-danger)}
|
|
73
|
+
@media(max-width:650px){.ic-shell{flex-direction:column}.ic-contacts{width:100%;padding:7px 10px;border-right:0;border-bottom:1px solid var(--bp-chat-line);max-height:66px}.ic-contact-title,.ic-team-link{display:none}.ic-contacts nav{display:flex;gap:5px;overflow:auto;flex:none}.ic-contacts nav button{width:auto;flex:none;padding:5px 10px;margin:0;border-radius:12px;max-width:210px}.ic-contacts nav button small{display:none}.ic-contacts .ic-avatar{width:30px;height:30px;border-radius:10px}.ic-contacts nav button strong{white-space:nowrap;font-size:13px}.ic-header{height:68px;padding:10px 15px;gap:9px}.ic-heading small{font-size:10px}.ic-header-actions button{width:30px}.ic-transcript{padding:17px 16px}.ic-message-column{gap:20px}.ic-message{max-width:100%}.ic-message-user{max-width:88%}.ic-composer-area{padding:7px 12px 10px}.ic-composer{padding:10px 12px 8px;border-radius:16px}.ic-composer-footer>span{font-size:10px}.ic-capability-note{font-size:9px}.ic-request{padding:8px 10px}.ic-scroll-latest{right:17px}.ic-native-entry{font-size:11px;padding:6px}.ic-native-entry>svg:last-child{display:none}}
|
|
@@ -5,39 +5,44 @@ import { apply as applyMr } from '../../.dsh-plugin/client/official-harness.jsx'
|
|
|
5
5
|
import { createProductApi, PRODUCT_PANELS } from './api.mjs'
|
|
6
6
|
import { ProductNavigation, ProductPage } from './panels.jsx'
|
|
7
7
|
import css from './product.css'
|
|
8
|
+
import workspaceCss from './workspace.css'
|
|
9
|
+
import chatCss from './chat.css'
|
|
10
|
+
import desktopCss from './desktop.css'
|
|
11
|
+
import usageCss from './usage.css'
|
|
12
|
+
import notificationsCss from './notifications.css'
|
|
13
|
+
import dataCss from './data.css'
|
|
14
|
+
import botThreadsCss from './bot-threads.css'
|
|
15
|
+
import webPanelCss from './web-panel.css'
|
|
16
|
+
import composerDraftCss from './composer-draft.css'
|
|
17
|
+
import botThreadHeaderCss from './bot-thread-header-bridge.css'
|
|
18
|
+
import { createProductSlots } from './product-slots.jsx'
|
|
8
19
|
import { installDesktopBridge } from './desktop-bridge.mjs'
|
|
9
20
|
import { DesktopPane } from './desktop-pane.jsx'
|
|
21
|
+
import { installWorkspaceAppearance } from './workspace-ui.jsx'
|
|
22
|
+
import { IndependentChatPage } from './independent-chat-page.jsx'
|
|
23
|
+
import { INDEPENDENT_CHAT_PANEL } from './independent-chat-navigation.mjs'
|
|
24
|
+
import independentChatCss from './independent-chat.css'
|
|
10
25
|
|
|
11
26
|
export const inject = [...new Set([...dsInject, 'remote'])]
|
|
12
27
|
export { ProductPage, ProductNavigation, PRODUCT_PANELS }
|
|
13
28
|
|
|
14
|
-
export function productSlots(slots, openPanel) {
|
|
15
|
-
return
|
|
16
|
-
if (key === 'register') return (options, component) => {
|
|
17
|
-
if (component !== TeamSidebar) return target.register(options, component)
|
|
18
|
-
const Sidebar = props => {
|
|
19
|
-
const sidebarAddon = () => <ProductNavigation panels={PRODUCT_PANELS} openPanel={openPanel} compact={!props.wide} />
|
|
20
|
-
return <TeamSidebar {...props} actions={{ ...props.actions, sidebarAddon }} />
|
|
21
|
-
}
|
|
22
|
-
Sidebar.dsBotTeamSidebar = TeamSidebar
|
|
23
|
-
return target.register(options, Sidebar)
|
|
24
|
-
}
|
|
25
|
-
const value = Reflect.get(target, key, target)
|
|
26
|
-
return typeof value === 'function' ? value.bind(target) : value
|
|
27
|
-
} })
|
|
29
|
+
export function productSlots(slots, openPanel, productApi, client) {
|
|
30
|
+
return createProductSlots(slots,openPanel,productApi,TeamSidebar,client)
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
export async function apply(ctx) {
|
|
31
34
|
const api = createProductApi()
|
|
32
35
|
ctx.effect(() => installDesktopBridge(api, props => <DesktopPane {...props} />), 'bot-product: desktop bridge')
|
|
33
36
|
const openPanel = id => ctx.layout.selectPanel(id)
|
|
34
|
-
const slots = productSlots(ctx.slots, openPanel)
|
|
37
|
+
const slots = productSlots(ctx.slots, openPanel, api, { sessionBindingOf: id => ctx.sessions.binding(id), openSession: id => ctx.uiWorkspace.openSession(id) })
|
|
35
38
|
const dsContext = new Proxy(ctx, { get: (target, key) => key === 'slots' ? slots : Reflect.get(target, key, target) })
|
|
36
39
|
ctx.effect(() => {
|
|
37
40
|
const previous = document.body.getAttribute('data-bot-product-ui')
|
|
38
41
|
document.body.setAttribute('data-bot-product-ui', '1')
|
|
39
|
-
const style = document.createElement('style'); style.dataset.botProduct = '1'; style.textContent = css
|
|
42
|
+
const style = document.createElement('style'); style.dataset.botProduct = '1'; style.textContent = `${css}\n${workspaceCss}\n${chatCss}\n${desktopCss}\n${usageCss}\n${notificationsCss}\n${dataCss}\n${botThreadsCss}\n${webPanelCss}\n${composerDraftCss}\n${botThreadHeaderCss}\n${independentChatCss}`; document.head.append(style)
|
|
43
|
+
const disposeAppearance = installWorkspaceAppearance(window)
|
|
40
44
|
return () => {
|
|
45
|
+
disposeAppearance()
|
|
41
46
|
style.remove()
|
|
42
47
|
if (previous === null) document.body.removeAttribute('data-bot-product-ui')
|
|
43
48
|
else document.body.setAttribute('data-bot-product-ui', previous)
|
|
@@ -45,6 +50,9 @@ export async function apply(ctx) {
|
|
|
45
50
|
}, 'bot-product: styles')
|
|
46
51
|
applyDs(dsContext)
|
|
47
52
|
const disposeMr = await applyMr(ctx)
|
|
53
|
+
ctx.effect(() => ctx.slots.inject('main', () => ctx.slots.register({ name: 'main', key: INDEPENDENT_CHAT_PANEL,
|
|
54
|
+
inject: () => ({ productApi: api, openPanel, openSession: id => ctx.uiWorkspace.openSession(id) }),
|
|
55
|
+
}, IndependentChatPage)), 'bot-product: independent chat')
|
|
48
56
|
for (const [section, key] of Object.entries(PRODUCT_PANELS)) {
|
|
49
57
|
ctx.effect(() => ctx.slots.inject('main', () => ctx.slots.register({ name: 'main', key,
|
|
50
58
|
inject: () => ({ section, productApi: api, openPanel,
|
|
@@ -11,7 +11,7 @@ const fileBase64 = file => new Promise((resolve, reject) => {
|
|
|
11
11
|
reader.readAsDataURL(file)
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
-
export function LibraryPanel({ snapshot, dispatch, busy }) {
|
|
14
|
+
export function LibraryPanel({ snapshot, dispatch, busy, focus }) {
|
|
15
15
|
const bots = snapshot.bots ?? []
|
|
16
16
|
const [botId, setBotId] = useState(bots[0]?.id ?? '')
|
|
17
17
|
const [path, setPath] = useState('')
|
|
@@ -45,6 +45,9 @@ export function LibraryPanel({ snapshot, dispatch, busy }) {
|
|
|
45
45
|
}, [botId, path, call])
|
|
46
46
|
useEffect(() => { setEditor(null); setDeleteName(null); setEntries([]); setSearchResults(null); void load(); return () => { sequence.current++ } }, [load])
|
|
47
47
|
useEffect(() => { if (!botId && bots[0]) setBotId(bots[0].id) }, [botId, bots])
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (focus?.botId && bots.some(bot => bot.id === focus.botId)) { setBotId(focus.botId); setPath(''); setEditor(null); setSearchResults(null) }
|
|
50
|
+
}, [focus?.version, focus?.botId])
|
|
48
51
|
useEffect(() => {
|
|
49
52
|
if (!editor?.line || !editorRef.current) return
|
|
50
53
|
const textarea = editorRef.current, lines = textarea.value.split('\n')
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { BotModelPicker } from './model-picker.jsx'
|
|
3
|
+
import { UiIcon } from './ui-icons.jsx'
|
|
4
|
+
import { accountFor, findModel, FUNDING_MODES, numberOrNull, routeOf, textOf } from './binding-model.mjs'
|
|
5
|
+
import { MAIN_LIMIT_FIELDS, newMainRoute } from './main-route-model.mjs'
|
|
6
|
+
|
|
7
|
+
const PRICES = [['input', '输入价格'], ['output', '输出价格'], ['cacheRead', '缓存读取价格'], ['cacheWrite', '缓存写入价格']]
|
|
8
|
+
const BOUNDS = [['maxInputTokens', '最大输入 Token'], ['maxOutputTokens', '最大输出 Token']]
|
|
9
|
+
|
|
10
|
+
function NumberField({ label, value, onChange, min = 0, step = 'any' }) {
|
|
11
|
+
return <label className="bb-field"><span>{label}</span>
|
|
12
|
+
<input type="number" min={min} step={step} value={textOf(value)} onChange={event => onChange(event.target.value)} />
|
|
13
|
+
</label>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function EnableAccount({ account, onEnable }) {
|
|
17
|
+
const [daily, setDaily] = useState(textOf(account.dailyLimitUsd))
|
|
18
|
+
const [monthly, setMonthly] = useState(textOf(account.monthlyLimitUsd))
|
|
19
|
+
const day = numberOrNull(daily), month = numberOrNull(monthly)
|
|
20
|
+
return <div className="bb-route-account">
|
|
21
|
+
<div className="bb-fields">
|
|
22
|
+
<NumberField label="账户每日上限(USD)" value={daily} onChange={setDaily} />
|
|
23
|
+
<NumberField label="账户每月上限(USD)" value={monthly} onChange={setMonthly} />
|
|
24
|
+
</div>
|
|
25
|
+
<button type="button" disabled={day === null || month === null || day < 0 || month < 0}
|
|
26
|
+
onClick={() => onEnable(account, day, month)}>启用 {account.provider} 资金范围</button>
|
|
27
|
+
</div>
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function MainRouteEditor({ draft, defaultRoute, catalog, accounts, busy, onChange, onDefault, onEnableAccount, onSingleRoute }) {
|
|
31
|
+
const used = new Set(draft.routes.map(routeOf))
|
|
32
|
+
const offered = (catalog?.models ?? []).filter(model => !used.has(routeOf(model)))
|
|
33
|
+
const update = (index, route) => onChange({ ...draft, routes: draft.routes.map((item, at) => at === index ? route : item) })
|
|
34
|
+
return <section className="bb-route-editor" aria-label="Main 模型路线">
|
|
35
|
+
<header className="bb-route-heading">
|
|
36
|
+
<strong><UiIcon name="chart" size={16} />Main 模型路线</strong>
|
|
37
|
+
<span className="bb-pill">{draft.routes.filter(route => route.enabled).length} / {draft.routes.length} 已启用</span>
|
|
38
|
+
<p className="bb-note">每条路线单独设置资金渠道。API 路线共用金额预算,订阅路线共用调用次数。</p>
|
|
39
|
+
</header>
|
|
40
|
+
<fieldset className="bb-fieldset" disabled={busy}>
|
|
41
|
+
<details className="bb-fold">
|
|
42
|
+
<summary>共享预算与订阅次数</summary>
|
|
43
|
+
<div className="bb-fold-body">
|
|
44
|
+
<div className="bb-fields">{Object.entries(MAIN_LIMIT_FIELDS).flatMap(([mode, fields]) => fields.map(([key, label]) =>
|
|
45
|
+
<NumberField key={key} label={label} value={draft.limits[mode]?.[key]} step={mode === 'subscription' ? 1 : 'any'}
|
|
46
|
+
onChange={value => onChange({ ...draft, limits: { ...draft.limits, [mode]: { ...draft.limits[mode], [key]: value } } })} />))}</div>
|
|
47
|
+
<p className="bb-note">每日与每月限额成对填写。0 表示禁止消费或调用。</p>
|
|
48
|
+
</div>
|
|
49
|
+
</details>
|
|
50
|
+
{draft.routes.map((route, index) => {
|
|
51
|
+
const id = routeOf(route), model = findModel(catalog, id), primary = defaultRoute === id
|
|
52
|
+
const account = accountFor(accounts, route.provider), funding = route.funding
|
|
53
|
+
const changeFunding = patch => update(index, { ...route, funding: { ...funding, ...patch } })
|
|
54
|
+
return <details key={id} className="bb-route" data-main-route={id}>
|
|
55
|
+
<summary><span><strong>{model?.label ?? route.model}</strong><small>{id}</small></span>
|
|
56
|
+
<span className="bb-pill" data-tone={route.enabled && account?.enabled && model ? 'current' : 'muted'}>
|
|
57
|
+
{primary ? '默认 · ' : ''}{route.enabled ? (account?.enabled && model ? '已启用' : '待配置') : '已停用'}</span>
|
|
58
|
+
</summary>
|
|
59
|
+
<div className="bb-fold-body">
|
|
60
|
+
<div className="bb-row">
|
|
61
|
+
<label className="bb-check"><input type="checkbox" aria-label={`启用路线 ${id}`} checked={route.enabled} onChange={event => update(index, { ...route, enabled: event.target.checked })} />启用路线</label>
|
|
62
|
+
<button type="button" className="bb-link" disabled={primary || !route.enabled || !model} onClick={() => onDefault(route)}>设为默认</button>
|
|
63
|
+
<button type="button" className="bb-link" disabled={primary} onClick={() => onChange({ ...draft, routes: draft.routes.filter(item => item !== route) })}>移除路线</button>
|
|
64
|
+
</div>
|
|
65
|
+
<label className="bb-field"><span>资金渠道</span>
|
|
66
|
+
<select value={funding.mode} onChange={event => changeFunding({ mode: event.target.value, pricing: model?.pricing ?? null, request: null })}>
|
|
67
|
+
{FUNDING_MODES.filter(mode => mode.value === funding.mode || !model?.fundingModes || model.fundingModes.includes(mode.value))
|
|
68
|
+
.map(mode => <option value={mode.value} key={mode.value}>{mode.label}</option>)}
|
|
69
|
+
</select>
|
|
70
|
+
</label>
|
|
71
|
+
<p className="bb-note">{account?.id === funding.scopeId ? `${account.provider} · ${account.enabled ? '资金范围已启用' : '资金范围未启用'}` : '需要重新选择此提供商的资金范围。'}</p>
|
|
72
|
+
{account && account.id !== funding.scopeId && <button type="button" className="bb-link" onClick={() => changeFunding({ scopeId: account.id })}>选择 {account.provider} 资金范围</button>}
|
|
73
|
+
{account && !account.enabled && <EnableAccount key={`${account.id}:${account.revision}`} account={account} onEnable={onEnableAccount} />}
|
|
74
|
+
{funding.mode === 'api' && <>
|
|
75
|
+
<div className="bb-fields">{PRICES.map(([key, label]) => <NumberField key={key} label={`${label}(USD / 百万 Token)`} value={funding.pricing?.[key]}
|
|
76
|
+
onChange={value => changeFunding({ pricing: { ...funding.pricing, [key]: value } })} />)}
|
|
77
|
+
{BOUNDS.map(([key, label]) => <NumberField key={key} label={label} value={funding.request?.[key]} min={1} step={1}
|
|
78
|
+
onChange={value => changeFunding({ request: { ...funding.request, [key]: value } })} />)}
|
|
79
|
+
</div>
|
|
80
|
+
{model?.pricing && <button type="button" className="bb-link" onClick={() => changeFunding({ pricing: { ...model.pricing } })}>使用宿主登记的准确价格</button>}
|
|
81
|
+
</>}
|
|
82
|
+
</div>
|
|
83
|
+
</details>
|
|
84
|
+
})}
|
|
85
|
+
{offered.length > 0 && draft.routes.length < 64 && <BotModelPicker label="添加路线" models={offered} disabled={busy}
|
|
86
|
+
note="添加后先配置资金渠道和限额,再启用该路线。"
|
|
87
|
+
onSelect={model => onChange({ ...draft, routes: [...draft.routes, newMainRoute(model, accounts)] })} />}
|
|
88
|
+
<div className="bb-row">
|
|
89
|
+
<button type="button" className="bb-link" onClick={onSingleRoute}>改用单路线</button>
|
|
90
|
+
<small className="bb-note">保存后只保留默认模型的资金配置。</small>
|
|
91
|
+
</div>
|
|
92
|
+
</fieldset>
|
|
93
|
+
</section>
|
|
94
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { accountFor, findModel, numberOrNull, routeOf, scopeAllows, textOf } from './binding-model.mjs'
|
|
2
|
+
|
|
3
|
+
export const MAIN_LIMIT_FIELDS = {
|
|
4
|
+
api: [['dailyBudgetUsd', '共享每日 API 预算(USD)'], ['monthlyBudgetUsd', '共享每月 API 预算(USD)']],
|
|
5
|
+
subscription: [['dailyCalls', '共享每日订阅次数'], ['monthlyCalls', '共享每月订阅次数']],
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const pair = (value, first, second) => {
|
|
9
|
+
const a = numberOrNull(value?.[first]), b = numberOrNull(value?.[second])
|
|
10
|
+
return a === null || b === null ? null : { [first]: a, [second]: b }
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function routeDraft(model, account, funding = null, enabled = false) {
|
|
14
|
+
return {
|
|
15
|
+
provider: model.provider, model: model.model, enabled,
|
|
16
|
+
funding: {
|
|
17
|
+
mode: funding?.mode ?? model.fundingModes?.[0] ?? 'api',
|
|
18
|
+
scopeId: funding?.scopeId ?? account?.id ?? null,
|
|
19
|
+
pricing: funding ? funding.pricing ?? null : model.pricing ?? null,
|
|
20
|
+
request: funding?.request ?? null,
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const newMainRoute = (model, accounts) => routeDraft(model, accountFor(accounts, model.provider))
|
|
26
|
+
|
|
27
|
+
export function startMainRoutes(form, model, account, savedFunding) {
|
|
28
|
+
const pricing = pair(form, 'input', 'output')
|
|
29
|
+
const savedPrice = savedFunding?.pricing
|
|
30
|
+
const exactPrice = pricing && savedPrice?.input === pricing.input && savedPrice?.output === pricing.output ? savedPrice : pricing
|
|
31
|
+
return {
|
|
32
|
+
schemaVersion: 1,
|
|
33
|
+
limits: {
|
|
34
|
+
api: { dailyBudgetUsd: form.daily, monthlyBudgetUsd: form.monthly },
|
|
35
|
+
subscription: { dailyCalls: form.dailyCalls, monthlyCalls: form.monthlyCalls },
|
|
36
|
+
},
|
|
37
|
+
routes: model ? [routeDraft(model, account, {
|
|
38
|
+
mode: form.fundingMode, scopeId: account?.id,
|
|
39
|
+
pricing: form.fundingMode === 'api' ? exactPrice : null,
|
|
40
|
+
request: form.fundingMode === 'api' ? pair(form, 'maxInputTokens', 'maxOutputTokens') : null,
|
|
41
|
+
}, form.enabled && Boolean(account?.enabled))] : [],
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function mainRoutePayload(draft) {
|
|
46
|
+
if (!draft) return draft
|
|
47
|
+
return {
|
|
48
|
+
schemaVersion: 1,
|
|
49
|
+
limits: Object.fromEntries(Object.entries(MAIN_LIMIT_FIELDS).map(([mode, [[first], [second]]]) => [mode, pair(draft.limits[mode], first, second)])),
|
|
50
|
+
routes: draft.routes.map(route => {
|
|
51
|
+
const funding = route.funding
|
|
52
|
+
const pricing = funding.mode === 'api' ? pair(funding.pricing, 'input', 'output') : null
|
|
53
|
+
if (pricing) for (const key of ['cacheRead', 'cacheWrite']) {
|
|
54
|
+
const value = numberOrNull(funding.pricing[key])
|
|
55
|
+
if (value !== null) pricing[key] = value
|
|
56
|
+
}
|
|
57
|
+
return { ...route, funding: { mode: funding.mode, scopeId: funding.scopeId, pricing,
|
|
58
|
+
request: funding.mode === 'api' ? pair(funding.request, 'maxInputTokens', 'maxOutputTokens') : null } }
|
|
59
|
+
}),
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function mainDefaultFields(draft, routeId) {
|
|
64
|
+
const route = draft.routes.find(item => routeOf(item) === routeId)
|
|
65
|
+
if (!route) return {}
|
|
66
|
+
return {
|
|
67
|
+
fundingMode: route.funding.mode, input: textOf(route.funding.pricing?.input), output: textOf(route.funding.pricing?.output),
|
|
68
|
+
maxInputTokens: textOf(route.funding.request?.maxInputTokens), maxOutputTokens: textOf(route.funding.request?.maxOutputTokens),
|
|
69
|
+
daily: textOf(draft.limits.api?.dailyBudgetUsd), monthly: textOf(draft.limits.api?.monthlyBudgetUsd),
|
|
70
|
+
dailyCalls: textOf(draft.limits.subscription?.dailyCalls), monthlyCalls: textOf(draft.limits.subscription?.monthlyCalls),
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function mainRouteProblems(draft, { defaultRoute, enabled, catalog, accounts }) {
|
|
75
|
+
const settings = mainRoutePayload(draft)
|
|
76
|
+
const problems = []
|
|
77
|
+
const valid = (value, minimum = 0, integer = false) => Number.isFinite(value) && value >= minimum && (!integer || Number.isSafeInteger(value))
|
|
78
|
+
if (enabled && !settings.routes.some(route => route.enabled && routeOf(route) === defaultRoute)) problems.push('请从已启用的路线中选择默认模型。')
|
|
79
|
+
for (const [mode, fields] of Object.entries(MAIN_LIMIT_FIELDS)) {
|
|
80
|
+
const values = fields.map(([key]) => numberOrNull(draft.limits[mode]?.[key]))
|
|
81
|
+
if (values.some(value => value !== null) && !values.every(value => valid(value, 0, mode === 'subscription'))) {
|
|
82
|
+
problems.push(`${mode === 'api' ? 'API 预算' : '订阅次数'}的每日与每月限额需同时填写。`)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
for (const route of settings.routes) {
|
|
86
|
+
if (!route.enabled) continue
|
|
87
|
+
const id = routeOf(route), model = findModel(catalog, id), { mode, scopeId, pricing, request } = route.funding
|
|
88
|
+
const account = accountFor(accounts, route.provider)
|
|
89
|
+
const scope = (catalog?.fundingScopes ?? []).find(item => item.id === scopeId)
|
|
90
|
+
if (!model || (model.fundingModes && !model.fundingModes.includes(mode)) || account?.id !== scopeId || !account?.enabled || !scopeAllows(scope, mode, id)) {
|
|
91
|
+
problems.push(`${id} 需要有效的模型、渠道和已启用的资金范围。`)
|
|
92
|
+
}
|
|
93
|
+
if (!settings.limits[mode]) problems.push(`${id} 需要填写共享${mode === 'api' ? ' API 预算' : '订阅次数'}。`)
|
|
94
|
+
if (mode === 'api' && (!(pricing ?? model?.pricing) || !Object.values(pricing ?? model.pricing).every(value => valid(value))
|
|
95
|
+
|| !valid(request?.maxInputTokens, 1, true) || !valid(request?.maxOutputTokens, 1, true))) {
|
|
96
|
+
problems.push(`${id} 需要准确价格与正整数请求上界。`)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return problems
|
|
100
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
html body[data-bot-product-ui] .bp-model-picker { display: flex; align-items: center; gap: 20px; color: var(--bp-ink); }
|
|
2
|
+
html body[data-bot-product-ui] .bp-model-picker-label { flex: 1; font-size: 14px; font-weight: 550; }
|
|
3
|
+
html body[data-bot-product-ui] .bp-model-picker-trigger { display: flex; align-items: center; justify-content: flex-start; gap: 10px; min-width: 240px; max-width: 360px; padding: 9px 12px; border: 1px solid var(--bp-border); border-radius: 10px; background: var(--bp-surface); color: var(--bp-ink); cursor: pointer; text-align: left; font: inherit; }
|
|
4
|
+
html body[data-bot-product-ui] .bp-model-current { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 3px; }
|
|
5
|
+
html body[data-bot-product-ui] .bp-model-current strong { font-size: 13px; font-weight: 550; overflow-wrap: anywhere; }
|
|
6
|
+
html body[data-bot-product-ui] .bp-model-current small { color: var(--bp-muted); font-size: 11px; }
|
|
7
|
+
html body[data-bot-product-ui] .bp-model-provider-mark { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 8px; background: var(--bp-subtle); color: var(--bp-ink); font-size: 11px; font-weight: 650; }
|
|
8
|
+
html body[data-bot-product-ui] .bp-model-picker-note { flex-basis: 100%; margin: 0; font-size: 12px; line-height: 1.5; color: var(--bp-muted); }
|
|
9
|
+
html body[data-bot-product-ui] .bp-model-picker { flex-wrap: wrap; }
|
|
10
|
+
html body[data-bot-product-ui] .bp-model-popover { position: fixed; z-index: 11000; display: flex; flex-direction: column; box-sizing: border-box; border: 1px solid var(--bp-border, #dce2da); border-radius: 14px; background: var(--bp-surface, #fff); color: var(--bp-ink, #253d30); font: 13px var(--bp-font, system-ui); box-shadow: 0 12px 44px #0003; overflow: hidden; }
|
|
11
|
+
html body[data-bot-product-ui] .bp-model-popover * { box-sizing: border-box; }
|
|
12
|
+
html body[data-bot-product-ui] .bp-model-popover button { font: inherit; }
|
|
13
|
+
html body[data-bot-product-ui] .bp-model-search { display: flex; align-items: center; gap: 9px; padding: 12px; border-bottom: 1px solid var(--bp-border); flex: none; }
|
|
14
|
+
html body[data-bot-product-ui] .bp-model-search input { flex: 1; width: 0; padding: 5px 0; border: 0; outline: 0; background: transparent; color: inherit; font: inherit; }
|
|
15
|
+
html body[data-bot-product-ui] .bp-model-search button { display: grid; place-items: center; padding: 5px; border: 0; border-radius: 6px; background: transparent; color: var(--bp-muted); cursor: pointer; }
|
|
16
|
+
html body[data-bot-product-ui] .bp-model-options { display: grid; grid-template-columns: 155px minmax(0, 1fr); min-height: 180px; max-height: 340px; overflow: hidden; }
|
|
17
|
+
html body[data-bot-product-ui] .bp-model-provider-rail { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; padding: 8px; border-right: 1px solid var(--bp-border); background: var(--bp-subtle); }
|
|
18
|
+
html body[data-bot-product-ui] .bp-model-provider-rail button { display: flex; align-items: center; justify-content: flex-start; gap: 8px; min-height: 36px; padding: 7px; border: 0; border-radius: 7px; background: transparent; color: var(--bp-ink); cursor: pointer; text-align: left; overflow-wrap: anywhere; }
|
|
19
|
+
html body[data-bot-product-ui] .bp-model-provider-rail button span { display: grid; place-items: center; flex: none; width: 23px; height: 23px; border-radius: 6px; background: var(--bp-surface); font-size: 9px; font-weight: 650; }
|
|
20
|
+
html body[data-bot-product-ui] .bp-model-provider-rail button[aria-pressed=true] { background: var(--bp-surface); box-shadow: 0 0 0 1px var(--bp-border); font-weight: 600; }
|
|
21
|
+
html body[data-bot-product-ui] .bp-model-results { min-width: 0; overflow-y: auto; padding: 8px; }
|
|
22
|
+
html body[data-bot-product-ui] .bp-model-results-caption { display: flex; justify-content: space-between; margin: 4px 7px 8px; font-size: 11px; color: var(--bp-muted); }
|
|
23
|
+
html body[data-bot-product-ui] .bp-model-option { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 50px; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--bp-ink); text-align: left; cursor: pointer; }
|
|
24
|
+
html body[data-bot-product-ui] .bp-model-option > span { display: flex; flex-direction: column; gap: 5px; min-width: 0; overflow-wrap: anywhere; }
|
|
25
|
+
html body[data-bot-product-ui] .bp-model-option strong { font-size: 13px; font-weight: 550; }
|
|
26
|
+
html body[data-bot-product-ui] .bp-model-option small { font-size: 11px; line-height: 1.4; color: var(--bp-muted); }
|
|
27
|
+
html body[data-bot-product-ui] .bp-model-option[aria-pressed=true], html body[data-bot-product-ui] .bp-model-popover button:hover { background: var(--bp-hover); }
|
|
28
|
+
html body[data-bot-product-ui] .bp-model-popover button:focus-visible, html body[data-bot-product-ui] .bp-model-picker-trigger:focus-visible { outline: 2px solid var(--bp-focus); outline-offset: -2px; }
|
|
29
|
+
html body[data-bot-product-ui] .bp-model-popover footer { padding: 10px 14px; font-size: 11px; color: var(--bp-muted); border-top: 1px solid var(--bp-border); }
|
|
30
|
+
html body[data-bot-product-ui] .bp-model-empty { padding: 15px 10px; color: var(--bp-muted); line-height: 1.6; }
|
|
31
|
+
@media (max-width: 520px) {
|
|
32
|
+
html body[data-bot-product-ui] .bp-model-picker { align-items: stretch; gap: 10px; }
|
|
33
|
+
html body[data-bot-product-ui] .bp-model-picker-label { flex-basis: 100%; }
|
|
34
|
+
html body[data-bot-product-ui] .bp-model-picker-trigger { flex: 1; min-width: 0; max-width: 100%; }
|
|
35
|
+
html body[data-bot-product-ui] .bp-model-options { grid-template-columns: 118px minmax(0, 1fr); }
|
|
36
|
+
html body[data-bot-product-ui] .bp-model-provider-rail button { font-size: 11px; }
|
|
37
|
+
}
|