flavor-code 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{app-NXOGWGSI.js → app-EHB3XAQY.js} +1 -1
- package/dist/{chunk-JKJOQRAL.js → chunk-RDBTC35M.js} +1 -1
- package/dist/{chunk-YY5H6GFN.js → chunk-YKSMZDUZ.js} +141 -23
- package/dist/cli.js +3 -3
- package/dist/desktop/main.js +141 -23
- package/dist/desktop-renderer/assets/{index-CnGHSdJ6.js → index-bFGsR_uj.js} +2 -2
- package/dist/desktop-renderer/assets/{interactive-terminal-BpNgJ_fv.js → interactive-terminal-BwS6MvIe.js} +1 -1
- package/dist/desktop-renderer/index.html +1 -1
- package/dist/sdk/index.js +2 -2
- package/package.json +1 -1
|
@@ -7985,7 +7985,7 @@ function toModelTool(tool) {
|
|
|
7985
7985
|
|
|
7986
7986
|
// src/harness/journal.ts
|
|
7987
7987
|
import { createHash as createHash6, randomUUID as randomUUID8 } from "crypto";
|
|
7988
|
-
import { closeSync, constants, existsSync as existsSync2, fsyncSync, mkdirSync as mkdirSync2, openSync, readFileSync as readFileSync2, realpathSync as realpathSync2, statSync, truncateSync, writeSync } from "fs";
|
|
7988
|
+
import { closeSync, constants, existsSync as existsSync2, fsyncSync, mkdirSync as mkdirSync2, openSync, readFileSync as readFileSync2, realpathSync as realpathSync2, renameSync, statSync, truncateSync, unlinkSync, writeSync } from "fs";
|
|
7989
7989
|
import { join as join8, relative as relative7, resolve as resolve8, sep as sep7 } from "path";
|
|
7990
7990
|
import { z as z10 } from "zod";
|
|
7991
7991
|
|
|
@@ -7996,8 +7996,10 @@ function harnessInvariantViolations(records) {
|
|
|
7996
7996
|
const tools = /* @__PURE__ */ new Set();
|
|
7997
7997
|
const models = /* @__PURE__ */ new Set();
|
|
7998
7998
|
const turns = /* @__PURE__ */ new Set();
|
|
7999
|
+
const firstSequence = records[0]?.sequence ?? 1;
|
|
7999
8000
|
records.forEach((record, index) => {
|
|
8000
|
-
|
|
8001
|
+
const expectedSequence = firstSequence + index;
|
|
8002
|
+
if (record.sequence !== expectedSequence) violations.push(`sequence ${record.sequence} is not ${expectedSequence}`);
|
|
8001
8003
|
const id = typeof record.payload.id === "string" ? record.payload.id : "";
|
|
8002
8004
|
if (record.type === "queue.admitted") {
|
|
8003
8005
|
if (queues.has(id)) violations.push(`queue ${id} was admitted twice`);
|
|
@@ -8013,13 +8015,13 @@ function harnessInvariantViolations(records) {
|
|
|
8013
8015
|
if (!tools.delete(id)) violations.push(`${record.type} references unknown tool ${id}`);
|
|
8014
8016
|
} else if (record.type === "model.requested") {
|
|
8015
8017
|
if (models.has(id)) violations.push(`model ${id} was requested twice`);
|
|
8016
|
-
if (!
|
|
8018
|
+
if (!isHash(record.payload.messagesHash)) violations.push(`model ${id} has no valid messages hash`);
|
|
8017
8019
|
models.add(id);
|
|
8018
8020
|
} else if (record.type === "model.completed") {
|
|
8019
8021
|
if (!models.delete(id)) violations.push(`model.completed references unknown model ${id}`);
|
|
8020
8022
|
} else if (record.type === "turn.started") {
|
|
8021
8023
|
if (turns.has(id)) violations.push(`turn ${id} was started twice`);
|
|
8022
|
-
if (!(
|
|
8024
|
+
if (!isHash(record.payload.promptHash)) violations.push(`turn ${id} has no valid prompt hash`);
|
|
8023
8025
|
turns.add(id);
|
|
8024
8026
|
} else if (record.type === "turn.completed" || record.type === "turn.interrupted") {
|
|
8025
8027
|
if (!turns.delete(id)) violations.push(`${record.type} references unknown turn ${id}`);
|
|
@@ -8027,6 +8029,9 @@ function harnessInvariantViolations(records) {
|
|
|
8027
8029
|
});
|
|
8028
8030
|
return violations;
|
|
8029
8031
|
}
|
|
8032
|
+
function isHash(value) {
|
|
8033
|
+
return typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
|
|
8034
|
+
}
|
|
8030
8035
|
function assertHarnessInvariants(records) {
|
|
8031
8036
|
const violations = harnessInvariantViolations(records);
|
|
8032
8037
|
if (violations.length > 0) throw new Error(`Harness invariant violation: ${violations.join("; ")}`);
|
|
@@ -8107,7 +8112,7 @@ var HarnessJournal = class {
|
|
|
8107
8112
|
}
|
|
8108
8113
|
startTurn(config, prompt) {
|
|
8109
8114
|
const id = randomUUID8();
|
|
8110
|
-
this.#append("turn.started", { id,
|
|
8115
|
+
this.#append("turn.started", { id, configHash: hashJson(config), promptHash: hashJson(prompt) });
|
|
8111
8116
|
return id;
|
|
8112
8117
|
}
|
|
8113
8118
|
completeTurn(id) {
|
|
@@ -8118,7 +8123,14 @@ var HarnessJournal = class {
|
|
|
8118
8123
|
}
|
|
8119
8124
|
startModel(input) {
|
|
8120
8125
|
const id = randomUUID8();
|
|
8121
|
-
this.#append("model.requested", {
|
|
8126
|
+
this.#append("model.requested", {
|
|
8127
|
+
id,
|
|
8128
|
+
agent: input.agent,
|
|
8129
|
+
model: input.model,
|
|
8130
|
+
iteration: input.iteration,
|
|
8131
|
+
attempt: input.attempt,
|
|
8132
|
+
messagesHash: hashJson(input.messages)
|
|
8133
|
+
});
|
|
8122
8134
|
return id;
|
|
8123
8135
|
}
|
|
8124
8136
|
completeModel(id, completed, error) {
|
|
@@ -8126,11 +8138,11 @@ var HarnessJournal = class {
|
|
|
8126
8138
|
}
|
|
8127
8139
|
startTool(tool, input, retrySafe) {
|
|
8128
8140
|
const id = randomUUID8();
|
|
8129
|
-
this.#append("tool.started", { id, tool,
|
|
8141
|
+
this.#append("tool.started", { id, tool, inputHash: hashJson(input), retrySafe });
|
|
8130
8142
|
return id;
|
|
8131
8143
|
}
|
|
8132
8144
|
completeTool(id, result) {
|
|
8133
|
-
this.#append("tool.completed", { id,
|
|
8145
|
+
this.#append("tool.completed", { id, resultHash: hashJson(result) });
|
|
8134
8146
|
}
|
|
8135
8147
|
interruptTool(id, reason) {
|
|
8136
8148
|
this.#append("tool.interrupted", { id, reason });
|
|
@@ -8207,47 +8219,153 @@ var HarnessJournal = class {
|
|
|
8207
8219
|
const committed = raw.endsWith("\n") ? raw : raw.slice(0, Math.max(0, raw.lastIndexOf("\n") + 1));
|
|
8208
8220
|
if (committed.length !== raw.length) truncateSync(this.#path, Buffer.byteLength(committed));
|
|
8209
8221
|
const lines = committed.split("\n").filter(Boolean);
|
|
8210
|
-
let previousHash
|
|
8222
|
+
let previousHash;
|
|
8223
|
+
let expectedSequence;
|
|
8211
8224
|
for (const line of lines) {
|
|
8212
8225
|
const record = JournalRecordSchema.parse(JSON.parse(line));
|
|
8213
|
-
|
|
8226
|
+
expectedSequence ??= record.sequence;
|
|
8227
|
+
previousHash ??= record.previousHash;
|
|
8228
|
+
if (record.sequence !== expectedSequence) throw new Error("Harness journal sequence is not contiguous");
|
|
8214
8229
|
if (record.previousHash !== previousHash) throw new Error("Harness journal hash chain is broken");
|
|
8215
8230
|
if (record.hash !== recordHash(record)) throw new Error("Harness journal record hash is invalid");
|
|
8216
8231
|
this.#records.push(record);
|
|
8217
8232
|
previousHash = record.hash;
|
|
8233
|
+
expectedSequence += 1;
|
|
8218
8234
|
}
|
|
8219
|
-
this.#sequence = this.#records.
|
|
8220
|
-
this.#lastHash = previousHash;
|
|
8235
|
+
this.#sequence = this.#records.at(-1)?.sequence ?? 0;
|
|
8236
|
+
this.#lastHash = previousHash ?? null;
|
|
8221
8237
|
assertHarnessInvariants(this.#records);
|
|
8238
|
+
const hasRotatedPrefix = (this.#records[0]?.sequence ?? 1) !== 1;
|
|
8239
|
+
if (metadata.size > this.#maxBytes * 0.75 || hasRotatedPrefix || this.#records.some(hasLegacyPayload)) this.#compact();
|
|
8222
8240
|
}
|
|
8223
8241
|
#append(type, payload) {
|
|
8224
8242
|
const normalizedPayload = jsonSafeRecord(payload);
|
|
8243
|
+
let record = this.#createRecord(type, normalizedPayload);
|
|
8244
|
+
let line = `${JSON.stringify(record)}
|
|
8245
|
+
`;
|
|
8246
|
+
let priorBytes = existsSync2(this.#path) ? statSync(this.#path).size : 0;
|
|
8247
|
+
if (priorBytes + Buffer.byteLength(line) > this.#maxBytes) {
|
|
8248
|
+
this.#compact();
|
|
8249
|
+
record = this.#createRecord(type, normalizedPayload);
|
|
8250
|
+
line = `${JSON.stringify(record)}
|
|
8251
|
+
`;
|
|
8252
|
+
priorBytes = existsSync2(this.#path) ? statSync(this.#path).size : 0;
|
|
8253
|
+
if (priorBytes + Buffer.byteLength(line) > this.#maxBytes) {
|
|
8254
|
+
throw new Error(`Harness journal event exceeds the ${this.#maxBytes} byte bounded journal capacity`);
|
|
8255
|
+
}
|
|
8256
|
+
}
|
|
8257
|
+
const fd = openSync(this.#path, constants.O_CREAT | constants.O_APPEND | constants.O_WRONLY, 384);
|
|
8258
|
+
try {
|
|
8259
|
+
writeSync(fd, line, void 0, "utf8");
|
|
8260
|
+
fsyncSync(fd);
|
|
8261
|
+
} finally {
|
|
8262
|
+
closeSync(fd);
|
|
8263
|
+
}
|
|
8264
|
+
this.#records.push(record);
|
|
8265
|
+
this.#sequence = record.sequence;
|
|
8266
|
+
this.#lastHash = record.hash;
|
|
8267
|
+
}
|
|
8268
|
+
#createRecord(type, payload) {
|
|
8225
8269
|
const unsigned = {
|
|
8226
8270
|
version: HARNESS_JOURNAL_VERSION,
|
|
8227
8271
|
sequence: this.#sequence + 1,
|
|
8228
8272
|
id: randomUUID8(),
|
|
8229
8273
|
timestamp: this.#now(),
|
|
8230
8274
|
type,
|
|
8231
|
-
payload
|
|
8275
|
+
payload,
|
|
8232
8276
|
previousHash: this.#lastHash
|
|
8233
8277
|
};
|
|
8234
|
-
|
|
8235
|
-
|
|
8236
|
-
|
|
8237
|
-
const
|
|
8238
|
-
|
|
8239
|
-
const
|
|
8278
|
+
return JournalRecordSchema.parse({ ...unsigned, hash: hashJson(unsigned) });
|
|
8279
|
+
}
|
|
8280
|
+
#compact() {
|
|
8281
|
+
const queues = /* @__PURE__ */ new Map();
|
|
8282
|
+
const claims = /* @__PURE__ */ new Map();
|
|
8283
|
+
const tools = /* @__PURE__ */ new Map();
|
|
8284
|
+
const models = /* @__PURE__ */ new Map();
|
|
8285
|
+
const turns = /* @__PURE__ */ new Map();
|
|
8286
|
+
let savepoint;
|
|
8287
|
+
for (const record of this.#records) {
|
|
8288
|
+
const id = typeof record.payload.id === "string" ? record.payload.id : "";
|
|
8289
|
+
if (record.type === "queue.admitted") queues.set(id, record);
|
|
8290
|
+
else if (record.type === "queue.claimed") claims.set(id, record);
|
|
8291
|
+
else if (record.type === "queue.released") claims.delete(id);
|
|
8292
|
+
else if (record.type === "queue.acked") {
|
|
8293
|
+
queues.delete(id);
|
|
8294
|
+
claims.delete(id);
|
|
8295
|
+
} else if (record.type === "tool.started") tools.set(id, record);
|
|
8296
|
+
else if (record.type === "tool.completed" || record.type === "tool.interrupted") tools.delete(id);
|
|
8297
|
+
else if (record.type === "model.requested") models.set(id, record);
|
|
8298
|
+
else if (record.type === "model.completed") models.delete(id);
|
|
8299
|
+
else if (record.type === "turn.started") turns.set(id, record);
|
|
8300
|
+
else if (record.type === "turn.completed" || record.type === "turn.interrupted") turns.delete(id);
|
|
8301
|
+
else if (record.type === "savepoint.created") savepoint = record;
|
|
8302
|
+
}
|
|
8303
|
+
const retained = [
|
|
8304
|
+
...queues.values(),
|
|
8305
|
+
...claims.values(),
|
|
8306
|
+
...tools.values(),
|
|
8307
|
+
...models.values(),
|
|
8308
|
+
...turns.values(),
|
|
8309
|
+
...savepoint === void 0 ? [] : [savepoint]
|
|
8310
|
+
].sort((left, right) => left.sequence - right.sequence);
|
|
8311
|
+
const compacted = [];
|
|
8312
|
+
let previousHash = null;
|
|
8313
|
+
for (const source of retained) {
|
|
8314
|
+
const unsigned = {
|
|
8315
|
+
version: HARNESS_JOURNAL_VERSION,
|
|
8316
|
+
sequence: compacted.length + 1,
|
|
8317
|
+
id: randomUUID8(),
|
|
8318
|
+
timestamp: source.timestamp,
|
|
8319
|
+
type: source.type,
|
|
8320
|
+
payload: compactPayload(source),
|
|
8321
|
+
previousHash
|
|
8322
|
+
};
|
|
8323
|
+
const record = JournalRecordSchema.parse({ ...unsigned, hash: hashJson(unsigned) });
|
|
8324
|
+
compacted.push(record);
|
|
8325
|
+
previousHash = record.hash;
|
|
8326
|
+
}
|
|
8327
|
+
const contents = compacted.map((record) => `${JSON.stringify(record)}
|
|
8328
|
+
`).join("");
|
|
8329
|
+
if (Buffer.byteLength(contents) > this.#maxBytes) return;
|
|
8330
|
+
const temporary = `${this.#path}.compact-${process.pid}-${randomUUID8()}`;
|
|
8331
|
+
const fd = openSync(temporary, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY, 384);
|
|
8240
8332
|
try {
|
|
8241
|
-
writeSync(fd,
|
|
8333
|
+
writeSync(fd, contents, void 0, "utf8");
|
|
8242
8334
|
fsyncSync(fd);
|
|
8243
8335
|
} finally {
|
|
8244
8336
|
closeSync(fd);
|
|
8245
8337
|
}
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8338
|
+
try {
|
|
8339
|
+
renameSync(temporary, this.#path);
|
|
8340
|
+
} catch (error) {
|
|
8341
|
+
if (existsSync2(temporary)) unlinkSync(temporary);
|
|
8342
|
+
throw error;
|
|
8343
|
+
}
|
|
8344
|
+
this.#records = compacted;
|
|
8345
|
+
this.#sequence = compacted.length;
|
|
8346
|
+
this.#lastHash = previousHash;
|
|
8249
8347
|
}
|
|
8250
8348
|
};
|
|
8349
|
+
function compactPayload(record) {
|
|
8350
|
+
const payload = record.payload;
|
|
8351
|
+
if (record.type === "queue.admitted") return payload;
|
|
8352
|
+
if (record.type === "queue.claimed") return { id: payload.id };
|
|
8353
|
+
if (record.type === "tool.started") return pick(payload, ["id", "tool", "inputHash", "retrySafe"]);
|
|
8354
|
+
if (record.type === "model.requested") return pick(payload, ["id", "agent", "model", "iteration", "attempt", "messagesHash"]);
|
|
8355
|
+
if (record.type === "turn.started") return pick(payload, ["id", "configHash", "promptHash"]);
|
|
8356
|
+
if (record.type === "savepoint.created") return pick(payload, ["id", "phase", "configHash"]);
|
|
8357
|
+
return payload;
|
|
8358
|
+
}
|
|
8359
|
+
function hasLegacyPayload(record) {
|
|
8360
|
+
if (record.type === "turn.started") return "config" in record.payload || "prompt" in record.payload;
|
|
8361
|
+
if (record.type === "model.requested") return "messages" in record.payload;
|
|
8362
|
+
if (record.type === "tool.started") return "input" in record.payload;
|
|
8363
|
+
if (record.type === "tool.completed") return "result" in record.payload;
|
|
8364
|
+
return false;
|
|
8365
|
+
}
|
|
8366
|
+
function pick(source, keys) {
|
|
8367
|
+
return Object.fromEntries(keys.flatMap((key) => key in source ? [[key, source[key]]] : []));
|
|
8368
|
+
}
|
|
8251
8369
|
function jsonSafeRecord(value) {
|
|
8252
8370
|
const json = JSON.stringify(value, (_key, item) => typeof item === "bigint" ? `${item}n` : item);
|
|
8253
8371
|
return JSON.parse(json);
|
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createRequire } from "node:module"; const require = createRequire(impor
|
|
|
3
3
|
import {
|
|
4
4
|
FlavorRpcServer,
|
|
5
5
|
TraceRecorder
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-RDBTC35M.js";
|
|
7
7
|
import {
|
|
8
8
|
staticTaskLines
|
|
9
9
|
} from "./chunk-KKIBYDJI.js";
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
packageVersion,
|
|
24
24
|
redactErrorText,
|
|
25
25
|
runPalBroker
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-YKSMZDUZ.js";
|
|
27
27
|
import {
|
|
28
28
|
McpServerConfigSchema,
|
|
29
29
|
McpServerNameSchema,
|
|
@@ -877,7 +877,7 @@ async function runInteractiveCli(props) {
|
|
|
877
877
|
const [{ render, AlternateScreen }, { createElement }, { App }] = await Promise.all([
|
|
878
878
|
import("./claude-ink-ORUA7GWG.js"),
|
|
879
879
|
import("react"),
|
|
880
|
-
import("./app-
|
|
880
|
+
import("./app-EHB3XAQY.js")
|
|
881
881
|
]);
|
|
882
882
|
const instance = await render(createElement(
|
|
883
883
|
AlternateScreen,
|
package/dist/desktop/main.js
CHANGED
|
@@ -8025,7 +8025,7 @@ function toModelTool(tool) {
|
|
|
8025
8025
|
|
|
8026
8026
|
// src/harness/journal.ts
|
|
8027
8027
|
import { createHash as createHash6, randomUUID as randomUUID8 } from "crypto";
|
|
8028
|
-
import { closeSync, constants as constants2, existsSync as existsSync2, fsyncSync, mkdirSync, openSync, readFileSync, realpathSync as realpathSync2, statSync, truncateSync, writeSync } from "fs";
|
|
8028
|
+
import { closeSync, constants as constants2, existsSync as existsSync2, fsyncSync, mkdirSync, openSync, readFileSync, realpathSync as realpathSync2, renameSync, statSync, truncateSync, unlinkSync, writeSync } from "fs";
|
|
8029
8029
|
import { join as join8, relative as relative6, resolve as resolve8, sep as sep6 } from "path";
|
|
8030
8030
|
import { z as z15 } from "zod";
|
|
8031
8031
|
|
|
@@ -8036,8 +8036,10 @@ function harnessInvariantViolations(records) {
|
|
|
8036
8036
|
const tools = /* @__PURE__ */ new Set();
|
|
8037
8037
|
const models = /* @__PURE__ */ new Set();
|
|
8038
8038
|
const turns = /* @__PURE__ */ new Set();
|
|
8039
|
+
const firstSequence = records[0]?.sequence ?? 1;
|
|
8039
8040
|
records.forEach((record3, index) => {
|
|
8040
|
-
|
|
8041
|
+
const expectedSequence = firstSequence + index;
|
|
8042
|
+
if (record3.sequence !== expectedSequence) violations.push(`sequence ${record3.sequence} is not ${expectedSequence}`);
|
|
8041
8043
|
const id = typeof record3.payload.id === "string" ? record3.payload.id : "";
|
|
8042
8044
|
if (record3.type === "queue.admitted") {
|
|
8043
8045
|
if (queues.has(id)) violations.push(`queue ${id} was admitted twice`);
|
|
@@ -8053,13 +8055,13 @@ function harnessInvariantViolations(records) {
|
|
|
8053
8055
|
if (!tools.delete(id)) violations.push(`${record3.type} references unknown tool ${id}`);
|
|
8054
8056
|
} else if (record3.type === "model.requested") {
|
|
8055
8057
|
if (models.has(id)) violations.push(`model ${id} was requested twice`);
|
|
8056
|
-
if (!
|
|
8058
|
+
if (!isHash(record3.payload.messagesHash)) violations.push(`model ${id} has no valid messages hash`);
|
|
8057
8059
|
models.add(id);
|
|
8058
8060
|
} else if (record3.type === "model.completed") {
|
|
8059
8061
|
if (!models.delete(id)) violations.push(`model.completed references unknown model ${id}`);
|
|
8060
8062
|
} else if (record3.type === "turn.started") {
|
|
8061
8063
|
if (turns.has(id)) violations.push(`turn ${id} was started twice`);
|
|
8062
|
-
if (!(
|
|
8064
|
+
if (!isHash(record3.payload.promptHash)) violations.push(`turn ${id} has no valid prompt hash`);
|
|
8063
8065
|
turns.add(id);
|
|
8064
8066
|
} else if (record3.type === "turn.completed" || record3.type === "turn.interrupted") {
|
|
8065
8067
|
if (!turns.delete(id)) violations.push(`${record3.type} references unknown turn ${id}`);
|
|
@@ -8067,6 +8069,9 @@ function harnessInvariantViolations(records) {
|
|
|
8067
8069
|
});
|
|
8068
8070
|
return violations;
|
|
8069
8071
|
}
|
|
8072
|
+
function isHash(value) {
|
|
8073
|
+
return typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
|
|
8074
|
+
}
|
|
8070
8075
|
function assertHarnessInvariants(records) {
|
|
8071
8076
|
const violations = harnessInvariantViolations(records);
|
|
8072
8077
|
if (violations.length > 0) throw new Error(`Harness invariant violation: ${violations.join("; ")}`);
|
|
@@ -8147,7 +8152,7 @@ var HarnessJournal = class {
|
|
|
8147
8152
|
}
|
|
8148
8153
|
startTurn(config, prompt) {
|
|
8149
8154
|
const id = randomUUID8();
|
|
8150
|
-
this.#append("turn.started", { id,
|
|
8155
|
+
this.#append("turn.started", { id, configHash: hashJson(config), promptHash: hashJson(prompt) });
|
|
8151
8156
|
return id;
|
|
8152
8157
|
}
|
|
8153
8158
|
completeTurn(id) {
|
|
@@ -8158,7 +8163,14 @@ var HarnessJournal = class {
|
|
|
8158
8163
|
}
|
|
8159
8164
|
startModel(input) {
|
|
8160
8165
|
const id = randomUUID8();
|
|
8161
|
-
this.#append("model.requested", {
|
|
8166
|
+
this.#append("model.requested", {
|
|
8167
|
+
id,
|
|
8168
|
+
agent: input.agent,
|
|
8169
|
+
model: input.model,
|
|
8170
|
+
iteration: input.iteration,
|
|
8171
|
+
attempt: input.attempt,
|
|
8172
|
+
messagesHash: hashJson(input.messages)
|
|
8173
|
+
});
|
|
8162
8174
|
return id;
|
|
8163
8175
|
}
|
|
8164
8176
|
completeModel(id, completed, error) {
|
|
@@ -8166,11 +8178,11 @@ var HarnessJournal = class {
|
|
|
8166
8178
|
}
|
|
8167
8179
|
startTool(tool, input, retrySafe) {
|
|
8168
8180
|
const id = randomUUID8();
|
|
8169
|
-
this.#append("tool.started", { id, tool,
|
|
8181
|
+
this.#append("tool.started", { id, tool, inputHash: hashJson(input), retrySafe });
|
|
8170
8182
|
return id;
|
|
8171
8183
|
}
|
|
8172
8184
|
completeTool(id, result) {
|
|
8173
|
-
this.#append("tool.completed", { id,
|
|
8185
|
+
this.#append("tool.completed", { id, resultHash: hashJson(result) });
|
|
8174
8186
|
}
|
|
8175
8187
|
interruptTool(id, reason) {
|
|
8176
8188
|
this.#append("tool.interrupted", { id, reason });
|
|
@@ -8247,47 +8259,153 @@ var HarnessJournal = class {
|
|
|
8247
8259
|
const committed = raw.endsWith("\n") ? raw : raw.slice(0, Math.max(0, raw.lastIndexOf("\n") + 1));
|
|
8248
8260
|
if (committed.length !== raw.length) truncateSync(this.#path, Buffer.byteLength(committed));
|
|
8249
8261
|
const lines = committed.split("\n").filter(Boolean);
|
|
8250
|
-
let previousHash
|
|
8262
|
+
let previousHash;
|
|
8263
|
+
let expectedSequence;
|
|
8251
8264
|
for (const line of lines) {
|
|
8252
8265
|
const record3 = JournalRecordSchema.parse(JSON.parse(line));
|
|
8253
|
-
|
|
8266
|
+
expectedSequence ??= record3.sequence;
|
|
8267
|
+
previousHash ??= record3.previousHash;
|
|
8268
|
+
if (record3.sequence !== expectedSequence) throw new Error("Harness journal sequence is not contiguous");
|
|
8254
8269
|
if (record3.previousHash !== previousHash) throw new Error("Harness journal hash chain is broken");
|
|
8255
8270
|
if (record3.hash !== recordHash(record3)) throw new Error("Harness journal record hash is invalid");
|
|
8256
8271
|
this.#records.push(record3);
|
|
8257
8272
|
previousHash = record3.hash;
|
|
8273
|
+
expectedSequence += 1;
|
|
8258
8274
|
}
|
|
8259
|
-
this.#sequence = this.#records.
|
|
8260
|
-
this.#lastHash = previousHash;
|
|
8275
|
+
this.#sequence = this.#records.at(-1)?.sequence ?? 0;
|
|
8276
|
+
this.#lastHash = previousHash ?? null;
|
|
8261
8277
|
assertHarnessInvariants(this.#records);
|
|
8278
|
+
const hasRotatedPrefix = (this.#records[0]?.sequence ?? 1) !== 1;
|
|
8279
|
+
if (metadata.size > this.#maxBytes * 0.75 || hasRotatedPrefix || this.#records.some(hasLegacyPayload)) this.#compact();
|
|
8262
8280
|
}
|
|
8263
8281
|
#append(type, payload) {
|
|
8264
8282
|
const normalizedPayload = jsonSafeRecord(payload);
|
|
8283
|
+
let record3 = this.#createRecord(type, normalizedPayload);
|
|
8284
|
+
let line = `${JSON.stringify(record3)}
|
|
8285
|
+
`;
|
|
8286
|
+
let priorBytes = existsSync2(this.#path) ? statSync(this.#path).size : 0;
|
|
8287
|
+
if (priorBytes + Buffer.byteLength(line) > this.#maxBytes) {
|
|
8288
|
+
this.#compact();
|
|
8289
|
+
record3 = this.#createRecord(type, normalizedPayload);
|
|
8290
|
+
line = `${JSON.stringify(record3)}
|
|
8291
|
+
`;
|
|
8292
|
+
priorBytes = existsSync2(this.#path) ? statSync(this.#path).size : 0;
|
|
8293
|
+
if (priorBytes + Buffer.byteLength(line) > this.#maxBytes) {
|
|
8294
|
+
throw new Error(`Harness journal event exceeds the ${this.#maxBytes} byte bounded journal capacity`);
|
|
8295
|
+
}
|
|
8296
|
+
}
|
|
8297
|
+
const fd = openSync(this.#path, constants2.O_CREAT | constants2.O_APPEND | constants2.O_WRONLY, 384);
|
|
8298
|
+
try {
|
|
8299
|
+
writeSync(fd, line, void 0, "utf8");
|
|
8300
|
+
fsyncSync(fd);
|
|
8301
|
+
} finally {
|
|
8302
|
+
closeSync(fd);
|
|
8303
|
+
}
|
|
8304
|
+
this.#records.push(record3);
|
|
8305
|
+
this.#sequence = record3.sequence;
|
|
8306
|
+
this.#lastHash = record3.hash;
|
|
8307
|
+
}
|
|
8308
|
+
#createRecord(type, payload) {
|
|
8265
8309
|
const unsigned = {
|
|
8266
8310
|
version: HARNESS_JOURNAL_VERSION,
|
|
8267
8311
|
sequence: this.#sequence + 1,
|
|
8268
8312
|
id: randomUUID8(),
|
|
8269
8313
|
timestamp: this.#now(),
|
|
8270
8314
|
type,
|
|
8271
|
-
payload
|
|
8315
|
+
payload,
|
|
8272
8316
|
previousHash: this.#lastHash
|
|
8273
8317
|
};
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
const
|
|
8278
|
-
|
|
8279
|
-
const
|
|
8318
|
+
return JournalRecordSchema.parse({ ...unsigned, hash: hashJson(unsigned) });
|
|
8319
|
+
}
|
|
8320
|
+
#compact() {
|
|
8321
|
+
const queues = /* @__PURE__ */ new Map();
|
|
8322
|
+
const claims = /* @__PURE__ */ new Map();
|
|
8323
|
+
const tools = /* @__PURE__ */ new Map();
|
|
8324
|
+
const models = /* @__PURE__ */ new Map();
|
|
8325
|
+
const turns = /* @__PURE__ */ new Map();
|
|
8326
|
+
let savepoint;
|
|
8327
|
+
for (const record3 of this.#records) {
|
|
8328
|
+
const id = typeof record3.payload.id === "string" ? record3.payload.id : "";
|
|
8329
|
+
if (record3.type === "queue.admitted") queues.set(id, record3);
|
|
8330
|
+
else if (record3.type === "queue.claimed") claims.set(id, record3);
|
|
8331
|
+
else if (record3.type === "queue.released") claims.delete(id);
|
|
8332
|
+
else if (record3.type === "queue.acked") {
|
|
8333
|
+
queues.delete(id);
|
|
8334
|
+
claims.delete(id);
|
|
8335
|
+
} else if (record3.type === "tool.started") tools.set(id, record3);
|
|
8336
|
+
else if (record3.type === "tool.completed" || record3.type === "tool.interrupted") tools.delete(id);
|
|
8337
|
+
else if (record3.type === "model.requested") models.set(id, record3);
|
|
8338
|
+
else if (record3.type === "model.completed") models.delete(id);
|
|
8339
|
+
else if (record3.type === "turn.started") turns.set(id, record3);
|
|
8340
|
+
else if (record3.type === "turn.completed" || record3.type === "turn.interrupted") turns.delete(id);
|
|
8341
|
+
else if (record3.type === "savepoint.created") savepoint = record3;
|
|
8342
|
+
}
|
|
8343
|
+
const retained = [
|
|
8344
|
+
...queues.values(),
|
|
8345
|
+
...claims.values(),
|
|
8346
|
+
...tools.values(),
|
|
8347
|
+
...models.values(),
|
|
8348
|
+
...turns.values(),
|
|
8349
|
+
...savepoint === void 0 ? [] : [savepoint]
|
|
8350
|
+
].sort((left, right) => left.sequence - right.sequence);
|
|
8351
|
+
const compacted = [];
|
|
8352
|
+
let previousHash = null;
|
|
8353
|
+
for (const source of retained) {
|
|
8354
|
+
const unsigned = {
|
|
8355
|
+
version: HARNESS_JOURNAL_VERSION,
|
|
8356
|
+
sequence: compacted.length + 1,
|
|
8357
|
+
id: randomUUID8(),
|
|
8358
|
+
timestamp: source.timestamp,
|
|
8359
|
+
type: source.type,
|
|
8360
|
+
payload: compactPayload(source),
|
|
8361
|
+
previousHash
|
|
8362
|
+
};
|
|
8363
|
+
const record3 = JournalRecordSchema.parse({ ...unsigned, hash: hashJson(unsigned) });
|
|
8364
|
+
compacted.push(record3);
|
|
8365
|
+
previousHash = record3.hash;
|
|
8366
|
+
}
|
|
8367
|
+
const contents = compacted.map((record3) => `${JSON.stringify(record3)}
|
|
8368
|
+
`).join("");
|
|
8369
|
+
if (Buffer.byteLength(contents) > this.#maxBytes) return;
|
|
8370
|
+
const temporary = `${this.#path}.compact-${process.pid}-${randomUUID8()}`;
|
|
8371
|
+
const fd = openSync(temporary, constants2.O_CREAT | constants2.O_EXCL | constants2.O_WRONLY, 384);
|
|
8280
8372
|
try {
|
|
8281
|
-
writeSync(fd,
|
|
8373
|
+
writeSync(fd, contents, void 0, "utf8");
|
|
8282
8374
|
fsyncSync(fd);
|
|
8283
8375
|
} finally {
|
|
8284
8376
|
closeSync(fd);
|
|
8285
8377
|
}
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8378
|
+
try {
|
|
8379
|
+
renameSync(temporary, this.#path);
|
|
8380
|
+
} catch (error) {
|
|
8381
|
+
if (existsSync2(temporary)) unlinkSync(temporary);
|
|
8382
|
+
throw error;
|
|
8383
|
+
}
|
|
8384
|
+
this.#records = compacted;
|
|
8385
|
+
this.#sequence = compacted.length;
|
|
8386
|
+
this.#lastHash = previousHash;
|
|
8289
8387
|
}
|
|
8290
8388
|
};
|
|
8389
|
+
function compactPayload(record3) {
|
|
8390
|
+
const payload = record3.payload;
|
|
8391
|
+
if (record3.type === "queue.admitted") return payload;
|
|
8392
|
+
if (record3.type === "queue.claimed") return { id: payload.id };
|
|
8393
|
+
if (record3.type === "tool.started") return pick(payload, ["id", "tool", "inputHash", "retrySafe"]);
|
|
8394
|
+
if (record3.type === "model.requested") return pick(payload, ["id", "agent", "model", "iteration", "attempt", "messagesHash"]);
|
|
8395
|
+
if (record3.type === "turn.started") return pick(payload, ["id", "configHash", "promptHash"]);
|
|
8396
|
+
if (record3.type === "savepoint.created") return pick(payload, ["id", "phase", "configHash"]);
|
|
8397
|
+
return payload;
|
|
8398
|
+
}
|
|
8399
|
+
function hasLegacyPayload(record3) {
|
|
8400
|
+
if (record3.type === "turn.started") return "config" in record3.payload || "prompt" in record3.payload;
|
|
8401
|
+
if (record3.type === "model.requested") return "messages" in record3.payload;
|
|
8402
|
+
if (record3.type === "tool.started") return "input" in record3.payload;
|
|
8403
|
+
if (record3.type === "tool.completed") return "result" in record3.payload;
|
|
8404
|
+
return false;
|
|
8405
|
+
}
|
|
8406
|
+
function pick(source, keys) {
|
|
8407
|
+
return Object.fromEntries(keys.flatMap((key) => key in source ? [[key, source[key]]] : []));
|
|
8408
|
+
}
|
|
8291
8409
|
function jsonSafeRecord(value) {
|
|
8292
8410
|
const json = JSON.stringify(value, (_key, item) => typeof item === "bigint" ? `${item}n` : item);
|
|
8293
8411
|
return JSON.parse(json);
|
|
@@ -147,8 +147,8 @@ Describe when and how the agent should use this skill.`,disableModelInvocation:!
|
|
|
147
147
|
`).length+3)),value:we,onChange:e=>Te(e.target.value),onDoubleClick:e=>e.stopPropagation(),spellCheck:!1})]}):(0,I.jsx)(Jt,{text:yu(e)})},e.id)})??(D.prdMarkdown!==void 0&&(0,I.jsx)(Jt,{text:D.prdMarkdown}))}),(0,I.jsxs)(`section`,{className:`d2c-prd-regenerate`,children:[(0,I.jsx)(`header`,{children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`需要整体调整?`}),(0,I.jsx)(`span`,{children:`描述期望变化,AI 会基于当前 PRD 生成一份新草案。`})]})}),(0,I.jsx)(`textarea`,{rows:3,value:be,"aria-label":`PRD 重新生成要求`,placeholder:`例如:保留现有范围,补充退款失败后的恢复流程`,onChange:e=>xe(e.target.value)}),(0,I.jsxs)(`footer`,{children:[(0,I.jsx)(`span`,{children:`当前版本不会在生成过程中被覆盖`}),(0,I.jsxs)(`button`,{type:`button`,className:`d2c-prd-regenerate-button`,disabled:Ee||s||be.trim().length===0,onClick:()=>void on(),children:[(0,I.jsx)(`i`,{"aria-hidden":`true`,children:`↻`}),`重新生成 PRD`]})]})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`退回意见`}),(0,I.jsx)(`textarea`,{rows:3,value:ve,placeholder:`例如:补充退款失败后的恢复路径`,onChange:e=>ye(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`d2c-artifact-actions`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:Ee||s||ve.trim().length===0,onClick:()=>void an(`prd`,!1),children:`退回修改`}),(0,I.jsx)(`button`,{type:`button`,className:`primary`,disabled:Ee||s,onClick:()=>void an(`prd`,!0),children:`确认 PRD,生成交互稿`})]})]}),D?.plan.phase===`design-generating`&&(0,I.jsxs)(`div`,{className:`d2c-artifact-wait`,"data-invalid":D.validationError?.stage===`design`,"aria-live":`polite`,children:[(0,I.jsx)(`i`,{}),(0,I.jsx)(`div`,{children:D.validationError?.stage===`design`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`strong`,{children:`交互契约未通过预检`}),(0,I.jsx)(`span`,{children:D.validationError.message})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`strong`,{children:`正在生成可交互体验基线`}),(0,I.jsx)(`span`,{children:`视觉、关键状态和行为契约会一起落盘。`})]})}),D.validationError?.stage===`design`?(0,I.jsx)(`button`,{type:`button`,disabled:Ee||s,onClick:()=>void At(),children:`自动修复清单`}):(0,I.jsx)(`button`,{type:`button`,onClick:()=>void nn(D.plan.task),children:`刷新`})]}),D?.plan.phase===`design-review`&&(0,I.jsxs)(`div`,{className:`d2c-artifact-review d2c-design-review`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`span`,{children:`INTERACTIVE PROTOTYPE`}),(0,I.jsx)(`h3`,{children:`直接体验,再决定是否开发`}),(0,I.jsx)(`p`,{children:`点击、输入并检查主流程和异常状态;确认后它会成为 E2E 中 D2C 视觉还原的设计基线。`})]}),(0,I.jsx)(Vu,{url:ge.url,onStart:()=>void en(D.plan.task)}),(0,I.jsxs)(`div`,{className:`d2c-prototype-tools`,children:[(0,I.jsx)(`span`,{children:ge.running?`● LOOPBACK PREVIEW`:`PREVIEW STOPPED`}),ge.running&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>void window.flavorDesktop.openD2cProductPreview(D.plan.task),children:`浏览器打开`})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`退回意见`}),(0,I.jsx)(`textarea`,{rows:3,value:ve,placeholder:`例如:筛选结果缺少空状态,趋势图悬停信息不够明确`,onChange:e=>ye(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`d2c-artifact-actions`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:Ee||s||ve.trim().length===0,onClick:()=>void an(`design`,!1),children:`退回修改`}),(0,I.jsx)(`button`,{type:`button`,className:`primary`,disabled:Ee||s,onClick:()=>void an(`design`,!0),children:`确认设计,进入 D2C 视觉还原`})]})]}),D?.plan.phase===`ready-for-d2c`&&(0,I.jsxs)(`div`,{className:`d2c-artifact-wait`,"data-ready":`true`,children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`设计基线已确认`}),(0,I.jsx)(`span`,{children:`如果生成任务未启动或应用曾关闭,可从这里安全地继续 D2C 视觉还原。`})]}),(0,I.jsx)(`button`,{type:`button`,disabled:Ee||s,onClick:()=>void an(`design`,!0),children:`继续视觉还原 →`})]}),s&&(0,I.jsx)(`p`,{className:`d2c-start-warning`,children:`当前会话正在执行其他任务,完成或中断后可开始 E2E。`})]})]}):xn===`pending`&&a!==void 0?(0,I.jsx)(Ju,{pending:a,onOpenLog:e,onInterrupt:t}):(ke===`integration`||ke===`acceptance`)&&A.running&&A.url!==void 0?(0,I.jsxs)(`main`,{className:`d2c-live-preview`,"aria-label":`Interactive integration preview`,children:[(0,I.jsxs)(`header`,{className:`d2c-live-toolbar`,children:[(0,I.jsxs)(`span`,{className:`d2c-live-state`,children:[(0,I.jsx)(`i`,{}),` LIVE`]}),(0,I.jsx)(`code`,{title:A.url,children:A.url}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>ut(e=>e+1),children:`Refresh`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>void window.flavorDesktop.openD2cPreview(u.report.task),children:`Open in browser`})]}),(0,I.jsx)(Hu,{url:A.url,reloadKey:lt,task:u.report.task})]}):(0,I.jsxs)(`main`,{className:`d2c-canvas-area`,"data-pages":_n.length>1?`multiple`:`single`,children:[u!==void 0&&Tt!==void 0&&fn!==void 0&&pn!==void 0&&(0,I.jsxs)(I.Fragment,{children:[_n.length>1&&(0,I.jsxs)(`nav`,{className:`d2c-page-rail`,"aria-label":`页面评测结果`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`页面`}),(0,I.jsx)(`span`,{children:u.report.page===void 0?``:`${u.report.page.index+1} / ${u.report.page.count}`})]}),(0,I.jsx)(`div`,{children:_n.map(e=>(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":e.reportId===u.report.reportId,"data-selected":e.reportId===u.report.reportId,"data-status":e.evaluationStatus,onClick:()=>void Ot(e),children:[(0,I.jsx)(`span`,{children:e.page?.label??e.reportId}),(0,I.jsx)(`small`,{children:e.evaluationStatus===`invalid`?`待重测`:`${e.total.toFixed(1)} · ${e.issueCount} 项`})]},e.reportId))})]}),(0,I.jsxs)(`div`,{className:`d2c-trust-bar`,"data-status":pn.status,children:[(0,I.jsx)(`strong`,{children:Nu[pn.verdict]}),(0,I.jsx)(`span`,{children:pn.summary}),(0,I.jsx)(`div`,{children:pn.checks.map(e=>(0,I.jsxs)(`span`,{"data-status":e.status,title:e.message,children:[e.status===`pass`?`✓`:e.status===`warn`?`!`:`×`,` `,e.label]},e.key))})]}),(0,I.jsxs)(`div`,{className:`d2c-canvas-toolbar`,children:[(0,I.jsx)(`div`,{className:`d2c-mode-switch`,role:`tablist`,"aria-label":`画布显示模式`,children:mn.map(e=>(0,I.jsx)(`button`,{role:`tab`,"aria-selected":g===e,"data-active":g===e,onClick:()=>v(e),children:Mu[e]},e))}),g===`overlay`&&(0,I.jsxs)(`label`,{className:`d2c-opacity d2c-opacity-overlay`,children:[(0,I.jsxs)(`span`,{children:[`实现 `,Math.round(y*100),`%`]}),(0,I.jsx)(`input`,{type:`range`,min:0,max:100,value:Math.round(y*100),onChange:e=>b(Number(e.target.value)/100)})]}),g===`wipe`&&(0,I.jsxs)(`label`,{className:`d2c-opacity d2c-opacity-wipe`,children:[(0,I.jsxs)(`span`,{children:[`分界 `,x,`%`]}),(0,I.jsx)(`input`,{type:`range`,min:0,max:100,value:x,onChange:e=>S(Number(e.target.value))})]}),(0,I.jsxs)(`div`,{className:`d2c-zoom-tools`,"aria-label":`缩放控制`,children:[(0,I.jsx)(`button`,{onClick:()=>Lt(1/1.2),"aria-label":`缩小`,children:`−`}),(0,I.jsx)(`button`,{onClick:zt,children:`100%`}),(0,I.jsx)(`button`,{onClick:Dt,children:`适应`}),(0,I.jsx)(`button`,{onClick:()=>Lt(1.2),"aria-label":`放大`,children:`+`}),(0,I.jsxs)(`output`,{children:[Math.round(pt.scale*100),`%`]})]})]}),(0,I.jsxs)(`div`,{className:`d2c-canvas-viewport`,ref:ht,tabIndex:0,"aria-label":`差异画布。滚轮缩放,拖动平移,F 适应,0 显示 100%。`,onWheel:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();Lt(Math.exp(-e.deltaY*.0015),{x:e.clientX-t.left,y:e.clientY-t.top},!1),xt.current!==void 0&&clearTimeout(xt.current),xt.current=setTimeout(()=>{mt({...yt.current}),xt.current=void 0},120)},onPointerDown:e=>{e.button===0&&(e.currentTarget.setPointerCapture(e.pointerId),St.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,originX:yt.current.x,originY:yt.current.y},e.currentTarget.dataset.dragging=`true`)},onPointerMove:e=>{let t=St.current;t===void 0||t.pointerId!==e.pointerId||Et({...yt.current,x:t.originX+e.clientX-t.x,y:t.originY+e.clientY-t.y},!1)},onPointerUp:e=>{St.current?.pointerId===e.pointerId&&(St.current=void 0,e.currentTarget.dataset.dragging=`false`,mt({...yt.current}))},onKeyDown:e=>{if(e.key===`+`||e.key===`=`)Lt(1.2);else if(e.key===`-`)Lt(1/1.2);else if(e.key===`0`)zt();else if(e.key.toLowerCase()===`f`)Dt();else if(e.key.toLowerCase()===`b`&&Ct.current===void 0)Ct.current=g,v(`blink`);else if(/^[1-6]$/.test(e.key)){let t=mn[Number(e.key)-1];t!==void 0&&v(t)}},onKeyUp:e=>{e.key.toLowerCase()===`b`&&Ct.current!==void 0&&(v(Ct.current),Ct.current=void 0)},children:[(0,I.jsxs)(`div`,{className:`d2c-canvas-stage d2c-mode-${g}`,ref:vt,style:{width:Tt.width,height:Tt.height,"--d2c-scale":pt.scale,"--d2c-x":`${pt.x}px`,"--d2c-y":`${pt.y}px`,"--d2c-impl-opacity":y,"--d2c-wipe":`${x}%`},children:[(0,I.jsx)(`img`,{className:`d2c-layer d2c-layer-design`,src:u.designPng,alt:`设计稿截图`,draggable:!1}),(0,I.jsx)(`img`,{className:`d2c-layer d2c-layer-impl`,src:u.implementationPng,alt:`实现截图`,draggable:!1}),(0,I.jsx)(`img`,{className:`d2c-layer d2c-layer-heatmap`,src:u.heatmapPng,alt:`像素差异热力图`,draggable:!1}),pn.status===`invalid`&&(0,I.jsx)(`div`,{className:`d2c-invalid-capture-badge`,children:`错误现场 · 不参与评分`}),g===`wipe`&&(0,I.jsx)(`button`,{className:`d2c-wipe-handle`,"aria-label":`拖动拉帘分界,当前 ${Math.round(x)}%`,onPointerDown:e=>{e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&Rt(e.clientX,!1)},onPointerUp:e=>{Rt(e.clientX,!0),e.currentTarget.releasePointerCapture(e.pointerId)},children:(0,I.jsx)(`span`,{})}),(0,I.jsx)(`div`,{className:`d2c-annotations`,"aria-hidden":`true`,children:Ft.map(e=>{let t=e.designRect??e.implementationRect;return t===void 0?null:(0,I.jsx)(`div`,{className:`d2c-annotation`,"data-kind":e.kind,"data-severity":e.severity,"data-selected":e.fingerprint===C,style:Uu(t)},e.fingerprint)})}),Pt?.designRect!==void 0&&(0,I.jsx)(`div`,{className:`d2c-focus-box d2c-focus-design`,style:Uu(Pt.designRect),children:(0,I.jsx)(`span`,{children:`设计`})}),Pt?.implementationRect!==void 0&&(0,I.jsx)(`div`,{className:`d2c-focus-box d2c-focus-implementation`,style:Uu(Pt.implementationRect),children:(0,I.jsx)(`span`,{children:`实现`})}),Pt?.designRect!==void 0&&Pt.implementationRect!==void 0&&(0,I.jsx)(Q,{design:Pt.designRect,implementation:Pt.implementationRect,canvas:Tt,scale:pt.scale})]}),(0,I.jsx)(`aside`,{className:`d2c-difference-ruler`,"aria-label":`垂直差异分布`,children:P.slice(0,500).map(e=>{let t=e.designRect??e.implementationRect;return t===void 0?null:(0,I.jsx)(`button`,{style:{top:`${(t.y+t.height/2)/Tt.height*100}%`},"data-severity":e.severity,"aria-label":`定位 ${e.label}`,title:e.label,onClick:()=>It(e)},e.fingerprint)})}),(0,I.jsx)(`div`,{className:`d2c-canvas-hint`,children:`滚轮缩放 · 拖动平移 · F 适应 · 0 原始尺寸 · 按住 B 闪烁`})]})]}),m&&(0,I.jsx)(`div`,{className:`d2c-loading`,"aria-busy":`true`,children:`正在加载报告…`})]}),xn===`report`&&(0,I.jsx)(`aside`,{className:`d2c-inspector`,"aria-label":`差异检查器`,children:u!==void 0&&Tt!==void 0&&fn!==void 0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`section`,{className:`d2c-inspector-verdict`,"data-verdict":u.report.evaluation.verdict,children:[(0,I.jsx)(`span`,{className:`d2c-verdict-mark`,"aria-hidden":`true`,children:u.report.evaluation.verdict===`pass`?`✓`:u.report.evaluation.verdict===`conditional`?`!`:`×`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:u.report.evaluation.status===`invalid`?`EVALUATION INTERRUPTED`:`PAGE VERDICT`}),(0,I.jsx)(`h2`,{children:u.report.evaluation.verdict===`pass`?P.length===0?`本页已通过验收`:`已通过,仍可继续优化`:u.report.evaluation.verdict===`conditional`?`有差异需要确认`:u.report.evaluation.verdict===`invalid`?`评测需要重新运行`:`本页尚未通过验收`}),(0,I.jsx)(`span`,{children:u.report.evaluation.summary})]})]}),(0,I.jsxs)(`nav`,{className:`d2c-stage-tabs`,"aria-label":`E2E 交付阶段`,children:[(0,I.jsxs)(`button`,{type:`button`,"data-active":ke===`review`,"aria-pressed":ke===`review`,onClick:()=>Ae(`review`),children:[(0,I.jsx)(`span`,{children:`04`}),`D2C 视觉还原`]}),(0,I.jsxs)(`button`,{type:`button`,"data-active":ke===`integration`,"aria-pressed":ke===`integration`,disabled:yn===void 0||!yn.complete||u.report.evaluation.status===`invalid`,title:yn?.complete?`进入接口联调`:`全部差异通过后解锁`,onClick:Ut,children:[(0,I.jsx)(`span`,{children:`05`}),`接口联调`]}),(0,I.jsxs)(`button`,{type:`button`,"data-active":ke===`acceptance`,"aria-pressed":ke===`acceptance`,disabled:u.workflow.integrationFiles===void 0,title:u.workflow.integrationFiles===void 0?`生成联调代码后解锁`:`进入验收与交付`,onClick:Wt,children:[(0,I.jsx)(`span`,{children:`06—07`}),`验收与交付`]})]}),ke===`review`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`section`,{className:`d2c-score-card`,"aria-label":`分项得分`,"data-status":u.report.evaluation.status,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:`QUALITY PROFILE`}),(0,I.jsx)(`h2`,{children:`五项质量`})]}),u.report.evaluation.status!==`invalid`&&(0,I.jsxs)(`span`,{children:[ku.filter(({key:e})=>(fn[e]??0)>=.9).length,` / 5 达标`]})]}),u.report.evaluation.status===`invalid`&&(0,I.jsx)(`p`,{className:`d2c-score-invalid`,children:`实现页面渲染失败,当前截图仅用于诊断,不生成正式分数。`}),u.report.evaluation.status!==`invalid`&&(0,I.jsx)(`div`,{className:`d2c-score-list`,children:ku.map(({key:e,label:t})=>fn[e]===void 0?null:(0,I.jsxs)(`div`,{"data-level":zu(fn[e]),children:[(0,I.jsx)(`span`,{children:t}),(0,I.jsx)(`i`,{children:(0,I.jsx)(`b`,{style:{"--score":fn[e]}})}),(0,I.jsx)(`strong`,{children:Math.round(fn[e]*100)})]},e))})]}),u.report.evaluation.status!==`invalid`&&yn!==void 0&&(0,I.jsxs)(`section`,{className:`d2c-review-console`,"data-complete":yn.complete,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:`REVIEW QUEUE`}),(0,I.jsx)(`h2`,{children:yn.complete?`视觉审阅已完成`:`等待你的验收`})]}),(0,I.jsxs)(`strong`,{children:[yn.accepted,(0,I.jsxs)(`span`,{children:[` / `,yn.total]})]})]}),(0,I.jsxs)(`div`,{className:`d2c-review-meter`,"aria-label":`已通过 ${yn.accepted},待审 ${yn.pending},退回 ${yn.needsFix}`,children:[(0,I.jsx)(`i`,{style:{"--accepted":yn.total===0?1:yn.accepted/yn.total}}),(0,I.jsxs)(`span`,{children:[`待审 `,(0,I.jsx)(`b`,{children:yn.pending})]}),(0,I.jsxs)(`span`,{children:[`通过 `,(0,I.jsx)(`b`,{children:yn.accepted})]}),(0,I.jsxs)(`span`,{children:[`退回 `,(0,I.jsx)(`b`,{children:yn.needsFix})]})]}),(0,I.jsxs)(`div`,{className:`d2c-review-bulk`,children:[!yn.complete&&(0,I.jsx)(`button`,{type:`button`,disabled:je||s||P.length===0,onClick:()=>void Vt(P.map(e=>e.fingerprint),`accepted`),children:`全部跳过(不扣分)`}),!yn.complete&&(0,I.jsx)(`button`,{type:`button`,className:`d2c-review-reject`,disabled:je||s||P.length===0,onClick:()=>void Vt(P.map(e=>e.fingerprint),`needs-fix`,`集中修复所有退回差异,仍需严格限制在各自模块文件内。`),children:`全部退回并修复`}),yn.complete&&(0,I.jsxs)(`button`,{type:`button`,className:`d2c-review-next`,onClick:Ut,children:[`进入接口联调 `,(0,I.jsx)(`span`,{children:`→`})]})]})]}),(0,I.jsxs)(`div`,{className:`d2c-issue-heading`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{children:u.report.evaluation.status===`invalid`?`错误诊断`:`差异问题`}),u.report.evaluation.status!==`invalid`&&(0,I.jsxs)(`span`,{children:[Nt.length,` / `,P.length]})]}),u.report.evaluation.status!==`invalid`&&(0,I.jsx)(`div`,{className:`d2c-issue-filters`,children:[`all`,`blocking`,`content`,`geometry`].map(e=>(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":ee===e,"data-active":ee===e,onClick:()=>{te(e),re(_u)},children:[(0,I.jsx)(`span`,{children:Au[e]}),(0,I.jsx)(`small`,{children:Mt[e]})]},e))})]}),Nt.length===0?(0,I.jsxs)(`div`,{className:`d2c-issue-empty`,"data-kind":u.report.evaluation.status===`invalid`?`invalid`:P.length===0?`clear`:`filtered`,children:[(0,I.jsx)(`span`,{className:`d2c-empty-mark`,"aria-hidden":`true`,children:u.report.evaluation.status===`invalid`?`!`:P.length===0?`✓`:`⌁`}),(0,I.jsx)(`strong`,{children:u.report.evaluation.status===`invalid`?`等待有效评测`:P.length===0?`未发现可定位的差异`:`这个筛选下没有问题`}),(0,I.jsx)(`p`,{children:u.report.evaluation.status===`invalid`?`修复项目并重新运行 E2E 中的 D2C 视觉还原后,这里会生成可定位的差异清单。`:P.length===0?`布局、色彩、字体、内容与像素结果均已通过检查。`:`切换分类或显示全部问题,继续检查其他差异。`}),u.report.evaluation.status!==`invalid`&&(0,I.jsxs)(`div`,{className:`d2c-empty-stats`,children:[(0,I.jsxs)(`span`,{children:[`阻断 `,(0,I.jsx)(`b`,{children:Mt.blocking})]}),(0,I.jsxs)(`span`,{children:[`内容 `,(0,I.jsx)(`b`,{children:Mt.content})]}),(0,I.jsxs)(`span`,{children:[`几何 `,(0,I.jsx)(`b`,{children:Mt.geometry})]})]}),u.report.evaluation.status!==`invalid`&&(P.length===0?(0,I.jsx)(`button`,{type:`button`,onClick:()=>{v(`overlay`),Dt()},children:`查看叠加结果`}):(0,I.jsx)(`button`,{type:`button`,onClick:()=>{te(`all`),re(_u)},children:`显示全部问题`}))]}):(0,I.jsx)(`ol`,{className:`d2c-issue-list`,children:Nt.slice(0,ne).map(e=>{let t=bn(e.fingerprint);return(0,I.jsxs)(`li`,{"data-severity":e.severity,"data-selected":C===e.fingerprint,"data-review":t?.decision??`pending`,children:[(0,I.jsxs)(`button`,{className:`d2c-issue-main`,onClick:()=>It(e),"aria-pressed":C===e.fingerprint,children:[(0,I.jsx)(`span`,{className:`d2c-impact`,children:t?.decision===`accepted`?`✓`:t?.decision===`needs-fix`?`↻`:e.impact.toFixed(1)}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:e.label}),Lu(e).map(e=>(0,I.jsx)(`small`,{children:e},e))]})]}),C===e.fingerprint&&(0,I.jsxs)(`div`,{className:`d2c-evidence`,children:[(0,I.jsxs)(`div`,{className:`d2c-evidence-pair`,children:[e.designRect!==void 0&&(0,I.jsx)(Bu,{src:u.designPng,rect:e.designRect,canvas:Tt,label:`设计`}),e.implementationRect!==void 0&&(0,I.jsx)(Bu,{src:u.implementationPng,rect:e.implementationRect,canvas:Tt,label:`实现`})]}),(0,I.jsxs)(`div`,{className:`d2c-copy-actions`,children:[e.selector!==void 0&&(0,I.jsx)(`button`,{onClick:()=>Bt(e.selector),children:`复制选择器`}),(0,I.jsx)(`button`,{onClick:()=>Bt(`${e.label}\n${Lu(e).join(`
|
|
148
148
|
`)}\n位置:${JSON.stringify(vn)}`),children:`复制修复线索`})]}),(0,I.jsxs)(`label`,{className:`d2c-review-instruction`,children:[(0,I.jsx)(`span`,{children:`补充修改要求`}),(0,I.jsx)(`textarea`,{rows:2,value:Ne,placeholder:`例如:保持卡片高度,只调整内部间距`,onChange:e=>Pe(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`d2c-review-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`d2c-accept`,disabled:je||s||t?.decision===`accepted`,onClick:()=>void Vt([e.fingerprint],`accepted`),children:`跳过(本项不扣分)`}),(0,I.jsx)(`button`,{type:`button`,className:`d2c-fix`,disabled:je||s,onClick:()=>void Vt([e.fingerprint],`needs-fix`,Ne||void 0),children:`修复并自动视觉复验`})]})]})]},e.fingerprint)})}),Nt.length>ne&&(0,I.jsxs)(`button`,{className:`d2c-show-more`,onClick:()=>re(e=>e+_u),children:[`再显示 `,Math.min(_u,Nt.length-ne),` 条`]})]}):(0,I.jsxs)(`section`,{className:`d2c-integration-panel`,"data-stage":ke,"aria-label":ke===`acceptance`?`验收与交付`:`接口联调`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`p`,{children:ke===`acceptance`?`ACCEPTANCE & DELIVERY`:`API INTEGRATION`}),(0,I.jsx)(`h2`,{children:ke===`acceptance`?`验收与交付`:Fe===void 0?u.deliveryOrigin===`requirement`?`自动准备接口契约`:`导入接口描述`:Fe.document.title}),(0,I.jsx)(`span`,{children:ke===`acceptance`?`通过自动回放、人工操作与多模态质量门,完成最终交付验收。`:Fe===void 0?u.deliveryOrigin===`requirement`?`根据已确认 PRD 与实现模块生成 OpenAPI,无需手动上传。`:`上传 Swagger / OpenAPI JSON,自动匹配页面模块和接口出入参。`:`${Fe.document.version}${Fe.document.baseUrl?` · ${Fe.document.baseUrl}`:``}`})]}),Fe===void 0?(0,I.jsxs)(`div`,{className:`d2c-api-import`,"data-origin":u.deliveryOrigin,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`{}`}),(0,I.jsx)(`strong`,{children:u.deliveryOrigin===`requirement`?`正在根据 PRD 与模块准备 OpenAPI 契约`:`Swagger JSON`}),(0,I.jsx)(`p`,{children:u.deliveryOrigin===`requirement`?`契约会自动生成并映射到当前实现;也可接入已有后端契约覆盖默认结果。`:`支持 Swagger 2.0、OpenAPI 3.0/3.1 和文档内引用。`}),(0,I.jsx)(`button`,{type:`button`,disabled:Le,onClick:()=>void F(),children:Le?u.deliveryOrigin===`requirement`?`自动准备中…`:`正在解析…`:u.deliveryOrigin===`requirement`?`接入已有 Swagger / OpenAPI`:`选择 swagger.json`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`d2c-api-summary`,children:[(0,I.jsxs)(`span`,{children:[`模块 `,(0,I.jsx)(`b`,{children:Fe.mappings.length})]}),(0,I.jsxs)(`span`,{children:[`自动匹配 `,(0,I.jsx)(`b`,{children:Fe.mappings.filter(e=>e.status===`auto`).length})]}),(0,I.jsxs)(`span`,{children:[`待确认 `,(0,I.jsx)(`b`,{children:Fe.mappings.filter(e=>e.status===`needs-confirmation`).length})]})]}),(0,I.jsx)(`ol`,{className:`d2c-mapping-list`,children:Fe.mappings.map(e=>(0,I.jsxs)(`li`,{"data-status":e.status,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`span`,{children:e.moduleLabel}),(0,I.jsx)(`small`,{children:e.status===`auto`?`自动匹配`:e.status===`confirmed`?`已确认`:`需要确认`})]}),(0,I.jsx)(`select`,{"aria-label":`${e.moduleLabel} 接口`,value:e.operationKey,disabled:Le,onChange:t=>void Gt(e,t.target.value),children:Fe.document.operations.map(e=>(0,I.jsxs)(`option`,{value:e.id,children:[e.operationId,` · `,e.id]},e.id))}),e.status===`needs-confirmation`&&(0,I.jsx)(`button`,{type:`button`,className:`d2c-confirm-mapping`,disabled:Le,onClick:()=>void Gt(e,e.operationKey),children:`确认此映射`}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{children:[`请求 `,e.parameters.length+e.requestFields.length,` 字段`]}),(0,I.jsxs)(`span`,{children:[`响应 `,e.responseFields.length,` 字段`]}),(0,I.jsxs)(`b`,{children:[Math.round(e.confidence*100),`%`]})]})]},e.moduleId))}),(0,I.jsxs)(`div`,{className:`d2c-integration-launch`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{children:`接口映射已就绪`}),(0,I.jsx)(`small`,{children:Fe.mappings.some(e=>e.status===`needs-confirmation`)?`仍有接口需要人工确认`:`${Fe.mappings.length} 个模块将接入真实请求链路`})]}),(0,I.jsxs)(`button`,{type:`button`,className:`d2c-generate-integration`,disabled:Le||Fe.mappings.some(e=>e.status===`needs-confirmation`),onClick:()=>void Kt(),children:[Le?`正在准备联调…`:u.workflow.integrationFiles===void 0?`生成并开始联调`:`重新生成联调代码`,(0,I.jsx)(`span`,{children:`→`})]})]}),Fe.mappings.some(e=>e.status===`needs-confirmation`)&&(0,I.jsx)(`p`,{className:`d2c-api-hint`,children:`确认所有标记为“需要确认”的接口后即可生成。`}),(0,I.jsxs)(`section`,{className:`d2c-mock-control`,"data-running":ze.running,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:u.deliveryOrigin===`requirement`?ze.running?`真实后端服务运行中`:`真实后端服务未启动`:ze.running?`本地契约服务运行中`:`本地契约服务未启动`}),(0,I.jsx)(`small`,{children:ze.url??`生成联调代码后可启动`})]})]}),u.workflow.integrationFiles!==void 0&&(0,I.jsx)(`button`,{type:`button`,disabled:Le||A.running,title:A.running?`请先停止交互页面`:void 0,onClick:()=>void qt(),children:ze.running?`停止`:`启动`})]}),u.workflow.integrationFiles!==void 0&&(0,I.jsxs)(`section`,{className:`d2c-integration-ready`,"data-running":A.running,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`✓`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`联调环境已生成`}),(0,I.jsx)(`small`,{children:A.running?`前端页面与后端服务已连接,可进入最终验收。`:`启动联调页面后即可进入自动与人工验收。`})]}),(0,I.jsx)(`button`,{type:`button`,onClick:Wt,children:`进入验收与交付 →`})]}),(0,I.jsxs)(`section`,{className:`d2c-preview-control`,"data-running":A.running,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:`INTERACTIVE ACCEPTANCE`}),(0,I.jsx)(`h3`,{children:A.running?`可交互页面运行中`:`等待启动可交互页面`})]}),(0,I.jsx)(`i`,{})]}),(0,I.jsx)(`code`,{children:A.url??`Vite preview not started`}),(0,I.jsxs)(`div`,{className:`d2c-preview-actions`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:Ge||u.workflow.integrationFiles===void 0,onClick:()=>void(A.running?Xt():Yt()),children:A.running?`停止页面`:`启动页面`}),(0,I.jsx)(`button`,{type:`button`,disabled:Ge||!A.running,onClick:()=>void Zt(),children:qe?`可视回放中…`:Ge?`处理中…`:`运行自动验收`}),A.running&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>void window.flavorDesktop.openD2cPreview(u.report.task),children:`浏览器打开`})]}),qe&&(0,I.jsxs)(`div`,{className:`d2c-playback-notice`,role:`status`,"aria-live":`polite`,children:[(0,I.jsx)(`i`,{"aria-hidden":`true`}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:`正在可视化回放`}),(0,I.jsx)(`small`,{children:$e.configured?`多模态模型正在观察并规划用户旅程;随后青色指针会完成点击、输入、导航和检查。`:`请观察左侧页面:青色指针会依次完成设计契约中的定位、点击、输入和检查。配置多模态模型后可启用自主审阅。`})]})]}),j!==void 0&&(0,I.jsxs)(`div`,{className:`d2c-review-plan`,"data-mode":j.mode,children:[(0,I.jsx)(`strong`,{children:j.mode===`autonomous`?`自主审阅已执行`:j.mode===`contract-fallback`?`自主规划失败,已执行设计契约`:`设计契约已执行`}),(0,I.jsxs)(`span`,{children:[j.plannedScenarios,` 条用户旅程`,j.model?` · ${j.model}`:``]}),j.summary&&(0,I.jsx)(`p`,{children:j.summary}),j.warning&&(0,I.jsx)(`p`,{role:`alert`,children:j.warning})]}),He!==void 0&&(0,I.jsxs)(`div`,{className:`d2c-test-results`,"data-passed":He.passed,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:He.passed?`自动验收通过`:`${He.failures} 条自动验收失败`}),(0,I.jsxs)(`span`,{children:[He.total,` scenarios · `,He.apiRequestCount,` API requests`]})]}),!He.passed&&(0,I.jsx)(`button`,{type:`button`,disabled:Ye!==void 0||s,onClick:()=>void $t(He.scenarios.filter(e=>!e.passed)),children:Ye===`all`?`正在发起修复…`:Ze.trim()?`按要求修复全部`:`修复全部失败`})]}),!He.passed&&(0,I.jsxs)(`label`,{className:`d2c-interaction-repair-guide`,children:[(0,I.jsxs)(`span`,{children:[`补充修复要求 `,(0,I.jsx)(`small`,{children:`可选`})]}),(0,I.jsx)(`textarea`,{rows:3,value:Ze,placeholder:`例如:不要修改接口契约;优先检查登录响应的 data 包装层与会话持久化`,onChange:e=>Qe(e.target.value)}),(0,I.jsx)(`small`,{children:`留空则按失败证据自动修复;填写后会连同请求日志一起交给修复任务。`})]}),(0,I.jsx)(`ol`,{children:He.scenarios.map(e=>(0,I.jsxs)(`li`,{"data-passed":e.passed,children:[(0,I.jsxs)(`span`,{children:[e.passed?`✓`:`×`,` `,e.id]}),(0,I.jsxs)(`small`,{children:[e.apiRequestCount,` API · `,e.durationMs,`ms`]}),e.failure!==void 0&&(0,I.jsx)(`p`,{children:e.failure}),!e.passed&&(0,I.jsx)(`button`,{type:`button`,className:`d2c-fix-scenario`,disabled:Ye!==void 0||s,"aria-label":`修复失败场景 ${e.id}`,onClick:()=>void $t([e]),children:Ye===e.id?`正在发起修复…`:Ze.trim()?`按要求修复此项`:`修复此项`})]},e.id))})]}),(0,I.jsxs)(`div`,{className:`d2c-manual-acceptance`,children:[(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:`人工验收`}),(0,I.jsx)(`small`,{children:`请直接在左侧页面完成点击、输入和提交流程`})]}),(0,I.jsx)(`button`,{type:`button`,disabled:Ge||!A.running,"data-accepted":u.workflow.interaction?.manualDecision===`accepted`,onClick:()=>void Qt(u.workflow.interaction?.manualDecision!==`accepted`),children:u.workflow.interaction?.manualDecision===`accepted`?`已通过(撤回)`:`确认人工验收通过`})]}),(0,I.jsxs)(`section`,{className:`d2c-quality-gate`,"data-verdict":u.workflow.quality?.verdict??`pending`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:`LLM-AS-A-JUDGE`}),(0,I.jsx)(`h3`,{children:`最终质量门`})]}),u.workflow.quality!==void 0&&(0,I.jsx)(`strong`,{children:u.workflow.quality.overallScore.toFixed(1)})]}),!$e.configured||at?(0,I.jsxs)(`form`,{className:`d2c-judge-config`,onSubmit:e=>void ln(e),children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`协议`}),(0,I.jsxs)(`select`,{value:st.protocol,onChange:e=>ct(t=>({...t,protocol:e.target.value})),children:[(0,I.jsx)(`option`,{value:`openai-compatible`,children:`OpenAI 兼容`}),(0,I.jsx)(`option`,{value:`anthropic`,children:`Anthropic`})]})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`Base URL`}),(0,I.jsx)(`input`,{required:!0,type:`url`,placeholder:`https://api.example.com/v1`,value:st.baseURL,onChange:e=>ct(t=>({...t,baseURL:e.target.value}))})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`模型`}),(0,I.jsx)(`input`,{required:!0,placeholder:`支持视觉的模型名称`,value:st.model,onChange:e=>ct(t=>({...t,model:e.target.value}))})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`API Key`}),(0,I.jsx)(`input`,{required:!0,type:`password`,autoComplete:`off`,value:st.apiKey,onChange:e=>ct(t=>({...t,apiKey:e.target.value}))})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`通过阈值`}),(0,I.jsx)(`input`,{required:!0,type:`number`,min:0,max:100,value:st.passThreshold,onChange:e=>ct(t=>({...t,passThreshold:Number(e.target.value)}))})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{type:`submit`,disabled:tt,children:tt?`保存中…`:`保存多模态模型`}),$e.configured&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>ot(!1),children:`取消`})]})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`d2c-judge-model`,children:[(0,I.jsx)(`span`,{children:$e.model}),(0,I.jsxs)(`small`,{children:[$e.baseURL,` · 阈值 `,$e.passThreshold]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>ot(!0),children:`修改配置`})]}),u.workflow.quality===void 0?(0,I.jsx)(`p`,{children:`可随时评测当前版本;自动与人工验收未通过时,评分只用于诊断,不会放行最终交付。`}):(0,I.jsxs)(`div`,{className:`d2c-quality-result`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{children:[`视觉质量 `,(0,I.jsx)(`b`,{children:u.workflow.quality.visualScore})]}),(0,I.jsxs)(`span`,{children:[`交互质量 `,(0,I.jsx)(`b`,{children:u.workflow.quality.interactionScore})]}),(0,I.jsxs)(`span`,{children:[`综合得分 `,(0,I.jsx)(`b`,{children:u.workflow.quality.overallScore})]})]}),(0,I.jsx)(`strong`,{children:u.workflow.quality.verdict===`pass`?`质量门通过`:`质量门未通过`}),(0,I.jsx)(`p`,{children:u.workflow.quality.summary}),u.workflow.quality.issues.length>0&&(0,I.jsx)(`ol`,{children:u.workflow.quality.issues.map(e=>(0,I.jsxs)(`li`,{"data-severity":e.severity,"data-decision":e.decision,children:[(0,I.jsx)(`span`,{children:e.description}),(0,I.jsx)(`small`,{children:e.recommendation}),(0,I.jsxs)(`em`,{children:[e.category,` · 影响 `,e.scoreImpact,` 分 · `,e.decision===`skipped`?`已跳过,不扣分`:e.decision===`fixing`?`修复中,完成后自动复验`:`待处理`]}),(0,I.jsxs)(`div`,{className:`d2c-quality-issue-actions`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:rt!==void 0||e.decision===`skipped`,onClick:()=>void dn(e,`skipped`),children:`跳过(不扣分)`}),(0,I.jsx)(`button`,{type:`button`,disabled:rt!==void 0||e.decision===`fixing`,onClick:()=>void dn(e,`fixing`),children:`修复并自动复验`})]})]},e.id))})]}),(0,I.jsx)(`button`,{type:`button`,className:`d2c-run-judge`,disabled:tt||!A.running||u.workflow.interaction?.automated===void 0,title:u.workflow.interaction?.automated===void 0?`至少运行一次自动验收后可评分;验收失败也可以评分诊断`:void 0,onClick:()=>void un(),children:tt?`AI 评审中…`:u.workflow.quality===void 0?`运行 AI 质量评审`:`重新运行 AI 质量评审`})]})]}),u.workflow.stage===`completed`&&(0,I.jsx)(`p`,{className:`d2c-acceptance-complete`,children:`✓ 自动、人工与多模态质量验收均已完成`})]})]})]})]}):(0,I.jsxs)(`div`,{className:`d2c-inspector-empty`,children:[(0,I.jsx)(`strong`,{children:`问题检查器`}),(0,I.jsx)(`span`,{children:`选择报告后,可按影响度逐项定位和取证。`})]})})]})]})}var Xu={repository:!1,branch:``,head:``,files:[]};function Zu(e,t=!1){let n=e.replace(/\r\n/g,`
|
|
149
149
|
`).split(`
|
|
150
|
-
`);if(n.at(-1)===``&&n.pop(),t&&!n.some(e=>e.startsWith(`@@`)))return n.map((e,t)=>({kind:`addition`,marker:`+`,text:e,newNumber:t+1}));let r=0,i=0,a=!1;return n.map(e=>{let t=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@(.*)$/.exec(e);if(t!==null)return r=Number(t[1]),i=Number(t[2]),a=!0,{kind:`hunk`,marker:`@@`,text:t[3]?.trim()??``};if(!a||e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`--- `)||e.startsWith(`+++ `))return{kind:`meta`,marker:``,text:e};if(e.startsWith(`+`)&&!e.startsWith(`+++`))return{kind:`addition`,marker:`+`,text:e.slice(1),newNumber:i++};if(e.startsWith(`-`)&&!e.startsWith(`---`))return{kind:`deletion`,marker:`−`,text:e.slice(1),oldNumber:r++};if(e.startsWith(`\\ No newline`))return{kind:`meta`,marker:``,text:e};let n={kind:`context`,marker:``,text:e.startsWith(` `)?e.slice(1):e,oldNumber:r,newNumber:i};return r+=1,i+=1,n})}function Qu({onClose:e,onReview:t,onError:n}){let[r,i]=(0,_.useState)(Xu),[a,o]=(0,_.useState)(),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(`working`),[d,f]=(0,_.useState)(!0),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),v=(0,_.useMemo)(()=>Zu(s,a?.untracked),[s,a?.untracked]),y=v.filter(e=>e.kind===`addition`).length,b=v.filter(e=>e.kind===`deletion`).length,x=r.files.filter(e=>e.staged).length,S=async()=>{try{i(await window.flavorDesktop.gitStatus())}catch(e){n(ed(e))}finally{f(!1)}};(0,_.useEffect)(()=>{S()},[]);let C=async(e,t)=>{m(!0),c(``),u(t);try{c(await window.flavorDesktop.gitDiff(e.path,t===`staged`))}catch(e){let t=ed(e);c(t),n(t)}finally{m(!1)}},w=async e=>{o(e),await C(e,e.unstaged||e.untracked?`working`:`staged`)},ee=async(e,t)=>{if(!(e===`discard`&&!window.confirm(`确定还原 ${t.path}?此操作无法撤销。`)))try{let n=e===`stage`?await window.flavorDesktop.gitStage(t.path):e===`unstage`?await window.flavorDesktop.gitUnstage(t.path):await window.flavorDesktop.gitDiscard(t.path);i(n);let r=n.files.find(e=>e.path===t.path);r===void 0?(o(void 0),c(``)):(o(r),await C(r,r.unstaged||r.untracked?`working`:`staged`))}catch(e){n(ed(e))}},te=async()=>{if(h.trim())try{let e=await window.flavorDesktop.gitCommit(h.trim());i(e.status),g(``),o(void 0),c(``),n(`已提交 ${e.result}`)}catch(e){n(ed(e))}};return(0,I.jsxs)(`section`,{className:`manager-view git-view`,children:[(0,I.jsxs)(`header`,{className:`manager-header git-header`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{className:`git-back`,onClick:e,"aria-label":`返回`,children:`←`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{children:`Git 变更`}),(0,I.jsx)(`span`,{children:`审阅并整理本次工作区修改`})]})]}),r.repository&&(0,I.jsxs)(`span`,{className:`git-branch`,children:[(0,I.jsx)(`i`,{}),r.branch,(0,I.jsx)(`b`,{children:r.head})]})]}),d?(0,I.jsx)(`p`,{className:`manager-empty`,children:`正在读取工作区…`}):r.repository?(0,I.jsxs)(`div`,{className:`git-layout`,children:[(0,I.jsxs)(`aside`,{className:`git-files`,children:[(0,I.jsxs)(`div`,{className:`git-toolbar`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`变更`}),(0,I.jsx)(`span`,{children:r.files.length})]}),(0,I.jsx)(`button`,{onClick:()=>void S(),title:`重新读取变更`,children:`↻`})]}),r.files.length===0?(0,I.jsxs)(`div`,{className:`git-clean`,children:[(0,I.jsx)(`i`,{children:`✓`}),(0,I.jsx)(`strong`,{children:`工作区干净`}),(0,I.jsx)(`span`,{children:`没有需要审阅的修改`})]}):r.files.map(e=>{let t=$u(e.path),n=e.untracked?`U`:e.index===`A`?`A`:e.index===`D`||e.worktree===`D`?`D`:`M`;return(0,I.jsxs)(`div`,{className:`git-file-row`,"data-active":a?.path===e.path,children:[(0,I.jsxs)(`button`,{className:`git-file-name`,onClick:()=>void w(e),title:e.path,children:[(0,I.jsx)(`code`,{"data-state":n,children:n}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`b`,{children:t.name}),t.directory&&(0,I.jsx)(`small`,{children:t.directory})]})]}),(0,I.jsxs)(`div`,{className:`git-file-actions`,children:[e.staged?(0,I.jsx)(`button`,{onClick:()=>void ee(`unstage`,e),children:`取消暂存`}):(0,I.jsx)(`button`,{className:`stage-action`,onClick:()=>void ee(`stage`,e),children:`暂存`}),(e.unstaged||e.untracked)&&(0,I.jsx)(`button`,{className:`danger-text`,onClick:()=>void ee(`discard`,e),children:`还原`})]})]},e.path)})]}),(0,I.jsx)(`article`,{className:`git-diff`,children:a===void 0?(0,I.jsxs)(`div`,{className:`git-diff-empty`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{children:`−`}),(0,I.jsx)(`span`,{children:`+`})]}),(0,I.jsx)(`strong`,{children:`选择文件查看差异`}),(0,I.jsx)(`p`,{children:`逐行审阅修改,然后决定暂存或还原。`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`header`,{className:`git-diff-header`,children:[(0,I.jsxs)(`div`,{className:`git-diff-title`,children:[(0,I.jsx)(`span`,{children:$u(a.path).directory||`项目根目录`}),(0,I.jsx)(`strong`,{children:$u(a.path).name})]}),(0,I.jsxs)(`div`,{className:`git-diff-controls`,children:[a.staged&&a.unstaged&&(0,I.jsxs)(`div`,{className:`git-layer-switch`,children:[(0,I.jsx)(`button`,{"data-active":l===`working`,onClick:()=>void C(a,`working`),children:`工作区`}),(0,I.jsx)(`button`,{"data-active":l===`staged`,onClick:()=>void C(a,`staged`),children:`已暂存`})]}),!p&&(0,I.jsxs)(`div`,{className:`git-diff-stats`,children:[(0,I.jsxs)(`span`,{className:`add`,children:[`+`,y]}),(0,I.jsxs)(`span`,{className:`del`,children:[`−`,b]})]})]})]}),(0,I.jsx)(`div`,{className:`git-code`,"aria-label":`${a.path} 差异`,children:p?(0,I.jsxs)(`div`,{className:`git-diff-loading`,children:[(0,I.jsx)(`i`,{}),`正在生成差异…`]}):v.map((e,t)=>(0,I.jsxs)(`div`,{className:`git-code-line`,"data-kind":e.kind,children:[(0,I.jsx)(`span`,{className:`old-line`,children:e.oldNumber??``}),(0,I.jsx)(`span`,{className:`new-line`,children:e.newNumber??``}),(0,I.jsx)(`span`,{className:`change-marker`,children:e.marker}),(0,I.jsx)(`code`,{children:e.text||` `})]},`${t}-${e.oldNumber??``}-${e.newNumber??``}`))})]})})]}):(0,I.jsx)(`p`,{className:`manager-empty`,children:`当前项目不是 Git 仓库`}),r.repository&&(0,I.jsxs)(`footer`,{className:`git-footer`,children:[(0,I.jsx)(`button`,{className:`review-action`,onClick:t,children:`交给 /review`}),(0,I.jsxs)(`div`,{className:`commit-field`,children:[(0,I.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:x>0?`描述这次提交…`:`暂存文件后即可提交`}),(0,I.jsxs)(`span`,{children:[x,` 个文件已暂存`]})]}),(0,I.jsx)(`button`,{className:`commit-action`,disabled:!h.trim()||x===0,onClick:()=>void te(),children:`提交`})]})]})}function $u(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/`);return n<0?{name:t,directory:``}:{name:t.slice(n+1),directory:t.slice(0,n)}}function ed(e){return e instanceof Error?e.message:String(e)}function td(e){let t=[],n,r=()=>{if(n===void 0)return;let e=n.lines.length,r=n.hunks.map((t,r)=>({...t,end:n.hunks[r+1]?.start??e}));t.push({...n,hunks:r})};for(let t of e.split(/\r?\n/)){let e=/^diff --(?:git|flavor) a\/(.+?) b\/(.+)$/.exec(t);if(e!==null){r(),n={path:e[2],lines:[t],hunks:[],additions:0,deletions:0};continue}if(n===void 0)continue;let i=n.lines.length;n.lines.push(t),t.startsWith(`@@`)?n.hunks.push({id:`${n.path}:${n.hunks.length+1}`,header:t,start:i,end:i+1}):t.startsWith(`+`)&&!t.startsWith(`+++`)?n.additions+=1:t.startsWith(`-`)&&!t.startsWith(`---`)&&(n.deletions+=1)}return r(),t}function nd(e){return Math.min(2.4,Math.max(.55,e))}function rd(e,t,n){let r=nd(n),i=r/e.scale;return{x:t.x-(t.x-e.x)*i,y:t.y-(t.y-e.y)*i,scale:r}}function id(e,t,n){return{x:Math.round(t.x+e.x*n.width*t.scale/100),y:Math.round(t.y+e.y*n.height*t.scale/100)}}function ad(e,t){let n=new Map,r=[];n.set(e.id,{...e,role:`origin`,x:50,y:50});let i=(t,i,a)=>{t.slice(0,8).forEach((t,o,s)=>{n.set(t.id,{...t,role:i,x:a,y:(o+1)*100/(s.length+1)}),r.push(i===`caller`?{from:t.id,to:e.id,kind:i}:{from:e.id,to:t.id,kind:i})})};i(t.callers,`caller`,14),i(t.callees,`callee`,86);let a=t.impact.filter(e=>!n.has(e.id)).slice(0,12),o=Math.ceil(a.length/2);return a.forEach((t,i)=>{let s=i<o,c=s?i:i-o,l=s?o:a.length-o,u=Math.floor(c/3),d=c%3,f=Math.min(3,l-u*3),p=(d+1)*100/(f+1),m=s?13+u*11:87-u*11;n.set(t.id,{...t,role:`impact`,x:p,y:m,hop:t.hop}),r.push({from:e.id,to:t.id,kind:`impact`,hop:t.hop})}),{nodes:[...n.values()],edges:r}}function od(e){let t=new Map(e.map(e=>[e.id,e]));return e.map(e=>{let n=0,r=e.parentId,i=new Set([e.id]);for(;r!==null&&n<12&&!i.has(r);){i.add(r);let e=t.get(r);if(e===void 0)break;n+=1,r=e.parentId}return{node:e,depth:n}})}function sd(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)??e}function cd(e,t){let n=t.filter(e=>e.state!==`closed`);return e!==void 0&&n.some(t=>t.id===e)?e:n.find(e=>e.state===`running`)?.id??n[0]?.id}var ld=`modulepreload`,ud=function(e,t){return new URL(e,t).href},dd={},fd=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=ud(t,n),t=s(t),t in dd)return;dd[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:ld,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},pd=[{id:`cockpit`,label:`执行`},{id:`timeline`,label:`时间机`},{id:`terminal`,label:`终端`},{id:`review`,label:`审查`},{id:`preview`,label:`预览`},{id:`context`,label:`上下文`},{id:`ast`,label:`代码图`},{id:`pals`,label:`Pals`},{id:`worktrees`,label:`工作树`}],md=_.lazy(()=>fd(()=>import(`./interactive-terminal-BpNgJ_fv.js`),[],import.meta.url));function hd({snapshot:e,onClose:t,onError:n,onCompose:r}){let[i,a]=(0,_.useState)(`cockpit`),[o,s]=(0,_.useState)(()=>Od(e.jobs.map(e=>e.label).join(`
|
|
151
|
-
`))),c=(0,_.useRef)(new Map),l=e=>s(t=>[...new Set([...t,...Od(e)])].slice(-20));return(0,_.useEffect)(()=>{let t=!1;return Promise.all(e.jobs.map(async e=>{let n=await window.flavorDesktop.readJob(e.id,c.current.get(e.id)??0).catch(()=>void 0);n===void 0||t||(c.current.set(e.id,n.cursor),l(n.output))})),()=>{t=!0}},[e.jobs]),(0,I.jsxs)(`section`,{className:`agent-workbench manager-view`,children:[(0,I.jsxs)(`header`,{className:`manager-header workbench-header`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{onClick:t,children:`‹`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`FLAVOR DESKTOP 1.3.3`}),(0,I.jsx)(`h2`,{children:`Agent 工作台`})]})]}),(0,I.jsx)(`span`,{children:e.activeSession?.environment===`worktree`?`隔离工作树`:`本地检出`})]}),(0,I.jsx)(`nav`,{className:`workbench-tabs`,"aria-label":`工作台功能`,children:pd.map(e=>(0,I.jsx)(`button`,{"data-active":i===e.id,onClick:()=>a(e.id),children:e.label},e.id))}),(0,I.jsxs)(`div`,{className:`workbench-stage`,children:[i===`cockpit`&&(0,I.jsx)(gd,{snapshot:e,onCompose:r}),i===`timeline`&&(0,I.jsx)(_d,{onError:n}),i===`terminal`&&(0,I.jsx)(vd,{onError:n,onDiscover:l}),i===`review`&&(0,I.jsx)($,{onError:n,onCompose:r}),i===`preview`&&(0,I.jsx)(bd,{onError:n,suggestions:o}),i===`context`&&(0,I.jsx)(xd,{snapshot:e,onError:n}),i===`ast`&&(0,I.jsx)(Sd,{onError:n,onCompose:r}),i===`pals`&&(0,I.jsx)(Td,{onError:n}),i===`worktrees`&&(0,I.jsx)(Ed,{snapshot:e,onError:n})]})]})}function gd({snapshot:e,onCompose:t}){let[n,r]=(0,_.useState)(),[i,a]=(0,_.useState)(``);(0,_.useEffect)(()=>{window.flavorDesktop.inspectWorkbench().then(r).catch(()=>void 0)},[e.activeSession?.sessionId]);let o=n?.goals[0];(0,_.useEffect)(()=>{o!==void 0&&a(o.objective)},[o?.id]);let s=e.tasks?.plan?.tasks??[],c=Object.entries(e.tasks?.subagents.states??{});return(0,I.jsxs)(`div`,{className:`cockpit-grid`,children:[(0,I.jsxs)(`section`,{className:`cockpit-trace`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`small`,{children:`EXECUTION TRACE`}),(0,I.jsx)(`h3`,{children:o?.objective??`当前会话尚未启动持久目标`})]}),(0,I.jsx)(`ol`,{children:s.length===0?(0,I.jsxs)(`li`,{"data-state":`pending`,children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`等待执行计划`}),(0,I.jsx)(`small`,{children:`TaskPlan 出现后会自动同步`})]})]}):s.map(e=>(0,I.jsxs)(`li`,{"data-state":e.status,children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:e.subject}),(0,I.jsxs)(`small`,{children:[e.status,e.result?` · ${e.result}`:``]})]})]},e.id))})]}),(0,I.jsxs)(`aside`,{className:`cockpit-evidence`,children:[(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`small`,{children:`目标状态`}),(0,I.jsx)(`b`,{"data-phase":o?.phase,children:o?.phase??`idle`}),(0,I.jsx)(`p`,{children:o?`${o.status} · worker ${o.workerRounds} · verify ${o.verifyRounds}`:`使用 /goal 启动带验证的长期任务`}),o&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`textarea`,{className:`cockpit-goal-editor`,value:i,onChange:e=>a(e.target.value),"aria-label":`继续目标`}),(0,I.jsxs)(`div`,{className:`cockpit-goal-actions`,children:[e.activeSession?.busy&&(0,I.jsx)(`button`,{onClick:()=>void window.flavorDesktop.interrupt(),children:`安全暂停`}),(0,I.jsx)(`button`,{disabled:!i.trim(),onClick:()=>t(`/goal ${i.trim()}`),children:`以编辑目标继续`})]})]})]}),(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`small`,{children:`协作 Agent`}),c.length===0?(0,I.jsx)(`p`,{children:`没有活跃子 Agent`}):c.map(([e,t])=>(0,I.jsxs)(`div`,{className:`cockpit-row`,children:[(0,I.jsx)(`code`,{children:e}),(0,I.jsx)(`span`,{"data-state":t,children:t})]},e))]}),(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`small`,{children:`后台作业`}),e.jobs.length===0?(0,I.jsx)(`p`,{children:`没有后台作业`}):e.jobs.map(e=>(0,I.jsxs)(`div`,{className:`cockpit-row`,children:[(0,I.jsx)(`code`,{children:e.label}),(0,I.jsx)(`span`,{"data-state":e.state,children:e.state})]},e.id))]}),o&&o.evidenceRounds.length>0&&(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`small`,{children:`验证证据`}),o.evidenceRounds.slice(-3).reverse().map(e=>(0,I.jsxs)(`div`,{className:`cockpit-evidence-round`,children:[(0,I.jsxs)(`b`,{children:[`ROUND `,e.round]}),(0,I.jsx)(`p`,{children:e.hostVerification?.summary??`workspace ${e.workspaceDiffHash.slice(0,10)}`}),(0,I.jsx)(`span`,{"data-passed":e.hostVerification?.passed,children:e.hostVerification===void 0?`workspace evidence`:e.hostVerification.passed?`passed`:`failed`})]},e.round))]}),o&&o.lastGaps.length>0&&(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`small`,{children:`验证缺口`}),o.lastGaps.map((e,t)=>(0,I.jsx)(`p`,{className:`cockpit-gap`,children:e.description},t))]})]})]})}function _d({onError:e}){let[t,n]=(0,_.useState)({leafId:null,nodes:[]}),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(!1),s=()=>window.flavorDesktop.historySnapshot().then(n).catch(t=>e(Dd(t)));(0,_.useEffect)(()=>{s()},[]);let c=async t=>{o(!0);try{await t(),await s()}catch(t){e(Dd(t))}finally{o(!1)}},l=od(t.nodes);return(0,I.jsxs)(`div`,{className:`timeline-layout`,children:[(0,I.jsxs)(`section`,{className:`timeline-canvas`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`small`,{children:`SESSION TREE`}),(0,I.jsxs)(`h3`,{children:[t.nodes.length,` 个可恢复节点`]})]}),(0,I.jsx)(`ol`,{children:l.map(({node:e,depth:n})=>(0,I.jsxs)(`li`,{className:`timeline-node`,style:{paddingLeft:n*26},"data-depth":n,"data-current":e.id===t.leafId,children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:e.prompt||e.id}),(0,I.jsxs)(`small`,{children:[new Date(e.createdAt).toLocaleString(),` · `,e.checkpointId]})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{disabled:a,onClick:()=>void c(()=>window.flavorDesktop.rewindHistory(e.id)),children:`回到这里`}),(0,I.jsx)(`button`,{disabled:a,onClick:()=>{window.confirm(`从这个节点建立新分支?当前上下文将切换。`)&&c(()=>window.flavorDesktop.forkHistory(e.id))},children:`Fork`})]})]},e.id))})]}),(0,I.jsxs)(`aside`,{className:`timeline-actions`,children:[(0,I.jsx)(`h3`,{children:`建立安全点`}),(0,I.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`例如:重构前`}),(0,I.jsx)(`button`,{disabled:a,onClick:()=>void c(()=>window.flavorDesktop.createCheckpoint(r||void 0)),children:`创建 checkpoint`}),(0,I.jsx)(`button`,{disabled:a,onClick:()=>void c(()=>window.flavorDesktop.unrevertHistory()),children:`撤销上次回退`})]})]})}function vd({onError:e,onDiscover:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),o=n.find(e=>e.id===i),s=(e,t)=>{let n=e.filter(e=>e.state!==`closed`);r(n),a(e=>cd(t??e,n))},c=async e=>s(await window.flavorDesktop.listTerminals(),e);(0,_.useEffect)(()=>{c().catch(t=>e(Dd(t)))},[]);let l=async()=>{try{let e=await window.flavorDesktop.openTerminal();await c(e.id)}catch(t){e(Dd(t))}},u=async()=>{if(i!==void 0)try{await window.flavorDesktop.closeTerminal(i),await c()}catch(t){e(Dd(t))}};return(0,I.jsxs)(`div`,{className:`terminal-layout`,children:[(0,I.jsxs)(`aside`,{children:[(0,I.jsx)(`button`,{className:`primary`,onClick:()=>void l(),children:`+ 新终端`}),n.map(e=>(0,I.jsxs)(`button`,{"data-active":e.id===i,onClick:()=>a(e.id),title:e.shell,children:[(0,I.jsx)(`strong`,{children:sd(e.shell)}),(0,I.jsxs)(`small`,{children:[e.state,` · `,e.id]})]},e.id))]}),(0,I.jsxs)(`main`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`span`,{title:o?.cwd,children:o?.cwd??`尚未打开终端`}),o&&(0,I.jsx)(`button`,{onClick:()=>void u(),children:`关闭终端`})]}),o===void 0?(0,I.jsxs)(`div`,{className:`terminal-empty`,children:[(0,I.jsx)(`b`,{children:`没有打开终端`}),(0,I.jsx)(`span`,{children:`新建终端后,直接在终端区域输入和操作。`})]}):(0,I.jsx)(_.Suspense,{fallback:(0,I.jsxs)(`div`,{className:`terminal-empty`,children:[(0,I.jsx)(`b`,{children:`正在连接终端`}),(0,I.jsx)(`span`,{children:`正在加载交互渲染器…`})]}),children:(0,I.jsx)(md,{terminal:o,onError:e,onDiscover:t},o.id)})]})]})}function $({onError:e,onCompose:t}){let[n,r]=(0,_.useState)(`working`),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(),[f,p]=(0,_.useState)(),m=(0,_.useMemo)(()=>td(o),[o]),h=m.find(e=>e.path===u)??m[0],g=async()=>{l(!0);try{let e=await window.flavorDesktop.gitReview(n,i||void 0);s(e);let t=td(e);d(t[0]?.path),p(t[0]?.hunks[0]?.id)}catch(t){e(Dd(t))}finally{l(!1)}};return(0,_.useEffect)(()=>{if(n===`commit`||n===`base`){s(``),d(void 0),p(void 0);return}g()},[n]),(0,I.jsxs)(`div`,{className:`review-layout`,children:[(0,I.jsxs)(`aside`,{className:`review-scope`,children:[(0,I.jsx)(`small`,{children:`DIFF SCOPE`}),[`working`,`staged`,`last-turn`,`commit`,`base`].map(e=>(0,I.jsx)(`button`,{"data-active":n===e,onClick:()=>r(e),children:e},e)),(n===`commit`||n===`base`)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:n===`base`?`main / origin/main`:`commit SHA`}),(0,I.jsx)(`button`,{onClick:()=>void g(),children:`载入范围`})]})]}),(0,I.jsxs)(`section`,{className:`review-files`,"aria-label":`变更文件`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`strong`,{children:`文件`}),(0,I.jsx)(`span`,{children:m.length})]}),m.map(e=>(0,I.jsxs)(`button`,{"data-active":e.path===h?.path,onClick:()=>{d(e.path),p(e.hunks[0]?.id)},children:[(0,I.jsx)(`strong`,{children:e.path.split(`/`).at(-1)}),(0,I.jsx)(`small`,{children:e.path}),(0,I.jsxs)(`span`,{children:[(0,I.jsxs)(`b`,{children:[`+`,e.additions]}),(0,I.jsxs)(`em`,{children:[`-`,e.deletions]})]})]},e.path))]}),(0,I.jsxs)(`main`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:h?.path??n}),(0,I.jsxs)(`span`,{children:[h?.hunks.length??0,` hunks`]})]}),(0,I.jsx)(`button`,{onClick:()=>t(`/review 请审查 ${n}${i?` ${i}`:``}${h?` 中的 ${h.path}`:``},按 P0/P1/P2 分级输出发现,必须给出文件行号和触发场景。`),children:`交给 Agent 审查`})]}),h&&h.hunks.length>0&&(0,I.jsx)(`nav`,{className:`review-hunks`,"aria-label":`Hunk 导航`,children:h.hunks.map((e,t)=>(0,I.jsxs)(`button`,{"data-active":f===e.id,onClick:()=>p(e.id),children:[`H`,t+1,(0,I.jsx)(`span`,{children:e.header})]},e.id))}),(0,I.jsx)(yd,{file:h,activeHunk:f,loading:c,empty:o}),(0,I.jsxs)(`footer`,{className:`review-priority-legend`,children:[(0,I.jsx)(`span`,{"data-priority":`0`,children:`P0 阻断`}),(0,I.jsx)(`span`,{"data-priority":`1`,children:`P1 高风险`}),(0,I.jsx)(`span`,{"data-priority":`2`,children:`P2 一般`}),(0,I.jsx)(`small`,{children:`审查结果将在对话中返回,并携带文件行号。`})]})]})]})}function yd({file:e,activeHunk:t,loading:n,empty:r}){return n?(0,I.jsx)(`div`,{className:`review-empty`,children:`正在生成 diff…`}):e===void 0?(0,I.jsx)(`div`,{className:`review-empty`,children:r||`此范围没有差异`}):(0,I.jsx)(`div`,{className:`review-code`,role:`region`,"aria-label":`${e.path} 差异`,children:(0,I.jsx)(`pre`,{children:e.lines.map((n,r)=>{let i=e.hunks.find(e=>r>=e.start&&r<e.end);return(0,I.jsx)(`code`,{"data-kind":n.startsWith(`+++`)||n.startsWith(`---`)?`meta`:n.startsWith(`+`)?`addition`:n.startsWith(`-`)?`deletion`:n.startsWith(`@@`)?`hunk`:`context`,"data-active":i?.id===t,children:n||` `},r)})})})}function bd({onError:e,suggestions:t}){let[n,r]=(0,_.useState)(`http://localhost:3000`),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(0),c=async()=>{try{a(await window.flavorDesktop.validatePreviewUrl(n))}catch(t){e(Dd(t))}};return(0,I.jsxs)(`div`,{className:`preview-layout`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()}}),(0,I.jsx)(`button`,{onClick:()=>void c(),children:`打开`}),(0,I.jsx)(`button`,{disabled:!i,onClick:()=>s(e=>e+1),children:`刷新`}),(0,I.jsx)(`button`,{disabled:!i,onClick:()=>{i&&window.flavorDesktop.openPreviewUrl(i)},children:`外部打开`}),(0,I.jsx)(`button`,{disabled:!i,onClick:()=>{i&&navigator.clipboard.writeText(i)},children:`复制`})]}),t.length>0&&(0,I.jsxs)(`div`,{className:`preview-suggestions`,children:[`检测到:`,t.map(t=>(0,I.jsx)(`button`,{onClick:()=>{r(t),window.flavorDesktop.validatePreviewUrl(t).then(a).catch(t=>e(Dd(t)))},children:t},t))]}),i?(0,I.jsx)(`iframe`,{src:i,title:`本地应用预览`,sandbox:`allow-forms allow-modals allow-popups allow-scripts allow-same-origin`},o):(0,I.jsxs)(`div`,{className:`preview-empty`,children:[(0,I.jsx)(`strong`,{children:`安全的本地预览`}),(0,I.jsx)(`p`,{children:`仅允许 localhost、127.0.0.1 和 ::1 的 HTTP(S) 地址。`})]})]})}function xd({snapshot:e,onError:t}){let[n,r]=(0,_.useState)();return(0,_.useEffect)(()=>{window.flavorDesktop.inspectWorkbench().then(r).catch(e=>t(Dd(e)))},[]),(0,I.jsxs)(`div`,{className:`context-grid`,children:[(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`small`,{children:`RUNTIME`}),(0,I.jsx)(`h3`,{children:`上下文 Epoch`})]}),(0,I.jsxs)(`dl`,{children:[(0,I.jsx)(`dt`,{children:`Permission`}),(0,I.jsx)(`dd`,{children:e.activeSession?.permissionMode??`—`}),(0,I.jsx)(`dt`,{children:`Model`}),(0,I.jsx)(`dd`,{children:e.activeSession?.mainModel??`—`}),(0,I.jsx)(`dt`,{children:`Checkout`}),(0,I.jsx)(`dd`,{children:e.activeSession?.workingDirectory??e.workspace??`—`})]}),n?.context?.epoch!==void 0&&(0,I.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(n.context.epoch,null,2)}),n?.context?.visibility.map((e,t)=>(0,I.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(e,null,2)},t)),n?.context?.usage.map((e,t)=>(0,I.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(e,null,2)},`usage-${t}`)),e.diagnostics.map((e,t)=>(0,I.jsx)(`p`,{className:`context-record`,children:e},`diag-${t}`))]}),(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`small`,{children:`INSTRUCTIONS`}),(0,I.jsx)(`h3`,{children:`生效的项目指令`})]}),n?.instructions.map(e=>(0,I.jsxs)(`details`,{children:[(0,I.jsx)(`summary`,{children:e.name}),(0,I.jsx)(`pre`,{children:e.content})]},e.path))]}),(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`small`,{children:`SAFETY`}),(0,I.jsx)(`h3`,{children:`权限规则与审计`})]}),n?.permissionFiles.map(e=>(0,I.jsxs)(`details`,{children:[(0,I.jsxs)(`summary`,{children:[e.tier,` · `,e.path]}),(0,I.jsx)(`pre`,{children:e.content})]},e.path)),n?.audit.slice(0,30).map((e,t)=>(0,I.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(e,null,2)},t))]})]})}function Sd({onError:e,onCompose:t}){let[n,r]=(0,_.useState)(),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(),[u,d]=(0,_.useState)(),[f,p]=(0,_.useState)(2),[m,h]=(0,_.useState)(!1);(0,_.useEffect)(()=>{window.flavorDesktop.astStatus().then(r).catch(t=>e(Dd(t)))},[]);let g=async()=>{try{s(await window.flavorDesktop.astSearch(i))}catch(t){e(Dd(t))}},v=async(t,n=f)=>{l(t),h(!0);try{d(await window.flavorDesktop.astRelations(t.id,n))}catch(t){e(Dd(t))}finally{h(!1)}},y=c===void 0||u===void 0?void 0:ad(c,u);return(0,I.jsxs)(`div`,{className:`ast-layout`,children:[(0,I.jsxs)(`aside`,{className:`ast-symbols`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`SYMBOL INDEX`}),(0,I.jsx)(`strong`,{children:`代码索引`})]}),(0,I.jsx)(`span`,{"data-ready":n?.available,children:n?.available?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`b`,{children:n.nodes}),` symbols`,(0,I.jsx)(`br`,{}),(0,I.jsx)(`b`,{children:n.edges}),` edges`]}):`尚未建立索引`})]}),(0,I.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`⌕`}),(0,I.jsx)(`input`,{"aria-label":`搜索代码符号`,value:i,onChange:e=>a(e.target.value),placeholder:`函数、类型或模块`}),(0,I.jsx)(`button`,{children:`搜索`})]}),(0,I.jsx)(`div`,{className:`ast-symbol-list`,children:o.length===0?(0,I.jsx)(`p`,{children:n?.available===!1?`项目尚未建立代码索引`:`输入名称,定位代码中的关键符号`}):o.map(e=>(0,I.jsxs)(`button`,{"data-active":e.id===c?.id,onClick:()=>void v(e),children:[(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsx)(`em`,{children:e.kind})]}),(0,I.jsxs)(`small`,{children:[e.filePath,`:`,e.startLine]})]},e.id))})]}),(0,I.jsxs)(`main`,{className:`ast-graph-stage`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`RELATION MAP`}),(0,I.jsx)(`h3`,{children:c?.qualifiedName??`代码关系浏览器`}),(0,I.jsx)(`code`,{children:c?`${c.filePath}:${c.startLine}-${c.endLine}`:`搜索并选择一个符号作为图中心`})]}),(0,I.jsxs)(`div`,{className:`ast-depth`,"aria-label":`影响深度`,children:[(0,I.jsx)(`span`,{children:`影响深度`}),[1,2,3,4].map(e=>(0,I.jsx)(`button`,{"aria-label":`${e} 层影响深度`,"data-active":f===e,onClick:()=>{p(e),c&&v(c,e)},children:e},e))]})]}),m?(0,I.jsx)(`div`,{className:`ast-graph-empty`,children:`正在展开关系图…`}):y?(0,I.jsx)(Cd,{graph:y,selected:c,onSelect:e=>void v(e)}):(0,I.jsxs)(`div`,{className:`ast-graph-empty`,children:[(0,I.jsx)(`strong`,{children:`从一个符号开始`}),(0,I.jsx)(`p`,{children:`搜索函数、类或模块,在同一张图上查看调用者、被调用项和多跳影响范围。`})]})]}),(0,I.jsxs)(`aside`,{className:`ast-inspector`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`SYMBOL INSPECTOR`}),(0,I.jsx)(`h3`,{children:c?.name??`未选择符号`})]}),c&&(0,I.jsx)(`span`,{children:c.kind})]}),c?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`dl`,{children:[(0,I.jsx)(`dt`,{children:`语言`}),(0,I.jsx)(`dd`,{children:c.language}),(0,I.jsx)(`dt`,{children:`位置`}),(0,I.jsxs)(`dd`,{children:[c.filePath,`:`,c.startLine]}),c.signature&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`dt`,{children:`签名`}),(0,I.jsx)(`dd`,{children:c.signature})]})]}),(0,I.jsxs)(`button`,{className:`ast-compose`,onClick:()=>t(`请查看 @${c.filePath}#L${c.startLine}-L${c.endLine} 中的 ${c.qualifiedName}`),children:[(0,I.jsx)(`span`,{children:`加入输入框`}),(0,I.jsx)(`b`,{"aria-hidden":`true`,children:`↗`})]}),(0,I.jsx)(wd,{title:`Callers`,nodes:u?.callers??[],onSelect:e=>void v(e)}),(0,I.jsx)(wd,{title:`Callees`,nodes:u?.callees??[],onSelect:e=>void v(e)}),(0,I.jsx)(wd,{title:`Impact`,nodes:u?.impact??[],onSelect:e=>void v(e)})]}):(0,I.jsx)(`p`,{className:`ast-inspector-empty`,children:`选择一个符号后,这里会显示源码位置和完整关系。`})]})]})}function Cd({graph:e,selected:t,onSelect:n}){let r={x:0,y:0,scale:1},[i,a]=(0,_.useState)(r),[o,s]=(0,_.useState)({width:0,height:0}),[c,l]=(0,_.useState)(!1),u=(0,_.useRef)(null),d=(0,_.useRef)(void 0),f=new Map(e.nodes.map(e=>[e.id,e]));(0,_.useEffect)(()=>{a(r)},[t.id]),(0,_.useEffect)(()=>{let e=u.current;if(e===null)return;let t=()=>{let t=e.getBoundingClientRect();s({width:t.width,height:t.height})};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let p=(e,t)=>{let n=u.current?.getBoundingClientRect(),r=t??{x:(n?.width??0)/2,y:(n?.height??0)/2};a(t=>rd(t,r,e))},m=e=>{d.current?.pointerId===e.pointerId&&(d.current=void 0,l(!1),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,I.jsxs)(`div`,{ref:u,className:`ast-graph`,"data-dragging":c,role:`region`,"aria-label":`${t.name} 代码关系图,可拖动和滚轮缩放`,onWheel:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();p(i.scale*Math.exp(-e.deltaY*.0014),{x:e.clientX-t.left,y:e.clientY-t.top})},onPointerDown:e=>{e.button!==0||e.target.closest(`button`)||(e.currentTarget.setPointerCapture(e.pointerId),d.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY},l(!0))},onPointerMove:e=>{let t=d.current;if(t?.pointerId!==e.pointerId)return;let n=e.clientX-t.x,r=e.clientY-t.y;d.current={...t,x:e.clientX,y:e.clientY},a(e=>({...e,x:e.x+n,y:e.y+r}))},onPointerUp:m,onPointerCancel:m,children:[(0,I.jsx)(`div`,{className:`ast-graph-viewport`,style:{transform:`translate(${i.x}px, ${i.y}px) scale(${i.scale})`},children:(0,I.jsx)(`svg`,{viewBox:`0 0 100 100`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:e.edges.map((e,t)=>{let n=f.get(e.from),r=f.get(e.to);if(!n||!r)return null;let i=(n.x+r.x)/2;return(0,I.jsx)(`path`,{"data-kind":e.kind,d:`M ${n.x} ${n.y} C ${i} ${n.y}, ${i} ${r.y}, ${r.x} ${r.y}`},`${e.from}-${e.to}-${t}`)})})}),e.nodes.map(e=>{let t=id(e,i,o);return(0,I.jsxs)(`button`,{className:`ast-graph-node`,"data-role":e.role,style:{left:t.x,top:t.y,visibility:o.width>0?`visible`:`hidden`},onClick:()=>n(e),title:`${e.qualifiedName}\n${e.filePath}:${e.startLine}`,children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsx)(`small`,{children:e.role===`impact`?`hop ${e.hop}`:e.kind})]})]},e.id)}),(0,I.jsxs)(`div`,{className:`ast-graph-hint`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`↔`}),` 拖动平移 `,(0,I.jsx)(`i`,{}),` 滚轮缩放`]}),(0,I.jsxs)(`div`,{className:`ast-graph-controls`,"aria-label":`画布缩放`,children:[(0,I.jsx)(`button`,{"aria-label":`放大`,onClick:()=>p(i.scale*1.2),children:`+`}),(0,I.jsxs)(`span`,{children:[Math.round(i.scale*100),`%`]}),(0,I.jsx)(`button`,{"aria-label":`缩小`,onClick:()=>p(i.scale/1.2),children:`−`}),(0,I.jsx)(`button`,{className:`ast-graph-reset`,"aria-label":`复位画布`,onClick:()=>a(r),children:`复位`})]}),(0,I.jsxs)(`div`,{className:`ast-graph-legend`,children:[(0,I.jsx)(`span`,{"data-kind":`caller`,children:`调用者`}),(0,I.jsx)(`span`,{"data-kind":`origin`,children:`中心符号`}),(0,I.jsx)(`span`,{"data-kind":`callee`,children:`被调用`}),(0,I.jsx)(`span`,{"data-kind":`impact`,children:`影响范围`})]})]})}function wd({title:e,nodes:t,onSelect:n}){return(0,I.jsxs)(`section`,{className:`ast-relation`,children:[(0,I.jsxs)(`h4`,{children:[e,(0,I.jsx)(`span`,{children:t.length})]}),t.length===0?(0,I.jsx)(`p`,{children:`没有关系记录`}):t.slice(0,20).map(e=>(0,I.jsxs)(`button`,{onClick:()=>n(e),children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsxs)(`code`,{children:[e.filePath,`:`,e.startLine]})]},e.id))]})}function Td({onError:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(),[d,f]=(0,_.useState)(),[p,m]=(0,_.useState)(),[h,g]=(0,_.useState)(),v=()=>window.flavorDesktop.listPals().then(e=>{f(void 0),n(e),i(t=>e.some(e=>e.alias===t)?t:e[0]?.alias)}).catch(e=>{n([]),f(Dd(e))});(0,_.useEffect)(()=>{v();let e=window.setInterval(v,4e3);return()=>window.clearInterval(e)},[]);let y=async(t,n,r)=>{m(t),g(void 0);try{r(await n())}catch(t){e(Dd(t))}finally{m(void 0)}},b=t.find(e=>e.alias===r),x=b?.alias,S=typeof l==`object`&&l?l:void 0,C=typeof S?.coWorkId==`string`?S.coWorkId:void 0,w=typeof S?.status==`string`?S.status:`created`,ee=e=>{x===void 0||!a.trim()||y(e,()=>window.flavorDesktop.sendPalMessage(x,a.trim(),e),()=>{o(``),g(e===`chat`?`消息已发送给 ${x}`:`任务已委托给 ${x}`)})};return(0,I.jsxs)(`div`,{className:`pals-layout`,children:[(0,I.jsxs)(`aside`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`LOCAL BROKER`}),(0,I.jsx)(`h3`,{children:`在线 Pals`})]}),(0,I.jsx)(`span`,{children:t.length})]}),d===void 0?t.length===0&&(0,I.jsxs)(`div`,{className:`pals-list-empty`,children:[(0,I.jsx)(`b`,{children:`等待其他实例`}),(0,I.jsx)(`p`,{children:`同一台设备上的 Flavor 实例上线后会出现在这里。`})]}):(0,I.jsxs)(`div`,{className:`pals-unavailable`,children:[(0,I.jsx)(`strong`,{children:`正在恢复本地协作`}),(0,I.jsx)(`p`,{children:`broker 暂时不可用,工作台会自动重试。`}),(0,I.jsx)(`button`,{onClick:()=>void v(),children:`立即重试`})]}),(0,I.jsx)(`div`,{className:`pals-list`,children:t.map(e=>(0,I.jsxs)(`button`,{"data-active":r===e.alias,onClick:()=>{i(e.alias),g(void 0)},children:[(0,I.jsx)(`span`,{className:`pal-presence`,children:(0,I.jsx)(`i`,{})}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:e.alias}),(0,I.jsx)(`small`,{title:e.projectPath??e.id,children:e.projectPath??e.id})]}),(0,I.jsx)(`em`,{children:`在线`})]},e.id))})]}),(0,I.jsxs)(`main`,{children:[(0,I.jsxs)(`header`,{className:`pals-channel-header`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`CO-WORK CHANNEL`}),(0,I.jsx)(`h3`,{children:x??`没有选中 Pal`}),(0,I.jsx)(`p`,{title:b?.projectPath,children:b?.projectPath??`从左侧选择一个在线实例后即可发送消息、委托任务或共同执行目标。`})]}),(0,I.jsxs)(`span`,{"data-online":b!==void 0,children:[(0,I.jsx)(`i`,{}),b===void 0?`等待选择`:`连接正常`]})]}),(0,I.jsxs)(`div`,{className:`pals-compose-grid`,children:[(0,I.jsxs)(`section`,{className:`pal-compose-card`,"data-kind":`message`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`span`,{children:`MESSAGE`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{children:`发消息或委托任务`}),(0,I.jsx)(`p`,{children:`同一段内容,可以即时沟通,也可以交给对方独立执行。`})]})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`内容`}),(0,I.jsx)(`textarea`,{"aria-label":`消息或任务内容`,value:a,onChange:e=>o(e.target.value),placeholder:`写下背景、期望结果和必要约束…`})]}),(0,I.jsxs)(`footer`,{children:[(0,I.jsx)(`small`,{children:a.length===0?`建议说明交付结果`:`${a.length} 字符`}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`button`,{disabled:p!==void 0||x===void 0||!a.trim(),onClick:()=>ee(`chat`),children:[(0,I.jsx)(`b`,{children:p===`chat`?`发送中…`:`发送 Chat`}),(0,I.jsx)(`span`,{children:`直接沟通`})]}),(0,I.jsxs)(`button`,{disabled:p!==void 0||x===void 0||!a.trim(),onClick:()=>ee(`task`),children:[(0,I.jsx)(`b`,{children:p===`task`?`委托中…`:`委托 Task`}),(0,I.jsx)(`span`,{children:`异步执行`})]})]})]})]}),(0,I.jsxs)(`section`,{className:`pal-compose-card`,"data-kind":`cowork`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`span`,{children:`CO-WORK`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{children:`共同完成一个目标`}),(0,I.jsx)(`p`,{children:`双方先共同规划,再持续同步执行状态与结果。`})]})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`共同目标`}),(0,I.jsx)(`textarea`,{"aria-label":`共同目标`,value:s,onChange:e=>c(e.target.value),placeholder:`描述目标、完成标准和双方需要协作的部分…`})]}),(0,I.jsxs)(`footer`,{children:[(0,I.jsx)(`small`,{children:s.length===0?`适合跨实例并行工作`:`${s.length} 字符`}),(0,I.jsxs)(`button`,{className:`primary`,disabled:p!==void 0||x===void 0||!s.trim(),onClick:()=>{x===void 0||!s.trim()||y(`cowork`,()=>window.flavorDesktop.startCoWork(x,s.trim()),e=>{u(e),c(``),g(`已与 ${x} 建立共同目标`)})},children:[(0,I.jsx)(`b`,{children:p===`cowork`?`建立中…`:`开始 Co-work`}),(0,I.jsx)(`span`,{children:`共同规划并执行`})]})]})]})]}),h!==void 0&&(0,I.jsxs)(`div`,{className:`pals-notice`,children:[(0,I.jsx)(`i`,{}),` `,h]}),l!==void 0&&(0,I.jsxs)(`section`,{className:`cowork-state`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`LIVE CO-WORK`}),(0,I.jsx)(`strong`,{children:`最新协作状态`})]}),(0,I.jsx)(`span`,{"data-status":w,children:w}),(0,I.jsxs)(`nav`,{children:[(0,I.jsx)(`button`,{disabled:p!==void 0,onClick:()=>void y(`refresh`,()=>window.flavorDesktop.coWorkStatus(C),u),children:`刷新状态`}),C&&(0,I.jsx)(`button`,{className:`danger`,disabled:p!==void 0,onClick:()=>{window.confirm(`取消这个 Co-work?`)&&y(`cancel`,()=>window.flavorDesktop.cancelCoWork(C,`cancelled from desktop workbench`),e=>{u(e),g(`协作已取消`)})},children:`取消协作`})]})]}),(0,I.jsxs)(`details`,{children:[(0,I.jsx)(`summary`,{children:`查看原始协作数据`}),(0,I.jsx)(`pre`,{children:JSON.stringify(l,null,2)})]})]})]})]})}function Ed({snapshot:e,onError:t}){let[n,r]=(0,_.useState)([]),i=()=>window.flavorDesktop.listWorktrees().then(r).catch(e=>t(Dd(e)));return(0,_.useEffect)(()=>{i()},[]),(0,I.jsxs)(`div`,{className:`worktree-pane`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`TASK ISOLATION`}),(0,I.jsx)(`h3`,{children:`工作树`}),(0,I.jsx)(`p`,{children:`新任务可在独立分支中运行,不改动当前检出。`})]}),(0,I.jsxs)(`span`,{children:[n.length,` active`]})]}),n.length===0?(0,I.jsx)(`div`,{className:`manager-empty`,children:`还没有隔离工作树。新建任务时选择“隔离工作树”。`}):(0,I.jsx)(`div`,{className:`worktree-list`,children:n.map(n=>(0,I.jsxs)(`article`,{"data-current":e.activeSession?.worktreeId===n.id,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`i`,{}),(0,I.jsx)(`strong`,{children:n.branch}),(0,I.jsx)(`small`,{children:n.path})]}),(0,I.jsx)(`span`,{"data-dirty":n.dirty,children:n.merged?`merged`:n.dirty?`dirty`:`clean`}),(0,I.jsxs)(`div`,{className:`worktree-actions`,children:[(0,I.jsx)(`button`,{disabled:n.dirty||n.merged,onClick:()=>{window.confirm(`将 ${n.branch} 合并回当前项目分支?`)&&window.flavorDesktop.mergeWorktree(n.id).then(i).catch(e=>t(Dd(e)))},children:`合并交付`}),(0,I.jsx)(`button`,{onClick:()=>{window.confirm(`移除工作树 ${n.branch}?${n.dirty?`存在未提交变更,将强制移除。`:`分支会保留。`}`)&&window.flavorDesktop.removeWorktree(n.id,n.dirty).then(i).catch(e=>t(Dd(e)))},children:`移除并保留分支`})]})]},n.id))})]})}function Dd(e){return e instanceof Error?e.message:String(e)}function Od(e){return e.match(/https?:\/\/(?:localhost|127\.0\.0\.1|\[?::1\]?)(?::\d{1,5})?(?:\/[^\s"'<>]*)?/gi)??[]}function kd(e,t,n=Date.now()){return{task:e,framework:t,startedAt:n,updatedAt:n,phase:`analyzing`,comparisonCycle:0,activity:[{id:`import`,label:`HTML 设计稿已导入`,state:`completed`,startedAt:n,completedAt:n}]}}function Ad(e,t,n=Date.now()){if(t.type===`model-start`){let r=e.phase===`analyzing`?`分析设计并规划实现`:e.phase===`building`?`检查实现并规划下一步`:`分析评测结果`;return Pd(e,{id:`model:${t.id}`,label:r,state:`running`,startedAt:n},n)}if(t.type===`model-end`)return Fd(e,`model:${t.id}`,`completed`,n);if(t.type===`tool-start`){let r=Md(t.name,e.phase),i=Nd(t.name,t.label,t.hint);return Pd({...e,phase:r},{id:`tool:${t.id}`,label:i,state:`running`,startedAt:n,...t.hint===void 0||t.hint===t.label?{}:{detail:Id(t.hint,72)}},n)}if(t.type===`tool-end`){let r=t.result.ok?`completed`:`failed`,i=e.activity.find(e=>e.id===`tool:${t.id}`);return i===void 0?Pd(e,{id:`tool:${t.id}`,label:Nd(t.name,t.label,t.hint),state:r,startedAt:n,completedAt:n},n):Fd(e,i.id,r,n)}return t.type===`model-retry`?Pd(e,{id:`retry:${t.attempt}`,label:`模型请求重试 ${t.attempt}/${t.maxAttempts}`,detail:`${Math.ceil(t.delayMs/1e3)} 秒后继续`,state:`info`,startedAt:n,completedAt:n},n):t.type===`warning`?Pd(e,{id:`warning:${n}`,label:Id(t.message,96),state:`info`,startedAt:n,completedAt:n},n):t.type===`error`?Pd(e,{id:`error:${n}`,label:Id(t.error.message,96),state:`failed`,startedAt:n,completedAt:n},n):e}function jd(e,t,n=Date.now()){if(t.task!==e.task)return e;let r=`engine:${t.cycle}:${t.stage}`,i=e.activity.find(e=>e.id===r);return Pd({...e,phase:`evaluating`,comparisonCycle:t.cycle},{id:r,label:t.message,state:t.state,startedAt:i?.startedAt??n,...t.state===`running`?{}:{completedAt:n},...t.cached===!0?{detail:`已复用缓存`}:{}},n)}function Md(e,t){return e===`D2cCompare`?`evaluating`:[`Write`,`Edit`,`ApplyPatch`,`Mkdir`,`Copy`,`Move`,`Shell`,`Bash`,`Command`,`Exec`].includes(e)?`building`:t}function Nd(e,t,n){let r=Id(t??n??``,60),i=r===``?``:` ${r}`;return[`Read`,`Glob`,`Grep`,`Search`,`List`].includes(e)?`读取${i||`设计与项目文件`}`:e===`Write`?`创建${i||`前端文件`}`:e===`Edit`||e===`ApplyPatch`?`调整${i||`前端实现`}`:e===`Mkdir`?`创建${i||`项目目录`}`:[`Shell`,`Bash`,`Command`,`Exec`].includes(e)?`运行${i||`项目命令`}`:e===`D2cCompare`?`启动视觉评测`:`${e}${i}`}function Pd(e,t,n){let r=e.activity.findIndex(e=>e.id===t.id),i=[...e.activity];return r<0?i.push(t):i[r]=t,{...e,updatedAt:n,activity:i.slice(-12)}}function Fd(e,t,n,r){let i=e.activity.find(e=>e.id===t);return i===void 0?e:Pd(e,{...i,state:n,completedAt:r},r)}function Id(e,t){let n=e.replaceAll(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}var Ld={sessions:[],diagnostics:[],models:[],jobs:[]},Rd=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`],zd=Z.map(e=>({name:e,description:Rl[e]})),Bd=5,Vd=5*1024*1024,Hd=20*1024*1024,Ud=new Set([`image/png`,`image/jpeg`,`image/webp`]);function Wd(e,t){return[e.trim(),...t.map((e,t)=>`[Image #${t+1}]`)].filter(Boolean).join(`
|
|
150
|
+
`);if(n.at(-1)===``&&n.pop(),t&&!n.some(e=>e.startsWith(`@@`)))return n.map((e,t)=>({kind:`addition`,marker:`+`,text:e,newNumber:t+1}));let r=0,i=0,a=!1;return n.map(e=>{let t=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@(.*)$/.exec(e);if(t!==null)return r=Number(t[1]),i=Number(t[2]),a=!0,{kind:`hunk`,marker:`@@`,text:t[3]?.trim()??``};if(!a||e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`--- `)||e.startsWith(`+++ `))return{kind:`meta`,marker:``,text:e};if(e.startsWith(`+`)&&!e.startsWith(`+++`))return{kind:`addition`,marker:`+`,text:e.slice(1),newNumber:i++};if(e.startsWith(`-`)&&!e.startsWith(`---`))return{kind:`deletion`,marker:`−`,text:e.slice(1),oldNumber:r++};if(e.startsWith(`\\ No newline`))return{kind:`meta`,marker:``,text:e};let n={kind:`context`,marker:``,text:e.startsWith(` `)?e.slice(1):e,oldNumber:r,newNumber:i};return r+=1,i+=1,n})}function Qu({onClose:e,onReview:t,onError:n}){let[r,i]=(0,_.useState)(Xu),[a,o]=(0,_.useState)(),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(`working`),[d,f]=(0,_.useState)(!0),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(``),v=(0,_.useMemo)(()=>Zu(s,a?.untracked),[s,a?.untracked]),y=v.filter(e=>e.kind===`addition`).length,b=v.filter(e=>e.kind===`deletion`).length,x=r.files.filter(e=>e.staged).length,S=async()=>{try{i(await window.flavorDesktop.gitStatus())}catch(e){n(ed(e))}finally{f(!1)}};(0,_.useEffect)(()=>{S()},[]);let C=async(e,t)=>{m(!0),c(``),u(t);try{c(await window.flavorDesktop.gitDiff(e.path,t===`staged`))}catch(e){let t=ed(e);c(t),n(t)}finally{m(!1)}},w=async e=>{o(e),await C(e,e.unstaged||e.untracked?`working`:`staged`)},ee=async(e,t)=>{if(!(e===`discard`&&!window.confirm(`确定还原 ${t.path}?此操作无法撤销。`)))try{let n=e===`stage`?await window.flavorDesktop.gitStage(t.path):e===`unstage`?await window.flavorDesktop.gitUnstage(t.path):await window.flavorDesktop.gitDiscard(t.path);i(n);let r=n.files.find(e=>e.path===t.path);r===void 0?(o(void 0),c(``)):(o(r),await C(r,r.unstaged||r.untracked?`working`:`staged`))}catch(e){n(ed(e))}},te=async()=>{if(h.trim())try{let e=await window.flavorDesktop.gitCommit(h.trim());i(e.status),g(``),o(void 0),c(``),n(`已提交 ${e.result}`)}catch(e){n(ed(e))}};return(0,I.jsxs)(`section`,{className:`manager-view git-view`,children:[(0,I.jsxs)(`header`,{className:`manager-header git-header`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{className:`git-back`,onClick:e,"aria-label":`返回`,children:`←`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h2`,{children:`Git 变更`}),(0,I.jsx)(`span`,{children:`审阅并整理本次工作区修改`})]})]}),r.repository&&(0,I.jsxs)(`span`,{className:`git-branch`,children:[(0,I.jsx)(`i`,{}),r.branch,(0,I.jsx)(`b`,{children:r.head})]})]}),d?(0,I.jsx)(`p`,{className:`manager-empty`,children:`正在读取工作区…`}):r.repository?(0,I.jsxs)(`div`,{className:`git-layout`,children:[(0,I.jsxs)(`aside`,{className:`git-files`,children:[(0,I.jsxs)(`div`,{className:`git-toolbar`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`变更`}),(0,I.jsx)(`span`,{children:r.files.length})]}),(0,I.jsx)(`button`,{onClick:()=>void S(),title:`重新读取变更`,children:`↻`})]}),r.files.length===0?(0,I.jsxs)(`div`,{className:`git-clean`,children:[(0,I.jsx)(`i`,{children:`✓`}),(0,I.jsx)(`strong`,{children:`工作区干净`}),(0,I.jsx)(`span`,{children:`没有需要审阅的修改`})]}):r.files.map(e=>{let t=$u(e.path),n=e.untracked?`U`:e.index===`A`?`A`:e.index===`D`||e.worktree===`D`?`D`:`M`;return(0,I.jsxs)(`div`,{className:`git-file-row`,"data-active":a?.path===e.path,children:[(0,I.jsxs)(`button`,{className:`git-file-name`,onClick:()=>void w(e),title:e.path,children:[(0,I.jsx)(`code`,{"data-state":n,children:n}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`b`,{children:t.name}),t.directory&&(0,I.jsx)(`small`,{children:t.directory})]})]}),(0,I.jsxs)(`div`,{className:`git-file-actions`,children:[e.staged?(0,I.jsx)(`button`,{onClick:()=>void ee(`unstage`,e),children:`取消暂存`}):(0,I.jsx)(`button`,{className:`stage-action`,onClick:()=>void ee(`stage`,e),children:`暂存`}),(e.unstaged||e.untracked)&&(0,I.jsx)(`button`,{className:`danger-text`,onClick:()=>void ee(`discard`,e),children:`还原`})]})]},e.path)})]}),(0,I.jsx)(`article`,{className:`git-diff`,children:a===void 0?(0,I.jsxs)(`div`,{className:`git-diff-empty`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{children:`−`}),(0,I.jsx)(`span`,{children:`+`})]}),(0,I.jsx)(`strong`,{children:`选择文件查看差异`}),(0,I.jsx)(`p`,{children:`逐行审阅修改,然后决定暂存或还原。`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`header`,{className:`git-diff-header`,children:[(0,I.jsxs)(`div`,{className:`git-diff-title`,children:[(0,I.jsx)(`span`,{children:$u(a.path).directory||`项目根目录`}),(0,I.jsx)(`strong`,{children:$u(a.path).name})]}),(0,I.jsxs)(`div`,{className:`git-diff-controls`,children:[a.staged&&a.unstaged&&(0,I.jsxs)(`div`,{className:`git-layer-switch`,children:[(0,I.jsx)(`button`,{"data-active":l===`working`,onClick:()=>void C(a,`working`),children:`工作区`}),(0,I.jsx)(`button`,{"data-active":l===`staged`,onClick:()=>void C(a,`staged`),children:`已暂存`})]}),!p&&(0,I.jsxs)(`div`,{className:`git-diff-stats`,children:[(0,I.jsxs)(`span`,{className:`add`,children:[`+`,y]}),(0,I.jsxs)(`span`,{className:`del`,children:[`−`,b]})]})]})]}),(0,I.jsx)(`div`,{className:`git-code`,"aria-label":`${a.path} 差异`,children:p?(0,I.jsxs)(`div`,{className:`git-diff-loading`,children:[(0,I.jsx)(`i`,{}),`正在生成差异…`]}):v.map((e,t)=>(0,I.jsxs)(`div`,{className:`git-code-line`,"data-kind":e.kind,children:[(0,I.jsx)(`span`,{className:`old-line`,children:e.oldNumber??``}),(0,I.jsx)(`span`,{className:`new-line`,children:e.newNumber??``}),(0,I.jsx)(`span`,{className:`change-marker`,children:e.marker}),(0,I.jsx)(`code`,{children:e.text||` `})]},`${t}-${e.oldNumber??``}-${e.newNumber??``}`))})]})})]}):(0,I.jsx)(`p`,{className:`manager-empty`,children:`当前项目不是 Git 仓库`}),r.repository&&(0,I.jsxs)(`footer`,{className:`git-footer`,children:[(0,I.jsx)(`button`,{className:`review-action`,onClick:t,children:`交给 /review`}),(0,I.jsxs)(`div`,{className:`commit-field`,children:[(0,I.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:x>0?`描述这次提交…`:`暂存文件后即可提交`}),(0,I.jsxs)(`span`,{children:[x,` 个文件已暂存`]})]}),(0,I.jsx)(`button`,{className:`commit-action`,disabled:!h.trim()||x===0,onClick:()=>void te(),children:`提交`})]})]})}function $u(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/`);return n<0?{name:t,directory:``}:{name:t.slice(n+1),directory:t.slice(0,n)}}function ed(e){return e instanceof Error?e.message:String(e)}function td(e){let t=[],n,r=()=>{if(n===void 0)return;let e=n.lines.length,r=n.hunks.map((t,r)=>({...t,end:n.hunks[r+1]?.start??e}));t.push({...n,hunks:r})};for(let t of e.split(/\r?\n/)){let e=/^diff --(?:git|flavor) a\/(.+?) b\/(.+)$/.exec(t);if(e!==null){r(),n={path:e[2],lines:[t],hunks:[],additions:0,deletions:0};continue}if(n===void 0)continue;let i=n.lines.length;n.lines.push(t),t.startsWith(`@@`)?n.hunks.push({id:`${n.path}:${n.hunks.length+1}`,header:t,start:i,end:i+1}):t.startsWith(`+`)&&!t.startsWith(`+++`)?n.additions+=1:t.startsWith(`-`)&&!t.startsWith(`---`)&&(n.deletions+=1)}return r(),t}function nd(e){return Math.min(2.4,Math.max(.55,e))}function rd(e,t,n){let r=nd(n),i=r/e.scale;return{x:t.x-(t.x-e.x)*i,y:t.y-(t.y-e.y)*i,scale:r}}function id(e,t,n){return{x:Math.round(t.x+e.x*n.width*t.scale/100),y:Math.round(t.y+e.y*n.height*t.scale/100)}}function ad(e,t){let n=new Map,r=[];n.set(e.id,{...e,role:`origin`,x:50,y:50});let i=(t,i,a)=>{t.slice(0,8).forEach((t,o,s)=>{n.set(t.id,{...t,role:i,x:a,y:(o+1)*100/(s.length+1)}),r.push(i===`caller`?{from:t.id,to:e.id,kind:i}:{from:e.id,to:t.id,kind:i})})};i(t.callers,`caller`,14),i(t.callees,`callee`,86);let a=t.impact.filter(e=>!n.has(e.id)).slice(0,12),o=Math.ceil(a.length/2);return a.forEach((t,i)=>{let s=i<o,c=s?i:i-o,l=s?o:a.length-o,u=Math.floor(c/3),d=c%3,f=Math.min(3,l-u*3),p=(d+1)*100/(f+1),m=s?13+u*11:87-u*11;n.set(t.id,{...t,role:`impact`,x:p,y:m,hop:t.hop}),r.push({from:e.id,to:t.id,kind:`impact`,hop:t.hop})}),{nodes:[...n.values()],edges:r}}function od(e){let t=new Map(e.map(e=>[e.id,e]));return e.map(e=>{let n=0,r=e.parentId,i=new Set([e.id]);for(;r!==null&&n<12&&!i.has(r);){i.add(r);let e=t.get(r);if(e===void 0)break;n+=1,r=e.parentId}return{node:e,depth:n}})}function sd(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).at(-1)??e}function cd(e,t){let n=t.filter(e=>e.state!==`closed`);return e!==void 0&&n.some(t=>t.id===e)?e:n.find(e=>e.state===`running`)?.id??n[0]?.id}var ld=`modulepreload`,ud=function(e,t){return new URL(e,t).href},dd={},fd=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=ud(t,n),t=s(t),t in dd)return;dd[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:ld,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},pd=[{id:`cockpit`,label:`执行`},{id:`timeline`,label:`时间机`},{id:`terminal`,label:`终端`},{id:`review`,label:`审查`},{id:`preview`,label:`预览`},{id:`context`,label:`上下文`},{id:`ast`,label:`代码图`},{id:`pals`,label:`Pals`},{id:`worktrees`,label:`工作树`}],md=_.lazy(()=>fd(()=>import(`./interactive-terminal-BwS6MvIe.js`),[],import.meta.url));function hd({snapshot:e,onClose:t,onError:n,onCompose:r}){let[i,a]=(0,_.useState)(`cockpit`),[o,s]=(0,_.useState)(()=>Od(e.jobs.map(e=>e.label).join(`
|
|
151
|
+
`))),c=(0,_.useRef)(new Map),l=e=>s(t=>[...new Set([...t,...Od(e)])].slice(-20));return(0,_.useEffect)(()=>{let t=!1;return Promise.all(e.jobs.map(async e=>{let n=await window.flavorDesktop.readJob(e.id,c.current.get(e.id)??0).catch(()=>void 0);n===void 0||t||(c.current.set(e.id,n.cursor),l(n.output))})),()=>{t=!0}},[e.jobs]),(0,I.jsxs)(`section`,{className:`agent-workbench manager-view`,children:[(0,I.jsxs)(`header`,{className:`manager-header workbench-header`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{onClick:t,children:`‹`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`FLAVOR DESKTOP 1.3.4`}),(0,I.jsx)(`h2`,{children:`Agent 工作台`})]})]}),(0,I.jsx)(`span`,{children:e.activeSession?.environment===`worktree`?`隔离工作树`:`本地检出`})]}),(0,I.jsx)(`nav`,{className:`workbench-tabs`,"aria-label":`工作台功能`,children:pd.map(e=>(0,I.jsx)(`button`,{"data-active":i===e.id,onClick:()=>a(e.id),children:e.label},e.id))}),(0,I.jsxs)(`div`,{className:`workbench-stage`,children:[i===`cockpit`&&(0,I.jsx)(gd,{snapshot:e,onCompose:r}),i===`timeline`&&(0,I.jsx)(_d,{onError:n}),i===`terminal`&&(0,I.jsx)(vd,{onError:n,onDiscover:l}),i===`review`&&(0,I.jsx)($,{onError:n,onCompose:r}),i===`preview`&&(0,I.jsx)(bd,{onError:n,suggestions:o}),i===`context`&&(0,I.jsx)(xd,{snapshot:e,onError:n}),i===`ast`&&(0,I.jsx)(Sd,{onError:n,onCompose:r}),i===`pals`&&(0,I.jsx)(Td,{onError:n}),i===`worktrees`&&(0,I.jsx)(Ed,{snapshot:e,onError:n})]})]})}function gd({snapshot:e,onCompose:t}){let[n,r]=(0,_.useState)(),[i,a]=(0,_.useState)(``);(0,_.useEffect)(()=>{window.flavorDesktop.inspectWorkbench().then(r).catch(()=>void 0)},[e.activeSession?.sessionId]);let o=n?.goals[0];(0,_.useEffect)(()=>{o!==void 0&&a(o.objective)},[o?.id]);let s=e.tasks?.plan?.tasks??[],c=Object.entries(e.tasks?.subagents.states??{});return(0,I.jsxs)(`div`,{className:`cockpit-grid`,children:[(0,I.jsxs)(`section`,{className:`cockpit-trace`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`small`,{children:`EXECUTION TRACE`}),(0,I.jsx)(`h3`,{children:o?.objective??`当前会话尚未启动持久目标`})]}),(0,I.jsx)(`ol`,{children:s.length===0?(0,I.jsxs)(`li`,{"data-state":`pending`,children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`等待执行计划`}),(0,I.jsx)(`small`,{children:`TaskPlan 出现后会自动同步`})]})]}):s.map(e=>(0,I.jsxs)(`li`,{"data-state":e.status,children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:e.subject}),(0,I.jsxs)(`small`,{children:[e.status,e.result?` · ${e.result}`:``]})]})]},e.id))})]}),(0,I.jsxs)(`aside`,{className:`cockpit-evidence`,children:[(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`small`,{children:`目标状态`}),(0,I.jsx)(`b`,{"data-phase":o?.phase,children:o?.phase??`idle`}),(0,I.jsx)(`p`,{children:o?`${o.status} · worker ${o.workerRounds} · verify ${o.verifyRounds}`:`使用 /goal 启动带验证的长期任务`}),o&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`textarea`,{className:`cockpit-goal-editor`,value:i,onChange:e=>a(e.target.value),"aria-label":`继续目标`}),(0,I.jsxs)(`div`,{className:`cockpit-goal-actions`,children:[e.activeSession?.busy&&(0,I.jsx)(`button`,{onClick:()=>void window.flavorDesktop.interrupt(),children:`安全暂停`}),(0,I.jsx)(`button`,{disabled:!i.trim(),onClick:()=>t(`/goal ${i.trim()}`),children:`以编辑目标继续`})]})]})]}),(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`small`,{children:`协作 Agent`}),c.length===0?(0,I.jsx)(`p`,{children:`没有活跃子 Agent`}):c.map(([e,t])=>(0,I.jsxs)(`div`,{className:`cockpit-row`,children:[(0,I.jsx)(`code`,{children:e}),(0,I.jsx)(`span`,{"data-state":t,children:t})]},e))]}),(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`small`,{children:`后台作业`}),e.jobs.length===0?(0,I.jsx)(`p`,{children:`没有后台作业`}):e.jobs.map(e=>(0,I.jsxs)(`div`,{className:`cockpit-row`,children:[(0,I.jsx)(`code`,{children:e.label}),(0,I.jsx)(`span`,{"data-state":e.state,children:e.state})]},e.id))]}),o&&o.evidenceRounds.length>0&&(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`small`,{children:`验证证据`}),o.evidenceRounds.slice(-3).reverse().map(e=>(0,I.jsxs)(`div`,{className:`cockpit-evidence-round`,children:[(0,I.jsxs)(`b`,{children:[`ROUND `,e.round]}),(0,I.jsx)(`p`,{children:e.hostVerification?.summary??`workspace ${e.workspaceDiffHash.slice(0,10)}`}),(0,I.jsx)(`span`,{"data-passed":e.hostVerification?.passed,children:e.hostVerification===void 0?`workspace evidence`:e.hostVerification.passed?`passed`:`failed`})]},e.round))]}),o&&o.lastGaps.length>0&&(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`small`,{children:`验证缺口`}),o.lastGaps.map((e,t)=>(0,I.jsx)(`p`,{className:`cockpit-gap`,children:e.description},t))]})]})]})}function _d({onError:e}){let[t,n]=(0,_.useState)({leafId:null,nodes:[]}),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(!1),s=()=>window.flavorDesktop.historySnapshot().then(n).catch(t=>e(Dd(t)));(0,_.useEffect)(()=>{s()},[]);let c=async t=>{o(!0);try{await t(),await s()}catch(t){e(Dd(t))}finally{o(!1)}},l=od(t.nodes);return(0,I.jsxs)(`div`,{className:`timeline-layout`,children:[(0,I.jsxs)(`section`,{className:`timeline-canvas`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`small`,{children:`SESSION TREE`}),(0,I.jsxs)(`h3`,{children:[t.nodes.length,` 个可恢复节点`]})]}),(0,I.jsx)(`ol`,{children:l.map(({node:e,depth:n})=>(0,I.jsxs)(`li`,{className:`timeline-node`,style:{paddingLeft:n*26},"data-depth":n,"data-current":e.id===t.leafId,children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:e.prompt||e.id}),(0,I.jsxs)(`small`,{children:[new Date(e.createdAt).toLocaleString(),` · `,e.checkpointId]})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{disabled:a,onClick:()=>void c(()=>window.flavorDesktop.rewindHistory(e.id)),children:`回到这里`}),(0,I.jsx)(`button`,{disabled:a,onClick:()=>{window.confirm(`从这个节点建立新分支?当前上下文将切换。`)&&c(()=>window.flavorDesktop.forkHistory(e.id))},children:`Fork`})]})]},e.id))})]}),(0,I.jsxs)(`aside`,{className:`timeline-actions`,children:[(0,I.jsx)(`h3`,{children:`建立安全点`}),(0,I.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`例如:重构前`}),(0,I.jsx)(`button`,{disabled:a,onClick:()=>void c(()=>window.flavorDesktop.createCheckpoint(r||void 0)),children:`创建 checkpoint`}),(0,I.jsx)(`button`,{disabled:a,onClick:()=>void c(()=>window.flavorDesktop.unrevertHistory()),children:`撤销上次回退`})]})]})}function vd({onError:e,onDiscover:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),o=n.find(e=>e.id===i),s=(e,t)=>{let n=e.filter(e=>e.state!==`closed`);r(n),a(e=>cd(t??e,n))},c=async e=>s(await window.flavorDesktop.listTerminals(),e);(0,_.useEffect)(()=>{c().catch(t=>e(Dd(t)))},[]);let l=async()=>{try{let e=await window.flavorDesktop.openTerminal();await c(e.id)}catch(t){e(Dd(t))}},u=async()=>{if(i!==void 0)try{await window.flavorDesktop.closeTerminal(i),await c()}catch(t){e(Dd(t))}};return(0,I.jsxs)(`div`,{className:`terminal-layout`,children:[(0,I.jsxs)(`aside`,{children:[(0,I.jsx)(`button`,{className:`primary`,onClick:()=>void l(),children:`+ 新终端`}),n.map(e=>(0,I.jsxs)(`button`,{"data-active":e.id===i,onClick:()=>a(e.id),title:e.shell,children:[(0,I.jsx)(`strong`,{children:sd(e.shell)}),(0,I.jsxs)(`small`,{children:[e.state,` · `,e.id]})]},e.id))]}),(0,I.jsxs)(`main`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`span`,{title:o?.cwd,children:o?.cwd??`尚未打开终端`}),o&&(0,I.jsx)(`button`,{onClick:()=>void u(),children:`关闭终端`})]}),o===void 0?(0,I.jsxs)(`div`,{className:`terminal-empty`,children:[(0,I.jsx)(`b`,{children:`没有打开终端`}),(0,I.jsx)(`span`,{children:`新建终端后,直接在终端区域输入和操作。`})]}):(0,I.jsx)(_.Suspense,{fallback:(0,I.jsxs)(`div`,{className:`terminal-empty`,children:[(0,I.jsx)(`b`,{children:`正在连接终端`}),(0,I.jsx)(`span`,{children:`正在加载交互渲染器…`})]}),children:(0,I.jsx)(md,{terminal:o,onError:e,onDiscover:t},o.id)})]})]})}function $({onError:e,onCompose:t}){let[n,r]=(0,_.useState)(`working`),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(),[f,p]=(0,_.useState)(),m=(0,_.useMemo)(()=>td(o),[o]),h=m.find(e=>e.path===u)??m[0],g=async()=>{l(!0);try{let e=await window.flavorDesktop.gitReview(n,i||void 0);s(e);let t=td(e);d(t[0]?.path),p(t[0]?.hunks[0]?.id)}catch(t){e(Dd(t))}finally{l(!1)}};return(0,_.useEffect)(()=>{if(n===`commit`||n===`base`){s(``),d(void 0),p(void 0);return}g()},[n]),(0,I.jsxs)(`div`,{className:`review-layout`,children:[(0,I.jsxs)(`aside`,{className:`review-scope`,children:[(0,I.jsx)(`small`,{children:`DIFF SCOPE`}),[`working`,`staged`,`last-turn`,`commit`,`base`].map(e=>(0,I.jsx)(`button`,{"data-active":n===e,onClick:()=>r(e),children:e},e)),(n===`commit`||n===`base`)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:n===`base`?`main / origin/main`:`commit SHA`}),(0,I.jsx)(`button`,{onClick:()=>void g(),children:`载入范围`})]})]}),(0,I.jsxs)(`section`,{className:`review-files`,"aria-label":`变更文件`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`strong`,{children:`文件`}),(0,I.jsx)(`span`,{children:m.length})]}),m.map(e=>(0,I.jsxs)(`button`,{"data-active":e.path===h?.path,onClick:()=>{d(e.path),p(e.hunks[0]?.id)},children:[(0,I.jsx)(`strong`,{children:e.path.split(`/`).at(-1)}),(0,I.jsx)(`small`,{children:e.path}),(0,I.jsxs)(`span`,{children:[(0,I.jsxs)(`b`,{children:[`+`,e.additions]}),(0,I.jsxs)(`em`,{children:[`-`,e.deletions]})]})]},e.path))]}),(0,I.jsxs)(`main`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:h?.path??n}),(0,I.jsxs)(`span`,{children:[h?.hunks.length??0,` hunks`]})]}),(0,I.jsx)(`button`,{onClick:()=>t(`/review 请审查 ${n}${i?` ${i}`:``}${h?` 中的 ${h.path}`:``},按 P0/P1/P2 分级输出发现,必须给出文件行号和触发场景。`),children:`交给 Agent 审查`})]}),h&&h.hunks.length>0&&(0,I.jsx)(`nav`,{className:`review-hunks`,"aria-label":`Hunk 导航`,children:h.hunks.map((e,t)=>(0,I.jsxs)(`button`,{"data-active":f===e.id,onClick:()=>p(e.id),children:[`H`,t+1,(0,I.jsx)(`span`,{children:e.header})]},e.id))}),(0,I.jsx)(yd,{file:h,activeHunk:f,loading:c,empty:o}),(0,I.jsxs)(`footer`,{className:`review-priority-legend`,children:[(0,I.jsx)(`span`,{"data-priority":`0`,children:`P0 阻断`}),(0,I.jsx)(`span`,{"data-priority":`1`,children:`P1 高风险`}),(0,I.jsx)(`span`,{"data-priority":`2`,children:`P2 一般`}),(0,I.jsx)(`small`,{children:`审查结果将在对话中返回,并携带文件行号。`})]})]})]})}function yd({file:e,activeHunk:t,loading:n,empty:r}){return n?(0,I.jsx)(`div`,{className:`review-empty`,children:`正在生成 diff…`}):e===void 0?(0,I.jsx)(`div`,{className:`review-empty`,children:r||`此范围没有差异`}):(0,I.jsx)(`div`,{className:`review-code`,role:`region`,"aria-label":`${e.path} 差异`,children:(0,I.jsx)(`pre`,{children:e.lines.map((n,r)=>{let i=e.hunks.find(e=>r>=e.start&&r<e.end);return(0,I.jsx)(`code`,{"data-kind":n.startsWith(`+++`)||n.startsWith(`---`)?`meta`:n.startsWith(`+`)?`addition`:n.startsWith(`-`)?`deletion`:n.startsWith(`@@`)?`hunk`:`context`,"data-active":i?.id===t,children:n||` `},r)})})})}function bd({onError:e,suggestions:t}){let[n,r]=(0,_.useState)(`http://localhost:3000`),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(0),c=async()=>{try{a(await window.flavorDesktop.validatePreviewUrl(n))}catch(t){e(Dd(t))}};return(0,I.jsxs)(`div`,{className:`preview-layout`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c()}}),(0,I.jsx)(`button`,{onClick:()=>void c(),children:`打开`}),(0,I.jsx)(`button`,{disabled:!i,onClick:()=>s(e=>e+1),children:`刷新`}),(0,I.jsx)(`button`,{disabled:!i,onClick:()=>{i&&window.flavorDesktop.openPreviewUrl(i)},children:`外部打开`}),(0,I.jsx)(`button`,{disabled:!i,onClick:()=>{i&&navigator.clipboard.writeText(i)},children:`复制`})]}),t.length>0&&(0,I.jsxs)(`div`,{className:`preview-suggestions`,children:[`检测到:`,t.map(t=>(0,I.jsx)(`button`,{onClick:()=>{r(t),window.flavorDesktop.validatePreviewUrl(t).then(a).catch(t=>e(Dd(t)))},children:t},t))]}),i?(0,I.jsx)(`iframe`,{src:i,title:`本地应用预览`,sandbox:`allow-forms allow-modals allow-popups allow-scripts allow-same-origin`},o):(0,I.jsxs)(`div`,{className:`preview-empty`,children:[(0,I.jsx)(`strong`,{children:`安全的本地预览`}),(0,I.jsx)(`p`,{children:`仅允许 localhost、127.0.0.1 和 ::1 的 HTTP(S) 地址。`})]})]})}function xd({snapshot:e,onError:t}){let[n,r]=(0,_.useState)();return(0,_.useEffect)(()=>{window.flavorDesktop.inspectWorkbench().then(r).catch(e=>t(Dd(e)))},[]),(0,I.jsxs)(`div`,{className:`context-grid`,children:[(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`small`,{children:`RUNTIME`}),(0,I.jsx)(`h3`,{children:`上下文 Epoch`})]}),(0,I.jsxs)(`dl`,{children:[(0,I.jsx)(`dt`,{children:`Permission`}),(0,I.jsx)(`dd`,{children:e.activeSession?.permissionMode??`—`}),(0,I.jsx)(`dt`,{children:`Model`}),(0,I.jsx)(`dd`,{children:e.activeSession?.mainModel??`—`}),(0,I.jsx)(`dt`,{children:`Checkout`}),(0,I.jsx)(`dd`,{children:e.activeSession?.workingDirectory??e.workspace??`—`})]}),n?.context?.epoch!==void 0&&(0,I.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(n.context.epoch,null,2)}),n?.context?.visibility.map((e,t)=>(0,I.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(e,null,2)},t)),n?.context?.usage.map((e,t)=>(0,I.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(e,null,2)},`usage-${t}`)),e.diagnostics.map((e,t)=>(0,I.jsx)(`p`,{className:`context-record`,children:e},`diag-${t}`))]}),(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`small`,{children:`INSTRUCTIONS`}),(0,I.jsx)(`h3`,{children:`生效的项目指令`})]}),n?.instructions.map(e=>(0,I.jsxs)(`details`,{children:[(0,I.jsx)(`summary`,{children:e.name}),(0,I.jsx)(`pre`,{children:e.content})]},e.path))]}),(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`small`,{children:`SAFETY`}),(0,I.jsx)(`h3`,{children:`权限规则与审计`})]}),n?.permissionFiles.map(e=>(0,I.jsxs)(`details`,{children:[(0,I.jsxs)(`summary`,{children:[e.tier,` · `,e.path]}),(0,I.jsx)(`pre`,{children:e.content})]},e.path)),n?.audit.slice(0,30).map((e,t)=>(0,I.jsx)(`pre`,{className:`context-record`,children:JSON.stringify(e,null,2)},t))]})]})}function Sd({onError:e,onCompose:t}){let[n,r]=(0,_.useState)(),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(),[u,d]=(0,_.useState)(),[f,p]=(0,_.useState)(2),[m,h]=(0,_.useState)(!1);(0,_.useEffect)(()=>{window.flavorDesktop.astStatus().then(r).catch(t=>e(Dd(t)))},[]);let g=async()=>{try{s(await window.flavorDesktop.astSearch(i))}catch(t){e(Dd(t))}},v=async(t,n=f)=>{l(t),h(!0);try{d(await window.flavorDesktop.astRelations(t.id,n))}catch(t){e(Dd(t))}finally{h(!1)}},y=c===void 0||u===void 0?void 0:ad(c,u);return(0,I.jsxs)(`div`,{className:`ast-layout`,children:[(0,I.jsxs)(`aside`,{className:`ast-symbols`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`SYMBOL INDEX`}),(0,I.jsx)(`strong`,{children:`代码索引`})]}),(0,I.jsx)(`span`,{"data-ready":n?.available,children:n?.available?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`b`,{children:n.nodes}),` symbols`,(0,I.jsx)(`br`,{}),(0,I.jsx)(`b`,{children:n.edges}),` edges`]}):`尚未建立索引`})]}),(0,I.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`⌕`}),(0,I.jsx)(`input`,{"aria-label":`搜索代码符号`,value:i,onChange:e=>a(e.target.value),placeholder:`函数、类型或模块`}),(0,I.jsx)(`button`,{children:`搜索`})]}),(0,I.jsx)(`div`,{className:`ast-symbol-list`,children:o.length===0?(0,I.jsx)(`p`,{children:n?.available===!1?`项目尚未建立代码索引`:`输入名称,定位代码中的关键符号`}):o.map(e=>(0,I.jsxs)(`button`,{"data-active":e.id===c?.id,onClick:()=>void v(e),children:[(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsx)(`em`,{children:e.kind})]}),(0,I.jsxs)(`small`,{children:[e.filePath,`:`,e.startLine]})]},e.id))})]}),(0,I.jsxs)(`main`,{className:`ast-graph-stage`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`RELATION MAP`}),(0,I.jsx)(`h3`,{children:c?.qualifiedName??`代码关系浏览器`}),(0,I.jsx)(`code`,{children:c?`${c.filePath}:${c.startLine}-${c.endLine}`:`搜索并选择一个符号作为图中心`})]}),(0,I.jsxs)(`div`,{className:`ast-depth`,"aria-label":`影响深度`,children:[(0,I.jsx)(`span`,{children:`影响深度`}),[1,2,3,4].map(e=>(0,I.jsx)(`button`,{"aria-label":`${e} 层影响深度`,"data-active":f===e,onClick:()=>{p(e),c&&v(c,e)},children:e},e))]})]}),m?(0,I.jsx)(`div`,{className:`ast-graph-empty`,children:`正在展开关系图…`}):y?(0,I.jsx)(Cd,{graph:y,selected:c,onSelect:e=>void v(e)}):(0,I.jsxs)(`div`,{className:`ast-graph-empty`,children:[(0,I.jsx)(`strong`,{children:`从一个符号开始`}),(0,I.jsx)(`p`,{children:`搜索函数、类或模块,在同一张图上查看调用者、被调用项和多跳影响范围。`})]})]}),(0,I.jsxs)(`aside`,{className:`ast-inspector`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`SYMBOL INSPECTOR`}),(0,I.jsx)(`h3`,{children:c?.name??`未选择符号`})]}),c&&(0,I.jsx)(`span`,{children:c.kind})]}),c?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`dl`,{children:[(0,I.jsx)(`dt`,{children:`语言`}),(0,I.jsx)(`dd`,{children:c.language}),(0,I.jsx)(`dt`,{children:`位置`}),(0,I.jsxs)(`dd`,{children:[c.filePath,`:`,c.startLine]}),c.signature&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`dt`,{children:`签名`}),(0,I.jsx)(`dd`,{children:c.signature})]})]}),(0,I.jsxs)(`button`,{className:`ast-compose`,onClick:()=>t(`请查看 @${c.filePath}#L${c.startLine}-L${c.endLine} 中的 ${c.qualifiedName}`),children:[(0,I.jsx)(`span`,{children:`加入输入框`}),(0,I.jsx)(`b`,{"aria-hidden":`true`,children:`↗`})]}),(0,I.jsx)(wd,{title:`Callers`,nodes:u?.callers??[],onSelect:e=>void v(e)}),(0,I.jsx)(wd,{title:`Callees`,nodes:u?.callees??[],onSelect:e=>void v(e)}),(0,I.jsx)(wd,{title:`Impact`,nodes:u?.impact??[],onSelect:e=>void v(e)})]}):(0,I.jsx)(`p`,{className:`ast-inspector-empty`,children:`选择一个符号后,这里会显示源码位置和完整关系。`})]})]})}function Cd({graph:e,selected:t,onSelect:n}){let r={x:0,y:0,scale:1},[i,a]=(0,_.useState)(r),[o,s]=(0,_.useState)({width:0,height:0}),[c,l]=(0,_.useState)(!1),u=(0,_.useRef)(null),d=(0,_.useRef)(void 0),f=new Map(e.nodes.map(e=>[e.id,e]));(0,_.useEffect)(()=>{a(r)},[t.id]),(0,_.useEffect)(()=>{let e=u.current;if(e===null)return;let t=()=>{let t=e.getBoundingClientRect();s({width:t.width,height:t.height})};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let p=(e,t)=>{let n=u.current?.getBoundingClientRect(),r=t??{x:(n?.width??0)/2,y:(n?.height??0)/2};a(t=>rd(t,r,e))},m=e=>{d.current?.pointerId===e.pointerId&&(d.current=void 0,l(!1),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,I.jsxs)(`div`,{ref:u,className:`ast-graph`,"data-dragging":c,role:`region`,"aria-label":`${t.name} 代码关系图,可拖动和滚轮缩放`,onWheel:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();p(i.scale*Math.exp(-e.deltaY*.0014),{x:e.clientX-t.left,y:e.clientY-t.top})},onPointerDown:e=>{e.button!==0||e.target.closest(`button`)||(e.currentTarget.setPointerCapture(e.pointerId),d.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY},l(!0))},onPointerMove:e=>{let t=d.current;if(t?.pointerId!==e.pointerId)return;let n=e.clientX-t.x,r=e.clientY-t.y;d.current={...t,x:e.clientX,y:e.clientY},a(e=>({...e,x:e.x+n,y:e.y+r}))},onPointerUp:m,onPointerCancel:m,children:[(0,I.jsx)(`div`,{className:`ast-graph-viewport`,style:{transform:`translate(${i.x}px, ${i.y}px) scale(${i.scale})`},children:(0,I.jsx)(`svg`,{viewBox:`0 0 100 100`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:e.edges.map((e,t)=>{let n=f.get(e.from),r=f.get(e.to);if(!n||!r)return null;let i=(n.x+r.x)/2;return(0,I.jsx)(`path`,{"data-kind":e.kind,d:`M ${n.x} ${n.y} C ${i} ${n.y}, ${i} ${r.y}, ${r.x} ${r.y}`},`${e.from}-${e.to}-${t}`)})})}),e.nodes.map(e=>{let t=id(e,i,o);return(0,I.jsxs)(`button`,{className:`ast-graph-node`,"data-role":e.role,style:{left:t.x,top:t.y,visibility:o.width>0?`visible`:`hidden`},onClick:()=>n(e),title:`${e.qualifiedName}\n${e.filePath}:${e.startLine}`,children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsx)(`small`,{children:e.role===`impact`?`hop ${e.hop}`:e.kind})]})]},e.id)}),(0,I.jsxs)(`div`,{className:`ast-graph-hint`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`↔`}),` 拖动平移 `,(0,I.jsx)(`i`,{}),` 滚轮缩放`]}),(0,I.jsxs)(`div`,{className:`ast-graph-controls`,"aria-label":`画布缩放`,children:[(0,I.jsx)(`button`,{"aria-label":`放大`,onClick:()=>p(i.scale*1.2),children:`+`}),(0,I.jsxs)(`span`,{children:[Math.round(i.scale*100),`%`]}),(0,I.jsx)(`button`,{"aria-label":`缩小`,onClick:()=>p(i.scale/1.2),children:`−`}),(0,I.jsx)(`button`,{className:`ast-graph-reset`,"aria-label":`复位画布`,onClick:()=>a(r),children:`复位`})]}),(0,I.jsxs)(`div`,{className:`ast-graph-legend`,children:[(0,I.jsx)(`span`,{"data-kind":`caller`,children:`调用者`}),(0,I.jsx)(`span`,{"data-kind":`origin`,children:`中心符号`}),(0,I.jsx)(`span`,{"data-kind":`callee`,children:`被调用`}),(0,I.jsx)(`span`,{"data-kind":`impact`,children:`影响范围`})]})]})}function wd({title:e,nodes:t,onSelect:n}){return(0,I.jsxs)(`section`,{className:`ast-relation`,children:[(0,I.jsxs)(`h4`,{children:[e,(0,I.jsx)(`span`,{children:t.length})]}),t.length===0?(0,I.jsx)(`p`,{children:`没有关系记录`}):t.slice(0,20).map(e=>(0,I.jsxs)(`button`,{onClick:()=>n(e),children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsxs)(`code`,{children:[e.filePath,`:`,e.startLine]})]},e.id))]})}function Td({onError:e}){let[t,n]=(0,_.useState)([]),[r,i]=(0,_.useState)(),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(),[d,f]=(0,_.useState)(),[p,m]=(0,_.useState)(),[h,g]=(0,_.useState)(),v=()=>window.flavorDesktop.listPals().then(e=>{f(void 0),n(e),i(t=>e.some(e=>e.alias===t)?t:e[0]?.alias)}).catch(e=>{n([]),f(Dd(e))});(0,_.useEffect)(()=>{v();let e=window.setInterval(v,4e3);return()=>window.clearInterval(e)},[]);let y=async(t,n,r)=>{m(t),g(void 0);try{r(await n())}catch(t){e(Dd(t))}finally{m(void 0)}},b=t.find(e=>e.alias===r),x=b?.alias,S=typeof l==`object`&&l?l:void 0,C=typeof S?.coWorkId==`string`?S.coWorkId:void 0,w=typeof S?.status==`string`?S.status:`created`,ee=e=>{x===void 0||!a.trim()||y(e,()=>window.flavorDesktop.sendPalMessage(x,a.trim(),e),()=>{o(``),g(e===`chat`?`消息已发送给 ${x}`:`任务已委托给 ${x}`)})};return(0,I.jsxs)(`div`,{className:`pals-layout`,children:[(0,I.jsxs)(`aside`,{children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`LOCAL BROKER`}),(0,I.jsx)(`h3`,{children:`在线 Pals`})]}),(0,I.jsx)(`span`,{children:t.length})]}),d===void 0?t.length===0&&(0,I.jsxs)(`div`,{className:`pals-list-empty`,children:[(0,I.jsx)(`b`,{children:`等待其他实例`}),(0,I.jsx)(`p`,{children:`同一台设备上的 Flavor 实例上线后会出现在这里。`})]}):(0,I.jsxs)(`div`,{className:`pals-unavailable`,children:[(0,I.jsx)(`strong`,{children:`正在恢复本地协作`}),(0,I.jsx)(`p`,{children:`broker 暂时不可用,工作台会自动重试。`}),(0,I.jsx)(`button`,{onClick:()=>void v(),children:`立即重试`})]}),(0,I.jsx)(`div`,{className:`pals-list`,children:t.map(e=>(0,I.jsxs)(`button`,{"data-active":r===e.alias,onClick:()=>{i(e.alias),g(void 0)},children:[(0,I.jsx)(`span`,{className:`pal-presence`,children:(0,I.jsx)(`i`,{})}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:e.alias}),(0,I.jsx)(`small`,{title:e.projectPath??e.id,children:e.projectPath??e.id})]}),(0,I.jsx)(`em`,{children:`在线`})]},e.id))})]}),(0,I.jsxs)(`main`,{children:[(0,I.jsxs)(`header`,{className:`pals-channel-header`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`CO-WORK CHANNEL`}),(0,I.jsx)(`h3`,{children:x??`没有选中 Pal`}),(0,I.jsx)(`p`,{title:b?.projectPath,children:b?.projectPath??`从左侧选择一个在线实例后即可发送消息、委托任务或共同执行目标。`})]}),(0,I.jsxs)(`span`,{"data-online":b!==void 0,children:[(0,I.jsx)(`i`,{}),b===void 0?`等待选择`:`连接正常`]})]}),(0,I.jsxs)(`div`,{className:`pals-compose-grid`,children:[(0,I.jsxs)(`section`,{className:`pal-compose-card`,"data-kind":`message`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`span`,{children:`MESSAGE`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{children:`发消息或委托任务`}),(0,I.jsx)(`p`,{children:`同一段内容,可以即时沟通,也可以交给对方独立执行。`})]})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`内容`}),(0,I.jsx)(`textarea`,{"aria-label":`消息或任务内容`,value:a,onChange:e=>o(e.target.value),placeholder:`写下背景、期望结果和必要约束…`})]}),(0,I.jsxs)(`footer`,{children:[(0,I.jsx)(`small`,{children:a.length===0?`建议说明交付结果`:`${a.length} 字符`}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`button`,{disabled:p!==void 0||x===void 0||!a.trim(),onClick:()=>ee(`chat`),children:[(0,I.jsx)(`b`,{children:p===`chat`?`发送中…`:`发送 Chat`}),(0,I.jsx)(`span`,{children:`直接沟通`})]}),(0,I.jsxs)(`button`,{disabled:p!==void 0||x===void 0||!a.trim(),onClick:()=>ee(`task`),children:[(0,I.jsx)(`b`,{children:p===`task`?`委托中…`:`委托 Task`}),(0,I.jsx)(`span`,{children:`异步执行`})]})]})]})]}),(0,I.jsxs)(`section`,{className:`pal-compose-card`,"data-kind":`cowork`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`span`,{children:`CO-WORK`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{children:`共同完成一个目标`}),(0,I.jsx)(`p`,{children:`双方先共同规划,再持续同步执行状态与结果。`})]})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`共同目标`}),(0,I.jsx)(`textarea`,{"aria-label":`共同目标`,value:s,onChange:e=>c(e.target.value),placeholder:`描述目标、完成标准和双方需要协作的部分…`})]}),(0,I.jsxs)(`footer`,{children:[(0,I.jsx)(`small`,{children:s.length===0?`适合跨实例并行工作`:`${s.length} 字符`}),(0,I.jsxs)(`button`,{className:`primary`,disabled:p!==void 0||x===void 0||!s.trim(),onClick:()=>{x===void 0||!s.trim()||y(`cowork`,()=>window.flavorDesktop.startCoWork(x,s.trim()),e=>{u(e),c(``),g(`已与 ${x} 建立共同目标`)})},children:[(0,I.jsx)(`b`,{children:p===`cowork`?`建立中…`:`开始 Co-work`}),(0,I.jsx)(`span`,{children:`共同规划并执行`})]})]})]})]}),h!==void 0&&(0,I.jsxs)(`div`,{className:`pals-notice`,children:[(0,I.jsx)(`i`,{}),` `,h]}),l!==void 0&&(0,I.jsxs)(`section`,{className:`cowork-state`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`LIVE CO-WORK`}),(0,I.jsx)(`strong`,{children:`最新协作状态`})]}),(0,I.jsx)(`span`,{"data-status":w,children:w}),(0,I.jsxs)(`nav`,{children:[(0,I.jsx)(`button`,{disabled:p!==void 0,onClick:()=>void y(`refresh`,()=>window.flavorDesktop.coWorkStatus(C),u),children:`刷新状态`}),C&&(0,I.jsx)(`button`,{className:`danger`,disabled:p!==void 0,onClick:()=>{window.confirm(`取消这个 Co-work?`)&&y(`cancel`,()=>window.flavorDesktop.cancelCoWork(C,`cancelled from desktop workbench`),e=>{u(e),g(`协作已取消`)})},children:`取消协作`})]})]}),(0,I.jsxs)(`details`,{children:[(0,I.jsx)(`summary`,{children:`查看原始协作数据`}),(0,I.jsx)(`pre`,{children:JSON.stringify(l,null,2)})]})]})]})]})}function Ed({snapshot:e,onError:t}){let[n,r]=(0,_.useState)([]),i=()=>window.flavorDesktop.listWorktrees().then(r).catch(e=>t(Dd(e)));return(0,_.useEffect)(()=>{i()},[]),(0,I.jsxs)(`div`,{className:`worktree-pane`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`small`,{children:`TASK ISOLATION`}),(0,I.jsx)(`h3`,{children:`工作树`}),(0,I.jsx)(`p`,{children:`新任务可在独立分支中运行,不改动当前检出。`})]}),(0,I.jsxs)(`span`,{children:[n.length,` active`]})]}),n.length===0?(0,I.jsx)(`div`,{className:`manager-empty`,children:`还没有隔离工作树。新建任务时选择“隔离工作树”。`}):(0,I.jsx)(`div`,{className:`worktree-list`,children:n.map(n=>(0,I.jsxs)(`article`,{"data-current":e.activeSession?.worktreeId===n.id,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`i`,{}),(0,I.jsx)(`strong`,{children:n.branch}),(0,I.jsx)(`small`,{children:n.path})]}),(0,I.jsx)(`span`,{"data-dirty":n.dirty,children:n.merged?`merged`:n.dirty?`dirty`:`clean`}),(0,I.jsxs)(`div`,{className:`worktree-actions`,children:[(0,I.jsx)(`button`,{disabled:n.dirty||n.merged,onClick:()=>{window.confirm(`将 ${n.branch} 合并回当前项目分支?`)&&window.flavorDesktop.mergeWorktree(n.id).then(i).catch(e=>t(Dd(e)))},children:`合并交付`}),(0,I.jsx)(`button`,{onClick:()=>{window.confirm(`移除工作树 ${n.branch}?${n.dirty?`存在未提交变更,将强制移除。`:`分支会保留。`}`)&&window.flavorDesktop.removeWorktree(n.id,n.dirty).then(i).catch(e=>t(Dd(e)))},children:`移除并保留分支`})]})]},n.id))})]})}function Dd(e){return e instanceof Error?e.message:String(e)}function Od(e){return e.match(/https?:\/\/(?:localhost|127\.0\.0\.1|\[?::1\]?)(?::\d{1,5})?(?:\/[^\s"'<>]*)?/gi)??[]}function kd(e,t,n=Date.now()){return{task:e,framework:t,startedAt:n,updatedAt:n,phase:`analyzing`,comparisonCycle:0,activity:[{id:`import`,label:`HTML 设计稿已导入`,state:`completed`,startedAt:n,completedAt:n}]}}function Ad(e,t,n=Date.now()){if(t.type===`model-start`){let r=e.phase===`analyzing`?`分析设计并规划实现`:e.phase===`building`?`检查实现并规划下一步`:`分析评测结果`;return Pd(e,{id:`model:${t.id}`,label:r,state:`running`,startedAt:n},n)}if(t.type===`model-end`)return Fd(e,`model:${t.id}`,`completed`,n);if(t.type===`tool-start`){let r=Md(t.name,e.phase),i=Nd(t.name,t.label,t.hint);return Pd({...e,phase:r},{id:`tool:${t.id}`,label:i,state:`running`,startedAt:n,...t.hint===void 0||t.hint===t.label?{}:{detail:Id(t.hint,72)}},n)}if(t.type===`tool-end`){let r=t.result.ok?`completed`:`failed`,i=e.activity.find(e=>e.id===`tool:${t.id}`);return i===void 0?Pd(e,{id:`tool:${t.id}`,label:Nd(t.name,t.label,t.hint),state:r,startedAt:n,completedAt:n},n):Fd(e,i.id,r,n)}return t.type===`model-retry`?Pd(e,{id:`retry:${t.attempt}`,label:`模型请求重试 ${t.attempt}/${t.maxAttempts}`,detail:`${Math.ceil(t.delayMs/1e3)} 秒后继续`,state:`info`,startedAt:n,completedAt:n},n):t.type===`warning`?Pd(e,{id:`warning:${n}`,label:Id(t.message,96),state:`info`,startedAt:n,completedAt:n},n):t.type===`error`?Pd(e,{id:`error:${n}`,label:Id(t.error.message,96),state:`failed`,startedAt:n,completedAt:n},n):e}function jd(e,t,n=Date.now()){if(t.task!==e.task)return e;let r=`engine:${t.cycle}:${t.stage}`,i=e.activity.find(e=>e.id===r);return Pd({...e,phase:`evaluating`,comparisonCycle:t.cycle},{id:r,label:t.message,state:t.state,startedAt:i?.startedAt??n,...t.state===`running`?{}:{completedAt:n},...t.cached===!0?{detail:`已复用缓存`}:{}},n)}function Md(e,t){return e===`D2cCompare`?`evaluating`:[`Write`,`Edit`,`ApplyPatch`,`Mkdir`,`Copy`,`Move`,`Shell`,`Bash`,`Command`,`Exec`].includes(e)?`building`:t}function Nd(e,t,n){let r=Id(t??n??``,60),i=r===``?``:` ${r}`;return[`Read`,`Glob`,`Grep`,`Search`,`List`].includes(e)?`读取${i||`设计与项目文件`}`:e===`Write`?`创建${i||`前端文件`}`:e===`Edit`||e===`ApplyPatch`?`调整${i||`前端实现`}`:e===`Mkdir`?`创建${i||`项目目录`}`:[`Shell`,`Bash`,`Command`,`Exec`].includes(e)?`运行${i||`项目命令`}`:e===`D2cCompare`?`启动视觉评测`:`${e}${i}`}function Pd(e,t,n){let r=e.activity.findIndex(e=>e.id===t.id),i=[...e.activity];return r<0?i.push(t):i[r]=t,{...e,updatedAt:n,activity:i.slice(-12)}}function Fd(e,t,n,r){let i=e.activity.find(e=>e.id===t);return i===void 0?e:Pd(e,{...i,state:n,completedAt:r},r)}function Id(e,t){let n=e.replaceAll(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}var Ld={sessions:[],diagnostics:[],models:[],jobs:[]},Rd=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`],zd=Z.map(e=>({name:e,description:Rl[e]})),Bd=5,Vd=5*1024*1024,Hd=20*1024*1024,Ud=new Set([`image/png`,`image/jpeg`,`image/webp`]);function Wd(e,t){return[e.trim(),...t.map((e,t)=>`[Image #${t+1}]`)].filter(Boolean).join(`
|
|
152
152
|
`)}function Gd({attachments:e,onRemove:t}){return(0,I.jsx)(`div`,{className:`image-attachment-strip`,"aria-label":`待发送图片`,children:e.map((e,n)=>(0,I.jsxs)(`figure`,{className:`image-attachment-chip`,children:[(0,I.jsx)(`img`,{src:e.previewUrl,alt:e.name}),(0,I.jsxs)(`figcaption`,{children:[(0,I.jsxs)(`strong`,{children:[`[Image #`,n+1,`]`]}),(0,I.jsx)(`span`,{children:e.name})]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-label":`移除 ${e.name}`,title:`移除图片`,children:`×`})]},e.id))})}function Kd(){let[e,t]=(0,_.useState)(Ld),[n,r]=(0,_.useState)(x),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(!0),[u,d]=(0,_.useState)(),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(),[y,b]=(0,_.useState)(),[C,w]=(0,_.useState)(!1),[ee,te]=(0,_.useState)(0),[ne,re]=(0,_.useState)(),[ie,ae]=(0,_.useState)([]),[oe,se]=(0,_.useState)([]),[ce,le]=(0,_.useState)(0),[ue,T]=(0,_.useState)(),[E,de]=(0,_.useState)(),[fe,pe]=(0,_.useState)(0),[D,O]=(0,_.useState)(`conversation`),[me,he]=(0,_.useState)(!1),[ge,_e]=(0,_.useState)(``),[ve,ye]=(0,_.useState)(`active`),[Ce,Te]=(0,_.useState)(),[Ee,De]=(0,_.useState)(),[Oe,k]=(0,_.useState)(``),[ke,Ae]=(0,_.useState)([]),[je,Me]=(0,_.useState)(-1),[Ne,Pe]=(0,_.useState)(0),[Fe,Ie]=(0,_.useState)(),[Le,Re]=(0,_.useState)(()=>new Map),ze=(0,_.useRef)(null),Be=(0,_.useRef)(null),A=(0,_.useRef)(void 0),Ve=(0,_.useRef)(void 0),He=(0,_.useRef)(n),Ue=(0,_.useRef)(new Map),j=(0,_.useRef)(new Map),We=(0,_.useRef)(new Map),Ge=(0,_.useRef)(new Set),Ke=(0,_.useRef)(!1),qe=(0,_.useCallback)(e=>{a(e),re(void 0),T(void 0)},[]);(0,_.useEffect)(()=>{He.current=n},[n]);let Je=(0,_.useCallback)(()=>{let e=Ve.current;e!==void 0&&(Ue.current.set(e,{sessionId:A.current,transcript:He.current}),A.current!==void 0&&j.current.set(`${e}\u0000${A.current}`,He.current))},[]),Ye=(0,_.useCallback)(e=>{e!==void 0&&Re(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),Xe=(0,_.useCallback)(e=>{let n=e.workspace;Ve.current=n,A.current=e.activeSession?.sessionId,t(e);let i=n===void 0?void 0:Ue.current.get(n);r(i!==void 0&&i.sessionId===e.activeSession?.sessionId?i.transcript:x()),Ye(n),O(`conversation`),p(!1)},[Ye]);(0,_.useEffect)(()=>()=>{for(let e of Ge.current)URL.revokeObjectURL(e);Ge.current.clear()},[]);let Ze=(0,_.useCallback)(e=>{s(t=>{let n=t.find(t=>t.id===e);return n!==void 0&&(URL.revokeObjectURL(n.previewUrl),Ge.current.delete(n.previewUrl)),t.filter(t=>t.id!==e)})},[]),Qe=(0,_.useCallback)(()=>{s(e=>{for(let t of e)URL.revokeObjectURL(t.previewUrl),Ge.current.delete(t.previewUrl);return[]})},[]),$e=(0,_.useCallback)(async e=>{if(e.length===0)return;let t=Bd-o.length;if(t<=0||e.length>t){d(`每条消息最多添加 ${Bd} 张图片。`);return}if(o.reduce((e,t)=>e+Math.floor(t.dataBase64.length*3/4),0)+e.reduce((e,t)=>e+t.size,0)>Hd){d(`单条消息的图片总大小不能超过 20 MiB。`);return}try{let t=await Promise.all(e.map(sf));for(let e of t)Ge.current.add(e.previewUrl);s(e=>[...e,...t].slice(0,Bd)),d(void 0)}catch(e){d(Cf(e))}},[o]);(0,_.useEffect)(()=>{let e=ze.current;if(!e)return;let t=e=>{e.deltaY<0?Ke.current=!0:requestAnimationFrame(()=>{let e=ze.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<8&&(Ke.current=!1)})};return e.addEventListener(`wheel`,t,{passive:!0}),()=>e.removeEventListener(`wheel`,t)},[]),(0,_.useEffect)(()=>{let e=window.flavorDesktop.onEvent(e=>{if(e.type===`snapshot`&&e.workspace!==void 0&&e.snapshot.workspace===e.workspace){let t=Ve.current;if(t!==void 0&&t!==e.workspace){Ue.current.set(t,{sessionId:A.current,transcript:He.current});let n=Ue.current.get(e.workspace);r(n!==void 0&&n.sessionId===e.snapshot.activeSession?.sessionId?n.transcript:x()),O(`conversation`),Ye(e.workspace)}Ve.current=e.workspace}else if(e.workspace!==void 0&&(e.workspace!==Ve.current||e.type===`session-output`&&e.sessionId!==A.current||e.type===`session-started`&&e.payload.sessionId!==A.current)){let t=Ue.current.get(e.workspace)??{sessionId:void 0,transcript:x()};if(e.type===`session-started`){let t=S(x(),{type:`restore`,state:e.payload.restoredTranscript});j.current.set(`${e.workspace}\u0000${e.payload.sessionId}`,t),Ue.current.set(e.workspace,{sessionId:e.payload.sessionId,transcript:t})}else if(e.type===`session-output`){let n=`${e.workspace}\u0000${e.sessionId}`,r=we(j.current.get(n)??x(),e.sessionId,e);j.current.set(n,r),t.sessionId===e.sessionId&&Ue.current.set(e.workspace,{...t,transcript:r})}return}if(e.type===`d2c-report`){Pe(e=>e+1),Ie(t=>t!==void 0&&t.task===e.payload.task?void 0:t),O(`e2e`);return}if(e.type===`d2c-progress`){Ie(t=>t===void 0?t:jd(t,e.payload));return}e.type===`session-output`&&e.sessionId===A.current&&Ie(t=>t===void 0?t:Ad(t,e.event)),(e.type===`session-output`&&e.sessionId===A.current&&[`done`,`error`,`exit`].includes(e.event.type)||e.type===`runtime-error`&&(e.sessionId===void 0||e.sessionId===A.current))&&Ie(void 0),Zd(e,A,t,r,d)});return window.flavorDesktop.bootstrap().then(e=>{Ve.current=e.workspace,A.current=e.activeSession?.sessionId,t(e)}).catch(e=>d(Cf(e))).finally(()=>l(!1)),e},[]),(0,_.useEffect)(()=>{Ke.current||ze.current?.scrollTo({top:ze.current.scrollHeight,behavior:`smooth`})},[n]),(0,_.useEffect)(()=>{let e=!1;return window.flavorDesktop.listFiles().then(t=>{e||se(pn(t))}).catch(()=>{}),()=>{e=!0}},[e.workspace]),(0,_.useEffect)(()=>{let t=!1;return e.workspace===void 0?(ae([]),()=>{t=!0}):(window.flavorDesktop.listSkills().then(e=>{t||ae(e)}).catch(()=>{t||ae([])}),()=>{t=!0})},[e.workspace,D]);let et=e.activeSession?.busy??!1,tt=(0,_.useMemo)(()=>e.projects??(e.workspace===void 0?[]:[{workspace:e.workspace,sessions:e.sessions,...e.activeSession===void 0?{}:{activeSession:{sessionId:e.activeSession.sessionId,busy:e.activeSession.busy}},running:et||e.jobs.some(e=>e.state===`running`)}]),[e.projects,e.workspace,e.sessions,e.activeSession,e.jobs,et]);(0,_.useEffect)(()=>{Re(e=>{let t=Se(tt,We.current,e);return We.current=t.activity,t.notices})},[tt]);let nt=(0,_.useMemo)(()=>Qt(zd,[],ie.filter(e=>e.enabled)),[ie]),rt=(0,_.useMemo)(()=>et||e.approval!==void 0||e.questions!==void 0||ne===i?null:en(i,fe,nt,ee),[i,fe,ee,ne,et,e.approval,e.questions,nt]),it=(0,_.useMemo)(()=>et||e.approval!==void 0||e.questions!==void 0||ue===i||rt!==null?null:mn(i,fe,oe,ce),[i,fe,ce,ue,et,e.approval,e.questions,oe,rt]),at=rt===null?$t(i,nt,!1):0,ot=(0,_.useCallback)(e=>{let t=nn(i,fe,e);a(t.text),re(t.text),te(0),pe(t.cursor),setTimeout(()=>{let e=Be.current;e!==null&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},0)},[i,fe]),st=(0,_.useCallback)(()=>{re(i)},[i]),ct=(0,_.useCallback)(e=>{te(t=>tn(t,e,rt?.items.length??0))},[rt]),lt=(0,_.useCallback)(e=>{let t=gn(i,fe,e);a(t.text),T(t.text),le(0),de(t.span),pe(t.cursor),setTimeout(()=>{let e=Be.current;e!==null&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},0)},[i,fe]),ut=(0,_.useCallback)(()=>{T(i)},[i]),dt=(0,_.useCallback)(e=>{le(t=>hn(t,e,it?.items.length??0))},[it]),ft=async()=>{d(void 0);try{Je();let e=await window.flavorDesktop.chooseWorkspace();e!==void 0&&(Qe(),Xe(e))}catch(e){d(Cf(e))}},pt=async n=>{if(n===e.workspace)return Ye(n),window.flavorDesktop.acknowledgeSession().then(t).catch(()=>void 0),O(`conversation`),p(!1),e;d(void 0),Je();try{let e=await window.flavorDesktop.openWorkspace(n);return Qe(),Xe(e),window.flavorDesktop.acknowledgeSession().then(t).catch(()=>void 0),e}catch(e){d(Cf(e));return}},mt=async(e,t)=>{let n=await pt(e);if(n!==void 0){if(n.activeSession?.sessionId===t.sessionId){O(`conversation`),p(!1);return}await ht(t)}},ht=async e=>{d(void 0);try{Je();let n=await window.flavorDesktop.selectSession(e.sessionId),i=n.snapshot.workspace===void 0?void 0:j.current.get(`${n.snapshot.workspace}\u0000${n.sessionId}`);t(n.snapshot),Ve.current=n.snapshot.workspace,A.current=n.sessionId,r(i??S(x(),{type:`restore`,state:n.restoredTranscript})),O(`conversation`),p(!1)}catch(e){d(Cf(e))}},gt=async(e,n)=>{d(void 0);try{let i=await window.flavorDesktop.startSession(e?.sessionId,n);Qe(),t(i.snapshot),Ve.current=i.snapshot.workspace,A.current=i.sessionId,r(S(x(),{type:`restore`,state:i.restoredTranscript})),i.snapshot.workspace!==void 0&&j.current.set(`${i.snapshot.workspace}\u0000${i.sessionId}`,S(x(),{type:`restore`,state:i.restoredTranscript})),p(!1),O(`conversation`),setTimeout(()=>Be.current?.focus(),0)}catch(e){d(Cf(e))}},_t=async(n,s,c)=>{let l=(n??i).trim(),u=n===void 0?o:[];if(!l&&u.length===0)return!1;d(void 0);try{let i=e;if(i.activeSession===void 0){let e=await window.flavorDesktop.startSession();i=e.snapshot,t(i),r(S(x(),{type:`restore`,state:e.restoredTranscript}))}let o=s??(et?`steer`:`prompt`);if(u.length>0&&o!==`prompt`)throw Error(`图片只能随新消息发送,不能作为运行中的引导或后续消息。`);return o===`prompt`&&r(e=>S(e,{type:`submit`,prompt:Wd(l,u)})),n===void 0&&a(``),await window.flavorDesktop.submit(l,o,u.map(({name:e,mediaType:t,dataBase64:n})=>({name:e,mediaType:t,dataBase64:n})),c),u.length>0&&Qe(),!0}catch(e){let t=Cf(e);return d(t),r(e=>S(e,{type:`submit-error`,message:t})),!1}},vt=e=>void _t(`/permissions ${e}`),yt=async e=>{d(void 0);try{t(await window.flavorDesktop.switchModel(e))}catch(e){d(Cf(e))}},bt=async()=>{if(!(et||e.activeSession===void 0)){d(void 0);try{await window.flavorDesktop.finishTask()}catch(e){d(Cf(e))}}},xt=async e=>{d(void 0);try{let n=await window.flavorDesktop.addModel(e);t(n.snapshot)}catch(e){throw d(Cf(e)),e}},St=(e,t)=>{let n=t.currentTarget.getBoundingClientRect();window.flavorDesktop.showAppMenu(e,Math.round(n.left),Math.round(n.bottom))},Ct=async()=>{if(!(y===void 0||C)){w(!0),d(void 0);try{let n=y.sessionId===e.activeSession?.sessionId,i=await window.flavorDesktop.deleteSession(y.sessionId);t(i),n&&r(x()),b(void 0),v(void 0)}catch(e){d(Cf(e))}finally{w(!1)}}},wt=async(e,n)=>{try{t(await window.flavorDesktop.updateSession(e.sessionId,n)),v(void 0)}catch(e){d(Cf(e))}},M=e=>{let t=window.prompt(`任务名称`,e.title??be(e));t!==null&&wt(e,{title:t.trim()})},N=async(e,n)=>{try{t(await window.flavorDesktop.updateProject(e,n)),Te(void 0)}catch(e){d(Cf(e))}},Tt=(e,t)=>{let n=window.prompt(`项目显示名称`,t??xe(e));n!==null&&N(e,{label:n.trim()})},Et=async(e,t)=>{if(!(t&&!window.confirm(`项目中有任务正在运行。停止任务并关闭项目?`)))try{Xe(await window.flavorDesktop.closeProject(e,t)),Te(void 0)}catch(e){d(Cf(e))}},Dt=async(e,t)=>{let n=await pt(e);if(n!==void 0&&t!==void 0){let e=n.sessions.find(e=>e.sessionId===t);e!==void 0&&await ht(e)}};(0,_.useEffect)(()=>{let t={...e.workspace===void 0?{}:{workspace:e.workspace},...e.activeSession===void 0?{}:{sessionId:e.activeSession.sessionId},view:D};Ae(e=>{let n=e[je];if(n?.workspace===t.workspace&&n?.sessionId===t.sessionId&&n?.view===t.view)return e;let r=[...e.slice(0,je+1),t].slice(-50);return Me(r.length-1),r})},[e.workspace,e.activeSession?.sessionId,D]);let Ot=async e=>{let n=je+e,i=ke[n];if(i!==void 0){if(Me(n),i.workspace!==void 0){let e=await window.flavorDesktop.openWorkspace(i.workspace);if(Xe(e),i.sessionId!==void 0){let e=await window.flavorDesktop.selectSession(i.sessionId);t(e.snapshot),A.current=e.sessionId,r(j.current.get(`${i.workspace}\u0000${i.sessionId}`)??S(x(),{type:`restore`,state:e.restoredTranscript}))}}O(i.view)}};return(0,_.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey))return;let t=e.key.toLowerCase();t===`n`&&(e.preventDefault(),he(!0)),t===`p`&&(e.preventDefault(),De(`projects`),k(``)),t===`k`&&(e.preventDefault(),De(`commands`),k(``)),t===`[`&&(e.preventDefault(),Ot(-1)),t===`]`&&(e.preventDefault(),Ot(1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[e.workspace,ke,je]),(0,I.jsxs)(`div`,{className:`app-frame`,children:[(0,I.jsx)(Xd,{railCollapsed:m,onToggleRail:()=>h(e=>!e),onMenu:St,canBack:je>0,canForward:je<ke.length-1,onBack:()=>void Ot(-1),onForward:()=>void Ot(1)}),(0,I.jsxs)(`div`,{className:`desktop-shell`,"data-rail-collapsed":m,children:[(0,I.jsx)(`button`,{className:`rail-scrim`,"data-open":f,onClick:()=>p(!1),"aria-label":`关闭项目栏`}),(0,I.jsxs)(`aside`,{className:`project-rail`,"data-open":f,children:[(0,I.jsxs)(`div`,{className:`brand-row`,children:[(0,I.jsx)(Sf,{}),(0,I.jsx)(`strong`,{children:`Flavor Code`})]}),(0,I.jsxs)(`nav`,{className:`primary-actions`,"aria-label":`主要操作`,children:[(0,I.jsxs)(`button`,{className:`rail-action rail-action-primary`,disabled:e.workspace===void 0,onClick:()=>he(!0),children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`plus`})}),(0,I.jsx)(`span`,{children:`新建任务`}),(0,I.jsx)(`kbd`,{children:`Ctrl N`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,onClick:()=>void ft(),children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`folder`})}),(0,I.jsx)(`span`,{children:`打开项目`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`skills`,onClick:()=>{O(`skills`),p(!1)},disabled:e.workspace===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`sparkles`})}),(0,I.jsx)(`span`,{children:`技能`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`memory`,onClick:()=>{O(`memory`),p(!1)},disabled:e.workspace===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`database`})}),(0,I.jsx)(`span`,{children:`长期记忆`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`mcp`,onClick:()=>{O(`mcp`),p(!1)},disabled:e.workspace===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`server`})}),(0,I.jsx)(`span`,{children:`MCP 服务`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`e2e`,onClick:()=>{O(`e2e`),p(!1)},disabled:e.workspace===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`checklist`})}),(0,I.jsx)(`span`,{children:`E2E`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`activity`,onClick:()=>{O(`activity`),p(!1)},children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`bell`})}),(0,I.jsx)(`span`,{children:`活动`}),(e.activities?.filter(e=>e.unread).length??0)>0&&(0,I.jsx)(`em`,{className:`rail-badge`,children:e.activities.filter(e=>e.unread).length})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`git`,onClick:()=>{O(`git`),p(!1)},disabled:e.workspace===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`git`})}),(0,I.jsx)(`span`,{children:`Git 变更`})]}),(0,I.jsxs)(`button`,{className:`rail-action`,"data-active":D===`workbench`,onClick:()=>{O(`workbench`),p(!1)},disabled:e.workspace===void 0||e.activeSession===void 0,children:[(0,I.jsx)(`span`,{className:`action-icon`,children:(0,I.jsx)(xf,{name:`checklist`})}),(0,I.jsx)(`span`,{children:`Agent 工作台`})]})]}),(0,I.jsxs)(`div`,{className:`sessions-scroll`,children:[(0,I.jsxs)(`div`,{className:`rail-section-heading`,children:[(0,I.jsx)(`span`,{children:`项目`}),(0,I.jsx)(`button`,{onClick:()=>void ft(),"aria-label":`打开新项目`,title:`打开新项目`,children:(0,I.jsx)(xf,{name:`plus`})})]}),tt.length>0&&(0,I.jsxs)(`div`,{className:`session-filter`,children:[(0,I.jsxs)(`div`,{className:`session-search`,children:[(0,I.jsx)(xf,{name:`search`}),(0,I.jsx)(`input`,{value:ge,onChange:e=>_e(e.target.value),placeholder:`搜索任务`,"aria-label":`搜索任务`}),ge.length>0&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>_e(``),"aria-label":`清除搜索`,title:`清除搜索`,children:`×`})]}),(0,I.jsxs)(`div`,{className:`session-group-filter`,children:[(0,I.jsxs)(`select`,{value:ve,onChange:e=>ye(e.target.value),"aria-label":`按状态筛选`,children:[(0,I.jsx)(`option`,{value:`active`,children:`任务`}),(0,I.jsx)(`option`,{value:`running`,children:`运行`}),(0,I.jsx)(`option`,{value:`unread`,children:`未读`}),(0,I.jsx)(`option`,{value:`archived`,children:`归档`})]}),(0,I.jsx)(`span`,{"aria-hidden":`true`})]})]}),tt.length===0?(0,I.jsx)(`button`,{className:`empty-project`,onClick:()=>void ft(),children:`选择一个本地文件夹开始`}):tt.map(t=>{let n=t.workspace===e.workspace,r=Le.has(t.workspace);Le.get(t.workspace);let i=n||t.running||r;return(0,I.jsxs)(`section`,{className:`project-entry`,"data-active":n,children:[(0,I.jsxs)(`div`,{className:`project-heading-shell`,children:[(0,I.jsxs)(`button`,{className:`project-heading`,onClick:()=>void pt(t.workspace),title:t.workspace,children:[(0,I.jsx)(`span`,{className:`folder-icon`,"aria-hidden":`true`,children:(0,I.jsx)(xf,{name:`folder`})}),(0,I.jsx)(`span`,{children:t.label||xe(t.workspace)}),t.running?(0,I.jsx)(`span`,{className:`project-running-dot`,title:`项目中有任务正在执行`}):(t.unreadCount??0)>0&&(0,I.jsx)(`span`,{className:`project-complete-dot`,role:`status`,"aria-label":`项目有未读活动`})]}),(0,I.jsx)(`button`,{className:`project-more`,onClick:()=>Te(e=>e===t.workspace?void 0:t.workspace),"aria-label":`管理项目`,children:`•••`}),Ce===t.workspace&&(0,I.jsxs)(`div`,{className:`project-menu`,role:`menu`,children:[(0,I.jsx)(`button`,{onClick:()=>Tt(t.workspace,t.label),children:`修改显示名称`}),(0,I.jsx)(`button`,{onClick:()=>void N(t.workspace,{pinned:!t.pinned}),children:t.pinned?`取消置顶`:`置顶项目`}),(0,I.jsx)(`button`,{onClick:()=>void window.flavorDesktop.revealProject(t.workspace),children:`在资源管理器中打开`}),(0,I.jsx)(`button`,{onClick:()=>void window.flavorDesktop.copyProjectPath(t.workspace),children:`复制路径`}),(0,I.jsx)(`button`,{className:`danger-item`,onClick:()=>void Et(t.workspace,t.running),children:`关闭项目`})]})]}),i&&t.sessions.length===0&&(0,I.jsx)(`p`,{className:`no-sessions`,children:`还没有任务`}),i&&t.sessions.filter(e=>(ve===`archived`?e.archived:!e.archived)&&(ve!==`running`||t.runningSessions?.includes(e.sessionId))&&(ve!==`unread`||e.unread)&&(!ge.trim()||be(e).toLowerCase().includes(ge.trim().toLowerCase()))).map(r=>{let i=n&&r.sessionId===e.activeSession?.sessionId,a=t.runningSessions?.includes(r.sessionId)??(t.running&&r.sessionId===t.activeSession?.sessionId),o=r.unread&&r.activity===`completed`;return(0,I.jsxs)(`div`,{className:`session-item-shell`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||v(void 0)},children:[(0,I.jsxs)(`button`,{className:`session-item`,"data-active":i,"data-running":a,disabled:n&&et&&!i,onClick:()=>void mt(t.workspace,r),children:[(0,I.jsxs)(`span`,{children:[r.pinned&&(0,I.jsx)(`i`,{className:`pin-mark`,children:`◆`}),be(r)]}),a?(0,I.jsx)(`span`,{className:`session-spinner`,role:`status`,"aria-label":`任务正在执行`}):o?(0,I.jsx)(`span`,{className:`session-complete-dot`,role:`status`,"aria-label":`任务已完成,点击查看`}):(0,I.jsx)(`time`,{children:Df(r.updatedAt)})]}),n&&(0,I.jsx)(`button`,{className:`session-more`,"aria-label":`管理会话:${be(r)}`,"aria-expanded":g===r.sessionId,onClick:()=>v(e=>e===r.sessionId?void 0:r.sessionId),children:`•••`}),n&&g===r.sessionId&&(0,I.jsxs)(`div`,{className:`session-menu`,role:`menu`,children:[(0,I.jsx)(`button`,{role:`menuitem`,onClick:()=>M(r),children:`重命名`}),(0,I.jsx)(`button`,{role:`menuitem`,onClick:()=>void wt(r,{pinned:!r.pinned}),children:r.pinned?`取消置顶`:`置顶`}),(0,I.jsx)(`button`,{role:`menuitem`,onClick:()=>void wt(r,{archived:!r.archived}),children:r.archived?`取消归档`:`归档`}),(0,I.jsx)(`button`,{role:`menuitem`,className:`danger-item`,disabled:et&&r.sessionId===e.activeSession?.sessionId,onClick:()=>{b(r),v(void 0)},children:`删除会话`})]})]},r.sessionId)})]},t.workspace)})]}),(0,I.jsxs)(`div`,{className:`rail-footer`,children:[(0,I.jsx)(`span`,{className:`avatar`,children:`F`}),(0,I.jsx)(`span`,{children:`本地工作区`}),(0,I.jsx)(`button`,{title:`帮助`,children:`?`})]})]}),(0,I.jsxs)(`main`,{className:`workspace-panel`,children:[D===`workbench`&&e.workspace!==void 0&&e.activeSession!==void 0?(0,I.jsx)(hd,{snapshot:e,onClose:()=>O(`conversation`),onError:d,onCompose:e=>{qe(e),O(`conversation`),setTimeout(()=>Be.current?.focus(),0)}}):D===`skills`&&e.workspace!==void 0?(0,I.jsx)(Bl,{onClose:()=>O(`conversation`),onError:d}):D===`memory`&&e.workspace!==void 0?(0,I.jsx)(Gl,{onClose:()=>O(`conversation`),onError:d}):D===`mcp`&&e.workspace!==void 0?(0,I.jsx)(ql,{onClose:()=>O(`conversation`),onError:d}):D===`activity`?(0,I.jsx)(qd,{activities:e.activities??[],onClose:()=>O(`conversation`),onOpen:(e,t)=>void Dt(e,t),onClear:()=>void window.flavorDesktop.acknowledgeSession().then(t)}):D===`git`&&e.workspace!==void 0?(0,I.jsx)(Qu,{onClose:()=>O(`conversation`),onError:d,onReview:()=>{O(`conversation`),_t(`/review`,`prompt`)}}):D===`e2e`&&e.workspace!==void 0?(0,I.jsx)(Yu,{onClose:()=>O(`conversation`),onInterrupt:()=>void window.flavorDesktop.interrupt(),onError:d,refreshKey:Ne,pending:Fe,disabled:et,onLaunch:(e,t)=>Ie(kd(e,t)),onStartTask:e=>_t(e,`prompt`,`d2c`)}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`header`,{className:`workspace-header`,children:[(0,I.jsx)(`button`,{className:`mobile-rail-toggle`,onClick:()=>p(!0),"aria-label":`打开项目栏`,children:`☰`}),(0,I.jsx)(`div`,{className:`workspace-breadcrumb`,children:(0,I.jsx)(`span`,{children:xe(e.workspace)})}),(0,I.jsxs)(`div`,{className:`header-actions`,children:[e.jobs.some(e=>e.state===`running`)&&(0,I.jsxs)(`div`,{className:`job-strip`,title:`后台任务`,children:[(0,I.jsx)(`span`,{className:`job-pulse`}),e.jobs.filter(e=>e.state===`running`).length,` 个后台任务`]}),(0,I.jsx)(`button`,{className:`finish-task-button`,onClick:()=>void bt(),disabled:et||e.activeSession===void 0,title:`评估并完成当前任务`,children:`完成任务`}),(0,I.jsx)(`button`,{title:`更多选项`,children:`•••`})]})]}),(e.recoveryItems?.filter(t=>t.workspace===e.workspace).length??0)>0&&(0,I.jsxs)(`div`,{className:`recovery-banner`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:`检测到上次未完成的任务`}),(0,I.jsx)(`span`,{children:`应用异常退出时,这些任务仍在运行。`})]}),e.recoveryItems.filter(t=>t.workspace===e.workspace).map(n=>(0,I.jsxs)(`div`,{className:`recovery-action`,children:[(0,I.jsx)(`code`,{children:wf(n.sessionId)}),(0,I.jsx)(`button`,{onClick:()=>{let t=e.sessions.find(e=>e.sessionId===n.sessionId);t!==void 0&&ht(t)},children:`恢复 / 查看`}),(0,I.jsx)(`button`,{onClick:()=>void window.flavorDesktop.dismissRecovery(n.sessionId).then(t),children:`忽略`})]},n.sessionId))]}),(0,I.jsx)(`div`,{className:`conversation-scroll`,ref:ze,children:c?(0,I.jsx)(_f,{}):e.workspace===void 0?(0,I.jsx)(gf,{onOpen:ft}):n.completed.length===0&&n.active===void 0?(0,I.jsx)(hf,{project:xe(e.workspace),onStart:e=>void _t(e)}):(0,I.jsxs)(`div`,{className:`conversation-column`,children:[n.completed.map(e=>(0,I.jsx)(Qd,{turn:e},e.id)),n.active!==void 0&&(0,I.jsx)(Qd,{turn:n.active,active:!0})]})}),e.diagnostics.length>0&&(0,I.jsxs)(`details`,{className:`diagnostics`,children:[(0,I.jsxs)(`summary`,{children:[e.diagnostics.length,` 条启动提示`]}),(0,I.jsx)(`pre`,{children:e.diagnostics.join(`
|
|
153
153
|
`)})]}),(0,I.jsx)(rf,{input:i,setInput:qe,onSend:e=>void _t(void 0,e),busy:et,onInterrupt:()=>{Ie(void 0),window.flavorDesktop.interrupt()},inputRef:Be,snapshot:e,attachments:o,onAddImages:e=>void $e(e),onRemoveImage:Ze,setModel:yt,addModel:xt,setPermission:vt,slashCompletion:rt,onSlashSelect:ot,onSlashDismiss:st,onSlashMove:ct,mentionCompletion:it,onMentionSelect:lt,onMentionDismiss:ut,onMentionMove:dt,mentionSpan:E,setMentionSpan:de,completedTokenLen:at,cursorPos:fe,setCursorPos:pe})]}),u!==void 0&&(0,I.jsxs)(`div`,{className:`error-toast`,role:`alert`,children:[(0,I.jsx)(`span`,{children:`!`}),(0,I.jsx)(`p`,{children:u}),(0,I.jsx)(`button`,{onClick:()=>d(void 0),children:`×`})]})]})]}),e.approval!==void 0&&(0,I.jsx)(df,{approval:e.approval,onResolve:e=>void window.flavorDesktop.resolveApproval(e)}),e.questions!==void 0&&(0,I.jsx)(ff,{questions:e.questions,onAnswer:e=>void window.flavorDesktop.answerQuestions(e)}),e.memoryReviews!==void 0&&e.memoryReviews.length>0&&(0,I.jsx)(pf,{reviews:e.memoryReviews,autoDismissSeconds:e.memoryAutoDismissSeconds??0,onResolve:(e,t)=>{window.flavorDesktop.resolveMemoryReview(e,t).catch(e=>d(Cf(e)))}}),y!==void 0&&(0,I.jsx)(lf,{session:y,deleting:C,onCancel:()=>b(void 0),onDelete:()=>void Ct()}),me&&(0,I.jsx)(Jd,{onCancel:()=>he(!1),onChoose:e=>{he(!1),gt(void 0,e)}}),Ee!==void 0&&(0,I.jsx)(Yd,{mode:Ee,query:Oe,setQuery:k,projects:tt,onClose:()=>De(void 0),onProject:e=>{De(void 0),pt(e)},onCommand:e=>{De(void 0),e===`new`?he(!0):e===`open`?ft():e===`activity`?O(`activity`):e===`git`?O(`git`):e===`skills`&&O(`skills`)}})]})}function qd({activities:e,onClose:t,onOpen:n,onClear:r}){return(0,I.jsxs)(`section`,{className:`manager-view activity-center`,children:[(0,I.jsxs)(`header`,{className:`manager-header`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{onClick:t,children:`←`}),(0,I.jsx)(`h2`,{children:`活动`})]}),(0,I.jsx)(`button`,{onClick:r,children:`全部标为已读`})]}),(0,I.jsx)(`div`,{className:`activity-list`,children:e.length===0?(0,I.jsx)(`p`,{className:`manager-empty`,children:`还没有任务活动`}):e.map(e=>(0,I.jsxs)(`button`,{className:`activity-row`,"data-kind":e.kind,"data-unread":e.unread,onClick:()=>n(e.workspace,e.sessionId),children:[(0,I.jsx)(`i`,{}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:e.title}),(0,I.jsxs)(`span`,{children:[xe(e.workspace),e.detail?` · ${e.detail}`:``]})]}),(0,I.jsx)(`time`,{children:Df(e.createdAt)})]},e.id))})]})}function Jd({onCancel:e,onChoose:t}){return(0,I.jsx)(`div`,{className:`modal-layer`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,I.jsxs)(`section`,{className:`new-task-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`new-task-title`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`p`,{children:`NEW TASK`}),(0,I.jsx)(`h2`,{id:`new-task-title`,children:`选择任务运行环境`}),(0,I.jsx)(`span`,{children:`隔离只影响 Electron 任务,不改变 CLI 默认行为。`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`button`,{onClick:()=>t(`worktree`),children:[(0,I.jsx)(`i`,{children:`◇`}),(0,I.jsx)(`strong`,{children:`隔离工作树`}),(0,I.jsx)(`span`,{children:`新建 flavor/desktop-* 分支,在应用目录中独立运行。`}),(0,I.jsx)(`em`,{children:`推荐`})]}),(0,I.jsxs)(`button`,{onClick:()=>t(`local`),children:[(0,I.jsx)(`i`,{children:`⌂`}),(0,I.jsx)(`strong`,{children:`当前检出`}),(0,I.jsx)(`span`,{children:`直接使用项目当前目录,适合快速查看和轻量操作。`})]})]}),(0,I.jsx)(`footer`,{children:(0,I.jsx)(`button`,{onClick:e,children:`取消`})})]})})}function Yd({mode:e,query:t,setQuery:n,projects:r,onClose:i,onProject:a,onCommand:o}){let s=[{id:`new`,label:`新建任务`,hint:`Ctrl N`},{id:`open`,label:`打开项目`,hint:`Ctrl O`},{id:`activity`,label:`查看活动`,hint:``},{id:`git`,label:`打开 Git 变更`,hint:``},{id:`skills`,label:`管理技能`,hint:``}].filter(e=>e.label.toLowerCase().includes(t.toLowerCase())),c=r.filter(e=>`${e.label??``} ${xe(e.workspace)} ${e.workspace}`.toLowerCase().includes(t.toLowerCase()));return(0,I.jsx)(`div`,{className:`palette-layer`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:(0,I.jsxs)(`section`,{className:`command-palette`,role:`dialog`,"aria-modal":`true`,children:[(0,I.jsx)(`input`,{autoFocus:!0,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Escape`&&i()},placeholder:e===`projects`?`切换到项目…`:`键入命令…`}),(0,I.jsx)(`div`,{children:e===`projects`?c.map(e=>(0,I.jsxs)(`button`,{onClick:()=>a(e.workspace),children:[(0,I.jsx)(xf,{name:`folder`}),(0,I.jsx)(`span`,{children:e.label||xe(e.workspace)}),(0,I.jsx)(`small`,{children:e.workspace})]},e.workspace)):s.map(e=>(0,I.jsxs)(`button`,{onClick:()=>o(e.id),children:[(0,I.jsx)(`span`,{children:e.label}),(0,I.jsx)(`kbd`,{children:e.hint})]},e.id))})]})})}function Xd({railCollapsed:e,onToggleRail:t,onMenu:n,canBack:r,canForward:i,onBack:a,onForward:o}){return(0,I.jsxs)(`header`,{className:`window-titlebar`,children:[(0,I.jsx)(`button`,{className:`titlebar-icon sidebar-toggle`,"data-collapsed":e,onClick:t,"aria-label":e?`显示项目栏`:`隐藏项目栏`,title:e?`显示项目栏`:`隐藏项目栏`,children:(0,I.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,I.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`11`,height:`11`,rx:`2`}),(0,I.jsx)(`path`,{d:`M6 3v10`})]})}),(0,I.jsx)(`button`,{className:`titlebar-icon nav-button`,disabled:!r,onClick:a,"aria-label":`后退`,title:`后退 (Ctrl+[)`,children:(0,I.jsx)(`span`,{children:`‹`})}),(0,I.jsx)(`button`,{className:`titlebar-icon nav-button`,disabled:!i,onClick:o,"aria-label":`前进`,title:`前进 (Ctrl+])`,children:(0,I.jsx)(`span`,{children:`›`})}),(0,I.jsxs)(`nav`,{className:`titlebar-menus`,"aria-label":`应用菜单`,children:[(0,I.jsx)(`button`,{onClick:e=>n(`file`,e),children:`文件`}),(0,I.jsx)(`button`,{onClick:e=>n(`edit`,e),children:`编辑`}),(0,I.jsx)(`button`,{onClick:e=>n(`view`,e),children:`视图`}),(0,I.jsx)(`button`,{onClick:e=>n(`help`,e),children:`帮助`})]})]})}function Zd(e,t,n,r,i){e.type===`snapshot`?(t.current=e.snapshot.activeSession?.sessionId,n(e.snapshot)):e.type===`session-started`?(t.current=e.payload.sessionId,n(e.payload.snapshot),r(S(x(),{type:`restore`,state:e.payload.restoredTranscript}))):e.type===`session-output`?r(n=>we(n,t.current,e)):e.type===`runtime-error`&&(e.sessionId===void 0||e.sessionId===t.current)&&i(e.message)}function Qd({turn:e,active:t=!1}){let n=t?e.blocks:e.blocks.filter(e=>e.kind!==`status`||e.task===void 0);return(0,I.jsxs)(`article`,{className:`turn`,"data-active":t,"data-kind":e.kind??`conversation`,children:[(0,I.jsx)(`div`,{className:`user-message`,children:(0,I.jsx)(`span`,{children:e.prompt})}),(0,I.jsxs)(`div`,{className:`assistant-message`,children:[(0,I.jsx)(`div`,{className:`assistant-avatar`,children:(0,I.jsx)(Sf,{})}),(0,I.jsxs)(`div`,{className:`turn-content`,children:[n.map((e,t)=>(0,I.jsx)($d,{block:e},e.kind===`status`?e.id:`text-${t}`)),t&&n.length===0&&(0,I.jsxs)(`div`,{className:`thinking-line`,children:[(0,I.jsx)(`i`,{}),(0,I.jsx)(`span`,{children:`正在理解任务…`})]})]})]})]})}function $d({block:e}){if(e.kind===`text`)return(0,I.jsx)(`div`,{className:`assistant-copy`,children:(0,I.jsx)(Jt,{text:e.text})});let t=e.state===`completed`?`✓`:e.state===`failed`?`×`:e.state===`cancelled`?`–`:e.state===`running`?``:`·`;return(0,I.jsxs)(`div`,{className:`activity-card`,"data-state":e.state,"data-tone":e.tone,children:[(0,I.jsx)(`span`,{className:`activity-node`,children:t}),(0,I.jsxs)(`div`,{className:`activity-body`,children:[(0,I.jsxs)(`div`,{className:`activity-title`,children:[(0,I.jsx)(`span`,{children:e.text.replace(/^[·✓×]\s*/,``)}),e.hint&&(0,I.jsx)(`code`,{children:e.hint})]}),e.progress!==void 0&&(0,I.jsx)(`div`,{className:`progress-track`,children:(0,I.jsx)(`i`,{style:{width:`${e.progress}%`}})}),e.presentation?.kind===`file-change`&&(0,I.jsx)(tf,{presentation:e.presentation}),e.presentation?.kind===`generic`&&(0,I.jsxs)(`div`,{className:`tool-presentation`,children:[(0,I.jsx)(`strong`,{children:e.presentation.title}),e.presentation.summary&&(0,I.jsx)(`span`,{children:e.presentation.summary})]}),e.presentation?.kind===`terminal`&&(0,I.jsxs)(`div`,{className:`tool-presentation`,children:[(0,I.jsx)(`strong`,{children:e.presentation.title}),e.presentation.stdout&&(0,I.jsx)(`pre`,{children:e.presentation.stdout})]}),e.presentation?.kind===`web`&&(0,I.jsxs)(`div`,{className:`tool-presentation`,children:[(0,I.jsx)(`strong`,{children:e.presentation.title}),e.presentation.summary&&(0,I.jsx)(`span`,{children:e.presentation.summary})]}),e.tool&&(0,I.jsxs)(`details`,{className:`tool-details`,children:[(0,I.jsx)(`summary`,{children:`调用详情`}),(0,I.jsx)(`label`,{children:`Input`}),(0,I.jsx)(`pre`,{children:ef(e.tool.input)}),e.tool.result===void 0?null:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`label`,{children:`Result`}),(0,I.jsx)(`pre`,{children:ef(e.tool.result)})]})]}),e.details&&(0,I.jsxs)(`details`,{className:`timeline-details`,children:[(0,I.jsx)(`summary`,{children:`压缩摘要`}),(0,I.jsx)(Jt,{text:e.details})]})]})]})}function ef(e,t=1e4){let n;try{n=JSON.stringify(e,null,2)??`undefined`}catch{n=String(e)}return n.length<=t?n:`${n.slice(0,t)}…`}function tf({presentation:e}){let t=e.operation===`delete`,n=e.operation===`create`?`新建`:e.operation===`delete`?`删除`:`修改`,r=e.path.replace(/^.*[/\\]/,``),i=t?1:Math.max(1,...e.lines.map(e=>Math.max(e.oldLine??0,e.newLine??0))).toString().length;return(0,I.jsxs)(`details`,{className:`diff-preview`,children:[(0,I.jsxs)(`summary`,{children:[(0,I.jsx)(`span`,{className:`diff-marker ${t?`diff-delete`:`diff-add`}`,children:`●`}),(0,I.jsx)(`span`,{className:`diff-label`,children:n}),(0,I.jsx)(`span`,{className:`diff-path`,children:r}),(0,I.jsxs)(`span`,{className:`diff-counts`,children:[!t&&(0,I.jsxs)(`span`,{className:`diff-added-count`,children:[`+`,e.added]}),!t&&e.removed>0&&(0,I.jsxs)(`span`,{className:`diff-removed-count`,children:[` −`,e.removed]}),t&&(0,I.jsxs)(`span`,{className:`diff-removed-count`,children:[`−`,e.removed]})]})]}),t?null:(0,I.jsx)(`div`,{className:`diff-body`,children:e.lines.map((e,t)=>(0,I.jsx)(nf,{line:e,lineWidth:i},t))})]})}function nf({line:e,lineWidth:t}){let n=e.kind===`removed`||e.kind===`context`?e.oldLine:e.newLine,r=e.kind===`removed`?`-`:e.kind===`added`?`+`:e.kind===`omitted`?`…`:` `;return(0,I.jsxs)(`div`,{className:`diff-row ${e.kind===`added`?`diff-row-added`:e.kind===`removed`?`diff-row-removed`:e.kind===`omitted`?`diff-row-omitted`:`diff-row-context`}`,children:[(0,I.jsx)(`span`,{className:`diff-line-number`,children:String(n??``).padStart(t)}),(0,I.jsx)(`span`,{className:`diff-line-marker`,children:r}),(0,I.jsx)(`span`,{className:`diff-line-text`,children:e.text})]})}function rf(e){let t=e.snapshot.workspace===void 0,[n,r]=(0,_.useState)(!1),i=(0,_.useRef)(null),a=e.slashCompletion!==null,o=e.mentionCompletion!==null,s=a||o,c=e.completedTokenLen>0,l=c?e.input.slice(0,e.completedTokenLen):void 0,u=l?.startsWith(`/`)?l.slice(1).trim():l?.trim(),d=c?void 0:e.mentionSpan,f=d!==void 0&&d.start>=0&&d.end>d.start&&d.start<e.input.length&&d.end<=e.input.length&&e.input.slice(d.start,d.end)===e.input.slice(d.start,d.end),p=f?e.input.slice(0,d.start):``,m=f?e.input.slice(d.start,d.end):``,h=f?e.input.slice(d.end):``,g=m.startsWith(`@`)?m.slice(1).trim():m,v=c?e.input.slice(e.completedTokenLen):f?h:e.input,y=c?l.length:f?d.start+m.length:0,b=e=>y+e,x=t=>{if(a){if(t.key===`ArrowDown`){t.preventDefault(),e.onSlashMove(1);return}if(t.key===`ArrowUp`){t.preventDefault(),e.onSlashMove(-1);return}if(t.key===`Tab`||t.key===`Enter`){t.preventDefault();let n=e.slashCompletion?.items[e.slashCompletion?.selectedIndex??0];n!==void 0&&e.onSlashSelect(n.name);return}if(t.key===`Escape`){t.preventDefault(),e.onSlashDismiss();return}}if(o){if(t.key===`ArrowDown`){t.preventDefault(),e.onMentionMove(1);return}if(t.key===`ArrowUp`){t.preventDefault(),e.onMentionMove(-1);return}if(t.key===`Tab`||t.key===`Enter`){t.preventDefault();let n=e.mentionCompletion?.items[e.mentionCompletion?.selectedIndex??0];n!==void 0&&e.onMentionSelect(n);return}if(t.key===`Escape`){t.preventDefault(),e.onMentionDismiss();return}}let n=t.target,r=n.selectionStart,i=n.selectionEnd;if(t.key===`Backspace`&&r===i&&!s){if(c){let n=rn(e.input,e.completedTokenLen,b(r));if(n!==null){t.preventDefault(),e.setInput(n.text),e.setCursorPos(n.cursor);return}}if(f&&r===0){t.preventDefault();let n=p+h;e.setInput(n),e.setMentionSpan(void 0),e.setCursorPos(p.length);return}}t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),e.onSend(t.altKey?`followUp`:e.busy?`steer`:void 0))},S=(t,n)=>{let r;if(r=c?l+t:f?p+m+t:t,f){let t=p+m;r.startsWith(t)||e.setMentionSpan(void 0)}e.setInput(r),e.setCursorPos(b(n))},C=t=>{e.setCursorPos(b(t))},w=(0,I.jsx)(`textarea`,{ref:e.inputRef,className:`composer-textarea`,value:v,onChange:e=>S(e.target.value,e.target.selectionStart),onSelect:e=>C(e.target.selectionStart),onKeyDown:x,onPaste:t=>{let n=af(t.clipboardData.files);n.length!==0&&(t.preventDefault(),e.onAddImages(n))},onClick:e=>C(e.target.selectionStart),placeholder:t?`先打开一个项目`:c||f?``:`给 Flavor 一个任务,或输入 / 查看命令`,disabled:t,rows:1}),ee=c?(0,I.jsxs)(`div`,{className:`composer-input-row`,children:[(0,I.jsx)(`span`,{className:`slash-tag`,children:u}),w]}):f?(0,I.jsxs)(`div`,{className:`composer-input-row`,children:[p.length>0&&(0,I.jsx)(`span`,{className:`composer-plain-text`,children:p}),(0,I.jsx)(`span`,{className:`mention-tag`,children:g}),w]}):w;return(0,I.jsxs)(`div`,{className:`composer-wrap`,onDragEnter:e=>{of(e.dataTransfer)&&(e.preventDefault(),r(!0))},onDragOver:e=>{of(e.dataTransfer)&&e.preventDefault()},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||r(!1)},onDrop:t=>{let n=af(t.dataTransfer.files);n.length!==0&&(t.preventDefault(),r(!1),e.onAddImages(n))},children:[a&&(0,I.jsx)(cn,{completion:e.slashCompletion,onSelect:e.onSlashSelect,onDismiss:e.onSlashDismiss}),o&&(0,I.jsx)(dn,{completion:e.mentionCompletion,onSelect:e.onMentionSelect,onDismiss:e.onMentionDismiss}),(0,I.jsxs)(`div`,{className:`composer${c||f?` has-tag`:``}`,"data-busy":e.busy,"data-image-drag":n,children:[e.attachments.length>0&&(0,I.jsx)(Gd,{attachments:e.attachments,onRemove:e.onRemoveImage}),ee,(0,I.jsxs)(`div`,{className:`composer-tools`,children:[(0,I.jsx)(`input`,{ref:i,className:`image-file-input`,type:`file`,accept:`image/png,image/jpeg,image/webp`,multiple:!0,onChange:t=>{e.onAddImages(af(t.target.files)),t.target.value=``}}),(0,I.jsxs)(`button`,{type:`button`,className:`attach-button attach-button-labeled image-attach-button`,title:`添加图片(也可粘贴或拖入)`,"aria-label":`添加图片`,onClick:()=>i.current?.click(),disabled:t||e.busy||e.attachments.length>=Bd,children:[(0,I.jsx)(xf,{name:`image`}),(0,I.jsx)(`span`,{children:`图片`})]}),(0,I.jsxs)(`button`,{className:`attach-button attach-button-labeled`,title:`在提示中输入 @ 引用项目文件`,onClick:()=>{e.setInput(`${e.input}${e.input?` `:``}@`),setTimeout(()=>{let t=e.inputRef.current;t!==null&&(t.focus(),t.setSelectionRange(t.value.length,t.value.length))},0)},disabled:t,children:[(0,I.jsx)(xf,{name:`at`}),(0,I.jsx)(`span`,{children:`文件`})]}),(0,I.jsxs)(`div`,{className:`composer-context`,children:[(0,I.jsxs)(`span`,{className:`context-item`,title:e.snapshot.workspace,children:[(0,I.jsx)(xf,{name:`folder`}),(0,I.jsx)(`span`,{children:xe(e.snapshot.workspace)})]}),(0,I.jsxs)(`span`,{className:`context-item`,children:[(0,I.jsx)(xf,{name:`monitor`}),(0,I.jsx)(`span`,{children:`本地`})]})]}),(0,I.jsxs)(`div`,{className:`composer-controls`,children:[(0,I.jsx)(Ef,{models:e.snapshot.models,activeModel:e.snapshot.activeSession?.mainModel,busy:e.busy,onSelect:e.setModel,onAdd:e.addModel}),(0,I.jsx)(`select`,{"aria-label":`权限模式`,value:e.snapshot.activeSession?.permissionMode??`default`,disabled:e.busy||e.snapshot.activeSession===void 0,onChange:t=>e.setPermission(t.target.value),children:Rd.map(e=>(0,I.jsx)(`option`,{value:e,children:ye(e)},e))}),e.busy&&(0,I.jsxs)(`span`,{className:`queue-count`,title:`引导 + 后续消息`,children:[e.snapshot.activeSession?.queue.steering.length??0,`+`,e.snapshot.activeSession?.queue.followUp.length??0]}),(0,I.jsx)(`button`,{className:`send-button`,onClick:()=>e.onSend(e.busy?`steer`:void 0),disabled:t||!e.input.trim()&&e.attachments.length===0,title:e.busy?`发送引导消息`:`发送`,children:(0,I.jsx)(`span`,{children:`↑`})}),e.busy&&(0,I.jsx)(`button`,{className:`send-button stop-button`,onClick:e.onInterrupt,title:`停止任务`,children:(0,I.jsx)(`span`,{})})]})]})]}),(0,I.jsx)(`p`,{className:`composer-hint`,children:`Enter 发送 · Shift Enter 换行 · 粘贴/拖入图片 · @ 引用文件 · / 调用命令`})]})}function af(e){return e===null?[]:Array.from(e).filter(e=>e.type.startsWith(`image/`))}function of(e){return Array.from(e.items).some(e=>e.kind===`file`&&e.type.startsWith(`image/`))}async function sf(e){if(!Ud.has(e.type))throw Error(`不支持 ${e.type||`未知格式`};请选择 PNG、JPEG 或 WebP 图片。`);if(e.size<=0)throw Error(`${e.name} 是空文件。`);if(e.size>Vd)throw Error(`${e.name} 超过单图 5 MiB 限制。`);let t=cf(new Uint8Array(await e.arrayBuffer())),n=URL.createObjectURL(e);return{id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`,name:e.name,mediaType:e.type,dataBase64:t,previewUrl:n}}function cf(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}function lf({session:e,deleting:t,onCancel:n,onDelete:r}){return(0,I.jsx)(`div`,{className:`modal-layer`,children:(0,I.jsxs)(`section`,{className:`decision-sheet delete-session-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`delete-session-title`,children:[(0,I.jsx)(`div`,{className:`sheet-icon danger`,children:`×`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`sheet-kicker`,children:`删除历史会话`}),(0,I.jsxs)(`h2`,{id:`delete-session-title`,children:[`删除“`,be(e),`”?`]}),(0,I.jsx)(`p`,{children:`此会话的消息和任务记录将从当前项目中永久删除,此操作无法撤销。`}),(0,I.jsxs)(`div`,{className:`sheet-actions`,children:[(0,I.jsx)(`button`,{disabled:t,onClick:n,children:`取消`}),(0,I.jsx)(`button`,{className:`danger`,disabled:t,onClick:r,children:t?`正在删除…`:`删除会话`})]})]})]})})}var uf=new Set([`Delete`,`Move`,`RemoveTool`]);function df({approval:e,onResolve:t}){let n=uf.has(e.tool)||e.allowAlways===!1;return(0,I.jsx)(`div`,{className:`modal-layer`,children:(0,I.jsxs)(`section`,{className:`decision-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`approval-title`,children:[(0,I.jsx)(`div`,{className:`sheet-icon warning`,children:`!`}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`p`,{className:`sheet-kicker`,children:[`权限确认 · `,e.agent===`main`?`主 Agent`:`子 Agent`]}),(0,I.jsxs)(`h2`,{id:`approval-title`,children:[`允许执行 `,e.tool,`?`]}),(0,I.jsx)(`p`,{children:e.reason??`这项操作需要你的确认。`}),(e.command||e.paths?.length)&&(0,I.jsxs)(`pre`,{children:[e.command??e.paths?.join(`
|
|
154
154
|
`),e.args?.length?` ${e.args.join(` `)}`:``]}),(0,I.jsxs)(`div`,{className:`sheet-actions`,children:[(0,I.jsx)(`button`,{onClick:()=>t(`deny`),children:`拒绝`}),!n&&(0,I.jsx)(`button`,{onClick:()=>t(`always`),children:`始终允许同类操作`}),(0,I.jsx)(`button`,{className:`primary`,onClick:()=>t(`allow`),children:`允许一次`})]})]})]})})}function ff({questions:e,onAnswer:t}){let[n,r]=(0,_.useState)({}),[i,a]=(0,_.useState)({}),o=e.every((e,t)=>!!n[t]?.trim());return(0,I.jsx)(`div`,{className:`modal-layer`,children:(0,I.jsxs)(`section`,{className:`question-sheet`,role:`dialog`,"aria-modal":`true`,children:[(0,I.jsx)(`p`,{className:`sheet-kicker`,children:`Flavor 需要确认`}),e.map((e,t)=>(0,I.jsxs)(`fieldset`,{children:[(0,I.jsx)(`legend`,{children:e.header}),(0,I.jsx)(`p`,{children:e.question}),(0,I.jsxs)(`div`,{className:`question-options`,children:[e.options.map(e=>(0,I.jsxs)(`button`,{"data-selected":!i[t]&&n[t]===e.label,onClick:()=>{a(e=>({...e,[t]:!1})),r(n=>({...n,[t]:e.label}))},children:[(0,I.jsx)(`strong`,{children:e.label}),(0,I.jsx)(`span`,{children:e.description})]},e.label)),(0,I.jsxs)(`button`,{"data-selected":i[t]===!0,onClick:()=>{a(e=>({...e,[t]:!0})),r(e=>({...e,[t]:``}))},children:[(0,I.jsx)(`strong`,{children:`其他(自定义输入)`}),(0,I.jsx)(`span`,{children:`键入你自己的回答`})]}),i[t]===!0&&(0,I.jsx)(`input`,{className:`question-custom-input`,autoFocus:!0,value:n[t]??``,onChange:e=>r(n=>({...n,[t]:e.target.value})),placeholder:`请输入回答`,"aria-label":`${e.header} 自定义回答`})]})]},`${e.header}-${t}`)),(0,I.jsx)(`div`,{className:`sheet-actions`,children:(0,I.jsx)(`button`,{className:`primary`,disabled:!o,onClick:()=>t(n),children:`继续`})})]})})}function pf({reviews:e,autoDismissSeconds:t,onResolve:n}){return(0,I.jsxs)(`aside`,{className:`memory-review-rail`,"aria-label":`长期记忆写入确认`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{children:`待确认`}),(0,I.jsx)(`h2`,{children:`长期记忆候选`})]}),(0,I.jsx)(`span`,{children:e.length})]}),(0,I.jsx)(`p`,{className:`memory-review-warning`,children:`以下内容由模型生成,确认前不会写入长期记忆,也不会影响后续会话。`}),(0,I.jsx)(`div`,{className:`memory-review-list`,children:e.map(e=>(0,I.jsxs)(`article`,{children:[(0,I.jsx)(`small`,{children:e.type}),(0,I.jsx)(`p`,{children:e.content}),(0,I.jsx)(mf,{seconds:t}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`button`,{onClick:()=>n(e.id,`dismiss`),children:`忽略`}),(0,I.jsx)(`button`,{className:`primary`,onClick:()=>n(e.id,`accept`),children:`保存`})]})]},e.id))})]})}function mf({seconds:e}){let[t,n]=(0,_.useState)(e);return(0,_.useEffect)(()=>{if(e<=0)return;n(e);let t=setInterval(()=>n(e=>Math.max(0,e-1)),1e3);return()=>clearInterval(t)},[e]),e<=0?null:(0,I.jsxs)(`small`,{className:`memory-review-countdown`,children:[`未操作将在 `,t,`s 后自动忽略`]})}function hf({project:e,onStart:t}){return(0,I.jsxs)(`section`,{className:`welcome-state`,children:[(0,I.jsx)(`div`,{className:`welcome-mark`,children:(0,I.jsx)(Sf,{})}),(0,I.jsx)(`p`,{children:`已连接本地项目`}),(0,I.jsxs)(`h1`,{children:[`我们应该在 `,(0,I.jsx)(`u`,{children:e}),` 中构建什么?`]}),(0,I.jsx)(`div`,{className:`starter-grid`,children:_e.map(e=>(0,I.jsx)(`button`,{onClick:()=>t(e),children:e},e))})]})}function gf({onOpen:e}){return(0,I.jsxs)(`section`,{className:`open-state`,children:[(0,I.jsx)(`div`,{className:`welcome-mark`,children:(0,I.jsx)(Sf,{})}),(0,I.jsx)(`h1`,{children:`从一个本地项目开始`}),(0,I.jsx)(`p`,{children:`Flavor 会在你选择的文件夹范围内阅读、修改和运行代码。`}),(0,I.jsx)(`button`,{onClick:e,children:`打开项目`})]})}function _f(){return(0,I.jsxs)(`div`,{className:`loading-state`,children:[(0,I.jsx)(Sf,{}),(0,I.jsx)(`span`,{children:`正在准备桌面工作区…`})]})}var vf;function yf(){return vf??=window.flavorDesktop.appIcon().catch(()=>void 0),vf}function bf(){let[e,t]=(0,_.useState)(void 0);return(0,_.useEffect)(()=>{let e=!1;return yf().then(n=>{e||t(n)}),()=>{e=!0}},[]),e}function xf({name:e}){let t;switch(e){case`plus`:t=(0,I.jsx)(`path`,{d:`M10 4v12M4 10h12`});break;case`folder`:t=(0,I.jsx)(`path`,{d:`M2.75 6.25h5l1.5 1.75h8v7.25a1.5 1.5 0 0 1-1.5 1.5h-12a1.5 1.5 0 0 1-1.5-1.5v-7.5a1.5 1.5 0 0 1 1.5-1.5Z`});break;case`sparkles`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`path`,{d:`M8.25 3.25c.4 2.4 1.6 3.6 4 4-2.4.4-3.6 1.6-4 4-.4-2.4-1.6-3.6-4-4 2.4-.4 3.6-1.6 4-4Z`}),(0,I.jsx)(`path`,{d:`M14.5 11.5c.25 1.45 1.05 2.25 2.5 2.5-1.45.25-2.25 1.05-2.5 2.5-.25-1.45-1.05-2.25-2.5-2.5 1.45-.25 2.25-1.05 2.5-2.5Z`})]});break;case`database`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`ellipse`,{cx:`10`,cy:`5`,rx:`6.25`,ry:`2.5`}),(0,I.jsx)(`path`,{d:`M3.75 5v5c0 1.38 2.8 2.5 6.25 2.5s6.25-1.12 6.25-2.5V5M3.75 10v5c0 1.38 2.8 2.5 6.25 2.5s6.25-1.12 6.25-2.5v-5`})]});break;case`server`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`rect`,{x:`3`,y:`3.5`,width:`14`,height:`5`,rx:`1.5`}),(0,I.jsx)(`rect`,{x:`3`,y:`11.5`,width:`14`,height:`5`,rx:`1.5`}),(0,I.jsx)(`path`,{d:`M6 6h.01M6 14h.01M9 6h5M9 14h5`})]});break;case`checklist`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`rect`,{x:`3.25`,y:`2.75`,width:`13.5`,height:`14.5`,rx:`2`}),(0,I.jsx)(`path`,{d:`m6.25 7 1.25 1.25L10 5.75M11.75 7h2M6.25 12h1.5M10 12h4`})]});break;case`image`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`rect`,{x:`2.75`,y:`3.25`,width:`14.5`,height:`13.5`,rx:`2`}),(0,I.jsx)(`circle`,{cx:`7`,cy:`7.25`,r:`1.25`}),(0,I.jsx)(`path`,{d:`m4.75 14 3.5-3.5 2.25 2.25 2.25-2.5 2.5 3.75`})]});break;case`at`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`circle`,{cx:`9.5`,cy:`10`,r:`3`}),(0,I.jsx)(`path`,{d:`M12.5 10v1.25c0 1.15.8 1.75 1.75 1.75 1.4 0 2.25-1.2 2.25-3a6.5 6.5 0 1 0-2.1 4.78`})]});break;case`monitor`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`rect`,{x:`2.75`,y:`3.5`,width:`14.5`,height:`10.5`,rx:`2`}),(0,I.jsx)(`path`,{d:`M7 17h6M10 14v3`})]});break;case`bell`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`path`,{d:`M5.25 8.5a4.75 4.75 0 0 1 9.5 0c0 5 2 5.5 2 5.5H3.25s2-.5 2-5.5Z`}),(0,I.jsx)(`path`,{d:`M8 16a2.25 2.25 0 0 0 4 0`})]});break;case`git`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`circle`,{cx:`5`,cy:`4`,r:`1.75`}),(0,I.jsx)(`circle`,{cx:`15`,cy:`6.5`,r:`1.75`}),(0,I.jsx)(`circle`,{cx:`5`,cy:`16`,r:`1.75`}),(0,I.jsx)(`path`,{d:`M5 5.75v8.5M6.75 7.5C11 7.5 10.5 6.5 13.25 6.5`})]});break;case`search`:t=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`circle`,{cx:`8.75`,cy:`8.75`,r:`5.25`}),(0,I.jsx)(`path`,{d:`m12.5 12.5 4 4`})]});break}return(0,I.jsx)(`svg`,{className:`ui-icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,focusable:`false`,children:t})}function Sf(){let e=bf();return e===void 0?(0,I.jsxs)(`svg`,{className:`flavor-mark`,viewBox:`0 0 36 36`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{d:`M8 17.5C8 11.7 12.5 7 18 7s10 4.7 10 10.5c0 2.7-1 5.1-2.7 7l1 3.8-4-1.2A9.5 9.5 0 0 1 18 28c-5.5 0-10-4.7-10-10.5Z`}),(0,I.jsx)(`path`,{d:`M16 15l-2 2l2 2`,fill:`none`,stroke:`#1979c9`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,I.jsx)(`path`,{d:`M20 15l2 2l-2 2`,fill:`none`,stroke:`#1979c9`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,I.jsx)(`path`,{className:`mark-smile`,d:`M14 23c2.5 1.5 5.5 1.5 8 0`}),(0,I.jsx)(`ellipse`,{cx:`22`,cy:`24`,rx:`1.2`,ry:`0.9`,fill:`#f472b6`,stroke:`#ec4899`,strokeWidth:`0.3`,transform:`rotate(15 22 24)`})]}):(0,I.jsx)(`img`,{className:`flavor-mark`,src:e,alt:``,"aria-hidden":`true`})}function Cf(e){return e instanceof Error?e.message:String(e)}function wf(e){return e.replace(/^session-/,``).slice(0,17)}function Tf(e){return e?e.split(`:`).at(-1)??e:`选择模型`}function Ef({models:e,activeModel:t,busy:n,onSelect:r,onAdd:i}){let[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(),[d,f]=(0,_.useState)({provider:``,model:``,baseURL:``,apiKey:``,protocol:`openai-compatible`}),p=t??e[0]?.id,m=e.find(e=>e.id===p),h=m?.label??Tf(p),g=(e,t)=>{f(n=>({...n,[e]:t})),u(void 0)},v=async e=>{if(e.preventDefault(),s)return;let t=e.currentTarget;c(!0),u(void 0);try{await i(d),o(!1),f({provider:``,model:``,baseURL:``,apiKey:``,protocol:`openai-compatible`}),t.closest(`details`)?.removeAttribute(`open`)}catch(e){u(Cf(e))}finally{c(!1)}};return(0,I.jsxs)(`details`,{className:`model-menu`,children:[(0,I.jsxs)(`summary`,{"aria-label":`主模型:${h}`,title:`切换主模型`,children:[(0,I.jsx)(`span`,{className:`model-status-dot`,"data-configured":m!==void 0}),(0,I.jsx)(`span`,{className:`model-summary-label`,children:h}),(0,I.jsx)(`span`,{className:`model-summary-chevron`,"aria-hidden":`true`})]}),(0,I.jsxs)(`div`,{className:`popover model-popover`,children:[(0,I.jsxs)(`div`,{className:`model-popover-heading`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:a?`添加厂商模型`:`切换主模型`}),(0,I.jsx)(`span`,{children:a?`连接 OpenAI 兼容或 Anthropic 服务`:`DeepSeek 默认可用,也可接入其他厂商`})]}),!a&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>o(!0),disabled:n,children:`+ 新增`})]}),a?(0,I.jsxs)(`form`,{className:`model-provider-form`,onSubmit:e=>void v(e),children:[(0,I.jsxs)(`div`,{className:`model-form-grid`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`厂商名称 / ID`}),(0,I.jsx)(`input`,{required:!0,maxLength:64,placeholder:`例如 siliconflow`,value:d.provider,onChange:e=>g(`provider`,e.target.value),pattern:`[A-Za-z0-9][A-Za-z0-9_-]*`})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`模型名称`}),(0,I.jsx)(`input`,{required:!0,maxLength:256,placeholder:`例如 qwen3-coder`,value:d.model,onChange:e=>g(`model`,e.target.value)})]})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`接口协议`}),(0,I.jsxs)(`select`,{value:d.protocol,onChange:e=>g(`protocol`,e.target.value),children:[(0,I.jsx)(`option`,{value:`openai-compatible`,children:`OpenAI 兼容 API`}),(0,I.jsx)(`option`,{value:`anthropic`,children:`Anthropic API`})]})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`Base URL`}),(0,I.jsx)(`input`,{required:!0,type:`url`,maxLength:2048,placeholder:`https://api.example.com/v1`,value:d.baseURL,onChange:e=>g(`baseURL`,e.target.value)})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:`API Key`}),(0,I.jsx)(`input`,{required:!0,type:`password`,autoComplete:`off`,maxLength:16384,placeholder:`输入服务密钥`,value:d.apiKey,onChange:e=>g(`apiKey`,e.target.value)})]}),(0,I.jsxs)(`p`,{className:`model-security-note`,children:[(0,I.jsx)(`span`,{children:`◆`}),` 配置同步到当前项目,密钥只加密保存在本机。保存后会新建会话。`]}),l!==void 0&&(0,I.jsx)(`p`,{className:`model-form-error`,role:`alert`,children:l}),(0,I.jsxs)(`div`,{className:`model-form-actions`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),u(void 0)},disabled:s,children:`取消`}),(0,I.jsx)(`button`,{type:`submit`,className:`primary`,disabled:s||n,children:s?`正在连接…`:`保存并切换`})]})]}):(0,I.jsx)(`div`,{className:`model-options`,role:`listbox`,"aria-label":`主模型`,children:e.map(e=>{let t=p===e.id;return(0,I.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:`model-option`,disabled:n||t,onClick:t=>{r(e.id),t.currentTarget.closest(`details`)?.removeAttribute(`open`)},children:[(0,I.jsxs)(`span`,{className:`model-option-copy`,children:[(0,I.jsx)(`strong`,{children:e.label}),(0,I.jsx)(`small`,{children:e.description})]}),e.source===`custom`&&(0,I.jsx)(`span`,{className:`model-option-badge`,children:`自定义`}),(0,I.jsx)(`span`,{className:`model-option-state`,"aria-hidden":`true`,children:t?`✓`:`→`})]},e.id)})})]})]})}function Df(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})}var Of=document.getElementById(`root`);if(Of===null)throw Error(`Desktop root element was not found`);(0,v.createRoot)(Of).render((0,I.jsx)(_.StrictMode,{children:(0,I.jsx)(Kd,{})}));export{c as i,Kt as n,u as r,sd as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,n as t,r as n,t as r}from"./index-CnGHSdJ6.js";var i=e(n(),1),a=2,o=1,s=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),s=window.getComputedStyle(this._terminal.element),c={top:parseInt(s.getPropertyValue(`padding-top`)),bottom:parseInt(s.getPropertyValue(`padding-bottom`)),right:parseInt(s.getPropertyValue(`padding-right`)),left:parseInt(s.getPropertyValue(`padding-left`))},l=c.top+c.bottom,u=c.right+c.left,d=r-l,f=i-u-t;return{cols:Math.max(a,Math.floor(f/e.css.cell.width)),rows:Math.max(o,Math.floor(d/e.css.cell.height))}}},c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=(e,t)=>{for(var n in t)c(e,n,{get:t[n],enumerable:!0})},d=(e,t,n,r)=>{for(var i=r>1?void 0:r?l(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&c(t,n,i),i},f=(e,t)=>(n,r)=>t(n,r,e),p=`Terminal input`,m={get:()=>p,set:e=>p=e},h=`Too much output to announce, navigate to rows manually to read`,g={get:()=>h,set:e=>h=e};function _(e){return e.replace(/\r?\n/g,`\r`)}function ee(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function te(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function ne(e,t,n,r){e.stopPropagation(),e.clipboardData&&re(e.clipboardData.getData(`text/plain`),t,n,r)}function re(e,t,n,r){e=_(e),e=ee(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ie(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ae(e,t,n,r,i){ie(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function v(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function oe(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var se=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},y=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},ce=``,le=` `,ue=class e{constructor(){this.fg=0,this.bg=0,this.extended=new b}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},b=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},x=class e extends ue{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new b,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?v(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},de=`di$target`,fe=`di$dependencies`,S=new Map;function pe(e){return e[fe]||[]}function C(e){if(S.has(e))return S.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);me(t,e,r)};return t._id=e,S.set(e,t),t}function me(e,t,n){t[de]===t?t[fe].push({id:e,index:n}):(t[fe]=[{id:e,index:n}],t[de]=t)}var w=C(`BufferService`),he=C(`CoreMouseService`),T=C(`CoreService`),ge=C(`CharsetService`),E=C(`InstantiationService`),_e=C(`LogService`),D=C(`OptionsService`),ve=C(`OscLinkService`),ye=C(`UnicodeService`),be=C(`DecorationService`),xe=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new x,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Se(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};xe=d([f(0,w),f(1,D),f(2,ve)],xe);function Se(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
1
|
+
import{i as e,n as t,r as n,t as r}from"./index-bFGsR_uj.js";var i=e(n(),1),a=2,o=1,s=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),s=window.getComputedStyle(this._terminal.element),c={top:parseInt(s.getPropertyValue(`padding-top`)),bottom:parseInt(s.getPropertyValue(`padding-bottom`)),right:parseInt(s.getPropertyValue(`padding-right`)),left:parseInt(s.getPropertyValue(`padding-left`))},l=c.top+c.bottom,u=c.right+c.left,d=r-l,f=i-u-t;return{cols:Math.max(a,Math.floor(f/e.css.cell.width)),rows:Math.max(o,Math.floor(d/e.css.cell.height))}}},c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=(e,t)=>{for(var n in t)c(e,n,{get:t[n],enumerable:!0})},d=(e,t,n,r)=>{for(var i=r>1?void 0:r?l(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&c(t,n,i),i},f=(e,t)=>(n,r)=>t(n,r,e),p=`Terminal input`,m={get:()=>p,set:e=>p=e},h=`Too much output to announce, navigate to rows manually to read`,g={get:()=>h,set:e=>h=e};function _(e){return e.replace(/\r?\n/g,`\r`)}function ee(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function te(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function ne(e,t,n,r){e.stopPropagation(),e.clipboardData&&re(e.clipboardData.getData(`text/plain`),t,n,r)}function re(e,t,n,r){e=_(e),e=ee(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ie(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ae(e,t,n,r,i){ie(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function v(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function oe(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var se=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},y=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},ce=``,le=` `,ue=class e{constructor(){this.fg=0,this.bg=0,this.extended=new b}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},b=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},x=class e extends ue{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new b,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?v(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},de=`di$target`,fe=`di$dependencies`,S=new Map;function pe(e){return e[fe]||[]}function C(e){if(S.has(e))return S.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);me(t,e,r)};return t._id=e,S.set(e,t),t}function me(e,t,n){t[de]===t?t[fe].push({id:e,index:n}):(t[fe]=[{id:e,index:n}],t[de]=t)}var w=C(`BufferService`),he=C(`CoreMouseService`),T=C(`CoreService`),ge=C(`CharsetService`),E=C(`InstantiationService`),_e=C(`LogService`),D=C(`OptionsService`),ve=C(`OscLinkService`),ye=C(`UnicodeService`),be=C(`DecorationService`),xe=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new x,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Se(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};xe=d([f(0,w),f(1,D),f(2,ve)],xe);function Se(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
2
2
|
|
|
3
3
|
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var Ce=C(`CharSizeService`),we=C(`CoreBrowserService`),Te=C(`MouseService`),Ee=C(`RenderService`),De=C(`SelectionService`),Oe=C(`CharacterJoinerService`),ke=C(`ThemeService`),Ae=C(`LinkProviderService`),je=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Le.isErrorNoTelemetry(e)?new Le(e.message+`
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="color-scheme" content="light" />
|
|
7
7
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self' http://127.0.0.1:* http://localhost:* http://[::1]:* ws://127.0.0.1:* ws://localhost:* ws://[::1]:*; frame-src http://127.0.0.1:* http://localhost:* http://[::1]:*" />
|
|
8
8
|
<title>Flavor Code</title>
|
|
9
|
-
<script type="module" crossorigin src="./assets/index-
|
|
9
|
+
<script type="module" crossorigin src="./assets/index-bFGsR_uj.js"></script>
|
|
10
10
|
<link rel="stylesheet" crossorigin href="./assets/index-CdeAi527.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
package/dist/sdk/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
FlavorRpcServer,
|
|
5
5
|
TraceRecordSchema,
|
|
6
6
|
TraceRecorder
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-RDBTC35M.js";
|
|
8
8
|
import {
|
|
9
9
|
AgentMessageQueue,
|
|
10
10
|
DockerExecutionEnvironment,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
WorkspaceCheckpointStore,
|
|
14
14
|
buildDockerInvocation,
|
|
15
15
|
createProductionRuntime
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-YKSMZDUZ.js";
|
|
17
17
|
import "../chunk-IG4Z23CL.js";
|
|
18
18
|
import "../chunk-RQTYHUMK.js";
|
|
19
19
|
import "../chunk-S32JRDZK.js";
|