@orbit-build/cli 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1273 -1372
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -303934,13 +303934,15 @@ var DISABLE_ALT_SCREEN = "\x1B[?1049l";
|
|
|
303934
303934
|
var ENABLE_MOUSE = "\x1B[?1000h\x1B[?1006h";
|
|
303935
303935
|
var DISABLE_MOUSE = "\x1B[?1006l\x1B[?1000l";
|
|
303936
303936
|
var HIDE_CURSOR = "\x1B[?25l";
|
|
303937
|
+
var STEADY_BAR_CURSOR = "\x1B[6 q";
|
|
303938
|
+
var DEFAULT_CURSOR = "\x1B[0 q";
|
|
303937
303939
|
var RESET_AND_SHOW_CURSOR = "\x1B[0m\x1B[?25h";
|
|
303938
303940
|
function enterFullscreenTerminal(mouseEnabled, stdout2 = process.stdout) {
|
|
303939
303941
|
const mouseMode = mouseEnabled ? ENABLE_MOUSE : "";
|
|
303940
|
-
stdout2.write(`${ENABLE_ALT_SCREEN}${mouseMode}${HIDE_CURSOR}`);
|
|
303942
|
+
stdout2.write(`${ENABLE_ALT_SCREEN}${STEADY_BAR_CURSOR}${mouseMode}${HIDE_CURSOR}`);
|
|
303941
303943
|
}
|
|
303942
303944
|
function leaveFullscreenTerminal(stdin2 = process.stdin, stdout2 = process.stdout) {
|
|
303943
|
-
stdout2.write(`${DISABLE_MOUSE}${DISABLE_ALT_SCREEN}${RESET_AND_SHOW_CURSOR}`);
|
|
303945
|
+
stdout2.write(`${DISABLE_MOUSE}${DEFAULT_CURSOR}${DISABLE_ALT_SCREEN}${RESET_AND_SHOW_CURSOR}`);
|
|
303944
303946
|
if (stdin2.setRawMode) stdin2.setRawMode(false);
|
|
303945
303947
|
}
|
|
303946
303948
|
|
|
@@ -306124,6 +306126,7 @@ import { randomBytes as randomBytes5, randomUUID as randomUUID20, timingSafeEqua
|
|
|
306124
306126
|
import { z as z86 } from "zod";
|
|
306125
306127
|
|
|
306126
306128
|
// src/runtime/CommandRouter.ts
|
|
306129
|
+
import { createHash as createHash14 } from "node:crypto";
|
|
306127
306130
|
import picocolors21 from "picocolors";
|
|
306128
306131
|
|
|
306129
306132
|
// src/commands/customCommands.ts
|
|
@@ -306582,6 +306585,26 @@ async function getAutocompleteCandidates(cwd, config, mcpPromptCommands = []) {
|
|
|
306582
306585
|
function projectPathKey(path10) {
|
|
306583
306586
|
return /^(?:[A-Za-z]:|\\\\)/.test(path10) ? path10.replace(/\\/g, "/").toLowerCase() : path10;
|
|
306584
306587
|
}
|
|
306588
|
+
function projectFolderHints(projects) {
|
|
306589
|
+
const hints = /* @__PURE__ */ new Map();
|
|
306590
|
+
const parents = projects.map(({ path: path10 }) => {
|
|
306591
|
+
const windows = /^(?:[A-Za-z]:|\\\\)/.test(path10);
|
|
306592
|
+
const separator = windows && path10.includes("\\") ? "\\" : "/";
|
|
306593
|
+
const parts = (windows ? path10.replace(/\\/g, "/") : path10).split("/").filter(Boolean);
|
|
306594
|
+
return { parts: parts.slice(0, -1), separator };
|
|
306595
|
+
});
|
|
306596
|
+
for (const [index, project] of projects.entries()) {
|
|
306597
|
+
const others = parents.filter((_, i2) => i2 !== index && projects[i2].name === project.name);
|
|
306598
|
+
if (!others.length) continue;
|
|
306599
|
+
const { parts, separator } = parents[index];
|
|
306600
|
+
let count = 1;
|
|
306601
|
+
while (count < parts.length && others.some(
|
|
306602
|
+
(parent) => parent.parts.slice(-count).join("/") === parts.slice(-count).join("/")
|
|
306603
|
+
)) count++;
|
|
306604
|
+
hints.set(project.path, parts.slice(-count).join(separator) || separator);
|
|
306605
|
+
}
|
|
306606
|
+
return hints;
|
|
306607
|
+
}
|
|
306585
306608
|
function createNavigationRows() {
|
|
306586
306609
|
const signatures = /* @__PURE__ */ new WeakMap();
|
|
306587
306610
|
return function reconcile(container, items, id, content, render) {
|
|
@@ -306707,6 +306730,460 @@ var WEB_UI_CLIENT_DRAFTS_SCRIPT = String.raw` const drafts = (${createConversat
|
|
|
306707
306730
|
}
|
|
306708
306731
|
`;
|
|
306709
306732
|
|
|
306733
|
+
// src/runtime/webui/WebUiSecurity.ts
|
|
306734
|
+
import { timingSafeEqual } from "crypto";
|
|
306735
|
+
import { z as z68 } from "zod";
|
|
306736
|
+
|
|
306737
|
+
// src/runtime/webui/WebUiErrors.ts
|
|
306738
|
+
var WebUiRequestError = class extends Error {
|
|
306739
|
+
constructor(code, statusCode, message2) {
|
|
306740
|
+
super(message2);
|
|
306741
|
+
this.code = code;
|
|
306742
|
+
this.statusCode = statusCode;
|
|
306743
|
+
}
|
|
306744
|
+
code;
|
|
306745
|
+
statusCode;
|
|
306746
|
+
name = "WebUiRequestError";
|
|
306747
|
+
};
|
|
306748
|
+
|
|
306749
|
+
// src/runtime/webui/WebUiContracts.ts
|
|
306750
|
+
var WEB_UI_PROJECT_ERROR_CODES = [
|
|
306751
|
+
"absolute_path_required",
|
|
306752
|
+
"filesystem_root",
|
|
306753
|
+
"entrypoint_unavailable",
|
|
306754
|
+
"project_missing",
|
|
306755
|
+
"project_not_directory",
|
|
306756
|
+
"parent_missing",
|
|
306757
|
+
"parent_not_directory",
|
|
306758
|
+
"create_failed",
|
|
306759
|
+
"launch_failed",
|
|
306760
|
+
"startup_failed",
|
|
306761
|
+
"startup_timeout"
|
|
306762
|
+
];
|
|
306763
|
+
|
|
306764
|
+
// src/runtime/webui/WebUiSecurity.ts
|
|
306765
|
+
var WEB_UI_PROJECT_ERROR_CODE_SET = new Set(
|
|
306766
|
+
WEB_UI_PROJECT_ERROR_CODES
|
|
306767
|
+
);
|
|
306768
|
+
function sanitizeWebEventPayload(type, payload) {
|
|
306769
|
+
if (!isRecord7(payload)) return void 0;
|
|
306770
|
+
switch (type) {
|
|
306771
|
+
case "ui_turn_started":
|
|
306772
|
+
return {
|
|
306773
|
+
turnId: safeWebText(payload.turnId, 200),
|
|
306774
|
+
source: payload.source === "terminal" ? "terminal" : "web",
|
|
306775
|
+
prompt: safeWebText(payload.prompt, 8e3)
|
|
306776
|
+
};
|
|
306777
|
+
case "ui_turn_completed":
|
|
306778
|
+
return {
|
|
306779
|
+
turnId: safeWebText(payload.turnId, 200),
|
|
306780
|
+
source: payload.source === "terminal" ? "terminal" : "web",
|
|
306781
|
+
status: payload.status === "failed" || payload.status === "aborted" ? payload.status : "completed",
|
|
306782
|
+
message: safeWebText(payload.message, 2e3)
|
|
306783
|
+
};
|
|
306784
|
+
case "model_request":
|
|
306785
|
+
return { model: safeWebText(payload.model, 200) };
|
|
306786
|
+
case "model_routing":
|
|
306787
|
+
return {
|
|
306788
|
+
model: safeWebText(payload.model, 200),
|
|
306789
|
+
lane: ["locked", "fallback", "fast", "balanced", "quality"].includes(
|
|
306790
|
+
String(payload.lane)
|
|
306791
|
+
) ? String(payload.lane) : "balanced",
|
|
306792
|
+
reason: safeWebText(payload.reason, 100),
|
|
306793
|
+
confidence: payload.confidence === "high" ? "high" : "medium"
|
|
306794
|
+
};
|
|
306795
|
+
case "model_response":
|
|
306796
|
+
return {
|
|
306797
|
+
model: safeWebText(payload.model, 200),
|
|
306798
|
+
usage: sanitizeTokenUsage(payload.usage)
|
|
306799
|
+
};
|
|
306800
|
+
case "model_delta":
|
|
306801
|
+
case "thinking_delta":
|
|
306802
|
+
return { text: safeWebText(payload.text, 65536) };
|
|
306803
|
+
case "tool_proposal":
|
|
306804
|
+
return {
|
|
306805
|
+
toolCallId: safeWebText(payload.toolCallId, 200),
|
|
306806
|
+
toolName: safeWebText(payload.toolName, 200),
|
|
306807
|
+
...summarizeWebToolValue(payload.arguments) ? { detail: summarizeWebToolValue(payload.arguments) } : {},
|
|
306808
|
+
explanation: safeWebText(payload.explanation, 500)
|
|
306809
|
+
};
|
|
306810
|
+
case "tool_result":
|
|
306811
|
+
return {
|
|
306812
|
+
toolCallId: safeWebText(payload.toolCallId, 200),
|
|
306813
|
+
toolName: safeWebText(payload.toolName, 200),
|
|
306814
|
+
display: safeWebText(payload.display, 500),
|
|
306815
|
+
error: safeWebText(payload.error, 1e3)
|
|
306816
|
+
};
|
|
306817
|
+
case "tool_approval":
|
|
306818
|
+
return {
|
|
306819
|
+
toolCallId: safeWebText(payload.toolCallId, 200),
|
|
306820
|
+
approved: payload.approved === true,
|
|
306821
|
+
reason: safeWebText(payload.reason, 500)
|
|
306822
|
+
};
|
|
306823
|
+
case "web_approval_requested":
|
|
306824
|
+
return {
|
|
306825
|
+
approvalId: safeWebText(payload.approvalId, 200),
|
|
306826
|
+
kind: payload.kind === "change" || payload.kind === "action" ? payload.kind : "tool",
|
|
306827
|
+
title: safeWebText(payload.title, 200),
|
|
306828
|
+
toolCallId: safeWebText(payload.toolCallId, 200),
|
|
306829
|
+
agentId: /^agent_[a-z0-9-]+$/.test(String(payload.agentId || "")) ? safeWebText(payload.agentId, 128) : "",
|
|
306830
|
+
agentRole: safeWebText(payload.agentRole, 80)
|
|
306831
|
+
};
|
|
306832
|
+
case "web_approval_resolved":
|
|
306833
|
+
return {
|
|
306834
|
+
...["tool", "change", "action"].includes(String(payload.kind)) ? { kind: payload.kind } : {},
|
|
306835
|
+
approvalId: safeWebText(payload.approvalId, 200),
|
|
306836
|
+
approved: payload.approved === true
|
|
306837
|
+
};
|
|
306838
|
+
case "cost_update":
|
|
306839
|
+
return {
|
|
306840
|
+
turnCost: safeNumber(payload.turnCost),
|
|
306841
|
+
sessionCost: safeNumber(payload.sessionCost),
|
|
306842
|
+
costKnown: payload.costKnown !== false,
|
|
306843
|
+
totalInputTokens: safeNumber(payload.totalInputTokens),
|
|
306844
|
+
totalCacheReadTokens: safeNumber(payload.totalCacheReadTokens),
|
|
306845
|
+
totalOutputTokens: safeNumber(payload.totalOutputTokens)
|
|
306846
|
+
};
|
|
306847
|
+
case "cache_update":
|
|
306848
|
+
return {
|
|
306849
|
+
hitTokens: safeNumber(payload.hitTokens),
|
|
306850
|
+
missTokens: safeNumber(payload.missTokens),
|
|
306851
|
+
inputTokens: safeNumber(payload.inputTokens),
|
|
306852
|
+
hitRate: safeNumber(payload.hitRate),
|
|
306853
|
+
degraded: payload.degraded === true
|
|
306854
|
+
};
|
|
306855
|
+
case "agent_start": {
|
|
306856
|
+
const taskId = safeWebText(payload.taskId, 200);
|
|
306857
|
+
if (!taskId) return void 0;
|
|
306858
|
+
return {
|
|
306859
|
+
taskId,
|
|
306860
|
+
task: safeWebText(payload.task, 1e3)
|
|
306861
|
+
};
|
|
306862
|
+
}
|
|
306863
|
+
case "agent_spawn": {
|
|
306864
|
+
const childId = safeWebText(payload.childId, 200);
|
|
306865
|
+
if (!childId) return void 0;
|
|
306866
|
+
return {
|
|
306867
|
+
parentId: safeWebText(payload.parentId, 200),
|
|
306868
|
+
childId,
|
|
306869
|
+
role: safeWebText(payload.role, 100),
|
|
306870
|
+
task: safeWebText(payload.task, 1e3)
|
|
306871
|
+
};
|
|
306872
|
+
}
|
|
306873
|
+
case "agent_status": {
|
|
306874
|
+
const taskId = safeWebText(payload.taskId, 200);
|
|
306875
|
+
if (!taskId) return void 0;
|
|
306876
|
+
return {
|
|
306877
|
+
taskId,
|
|
306878
|
+
status: safeWebText(payload.status, 100),
|
|
306879
|
+
detail: safeWebText(payload.detail, 500)
|
|
306880
|
+
};
|
|
306881
|
+
}
|
|
306882
|
+
case "agent_completed": {
|
|
306883
|
+
const taskId = safeWebText(payload.taskId, 200);
|
|
306884
|
+
if (!taskId) return void 0;
|
|
306885
|
+
const status = ["completed", "failed", "aborted"].includes(
|
|
306886
|
+
String(payload.status)
|
|
306887
|
+
) ? String(payload.status) : void 0;
|
|
306888
|
+
return {
|
|
306889
|
+
taskId,
|
|
306890
|
+
success: payload.success === true,
|
|
306891
|
+
...status ? { status } : {},
|
|
306892
|
+
error: safeWebText(payload.error, 1e3)
|
|
306893
|
+
};
|
|
306894
|
+
}
|
|
306895
|
+
case "background_task_started":
|
|
306896
|
+
case "background_task_completed": {
|
|
306897
|
+
const taskId = safeWebText(payload.taskId, 200);
|
|
306898
|
+
if (!taskId) return void 0;
|
|
306899
|
+
const status = [
|
|
306900
|
+
"running",
|
|
306901
|
+
"completed",
|
|
306902
|
+
"failed",
|
|
306903
|
+
"killed",
|
|
306904
|
+
"timed_out"
|
|
306905
|
+
].includes(String(payload.status)) ? String(payload.status) : "failed";
|
|
306906
|
+
return {
|
|
306907
|
+
taskId,
|
|
306908
|
+
sessionId: safeWebText(payload.sessionId, 200),
|
|
306909
|
+
status,
|
|
306910
|
+
durationMs: safeNumber(payload.durationMs),
|
|
306911
|
+
exitCode: typeof payload.exitCode === "number" && Number.isSafeInteger(payload.exitCode) ? payload.exitCode : null,
|
|
306912
|
+
outputTruncated: payload.outputTruncated === true
|
|
306913
|
+
};
|
|
306914
|
+
}
|
|
306915
|
+
case "agent_input_queued":
|
|
306916
|
+
case "agent_input_consumed":
|
|
306917
|
+
case "agent_input_removed":
|
|
306918
|
+
case "agent_input_updated":
|
|
306919
|
+
case "agent_input_moved": {
|
|
306920
|
+
const result = {
|
|
306921
|
+
inputId: safeWebText(payload.inputId, 200),
|
|
306922
|
+
sessionId: safeWebText(payload.sessionId, 200),
|
|
306923
|
+
mode: payload.mode === "steer" ? "steer" : "follow_up",
|
|
306924
|
+
source: ["terminal", "web", "api"].includes(String(payload.source)) ? String(payload.source) : "api",
|
|
306925
|
+
remaining: safeNumber(payload.remaining)
|
|
306926
|
+
};
|
|
306927
|
+
if (type === "agent_input_moved") {
|
|
306928
|
+
result.fromIndex = safeNumber(payload.fromIndex);
|
|
306929
|
+
result.toIndex = safeNumber(payload.toIndex);
|
|
306930
|
+
}
|
|
306931
|
+
return result;
|
|
306932
|
+
}
|
|
306933
|
+
case "agent_input_queue_cleared":
|
|
306934
|
+
return {
|
|
306935
|
+
sessionId: safeWebText(payload.sessionId, 200),
|
|
306936
|
+
removed: safeNumber(payload.removed)
|
|
306937
|
+
};
|
|
306938
|
+
case "loop_start":
|
|
306939
|
+
return { attempt: safeNumber(payload.attempt) };
|
|
306940
|
+
case "verification_started":
|
|
306941
|
+
return { type: safeWebText(payload.type, 100) };
|
|
306942
|
+
case "verification_ended":
|
|
306943
|
+
return { success: payload.success === true };
|
|
306944
|
+
case "hook_started":
|
|
306945
|
+
return {
|
|
306946
|
+
hookId: safeWebText(payload.hookId, 200),
|
|
306947
|
+
event: safeWebText(payload.event, 100),
|
|
306948
|
+
legacy: payload.legacy === true
|
|
306949
|
+
};
|
|
306950
|
+
case "hook_completed":
|
|
306951
|
+
return {
|
|
306952
|
+
hookId: safeWebText(payload.hookId, 200),
|
|
306953
|
+
event: safeWebText(payload.event, 100),
|
|
306954
|
+
success: payload.success === true,
|
|
306955
|
+
durationMs: safeNumber(payload.durationMs),
|
|
306956
|
+
action: ["continue", "warn", "blocked", "ignored"].includes(
|
|
306957
|
+
String(payload.action)
|
|
306958
|
+
) ? String(payload.action) : "warn",
|
|
306959
|
+
error: safeWebText(payload.error, 1e3)
|
|
306960
|
+
};
|
|
306961
|
+
case "checkpoint_created":
|
|
306962
|
+
return {
|
|
306963
|
+
timestamp: safeWebText(payload.timestamp, 100),
|
|
306964
|
+
message: safeWebText(payload.message, 500)
|
|
306965
|
+
};
|
|
306966
|
+
case "file_change":
|
|
306967
|
+
return {
|
|
306968
|
+
filePath: safeWebText(payload.filePath, 500),
|
|
306969
|
+
type: safeWebText(payload.type, 20),
|
|
306970
|
+
explanation: safeWebText(payload.explanation, 500)
|
|
306971
|
+
};
|
|
306972
|
+
case "file_diff":
|
|
306973
|
+
return {
|
|
306974
|
+
filePath: safeWebText(payload.filePath, 500),
|
|
306975
|
+
diff: safeWebText(payload.diff, 48e3)
|
|
306976
|
+
};
|
|
306977
|
+
case "skill_activated":
|
|
306978
|
+
return {
|
|
306979
|
+
name: safeWebText(payload.name, 100),
|
|
306980
|
+
activation: payload.activation === "explicit" ? "explicit" : "auto",
|
|
306981
|
+
loadedBytes: safeNumber(payload.loadedBytes),
|
|
306982
|
+
truncated: payload.truncated === true,
|
|
306983
|
+
activationReason: [
|
|
306984
|
+
"explicit-marker",
|
|
306985
|
+
"name-match",
|
|
306986
|
+
"metadata-match"
|
|
306987
|
+
].includes(String(payload.activationReason)) ? payload.activationReason : void 0,
|
|
306988
|
+
matchedTerms: safeNumber(payload.matchedTerms),
|
|
306989
|
+
truncationReason: [
|
|
306990
|
+
"skill-size-limit",
|
|
306991
|
+
"auto-size-limit",
|
|
306992
|
+
"context-budget"
|
|
306993
|
+
].includes(String(payload.truncationReason)) ? payload.truncationReason : void 0
|
|
306994
|
+
};
|
|
306995
|
+
case "info":
|
|
306996
|
+
case "warning":
|
|
306997
|
+
case "error":
|
|
306998
|
+
return { message: safeWebText(payload.message, 2e3) };
|
|
306999
|
+
default:
|
|
307000
|
+
return void 0;
|
|
307001
|
+
}
|
|
307002
|
+
}
|
|
307003
|
+
function isAuthorizedWebRequest(req, expectedToken) {
|
|
307004
|
+
if (!expectedToken || !isRequestOriginAllowed(req)) return false;
|
|
307005
|
+
const authorization = req.headers.authorization;
|
|
307006
|
+
const cookieToken = readCookie(req, "orbit_web_token");
|
|
307007
|
+
const supplied = authorization?.startsWith("Bearer ") ? authorization.slice(7) : cookieToken;
|
|
307008
|
+
return safeTokenMatch(supplied, expectedToken);
|
|
307009
|
+
}
|
|
307010
|
+
function isBearerAuthorizedWebRequest(req, expectedToken) {
|
|
307011
|
+
if (!expectedToken || !isRequestOriginAllowed(req)) return false;
|
|
307012
|
+
const authorization = req.headers.authorization;
|
|
307013
|
+
const supplied = authorization?.startsWith("Bearer ") ? authorization.slice(7) : "";
|
|
307014
|
+
return safeTokenMatch(supplied, expectedToken);
|
|
307015
|
+
}
|
|
307016
|
+
function isAuthorizedWebEventRequest(req, expectedToken, url2) {
|
|
307017
|
+
if (!expectedToken || !isRequestOriginAllowed(req)) return false;
|
|
307018
|
+
return safeTokenMatch(
|
|
307019
|
+
url2.searchParams.get("access_token") || "",
|
|
307020
|
+
expectedToken
|
|
307021
|
+
);
|
|
307022
|
+
}
|
|
307023
|
+
function safeWebMessage(message2) {
|
|
307024
|
+
return sanitizeExternalErrorMessage(message2, { maxLength: 2e3 });
|
|
307025
|
+
}
|
|
307026
|
+
function safeWebErrorMessage(error) {
|
|
307027
|
+
if (error instanceof z68.ZodError) {
|
|
307028
|
+
const confirmation = "Full Access requires explicit confirmation.";
|
|
307029
|
+
return error.issues.some(
|
|
307030
|
+
(issue) => issue.code === "custom" && issue.message === confirmation
|
|
307031
|
+
) ? confirmation : "Invalid request parameters.";
|
|
307032
|
+
}
|
|
307033
|
+
if (error instanceof WebUiRequestError) {
|
|
307034
|
+
switch (error.code) {
|
|
307035
|
+
case "invalid_json":
|
|
307036
|
+
return "Request body must contain valid JSON.";
|
|
307037
|
+
case "request_body_too_large":
|
|
307038
|
+
return "Request body too large.";
|
|
307039
|
+
case "attachment_too_large":
|
|
307040
|
+
return "Attachment is too large.";
|
|
307041
|
+
}
|
|
307042
|
+
}
|
|
307043
|
+
return "Request failed. Check the request, project permissions, and provider settings before retrying.";
|
|
307044
|
+
}
|
|
307045
|
+
function summarizeWebToolValue(value, options = {}) {
|
|
307046
|
+
let candidate = value;
|
|
307047
|
+
if (typeof candidate === "string") {
|
|
307048
|
+
const rawText = candidate;
|
|
307049
|
+
try {
|
|
307050
|
+
candidate = JSON.parse(rawText);
|
|
307051
|
+
} catch {
|
|
307052
|
+
return options.allowPlainText ? safeWebToolText(rawText, 700) : "";
|
|
307053
|
+
}
|
|
307054
|
+
}
|
|
307055
|
+
if (!isRecord7(candidate)) return "";
|
|
307056
|
+
const safeFields = [
|
|
307057
|
+
"path",
|
|
307058
|
+
"filePath",
|
|
307059
|
+
"file",
|
|
307060
|
+
"cwd",
|
|
307061
|
+
"query",
|
|
307062
|
+
"pattern",
|
|
307063
|
+
"symbol",
|
|
307064
|
+
"url",
|
|
307065
|
+
"language",
|
|
307066
|
+
"description",
|
|
307067
|
+
"command"
|
|
307068
|
+
];
|
|
307069
|
+
const entries = [];
|
|
307070
|
+
for (const field of safeFields) {
|
|
307071
|
+
const fieldValue = candidate[field];
|
|
307072
|
+
if (typeof fieldValue !== "string" && typeof fieldValue !== "number" && typeof fieldValue !== "boolean") {
|
|
307073
|
+
continue;
|
|
307074
|
+
}
|
|
307075
|
+
const text2 = safeWebToolText(String(fieldValue), 220);
|
|
307076
|
+
if (text2) entries.push(`${field}: ${text2}`);
|
|
307077
|
+
if (entries.length >= 3) break;
|
|
307078
|
+
}
|
|
307079
|
+
return entries.join("\n");
|
|
307080
|
+
}
|
|
307081
|
+
function sanitizeActionResult(result) {
|
|
307082
|
+
return result.message ? { ok: result.ok, message: safeWebMessage(result.message) } : { ok: result.ok };
|
|
307083
|
+
}
|
|
307084
|
+
function sanitizeProjectActionResult(result) {
|
|
307085
|
+
const url2 = result.ok ? sanitizeLocalWebUiUrl(result.url) : void 0;
|
|
307086
|
+
const errorCode = !result.ok && WEB_UI_PROJECT_ERROR_CODE_SET.has(result.errorCode) ? result.errorCode : void 0;
|
|
307087
|
+
return {
|
|
307088
|
+
ok: result.ok,
|
|
307089
|
+
...result.message ? { message: safeWebMessage(result.message) } : {},
|
|
307090
|
+
...errorCode ? { errorCode } : {},
|
|
307091
|
+
...result.ok && result.path ? { path: safeWebText(result.path, 4096) } : {},
|
|
307092
|
+
...url2 ? { url: url2 } : {},
|
|
307093
|
+
...result.ok && result.cancelled ? { cancelled: true } : {}
|
|
307094
|
+
};
|
|
307095
|
+
}
|
|
307096
|
+
function sanitizeLocalWebUiUrl(value) {
|
|
307097
|
+
if (typeof value !== "string") return void 0;
|
|
307098
|
+
try {
|
|
307099
|
+
const url2 = new URL(value);
|
|
307100
|
+
const fragment = new URLSearchParams(url2.hash.slice(1));
|
|
307101
|
+
const tokens = fragment.getAll("token");
|
|
307102
|
+
const token = tokens.length === 1 ? tokens[0] : void 0;
|
|
307103
|
+
if (url2.protocol !== "http:" || !["127.0.0.1", "[::1]", "localhost"].includes(url2.hostname) || !/^\d{1,5}$/.test(url2.port) || Number(url2.port) < 1 || Number(url2.port) > 65535 || url2.username || url2.password || url2.pathname !== "/" || url2.search || Array.from(fragment.keys()).length !== 1 || !token || !/^[A-Za-z0-9_-]{32,128}$/.test(token)) {
|
|
307104
|
+
return void 0;
|
|
307105
|
+
}
|
|
307106
|
+
return url2.href;
|
|
307107
|
+
} catch {
|
|
307108
|
+
return void 0;
|
|
307109
|
+
}
|
|
307110
|
+
}
|
|
307111
|
+
function sanitizeBaseUrl(value) {
|
|
307112
|
+
if (typeof value !== "string" || !value) return "";
|
|
307113
|
+
try {
|
|
307114
|
+
const url2 = new URL(value);
|
|
307115
|
+
url2.username = "";
|
|
307116
|
+
url2.password = "";
|
|
307117
|
+
url2.search = "";
|
|
307118
|
+
url2.hash = "";
|
|
307119
|
+
return url2.toString().replace(/\/$/, "");
|
|
307120
|
+
} catch {
|
|
307121
|
+
return safeWebText(value, 500);
|
|
307122
|
+
}
|
|
307123
|
+
}
|
|
307124
|
+
function webRequestErrorStatus(error) {
|
|
307125
|
+
if (error instanceof z68.ZodError) return 400;
|
|
307126
|
+
if (error instanceof WebUiRequestError) return error.statusCode;
|
|
307127
|
+
return 500;
|
|
307128
|
+
}
|
|
307129
|
+
function isNodeError3(error) {
|
|
307130
|
+
return error instanceof Error;
|
|
307131
|
+
}
|
|
307132
|
+
function isRequestOriginAllowed(req) {
|
|
307133
|
+
const origin = req.headers.origin;
|
|
307134
|
+
return !origin || origin === `http://${req.headers.host}`;
|
|
307135
|
+
}
|
|
307136
|
+
function safeTokenMatch(supplied, expected) {
|
|
307137
|
+
const suppliedBuffer = Buffer.from(supplied);
|
|
307138
|
+
const expectedBuffer = Buffer.from(expected);
|
|
307139
|
+
return suppliedBuffer.length === expectedBuffer.length && timingSafeEqual(suppliedBuffer, expectedBuffer);
|
|
307140
|
+
}
|
|
307141
|
+
function readCookie(req, name) {
|
|
307142
|
+
const rawCookie = req.headers.cookie;
|
|
307143
|
+
if (!rawCookie) return "";
|
|
307144
|
+
for (const item of rawCookie.split(";")) {
|
|
307145
|
+
const separator = item.indexOf("=");
|
|
307146
|
+
if (separator < 0 || item.slice(0, separator).trim() !== name) continue;
|
|
307147
|
+
try {
|
|
307148
|
+
return decodeURIComponent(item.slice(separator + 1).trim());
|
|
307149
|
+
} catch {
|
|
307150
|
+
return "";
|
|
307151
|
+
}
|
|
307152
|
+
}
|
|
307153
|
+
return "";
|
|
307154
|
+
}
|
|
307155
|
+
function sanitizeTokenUsage(value) {
|
|
307156
|
+
if (!isRecord7(value)) return void 0;
|
|
307157
|
+
return {
|
|
307158
|
+
inputTokens: safeNumber(value.inputTokens),
|
|
307159
|
+
outputTokens: safeNumber(value.outputTokens),
|
|
307160
|
+
cacheReadTokens: safeNumber(value.cacheReadTokens),
|
|
307161
|
+
cacheWriteTokens: safeNumber(value.cacheWriteTokens)
|
|
307162
|
+
};
|
|
307163
|
+
}
|
|
307164
|
+
function safeNumber(value) {
|
|
307165
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
307166
|
+
}
|
|
307167
|
+
function safeWebText(value, maxLength) {
|
|
307168
|
+
if (typeof value !== "string") return "";
|
|
307169
|
+
return redactSecrets(stripAnsi2(value)).slice(0, maxLength);
|
|
307170
|
+
}
|
|
307171
|
+
function safeWebToolText(value, maxLength) {
|
|
307172
|
+
return safeWebText(value, maxLength).replace(
|
|
307173
|
+
/(--(?:api-?key|token|password|secret)(?:=|\s+))(?:"[^"]*"|'[^']*'|[^\s,;]+)/gi,
|
|
307174
|
+
"$1***REDACTED***"
|
|
307175
|
+
).replace(
|
|
307176
|
+
/((?:api[_-]?key|token|password|secret)\s*[=:]\s*)[^\s,;]+/gi,
|
|
307177
|
+
"$1***REDACTED***"
|
|
307178
|
+
).trim();
|
|
307179
|
+
}
|
|
307180
|
+
function stripAnsi2(value) {
|
|
307181
|
+
return value.replace(/\u001b\[[0-9;]*m/g, "");
|
|
307182
|
+
}
|
|
307183
|
+
function isRecord7(value) {
|
|
307184
|
+
return typeof value === "object" && value !== null;
|
|
307185
|
+
}
|
|
307186
|
+
|
|
306710
307187
|
// src/runtime/webui/WebUiClientBindings.ts
|
|
306711
307188
|
var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListener('submit', (event) => {
|
|
306712
307189
|
event.preventDefault();
|
|
@@ -307113,9 +307590,9 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
307113
307590
|
closeContextPicker({ skipRestore: true });
|
|
307114
307591
|
void updateSession({ action: 'new' });
|
|
307115
307592
|
});
|
|
307116
|
-
const closeProjectDialog = (restoreFocus = true
|
|
307593
|
+
const closeProjectDialog = (restoreFocus = true) => {
|
|
307117
307594
|
if (elements.projectDialog.hidden) return;
|
|
307118
|
-
if (state.projectLaunchPending
|
|
307595
|
+
if (state.projectLaunchPending || state.projectPickerPending) return;
|
|
307119
307596
|
elements.projectDialog.hidden = true;
|
|
307120
307597
|
elements.projectDialog.setAttribute('aria-hidden', 'true');
|
|
307121
307598
|
syncApplicationModalState();
|
|
@@ -307123,7 +307600,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
307123
307600
|
state.projectDialogReturnFocus = null;
|
|
307124
307601
|
};
|
|
307125
307602
|
const openProjectDialog = () => {
|
|
307126
|
-
if (state.busy || state.projectLaunchPending) return;
|
|
307603
|
+
if (!state.ready || state.busy || state.sessionChanging || state.projectLaunchPending || state.projectPickerPending) return;
|
|
307127
307604
|
state.projectDialogReturnFocus = document.activeElement;
|
|
307128
307605
|
elements.projectDialog.hidden = false;
|
|
307129
307606
|
elements.projectDialog.setAttribute('aria-hidden', 'false');
|
|
@@ -307131,150 +307608,54 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
307131
307608
|
elements.projectPathInput.focus();
|
|
307132
307609
|
elements.projectPathInput.select();
|
|
307133
307610
|
};
|
|
307134
|
-
|
|
307135
|
-
if (!
|
|
307136
|
-
|
|
307137
|
-
|
|
307138
|
-
const sourceStyle = getComputedStyle(document.documentElement);
|
|
307139
|
-
const themeValue = (name, fallback) =>
|
|
307140
|
-
sourceStyle.getPropertyValue(name).trim() || fallback;
|
|
307141
|
-
projectDocument.title = 'Orbit · ' + label;
|
|
307142
|
-
projectDocument.documentElement.lang = document.documentElement.lang;
|
|
307143
|
-
projectDocument.documentElement.style.colorScheme = sourceStyle.colorScheme;
|
|
307144
|
-
projectDocument.body.replaceChildren();
|
|
307145
|
-
Object.assign(projectDocument.body.style, {
|
|
307146
|
-
minHeight: '100vh',
|
|
307147
|
-
margin: '0',
|
|
307148
|
-
display: 'grid',
|
|
307149
|
-
placeItems: 'center',
|
|
307150
|
-
color: themeValue('--ink', '#2c3834'),
|
|
307151
|
-
background: themeValue('--canvas', '#f4f6f3'),
|
|
307152
|
-
fontFamily: themeValue('--font-sans', 'Inter, ui-sans-serif, system-ui, sans-serif'),
|
|
307153
|
-
});
|
|
307154
|
-
const status = projectDocument.createElement('main');
|
|
307155
|
-
status.setAttribute('role', 'status');
|
|
307156
|
-
status.dataset.orbitProjectHandoff = failed ? 'failed' : 'pending';
|
|
307157
|
-
Object.assign(status.style, {
|
|
307158
|
-
display: 'grid',
|
|
307159
|
-
gap: '10px',
|
|
307160
|
-
justifyItems: 'center',
|
|
307161
|
-
minWidth: 'min(360px, calc(100vw - 40px))',
|
|
307162
|
-
padding: '28px',
|
|
307163
|
-
textAlign: 'center',
|
|
307164
|
-
background: themeValue('--surface-raised', '#ffffff'),
|
|
307165
|
-
border: '1px solid ' + themeValue('--border', 'rgba(28, 49, 42, 0.105)'),
|
|
307166
|
-
borderRadius: themeValue('--radius-lg', '18px'),
|
|
307167
|
-
boxShadow: themeValue('--shadow-md', '0 18px 48px rgba(10, 24, 20, 0.14)'),
|
|
307168
|
-
});
|
|
307169
|
-
const brand = projectDocument.createElement('strong');
|
|
307170
|
-
brand.textContent = 'Orbit';
|
|
307171
|
-
Object.assign(brand.style, {
|
|
307172
|
-
color: themeValue('--accent-strong', '#276a5f'),
|
|
307173
|
-
fontSize: '24px',
|
|
307174
|
-
letterSpacing: '-0.02em',
|
|
307175
|
-
});
|
|
307176
|
-
const message = projectDocument.createElement('span');
|
|
307177
|
-
message.textContent = label;
|
|
307178
|
-
Object.assign(message.style, {
|
|
307179
|
-
maxWidth: '42ch',
|
|
307180
|
-
color: failed
|
|
307181
|
-
? themeValue('--danger', '#bb5755')
|
|
307182
|
-
: themeValue('--muted', '#596761'),
|
|
307183
|
-
fontSize: '14px',
|
|
307184
|
-
lineHeight: '1.55',
|
|
307185
|
-
});
|
|
307186
|
-
status.append(brand, message);
|
|
307187
|
-
projectDocument.body.append(status);
|
|
307188
|
-
} catch {
|
|
307189
|
-
// A browser may isolate the placeholder before Orbit can decorate it.
|
|
307190
|
-
}
|
|
307191
|
-
};
|
|
307192
|
-
const reserveProjectTab = (label) => {
|
|
307193
|
-
const projectTab = window.open('about:blank', '_blank');
|
|
307194
|
-
showReservedProjectStatus(projectTab, label);
|
|
307195
|
-
return projectTab;
|
|
307196
|
-
};
|
|
307197
|
-
const closeReservedProjectTab = (projectTab, message = copy.projectSwitchFailed) => {
|
|
307198
|
-
if (!projectTab || projectTab.closed) return;
|
|
307199
|
-
showReservedProjectStatus(projectTab, message, true);
|
|
307200
|
-
try {
|
|
307201
|
-
projectTab.close();
|
|
307202
|
-
} catch {
|
|
307203
|
-
// The visible failure state remains if the browser refuses window.close().
|
|
307204
|
-
}
|
|
307205
|
-
};
|
|
307206
|
-
const switchToProject = (result, projectTab) => {
|
|
307207
|
-
if (!result || typeof result.url !== 'string') {
|
|
307208
|
-
closeReservedProjectTab(projectTab);
|
|
307209
|
-
throw new Error(copy.projectSwitchFailed);
|
|
307210
|
-
}
|
|
307211
|
-
const projectUrl = new URL(result.url);
|
|
307212
|
-
const token = new URLSearchParams(projectUrl.hash.slice(1)).get('token');
|
|
307213
|
-
if (
|
|
307214
|
-
projectUrl.protocol !== 'http:' ||
|
|
307215
|
-
!['127.0.0.1', '[::1]', 'localhost'].includes(projectUrl.hostname) ||
|
|
307216
|
-
projectUrl.username ||
|
|
307217
|
-
projectUrl.password ||
|
|
307218
|
-
!token ||
|
|
307219
|
-
!/^[A-Za-z0-9_-]{32,128}$/.test(token)
|
|
307220
|
-
) {
|
|
307221
|
-
closeReservedProjectTab(projectTab);
|
|
307222
|
-
throw new Error(copy.projectSwitchFailed);
|
|
307223
|
-
}
|
|
307224
|
-
if (projectTab && !projectTab.closed) {
|
|
307225
|
-
projectTab.opener = null;
|
|
307226
|
-
projectTab.location.replace(projectUrl.href);
|
|
307227
|
-
projectTab.focus();
|
|
307228
|
-
showToast(copy.projectOpened, 'success');
|
|
307229
|
-
return;
|
|
307230
|
-
}
|
|
307231
|
-
window.location.assign(projectUrl.href);
|
|
307232
|
-
};
|
|
307233
|
-
const launchProject = async (selectedPath) => {
|
|
307234
|
-
const path = String(selectedPath || elements.projectPathInput.value).trim();
|
|
307611
|
+
async function launchProject(path, trigger) {
|
|
307612
|
+
if (!state.ready || state.busy || state.sessionChanging || state.projectLaunchPending || state.projectPickerPending) return;
|
|
307613
|
+
const fromDialog = !trigger;
|
|
307614
|
+
path = String(fromDialog ? elements.projectPathInput.value : path).trim();
|
|
307235
307615
|
if (!path) {
|
|
307236
307616
|
showToast(copy.projectPathRequired, 'error');
|
|
307237
307617
|
elements.projectPathInput.focus();
|
|
307238
307618
|
return;
|
|
307239
307619
|
}
|
|
307240
|
-
if (
|
|
307241
|
-
|
|
307242
|
-
const
|
|
307243
|
-
const
|
|
307244
|
-
const originalLabel = pendingButton.textContent;
|
|
307620
|
+
if (hasAttachmentDrafts() && !window.confirm(copy.leaveProjectImages)) return;
|
|
307621
|
+
drafts.save(elements.prompt.value);
|
|
307622
|
+
const button = trigger || elements.projectDialogCreate;
|
|
307623
|
+
const originalLabel = elements.projectDialogCreate.textContent;
|
|
307245
307624
|
state.projectLaunchPending = true;
|
|
307246
|
-
|
|
307247
|
-
|
|
307248
|
-
|
|
307249
|
-
|
|
307250
|
-
|
|
307251
|
-
|
|
307252
|
-
|
|
307625
|
+
updateSendButtonState();
|
|
307626
|
+
button.setAttribute('aria-busy', 'true');
|
|
307627
|
+
if (fromDialog) {
|
|
307628
|
+
elements.projectDialog.setAttribute('aria-busy', 'true');
|
|
307629
|
+
elements.projectDialogBackdrop.disabled = elements.projectDialogCancel.disabled = true;
|
|
307630
|
+
elements.projectDialogBrowse.disabled = elements.projectDialogCreate.disabled = true;
|
|
307631
|
+
elements.projectDialogCreate.textContent = copy.projectCreating;
|
|
307632
|
+
} else {
|
|
307633
|
+
button.classList.add('is-switching');
|
|
307634
|
+
showToast(copy.projectOpening);
|
|
307635
|
+
}
|
|
307253
307636
|
try {
|
|
307254
307637
|
const result = await api('/api/project', {
|
|
307255
307638
|
method: 'POST',
|
|
307256
307639
|
headers: { 'Content-Type': 'application/json' },
|
|
307257
|
-
body: JSON.stringify({ action: 'create', path }),
|
|
307640
|
+
body: JSON.stringify({ action: fromDialog ? 'create' : 'open', path }),
|
|
307258
307641
|
});
|
|
307259
|
-
|
|
307260
|
-
|
|
307261
|
-
|
|
307262
|
-
switchToProject(result, projectTab);
|
|
307642
|
+
const url = (${sanitizeLocalWebUiUrl.toString()})(result.url);
|
|
307643
|
+
if (!url) throw new Error(copy.projectSwitchFailed);
|
|
307644
|
+
window.location.replace(url);
|
|
307263
307645
|
} catch (error) {
|
|
307264
|
-
const message = projectErrorMessage(error);
|
|
307265
|
-
closeReservedProjectTab(projectTab, message);
|
|
307266
|
-
showToast(message, 'error');
|
|
307267
|
-
} finally {
|
|
307268
307646
|
state.projectLaunchPending = false;
|
|
307269
307647
|
elements.projectDialog.removeAttribute('aria-busy');
|
|
307270
|
-
elements.projectDialogBackdrop.disabled = false;
|
|
307271
|
-
elements.
|
|
307272
|
-
|
|
307273
|
-
|
|
307274
|
-
|
|
307275
|
-
|
|
307648
|
+
elements.projectDialogBackdrop.disabled = elements.projectDialogCancel.disabled = false;
|
|
307649
|
+
elements.projectDialogBrowse.disabled = elements.projectDialogCreate.disabled = false;
|
|
307650
|
+
elements.projectDialogCreate.textContent = originalLabel;
|
|
307651
|
+
button.classList.remove('is-switching');
|
|
307652
|
+
button.removeAttribute('aria-busy');
|
|
307653
|
+
updateSendButtonState();
|
|
307654
|
+
showToast(projectErrorMessage(error), 'error');
|
|
307655
|
+
if (fromDialog) elements.projectPathInput.focus();
|
|
307656
|
+
else button.focus();
|
|
307276
307657
|
}
|
|
307277
|
-
}
|
|
307658
|
+
}
|
|
307278
307659
|
const pickProjectFolder = async () => {
|
|
307279
307660
|
if (state.busy || state.projectPickerPending) return;
|
|
307280
307661
|
state.projectPickerPending = true;
|
|
@@ -307299,7 +307680,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
307299
307680
|
elements.projectDialogBrowse.disabled = false;
|
|
307300
307681
|
elements.projectDialogBrowse.removeAttribute('aria-busy');
|
|
307301
307682
|
elements.projectDialogCreate.disabled = false;
|
|
307302
|
-
|
|
307683
|
+
updateSendButtonState();
|
|
307303
307684
|
}
|
|
307304
307685
|
};
|
|
307305
307686
|
elements.newProjectButton.addEventListener('click', openProjectDialog);
|
|
@@ -307309,7 +307690,8 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
307309
307690
|
elements.projectDialogCreate.addEventListener('click', () => void launchProject());
|
|
307310
307691
|
elements.projectList.addEventListener('click', (event) => {
|
|
307311
307692
|
const remove = event.target.closest('[data-project-action="remove"]');
|
|
307312
|
-
if (
|
|
307693
|
+
if (!state.ready || state.busy || state.projectLaunchPending || state.sessionChanging) return;
|
|
307694
|
+
if (remove) {
|
|
307313
307695
|
if (remove.dataset.confirmRemove !== 'true') {
|
|
307314
307696
|
remove.dataset.confirmRemove = 'true';
|
|
307315
307697
|
remove.title = copy.confirmRemoveProject;
|
|
@@ -307321,7 +307703,8 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
307321
307703
|
}, 3000);
|
|
307322
307704
|
return;
|
|
307323
307705
|
}
|
|
307324
|
-
state.
|
|
307706
|
+
state.projectLaunchPending = true;
|
|
307707
|
+
updateSendButtonState();
|
|
307325
307708
|
api('/api/project', {
|
|
307326
307709
|
method: 'POST',
|
|
307327
307710
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -307330,30 +307713,11 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
307330
307713
|
showToast(copy.projectRemoved, 'success');
|
|
307331
307714
|
await loadStatus();
|
|
307332
307715
|
}).catch((error) => showToast(error.message || String(error), 'error'))
|
|
307333
|
-
.finally(() => { state.
|
|
307716
|
+
.finally(() => { state.projectLaunchPending = false; updateSendButtonState(); });
|
|
307334
307717
|
return;
|
|
307335
307718
|
}
|
|
307336
307719
|
const button = event.target.closest('[data-project-path]');
|
|
307337
|
-
if (
|
|
307338
|
-
state.busy = true;
|
|
307339
|
-
const projectTab = reserveProjectTab(copy.projectOpening);
|
|
307340
|
-
button.classList.add('is-switching');
|
|
307341
|
-
button.setAttribute('aria-busy', 'true');
|
|
307342
|
-
showToast(copy.projectOpening);
|
|
307343
|
-
api('/api/project', {
|
|
307344
|
-
method: 'POST',
|
|
307345
|
-
headers: { 'Content-Type': 'application/json' },
|
|
307346
|
-
body: JSON.stringify({ action: 'open', path: button.dataset.projectPath || '' }),
|
|
307347
|
-
}).then((result) => switchToProject(result, projectTab))
|
|
307348
|
-
.catch((error) => {
|
|
307349
|
-
closeReservedProjectTab(projectTab, error.message || String(error));
|
|
307350
|
-
showToast(error.message || String(error), 'error');
|
|
307351
|
-
})
|
|
307352
|
-
.finally(() => {
|
|
307353
|
-
state.busy = false;
|
|
307354
|
-
button.classList.remove('is-switching');
|
|
307355
|
-
button.removeAttribute('aria-busy');
|
|
307356
|
-
});
|
|
307720
|
+
if (button) void launchProject(button.dataset.projectPath, button);
|
|
307357
307721
|
});
|
|
307358
307722
|
onShortcutKeydown(elements.projectPathInput, (event) => {
|
|
307359
307723
|
if (event.key === 'Enter') {
|
|
@@ -307411,7 +307775,11 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
307411
307775
|
return;
|
|
307412
307776
|
}
|
|
307413
307777
|
const button = event.target.closest('.recent-session[data-session-id]');
|
|
307414
|
-
if (!button || state.busy || button.closest('.is-archived')
|
|
307778
|
+
if (!button || state.busy || button.closest('.is-archived')) return;
|
|
307779
|
+
if (button.closest('.is-active')) {
|
|
307780
|
+
focusMessageComposer();
|
|
307781
|
+
return;
|
|
307782
|
+
}
|
|
307415
307783
|
void updateSession({ action: 'resume', sessionId: button.dataset.sessionId });
|
|
307416
307784
|
};
|
|
307417
307785
|
elements.recentSessions.addEventListener('click', handleSessionListClick);
|
|
@@ -307438,6 +307806,9 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
307438
307806
|
const expanded = elements.archiveToggle.getAttribute('aria-expanded') === 'true';
|
|
307439
307807
|
elements.archiveToggle.setAttribute('aria-expanded', expanded ? 'false' : 'true');
|
|
307440
307808
|
elements.archivedPanel.hidden = expanded;
|
|
307809
|
+
if (expanded && !elements.archivedSessions.childElementCount) {
|
|
307810
|
+
elements.archiveToggle.hidden = true; elements.projectToggle.focus();
|
|
307811
|
+
}
|
|
307441
307812
|
});
|
|
307442
307813
|
elements.sessionDeleteBackdrop.addEventListener('click', () => closeSessionDeleteDialog());
|
|
307443
307814
|
elements.sessionDeleteCancel.addEventListener('click', () => closeSessionDeleteDialog());
|
|
@@ -307530,7 +307901,9 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
307530
307901
|
first.focus();
|
|
307531
307902
|
}
|
|
307532
307903
|
});
|
|
307533
|
-
|
|
307904
|
+
byId('findConversation').addEventListener('click', (event) => openCommandPalette('navigation', event.currentTarget));
|
|
307905
|
+
elements.commandsButton.addEventListener('click', (event) => openCommandPalette(null, event.currentTarget));
|
|
307906
|
+
byId('commandPaletteClose').addEventListener('click', closeCommandPalette);
|
|
307534
307907
|
elements.commandPaletteBackdrop.addEventListener('click', closeCommandPalette);
|
|
307535
307908
|
elements.commandSearch.addEventListener('input', () => {
|
|
307536
307909
|
paletteSelection = 0;
|
|
@@ -308011,6 +308384,7 @@ function parseWebUiStreamEvent(raw) {
|
|
|
308011
308384
|
if (typeof event.kind !== "string" || ![
|
|
308012
308385
|
"system",
|
|
308013
308386
|
"heartbeat",
|
|
308387
|
+
"sessions_changed",
|
|
308014
308388
|
"replay_gap",
|
|
308015
308389
|
"turn_started",
|
|
308016
308390
|
"turn_done",
|
|
@@ -308036,7 +308410,13 @@ function parseWebUiStreamEvent(raw) {
|
|
|
308036
308410
|
}
|
|
308037
308411
|
return event;
|
|
308038
308412
|
}
|
|
308039
|
-
|
|
308413
|
+
function requiresSessionRefresh(event, activeId) {
|
|
308414
|
+
if (event.kind === "sessions_changed") return true;
|
|
308415
|
+
if (!event.sessionId || event.sessionId === activeId) return false;
|
|
308416
|
+
return event.kind === "heartbeat" || Boolean(activeId && (event.kind === "turn_started" || event.kind === "turn_done"));
|
|
308417
|
+
}
|
|
308418
|
+
var WEB_UI_CLIENT_STREAM_PARSER_SCRIPT = ` const requiresSessionRefresh = (${requiresSessionRefresh.toString()});
|
|
308419
|
+
const parseWebUiStreamEvent = (${parseWebUiStreamEvent.toString()});
|
|
308040
308420
|
|
|
308041
308421
|
`;
|
|
308042
308422
|
|
|
@@ -308778,6 +309158,9 @@ function createAttachmentController(runtime) {
|
|
|
308778
309158
|
}
|
|
308779
309159
|
group.length = 0;
|
|
308780
309160
|
}
|
|
309161
|
+
function syncAttachmentButton() {
|
|
309162
|
+
elements.attachmentButton.disabled = !state.ready || state.sessionChanging || state.projectLaunchPending || state.attachments.length >= 4 || Boolean(uploads.get(state.attachments));
|
|
309163
|
+
}
|
|
308781
309164
|
function renderAttachments() {
|
|
308782
309165
|
elements.attachmentList.replaceChildren();
|
|
308783
309166
|
elements.attachmentShelf.hidden = state.attachments.length === 0;
|
|
@@ -308787,7 +309170,6 @@ function createAttachmentController(runtime) {
|
|
|
308787
309170
|
"aria-label",
|
|
308788
309171
|
String(state.attachments.length)
|
|
308789
309172
|
);
|
|
308790
|
-
elements.attachmentButton.disabled = state.attachments.length >= 4;
|
|
308791
309173
|
for (const attachment of state.attachments) {
|
|
308792
309174
|
const card = document.createElement("div");
|
|
308793
309175
|
card.className = "attachment-card";
|
|
@@ -308824,7 +309206,7 @@ function createAttachmentController(runtime) {
|
|
|
308824
309206
|
return;
|
|
308825
309207
|
}
|
|
308826
309208
|
uploads.set(group, (uploads.get(group) ?? 0) + 1);
|
|
308827
|
-
|
|
309209
|
+
syncAttachmentButton();
|
|
308828
309210
|
try {
|
|
308829
309211
|
const result = await api(
|
|
308830
309212
|
`/api/attachment?name=${encodeURIComponent(file.name || "image")}`,
|
|
@@ -308857,11 +309239,12 @@ function createAttachmentController(runtime) {
|
|
|
308857
309239
|
);
|
|
308858
309240
|
} finally {
|
|
308859
309241
|
uploads.set(group, (uploads.get(group) ?? 1) - 1);
|
|
308860
|
-
|
|
309242
|
+
syncAttachmentButton();
|
|
308861
309243
|
elements.attachmentInput.value = "";
|
|
308862
309244
|
}
|
|
308863
309245
|
}
|
|
308864
309246
|
async function addAttachmentFiles(files) {
|
|
309247
|
+
if (!state.ready || state.projectLaunchPending || state.sessionChanging) return;
|
|
308865
309248
|
const group = state.attachments;
|
|
308866
309249
|
for (const file of Array.from(files || []).slice(
|
|
308867
309250
|
0,
|
|
@@ -308910,6 +309293,10 @@ function createAttachmentController(runtime) {
|
|
|
308910
309293
|
renderAttachments();
|
|
308911
309294
|
}
|
|
308912
309295
|
return {
|
|
309296
|
+
hasAttachmentDrafts: () => [state.attachments, ...inactive.values()].some(
|
|
309297
|
+
(group) => group.length > 0 || Boolean(uploads.get(group))
|
|
309298
|
+
),
|
|
309299
|
+
syncAttachmentButton,
|
|
308913
309300
|
switchAttachmentDraft,
|
|
308914
309301
|
discardAttachmentDraft,
|
|
308915
309302
|
renderAttachments,
|
|
@@ -308919,7 +309306,7 @@ function createAttachmentController(runtime) {
|
|
|
308919
309306
|
consumeAttachments
|
|
308920
309307
|
};
|
|
308921
309308
|
}
|
|
308922
|
-
var WEB_UI_CLIENT_ATTACHMENTS_SCRIPT = ` const { switchAttachmentDraft, discardAttachmentDraft, renderAttachments, uploadAttachment, addAttachmentFiles, removeAttachment, consumeAttachments } = (${createAttachmentController.toString()})({ copy, elements, state, api, showToast, updateSendButtonState });
|
|
309309
|
+
var WEB_UI_CLIENT_ATTACHMENTS_SCRIPT = ` const { hasAttachmentDrafts, syncAttachmentButton, switchAttachmentDraft, discardAttachmentDraft, renderAttachments, uploadAttachment, addAttachmentFiles, removeAttachment, consumeAttachments } = (${createAttachmentController.toString()})({ copy, elements, state, api, showToast, updateSendButtonState });
|
|
308923
309310
|
|
|
308924
309311
|
`;
|
|
308925
309312
|
|
|
@@ -309386,9 +309773,9 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
|
|
|
309386
309773
|
sessionArchived: '对话已归档',
|
|
309387
309774
|
sessionRestored: '对话已恢复',
|
|
309388
309775
|
sessionDeleted: '对话已删除',
|
|
309389
|
-
projectOpening: '
|
|
309390
|
-
projectCreating: '
|
|
309391
|
-
|
|
309776
|
+
projectOpening: '正在切换项目…',
|
|
309777
|
+
projectCreating: '正在打开项目…',
|
|
309778
|
+
leaveProjectImages: '此项目有未发送的图片。切换后需要重新添加。仍要切换吗?',
|
|
309392
309779
|
projectSwitchFailed: '项目已启动,但无法安全打开页面',
|
|
309393
309780
|
projectRemoved: '项目已从 Orbit 移除,磁盘文件未删除',
|
|
309394
309781
|
removeProject: '从 Orbit 移除项目',
|
|
@@ -309549,9 +309936,9 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
|
|
|
309549
309936
|
sessionArchived: 'Chat archived',
|
|
309550
309937
|
sessionRestored: 'Chat restored',
|
|
309551
309938
|
sessionDeleted: 'Chat deleted',
|
|
309552
|
-
projectOpening: '
|
|
309553
|
-
projectCreating: '
|
|
309554
|
-
|
|
309939
|
+
projectOpening: 'Switching project…',
|
|
309940
|
+
projectCreating: 'Opening project…',
|
|
309941
|
+
leaveProjectImages: 'This project has unsent images. You will need to attach them again after switching. Switch projects?',
|
|
309555
309942
|
projectSwitchFailed: 'The project started, but Orbit could not open it safely',
|
|
309556
309943
|
projectRemoved: 'Project removed from Orbit; files were not deleted',
|
|
309557
309944
|
removeProject: 'Remove project from Orbit',
|
|
@@ -309668,9 +310055,9 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
|
|
|
309668
310055
|
sessionArchived: '對話已封存',
|
|
309669
310056
|
sessionRestored: '對話已復原',
|
|
309670
310057
|
sessionDeleted: '對話已刪除',
|
|
309671
|
-
projectOpening: '
|
|
309672
|
-
projectCreating: '
|
|
309673
|
-
|
|
310058
|
+
projectOpening: '正在切換專案…',
|
|
310059
|
+
projectCreating: '正在開啟專案…',
|
|
310060
|
+
leaveProjectImages: '此專案有未傳送的圖片。切換後需要重新加入,仍要切換嗎?',
|
|
309674
310061
|
projectSwitchFailed: '專案已啟動,但無法安全開啟頁面',
|
|
309675
310062
|
projectRemoved: '專案已從 Orbit 移除,磁碟檔案未刪除',
|
|
309676
310063
|
removeProject: '從 Orbit 移除專案',
|
|
@@ -310275,6 +310662,7 @@ ${WEB_UI_CLIENT_TRANSPORT_SCRIPT}
|
|
|
310275
310662
|
}
|
|
310276
310663
|
|
|
310277
310664
|
function updateMessageNavigation() {
|
|
310665
|
+
elements.jumpEarlier.disabled = state.loadingEarlierMessages;
|
|
310278
310666
|
const overflow = elements.messageScroll.scrollHeight > elements.messageScroll.clientHeight + 8;
|
|
310279
310667
|
const awayFromTop = elements.messageScroll.scrollTop > 72;
|
|
310280
310668
|
const hasEarlierPage = state.earliestMessagePosition > 0;
|
|
@@ -310336,8 +310724,23 @@ ${WEB_UI_CLIENT_TRANSPORT_SCRIPT}
|
|
|
310336
310724
|
else elements.applyModel.removeAttribute('aria-label');
|
|
310337
310725
|
}
|
|
310338
310726
|
|
|
310727
|
+
let lastNavigationDisabled;
|
|
310728
|
+
function syncNavigationControls(refreshRows = false) {
|
|
310729
|
+
const disabled = !state.ready || state.sessionChanging || state.projectLaunchPending || state.busy;
|
|
310730
|
+
elements.newProjectButton.disabled = disabled || state.projectPickerPending;
|
|
310731
|
+
if (lastNavigationDisabled === disabled && !refreshRows) return;
|
|
310732
|
+
lastNavigationDisabled = disabled;
|
|
310733
|
+
elements.newTaskButton.disabled = disabled;
|
|
310734
|
+
for (const list of [elements.recentSessions, elements.archivedSessions, elements.projectList]) {
|
|
310735
|
+
list.querySelectorAll(disabled ? 'button:enabled' : 'button:disabled').forEach(button => { button.disabled = disabled; });
|
|
310736
|
+
}
|
|
310737
|
+
}
|
|
310738
|
+
|
|
310339
310739
|
function updateSendButtonState() {
|
|
310340
|
-
const ready = state.ready && !state.sessionChanging;
|
|
310740
|
+
const ready = state.ready && !state.sessionChanging && !state.projectLaunchPending;
|
|
310741
|
+
syncNavigationControls();
|
|
310742
|
+
elements.prompt.readOnly = state.sessionChanging || state.projectLaunchPending;
|
|
310743
|
+
syncAttachmentButton();
|
|
310341
310744
|
elements.prompt.setAttribute('aria-busy', String(!ready));
|
|
310342
310745
|
const hasPrompt = Boolean(elements.prompt.value.trim());
|
|
310343
310746
|
elements.contextPickerButton.disabled = state.busy || !ready;
|
|
@@ -310390,6 +310793,24 @@ function createHistoryController(runtime) {
|
|
|
310390
310793
|
updateMessageNavigation,
|
|
310391
310794
|
scrollToBottom
|
|
310392
310795
|
} = runtime;
|
|
310796
|
+
let generation = 0;
|
|
310797
|
+
let latest = 0;
|
|
310798
|
+
function resetConversationHistory() {
|
|
310799
|
+
generation++;
|
|
310800
|
+
state.messageCache.clear();
|
|
310801
|
+
state.messageSessionId = "";
|
|
310802
|
+
state.messageTotal = state.earliestMessagePosition = 0;
|
|
310803
|
+
state.streaming = null;
|
|
310804
|
+
state.streamingTurnId = null;
|
|
310805
|
+
state.streamingTools.clear();
|
|
310806
|
+
state.loadingEarlierMessages = false;
|
|
310807
|
+
rebuildMessageTimeline();
|
|
310808
|
+
updateMessageNavigation();
|
|
310809
|
+
}
|
|
310810
|
+
function belongsToChat(data) {
|
|
310811
|
+
const current = state.status?.session?.activeId;
|
|
310812
|
+
return !current || data.page?.sessionId === current;
|
|
310813
|
+
}
|
|
310393
310814
|
function captureMessageAnchor() {
|
|
310394
310815
|
const scrollBounds = elements.messageScroll.getBoundingClientRect();
|
|
310395
310816
|
const node = Array.from(elements.messages.children).find(
|
|
@@ -310467,6 +310888,8 @@ function createHistoryController(runtime) {
|
|
|
310467
310888
|
state.earliestMessagePosition = positions.length ? Math.min(...positions) : Math.max(0, Number(page.start) || 0);
|
|
310468
310889
|
}
|
|
310469
310890
|
async function renderMessages(options) {
|
|
310891
|
+
const request = ++latest;
|
|
310892
|
+
const current = generation;
|
|
310470
310893
|
const forceBottom = Boolean(options?.forceBottom);
|
|
310471
310894
|
const resetHistory = Boolean(options?.resetHistory);
|
|
310472
310895
|
const preservePosition = !forceBottom && !state.stickToBottom;
|
|
@@ -310474,6 +310897,7 @@ function createHistoryController(runtime) {
|
|
|
310474
310897
|
const data = await api(
|
|
310475
310898
|
"/api/messages?limit=60"
|
|
310476
310899
|
);
|
|
310900
|
+
if (current !== generation || request !== latest || !belongsToChat(data)) return;
|
|
310477
310901
|
mergeMessagePage(data, resetHistory);
|
|
310478
310902
|
rebuildMessageTimeline();
|
|
310479
310903
|
state.streaming = null;
|
|
@@ -310490,6 +310914,7 @@ function createHistoryController(runtime) {
|
|
|
310490
310914
|
if (state.loadingEarlierMessages || state.earliestMessagePosition <= 0) {
|
|
310491
310915
|
return false;
|
|
310492
310916
|
}
|
|
310917
|
+
const current = generation;
|
|
310493
310918
|
state.loadingEarlierMessages = true;
|
|
310494
310919
|
elements.jumpEarlier.disabled = true;
|
|
310495
310920
|
const anchor = captureMessageAnchor();
|
|
@@ -310497,6 +310922,7 @@ function createHistoryController(runtime) {
|
|
|
310497
310922
|
const data = await api(
|
|
310498
310923
|
"/api/messages?limit=60&before=" + encodeURIComponent(String(state.earliestMessagePosition))
|
|
310499
310924
|
);
|
|
310925
|
+
if (current !== generation || !belongsToChat(data)) return false;
|
|
310500
310926
|
mergeMessagePage(data, false);
|
|
310501
310927
|
rebuildMessageTimeline();
|
|
310502
310928
|
if (options?.revealStart) {
|
|
@@ -310508,13 +310934,15 @@ function createHistoryController(runtime) {
|
|
|
310508
310934
|
}
|
|
310509
310935
|
return true;
|
|
310510
310936
|
} finally {
|
|
310511
|
-
|
|
310512
|
-
|
|
310937
|
+
if (current === generation) {
|
|
310938
|
+
state.loadingEarlierMessages = false;
|
|
310939
|
+
updateMessageNavigation();
|
|
310940
|
+
}
|
|
310513
310941
|
}
|
|
310514
310942
|
}
|
|
310515
|
-
return { renderMessages, loadEarlierMessages };
|
|
310943
|
+
return { renderMessages, loadEarlierMessages, resetConversationHistory };
|
|
310516
310944
|
}
|
|
310517
|
-
var WEB_UI_CLIENT_HISTORY_SCRIPT = ` const { renderMessages, loadEarlierMessages } = (${createHistoryController.toString()})({ elements, state, api, createMessage, renderControlTurn, setEmptyState, updateMessageNavigation, scrollToBottom });
|
|
310945
|
+
var WEB_UI_CLIENT_HISTORY_SCRIPT = ` const { renderMessages, loadEarlierMessages, resetConversationHistory } = (${createHistoryController.toString()})({ elements, state, api, createMessage, renderControlTurn, setEmptyState, updateMessageNavigation, scrollToBottom });
|
|
310518
310946
|
|
|
310519
310947
|
`;
|
|
310520
310948
|
|
|
@@ -312050,7 +312478,54 @@ var WEB_UI_CLIENT_MISSION_CONTROL_SCRIPT = ` const { renderTaskOverview, render
|
|
|
312050
312478
|
|
|
312051
312479
|
`;
|
|
312052
312480
|
|
|
312481
|
+
// src/runtime/webui/WebUiIcon.ts
|
|
312482
|
+
function renderUiIcon(name) {
|
|
312483
|
+
const paths = {
|
|
312484
|
+
add: '<path d="M12 5v14M5 12h14" />',
|
|
312485
|
+
tasks: '<rect x="5" y="4.5" width="14" height="15" rx="2" /><path d="m8 9 1.5 1.5L12 8M13.5 10h2.5M8 14h8M8 17h5" />',
|
|
312486
|
+
diagnostics: '<path d="M4.5 12h3l1.7-4 3.1 8 1.7-4h5.5" /><path d="M6 5.5h12v13H6z" />',
|
|
312487
|
+
changes: '<path d="M5 7h14M5 12h14M5 17h14" /><path d="M8 5v4M15 10v4M11 15v4" />',
|
|
312488
|
+
context: '<path d="M7 4.5h7l3 3v12H7z" /><path d="M14 4.5v3h3M9.5 12h5M12 9.5v5" />',
|
|
312489
|
+
image: '<rect x="4.5" y="5" width="15" height="14" rx="2" /><circle cx="9" cy="9.5" r="1.5" /><path d="m6.5 17 4-4 2.5 2 2.5-3 2.5 5" />',
|
|
312490
|
+
commands: '<rect x="4.5" y="5.5" width="15" height="13" rx="2" /><path d="m8 10 2 2-2 2M12.5 14h3.5" />',
|
|
312491
|
+
menu: '<path d="M5 7h14M5 12h14M5 17h14" />',
|
|
312492
|
+
panel: '<rect x="4.5" y="5" width="15" height="14" rx="2" /><path d="M14 5v14" />',
|
|
312493
|
+
close: '<path d="m7 7 10 10M17 7 7 17" />',
|
|
312494
|
+
back: '<path d="m10 6-6 6 6 6M4 12h16" />',
|
|
312495
|
+
up: '<path d="m7 14 5-5 5 5" />',
|
|
312496
|
+
down: '<path d="m7 10 5 5 5-5" />',
|
|
312497
|
+
archive: '<path d="M5.5 8.5h13v10h-13zM4.5 5h15v3.5h-15zM9.5 12h5" />',
|
|
312498
|
+
restore: '<path d="M8 8H4V4M4.5 8a8 8 0 1 1-.2 7" />',
|
|
312499
|
+
delete: '<path d="M8 7v11M12 7v11M16 7v11M5 5h14M9 5V3h6v2M6.5 5l1 16h9l1-16" />',
|
|
312500
|
+
search: '<circle cx="10.5" cy="10.5" r="5.5" /><path d="m14.7 14.7 4.3 4.3" />',
|
|
312501
|
+
chat: '<path d="M5 4.5h14a1.5 1.5 0 0 1 1.5 1.5v9a1.5 1.5 0 0 1-1.5 1.5h-8L5 20v-3.5A1.5 1.5 0 0 1 3.5 15V6A1.5 1.5 0 0 1 5 4.5Z" />',
|
|
312502
|
+
folder: '<path d="M3.5 7V6a1 1 0 0 1 1-1H10l2 2h7.5a1 1 0 0 1 1 1v9a1.5 1.5 0 0 1-1.5 1.5H5A1.5 1.5 0 0 1 3.5 17V7z" />',
|
|
312503
|
+
review: '<circle cx="10.5" cy="10.5" r="5.5" /><path d="m14.7 14.7 4.3 4.3M10.5 8v5M8 10.5h5" />',
|
|
312504
|
+
fix: '<path d="M14.5 5.5a4 4 0 0 0-4.8 5.2L5 15.4 8.6 19l4.7-4.7a4 4 0 0 0 5.2-4.8l-2.7 2.7-3-3z" />',
|
|
312505
|
+
explain: '<path d="m9 7-5 5 5 5M15 7l5 5-5 5M13 5l-2 14" />',
|
|
312506
|
+
improve: '<path d="M12 4l1.2 4.1L17 10l-3.8 1.9L12 16l-1.2-4.1L7 10l3.8-1.9zM18 16v4M16 18h4M5 4v3M3.5 5.5h3" />'
|
|
312507
|
+
};
|
|
312508
|
+
return `<svg class="ui-icon" viewBox="0 0 24 24" fill="none" aria-hidden="true" focusable="false">${paths[name]}</svg>`;
|
|
312509
|
+
}
|
|
312510
|
+
|
|
312053
312511
|
// src/runtime/webui/WebUiClientPalette.ts
|
|
312512
|
+
function renderCommandPaletteMarkup(copy) {
|
|
312513
|
+
return `<div class="command-palette" id="commandPalette" aria-hidden="true" hidden>
|
|
312514
|
+
<button class="command-palette-backdrop" id="commandPaletteBackdrop" type="button" aria-label="${copy.close}" tabindex="-1"></button>
|
|
312515
|
+
<section class="command-palette-dialog" role="dialog" aria-modal="true" aria-labelledby="commandPaletteTitle">
|
|
312516
|
+
<h2 class="sr-only" id="commandPaletteTitle">${copy.commands}</h2>
|
|
312517
|
+
<div class="command-search">
|
|
312518
|
+
<span aria-hidden="true" class="command-search-glyph">\u2318</span>
|
|
312519
|
+
<span aria-hidden="true" class="command-search-lens">${renderUiIcon("search")}</span>
|
|
312520
|
+
<input id="commandSearch" type="search" aria-label="${copy.commandSearch}" aria-controls="commandResults" aria-autocomplete="list" autocomplete="off" spellcheck="false" placeholder="${copy.commandSearch}" />
|
|
312521
|
+
<button id="commandPaletteClose" class="icon-button" type="button" aria-label="${copy.close}">${renderUiIcon("close")}</button>
|
|
312522
|
+
</div>
|
|
312523
|
+
<div class="command-results" id="commandResults" role="listbox"></div>
|
|
312524
|
+
<p class="command-empty" id="commandEmpty" data-default="${copy.noCommands}" hidden>${copy.noCommands}</p>
|
|
312525
|
+
<footer class="command-palette-footer">${copy.commandHint}</footer>
|
|
312526
|
+
</section>
|
|
312527
|
+
</div>`;
|
|
312528
|
+
}
|
|
312054
312529
|
function paletteMatches(action, query) {
|
|
312055
312530
|
if (!query) return true;
|
|
312056
312531
|
const haystack = (action.label + " " + action.detail + " " + action.keywords).toLocaleLowerCase();
|
|
@@ -312060,8 +312535,12 @@ var WEB_UI_CLIENT_PALETTE_SCRIPT = String.raw` const paletteMatches = ${palette
|
|
|
312060
312535
|
let paletteActions = [];
|
|
312061
312536
|
let paletteSelection = 0;
|
|
312062
312537
|
let paletteReturnFocus = null;
|
|
312538
|
+
let navigationPalette = false;
|
|
312539
|
+
const commandSearchLabel = elements.commandSearch.placeholder;
|
|
312540
|
+
const commandDialogLabel = byId('commandPaletteTitle').textContent;
|
|
312063
312541
|
|
|
312064
312542
|
function focusMessageComposer() {
|
|
312543
|
+
closeSidebar();
|
|
312065
312544
|
if (elements.inspector.classList.contains('is-open')) setInspector(false);
|
|
312066
312545
|
showConversation();
|
|
312067
312546
|
elements.prompt.focus();
|
|
@@ -312102,16 +312581,25 @@ var WEB_UI_CLIENT_PALETTE_SCRIPT = String.raw` const paletteMatches = ${palette
|
|
|
312102
312581
|
});
|
|
312103
312582
|
}
|
|
312104
312583
|
const status = state.status || {};
|
|
312584
|
+
for (const button of elements.projectList.querySelectorAll('[data-project-path]')) {
|
|
312585
|
+
actions.push({
|
|
312586
|
+
navigation: 'project', icon: '▱', label: button.querySelector('strong').textContent, detail: button.title,
|
|
312587
|
+
keywords: 'project workspace folder 项目 專案 ' + button.dataset.projectPath,
|
|
312588
|
+
idle: true, run: () => button.click(),
|
|
312589
|
+
});
|
|
312590
|
+
}
|
|
312105
312591
|
const session = status.session || {};
|
|
312106
312592
|
for (const item of session.recent || []) {
|
|
312107
|
-
if (item.active) continue;
|
|
312593
|
+
if (item.active && !navigationPalette) continue;
|
|
312108
312594
|
actions.push({
|
|
312109
|
-
icon: '○',
|
|
312595
|
+
navigation: 'chat', current: item.active, icon: '○',
|
|
312110
312596
|
label: item.title || copy.untitledTask,
|
|
312111
|
-
detail:
|
|
312597
|
+
detail: navigationPalette
|
|
312598
|
+
? [item.active ? stageCopy('Current chat', '当前聊天', '目前對話') : '', item.model, relativeSessionTime(item.updatedAt)].filter(Boolean).join(' · ')
|
|
312599
|
+
: copy.recentSession + ' · ' + workspaceName(status.workspace),
|
|
312112
312600
|
keywords: 'session recent history ' + item.id + ' ' + (item.model || ''),
|
|
312113
312601
|
idle: true,
|
|
312114
|
-
run: () => updateSession({ action: 'resume', sessionId: item.id }),
|
|
312602
|
+
run: () => item.active ? focusMessageComposer() : updateSession({ action: 'resume', sessionId: item.id }),
|
|
312115
312603
|
});
|
|
312116
312604
|
}
|
|
312117
312605
|
for (const model of status.modelOptions || []) {
|
|
@@ -312141,10 +312629,25 @@ var WEB_UI_CLIENT_PALETTE_SCRIPT = String.raw` const paletteMatches = ${palette
|
|
|
312141
312629
|
|
|
312142
312630
|
function renderCommandPalette() {
|
|
312143
312631
|
const query = elements.commandSearch.value.trim().toLocaleLowerCase();
|
|
312144
|
-
paletteActions = buildPaletteActions().filter((action) => paletteMatches(action, query));
|
|
312632
|
+
paletteActions = buildPaletteActions().filter((action) => (!navigationPalette || action.navigation) && paletteMatches(action, query));
|
|
312145
312633
|
paletteSelection = Math.max(0, Math.min(paletteSelection, paletteActions.length - 1));
|
|
312146
312634
|
elements.commandResults.replaceChildren();
|
|
312635
|
+
let container = elements.commandResults, groupKind;
|
|
312147
312636
|
paletteActions.forEach((action, index) => {
|
|
312637
|
+
if (navigationPalette && groupKind !== action.navigation) {
|
|
312638
|
+
groupKind = action.navigation;
|
|
312639
|
+
container = document.createElement('div');
|
|
312640
|
+
container.className = 'navigation-results-group';
|
|
312641
|
+
container.setAttribute('role', 'group');
|
|
312642
|
+
const heading = document.createElement('div');
|
|
312643
|
+
heading.className = 'navigation-results-heading';
|
|
312644
|
+
heading.id = 'navigation-' + groupKind;
|
|
312645
|
+
heading.textContent = groupKind === 'project' ? stageCopy('Projects', '项目', '專案')
|
|
312646
|
+
: stageCopy('Chats', '聊天', '對話') + ' · ' + workspaceName(state.status?.workspace);
|
|
312647
|
+
container.setAttribute('aria-labelledby', heading.id);
|
|
312648
|
+
container.append(heading);
|
|
312649
|
+
elements.commandResults.append(container);
|
|
312650
|
+
}
|
|
312148
312651
|
const button = document.createElement('button');
|
|
312149
312652
|
button.type = 'button';
|
|
312150
312653
|
button.id = 'command-result-' + index;
|
|
@@ -312154,7 +312657,10 @@ var WEB_UI_CLIENT_PALETTE_SCRIPT = String.raw` const paletteMatches = ${palette
|
|
|
312154
312657
|
button.disabled = Boolean(action.idle && state.busy);
|
|
312155
312658
|
const icon = document.createElement('span');
|
|
312156
312659
|
icon.className = 'command-result-icon';
|
|
312157
|
-
|
|
312660
|
+
if (action.navigation) {
|
|
312661
|
+
icon.innerHTML = action.navigation === 'project' ? '${renderUiIcon("folder")}' : '${renderUiIcon("chat")}';
|
|
312662
|
+
if (action.current) button.setAttribute('aria-current', 'page');
|
|
312663
|
+
} else icon.textContent = action.icon;
|
|
312158
312664
|
const body = document.createElement('span');
|
|
312159
312665
|
body.className = 'command-result-copy';
|
|
312160
312666
|
const label = document.createElement('strong');
|
|
@@ -312168,7 +312674,7 @@ var WEB_UI_CLIENT_PALETTE_SCRIPT = String.raw` const paletteMatches = ${palette
|
|
|
312168
312674
|
syncPaletteSelection();
|
|
312169
312675
|
});
|
|
312170
312676
|
button.addEventListener('click', () => executePaletteAction(index));
|
|
312171
|
-
|
|
312677
|
+
container.append(button);
|
|
312172
312678
|
});
|
|
312173
312679
|
elements.commandEmpty.hidden = paletteActions.length !== 0;
|
|
312174
312680
|
syncPaletteSelection();
|
|
@@ -312187,9 +312693,16 @@ var WEB_UI_CLIENT_PALETTE_SCRIPT = String.raw` const paletteMatches = ${palette
|
|
|
312187
312693
|
else elements.commandSearch.removeAttribute('aria-activedescendant');
|
|
312188
312694
|
}
|
|
312189
312695
|
|
|
312190
|
-
function openCommandPalette() {
|
|
312696
|
+
function openCommandPalette(mode, trigger) {
|
|
312191
312697
|
if (!elements.commandPalette.hidden) return;
|
|
312192
|
-
|
|
312698
|
+
navigationPalette = mode === 'navigation';
|
|
312699
|
+
const label = navigationPalette ? byId('findConversation').title : commandSearchLabel;
|
|
312700
|
+
elements.commandPalette.classList.toggle('is-navigation', navigationPalette);
|
|
312701
|
+
elements.commandEmpty.textContent = navigationPalette ? stageCopy('No matching projects or chats', '没有匹配的项目或聊天', '沒有相符的專案或對話') : elements.commandEmpty.dataset.default;
|
|
312702
|
+
elements.commandSearch.placeholder = label;
|
|
312703
|
+
elements.commandSearch.setAttribute('aria-label', label);
|
|
312704
|
+
byId('commandPaletteTitle').textContent = navigationPalette ? label : commandDialogLabel;
|
|
312705
|
+
paletteReturnFocus = trigger || document.activeElement;
|
|
312193
312706
|
elements.commandPalette.hidden = false;
|
|
312194
312707
|
elements.commandPalette.setAttribute('aria-hidden', 'false');
|
|
312195
312708
|
syncApplicationModalState();
|
|
@@ -312958,23 +313471,6 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
312958
313471
|
return language !== 'en' ? days + ' 天' : days + 'd';
|
|
312959
313472
|
}
|
|
312960
313473
|
|
|
312961
|
-
function appendSessionActionIcon(button, action) {
|
|
312962
|
-
const namespace = 'http://www.w3.org/2000/svg';
|
|
312963
|
-
const svg = document.createElementNS(namespace, 'svg');
|
|
312964
|
-
svg.setAttribute('class', 'ui-icon');
|
|
312965
|
-
svg.setAttribute('viewBox', '0 0 24 24');
|
|
312966
|
-
svg.setAttribute('fill', 'none');
|
|
312967
|
-
svg.setAttribute('aria-hidden', 'true');
|
|
312968
|
-
const path = document.createElementNS(namespace, 'path');
|
|
312969
|
-
path.setAttribute('d', {
|
|
312970
|
-
archive: 'M5.5 8.5h13v10h-13zM4.5 5h15v3.5h-15zM9.5 12h5',
|
|
312971
|
-
restore: 'M8 8H4V4M4.5 8a8 8 0 1 1-.2 7',
|
|
312972
|
-
delete: 'M8 7v11M12 7v11M16 7v11M5 5h14M9 5V3h6v2M6.5 5l1 16h9l1-16',
|
|
312973
|
-
}[action] || 'M6 12h12');
|
|
312974
|
-
svg.append(path);
|
|
312975
|
-
button.append(svg);
|
|
312976
|
-
}
|
|
312977
|
-
|
|
312978
313474
|
function renderSessionNavigation(sessionData) {
|
|
312979
313475
|
state.sessionData = sessionData || {};
|
|
312980
313476
|
const sessions = Array.isArray(sessionData && sessionData.recent)
|
|
@@ -313015,7 +313511,9 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
313015
313511
|
button.title = title.textContent;
|
|
313016
313512
|
const meta = document.createElement('span');
|
|
313017
313513
|
meta.className = 'recent-session-meta';
|
|
313018
|
-
meta.textContent =
|
|
313514
|
+
meta.textContent = relativeSessionTime(session.updatedAt);
|
|
313515
|
+
meta.title = [meta.textContent, session.model].filter(Boolean).join(' · ');
|
|
313516
|
+
button.setAttribute('aria-description', [meta.textContent, session.model].filter(Boolean).join(' · '));
|
|
313019
313517
|
button.append(title, meta);
|
|
313020
313518
|
row.append(button);
|
|
313021
313519
|
if (!isActive) {
|
|
@@ -313026,7 +313524,7 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
313026
313524
|
secondaryAction.className = 'session-action';
|
|
313027
313525
|
secondaryAction.dataset.sessionAction = archived ? 'restore' : 'archive';
|
|
313028
313526
|
secondaryAction.dataset.sessionId = session.id;
|
|
313029
|
-
|
|
313527
|
+
secondaryAction.innerHTML = archived ? '${renderUiIcon("restore")}' : '${renderUiIcon("archive")}';
|
|
313030
313528
|
secondaryAction.title = archived ? copy.restoreSession : copy.archiveSession;
|
|
313031
313529
|
secondaryAction.setAttribute('aria-label', secondaryAction.title);
|
|
313032
313530
|
const deleteAction = document.createElement('button');
|
|
@@ -313034,7 +313532,7 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
313034
313532
|
deleteAction.className = 'session-action is-danger';
|
|
313035
313533
|
deleteAction.dataset.sessionAction = 'delete';
|
|
313036
313534
|
deleteAction.dataset.sessionId = session.id;
|
|
313037
|
-
|
|
313535
|
+
deleteAction.innerHTML = '${renderUiIcon("delete")}';
|
|
313038
313536
|
deleteAction.title = copy.deleteSession;
|
|
313039
313537
|
deleteAction.setAttribute('aria-label', copy.deleteSession);
|
|
313040
313538
|
actions.append(secondaryAction, deleteAction);
|
|
@@ -313045,13 +313543,13 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
313045
313543
|
);
|
|
313046
313544
|
renderList(elements.recentSessions, visibleSessions, false);
|
|
313047
313545
|
renderList(elements.archivedSessions, archivedSessions, true);
|
|
313048
|
-
elements.sessionSearchField.hidden = sessions.length < 12;
|
|
313546
|
+
elements.sessionSearchField.hidden = sessions.length < 12 && !query;
|
|
313049
313547
|
elements.sessionShowMore.hidden = visibleSessions.length >= matchingSessions.length;
|
|
313050
313548
|
elements.recentEmpty.textContent = query ? copy.noMatchingChats : copy.noRecentTasks;
|
|
313051
313549
|
elements.recentEmpty.hidden = matchingSessions.length > 0;
|
|
313052
313550
|
elements.archivedEmpty.hidden = elements.archivedSessions.childElementCount > 0;
|
|
313053
313551
|
elements.archiveCount.textContent = String(archivedSessions.length);
|
|
313054
|
-
elements.archiveToggle.
|
|
313552
|
+
elements.archiveToggle.hidden = archivedSessions.length === 0 && elements.archivedPanel.hidden;
|
|
313055
313553
|
const sessionCount = Number(sessionData && sessionData.count || sessions.length + archivedSessions.length);
|
|
313056
313554
|
elements.projectChatCount.textContent = String(sessionCount);
|
|
313057
313555
|
elements.projectChatCount.setAttribute('aria-label', String(sessionCount));
|
|
@@ -313061,10 +313559,13 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
313061
313559
|
function renderProjectNavigation(projects, currentWorkspace) {
|
|
313062
313560
|
const current = projectPathKey(currentWorkspace || '');
|
|
313063
313561
|
const recentProjects = (Array.isArray(projects) ? projects : [])
|
|
313064
|
-
.filter((item) => item.available === true && projectPathKey(item.path || '') !== current)
|
|
313065
|
-
|
|
313562
|
+
.filter((item) => item.available === true && projectPathKey(item.path || '') !== current);
|
|
313563
|
+
const hints = projectFolderHints([
|
|
313564
|
+
{ name: workspaceName(currentWorkspace), path: currentWorkspace || '' },
|
|
313565
|
+
...recentProjects.map(p => ({name: p.name || workspaceName(p.path), path: p.path})),
|
|
313566
|
+
]);
|
|
313066
313567
|
reconcileNavigation(elements.projectList, recentProjects, project => project.id || project.path,
|
|
313067
|
-
project => [project.name, project.path], project => {
|
|
313568
|
+
project => [project.name, project.path, hints.get(project.path)], project => {
|
|
313068
313569
|
const row = document.createElement('div');
|
|
313069
313570
|
row.className = 'registered-project';
|
|
313070
313571
|
const button = document.createElement('button');
|
|
@@ -313074,14 +313575,18 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
313074
313575
|
button.setAttribute('aria-label', (language !== 'en' ? chinese('打开项目:', '開啟專案:') : 'Open project: ') + (project.name || 'Orbit'));
|
|
313075
313576
|
const icon = document.createElement('span');
|
|
313076
313577
|
icon.className = 'registered-project-icon project-folder-icon';
|
|
313077
|
-
icon.innerHTML = '
|
|
313578
|
+
icon.innerHTML = '${renderUiIcon("folder")}';
|
|
313078
313579
|
const copyNode = document.createElement('span');
|
|
313079
313580
|
copyNode.className = 'project-copy';
|
|
313080
313581
|
const name = document.createElement('strong');
|
|
313081
|
-
name.textContent = project.name || workspaceName(project.path);
|
|
313082
|
-
|
|
313083
|
-
|
|
313084
|
-
|
|
313582
|
+
name.textContent = project.name || workspaceName(project.path);
|
|
313583
|
+
button.title = project.path || ''; button.setAttribute('aria-description', button.title);
|
|
313584
|
+
copyNode.append(name);
|
|
313585
|
+
if (hints.has(project.path)) {
|
|
313586
|
+
const path = document.createElement('small');
|
|
313587
|
+
path.textContent = hints.get(project.path);
|
|
313588
|
+
copyNode.append(path);
|
|
313589
|
+
}
|
|
313085
313590
|
button.append(icon, copyNode);
|
|
313086
313591
|
const remove = document.createElement('button');
|
|
313087
313592
|
remove.type = 'button';
|
|
@@ -313099,12 +313604,13 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
313099
313604
|
}
|
|
313100
313605
|
|
|
313101
313606
|
async function updateSession(action) {
|
|
313102
|
-
if (!state.ready || state.busy || state.sessionChanging) return;
|
|
313607
|
+
if (!state.ready || state.busy || state.sessionChanging || state.projectLaunchPending) return;
|
|
313103
313608
|
state.sessionChanging = true;
|
|
313609
|
+
const target = Array.from(elements.recentSessions.querySelectorAll('[data-session-id]'))
|
|
313610
|
+
.find(button => button.dataset.sessionId === action.sessionId && button.classList.contains('recent-session'));
|
|
313611
|
+
if (action.action === 'resume' && target) target.setAttribute('aria-busy', 'true');
|
|
313612
|
+
const navigates = action.action === 'new' || action.action === 'resume';
|
|
313104
313613
|
updateSendButtonState();
|
|
313105
|
-
elements.newTaskButton.disabled = true;
|
|
313106
|
-
elements.recentSessions.querySelectorAll('button').forEach((button) => { button.disabled = true; });
|
|
313107
|
-
elements.archivedSessions.querySelectorAll('button').forEach((button) => { button.disabled = true; });
|
|
313108
313614
|
try {
|
|
313109
313615
|
await api('/api/session', {
|
|
313110
313616
|
method: 'POST',
|
|
@@ -313116,14 +313622,8 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
313116
313622
|
drafts.write(deleted, '');
|
|
313117
313623
|
discardAttachmentDraft(deleted);
|
|
313118
313624
|
}
|
|
313119
|
-
const navigates = action.action === 'new' || action.action === 'resume';
|
|
313120
313625
|
if (navigates) {
|
|
313121
|
-
|
|
313122
|
-
state.controlTurns.clear();
|
|
313123
|
-
const [, snapshot] = await Promise.all([
|
|
313124
|
-
renderMessages({ forceBottom: true, resetHistory: true }),
|
|
313125
|
-
loadStatus(),
|
|
313126
|
-
]);
|
|
313626
|
+
const snapshot = await loadStatus();
|
|
313127
313627
|
if (!snapshot) connectEvents();
|
|
313128
313628
|
} else {
|
|
313129
313629
|
await loadStatus();
|
|
@@ -313144,11 +313644,9 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
313144
313644
|
showToast(error.message || String(error), 'error');
|
|
313145
313645
|
connectEvents();
|
|
313146
313646
|
} finally {
|
|
313647
|
+
target?.removeAttribute('aria-busy');
|
|
313147
313648
|
state.sessionChanging = false;
|
|
313148
313649
|
updateSendButtonState();
|
|
313149
|
-
elements.newTaskButton.disabled = false;
|
|
313150
|
-
elements.recentSessions.querySelectorAll('button').forEach((button) => { button.disabled = false; });
|
|
313151
|
-
elements.archivedSessions.querySelectorAll('button').forEach((button) => { button.disabled = false; });
|
|
313152
313650
|
}
|
|
313153
313651
|
}
|
|
313154
313652
|
|
|
@@ -313156,7 +313654,14 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
313156
313654
|
const epoch = state.statusEpoch, request = ++state.statusRequest;
|
|
313157
313655
|
const requestedTurn = state.activeTurnId, data = await api('/api/status');
|
|
313158
313656
|
if (epoch !== state.statusEpoch || request !== state.statusRequest) return;
|
|
313159
|
-
|
|
313657
|
+
const sessionId = data.session?.activeId || '';
|
|
313658
|
+
const previousId = state.status?.session?.activeId;
|
|
313659
|
+
if (previousId !== undefined && previousId !== sessionId) {
|
|
313660
|
+
clearActivity();
|
|
313661
|
+
state.controlTurns.clear();
|
|
313662
|
+
resetConversationHistory();
|
|
313663
|
+
}
|
|
313664
|
+
activateComposerDraft(data.workspace || '', sessionId);
|
|
313160
313665
|
state.status = data;
|
|
313161
313666
|
state.promptQueue = Array.isArray(data.inputQueue) ? data.inputQueue : [];
|
|
313162
313667
|
renderPromptQueue();
|
|
@@ -313182,10 +313687,12 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
313182
313687
|
byId('workspaceFolder').textContent = data.workspace || '';
|
|
313183
313688
|
byId('sidebarWorkspace').textContent = name;
|
|
313184
313689
|
byId('sidebarWorkspace').title = data.workspace || '';
|
|
313185
|
-
|
|
313186
|
-
byId('sidebarSession').title = data.workspace || '';
|
|
313690
|
+
elements.projectToggle.title = data.workspace || '';
|
|
313187
313691
|
renderProjectNavigation(data.projects || [], data.workspace);
|
|
313188
313692
|
renderSessionNavigation(data.session || {});
|
|
313693
|
+
syncNavigationControls(true);
|
|
313694
|
+
if (previousId !== undefined && state.messageSessionId !== sessionId) await renderMessages({ forceBottom: true, resetHistory: true });
|
|
313695
|
+
if (epoch !== state.statusEpoch || request !== state.statusRequest) return;
|
|
313189
313696
|
elements.runtimeUpdated.textContent = formatTime(data.updatedAt);
|
|
313190
313697
|
fillRuntime(data);
|
|
313191
313698
|
syncProviderOptions(data);
|
|
@@ -313543,7 +314050,7 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
313543
314050
|
|
|
313544
314051
|
async function queuePrompt(prompt, mode) {
|
|
313545
314052
|
const value = String(prompt || '').trim();
|
|
313546
|
-
if (!state.ready || state.sessionChanging || state.stopping || state.queueSubmitting || !value || state.promptQueue.length >= 12) return;
|
|
314053
|
+
if (!state.ready || state.sessionChanging || state.projectLaunchPending || state.stopping || state.queueSubmitting || !value || state.promptQueue.length >= 12) return;
|
|
313547
314054
|
const attachmentIds = state.attachments.map((attachment) => attachment.id);
|
|
313548
314055
|
const scope = drafts.active;
|
|
313549
314056
|
const attachments = state.attachments;
|
|
@@ -313555,7 +314062,7 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
313555
314062
|
await api('/api/input-queue', {
|
|
313556
314063
|
method: 'POST',
|
|
313557
314064
|
headers: { 'Content-Type': 'application/json' },
|
|
313558
|
-
body: JSON.stringify({ action: 'enqueue', prompt: value, mode: mode === 'steer' ? 'steer' : 'follow_up', attachmentIds }),
|
|
314065
|
+
body: JSON.stringify({ action: 'enqueue', prompt: value, sessionId: state.status?.session?.activeId || undefined, mode: mode === 'steer' ? 'steer' : 'follow_up', attachmentIds }),
|
|
313559
314066
|
});
|
|
313560
314067
|
consumeAttachments(attachmentIds, attachments);
|
|
313561
314068
|
if (drafts.active !== scope && scope && drafts.read(scope) === prompt) drafts.write(scope, '');
|
|
@@ -313640,12 +314147,13 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
313640
314147
|
|
|
313641
314148
|
async function submitTurn(prompt, options) {
|
|
313642
314149
|
const value = String(prompt || '').trim();
|
|
313643
|
-
if (!value || state.busy || state.sessionChanging) return;
|
|
314150
|
+
if (!value || state.busy || state.sessionChanging || state.projectLaunchPending) return;
|
|
313644
314151
|
if (!state.ready) {
|
|
313645
314152
|
showToast(copy.waitForConnection, 'warning');
|
|
313646
314153
|
elements.prompt.focus();
|
|
313647
314154
|
return;
|
|
313648
314155
|
}
|
|
314156
|
+
const sessionId = state.status?.session?.activeId || undefined;
|
|
313649
314157
|
if (state.settingsPromise) {
|
|
313650
314158
|
setBusy(true, copy.settingsSaving);
|
|
313651
314159
|
try {
|
|
@@ -313657,6 +314165,7 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
313657
314165
|
}
|
|
313658
314166
|
setBusy(false, '');
|
|
313659
314167
|
}
|
|
314168
|
+
if (sessionId !== (state.status?.session?.activeId || undefined)) return;
|
|
313660
314169
|
closeContextPicker({ skipRestore: true });
|
|
313661
314170
|
closeSlashCommands();
|
|
313662
314171
|
const turnId = crypto.randomUUID ? crypto.randomUUID() : String(Date.now()) + '-' + Math.random().toString(16).slice(2);
|
|
@@ -313691,7 +314200,7 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
313691
314200
|
const result = await api('/api/chat', {
|
|
313692
314201
|
method: 'POST',
|
|
313693
314202
|
headers: { 'Content-Type': 'application/json' },
|
|
313694
|
-
body: JSON.stringify({ prompt: value, turnId, attachmentIds }),
|
|
314203
|
+
body: JSON.stringify({ prompt: value, sessionId, turnId, attachmentIds }),
|
|
313695
314204
|
});
|
|
313696
314205
|
if (result.turnId) state.activeTurnId = result.turnId;
|
|
313697
314206
|
consumeAttachments(attachmentIds, attachments);
|
|
@@ -314020,7 +314529,9 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
314020
314529
|
const event = parseWebUiStreamEvent(message.data);
|
|
314021
314530
|
if (!event) return;
|
|
314022
314531
|
if (state.eventSource !== source) return;
|
|
314023
|
-
if (event
|
|
314532
|
+
if (requiresSessionRefresh(event, state.status?.session?.activeId)) {
|
|
314533
|
+
if (!state.sessionChanging) void loadStatus().catch(error => showToast(error.message, 'error'));
|
|
314534
|
+
} else if (event.kind === 'system' || event.kind === 'heartbeat') {
|
|
314024
314535
|
if (!state.ready) syncConnection();
|
|
314025
314536
|
} else if (event.kind === 'replay_gap') {
|
|
314026
314537
|
// The server retained only a bounded replay window. Reconcile the
|
|
@@ -314289,6 +314800,7 @@ var WEB_UI_CLIENT_SCRIPT = [
|
|
|
314289
314800
|
WEB_UI_CLIENT_MISSION_CONTROL_SCRIPT,
|
|
314290
314801
|
WEB_UI_CLIENT_EVENT_ROUTING_SCRIPT,
|
|
314291
314802
|
WEB_UI_CLIENT_STREAM_PARSER_SCRIPT,
|
|
314803
|
+
`const projectFolderHints = ${projectFolderHints.toString()};`,
|
|
314292
314804
|
`const projectPathKey = ${projectPathKey.toString()};`,
|
|
314293
314805
|
`const reconcileNavigation = (${createNavigationRows.toString()})();`,
|
|
314294
314806
|
WEB_UI_CLIENT_SESSION_SCRIPT,
|
|
@@ -314324,459 +314836,40 @@ var WEB_UI_FAVICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4
|
|
|
314324
314836
|
// src/runtime/webui/WebUiData.ts
|
|
314325
314837
|
import { relative as relative9 } from "path";
|
|
314326
314838
|
|
|
314327
|
-
// src/runtime/
|
|
314328
|
-
|
|
314329
|
-
|
|
314330
|
-
|
|
314331
|
-
|
|
314332
|
-
|
|
314333
|
-
constructor(code, statusCode, message2) {
|
|
314334
|
-
super(message2);
|
|
314335
|
-
this.code = code;
|
|
314336
|
-
this.statusCode = statusCode;
|
|
314337
|
-
}
|
|
314338
|
-
code;
|
|
314339
|
-
statusCode;
|
|
314340
|
-
name = "WebUiRequestError";
|
|
314341
|
-
};
|
|
314342
|
-
|
|
314343
|
-
// src/runtime/webui/WebUiContracts.ts
|
|
314344
|
-
var WEB_UI_PROJECT_ERROR_CODES = [
|
|
314345
|
-
"absolute_path_required",
|
|
314346
|
-
"filesystem_root",
|
|
314347
|
-
"entrypoint_unavailable",
|
|
314348
|
-
"project_missing",
|
|
314349
|
-
"project_not_directory",
|
|
314350
|
-
"parent_missing",
|
|
314351
|
-
"parent_not_directory",
|
|
314352
|
-
"create_failed",
|
|
314353
|
-
"launch_failed",
|
|
314354
|
-
"startup_failed",
|
|
314355
|
-
"startup_timeout"
|
|
314356
|
-
];
|
|
314357
|
-
|
|
314358
|
-
// src/runtime/webui/WebUiSecurity.ts
|
|
314359
|
-
var WEB_UI_PROJECT_ERROR_CODE_SET = new Set(
|
|
314360
|
-
WEB_UI_PROJECT_ERROR_CODES
|
|
314361
|
-
);
|
|
314362
|
-
function sanitizeWebEventPayload(type, payload) {
|
|
314363
|
-
if (!isRecord7(payload)) return void 0;
|
|
314364
|
-
switch (type) {
|
|
314365
|
-
case "ui_turn_started":
|
|
314366
|
-
return {
|
|
314367
|
-
turnId: safeWebText(payload.turnId, 200),
|
|
314368
|
-
source: payload.source === "terminal" ? "terminal" : "web",
|
|
314369
|
-
prompt: safeWebText(payload.prompt, 8e3)
|
|
314370
|
-
};
|
|
314371
|
-
case "ui_turn_completed":
|
|
314372
|
-
return {
|
|
314373
|
-
turnId: safeWebText(payload.turnId, 200),
|
|
314374
|
-
source: payload.source === "terminal" ? "terminal" : "web",
|
|
314375
|
-
status: payload.status === "failed" || payload.status === "aborted" ? payload.status : "completed",
|
|
314376
|
-
message: safeWebText(payload.message, 2e3)
|
|
314377
|
-
};
|
|
314378
|
-
case "model_request":
|
|
314379
|
-
return { model: safeWebText(payload.model, 200) };
|
|
314380
|
-
case "model_routing":
|
|
314381
|
-
return {
|
|
314382
|
-
model: safeWebText(payload.model, 200),
|
|
314383
|
-
lane: ["locked", "fallback", "fast", "balanced", "quality"].includes(
|
|
314384
|
-
String(payload.lane)
|
|
314385
|
-
) ? String(payload.lane) : "balanced",
|
|
314386
|
-
reason: safeWebText(payload.reason, 100),
|
|
314387
|
-
confidence: payload.confidence === "high" ? "high" : "medium"
|
|
314388
|
-
};
|
|
314389
|
-
case "model_response":
|
|
314390
|
-
return {
|
|
314391
|
-
model: safeWebText(payload.model, 200),
|
|
314392
|
-
usage: sanitizeTokenUsage(payload.usage)
|
|
314393
|
-
};
|
|
314394
|
-
case "model_delta":
|
|
314395
|
-
case "thinking_delta":
|
|
314396
|
-
return { text: safeWebText(payload.text, 65536) };
|
|
314397
|
-
case "tool_proposal":
|
|
314398
|
-
return {
|
|
314399
|
-
toolCallId: safeWebText(payload.toolCallId, 200),
|
|
314400
|
-
toolName: safeWebText(payload.toolName, 200),
|
|
314401
|
-
...summarizeWebToolValue(payload.arguments) ? { detail: summarizeWebToolValue(payload.arguments) } : {},
|
|
314402
|
-
explanation: safeWebText(payload.explanation, 500)
|
|
314403
|
-
};
|
|
314404
|
-
case "tool_result":
|
|
314405
|
-
return {
|
|
314406
|
-
toolCallId: safeWebText(payload.toolCallId, 200),
|
|
314407
|
-
toolName: safeWebText(payload.toolName, 200),
|
|
314408
|
-
display: safeWebText(payload.display, 500),
|
|
314409
|
-
error: safeWebText(payload.error, 1e3)
|
|
314410
|
-
};
|
|
314411
|
-
case "tool_approval":
|
|
314412
|
-
return {
|
|
314413
|
-
toolCallId: safeWebText(payload.toolCallId, 200),
|
|
314414
|
-
approved: payload.approved === true,
|
|
314415
|
-
reason: safeWebText(payload.reason, 500)
|
|
314416
|
-
};
|
|
314417
|
-
case "web_approval_requested":
|
|
314418
|
-
return {
|
|
314419
|
-
approvalId: safeWebText(payload.approvalId, 200),
|
|
314420
|
-
kind: payload.kind === "change" || payload.kind === "action" ? payload.kind : "tool",
|
|
314421
|
-
title: safeWebText(payload.title, 200),
|
|
314422
|
-
toolCallId: safeWebText(payload.toolCallId, 200),
|
|
314423
|
-
agentId: /^agent_[a-z0-9-]+$/.test(String(payload.agentId || "")) ? safeWebText(payload.agentId, 128) : "",
|
|
314424
|
-
agentRole: safeWebText(payload.agentRole, 80)
|
|
314425
|
-
};
|
|
314426
|
-
case "web_approval_resolved":
|
|
314427
|
-
return {
|
|
314428
|
-
...["tool", "change", "action"].includes(String(payload.kind)) ? { kind: payload.kind } : {},
|
|
314429
|
-
approvalId: safeWebText(payload.approvalId, 200),
|
|
314430
|
-
approved: payload.approved === true
|
|
314431
|
-
};
|
|
314432
|
-
case "cost_update":
|
|
314433
|
-
return {
|
|
314434
|
-
turnCost: safeNumber(payload.turnCost),
|
|
314435
|
-
sessionCost: safeNumber(payload.sessionCost),
|
|
314436
|
-
costKnown: payload.costKnown !== false,
|
|
314437
|
-
totalInputTokens: safeNumber(payload.totalInputTokens),
|
|
314438
|
-
totalCacheReadTokens: safeNumber(payload.totalCacheReadTokens),
|
|
314439
|
-
totalOutputTokens: safeNumber(payload.totalOutputTokens)
|
|
314440
|
-
};
|
|
314441
|
-
case "cache_update":
|
|
314442
|
-
return {
|
|
314443
|
-
hitTokens: safeNumber(payload.hitTokens),
|
|
314444
|
-
missTokens: safeNumber(payload.missTokens),
|
|
314445
|
-
inputTokens: safeNumber(payload.inputTokens),
|
|
314446
|
-
hitRate: safeNumber(payload.hitRate),
|
|
314447
|
-
degraded: payload.degraded === true
|
|
314448
|
-
};
|
|
314449
|
-
case "agent_start": {
|
|
314450
|
-
const taskId = safeWebText(payload.taskId, 200);
|
|
314451
|
-
if (!taskId) return void 0;
|
|
314452
|
-
return {
|
|
314453
|
-
taskId,
|
|
314454
|
-
task: safeWebText(payload.task, 1e3)
|
|
314455
|
-
};
|
|
314456
|
-
}
|
|
314457
|
-
case "agent_spawn": {
|
|
314458
|
-
const childId = safeWebText(payload.childId, 200);
|
|
314459
|
-
if (!childId) return void 0;
|
|
314460
|
-
return {
|
|
314461
|
-
parentId: safeWebText(payload.parentId, 200),
|
|
314462
|
-
childId,
|
|
314463
|
-
role: safeWebText(payload.role, 100),
|
|
314464
|
-
task: safeWebText(payload.task, 1e3)
|
|
314465
|
-
};
|
|
314466
|
-
}
|
|
314467
|
-
case "agent_status": {
|
|
314468
|
-
const taskId = safeWebText(payload.taskId, 200);
|
|
314469
|
-
if (!taskId) return void 0;
|
|
314470
|
-
return {
|
|
314471
|
-
taskId,
|
|
314472
|
-
status: safeWebText(payload.status, 100),
|
|
314473
|
-
detail: safeWebText(payload.detail, 500)
|
|
314474
|
-
};
|
|
314475
|
-
}
|
|
314476
|
-
case "agent_completed": {
|
|
314477
|
-
const taskId = safeWebText(payload.taskId, 200);
|
|
314478
|
-
if (!taskId) return void 0;
|
|
314479
|
-
const status = ["completed", "failed", "aborted"].includes(
|
|
314480
|
-
String(payload.status)
|
|
314481
|
-
) ? String(payload.status) : void 0;
|
|
314482
|
-
return {
|
|
314483
|
-
taskId,
|
|
314484
|
-
success: payload.success === true,
|
|
314485
|
-
...status ? { status } : {},
|
|
314486
|
-
error: safeWebText(payload.error, 1e3)
|
|
314487
|
-
};
|
|
314488
|
-
}
|
|
314489
|
-
case "background_task_started":
|
|
314490
|
-
case "background_task_completed": {
|
|
314491
|
-
const taskId = safeWebText(payload.taskId, 200);
|
|
314492
|
-
if (!taskId) return void 0;
|
|
314493
|
-
const status = [
|
|
314494
|
-
"running",
|
|
314495
|
-
"completed",
|
|
314496
|
-
"failed",
|
|
314497
|
-
"killed",
|
|
314498
|
-
"timed_out"
|
|
314499
|
-
].includes(String(payload.status)) ? String(payload.status) : "failed";
|
|
314500
|
-
return {
|
|
314501
|
-
taskId,
|
|
314502
|
-
sessionId: safeWebText(payload.sessionId, 200),
|
|
314503
|
-
status,
|
|
314504
|
-
durationMs: safeNumber(payload.durationMs),
|
|
314505
|
-
exitCode: typeof payload.exitCode === "number" && Number.isSafeInteger(payload.exitCode) ? payload.exitCode : null,
|
|
314506
|
-
outputTruncated: payload.outputTruncated === true
|
|
314507
|
-
};
|
|
314508
|
-
}
|
|
314509
|
-
case "agent_input_queued":
|
|
314510
|
-
case "agent_input_consumed":
|
|
314511
|
-
case "agent_input_removed":
|
|
314512
|
-
case "agent_input_updated":
|
|
314513
|
-
case "agent_input_moved": {
|
|
314514
|
-
const result = {
|
|
314515
|
-
inputId: safeWebText(payload.inputId, 200),
|
|
314516
|
-
sessionId: safeWebText(payload.sessionId, 200),
|
|
314517
|
-
mode: payload.mode === "steer" ? "steer" : "follow_up",
|
|
314518
|
-
source: ["terminal", "web", "api"].includes(String(payload.source)) ? String(payload.source) : "api",
|
|
314519
|
-
remaining: safeNumber(payload.remaining)
|
|
314520
|
-
};
|
|
314521
|
-
if (type === "agent_input_moved") {
|
|
314522
|
-
result.fromIndex = safeNumber(payload.fromIndex);
|
|
314523
|
-
result.toIndex = safeNumber(payload.toIndex);
|
|
314524
|
-
}
|
|
314525
|
-
return result;
|
|
314526
|
-
}
|
|
314527
|
-
case "agent_input_queue_cleared":
|
|
314528
|
-
return {
|
|
314529
|
-
sessionId: safeWebText(payload.sessionId, 200),
|
|
314530
|
-
removed: safeNumber(payload.removed)
|
|
314531
|
-
};
|
|
314532
|
-
case "loop_start":
|
|
314533
|
-
return { attempt: safeNumber(payload.attempt) };
|
|
314534
|
-
case "verification_started":
|
|
314535
|
-
return { type: safeWebText(payload.type, 100) };
|
|
314536
|
-
case "verification_ended":
|
|
314537
|
-
return { success: payload.success === true };
|
|
314538
|
-
case "hook_started":
|
|
314539
|
-
return {
|
|
314540
|
-
hookId: safeWebText(payload.hookId, 200),
|
|
314541
|
-
event: safeWebText(payload.event, 100),
|
|
314542
|
-
legacy: payload.legacy === true
|
|
314543
|
-
};
|
|
314544
|
-
case "hook_completed":
|
|
314545
|
-
return {
|
|
314546
|
-
hookId: safeWebText(payload.hookId, 200),
|
|
314547
|
-
event: safeWebText(payload.event, 100),
|
|
314548
|
-
success: payload.success === true,
|
|
314549
|
-
durationMs: safeNumber(payload.durationMs),
|
|
314550
|
-
action: ["continue", "warn", "blocked", "ignored"].includes(
|
|
314551
|
-
String(payload.action)
|
|
314552
|
-
) ? String(payload.action) : "warn",
|
|
314553
|
-
error: safeWebText(payload.error, 1e3)
|
|
314554
|
-
};
|
|
314555
|
-
case "checkpoint_created":
|
|
314556
|
-
return {
|
|
314557
|
-
timestamp: safeWebText(payload.timestamp, 100),
|
|
314558
|
-
message: safeWebText(payload.message, 500)
|
|
314559
|
-
};
|
|
314560
|
-
case "file_change":
|
|
314561
|
-
return {
|
|
314562
|
-
filePath: safeWebText(payload.filePath, 500),
|
|
314563
|
-
type: safeWebText(payload.type, 20),
|
|
314564
|
-
explanation: safeWebText(payload.explanation, 500)
|
|
314565
|
-
};
|
|
314566
|
-
case "file_diff":
|
|
314567
|
-
return {
|
|
314568
|
-
filePath: safeWebText(payload.filePath, 500),
|
|
314569
|
-
diff: safeWebText(payload.diff, 48e3)
|
|
314570
|
-
};
|
|
314571
|
-
case "skill_activated":
|
|
314572
|
-
return {
|
|
314573
|
-
name: safeWebText(payload.name, 100),
|
|
314574
|
-
activation: payload.activation === "explicit" ? "explicit" : "auto",
|
|
314575
|
-
loadedBytes: safeNumber(payload.loadedBytes),
|
|
314576
|
-
truncated: payload.truncated === true,
|
|
314577
|
-
activationReason: [
|
|
314578
|
-
"explicit-marker",
|
|
314579
|
-
"name-match",
|
|
314580
|
-
"metadata-match"
|
|
314581
|
-
].includes(String(payload.activationReason)) ? payload.activationReason : void 0,
|
|
314582
|
-
matchedTerms: safeNumber(payload.matchedTerms),
|
|
314583
|
-
truncationReason: [
|
|
314584
|
-
"skill-size-limit",
|
|
314585
|
-
"auto-size-limit",
|
|
314586
|
-
"context-budget"
|
|
314587
|
-
].includes(String(payload.truncationReason)) ? payload.truncationReason : void 0
|
|
314588
|
-
};
|
|
314589
|
-
case "info":
|
|
314590
|
-
case "warning":
|
|
314591
|
-
case "error":
|
|
314592
|
-
return { message: safeWebText(payload.message, 2e3) };
|
|
314593
|
-
default:
|
|
314594
|
-
return void 0;
|
|
314595
|
-
}
|
|
314596
|
-
}
|
|
314597
|
-
function isAuthorizedWebRequest(req, expectedToken) {
|
|
314598
|
-
if (!expectedToken || !isRequestOriginAllowed(req)) return false;
|
|
314599
|
-
const authorization = req.headers.authorization;
|
|
314600
|
-
const cookieToken = readCookie(req, "orbit_web_token");
|
|
314601
|
-
const supplied = authorization?.startsWith("Bearer ") ? authorization.slice(7) : cookieToken;
|
|
314602
|
-
return safeTokenMatch(supplied, expectedToken);
|
|
314603
|
-
}
|
|
314604
|
-
function isBearerAuthorizedWebRequest(req, expectedToken) {
|
|
314605
|
-
if (!expectedToken || !isRequestOriginAllowed(req)) return false;
|
|
314606
|
-
const authorization = req.headers.authorization;
|
|
314607
|
-
const supplied = authorization?.startsWith("Bearer ") ? authorization.slice(7) : "";
|
|
314608
|
-
return safeTokenMatch(supplied, expectedToken);
|
|
314839
|
+
// src/runtime/SessionTitles.ts
|
|
314840
|
+
var MAX_TITLE_CHARACTERS = 64;
|
|
314841
|
+
var MAX_LATIN_WORDS = 8;
|
|
314842
|
+
function isDefaultSessionTitle(title) {
|
|
314843
|
+
const name = title.trim();
|
|
314844
|
+
return !name || name === "New Orbit Session";
|
|
314609
314845
|
}
|
|
314610
|
-
function
|
|
314611
|
-
|
|
314612
|
-
return
|
|
314613
|
-
|
|
314614
|
-
|
|
314846
|
+
function deriveSessionTitle(prompt) {
|
|
314847
|
+
const firstMeaningfulLine = prompt.split(/\r?\n/).map((line) => line.trim()).find(Boolean);
|
|
314848
|
+
if (!firstMeaningfulLine) return "Untitled task";
|
|
314849
|
+
const safe = redactSecrets(firstMeaningfulLine).replace(/^#{1,6}\s*/, "").replace(/^[-*+>]\s*/, "").replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
|
|
314850
|
+
if (!safe) return "Untitled task";
|
|
314851
|
+
const clause = safe.split(/[。!?!?;;]|\s+[—–-]\s+/u, 1)[0]?.trim() || safe;
|
|
314852
|
+
const hasCjk = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u.test(
|
|
314853
|
+
clause
|
|
314615
314854
|
);
|
|
314855
|
+
const compact2 = hasCjk ? Array.from(clause).slice(0, 30).join("") : clause.split(/\s+/).slice(0, MAX_LATIN_WORDS).join(" ");
|
|
314856
|
+
const bounded = Array.from(compact2).slice(0, MAX_TITLE_CHARACTERS).join("").replace(/[\s,.:;!?,。!?;:]+$/u, "").trim();
|
|
314857
|
+
return bounded || "Untitled task";
|
|
314616
314858
|
}
|
|
314617
|
-
function
|
|
314618
|
-
return sanitizeExternalErrorMessage(message2, { maxLength: 2e3 });
|
|
314619
|
-
}
|
|
314620
|
-
function safeWebErrorMessage(error) {
|
|
314621
|
-
if (error instanceof z68.ZodError) {
|
|
314622
|
-
const confirmation = "Full Access requires explicit confirmation.";
|
|
314623
|
-
return error.issues.some(
|
|
314624
|
-
(issue) => issue.code === "custom" && issue.message === confirmation
|
|
314625
|
-
) ? confirmation : "Invalid request parameters.";
|
|
314626
|
-
}
|
|
314627
|
-
if (error instanceof WebUiRequestError) {
|
|
314628
|
-
switch (error.code) {
|
|
314629
|
-
case "invalid_json":
|
|
314630
|
-
return "Request body must contain valid JSON.";
|
|
314631
|
-
case "request_body_too_large":
|
|
314632
|
-
return "Request body too large.";
|
|
314633
|
-
case "attachment_too_large":
|
|
314634
|
-
return "Attachment is too large.";
|
|
314635
|
-
}
|
|
314636
|
-
}
|
|
314637
|
-
return "Request failed. Check the request, project permissions, and provider settings before retrying.";
|
|
314638
|
-
}
|
|
314639
|
-
function summarizeWebToolValue(value, options = {}) {
|
|
314640
|
-
let candidate = value;
|
|
314641
|
-
if (typeof candidate === "string") {
|
|
314642
|
-
const rawText = candidate;
|
|
314643
|
-
try {
|
|
314644
|
-
candidate = JSON.parse(rawText);
|
|
314645
|
-
} catch {
|
|
314646
|
-
return options.allowPlainText ? safeWebToolText(rawText, 700) : "";
|
|
314647
|
-
}
|
|
314648
|
-
}
|
|
314649
|
-
if (!isRecord7(candidate)) return "";
|
|
314650
|
-
const safeFields = [
|
|
314651
|
-
"path",
|
|
314652
|
-
"filePath",
|
|
314653
|
-
"file",
|
|
314654
|
-
"cwd",
|
|
314655
|
-
"query",
|
|
314656
|
-
"pattern",
|
|
314657
|
-
"symbol",
|
|
314658
|
-
"url",
|
|
314659
|
-
"language",
|
|
314660
|
-
"description",
|
|
314661
|
-
"command"
|
|
314662
|
-
];
|
|
314663
|
-
const entries = [];
|
|
314664
|
-
for (const field of safeFields) {
|
|
314665
|
-
const fieldValue = candidate[field];
|
|
314666
|
-
if (typeof fieldValue !== "string" && typeof fieldValue !== "number" && typeof fieldValue !== "boolean") {
|
|
314667
|
-
continue;
|
|
314668
|
-
}
|
|
314669
|
-
const text2 = safeWebToolText(String(fieldValue), 220);
|
|
314670
|
-
if (text2) entries.push(`${field}: ${text2}`);
|
|
314671
|
-
if (entries.length >= 3) break;
|
|
314672
|
-
}
|
|
314673
|
-
return entries.join("\n");
|
|
314674
|
-
}
|
|
314675
|
-
function sanitizeActionResult(result) {
|
|
314676
|
-
return result.message ? { ok: result.ok, message: safeWebMessage(result.message) } : { ok: result.ok };
|
|
314677
|
-
}
|
|
314678
|
-
function sanitizeProjectActionResult(result) {
|
|
314679
|
-
const url2 = result.ok ? sanitizeLocalWebUiUrl(result.url) : void 0;
|
|
314680
|
-
const errorCode = !result.ok && WEB_UI_PROJECT_ERROR_CODE_SET.has(result.errorCode) ? result.errorCode : void 0;
|
|
314681
|
-
return {
|
|
314682
|
-
ok: result.ok,
|
|
314683
|
-
...result.message ? { message: safeWebMessage(result.message) } : {},
|
|
314684
|
-
...errorCode ? { errorCode } : {},
|
|
314685
|
-
...result.ok && result.path ? { path: safeWebText(result.path, 4096) } : {},
|
|
314686
|
-
...url2 ? { url: url2 } : {},
|
|
314687
|
-
...result.ok && result.cancelled ? { cancelled: true } : {}
|
|
314688
|
-
};
|
|
314689
|
-
}
|
|
314690
|
-
function sanitizeLocalWebUiUrl(value) {
|
|
314691
|
-
if (typeof value !== "string") return void 0;
|
|
314859
|
+
function ensureSessionTitle(loop, prompt) {
|
|
314692
314860
|
try {
|
|
314693
|
-
const
|
|
314694
|
-
|
|
314695
|
-
const tokens = fragment.getAll("token");
|
|
314696
|
-
const token = tokens.length === 1 ? tokens[0] : void 0;
|
|
314697
|
-
if (url2.protocol !== "http:" || !["127.0.0.1", "[::1]", "localhost"].includes(url2.hostname) || !/^\d{1,5}$/.test(url2.port) || Number(url2.port) < 1 || Number(url2.port) > 65535 || url2.username || url2.password || url2.pathname !== "/" || url2.search || Array.from(fragment.keys()).length !== 1 || !token || !/^[A-Za-z0-9_-]{32,128}$/.test(token)) {
|
|
314861
|
+
const activeSession = loop.sessionManager?.getActiveSession();
|
|
314862
|
+
if (!activeSession || !isDefaultSessionTitle(activeSession.title)) {
|
|
314698
314863
|
return void 0;
|
|
314699
314864
|
}
|
|
314700
|
-
|
|
314865
|
+
const title = deriveSessionTitle(prompt);
|
|
314866
|
+
activeSession.title = title;
|
|
314867
|
+
loop.sessionManager.getSessionStore().updateSession(activeSession);
|
|
314868
|
+
return title;
|
|
314701
314869
|
} catch {
|
|
314702
314870
|
return void 0;
|
|
314703
314871
|
}
|
|
314704
314872
|
}
|
|
314705
|
-
function sanitizeBaseUrl(value) {
|
|
314706
|
-
if (typeof value !== "string" || !value) return "";
|
|
314707
|
-
try {
|
|
314708
|
-
const url2 = new URL(value);
|
|
314709
|
-
url2.username = "";
|
|
314710
|
-
url2.password = "";
|
|
314711
|
-
url2.search = "";
|
|
314712
|
-
url2.hash = "";
|
|
314713
|
-
return url2.toString().replace(/\/$/, "");
|
|
314714
|
-
} catch {
|
|
314715
|
-
return safeWebText(value, 500);
|
|
314716
|
-
}
|
|
314717
|
-
}
|
|
314718
|
-
function webRequestErrorStatus(error) {
|
|
314719
|
-
if (error instanceof z68.ZodError) return 400;
|
|
314720
|
-
if (error instanceof WebUiRequestError) return error.statusCode;
|
|
314721
|
-
return 500;
|
|
314722
|
-
}
|
|
314723
|
-
function isNodeError3(error) {
|
|
314724
|
-
return error instanceof Error;
|
|
314725
|
-
}
|
|
314726
|
-
function isRequestOriginAllowed(req) {
|
|
314727
|
-
const origin = req.headers.origin;
|
|
314728
|
-
return !origin || origin === `http://${req.headers.host}`;
|
|
314729
|
-
}
|
|
314730
|
-
function safeTokenMatch(supplied, expected) {
|
|
314731
|
-
const suppliedBuffer = Buffer.from(supplied);
|
|
314732
|
-
const expectedBuffer = Buffer.from(expected);
|
|
314733
|
-
return suppliedBuffer.length === expectedBuffer.length && timingSafeEqual(suppliedBuffer, expectedBuffer);
|
|
314734
|
-
}
|
|
314735
|
-
function readCookie(req, name) {
|
|
314736
|
-
const rawCookie = req.headers.cookie;
|
|
314737
|
-
if (!rawCookie) return "";
|
|
314738
|
-
for (const item of rawCookie.split(";")) {
|
|
314739
|
-
const separator = item.indexOf("=");
|
|
314740
|
-
if (separator < 0 || item.slice(0, separator).trim() !== name) continue;
|
|
314741
|
-
try {
|
|
314742
|
-
return decodeURIComponent(item.slice(separator + 1).trim());
|
|
314743
|
-
} catch {
|
|
314744
|
-
return "";
|
|
314745
|
-
}
|
|
314746
|
-
}
|
|
314747
|
-
return "";
|
|
314748
|
-
}
|
|
314749
|
-
function sanitizeTokenUsage(value) {
|
|
314750
|
-
if (!isRecord7(value)) return void 0;
|
|
314751
|
-
return {
|
|
314752
|
-
inputTokens: safeNumber(value.inputTokens),
|
|
314753
|
-
outputTokens: safeNumber(value.outputTokens),
|
|
314754
|
-
cacheReadTokens: safeNumber(value.cacheReadTokens),
|
|
314755
|
-
cacheWriteTokens: safeNumber(value.cacheWriteTokens)
|
|
314756
|
-
};
|
|
314757
|
-
}
|
|
314758
|
-
function safeNumber(value) {
|
|
314759
|
-
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
314760
|
-
}
|
|
314761
|
-
function safeWebText(value, maxLength) {
|
|
314762
|
-
if (typeof value !== "string") return "";
|
|
314763
|
-
return redactSecrets(stripAnsi2(value)).slice(0, maxLength);
|
|
314764
|
-
}
|
|
314765
|
-
function safeWebToolText(value, maxLength) {
|
|
314766
|
-
return safeWebText(value, maxLength).replace(
|
|
314767
|
-
/(--(?:api-?key|token|password|secret)(?:=|\s+))(?:"[^"]*"|'[^']*'|[^\s,;]+)/gi,
|
|
314768
|
-
"$1***REDACTED***"
|
|
314769
|
-
).replace(
|
|
314770
|
-
/((?:api[_-]?key|token|password|secret)\s*[=:]\s*)[^\s,;]+/gi,
|
|
314771
|
-
"$1***REDACTED***"
|
|
314772
|
-
).trim();
|
|
314773
|
-
}
|
|
314774
|
-
function stripAnsi2(value) {
|
|
314775
|
-
return value.replace(/\u001b\[[0-9;]*m/g, "");
|
|
314776
|
-
}
|
|
314777
|
-
function isRecord7(value) {
|
|
314778
|
-
return typeof value === "object" && value !== null;
|
|
314779
|
-
}
|
|
314780
314873
|
|
|
314781
314874
|
// src/runtime/webui/WebUiAgentData.ts
|
|
314782
314875
|
function summarizeWebUiAgentRuns(value) {
|
|
@@ -314934,14 +315027,14 @@ function collectWebUiStatus(options, activeTurn) {
|
|
|
314934
315027
|
safeCall(() => options.getPendingApproval?.())
|
|
314935
315028
|
);
|
|
314936
315029
|
const contextFiles = summarizeWebUiContextFiles(relevantFiles);
|
|
314937
|
-
const normalizedSessions = normalizeSessions(sessions, sessionId);
|
|
315030
|
+
const normalizedSessions = normalizeSessions(sessions, sessionId, config.language);
|
|
314938
315031
|
const recentSessions = normalizedSessions.filter(
|
|
314939
315032
|
(session) => session.active || !session.archived
|
|
314940
315033
|
);
|
|
314941
315034
|
const archivedSessions = normalizedSessions.filter(
|
|
314942
315035
|
(session) => !session.active && session.archived
|
|
314943
315036
|
);
|
|
314944
|
-
const projects = (safeCall(() => options.getProjects?.()) || []).filter((project) => project && typeof project.path === "string").slice(0,
|
|
315037
|
+
const projects = (safeCall(() => options.getProjects?.()) || []).filter((project) => project && typeof project.path === "string").slice(0, 200).map((project) => ({
|
|
314945
315038
|
id: String(project.id || "").slice(0, 64),
|
|
314946
315039
|
path: redactSecrets(project.path).slice(0, 4096),
|
|
314947
315040
|
name: redactSecrets(project.name || "Orbit").slice(0, 200),
|
|
@@ -315239,17 +315332,41 @@ function safeApprovalText(value, maxLength, preserveLines) {
|
|
|
315239
315332
|
);
|
|
315240
315333
|
return (preserveLines ? safe : safe.replace(/\s+/g, " ")).trim().slice(0, maxLength);
|
|
315241
315334
|
}
|
|
315242
|
-
function normalizeSessions(sessions, activeId) {
|
|
315335
|
+
function normalizeSessions(sessions, activeId, language) {
|
|
315243
315336
|
if (!Array.isArray(sessions)) return [];
|
|
315244
|
-
|
|
315245
|
-
|
|
315246
|
-
|
|
315337
|
+
const records = sessions.filter(isRecord9).filter((s) => typeof s.id === "string" && s.id);
|
|
315338
|
+
const labels = /* @__PURE__ */ new Map();
|
|
315339
|
+
const unnamed = records.filter((session) => {
|
|
315340
|
+
const title = typeof session.title === "string" ? session.title.trim() : "";
|
|
315341
|
+
if (isDefaultSessionTitle(title)) return true;
|
|
315342
|
+
labels.set(session.id, redactSecrets(title).slice(0, 160));
|
|
315343
|
+
return false;
|
|
315344
|
+
});
|
|
315345
|
+
const creationTime = (session) => typeof session.createdAt === "string" ? Date.parse(session.createdAt) || 0 : 0;
|
|
315346
|
+
unnamed.sort(
|
|
315347
|
+
(a2, b) => creationTime(a2) - creationTime(b) || String(a2.id).localeCompare(String(b.id))
|
|
315348
|
+
);
|
|
315349
|
+
const base = { en: "Untitled chat", zh: "\u672A\u547D\u540D\u5BF9\u8BDD", "zh-TW": "\u672A\u547D\u540D\u5C0D\u8A71" }[language];
|
|
315350
|
+
const taken = new Set(labels.values());
|
|
315351
|
+
let ordinal = 0;
|
|
315352
|
+
for (const session of unnamed) {
|
|
315353
|
+
let label = base;
|
|
315354
|
+
if (unnamed.length > 1 || taken.has(base)) {
|
|
315355
|
+
do {
|
|
315356
|
+
label = base + " " + ++ordinal;
|
|
315357
|
+
} while (taken.has(label));
|
|
315358
|
+
}
|
|
315359
|
+
labels.set(session.id, label);
|
|
315360
|
+
}
|
|
315361
|
+
return records.map((session) => ({
|
|
315362
|
+
id: String(session.id),
|
|
315363
|
+
title: labels.get(session.id),
|
|
315247
315364
|
model: typeof session.model === "string" ? session.model : "",
|
|
315248
315365
|
updatedAt: typeof session.updatedAt === "string" ? session.updatedAt : typeof session.createdAt === "string" ? session.createdAt : "",
|
|
315249
315366
|
active: session.id === activeId,
|
|
315250
315367
|
archived: typeof session.archivedAt === "string",
|
|
315251
315368
|
archivedAt: typeof session.archivedAt === "string" ? session.archivedAt : ""
|
|
315252
|
-
})).
|
|
315369
|
+
})).sort((left, right) => {
|
|
315253
315370
|
if (left.active !== right.active) return left.active ? -1 : 1;
|
|
315254
315371
|
return Date.parse(right.updatedAt) - Date.parse(left.updatedAt);
|
|
315255
315372
|
});
|
|
@@ -315659,6 +315776,24 @@ async function readBinaryBody(req, limitBytes) {
|
|
|
315659
315776
|
}
|
|
315660
315777
|
return Buffer.concat(chunks);
|
|
315661
315778
|
}
|
|
315779
|
+
function listenOnLoopback(server2, port) {
|
|
315780
|
+
return new Promise((resolveListen, reject) => {
|
|
315781
|
+
const onError = (error) => {
|
|
315782
|
+
server2.off("listening", onListening);
|
|
315783
|
+
reject(error);
|
|
315784
|
+
};
|
|
315785
|
+
const onListening = () => {
|
|
315786
|
+
server2.off("error", onError);
|
|
315787
|
+
const address = server2.address();
|
|
315788
|
+
resolveListen(
|
|
315789
|
+
typeof address === "object" && address ? address.port : port
|
|
315790
|
+
);
|
|
315791
|
+
};
|
|
315792
|
+
server2.once("error", onError);
|
|
315793
|
+
server2.once("listening", onListening);
|
|
315794
|
+
server2.listen(port, "127.0.0.1");
|
|
315795
|
+
});
|
|
315796
|
+
}
|
|
315662
315797
|
|
|
315663
315798
|
// src/runtime/webui/WebUiEventStream.ts
|
|
315664
315799
|
var WEB_UI_SSE_HEARTBEAT_MS = 15e3;
|
|
@@ -315776,7 +315911,11 @@ var WebUiEventStream = class {
|
|
|
315776
315911
|
}
|
|
315777
315912
|
try {
|
|
315778
315913
|
const writable = res.write(
|
|
315779
|
-
`data: ${JSON.stringify({
|
|
315914
|
+
`data: ${JSON.stringify({
|
|
315915
|
+
kind: "heartbeat",
|
|
315916
|
+
sessionId: this.getSessionId?.(),
|
|
315917
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
315918
|
+
})}
|
|
315780
315919
|
|
|
315781
315920
|
`
|
|
315782
315921
|
);
|
|
@@ -315843,33 +315982,6 @@ data: ${JSON.stringify(entry.event)}
|
|
|
315843
315982
|
`;
|
|
315844
315983
|
}
|
|
315845
315984
|
|
|
315846
|
-
// src/runtime/webui/WebUiIcon.ts
|
|
315847
|
-
function renderUiIcon(name) {
|
|
315848
|
-
const paths = {
|
|
315849
|
-
add: '<path d="M12 5v14M5 12h14" />',
|
|
315850
|
-
tasks: '<rect x="5" y="4.5" width="14" height="15" rx="2" /><path d="m8 9 1.5 1.5L12 8M13.5 10h2.5M8 14h8M8 17h5" />',
|
|
315851
|
-
diagnostics: '<path d="M4.5 12h3l1.7-4 3.1 8 1.7-4h5.5" /><path d="M6 5.5h12v13H6z" />',
|
|
315852
|
-
changes: '<path d="M5 7h14M5 12h14M5 17h14" /><path d="M8 5v4M15 10v4M11 15v4" />',
|
|
315853
|
-
context: '<path d="M7 4.5h7l3 3v12H7z" /><path d="M14 4.5v3h3M9.5 12h5M12 9.5v5" />',
|
|
315854
|
-
image: '<rect x="4.5" y="5" width="15" height="14" rx="2" /><circle cx="9" cy="9.5" r="1.5" /><path d="m6.5 17 4-4 2.5 2 2.5-3 2.5 5" />',
|
|
315855
|
-
commands: '<rect x="4.5" y="5.5" width="15" height="13" rx="2" /><path d="m8 10 2 2-2 2M12.5 14h3.5" />',
|
|
315856
|
-
menu: '<path d="M5 7h14M5 12h14M5 17h14" />',
|
|
315857
|
-
panel: '<rect x="4.5" y="5" width="15" height="14" rx="2" /><path d="M14 5v14" />',
|
|
315858
|
-
close: '<path d="m7 7 10 10M17 7 7 17" />',
|
|
315859
|
-
back: '<path d="m10 6-6 6 6 6M4 12h16" />',
|
|
315860
|
-
up: '<path d="m7 14 5-5 5 5" />',
|
|
315861
|
-
down: '<path d="m7 10 5 5 5-5" />',
|
|
315862
|
-
archive: '<path d="M5.5 8.5h13v10h-13zM4.5 5h15v3.5h-15zM9.5 12h5" />',
|
|
315863
|
-
search: '<circle cx="10.5" cy="10.5" r="5.5" /><path d="m14.7 14.7 4.3 4.3" />',
|
|
315864
|
-
folder: '<path d="M4.5 7h5.3l2-2h7.7v14h-15z" /><path d="M4.5 9h15" />',
|
|
315865
|
-
review: '<circle cx="10.5" cy="10.5" r="5.5" /><path d="m14.7 14.7 4.3 4.3M10.5 8v5M8 10.5h5" />',
|
|
315866
|
-
fix: '<path d="M14.5 5.5a4 4 0 0 0-4.8 5.2L5 15.4 8.6 19l4.7-4.7a4 4 0 0 0 5.2-4.8l-2.7 2.7-3-3z" />',
|
|
315867
|
-
explain: '<path d="m9 7-5 5 5 5M15 7l5 5-5 5M13 5l-2 14" />',
|
|
315868
|
-
improve: '<path d="M12 4l1.2 4.1L17 10l-3.8 1.9L12 16l-1.2-4.1L7 10l3.8-1.9zM18 16v4M16 18h4M5 4v3M3.5 5.5h3" />'
|
|
315869
|
-
};
|
|
315870
|
-
return `<svg class="ui-icon" viewBox="0 0 24 24" fill="none" aria-hidden="true" focusable="false">${paths[name]}</svg>`;
|
|
315871
|
-
}
|
|
315872
|
-
|
|
315873
315985
|
// src/runtime/webui/WebUiWorkflowForm.ts
|
|
315874
315986
|
var STAGE_COPY = {
|
|
315875
315987
|
en: {
|
|
@@ -315955,6 +316067,7 @@ var BASE_COPY = {
|
|
|
315955
316067
|
projects: "Projects",
|
|
315956
316068
|
recentProjects: "Recent projects",
|
|
315957
316069
|
newProject: "Add project",
|
|
316070
|
+
findConversation: "Find projects and chats",
|
|
315958
316071
|
projectDialogTitle: "Open or create a project",
|
|
315959
316072
|
projectDialogBody: "Choose an existing folder to add it to Orbit, or enter the absolute path of a new folder whose parent already exists. Orbit opens it in a separate local browser tab with its own chats and context.",
|
|
315960
316073
|
projectPath: "Project folder path",
|
|
@@ -316144,6 +316257,7 @@ var BASE_COPY = {
|
|
|
316144
316257
|
projects: "\u9879\u76EE",
|
|
316145
316258
|
recentProjects: "\u6700\u8FD1\u9879\u76EE",
|
|
316146
316259
|
newProject: "\u6DFB\u52A0\u9879\u76EE",
|
|
316260
|
+
findConversation: "\u67E5\u627E\u9879\u76EE\u548C\u804A\u5929",
|
|
316147
316261
|
projectDialogTitle: "\u6253\u5F00\u6216\u521B\u5EFA\u9879\u76EE",
|
|
316148
316262
|
projectDialogBody: "\u9009\u62E9\u5DF2\u6709\u6587\u4EF6\u5939\u53EF\u76F4\u63A5\u52A0\u5165 Orbit\uFF1B\u4E5F\u53EF\u4EE5\u8F93\u5165\u7236\u76EE\u5F55\u5DF2\u5B58\u5728\u7684\u65B0\u6587\u4EF6\u5939\u7EDD\u5BF9\u8DEF\u5F84\u3002Orbit \u4F1A\u5728\u72EC\u7ACB\u7684\u672C\u5730\u6D4F\u89C8\u5668\u6807\u7B7E\u9875\u4E2D\u6253\u5F00\uFF0C\u5E76\u4FDD\u7559\u81EA\u5DF1\u7684\u804A\u5929\u548C\u4E0A\u4E0B\u6587\u3002",
|
|
316149
316263
|
projectPath: "\u9879\u76EE\u6587\u4EF6\u5939\u8DEF\u5F84",
|
|
@@ -316337,6 +316451,7 @@ var COPY = {
|
|
|
316337
316451
|
projects: "\u5C08\u6848",
|
|
316338
316452
|
recentProjects: "\u6700\u8FD1\u5C08\u6848",
|
|
316339
316453
|
newProject: "\u52A0\u5165\u5C08\u6848",
|
|
316454
|
+
findConversation: "\u5C0B\u627E\u5C08\u6848\u8207\u5C0D\u8A71",
|
|
316340
316455
|
projectDialogTitle: "\u958B\u555F\u6216\u5EFA\u7ACB\u5C08\u6848",
|
|
316341
316456
|
projectDialogBody: "\u9078\u64C7\u73FE\u6709\u8CC7\u6599\u593E\u53EF\u76F4\u63A5\u52A0\u5165 Orbit\uFF1B\u4E5F\u53EF\u4EE5\u8F38\u5165\u7236\u8CC7\u6599\u593E\u5DF2\u5B58\u5728\u7684\u65B0\u8CC7\u6599\u593E\u7D55\u5C0D\u8DEF\u5F91\u3002Orbit \u6703\u5728\u7368\u7ACB\u7684\u672C\u6A5F\u700F\u89BD\u5668\u5206\u9801\u958B\u555F\uFF0C\u4E26\u4FDD\u7559\u81EA\u5DF1\u7684\u804A\u5929\u548C\u4E0A\u4E0B\u6587\u3002",
|
|
316342
316457
|
projectPath: "\u5C08\u6848\u8CC7\u6599\u593E\u8DEF\u5F91",
|
|
@@ -316611,8 +316726,9 @@ function renderWebUiPage(language) {
|
|
|
316611
316726
|
<kbd data-control-key="N">Ctrl N</kbd>
|
|
316612
316727
|
</button>
|
|
316613
316728
|
|
|
316614
|
-
<div class="
|
|
316615
|
-
<span>${copy.projects}</span
|
|
316729
|
+
<div class="project-heading">
|
|
316730
|
+
<span>${copy.projects}</span>
|
|
316731
|
+
<button class="new-project-button" id="findConversation" type="button" aria-label="${copy.findConversation}" title="${copy.findConversation}" aria-haspopup="dialog" aria-controls="commandPalette">${renderUiIcon("search")}</button>
|
|
316616
316732
|
<button class="new-project-button" id="newProjectButton" type="button" aria-label="${copy.newProject}" aria-haspopup="dialog" aria-controls="projectDialog">${renderUiIcon("add")}</button>
|
|
316617
316733
|
</div>
|
|
316618
316734
|
<section class="project-section" id="projectSection" data-testid="active-project" aria-label="${copy.projects}">
|
|
@@ -316620,19 +316736,12 @@ function renderWebUiPage(language) {
|
|
|
316620
316736
|
<span class="project-folder-icon">${renderUiIcon("folder")}</span>
|
|
316621
316737
|
<span class="project-copy">
|
|
316622
316738
|
<strong id="sidebarWorkspace">\u2014</strong>
|
|
316623
|
-
<small id="sidebarSession">${copy.localOnly}</small>
|
|
316624
316739
|
</span>
|
|
316625
316740
|
<span class="project-chat-count" id="projectChatCount" aria-label="0">0</span>
|
|
316626
316741
|
<span class="project-toggle-chevron">${renderUiIcon("down")}</span>
|
|
316627
316742
|
</button>
|
|
316628
316743
|
<div class="project-chat-body" id="projectChatBody" role="region" aria-label="${copy.recentTasks}" tabindex="0">
|
|
316629
|
-
<section class="recent-section" id="recentSection" aria-
|
|
316630
|
-
<div class="nav-section-heading session-section-heading" id="recentHeading">
|
|
316631
|
-
<span>${copy.recentTasks}</span><i></i>
|
|
316632
|
-
<button class="archive-toggle" id="archiveToggle" type="button" aria-label="${copy.archivedTasks}" aria-controls="archivedPanel" aria-expanded="false">
|
|
316633
|
-
${renderUiIcon("archive")}<b id="archiveCount">0</b>
|
|
316634
|
-
</button>
|
|
316635
|
-
</div>
|
|
316744
|
+
<section class="recent-section" id="recentSection" aria-label="${copy.recentTasks}">
|
|
316636
316745
|
<label class="session-search" id="sessionSearchField" hidden>
|
|
316637
316746
|
<span class="sr-only">${copy.searchChats}</span>
|
|
316638
316747
|
${renderUiIcon("search")}
|
|
@@ -316641,8 +316750,10 @@ function renderWebUiPage(language) {
|
|
|
316641
316750
|
<div class="recent-sessions" id="recentSessions" data-testid="chat-list" aria-label="${copy.recentTasks}"></div>
|
|
316642
316751
|
<p class="session-list-empty" id="recentEmpty">${copy.noRecentTasks}</p>
|
|
316643
316752
|
<button class="session-show-more" id="sessionShowMore" type="button" hidden>${copy.showMoreChats}</button>
|
|
316753
|
+
<button class="archive-toggle" id="archiveToggle" type="button" aria-controls="archivedPanel" aria-expanded="false" hidden>
|
|
316754
|
+
${renderUiIcon("archive")}<span>${copy.archivedTasks}</span><b id="archiveCount">0</b>
|
|
316755
|
+
</button>
|
|
316644
316756
|
<section class="archived-panel" id="archivedPanel" aria-label="${copy.archivedTasks}" hidden>
|
|
316645
|
-
<div class="archived-panel-title">${copy.archivedTasks}</div>
|
|
316646
316757
|
<div class="archived-sessions" id="archivedSessions"></div>
|
|
316647
316758
|
<p class="session-list-empty" id="archivedEmpty">${copy.noArchivedTasks}</p>
|
|
316648
316759
|
</section>
|
|
@@ -316651,7 +316762,6 @@ function renderWebUiPage(language) {
|
|
|
316651
316762
|
</section>
|
|
316652
316763
|
|
|
316653
316764
|
<section class="recent-projects-shell" id="recentProjectsShell" aria-label="${copy.recentProjects}" hidden>
|
|
316654
|
-
<div class="project-list-label">${copy.recentProjects}</div>
|
|
316655
316765
|
<div class="project-list" id="projectList" role="region" aria-label="${copy.recentProjects}" tabindex="0"></div>
|
|
316656
316766
|
</section>
|
|
316657
316767
|
|
|
@@ -317017,20 +317127,7 @@ function renderWebUiPage(language) {
|
|
|
317017
317127
|
</aside>
|
|
317018
317128
|
|
|
317019
317129
|
</div>
|
|
317020
|
-
|
|
317021
|
-
<button class="command-palette-backdrop" id="commandPaletteBackdrop" type="button" aria-label="${copy.close}" tabindex="-1"></button>
|
|
317022
|
-
<section class="command-palette-dialog" role="dialog" aria-modal="true" aria-labelledby="commandPaletteTitle">
|
|
317023
|
-
<h2 class="sr-only" id="commandPaletteTitle">${copy.commands}</h2>
|
|
317024
|
-
<label class="command-search" for="commandSearch">
|
|
317025
|
-
<span aria-hidden="true">\u2318</span>
|
|
317026
|
-
<input id="commandSearch" type="search" aria-label="${copy.commandSearch}" aria-controls="commandResults" aria-autocomplete="list" autocomplete="off" spellcheck="false" placeholder="${copy.commandSearch}" />
|
|
317027
|
-
<kbd aria-hidden="true">Esc</kbd>
|
|
317028
|
-
</label>
|
|
317029
|
-
<div class="command-results" id="commandResults" role="listbox"></div>
|
|
317030
|
-
<p class="command-empty" id="commandEmpty" hidden>${copy.noCommands}</p>
|
|
317031
|
-
<footer class="command-palette-footer">${copy.commandHint}</footer>
|
|
317032
|
-
</section>
|
|
317033
|
-
</div>
|
|
317130
|
+
${renderCommandPaletteMarkup(copy)}
|
|
317034
317131
|
<div class="session-delete-dialog" id="sessionDeleteDialog" aria-hidden="true" hidden>
|
|
317035
317132
|
<button class="session-delete-backdrop" id="sessionDeleteBackdrop" type="button" aria-label="${copy.cancel}" tabindex="-1"></button>
|
|
317036
317133
|
<section class="session-delete-card" role="dialog" aria-modal="true" aria-labelledby="sessionDeleteTitle" aria-describedby="sessionDeleteBody">
|
|
@@ -321899,8 +321996,7 @@ var WEB_UI_PALETTE_STYLES = String.raw`
|
|
|
321899
321996
|
height: 14px;
|
|
321900
321997
|
}
|
|
321901
321998
|
|
|
321902
|
-
.command-trigger kbd
|
|
321903
|
-
.command-search kbd {
|
|
321999
|
+
.command-trigger kbd {
|
|
321904
322000
|
padding: 2px 5px;
|
|
321905
322001
|
color: var(--faint);
|
|
321906
322002
|
background: var(--surface-subtle);
|
|
@@ -321971,6 +322067,12 @@ var WEB_UI_PALETTE_STYLES = String.raw`
|
|
|
321971
322067
|
font: 700 11px/1 var(--font-mono);
|
|
321972
322068
|
}
|
|
321973
322069
|
|
|
322070
|
+
.command-search .command-search-lens,
|
|
322071
|
+
.is-navigation .command-search-glyph { display: none; }
|
|
322072
|
+
.is-navigation .command-search-lens { display: grid; }
|
|
322073
|
+
.command-search-lens .ui-icon { width: 16px; height: 16px; }
|
|
322074
|
+
.command-search .icon-button { width: 36px; height: 36px; }
|
|
322075
|
+
|
|
321974
322076
|
.command-search input {
|
|
321975
322077
|
width: 100%;
|
|
321976
322078
|
height: 56px;
|
|
@@ -322039,6 +322141,16 @@ var WEB_UI_PALETTE_STYLES = String.raw`
|
|
|
322039
322141
|
font: 650 11px/1 var(--font-mono);
|
|
322040
322142
|
}
|
|
322041
322143
|
|
|
322144
|
+
.navigation-results-group { display: grid; gap: 1px; }
|
|
322145
|
+
.navigation-results-heading {
|
|
322146
|
+
padding: 10px 11px 5px; color: var(--muted); font: 600 12px/1.4 var(--font-sans);
|
|
322147
|
+
}
|
|
322148
|
+
.navigation-results-group + .navigation-results-group { border-top: 1px solid var(--border); margin-top: 4px; }
|
|
322149
|
+
.is-navigation .command-result-icon { color: var(--accent-strong); background: transparent; border: 0; }
|
|
322150
|
+
.command-result-icon .ui-icon { width: 17px; height: 17px; }
|
|
322151
|
+
.is-navigation .command-result-copy strong { font-size: 13px; }
|
|
322152
|
+
.is-navigation .command-result-copy small { color: var(--muted); font: 12px/1.35 var(--font-sans); }
|
|
322153
|
+
.is-navigation .command-result[aria-current="page"] .command-result-icon { background: var(--accent-soft); }
|
|
322042
322154
|
.command-result-copy {
|
|
322043
322155
|
min-width: 0;
|
|
322044
322156
|
display: grid;
|
|
@@ -322098,9 +322210,10 @@ var WEB_UI_RESPONSIVE_STYLES = String.raw`
|
|
|
322098
322210
|
pointer-events: auto;
|
|
322099
322211
|
}
|
|
322100
322212
|
|
|
322101
|
-
.
|
|
322102
|
-
|
|
322103
|
-
}
|
|
322213
|
+
.session-actions { flex-basis: auto; width: auto; }
|
|
322214
|
+
.recent-session, .registered-project-open, .project-toggle { min-height: 44px; }
|
|
322215
|
+
.registered-project-remove { width: 32px; height: 32px; right: 2px; }
|
|
322216
|
+
|
|
322104
322217
|
|
|
322105
322218
|
.session-action {
|
|
322106
322219
|
width: 32px;
|
|
@@ -322108,7 +322221,7 @@ var WEB_UI_RESPONSIVE_STYLES = String.raw`
|
|
|
322108
322221
|
}
|
|
322109
322222
|
|
|
322110
322223
|
.session-row:has(.session-actions) .recent-session-meta {
|
|
322111
|
-
|
|
322224
|
+
display: none;
|
|
322112
322225
|
}
|
|
322113
322226
|
|
|
322114
322227
|
.icon-button,
|
|
@@ -322378,6 +322491,8 @@ var WEB_UI_RESPONSIVE_STYLES = String.raw`
|
|
|
322378
322491
|
scrollbar-gutter: auto;
|
|
322379
322492
|
}
|
|
322380
322493
|
|
|
322494
|
+
.project-chat-body { padding-inline-end: 10px; }
|
|
322495
|
+
|
|
322381
322496
|
.message-scroll {
|
|
322382
322497
|
scrollbar-width: none;
|
|
322383
322498
|
}
|
|
@@ -322997,7 +323112,7 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
322997
323112
|
gap: 8px;
|
|
322998
323113
|
padding: 8px 8px 8px 0;
|
|
322999
323114
|
background:
|
|
323000
|
-
radial-gradient(circle at 5% 0%, color-mix(in srgb, var(--accent)
|
|
323115
|
+
radial-gradient(circle at 5% 0%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 32%),
|
|
323001
323116
|
linear-gradient(145deg, color-mix(in srgb, var(--canvas-deep) 94%, white), var(--canvas-deep)),
|
|
323002
323117
|
var(--canvas-deep);
|
|
323003
323118
|
transition: grid-template-columns 210ms cubic-bezier(0.2, 0.75, 0.3, 1), gap 210ms ease, padding 210ms ease;
|
|
@@ -323091,14 +323206,9 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
323091
323206
|
|
|
323092
323207
|
.brand-version {
|
|
323093
323208
|
margin-left: auto;
|
|
323094
|
-
padding: 3px 6px;
|
|
323095
323209
|
color: var(--sidebar-muted);
|
|
323096
|
-
|
|
323097
|
-
|
|
323098
|
-
border-radius: 5px;
|
|
323099
|
-
font-family: var(--font-mono);
|
|
323100
|
-
font-size: 9px;
|
|
323101
|
-
letter-spacing: 0.04em;
|
|
323210
|
+
font: 11px var(--font-sans);
|
|
323211
|
+
font-variant-numeric: tabular-nums;
|
|
323102
323212
|
}
|
|
323103
323213
|
|
|
323104
323214
|
.sidebar-collapse-button {
|
|
@@ -323125,74 +323235,41 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
323125
323235
|
}
|
|
323126
323236
|
|
|
323127
323237
|
.new-task-button {
|
|
323128
|
-
height:
|
|
323238
|
+
min-height: 37px;
|
|
323129
323239
|
display: flex;
|
|
323130
323240
|
align-items: center;
|
|
323131
|
-
gap:
|
|
323132
|
-
|
|
323133
|
-
padding: 0 12px;
|
|
323241
|
+
gap: 8px;
|
|
323242
|
+
padding: 0 10px;
|
|
323134
323243
|
color: var(--sidebar-ink);
|
|
323135
|
-
background:
|
|
323136
|
-
border: 1px solid
|
|
323137
|
-
border-radius:
|
|
323138
|
-
|
|
323139
|
-
font-weight: 620;
|
|
323244
|
+
background: var(--sidebar-surface);
|
|
323245
|
+
border: 1px solid var(--sidebar-border);
|
|
323246
|
+
border-radius: 8px;
|
|
323247
|
+
font: 600 13px var(--font-sans);
|
|
323140
323248
|
text-align: left;
|
|
323141
|
-
transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
|
|
323142
|
-
}
|
|
323143
|
-
|
|
323144
|
-
.new-task-button:hover {
|
|
323145
|
-
background: color-mix(in srgb, var(--sidebar-active) 88%, var(--accent) 12%);
|
|
323146
|
-
border-color: color-mix(in srgb, var(--accent) 46%, var(--sidebar-border));
|
|
323147
|
-
box-shadow: 0 10px 26px rgba(3, 13, 10, 0.22);
|
|
323148
|
-
transform: translateY(-1px);
|
|
323149
323249
|
}
|
|
323150
|
-
|
|
323250
|
+
.new-task-button:hover { background: var(--sidebar-active); }
|
|
323151
323251
|
.new-task-button kbd {
|
|
323152
323252
|
margin-left: auto;
|
|
323153
|
-
|
|
323154
|
-
|
|
323155
|
-
background: var(--sidebar-surface);
|
|
323156
|
-
border: 1px solid var(--sidebar-border);
|
|
323157
|
-
border-radius: 5px;
|
|
323158
|
-
font: 9px/1.3 var(--font-mono);
|
|
323159
|
-
}
|
|
323160
|
-
|
|
323161
|
-
.new-task-icon {
|
|
323162
|
-
width: 20px;
|
|
323163
|
-
height: 20px;
|
|
323164
|
-
display: grid;
|
|
323165
|
-
place-items: center;
|
|
323166
|
-
color: #f6fbf9;
|
|
323167
|
-
background: color-mix(in srgb, var(--accent) 86%, white);
|
|
323168
|
-
border-radius: 6px;
|
|
323169
|
-
}
|
|
323170
|
-
|
|
323171
|
-
.new-task-icon .ui-icon {
|
|
323172
|
-
width: 14px;
|
|
323173
|
-
height: 14px;
|
|
323253
|
+
color: var(--sidebar-muted);
|
|
323254
|
+
font: 11px var(--font-sans);
|
|
323174
323255
|
}
|
|
323256
|
+
.new-task-icon { display: grid; place-items: center; color: var(--accent-strong); }
|
|
323257
|
+
.new-task-icon .ui-icon { width: 17px; height: 17px; }
|
|
323175
323258
|
|
|
323176
|
-
.
|
|
323177
|
-
height: 25px;
|
|
323259
|
+
.project-heading {
|
|
323178
323260
|
display: flex;
|
|
323179
323261
|
align-items: center;
|
|
323180
|
-
|
|
323181
|
-
|
|
323182
|
-
|
|
323183
|
-
|
|
323184
|
-
|
|
323185
|
-
text-transform: uppercase;
|
|
323186
|
-
}
|
|
323187
|
-
|
|
323188
|
-
.nav-section-heading i {
|
|
323189
|
-
height: 1px;
|
|
323190
|
-
flex: 1;
|
|
323191
|
-
background: var(--sidebar-border);
|
|
323262
|
+
justify-content: space-between;
|
|
323263
|
+
margin-top: 10px;
|
|
323264
|
+
padding: 0 6px 0 9px;
|
|
323265
|
+
color: var(--sidebar-muted);
|
|
323266
|
+
font: 600 12px/1.4 var(--font-sans);
|
|
323192
323267
|
}
|
|
323193
323268
|
|
|
323194
|
-
.project-heading {
|
|
323195
|
-
|
|
323269
|
+
.project-heading > span { margin-inline-end: auto; }
|
|
323270
|
+
.project-heading { gap: 3px; }
|
|
323271
|
+
@media (max-width: 760px) {
|
|
323272
|
+
.project-heading .new-project-button { width: 36px; height: 36px; }
|
|
323196
323273
|
}
|
|
323197
323274
|
|
|
323198
323275
|
.new-project-button {
|
|
@@ -323277,53 +323354,25 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
323277
323354
|
|
|
323278
323355
|
.project-section {
|
|
323279
323356
|
min-width: 0;
|
|
323280
|
-
min-height:
|
|
323357
|
+
min-height: 0;
|
|
323281
323358
|
display: grid;
|
|
323282
323359
|
grid-template-rows: auto minmax(0, 1fr);
|
|
323283
|
-
flex:
|
|
323360
|
+
flex: 0 1 auto;
|
|
323284
323361
|
overflow: hidden;
|
|
323285
|
-
background: transparent;
|
|
323286
|
-
border: 1px solid transparent;
|
|
323287
|
-
border-radius: 8px;
|
|
323288
323362
|
}
|
|
323289
|
-
|
|
323290
323363
|
.project-section:has(.project-toggle[aria-expanded="false"]) {
|
|
323291
|
-
min-height: 0;
|
|
323292
323364
|
flex: 0 0 auto;
|
|
323293
323365
|
grid-template-rows: auto;
|
|
323294
323366
|
}
|
|
323295
|
-
|
|
323296
|
-
.recent-projects-shell {
|
|
323297
|
-
min-width: 0;
|
|
323298
|
-
min-height: 0;
|
|
323299
|
-
max-height: min(196px, 26dvh);
|
|
323300
|
-
display: grid;
|
|
323301
|
-
grid-template-rows: auto minmax(0, 1fr);
|
|
323302
|
-
flex: 0 1 auto;
|
|
323303
|
-
gap: 3px;
|
|
323304
|
-
margin: 12px 4px 0;
|
|
323305
|
-
padding-top: 10px;
|
|
323306
|
-
border-top: 1px solid var(--sidebar-border);
|
|
323307
|
-
}
|
|
323308
|
-
|
|
323309
|
-
.recent-projects-shell[hidden] {
|
|
323310
|
-
display: none;
|
|
323311
|
-
}
|
|
323312
|
-
|
|
323313
|
-
.project-list-label {
|
|
323314
|
-
padding: 0 6px 3px;
|
|
323315
|
-
color: var(--sidebar-faint);
|
|
323316
|
-
font: 700 9.5px/1.4 var(--font-mono);
|
|
323317
|
-
letter-spacing: 0.11em;
|
|
323318
|
-
text-transform: uppercase;
|
|
323319
|
-
}
|
|
323367
|
+
.recent-projects-shell { min-width: 0; min-height: 0; max-height: min(170px, 24dvh); display: grid; flex: 0 1 auto; }
|
|
323368
|
+
.recent-projects-shell[hidden] { display: none; }
|
|
323320
323369
|
|
|
323321
323370
|
.project-list {
|
|
323322
323371
|
min-width: 0;
|
|
323323
323372
|
min-height: 0;
|
|
323324
323373
|
display: grid;
|
|
323325
323374
|
align-content: start;
|
|
323326
|
-
gap:
|
|
323375
|
+
gap: 1px;
|
|
323327
323376
|
overflow-x: hidden;
|
|
323328
323377
|
overflow-y: auto;
|
|
323329
323378
|
overscroll-behavior: contain;
|
|
@@ -323333,56 +323382,45 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
323333
323382
|
.registered-project {
|
|
323334
323383
|
position: relative;
|
|
323335
323384
|
min-width: 0;
|
|
323336
|
-
width: 100%;
|
|
323337
|
-
min-height: 52px;
|
|
323338
|
-
display: block;
|
|
323339
|
-
padding: 0;
|
|
323340
323385
|
color: var(--sidebar-muted);
|
|
323341
|
-
|
|
323342
|
-
border: 1px solid var(--sidebar-border);
|
|
323343
|
-
border-radius: 12px;
|
|
323344
|
-
text-align: left;
|
|
323345
|
-
transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
|
|
323346
|
-
}
|
|
323347
|
-
|
|
323348
|
-
.registered-project:focus-within,
|
|
323349
|
-
.registered-project:hover {
|
|
323350
|
-
color: var(--sidebar-ink);
|
|
323351
|
-
background: color-mix(in srgb, var(--sidebar-active) 72%, var(--sidebar-surface));
|
|
323352
|
-
border-color: color-mix(in srgb, var(--accent) 24%, var(--sidebar-border));
|
|
323386
|
+
border-radius: 7px;
|
|
323353
323387
|
}
|
|
323354
323388
|
|
|
323355
|
-
.registered-project:focus-within {
|
|
323356
|
-
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 34%, transparent);
|
|
323357
|
-
}
|
|
323389
|
+
.registered-project:hover, .registered-project:focus-within { background: var(--sidebar-surface); color: var(--sidebar-ink); }
|
|
323358
323390
|
|
|
323359
323391
|
.registered-project-open {
|
|
323360
|
-
min-
|
|
323361
|
-
|
|
323362
|
-
|
|
323363
|
-
|
|
323364
|
-
grid-template-columns: 30px minmax(0, 1fr);
|
|
323365
|
-
align-items: center;
|
|
323366
|
-
gap: 9px;
|
|
323367
|
-
padding: 7px 38px 7px 9px;
|
|
323368
|
-
color: inherit;
|
|
323369
|
-
background: transparent;
|
|
323370
|
-
border: 0;
|
|
323371
|
-
border-radius: inherit;
|
|
323372
|
-
text-align: left;
|
|
323392
|
+
width: 100%; min-height: 34px;
|
|
323393
|
+
display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: center; gap: 8px;
|
|
323394
|
+
padding: 4px 34px 4px 9px;
|
|
323395
|
+
color: inherit; background: transparent; border: 0; border-radius: inherit; text-align: left;
|
|
323373
323396
|
}
|
|
323397
|
+
.registered-project-open:focus-visible { outline-offset: -2px; }
|
|
323374
323398
|
|
|
323375
|
-
.registered-project-open
|
|
323376
|
-
|
|
323377
|
-
}
|
|
323378
|
-
|
|
323379
|
-
.registered-project-open.is-switching {
|
|
323399
|
+
.registered-project-open.is-switching,
|
|
323400
|
+
.recent-session[aria-busy="true"] {
|
|
323380
323401
|
cursor: progress;
|
|
323381
|
-
|
|
323402
|
+
color: var(--accent-strong);
|
|
323403
|
+
background: var(--accent-soft);
|
|
323382
323404
|
}
|
|
323383
|
-
|
|
323384
|
-
.
|
|
323385
|
-
.registered-project-
|
|
323405
|
+
.registered-project-open.is-switching .project-folder-icon,
|
|
323406
|
+
.recent-session[aria-busy="true"] .recent-session-meta { visibility: hidden; }
|
|
323407
|
+
.registered-project-open.is-switching::after,
|
|
323408
|
+
.recent-session[aria-busy="true"]::after {
|
|
323409
|
+
content: "";
|
|
323410
|
+
position: absolute;
|
|
323411
|
+
top: calc(50% - 6px);
|
|
323412
|
+
width: 12px; height: 12px;
|
|
323413
|
+
border: 1.5px solid currentColor;
|
|
323414
|
+
border-inline-end-color: transparent;
|
|
323415
|
+
border-radius: 50%;
|
|
323416
|
+
}
|
|
323417
|
+
.registered-project-open.is-switching::after { inset-inline-start: 12px; }
|
|
323418
|
+
.recent-session[aria-busy="true"]::after { inset-inline-end: 8px; }
|
|
323419
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
323420
|
+
.registered-project-open.is-switching::after,
|
|
323421
|
+
.recent-session[aria-busy="true"]::after { animation: orbit-nav-progress .8s linear infinite; }
|
|
323422
|
+
}
|
|
323423
|
+
@keyframes orbit-nav-progress { to { transform: rotate(1turn); } }
|
|
323386
323424
|
|
|
323387
323425
|
.registered-project-remove {
|
|
323388
323426
|
position: absolute;
|
|
@@ -323418,40 +323456,16 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
323418
323456
|
}
|
|
323419
323457
|
|
|
323420
323458
|
.project-toggle {
|
|
323421
|
-
min-width: 0;
|
|
323422
|
-
|
|
323423
|
-
|
|
323424
|
-
|
|
323425
|
-
grid-template-columns: auto minmax(0, 1fr) auto auto;
|
|
323426
|
-
align-items: center;
|
|
323427
|
-
gap: 9px;
|
|
323428
|
-
padding: 7px 9px;
|
|
323429
|
-
color: var(--sidebar-ink);
|
|
323430
|
-
background: transparent;
|
|
323431
|
-
border: 0;
|
|
323432
|
-
text-align: left;
|
|
323433
|
-
transition: background 140ms ease;
|
|
323434
|
-
}
|
|
323435
|
-
|
|
323436
|
-
.project-toggle:hover {
|
|
323437
|
-
background: color-mix(in srgb, var(--sidebar-active) 76%, transparent);
|
|
323438
|
-
}
|
|
323439
|
-
|
|
323440
|
-
.project-folder-icon {
|
|
323441
|
-
width: 30px;
|
|
323442
|
-
height: 30px;
|
|
323443
|
-
display: grid;
|
|
323444
|
-
place-items: center;
|
|
323445
|
-
color: var(--accent-strong);
|
|
323446
|
-
background: color-mix(in srgb, var(--accent-soft) 62%, var(--sidebar-surface));
|
|
323447
|
-
border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--sidebar-border));
|
|
323448
|
-
border-radius: 8px;
|
|
323449
|
-
}
|
|
323450
|
-
|
|
323451
|
-
.project-folder-icon .ui-icon {
|
|
323452
|
-
width: 16px;
|
|
323453
|
-
height: 16px;
|
|
323459
|
+
width: 100%; min-width: 0; min-height: 34px;
|
|
323460
|
+
display: grid; grid-template-columns: 18px minmax(0, 1fr) auto 14px; gap: 8px; align-items: center;
|
|
323461
|
+
padding: 4px 8px 4px 9px; color: var(--sidebar-ink);
|
|
323462
|
+
background: transparent; border: 0; border-radius: 7px; text-align: left;
|
|
323454
323463
|
}
|
|
323464
|
+
.project-toggle:hover { background: var(--sidebar-surface); }
|
|
323465
|
+
.project-toggle:focus-visible { outline-offset: -2px; }
|
|
323466
|
+
.project-folder-icon { display: grid; place-items: center; color: var(--sidebar-muted); }
|
|
323467
|
+
.project-toggle .project-folder-icon { color: var(--accent-strong); }
|
|
323468
|
+
.project-folder-icon .ui-icon { width: 17px; height: 17px; }
|
|
323455
323469
|
|
|
323456
323470
|
.project-copy {
|
|
323457
323471
|
min-width: 0;
|
|
@@ -323478,16 +323492,9 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
323478
323492
|
}
|
|
323479
323493
|
|
|
323480
323494
|
.project-chat-count {
|
|
323481
|
-
|
|
323482
|
-
|
|
323483
|
-
|
|
323484
|
-
place-items: center;
|
|
323485
|
-
padding: 0 5px;
|
|
323486
|
-
color: var(--sidebar-faint);
|
|
323487
|
-
background: var(--sidebar-surface);
|
|
323488
|
-
border: 1px solid var(--sidebar-border);
|
|
323489
|
-
border-radius: 7px;
|
|
323490
|
-
font: 600 10px/1 var(--font-mono);
|
|
323495
|
+
color: var(--sidebar-muted);
|
|
323496
|
+
font: 11px var(--font-sans);
|
|
323497
|
+
font-variant-numeric: tabular-nums;
|
|
323491
323498
|
}
|
|
323492
323499
|
|
|
323493
323500
|
.project-toggle-chevron {
|
|
@@ -323511,12 +323518,13 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
323511
323518
|
.project-chat-body {
|
|
323512
323519
|
min-width: 0;
|
|
323513
323520
|
min-height: 0;
|
|
323514
|
-
|
|
323521
|
+
margin-inline-start: 17px;
|
|
323522
|
+
padding: 0 1px 0 8px;
|
|
323515
323523
|
overflow-x: hidden;
|
|
323516
323524
|
overflow-y: auto;
|
|
323517
323525
|
overscroll-behavior: contain;
|
|
323518
323526
|
scrollbar-gutter: stable;
|
|
323519
|
-
border-
|
|
323527
|
+
border-inline-start: 1px solid var(--sidebar-border);
|
|
323520
323528
|
}
|
|
323521
323529
|
|
|
323522
323530
|
.project-chat-body,
|
|
@@ -323564,7 +323572,7 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
323564
323572
|
display: none;
|
|
323565
323573
|
}
|
|
323566
323574
|
|
|
323567
|
-
/*
|
|
323575
|
+
/* Indicate when more navigation items are outside the viewport. */
|
|
323568
323576
|
.project-list.has-scroll-before,
|
|
323569
323577
|
.project-chat-body.has-scroll-before {
|
|
323570
323578
|
box-shadow: inset 0 9px 13px -13px color-mix(in srgb, var(--accent) 76%, var(--sidebar-ink));
|
|
@@ -323585,7 +323593,7 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
323585
323593
|
.recent-section {
|
|
323586
323594
|
min-height: 0;
|
|
323587
323595
|
display: grid;
|
|
323588
|
-
grid-
|
|
323596
|
+
grid-auto-rows: max-content;
|
|
323589
323597
|
align-content: start;
|
|
323590
323598
|
margin-top: 2px;
|
|
323591
323599
|
}
|
|
@@ -323657,144 +323665,47 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
323657
323665
|
display: none;
|
|
323658
323666
|
}
|
|
323659
323667
|
|
|
323660
|
-
.session-section-heading {
|
|
323661
|
-
padding-right: 2px;
|
|
323662
|
-
}
|
|
323663
|
-
|
|
323664
323668
|
.archive-toggle {
|
|
323665
|
-
|
|
323666
|
-
height:
|
|
323667
|
-
|
|
323668
|
-
|
|
323669
|
-
|
|
323670
|
-
|
|
323671
|
-
|
|
323672
|
-
|
|
323673
|
-
|
|
323674
|
-
|
|
323675
|
-
border-radius: 7px;
|
|
323676
|
-
font: 600 10px/1 var(--font-mono);
|
|
323677
|
-
}
|
|
323678
|
-
|
|
323679
|
-
.archive-toggle:hover,
|
|
323680
|
-
.archive-toggle[aria-expanded="true"] {
|
|
323681
|
-
color: var(--sidebar-ink);
|
|
323682
|
-
background: var(--sidebar-surface);
|
|
323683
|
-
border-color: var(--sidebar-border);
|
|
323684
|
-
}
|
|
323685
|
-
|
|
323686
|
-
.archive-toggle b {
|
|
323687
|
-
min-width: 8px;
|
|
323688
|
-
font: inherit;
|
|
323689
|
-
}
|
|
323690
|
-
|
|
323691
|
-
.archive-toggle .ui-icon {
|
|
323692
|
-
width: 13px;
|
|
323693
|
-
height: 13px;
|
|
323694
|
-
}
|
|
323695
|
-
|
|
323696
|
-
.archive-toggle:not(.has-items) b {
|
|
323697
|
-
color: var(--sidebar-faint);
|
|
323698
|
-
}
|
|
323699
|
-
|
|
323700
|
-
.recent-sessions,
|
|
323701
|
-
.archived-sessions {
|
|
323702
|
-
min-height: 0;
|
|
323703
|
-
display: grid;
|
|
323704
|
-
gap: 2px;
|
|
323705
|
-
overflow: visible;
|
|
323706
|
-
padding: 2px;
|
|
323707
|
-
}
|
|
323708
|
-
|
|
323669
|
+
justify-self: start;
|
|
323670
|
+
display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 2px 7px;
|
|
323671
|
+
color: var(--sidebar-muted); background: transparent; border: 0; border-radius: 5px;
|
|
323672
|
+
font: 11px var(--font-sans);
|
|
323673
|
+
}
|
|
323674
|
+
.archive-toggle b { font-weight: 500; font-variant-numeric: tabular-nums; }
|
|
323675
|
+
.archive-toggle .ui-icon { width: 13px; height: 13px; }
|
|
323676
|
+
.archive-toggle:hover, .archive-toggle[aria-expanded="true"] { color: var(--sidebar-ink); background: var(--sidebar-surface); }
|
|
323677
|
+
.archive-toggle[hidden] { display: none; }
|
|
323678
|
+
.recent-sessions, .archived-sessions { min-width: 0; display: grid; gap: 2px; padding: 2px 0; }
|
|
323709
323679
|
.session-row {
|
|
323710
|
-
position: relative;
|
|
323711
323680
|
min-width: 0;
|
|
323712
|
-
display:
|
|
323713
|
-
|
|
323714
|
-
align-items: center;
|
|
323715
|
-
border: 1px solid transparent;
|
|
323716
|
-
border-radius: 9px;
|
|
323717
|
-
transition: background 140ms ease, border-color 140ms ease;
|
|
323718
|
-
}
|
|
323719
|
-
|
|
323720
|
-
.session-row:hover,
|
|
323721
|
-
.session-row:focus-within {
|
|
323722
|
-
background: color-mix(in srgb, var(--sidebar-surface) 78%, transparent);
|
|
323723
|
-
border-color: var(--sidebar-border);
|
|
323724
|
-
}
|
|
323725
|
-
|
|
323726
|
-
.session-row.is-active {
|
|
323727
|
-
background: color-mix(in srgb, var(--accent) 24%, transparent);
|
|
323728
|
-
border-color: color-mix(in srgb, var(--accent) 44%, var(--sidebar-border));
|
|
323729
|
-
}
|
|
323730
|
-
|
|
323731
|
-
.session-row.is-active .recent-session {
|
|
323732
|
-
color: var(--sidebar-ink);
|
|
323733
|
-
cursor: default;
|
|
323681
|
+
position: relative; display: flex; align-items: center;
|
|
323682
|
+
border-radius: 6px;
|
|
323734
323683
|
}
|
|
323735
|
-
|
|
323736
|
-
.session-row.is-active
|
|
323737
|
-
|
|
323738
|
-
height:
|
|
323739
|
-
|
|
323740
|
-
box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
|
|
323684
|
+
.session-row:hover, .session-row:focus-within { background: var(--sidebar-surface); }
|
|
323685
|
+
.session-row.is-active { color: var(--accent-strong); background: var(--accent-soft); }
|
|
323686
|
+
.session-row.is-active::before {
|
|
323687
|
+
content: ""; position: absolute; inset-inline-start: 0; width: 2px; height: 13px;
|
|
323688
|
+
border-radius: 2px; background: var(--accent); pointer-events: none;
|
|
323741
323689
|
}
|
|
323742
|
-
|
|
323690
|
+
.session-row.is-active .recent-session { color: inherit; font-weight: 620; cursor: default; }
|
|
323743
323691
|
.recent-session {
|
|
323744
|
-
|
|
323745
|
-
|
|
323746
|
-
|
|
323747
|
-
|
|
323748
|
-
gap: 6px;
|
|
323749
|
-
padding: 9px 12px 9px 18px;
|
|
323750
|
-
color: var(--sidebar-muted);
|
|
323751
|
-
background: transparent;
|
|
323752
|
-
border: 0;
|
|
323753
|
-
border-radius: 9px;
|
|
323754
|
-
text-align: left;
|
|
323755
|
-
transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
|
|
323756
|
-
}
|
|
323757
|
-
|
|
323758
|
-
.recent-session::before {
|
|
323759
|
-
content: "";
|
|
323760
|
-
position: absolute;
|
|
323761
|
-
width: 5px;
|
|
323762
|
-
height: 5px;
|
|
323763
|
-
top: 16px;
|
|
323764
|
-
left: 7px;
|
|
323765
|
-
background: var(--sidebar-faint);
|
|
323766
|
-
border-radius: 50%;
|
|
323767
|
-
}
|
|
323768
|
-
|
|
323769
|
-
.recent-session:hover {
|
|
323770
|
-
color: var(--sidebar-ink);
|
|
323692
|
+
min-width: 0; flex: 1; min-height: 33px;
|
|
323693
|
+
display: flex; align-items: center; gap: 6px; padding: 4px 7px 4px 10px;
|
|
323694
|
+
color: var(--sidebar-ink); background: transparent; border: 0; border-radius: inherit;
|
|
323695
|
+
text-align: left; font: 400 13px/1.35 var(--font-sans);
|
|
323771
323696
|
}
|
|
323772
|
-
|
|
323697
|
+
.recent-session:focus-visible { outline-offset: -2px; }
|
|
323773
323698
|
.session-actions {
|
|
323774
|
-
|
|
323775
|
-
|
|
323776
|
-
bottom: 4px;
|
|
323777
|
-
display: flex;
|
|
323778
|
-
align-items: center;
|
|
323779
|
-
gap: 1px;
|
|
323780
|
-
opacity: 0;
|
|
323781
|
-
pointer-events: none;
|
|
323782
|
-
transition: opacity 120ms ease;
|
|
323783
|
-
}
|
|
323784
|
-
|
|
323785
|
-
.session-row:hover .session-actions,
|
|
323786
|
-
.session-row:focus-within .session-actions {
|
|
323787
|
-
opacity: 1;
|
|
323788
|
-
pointer-events: auto;
|
|
323789
|
-
}
|
|
323790
|
-
|
|
323791
|
-
.session-row:has(.session-actions) .recent-session-meta {
|
|
323792
|
-
padding-right: 58px;
|
|
323699
|
+
flex: 0 0 0; width: 0; overflow: hidden;
|
|
323700
|
+
display: flex; align-items: center; gap: 1px; opacity: 0; pointer-events: none;
|
|
323793
323701
|
}
|
|
323702
|
+
.session-row:is(:hover, :focus-within) .session-actions { width: auto; flex-basis: auto; opacity: 1; pointer-events: auto; }
|
|
323703
|
+
.session-row:has(.session-actions):is(:hover, :focus-within) .recent-session-meta { display: none; }
|
|
323794
323704
|
|
|
323795
323705
|
.session-action {
|
|
323796
|
-
width:
|
|
323797
|
-
height:
|
|
323706
|
+
width: 26px;
|
|
323707
|
+
height: 28px;
|
|
323708
|
+
flex-shrink: 0;
|
|
323798
323709
|
display: grid;
|
|
323799
323710
|
place-items: center;
|
|
323800
323711
|
padding: 0;
|
|
@@ -323838,17 +323749,8 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
323838
323749
|
display: none;
|
|
323839
323750
|
}
|
|
323840
323751
|
|
|
323841
|
-
.archived-panel-title {
|
|
323842
|
-
padding: 0 8px 2px;
|
|
323843
|
-
color: var(--sidebar-faint);
|
|
323844
|
-
font: 700 10px/1.2 var(--font-mono);
|
|
323845
|
-
letter-spacing: 0.11em;
|
|
323846
|
-
text-transform: uppercase;
|
|
323847
|
-
}
|
|
323848
323752
|
|
|
323849
|
-
|
|
323850
|
-
overflow: visible;
|
|
323851
|
-
}
|
|
323753
|
+
|
|
323852
323754
|
|
|
323853
323755
|
.session-list-empty {
|
|
323854
323756
|
margin: 0;
|
|
@@ -323868,15 +323770,12 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
323868
323770
|
white-space: nowrap;
|
|
323869
323771
|
}
|
|
323870
323772
|
|
|
323871
|
-
.recent-session-title {
|
|
323872
|
-
color: inherit;
|
|
323873
|
-
font-size: 12px;
|
|
323874
|
-
font-weight: 590;
|
|
323875
|
-
}
|
|
323876
|
-
|
|
323773
|
+
.recent-session-title { flex: 1; min-width: 0; }
|
|
323877
323774
|
.recent-session-meta {
|
|
323775
|
+
flex: none;
|
|
323878
323776
|
color: var(--sidebar-muted);
|
|
323879
|
-
font:
|
|
323777
|
+
font: 11px/1.35 var(--font-sans);
|
|
323778
|
+
font-variant-numeric: tabular-nums;
|
|
323880
323779
|
}
|
|
323881
323780
|
|
|
323882
323781
|
.recent-session:disabled,
|
|
@@ -323897,7 +323796,7 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
323897
323796
|
|
|
323898
323797
|
.sidebar-spacer {
|
|
323899
323798
|
min-height: 4px;
|
|
323900
|
-
flex:
|
|
323799
|
+
flex: 1 0 4px;
|
|
323901
323800
|
}
|
|
323902
323801
|
|
|
323903
323802
|
.sidebar-footer { flex-shrink: 0; display: grid; gap: 2px; padding-top: 8px; border-top: 1px solid var(--sidebar-border); }
|
|
@@ -324473,6 +324372,7 @@ var MessagePageQuerySchema = z70.object({
|
|
|
324473
324372
|
}).strict();
|
|
324474
324373
|
var ChatRequestSchema = z70.object({
|
|
324475
324374
|
prompt: z70.string().trim().min(1).max(1e5),
|
|
324375
|
+
sessionId: z70.string().min(1).max(1e3).optional(),
|
|
324476
324376
|
turnId: WebTurnIdSchema.optional(),
|
|
324477
324377
|
attachmentIds: AttachmentIdsSchema.optional()
|
|
324478
324378
|
}).strict();
|
|
@@ -324480,6 +324380,7 @@ var InputQueueIdSchema = z70.string().trim().regex(/^input_[a-zA-Z0-9_-]+$/).max
|
|
|
324480
324380
|
var InputQueueActionSchema = z70.discriminatedUnion("action", [
|
|
324481
324381
|
z70.object({
|
|
324482
324382
|
action: z70.literal("enqueue"),
|
|
324383
|
+
sessionId: z70.string().min(1).max(1e3).optional(),
|
|
324483
324384
|
prompt: z70.string().trim().min(1).max(1e5),
|
|
324484
324385
|
mode: z70.enum(["follow_up", "steer"]).prefault("follow_up"),
|
|
324485
324386
|
attachmentIds: AttachmentIdsSchema.optional()
|
|
@@ -324626,24 +324527,6 @@ function safeCall2(fn) {
|
|
|
324626
324527
|
return void 0;
|
|
324627
324528
|
}
|
|
324628
324529
|
}
|
|
324629
|
-
function listen(server2, port) {
|
|
324630
|
-
return new Promise((resolveListen, reject) => {
|
|
324631
|
-
const onError = (error) => {
|
|
324632
|
-
server2.off("listening", onListening);
|
|
324633
|
-
reject(error);
|
|
324634
|
-
};
|
|
324635
|
-
const onListening = () => {
|
|
324636
|
-
server2.off("error", onError);
|
|
324637
|
-
const address = server2.address();
|
|
324638
|
-
resolveListen(
|
|
324639
|
-
typeof address === "object" && address ? address.port : port
|
|
324640
|
-
);
|
|
324641
|
-
};
|
|
324642
|
-
server2.once("error", onError);
|
|
324643
|
-
server2.once("listening", onListening);
|
|
324644
|
-
server2.listen(port, "127.0.0.1");
|
|
324645
|
-
});
|
|
324646
|
-
}
|
|
324647
324530
|
var OrbitWebUiRuntime = class {
|
|
324648
324531
|
options;
|
|
324649
324532
|
events;
|
|
@@ -324700,8 +324583,14 @@ var OrbitWebUiRuntime = class {
|
|
|
324700
324583
|
}
|
|
324701
324584
|
this.state = "starting";
|
|
324702
324585
|
this.token = randomBytes4(32).toString("base64url");
|
|
324703
|
-
const preferredPort = this.options.port ?? 6047;
|
|
324704
|
-
const attempts = preferredPort === 0 ? [0] :
|
|
324586
|
+
const preferredPort = this.options.port ?? this.options.preferredPort ?? 6047;
|
|
324587
|
+
const attempts = preferredPort === 0 ? [0] : [
|
|
324588
|
+
...Array.from(
|
|
324589
|
+
{ length: Math.min(20, 65536 - preferredPort) },
|
|
324590
|
+
(_, index) => preferredPort + index
|
|
324591
|
+
),
|
|
324592
|
+
0
|
|
324593
|
+
];
|
|
324705
324594
|
let lastError;
|
|
324706
324595
|
for (const port of attempts) {
|
|
324707
324596
|
const server2 = http2.createServer((req, res) => {
|
|
@@ -324713,7 +324602,7 @@ var OrbitWebUiRuntime = class {
|
|
|
324713
324602
|
});
|
|
324714
324603
|
});
|
|
324715
324604
|
try {
|
|
324716
|
-
const actualPort = await
|
|
324605
|
+
const actualPort = await listenOnLoopback(server2, port);
|
|
324717
324606
|
const token = this.token;
|
|
324718
324607
|
if (!token) throw new Error("Orbit Web UI authentication failed.");
|
|
324719
324608
|
this.server = server2;
|
|
@@ -325068,15 +324957,15 @@ var OrbitWebUiRuntime = class {
|
|
|
325068
324957
|
});
|
|
325069
324958
|
return;
|
|
325070
324959
|
}
|
|
325071
|
-
if (this.activeTurn) {
|
|
325072
|
-
sendJson(res, 409, {
|
|
325073
|
-
ok: false,
|
|
325074
|
-
message: "Wait for the active task to finish before opening a project."
|
|
325075
|
-
});
|
|
325076
|
-
return;
|
|
325077
|
-
}
|
|
325078
324960
|
try {
|
|
325079
324961
|
const action = ProjectActionSchema.parse(await readJsonBody(req));
|
|
324962
|
+
if (this.activeTurn) {
|
|
324963
|
+
sendJson(res, 409, {
|
|
324964
|
+
ok: false,
|
|
324965
|
+
message: "Wait for the active task to finish before opening a project."
|
|
324966
|
+
});
|
|
324967
|
+
return;
|
|
324968
|
+
}
|
|
325080
324969
|
if (this.projectActionPending) {
|
|
325081
324970
|
sendJson(res, 409, {
|
|
325082
324971
|
ok: false,
|
|
@@ -325089,6 +324978,9 @@ var OrbitWebUiRuntime = class {
|
|
|
325089
324978
|
const result = sanitizeProjectActionResult(
|
|
325090
324979
|
await options.openProject(action)
|
|
325091
324980
|
);
|
|
324981
|
+
if (result.ok && result.url && (action.action === "open" || action.action === "create") && options.onProjectHandoff) {
|
|
324982
|
+
res.once("finish", options.onProjectHandoff);
|
|
324983
|
+
}
|
|
325092
324984
|
sendJson(
|
|
325093
324985
|
res,
|
|
325094
324986
|
result.ok ? action.action === "remove" || action.action === "pick" ? 200 : 202 : 409,
|
|
@@ -325141,6 +325033,18 @@ var OrbitWebUiRuntime = class {
|
|
|
325141
325033
|
}
|
|
325142
325034
|
try {
|
|
325143
325035
|
const body = ChatRequestSchema.parse(await readJsonBody(req));
|
|
325036
|
+
const sessionId = safeCall2(() => options.loop?.getSessionId?.()) || "";
|
|
325037
|
+
if (body.sessionId !== void 0 && body.sessionId !== sessionId) {
|
|
325038
|
+
sendJson(res, 409, {
|
|
325039
|
+
ok: false,
|
|
325040
|
+
message: "The active chat changed. Your message was not sent."
|
|
325041
|
+
});
|
|
325042
|
+
return;
|
|
325043
|
+
}
|
|
325044
|
+
if (this.projectActionPending) {
|
|
325045
|
+
sendJson(res, 409, { ok: false, message: "A project action is in progress." });
|
|
325046
|
+
return;
|
|
325047
|
+
}
|
|
325144
325048
|
if (this.activeTurn) {
|
|
325145
325049
|
sendJson(res, 409, {
|
|
325146
325050
|
ok: false,
|
|
@@ -325151,7 +325055,7 @@ var OrbitWebUiRuntime = class {
|
|
|
325151
325055
|
}
|
|
325152
325056
|
const turn = {
|
|
325153
325057
|
id: body.turnId || randomUUID14(),
|
|
325154
|
-
sessionId
|
|
325058
|
+
sessionId,
|
|
325155
325059
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
325156
325060
|
cancelRequested: false
|
|
325157
325061
|
};
|
|
@@ -325191,6 +325095,13 @@ var OrbitWebUiRuntime = class {
|
|
|
325191
325095
|
let action;
|
|
325192
325096
|
let queuedAttachments = [];
|
|
325193
325097
|
if (request.action === "enqueue") {
|
|
325098
|
+
if (request.sessionId !== void 0 && request.sessionId !== options.loop?.getSessionId?.()) {
|
|
325099
|
+
sendJson(res, 409, {
|
|
325100
|
+
ok: false,
|
|
325101
|
+
message: "The active chat changed. Your message was not queued."
|
|
325102
|
+
});
|
|
325103
|
+
return;
|
|
325104
|
+
}
|
|
325194
325105
|
queuedAttachments = (request.attachmentIds || []).map((id) => {
|
|
325195
325106
|
const attachment = this.attachments.get(id);
|
|
325196
325107
|
if (!attachment) {
|
|
@@ -325234,6 +325145,10 @@ var OrbitWebUiRuntime = class {
|
|
|
325234
325145
|
try {
|
|
325235
325146
|
const body = TaskActionSchema.parse(await readJsonBody(req));
|
|
325236
325147
|
const action = { action: body.action };
|
|
325148
|
+
if (this.projectActionPending) {
|
|
325149
|
+
sendJson(res, 409, { ok: false, message: "A project action is in progress." });
|
|
325150
|
+
return;
|
|
325151
|
+
}
|
|
325237
325152
|
if (this.activeTurn) {
|
|
325238
325153
|
sendJson(res, 409, {
|
|
325239
325154
|
ok: false,
|
|
@@ -325424,7 +325339,15 @@ var OrbitWebUiRuntime = class {
|
|
|
325424
325339
|
}
|
|
325425
325340
|
try {
|
|
325426
325341
|
const action = SessionActionSchema.parse(await readJsonBody(req));
|
|
325342
|
+
if (this.activeTurn || this.projectActionPending) {
|
|
325343
|
+
sendJson(res, 409, {
|
|
325344
|
+
ok: false,
|
|
325345
|
+
message: "Wait for the current operation before changing chats."
|
|
325346
|
+
});
|
|
325347
|
+
return;
|
|
325348
|
+
}
|
|
325427
325349
|
const result = await options.updateSession(action);
|
|
325350
|
+
if (result.ok) this.events.broadcast({ kind: "sessions_changed" });
|
|
325428
325351
|
sendJson(res, result.ok ? 200 : 409, sanitizeActionResult(result));
|
|
325429
325352
|
} catch (error) {
|
|
325430
325353
|
sendJson(res, webRequestErrorStatus(error), {
|
|
@@ -327164,38 +327087,6 @@ async function handleSessionCommand(subcommand, argument, dependencies) {
|
|
|
327164
327087
|
}
|
|
327165
327088
|
}
|
|
327166
327089
|
|
|
327167
|
-
// src/runtime/SessionTitles.ts
|
|
327168
|
-
var DEFAULT_SESSION_TITLES = /* @__PURE__ */ new Set(["", "New Orbit Session"]);
|
|
327169
|
-
var MAX_TITLE_CHARACTERS = 64;
|
|
327170
|
-
var MAX_LATIN_WORDS = 8;
|
|
327171
|
-
function deriveSessionTitle(prompt) {
|
|
327172
|
-
const firstMeaningfulLine = prompt.split(/\r?\n/).map((line) => line.trim()).find(Boolean);
|
|
327173
|
-
if (!firstMeaningfulLine) return "Untitled task";
|
|
327174
|
-
const safe = redactSecrets(firstMeaningfulLine).replace(/^#{1,6}\s*/, "").replace(/^[-*+>]\s*/, "").replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
|
|
327175
|
-
if (!safe) return "Untitled task";
|
|
327176
|
-
const clause = safe.split(/[。!?!?;;]|\s+[—–-]\s+/u, 1)[0]?.trim() || safe;
|
|
327177
|
-
const hasCjk = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u.test(
|
|
327178
|
-
clause
|
|
327179
|
-
);
|
|
327180
|
-
const compact2 = hasCjk ? Array.from(clause).slice(0, 30).join("") : clause.split(/\s+/).slice(0, MAX_LATIN_WORDS).join(" ");
|
|
327181
|
-
const bounded = Array.from(compact2).slice(0, MAX_TITLE_CHARACTERS).join("").replace(/[\s,.:;!?,。!?;:]+$/u, "").trim();
|
|
327182
|
-
return bounded || "Untitled task";
|
|
327183
|
-
}
|
|
327184
|
-
function ensureSessionTitle(loop, prompt) {
|
|
327185
|
-
try {
|
|
327186
|
-
const activeSession = loop.sessionManager?.getActiveSession();
|
|
327187
|
-
if (!activeSession || !DEFAULT_SESSION_TITLES.has(activeSession.title.trim())) {
|
|
327188
|
-
return void 0;
|
|
327189
|
-
}
|
|
327190
|
-
const title = deriveSessionTitle(prompt);
|
|
327191
|
-
activeSession.title = title;
|
|
327192
|
-
loop.sessionManager.getSessionStore().updateSession(activeSession);
|
|
327193
|
-
return title;
|
|
327194
|
-
} catch {
|
|
327195
|
-
return void 0;
|
|
327196
|
-
}
|
|
327197
|
-
}
|
|
327198
|
-
|
|
327199
327090
|
// src/runtime/ModelDiscovery.ts
|
|
327200
327091
|
import { z as z75 } from "zod";
|
|
327201
327092
|
var ModelEntrySchema = z75.object({
|
|
@@ -327524,189 +327415,6 @@ function copyBooleanCapability(source, sourceKey, target, targetKey) {
|
|
|
327524
327415
|
}
|
|
327525
327416
|
}
|
|
327526
327417
|
|
|
327527
|
-
// src/runtime/ProjectLauncher.ts
|
|
327528
|
-
import { spawn as spawn5 } from "child_process";
|
|
327529
|
-
import { existsSync as existsSync21, mkdirSync as mkdirSync7, realpathSync as realpathSync5, statSync as statSync7 } from "fs";
|
|
327530
|
-
import { dirname as dirname13, isAbsolute as isAbsolute9, parse as parse5, resolve as resolve14 } from "path";
|
|
327531
|
-
var PROJECT_WEB_UI_READY_MESSAGE = "orbit-webui-ready";
|
|
327532
|
-
var ProjectLaunchError = class extends Error {
|
|
327533
|
-
constructor(code, message2, options) {
|
|
327534
|
-
super(message2, options);
|
|
327535
|
-
this.code = code;
|
|
327536
|
-
}
|
|
327537
|
-
code;
|
|
327538
|
-
name = "ProjectLaunchError";
|
|
327539
|
-
};
|
|
327540
|
-
async function launchOrbitProject(request, options = {}) {
|
|
327541
|
-
if (!isAbsolute9(request.path)) {
|
|
327542
|
-
throw new ProjectLaunchError(
|
|
327543
|
-
"absolute_path_required",
|
|
327544
|
-
"Enter an absolute project folder path."
|
|
327545
|
-
);
|
|
327546
|
-
}
|
|
327547
|
-
const requestedPath = resolve14(request.path);
|
|
327548
|
-
rejectFilesystemRoot(requestedPath);
|
|
327549
|
-
const entryPoint = options.entryPoint || process.argv[1];
|
|
327550
|
-
if (!entryPoint) {
|
|
327551
|
-
throw new ProjectLaunchError(
|
|
327552
|
-
"entrypoint_unavailable",
|
|
327553
|
-
"Orbit CLI entry point is unavailable."
|
|
327554
|
-
);
|
|
327555
|
-
}
|
|
327556
|
-
if (request.action === "create") {
|
|
327557
|
-
ensureProjectDirectory(requestedPath);
|
|
327558
|
-
} else {
|
|
327559
|
-
requireProjectDirectory(requestedPath);
|
|
327560
|
-
}
|
|
327561
|
-
const projectPath = realpathSync5.native(requestedPath);
|
|
327562
|
-
rejectFilesystemRoot(projectPath);
|
|
327563
|
-
const launch = options.launch || spawn5;
|
|
327564
|
-
let child;
|
|
327565
|
-
try {
|
|
327566
|
-
child = launch(
|
|
327567
|
-
options.executable || process.execPath,
|
|
327568
|
-
[entryPoint, "webui", "--cwd", projectPath],
|
|
327569
|
-
{
|
|
327570
|
-
...HIDDEN_CHILD_PROCESS_OPTIONS,
|
|
327571
|
-
cwd: projectPath,
|
|
327572
|
-
detached: true,
|
|
327573
|
-
stdio: ["ignore", "ignore", "ignore", "ipc"]
|
|
327574
|
-
}
|
|
327575
|
-
);
|
|
327576
|
-
} catch (error) {
|
|
327577
|
-
throw new ProjectLaunchError(
|
|
327578
|
-
"launch_failed",
|
|
327579
|
-
"Orbit project could not be started.",
|
|
327580
|
-
{ cause: error }
|
|
327581
|
-
);
|
|
327582
|
-
}
|
|
327583
|
-
return await new Promise(
|
|
327584
|
-
(resolveLaunch, rejectLaunch) => {
|
|
327585
|
-
let settled = false;
|
|
327586
|
-
const finish = (result, error) => {
|
|
327587
|
-
if (settled) return;
|
|
327588
|
-
settled = true;
|
|
327589
|
-
clearTimeout(timeout);
|
|
327590
|
-
child.removeListener("message", onMessage);
|
|
327591
|
-
child.removeListener("error", onError);
|
|
327592
|
-
child.removeListener("exit", onExit2);
|
|
327593
|
-
if (child.connected) {
|
|
327594
|
-
try {
|
|
327595
|
-
child.disconnect();
|
|
327596
|
-
} catch {
|
|
327597
|
-
}
|
|
327598
|
-
}
|
|
327599
|
-
child.unref();
|
|
327600
|
-
if (result) resolveLaunch(result);
|
|
327601
|
-
else
|
|
327602
|
-
rejectLaunch(
|
|
327603
|
-
error || new Error("Orbit Web UI could not be started.")
|
|
327604
|
-
);
|
|
327605
|
-
};
|
|
327606
|
-
const onMessage = (message2) => {
|
|
327607
|
-
const url2 = parseReadyUrl(message2);
|
|
327608
|
-
if (url2) finish({ path: projectPath, url: url2 });
|
|
327609
|
-
};
|
|
327610
|
-
const onError = (error) => finish(
|
|
327611
|
-
void 0,
|
|
327612
|
-
new ProjectLaunchError(
|
|
327613
|
-
"launch_failed",
|
|
327614
|
-
`Orbit project could not be opened: ${error.message}`,
|
|
327615
|
-
{ cause: error }
|
|
327616
|
-
)
|
|
327617
|
-
);
|
|
327618
|
-
const onExit2 = (code) => finish(
|
|
327619
|
-
void 0,
|
|
327620
|
-
new ProjectLaunchError(
|
|
327621
|
-
"startup_failed",
|
|
327622
|
-
`Orbit project exited before its Web UI was ready${code === null ? "." : ` (code ${code}).`}`
|
|
327623
|
-
)
|
|
327624
|
-
);
|
|
327625
|
-
const timeout = setTimeout(
|
|
327626
|
-
() => {
|
|
327627
|
-
child.kill();
|
|
327628
|
-
finish(
|
|
327629
|
-
void 0,
|
|
327630
|
-
new ProjectLaunchError(
|
|
327631
|
-
"startup_timeout",
|
|
327632
|
-
"Timed out while starting the Orbit project."
|
|
327633
|
-
)
|
|
327634
|
-
);
|
|
327635
|
-
},
|
|
327636
|
-
Math.max(1e3, options.startupTimeoutMs ?? 15e3)
|
|
327637
|
-
);
|
|
327638
|
-
timeout.unref();
|
|
327639
|
-
child.on("message", onMessage);
|
|
327640
|
-
child.once("error", onError);
|
|
327641
|
-
child.once("exit", onExit2);
|
|
327642
|
-
}
|
|
327643
|
-
);
|
|
327644
|
-
}
|
|
327645
|
-
function parseReadyUrl(message2) {
|
|
327646
|
-
if (typeof message2 !== "object" || message2 === null || !("type" in message2) || !("url" in message2) || message2.type !== PROJECT_WEB_UI_READY_MESSAGE || typeof message2.url !== "string") {
|
|
327647
|
-
return void 0;
|
|
327648
|
-
}
|
|
327649
|
-
return sanitizeLocalWebUiUrl(message2.url);
|
|
327650
|
-
}
|
|
327651
|
-
function ensureProjectDirectory(projectPath) {
|
|
327652
|
-
if (existsSync21(projectPath)) {
|
|
327653
|
-
requireProjectDirectory(projectPath);
|
|
327654
|
-
return;
|
|
327655
|
-
}
|
|
327656
|
-
const parentPath = dirname13(projectPath);
|
|
327657
|
-
if (!existsSync21(parentPath)) {
|
|
327658
|
-
throw new ProjectLaunchError(
|
|
327659
|
-
"parent_missing",
|
|
327660
|
-
"The parent folder does not exist. Choose an existing location first."
|
|
327661
|
-
);
|
|
327662
|
-
}
|
|
327663
|
-
if (!statSync7(parentPath).isDirectory()) {
|
|
327664
|
-
throw new ProjectLaunchError(
|
|
327665
|
-
"parent_not_directory",
|
|
327666
|
-
"The project parent path must be a directory."
|
|
327667
|
-
);
|
|
327668
|
-
}
|
|
327669
|
-
try {
|
|
327670
|
-
mkdirSync7(projectPath);
|
|
327671
|
-
} catch (error) {
|
|
327672
|
-
if (isNodeError4(error) && error.code === "EEXIST") {
|
|
327673
|
-
requireProjectDirectory(projectPath);
|
|
327674
|
-
return;
|
|
327675
|
-
}
|
|
327676
|
-
throw new ProjectLaunchError(
|
|
327677
|
-
"create_failed",
|
|
327678
|
-
"Orbit could not create the project folder.",
|
|
327679
|
-
{ cause: error }
|
|
327680
|
-
);
|
|
327681
|
-
}
|
|
327682
|
-
}
|
|
327683
|
-
function requireProjectDirectory(projectPath) {
|
|
327684
|
-
if (!existsSync21(projectPath)) {
|
|
327685
|
-
throw new ProjectLaunchError(
|
|
327686
|
-
"project_missing",
|
|
327687
|
-
"Project folder does not exist."
|
|
327688
|
-
);
|
|
327689
|
-
}
|
|
327690
|
-
if (!statSync7(projectPath).isDirectory()) {
|
|
327691
|
-
throw new ProjectLaunchError(
|
|
327692
|
-
"project_not_directory",
|
|
327693
|
-
"Project path must point to a directory."
|
|
327694
|
-
);
|
|
327695
|
-
}
|
|
327696
|
-
}
|
|
327697
|
-
function rejectFilesystemRoot(projectPath) {
|
|
327698
|
-
const normalized = resolve14(projectPath);
|
|
327699
|
-
if (normalized === parse5(normalized).root) {
|
|
327700
|
-
throw new ProjectLaunchError(
|
|
327701
|
-
"filesystem_root",
|
|
327702
|
-
"A filesystem root cannot be opened as an Orbit project."
|
|
327703
|
-
);
|
|
327704
|
-
}
|
|
327705
|
-
}
|
|
327706
|
-
function isNodeError4(error) {
|
|
327707
|
-
return error instanceof Error;
|
|
327708
|
-
}
|
|
327709
|
-
|
|
327710
327418
|
// src/runtime/ProjectFolderPicker.ts
|
|
327711
327419
|
import { execFile as execFile6 } from "child_process";
|
|
327712
327420
|
import { promisify as promisify4 } from "util";
|
|
@@ -327920,6 +327628,224 @@ function isPickerCancellation(error, platform) {
|
|
|
327920
327628
|
return stderr.includes("User canceled") || platform === "linux" && candidate.code === 1 && stderr.length === 0;
|
|
327921
327629
|
}
|
|
327922
327630
|
|
|
327631
|
+
// src/runtime/ProjectLauncher.ts
|
|
327632
|
+
import { spawn as spawn5 } from "child_process";
|
|
327633
|
+
import { existsSync as existsSync21, mkdirSync as mkdirSync7, realpathSync as realpathSync5, statSync as statSync7 } from "fs";
|
|
327634
|
+
import { dirname as dirname13, isAbsolute as isAbsolute9, parse as parse5, resolve as resolve14 } from "path";
|
|
327635
|
+
var PROJECT_WEB_UI_READY_MESSAGE = "orbit-webui-ready";
|
|
327636
|
+
var ProjectLaunchError = class extends Error {
|
|
327637
|
+
constructor(code, message2, options) {
|
|
327638
|
+
super(message2, options);
|
|
327639
|
+
this.code = code;
|
|
327640
|
+
}
|
|
327641
|
+
code;
|
|
327642
|
+
name = "ProjectLaunchError";
|
|
327643
|
+
};
|
|
327644
|
+
async function launchOrbitProject(request, options = {}) {
|
|
327645
|
+
if (!isAbsolute9(request.path)) {
|
|
327646
|
+
throw new ProjectLaunchError(
|
|
327647
|
+
"absolute_path_required",
|
|
327648
|
+
"Enter an absolute project folder path."
|
|
327649
|
+
);
|
|
327650
|
+
}
|
|
327651
|
+
const requestedPath = resolve14(request.path);
|
|
327652
|
+
rejectFilesystemRoot(requestedPath);
|
|
327653
|
+
const entryPoint = options.entryPoint || process.argv[1];
|
|
327654
|
+
if (!entryPoint) {
|
|
327655
|
+
throw new ProjectLaunchError(
|
|
327656
|
+
"entrypoint_unavailable",
|
|
327657
|
+
"Orbit CLI entry point is unavailable."
|
|
327658
|
+
);
|
|
327659
|
+
}
|
|
327660
|
+
if (request.action === "create") {
|
|
327661
|
+
ensureProjectDirectory(requestedPath);
|
|
327662
|
+
} else {
|
|
327663
|
+
requireProjectDirectory(requestedPath);
|
|
327664
|
+
}
|
|
327665
|
+
const projectPath = realpathSync5.native(requestedPath);
|
|
327666
|
+
rejectFilesystemRoot(projectPath);
|
|
327667
|
+
const launch = options.launch || spawn5;
|
|
327668
|
+
let child;
|
|
327669
|
+
try {
|
|
327670
|
+
child = launch(
|
|
327671
|
+
options.executable || process.execPath,
|
|
327672
|
+
[entryPoint, "webui", "--cwd", projectPath],
|
|
327673
|
+
{
|
|
327674
|
+
...HIDDEN_CHILD_PROCESS_OPTIONS,
|
|
327675
|
+
cwd: projectPath,
|
|
327676
|
+
detached: true,
|
|
327677
|
+
stdio: ["ignore", "ignore", "ignore", "ipc"]
|
|
327678
|
+
}
|
|
327679
|
+
);
|
|
327680
|
+
} catch (error) {
|
|
327681
|
+
throw new ProjectLaunchError(
|
|
327682
|
+
"launch_failed",
|
|
327683
|
+
"Orbit project could not be started.",
|
|
327684
|
+
{ cause: error }
|
|
327685
|
+
);
|
|
327686
|
+
}
|
|
327687
|
+
return await new Promise(
|
|
327688
|
+
(resolveLaunch, rejectLaunch) => {
|
|
327689
|
+
let settled = false;
|
|
327690
|
+
const finish = (result, error) => {
|
|
327691
|
+
if (settled) return;
|
|
327692
|
+
settled = true;
|
|
327693
|
+
clearTimeout(timeout);
|
|
327694
|
+
child.removeListener("message", onMessage);
|
|
327695
|
+
child.removeListener("error", onError);
|
|
327696
|
+
child.removeListener("exit", onExit2);
|
|
327697
|
+
if (child.connected) {
|
|
327698
|
+
try {
|
|
327699
|
+
child.disconnect();
|
|
327700
|
+
} catch {
|
|
327701
|
+
}
|
|
327702
|
+
}
|
|
327703
|
+
child.unref();
|
|
327704
|
+
if (result) resolveLaunch(result);
|
|
327705
|
+
else
|
|
327706
|
+
rejectLaunch(
|
|
327707
|
+
error || new Error("Orbit Web UI could not be started.")
|
|
327708
|
+
);
|
|
327709
|
+
};
|
|
327710
|
+
const onMessage = (message2) => {
|
|
327711
|
+
const url2 = parseReadyUrl(message2);
|
|
327712
|
+
if (url2) finish({ path: projectPath, url: url2 });
|
|
327713
|
+
};
|
|
327714
|
+
const onError = (error) => finish(
|
|
327715
|
+
void 0,
|
|
327716
|
+
new ProjectLaunchError(
|
|
327717
|
+
"launch_failed",
|
|
327718
|
+
`Orbit project could not be opened: ${error.message}`,
|
|
327719
|
+
{ cause: error }
|
|
327720
|
+
)
|
|
327721
|
+
);
|
|
327722
|
+
const onExit2 = (code) => finish(
|
|
327723
|
+
void 0,
|
|
327724
|
+
new ProjectLaunchError(
|
|
327725
|
+
"startup_failed",
|
|
327726
|
+
`Orbit project exited before its Web UI was ready${code === null ? "." : ` (code ${code}).`}`
|
|
327727
|
+
)
|
|
327728
|
+
);
|
|
327729
|
+
const timeout = setTimeout(
|
|
327730
|
+
() => {
|
|
327731
|
+
child.kill();
|
|
327732
|
+
finish(
|
|
327733
|
+
void 0,
|
|
327734
|
+
new ProjectLaunchError(
|
|
327735
|
+
"startup_timeout",
|
|
327736
|
+
"Timed out while starting the Orbit project."
|
|
327737
|
+
)
|
|
327738
|
+
);
|
|
327739
|
+
},
|
|
327740
|
+
Math.max(1e3, options.startupTimeoutMs ?? 15e3)
|
|
327741
|
+
);
|
|
327742
|
+
timeout.unref();
|
|
327743
|
+
child.on("message", onMessage);
|
|
327744
|
+
child.once("error", onError);
|
|
327745
|
+
child.once("exit", onExit2);
|
|
327746
|
+
}
|
|
327747
|
+
);
|
|
327748
|
+
}
|
|
327749
|
+
function parseReadyUrl(message2) {
|
|
327750
|
+
if (typeof message2 !== "object" || message2 === null || !("type" in message2) || !("url" in message2) || message2.type !== PROJECT_WEB_UI_READY_MESSAGE || typeof message2.url !== "string") {
|
|
327751
|
+
return void 0;
|
|
327752
|
+
}
|
|
327753
|
+
return sanitizeLocalWebUiUrl(message2.url);
|
|
327754
|
+
}
|
|
327755
|
+
function ensureProjectDirectory(projectPath) {
|
|
327756
|
+
if (existsSync21(projectPath)) {
|
|
327757
|
+
requireProjectDirectory(projectPath);
|
|
327758
|
+
return;
|
|
327759
|
+
}
|
|
327760
|
+
const parentPath = dirname13(projectPath);
|
|
327761
|
+
if (!existsSync21(parentPath)) {
|
|
327762
|
+
throw new ProjectLaunchError(
|
|
327763
|
+
"parent_missing",
|
|
327764
|
+
"The parent folder does not exist. Choose an existing location first."
|
|
327765
|
+
);
|
|
327766
|
+
}
|
|
327767
|
+
if (!statSync7(parentPath).isDirectory()) {
|
|
327768
|
+
throw new ProjectLaunchError(
|
|
327769
|
+
"parent_not_directory",
|
|
327770
|
+
"The project parent path must be a directory."
|
|
327771
|
+
);
|
|
327772
|
+
}
|
|
327773
|
+
try {
|
|
327774
|
+
mkdirSync7(projectPath);
|
|
327775
|
+
} catch (error) {
|
|
327776
|
+
if (isNodeError4(error) && error.code === "EEXIST") {
|
|
327777
|
+
requireProjectDirectory(projectPath);
|
|
327778
|
+
return;
|
|
327779
|
+
}
|
|
327780
|
+
throw new ProjectLaunchError(
|
|
327781
|
+
"create_failed",
|
|
327782
|
+
"Orbit could not create the project folder.",
|
|
327783
|
+
{ cause: error }
|
|
327784
|
+
);
|
|
327785
|
+
}
|
|
327786
|
+
}
|
|
327787
|
+
function requireProjectDirectory(projectPath) {
|
|
327788
|
+
if (!existsSync21(projectPath)) {
|
|
327789
|
+
throw new ProjectLaunchError(
|
|
327790
|
+
"project_missing",
|
|
327791
|
+
"Project folder does not exist."
|
|
327792
|
+
);
|
|
327793
|
+
}
|
|
327794
|
+
if (!statSync7(projectPath).isDirectory()) {
|
|
327795
|
+
throw new ProjectLaunchError(
|
|
327796
|
+
"project_not_directory",
|
|
327797
|
+
"Project path must point to a directory."
|
|
327798
|
+
);
|
|
327799
|
+
}
|
|
327800
|
+
}
|
|
327801
|
+
function rejectFilesystemRoot(projectPath) {
|
|
327802
|
+
const normalized = resolve14(projectPath);
|
|
327803
|
+
if (normalized === parse5(normalized).root) {
|
|
327804
|
+
throw new ProjectLaunchError(
|
|
327805
|
+
"filesystem_root",
|
|
327806
|
+
"A filesystem root cannot be opened as an Orbit project."
|
|
327807
|
+
);
|
|
327808
|
+
}
|
|
327809
|
+
}
|
|
327810
|
+
function isNodeError4(error) {
|
|
327811
|
+
return error instanceof Error;
|
|
327812
|
+
}
|
|
327813
|
+
async function handleWebUiProjectAction(action, coordinator) {
|
|
327814
|
+
if (action.action === "pick") {
|
|
327815
|
+
const path10 = await selectOrbitProjectFolder();
|
|
327816
|
+
return path10 ? { ok: true, path: path10 } : { ok: true, cancelled: true };
|
|
327817
|
+
}
|
|
327818
|
+
if (action.action === "remove") {
|
|
327819
|
+
const removed = new ProjectRegistry().remove(action.projectId);
|
|
327820
|
+
return {
|
|
327821
|
+
ok: removed,
|
|
327822
|
+
message: removed ? "Project was removed from Orbit. Files were not deleted." : "Project is no longer registered."
|
|
327823
|
+
};
|
|
327824
|
+
}
|
|
327825
|
+
const release = coordinator.acquire("web");
|
|
327826
|
+
if (!release)
|
|
327827
|
+
return {
|
|
327828
|
+
ok: false,
|
|
327829
|
+
message: "Wait for the active task before switching projects."
|
|
327830
|
+
};
|
|
327831
|
+
try {
|
|
327832
|
+
const launched = await launchOrbitProject(action);
|
|
327833
|
+
return {
|
|
327834
|
+
ok: true,
|
|
327835
|
+
message: `Opening Orbit project: ${launched.path}`,
|
|
327836
|
+
url: launched.url
|
|
327837
|
+
};
|
|
327838
|
+
} catch (error) {
|
|
327839
|
+
return {
|
|
327840
|
+
ok: false,
|
|
327841
|
+
...error instanceof ProjectLaunchError ? { errorCode: error.code } : {},
|
|
327842
|
+
message: error instanceof Error ? error.message : "Orbit could not open the selected project."
|
|
327843
|
+
};
|
|
327844
|
+
} finally {
|
|
327845
|
+
release();
|
|
327846
|
+
}
|
|
327847
|
+
}
|
|
327848
|
+
|
|
327923
327849
|
// src/runtime/commands/SessionMetadataCommandHandler.ts
|
|
327924
327850
|
import picocolors17 from "picocolors";
|
|
327925
327851
|
import { z as z76 } from "zod";
|
|
@@ -329552,12 +329478,15 @@ var CommandRouter = class {
|
|
|
329552
329478
|
const isZh = config.language !== "en";
|
|
329553
329479
|
const { port, open } = parseWebUiArgs(parts.slice(1).join(" "), process.env);
|
|
329554
329480
|
try {
|
|
329481
|
+
const savedPort = this.getLocalState().webUiPort;
|
|
329482
|
+
const preferredPort = savedPort ?? (process.connected ? 16e3 + createHash14("sha256").update(cwd).digest().readUInt16BE() % 32e3 : void 0);
|
|
329555
329483
|
const handle = await startOrbitWebUi({
|
|
329556
329484
|
cwd,
|
|
329557
329485
|
config,
|
|
329558
329486
|
loop,
|
|
329559
329487
|
port,
|
|
329560
|
-
|
|
329488
|
+
preferredPort,
|
|
329489
|
+
getProjects: () => new ProjectRegistry().list(),
|
|
329561
329490
|
getAgentRuns: () => {
|
|
329562
329491
|
const store = new AgentRunStore(cwd);
|
|
329563
329492
|
store.initialize();
|
|
@@ -329622,38 +329551,15 @@ var CommandRouter = class {
|
|
|
329622
329551
|
};
|
|
329623
329552
|
},
|
|
329624
329553
|
exportTrace: (includeHistory) => loop.exportSessionTrace(includeHistory),
|
|
329625
|
-
|
|
329626
|
-
|
|
329627
|
-
const path10 = await selectOrbitProjectFolder();
|
|
329628
|
-
return path10 ? { ok: true, path: path10 } : { ok: true, cancelled: true };
|
|
329629
|
-
}
|
|
329630
|
-
if (action.action === "remove") {
|
|
329631
|
-
const removed = new ProjectRegistry().remove(action.projectId);
|
|
329632
|
-
return {
|
|
329633
|
-
ok: removed,
|
|
329634
|
-
message: removed ? "Project was removed from Orbit. Files were not deleted." : "Project is no longer registered."
|
|
329635
|
-
};
|
|
329636
|
-
}
|
|
329637
|
-
try {
|
|
329638
|
-
const launched = await launchOrbitProject(action);
|
|
329639
|
-
this.onProjectHandoff?.();
|
|
329640
|
-
return {
|
|
329641
|
-
ok: true,
|
|
329642
|
-
message: `Opening Orbit project: ${launched.path}`,
|
|
329643
|
-
url: launched.url
|
|
329644
|
-
};
|
|
329645
|
-
} catch (error) {
|
|
329646
|
-
return {
|
|
329647
|
-
ok: false,
|
|
329648
|
-
...error instanceof ProjectLaunchError ? { errorCode: error.code } : {},
|
|
329649
|
-
message: error instanceof Error ? error.message : "Orbit could not open the selected project."
|
|
329650
|
-
};
|
|
329651
|
-
}
|
|
329652
|
-
},
|
|
329554
|
+
onProjectHandoff: this.onProjectHandoff,
|
|
329555
|
+
openProject: (action) => handleWebUiProjectAction(action, this.runCoordinator),
|
|
329653
329556
|
getPendingApproval: () => this.webApprovalBroker.getPending(),
|
|
329654
329557
|
respondToApproval: (decision2) => this.webApprovalBroker.respond(decision2),
|
|
329655
329558
|
invalidateSkills: () => loop.invalidateSkillsCache()
|
|
329656
329559
|
});
|
|
329560
|
+
if (handle.port >= 1024 && savedPort !== handle.port && (port !== void 0 || !savedPort)) {
|
|
329561
|
+
this.saveLocalState({ webUiPort: handle.port });
|
|
329562
|
+
}
|
|
329657
329563
|
if (typeof process.send === "function" && process.connected) {
|
|
329658
329564
|
try {
|
|
329659
329565
|
process.send({
|
|
@@ -331327,6 +331233,7 @@ var LocalSkillsStateSchema = z85.object({
|
|
|
331327
331233
|
disabled: z85.array(z85.string().min(1).max(128)).max(1e3).optional()
|
|
331328
331234
|
});
|
|
331329
331235
|
var LocalRuntimeStateSchema = z85.object({
|
|
331236
|
+
webUiPort: z85.number().int().min(1024).max(65535).optional().catch(void 0),
|
|
331330
331237
|
lastSessionId: z85.string().min(1).max(1e3).optional(),
|
|
331331
331238
|
lastProvider: z85.string().min(1).max(256).optional(),
|
|
331332
331239
|
lastModel: z85.string().max(512).optional(),
|
|
@@ -332055,14 +331962,8 @@ Risk Warning: ${reason}`);
|
|
|
332055
331962
|
resolveProjectHandoff = resolveHandoff;
|
|
332056
331963
|
});
|
|
332057
331964
|
const handleProjectHandoff = () => {
|
|
332058
|
-
|
|
332059
|
-
|
|
332060
|
-
resolveProjectHandoff?.();
|
|
332061
|
-
} else {
|
|
332062
|
-
void stopOrbitWebUi();
|
|
332063
|
-
}
|
|
332064
|
-
}, 750);
|
|
332065
|
-
timer.unref();
|
|
331965
|
+
if (this.webUiOnly) resolveProjectHandoff?.();
|
|
331966
|
+
else void stopOrbitWebUi();
|
|
332066
331967
|
};
|
|
332067
331968
|
const commandRouter = new CommandRouter(
|
|
332068
331969
|
this.cwd,
|
|
@@ -333735,7 +333636,7 @@ function errorMessage4(error) {
|
|
|
333735
333636
|
|
|
333736
333637
|
// src/commands/acp.ts
|
|
333737
333638
|
import picocolors29 from "picocolors";
|
|
333738
|
-
import { createHash as
|
|
333639
|
+
import { createHash as createHash16 } from "node:crypto";
|
|
333739
333640
|
import { dirname as dirname15 } from "node:path";
|
|
333740
333641
|
import { existsSync as existsSync29, mkdirSync as mkdirSync9 } from "node:fs";
|
|
333741
333642
|
|
|
@@ -337444,7 +337345,7 @@ var legacyClientNotificationMethods = /* @__PURE__ */ new Set([
|
|
|
337444
337345
|
]);
|
|
337445
337346
|
|
|
337446
337347
|
// ../acp/dist/index.js
|
|
337447
|
-
import { createHash as
|
|
337348
|
+
import { createHash as createHash15, createPublicKey as createPublicKey4, verify as verifySignature4 } from "node:crypto";
|
|
337448
337349
|
import { homedir as homedir12 } from "node:os";
|
|
337449
337350
|
import { existsSync as existsSync28, lstatSync as lstatSync10 } from "node:fs";
|
|
337450
337351
|
import { join as join19, resolve as resolve27 } from "node:path";
|
|
@@ -338143,7 +338044,7 @@ function buildAcpRegistrySignaturePayload(file) {
|
|
|
338143
338044
|
agents: file.agents,
|
|
338144
338045
|
...file.metadata ? { metadata: file.metadata } : {}
|
|
338145
338046
|
};
|
|
338146
|
-
const digest =
|
|
338047
|
+
const digest = createHash15("sha256").update(canonicalJsonStringify(unsigned), "utf8").digest("hex");
|
|
338147
338048
|
return {
|
|
338148
338049
|
digest,
|
|
338149
338050
|
payload: canonicalJsonStringify({ registry: unsigned, digest })
|
|
@@ -338842,7 +338743,7 @@ async function importAcpHistory(cwd, agentId, externalSessionId, config, options
|
|
|
338842
338743
|
if (messages.length === 0) {
|
|
338843
338744
|
throw new Error("ACP session/load returned no importable history.");
|
|
338844
338745
|
}
|
|
338845
|
-
const digest =
|
|
338746
|
+
const digest = createHash16("sha256").update(
|
|
338846
338747
|
canonicalJsonStringify({
|
|
338847
338748
|
externalSessionId,
|
|
338848
338749
|
updates: history.updates.map(({ sessionUpdate, data }) => ({
|
|
@@ -340230,7 +340131,7 @@ import {
|
|
|
340230
340131
|
writeFileSync as writeFileSync10
|
|
340231
340132
|
} from "fs";
|
|
340232
340133
|
import { basename as basename9, dirname as dirname17, join as join27, relative as relative14, resolve as resolve18 } from "path";
|
|
340233
|
-
import { createHash as
|
|
340134
|
+
import { createHash as createHash17, randomUUID as randomUUID26 } from "crypto";
|
|
340234
340135
|
import { promisify as promisify5 } from "util";
|
|
340235
340136
|
import picocolors33 from "picocolors";
|
|
340236
340137
|
import { parse as parseYaml5 } from "yaml";
|
|
@@ -340572,7 +340473,7 @@ function computeAcceptanceFixtureHash(cwd, fixturePaths) {
|
|
|
340572
340473
|
const normalized = relative14(resolve18(cwd), absolutePath).replace(/\\/g, "/");
|
|
340573
340474
|
visit(normalized, absolutePath);
|
|
340574
340475
|
}
|
|
340575
|
-
const digest =
|
|
340476
|
+
const digest = createHash17("sha256");
|
|
340576
340477
|
for (const directory of directories.sort()) {
|
|
340577
340478
|
digest.update(`directory\0${directory}\0`, "utf8");
|
|
340578
340479
|
}
|
|
@@ -341095,7 +340996,7 @@ import picocolors35 from "picocolors";
|
|
|
341095
340996
|
// ../daemon/dist/index.js
|
|
341096
340997
|
import { z as z105 } from "zod";
|
|
341097
340998
|
import { z as z312 } from "zod";
|
|
341098
|
-
import { createHash as
|
|
340999
|
+
import { createHash as createHash18 } from "crypto";
|
|
341099
341000
|
import {
|
|
341100
341001
|
appendFileSync,
|
|
341101
341002
|
closeSync as closeSync7,
|
|
@@ -341386,7 +341287,7 @@ var DaemonAuditLog = class {
|
|
|
341386
341287
|
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
341387
341288
|
const base = {
|
|
341388
341289
|
schemaVersion: 1,
|
|
341389
|
-
id: `audit_${
|
|
341290
|
+
id: `audit_${createHash18("sha256").update(`${now.toISOString()}\0${this.entries}\0${this.lastDigest}`).digest("hex").slice(0, 32)}`,
|
|
341390
341291
|
timestamp: now.toISOString(),
|
|
341391
341292
|
principalId: input.principalId,
|
|
341392
341293
|
authMethod: input.authMethod,
|
|
@@ -341397,7 +341298,7 @@ var DaemonAuditLog = class {
|
|
|
341397
341298
|
metadata: sanitizeMetadata(input.metadata),
|
|
341398
341299
|
previousDigest: this.lastDigest
|
|
341399
341300
|
};
|
|
341400
|
-
const digest =
|
|
341301
|
+
const digest = createHash18("sha256").update(canonicalJsonStringify(base), "utf8").digest("hex");
|
|
341401
341302
|
const entry = DaemonAuditEntrySchema.parse({ ...base, digest });
|
|
341402
341303
|
const serialized = `${JSON.stringify(entry)}
|
|
341403
341304
|
`;
|
|
@@ -341463,7 +341364,7 @@ var DaemonAuditLog = class {
|
|
|
341463
341364
|
if (entry.previousDigest !== previous)
|
|
341464
341365
|
throw new Error(`hash-chain break at entry ${index + 1}`);
|
|
341465
341366
|
const { digest, ...base } = entry;
|
|
341466
|
-
const expected =
|
|
341367
|
+
const expected = createHash18("sha256").update(canonicalJsonStringify(base), "utf8").digest("hex");
|
|
341467
341368
|
if (digest !== expected)
|
|
341468
341369
|
throw new Error(`digest mismatch at entry ${index + 1}`);
|
|
341469
341370
|
previous = digest;
|
|
@@ -343918,7 +343819,7 @@ import {
|
|
|
343918
343819
|
rmSync as rmSync13,
|
|
343919
343820
|
writeFileSync as writeFileSync12
|
|
343920
343821
|
} from "fs";
|
|
343921
|
-
import { createHash as
|
|
343822
|
+
import { createHash as createHash19, randomUUID as randomUUID27 } from "crypto";
|
|
343922
343823
|
import { dirname as dirname19, isAbsolute as isAbsolute12, join as join31, relative as relative16, resolve as resolve30, sep as sep5 } from "path";
|
|
343923
343824
|
import { z as z107 } from "zod";
|
|
343924
343825
|
var MAX_BACKUP_BYTES = 64 * 1024 * 1024;
|
|
@@ -344245,7 +344146,7 @@ function normalizeBundlePath(filePath) {
|
|
|
344245
344146
|
return normalized;
|
|
344246
344147
|
}
|
|
344247
344148
|
function hash2(content) {
|
|
344248
|
-
return
|
|
344149
|
+
return createHash19("sha256").update(content).digest("hex");
|
|
344249
344150
|
}
|
|
344250
344151
|
function formatBytes3(bytes) {
|
|
344251
344152
|
return `${Math.round(bytes / (1024 * 1024))} MiB`;
|