poe-code 14.0.0 → 14.0.1
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.
- package/dist/index.js +97 -46
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/process-launcher/dist/launcher.js +90 -45
package/dist/index.js
CHANGED
|
@@ -83357,8 +83357,14 @@ import { TextDecoder as TextDecoder2 } from "node:util";
|
|
|
83357
83357
|
async function startManagedProcess(options) {
|
|
83358
83358
|
assertOptionalFiniteDuration(options.startupTimeoutMs, "startup timeout");
|
|
83359
83359
|
assertOptionalFiniteDuration(options.pollIntervalMs, "poll interval");
|
|
83360
|
-
const fs31 = options.fs ?? defaultFs3();
|
|
83361
83360
|
const spec10 = normalizeSpec(options.spec);
|
|
83361
|
+
return await withManagedProcessOperation(
|
|
83362
|
+
{ ...options, id: spec10.id },
|
|
83363
|
+
async (fs31) => await startReservedProcess({ ...options, fs: fs31, spec: spec10 })
|
|
83364
|
+
);
|
|
83365
|
+
}
|
|
83366
|
+
async function startReservedProcess(options) {
|
|
83367
|
+
const { fs: fs31, spec: spec10 } = options;
|
|
83362
83368
|
const existing = await readManagedProcess({
|
|
83363
83369
|
baseDir: options.baseDir,
|
|
83364
83370
|
fs: fs31,
|
|
@@ -83400,7 +83406,13 @@ async function startManagedProcess(options) {
|
|
|
83400
83406
|
async function stopManagedProcess(options) {
|
|
83401
83407
|
assertOptionalFiniteDuration(options.stopTimeoutMs, "stop timeout");
|
|
83402
83408
|
assertOptionalFiniteDuration(options.pollIntervalMs, "poll interval");
|
|
83403
|
-
|
|
83409
|
+
return await withManagedProcessOperation(
|
|
83410
|
+
options,
|
|
83411
|
+
async (fs31) => await stopReservedProcess({ ...options, fs: fs31 })
|
|
83412
|
+
);
|
|
83413
|
+
}
|
|
83414
|
+
async function stopReservedProcess(options) {
|
|
83415
|
+
const { fs: fs31 } = options;
|
|
83404
83416
|
const record2 = await readManagedProcess({
|
|
83405
83417
|
baseDir: options.baseDir,
|
|
83406
83418
|
fs: fs31,
|
|
@@ -83443,37 +83455,75 @@ async function stopManagedProcess(options) {
|
|
|
83443
83455
|
return stopped;
|
|
83444
83456
|
}
|
|
83445
83457
|
async function restartManagedProcess(options) {
|
|
83446
|
-
|
|
83447
|
-
|
|
83448
|
-
|
|
83449
|
-
|
|
83450
|
-
|
|
83451
|
-
|
|
83458
|
+
assertOptionalFiniteDuration(options.startupTimeoutMs, "startup timeout");
|
|
83459
|
+
assertOptionalFiniteDuration(options.stopTimeoutMs, "stop timeout");
|
|
83460
|
+
assertOptionalFiniteDuration(options.pollIntervalMs, "poll interval");
|
|
83461
|
+
return await withManagedProcessOperation(options, async (fs31) => {
|
|
83462
|
+
const record2 = await readManagedProcess({
|
|
83463
|
+
baseDir: options.baseDir,
|
|
83464
|
+
fs: fs31,
|
|
83465
|
+
id: options.id,
|
|
83466
|
+
isPidRunning: options.isPidRunning
|
|
83467
|
+
});
|
|
83468
|
+
if (record2.spec === null) {
|
|
83469
|
+
throw await managedProcessNotFound(fs31, options.baseDir, options.id);
|
|
83470
|
+
}
|
|
83471
|
+
await stopReservedProcess({
|
|
83472
|
+
...options,
|
|
83473
|
+
force: false,
|
|
83474
|
+
fs: fs31
|
|
83475
|
+
});
|
|
83476
|
+
return await startReservedProcess({
|
|
83477
|
+
...options,
|
|
83478
|
+
fs: fs31,
|
|
83479
|
+
spec: normalizeSpec(record2.spec)
|
|
83480
|
+
});
|
|
83452
83481
|
});
|
|
83453
|
-
|
|
83454
|
-
|
|
83482
|
+
}
|
|
83483
|
+
async function withManagedProcessOperation(options, operation) {
|
|
83484
|
+
const fs31 = options.fs ?? defaultFs3();
|
|
83485
|
+
await assertProcessDirectorySafe(fs31, options.baseDir, options.id);
|
|
83486
|
+
await fs31.mkdir(options.baseDir, { recursive: true });
|
|
83487
|
+
const baseDir = path110.resolve(options.baseDir);
|
|
83488
|
+
const operationsDir = path110.join(path110.dirname(baseDir), ".process-operations", path110.basename(baseDir));
|
|
83489
|
+
await assertPathHasNoSymbolicLinks4(fs31, operationsDir);
|
|
83490
|
+
await fs31.mkdir(operationsDir, { recursive: true });
|
|
83491
|
+
const lockPath = path110.join(operationsDir, options.id);
|
|
83492
|
+
const owner = `${JSON.stringify({ token: randomUUID36(), pid: process.pid })}
|
|
83493
|
+
`;
|
|
83494
|
+
try {
|
|
83495
|
+
await fs31.writeFile(lockPath, owner, { encoding: "utf8", flag: "wx" });
|
|
83496
|
+
} catch (error3) {
|
|
83497
|
+
if (hasOwnErrorCode23(error3, "EEXIST")) {
|
|
83498
|
+
throw new UserError(
|
|
83499
|
+
`Managed process "${options.id}" has another operation in progress.
|
|
83500
|
+
Retry after it finishes.
|
|
83501
|
+
If the caller exited unexpectedly, confirm that all operations on this name have stopped,
|
|
83502
|
+
then remove this reservation file:
|
|
83503
|
+
${lockPath}`
|
|
83504
|
+
);
|
|
83505
|
+
}
|
|
83506
|
+
throw error3;
|
|
83455
83507
|
}
|
|
83456
|
-
|
|
83457
|
-
|
|
83458
|
-
|
|
83459
|
-
|
|
83460
|
-
|
|
83461
|
-
|
|
83462
|
-
|
|
83463
|
-
|
|
83464
|
-
|
|
83465
|
-
|
|
83466
|
-
|
|
83467
|
-
|
|
83468
|
-
|
|
83469
|
-
|
|
83470
|
-
|
|
83471
|
-
|
|
83472
|
-
|
|
83473
|
-
|
|
83474
|
-
|
|
83475
|
-
startupTimeoutMs: options.startupTimeoutMs
|
|
83476
|
-
});
|
|
83508
|
+
let outcome;
|
|
83509
|
+
try {
|
|
83510
|
+
outcome = { result: await operation(fs31) };
|
|
83511
|
+
} catch (error3) {
|
|
83512
|
+
outcome = { error: error3 };
|
|
83513
|
+
}
|
|
83514
|
+
try {
|
|
83515
|
+
if (await fs31.readFile(lockPath, "utf8") !== owner) {
|
|
83516
|
+
throw new UserError(`Managed process operation ownership changed before release: ${lockPath}`);
|
|
83517
|
+
}
|
|
83518
|
+
await fs31.rm(lockPath);
|
|
83519
|
+
} catch (releaseError) {
|
|
83520
|
+
if ("error" in outcome) {
|
|
83521
|
+
throw new AggregateError([outcome.error, releaseError], "Managed process operation and ownership release failed");
|
|
83522
|
+
}
|
|
83523
|
+
throw releaseError;
|
|
83524
|
+
}
|
|
83525
|
+
if ("error" in outcome) throw outcome.error;
|
|
83526
|
+
return outcome.result;
|
|
83477
83527
|
}
|
|
83478
83528
|
async function describeStartFailure(fs31, baseDir, id, record2) {
|
|
83479
83529
|
const state = record2.state;
|
|
@@ -83683,21 +83733,22 @@ function getFileId(stat35) {
|
|
|
83683
83733
|
return typeof stat35.dev === "number" && typeof stat35.ino === "number" ? `${stat35.dev}:${stat35.ino}` : null;
|
|
83684
83734
|
}
|
|
83685
83735
|
async function removeManagedProcess(options) {
|
|
83686
|
-
|
|
83687
|
-
|
|
83688
|
-
|
|
83689
|
-
|
|
83690
|
-
|
|
83691
|
-
|
|
83736
|
+
await withManagedProcessOperation(options, async (fs31) => {
|
|
83737
|
+
const record2 = await readManagedProcess({
|
|
83738
|
+
baseDir: options.baseDir,
|
|
83739
|
+
fs: fs31,
|
|
83740
|
+
id: options.id,
|
|
83741
|
+
isPidRunning: options.isPidRunning
|
|
83742
|
+
});
|
|
83743
|
+
if (isActiveRecord(record2)) {
|
|
83744
|
+
throw new Error(`Managed process "${options.id}" must be stopped before removal.`);
|
|
83745
|
+
}
|
|
83746
|
+
const stateStore = createStateStore(options.baseDir, fs31);
|
|
83747
|
+
await stateStore.remove(options.id);
|
|
83748
|
+
if (record2.spec !== null && options.removeRuntimeArtifacts) {
|
|
83749
|
+
await options.removeRuntimeArtifacts({ record: record2 });
|
|
83750
|
+
}
|
|
83692
83751
|
});
|
|
83693
|
-
if (isActiveRecord(record2)) {
|
|
83694
|
-
throw new Error(`Managed process "${options.id}" must be stopped before removal.`);
|
|
83695
|
-
}
|
|
83696
|
-
const stateStore = createStateStore(options.baseDir, fs31);
|
|
83697
|
-
await stateStore.remove(options.id);
|
|
83698
|
-
if (record2.spec !== null && options.removeRuntimeArtifacts) {
|
|
83699
|
-
await options.removeRuntimeArtifacts({ record: record2 });
|
|
83700
|
-
}
|
|
83701
83752
|
}
|
|
83702
83753
|
async function runManagedProcess(options) {
|
|
83703
83754
|
if (options.signal?.aborted) {
|
|
@@ -157476,7 +157527,7 @@ var init_package2 = __esm({
|
|
|
157476
157527
|
"package.json"() {
|
|
157477
157528
|
package_default2 = {
|
|
157478
157529
|
name: "poe-code",
|
|
157479
|
-
version: "14.0.
|
|
157530
|
+
version: "14.0.1",
|
|
157480
157531
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
157481
157532
|
license: "MIT",
|
|
157482
157533
|
type: "module",
|