@promus/cli 0.24.21 → 0.24.23
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/package.json +1 -1
- package/src/commands/chat.tsx +14 -0
- package/src/index.ts +18 -0
- package/src/ui/state.ts +5 -0
package/package.json
CHANGED
package/src/commands/chat.tsx
CHANGED
|
@@ -791,6 +791,19 @@ export async function runChat(opts?: { cwd?: string; yolo?: boolean; resume?: st
|
|
|
791
791
|
currency: NETWORK_CURRENCY[config.network],
|
|
792
792
|
})
|
|
793
793
|
|
|
794
|
+
// Resume: load saved chat rows from the session file into the TUI
|
|
795
|
+
if (opts?.resume) {
|
|
796
|
+
try {
|
|
797
|
+
const { readFileSync, existsSync } = require('node:fs')
|
|
798
|
+
if (existsSync(sessionFile)) {
|
|
799
|
+
const saved = JSON.parse(readFileSync(sessionFile, 'utf8'))
|
|
800
|
+
if (Array.isArray(saved.rows) && saved.rows.length > 0) {
|
|
801
|
+
state.loadRows(saved.rows)
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
} catch {}
|
|
805
|
+
}
|
|
806
|
+
|
|
794
807
|
// Phase 12: now that state exists, point the telegram row sinks at it. The
|
|
795
808
|
// dispatch slot stays null until brain.init resolves below.
|
|
796
809
|
if (telegram) {
|
|
@@ -1621,6 +1634,7 @@ export async function runChat(opts?: { cwd?: string; yolo?: boolean; resume?: st
|
|
|
1621
1634
|
brainProvider: config.brain?.provider,
|
|
1622
1635
|
brainModel: config.brain?.model,
|
|
1623
1636
|
startedAt: new Date().toISOString(),
|
|
1637
|
+
rows: state.rows(),
|
|
1624
1638
|
}, null, 2))
|
|
1625
1639
|
} catch {}
|
|
1626
1640
|
try {
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,20 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const argv = process.argv.slice(2)
|
|
7
|
+
|
|
8
|
+
// --root <dir> override PROMUS_ROOT so each agent gets its own config + data.
|
|
9
|
+
// Must be parsed before any subcommand to affect agentPaths / config loading.
|
|
10
|
+
const rootIdx = argv.indexOf('--root')
|
|
11
|
+
if (rootIdx >= 0) {
|
|
12
|
+
const root = argv[rootIdx + 1]
|
|
13
|
+
if (!root) {
|
|
14
|
+
console.error('promus --root requires a directory path')
|
|
15
|
+
process.exit(1)
|
|
16
|
+
}
|
|
17
|
+
process.env.PROMUS_ROOT = root
|
|
18
|
+
argv.splice(rootIdx, 2) // remove --root <dir> from argv
|
|
19
|
+
}
|
|
20
|
+
|
|
7
21
|
// First arg starting with `--` means the user invoked the default subcommand
|
|
8
22
|
// (chat) with flags, e.g. `promus --yolo`. Treat it as if `chat` were implicit.
|
|
9
23
|
// Exception: `--help` and `--version` are top-level commands, not chat flags.
|
|
@@ -330,6 +344,10 @@ function printHelp(): void {
|
|
|
330
344
|
[
|
|
331
345
|
'promus: sovereign agent harness CLI',
|
|
332
346
|
'',
|
|
347
|
+
'Global flags:',
|
|
348
|
+
' --root <dir> use a separate agent root (config, keystore, sessions)',
|
|
349
|
+
' enables running multiple agents on the same machine',
|
|
350
|
+
'',
|
|
333
351
|
'Commands:',
|
|
334
352
|
' promus init bootstrap a new agent identity + keystore',
|
|
335
353
|
' promus [--yolo] interactive chat with your agent (default; --yolo skips approvals)',
|
package/src/ui/state.ts
CHANGED
|
@@ -148,6 +148,10 @@ export function createChatState(opts: CreateChatStateOpts) {
|
|
|
148
148
|
let idCounter = 1
|
|
149
149
|
const nextId = () => `row-${idCounter++}`
|
|
150
150
|
|
|
151
|
+
const loadRows = (saved: TurnRow[]) => {
|
|
152
|
+
setRows(saved)
|
|
153
|
+
}
|
|
154
|
+
|
|
151
155
|
const pushRow = (row: Omit<TurnRow, 'id' | 'firstOfBlock'>) => {
|
|
152
156
|
setRows(prev => {
|
|
153
157
|
const last = prev[prev.length - 1] ?? null
|
|
@@ -188,6 +192,7 @@ export function createChatState(opts: CreateChatStateOpts) {
|
|
|
188
192
|
setSlashIndex,
|
|
189
193
|
bumpActiveJobs,
|
|
190
194
|
pushRow,
|
|
195
|
+
loadRows,
|
|
191
196
|
onStatusChange,
|
|
192
197
|
identityLabel: opts.identityLabel,
|
|
193
198
|
isLocalGateway: opts.isLocalGateway ?? false,
|