@hyperwindmill/caretaker-cli 0.11.1 → 0.12.0

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.
@@ -15315,26 +15315,31 @@ ${text}</tr>
15315
15315
 
15316
15316
  // src/MessageList.tsx
15317
15317
  var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
15318
+ var STICK_THRESHOLD = 100;
15318
15319
  function MessageList({ items, sessionId = null, trailing, isStreaming, agentName }) {
15319
15320
  const containerRef = (0, import_react3.useRef)(null);
15320
- const bottomRef = (0, import_react3.useRef)(null);
15321
15321
  const prevItemsLengthRef = (0, import_react3.useRef)(items.length);
15322
+ const stickRef = (0, import_react3.useRef)(true);
15323
+ const onScroll = () => {
15324
+ const c = containerRef.current;
15325
+ if (!c) return;
15326
+ stickRef.current = c.scrollHeight - c.scrollTop - c.clientHeight <= STICK_THRESHOLD;
15327
+ };
15322
15328
  (0, import_react3.useEffect)(() => {
15323
15329
  const container = containerRef.current;
15324
15330
  if (!container) return;
15325
- const isNewMessage = items.length > prevItemsLengthRef.current;
15331
+ const grew = items.length > prevItemsLengthRef.current;
15326
15332
  prevItemsLengthRef.current = items.length;
15327
- const threshold = 100;
15328
- const isNearBottom = container.scrollHeight - container.scrollTop - container.clientHeight <= threshold;
15329
- if (isNewMessage || isNearBottom) {
15330
- const behavior = isNewMessage && !isStreaming ? "smooth" : "auto";
15331
- bottomRef.current?.scrollIntoView({ behavior, block: "end" });
15333
+ const lastIsUser = items.length > 0 && items[items.length - 1].kind === "user";
15334
+ if (grew && lastIsUser) stickRef.current = true;
15335
+ if (stickRef.current) {
15336
+ container.scrollTo({ top: container.scrollHeight, behavior: "auto" });
15332
15337
  }
15333
15338
  }, [items, trailing, isStreaming]);
15334
15339
  if (items.length === 0 && !trailing && !isStreaming) {
15335
15340
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "messages messages--empty", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "Send a message to start." }) });
15336
15341
  }
15337
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { ref: containerRef, className: "messages", children: [
15342
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { ref: containerRef, className: "messages", onScroll, children: [
15338
15343
  items.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Item, { item, sessionId }, i)),
15339
15344
  trailing,
15340
15345
  isStreaming && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "messages__loading-indicator", children: [
@@ -15343,8 +15348,7 @@ ${text}</tr>
15343
15348
  agentName || "Caretaker",
15344
15349
  " is thinking"
15345
15350
  ] })
15346
- ] }),
15347
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: bottomRef })
15351
+ ] })
15348
15352
  ] });
15349
15353
  }
15350
15354
  function Item({ item, sessionId }) {
@@ -15392,7 +15396,7 @@ ${text}</tr>
15392
15396
  ] });
15393
15397
  case "assistant":
15394
15398
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "bubble bubble--assistant", children: [
15395
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "bubble__role", children: "assistant" }),
15399
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "bubble__role", children: item.label || "assistant" }),
15396
15400
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "bubble__text", children: [
15397
15401
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MarkdownText, { content: item.text }),
15398
15402
  item.streaming && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "bubble__caret", children: "\u258C" })
@@ -16143,6 +16147,8 @@ ${text}</tr>
16143
16147
  const [planningEnabled, setPlanningEnabled] = (0, import_react7.useState)(null);
16144
16148
  const [reviewEnabled, setReviewEnabled] = (0, import_react7.useState)(null);
16145
16149
  const [sddEnabled, setSddEnabled] = (0, import_react7.useState)(null);
16150
+ const [bootstrapText, setBootstrapText] = (0, import_react7.useState)("");
16151
+ const [maxRunSecondsText, setMaxRunSecondsText] = (0, import_react7.useState)("");
16146
16152
  const [errorMsg, setErrorMsg] = (0, import_react7.useState)(null);
16147
16153
  const projects = config.projects || [];
16148
16154
  const startEdit = (proj) => {
@@ -16157,6 +16163,8 @@ ${text}</tr>
16157
16163
  setPlanningEnabled(proj.planningEnabled !== void 0 ? proj.planningEnabled : null);
16158
16164
  setReviewEnabled(proj.reviewEnabled !== void 0 ? proj.reviewEnabled : null);
16159
16165
  setSddEnabled(proj.sddEnabled !== void 0 ? proj.sddEnabled : null);
16166
+ setBootstrapText((proj.bootstrapCommands || []).join("\n"));
16167
+ setMaxRunSecondsText(proj.maxRunSeconds ? String(proj.maxRunSeconds) : "");
16160
16168
  setErrorMsg(null);
16161
16169
  };
16162
16170
  const startCreate = () => {
@@ -16171,6 +16179,8 @@ ${text}</tr>
16171
16179
  setPlanningEnabled(null);
16172
16180
  setReviewEnabled(null);
16173
16181
  setSddEnabled(null);
16182
+ setBootstrapText("");
16183
+ setMaxRunSecondsText("");
16174
16184
  setErrorMsg(null);
16175
16185
  };
16176
16186
  const cancelForm = () => {
@@ -16194,6 +16204,9 @@ ${text}</tr>
16194
16204
  setErrorMsg("An Agent must be assigned.");
16195
16205
  return;
16196
16206
  }
16207
+ const bootstrapCommands = bootstrapText.split("\n").map((c) => c.trim()).filter(Boolean);
16208
+ const parsedMaxRun = parseInt(maxRunSecondsText.trim(), 10);
16209
+ const maxRunSeconds = Number.isFinite(parsedMaxRun) && parsedMaxRun > 0 ? parsedMaxRun : null;
16197
16210
  const updatedProjects = [...projects];
16198
16211
  if (isCreating) {
16199
16212
  const nextId = projects.length > 0 ? Math.max(...projects.map((p) => p.id)) + 1 : 1;
@@ -16208,7 +16221,9 @@ ${text}</tr>
16208
16221
  reviewerAgentId: reviewerAgentId || null,
16209
16222
  planningEnabled,
16210
16223
  reviewEnabled,
16211
- sddEnabled
16224
+ sddEnabled,
16225
+ bootstrapCommands,
16226
+ maxRunSeconds
16212
16227
  };
16213
16228
  updatedProjects.push(newProj);
16214
16229
  } else if (editingProject) {
@@ -16224,7 +16239,9 @@ ${text}</tr>
16224
16239
  reviewerAgentId: reviewerAgentId || null,
16225
16240
  planningEnabled,
16226
16241
  reviewEnabled,
16227
- sddEnabled
16242
+ sddEnabled,
16243
+ bootstrapCommands,
16244
+ maxRunSeconds
16228
16245
  };
16229
16246
  }
16230
16247
  }
@@ -16400,6 +16417,40 @@ ${text}</tr>
16400
16417
  ] })
16401
16418
  ] }),
16402
16419
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { style: { fontSize: "11px", opacity: 0.65, margin: "6px 0 0 0" }, children: "SDD mode lets the planner write markdown documents (specs, plans) during the planning phase. How and where they are written is up to this project's own conventions (AGENTS.md, agent prompt \u2014 e.g. superpowers specs). Everything else stays read-only." }),
16420
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "form-group", children: [
16421
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: "project-bootstrap", children: "Bootstrap Commands (one per line)" }),
16422
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
16423
+ "textarea",
16424
+ {
16425
+ id: "project-bootstrap",
16426
+ value: bootstrapText,
16427
+ onChange: (e) => setBootstrapText(e.target.value),
16428
+ placeholder: "pnpm install\npnpm build",
16429
+ rows: 3,
16430
+ style: { fontFamily: "var(--font-mono)", fontSize: "11px" }
16431
+ }
16432
+ ),
16433
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("p", { style: { fontSize: "11px", opacity: 0.65, margin: "6px 0 0 0" }, children: [
16434
+ "Run once, in order, right after a task worktree is created (git projects only) \u2014 before the agent's first cycle, so it doesn't spend tokens on setup like ",
16435
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: "pnpm install" }),
16436
+ ". The run stops and the task is blocked if any command fails."
16437
+ ] })
16438
+ ] }),
16439
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "form-group", children: [
16440
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: "project-max-run", children: "Max run seconds per cycle (optional)" }),
16441
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
16442
+ "input",
16443
+ {
16444
+ id: "project-max-run",
16445
+ type: "number",
16446
+ min: 1,
16447
+ value: maxRunSecondsText,
16448
+ onChange: (e) => setMaxRunSecondsText(e.target.value),
16449
+ placeholder: "Default: 120 (native) / 900 (claude-code)"
16450
+ }
16451
+ ),
16452
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { style: { fontSize: "11px", opacity: 0.65, margin: "6px 0 0 0" }, children: "Wall-clock budget for a single heartbeat cycle, enforced as an abort for every provider. Tasks inherit this and can override it. Leave empty for the default." })
16453
+ ] }),
16403
16454
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "form-actions", children: [
16404
16455
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: "btn btn--secondary", onClick: cancelForm, children: "Cancel" }),
16405
16456
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: "btn btn--primary", onClick: validateAndSave, children: "Save" })
@@ -18445,7 +18496,7 @@ ${text}</tr>
18445
18496
  } catch {
18446
18497
  }
18447
18498
  }
18448
- function taskMessagesToChatItems(msgs) {
18499
+ function taskMessagesToChatItems(msgs, labels) {
18449
18500
  const items = [];
18450
18501
  for (const msg of msgs) {
18451
18502
  if (msg.messageType === "system" || msg.messageType === "block") {
@@ -18469,7 +18520,7 @@ ${text}</tr>
18469
18520
  if (msg.messageType === "plan") {
18470
18521
  items.push({ kind: "assistant", text: `**\u{1F4CB} Plan submitted**
18471
18522
 
18472
- ${msg.content}`, streaming: false });
18523
+ ${msg.content}`, streaming: false, label: labels?.planner });
18473
18524
  continue;
18474
18525
  }
18475
18526
  if (msg.role === "user") {
@@ -18491,7 +18542,7 @@ ${msg.content}`, streaming: false });
18491
18542
  }
18492
18543
  }
18493
18544
  if (thinking) items.push({ kind: "thinking", text: thinking });
18494
- items.push({ kind: "assistant", text, streaming: false });
18545
+ items.push({ kind: "assistant", text, streaming: false, label: labels?.developer });
18495
18546
  }
18496
18547
  return items;
18497
18548
  }
@@ -18823,6 +18874,24 @@ ${msg.content}`, streaming: false });
18823
18874
  setTaskError("Failed to update task setting");
18824
18875
  }
18825
18876
  };
18877
+ const handleSetTaskMaxRun = async (task, value) => {
18878
+ try {
18879
+ const res = await fetch(`/api/tasks/${task.id}/flags`, {
18880
+ method: "PATCH",
18881
+ headers: { "Content-Type": "application/json" },
18882
+ body: JSON.stringify({ maxRunSeconds: value })
18883
+ });
18884
+ if (res.ok) {
18885
+ if (selectedProjectId !== null) fetchTasks(selectedProjectId);
18886
+ } else {
18887
+ const data = await res.json().catch(() => ({}));
18888
+ setTaskError(data.error || "Failed to update task setting");
18889
+ }
18890
+ } catch (err) {
18891
+ console.error("Failed to set task max run seconds:", err);
18892
+ setTaskError("Failed to update task setting");
18893
+ }
18894
+ };
18826
18895
  const backToList = () => {
18827
18896
  setView("list");
18828
18897
  setSelectedTaskId(null);
@@ -18832,6 +18901,16 @@ ${msg.content}`, streaming: false });
18832
18901
  const selectedProject = projects.find((p) => p.id === selectedProjectId);
18833
18902
  const selectedTask = tasks.find((t) => t.id === selectedTaskId);
18834
18903
  const selectedProjectAgentName = agents.find((a) => a.id === selectedProject?.agentId)?.name || "Default Agent";
18904
+ const agentLabelFor = (agentId) => {
18905
+ const a = agents.find((x) => x.id === agentId);
18906
+ return a ? `${a.name} \xB7 ${a.model}` : void 0;
18907
+ };
18908
+ const taskAgentLabels = selectedTask ? {
18909
+ developer: agentLabelFor(selectedTask.agentId || selectedProject?.agentId || agents[0]?.id),
18910
+ planner: agentLabelFor(
18911
+ selectedTask.plannerAgentId || selectedProject?.plannerAgentId || selectedTask.agentId || selectedProject?.agentId || agents[0]?.id
18912
+ )
18913
+ } : void 0;
18835
18914
  const reviewRound = selectedTask ? taskMessages.filter((m) => m.messageType === "review").length + 1 : 1;
18836
18915
  const isActiveLike = selectedTask ? selectedTask.status === "active" || selectedTask.status === "reviewing" || selectedTask.status === "planning" : false;
18837
18916
  const statusColor = (status) => {
@@ -18884,6 +18963,7 @@ ${msg.content}`, streaming: false });
18884
18963
  {
18885
18964
  task: selectedTask,
18886
18965
  taskMessages,
18966
+ agentLabels: taskAgentLabels,
18887
18967
  isActiveLike,
18888
18968
  reviewRound,
18889
18969
  composerText,
@@ -18892,6 +18972,7 @@ ${msg.content}`, streaming: false });
18892
18972
  isSending,
18893
18973
  onBack: backToList,
18894
18974
  onToggleChecklistItem: handleToggleChecklistItem,
18975
+ onToggleStatus: handleToggleTaskStatus,
18895
18976
  statusColor
18896
18977
  }
18897
18978
  ) : view === "edit" && selectedTask ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
@@ -18907,6 +18988,7 @@ ${msg.content}`, streaming: false });
18907
18988
  onToggleChecklistItem: handleToggleChecklistItem,
18908
18989
  onSetAgent: handleSetTaskAgent,
18909
18990
  onSetFlag: handleSetTaskFlag,
18991
+ onSetMaxRun: handleSetTaskMaxRun,
18910
18992
  onOpenLog: () => setView("log"),
18911
18993
  statusColor
18912
18994
  }
@@ -19325,6 +19407,7 @@ ${msg.content}`, streaming: false });
19325
19407
  function TaskLogView({
19326
19408
  task,
19327
19409
  taskMessages,
19410
+ agentLabels,
19328
19411
  isActiveLike,
19329
19412
  reviewRound,
19330
19413
  composerText,
@@ -19333,6 +19416,7 @@ ${msg.content}`, streaming: false });
19333
19416
  isSending,
19334
19417
  onBack,
19335
19418
  onToggleChecklistItem,
19419
+ onToggleStatus,
19336
19420
  statusColor
19337
19421
  }) {
19338
19422
  const completedCount = task.checklist.filter((c) => c.status === "done").length;
@@ -19360,14 +19444,32 @@ ${msg.content}`, streaming: false });
19360
19444
  ] })
19361
19445
  ] })
19362
19446
  ] }),
19363
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
19364
- "span",
19365
- {
19366
- className: "task-table__badge",
19367
- style: { background: statusColor(task.status) },
19368
- children: task.status
19369
- }
19370
- )
19447
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
19448
+ task.status !== "done" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
19449
+ "button",
19450
+ {
19451
+ className: "confirm__btn confirm__btn--primary",
19452
+ onClick: () => onToggleStatus(task),
19453
+ title: isActiveLike ? "Pause this task (aborts the running agent)" : "Activate this task",
19454
+ style: { padding: "3px 10px", fontSize: "10px", display: "inline-flex", alignItems: "center", gap: "4px" },
19455
+ children: isActiveLike ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
19456
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Pause, { size: 12 }),
19457
+ " Pause"
19458
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
19459
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Play, { size: 12 }),
19460
+ " Activate"
19461
+ ] })
19462
+ }
19463
+ ),
19464
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
19465
+ "span",
19466
+ {
19467
+ className: "task-table__badge",
19468
+ style: { background: statusColor(task.status) },
19469
+ children: task.status
19470
+ }
19471
+ )
19472
+ ] })
19371
19473
  ] }),
19372
19474
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { style: { flex: 1, minHeight: 0, display: "flex", flexDirection: "row" }, children: [
19373
19475
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
@@ -19431,7 +19533,7 @@ ${msg.content}`, streaming: false });
19431
19533
  }
19432
19534
  ),
19433
19535
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { style: { flex: 1, minWidth: 0, display: "flex", flexDirection: "column" }, children: [
19434
- taskMessages.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "messages messages--empty", children: "No messages in this execution yet. Agent will start on next tick." }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(MessageList, { items: taskMessagesToChatItems(taskMessages), sessionId: null }),
19536
+ taskMessages.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "messages messages--empty", children: "No messages in this execution yet. Agent will start on next tick." }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(MessageList, { items: taskMessagesToChatItems(taskMessages, agentLabels), sessionId: null }),
19435
19537
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("form", { className: "composer", onSubmit: onSend, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { style: { display: "flex", gap: "8px", alignItems: "flex-end" }, children: [
19436
19538
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
19437
19539
  "textarea",
@@ -19475,6 +19577,7 @@ ${msg.content}`, streaming: false });
19475
19577
  onToggleChecklistItem,
19476
19578
  onSetAgent,
19477
19579
  onSetFlag,
19580
+ onSetMaxRun,
19478
19581
  onOpenLog,
19479
19582
  statusColor
19480
19583
  }) {
@@ -19542,7 +19645,7 @@ ${msg.content}`, streaming: false });
19542
19645
  className: "confirm__btn confirm__btn--primary",
19543
19646
  onClick: () => onToggleStatus(task),
19544
19647
  style: { padding: "3px 10px", fontSize: "10px", display: "inline-flex", alignItems: "center", gap: "4px" },
19545
- children: task.status === "active" || task.status === "reviewing" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
19648
+ children: task.status === "active" || task.status === "reviewing" || task.status === "planning" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
19546
19649
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Pause, { size: 12 }),
19547
19650
  " Pause"
19548
19651
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
@@ -19674,7 +19777,31 @@ ${msg.content}`, streaming: false });
19674
19777
  ]
19675
19778
  }
19676
19779
  )
19677
- ] }, flag)) })
19780
+ ] }, flag)) }),
19781
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("label", { style: { fontSize: "11px", display: "flex", flexDirection: "column", gap: "4px", marginTop: "12px", maxWidth: "260px" }, children: [
19782
+ "Max run seconds per cycle",
19783
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
19784
+ "input",
19785
+ {
19786
+ type: "number",
19787
+ min: 1,
19788
+ defaultValue: task.maxRunSeconds ?? "",
19789
+ placeholder: "Project default",
19790
+ title: "Wall-clock budget for one cycle, enforced as an abort. Empty = inherit the project (or the 120s native / 900s claude-code default).",
19791
+ onBlur: (e) => {
19792
+ const raw = e.target.value.trim();
19793
+ const n = raw === "" ? null : parseInt(raw, 10);
19794
+ const next = n !== null && Number.isFinite(n) && n > 0 ? n : null;
19795
+ if (next !== (task.maxRunSeconds ?? null)) onSetMaxRun(task, next);
19796
+ },
19797
+ onKeyDown: (e) => {
19798
+ if (e.key === "Enter") e.target.blur();
19799
+ },
19800
+ style: { background: "var(--vscode-input-background, #252526)", color: "var(--vscode-input-foreground)", border: "1px solid var(--vscode-input-border, #3c3c3c)", borderRadius: "4px", padding: "6px 8px", fontSize: "12px", outline: "none" }
19801
+ },
19802
+ task.maxRunSeconds ?? "default"
19803
+ )
19804
+ ] })
19678
19805
  ] }),
19679
19806
  task.status === "blocked" && task.blockedReason && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
19680
19807
  "div",