palmier 1.0.11 → 1.0.12

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.
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from "crypto";
2
2
  import * as fs from "fs";
3
3
  import * as path from "path";
4
- import { listTasks, parseTaskFile, writeTaskFile, getTaskDir, readTaskStatus, writeTaskStatus, readHistory, deleteHistoryEntry, appendTaskList, removeFromTaskList, isTaskInList, appendHistory, createRunDir, appendRunMessage, getRunDir, writeFollowupStatus, readFollowupStatus, deleteFollowupStatus } from "./task.js";
4
+ import { listTasks, parseTaskFile, writeTaskFile, getTaskDir, readTaskStatus, writeTaskStatus, readHistory, deleteHistoryEntry, appendTaskList, removeFromTaskList, isTaskInList, appendHistory, createRunDir, appendRunMessage, getRunDir, writeFollowupStatus, readFollowupStatus, deleteFollowupStatus, isRunStarred, setRunStarred } from "./task.js";
5
5
  import { resolvePending, getPending, listPending } from "./pending-requests.js";
6
6
  import { getPlatform } from "./platform/index.js";
7
7
  import { spawnCommand } from "./spawn-command.js";
@@ -546,7 +546,7 @@ export function createRpcHandler(config, nc) {
546
546
  try {
547
547
  const raw = fs.readFileSync(taskrunPath, "utf-8");
548
548
  const meta = parseResultFrontmatter(raw);
549
- return { task_id: params.id, ...meta };
549
+ return { task_id: params.id, ...meta, starred: isRunStarred(path.dirname(taskrunPath)) };
550
550
  }
551
551
  catch {
552
552
  return { task_id: params.id, error: "Run not found" };
@@ -591,7 +591,7 @@ export function createRpcHandler(config, nc) {
591
591
  const raw = fs.readFileSync(taskrunPath, "utf-8");
592
592
  const meta = parseResultFrontmatter(raw);
593
593
  const { messages: _, ...rest } = meta;
594
- return { ...entry, ...rest };
594
+ return { ...entry, ...rest, starred: isRunStarred(path.dirname(taskrunPath)) };
595
595
  }
596
596
  catch {
597
597
  return { ...entry, error: "Run not found" };
@@ -605,6 +605,9 @@ export function createRpcHandler(config, nc) {
605
605
  return { error: "task_id and run_id are required" };
606
606
  }
607
607
  const deleteTaskDir = getTaskDir(config.projectRoot, params.task_id);
608
+ if (isRunStarred(getRunDir(deleteTaskDir, params.run_id))) {
609
+ return { error: "Unstar this session before deleting it" };
610
+ }
608
611
  const deleted = deleteHistoryEntry(config.projectRoot, params.task_id, params.run_id);
609
612
  if (!deleted) {
610
613
  return { error: "History entry not found" };
@@ -624,6 +627,21 @@ export function createRpcHandler(config, nc) {
624
627
  }
625
628
  return { ok: true, task_id: params.task_id, run_id: params.run_id };
626
629
  }
630
+ case "taskrun.star": {
631
+ const params = request.params;
632
+ if (!params.task_id || !params.run_id || typeof params.starred !== "boolean") {
633
+ return { error: "task_id, run_id and starred are required" };
634
+ }
635
+ if (path.basename(params.task_id) !== params.task_id || path.basename(params.run_id) !== params.run_id) {
636
+ return { error: "Invalid task_id or run_id" };
637
+ }
638
+ const starRunDir = getRunDir(getTaskDir(config.projectRoot, params.task_id), params.run_id);
639
+ if (!fs.existsSync(path.join(starRunDir, "TASKRUN.md"))) {
640
+ return { error: "Run not found" };
641
+ }
642
+ setRunStarred(starRunDir, params.starred);
643
+ return { ok: true, task_id: params.task_id, run_id: params.run_id, starred: params.starred };
644
+ }
627
645
  case "host.update": {
628
646
  const error = await performUpdate();
629
647
  if (error)
package/dist/task.d.ts CHANGED
@@ -16,6 +16,8 @@ export interface FollowupStatus {
16
16
  export declare function writeFollowupStatus(runDir: string, status: FollowupStatus): void;
17
17
  export declare function readFollowupStatus(runDir: string): FollowupStatus | undefined;
18
18
  export declare function deleteFollowupStatus(runDir: string): void;
19
+ export declare function isRunStarred(runDir: string): boolean;
20
+ export declare function setRunStarred(runDir: string, starred: boolean): void;
19
21
  /** Returns the run ID (timestamp string used as directory name). */
20
22
  export declare function createRunDir(taskDir: string, taskName: string, startTime: number, agent?: string, agentVersion?: string): string;
21
23
  export declare function getRunDir(taskDir: string, runId: string): string;
package/dist/task.js CHANGED
@@ -129,6 +129,18 @@ export function deleteFollowupStatus(runDir) {
129
129
  }
130
130
  catch { /* ignore */ }
131
131
  }
132
+ // A marker file rather than TASKRUN.md frontmatter, which a running agent process appends to concurrently.
133
+ const STARRED_MARKER = ".starred";
134
+ export function isRunStarred(runDir) {
135
+ return fs.existsSync(path.join(runDir, STARRED_MARKER));
136
+ }
137
+ export function setRunStarred(runDir, starred) {
138
+ const markerPath = path.join(runDir, STARRED_MARKER);
139
+ if (starred)
140
+ fs.writeFileSync(markerPath, "", "utf-8");
141
+ else
142
+ fs.rmSync(markerPath, { force: true });
143
+ }
132
144
  /** Returns the run ID (timestamp string used as directory name). */
133
145
  export function createRunDir(taskDir, taskName, startTime, agent, agentVersion) {
134
146
  const runId = String(startTime);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "palmier",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Palmier host CLI - provisions, executes tasks, and serves NATS RPC",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Hongxu Cai",