@chosengeneration/light-code 0.59.1 → 0.59.6
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/cli.js +89 -21
- package/dist/client/client.js +1 -1
- package/dist/server.js +88 -20
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -42195,9 +42195,19 @@ async function listModels(http, profile, auth2, signal) {
|
|
|
42195
42195
|
function messageOf(error51) {
|
|
42196
42196
|
return error51 instanceof Error ? error51.message : String(error51);
|
|
42197
42197
|
}
|
|
42198
|
+
var TEST_CONNECTION_TIMEOUT_MS = 2e4;
|
|
42198
42199
|
async function testConnection(profile, context, http, signal) {
|
|
42199
42200
|
const steps = [];
|
|
42200
42201
|
const finish = () => ({ ok: steps.every((step) => step.status !== "failed"), steps });
|
|
42202
|
+
const deadline = new AbortController();
|
|
42203
|
+
const timer = setTimeout(() => deadline.abort(), TEST_CONNECTION_TIMEOUT_MS);
|
|
42204
|
+
const onOuterAbort = () => deadline.abort();
|
|
42205
|
+
signal?.addEventListener("abort", onOuterAbort);
|
|
42206
|
+
const bounded = deadline.signal;
|
|
42207
|
+
const release = () => {
|
|
42208
|
+
clearTimeout(timer);
|
|
42209
|
+
signal?.removeEventListener("abort", onOuterAbort);
|
|
42210
|
+
};
|
|
42201
42211
|
if (profile.auth.type === "apigeeMtls") {
|
|
42202
42212
|
try {
|
|
42203
42213
|
let expiryNote = "";
|
|
@@ -42214,6 +42224,7 @@ async function testConnection(profile, context, http, signal) {
|
|
|
42214
42224
|
detail: `Loaded ${loaded?.pfx !== void 0 ? "PFX bundle" : "client certificate and key"}.${expiryNote}`
|
|
42215
42225
|
});
|
|
42216
42226
|
} catch (error51) {
|
|
42227
|
+
release();
|
|
42217
42228
|
steps.push({ step: "certificates", status: "failed", detail: messageOf(error51) });
|
|
42218
42229
|
steps.push({ step: "token", status: "skipped", detail: "Not attempted \u2014 certificates failed to load." });
|
|
42219
42230
|
steps.push({ step: "models", status: "skipped", detail: "Not attempted \u2014 certificates failed to load." });
|
|
@@ -42245,16 +42256,28 @@ async function testConnection(profile, context, http, signal) {
|
|
|
42245
42256
|
detail: profile.auth.type === "tokenCommand" ? "The token command ran and returned a token." : profile.auth.type === "apiKey" && profile.auth.apiKeyRef.startsWith("env:") ? `Key read from ${profile.auth.apiKeyRef.slice("env:".length)}.` : "Credential resolved from secure storage."
|
|
42246
42257
|
});
|
|
42247
42258
|
} catch (error51) {
|
|
42259
|
+
release();
|
|
42248
42260
|
steps.push({ step: "token", status: "failed", detail: messageOf(error51) });
|
|
42249
42261
|
steps.push({ step: "models", status: "skipped", detail: "Not attempted \u2014 no credential." });
|
|
42250
42262
|
return finish();
|
|
42251
42263
|
}
|
|
42252
42264
|
}
|
|
42253
|
-
const result = await listModels(http, profile, auth2,
|
|
42265
|
+
const result = await listModels(http, profile, auth2, bounded);
|
|
42266
|
+
release();
|
|
42254
42267
|
if (result.ids.length > 0) {
|
|
42255
42268
|
steps.push({ step: "models", status: "ok", detail: `Gateway returned ${result.ids.length} model(s).` });
|
|
42269
|
+
} else if (deadline.signal.aborted && signal?.aborted !== true) {
|
|
42270
|
+
steps.push({
|
|
42271
|
+
step: "models",
|
|
42272
|
+
status: "failed",
|
|
42273
|
+
detail: `No response within ${String(Math.round(TEST_CONNECTION_TIMEOUT_MS / 1e3))}s. The address resolved and the connection was accepted, but nothing came back \u2014 check the base URL path and whether anything is filtering this route.`
|
|
42274
|
+
});
|
|
42256
42275
|
} else {
|
|
42257
|
-
steps.push({
|
|
42276
|
+
steps.push({
|
|
42277
|
+
step: "models",
|
|
42278
|
+
status: "note",
|
|
42279
|
+
detail: `${result.warning ?? "No catalogue returned."} This does not by itself mean the connection is broken \u2014 plenty of gateways serve chat completions without publishing /models. Type the model id by hand.`
|
|
42280
|
+
});
|
|
42258
42281
|
}
|
|
42259
42282
|
return finish();
|
|
42260
42283
|
}
|
|
@@ -43981,7 +44004,24 @@ function buildSystemPrompt(workspaceRoot, options = {}) {
|
|
|
43981
44004
|
' write it for them \u2014 "checking which gateway the profile points at", not "reading a file".',
|
|
43982
44005
|
"- Paths are relative to the workspace root. You cannot access anything outside it.",
|
|
43983
44006
|
"- When the task is complete, call attempt_completion with a summary of what you did.",
|
|
43984
|
-
"- If you need information only the user can provide, call ask_followup_question."
|
|
44007
|
+
"- If you need information only the user can provide, call ask_followup_question.",
|
|
44008
|
+
/*
|
|
44009
|
+
* Asked for directly, from real use with a model whose training predates the libraries in
|
|
44010
|
+
* front of it. The failure it addresses is not refusing to answer - it is answering anyway,
|
|
44011
|
+
* from a remembered version of an API, which produces code that looks right and is wrong
|
|
44012
|
+
* against the installed version. The user very often has the page open.
|
|
44013
|
+
*
|
|
44014
|
+
* Phrased as a thing to do rather than a permission, because a model that is unsure is
|
|
44015
|
+
* already reluctant to interrupt, and "you may ask" reads as "prefer not to".
|
|
44016
|
+
*/
|
|
44017
|
+
"- **If a library or API is unfamiliar, or the version here does not match what you remember,",
|
|
44018
|
+
" ask the user for documentation rather than guessing.** Say which library and what you need",
|
|
44019
|
+
" to know - a signature, which module something moved to, whether a call is still supported.",
|
|
44020
|
+
" They can paste it, point you at a file or a URL they have already fetched, or tell you the",
|
|
44021
|
+
" house convention. Recalling an API from a version you were trained on produces code that",
|
|
44022
|
+
" looks correct and fails against the one installed, which is far more expensive than asking.",
|
|
44023
|
+
"- Before asking, check what is here: the imports and existing calls in this workspace are",
|
|
44024
|
+
" evidence about the version actually installed, and a skill may already describe it."
|
|
43985
44025
|
);
|
|
43986
44026
|
if (options.skills !== void 0 && options.skills.length > 0) {
|
|
43987
44027
|
lines.push("", options.skills);
|
|
@@ -44030,7 +44070,7 @@ function buildSystemPrompt(workspaceRoot, options = {}) {
|
|
|
44030
44070
|
lines.push("", "Email:", "- **Always answer questions about email from the index, using search_mail and", " mail_patterns.** That is what it is for. It is fast, it answers questions about time", " and recurrence that a live search cannot, and it does not disturb the running Outlook.", '- **Only search Outlook itself when the user asks you to.** "Check Outlook", "look at my', ' actual mailbox", "is it there now" and anything similar are the instruction to use', " outlook_search. Do not reach for it on your own initiative.", "- If the index has nothing, say so plainly and say when it was last synced. Do not", " quietly fall back to scanning Outlook - a slow live scan that nobody asked for reads", " as the assistant having hung.", "- One exception worth naming: if the user is asking about something that arrived in the", " last few minutes, the index may not have it yet. Say that, and offer to check Outlook", " rather than doing it unasked.", "- **The index holds plain text.** Colours, highlighting and images are not in it. When", " those could carry meaning \u2014 a red line marking a failure, a highlighted cell \u2014 use", " outlook_read_email on the id, which reads the live message and reports the colours.", " Never conclude a message looks fine from indexed text alone.", "- mail_coverage says which folders are indexed and how far back. Check it before saying", " something is not in the mail: an empty search over an unindexed folder looks exactly", " like an empty search over an indexed one.", "- **Use mail_stats for any question with a number in the answer** \u2014 how many alerts per", " folder, per day, per hour, which senders, whether a figure inside the alerts is climbing.", " It counts everything the filters matched. Never count search results by eye: search", " returns a page, so counting what you were shown reports a sample as if it were the total.", "- mail_stats already returns categories, values and detail in the shape show_chart wants.", " Pass it through rather than retyping the numbers, and keep the detail.");
|
|
44031
44071
|
}
|
|
44032
44072
|
if (options.expertAvailable === true) {
|
|
44033
|
-
lines.push("", "Expert consultation:", "- A stronger model, Claude, is available through the
|
|
44073
|
+
lines.push("", "Expert consultation:", "- A stronger model, Claude, is available through the ask_claude tool. You CAN talk to", " it. Never tell the user you have no way to reach another model \u2014 you do.", '- **If the user asks you to consult it, do so.** "Ask Claude", "check with the', ' expert", "what does Claude think" and anything similar are direct instructions.', " It is their money and their decision; do not talk them out of it or decide the", " question is too simple to be worth asking.", "- Otherwise, judge it yourself. It costs real money per call, so on your own", " initiative use it for: planning a change spanning several files, diagnosing a bug", " you have already failed to fix once, choosing between designs with long-lived", " consequences, or reviewing something subtle before committing to it.", "- On your own initiative, do not use it for anything you could answer by reading a", " file, for routine edits, or for restating something already established here.", "- If you decide against consulting it, say that you chose not to and why. Do not say", " you are unable to.", "- The expert can read and search this workspace but cannot edit or run anything. It", " cannot see this conversation, so put the context it needs in your question.", "- You remain responsible for the work. Treat its answer as advice from a colleague:", " verify it against the actual code, and say so if you disagree.");
|
|
44034
44074
|
}
|
|
44035
44075
|
if (options.modeGuidance !== void 0 && options.modeGuidance.length > 0) {
|
|
44036
44076
|
lines.push("", options.modeGuidance);
|
|
@@ -44294,9 +44334,11 @@ var paramsSchema2 = external_exports.object({
|
|
|
44294
44334
|
question: external_exports.string().min(1).describe("The question, with the code and context needed to answer it. The expert cannot see this conversation."),
|
|
44295
44335
|
files: external_exports.array(external_exports.string()).optional().describe("Workspace-relative paths worth reading. The expert can open these itself.")
|
|
44296
44336
|
});
|
|
44337
|
+
var ASK_CLAUDE_TOOL = "ask_claude";
|
|
44338
|
+
var LEGACY_ASK_EXPERT_TOOL = "ask_expert";
|
|
44297
44339
|
function createAskExpertTool(options) {
|
|
44298
44340
|
return {
|
|
44299
|
-
name:
|
|
44341
|
+
name: ASK_CLAUDE_TOOL,
|
|
44300
44342
|
group: "read",
|
|
44301
44343
|
/*
|
|
44302
44344
|
* The rationing is said only where somebody is counting.
|
|
@@ -44312,7 +44354,7 @@ function createAskExpertTool(options) {
|
|
|
44312
44354
|
* byte-stable for a whole session and changes only when the user changes their mind in
|
|
44313
44355
|
* Settings, exactly as switching the dispatcher does.
|
|
44314
44356
|
*/
|
|
44315
|
-
description: "Consult a
|
|
44357
|
+
description: "Consult Claude, running as a separate command line on this machine, about a hard problem: planning a multi-file change, diagnosing a bug you have already failed to fix, or choosing between designs. " + (options.budgetMatters === true ? "Each call costs the user money, so use it for genuinely difficult questions only, and there may be a per-task budget after which it stops being available. " : "Consult it whenever another reader would genuinely change what you do. ") + "The expert can read the workspace but cannot edit or run anything. Consultations within one task continue the same conversation, so after the first one it remembers what you already told it \u2014 a follow-up is far cheaper than a fresh explanation.",
|
|
44316
44358
|
parametersSchema: paramsSchema2,
|
|
44317
44359
|
async preview(params) {
|
|
44318
44360
|
return {
|
|
@@ -44595,6 +44637,9 @@ var PLAN_FIRST = [
|
|
|
44595
44637
|
"3. **Propose it with `update_plan`.** The user sees a diff and approves it. Do not skip this:",
|
|
44596
44638
|
" a plan held only in the conversation is forgotten as the chat grows, and it is not",
|
|
44597
44639
|
" something the user has agreed to.",
|
|
44640
|
+
" **Never write the plan to a file instead.** A file is not the plan: nothing reads it, the",
|
|
44641
|
+
" progress panel stays empty, and the user never approved it. If `update_plan` fails, say",
|
|
44642
|
+
" what it said and stop \u2014 a workaround that looks like progress is worse than the failure.",
|
|
44598
44643
|
"4. Only once it is approved, start the work, reporting each step with `plan_progress`.",
|
|
44599
44644
|
"",
|
|
44600
44645
|
"If the user declines, ask what they want changed and propose a revised plan. If no expert is",
|
|
@@ -44884,7 +44929,7 @@ function buildRoster(team, self) {
|
|
|
44884
44929
|
function buildAgentBriefing(input) {
|
|
44885
44930
|
const tools = (input.tools ?? []).filter(
|
|
44886
44931
|
// Telling a specialist it can consult a specialist is noise at best and a loop at worst.
|
|
44887
|
-
(tool) => tool.name !== "ask_agent" && tool.name !==
|
|
44932
|
+
(tool) => tool.name !== "ask_agent" && tool.name !== ASK_CLAUDE_TOOL
|
|
44888
44933
|
);
|
|
44889
44934
|
const skills = input.skills ?? [];
|
|
44890
44935
|
const team = input.team;
|
|
@@ -45009,7 +45054,7 @@ var PolicyApprovalGate = class {
|
|
|
45009
45054
|
var CONSULT_MAX_STEPS = 5;
|
|
45010
45055
|
var ALLOWED_GROUPS = /* @__PURE__ */ new Set(["read"]);
|
|
45011
45056
|
function toolsForConsultation(all, extra = /* @__PURE__ */ new Set()) {
|
|
45012
|
-
return all.filter((tool) => (ALLOWED_GROUPS.has(tool.group) || extra.has(tool.name)) && tool.name !== "ask_agent" && tool.name !==
|
|
45057
|
+
return all.filter((tool) => (ALLOWED_GROUPS.has(tool.group) || extra.has(tool.name)) && tool.name !== "ask_agent" && tool.name !== ASK_CLAUDE_TOOL && tool.name !== LEGACY_ASK_EXPERT_TOOL);
|
|
45013
45058
|
}
|
|
45014
45059
|
async function runConsultation(options) {
|
|
45015
45060
|
const limit = options.maxSteps ?? CONSULT_MAX_STEPS;
|
|
@@ -45091,13 +45136,13 @@ function createRecallExpertTool(options) {
|
|
|
45091
45136
|
return {
|
|
45092
45137
|
name: "recall_expert_advice",
|
|
45093
45138
|
group: "read",
|
|
45094
|
-
description: "Re-read advice the expert already gave in this task, at no cost. Check here before calling
|
|
45139
|
+
description: "Re-read advice the expert already gave in this task, at no cost. Check here before calling ask_claude \u2014 if a plan was lost to an error or a long conversation, it can be recovered instead of bought again. Returns previous answers verbatim; it never asks anything new.",
|
|
45095
45140
|
parametersSchema: paramsSchema4,
|
|
45096
45141
|
async execute(params) {
|
|
45097
45142
|
const all = options.history();
|
|
45098
45143
|
if (all.length === 0) {
|
|
45099
45144
|
return {
|
|
45100
|
-
content: "The expert has not been consulted in this task yet, so there is nothing to recall. Use
|
|
45145
|
+
content: "The expert has not been consulted in this task yet, so there is nothing to recall. Use ask_claude if you need advice."
|
|
45101
45146
|
};
|
|
45102
45147
|
}
|
|
45103
45148
|
const needle = params.contains?.trim().toLowerCase();
|
|
@@ -62015,8 +62060,8 @@ ${preview.text}` } : {}
|
|
|
62015
62060
|
}
|
|
62016
62061
|
for (const tool of python.generatedTools())
|
|
62017
62062
|
combined.register(tool, { dispatchOnly: dispatcher });
|
|
62018
|
-
combined.register(createUpdatePlanTool(planAccess)
|
|
62019
|
-
combined.register(createPlanProgressTool(planAccess)
|
|
62063
|
+
combined.register(createUpdatePlanTool(planAccess));
|
|
62064
|
+
combined.register(createPlanProgressTool(planAccess));
|
|
62020
62065
|
combined.register(createReadRolePromptTool(rolePromptAccess), { dispatchOnly: dispatcher });
|
|
62021
62066
|
combined.register(createUpdateRolePromptTool(rolePromptAccess), { dispatchOnly: dispatcher });
|
|
62022
62067
|
combined.register(createCreateRoleTool(rolePromptAccess), { dispatchOnly: dispatcher });
|
|
@@ -62210,7 +62255,7 @@ ${preview.text}` } : {}
|
|
|
62210
62255
|
...cachedAssessment === void 0 ? {} : { juniorAssessment: cachedAssessment },
|
|
62211
62256
|
// `ask_expert` itself is excluded: telling the expert it can consult itself is
|
|
62212
62257
|
// noise at best and a loop at worst.
|
|
62213
|
-
promptTools: combined.promptList().filter((tool) => tool.name !==
|
|
62258
|
+
promptTools: combined.promptList().filter((tool) => tool.name !== ASK_CLAUDE_TOOL),
|
|
62214
62259
|
dispatchOnlyTools: combined.dispatchOnlyList(),
|
|
62215
62260
|
skills,
|
|
62216
62261
|
retrievalAvailable: combined.get("search_docs") !== void 0
|
|
@@ -64047,11 +64092,22 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
64047
64092
|
}
|
|
64048
64093
|
}
|
|
64049
64094
|
async function handleRefreshMail(days) {
|
|
64050
|
-
if (mailBusy)
|
|
64095
|
+
if (mailBusy) {
|
|
64096
|
+
mailLastResult = "A mail sync is already running \u2014 wait for it to finish, then try again.";
|
|
64097
|
+
await postMailStatus();
|
|
64051
64098
|
return;
|
|
64099
|
+
}
|
|
64052
64100
|
const config2 = await loadSettings();
|
|
64053
|
-
if (cachedOffice.outlook !== true
|
|
64101
|
+
if (cachedOffice.outlook !== true) {
|
|
64102
|
+
mailLastResult = "Outlook is switched off in Settings \u2192 Tools.";
|
|
64103
|
+
await postMailStatus();
|
|
64104
|
+
return;
|
|
64105
|
+
}
|
|
64106
|
+
if (!officeAvailable()) {
|
|
64107
|
+
mailLastResult = "Outlook is not available on this host.";
|
|
64108
|
+
await postMailStatus();
|
|
64054
64109
|
return;
|
|
64110
|
+
}
|
|
64055
64111
|
const chosen = config2.mail?.folders ?? [];
|
|
64056
64112
|
if (chosen.length === 0) {
|
|
64057
64113
|
mailLastResult = "No folders selected.";
|
|
@@ -66989,20 +67045,32 @@ function toolCallSummary(call, outcome) {
|
|
|
66989
67045
|
};
|
|
66990
67046
|
}
|
|
66991
67047
|
function consultationFromToolCall(name, rawArguments) {
|
|
66992
|
-
|
|
67048
|
+
const call = throughDispatch(name, rawArguments);
|
|
67049
|
+
if (call.name === ASK_CLAUDE_TOOL || call.name === LEGACY_ASK_EXPERT_TOOL)
|
|
66993
67050
|
return "expert";
|
|
66994
|
-
if (name !== "ask_agent")
|
|
67051
|
+
if (call.name !== "ask_agent")
|
|
66995
67052
|
return void 0;
|
|
66996
|
-
const decoded =
|
|
67053
|
+
const decoded = call.args;
|
|
66997
67054
|
const role = typeof decoded === "object" && decoded !== null ? decoded.role : void 0;
|
|
66998
67055
|
return typeof role === "string" && role.trim().length > 0 ? role.trim().toLowerCase() : "unknown";
|
|
66999
67056
|
}
|
|
67000
67057
|
function chartFromToolCall(name, rawArguments) {
|
|
67001
|
-
|
|
67058
|
+
const call = throughDispatch(name, rawArguments);
|
|
67059
|
+
if (call.name !== "show_chart")
|
|
67002
67060
|
return void 0;
|
|
67003
|
-
const parsed = chartSpecSchema.safeParse(
|
|
67061
|
+
const parsed = chartSpecSchema.safeParse(call.args);
|
|
67004
67062
|
return parsed.success ? { kind: "chart", chart: parsed.data } : { kind: "chartError", message: parsed.error.issues.map((issue2) => issue2.message).join("; ") };
|
|
67005
67063
|
}
|
|
67064
|
+
function throughDispatch(name, rawArguments) {
|
|
67065
|
+
const decoded = decodeArguments(rawArguments);
|
|
67066
|
+
if (name !== CALL_TOOL_NAME || typeof decoded !== "object" || decoded === null) {
|
|
67067
|
+
return { name, args: decoded };
|
|
67068
|
+
}
|
|
67069
|
+
const inner = decoded;
|
|
67070
|
+
if (typeof inner.name !== "string" || inner.name.length === 0)
|
|
67071
|
+
return { name, args: decoded };
|
|
67072
|
+
return { name: inner.name, args: inner.arguments ?? {} };
|
|
67073
|
+
}
|
|
67006
67074
|
function decodeArguments(raw) {
|
|
67007
67075
|
try {
|
|
67008
67076
|
return JSON.parse(raw.length > 0 ? raw : "{}");
|
|
@@ -70312,7 +70380,7 @@ function respondJson(response, status, body) {
|
|
|
70312
70380
|
}
|
|
70313
70381
|
|
|
70314
70382
|
// src/cli.ts
|
|
70315
|
-
var VERSION = true ? "0.59.
|
|
70383
|
+
var VERSION = true ? "0.59.6" : "unknown (not a packaged build)";
|
|
70316
70384
|
var compat = installNodeCompat();
|
|
70317
70385
|
function lastMeaningfulLine(problem) {
|
|
70318
70386
|
const lines = problem.split(String.fromCharCode(10)).map((line) => line.trim()).filter((line) => line.length > 0 && !line.endsWith(":"));
|
package/dist/client/client.js
CHANGED
|
@@ -141,7 +141,7 @@ Default 5.`,placeholder:"5",value:S.maxIndexes,onChange:w=>v({...S,maxIndexes:w}
|
|
|
141
141
|
`),spellCheck:!1,rows:2,onChange:y=>m({args:y.target.value.split(`
|
|
142
142
|
`)}),style:{...A(),fontFamily:ni,resize:"vertical"}}),(0,se.jsx)("span",{style:{display:"block",color:s.muted,fontSize:11,marginBottom:12},children:"One per line, because nothing is parsed by a shell \u2014 an argument containing a space stays one argument."})]}):(0,se.jsxs)(se.Fragment,{children:[(0,se.jsxs)("label",{htmlFor:"lc-token-raw",style:D(),children:["Command ",(0,se.jsx)("span",{style:{color:s.muted,fontWeight:400},children:"(one argument per line)"})]}),(0,se.jsx)("textarea",{id:"lc-token-raw",value:t.join(`
|
|
143
143
|
`),spellCheck:!1,rows:4,onChange:y=>f("command",y.target.value.split(`
|
|
144
|
-
`)),style:{...A(),fontFamily:ni,resize:"vertical"}}),(0,se.jsxs)("span",{style:{display:"block",color:s.muted,fontSize:11,marginBottom:12},children:["The program first, then each argument on its own line. Spawned directly, so there are no pipes, no redirection and no ",(0,se.jsx)("code",{style:{fontFamily:ni},children:"&&"})," ","\u2014 put shell logic in a script instead."]})]}),(0,se.jsx)("button",{type:"button",style:{background:"none",border:"none",color:s.accent,cursor:"pointer",padding:0,fontSize:11},onClick:()=>i(y=>!y),children:l?"Enter a command instead":"It is a Python script"}),(0,se.jsx)("div",{style:{marginTop:10},children:(0,se.jsx)("button",{type:"button",style:{background:"none",border:"none",color:s.accent,cursor:"pointer",padding:0,fontSize:11},onClick:()=>a(y=>!y),children:o?"Hide advanced":"Advanced \u2014 JSON output, expiry, headers"})}),o&&(0,se.jsxs)("div",{style:{marginTop:10,paddingLeft:10,borderLeft:`2px solid ${s.border}`},children:[(0,se.jsx)("p",{style:{color:s.muted,fontSize:11,margin:"0 0 10px"},children:"Leave these empty if the script prints a bare token. Fill the two paths in if it prints the gateway\u2019s JSON instead \u2014 then it refreshes on the real expiry rather than an assumed hour."}),(0,se.jsx)("label",{htmlFor:"lc-token-path",style:D(),children:"Token field"}),(0,se.jsx)("input",{id:"lc-token-path",type:"text",value:e.value.tokenPath??"",spellCheck:!1,placeholder:"access_token",onChange:y=>f("tokenPath",y.target.value.trim()===""?void 0:y.target.value),style:{...A(),fontFamily:ni}}),(0,se.jsxs)("label",{htmlFor:"lc-expires-path",style:D(),children:["Expiry field ",(0,se.jsx)("span",{style:{color:s.muted,fontWeight:400},children:"(seconds)"})]}),(0,se.jsx)("input",{id:"lc-expires-path",type:"text",value:e.value.expiresInPath??"",spellCheck:!1,placeholder:"expires_in",onChange:y=>f("expiresInPath",y.target.value.trim()===""?void 0:y.target.value),style:{...A(),fontFamily:ni}}),(0,se.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,se.jsxs)("div",{style:{flex:1},children:[(0,se.jsx)("label",{htmlFor:"lc-token-expiry",style:D(),children:"Assume it lasts (s)"}),(0,se.jsx)("input",{id:"lc-token-expiry",type:"text",inputMode:"numeric",value:e.value.fallbackExpirySeconds??"",placeholder:"3600",onChange:y=>f("fallbackExpirySeconds",Number(y.target.value)||void 0),style:A()})]}),(0,se.jsxs)("div",{style:{flex:1},children:[(0,se.jsx)("label",{htmlFor:"lc-token-skew",style:D(),children:"Refresh this early (s)"}),(0,se.jsx)("input",{id:"lc-token-skew",type:"text",inputMode:"numeric",value:e.value.refreshSkewSeconds??"",placeholder:"60",onChange:y=>f("refreshSkewSeconds",Number(y.target.value)||void 0),style:A()})]}),(0,se.jsxs)("div",{style:{flex:1},children:[(0,se.jsx)("label",{htmlFor:"lc-token-timeout",style:D(),children:"Give up after (s)"}),(0,se.jsx)("input",{id:"lc-token-timeout",type:"text",inputMode:"numeric",value:e.value.timeoutSeconds??"",placeholder:"30",onChange:y=>f("timeoutSeconds",Number(y.target.value)||void 0),style:A()})]})]}),(0,se.jsxs)("label",{htmlFor:"lc-token-cwd",style:D(),children:["Run it in ",(0,se.jsx)("span",{style:{color:s.muted,fontWeight:400},children:"(optional folder)"})]}),(0,se.jsx)("input",{id:"lc-token-cwd",type:"text",value:e.value.cwd??"",spellCheck:!1,onChange:y=>f("cwd",y.target.value.trim()===""?void 0:y.target.value),style:{...A(),fontFamily:ni}}),(0,se.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,se.jsxs)("div",{style:{flex:1},children:[(0,se.jsx)("label",{htmlFor:"lc-token-header",style:D(),children:"Header name"}),(0,se.jsx)("input",{id:"lc-token-header",type:"text",value:e.value.headerName??"",spellCheck:!1,placeholder:"Authorization",onChange:y=>f("headerName",y.target.value.trim()===""?void 0:y.target.value),style:{...A(),fontFamily:ni}})]}),(0,se.jsxs)("div",{style:{flex:1},children:[(0,se.jsx)("label",{htmlFor:"lc-token-prefix",style:D(),children:"Header prefix"}),(0,se.jsx)("input",{id:"lc-token-prefix",type:"text",value:e.value.headerPrefix??"",spellCheck:!1,placeholder:"Bearer ",onChange:y=>f("headerPrefix",y.target.value===""?void 0:y.target.value),style:{...A(),fontFamily:ni}})]})]}),(0,se.jsxs)("span",{style:{display:"block",color:s.muted,fontSize:11,marginTop:4},children:["Left empty, these follow the wire format \u2014 ",(0,se.jsx)("code",{style:{fontFamily:ni},children:"Authorization: Bearer"})," ","for OpenAI, ",(0,se.jsx)("code",{style:{fontFamily:ni},children:"x-api-key"})," for Anthropic."]})]})]})}var Ut=N(pe(),1);var he=N(ne(),1),Bz=N(pe(),1);function zn(e){return(0,he.jsxs)("div",{style:{marginBottom:10},children:[(0,he.jsx)("label",{htmlFor:e.id,style:D(),children:e.label}),(0,he.jsx)("input",{id:e.id,type:"text",value:e.value??"",placeholder:e.placeholder,onChange:t=>e.onChange(t.target.value),style:A()}),e.hint!==void 0&&(0,he.jsx)("span",{style:{color:s.muted,fontSize:11,display:"block",marginTop:2},children:e.hint})]})}function Mz(e){return(0,he.jsxs)("div",{style:{marginBottom:10},children:[(0,he.jsx)("label",{htmlFor:e.id,style:D(),children:e.label}),(0,he.jsx)("input",{id:e.id,type:"number",value:e.value??"",placeholder:e.placeholder,onChange:t=>{let n=Number.parseInt(t.target.value,10);e.onChange(Number.isNaN(n)?void 0:n)},style:A()})]})}function GU(e){let[t,n]=(0,Bz.useState)(!1);return(0,he.jsxs)("div",{style:{marginBottom:12},children:[(0,he.jsxs)("button",{type:"button",onClick:()=>n(!t),style:{background:"transparent",border:"none",color:s.foreground,fontFamily:V,fontSize:12,padding:0,cursor:"pointer"},children:[t?"\u25BE":"\u25B8"," ",e.title]}),t&&(0,he.jsx)("div",{style:{marginTop:8,paddingLeft:12},children:e.children})]})}function Lz(e){let t=r=>e.onApigeeChange({...e.apigee,...r}),n=r=>e.onCertsChange({...e.certs,...r});return(0,he.jsxs)("div",{style:{paddingTop:12,borderTop:`1px solid ${s.border}`},children:[(0,he.jsxs)("div",{style:{marginBottom:12},children:[(0,he.jsx)("label",{htmlFor:"lc-auth-type",style:D(),children:"Authentication"}),(0,he.jsx)($e,{id:"lc-auth-type",value:e.authType,onChange:r=>e.onAuthTypeChange(r),style:{width:"100%"},options:[{value:"apiKey",label:"API key"},{value:"header",label:"A header the gateway expects"},{value:"tokenCommand",label:"Token from a script"},{value:"apigeeMtls",label:"Mutual TLS + OAuth (Apigee)"},{value:"none",label:"None"}]})]}),e.authType==="apigeeMtls"&&(0,he.jsxs)(he.Fragment,{children:[(0,he.jsxs)("div",{style:{marginBottom:12},children:[(0,he.jsx)("strong",{style:{fontSize:12,color:s.foreground},children:"Client certificate"}),(0,he.jsx)("p",{style:{color:s.muted,fontSize:11,margin:"4px 0 8px"},children:"Must live outside the workspace \u2014 a repository must not be able to read or replace your key material. Filenames resolve against the directory; absolute paths override it."})]}),(0,he.jsx)(zn,{id:"lc-cert-dir",label:"Certificate directory",value:e.certs.certDir,placeholder:"C:\\\\Users\\\\you\\\\certs",hint:"Leave blank to use the global certDir from config.",onChange:r=>n({certDir:r})}),(0,he.jsx)(zn,{id:"lc-cert-file",label:"Certificate file",value:e.certs.certFile,placeholder:"client.crt",onChange:r=>n({certFile:r})}),(0,he.jsx)(zn,{id:"lc-key-file",label:"Private key file",value:e.certs.keyFile,placeholder:"client.key",onChange:r=>n({keyFile:r})}),(0,he.jsx)(zn,{id:"lc-pfx-file",label:"PFX bundle (instead of certificate + key)",value:e.certs.pfxFile,placeholder:"client.pfx",hint:"Corporate Windows PKI usually issues a .pfx.",onChange:r=>n({pfxFile:r})}),(0,he.jsx)(zn,{id:"lc-ca-file",label:"Extra CA bundle",value:e.certs.caFile,placeholder:"corp-root.pem",hint:"Needed when your network intercepts TLS. NODE_EXTRA_CA_CERTS also works.",onChange:r=>n({caFile:r})}),(0,he.jsx)(Ri,{id:"lc-cert-passphrase",label:"Key / PFX passphrase",hasValue:e.hasCertPassphrase,value:e.certPassphrase,onChange:e.onCertPassphraseChange,placeholder:"Leave blank if the key is not encrypted"}),(0,he.jsx)("div",{style:{marginBottom:12},children:(0,he.jsx)("strong",{style:{fontSize:12,color:s.foreground},children:"Token endpoint"})}),(0,he.jsx)(zn,{id:"lc-token-url",label:"Token URL",value:e.apigee.tokenUrl,placeholder:"https://gateway.example.com/oauth/token",hint:"Defaults to the base URL's origin + /oauth/token.",onChange:r=>t({tokenUrl:r})}),(0,he.jsx)(zn,{id:"lc-client-id",label:"Client ID",value:e.apigee.clientId,onChange:r=>t({clientId:r})}),(0,he.jsx)(Ri,{id:"lc-client-secret",label:"Client secret",hasValue:e.hasClientSecret,value:e.clientSecret,onChange:e.onClientSecretChange,placeholder:"Stored in the OS keychain"}),(0,he.jsx)(zn,{id:"lc-scope",label:"Scope",value:e.apigee.scope,placeholder:"(optional)",onChange:r=>t({scope:r})}),(0,he.jsxs)(GU,{title:"Token response and header mapping",children:[(0,he.jsx)(zn,{id:"lc-grant-type",label:"Grant type",value:e.apigee.grantType,placeholder:"client_credentials",onChange:r=>t({grantType:r})}),(0,he.jsx)(zn,{id:"lc-token-path",label:"Token path in response",value:e.apigee.tokenPath,placeholder:"access_token",hint:"Dotted path, e.g. data.jwt if your gateway nests it.",onChange:r=>t({tokenPath:r})}),(0,he.jsx)(zn,{id:"lc-expires-path",label:"Expiry path in response",value:e.apigee.expiresInPath,placeholder:"expires_in",onChange:r=>t({expiresInPath:r})}),(0,he.jsx)(zn,{id:"lc-token-header",label:"Header name",value:e.apigee.tokenHeaderName,placeholder:"Authorization",onChange:r=>t({tokenHeaderName:r})}),(0,he.jsx)(zn,{id:"lc-token-prefix",label:"Header prefix",value:e.apigee.tokenHeaderPrefix,placeholder:"Bearer ",onChange:r=>t({tokenHeaderPrefix:r})}),(0,he.jsx)(Mz,{id:"lc-fallback-expiry",label:"Fallback expiry (seconds)",value:e.apigee.fallbackExpirySeconds,placeholder:"3600",onChange:r=>t({...r!==void 0?{fallbackExpirySeconds:r}:{}})}),(0,he.jsx)(Mz,{id:"lc-refresh-skew",label:"Refresh skew (seconds)",value:e.apigee.refreshSkewSeconds,placeholder:"60",onChange:r=>t({...r!==void 0?{refreshSkewSeconds:r}:{}})})]})]}),(0,he.jsxs)("div",{style:{marginBottom:12,paddingTop:12,borderTop:`1px solid ${s.border}`},children:[(0,he.jsx)("strong",{style:{fontSize:12,color:s.foreground},children:"Connection security"}),(0,he.jsx)("p",{style:{color:s.muted,fontSize:11,margin:"4px 0 8px"},children:"Needed when your network intercepts TLS, which is common on a corporate gateway. This is separate from the client certificate above: it decides whether you trust the server, not how the server identifies you."})]}),(0,he.jsx)(zn,{id:"lc-connection-ca",label:"Additional CA certificate",value:e.connectionTls.caFile,placeholder:"C:\\\\certs\\\\corp-root.pem",hint:"Only needed if this gateway uses a different root from the one in Settings \u2192 Network. Added to that one and to the built-in roots, never replacing either.",onChange:r=>e.onConnectionTlsChange({...e.connectionTls,caFile:r})}),(0,he.jsxs)("label",{style:{display:"flex",alignItems:"flex-start",gap:6,marginBottom:6,fontSize:12},children:[(0,he.jsx)("input",{type:"checkbox",style:{marginTop:2},checked:e.connectionTls.rejectUnauthorized===!1,onChange:r=>e.onConnectionTlsChange({...e.connectionTls,...r.target.checked?{rejectUnauthorized:!1}:{rejectUnauthorized:void 0}})}),(0,he.jsx)("span",{style:{color:s.foreground},children:"Skip certificate verification for this profile"})]}),e.connectionTls.rejectUnauthorized===!1&&(0,he.jsx)("p",{style:{color:s.error,fontSize:11,margin:"0 0 12px",paddingLeft:22},children:"Anyone able to intercept this connection can now read and modify it, including your API key, and nothing will detect it. Supplying the CA file above is the safe fix and solves the same problem."})]})}var wt=N(ne(),1);function Pz(e){let t=e.value.trim(),n=t.length>0?Kv(t,e.capabilities):void 0,r=o=>e.onCapabilitiesChange({...e.capabilities,...o}),i=()=>{let o={...e.capabilities};delete o.contextWindow,e.onCapabilitiesChange(o)};return(0,wt.jsxs)("div",{style:{marginBottom:12},children:[(0,wt.jsx)("label",{htmlFor:"lc-model",style:D(),children:"Model"}),(0,wt.jsxs)("div",{style:{display:"flex",gap:6,marginBottom:6},children:[(0,wt.jsx)("input",{id:"lc-model",type:"text",value:e.value,placeholder:"gpt-4o-mini",onChange:o=>e.onChange(o.target.value),style:A()}),(0,wt.jsx)("button",{type:"button",style:z(),onClick:e.onRefresh,disabled:e.loading,children:e.loading?"Loading\u2026":"Refresh"})]}),e.models.length>0&&(0,wt.jsx)($e,{ariaLabel:"Choose from the gateway's catalogue",value:e.models.includes(e.value)?e.value:"",onChange:o=>{o.length>0&&e.onChange(o)},style:{width:"100%"},options:[{value:"",label:`Choose from ${e.models.length} available model(s)\u2026`},...e.models.map(o=>({value:o,label:o}))]}),e.warning!==void 0&&e.models.length===0&&(0,wt.jsx)("span",{style:{...nn(),color:s.muted},children:e.warning}),e.error!==void 0&&(0,wt.jsx)("span",{style:nn(),children:e.error}),n!==void 0&&(0,wt.jsxs)("div",{style:{marginTop:6,padding:8,border:`1px solid ${s.border}`,borderRadius:3},children:[(0,wt.jsx)("div",{style:{color:s.muted,fontSize:11,marginBottom:6},children:n.known?"Capabilities for this model. Edit any of them if your deployment differs.":"Unrecognised model id \u2014 these are conservative guesses. Correct them here."}),(0,wt.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[(0,wt.jsx)("label",{htmlFor:"lc-context-window",style:{...D(),marginBottom:0,flex:1},children:"Context window (tokens)"}),(0,wt.jsx)("input",{id:"lc-context-window",type:"number",min:1,value:e.capabilities.contextWindow??n.contextWindow,onChange:o=>{let a=Number.parseInt(o.target.value,10);Number.isNaN(a)||a<=0?i():r({contextWindow:a})},style:{...A(),width:130,flex:"none"}}),e.capabilities.contextWindow!==void 0&&(0,wt.jsx)("button",{type:"button",style:z(),onClick:i,title:"Use the built-in value",children:"Reset"})]}),(0,wt.jsxs)("div",{style:{display:"flex",gap:16},children:[(0,wt.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:s.foreground},children:[(0,wt.jsx)("input",{type:"checkbox",checked:n.supportsVision,onChange:o=>r({supportsVision:o.target.checked})}),"Accepts images"]}),(0,wt.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:s.foreground},children:[(0,wt.jsx)("input",{type:"checkbox",checked:n.supportsTools,onChange:o=>r({supportsTools:o.target.checked})}),"Supports tool calling"]})]})]})]})}var Mi=N(ne(),1);var YU={certificates:"Load certificates",token:"Acquire credential",models:"List models"};function WU(e){return e==="ok"?{glyph:"\u2713",color:"var(--vscode-testing-iconPassed, #3fb950)"}:e==="failed"?{glyph:"\u2715",color:s.error}:{glyph:"\u2013",color:s.muted}}function Zz(e){return(0,Mi.jsxs)("div",{style:{marginBottom:16,paddingTop:12,borderTop:`1px solid ${s.border}`},children:[(0,Mi.jsx)("button",{type:"button",style:z(),onClick:e.onRun,disabled:e.running,children:e.running?"Testing\u2026":"Test Connection"}),e.result!==void 0&&(0,Mi.jsx)("div",{style:{marginTop:8,fontFamily:V,fontSize:12},children:e.result.steps.map(t=>{let n=WU(t.status);return(0,Mi.jsxs)("div",{style:{display:"flex",gap:8,marginBottom:4},children:[(0,Mi.jsx)("span",{style:{color:n.color,width:12,flexShrink:0},children:n.glyph}),(0,Mi.jsxs)("div",{children:[(0,Mi.jsx)("div",{style:{color:s.foreground},children:YU[t.step]}),(0,Mi.jsx)("div",{style:{color:t.status==="failed"?s.error:s.muted,fontSize:11},children:t.detail})]})]},t.step)})})]})}function Hb(e){let[t,n]=(0,Ut.useState)(e.initial.label),[r,i]=(0,Ut.useState)(e.initial.wireFormat),[o,a]=(0,Ut.useState)(e.initial.baseUrl),[l,c]=(0,Ut.useState)(e.initial.model),[u,d]=(0,Ut.useState)(""),[h,m]=(0,Ut.useState)(e.initial.authHeaders??[{name:"",valueRef:""}]),[f,y]=(0,Ut.useState)(e.initial.tokenCommand??{command:["python",""]}),[k,E]=(0,Ut.useState)(e.initial.authType),[g,b]=(0,Ut.useState)(e.initial.apigee??{}),[S,v]=(0,Ut.useState)(""),[C,K]=(0,Ut.useState)(e.initial.certs??{}),[q,w]=(0,Ut.useState)(""),[R,ce]=(0,Ut.useState)(e.initial.modelCapabilities??{}),[Me,ct]=(0,Ut.useState)(e.initial.thinking?.level??""),[en,cn]=(0,Ut.useState)(e.initial.thinking?.style??"effort"),[hi,L]=(0,Ut.useState)(e.initial.connectionTls??{}),[de,He]=(0,Ut.useState)([]),[Ft,U]=(0,Ut.useState)(void 0),fe=rt=>de.find(qi=>qi.path===rt)?.message,yt=rt=>{let qi=Ed.find(pi=>pi.id===rt);qi!==void 0&&(i(qi.wireFormat),a(qi.baseUrl),t.trim().length===0&&n(qi.label))},et=()=>({...e.initial.id!==void 0?{id:e.initial.id}:{},label:t,wireFormat:r,baseUrl:o,model:l,authType:k,apiKey:u,...k==="tokenCommand"?{tokenCommand:f}:{},...k==="header"?{authHeaders:h}:{},...k==="apigeeMtls"?{apigee:g,clientSecret:S,certs:C,certPassphrase:q}:{},...Object.keys(R).length>0?{modelCapabilities:R}:{},...Me===""?{}:{thinking:{level:Me,...r==="openai"?{style:en}:{}}},...hi.caFile!==void 0||hi.rejectUnauthorized!==void 0?{connectionTls:hi}:{}}),At=()=>{let rt=o.trim();if(rt===Ft||rt.length===0)return;try{let pi=new URL(rt);if(pi.protocol!=="https:"&&pi.protocol!=="http:")return}catch{return}(k==="none"||u.trim().length>0||e.initial.hasApiKey||k==="apigeeMtls"||k==="header"&&h.some(pi=>pi.name.trim().length>0&&pi.valueRef.trim().length>0)||k==="tokenCommand"&&f.command.filter(pi=>pi.trim().length>0).length>0)&&(U(rt),e.onRequestModels(et()))},_i=()=>{let rt=Xv({label:t,wireFormat:r,baseUrl:o,model:l});He(rt),!(rt.length>0)&&e.onSave(et())};return(0,Oe.jsxs)("div",{style:{padding:12,overflowY:"auto"},children:[(0,Oe.jsx)("h3",{style:{margin:"0 0 12px",color:s.foreground},children:e.initial.id===void 0?"Add Provider":"Edit Provider"}),(0,Oe.jsxs)("div",{style:{marginBottom:12},children:[(0,Oe.jsx)("label",{htmlFor:"lc-preset",style:D(),children:"Preset"}),(0,Oe.jsx)($e,{id:"lc-preset",value:"",placeholder:"Choose a preset\u2026",onChange:yt,style:{width:"100%"},options:Ed.map(rt=>({value:rt.id,label:rt.label}))})]}),(0,Oe.jsxs)("div",{style:{marginBottom:12},children:[(0,Oe.jsx)("label",{htmlFor:"lc-label",style:D(),children:"Label"}),(0,Oe.jsx)("input",{id:"lc-label",type:"text",value:t,onChange:rt=>n(rt.target.value),style:A()}),fe("label")!==void 0&&(0,Oe.jsx)("span",{style:nn(),children:fe("label")})]}),(0,Oe.jsxs)("div",{style:{marginBottom:12},children:[(0,Oe.jsx)("label",{htmlFor:"lc-base-url",style:D(),children:"Base URL"}),(0,Oe.jsx)("input",{id:"lc-base-url",type:"text",value:o,placeholder:"https://api.openai.com/v1",onChange:rt=>a(rt.target.value),onBlur:At,style:A()}),fe("baseUrl")!==void 0&&(0,Oe.jsx)("span",{style:nn(),children:fe("baseUrl")})]}),(0,Oe.jsx)(Pz,{value:l,onChange:c,models:e.models,...e.modelsWarning!==void 0?{warning:e.modelsWarning}:{},loading:e.modelsLoading,onRefresh:()=>e.onRequestModels(et()),...fe("model")!==void 0?{error:fe("model")}:{},capabilities:R,onCapabilitiesChange:ce}),(0,Oe.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,marginBottom:12},children:[(0,Oe.jsx)("label",{style:D(),children:"Thinking"}),(0,Oe.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[(0,Oe.jsx)("div",{style:{minWidth:150,flex:1},children:(0,Oe.jsx)($e,{compact:!0,ariaLabel:"Thinking level",value:Me,onChange:ct,options:[{value:"",label:"Send nothing (default)"},{value:"off",label:"Off"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}]})}),r==="openai"&&Me!==""&&(0,Oe.jsx)("div",{style:{minWidth:210,flex:1},children:(0,Oe.jsx)($e,{compact:!0,ariaLabel:"Thinking parameter",value:en,onChange:rt=>cn(rt),options:[{value:"effort",label:"as reasoning_effort"},{value:"qwen",label:"as enable_thinking (Qwen)"}]})})]}),(0,Oe.jsx)("span",{style:{color:s.muted,fontSize:11,lineHeight:1.5},children:Me===""?"Nothing is sent, which is how every profile behaved before this existed. Set it only against a gateway you know accepts it.":r!=="openai"?"This wire format spells thinking one way, so there is nothing to choose.":en==="effort"?"Sends reasoning_effort. Right for OpenAI and most gateways fronting a reasoning model.":"Sends chat_template_kwargs.enable_thinking, which vLLM and SGLang expose for Qwen3 and its relatives. On or off only \u2014 the level is not a depth dial here."})]}),k==="header"&&(0,Oe.jsx)(Uz,{headers:h,onChange:m}),k==="tokenCommand"&&(0,Oe.jsx)(Rz,{value:f,onChange:y,...e.onBrowse===void 0?{}:{onBrowse:e.onBrowse},...e.pickedPath===void 0?{}:{pickedPath:e.pickedPath}}),k==="apiKey"&&(0,Oe.jsxs)("div",{onBlur:At,children:[(0,Oe.jsx)(Ri,{id:"lc-api-key",label:"API key",hasValue:e.initial.hasApiKey,value:u,onChange:d,...e.initial.apiKeyEnvVar===void 0?{}:{envVar:e.initial.apiKeyEnvVar}}),(0,Oe.jsxs)("span",{style:{display:"block",color:s.muted,fontSize:11,marginTop:-10,marginBottom:16},children:["Enter ",(0,Oe.jsx)("code",{style:{fontFamily:"var(--vscode-editor-font-family, monospace)"},children:"env:API_TOKEN"})," to read the key from that environment variable instead of storing it. It is read fresh on every request, and must be exported before Light Code starts \u2014 a child process cannot see a variable its parent set afterwards."]})]}),(0,Oe.jsx)(Lz,{authType:k,onAuthTypeChange:E,apigee:g,onApigeeChange:b,clientSecret:S,onClientSecretChange:v,hasClientSecret:e.initial.hasClientSecret,certs:C,onCertsChange:K,certPassphrase:q,onCertPassphraseChange:w,hasCertPassphrase:e.initial.hasCertPassphrase,connectionTls:hi,onConnectionTlsChange:L}),(0,Oe.jsx)(Zz,{running:e.testRunning,...e.testResult!==void 0?{result:e.testResult}:{result:void 0},onRun:()=>e.onTestConnection(et())}),(0,Oe.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,Oe.jsx)("button",{type:"button",style:le(!1),onClick:_i,children:"Save"}),(0,Oe.jsx)("button",{type:"button",style:z(),onClick:e.onCancel,children:"Cancel"})]})]})}function qb(e){let[t,n]=(0,Fz.useState)({mode:"closed"}),r=i=>{e.onEditingChange(),n(i)};if(t.mode!=="closed"){let i=t.mode==="edit"?{id:t.profile.id,label:t.profile.label,wireFormat:t.profile.wireFormat,baseUrl:t.profile.baseUrl,model:t.profile.model,authType:t.profile.authType,hasApiKey:t.profile.hasApiKey,...t.profile.authHeaders===void 0?{}:{authHeaders:t.profile.authHeaders},...t.profile.tokenCommand===void 0?{}:{tokenCommand:t.profile.tokenCommand},...t.profile.apiKeyEnvVar===void 0?{}:{apiKeyEnvVar:t.profile.apiKeyEnvVar},hasClientSecret:t.profile.hasClientSecret,hasCertPassphrase:t.profile.hasCertPassphrase,...t.profile.apigee!==void 0?{apigee:t.profile.apigee}:{},...t.profile.certs!==void 0?{certs:t.profile.certs}:{},...t.profile.modelCapabilities!==void 0?{modelCapabilities:t.profile.modelCapabilities}:{},...t.profile.connectionTls!==void 0?{connectionTls:t.profile.connectionTls}:{}}:{label:"",wireFormat:"openai",baseUrl:"",model:"",authType:"apiKey",hasApiKey:!1,hasClientSecret:!1,hasCertPassphrase:!1};return(0,Fe.jsx)(Hb,{onBrowse:e.onBrowse,...e.pickedPath===void 0?{}:{pickedPath:e.pickedPath},initial:i,onSave:o=>{e.onSave(o),n({mode:"closed"})},onCancel:()=>n({mode:"closed"}),onRequestModels:e.onRequestModels,onTestConnection:e.onTestConnection,models:e.models,...e.modelsWarning!==void 0?{modelsWarning:e.modelsWarning}:{},modelsLoading:e.modelsLoading,testRunning:e.testRunning,...e.testResult!==void 0?{testResult:e.testResult}:{}})}return(0,Fe.jsxs)("div",{style:{padding:12,overflowY:"auto"},children:[(0,Fe.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[(0,Fe.jsx)("h3",{style:{margin:0,color:s.foreground},children:"Providers"}),(0,Fe.jsx)(Ui,{scope:"user"})]}),e.profiles.length===0&&(0,Fe.jsx)("p",{style:{color:s.muted,fontFamily:V},children:"No providers configured yet. Add one to start chatting."}),e.profiles.map(i=>{let o=i.id===e.activeProfileId,a=e.sharedProfileIds?.includes(i.id)===!0;return(0,Fe.jsxs)("div",{"data-profile":i.id,style:{padding:10,marginBottom:8,borderRadius:4,border:`1px solid ${s.border}`,background:o?s.assistantBubble:"transparent"},children:[(0,Fe.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[(0,Fe.jsx)("strong",{children:i.label}),o&&(0,Fe.jsx)(Ui,{scope:"user"})]}),(0,Fe.jsxs)("div",{style:{color:s.muted,fontSize:12,marginBottom:8},children:[i.baseUrl," \u2014 ",i.model]}),a&&(0,Fe.jsxs)("div",{style:{color:s.muted,fontSize:10,marginBottom:6},children:[(0,Fe.jsx)("span",{style:{...ot(),fontSize:9,marginRight:5},children:"provided"}),"Set up by an administrator for everyone. Duplicate it to make a copy you can edit with your own key."]}),(0,Fe.jsxs)("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:[!o&&(0,Fe.jsx)("button",{type:"button",title:"Use this profile","aria-label":"Use this profile",style:ze("secondary"),onClick:()=>e.onSetActive(i.id),children:(0,Fe.jsx)(Di,{})}),!a&&(0,Fe.jsx)("button",{type:"button",title:"Edit","aria-label":"Edit",style:ze("secondary"),onClick:()=>r({mode:"edit",profile:i}),children:(0,Fe.jsx)(W_,{})}),(0,Fe.jsx)("button",{type:"button",title:a?"Copy this into a profile of your own":"Duplicate","aria-label":"Duplicate",style:ze("secondary"),onClick:()=>e.onDuplicate(i.id),children:(0,Fe.jsx)(Ur,{})}),!a&&(0,Fe.jsx)("button",{type:"button",title:"Delete","aria-label":"Delete",style:{...ze("secondary"),color:s.error},onClick:()=>e.onDelete(i.id),children:(0,Fe.jsx)(Ht,{})})]})]},i.id)}),(0,Fe.jsx)("button",{type:"button",style:le(!1),onClick:()=>r({mode:"create"}),children:"Add Provider"}),(0,Fe.jsxs)("div",{style:{marginTop:20,paddingTop:12,borderTop:`1px solid ${s.border}`},children:[(0,Fe.jsx)("label",{style:D(),children:"Config file"}),(0,Fe.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,Fe.jsx)("button",{type:"button",style:z(),onClick:e.onExport,children:"Export"}),(0,Fe.jsx)("button",{type:"button",style:z(),onClick:e.onImport,children:"Import"})]})]})]})}var Ne=N(ne(),1),Qd=N(pe(),1);var Xa="#22C55E",Hz=[{id:"green",label:"Green",value:Xa},{id:"purple",label:"Purple",value:"#A855F7"},{id:"indigo",label:"Indigo",value:"#6366F1"},{id:"blue",label:"Blue",value:"#3B82F6"},{id:"teal",label:"Teal",value:"#14B8A6"},{id:"amber",label:"Amber",value:"#F59E0B"},{id:"rose",label:"Rose",value:"#F43F5E"},{id:"graphite",label:"Graphite",value:"#64748B"}],Fr="#D97757",Yb=[{id:"coral",label:"Coral",value:Fr},{id:"orange",label:"Orange",value:"#F97316"},{id:"amber",label:"Amber",value:"#F59E0B"},{id:"rose",label:"Rose",value:"#F43F5E"},{id:"purple",label:"Purple",value:"#A855F7"},{id:"blue",label:"Blue",value:"#3B82F6"},{id:"teal",label:"Teal",value:"#14B8A6"},{id:"graphite",label:"Graphite",value:"#64748B"}];function Wd(e){let t=e.trim().replace(/^#/,""),n=t.length===3?t.replace(/./g,r=>r+r):t;if(/^[0-9a-fA-F]{6}$/.test(n))return{r:Number.parseInt(n.slice(0,2),16),g:Number.parseInt(n.slice(2,4),16),b:Number.parseInt(n.slice(4,6),16)}}function Jd(e){return Wd(e)!==void 0}function Gb({r:e,g:t,b:n}){let r=i=>Math.max(0,Math.min(255,Math.round(i))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function Vz(e,t){return t<=1?{r:e.r*t,g:e.g*t,b:e.b*t}:{r:e.r+(255-e.r)*(t-1),g:e.g+(255-e.g)*(t-1),b:e.b+(255-e.b)*(t-1)}}function JU({r:e,g:t,b:n}){let r=i=>{let o=i/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function Xd(e){let t=Wd(e);return t===void 0?"#ffffff":JU(t)>.35?"#12111a":"#ffffff"}function Wb(e,t,n){let r=Wd(t)??Wd(n);if(r===void 0)return;let i=document.documentElement.style,o=Gb(r);i.setProperty(`--lc-${e}`,o),i.setProperty(`--lc-${e}-deep`,Gb(Vz(r,.62))),i.setProperty(`--lc-${e}-bright`,Gb(Vz(r,1.22))),i.setProperty(`--lc-${e}-contrast`,Xd(o)),i.setProperty(`--lc-${e}-a12`,`rgba(${r.r}, ${r.g}, ${r.b}, 0.12)`),i.setProperty(`--lc-${e}-a20`,`rgba(${r.r}, ${r.g}, ${r.b}, 0.20)`),i.setProperty(`--lc-${e}-a35`,`rgba(${r.r}, ${r.g}, ${r.b}, 0.35)`)}function Jb(e){Wb("accent",e,Xa)}function Xb(e){Wb("expert",e,Fr)}var Kb={expert:Fr,programmer:"#8B7FD4",reviewer:"#3B9EDB",tester:"#D4A72C",librarian:"#59B89C"};function Qb(e,t){Wb(`agent-${e}`,t,Kb[e]??Fr)}function qz(e,t=[]){let n=new Set([...Object.keys(Kb),...t,...Object.keys(e??{})]);for(let r of n)Qb(r,e?.[r]??Kd(r))}function Kd(e){return Kb[e]??XU(e)}function XU(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t^=t>>>16,t=Math.imul(t,2146121005)>>>0,t^=t>>>15,t=Math.imul(t,2221713035)>>>0,t^=t>>>16,KU((t>>>0)%12*30,.52,.58)}function KU(e,t,n){let r=(1-Math.abs(2*n-1))*t,i=r*(1-Math.abs(e/60%2-1)),o=n-r/2,[a,l,c]=e<60?[r,i,0]:e<120?[i,r,0]:e<180?[0,r,i]:e<240?[0,i,r]:e<300?[i,0,r]:[r,0,i],u=d=>Math.round((d+o)*255).toString(16).padStart(2,"0");return`#${u(a)}${u(l)}${u(c)}`}function ex(e){let[t,n]=(0,Qd.useState)(e.value);(0,Qd.useEffect)(()=>n(e.value),[e.value]);let r=o=>{n(o),Jd(o)&&e.onChange(o)},i=e.value.toLowerCase();return(0,Ne.jsxs)("div",{style:{marginBottom:22},children:[(0,Ne.jsx)("span",{style:D(),children:e.label}),(0,Ne.jsx)("p",{style:{color:s.muted,fontSize:11,margin:"0 0 8px"},children:e.description}),(0,Ne.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginBottom:10},children:e.presets.map(o=>{let a=o.value.toLowerCase()===i;return(0,Ne.jsx)("button",{type:"button",className:"lc-swatch",title:o.label,"aria-label":o.label,"aria-pressed":a,onClick:()=>r(o.value),style:{width:26,height:26,borderRadius:"50%",border:"none",cursor:"pointer",padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",background:o.value,color:Xd(o.value)},children:a&&(0,Ne.jsx)(Di,{size:13})},o.id)})}),(0,Ne.jsx)("label",{style:{...D(),marginBottom:4},htmlFor:e.inputId,children:"Or a custom hex colour"}),(0,Ne.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,Ne.jsx)("input",{id:e.inputId,type:"text",value:t,spellCheck:!1,placeholder:e.fallback,onChange:o=>r(o.target.value),style:{...A(),width:130,fontFamily:"var(--vscode-editor-font-family, monospace)"}}),(0,Ne.jsx)("span",{"aria-hidden":"true",style:{width:26,height:26,borderRadius:8,flexShrink:0,background:Jd(t)?t:"transparent",border:`1px solid ${s.border}`}}),!Jd(t)&&(0,Ne.jsxs)("span",{style:{color:s.error,fontSize:11,fontFamily:V},children:["Needs a hex colour, e.g. ",e.fallback]})]})]})}function Gz(e){let t=e.accentColor.toLowerCase()===e.expertColor.toLowerCase();return(0,Ne.jsxs)("section",{children:[e.onChangeTheme!==void 0&&(0,Ne.jsxs)("div",{style:{marginBottom:16},children:[(0,Ne.jsx)("label",{style:D(),children:"Theme"}),(0,Ne.jsx)("div",{style:{display:"flex",gap:6,marginBottom:4},children:["system","light","dark"].map(n=>{let r=(e.theme??"system")===n;return(0,Ne.jsx)("button",{type:"button",onClick:()=>e.onChangeTheme?.(n),style:{...A(),width:"auto",cursor:"pointer",textTransform:"capitalize",...r?{borderColor:s.accent,color:s.accent,fontWeight:600}:{}},children:n},n)})}),(0,Ne.jsxs)("span",{style:{display:"block",color:s.muted,fontSize:11},children:[(0,Ne.jsx)("strong",{children:"System"})," follows your browser\u2019s appearance setting \u2014 which is the browser\u2019s own, not Windows\u2019. If your browser is pinned to light by policy, choose Dark here instead."]})]}),(0,Ne.jsx)(ex,{label:"Accent colour",description:"Buttons, your messages, selections and focus rings.",value:e.accentColor,presets:Hz,fallback:Xa,inputId:"lc-accent-hex",onChange:e.onChangeAccent}),(0,Ne.jsx)(ex,{label:"Expert colour",description:"Marks answers that came from Claude rather than from your own model. Kept separate from the accent so the two are told apart at a glance.",value:e.expertColor,presets:Yb,fallback:Fr,inputId:"lc-expert-hex",onChange:e.onChangeExpert}),e.agentRoles.length>0&&(0,Ne.jsx)("div",{style:{marginTop:4},children:e.agentRoles.filter(n=>n.role!=="expert").map(n=>(0,Ne.jsx)(ex,{label:`${n.name} colour`,description:`Marks answers from the ${n.name.toLowerCase()}.`,value:e.agentColors[n.role]??Kd(n.role),presets:Yb,fallback:Kd(n.role),inputId:`lc-agent-${n.role}-hex`,onChange:r=>e.onChangeAgentColor(n.role,r)},n.role))}),t&&(0,Ne.jsx)("p",{style:{color:s.error,fontSize:11,margin:"0 0 14px"},children:"These are the same colour, so expert answers will not stand out. Only the expert mark will tell them apart."}),(0,Ne.jsxs)("div",{style:{borderTop:`1px solid ${s.border}`,paddingTop:12},children:[(0,Ne.jsx)("span",{style:D(),children:"Preview"}),(0,Ne.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8,marginTop:6},children:[(0,Ne.jsx)("div",{style:{display:"flex",justifyContent:"flex-end"},children:(0,Ne.jsx)("span",{style:{padding:"7px 12px",borderRadius:"14px 14px 4px 14px",background:`linear-gradient(135deg, ${e.accentColor}, ${e.accentColor})`,color:Xd(e.accentColor),fontSize:12,fontFamily:V},children:"Your message"})}),(0,Ne.jsx)("div",{style:{display:"flex"},children:(0,Ne.jsx)("span",{style:{padding:"7px 12px",borderRadius:"14px 14px 14px 4px",background:s.assistantBubble,color:s.foreground,fontSize:12,fontFamily:V},children:"The assistant's reply"})}),(0,Ne.jsxs)("div",{style:{display:"inline-flex",alignItems:"center",gap:6,alignSelf:"flex-start",padding:"6px 10px",borderRadius:10,border:`1px solid ${e.expertColor}`,background:s.expertSoft,color:e.expertColor,fontSize:12,fontFamily:V},children:[(0,Ne.jsx)(wn,{size:12}),"Answered by the expert"]})]})]})]})}function tx(e){if(e===void 0)return;if(e.error!==void 0)return`Failed: ${e.error}`;let t=e.indexed??0;return`Indexed ${String(t)} ${t===1?"entry":"entries"}.`}var QU={expert:"agents"},Yz=[{id:"providers",label:"Providers",Icon:i$},{id:"approvals",label:"Approvals",Icon:ub},{id:"mcp",label:"MCP",Icon:r$},{id:"search",label:"Search",Icon:o$},{id:"agents",label:"Agents",Icon:wn},{id:"schedules",label:"Schedules",Icon:f$},{id:"python",label:"Python",Icon:l$},{id:"tools",label:"Tools",Icon:c$},{id:"outlook",label:"Outlook",Icon:u$},{id:"customData",label:"Custom data",Icon:h$},{id:"skills",label:"Skills",Icon:d$},{id:"network",label:"Network",Icon:a$},{id:"reviews",label:"Review",Icon:ub},{id:"variables",label:"Variables",Icon:t$},{id:"appearance",label:"Appearance",Icon:n$}];function nx(e){let[t,n]=(0,ef.useState)("providers"),r={variables:e.variables!==void 0,reviews:e.reviews!==void 0,outlook:e.offersOffice!==!1},i=Yz.filter(l=>r[l.id]??!0),o=i.some(l=>l.id===t)?t:"providers",a=e.requestedTab;return(0,ef.useEffect)(()=>{if(a===void 0)return;let l=QU[a.tab]??a.tab;Yz.some(c=>c.id===l)&&n(l)},[a]),(0,lt.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,lt.jsx)("div",{role:"tablist",className:"lc-scroll",style:{display:"flex",borderBottom:`1px solid ${s.border}`,flexShrink:0,overflowX:"auto"},children:i.map(l=>{let c=o===l.id;return(0,lt.jsxs)("button",{type:"button",role:"tab","aria-selected":c,className:"lc-tab",title:l.label,"aria-label":l.label,onClick:()=>n(l.id),style:{display:"inline-flex",alignItems:"center",gap:5,padding:c?"8px 10px":"8px 8px",fontFamily:V,fontSize:12,background:"transparent",color:c?s.accent:s.muted,border:"none",cursor:"pointer",whiteSpace:"nowrap",flexShrink:0},children:[(0,lt.jsx)(l.Icon,{size:15}),c&&(0,lt.jsx)("span",{children:l.label})]},l.id)})}),(0,lt.jsx)("div",{className:"lc-scroll lc-panel",style:{flex:1,minHeight:0,overflowY:"auto"},children:o==="reviews"&&e.reviews!==void 0?(0,lt.jsx)(zz,{...e.reviews}):o==="variables"&&e.variables!==void 0?(0,lt.jsx)(Cz,{...e.variables}):o==="appearance"?(0,lt.jsx)("div",{style:{padding:12},children:(0,lt.jsx)(Gz,{accentColor:e.accentColor,onChangeAccent:e.onSetAccentColor,expertColor:e.expertColor,onChangeExpert:e.onSetExpertColor,agentRoles:e.agents.roles.map(l=>({role:l.role,name:l.name})),agentColors:e.agents.colors,onChangeAgentColor:e.onSetAgentColor,...e.theme===void 0?{}:{theme:e.theme},...e.choosesTheme===!0&&e.onSetTheme!==void 0?{onChangeTheme:e.onSetTheme}:{}})}):o==="providers"?(0,lt.jsx)(qb,{onBrowse:e.onBrowse,...e.pickedPath===void 0?{}:{pickedPath:e.pickedPath},...e.sharedProfileIds!==void 0?{sharedProfileIds:e.sharedProfileIds}:{},profiles:e.profiles,activeProfileId:e.activeProfileId,onSave:e.onSave,onDuplicate:e.onDuplicate,onDelete:e.onDelete,onSetActive:e.onSetActive,onExport:e.onExport,onImport:e.onImport,onRequestModels:e.onRequestModels,onTestConnection:e.onTestConnection,onEditingChange:e.onEditingChange,models:e.models,...e.modelsWarning!==void 0?{modelsWarning:e.modelsWarning}:{},modelsLoading:e.modelsLoading,testRunning:e.testRunning,...e.testResult!==void 0?{testResult:e.testResult}:{}}):o==="approvals"?(0,lt.jsx)(jb,{approvals:e.approvals,onSetAutoApprove:e.onSetAutoApprove,onRevokeTool:e.onRevokeTool,onRevokeCommand:e.onRevokeCommand,maxIterations:e.maxIterations,onSetMaxIterations:e.onSetMaxIterations,readRoots:e.readRoots,onSetReadRoots:e.onSetReadRoots}):o==="search"?(0,lt.jsx)(xz,{...e.search}):o==="schedules"?(0,lt.jsx)(Oz,{...e.schedules}):o==="skills"?(0,lt.jsx)(jz,{...e.skills}):o==="tools"?(0,lt.jsx)($z,{...e.tools}):o==="outlook"?(0,lt.jsx)(_z,{...e.outlook,onOpenTools:()=>n("tools")}):o==="customData"?(0,lt.jsx)(tz,{...e.customData,onOpenPython:()=>n("python")}):o==="python"?(0,lt.jsx)(kz,{...e.python}):o==="network"?(0,lt.jsx)(Sz,{...e.network,onBrowse:e.onBrowse,pickedPath:e.pickedPath}):o==="agents"?(0,lt.jsx)(sz,{...e.agents,budgetPanel:(0,lt.jsx)(fz,{expert:e.expert,onSave:e.onSaveExpert,onRecheck:e.onRecheckExpert,onMeasureCost:e.onMeasureCost,onClearPricing:e.onClearPricing,onSetKeepAlive:e.onSetKeepAlive,onBrowse:e.onBrowse,pickedPath:e.pickedPath}),fitPanel:(0,lt.jsx)(hz,{assessments:e.expert?.assessments??[],seatFits:e.expert?.seatFits??[],expertGuidance:e.expert?.expertGuidance??"",assessor:e.expert?.assessor,profiles:e.agents.profiles,assessing:e.expert?.assessing===!0,step:e.expert?.assessmentStep,onAssess:e.onAssessJunior,onClear:e.onClearAssessment})}):(0,lt.jsx)(Ub,{servers:e.mcpServers,json:e.mcpJson,warnings:e.mcpWarnings,saveError:e.mcpSaveError,configs:e.mcpConfigs,platform:e.mcpPlatform,savedTick:e.mcpSavedTick,pythonProbe:e.mcpPythonProbe,onDetectPython:e.onDetectPython,onBrowse:e.onBrowse,pickedPath:e.pickedPath,onSaveServer:e.onSaveMcpServer,onDeleteServer:e.onDeleteMcpServer,onDuplicateServer:e.onDuplicateMcpServer,onSave:e.onSaveMcp,onRestart:e.onRestartMcp,onSetServerEnabled:e.onSetMcpServerEnabled,onSetToolPermission:e.onSetMcpToolPermission,onSetToolTimeout:e.onSetMcpToolTimeout,onConnect:e.onConnectMcp,docsIndex:{enabled:e.search.dispatcher.enabled,ready:e.search.dispatcher.retrievalReady,indexing:e.search.dispatcher.indexing,result:tx(e.search.dispatcher.result)},onIndexDocs:()=>e.search.dispatcher.onIndexDocs("tool"),indexProgress:e.tools.progress,onStopIndexing:e.tools.onStopIndexing})},o)]})}var Wz=N(ne(),1);function ix(e){let t=Vm(e.modeId);return(0,Wz.jsx)($e,{compact:!0,value:t.id,disabled:e.disabled,title:t.description,ariaLabel:"Mode",onChange:e.onChange,options:Fc.map(n=>({value:n.id,label:n.name,...n.requiresExpert===!0&&!e.expertAvailable?{disabled:!0,detail:"needs the expert"}:{}}))})}var _t=N(ne(),1);var Jz=N(pe(),1);function Xz(e){let[t,n]=(0,Jz.useState)(0),r=Or[t]??Or[0],i=t===0,o=t===Or.length-1;return(0,_t.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,fontFamily:V,fontSize:13,color:s.foreground},children:[(0,_t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",borderBottom:`1px solid ${s.border}`,flexShrink:0},children:[(0,_t.jsx)("strong",{style:{fontSize:13},children:r.title}),(0,_t.jsxs)("span",{style:{marginLeft:"auto",color:s.muted,fontSize:11},children:[t+1," of ",Or.length]}),(0,_t.jsx)("button",{type:"button",style:{...z(),fontSize:11},onClick:e.onClose,children:"Close"})]}),(0,_t.jsxs)("div",{className:"lc-scroll",style:{flex:1,minHeight:0,overflowY:"auto",padding:12},children:[e.mediaBase!==void 0&&(0,_t.jsxs)("picture",{children:[(0,_t.jsx)("source",{media:"(prefers-color-scheme: dark)",srcSet:`${e.mediaBase}/${r.id}-dark.svg`}),(0,_t.jsx)("img",{src:`${e.mediaBase}/${r.id}-light.svg`,alt:r.altText,style:{display:"block",width:"100%",maxWidth:"100%",height:"auto",borderRadius:6,border:`1px solid ${s.border}`,marginBottom:12}})]}),r.body.map((a,l)=>(0,_t.jsx)("div",{style:{marginBottom:10,lineHeight:1.5},children:(0,_t.jsx)(Ld,{text:a})},l)),r.tab!==void 0&&(0,_t.jsxs)("button",{type:"button",style:{...le(!1),marginTop:4},onClick:()=>e.onOpenTab(r.tab),children:["Open the ",r.tab[0]?.toUpperCase(),r.tab.slice(1)," tab"]}),r.tab===void 0&&r.opensPanel===!0&&(0,_t.jsx)("button",{type:"button",style:{...z(),marginTop:4},onClick:e.onClose,children:"Back to the chat"})]}),(0,_t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",borderTop:`1px solid ${s.border}`,flexShrink:0},children:[(0,_t.jsx)("button",{type:"button",style:z(),disabled:i,onClick:()=>n(a=>Math.max(0,a-1)),children:"Back"}),(0,_t.jsx)("div",{style:{display:"flex",gap:4,flex:1,justifyContent:"center",flexWrap:"wrap"},children:Or.map((a,l)=>(0,_t.jsx)("button",{type:"button","aria-label":a.title,title:a.title,onClick:()=>n(l),style:{width:7,height:7,padding:0,borderRadius:"50%",border:"none",cursor:"pointer",background:l===t?s.accent:s.border}},a.id))}),o?(0,_t.jsx)("button",{type:"button",style:le(!1),onClick:e.onClose,children:"Done"}):(0,_t.jsx)("button",{type:"button",style:le(!1),onClick:()=>n(a=>Math.min(Or.length-1,a+1)),children:"Next"})]})]})}var Yt=N(ne(),1),Kz=N(pe(),1);function eN(e,t=Date.now()){let n=Math.max(0,Math.round((t-e)/1e3));if(n<60)return"just now";let r=Math.round(n/60);if(r<60)return`${r}m ago`;let i=Math.round(r/60);if(i<24)return`${i}h ago`;let o=Math.round(i/24);return o<=7?`${o}d ago`:new Date(e).toLocaleDateString()}function Qz(e){let[t,n]=(0,Kz.useState)(void 0);return(0,Yt.jsxs)("div",{style:{padding:12,overflowY:"auto"},children:[(0,Yt.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[(0,Yt.jsx)("h3",{style:{margin:0,color:s.foreground},children:"History"}),(0,Yt.jsx)("button",{type:"button",style:{...le(!1),marginLeft:"auto"},onClick:e.onNew,children:"New task"})]}),e.tasks.length===0&&(0,Yt.jsx)("p",{style:{color:s.muted,fontFamily:V},children:"No past tasks in this workspace yet. Conversations are saved automatically as you go."}),e.tasks.map(r=>{let i=r.id===e.activeTaskId,o=r.id===t;return(0,Yt.jsxs)("div",{style:{padding:10,marginBottom:8,borderRadius:4,border:`1px solid ${i?s.accent:s.border}`,background:i?s.assistantBubble:"transparent"},children:[(0,Yt.jsx)("div",{style:{color:s.foreground,marginBottom:4,wordBreak:"break-word"},children:r.title}),(0,Yt.jsxs)("div",{style:{color:s.muted,fontSize:11,marginBottom:8},children:[eN(r.updatedAt)," \xB7 ",r.messageCount," message",r.messageCount===1?"":"s",i?" \xB7 current":""]}),o?(0,Yt.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center",flexWrap:"wrap"},children:[(0,Yt.jsx)("span",{style:{color:s.muted,fontSize:11},children:"Delete this task and its saved output?"}),(0,Yt.jsx)("button",{type:"button",style:{...z(),color:s.error},onClick:()=>{n(void 0),e.onDelete(r.id)},children:"Delete"}),(0,Yt.jsx)("button",{type:"button",style:z(),onClick:()=>n(void 0),children:"Cancel"})]}):(0,Yt.jsxs)("div",{style:{display:"flex",gap:6},children:[!i&&(0,Yt.jsx)("button",{type:"button",style:z(),onClick:()=>e.onOpen(r.id),children:"Open"}),(0,Yt.jsx)("button",{type:"button",style:z(),onClick:()=>n(r.id),children:"Delete"})]})]},r.id)})]})}function Ka(e){let t=e.map(r=>r.kind==="reasoning"&&r.pending===!0?{kind:"reasoning",content:r.content}:r),n=t[t.length-1];return n===void 0||n.kind!=="text"||!n.pending?t:[...t.slice(0,-1),{kind:"text",role:n.role,content:n.content,...n.expertInformed===!0?{expertInformed:!0}:{},...n.informedBy!==void 0?{informedBy:n.informedBy}:{}}]}function rx(e){let[t,n]=(0,F.useState)("chat"),[r,i]=(0,F.useState)(),[o,a]=(0,F.useState)({native:!0}),[l,c]=(0,F.useState)(),[u,d]=(0,F.useState)(),[h,m]=(0,F.useState)(),[f,y]=(0,F.useState)(!1),[k,E]=(0,F.useState)(),[g,b]=(0,F.useState)([]),[S,v]=(0,F.useState)(!1),[C,K]=(0,F.useState)(void 0),[q,w]=(0,F.useState)([]),[R,ce]=(0,F.useState)(void 0),[Me,ct]=(0,F.useState)(!1),[en,cn]=(0,F.useState)(void 0),[hi,L]=(0,F.useState)(void 0),[de,He]=(0,F.useState)(!1),[Ft,U]=(0,F.useState)(Fm),[fe,yt]=(0,F.useState)({}),[et,At]=(0,F.useState)(25),[_i,rt]=(0,F.useState)(Xa),[qi,pi]=(0,F.useState)([]),[A6,BS]=(0,F.useState)(Fr),[Dm,LS]=(0,F.useState)({type:"agents",roles:[],profiles:[],cliAvailable:!1,budgetMatters:!1,claudeSeated:!1,teamGuidance:"",defaultTeamGuidance:"",teamGuidanceIsDefault:!0,colors:{}}),[Yn,j6]=(0,F.useState)({usd:0,consultations:0,unpriced:0,maxSpendUsd:0,maxConsultations:0,overridden:!1}),[vo,Am]=(0,F.useState)({enabled:!0,hiddenTools:0,skills:!0,hiddenSkills:0}),[jm,Bc]=(0,F.useState)(!1),[O6,U6]=(0,F.useState)([]),[Fl,PS]=(0,F.useState)({}),[Vl,ta]=(0,F.useState)({}),$i=x=>PS(P=>{let p={...P};return delete p[x],p}),[bo,na]=(0,F.useState)(void 0),[N6,R6]=(0,F.useState)([]),[M6,B6]=(0,F.useState)(`{
|
|
144
|
+
`)),style:{...A(),fontFamily:ni,resize:"vertical"}}),(0,se.jsxs)("span",{style:{display:"block",color:s.muted,fontSize:11,marginBottom:12},children:["The program first, then each argument on its own line. Spawned directly, so there are no pipes, no redirection and no ",(0,se.jsx)("code",{style:{fontFamily:ni},children:"&&"})," ","\u2014 put shell logic in a script instead."]})]}),(0,se.jsx)("button",{type:"button",style:{background:"none",border:"none",color:s.accent,cursor:"pointer",padding:0,fontSize:11},onClick:()=>i(y=>!y),children:l?"Enter a command instead":"It is a Python script"}),(0,se.jsx)("div",{style:{marginTop:10},children:(0,se.jsx)("button",{type:"button",style:{background:"none",border:"none",color:s.accent,cursor:"pointer",padding:0,fontSize:11},onClick:()=>a(y=>!y),children:o?"Hide advanced":"Advanced \u2014 JSON output, expiry, headers"})}),o&&(0,se.jsxs)("div",{style:{marginTop:10,paddingLeft:10,borderLeft:`2px solid ${s.border}`},children:[(0,se.jsx)("p",{style:{color:s.muted,fontSize:11,margin:"0 0 10px"},children:"Leave these empty if the script prints a bare token. Fill the two paths in if it prints the gateway\u2019s JSON instead \u2014 then it refreshes on the real expiry rather than an assumed hour."}),(0,se.jsx)("label",{htmlFor:"lc-token-path",style:D(),children:"Token field"}),(0,se.jsx)("input",{id:"lc-token-path",type:"text",value:e.value.tokenPath??"",spellCheck:!1,placeholder:"access_token",onChange:y=>f("tokenPath",y.target.value.trim()===""?void 0:y.target.value),style:{...A(),fontFamily:ni}}),(0,se.jsxs)("label",{htmlFor:"lc-expires-path",style:D(),children:["Expiry field ",(0,se.jsx)("span",{style:{color:s.muted,fontWeight:400},children:"(seconds)"})]}),(0,se.jsx)("input",{id:"lc-expires-path",type:"text",value:e.value.expiresInPath??"",spellCheck:!1,placeholder:"expires_in",onChange:y=>f("expiresInPath",y.target.value.trim()===""?void 0:y.target.value),style:{...A(),fontFamily:ni}}),(0,se.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,se.jsxs)("div",{style:{flex:1},children:[(0,se.jsx)("label",{htmlFor:"lc-token-expiry",style:D(),children:"Assume it lasts (s)"}),(0,se.jsx)("input",{id:"lc-token-expiry",type:"text",inputMode:"numeric",value:e.value.fallbackExpirySeconds??"",placeholder:"3600",onChange:y=>f("fallbackExpirySeconds",Number(y.target.value)||void 0),style:A()})]}),(0,se.jsxs)("div",{style:{flex:1},children:[(0,se.jsx)("label",{htmlFor:"lc-token-skew",style:D(),children:"Refresh this early (s)"}),(0,se.jsx)("input",{id:"lc-token-skew",type:"text",inputMode:"numeric",value:e.value.refreshSkewSeconds??"",placeholder:"60",onChange:y=>f("refreshSkewSeconds",Number(y.target.value)||void 0),style:A()})]}),(0,se.jsxs)("div",{style:{flex:1},children:[(0,se.jsx)("label",{htmlFor:"lc-token-timeout",style:D(),children:"Give up after (s)"}),(0,se.jsx)("input",{id:"lc-token-timeout",type:"text",inputMode:"numeric",value:e.value.timeoutSeconds??"",placeholder:"30",onChange:y=>f("timeoutSeconds",Number(y.target.value)||void 0),style:A()})]})]}),(0,se.jsxs)("label",{htmlFor:"lc-token-cwd",style:D(),children:["Run it in ",(0,se.jsx)("span",{style:{color:s.muted,fontWeight:400},children:"(optional folder)"})]}),(0,se.jsx)("input",{id:"lc-token-cwd",type:"text",value:e.value.cwd??"",spellCheck:!1,onChange:y=>f("cwd",y.target.value.trim()===""?void 0:y.target.value),style:{...A(),fontFamily:ni}}),(0,se.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,se.jsxs)("div",{style:{flex:1},children:[(0,se.jsx)("label",{htmlFor:"lc-token-header",style:D(),children:"Header name"}),(0,se.jsx)("input",{id:"lc-token-header",type:"text",value:e.value.headerName??"",spellCheck:!1,placeholder:"Authorization",onChange:y=>f("headerName",y.target.value.trim()===""?void 0:y.target.value),style:{...A(),fontFamily:ni}})]}),(0,se.jsxs)("div",{style:{flex:1},children:[(0,se.jsx)("label",{htmlFor:"lc-token-prefix",style:D(),children:"Header prefix"}),(0,se.jsx)("input",{id:"lc-token-prefix",type:"text",value:e.value.headerPrefix??"",spellCheck:!1,placeholder:"Bearer ",onChange:y=>f("headerPrefix",y.target.value===""?void 0:y.target.value),style:{...A(),fontFamily:ni}})]})]}),(0,se.jsxs)("span",{style:{display:"block",color:s.muted,fontSize:11,marginTop:4},children:["Left empty, these follow the wire format \u2014 ",(0,se.jsx)("code",{style:{fontFamily:ni},children:"Authorization: Bearer"})," ","for OpenAI, ",(0,se.jsx)("code",{style:{fontFamily:ni},children:"x-api-key"})," for Anthropic."]})]})]})}var Ut=N(pe(),1);var he=N(ne(),1),Bz=N(pe(),1);function zn(e){return(0,he.jsxs)("div",{style:{marginBottom:10},children:[(0,he.jsx)("label",{htmlFor:e.id,style:D(),children:e.label}),(0,he.jsx)("input",{id:e.id,type:"text",value:e.value??"",placeholder:e.placeholder,onChange:t=>e.onChange(t.target.value),style:A()}),e.hint!==void 0&&(0,he.jsx)("span",{style:{color:s.muted,fontSize:11,display:"block",marginTop:2},children:e.hint})]})}function Mz(e){return(0,he.jsxs)("div",{style:{marginBottom:10},children:[(0,he.jsx)("label",{htmlFor:e.id,style:D(),children:e.label}),(0,he.jsx)("input",{id:e.id,type:"number",value:e.value??"",placeholder:e.placeholder,onChange:t=>{let n=Number.parseInt(t.target.value,10);e.onChange(Number.isNaN(n)?void 0:n)},style:A()})]})}function GU(e){let[t,n]=(0,Bz.useState)(!1);return(0,he.jsxs)("div",{style:{marginBottom:12},children:[(0,he.jsxs)("button",{type:"button",onClick:()=>n(!t),style:{background:"transparent",border:"none",color:s.foreground,fontFamily:V,fontSize:12,padding:0,cursor:"pointer"},children:[t?"\u25BE":"\u25B8"," ",e.title]}),t&&(0,he.jsx)("div",{style:{marginTop:8,paddingLeft:12},children:e.children})]})}function Lz(e){let t=r=>e.onApigeeChange({...e.apigee,...r}),n=r=>e.onCertsChange({...e.certs,...r});return(0,he.jsxs)("div",{style:{paddingTop:12,borderTop:`1px solid ${s.border}`},children:[(0,he.jsxs)("div",{style:{marginBottom:12},children:[(0,he.jsx)("label",{htmlFor:"lc-auth-type",style:D(),children:"Authentication"}),(0,he.jsx)($e,{id:"lc-auth-type",value:e.authType,onChange:r=>e.onAuthTypeChange(r),style:{width:"100%"},options:[{value:"apiKey",label:"API key"},{value:"header",label:"A header the gateway expects"},{value:"tokenCommand",label:"Token from a script"},{value:"apigeeMtls",label:"Mutual TLS + OAuth (Apigee)"},{value:"none",label:"None"}]})]}),e.authType==="apigeeMtls"&&(0,he.jsxs)(he.Fragment,{children:[(0,he.jsxs)("div",{style:{marginBottom:12},children:[(0,he.jsx)("strong",{style:{fontSize:12,color:s.foreground},children:"Client certificate"}),(0,he.jsx)("p",{style:{color:s.muted,fontSize:11,margin:"4px 0 8px"},children:"Must live outside the workspace \u2014 a repository must not be able to read or replace your key material. Filenames resolve against the directory; absolute paths override it."})]}),(0,he.jsx)(zn,{id:"lc-cert-dir",label:"Certificate directory",value:e.certs.certDir,placeholder:"C:\\\\Users\\\\you\\\\certs",hint:"Leave blank to use the global certDir from config.",onChange:r=>n({certDir:r})}),(0,he.jsx)(zn,{id:"lc-cert-file",label:"Certificate file",value:e.certs.certFile,placeholder:"client.crt",onChange:r=>n({certFile:r})}),(0,he.jsx)(zn,{id:"lc-key-file",label:"Private key file",value:e.certs.keyFile,placeholder:"client.key",onChange:r=>n({keyFile:r})}),(0,he.jsx)(zn,{id:"lc-pfx-file",label:"PFX bundle (instead of certificate + key)",value:e.certs.pfxFile,placeholder:"client.pfx",hint:"Corporate Windows PKI usually issues a .pfx.",onChange:r=>n({pfxFile:r})}),(0,he.jsx)(zn,{id:"lc-ca-file",label:"Extra CA bundle",value:e.certs.caFile,placeholder:"corp-root.pem",hint:"Needed when your network intercepts TLS. NODE_EXTRA_CA_CERTS also works.",onChange:r=>n({caFile:r})}),(0,he.jsx)(Ri,{id:"lc-cert-passphrase",label:"Key / PFX passphrase",hasValue:e.hasCertPassphrase,value:e.certPassphrase,onChange:e.onCertPassphraseChange,placeholder:"Leave blank if the key is not encrypted"}),(0,he.jsx)("div",{style:{marginBottom:12},children:(0,he.jsx)("strong",{style:{fontSize:12,color:s.foreground},children:"Token endpoint"})}),(0,he.jsx)(zn,{id:"lc-token-url",label:"Token URL",value:e.apigee.tokenUrl,placeholder:"https://gateway.example.com/oauth/token",hint:"Defaults to the base URL's origin + /oauth/token.",onChange:r=>t({tokenUrl:r})}),(0,he.jsx)(zn,{id:"lc-client-id",label:"Client ID",value:e.apigee.clientId,onChange:r=>t({clientId:r})}),(0,he.jsx)(Ri,{id:"lc-client-secret",label:"Client secret",hasValue:e.hasClientSecret,value:e.clientSecret,onChange:e.onClientSecretChange,placeholder:"Stored in the OS keychain"}),(0,he.jsx)(zn,{id:"lc-scope",label:"Scope",value:e.apigee.scope,placeholder:"(optional)",onChange:r=>t({scope:r})}),(0,he.jsxs)(GU,{title:"Token response and header mapping",children:[(0,he.jsx)(zn,{id:"lc-grant-type",label:"Grant type",value:e.apigee.grantType,placeholder:"client_credentials",onChange:r=>t({grantType:r})}),(0,he.jsx)(zn,{id:"lc-token-path",label:"Token path in response",value:e.apigee.tokenPath,placeholder:"access_token",hint:"Dotted path, e.g. data.jwt if your gateway nests it.",onChange:r=>t({tokenPath:r})}),(0,he.jsx)(zn,{id:"lc-expires-path",label:"Expiry path in response",value:e.apigee.expiresInPath,placeholder:"expires_in",onChange:r=>t({expiresInPath:r})}),(0,he.jsx)(zn,{id:"lc-token-header",label:"Header name",value:e.apigee.tokenHeaderName,placeholder:"Authorization",onChange:r=>t({tokenHeaderName:r})}),(0,he.jsx)(zn,{id:"lc-token-prefix",label:"Header prefix",value:e.apigee.tokenHeaderPrefix,placeholder:"Bearer ",onChange:r=>t({tokenHeaderPrefix:r})}),(0,he.jsx)(Mz,{id:"lc-fallback-expiry",label:"Fallback expiry (seconds)",value:e.apigee.fallbackExpirySeconds,placeholder:"3600",onChange:r=>t({...r!==void 0?{fallbackExpirySeconds:r}:{}})}),(0,he.jsx)(Mz,{id:"lc-refresh-skew",label:"Refresh skew (seconds)",value:e.apigee.refreshSkewSeconds,placeholder:"60",onChange:r=>t({...r!==void 0?{refreshSkewSeconds:r}:{}})})]})]}),(0,he.jsxs)("div",{style:{marginBottom:12,paddingTop:12,borderTop:`1px solid ${s.border}`},children:[(0,he.jsx)("strong",{style:{fontSize:12,color:s.foreground},children:"Connection security"}),(0,he.jsx)("p",{style:{color:s.muted,fontSize:11,margin:"4px 0 8px"},children:"Needed when your network intercepts TLS, which is common on a corporate gateway. This is separate from the client certificate above: it decides whether you trust the server, not how the server identifies you."})]}),(0,he.jsx)(zn,{id:"lc-connection-ca",label:"Additional CA certificate",value:e.connectionTls.caFile,placeholder:"C:\\\\certs\\\\corp-root.pem",hint:"Only needed if this gateway uses a different root from the one in Settings \u2192 Network. Added to that one and to the built-in roots, never replacing either.",onChange:r=>e.onConnectionTlsChange({...e.connectionTls,caFile:r})}),(0,he.jsxs)("label",{style:{display:"flex",alignItems:"flex-start",gap:6,marginBottom:6,fontSize:12},children:[(0,he.jsx)("input",{type:"checkbox",style:{marginTop:2},checked:e.connectionTls.rejectUnauthorized===!1,onChange:r=>e.onConnectionTlsChange({...e.connectionTls,...r.target.checked?{rejectUnauthorized:!1}:{rejectUnauthorized:void 0}})}),(0,he.jsx)("span",{style:{color:s.foreground},children:"Skip certificate verification for this profile"})]}),e.connectionTls.rejectUnauthorized===!1&&(0,he.jsx)("p",{style:{color:s.error,fontSize:11,margin:"0 0 12px",paddingLeft:22},children:"Anyone able to intercept this connection can now read and modify it, including your API key, and nothing will detect it. Supplying the CA file above is the safe fix and solves the same problem."})]})}var wt=N(ne(),1);function Pz(e){let t=e.value.trim(),n=t.length>0?Kv(t,e.capabilities):void 0,r=o=>e.onCapabilitiesChange({...e.capabilities,...o}),i=()=>{let o={...e.capabilities};delete o.contextWindow,e.onCapabilitiesChange(o)};return(0,wt.jsxs)("div",{style:{marginBottom:12},children:[(0,wt.jsx)("label",{htmlFor:"lc-model",style:D(),children:"Model"}),(0,wt.jsxs)("div",{style:{display:"flex",gap:6,marginBottom:6},children:[(0,wt.jsx)("input",{id:"lc-model",type:"text",value:e.value,placeholder:"gpt-4o-mini",onChange:o=>e.onChange(o.target.value),style:A()}),(0,wt.jsx)("button",{type:"button",style:z(),onClick:e.onRefresh,disabled:e.loading,children:e.loading?"Loading\u2026":"Refresh"})]}),e.models.length>0&&(0,wt.jsx)($e,{ariaLabel:"Choose from the gateway's catalogue",value:e.models.includes(e.value)?e.value:"",onChange:o=>{o.length>0&&e.onChange(o)},style:{width:"100%"},options:[{value:"",label:`Choose from ${e.models.length} available model(s)\u2026`},...e.models.map(o=>({value:o,label:o}))]}),e.warning!==void 0&&e.models.length===0&&(0,wt.jsx)("span",{style:{...nn(),color:s.muted},children:e.warning}),e.error!==void 0&&(0,wt.jsx)("span",{style:nn(),children:e.error}),n!==void 0&&(0,wt.jsxs)("div",{style:{marginTop:6,padding:8,border:`1px solid ${s.border}`,borderRadius:3},children:[(0,wt.jsx)("div",{style:{color:s.muted,fontSize:11,marginBottom:6},children:n.known?"Capabilities for this model. Edit any of them if your deployment differs.":"Unrecognised model id \u2014 these are conservative guesses. Correct them here."}),(0,wt.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[(0,wt.jsx)("label",{htmlFor:"lc-context-window",style:{...D(),marginBottom:0,flex:1},children:"Context window (tokens)"}),(0,wt.jsx)("input",{id:"lc-context-window",type:"number",min:1,value:e.capabilities.contextWindow??n.contextWindow,onChange:o=>{let a=Number.parseInt(o.target.value,10);Number.isNaN(a)||a<=0?i():r({contextWindow:a})},style:{...A(),width:130,flex:"none"}}),e.capabilities.contextWindow!==void 0&&(0,wt.jsx)("button",{type:"button",style:z(),onClick:i,title:"Use the built-in value",children:"Reset"})]}),(0,wt.jsxs)("div",{style:{display:"flex",gap:16},children:[(0,wt.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:s.foreground},children:[(0,wt.jsx)("input",{type:"checkbox",checked:n.supportsVision,onChange:o=>r({supportsVision:o.target.checked})}),"Accepts images"]}),(0,wt.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:s.foreground},children:[(0,wt.jsx)("input",{type:"checkbox",checked:n.supportsTools,onChange:o=>r({supportsTools:o.target.checked})}),"Supports tool calling"]})]})]})]})}var Mi=N(ne(),1);var YU={certificates:"Load certificates",token:"Acquire credential",models:"List models"};function WU(e){return e==="ok"?{glyph:"\u2713",color:"var(--vscode-testing-iconPassed, #3fb950)"}:e==="failed"?{glyph:"\u2715",color:s.error}:e==="note"?{glyph:"\u2139",color:s.muted}:{glyph:"\u2013",color:s.muted}}function Zz(e){return(0,Mi.jsxs)("div",{style:{marginBottom:16,paddingTop:12,borderTop:`1px solid ${s.border}`},children:[(0,Mi.jsx)("button",{type:"button",style:z(),onClick:e.onRun,disabled:e.running,children:e.running?"Testing\u2026":"Test Connection"}),e.result!==void 0&&(0,Mi.jsx)("div",{style:{marginTop:8,fontFamily:V,fontSize:12},children:e.result.steps.map(t=>{let n=WU(t.status);return(0,Mi.jsxs)("div",{style:{display:"flex",gap:8,marginBottom:4},children:[(0,Mi.jsx)("span",{style:{color:n.color,width:12,flexShrink:0},children:n.glyph}),(0,Mi.jsxs)("div",{children:[(0,Mi.jsx)("div",{style:{color:s.foreground},children:YU[t.step]}),(0,Mi.jsx)("div",{style:{color:t.status==="failed"?s.error:s.muted,fontSize:11},children:t.detail})]})]},t.step)})})]})}function Hb(e){let[t,n]=(0,Ut.useState)(e.initial.label),[r,i]=(0,Ut.useState)(e.initial.wireFormat),[o,a]=(0,Ut.useState)(e.initial.baseUrl),[l,c]=(0,Ut.useState)(e.initial.model),[u,d]=(0,Ut.useState)(""),[h,m]=(0,Ut.useState)(e.initial.authHeaders??[{name:"",valueRef:""}]),[f,y]=(0,Ut.useState)(e.initial.tokenCommand??{command:["python",""]}),[k,E]=(0,Ut.useState)(e.initial.authType),[g,b]=(0,Ut.useState)(e.initial.apigee??{}),[S,v]=(0,Ut.useState)(""),[C,K]=(0,Ut.useState)(e.initial.certs??{}),[q,w]=(0,Ut.useState)(""),[R,ce]=(0,Ut.useState)(e.initial.modelCapabilities??{}),[Me,ct]=(0,Ut.useState)(e.initial.thinking?.level??""),[en,cn]=(0,Ut.useState)(e.initial.thinking?.style??"effort"),[hi,L]=(0,Ut.useState)(e.initial.connectionTls??{}),[de,He]=(0,Ut.useState)([]),[Ft,U]=(0,Ut.useState)(void 0),fe=rt=>de.find(qi=>qi.path===rt)?.message,yt=rt=>{let qi=Ed.find(pi=>pi.id===rt);qi!==void 0&&(i(qi.wireFormat),a(qi.baseUrl),t.trim().length===0&&n(qi.label))},et=()=>({...e.initial.id!==void 0?{id:e.initial.id}:{},label:t,wireFormat:r,baseUrl:o,model:l,authType:k,apiKey:u,...k==="tokenCommand"?{tokenCommand:f}:{},...k==="header"?{authHeaders:h}:{},...k==="apigeeMtls"?{apigee:g,clientSecret:S,certs:C,certPassphrase:q}:{},...Object.keys(R).length>0?{modelCapabilities:R}:{},...Me===""?{}:{thinking:{level:Me,...r==="openai"?{style:en}:{}}},...hi.caFile!==void 0||hi.rejectUnauthorized!==void 0?{connectionTls:hi}:{}}),At=()=>{let rt=o.trim();if(rt===Ft||rt.length===0)return;try{let pi=new URL(rt);if(pi.protocol!=="https:"&&pi.protocol!=="http:")return}catch{return}(k==="none"||u.trim().length>0||e.initial.hasApiKey||k==="apigeeMtls"||k==="header"&&h.some(pi=>pi.name.trim().length>0&&pi.valueRef.trim().length>0)||k==="tokenCommand"&&f.command.filter(pi=>pi.trim().length>0).length>0)&&(U(rt),e.onRequestModels(et()))},_i=()=>{let rt=Xv({label:t,wireFormat:r,baseUrl:o,model:l});He(rt),!(rt.length>0)&&e.onSave(et())};return(0,Oe.jsxs)("div",{style:{padding:12,overflowY:"auto"},children:[(0,Oe.jsx)("h3",{style:{margin:"0 0 12px",color:s.foreground},children:e.initial.id===void 0?"Add Provider":"Edit Provider"}),(0,Oe.jsxs)("div",{style:{marginBottom:12},children:[(0,Oe.jsx)("label",{htmlFor:"lc-preset",style:D(),children:"Preset"}),(0,Oe.jsx)($e,{id:"lc-preset",value:"",placeholder:"Choose a preset\u2026",onChange:yt,style:{width:"100%"},options:Ed.map(rt=>({value:rt.id,label:rt.label}))})]}),(0,Oe.jsxs)("div",{style:{marginBottom:12},children:[(0,Oe.jsx)("label",{htmlFor:"lc-label",style:D(),children:"Label"}),(0,Oe.jsx)("input",{id:"lc-label",type:"text",value:t,onChange:rt=>n(rt.target.value),style:A()}),fe("label")!==void 0&&(0,Oe.jsx)("span",{style:nn(),children:fe("label")})]}),(0,Oe.jsxs)("div",{style:{marginBottom:12},children:[(0,Oe.jsx)("label",{htmlFor:"lc-base-url",style:D(),children:"Base URL"}),(0,Oe.jsx)("input",{id:"lc-base-url",type:"text",value:o,placeholder:"https://api.openai.com/v1",onChange:rt=>a(rt.target.value),onBlur:At,style:A()}),fe("baseUrl")!==void 0&&(0,Oe.jsx)("span",{style:nn(),children:fe("baseUrl")})]}),(0,Oe.jsx)(Pz,{value:l,onChange:c,models:e.models,...e.modelsWarning!==void 0?{warning:e.modelsWarning}:{},loading:e.modelsLoading,onRefresh:()=>e.onRequestModels(et()),...fe("model")!==void 0?{error:fe("model")}:{},capabilities:R,onCapabilitiesChange:ce}),(0,Oe.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,marginBottom:12},children:[(0,Oe.jsx)("label",{style:D(),children:"Thinking"}),(0,Oe.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[(0,Oe.jsx)("div",{style:{minWidth:150,flex:1},children:(0,Oe.jsx)($e,{compact:!0,ariaLabel:"Thinking level",value:Me,onChange:ct,options:[{value:"",label:"Send nothing (default)"},{value:"off",label:"Off"},{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}]})}),r==="openai"&&Me!==""&&(0,Oe.jsx)("div",{style:{minWidth:210,flex:1},children:(0,Oe.jsx)($e,{compact:!0,ariaLabel:"Thinking parameter",value:en,onChange:rt=>cn(rt),options:[{value:"effort",label:"as reasoning_effort"},{value:"qwen",label:"as enable_thinking (Qwen)"}]})})]}),(0,Oe.jsx)("span",{style:{color:s.muted,fontSize:11,lineHeight:1.5},children:Me===""?"Nothing is sent, which is how every profile behaved before this existed. Set it only against a gateway you know accepts it.":r!=="openai"?"This wire format spells thinking one way, so there is nothing to choose.":en==="effort"?"Sends reasoning_effort. Right for OpenAI and most gateways fronting a reasoning model.":"Sends chat_template_kwargs.enable_thinking, which vLLM and SGLang expose for Qwen3 and its relatives. On or off only \u2014 the level is not a depth dial here."})]}),k==="header"&&(0,Oe.jsx)(Uz,{headers:h,onChange:m}),k==="tokenCommand"&&(0,Oe.jsx)(Rz,{value:f,onChange:y,...e.onBrowse===void 0?{}:{onBrowse:e.onBrowse},...e.pickedPath===void 0?{}:{pickedPath:e.pickedPath}}),k==="apiKey"&&(0,Oe.jsxs)("div",{onBlur:At,children:[(0,Oe.jsx)(Ri,{id:"lc-api-key",label:"API key",hasValue:e.initial.hasApiKey,value:u,onChange:d,...e.initial.apiKeyEnvVar===void 0?{}:{envVar:e.initial.apiKeyEnvVar}}),(0,Oe.jsxs)("span",{style:{display:"block",color:s.muted,fontSize:11,marginTop:-10,marginBottom:16},children:["Enter ",(0,Oe.jsx)("code",{style:{fontFamily:"var(--vscode-editor-font-family, monospace)"},children:"env:API_TOKEN"})," to read the key from that environment variable instead of storing it. It is read fresh on every request, and must be exported before Light Code starts \u2014 a child process cannot see a variable its parent set afterwards."]})]}),(0,Oe.jsx)(Lz,{authType:k,onAuthTypeChange:E,apigee:g,onApigeeChange:b,clientSecret:S,onClientSecretChange:v,hasClientSecret:e.initial.hasClientSecret,certs:C,onCertsChange:K,certPassphrase:q,onCertPassphraseChange:w,hasCertPassphrase:e.initial.hasCertPassphrase,connectionTls:hi,onConnectionTlsChange:L}),(0,Oe.jsx)(Zz,{running:e.testRunning,...e.testResult!==void 0?{result:e.testResult}:{result:void 0},onRun:()=>e.onTestConnection(et())}),(0,Oe.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,Oe.jsx)("button",{type:"button",style:le(!1),onClick:_i,children:"Save"}),(0,Oe.jsx)("button",{type:"button",style:z(),onClick:e.onCancel,children:"Cancel"})]})]})}function qb(e){let[t,n]=(0,Fz.useState)({mode:"closed"}),r=i=>{e.onEditingChange(),n(i)};if(t.mode!=="closed"){let i=t.mode==="edit"?{id:t.profile.id,label:t.profile.label,wireFormat:t.profile.wireFormat,baseUrl:t.profile.baseUrl,model:t.profile.model,authType:t.profile.authType,hasApiKey:t.profile.hasApiKey,...t.profile.authHeaders===void 0?{}:{authHeaders:t.profile.authHeaders},...t.profile.tokenCommand===void 0?{}:{tokenCommand:t.profile.tokenCommand},...t.profile.apiKeyEnvVar===void 0?{}:{apiKeyEnvVar:t.profile.apiKeyEnvVar},hasClientSecret:t.profile.hasClientSecret,hasCertPassphrase:t.profile.hasCertPassphrase,...t.profile.apigee!==void 0?{apigee:t.profile.apigee}:{},...t.profile.certs!==void 0?{certs:t.profile.certs}:{},...t.profile.modelCapabilities!==void 0?{modelCapabilities:t.profile.modelCapabilities}:{},...t.profile.connectionTls!==void 0?{connectionTls:t.profile.connectionTls}:{}}:{label:"",wireFormat:"openai",baseUrl:"",model:"",authType:"apiKey",hasApiKey:!1,hasClientSecret:!1,hasCertPassphrase:!1};return(0,Fe.jsx)(Hb,{onBrowse:e.onBrowse,...e.pickedPath===void 0?{}:{pickedPath:e.pickedPath},initial:i,onSave:o=>{e.onSave(o),n({mode:"closed"})},onCancel:()=>n({mode:"closed"}),onRequestModels:e.onRequestModels,onTestConnection:e.onTestConnection,models:e.models,...e.modelsWarning!==void 0?{modelsWarning:e.modelsWarning}:{},modelsLoading:e.modelsLoading,testRunning:e.testRunning,...e.testResult!==void 0?{testResult:e.testResult}:{}})}return(0,Fe.jsxs)("div",{style:{padding:12,overflowY:"auto"},children:[(0,Fe.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[(0,Fe.jsx)("h3",{style:{margin:0,color:s.foreground},children:"Providers"}),(0,Fe.jsx)(Ui,{scope:"user"})]}),e.profiles.length===0&&(0,Fe.jsx)("p",{style:{color:s.muted,fontFamily:V},children:"No providers configured yet. Add one to start chatting."}),e.profiles.map(i=>{let o=i.id===e.activeProfileId,a=e.sharedProfileIds?.includes(i.id)===!0;return(0,Fe.jsxs)("div",{"data-profile":i.id,style:{padding:10,marginBottom:8,borderRadius:4,border:`1px solid ${s.border}`,background:o?s.assistantBubble:"transparent"},children:[(0,Fe.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[(0,Fe.jsx)("strong",{children:i.label}),o&&(0,Fe.jsx)(Ui,{scope:"user"})]}),(0,Fe.jsxs)("div",{style:{color:s.muted,fontSize:12,marginBottom:8},children:[i.baseUrl," \u2014 ",i.model]}),a&&(0,Fe.jsxs)("div",{style:{color:s.muted,fontSize:10,marginBottom:6},children:[(0,Fe.jsx)("span",{style:{...ot(),fontSize:9,marginRight:5},children:"provided"}),"Set up by an administrator for everyone. Duplicate it to make a copy you can edit with your own key."]}),(0,Fe.jsxs)("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:[!o&&(0,Fe.jsx)("button",{type:"button",title:"Use this profile","aria-label":"Use this profile",style:ze("secondary"),onClick:()=>e.onSetActive(i.id),children:(0,Fe.jsx)(Di,{})}),!a&&(0,Fe.jsx)("button",{type:"button",title:"Edit","aria-label":"Edit",style:ze("secondary"),onClick:()=>r({mode:"edit",profile:i}),children:(0,Fe.jsx)(W_,{})}),(0,Fe.jsx)("button",{type:"button",title:a?"Copy this into a profile of your own":"Duplicate","aria-label":"Duplicate",style:ze("secondary"),onClick:()=>e.onDuplicate(i.id),children:(0,Fe.jsx)(Ur,{})}),!a&&(0,Fe.jsx)("button",{type:"button",title:"Delete","aria-label":"Delete",style:{...ze("secondary"),color:s.error},onClick:()=>e.onDelete(i.id),children:(0,Fe.jsx)(Ht,{})})]})]},i.id)}),(0,Fe.jsx)("button",{type:"button",style:le(!1),onClick:()=>r({mode:"create"}),children:"Add Provider"}),(0,Fe.jsxs)("div",{style:{marginTop:20,paddingTop:12,borderTop:`1px solid ${s.border}`},children:[(0,Fe.jsx)("label",{style:D(),children:"Config file"}),(0,Fe.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,Fe.jsx)("button",{type:"button",style:z(),onClick:e.onExport,children:"Export"}),(0,Fe.jsx)("button",{type:"button",style:z(),onClick:e.onImport,children:"Import"})]})]})]})}var Ne=N(ne(),1),Qd=N(pe(),1);var Xa="#22C55E",Hz=[{id:"green",label:"Green",value:Xa},{id:"purple",label:"Purple",value:"#A855F7"},{id:"indigo",label:"Indigo",value:"#6366F1"},{id:"blue",label:"Blue",value:"#3B82F6"},{id:"teal",label:"Teal",value:"#14B8A6"},{id:"amber",label:"Amber",value:"#F59E0B"},{id:"rose",label:"Rose",value:"#F43F5E"},{id:"graphite",label:"Graphite",value:"#64748B"}],Fr="#D97757",Yb=[{id:"coral",label:"Coral",value:Fr},{id:"orange",label:"Orange",value:"#F97316"},{id:"amber",label:"Amber",value:"#F59E0B"},{id:"rose",label:"Rose",value:"#F43F5E"},{id:"purple",label:"Purple",value:"#A855F7"},{id:"blue",label:"Blue",value:"#3B82F6"},{id:"teal",label:"Teal",value:"#14B8A6"},{id:"graphite",label:"Graphite",value:"#64748B"}];function Wd(e){let t=e.trim().replace(/^#/,""),n=t.length===3?t.replace(/./g,r=>r+r):t;if(/^[0-9a-fA-F]{6}$/.test(n))return{r:Number.parseInt(n.slice(0,2),16),g:Number.parseInt(n.slice(2,4),16),b:Number.parseInt(n.slice(4,6),16)}}function Jd(e){return Wd(e)!==void 0}function Gb({r:e,g:t,b:n}){let r=i=>Math.max(0,Math.min(255,Math.round(i))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function Vz(e,t){return t<=1?{r:e.r*t,g:e.g*t,b:e.b*t}:{r:e.r+(255-e.r)*(t-1),g:e.g+(255-e.g)*(t-1),b:e.b+(255-e.b)*(t-1)}}function JU({r:e,g:t,b:n}){let r=i=>{let o=i/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function Xd(e){let t=Wd(e);return t===void 0?"#ffffff":JU(t)>.35?"#12111a":"#ffffff"}function Wb(e,t,n){let r=Wd(t)??Wd(n);if(r===void 0)return;let i=document.documentElement.style,o=Gb(r);i.setProperty(`--lc-${e}`,o),i.setProperty(`--lc-${e}-deep`,Gb(Vz(r,.62))),i.setProperty(`--lc-${e}-bright`,Gb(Vz(r,1.22))),i.setProperty(`--lc-${e}-contrast`,Xd(o)),i.setProperty(`--lc-${e}-a12`,`rgba(${r.r}, ${r.g}, ${r.b}, 0.12)`),i.setProperty(`--lc-${e}-a20`,`rgba(${r.r}, ${r.g}, ${r.b}, 0.20)`),i.setProperty(`--lc-${e}-a35`,`rgba(${r.r}, ${r.g}, ${r.b}, 0.35)`)}function Jb(e){Wb("accent",e,Xa)}function Xb(e){Wb("expert",e,Fr)}var Kb={expert:Fr,programmer:"#8B7FD4",reviewer:"#3B9EDB",tester:"#D4A72C",librarian:"#59B89C"};function Qb(e,t){Wb(`agent-${e}`,t,Kb[e]??Fr)}function qz(e,t=[]){let n=new Set([...Object.keys(Kb),...t,...Object.keys(e??{})]);for(let r of n)Qb(r,e?.[r]??Kd(r))}function Kd(e){return Kb[e]??XU(e)}function XU(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t^=t>>>16,t=Math.imul(t,2146121005)>>>0,t^=t>>>15,t=Math.imul(t,2221713035)>>>0,t^=t>>>16,KU((t>>>0)%12*30,.52,.58)}function KU(e,t,n){let r=(1-Math.abs(2*n-1))*t,i=r*(1-Math.abs(e/60%2-1)),o=n-r/2,[a,l,c]=e<60?[r,i,0]:e<120?[i,r,0]:e<180?[0,r,i]:e<240?[0,i,r]:e<300?[i,0,r]:[r,0,i],u=d=>Math.round((d+o)*255).toString(16).padStart(2,"0");return`#${u(a)}${u(l)}${u(c)}`}function ex(e){let[t,n]=(0,Qd.useState)(e.value);(0,Qd.useEffect)(()=>n(e.value),[e.value]);let r=o=>{n(o),Jd(o)&&e.onChange(o)},i=e.value.toLowerCase();return(0,Ne.jsxs)("div",{style:{marginBottom:22},children:[(0,Ne.jsx)("span",{style:D(),children:e.label}),(0,Ne.jsx)("p",{style:{color:s.muted,fontSize:11,margin:"0 0 8px"},children:e.description}),(0,Ne.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginBottom:10},children:e.presets.map(o=>{let a=o.value.toLowerCase()===i;return(0,Ne.jsx)("button",{type:"button",className:"lc-swatch",title:o.label,"aria-label":o.label,"aria-pressed":a,onClick:()=>r(o.value),style:{width:26,height:26,borderRadius:"50%",border:"none",cursor:"pointer",padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",background:o.value,color:Xd(o.value)},children:a&&(0,Ne.jsx)(Di,{size:13})},o.id)})}),(0,Ne.jsx)("label",{style:{...D(),marginBottom:4},htmlFor:e.inputId,children:"Or a custom hex colour"}),(0,Ne.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,Ne.jsx)("input",{id:e.inputId,type:"text",value:t,spellCheck:!1,placeholder:e.fallback,onChange:o=>r(o.target.value),style:{...A(),width:130,fontFamily:"var(--vscode-editor-font-family, monospace)"}}),(0,Ne.jsx)("span",{"aria-hidden":"true",style:{width:26,height:26,borderRadius:8,flexShrink:0,background:Jd(t)?t:"transparent",border:`1px solid ${s.border}`}}),!Jd(t)&&(0,Ne.jsxs)("span",{style:{color:s.error,fontSize:11,fontFamily:V},children:["Needs a hex colour, e.g. ",e.fallback]})]})]})}function Gz(e){let t=e.accentColor.toLowerCase()===e.expertColor.toLowerCase();return(0,Ne.jsxs)("section",{children:[e.onChangeTheme!==void 0&&(0,Ne.jsxs)("div",{style:{marginBottom:16},children:[(0,Ne.jsx)("label",{style:D(),children:"Theme"}),(0,Ne.jsx)("div",{style:{display:"flex",gap:6,marginBottom:4},children:["system","light","dark"].map(n=>{let r=(e.theme??"system")===n;return(0,Ne.jsx)("button",{type:"button",onClick:()=>e.onChangeTheme?.(n),style:{...A(),width:"auto",cursor:"pointer",textTransform:"capitalize",...r?{borderColor:s.accent,color:s.accent,fontWeight:600}:{}},children:n},n)})}),(0,Ne.jsxs)("span",{style:{display:"block",color:s.muted,fontSize:11},children:[(0,Ne.jsx)("strong",{children:"System"})," follows your browser\u2019s appearance setting \u2014 which is the browser\u2019s own, not Windows\u2019. If your browser is pinned to light by policy, choose Dark here instead."]})]}),(0,Ne.jsx)(ex,{label:"Accent colour",description:"Buttons, your messages, selections and focus rings.",value:e.accentColor,presets:Hz,fallback:Xa,inputId:"lc-accent-hex",onChange:e.onChangeAccent}),(0,Ne.jsx)(ex,{label:"Expert colour",description:"Marks answers that came from Claude rather than from your own model. Kept separate from the accent so the two are told apart at a glance.",value:e.expertColor,presets:Yb,fallback:Fr,inputId:"lc-expert-hex",onChange:e.onChangeExpert}),e.agentRoles.length>0&&(0,Ne.jsx)("div",{style:{marginTop:4},children:e.agentRoles.filter(n=>n.role!=="expert").map(n=>(0,Ne.jsx)(ex,{label:`${n.name} colour`,description:`Marks answers from the ${n.name.toLowerCase()}.`,value:e.agentColors[n.role]??Kd(n.role),presets:Yb,fallback:Kd(n.role),inputId:`lc-agent-${n.role}-hex`,onChange:r=>e.onChangeAgentColor(n.role,r)},n.role))}),t&&(0,Ne.jsx)("p",{style:{color:s.error,fontSize:11,margin:"0 0 14px"},children:"These are the same colour, so expert answers will not stand out. Only the expert mark will tell them apart."}),(0,Ne.jsxs)("div",{style:{borderTop:`1px solid ${s.border}`,paddingTop:12},children:[(0,Ne.jsx)("span",{style:D(),children:"Preview"}),(0,Ne.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8,marginTop:6},children:[(0,Ne.jsx)("div",{style:{display:"flex",justifyContent:"flex-end"},children:(0,Ne.jsx)("span",{style:{padding:"7px 12px",borderRadius:"14px 14px 4px 14px",background:`linear-gradient(135deg, ${e.accentColor}, ${e.accentColor})`,color:Xd(e.accentColor),fontSize:12,fontFamily:V},children:"Your message"})}),(0,Ne.jsx)("div",{style:{display:"flex"},children:(0,Ne.jsx)("span",{style:{padding:"7px 12px",borderRadius:"14px 14px 14px 4px",background:s.assistantBubble,color:s.foreground,fontSize:12,fontFamily:V},children:"The assistant's reply"})}),(0,Ne.jsxs)("div",{style:{display:"inline-flex",alignItems:"center",gap:6,alignSelf:"flex-start",padding:"6px 10px",borderRadius:10,border:`1px solid ${e.expertColor}`,background:s.expertSoft,color:e.expertColor,fontSize:12,fontFamily:V},children:[(0,Ne.jsx)(wn,{size:12}),"Answered by the expert"]})]})]})]})}function tx(e){if(e===void 0)return;if(e.error!==void 0)return`Failed: ${e.error}`;let t=e.indexed??0;return`Indexed ${String(t)} ${t===1?"entry":"entries"}.`}var QU={expert:"agents"},Yz=[{id:"providers",label:"Providers",Icon:i$},{id:"approvals",label:"Approvals",Icon:ub},{id:"mcp",label:"MCP",Icon:r$},{id:"search",label:"Search",Icon:o$},{id:"agents",label:"Agents",Icon:wn},{id:"schedules",label:"Schedules",Icon:f$},{id:"python",label:"Python",Icon:l$},{id:"tools",label:"Tools",Icon:c$},{id:"outlook",label:"Outlook",Icon:u$},{id:"customData",label:"Custom data",Icon:h$},{id:"skills",label:"Skills",Icon:d$},{id:"network",label:"Network",Icon:a$},{id:"reviews",label:"Review",Icon:ub},{id:"variables",label:"Variables",Icon:t$},{id:"appearance",label:"Appearance",Icon:n$}];function nx(e){let[t,n]=(0,ef.useState)("providers"),r={variables:e.variables!==void 0,reviews:e.reviews!==void 0,outlook:e.offersOffice!==!1},i=Yz.filter(l=>r[l.id]??!0),o=i.some(l=>l.id===t)?t:"providers",a=e.requestedTab;return(0,ef.useEffect)(()=>{if(a===void 0)return;let l=QU[a.tab]??a.tab;Yz.some(c=>c.id===l)&&n(l)},[a]),(0,lt.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,lt.jsx)("div",{role:"tablist",className:"lc-scroll",style:{display:"flex",borderBottom:`1px solid ${s.border}`,flexShrink:0,overflowX:"auto"},children:i.map(l=>{let c=o===l.id;return(0,lt.jsxs)("button",{type:"button",role:"tab","aria-selected":c,className:"lc-tab",title:l.label,"aria-label":l.label,onClick:()=>n(l.id),style:{display:"inline-flex",alignItems:"center",gap:5,padding:c?"8px 10px":"8px 8px",fontFamily:V,fontSize:12,background:"transparent",color:c?s.accent:s.muted,border:"none",cursor:"pointer",whiteSpace:"nowrap",flexShrink:0},children:[(0,lt.jsx)(l.Icon,{size:15}),c&&(0,lt.jsx)("span",{children:l.label})]},l.id)})}),(0,lt.jsx)("div",{className:"lc-scroll lc-panel",style:{flex:1,minHeight:0,overflowY:"auto"},children:o==="reviews"&&e.reviews!==void 0?(0,lt.jsx)(zz,{...e.reviews}):o==="variables"&&e.variables!==void 0?(0,lt.jsx)(Cz,{...e.variables}):o==="appearance"?(0,lt.jsx)("div",{style:{padding:12},children:(0,lt.jsx)(Gz,{accentColor:e.accentColor,onChangeAccent:e.onSetAccentColor,expertColor:e.expertColor,onChangeExpert:e.onSetExpertColor,agentRoles:e.agents.roles.map(l=>({role:l.role,name:l.name})),agentColors:e.agents.colors,onChangeAgentColor:e.onSetAgentColor,...e.theme===void 0?{}:{theme:e.theme},...e.choosesTheme===!0&&e.onSetTheme!==void 0?{onChangeTheme:e.onSetTheme}:{}})}):o==="providers"?(0,lt.jsx)(qb,{onBrowse:e.onBrowse,...e.pickedPath===void 0?{}:{pickedPath:e.pickedPath},...e.sharedProfileIds!==void 0?{sharedProfileIds:e.sharedProfileIds}:{},profiles:e.profiles,activeProfileId:e.activeProfileId,onSave:e.onSave,onDuplicate:e.onDuplicate,onDelete:e.onDelete,onSetActive:e.onSetActive,onExport:e.onExport,onImport:e.onImport,onRequestModels:e.onRequestModels,onTestConnection:e.onTestConnection,onEditingChange:e.onEditingChange,models:e.models,...e.modelsWarning!==void 0?{modelsWarning:e.modelsWarning}:{},modelsLoading:e.modelsLoading,testRunning:e.testRunning,...e.testResult!==void 0?{testResult:e.testResult}:{}}):o==="approvals"?(0,lt.jsx)(jb,{approvals:e.approvals,onSetAutoApprove:e.onSetAutoApprove,onRevokeTool:e.onRevokeTool,onRevokeCommand:e.onRevokeCommand,maxIterations:e.maxIterations,onSetMaxIterations:e.onSetMaxIterations,readRoots:e.readRoots,onSetReadRoots:e.onSetReadRoots}):o==="search"?(0,lt.jsx)(xz,{...e.search}):o==="schedules"?(0,lt.jsx)(Oz,{...e.schedules}):o==="skills"?(0,lt.jsx)(jz,{...e.skills}):o==="tools"?(0,lt.jsx)($z,{...e.tools}):o==="outlook"?(0,lt.jsx)(_z,{...e.outlook,onOpenTools:()=>n("tools")}):o==="customData"?(0,lt.jsx)(tz,{...e.customData,onOpenPython:()=>n("python")}):o==="python"?(0,lt.jsx)(kz,{...e.python}):o==="network"?(0,lt.jsx)(Sz,{...e.network,onBrowse:e.onBrowse,pickedPath:e.pickedPath}):o==="agents"?(0,lt.jsx)(sz,{...e.agents,budgetPanel:(0,lt.jsx)(fz,{expert:e.expert,onSave:e.onSaveExpert,onRecheck:e.onRecheckExpert,onMeasureCost:e.onMeasureCost,onClearPricing:e.onClearPricing,onSetKeepAlive:e.onSetKeepAlive,onBrowse:e.onBrowse,pickedPath:e.pickedPath}),fitPanel:(0,lt.jsx)(hz,{assessments:e.expert?.assessments??[],seatFits:e.expert?.seatFits??[],expertGuidance:e.expert?.expertGuidance??"",assessor:e.expert?.assessor,profiles:e.agents.profiles,assessing:e.expert?.assessing===!0,step:e.expert?.assessmentStep,onAssess:e.onAssessJunior,onClear:e.onClearAssessment})}):(0,lt.jsx)(Ub,{servers:e.mcpServers,json:e.mcpJson,warnings:e.mcpWarnings,saveError:e.mcpSaveError,configs:e.mcpConfigs,platform:e.mcpPlatform,savedTick:e.mcpSavedTick,pythonProbe:e.mcpPythonProbe,onDetectPython:e.onDetectPython,onBrowse:e.onBrowse,pickedPath:e.pickedPath,onSaveServer:e.onSaveMcpServer,onDeleteServer:e.onDeleteMcpServer,onDuplicateServer:e.onDuplicateMcpServer,onSave:e.onSaveMcp,onRestart:e.onRestartMcp,onSetServerEnabled:e.onSetMcpServerEnabled,onSetToolPermission:e.onSetMcpToolPermission,onSetToolTimeout:e.onSetMcpToolTimeout,onConnect:e.onConnectMcp,docsIndex:{enabled:e.search.dispatcher.enabled,ready:e.search.dispatcher.retrievalReady,indexing:e.search.dispatcher.indexing,result:tx(e.search.dispatcher.result)},onIndexDocs:()=>e.search.dispatcher.onIndexDocs("tool"),indexProgress:e.tools.progress,onStopIndexing:e.tools.onStopIndexing})},o)]})}var Wz=N(ne(),1);function ix(e){let t=Vm(e.modeId);return(0,Wz.jsx)($e,{compact:!0,value:t.id,disabled:e.disabled,title:t.description,ariaLabel:"Mode",onChange:e.onChange,options:Fc.map(n=>({value:n.id,label:n.name,...n.requiresExpert===!0&&!e.expertAvailable?{disabled:!0,detail:"needs the expert"}:{}}))})}var _t=N(ne(),1);var Jz=N(pe(),1);function Xz(e){let[t,n]=(0,Jz.useState)(0),r=Or[t]??Or[0],i=t===0,o=t===Or.length-1;return(0,_t.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,fontFamily:V,fontSize:13,color:s.foreground},children:[(0,_t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",borderBottom:`1px solid ${s.border}`,flexShrink:0},children:[(0,_t.jsx)("strong",{style:{fontSize:13},children:r.title}),(0,_t.jsxs)("span",{style:{marginLeft:"auto",color:s.muted,fontSize:11},children:[t+1," of ",Or.length]}),(0,_t.jsx)("button",{type:"button",style:{...z(),fontSize:11},onClick:e.onClose,children:"Close"})]}),(0,_t.jsxs)("div",{className:"lc-scroll",style:{flex:1,minHeight:0,overflowY:"auto",padding:12},children:[e.mediaBase!==void 0&&(0,_t.jsxs)("picture",{children:[(0,_t.jsx)("source",{media:"(prefers-color-scheme: dark)",srcSet:`${e.mediaBase}/${r.id}-dark.svg`}),(0,_t.jsx)("img",{src:`${e.mediaBase}/${r.id}-light.svg`,alt:r.altText,style:{display:"block",width:"100%",maxWidth:"100%",height:"auto",borderRadius:6,border:`1px solid ${s.border}`,marginBottom:12}})]}),r.body.map((a,l)=>(0,_t.jsx)("div",{style:{marginBottom:10,lineHeight:1.5},children:(0,_t.jsx)(Ld,{text:a})},l)),r.tab!==void 0&&(0,_t.jsxs)("button",{type:"button",style:{...le(!1),marginTop:4},onClick:()=>e.onOpenTab(r.tab),children:["Open the ",r.tab[0]?.toUpperCase(),r.tab.slice(1)," tab"]}),r.tab===void 0&&r.opensPanel===!0&&(0,_t.jsx)("button",{type:"button",style:{...z(),marginTop:4},onClick:e.onClose,children:"Back to the chat"})]}),(0,_t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px",borderTop:`1px solid ${s.border}`,flexShrink:0},children:[(0,_t.jsx)("button",{type:"button",style:z(),disabled:i,onClick:()=>n(a=>Math.max(0,a-1)),children:"Back"}),(0,_t.jsx)("div",{style:{display:"flex",gap:4,flex:1,justifyContent:"center",flexWrap:"wrap"},children:Or.map((a,l)=>(0,_t.jsx)("button",{type:"button","aria-label":a.title,title:a.title,onClick:()=>n(l),style:{width:7,height:7,padding:0,borderRadius:"50%",border:"none",cursor:"pointer",background:l===t?s.accent:s.border}},a.id))}),o?(0,_t.jsx)("button",{type:"button",style:le(!1),onClick:e.onClose,children:"Done"}):(0,_t.jsx)("button",{type:"button",style:le(!1),onClick:()=>n(a=>Math.min(Or.length-1,a+1)),children:"Next"})]})]})}var Yt=N(ne(),1),Kz=N(pe(),1);function eN(e,t=Date.now()){let n=Math.max(0,Math.round((t-e)/1e3));if(n<60)return"just now";let r=Math.round(n/60);if(r<60)return`${r}m ago`;let i=Math.round(r/60);if(i<24)return`${i}h ago`;let o=Math.round(i/24);return o<=7?`${o}d ago`:new Date(e).toLocaleDateString()}function Qz(e){let[t,n]=(0,Kz.useState)(void 0);return(0,Yt.jsxs)("div",{style:{padding:12,overflowY:"auto"},children:[(0,Yt.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[(0,Yt.jsx)("h3",{style:{margin:0,color:s.foreground},children:"History"}),(0,Yt.jsx)("button",{type:"button",style:{...le(!1),marginLeft:"auto"},onClick:e.onNew,children:"New task"})]}),e.tasks.length===0&&(0,Yt.jsx)("p",{style:{color:s.muted,fontFamily:V},children:"No past tasks in this workspace yet. Conversations are saved automatically as you go."}),e.tasks.map(r=>{let i=r.id===e.activeTaskId,o=r.id===t;return(0,Yt.jsxs)("div",{style:{padding:10,marginBottom:8,borderRadius:4,border:`1px solid ${i?s.accent:s.border}`,background:i?s.assistantBubble:"transparent"},children:[(0,Yt.jsx)("div",{style:{color:s.foreground,marginBottom:4,wordBreak:"break-word"},children:r.title}),(0,Yt.jsxs)("div",{style:{color:s.muted,fontSize:11,marginBottom:8},children:[eN(r.updatedAt)," \xB7 ",r.messageCount," message",r.messageCount===1?"":"s",i?" \xB7 current":""]}),o?(0,Yt.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center",flexWrap:"wrap"},children:[(0,Yt.jsx)("span",{style:{color:s.muted,fontSize:11},children:"Delete this task and its saved output?"}),(0,Yt.jsx)("button",{type:"button",style:{...z(),color:s.error},onClick:()=>{n(void 0),e.onDelete(r.id)},children:"Delete"}),(0,Yt.jsx)("button",{type:"button",style:z(),onClick:()=>n(void 0),children:"Cancel"})]}):(0,Yt.jsxs)("div",{style:{display:"flex",gap:6},children:[!i&&(0,Yt.jsx)("button",{type:"button",style:z(),onClick:()=>e.onOpen(r.id),children:"Open"}),(0,Yt.jsx)("button",{type:"button",style:z(),onClick:()=>n(r.id),children:"Delete"})]})]},r.id)})]})}function Ka(e){let t=e.map(r=>r.kind==="reasoning"&&r.pending===!0?{kind:"reasoning",content:r.content}:r),n=t[t.length-1];return n===void 0||n.kind!=="text"||!n.pending?t:[...t.slice(0,-1),{kind:"text",role:n.role,content:n.content,...n.expertInformed===!0?{expertInformed:!0}:{},...n.informedBy!==void 0?{informedBy:n.informedBy}:{}}]}function rx(e){let[t,n]=(0,F.useState)("chat"),[r,i]=(0,F.useState)(),[o,a]=(0,F.useState)({native:!0}),[l,c]=(0,F.useState)(),[u,d]=(0,F.useState)(),[h,m]=(0,F.useState)(),[f,y]=(0,F.useState)(!1),[k,E]=(0,F.useState)(),[g,b]=(0,F.useState)([]),[S,v]=(0,F.useState)(!1),[C,K]=(0,F.useState)(void 0),[q,w]=(0,F.useState)([]),[R,ce]=(0,F.useState)(void 0),[Me,ct]=(0,F.useState)(!1),[en,cn]=(0,F.useState)(void 0),[hi,L]=(0,F.useState)(void 0),[de,He]=(0,F.useState)(!1),[Ft,U]=(0,F.useState)(Fm),[fe,yt]=(0,F.useState)({}),[et,At]=(0,F.useState)(25),[_i,rt]=(0,F.useState)(Xa),[qi,pi]=(0,F.useState)([]),[A6,BS]=(0,F.useState)(Fr),[Dm,LS]=(0,F.useState)({type:"agents",roles:[],profiles:[],cliAvailable:!1,budgetMatters:!1,claudeSeated:!1,teamGuidance:"",defaultTeamGuidance:"",teamGuidanceIsDefault:!0,colors:{}}),[Yn,j6]=(0,F.useState)({usd:0,consultations:0,unpriced:0,maxSpendUsd:0,maxConsultations:0,overridden:!1}),[vo,Am]=(0,F.useState)({enabled:!0,hiddenTools:0,skills:!0,hiddenSkills:0}),[jm,Bc]=(0,F.useState)(!1),[O6,U6]=(0,F.useState)([]),[Fl,PS]=(0,F.useState)({}),[Vl,ta]=(0,F.useState)({}),$i=x=>PS(P=>{let p={...P};return delete p[x],p}),[bo,na]=(0,F.useState)(void 0),[N6,R6]=(0,F.useState)([]),[M6,B6]=(0,F.useState)(`{
|
|
145
145
|
"mcpServers": {}
|
|
146
146
|
}`),[L6,P6]=(0,F.useState)({}),[Z6,ZS]=(0,F.useState)(void 0),[F6,V6]=(0,F.useState)({}),[H6,q6]=(0,F.useState)("posix"),[G6,Y6]=(0,F.useState)(0),[FS,VS]=(0,F.useState)(void 0),[W6,J6]=(0,F.useState)(void 0),[X6,HS]=(0,F.useState)([]),[qS,Om]=(0,F.useState)(void 0),[K6,Um]=(0,F.useState)(!1),[Q6,Nm]=(0,F.useState)(!1),[GS,Rm]=(0,F.useState)(void 0),[eE,tE]=(0,F.useState)([]),[YS,WS]=(0,F.useState)(void 0),[nE,iE]=(0,F.useState)(void 0),[rE,oE]=(0,F.useState)(!1),[Mm,aE]=(0,F.useState)(!1),[lE,JS]=(0,F.useState)(void 0),[XS,sE]=(0,F.useState)(void 0),[KS,cE]=(0,F.useState)([]),[uE,dE]=(0,F.useState)([]),[Bm,fE]=(0,F.useState)([]),[Hl,mE]=(0,F.useState)(void 0),[hE,pE]=(0,F.useState)([]),[QS,gE]=(0,F.useState)(void 0),[e0,t0]=(0,F.useState)(void 0),[yE,vE]=(0,F.useState)(0),[n0,i0]=(0,F.useState)(void 0),[Lc,bE]=(0,F.useState)(void 0),[xE,r0]=(0,F.useState)(void 0),[SE,o0]=(0,F.useState)(void 0),[kE,a0]=(0,F.useState)(void 0),[wE,_E]=(0,F.useState)(void 0),[ia,$E]=(0,F.useState)({datasets:[],tools:[],stores:[],defaultStoreLabel:"none",semantic:!1,guidance:""}),[l0,s0]=(0,F.useState)({folders:[],loading:!1}),[Wn,zE]=(0,F.useState)(void 0),[TE,Lm]=(0,F.useState)(void 0),[CE,c0]=(0,F.useState)([]),[EE,u0]=(0,F.useState)(void 0),[IE,d0]=(0,F.useState)(!1),[DE,AE]=(0,F.useState)(0),[jE,OE]=(0,F.useState)(void 0),[UE,NE]=(0,F.useState)(void 0),[RE,ME]=(0,F.useState)([]),[BE,LE]=(0,F.useState)([]),[PE,ZE]=(0,F.useState)(void 0),[FE,VE]=(0,F.useState)([]),[HE,qE]=(0,F.useState)([]),[GE,YE]=(0,F.useState)([]),[Pm,f0]=(0,F.useState)({choosesTheme:!1}),[WE,m0]=(0,F.useState)(""),[JE,XE]=(0,F.useState)([]),[KE,QE]=(0,F.useState)(!0),[h0,eI]=(0,F.useState)(void 0),[tI,nI]=(0,F.useState)({workspaceOpen:!1,overridden:[]}),[iI,p0]=(0,F.useState)({tools:[],dispatcher:!1,office:{supported:!1,excel:!1,outlook:!1}}),[rI,oI]=(0,F.useState)(void 0),[aI,lI]=(0,F.useState)(void 0),[sI,cI]=(0,F.useState)([]),[uI,dI]=(0,F.useState)("");(0,F.useEffect)(()=>{let x=e.transport.onMessage(P=>{let p=P;if(p.type==="textChunk")b(ye=>{let vt=ye[ye.length-1],Jn={kind:"text",role:"assistant",content:p.text,pending:!0,...p.expertInformed===!0?{expertInformed:!0}:{},...p.informedBy!==void 0?{informedBy:p.informedBy}:{}};return vt?.kind==="text"&&vt.role==="assistant"&&vt.pending?[...ye.slice(0,-1),Jn]:[...ye,Jn]});else if(p.type==="reasoningChunk")b(ye=>{let vt=ye.findIndex(ql=>ql.kind==="reasoning"&&ql.pending===!0),Jn={kind:"reasoning",content:p.text,pending:!0};return vt===-1?[...ye,Jn]:[...ye.slice(0,vt),Jn,...ye.slice(vt+1)]});else if(p.type==="toolCall")b(ye=>[...Ka(ye),{kind:"tool",toolCall:p.toolCall,...p.expertInformed===!0?{expertInformed:!0}:{},...p.informedBy!==void 0?{informedBy:p.informedBy}:{}}]);else if(p.type==="toolResult")b(ye=>{let vt={kind:"tool",toolCall:p.toolCall,...p.expertInformed===!0?{expertInformed:!0}:{},...p.informedBy!==void 0?{informedBy:p.informedBy}:{}},Jn=ye.findIndex(ql=>ql.kind==="tool"&&ql.toolCall.id===p.toolCall.id);return Jn===-1?[...ye,vt]:[...ye.slice(0,Jn),vt,...ye.slice(Jn+1)]});else if(p.type==="formRequest")b(Ka),L(p);else if(p.type==="approvalRequest")b(Ka),cn({id:p.id,toolName:p.toolName,group:p.group,preview:p.preview,...p.alwaysScope===void 0?{}:{alwaysScope:p.alwaysScope}});else if(p.type==="openSettings")e.transport.post({type:"requestProfiles"}),i({tab:p.tab,nonce:Date.now()}),n("settings");else if(p.type==="hostRole")E({role:p.role,shared:p.shared,displayName:p.displayName,sharedProfileIds:p.sharedProfileIds});else if(p.type==="reviews")d({items:p.items,canDecide:p.canDecide});else if(p.type==="variables")c({user:p.user,admin:p.admin,resolved:p.resolved,adminIds:p.adminIds,canEditAdmin:p.canEditAdmin});else if(p.type==="settings")U(p.modeId),m(p.programmingProfileId),y(p.allowProgrammingProfile),QE(p.offersOffice!==!1),f0({choosesTheme:p.choosesTheme===!0,...p.theme===void 0?{}:{theme:p.theme}}),eI(p.toolTimeoutSeconds),a({native:p.nativeGuide,...p.guideMediaBase!==void 0?{mediaBase:p.guideMediaBase}:{}}),yt(p.approvals),At(p.maxIterations),rt(p.accentColor),pi(p.readRoots),BS(p.expertColor),Jb(p.accentColor),Xb(p.expertColor);else if(p.type==="mcp")R6(p.servers),B6(p.json),P6(p.warnings),V6(p.configs),q6(p.platform),ZS(void 0);else if(p.type==="mcpSaveError")ZS(p.message);else if(p.type==="checkpointAvailable")He(!0);else if(p.type==="rolledBack")He(!1);else if(p.type==="done")b(Ka),cn(void 0),v(!1);else if(p.type==="error")b(Ka),cn(void 0),K(p.message),v(!1);else if(p.type==="profiles")w(p.profiles),ce(p.activeProfileId),ct(!0);else if(p.type==="profileSaved")n("chat");else if(p.type==="models")HS(p.models),Om(p.warning),Um(!1);else if(p.type==="testConnectionResult")Rm({ok:p.ok,steps:p.steps}),Nm(!1);else if(p.type==="contextUsage")iE(p.usage);else if(p.type==="compacted")b(ye=>[...ye,{kind:"text",role:"assistant",content:`[${p.summarisedCount} earlier messages were summarised to stay within the context window. The full transcript is still saved.]`}]);else if(p.type==="search")fE(p.connections),mE(p.activeConnectionId);else if(p.type==="searchIndexes")pE(p.indexes),gE(p.warning);else if(p.type==="searchTestResult")t0({ok:p.ok,detail:p.detail});else if(p.type==="queued")dE(p.messages);else if(p.type==="queuedMessageConsumed")b(ye=>[...Ka(ye),{kind:"text",role:"user",content:p.text}]);else if(p.type==="mentionCandidates")cE(p.paths);else if(p.type==="capabilities")oE(p.supportsVision);else if(p.type==="pathPicked")VS({purpose:p.purpose,path:p.path});else if(p.type==="pythonEnvProbe")J6({...p.interpreter!==void 0?{interpreter:p.interpreter}:{},...p.venvDir!==void 0?{venvDir:p.venvDir}:{},detail:p.detail});else if(p.type==="tools")p0(p);else if(p.type==="schedules")YE(p.skills),VE(p.schedules),qE(p.tools),lI(p.runningId),oI(p.scheduler);else if(p.type==="searchLog")U6(p.entries);else if(p.type==="chart")b(ye=>[...ye.filter(vt=>!(vt.kind==="text"&&vt.role==="assistant"&&vt.pending===!0&&vt.content.length===0)),{kind:"chart",chart:p.chart,...p.expertInformed===!0?{expertInformed:!0}:{},...p.informedBy!==void 0?{informedBy:p.informedBy}:{}}]);else if(p.type==="chartError")b(ye=>[...ye,{kind:"chartError",message:p.message}]);else if(p.type==="searchProbe")PS(ye=>({...ye,[p.target]:{query:p.query,text:p.text,...p.error!==void 0?{error:p.error}:{}}})),ta(ye=>({...ye,[p.target]:!1}));else if(p.type==="dispatcher")Am({enabled:p.enabled,hiddenTools:p.hiddenTools,skills:p.skills,hiddenSkills:p.hiddenSkills,...p.docsIndex!==void 0?{docsIndex:p.docsIndex}:{}});else if(p.type==="projectSettings")nI(p);else if(p.type==="docsIndexed")Bc(!1),na({...p.indexed!==void 0?{indexed:p.indexed}:{},...p.index!==void 0?{index:p.index}:{},...p.error!==void 0?{error:p.error}:{}});else if(p.type==="expertSpend")j6({usd:p.usd,consultations:p.consultations,unpriced:p.unpriced,...p.usage!==void 0?{usage:p.usage}:{},...p.exhausted!==void 0?{exhausted:p.exhausted}:{},maxSpendUsd:p.maxSpendUsd,maxConsultations:p.maxConsultations,overridden:p.overridden,...p.estimate!==void 0?{estimate:p.estimate}:{}});else if(p.type==="mcpServerSaved")Y6(ye=>ye+1);else if(p.type==="embedder"){let{type:ye,...vt}=p;bE(vt)}else p.type==="skills"?(ME(p.skills),LE(p.issues),ZE(p.skillsDir),cI(p.extraDirs)):p.type==="python"?(OE(p.status),NE(p.settings)):p.type==="embedderModels"?(c0(p.models),u0(p.warning),d0(!1)):p.type==="embedderSaved"?AE(ye=>ye+1):p.type==="indexProgress"?r0(p.progress):p.type==="outlookFolders"?s0({folders:p.folders??[],loading:!1,...p.error!==void 0?{error:p.error}:{}}):p.type==="indexingProgress"?zE({kind:p.kind,phase:p.phase,running:p.running,...p.done!==void 0?{done:p.done}:{},...p.total!==void 0?{total:p.total}:{},...p.detail!==void 0?{detail:p.detail}:{}}):p.type==="datasetStatus"?$E({datasets:p.datasets,tools:p.tools,stores:p.stores,defaultStoreLabel:p.defaultStoreLabel,semantic:p.semantic,guidance:p.guidance}):p.type==="mailStatus"?_E({enabled:p.enabled,available:p.available,folders:p.folders,syncMinutes:p.syncMinutes,retentionMonths:p.retentionMonths,indexed:p.indexed,...p.oldest!==void 0?{oldest:p.oldest}:{},...p.newest!==void 0?{newest:p.newest}:{},sizeBytes:p.sizeBytes,semantic:p.semantic,...p.storeId!==void 0?{storeId:p.storeId}:{},stores:p.stores,...p.busy!==void 0?{busy:p.busy}:{},...p.lastResult!==void 0?{lastResult:p.lastResult}:{}}):p.type==="teamSkillsPublished"?Lm({...p.count!==void 0?{count:p.count}:{},...p.collection!==void 0?{collection:p.collection}:{},...p.error!==void 0?{error:p.error}:{}}):p.type==="teamAliasAttached"?a0({...p.alias!==void 0?{alias:p.alias}:{},...p.index!==void 0?{index:p.index}:{},...p.attributed!==void 0?{attributed:p.attributed}:{},...p.error!==void 0?{error:p.error}:{}}):p.type==="indexResult"?(r0(void 0),o0({...p.result!==void 0?{result:p.result}:{},...p.error!==void 0?{error:p.error}:{}})):p.type==="storeSync"?i0({running:p.running,...p.copied!==void 0?{copied:p.copied}:{},...p.error!==void 0?{error:p.error}:{},...p.fromLabel!==void 0?{fromLabel:p.fromLabel}:{}}):p.type==="searchConnectionSaved"?vE(ye=>ye+1):p.type==="network"?sE(p.settings):p.type==="plan"?m0(p.plan):p.type==="planProgress"?XE(p.checkpoints):p.type==="agents"?(LS(p),qz(p.colors,p.roles.map(ye=>ye.role))):p.type==="expert"?(JS(p),aE(p.enabled&&p.available)):p.type==="tasks"?(tE(p.tasks),WS(p.activeTaskId)):p.type==="taskRestored"&&(b(p.entries),WS(p.taskId),K(void 0),cn(void 0),v(!1),He(!1))});return e.transport.post({type:"requestProfiles"}),e.transport.post({type:"requestSettings"}),e.transport.post({type:"requestMcp"}),e.transport.post({type:"requestExpert"}),e.transport.post({type:"requestAgents"}),e.transport.post({type:"requestPlan"}),e.transport.post({type:"requestSearch"}),e.transport.post({type:"requestMailStatus"}),e.transport.post({type:"requestDatasetStatus"}),e.transport.post({type:"requestProjectSettings"}),e.transport.post({type:"requestNetwork"}),e.transport.post({type:"requestPython"}),e.transport.post({type:"requestSkills"}),e.transport.post({type:"requestSchedules"}),e.transport.post({type:"requestTools"}),e.transport.post({type:"requestVariables"}),e.transport.post({type:"requestReviews"}),x},[e.transport]);let g0=()=>{let x={type:"requestProfiles"};e.transport.post(x),n("settings")},fI=(x,P)=>{if(S){e.transport.post({type:"queueMessage",text:x});return}K(void 0);let p=P.length>0?`${x}${x.length>0?`
|
|
147
147
|
`:""}[${P.length} image(s) attached]`:x;b(vt=>[...vt,{kind:"text",role:"user",content:p}]),v(!0);let ye=P.length>0?{type:"sendMessage",text:x,images:P}:{type:"sendMessage",text:x};e.transport.post(ye)},mI=x=>{e.transport.post({type:"unqueueMessage",index:x})},y0=x=>{e.transport.post({type:"requestMentionCandidates",query:x})},hI=()=>{let x={type:"cancel"};e.transport.post(x)},pI=(x,P)=>{cn(void 0),e.transport.post({type:"approvalResponse",id:x,decision:P})},gI=(x,P)=>{cn(void 0),e.transport.post({type:"approvalResponseAlways",id:x,scope:P})},yI=x=>{U(x),e.transport.post({type:"setMode",modeId:x})},vI=(x,P)=>{e.transport.post({type:"setAutoApprove",group:x,enabled:P})},bI=x=>{e.transport.post({type:"revokeAllowedTool",toolName:x})},xI=x=>{e.transport.post({type:"revokeAllowedCommand",command:x})},SI=()=>{e.transport.post({type:"requestTasks"}),n("history")},kI=x=>{e.transport.post({type:"openTask",id:x}),n("chat")},v0=()=>{e.transport.post({type:"newTask"}),n("chat")},wI=x=>{e.transport.post({type:"deleteTask",id:x})},_I=x=>{Um(!0),Om(void 0),e.transport.post({type:"requestModels",profile:x})},$I=x=>{Nm(!0),Rm(void 0),e.transport.post({type:"testConnection",profile:x})},zI=()=>{HS([]),Om(void 0),Um(!1),Rm(void 0),Nm(!1)},TI={connections:Bm,activeConnectionId:Hl,indexes:hE,...QS!==void 0?{indexesWarning:QS}:{},...e0!==void 0?{testResult:e0}:{},savedTick:yE,onSave:x=>{K(void 0),e.transport.post({type:"saveSearchConnection",connection:x})},onDelete:x=>e.transport.post({type:"deleteSearchConnection",id:x}),onSyncFrom:x=>{i0({running:!0}),e.transport.post({type:"syncVectorStore",fromId:x})},...n0!==void 0?{sync:n0}:{},onSetActive:(x,P)=>e.transport.post({type:"setActiveSearchConnection",id:x,...P===!0?{forProject:!0}:{}}),project:tI,onClearProject:()=>e.transport.post({type:"clearProjectSettings"}),onListIndexes:x=>e.transport.post({type:"requestSearchIndexes",connection:x}),onTest:x=>{t0(void 0),e.transport.post({type:"testSearchConnection",connection:x})},indexing:{embedder:Lc,profiles:q,connectionLabel:Bm.find(x=>x.id===Hl)?.label,progress:xE,lastResult:SE,models:CE,modelsWarning:EE,modelsLoading:IE,savedTick:DE,onRequestModels:x=>{c0([]),u0(void 0),d0(!0),e.transport.post({type:"requestEmbedderModels",profileId:x})},onSaveEmbedder:(x,P,p,ye,vt,Jn)=>{K(void 0),e.transport.post({type:"saveEmbedder",profileId:x,model:P,dimensions:p,...ye.length>0?{indexName:ye}:{},...vt.length>0?{indexPrefix:vt}:{},...Jn.length>0?{indexAlias:Jn}:{}})},onAttachTeamAlias:()=>{a0(void 0),e.transport.post({type:"attachTeamAlias"})},aliasResult:kE,onStartIndexing:()=>{o0(void 0),e.transport.post({type:"startIndexing"})},onClearIndex:()=>e.transport.post({type:"clearCodebaseIndex"}),onCancelIndexing:()=>e.transport.post({type:"cancelIndexing"})},dispatcher:{enabled:vo.enabled,hiddenTools:vo.hiddenTools,skills:vo.skills,hiddenSkills:vo.hiddenSkills,...vo.docsIndex!==void 0?{docsIndex:vo.docsIndex}:{},indexing:jm,...bo!==void 0?{result:bo}:{},retrievalReady:Hl!==void 0&&Lc?.model!==void 0,onToggle:x=>{Am(P=>({...P,enabled:x})),e.transport.post({type:"setDispatcher",enabled:x})},onToggleSkills:x=>{Am(P=>({...P,skills:x})),e.transport.post({type:"setSkillRetrieval",enabled:x})},onIndexDocs:x=>{na(void 0),Bc(!0),e.transport.post({type:"indexDocs",...x===void 0?{}:{kind:x}})},onClearDocsIndex:()=>{na(void 0),Bc(!0),e.transport.post({type:"clearDocsIndex"})}},activity:{entries:O6,probe:Fl.docs,probeRunning:Vl.docs===!0,onProbe:(x,P)=>{$i(P),ta(p=>({...p,[P]:!0})),e.transport.post({type:"runSearchProbe",query:x,target:P})},onClear:()=>e.transport.post({type:"clearSearchLog"}),onClearProbe:()=>$i("docs")}},CI=(x,P,p,ye)=>{e.transport.post({type:"setExpert",enabled:x,...P.length>0?{path:P}:{},...p.length>0?{model:p}:{},maxSpendUsd:ye.maxSpendUsd,maxConsultations:ye.maxConsultations})},EI=(x,P,p)=>{K(void 0),e.transport.post({type:"saveMcpServer",name:x,...P!==void 0?{previousName:P}:{},config:p})},b0=x=>{e.transport.post({type:"openManagedFile",path:x})},x0=x=>{VS(void 0),e.transport.post({type:"browseForPath",...x})},II=(x,P)=>{e.transport.post({type:"probePythonEnv",venvDir:x,script:P})},DI=x=>{e.transport.post({type:"deleteMcpServer",name:x})},AI=x=>{e.transport.post({type:"saveMcpServers",json:x})},jI=x=>{e.transport.post({type:"restartMcpServer",name:x})},OI=(x,P)=>{e.transport.post({type:"setMcpServerEnabled",name:x,enabled:P})},UI=x=>{e.transport.post({type:"connectMcpServer",name:x})},NI=(x,P,p)=>{e.transport.post({type:"setMcpToolPermission",server:x,tool:P,permission:p})},RI=()=>{e.transport.post({type:"rollback"})},MI=x=>{e.transport.post({type:"saveProfile",profile:x})},BI=x=>{e.transport.post({type:"duplicateProfile",id:x})},LI=x=>{e.transport.post({type:"deleteProfile",id:x})},S0=x=>{e.transport.post({type:"setActiveProfile",id:x})},PI=()=>{e.transport.post({type:"exportConfig"})},ZI=()=>{e.transport.post({type:"importConfig"})},FI=Me&&q.length===0;return(0,Ve.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100vh",boxSizing:"border-box",background:s.background,color:s.foreground,fontFamily:V,fontSize:13},children:[(0,Ve.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderBottom:`1px solid ${s.border}`,flexShrink:0},children:[(0,Ve.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,Ve.jsx)("strong",{children:"Light Code"}),t==="chat"&&(0,Ve.jsx)(ix,{modeId:Ft,disabled:S,onChange:yI,expertAvailable:Mm}),t==="chat"&&Dm.budgetMatters&&(0,Ve.jsx)(X$,{enabled:Mm,modeId:Ft,usd:Yn.usd,consultations:Yn.consultations,maxSpendUsd:Yn.maxSpendUsd,maxConsultations:Yn.maxConsultations,overridden:Yn.overridden,...Yn.estimate!==void 0?{estimate:Yn.estimate}:{},...Yn.usage!==void 0?{usage:Yn.usage}:{},...Yn.exhausted!==void 0?{exhausted:Yn.exhausted}:{},onSetLimits:x=>e.transport.post({type:"setTaskExpertLimits",...x})})]}),t==="chat"?(0,Ve.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:2},children:[(0,Ve.jsx)("button",{type:"button","aria-label":"New task",title:"New task",style:ze("ghost",S),disabled:S,onClick:v0,children:(0,Ve.jsx)(K_,{})}),(0,Ve.jsx)("button",{type:"button","aria-label":"History",title:"History",style:ze("ghost"),onClick:SI,children:(0,Ve.jsx)(X_,{})}),(0,Ve.jsx)("button",{type:"button","aria-label":"Settings",title:"Settings",style:ze("ghost"),onClick:g0,children:(0,Ve.jsx)(Q_,{})}),(0,Ve.jsx)("button",{type:"button","aria-label":"Guide",title:"Open the guide",style:ze("ghost"),onClick:()=>{if(o.native){e.transport.post({type:"openWalkthrough"});return}n("guide")},children:(0,Ve.jsx)(s$,{})})]}):(0,Ve.jsx)("button",{type:"button","aria-label":"Back",title:"Back",style:ze("ghost"),onClick:()=>n("chat"),children:(0,Ve.jsx)(q_,{})})]}),C!==void 0&&t!=="chat"&&(0,Ve.jsxs)("div",{role:"alert",style:{margin:"8px 12px 0",padding:"8px 10px",fontSize:12,borderRadius:4,display:"flex",alignItems:"flex-start",gap:8,color:"var(--vscode-inputValidation-errorForeground, var(--vscode-foreground))",background:"var(--vscode-inputValidation-errorBackground, transparent)",border:"1px solid var(--vscode-inputValidation-errorBorder, var(--vscode-errorForeground))"},children:[(0,Ve.jsx)("span",{style:{flex:1},children:C}),(0,Ve.jsx)("button",{type:"button","aria-label":"Dismiss",onClick:()=>K(void 0),style:{background:"transparent",border:"none",color:"inherit",cursor:"pointer",padding:0},children:"\u2715"})]}),(0,Ve.jsx)("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:t==="guide"?(0,Ve.jsx)(Xz,{...o.mediaBase!==void 0?{mediaBase:o.mediaBase}:{},onClose:()=>n("chat"),onOpenTab:x=>{e.transport.post({type:"requestProfiles"}),i({tab:x,nonce:Date.now()}),n("settings")}}):t==="settings"?(0,Ve.jsx)(nx,{...r!==void 0?{requestedTab:r}:{},profiles:q,activeProfileId:R,onSave:MI,onDuplicate:BI,onDelete:LI,onSetActive:S0,onExport:PI,onImport:ZI,...k!==void 0?{sharedProfileIds:k.sharedProfileIds}:{},onRequestModels:_I,onTestConnection:$I,onEditingChange:zI,models:X6,...qS!==void 0?{modelsWarning:qS}:{},modelsLoading:K6,testRunning:Q6,...GS!==void 0?{testResult:GS}:{},approvals:fe,onSetAutoApprove:vI,onRevokeTool:bI,onRevokeCommand:xI,maxIterations:et,readRoots:qi,onSetReadRoots:x=>e.transport.post({type:"setReadRoots",roots:x}),accentColor:_i,onSetAccentColor:x=>{rt(x),Jb(x),e.transport.post({type:"setAccentColor",value:x})},agents:{...Dm,onAssign:(x,P)=>e.transport.post({type:"setAgentRole",role:x,...P!==void 0?{assignment:P}:{}}),onSetPrompt:(x,P)=>e.transport.post({type:"setAgentPrompt",role:x,...P!==void 0?{prompt:P}:{}}),onSetBudget:x=>e.transport.post({type:"setAgentBudget",matters:x}),onSetTeamGuidance:x=>e.transport.post({type:"setTeamGuidance",...x!==void 0?{guidance:x}:{}}),onSaveCustomRole:x=>e.transport.post({type:"saveCustomRole",...x}),onDeleteCustomRole:x=>e.transport.post({type:"deleteCustomRole",id:x}),onSetRoleTools:(x,P)=>e.transport.post({type:"setRoleTools",role:x,usesTools:P}),onSetRoleWrite:(x,P)=>e.transport.post({type:"setRoleWrite",role:x,canWrite:P}),onSetRoleEnabled:(x,P)=>e.transport.post({type:"setRoleEnabled",role:x,enabled:P}),onSetRoleThinking:(x,P)=>e.transport.post({type:"setRoleThinking",role:x,...P!==void 0?{level:P}:{}}),customRoleLimit:5},onSetAgentColor:(x,P)=>{LS(p=>({...p,colors:{...p.colors,[x]:P}})),Qb(x,P),e.transport.post({type:"setAgentColor",role:x,color:P})},expertColor:A6,onSetExpertColor:x=>{BS(x),Xb(x),e.transport.post({type:"setExpertColor",value:x})},offersOffice:KE,...Pm.choosesTheme?{choosesTheme:!0}:{},...Pm.theme===void 0?{}:{theme:Pm.theme},onSetTheme:x=>{f0(P=>({...P,theme:x})),e.transport.post({type:"setTheme",theme:x})},onSetMaxIterations:x=>e.transport.post({type:"setMaxIterations",value:x}),mcpServers:N6,mcpJson:M6,mcpWarnings:L6,mcpSaveError:Z6,mcpConfigs:F6,mcpPlatform:H6,mcpSavedTick:G6,mcpPythonProbe:W6,onDetectPython:II,onBrowse:x0,pickedPath:FS,onSaveMcpServer:EI,onDeleteMcpServer:DI,onDuplicateMcpServer:x=>e.transport.post({type:"duplicateMcpServer",name:x}),onSaveMcp:AI,onRestartMcp:jI,onSetMcpServerEnabled:OI,onSetMcpToolPermission:NI,onSetMcpToolTimeout:(x,P,p)=>e.transport.post({type:"setMcpToolTimeout",server:x,tool:P,...p===void 0?{}:{seconds:p}}),onConnectMcp:UI,expert:lE,onSaveExpert:CI,onAssessJunior:x=>e.transport.post({type:"assessJunior",...x!==void 0?{profileId:x}:{}}),onMeasureCost:()=>e.transport.post({type:"measureExpertCost"}),onClearPricing:()=>e.transport.post({type:"clearExpertPricing"}),onSetKeepAlive:x=>e.transport.post({type:"setExpertKeepAlive",enabled:x}),onClearAssessment:(x,P)=>e.transport.post({type:"clearAssessment",...x!==void 0&&P!==void 0?{model:x,profileLabel:P}:{}}),onRecheckExpert:()=>{JS(void 0),e.transport.post({type:"requestExpert"})},search:TI,skills:{team:{alias:Lc?.skillsAlias,onSaveAlias:x=>e.transport.post({type:"saveSkillsAlias",alias:x}),onPublish:()=>{Lm(void 0),e.transport.post({type:"publishTeamSkills"})},onClear:()=>{Lm(void 0),e.transport.post({type:"clearTeamSkills"})},onStop:()=>e.transport.post({type:"cancelIndexing",kind:"teamSkills"}),publishing:Wn?.kind==="teamSkills"&&Wn.running,progress:Wn?.kind==="teamSkills"?Wn:void 0,result:TE},skills:RE,issues:BE,skillsDir:PE,extraDirs:sI,configuredDir:uI,onOpenFile:b0,onOpenStandingSkill:()=>e.transport.post({type:"openStandingSkill"}),onReindex:()=>{na(void 0),Bc(!0),e.transport.post({type:"indexDocs",kind:"skill"})},probe:{running:Vl.docs===!0,result:Fl.docs},onProbe:(x,P)=>{$i(P),ta(p=>({...p,[P]:!0})),e.transport.post({type:"runSearchProbe",query:x,target:P})},onClearProbe:()=>$i("docs"),onClearIndex:()=>{na(void 0),e.transport.post({type:"clearDocsIndex",kind:"skill"})},indexProgress:Wn?.kind==="skills"?Wn:void 0,onStopIndexing:()=>e.transport.post({type:"cancelIndexing",kind:"skills"}),indexing:jm,indexResult:bo===void 0?void 0:bo.error!==void 0?`Failed: ${bo.error}`:`Indexed ${String(bo.indexed??0)} entries.`,onDelete:x=>e.transport.post({type:"deleteSkillFile",name:x}),onSaveDirs:(x,P)=>{dI(x),e.transport.post({type:"saveSkillDirs",dir:x,paths:P})}},schedules:{schedules:FE,tools:HE,skills:GE,runningId:aI,onSave:x=>e.transport.post({type:"saveSchedule",schedule:x}),onDelete:x=>e.transport.post({type:"deleteSchedule",id:x}),onDuplicate:x=>e.transport.post({type:"duplicateSchedule",id:x}),onToggle:(x,P)=>e.transport.post({type:"setScheduleEnabled",id:x,enabled:P}),onRunNow:x=>e.transport.post({type:"runScheduleNow",id:x}),mentionCandidates:KS,onQueryMentions:y0,onOpenReport:x=>e.transport.post({type:"openManagedFile",path:x}),onOpenRun:(x,P)=>e.transport.post({type:"openScheduleRun",taskId:x,title:P}),scheduler:rI,onRestartScheduler:()=>e.transport.post({type:"restartScheduler"}),onDeleteRun:(x,P)=>e.transport.post({type:"deleteScheduleRun",id:x,at:P}),onClearRuns:x=>e.transport.post({type:"clearScheduleRuns",...x===void 0?{}:{id:x}})},customData:{datasets:ia.datasets,tools:ia.tools,stores:ia.stores,defaultStoreLabel:ia.defaultStoreLabel,semantic:ia.semantic,guidance:ia.guidance,progress:Wn?.kind==="dataset"?Wn:void 0,probe:{running:Vl.data===!0,result:Fl.data},onProbe:(x,P)=>{$i(P),ta(p=>({...p,[P]:!0})),e.transport.post({type:"runSearchProbe",query:x,target:P})},onClearProbe:()=>$i("data"),onRefresh:()=>{e.transport.post({type:"requestTools"}),e.transport.post({type:"requestDatasetStatus"})},onSave:x=>e.transport.post({type:"saveDataset",dataset:x}),onDelete:x=>e.transport.post({type:"deleteDataset",id:x}),onSync:x=>e.transport.post({type:"syncDataset",id:x}),onClear:(x,P)=>e.transport.post({type:"clearDataset",id:x,resync:P}),onStop:()=>e.transport.post({type:"cancelIndexing"})},outlook:{status:wE,onSave:x=>e.transport.post({type:"saveMailSettings",...x}),onSyncNow:()=>e.transport.post({type:"syncMail"}),onPrune:()=>e.transport.post({type:"pruneMail"}),tree:l0,progress:Wn?.kind==="mail"?Wn:void 0,onRefreshFolders:()=>{s0(x=>({...x,loading:!0})),e.transport.post({type:"requestOutlookFolders",force:l0.folders.length>0})},onClear:x=>e.transport.post({type:"clearMailIndex",resync:x}),probe:{running:Vl.mail===!0,result:Fl.mail},onProbe:(x,P)=>{$i(P),ta(p=>({...p,[P]:!0})),e.transport.post({type:"runSearchProbe",query:x,target:P})},onClearProbe:()=>$i("mail"),onRefreshDays:x=>e.transport.post({type:"refreshMail",days:x}),onStop:()=>e.transport.post({type:"cancelIndexing",kind:"mail"})},tools:{...iI,docsIndex:{enabled:vo.enabled,retrievalReady:Hl!==void 0&&Lc?.model!==void 0,indexing:jm,result:tx(bo)},onIndexDocs:()=>e.transport.post({type:"indexDocs",kind:"tool"}),probe:{running:Vl.docs===!0,result:Fl.docs},onProbe:(x,P)=>{$i(P),ta(p=>({...p,[P]:!0})),e.transport.post({type:"runSearchProbe",query:x,target:P})},onClearProbe:()=>$i("docs"),onRefreshTools:()=>e.transport.post({type:"requestTools"}),onClearDocs:()=>{na(void 0),e.transport.post({type:"clearDocsIndex",kind:"tool"})},progress:Wn?.kind==="tools"?Wn:void 0,onStopIndexing:()=>e.transport.post({type:"cancelIndexing",kind:"tools"}),...h0===void 0?{}:{toolTimeoutSeconds:h0},onSetToolTimeoutFor:(x,P)=>e.transport.post({type:"setToolTimeoutFor",name:x,...P===void 0?{}:{seconds:P}}),onSetToolTimeout:x=>e.transport.post({type:"setToolTimeout",...x===void 0?{}:{seconds:x}}),onSetOffice:(x,P)=>{p0(p=>({...p,office:{...p.office,excel:x,outlook:P}})),e.transport.post({type:"setOffice",excel:x,outlook:P})}},...u!==void 0?{reviews:{...u,onDecide:(x,P,p)=>e.transport.post({type:"decideReview",id:x,approved:P,...p!==void 0?{reason:p}:{}})}}:{},...l!==void 0?{variables:{...l,onSaveUser:x=>e.transport.post({type:"saveUserVariables",variables:x}),onSaveAdmin:x=>e.transport.post({type:"saveAdminVariables",variables:x}),onSaveAdminIds:x=>e.transport.post({type:"saveAdminIds",ids:x})}}:{},python:{...f?{programming:{profiles:q.map(x=>({id:x.id,label:x.label})),selectedId:h,onSelect:x=>e.transport.post({type:"setProgrammingProfile",id:x})}}:{},status:jE,settings:UE,onBrowse:x0,pickedPath:FS,onOpenFile:b0,onDeleteTool:x=>e.transport.post({type:"deletePythonTool",name:x}),onApproveTool:x=>e.transport.post({type:"approvePythonTool",name:x}),onSave:x=>e.transport.post({type:"setPython",dynamicTools:x.dynamicTools,uvPath:x.uvPath,toolsDir:x.toolsDir,venvPath:x.venvPath,interpreterPath:x.interpreterPath,timeoutSeconds:x.timeoutSeconds,indexUrl:x.indexUrl,offline:x.offline,env:x.env})},network:{...XS!==void 0?{settings:XS}:{settings:void 0},onSave:x=>e.transport.post({type:"saveNetwork",settings:x})}}):t==="history"?(0,Ve.jsx)(Qz,{tasks:eE,activeTaskId:YS,onOpen:kI,onDelete:wI,onNew:v0}):FI?(0,Ve.jsxs)("div",{style:{padding:20,textAlign:"center"},children:[(0,Ve.jsx)("p",{style:{color:s.muted},children:"No provider configured yet."}),(0,Ve.jsx)("button",{type:"button",style:le(!1),onClick:g0,children:"Configure a Provider"})]}):(0,Ve.jsx)(Ib,{plan:WE,planCheckpoints:JE,directRoles:Dm.roles.filter(x=>x.available&&x.enabled).map(x=>({role:x.role,name:x.name,summary:x.summary})),onSetPlan:x=>{m0(x),e.transport.post({type:"setPlan",plan:x})},conversationKey:YS??"new",messages:g,isStreaming:S,error:C,pendingApproval:en,pendingForm:hi,onSubmitForm:(x,P)=>{L(void 0),e.transport.post({type:"formResponse",id:x,submitted:!0,values:P})},onDismissForm:x=>{L(void 0),e.transport.post({type:"formResponse",id:x,submitted:!1,values:{}})},canRollback:de,onSend:fI,onCancel:hI,onDecideApproval:pI,onAlwaysAllow:gI,onRollback:RI,usage:nE,expertSpend:Yn,supportsVision:rE,mentionCandidates:KS,onQueryMentions:y0,profiles:q,activeProfileId:R,onSelectProfile:S0,expertEnabled:Mm,queued:uE,onUnqueue:mI,searchConnections:Bm.map(x=>({id:x.id,label:x.label})),activeSearchId:Hl,onSelectSearch:x=>e.transport.post({type:"setActiveSearchConnection",id:x})})})]})}var T6=N(z6(),1);var Im=class{constructor(t){this.onStatus=t}onStatus;listeners=new Set;token;streamOpen=!1;queued=[];async connect(){let t=new URLSearchParams(window.location.hash.slice(1)).get("t");if(t!==null){window.history.replaceState(null,"",window.location.pathname);let n=await fetch("/api/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({handoff:t})});if(!n.ok)throw new Error(await n.text());this.token=(await n.json()).token,sessionStorage.setItem("lightCodeToken",this.token)}else this.token=sessionStorage.getItem("lightCodeToken")??void 0;if(this.token===void 0)try{let n=await fetch("/api/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});n.ok&&(this.token=(await n.json()).token,sessionStorage.setItem("lightCodeToken",this.token))}catch{}if(this.token===void 0)throw new Error("No session. Restart light-code and open the printed URL.");this.listen()}async listen(){for(;;){try{let t=window.location.pathname.startsWith("/admin")?"?view=admin":"",n=await fetch(`/api/events${t}`,{headers:{Authorization:`Bearer ${this.token??""}`}});if(!n.ok||n.body===null)throw new Error(`stream failed: ${n.status}`);this.onStatus("connected"),this.openStream();let r=n.body.getReader(),i=new TextDecoder,o="";for(;;){let{done:a,value:l}=await r.read();if(a)break;o+=i.decode(l,{stream:!0});let c=o.indexOf(`
|
package/dist/server.js
CHANGED
|
@@ -42096,9 +42096,19 @@ async function listModels(http, profile, auth2, signal) {
|
|
|
42096
42096
|
function messageOf(error51) {
|
|
42097
42097
|
return error51 instanceof Error ? error51.message : String(error51);
|
|
42098
42098
|
}
|
|
42099
|
+
var TEST_CONNECTION_TIMEOUT_MS = 2e4;
|
|
42099
42100
|
async function testConnection(profile, context, http, signal) {
|
|
42100
42101
|
const steps = [];
|
|
42101
42102
|
const finish = () => ({ ok: steps.every((step) => step.status !== "failed"), steps });
|
|
42103
|
+
const deadline = new AbortController();
|
|
42104
|
+
const timer = setTimeout(() => deadline.abort(), TEST_CONNECTION_TIMEOUT_MS);
|
|
42105
|
+
const onOuterAbort = () => deadline.abort();
|
|
42106
|
+
signal?.addEventListener("abort", onOuterAbort);
|
|
42107
|
+
const bounded = deadline.signal;
|
|
42108
|
+
const release = () => {
|
|
42109
|
+
clearTimeout(timer);
|
|
42110
|
+
signal?.removeEventListener("abort", onOuterAbort);
|
|
42111
|
+
};
|
|
42102
42112
|
if (profile.auth.type === "apigeeMtls") {
|
|
42103
42113
|
try {
|
|
42104
42114
|
let expiryNote = "";
|
|
@@ -42115,6 +42125,7 @@ async function testConnection(profile, context, http, signal) {
|
|
|
42115
42125
|
detail: `Loaded ${loaded?.pfx !== void 0 ? "PFX bundle" : "client certificate and key"}.${expiryNote}`
|
|
42116
42126
|
});
|
|
42117
42127
|
} catch (error51) {
|
|
42128
|
+
release();
|
|
42118
42129
|
steps.push({ step: "certificates", status: "failed", detail: messageOf(error51) });
|
|
42119
42130
|
steps.push({ step: "token", status: "skipped", detail: "Not attempted \u2014 certificates failed to load." });
|
|
42120
42131
|
steps.push({ step: "models", status: "skipped", detail: "Not attempted \u2014 certificates failed to load." });
|
|
@@ -42146,16 +42157,28 @@ async function testConnection(profile, context, http, signal) {
|
|
|
42146
42157
|
detail: profile.auth.type === "tokenCommand" ? "The token command ran and returned a token." : profile.auth.type === "apiKey" && profile.auth.apiKeyRef.startsWith("env:") ? `Key read from ${profile.auth.apiKeyRef.slice("env:".length)}.` : "Credential resolved from secure storage."
|
|
42147
42158
|
});
|
|
42148
42159
|
} catch (error51) {
|
|
42160
|
+
release();
|
|
42149
42161
|
steps.push({ step: "token", status: "failed", detail: messageOf(error51) });
|
|
42150
42162
|
steps.push({ step: "models", status: "skipped", detail: "Not attempted \u2014 no credential." });
|
|
42151
42163
|
return finish();
|
|
42152
42164
|
}
|
|
42153
42165
|
}
|
|
42154
|
-
const result = await listModels(http, profile, auth2,
|
|
42166
|
+
const result = await listModels(http, profile, auth2, bounded);
|
|
42167
|
+
release();
|
|
42155
42168
|
if (result.ids.length > 0) {
|
|
42156
42169
|
steps.push({ step: "models", status: "ok", detail: `Gateway returned ${result.ids.length} model(s).` });
|
|
42170
|
+
} else if (deadline.signal.aborted && signal?.aborted !== true) {
|
|
42171
|
+
steps.push({
|
|
42172
|
+
step: "models",
|
|
42173
|
+
status: "failed",
|
|
42174
|
+
detail: `No response within ${String(Math.round(TEST_CONNECTION_TIMEOUT_MS / 1e3))}s. The address resolved and the connection was accepted, but nothing came back \u2014 check the base URL path and whether anything is filtering this route.`
|
|
42175
|
+
});
|
|
42157
42176
|
} else {
|
|
42158
|
-
steps.push({
|
|
42177
|
+
steps.push({
|
|
42178
|
+
step: "models",
|
|
42179
|
+
status: "note",
|
|
42180
|
+
detail: `${result.warning ?? "No catalogue returned."} This does not by itself mean the connection is broken \u2014 plenty of gateways serve chat completions without publishing /models. Type the model id by hand.`
|
|
42181
|
+
});
|
|
42159
42182
|
}
|
|
42160
42183
|
return finish();
|
|
42161
42184
|
}
|
|
@@ -43882,7 +43905,24 @@ function buildSystemPrompt(workspaceRoot, options = {}) {
|
|
|
43882
43905
|
' write it for them \u2014 "checking which gateway the profile points at", not "reading a file".',
|
|
43883
43906
|
"- Paths are relative to the workspace root. You cannot access anything outside it.",
|
|
43884
43907
|
"- When the task is complete, call attempt_completion with a summary of what you did.",
|
|
43885
|
-
"- If you need information only the user can provide, call ask_followup_question."
|
|
43908
|
+
"- If you need information only the user can provide, call ask_followup_question.",
|
|
43909
|
+
/*
|
|
43910
|
+
* Asked for directly, from real use with a model whose training predates the libraries in
|
|
43911
|
+
* front of it. The failure it addresses is not refusing to answer - it is answering anyway,
|
|
43912
|
+
* from a remembered version of an API, which produces code that looks right and is wrong
|
|
43913
|
+
* against the installed version. The user very often has the page open.
|
|
43914
|
+
*
|
|
43915
|
+
* Phrased as a thing to do rather than a permission, because a model that is unsure is
|
|
43916
|
+
* already reluctant to interrupt, and "you may ask" reads as "prefer not to".
|
|
43917
|
+
*/
|
|
43918
|
+
"- **If a library or API is unfamiliar, or the version here does not match what you remember,",
|
|
43919
|
+
" ask the user for documentation rather than guessing.** Say which library and what you need",
|
|
43920
|
+
" to know - a signature, which module something moved to, whether a call is still supported.",
|
|
43921
|
+
" They can paste it, point you at a file or a URL they have already fetched, or tell you the",
|
|
43922
|
+
" house convention. Recalling an API from a version you were trained on produces code that",
|
|
43923
|
+
" looks correct and fails against the one installed, which is far more expensive than asking.",
|
|
43924
|
+
"- Before asking, check what is here: the imports and existing calls in this workspace are",
|
|
43925
|
+
" evidence about the version actually installed, and a skill may already describe it."
|
|
43886
43926
|
);
|
|
43887
43927
|
if (options.skills !== void 0 && options.skills.length > 0) {
|
|
43888
43928
|
lines.push("", options.skills);
|
|
@@ -43931,7 +43971,7 @@ function buildSystemPrompt(workspaceRoot, options = {}) {
|
|
|
43931
43971
|
lines.push("", "Email:", "- **Always answer questions about email from the index, using search_mail and", " mail_patterns.** That is what it is for. It is fast, it answers questions about time", " and recurrence that a live search cannot, and it does not disturb the running Outlook.", '- **Only search Outlook itself when the user asks you to.** "Check Outlook", "look at my', ' actual mailbox", "is it there now" and anything similar are the instruction to use', " outlook_search. Do not reach for it on your own initiative.", "- If the index has nothing, say so plainly and say when it was last synced. Do not", " quietly fall back to scanning Outlook - a slow live scan that nobody asked for reads", " as the assistant having hung.", "- One exception worth naming: if the user is asking about something that arrived in the", " last few minutes, the index may not have it yet. Say that, and offer to check Outlook", " rather than doing it unasked.", "- **The index holds plain text.** Colours, highlighting and images are not in it. When", " those could carry meaning \u2014 a red line marking a failure, a highlighted cell \u2014 use", " outlook_read_email on the id, which reads the live message and reports the colours.", " Never conclude a message looks fine from indexed text alone.", "- mail_coverage says which folders are indexed and how far back. Check it before saying", " something is not in the mail: an empty search over an unindexed folder looks exactly", " like an empty search over an indexed one.", "- **Use mail_stats for any question with a number in the answer** \u2014 how many alerts per", " folder, per day, per hour, which senders, whether a figure inside the alerts is climbing.", " It counts everything the filters matched. Never count search results by eye: search", " returns a page, so counting what you were shown reports a sample as if it were the total.", "- mail_stats already returns categories, values and detail in the shape show_chart wants.", " Pass it through rather than retyping the numbers, and keep the detail.");
|
|
43932
43972
|
}
|
|
43933
43973
|
if (options.expertAvailable === true) {
|
|
43934
|
-
lines.push("", "Expert consultation:", "- A stronger model, Claude, is available through the
|
|
43974
|
+
lines.push("", "Expert consultation:", "- A stronger model, Claude, is available through the ask_claude tool. You CAN talk to", " it. Never tell the user you have no way to reach another model \u2014 you do.", '- **If the user asks you to consult it, do so.** "Ask Claude", "check with the', ' expert", "what does Claude think" and anything similar are direct instructions.', " It is their money and their decision; do not talk them out of it or decide the", " question is too simple to be worth asking.", "- Otherwise, judge it yourself. It costs real money per call, so on your own", " initiative use it for: planning a change spanning several files, diagnosing a bug", " you have already failed to fix once, choosing between designs with long-lived", " consequences, or reviewing something subtle before committing to it.", "- On your own initiative, do not use it for anything you could answer by reading a", " file, for routine edits, or for restating something already established here.", "- If you decide against consulting it, say that you chose not to and why. Do not say", " you are unable to.", "- The expert can read and search this workspace but cannot edit or run anything. It", " cannot see this conversation, so put the context it needs in your question.", "- You remain responsible for the work. Treat its answer as advice from a colleague:", " verify it against the actual code, and say so if you disagree.");
|
|
43935
43975
|
}
|
|
43936
43976
|
if (options.modeGuidance !== void 0 && options.modeGuidance.length > 0) {
|
|
43937
43977
|
lines.push("", options.modeGuidance);
|
|
@@ -44195,9 +44235,11 @@ var paramsSchema2 = external_exports.object({
|
|
|
44195
44235
|
question: external_exports.string().min(1).describe("The question, with the code and context needed to answer it. The expert cannot see this conversation."),
|
|
44196
44236
|
files: external_exports.array(external_exports.string()).optional().describe("Workspace-relative paths worth reading. The expert can open these itself.")
|
|
44197
44237
|
});
|
|
44238
|
+
var ASK_CLAUDE_TOOL = "ask_claude";
|
|
44239
|
+
var LEGACY_ASK_EXPERT_TOOL = "ask_expert";
|
|
44198
44240
|
function createAskExpertTool(options) {
|
|
44199
44241
|
return {
|
|
44200
|
-
name:
|
|
44242
|
+
name: ASK_CLAUDE_TOOL,
|
|
44201
44243
|
group: "read",
|
|
44202
44244
|
/*
|
|
44203
44245
|
* The rationing is said only where somebody is counting.
|
|
@@ -44213,7 +44255,7 @@ function createAskExpertTool(options) {
|
|
|
44213
44255
|
* byte-stable for a whole session and changes only when the user changes their mind in
|
|
44214
44256
|
* Settings, exactly as switching the dispatcher does.
|
|
44215
44257
|
*/
|
|
44216
|
-
description: "Consult a
|
|
44258
|
+
description: "Consult Claude, running as a separate command line on this machine, about a hard problem: planning a multi-file change, diagnosing a bug you have already failed to fix, or choosing between designs. " + (options.budgetMatters === true ? "Each call costs the user money, so use it for genuinely difficult questions only, and there may be a per-task budget after which it stops being available. " : "Consult it whenever another reader would genuinely change what you do. ") + "The expert can read the workspace but cannot edit or run anything. Consultations within one task continue the same conversation, so after the first one it remembers what you already told it \u2014 a follow-up is far cheaper than a fresh explanation.",
|
|
44217
44259
|
parametersSchema: paramsSchema2,
|
|
44218
44260
|
async preview(params) {
|
|
44219
44261
|
return {
|
|
@@ -44496,6 +44538,9 @@ var PLAN_FIRST = [
|
|
|
44496
44538
|
"3. **Propose it with `update_plan`.** The user sees a diff and approves it. Do not skip this:",
|
|
44497
44539
|
" a plan held only in the conversation is forgotten as the chat grows, and it is not",
|
|
44498
44540
|
" something the user has agreed to.",
|
|
44541
|
+
" **Never write the plan to a file instead.** A file is not the plan: nothing reads it, the",
|
|
44542
|
+
" progress panel stays empty, and the user never approved it. If `update_plan` fails, say",
|
|
44543
|
+
" what it said and stop \u2014 a workaround that looks like progress is worse than the failure.",
|
|
44499
44544
|
"4. Only once it is approved, start the work, reporting each step with `plan_progress`.",
|
|
44500
44545
|
"",
|
|
44501
44546
|
"If the user declines, ask what they want changed and propose a revised plan. If no expert is",
|
|
@@ -44785,7 +44830,7 @@ function buildRoster(team, self) {
|
|
|
44785
44830
|
function buildAgentBriefing(input) {
|
|
44786
44831
|
const tools = (input.tools ?? []).filter(
|
|
44787
44832
|
// Telling a specialist it can consult a specialist is noise at best and a loop at worst.
|
|
44788
|
-
(tool) => tool.name !== "ask_agent" && tool.name !==
|
|
44833
|
+
(tool) => tool.name !== "ask_agent" && tool.name !== ASK_CLAUDE_TOOL
|
|
44789
44834
|
);
|
|
44790
44835
|
const skills = input.skills ?? [];
|
|
44791
44836
|
const team = input.team;
|
|
@@ -44910,7 +44955,7 @@ var PolicyApprovalGate = class {
|
|
|
44910
44955
|
var CONSULT_MAX_STEPS = 5;
|
|
44911
44956
|
var ALLOWED_GROUPS = /* @__PURE__ */ new Set(["read"]);
|
|
44912
44957
|
function toolsForConsultation(all, extra = /* @__PURE__ */ new Set()) {
|
|
44913
|
-
return all.filter((tool) => (ALLOWED_GROUPS.has(tool.group) || extra.has(tool.name)) && tool.name !== "ask_agent" && tool.name !==
|
|
44958
|
+
return all.filter((tool) => (ALLOWED_GROUPS.has(tool.group) || extra.has(tool.name)) && tool.name !== "ask_agent" && tool.name !== ASK_CLAUDE_TOOL && tool.name !== LEGACY_ASK_EXPERT_TOOL);
|
|
44914
44959
|
}
|
|
44915
44960
|
async function runConsultation(options) {
|
|
44916
44961
|
const limit = options.maxSteps ?? CONSULT_MAX_STEPS;
|
|
@@ -44992,13 +45037,13 @@ function createRecallExpertTool(options) {
|
|
|
44992
45037
|
return {
|
|
44993
45038
|
name: "recall_expert_advice",
|
|
44994
45039
|
group: "read",
|
|
44995
|
-
description: "Re-read advice the expert already gave in this task, at no cost. Check here before calling
|
|
45040
|
+
description: "Re-read advice the expert already gave in this task, at no cost. Check here before calling ask_claude \u2014 if a plan was lost to an error or a long conversation, it can be recovered instead of bought again. Returns previous answers verbatim; it never asks anything new.",
|
|
44996
45041
|
parametersSchema: paramsSchema4,
|
|
44997
45042
|
async execute(params) {
|
|
44998
45043
|
const all = options.history();
|
|
44999
45044
|
if (all.length === 0) {
|
|
45000
45045
|
return {
|
|
45001
|
-
content: "The expert has not been consulted in this task yet, so there is nothing to recall. Use
|
|
45046
|
+
content: "The expert has not been consulted in this task yet, so there is nothing to recall. Use ask_claude if you need advice."
|
|
45002
45047
|
};
|
|
45003
45048
|
}
|
|
45004
45049
|
const needle = params.contains?.trim().toLowerCase();
|
|
@@ -61916,8 +61961,8 @@ ${preview.text}` } : {}
|
|
|
61916
61961
|
}
|
|
61917
61962
|
for (const tool of python.generatedTools())
|
|
61918
61963
|
combined.register(tool, { dispatchOnly: dispatcher });
|
|
61919
|
-
combined.register(createUpdatePlanTool(planAccess)
|
|
61920
|
-
combined.register(createPlanProgressTool(planAccess)
|
|
61964
|
+
combined.register(createUpdatePlanTool(planAccess));
|
|
61965
|
+
combined.register(createPlanProgressTool(planAccess));
|
|
61921
61966
|
combined.register(createReadRolePromptTool(rolePromptAccess), { dispatchOnly: dispatcher });
|
|
61922
61967
|
combined.register(createUpdateRolePromptTool(rolePromptAccess), { dispatchOnly: dispatcher });
|
|
61923
61968
|
combined.register(createCreateRoleTool(rolePromptAccess), { dispatchOnly: dispatcher });
|
|
@@ -62111,7 +62156,7 @@ ${preview.text}` } : {}
|
|
|
62111
62156
|
...cachedAssessment === void 0 ? {} : { juniorAssessment: cachedAssessment },
|
|
62112
62157
|
// `ask_expert` itself is excluded: telling the expert it can consult itself is
|
|
62113
62158
|
// noise at best and a loop at worst.
|
|
62114
|
-
promptTools: combined.promptList().filter((tool) => tool.name !==
|
|
62159
|
+
promptTools: combined.promptList().filter((tool) => tool.name !== ASK_CLAUDE_TOOL),
|
|
62115
62160
|
dispatchOnlyTools: combined.dispatchOnlyList(),
|
|
62116
62161
|
skills,
|
|
62117
62162
|
retrievalAvailable: combined.get("search_docs") !== void 0
|
|
@@ -63948,11 +63993,22 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
63948
63993
|
}
|
|
63949
63994
|
}
|
|
63950
63995
|
async function handleRefreshMail(days) {
|
|
63951
|
-
if (mailBusy)
|
|
63996
|
+
if (mailBusy) {
|
|
63997
|
+
mailLastResult = "A mail sync is already running \u2014 wait for it to finish, then try again.";
|
|
63998
|
+
await postMailStatus();
|
|
63952
63999
|
return;
|
|
64000
|
+
}
|
|
63953
64001
|
const config2 = await loadSettings();
|
|
63954
|
-
if (cachedOffice.outlook !== true
|
|
64002
|
+
if (cachedOffice.outlook !== true) {
|
|
64003
|
+
mailLastResult = "Outlook is switched off in Settings \u2192 Tools.";
|
|
64004
|
+
await postMailStatus();
|
|
64005
|
+
return;
|
|
64006
|
+
}
|
|
64007
|
+
if (!officeAvailable()) {
|
|
64008
|
+
mailLastResult = "Outlook is not available on this host.";
|
|
64009
|
+
await postMailStatus();
|
|
63955
64010
|
return;
|
|
64011
|
+
}
|
|
63956
64012
|
const chosen = config2.mail?.folders ?? [];
|
|
63957
64013
|
if (chosen.length === 0) {
|
|
63958
64014
|
mailLastResult = "No folders selected.";
|
|
@@ -66890,20 +66946,32 @@ function toolCallSummary(call, outcome) {
|
|
|
66890
66946
|
};
|
|
66891
66947
|
}
|
|
66892
66948
|
function consultationFromToolCall(name, rawArguments) {
|
|
66893
|
-
|
|
66949
|
+
const call = throughDispatch(name, rawArguments);
|
|
66950
|
+
if (call.name === ASK_CLAUDE_TOOL || call.name === LEGACY_ASK_EXPERT_TOOL)
|
|
66894
66951
|
return "expert";
|
|
66895
|
-
if (name !== "ask_agent")
|
|
66952
|
+
if (call.name !== "ask_agent")
|
|
66896
66953
|
return void 0;
|
|
66897
|
-
const decoded =
|
|
66954
|
+
const decoded = call.args;
|
|
66898
66955
|
const role = typeof decoded === "object" && decoded !== null ? decoded.role : void 0;
|
|
66899
66956
|
return typeof role === "string" && role.trim().length > 0 ? role.trim().toLowerCase() : "unknown";
|
|
66900
66957
|
}
|
|
66901
66958
|
function chartFromToolCall(name, rawArguments) {
|
|
66902
|
-
|
|
66959
|
+
const call = throughDispatch(name, rawArguments);
|
|
66960
|
+
if (call.name !== "show_chart")
|
|
66903
66961
|
return void 0;
|
|
66904
|
-
const parsed = chartSpecSchema.safeParse(
|
|
66962
|
+
const parsed = chartSpecSchema.safeParse(call.args);
|
|
66905
66963
|
return parsed.success ? { kind: "chart", chart: parsed.data } : { kind: "chartError", message: parsed.error.issues.map((issue2) => issue2.message).join("; ") };
|
|
66906
66964
|
}
|
|
66965
|
+
function throughDispatch(name, rawArguments) {
|
|
66966
|
+
const decoded = decodeArguments(rawArguments);
|
|
66967
|
+
if (name !== CALL_TOOL_NAME || typeof decoded !== "object" || decoded === null) {
|
|
66968
|
+
return { name, args: decoded };
|
|
66969
|
+
}
|
|
66970
|
+
const inner = decoded;
|
|
66971
|
+
if (typeof inner.name !== "string" || inner.name.length === 0)
|
|
66972
|
+
return { name, args: decoded };
|
|
66973
|
+
return { name: inner.name, args: inner.arguments ?? {} };
|
|
66974
|
+
}
|
|
66907
66975
|
function decodeArguments(raw) {
|
|
66908
66976
|
try {
|
|
66909
66977
|
return JSON.parse(raw.length > 0 ? raw : "{}");
|