offsite 0.0.42 → 0.0.43
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.
|
@@ -5,7 +5,7 @@ import path from "node:path";
|
|
|
5
5
|
import { consola } from "consola";
|
|
6
6
|
import { WebSocketServer } from "ws";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
import os
|
|
8
|
+
import os from "node:os";
|
|
9
9
|
import { deleteSession, forkSession, getSessionInfo, getSessionMessages, getSubagentMessages, listSessions, query, renameSession } from "@anthropic-ai/claude-agent-sdk";
|
|
10
10
|
import { execFile, spawn } from "node:child_process";
|
|
11
11
|
import readline from "node:readline";
|
|
@@ -955,6 +955,10 @@ function platform() {
|
|
|
955
955
|
function claudeBaseDir() {
|
|
956
956
|
return readConfig().claudeBaseDir[platform()] ?? path.join(os.homedir(), ".claude");
|
|
957
957
|
}
|
|
958
|
+
function workingDirectory() {
|
|
959
|
+
const dir = readConfig().workingDir[platform()] ?? "~";
|
|
960
|
+
return dir.startsWith("~") ? path.join(os.homedir(), dir.slice(1)) : dir;
|
|
961
|
+
}
|
|
958
962
|
function defaultShell() {
|
|
959
963
|
if (process.platform === "win32") return process.env.COMSPEC ?? "cmd.exe";
|
|
960
964
|
return os.userInfo().shell ?? "/bin/sh";
|
|
@@ -3314,6 +3318,7 @@ const CAN = 24;
|
|
|
3314
3318
|
const SUB = 26;
|
|
3315
3319
|
var Scanner = class {
|
|
3316
3320
|
title = "";
|
|
3321
|
+
directory = null;
|
|
3317
3322
|
state = "ground";
|
|
3318
3323
|
payload = [];
|
|
3319
3324
|
scan(bytes) {
|
|
@@ -3390,6 +3395,10 @@ var Scanner = class {
|
|
|
3390
3395
|
this.title = text.slice(2);
|
|
3391
3396
|
return null;
|
|
3392
3397
|
}
|
|
3398
|
+
if (text.startsWith("9;9;")) {
|
|
3399
|
+
this.directory = text.slice(4).replace(/^"(.*)"$/, "$1");
|
|
3400
|
+
return null;
|
|
3401
|
+
}
|
|
3393
3402
|
if (text.startsWith("9;")) {
|
|
3394
3403
|
const body = text.slice(2);
|
|
3395
3404
|
const digits = /^\d*/.exec(body)?.[0].length ?? 0;
|
|
@@ -3710,7 +3719,7 @@ function startShell(cwd) {
|
|
|
3710
3719
|
encoding: null
|
|
3711
3720
|
});
|
|
3712
3721
|
}
|
|
3713
|
-
async function currentDirectory(pid) {
|
|
3722
|
+
async function currentDirectory(pid, reported) {
|
|
3714
3723
|
if (process.platform === "linux") return readlink(`/proc/${pid}/cwd`);
|
|
3715
3724
|
if (process.platform === "darwin") {
|
|
3716
3725
|
const { stdout } = await run("lsof", [
|
|
@@ -3725,6 +3734,10 @@ async function currentDirectory(pid) {
|
|
|
3725
3734
|
if (line === void 0) throw new Error(`lsof found no folder for ${pid}`);
|
|
3726
3735
|
return line.slice(1);
|
|
3727
3736
|
}
|
|
3737
|
+
if (process.platform === "win32") {
|
|
3738
|
+
if (reported === null || !statSync(reported, { throwIfNoEntry: false })?.isDirectory()) throw new Error(`the shell reported no existing folder, it reported ${reported}`);
|
|
3739
|
+
return reported;
|
|
3740
|
+
}
|
|
3728
3741
|
throw new Error("reading the directory of another process is not supported on this platform");
|
|
3729
3742
|
}
|
|
3730
3743
|
async function busyProgram(pid) {
|
|
@@ -3835,12 +3848,6 @@ const OUTPUT_LIMIT$1 = 1048576;
|
|
|
3835
3848
|
const STALL_LIMIT = 1e4;
|
|
3836
3849
|
const SILENCE_LIMIT$1 = 9e4;
|
|
3837
3850
|
const KILL_DELAY = 3e3;
|
|
3838
|
-
const pasteTypes = {
|
|
3839
|
-
"image/png": "png",
|
|
3840
|
-
"image/jpeg": "jpg",
|
|
3841
|
-
"image/gif": "gif",
|
|
3842
|
-
"image/webp": "webp"
|
|
3843
|
-
};
|
|
3844
3851
|
const instance = `${Date.now()}-${randomUUID()}`;
|
|
3845
3852
|
const projects = /* @__PURE__ */ new Map();
|
|
3846
3853
|
const terminals = /* @__PURE__ */ new Map();
|
|
@@ -3894,15 +3901,6 @@ function closeProjectTabs(projectId) {
|
|
|
3894
3901
|
for (const tab of [...project.tabs]) closeTab(tab.id);
|
|
3895
3902
|
publish();
|
|
3896
3903
|
}
|
|
3897
|
-
function savePastedImage(type, data) {
|
|
3898
|
-
const extension = pasteTypes[type];
|
|
3899
|
-
if (extension === void 0) throw new Error("pasted image must be a PNG, JPEG, GIF or WebP image");
|
|
3900
|
-
const directory = path.join(home, "paste");
|
|
3901
|
-
mkdirSync(directory, { recursive: true });
|
|
3902
|
-
const file = path.join(directory, `${Date.now()}-${randomUUID()}.${extension}`);
|
|
3903
|
-
writeFileSync(file, data);
|
|
3904
|
-
return file;
|
|
3905
|
-
}
|
|
3906
3904
|
function attach(client) {
|
|
3907
3905
|
detachTerminal(client);
|
|
3908
3906
|
const connection = {
|
|
@@ -3999,7 +3997,7 @@ function input(connection, bytes) {
|
|
|
3999
3997
|
terminal.pty.write(Buffer.from(frame.data));
|
|
4000
3998
|
}
|
|
4001
3999
|
async function createTab(projectId) {
|
|
4002
|
-
const cwd = projectId === "global" ?
|
|
4000
|
+
const cwd = projectId === "global" ? workingDirectory() : projectPath(projectId);
|
|
4003
4001
|
if (!statSync(cwd, { throwIfNoEntry: false })?.isDirectory()) {
|
|
4004
4002
|
console.error(`${cwd} is not a folder, terminal not created`);
|
|
4005
4003
|
return;
|
|
@@ -4012,7 +4010,7 @@ async function createTab(projectId) {
|
|
|
4012
4010
|
const active = project.activeTab === null ? void 0 : terminals.get(project.activeTab);
|
|
4013
4011
|
let directory = cwd;
|
|
4014
4012
|
if (active !== void 0) try {
|
|
4015
|
-
directory = await currentDirectory(active.pty.pid);
|
|
4013
|
+
directory = await currentDirectory(active.pty.pid, active.scanner.directory);
|
|
4016
4014
|
} catch (error) {
|
|
4017
4015
|
console.warn(`starting in the project folder, could not read the folder of the active terminal: ${error}`);
|
|
4018
4016
|
}
|
|
@@ -4111,12 +4109,8 @@ function drain() {
|
|
|
4111
4109
|
}, 10);
|
|
4112
4110
|
}
|
|
4113
4111
|
function scan(id, terminal, data) {
|
|
4114
|
-
if (!pushActive()) {
|
|
4115
|
-
terminal.scanner = new Scanner();
|
|
4116
|
-
return;
|
|
4117
|
-
}
|
|
4118
4112
|
const alert = terminal.scanner.scan(data);
|
|
4119
|
-
if (alert === null || notifierWatching()) return;
|
|
4113
|
+
if (!pushActive() || alert === null || notifierWatching()) return;
|
|
4120
4114
|
if (!(alert.type === "bell" ? terminal.alerts.startBell() : terminal.alerts.startNotification())) return;
|
|
4121
4115
|
const windowTitle = terminal.scanner.title;
|
|
4122
4116
|
setTimeout(() => push(id, alert, windowTitle), 500);
|
|
@@ -6404,6 +6398,23 @@ async function changedElsewhere(run, cwd) {
|
|
|
6404
6398
|
return last !== void 0 && !run.messages.some((item) => item.uuid === last);
|
|
6405
6399
|
}
|
|
6406
6400
|
//#endregion
|
|
6401
|
+
//#region src/services/terminal/paste.ts
|
|
6402
|
+
const pasteTypes = {
|
|
6403
|
+
"image/png": "png",
|
|
6404
|
+
"image/jpeg": "jpg",
|
|
6405
|
+
"image/gif": "gif",
|
|
6406
|
+
"image/webp": "webp"
|
|
6407
|
+
};
|
|
6408
|
+
function savePastedImage(type, data) {
|
|
6409
|
+
const extension = pasteTypes[type];
|
|
6410
|
+
if (extension === void 0) throw new Error("pasted image must be a PNG, JPEG, GIF or WebP image");
|
|
6411
|
+
const directory = path.join(home, "paste");
|
|
6412
|
+
mkdirSync(directory, { recursive: true });
|
|
6413
|
+
const file = path.join(directory, `${Date.now()}-${randomUUID()}.${extension}`);
|
|
6414
|
+
writeFileSync(file, data);
|
|
6415
|
+
return file;
|
|
6416
|
+
}
|
|
6417
|
+
//#endregion
|
|
6407
6418
|
//#region src/storage/state.ts
|
|
6408
6419
|
const stateFile = path.join(home, "state.json");
|
|
6409
6420
|
const stateSchema = z.strictObject({ composer: z.strictObject({
|