@mp-lb/berth 0.1.4 → 0.1.5

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.
Files changed (2) hide show
  1. package/dist/berth.js +14 -15
  2. package/package.json +1 -1
package/dist/berth.js CHANGED
@@ -5995,7 +5995,7 @@ var require_lib = __commonJS({
5995
5995
  });
5996
5996
 
5997
5997
  // package.json
5998
- var version = "0.1.4";
5998
+ var version = "0.1.5";
5999
5999
 
6000
6000
  // src/runAuthCommand.ts
6001
6001
  import { spawn } from "node:child_process";
@@ -24103,13 +24103,6 @@ var runPromptCommand = async (args2) => {
24103
24103
  );
24104
24104
  };
24105
24105
 
24106
- // ../../packages/core/src/work/data/getSessionRecoveryProblem.ts
24107
- var getSessionRecoveryProblem = (session) => {
24108
- if (session.endedAt) return "Worker was intentionally ended.";
24109
- if (!session.startedAt) return "Worker startup was never confirmed.";
24110
- return null;
24111
- };
24112
-
24113
24106
  // ../../packages/core/src/work/data/renderAgentPrompt.ts
24114
24107
  var import_handlebars = __toESM(require_lib(), 1);
24115
24108
 
@@ -24162,7 +24155,7 @@ var terminalSessionCreateSchema = terminalSessionSchema.pick({
24162
24155
  var terminalSessionUpdateSchema = external_exports.strictObject({
24163
24156
  id: external_exports.uuid(),
24164
24157
  startedAt: external_exports.iso.datetime().optional(),
24165
- endedAt: external_exports.iso.datetime().optional(),
24158
+ endedAt: external_exports.iso.datetime().nullable().optional(),
24166
24159
  error: external_exports.string().max(2e3).nullable().optional(),
24167
24160
  workerSessionId: external_exports.string().max(200).nullable().optional()
24168
24161
  }).refine(
@@ -24170,7 +24163,9 @@ var terminalSessionUpdateSchema = external_exports.strictObject({
24170
24163
  {
24171
24164
  message: "Set startedAt or endedAt."
24172
24165
  }
24173
- );
24166
+ ).refine((input) => input.endedAt !== null || input.startedAt !== void 0, {
24167
+ message: "Confirm startedAt when relaunching an ended worker."
24168
+ });
24174
24169
 
24175
24170
  // src/renderWorkerCommand.ts
24176
24171
  var renderWorkerCommand = (template, values) => {
@@ -24274,8 +24269,6 @@ var attachTmuxSession = (name) => {
24274
24269
 
24275
24270
  // src/recoverTerminalSession.ts
24276
24271
  var recoverTerminalSession = async (session, worker, prompts) => {
24277
- if (session.endedAt || !session.startedAt)
24278
- throw new Error("Session is not an unexpectedly exited session.");
24279
24272
  if (tmuxSessionExists(session.terminalSessionId))
24280
24273
  throw new Error("Session is already running.");
24281
24274
  if (session.workerTypeId !== "shell" && (!worker?.resumeCommand || !session.workerSessionId))
@@ -24380,13 +24373,19 @@ var runSessionCommand = async (args2) => {
24380
24373
  const machine = resolveSessionMachine(config2);
24381
24374
  if (session.machineId !== machine.id)
24382
24375
  throw new Error("Session belongs to another work machine.");
24383
- const problem = getSessionRecoveryProblem(session);
24384
- if (problem) throw new Error(problem);
24385
- return recoverTerminalSession(
24376
+ const result = await recoverTerminalSession(
24386
24377
  session,
24387
24378
  session.workerTypeId === "shell" ? null : findWorkerType(config2.workerTypes ?? [], session.workerTypeId),
24388
24379
  config2.agentPrompts
24389
24380
  );
24381
+ if (session.endedAt || !session.startedAt || session.error)
24382
+ await client.terminalSession.update.mutate({
24383
+ id: session.id,
24384
+ startedAt: session.startedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
24385
+ endedAt: null,
24386
+ error: null
24387
+ });
24388
+ return result;
24390
24389
  }
24391
24390
  if (action === "attach" && value && !agentValue) {
24392
24391
  const session = await client.terminalSession.read.query(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mp-lb/berth",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {