@hydra-acp/cli 0.1.21 → 0.1.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/dist/index.d.ts CHANGED
@@ -24,10 +24,9 @@ type ExtensionConfig = ExtensionBody & {
24
24
  name: string;
25
25
  };
26
26
  declare const HydraConfig: z.ZodObject<{
27
- daemon: z.ZodObject<{
27
+ daemon: z.ZodDefault<z.ZodObject<{
28
28
  host: z.ZodDefault<z.ZodString>;
29
29
  port: z.ZodDefault<z.ZodNumber>;
30
- authToken: z.ZodString;
31
30
  logLevel: z.ZodDefault<z.ZodEnum<["debug", "info", "warn", "error"]>>;
32
31
  tls: z.ZodOptional<z.ZodObject<{
33
32
  cert: z.ZodString;
@@ -45,7 +44,6 @@ declare const HydraConfig: z.ZodObject<{
45
44
  }, "strip", z.ZodTypeAny, {
46
45
  host: string;
47
46
  port: number;
48
- authToken: string;
49
47
  logLevel: "info" | "debug" | "warn" | "error";
50
48
  sessionIdleTimeoutSeconds: number;
51
49
  sessionHistoryMaxEntries: number;
@@ -55,7 +53,6 @@ declare const HydraConfig: z.ZodObject<{
55
53
  key: string;
56
54
  } | undefined;
57
55
  }, {
58
- authToken: string;
59
56
  host?: string | undefined;
60
57
  port?: number | undefined;
61
58
  logLevel?: "info" | "debug" | "warn" | "error" | undefined;
@@ -66,7 +63,7 @@ declare const HydraConfig: z.ZodObject<{
66
63
  sessionIdleTimeoutSeconds?: number | undefined;
67
64
  sessionHistoryMaxEntries?: number | undefined;
68
65
  agentStderrTailBytes?: number | undefined;
69
- }>;
66
+ }>>;
70
67
  registry: z.ZodDefault<z.ZodObject<{
71
68
  url: z.ZodDefault<z.ZodString>;
72
69
  ttlHours: z.ZodDefault<z.ZodNumber>;
@@ -97,6 +94,7 @@ declare const HydraConfig: z.ZodObject<{
97
94
  env?: Record<string, string> | undefined;
98
95
  enabled?: boolean | undefined;
99
96
  }>>>;
97
+ npmRegistry: z.ZodOptional<z.ZodString>;
100
98
  tui: z.ZodDefault<z.ZodObject<{
101
99
  repaintThrottleMs: z.ZodDefault<z.ZodNumber>;
102
100
  maxScrollbackLines: z.ZodDefault<z.ZodNumber>;
@@ -123,7 +121,6 @@ declare const HydraConfig: z.ZodObject<{
123
121
  daemon: {
124
122
  host: string;
125
123
  port: number;
126
- authToken: string;
127
124
  logLevel: "info" | "debug" | "warn" | "error";
128
125
  sessionIdleTimeoutSeconds: number;
129
126
  sessionHistoryMaxEntries: number;
@@ -155,9 +152,9 @@ declare const HydraConfig: z.ZodObject<{
155
152
  defaultModels: Record<string, string>;
156
153
  defaultCwd: string;
157
154
  sessionListColdLimit: number;
155
+ npmRegistry?: string | undefined;
158
156
  }, {
159
- daemon: {
160
- authToken: string;
157
+ daemon?: {
161
158
  host?: string | undefined;
162
159
  port?: number | undefined;
163
160
  logLevel?: "info" | "debug" | "warn" | "error" | undefined;
@@ -168,7 +165,7 @@ declare const HydraConfig: z.ZodObject<{
168
165
  sessionIdleTimeoutSeconds?: number | undefined;
169
166
  sessionHistoryMaxEntries?: number | undefined;
170
167
  agentStderrTailBytes?: number | undefined;
171
- };
168
+ } | undefined;
172
169
  extensions?: Record<string, {
173
170
  command?: string[] | undefined;
174
171
  args?: string[] | undefined;
@@ -191,12 +188,11 @@ declare const HydraConfig: z.ZodObject<{
191
188
  defaultModels?: Record<string, string> | undefined;
192
189
  defaultCwd?: string | undefined;
193
190
  sessionListColdLimit?: number | undefined;
191
+ npmRegistry?: string | undefined;
194
192
  }>;
195
193
  type HydraConfig = z.infer<typeof HydraConfig>;
196
194
  declare function loadConfig(): Promise<HydraConfig>;
197
- declare function ensureConfig(): Promise<HydraConfig>;
198
195
  declare function writeConfig(config: HydraConfig): Promise<void>;
199
- declare function generateAuthToken(): string;
200
196
  declare function defaultConfig(): HydraConfig;
201
197
 
202
198
  declare const RegistryAgent: z.ZodObject<{
@@ -1224,7 +1220,9 @@ interface SpawnPlan {
1224
1220
  args: string[];
1225
1221
  env: Record<string, string>;
1226
1222
  }
1227
- declare function planSpawn(agent: RegistryAgent, callerArgs?: string[]): Promise<SpawnPlan>;
1223
+ declare function planSpawn(agent: RegistryAgent, callerArgs?: string[], options?: {
1224
+ npmRegistry?: string;
1225
+ }): Promise<SpawnPlan>;
1228
1226
 
1229
1227
  type JsonRpcId = string | number;
1230
1228
  interface JsonRpcRequest {
@@ -1290,6 +1288,18 @@ declare const SessionAttachParams: z.ZodObject<{
1290
1288
  _meta?: Record<string, unknown> | undefined;
1291
1289
  }>;
1292
1290
  type SessionAttachParams = z.infer<typeof SessionAttachParams>;
1291
+ interface PromptOriginator {
1292
+ clientId: string;
1293
+ name?: string;
1294
+ version?: string;
1295
+ }
1296
+ interface PromptQueueEntry {
1297
+ messageId: string;
1298
+ originator: PromptOriginator;
1299
+ prompt: unknown[];
1300
+ position: number;
1301
+ enqueuedAt: number;
1302
+ }
1293
1303
  declare const SessionDetachParams: z.ZodObject<{
1294
1304
  sessionId: z.ZodString;
1295
1305
  }, "strip", z.ZodTypeAny, {
@@ -1497,6 +1507,28 @@ declare const SessionListResult: z.ZodObject<{
1497
1507
  nextCursor?: string | undefined;
1498
1508
  }>;
1499
1509
  type SessionListResult = z.infer<typeof SessionListResult>;
1510
+ declare const CancelPromptResult: z.ZodObject<{
1511
+ cancelled: z.ZodBoolean;
1512
+ reason: z.ZodEnum<["ok", "not_found", "already_running"]>;
1513
+ }, "strip", z.ZodTypeAny, {
1514
+ reason: "ok" | "not_found" | "already_running";
1515
+ cancelled: boolean;
1516
+ }, {
1517
+ reason: "ok" | "not_found" | "already_running";
1518
+ cancelled: boolean;
1519
+ }>;
1520
+ type CancelPromptResult = z.infer<typeof CancelPromptResult>;
1521
+ declare const UpdatePromptResult: z.ZodObject<{
1522
+ updated: z.ZodBoolean;
1523
+ reason: z.ZodEnum<["ok", "not_found", "already_running"]>;
1524
+ }, "strip", z.ZodTypeAny, {
1525
+ reason: "ok" | "not_found" | "already_running";
1526
+ updated: boolean;
1527
+ }, {
1528
+ reason: "ok" | "not_found" | "already_running";
1529
+ updated: boolean;
1530
+ }>;
1531
+ type UpdatePromptResult = z.infer<typeof UpdatePromptResult>;
1500
1532
  interface SessionCapabilities {
1501
1533
  attach?: Record<string, never>;
1502
1534
  list?: boolean;
@@ -1527,6 +1559,7 @@ interface InitializeResult {
1527
1559
  id: string;
1528
1560
  description: string;
1529
1561
  }>;
1562
+ _meta?: Record<string, unknown>;
1530
1563
  }
1531
1564
 
1532
1565
  interface MessageStream {
@@ -1606,6 +1639,11 @@ interface AdvertisedCommand {
1606
1639
  name: string;
1607
1640
  description?: string;
1608
1641
  }
1642
+ interface AdvertisedMode {
1643
+ id: string;
1644
+ name?: string;
1645
+ description?: string;
1646
+ }
1609
1647
 
1610
1648
  interface HistoryEntry {
1611
1649
  method: string;
@@ -1627,6 +1665,18 @@ declare class HistoryStore {
1627
1665
  private enqueue;
1628
1666
  }
1629
1667
 
1668
+ interface PersistedQueueEntry {
1669
+ messageId: string;
1670
+ originator: {
1671
+ clientInfo: {
1672
+ name?: string;
1673
+ version?: string;
1674
+ };
1675
+ };
1676
+ prompt: unknown[];
1677
+ enqueuedAt: number;
1678
+ }
1679
+
1630
1680
  interface AttachedClient {
1631
1681
  clientId: string;
1632
1682
  connection: JsonRpcConnection;
@@ -1674,6 +1724,7 @@ interface SessionInit {
1674
1724
  currentMode?: string;
1675
1725
  currentUsage?: UsageSnapshot;
1676
1726
  agentCommands?: AdvertisedCommand[];
1727
+ agentModes?: AdvertisedMode[];
1677
1728
  firstPromptSeeded?: boolean;
1678
1729
  createdAt?: number;
1679
1730
  }
@@ -1699,7 +1750,9 @@ declare class Session {
1699
1750
  private clients;
1700
1751
  private historyStore;
1701
1752
  private promptQueue;
1753
+ private currentEntry;
1702
1754
  private promptInFlight;
1755
+ private queueWriteChain;
1703
1756
  private closed;
1704
1757
  private closeHandlers;
1705
1758
  private titleHandlers;
@@ -1718,12 +1771,15 @@ declare class Session {
1718
1771
  private logger;
1719
1772
  private agentChangeHandlers;
1720
1773
  private agentAdvertisedCommands;
1774
+ private agentAdvertisedModes;
1721
1775
  private agentCommandsHandlers;
1776
+ private agentModesHandlers;
1722
1777
  private modelHandlers;
1723
1778
  private modeHandlers;
1724
1779
  private usageHandlers;
1725
1780
  constructor(init: SessionInit);
1726
1781
  private broadcastMergedCommands;
1782
+ private broadcastAvailableModes;
1727
1783
  private wireAgent;
1728
1784
  onAgentChange(handler: (info: {
1729
1785
  agentId: string;
@@ -1752,6 +1808,16 @@ declare class Session {
1752
1808
  prompt(clientId: string, params: unknown): Promise<unknown>;
1753
1809
  private broadcastPromptReceived;
1754
1810
  private broadcastTurnComplete;
1811
+ private visibleQueueDepth;
1812
+ private broadcastQueueAdded;
1813
+ private broadcastQueueUpdated;
1814
+ private broadcastQueueRemoved;
1815
+ private broadcastQueueNotification;
1816
+ queueSnapshot(): PromptQueueEntry[];
1817
+ flushPersistWrites(): Promise<void>;
1818
+ replayPersistedQueue(entries: PersistedQueueEntry[]): void;
1819
+ cancelQueuedPrompt(messageId: string): CancelPromptResult;
1820
+ updateQueuedPrompt(messageId: string, prompt: unknown[]): UpdatePromptResult;
1755
1821
  cancel(clientId: string): Promise<void>;
1756
1822
  forwardRequest(method: string, params: unknown): Promise<unknown>;
1757
1823
  private rewriteForAgent;
@@ -1766,12 +1832,15 @@ declare class Session {
1766
1832
  private maybeApplyAgentMode;
1767
1833
  private maybeApplyAgentUsage;
1768
1834
  private setAgentAdvertisedCommands;
1835
+ private setAgentAdvertisedModes;
1769
1836
  onAgentCommandsChange(handler: (commands: AdvertisedCommand[]) => void): void;
1837
+ onAgentModesChange(handler: (modes: AdvertisedMode[]) => void): void;
1770
1838
  onModelChange(handler: (model: string) => void): void;
1771
1839
  onModeChange(handler: (mode: string) => void): void;
1772
1840
  onUsageChange(handler: (usage: UsageSnapshot) => void): void;
1773
1841
  mergedAvailableCommands(): AdvertisedCommand[];
1774
1842
  agentOnlyAdvertisedCommands(): AdvertisedCommand[];
1843
+ availableModes(): AdvertisedMode[];
1775
1844
  private maybeApplyAgentSessionInfo;
1776
1845
  private handleSlashCommand;
1777
1846
  private runTitleCommand;
@@ -1792,7 +1861,11 @@ declare class Session {
1792
1861
  private recordAndBroadcast;
1793
1862
  private handlePermissionRequest;
1794
1863
  private enqueuePrompt;
1864
+ private enqueueUserPrompt;
1865
+ private persistRewrite;
1866
+ private persistedFromEntry;
1795
1867
  private drainQueue;
1868
+ private runQueueEntry;
1796
1869
  }
1797
1870
 
1798
1871
  declare const SessionRecord: z.ZodObject<{
@@ -1835,6 +1908,19 @@ declare const SessionRecord: z.ZodObject<{
1835
1908
  name: string;
1836
1909
  description?: string | undefined;
1837
1910
  }>, "many">>;
1911
+ agentModes: z.ZodOptional<z.ZodArray<z.ZodObject<{
1912
+ id: z.ZodString;
1913
+ name: z.ZodOptional<z.ZodString>;
1914
+ description: z.ZodOptional<z.ZodString>;
1915
+ }, "strip", z.ZodTypeAny, {
1916
+ id: string;
1917
+ name?: string | undefined;
1918
+ description?: string | undefined;
1919
+ }, {
1920
+ id: string;
1921
+ name?: string | undefined;
1922
+ description?: string | undefined;
1923
+ }>, "many">>;
1838
1924
  createdAt: z.ZodString;
1839
1925
  updatedAt: z.ZodString;
1840
1926
  }, "strip", z.ZodTypeAny, {
@@ -1863,6 +1949,11 @@ declare const SessionRecord: z.ZodObject<{
1863
1949
  name: string;
1864
1950
  description?: string | undefined;
1865
1951
  }[] | undefined;
1952
+ agentModes?: {
1953
+ id: string;
1954
+ name?: string | undefined;
1955
+ description?: string | undefined;
1956
+ }[] | undefined;
1866
1957
  }, {
1867
1958
  version: 1;
1868
1959
  cwd: string;
@@ -1889,6 +1980,11 @@ declare const SessionRecord: z.ZodObject<{
1889
1980
  name: string;
1890
1981
  description?: string | undefined;
1891
1982
  }[] | undefined;
1983
+ agentModes?: {
1984
+ id: string;
1985
+ name?: string | undefined;
1986
+ description?: string | undefined;
1987
+ }[] | undefined;
1892
1988
  }>;
1893
1989
  type SessionRecord = z.infer<typeof SessionRecord>;
1894
1990
  declare class SessionStore {
@@ -1947,6 +2043,19 @@ declare const Bundle: z.ZodObject<{
1947
2043
  name: string;
1948
2044
  description?: string | undefined;
1949
2045
  }>, "many">>;
2046
+ agentModes: z.ZodOptional<z.ZodArray<z.ZodObject<{
2047
+ id: z.ZodString;
2048
+ name: z.ZodOptional<z.ZodString>;
2049
+ description: z.ZodOptional<z.ZodString>;
2050
+ }, "strip", z.ZodTypeAny, {
2051
+ id: string;
2052
+ name?: string | undefined;
2053
+ description?: string | undefined;
2054
+ }, {
2055
+ id: string;
2056
+ name?: string | undefined;
2057
+ description?: string | undefined;
2058
+ }>, "many">>;
1950
2059
  createdAt: z.ZodString;
1951
2060
  updatedAt: z.ZodString;
1952
2061
  }, "strip", z.ZodTypeAny, {
@@ -1970,6 +2079,11 @@ declare const Bundle: z.ZodObject<{
1970
2079
  name: string;
1971
2080
  description?: string | undefined;
1972
2081
  }[] | undefined;
2082
+ agentModes?: {
2083
+ id: string;
2084
+ name?: string | undefined;
2085
+ description?: string | undefined;
2086
+ }[] | undefined;
1973
2087
  }, {
1974
2088
  cwd: string;
1975
2089
  agentId: string;
@@ -1991,6 +2105,11 @@ declare const Bundle: z.ZodObject<{
1991
2105
  name: string;
1992
2106
  description?: string | undefined;
1993
2107
  }[] | undefined;
2108
+ agentModes?: {
2109
+ id: string;
2110
+ name?: string | undefined;
2111
+ description?: string | undefined;
2112
+ }[] | undefined;
1994
2113
  }>;
1995
2114
  history: z.ZodArray<z.ZodObject<{
1996
2115
  method: z.ZodString;
@@ -2008,11 +2127,6 @@ declare const Bundle: z.ZodObject<{
2008
2127
  promptHistory: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2009
2128
  }, "strip", z.ZodTypeAny, {
2010
2129
  version: 1;
2011
- exportedAt: string;
2012
- exportedFrom: {
2013
- hydraVersion: string;
2014
- machine: string;
2015
- };
2016
2130
  session: {
2017
2131
  cwd: string;
2018
2132
  agentId: string;
@@ -2034,6 +2148,16 @@ declare const Bundle: z.ZodObject<{
2034
2148
  name: string;
2035
2149
  description?: string | undefined;
2036
2150
  }[] | undefined;
2151
+ agentModes?: {
2152
+ id: string;
2153
+ name?: string | undefined;
2154
+ description?: string | undefined;
2155
+ }[] | undefined;
2156
+ };
2157
+ exportedAt: string;
2158
+ exportedFrom: {
2159
+ hydraVersion: string;
2160
+ machine: string;
2037
2161
  };
2038
2162
  history: {
2039
2163
  method: string;
@@ -2043,11 +2167,6 @@ declare const Bundle: z.ZodObject<{
2043
2167
  promptHistory?: string[] | undefined;
2044
2168
  }, {
2045
2169
  version: 1;
2046
- exportedAt: string;
2047
- exportedFrom: {
2048
- hydraVersion: string;
2049
- machine: string;
2050
- };
2051
2170
  session: {
2052
2171
  cwd: string;
2053
2172
  agentId: string;
@@ -2069,6 +2188,16 @@ declare const Bundle: z.ZodObject<{
2069
2188
  name: string;
2070
2189
  description?: string | undefined;
2071
2190
  }[] | undefined;
2191
+ agentModes?: {
2192
+ id: string;
2193
+ name?: string | undefined;
2194
+ description?: string | undefined;
2195
+ }[] | undefined;
2196
+ };
2197
+ exportedAt: string;
2198
+ exportedFrom: {
2199
+ hydraVersion: string;
2200
+ machine: string;
2072
2201
  };
2073
2202
  history: {
2074
2203
  method: string;
@@ -2098,6 +2227,7 @@ interface ResurrectParams {
2098
2227
  currentMode?: string;
2099
2228
  currentUsage?: UsageSnapshot;
2100
2229
  agentCommands?: AdvertisedCommand[];
2230
+ agentModes?: AdvertisedMode[];
2101
2231
  createdAt?: string;
2102
2232
  }
2103
2233
  type AgentSpawner = (opts: AgentInstanceOptions) => AgentInstance;
@@ -2106,6 +2236,7 @@ interface SessionManagerOptions {
2106
2236
  defaultModels?: Record<string, string>;
2107
2237
  sessionHistoryMaxEntries?: number;
2108
2238
  logger?: AgentLogger;
2239
+ npmRegistry?: string;
2109
2240
  }
2110
2241
  declare class SessionManager {
2111
2242
  private registry;
@@ -2119,6 +2250,7 @@ declare class SessionManager {
2119
2250
  private sessionHistoryMaxEntries;
2120
2251
  private metaWriteQueues;
2121
2252
  private logger?;
2253
+ private npmRegistry?;
2122
2254
  constructor(registry: Registry, spawner?: AgentSpawner, store?: SessionStore, options?: SessionManagerOptions);
2123
2255
  create(params: CreateSessionParams): Promise<Session>;
2124
2256
  resurrect(params: ResurrectParams): Promise<Session>;
@@ -2160,13 +2292,14 @@ declare class SessionManager {
2160
2292
  private enqueueMetaWrite;
2161
2293
  closeAll(): Promise<void>;
2162
2294
  flushMetaWrites(): Promise<void>;
2295
+ resurrectPendingQueues(): Promise<void>;
2163
2296
  }
2164
2297
 
2165
2298
  interface ExtensionContext {
2166
2299
  daemonUrl: string;
2167
2300
  daemonHost: string;
2168
2301
  daemonPort: number;
2169
- daemonToken: string;
2302
+ serviceToken: string;
2170
2303
  daemonWsUrl: string;
2171
2304
  hydraHome: string;
2172
2305
  }
@@ -2217,10 +2350,14 @@ interface DaemonHandle {
2217
2350
  extensions: ExtensionManager;
2218
2351
  shutdown: () => Promise<void>;
2219
2352
  }
2220
- declare function startDaemon(config: HydraConfig): Promise<DaemonHandle>;
2353
+ declare function startDaemon(config: HydraConfig, serviceToken: string): Promise<DaemonHandle>;
2221
2354
 
2222
2355
  declare function wsToMessageStream(ws: WebSocket): MessageStream;
2223
2356
 
2357
+ declare function generateServiceToken(): string;
2358
+ declare function loadServiceToken(): Promise<string>;
2359
+ declare function ensureServiceToken(): Promise<string>;
2360
+
2224
2361
  declare function hydraHome(): string;
2225
2362
  declare const paths: {
2226
2363
  home: typeof hydraHome;
@@ -2237,6 +2374,7 @@ declare const paths: {
2237
2374
  sessionDir: (id: string) => string;
2238
2375
  sessionFile: (id: string) => string;
2239
2376
  historyFile: (id: string) => string;
2377
+ queueFile: (id: string) => string;
2240
2378
  extensionsDir: () => string;
2241
2379
  extensionLogFile: (name: string) => string;
2242
2380
  extensionPidFile: (name: string) => string;
@@ -2244,4 +2382,4 @@ declare const paths: {
2244
2382
  tuiLogFile: () => string;
2245
2383
  };
2246
2384
 
2247
- export { type AgentCapabilities, AgentInstance, HistoryPolicy, HydraConfig, type InitializeResult, JsonRpcConnection, type MessageStream, Registry, Session, SessionAttachParams, type SessionCapabilities, SessionDetachParams, SessionListEntry, SessionListParams, SessionListResult, SessionManager, defaultConfig, ensureConfig, generateAuthToken, loadConfig, ndjsonStreamFromStdio, paths, planSpawn, startDaemon, writeConfig, wsToMessageStream };
2385
+ export { type AgentCapabilities, AgentInstance, HistoryPolicy, HydraConfig, type InitializeResult, JsonRpcConnection, type MessageStream, Registry, Session, SessionAttachParams, type SessionCapabilities, SessionDetachParams, SessionListEntry, SessionListParams, SessionListResult, SessionManager, defaultConfig, ensureServiceToken, generateServiceToken, loadConfig, loadServiceToken, ndjsonStreamFromStdio, paths, planSpawn, startDaemon, writeConfig, wsToMessageStream };