dsh-rwkv-plugin 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +50 -2
- package/cordis.patch.yml +59 -0
- package/lib/client.js +3148 -0
- package/lib/client.js.map +7 -0
- package/lib/index.js +6294 -0
- package/lib/index.js.map +7 -0
- package/lib/line-edit.js +1423 -0
- package/lib/line-edit.js.map +7 -0
- package/lib/todo.js +610 -0
- package/lib/todo.js.map +7 -0
- package/package.json +72 -4
- package/scripts/build.mjs +77 -0
- package/scripts/headless.ts +279 -0
- package/scripts/link-dsh.sh +31 -0
- package/scripts/relay-e2e.mjs +157 -0
- package/scripts/smoke.ts +116 -0
- package/scripts/state.ts +39 -0
- package/scripts/tokenizer-parity.ts +107 -0
- package/scripts/trace-stats.ts +33 -0
- package/src/adapter.ts +388 -0
- package/src/backend/generator.ts +221 -0
- package/src/backend/irwkv.ts +117 -0
- package/src/backend/lightning.ts +228 -0
- package/src/backend/stream.ts +97 -0
- package/src/client/AdapterPicker.tsx +264 -0
- package/src/client/DeveloperPanel.tsx +403 -0
- package/src/client/FoldNode.tsx +82 -0
- package/src/client/ModelCard.tsx +230 -0
- package/src/client/RwkvSettings.tsx +265 -0
- package/src/client/Segment.tsx +15 -0
- package/src/client/StatePicker.tsx +248 -0
- package/src/client/TraceFrames.tsx +462 -0
- package/src/client/TraceView.tsx +77 -0
- package/src/client/WirePanel.tsx +566 -0
- package/src/client/fields.tsx +362 -0
- package/src/client/index.tsx +109 -0
- package/src/client/styles.ts +277 -0
- package/src/client/traces-api.ts +222 -0
- package/src/client/url.ts +20 -0
- package/src/core/agent.ts +586 -0
- package/src/core/defaults.ts +51 -0
- package/src/core/dsh-prompt.ts +32 -0
- package/src/core/edit-modes/index.ts +108 -0
- package/src/core/edit-modes/line-edit.ts +793 -0
- package/src/core/edit-modes/literal.ts +26 -0
- package/src/core/edit-modes/shared.ts +213 -0
- package/src/core/edit-modes/tolerant.ts +558 -0
- package/src/core/fold-pairs.ts +407 -0
- package/src/core/fold-window.ts +563 -0
- package/src/core/line-edit.ts +33 -0
- package/src/core/parse.ts +290 -0
- package/src/core/policy.ts +500 -0
- package/src/core/prompt.ts +220 -0
- package/src/core/relay.ts +400 -0
- package/src/core/step-gates.ts +371 -0
- package/src/core/time-zone.ts +32 -0
- package/src/core/todo-state.ts +227 -0
- package/src/core/tolerant-edit.ts +14 -0
- package/src/core/tool-mappings.ts +209 -0
- package/src/core/tool-repairs.ts +255 -0
- package/src/core/tools.ts +162 -0
- package/src/core/worklist.ts +606 -0
- package/src/dsh-host.ts +48 -0
- package/src/edit-modes/folded-read-guard.ts +32 -0
- package/src/edit-modes/index.ts +26 -0
- package/src/edit-modes/line-edit.ts +154 -0
- package/src/edit-modes/literal.ts +9 -0
- package/src/edit-modes/observations.ts +234 -0
- package/src/edit-modes/syntax-check.ts +226 -0
- package/src/edit-modes/tolerant.ts +232 -0
- package/src/folded-read-guard.ts +6 -0
- package/src/history.ts +163 -0
- package/src/index.ts +287 -0
- package/src/line-edit.ts +15 -0
- package/src/live-wire.ts +133 -0
- package/src/paths.ts +91 -0
- package/src/relay-store.ts +59 -0
- package/src/result-budget.ts +225 -0
- package/src/routes.ts +324 -0
- package/src/session-setup.ts +150 -0
- package/src/syntax-check.ts +2 -0
- package/src/todo.ts +328 -0
- package/src/tokenizer.ts +48 -0
- package/src/tolerant-edit.ts +2 -0
- package/src/trace-stats.ts +225 -0
- package/src/traces.ts +289 -0
- package/vendor/rwkv-tokenizer/NOTICE.md +26 -0
- package/vendor/rwkv-tokenizer/package.json +5 -0
- package/vendor/rwkv-tokenizer/rwkv_tokenizer.d.ts +11 -0
- package/vendor/rwkv-tokenizer/rwkv_tokenizer.js +280 -0
- package/vendor/rwkv-tokenizer/rwkv_tokenizer_bg.wasm +0 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,3148 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({ id: "dsh-rwkv-plugin", factory: (require) => {
|
|
2
|
+
var module = { exports: {} }; var exports = module.exports;
|
|
3
|
+
"use strict";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/client/index.tsx
|
|
23
|
+
var index_exports = {};
|
|
24
|
+
__export(index_exports, {
|
|
25
|
+
NAMESPACE: () => NAMESPACE,
|
|
26
|
+
apply: () => apply,
|
|
27
|
+
inject: () => inject
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(index_exports);
|
|
30
|
+
|
|
31
|
+
// src/client/traces-api.ts
|
|
32
|
+
var TRACE_ROUTE = "/api/rwkv/traces";
|
|
33
|
+
var TRACE_EXPORT_ROUTE = "/api/rwkv/trace-export";
|
|
34
|
+
function formatTokens(tokens) {
|
|
35
|
+
if (tokens >= 1e3) return `${(tokens / 1e3).toFixed(1)}k`;
|
|
36
|
+
return String(tokens);
|
|
37
|
+
}
|
|
38
|
+
function ctxTier(tokens) {
|
|
39
|
+
if (tokens <= 8e3) return "green";
|
|
40
|
+
if (tokens <= 12e3) return "blue";
|
|
41
|
+
if (tokens <= 16e3) return "yellow";
|
|
42
|
+
return "red";
|
|
43
|
+
}
|
|
44
|
+
function foldKindLabel(kind) {
|
|
45
|
+
switch (kind) {
|
|
46
|
+
case "prior-turn":
|
|
47
|
+
return "\u8DE8\u8F6E\u4E0A\u4E0B\u6587\u538B\u7F29";
|
|
48
|
+
case "stage-archive":
|
|
49
|
+
return "\u9636\u6BB5\u5F52\u6863\u6298\u53E0";
|
|
50
|
+
case "worklist":
|
|
51
|
+
return "\u5DE5\u5355\u68C0\u67E5\u70B9\u6298\u53E0";
|
|
52
|
+
case "relay":
|
|
53
|
+
return "\u4EA4\u63A5\u5361\u538B\u7F29";
|
|
54
|
+
default:
|
|
55
|
+
return "\u4E0A\u4E0B\u6587\u6298\u53E0";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function foldDetailText(fold) {
|
|
59
|
+
const range = `${formatTokens(fold.beforeTokens)} \u2192 ${formatTokens(fold.afterTokens)}`;
|
|
60
|
+
if (fold.foldedTools > 0) {
|
|
61
|
+
return `${range}\uFF0C\u5DF2\u6298\u53E0 ${fold.foldedTools} \u6761\u5DE5\u5177\u8C03\u7528`;
|
|
62
|
+
}
|
|
63
|
+
return range;
|
|
64
|
+
}
|
|
65
|
+
async function getJSON(url, signal) {
|
|
66
|
+
const response = await fetch(url, { credentials: "same-origin", ...signal ? { signal } : {} });
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
let message = `HTTP ${response.status}`;
|
|
69
|
+
try {
|
|
70
|
+
message = (await response.json()).error ?? message;
|
|
71
|
+
} catch {
|
|
72
|
+
}
|
|
73
|
+
throw new Error(message);
|
|
74
|
+
}
|
|
75
|
+
return await response.json();
|
|
76
|
+
}
|
|
77
|
+
function fetchSessions(signal) {
|
|
78
|
+
return getJSON(TRACE_ROUTE, signal);
|
|
79
|
+
}
|
|
80
|
+
function fetchSession(session, signal) {
|
|
81
|
+
return getJSON(`${TRACE_ROUTE}/${encodeURIComponent(session)}`, signal);
|
|
82
|
+
}
|
|
83
|
+
function fetchRecord(session, index) {
|
|
84
|
+
return getJSON(`${TRACE_ROUTE}/${encodeURIComponent(session)}?index=${index}`);
|
|
85
|
+
}
|
|
86
|
+
async function deleteSession(session) {
|
|
87
|
+
const response = await fetch(`${TRACE_ROUTE}/${encodeURIComponent(session)}`, { method: "DELETE", credentials: "same-origin" });
|
|
88
|
+
if (!response.ok) throw new Error(`\u5220\u9664\u5931\u8D25\uFF1AHTTP ${response.status}`);
|
|
89
|
+
}
|
|
90
|
+
async function downloadExport(sessions) {
|
|
91
|
+
const query = sessions.length > 0 ? `?sessions=${sessions.map(encodeURIComponent).join(",")}` : "";
|
|
92
|
+
const response = await fetch(`${TRACE_EXPORT_ROUTE}${query}`, { credentials: "same-origin" });
|
|
93
|
+
if (!response.ok) throw new Error(`\u5BFC\u51FA\u5931\u8D25\uFF1AHTTP ${response.status}`);
|
|
94
|
+
const name = /filename="([^"]+)"/.exec(response.headers.get("content-disposition") ?? "")?.[1] ?? "rwkv-traces.jsonl";
|
|
95
|
+
const url = URL.createObjectURL(await response.blob());
|
|
96
|
+
const link = document.createElement("a");
|
|
97
|
+
link.href = url;
|
|
98
|
+
link.download = name;
|
|
99
|
+
document.body.append(link);
|
|
100
|
+
link.click();
|
|
101
|
+
link.remove();
|
|
102
|
+
setTimeout(() => URL.revokeObjectURL(url), 1e4);
|
|
103
|
+
}
|
|
104
|
+
var OUTCOME_LABEL = {
|
|
105
|
+
"run": "\u6267\u884C\u8C03\u7528",
|
|
106
|
+
"final": "\u4F5C\u7B54",
|
|
107
|
+
"re-ask": "\u683C\u5F0F\u91CD\u95EE",
|
|
108
|
+
"duplicate-retry": "\u91CD\u590D\u8C03\u7528\uFF0C\u518D\u7ED9\u4E00\u6B21",
|
|
109
|
+
"closeout": "\u5F3A\u5236\u6536\u5C3E",
|
|
110
|
+
"rejected unknown-tool": "\u672A\u77E5\u5DE5\u5177",
|
|
111
|
+
"rejected blocked": "\u8C03\u7528\u88AB\u62E6\u622A\uFF08\u8FDE\u7EED\u5931\u8D25\u6216\u8FDE\u7EED\u66F4\u65B0\u5DE5\u5355\uFF09",
|
|
112
|
+
"empty-exit": "no_tool \u6CA1\u5199\u56DE\u7B54",
|
|
113
|
+
"raw": "\u539F\u6837\u8F93\u51FA\uFF08\u672A\u4FEE\uFF09"
|
|
114
|
+
};
|
|
115
|
+
var REPAIR_LABEL = {
|
|
116
|
+
json_repaired: "\u53BB\u6389\u591A\u4F59\u7684 }",
|
|
117
|
+
array_unwrapped: "\u62C6\u5F00\u5355\u5143\u7D20\u6570\u7EC4",
|
|
118
|
+
function_wrapper: "\u62C6 OpenAI \u5916\u58F3",
|
|
119
|
+
name_alias: "name \u5B57\u6BB5\u5199\u9519",
|
|
120
|
+
arguments_alias: "arguments \u5B57\u6BB5\u5199\u9519",
|
|
121
|
+
arguments_lifted: "\u53C2\u6570\u5199\u5728\u9876\u5C42",
|
|
122
|
+
path_argument: "\u53EA\u5199\u4E86\u8DEF\u5F84",
|
|
123
|
+
stringified_arguments: "arguments \u662F\u5B57\u7B26\u4E32",
|
|
124
|
+
tool_renamed: "\u5DE5\u5177\u540D\u6539\u5199",
|
|
125
|
+
preamble_stripped: "\u53BB\u6389\u8C03\u7528\u524D\u7684\u8BDD",
|
|
126
|
+
envelope_recovered: "\u5916\u9762\u591A\u5957\u4E00\u5C42",
|
|
127
|
+
legacy_xml_call: "\u81EA\u95ED\u5408\u6807\u7B7E\u8C03\u7528",
|
|
128
|
+
tool_name_alias: "\u5DE5\u5177\u540D\u522B\u540D",
|
|
129
|
+
argument_alias: "\u53C2\u6570\u540D\u522B\u540D",
|
|
130
|
+
scalar_coerced: "\u6570\u503C/\u5E03\u5C14\u8F6C\u6362",
|
|
131
|
+
unknown_arguments_dropped: "\u5220\u6389\u591A\u4F59\u53C2\u6570",
|
|
132
|
+
pattern_array: "pattern \u662F\u6570\u7EC4",
|
|
133
|
+
glob_default_pattern: "glob \u8865 pattern",
|
|
134
|
+
offset_below_one: "offset \u6539\u6210 1",
|
|
135
|
+
limit_below_one: "\u53BB\u6389 limit",
|
|
136
|
+
path_repaired: "\u8DEF\u5F84\u4FEE\u590D",
|
|
137
|
+
bash_description_filled: "bash \u8865 description",
|
|
138
|
+
answer_stage_tool: "\u6536\u5C3E\u9636\u6BB5\u7684\u8C03\u7528"
|
|
139
|
+
};
|
|
140
|
+
var isGeneration = (record) => record.stage === "decision" || record.stage === "answer";
|
|
141
|
+
var isCard = (record) => record.stage === "card";
|
|
142
|
+
function touched(record) {
|
|
143
|
+
if (isCard(record)) return record.relay?.fallback === true || record.outcome === "card-empty" || record.outcome === "card-failed";
|
|
144
|
+
if (!isGeneration(record) || record.outcome === void 0) return false;
|
|
145
|
+
return !((record.outcome === "run" || record.outcome === "final") && (record.repairs ?? []).length === 0);
|
|
146
|
+
}
|
|
147
|
+
var percent = (part, whole) => whole === 0 ? "\u2013" : `${(100 * part / whole).toFixed(1)}%`;
|
|
148
|
+
|
|
149
|
+
// src/client/FoldNode.tsx
|
|
150
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
151
|
+
var CONTEXT_FOLD_RECORD = "plugin:rwkv-llm/context-fold";
|
|
152
|
+
var CONTEXT_FOLD_NODE_KEY = "rwkv-fold";
|
|
153
|
+
var rwkvFoldDefinition = {
|
|
154
|
+
kind: CONTEXT_FOLD_NODE_KEY,
|
|
155
|
+
target: "chat",
|
|
156
|
+
match: (event) => {
|
|
157
|
+
if (event?.type !== CONTEXT_FOLD_RECORD) return null;
|
|
158
|
+
return { id: `rwkv-fold-${event.seq}`, role: "start" };
|
|
159
|
+
},
|
|
160
|
+
start: (_context, match) => {
|
|
161
|
+
const raw = match.event.data ?? {};
|
|
162
|
+
return {
|
|
163
|
+
seq: match.event.seq,
|
|
164
|
+
...match.event.time === void 0 ? {} : { time: match.event.time },
|
|
165
|
+
kind: typeof raw.kind === "string" ? raw.kind : "in-place",
|
|
166
|
+
beforeTokens: typeof raw.beforeTokens === "number" ? raw.beforeTokens : 0,
|
|
167
|
+
afterTokens: typeof raw.afterTokens === "number" ? raw.afterTokens : 0,
|
|
168
|
+
foldedTools: typeof raw.foldedTools === "number" ? raw.foldedTools : 0
|
|
169
|
+
};
|
|
170
|
+
},
|
|
171
|
+
update: (context) => context.state,
|
|
172
|
+
buildViewNode: (context) => {
|
|
173
|
+
if (context.state === void 0) return null;
|
|
174
|
+
return {
|
|
175
|
+
key: context.key,
|
|
176
|
+
kind: CONTEXT_FOLD_NODE_KEY,
|
|
177
|
+
id: context.id,
|
|
178
|
+
target: "chat",
|
|
179
|
+
anchorSeq: context.state.seq,
|
|
180
|
+
location: context.start?.location ?? { kind: "unresolved" },
|
|
181
|
+
visibility: "visible",
|
|
182
|
+
data: context.state
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
function RwkvFoldNodeView(props) {
|
|
187
|
+
const data = props.node?.data;
|
|
188
|
+
if (data === void 0) return null;
|
|
189
|
+
const label = foldKindLabel(data.kind);
|
|
190
|
+
const range = `${formatTokens(data.beforeTokens)} \u2192 ${formatTokens(data.afterTokens)}`;
|
|
191
|
+
const detail = data.foldedTools > 0 ? `${range}\uFF0C\u5DF2\u6298\u53E0 ${data.foldedTools} \u6761\u5DE5\u5177\u8C03\u7528` : range;
|
|
192
|
+
const title = `RWKV ${label}\uFF1A${data.beforeTokens.toLocaleString()} \u2192 ${data.afterTokens.toLocaleString()} RWKV token`;
|
|
193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rwkv-chat-fold", title, children: [
|
|
194
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "rwkv-chat-fold-icon", width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4.5 2.5L7 5L9.5 2.5M4.5 11.5L7 9L9.5 11.5M2.5 7H11.5", stroke: "currentColor", strokeWidth: "1.25", strokeLinecap: "round", strokeLinejoin: "round" }) }),
|
|
195
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rwkv-chat-fold-label", children: label }),
|
|
196
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rwkv-chat-fold-sep", "aria-hidden": "true", children: "\xB7" }),
|
|
197
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rwkv-chat-fold-detail", children: detail })
|
|
198
|
+
] });
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// src/client/RwkvSettings.tsx
|
|
202
|
+
var import_react7 = require("react");
|
|
203
|
+
|
|
204
|
+
// src/core/defaults.ts
|
|
205
|
+
var AGENT_FAST_SAMPLING = {
|
|
206
|
+
temperature: 0.35,
|
|
207
|
+
topK: 65536,
|
|
208
|
+
topP: 0.85,
|
|
209
|
+
presencePenalty: 0.5,
|
|
210
|
+
frequencyPenalty: 0.2,
|
|
211
|
+
penaltyDecay: 0.996
|
|
212
|
+
};
|
|
213
|
+
var DEFAULT_MAX_STEPS = 30;
|
|
214
|
+
var DEFAULT_MAX_CONSECUTIVE_FAILURES = 2;
|
|
215
|
+
var DEFAULT_PROTOCOL_RETRIES = 2;
|
|
216
|
+
var DEFAULT_DECISION_MAX_TOKENS = 8192;
|
|
217
|
+
var DEFAULT_ANSWER_MAX_TOKENS = 8192;
|
|
218
|
+
|
|
219
|
+
// src/client/DeveloperPanel.tsx
|
|
220
|
+
var import_react2 = require("react");
|
|
221
|
+
|
|
222
|
+
// src/client/Segment.tsx
|
|
223
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
224
|
+
function Segment(props) {
|
|
225
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "rwkv-segment", role: "group", children: props.options.map(([value, label]) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", "aria-pressed": props.value === value, disabled: props.disabled, onClick: () => props.onChange(value), children: label }, value)) });
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// src/client/TraceFrames.tsx
|
|
229
|
+
var import_react = require("react");
|
|
230
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
231
|
+
var SHORT_VALUE = 16;
|
|
232
|
+
var MAX_CHANGES = 3;
|
|
233
|
+
function valueText(value) {
|
|
234
|
+
return typeof value === "string" ? JSON.stringify(value) : JSON.stringify(value) ?? String(value);
|
|
235
|
+
}
|
|
236
|
+
function changeText(change) {
|
|
237
|
+
switch (change.kind) {
|
|
238
|
+
case "removed":
|
|
239
|
+
return `\u2212${change.key}`;
|
|
240
|
+
case "added":
|
|
241
|
+
return `+${change.key}`;
|
|
242
|
+
case "renamed":
|
|
243
|
+
return `${change.from}\u2192${change.key}`;
|
|
244
|
+
case "changed": {
|
|
245
|
+
const before = valueText(change.before);
|
|
246
|
+
const after = valueText(change.after);
|
|
247
|
+
return before.length + after.length > SHORT_VALUE * 2 ? `${change.key} \u5DF2\u6539` : `${change.key} ${before}\u2192${after}`;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function changeTitle(change) {
|
|
252
|
+
switch (change.kind) {
|
|
253
|
+
case "removed":
|
|
254
|
+
return `\u5220\u6389 ${change.key}=${valueText(change.before)}`;
|
|
255
|
+
case "added":
|
|
256
|
+
return `\u8865\u4E0A ${change.key}=${valueText(change.after)}`;
|
|
257
|
+
case "renamed":
|
|
258
|
+
return `\u53C2\u6570\u540D ${change.from} \u6539\u6210 ${change.key}`;
|
|
259
|
+
case "changed":
|
|
260
|
+
return `${change.key}\uFF1A${valueText(change.before)} \u2192 ${valueText(change.after)}`;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function HandedLine(props) {
|
|
264
|
+
const { record } = props;
|
|
265
|
+
const changes = record.changes ?? [];
|
|
266
|
+
const decision = (record.decision ?? "").replace(/^tool /, "");
|
|
267
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "rl-step", title: "\u4EA4\u7ED9 DSH", children: [
|
|
268
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { className: "rl-step-arrow", width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M2.5 2V6.5C2.5 7.05228 2.94772 7.5 3.5 7.5H9.5M9.5 7.5L7.25 5.25M9.5 7.5L7.25 9.75", stroke: "currentColor", strokeWidth: "1.25", strokeLinecap: "round", strokeLinejoin: "round" }) }),
|
|
269
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("code", { children: decision }),
|
|
270
|
+
changes.slice(0, MAX_CHANGES).map((change, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-change", title: changeTitle(change), children: changeText(change) }, index)),
|
|
271
|
+
record.changes === void 0 ? (record.repairs ?? []).map((repair) => (
|
|
272
|
+
// Records written before the changes field: name the repairs instead.
|
|
273
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-change", title: repair, children: REPAIR_LABEL[repair] ?? repair }, repair)
|
|
274
|
+
)) : null,
|
|
275
|
+
changes.length > MAX_CHANGES ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "rl-change", title: changes.slice(MAX_CHANGES).map(changeTitle).join("\n"), children: [
|
|
276
|
+
"+",
|
|
277
|
+
changes.length - MAX_CHANGES
|
|
278
|
+
] }) : null,
|
|
279
|
+
record.attempts && record.attempts > 1 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "rl-step-note", children: [
|
|
280
|
+
"\u751F\u6210 ",
|
|
281
|
+
record.attempts,
|
|
282
|
+
" \u6B21"
|
|
283
|
+
] }) : null
|
|
284
|
+
] });
|
|
285
|
+
}
|
|
286
|
+
var OUTCOME_TAG = {
|
|
287
|
+
"card": "\u5199\u5361",
|
|
288
|
+
"card-empty": "\u7A7A\u5361",
|
|
289
|
+
"card-failed": "\u5361\u5931\u8D25",
|
|
290
|
+
"run": "\u8C03\u7528",
|
|
291
|
+
"final": "\u4F5C\u7B54",
|
|
292
|
+
"re-ask": "\u91CD\u95EE",
|
|
293
|
+
"duplicate-retry": "\u91CD\u590D",
|
|
294
|
+
"closeout": "\u6536\u5C3E",
|
|
295
|
+
"rejected unknown-tool": "\u62D2\u7EDD",
|
|
296
|
+
"rejected blocked": "\u62D2\u7EDD",
|
|
297
|
+
"empty-exit": "\u7A7A\u7B54",
|
|
298
|
+
"raw": "\u539F\u6837"
|
|
299
|
+
};
|
|
300
|
+
function toneOf(record) {
|
|
301
|
+
if (record.outcome === void 0) return "neutral";
|
|
302
|
+
if (record.outcome === "raw" || record.outcome.startsWith("rejected")) return "error";
|
|
303
|
+
return touched(record) ? "touched" : "clean";
|
|
304
|
+
}
|
|
305
|
+
function afterThink(output) {
|
|
306
|
+
const text = output.trimStart();
|
|
307
|
+
if (!text.startsWith("<think")) return text;
|
|
308
|
+
const end = text.indexOf("</think>");
|
|
309
|
+
return end < 0 ? "" : text.slice(end + "</think>".length).trim();
|
|
310
|
+
}
|
|
311
|
+
function thinkOf(output) {
|
|
312
|
+
const text = output.trimStart();
|
|
313
|
+
if (!text.startsWith("<think")) return "";
|
|
314
|
+
const end = text.indexOf("</think>");
|
|
315
|
+
return text.slice(text.indexOf(">") + 1, end < 0 ? void 0 : end).trim();
|
|
316
|
+
}
|
|
317
|
+
function CutNote(props) {
|
|
318
|
+
const relay = props.record.relay;
|
|
319
|
+
const wl = props.record.worklist;
|
|
320
|
+
const fold = props.worklistFold;
|
|
321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
322
|
+
relay !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "rl-cut", title: `\u7B2C ${relay.from}\u2013${relay.to - 1} \u6761\u5386\u53F2\uFF08\u7528\u6237\u7B2C ${relay.turn} \u8F6E\uFF0C\u5171 ${relay.to - relay.from} \u6761\uFF09\u88AB\u8FD9\u5F20\u5361\u66FF\u6362\uFF1B\u6B64\u524D\u7684\u8C03\u7528\u4E0E\u7ED3\u679C\u4E0D\u518D\u9010\u6761\u53EF\u89C1`, children: [
|
|
323
|
+
"\u2702 \u538B\u7F29 ",
|
|
324
|
+
relay.to - relay.from,
|
|
325
|
+
" \u6761\u5386\u53F2 \xB7 \u7B2C ",
|
|
326
|
+
relay.turn,
|
|
327
|
+
" \u8F6E"
|
|
328
|
+
] }) : null,
|
|
329
|
+
fold !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
330
|
+
"span",
|
|
331
|
+
{
|
|
332
|
+
className: "rl-cut",
|
|
333
|
+
title: `\u4E0A\u4E00\u6B65\u5199\u5165\u5DE5\u5355 note \u540E\uFF0C\u672C\u6B65\u6298\u53E0\u4E86\u65E9\u671F\u63A2\u7D22\u8F93\u51FA\uFF08\u63D0\u793A\u8BCD ${fold.fromTokens !== void 0 ? `${fold.fromTokens} \u2192 ` : ""}${fold.toTokens} token\uFF09`,
|
|
334
|
+
children: [
|
|
335
|
+
"\u2702 \u672C\u6B65\u6298\u53E0 \xB7 ",
|
|
336
|
+
fold.fromTokens !== void 0 ? `${fold.fromTokens}\u2192${fold.toTokens}` : fold.toTokens,
|
|
337
|
+
" tok"
|
|
338
|
+
]
|
|
339
|
+
}
|
|
340
|
+
) : null,
|
|
341
|
+
wl !== void 0 && wl.nudged ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-chip rl-chip-warn", title: `\u5F53\u524D\u63D0\u793A\u8BCD ${wl.promptTokens} token \u8D85\u8FC7\u5DE5\u5355\u9884\u7B97 ${wl.budgetTokens} token\uFF0C\u5DF2\u8FFD\u52A0\u4E0D\u64A4\u56DE\u9884\u7B97\u63D0\u9192`, children: "\u9884\u7B97\u63D0\u9192" }) : null
|
|
342
|
+
] });
|
|
343
|
+
}
|
|
344
|
+
function Preview(props) {
|
|
345
|
+
if (props.record.stage === "card") {
|
|
346
|
+
const card = props.record.relay?.card ?? afterThink(props.record.output ?? "");
|
|
347
|
+
const fallback = props.record.relay?.fallback === true || props.record.outcome === "card-empty";
|
|
348
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "rl-text", children: [
|
|
349
|
+
fallback ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-chip rl-chip-warn", children: "\u81EA\u52A8\u6458\u8981" }) : null,
|
|
350
|
+
card.replace(/\s+/g, " ").slice(0, 220) || "\uFF08\u7A7A\u5361\uFF09"
|
|
351
|
+
] });
|
|
352
|
+
}
|
|
353
|
+
const output = props.record.output ?? "";
|
|
354
|
+
const action = afterThink(output);
|
|
355
|
+
const call = /<tool_calls?>\s*([\s\S]*)/.exec(action);
|
|
356
|
+
if (call !== null) {
|
|
357
|
+
let name = "";
|
|
358
|
+
let payload = call[1].replace(/<\/tool_calls?>\s*$/, "").trim();
|
|
359
|
+
try {
|
|
360
|
+
const parsed = JSON.parse(payload);
|
|
361
|
+
const inner = parsed.function ?? parsed;
|
|
362
|
+
if (typeof inner.name === "string") {
|
|
363
|
+
name = inner.name;
|
|
364
|
+
payload = JSON.stringify(inner.arguments ?? {});
|
|
365
|
+
}
|
|
366
|
+
} catch {
|
|
367
|
+
}
|
|
368
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "rl-text", children: [
|
|
369
|
+
name ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-call-name", children: name }) : null,
|
|
370
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-call-payload", children: payload })
|
|
371
|
+
] });
|
|
372
|
+
}
|
|
373
|
+
const text = action || thinkOf(output);
|
|
374
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: `rl-text${action ? "" : " rl-dim"}`, children: text.replace(/\s+/g, " ") || "\uFF08\u7A7A\u8F93\u51FA\uFF09" });
|
|
375
|
+
}
|
|
376
|
+
function time(at) {
|
|
377
|
+
if (at === void 0) return "";
|
|
378
|
+
const date = new Date(at);
|
|
379
|
+
return Number.isNaN(date.getTime()) ? at : `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
|
|
380
|
+
}
|
|
381
|
+
function KeyValue(props) {
|
|
382
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
383
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-kv-key", children: props.label }),
|
|
384
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-kv-value", children: props.children })
|
|
385
|
+
] });
|
|
386
|
+
}
|
|
387
|
+
function Inspector(props) {
|
|
388
|
+
const { row, step } = props;
|
|
389
|
+
const { record } = row;
|
|
390
|
+
const [tab, setTab] = (0, import_react.useState)("overview");
|
|
391
|
+
const [prompt, setPrompt] = (0, import_react.useState)();
|
|
392
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
393
|
+
(0, import_react.useEffect)(() => {
|
|
394
|
+
setPrompt(void 0);
|
|
395
|
+
setError("");
|
|
396
|
+
}, [row.index]);
|
|
397
|
+
(0, import_react.useEffect)(() => {
|
|
398
|
+
if (tab !== "prompt" || prompt !== void 0) return;
|
|
399
|
+
let stopped = false;
|
|
400
|
+
fetchRecord(props.session, row.index).then((body) => {
|
|
401
|
+
if (!stopped) setPrompt(body.record.prompt ?? "");
|
|
402
|
+
}).catch((cause) => {
|
|
403
|
+
if (!stopped) setError(cause instanceof Error ? cause.message : String(cause));
|
|
404
|
+
});
|
|
405
|
+
return () => {
|
|
406
|
+
stopped = true;
|
|
407
|
+
};
|
|
408
|
+
}, [tab, prompt, props.session, row.index]);
|
|
409
|
+
const tone = toneOf(record);
|
|
410
|
+
const repairs = record.repairs ?? [];
|
|
411
|
+
const think = thinkOf(record.output ?? "");
|
|
412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("aside", { className: "rl-inspector", "aria-label": "\u751F\u6210\u8BE6\u60C5", children: [
|
|
413
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "rl-inspector-head", children: [
|
|
414
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: `rl-tag rl-tone-${tone}`, children: OUTCOME_TAG[record.outcome ?? ""] ?? "\u751F\u6210" }),
|
|
415
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "rl-inspector-title", children: [
|
|
416
|
+
"\u8BF7\u6C42 ",
|
|
417
|
+
row.request,
|
|
418
|
+
" \xB7 \u7B2C ",
|
|
419
|
+
row.generation,
|
|
420
|
+
" \u6B21\u751F\u6210",
|
|
421
|
+
record.stage === "answer" ? " \xB7 \u6536\u5C3E\u9636\u6BB5" : record.stage === "card" ? " \xB7 \u5199\u4EA4\u63A5\u5361" : ""
|
|
422
|
+
] }),
|
|
423
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "rl-icon", "aria-label": "\u5173\u95ED", onClick: props.onClose, children: "\xD7" })
|
|
424
|
+
] }),
|
|
425
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "rl-tabs", role: "tablist", children: [["overview", "\u6982\u8FF0"], ["output", "\u539F\u59CB\u8F93\u51FA"], ["prompt", "\u63D0\u793A\u8BCD"]].map(([id, label]) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", role: "tab", "aria-selected": tab === id, onClick: () => setTab(id), children: label }, id)) }),
|
|
426
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "rl-inspector-body", children: tab === "overview" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
427
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "rl-kv", children: [
|
|
428
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(KeyValue, { label: "\u63D2\u4EF6\u5904\u7406", children: record.outcome === void 0 ? `${record.action ?? "\u2014"}\uFF08\u65E7\u8BB0\u5F55\uFF0C\u6CA1\u6709\u5224\u5B9A\uFF09` : OUTCOME_LABEL[record.outcome] ?? record.outcome }),
|
|
429
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(KeyValue, { label: "\u7528\u5230\u7684\u4FEE\u590D", children: repairs.length === 0 ? "\u65E0" : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-chips", children: repairs.map((repair) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-chip", title: repair, children: REPAIR_LABEL[repair] ?? repair }, repair)) }) }),
|
|
430
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(KeyValue, { label: "\u89E3\u6790\u4E3A", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("code", { children: record.action ?? "\u2014" }) }),
|
|
431
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(KeyValue, { label: "\u505C\u6B62\u539F\u56E0", children: [
|
|
432
|
+
record.finish === "length" ? "\u5199\u6EE1 token \u4E0A\u9650" : record.finish ?? "\u2014",
|
|
433
|
+
record.stop ? `\uFF08${record.stop}\uFF09` : ""
|
|
434
|
+
] }),
|
|
435
|
+
step ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(KeyValue, { label: "\u4EA4\u7ED9 DSH", children: [
|
|
436
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("code", { children: step.decision }),
|
|
437
|
+
step.attempts && step.attempts > 1 ? ` \xB7 \u8FD9\u6B21\u8BF7\u6C42\u751F\u6210\u4E86 ${step.attempts} \u6B21` : ""
|
|
438
|
+
] }) : null,
|
|
439
|
+
step?.changes && step.changes.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(KeyValue, { label: "\u63D2\u4EF6\u6539\u7684\u53C2\u6570", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-change-list", children: step.changes.map((change, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: changeTitle(change) }, index)) }) }) : null,
|
|
440
|
+
step && (step.outputRepairs === false || step.guards === false) ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(KeyValue, { label: "\u5F00\u5173", children: [
|
|
441
|
+
step.outputRepairs === false ? "\u4FEE\u6B63\u6A21\u578B\u8F93\u51FA\uFF1A\u5173 " : "",
|
|
442
|
+
step.guards === false ? "\u63D2\u4EF6\u4FEE\u590D\uFF1A\u5173" : ""
|
|
443
|
+
] }) : null,
|
|
444
|
+
record.worklist ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(KeyValue, { label: "\u4E0A\u4E0B\u6587\u9884\u7B97", children: [
|
|
445
|
+
"\u63D0\u793A\u8BCD ",
|
|
446
|
+
record.worklist.promptTokens.toLocaleString(),
|
|
447
|
+
" / ",
|
|
448
|
+
record.worklist.budgetTokens.toLocaleString(),
|
|
449
|
+
" token",
|
|
450
|
+
row.worklistFold !== void 0 ? ` \xB7 \u672C\u6B65\u521A\u6267\u884C\u6298\u53E0\uFF08${row.worklistFold.fromTokens !== void 0 ? `${row.worklistFold.fromTokens} \u2192 ` : ""}${row.worklistFold.toTokens} token\uFF0C\u68C0\u67E5\u70B9 #${record.worklist.checkpointAt}\uFF09` : record.worklist.checkpointAt !== void 0 ? ` \xB7 \u6CBF\u7528\u5DF2\u6298\u53E0\u7A97\u53E3\uFF08\u68C0\u67E5\u70B9 #${record.worklist.checkpointAt}\uFF09` : "",
|
|
451
|
+
record.worklist.nudged ? " \xB7 \u672C\u6B65\u89E6\u53D1\u4E0D\u64A4\u56DE\u9884\u7B97\u63D0\u9192" : ""
|
|
452
|
+
] }) : record.promptTokens !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(KeyValue, { label: "\u4E0A\u4E0B\u6587\u957F\u5EA6", children: [
|
|
453
|
+
record.promptTokens.toLocaleString(),
|
|
454
|
+
" RWKV token"
|
|
455
|
+
] }) : null,
|
|
456
|
+
record.fold ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(KeyValue, { label: "\u672C\u6B65\u6298\u53E0", children: [
|
|
457
|
+
foldKindLabel(record.fold.kind),
|
|
458
|
+
"\uFF1A",
|
|
459
|
+
foldDetailText(record.fold)
|
|
460
|
+
] }) : null,
|
|
461
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(KeyValue, { label: "\u6A21\u578B", children: record.model ?? "\u2014" }),
|
|
462
|
+
record.purpose ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(KeyValue, { label: "\u7528\u9014", children: record.purpose }) : null,
|
|
463
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(KeyValue, { label: "\u65F6\u95F4", children: time(record.at) })
|
|
464
|
+
] }),
|
|
465
|
+
think ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
466
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "rl-section-title", children: "\u601D\u8003" }),
|
|
467
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "rl-prose", children: think })
|
|
468
|
+
] }) : null,
|
|
469
|
+
record.stage === "card" && record.relay !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
470
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "rl-section-title", children: "\u8FD9\u4E00\u6B65\u5207\u6389\u4E86\u4EC0\u4E48" }),
|
|
471
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "rl-kv", children: [
|
|
472
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(KeyValue, { label: "\u8986\u76D6\u8303\u56F4", children: [
|
|
473
|
+
"\u7B2C ",
|
|
474
|
+
record.relay.from,
|
|
475
|
+
"\u2013",
|
|
476
|
+
record.relay.to - 1,
|
|
477
|
+
" \u6761\u5386\u53F2\uFF08\u5171 ",
|
|
478
|
+
record.relay.to - record.relay.from,
|
|
479
|
+
" \u6761\uFF09"
|
|
480
|
+
] }),
|
|
481
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(KeyValue, { label: "\u6240\u5C5E\u8F6E\u6B21", children: [
|
|
482
|
+
"\u7528\u6237\u7B2C ",
|
|
483
|
+
record.relay.turn,
|
|
484
|
+
" \u8F6E"
|
|
485
|
+
] }),
|
|
486
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(KeyValue, { label: "\u5361\u7247\u6765\u6E90", children: record.relay.fallback ? "\u81EA\u52A8\u6458\u8981\uFF08\u6A21\u578B\u6CA1\u5199\u51FA\u53EF\u7528\u7684\u5361\uFF09" : "\u6A21\u578B\u81EA\u5DF1\u5199\u7684" })
|
|
487
|
+
] }),
|
|
488
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "rl-section-title", children: "\u5199\u8FDB\u4E0A\u4E0B\u6587\u7684\u5361\u7247" }),
|
|
489
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { className: "rl-pre", children: record.relay.card || "\uFF08\u7A7A\u5361\uFF09" }),
|
|
490
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rwkv-hint", children: "\u8FD9\u5F20\u5361\u4F1A\u66FF\u6362\u4E0A\u9762\u90A3\u4E9B\u5386\u53F2\uFF1B\u6B64\u540E\u7684\u8BF7\u6C42\u53EA\u80FD\u770B\u5230\u5361\u7247\uFF0C\u770B\u4E0D\u5230\u88AB\u538B\u7F29\u7684\u8C03\u7528\u4E0E\u7ED3\u679C\u539F\u6587\u3002" })
|
|
491
|
+
] }) : null,
|
|
492
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "rl-section-title", children: "\u6A21\u578B\u5199\u7684\u52A8\u4F5C" }),
|
|
493
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { className: "rl-pre", children: afterThink(record.output ?? "") || "\uFF08\u65E0\uFF09" }),
|
|
494
|
+
step?.args && record.outcome === "run" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
495
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "rl-section-title", children: "DSH \u6536\u5230\u7684\u53C2\u6570" }),
|
|
496
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { className: "rl-pre", children: JSON.stringify(step.args, null, 2) })
|
|
497
|
+
] }) : null
|
|
498
|
+
] }) : tab === "output" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { className: "rl-pre rl-pre-full", children: record.output ?? "" }) : error ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rwkv-error", children: error }) : prompt === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rwkv-hint", children: "\u52A0\u8F7D\u4E2D\u2026" }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { className: "rl-pre rl-pre-full", children: prompt }) })
|
|
499
|
+
] });
|
|
500
|
+
}
|
|
501
|
+
function CtxBadge(props) {
|
|
502
|
+
if (props.tokens === void 0) return null;
|
|
503
|
+
const tier = ctxTier(props.tokens);
|
|
504
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: `rl-ctx rl-ctx-${tier}`, title: `\u63D0\u793A\u8BCD ${props.tokens.toLocaleString()} RWKV token`, children: formatTokens(props.tokens) });
|
|
505
|
+
}
|
|
506
|
+
function foldForRow(row) {
|
|
507
|
+
if (row.record.fold !== void 0) return row.record.fold;
|
|
508
|
+
if (row.worklistFold !== void 0) {
|
|
509
|
+
return {
|
|
510
|
+
kind: "worklist",
|
|
511
|
+
beforeTokens: row.worklistFold.fromTokens ?? row.worklistFold.toTokens,
|
|
512
|
+
afterTokens: row.worklistFold.toTokens,
|
|
513
|
+
foldedTools: 0
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
return void 0;
|
|
517
|
+
}
|
|
518
|
+
function TraceFrames(props) {
|
|
519
|
+
const [selected, setSelected] = (0, import_react.useState)();
|
|
520
|
+
const rows = [];
|
|
521
|
+
const steps = /* @__PURE__ */ new Map();
|
|
522
|
+
let request = 1;
|
|
523
|
+
let generation = 0;
|
|
524
|
+
let lastCheckpointAt;
|
|
525
|
+
let lastPromptTokens;
|
|
526
|
+
props.records.forEach((record, index) => {
|
|
527
|
+
if (!props.showSide && record.purpose !== void 0) return;
|
|
528
|
+
if (record.stage === "step") {
|
|
529
|
+
steps.set(request, record);
|
|
530
|
+
rows.push({ index, record, request, generation, first: false });
|
|
531
|
+
request++;
|
|
532
|
+
generation = 0;
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
if (!isGeneration(record) && !isCard(record)) return;
|
|
536
|
+
generation++;
|
|
537
|
+
let worklistFold;
|
|
538
|
+
if (record.purpose === void 0 && generation === 1 && record.worklist !== void 0) {
|
|
539
|
+
const cp = record.worklist.checkpointAt;
|
|
540
|
+
if (cp !== void 0 && cp !== lastCheckpointAt) {
|
|
541
|
+
worklistFold = {
|
|
542
|
+
...lastPromptTokens !== void 0 ? { fromTokens: lastPromptTokens } : {},
|
|
543
|
+
toTokens: record.worklist.promptTokens
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
lastCheckpointAt = cp;
|
|
547
|
+
lastPromptTokens = record.worklist.promptTokens;
|
|
548
|
+
}
|
|
549
|
+
rows.push({ index, record, request, generation, first: generation === 1, worklistFold });
|
|
550
|
+
});
|
|
551
|
+
const visible = props.onlyTouched ? rows.filter((row) => row.record.stage !== "step" && touched(row.record)) : rows;
|
|
552
|
+
const current = rows.find((row) => row.index === selected);
|
|
553
|
+
if (visible.length === 0) {
|
|
554
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rl-empty", children: props.onlyTouched ? "\u8FD9\u4E2A\u4F1A\u8BDD\u91CC\u6CA1\u6709\u7528\u5230\u515C\u5E95\u7684\u751F\u6210\u3002" : "\u8FD9\u4E2A\u4F1A\u8BDD\u8FD8\u6CA1\u6709 RWKV \u8BB0\u5F55\u3002" });
|
|
555
|
+
}
|
|
556
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "rl-ledger", children: [
|
|
557
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "rl-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("table", { className: "rl-table", children: [
|
|
558
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("colgroup", { children: [
|
|
559
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("col", { className: "rl-event-col" }),
|
|
560
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("col", {}),
|
|
561
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("col", { className: "rl-ctx-col" })
|
|
562
|
+
] }),
|
|
563
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tbody", { children: visible.flatMap((row) => {
|
|
564
|
+
if (row.record.stage === "step") {
|
|
565
|
+
return [/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("tr", { className: "rl-step-row", children: [
|
|
566
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { className: "rl-event", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-rail" }) }),
|
|
567
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { className: "rl-content", colSpan: 2, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HandedLine, { record: row.record }) })
|
|
568
|
+
] }, row.index)];
|
|
569
|
+
}
|
|
570
|
+
const tone = toneOf(row.record);
|
|
571
|
+
const repairs = row.record.repairs ?? [];
|
|
572
|
+
const ctxTokens = row.record.promptTokens ?? row.record.worklist?.promptTokens;
|
|
573
|
+
const fold = !props.onlyTouched ? foldForRow(row) : void 0;
|
|
574
|
+
const out = [];
|
|
575
|
+
if (fold !== void 0) {
|
|
576
|
+
out.push(
|
|
577
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("tr", { className: "rl-fold-row", "data-turn-start": row.first, children: [
|
|
578
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("td", { className: "rl-event", children: [
|
|
579
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-rail rl-rail-fold" }),
|
|
580
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-tag rl-tone-fold", children: "\u6298\u53E0" })
|
|
581
|
+
] }),
|
|
582
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { className: "rl-content", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "rl-content-inner rl-fold-text", children: [
|
|
583
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { className: "rl-fold-icon", width: "12", height: "12", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M4.5 2.5L7 5L9.5 2.5M4.5 11.5L7 9L9.5 11.5M2.5 7H11.5", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round", strokeLinejoin: "round" }) }),
|
|
584
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-fold-badge", children: foldKindLabel(fold.kind) }),
|
|
585
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-dim", children: "\xB7" }),
|
|
586
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "rl-fold-range", children: [
|
|
587
|
+
formatTokens(fold.beforeTokens),
|
|
588
|
+
" \u2192 ",
|
|
589
|
+
formatTokens(fold.afterTokens)
|
|
590
|
+
] }),
|
|
591
|
+
fold.foldedTools > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "rl-dim", children: [
|
|
592
|
+
"\xB7 \u5DF2\u6298\u53E0 ",
|
|
593
|
+
fold.foldedTools,
|
|
594
|
+
" \u6761\u5DE5\u5177\u8C03\u7528"
|
|
595
|
+
] }) : null
|
|
596
|
+
] }) }),
|
|
597
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { className: "rl-ctx-cell" })
|
|
598
|
+
] }, `fold-${row.index}`)
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
out.push(
|
|
602
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
603
|
+
"tr",
|
|
604
|
+
{
|
|
605
|
+
tabIndex: 0,
|
|
606
|
+
"data-selected": row.index === selected,
|
|
607
|
+
"data-turn-start": row.first && fold === void 0 && !props.onlyTouched,
|
|
608
|
+
onClick: () => setSelected((current2) => current2 === row.index ? void 0 : row.index),
|
|
609
|
+
onKeyDown: (event) => {
|
|
610
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
611
|
+
event.preventDefault();
|
|
612
|
+
setSelected(row.index);
|
|
613
|
+
}
|
|
614
|
+
},
|
|
615
|
+
children: [
|
|
616
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("td", { className: "rl-event", children: [
|
|
617
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: `rl-rail rl-rail-${tone}` }),
|
|
618
|
+
row.first || props.onlyTouched ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "rl-turn-label", children: [
|
|
619
|
+
"\u8BF7\u6C42 ",
|
|
620
|
+
row.request
|
|
621
|
+
] }) : null,
|
|
622
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: `rl-tag rl-tone-${tone}`, title: row.record.outcome === void 0 ? "\u65E7\u8BB0\u5F55" : OUTCOME_LABEL[row.record.outcome] ?? row.record.outcome, children: row.record.outcome === void 0 ? "\u751F\u6210" : OUTCOME_TAG[row.record.outcome] ?? row.record.outcome })
|
|
623
|
+
] }),
|
|
624
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { className: "rl-content", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "rl-content-inner", children: [
|
|
625
|
+
row.record.stage === "answer" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-chip rl-chip-muted", children: "\u6536\u5C3E\u9636\u6BB5" }) : null,
|
|
626
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CutNote, { record: row.record, worklistFold: row.record.fold === void 0 ? row.worklistFold : void 0 }),
|
|
627
|
+
row.record.finish === "length" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-chip rl-chip-warn", children: "\u5199\u6EE1\u4E0A\u9650" }) : null,
|
|
628
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Preview, { record: row.record }),
|
|
629
|
+
repairs.map((repair) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rl-chip rl-chip-warn", title: repair, children: REPAIR_LABEL[repair] ?? repair }, repair))
|
|
630
|
+
] }) }),
|
|
631
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { className: "rl-ctx-cell", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CtxBadge, { tokens: ctxTokens }) })
|
|
632
|
+
]
|
|
633
|
+
},
|
|
634
|
+
row.index
|
|
635
|
+
)
|
|
636
|
+
);
|
|
637
|
+
return out;
|
|
638
|
+
}) })
|
|
639
|
+
] }) }),
|
|
640
|
+
current ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Inspector, { session: props.session, row: current, step: steps.get(current.request), onClose: () => setSelected(void 0) }) : null
|
|
641
|
+
] });
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
// src/client/DeveloperPanel.tsx
|
|
645
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
646
|
+
var DEVELOPER_DEFAULTS = {
|
|
647
|
+
recordTraces: true,
|
|
648
|
+
traceDir: "",
|
|
649
|
+
outputRepairs: true,
|
|
650
|
+
guards: true,
|
|
651
|
+
editMode: "tolerant",
|
|
652
|
+
historyMode: "auto-fold",
|
|
653
|
+
worklistMinFoldTokens: 8e3,
|
|
654
|
+
worklistBudgetTokens: 13500,
|
|
655
|
+
worklistEpochTargetTokens: 9e3,
|
|
656
|
+
worklistKeepRecentPairs: 3
|
|
657
|
+
};
|
|
658
|
+
function Toggle(props) {
|
|
659
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "rwkv-check rwkv-toggle", children: [
|
|
660
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "checkbox", checked: props.checked, disabled: props.disabled, onChange: (event) => props.onChange(event.target.checked) }),
|
|
661
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
662
|
+
props.label,
|
|
663
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "rwkv-hint rwkv-toggle-hint", children: props.hint })
|
|
664
|
+
] })
|
|
665
|
+
] });
|
|
666
|
+
}
|
|
667
|
+
function Counts(props) {
|
|
668
|
+
const entries = Object.entries(props.counts).sort((a, b) => b[1] - a[1]);
|
|
669
|
+
if (entries.length === 0) return null;
|
|
670
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rwkv-counts", children: [
|
|
671
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "rwkv-block-title", children: props.title }),
|
|
672
|
+
entries.map(([key, count]) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "rwkv-count", title: key, children: [
|
|
673
|
+
props.labels[key] ?? key,
|
|
674
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("b", { children: count }),
|
|
675
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "rwkv-hint", children: percent(count, props.total) })
|
|
676
|
+
] }, key))
|
|
677
|
+
] });
|
|
678
|
+
}
|
|
679
|
+
function StatsCard(props) {
|
|
680
|
+
const counted = props.stats.filter((stats) => stats.generations > 0 || stats.steps > 0);
|
|
681
|
+
if (counted.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "rwkv-hint", children: "\u8FD8\u6CA1\u6709\u8BB0\u5F55\u3002" });
|
|
682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: counted.map((stats) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rwkv-stats", children: [
|
|
683
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rwkv-stats-head", children: [
|
|
684
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "rwkv-name", children: stats.model }),
|
|
685
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "rwkv-stat", children: [
|
|
686
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("b", { children: percent(stats.clean, stats.generations) }),
|
|
687
|
+
" \u751F\u6210\u539F\u6837\u53EF\u7528\uFF08",
|
|
688
|
+
stats.clean,
|
|
689
|
+
"/",
|
|
690
|
+
stats.generations,
|
|
691
|
+
"\uFF09"
|
|
692
|
+
] }),
|
|
693
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "rwkv-stat", children: [
|
|
694
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("b", { children: percent(stats.cleanSteps, stats.steps) }),
|
|
695
|
+
" \u8BF7\u6C42\u4E00\u6B21\u5B9A\u4E0B\u4E14\u65E0\u4FEE\u590D\uFF08",
|
|
696
|
+
stats.cleanSteps,
|
|
697
|
+
"/",
|
|
698
|
+
stats.steps,
|
|
699
|
+
"\uFF09"
|
|
700
|
+
] })
|
|
701
|
+
] }),
|
|
702
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Counts, { title: "\u63D2\u4EF6\u600E\u4E48\u5904\u7406\u7684", counts: stats.outcomes, total: stats.generations, labels: OUTCOME_LABEL }),
|
|
703
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Counts, { title: "\u7528\u5230\u7684\u4FEE\u590D\uFF08\u6309\u751F\u6210\u8BA1\uFF09", counts: stats.repairs, total: stats.generations, labels: REPAIR_LABEL })
|
|
704
|
+
] }, stats.model)) });
|
|
705
|
+
}
|
|
706
|
+
function SessionRow(props) {
|
|
707
|
+
const { item } = props;
|
|
708
|
+
const [open, setOpen] = (0, import_react2.useState)(false);
|
|
709
|
+
const [confirming, setConfirming] = (0, import_react2.useState)(false);
|
|
710
|
+
const [deleting, setDeleting] = (0, import_react2.useState)(false);
|
|
711
|
+
const remove = async () => {
|
|
712
|
+
setDeleting(true);
|
|
713
|
+
setError("");
|
|
714
|
+
try {
|
|
715
|
+
await deleteSession(item.session);
|
|
716
|
+
props.onDeleted();
|
|
717
|
+
} catch (cause) {
|
|
718
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
719
|
+
setDeleting(false);
|
|
720
|
+
setConfirming(false);
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
const [records, setRecords] = (0, import_react2.useState)();
|
|
724
|
+
const [onlyTouched, setOnlyTouched] = (0, import_react2.useState)(true);
|
|
725
|
+
const [error, setError] = (0, import_react2.useState)("");
|
|
726
|
+
(0, import_react2.useEffect)(() => {
|
|
727
|
+
if (!open || records !== void 0) return;
|
|
728
|
+
const abort = new AbortController();
|
|
729
|
+
fetchSession(item.session, abort.signal).then((body) => setRecords(body.records)).catch((cause) => {
|
|
730
|
+
if (!abort.signal.aborted) setError(cause instanceof Error ? cause.message : String(cause));
|
|
731
|
+
});
|
|
732
|
+
return () => abort.abort();
|
|
733
|
+
}, [open, records, item.session]);
|
|
734
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { className: "rwkv-session", children: [
|
|
735
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rwkv-session-head", children: [
|
|
736
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "checkbox", checked: props.selected, onChange: (event) => props.onSelect(event.target.checked), "aria-label": "\u9009\u4E2D\u8FD9\u4E2A\u4F1A\u8BDD" }),
|
|
737
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("button", { type: "button", className: "rwkv-session-title", onClick: () => setOpen((value) => !value), "aria-expanded": open, children: [
|
|
738
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "rwkv-session-task", children: item.task || item.session }),
|
|
739
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "rwkv-session-meta", children: [
|
|
740
|
+
new Date(item.modified).toLocaleString(),
|
|
741
|
+
" \xB7 ",
|
|
742
|
+
item.models.join(", "),
|
|
743
|
+
" \xB7 ",
|
|
744
|
+
item.steps,
|
|
745
|
+
" \u6B21\u8BF7\u6C42 \xB7 ",
|
|
746
|
+
item.generations,
|
|
747
|
+
" \u6B21\u751F\u6210",
|
|
748
|
+
item.touchedGenerations > 0 ? ` \xB7 ${item.touchedGenerations} \u6B21\u7528\u5230\u515C\u5E95` : "",
|
|
749
|
+
item.persisted ? "" : " \xB7 \u4EC5\u5728\u5185\u5B58"
|
|
750
|
+
] })
|
|
751
|
+
] }),
|
|
752
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "rwkv-actions", children: confirming ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
753
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "rwkv-link", disabled: deleting, onClick: () => setConfirming(false), children: "\u53D6\u6D88" }),
|
|
754
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "rwkv-btn rwkv-secondary rwkv-small rwkv-danger", disabled: deleting, onClick: () => {
|
|
755
|
+
void remove();
|
|
756
|
+
}, children: "\u786E\u8BA4\u5220\u9664" })
|
|
757
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "rwkv-link", title: "\u53EA\u5220 RWKV \u8F68\u8FF9\uFF0C\u4E0D\u52A8 DSH \u7684\u4F1A\u8BDD\u8BB0\u5F55", onClick: () => setConfirming(true), children: "\u5220\u9664" }) })
|
|
758
|
+
] }),
|
|
759
|
+
!open && error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "rwkv-error", children: error }) : null,
|
|
760
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rwkv-session-body", children: [
|
|
761
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "rwkv-check", children: [
|
|
762
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "checkbox", checked: onlyTouched, onChange: (event) => setOnlyTouched(event.target.checked) }),
|
|
763
|
+
"\u53EA\u770B\u7528\u5230\u515C\u5E95\u7684\u751F\u6210"
|
|
764
|
+
] }),
|
|
765
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "rwkv-error", children: error }) : records === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "rwkv-hint", children: "\u52A0\u8F7D\u4E2D\u2026" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TraceFrames, { session: item.session, records, onlyTouched, showSide: false })
|
|
766
|
+
] }) : null
|
|
767
|
+
] });
|
|
768
|
+
}
|
|
769
|
+
function Traces(props) {
|
|
770
|
+
const [data, setData] = (0, import_react2.useState)();
|
|
771
|
+
const [error, setError] = (0, import_react2.useState)("");
|
|
772
|
+
const [selected, setSelected] = (0, import_react2.useState)(/* @__PURE__ */ new Set());
|
|
773
|
+
const [busy, setBusy] = (0, import_react2.useState)(false);
|
|
774
|
+
const [reload, setReload] = (0, import_react2.useState)(0);
|
|
775
|
+
const [listOpen, setListOpen] = (0, import_react2.useState)(false);
|
|
776
|
+
(0, import_react2.useEffect)(() => {
|
|
777
|
+
const abort = new AbortController();
|
|
778
|
+
setError("");
|
|
779
|
+
fetchSessions(abort.signal).then((body) => setData(body)).catch((cause) => {
|
|
780
|
+
if (!abort.signal.aborted) setError(cause instanceof Error ? cause.message : String(cause));
|
|
781
|
+
});
|
|
782
|
+
return () => abort.abort();
|
|
783
|
+
}, [reload, props.recording]);
|
|
784
|
+
const exportSessions = async (sessions) => {
|
|
785
|
+
setBusy(true);
|
|
786
|
+
setError("");
|
|
787
|
+
try {
|
|
788
|
+
await downloadExport(sessions);
|
|
789
|
+
} catch (cause) {
|
|
790
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
791
|
+
}
|
|
792
|
+
setBusy(false);
|
|
793
|
+
};
|
|
794
|
+
const select = (session, value) => setSelected((current) => {
|
|
795
|
+
const next = new Set(current);
|
|
796
|
+
if (value) next.add(session);
|
|
797
|
+
else next.delete(session);
|
|
798
|
+
return next;
|
|
799
|
+
});
|
|
800
|
+
if (error && data === void 0) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "rwkv-error", children: error });
|
|
801
|
+
if (data === void 0) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "rwkv-hint", children: "\u52A0\u8F7D\u4E2D\u2026" });
|
|
802
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
803
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rwkv-block", children: [
|
|
804
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rwkv-block-head", children: [
|
|
805
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "rwkv-block-title", children: "\u515C\u5E95\u7EDF\u8BA1" }),
|
|
806
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "rwkv-link", onClick: () => setReload((value) => value + 1), children: "\u5237\u65B0" })
|
|
807
|
+
] }),
|
|
808
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StatsCard, { stats: data.stats })
|
|
809
|
+
] }),
|
|
810
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rwkv-block", children: [
|
|
811
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rwkv-block-head", children: [
|
|
812
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
813
|
+
"span",
|
|
814
|
+
{
|
|
815
|
+
className: "rwkv-block-title rwkv-session-toggle",
|
|
816
|
+
title: data.dir,
|
|
817
|
+
onClick: () => {
|
|
818
|
+
if (data.sessions.length > 0) setListOpen((value) => !value);
|
|
819
|
+
},
|
|
820
|
+
children: [
|
|
821
|
+
"\u5DF2\u8BB0\u5F55\u7684\u4F1A\u8BDD \xB7 ",
|
|
822
|
+
data.sessions.length,
|
|
823
|
+
" \u4E2A"
|
|
824
|
+
]
|
|
825
|
+
}
|
|
826
|
+
),
|
|
827
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "rwkv-actions", children: [
|
|
828
|
+
listOpen || selected.size > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("button", { type: "button", className: "rwkv-btn rwkv-secondary rwkv-small", disabled: busy || selected.size === 0, onClick: () => {
|
|
829
|
+
void exportSessions([...selected]);
|
|
830
|
+
}, children: [
|
|
831
|
+
"\u5BFC\u51FA\u6240\u9009\uFF08",
|
|
832
|
+
selected.size,
|
|
833
|
+
"\uFF09"
|
|
834
|
+
] }) : null,
|
|
835
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "rwkv-btn rwkv-secondary rwkv-small", disabled: busy || data.sessions.length === 0, onClick: () => {
|
|
836
|
+
void exportSessions([]);
|
|
837
|
+
}, children: "\u5BFC\u51FA\u5168\u90E8" }),
|
|
838
|
+
data.sessions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
839
|
+
"button",
|
|
840
|
+
{
|
|
841
|
+
type: "button",
|
|
842
|
+
className: "rwkv-btn rwkv-secondary rwkv-small",
|
|
843
|
+
"aria-expanded": listOpen,
|
|
844
|
+
onClick: () => setListOpen((value) => !value),
|
|
845
|
+
children: listOpen ? "\u6536\u8D77" : "\u5C55\u5F00"
|
|
846
|
+
}
|
|
847
|
+
) : null
|
|
848
|
+
] })
|
|
849
|
+
] }),
|
|
850
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "rwkv-error", children: error }) : null,
|
|
851
|
+
data.sessions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "rwkv-hint", children: "\u8FD8\u6CA1\u6709\u8F68\u8FF9\u3002" }) : listOpen ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
852
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "rwkv-hint", children: [
|
|
853
|
+
"\u4FDD\u5B58\u5728 ",
|
|
854
|
+
data.dir,
|
|
855
|
+
"\uFF08\u5220\u9664\u4EC5\u5220\u8F68\u8FF9\uFF0C\u4E0D\u5F71\u54CD DSH \u4F1A\u8BDD\uFF09\u3002"
|
|
856
|
+
] }),
|
|
857
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: "rwkv-sessions", children: data.sessions.map((item) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
858
|
+
SessionRow,
|
|
859
|
+
{
|
|
860
|
+
item,
|
|
861
|
+
selected: selected.has(item.session),
|
|
862
|
+
onSelect: (value) => select(item.session, value),
|
|
863
|
+
onDeleted: () => {
|
|
864
|
+
select(item.session, false);
|
|
865
|
+
setReload((value) => value + 1);
|
|
866
|
+
}
|
|
867
|
+
},
|
|
868
|
+
item.session
|
|
869
|
+
)) })
|
|
870
|
+
] }) : null
|
|
871
|
+
] })
|
|
872
|
+
] });
|
|
873
|
+
}
|
|
874
|
+
function DirInput(props) {
|
|
875
|
+
const [text, setText] = (0, import_react2.useState)(props.value);
|
|
876
|
+
(0, import_react2.useEffect)(() => setText(props.value), [props.value]);
|
|
877
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "rwkv-dir", children: [
|
|
878
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
879
|
+
"input",
|
|
880
|
+
{
|
|
881
|
+
className: "rwkv-input",
|
|
882
|
+
value: text,
|
|
883
|
+
disabled: props.disabled,
|
|
884
|
+
spellCheck: false,
|
|
885
|
+
autoComplete: "off",
|
|
886
|
+
placeholder: "\u7559\u7A7A\uFF1A\u5B58\u5728\u4F1A\u8BDD\u76EE\u5F55\u91CC",
|
|
887
|
+
onChange: (event) => setText(event.target.value),
|
|
888
|
+
onKeyDown: (event) => {
|
|
889
|
+
if (event.key === "Enter") props.onSave(text.trim());
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
),
|
|
893
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "rwkv-btn rwkv-secondary rwkv-small", disabled: props.disabled || text.trim() === props.value, onClick: () => props.onSave(text.trim()), children: "\u4FDD\u5B58" })
|
|
894
|
+
] });
|
|
895
|
+
}
|
|
896
|
+
function NumberField(props) {
|
|
897
|
+
const [text, setText] = (0, import_react2.useState)(String(props.value));
|
|
898
|
+
(0, import_react2.useEffect)(() => setText(String(props.value)), [props.value]);
|
|
899
|
+
const minVal = props.min ?? 1;
|
|
900
|
+
const commit = () => {
|
|
901
|
+
const parsed = Number(text);
|
|
902
|
+
if (text.trim() === "" || !Number.isInteger(parsed) || parsed < minVal) {
|
|
903
|
+
setText(String(props.value));
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
if (parsed !== props.value) props.onSave(parsed);
|
|
907
|
+
};
|
|
908
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
909
|
+
"input",
|
|
910
|
+
{
|
|
911
|
+
className: "rwkv-input",
|
|
912
|
+
inputMode: "numeric",
|
|
913
|
+
value: text,
|
|
914
|
+
disabled: props.disabled,
|
|
915
|
+
placeholder: props.placeholder,
|
|
916
|
+
onChange: (event) => setText(event.target.value),
|
|
917
|
+
onBlur: commit,
|
|
918
|
+
onKeyDown: (event) => {
|
|
919
|
+
if (event.key === "Enter") commit();
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
);
|
|
923
|
+
}
|
|
924
|
+
var EDIT_MODE_HINT = {
|
|
925
|
+
tolerant: "\u81EA\u52A8\u5BF9\u9F50\u7F29\u8FDB\u7A7A\u884C\u5E76\u505A\u8BED\u6CD5\u68C0\u67E5\u3002",
|
|
926
|
+
"line-edit": "\u8BED\u4E49\u9996\u884C\u951A\u70B9\uFF08start_text\uFF09\u4E09\u7EA7\u81EA\u6108 + \u539F\u5B50\u6279\u91CF edits[] + \u2264200 \u884C read \u4E0A\u9650\uFF0C\u9690\u85CF\u6807\u51C6 edit\u3002",
|
|
927
|
+
literal: "\u539F\u6837\u7CBE\u786E\u5339\u914D\uFF0C\u4E0D\u505A\u5BB9\u9519\u4E0E\u68C0\u67E5\u3002"
|
|
928
|
+
};
|
|
929
|
+
var HISTORY_MODE_HINT = {
|
|
930
|
+
"auto-fold": "\u8D85\u6C34\u4F4D\u81EA\u52A8\u538B\u7F29\u65E9\u671F\u6B65\u9AA4\u8F93\u51FA\uFF0C\u4E0D\u6302 todo \u5DE5\u5177\u3002",
|
|
931
|
+
full: "\u4FDD\u7559\u5168\u90E8\u5386\u53F2\u539F\u6587\uFF0C\u4E0D\u505A\u538B\u7F29\u3002",
|
|
932
|
+
worklist: "\u542F\u7528 todo \u5DE5\u5177\u7531\u6A21\u578B\u8BB0\u5DE5\u5355\uFF0C\u8D85\u9650\u540E\u6298\u53E0\u65E7\u6B65\u9AA4\u3002"
|
|
933
|
+
};
|
|
934
|
+
function DeveloperCard(props) {
|
|
935
|
+
const { settings, disabled, write } = props;
|
|
936
|
+
const [open, setOpen] = (0, import_react2.useState)(false);
|
|
937
|
+
const [busy, setBusy] = (0, import_react2.useState)(false);
|
|
938
|
+
const set = async (field, value) => {
|
|
939
|
+
setBusy(true);
|
|
940
|
+
await write(field, value);
|
|
941
|
+
setBusy(false);
|
|
942
|
+
};
|
|
943
|
+
const off = disabled || busy;
|
|
944
|
+
const historyMode = settings.historyMode === "worklist" ? "worklist" : settings.historyMode === "full" ? "full" : "auto-fold";
|
|
945
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rwkv-card", children: [
|
|
946
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
947
|
+
"button",
|
|
948
|
+
{
|
|
949
|
+
type: "button",
|
|
950
|
+
className: "rwkv-head rwkv-developer-head",
|
|
951
|
+
"aria-expanded": open,
|
|
952
|
+
onClick: () => setOpen((value) => !value),
|
|
953
|
+
children: [
|
|
954
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "rwkv-identity", children: [
|
|
955
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "rwkv-chevron", "aria-hidden": "true" }),
|
|
956
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "rwkv-name", children: "\u5F00\u53D1\u8005" })
|
|
957
|
+
] }),
|
|
958
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "rwkv-meta", children: [
|
|
959
|
+
settings.recordTraces ? "\u8F68\u8FF9\u968F\u4F1A\u8BDD\u4FDD\u5B58" : "\u8F68\u8FF9\u53EA\u5728\u5185\u5B58",
|
|
960
|
+
settings.outputRepairs ? "" : " \xB7 \u4FEE\u6B63\u5DF2\u5173",
|
|
961
|
+
settings.guards ? "" : " \xB7 \u4FEE\u590D\u5DF2\u5173",
|
|
962
|
+
settings.editMode === "tolerant" ? " \xB7 \u5BB9\u9519 edit" : settings.editMode === "literal" ? " \xB7 \u7CBE\u786E edit" : " \xB7 \u951A\u70B9\u884C\u53F7 edit_lines",
|
|
963
|
+
historyMode === "auto-fold" ? ` \xB7 \u81EA\u52A8\u6298\u53E0\uFF08${settings.worklistEpochTargetTokens} \u2190 ${settings.worklistBudgetTokens}\uFF09` : historyMode === "worklist" ? ` \xB7 \u5DE5\u5355\u6A21\u5F0F\uFF08${settings.worklistMinFoldTokens} / ${settings.worklistBudgetTokens}\uFF09` : " \xB7 \u5B8C\u6574\u5BF9\u8BDD"
|
|
964
|
+
] })
|
|
965
|
+
]
|
|
966
|
+
}
|
|
967
|
+
),
|
|
968
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rwkv-developer-body", children: [
|
|
969
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rwkv-field", children: [
|
|
970
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "rwkv-label", children: "\u6587\u4EF6\u7F16\u8F91\u6A21\u5F0F" }),
|
|
971
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
972
|
+
Segment,
|
|
973
|
+
{
|
|
974
|
+
value: settings.editMode,
|
|
975
|
+
disabled: off,
|
|
976
|
+
options: [["tolerant", "\u5BB9\u9519 edit\uFF08\u9ED8\u8BA4\uFF09"], ["line-edit", "\u951A\u70B9\u884C\u53F7 edit_lines"], ["literal", "\u7CBE\u786E edit"]],
|
|
977
|
+
onChange: (value) => {
|
|
978
|
+
void set("editMode", value);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
),
|
|
982
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "rwkv-hint", children: EDIT_MODE_HINT[settings.editMode] ?? EDIT_MODE_HINT.tolerant })
|
|
983
|
+
] }),
|
|
984
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rwkv-field", children: [
|
|
985
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "rwkv-label", children: "\u4E0A\u4E0B\u6587\u7BA1\u7406\u6A21\u5F0F" }),
|
|
986
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
987
|
+
Segment,
|
|
988
|
+
{
|
|
989
|
+
value: historyMode,
|
|
990
|
+
disabled: off,
|
|
991
|
+
options: [["auto-fold", "\u81EA\u52A8\u6298\u53E0\uFF08\u9ED8\u8BA4\uFF09"], ["full", "\u5B8C\u6574\u5BF9\u8BDD"], ["worklist", "\u5DE5\u5355\u6A21\u5F0F\uFF08\u5B9E\u9A8C\uFF09"]],
|
|
992
|
+
onChange: (value) => {
|
|
993
|
+
void set("historyMode", value);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
),
|
|
997
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "rwkv-hint", children: HISTORY_MODE_HINT[historyMode] })
|
|
998
|
+
] }),
|
|
999
|
+
historyMode === "auto-fold" || historyMode === "worklist" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rwkv-grid3", children: [
|
|
1000
|
+
historyMode === "auto-fold" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "rwkv-field", children: [
|
|
1001
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "rwkv-label", children: "\u56DE\u843D\u6C34\u4F4D (token)" }),
|
|
1002
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1003
|
+
NumberField,
|
|
1004
|
+
{
|
|
1005
|
+
value: settings.worklistEpochTargetTokens,
|
|
1006
|
+
min: 0,
|
|
1007
|
+
disabled: off,
|
|
1008
|
+
placeholder: "9000",
|
|
1009
|
+
onSave: (value) => {
|
|
1010
|
+
void set("worklistEpochTargetTokens", value);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
),
|
|
1014
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "rwkv-hint", children: "\u6279\u91CF\u539F\u5730\u906E\u853D\u540E\u7684\u76EE\u6807\u6C34\u4F4D" })
|
|
1015
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "rwkv-field", children: [
|
|
1016
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "rwkv-label", children: "\u5F00\u59CB\u6298\u53E0 (token)" }),
|
|
1017
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1018
|
+
NumberField,
|
|
1019
|
+
{
|
|
1020
|
+
value: settings.worklistMinFoldTokens,
|
|
1021
|
+
min: 0,
|
|
1022
|
+
disabled: off,
|
|
1023
|
+
placeholder: "8000",
|
|
1024
|
+
onSave: (value) => {
|
|
1025
|
+
void set("worklistMinFoldTokens", value);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
),
|
|
1029
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "rwkv-hint", children: "\u8D85\u6B64\u503C\u624D\u5141\u8BB8\u6298\u53E0" })
|
|
1030
|
+
] }),
|
|
1031
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "rwkv-field", children: [
|
|
1032
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "rwkv-label", children: "\u5355\u8F6E\u4E0A\u9650 (token)" }),
|
|
1033
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1034
|
+
NumberField,
|
|
1035
|
+
{
|
|
1036
|
+
value: settings.worklistBudgetTokens,
|
|
1037
|
+
disabled: off,
|
|
1038
|
+
placeholder: "13500",
|
|
1039
|
+
onSave: (value) => {
|
|
1040
|
+
void set("worklistBudgetTokens", value);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
),
|
|
1044
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "rwkv-hint", children: historyMode === "auto-fold" ? "\u8D85\u6B64\u503C\u89E6\u53D1\u6279\u91CF\u539F\u5730\u906E\u853D" : "\u8D85\u6B64\u503C\u8FFD\u52A0\u9884\u7B97\u63D0\u9192" })
|
|
1045
|
+
] }),
|
|
1046
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "rwkv-field", children: [
|
|
1047
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "rwkv-label", children: "\u4FDD\u7559\u6700\u8FD1\u6B65\u6570" }),
|
|
1048
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1049
|
+
NumberField,
|
|
1050
|
+
{
|
|
1051
|
+
value: settings.worklistKeepRecentPairs,
|
|
1052
|
+
min: 0,
|
|
1053
|
+
disabled: off,
|
|
1054
|
+
placeholder: "3",
|
|
1055
|
+
onSave: (value) => {
|
|
1056
|
+
void set("worklistKeepRecentPairs", value);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
),
|
|
1060
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "rwkv-hint", children: "\u6298\u53E0\u65F6\u4FDD\u7559\u6700\u8FD1\u539F\u6587\u6B65\u6570" })
|
|
1061
|
+
] })
|
|
1062
|
+
] }) : null,
|
|
1063
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1064
|
+
Toggle,
|
|
1065
|
+
{
|
|
1066
|
+
label: "\u539F\u59CB\u8FD0\u884C\u8F68\u8FF9\u843D\u76D8",
|
|
1067
|
+
checked: settings.recordTraces,
|
|
1068
|
+
disabled: off,
|
|
1069
|
+
onChange: (value) => {
|
|
1070
|
+
void set("recordTraces", value);
|
|
1071
|
+
},
|
|
1072
|
+
hint: "\u968F\u4F1A\u8BDD\u4FDD\u5B58\u5728\u672C\u5730\uFF0C\u5173\u95ED\u540E\u4EC5\u7559\u5185\u5B58\u3002"
|
|
1073
|
+
}
|
|
1074
|
+
),
|
|
1075
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "rwkv-field", children: [
|
|
1076
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "rwkv-label", children: "\u81EA\u5B9A\u4E49\u76EE\u5F55" }),
|
|
1077
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DirInput, { value: settings.traceDir, disabled: off, onSave: (value) => {
|
|
1078
|
+
void set("traceDir", value);
|
|
1079
|
+
} })
|
|
1080
|
+
] }),
|
|
1081
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1082
|
+
Toggle,
|
|
1083
|
+
{
|
|
1084
|
+
label: "\u4FEE\u6B63\u6A21\u578B\u8F93\u51FA",
|
|
1085
|
+
checked: settings.outputRepairs,
|
|
1086
|
+
disabled: off,
|
|
1087
|
+
onChange: (value) => {
|
|
1088
|
+
void set("outputRepairs", value);
|
|
1089
|
+
},
|
|
1090
|
+
hint: "\u81EA\u52A8\u4FEE\u683C\u5F0F\u3001\u5DE5\u5177\u540D\u4E0E\u53C2\u6570\u3002"
|
|
1091
|
+
}
|
|
1092
|
+
),
|
|
1093
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1094
|
+
Toggle,
|
|
1095
|
+
{
|
|
1096
|
+
label: "\u63D2\u4EF6\u4FEE\u590D",
|
|
1097
|
+
checked: settings.guards,
|
|
1098
|
+
disabled: off,
|
|
1099
|
+
onChange: (value) => {
|
|
1100
|
+
void set("guards", value);
|
|
1101
|
+
},
|
|
1102
|
+
hint: "\u683C\u5F0F\u91CD\u95EE\u3001\u9632\u91CD\u590D\u8C03\u7528\u4E0E\u5F3A\u5236\u6536\u5C3E\u3002"
|
|
1103
|
+
}
|
|
1104
|
+
),
|
|
1105
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Traces, { recording: settings.recordTraces })
|
|
1106
|
+
] }) : null
|
|
1107
|
+
] });
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
// src/client/fields.tsx
|
|
1111
|
+
var import_react3 = require("react");
|
|
1112
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1113
|
+
var same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
1114
|
+
function ChevronIcon(props) {
|
|
1115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1116
|
+
"svg",
|
|
1117
|
+
{
|
|
1118
|
+
className: props.open ? "rwkv-menu-chevron rwkv-menu-chevron-open" : "rwkv-menu-chevron",
|
|
1119
|
+
width: "12",
|
|
1120
|
+
height: "12",
|
|
1121
|
+
viewBox: "0 0 12 12",
|
|
1122
|
+
fill: "none",
|
|
1123
|
+
"aria-hidden": "true",
|
|
1124
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M3 4.5L6 7.5L9 4.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
1125
|
+
}
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
function CheckIcon() {
|
|
1129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { className: "rwkv-menu-check", width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M3 7.25L5.75 10L11 4.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
1130
|
+
}
|
|
1131
|
+
function useDismiss(open, ref, onClose) {
|
|
1132
|
+
(0, import_react3.useEffect)(() => {
|
|
1133
|
+
if (!open) return;
|
|
1134
|
+
const onPointerDown = (event) => {
|
|
1135
|
+
if (ref.current && !ref.current.contains(event.target)) onClose();
|
|
1136
|
+
};
|
|
1137
|
+
const onKeyDown = (event) => {
|
|
1138
|
+
if (event.key === "Escape") onClose();
|
|
1139
|
+
};
|
|
1140
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
1141
|
+
document.addEventListener("keydown", onKeyDown);
|
|
1142
|
+
return () => {
|
|
1143
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
1144
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
1145
|
+
};
|
|
1146
|
+
}, [open, ref, onClose]);
|
|
1147
|
+
}
|
|
1148
|
+
function Field(props) {
|
|
1149
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: props.wide ? "rwkv-field rwkv-wide" : "rwkv-field", children: [
|
|
1150
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "rwkv-label", children: props.label }),
|
|
1151
|
+
props.children,
|
|
1152
|
+
props.hint ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "rwkv-hint", children: props.hint }) : null
|
|
1153
|
+
] });
|
|
1154
|
+
}
|
|
1155
|
+
function TextInput(props) {
|
|
1156
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1157
|
+
"input",
|
|
1158
|
+
{
|
|
1159
|
+
className: "rwkv-input",
|
|
1160
|
+
type: props.type ?? "text",
|
|
1161
|
+
value: props.value ?? "",
|
|
1162
|
+
placeholder: props.placeholder,
|
|
1163
|
+
list: props.list,
|
|
1164
|
+
disabled: props.disabled,
|
|
1165
|
+
spellCheck: false,
|
|
1166
|
+
autoComplete: "off",
|
|
1167
|
+
onChange: (event) => props.onChange(event.target.value)
|
|
1168
|
+
}
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
function NumberInput(props) {
|
|
1172
|
+
const [text, setText] = (0, import_react3.useState)(props.value === void 0 ? "" : String(props.value));
|
|
1173
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1174
|
+
"input",
|
|
1175
|
+
{
|
|
1176
|
+
className: "rwkv-input",
|
|
1177
|
+
inputMode: "decimal",
|
|
1178
|
+
value: text,
|
|
1179
|
+
placeholder: props.placeholder,
|
|
1180
|
+
disabled: props.disabled,
|
|
1181
|
+
onChange: (event) => {
|
|
1182
|
+
const next = event.target.value;
|
|
1183
|
+
setText(next);
|
|
1184
|
+
const parsed = Number(next);
|
|
1185
|
+
if (next.trim() === "") props.onChange(void 0);
|
|
1186
|
+
else if (Number.isFinite(parsed)) props.onChange(parsed);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
);
|
|
1190
|
+
}
|
|
1191
|
+
function ComboInput(props) {
|
|
1192
|
+
const [open, setOpen] = (0, import_react3.useState)(false);
|
|
1193
|
+
const [active, setActive] = (0, import_react3.useState)(-1);
|
|
1194
|
+
const rootRef = (0, import_react3.useRef)(null);
|
|
1195
|
+
const listId = (0, import_react3.useId)();
|
|
1196
|
+
useDismiss(open, rootRef, () => setOpen(false));
|
|
1197
|
+
const value = props.value ?? "";
|
|
1198
|
+
const trimmed = value.trim();
|
|
1199
|
+
const exactMatch = props.options.includes(trimmed);
|
|
1200
|
+
const filtered = trimmed === "" || exactMatch ? props.options : props.options.filter((item) => item.toLowerCase().includes(trimmed.toLowerCase()));
|
|
1201
|
+
const visibleOptions = filtered.length > 0 ? filtered : props.options;
|
|
1202
|
+
const hasOptions = props.options.length > 0 && !props.disabled;
|
|
1203
|
+
const showMenu = open && hasOptions;
|
|
1204
|
+
const choose = (item) => {
|
|
1205
|
+
props.onChange(item);
|
|
1206
|
+
setOpen(false);
|
|
1207
|
+
setActive(-1);
|
|
1208
|
+
};
|
|
1209
|
+
const onKeyDown = (event) => {
|
|
1210
|
+
if (!hasOptions) return;
|
|
1211
|
+
if (event.key === "ArrowDown") {
|
|
1212
|
+
event.preventDefault();
|
|
1213
|
+
if (!open) {
|
|
1214
|
+
setOpen(true);
|
|
1215
|
+
const currentIndex = visibleOptions.indexOf(trimmed);
|
|
1216
|
+
setActive(currentIndex >= 0 ? currentIndex : 0);
|
|
1217
|
+
} else {
|
|
1218
|
+
setActive((index) => (index + 1) % visibleOptions.length);
|
|
1219
|
+
}
|
|
1220
|
+
} else if (event.key === "ArrowUp") {
|
|
1221
|
+
event.preventDefault();
|
|
1222
|
+
if (!open) {
|
|
1223
|
+
setOpen(true);
|
|
1224
|
+
setActive(visibleOptions.length - 1);
|
|
1225
|
+
} else {
|
|
1226
|
+
setActive((index) => index <= 0 ? visibleOptions.length - 1 : index - 1);
|
|
1227
|
+
}
|
|
1228
|
+
} else if (event.key === "Enter" && open && active >= 0 && active < visibleOptions.length) {
|
|
1229
|
+
event.preventDefault();
|
|
1230
|
+
choose(visibleOptions[active]);
|
|
1231
|
+
} else if (event.key === "Escape" && open) {
|
|
1232
|
+
event.preventDefault();
|
|
1233
|
+
setOpen(false);
|
|
1234
|
+
}
|
|
1235
|
+
};
|
|
1236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { ref: rootRef, className: "rwkv-combo", children: [
|
|
1237
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1238
|
+
"input",
|
|
1239
|
+
{
|
|
1240
|
+
className: hasOptions ? "rwkv-input rwkv-combo-input" : "rwkv-input",
|
|
1241
|
+
type: "text",
|
|
1242
|
+
role: "combobox",
|
|
1243
|
+
"aria-expanded": showMenu,
|
|
1244
|
+
"aria-controls": showMenu ? listId : void 0,
|
|
1245
|
+
"aria-autocomplete": "list",
|
|
1246
|
+
value,
|
|
1247
|
+
placeholder: props.placeholder,
|
|
1248
|
+
disabled: props.disabled,
|
|
1249
|
+
spellCheck: false,
|
|
1250
|
+
autoComplete: "off",
|
|
1251
|
+
onFocus: () => {
|
|
1252
|
+
if (hasOptions) setOpen(true);
|
|
1253
|
+
},
|
|
1254
|
+
onClick: () => {
|
|
1255
|
+
if (hasOptions) setOpen(true);
|
|
1256
|
+
},
|
|
1257
|
+
onChange: (event) => {
|
|
1258
|
+
props.onChange(event.target.value);
|
|
1259
|
+
if (hasOptions) setOpen(true);
|
|
1260
|
+
setActive(-1);
|
|
1261
|
+
},
|
|
1262
|
+
onKeyDown
|
|
1263
|
+
}
|
|
1264
|
+
),
|
|
1265
|
+
hasOptions ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1266
|
+
"button",
|
|
1267
|
+
{
|
|
1268
|
+
type: "button",
|
|
1269
|
+
className: "rwkv-combo-toggle",
|
|
1270
|
+
tabIndex: -1,
|
|
1271
|
+
"aria-label": "\u5C55\u5F00\u6A21\u578B\u5217\u8868",
|
|
1272
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
1273
|
+
onClick: () => setOpen((current) => !current),
|
|
1274
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChevronIcon, { open: showMenu })
|
|
1275
|
+
}
|
|
1276
|
+
) : null,
|
|
1277
|
+
showMenu ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1278
|
+
"div",
|
|
1279
|
+
{
|
|
1280
|
+
id: listId,
|
|
1281
|
+
role: "listbox",
|
|
1282
|
+
className: props.align === "end" ? "rwkv-menu rwkv-menu-end" : "rwkv-menu",
|
|
1283
|
+
children: visibleOptions.map((option, index) => {
|
|
1284
|
+
const selected = option === trimmed;
|
|
1285
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1286
|
+
"button",
|
|
1287
|
+
{
|
|
1288
|
+
type: "button",
|
|
1289
|
+
role: "option",
|
|
1290
|
+
"aria-selected": selected,
|
|
1291
|
+
"data-active": active === index ? "true" : void 0,
|
|
1292
|
+
className: "rwkv-menu-item",
|
|
1293
|
+
title: option,
|
|
1294
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
1295
|
+
onMouseEnter: () => setActive(index),
|
|
1296
|
+
onClick: () => choose(option),
|
|
1297
|
+
children: [
|
|
1298
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "rwkv-menu-label", children: option }),
|
|
1299
|
+
selected ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CheckIcon, {}) : null
|
|
1300
|
+
]
|
|
1301
|
+
},
|
|
1302
|
+
option
|
|
1303
|
+
);
|
|
1304
|
+
})
|
|
1305
|
+
}
|
|
1306
|
+
) : null
|
|
1307
|
+
] });
|
|
1308
|
+
}
|
|
1309
|
+
function SelectInput(props) {
|
|
1310
|
+
const [open, setOpen] = (0, import_react3.useState)(false);
|
|
1311
|
+
const [active, setActive] = (0, import_react3.useState)(-1);
|
|
1312
|
+
const rootRef = (0, import_react3.useRef)(null);
|
|
1313
|
+
const listId = (0, import_react3.useId)();
|
|
1314
|
+
useDismiss(open, rootRef, () => setOpen(false));
|
|
1315
|
+
const selectedIndex = props.options.findIndex(([value]) => value === props.value);
|
|
1316
|
+
const currentLabel = selectedIndex >= 0 ? props.options[selectedIndex][1] : "";
|
|
1317
|
+
const showMenu = open && !props.disabled;
|
|
1318
|
+
const choose = (value) => {
|
|
1319
|
+
props.onChange(value);
|
|
1320
|
+
setOpen(false);
|
|
1321
|
+
setActive(-1);
|
|
1322
|
+
};
|
|
1323
|
+
const onKeyDown = (event) => {
|
|
1324
|
+
if (props.disabled) return;
|
|
1325
|
+
if (event.key === "ArrowDown") {
|
|
1326
|
+
event.preventDefault();
|
|
1327
|
+
if (!open) {
|
|
1328
|
+
setOpen(true);
|
|
1329
|
+
setActive(selectedIndex >= 0 ? selectedIndex : 0);
|
|
1330
|
+
} else {
|
|
1331
|
+
setActive((index) => (index + 1) % props.options.length);
|
|
1332
|
+
}
|
|
1333
|
+
} else if (event.key === "ArrowUp") {
|
|
1334
|
+
event.preventDefault();
|
|
1335
|
+
if (!open) {
|
|
1336
|
+
setOpen(true);
|
|
1337
|
+
setActive(selectedIndex >= 0 ? selectedIndex : props.options.length - 1);
|
|
1338
|
+
} else {
|
|
1339
|
+
setActive((index) => index <= 0 ? props.options.length - 1 : index - 1);
|
|
1340
|
+
}
|
|
1341
|
+
} else if ((event.key === "Enter" || event.key === " ") && open && active >= 0 && active < props.options.length) {
|
|
1342
|
+
event.preventDefault();
|
|
1343
|
+
choose(props.options[active][0]);
|
|
1344
|
+
} else if (event.key === "Escape" && open) {
|
|
1345
|
+
event.preventDefault();
|
|
1346
|
+
setOpen(false);
|
|
1347
|
+
}
|
|
1348
|
+
};
|
|
1349
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { ref: rootRef, className: "rwkv-combo", children: [
|
|
1350
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1351
|
+
"button",
|
|
1352
|
+
{
|
|
1353
|
+
type: "button",
|
|
1354
|
+
role: "combobox",
|
|
1355
|
+
"aria-expanded": showMenu,
|
|
1356
|
+
"aria-controls": showMenu ? listId : void 0,
|
|
1357
|
+
className: "rwkv-input rwkv-select-trigger",
|
|
1358
|
+
disabled: props.disabled,
|
|
1359
|
+
onClick: () => {
|
|
1360
|
+
setOpen((current) => !current);
|
|
1361
|
+
setActive(selectedIndex >= 0 ? selectedIndex : 0);
|
|
1362
|
+
},
|
|
1363
|
+
onKeyDown,
|
|
1364
|
+
children: [
|
|
1365
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "rwkv-select-value", children: currentLabel }),
|
|
1366
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChevronIcon, { open: showMenu })
|
|
1367
|
+
]
|
|
1368
|
+
}
|
|
1369
|
+
),
|
|
1370
|
+
showMenu ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { id: listId, role: "listbox", className: "rwkv-menu", children: props.options.map(([value, label], index) => {
|
|
1371
|
+
const selected = value === props.value;
|
|
1372
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1373
|
+
"button",
|
|
1374
|
+
{
|
|
1375
|
+
type: "button",
|
|
1376
|
+
role: "option",
|
|
1377
|
+
"aria-selected": selected,
|
|
1378
|
+
"data-active": active === index ? "true" : void 0,
|
|
1379
|
+
className: "rwkv-menu-item",
|
|
1380
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
1381
|
+
onMouseEnter: () => setActive(index),
|
|
1382
|
+
onClick: () => choose(value),
|
|
1383
|
+
children: [
|
|
1384
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "rwkv-menu-label", children: label }),
|
|
1385
|
+
selected ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CheckIcon, {}) : null
|
|
1386
|
+
]
|
|
1387
|
+
},
|
|
1388
|
+
value
|
|
1389
|
+
);
|
|
1390
|
+
}) }) : null
|
|
1391
|
+
] });
|
|
1392
|
+
}
|
|
1393
|
+
function Check(props) {
|
|
1394
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "rwkv-check", children: [
|
|
1395
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "checkbox", checked: props.checked, disabled: props.disabled, onChange: (event) => props.onChange(event.target.checked) }),
|
|
1396
|
+
props.label
|
|
1397
|
+
] });
|
|
1398
|
+
}
|
|
1399
|
+
function HeadersInput(props) {
|
|
1400
|
+
const [text, setText] = (0, import_react3.useState)(() => props.value && Object.keys(props.value).length > 0 ? JSON.stringify(props.value, null, 2) : "");
|
|
1401
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1402
|
+
"textarea",
|
|
1403
|
+
{
|
|
1404
|
+
className: "rwkv-input",
|
|
1405
|
+
value: text,
|
|
1406
|
+
disabled: props.disabled,
|
|
1407
|
+
spellCheck: false,
|
|
1408
|
+
placeholder: '{"CF-Access-Client-Id": "\u2026", "CF-Access-Client-Secret": "\u2026"}',
|
|
1409
|
+
onChange: (event) => {
|
|
1410
|
+
setText(event.target.value);
|
|
1411
|
+
if (event.target.value.trim() === "") return props.onChange(void 0);
|
|
1412
|
+
try {
|
|
1413
|
+
const parsed = JSON.parse(event.target.value);
|
|
1414
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error("\u9700\u8981\u4E00\u4E2A JSON \u5BF9\u8C61");
|
|
1415
|
+
props.onChange(Object.fromEntries(Object.entries(parsed).map(([key, value]) => [key, String(value)])));
|
|
1416
|
+
} catch (cause) {
|
|
1417
|
+
props.onChange(void 0, `\u8BF7\u6C42\u5934\u4E0D\u662F\u6709\u6548\u7684 JSON\uFF1A${cause instanceof Error ? cause.message : String(cause)}`);
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
);
|
|
1422
|
+
}
|
|
1423
|
+
function EditorActions(props) {
|
|
1424
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "rwkv-editor-actions", children: [
|
|
1425
|
+
props.error ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "rwkv-error", children: props.error }) : null,
|
|
1426
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "rwkv-btn rwkv-secondary", disabled: props.busy, onClick: props.onCancel, children: "\u53D6\u6D88" }),
|
|
1427
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "rwkv-btn rwkv-primary", disabled: props.busy || !props.canSave, onClick: props.onSave, children: props.busy ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58" })
|
|
1428
|
+
] });
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
// src/client/ModelCard.tsx
|
|
1432
|
+
var import_react6 = require("react");
|
|
1433
|
+
|
|
1434
|
+
// src/client/AdapterPicker.tsx
|
|
1435
|
+
var import_react4 = require("react");
|
|
1436
|
+
|
|
1437
|
+
// src/client/url.ts
|
|
1438
|
+
function isHttpUrl(value) {
|
|
1439
|
+
try {
|
|
1440
|
+
const url = new URL(value.trim());
|
|
1441
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.hostname !== "";
|
|
1442
|
+
} catch {
|
|
1443
|
+
return false;
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
function normalizeBaseURL(value) {
|
|
1447
|
+
const trimmed = value.trim();
|
|
1448
|
+
if (trimmed === "" || /^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed)) return trimmed;
|
|
1449
|
+
return `http://${trimmed}`;
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
// src/client/AdapterPicker.tsx
|
|
1453
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1454
|
+
var ROUTE = "/api/rwkv/adapters";
|
|
1455
|
+
var MAX_UPLOAD_BYTES = 512 << 20;
|
|
1456
|
+
function connectionHeader(connection) {
|
|
1457
|
+
const bytes = new TextEncoder().encode(JSON.stringify({
|
|
1458
|
+
baseURL: connection.baseURL.trim(),
|
|
1459
|
+
...connection.apiKey ? { apiKey: connection.apiKey } : {},
|
|
1460
|
+
...connection.headers ? { headers: connection.headers } : {}
|
|
1461
|
+
}));
|
|
1462
|
+
let binary = "";
|
|
1463
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
1464
|
+
return btoa(binary);
|
|
1465
|
+
}
|
|
1466
|
+
async function failureOf(response) {
|
|
1467
|
+
try {
|
|
1468
|
+
const body = await response.json();
|
|
1469
|
+
return body.error || `HTTP ${response.status}`;
|
|
1470
|
+
} catch {
|
|
1471
|
+
return `HTTP ${response.status}`;
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
function methodLabel(method) {
|
|
1475
|
+
const value = method.trim().toLowerCase();
|
|
1476
|
+
if (value === "miss") return "MiSS";
|
|
1477
|
+
if (value === "nora") return "NoRA";
|
|
1478
|
+
return value.toUpperCase();
|
|
1479
|
+
}
|
|
1480
|
+
function suggestID(path) {
|
|
1481
|
+
const parts = path.trim().split(/[\\/]+/).filter(Boolean);
|
|
1482
|
+
const stem = (parts.at(-1) || "").replace(/\.pth$/i, "");
|
|
1483
|
+
if (stem === "adapter-final" || stem === "training") {
|
|
1484
|
+
const parent = parts.at(-2) || "";
|
|
1485
|
+
if (/^checkpoint-\d+$/.test(parent) && parts.length >= 3) return `${parts.at(-3)}-${parent}`;
|
|
1486
|
+
return parent || stem;
|
|
1487
|
+
}
|
|
1488
|
+
return stem;
|
|
1489
|
+
}
|
|
1490
|
+
function AdapterPicker(props) {
|
|
1491
|
+
const { connection } = props;
|
|
1492
|
+
const ready = isHttpUrl(connection.baseURL);
|
|
1493
|
+
const key = JSON.stringify(connection);
|
|
1494
|
+
const [adapters, setAdapters] = (0, import_react4.useState)();
|
|
1495
|
+
const [loading, setLoading] = (0, import_react4.useState)(false);
|
|
1496
|
+
const [error, setError] = (0, import_react4.useState)("");
|
|
1497
|
+
const [pending, setPending] = (0, import_react4.useState)();
|
|
1498
|
+
const [customInput, setCustomInput] = (0, import_react4.useState)(false);
|
|
1499
|
+
const [customId, setCustomId] = (0, import_react4.useState)("");
|
|
1500
|
+
const [progress, setProgress] = (0, import_react4.useState)();
|
|
1501
|
+
const [deleting, setDeleting] = (0, import_react4.useState)();
|
|
1502
|
+
const fileInput = (0, import_react4.useRef)(null);
|
|
1503
|
+
const request = (0, import_react4.useRef)(0);
|
|
1504
|
+
const refresh = async () => {
|
|
1505
|
+
if (!ready) return;
|
|
1506
|
+
const current2 = ++request.current;
|
|
1507
|
+
setLoading(true);
|
|
1508
|
+
setError("");
|
|
1509
|
+
try {
|
|
1510
|
+
const response = await fetch(ROUTE, { headers: { "x-rwkv-connection": connectionHeader(connection) }, credentials: "same-origin" });
|
|
1511
|
+
if (!response.ok) throw new Error(await failureOf(response));
|
|
1512
|
+
const body = await response.json();
|
|
1513
|
+
if (current2 === request.current) setAdapters(body.adapters);
|
|
1514
|
+
} catch (cause) {
|
|
1515
|
+
if (current2 === request.current) {
|
|
1516
|
+
setAdapters(void 0);
|
|
1517
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
1518
|
+
}
|
|
1519
|
+
} finally {
|
|
1520
|
+
if (current2 === request.current) setLoading(false);
|
|
1521
|
+
}
|
|
1522
|
+
};
|
|
1523
|
+
(0, import_react4.useEffect)(() => {
|
|
1524
|
+
setAdapters(void 0);
|
|
1525
|
+
if (!ready) return;
|
|
1526
|
+
const timer = setTimeout(() => {
|
|
1527
|
+
void refresh();
|
|
1528
|
+
}, 400);
|
|
1529
|
+
return () => clearTimeout(timer);
|
|
1530
|
+
}, [key, ready]);
|
|
1531
|
+
const upload = (file, id) => {
|
|
1532
|
+
if (file.size > MAX_UPLOAD_BYTES) {
|
|
1533
|
+
setError(`\u6587\u4EF6 ${(file.size / 1048576).toFixed(0)} MB\uFF0C\u8D85\u8FC7 ${MAX_UPLOAD_BYTES >> 20} MB \u4E0A\u9650\uFF1B\u8BF7\u4E0A\u4F20 adapter-final.pth\uFF0C\u4E0D\u8981\u4F20\u5B8C\u6574\u8BAD\u7EC3 checkpoint`);
|
|
1534
|
+
return;
|
|
1535
|
+
}
|
|
1536
|
+
setError("");
|
|
1537
|
+
setProgress(0);
|
|
1538
|
+
const xhr = new XMLHttpRequest();
|
|
1539
|
+
xhr.open("PUT", `${ROUTE}/${encodeURIComponent(id)}?name=${encodeURIComponent(file.name)}`);
|
|
1540
|
+
xhr.setRequestHeader("x-rwkv-connection", connectionHeader(connection));
|
|
1541
|
+
xhr.setRequestHeader("content-type", "application/octet-stream");
|
|
1542
|
+
xhr.upload.onprogress = (event) => {
|
|
1543
|
+
if (event.lengthComputable) setProgress(Math.round(event.loaded * 100 / event.total));
|
|
1544
|
+
};
|
|
1545
|
+
xhr.onload = () => {
|
|
1546
|
+
setProgress(void 0);
|
|
1547
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
1548
|
+
setPending(void 0);
|
|
1549
|
+
props.onChange(id);
|
|
1550
|
+
void refresh();
|
|
1551
|
+
} else {
|
|
1552
|
+
let message = `HTTP ${xhr.status}`;
|
|
1553
|
+
try {
|
|
1554
|
+
message = JSON.parse(xhr.responseText).error || message;
|
|
1555
|
+
} catch {
|
|
1556
|
+
}
|
|
1557
|
+
setError(message);
|
|
1558
|
+
}
|
|
1559
|
+
};
|
|
1560
|
+
xhr.onerror = () => {
|
|
1561
|
+
setProgress(void 0);
|
|
1562
|
+
setError("\u4E0A\u4F20\u4E2D\u65AD\uFF1A\u8FDE\u63A5\u88AB\u65AD\u5F00");
|
|
1563
|
+
};
|
|
1564
|
+
xhr.send(file);
|
|
1565
|
+
};
|
|
1566
|
+
const remove = async (id) => {
|
|
1567
|
+
setDeleting(void 0);
|
|
1568
|
+
setError("");
|
|
1569
|
+
try {
|
|
1570
|
+
const response = await fetch(`${ROUTE}/${encodeURIComponent(id)}`, {
|
|
1571
|
+
method: "DELETE",
|
|
1572
|
+
headers: { "x-rwkv-connection": connectionHeader(connection) },
|
|
1573
|
+
credentials: "same-origin"
|
|
1574
|
+
});
|
|
1575
|
+
if (!response.ok) throw new Error(await failureOf(response));
|
|
1576
|
+
if (props.value === id) props.onChange(void 0);
|
|
1577
|
+
await refresh();
|
|
1578
|
+
} catch (cause) {
|
|
1579
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
1580
|
+
}
|
|
1581
|
+
};
|
|
1582
|
+
const current = props.value?.trim() || "";
|
|
1583
|
+
const busy = props.disabled || loading || progress !== void 0;
|
|
1584
|
+
const missing = adapters !== void 0 && current !== "" && !adapters.some((adapter) => adapter.id === current);
|
|
1585
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "rwkv-field", children: [
|
|
1586
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "rwkv-block-head", children: [
|
|
1587
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "rwkv-label", children: "Adapter" }),
|
|
1588
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "rwkv-actions", children: [
|
|
1589
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "rwkv-link", disabled: busy || !ready, onClick: () => {
|
|
1590
|
+
void refresh();
|
|
1591
|
+
}, children: loading ? "\u67E5\u8BE2\u4E2D\u2026" : "\u5237\u65B0" }),
|
|
1592
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "rwkv-link", disabled: props.disabled, onClick: () => setCustomInput(!customInput), children: customInput ? "\u53D6\u6D88\u8F93\u5165" : "\u624B\u586B ID" }),
|
|
1593
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "rwkv-btn rwkv-secondary rwkv-small", disabled: busy || !ready, onClick: () => fileInput.current?.click(), children: "\u4E0A\u4F20" })
|
|
1594
|
+
] }),
|
|
1595
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1596
|
+
"input",
|
|
1597
|
+
{
|
|
1598
|
+
ref: fileInput,
|
|
1599
|
+
type: "file",
|
|
1600
|
+
accept: ".pth",
|
|
1601
|
+
hidden: true,
|
|
1602
|
+
onChange: (event) => {
|
|
1603
|
+
const file = event.target.files?.[0];
|
|
1604
|
+
event.target.value = "";
|
|
1605
|
+
if (file) setPending({ file, id: suggestID(file.name) });
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
)
|
|
1609
|
+
] }),
|
|
1610
|
+
customInput ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "rwkv-upload-row", style: { marginBottom: 8 }, children: [
|
|
1611
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1612
|
+
"input",
|
|
1613
|
+
{
|
|
1614
|
+
className: "rwkv-input",
|
|
1615
|
+
value: customId,
|
|
1616
|
+
spellCheck: false,
|
|
1617
|
+
placeholder: "\u8F93\u5165\u5DF2\u6709\u7684 adapter ID",
|
|
1618
|
+
disabled: props.disabled,
|
|
1619
|
+
onChange: (event) => setCustomId(event.target.value)
|
|
1620
|
+
}
|
|
1621
|
+
),
|
|
1622
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1623
|
+
"button",
|
|
1624
|
+
{
|
|
1625
|
+
type: "button",
|
|
1626
|
+
className: "rwkv-btn rwkv-primary rwkv-small",
|
|
1627
|
+
disabled: !customId.trim(),
|
|
1628
|
+
onClick: () => {
|
|
1629
|
+
props.onChange(customId.trim() || void 0);
|
|
1630
|
+
setCustomInput(false);
|
|
1631
|
+
setCustomId("");
|
|
1632
|
+
},
|
|
1633
|
+
children: "\u4F7F\u7528"
|
|
1634
|
+
}
|
|
1635
|
+
)
|
|
1636
|
+
] }) : null,
|
|
1637
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "rwkv-list", children: [
|
|
1638
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "rwkv-option", "aria-pressed": current === "", disabled: props.disabled, onClick: () => props.onChange(void 0), children: [
|
|
1639
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "rwkv-option-name", children: "\u4E0D\u7528 adapter" }),
|
|
1640
|
+
current === "" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "rwkv-option-state", children: "\u4F7F\u7528\u4E2D" }) : null
|
|
1641
|
+
] }),
|
|
1642
|
+
(adapters ?? []).map((adapter) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "rwkv-option", "aria-pressed": current === adapter.id, children: [
|
|
1643
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "rwkv-option-main", disabled: props.disabled, onClick: () => props.onChange(adapter.id), children: [
|
|
1644
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "rwkv-option-name", children: adapter.id }),
|
|
1645
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "rwkv-option-meta", children: [methodLabel(adapter.method), adapter.rank ? `rank ${adapter.rank}` : "", adapter.version.slice(0, 8)].filter(Boolean).join(" \xB7 ") }),
|
|
1646
|
+
current === adapter.id ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "rwkv-option-state", children: "\u4F7F\u7528\u4E2D" }) : null
|
|
1647
|
+
] }),
|
|
1648
|
+
deleting === adapter.id ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "rwkv-actions", children: [
|
|
1649
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "rwkv-link", onClick: () => setDeleting(void 0), children: "\u53D6\u6D88" }),
|
|
1650
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "rwkv-btn rwkv-secondary rwkv-small rwkv-danger", onClick: () => {
|
|
1651
|
+
void remove(adapter.id);
|
|
1652
|
+
}, children: "\u4ECE\u670D\u52A1\u5668\u5220\u9664" })
|
|
1653
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "rwkv-link", disabled: busy, onClick: () => setDeleting(adapter.id), children: "\u5220\u9664" })
|
|
1654
|
+
] }, adapter.id)),
|
|
1655
|
+
missing ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "rwkv-option", "aria-pressed": true, children: [
|
|
1656
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "rwkv-option-main", children: [
|
|
1657
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "rwkv-option-name", children: current }),
|
|
1658
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "rwkv-error", children: "\u672A\u5728\u670D\u52A1\u5668\u5217\u8868\u4E2D\uFF08\u5C06\u76F4\u63A5\u6309\u6B64 ID \u8BF7\u6C42\uFF09" }),
|
|
1659
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "rwkv-option-state", children: "\u4F7F\u7528\u4E2D" })
|
|
1660
|
+
] }),
|
|
1661
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "rwkv-link", disabled: props.disabled, onClick: () => props.onChange(void 0), children: "\u6E05\u9664" })
|
|
1662
|
+
] }) : null
|
|
1663
|
+
] }),
|
|
1664
|
+
pending ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "rwkv-upload", children: [
|
|
1665
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "rwkv-option-meta", title: pending.file.name, children: [
|
|
1666
|
+
pending.file.name,
|
|
1667
|
+
" \xB7 ",
|
|
1668
|
+
(pending.file.size / 1048576).toFixed(1),
|
|
1669
|
+
" MB"
|
|
1670
|
+
] }),
|
|
1671
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "rwkv-upload-row", children: [
|
|
1672
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { className: "rwkv-input", value: pending.id, spellCheck: false, placeholder: "adapter id", disabled: progress !== void 0, onChange: (event) => setPending({ ...pending, id: event.target.value }) }),
|
|
1673
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "rwkv-btn rwkv-primary rwkv-small", disabled: !pending.id.trim() || progress !== void 0, onClick: () => upload(pending.file, pending.id.trim()), children: progress === void 0 ? "\u4E0A\u4F20" : `${progress}%` }),
|
|
1674
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "rwkv-link", disabled: progress !== void 0, onClick: () => setPending(void 0), children: "\u53D6\u6D88" })
|
|
1675
|
+
] })
|
|
1676
|
+
] }) : null,
|
|
1677
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "rwkv-error", children: error }) : null
|
|
1678
|
+
] });
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
// src/client/StatePicker.tsx
|
|
1682
|
+
var import_react5 = require("react");
|
|
1683
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1684
|
+
var MODEL_ROUTE = "/api/rwkv/models";
|
|
1685
|
+
var STATE_ROUTE = "/api/rwkv/states";
|
|
1686
|
+
function connectionHeader2(connection) {
|
|
1687
|
+
const bytes = new TextEncoder().encode(JSON.stringify({
|
|
1688
|
+
baseURL: connection.baseURL.trim(),
|
|
1689
|
+
...connection.apiKey ? { apiKey: connection.apiKey } : {},
|
|
1690
|
+
...connection.headers ? { headers: connection.headers } : {}
|
|
1691
|
+
}));
|
|
1692
|
+
let binary = "";
|
|
1693
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
1694
|
+
return btoa(binary);
|
|
1695
|
+
}
|
|
1696
|
+
async function failureOf2(response) {
|
|
1697
|
+
try {
|
|
1698
|
+
const body = await response.json();
|
|
1699
|
+
return body.error || `HTTP ${response.status}`;
|
|
1700
|
+
} catch {
|
|
1701
|
+
return `HTTP ${response.status}`;
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
function useServerModels(connection) {
|
|
1705
|
+
const ready = isHttpUrl(connection.baseURL);
|
|
1706
|
+
const key = JSON.stringify(connection);
|
|
1707
|
+
const [models, setModels] = (0, import_react5.useState)();
|
|
1708
|
+
const [loading, setLoading] = (0, import_react5.useState)(false);
|
|
1709
|
+
const [error, setError] = (0, import_react5.useState)("");
|
|
1710
|
+
(0, import_react5.useEffect)(() => {
|
|
1711
|
+
setModels(void 0);
|
|
1712
|
+
setError("");
|
|
1713
|
+
if (!ready) return;
|
|
1714
|
+
let live = true;
|
|
1715
|
+
const timer = setTimeout(() => {
|
|
1716
|
+
setLoading(true);
|
|
1717
|
+
void (async () => {
|
|
1718
|
+
try {
|
|
1719
|
+
const response = await fetch(MODEL_ROUTE, { headers: { "x-rwkv-connection": connectionHeader2(connection) }, credentials: "same-origin" });
|
|
1720
|
+
if (!response.ok) throw new Error(await failureOf2(response));
|
|
1721
|
+
const body = await response.json();
|
|
1722
|
+
if (live) setModels(body.models);
|
|
1723
|
+
} catch (cause) {
|
|
1724
|
+
if (live) setError(cause instanceof Error ? cause.message : String(cause));
|
|
1725
|
+
} finally {
|
|
1726
|
+
if (live) setLoading(false);
|
|
1727
|
+
}
|
|
1728
|
+
})();
|
|
1729
|
+
}, 400);
|
|
1730
|
+
return () => {
|
|
1731
|
+
live = false;
|
|
1732
|
+
clearTimeout(timer);
|
|
1733
|
+
};
|
|
1734
|
+
}, [key, ready]);
|
|
1735
|
+
return { models, loading, error };
|
|
1736
|
+
}
|
|
1737
|
+
function stateMeta(state) {
|
|
1738
|
+
return [
|
|
1739
|
+
state.original_filename,
|
|
1740
|
+
state.size_bytes === void 0 ? "" : `${(state.size_bytes / 1048576).toFixed(1)} MB`,
|
|
1741
|
+
state.layers ? `${state.layers} \u5C42` : "",
|
|
1742
|
+
state.uploaded_at ? state.uploaded_at.slice(0, 16).replace("T", " ") : ""
|
|
1743
|
+
].filter(Boolean).join(" \xB7 ");
|
|
1744
|
+
}
|
|
1745
|
+
function StatePicker(props) {
|
|
1746
|
+
const { connection } = props;
|
|
1747
|
+
const ready = isHttpUrl(connection.baseURL);
|
|
1748
|
+
const key = JSON.stringify(connection);
|
|
1749
|
+
const [states, setStates] = (0, import_react5.useState)();
|
|
1750
|
+
const [loading, setLoading] = (0, import_react5.useState)(false);
|
|
1751
|
+
const [error, setError] = (0, import_react5.useState)("");
|
|
1752
|
+
const [progress, setProgress] = (0, import_react5.useState)();
|
|
1753
|
+
const [deleting, setDeleting] = (0, import_react5.useState)();
|
|
1754
|
+
const fileInput = (0, import_react5.useRef)(null);
|
|
1755
|
+
const request = (0, import_react5.useRef)(0);
|
|
1756
|
+
const refresh = async () => {
|
|
1757
|
+
if (!ready) return;
|
|
1758
|
+
const current2 = ++request.current;
|
|
1759
|
+
setLoading(true);
|
|
1760
|
+
setError("");
|
|
1761
|
+
try {
|
|
1762
|
+
const response = await fetch(STATE_ROUTE, { headers: { "x-rwkv-connection": connectionHeader2(connection) }, credentials: "same-origin" });
|
|
1763
|
+
if (!response.ok) throw new Error(await failureOf2(response));
|
|
1764
|
+
const body = await response.json();
|
|
1765
|
+
if (current2 === request.current) setStates(body.states);
|
|
1766
|
+
} catch (cause) {
|
|
1767
|
+
if (current2 === request.current) {
|
|
1768
|
+
setStates(void 0);
|
|
1769
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
1770
|
+
}
|
|
1771
|
+
} finally {
|
|
1772
|
+
if (current2 === request.current) setLoading(false);
|
|
1773
|
+
}
|
|
1774
|
+
};
|
|
1775
|
+
(0, import_react5.useEffect)(() => {
|
|
1776
|
+
setStates(void 0);
|
|
1777
|
+
if (!ready) return;
|
|
1778
|
+
const timer = setTimeout(() => {
|
|
1779
|
+
void refresh();
|
|
1780
|
+
}, 400);
|
|
1781
|
+
return () => clearTimeout(timer);
|
|
1782
|
+
}, [key, ready]);
|
|
1783
|
+
const upload = (file) => {
|
|
1784
|
+
setError("");
|
|
1785
|
+
setProgress(0);
|
|
1786
|
+
const xhr = new XMLHttpRequest();
|
|
1787
|
+
xhr.open("PUT", `${STATE_ROUTE}?name=${encodeURIComponent(file.name)}`);
|
|
1788
|
+
xhr.setRequestHeader("x-rwkv-connection", connectionHeader2(connection));
|
|
1789
|
+
xhr.setRequestHeader("content-type", "application/octet-stream");
|
|
1790
|
+
xhr.upload.onprogress = (event) => {
|
|
1791
|
+
if (event.lengthComputable) setProgress(Math.round(event.loaded * 100 / event.total));
|
|
1792
|
+
};
|
|
1793
|
+
xhr.onload = () => {
|
|
1794
|
+
setProgress(void 0);
|
|
1795
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
1796
|
+
try {
|
|
1797
|
+
const body = JSON.parse(xhr.responseText);
|
|
1798
|
+
props.onChange(body.state.state_id);
|
|
1799
|
+
} catch {
|
|
1800
|
+
}
|
|
1801
|
+
void refresh();
|
|
1802
|
+
} else {
|
|
1803
|
+
let message = `HTTP ${xhr.status}`;
|
|
1804
|
+
try {
|
|
1805
|
+
message = JSON.parse(xhr.responseText).error || message;
|
|
1806
|
+
} catch {
|
|
1807
|
+
}
|
|
1808
|
+
setError(message);
|
|
1809
|
+
}
|
|
1810
|
+
};
|
|
1811
|
+
xhr.onerror = () => {
|
|
1812
|
+
setProgress(void 0);
|
|
1813
|
+
setError("\u4E0A\u4F20\u4E2D\u65AD\uFF1A\u8FDE\u63A5\u88AB\u65AD\u5F00");
|
|
1814
|
+
};
|
|
1815
|
+
xhr.send(file);
|
|
1816
|
+
};
|
|
1817
|
+
const remove = async (id) => {
|
|
1818
|
+
setDeleting(void 0);
|
|
1819
|
+
setError("");
|
|
1820
|
+
try {
|
|
1821
|
+
const response = await fetch(`${STATE_ROUTE}/${encodeURIComponent(id)}`, {
|
|
1822
|
+
method: "DELETE",
|
|
1823
|
+
headers: { "x-rwkv-connection": connectionHeader2(connection) },
|
|
1824
|
+
credentials: "same-origin"
|
|
1825
|
+
});
|
|
1826
|
+
if (!response.ok) throw new Error(await failureOf2(response));
|
|
1827
|
+
if (props.value === id) props.onChange(void 0);
|
|
1828
|
+
await refresh();
|
|
1829
|
+
} catch (cause) {
|
|
1830
|
+
setError(cause instanceof Error ? cause.message : String(cause));
|
|
1831
|
+
}
|
|
1832
|
+
};
|
|
1833
|
+
const current = props.value?.trim() || "";
|
|
1834
|
+
const busy = props.disabled || loading || progress !== void 0;
|
|
1835
|
+
const missing = states !== void 0 && current !== "" && !states.some((state) => state.state_id === current);
|
|
1836
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "rwkv-field", children: [
|
|
1837
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "rwkv-block-head", children: [
|
|
1838
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "rwkv-label", children: "State" }),
|
|
1839
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "rwkv-actions", children: [
|
|
1840
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "rwkv-link", disabled: busy || !ready, onClick: () => {
|
|
1841
|
+
void refresh();
|
|
1842
|
+
}, children: loading ? "\u5237\u65B0\u4E2D\u2026" : "\u5237\u65B0" }),
|
|
1843
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "rwkv-btn rwkv-secondary rwkv-small", disabled: busy || !ready, onClick: () => fileInput.current?.click(), children: progress === void 0 ? "\u4E0A\u4F20" : `${progress}%` })
|
|
1844
|
+
] }),
|
|
1845
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1846
|
+
"input",
|
|
1847
|
+
{
|
|
1848
|
+
ref: fileInput,
|
|
1849
|
+
type: "file",
|
|
1850
|
+
accept: ".pth",
|
|
1851
|
+
hidden: true,
|
|
1852
|
+
onChange: (event) => {
|
|
1853
|
+
const file = event.target.files?.[0];
|
|
1854
|
+
event.target.value = "";
|
|
1855
|
+
if (file) upload(file);
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
)
|
|
1859
|
+
] }),
|
|
1860
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "rwkv-list", children: [
|
|
1861
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("button", { type: "button", className: "rwkv-option", "aria-pressed": current === "", disabled: props.disabled, onClick: () => props.onChange(void 0), children: [
|
|
1862
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "rwkv-option-name", children: "\u4E0D\u7528 state" }),
|
|
1863
|
+
current === "" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "rwkv-option-state", children: "\u4F7F\u7528\u4E2D" }) : null
|
|
1864
|
+
] }),
|
|
1865
|
+
(states ?? []).map((state) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "rwkv-option", "aria-pressed": current === state.state_id, children: [
|
|
1866
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("button", { type: "button", className: "rwkv-option-main", disabled: props.disabled, onClick: () => props.onChange(state.state_id), children: [
|
|
1867
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "rwkv-option-name", title: state.state_id, children: state.state_id }),
|
|
1868
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "rwkv-option-meta", children: stateMeta(state) }),
|
|
1869
|
+
current === state.state_id ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "rwkv-option-state", children: "\u4F7F\u7528\u4E2D" }) : null
|
|
1870
|
+
] }),
|
|
1871
|
+
deleting === state.state_id ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "rwkv-actions", children: [
|
|
1872
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "rwkv-link", onClick: () => setDeleting(void 0), children: "\u53D6\u6D88" }),
|
|
1873
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "rwkv-btn rwkv-secondary rwkv-small rwkv-danger", onClick: () => {
|
|
1874
|
+
void remove(state.state_id);
|
|
1875
|
+
}, children: "\u4ECE\u670D\u52A1\u5668\u5220\u9664" })
|
|
1876
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "rwkv-link", disabled: busy, onClick: () => setDeleting(state.state_id), children: "\u5220\u9664" })
|
|
1877
|
+
] }, state.state_id)),
|
|
1878
|
+
missing ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rwkv-option", "aria-pressed": true, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "rwkv-option-main", children: [
|
|
1879
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "rwkv-option-name", children: current }),
|
|
1880
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "rwkv-error", children: "\u4E0D\u5728\u670D\u52A1\u5668\u4E0A\uFF08\u670D\u52A1\u91CD\u542F\u4F1A\u6E05\u6389\u4E0A\u4F20\u7684 state\uFF0C\u9700\u8981\u91CD\u65B0\u4E0A\u4F20\uFF09" })
|
|
1881
|
+
] }) }) : null
|
|
1882
|
+
] }),
|
|
1883
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "rwkv-error", children: error }) : null
|
|
1884
|
+
] });
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
// src/client/ModelCard.tsx
|
|
1888
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1889
|
+
var BLANK_MODEL = { id: "", backend: "lightning", baseURL: "", model: "", contextWindow: 32768 };
|
|
1890
|
+
var BACKEND_LABEL = { lightning: "rwkv_lightning", irwkv: "iRWKV" };
|
|
1891
|
+
function cleanModel(model) {
|
|
1892
|
+
const result = {};
|
|
1893
|
+
for (const [key, value] of Object.entries(model)) {
|
|
1894
|
+
if (value === "" || value === void 0) continue;
|
|
1895
|
+
if (key === "adapter") {
|
|
1896
|
+
const id = value.id;
|
|
1897
|
+
if (typeof id === "string" && id !== "" && !model.adapterId) result.adapterId = id;
|
|
1898
|
+
continue;
|
|
1899
|
+
}
|
|
1900
|
+
if (key === "headers" && Object.keys(value).length === 0) continue;
|
|
1901
|
+
result[key] = value;
|
|
1902
|
+
}
|
|
1903
|
+
return result;
|
|
1904
|
+
}
|
|
1905
|
+
function modelFailure(model, others) {
|
|
1906
|
+
if (!model.id.trim()) return "\u8BF7\u586B\u5199\u6A21\u578B ID";
|
|
1907
|
+
if (!/^[A-Za-z0-9][\w.-]*$/.test(model.id.trim())) return "\u6A21\u578B ID \u53EA\u80FD\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u70B9\u3001\u4E0B\u5212\u7EBF\u548C\u8FDE\u5B57\u7B26";
|
|
1908
|
+
if (others.some((other) => other.id === model.id.trim())) return `\u5DF2\u6709\u4E00\u4E2A\u6A21\u578B\u53EB ${model.id}`;
|
|
1909
|
+
if (!isHttpUrl(normalizeBaseURL(model.baseURL))) return "\u670D\u52A1\u5730\u5740\u9700\u8981\u662F IP:\u7AEF\u53E3 \u6216 http(s) \u5730\u5740";
|
|
1910
|
+
if (!model.model.trim()) return "\u8BF7\u586B\u5199\u4E0A\u6E38\u6A21\u578B ID";
|
|
1911
|
+
return void 0;
|
|
1912
|
+
}
|
|
1913
|
+
function ModelEditor(props) {
|
|
1914
|
+
const [draft, setDraft] = (0, import_react6.useState)(props.initial);
|
|
1915
|
+
const [idLinked, setIdLinked] = (0, import_react6.useState)(props.initial.id === "" || props.initial.id === props.initial.model);
|
|
1916
|
+
const [nameLinked, setNameLinked] = (0, import_react6.useState)(!props.initial.name || props.initial.name === props.initial.model);
|
|
1917
|
+
const [modelLinked, setModelLinked] = (0, import_react6.useState)(props.initial.model === "");
|
|
1918
|
+
const [touched2, setTouched] = (0, import_react6.useState)(false);
|
|
1919
|
+
const [headersError, setHeadersError] = (0, import_react6.useState)();
|
|
1920
|
+
const [busy, setBusy] = (0, import_react6.useState)(false);
|
|
1921
|
+
const [failure, setFailure] = (0, import_react6.useState)();
|
|
1922
|
+
const set = (key, value) => {
|
|
1923
|
+
setDraft((current) => ({ ...current, [key]: value }));
|
|
1924
|
+
setTouched(true);
|
|
1925
|
+
setFailure(void 0);
|
|
1926
|
+
};
|
|
1927
|
+
const setUpstream = (value, byHand = true) => {
|
|
1928
|
+
if (byHand) setModelLinked(value.trim() === "");
|
|
1929
|
+
setDraft((current) => ({
|
|
1930
|
+
...current,
|
|
1931
|
+
model: value,
|
|
1932
|
+
...idLinked ? { id: value.trim() } : {},
|
|
1933
|
+
...nameLinked ? { name: value.trim() } : {}
|
|
1934
|
+
}));
|
|
1935
|
+
setTouched(true);
|
|
1936
|
+
setFailure(void 0);
|
|
1937
|
+
};
|
|
1938
|
+
const lightning = draft.backend === "lightning";
|
|
1939
|
+
const connection = { baseURL: normalizeBaseURL(draft.baseURL), apiKey: draft.apiKey, headers: draft.headers };
|
|
1940
|
+
const server = useServerModels(connection);
|
|
1941
|
+
(0, import_react6.useEffect)(() => {
|
|
1942
|
+
const first = server.models?.[0];
|
|
1943
|
+
if (modelLinked && first !== void 0 && first !== draft.model) setUpstream(first, false);
|
|
1944
|
+
}, [server.models, modelLinked]);
|
|
1945
|
+
const modelHint = server.loading ? "\u6B63\u5728\u5411\u670D\u52A1\u5668\u67E5\u8BE2\u6A21\u578B\u2026" : server.error ? `\u6CA1\u80FD\u53D6\u5230\u6A21\u578B\u5217\u8868\uFF1A${server.error}` : server.models === void 0 ? "\u586B\u597D\u670D\u52A1\u5730\u5740\u540E\u4F1A\u81EA\u52A8\u4ECE\u670D\u52A1\u5668\u8BFB\u53D6" : server.models.length === 0 ? "\u670D\u52A1\u5668\u6CA1\u6709\u5217\u51FA\u6A21\u578B" : server.models.includes(draft.model.trim()) ? void 0 : `\u670D\u52A1\u5668\u4E0A\u7684\u6A21\u578B\uFF1A${server.models.join("\u3001")}`;
|
|
1946
|
+
const disabled = props.disabled || busy;
|
|
1947
|
+
const invalid = modelFailure(draft, props.others) ?? headersError;
|
|
1948
|
+
const save = async () => {
|
|
1949
|
+
setBusy(true);
|
|
1950
|
+
const ok = await props.onSave(cleanModel({ ...draft, id: draft.id.trim(), baseURL: normalizeBaseURL(draft.baseURL), model: draft.model.trim() }));
|
|
1951
|
+
setBusy(false);
|
|
1952
|
+
if (!ok) setFailure("Host \u6CA1\u6709\u63A5\u53D7\u8FD9\u4EFD\u914D\u7F6E\uFF08\u6821\u9A8C\u5931\u8D25\uFF0C\u6216\u914D\u7F6E\u5DF2\u5728\u522B\u5904\u4FEE\u6539\uFF09\uFF0C\u8349\u7A3F\u5DF2\u4FDD\u7559");
|
|
1953
|
+
};
|
|
1954
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rwkv-editor", children: [
|
|
1955
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rwkv-editor-head", children: [
|
|
1956
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rwkv-editor-title", children: draft.name || draft.id || "\u65B0\u6A21\u578B" }),
|
|
1957
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "rwkv-editor-sub", children: [
|
|
1958
|
+
"rwkv/",
|
|
1959
|
+
draft.id || "\u2026"
|
|
1960
|
+
] })
|
|
1961
|
+
] }),
|
|
1962
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: "\u540E\u7AEF", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1963
|
+
Segment,
|
|
1964
|
+
{
|
|
1965
|
+
value: draft.backend,
|
|
1966
|
+
disabled,
|
|
1967
|
+
options: [["lightning", "rwkv_lightning CUDA"], ["irwkv", "iRWKV\uFF08vLLM\uFF09"]],
|
|
1968
|
+
onChange: (value) => set("backend", value)
|
|
1969
|
+
}
|
|
1970
|
+
) }),
|
|
1971
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rwkv-grid", children: [
|
|
1972
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: "\u670D\u52A1\u5730\u5740", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TextInput, { value: draft.baseURL, disabled, placeholder: "100.64.0.8:8060", onChange: (value) => set("baseURL", value) }) }),
|
|
1973
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: "\u4E0A\u6E38\u6A21\u578B ID", hint: modelHint, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ComboInput, { value: draft.model, options: server.models ?? [], disabled, placeholder: "\u81EA\u52A8\u4ECE\u670D\u52A1\u5668\u8BFB\u53D6", align: "end", onChange: (value) => setUpstream(value) }) }),
|
|
1974
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: "\u6A21\u578B ID", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TextInput, { value: draft.id, disabled, placeholder: "\u9ED8\u8BA4\u540C\u4E0A\u6E38\u6A21\u578B ID", onChange: (value) => {
|
|
1975
|
+
setIdLinked(value.trim() === "");
|
|
1976
|
+
set("id", value);
|
|
1977
|
+
} }) }),
|
|
1978
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: "\u663E\u793A\u540D", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TextInput, { value: draft.name, disabled, placeholder: "\u9ED8\u8BA4\u540C\u4E0A\u6E38\u6A21\u578B ID", onChange: (value) => {
|
|
1979
|
+
setNameLinked(value.trim() === "");
|
|
1980
|
+
set("name", value);
|
|
1981
|
+
} }) })
|
|
1982
|
+
] }),
|
|
1983
|
+
lightning ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
1984
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1985
|
+
StatePicker,
|
|
1986
|
+
{
|
|
1987
|
+
connection,
|
|
1988
|
+
value: draft.stateId,
|
|
1989
|
+
disabled,
|
|
1990
|
+
onChange: (id) => set("stateId", id)
|
|
1991
|
+
}
|
|
1992
|
+
),
|
|
1993
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1994
|
+
AdapterPicker,
|
|
1995
|
+
{
|
|
1996
|
+
connection,
|
|
1997
|
+
value: draft.adapterId ?? draft.adapter?.id,
|
|
1998
|
+
disabled,
|
|
1999
|
+
onChange: (id) => {
|
|
2000
|
+
set("adapterId", id);
|
|
2001
|
+
set("adapter", void 0);
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
)
|
|
2005
|
+
] }) : null,
|
|
2006
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("details", { className: "rwkv-details", children: [
|
|
2007
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("summary", { className: "rwkv-summary", children: "\u81EA\u5B9A\u4E49\u8BBE\u7F6E" }),
|
|
2008
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "rwkv-details-body", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rwkv-grid", children: [
|
|
2009
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: lightning ? "\u5BC6\u7801" : "API \u5BC6\u94A5", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TextInput, { type: "password", value: draft.apiKey, disabled, placeholder: "\u7559\u7A7A\u8868\u793A\u4E0D\u9700\u8981", onChange: (value) => set("apiKey", value) }) }),
|
|
2010
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: "\u4E0A\u4E0B\u6587\u7A97\u53E3", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(NumberInput, { value: draft.contextWindow, disabled, placeholder: "32768", onChange: (value) => set("contextWindow", value) }) }),
|
|
2011
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: "\u601D\u8003", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2012
|
+
SelectInput,
|
|
2013
|
+
{
|
|
2014
|
+
value: draft.thinking ?? "",
|
|
2015
|
+
disabled,
|
|
2016
|
+
options: [["", "\u8DDF\u968F\u8FD0\u884C\u53C2\u6570"], ["full", "\u5F00\u542F"], ["off", "\u5173\u95ED"]],
|
|
2017
|
+
onChange: (value) => set("thinking", value || void 0)
|
|
2018
|
+
}
|
|
2019
|
+
) }),
|
|
2020
|
+
draft.thinking !== "off" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: "\u5386\u53F2\u6B65\u9AA4\u601D\u8003", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2021
|
+
SelectInput,
|
|
2022
|
+
{
|
|
2023
|
+
value: draft.historyEmptyThink === void 0 ? "" : draft.historyEmptyThink ? "on" : "off",
|
|
2024
|
+
disabled,
|
|
2025
|
+
options: [["", "\u8DDF\u968F\u8FD0\u884C\u53C2\u6570"], ["on", "\u5386\u53F2\u7A7A\u601D\u8003\uFF08\u63A8\u8350\uFF09"], ["off", "\u5B8C\u6574\u601D\u8003"]],
|
|
2026
|
+
onChange: (value) => set("historyEmptyThink", value === "" ? void 0 : value === "on")
|
|
2027
|
+
}
|
|
2028
|
+
) }) : null,
|
|
2029
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label: "\u989D\u5916\u8BF7\u6C42\u5934\uFF08JSON\uFF09", wide: true, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HeadersInput, { value: draft.headers, disabled, onChange: (value, error) => {
|
|
2030
|
+
setHeadersError(error);
|
|
2031
|
+
if (!error) set("headers", value);
|
|
2032
|
+
} }) })
|
|
2033
|
+
] }) })
|
|
2034
|
+
] }),
|
|
2035
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2036
|
+
EditorActions,
|
|
2037
|
+
{
|
|
2038
|
+
error: failure ?? (touched2 ? invalid : void 0),
|
|
2039
|
+
busy,
|
|
2040
|
+
canSave: !disabled && invalid === void 0,
|
|
2041
|
+
onCancel: props.onCancel,
|
|
2042
|
+
onSave: () => {
|
|
2043
|
+
void save();
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
)
|
|
2047
|
+
] });
|
|
2048
|
+
}
|
|
2049
|
+
function ModelCard(props) {
|
|
2050
|
+
const { model } = props;
|
|
2051
|
+
const [confirming, setConfirming] = (0, import_react6.useState)(false);
|
|
2052
|
+
const stateId = model.backend === "lightning" ? model.stateId : void 0;
|
|
2053
|
+
const adapterId = model.backend === "lightning" ? model.adapterId ?? model.adapter?.id : void 0;
|
|
2054
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("li", { className: "rwkv-card", children: [
|
|
2055
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "rwkv-head", children: [
|
|
2056
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "rwkv-identity", children: [
|
|
2057
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rwkv-name", children: model.name || model.id }),
|
|
2058
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rwkv-tag", children: BACKEND_LABEL[model.backend] }),
|
|
2059
|
+
stateId ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rwkv-dot", title: `state ${stateId}` }) : null,
|
|
2060
|
+
adapterId ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rwkv-dot", title: `adapter ${adapterId}` }) : null
|
|
2061
|
+
] }),
|
|
2062
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "rwkv-meta", children: [
|
|
2063
|
+
model.model,
|
|
2064
|
+
stateId ? ` \xB7 state ${stateId}` : "",
|
|
2065
|
+
adapterId ? ` \xB7 adapter ${adapterId}` : "",
|
|
2066
|
+
model.thinking === "off" ? " \xB7 \u601D\u8003\u5173" : model.historyEmptyThink === true ? " \xB7 \u5386\u53F2\u7A7A\u601D\u8003" : model.historyEmptyThink === false ? " \xB7 \u5B8C\u6574\u601D\u8003" : ""
|
|
2067
|
+
] }),
|
|
2068
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "rwkv-actions", children: props.editing ? null : confirming ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
2069
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "rwkv-link", onClick: () => setConfirming(false), children: "\u53D6\u6D88" }),
|
|
2070
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "rwkv-btn rwkv-secondary rwkv-small rwkv-danger", disabled: props.disabled, onClick: () => {
|
|
2071
|
+
void props.onRemove();
|
|
2072
|
+
}, children: "\u786E\u8BA4\u5220\u9664" })
|
|
2073
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
2074
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "rwkv-link", disabled: props.disabled, onClick: () => setConfirming(true), children: "\u5220\u9664" }),
|
|
2075
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "rwkv-btn rwkv-secondary rwkv-small", disabled: props.disabled, onClick: props.onEdit, children: "\u7F16\u8F91" })
|
|
2076
|
+
] }) })
|
|
2077
|
+
] }),
|
|
2078
|
+
props.editing ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ModelEditor, { initial: model, others: props.others, disabled: props.disabled, onCancel: props.onClose, onSave: props.onSave }) : null
|
|
2079
|
+
] });
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
// src/client/RwkvSettings.tsx
|
|
2083
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2084
|
+
var RUN_DEFAULTS = {
|
|
2085
|
+
thinking: "full",
|
|
2086
|
+
historyEmptyThink: true,
|
|
2087
|
+
maxSteps: DEFAULT_MAX_STEPS,
|
|
2088
|
+
maxConsecutiveFailures: DEFAULT_MAX_CONSECUTIVE_FAILURES,
|
|
2089
|
+
protocolRetries: DEFAULT_PROTOCOL_RETRIES,
|
|
2090
|
+
decisionMaxTokens: DEFAULT_DECISION_MAX_TOKENS,
|
|
2091
|
+
answerMaxTokens: DEFAULT_ANSWER_MAX_TOKENS,
|
|
2092
|
+
sampling: AGENT_FAST_SAMPLING,
|
|
2093
|
+
taskContract: "",
|
|
2094
|
+
loopGuard: true,
|
|
2095
|
+
currentDate: true
|
|
2096
|
+
};
|
|
2097
|
+
var RUN_FIELDS = Object.keys(RUN_DEFAULTS);
|
|
2098
|
+
function normalize(value) {
|
|
2099
|
+
const config = { ...RUN_DEFAULTS, ...DEVELOPER_DEFAULTS, models: [], ...typeof value === "object" && value !== null ? value : {} };
|
|
2100
|
+
return { ...config, sampling: { ...AGENT_FAST_SAMPLING, ...config.sampling }, models: (config.models ?? []).map((model) => ({ ...model })) };
|
|
2101
|
+
}
|
|
2102
|
+
function runSummary(run) {
|
|
2103
|
+
const sampling = same(run.sampling, AGENT_FAST_SAMPLING) ? "\u63A8\u8350\u91C7\u6837" : `T ${run.sampling.temperature} \xB7 top_p ${run.sampling.topP}`;
|
|
2104
|
+
const think = run.thinking === "off" ? "\u601D\u8003\u5173" : run.historyEmptyThink ? "\u601D\u8003\u5F00\uFF08\u5386\u53F2\u7A7A\u601D\u8003\uFF09" : "\u601D\u8003\u5F00\uFF08\u5B8C\u6574\u601D\u8003\uFF09";
|
|
2105
|
+
return `${think} \xB7 \u6BCF\u8F6E ${run.maxSteps} \u6B65 \xB7 ${sampling}`;
|
|
2106
|
+
}
|
|
2107
|
+
var isRunDefault = (run) => RUN_FIELDS.every((field) => same(run[field], RUN_DEFAULTS[field]));
|
|
2108
|
+
function RunEditor(props) {
|
|
2109
|
+
const [draft, setDraft] = (0, import_react7.useState)(props.initial);
|
|
2110
|
+
const [resetKey, setResetKey] = (0, import_react7.useState)(0);
|
|
2111
|
+
const [samplingKey, setSamplingKey] = (0, import_react7.useState)(0);
|
|
2112
|
+
const [busy, setBusy] = (0, import_react7.useState)(false);
|
|
2113
|
+
const [failure, setFailure] = (0, import_react7.useState)();
|
|
2114
|
+
const disabled = props.disabled || busy;
|
|
2115
|
+
const update = (patch) => {
|
|
2116
|
+
setDraft((current) => ({ ...current, ...patch }));
|
|
2117
|
+
setFailure(void 0);
|
|
2118
|
+
};
|
|
2119
|
+
const num = (key) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(NumberInput, { value: draft[key], disabled, onChange: (value) => update({ [key]: value ?? RUN_DEFAULTS[key] }) }, `${key}-${resetKey}`);
|
|
2120
|
+
const sampling = (key) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(NumberInput, { value: draft.sampling[key], disabled, onChange: (value) => update({ sampling: { ...draft.sampling, [key]: value ?? AGENT_FAST_SAMPLING[key] } }) }, `${key}-${resetKey}-${samplingKey}`);
|
|
2121
|
+
const save = async () => {
|
|
2122
|
+
setBusy(true);
|
|
2123
|
+
const ok = await props.onSave(draft);
|
|
2124
|
+
setBusy(false);
|
|
2125
|
+
if (!ok) setFailure("Host \u6CA1\u6709\u63A5\u53D7\u8FD9\u4EFD\u914D\u7F6E\uFF0C\u8349\u7A3F\u5DF2\u4FDD\u7559");
|
|
2126
|
+
};
|
|
2127
|
+
const thinkChoice = draft.thinking === "off" ? "off" : draft.historyEmptyThink ? "empty" : "full";
|
|
2128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "rwkv-editor", children: [
|
|
2129
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "rwkv-field", children: [
|
|
2130
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "rwkv-block-head", children: [
|
|
2131
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "rwkv-label", children: "\u601D\u8003" }),
|
|
2132
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2133
|
+
"button",
|
|
2134
|
+
{
|
|
2135
|
+
type: "button",
|
|
2136
|
+
className: "rwkv-link",
|
|
2137
|
+
disabled: disabled || isRunDefault(draft),
|
|
2138
|
+
onClick: () => {
|
|
2139
|
+
update(RUN_DEFAULTS);
|
|
2140
|
+
setResetKey((key) => key + 1);
|
|
2141
|
+
},
|
|
2142
|
+
children: "\u6062\u590D\u9ED8\u8BA4\u53C2\u6570"
|
|
2143
|
+
}
|
|
2144
|
+
)
|
|
2145
|
+
] }),
|
|
2146
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2147
|
+
Segment,
|
|
2148
|
+
{
|
|
2149
|
+
value: thinkChoice,
|
|
2150
|
+
disabled,
|
|
2151
|
+
options: [["empty", "\u5F00 \xB7 \u5386\u53F2\u7A7A\u601D\u8003"], ["full", "\u5F00 \xB7 \u5B8C\u6574\u601D\u8003"], ["off", "\u5173\u95ED"]],
|
|
2152
|
+
onChange: (value) => update(value === "off" ? { thinking: "off" } : { thinking: "full", historyEmptyThink: value === "empty" })
|
|
2153
|
+
}
|
|
2154
|
+
),
|
|
2155
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "rwkv-hint", children: "\u63A8\u8350\u300C\u5F00 \xB7 \u5386\u53F2\u7A7A\u601D\u8003\u300D\uFF1A\u53EA\u4FDD\u7559\u5F53\u524D\u6B65\u601D\u8003\uFF0C\u907F\u514D\u957F\u4E0A\u4E0B\u6587\u590D\u8BFB\u3002" })
|
|
2156
|
+
] }),
|
|
2157
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "rwkv-grid3", children: [
|
|
2158
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Field, { label: "\u6BCF\u8F6E\u6700\u591A\u5DE5\u5177\u6B65\u6570", children: num("maxSteps") }),
|
|
2159
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Field, { label: "\u540C\u4E00\u5DE5\u5177\u8FDE\u7EED\u5931\u8D25\u4E0A\u9650", children: num("maxConsecutiveFailures") }),
|
|
2160
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Field, { label: "\u683C\u5F0F\u9519\u8BEF\u91CD\u95EE\u6B21\u6570", children: num("protocolRetries") })
|
|
2161
|
+
] }),
|
|
2162
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "rwkv-grid", children: [
|
|
2163
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Field, { label: "\u5355\u6B65\u6700\u591A\u8F93\u51FA (token)", hint: "\u6BCF\u6B21\u601D\u8003\u3001\u8C03\u5DE5\u5177\u6216\u6B63\u5E38\u56DE\u7B54\u7684\u4E0A\u9650", children: num("decisionMaxTokens") }),
|
|
2164
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Field, { label: "\u5F3A\u884C\u6536\u5C3E\u6700\u591A\u8F93\u51FA (token)", hint: "\u6253\u6EE1\u6B65\u6570\u6216\u88AB\u62E6\u622A\u540E\u5F3A\u5236\u603B\u7ED3\u7684\u4E0A\u9650", children: num("answerMaxTokens") })
|
|
2165
|
+
] }),
|
|
2166
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "rwkv-checks", children: [
|
|
2167
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Check, { label: "\u590D\u8BFB\u65F6\u622A\u65AD\u751F\u6210", checked: draft.loopGuard, disabled, onChange: (value) => update({ loopGuard: value }) }),
|
|
2168
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Check, { label: "\u7CFB\u7EDF\u63D0\u793A\u8BCD\u672B\u5C3E\u5199\u5F53\u524D\u65E5\u671F\u548C\u65F6\u533A", checked: draft.currentDate, disabled, onChange: (value) => update({ currentDate: value }) })
|
|
2169
|
+
] }),
|
|
2170
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Field, { label: "\u4EFB\u52A1\u4E13\u7528\u8865\u5145\u89C4\u5219\uFF08Task-specific contract\uFF09", wide: true, hint: "\u9644\u52A0\u5728\u7CFB\u7EDF\u63D0\u793A\u8BCD\u672B\u5C3E\u3002\u8BAD\u7EC3\u6570\u636E\u548C\u8BC4\u6D4B\u90FD\u4E0D\u5E26\u8FD9\u6BB5\uFF0C\u586B\u4E86\u5C31\u548C\u8BAD\u7EC3\u5206\u5E03\u4E0D\u4E00\u81F4\uFF0C\u53EA\u7528\u4E8E\u4E34\u65F6\u8BD5\u9A8C\uFF1B\u6B63\u5F0F\u8BC4\u6D4B\u8BF7\u7559\u7A7A", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2171
|
+
"textarea",
|
|
2172
|
+
{
|
|
2173
|
+
className: "rwkv-input",
|
|
2174
|
+
value: draft.taskContract ?? "",
|
|
2175
|
+
disabled,
|
|
2176
|
+
placeholder: "\u7559\u7A7A = \u4E0D\u9644\u52A0\uFF08\u9ED8\u8BA4\uFF09",
|
|
2177
|
+
style: { minHeight: 64 },
|
|
2178
|
+
onChange: (event) => update({ taskContract: event.target.value })
|
|
2179
|
+
}
|
|
2180
|
+
) }),
|
|
2181
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "rwkv-block", children: [
|
|
2182
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "rwkv-block-head", children: [
|
|
2183
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "rwkv-block-title", children: "\u91C7\u6837" }),
|
|
2184
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2185
|
+
"button",
|
|
2186
|
+
{
|
|
2187
|
+
type: "button",
|
|
2188
|
+
className: "rwkv-link",
|
|
2189
|
+
disabled: disabled || same(draft.sampling, AGENT_FAST_SAMPLING),
|
|
2190
|
+
onClick: () => {
|
|
2191
|
+
update({ sampling: AGENT_FAST_SAMPLING });
|
|
2192
|
+
setSamplingKey((key) => key + 1);
|
|
2193
|
+
},
|
|
2194
|
+
children: "\u6062\u590D\u63A8\u8350\u53C2\u6570"
|
|
2195
|
+
}
|
|
2196
|
+
)
|
|
2197
|
+
] }),
|
|
2198
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "rwkv-grid3", children: [
|
|
2199
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Field, { label: "temperature", children: sampling("temperature") }),
|
|
2200
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Field, { label: "top_p", children: sampling("topP") }),
|
|
2201
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Field, { label: "top_k", children: sampling("topK") }),
|
|
2202
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Field, { label: "presence penalty", children: sampling("presencePenalty") }),
|
|
2203
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Field, { label: "frequency penalty", children: sampling("frequencyPenalty") }),
|
|
2204
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Field, { label: "penalty decay", children: sampling("penaltyDecay") })
|
|
2205
|
+
] })
|
|
2206
|
+
] }),
|
|
2207
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(EditorActions, { error: failure, busy, canSave: !disabled, onCancel: props.onCancel, onSave: () => {
|
|
2208
|
+
void save();
|
|
2209
|
+
} })
|
|
2210
|
+
] });
|
|
2211
|
+
}
|
|
2212
|
+
function RwkvSettings(props) {
|
|
2213
|
+
const { form } = props;
|
|
2214
|
+
const [writeError, setWriteError] = (0, import_react7.useState)("");
|
|
2215
|
+
const write = async (field, value) => {
|
|
2216
|
+
setWriteError("");
|
|
2217
|
+
const settled = await Promise.race([
|
|
2218
|
+
form.set(field, value),
|
|
2219
|
+
new Promise((resolve) => setTimeout(() => resolve("timeout"), 8e3))
|
|
2220
|
+
]);
|
|
2221
|
+
if (settled === true) return true;
|
|
2222
|
+
const reason = await props.explain?.(field, value);
|
|
2223
|
+
if (settled === "timeout" && !reason) return true;
|
|
2224
|
+
setWriteError(`\u4FDD\u5B58\u5931\u8D25${reason ? `\uFF1A${reason}` : ""}`);
|
|
2225
|
+
return false;
|
|
2226
|
+
};
|
|
2227
|
+
const getSnapshot = () => form.getSnapshot();
|
|
2228
|
+
const snapshot = (0, import_react7.useSyncExternalStore)((listener) => form.subscribe(listener), getSnapshot, getSnapshot);
|
|
2229
|
+
const [editing, setEditing] = (0, import_react7.useState)();
|
|
2230
|
+
if (snapshot.status === "loading") return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "rwkv-section", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "rwkv-intro", children: "\u52A0\u8F7D\u4E2D\u2026" }) });
|
|
2231
|
+
if (snapshot.status === "unavailable") return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "rwkv-section", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "rwkv-intro", children: "rwkv-llm \u63D2\u4EF6\u5F53\u524D\u6CA1\u6709\u52A0\u8F7D\uFF0C\u6682\u65F6\u65E0\u6CD5\u914D\u7F6E\u3002" }) });
|
|
2232
|
+
const config = normalize(snapshot.value);
|
|
2233
|
+
const disabled = !snapshot.writable;
|
|
2234
|
+
const saveModels = async (models) => {
|
|
2235
|
+
const ok = await write("models", models.map(cleanModel));
|
|
2236
|
+
if (ok) setEditing(void 0);
|
|
2237
|
+
return ok;
|
|
2238
|
+
};
|
|
2239
|
+
const saveRun = async (run) => {
|
|
2240
|
+
for (const field of RUN_FIELDS) {
|
|
2241
|
+
if (same(run[field], config[field])) continue;
|
|
2242
|
+
if (!await write(field, run[field])) return false;
|
|
2243
|
+
}
|
|
2244
|
+
setEditing(void 0);
|
|
2245
|
+
return true;
|
|
2246
|
+
};
|
|
2247
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "rwkv-section", children: [
|
|
2248
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { className: "rwkv-title", children: "RWKV Agent" }),
|
|
2249
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "rwkv-intro", children: "\u901A\u8FC7\u7EED\u5199\u63A5\u53E3\u63A5\u5165\u7684 RWKV-7 G1 \u6A21\u578B\u3002\u6BCF\u4E2A\u6A21\u578B\u90FD\u4F1A\u51FA\u73B0\u5728\u6A21\u578B\u9009\u62E9\u7684\u300CRWKV\u300D\u4E0B\uFF0C\u4E5F\u53EF\u4EE5\u4F5C\u4E3A\u5B50 Agent \u5DE5\u5177 rwkv_agent \u7684\u6267\u884C\u6A21\u578B\u3002" }),
|
|
2250
|
+
disabled ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "rwkv-hint", children: "\u672C\u90E8\u7F72\u7684\u8BBE\u7F6E\u662F\u53EA\u8BFB\u7684\u3002" }) : null,
|
|
2251
|
+
writeError ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "rwkv-error", children: writeError }) : null,
|
|
2252
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("ul", { className: "rwkv-rows", children: [
|
|
2253
|
+
config.models.map((model, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2254
|
+
ModelCard,
|
|
2255
|
+
{
|
|
2256
|
+
model,
|
|
2257
|
+
editing: editing === index,
|
|
2258
|
+
others: config.models.filter((_, at) => at !== index),
|
|
2259
|
+
disabled: disabled || editing !== void 0 && editing !== index,
|
|
2260
|
+
onEdit: () => setEditing(index),
|
|
2261
|
+
onClose: () => setEditing(void 0),
|
|
2262
|
+
onSave: (next) => saveModels(config.models.map((item, at) => at === index ? next : item)),
|
|
2263
|
+
onRemove: () => saveModels(config.models.filter((_, at) => at !== index))
|
|
2264
|
+
},
|
|
2265
|
+
`${model.id}-${index}`
|
|
2266
|
+
)),
|
|
2267
|
+
editing === "new" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { className: "rwkv-card", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2268
|
+
ModelEditor,
|
|
2269
|
+
{
|
|
2270
|
+
initial: BLANK_MODEL,
|
|
2271
|
+
others: config.models,
|
|
2272
|
+
disabled,
|
|
2273
|
+
onCancel: () => setEditing(void 0),
|
|
2274
|
+
onSave: (model) => saveModels([...config.models, model])
|
|
2275
|
+
}
|
|
2276
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("button", { type: "button", className: "rwkv-add", disabled: disabled || editing !== void 0, onClick: () => setEditing("new"), children: [
|
|
2277
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { "aria-hidden": "true", className: "rwkv-plus", children: "+" }),
|
|
2278
|
+
"\u6DFB\u52A0\u6A21\u578B"
|
|
2279
|
+
] }) })
|
|
2280
|
+
] }),
|
|
2281
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { className: "rwkv-subtitle", children: "\u8FD0\u884C\u53C2\u6570" }),
|
|
2282
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "rwkv-card", children: [
|
|
2283
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "rwkv-head", children: [
|
|
2284
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "rwkv-identity", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "rwkv-name", children: "Agent \u5FAA\u73AF\u4E0E\u91C7\u6837" }) }),
|
|
2285
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "rwkv-meta", children: runSummary(config) }),
|
|
2286
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "rwkv-actions", children: editing === "run" ? null : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: "rwkv-btn rwkv-secondary rwkv-small", disabled: disabled || editing !== void 0, onClick: () => setEditing("run"), children: "\u7F16\u8F91" }) })
|
|
2287
|
+
] }),
|
|
2288
|
+
editing === "run" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RunEditor, { initial: config, disabled, onCancel: () => setEditing(void 0), onSave: saveRun }) : null
|
|
2289
|
+
] }),
|
|
2290
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { className: "rwkv-subtitle", children: "\u5F00\u53D1\u8005\u4E0E\u8F68\u8FF9" }),
|
|
2291
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DeveloperCard, { settings: config, disabled, write })
|
|
2292
|
+
] });
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
// src/client/TraceView.tsx
|
|
2296
|
+
var import_react8 = require("react");
|
|
2297
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2298
|
+
var POLL_MS = 2500;
|
|
2299
|
+
function RwkvTraceView(props) {
|
|
2300
|
+
const [records, setRecords] = (0, import_react8.useState)();
|
|
2301
|
+
const [recording, setRecording] = (0, import_react8.useState)(false);
|
|
2302
|
+
const [error, setError] = (0, import_react8.useState)("");
|
|
2303
|
+
const [onlyTouched, setOnlyTouched] = (0, import_react8.useState)(false);
|
|
2304
|
+
const [showSide, setShowSide] = (0, import_react8.useState)(false);
|
|
2305
|
+
(0, import_react8.useEffect)(() => {
|
|
2306
|
+
setRecords(void 0);
|
|
2307
|
+
let stopped = false;
|
|
2308
|
+
let timer;
|
|
2309
|
+
let first = true;
|
|
2310
|
+
const load = async () => {
|
|
2311
|
+
if (first || document.visibilityState === "visible") {
|
|
2312
|
+
first = false;
|
|
2313
|
+
try {
|
|
2314
|
+
const body = await fetchSession(props.session);
|
|
2315
|
+
if (stopped) return;
|
|
2316
|
+
setRecording(body.recording);
|
|
2317
|
+
setRecords((current) => current !== void 0 && current.length === body.records.length ? current : body.records);
|
|
2318
|
+
setError("");
|
|
2319
|
+
} catch (cause) {
|
|
2320
|
+
if (!stopped) setError(cause instanceof Error ? cause.message : String(cause));
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
if (!stopped) timer = setTimeout(() => {
|
|
2324
|
+
void load();
|
|
2325
|
+
}, POLL_MS);
|
|
2326
|
+
};
|
|
2327
|
+
void load();
|
|
2328
|
+
return () => {
|
|
2329
|
+
stopped = true;
|
|
2330
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
2331
|
+
};
|
|
2332
|
+
}, [props.session]);
|
|
2333
|
+
const generations = (records ?? []).filter((record) => isGeneration(record) && record.purpose === void 0);
|
|
2334
|
+
const cards = (records ?? []).filter((record) => isCard(record) && record.purpose === void 0);
|
|
2335
|
+
const fallbackCards = cards.filter((record) => record.relay?.fallback === true).length;
|
|
2336
|
+
const judged = generations.filter((record) => record.outcome !== void 0);
|
|
2337
|
+
const hit = judged.filter(touched).length;
|
|
2338
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "rl-root", children: [
|
|
2339
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "rl-toolbar", children: [
|
|
2340
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "rl-toggles", children: [
|
|
2341
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: "rl-toggle", "aria-pressed": onlyTouched, onClick: () => setOnlyTouched((value) => !value), children: "\u53EA\u770B\u515C\u5E95" }),
|
|
2342
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: "rl-toggle", "aria-pressed": showSide, onClick: () => setShowSide((value) => !value), children: "\u9644\u5E26\u8BF7\u6C42" })
|
|
2343
|
+
] }),
|
|
2344
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: "rl-summary", children: [
|
|
2345
|
+
generations.length,
|
|
2346
|
+
" \u6B21\u751F\u6210 \xB7 ",
|
|
2347
|
+
hit,
|
|
2348
|
+
" \u6B21\u7528\u5230\u515C\u5E95",
|
|
2349
|
+
judged.length > 0 ? ` \xB7 \u539F\u6837\u53EF\u7528 ${percent(judged.length - hit, judged.length)}` : "",
|
|
2350
|
+
cards.length > 0 ? ` \xB7 \u63A5\u529B\u5361 ${cards.length} \u5F20${fallbackCards > 0 ? `\uFF08\u81EA\u52A8\u6458\u8981 ${fallbackCards}\uFF09` : ""}` : ""
|
|
2351
|
+
] })
|
|
2352
|
+
] }),
|
|
2353
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "rl-notice rwkv-error", children: error }) : null,
|
|
2354
|
+
records !== void 0 && records.length > 0 && !recording ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "rl-notice", children: "\u8F68\u8FF9\u53EA\u5728\u5185\u5B58\u91CC\uFF0CDSH \u91CD\u542F\u540E\u6E05\u7A7A\u3002\u8981\u843D\u76D8\uFF0C\u53BB\u8BBE\u7F6E \u2192 RWKV Agent \u2192 \u5F00\u53D1\u8005\u6253\u5F00\u300C\u539F\u59CB\u8FD0\u884C\u8F68\u8FF9\u843D\u76D8\u300D\u3002" }) : null,
|
|
2355
|
+
records === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "rl-empty", children: "\u52A0\u8F7D\u4E2D\u2026" }) : records.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "rl-empty", children: "\u8FD9\u4E2A\u4F1A\u8BDD\u6CA1\u6709 RWKV \u8BB0\u5F55\uFF1A\u5B83\u6CA1\u7528 RWKV \u6A21\u578B\uFF0C\u6216\u8005\u8F68\u8FF9\u6CA1\u6709\u4FDD\u5B58\u5230\u78C1\u76D8\u3001\u5DF2\u88AB\u5220\u9664\u3002" }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TraceFrames, { session: props.session, records, onlyTouched, showSide })
|
|
2356
|
+
] });
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
// src/client/WirePanel.tsx
|
|
2360
|
+
var import_react9 = require("react");
|
|
2361
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2362
|
+
var WIRE_TAB_ID = "rwkv-wire";
|
|
2363
|
+
var LONG_BLOCK_CHARS = 480;
|
|
2364
|
+
var LONG_BLOCK_LINES = 6;
|
|
2365
|
+
function tokenizeBody(text, role, options) {
|
|
2366
|
+
const spans = [];
|
|
2367
|
+
let i = 0;
|
|
2368
|
+
let usedPastThink = false;
|
|
2369
|
+
const push = (kind, slice, title) => {
|
|
2370
|
+
if (slice === "") return;
|
|
2371
|
+
const prev = spans[spans.length - 1];
|
|
2372
|
+
if (prev !== void 0 && prev.kind === kind && prev.title === title) {
|
|
2373
|
+
spans[spans.length - 1] = { kind, text: prev.text + slice, ...title === void 0 ? {} : { title } };
|
|
2374
|
+
} else {
|
|
2375
|
+
spans.push({ kind, text: slice, ...title === void 0 ? {} : { title } });
|
|
2376
|
+
}
|
|
2377
|
+
};
|
|
2378
|
+
const prefixMatch = /^(System:|User:|Assistant:|Tool:)/.exec(text);
|
|
2379
|
+
if (prefixMatch !== null) {
|
|
2380
|
+
push("label", prefixMatch[0]);
|
|
2381
|
+
i = prefixMatch[0].length;
|
|
2382
|
+
}
|
|
2383
|
+
if (role === "system") {
|
|
2384
|
+
push("plain", text.slice(i));
|
|
2385
|
+
return spans;
|
|
2386
|
+
}
|
|
2387
|
+
const TAG_RE = /<think>|<tool_call>|<tool_response>/g;
|
|
2388
|
+
while (i < text.length) {
|
|
2389
|
+
TAG_RE.lastIndex = i;
|
|
2390
|
+
const match = TAG_RE.exec(text);
|
|
2391
|
+
if (match === null) {
|
|
2392
|
+
const rest = text.slice(i);
|
|
2393
|
+
const openThinkIdx = rest.indexOf("<think");
|
|
2394
|
+
if (openThinkIdx >= 0 && openThinkIdx === rest.length - "<think".length) {
|
|
2395
|
+
push("plain", rest.slice(0, openThinkIdx));
|
|
2396
|
+
push("think", rest.slice(openThinkIdx));
|
|
2397
|
+
} else {
|
|
2398
|
+
push("plain", rest);
|
|
2399
|
+
}
|
|
2400
|
+
break;
|
|
2401
|
+
}
|
|
2402
|
+
if (match.index > i) {
|
|
2403
|
+
push("plain", text.slice(i, match.index));
|
|
2404
|
+
}
|
|
2405
|
+
const openTag = match[0];
|
|
2406
|
+
const closeTag = openTag === "<think>" ? "</think>" : openTag === "<tool_call>" ? "</tool_call>" : "</tool_response>";
|
|
2407
|
+
const closeIdx = text.indexOf(closeTag, match.index + openTag.length);
|
|
2408
|
+
const endIdx = closeIdx >= 0 ? closeIdx + closeTag.length : text.length;
|
|
2409
|
+
const chunk = text.slice(match.index, endIdx);
|
|
2410
|
+
if (openTag === "<think>") {
|
|
2411
|
+
const inner = closeIdx >= 0 ? text.slice(match.index + openTag.length, closeIdx).trim() : "streaming";
|
|
2412
|
+
if (inner === "" && options.fillPastThink && !usedPastThink && options.pastThink) {
|
|
2413
|
+
usedPastThink = true;
|
|
2414
|
+
push("think-past", `<think>${options.pastThink}</think>`, "\u5386\u53F2\u601D\u8003\uFF08\u672A\u56DE\u4F20\u7ED9\u6A21\u578B\uFF0C\u4EC5\u5168\u91CF\u5386\u53F2\u5C55\u793A\uFF09");
|
|
2415
|
+
} else if (inner === "") {
|
|
2416
|
+
push("think-empty", chunk);
|
|
2417
|
+
} else if (options.isPastAssistant) {
|
|
2418
|
+
push("think-past", chunk, "\u5386\u53F2\u601D\u8003\uFF08\u6A21\u578B\u5B9E\u65F6\u89C6\u56FE\u4E2D\u7F6E\u7A7A\uFF09");
|
|
2419
|
+
} else {
|
|
2420
|
+
push("think", chunk);
|
|
2421
|
+
}
|
|
2422
|
+
} else if (openTag === "<tool_call>") {
|
|
2423
|
+
push("tool-call", chunk);
|
|
2424
|
+
} else {
|
|
2425
|
+
const isFolded = chunk.includes("[Old ");
|
|
2426
|
+
const isError = /"ok"\s*:\s*false/.test(chunk);
|
|
2427
|
+
push(isFolded ? "folded" : isError ? "tool-error" : "tool-result", chunk);
|
|
2428
|
+
}
|
|
2429
|
+
i = endIdx;
|
|
2430
|
+
}
|
|
2431
|
+
return spans;
|
|
2432
|
+
}
|
|
2433
|
+
function parseWireBlocks(raw, mode, pastThinks) {
|
|
2434
|
+
if (raw === "") return [];
|
|
2435
|
+
const splitRe = /(?=\n\n(?:System:|User:|Assistant:|Tool:))/g;
|
|
2436
|
+
const parts = raw.split(splitRe);
|
|
2437
|
+
const assistantCount = parts.filter((part) => part.replace(/^\n+/, "").startsWith("Assistant:")).length;
|
|
2438
|
+
const historyAssistants = Math.max(0, assistantCount - 1);
|
|
2439
|
+
const pastOffset = pastThinks && pastThinks.length > historyAssistants ? pastThinks.length - historyAssistants : 0;
|
|
2440
|
+
let assistantSeen = 0;
|
|
2441
|
+
return parts.map((part) => {
|
|
2442
|
+
const trimmed = part.replace(/^\n+/, "");
|
|
2443
|
+
const role = trimmed.startsWith("System:") ? "system" : trimmed.startsWith("User:") ? "user" : trimmed.startsWith("Assistant:") ? "assistant" : trimmed.startsWith("Tool:") ? "tool" : "other";
|
|
2444
|
+
let isPastAssistant = false;
|
|
2445
|
+
let pastThink;
|
|
2446
|
+
if (role === "assistant") {
|
|
2447
|
+
isPastAssistant = assistantSeen < historyAssistants;
|
|
2448
|
+
if (isPastAssistant && mode === "full" && pastThinks !== void 0) {
|
|
2449
|
+
pastThink = pastThinks[pastOffset + assistantSeen];
|
|
2450
|
+
}
|
|
2451
|
+
assistantSeen++;
|
|
2452
|
+
}
|
|
2453
|
+
const spans = tokenizeBody(trimmed, role, {
|
|
2454
|
+
isPastAssistant,
|
|
2455
|
+
...pastThink === void 0 ? {} : { pastThink },
|
|
2456
|
+
fillPastThink: mode === "full"
|
|
2457
|
+
});
|
|
2458
|
+
const hasFolded = spans.some((s) => s.kind === "folded");
|
|
2459
|
+
const hasError = spans.some((s) => s.kind === "tool-error");
|
|
2460
|
+
const hasResult = spans.some((s) => s.kind === "tool-result");
|
|
2461
|
+
const cardKind = role === "system" ? "system" : hasFolded ? "folded" : hasError ? "error" : hasResult || role === "tool" ? "tool" : role;
|
|
2462
|
+
return {
|
|
2463
|
+
role,
|
|
2464
|
+
cardKind,
|
|
2465
|
+
raw: trimmed,
|
|
2466
|
+
spans
|
|
2467
|
+
};
|
|
2468
|
+
});
|
|
2469
|
+
}
|
|
2470
|
+
function prettyJsonObject(rawJson) {
|
|
2471
|
+
try {
|
|
2472
|
+
const parsed = JSON.parse(rawJson);
|
|
2473
|
+
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
2474
|
+
const multilineKey = typeof parsed.result === "string" && parsed.result.includes("\n") ? "result" : typeof parsed.error === "string" && parsed.error.includes("\n") ? "error" : void 0;
|
|
2475
|
+
if (multilineKey !== void 0) {
|
|
2476
|
+
const textVal = parsed[multilineKey];
|
|
2477
|
+
const rest = Object.fromEntries(Object.entries(parsed).filter(([k]) => k !== multilineKey));
|
|
2478
|
+
const head = JSON.stringify(rest, null, 2);
|
|
2479
|
+
const indented = textVal.split("\n").map((line) => ` ${line}`).join("\n");
|
|
2480
|
+
return head === "{}" ? `{
|
|
2481
|
+
"${multilineKey}": """
|
|
2482
|
+
${indented}
|
|
2483
|
+
"""
|
|
2484
|
+
}` : `${head.slice(0, -1).trimEnd()},
|
|
2485
|
+
"${multilineKey}": """
|
|
2486
|
+
${indented}
|
|
2487
|
+
"""
|
|
2488
|
+
}`;
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
return JSON.stringify(parsed, null, 2);
|
|
2492
|
+
} catch {
|
|
2493
|
+
return rawJson;
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
function prettySystemText(text) {
|
|
2497
|
+
return text.replace(/<tool_call>(\{[^\n]*\})<\/tool_call>/g, (full, json) => {
|
|
2498
|
+
const formatted = prettyJsonObject(json);
|
|
2499
|
+
return formatted === json ? full : `<tool_call>
|
|
2500
|
+
${formatted}
|
|
2501
|
+
</tool_call>`;
|
|
2502
|
+
}).replace(/(^|\n)([ \t]*)(\{"name":[^\n]+\})(?=\n|$)/g, (full, lead, indent, json) => {
|
|
2503
|
+
const formatted = prettyJsonObject(json);
|
|
2504
|
+
if (formatted === json) return full;
|
|
2505
|
+
const indented = formatted.split("\n").map((line) => `${indent}${line}`).join("\n");
|
|
2506
|
+
return `${lead}${indented}`;
|
|
2507
|
+
});
|
|
2508
|
+
}
|
|
2509
|
+
function prettySpanText(span, role) {
|
|
2510
|
+
if (role === "system" && span.kind === "plain") return prettySystemText(span.text);
|
|
2511
|
+
if (span.kind !== "tool-call" && span.kind !== "tool-result" && span.kind !== "tool-error" && span.kind !== "folded") return span.text;
|
|
2512
|
+
const tag = span.kind === "tool-call" ? "tool_call" : "tool_response";
|
|
2513
|
+
const open = `<${tag}>`;
|
|
2514
|
+
const close = `</${tag}>`;
|
|
2515
|
+
if (!span.text.startsWith(open) || !span.text.endsWith(close)) return span.text;
|
|
2516
|
+
const inner = span.text.slice(open.length, span.text.length - close.length).trim();
|
|
2517
|
+
const formatted = prettyJsonObject(inner);
|
|
2518
|
+
return formatted === inner ? span.text : `${open}
|
|
2519
|
+
${formatted}
|
|
2520
|
+
${close}`;
|
|
2521
|
+
}
|
|
2522
|
+
function isLongBlock(raw) {
|
|
2523
|
+
if (raw.length > LONG_BLOCK_CHARS) return true;
|
|
2524
|
+
let lines = 1;
|
|
2525
|
+
for (let i = 0; i < raw.length; i++) {
|
|
2526
|
+
if (raw.charCodeAt(i) === 10 && ++lines > LONG_BLOCK_LINES) return true;
|
|
2527
|
+
}
|
|
2528
|
+
return false;
|
|
2529
|
+
}
|
|
2530
|
+
function TokChevron(props) {
|
|
2531
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2532
|
+
"svg",
|
|
2533
|
+
{
|
|
2534
|
+
className: props.open ? "rw-tok-chevron rw-tok-chevron-open" : "rw-tok-chevron",
|
|
2535
|
+
width: "10",
|
|
2536
|
+
height: "10",
|
|
2537
|
+
viewBox: "0 0 12 12",
|
|
2538
|
+
fill: "none",
|
|
2539
|
+
"aria-hidden": "true",
|
|
2540
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "M3 4.5L6 7.5L9 4.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
2541
|
+
}
|
|
2542
|
+
);
|
|
2543
|
+
}
|
|
2544
|
+
function CardTokBadge(props) {
|
|
2545
|
+
if (props.tokens === void 0 && !props.collapsible) return null;
|
|
2546
|
+
const text = props.tokens !== void 0 ? `${formatTokens(props.tokens)} tok` : props.expanded ? "\u6536\u8D77" : "\u5C55\u5F00";
|
|
2547
|
+
const title = props.collapsible ? `${props.tokens !== void 0 ? `${props.tokens.toLocaleString()} RWKV token \xB7 ` : ""}${props.expanded ? "\u70B9\u51FB\u6536\u8D77" : "\u70B9\u51FB\u5C55\u5F00\u5168\u90E8"}` : `${props.tokens?.toLocaleString()} RWKV token`;
|
|
2548
|
+
if (!props.collapsible) {
|
|
2549
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: props.floating ? "rw-card-tok rw-card-tok-float" : "rw-card-tok", title, children: text });
|
|
2550
|
+
}
|
|
2551
|
+
const cls = props.floating ? props.expanded ? "rw-card-tok rw-card-tok-btn rw-card-tok-sticky" : "rw-card-tok rw-card-tok-btn rw-card-tok-float" : "rw-card-tok rw-card-tok-btn";
|
|
2552
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
2553
|
+
"button",
|
|
2554
|
+
{
|
|
2555
|
+
type: "button",
|
|
2556
|
+
className: cls,
|
|
2557
|
+
"aria-expanded": props.expanded,
|
|
2558
|
+
title,
|
|
2559
|
+
onClick: (event) => {
|
|
2560
|
+
event.stopPropagation();
|
|
2561
|
+
props.onToggle?.();
|
|
2562
|
+
},
|
|
2563
|
+
children: [
|
|
2564
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: text }),
|
|
2565
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TokChevron, { open: props.expanded })
|
|
2566
|
+
]
|
|
2567
|
+
}
|
|
2568
|
+
);
|
|
2569
|
+
}
|
|
2570
|
+
var RWKV_LOGO_PIXELS = [
|
|
2571
|
+
[133.4, 310.04],
|
|
2572
|
+
[192.28, 310.04],
|
|
2573
|
+
[251.16, 310.04],
|
|
2574
|
+
[310.04, 310.04],
|
|
2575
|
+
[133.4, 368.92],
|
|
2576
|
+
[368.92, 368.92],
|
|
2577
|
+
[486.68, 368.92],
|
|
2578
|
+
[133.4, 427.8],
|
|
2579
|
+
[368.92, 427.8],
|
|
2580
|
+
[545.56, 427.8],
|
|
2581
|
+
[133.4, 486.68],
|
|
2582
|
+
[192.28, 486.68],
|
|
2583
|
+
[251.16, 486.68],
|
|
2584
|
+
[310.04, 486.68],
|
|
2585
|
+
[604.44, 486.68],
|
|
2586
|
+
[133.4, 545.56],
|
|
2587
|
+
[251.16, 545.56],
|
|
2588
|
+
[545.56, 545.56],
|
|
2589
|
+
[133.4, 604.44],
|
|
2590
|
+
[310.04, 604.44],
|
|
2591
|
+
[486.68, 604.44],
|
|
2592
|
+
[133.4, 663.32],
|
|
2593
|
+
[368.92, 663.32],
|
|
2594
|
+
[722.2, 663.32],
|
|
2595
|
+
[781.08, 663.32],
|
|
2596
|
+
[839.96, 663.32]
|
|
2597
|
+
];
|
|
2598
|
+
function RwkvWireIcon() {
|
|
2599
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("svg", { width: "22", height: "22", viewBox: "0 0 1024 1024", fill: "none", "aria-hidden": "true", children: [
|
|
2600
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("rect", { x: "40.96", y: "40.96", width: "942.08", height: "942.08", rx: "188.42", fill: "#18181B" }),
|
|
2601
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("g", { fill: "#FFFFFF", children: RWKV_LOGO_PIXELS.map(([x, y], index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("rect", { x, y, width: "54", height: "54", rx: "11" }, index)) })
|
|
2602
|
+
] });
|
|
2603
|
+
}
|
|
2604
|
+
function RwkvWirePanel(props) {
|
|
2605
|
+
const session = props.session ?? props.sessionId ?? "";
|
|
2606
|
+
const [snapshot, setSnapshot] = (0, import_react9.useState)();
|
|
2607
|
+
const [connected, setConnected] = (0, import_react9.useState)(false);
|
|
2608
|
+
const [mode, setMode] = (0, import_react9.useState)("model");
|
|
2609
|
+
const [prettyAll, setPrettyAll] = (0, import_react9.useState)(false);
|
|
2610
|
+
const [expandAll, setExpandAll] = (0, import_react9.useState)(false);
|
|
2611
|
+
const [autoScroll, setAutoScroll] = (0, import_react9.useState)(true);
|
|
2612
|
+
const [copied, setCopied] = (0, import_react9.useState)(false);
|
|
2613
|
+
const [expanded, setExpanded] = (0, import_react9.useState)({});
|
|
2614
|
+
const scrollRef = (0, import_react9.useRef)(null);
|
|
2615
|
+
(0, import_react9.useEffect)(() => {
|
|
2616
|
+
setSnapshot(void 0);
|
|
2617
|
+
setExpandAll(false);
|
|
2618
|
+
setExpanded({});
|
|
2619
|
+
if (!session) return;
|
|
2620
|
+
const url = `/api/rwkv/live/${encodeURIComponent(session)}`;
|
|
2621
|
+
const source = new EventSource(url);
|
|
2622
|
+
source.onopen = () => setConnected(true);
|
|
2623
|
+
source.onerror = () => setConnected(false);
|
|
2624
|
+
source.addEventListener("snapshot", (event) => {
|
|
2625
|
+
try {
|
|
2626
|
+
const next = JSON.parse(event.data);
|
|
2627
|
+
setSnapshot(next);
|
|
2628
|
+
} catch {
|
|
2629
|
+
}
|
|
2630
|
+
});
|
|
2631
|
+
source.addEventListener("delta", (event) => {
|
|
2632
|
+
try {
|
|
2633
|
+
const payload = JSON.parse(event.data);
|
|
2634
|
+
setSnapshot((current) => current === void 0 ? current : { ...current, streaming: true, output: current.output + payload.text });
|
|
2635
|
+
} catch {
|
|
2636
|
+
}
|
|
2637
|
+
});
|
|
2638
|
+
source.addEventListener("done", (event) => {
|
|
2639
|
+
try {
|
|
2640
|
+
const payload = JSON.parse(event.data);
|
|
2641
|
+
setSnapshot((current) => current === void 0 ? current : {
|
|
2642
|
+
...current,
|
|
2643
|
+
streaming: false,
|
|
2644
|
+
output: payload.output,
|
|
2645
|
+
outputTokens: payload.outputTokens,
|
|
2646
|
+
updatedAt: payload.updatedAt
|
|
2647
|
+
});
|
|
2648
|
+
} catch {
|
|
2649
|
+
}
|
|
2650
|
+
});
|
|
2651
|
+
return () => {
|
|
2652
|
+
source.close();
|
|
2653
|
+
setConnected(false);
|
|
2654
|
+
};
|
|
2655
|
+
}, [session]);
|
|
2656
|
+
const activePrompt = snapshot ? mode === "full" && snapshot.fullPrompt ? snapshot.fullPrompt : snapshot.prompt : "";
|
|
2657
|
+
const activeBlockTokens = snapshot ? mode === "full" && snapshot.fullBlockTokens ? snapshot.fullBlockTokens : snapshot.blockTokens : void 0;
|
|
2658
|
+
const fullWire = snapshot ? `${activePrompt}${snapshot.output}` : "";
|
|
2659
|
+
const blocks = (0, import_react9.useMemo)(() => parseWireBlocks(fullWire, mode, snapshot?.pastThinks), [fullWire, mode, snapshot?.pastThinks]);
|
|
2660
|
+
(0, import_react9.useEffect)(() => {
|
|
2661
|
+
if (!autoScroll) return;
|
|
2662
|
+
const el = scrollRef.current;
|
|
2663
|
+
if (el !== null) el.scrollTop = el.scrollHeight;
|
|
2664
|
+
}, [fullWire, autoScroll]);
|
|
2665
|
+
const onScroll = () => {
|
|
2666
|
+
const el = scrollRef.current;
|
|
2667
|
+
if (el === null) return;
|
|
2668
|
+
const nearBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 36;
|
|
2669
|
+
if (!nearBottom && autoScroll) setAutoScroll(false);
|
|
2670
|
+
else if (nearBottom && !autoScroll) setAutoScroll(true);
|
|
2671
|
+
};
|
|
2672
|
+
const copyRaw = () => {
|
|
2673
|
+
if (!fullWire) return;
|
|
2674
|
+
void navigator.clipboard?.writeText(fullWire).then(() => {
|
|
2675
|
+
setCopied(true);
|
|
2676
|
+
setTimeout(() => setCopied(false), 1500);
|
|
2677
|
+
});
|
|
2678
|
+
};
|
|
2679
|
+
const toggleCard = (key) => {
|
|
2680
|
+
if (window.getSelection()?.toString()) return;
|
|
2681
|
+
setExpanded((cur) => ({ ...cur, [key]: !(cur[key] ?? expandAll) }));
|
|
2682
|
+
};
|
|
2683
|
+
const toggleExpandAll = () => {
|
|
2684
|
+
setExpandAll((v) => !v);
|
|
2685
|
+
setExpanded({});
|
|
2686
|
+
};
|
|
2687
|
+
const tokens = snapshot?.promptTokens ?? 0;
|
|
2688
|
+
const tier = ctxTier(tokens);
|
|
2689
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "rw-root", children: [
|
|
2690
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "rw-toolbar", children: [
|
|
2691
|
+
tokens > 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
2692
|
+
"span",
|
|
2693
|
+
{
|
|
2694
|
+
className: `rl-ctx rl-ctx-${tier} rw-ctx-pill`,
|
|
2695
|
+
title: `${snapshot?.streaming ? "\u5B9E\u65F6\u751F\u6210\u4E2D" : "\u5DF2\u540C\u6B65"} \xB7 \u6A21\u578B\u5B9E\u65F6\u4E0A\u4E0B\u6587 ${tokens.toLocaleString()} RWKV token`,
|
|
2696
|
+
children: [
|
|
2697
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: snapshot?.streaming ? "rw-dot rw-dot-live" : connected ? "rw-dot rw-dot-idle" : "rw-dot" }),
|
|
2698
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: formatTokens(tokens) })
|
|
2699
|
+
]
|
|
2700
|
+
}
|
|
2701
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "rw-status", children: [
|
|
2702
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: connected ? "rw-dot rw-dot-idle" : "rw-dot" }),
|
|
2703
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: "\u7B49\u5F85\u8BF7\u6C42" })
|
|
2704
|
+
] }),
|
|
2705
|
+
snapshot?.fold ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
2706
|
+
"span",
|
|
2707
|
+
{
|
|
2708
|
+
className: "rl-cut",
|
|
2709
|
+
title: `${foldKindLabel(snapshot.fold.kind)}\uFF1A${snapshot.fold.beforeTokens.toLocaleString()} \u2192 ${snapshot.fold.afterTokens.toLocaleString()} tok`,
|
|
2710
|
+
children: [
|
|
2711
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("svg", { width: "11", height: "11", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", style: { marginRight: 3, verticalAlign: "-1.5px" }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "M4.5 2.5L7 5L9.5 2.5M4.5 11.5L7 9L9.5 11.5M2.5 7H11.5", stroke: "currentColor", strokeWidth: "1.35", strokeLinecap: "round", strokeLinejoin: "round" }) }),
|
|
2712
|
+
formatTokens(snapshot.fold.beforeTokens),
|
|
2713
|
+
"\u2192",
|
|
2714
|
+
formatTokens(snapshot.fold.afterTokens)
|
|
2715
|
+
]
|
|
2716
|
+
}
|
|
2717
|
+
) : null,
|
|
2718
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "rw-controls", children: [
|
|
2719
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "rw-mode-seg", role: "group", "aria-label": "\u4E0A\u4E0B\u6587\u89C6\u56FE\u6A21\u5F0F", children: [
|
|
2720
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: "rw-mode-btn", "aria-pressed": mode === "model", onClick: () => setMode("model"), title: "\u4E25\u683C\u663E\u793A\u5F53\u524D\u6A21\u578B\u5B9E\u9645\u770B\u5F97\u89C1\u7684\u5185\u5BB9\uFF08\u542B\u7A7A\u601D\u8003\u4E0E\u6298\u53E0\u5360\u4F4D\uFF09", children: "\u6A21\u578B\u5B9E\u65F6" }),
|
|
2721
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: "rw-mode-btn", "aria-pressed": mode === "full", onClick: () => setMode("full"), title: "\u5B8C\u6574\u56DE\u6EAF\u89C6\u89D2\uFF1A\u663E\u793A\u5168\u90E8\u5386\u53F2\u601D\u8003\u4E0E\u88AB\u6298\u53E0\u7684\u5DE5\u5177\u7ED3\u679C", children: "\u5168\u91CF\u5386\u53F2" })
|
|
2722
|
+
] }),
|
|
2723
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2724
|
+
"button",
|
|
2725
|
+
{
|
|
2726
|
+
type: "button",
|
|
2727
|
+
className: "rl-toggle",
|
|
2728
|
+
"aria-pressed": expandAll,
|
|
2729
|
+
title: expandAll ? "\u6536\u8D77\u5168\u90E8\u957F\u5361\u7247\u4E0E System" : "\u5C55\u5F00\u5168\u90E8\u957F\u5361\u7247\u4E0E System",
|
|
2730
|
+
onClick: toggleExpandAll,
|
|
2731
|
+
children: expandAll ? "\u6536\u8D77" : "\u5168\u5C55"
|
|
2732
|
+
}
|
|
2733
|
+
),
|
|
2734
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2735
|
+
"button",
|
|
2736
|
+
{
|
|
2737
|
+
type: "button",
|
|
2738
|
+
className: "rl-toggle",
|
|
2739
|
+
"aria-pressed": prettyAll,
|
|
2740
|
+
title: "\u5168\u5C40\u7F8E\u5316 System \u5DE5\u5177\u6A21\u677F\u4E0E\u5DE5\u5177\u8C03\u7528/\u7ED3\u679C JSON\uFF08\u9ED8\u8BA4\u663E\u793A\u539F\u59CB\u7D27\u51D1\u6587\u672C\uFF09",
|
|
2741
|
+
onClick: () => setPrettyAll((v) => !v),
|
|
2742
|
+
children: "\u7F8E\u5316"
|
|
2743
|
+
}
|
|
2744
|
+
),
|
|
2745
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: "rl-toggle", "aria-pressed": autoScroll, onClick: () => setAutoScroll((v) => !v), children: "\u8DDF\u5E95" }),
|
|
2746
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", className: "rl-toggle", disabled: !fullWire, onClick: copyRaw, children: copied ? "\u5DF2\u590D\u5236" : "\u590D\u5236" })
|
|
2747
|
+
] })
|
|
2748
|
+
] }),
|
|
2749
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "rw-legend", children: [
|
|
2750
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "rw-swatch rw-swatch-user", children: "User" }),
|
|
2751
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "rw-swatch rw-swatch-assistant", children: "Assistant" }),
|
|
2752
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "rw-swatch rw-swatch-think", children: "Think" }),
|
|
2753
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "rw-swatch rw-swatch-call", children: "Tool Call" }),
|
|
2754
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "rw-swatch rw-swatch-result", children: "Tool Result" }),
|
|
2755
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "rw-swatch rw-swatch-error", children: "Error" }),
|
|
2756
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "rw-swatch rw-swatch-folded", children: "Folded" })
|
|
2757
|
+
] }),
|
|
2758
|
+
!snapshot ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "rw-empty", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "rl-empty", children: "\u53D1\u4E00\u6761 RWKV \u6D88\u606F\u540E\uFF0C\u8FD9\u91CC\u4F1A\u5B9E\u65F6\u9010\u5B57\u5C55\u793A\u53D1\u7ED9\u6A21\u578B\u7684\u539F\u59CB\u5B57\u7B26\u7EA7\u4E0A\u4E0B\u6587\u3002" }) }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { ref: scrollRef, className: "rw-scroll", onScroll, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "rw-blocks", children: blocks.map((block, blockIdx) => {
|
|
2759
|
+
const key = `${mode}-${blockIdx}`;
|
|
2760
|
+
const isLast = blockIdx === blocks.length - 1;
|
|
2761
|
+
const isLiveTail = isLast && snapshot.streaming;
|
|
2762
|
+
const baseBlockTok = activeBlockTokens?.[blockIdx];
|
|
2763
|
+
const cardTokens = baseBlockTok === void 0 ? void 0 : isLast ? baseBlockTok + snapshot.outputTokens : baseBlockTok;
|
|
2764
|
+
if (block.role === "system") {
|
|
2765
|
+
const open = expanded[key] ?? expandAll;
|
|
2766
|
+
if (!open) {
|
|
2767
|
+
const firstLine = block.raw.split("\n")[0]?.slice(0, 72) ?? "System:";
|
|
2768
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
2769
|
+
"div",
|
|
2770
|
+
{
|
|
2771
|
+
className: "rw-card rw-card-system rw-system-collapsed",
|
|
2772
|
+
children: [
|
|
2773
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "rw-span-label", children: "System:" }),
|
|
2774
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "rw-system-preview", children: [
|
|
2775
|
+
firstLine.replace(/^System:\s*/, ""),
|
|
2776
|
+
"\u2026"
|
|
2777
|
+
] }),
|
|
2778
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CardTokBadge, { tokens: cardTokens, collapsible: true, expanded: false, onToggle: () => toggleCard(key) })
|
|
2779
|
+
]
|
|
2780
|
+
},
|
|
2781
|
+
key
|
|
2782
|
+
);
|
|
2783
|
+
}
|
|
2784
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "rw-card rw-card-system", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "rw-card-content", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "rw-card-body", children: [
|
|
2785
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CardTokBadge, { tokens: cardTokens, collapsible: true, expanded: true, floating: true, onToggle: () => toggleCard(key) }),
|
|
2786
|
+
block.spans.map((span, spanIdx) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: `rw-span rw-span-${span.kind}`, title: span.title, children: prettyAll ? prettySpanText(span, block.role) : span.text }, spanIdx))
|
|
2787
|
+
] }) }) }, key);
|
|
2788
|
+
}
|
|
2789
|
+
const renderedSpans = prettyAll ? block.spans.map((span) => ({ ...span, text: prettySpanText(span, block.role) })) : block.spans;
|
|
2790
|
+
const renderedText = prettyAll ? renderedSpans.map((s) => s.text).join("") : block.raw;
|
|
2791
|
+
const collapsible = !isLiveTail && isLongBlock(renderedText);
|
|
2792
|
+
const isCollapsed = collapsible && !(expanded[key] ?? expandAll);
|
|
2793
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: `rw-card rw-card-${block.cardKind}`, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "rw-card-content", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: isCollapsed ? "rw-card-body rw-card-hardcut" : "rw-card-body", children: [
|
|
2794
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2795
|
+
CardTokBadge,
|
|
2796
|
+
{
|
|
2797
|
+
tokens: cardTokens,
|
|
2798
|
+
collapsible,
|
|
2799
|
+
expanded: !isCollapsed,
|
|
2800
|
+
floating: true,
|
|
2801
|
+
onToggle: () => toggleCard(key)
|
|
2802
|
+
}
|
|
2803
|
+
),
|
|
2804
|
+
renderedSpans.map((span, spanIdx) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: `rw-span rw-span-${span.kind}`, title: span.title, children: span.text }, spanIdx)),
|
|
2805
|
+
isLiveTail ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "rw-cursor", "aria-hidden": "true", children: "\u258D" }) : null
|
|
2806
|
+
] }) }) }, key);
|
|
2807
|
+
}) }) })
|
|
2808
|
+
] });
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2811
|
+
// src/client/styles.ts
|
|
2812
|
+
var CSS = `
|
|
2813
|
+
.rwkv-section{display:flex;flex-direction:column;gap:12px;max-width:720px;color:var(--dsw-alias-label-primary)}
|
|
2814
|
+
.rwkv-title{margin:0;font-size:16px;line-height:24px;font-weight:500;color:var(--dsw-alias-label-primary)}
|
|
2815
|
+
.rwkv-intro{margin:0;font-size:14px;line-height:22px;color:var(--dsw-alias-label-tertiary)}
|
|
2816
|
+
.rwkv-subtitle{margin:20px 0 0;font-size:14px;line-height:22px;font-weight:500;color:var(--dsw-alias-label-primary)}
|
|
2817
|
+
.rwkv-rows{list-style:none;margin:12px 0 0;padding:0;display:flex;flex-direction:column;gap:8px}
|
|
2818
|
+
.rwkv-checks{display:flex;gap:20px;flex-wrap:wrap}
|
|
2819
|
+
.rwkv-block-head{display:flex;align-items:center;justify-content:space-between}
|
|
2820
|
+
.rwkv-plus{font-size:18px;line-height:1}
|
|
2821
|
+
textarea.rwkv-prose{font-family:inherit;font-size:14px;line-height:22px}
|
|
2822
|
+
.rwkv-card{border:.5px solid var(--dsw-alias-settings-card-stroke);background:var(--dsw-alias-settings-card-fill);border-radius:var(--dsw-radius-xl);padding:12px 14px;display:flex;flex-direction:column;gap:12px}
|
|
2823
|
+
.rwkv-head{display:flex;align-items:center;gap:10px;min-height:28px}
|
|
2824
|
+
.rwkv-identity{display:inline-flex;align-items:center;gap:6px;flex:none;max-width:60%}
|
|
2825
|
+
.rwkv-name{font-size:14px;line-height:22px;font-weight:500;color:var(--dsw-alias-label-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
2826
|
+
.rwkv-tag{flex:none;padding:1px 6px;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-xs);font-size:11px;line-height:16px;color:var(--dsw-alias-label-secondary)}
|
|
2827
|
+
.rwkv-dot{display:inline-block;flex:none;width:8px;height:8px;border-radius:50%;background:var(--dsw-alias-state-success-primary)}
|
|
2828
|
+
.rwkv-meta{flex:1 1 0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
|
|
2829
|
+
.rwkv-actions{display:inline-flex;align-items:center;gap:4px;margin-left:auto;flex:none}
|
|
2830
|
+
.rwkv-btn{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:4px;height:36px;padding:0 14px;border:none;border-radius:var(--dsw-radius-md);font:inherit;font-size:14px;line-height:22px;cursor:pointer}
|
|
2831
|
+
.rwkv-btn:disabled{opacity:.4;cursor:default}
|
|
2832
|
+
.rwkv-primary{background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground)}
|
|
2833
|
+
.rwkv-primary:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}
|
|
2834
|
+
.rwkv-secondary{border:.5px solid var(--dsw-alias-border-l3);background:transparent;color:var(--dsw-alias-label-primary)}
|
|
2835
|
+
.rwkv-secondary:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-solid)}
|
|
2836
|
+
.rwkv-small{height:28px;padding:0 10px;border-radius:var(--dsw-radius-sm);font-size:12px;line-height:18px}
|
|
2837
|
+
.rwkv-danger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary)}
|
|
2838
|
+
.rwkv-link{box-sizing:border-box;display:inline-flex;align-items:center;height:28px;padding:0 10px;border:none;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:12px;line-height:18px;cursor:pointer}
|
|
2839
|
+
.rwkv-link:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}
|
|
2840
|
+
.rwkv-editor{border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-module-platform);padding:14px 16px;display:flex;flex-direction:column;gap:14px}
|
|
2841
|
+
.rwkv-editor-head{display:flex;align-items:baseline;gap:8px}
|
|
2842
|
+
.rwkv-editor-title{font-size:14px;line-height:22px;font-weight:500;color:var(--dsw-alias-label-primary)}
|
|
2843
|
+
.rwkv-editor-sub{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
|
|
2844
|
+
.rwkv-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px 14px}
|
|
2845
|
+
.rwkv-grid3{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px 14px}
|
|
2846
|
+
.rwkv-field{display:flex;flex-direction:column;gap:6px;min-width:0}
|
|
2847
|
+
.rwkv-wide{grid-column:1/-1}
|
|
2848
|
+
.rwkv-label{display:inline-flex;align-items:center;gap:10px;font-size:12px;line-height:18px;font-weight:500;color:var(--dsw-alias-label-secondary)}
|
|
2849
|
+
.rwkv-hint{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
|
|
2850
|
+
.rwkv-error{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-state-error-primary)}
|
|
2851
|
+
.rwkv-saved{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-state-success-primary)}
|
|
2852
|
+
.rwkv-input{box-sizing:border-box;width:100%;height:32px;padding:0 10px;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);font:inherit;font-size:14px;line-height:22px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary)}
|
|
2853
|
+
.rwkv-input:focus{outline:none;border-color:var(--dsw-alias-state-business-primary)}
|
|
2854
|
+
.rwkv-input::placeholder{color:var(--dsw-alias-label-dimmed)}
|
|
2855
|
+
.rwkv-input:disabled{opacity:.6;cursor:default}
|
|
2856
|
+
textarea.rwkv-input{height:auto;min-height:64px;padding:6px 10px;resize:vertical;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;line-height:18px}
|
|
2857
|
+
.rwkv-combo{position:relative;width:100%}
|
|
2858
|
+
.rwkv-combo-input{padding-right:30px}
|
|
2859
|
+
.rwkv-combo-toggle{position:absolute;top:0;right:0;bottom:0;width:30px;display:inline-flex;align-items:center;justify-content:center;padding:0;border:none;background:transparent;color:var(--dsw-alias-label-secondary);cursor:pointer;border-radius:0 var(--dsw-radius-md) var(--dsw-radius-md) 0}
|
|
2860
|
+
.rwkv-combo-toggle:hover{color:var(--dsw-alias-label-primary)}
|
|
2861
|
+
.rwkv-select-trigger{display:flex;align-items:center;justify-content:space-between;gap:8px;cursor:pointer;text-align:left}
|
|
2862
|
+
.rwkv-select-value{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
2863
|
+
.rwkv-menu-chevron{flex:none;color:var(--dsw-alias-label-secondary);transition:transform 140ms ease}
|
|
2864
|
+
.rwkv-menu-chevron-open{transform:rotate(180deg)}
|
|
2865
|
+
.rwkv-menu{position:absolute;top:calc(100% + 4px);left:0;z-index:100;box-sizing:border-box;min-width:100%;width:max-content;max-width:min(440px,calc(100vw - 32px));max-height:240px;overflow-y:auto;padding:4px;display:flex;flex-direction:column;gap:0;border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-lg);background:var(--dsw-menu-surface-fill,var(--dsw-alias-bg-layer-1));backdrop-filter:var(--dsw-menu-backdrop-filter,none);box-shadow:var(--dsw-elevation-prominent,0 8px 24px rgba(0,0,0,.12));--dsw-elevation-stroke-color:var(--dsw-alias-border-l1)}
|
|
2866
|
+
.rwkv-menu-end{left:auto;right:0}
|
|
2867
|
+
.rwkv-menu-item{box-sizing:border-box;display:flex;align-items:center;gap:8px;width:100%;min-height:34px;padding:6px 8px;border:none;border-radius:var(--dsw-radius-md);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:20px;text-align:left;cursor:pointer}
|
|
2868
|
+
.rwkv-menu-item:hover,.rwkv-menu-item[data-active=true]{background:var(--dsw-alias-interactive-bg-hover)}
|
|
2869
|
+
.rwkv-menu-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
2870
|
+
.rwkv-menu-check{flex:none;width:14px;height:14px;color:var(--dsw-alias-label-primary)}
|
|
2871
|
+
.rwkv-check{display:inline-flex;align-items:center;gap:8px;font-size:14px;line-height:22px;color:var(--dsw-alias-label-primary);cursor:pointer}
|
|
2872
|
+
.rwkv-check input{width:14px;height:14px;margin:0;accent-color:var(--dsw-alias-button-primary-fill)}
|
|
2873
|
+
.rwkv-details{border-top:.5px solid var(--dsw-alias-border-l2);padding-top:10px}
|
|
2874
|
+
.rwkv-summary{display:flex;align-items:center;gap:6px;width:fit-content;padding:2px 4px;margin-left:-4px;border-radius:var(--dsw-radius-sm);cursor:pointer;font-size:12px;line-height:18px;font-weight:500;color:var(--dsw-alias-label-secondary);list-style:none}
|
|
2875
|
+
.rwkv-summary::-webkit-details-marker{display:none}
|
|
2876
|
+
.rwkv-summary::before{content:'';width:5px;height:5px;border-right:1.5px solid currentcolor;border-bottom:1.5px solid currentcolor;transform:rotate(-45deg) translate(-1px,-1px);transition:transform 120ms ease}
|
|
2877
|
+
.rwkv-details[open]>.rwkv-summary::before{transform:rotate(45deg) translate(-1px,-1px)}
|
|
2878
|
+
.rwkv-summary:hover{color:var(--dsw-alias-label-primary)}
|
|
2879
|
+
.rwkv-details-body{display:flex;flex-direction:column;gap:12px;padding-top:12px}
|
|
2880
|
+
.rwkv-block{display:flex;flex-direction:column;gap:12px;padding-top:12px;border-top:.5px solid var(--dsw-alias-border-l2)}
|
|
2881
|
+
.rwkv-block-title{font-size:12px;line-height:18px;font-weight:500;color:var(--dsw-alias-label-secondary)}
|
|
2882
|
+
.rwkv-editor-actions{display:flex;justify-content:flex-end;align-items:center;gap:8px}
|
|
2883
|
+
.rwkv-editor-actions .rwkv-error,.rwkv-editor-actions .rwkv-saved{margin-right:auto}
|
|
2884
|
+
.rwkv-add{box-sizing:border-box;width:100%;display:flex;align-items:center;justify-content:center;gap:6px;height:56px;border:1px dashed var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-xl);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:14px;cursor:pointer}
|
|
2885
|
+
.rwkv-add:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
2886
|
+
.rwkv-add:disabled{opacity:.4;cursor:default}
|
|
2887
|
+
.rwkv-segment{display:inline-flex;flex-wrap:wrap;padding:2px;gap:2px;border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1);border:.5px solid var(--dsw-alias-border-l4);width:fit-content}
|
|
2888
|
+
.rwkv-segment button{height:26px;padding:0 10px;border:none;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;cursor:pointer}
|
|
2889
|
+
.rwkv-segment button[aria-pressed=true]{background:var(--dsw-alias-settings-card-fill);color:var(--dsw-alias-label-primary);box-shadow:0 0 0 .5px var(--dsw-alias-border-l3)}
|
|
2890
|
+
.rwkv-list{display:flex;flex-direction:column;gap:4px}
|
|
2891
|
+
.rwkv-option{box-sizing:border-box;display:flex;align-items:center;gap:8px;min-height:36px;padding:0 6px 0 10px;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;text-align:left}
|
|
2892
|
+
button.rwkv-option{cursor:pointer;padding-right:10px}
|
|
2893
|
+
.rwkv-option[aria-pressed=true]{border-color:var(--dsw-alias-state-business-primary)}
|
|
2894
|
+
.rwkv-option-main{display:flex;align-items:center;gap:8px;flex:1;min-width:0;height:34px;padding:0;border:none;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}
|
|
2895
|
+
.rwkv-option-main:disabled,button.rwkv-option:disabled{cursor:default}
|
|
2896
|
+
.rwkv-option-name{font-size:14px;line-height:22px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
2897
|
+
.rwkv-option-meta{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
|
|
2898
|
+
.rwkv-option-state{margin-left:auto;flex:none;font-size:12px;line-height:18px;color:var(--dsw-alias-state-business-primary)}
|
|
2899
|
+
.rwkv-upload{display:flex;flex-direction:column;gap:6px;padding-top:4px}
|
|
2900
|
+
.rwkv-upload-row{display:flex;align-items:center;gap:8px}
|
|
2901
|
+
@container (max-width:560px){.rwkv-grid,.rwkv-grid3{grid-template-columns:minmax(0,1fr)}}
|
|
2902
|
+
.rwkv-developer-head{width:100%;padding:0;border:none;background:transparent;font:inherit;color:inherit;text-align:left;cursor:pointer}
|
|
2903
|
+
.rwkv-chevron{flex:none;width:5px;height:5px;margin:0 2px;border-right:1.5px solid var(--dsw-alias-label-secondary);border-bottom:1.5px solid var(--dsw-alias-label-secondary);transform:rotate(-45deg) translate(-1px,-1px);transition:transform 120ms ease}
|
|
2904
|
+
.rwkv-developer-head[aria-expanded=true] .rwkv-chevron{transform:rotate(45deg) translate(-1px,-1px)}
|
|
2905
|
+
.rwkv-developer-body{display:flex;flex-direction:column;gap:12px;padding-top:12px;border-top:.5px solid var(--dsw-alias-border-l2)}
|
|
2906
|
+
.rwkv-toggle{align-items:flex-start}
|
|
2907
|
+
.rwkv-toggle input{margin-top:4px}
|
|
2908
|
+
.rwkv-toggle-hint{display:block}
|
|
2909
|
+
.rwkv-dir{display:flex;gap:8px;align-items:center}
|
|
2910
|
+
.rwkv-dir .rwkv-btn{flex:none;white-space:nowrap}
|
|
2911
|
+
.rwkv-session-meta{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
|
|
2912
|
+
.rwkv-block-head .rwkv-actions .rwkv-btn{white-space:nowrap}
|
|
2913
|
+
.rwkv-actions{display:inline-flex;gap:6px;align-items:center}
|
|
2914
|
+
.rwkv-stats{display:flex;flex-direction:column;gap:8px;padding:10px 12px;border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-module-platform)}
|
|
2915
|
+
.rwkv-stats-head{display:flex;flex-wrap:wrap;gap:6px 16px;align-items:baseline}
|
|
2916
|
+
.rwkv-stat{font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary)}
|
|
2917
|
+
.rwkv-stat b{font-size:16px;margin-right:4px;color:var(--dsw-alias-label-primary)}
|
|
2918
|
+
.rwkv-counts{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
|
|
2919
|
+
.rwkv-count{display:inline-flex;gap:4px;align-items:baseline;padding:1px 8px;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm);font-size:12px;line-height:18px}
|
|
2920
|
+
.rwkv-session-toggle{cursor:pointer}
|
|
2921
|
+
.rwkv-sessions{list-style:none;margin:0;padding:0 2px 0 0;display:flex;flex-direction:column;gap:6px;max-height:440px;overflow-y:auto}
|
|
2922
|
+
.rwkv-session{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-lg);padding:6px 10px}
|
|
2923
|
+
.rwkv-session-head{display:flex;gap:8px;align-items:center}
|
|
2924
|
+
.rwkv-session-title{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0;border:none;background:transparent;padding:0;text-align:left;font:inherit;color:inherit;cursor:pointer}
|
|
2925
|
+
.rwkv-session-task{font-size:13px;line-height:20px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
2926
|
+
.rwkv-session-body{display:flex;flex-direction:column;gap:8px;padding:8px 0 4px}
|
|
2927
|
+
.rwkv-session-body .rl-ledger{height:340px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md)}
|
|
2928
|
+
/* RWKV trace ledger, after DSH's Trajectory view (ui-trajectory TrajectoryTable / Toolbar). */
|
|
2929
|
+
.rl-root{isolation:isolate;display:flex;flex-direction:column;height:100%;min-height:0;width:100%;box-sizing:border-box;overflow:hidden;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1)}
|
|
2930
|
+
.rl-toolbar{flex:none;display:flex;flex-wrap:wrap;align-items:center;gap:4px 8px;box-sizing:border-box;min-height:32px;padding:4px 6px;border-bottom:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1)}
|
|
2931
|
+
.rl-toggles{display:flex;flex-wrap:wrap;align-items:center;gap:2px}
|
|
2932
|
+
.rl-toggle{display:inline-flex;align-items:center;height:20px;padding:0 7px;gap:4px;border:0;border-radius:var(--dsw-radius-sm);color:var(--dsw-alias-label-tertiary);background:transparent;cursor:pointer;font:var(--dsw-font-xxs-12)}
|
|
2933
|
+
.rl-toggle:hover,.rl-toggle[aria-pressed=true]{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}
|
|
2934
|
+
.rl-summary{margin-left:auto;padding-right:4px;font:var(--dsw-font-xxs-12);color:var(--dsw-alias-label-tertiary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
2935
|
+
.rl-notice{flex:none;margin:0;padding:6px 12px;font:var(--dsw-font-xxs-12);color:var(--dsw-alias-label-tertiary);border-bottom:.5px solid var(--dsw-alias-border-l1)}
|
|
2936
|
+
.rl-ledger{position:relative;flex:1;min-height:0;overflow:hidden;display:flex}
|
|
2937
|
+
.rl-root .rl-ledger{--rl-bottom:calc(var(--dsh-composer-height,152px) + 16px)}
|
|
2938
|
+
.rl-scroll{flex:1;min-width:0;overflow-y:auto;overflow-x:hidden;padding-bottom:var(--rl-bottom,0px)}
|
|
2939
|
+
.rl-table{width:100%;table-layout:fixed;border-spacing:0;color:var(--dsw-alias-label-primary);font:var(--dsw-font-xxs-12)}
|
|
2940
|
+
.rl-event-col{width:96px}
|
|
2941
|
+
.rl-ctx-col{width:64px}
|
|
2942
|
+
.rl-ctx-cell{text-align:right;padding-left:4px!important;padding-right:10px!important}
|
|
2943
|
+
.rl-ctx{display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;min-width:42px;height:19px;padding:0 6px;border-radius:999px;font:600 10px/16px var(--ds-font-family-code,ui-monospace,monospace);white-space:nowrap}
|
|
2944
|
+
.rl-ctx-green{color:var(--dsw-alias-state-success-primary,#15803d);background:color-mix(in srgb,var(--dsw-alias-state-success-primary,#22c55e) 14%,var(--dsw-alias-bg-layer-1))}
|
|
2945
|
+
.rl-ctx-blue{color:var(--dsw-alias-state-business-primary,#1d4ed8);background:color-mix(in srgb,var(--dsw-alias-state-business-primary,#3b82f6) 14%,var(--dsw-alias-bg-layer-1))}
|
|
2946
|
+
.rl-ctx-yellow{color:var(--dsw-alias-state-warn-label,#b45309);background:var(--dsw-alias-state-warn-tertiary,color-mix(in srgb,#f59e0b 18%,var(--dsw-alias-bg-layer-1)))}
|
|
2947
|
+
.rl-ctx-red{color:var(--dsw-alias-state-error-primary,#dc2626);background:color-mix(in srgb,var(--dsw-alias-state-error-primary,#dc2626) 14%,var(--dsw-alias-bg-layer-1))}
|
|
2948
|
+
.rl-fold-row td{height:26px;background:color-mix(in srgb,var(--dsw-alias-state-business-primary,#3b82f6) 5%,var(--dsw-alias-bg-layer-1));border-bottom:.5px dashed var(--dsw-alias-border-l2)}
|
|
2949
|
+
.rl-rail-fold{background:color-mix(in srgb,var(--dsw-alias-state-business-primary,#3b82f6) 55%,var(--dsw-alias-bg-layer-1))}
|
|
2950
|
+
.rl-tone-fold{color:var(--dsw-alias-state-business-primary,#1d4ed8);background:color-mix(in srgb,var(--dsw-alias-state-business-primary,#3b82f6) 14%,var(--dsw-alias-bg-layer-1))}
|
|
2951
|
+
.rl-fold-text{font-size:12px;line-height:18px}
|
|
2952
|
+
.rl-fold-icon{flex:none;color:var(--dsw-alias-state-business-primary,#1d4ed8)}
|
|
2953
|
+
.rl-fold-badge{font-weight:500;color:var(--dsw-alias-label-secondary);white-space:nowrap}
|
|
2954
|
+
.rl-fold-range{font:500 11px/16px var(--ds-font-family-code,ui-monospace,monospace);color:var(--dsw-alias-label-primary);white-space:nowrap}
|
|
2955
|
+
.rwkv-chat-fold{display:flex;align-items:center;gap:6px;margin:4px 0;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary);user-select:none}
|
|
2956
|
+
.rwkv-chat-fold-icon{flex:none;color:var(--dsw-alias-label-tertiary)}
|
|
2957
|
+
.rwkv-chat-fold-label{flex:none;color:var(--dsw-alias-label-tertiary)}
|
|
2958
|
+
.rwkv-chat-fold-sep{flex:none;color:var(--dsw-alias-label-dimmed,var(--dsw-alias-label-tertiary))}
|
|
2959
|
+
.rwkv-chat-fold-detail{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-tertiary)}
|
|
2960
|
+
.rl-table td{box-sizing:border-box;height:30px;padding:0 8px;overflow:hidden;border-bottom:.5px solid var(--dsw-alias-border-l1);white-space:nowrap;text-overflow:ellipsis}
|
|
2961
|
+
.rl-table tr{outline:none;transition:background-color 120ms}
|
|
2962
|
+
.rl-table tr:not(.rl-step-row){cursor:pointer}
|
|
2963
|
+
.rl-table tr:not(.rl-step-row):hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
2964
|
+
.rl-table tr[data-selected=true]{background:var(--dsw-alias-interactive-bg-active)}
|
|
2965
|
+
.rl-table tr:focus-visible{box-shadow:inset 0 0 0 1px var(--dsw-alias-state-business-primary)}
|
|
2966
|
+
.rl-table tr[data-turn-start=true]:not(:first-child) td{border-top:1.5px solid var(--dsw-alias-border-l1)}
|
|
2967
|
+
.rl-event{position:relative;overflow:visible!important;padding-left:36px!important;padding-right:4px!important;text-align:right}
|
|
2968
|
+
.rl-rail{position:absolute;left:0;top:-1px;bottom:-1px;width:2px;background:color-mix(in srgb,var(--dsw-static-blue-500,#3b82f6) 22%,var(--dsw-alias-bg-layer-1))}
|
|
2969
|
+
.rl-rail-touched{background:color-mix(in srgb,var(--dsw-alias-state-warn-label,#d9822b) 45%,var(--dsw-alias-bg-layer-1))}
|
|
2970
|
+
.rl-rail-error{background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 45%,var(--dsw-alias-bg-layer-1))}
|
|
2971
|
+
.rl-turn-label{position:absolute;top:0;left:0;padding:1px 5px;border-radius:0 0 2px;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-module-platform);font:8px/10px var(--ds-font-family-code,ui-monospace,monospace);white-space:nowrap}
|
|
2972
|
+
.rl-tag{display:inline-flex;align-items:center;box-sizing:border-box;height:19px;padding:0 5px;border-radius:var(--dsw-radius-xs);font-size:10px;line-height:16px;font-weight:650;letter-spacing:.035em;white-space:nowrap}
|
|
2973
|
+
.rl-tone-clean{color:color-mix(in srgb,var(--dsw-alias-brand-primary-new-colorprimary-new-color) 60%,var(--dsw-alias-state-error-secondary));background:color-mix(in srgb,color-mix(in srgb,var(--dsw-alias-brand-primary-new-colorprimary-new-color) 55%,var(--dsw-alias-state-error-secondary)) 15%,var(--dsw-alias-bg-layer-1))}
|
|
2974
|
+
.rl-tone-touched{color:var(--dsw-alias-state-warn-label);background:var(--dsw-alias-state-warn-tertiary)}
|
|
2975
|
+
.rl-tone-error{color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 12%,var(--dsw-alias-bg-layer-1))}
|
|
2976
|
+
.rl-tone-neutral{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-module-platform)}
|
|
2977
|
+
.rl-content{padding-left:4px!important}
|
|
2978
|
+
.rl-content-inner{display:flex;align-items:center;gap:6px;min-width:0}
|
|
2979
|
+
.rl-text{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
2980
|
+
.rl-dim{color:var(--dsw-alias-label-tertiary)}
|
|
2981
|
+
.rl-call-name{color:var(--dsw-alias-label-primary);font:400 12px/18px Menlo,Consolas,'Liberation Mono','PingFang SC',monospace}
|
|
2982
|
+
.rl-call-payload{margin-left:7px;color:var(--dsw-alias-label-secondary);font:400 12px/18px var(--ds-font-family-code,ui-monospace,monospace)}
|
|
2983
|
+
.rl-chips{display:inline-flex;flex-wrap:wrap;gap:4px}
|
|
2984
|
+
.rl-chip{flex:none;padding:0 5px;border-radius:var(--dsw-radius-xs);font-size:10px;line-height:16px;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-module-platform);white-space:nowrap}
|
|
2985
|
+
.rl-chip-warn{color:var(--dsw-alias-state-warn-label);background:var(--dsw-alias-state-warn-tertiary)}
|
|
2986
|
+
.rl-cut{flex:none;padding:0 5px;border-radius:var(--dsw-radius-xs);font-size:10px;line-height:16px;color:var(--dsw-alias-brand-primary-new-colorprimary-new-color);background:color-mix(in srgb,var(--dsw-alias-brand-primary-new-colorprimary-new-color) 10%,var(--dsw-alias-bg-module-platform))}
|
|
2987
|
+
.rl-chip-muted{color:var(--dsw-alias-label-tertiary)}
|
|
2988
|
+
.rl-step-row td{height:22px;border-bottom:.5px dashed var(--dsw-alias-border-l1)}
|
|
2989
|
+
.rl-step{display:flex;align-items:center;gap:6px;min-width:0;overflow:hidden;color:var(--dsw-alias-label-tertiary);font-size:11px}
|
|
2990
|
+
.rl-step-arrow{flex:none;color:var(--dsw-alias-label-tertiary)}
|
|
2991
|
+
.rl-change{flex:none;padding:0 4px;border-radius:var(--dsw-radius-xs);font:10px/15px var(--ds-font-family-code,ui-monospace,monospace);color:var(--dsw-alias-state-warn-label);background:var(--dsw-alias-state-warn-tertiary);cursor:default}
|
|
2992
|
+
.rl-step-note{flex:none}
|
|
2993
|
+
.rl-change-list{display:flex;flex-direction:column;gap:2px;font:11px/16px var(--ds-font-family-code,ui-monospace,monospace)}
|
|
2994
|
+
.rl-step code,.rl-kv code{font:11px/16px var(--ds-font-family-code,ui-monospace,monospace);color:var(--dsw-alias-label-secondary)}
|
|
2995
|
+
.rl-empty{margin:0;padding:16px;font:var(--dsw-font-xxs-12);color:var(--dsw-alias-label-tertiary)}
|
|
2996
|
+
.rl-inspector{position:absolute;top:0;right:0;bottom:0;z-index:5;width:min(560px,72%);display:flex;flex-direction:column;box-sizing:border-box;padding-bottom:var(--rl-bottom,0px);border-left:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-layer-1));box-shadow:var(--dsw-elevation-panel,-8px 0 24px rgba(0,0,0,.06))}
|
|
2997
|
+
.rl-inspector-head{flex:none;display:flex;align-items:center;gap:10px;padding:10px 12px 8px 16px}
|
|
2998
|
+
.rl-inspector-title{flex:1;min-width:0;font:var(--dsw-font-xs-13);color:var(--dsw-alias-label-tertiary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
2999
|
+
.rl-icon{width:24px;height:24px;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-secondary);font-size:18px;line-height:1;cursor:pointer}
|
|
3000
|
+
.rl-icon:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
3001
|
+
.rl-tabs{flex:none;display:flex;gap:16px;padding:0 16px;border-bottom:.5px solid var(--dsw-alias-border-l2)}
|
|
3002
|
+
.rl-tabs button{height:32px;padding:0;border:0;border-bottom:2px solid transparent;background:transparent;color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xs-13);cursor:pointer}
|
|
3003
|
+
.rl-tabs button[aria-selected=true]{color:var(--dsw-alias-state-business-primary);border-bottom-color:var(--dsw-alias-state-business-primary)}
|
|
3004
|
+
.rl-inspector-body{flex:1;min-height:0;overflow:auto;padding:12px 16px;display:flex;flex-direction:column;gap:10px}
|
|
3005
|
+
.rl-kv{display:grid;grid-template-columns:96px minmax(0,1fr);gap:6px 12px;font:var(--dsw-font-xs-13)}
|
|
3006
|
+
.rl-kv-key{color:var(--dsw-alias-label-tertiary)}
|
|
3007
|
+
.rl-kv-value{min-width:0;overflow-wrap:anywhere}
|
|
3008
|
+
.rl-section-title{font:var(--dsw-font-xs-13);color:var(--dsw-alias-label-secondary);font-weight:500}
|
|
3009
|
+
.rl-prose{font:var(--dsw-font-xs-13);line-height:20px;color:var(--dsw-alias-label-secondary);white-space:pre-wrap}
|
|
3010
|
+
.rl-pre{margin:0;padding:8px 10px;border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-module-platform);font:12px/18px var(--ds-font-family-code,ui-monospace,monospace);white-space:pre-wrap;word-break:break-word}
|
|
3011
|
+
.rl-pre-full{flex:1}
|
|
3012
|
+
/* Right-sidebar live character-level RWKV wire viewer. */
|
|
3013
|
+
.rw-root{--rw-bg-page:#FFFFFF;--rw-text-primary:#18181B;--rw-text-muted:#71717A;--rw-user-bg:#F4F7FB;--rw-user-border:#D8E3F2;--rw-user-footer:#E8EFF9;--rw-user-accent:#2563EB;--rw-assistant-bg:#FAFAFC;--rw-assistant-border:#E4E4E9;--rw-assistant-footer:#F0F0F5;--rw-assistant-accent:#6D28D9;--rw-think-bg:#FFFBEB;--rw-think-border:#F5DFB0;--rw-think-footer:#FEF3C7;--rw-think-accent:#B45309;--rw-call-bg:#F0FAFC;--rw-call-border:#BEE7F0;--rw-call-footer:#E0F4F8;--rw-call-accent:#0E7490;--rw-resp-bg:#F2FBF6;--rw-resp-border:#C3E8D5;--rw-resp-footer:#E3F5EC;--rw-resp-accent:#047857;--rw-err-bg:#FFF5F5;--rw-err-border:#F8CACA;--rw-err-footer:#FDE8E8;--rw-err-accent:#BE123C;display:flex;flex-direction:column;height:100%;min-height:0;width:100%;box-sizing:border-box;background:var(--rw-bg-page);color:var(--rw-text-primary)}
|
|
3014
|
+
.rw-toolbar{flex:none;display:flex;flex-wrap:wrap;align-items:center;gap:6px 8px;padding:6px 10px;border-bottom:.5px solid var(--dsw-alias-border-l2);background:var(--rw-bg-page)}
|
|
3015
|
+
.rw-status{display:inline-flex;align-items:center;gap:6px;font-size:12px;line-height:18px;color:var(--rw-text-muted)}
|
|
3016
|
+
.rw-ctx-pill{gap:5px;padding:0 7px}
|
|
3017
|
+
.rw-dot{width:6px;height:6px;border-radius:50%;flex:none;background:var(--dsw-alias-label-dimmed,#9ca3af)}
|
|
3018
|
+
.rw-dot-idle{background:currentColor}
|
|
3019
|
+
.rw-dot-live{background:currentColor;box-shadow:0 0 0 3px color-mix(in srgb,currentColor 25%,transparent);animation:rw-pulse 1.2s ease-in-out infinite}
|
|
3020
|
+
@keyframes rw-pulse{0%,100%{opacity:1}50%{opacity:.45}}
|
|
3021
|
+
.rw-controls{display:inline-flex;align-items:center;gap:4px;margin-left:auto;flex-wrap:wrap}
|
|
3022
|
+
.rw-mode-seg{display:inline-flex;align-items:center;padding:1px;gap:1px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);background:var(--rw-assistant-footer)}
|
|
3023
|
+
.rw-mode-btn{height:18px;padding:0 6px;border:0;border-radius:calc(var(--dsw-radius-sm) - 1px);background:transparent;color:var(--rw-text-muted);font:var(--dsw-font-xxs-12);font-size:11px;cursor:pointer;white-space:nowrap}
|
|
3024
|
+
.rw-mode-btn:hover{color:var(--rw-text-primary)}
|
|
3025
|
+
.rw-mode-btn[aria-pressed=true]{background:var(--rw-bg-page);color:var(--rw-text-primary);box-shadow:0 1px 2px rgba(0,0,0,.06)}
|
|
3026
|
+
.rw-legend{flex:none;display:flex;flex-wrap:wrap;align-items:center;gap:4px 12px;padding:5px 12px;border-bottom:.5px solid var(--dsw-alias-border-l1);background:var(--rw-bg-page)}
|
|
3027
|
+
.rw-swatch{display:inline-flex;align-items:center;gap:5px;font:500 11px/16px var(--ds-font-family-code,ui-monospace,monospace);color:var(--rw-text-muted)}
|
|
3028
|
+
.rw-swatch::before{content:'';width:6px;height:6px;border-radius:50%;flex:none;background:var(--rw-dot-color,var(--rw-text-muted))}
|
|
3029
|
+
.rw-swatch-user{--rw-dot-color:var(--rw-user-accent)}
|
|
3030
|
+
.rw-swatch-assistant{--rw-dot-color:var(--rw-assistant-accent)}
|
|
3031
|
+
.rw-swatch-think{--rw-dot-color:var(--rw-think-accent)}
|
|
3032
|
+
.rw-swatch-call{--rw-dot-color:var(--rw-call-accent)}
|
|
3033
|
+
.rw-swatch-result{--rw-dot-color:var(--rw-resp-accent)}
|
|
3034
|
+
.rw-swatch-error{--rw-dot-color:var(--rw-err-accent)}
|
|
3035
|
+
.rw-swatch-folded{--rw-dot-color:var(--rw-text-muted)}
|
|
3036
|
+
.rw-empty{flex:1;display:flex;align-items:center;justify-content:center;padding:16px;background:var(--rw-bg-page)}
|
|
3037
|
+
.rw-scroll{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;scrollbar-gutter:stable;padding:10px 12px 24px;background:var(--rw-bg-page)}
|
|
3038
|
+
.rw-blocks{display:flex;flex-direction:column;gap:10px;font:12px/1.6 var(--ds-font-family-code,ui-monospace,SFMono-Regular,Menlo,monospace);color:var(--rw-text-primary)}
|
|
3039
|
+
.rw-card{position:relative;box-sizing:border-box;width:100%;overflow:clip;border-radius:var(--dsw-radius-md);border:1px solid var(--rw-assistant-border);background:var(--rw-assistant-bg);transition:border-color 120ms ease}
|
|
3040
|
+
.rw-card-content{padding:9px 11px}
|
|
3041
|
+
.rw-card-system{--rw-card-footer:var(--rw-assistant-footer);--rw-card-border:var(--rw-assistant-border);--rw-card-accent:var(--rw-text-muted);background:var(--rw-assistant-bg);border-color:var(--rw-assistant-border)}
|
|
3042
|
+
.rw-system-collapsed{display:flex;align-items:center;gap:6px;padding:9px 11px;color:var(--rw-text-muted)}
|
|
3043
|
+
.rw-system-preview{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1}
|
|
3044
|
+
.rw-card-user{--rw-card-footer:var(--rw-user-footer);--rw-card-border:var(--rw-user-border);--rw-card-accent:var(--rw-user-accent);background:var(--rw-user-bg);border-color:var(--rw-user-border)}
|
|
3045
|
+
.rw-card-assistant{--rw-card-footer:var(--rw-assistant-footer);--rw-card-border:var(--rw-assistant-border);--rw-card-accent:var(--rw-assistant-accent);background:var(--rw-assistant-bg);border-color:var(--rw-assistant-border)}
|
|
3046
|
+
.rw-card-tool{--rw-card-footer:var(--rw-resp-footer);--rw-card-border:var(--rw-resp-border);--rw-card-accent:var(--rw-resp-accent);background:var(--rw-resp-bg);border-color:var(--rw-resp-border)}
|
|
3047
|
+
.rw-card-error{--rw-card-footer:var(--rw-err-footer);--rw-card-border:var(--rw-err-border);--rw-card-accent:var(--rw-err-accent);background:var(--rw-err-bg);border-color:var(--rw-err-border)}
|
|
3048
|
+
.rw-card-folded{--rw-card-footer:var(--rw-assistant-footer);--rw-card-border:var(--rw-assistant-border);--rw-card-accent:var(--rw-text-muted);background:var(--rw-assistant-bg);border:1px dashed var(--rw-assistant-border)}
|
|
3049
|
+
.rw-card-other{--rw-card-footer:var(--rw-assistant-footer);--rw-card-border:var(--rw-assistant-border);--rw-card-accent:var(--rw-text-muted);background:var(--rw-assistant-bg)}
|
|
3050
|
+
.rw-card-body{white-space:pre-wrap;word-break:break-word}
|
|
3051
|
+
.rw-card-tok{flex:none;display:inline-flex;align-items:center;gap:3px;padding:2px 6px;border:none;border-radius:var(--dsw-radius-xs);background:var(--rw-card-footer,var(--rw-assistant-footer));color:var(--rw-card-accent,var(--rw-text-muted));font:500 10px/14px var(--ds-font-family-code,ui-monospace,monospace);white-space:nowrap;user-select:none}
|
|
3052
|
+
.rw-card-tok-btn{cursor:pointer;background:color-mix(in srgb,var(--rw-card-footer,var(--rw-assistant-footer)) 78%,transparent);border:.5px solid color-mix(in srgb,var(--rw-card-border,var(--rw-assistant-border)) 85%,transparent);backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);transition:background-color 120ms ease,border-color 120ms ease}
|
|
3053
|
+
.rw-card-tok-btn:hover{background:var(--rw-card-footer,var(--rw-assistant-footer));border-color:color-mix(in srgb,var(--rw-card-accent,var(--rw-text-muted)) 40%,var(--rw-card-border,var(--rw-assistant-border)))}
|
|
3054
|
+
.rw-card-tok-float{float:right;margin:0 0 4px 10px}
|
|
3055
|
+
.rw-card-tok-sticky{position:sticky;top:8px;z-index:2;float:right;margin:0 0 4px 10px;box-shadow:0 1px 4px rgba(0,0,0,.06)}
|
|
3056
|
+
.rw-tok-chevron{flex:none;transition:transform 140ms ease}
|
|
3057
|
+
.rw-tok-chevron-open{transform:rotate(180deg)}
|
|
3058
|
+
.rw-card-hardcut{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:5;overflow:hidden;color:var(--rw-text-muted)}
|
|
3059
|
+
.rw-span-plain{color:var(--rw-text-primary)}
|
|
3060
|
+
.rw-span-label{font-weight:700;color:var(--rw-card-accent,var(--rw-text-primary));margin-right:4px}
|
|
3061
|
+
.rw-span-think{background:var(--rw-think-bg);padding:1px 4px;margin-right:4px;border-radius:4px;box-shadow:inset 0 0 0 .5px var(--rw-think-border);box-decoration-break:clone;-webkit-box-decoration-break:clone}
|
|
3062
|
+
.rw-span-think-past{background:var(--rw-think-bg);color:var(--rw-text-muted);opacity:.72;padding:1px 4px;margin-right:4px;border-radius:4px;box-decoration-break:clone;-webkit-box-decoration-break:clone}
|
|
3063
|
+
.rw-span-think-empty{background:var(--rw-assistant-footer);color:var(--rw-text-muted);padding:1px 4px;margin-right:4px;border-radius:4px}
|
|
3064
|
+
.rw-span-tool-call{background:var(--rw-call-bg);border-radius:3px;box-shadow:inset 0 0 0 .5px var(--rw-call-border);box-decoration-break:clone;-webkit-box-decoration-break:clone}
|
|
3065
|
+
.rw-span-tool-result{background:transparent}
|
|
3066
|
+
.rw-span-tool-error{background:transparent;color:var(--rw-err-accent)}
|
|
3067
|
+
.rw-span-folded{color:var(--rw-text-muted)}
|
|
3068
|
+
.rw-cursor{display:inline-block;margin-left:1px;color:var(--rw-user-accent);animation:rw-blink .9s step-end infinite}
|
|
3069
|
+
@keyframes rw-blink{0%,100%{opacity:1}50%{opacity:0}}
|
|
3070
|
+
`;
|
|
3071
|
+
function mountStyles() {
|
|
3072
|
+
if (typeof document === "undefined") return () => {
|
|
3073
|
+
};
|
|
3074
|
+
const id = "dsh-rwkv-plugin-styles";
|
|
3075
|
+
document.getElementById(id)?.remove();
|
|
3076
|
+
const tag = document.createElement("style");
|
|
3077
|
+
tag.id = id;
|
|
3078
|
+
tag.dataset.plugin = "dsh-rwkv-plugin";
|
|
3079
|
+
tag.textContent = CSS;
|
|
3080
|
+
document.head.appendChild(tag);
|
|
3081
|
+
return () => tag.remove();
|
|
3082
|
+
}
|
|
3083
|
+
|
|
3084
|
+
// src/client/index.tsx
|
|
3085
|
+
var NAMESPACE = "rwkv-llm";
|
|
3086
|
+
var inject = ["slots", "configForms", "remote"];
|
|
3087
|
+
function apply(ctx) {
|
|
3088
|
+
const services = ctx;
|
|
3089
|
+
const form = services.configForms.get(NAMESPACE);
|
|
3090
|
+
const explain = async (field, value) => {
|
|
3091
|
+
const mutate = services.remote?.settings?.mutate;
|
|
3092
|
+
if (mutate === void 0) return "";
|
|
3093
|
+
try {
|
|
3094
|
+
const result = await mutate.call(services.remote.settings, NAMESPACE, [{ op: "set", path: [field], value }], form.getSnapshot().revision);
|
|
3095
|
+
return result.ok ? "" : result.error?.message ?? result.error?.code ?? "";
|
|
3096
|
+
} catch (error) {
|
|
3097
|
+
return error instanceof Error ? error.message : String(error);
|
|
3098
|
+
}
|
|
3099
|
+
};
|
|
3100
|
+
ctx.effect(() => mountStyles(), "rwkv-llm: settings styles");
|
|
3101
|
+
ctx.effect(() => services.configForms.whileServed([NAMESPACE], () => services.slots.inject("settings.section", () => services.slots.register({
|
|
3102
|
+
name: "settings.section",
|
|
3103
|
+
id: "rwkv",
|
|
3104
|
+
order: 15,
|
|
3105
|
+
label: () => "RWKV Agent",
|
|
3106
|
+
inject: () => ({ form, explain })
|
|
3107
|
+
}, RwkvSettings))), "rwkv-llm: settings section");
|
|
3108
|
+
ctx.effect(() => services.configForms.whileServed([NAMESPACE], () => services.slots.inject("conversation.view", () => services.slots.register({
|
|
3109
|
+
name: "conversation.view",
|
|
3110
|
+
id: "rwkv-trace",
|
|
3111
|
+
order: 45,
|
|
3112
|
+
label: () => "RWKV",
|
|
3113
|
+
inject: (sessionId) => ({ session: String(sessionId) })
|
|
3114
|
+
}, RwkvTraceView))), "rwkv-llm: trace view");
|
|
3115
|
+
const injectFn = ctx.inject;
|
|
3116
|
+
injectFn?.call(ctx, ["uiConversation"], (subCtx) => {
|
|
3117
|
+
const uiConv = subCtx.uiConversation;
|
|
3118
|
+
const dispose = uiConv?.events?.register?.(rwkvFoldDefinition);
|
|
3119
|
+
if (typeof dispose === "function") subCtx.effect(() => dispose, "rwkv-llm: chat fold definition");
|
|
3120
|
+
subCtx.effect(() => services.slots.inject("conversation.chat.node", () => services.slots.register({
|
|
3121
|
+
name: "conversation.chat.node",
|
|
3122
|
+
key: CONTEXT_FOLD_NODE_KEY
|
|
3123
|
+
}, RwkvFoldNodeView)), "rwkv-llm: chat fold node");
|
|
3124
|
+
});
|
|
3125
|
+
injectFn?.call(ctx, ["sidebarRightTabs"], (subCtx) => {
|
|
3126
|
+
const tabs = subCtx.sidebarRightTabs;
|
|
3127
|
+
const dispose = tabs?.register?.({
|
|
3128
|
+
id: WIRE_TAB_ID,
|
|
3129
|
+
kind: WIRE_TAB_ID,
|
|
3130
|
+
title: () => "RWKV \u5B9E\u65F6\u4E0A\u4E0B\u6587",
|
|
3131
|
+
guide: [{
|
|
3132
|
+
id: WIRE_TAB_ID,
|
|
3133
|
+
order: 45,
|
|
3134
|
+
title: () => "RWKV \u5B9E\u65F6\u4E0A\u4E0B\u6587",
|
|
3135
|
+
description: () => "\u67E5\u770B\u6A21\u578B\u539F\u59CB\u4E0A\u4E0B\u6587",
|
|
3136
|
+
icon: RwkvWireIcon
|
|
3137
|
+
}]
|
|
3138
|
+
});
|
|
3139
|
+
if (typeof dispose === "function") subCtx.effect(() => dispose, "rwkv-llm: wire tab type");
|
|
3140
|
+
subCtx.effect(() => services.slots.inject("sidebar.right.pane.tab", () => services.slots.register({
|
|
3141
|
+
name: "sidebar.right.pane.tab",
|
|
3142
|
+
key: WIRE_TAB_ID,
|
|
3143
|
+
inject: (sessionId) => ({ session: String(sessionId) })
|
|
3144
|
+
}, RwkvWirePanel)), "rwkv-llm: wire tab body");
|
|
3145
|
+
});
|
|
3146
|
+
}
|
|
3147
|
+
return module.exports; } });
|
|
3148
|
+
//# sourceMappingURL=client.js.map
|