@mp-lb/berth 0.1.3 → 0.1.4

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 -24
  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.3";
5998
+ var version = "0.1.4";
5999
5999
 
6000
6000
  // src/runAuthCommand.ts
6001
6001
  import { spawn } from "node:child_process";
@@ -23522,6 +23522,7 @@ var runMessageCommand = async (args2) => {
23522
23522
 
23523
23523
  // ../../packages/core/src/work/schemas/agentPromptsSchema.ts
23524
23524
  var agentPromptsSchema = external_exports.object({
23525
+ workerRecovery: external_exports.string().min(1).optional(),
23525
23526
  workerLaunch: external_exports.string().min(1),
23526
23527
  roleMessage: external_exports.string().min(1),
23527
23528
  reassignedRoleMessage: external_exports.string().min(1)
@@ -24103,18 +24104,9 @@ var runPromptCommand = async (args2) => {
24103
24104
  };
24104
24105
 
24105
24106
  // ../../packages/core/src/work/data/getSessionRecoveryProblem.ts
24106
- var getSessionRecoveryProblem = (session, task) => {
24107
- if (!task || session.taskId !== task.uuid || task.status !== "working" || task.archivedAt)
24108
- return "Task is not in the working column.";
24109
- if (task.workerRun?.completedAt)
24110
- return "This worker has already completed its work.";
24111
- const owner = task.ownership?.worker;
24112
- if (owner && (!("sessionId" in owner) || owner.sessionId !== session.id || owner.machineId !== session.machineId))
24113
- return "Task is assigned to another worker.";
24114
- if (task.workerId && task.workerId !== session.workerSessionId)
24115
- return "Task is assigned to another worker.";
24116
- if (session.endedAt || !session.startedAt)
24117
- return "Session is not an unexpectedly exited session.";
24107
+ var getSessionRecoveryProblem = (session) => {
24108
+ if (session.endedAt) return "Worker was intentionally ended.";
24109
+ if (!session.startedAt) return "Worker startup was never confirmed.";
24118
24110
  return null;
24119
24111
  };
24120
24112
 
@@ -24125,7 +24117,8 @@ var import_handlebars = __toESM(require_lib(), 1);
24125
24117
  var agentPromptDefaults_default = {
24126
24118
  workerLaunch: "Run fm read 'worker.md' --store 'mp-lb/roles' and follow its instructions for task {{taskId}}.",
24127
24119
  roleMessage: "You have a new Berth message ({{messageId}}). Read it with berth message read {{messageId}}.",
24128
- reassignedRoleMessage: "Berth message {{messageId}} is ready for you. Read it with berth message read {{messageId}}."
24120
+ reassignedRoleMessage: "Berth message {{messageId}} is ready for you. Read it with berth message read {{messageId}}.",
24121
+ workerRecovery: "Your terminal was interrupted. Review your conversation and the current state of task {{taskId}} if one is linked. Continue only unfinished work still assigned to you, respect blockers, and do not repeat completed actions. If work is complete or assigned elsewhere, wait for instructions."
24129
24122
  };
24130
24123
 
24131
24124
  // ../../packages/core/src/work/data/defaultAgentPrompts.ts
@@ -24280,7 +24273,7 @@ var attachTmuxSession = (name) => {
24280
24273
  };
24281
24274
 
24282
24275
  // src/recoverTerminalSession.ts
24283
- var recoverTerminalSession = async (session, worker) => {
24276
+ var recoverTerminalSession = async (session, worker, prompts) => {
24284
24277
  if (session.endedAt || !session.startedAt)
24285
24278
  throw new Error("Session is not an unexpectedly exited session.");
24286
24279
  if (tmuxSessionExists(session.terminalSessionId))
@@ -24296,7 +24289,9 @@ var recoverTerminalSession = async (session, worker) => {
24296
24289
  "Resume command must include {{workerSessionId}} to resume the original conversation."
24297
24290
  );
24298
24291
  const command = worker ? renderWorkerCommand(worker.resumeCommand, {
24299
- prompt: `Your terminal was interrupted. Review task ${session.taskId ?? ""} and your prior progress, then continue working. Respect any existing blockers and do not repeat completed actions.`,
24292
+ prompt: renderAgentPrompt(prompts, "workerRecovery", {
24293
+ taskId: session.taskId ?? ""
24294
+ }),
24300
24295
  sessionId: session.id,
24301
24296
  workerSessionId: session.workerSessionId ?? "",
24302
24297
  taskId: session.taskId ?? "",
@@ -24385,17 +24380,12 @@ var runSessionCommand = async (args2) => {
24385
24380
  const machine = resolveSessionMachine(config2);
24386
24381
  if (session.machineId !== machine.id)
24387
24382
  throw new Error("Session belongs to another work machine.");
24388
- if (!session.taskId)
24389
- throw new Error("Only task sessions can be recovered.");
24390
- const tasks = await client.task.list.query({ status: "working" });
24391
- const problem = getSessionRecoveryProblem(
24392
- session,
24393
- tasks.find((task) => task.uuid === session.taskId)
24394
- );
24383
+ const problem = getSessionRecoveryProblem(session);
24395
24384
  if (problem) throw new Error(problem);
24396
24385
  return recoverTerminalSession(
24397
24386
  session,
24398
- session.workerTypeId === "shell" ? null : findWorkerType(config2.workerTypes ?? [], session.workerTypeId)
24387
+ session.workerTypeId === "shell" ? null : findWorkerType(config2.workerTypes ?? [], session.workerTypeId),
24388
+ config2.agentPrompts
24399
24389
  );
24400
24390
  }
24401
24391
  if (action === "attach" && value && !agentValue) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mp-lb/berth",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {