@orbit-build/cli 0.4.2 → 0.4.3
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 +306 -148
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -258121,11 +258121,18 @@ import {
|
|
|
258121
258121
|
writeFileSync as writeFileSync7
|
|
258122
258122
|
} from "fs";
|
|
258123
258123
|
import { createHash as createHash23 } from "crypto";
|
|
258124
|
-
import {
|
|
258124
|
+
import {
|
|
258125
|
+
closeSync as closeSync22,
|
|
258126
|
+
lstatSync as lstatSync22,
|
|
258127
|
+
openSync as openSync22,
|
|
258128
|
+
realpathSync as realpathSync2,
|
|
258129
|
+
statSync,
|
|
258130
|
+
unlinkSync as unlinkSync3
|
|
258131
|
+
} from "fs";
|
|
258125
258132
|
import { homedir as homedir5 } from "os";
|
|
258126
258133
|
import { basename as basename2, dirname as dirname23, isAbsolute as isAbsolute23, join as join25, parse as parse2, resolve as resolve24 } from "path";
|
|
258127
258134
|
import { z as z210 } from "zod";
|
|
258128
|
-
import { existsSync as existsSync26, lstatSync as
|
|
258135
|
+
import { existsSync as existsSync26, lstatSync as lstatSync32, mkdirSync as mkdirSync22, readdirSync as readdirSync22 } from "fs";
|
|
258129
258136
|
import { basename as basename22, join as join33, resolve as resolve32 } from "path";
|
|
258130
258137
|
import { z as z36 } from "zod";
|
|
258131
258138
|
var SafeObjectKeySchema = z29.string().refine(
|
|
@@ -259454,6 +259461,10 @@ var SessionManager = class {
|
|
|
259454
259461
|
};
|
|
259455
259462
|
var MAX_PROJECTS = 200;
|
|
259456
259463
|
var MAX_PROJECT_REGISTRY_BYTES = 2 * 1024 * 1024;
|
|
259464
|
+
var PROJECT_REGISTRY_LOCK_RETRIES = 50;
|
|
259465
|
+
var PROJECT_REGISTRY_LOCK_WAIT_MS = 10;
|
|
259466
|
+
var PROJECT_REGISTRY_STALE_LOCK_MS = 1e4;
|
|
259467
|
+
var PROJECT_REGISTRY_LOCK_WAIT = new Int32Array(new SharedArrayBuffer(4));
|
|
259457
259468
|
var ProjectRecordSchema = z210.object({
|
|
259458
259469
|
id: z210.string().regex(/^proj_[a-f0-9]{16}$/),
|
|
259459
259470
|
path: z210.string().min(1).max(4096).refine((value) => !/[\u0000-\u001f\u007f]/.test(value)),
|
|
@@ -259490,33 +259501,35 @@ var ProjectRegistry = class {
|
|
|
259490
259501
|
}
|
|
259491
259502
|
register(projectPath, sessionId) {
|
|
259492
259503
|
const canonicalPath = canonicalizeProjectPath(projectPath);
|
|
259493
|
-
|
|
259494
|
-
|
|
259495
|
-
|
|
259496
|
-
|
|
259497
|
-
|
|
259498
|
-
|
|
259499
|
-
|
|
259500
|
-
|
|
259501
|
-
|
|
259502
|
-
|
|
259503
|
-
|
|
259504
|
-
|
|
259505
|
-
|
|
259506
|
-
|
|
259507
|
-
|
|
259508
|
-
|
|
259509
|
-
|
|
259510
|
-
|
|
259511
|
-
|
|
259512
|
-
|
|
259513
|
-
|
|
259514
|
-
|
|
259515
|
-
|
|
259516
|
-
|
|
259517
|
-
|
|
259518
|
-
|
|
259519
|
-
|
|
259504
|
+
return this.withMutationLock(() => {
|
|
259505
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
259506
|
+
const snapshot = this.readSnapshot();
|
|
259507
|
+
const identity2 = projectIdentity(canonicalPath);
|
|
259508
|
+
const existing = snapshot.projects.find(
|
|
259509
|
+
(project) => project.id === identity2
|
|
259510
|
+
);
|
|
259511
|
+
const record = existing ? {
|
|
259512
|
+
...existing,
|
|
259513
|
+
path: canonicalPath,
|
|
259514
|
+
name: basename2(canonicalPath),
|
|
259515
|
+
lastOpenedAt: now,
|
|
259516
|
+
...sessionId ? { lastSessionId: sessionId } : {},
|
|
259517
|
+
archivedAt: void 0
|
|
259518
|
+
} : {
|
|
259519
|
+
id: identity2,
|
|
259520
|
+
path: canonicalPath,
|
|
259521
|
+
name: basename2(canonicalPath),
|
|
259522
|
+
createdAt: now,
|
|
259523
|
+
lastOpenedAt: now,
|
|
259524
|
+
...sessionId ? { lastSessionId: sessionId } : {}
|
|
259525
|
+
};
|
|
259526
|
+
snapshot.projects = [
|
|
259527
|
+
record,
|
|
259528
|
+
...snapshot.projects.filter((project) => project.id !== identity2)
|
|
259529
|
+
].slice(0, MAX_PROJECTS);
|
|
259530
|
+
this.writeSnapshot(snapshot);
|
|
259531
|
+
return record;
|
|
259532
|
+
});
|
|
259520
259533
|
}
|
|
259521
259534
|
list(options = {}) {
|
|
259522
259535
|
return this.readSnapshot().projects.filter(
|
|
@@ -259539,26 +259552,65 @@ var ProjectRegistry = class {
|
|
|
259539
259552
|
}));
|
|
259540
259553
|
}
|
|
259541
259554
|
remove(projectId) {
|
|
259542
|
-
|
|
259543
|
-
|
|
259544
|
-
|
|
259545
|
-
|
|
259546
|
-
|
|
259547
|
-
|
|
259548
|
-
|
|
259549
|
-
|
|
259555
|
+
return this.withMutationLock(() => {
|
|
259556
|
+
const snapshot = this.readSnapshot();
|
|
259557
|
+
const next = snapshot.projects.filter(
|
|
259558
|
+
(project) => project.id !== projectId
|
|
259559
|
+
);
|
|
259560
|
+
if (next.length === snapshot.projects.length) return false;
|
|
259561
|
+
snapshot.projects = next;
|
|
259562
|
+
this.writeSnapshot(snapshot);
|
|
259563
|
+
return true;
|
|
259564
|
+
});
|
|
259550
259565
|
}
|
|
259551
259566
|
update(projectId, updater) {
|
|
259552
|
-
|
|
259553
|
-
|
|
259554
|
-
|
|
259555
|
-
|
|
259556
|
-
|
|
259557
|
-
|
|
259558
|
-
|
|
259559
|
-
|
|
259560
|
-
|
|
259561
|
-
|
|
259567
|
+
return this.withMutationLock(() => {
|
|
259568
|
+
const snapshot = this.readSnapshot();
|
|
259569
|
+
const index = snapshot.projects.findIndex(
|
|
259570
|
+
(project) => project.id === projectId
|
|
259571
|
+
);
|
|
259572
|
+
if (index < 0) return false;
|
|
259573
|
+
snapshot.projects[index] = ProjectRecordSchema.parse(
|
|
259574
|
+
updater(snapshot.projects[index])
|
|
259575
|
+
);
|
|
259576
|
+
this.writeSnapshot(snapshot);
|
|
259577
|
+
return true;
|
|
259578
|
+
});
|
|
259579
|
+
}
|
|
259580
|
+
withMutationLock(operation) {
|
|
259581
|
+
ensurePrivateDirectory(dirname23(this.filePath), { windowsAcl: false });
|
|
259582
|
+
const lockPath = `${this.filePath}.lock`;
|
|
259583
|
+
for (let attempt = 0; attempt < PROJECT_REGISTRY_LOCK_RETRIES; attempt++) {
|
|
259584
|
+
let handle;
|
|
259585
|
+
try {
|
|
259586
|
+
handle = openSync22(lockPath, "wx", 384);
|
|
259587
|
+
} catch (error) {
|
|
259588
|
+
if (!isNodeError(error) || error.code !== "EEXIST") throw error;
|
|
259589
|
+
if (removeStaleLock(lockPath)) continue;
|
|
259590
|
+
if (attempt === PROJECT_REGISTRY_LOCK_RETRIES - 1) {
|
|
259591
|
+
throw new Error(
|
|
259592
|
+
"The Orbit project registry is busy. Try the action again."
|
|
259593
|
+
);
|
|
259594
|
+
}
|
|
259595
|
+
Atomics.wait(
|
|
259596
|
+
PROJECT_REGISTRY_LOCK_WAIT,
|
|
259597
|
+
0,
|
|
259598
|
+
0,
|
|
259599
|
+
PROJECT_REGISTRY_LOCK_WAIT_MS
|
|
259600
|
+
);
|
|
259601
|
+
continue;
|
|
259602
|
+
}
|
|
259603
|
+
try {
|
|
259604
|
+
return operation();
|
|
259605
|
+
} finally {
|
|
259606
|
+
closeSync22(handle);
|
|
259607
|
+
try {
|
|
259608
|
+
unlinkSync3(lockPath);
|
|
259609
|
+
} catch {
|
|
259610
|
+
}
|
|
259611
|
+
}
|
|
259612
|
+
}
|
|
259613
|
+
throw new Error("The Orbit project registry could not be locked.");
|
|
259562
259614
|
}
|
|
259563
259615
|
readSnapshot() {
|
|
259564
259616
|
for (const candidate of [this.filePath, `${this.filePath}.bak`]) {
|
|
@@ -259627,6 +259679,21 @@ function isDirectory(targetPath) {
|
|
|
259627
259679
|
return false;
|
|
259628
259680
|
}
|
|
259629
259681
|
}
|
|
259682
|
+
function removeStaleLock(lockPath) {
|
|
259683
|
+
try {
|
|
259684
|
+
const lock = lstatSync22(lockPath);
|
|
259685
|
+
if (!lock.isFile() || Date.now() - lock.mtimeMs <= PROJECT_REGISTRY_STALE_LOCK_MS) {
|
|
259686
|
+
return false;
|
|
259687
|
+
}
|
|
259688
|
+
unlinkSync3(lockPath);
|
|
259689
|
+
return true;
|
|
259690
|
+
} catch (error) {
|
|
259691
|
+
return isNodeError(error) && error.code === "ENOENT";
|
|
259692
|
+
}
|
|
259693
|
+
}
|
|
259694
|
+
function isNodeError(error) {
|
|
259695
|
+
return error instanceof Error;
|
|
259696
|
+
}
|
|
259630
259697
|
var AGENT_RUN_MAX_BYTES = 2 * 1024 * 1024;
|
|
259631
259698
|
var AgentIdSchema = z36.string().regex(/^agent_[a-z0-9-]+$/, "Invalid agent id.");
|
|
259632
259699
|
var AgentRunIdSchema = z36.string().regex(/^run_[a-z0-9-]+$/, "Invalid agent run id.");
|
|
@@ -259819,7 +259886,7 @@ var AgentRunStore = class {
|
|
|
259819
259886
|
}
|
|
259820
259887
|
}
|
|
259821
259888
|
assertRunDirectorySafe() {
|
|
259822
|
-
const stats =
|
|
259889
|
+
const stats = lstatSync32(this.directory);
|
|
259823
259890
|
if (stats.isSymbolicLink() || !stats.isDirectory()) {
|
|
259824
259891
|
throw new Error("Orbit agent-run directory must be a real directory.");
|
|
259825
259892
|
}
|
|
@@ -273991,7 +274058,7 @@ var FullscreenTui = class {
|
|
|
273991
274058
|
// src/runtime/ReplController.ts
|
|
273992
274059
|
import picocolors19 from "picocolors";
|
|
273993
274060
|
import { rmSync as rmSync6, watch } from "fs";
|
|
273994
|
-
import { dirname as
|
|
274061
|
+
import { dirname as dirname10, resolve as resolve12 } from "path";
|
|
273995
274062
|
import { homedir as homedir10 } from "os";
|
|
273996
274063
|
import http3 from "http";
|
|
273997
274064
|
import { randomBytes as randomBytes5, randomUUID as randomUUID11, timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
@@ -274683,7 +274750,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
274683
274750
|
if (restoreFocus && state.projectDialogReturnFocus) state.projectDialogReturnFocus.focus();
|
|
274684
274751
|
state.projectDialogReturnFocus = null;
|
|
274685
274752
|
};
|
|
274686
|
-
const
|
|
274753
|
+
const openProjectDialog = () => {
|
|
274687
274754
|
if (state.busy) return;
|
|
274688
274755
|
state.projectDialogReturnFocus = document.activeElement;
|
|
274689
274756
|
elements.projectDialog.hidden = false;
|
|
@@ -274716,6 +274783,8 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
274716
274783
|
elements.projectPathInput.focus();
|
|
274717
274784
|
return;
|
|
274718
274785
|
}
|
|
274786
|
+
if (elements.projectDialogOpen.disabled) return;
|
|
274787
|
+
elements.projectDialogBrowse.disabled = true;
|
|
274719
274788
|
elements.projectDialogOpen.disabled = true;
|
|
274720
274789
|
elements.projectDialogCreate.disabled = true;
|
|
274721
274790
|
showToast(copy.projectOpened);
|
|
@@ -274731,13 +274800,18 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
274731
274800
|
} catch (error) {
|
|
274732
274801
|
showToast(error.message || String(error), 'error');
|
|
274733
274802
|
} finally {
|
|
274803
|
+
elements.projectDialogBrowse.disabled = false;
|
|
274734
274804
|
elements.projectDialogOpen.disabled = false;
|
|
274735
274805
|
elements.projectDialogCreate.disabled = false;
|
|
274736
274806
|
}
|
|
274737
274807
|
};
|
|
274738
|
-
const
|
|
274808
|
+
const pickProjectFolder = async () => {
|
|
274739
274809
|
if (state.busy || state.projectPickerPending) return;
|
|
274740
274810
|
state.projectPickerPending = true;
|
|
274811
|
+
elements.projectDialogBrowse.disabled = true;
|
|
274812
|
+
elements.projectDialogBrowse.setAttribute('aria-busy', 'true');
|
|
274813
|
+
elements.projectDialogOpen.disabled = true;
|
|
274814
|
+
elements.projectDialogCreate.disabled = true;
|
|
274741
274815
|
elements.newProjectButton.disabled = true;
|
|
274742
274816
|
try {
|
|
274743
274817
|
const result = await api('/api/project', {
|
|
@@ -274746,19 +274820,24 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
274746
274820
|
body: JSON.stringify({ action: 'pick' }),
|
|
274747
274821
|
});
|
|
274748
274822
|
if (result.cancelled || !result.path) return;
|
|
274749
|
-
|
|
274823
|
+
elements.projectPathInput.value = result.path;
|
|
274824
|
+
elements.projectPathInput.focus();
|
|
274825
|
+
elements.projectPathInput.select();
|
|
274750
274826
|
} catch (error) {
|
|
274751
274827
|
showToast(error.message || String(error), 'warning');
|
|
274752
|
-
openManualProjectDialog();
|
|
274753
274828
|
} finally {
|
|
274754
274829
|
state.projectPickerPending = false;
|
|
274830
|
+
elements.projectDialogBrowse.disabled = false;
|
|
274831
|
+
elements.projectDialogBrowse.removeAttribute('aria-busy');
|
|
274832
|
+
elements.projectDialogOpen.disabled = false;
|
|
274833
|
+
elements.projectDialogCreate.disabled = false;
|
|
274755
274834
|
elements.newProjectButton.disabled = false;
|
|
274756
274835
|
}
|
|
274757
274836
|
};
|
|
274758
|
-
|
|
274759
|
-
elements.newProjectButton.addEventListener('click', () => void pickAndOpenProject());
|
|
274837
|
+
elements.newProjectButton.addEventListener('click', openProjectDialog);
|
|
274760
274838
|
elements.projectDialogBackdrop.addEventListener('click', () => closeProjectDialog());
|
|
274761
274839
|
elements.projectDialogCancel.addEventListener('click', () => closeProjectDialog());
|
|
274840
|
+
elements.projectDialogBrowse.addEventListener('click', () => void pickProjectFolder());
|
|
274762
274841
|
elements.projectDialogOpen.addEventListener('click', () => void launchProject('open'));
|
|
274763
274842
|
elements.projectDialogCreate.addEventListener('click', () => void launchProject('create'));
|
|
274764
274843
|
elements.projectList.addEventListener('click', (event) => {
|
|
@@ -274813,7 +274892,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
274813
274892
|
});
|
|
274814
274893
|
elements.projectDialog.addEventListener('keydown', (event) => {
|
|
274815
274894
|
if (event.key !== 'Tab') return;
|
|
274816
|
-
const focusable = [elements.projectPathInput, elements.projectDialogCancel, elements.projectDialogOpen, elements.projectDialogCreate];
|
|
274895
|
+
const focusable = [elements.projectPathInput, elements.projectDialogBrowse, elements.projectDialogCancel, elements.projectDialogOpen, elements.projectDialogCreate];
|
|
274817
274896
|
const first = focusable[0];
|
|
274818
274897
|
const last = focusable[focusable.length - 1];
|
|
274819
274898
|
if (event.shiftKey && document.activeElement === first) {
|
|
@@ -276315,6 +276394,7 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
|
|
|
276315
276394
|
projectDialogCancel: byId('projectDialogCancel'),
|
|
276316
276395
|
projectDialogOpen: byId('projectDialogOpen'),
|
|
276317
276396
|
projectDialogCreate: byId('projectDialogCreate'),
|
|
276397
|
+
projectDialogBrowse: byId('projectDialogBrowse'),
|
|
276318
276398
|
projectPathInput: byId('projectPathInput'),
|
|
276319
276399
|
recentSection: byId('recentSection'),
|
|
276320
276400
|
sessionSearchField: byId('sessionSearchField'),
|
|
@@ -276498,6 +276578,7 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
|
|
|
276498
276578
|
sessionLimit: 24,
|
|
276499
276579
|
sessionDeleteReturnFocus: null,
|
|
276500
276580
|
projectDialogReturnFocus: null,
|
|
276581
|
+
projectPickerPending: false,
|
|
276501
276582
|
promptQueue: [],
|
|
276502
276583
|
queueEditingId: null,
|
|
276503
276584
|
queueEditDraft: '',
|
|
@@ -276589,8 +276670,8 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
|
|
|
276589
276670
|
async function bootstrapSession() {
|
|
276590
276671
|
let savedToken = '';
|
|
276591
276672
|
try { savedToken = sessionStorage.getItem(webSessionTokenKey) || ''; } catch {}
|
|
276592
|
-
const bootstrapToken =
|
|
276593
|
-
if (!bootstrapToken) return;
|
|
276673
|
+
const bootstrapToken = webSessionToken || savedToken;
|
|
276674
|
+
if (!bootstrapToken) return false;
|
|
276594
276675
|
webSessionToken = bootstrapToken;
|
|
276595
276676
|
const response = await fetch('/api/bootstrap', {
|
|
276596
276677
|
method: 'POST',
|
|
@@ -276602,25 +276683,15 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
|
|
|
276602
276683
|
try { sessionStorage.removeItem(webSessionTokenKey); } catch {}
|
|
276603
276684
|
webSessionToken = '';
|
|
276604
276685
|
state.useBearerTransport = false;
|
|
276686
|
+
return false;
|
|
276605
276687
|
}
|
|
276688
|
+
state.useBearerTransport = false;
|
|
276689
|
+
return true;
|
|
276606
276690
|
}
|
|
276607
276691
|
|
|
276608
|
-
async function
|
|
276692
|
+
async function recoverAuthenticatedSession() {
|
|
276609
276693
|
if (sessionRecoveryPromise) return sessionRecoveryPromise;
|
|
276610
|
-
sessionRecoveryPromise = (
|
|
276611
|
-
const response = await fetch(location.pathname || '/', {
|
|
276612
|
-
method: 'GET',
|
|
276613
|
-
credentials: 'same-origin',
|
|
276614
|
-
cache: 'no-store',
|
|
276615
|
-
headers: { Accept: 'text/html' },
|
|
276616
|
-
});
|
|
276617
|
-
await response.body?.cancel().catch(() => {});
|
|
276618
|
-
if (!response.ok) return false;
|
|
276619
|
-
try { sessionStorage.removeItem(webSessionTokenKey); } catch {}
|
|
276620
|
-
webSessionToken = '';
|
|
276621
|
-
state.useBearerTransport = false;
|
|
276622
|
-
return true;
|
|
276623
|
-
})().finally(() => {
|
|
276694
|
+
sessionRecoveryPromise = bootstrapSession().finally(() => {
|
|
276624
276695
|
sessionRecoveryPromise = null;
|
|
276625
276696
|
});
|
|
276626
276697
|
return sessionRecoveryPromise;
|
|
@@ -276643,7 +276714,7 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
|
|
|
276643
276714
|
state.useBearerTransport = true;
|
|
276644
276715
|
response = await requestApi(true);
|
|
276645
276716
|
}
|
|
276646
|
-
if (response.status === 401 && await
|
|
276717
|
+
if (response.status === 401 && await recoverAuthenticatedSession()) {
|
|
276647
276718
|
await response.body?.cancel().catch(() => {});
|
|
276648
276719
|
response = await requestApi(false);
|
|
276649
276720
|
}
|
|
@@ -279758,7 +279829,7 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
279758
279829
|
state.eventRetryTimer = window.setTimeout(async () => {
|
|
279759
279830
|
state.eventRetryTimer = 0;
|
|
279760
279831
|
try {
|
|
279761
|
-
await
|
|
279832
|
+
await recoverAuthenticatedSession();
|
|
279762
279833
|
} catch {}
|
|
279763
279834
|
connectEvents();
|
|
279764
279835
|
}, delay);
|
|
@@ -280309,7 +280380,7 @@ function sanitizeActionResult(result) {
|
|
|
280309
280380
|
return result.message ? { ok: result.ok, message: safeWebMessage(result.message) } : { ok: result.ok };
|
|
280310
280381
|
}
|
|
280311
280382
|
function sanitizeProjectActionResult(result) {
|
|
280312
|
-
const url =
|
|
280383
|
+
const url = sanitizeLocalWebUiUrl(result.url);
|
|
280313
280384
|
return {
|
|
280314
280385
|
ok: result.ok,
|
|
280315
280386
|
...result.message ? { message: safeWebMessage(result.message) } : {},
|
|
@@ -280318,12 +280389,14 @@ function sanitizeProjectActionResult(result) {
|
|
|
280318
280389
|
...result.cancelled ? { cancelled: true } : {}
|
|
280319
280390
|
};
|
|
280320
280391
|
}
|
|
280321
|
-
function
|
|
280392
|
+
function sanitizeLocalWebUiUrl(value) {
|
|
280322
280393
|
if (typeof value !== "string") return void 0;
|
|
280323
280394
|
try {
|
|
280324
280395
|
const url = new URL(value);
|
|
280325
|
-
const
|
|
280326
|
-
|
|
280396
|
+
const fragment = new URLSearchParams(url.hash.slice(1));
|
|
280397
|
+
const tokens = fragment.getAll("token");
|
|
280398
|
+
const token = tokens.length === 1 ? tokens[0] : void 0;
|
|
280399
|
+
if (url.protocol !== "http:" || !["127.0.0.1", "::1", "localhost"].includes(url.hostname) || !/^\d{1,5}$/.test(url.port) || Number(url.port) < 1 || Number(url.port) > 65535 || url.username || url.password || url.pathname !== "/" || url.search || Array.from(fragment.keys()).length !== 1 || !token || !/^[A-Za-z0-9_-]{32,128}$/.test(token)) {
|
|
280327
280400
|
return void 0;
|
|
280328
280401
|
}
|
|
280329
280402
|
return url.href;
|
|
@@ -280351,7 +280424,7 @@ function webRequestErrorStatus(error) {
|
|
|
280351
280424
|
}
|
|
280352
280425
|
return 500;
|
|
280353
280426
|
}
|
|
280354
|
-
function
|
|
280427
|
+
function isNodeError2(error) {
|
|
280355
280428
|
return error instanceof Error;
|
|
280356
280429
|
}
|
|
280357
280430
|
function isRequestOriginAllowed(req) {
|
|
@@ -281144,7 +281217,7 @@ function sendJson(res, status, data) {
|
|
|
281144
281217
|
});
|
|
281145
281218
|
res.end(JSON.stringify(data));
|
|
281146
281219
|
}
|
|
281147
|
-
function sendHtml(res, status, body
|
|
281220
|
+
function sendHtml(res, status, body) {
|
|
281148
281221
|
const headers = {
|
|
281149
281222
|
"Content-Type": "text/html; charset=utf-8",
|
|
281150
281223
|
"Cache-Control": "no-store",
|
|
@@ -281154,8 +281227,6 @@ function sendHtml(res, status, body, sessionToken) {
|
|
|
281154
281227
|
"X-Content-Type-Options": "nosniff",
|
|
281155
281228
|
"X-Frame-Options": "DENY"
|
|
281156
281229
|
};
|
|
281157
|
-
if (sessionToken)
|
|
281158
|
-
headers["Set-Cookie"] = createWebSessionCookie(sessionToken);
|
|
281159
281230
|
res.writeHead(status, headers);
|
|
281160
281231
|
res.end(body);
|
|
281161
281232
|
}
|
|
@@ -281373,10 +281444,11 @@ var BASE_COPY = {
|
|
|
281373
281444
|
projects: "Projects",
|
|
281374
281445
|
recentProjects: "Recent projects",
|
|
281375
281446
|
newProject: "New project",
|
|
281376
|
-
projectDialogTitle: "Open a project",
|
|
281377
|
-
projectDialogBody: "
|
|
281447
|
+
projectDialogTitle: "Open or create a project",
|
|
281448
|
+
projectDialogBody: "Choose an existing folder, or enter the absolute path of a new folder. Orbit opens it in a separate local tab with its own chats and context.",
|
|
281378
281449
|
projectPath: "Project folder path",
|
|
281379
281450
|
projectPathPlaceholder: "C:\\path\\to\\project",
|
|
281451
|
+
browseProject: "Browse folders",
|
|
281380
281452
|
openProject: "Open folder",
|
|
281381
281453
|
createProject: "Create & open",
|
|
281382
281454
|
recentTasks: "Chats",
|
|
@@ -281545,10 +281617,11 @@ var BASE_COPY = {
|
|
|
281545
281617
|
projects: "\u9879\u76EE",
|
|
281546
281618
|
recentProjects: "\u6700\u8FD1\u9879\u76EE",
|
|
281547
281619
|
newProject: "\u65B0\u5EFA\u9879\u76EE",
|
|
281548
|
-
projectDialogTitle: "\u6253\u5F00\u9879\u76EE",
|
|
281549
|
-
projectDialogBody: "\
|
|
281620
|
+
projectDialogTitle: "\u6253\u5F00\u6216\u521B\u5EFA\u9879\u76EE",
|
|
281621
|
+
projectDialogBody: "\u6D4F\u89C8\u9009\u62E9\u5DF2\u6709\u6587\u4EF6\u5939\uFF0C\u6216\u8F93\u5165\u65B0\u6587\u4EF6\u5939\u7684\u7EDD\u5BF9\u8DEF\u5F84\u3002Orbit \u4F1A\u5728\u65B0\u7684\u672C\u5730\u6807\u7B7E\u9875\u6253\u5F00\uFF0C\u5E76\u4FDD\u7559\u72EC\u7ACB\u7684\u804A\u5929\u548C\u4E0A\u4E0B\u6587\u3002",
|
|
281550
281622
|
projectPath: "\u9879\u76EE\u6587\u4EF6\u5939\u8DEF\u5F84",
|
|
281551
281623
|
projectPathPlaceholder: "C:\\\u8DEF\u5F84\\\u9879\u76EE\u540D\u79F0",
|
|
281624
|
+
browseProject: "\u6D4F\u89C8\u6587\u4EF6\u5939",
|
|
281552
281625
|
openProject: "\u6253\u5F00\u6587\u4EF6\u5939",
|
|
281553
281626
|
createProject: "\u521B\u5EFA\u5E76\u6253\u5F00",
|
|
281554
281627
|
recentTasks: "\u5BF9\u8BDD",
|
|
@@ -281721,9 +281794,10 @@ var COPY = {
|
|
|
281721
281794
|
projects: "\u5C08\u6848",
|
|
281722
281795
|
recentProjects: "\u6700\u8FD1\u5C08\u6848",
|
|
281723
281796
|
newProject: "\u65B0\u589E\u5C08\u6848",
|
|
281724
|
-
projectDialogTitle: "\u958B\u555F\u5C08\u6848",
|
|
281725
|
-
projectDialogBody: "\
|
|
281797
|
+
projectDialogTitle: "\u958B\u555F\u6216\u5EFA\u7ACB\u5C08\u6848",
|
|
281798
|
+
projectDialogBody: "\u700F\u89BD\u9078\u64C7\u73FE\u6709\u8CC7\u6599\u593E\uFF0C\u6216\u8F38\u5165\u65B0\u8CC7\u6599\u593E\u7684\u7D55\u5C0D\u8DEF\u5F91\u3002Orbit \u6703\u5728\u65B0\u7684\u672C\u6A5F\u5206\u9801\u958B\u555F\uFF0C\u4E26\u4FDD\u7559\u7368\u7ACB\u7684\u804A\u5929\u548C\u4E0A\u4E0B\u6587\u3002",
|
|
281726
281799
|
projectPath: "\u5C08\u6848\u8CC7\u6599\u593E\u8DEF\u5F91",
|
|
281800
|
+
browseProject: "\u700F\u89BD\u8CC7\u6599\u593E",
|
|
281727
281801
|
openProject: "\u958B\u555F\u8CC7\u6599\u593E",
|
|
281728
281802
|
createProject: "\u5EFA\u7ACB\u4E26\u958B\u555F",
|
|
281729
281803
|
recentTasks: "\u5C0D\u8A71",
|
|
@@ -282425,10 +282499,13 @@ function renderWebUiPage(language) {
|
|
|
282425
282499
|
<p id="projectDialogBody">${copy.projectDialogBody}</p>
|
|
282426
282500
|
</div>
|
|
282427
282501
|
</div>
|
|
282428
|
-
<
|
|
282429
|
-
<
|
|
282430
|
-
<
|
|
282431
|
-
|
|
282502
|
+
<div class="project-path-field">
|
|
282503
|
+
<label for="projectPathInput">${copy.projectPath}</label>
|
|
282504
|
+
<div class="project-path-control">
|
|
282505
|
+
<input id="projectPathInput" type="text" maxlength="4096" autocomplete="off" spellcheck="false" placeholder="${copy.projectPathPlaceholder}" />
|
|
282506
|
+
<button class="project-dialog-browse" id="projectDialogBrowse" type="button">${copy.browseProject}</button>
|
|
282507
|
+
</div>
|
|
282508
|
+
</div>
|
|
282432
282509
|
<div class="project-dialog-actions">
|
|
282433
282510
|
<button class="project-dialog-cancel" id="projectDialogCancel" type="button">${copy.cancel}</button>
|
|
282434
282511
|
<button class="project-dialog-open" id="projectDialogOpen" type="button">${copy.openProject}</button>
|
|
@@ -284754,12 +284831,19 @@ var WEB_UI_FEEDBACK_STYLES = String.raw`
|
|
|
284754
284831
|
gap: 7px;
|
|
284755
284832
|
}
|
|
284756
284833
|
|
|
284757
|
-
.project-path-field
|
|
284834
|
+
.project-path-field > label {
|
|
284758
284835
|
color: var(--muted);
|
|
284759
284836
|
font-size: 11px;
|
|
284760
284837
|
font-weight: 650;
|
|
284761
284838
|
}
|
|
284762
284839
|
|
|
284840
|
+
.project-path-control {
|
|
284841
|
+
min-width: 0;
|
|
284842
|
+
display: grid;
|
|
284843
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
284844
|
+
gap: 8px;
|
|
284845
|
+
}
|
|
284846
|
+
|
|
284763
284847
|
.project-path-field input {
|
|
284764
284848
|
width: 100%;
|
|
284765
284849
|
min-width: 0;
|
|
@@ -284778,6 +284862,28 @@ var WEB_UI_FEEDBACK_STYLES = String.raw`
|
|
|
284778
284862
|
border-color: color-mix(in srgb, var(--accent) 48%, var(--border));
|
|
284779
284863
|
}
|
|
284780
284864
|
|
|
284865
|
+
.project-dialog-browse {
|
|
284866
|
+
min-height: 42px;
|
|
284867
|
+
padding: 0 13px;
|
|
284868
|
+
color: var(--ink);
|
|
284869
|
+
background: var(--surface-subtle);
|
|
284870
|
+
border: 1px solid var(--border-strong);
|
|
284871
|
+
border-radius: 10px;
|
|
284872
|
+
font-size: 12px;
|
|
284873
|
+
font-weight: 620;
|
|
284874
|
+
white-space: nowrap;
|
|
284875
|
+
}
|
|
284876
|
+
|
|
284877
|
+
.project-dialog-browse:hover {
|
|
284878
|
+
background: var(--surface-hover);
|
|
284879
|
+
}
|
|
284880
|
+
|
|
284881
|
+
.project-dialog-browse:focus-visible,
|
|
284882
|
+
.project-dialog-actions button:focus-visible {
|
|
284883
|
+
outline: 2px solid color-mix(in srgb, var(--accent) 62%, transparent);
|
|
284884
|
+
outline-offset: 2px;
|
|
284885
|
+
}
|
|
284886
|
+
|
|
284781
284887
|
.project-dialog-actions {
|
|
284782
284888
|
display: flex;
|
|
284783
284889
|
justify-content: flex-end;
|
|
@@ -284805,7 +284911,8 @@ var WEB_UI_FEEDBACK_STYLES = String.raw`
|
|
|
284805
284911
|
border: 1px solid var(--accent-strong);
|
|
284806
284912
|
}
|
|
284807
284913
|
|
|
284808
|
-
.project-dialog-actions button:disabled
|
|
284914
|
+
.project-dialog-actions button:disabled,
|
|
284915
|
+
.project-dialog-browse:disabled {
|
|
284809
284916
|
cursor: wait;
|
|
284810
284917
|
opacity: 0.55;
|
|
284811
284918
|
}
|
|
@@ -287047,6 +287154,14 @@ var WEB_UI_RESPONSIVE_STYLES = String.raw`
|
|
|
287047
287154
|
grid-template-columns: 1fr 1fr;
|
|
287048
287155
|
}
|
|
287049
287156
|
|
|
287157
|
+
.project-path-control {
|
|
287158
|
+
grid-template-columns: 1fr;
|
|
287159
|
+
}
|
|
287160
|
+
|
|
287161
|
+
.project-dialog-browse {
|
|
287162
|
+
width: 100%;
|
|
287163
|
+
}
|
|
287164
|
+
|
|
287050
287165
|
.project-dialog-cancel {
|
|
287051
287166
|
grid-column: 1 / -1;
|
|
287052
287167
|
grid-row: 2;
|
|
@@ -288928,6 +289043,7 @@ var OrbitWebUiRuntime = class {
|
|
|
288928
289043
|
state = "idle";
|
|
288929
289044
|
token;
|
|
288930
289045
|
activeTurn;
|
|
289046
|
+
projectActionPending = false;
|
|
288931
289047
|
server;
|
|
288932
289048
|
handle;
|
|
288933
289049
|
stopPromise;
|
|
@@ -288999,7 +289115,7 @@ var OrbitWebUiRuntime = class {
|
|
|
288999
289115
|
return handle;
|
|
289000
289116
|
} catch (error) {
|
|
289001
289117
|
lastError = error;
|
|
289002
|
-
if (!
|
|
289118
|
+
if (!isNodeError2(error) || error.code !== "EADDRINUSE" || preferredPort === 0) {
|
|
289003
289119
|
this.token = void 0;
|
|
289004
289120
|
this.state = "stopped";
|
|
289005
289121
|
throw error;
|
|
@@ -289049,7 +289165,7 @@ var OrbitWebUiRuntime = class {
|
|
|
289049
289165
|
}
|
|
289050
289166
|
const url = new URL(req.url || "/", "http://127.0.0.1");
|
|
289051
289167
|
if (req.method === "GET" && url.pathname === "/") {
|
|
289052
|
-
sendHtml(res, 200, renderWebUiPage(options.config.language)
|
|
289168
|
+
sendHtml(res, 200, renderWebUiPage(options.config.language));
|
|
289053
289169
|
return;
|
|
289054
289170
|
}
|
|
289055
289171
|
if (req.method === "GET" && url.pathname === "/assets/orbit.css") {
|
|
@@ -289345,14 +289461,26 @@ var OrbitWebUiRuntime = class {
|
|
|
289345
289461
|
}
|
|
289346
289462
|
try {
|
|
289347
289463
|
const action = ProjectActionSchema.parse(await readJsonBody(req));
|
|
289348
|
-
|
|
289349
|
-
|
|
289350
|
-
|
|
289351
|
-
|
|
289352
|
-
|
|
289353
|
-
|
|
289354
|
-
|
|
289355
|
-
|
|
289464
|
+
if (this.projectActionPending) {
|
|
289465
|
+
sendJson(res, 409, {
|
|
289466
|
+
ok: false,
|
|
289467
|
+
message: "Another project action is already in progress."
|
|
289468
|
+
});
|
|
289469
|
+
return;
|
|
289470
|
+
}
|
|
289471
|
+
this.projectActionPending = true;
|
|
289472
|
+
try {
|
|
289473
|
+
const result = sanitizeProjectActionResult(
|
|
289474
|
+
await options.openProject(action)
|
|
289475
|
+
);
|
|
289476
|
+
sendJson(
|
|
289477
|
+
res,
|
|
289478
|
+
result.ok ? action.action === "remove" || action.action === "pick" ? 200 : 202 : 409,
|
|
289479
|
+
result
|
|
289480
|
+
);
|
|
289481
|
+
} finally {
|
|
289482
|
+
this.projectActionPending = false;
|
|
289483
|
+
}
|
|
289356
289484
|
} catch (error) {
|
|
289357
289485
|
sendJson(res, webRequestErrorStatus(error), {
|
|
289358
289486
|
ok: false,
|
|
@@ -291460,7 +291588,7 @@ function copyBooleanCapability(source, sourceKey, target, targetKey) {
|
|
|
291460
291588
|
// src/runtime/ProjectLauncher.ts
|
|
291461
291589
|
import { spawn as spawn3 } from "child_process";
|
|
291462
291590
|
import { existsSync as existsSync17, mkdirSync as mkdirSync6, realpathSync as realpathSync3, statSync as statSync4 } from "fs";
|
|
291463
|
-
import { isAbsolute as isAbsolute7, parse as parse4, resolve as resolve11 } from "path";
|
|
291591
|
+
import { dirname as dirname9, isAbsolute as isAbsolute7, parse as parse4, resolve as resolve11 } from "path";
|
|
291464
291592
|
var PROJECT_WEB_UI_READY_MESSAGE = "orbit-webui-ready";
|
|
291465
291593
|
async function launchOrbitProject(request, options = {}) {
|
|
291466
291594
|
if (!isAbsolute7(request.path)) {
|
|
@@ -291470,19 +291598,14 @@ async function launchOrbitProject(request, options = {}) {
|
|
|
291470
291598
|
if (requestedPath === parse4(requestedPath).root) {
|
|
291471
291599
|
throw new Error("A filesystem root cannot be opened as an Orbit project.");
|
|
291472
291600
|
}
|
|
291473
|
-
if (!existsSync17(requestedPath)) {
|
|
291474
|
-
if (request.action !== "create") {
|
|
291475
|
-
throw new Error("Project folder does not exist.");
|
|
291476
|
-
}
|
|
291477
|
-
mkdirSync6(requestedPath, { recursive: true });
|
|
291478
|
-
}
|
|
291479
|
-
if (!statSync4(requestedPath).isDirectory()) {
|
|
291480
|
-
throw new Error("Project path must point to a directory.");
|
|
291481
|
-
}
|
|
291482
|
-
const projectPath = realpathSync3(requestedPath);
|
|
291483
|
-
(options.registry || new ProjectRegistry()).register(projectPath);
|
|
291484
291601
|
const entryPoint = options.entryPoint || process.argv[1];
|
|
291485
291602
|
if (!entryPoint) throw new Error("Orbit CLI entry point is unavailable.");
|
|
291603
|
+
if (request.action === "create") {
|
|
291604
|
+
createProjectDirectory(requestedPath);
|
|
291605
|
+
} else {
|
|
291606
|
+
requireProjectDirectory(requestedPath);
|
|
291607
|
+
}
|
|
291608
|
+
const projectPath = realpathSync3(requestedPath);
|
|
291486
291609
|
const launch = options.launch || spawn3;
|
|
291487
291610
|
const child = launch(
|
|
291488
291611
|
options.executable || process.execPath,
|
|
@@ -291552,17 +291675,45 @@ function parseReadyUrl(message2) {
|
|
|
291552
291675
|
if (typeof message2 !== "object" || message2 === null || !("type" in message2) || !("url" in message2) || message2.type !== PROJECT_WEB_UI_READY_MESSAGE || typeof message2.url !== "string") {
|
|
291553
291676
|
return void 0;
|
|
291554
291677
|
}
|
|
291678
|
+
return sanitizeLocalWebUiUrl(message2.url);
|
|
291679
|
+
}
|
|
291680
|
+
function createProjectDirectory(projectPath) {
|
|
291681
|
+
if (existsSync17(projectPath)) {
|
|
291682
|
+
throw new Error("Project folder already exists. Use Open folder instead.");
|
|
291683
|
+
}
|
|
291684
|
+
const parentPath = dirname9(projectPath);
|
|
291685
|
+
if (!existsSync17(parentPath)) {
|
|
291686
|
+
throw new Error(
|
|
291687
|
+
"The parent folder does not exist. Choose an existing location first."
|
|
291688
|
+
);
|
|
291689
|
+
}
|
|
291690
|
+
if (!statSync4(parentPath).isDirectory()) {
|
|
291691
|
+
throw new Error("The project parent path must be a directory.");
|
|
291692
|
+
}
|
|
291555
291693
|
try {
|
|
291556
|
-
|
|
291557
|
-
|
|
291558
|
-
if (
|
|
291559
|
-
|
|
291694
|
+
mkdirSync6(projectPath);
|
|
291695
|
+
} catch (error) {
|
|
291696
|
+
if (isNodeError3(error) && error.code === "EEXIST") {
|
|
291697
|
+
throw new Error(
|
|
291698
|
+
"Project folder already exists. Use Open folder instead."
|
|
291699
|
+
);
|
|
291560
291700
|
}
|
|
291561
|
-
|
|
291562
|
-
|
|
291563
|
-
|
|
291701
|
+
throw new Error("Orbit could not create the project folder.", {
|
|
291702
|
+
cause: error
|
|
291703
|
+
});
|
|
291704
|
+
}
|
|
291705
|
+
}
|
|
291706
|
+
function requireProjectDirectory(projectPath) {
|
|
291707
|
+
if (!existsSync17(projectPath)) {
|
|
291708
|
+
throw new Error("Project folder does not exist.");
|
|
291709
|
+
}
|
|
291710
|
+
if (!statSync4(projectPath).isDirectory()) {
|
|
291711
|
+
throw new Error("Project path must point to a directory.");
|
|
291564
291712
|
}
|
|
291565
291713
|
}
|
|
291714
|
+
function isNodeError3(error) {
|
|
291715
|
+
return error instanceof Error;
|
|
291716
|
+
}
|
|
291566
291717
|
|
|
291567
291718
|
// src/runtime/ProjectFolderPicker.ts
|
|
291568
291719
|
import { execFile as execFile5 } from "child_process";
|
|
@@ -292484,13 +292635,20 @@ var CommandRouter = class {
|
|
|
292484
292635
|
message: removed ? "Project was removed from Orbit. Files were not deleted." : "Project is no longer registered."
|
|
292485
292636
|
};
|
|
292486
292637
|
}
|
|
292487
|
-
|
|
292488
|
-
|
|
292489
|
-
|
|
292490
|
-
|
|
292491
|
-
|
|
292492
|
-
|
|
292493
|
-
|
|
292638
|
+
try {
|
|
292639
|
+
const launched = await launchOrbitProject(action);
|
|
292640
|
+
this.onProjectHandoff?.();
|
|
292641
|
+
return {
|
|
292642
|
+
ok: true,
|
|
292643
|
+
message: `Opening Orbit project: ${launched.path}`,
|
|
292644
|
+
url: launched.url
|
|
292645
|
+
};
|
|
292646
|
+
} catch (error) {
|
|
292647
|
+
return {
|
|
292648
|
+
ok: false,
|
|
292649
|
+
message: error instanceof Error ? error.message : "Orbit could not open the selected project."
|
|
292650
|
+
};
|
|
292651
|
+
}
|
|
292494
292652
|
},
|
|
292495
292653
|
getPendingApproval: () => this.webApprovalBroker.getPending(),
|
|
292496
292654
|
respondToApproval: (decision2) => this.webApprovalBroker.respond(decision2),
|
|
@@ -294256,7 +294414,7 @@ Risk Warning: ${reason}`);
|
|
|
294256
294414
|
});
|
|
294257
294415
|
const normCwd = resolve12(this.cwd).toLowerCase().replace(/\\/g, "/");
|
|
294258
294416
|
const normHome = resolve12(homedir10()).toLowerCase().replace(/\\/g, "/");
|
|
294259
|
-
const isHomeOrRoot = normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) ||
|
|
294417
|
+
const isHomeOrRoot = normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname10(normCwd) === normCwd;
|
|
294260
294418
|
if (!isHomeOrRoot) {
|
|
294261
294419
|
const indexer = new SymbolIndexer(this.cwd);
|
|
294262
294420
|
this.watcher = watch(
|
|
@@ -295672,7 +295830,7 @@ import {
|
|
|
295672
295830
|
rmSync as rmSync7,
|
|
295673
295831
|
writeFileSync as writeFileSync8
|
|
295674
295832
|
} from "fs";
|
|
295675
|
-
import { dirname as
|
|
295833
|
+
import { dirname as dirname11, resolve as resolve13 } from "path";
|
|
295676
295834
|
import { randomUUID as randomUUID12 } from "crypto";
|
|
295677
295835
|
import { z as z68 } from "zod";
|
|
295678
295836
|
var TraceOptionsSchema = z68.object({
|
|
@@ -295692,7 +295850,7 @@ function runTraceExport(cwd, sessionId, options = {}) {
|
|
|
295692
295850
|
return void 0;
|
|
295693
295851
|
}
|
|
295694
295852
|
const outputPath = resolveSafePath(cwd, value.out);
|
|
295695
|
-
const directory =
|
|
295853
|
+
const directory = dirname11(outputPath);
|
|
295696
295854
|
if (existsSync18(directory)) {
|
|
295697
295855
|
const stats = lstatSync6(directory);
|
|
295698
295856
|
if (stats.isSymbolicLink() || !stats.isDirectory()) {
|
|
@@ -295727,7 +295885,7 @@ import {
|
|
|
295727
295885
|
rmSync as rmSync8,
|
|
295728
295886
|
writeFileSync as writeFileSync9
|
|
295729
295887
|
} from "fs";
|
|
295730
|
-
import { basename as basename5, dirname as
|
|
295888
|
+
import { basename as basename5, dirname as dirname12, join as join17 } from "path";
|
|
295731
295889
|
import { randomUUID as randomUUID13 } from "crypto";
|
|
295732
295890
|
import { promisify as promisify5 } from "util";
|
|
295733
295891
|
import picocolors25 from "picocolors";
|
|
@@ -295986,7 +296144,7 @@ function snapshotWorkspaceIntoWorktree(sourceCwd, worktreeCwd) {
|
|
|
295986
296144
|
const targetPath = resolveSafePath(worktreeCwd, relativePath);
|
|
295987
296145
|
const stats = lstatSync7(sourcePath);
|
|
295988
296146
|
if (stats.isSymbolicLink() || !stats.isFile()) continue;
|
|
295989
|
-
mkdirSync8(
|
|
296147
|
+
mkdirSync8(dirname12(targetPath), { recursive: true });
|
|
295990
296148
|
copyFileSync(sourcePath, targetPath);
|
|
295991
296149
|
}
|
|
295992
296150
|
execFileSync7("git", ["add", "-A"], {
|
|
@@ -296045,7 +296203,7 @@ function writeEvaluationReport(cwd, runId, report) {
|
|
|
296045
296203
|
return filePath;
|
|
296046
296204
|
}
|
|
296047
296205
|
function writeJsonAtomically2(filePath, value) {
|
|
296048
|
-
const directory =
|
|
296206
|
+
const directory = dirname12(filePath);
|
|
296049
296207
|
if (existsSync19(directory)) {
|
|
296050
296208
|
const stats = lstatSync7(directory);
|
|
296051
296209
|
if (stats.isSymbolicLink() || !stats.isDirectory()) {
|
|
@@ -296341,7 +296499,7 @@ import {
|
|
|
296341
296499
|
writeFileSync as writeFileSync10
|
|
296342
296500
|
} from "fs";
|
|
296343
296501
|
import { createHash as createHash8, randomUUID as randomUUID14 } from "crypto";
|
|
296344
|
-
import { dirname as
|
|
296502
|
+
import { dirname as dirname13, isAbsolute as isAbsolute8, join as join19, relative as relative9, resolve as resolve16, sep as sep2 } from "path";
|
|
296345
296503
|
import { z as z74 } from "zod";
|
|
296346
296504
|
var MAX_BACKUP_BYTES = 64 * 1024 * 1024;
|
|
296347
296505
|
var MAX_SERIALIZED_BACKUP_BYTES = 96 * 1024 * 1024;
|
|
@@ -296450,7 +296608,7 @@ function createProjectBackup(projectDirectory) {
|
|
|
296450
296608
|
}
|
|
296451
296609
|
function writeProjectBackup(outputPath, bundle) {
|
|
296452
296610
|
const destination = resolve16(outputPath);
|
|
296453
|
-
mkdirSync9(
|
|
296611
|
+
mkdirSync9(dirname13(destination), { recursive: true });
|
|
296454
296612
|
const temporaryPath = `${destination}.${process.pid}.${randomUUID14()}.tmp`;
|
|
296455
296613
|
try {
|
|
296456
296614
|
writeFileSync10(
|
|
@@ -296495,8 +296653,8 @@ function restoreProjectBackup(projectDirectory, bundle, options = {}) {
|
|
|
296495
296653
|
}
|
|
296496
296654
|
const restored = [];
|
|
296497
296655
|
for (const { file, destination } of planned) {
|
|
296498
|
-
assertDirectoryChainHasNoSymlink(orbitRoot,
|
|
296499
|
-
mkdirSync9(
|
|
296656
|
+
assertDirectoryChainHasNoSymlink(orbitRoot, dirname13(destination));
|
|
296657
|
+
mkdirSync9(dirname13(destination), { recursive: true });
|
|
296500
296658
|
const temporaryPath = `${destination}.${process.pid}.${randomUUID14()}.tmp`;
|
|
296501
296659
|
try {
|
|
296502
296660
|
writeFileSync10(temporaryPath, Buffer.from(file.content, "base64"), {
|
|
@@ -296716,7 +296874,7 @@ import {
|
|
|
296716
296874
|
writeFileSync as writeFileSync11
|
|
296717
296875
|
} from "fs";
|
|
296718
296876
|
import { randomUUID as randomUUID15 } from "crypto";
|
|
296719
|
-
import { dirname as
|
|
296877
|
+
import { dirname as dirname14, isAbsolute as isAbsolute9, join as join20, relative as relative10, resolve as resolve18, sep as sep3 } from "path";
|
|
296720
296878
|
import { homedir as homedir12 } from "os";
|
|
296721
296879
|
import { z as z76 } from "zod";
|
|
296722
296880
|
var InstalledExtensionSchema2 = z76.object({
|
|
@@ -296755,7 +296913,7 @@ var ExtensionManager = class {
|
|
|
296755
296913
|
install(cwd, manifestPath, options = {}) {
|
|
296756
296914
|
const manifest = loadOrbitExtensionManifest(cwd, manifestPath);
|
|
296757
296915
|
verifyOrbitCompatibility(manifest, readCliVersion());
|
|
296758
|
-
const sourceRoot =
|
|
296916
|
+
const sourceRoot = dirname14(resolve18(cwd, manifestPath));
|
|
296759
296917
|
validateContributionFiles(sourceRoot, manifest);
|
|
296760
296918
|
validateContributionPermissions(manifest);
|
|
296761
296919
|
const requiresTrust = extensionRequiresTrust(manifest);
|
|
@@ -296805,7 +296963,7 @@ var ExtensionManager = class {
|
|
|
296805
296963
|
}
|
|
296806
296964
|
for (const prompt of promptTargets) {
|
|
296807
296965
|
if (!existsSync21(prompt.target)) continue;
|
|
296808
|
-
mkdirSync10(
|
|
296966
|
+
mkdirSync10(dirname14(prompt.backup), { recursive: true });
|
|
296809
296967
|
renameSync7(prompt.target, prompt.backup);
|
|
296810
296968
|
prompt.backedUp = true;
|
|
296811
296969
|
}
|
|
@@ -296848,7 +297006,7 @@ var ExtensionManager = class {
|
|
|
296848
297006
|
rmSync11(prompt.target, { recursive: true, force: true });
|
|
296849
297007
|
}
|
|
296850
297008
|
if (prompt.backedUp && existsSync21(prompt.backup)) {
|
|
296851
|
-
mkdirSync10(
|
|
297009
|
+
mkdirSync10(dirname14(prompt.target), { recursive: true });
|
|
296852
297010
|
renameSync7(prompt.backup, prompt.target);
|
|
296853
297011
|
}
|
|
296854
297012
|
}
|
|
@@ -296896,7 +297054,7 @@ var ExtensionManager = class {
|
|
|
296896
297054
|
try {
|
|
296897
297055
|
for (const entry of targets) {
|
|
296898
297056
|
if (!existsSync21(entry.target)) continue;
|
|
296899
|
-
mkdirSync10(
|
|
297057
|
+
mkdirSync10(dirname14(entry.backup), { recursive: true });
|
|
296900
297058
|
renameSync7(entry.target, entry.backup);
|
|
296901
297059
|
entry.backedUp = true;
|
|
296902
297060
|
}
|
|
@@ -296907,7 +297065,7 @@ var ExtensionManager = class {
|
|
|
296907
297065
|
try {
|
|
296908
297066
|
for (const entry of targets) {
|
|
296909
297067
|
if (!entry.backedUp || !existsSync21(entry.backup)) continue;
|
|
296910
|
-
mkdirSync10(
|
|
297068
|
+
mkdirSync10(dirname14(entry.target), { recursive: true });
|
|
296911
297069
|
renameSync7(entry.backup, entry.target);
|
|
296912
297070
|
}
|
|
296913
297071
|
rmSync11(rollbackRoot, { recursive: true, force: true });
|
|
@@ -297077,7 +297235,7 @@ function copyDirectoryEntry(source, target, budget, depth) {
|
|
|
297077
297235
|
if (budget.bytes > MAX_EXTENSION_TREE_BYTES) {
|
|
297078
297236
|
throw new Error("Extension tree exceeds the 256 MiB limit.");
|
|
297079
297237
|
}
|
|
297080
|
-
mkdirSync10(
|
|
297238
|
+
mkdirSync10(dirname14(target), { recursive: true });
|
|
297081
297239
|
writeFileSync11(target, data, { mode: 384 });
|
|
297082
297240
|
}
|
|
297083
297241
|
function materializePromptContributions(extensionRoot, manifest, orbitDir) {
|