@linkshell/host 0.1.0 → 0.1.2

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.
Files changed (78) hide show
  1. package/dist/host/src/carry.d.ts +15 -0
  2. package/dist/host/src/carry.js +83 -0
  3. package/dist/host/src/carry.js.map +1 -0
  4. package/dist/host/src/drivers/acp/driver.d.ts +21 -3
  5. package/dist/host/src/drivers/acp/driver.js +99 -13
  6. package/dist/host/src/drivers/acp/driver.js.map +1 -1
  7. package/dist/host/src/drivers/acp/mapper.d.ts +5 -1
  8. package/dist/host/src/drivers/acp/mapper.js +58 -6
  9. package/dist/host/src/drivers/acp/mapper.js.map +1 -1
  10. package/dist/host/src/drivers/claude/driver.d.ts +76 -8
  11. package/dist/host/src/drivers/claude/driver.js +510 -29
  12. package/dist/host/src/drivers/claude/driver.js.map +1 -1
  13. package/dist/host/src/drivers/claude/holders.d.ts +9 -0
  14. package/dist/host/src/drivers/claude/holders.js +61 -0
  15. package/dist/host/src/drivers/claude/holders.js.map +1 -0
  16. package/dist/host/src/drivers/claude/transcript.d.ts +108 -64
  17. package/dist/host/src/drivers/claude/transcript.js +260 -22
  18. package/dist/host/src/drivers/claude/transcript.js.map +1 -1
  19. package/dist/host/src/drivers/codex/commands.d.ts +27 -0
  20. package/dist/host/src/drivers/codex/commands.js +23 -0
  21. package/dist/host/src/drivers/codex/commands.js.map +1 -0
  22. package/dist/host/src/drivers/codex/driver.d.ts +21 -1
  23. package/dist/host/src/drivers/codex/driver.js +140 -1
  24. package/dist/host/src/drivers/codex/driver.js.map +1 -1
  25. package/dist/host/src/drivers/codex/mapper.d.ts +4 -0
  26. package/dist/host/src/drivers/codex/mapper.js +29 -5
  27. package/dist/host/src/drivers/codex/mapper.js.map +1 -1
  28. package/dist/host/src/drivers/types.d.ts +45 -4
  29. package/dist/host/src/fs.d.ts +26 -4
  30. package/dist/host/src/fs.js +71 -17
  31. package/dist/host/src/fs.js.map +1 -1
  32. package/dist/host/src/gateway.d.ts +3 -0
  33. package/dist/host/src/gateway.js +10 -1
  34. package/dist/host/src/gateway.js.map +1 -1
  35. package/dist/host/src/host.d.ts +7 -3
  36. package/dist/host/src/host.js +53 -21
  37. package/dist/host/src/host.js.map +1 -1
  38. package/dist/host/src/hub.d.ts +98 -14
  39. package/dist/host/src/hub.js +639 -27
  40. package/dist/host/src/hub.js.map +1 -1
  41. package/dist/host/src/index.d.ts +1 -1
  42. package/dist/host/src/index.js +1 -1
  43. package/dist/host/src/index.js.map +1 -1
  44. package/dist/host/src/legacy.d.ts +7 -0
  45. package/dist/host/src/legacy.js +36 -0
  46. package/dist/host/src/legacy.js.map +1 -0
  47. package/dist/host/src/rpc/server.d.ts +4 -2
  48. package/dist/host/src/rpc/server.js +62 -5
  49. package/dist/host/src/rpc/server.js.map +1 -1
  50. package/dist/host/src/screen.d.ts +11 -0
  51. package/dist/host/src/screen.js +54 -2
  52. package/dist/host/src/screen.js.map +1 -1
  53. package/dist/host/src/shell-env.d.ts +6 -0
  54. package/dist/host/src/shell-env.js +48 -0
  55. package/dist/host/src/shell-env.js.map +1 -1
  56. package/dist/host/src/slim.d.ts +17 -0
  57. package/dist/host/src/slim.js +66 -0
  58. package/dist/host/src/slim.js.map +1 -0
  59. package/dist/host/src/store.d.ts +81 -3
  60. package/dist/host/src/store.js +249 -16
  61. package/dist/host/src/store.js.map +1 -1
  62. package/dist/host/src/terminals.js +19 -4
  63. package/dist/host/src/terminals.js.map +1 -1
  64. package/dist/host/src/worktrees.d.ts +36 -0
  65. package/dist/host/src/worktrees.js +96 -0
  66. package/dist/host/src/worktrees.js.map +1 -0
  67. package/dist/host/tsconfig.tsbuildinfo +1 -1
  68. package/dist/wire/src/model.d.ts +195 -0
  69. package/dist/wire/src/model.js +68 -0
  70. package/dist/wire/src/model.js.map +1 -1
  71. package/dist/wire/src/relay-client.d.ts +2 -0
  72. package/dist/wire/src/relay-client.js +12 -0
  73. package/dist/wire/src/relay-client.js.map +1 -1
  74. package/dist/wire/src/rpc.d.ts +6543 -160
  75. package/dist/wire/src/rpc.js +154 -6
  76. package/dist/wire/src/rpc.js.map +1 -1
  77. package/dist/wire/src/updates.d.ts +79 -79
  78. package/package.json +3 -2
@@ -1,8 +1,10 @@
1
- import { type AgentInfo, type ContentBlock, type SessionEvent, type SessionSummary } from "@linkshell/wire";
1
+ import { type AgentInfo, type ContentBlock, type SessionEvent, type SessionSummary, type SubagentInfo, type GitInfo, type ProjectSummary, type WorktreeEntry } from "@linkshell/wire";
2
2
  import type { AgentDriver, DesktopController, DesktopLaunchContext, DriverHost, LaunchSpec } from "./drivers/types.js";
3
- import type { HostStore } from "./store.js";
3
+ import { type HostStore } from "./store.js";
4
4
  export interface Subscriber {
5
5
  event(event: SessionEvent): void;
6
+ /** The backlog that follows starts after `startSeq`, not where the subscriber left off. */
7
+ window?(startSeq: number): void;
6
8
  }
7
9
  /**
8
10
  * The host's source of truth for sessions. Drivers push native events in;
@@ -12,16 +14,23 @@ export interface Subscriber {
12
14
  export declare class SessionHub {
13
15
  private readonly store;
14
16
  private readonly log;
17
+ /** Where the host keeps its own files: worktrees go under it. */
18
+ private readonly home;
15
19
  private readonly drivers;
16
20
  private readonly live;
17
21
  private readonly summaryListeners;
22
+ private readonly removedListeners;
18
23
  private readonly auth;
19
24
  /** Terminals (`linkshell <agent>`) currently driving handoff sessions. */
20
25
  private readonly desktops;
21
26
  private discoveryTimer?;
27
+ private readonly branches;
28
+ private worktreeCache?;
22
29
  private authRefreshing?;
23
30
  readonly driverHost: DriverHost;
24
- constructor(store: HostStore, drivers: AgentDriver[], log?: (message: string) => void);
31
+ constructor(store: HostStore, drivers: AgentDriver[], log?: (message: string) => void,
32
+ /** Where the host keeps its own files: worktrees go under it. */
33
+ home?: string);
25
34
  start(options?: {
26
35
  discoveryIntervalMs?: number;
27
36
  }): Promise<void>;
@@ -41,14 +50,16 @@ export declare class SessionHub {
41
50
  sessions: SessionSummary[];
42
51
  nextBefore?: number;
43
52
  };
44
- listProjects(limit?: number): {
45
- name: string;
46
- cwd: string;
47
- lastActiveAt: number;
48
- sessionCount: number;
49
- }[];
53
+ /** Projects, each with the branch checked out there now. */
54
+ listProjects(limit?: number): Promise<ProjectSummary[]>;
55
+ /** Asked for every project each time the list is: remembered for a moment. */
56
+ private branchOf;
50
57
  getSession(sessionId: string): SessionSummary;
51
58
  /** Adds the live-only fields (current activity, first pending permission) to a stored summary. */
59
+ /** Marks a session that works in one of LinkShell's worktrees. */
60
+ private withWorktree;
61
+ /** The worktrees table, read once and again whenever it changes. */
62
+ private worktrees;
52
63
  private decorate;
53
64
  createSession(input: {
54
65
  agent: string;
@@ -56,17 +67,88 @@ export declare class SessionHub {
56
67
  model?: string;
57
68
  prompt?: ContentBlock[];
58
69
  clientMessageId?: string;
70
+ /** Start in a new git worktree of `cwd`'s repository. */
71
+ worktree?: boolean;
72
+ }): Promise<SessionSummary>;
73
+ /**
74
+ * A new session that starts with this one's conversation: all of it, or
75
+ * through the turn `itemId` is in. With `worktree` it works in a new git
76
+ * worktree of the project.
77
+ */
78
+ fork(sessionId: string, options?: {
79
+ itemId?: string;
80
+ worktree?: boolean;
59
81
  }): Promise<SessionSummary>;
60
82
  /**
61
- * Sends everything after `fromSeq`, then streams live events. The backlog read
62
- * and the subscriber registration happen in one synchronous step, so no event
63
- * can fall between them.
83
+ * A fork for an agent that can't fork a session itself: a new session that
84
+ * shows the conversation up to `cut` (its latest page, from our log), whose
85
+ * agent is told that conversation with the first message sent to it.
86
+ */
87
+ private forkByReplay;
88
+ /** Hands a message to the agent — with the conversation a forked session still owes it, the first time. */
89
+ private deliver;
90
+ gitInfo(path: string): Promise<GitInfo | undefined>;
91
+ private newWorktree;
92
+ private dropWorktree;
93
+ listWorktrees(): Promise<WorktreeEntry[]>;
94
+ /** Removes a worktree and its branch, unless a session uses it or (without `force`) work in it would be lost. */
95
+ removeWorktree(path: string, force?: boolean): Promise<void>;
96
+ /**
97
+ * Sends the backlog, then streams live events. A fresh subscriber (or one too
98
+ * far behind to catch up) gets the latest turns only, after the standing
99
+ * state from before them; earlier history is read in pages (`history`).
100
+ * The backlog read and the subscriber registration happen in one synchronous
101
+ * step, so no event can fall between them.
102
+ */
103
+ subscribe(sessionId: string, fromSeq: number, subscriber: Subscriber): Promise<{
104
+ session: SessionSummary;
105
+ startSeq: number;
106
+ }>;
107
+ /**
108
+ * A handoff agent names its commands only once it runs here, so a session
109
+ * still driven at the desk has none to offer. It borrows the list of the
110
+ * agent's latest session in the same folder (or its latest anywhere) until
111
+ * it gets its own: `/compact` typed on the phone works from the first message.
64
112
  */
65
- subscribe(sessionId: string, fromSeq: number, subscriber: Subscriber): Promise<SessionSummary>;
113
+ private lendCommands;
114
+ /** The page of history before `beforeSeq`, oldest first. */
115
+ history(sessionId: string, beforeSeq: number): {
116
+ events: SessionEvent[];
117
+ startSeq: number;
118
+ };
119
+ /** The sub-agents the session started, newest first. */
120
+ subagents(sessionId: string): SubagentInfo[];
121
+ private subagentsOf;
122
+ /** Keeps the sub-agent tally current; true when it changed. */
123
+ private trackSubagent;
124
+ /** A sub-agent's conversation: its call, then what happened under it. */
125
+ subagent(sessionId: string, toolCallId: string): SessionEvent[];
126
+ readEvent(sessionId: string, seq: number): SessionEvent | undefined;
127
+ /** What still holds at `seq` from the events before it: settings, an open turn, unanswered approvals. */
128
+ private standingBefore;
66
129
  unsubscribe(sessionId: string, subscriber: Subscriber): void;
67
- prompt(sessionId: string, clientMessageId: string, content: ContentBlock[]): Promise<"started" | "steered" | "queued" | "duplicate">;
130
+ prompt(sessionId: string, clientMessageId: string, content: ContentBlock[], whenBusy?: "queue"): Promise<"started" | "steered" | "queued" | "duplicate">;
68
131
  /** Retries attaching a session that just became joinable. */
69
132
  private attachWhenReady;
133
+ unqueue(sessionId: string, clientMessageId: string): boolean;
134
+ reorderQueue(sessionId: string, clientMessageIds: string[]): void;
135
+ /**
136
+ * Sends a queued message without waiting for the running turn to end: into
137
+ * that turn if the agent takes input mid-turn, otherwise by stopping it.
138
+ */
139
+ sendQueuedNow(sessionId: string, clientMessageId?: string): Promise<void>;
140
+ /** A turn ended: the next held message starts the following one. */
141
+ private sendHeld;
142
+ onRemoved(listener: (sessionId: string) => void): () => void;
143
+ archive(sessionId: string, archived: boolean): Promise<SessionSummary>;
144
+ rename(sessionId: string, title: string): Promise<SessionSummary>;
145
+ /**
146
+ * Deletes a session. A worktree only it used goes too when nothing in it
147
+ * would be lost (or `worktree` says "remove"); "keep" leaves it.
148
+ */
149
+ delete(sessionId: string, worktree?: "keep" | "remove"): Promise<void>;
150
+ /** Drops a session from LinkShell and tells every client. */
151
+ private forget;
70
152
  cancel(sessionId: string): Promise<void>;
71
153
  respondPermission(sessionId: string, requestId: string, optionId: string): Promise<void>;
72
154
  desktopLaunch(agent: string, args: string[], sessionId: string | undefined, context: DesktopLaunchContext): Promise<LaunchSpec & {
@@ -85,5 +167,7 @@ export declare class SessionHub {
85
167
  private ingest;
86
168
  private commit;
87
169
  private applyToSummary;
170
+ /** Sends the session's current summary to every client (its queue or activity changed). */
171
+ private announce;
88
172
  private emitSummary;
89
173
  }