pi-crew 0.2.0 → 0.2.2

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.
@@ -229,11 +229,10 @@ export function purgeStaleActiveRunIndex(staleThresholdMs = 300_000, now = Date.
229
229
  continue;
230
230
  }
231
231
 
232
- // 4. Terminal status → no longer active
232
+ // 4. Terminal status → no longer active (just unregister, don't delete files)
233
233
  const terminalStatuses = new Set(["completed", "failed", "cancelled", "blocked"]);
234
234
  if (manifest && terminalStatuses.has(manifest.status ?? "")) {
235
235
  unregisterActiveRun(entry.runId);
236
- tryRemoveRunDirectories(entry);
237
236
  purged.push(entry.runId);
238
237
  continue;
239
238
  }
@@ -122,6 +122,7 @@ function isScriptRunnable(scriptPath: string): boolean {
122
122
  export async function runIterationHook(
123
123
  payload: HookPayload,
124
124
  hookScriptPath: string,
125
+ options?: { timeoutMs?: number },
125
126
  ): Promise<HookResult> {
126
127
  if (!isScriptRunnable(hookScriptPath)) {
127
128
  return notFiredResult();
@@ -140,10 +141,11 @@ export async function runIterationHook(
140
141
  });
141
142
 
142
143
  let killed = false;
144
+ const timeoutMs = options?.timeoutMs ?? HOOK_TIMEOUT_MS;
143
145
  const timeout = setTimeout(() => {
144
146
  killed = true;
145
147
  child.kill("SIGKILL");
146
- }, HOOK_TIMEOUT_MS);
148
+ }, timeoutMs);
147
149
 
148
150
  child.stdout.on("data", (chunk: Buffer) => {
149
151
  stdoutChunks.push(chunk);
@@ -8,7 +8,7 @@ import { DEFAULT_CACHE, DEFAULT_PATHS } from "../config/defaults.ts";
8
8
  import { createRunId, createTaskId } from "../utils/ids.ts";
9
9
  import { findRepoRoot, projectCrewRoot, userCrewRoot } from "../utils/paths.ts";
10
10
  import { assertSafePathId, resolveContainedRelativePath, resolveRealContainedPath } from "../utils/safe-paths.ts";
11
- import { withRunLockSync, withRunLock } from "./locks.ts";
11
+ import { withRunLock } from "./locks.ts";
12
12
  import type { TeamConfig } from "../teams/team-config.ts";
13
13
  import type { WorkflowConfig } from "../workflows/workflow-config.ts";
14
14
 
@@ -181,31 +181,23 @@ export function createRunManifest(params: {
181
181
  }
182
182
 
183
183
  export function saveRunManifest(manifest: TeamRunManifest): void {
184
- withRunLockSync(manifest, () => {
185
- atomicWriteJson(path.join(manifest.stateRoot, "manifest.json"), manifest);
186
- invalidateRunCache(manifest.stateRoot);
187
- });
184
+ atomicWriteJson(path.join(manifest.stateRoot, "manifest.json"), manifest);
185
+ invalidateRunCache(manifest.stateRoot);
188
186
  }
189
187
 
190
188
  export async function saveRunManifestAsync(manifest: TeamRunManifest): Promise<void> {
191
- await withRunLock(manifest, async () => {
192
- await atomicWriteJsonAsync(path.join(manifest.stateRoot, "manifest.json"), manifest);
193
- invalidateRunCache(manifest.stateRoot);
194
- });
189
+ await atomicWriteJsonAsync(path.join(manifest.stateRoot, "manifest.json"), manifest);
190
+ invalidateRunCache(manifest.stateRoot);
195
191
  }
196
192
 
197
193
  export function saveRunTasks(manifest: TeamRunManifest, tasks: TeamTaskState[]): void {
198
- withRunLockSync(manifest, () => {
199
- atomicWriteJson(manifest.tasksPath, tasks);
200
- invalidateRunCache(manifest.stateRoot);
201
- });
194
+ atomicWriteJson(manifest.tasksPath, tasks);
195
+ invalidateRunCache(manifest.stateRoot);
202
196
  }
203
197
 
204
198
  export async function saveRunTasksAsync(manifest: TeamRunManifest, tasks: TeamTaskState[]): Promise<void> {
205
- await withRunLock(manifest, async () => {
206
- await atomicWriteJsonAsync(manifest.tasksPath, tasks);
207
- invalidateRunCache(manifest.stateRoot);
208
- });
199
+ await atomicWriteJsonAsync(manifest.tasksPath, tasks);
200
+ invalidateRunCache(manifest.stateRoot);
209
201
  }
210
202
 
211
203
  /**