@hydra-acp/cli 0.1.3 → 0.1.4
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/README.md +25 -1
- package/dist/cli.js +1078 -266
- package/dist/index.d.ts +176 -7
- package/dist/index.js +660 -129
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1214,6 +1214,7 @@ declare class HistoryStore {
|
|
|
1214
1214
|
private writeQueues;
|
|
1215
1215
|
append(sessionId: string, entry: HistoryEntry): Promise<void>;
|
|
1216
1216
|
rewrite(sessionId: string, entries: HistoryEntry[]): Promise<void>;
|
|
1217
|
+
compact(sessionId: string, maxEntries: number): Promise<void>;
|
|
1217
1218
|
load(sessionId: string): Promise<HistoryEntry[]>;
|
|
1218
1219
|
delete(sessionId: string): Promise<void>;
|
|
1219
1220
|
private enqueue;
|
|
@@ -1250,12 +1251,12 @@ interface SessionInit {
|
|
|
1250
1251
|
agentArgs?: string[];
|
|
1251
1252
|
idleTimeoutMs?: number;
|
|
1252
1253
|
spawnReplacementAgent?: SpawnReplacementAgent;
|
|
1253
|
-
seedHistory?: CachedNotification[];
|
|
1254
1254
|
historyStore?: HistoryStore;
|
|
1255
1255
|
currentModel?: string;
|
|
1256
1256
|
currentMode?: string;
|
|
1257
1257
|
agentCommands?: AdvertisedCommand[];
|
|
1258
1258
|
firstPromptSeeded?: boolean;
|
|
1259
|
+
createdAt?: number;
|
|
1259
1260
|
}
|
|
1260
1261
|
interface CloseOptions {
|
|
1261
1262
|
deleteRecord?: boolean;
|
|
@@ -1274,8 +1275,8 @@ declare class Session {
|
|
|
1274
1275
|
currentModel: string | undefined;
|
|
1275
1276
|
currentMode: string | undefined;
|
|
1276
1277
|
updatedAt: number;
|
|
1278
|
+
readonly createdAt: number;
|
|
1277
1279
|
private clients;
|
|
1278
|
-
private history;
|
|
1279
1280
|
private historyStore;
|
|
1280
1281
|
private promptQueue;
|
|
1281
1282
|
private promptInFlight;
|
|
@@ -1284,10 +1285,13 @@ declare class Session {
|
|
|
1284
1285
|
private titleHandlers;
|
|
1285
1286
|
private broadcastHandlers;
|
|
1286
1287
|
private firstPromptSeeded;
|
|
1288
|
+
private promptStartedAt;
|
|
1289
|
+
private appendCount;
|
|
1287
1290
|
private inFlightPermissions;
|
|
1288
1291
|
private internalPromptCapture;
|
|
1289
1292
|
private idleTimeoutMs;
|
|
1290
1293
|
private idleTimer;
|
|
1294
|
+
private lastRecordedAt;
|
|
1291
1295
|
private spawnReplacementAgent;
|
|
1292
1296
|
private agentChangeHandlers;
|
|
1293
1297
|
private agentAdvertisedCommands;
|
|
@@ -1303,9 +1307,9 @@ declare class Session {
|
|
|
1303
1307
|
}) => void): void;
|
|
1304
1308
|
get attachedCount(): number;
|
|
1305
1309
|
get turnStartedAt(): number | undefined;
|
|
1306
|
-
getHistorySnapshot(): CachedNotification[]
|
|
1310
|
+
getHistorySnapshot(): Promise<CachedNotification[]>;
|
|
1307
1311
|
onBroadcast(handler: (entry: CachedNotification) => void): () => void;
|
|
1308
|
-
attach(client: AttachedClient, historyPolicy: HistoryPolicy): CachedNotification[]
|
|
1312
|
+
attach(client: AttachedClient, historyPolicy: HistoryPolicy): Promise<CachedNotification[]>;
|
|
1309
1313
|
replayPendingPermissions(client: AttachedClient): void;
|
|
1310
1314
|
detach(clientId: string): void;
|
|
1311
1315
|
prompt(clientId: string, params: unknown): Promise<unknown>;
|
|
@@ -1328,6 +1332,7 @@ declare class Session {
|
|
|
1328
1332
|
onModelChange(handler: (model: string) => void): void;
|
|
1329
1333
|
onModeChange(handler: (mode: string) => void): void;
|
|
1330
1334
|
mergedAvailableCommands(): AdvertisedCommand[];
|
|
1335
|
+
agentOnlyAdvertisedCommands(): AdvertisedCommand[];
|
|
1331
1336
|
private maybeApplyAgentSessionInfo;
|
|
1332
1337
|
private handleSlashCommand;
|
|
1333
1338
|
private runTitleCommand;
|
|
@@ -1335,9 +1340,13 @@ declare class Session {
|
|
|
1335
1340
|
private runInternalPrompt;
|
|
1336
1341
|
private runSwitchCommand;
|
|
1337
1342
|
private buildSwitchTranscript;
|
|
1343
|
+
seedFromImport(): Promise<void>;
|
|
1338
1344
|
private broadcastAgentSwitch;
|
|
1339
1345
|
private markClosed;
|
|
1340
|
-
private
|
|
1346
|
+
private get lastActivityAt();
|
|
1347
|
+
private scheduleIdleCheck;
|
|
1348
|
+
private armIdleTimer;
|
|
1349
|
+
private checkIdle;
|
|
1341
1350
|
private cancelIdleTimer;
|
|
1342
1351
|
private rewriteForClient;
|
|
1343
1352
|
private recordAndBroadcast;
|
|
@@ -1349,7 +1358,9 @@ declare class Session {
|
|
|
1349
1358
|
declare const SessionRecord: z.ZodObject<{
|
|
1350
1359
|
version: z.ZodLiteral<1>;
|
|
1351
1360
|
sessionId: z.ZodString;
|
|
1361
|
+
lineageId: z.ZodOptional<z.ZodString>;
|
|
1352
1362
|
upstreamSessionId: z.ZodString;
|
|
1363
|
+
importedFromSessionId: z.ZodOptional<z.ZodString>;
|
|
1353
1364
|
agentId: z.ZodString;
|
|
1354
1365
|
cwd: z.ZodString;
|
|
1355
1366
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -1380,6 +1391,8 @@ declare const SessionRecord: z.ZodObject<{
|
|
|
1380
1391
|
agentArgs?: string[] | undefined;
|
|
1381
1392
|
currentModel?: string | undefined;
|
|
1382
1393
|
currentMode?: string | undefined;
|
|
1394
|
+
lineageId?: string | undefined;
|
|
1395
|
+
importedFromSessionId?: string | undefined;
|
|
1383
1396
|
agentCommands?: {
|
|
1384
1397
|
name: string;
|
|
1385
1398
|
description?: string | undefined;
|
|
@@ -1396,6 +1409,8 @@ declare const SessionRecord: z.ZodObject<{
|
|
|
1396
1409
|
agentArgs?: string[] | undefined;
|
|
1397
1410
|
currentModel?: string | undefined;
|
|
1398
1411
|
currentMode?: string | undefined;
|
|
1412
|
+
lineageId?: string | undefined;
|
|
1413
|
+
importedFromSessionId?: string | undefined;
|
|
1399
1414
|
agentCommands?: {
|
|
1400
1415
|
name: string;
|
|
1401
1416
|
description?: string | undefined;
|
|
@@ -1406,9 +1421,145 @@ declare class SessionStore {
|
|
|
1406
1421
|
write(record: Omit<SessionRecord, "version">): Promise<void>;
|
|
1407
1422
|
read(sessionId: string): Promise<SessionRecord | undefined>;
|
|
1408
1423
|
delete(sessionId: string): Promise<void>;
|
|
1424
|
+
findByLineageId(lineageId: string): Promise<SessionRecord | undefined>;
|
|
1409
1425
|
list(): Promise<SessionRecord[]>;
|
|
1410
1426
|
}
|
|
1411
1427
|
|
|
1428
|
+
declare const Bundle: z.ZodObject<{
|
|
1429
|
+
version: z.ZodLiteral<1>;
|
|
1430
|
+
exportedAt: z.ZodString;
|
|
1431
|
+
exportedFrom: z.ZodObject<{
|
|
1432
|
+
hydraVersion: z.ZodString;
|
|
1433
|
+
machine: z.ZodString;
|
|
1434
|
+
}, "strip", z.ZodTypeAny, {
|
|
1435
|
+
hydraVersion: string;
|
|
1436
|
+
machine: string;
|
|
1437
|
+
}, {
|
|
1438
|
+
hydraVersion: string;
|
|
1439
|
+
machine: string;
|
|
1440
|
+
}>;
|
|
1441
|
+
session: z.ZodObject<{
|
|
1442
|
+
sessionId: z.ZodString;
|
|
1443
|
+
lineageId: z.ZodString;
|
|
1444
|
+
agentId: z.ZodString;
|
|
1445
|
+
cwd: z.ZodString;
|
|
1446
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1447
|
+
currentModel: z.ZodOptional<z.ZodString>;
|
|
1448
|
+
currentMode: z.ZodOptional<z.ZodString>;
|
|
1449
|
+
agentCommands: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1450
|
+
name: z.ZodString;
|
|
1451
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1452
|
+
}, "strip", z.ZodTypeAny, {
|
|
1453
|
+
name: string;
|
|
1454
|
+
description?: string | undefined;
|
|
1455
|
+
}, {
|
|
1456
|
+
name: string;
|
|
1457
|
+
description?: string | undefined;
|
|
1458
|
+
}>, "many">>;
|
|
1459
|
+
createdAt: z.ZodString;
|
|
1460
|
+
updatedAt: z.ZodString;
|
|
1461
|
+
}, "strip", z.ZodTypeAny, {
|
|
1462
|
+
cwd: string;
|
|
1463
|
+
agentId: string;
|
|
1464
|
+
sessionId: string;
|
|
1465
|
+
updatedAt: string;
|
|
1466
|
+
lineageId: string;
|
|
1467
|
+
createdAt: string;
|
|
1468
|
+
title?: string | undefined;
|
|
1469
|
+
currentModel?: string | undefined;
|
|
1470
|
+
currentMode?: string | undefined;
|
|
1471
|
+
agentCommands?: {
|
|
1472
|
+
name: string;
|
|
1473
|
+
description?: string | undefined;
|
|
1474
|
+
}[] | undefined;
|
|
1475
|
+
}, {
|
|
1476
|
+
cwd: string;
|
|
1477
|
+
agentId: string;
|
|
1478
|
+
sessionId: string;
|
|
1479
|
+
updatedAt: string;
|
|
1480
|
+
lineageId: string;
|
|
1481
|
+
createdAt: string;
|
|
1482
|
+
title?: string | undefined;
|
|
1483
|
+
currentModel?: string | undefined;
|
|
1484
|
+
currentMode?: string | undefined;
|
|
1485
|
+
agentCommands?: {
|
|
1486
|
+
name: string;
|
|
1487
|
+
description?: string | undefined;
|
|
1488
|
+
}[] | undefined;
|
|
1489
|
+
}>;
|
|
1490
|
+
history: z.ZodArray<z.ZodObject<{
|
|
1491
|
+
method: z.ZodString;
|
|
1492
|
+
params: z.ZodUnknown;
|
|
1493
|
+
recordedAt: z.ZodNumber;
|
|
1494
|
+
}, "strip", z.ZodTypeAny, {
|
|
1495
|
+
method: string;
|
|
1496
|
+
recordedAt: number;
|
|
1497
|
+
params?: unknown;
|
|
1498
|
+
}, {
|
|
1499
|
+
method: string;
|
|
1500
|
+
recordedAt: number;
|
|
1501
|
+
params?: unknown;
|
|
1502
|
+
}>, "many">;
|
|
1503
|
+
promptHistory: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1504
|
+
}, "strip", z.ZodTypeAny, {
|
|
1505
|
+
version: 1;
|
|
1506
|
+
exportedAt: string;
|
|
1507
|
+
exportedFrom: {
|
|
1508
|
+
hydraVersion: string;
|
|
1509
|
+
machine: string;
|
|
1510
|
+
};
|
|
1511
|
+
session: {
|
|
1512
|
+
cwd: string;
|
|
1513
|
+
agentId: string;
|
|
1514
|
+
sessionId: string;
|
|
1515
|
+
updatedAt: string;
|
|
1516
|
+
lineageId: string;
|
|
1517
|
+
createdAt: string;
|
|
1518
|
+
title?: string | undefined;
|
|
1519
|
+
currentModel?: string | undefined;
|
|
1520
|
+
currentMode?: string | undefined;
|
|
1521
|
+
agentCommands?: {
|
|
1522
|
+
name: string;
|
|
1523
|
+
description?: string | undefined;
|
|
1524
|
+
}[] | undefined;
|
|
1525
|
+
};
|
|
1526
|
+
history: {
|
|
1527
|
+
method: string;
|
|
1528
|
+
recordedAt: number;
|
|
1529
|
+
params?: unknown;
|
|
1530
|
+
}[];
|
|
1531
|
+
promptHistory?: string[] | undefined;
|
|
1532
|
+
}, {
|
|
1533
|
+
version: 1;
|
|
1534
|
+
exportedAt: string;
|
|
1535
|
+
exportedFrom: {
|
|
1536
|
+
hydraVersion: string;
|
|
1537
|
+
machine: string;
|
|
1538
|
+
};
|
|
1539
|
+
session: {
|
|
1540
|
+
cwd: string;
|
|
1541
|
+
agentId: string;
|
|
1542
|
+
sessionId: string;
|
|
1543
|
+
updatedAt: string;
|
|
1544
|
+
lineageId: string;
|
|
1545
|
+
createdAt: string;
|
|
1546
|
+
title?: string | undefined;
|
|
1547
|
+
currentModel?: string | undefined;
|
|
1548
|
+
currentMode?: string | undefined;
|
|
1549
|
+
agentCommands?: {
|
|
1550
|
+
name: string;
|
|
1551
|
+
description?: string | undefined;
|
|
1552
|
+
}[] | undefined;
|
|
1553
|
+
};
|
|
1554
|
+
history: {
|
|
1555
|
+
method: string;
|
|
1556
|
+
recordedAt: number;
|
|
1557
|
+
params?: unknown;
|
|
1558
|
+
}[];
|
|
1559
|
+
promptHistory?: string[] | undefined;
|
|
1560
|
+
}>;
|
|
1561
|
+
type Bundle = z.infer<typeof Bundle>;
|
|
1562
|
+
|
|
1412
1563
|
interface CreateSessionParams {
|
|
1413
1564
|
cwd: string;
|
|
1414
1565
|
agentId: string;
|
|
@@ -1423,10 +1574,10 @@ interface ResurrectParams {
|
|
|
1423
1574
|
cwd: string;
|
|
1424
1575
|
title?: string;
|
|
1425
1576
|
agentArgs?: string[];
|
|
1426
|
-
seedHistory?: CachedNotification[];
|
|
1427
1577
|
currentModel?: string;
|
|
1428
1578
|
currentMode?: string;
|
|
1429
1579
|
agentCommands?: AdvertisedCommand[];
|
|
1580
|
+
createdAt?: string;
|
|
1430
1581
|
}
|
|
1431
1582
|
type AgentSpawner = (opts: AgentInstanceOptions) => AgentInstance;
|
|
1432
1583
|
interface SessionManagerOptions {
|
|
@@ -1445,16 +1596,33 @@ declare class SessionManager {
|
|
|
1445
1596
|
create(params: CreateSessionParams): Promise<Session>;
|
|
1446
1597
|
resurrect(params: ResurrectParams): Promise<Session>;
|
|
1447
1598
|
private doResurrect;
|
|
1599
|
+
private doResurrectFromImport;
|
|
1448
1600
|
private bootstrapAgent;
|
|
1449
1601
|
private attachManagerHooks;
|
|
1450
|
-
getHistory(sessionId: string): Promise<
|
|
1602
|
+
getHistory(sessionId: string): Promise<HistoryEntry[] | undefined>;
|
|
1451
1603
|
loadFromDisk(sessionId: string): Promise<ResurrectParams | undefined>;
|
|
1604
|
+
private deriveTitleFromHistory;
|
|
1452
1605
|
get(sessionId: string): Session | undefined;
|
|
1453
1606
|
resolveCanonicalId(input: string): Promise<string | undefined>;
|
|
1454
1607
|
require(sessionId: string): Session;
|
|
1455
1608
|
list(filter?: {
|
|
1456
1609
|
cwd?: string;
|
|
1457
1610
|
}): Promise<SessionListEntry[]>;
|
|
1611
|
+
exportBundle(sessionId: string): Promise<{
|
|
1612
|
+
record: SessionRecord & {
|
|
1613
|
+
lineageId: string;
|
|
1614
|
+
};
|
|
1615
|
+
history: HistoryEntry[];
|
|
1616
|
+
promptHistory: string[];
|
|
1617
|
+
} | undefined>;
|
|
1618
|
+
importBundle(bundle: Bundle, opts?: {
|
|
1619
|
+
replace?: boolean;
|
|
1620
|
+
}): Promise<{
|
|
1621
|
+
sessionId: string;
|
|
1622
|
+
importedFromSessionId: string;
|
|
1623
|
+
replaced: boolean;
|
|
1624
|
+
}>;
|
|
1625
|
+
private writeImportedRecord;
|
|
1458
1626
|
deleteRecord(sessionId: string): Promise<boolean>;
|
|
1459
1627
|
hasRecord(sessionId: string): Promise<boolean>;
|
|
1460
1628
|
private persistTitle;
|
|
@@ -1462,6 +1630,7 @@ declare class SessionManager {
|
|
|
1462
1630
|
private persistSnapshot;
|
|
1463
1631
|
private enqueueMetaWrite;
|
|
1464
1632
|
closeAll(): Promise<void>;
|
|
1633
|
+
flushMetaWrites(): Promise<void>;
|
|
1465
1634
|
}
|
|
1466
1635
|
|
|
1467
1636
|
interface ExtensionContext {
|