perstack 0.0.63 → 0.0.65
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 +78 -5
- package/dist/bin/cli.js.map +1 -1
- package/package.json +4 -4
package/dist/bin/cli.js
CHANGED
|
@@ -13,15 +13,14 @@ import { existsSync, readdirSync, readFileSync, statSync } from 'fs';
|
|
|
13
13
|
import { spawn, execSync } from 'child_process';
|
|
14
14
|
import * as os from 'os';
|
|
15
15
|
import { render, useApp, useInput, Box, Text } from 'ink';
|
|
16
|
-
import { createContext, useMemo, useReducer, useState, useEffect, useCallback, useRef, useContext } from 'react';
|
|
17
|
-
import { useTextInput, useListNavigation } from '@perstack/tui-components';
|
|
16
|
+
import { createContext, useMemo, useReducer, useState, useEffect, useCallback, useRef, useInsertionEffect, useContext } from 'react';
|
|
18
17
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
19
18
|
import { useRun } from '@perstack/react';
|
|
20
19
|
|
|
21
20
|
// package.json
|
|
22
21
|
var package_default = {
|
|
23
22
|
name: "perstack",
|
|
24
|
-
version: "0.0.
|
|
23
|
+
version: "0.0.65",
|
|
25
24
|
description: "PerStack CLI"};
|
|
26
25
|
function getEnv(envPath) {
|
|
27
26
|
const env = Object.fromEntries(
|
|
@@ -5451,6 +5450,77 @@ var KEY_HINTS = {
|
|
|
5451
5450
|
NEW: `${KEY_BINDINGS.NEW}:New Run`,
|
|
5452
5451
|
CHECKPOINTS: `${KEY_BINDINGS.CHECKPOINTS}:Checkpoints`,
|
|
5453
5452
|
EVENTS: `${KEY_BINDINGS.EVENTS}:Events`};
|
|
5453
|
+
var useLatestRef = (value) => {
|
|
5454
|
+
const ref = useRef(value);
|
|
5455
|
+
useInsertionEffect(() => {
|
|
5456
|
+
ref.current = value;
|
|
5457
|
+
});
|
|
5458
|
+
return ref;
|
|
5459
|
+
};
|
|
5460
|
+
var useListNavigation = (options) => {
|
|
5461
|
+
const { items, onSelect, onBack } = options;
|
|
5462
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
5463
|
+
useEffect(() => {
|
|
5464
|
+
if (selectedIndex >= items.length && items.length > 0) {
|
|
5465
|
+
setSelectedIndex(items.length - 1);
|
|
5466
|
+
}
|
|
5467
|
+
}, [items.length, selectedIndex]);
|
|
5468
|
+
const handleNavigation = useCallback(
|
|
5469
|
+
(inputChar, key) => {
|
|
5470
|
+
if (key.upArrow && items.length > 0) {
|
|
5471
|
+
setSelectedIndex((prev) => Math.max(0, prev - 1));
|
|
5472
|
+
return true;
|
|
5473
|
+
}
|
|
5474
|
+
if (key.downArrow && items.length > 0) {
|
|
5475
|
+
setSelectedIndex((prev) => Math.min(items.length - 1, prev + 1));
|
|
5476
|
+
return true;
|
|
5477
|
+
}
|
|
5478
|
+
if (key.return && items[selectedIndex]) {
|
|
5479
|
+
onSelect?.(items[selectedIndex]);
|
|
5480
|
+
return true;
|
|
5481
|
+
}
|
|
5482
|
+
if ((key.escape || inputChar === "b") && onBack) {
|
|
5483
|
+
onBack();
|
|
5484
|
+
return true;
|
|
5485
|
+
}
|
|
5486
|
+
return false;
|
|
5487
|
+
},
|
|
5488
|
+
[items, selectedIndex, onSelect, onBack]
|
|
5489
|
+
);
|
|
5490
|
+
return { selectedIndex, handleNavigation };
|
|
5491
|
+
};
|
|
5492
|
+
var useTextInput = (options) => {
|
|
5493
|
+
const [input, setInput] = useState("");
|
|
5494
|
+
const inputRef = useLatestRef(input);
|
|
5495
|
+
const onSubmitRef = useLatestRef(options.onSubmit);
|
|
5496
|
+
const onCancelRef = useLatestRef(options.onCancel);
|
|
5497
|
+
const handleInput = useCallback(
|
|
5498
|
+
(inputChar, key) => {
|
|
5499
|
+
if (key.escape) {
|
|
5500
|
+
setInput("");
|
|
5501
|
+
onCancelRef.current?.();
|
|
5502
|
+
return;
|
|
5503
|
+
}
|
|
5504
|
+
if (key.return && inputRef.current.trim()) {
|
|
5505
|
+
onSubmitRef.current(inputRef.current.trim());
|
|
5506
|
+
setInput("");
|
|
5507
|
+
return;
|
|
5508
|
+
}
|
|
5509
|
+
if (key.backspace || key.delete) {
|
|
5510
|
+
setInput((prev) => prev.slice(0, -1));
|
|
5511
|
+
return;
|
|
5512
|
+
}
|
|
5513
|
+
if (!key.ctrl && !key.meta && inputChar) {
|
|
5514
|
+
setInput((prev) => prev + inputChar);
|
|
5515
|
+
}
|
|
5516
|
+
},
|
|
5517
|
+
[inputRef, onSubmitRef, onCancelRef]
|
|
5518
|
+
);
|
|
5519
|
+
const reset = useCallback(() => {
|
|
5520
|
+
setInput("");
|
|
5521
|
+
}, []);
|
|
5522
|
+
return { input, handleInput, reset };
|
|
5523
|
+
};
|
|
5454
5524
|
var ListBrowser = ({
|
|
5455
5525
|
title,
|
|
5456
5526
|
items,
|
|
@@ -6856,6 +6926,7 @@ var startCommand = new Command().command("start").description("Start Perstack wi
|
|
|
6856
6926
|
}
|
|
6857
6927
|
let currentQuery = selection.query;
|
|
6858
6928
|
let currentJobId = currentCheckpoint?.jobId ?? input.options.jobId;
|
|
6929
|
+
let isNextQueryInteractiveToolResult = input.options.interactiveToolCallResult ?? false;
|
|
6859
6930
|
let accumulatedEvents = currentCheckpoint ? getAllEventContentsForJob(currentCheckpoint.jobId, currentCheckpoint.stepNumber) : void 0;
|
|
6860
6931
|
while (currentQuery !== null) {
|
|
6861
6932
|
const historicalEvents = accumulatedEvents;
|
|
@@ -6878,7 +6949,7 @@ var startCommand = new Command().command("start").description("Start Perstack wi
|
|
|
6878
6949
|
setting: {
|
|
6879
6950
|
jobId: currentJobId,
|
|
6880
6951
|
expertKey: selection.expertKey,
|
|
6881
|
-
input:
|
|
6952
|
+
input: isNextQueryInteractiveToolResult && currentCheckpoint ? parseInteractiveToolCallResult(currentQuery, currentCheckpoint) : { text: currentQuery },
|
|
6882
6953
|
experts,
|
|
6883
6954
|
model,
|
|
6884
6955
|
providerConfig,
|
|
@@ -6900,10 +6971,12 @@ var startCommand = new Command().command("start").description("Start Perstack wi
|
|
|
6900
6971
|
additionalEnvKeys: input.options.env
|
|
6901
6972
|
});
|
|
6902
6973
|
const result = await executionResult;
|
|
6903
|
-
|
|
6974
|
+
const canContinue = runResult.status === "completed" || runResult.status === "stoppedByExceededMaxSteps" || runResult.status === "stoppedByError" || runResult.status === "stoppedByInteractiveTool";
|
|
6975
|
+
if (result.nextQuery && canContinue) {
|
|
6904
6976
|
currentQuery = result.nextQuery;
|
|
6905
6977
|
currentCheckpoint = runResult;
|
|
6906
6978
|
currentJobId = runResult.jobId;
|
|
6979
|
+
isNextQueryInteractiveToolResult = runResult.status === "stoppedByInteractiveTool";
|
|
6907
6980
|
const newRunEvents = getEventContents2(runResult.jobId, runResult.runId);
|
|
6908
6981
|
if (accumulatedEvents) {
|
|
6909
6982
|
accumulatedEvents = [...accumulatedEvents, ...newRunEvents];
|