cc-viewer 1.9.21 → 1.9.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/cli.js +50 -14
- package/dist/assets/{App-C4f2Dpy9.js → App-DEA3HoZr.js} +2 -2
- package/dist/assets/{MdxEditorPanel-D7aQDQJp.js → MdxEditorPanel-CTAS2DJv.js} +1 -1
- package/dist/assets/{Mobile-D9ekLQFS.js → Mobile-CgVpXvs2.js} +1 -1
- package/dist/assets/{ProxyStatsModal-CWpgyVKI.js → ProxyStatsModal-C4sl-cuB.js} +1 -1
- package/dist/assets/index-CS47d9oh.js +2 -0
- package/dist/assets/seqResourceLoaders-CORH46PN.js +2 -0
- package/dist/assets/seqResourceLoaders-v4YzKhTS.css +41 -0
- package/dist/index.html +1 -1
- package/findcc.js +4 -4
- package/node_modules/@ccv/core/src/contentFilter.js +4 -1
- package/node_modules/@ccv/core/src/ultraplanTemplates.js +199 -0
- package/package.json +1 -1
- package/server/i18n.js +97 -14
- package/server/interceptor.js +6 -0
- package/server/lib/async-write-queue.js +18 -0
- package/server/lib/auth.js +11 -3
- package/server/lib/base-path.js +89 -18
- package/server/lib/base-url.js +209 -0
- package/server/lib/ensure-hooks.js +134 -2
- package/server/lib/im/im-bridge-core.js +16 -0
- package/server/lib/log-management.js +21 -1
- package/server/lib/plugin-runtime.js +24 -5
- package/server/lib/scheduled-task-executor.js +14 -2
- package/server/lib/scheduled-task-store.js +129 -18
- package/server/lib/sdk-manager.js +113 -11
- package/server/lib/v2/adapter.js +147 -15
- package/server/lib/v2/conversation-store.js +9 -0
- package/server/lib/v2/journal.js +35 -0
- package/server/lib/v2/layout.js +67 -1
- package/server/lib/v2/live-feed.js +15 -0
- package/server/lib/v2/replay.js +11 -3
- package/server/lib/v2/session-select.js +34 -2
- package/server/lib/v2/shard-manager.js +249 -0
- package/server/lib/v2/v2-writer.js +252 -6
- package/server/pty-manager.js +103 -4
- package/server/routes/events.js +75 -4
- package/server/routes/logs.js +47 -16
- package/server/routes/misc.js +15 -5
- package/server/routes/scheduled-tasks.js +13 -0
- package/server/server.js +123 -23
- package/dist/assets/index-CocpEURl.js +0 -2
- package/dist/assets/seqResourceLoaders-BhiCEaUt.js +0 -2
- package/dist/assets/seqResourceLoaders-DbccWwKz.css +0 -41
package/findcc.js
CHANGED
|
@@ -201,7 +201,7 @@ export function resolveExplicitClaudePath(value, platform = process.platform) {
|
|
|
201
201
|
} catch { return null; }
|
|
202
202
|
let real = expanded;
|
|
203
203
|
try { real = realpathSync(expanded); } catch { }
|
|
204
|
-
const isJs = real.toLowerCase().endsWith('.js');
|
|
204
|
+
const isJs = real.toLowerCase().endsWith('.js') || real.toLowerCase().endsWith('.cjs');
|
|
205
205
|
try {
|
|
206
206
|
if (isJs) {
|
|
207
207
|
accessSync(real, fsConstants.R_OK);
|
|
@@ -571,7 +571,7 @@ export function resolveClaudeFromPath() {
|
|
|
571
571
|
|
|
572
572
|
let real = result;
|
|
573
573
|
try { real = realpathSync(result); } catch { }
|
|
574
|
-
if (real.endsWith('.js')) return { path: real, isNpmVersion: true };
|
|
574
|
+
if (real.endsWith('.js') || real.endsWith('.cjs')) return { path: real, isNpmVersion: true };
|
|
575
575
|
return { path: result, isNpmVersion: false };
|
|
576
576
|
} catch {
|
|
577
577
|
// Try the next lookup command.
|
|
@@ -630,12 +630,12 @@ export function resolveNativePath() {
|
|
|
630
630
|
// win32 过滤掉 sh shim / .cmd / .ps1,只取 .exe(否则 ConPTY spawn 报 error 193)
|
|
631
631
|
const result = pickSpawnableLookupResult(rawOut);
|
|
632
632
|
if (result && existsSync(result)) {
|
|
633
|
-
// 只排除 .js
|
|
633
|
+
// 只排除 .js/.cjs 文件(npm 分发的 Node 入口,需要 node 运行,
|
|
634
634
|
// 由 resolveNpmClaudePath 处理)。Claude Code 2.x+ 的 npm 包内
|
|
635
635
|
// 直接打包了原生二进制(bin/claude.exe),应当作 native 处理。
|
|
636
636
|
let real = result;
|
|
637
637
|
try { real = realpathSync(result); } catch { }
|
|
638
|
-
if (real.endsWith('.js')) continue;
|
|
638
|
+
if (real.endsWith('.js') || real.endsWith('.cjs')) continue;
|
|
639
639
|
return result;
|
|
640
640
|
}
|
|
641
641
|
} catch {
|
|
@@ -610,7 +610,10 @@ let _registryScanned = new WeakSet();
|
|
|
610
610
|
// Identify the session by the first request's timestamp; auto-reset on switch
|
|
611
611
|
let _registrySessionKey = null;
|
|
612
612
|
|
|
613
|
-
const PROMPT_PREFIX_LEN = 60;
|
|
613
|
+
export const PROMPT_PREFIX_LEN = 60;
|
|
614
|
+
// Shared cap on the retained prompt snippet for agent tasks — the web tracker and
|
|
615
|
+
// the server replay table must truncate identically for prompt-prefix joins.
|
|
616
|
+
export const AGENT_PROMPT_SNIPPET_LEN = 1024;
|
|
614
617
|
const TM_TAG_RE = /<teammate-message[^>]*>/;
|
|
615
618
|
|
|
616
619
|
/**
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// Ultraplan prompt templates for local Claude Code execution.
|
|
2
|
+
// Shared isomorphic module (@ccv/core): the web hosts (TerminalPanel / ChatView) assemble
|
|
3
|
+
// at send time, and the scheduled-task executor (packages/app) assembles at fire time —
|
|
4
|
+
// one source of truth so the wrapper can never drift between the two.
|
|
5
|
+
//
|
|
6
|
+
// Two expert roles:
|
|
7
|
+
// - codeExpert: Multi-agent code planning & implementation (from subagents template)
|
|
8
|
+
// - researchExpert: Multi-agent research & analysis
|
|
9
|
+
// Plus the 'none' variant: no template wrapper, the user input is sent as-is.
|
|
10
|
+
//
|
|
11
|
+
// Assembly logic mirrors ~/claude-code/commands/ultraplan.tsx:63-73
|
|
12
|
+
// buildUltraplanPrompt(blurb, seedPlan?)
|
|
13
|
+
|
|
14
|
+
export const ULTRAPLAN_VARIANTS = {
|
|
15
|
+
|
|
16
|
+
codeExpert: `<system-reminder>
|
|
17
|
+
[SCOPED INSTRUCTION] The following instructions apply only to the next 1–3 interactions. Once the task is complete, these instructions should gradually decrease in priority and no longer affect subsequent interactions. You should be adept at utilizing tools such as \`AskUserQuestion\` and \`EnterPlanMode\`, rather than relying solely on plain text processing. Before execution, you must ensure that the \`EnterPlanMode\`, \`ExitPlanMode\`, \`SendMessage\`, \`TaskCreate\`, \`TaskUpdate\`, \`TaskStop\`, \`TaskGet\`, \`TaskOutput\` and \`TaskList\` tools are loaded.
|
|
18
|
+
|
|
19
|
+
Pre-requisite: Use \`AskUserQuestion\` to clarify user intent whenever the request is ambiguous (target element, interaction style, scope of platforms, etc.). Skip only if the intent is unambiguous.
|
|
20
|
+
|
|
21
|
+
Leverage a multi-agent exploration mechanism to formulate a highly detailed implementation plan.
|
|
22
|
+
|
|
23
|
+
Instructions:
|
|
24
|
+
1. Use the \`Agent\` tool to spawn parallel agents that simultaneously explore different aspects of the codebase:
|
|
25
|
+
- If necessary, assign a preliminary researcher to use the \`webSearch\` tool to first investigate cutting-edge solutions in the relevant industry domain;
|
|
26
|
+
- One agent responsible for understanding the relevant existing code and architecture;
|
|
27
|
+
- One agent responsible for identifying all files that need to be modified;
|
|
28
|
+
- One agent responsible for identifying potential risks, edge cases, and dependencies;
|
|
29
|
+
- You may add other roles or deploy additional agents beyond the three listed above; the maximum number of concurrently dispatched agents is 5.
|
|
30
|
+
|
|
31
|
+
2. Synthesize the findings from all agents into a detailed, step-by-step implementation plan.
|
|
32
|
+
|
|
33
|
+
3. Use the \`Agent\` tool to spawn 2-3 review agents that examine the plan from different perspectives, checking for missing steps, potential risks, or corresponding mitigation strategies.
|
|
34
|
+
|
|
35
|
+
4. Integrate the feedback gathered during the review process, then call \`ExitPlanMode\` to submit your final plan.
|
|
36
|
+
|
|
37
|
+
5. Once \`ExitPlanMode\` returns a result:
|
|
38
|
+
- If approved: proceed to execute the plan within this session.
|
|
39
|
+
- If rejected: revise the plan based on the feedback provided and call \`ExitPlanMode\` again.
|
|
40
|
+
- If an error occurs (including receiving a "Not in Plan Mode" message): do **not** follow the suggestions provided in the error message; instead, prompt the user for further instructions.
|
|
41
|
+
|
|
42
|
+
Your final plan must include the following elements:
|
|
43
|
+
- A clear summary of the implementation strategy;
|
|
44
|
+
- An ordered list of files to be created or modified, with precise details of the required changes for each file;
|
|
45
|
+
- A step-by-step execution sequence;
|
|
46
|
+
- Testing and validation procedures;
|
|
47
|
+
- Potential risks and their corresponding mitigation strategies;
|
|
48
|
+
|
|
49
|
+
6. After the final plan has been successfully executed:
|
|
50
|
+
First run \`git diff --quiet && git diff --cached --quiet\` (or equivalent) to detect whether the working tree actually has non-trivial changes; if there are no real changes (or only whitespace/comment-only edits), skip the UltraReview step.
|
|
51
|
+
Otherwise, if the project is managed with Git:
|
|
52
|
+
Use the \`Agent\` tool to build a team, dynamically allocating the number of teammates based on task complexity (5+ recommended);
|
|
53
|
+
Note: spawn teammates (which have a \`name\`), not plain subagents (which have no name);
|
|
54
|
+
Task: Conduct a Code Review of the current git changes from multiple roles and perspectives;
|
|
55
|
+
Pre-requisites:
|
|
56
|
+
- The git repository may be located in a subdirectory of the current directory; recursively locate the \`.git\` directory first before proceeding;
|
|
57
|
+
- In the case of multiple repositories, review tasks may be executed separately per repository;
|
|
58
|
+
Review dimensions (a reference framework — each role covers them as its perspective requires, aiming to be as comprehensive as possible):
|
|
59
|
+
- Whether requirements/objectives have been met and functionality is complete;
|
|
60
|
+
- Whether newly added code introduces side effects, breaks existing functionality, or poses potential risks;
|
|
61
|
+
- Code quality: naming, readability, complexity, technical debt, maintainability;
|
|
62
|
+
- Testing and documentation: whether there is adequate test coverage, and whether critical logic has necessary comments or documentation;
|
|
63
|
+
- Dependencies and compatibility: whether new dependencies or version compatibility issues have been introduced;
|
|
64
|
+
- Any other dimensions you see fit;
|
|
65
|
+
Workflow:
|
|
66
|
+
- Each teammate, according to their own role, covers the review dimensions one by one and independently outputs a report;
|
|
67
|
+
- After consolidating the reports, perform a cross-review to identify conflicts or shared concerns;
|
|
68
|
+
- Distill specific, actionable modification suggestions and annotate them with priority levels (P0/P1/P2/P3);
|
|
69
|
+
- Upon completion, fix all P0 and P1 items; evaluate P2 items dialectically (use \`AskUserQuestion\` to consult the user when any item needs a special decision);
|
|
70
|
+
- After execution is complete, close the team: notify each teammate to exit individually;
|
|
71
|
+
</system-reminder>`,
|
|
72
|
+
|
|
73
|
+
researchExpert: `<system-reminder>
|
|
74
|
+
[SCOPED INSTRUCTION] The following instructions are intended for the next 1–3 interactions. Once the task is complete, these instructions should be gradually deprioritized and no longer influence subsequent interactions.You should be adept at utilizing tools such as \`AskUserQuestion\`, \`EnterPlanMode\` and \`WebSearch\`, rather than relying solely on plain text processing. Before execution, you must ensure that the \`EnterPlanMode\`, \`ExitPlanMode\`, \`TaskCreate\`, \`TaskUpdate\`, \`TaskStop\`, \`TaskGet\`, \`TaskOutput\` and \`TaskList\` tools are loaded.
|
|
75
|
+
|
|
76
|
+
Pre-requisite: Use \`AskUserQuestion\` to clarify the research scope, target audience, and deliverable format whenever the user's intent is ambiguous. Skip only if the intent is unambiguous.
|
|
77
|
+
|
|
78
|
+
Leverage a multi-agent exploration mechanism to formulate an exceptionally detailed implementation plan.
|
|
79
|
+
|
|
80
|
+
Instructions:
|
|
81
|
+
1. Utilize the Agent tool to spawn parallel agents that simultaneously explore various facets of the requirements:
|
|
82
|
+
- If necessary, deploy a preliminary investigator to conduct an initial survey of industry-specific solutions using \`webSearch\`;
|
|
83
|
+
- If necessary, deploy a specialized investigator to research authoritative sources—such as academic papers, news articles, and research reports—using \`webSearch\`;
|
|
84
|
+
- Assign an agent to synthesize the target solution, while simultaneously verifying the rigor and credibility of the gathered papers, news, and research reports;
|
|
85
|
+
- If necessary, assign an agent to analyze competitor data to provide supplementary analytical perspectives;
|
|
86
|
+
- If necessary, assign an agent to handle the implementation of a product demo (generating outputs such as HTML, Markdown, etc.);
|
|
87
|
+
- If the task is sufficiently complex, you may assign additional teammates to the roles defined above, or introduce other specialized roles; you are permitted to schedule up to 5 teammates concurrently.
|
|
88
|
+
|
|
89
|
+
2. Synthesize the findings from the aforementioned agents into a comprehensive, step-by-step implementation plan.
|
|
90
|
+
|
|
91
|
+
3. Utilize the Agent tool to spawn a set of parallel review agents; these agents shall scrutinize the plan from multiple roles and perspectives to identify any omitted steps and to propose reasonable additions or optimizations.
|
|
92
|
+
|
|
93
|
+
4. Consolidate the feedback received from the review agents, then invoke \`ExitPlanMode\` to submit your final plan.
|
|
94
|
+
|
|
95
|
+
5. Upon receiving the result from \`ExitPlanMode\`:
|
|
96
|
+
- If Approved: Proceed to execute the plan within this current session.
|
|
97
|
+
- If Rejected: Revise the plan based on the provided feedback, and then invoke \`ExitPlanMode\` once again.
|
|
98
|
+
- If an Error Occurs (including the message "Not in Plan Mode"): Do *not* follow the suggestions provided by the error message; instead, prompt the user for further instructions.
|
|
99
|
+
|
|
100
|
+
Your final plan must include the following elements:
|
|
101
|
+
- A clear summary of the proposed implementation strategy;
|
|
102
|
+
- An ordered list of files to be created or modified, specifying the exact changes required for each;
|
|
103
|
+
- A step-by-step sequence for executing the implementation;
|
|
104
|
+
- Identification of potential risks and corresponding mitigation strategies;
|
|
105
|
+
- Creative ideation and suggestions for advanced enhancements;
|
|
106
|
+
- If a product demo was generated, place the corresponding demo output in an appropriate location and notify the user.
|
|
107
|
+
</system-reminder>`,
|
|
108
|
+
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Wrap user-authored custom instruction body with the same scoped-instruction
|
|
113
|
+
* preamble used by the built-in variants. Produces a full <system-reminder>
|
|
114
|
+
* block ready to be inlined into a Claude Code prompt.
|
|
115
|
+
*/
|
|
116
|
+
export function buildCustomTemplate(content) {
|
|
117
|
+
const body = (content || '').trim();
|
|
118
|
+
if (!body) return '';
|
|
119
|
+
// A body that already carries the wrapper shell (the prefilled skeleton or a
|
|
120
|
+
// hand-written one) must not be wrapped again; startsWith (not includes) so a
|
|
121
|
+
// body that merely *mentions* the tag in prose still gets the scope preamble.
|
|
122
|
+
if (body.startsWith('<system-reminder>')) return body;
|
|
123
|
+
return `<system-reminder>
|
|
124
|
+
[SCOPED INSTRUCTION] The following instructions apply only to the next 1–3 interactions. Once the task is complete, these instructions should gradually decrease in priority and no longer affect subsequent interactions. You should be adept at utilizing tools such as \`AskUserQuestion\` and \`EnterPlanMode\`, rather than relying solely on plain text processing.
|
|
125
|
+
|
|
126
|
+
${body}
|
|
127
|
+
</system-reminder>`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Assemble a local ultraplan prompt.
|
|
132
|
+
* Mirrors ~/claude-code/commands/ultraplan.tsx:63-73 buildUltraplanPrompt()
|
|
133
|
+
*
|
|
134
|
+
* @param {string} userPrompt - User's task description
|
|
135
|
+
* @param {'none'|'codeExpert'|'researchExpert'|'custom'} variant - Template variant;
|
|
136
|
+
* 'none' returns the user prompt as-is (no wrapper).
|
|
137
|
+
* @param {string} [seedPlan] - Optional draft plan to refine
|
|
138
|
+
* @param {string} [customContent] - Required when variant === 'custom': the user-authored body
|
|
139
|
+
* @returns {string} Assembled prompt ready to send to Claude Code
|
|
140
|
+
*/
|
|
141
|
+
export function buildLocalUltraplan(userPrompt, variant = 'codeExpert', seedPlan, customContent) {
|
|
142
|
+
// 'none' is the empty template: send the user input verbatim. seedPlan only
|
|
143
|
+
// makes sense together with a wrapper, so it is ignored here.
|
|
144
|
+
if (variant === 'none') return userPrompt || '';
|
|
145
|
+
let template;
|
|
146
|
+
if (variant === 'custom') {
|
|
147
|
+
template = buildCustomTemplate(customContent);
|
|
148
|
+
if (!template) return '';
|
|
149
|
+
} else {
|
|
150
|
+
template = ULTRAPLAN_VARIANTS[variant] || ULTRAPLAN_VARIANTS.codeExpert;
|
|
151
|
+
}
|
|
152
|
+
const parts = [];
|
|
153
|
+
if (seedPlan) {
|
|
154
|
+
parts.push('Here is a draft plan to refine:', '', seedPlan, '');
|
|
155
|
+
}
|
|
156
|
+
parts.push(template);
|
|
157
|
+
if (userPrompt) {
|
|
158
|
+
parts.push('', userPrompt);
|
|
159
|
+
}
|
|
160
|
+
return parts.join('\n');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Assemble the text a scheduled task actually dispatches (executor-side).
|
|
165
|
+
* The task stores the RAW user input (task.prompt) plus the template selection
|
|
166
|
+
* and attachment paths; the wrapper and the quoted-path prefix are injected here
|
|
167
|
+
* at fire time so the stored prompt stays editable and summaries stay human-readable.
|
|
168
|
+
*
|
|
169
|
+
* @param {object} task
|
|
170
|
+
* @param {string} task.prompt raw user text (never pre-wrapped)
|
|
171
|
+
* @param {string} [task.template] 'none' | builtin key | 'custom:<id>'; absent → 'none'
|
|
172
|
+
* @param {string} [task.templateContent] snapshot of the custom expert body (custom:* only)
|
|
173
|
+
* @param {Array<{name:string, path:string}>} [task.attachments]
|
|
174
|
+
* @returns {string} the prompt to dispatch (empty string when there is nothing to send)
|
|
175
|
+
*/
|
|
176
|
+
export function assembleScheduledPrompt(task) {
|
|
177
|
+
const raw = (task && task.prompt != null) ? String(task.prompt).trim() : '';
|
|
178
|
+
const attachments = Array.isArray(task?.attachments) ? task.attachments : [];
|
|
179
|
+
const filePaths = attachments
|
|
180
|
+
.map(f => (f && typeof f.path === 'string') ? `"${f.path.replace(/"/g, '')}"` : '')
|
|
181
|
+
.filter(Boolean)
|
|
182
|
+
.join(' ');
|
|
183
|
+
const userInput = filePaths ? (raw ? `${filePaths} ${raw}` : filePaths) : raw;
|
|
184
|
+
|
|
185
|
+
const template = typeof task?.template === 'string' ? task.template : 'none';
|
|
186
|
+
if (template.startsWith('custom:')) {
|
|
187
|
+
// The snapshot rides with the task so later edits/deletions of the custom
|
|
188
|
+
// expert do not change what fires. A missing/empty snapshot degrades to the
|
|
189
|
+
// raw input rather than silently dropping the task.
|
|
190
|
+
const wrapped = buildCustomTemplate(task.templateContent);
|
|
191
|
+
if (!wrapped) return userInput;
|
|
192
|
+
return `${wrapped}\n\n${userInput}`.trim();
|
|
193
|
+
}
|
|
194
|
+
if (template === 'codeExpert' || template === 'researchExpert') {
|
|
195
|
+
return buildLocalUltraplan(userInput, template);
|
|
196
|
+
}
|
|
197
|
+
// 'none' or anything unknown: verbatim.
|
|
198
|
+
return userInput;
|
|
199
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-viewer",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.23",
|
|
4
4
|
"description": "Claude Code logging, visualization, and management toolkit — launch a web viewer alongside Claude Code with full request/response tracing, proxy, and mobile support",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "server.js",
|
package/server/i18n.js
CHANGED
|
@@ -647,6 +647,86 @@ const i18nData = {
|
|
|
647
647
|
"tr": " ⚠️ CCV_BASE_PATH \"{value}\" \"/\" ile başlamalıdır — yok sayıldı. Örnek: \"/proxy/\"",
|
|
648
648
|
"uk": " ⚠️ CCV_BASE_PATH \"{value}\" має починатися з \"/\" — проігноровано. Приклад: \"/proxy/\""
|
|
649
649
|
},
|
|
650
|
+
"baseUrl.invalid": {
|
|
651
|
+
"zh": " ⚠️ CCV_BASE_URL \"{value}\" 无法解析或使用了不支持的 scheme(支持 http(s)://、ws(s)://、host/path 或 /path 写法),已忽略并回退到 CCV_BASE_PATH。",
|
|
652
|
+
"en": " ⚠️ CCV_BASE_URL \"{value}\" is invalid or uses an unsupported scheme (use http(s)://, ws(s)://, host/path, or /path) — ignored; falling back to CCV_BASE_PATH.",
|
|
653
|
+
"zh-TW": " ⚠️ CCV_BASE_URL \"{value}\" 無法解析或使用了不支援的 scheme(支援 http(s)://、ws(s)://、host/path 或 /path 寫法),已忽略並回退到 CCV_BASE_PATH。",
|
|
654
|
+
"ko": " ⚠️ CCV_BASE_URL \"{value}\"을(를) 해석할 수 없거나 지원하지 않는 scheme입니다(http(s)://, ws(s)://, host/path 또는 /path 형식 사용) — 무시하고 CCV_BASE_PATH로 되돌립니다.",
|
|
655
|
+
"ja": " ⚠️ CCV_BASE_URL \"{value}\" は解析できないか、未対応の scheme です(http(s)://、ws(s)://、host/path、/path 形式を使用)— 無視し、CCV_BASE_PATH にフォールバックします。",
|
|
656
|
+
"de": " ⚠️ CCV_BASE_URL \"{value}\" ist ungültig oder verwendet ein nicht unterstütztes Schema (http(s)://, ws(s)://, host/path oder /path verwenden) — ignoriert; Rückfall auf CCV_BASE_PATH.",
|
|
657
|
+
"es": " ⚠️ CCV_BASE_URL \"{value}\" no es válida o usa un esquema no admitido (use http(s)://, ws(s)://, host/path o /path) — ignorada; se recurre a CCV_BASE_PATH.",
|
|
658
|
+
"fr": " ⚠️ CCV_BASE_URL « {value} » est invalide ou utilise un schéma non pris en charge (utilisez http(s)://, ws(s)://, host/path ou /path) — ignorée ; retour à CCV_BASE_PATH.",
|
|
659
|
+
"it": " ⚠️ CCV_BASE_URL \"{value}\" non è valida o usa uno schema non supportato (usa http(s)://, ws(s)://, host/path o /path) — ignorata; ripiego su CCV_BASE_PATH.",
|
|
660
|
+
"da": " ⚠️ CCV_BASE_URL \"{value}\" er ugyldig eller bruger et ikke-understøttet skema (brug http(s)://, ws(s)://, host/path eller /path) — ignoreret; falder tilbage på CCV_BASE_PATH.",
|
|
661
|
+
"pl": " ⚠️ CCV_BASE_URL \"{value}\" jest nieprawidłowy lub używa nieobsługiwanego schematu (użyj http(s)://, ws(s)://, host/path lub /path) — zignorowano; powrót do CCV_BASE_PATH.",
|
|
662
|
+
"ru": " ⚠️ CCV_BASE_URL \"{value}\" недействителен или использует неподдерживаемую схему (используйте http(s)://, ws(s)://, host/path или /path) — проигнорировано; возврат к CCV_BASE_PATH.",
|
|
663
|
+
"ar": " ⚠️ CCV_BASE_URL \"{value}\" غير صالح أو يستخدم مخططًا غير مدعوم (استخدم http(s):// أو ws(s):// أو host/path أو /path) — تم التجاهل؛ الرجوع إلى CCV_BASE_PATH.",
|
|
664
|
+
"no": " ⚠️ CCV_BASE_URL \"{value}\" er ugyldig eller bruker et ikke-støttet skjema (bruk http(s)://, ws(s)://, host/path eller /path) — ignorert; faller tilbake til CCV_BASE_PATH.",
|
|
665
|
+
"pt-BR": " ⚠️ CCV_BASE_URL \"{value}\" é inválida ou usa um esquema não suportado (use http(s)://, ws(s)://, host/path ou /path) — ignorada; revertendo para CCV_BASE_PATH.",
|
|
666
|
+
"th": " ⚠️ CCV_BASE_URL \"{value}\" ไม่ถูกต้องหรือใช้ scheme ที่ไม่รองรับ (ใช้ http(s)://, ws(s)://, host/path หรือ /path) — ถูกละเว้น กลับไปใช้ CCV_BASE_PATH",
|
|
667
|
+
"tr": " ⚠️ CCV_BASE_URL \"{value}\" geçersiz veya desteklenmeyen bir şema kullanıyor (http(s)://, ws(s)://, host/path veya /path kullanın) — yoksayıldı; CCV_BASE_PATH değerine geri dönülüyor.",
|
|
668
|
+
"uk": " ⚠️ CCV_BASE_URL \"{value}\" недійсний або використовує непідтримувану схему (використовуйте http(s)://, ws(s)://, host/path або /path) — проігноровано; повернення до CCV_BASE_PATH."
|
|
669
|
+
},
|
|
670
|
+
"baseUrl.queryFragmentIgnored": {
|
|
671
|
+
"zh": " ⚠️ CCV_BASE_URL \"{value}\" 中的查询串/锚点已忽略(只使用 scheme、host 与 path)。",
|
|
672
|
+
"en": " ⚠️ CCV_BASE_URL \"{value}\": query string / fragment ignored (only scheme, host, and path are used).",
|
|
673
|
+
"zh-TW": " ⚠️ CCV_BASE_URL \"{value}\" 中的查詢串/錨點已忽略(只使用 scheme、host 與 path)。",
|
|
674
|
+
"ko": " ⚠️ CCV_BASE_URL \"{value}\": 쿼리 문자열/프래그먼트는 무시됩니다(scheme, host, path만 사용).",
|
|
675
|
+
"ja": " ⚠️ CCV_BASE_URL \"{value}\": クエリ文字列/フラグメントは無視されます(scheme、host、path のみ使用)。",
|
|
676
|
+
"de": " ⚠️ CCV_BASE_URL \"{value}\": Query-String/Fragment ignoriert (nur Schema, Host und Pfad werden verwendet).",
|
|
677
|
+
"es": " ⚠️ CCV_BASE_URL \"{value}\": cadena de consulta/fragmento ignorados (solo se usan esquema, host y ruta).",
|
|
678
|
+
"fr": " ⚠️ CCV_BASE_URL « {value} » : chaîne de requête/fragment ignorés (seuls le schéma, l'hôte et le chemin sont utilisés).",
|
|
679
|
+
"it": " ⚠️ CCV_BASE_URL \"{value}\": query string/frammento ignorati (vengono usati solo schema, host e percorso).",
|
|
680
|
+
"da": " ⚠️ CCV_BASE_URL \"{value}\": forespørgselsstreng/fragment ignoreret (kun skema, vært og sti bruges).",
|
|
681
|
+
"pl": " ⚠️ CCV_BASE_URL \"{value}\": ciąg zapytania/fragment zignorowane (używany jest tylko schemat, host i ścieżka).",
|
|
682
|
+
"ru": " ⚠️ CCV_BASE_URL \"{value}\": строка запроса/фрагмент проигнорированы (используются только схема, хост и путь).",
|
|
683
|
+
"ar": " ⚠️ CCV_BASE_URL \"{value}\": تم تجاهل سلسلة الاستعلام/الجزء (يُستخدم فقط المخطط والمضيف والمسار).",
|
|
684
|
+
"no": " ⚠️ CCV_BASE_URL \"{value}\": spørrestreng/fragment ignorert (kun skjema, vert og sti brukes).",
|
|
685
|
+
"pt-BR": " ⚠️ CCV_BASE_URL \"{value}\": query string/fragmento ignorados (apenas esquema, host e caminho são usados).",
|
|
686
|
+
"th": " ⚠️ CCV_BASE_URL \"{value}\": ละเว้น query string/fragment (ใช้เฉพาะ scheme, host และ path)",
|
|
687
|
+
"tr": " ⚠️ CCV_BASE_URL \"{value}\": sorgu dizesi/parça yoksayıldı (yalnızca şema, ana bilgisayar ve yol kullanılır).",
|
|
688
|
+
"uk": " ⚠️ CCV_BASE_URL \"{value}\": рядок запиту/фрагмент проігноровано (використовуються лише схема, хост і шлях)."
|
|
689
|
+
},
|
|
690
|
+
"baseUrl.overridesBasePath": {
|
|
691
|
+
"zh": " ℹ️ CCV_BASE_URL 与 CCV_BASE_PATH 同时设置,CCV_BASE_URL 优先(CCV_BASE_PATH 被忽略)。",
|
|
692
|
+
"en": " ℹ️ Both CCV_BASE_URL and CCV_BASE_PATH are set; CCV_BASE_URL takes precedence (CCV_BASE_PATH is ignored).",
|
|
693
|
+
"zh-TW": " ℹ️ CCV_BASE_URL 與 CCV_BASE_PATH 同時設定,CCV_BASE_URL 優先(CCV_BASE_PATH 被忽略)。",
|
|
694
|
+
"ko": " ℹ️ CCV_BASE_URL과 CCV_BASE_PATH가 모두 설정되어 있습니다. CCV_BASE_URL이 우선합니다(CCV_BASE_PATH는 무시됨).",
|
|
695
|
+
"ja": " ℹ️ CCV_BASE_URL と CCV_BASE_PATH の両方が設定されています。CCV_BASE_URL が優先されます(CCV_BASE_PATH は無視されます)。",
|
|
696
|
+
"de": " ℹ️ CCV_BASE_URL und CCV_BASE_PATH sind beide gesetzt; CCV_BASE_URL hat Vorrang (CCV_BASE_PATH wird ignoriert).",
|
|
697
|
+
"es": " ℹ️ CCV_BASE_URL y CCV_BASE_PATH están definidas; CCV_BASE_URL tiene prioridad (CCV_BASE_PATH se ignora).",
|
|
698
|
+
"fr": " ℹ️ CCV_BASE_URL et CCV_BASE_PATH sont toutes deux définies ; CCV_BASE_URL est prioritaire (CCV_BASE_PATH est ignorée).",
|
|
699
|
+
"it": " ℹ️ CCV_BASE_URL e CCV_BASE_PATH sono entrambe impostate; CCV_BASE_URL ha la precedenza (CCV_BASE_PATH viene ignorata).",
|
|
700
|
+
"da": " ℹ️ Både CCV_BASE_URL og CCV_BASE_PATH er sat; CCV_BASE_URL har forrang (CCV_BASE_PATH ignoreres).",
|
|
701
|
+
"pl": " ℹ️ Ustawiono zarówno CCV_BASE_URL, jak i CCV_BASE_PATH; CCV_BASE_URL ma pierwszeństwo (CCV_BASE_PATH jest ignorowana).",
|
|
702
|
+
"ru": " ℹ️ Заданы и CCV_BASE_URL, и CCV_BASE_PATH; приоритет у CCV_BASE_URL (CCV_BASE_PATH игнорируется).",
|
|
703
|
+
"ar": " ℹ️ تم تعيين كل من CCV_BASE_URL و CCV_BASE_PATH؛ الأولوية لـ CCV_BASE_URL (يتم تجاهل CCV_BASE_PATH).",
|
|
704
|
+
"no": " ℹ️ Både CCV_BASE_URL og CCV_BASE_PATH er satt; CCV_BASE_URL har forrang (CCV_BASE_PATH ignoreres).",
|
|
705
|
+
"pt-BR": " ℹ️ CCV_BASE_URL e CCV_BASE_PATH estão definidas; CCV_BASE_URL tem precedência (CCV_BASE_PATH é ignorada).",
|
|
706
|
+
"th": " ℹ️ ตั้งค่าทั้ง CCV_BASE_URL และ CCV_BASE_PATH; CCV_BASE_URL มีความสำคัญกว่า (CCV_BASE_PATH จะถูกละเว้น)",
|
|
707
|
+
"tr": " ℹ️ Hem CCV_BASE_URL hem CCV_BASE_PATH ayarlı; CCV_BASE_URL önceliklidir (CCV_BASE_PATH yoksayılır).",
|
|
708
|
+
"uk": " ℹ️ Задано і CCV_BASE_URL, і CCV_BASE_PATH; пріоритет має CCV_BASE_URL (CCV_BASE_PATH ігнорується)."
|
|
709
|
+
},
|
|
710
|
+
"server.startedExternal": {
|
|
711
|
+
"zh": " ➜ External: {url}",
|
|
712
|
+
"en": " ➜ External: {url}",
|
|
713
|
+
"zh-TW": " ➜ External: {url}",
|
|
714
|
+
"ko": " ➜ External: {url}",
|
|
715
|
+
"ja": " ➜ External: {url}",
|
|
716
|
+
"de": " ➜ External: {url}",
|
|
717
|
+
"es": " ➜ External: {url}",
|
|
718
|
+
"fr": " ➜ External: {url}",
|
|
719
|
+
"it": " ➜ External: {url}",
|
|
720
|
+
"da": " ➜ External: {url}",
|
|
721
|
+
"pl": " ➜ External: {url}",
|
|
722
|
+
"ru": " ➜ External: {url}",
|
|
723
|
+
"ar": " ➜ External: {url}",
|
|
724
|
+
"no": " ➜ External: {url}",
|
|
725
|
+
"pt-BR": " ➜ External: {url}",
|
|
726
|
+
"th": " ➜ External: {url}",
|
|
727
|
+
"tr": " ➜ External: {url}",
|
|
728
|
+
"uk": " ➜ External: {url}"
|
|
729
|
+
},
|
|
650
730
|
"server.auth.loginTitle": {
|
|
651
731
|
"zh": "请输入访问密码",
|
|
652
732
|
"en": "Enter access password",
|
|
@@ -761,6 +841,7 @@ const i18nData = {
|
|
|
761
841
|
"server.dingtalk.queueFull": { "zh": "消息队列已满({max}),已丢弃该消息,请稍后再发。", "en": "Message queue is full ({max}); this message was dropped. Try again later." },
|
|
762
842
|
"server.dingtalk.ackProcessing": { "zh": "收到,正在思考…", "en": "Got it, thinking…" },
|
|
763
843
|
"server.dingtalk.ackTimeout": { "zh": "处理超时,请重试。", "en": "Processing timed out, please try again." },
|
|
844
|
+
"server.dingtalk.startupError": { "zh": "Claude 启动未完成(目录信任待处理),请检查配置后重试。", "en": "Claude startup incomplete (directory trust pending) — check configuration and retry." },
|
|
764
845
|
"server.feishu.replyChunkTitle": { "zh": "Claude", "en": "Claude" },
|
|
765
846
|
"server.feishu.truncated": { "zh": "(回复过长已截断,完整内容请见 Web 界面)", "en": "(reply truncated — see the web UI for the full content)" },
|
|
766
847
|
"server.feishu.noTextReply": { "zh": "(本轮无文本回复)", "en": "(no text reply this turn)" },
|
|
@@ -775,6 +856,7 @@ const i18nData = {
|
|
|
775
856
|
"server.feishu.queueFull": { "zh": "消息队列已满({max}),已丢弃该消息,请稍后再发。", "en": "Message queue is full ({max}); this message was dropped. Try again later." },
|
|
776
857
|
"server.feishu.ackProcessing": { "zh": "收到,正在思考…", "en": "Got it, thinking…" },
|
|
777
858
|
"server.feishu.ackTimeout": { "zh": "处理超时,请重试。", "en": "Processing timed out, please try again." },
|
|
859
|
+
"server.feishu.startupError": { "zh": "Claude 启动未完成(目录信任待处理),请检查配置后重试。", "en": "Claude startup incomplete (directory trust pending) — check configuration and retry." },
|
|
778
860
|
"server.wecom.replyChunkTitle": { "zh": "Claude", "en": "Claude" },
|
|
779
861
|
"server.wecom.truncated": { "zh": "(回复过长已截断,完整内容请见 Web 界面)", "en": "(reply truncated — see the web UI for the full content)" },
|
|
780
862
|
"server.wecom.noTextReply": { "zh": "(本轮无文本回复)", "en": "(no text reply this turn)" },
|
|
@@ -789,6 +871,7 @@ const i18nData = {
|
|
|
789
871
|
"server.wecom.queueFull": { "zh": "消息队列已满({max}),已丢弃该消息,请稍后再发。", "en": "Message queue is full ({max}); this message was dropped. Try again later." },
|
|
790
872
|
"server.wecom.ackProcessing": { "zh": "收到,正在思考…", "en": "Got it, thinking…" },
|
|
791
873
|
"server.wecom.ackTimeout": { "zh": "处理超时,请重试。", "en": "Processing timed out, please try again." },
|
|
874
|
+
"server.wecom.startupError": { "zh": "Claude 启动未完成(目录信任待处理),请检查配置后重试。", "en": "Claude startup incomplete (directory trust pending) — check configuration and retry." },
|
|
792
875
|
"server.discord.replyChunkTitle": { "zh": "Claude", "en": "Claude" },
|
|
793
876
|
"server.discord.truncated": { "zh": "(回复过长已截断,完整内容请见 Web 界面)", "en": "(reply truncated — see the web UI for the full content)" },
|
|
794
877
|
"server.discord.noTextReply": { "zh": "(本轮无文本回复)", "en": "(no text reply this turn)" },
|
|
@@ -803,6 +886,7 @@ const i18nData = {
|
|
|
803
886
|
"server.discord.queueFull": { "zh": "消息队列已满({max}),已丢弃该消息,请稍后再发。", "en": "Message queue is full ({max}); this message was dropped. Try again later." },
|
|
804
887
|
"server.discord.ackProcessing": { "zh": "收到,正在思考…", "en": "Got it, thinking…" },
|
|
805
888
|
"server.discord.ackTimeout": { "zh": "处理超时,请重试。", "en": "Processing timed out, please try again." },
|
|
889
|
+
"server.discord.startupError": { "zh": "Claude 启动未完成(目录信任待处理),请检查配置后重试。", "en": "Claude startup incomplete (directory trust pending) — check configuration and retry." },
|
|
806
890
|
"update.updating": {
|
|
807
891
|
"zh": "正在更新到 v{version}...",
|
|
808
892
|
"en": "Updating to v{version}...",
|
|
@@ -3095,14 +3179,18 @@ export function getLang() {
|
|
|
3095
3179
|
return currentLang;
|
|
3096
3180
|
}
|
|
3097
3181
|
|
|
3182
|
+
// Single-pass interpolation: a param value that itself contains '{otherKey}' must NOT be
|
|
3183
|
+
// re-substituted (e.g. basePath '/arca/.../session/{token}/' must survive the later {token}
|
|
3184
|
+
// param pass). Per-key replaceAll loops rewrite earlier insertions; a regex callback resolves
|
|
3185
|
+
// each placeholder exactly once against the ORIGINAL template text.
|
|
3186
|
+
function interpolate(text, params) {
|
|
3187
|
+
return text.replace(/\{([A-Za-z0-9_]+)\}/g, (m, k) =>
|
|
3188
|
+
Object.prototype.hasOwnProperty.call(params, k) ? String(params[k]) : m);
|
|
3189
|
+
}
|
|
3190
|
+
|
|
3098
3191
|
export function t(key, params) {
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
for (const [k, v] of Object.entries(params)) {
|
|
3102
|
-
text = text.replaceAll(`{${k}}`, v);
|
|
3103
|
-
}
|
|
3104
|
-
}
|
|
3105
|
-
return text;
|
|
3192
|
+
const text = locales[currentLang]?.[key] || locales['en'][key] || key;
|
|
3193
|
+
return params ? interpolate(text, params) : text;
|
|
3106
3194
|
}
|
|
3107
3195
|
|
|
3108
3196
|
/**
|
|
@@ -3111,13 +3199,8 @@ export function t(key, params) {
|
|
|
3111
3199
|
* without mutating shared state. Falls back to en → key.
|
|
3112
3200
|
*/
|
|
3113
3201
|
export function tFor(key, lang, params) {
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
for (const [k, v] of Object.entries(params)) {
|
|
3117
|
-
text = text.replaceAll(`{${k}}`, v);
|
|
3118
|
-
}
|
|
3119
|
-
}
|
|
3120
|
-
return text;
|
|
3202
|
+
const text = locales[lang]?.[key] || locales['en'][key] || key;
|
|
3203
|
+
return params ? interpolate(text, params) : text;
|
|
3121
3204
|
}
|
|
3122
3205
|
|
|
3123
3206
|
/**
|
package/server/interceptor.js
CHANGED
|
@@ -1492,6 +1492,9 @@ export function setupInterceptor() {
|
|
|
1492
1492
|
response = await _originalFetch.call(this, _fetchUrl, _fetchOpts);
|
|
1493
1493
|
} catch (err) {
|
|
1494
1494
|
if (streamingBucket) _resetStreamingBucket();
|
|
1495
|
+
// The request will never produce a completion — release its v2 in-flight
|
|
1496
|
+
// count so the session isn't permanently blocked from shard rotation.
|
|
1497
|
+
if (_v2Handle) { try { _v2Writer.releaseHandle(_v2Handle); } catch { /* best-effort */ } _v2Handle = null; }
|
|
1495
1498
|
throw err;
|
|
1496
1499
|
}
|
|
1497
1500
|
|
|
@@ -1706,6 +1709,9 @@ export function setupInterceptor() {
|
|
|
1706
1709
|
}
|
|
1707
1710
|
} catch (err) {
|
|
1708
1711
|
_resetStreamingBucket();
|
|
1712
|
+
// The stream died before producing a completion — release the
|
|
1713
|
+
// v2 in-flight count so shard rotation isn't permanently blocked.
|
|
1714
|
+
if (_v2Handle) { try { _v2Writer.releaseHandle(_v2Handle); } catch { /* best-effort */ } _v2Handle = null; }
|
|
1709
1715
|
controller.error(err);
|
|
1710
1716
|
}
|
|
1711
1717
|
}
|
|
@@ -26,6 +26,7 @@ export class AsyncWriteQueue {
|
|
|
26
26
|
// typeof 防御:字符串 "1000" 能通过 > 0 协转检查,但后续字节比较会退化为字典序
|
|
27
27
|
this._highWaterMark = (typeof opts.highWaterMark === 'number' && opts.highWaterMark > 0)
|
|
28
28
|
? opts.highWaterMark : HIGH_WATER_MARK;
|
|
29
|
+
this._idleCbs = []; // one-shot drain-complete listeners (shard rotation)
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
_getPath() {
|
|
@@ -34,6 +35,10 @@ export class AsyncWriteQueue {
|
|
|
34
35
|
|
|
35
36
|
get filePath() { return this._getPath(); }
|
|
36
37
|
get pendingBytes() { return this._pendingBytes; }
|
|
38
|
+
/** True when no bytes are queued and no drain is in flight — a synchronous
|
|
39
|
+
* rename of a target path is safe only at this point (a chunked drain
|
|
40
|
+
* re-opens the path per chunk). Used by v2 shard rotation. */
|
|
41
|
+
get isIdle() { return this._pendingBytes === 0 && !this._draining; }
|
|
37
42
|
|
|
38
43
|
append(data, onDone) {
|
|
39
44
|
return this.appendTo(this._getPath(), data, onDone);
|
|
@@ -164,5 +169,18 @@ export class AsyncWriteQueue {
|
|
|
164
169
|
|
|
165
170
|
for (const resolve of this._flushResolvers) resolve();
|
|
166
171
|
this._flushResolvers.length = 0;
|
|
172
|
+
// Drain-complete callbacks (v2 shard rotation): a rotation armed while the
|
|
173
|
+
// queue was busy re-runs here, at the true idle point.
|
|
174
|
+
for (const cb of this._idleCbs.splice(0)) {
|
|
175
|
+
try { cb(); } catch { /* a listener must never break the drain path */ }
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Register a one-shot callback fired the next time the queue goes idle
|
|
180
|
+
* (queue empty + no drain in flight). Fires SYNCHRONOUSLY if already idle. */
|
|
181
|
+
onIdle(cb) {
|
|
182
|
+
if (typeof cb !== 'function') return;
|
|
183
|
+
if (this._queue.length === 0 && !this._draining) { try { cb(); } catch {} return; }
|
|
184
|
+
this._idleCbs.push(cb);
|
|
167
185
|
}
|
|
168
186
|
}
|
package/server/lib/auth.js
CHANGED
|
@@ -295,11 +295,14 @@ function escapeHtml(s) {
|
|
|
295
295
|
/**
|
|
296
296
|
* Self-contained login page (inline CSS + JS, references NO /assets — static assets
|
|
297
297
|
* are auth-exempt but we don't want to surface the SPA bundle to unauthenticated
|
|
298
|
-
* remotes). On submit it POSTs to
|
|
298
|
+
* remotes). On submit it POSTs to <basePath>api/auth/login and reloads on success.
|
|
299
299
|
*
|
|
300
300
|
* `lang` is a resolved locale code (caller derives it from Accept-Language).
|
|
301
|
+
* `basePath` is the effective deployment prefix (CCV_BASE_URL/CCV_BASE_PATH), normalized
|
|
302
|
+
* with a trailing slash ('' at root): a prefix-preserving reverse proxy would otherwise
|
|
303
|
+
* route the hardcoded '/api/auth/login' POST nowhere near ccv.
|
|
301
304
|
*/
|
|
302
|
-
export function renderLoginPage({ lang = 'en', error = false } = {}) {
|
|
305
|
+
export function renderLoginPage({ lang = 'en', error = false, basePath = '' } = {}) {
|
|
303
306
|
const dir = lang === 'ar' ? 'rtl' : 'ltr';
|
|
304
307
|
const title = escapeHtml(tFor('server.auth.loginTitle', lang));
|
|
305
308
|
const placeholder = escapeHtml(tFor('server.auth.loginPlaceholder', lang));
|
|
@@ -307,6 +310,11 @@ export function renderLoginPage({ lang = 'en', error = false } = {}) {
|
|
|
307
310
|
const errMsg = escapeHtml(tFor('server.auth.loginError', lang));
|
|
308
311
|
const toggleLabel = escapeHtml(tFor('server.auth.togglePassword', lang));
|
|
309
312
|
const errStyle = error ? '' : ' style="display:none"';
|
|
313
|
+
// Login POST target: always root-absolute. basePath carries its own trailing slash; without
|
|
314
|
+
// a prefix fall back to '/api/auth/login' — the login page is served for ANY HTML navigation
|
|
315
|
+
// path (deep links included) and a relative 'api/auth/login' would resolve against the
|
|
316
|
+
// document URL and miss the endpoint. JS string escape: \ -> \\, " -> \", </ -> <\/ .
|
|
317
|
+
const jsSafeBase = String(basePath || '/').replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/<\//g, '<\\/');
|
|
310
318
|
return `<!DOCTYPE html>
|
|
311
319
|
<html lang="${escapeHtml(lang)}" dir="${dir}" data-theme="dark">
|
|
312
320
|
<head>
|
|
@@ -387,7 +395,7 @@ export function renderLoginPage({ lang = 'en', error = false } = {}) {
|
|
|
387
395
|
f.addEventListener('submit', function (ev) {
|
|
388
396
|
ev.preventDefault();
|
|
389
397
|
b.disabled = true; e.style.display = 'none';
|
|
390
|
-
fetch(
|
|
398
|
+
fetch("${jsSafeBase}api/auth/login", {
|
|
391
399
|
method: 'POST',
|
|
392
400
|
headers: { 'Content-Type': 'application/json' },
|
|
393
401
|
body: JSON.stringify({ password: p.value })
|