offsite 0.0.38 → 0.0.40

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 from "node:os";
8
+ import os, { homedir } 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";
@@ -3172,8 +3172,6 @@ async function find(provider, paths) {
3172
3172
  });
3173
3173
  }
3174
3174
  }
3175
- //#endregion
3176
- //#region ../core/src/terminal.ts
3177
3175
  function encodeFrame(kind, id, data) {
3178
3176
  const frame = new Uint8Array(5 + data.length);
3179
3177
  frame[0] = kind;
@@ -3438,6 +3436,32 @@ var Alerts = class {
3438
3436
  }
3439
3437
  };
3440
3438
  //#endregion
3439
+ //#region src/services/terminal/find-program.ts
3440
+ const found = /* @__PURE__ */ new Map();
3441
+ function findWindowsProgram(command) {
3442
+ if (/[\\/]/.test(command)) return command;
3443
+ const cached = found.get(command);
3444
+ if (cached !== void 0) return cached;
3445
+ const extensions = path.extname(command) === "" ? (process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";") : [""];
3446
+ for (const directory of (process.env.PATH ?? "").split(path.delimiter)) {
3447
+ if (directory === "") continue;
3448
+ for (const extension of extensions) {
3449
+ const candidate = path.join(directory, command + extension);
3450
+ let entry;
3451
+ try {
3452
+ entry = lstatSync(candidate, { throwIfNoEntry: false });
3453
+ } catch {
3454
+ continue;
3455
+ }
3456
+ if (entry !== void 0 && !entry.isDirectory()) {
3457
+ found.set(command, candidate);
3458
+ return candidate;
3459
+ }
3460
+ }
3461
+ }
3462
+ throw new Error(`could not find ${command} in PATH`);
3463
+ }
3464
+ //#endregion
3441
3465
  //#region ../core/src/shell-check.ts
3442
3466
  function zshOptionsSupported(options) {
3443
3467
  for (let position = 0; position < options.length; position++) {
@@ -3643,7 +3667,7 @@ function startShell(cwd) {
3643
3667
  let args;
3644
3668
  if (process.platform === "win32") {
3645
3669
  Object.assign(env, process.env);
3646
- file = options.command ?? defaultShell();
3670
+ file = findWindowsProgram(options.command ?? defaultShell());
3647
3671
  args = [];
3648
3672
  } else {
3649
3673
  for (const name of [
@@ -3970,7 +3994,7 @@ function input(connection, bytes) {
3970
3994
  terminal.pty.write(Buffer.from(frame.data));
3971
3995
  }
3972
3996
  async function createTab(projectId) {
3973
- const cwd = projectPath(projectId);
3997
+ const cwd = projectId === "global" ? homedir() : projectPath(projectId);
3974
3998
  if (!statSync(cwd, { throwIfNoEntry: false })?.isDirectory()) {
3975
3999
  console.error(`${cwd} is not a folder, terminal not created`);
3976
4000
  return;
@@ -4386,7 +4410,7 @@ async function updateSession(id, patch) {
4386
4410
  db.delete(sessions$1).where(eq(sessions$1.sessionId, id)).run();
4387
4411
  const all = withStatus(allProviders.flatMap((provider) => listed[provider]));
4388
4412
  const session = all.find((item) => item.id === id);
4389
- if (session !== void 0 && all.every((item) => item.projectId !== session.projectId || item.status === "inactive")) closeProjectTabs(session.projectId);
4413
+ if (session !== void 0 && all.every((item) => item.projectId !== session.projectId || item.status === "inactive") && [...runs.values()].every((other) => other.sessionId === id || other.cwd !== projectPath(session.projectId) || all.some((item) => item.id === other.sessionId))) closeProjectTabs(session.projectId);
4390
4414
  } else if (patch.status !== void 0) {
4391
4415
  const set = patch.status === "active" ? {
4392
4416
  status: patch.status,
@@ -5576,6 +5600,7 @@ const IDLE_LIMIT = 6e5;
5576
5600
  var Run = class {
5577
5601
  provider = "claude";
5578
5602
  sessionId;
5603
+ cwd;
5579
5604
  messages = [];
5580
5605
  pending = /* @__PURE__ */ new Map();
5581
5606
  published = /* @__PURE__ */ new Map();
@@ -5598,6 +5623,7 @@ var Run = class {
5598
5623
  stopping = false;
5599
5624
  constructor(options) {
5600
5625
  this.sessionId = options.sessionId;
5626
+ this.cwd = options.cwd;
5601
5627
  this.resumeAt = options.resumeAt;
5602
5628
  this.settings = options.settings;
5603
5629
  this.query = query({