perstack 0.0.64 → 0.0.66
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/bin/cli.js +16 -9
- package/dist/bin/cli.js.map +1 -1
- package/package.json +5 -5
package/dist/bin/cli.js
CHANGED
|
@@ -20,7 +20,7 @@ import { useRun } from '@perstack/react';
|
|
|
20
20
|
// package.json
|
|
21
21
|
var package_default = {
|
|
22
22
|
name: "perstack",
|
|
23
|
-
version: "0.0.
|
|
23
|
+
version: "0.0.66",
|
|
24
24
|
description: "PerStack CLI"};
|
|
25
25
|
function getEnv(envPath) {
|
|
26
26
|
const env = Object.fromEntries(
|
|
@@ -433,6 +433,13 @@ function getEventContents(jobId, runId, maxStepNumber) {
|
|
|
433
433
|
}
|
|
434
434
|
return events;
|
|
435
435
|
}
|
|
436
|
+
function getRunIdsByJobId(jobId) {
|
|
437
|
+
const runsDir = path10__default.resolve(getJobDir(jobId), "runs");
|
|
438
|
+
if (!existsSync(runsDir)) {
|
|
439
|
+
return [];
|
|
440
|
+
}
|
|
441
|
+
return readdirSync(runsDir, { withFileTypes: true }).filter((dir) => dir.isDirectory()).map((dir) => dir.name);
|
|
442
|
+
}
|
|
436
443
|
var FileSystemStorage = class {
|
|
437
444
|
basePath;
|
|
438
445
|
constructor(config = {}) {
|
|
@@ -1444,9 +1451,6 @@ function getMostRecentRun() {
|
|
|
1444
1451
|
}
|
|
1445
1452
|
return runs[0];
|
|
1446
1453
|
}
|
|
1447
|
-
function getRunsByJobId(jobId) {
|
|
1448
|
-
return getAllRuns2().filter((r) => r.jobId === jobId);
|
|
1449
|
-
}
|
|
1450
1454
|
function getCheckpointsByJobId2(jobId) {
|
|
1451
1455
|
return getCheckpointsByJobId(jobId);
|
|
1452
1456
|
}
|
|
@@ -1493,10 +1497,10 @@ function getEventContents2(jobId, runId, maxStepNumber) {
|
|
|
1493
1497
|
return getEventContents(jobId, runId, maxStepNumber);
|
|
1494
1498
|
}
|
|
1495
1499
|
function getAllEventContentsForJob(jobId, maxStepNumber) {
|
|
1496
|
-
const
|
|
1500
|
+
const runIds = getRunIdsByJobId(jobId);
|
|
1497
1501
|
const allEvents = [];
|
|
1498
|
-
for (const
|
|
1499
|
-
const events = getEventContents(jobId,
|
|
1502
|
+
for (const runId of runIds) {
|
|
1503
|
+
const events = getEventContents(jobId, runId, maxStepNumber);
|
|
1500
1504
|
allEvents.push(...events);
|
|
1501
1505
|
}
|
|
1502
1506
|
return allEvents.sort((a, b) => a.timestamp - b.timestamp);
|
|
@@ -6926,6 +6930,7 @@ var startCommand = new Command().command("start").description("Start Perstack wi
|
|
|
6926
6930
|
}
|
|
6927
6931
|
let currentQuery = selection.query;
|
|
6928
6932
|
let currentJobId = currentCheckpoint?.jobId ?? input.options.jobId;
|
|
6933
|
+
let isNextQueryInteractiveToolResult = input.options.interactiveToolCallResult ?? false;
|
|
6929
6934
|
let accumulatedEvents = currentCheckpoint ? getAllEventContentsForJob(currentCheckpoint.jobId, currentCheckpoint.stepNumber) : void 0;
|
|
6930
6935
|
while (currentQuery !== null) {
|
|
6931
6936
|
const historicalEvents = accumulatedEvents;
|
|
@@ -6948,7 +6953,7 @@ var startCommand = new Command().command("start").description("Start Perstack wi
|
|
|
6948
6953
|
setting: {
|
|
6949
6954
|
jobId: currentJobId,
|
|
6950
6955
|
expertKey: selection.expertKey,
|
|
6951
|
-
input:
|
|
6956
|
+
input: isNextQueryInteractiveToolResult && currentCheckpoint ? parseInteractiveToolCallResult(currentQuery, currentCheckpoint) : { text: currentQuery },
|
|
6952
6957
|
experts,
|
|
6953
6958
|
model,
|
|
6954
6959
|
providerConfig,
|
|
@@ -6970,10 +6975,12 @@ var startCommand = new Command().command("start").description("Start Perstack wi
|
|
|
6970
6975
|
additionalEnvKeys: input.options.env
|
|
6971
6976
|
});
|
|
6972
6977
|
const result = await executionResult;
|
|
6973
|
-
|
|
6978
|
+
const canContinue = runResult.status === "completed" || runResult.status === "stoppedByExceededMaxSteps" || runResult.status === "stoppedByError" || runResult.status === "stoppedByInteractiveTool";
|
|
6979
|
+
if (result.nextQuery && canContinue) {
|
|
6974
6980
|
currentQuery = result.nextQuery;
|
|
6975
6981
|
currentCheckpoint = runResult;
|
|
6976
6982
|
currentJobId = runResult.jobId;
|
|
6983
|
+
isNextQueryInteractiveToolResult = runResult.status === "stoppedByInteractiveTool";
|
|
6977
6984
|
const newRunEvents = getEventContents2(runResult.jobId, runResult.runId);
|
|
6978
6985
|
if (accumulatedEvents) {
|
|
6979
6986
|
accumulatedEvents = [...accumulatedEvents, ...newRunEvents];
|