vibe-coding-master 0.8.7 → 0.8.9
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 +7 -6
- package/dist/backend/api/task-routes.js +0 -6
- package/dist/backend/gateway/gateway-service.js +2 -18
- package/dist/backend/server.js +1 -4
- package/dist/backend/services/claude-hook-service.js +1 -16
- package/dist/backend/services/translation-service.js +0 -47
- package/dist/backend/services/workflow-control-service.js +2 -40
- package/dist/backend/templates/harness/project-manager-agent.js +1 -1
- package/dist/backend/templates/harness/vcm-ask-user-skill.js +1 -1
- package/dist-frontend/assets/{index-CqZm9xCA.js → index-BWbworWs.js} +1 -1
- package/dist-frontend/index.html +1 -1
- package/package.json +1 -1
- package/dist/backend/services/user-question-reply.js +0 -10
package/README.md
CHANGED
|
@@ -193,17 +193,18 @@ authoritative.
|
|
|
193
193
|
|
|
194
194
|
Whenever Project Manager asks the user a question, it first uses
|
|
195
195
|
`vcm-ask-user` with the complete question and necessary context. VCM records the
|
|
196
|
-
wait and cancels any pending role dispatch in one state update.
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
translation panel and Gateway
|
|
200
|
-
|
|
196
|
+
wait and cancels any pending role dispatch in one state update. PM then presents
|
|
197
|
+
the complete question and necessary context in its normal final reply. Stop Hook
|
|
198
|
+
ends the PM turn without route scanning. The CC session displays that reply;
|
|
199
|
+
the translation panel reads its transcript and Gateway reuses the same reply
|
|
200
|
+
and translation. Pause Alert remains a round-pause notice, not a question display.
|
|
201
|
+
While waiting, new dispatches, Gate requests/retries, and workflow
|
|
201
202
|
completion are blocked; already-running roles may still return results. Only
|
|
202
203
|
a new direct user message clears the wait, and the next role dispatch requires
|
|
203
204
|
a fresh Workflow Review. PM treats text emitted while a Round continues as
|
|
204
205
|
intermediate output, not as delivered user communication. When the Round pauses
|
|
205
206
|
or completes, its Round Final Reply contains the complete user-facing result or
|
|
206
|
-
|
|
207
|
+
question without relying on earlier PM output or tool arguments.
|
|
207
208
|
|
|
208
209
|
Typical flow:
|
|
209
210
|
|
|
@@ -65,12 +65,6 @@ export function registerTaskRoutes(app, deps) {
|
|
|
65
65
|
taskSlug
|
|
66
66
|
}) ?? Promise.resolve(degradedWorkflowState(taskSlug))
|
|
67
67
|
]);
|
|
68
|
-
if (roundState.flowPause?.paused && deps.workflowControlService) {
|
|
69
|
-
const workflow = await deps.workflowControlService.getState(context);
|
|
70
|
-
const reply = workflow.userQuestionReplies?.find((item) => item.requestedAt === workflow.awaitingUser?.requestedAt);
|
|
71
|
-
if (reply)
|
|
72
|
-
roundState.flowPause = { ...roundState.flowPause, message: reply.question };
|
|
73
|
-
}
|
|
74
68
|
const displayedRoundState = await delayFlowPauseForTranslation(deps, {
|
|
75
69
|
repoRoot: project.repoRoot,
|
|
76
70
|
taskRepoRoot,
|
|
@@ -2,7 +2,6 @@ import { getRoleDefinition, isVcmRoleName, VCM_ROLE_NAMES } from "../../shared/c
|
|
|
2
2
|
import { VcmError } from "../errors.js";
|
|
3
3
|
import { submitTerminalInput } from "../runtime/terminal-submit.js";
|
|
4
4
|
import { getTaskRuntimeRepoRoot } from "../services/task-service.js";
|
|
5
|
-
import { findUserQuestionReply } from "../services/user-question-reply.js";
|
|
6
5
|
import { resolveExistingClaudeTranscriptPath } from "../services/claude-transcript-service.js";
|
|
7
6
|
import { isFinalTurnTextEvent, readTranscriptTextEvents } from "../services/claude-transcript-reply.js";
|
|
8
7
|
import { parseGatewayCommand } from "./gateway-command-parser.js";
|
|
@@ -1163,16 +1162,10 @@ export function createGatewayService(deps) {
|
|
|
1163
1162
|
|| settings.targetRole !== role) {
|
|
1164
1163
|
return;
|
|
1165
1164
|
}
|
|
1166
|
-
const questionReply = role === "project-manager" && deps.workflowControlService
|
|
1167
|
-
? await readRegisteredQuestionReply(input)
|
|
1168
|
-
: undefined;
|
|
1169
1165
|
const transcriptPath = resolveExistingClaudeTranscriptPath(input.session);
|
|
1170
|
-
if (!
|
|
1166
|
+
if (!transcriptPath)
|
|
1171
1167
|
return;
|
|
1172
|
-
const events =
|
|
1173
|
-
id: questionReply.id, timestamp: questionReply.completedAt,
|
|
1174
|
-
text: questionReply.question, stopReason: "end_turn"
|
|
1175
|
-
}] : await readTranscriptTextEvents(transcriptPath);
|
|
1168
|
+
const events = await readTranscriptTextEvents(transcriptPath);
|
|
1176
1169
|
const round = await waitForGatewayRoundFinal(input.repoRoot, input.taskSlug, role);
|
|
1177
1170
|
if (!round) {
|
|
1178
1171
|
return;
|
|
@@ -1291,15 +1284,6 @@ export function createGatewayService(deps) {
|
|
|
1291
1284
|
};
|
|
1292
1285
|
}
|
|
1293
1286
|
};
|
|
1294
|
-
async function readRegisteredQuestionReply(input) {
|
|
1295
|
-
const task = await deps.taskService.loadTask(input.repoRoot, input.taskSlug);
|
|
1296
|
-
const config = await deps.projectService.loadConfig(input.repoRoot);
|
|
1297
|
-
const state = await deps.workflowControlService.getState({
|
|
1298
|
-
taskRepoRoot: getTaskRuntimeRepoRoot(task), taskSlug: input.taskSlug,
|
|
1299
|
-
stateRoot: config.stateRoot, handoffDir: task.handoffDir
|
|
1300
|
-
});
|
|
1301
|
-
return findUserQuestionReply(state, input.session.id, input.session.lastTurnEndedAt ?? input.session.updatedAt);
|
|
1302
|
-
}
|
|
1303
1287
|
function getLatestRoleReply(settings) {
|
|
1304
1288
|
if (!settings.currentProjectId || !settings.currentTaskSlug) {
|
|
1305
1289
|
return undefined;
|
package/dist/backend/server.js
CHANGED
|
@@ -136,8 +136,7 @@ export async function createServer(deps, options = {}) {
|
|
|
136
136
|
roundService: deps.roundService,
|
|
137
137
|
taskWorkflowService: deps.taskWorkflowService,
|
|
138
138
|
architectRestartService: deps.architectRestartService,
|
|
139
|
-
translationService: deps.translationService
|
|
140
|
-
workflowControlService: deps.workflowControlService
|
|
139
|
+
translationService: deps.translationService
|
|
141
140
|
});
|
|
142
141
|
registerSessionRoutes(app, {
|
|
143
142
|
projectService: deps.projectService,
|
|
@@ -354,7 +353,6 @@ export function createDefaultServerDeps(options = {}) {
|
|
|
354
353
|
});
|
|
355
354
|
const transcripts = createClaudeTranscriptService();
|
|
356
355
|
const translationService = createTranslationService({
|
|
357
|
-
workflowControlService,
|
|
358
356
|
runtime,
|
|
359
357
|
sessionRegistry: registry,
|
|
360
358
|
transcripts,
|
|
@@ -390,7 +388,6 @@ export function createDefaultServerDeps(options = {}) {
|
|
|
390
388
|
roleContextRestartService
|
|
391
389
|
});
|
|
392
390
|
const gatewayService = createGatewayService({
|
|
393
|
-
workflowControlService,
|
|
394
391
|
fs,
|
|
395
392
|
settings: gatewaySettings,
|
|
396
393
|
audit: gatewayAudit,
|
|
@@ -353,7 +353,7 @@ export function createClaudeHookService(deps) {
|
|
|
353
353
|
dispatchedCount: 0,
|
|
354
354
|
stopDecision: {
|
|
355
355
|
behavior: "block",
|
|
356
|
-
reason: `Possible unregistered user question: ${JSON.stringify(question.slice(0, 600))}. If you are asking the user, use vcm-ask-user
|
|
356
|
+
reason: `Possible unregistered user question: ${JSON.stringify(question.slice(0, 600))}. If you are asking the user, use vcm-ask-user, then present the complete question and necessary context in your final reply and end the turn without advancing or routing the workflow. If this only reports or quotes another question, clarify that context and end normally; do not invent a user question or register a false wait.`
|
|
357
357
|
}
|
|
358
358
|
};
|
|
359
359
|
}
|
|
@@ -508,21 +508,6 @@ export function createClaudeHookService(deps) {
|
|
|
508
508
|
if (!session) {
|
|
509
509
|
return completedHookResult(input, eventName);
|
|
510
510
|
}
|
|
511
|
-
if (eventName === "Stop" && input.role === "project-manager") {
|
|
512
|
-
const reply = await deps.workflowControlService?.completeUserQuestion?.(createWorkflowControlContext(context), {
|
|
513
|
-
sessionId: session.id,
|
|
514
|
-
startedAt: session.lastTurnStartedAt ?? session.updatedAt,
|
|
515
|
-
endedAt: session.lastTurnEndedAt ?? session.updatedAt
|
|
516
|
-
});
|
|
517
|
-
if (reply) {
|
|
518
|
-
await deps.translationService.recordUserQuestionReply?.({
|
|
519
|
-
repoRoot: context.project.repoRoot,
|
|
520
|
-
taskRepoRoot: context.taskRepoRoot,
|
|
521
|
-
taskSlug: context.taskSlug,
|
|
522
|
-
reply
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
511
|
const boundToTask = await isHookSessionBoundToTask(context, input.role);
|
|
527
512
|
if (boundToTask) {
|
|
528
513
|
await deps.roundService.recordClaudeHookEvent({
|
|
@@ -5,7 +5,6 @@ import { VcmError } from "../errors.js";
|
|
|
5
5
|
import { submitTerminalInput } from "../runtime/terminal-submit.js";
|
|
6
6
|
import { readLatestRoleTurnReply } from "./claude-transcript-reply.js";
|
|
7
7
|
import { createTranslationQueueRegistry } from "./translation-queue.js";
|
|
8
|
-
import { findUserQuestionReply, isPendingUserQuestion } from "./user-question-reply.js";
|
|
9
8
|
const TRANSLATION_SOURCE_LANGUAGE = "auto";
|
|
10
9
|
const TRANSLATION_INPUT_MODE = "review-before-send";
|
|
11
10
|
const TRANSLATION_CONTEXT_ENABLED = false;
|
|
@@ -241,22 +240,6 @@ export function createTranslationService(deps) {
|
|
|
241
240
|
return;
|
|
242
241
|
}
|
|
243
242
|
const config = await loadConfig();
|
|
244
|
-
if (state.role === "project-manager" && event.kind === "text" && event.stopReason === "end_turn"
|
|
245
|
-
&& !event.isSidechain && state.repoRoot && state.taskSlug && deps.workflowControlService && deps.projectService) {
|
|
246
|
-
const projectConfig = await deps.projectService.loadConfig(state.baseRepoRoot ?? state.repoRoot);
|
|
247
|
-
const workflow = await deps.workflowControlService.getState({
|
|
248
|
-
taskRepoRoot: state.repoRoot, taskSlug: state.taskSlug,
|
|
249
|
-
stateRoot: projectConfig.stateRoot, handoffDir: projectConfig.handoffRoot
|
|
250
|
-
});
|
|
251
|
-
const reply = findUserQuestionReply(workflow, sessionId, event.timestamp);
|
|
252
|
-
if (reply) {
|
|
253
|
-
publishUserQuestionReply(reply, config);
|
|
254
|
-
state.seenTranscriptIds.add(event.id);
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
if (isPendingUserQuestion(workflow, event.timestamp))
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
243
|
let displayed = false;
|
|
261
244
|
if (event.kind === "text") {
|
|
262
245
|
const shouldTranslate = shouldTranslateTextTranscriptEvent(state, event, config);
|
|
@@ -299,20 +282,6 @@ export function createTranslationService(deps) {
|
|
|
299
282
|
}
|
|
300
283
|
return true;
|
|
301
284
|
}
|
|
302
|
-
function publishUserQuestionReply(reply, config) {
|
|
303
|
-
const state = getState(reply.sessionId);
|
|
304
|
-
if (state.seenTranscriptIds.has(reply.id))
|
|
305
|
-
return;
|
|
306
|
-
const metadata = { transcriptStopReason: "end_turn", transcriptTimestamp: reply.completedAt };
|
|
307
|
-
// Claim before scheduling translation so Stop and transcript replay share one entry/job.
|
|
308
|
-
state.seenTranscriptIds.add(reply.id);
|
|
309
|
-
if (config.enabled === false || config.outputMode === "round-final") {
|
|
310
|
-
pushPreservedProseEntry(reply.sessionId, reply.id, reply.question, config, metadata);
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
processClaudeOutputText(reply.sessionId, reply.question, config, reply.id, { flushImmediately: true, metadata });
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
285
|
function processClaudeOutputText(sessionId, rawText, config, entryId, options = {}) {
|
|
317
286
|
return startClaudeOutputTranslation(sessionId, rawText, config, {
|
|
318
287
|
entryId,
|
|
@@ -679,12 +648,6 @@ export function createTranslationService(deps) {
|
|
|
679
648
|
return state;
|
|
680
649
|
}
|
|
681
650
|
return {
|
|
682
|
-
async recordUserQuestionReply(input) {
|
|
683
|
-
await prepareCache({ repoRoot: input.taskRepoRoot, baseRepoRoot: input.repoRoot,
|
|
684
|
-
taskSlug: input.taskSlug, role: "project-manager", sessionId: input.reply.sessionId });
|
|
685
|
-
publishUserQuestionReply(input.reply, await loadConfig());
|
|
686
|
-
await persistEvents(getState(input.reply.sessionId));
|
|
687
|
-
},
|
|
688
651
|
async startSession(input) {
|
|
689
652
|
const roleSession = await deps.sessionService.getRoleSession(input.repoRoot, input.taskSlug, input.role);
|
|
690
653
|
if (!roleSession || roleSession.status !== "running") {
|
|
@@ -758,16 +721,6 @@ export function createTranslationService(deps) {
|
|
|
758
721
|
status: state.status
|
|
759
722
|
});
|
|
760
723
|
}
|
|
761
|
-
if (deps.workflowControlService && deps.projectService) {
|
|
762
|
-
const projectConfig = await deps.projectService.loadConfig(input.repoRoot);
|
|
763
|
-
const workflow = await deps.workflowControlService.getState({ ...input,
|
|
764
|
-
stateRoot: projectConfig.stateRoot, handoffDir: projectConfig.handoffRoot });
|
|
765
|
-
for (const reply of workflow.userQuestionReplies ?? []) {
|
|
766
|
-
if (feedSessions.some((session) => session.role === "project-manager" && session.sessionId === reply.sessionId)) {
|
|
767
|
-
publishUserQuestionReply(reply, config);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
724
|
if (config.outputMode === "round-final") {
|
|
772
725
|
await translateRoundFinalReplyIfReady(input, config);
|
|
773
726
|
}
|
|
@@ -317,7 +317,6 @@ export function createWorkflowControlService(deps) {
|
|
|
317
317
|
},
|
|
318
318
|
requestUserInput,
|
|
319
319
|
resolveUserInput,
|
|
320
|
-
completeUserQuestion,
|
|
321
320
|
runWhileNotAwaitingUser,
|
|
322
321
|
submitProgress,
|
|
323
322
|
assertDocsArtifactAllowed,
|
|
@@ -418,30 +417,6 @@ export function createWorkflowControlService(deps) {
|
|
|
418
417
|
return run();
|
|
419
418
|
});
|
|
420
419
|
}
|
|
421
|
-
async function completeUserQuestion(input, turn) {
|
|
422
|
-
return withLock(statePath(input), async () => {
|
|
423
|
-
const state = await getState(input);
|
|
424
|
-
failOnStateWarnings(state);
|
|
425
|
-
const question = state.awaitingUser;
|
|
426
|
-
if (!question)
|
|
427
|
-
return undefined;
|
|
428
|
-
const replies = state.userQuestionReplies ?? [];
|
|
429
|
-
const existing = replies.find((reply) => reply.requestedAt === question.requestedAt);
|
|
430
|
-
if (existing)
|
|
431
|
-
return existing.sessionId === turn.sessionId ? existing : undefined;
|
|
432
|
-
if (question.requestedAt > turn.endedAt)
|
|
433
|
-
return undefined;
|
|
434
|
-
const reply = {
|
|
435
|
-
...question,
|
|
436
|
-
id: `user-question:${turn.sessionId}:${question.requestedAt}`,
|
|
437
|
-
sessionId: turn.sessionId,
|
|
438
|
-
turnStartedAt: turn.startedAt,
|
|
439
|
-
completedAt: turn.endedAt
|
|
440
|
-
};
|
|
441
|
-
await saveState(input, { ...state, userQuestionReplies: [...replies, reply], updatedAt: now() });
|
|
442
|
-
return reply;
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
420
|
async function saveState(input, state) {
|
|
446
421
|
await deps.fs.writeJsonAtomic(statePath(input), state);
|
|
447
422
|
}
|
|
@@ -1376,24 +1351,18 @@ function normalizeState(value, taskSlug, timestamp) {
|
|
|
1376
1351
|
const awaitingUser = value.awaitingUser === undefined || value.awaitingUser === null
|
|
1377
1352
|
? null
|
|
1378
1353
|
: isAwaitingUser(value.awaitingUser) ? value.awaitingUser : undefined;
|
|
1379
|
-
const validQuestionReplies = value.userQuestionReplies === undefined
|
|
1380
|
-
|| (Array.isArray(value.userQuestionReplies) && value.userQuestionReplies.every(isUserQuestionReply));
|
|
1381
1354
|
if (pendingDispatch === undefined
|
|
1382
1355
|
|| activeDispatch === undefined
|
|
1383
1356
|
|| flowRun === undefined
|
|
1384
1357
|
|| userAuthorizations === undefined
|
|
1385
1358
|
|| userApprovedFollowUps === undefined
|
|
1386
|
-
|| awaitingUser === undefined
|
|
1387
|
-
|| !validQuestionReplies) {
|
|
1359
|
+
|| awaitingUser === undefined) {
|
|
1388
1360
|
return { ...emptyState(taskSlug, timestamp), warnings: ["Workflow control state has an unsupported shape."] };
|
|
1389
1361
|
}
|
|
1390
1362
|
return {
|
|
1391
1363
|
version: 1,
|
|
1392
1364
|
taskSlug,
|
|
1393
1365
|
awaitingUser,
|
|
1394
|
-
...(Array.isArray(value.userQuestionReplies) ? {
|
|
1395
|
-
userQuestionReplies: value.userQuestionReplies
|
|
1396
|
-
} : {}),
|
|
1397
1366
|
pendingDispatch,
|
|
1398
1367
|
activeDispatch,
|
|
1399
1368
|
flowRun,
|
|
@@ -1403,13 +1372,6 @@ function normalizeState(value, taskSlug, timestamp) {
|
|
|
1403
1372
|
updatedAt: typeof value.updatedAt === "string" ? value.updatedAt : timestamp
|
|
1404
1373
|
};
|
|
1405
1374
|
}
|
|
1406
|
-
function isUserQuestionReply(value) {
|
|
1407
|
-
if (!value || typeof value !== "object")
|
|
1408
|
-
return false;
|
|
1409
|
-
const reply = value;
|
|
1410
|
-
return [reply.id, reply.sessionId, reply.question, reply.requestedAt, reply.turnStartedAt, reply.completedAt]
|
|
1411
|
-
.every((field) => typeof field === "string" && field.length > 0);
|
|
1412
|
-
}
|
|
1413
1375
|
function emptyState(taskSlug, timestamp) {
|
|
1414
1376
|
return {
|
|
1415
1377
|
version: 1,
|
|
@@ -1487,7 +1449,7 @@ function failOnStateWarnings(state) {
|
|
|
1487
1449
|
function failWhileAwaitingUser(state) {
|
|
1488
1450
|
if (!state.awaitingUser)
|
|
1489
1451
|
return;
|
|
1490
|
-
throw workflowError("WORKFLOW_AWAITING_USER", "Project Manager
|
|
1452
|
+
throw workflowError("WORKFLOW_AWAITING_USER", "vcm-ask-user has registered a user question; Project Manager cannot advance the workflow. Present the complete question and necessary context in your final reply, end the current turn, and wait for a new direct user message.", "The previous workflow approval was canceled; request a fresh approval after the answer arrives.");
|
|
1491
1453
|
}
|
|
1492
1454
|
function progressValidationError(errors) {
|
|
1493
1455
|
return workflowError("WORKFLOW_PROGRESS_INVALID", `Workflow Progress validation failed:\n${errors.map((error) => `- ${error}`).join("\n")}`);
|
|
@@ -21,7 +21,7 @@ ${renderRoleMemoryRules("project-manager")}
|
|
|
21
21
|
- Assistant text emitted before a tool call or role dispatch while the current Round continues is not user communication. Do not use intermediate text to deliver status, findings, decisions, questions, or required actions to the user.
|
|
22
22
|
- The user is informed only by PM's Round Final Reply when the Round pauses for user input or reaches a terminal result.
|
|
23
23
|
- The Round Final Reply must be self-contained. Restate every result, blocker, decision, risk, and required user action needed to understand the current state. Never rely on earlier PM text in the same Round.
|
|
24
|
-
- When asking the user a question,
|
|
24
|
+
- When asking the user a question, register it through \`vcm-ask-user\`. After the tool returns \`awaiting_user\`, present the complete question and necessary context in your final reply, then end the turn and wait for the user.
|
|
25
25
|
- Explain task status, blockers, role results, and decisions in user-facing language.
|
|
26
26
|
- Prefer plain logic over code-level detail: describe what changed, why it matters, what risk remains, and what decision is needed.
|
|
27
27
|
- Exclude irrelevant implementation detail, but retain the technical facts needed to explain the cause, evidence, impact, and unresolved state. Plain language means translating technical detail, not deleting it.
|
|
@@ -11,7 +11,7 @@ Submit the complete user-facing question, including the context needed to answer
|
|
|
11
11
|
.ai/tools/vcm-ask-user --question "<exact question>"
|
|
12
12
|
\`\`\`
|
|
13
13
|
|
|
14
|
-
After the tool returns \`awaiting_user\`,
|
|
14
|
+
After the tool returns \`awaiting_user\`, present the complete question and necessary context in your final reply, then end the turn and wait for the user. The tool registers the workflow wait; it does not deliver your question. Do not request Workflow Review, write a route message, run a Gate, or advance the workflow in the same turn.
|
|
15
15
|
|
|
16
16
|
Every question pauses the workflow. PM may defer a question by not asking it; once PM asks, only a new direct user message resumes the workflow. The previous workflow approval is canceled, so request a fresh approval before the next dispatch.
|
|
17
17
|
`;
|
|
@@ -90,7 +90,7 @@ WARNING: This link could potentially be dangerous`)){const v=window.open();if(v)
|
|
|
90
90
|
`))}function c(x,T,E,y){const v=E.enter("tableCell"),_=E.enter("phrasing"),b=E.containerPhrasing(x,{...y,before:m,after:m});return _(),v(),b}function u(x,T){return $x(x,{align:T,alignDelimiters:l,padding:s,stringLength:d})}function g(x,T,E){const y=x.children;let v=-1;const _=[],b=T.enter("table");for(;++v<y.length;)_[v]=h(y[v],T,E);return b(),_}function h(x,T,E){const y=x.children;let v=-1;const _=[],b=T.enter("tableRow");for(;++v<y.length;)_[v]=c(y[v],x,T,E);return b(),_}function S(x,T,E){let y=yv.inlineCode(x,T,E);return E.stack.includes("tableCell")&&(y=y.replace(/\|/g,"\\$&")),y}}function ME(){return{exit:{taskListCheckValueChecked:Wg,taskListCheckValueUnchecked:Wg,paragraph:OE}}}function LE(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:BE}}}function Wg(t){const r=this.stack[this.stack.length-2];r.type,r.checked=t.type==="taskListCheckValueChecked"}function OE(t){const r=this.stack[this.stack.length-2];if(r&&r.type==="listItem"&&typeof r.checked=="boolean"){const s=this.stack[this.stack.length-1];s.type;const l=s.children[0];if(l&&l.type==="text"){const d=r.children;let m=-1,f;for(;++m<d.length;){const o=d[m];if(o.type==="paragraph"){f=o;break}}f===s&&(l.value=l.value.slice(1),l.value.length===0?s.children.shift():s.position&&l.position&&typeof l.position.start.offset=="number"&&(l.position.start.column++,l.position.start.offset++,s.position.start=Object.assign({},l.position.start)))}}this.exit(t)}function BE(t,r,s,l){const d=t.children[0],m=typeof t.checked=="boolean"&&d&&d.type==="paragraph",f="["+(t.checked?"x":" ")+"] ",o=s.createTracker(l);m&&o.move(f);let c=yv.listItem(t,r,s,{...l,...o.current()});return m&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),c;function u(g){return g+f}}function jE(){return[dx(),Bx(),zx(),xE(),ME()]}function NE(t){return{extensions:[px(),jx(t),Ix(),DE(t),LE()]}}const HE={tokenize:qE,partial:!0},Sv={tokenize:$E,partial:!0},bv={tokenize:GE,partial:!0},Cv={tokenize:VE,partial:!0},zE={tokenize:WE,partial:!0},wv={name:"wwwAutolink",tokenize:PE,previous:Ev},xv={name:"protocolAutolink",tokenize:FE,previous:kv},Ui={name:"emailAutolink",tokenize:UE,previous:Av},pi={};function IE(){return{text:pi}}let Wr=48;for(;Wr<123;)pi[Wr]=Ui,Wr++,Wr===58?Wr=65:Wr===91&&(Wr=97);pi[43]=Ui;pi[45]=Ui;pi[46]=Ui;pi[95]=Ui;pi[72]=[Ui,xv];pi[104]=[Ui,xv];pi[87]=[Ui,wv];pi[119]=[Ui,wv];function UE(t,r,s){const l=this;let d,m;return f;function f(h){return!Nh(h)||!Av.call(l,l.previous)||sf(l.events)?s(h):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),o(h))}function o(h){return Nh(h)?(t.consume(h),o):h===64?(t.consume(h),c):s(h)}function c(h){return h===46?t.check(zE,g,u)(h):h===45||h===95||tn(h)?(m=!0,t.consume(h),c):g(h)}function u(h){return t.consume(h),d=!0,c}function g(h){return m&&d&&un(l.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),r(h)):s(h)}}function PE(t,r,s){const l=this;return d;function d(f){return f!==87&&f!==119||!Ev.call(l,l.previous)||sf(l.events)?s(f):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(HE,t.attempt(Sv,t.attempt(bv,m),s),s)(f))}function m(f){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),r(f)}}function FE(t,r,s){const l=this;let d="",m=!1;return f;function f(h){return(h===72||h===104)&&kv.call(l,l.previous)&&!sf(l.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),d+=String.fromCodePoint(h),t.consume(h),o):s(h)}function o(h){if(un(h)&&d.length<5)return d+=String.fromCodePoint(h),t.consume(h),o;if(h===58){const S=d.toLowerCase();if(S==="http"||S==="https")return t.consume(h),c}return s(h)}function c(h){return h===47?(t.consume(h),m?u:(m=!0,c)):s(h)}function u(h){return h===null||Oo(h)||pt(h)||Xr(h)||Fo(h)?s(h):t.attempt(Sv,t.attempt(bv,g),s)(h)}function g(h){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),r(h)}}function qE(t,r,s){let l=0;return d;function d(f){return(f===87||f===119)&&l<3?(l++,t.consume(f),d):f===46&&l===3?(t.consume(f),m):s(f)}function m(f){return f===null?s(f):r(f)}}function $E(t,r,s){let l,d,m;return f;function f(u){return u===46||u===95?t.check(Cv,c,o)(u):u===null||pt(u)||Xr(u)||u!==45&&Fo(u)?c(u):(m=!0,t.consume(u),f)}function o(u){return u===95?l=!0:(d=l,l=void 0),t.consume(u),f}function c(u){return d||l||!m?s(u):r(u)}}function GE(t,r){let s=0,l=0;return d;function d(f){return f===40?(s++,t.consume(f),d):f===41&&l<s?m(f):f===33||f===34||f===38||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===60||f===63||f===93||f===95||f===126?t.check(Cv,r,m)(f):f===null||pt(f)||Xr(f)?r(f):(t.consume(f),d)}function m(f){return f===41&&l++,t.consume(f),d}}function VE(t,r,s){return l;function l(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(t.consume(o),l):o===38?(t.consume(o),m):o===93?(t.consume(o),d):o===60||o===null||pt(o)||Xr(o)?r(o):s(o)}function d(o){return o===null||o===40||o===91||pt(o)||Xr(o)?r(o):l(o)}function m(o){return un(o)?f(o):s(o)}function f(o){return o===59?(t.consume(o),l):un(o)?(t.consume(o),f):s(o)}}function WE(t,r,s){return l;function l(m){return t.consume(m),d}function d(m){return tn(m)?s(m):r(m)}}function Ev(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||pt(t)}function kv(t){return!un(t)}function Av(t){return!(t===47||Nh(t))}function Nh(t){return t===43||t===45||t===46||t===95||tn(t)}function sf(t){let r=t.length,s=!1;for(;r--;){const l=t[r][1];if((l.type==="labelLink"||l.type==="labelImage")&&!l._balanced){s=!0;break}if(l._gfmAutolinkLiteralWalkedInto){s=!1;break}}return t.length>0&&!s&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),s}const KE={tokenize:nk,partial:!0};function YE(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:ZE,continuation:{tokenize:ek},exit:tk}},text:{91:{name:"gfmFootnoteCall",tokenize:JE},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:XE,resolveTo:QE}}}}function XE(t,r,s){const l=this;let d=l.events.length;const m=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let f;for(;d--;){const c=l.events[d][1];if(c.type==="labelImage"){f=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return o;function o(c){if(!f||!f._balanced)return s(c);const u=ri(l.sliceSerialize({start:f.end,end:l.now()}));return u.codePointAt(0)!==94||!m.includes(u.slice(1))?s(c):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(c),t.exit("gfmFootnoteCallLabelMarker"),r(c))}}function QE(t,r){let s=t.length;for(;s--;)if(t[s][1].type==="labelImage"&&t[s][0]==="enter"){t[s][1];break}t[s+1][1].type="data",t[s+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},t[s+3][1].start),end:Object.assign({},t[t.length-1][1].end)},d={type:"gfmFootnoteCallMarker",start:Object.assign({},t[s+3][1].end),end:Object.assign({},t[s+3][1].end)};d.end.column++,d.end.offset++,d.end._bufferIndex++;const m={type:"gfmFootnoteCallString",start:Object.assign({},d.end),end:Object.assign({},t[t.length-1][1].start)},f={type:"chunkString",contentType:"string",start:Object.assign({},m.start),end:Object.assign({},m.end)},o=[t[s+1],t[s+2],["enter",l,r],t[s+3],t[s+4],["enter",d,r],["exit",d,r],["enter",m,r],["enter",f,r],["exit",f,r],["exit",m,r],t[t.length-2],t[t.length-1],["exit",l,r]];return t.splice(s,t.length-s+1,...o),t}function JE(t,r,s){const l=this,d=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let m=0,f;return o;function o(h){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),c}function c(h){return h!==94?s(h):(t.enter("gfmFootnoteCallMarker"),t.consume(h),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",u)}function u(h){if(m>999||h===93&&!f||h===null||h===91||pt(h))return s(h);if(h===93){t.exit("chunkString");const S=t.exit("gfmFootnoteCallString");return d.includes(ri(l.sliceSerialize(S)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),r):s(h)}return pt(h)||(f=!0),m++,t.consume(h),h===92?g:u}function g(h){return h===91||h===92||h===93?(t.consume(h),m++,u):u(h)}}function ZE(t,r,s){const l=this,d=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let m,f=0,o;return c;function c(T){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(T),t.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(T){return T===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(T),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",g):s(T)}function g(T){if(f>999||T===93&&!o||T===null||T===91||pt(T))return s(T);if(T===93){t.exit("chunkString");const E=t.exit("gfmFootnoteDefinitionLabelString");return m=ri(l.sliceSerialize(E)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(T),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),S}return pt(T)||(o=!0),f++,t.consume(T),T===92?h:g}function h(T){return T===91||T===92||T===93?(t.consume(T),f++,g):g(T)}function S(T){return T===58?(t.enter("definitionMarker"),t.consume(T),t.exit("definitionMarker"),d.includes(m)||d.push(m),et(t,x,"gfmFootnoteDefinitionWhitespace")):s(T)}function x(T){return r(T)}}function ek(t,r,s){return t.check(hl,r,t.attempt(KE,r,s))}function tk(t){t.exit("gfmFootnoteDefinition")}function nk(t,r,s){const l=this;return et(t,d,"gfmFootnoteDefinitionIndent",5);function d(m){const f=l.events[l.events.length-1];return f&&f[1].type==="gfmFootnoteDefinitionIndent"&&f[2].sliceSerialize(f[1],!0).length===4?r(m):s(m)}}function ik(t){let s=(t||{}).singleTilde;const l={name:"strikethrough",tokenize:m,resolveAll:d};return s==null&&(s=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function d(f,o){let c=-1;for(;++c<f.length;)if(f[c][0]==="enter"&&f[c][1].type==="strikethroughSequenceTemporary"&&f[c][1]._close){let u=c;for(;u--;)if(f[u][0]==="exit"&&f[u][1].type==="strikethroughSequenceTemporary"&&f[u][1]._open&&f[c][1].end.offset-f[c][1].start.offset===f[u][1].end.offset-f[u][1].start.offset){f[c][1].type="strikethroughSequence",f[u][1].type="strikethroughSequence";const g={type:"strikethrough",start:Object.assign({},f[u][1].start),end:Object.assign({},f[c][1].end)},h={type:"strikethroughText",start:Object.assign({},f[u][1].end),end:Object.assign({},f[c][1].start)},S=[["enter",g,o],["enter",f[u][1],o],["exit",f[u][1],o],["enter",h,o]],x=o.parser.constructs.insideSpan.null;x&&Nn(S,S.length,0,qo(x,f.slice(u+1,c),o)),Nn(S,S.length,0,[["exit",h,o],["enter",f[c][1],o],["exit",f[c][1],o],["exit",g,o]]),Nn(f,u-1,c-u+3,S),c=u+S.length-2;break}}for(c=-1;++c<f.length;)f[c][1].type==="strikethroughSequenceTemporary"&&(f[c][1].type="data");return f}function m(f,o,c){const u=this.previous,g=this.events;let h=0;return S;function S(T){return u===126&&g[g.length-1][1].type!=="characterEscape"?c(T):(f.enter("strikethroughSequenceTemporary"),x(T))}function x(T){const E=Vs(u);if(T===126)return h>1?c(T):(f.consume(T),h++,x);if(h<2&&!s)return c(T);const y=f.exit("strikethroughSequenceTemporary"),v=Vs(T);return y._open=!v||v===2&&!!E,y._close=!E||E===2&&!!v,o(T)}}}class rk{constructor(){this.map=[]}add(r,s,l){sk(this,r,s,l)}consume(r){if(this.map.sort(function(m,f){return m[0]-f[0]}),this.map.length===0)return;let s=this.map.length;const l=[];for(;s>0;)s-=1,l.push(r.slice(this.map[s][0]+this.map[s][1]),this.map[s][2]),r.length=this.map[s][0];l.push(r.slice()),r.length=0;let d=l.pop();for(;d;){for(const m of d)r.push(m);d=l.pop()}this.map.length=0}}function sk(t,r,s,l){let d=0;if(!(s===0&&l.length===0)){for(;d<t.map.length;){if(t.map[d][0]===r){t.map[d][1]+=s,t.map[d][2].push(...l);return}d+=1}t.map.push([r,s,l])}}function ak(t,r){let s=!1;const l=[];for(;r<t.length;){const d=t[r];if(s){if(d[0]==="enter")d[1].type==="tableContent"&&l.push(t[r+1][1].type==="tableDelimiterMarker"?"left":"none");else if(d[1].type==="tableContent"){if(t[r-1][1].type==="tableDelimiterMarker"){const m=l.length-1;l[m]=l[m]==="left"?"center":"right"}}else if(d[1].type==="tableDelimiterRow")break}else d[0]==="enter"&&d[1].type==="tableDelimiterRow"&&(s=!0);r+=1}return l}function lk(){return{flow:{null:{name:"table",tokenize:ok,resolveAll:ck}}}}function ok(t,r,s){const l=this;let d=0,m=0,f;return o;function o(O){let H=l.events.length-1;for(;H>-1;){const W=l.events[H][1].type;if(W==="lineEnding"||W==="linePrefix")H--;else break}const U=H>-1?l.events[H][1].type:null,P=U==="tableHead"||U==="tableRow"?R:c;return P===R&&l.parser.lazy[l.now().line]?s(O):P(O)}function c(O){return t.enter("tableHead"),t.enter("tableRow"),u(O)}function u(O){return O===124||(f=!0,m+=1),g(O)}function g(O){return O===null?s(O):Me(O)?m>1?(m=0,l.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(O),t.exit("lineEnding"),x):s(O):Ye(O)?et(t,g,"whitespace")(O):(m+=1,f&&(f=!1,d+=1),O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),f=!0,g):(t.enter("data"),h(O)))}function h(O){return O===null||O===124||pt(O)?(t.exit("data"),g(O)):(t.consume(O),O===92?S:h)}function S(O){return O===92||O===124?(t.consume(O),h):h(O)}function x(O){return l.interrupt=!1,l.parser.lazy[l.now().line]?s(O):(t.enter("tableDelimiterRow"),f=!1,Ye(O)?et(t,T,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):T(O))}function T(O){return O===45||O===58?y(O):O===124?(f=!0,t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),E):L(O)}function E(O){return Ye(O)?et(t,y,"whitespace")(O):y(O)}function y(O){return O===58?(m+=1,f=!0,t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),v):O===45?(m+=1,v(O)):O===null||Me(O)?k(O):L(O)}function v(O){return O===45?(t.enter("tableDelimiterFiller"),_(O)):L(O)}function _(O){return O===45?(t.consume(O),_):O===58?(f=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),b):(t.exit("tableDelimiterFiller"),b(O))}function b(O){return Ye(O)?et(t,k,"whitespace")(O):k(O)}function k(O){return O===124?T(O):O===null||Me(O)?!f||d!==m?L(O):(t.exit("tableDelimiterRow"),t.exit("tableHead"),r(O)):L(O)}function L(O){return s(O)}function R(O){return t.enter("tableRow"),D(O)}function D(O){return O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),D):O===null||Me(O)?(t.exit("tableRow"),r(O)):Ye(O)?et(t,D,"whitespace")(O):(t.enter("data"),A(O))}function A(O){return O===null||O===124||pt(O)?(t.exit("data"),D(O)):(t.consume(O),O===92?M:A)}function M(O){return O===92||O===124?(t.consume(O),A):A(O)}}function ck(t,r){let s=-1,l=!0,d=0,m=[0,0,0,0],f=[0,0,0,0],o=!1,c=0,u,g,h;const S=new rk;for(;++s<t.length;){const x=t[s],T=x[1];x[0]==="enter"?T.type==="tableHead"?(o=!1,c!==0&&(Kg(S,r,c,u,g),g=void 0,c=0),u={type:"table",start:Object.assign({},T.start),end:Object.assign({},T.end)},S.add(s,0,[["enter",u,r]])):T.type==="tableRow"||T.type==="tableDelimiterRow"?(l=!0,h=void 0,m=[0,0,0,0],f=[0,s+1,0,0],o&&(o=!1,g={type:"tableBody",start:Object.assign({},T.start),end:Object.assign({},T.end)},S.add(s,0,[["enter",g,r]])),d=T.type==="tableDelimiterRow"?2:g?3:1):d&&(T.type==="data"||T.type==="tableDelimiterMarker"||T.type==="tableDelimiterFiller")?(l=!1,f[2]===0&&(m[1]!==0&&(f[0]=f[1],h=To(S,r,m,d,void 0,h),m=[0,0,0,0]),f[2]=s)):T.type==="tableCellDivider"&&(l?l=!1:(m[1]!==0&&(f[0]=f[1],h=To(S,r,m,d,void 0,h)),m=f,f=[m[1],s,0,0])):T.type==="tableHead"?(o=!0,c=s):T.type==="tableRow"||T.type==="tableDelimiterRow"?(c=s,m[1]!==0?(f[0]=f[1],h=To(S,r,m,d,s,h)):f[1]!==0&&(h=To(S,r,f,d,s,h)),d=0):d&&(T.type==="data"||T.type==="tableDelimiterMarker"||T.type==="tableDelimiterFiller")&&(f[3]=s)}for(c!==0&&Kg(S,r,c,u,g),S.consume(r.events),s=-1;++s<r.events.length;){const x=r.events[s];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=ak(r.events,s))}return t}function To(t,r,s,l,d,m){const f=l===1?"tableHeader":l===2?"tableDelimiter":"tableData",o="tableContent";s[0]!==0&&(m.end=Object.assign({},Fs(r.events,s[0])),t.add(s[0],0,[["exit",m,r]]));const c=Fs(r.events,s[1]);if(m={type:f,start:Object.assign({},c),end:Object.assign({},c)},t.add(s[1],0,[["enter",m,r]]),s[2]!==0){const u=Fs(r.events,s[2]),g=Fs(r.events,s[3]),h={type:o,start:Object.assign({},u),end:Object.assign({},g)};if(t.add(s[2],0,[["enter",h,r]]),l!==2){const S=r.events[s[2]],x=r.events[s[3]];if(S[1].end=Object.assign({},x[1].end),S[1].type="chunkText",S[1].contentType="text",s[3]>s[2]+1){const T=s[2]+1,E=s[3]-s[2]-1;t.add(T,E,[])}}t.add(s[3]+1,0,[["exit",h,r]])}return d!==void 0&&(m.end=Object.assign({},Fs(r.events,d)),t.add(d,0,[["exit",m,r]]),m=void 0),m}function Kg(t,r,s,l,d){const m=[],f=Fs(r.events,s);d&&(d.end=Object.assign({},f),m.push(["exit",d,r])),l.end=Object.assign({},f),m.push(["exit",l,r]),t.add(s+1,0,m)}function Fs(t,r){const s=t[r],l=s[0]==="enter"?"start":"end";return s[1][l]}const uk={name:"tasklistCheck",tokenize:fk};function hk(){return{text:{91:uk}}}function fk(t,r,s){const l=this;return d;function d(c){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?s(c):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(c),t.exit("taskListCheckMarker"),m)}function m(c){return pt(c)?(t.enter("taskListCheckValueUnchecked"),t.consume(c),t.exit("taskListCheckValueUnchecked"),f):c===88||c===120?(t.enter("taskListCheckValueChecked"),t.consume(c),t.exit("taskListCheckValueChecked"),f):s(c)}function f(c){return c===93?(t.enter("taskListCheckMarker"),t.consume(c),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),o):s(c)}function o(c){return Me(c)?r(c):Ye(c)?t.check({tokenize:dk},r,s)(c):s(c)}}function dk(t,r,s){return et(t,l,"whitespace");function l(d){return d===null?s(d):r(d)}}function pk(t){return H_([IE(),YE(),ik(t),lk(),hk()])}const mk={};function Tv(t){const r=this,s=t||mk,l=r.data(),d=l.micromarkExtensions||(l.micromarkExtensions=[]),m=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),f=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);d.push(pk(s)),m.push(jE()),f.push(NE(s))}const Rv=1e3,qs=new Map;let il;function gk(t,r,s){const l=Symbol(t),d=Math.max(Rv,s.intervalMs),m=Date.now();return qs.set(t,{id:t,intervalMs:d,nextRunAt:s.runImmediately===!1?m+d:m,inFlight:!1,run:r,token:l}),_k(),Dv(),()=>{const f=qs.get(t);(f==null?void 0:f.token)===l&&(qs.delete(t),qs.size===0&&il!==void 0&&(window.clearInterval(il),il=void 0))}}function _k(){il!==void 0||typeof window>"u"||(il=window.setInterval(()=>{Dv()},Rv))}async function Dv(){const t=Date.now();for(const r of qs.values())r.inFlight||r.nextRunAt>t||vk(r)}async function vk(t){t.inFlight=!0;try{await t.run()}catch{}finally{const r=qs.get(t.id);(r==null?void 0:r.token)===t.token&&(r.inFlight=!1,r.nextRunAt=Date.now()+r.intervalMs)}}function ol(t,r,s){const l=ee.useRef(r);ee.useEffect(()=>{l.current=r},[r]),ee.useEffect(()=>{if(!(!t||s.enabled===!1))return gk(t,()=>l.current(),{intervalMs:s.intervalMs,runImmediately:s.runImmediately})},[t,s.enabled,s.intervalMs,s.runImmediately])}const Ho=`
|
|
91
91
|
|
|
92
92
|
--- Translation ---
|
|
93
|
-
`;function yk({active:t=!0,autoSendEnabled:r,targetLanguage:s,taskSlug:l,role:d,sessionId:m,panelState:f,onClearSession:o,onEntry:c,onFailures:u}){const[g,h]=ee.useState(""),[S,x]=ee.useState(""),[T,E]=ee.useState(!1),[y,v]=ee.useState(Date.now()),[_,b]=ee.useState(!1),[,k]=Ii(""),L=ee.useRef(null),R=f.entries,D=f.failures,A=f.status;ee.useEffect(()=>{if(!t)return;const N=L.current;if(!N)return;const q=window.requestAnimationFrame(()=>{N.scrollTop=N.scrollHeight});return()=>window.cancelAnimationFrame(q)},[t,R]);const M=Ak(R);ee.useEffect(()=>{if(!M)return;v(Date.now());const N=window.setInterval(()=>v(Date.now()),250);return()=>window.clearInterval(N)},[M]);async function O(N=!1){const q=g;b(!0),k(""),E(!1);try{const I=await ye.translateUserInput(l,d,{text:q,mode:N?"auto-send":"review-before-send",useContext:!1,send:N});I.sent?(h(""),E(!1)):(h(Lv(q,I.englishPreview)),E(!0))}catch(I){k(ft("Translate composer input",I))}finally{b(!1)}}async function H(){const N=S.trim();if(N){b(!0),k("");try{const q=await ye.translateManualOutput(l,d,{text:N});c(m,d,q),x("")}catch(q){k(ft("Translate pasted English output",q))}finally{b(!1)}}}async function U(){b(!0),k("");try{const N=await ye.translateLatestReply(l,d);c(m,d,N)}catch(N){k(ft("Translate final reply",N))}finally{b(!1)}}async function P(){const N=T?Xg(g):g;if(N.trim()){b(!0),k("");try{await ye.sendTranslatedInput(l,d,{englishText:N}),h(""),E(!1)}catch(q){k(ft("Send translated English input to role",q))}finally{b(!1)}}}function W(N){N.key!=="Enter"||N.shiftKey||N.nativeEvent.isComposing||(N.preventDefault(),!_&&g.trim()&&(T?P():O(r)))}async function K(){o(m,d),await ye.clearTranslationSession(m).catch(N=>k(ft("Clear conversation translation panel",N)))}async function V(){b(!0),k("");try{const N=await ye.ignoreTranslationFailures(m);u(m,d,N.failures)}catch(N){k(ft("Ignore failed conversation translations",N))}finally{b(!1)}}async function Y(N){b(!0),k("");try{const q=await ye.retryTranslation(m,N.translationId);c(m,d,q)}catch(q){k(ft("Retry latest failed conversation translation",q))}finally{b(!1)}}const te=Tk(R,A,y),z=D.length,j=bk(D);return C.jsxs("aside",{className:"translation-panel",children:[C.jsxs("header",{className:"translation-panel-header",children:[C.jsxs("div",{className:"translation-panel-titlebar",children:[C.jsx("h2",{children:"Translation"}),C.jsxs("div",{className:"translation-panel-actions",children:[z>0?C.jsxs(C.Fragment,{children:[C.jsxs("button",{type:"button",disabled:_,onClick:()=>void V(),children:["Ignore ",z]}),j?C.jsx("button",{type:"button",disabled:_,onClick:()=>void Y(j),children:"Retry latest"}):null]}):null,C.jsx("button",{type:"button",disabled:_,onClick:()=>void U(),children:"Translate final reply"}),C.jsx("button",{type:"button",onClick:()=>void K(),children:"Clear"})]})]}),C.jsx("div",{className:"translation-status-row",children:C.jsxs("p",{children:["Claude Code · target ",Sk(s)," · ",te]})})]}),C.jsx("div",{className:"translation-manual-panel",children:C.jsxs("div",{className:"translation-composer-row translation-manual-row",children:[C.jsx("textarea",{value:S,onChange:N=>x(N.target.value),placeholder:"Paste English to translate on demand..."}),C.jsx("div",{className:"translation-composer-actions",children:C.jsx("button",{type:"button",disabled:_||!S.trim(),onClick:()=>void H(),children:"Translate"})})]})}),C.jsxs("div",{className:"translation-entry-list",ref:L,children:[R.length===0?C.jsx("p",{className:"muted",children:"Translated Claude Code output will appear here."}):null,R.map(N=>C.jsx(Ek,{entry:N},N.id))]}),C.jsx("div",{className:"translation-composer",children:C.jsxs("div",{className:"translation-composer-row",children:[C.jsx("textarea",{value:g,onChange:N=>{h(N.target.value),(!N.target.value.trim()||T&&!Mk(N.target.value))&&E(!1)},onKeyDown:W,placeholder:"输入中文,先翻译成英文工程指令..."}),C.jsx("div",{className:"translation-composer-actions",children:C.jsx("button",{type:"button",disabled:_||!T||!Xg(g).trim(),onClick:()=>void P(),children:"Send English"})})]})})]})}function Sk(t){var r;return((r=g_.find(s=>s.value===t))==null?void 0:r.label)??t}function bk(t){let r,s=Number.NEGATIVE_INFINITY;for(const l of t){const d=Date.parse(l.failedAt),m=Number.isFinite(d)?d:Number.NEGATIVE_INFINITY;(!r||m>=s)&&(r=l,s=m)}return r}function Ck({open:t,taskSlug:r,targetLanguage:s,onClose:l}){const[d,m]=ee.useState(!1),[,f]=Ii(""),[o,c]=ee.useState(null),[u,g]=ee.useState(""),[h,S]=ee.useState(""),[x,T]=ee.useState(""),[E,y]=ee.useState(!1),[v,_]=ee.useState(null),[b,k]=ee.useState(""),[L,R]=ee.useState(""),[D,A]=ee.useState(""),[M,O]=ee.useState(!1);ol(t?`file-translation:${u||"none"}`:null,()=>H(!0),{intervalMs:2e3,runImmediately:!0});async function H(V=!1){try{const Y=await ye.getTranslationState();c(Y);const te=u?Y.fileIndex.jobs.some(z=>z.id===u):!1;if((!u||!te)&&Y.fileIndex.jobs[0])U(Y.fileIndex.jobs[0].id);else if(!Y.fileIndex.jobs[0])g(""),S(""),T("");else if(V&&u){const z=await ye.readFileTranslation(u);S(z.output),T(z.report)}}catch(Y){f(ft("Load file translation list",Y))}}async function U(V){g(V),S(""),T("");try{const Y=await ye.readFileTranslation(V);S(Y.output),T(Y.report)}catch(Y){f(ft(`Read translated file ${V}`,Y))}}async function P(){y(!0),await W(b,L)}async function W(V="",Y=""){O(!0),f("");try{const te=await ye.browseTranslationSourceFiles({path:V,query:Y,limit:250});_(te),k(te.currentPath),R(Y)}catch(te){f(ft("Browse translation source files",te))}finally{O(!1)}}async function K(V=D){const Y=V.trim();if(Y){m(!0),f("");try{if(!r)throw new Error("Create or select a task before translating files.");const te=await ye.createFileTranslation({taskSlug:r,sourcePath:Y,targetLanguage:s});y(!1),await H(),await U(te.id)}catch(te){f(ft(`Create file translation for ${Y}`,te))}finally{m(!1)}}}return t?C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"modal-backdrop file-translation-backdrop",children:C.jsx(xk,{busy:d,state:o,selectedJobId:u,output:h,report:x,onClose:()=>{y(!1),l()},onRefresh:()=>void H(),onSelectJob:V=>void U(V),onTranslate:()=>void P()})}),E?C.jsx(wk,{busy:d||M,state:v,currentPath:b,query:L,selectedPath:D,onBrowse:(V,Y)=>void W(V,Y),onClose:()=>y(!1),onQueryChange:R,onSelectPath:A,onTranslate:()=>void K()}):null]}):null}function wk({busy:t,state:r,currentPath:s,query:l,selectedPath:d,onBrowse:m,onClose:f,onQueryChange:o,onSelectPath:c,onTranslate:u}){const g=(r==null?void 0:r.entries)??[],h=g.filter(x=>x.type==="directory"),S=g.filter(x=>x.type==="file");return C.jsx("div",{className:"modal-backdrop translation-file-browser-backdrop",children:C.jsxs("section",{className:"translation-file-browser-modal",role:"dialog","aria-modal":"true","aria-label":"Select Source File",children:[C.jsxs("header",{children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Select Source File"}),C.jsx("p",{children:s||"."})]}),C.jsx("button",{type:"button",onClick:f,children:"Close"})]}),C.jsxs("div",{className:"translation-file-browser-controls",children:[C.jsxs("div",{className:"translation-file-browser-nav",children:[C.jsx("button",{type:"button",disabled:t||!s,onClick:()=>m((r==null?void 0:r.parentPath)??"",""),children:"Up"}),C.jsx("button",{type:"button",disabled:t||!s,onClick:()=>m("",""),children:"Root"})]}),C.jsxs("form",{className:"translation-file-browser-search",onSubmit:x=>{x.preventDefault(),m(s,l)},children:[C.jsx("input",{value:l,onChange:x=>o(x.target.value),placeholder:"Search files"}),C.jsx("button",{type:"submit",disabled:t,children:"Search"}),C.jsx("button",{type:"button",disabled:t||!l,onClick:()=>m(s,""),children:"Clear"})]})]}),C.jsxs("div",{className:"translation-file-browser-layout",children:[C.jsxs("div",{className:"translation-file-browser-list",children:[t&&!r?C.jsx("p",{className:"muted",children:"Loading files..."}):null,!t&&g.length===0?C.jsx("p",{className:"muted",children:"No source files found."}):null,h.length>0?C.jsxs("div",{className:"translation-file-browser-group",children:[C.jsx("h3",{children:"Folders"}),h.map(x=>C.jsx(Yg,{entry:x,selected:d===x.path,onBrowse:m,onSelectPath:c},x.path))]}):null,S.length>0?C.jsxs("div",{className:"translation-file-browser-group",children:[C.jsx("h3",{children:"Files"}),S.map(x=>C.jsx(Yg,{entry:x,selected:d===x.path,onBrowse:m,onSelectPath:c},x.path))]}):null,r!=null&&r.truncated?C.jsx("p",{className:"translation-entry-note",children:"Result limit reached."}):null]}),C.jsxs("aside",{className:"translation-file-browser-selection",children:[C.jsxs("label",{children:[C.jsx("span",{children:"Source path"}),C.jsx("input",{value:d,onChange:x=>c(x.target.value)})]}),C.jsx("button",{type:"button",disabled:t||!d.trim(),onClick:u,children:"Translate File"})]})]})]})})}function Yg({entry:t,selected:r,onBrowse:s,onSelectPath:l}){const d=t.type==="directory";return C.jsxs("button",{className:r?"translation-file-browser-entry is-selected":"translation-file-browser-entry",type:"button",onClick:()=>d?s(t.path,""):l(t.path),onDoubleClick:()=>d?s(t.path,""):void 0,children:[C.jsx("span",{children:d?"DIR":"FILE"}),C.jsx("strong",{children:t.name}),C.jsx("small",{children:t.path})]})}function xk({busy:t,state:r,selectedJobId:s,output:l,report:d,onClose:m,onRefresh:f,onSelectJob:o,onTranslate:c}){const u=(r==null?void 0:r.fileIndex.jobs)??[],g=u.find(h=>h.id===s);return C.jsxs("section",{className:"file-translation-modal",role:"dialog","aria-modal":"true","aria-label":"File Translation",children:[C.jsxs("header",{className:"file-translation-header",children:[C.jsxs("div",{children:[C.jsx("h2",{children:"File Translation"}),C.jsx("p",{children:"Claude Code · 中英互译"})]}),C.jsxs("div",{className:"file-translation-toolbar",children:[C.jsx("button",{type:"button",disabled:t,onClick:c,children:"Translate"}),C.jsx("button",{type:"button",disabled:t,onClick:f,children:"Refresh"}),C.jsx("button",{type:"button",onClick:m,children:"Close"})]})]}),r!=null&&r.memoryInitialized?null:C.jsx("p",{className:"translation-entry-note",children:"Translation memory is not initialized. Run Bootstrap from the sidebar before important file translations."}),C.jsxs("div",{className:"file-translation-layout",children:[C.jsxs("div",{className:"file-translation-list",children:[u.length===0?C.jsx("p",{className:"muted",children:"No translated files yet."}):null,u.map(h=>C.jsxs("button",{className:h.id===s?"file-translation-item is-active":"file-translation-item",type:"button",onClick:()=>o(h.id),children:[C.jsx("strong",{children:h.sourcePath}),C.jsxs("span",{children:[h.status," · ",h.targetLanguage]})]},h.id))]}),C.jsx("div",{className:"file-translation-preview",children:g?C.jsxs(C.Fragment,{children:[C.jsxs("header",{children:[C.jsx("strong",{children:g.sourcePath}),C.jsx("span",{children:g.status})]}),C.jsx("div",{className:"translation-markdown",children:C.jsx(rv,{remarkPlugins:[Tv],children:l||d||"Translation output is not available yet."})})]}):C.jsx("p",{className:"muted",children:"Select a translated file to preview it."})})]})]})}function Ek({entry:t}){if(t.sourceKind==="conversation-boundary")return C.jsx(kk,{entry:t});const r=Dk(t),s=t.sourceKind==="tool-output",l=t.direction==="user-input-to-english",d=["translation-entry",`is-${t.sourceKind}`,l?"is-user-input":""].filter(Boolean).join(" ");return C.jsxs("article",{className:d,children:[s?C.jsx("pre",{children:r}):C.jsx("div",{className:"translation-markdown",children:C.jsx(rv,{remarkPlugins:[Tv],children:r})}),t.warning?C.jsx("p",{className:"translation-entry-note",children:t.warning}):null,t.error?C.jsx("p",{className:"translation-entry-note is-error",children:t.error}):null]})}function kk({entry:t}){const r=t.boundaryKind==="end"?"结束":"开始",s=t.conversationTurn??0,l=Ok(t.occurredAt??t.createdAt);return C.jsxs("div",{className:"translation-conversation-boundary","aria-label":`${r} 第 ${s} 轮 ${l}`,children:[C.jsx("span",{className:"translation-boundary-dash","aria-hidden":"true"}),C.jsx("span",{children:r}),C.jsxs("span",{children:["第 ",s," 轮"]}),C.jsx("time",{children:l}),C.jsx("span",{className:"translation-boundary-dash","aria-hidden":"true"})]})}function Ak(t){const r=t.find(Mv);return(r==null?void 0:r.translationStartedAt)??(r==null?void 0:r.createdAt)}function Tk(t,r,s){const l=t.find(Mv);if(l)return`translating ${Lk(Math.max(0,s-Rk(l)))}`;const d=t.at(-1);return(d==null?void 0:d.status)==="failed"||r==="failed"?"error":r}function Mv(t){return t.status==="queued"||t.status==="translating"}function Rk(t){const r=Date.parse(t.translationStartedAt??t.createdAt);return Number.isFinite(r)?r:Date.now()}function Dk(t){return t.status==="queued"||t.status==="translating"?t.sourceText:t.status==="translated"?t.direction==="user-input-to-english"?Lv(t.sourceText,t.translatedText):t.translatedText:t.translatedText||t.sourceText}function Lv(t,r){return`${t.trimEnd()}${Ho}${r.trimStart()}`}function Mk(t){return t.includes(Ho)}function Xg(t){const r=t.indexOf(Ho);return r===-1?t:t.slice(r+Ho.length)}function Lk(t){if(t<1e3)return`${Math.max(.1,t/1e3).toFixed(1)}s`;const r=t/1e3;if(r<60)return`${r.toFixed(1)}s`;const s=Math.floor(r/60),l=Math.floor(r%60).toString().padStart(2,"0");return`${s}:${l}`}function Ok(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleTimeString()}const Bk=8;function jk(){const[t,r]=ee.useState([]);return ee.useEffect(()=>{const s=m=>{var c,u;const f=(u=(c=m.detail)==null?void 0:c.message)==null?void 0:u.trim();if(!f)return;const o=new Date().toISOString();r(g=>{const h=g.find(S=>S.message===f);return h?[{...h,count:h.count+1,updatedAt:o},...g.filter(S=>S.id!==h.id)]:[{id:`ui_error_${Date.now()}_${Math.random().toString(16).slice(2)}`,message:f,count:1,createdAt:o,updatedAt:o},...g].slice(0,Bk)})},l=m=>{var o;const f=((o=m.detail)==null?void 0:o.actions)??[];f.length!==0&&r(c=>c.filter(u=>!f.some(g=>u.message.startsWith(`${g} failed.`))))},d=m=>{var o,c;const f=(c=(o=m.detail)==null?void 0:o.message)==null?void 0:c.trim();f&&r(u=>u.filter(g=>g.message!==f))};return window.addEventListener(bh,s),window.addEventListener(Ch,l),window.addEventListener(wh,d),()=>{window.removeEventListener(bh,s),window.removeEventListener(Ch,l),window.removeEventListener(wh,d)}},[]),t.length===0?null:C.jsxs("aside",{className:"ui-error-center",role:"alert","aria-live":"polite","aria-label":"Application errors",children:[C.jsxs("header",{className:"ui-error-center-header",children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Errors"}),C.jsxs("p",{children:[t.length," active"]})]}),C.jsx("button",{type:"button",onClick:()=>r([]),children:"Clear"})]}),C.jsx("ol",{className:"ui-error-list",children:t.map(s=>C.jsxs("li",{children:[C.jsxs("div",{children:[C.jsx("p",{children:s.message}),C.jsxs("span",{children:[Nk(s.updatedAt),s.count>1?` · repeated ${s.count} times`:""]})]}),C.jsx("button",{type:"button","aria-label":"Dismiss error",onClick:()=>r(l=>l.filter(d=>d.id!==s.id)),children:"Close"})]},s.id))})]})}function Nk(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Hk(t,r){return t.find(s=>s.taskSlug===r)??t[0]??null}function zk(t){if(!(t.mode!=="auto"||t.status!=="running")&&!(!t.activeRole||t.activeRole===t.lastFollowedRole))return t.activeRole}function Ik(t,r){var d;if(!((d=t.flowPause)!=null&&d.paused))return null;const s=t.flowPause.role??t.activeRole??"role",l=t.roleRecovery;return t.flowPause.reason==="role-recovery-failed"&&l?r(l,s):t.flowPause.message??`No new turn started after ${s} stopped.`}function Uk(t){const r=t.roundId??t.startedAt??t.taskSlug,s=t.stoppedAt??t.lastTurnEndedAt??"stopped";return`${r}:${s}`}function Pk(t,r,s){var d;if((d=t.flowPause)!=null&&d.paused&&t.flowPause.message||(r==null?void 0:r.status)==="running")return!0;const l=Date.parse(t.stoppedAt??t.lastTurnEndedAt??"");return!!(s&&Number.isFinite(l)&&l>s)}function Fk(t){return t?"strong":"none"}function qk(t,r){if(!r)return{observation:t,dismissPauseAlert:!1};const s=r.lastGatewayInputMessageId??null;return t.initialized?{observation:{initialized:!0,messageId:s},dismissPauseAlert:!!(r.enabled&&s&&s!==t.messageId)}:{observation:{initialized:!0,messageId:s},dismissPauseAlert:!1}}const $k=3,Gk=3e4,Mo=new Map;function Ov(t,r){const s=ft(t,r);if(!Vk(r))return Mo.set(t,{consecutiveFailures:1,lastMessage:s,lastReportedAt:Date.now()}),s;const l=Mo.get(t),d=((l==null?void 0:l.consecutiveFailures)??0)+1,m=Date.now(),f=d>=$k&&(!l||l.lastMessage!==s||m-l.lastReportedAt>=Gk);return Mo.set(t,{consecutiveFailures:d,lastMessage:s,lastReportedAt:f?m:(l==null?void 0:l.lastReportedAt)??0}),f?s:null}function zo(t){Mo.delete(t),yS([t])}function Vk(t){const r=cl(t);return r.includes("could not reach the VCM backend")||r.includes("Failed to fetch")||r.includes("NetworkError")||r.includes("Load failed")||r.includes("ERR_CONNECTION")}const Wk=["architecture-plan","validation-adequacy","code-diff"];function Kk({events:t,maxEvents:r=8,showHeader:s=!0}){const l=r===null?t:t.slice(-r);return C.jsxs("section",{className:"event-log",children:[s?C.jsx("h2",{children:"Events"}):null,t.length===0?C.jsx("p",{className:"muted",children:"No terminal events yet."}):C.jsx("ol",{children:l.map((d,m)=>C.jsx("li",{children:d},`${d}-${m}`))})]})}function Hn({checked:t,className:r,disabled:s,label:l,stateLabel:d,title:m,onChange:f}){const o=["switch-control",t?"is-on":"is-off",r].filter(Boolean).join(" "),c=d??(t?"on":"off");return C.jsxs("button",{type:"button",role:"switch","aria-checked":t,"aria-label":`${l}: ${c}`,className:o,disabled:s,title:m,onClick:()=>f(!t),children:[C.jsx("span",{className:"switch-control-label",children:l}),C.jsx("span",{className:"switch-control-track","aria-hidden":"true",children:C.jsx("span",{className:"switch-control-thumb"})})]})}function Yk({status:t,bootstrapStatus:r,applyResult:s,hasActiveTask:l=!1,autoTaskHarnessReviewEnabled:d,autoMemoryEnabled:m,launchOptions:f,modelOptions:o,busy:c=!1,onRefresh:u,onApply:g,onOpenStudio:h,onOpenRepositoryDiff:S,onAutoTaskHarnessReviewChange:x,onAutoMemoryChange:T,onLaunchOptionsChange:E,onStartBootstrap:y,onRestartBootstrap:v,onStopBootstrap:_,onRunBootstrap:b}){const[k,L]=ee.useState(!1),R=r==null?void 0:r.session,D=(r==null?void 0:r.status)==="running",A=(R==null?void 0:R.status)==="running",M=(r==null?void 0:r.status)!=="complete";return l?t?C.jsxs("section",{className:"harness-panel",children:[C.jsxs("div",{className:"harness-stage",children:[C.jsxs("div",{className:"harness-panel-header",children:[C.jsxs("div",{children:[C.jsx("strong",{children:"Fixed install"}),C.jsx("p",{className:"muted",children:t.initialized?t.needsApply?`${t.plannedChanges.length} pending updates`:"Up to date":"Not initialized"})]}),C.jsx("div",{className:"harness-actions",children:t.initialized?C.jsxs(C.Fragment,{children:[C.jsx("button",{type:"button",disabled:c,onClick:()=>void u(),children:"Refresh"}),t.needsApply?C.jsx("button",{type:"button",disabled:c,onClick:()=>void g(),children:"Update"}):null]}):C.jsx("button",{type:"button",disabled:c,onClick:()=>void g(),children:"Initialize"})})]}),t.initialized&&t.needsApply?C.jsxs(C.Fragment,{children:[C.jsx("h3",{className:"harness-file-list-title",children:"Files to update"}),C.jsx("ol",{className:"harness-file-list",children:t.plannedChanges.map(O=>C.jsxs("li",{children:[C.jsx("span",{children:O.path}),C.jsx(jn,{status:O.action})]},`${O.path}:${O.action}`))})]}):null]}),C.jsxs("div",{className:"harness-stage",children:[C.jsxs("div",{className:"harness-panel-header",children:[C.jsx("div",{children:C.jsx("strong",{children:"Harness Studio"})}),C.jsx("div",{className:"harness-actions",children:C.jsx("button",{type:"button",disabled:c,onClick:h,children:"Open Studio"})})]}),C.jsx("button",{className:"harness-review-diff-button",type:"button",disabled:c,onClick:S,children:"Review Diff"}),C.jsx(Hn,{checked:d,className:"sidebar-switch",disabled:c,label:"Auto task harness review",title:"Automatically ask Harness Engineer to review task harness after final acceptance completes",onChange:x}),C.jsx(Hn,{checked:m,className:"sidebar-switch",disabled:c,label:"Auto memory",title:"Collect role memory drafts after Final Acceptance and let Harness Engineer apply reviewed memory",onChange:T})]}),M?C.jsx("div",{className:"harness-stage",children:C.jsxs("div",{className:"harness-panel-header",children:[C.jsxs("div",{children:[C.jsx("strong",{children:"Bootstrap"}),C.jsx("p",{className:"muted",children:r?Xk(r.status):"not loaded"})]}),C.jsx("div",{className:"harness-actions",children:C.jsx("button",{type:"button",disabled:c||!(r!=null&&r.canStart),onClick:()=>{L(!0)},children:"Open Bootstrap"})})]})}):null,s!=null&&s.changedFiles.length?C.jsx("div",{className:"harness-result",children:C.jsx("p",{className:"muted",children:s.message})}):null,t.warnings.length>0?C.jsx("ul",{className:"warnings",children:t.warnings.map(O=>C.jsx("li",{children:O},O))}):null,r!=null&&r.warnings.length?C.jsx("ul",{className:"warnings",children:r.warnings.map(O=>C.jsx("li",{children:O},O))}):null,M&&k?C.jsx("div",{className:"harness-bootstrap-modal",role:"dialog","aria-modal":"true","aria-label":"Harness Engineer bootstrap session",children:C.jsxs("div",{className:"harness-bootstrap-modal-surface",children:[C.jsxs("header",{className:"harness-bootstrap-modal-header",children:[C.jsxs("div",{children:[C.jsx("strong",{children:"Harness Engineer Bootstrap"}),C.jsx("p",{className:"muted",children:(R==null?void 0:R.command)??"Start Harness Engineer, then run bootstrap when ready."})]}),C.jsxs("div",{className:"harness-bootstrap-modal-actions",children:[R?C.jsx(jn,{status:R.status}):null,C.jsx("button",{type:"button",onClick:()=>L(!1),children:"Close"})]})]}),C.jsxs("div",{className:"harness-bootstrap-controls",children:[C.jsxs("label",{children:[C.jsx("span",{children:"Permission"}),C.jsx("select",{value:f.permissionMode,disabled:c||D||A,onChange:O=>E({...f,permissionMode:O.target.value}),children:__.map(O=>C.jsx("option",{value:O.value,children:O.label},O.value))})]}),C.jsxs("label",{children:[C.jsx("span",{children:"Model"}),C.jsx("select",{value:f.model,title:(()=>{const O=o.find(H=>H.value===f.model);return O!=null&&O.available?O.description:O==null?void 0:O.unavailableReason})(),disabled:c||D||A,onChange:O=>E({...f,model:O.target.value}),children:o.map(O=>C.jsx("option",{value:O.value,disabled:!O.available,title:O.available?O.description:O.unavailableReason,children:O.label},O.value))})]}),C.jsxs("label",{children:[C.jsx("span",{children:"Effort"}),C.jsx("select",{value:f.effort,disabled:c||D||A,onChange:O=>E({...f,effort:O.target.value}),children:y_.map(O=>C.jsx("option",{value:O.value,children:O.label},O.value))})]}),C.jsxs("div",{className:"harness-bootstrap-control-actions",children:[C.jsx("button",{type:"button",disabled:c||D||!(r!=null&&r.canStart),onClick:()=>void y(f),children:"Start"}),C.jsx("button",{type:"button",disabled:c||D||!(r!=null&&r.canStart),onClick:()=>void v(f),children:"Restart"}),C.jsx("button",{type:"button",disabled:c||!R,onClick:()=>void _(),children:"Stop"}),C.jsx("button",{type:"button",disabled:c||D||!A,onClick:()=>void b(),children:"Run bootstrap"})]})]}),C.jsx("div",{className:"harness-bootstrap-terminal",children:A?C.jsx(Po,{sessionId:R.id,active:k}):C.jsxs("div",{className:"terminal-empty",children:[C.jsx("strong",{children:"Harness Bootstrap"}),C.jsx("span",{children:"Start Harness Engineer first. When it is ready, click Run bootstrap to send the prompt."})]})})]})}):null]}):null:C.jsx("section",{className:"harness-panel",children:C.jsxs("div",{className:"harness-result",children:[C.jsx("strong",{children:"Task required"}),C.jsx("p",{className:"muted",children:"Create or select a task before changing VCM Harness. Harness changes are committed in the active task worktree."})]})})}function Xk(t){return t.replaceAll("_"," ")}function af(t){return{total:t.length,accepted:t.filter(r=>r.acceptedAt).length,delivered:t.filter(r=>r.deliveredAt).length}}function Qk(t,r=6){const s=[...t].sort(e2).map((d,m)=>({message:d,sequence:m+1}));return[...r===null?s:s.slice(-r)].sort((d,m)=>m.sequence-d.sequence)}function Jk({messages:t,orchestration:r,busy:s,maxMessages:l=6,showControls:d=!0,showHeader:m=!0,onModeChange:f,onMarkAllDone:o}){const[c,u]=ee.useState(null),g=af(t),h=(r==null?void 0:r.mode)??"auto",S=Qk(t,l);async function x(T){await t2(T.body),u(T.id),window.setTimeout(()=>u(E=>E===T.id?null:E),1200)}return C.jsxs("section",{className:"message-panel",children:[m?C.jsxs("div",{className:"message-panel-header",children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Messages"}),C.jsxs("p",{className:"muted",children:[g.total," total / ",g.accepted," accepted"]})]}),d&&f?C.jsx("div",{className:"message-controls",children:C.jsx(Hn,{checked:h==="auto",className:"message-mode-toggle",disabled:s,label:"Auto orchestration",onChange:T=>f(T?"auto":"manual")})}):null,d&&o?C.jsx("button",{type:"button",disabled:s,onClick:o,children:"Mark All Done"}):null]}):null,t.length===0?C.jsx("p",{className:"muted",children:"No role messages yet."}):C.jsx("ol",{className:"message-list",children:S.map(({message:T,sequence:E})=>C.jsxs("li",{className:"message-item",children:[C.jsxs("div",{className:"message-item-main",children:[C.jsxs("div",{className:"message-meta",children:[C.jsxs("span",{className:"message-sequence",children:["#",E]}),C.jsx("time",{dateTime:Io(T),children:Zk(Io(T))}),C.jsxs("strong",{children:[T.fromRole," ","->"," ",T.toRole]}),C.jsx("span",{children:T.type})]}),C.jsx("p",{children:T.body}),T.failureReason?C.jsx("span",{className:"message-reason",children:T.failureReason}):null,T.bodyPath?C.jsx("span",{className:"message-path",children:T.bodyPath}):null]}),C.jsx("div",{className:"message-actions",children:C.jsx("button",{type:"button",disabled:s,onClick:()=>void x(T),children:c===T.id?"Copied":"Copy"})})]},T.id))})]})}function Zk(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Io(t){return t.acceptedAt??t.deliveredAt??t.dispatchingAt??t.createdAt}function e2(t,r){const s=Io(t).localeCompare(Io(r));if(s!==0)return s;const l=t.createdAt.localeCompare(r.createdAt);return l!==0?l:t.id.localeCompare(r.id)}async function t2(t){var s;if((s=navigator.clipboard)!=null&&s.writeText){await navigator.clipboard.writeText(t);return}const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly","true"),r.style.position="fixed",r.style.left="-9999px",document.body.appendChild(r),r.select(),document.execCommand("copy"),r.remove()}function n2({defaultPath:t="",recentPaths:r=[],busy:s=!1,onConnect:l}){const[d,m]=ee.useState(t);ee.useEffect(()=>{t&&m(t)},[t]);async function f(o){o.preventDefault(),await l(d)}return C.jsx("form",{className:"repo-connect",onSubmit:f,children:C.jsxs("div",{className:r.length>0?"inline-form has-recent-paths":"inline-form",children:[C.jsx("input",{"aria-label":"Repository path",id:"repo-path",value:d,onChange:o=>m(o.target.value),placeholder:"/path/to/repo"}),r.length>0?C.jsxs("select",{"aria-label":"Recent repositories",className:"repo-recent-select",value:"",onChange:o=>{o.target.value&&m(o.target.value)},children:[C.jsx("option",{value:"",children:"Recent"}),r.map(o=>C.jsx("option",{value:o,children:o},o))]}):null,C.jsx("button",{type:"submit",disabled:s||!d.trim(),children:"Connect"})]})})}function i2({tasks:t,activeTaskSlug:r,onSelect:s}){return C.jsx("nav",{className:"task-nav","aria-label":"Tasks",children:t.map(l=>C.jsxs("button",{className:l.taskSlug===r?"task-nav-item is-active":"task-nav-item",type:"button",onClick:()=>s(l.taskSlug),children:[C.jsx("span",{children:l.title||l.taskSlug}),C.jsx(jn,{status:l.status})]},l.taskSlug))})}function r2({open:t,taskSlug:r,taskTitle:s,onClose:l}){const[d,m]=ee.useState(null),[f,o]=ee.useState(!1),[c,u]=ee.useState(null),g=ee.useCallback(async()=>{o(!0),u(null);try{m(await ye.getTaskUsageAnalytics(r))}catch(h){u(`Load task usage analytics failed. Reason: ${cl(h)}`)}finally{o(!1)}},[r]);return ee.useEffect(()=>{t&&g()},[g,t]),t?C.jsx("div",{className:"modal-backdrop usage-analytics-backdrop",children:C.jsxs("section",{className:"usage-analytics-modal",role:"dialog","aria-modal":"true","aria-label":"Usage Analytics",children:[C.jsxs("header",{className:"usage-analytics-header",children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Usage Analytics"}),C.jsxs("p",{children:[(s==null?void 0:s.trim())||r," · Claude models only"]})]}),C.jsxs("div",{className:"usage-analytics-header-actions",children:[C.jsx("button",{type:"button",disabled:f,onClick:()=>void g(),children:f?"Refreshing...":"Refresh"}),C.jsx("button",{type:"button",onClick:l,children:"Close"})]})]}),c?C.jsx("p",{className:"inline-error usage-analytics-error",children:c}):null,d?C.jsx(s2,{report:d}):C.jsx("div",{className:"usage-analytics-empty",children:f?"Loading usage data...":"No usage data available."})]})}):null}function s2({report:t}){return C.jsxs("div",{className:"usage-analytics-content",children:[C.jsxs("div",{className:"usage-analytics-meta",children:[C.jsx("span",{children:t.updatedAt?`Updated ${l2(t.updatedAt)}`:"No Claude usage recorded yet"}),C.jsxs("span",{children:[bn(t.totals.requestCount)," requests · ",bn(t.totals.sessionCount)," sessions"]})]}),C.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-task-summary",children:[C.jsx("h3",{id:"usage-task-summary",children:"Task Summary"}),C.jsx(a2,{totals:t.totals})]}),C.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-by-role",children:[C.jsx("h3",{id:"usage-by-role",children:"Usage by Role"}),C.jsx("div",{className:"usage-analytics-table-wrap",children:C.jsxs("table",{className:"usage-analytics-table",children:[C.jsx("thead",{children:C.jsx(Qg,{firstColumn:"Role"})}),C.jsx("tbody",{children:t.byRole.map(r=>C.jsxs("tr",{children:[C.jsxs("th",{scope:"row",children:[C.jsx("span",{children:aS(r.role).label}),C.jsxs("small",{children:[bn(r.requestCount)," requests · ",bn(r.sessionCount)," sessions"]})]}),C.jsx(Jg,{totals:r})]},r.role))})]})})]}),C.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-by-model",children:[C.jsx("h3",{id:"usage-by-model",children:"Usage by Model"}),t.byModel.length>0?C.jsx("div",{className:"usage-analytics-table-wrap",children:C.jsxs("table",{className:"usage-analytics-table",children:[C.jsx("thead",{children:C.jsx(Qg,{firstColumn:"Model"})}),C.jsx("tbody",{children:t.byModel.map(r=>C.jsxs("tr",{children:[C.jsxs("th",{scope:"row",children:[C.jsx("span",{children:r.model}),C.jsxs("small",{children:[bn(r.requestCount)," requests · ",bn(r.sessionCount)," sessions"]})]}),C.jsx(Jg,{totals:r})]},r.model))})]})}):C.jsx("p",{className:"usage-analytics-no-models",children:"No Claude model usage recorded yet."})]})]})}function a2({totals:t}){return C.jsxs("dl",{className:"usage-totals-grid",children:[C.jsx(Ja,{label:"Input Tokens",value:bn(t.inputTokens)}),C.jsx(Ja,{label:"Output Tokens",value:bn(t.outputTokens)}),C.jsx(Ja,{label:"Cache Read",value:bn(t.cacheReadTokens)}),C.jsx(Ja,{label:"Cache Creation",value:bn(t.cacheCreationTokens)}),C.jsx(Ja,{label:"Estimated Cost",value:Bv(t.costUsd)})]})}function Ja({label:t,value:r}){return C.jsxs("div",{children:[C.jsx("dt",{children:t}),C.jsx("dd",{children:r})]})}function Qg({firstColumn:t}){return C.jsxs("tr",{children:[C.jsx("th",{scope:"col",children:t}),C.jsx("th",{scope:"col",children:"Input"}),C.jsx("th",{scope:"col",children:"Output"}),C.jsx("th",{scope:"col",children:"Cache Read"}),C.jsx("th",{scope:"col",children:"Cache Creation"}),C.jsx("th",{scope:"col",children:"Estimated Cost"})]})}function Jg({totals:t}){return C.jsxs(C.Fragment,{children:[C.jsx("td",{children:bn(t.inputTokens)}),C.jsx("td",{children:bn(t.outputTokens)}),C.jsx("td",{children:bn(t.cacheReadTokens)}),C.jsx("td",{children:bn(t.cacheCreationTokens)}),C.jsx("td",{children:Bv(t.costUsd)})]})}function bn(t){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(t)}function Bv(t){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}).format(t)}function l2(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function o2({project:t,recentRepositoryPaths:r,tasks:s,activeTaskSlug:l,messages:d,orchestration:m,events:f,roundState:o,gateReview:c,translationEnabled:u,translationAutoSendEnabled:g,translationTargetLanguage:h,translationOutputMode:S,translationMemoryInitialized:x,translatorSession:T,harnessStatus:E,harnessBootstrapStatus:y,harnessApplyResult:v,harnessEngineerLaunchOptions:_,autoTaskHarnessReviewEnabled:b,autoMemoryEnabled:k,gatewayStatus:L,gatewayQrLogin:R,gatewayQrCheck:D,gatewayLarkRegistration:A,gatewayLarkRegistrationCheck:M,codexBridgeStatus:O,modelOptions:H,busy:U,onConnect:P,onRefreshConnectedRepository:W,onPullConnectedRepository:K,onRefreshHarness:V,onApplyHarness:Y,onStartHarnessBootstrap:te,onRestartHarnessBootstrap:z,onStopHarnessBootstrap:j,onRunHarnessBootstrap:N,onOpenHarnessStudio:q,onOpenRepositoryDiff:I,onAutoTaskHarnessReviewChange:ie,onAutoMemoryChange:me,onHarnessEngineerLaunchOptionsChange:_e,onRefreshGateway:Q,onGatewayEnabledChange:$,onGatewaySettingsChange:he,onCodexBridgeSettingsChange:ae,onCodexBridgeCheck:Ce,onGatewayTranslationChange:be,onGatewayConnectionChange:Le,onStartGatewayQrLogin:Fe,onStartGatewayLarkRegistration:He,onResetGatewayBinding:Ee,onGateReviewGateEnabledChange:ce,onCancelGateReviewGate:ze,onTranslationEnabledChange:St,onTranslationAutoSendChange:mt,onTranslationTargetLanguageChange:de,onTranslationOutputModeChange:Ne,onOpenFileTranslation:Ue,onOpenTranslatorSession:it,onCreateTranslationBootstrap:wt,onUpdateTranslationMemory:fe,onCreateTask:we,onCloseTask:Te,onSelectTask:Be,themeMode:je,onAutoOrchestrationChange:bt,onThemeModeChange:qe,pauseAlertSound:Et,onPauseAlertSoundChange:xt,roleRetryEnabled:Nt,onRoleRetryEnabledChange:rt,permissionRequestMode:Wt,onPermissionRequestModeChange:rn,launchTemplate:Cr,canSaveLaunchTemplate:mi,canOneClickStart:gi,onSaveLaunchTemplate:Pi,onOneClickStart:zn,onMarkAllMessagesDone:Fi,onDeleteMessageHistory:Jn}){const[si,sn]=ee.useState(""),[ai,In]=ee.useState(!1),[qi,_i]=ee.useState(!1),[vi,yi]=ee.useState(!1),[wn,Pt]=ee.useState(()=>l?null:"repository"),li=af(d),hn=si.trim(),Kt=d2(t,l,E),gt=s.filter(Ve=>Ve.cleanupStatus!=="cleaned"),ot=gt.find(Ve=>Ve.taskSlug===l)??null;ee.useEffect(()=>{Pt(Ve=>!l&&Ve===null?t?"task":"repository":Ve)},[l,t]);function Ht(Ve,Un){Pt(Un?Ve:null)}async function $i(Ve){Ve.preventDefault(),await we({taskSlug:hn}),sn("")}return C.jsxs("div",{className:"project-dashboard",children:[C.jsx("header",{className:"brand-header",children:C.jsx("strong",{children:"VibeCodingMaster"})}),C.jsx(Kr,{title:"Repository",open:wn==="repository",onOpenChange:Ve=>{Ht("repository",Ve),Ve&&t&&W()},children:C.jsxs("div",{className:"repository-panel",children:[C.jsx(n2,{defaultPath:(t==null?void 0:t.repoRoot)??"",recentPaths:r,busy:U,onConnect:P}),t?C.jsx(_2,{busy:U,project:t,onPull:K}):null]})}),C.jsx(Kr,{title:"Settings",open:wn==="settings",onOpenChange:Ve=>Ht("settings",Ve),children:C.jsxs("div",{className:"sidebar-settings",children:[C.jsxs("button",{"aria-label":`Theme mode: ${e_(je)}`,className:"settings-toggle theme-mode-toggle",disabled:U,title:"Cycle theme: system, light, dark",type:"button",onClick:()=>qe(C2(je)),children:[C.jsx("span",{children:"Theme"}),C.jsx("span",{children:e_(je)})]}),C.jsx(Hn,{checked:((m==null?void 0:m.mode)??"auto")==="auto",className:"sidebar-switch",disabled:U||!l,label:"Auto orchestration",title:l?"Automatically dispatch role messages during the active task":"Create or select a task first",onChange:bt}),C.jsx(Hn,{checked:Et,className:"sidebar-switch",disabled:U,label:"Pause alert sound",title:"Play a sound when VCM shows the fixed flow pause dialog",onChange:Ve=>xt(Ve)}),C.jsx(Hn,{checked:Nt,className:"sidebar-switch",disabled:U,label:"CC auto retry",title:"Retry temporary Claude Code turn failures before showing the flow pause alert",onChange:Ve=>rt(Ve)}),C.jsxs("label",{className:"settings-select-row",children:[C.jsx("span",{children:"Permission requests"}),C.jsxs("select",{value:Wt,disabled:U,onChange:Ve=>rn(Ve.target.value),children:[C.jsx("option",{value:"off",children:"off"}),C.jsx("option",{value:"allowAll",children:"allow all"})]})]}),C.jsx(u2,{busy:U,status:O,onCheck:Ce,onSettingsChange:ae}),C.jsxs("button",{className:"settings-toggle",disabled:U||!mi,title:"Save the current core role launch settings and optional Reviewer settings",type:"button",onClick:Pi,children:[C.jsx("span",{children:"Save launch template"}),C.jsx("span",{children:mi?"ready":"open task"})]}),gi?C.jsxs("button",{className:"settings-toggle is-active",disabled:U,title:c2(Cr),type:"button",onClick:zn,children:[C.jsx("span",{children:"One-click start"}),C.jsx("span",{children:jv(Cr)})]}):null,l?C.jsxs(C.Fragment,{children:[C.jsxs("button",{type:"button",onClick:()=>In(!0),children:[C.jsx("span",{children:"Messages"}),C.jsxs("span",{className:"muted",children:[li.total," total"]})]}),C.jsxs("button",{type:"button",onClick:()=>_i(!0),children:[C.jsx("span",{children:"Events"}),C.jsxs("span",{className:"muted",children:[f.length," total"]})]})]}):null]})}),C.jsx(Kr,{title:"Translation",open:wn==="translation",onOpenChange:Ve=>Ht("translation",Ve),children:C.jsx(h2,{busy:U,enabled:u,autoSendEnabled:g,targetLanguage:h,outputMode:S,memoryInitialized:x,baseUnavailableReason:Kt,translatorSession:T,onAutoSendChange:mt,onCreateBootstrap:wt,onEnabledChange:St,onUpdateMemory:fe,onTargetLanguageChange:de,onOutputModeChange:Ne,onOpenFileTranslation:Ue,onOpenTranslatorSession:it})}),t&&l?C.jsx(Kr,{title:"Gate Review Gates",open:wn==="gate-review-gates",onOpenChange:Ve=>Ht("gate-review-gates",Ve),children:C.jsx(p2,{busy:U,state:c,onCancelGateReview:ze,onGateEnabledChange:ce})}):null,C.jsx(Kr,{title:"Gateway",open:wn==="gateway",onOpenChange:Ve=>{Ht("gateway",Ve),Ve&&Q()},children:C.jsx(g2,{busy:U,qrCheck:D,qrLogin:R,larkRegistration:A,larkRegistrationCheck:M,status:L,onEnabledChange:$,onSettingsChange:he,onResetBinding:Ee,onStartLarkRegistration:He,onStartQrLogin:Fe,onTranslationChange:be,onConnectionChange:Le})}),t?C.jsx(Kr,{title:"VCM Harness",open:wn==="vcm-harness",onOpenChange:Ve=>Ht("vcm-harness",Ve),children:C.jsx(Yk,{status:E,bootstrapStatus:y,applyResult:v,hasActiveTask:!!ot,autoTaskHarnessReviewEnabled:b,autoMemoryEnabled:k,launchOptions:_,modelOptions:H,busy:U,onRefresh:V,onApply:Y,onOpenStudio:q,onOpenRepositoryDiff:I,onAutoTaskHarnessReviewChange:ie,onAutoMemoryChange:me,onLaunchOptionsChange:_e,onStartBootstrap:te,onRestartBootstrap:z,onStopBootstrap:j,onRunBootstrap:N})}):null,t?C.jsx(Kr,{title:"Task",open:wn==="task",onOpenChange:Ve=>Ht("task",Ve),children:gt.length>0?C.jsxs("div",{className:"task-panel",children:[C.jsx(i2,{tasks:gt,activeTaskSlug:l,onSelect:Be}),ot?C.jsxs("div",{className:"task-panel-actions",children:[C.jsx("button",{type:"button",onClick:()=>yi(!0),children:"Usage Analytics"}),C.jsx("button",{className:"danger-button",disabled:U,type:"button",onClick:Te,children:"Close Task"})]}):null]}):C.jsx("div",{className:"task-create",children:C.jsxs("form",{onSubmit:$i,children:[C.jsx("input",{value:si,onChange:Ve=>sn(Ve.target.value),placeholder:"task name"}),C.jsxs("div",{className:"task-create-preview",children:[C.jsxs("small",{children:["branch: ",hn?`feature/${hn}`:"feature/<task>"]}),C.jsxs("small",{children:["worktree: ",hn?`.claude/worktrees/${hn}`:".claude/worktrees/<task>"]})]}),C.jsx("button",{type:"submit",disabled:U||!hn,children:"Create"})]})})}):null,t&&ot?C.jsx(S2,{task:ot,roundState:o}):null,ai?C.jsx(x2,{busy:U,messages:d,orchestration:m,onClose:()=>In(!1),onMarkAllDone:()=>{l&&Fi(l)},onDeleteMessageHistory:()=>{l&&Jn(l)}}):null,qi?C.jsx(w2,{events:f,onClose:()=>_i(!1)}):null,ot?C.jsx(r2,{open:vi,taskSlug:ot.taskSlug,taskTitle:ot.title,onClose:()=>yi(!1)}):null]})}function jv(t){return[t.autoOrchestration?"auto":"manual"].join(" + ")}function c2(t){const r=Object.entries(t.roles).map(([s,l])=>`${s}: ${l.permissionMode} / ${l.model} / ${l.effort}`).join("; ");return`Launch template: ${jv(t)}; ${r}`}function u2({busy:t,status:r,onCheck:s,onSettingsChange:l}){const[d,m]=ee.useState(""),f=!!(r!=null&&r.apiKeyConfigured),o=async c=>{c.preventDefault();const u=d.trim();u&&(await l({apiKey:u}),m(""))};return C.jsxs("div",{className:"codex-bridge-settings",children:[C.jsx(Hn,{checked:!!(r!=null&&r.enabled),className:"sidebar-switch",disabled:t||!f,label:"Codex Bridge models",title:f?"Enable Codex models through Codex Bridge":"Save the Codex Bridge API key first",onChange:c=>void l({enabled:c})}),C.jsxs("form",{className:"codex-bridge-api-key-form",onSubmit:c=>void o(c),children:[C.jsx("label",{htmlFor:"codex-bridge-api-key",children:"Codex Bridge API key"}),C.jsxs("div",{children:[C.jsx("input",{id:"codex-bridge-api-key",type:"password",autoComplete:"off",disabled:t,placeholder:f?"Saved":"Required",value:d,onChange:c=>m(c.target.value)}),C.jsx("button",{type:"submit",disabled:t||!d.trim(),children:"Save"})]})]}),C.jsxs("div",{className:"settings-status-row",children:[C.jsx("span",{children:"Codex Bridge status"}),C.jsx("strong",{children:(r==null?void 0:r.connectionState)??"loading"})]}),C.jsxs("div",{className:"codex-bridge-actions",children:[C.jsx("button",{type:"button",disabled:t||!(r!=null&&r.enabled),onClick:()=>void s(),children:"Check"}),C.jsx("button",{type:"button",disabled:t||!f,onClick:()=>void l({clearApiKey:!0}),children:"Clear key"})]}),r!=null&&r.error?C.jsx("p",{className:"settings-help-text",children:r.error}):null]})}function h2({autoSendEnabled:t,baseUnavailableReason:r,busy:s,enabled:l,memoryInitialized:d,outputMode:m,targetLanguage:f,translatorSession:o,onAutoSendChange:c,onCreateBootstrap:u,onEnabledChange:g,onUpdateMemory:h,onOutputModeChange:S,onTargetLanguageChange:x,onOpenFileTranslation:T,onOpenTranslatorSession:E}){const y=!!(s||r),v=(o==null?void 0:o.status)==="running",_=!!(l&&!r&&v),b=r??(v?null:"Start Translator session first."),k=!!(s||b),R=r??"Open Translator session",D=b??"Translation tools are ready";return C.jsxs("div",{className:"sidebar-settings",children:[C.jsx(Hn,{checked:_,className:"sidebar-switch",disabled:y||!v,label:"Conversation translation",title:D,onChange:g}),C.jsx(Hn,{checked:t,className:"sidebar-switch",disabled:y,label:"Auto-send",onChange:c}),C.jsxs("label",{className:"settings-select-row",children:[C.jsx("span",{children:"Language"}),C.jsx("select",{value:f,disabled:y,onChange:A=>x(A.target.value),children:g_.map(A=>C.jsx("option",{value:A.value,children:A.label},A.value))})]}),C.jsxs("label",{className:"settings-select-row",children:[C.jsx("span",{children:"Reply scope"}),C.jsx("select",{value:m,disabled:y,onChange:A=>S(A.target.value),children:cS.map(A=>C.jsx("option",{value:A.value,children:A.label},A.value))})]}),C.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:T,children:[C.jsx("span",{children:"File translation"}),C.jsx("span",{children:"open"})]}),d?null:C.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:u,children:[C.jsx("span",{children:"Bootstrap"}),C.jsx("span",{children:"run"})]}),C.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:h,children:[C.jsx("span",{children:"Update memory"}),C.jsx("span",{children:"run"})]}),b?C.jsx("p",{className:"settings-help-text",children:b}):null,C.jsxs("div",{className:"settings-status-row",children:[C.jsx("span",{children:"Session status"}),C.jsx("strong",{children:f2(o)})]}),C.jsxs("button",{className:"settings-toggle",disabled:y,title:R,type:"button",onClick:E,children:[C.jsx("span",{children:"Open Session"}),C.jsx("span",{children:"open"})]})]})}function f2(t){return t?t.status==="running"?t.activityStatus??"idle":t.status:"not started"}function d2(t,r,s){return t?r?s?s.initialized?null:"Initialize VCM Harness first.":"Load VCM Harness status first.":"Create or select a task first.":"Connect a repository first."}function p2({busy:t,onCancelGateReview:r,onGateEnabledChange:s,state:l}){return C.jsx("div",{className:"sidebar-settings",children:Wk.map(d=>{const m=l==null?void 0:l.gates[d],f=!!(m!=null&&m.required);return C.jsxs("div",{className:"gate-review-setting",children:[C.jsx(Hn,{checked:f,className:"sidebar-switch",disabled:t||!l||(m==null?void 0:m.status)==="running",label:m2(d),title:m!=null&&m.status?`status: ${m.status}`:void 0,onChange:o=>s(d,o)}),(m==null?void 0:m.status)==="running"&&m.requestId?C.jsx("button",{className:"danger-button",disabled:t,type:"button",onClick:()=>r(d,m.requestId),children:"Cancel review"}):null]},d)})})}function m2(t){switch(t){case"architecture-plan":return"Architecture plan";case"validation-adequacy":return"Validation adequacy";case"code-diff":return"Code diff"}return t}function g2({busy:t,larkRegistration:r,larkRegistrationCheck:s,onEnabledChange:l,onResetBinding:d,onSettingsChange:m,onStartLarkRegistration:f,onStartQrLogin:o,onTranslationChange:c,onConnectionChange:u,qrCheck:g,qrLogin:h,status:S}){const x=(S==null?void 0:S.channel)==="lark",T=(S==null?void 0:S.channel)==="lark"?!!(S.binding.appIdConfigured&&S.binding.appSecretConfigured):!!(S!=null&&S.binding.tokenConfigured),E=(S==null?void 0:S.channel)==="lark"?!!(S.binding.appIdConfigured&&S.binding.appSecretConfigured):!!(S!=null&&S.binding.tokenConfigured);return C.jsxs("div",{className:"gateway-panel",children:[C.jsxs("label",{className:"compact-field",children:[C.jsx("span",{children:"Channel"}),C.jsxs("select",{disabled:t||!S,value:(S==null?void 0:S.channel)??"weixin-ilink",onChange:y=>{m({channel:y.currentTarget.value==="lark"?"lark":"weixin-ilink"})},children:[C.jsx("option",{value:"weixin-ilink",children:"Weixin iLink"}),C.jsx("option",{value:"lark",children:"Lark"})]})]}),C.jsxs("div",{className:"gateway-actions",children:[C.jsx(Hn,{checked:!!(S!=null&&S.connectionEnabled),className:"sidebar-switch",disabled:t||!S||!S.connectionEnabled&&!T,label:"Connection",stateLabel:S!=null&&S.connectionEnabled?"connected":"off",title:T?"Connect or disconnect the channel for this session. Off by default; the phone can drive the gateway only while Connection is on. Separate from the Gateway command switch.":"Configure the selected Gateway channel first",onChange:y=>u(y)}),C.jsx(Hn,{checked:!!(S!=null&&S.enabled),className:"sidebar-switch",disabled:t||!S||!S.enabled&&!T,label:"Gateway",title:T?"Enable or disable role messages and task-changing Gateway commands":"Configure the selected Gateway channel first",onChange:y=>l(y)}),C.jsx(Hn,{checked:!!(S!=null&&S.translationEnabled),className:"sidebar-switch",disabled:t||!S,label:"Translation",onChange:y=>c(y)}),x?C.jsx("button",{type:"button",disabled:t,onClick:f,children:"Start QR Setup"}):E?C.jsx("button",{className:"danger-button",type:"button",disabled:t,onClick:d,children:"Reset Binding"}):C.jsx("button",{type:"button",disabled:t,onClick:o,children:"Start QR Login"})]}),x?C.jsxs("div",{className:"gateway-lark-settings",children:[C.jsx("p",{className:"muted",children:S!=null&&S.binding.appIdConfigured&&S.binding.appSecretConfigured?`Lark app configured${S.binding.larkBotName?` · ${S.binding.larkBotName}`:""}.`:"Use QR setup to create and configure the Lark bot automatically."}),r?C.jsxs("p",{className:"muted",children:["QR setup: ",(s==null?void 0:s.status)??r.status,s!=null&&s.message?` · ${s.message}`:""]}):null]}):h?C.jsx("p",{className:"muted",children:"QR login started. Use the login dialog to confirm binding."}):null,!x&&g?C.jsxs("p",{className:"muted",children:["QR status: ",g.status,g.message?` · ${g.message}`:""]}):null]})}function _2({busy:t,onPull:r,project:s}){const l=s.pullDisabledReason,d=!!s.canPull;return C.jsxs("div",{className:"project-summary",children:[C.jsxs("dl",{children:[C.jsxs("div",{children:[C.jsx("dt",{children:"Base path"}),C.jsx("dd",{children:s.repoRoot})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Branch"}),C.jsx("dd",{children:v2(s)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Remote"}),C.jsx("dd",{children:s.upstreamBranch??"no upstream"})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Status"}),C.jsx("dd",{children:y2(s)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Commit"}),C.jsx("dd",{children:s.shortHeadCommit??s.headCommit??"unknown"})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Working tree"}),C.jsx("dd",{children:s.isDirty?"uncommitted changes":"clean"})]})]}),C.jsxs("div",{className:"connected-repo-actions",children:[C.jsx("button",{type:"button",disabled:t||!d,title:l??"Pull latest changes with git pull --ff-only",onClick:()=>void r(),children:"Pull"}),C.jsx("span",{className:"muted",children:s.checkedAt?`checked ${Hh(s.checkedAt)}`:"status not refreshed"})]}),l?C.jsx("p",{className:"muted",children:l}):null,s.warnings.length>0?C.jsx("ul",{className:"warnings",children:s.warnings.map(m=>C.jsx("li",{children:m},m))}):null]})}function v2(t){return t.branch||"unknown"}function y2(t){if(!t.upstreamBranch)return"no upstream";const r=t.ahead??0,s=t.behind??0;return r===0&&s===0?"up to date":r>0&&s>0?`ahead ${r}, behind ${s}`:r>0?`ahead ${r}`:`behind ${s}`}function S2({roundState:t,task:r}){var g;const[s,l]=ee.useState(()=>Date.now()),d=!!(t!=null&&t.startedAt),m=Nv(r.createdAt,s),f=Zg(t,(t==null?void 0:t.totalCcActiveMs)??0,s),o=d&&t?Zg(t,t.currentRoundCcActiveMs,s):0,c=d&&t?b2(t,s):0,u=((g=r.title)==null?void 0:g.trim())||r.taskSlug;return ee.useEffect(()=>{const h=window.setInterval(()=>l(Date.now()),1e3);return()=>window.clearInterval(h)},[]),C.jsxs("section",{className:"task-status-dock","aria-label":"VCM Session status",children:[C.jsxs("div",{className:"task-status-dock-title",children:[C.jsx("strong",{title:u,children:u}),C.jsx("span",{className:`status-badge status-${r.status}`,children:r.status})]}),C.jsxs("dl",{className:"task-status-stats",children:[C.jsxs("div",{children:[C.jsx("dt",{children:"Session start"}),C.jsx("dd",{children:Hh(r.createdAt)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Session total"}),C.jsx("dd",{children:Ro(m)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Rounds"}),C.jsx("dd",{children:(t==null?void 0:t.totalRoundCount)??0})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Role runtime"}),C.jsx("dd",{children:Ro(f)})]})]}),d&&t?C.jsxs("div",{className:"current-round-status",children:[C.jsxs("div",{className:"current-round-title",children:[C.jsx("span",{children:t.status==="running"?"Current Round":"Last Round"}),C.jsx("span",{className:`status-badge status-${t.status}`,children:t.status})]}),C.jsxs("dl",{className:"task-status-stats",children:[C.jsxs("div",{children:[C.jsx("dt",{children:"Started"}),C.jsx("dd",{children:Hh(t.startedAt)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Total"}),C.jsx("dd",{children:Ro(c)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Role runtime"}),C.jsx("dd",{children:Ro(o)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Turn count"}),C.jsx("dd",{children:t.turnCount})]})]})]}):null]})}function Zg(t,r,s){if(!(t!=null&&t.activeTurnStartedAt)||t.status!=="running")return r;const l=Date.parse(t.updatedAt);return Number.isFinite(l)?r+Math.max(0,s-l):r}function b2(t,r){const s=t.status==="running"?r:Date.parse(t.stoppedAt??t.lastTurnEndedAt??"");return Nv(t.startedAt??"",Number.isFinite(s)?s:r)}function Nv(t,r){const s=Date.parse(t);return Number.isFinite(s)?Math.max(0,r-s):0}function Hh(t){if(!t)return"-";const r=new Date(t);return Number.isNaN(r.getTime())?"-":new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(r)}function Ro(t){const r=Math.max(0,Math.floor(t/1e3)),s=Math.floor(r/3600),l=Math.floor(r%3600/60),d=r%60;return s>0?l>0?`${s}h ${l}m`:`${s}h`:l>0?d>0?`${l}m ${d}s`:`${l}m`:`${d}s`}function C2(t){return t==="system"?"light":t==="light"?"dark":"system"}function e_(t){return t==="system"?"System":t==="light"?"Light":"Dark"}function w2({events:t,onClose:r}){return C.jsx("div",{className:"modal-backdrop",children:C.jsxs("section",{className:"event-modal",role:"dialog","aria-modal":"true","aria-label":"Events",children:[C.jsxs("header",{children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Events"}),C.jsxs("p",{className:"muted",children:[t.length," total"]})]}),C.jsx("button",{type:"button",onClick:r,children:"Close"})]}),C.jsx(Kk,{events:t,maxEvents:null,showHeader:!1})]})})}function x2({busy:t,messages:r,orchestration:s,onClose:l,onMarkAllDone:d,onDeleteMessageHistory:m}){const f=af(r);function o(){window.confirm(["Clear all pending route-file messages?","","Use this only after you manually copied or handled stuck route-file messages.","VCM will clear non-empty handoff message files so Stop-hook orchestration can continue."].join(`
|
|
93
|
+
`;function yk({active:t=!0,autoSendEnabled:r,targetLanguage:s,taskSlug:l,role:d,sessionId:m,panelState:f,onClearSession:o,onEntry:c,onFailures:u}){const[g,h]=ee.useState(""),[S,x]=ee.useState(""),[T,E]=ee.useState(!1),[y,v]=ee.useState(Date.now()),[_,b]=ee.useState(!1),[,k]=Ii(""),L=ee.useRef(null),R=f.entries,D=f.failures,A=f.status;ee.useEffect(()=>{if(!t)return;const N=L.current;if(!N)return;const q=window.requestAnimationFrame(()=>{N.scrollTop=N.scrollHeight});return()=>window.cancelAnimationFrame(q)},[t,R]);const M=Ak(R);ee.useEffect(()=>{if(!M)return;v(Date.now());const N=window.setInterval(()=>v(Date.now()),250);return()=>window.clearInterval(N)},[M]);async function O(N=!1){const q=g;b(!0),k(""),E(!1);try{const I=await ye.translateUserInput(l,d,{text:q,mode:N?"auto-send":"review-before-send",useContext:!1,send:N});I.sent?(h(""),E(!1)):(h(Lv(q,I.englishPreview)),E(!0))}catch(I){k(ft("Translate composer input",I))}finally{b(!1)}}async function H(){const N=S.trim();if(N){b(!0),k("");try{const q=await ye.translateManualOutput(l,d,{text:N});c(m,d,q),x("")}catch(q){k(ft("Translate pasted English output",q))}finally{b(!1)}}}async function U(){b(!0),k("");try{const N=await ye.translateLatestReply(l,d);c(m,d,N)}catch(N){k(ft("Translate final reply",N))}finally{b(!1)}}async function P(){const N=T?Xg(g):g;if(N.trim()){b(!0),k("");try{await ye.sendTranslatedInput(l,d,{englishText:N}),h(""),E(!1)}catch(q){k(ft("Send translated English input to role",q))}finally{b(!1)}}}function W(N){N.key!=="Enter"||N.shiftKey||N.nativeEvent.isComposing||(N.preventDefault(),!_&&g.trim()&&(T?P():O(r)))}async function K(){o(m,d),await ye.clearTranslationSession(m).catch(N=>k(ft("Clear conversation translation panel",N)))}async function V(){b(!0),k("");try{const N=await ye.ignoreTranslationFailures(m);u(m,d,N.failures)}catch(N){k(ft("Ignore failed conversation translations",N))}finally{b(!1)}}async function Y(N){b(!0),k("");try{const q=await ye.retryTranslation(m,N.translationId);c(m,d,q)}catch(q){k(ft("Retry latest failed conversation translation",q))}finally{b(!1)}}const te=Tk(R,A,y),z=D.length,j=bk(D);return C.jsxs("aside",{className:"translation-panel",children:[C.jsxs("header",{className:"translation-panel-header",children:[C.jsxs("div",{className:"translation-panel-titlebar",children:[C.jsx("h2",{children:"Translation"}),C.jsxs("div",{className:"translation-panel-actions",children:[z>0?C.jsxs(C.Fragment,{children:[C.jsxs("button",{type:"button",disabled:_,onClick:()=>void V(),children:["Ignore ",z]}),j?C.jsx("button",{type:"button",disabled:_,onClick:()=>void Y(j),children:"Retry latest"}):null]}):null,C.jsx("button",{type:"button",disabled:_,onClick:()=>void U(),children:"Translate final reply"}),C.jsx("button",{type:"button",onClick:()=>void K(),children:"Clear"})]})]}),C.jsx("div",{className:"translation-status-row",children:C.jsxs("p",{children:["Claude Code · target ",Sk(s)," · ",te]})})]}),C.jsx("div",{className:"translation-manual-panel",children:C.jsxs("div",{className:"translation-composer-row translation-manual-row",children:[C.jsx("textarea",{value:S,onChange:N=>x(N.target.value),placeholder:"Paste English to translate on demand..."}),C.jsx("div",{className:"translation-composer-actions",children:C.jsx("button",{type:"button",disabled:_||!S.trim(),onClick:()=>void H(),children:"Translate"})})]})}),C.jsxs("div",{className:"translation-entry-list",ref:L,children:[R.length===0?C.jsx("p",{className:"muted",children:"Translated Claude Code output will appear here."}):null,R.map(N=>C.jsx(Ek,{entry:N},N.id))]}),C.jsx("div",{className:"translation-composer",children:C.jsxs("div",{className:"translation-composer-row",children:[C.jsx("textarea",{value:g,onChange:N=>{h(N.target.value),(!N.target.value.trim()||T&&!Mk(N.target.value))&&E(!1)},onKeyDown:W,placeholder:"输入中文,先翻译成英文工程指令..."}),C.jsx("div",{className:"translation-composer-actions",children:C.jsx("button",{type:"button",disabled:_||!T||!Xg(g).trim(),onClick:()=>void P(),children:"Send English"})})]})})]})}function Sk(t){var r;return((r=g_.find(s=>s.value===t))==null?void 0:r.label)??t}function bk(t){let r,s=Number.NEGATIVE_INFINITY;for(const l of t){const d=Date.parse(l.failedAt),m=Number.isFinite(d)?d:Number.NEGATIVE_INFINITY;(!r||m>=s)&&(r=l,s=m)}return r}function Ck({open:t,taskSlug:r,targetLanguage:s,onClose:l}){const[d,m]=ee.useState(!1),[,f]=Ii(""),[o,c]=ee.useState(null),[u,g]=ee.useState(""),[h,S]=ee.useState(""),[x,T]=ee.useState(""),[E,y]=ee.useState(!1),[v,_]=ee.useState(null),[b,k]=ee.useState(""),[L,R]=ee.useState(""),[D,A]=ee.useState(""),[M,O]=ee.useState(!1);ol(t?`file-translation:${u||"none"}`:null,()=>H(!0),{intervalMs:2e3,runImmediately:!0});async function H(V=!1){try{const Y=await ye.getTranslationState();c(Y);const te=u?Y.fileIndex.jobs.some(z=>z.id===u):!1;if((!u||!te)&&Y.fileIndex.jobs[0])U(Y.fileIndex.jobs[0].id);else if(!Y.fileIndex.jobs[0])g(""),S(""),T("");else if(V&&u){const z=await ye.readFileTranslation(u);S(z.output),T(z.report)}}catch(Y){f(ft("Load file translation list",Y))}}async function U(V){g(V),S(""),T("");try{const Y=await ye.readFileTranslation(V);S(Y.output),T(Y.report)}catch(Y){f(ft(`Read translated file ${V}`,Y))}}async function P(){y(!0),await W(b,L)}async function W(V="",Y=""){O(!0),f("");try{const te=await ye.browseTranslationSourceFiles({path:V,query:Y,limit:250});_(te),k(te.currentPath),R(Y)}catch(te){f(ft("Browse translation source files",te))}finally{O(!1)}}async function K(V=D){const Y=V.trim();if(Y){m(!0),f("");try{if(!r)throw new Error("Create or select a task before translating files.");const te=await ye.createFileTranslation({taskSlug:r,sourcePath:Y,targetLanguage:s});y(!1),await H(),await U(te.id)}catch(te){f(ft(`Create file translation for ${Y}`,te))}finally{m(!1)}}}return t?C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"modal-backdrop file-translation-backdrop",children:C.jsx(xk,{busy:d,state:o,selectedJobId:u,output:h,report:x,onClose:()=>{y(!1),l()},onRefresh:()=>void H(),onSelectJob:V=>void U(V),onTranslate:()=>void P()})}),E?C.jsx(wk,{busy:d||M,state:v,currentPath:b,query:L,selectedPath:D,onBrowse:(V,Y)=>void W(V,Y),onClose:()=>y(!1),onQueryChange:R,onSelectPath:A,onTranslate:()=>void K()}):null]}):null}function wk({busy:t,state:r,currentPath:s,query:l,selectedPath:d,onBrowse:m,onClose:f,onQueryChange:o,onSelectPath:c,onTranslate:u}){const g=(r==null?void 0:r.entries)??[],h=g.filter(x=>x.type==="directory"),S=g.filter(x=>x.type==="file");return C.jsx("div",{className:"modal-backdrop translation-file-browser-backdrop",children:C.jsxs("section",{className:"translation-file-browser-modal",role:"dialog","aria-modal":"true","aria-label":"Select Source File",children:[C.jsxs("header",{children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Select Source File"}),C.jsx("p",{children:s||"."})]}),C.jsx("button",{type:"button",onClick:f,children:"Close"})]}),C.jsxs("div",{className:"translation-file-browser-controls",children:[C.jsxs("div",{className:"translation-file-browser-nav",children:[C.jsx("button",{type:"button",disabled:t||!s,onClick:()=>m((r==null?void 0:r.parentPath)??"",""),children:"Up"}),C.jsx("button",{type:"button",disabled:t||!s,onClick:()=>m("",""),children:"Root"})]}),C.jsxs("form",{className:"translation-file-browser-search",onSubmit:x=>{x.preventDefault(),m(s,l)},children:[C.jsx("input",{value:l,onChange:x=>o(x.target.value),placeholder:"Search files"}),C.jsx("button",{type:"submit",disabled:t,children:"Search"}),C.jsx("button",{type:"button",disabled:t||!l,onClick:()=>m(s,""),children:"Clear"})]})]}),C.jsxs("div",{className:"translation-file-browser-layout",children:[C.jsxs("div",{className:"translation-file-browser-list",children:[t&&!r?C.jsx("p",{className:"muted",children:"Loading files..."}):null,!t&&g.length===0?C.jsx("p",{className:"muted",children:"No source files found."}):null,h.length>0?C.jsxs("div",{className:"translation-file-browser-group",children:[C.jsx("h3",{children:"Folders"}),h.map(x=>C.jsx(Yg,{entry:x,selected:d===x.path,onBrowse:m,onSelectPath:c},x.path))]}):null,S.length>0?C.jsxs("div",{className:"translation-file-browser-group",children:[C.jsx("h3",{children:"Files"}),S.map(x=>C.jsx(Yg,{entry:x,selected:d===x.path,onBrowse:m,onSelectPath:c},x.path))]}):null,r!=null&&r.truncated?C.jsx("p",{className:"translation-entry-note",children:"Result limit reached."}):null]}),C.jsxs("aside",{className:"translation-file-browser-selection",children:[C.jsxs("label",{children:[C.jsx("span",{children:"Source path"}),C.jsx("input",{value:d,onChange:x=>c(x.target.value)})]}),C.jsx("button",{type:"button",disabled:t||!d.trim(),onClick:u,children:"Translate File"})]})]})]})})}function Yg({entry:t,selected:r,onBrowse:s,onSelectPath:l}){const d=t.type==="directory";return C.jsxs("button",{className:r?"translation-file-browser-entry is-selected":"translation-file-browser-entry",type:"button",onClick:()=>d?s(t.path,""):l(t.path),onDoubleClick:()=>d?s(t.path,""):void 0,children:[C.jsx("span",{children:d?"DIR":"FILE"}),C.jsx("strong",{children:t.name}),C.jsx("small",{children:t.path})]})}function xk({busy:t,state:r,selectedJobId:s,output:l,report:d,onClose:m,onRefresh:f,onSelectJob:o,onTranslate:c}){const u=(r==null?void 0:r.fileIndex.jobs)??[],g=u.find(h=>h.id===s);return C.jsxs("section",{className:"file-translation-modal",role:"dialog","aria-modal":"true","aria-label":"File Translation",children:[C.jsxs("header",{className:"file-translation-header",children:[C.jsxs("div",{children:[C.jsx("h2",{children:"File Translation"}),C.jsx("p",{children:"Claude Code · 中英互译"})]}),C.jsxs("div",{className:"file-translation-toolbar",children:[C.jsx("button",{type:"button",disabled:t,onClick:c,children:"Translate"}),C.jsx("button",{type:"button",disabled:t,onClick:f,children:"Refresh"}),C.jsx("button",{type:"button",onClick:m,children:"Close"})]})]}),r!=null&&r.memoryInitialized?null:C.jsx("p",{className:"translation-entry-note",children:"Translation memory is not initialized. Run Bootstrap from the sidebar before important file translations."}),C.jsxs("div",{className:"file-translation-layout",children:[C.jsxs("div",{className:"file-translation-list",children:[u.length===0?C.jsx("p",{className:"muted",children:"No translated files yet."}):null,u.map(h=>C.jsxs("button",{className:h.id===s?"file-translation-item is-active":"file-translation-item",type:"button",onClick:()=>o(h.id),children:[C.jsx("strong",{children:h.sourcePath}),C.jsxs("span",{children:[h.status," · ",h.targetLanguage]})]},h.id))]}),C.jsx("div",{className:"file-translation-preview",children:g?C.jsxs(C.Fragment,{children:[C.jsxs("header",{children:[C.jsx("strong",{children:g.sourcePath}),C.jsx("span",{children:g.status})]}),C.jsx("div",{className:"translation-markdown",children:C.jsx(rv,{remarkPlugins:[Tv],children:l||d||"Translation output is not available yet."})})]}):C.jsx("p",{className:"muted",children:"Select a translated file to preview it."})})]})]})}function Ek({entry:t}){if(t.sourceKind==="conversation-boundary")return C.jsx(kk,{entry:t});const r=Dk(t),s=t.sourceKind==="tool-output",l=t.direction==="user-input-to-english",d=["translation-entry",`is-${t.sourceKind}`,l?"is-user-input":""].filter(Boolean).join(" ");return C.jsxs("article",{className:d,children:[s?C.jsx("pre",{children:r}):C.jsx("div",{className:"translation-markdown",children:C.jsx(rv,{remarkPlugins:[Tv],children:r})}),t.warning?C.jsx("p",{className:"translation-entry-note",children:t.warning}):null,t.error?C.jsx("p",{className:"translation-entry-note is-error",children:t.error}):null]})}function kk({entry:t}){const r=t.boundaryKind==="end"?"结束":"开始",s=t.conversationTurn??0,l=Ok(t.occurredAt??t.createdAt);return C.jsxs("div",{className:"translation-conversation-boundary","aria-label":`${r} 第 ${s} 轮 ${l}`,children:[C.jsx("span",{className:"translation-boundary-dash","aria-hidden":"true"}),C.jsx("span",{children:r}),C.jsxs("span",{children:["第 ",s," 轮"]}),C.jsx("time",{children:l}),C.jsx("span",{className:"translation-boundary-dash","aria-hidden":"true"})]})}function Ak(t){const r=t.find(Mv);return(r==null?void 0:r.translationStartedAt)??(r==null?void 0:r.createdAt)}function Tk(t,r,s){const l=t.find(Mv);if(l)return`translating ${Lk(Math.max(0,s-Rk(l)))}`;const d=t.at(-1);return(d==null?void 0:d.status)==="failed"||r==="failed"?"error":r}function Mv(t){return t.status==="queued"||t.status==="translating"}function Rk(t){const r=Date.parse(t.translationStartedAt??t.createdAt);return Number.isFinite(r)?r:Date.now()}function Dk(t){return t.status==="queued"||t.status==="translating"?t.sourceText:t.status==="translated"?t.direction==="user-input-to-english"?Lv(t.sourceText,t.translatedText):t.translatedText:t.translatedText||t.sourceText}function Lv(t,r){return`${t.trimEnd()}${Ho}${r.trimStart()}`}function Mk(t){return t.includes(Ho)}function Xg(t){const r=t.indexOf(Ho);return r===-1?t:t.slice(r+Ho.length)}function Lk(t){if(t<1e3)return`${Math.max(.1,t/1e3).toFixed(1)}s`;const r=t/1e3;if(r<60)return`${r.toFixed(1)}s`;const s=Math.floor(r/60),l=Math.floor(r%60).toString().padStart(2,"0");return`${s}:${l}`}function Ok(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleTimeString()}const Bk=8;function jk(){const[t,r]=ee.useState([]);return ee.useEffect(()=>{const s=m=>{var c,u;const f=(u=(c=m.detail)==null?void 0:c.message)==null?void 0:u.trim();if(!f)return;const o=new Date().toISOString();r(g=>{const h=g.find(S=>S.message===f);return h?[{...h,count:h.count+1,updatedAt:o},...g.filter(S=>S.id!==h.id)]:[{id:`ui_error_${Date.now()}_${Math.random().toString(16).slice(2)}`,message:f,count:1,createdAt:o,updatedAt:o},...g].slice(0,Bk)})},l=m=>{var o;const f=((o=m.detail)==null?void 0:o.actions)??[];f.length!==0&&r(c=>c.filter(u=>!f.some(g=>u.message.startsWith(`${g} failed.`))))},d=m=>{var o,c;const f=(c=(o=m.detail)==null?void 0:o.message)==null?void 0:c.trim();f&&r(u=>u.filter(g=>g.message!==f))};return window.addEventListener(bh,s),window.addEventListener(Ch,l),window.addEventListener(wh,d),()=>{window.removeEventListener(bh,s),window.removeEventListener(Ch,l),window.removeEventListener(wh,d)}},[]),t.length===0?null:C.jsxs("aside",{className:"ui-error-center",role:"alert","aria-live":"polite","aria-label":"Application errors",children:[C.jsxs("header",{className:"ui-error-center-header",children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Errors"}),C.jsxs("p",{children:[t.length," active"]})]}),C.jsx("button",{type:"button",onClick:()=>r([]),children:"Clear"})]}),C.jsx("ol",{className:"ui-error-list",children:t.map(s=>C.jsxs("li",{children:[C.jsxs("div",{children:[C.jsx("p",{children:s.message}),C.jsxs("span",{children:[Nk(s.updatedAt),s.count>1?` · repeated ${s.count} times`:""]})]}),C.jsx("button",{type:"button","aria-label":"Dismiss error",onClick:()=>r(l=>l.filter(d=>d.id!==s.id)),children:"Close"})]},s.id))})]})}function Nk(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Hk(t,r){return t.find(s=>s.taskSlug===r)??t[0]??null}function zk(t){if(!(t.mode!=="auto"||t.status!=="running")&&!(!t.activeRole||t.activeRole===t.lastFollowedRole))return t.activeRole}function Ik(t,r){var d;if(!((d=t.flowPause)!=null&&d.paused))return null;const s=t.flowPause.role??t.activeRole??"role",l=t.roleRecovery;return t.flowPause.reason==="role-recovery-failed"&&l?r(l,s):t.flowPause.message??`No new turn started after ${s} stopped.`}function Uk(t){const r=t.roundId??t.startedAt??t.taskSlug,s=t.stoppedAt??t.lastTurnEndedAt??"stopped";return`${r}:${s}`}function Pk(t,r,s){if((r==null?void 0:r.status)==="running")return!0;const l=Date.parse(t.stoppedAt??t.lastTurnEndedAt??"");return!!(s&&Number.isFinite(l)&&l>s)}function Fk(t){return t?"strong":"none"}function qk(t,r){if(!r)return{observation:t,dismissPauseAlert:!1};const s=r.lastGatewayInputMessageId??null;return t.initialized?{observation:{initialized:!0,messageId:s},dismissPauseAlert:!!(r.enabled&&s&&s!==t.messageId)}:{observation:{initialized:!0,messageId:s},dismissPauseAlert:!1}}const $k=3,Gk=3e4,Mo=new Map;function Ov(t,r){const s=ft(t,r);if(!Vk(r))return Mo.set(t,{consecutiveFailures:1,lastMessage:s,lastReportedAt:Date.now()}),s;const l=Mo.get(t),d=((l==null?void 0:l.consecutiveFailures)??0)+1,m=Date.now(),f=d>=$k&&(!l||l.lastMessage!==s||m-l.lastReportedAt>=Gk);return Mo.set(t,{consecutiveFailures:d,lastMessage:s,lastReportedAt:f?m:(l==null?void 0:l.lastReportedAt)??0}),f?s:null}function zo(t){Mo.delete(t),yS([t])}function Vk(t){const r=cl(t);return r.includes("could not reach the VCM backend")||r.includes("Failed to fetch")||r.includes("NetworkError")||r.includes("Load failed")||r.includes("ERR_CONNECTION")}const Wk=["architecture-plan","validation-adequacy","code-diff"];function Kk({events:t,maxEvents:r=8,showHeader:s=!0}){const l=r===null?t:t.slice(-r);return C.jsxs("section",{className:"event-log",children:[s?C.jsx("h2",{children:"Events"}):null,t.length===0?C.jsx("p",{className:"muted",children:"No terminal events yet."}):C.jsx("ol",{children:l.map((d,m)=>C.jsx("li",{children:d},`${d}-${m}`))})]})}function Hn({checked:t,className:r,disabled:s,label:l,stateLabel:d,title:m,onChange:f}){const o=["switch-control",t?"is-on":"is-off",r].filter(Boolean).join(" "),c=d??(t?"on":"off");return C.jsxs("button",{type:"button",role:"switch","aria-checked":t,"aria-label":`${l}: ${c}`,className:o,disabled:s,title:m,onClick:()=>f(!t),children:[C.jsx("span",{className:"switch-control-label",children:l}),C.jsx("span",{className:"switch-control-track","aria-hidden":"true",children:C.jsx("span",{className:"switch-control-thumb"})})]})}function Yk({status:t,bootstrapStatus:r,applyResult:s,hasActiveTask:l=!1,autoTaskHarnessReviewEnabled:d,autoMemoryEnabled:m,launchOptions:f,modelOptions:o,busy:c=!1,onRefresh:u,onApply:g,onOpenStudio:h,onOpenRepositoryDiff:S,onAutoTaskHarnessReviewChange:x,onAutoMemoryChange:T,onLaunchOptionsChange:E,onStartBootstrap:y,onRestartBootstrap:v,onStopBootstrap:_,onRunBootstrap:b}){const[k,L]=ee.useState(!1),R=r==null?void 0:r.session,D=(r==null?void 0:r.status)==="running",A=(R==null?void 0:R.status)==="running",M=(r==null?void 0:r.status)!=="complete";return l?t?C.jsxs("section",{className:"harness-panel",children:[C.jsxs("div",{className:"harness-stage",children:[C.jsxs("div",{className:"harness-panel-header",children:[C.jsxs("div",{children:[C.jsx("strong",{children:"Fixed install"}),C.jsx("p",{className:"muted",children:t.initialized?t.needsApply?`${t.plannedChanges.length} pending updates`:"Up to date":"Not initialized"})]}),C.jsx("div",{className:"harness-actions",children:t.initialized?C.jsxs(C.Fragment,{children:[C.jsx("button",{type:"button",disabled:c,onClick:()=>void u(),children:"Refresh"}),t.needsApply?C.jsx("button",{type:"button",disabled:c,onClick:()=>void g(),children:"Update"}):null]}):C.jsx("button",{type:"button",disabled:c,onClick:()=>void g(),children:"Initialize"})})]}),t.initialized&&t.needsApply?C.jsxs(C.Fragment,{children:[C.jsx("h3",{className:"harness-file-list-title",children:"Files to update"}),C.jsx("ol",{className:"harness-file-list",children:t.plannedChanges.map(O=>C.jsxs("li",{children:[C.jsx("span",{children:O.path}),C.jsx(jn,{status:O.action})]},`${O.path}:${O.action}`))})]}):null]}),C.jsxs("div",{className:"harness-stage",children:[C.jsxs("div",{className:"harness-panel-header",children:[C.jsx("div",{children:C.jsx("strong",{children:"Harness Studio"})}),C.jsx("div",{className:"harness-actions",children:C.jsx("button",{type:"button",disabled:c,onClick:h,children:"Open Studio"})})]}),C.jsx("button",{className:"harness-review-diff-button",type:"button",disabled:c,onClick:S,children:"Review Diff"}),C.jsx(Hn,{checked:d,className:"sidebar-switch",disabled:c,label:"Auto task harness review",title:"Automatically ask Harness Engineer to review task harness after final acceptance completes",onChange:x}),C.jsx(Hn,{checked:m,className:"sidebar-switch",disabled:c,label:"Auto memory",title:"Collect role memory drafts after Final Acceptance and let Harness Engineer apply reviewed memory",onChange:T})]}),M?C.jsx("div",{className:"harness-stage",children:C.jsxs("div",{className:"harness-panel-header",children:[C.jsxs("div",{children:[C.jsx("strong",{children:"Bootstrap"}),C.jsx("p",{className:"muted",children:r?Xk(r.status):"not loaded"})]}),C.jsx("div",{className:"harness-actions",children:C.jsx("button",{type:"button",disabled:c||!(r!=null&&r.canStart),onClick:()=>{L(!0)},children:"Open Bootstrap"})})]})}):null,s!=null&&s.changedFiles.length?C.jsx("div",{className:"harness-result",children:C.jsx("p",{className:"muted",children:s.message})}):null,t.warnings.length>0?C.jsx("ul",{className:"warnings",children:t.warnings.map(O=>C.jsx("li",{children:O},O))}):null,r!=null&&r.warnings.length?C.jsx("ul",{className:"warnings",children:r.warnings.map(O=>C.jsx("li",{children:O},O))}):null,M&&k?C.jsx("div",{className:"harness-bootstrap-modal",role:"dialog","aria-modal":"true","aria-label":"Harness Engineer bootstrap session",children:C.jsxs("div",{className:"harness-bootstrap-modal-surface",children:[C.jsxs("header",{className:"harness-bootstrap-modal-header",children:[C.jsxs("div",{children:[C.jsx("strong",{children:"Harness Engineer Bootstrap"}),C.jsx("p",{className:"muted",children:(R==null?void 0:R.command)??"Start Harness Engineer, then run bootstrap when ready."})]}),C.jsxs("div",{className:"harness-bootstrap-modal-actions",children:[R?C.jsx(jn,{status:R.status}):null,C.jsx("button",{type:"button",onClick:()=>L(!1),children:"Close"})]})]}),C.jsxs("div",{className:"harness-bootstrap-controls",children:[C.jsxs("label",{children:[C.jsx("span",{children:"Permission"}),C.jsx("select",{value:f.permissionMode,disabled:c||D||A,onChange:O=>E({...f,permissionMode:O.target.value}),children:__.map(O=>C.jsx("option",{value:O.value,children:O.label},O.value))})]}),C.jsxs("label",{children:[C.jsx("span",{children:"Model"}),C.jsx("select",{value:f.model,title:(()=>{const O=o.find(H=>H.value===f.model);return O!=null&&O.available?O.description:O==null?void 0:O.unavailableReason})(),disabled:c||D||A,onChange:O=>E({...f,model:O.target.value}),children:o.map(O=>C.jsx("option",{value:O.value,disabled:!O.available,title:O.available?O.description:O.unavailableReason,children:O.label},O.value))})]}),C.jsxs("label",{children:[C.jsx("span",{children:"Effort"}),C.jsx("select",{value:f.effort,disabled:c||D||A,onChange:O=>E({...f,effort:O.target.value}),children:y_.map(O=>C.jsx("option",{value:O.value,children:O.label},O.value))})]}),C.jsxs("div",{className:"harness-bootstrap-control-actions",children:[C.jsx("button",{type:"button",disabled:c||D||!(r!=null&&r.canStart),onClick:()=>void y(f),children:"Start"}),C.jsx("button",{type:"button",disabled:c||D||!(r!=null&&r.canStart),onClick:()=>void v(f),children:"Restart"}),C.jsx("button",{type:"button",disabled:c||!R,onClick:()=>void _(),children:"Stop"}),C.jsx("button",{type:"button",disabled:c||D||!A,onClick:()=>void b(),children:"Run bootstrap"})]})]}),C.jsx("div",{className:"harness-bootstrap-terminal",children:A?C.jsx(Po,{sessionId:R.id,active:k}):C.jsxs("div",{className:"terminal-empty",children:[C.jsx("strong",{children:"Harness Bootstrap"}),C.jsx("span",{children:"Start Harness Engineer first. When it is ready, click Run bootstrap to send the prompt."})]})})]})}):null]}):null:C.jsx("section",{className:"harness-panel",children:C.jsxs("div",{className:"harness-result",children:[C.jsx("strong",{children:"Task required"}),C.jsx("p",{className:"muted",children:"Create or select a task before changing VCM Harness. Harness changes are committed in the active task worktree."})]})})}function Xk(t){return t.replaceAll("_"," ")}function af(t){return{total:t.length,accepted:t.filter(r=>r.acceptedAt).length,delivered:t.filter(r=>r.deliveredAt).length}}function Qk(t,r=6){const s=[...t].sort(e2).map((d,m)=>({message:d,sequence:m+1}));return[...r===null?s:s.slice(-r)].sort((d,m)=>m.sequence-d.sequence)}function Jk({messages:t,orchestration:r,busy:s,maxMessages:l=6,showControls:d=!0,showHeader:m=!0,onModeChange:f,onMarkAllDone:o}){const[c,u]=ee.useState(null),g=af(t),h=(r==null?void 0:r.mode)??"auto",S=Qk(t,l);async function x(T){await t2(T.body),u(T.id),window.setTimeout(()=>u(E=>E===T.id?null:E),1200)}return C.jsxs("section",{className:"message-panel",children:[m?C.jsxs("div",{className:"message-panel-header",children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Messages"}),C.jsxs("p",{className:"muted",children:[g.total," total / ",g.accepted," accepted"]})]}),d&&f?C.jsx("div",{className:"message-controls",children:C.jsx(Hn,{checked:h==="auto",className:"message-mode-toggle",disabled:s,label:"Auto orchestration",onChange:T=>f(T?"auto":"manual")})}):null,d&&o?C.jsx("button",{type:"button",disabled:s,onClick:o,children:"Mark All Done"}):null]}):null,t.length===0?C.jsx("p",{className:"muted",children:"No role messages yet."}):C.jsx("ol",{className:"message-list",children:S.map(({message:T,sequence:E})=>C.jsxs("li",{className:"message-item",children:[C.jsxs("div",{className:"message-item-main",children:[C.jsxs("div",{className:"message-meta",children:[C.jsxs("span",{className:"message-sequence",children:["#",E]}),C.jsx("time",{dateTime:Io(T),children:Zk(Io(T))}),C.jsxs("strong",{children:[T.fromRole," ","->"," ",T.toRole]}),C.jsx("span",{children:T.type})]}),C.jsx("p",{children:T.body}),T.failureReason?C.jsx("span",{className:"message-reason",children:T.failureReason}):null,T.bodyPath?C.jsx("span",{className:"message-path",children:T.bodyPath}):null]}),C.jsx("div",{className:"message-actions",children:C.jsx("button",{type:"button",disabled:s,onClick:()=>void x(T),children:c===T.id?"Copied":"Copy"})})]},T.id))})]})}function Zk(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Io(t){return t.acceptedAt??t.deliveredAt??t.dispatchingAt??t.createdAt}function e2(t,r){const s=Io(t).localeCompare(Io(r));if(s!==0)return s;const l=t.createdAt.localeCompare(r.createdAt);return l!==0?l:t.id.localeCompare(r.id)}async function t2(t){var s;if((s=navigator.clipboard)!=null&&s.writeText){await navigator.clipboard.writeText(t);return}const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly","true"),r.style.position="fixed",r.style.left="-9999px",document.body.appendChild(r),r.select(),document.execCommand("copy"),r.remove()}function n2({defaultPath:t="",recentPaths:r=[],busy:s=!1,onConnect:l}){const[d,m]=ee.useState(t);ee.useEffect(()=>{t&&m(t)},[t]);async function f(o){o.preventDefault(),await l(d)}return C.jsx("form",{className:"repo-connect",onSubmit:f,children:C.jsxs("div",{className:r.length>0?"inline-form has-recent-paths":"inline-form",children:[C.jsx("input",{"aria-label":"Repository path",id:"repo-path",value:d,onChange:o=>m(o.target.value),placeholder:"/path/to/repo"}),r.length>0?C.jsxs("select",{"aria-label":"Recent repositories",className:"repo-recent-select",value:"",onChange:o=>{o.target.value&&m(o.target.value)},children:[C.jsx("option",{value:"",children:"Recent"}),r.map(o=>C.jsx("option",{value:o,children:o},o))]}):null,C.jsx("button",{type:"submit",disabled:s||!d.trim(),children:"Connect"})]})})}function i2({tasks:t,activeTaskSlug:r,onSelect:s}){return C.jsx("nav",{className:"task-nav","aria-label":"Tasks",children:t.map(l=>C.jsxs("button",{className:l.taskSlug===r?"task-nav-item is-active":"task-nav-item",type:"button",onClick:()=>s(l.taskSlug),children:[C.jsx("span",{children:l.title||l.taskSlug}),C.jsx(jn,{status:l.status})]},l.taskSlug))})}function r2({open:t,taskSlug:r,taskTitle:s,onClose:l}){const[d,m]=ee.useState(null),[f,o]=ee.useState(!1),[c,u]=ee.useState(null),g=ee.useCallback(async()=>{o(!0),u(null);try{m(await ye.getTaskUsageAnalytics(r))}catch(h){u(`Load task usage analytics failed. Reason: ${cl(h)}`)}finally{o(!1)}},[r]);return ee.useEffect(()=>{t&&g()},[g,t]),t?C.jsx("div",{className:"modal-backdrop usage-analytics-backdrop",children:C.jsxs("section",{className:"usage-analytics-modal",role:"dialog","aria-modal":"true","aria-label":"Usage Analytics",children:[C.jsxs("header",{className:"usage-analytics-header",children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Usage Analytics"}),C.jsxs("p",{children:[(s==null?void 0:s.trim())||r," · Claude models only"]})]}),C.jsxs("div",{className:"usage-analytics-header-actions",children:[C.jsx("button",{type:"button",disabled:f,onClick:()=>void g(),children:f?"Refreshing...":"Refresh"}),C.jsx("button",{type:"button",onClick:l,children:"Close"})]})]}),c?C.jsx("p",{className:"inline-error usage-analytics-error",children:c}):null,d?C.jsx(s2,{report:d}):C.jsx("div",{className:"usage-analytics-empty",children:f?"Loading usage data...":"No usage data available."})]})}):null}function s2({report:t}){return C.jsxs("div",{className:"usage-analytics-content",children:[C.jsxs("div",{className:"usage-analytics-meta",children:[C.jsx("span",{children:t.updatedAt?`Updated ${l2(t.updatedAt)}`:"No Claude usage recorded yet"}),C.jsxs("span",{children:[bn(t.totals.requestCount)," requests · ",bn(t.totals.sessionCount)," sessions"]})]}),C.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-task-summary",children:[C.jsx("h3",{id:"usage-task-summary",children:"Task Summary"}),C.jsx(a2,{totals:t.totals})]}),C.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-by-role",children:[C.jsx("h3",{id:"usage-by-role",children:"Usage by Role"}),C.jsx("div",{className:"usage-analytics-table-wrap",children:C.jsxs("table",{className:"usage-analytics-table",children:[C.jsx("thead",{children:C.jsx(Qg,{firstColumn:"Role"})}),C.jsx("tbody",{children:t.byRole.map(r=>C.jsxs("tr",{children:[C.jsxs("th",{scope:"row",children:[C.jsx("span",{children:aS(r.role).label}),C.jsxs("small",{children:[bn(r.requestCount)," requests · ",bn(r.sessionCount)," sessions"]})]}),C.jsx(Jg,{totals:r})]},r.role))})]})})]}),C.jsxs("section",{className:"usage-analytics-section","aria-labelledby":"usage-by-model",children:[C.jsx("h3",{id:"usage-by-model",children:"Usage by Model"}),t.byModel.length>0?C.jsx("div",{className:"usage-analytics-table-wrap",children:C.jsxs("table",{className:"usage-analytics-table",children:[C.jsx("thead",{children:C.jsx(Qg,{firstColumn:"Model"})}),C.jsx("tbody",{children:t.byModel.map(r=>C.jsxs("tr",{children:[C.jsxs("th",{scope:"row",children:[C.jsx("span",{children:r.model}),C.jsxs("small",{children:[bn(r.requestCount)," requests · ",bn(r.sessionCount)," sessions"]})]}),C.jsx(Jg,{totals:r})]},r.model))})]})}):C.jsx("p",{className:"usage-analytics-no-models",children:"No Claude model usage recorded yet."})]})]})}function a2({totals:t}){return C.jsxs("dl",{className:"usage-totals-grid",children:[C.jsx(Ja,{label:"Input Tokens",value:bn(t.inputTokens)}),C.jsx(Ja,{label:"Output Tokens",value:bn(t.outputTokens)}),C.jsx(Ja,{label:"Cache Read",value:bn(t.cacheReadTokens)}),C.jsx(Ja,{label:"Cache Creation",value:bn(t.cacheCreationTokens)}),C.jsx(Ja,{label:"Estimated Cost",value:Bv(t.costUsd)})]})}function Ja({label:t,value:r}){return C.jsxs("div",{children:[C.jsx("dt",{children:t}),C.jsx("dd",{children:r})]})}function Qg({firstColumn:t}){return C.jsxs("tr",{children:[C.jsx("th",{scope:"col",children:t}),C.jsx("th",{scope:"col",children:"Input"}),C.jsx("th",{scope:"col",children:"Output"}),C.jsx("th",{scope:"col",children:"Cache Read"}),C.jsx("th",{scope:"col",children:"Cache Creation"}),C.jsx("th",{scope:"col",children:"Estimated Cost"})]})}function Jg({totals:t}){return C.jsxs(C.Fragment,{children:[C.jsx("td",{children:bn(t.inputTokens)}),C.jsx("td",{children:bn(t.outputTokens)}),C.jsx("td",{children:bn(t.cacheReadTokens)}),C.jsx("td",{children:bn(t.cacheCreationTokens)}),C.jsx("td",{children:Bv(t.costUsd)})]})}function bn(t){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(t)}function Bv(t){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}).format(t)}function l2(t){const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function o2({project:t,recentRepositoryPaths:r,tasks:s,activeTaskSlug:l,messages:d,orchestration:m,events:f,roundState:o,gateReview:c,translationEnabled:u,translationAutoSendEnabled:g,translationTargetLanguage:h,translationOutputMode:S,translationMemoryInitialized:x,translatorSession:T,harnessStatus:E,harnessBootstrapStatus:y,harnessApplyResult:v,harnessEngineerLaunchOptions:_,autoTaskHarnessReviewEnabled:b,autoMemoryEnabled:k,gatewayStatus:L,gatewayQrLogin:R,gatewayQrCheck:D,gatewayLarkRegistration:A,gatewayLarkRegistrationCheck:M,codexBridgeStatus:O,modelOptions:H,busy:U,onConnect:P,onRefreshConnectedRepository:W,onPullConnectedRepository:K,onRefreshHarness:V,onApplyHarness:Y,onStartHarnessBootstrap:te,onRestartHarnessBootstrap:z,onStopHarnessBootstrap:j,onRunHarnessBootstrap:N,onOpenHarnessStudio:q,onOpenRepositoryDiff:I,onAutoTaskHarnessReviewChange:ie,onAutoMemoryChange:me,onHarnessEngineerLaunchOptionsChange:_e,onRefreshGateway:Q,onGatewayEnabledChange:$,onGatewaySettingsChange:he,onCodexBridgeSettingsChange:ae,onCodexBridgeCheck:Ce,onGatewayTranslationChange:be,onGatewayConnectionChange:Le,onStartGatewayQrLogin:Fe,onStartGatewayLarkRegistration:He,onResetGatewayBinding:Ee,onGateReviewGateEnabledChange:ce,onCancelGateReviewGate:ze,onTranslationEnabledChange:St,onTranslationAutoSendChange:mt,onTranslationTargetLanguageChange:de,onTranslationOutputModeChange:Ne,onOpenFileTranslation:Ue,onOpenTranslatorSession:it,onCreateTranslationBootstrap:wt,onUpdateTranslationMemory:fe,onCreateTask:we,onCloseTask:Te,onSelectTask:Be,themeMode:je,onAutoOrchestrationChange:bt,onThemeModeChange:qe,pauseAlertSound:Et,onPauseAlertSoundChange:xt,roleRetryEnabled:Nt,onRoleRetryEnabledChange:rt,permissionRequestMode:Wt,onPermissionRequestModeChange:rn,launchTemplate:Cr,canSaveLaunchTemplate:mi,canOneClickStart:gi,onSaveLaunchTemplate:Pi,onOneClickStart:zn,onMarkAllMessagesDone:Fi,onDeleteMessageHistory:Jn}){const[si,sn]=ee.useState(""),[ai,In]=ee.useState(!1),[qi,_i]=ee.useState(!1),[vi,yi]=ee.useState(!1),[wn,Pt]=ee.useState(()=>l?null:"repository"),li=af(d),hn=si.trim(),Kt=d2(t,l,E),gt=s.filter(Ve=>Ve.cleanupStatus!=="cleaned"),ot=gt.find(Ve=>Ve.taskSlug===l)??null;ee.useEffect(()=>{Pt(Ve=>!l&&Ve===null?t?"task":"repository":Ve)},[l,t]);function Ht(Ve,Un){Pt(Un?Ve:null)}async function $i(Ve){Ve.preventDefault(),await we({taskSlug:hn}),sn("")}return C.jsxs("div",{className:"project-dashboard",children:[C.jsx("header",{className:"brand-header",children:C.jsx("strong",{children:"VibeCodingMaster"})}),C.jsx(Kr,{title:"Repository",open:wn==="repository",onOpenChange:Ve=>{Ht("repository",Ve),Ve&&t&&W()},children:C.jsxs("div",{className:"repository-panel",children:[C.jsx(n2,{defaultPath:(t==null?void 0:t.repoRoot)??"",recentPaths:r,busy:U,onConnect:P}),t?C.jsx(_2,{busy:U,project:t,onPull:K}):null]})}),C.jsx(Kr,{title:"Settings",open:wn==="settings",onOpenChange:Ve=>Ht("settings",Ve),children:C.jsxs("div",{className:"sidebar-settings",children:[C.jsxs("button",{"aria-label":`Theme mode: ${e_(je)}`,className:"settings-toggle theme-mode-toggle",disabled:U,title:"Cycle theme: system, light, dark",type:"button",onClick:()=>qe(C2(je)),children:[C.jsx("span",{children:"Theme"}),C.jsx("span",{children:e_(je)})]}),C.jsx(Hn,{checked:((m==null?void 0:m.mode)??"auto")==="auto",className:"sidebar-switch",disabled:U||!l,label:"Auto orchestration",title:l?"Automatically dispatch role messages during the active task":"Create or select a task first",onChange:bt}),C.jsx(Hn,{checked:Et,className:"sidebar-switch",disabled:U,label:"Pause alert sound",title:"Play a sound when VCM shows the fixed flow pause dialog",onChange:Ve=>xt(Ve)}),C.jsx(Hn,{checked:Nt,className:"sidebar-switch",disabled:U,label:"CC auto retry",title:"Retry temporary Claude Code turn failures before showing the flow pause alert",onChange:Ve=>rt(Ve)}),C.jsxs("label",{className:"settings-select-row",children:[C.jsx("span",{children:"Permission requests"}),C.jsxs("select",{value:Wt,disabled:U,onChange:Ve=>rn(Ve.target.value),children:[C.jsx("option",{value:"off",children:"off"}),C.jsx("option",{value:"allowAll",children:"allow all"})]})]}),C.jsx(u2,{busy:U,status:O,onCheck:Ce,onSettingsChange:ae}),C.jsxs("button",{className:"settings-toggle",disabled:U||!mi,title:"Save the current core role launch settings and optional Reviewer settings",type:"button",onClick:Pi,children:[C.jsx("span",{children:"Save launch template"}),C.jsx("span",{children:mi?"ready":"open task"})]}),gi?C.jsxs("button",{className:"settings-toggle is-active",disabled:U,title:c2(Cr),type:"button",onClick:zn,children:[C.jsx("span",{children:"One-click start"}),C.jsx("span",{children:jv(Cr)})]}):null,l?C.jsxs(C.Fragment,{children:[C.jsxs("button",{type:"button",onClick:()=>In(!0),children:[C.jsx("span",{children:"Messages"}),C.jsxs("span",{className:"muted",children:[li.total," total"]})]}),C.jsxs("button",{type:"button",onClick:()=>_i(!0),children:[C.jsx("span",{children:"Events"}),C.jsxs("span",{className:"muted",children:[f.length," total"]})]})]}):null]})}),C.jsx(Kr,{title:"Translation",open:wn==="translation",onOpenChange:Ve=>Ht("translation",Ve),children:C.jsx(h2,{busy:U,enabled:u,autoSendEnabled:g,targetLanguage:h,outputMode:S,memoryInitialized:x,baseUnavailableReason:Kt,translatorSession:T,onAutoSendChange:mt,onCreateBootstrap:wt,onEnabledChange:St,onUpdateMemory:fe,onTargetLanguageChange:de,onOutputModeChange:Ne,onOpenFileTranslation:Ue,onOpenTranslatorSession:it})}),t&&l?C.jsx(Kr,{title:"Gate Review Gates",open:wn==="gate-review-gates",onOpenChange:Ve=>Ht("gate-review-gates",Ve),children:C.jsx(p2,{busy:U,state:c,onCancelGateReview:ze,onGateEnabledChange:ce})}):null,C.jsx(Kr,{title:"Gateway",open:wn==="gateway",onOpenChange:Ve=>{Ht("gateway",Ve),Ve&&Q()},children:C.jsx(g2,{busy:U,qrCheck:D,qrLogin:R,larkRegistration:A,larkRegistrationCheck:M,status:L,onEnabledChange:$,onSettingsChange:he,onResetBinding:Ee,onStartLarkRegistration:He,onStartQrLogin:Fe,onTranslationChange:be,onConnectionChange:Le})}),t?C.jsx(Kr,{title:"VCM Harness",open:wn==="vcm-harness",onOpenChange:Ve=>Ht("vcm-harness",Ve),children:C.jsx(Yk,{status:E,bootstrapStatus:y,applyResult:v,hasActiveTask:!!ot,autoTaskHarnessReviewEnabled:b,autoMemoryEnabled:k,launchOptions:_,modelOptions:H,busy:U,onRefresh:V,onApply:Y,onOpenStudio:q,onOpenRepositoryDiff:I,onAutoTaskHarnessReviewChange:ie,onAutoMemoryChange:me,onLaunchOptionsChange:_e,onStartBootstrap:te,onRestartBootstrap:z,onStopBootstrap:j,onRunBootstrap:N})}):null,t?C.jsx(Kr,{title:"Task",open:wn==="task",onOpenChange:Ve=>Ht("task",Ve),children:gt.length>0?C.jsxs("div",{className:"task-panel",children:[C.jsx(i2,{tasks:gt,activeTaskSlug:l,onSelect:Be}),ot?C.jsxs("div",{className:"task-panel-actions",children:[C.jsx("button",{type:"button",onClick:()=>yi(!0),children:"Usage Analytics"}),C.jsx("button",{className:"danger-button",disabled:U,type:"button",onClick:Te,children:"Close Task"})]}):null]}):C.jsx("div",{className:"task-create",children:C.jsxs("form",{onSubmit:$i,children:[C.jsx("input",{value:si,onChange:Ve=>sn(Ve.target.value),placeholder:"task name"}),C.jsxs("div",{className:"task-create-preview",children:[C.jsxs("small",{children:["branch: ",hn?`feature/${hn}`:"feature/<task>"]}),C.jsxs("small",{children:["worktree: ",hn?`.claude/worktrees/${hn}`:".claude/worktrees/<task>"]})]}),C.jsx("button",{type:"submit",disabled:U||!hn,children:"Create"})]})})}):null,t&&ot?C.jsx(S2,{task:ot,roundState:o}):null,ai?C.jsx(x2,{busy:U,messages:d,orchestration:m,onClose:()=>In(!1),onMarkAllDone:()=>{l&&Fi(l)},onDeleteMessageHistory:()=>{l&&Jn(l)}}):null,qi?C.jsx(w2,{events:f,onClose:()=>_i(!1)}):null,ot?C.jsx(r2,{open:vi,taskSlug:ot.taskSlug,taskTitle:ot.title,onClose:()=>yi(!1)}):null]})}function jv(t){return[t.autoOrchestration?"auto":"manual"].join(" + ")}function c2(t){const r=Object.entries(t.roles).map(([s,l])=>`${s}: ${l.permissionMode} / ${l.model} / ${l.effort}`).join("; ");return`Launch template: ${jv(t)}; ${r}`}function u2({busy:t,status:r,onCheck:s,onSettingsChange:l}){const[d,m]=ee.useState(""),f=!!(r!=null&&r.apiKeyConfigured),o=async c=>{c.preventDefault();const u=d.trim();u&&(await l({apiKey:u}),m(""))};return C.jsxs("div",{className:"codex-bridge-settings",children:[C.jsx(Hn,{checked:!!(r!=null&&r.enabled),className:"sidebar-switch",disabled:t||!f,label:"Codex Bridge models",title:f?"Enable Codex models through Codex Bridge":"Save the Codex Bridge API key first",onChange:c=>void l({enabled:c})}),C.jsxs("form",{className:"codex-bridge-api-key-form",onSubmit:c=>void o(c),children:[C.jsx("label",{htmlFor:"codex-bridge-api-key",children:"Codex Bridge API key"}),C.jsxs("div",{children:[C.jsx("input",{id:"codex-bridge-api-key",type:"password",autoComplete:"off",disabled:t,placeholder:f?"Saved":"Required",value:d,onChange:c=>m(c.target.value)}),C.jsx("button",{type:"submit",disabled:t||!d.trim(),children:"Save"})]})]}),C.jsxs("div",{className:"settings-status-row",children:[C.jsx("span",{children:"Codex Bridge status"}),C.jsx("strong",{children:(r==null?void 0:r.connectionState)??"loading"})]}),C.jsxs("div",{className:"codex-bridge-actions",children:[C.jsx("button",{type:"button",disabled:t||!(r!=null&&r.enabled),onClick:()=>void s(),children:"Check"}),C.jsx("button",{type:"button",disabled:t||!f,onClick:()=>void l({clearApiKey:!0}),children:"Clear key"})]}),r!=null&&r.error?C.jsx("p",{className:"settings-help-text",children:r.error}):null]})}function h2({autoSendEnabled:t,baseUnavailableReason:r,busy:s,enabled:l,memoryInitialized:d,outputMode:m,targetLanguage:f,translatorSession:o,onAutoSendChange:c,onCreateBootstrap:u,onEnabledChange:g,onUpdateMemory:h,onOutputModeChange:S,onTargetLanguageChange:x,onOpenFileTranslation:T,onOpenTranslatorSession:E}){const y=!!(s||r),v=(o==null?void 0:o.status)==="running",_=!!(l&&!r&&v),b=r??(v?null:"Start Translator session first."),k=!!(s||b),R=r??"Open Translator session",D=b??"Translation tools are ready";return C.jsxs("div",{className:"sidebar-settings",children:[C.jsx(Hn,{checked:_,className:"sidebar-switch",disabled:y||!v,label:"Conversation translation",title:D,onChange:g}),C.jsx(Hn,{checked:t,className:"sidebar-switch",disabled:y,label:"Auto-send",onChange:c}),C.jsxs("label",{className:"settings-select-row",children:[C.jsx("span",{children:"Language"}),C.jsx("select",{value:f,disabled:y,onChange:A=>x(A.target.value),children:g_.map(A=>C.jsx("option",{value:A.value,children:A.label},A.value))})]}),C.jsxs("label",{className:"settings-select-row",children:[C.jsx("span",{children:"Reply scope"}),C.jsx("select",{value:m,disabled:y,onChange:A=>S(A.target.value),children:cS.map(A=>C.jsx("option",{value:A.value,children:A.label},A.value))})]}),C.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:T,children:[C.jsx("span",{children:"File translation"}),C.jsx("span",{children:"open"})]}),d?null:C.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:u,children:[C.jsx("span",{children:"Bootstrap"}),C.jsx("span",{children:"run"})]}),C.jsxs("button",{className:"settings-toggle",disabled:k,title:D,type:"button",onClick:h,children:[C.jsx("span",{children:"Update memory"}),C.jsx("span",{children:"run"})]}),b?C.jsx("p",{className:"settings-help-text",children:b}):null,C.jsxs("div",{className:"settings-status-row",children:[C.jsx("span",{children:"Session status"}),C.jsx("strong",{children:f2(o)})]}),C.jsxs("button",{className:"settings-toggle",disabled:y,title:R,type:"button",onClick:E,children:[C.jsx("span",{children:"Open Session"}),C.jsx("span",{children:"open"})]})]})}function f2(t){return t?t.status==="running"?t.activityStatus??"idle":t.status:"not started"}function d2(t,r,s){return t?r?s?s.initialized?null:"Initialize VCM Harness first.":"Load VCM Harness status first.":"Create or select a task first.":"Connect a repository first."}function p2({busy:t,onCancelGateReview:r,onGateEnabledChange:s,state:l}){return C.jsx("div",{className:"sidebar-settings",children:Wk.map(d=>{const m=l==null?void 0:l.gates[d],f=!!(m!=null&&m.required);return C.jsxs("div",{className:"gate-review-setting",children:[C.jsx(Hn,{checked:f,className:"sidebar-switch",disabled:t||!l||(m==null?void 0:m.status)==="running",label:m2(d),title:m!=null&&m.status?`status: ${m.status}`:void 0,onChange:o=>s(d,o)}),(m==null?void 0:m.status)==="running"&&m.requestId?C.jsx("button",{className:"danger-button",disabled:t,type:"button",onClick:()=>r(d,m.requestId),children:"Cancel review"}):null]},d)})})}function m2(t){switch(t){case"architecture-plan":return"Architecture plan";case"validation-adequacy":return"Validation adequacy";case"code-diff":return"Code diff"}return t}function g2({busy:t,larkRegistration:r,larkRegistrationCheck:s,onEnabledChange:l,onResetBinding:d,onSettingsChange:m,onStartLarkRegistration:f,onStartQrLogin:o,onTranslationChange:c,onConnectionChange:u,qrCheck:g,qrLogin:h,status:S}){const x=(S==null?void 0:S.channel)==="lark",T=(S==null?void 0:S.channel)==="lark"?!!(S.binding.appIdConfigured&&S.binding.appSecretConfigured):!!(S!=null&&S.binding.tokenConfigured),E=(S==null?void 0:S.channel)==="lark"?!!(S.binding.appIdConfigured&&S.binding.appSecretConfigured):!!(S!=null&&S.binding.tokenConfigured);return C.jsxs("div",{className:"gateway-panel",children:[C.jsxs("label",{className:"compact-field",children:[C.jsx("span",{children:"Channel"}),C.jsxs("select",{disabled:t||!S,value:(S==null?void 0:S.channel)??"weixin-ilink",onChange:y=>{m({channel:y.currentTarget.value==="lark"?"lark":"weixin-ilink"})},children:[C.jsx("option",{value:"weixin-ilink",children:"Weixin iLink"}),C.jsx("option",{value:"lark",children:"Lark"})]})]}),C.jsxs("div",{className:"gateway-actions",children:[C.jsx(Hn,{checked:!!(S!=null&&S.connectionEnabled),className:"sidebar-switch",disabled:t||!S||!S.connectionEnabled&&!T,label:"Connection",stateLabel:S!=null&&S.connectionEnabled?"connected":"off",title:T?"Connect or disconnect the channel for this session. Off by default; the phone can drive the gateway only while Connection is on. Separate from the Gateway command switch.":"Configure the selected Gateway channel first",onChange:y=>u(y)}),C.jsx(Hn,{checked:!!(S!=null&&S.enabled),className:"sidebar-switch",disabled:t||!S||!S.enabled&&!T,label:"Gateway",title:T?"Enable or disable role messages and task-changing Gateway commands":"Configure the selected Gateway channel first",onChange:y=>l(y)}),C.jsx(Hn,{checked:!!(S!=null&&S.translationEnabled),className:"sidebar-switch",disabled:t||!S,label:"Translation",onChange:y=>c(y)}),x?C.jsx("button",{type:"button",disabled:t,onClick:f,children:"Start QR Setup"}):E?C.jsx("button",{className:"danger-button",type:"button",disabled:t,onClick:d,children:"Reset Binding"}):C.jsx("button",{type:"button",disabled:t,onClick:o,children:"Start QR Login"})]}),x?C.jsxs("div",{className:"gateway-lark-settings",children:[C.jsx("p",{className:"muted",children:S!=null&&S.binding.appIdConfigured&&S.binding.appSecretConfigured?`Lark app configured${S.binding.larkBotName?` · ${S.binding.larkBotName}`:""}.`:"Use QR setup to create and configure the Lark bot automatically."}),r?C.jsxs("p",{className:"muted",children:["QR setup: ",(s==null?void 0:s.status)??r.status,s!=null&&s.message?` · ${s.message}`:""]}):null]}):h?C.jsx("p",{className:"muted",children:"QR login started. Use the login dialog to confirm binding."}):null,!x&&g?C.jsxs("p",{className:"muted",children:["QR status: ",g.status,g.message?` · ${g.message}`:""]}):null]})}function _2({busy:t,onPull:r,project:s}){const l=s.pullDisabledReason,d=!!s.canPull;return C.jsxs("div",{className:"project-summary",children:[C.jsxs("dl",{children:[C.jsxs("div",{children:[C.jsx("dt",{children:"Base path"}),C.jsx("dd",{children:s.repoRoot})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Branch"}),C.jsx("dd",{children:v2(s)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Remote"}),C.jsx("dd",{children:s.upstreamBranch??"no upstream"})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Status"}),C.jsx("dd",{children:y2(s)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Commit"}),C.jsx("dd",{children:s.shortHeadCommit??s.headCommit??"unknown"})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Working tree"}),C.jsx("dd",{children:s.isDirty?"uncommitted changes":"clean"})]})]}),C.jsxs("div",{className:"connected-repo-actions",children:[C.jsx("button",{type:"button",disabled:t||!d,title:l??"Pull latest changes with git pull --ff-only",onClick:()=>void r(),children:"Pull"}),C.jsx("span",{className:"muted",children:s.checkedAt?`checked ${Hh(s.checkedAt)}`:"status not refreshed"})]}),l?C.jsx("p",{className:"muted",children:l}):null,s.warnings.length>0?C.jsx("ul",{className:"warnings",children:s.warnings.map(m=>C.jsx("li",{children:m},m))}):null]})}function v2(t){return t.branch||"unknown"}function y2(t){if(!t.upstreamBranch)return"no upstream";const r=t.ahead??0,s=t.behind??0;return r===0&&s===0?"up to date":r>0&&s>0?`ahead ${r}, behind ${s}`:r>0?`ahead ${r}`:`behind ${s}`}function S2({roundState:t,task:r}){var g;const[s,l]=ee.useState(()=>Date.now()),d=!!(t!=null&&t.startedAt),m=Nv(r.createdAt,s),f=Zg(t,(t==null?void 0:t.totalCcActiveMs)??0,s),o=d&&t?Zg(t,t.currentRoundCcActiveMs,s):0,c=d&&t?b2(t,s):0,u=((g=r.title)==null?void 0:g.trim())||r.taskSlug;return ee.useEffect(()=>{const h=window.setInterval(()=>l(Date.now()),1e3);return()=>window.clearInterval(h)},[]),C.jsxs("section",{className:"task-status-dock","aria-label":"VCM Session status",children:[C.jsxs("div",{className:"task-status-dock-title",children:[C.jsx("strong",{title:u,children:u}),C.jsx("span",{className:`status-badge status-${r.status}`,children:r.status})]}),C.jsxs("dl",{className:"task-status-stats",children:[C.jsxs("div",{children:[C.jsx("dt",{children:"Session start"}),C.jsx("dd",{children:Hh(r.createdAt)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Session total"}),C.jsx("dd",{children:Ro(m)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Rounds"}),C.jsx("dd",{children:(t==null?void 0:t.totalRoundCount)??0})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Role runtime"}),C.jsx("dd",{children:Ro(f)})]})]}),d&&t?C.jsxs("div",{className:"current-round-status",children:[C.jsxs("div",{className:"current-round-title",children:[C.jsx("span",{children:t.status==="running"?"Current Round":"Last Round"}),C.jsx("span",{className:`status-badge status-${t.status}`,children:t.status})]}),C.jsxs("dl",{className:"task-status-stats",children:[C.jsxs("div",{children:[C.jsx("dt",{children:"Started"}),C.jsx("dd",{children:Hh(t.startedAt)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Total"}),C.jsx("dd",{children:Ro(c)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Role runtime"}),C.jsx("dd",{children:Ro(o)})]}),C.jsxs("div",{children:[C.jsx("dt",{children:"Turn count"}),C.jsx("dd",{children:t.turnCount})]})]})]}):null]})}function Zg(t,r,s){if(!(t!=null&&t.activeTurnStartedAt)||t.status!=="running")return r;const l=Date.parse(t.updatedAt);return Number.isFinite(l)?r+Math.max(0,s-l):r}function b2(t,r){const s=t.status==="running"?r:Date.parse(t.stoppedAt??t.lastTurnEndedAt??"");return Nv(t.startedAt??"",Number.isFinite(s)?s:r)}function Nv(t,r){const s=Date.parse(t);return Number.isFinite(s)?Math.max(0,r-s):0}function Hh(t){if(!t)return"-";const r=new Date(t);return Number.isNaN(r.getTime())?"-":new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(r)}function Ro(t){const r=Math.max(0,Math.floor(t/1e3)),s=Math.floor(r/3600),l=Math.floor(r%3600/60),d=r%60;return s>0?l>0?`${s}h ${l}m`:`${s}h`:l>0?d>0?`${l}m ${d}s`:`${l}m`:`${d}s`}function C2(t){return t==="system"?"light":t==="light"?"dark":"system"}function e_(t){return t==="system"?"System":t==="light"?"Light":"Dark"}function w2({events:t,onClose:r}){return C.jsx("div",{className:"modal-backdrop",children:C.jsxs("section",{className:"event-modal",role:"dialog","aria-modal":"true","aria-label":"Events",children:[C.jsxs("header",{children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Events"}),C.jsxs("p",{className:"muted",children:[t.length," total"]})]}),C.jsx("button",{type:"button",onClick:r,children:"Close"})]}),C.jsx(Kk,{events:t,maxEvents:null,showHeader:!1})]})})}function x2({busy:t,messages:r,orchestration:s,onClose:l,onMarkAllDone:d,onDeleteMessageHistory:m}){const f=af(r);function o(){window.confirm(["Clear all pending route-file messages?","","Use this only after you manually copied or handled stuck route-file messages.","VCM will clear non-empty handoff message files so Stop-hook orchestration can continue."].join(`
|
|
94
94
|
`))&&d()}function c(){window.confirm([`Delete ${f.total} message histor${f.total===1?"y item":"y items"}?`,"","This removes message history from the Messages panel.","Pending route-file messages are not touched."].join(`
|
|
95
95
|
`))&&m()}return C.jsx("div",{className:"modal-backdrop",children:C.jsxs("section",{className:"message-modal",role:"dialog","aria-modal":"true","aria-label":"Messages",children:[C.jsxs("header",{children:[C.jsxs("div",{children:[C.jsx("h2",{children:"Messages"}),C.jsxs("p",{className:"muted",children:[f.total," total / ",f.accepted," accepted",s?` · ${s.mode}`:""]})]}),C.jsxs("div",{className:"modal-actions",children:[C.jsx("button",{type:"button",disabled:t,onClick:o,children:"Mark All Done"}),C.jsx("button",{type:"button",disabled:t||f.total===0,onClick:c,children:"Delete All"}),C.jsx("button",{type:"button",onClick:l,children:"Close"})]})]}),C.jsx(Jk,{busy:t,maxMessages:null,messages:r,orchestration:s,showControls:!1,showHeader:!1})]})})}function Kr({children:t,onOpenChange:r,open:s,title:l}){return C.jsxs("section",{className:"sidebar-section",children:[C.jsxs("button",{"aria-expanded":s,className:"sidebar-section-toggle",type:"button",onClick:()=>{r==null||r(!s)},children:[C.jsx("span",{children:l}),C.jsx("span",{"aria-hidden":"true",className:"sidebar-section-chevron"})]}),s?C.jsx("div",{className:"sidebar-section-content",children:t}):null]})}function Hv(t,r){return t.find(s=>s.role===r)}function E2({activeRole:t,roles:r=Uo,sessions:s,onSelect:l}){return C.jsx("div",{className:"role-tabs",role:"tablist","aria-label":"Role sessions",children:r.map(d=>{const m=Hv(s,d.name),f=(m==null?void 0:m.status)==="running"?m.activityStatus??"idle":(m==null?void 0:m.status)??"not_started";return C.jsxs("button",{className:d.name===t?"role-tab is-active":"role-tab",type:"button",role:"tab","aria-selected":d.name===t,onClick:()=>l(d.name),children:[C.jsx("span",{children:d.label}),C.jsx(jn,{status:f})]},d.name)})})}function k2({role:t,session:r,permissionMode:s,model:l,effort:d,modelOptions:m,active:f=!0,busy:o,translationEnabled:c,translationAutoSendEnabled:u,translationTargetLanguage:g,translationPanelState:h,onClearTranslationSession:S,onTranslationEntry:x,onTranslationFailures:T,onPermissionModeChange:E,onModelChange:y,onEffortChange:v,onStart:_,onResume:b,onStop:k,onRestart:L,onRestartWithContext:R,onNotifyHarnessUpdated:D,onTerminalEvent:A}){const M=m_(t)&&c&&(r==null?void 0:r.status)==="running";return C.jsx("section",{className:"session-console",children:C.jsxs("div",{className:M?"session-console-body has-translation":"session-console-body",children:[C.jsxs("div",{className:"terminal-pane",children:[C.jsx(Uh,{role:t,session:r,permissionMode:s,model:l,effort:d,modelOptions:m,busy:o,onPermissionModeChange:E,onModelChange:y,onEffortChange:v,onStart:_,onResume:b,onStop:k,onRestart:L,onRestartWithContext:R,onNotifyHarnessUpdated:D}),(r==null?void 0:r.status)==="running"?C.jsx(Po,{sessionId:r.id,active:f,onEvent:A},r.id):C.jsxs("div",{className:"terminal-empty",children:[C.jsx("strong",{children:t}),C.jsx("span",{children:r!=null&&r.claudeSessionId?"Resume this role to reconnect its Claude Code conversation.":"Start this role to open an embedded Claude Code terminal."})]})]}),M?C.jsx("div",{className:"translation-pane",children:C.jsx(yk,{active:f,autoSendEnabled:u,targetLanguage:g,taskSlug:r.taskSlug,role:t,sessionId:r.id,panelState:h??{role:t,status:"ready",entries:[],failures:[]},onClearSession:S??(()=>{}),onEntry:x??(()=>{}),onFailures:T??(()=>{})},`${t}:${r.id}`)}):null]})})}const Sh=500;function zh(t){return{taskSlug:t,cursor:1,sessions:{}}}function A2(t,r,s){return t.sessions[r]??Ws(s)}function T2(t,r){const l={...L2(t,r.taskSlug).sessions};for(const d of r.sessions)l[d.sessionId]={...Ws(d.role),...l[d.sessionId],role:d.role,status:d.status};for(const d of r.events){const m=l[d.sessionId]??Ws(d.role);if(d.event.type==="status")l[d.sessionId]={...m,role:d.role,status:d.event.status};else if(d.event.type==="failures")l[d.sessionId]={...m,role:d.role,failures:d.event.failures};else if(d.event.type==="entry"){const f=Iv(zv(m.entries,d.event.entry));l[d.sessionId]={...m,role:d.role,entries:f.entries,failures:f.removedIds.size>0?m.failures.filter(o=>!f.removedIds.has(o.translationId)):m.failures}}}return{taskSlug:r.taskSlug,cursor:r.nextCursor,sessions:l}}function R2(t,r,s){return{...t,sessions:{...t.sessions,[r]:Ws(s)}}}function D2(t,r,s,l){const d=t.sessions[r]??Ws(s),m=Iv(zv(d.entries,l));return{...t,sessions:{...t.sessions,[r]:{...d,role:s,entries:m.entries,failures:m.removedIds.size>0?d.failures.filter(f=>!m.removedIds.has(f.translationId)):d.failures}}}}function M2(t,r,s,l){const d=t.sessions[r]??Ws(s);return{...t,sessions:{...t.sessions,[r]:{...d,role:s,failures:l}}}}function L2(t,r){return t.taskSlug===r?t:zh(r)}function Ws(t){return{role:t,status:"ready",entries:[],failures:[]}}function zv(t,r){return t.findIndex(l=>l.id===r.id)===-1?[...t,r]:t.map(l=>l.id===r.id?r:l)}function Iv(t){if(t.length<=Sh)return{entries:t,removedIds:new Set};const r=t.slice(0,t.length-Sh);return{entries:t.slice(-Sh),removedIds:new Set(r.map(s=>s.id))}}const O2={"project-manager":"bypassPermissions",architect:"bypassPermissions",coder:"bypassPermissions",tester:"bypassPermissions",reviewer:"bypassPermissions",translator:"bypassPermissions","harness-engineer":"bypassPermissions"},B2={"project-manager":"default",architect:"default",coder:"default",tester:"default",reviewer:"default",translator:"default","harness-engineer":"default"},j2={"project-manager":"default",architect:"default",coder:"default",tester:"default",reviewer:"default",translator:"medium","harness-engineer":"medium"};function N2({task:t,activeRole:r,reviewerEnabled:s,translationEnabled:l,translationAutoSendEnabled:d,translationTargetLanguage:m,launchTemplate:f,modelOptions:o,refreshNonce:c=0,onTaskChanged:u,onActiveRoleChange:g,onMessagesChanged:h,onOrchestrationChanged:S,onRoundStateChanged:x,onEventsChanged:T,onLaunchStateChanged:E}){const[y,v]=ee.useState(null),[_,b]=ee.useState(()=>n_(f)),[k,L]=ee.useState(()=>i_(f)),[R,D]=ee.useState(()=>r_(f)),[A,M]=ee.useState(!1),[,O]=Ii(""),[H,U]=ee.useState([]),[P,W]=ee.useState(null),[K,V]=ee.useState(null),[Y,te]=ee.useState(null),[z,j]=ee.useState(()=>zh(t.taskSlug)),N=ee.useRef(""),q=ee.useRef(1),I=ee.useMemo(()=>JSON.stringify(f),[f]),ie=!!(y!=null&&y.sessions.some(Ee=>Ee.role==="reviewer")),me=s||ie,_e=[...sl,...me?[f_]:[]],Q=ee.useCallback((Ee,ce)=>{W(ce),h==null||h(Ee),S==null||S(ce)},[h,S]),$=ee.useCallback((Ee,ce,ze,St,mt)=>{v(Ee),V(mt),Q(ce,ze),x==null||x(St)},[Q,x]),he=ee.useCallback(async()=>{const Ee=await ye.getTaskWorkspaceState(t.taskSlug);te(Ee.architectRestart),$(Ee.taskStatus,Ee.messages,Ee.orchestration,Ee.roundState,Ee.workflowState),zo("Poll task workspace state"),O(ce=>Lo(ce,["Load task workspace state","Poll task workspace state"]))},[$,t.taskSlug]),ae=ee.useCallback((Ee,ce)=>{const ze=Ov(Ee,ce);ze&&O(ze)},[]);ol(`task-workspace:${t.taskSlug}:${c}`,()=>he().catch(Ee=>{ae("Poll task workspace state",Ee)}),{intervalMs:3e3,runImmediately:!0}),ol(l?`task-translation-feed:${t.taskSlug}`:null,async()=>{try{const Ee=await ye.pollTranslationTaskFeed(t.taskSlug,q.current);q.current=Ee.nextCursor,j(ce=>T2(ce,Ee)),zo("Poll task translation feed"),O(ce=>Lo(ce,["Poll task translation feed"]))}catch(Ee){ae("Poll task translation feed",Ee)}},{intervalMs:1e3,runImmediately:!0}),ee.useEffect(()=>{U([]),V(null),T==null||T([])},[T,t.taskSlug]),ee.useEffect(()=>{q.current=1,j(zh(t.taskSlug))},[t.taskSlug]),ee.useEffect(()=>{b(n_(f)),L(i_(f)),D(r_(f))},[I,t.taskSlug]),ee.useEffect(()=>{y&&!me&&r==="reviewer"&&g("project-manager"),y&&r==="translator"&&g("project-manager")},[r,me,g,y]),ee.useEffect(()=>{const Ee=y==null?void 0:y.task;if(!Ee||Ee.taskSlug!==t.taskSlug)return;const ce=t_(Ee);if(ce===t_(t)){N.current="";return}N.current!==ce&&(N.current=ce,u().catch(ze=>{N.current="",O(ft("Refresh task list after task status changed",ze))}))},[u,y==null?void 0:y.task,t]),ee.useEffect(()=>{const Ee=(y==null?void 0:y.sessions)??[],ce=Ee.filter(de=>H2(de.role)),ze=new Set(ce.map(de=>de.role)),St=Ee.some(de=>de.role==="reviewer"),mt={};for(const de of Ks)mt[de.name]={permissionMode:_[de.name],model:k[de.name],effort:R[de.name]};E==null||E({taskSlug:t.taskSlug,roles:mt,autoOrchestration:((P==null?void 0:P.mode)??"auto")==="auto",statusLoaded:!!y,sessionCount:ce.length,hasAnySession:ce.length>0,hasReviewerSession:St,allRolesHaveSession:sl.every(de=>ze.has(de.name))})},[k,R,E,P==null?void 0:P.mode,_,y,t.taskSlug]);async function Ce(Ee,ce="Run role session action"){M(!0),O("");try{await Ee(),await he(),await u()}catch(ze){O(ft(ce,ze))}finally{M(!1)}}function be(Ee){U(ce=>{const ze=[...ce,`${new Date().toLocaleTimeString()} ${Ee}`];return T==null||T(ze),ze})}function Le(Ee,ce){b(ze=>({...ze,[Ee]:ce}))}function Fe(Ee,ce){L(ze=>({...ze,[Ee]:ce}))}function He(Ee,ce){D(ze=>({...ze,[Ee]:ce}))}return C.jsxs("div",{className:"task-workspace",children:[C.jsxs("header",{className:"workspace-header",children:[C.jsxs("div",{className:"workspace-title-line",children:[C.jsx("h1",{children:t.title||t.taskSlug}),K!=null&&K.declared?C.jsxs("div",{className:"workspace-workflow-state",title:[K.declared.branch?`Branch: ${K.declared.branch}`:"",K.declared.resumePoint?`Resume: ${K.declared.resumePoint}`:"",K.declared.status?`Status: ${K.declared.status}`:""].filter(Boolean).join(" | "),children:[C.jsx("span",{children:K.declared.flow??"Workflow"}),K.declared.step?C.jsx("strong",{children:K.declared.step}):null]}):null]}),C.jsx(E2,{activeRole:r,roles:_e,sessions:(y==null?void 0:y.sessions)??[],onSelect:g})]}),(Y==null?void 0:Y.status)==="blocked"&&Y.blocker?C.jsxs("div",{className:"workspace-runtime-warning",role:"alert",children:[C.jsx("strong",{children:"Architect restart blocked"}),C.jsx("span",{children:Y.blocker.message}),C.jsx("code",{children:Y.blocker.code})]}):null,C.jsx("div",{className:"workspace-grid",children:C.jsx("div",{className:"workspace-main",children:C.jsx("div",{className:"role-console-stack",children:_e.map(Ee=>{const ce=Ee.name,ze=ce===r,St=(y==null?void 0:y.sessions)??[],mt=Hv(St,ce),de=mt?A2(z,mt.id,ce):void 0;return C.jsx("div",{className:ze?"role-console-panel is-active":"role-console-panel","aria-hidden":!ze,children:C.jsx(k2,{role:ce,session:mt,permissionMode:_[ce],model:k[ce],effort:R[ce],modelOptions:o,active:ze,busy:A,translationEnabled:l,translationAutoSendEnabled:d,translationTargetLanguage:m,translationPanelState:de,onClearTranslationSession:(Ne,Ue)=>{j(it=>R2(it,Ne,Ue))},onTranslationEntry:(Ne,Ue,it)=>{j(wt=>D2(wt,Ne,Ue,it))},onTranslationFailures:(Ne,Ue,it)=>{j(wt=>M2(wt,Ne,Ue,it))},onPermissionModeChange:Ne=>Le(ce,Ne),onModelChange:Ne=>Fe(ce,Ne),onEffortChange:Ne=>He(ce,Ne),onStart:()=>void Ce(async()=>{await ye.startRoleSession(t.taskSlug,ce,{cols:100,rows:28,permissionMode:_[ce],model:k[ce],effort:R[ce]}),be(`started ${ce} with ${_[ce]} / ${k[ce]} / ${R[ce]}`)},`Start ${ce} session`),onResume:()=>void Ce(async()=>{await ye.resumeRoleSession(t.taskSlug,ce,{cols:100,rows:28,permissionMode:_[ce],model:k[ce],effort:R[ce]}),be(`resumed ${ce} with ${_[ce]} / ${k[ce]} / ${R[ce]}`)},`Resume ${ce} session`),onStop:()=>void Ce(async()=>{await ye.stopRoleSession(t.taskSlug,ce),be(`stopped ${ce}`)},`Stop ${ce} session`),onRestart:()=>void Ce(async()=>{await ye.restartRoleSession(t.taskSlug,ce,{cols:100,rows:28,permissionMode:_[ce],model:k[ce],effort:R[ce]}),be(`restarted ${ce} with ${_[ce]} / ${k[ce]} / ${R[ce]}`)},`Restart ${ce} session`),onRestartWithContext:()=>void Ce(async()=>{m_(ce)&&(await ye.restartRoleSessionWithContext(t.taskSlug,ce,{cols:100,rows:28,permissionMode:_[ce],model:k[ce],effort:R[ce]}),be(`restarted ${ce} with task context`))},`Restart ${ce} session with task context`),onNotifyHarnessUpdated:()=>void Ce(async()=>{await ye.notifyRoleHarnessUpdated(t.taskSlug,ce),be(`notified ${ce} to reload latest harness`)},`Notify ${ce} to reload harness`),onTerminalEvent:Ne=>be(`${Ee.label}: ${Ne}`)})},ce)})})})})]})}function H2(t){return sl.some(r=>r.name===t)}function t_(t){return[t.status,t.updatedAt,t.cleanupStatus??"",t.cleanedAt??""].join(":")}function n_(t){var s;const r={...O2};for(const l of Ks)r[l.name]=((s=t.roles[l.name])==null?void 0:s.permissionMode)??r[l.name];return r}function i_(t){var s;const r={...B2};for(const l of Ks)r[l.name]=((s=t.roles[l.name])==null?void 0:s.model)??r[l.name];return r}function r_(t){var s;const r={...j2};for(const l of Ks)r[l.name]=((s=t.roles[l.name])==null?void 0:s.effort)??r[l.name];return r}const z2=1400;function I2(t){return!!(t!=null&&t.initialized)}function U2(){const[t,r]=ee.useState(null),[s,l]=ee.useState([]),[d,m]=ee.useState(null),[f,o]=ee.useState(null),[c,u]=ee.useState(null),[g,h]=ee.useState(null),[S,x]=ee.useState(null),[T,E]=ee.useState(null),[y,v]=ee.useState(null),[_,b]=ee.useState(null),[k,L]=ee.useState(null),[R,D]=ee.useState(null),[A,M]=ee.useState(null),[O,H]=ee.useState(null),[U,P]=ee.useState(!1),[W,K]=ee.useState(null),[V,Y]=ee.useState(null),[te,z]=ee.useState(!1),[j,N]=ee.useState([]),[q,I]=ee.useState(null),[ie,me]=ee.useState(null),[_e,Q]=ee.useState(null),[$,he]=ee.useState(null),[ae,Ce]=ee.useState(null),[be,Le]=ee.useState(null),[Fe,He]=ee.useState("project-manager"),[Ee,ce]=ee.useState("system"),[ze,St]=ee.useState(!0),[mt,de]=ee.useState(!0),[Ne,Ue]=ee.useState("off"),[it,wt]=ee.useState(!1),[fe,we]=ee.useState(!1),[Te,Be]=ee.useState(!1),[je,bt]=ee.useState(!1),[qe,Et]=ee.useState(lS),[xt,Nt]=ee.useState(oS),[rt,Wt]=ee.useState(!1),[rn,Cr]=ee.useState(!1),[mi,gi]=ee.useState(!1),[Pi,zn]=ee.useState(!1),[Fi,Jn]=ee.useState(!1),[si,sn]=ee.useState(null),[ai,In]=ee.useState("bypassPermissions"),[qi,_i]=ee.useState("default"),[vi,yi]=ee.useState("medium"),[wn,Pt]=ee.useState(null),[li,hn]=ee.useState("bypassPermissions"),[Kt,gt]=ee.useState("default"),[ot,Ht]=ee.useState("medium"),[$i,Ve]=ee.useState(()=>uS()),[Un,dl]=ee.useState(null),[wr,Zr]=ee.useState(0),[xn,Si]=ee.useState(null),[xr,Gi]=ee.useState(null),[Tt,pl]=ee.useState(!1),[Vi,oi]=ee.useState(!1),[,fn]=Ii(""),ml=ee.useRef({}),es=ee.useRef({}),Qs=ee.useRef({}),gl=ee.useRef({}),Er=ee.useRef({}),bi=ee.useRef(null),Pn=ee.useRef({initialized:!1,messageId:null}),Yt=ee.useRef(""),Z=ee.useMemo(()=>Hk(j,q),[j,q]),dn=(Un==null?void 0:Un.taskSlug)===(Z==null?void 0:Z.taskSlug)?Un:null,kr=c===(Z==null?void 0:Z.taskSlug)?d:null,Js=g===(Z==null?void 0:Z.taskSlug)?f:null,ts=_===(Z==null?void 0:Z.taskSlug)?y:null,Wo=!!(t&&Z&&I2(kr)),pn=(si==null?void 0:si.status)==="running",ns=!!(Te&&Wo&&pn),_l=!!(dn!=null&&dn.statusLoaded),Zs=!!(Z&&(dn!=null&&dn.statusLoaded)&&!dn.hasAnySession),Zn=(R==null?void 0:R.modelOptions)??v_(),Ft=ee.useCallback((G,ue={})=>{ce(G.themeMode),St(G.flowPauseAlerts),de(G.roleRetryEnabled),Ue(G.permissionRequestMode),wt(G.autoTaskHarnessReviewEnabled),we(G.autoMemoryEnabled),Be(G.translationEnabled),bt(G.translationAutoSendEnabled),Et(G.translationTargetLanguage),Nt(G.translationOutputMode),Ve(G.launchTemplate),ue.syncToolLaunchOptions&&(In(G.toolSessionDefaults.translator.permissionMode),_i(G.toolSessionDefaults.translator.model),yi(G.toolSessionDefaults.translator.effort),hn(G.toolSessionDefaults["harness-engineer"].permissionMode),gt(G.toolSessionDefaults["harness-engineer"].model),Ht(G.toolSessionDefaults["harness-engineer"].effort))},[]);ee.useEffect(()=>{if(!ze)return;let G=!1;const ue=()=>{G||(G=!0,s_(),window.removeEventListener("pointerdown",ue),window.removeEventListener("keydown",ue))};return window.addEventListener("pointerdown",ue),window.addEventListener("keydown",ue),()=>{window.removeEventListener("pointerdown",ue),window.removeEventListener("keydown",ue)}},[ze]);const Fn=ee.useCallback(()=>{bi.current!==null&&(window.clearInterval(bi.current),bi.current=null)},[]),Ci=ee.useCallback(()=>{Fn(),a_(),bi.current=window.setInterval(()=>{a_()},z2)},[Fn]),vl=ee.useCallback((G,ue=`manual-${Date.now()}`)=>{Si({id:ue,text:G})},[]),is=ee.useCallback(()=>{Fn(),Si(null)},[Fn]);ee.useEffect(()=>{Z!=null&&Z.taskSlug&&(Er.current[Z.taskSlug]=Date.now())},[Z==null?void 0:Z.taskSlug]);const yl=ee.useCallback(G=>{Z!=null&&Z.taskSlug&&me({taskSlug:Z.taskSlug,messages:G})},[Z==null?void 0:Z.taskSlug]),ea=ee.useCallback(G=>{Qs.current[G.taskSlug]=G.mode,Z!=null&&Z.taskSlug&&Q({taskSlug:Z.taskSlug,orchestration:G})},[Z==null?void 0:Z.taskSlug]),Ko=ee.useCallback(G=>{Z!=null&&Z.taskSlug&&he({taskSlug:Z.taskSlug,events:G})},[Z==null?void 0:Z.taskSlug]),Yo=ee.useCallback(G=>{if(!(Z!=null&&Z.taskSlug)||G.taskSlug!==Z.taskSlug)return;Ce({taskSlug:G.taskSlug,roundState:G});const ue=zk({mode:Qs.current[G.taskSlug],status:G.status,activeRole:G.activeRole,lastFollowedRole:gl.current[G.taskSlug]});ue&&(gl.current[G.taskSlug]=ue,He(ue));const Xe=Ik(G,G2);if(Xe===null){es.current[G.taskSlug]={status:G.status};return}const on=Uk(G),wi=ml.current[G.taskSlug],Jo=es.current[G.taskSlug];es.current[G.taskSlug]={status:G.status},wi!==on&&(ml.current[G.taskSlug]=on,Pk(G,Jo,Er.current[G.taskSlug])&&vl(Xe,on))},[Z==null?void 0:Z.taskSlug,vl]),rs=ee.useCallback(G=>{dl(ue=>(ue==null?void 0:ue.taskSlug)===G.taskSlug&&ue.statusLoaded===G.statusLoaded&&ue.sessionCount===G.sessionCount&&ue.hasAnySession===G.hasAnySession&&ue.hasReviewerSession===G.hasReviewerSession&&ue.allRolesHaveSession===G.allRolesHaveSession&&ue.autoOrchestration===G.autoOrchestration&&JSON.stringify(ue.roles)===JSON.stringify(G.roles)?ue:G)},[]);async function Xt(){const G=await ye.listTasks();return N(G),I(ue=>{var Xe;return ue&&G.some(on=>on.taskSlug===ue)?ue:((Xe=G[0])==null?void 0:Xe.taskSlug)??null}),G}async function Ar(G=Z==null?void 0:Z.taskSlug){if(!G)return m(null),u(null),null;const ue=await ye.getHarnessStatus(G);return m(ue),u(G),ue}async function Tr(G=Z==null?void 0:Z.taskSlug){if(!G)return o(null),h(null),null;const ue=await ye.getHarnessBootstrapStatus(G);return o(ue),h(G),ue}async function En(){const G=await ye.getGatewayStatus();return L(G),G}async function Wi(){const G=await ye.getRecentRepositoryPaths();return l(G),G}async function ta(){if(!t)return Wt(!1),!1;const G=await ye.getTranslationState();return Wt(G.memoryInitialized),G.memoryInitialized}async function Rr(G){const[ue,Xe]=await Promise.all([ye.listMessages(G),ye.getOrchestrationState(G)]);me({taskSlug:G,messages:ue}),Q({taskSlug:G,orchestration:Xe})}async function na(G){const ue=await ye.getGateReviewState(G);return Le({taskSlug:G,state:ue}),zo("Poll Gate Review state"),fn(Xe=>Lo(Xe,["Refresh Gate Review state","Poll Gate Review state"])),ue}function Ki(G,ue){const Xe=Ov(G,ue);Xe&&fn(Xe)}function Qt(G){G&&(In(G.permissionMode),G.model&&_i(G.model),G.effort&&yi(G.effort))}async function ss(G={}){const ue=await ye.getTranslatorSession((Z==null?void 0:Z.taskSlug)??null);return sn(ue),G.syncLaunchOptions&&Qt(ue),ue}function kn(G){G&&(hn(G.permissionMode),G.model&>(G.model),G.effort&&Ht(G.effort))}async function an(G={}){const ue=await ye.getHarnessEngineerSession((Z==null?void 0:Z.taskSlug)??null);return Pt(ue),G.syncLaunchOptions&&kn(ue),ue}async function ia(G=Z==null?void 0:Z.taskSlug){if(!t)return E(null),null;const ue=await ye.getHarnessFeedbackState(G);return E(ue),ue}function as(G,ue,Xe={}){var on;sn(G.translatorSession),Wt(!!((on=G.translationState)!=null&&on.memoryInitialized)),Pt(G.harnessEngineerSession),E(G.harnessFeedbackState),v(G.autoMemoryState),b(ue&&G.autoMemoryState?ue:null),L(G.gatewayStatus),ue&&G.harnessStatus?(m(G.harnessStatus),u(ue)):(m(null),u(null)),ue&&G.harnessBootstrapStatus?(o(G.harnessBootstrapStatus),h(ue)):(o(null),h(null)),Xe.syncLaunchOptions&&(Qt(G.translatorSession),kn(G.harnessEngineerSession))}async function ra(G={}){if(!t)return sn(null),Wt(!1),Pt(null),m(null),o(null),u(null),h(null),E(null),v(null),b(null),null;const ue=(Z==null?void 0:Z.taskSlug)??null,Xe=await ye.getProjectRuntimeState(ue);return as(Xe,ue,G),Xe}function ls(){const G=["Poll project runtime state","Load project runtime state","Refresh Harness feedback state","Poll Harness feedback state","Load Translator session","Poll Translator session","Poll translation memory status","Load Harness Engineer session","Poll Harness Engineer session","Load VCM Harness status","Poll VCM Harness status"];for(const ue of G)zo(ue);fn(ue=>Lo(ue,G))}ee.useEffect(()=>{Promise.all([ye.getCurrentProject(),ye.getRecentRepositoryPaths(),ye.getAppPreferences(),ye.getGatewayStatus(),ye.getCodexBridgeIntegrationStatus()]).then(async([G,ue,Xe,on,wi])=>{r(G),l(ue),L(on),D(wi),Ft(Xe,{syncToolLaunchOptions:!0}),G&&await Xt()}).catch(G=>fn(ft("Load initial app data",G)))},[Ft]),ee.useEffect(()=>{const G=window.matchMedia("(prefers-color-scheme: dark)"),ue=()=>pl(G.matches);return ue(),G.addEventListener("change",ue),()=>G.removeEventListener("change",ue)},[]),ee.useEffect(()=>()=>Fn(),[Fn]),ee.useEffect(()=>{(k==null?void 0:k.pauseAlertSoundEnabled)!==void 0&&St(k.pauseAlertSoundEnabled);const G=qk(Pn.current,k);Pn.current=G.observation,G.dismissPauseAlert&&is()},[is,k]),ee.useEffect(()=>{if(xn&&Fk(ze)==="strong")return Ci(),Fn;Fn()},[xn==null?void 0:xn.id,ze,Ci,Fn]),ee.useEffect(()=>{const G=Ee==="system"?Tt?"dark":"light":Ee;document.documentElement.dataset.theme=G,document.documentElement.dataset.themeMode=Ee},[Tt,Ee]),ee.useEffect(()=>{if(!(Z!=null&&Z.taskSlug)){Le(null);return}na(Z.taskSlug).catch(G=>fn(ft("Refresh Gate Review state",G)))},[Z==null?void 0:Z.taskSlug]),ee.useEffect(()=>{Yt.current="",sn(null),Wt(!1),Pt(null),m(null),o(null),u(null),h(null),E(null)},[t==null?void 0:t.repoRoot,Z==null?void 0:Z.taskSlug]),ol(t?`project-runtime:${t.repoRoot}:${(Z==null?void 0:Z.taskSlug)??"no-task"}`:null,async()=>{try{const G=t?`${t.repoRoot}:${(Z==null?void 0:Z.taskSlug)??"no-task"}`:"",ue=!!(t&&Yt.current!==G);await ra({syncLaunchOptions:ue}),ue&&(Yt.current=G),ls()}catch(G){Ki("Poll project runtime state",G)}},{intervalMs:3e3,runImmediately:!0});const Jt=(Z==null?void 0:Z.taskSlug)??null,os=Jt&&(be==null?void 0:be.taskSlug)===Jt?be.state:null,It=Jt&&(ae==null?void 0:ae.taskSlug)===Jt?ae.roundState:null,ei=Jt&&(Un==null?void 0:Un.taskSlug)===Jt?Un:null,cs=!!(Jt&&(os!=null&&os.activeGate||(It==null?void 0:It.activeRole)==="reviewer"||ei!=null&&ei.hasReviewerSession));ol(cs&&Jt?`gate-review:${Jt}`:null,async()=>{if(Jt)try{await na(Jt)}catch(G){Ki("Poll Gate Review state",G)}},{intervalMs:3e3,runImmediately:!1});async function Ae(G,ue="Run UI action"){oi(!0),fn("");try{await G()}catch(Xe){fn(ft(ue,Xe))}finally{oi(!1)}}async function Xo(){var on;if(!Z)throw new Error("Create or select a task before closing it.");const G=[`Close task "${Z.taskSlug}"?`,"","This is destructive:","- stops VCM-managed running role sessions for this task","- stops Translator and Harness Engineer sessions for this task",`- deletes the task worktree: ${Z.worktreePath}`,`- deletes the Git branch: ${Z.branch}`,"- deletes VCM task/session/message/orchestration state","","The task will close even if a cleanup step fails; cleanup issues are reported as warnings."].join(`
|
|
96
96
|
`);if(!window.confirm(G))return;const Xe=await ye.cleanupTask(Z.taskSlug);I(null),me(null),Q(null),he(null),Ce(null),Le(null),Zr(wi=>wi+1),await Xt(),(on=Xe.warnings)!=null&&on.length&&window.alert([`Task "${Xe.taskSlug}" closed with cleanup warnings:`,"",...Xe.warnings.map(wi=>`- ${wi}`)].join(`
|
package/dist-frontend/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>VibeCodingMaster</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-BWbworWs.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-xgiQeUD5.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Use the recorded turn window, not the current wait flag: replies must survive
|
|
2
|
-
// the user's answer and transcript replay without becoming a second message.
|
|
3
|
-
export function findUserQuestionReply(state, sessionId, timestamp) {
|
|
4
|
-
return state.userQuestionReplies?.slice().reverse().find((reply) => reply.sessionId === sessionId
|
|
5
|
-
&& timestamp >= reply.turnStartedAt && timestamp <= reply.completedAt);
|
|
6
|
-
}
|
|
7
|
-
export function isPendingUserQuestion(state, timestamp) {
|
|
8
|
-
return Boolean(state.awaitingUser && timestamp >= state.awaitingUser.requestedAt
|
|
9
|
-
&& !state.userQuestionReplies?.some((reply) => reply.requestedAt === state.awaitingUser?.requestedAt));
|
|
10
|
-
}
|