@jingyi0605/codingns4dsh 0.2.1-rc.3 → 0.2.1-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +3 -3
- package/README.md +3 -3
- package/data/build/dist/client/bundle.js +168 -47
- package/data/build/dist/client/bundle.js.map +1 -1
- package/data/build/dist/client/client.native-workspace-store.js +1 -1
- package/data/build/dist/client/client.native-workspace-store.js.map +1 -1
- package/data/build/dist/client/client.transport.js +32 -10
- package/data/build/dist/client/client.transport.js.map +1 -1
- package/data/build/dist/client/desktop-assistant.js +32 -10
- package/data/build/dist/client/features/magpie-management-controls.d.ts.map +1 -1
- package/data/build/dist/client/features/magpie-management-controls.js +45 -10
- package/data/build/dist/client/features/magpie-management-controls.js.map +1 -1
- package/data/build/dist/client/features/magpie-management-page.d.ts +6 -1
- package/data/build/dist/client/features/magpie-management-page.d.ts.map +1 -1
- package/data/build/dist/client/features/magpie-management-page.js +29 -6
- package/data/build/dist/client/features/magpie-management-page.js.map +1 -1
- package/data/build/dist/client/locales/magpie.d.ts.map +1 -1
- package/data/build/dist/client/locales/magpie.js +32 -10
- package/data/build/dist/client/locales/magpie.js.map +1 -1
- package/data/build/dist/client/subscription-slot.d.ts +3 -2
- package/data/build/dist/client/subscription-slot.d.ts.map +1 -1
- package/data/build/dist/client/subscription-slot.js +68 -22
- package/data/build/dist/client/subscription-slot.js.map +1 -1
- package/data/build/dist/host/cli-adapters/feature.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/feature.js +56 -8
- package/data/build/dist/host/cli-adapters/feature.js.map +1 -1
- package/data/build/dist/host/cli-adapters/magpie-detection.d.ts +3 -3
- package/data/build/dist/host/cli-adapters/magpie-detection.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/magpie-detection.js +18 -4
- package/data/build/dist/host/cli-adapters/magpie-detection.js.map +1 -1
- package/data/build/dist/host/cli-adapters/magpie-management.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/magpie-management.js +95 -20
- package/data/build/dist/host/cli-adapters/magpie-management.js.map +1 -1
- package/data/build/dist/host/cli-adapters/magpie-usage.d.ts +5 -1
- package/data/build/dist/host/cli-adapters/magpie-usage.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/magpie-usage.js +285 -59
- package/data/build/dist/host/cli-adapters/magpie-usage.js.map +1 -1
- package/data/build/dist/host/cli-adapters/magpie-web.d.ts +15 -0
- package/data/build/dist/host/cli-adapters/magpie-web.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/magpie-web.js +100 -22
- package/data/build/dist/host/cli-adapters/magpie-web.js.map +1 -1
- package/data/build/dist/host/cli-adapters/process-utils.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/process-utils.js +4 -0
- package/data/build/dist/host/cli-adapters/process-utils.js.map +1 -1
- package/data/build/dist/host/cli-adapters/session-performance-projection.d.ts +6 -0
- package/data/build/dist/host/cli-adapters/session-performance-projection.d.ts.map +1 -1
- package/data/build/dist/host/cli-adapters/session-performance-projection.js +25 -0
- package/data/build/dist/host/cli-adapters/session-performance-projection.js.map +1 -1
- package/data/build/dist/shared/contracts/magpie-management.d.ts +19 -0
- package/data/build/dist/shared/contracts/magpie-management.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/subscription.d.ts +2 -0
- package/data/build/dist/shared/contracts/subscription.d.ts.map +1 -1
- package/data/build/dist/shared/contracts/subscription.js.map +1 -1
- package/data/build/dist/shared/contracts/version.d.ts +1 -1
- package/data/build/dist/shared/contracts/version.js +1 -1
- package/data/build/dist/shared/index.d.ts +2 -1
- package/data/build/dist/shared/index.d.ts.map +1 -1
- package/data/build/dist/shared/index.js +1 -0
- package/data/build/dist/shared/index.js.map +1 -1
- package/data/build/dist/shared/magpie-provider-id.d.ts +12 -0
- package/data/build/dist/shared/magpie-provider-id.d.ts.map +1 -0
- package/data/build/dist/shared/magpie-provider-id.js +16 -0
- package/data/build/dist/shared/magpie-provider-id.js.map +1 -0
- package/package.json +1 -1
- package/profile/README.md +2 -2
- package/profile/package.json +2 -2
- package/profile/version.json +1 -1
- package/version.json +1 -1
package/README.en.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
[简体中文](README.md) · **English**
|
|
13
13
|
|
|
14
|
-
**Current release `@jingyi0605/codingns4dsh@0.2.1-rc.
|
|
14
|
+
**Current release `@jingyi0605/codingns4dsh@0.2.1-rc.4`** · DSH **`>=0.2.0-rc.2 <=0.2.1-rc.3`** (tested with `0.2.1-rc.3`) · Node **`>= 22.19`** · macOS / Linux / Windows
|
|
15
15
|
|
|
16
16
|
**[GitHub](https://github.com/jingyi0605/Codingns4DSH)** · **[npm](https://www.npmjs.com/package/@jingyi0605/codingns4dsh)** · **QQ group 1092985965** · **[WeChat / QQ QR codes](#community)**
|
|
17
17
|
|
|
@@ -225,7 +225,7 @@ The account menu shows login status, access method, connection latency and Host
|
|
|
225
225
|
### Use the Built-in Web Profile
|
|
226
226
|
|
|
227
227
|
```bash
|
|
228
|
-
dsh plugin --profile web add @jingyi0605/codingns4dsh@0.2.1-rc.
|
|
228
|
+
dsh plugin --profile web add @jingyi0605/codingns4dsh@0.2.1-rc.4
|
|
229
229
|
dsh web
|
|
230
230
|
```
|
|
231
231
|
|
|
@@ -235,7 +235,7 @@ Create a separate environment from the built-in Web profile:
|
|
|
235
235
|
|
|
236
236
|
```bash
|
|
237
237
|
dsh codingns --from-default-profile web --dump-config
|
|
238
|
-
dsh plugin --profile codingns add @jingyi0605/codingns4dsh@0.2.1-rc.
|
|
238
|
+
dsh plugin --profile codingns add @jingyi0605/codingns4dsh@0.2.1-rc.4
|
|
239
239
|
dsh codingns
|
|
240
240
|
```
|
|
241
241
|
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
**简体中文** · [English](README.en.md)
|
|
13
13
|
|
|
14
|
-
**当前版本 `@jingyi0605/codingns4dsh@0.2.1-rc.
|
|
14
|
+
**当前版本 `@jingyi0605/codingns4dsh@0.2.1-rc.4`** · DSH **`>=0.2.0-rc.2 <=0.2.1-rc.3`**(已验证 `0.2.1-rc.3`)· Node **`>= 22.19`** · macOS / Linux / Windows
|
|
15
15
|
|
|
16
16
|
**[GitHub](https://github.com/jingyi0605/Codingns4DSH)** · **[npm](https://www.npmjs.com/package/@jingyi0605/codingns4dsh)** · **QQ 群 1092985965** · **[微信群 / QQ 群二维码](#交流群)**
|
|
17
17
|
|
|
@@ -244,7 +244,7 @@ DSH 原生会话的翻译默认关闭,可在会话模型选择菜单中开启
|
|
|
244
244
|
### 使用内置 Web 配置
|
|
245
245
|
|
|
246
246
|
```bash
|
|
247
|
-
dsh plugin --profile web add @jingyi0605/codingns4dsh@0.2.1-rc.
|
|
247
|
+
dsh plugin --profile web add @jingyi0605/codingns4dsh@0.2.1-rc.4
|
|
248
248
|
dsh web
|
|
249
249
|
```
|
|
250
250
|
|
|
@@ -254,7 +254,7 @@ dsh web
|
|
|
254
254
|
|
|
255
255
|
```bash
|
|
256
256
|
dsh codingns --from-default-profile web --dump-config
|
|
257
|
-
dsh plugin --profile codingns add @jingyi0605/codingns4dsh@0.2.1-rc.
|
|
257
|
+
dsh plugin --profile codingns add @jingyi0605/codingns4dsh@0.2.1-rc.4
|
|
258
258
|
dsh codingns
|
|
259
259
|
```
|
|
260
260
|
|
|
@@ -8376,7 +8376,7 @@ window.__ModuleLoader__.load({
|
|
|
8376
8376
|
return /^0\.1\.5(?:-|$)/u.test(version);
|
|
8377
8377
|
}
|
|
8378
8378
|
/** Codingns4DSH 插件自身的 npm 版本。 */
|
|
8379
|
-
const CODINGNS_VERSION = "0.2.1-rc.
|
|
8379
|
+
const CODINGNS_VERSION = "0.2.1-rc.4";
|
|
8380
8380
|
/** 判断宿主版本是否落在当前插件声明的 DSH 兼容范围内;范围省略上界时不校验上限。 */
|
|
8381
8381
|
function isDshVersionCompatible(version) {
|
|
8382
8382
|
const match = /^>=([^ ]+)(?: <=([^ ]+))?$/u.exec(DSH_COMPATIBILITY);
|
|
@@ -20817,6 +20817,8 @@ window.__ModuleLoader__.load({
|
|
|
20817
20817
|
"magpie.routing": "Routing",
|
|
20818
20818
|
"magpie.statTokens": "Tokens",
|
|
20819
20819
|
"magpie.statCalls": "Requests",
|
|
20820
|
+
"magpie.statTurns": "Turns",
|
|
20821
|
+
"magpie.statSteps": "Steps",
|
|
20820
20822
|
"magpie.statWriteDown": "Output",
|
|
20821
20823
|
"magpie.statSessions": "Sessions",
|
|
20822
20824
|
"magpie.statReasoning": "Reasoning",
|
|
@@ -20984,6 +20986,11 @@ window.__ModuleLoader__.load({
|
|
|
20984
20986
|
"magpie.management.modelCountUnknown": "Model count not reported",
|
|
20985
20987
|
"magpie.management.modelCounts": "{exposed} exposed / {total} available models",
|
|
20986
20988
|
"magpie.management.providerName": "Provider name",
|
|
20989
|
+
"magpie.management.providerId": "Provider ID",
|
|
20990
|
+
"magpie.management.providerIdHint": "Lower-case letters, digits and dashes, as model IDs spell it ({id}/model). Renaming carries the routing groups and Agent configs that name its models along.",
|
|
20991
|
+
"magpie.management.providerIdLocked": "Magpie stores this provider under an ID it will not write again, so it cannot be renamed here.",
|
|
20992
|
+
"magpie.management.providerIdInvalid": "An ID needs at least one letter or digit.",
|
|
20993
|
+
"magpie.management.providerIdPreview": "Saved as {id}; the current one stays a remembered alias.",
|
|
20987
20994
|
"magpie.management.endpointType": "Endpoint type",
|
|
20988
20995
|
"magpie.management.endpointUrl": "Endpoint URL",
|
|
20989
20996
|
"magpie.management.exposedModels": "Exposed models",
|
|
@@ -21047,6 +21054,8 @@ window.__ModuleLoader__.load({
|
|
|
21047
21054
|
"magpie.management.reviewProvider": "Review provider changes",
|
|
21048
21055
|
"magpie.management.reviewGroup": "Review routing-group changes",
|
|
21049
21056
|
"magpie.management.reviewName": "Name: {value}",
|
|
21057
|
+
"magpie.management.reviewProviderId": "ID: {from} → {to}",
|
|
21058
|
+
"magpie.management.providerIdRenameHint": "Magpie saves the other changes under the current ID first, then moves the provider: the routing groups and Agent configs naming its models follow, and the current ID stays an alias of the new one.",
|
|
21050
21059
|
"magpie.management.reviewEndpoint": "{field} endpoint: {value}",
|
|
21051
21060
|
"magpie.management.reviewModels": "Model list: {count} entries",
|
|
21052
21061
|
"magpie.management.reviewRouting": "Routing: {value}",
|
|
@@ -21080,6 +21089,8 @@ window.__ModuleLoader__.load({
|
|
|
21080
21089
|
"magpie.previous": "Previous",
|
|
21081
21090
|
"magpie.next": "Next",
|
|
21082
21091
|
"magpie.pageOf": "Page {page}",
|
|
21092
|
+
"magpie.loadMore": "Load more",
|
|
21093
|
+
"magpie.loadedCount": "Loaded {count}",
|
|
21083
21094
|
"magpie.quotaHistory": "Allowance history",
|
|
21084
21095
|
"magpie.quotaHistoryNote": "Remaining allowance values recorded by Magpie; units follow each provider.",
|
|
21085
21096
|
"magpie.dailyUsage": "Daily usage",
|
|
@@ -21108,13 +21119,13 @@ window.__ModuleLoader__.load({
|
|
|
21108
21119
|
"magpie.install.reason.launch": "The entry {command} exists but Magpie could not run. Check the installation and try again.",
|
|
21109
21120
|
"magpie.install.reason.timeout": "The entry {command} did not answer in time. Check the installation and try again.",
|
|
21110
21121
|
"magpie.install.reason.version": "The entry {command} ran but did not report a recognizable Magpie version.",
|
|
21111
|
-
"magpie.install.command": "
|
|
21112
|
-
"magpie.install.installHelp.macos": "Install with
|
|
21113
|
-
"magpie.install.installHelp.windows": "Install
|
|
21114
|
-
"magpie.install.installHelp.linux": "Install with
|
|
21122
|
+
"magpie.install.command": "magpie --version",
|
|
21123
|
+
"magpie.install.installHelp.macos": "Install Magpie with the official GitHub release or installation script, then reopen DSH. The Host reads the login shell PATH and common standalone binary directories such as Homebrew and ~/.local/bin.",
|
|
21124
|
+
"magpie.install.installHelp.windows": "Install Magpie from the official GitHub release or installation script. The Host reads the Windows registry PATH and checks the installer's %USERPROFILE%\\.local\\bin location plus other common standalone binary directories. Reopen DSH after installing so it picks up the new PATH.",
|
|
21125
|
+
"magpie.install.installHelp.linux": "Install Magpie with the official GitHub release or installation script, then reopen DSH. The Host reads the login shell PATH plus /usr/local/bin and ~/.local/bin.",
|
|
21115
21126
|
"magpie.install.customToggle": "Specify the Magpie path",
|
|
21116
21127
|
"magpie.install.customLabel": "Absolute path to the Magpie executable",
|
|
21117
|
-
"magpie.install.customPlaceholder": "/opt/homebrew/bin/magpie or C:\\Users\\you\\
|
|
21128
|
+
"magpie.install.customPlaceholder": "/opt/homebrew/bin/magpie or C:\\Users\\you\\.local\\bin\\magpie.exe",
|
|
21118
21129
|
"magpie.install.customHelp": "Only an absolute path to a file is accepted; arguments are not allowed. The path is used for this session only.",
|
|
21119
21130
|
"magpie.install.customApply": "Detect this path",
|
|
21120
21131
|
"magpie.install.disabledNote": "Magpie management stays off until a working Magpie CLI is detected."
|
|
@@ -21127,6 +21138,8 @@ window.__ModuleLoader__.load({
|
|
|
21127
21138
|
"magpie.routing": "路由",
|
|
21128
21139
|
"magpie.statTokens": "Token",
|
|
21129
21140
|
"magpie.statCalls": "请求",
|
|
21141
|
+
"magpie.statTurns": "回合",
|
|
21142
|
+
"magpie.statSteps": "步骤",
|
|
21130
21143
|
"magpie.statWriteDown": "输出",
|
|
21131
21144
|
"magpie.statSessions": "会话数",
|
|
21132
21145
|
"magpie.statReasoning": "推理",
|
|
@@ -21294,6 +21307,11 @@ window.__ModuleLoader__.load({
|
|
|
21294
21307
|
"magpie.management.modelCountUnknown": "未报告模型数量",
|
|
21295
21308
|
"magpie.management.modelCounts": "已公开 {exposed} / 可用 {total} 个模型",
|
|
21296
21309
|
"magpie.management.providerName": "提供商名称",
|
|
21310
|
+
"magpie.management.providerId": "提供商 ID",
|
|
21311
|
+
"magpie.management.providerIdHint": "只能使用小写字母、数字和短横线,模型 ID 以它开头({id}/模型)。改名时会一并迁移引用其模型的路由组与 Agent 配置。",
|
|
21312
|
+
"magpie.management.providerIdLocked": "Magpie 以这个不会再写入的 ID 保存该提供商,因此此处不能改名。",
|
|
21313
|
+
"magpie.management.providerIdInvalid": "ID 至少需要一个字母或数字。",
|
|
21314
|
+
"magpie.management.providerIdPreview": "将保存为 {id};原 ID 仍会作为别名保留。",
|
|
21297
21315
|
"magpie.management.endpointType": "端点类型",
|
|
21298
21316
|
"magpie.management.endpointUrl": "端点 URL",
|
|
21299
21317
|
"magpie.management.exposedModels": "已公开模型",
|
|
@@ -21357,6 +21375,8 @@ window.__ModuleLoader__.load({
|
|
|
21357
21375
|
"magpie.management.reviewProvider": "确认提供商变更",
|
|
21358
21376
|
"magpie.management.reviewGroup": "确认路由组变更",
|
|
21359
21377
|
"magpie.management.reviewName": "名称:{value}",
|
|
21378
|
+
"magpie.management.reviewProviderId": "ID:{from} → {to}",
|
|
21379
|
+
"magpie.management.providerIdRenameHint": "Magpie 会先在当前 ID 下保存其他变更,再迁移该提供商:引用其模型的路由组与 Agent 配置会随之迁移,当前 ID 会保留为新 ID 的别名。",
|
|
21360
21380
|
"magpie.management.reviewEndpoint": "{field} 端点:{value}",
|
|
21361
21381
|
"magpie.management.reviewModels": "模型列表:{count} 项",
|
|
21362
21382
|
"magpie.management.reviewRouting": "路由:{value}",
|
|
@@ -21390,6 +21410,8 @@ window.__ModuleLoader__.load({
|
|
|
21390
21410
|
"magpie.previous": "上一页",
|
|
21391
21411
|
"magpie.next": "下一页",
|
|
21392
21412
|
"magpie.pageOf": "第 {page} 页",
|
|
21413
|
+
"magpie.loadMore": "加载更多",
|
|
21414
|
+
"magpie.loadedCount": "已加载 {count} 条",
|
|
21393
21415
|
"magpie.quotaHistory": "额度历史",
|
|
21394
21416
|
"magpie.quotaHistoryNote": "Magpie 记录的剩余额度;单位以各提供商报告为准。",
|
|
21395
21417
|
"magpie.dailyUsage": "每日用量",
|
|
@@ -21418,13 +21440,13 @@ window.__ModuleLoader__.load({
|
|
|
21418
21440
|
"magpie.install.reason.launch": "入口 {command} 存在,但 Magpie 无法运行;请检查安装后重试。",
|
|
21419
21441
|
"magpie.install.reason.timeout": "入口 {command} 未在限定时间内响应;请检查安装后重试。",
|
|
21420
21442
|
"magpie.install.reason.version": "入口 {command} 已运行,但没有输出可识别的 Magpie 版本。",
|
|
21421
|
-
"magpie.install.command": "
|
|
21422
|
-
"magpie.install.installHelp.macos": "
|
|
21423
|
-
"magpie.install.installHelp.windows": "
|
|
21424
|
-
"magpie.install.installHelp.linux": "
|
|
21443
|
+
"magpie.install.command": "magpie --version",
|
|
21444
|
+
"magpie.install.installHelp.macos": "请使用官方 GitHub Release 或安装脚本安装 Magpie,然后重新打开 DSH。Host 会读取登录 Shell 的 PATH,以及 Homebrew、/usr/local/bin、~/.local/bin 等常见独立程序目录。",
|
|
21445
|
+
"magpie.install.installHelp.windows": "请使用官方 GitHub Release 或安装脚本安装 Magpie。Host 会读取 Windows 注册表中的 PATH,并检查安装脚本使用的 %USERPROFILE%\\.local\\bin 以及其他常见独立程序目录。安装后请重新打开 DSH,以读取新的 PATH。",
|
|
21446
|
+
"magpie.install.installHelp.linux": "请使用官方 GitHub Release 或安装脚本安装 Magpie,然后重新打开 DSH。Host 会读取登录 Shell 的 PATH、/usr/local/bin 和 ~/.local/bin。",
|
|
21425
21447
|
"magpie.install.customToggle": "手动指定 Magpie 路径",
|
|
21426
21448
|
"magpie.install.customLabel": "Magpie 可执行文件的绝对路径",
|
|
21427
|
-
"magpie.install.customPlaceholder": "/opt/homebrew/bin/magpie 或 C:\\Users
|
|
21449
|
+
"magpie.install.customPlaceholder": "/opt/homebrew/bin/magpie 或 C:\\Users\\你\\.local\\bin\\magpie.exe",
|
|
21428
21450
|
"magpie.install.customHelp": "只接受文件绝对路径,不允许附加参数;该路径只在本次会话生效。",
|
|
21429
21451
|
"magpie.install.customApply": "检测此路径",
|
|
21430
21452
|
"magpie.install.disabledNote": "检测到可用的 Magpie CLI 前,Magpie 管理保持关闭。"
|
|
@@ -25022,6 +25044,19 @@ window.__ModuleLoader__.load({
|
|
|
25022
25044
|
return age >= 0 && age < refreshIntervalMins * 6e4;
|
|
25023
25045
|
}
|
|
25024
25046
|
//#endregion
|
|
25047
|
+
//#region src/shared/magpie-provider-id.ts
|
|
25048
|
+
/**
|
|
25049
|
+
* Magpie's own spelling of a provider ID (`provider.Slug`): lower-case letters and digits, every
|
|
25050
|
+
* run of anything else folded into one dash, and no dash at either end.
|
|
25051
|
+
*
|
|
25052
|
+
* Magpie accepts a provider only under an ID it spells this way, so a rename has to be written in
|
|
25053
|
+
* this form; the Host refuses anything else and the editor shows what would be stored. One rule,
|
|
25054
|
+
* both sides.
|
|
25055
|
+
*/
|
|
25056
|
+
function magpieProviderId(value) {
|
|
25057
|
+
return value.toLocaleLowerCase().replace(/[^a-z0-9]+/gu, "-").replace(/^-+|-+$/gu, "");
|
|
25058
|
+
}
|
|
25059
|
+
//#endregion
|
|
25025
25060
|
//#region src/shared/voice-stream.ts
|
|
25026
25061
|
const ASSISTANT_VOICE_STREAM_PATH = "/api/codingns/assistant/voice/stream";
|
|
25027
25062
|
const ASSISTANT_VOICE_EVENTS_PATH = "/api/codingns/assistant/voice/events";
|
|
@@ -33745,12 +33780,18 @@ window.__ModuleLoader__.load({
|
|
|
33745
33780
|
}
|
|
33746
33781
|
function MagpieProvidersPage({ snapshot, t, onUpdate, onAccountUpdate, writing }) {
|
|
33747
33782
|
const providers = snapshot?.providers ?? [];
|
|
33748
|
-
const [
|
|
33749
|
-
|
|
33783
|
+
const [selectedSelection, setSelectedSelection] = (0, react.useState)(() => providers[0] === void 0 ? null : {
|
|
33784
|
+
id: providers[0].id,
|
|
33785
|
+
renamedTo: null
|
|
33786
|
+
});
|
|
33787
|
+
const selected = providers.find((provider) => provider.id === selectedSelection?.id) ?? providers.find((provider) => provider.id === selectedSelection?.renamedTo) ?? providers[0] ?? null;
|
|
33750
33788
|
const unlinkedAccounts = snapshot?.accountStatus === "available" ? snapshot.accounts.filter((account) => !providers.some((provider) => accountBelongsToProvider(account, provider))) : [];
|
|
33751
33789
|
(0, react.useEffect)(() => {
|
|
33752
|
-
if (selected !== null && selected.id !==
|
|
33753
|
-
|
|
33790
|
+
if (selected !== null && selected.id !== selectedSelection?.id && selected.id !== selectedSelection?.renamedTo) setSelectedSelection({
|
|
33791
|
+
id: selected.id,
|
|
33792
|
+
renamedTo: null
|
|
33793
|
+
});
|
|
33794
|
+
}, [selected, selectedSelection]);
|
|
33754
33795
|
return (0, react.createElement)("div", { className: "codingns-magpie-view" }, snapshot?.providerStatus === "unavailable" ? (0, react.createElement)(PanelEmpty, { message: t("magpie.management.providersUnavailable") }) : providers.length === 0 ? (0, react.createElement)(PanelEmpty, { message: t("magpie.management.noProviders") }) : (0, react.createElement)("div", { className: "codingns-magpie-management-grid" }, (0, react.createElement)("nav", {
|
|
33755
33796
|
className: "codingns-magpie-panel codingns-magpie-management-list",
|
|
33756
33797
|
"aria-label": t("magpie.management.providers")
|
|
@@ -33759,7 +33800,10 @@ window.__ModuleLoader__.load({
|
|
|
33759
33800
|
type: "button",
|
|
33760
33801
|
className: `codingns-magpie-management-row${provider.id === selected?.id ? " is-active" : ""}`,
|
|
33761
33802
|
"aria-pressed": provider.id === selected?.id,
|
|
33762
|
-
onClick: () =>
|
|
33803
|
+
onClick: () => setSelectedSelection({
|
|
33804
|
+
id: provider.id,
|
|
33805
|
+
renamedTo: null
|
|
33806
|
+
})
|
|
33763
33807
|
}, (0, react.createElement)(MagpieProviderLogo, {
|
|
33764
33808
|
identities: [
|
|
33765
33809
|
provider.accountAgent,
|
|
@@ -33773,11 +33817,16 @@ window.__ModuleLoader__.load({
|
|
|
33773
33817
|
state: provider.state === "on" ? "on" : provider.state === "off" ? "off" : "unknown",
|
|
33774
33818
|
t
|
|
33775
33819
|
})))), selected === null ? (0, react.createElement)(PanelEmpty, { message: t("magpie.management.noProviders") }) : (0, react.createElement)(ProviderEditor, {
|
|
33820
|
+
key: selected.id,
|
|
33776
33821
|
provider: selected,
|
|
33777
33822
|
snapshot,
|
|
33778
33823
|
t,
|
|
33779
33824
|
onUpdate,
|
|
33780
33825
|
onAccountUpdate,
|
|
33826
|
+
onRenamed: (previousId, nextId) => setSelectedSelection({
|
|
33827
|
+
id: previousId,
|
|
33828
|
+
renamedTo: nextId
|
|
33829
|
+
}),
|
|
33781
33830
|
writing
|
|
33782
33831
|
})), unlinkedAccounts.length > 0 && (0, react.createElement)("section", { className: "codingns-magpie-panel codingns-magpie-management-editor" }, (0, react.createElement)("div", { className: "codingns-magpie-panel-head" }, (0, react.createElement)("div", void 0, (0, react.createElement)("h2", void 0, t("magpie.management.unlinkedAccounts")), (0, react.createElement)("p", void 0, t("magpie.management.unlinkedAccountsNote")))), (0, react.createElement)(AccountGrid, {
|
|
33783
33832
|
accounts: unlinkedAccounts,
|
|
@@ -33788,11 +33837,12 @@ window.__ModuleLoader__.load({
|
|
|
33788
33837
|
onUpdate: onAccountUpdate
|
|
33789
33838
|
})));
|
|
33790
33839
|
}
|
|
33791
|
-
function ProviderEditor({ provider, snapshot, t, onUpdate, onAccountUpdate, writing }) {
|
|
33840
|
+
function ProviderEditor({ provider, snapshot, t, onUpdate, onAccountUpdate, onRenamed, writing }) {
|
|
33792
33841
|
const editableEndpoints = provider.endpoints.filter((endpoint) => endpoint.editable);
|
|
33793
33842
|
const endpointKey = editableEndpoints.map((endpoint) => `${endpoint.field}:${endpoint.url}`).join("|");
|
|
33794
33843
|
const modelsKey = provider.models.map((model) => `${model.id}:${model.exposed ? "on" : "off"}`).join("|");
|
|
33795
33844
|
const [name, setName] = (0, react.useState)(provider.name);
|
|
33845
|
+
const [id, setId] = (0, react.useState)(provider.id);
|
|
33796
33846
|
const [endpointField, setEndpointField] = (0, react.useState)(editableEndpoints[0]?.field ?? "");
|
|
33797
33847
|
const [endpointUrl, setEndpointUrl] = (0, react.useState)(editableEndpoints[0]?.url ?? "");
|
|
33798
33848
|
const [enabledModelIds, setEnabledModelIds] = (0, react.useState)(() => provider.models.filter((model) => model.exposed).map((model) => model.id));
|
|
@@ -33801,6 +33851,7 @@ window.__ModuleLoader__.load({
|
|
|
33801
33851
|
const [notice, setNotice] = (0, react.useState)("");
|
|
33802
33852
|
(0, react.useEffect)(() => {
|
|
33803
33853
|
setName(provider.name);
|
|
33854
|
+
setId(provider.id);
|
|
33804
33855
|
setEndpointField(editableEndpoints[0]?.field ?? "");
|
|
33805
33856
|
setEndpointUrl(editableEndpoints[0]?.url ?? "");
|
|
33806
33857
|
setEnabledModelIds(provider.models.filter((model) => model.exposed).map((model) => model.id));
|
|
@@ -33812,11 +33863,13 @@ window.__ModuleLoader__.load({
|
|
|
33812
33863
|
modelsKey
|
|
33813
33864
|
]);
|
|
33814
33865
|
const endpoint = editableEndpoints.find((item) => item.field === endpointField);
|
|
33866
|
+
const nextId = magpieProviderId(id);
|
|
33815
33867
|
const proposed = () => {
|
|
33816
33868
|
const models = provider.models.filter((model) => enabledModelIds.includes(model.id)).map((model) => model.id);
|
|
33817
33869
|
const currentModels = provider.models.filter((model) => model.exposed).map((model) => model.id);
|
|
33818
33870
|
const update = {
|
|
33819
33871
|
id: provider.id,
|
|
33872
|
+
...provider.idEditable && nextId !== provider.id ? { newId: nextId } : {},
|
|
33820
33873
|
...name.trim() === provider.name ? {} : { name: name.trim() },
|
|
33821
33874
|
...endpoint === void 0 || endpointUrl.trim() === endpoint.url ? {} : {
|
|
33822
33875
|
endpointField: endpoint.field,
|
|
@@ -33836,6 +33889,7 @@ window.__ModuleLoader__.load({
|
|
|
33836
33889
|
setNotice("");
|
|
33837
33890
|
try {
|
|
33838
33891
|
await onUpdate(review);
|
|
33892
|
+
if (review.newId !== void 0) onRenamed(provider.id, review.newId);
|
|
33839
33893
|
setReview(null);
|
|
33840
33894
|
setNotice(t("magpie.management.saved"));
|
|
33841
33895
|
} catch {
|
|
@@ -33887,7 +33941,17 @@ window.__ModuleLoader__.load({
|
|
|
33887
33941
|
value: name,
|
|
33888
33942
|
maxLength: 80,
|
|
33889
33943
|
onChange: (event) => setName(event.currentTarget.value)
|
|
33890
|
-
})),
|
|
33944
|
+
})), (0, react.createElement)("label", { className: "codingns-magpie-field" }, (0, react.createElement)("span", void 0, t("magpie.management.providerId")), (0, react.createElement)("input", {
|
|
33945
|
+
className: "codingns-magpie-provider-id-input",
|
|
33946
|
+
value: id,
|
|
33947
|
+
maxLength: 64,
|
|
33948
|
+
disabled: !provider.idEditable,
|
|
33949
|
+
spellCheck: false,
|
|
33950
|
+
autoCapitalize: "none",
|
|
33951
|
+
autoCorrect: "off",
|
|
33952
|
+
"aria-label": t("magpie.management.providerId"),
|
|
33953
|
+
onChange: (event) => setId(event.currentTarget.value.toLowerCase())
|
|
33954
|
+
}), (0, react.createElement)("small", void 0, t(provider.idEditable ? "magpie.management.providerIdHint" : "magpie.management.providerIdLocked")), provider.idEditable && id !== provider.id && (0, react.createElement)("small", void 0, nextId === "" ? t("magpie.management.providerIdInvalid") : t("magpie.management.providerIdPreview", { id: nextId }))), editableEndpoints.length > 0 && (0, react.createElement)("div", { className: "codingns-magpie-field-row" }, (0, react.createElement)("label", { className: "codingns-magpie-field" }, (0, react.createElement)("span", void 0, t("magpie.management.endpointType")), (0, react.createElement)("select", {
|
|
33891
33955
|
value: endpointField,
|
|
33892
33956
|
onChange: (event) => {
|
|
33893
33957
|
const next = provider.endpoints.find((item) => item.field === event.currentTarget.value);
|
|
@@ -33932,7 +33996,7 @@ window.__ModuleLoader__.load({
|
|
|
33932
33996
|
}, model.name ?? model.id), (0, react.createElement)("code", {
|
|
33933
33997
|
className: "codingns-magpie-model-id",
|
|
33934
33998
|
title: model.id
|
|
33935
|
-
}, model.id)))))), review !== null && (0, react.createElement)("div", { className: "codingns-magpie-confirm" }, (0, react.createElement)("strong", void 0, t("magpie.management.reviewProvider")), (0, react.createElement)("span", void 0, summarizeProviderUpdate(review, t)), (0, react.createElement)("div", { className: "codingns-magpie-management-actions" }, (0, react.createElement)("button", {
|
|
33999
|
+
}, model.id)))))), review !== null && (0, react.createElement)("div", { className: "codingns-magpie-confirm" }, (0, react.createElement)("strong", void 0, t("magpie.management.reviewProvider")), (0, react.createElement)("span", void 0, summarizeProviderUpdate(review, t)), review.newId !== void 0 && (0, react.createElement)("small", void 0, t("magpie.management.providerIdRenameHint")), (0, react.createElement)("div", { className: "codingns-magpie-management-actions" }, (0, react.createElement)("button", {
|
|
33936
34000
|
type: "button",
|
|
33937
34001
|
disabled: saving || writing,
|
|
33938
34002
|
onClick: () => setReview(null)
|
|
@@ -33949,6 +34013,7 @@ window.__ModuleLoader__.load({
|
|
|
33949
34013
|
disabled: writing,
|
|
33950
34014
|
onClick: () => {
|
|
33951
34015
|
setName(provider.name);
|
|
34016
|
+
setId(provider.id);
|
|
33952
34017
|
setEndpointUrl(editableEndpoints.find((item) => item.field === endpointField)?.url ?? "");
|
|
33953
34018
|
setEnabledModelIds(provider.models.filter((model) => model.exposed).map((model) => model.id));
|
|
33954
34019
|
setNotice("");
|
|
@@ -34694,6 +34759,10 @@ window.__ModuleLoader__.load({
|
|
|
34694
34759
|
}
|
|
34695
34760
|
function summarizeProviderUpdate(update, t) {
|
|
34696
34761
|
const changes = [];
|
|
34762
|
+
if (update.newId !== void 0) changes.push(t("magpie.management.reviewProviderId", {
|
|
34763
|
+
from: update.id,
|
|
34764
|
+
to: update.newId
|
|
34765
|
+
}));
|
|
34697
34766
|
if (update.name !== void 0) changes.push(t("magpie.management.reviewName", { value: update.name }));
|
|
34698
34767
|
if (update.endpointUrl !== void 0) changes.push(t("magpie.management.reviewEndpoint", {
|
|
34699
34768
|
field: update.endpointField ?? "",
|
|
@@ -35560,10 +35629,11 @@ window.__ModuleLoader__.load({
|
|
|
35560
35629
|
try {
|
|
35561
35630
|
const result = await callMagpieRpc(rpc, "management/provider/update", update);
|
|
35562
35631
|
setManagement(result.snapshot);
|
|
35632
|
+
await loadManagement(new AbortController().signal).catch(() => void 0);
|
|
35563
35633
|
} finally {
|
|
35564
35634
|
setManagementWriting(false);
|
|
35565
35635
|
}
|
|
35566
|
-
}, [rpc]);
|
|
35636
|
+
}, [loadManagement, rpc]);
|
|
35567
35637
|
const updateGroup = (0, react.useCallback)(async (update) => {
|
|
35568
35638
|
setManagementWriting(true);
|
|
35569
35639
|
try {
|
|
@@ -35595,6 +35665,7 @@ window.__ModuleLoader__.load({
|
|
|
35595
35665
|
limit: PAGE_SIZE,
|
|
35596
35666
|
...selectedSession === null ? {} : {
|
|
35597
35667
|
sessionId: selectedSession.id,
|
|
35668
|
+
...selectedSession.sessionIds === void 0 ? {} : { sessionIds: selectedSession.sessionIds },
|
|
35598
35669
|
sessionAgent: selectedSession.agent
|
|
35599
35670
|
}
|
|
35600
35671
|
}, controller.signal).then((next) => {
|
|
@@ -36038,7 +36109,7 @@ window.__ModuleLoader__.load({
|
|
|
36038
36109
|
}
|
|
36039
36110
|
return any ? total : { ...total };
|
|
36040
36111
|
}
|
|
36041
|
-
function RequestsPage({ page, loading, error, selectedSession, offset, onOffsetChange, onClearSession, t }) {
|
|
36112
|
+
function RequestsPage({ page, loading, error, selectedSession, offset, onOffsetChange, onClearSession, t, append = false }) {
|
|
36042
36113
|
const items = page?.items ?? [];
|
|
36043
36114
|
const aggregate = sumRequests(items);
|
|
36044
36115
|
const stats = [
|
|
@@ -36052,6 +36123,11 @@ window.__ModuleLoader__.load({
|
|
|
36052
36123
|
value: formatInteger$1(page?.total ?? aggregate.calls),
|
|
36053
36124
|
detail: `${formatInteger$1(aggregate.errors)} ${t("magpie.metricErrors")} · ${formatInteger$1(aggregate.retried)} ${t("magpie.metricRetries")}`
|
|
36054
36125
|
},
|
|
36126
|
+
...selectedSession === null ? [] : [{
|
|
36127
|
+
label: t("magpie.statTurns"),
|
|
36128
|
+
value: formatInteger$1(page?.sessionMetrics?.turns ?? null),
|
|
36129
|
+
detail: `${t("magpie.statSteps")} ${formatInteger$1(page?.sessionMetrics?.steps ?? null)}`
|
|
36130
|
+
}],
|
|
36055
36131
|
{
|
|
36056
36132
|
label: t("magpie.metricCost"),
|
|
36057
36133
|
value: formatValue(aggregate.cost),
|
|
@@ -36068,6 +36144,8 @@ window.__ModuleLoader__.load({
|
|
|
36068
36144
|
detail: t("magpie.statLatencyNote")
|
|
36069
36145
|
}
|
|
36070
36146
|
];
|
|
36147
|
+
/** 追加列表按位置生成稳定 key,翻页列表按本页偏移生成,切换页面时行不会错位。 */
|
|
36148
|
+
const rowKey = (index) => append ? index : offset + index;
|
|
36071
36149
|
return (0, react.createElement)("div", { className: "codingns-magpie-view" }, selectedSession !== null && (0, react.createElement)("div", { className: "codingns-magpie-selection" }, (0, react.createElement)("span", { className: "codingns-magpie-provider-inline" }, (0, react.createElement)(MagpieProviderLogo, {
|
|
36072
36150
|
identities: [selectedSession.agent],
|
|
36073
36151
|
size: 20,
|
|
@@ -36083,15 +36161,20 @@ window.__ModuleLoader__.load({
|
|
|
36083
36161
|
}, t("magpie.clearSession"))), error && (0, react.createElement)(InlineNotice, { message: t("magpie.usageUnavailable") }), loading && page === null ? (0, react.createElement)(EmptyState, {
|
|
36084
36162
|
message: t("magpie.loading"),
|
|
36085
36163
|
loading: true
|
|
36086
|
-
}) : page === null
|
|
36087
|
-
key: `${request.routeId ??
|
|
36164
|
+
}) : page === null ? (0, react.createElement)(EmptyState, { message: t("magpie.noRequests") }) : (0, react.createElement)("div", void 0, (0, react.createElement)(StatStrip, { stats }), items.length === 0 ? (0, react.createElement)(EmptyState, { message: t("magpie.noRequests") }) : (0, react.createElement)("section", { className: "codingns-magpie-panel codingns-magpie-request-panel" }, (0, react.createElement)("div", { className: "codingns-magpie-reqlist" }, ...items.map((request, index) => (0, react.createElement)(NativeRequestCard, {
|
|
36165
|
+
key: `${request.routeId ?? rowKey(index)}:${request.time ?? ""}`,
|
|
36088
36166
|
request,
|
|
36089
36167
|
t
|
|
36090
36168
|
}))), (0, react.createElement)("div", { className: "codingns-magpie-table-scroll" }, (0, react.createElement)("table", { className: "codingns-magpie-table codingns-magpie-native-table" }, (0, react.createElement)("thead", void 0, (0, react.createElement)("tr", void 0, (0, react.createElement)("th", void 0, t("magpie.ncolTime")), (0, react.createElement)("th", void 0, "AGENT"), (0, react.createElement)("th", void 0, t("magpie.ncolRequested")), (0, react.createElement)("th", void 0, t("magpie.ncolProvider")), (0, react.createElement)("th", void 0, t("magpie.ncolServed")), (0, react.createElement)("th", void 0, t("magpie.ncolInput")), (0, react.createElement)("th", void 0, t("magpie.ncolOutput")), (0, react.createElement)("th", void 0, t("magpie.ncolCost")), (0, react.createElement)("th", void 0, t("magpie.ncolFirstText")), (0, react.createElement)("th", void 0, t("magpie.ncolDuration")), (0, react.createElement)("th", void 0, t("magpie.ncolSpeed")), (0, react.createElement)("th", void 0, t("magpie.ncolStatus")))), (0, react.createElement)("tbody", void 0, ...items.map((request, index) => (0, react.createElement)(NativeRequestRow, {
|
|
36091
|
-
key: `${request.routeId ??
|
|
36169
|
+
key: `${request.routeId ?? rowKey(index)}:${request.time ?? ""}`,
|
|
36092
36170
|
request,
|
|
36093
36171
|
t
|
|
36094
|
-
}))))), (0, react.createElement)("div", { className: "codingns-magpie-pagination" }, (0, react.createElement)("span", void 0, page.total === null ? t("magpie.pageOf", { page: Math.floor(offset / PAGE_SIZE) + 1 }) : `${offset + 1}–${Math.min(offset + items.length, page.total)} / ${formatInteger$1(page.total)}`), (0, react.createElement)("div", void 0, (0, react.createElement)("button", {
|
|
36172
|
+
}))))), (0, react.createElement)("div", { className: "codingns-magpie-pagination" }, (0, react.createElement)("span", void 0, append ? page.total === null ? t("magpie.loadedCount", { count: formatInteger$1(items.length) }) : `${formatInteger$1(items.length)} / ${formatInteger$1(page.total)}` : page.total === null ? t("magpie.pageOf", { page: Math.floor(offset / PAGE_SIZE) + 1 }) : `${offset + 1}–${Math.min(offset + items.length, page.total)} / ${formatInteger$1(page.total)}`), (0, react.createElement)("div", void 0, append ? (0, react.createElement)("button", {
|
|
36173
|
+
type: "button",
|
|
36174
|
+
className: "codingns-magpie-load-more",
|
|
36175
|
+
disabled: !page.hasMore || loading,
|
|
36176
|
+
onClick: () => onOffsetChange(items.length)
|
|
36177
|
+
}, loading ? t("magpie.loading") : t("magpie.loadMore")) : (0, react.createElement)(react.Fragment, void 0, (0, react.createElement)("button", {
|
|
36095
36178
|
type: "button",
|
|
36096
36179
|
disabled: offset === 0 || loading,
|
|
36097
36180
|
onClick: () => onOffsetChange(Math.max(0, offset - PAGE_SIZE))
|
|
@@ -36099,7 +36182,7 @@ window.__ModuleLoader__.load({
|
|
|
36099
36182
|
type: "button",
|
|
36100
36183
|
disabled: !page.hasMore || loading,
|
|
36101
36184
|
onClick: () => onOffsetChange(offset + PAGE_SIZE)
|
|
36102
|
-
}, t("magpie.next")))))));
|
|
36185
|
+
}, t("magpie.next"))))))));
|
|
36103
36186
|
}
|
|
36104
36187
|
function sumRequests(items) {
|
|
36105
36188
|
const total = {
|
|
@@ -39421,6 +39504,7 @@ html[data-codingns-mobile-sidebar="on"] .codingns-magpie-page{padding-left:0;--m
|
|
|
39421
39504
|
const [clock, setClock] = (0, react.useState)(() => Date.now());
|
|
39422
39505
|
const rootRef = (0, react.useRef)(null);
|
|
39423
39506
|
const magpiePopoverRef = (0, react.useRef)(null);
|
|
39507
|
+
const magpieRequestsDialogRef = (0, react.useRef)(null);
|
|
39424
39508
|
const resetDialogRef = (0, react.useRef)(null);
|
|
39425
39509
|
const refreshRef = (0, react.useRef)(null);
|
|
39426
39510
|
const routeRefreshControllerRef = (0, react.useRef)(null);
|
|
@@ -39644,7 +39728,7 @@ html[data-codingns-mobile-sidebar="on"] .codingns-magpie-page{padding-left:0;--m
|
|
|
39644
39728
|
}
|
|
39645
39729
|
})();
|
|
39646
39730
|
};
|
|
39647
|
-
useDismissOnOutsidePointer(rootRef, open, () => setOpen(false));
|
|
39731
|
+
useDismissOnOutsidePointer(rootRef, open, () => setOpen(false), { portal: magpieRequestsDialogRef });
|
|
39648
39732
|
useDismissOnOutsidePointer(resetDialogRef, resetOpen && !resetPending, closeResetDialog);
|
|
39649
39733
|
if (!eligible || snapshot === null) return null;
|
|
39650
39734
|
if (snapshot.magpie !== null) {
|
|
@@ -39679,7 +39763,8 @@ html[data-codingns-mobile-sidebar="on"] .codingns-magpie-page{padding-left:0;--m
|
|
|
39679
39763
|
expandedGroups: expandedQuotaGroups,
|
|
39680
39764
|
onToggleGroup: toggleQuotaGroup,
|
|
39681
39765
|
placement: magpiePlacement,
|
|
39682
|
-
popoverRef: magpiePopoverRef
|
|
39766
|
+
popoverRef: magpiePopoverRef,
|
|
39767
|
+
requestsDialogRef: magpieRequestsDialogRef
|
|
39683
39768
|
}));
|
|
39684
39769
|
}
|
|
39685
39770
|
const usage = snapshot.providerUsage;
|
|
@@ -39814,7 +39899,7 @@ html[data-codingns-mobile-sidebar="on"] .codingns-magpie-page{padding-left:0;--m
|
|
|
39814
39899
|
function MagpieUsagePopover({ rpc, usage, t, tab = "usage", onTabChange = () => {}, expandedGroups = [], onToggleGroup = () => {}, placement = {
|
|
39815
39900
|
left: 0,
|
|
39816
39901
|
width: 400
|
|
39817
|
-
}, popoverRef }) {
|
|
39902
|
+
}, popoverRef, requestsDialogRef }) {
|
|
39818
39903
|
const aggregateRows = usage.aggregate === null ? [] : [
|
|
39819
39904
|
[t("usage.magpieRequests"), formatMagpieNumber(usage.aggregate.calls)],
|
|
39820
39905
|
[t("usage.magpieErrors"), formatMagpieNumber(usage.aggregate.errors)],
|
|
@@ -39889,7 +39974,8 @@ html[data-codingns-mobile-sidebar="on"] .codingns-magpie-page{padding-left:0;--m
|
|
|
39889
39974
|
quotas,
|
|
39890
39975
|
t,
|
|
39891
39976
|
expandedGroups,
|
|
39892
|
-
onToggleGroup
|
|
39977
|
+
onToggleGroup,
|
|
39978
|
+
...requestsDialogRef === void 0 ? {} : { requestsDialogRef }
|
|
39893
39979
|
})));
|
|
39894
39980
|
}
|
|
39895
39981
|
function MagpieUsagePanel({ usage, aggregateRows, sessionRows, t }) {
|
|
@@ -39909,10 +39995,11 @@ html[data-codingns-mobile-sidebar="on"] .codingns-magpie-page{padding-left:0;--m
|
|
|
39909
39995
|
style: magpieProviderBadgeStyle
|
|
39910
39996
|
}, provider)));
|
|
39911
39997
|
}
|
|
39912
|
-
function MagpieRoutePanel({ rpc, usage, quotas, t, expandedGroups, onToggleGroup }) {
|
|
39998
|
+
function MagpieRoutePanel({ rpc, usage, quotas, t, expandedGroups, onToggleGroup, requestsDialogRef }) {
|
|
39913
39999
|
const route = usage.route;
|
|
39914
40000
|
const groups = groupQuotasByProvider(quotas);
|
|
39915
40001
|
const sessionAccount = route?.providerAccount ?? null;
|
|
40002
|
+
const requestSessionId = usage.requestSessionId ?? usage.session?.id ?? usage.sessionId;
|
|
39916
40003
|
const quotaMessage = magpieQuotaUnavailableMessage(usage, quotas, t);
|
|
39917
40004
|
const routeStatus = usage.routeStatus === "no-route" ? t("usage.magpieRouteNoRequests") : usage.routeStatus === "session-unavailable" ? t("usage.magpieSessionIdUnavailable") : t("usage.magpieRouteUnavailable");
|
|
39918
40005
|
const routeStages = route === null ? [] : [
|
|
@@ -39948,10 +40035,11 @@ html[data-codingns-mobile-sidebar="on"] .codingns-magpie-page{padding-left:0;--m
|
|
|
39948
40035
|
}))));
|
|
39949
40036
|
})), (0, react.createElement)("section", { style: magpieSectionStyle }, (0, react.createElement)("div", { style: magpieRouteHeadingStyle }, (0, react.createElement)("strong", { style: magpieSectionTitleStyle }, t("usage.magpieRouteTitle")), route !== null && (0, react.createElement)("div", { style: magpieRouteHeadingActionsStyle }, (0, react.createElement)(MagpieRouteRequests, {
|
|
39950
40037
|
rpc,
|
|
39951
|
-
sessionId:
|
|
40038
|
+
sessionId: requestSessionId,
|
|
39952
40039
|
sessionName: usage.sessionName ?? null,
|
|
39953
40040
|
agent: usage.agent,
|
|
39954
|
-
t
|
|
40041
|
+
t,
|
|
40042
|
+
...requestsDialogRef === void 0 ? {} : { requestsDialogRef }
|
|
39955
40043
|
}), (0, react.createElement)("span", {
|
|
39956
40044
|
className: active ? "codingns4dsh-magpie-route-node-active" : void 0,
|
|
39957
40045
|
style: magpieRouteStatusStyle
|
|
@@ -39997,7 +40085,7 @@ html[data-codingns-mobile-sidebar="on"] .codingns-magpie-page{padding-left:0;--m
|
|
|
39997
40085
|
* `MagpieRoutePanel` 渲染元素,真正的状态留在本组件内部。模态框内的请求明细
|
|
39998
40086
|
* 直接复用管理页的 `RequestsPage`,只把会话筛选固定为当前会话。
|
|
39999
40087
|
*/
|
|
40000
|
-
function MagpieRouteRequests({ rpc, sessionId, sessionName, agent, t }) {
|
|
40088
|
+
function MagpieRouteRequests({ rpc, sessionId, sessionName, agent, t, requestsDialogRef }) {
|
|
40001
40089
|
const enabled = canReadMagpieSessionRequests(sessionId, agent);
|
|
40002
40090
|
const [open, setOpen] = (0, react.useState)(false);
|
|
40003
40091
|
const [page, setPage] = (0, react.useState)(null);
|
|
@@ -40006,23 +40094,29 @@ html[data-codingns-mobile-sidebar="on"] .codingns-magpie-page{padding-left:0;--m
|
|
|
40006
40094
|
const [error, setError] = (0, react.useState)(false);
|
|
40007
40095
|
const [reloadKey, setReloadKey] = (0, react.useState)(0);
|
|
40008
40096
|
const controllerRef = (0, react.useRef)(null);
|
|
40097
|
+
const sequenceRef = (0, react.useRef)(0);
|
|
40009
40098
|
(0, react.useEffect)(() => {
|
|
40010
40099
|
if (!open || !enabled) return;
|
|
40011
40100
|
const controller = new AbortController();
|
|
40012
40101
|
controllerRef.current = controller;
|
|
40102
|
+
const sequence = sequenceRef.current + 1;
|
|
40103
|
+
sequenceRef.current = sequence;
|
|
40013
40104
|
setLoading(true);
|
|
40014
40105
|
setError(false);
|
|
40015
40106
|
readMagpieSessionRequestPage(rpc, sessionId, agent, offset, controller.signal).then((next) => {
|
|
40016
|
-
if (controller.signal.aborted) return;
|
|
40107
|
+
if (controller.signal.aborted || sequence !== sequenceRef.current) return;
|
|
40017
40108
|
if (next === null) {
|
|
40018
40109
|
setError(true);
|
|
40019
40110
|
return;
|
|
40020
40111
|
}
|
|
40021
|
-
setPage(next
|
|
40112
|
+
setPage((current) => current === null || offset === 0 ? next : {
|
|
40113
|
+
...next,
|
|
40114
|
+
items: [...current.items, ...next.items]
|
|
40115
|
+
});
|
|
40022
40116
|
}).catch(() => {
|
|
40023
|
-
if (!controller.signal.aborted) setError(true);
|
|
40117
|
+
if (!controller.signal.aborted && sequence === sequenceRef.current) setError(true);
|
|
40024
40118
|
}).finally(() => {
|
|
40025
|
-
if (!controller.signal.aborted) setLoading(false);
|
|
40119
|
+
if (!controller.signal.aborted && sequence === sequenceRef.current) setLoading(false);
|
|
40026
40120
|
});
|
|
40027
40121
|
return () => {
|
|
40028
40122
|
controller.abort();
|
|
@@ -40037,6 +40131,24 @@ html[data-codingns-mobile-sidebar="on"] .codingns-magpie-page{padding-left:0;--m
|
|
|
40037
40131
|
sessionId,
|
|
40038
40132
|
agent
|
|
40039
40133
|
]);
|
|
40134
|
+
(0, react.useEffect)(() => {
|
|
40135
|
+
if (!open || typeof document === "undefined" || !enabled) return;
|
|
40136
|
+
const onScroll = (event) => {
|
|
40137
|
+
const target = event.target;
|
|
40138
|
+
if (!(target instanceof Element) || !target.closest(".codingns4dsh-magpie-requests-body")) return;
|
|
40139
|
+
if (target.scrollHeight - target.scrollTop - target.clientHeight > 160) return;
|
|
40140
|
+
if (loading || error || page === null || !page.hasMore) return;
|
|
40141
|
+
setOffset(page.items.length);
|
|
40142
|
+
};
|
|
40143
|
+
document.addEventListener("scroll", onScroll, true);
|
|
40144
|
+
return () => document.removeEventListener("scroll", onScroll, true);
|
|
40145
|
+
}, [
|
|
40146
|
+
open,
|
|
40147
|
+
enabled,
|
|
40148
|
+
loading,
|
|
40149
|
+
error,
|
|
40150
|
+
page
|
|
40151
|
+
]);
|
|
40040
40152
|
(0, react.useEffect)(() => {
|
|
40041
40153
|
if (!open || typeof document === "undefined") return;
|
|
40042
40154
|
const onKeyDown = (event) => {
|
|
@@ -40078,7 +40190,11 @@ html[data-codingns-mobile-sidebar="on"] .codingns-magpie-page{padding-left:0;--m
|
|
|
40078
40190
|
error,
|
|
40079
40191
|
t,
|
|
40080
40192
|
onClose: close,
|
|
40081
|
-
|
|
40193
|
+
...requestsDialogRef === void 0 ? {} : { dialogRef: requestsDialogRef },
|
|
40194
|
+
onOffsetChange: (value) => {
|
|
40195
|
+
if (value === 0) setPage(null);
|
|
40196
|
+
setOffset(value);
|
|
40197
|
+
},
|
|
40082
40198
|
onRetry: () => {
|
|
40083
40199
|
setLoading(true);
|
|
40084
40200
|
setError(false);
|
|
@@ -40109,9 +40225,10 @@ html[data-codingns-mobile-sidebar="on"] .codingns-magpie-page{padding-left:0;--m
|
|
|
40109
40225
|
* 管理页视图自带统计条、桌面表格 / 移动卡片、分页和空状态,这里只负责把会话固定住,
|
|
40110
40226
|
* 不再维护一套重复的请求卡片渲染。
|
|
40111
40227
|
*/
|
|
40112
|
-
function MagpieSessionRequestsDialog({ sessionId, sessionName, agent, page, offset, loading, error, t, onClose, onOffsetChange, onRetry }) {
|
|
40113
|
-
|
|
40228
|
+
function MagpieSessionRequestsDialog({ sessionId, sessionName, agent, page, offset, loading, error, t, onClose, dialogRef, onOffsetChange, onRetry }) {
|
|
40229
|
+
const dialog = (0, react.createElement)("div", {
|
|
40114
40230
|
className: "codingns4dsh-magpie-requests-overlay",
|
|
40231
|
+
ref: dialogRef,
|
|
40115
40232
|
role: "presentation",
|
|
40116
40233
|
style: magpieRequestsOverlayStyle,
|
|
40117
40234
|
onPointerDown: backdropPointerDownHandler(onClose)
|
|
@@ -40149,8 +40266,10 @@ html[data-codingns-mobile-sidebar="on"] .codingns-magpie-page{padding-left:0;--m
|
|
|
40149
40266
|
offset,
|
|
40150
40267
|
onOffsetChange,
|
|
40151
40268
|
onClearSession: null,
|
|
40152
|
-
t
|
|
40269
|
+
t,
|
|
40270
|
+
append: true
|
|
40153
40271
|
})))));
|
|
40272
|
+
return typeof document === "undefined" ? dialog : (0, import_react_dom.createPortal)(dialog, document.body);
|
|
40154
40273
|
}
|
|
40155
40274
|
function createMagpieRows(rows) {
|
|
40156
40275
|
if (rows.length === 0) return (0, react.createElement)("div", { style: magpieMutedTextStyle }, "--");
|
|
@@ -40713,11 +40832,13 @@ html[data-codingns-mobile-sidebar="on"] .codingns-magpie-page{padding-left:0;--m
|
|
|
40713
40832
|
function shouldResolveMagpieQuota(usage) {
|
|
40714
40833
|
if (usage === null || usage === void 0) return false;
|
|
40715
40834
|
if (usage.quotaStatus !== "available") return usage.upstreamProvider === null;
|
|
40716
|
-
return usage.sessionId !== null && usage.session !== null && usage.quotas
|
|
40835
|
+
return usage.sessionId !== null && usage.session !== null && (usage.quotas?.length ?? 0) === 0;
|
|
40717
40836
|
}
|
|
40718
40837
|
function resolveMagpieQuotaRemaining(usage) {
|
|
40719
|
-
|
|
40720
|
-
|
|
40838
|
+
for (const quota of usage.quotas ?? []) for (const window of quota.windows) {
|
|
40839
|
+
const remaining = quotaWindowRemaining(window);
|
|
40840
|
+
if (remaining !== null) return remaining;
|
|
40841
|
+
}
|
|
40721
40842
|
return null;
|
|
40722
40843
|
}
|
|
40723
40844
|
function resolveMagpieTriggerReadout(usage) {
|
|
@@ -41311,7 +41432,7 @@ html[data-codingns-mobile-sidebar="on"] .codingns-magpie-page{padding-left:0;--m
|
|
|
41311
41432
|
const magpieRequestsOverlayStyle = {
|
|
41312
41433
|
position: "fixed",
|
|
41313
41434
|
inset: 0,
|
|
41314
|
-
zIndex:
|
|
41435
|
+
zIndex: 2147483e3,
|
|
41315
41436
|
display: "flex",
|
|
41316
41437
|
alignItems: "center",
|
|
41317
41438
|
justifyContent: "center",
|
|
@@ -90292,5 +90413,5 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
90292
90413
|
});
|
|
90293
90414
|
|
|
90294
90415
|
})();
|
|
90295
|
-
// codingns-client-revision:
|
|
90416
|
+
// codingns-client-revision: 35886f7c011dbf3b1b8887fda4f4d0801ce70892fbbcbc56eb0a5b58cea97891
|
|
90296
90417
|
//# sourceMappingURL=bundle.js.map
|