@parallelworks/code 0.2.0 → 0.3.0

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 (83) hide show
  1. package/README.md +43 -10
  2. package/dist/ago.d.ts +8 -0
  3. package/dist/ago.js +26 -0
  4. package/dist/api.d.ts +78 -0
  5. package/dist/base64.d.ts +3 -0
  6. package/dist/base64.js +15 -0
  7. package/dist/chatHandoff.d.ts +12 -0
  8. package/dist/chatHandoff.js +27 -0
  9. package/dist/claudeAccounts.d.ts +112 -0
  10. package/dist/claudeAccounts.js +234 -0
  11. package/dist/claudeSignIn.d.ts +62 -0
  12. package/dist/claudeSignIn.js +239 -0
  13. package/dist/contextRow.d.ts +25 -0
  14. package/dist/contextRow.js +16 -0
  15. package/dist/createPwCodeApi.d.ts +8 -0
  16. package/dist/createPwCodeApi.js +2 -0
  17. package/dist/howSessionsAppear.d.ts +12 -0
  18. package/dist/howSessionsAppear.js +24 -0
  19. package/dist/index.d.ts +24 -1
  20. package/dist/index.js +24 -2
  21. package/dist/locales/en/agentTranscript.js +2 -10
  22. package/dist/locales/en/agents.js +5 -5
  23. package/dist/locales/en.d.ts +5 -13
  24. package/dist/locales/es/agentTranscript.js +2 -10
  25. package/dist/locales/es/agents.js +5 -5
  26. package/dist/locales/ja/agentTranscript.js +2 -10
  27. package/dist/locales/ja/agents.js +5 -5
  28. package/dist/locales/ko/agentTranscript.js +2 -10
  29. package/dist/locales/ko/agents.js +5 -5
  30. package/dist/locales/zh/agentTranscript.js +2 -10
  31. package/dist/locales/zh/agents.js +5 -5
  32. package/dist/machine.d.ts +2 -0
  33. package/dist/models.d.ts +47 -0
  34. package/dist/models.js +49 -0
  35. package/dist/notices.d.ts +2 -1
  36. package/dist/notices.js +29 -3
  37. package/dist/pullRequestList.d.ts +52 -0
  38. package/dist/pullRequestList.js +106 -0
  39. package/dist/session.d.ts +5 -0
  40. package/dist/sessionActions.d.ts +105 -0
  41. package/dist/sessionActions.js +178 -0
  42. package/dist/sessionGroups.d.ts +49 -0
  43. package/dist/sessionGroups.js +72 -0
  44. package/dist/sessionHeader.d.ts +14 -0
  45. package/dist/sessionHeader.js +16 -0
  46. package/dist/sessionList.d.ts +134 -0
  47. package/dist/sessionList.js +271 -0
  48. package/dist/sessionsApi.js +2 -4
  49. package/dist/settingsApi.d.ts +36 -0
  50. package/dist/settingsApi.js +151 -0
  51. package/dist/startSession.d.ts +138 -0
  52. package/dist/startSession.js +234 -0
  53. package/dist/terminalHandoffPanel.d.ts +30 -0
  54. package/dist/terminalHandoffPanel.js +33 -0
  55. package/dist/transcript.d.ts +2 -0
  56. package/dist/transcript.js +15 -12
  57. package/dist/usageLimit.d.ts +8 -0
  58. package/dist/usageLimit.js +13 -0
  59. package/dist/useAwayRecap.d.ts +30 -0
  60. package/dist/useAwayRecap.js +75 -0
  61. package/dist/useComposer.d.ts +121 -0
  62. package/dist/useComposer.js +244 -0
  63. package/dist/useComposerImages.d.ts +66 -0
  64. package/dist/useComposerImages.js +195 -0
  65. package/dist/useConversation.d.ts +190 -0
  66. package/dist/useConversation.js +287 -0
  67. package/dist/useSubagent.d.ts +58 -0
  68. package/dist/useSubagent.js +149 -0
  69. package/dist/workingDirectories.d.ts +32 -0
  70. package/dist/workingDirectories.js +71 -0
  71. package/dist/worktreeChoice.d.ts +31 -0
  72. package/dist/worktreeChoice.js +38 -0
  73. package/locales/en/agentTranscript.json +2 -10
  74. package/locales/en/agents.json +5 -5
  75. package/locales/es/agentTranscript.json +2 -10
  76. package/locales/es/agents.json +5 -5
  77. package/locales/ja/agentTranscript.json +2 -10
  78. package/locales/ja/agents.json +5 -5
  79. package/locales/ko/agentTranscript.json +2 -10
  80. package/locales/ko/agents.json +5 -5
  81. package/locales/zh/agentTranscript.json +2 -10
  82. package/locales/zh/agents.json +5 -5
  83. package/package.json +3 -3
@@ -0,0 +1,62 @@
1
+ import { type ClaudeLogin, type claudeApi } from './claudeApi.js';
2
+ /** The sign-in calls of `createPwCodeApi`. */
3
+ export type ClaudeSignInCalls = Pick<ReturnType<typeof claudeApi>, 'startClaudeLogin' | 'followClaudeLogin' | 'writeClaudeLogin' | 'cancelClaudeLogin'>;
4
+ export interface ClaudeTerminalSize {
5
+ columns: number;
6
+ rows: number;
7
+ }
8
+ /** The host's terminal that Claude Code's sign-in prompt runs in. */
9
+ export interface ClaudeSignInTerminal {
10
+ /** Its size in cells, read as the sign-in starts and on `resized`. */
11
+ size: () => ClaudeTerminalSize;
12
+ /** Output as Claude Code printed it, escape sequences included. */
13
+ write?: (bytes: Uint8Array) => void;
14
+ /** Clears the screen: the output before this is gone. */
15
+ reset?: () => void;
16
+ /** Whether what is typed into it reaches Claude Code. */
17
+ setInputEnabled?: (enabled: boolean) => void;
18
+ /** Called once the sign-in has started and waits for input. */
19
+ focus?: () => void;
20
+ }
21
+ export interface ClaudeSignInState {
22
+ /** Bumped by `retry`, which starts a new sign-in; give each attempt a fresh terminal. */
23
+ attempt: number;
24
+ login: ClaudeLogin | null;
25
+ /** Why starting, following or writing failed. */
26
+ error: unknown;
27
+ /** Earlier output was dropped, so the screen was cleared. */
28
+ truncated: boolean;
29
+ /** The last input was refused for not fitting the queue. */
30
+ inputTooLong: boolean;
31
+ /** The sign-in page's address, as Claude Code last printed it. */
32
+ link: string | null;
33
+ /** The last 8192 characters of output since the screen was last cleared. */
34
+ output: string;
35
+ acceptsInput: boolean;
36
+ starting: boolean;
37
+ signedIn: boolean;
38
+ finished: boolean;
39
+ /** Following broke while the sign-in still runs. */
40
+ canReconnect: boolean;
41
+ /** The sign-in never started or ended without signing in. */
42
+ canRetry: boolean;
43
+ /** Where the sign-in stands, in words. */
44
+ status: string | null;
45
+ /** Queues text, such as a pasted code (Enter is `\r`); false when refused. */
46
+ input: (data: string) => boolean;
47
+ /** Sends the terminal's new size, if it changed while the sign-in runs. */
48
+ resized: () => void;
49
+ /** Follows the sign-in again from the last output read. */
50
+ reconnect: () => void;
51
+ retry: () => void;
52
+ }
53
+ /** Runs Claude Code's sign-in for `account` on a machine: starts it at the
54
+ * terminal's size, follows its output into the terminal, sends what is typed,
55
+ * and cancels it when the host leaves before it finishes. */
56
+ export declare function useClaudeSignIn(calls: ClaudeSignInCalls, { machine, sessionId, account, terminal, onSignedIn, }: {
57
+ machine: string;
58
+ sessionId: string | undefined;
59
+ account: string;
60
+ terminal: ClaudeSignInTerminal;
61
+ onSignedIn?: (() => void) | undefined;
62
+ }): ClaudeSignInState;
@@ -0,0 +1,239 @@
1
+ import { base64ToBytes, bytesToBase64 } from "./base64.js";
2
+ import { claudeLoginFinished } from "./claudeApi.js";
3
+ import { usePwCodeTranslations } from "./messages.js";
4
+ import { useCallback, useEffect, useRef, useState } from "react";
5
+ // src/claudeSignIn.ts
6
+ var pendingStops = /* @__PURE__ */ new Map();
7
+ var signInUrl = /https:\/\/claude\.(?:ai|com)\/[\w\-.~:/?#[\]@!$&'()*+,;=%]+(?=[^\w\-.~:/?#[\]@!$&'()*+,;=%])/g;
8
+ var maxQueuedInput = 16384;
9
+ var inputChunk = 4096;
10
+ var inputBatchMs = 30;
11
+ /** Runs Claude Code's sign-in for `account` on a machine: starts it at the
12
+ * terminal's size, follows its output into the terminal, sends what is typed,
13
+ * and cancels it when the host leaves before it finishes. */
14
+ function useClaudeSignIn(calls, { machine, sessionId, account, terminal, onSignedIn }) {
15
+ const t = usePwCodeTranslations("agents");
16
+ const [attempt, setAttempt] = useState(0);
17
+ const [login, setLogin] = useState(null);
18
+ const [error, setError] = useState(null);
19
+ const [truncated, setTruncated] = useState(false);
20
+ const [inputTooLong, setInputTooLong] = useState(false);
21
+ const [link, setLink] = useState(null);
22
+ const [output, setOutput] = useState("");
23
+ const [acceptsInput, setAcceptsInput] = useState(false);
24
+ const running = useRef(null);
25
+ const latest = useRef({
26
+ calls,
27
+ terminal,
28
+ onSignedIn
29
+ });
30
+ latest.current = {
31
+ calls,
32
+ terminal,
33
+ onSignedIn
34
+ };
35
+ useEffect(() => {
36
+ const { calls } = latest.current;
37
+ const screen = () => latest.current.terminal;
38
+ let disposed = false;
39
+ let current = null;
40
+ let cursor = 0;
41
+ let pending = /* @__PURE__ */ new Uint8Array(0);
42
+ let queuedBytes = 0;
43
+ let writeEpoch = 0;
44
+ let writeFailed = false;
45
+ let inputEnabled = false;
46
+ let flushTimer;
47
+ let writes = Promise.resolve();
48
+ let reading;
49
+ let tail = "";
50
+ let sentSize = "";
51
+ const decoder = new TextDecoder();
52
+ setLogin(null);
53
+ setError(null);
54
+ setTruncated(false);
55
+ setInputTooLong(false);
56
+ setLink(null);
57
+ setOutput("");
58
+ setAcceptsInput(false);
59
+ const allowInput = (enabled) => {
60
+ inputEnabled = enabled;
61
+ screen().setInputEnabled?.(enabled);
62
+ setAcceptsInput(enabled);
63
+ };
64
+ const findLink = (bytes) => {
65
+ tail = (tail + decoder.decode(bytes, { stream: true })).slice(-8192);
66
+ const found = tail.match(signInUrl)?.at(-1);
67
+ if (found) setLink(found);
68
+ };
69
+ const receive = (event) => {
70
+ if (disposed) return;
71
+ if (event.offset > cursor || cursor > event.next) {
72
+ screen().reset?.();
73
+ tail = "";
74
+ setTruncated(true);
75
+ }
76
+ current = event.login;
77
+ allowInput(!writeFailed && current.status === "running");
78
+ setLogin(current);
79
+ if (event.data) {
80
+ const bytes = base64ToBytes(event.data);
81
+ screen().write?.(bytes);
82
+ findLink(bytes);
83
+ }
84
+ setOutput(tail);
85
+ cursor = event.next;
86
+ if (current.status === "signed_in") latest.current.onSignedIn?.();
87
+ };
88
+ const read = async () => {
89
+ if (!current || disposed) return;
90
+ reading?.abort();
91
+ const controller = new AbortController();
92
+ reading = controller;
93
+ writeFailed = false;
94
+ setError(null);
95
+ try {
96
+ await calls.followClaudeLogin(machine, current, cursor, controller.signal, receive);
97
+ } catch (cause) {
98
+ if (controller.signal.aborted) return;
99
+ allowInput(false);
100
+ setError(cause);
101
+ }
102
+ };
103
+ const send = (input, bytes = 0) => {
104
+ const id = current?.id;
105
+ if (!id || disposed) return;
106
+ const epoch = writeEpoch;
107
+ writes = writes.then(async () => {
108
+ if (!disposed && !writeFailed && epoch === writeEpoch && current?.status === "running") await calls.writeClaudeLogin(machine, id, input);
109
+ else if (input.columns) sentSize = "";
110
+ }).catch((cause) => {
111
+ if (input.columns) sentSize = "";
112
+ if (!disposed) {
113
+ writeEpoch++;
114
+ writeFailed = true;
115
+ allowInput(false);
116
+ setError(cause);
117
+ }
118
+ }).finally(() => {
119
+ queuedBytes -= bytes;
120
+ });
121
+ };
122
+ const flush = () => {
123
+ flushTimer = void 0;
124
+ const bytes = pending;
125
+ pending = /* @__PURE__ */ new Uint8Array(0);
126
+ for (let offset = 0; offset < bytes.length; offset += inputChunk) {
127
+ const chunk = bytes.subarray(offset, offset + inputChunk);
128
+ send({ data: bytesToBase64(chunk) }, chunk.length);
129
+ }
130
+ };
131
+ const input = (data) => {
132
+ if (!inputEnabled || current?.status !== "running" || disposed || writeFailed) return false;
133
+ const bytes = new TextEncoder().encode(data);
134
+ if (queuedBytes + bytes.length > maxQueuedInput) {
135
+ setInputTooLong(true);
136
+ return false;
137
+ }
138
+ queuedBytes += bytes.length;
139
+ setInputTooLong(false);
140
+ const buffer = new Uint8Array(pending.length + bytes.length);
141
+ buffer.set(pending);
142
+ buffer.set(bytes, pending.length);
143
+ pending = buffer;
144
+ flushTimer ??= setTimeout(flush, inputBatchMs);
145
+ return true;
146
+ };
147
+ const size = () => {
148
+ const { columns, rows } = screen().size();
149
+ return {
150
+ columns: Math.min(500, Math.max(1, columns)),
151
+ rows: Math.min(200, Math.max(1, rows))
152
+ };
153
+ };
154
+ const resized = () => {
155
+ const next = size();
156
+ const key = `${next.columns}x${next.rows}`;
157
+ if (current?.status === "running" && key !== sentSize) {
158
+ sentSize = key;
159
+ send(next);
160
+ }
161
+ };
162
+ running.current = {
163
+ input,
164
+ resized,
165
+ reconnect: () => {
166
+ read();
167
+ resized();
168
+ }
169
+ };
170
+ const key = JSON.stringify([
171
+ machine,
172
+ sessionId,
173
+ account
174
+ ]);
175
+ const previousStop = pendingStops.get(key);
176
+ const started = Promise.resolve().then(async () => {
177
+ await previousStop;
178
+ if (disposed) return;
179
+ const { columns, rows } = size();
180
+ sentSize = `${columns}x${rows}`;
181
+ return calls.startClaudeLogin(machine, account, sessionId, columns, rows);
182
+ });
183
+ started.then(async (event) => {
184
+ if (!event || disposed) return;
185
+ receive(event);
186
+ resized();
187
+ screen().focus?.();
188
+ await read();
189
+ }).catch((cause) => {
190
+ if (!disposed) setError(cause);
191
+ });
192
+ return () => {
193
+ disposed = true;
194
+ reading?.abort();
195
+ if (flushTimer) clearTimeout(flushTimer);
196
+ running.current = null;
197
+ const stopped = started.then(async (event) => {
198
+ const login = current ?? event?.login;
199
+ if (login && !claudeLoginFinished(login.status)) await calls.cancelClaudeLogin(machine, login.id);
200
+ }).catch(() => {});
201
+ pendingStops.set(key, stopped);
202
+ stopped.then(() => {
203
+ if (pendingStops.get(key) === stopped) pendingStops.delete(key);
204
+ });
205
+ };
206
+ }, [
207
+ machine,
208
+ account,
209
+ sessionId,
210
+ attempt
211
+ ]);
212
+ const input = useCallback((data) => running.current?.input(data) ?? false, []);
213
+ const resized = useCallback(() => running.current?.resized(), []);
214
+ const reconnect = useCallback(() => running.current?.reconnect(), []);
215
+ const retry = useCallback(() => setAttempt((value) => value + 1), []);
216
+ const finished = login ? claudeLoginFinished(login.status) : false;
217
+ const signedIn = login?.status === "signed_in";
218
+ return {
219
+ attempt,
220
+ login,
221
+ error,
222
+ truncated,
223
+ inputTooLong,
224
+ link,
225
+ output,
226
+ acceptsInput,
227
+ starting: !login && !error,
228
+ signedIn,
229
+ finished,
230
+ canReconnect: Boolean(error) && !!login && !finished,
231
+ canRetry: Boolean(error) && !login || finished && !signedIn,
232
+ status: login ? t(`claude.signInStatus.${login.status}`, { email: login.email ?? account }) : null,
233
+ input,
234
+ resized,
235
+ reconnect,
236
+ retry
237
+ };
238
+ }
239
+ export { useClaudeSignIn };
@@ -0,0 +1,25 @@
1
+ import { type LabeledPullRequest, type PullRequestStateOf } from './pullRequestList.js';
2
+ import type { PwCodeAddedDirectory, PwCodeAllowedDirectory } from './types.js';
3
+ /** What a session's context shows besides its working directory and goal. */
4
+ export interface PwCodeContextRow {
5
+ /** The directories added to the session. */
6
+ added: PwCodeAddedDirectory[];
7
+ /** The directories approvals opened for the session. */
8
+ allowed: PwCodeAllowedDirectory[];
9
+ /** In `orderPullRequests` order. */
10
+ pullRequests: LabeledPullRequest[];
11
+ stateOf: PullRequestStateOf;
12
+ /** For each of `pullRequests`, whether it folds into the merged-or-closed count. */
13
+ foldGroups: boolean[];
14
+ }
15
+ /** A session's context from its detail and the states read for its pull
16
+ * requests, which come from the URLs `labeledPullRequests` keeps. */
17
+ export declare function sessionContextRow({ added, allowed, pullRequests, states, }: {
18
+ added: PwCodeAddedDirectory[] | null | undefined;
19
+ allowed: PwCodeAllowedDirectory[] | null | undefined;
20
+ pullRequests: readonly string[] | null | undefined;
21
+ states: readonly {
22
+ url: string;
23
+ state?: string | undefined;
24
+ }[] | undefined;
25
+ }): PwCodeContextRow;
@@ -0,0 +1,16 @@
1
+ import { labeledPullRequests, orderPullRequests, pullRequestFoldGroups, pullRequestStateOf } from "./pullRequestList.js";
2
+ // src/contextRow.ts
3
+ /** A session's context from its detail and the states read for its pull
4
+ * requests, which come from the URLs `labeledPullRequests` keeps. */
5
+ function sessionContextRow({ added, allowed, pullRequests, states }) {
6
+ const stateOf = pullRequestStateOf(states);
7
+ const ordered = orderPullRequests(labeledPullRequests(pullRequests), stateOf);
8
+ return {
9
+ added: added ?? [],
10
+ allowed: allowed ?? [],
11
+ pullRequests: ordered,
12
+ stateOf,
13
+ foldGroups: pullRequestFoldGroups(ordered, stateOf)
14
+ };
15
+ }
16
+ export { sessionContextRow };
@@ -643,6 +643,14 @@ export declare function createPwCodeApi<P extends {}>(client: Client<P> & Covers
643
643
  answerApproval: (machine: string, sessionId: string, approvalId: string, answer: import("@parallelworks/ui/ai/headless").ApprovalAnswerValue) => Promise<unknown>;
644
644
  removeSessionDirectory: (machine: string, sessionId: string, path: string) => Promise<unknown>;
645
645
  uploadPaste: (machine: string, sessionId: string, text: string, describe: (error: unknown) => string) => Promise<import("./sessionsApi.js").PwCodePasteUpload>;
646
+ updateSessionSettings: (machine: string, id: string, body: {
647
+ allocation?: string;
648
+ claudeAccount?: string;
649
+ effort?: "default" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
650
+ model?: string;
651
+ permissionMode?: "read-only" | "accept-edits" | "auto" | "bypass-permissions";
652
+ }) => Promise<import("./apiClient.js").PwCodeResult<Schemas['SessionState']>>;
653
+ useSessionSettings: ({ machine, sessionId, model, effort, allocation, claudeAccount, nativeAllocation, locked, live, onPatched, onError, onModePicked, onEffortPicked, onAccountSaved, }: import("./settingsApi.js").PwCodeSessionSettingsOptions) => import("./settingsApi.js").PwCodeSessionSettings;
646
654
  useMachines: () => Schemas['AgentMachine'][];
647
655
  useSessionEvents: (machine: string, id: string, cursor: (() => number) | undefined, onEvent: (event: {
648
656
  agentType?: string;
@@ -2,6 +2,7 @@ import { claudeApi } from "./claudeApi.js";
2
2
  import { commandsApi } from "./commandsApi.js";
3
3
  import { reachedByFeed, sessionEvents } from "./sessionEvents.js";
4
4
  import { sessionsApi } from "./sessionsApi.js";
5
+ import { settingsApi } from "./settingsApi.js";
5
6
  import { useMemo } from "react";
6
7
  // src/createPwCodeApi.ts
7
8
  /** The calls and data hooks of pw code sessions over the host's API client,
@@ -24,6 +25,7 @@ function createPwCodeApi(client, options = {}) {
24
25
  ...sessions,
25
26
  ...commandsApi(routes),
26
27
  ...claudeApi(routes),
28
+ ...settingsApi(routes),
27
29
  useMachines,
28
30
  useSessionEvents
29
31
  };
@@ -0,0 +1,12 @@
1
+ import type { PwCodeTranslator } from './messages.js';
2
+ export interface HowSessionsAppearStep {
3
+ before: string;
4
+ /** What to run, offered for copying. */
5
+ command: string;
6
+ after?: string | undefined;
7
+ }
8
+ /** How a session gets listed: nothing is until its owner opens it to remote control. */
9
+ export declare function howSessionsAppear(t: PwCodeTranslator<'agents'>): {
10
+ title: string;
11
+ steps: HowSessionsAppearStep[];
12
+ };
@@ -0,0 +1,24 @@
1
+ // src/howSessionsAppear.ts
2
+ /** How a session gets listed: nothing is until its owner opens it to remote control. */
3
+ function howSessionsAppear(t) {
4
+ return {
5
+ title: t("start.howTitle"),
6
+ steps: [
7
+ {
8
+ before: t("start.howRemoteBefore"),
9
+ command: "/rc",
10
+ after: t("start.howRemoteAfter")
11
+ },
12
+ {
13
+ before: t("start.howNewBefore"),
14
+ command: "pw code --remote"
15
+ },
16
+ {
17
+ before: t("start.howAllBefore"),
18
+ command: "/settings",
19
+ after: t("start.howAllAfter")
20
+ }
21
+ ]
22
+ };
23
+ }
24
+ export { howSessionsAppear };
package/dist/index.d.ts CHANGED
@@ -2,17 +2,40 @@ export type { PwCodeAddedDirectory, PwCodeAllowedDirectory, PwCodeApprovalAnswer
2
2
  export { type PwCodeClient, type PwCodeComponents, type PwCodePaths, QUERY_KEY_PREFIX, } from './apiClient.js';
3
3
  export { createPwCodeApi, type PwCodeApi, type PwCodeApiOptions, } from './createPwCodeApi.js';
4
4
  export { cachedCopyCurrent, pasteRefs, patchPullRequestStates, patchSessionNames, pullRequestsRefreshMs, type PwCodePasteUpload, SESSIONS_REFRESH_MS, useLastReadAt, } from './sessionsApi.js';
5
+ export { type PwCodeLastModel, type PwCodeStartImages, type PwCodeStartLocation, type PwCodeStartMachine, type PwCodeStartModel, type PwCodeStartSession, startingMode, startMachines, useStartLocation, useStartModel, useStartPermissionMode, useStartSession, } from './startSession.js';
6
+ export { canRunModel, isClaudeModel, modelLabel, pickerCommand, type PwCodeModelCatalog, type PwCodePicker, runsClaude, useModelCatalog, } from './models.js';
7
+ export { allowedAccess, cutSpacing, cutToFit, directoryScopes, isSavedDirectory, lastSegmentAt, pathSegments, type PwCodeDirectoryScope, shortestPath, useRemoveSessionDirectory, } from './workingDirectories.js';
8
+ export { type PwCodeWorktreeLines, type PwCodeWorktreeWork, useWorktreeChoice, worktreeWork, } from './worktreeChoice.js';
5
9
  export { backgroundOfferDelayMs, type CommandOutcome, type SlashDeps, } from './commandsApi.js';
10
+ export { type PwCodeSessionSettings, type PwCodeSessionSettingsOptions, } from './settingsApi.js';
11
+ export { chatHandoffPrompt, type PwCodeHandoffChat } from './chatHandoff.js';
6
12
  export { type ClaudeLogin, type ClaudeLoginEvent, type ClaudeLoginInput, claudeLoginFinished, } from './claudeApi.js';
13
+ export { type ClaudeSignInCalls, type ClaudeSignInState, type ClaudeSignInTerminal, type ClaudeTerminalSize, useClaudeSignIn, } from './claudeSignIn.js';
14
+ export { type ClaudeAccount, type ClaudeAccountAction, type ClaudeAccountCalls, type ClaudeAccountPanelState, type ClaudeAccountUsage, type ClaudeAccountView, type ClaudeUsageLimit, type ClaudeUsageReset, claudeAccountName, claudeSignInRequired, useClaudeAccountName, useClaudeAccountPanel, useClaudeAccountRemoval, useClaudeAccountUsage, } from './claudeAccounts.js';
7
15
  export { changesSubagents, reachedByFeed, sessionEventsPath, } from './sessionEvents.js';
8
16
  export { githubAttachmentAsset, isSessionImageUrl, sessionGitHubImageUrl, sessionImageUrl, } from './images.js';
9
17
  export { type PwCodePalette, type PwCodeSlashCommand, paletteOptions, type SlashAction, shellCommand, slashAction, steerMayHaveLanded, } from './command.js';
10
18
  export { canStartHere, isComputer, isConnected, isMachineDown, isUnreachableError, machinesById, type PwCodeMachine, splitMachines, type TerminalHandoff, terminalHandoff, } from './machine.js';
11
19
  export { isPwCodeLocale, loadPwCodeMessages, type PwCodeLocale, type PwCodeMessages, type PwCodeNamespace, type PwCodeTranslator, pwCodeLocales, pwCodeNamespaces, usePwCodeTranslations, } from './messages.js';
12
- export { turnDuration, useCompactionNotice, useRecapNotice, useResumeTime, useTranscriptWords, } from './notices.js';
20
+ export { turnDuration, useCompactionNotice, useGoalNotice, useRecapNotice, useResumeTime, useTranscriptWords, } from './notices.js';
21
+ export { useCompactAgo } from './ago.js';
13
22
  export { pastedPullRequestLabel, pullRequestKind, pullRequestLabel, pullRequestShortLabel, } from './pullRequest.js';
23
+ export { donePullRequestsToFold, foldPullRequests, isPullRequestState, type LabeledPullRequest, labeledPullRequests, orderPullRequests, type PullRequestFold, type PullRequestFoldGroup, type PullRequestState, type PullRequestStateOf, type PullRequestWords, pullRequestFoldGroups, pullRequestGroupState, pullRequestStateBreaks, pullRequestStateOf, pullRequestWords, } from './pullRequestList.js';
24
+ export { type PwCodeContextRow, sessionContextRow } from './contextRow.js';
25
+ export { handoffCommandParts, type TerminalHandoffPanel, terminalHandoffPanel, } from './terminalHandoffPanel.js';
26
+ export { type UsageLimitWait, useUsageLimitWait } from './usageLimit.js';
27
+ export { type PwCodeWorktreeRef, useFollowedWorktree } from './sessionHeader.js';
28
+ export { type HowSessionsAppearStep, howSessionsAppear, } from './howSessionsAppear.js';
14
29
  export { isActiveSession, isArchived, isMidTurn, isSession, needsYou, newestFirst, pathBasename, type PwCodePendingApprovals, type PwCodeSession, type RecentDirectory, recentDirectories, sessionClock, sessionKey, sessionStatusVariant, sessionVariant, sharedStoreCopy, spansMachines, triageSessions, waitsOnAnswer, } from './session.js';
30
+ export { groupOf, inFlightFirst, isWorking, type ListedGroup, listGroups, patchGroup, type SessionGroup, type SessionGroups, useSessionGroups, } from './sessionGroups.js';
31
+ export { groupSectionKey, isUngroupedTarget, searchedSessions, type SessionDropTarget, type SessionList, type SessionListOptions, type SessionSection, type SessionSectionKind, sessionMark, sessionRowState, sessionSearchText, sessionSections, showsPinMark, useRetainedSessions, useSessionList, withArchiveSection, } from './sessionList.js';
32
+ export { type OpenSessionRef, type SessionActions, type SessionActionsOptions, type SessionConfirmation, type SessionMenuAction, type SessionMenuCommand, type SessionMenuItem, type SessionRename, type SessionRowKey, type SessionSubmenu, useSessionActions, } from './sessionActions.js';
15
33
  export { appendOwnMessage, appendSteeredMessage, applyStreamEvent, approvalAnswerBody, approvalToPart, bashRunning, type CompactionNotice, dropMessage, type GoalNotice, historyToMessages, type ImageUrl, initialTranscript, liveSessionStatus, pendingApprovals, pendingMessages, type RecapNotice, resolveApprovalEverywhere, reviewingCount, resumeCursor, type StreamEffect, subagentFrame, subagentSessionDetail, type TranscriptState, type TranscriptWords, turnRunning, type TurnVerb, } from './transcript.js';
16
34
  export { useToolStrings } from './toolStrings.js';
17
35
  export { type PwCodeSendResult, type PwCodeSteerResult, type PwCodeWithdrawResult, usePwCodeTranscript, } from './useTranscript.js';
36
+ export { type PwCodeConversation, type PwCodeConversationState, type PwCodeNotice, transcriptMessages, usePwCodeConversation, } from './useConversation.js';
37
+ export { promptHistory, type PwCodeCommandOutput, type PwCodeComposer, type PwCodeComposerHistory, useCommandOutputs, usePwCodeComposer, } from './useComposer.js';
38
+ export { type PwCodeSubagent, usePwCodeSubagent } from './useSubagent.js';
39
+ export { IMAGE_MAX_BYTES, IMAGE_MAX_SIDE, IMAGE_READ_MAX_BYTES, IMAGE_TYPES, nextImageSeq, type PwCodeComposerImage, type PwCodeImageFile, PwCodeImageTooLarge, type PwCodeImageType, type PwCodeSavedImage, type PwCodeTakenImages, useComposerImages, } from './useComposerImages.js';
40
+ export { type PwCodePresence, recapAfterLeavingMs, recapAfterTurnMs, useAwayRecap, } from './useAwayRecap.js';
18
41
  export { composerState, IMAGE_PLACEHOLDER, machineHint, rememberSentPrompt, sessionLabel, sessionStateText, sessionStatusText, } from './wording.js';
package/dist/index.js CHANGED
@@ -1,18 +1,40 @@
1
1
  import { QUERY_KEY_PREFIX } from "./apiClient.js";
2
2
  import { createPwCodeApi } from "./createPwCodeApi.js";
3
3
  import { SESSIONS_REFRESH_MS, cachedCopyCurrent, pasteRefs, patchPullRequestStates, patchSessionNames, pullRequestsRefreshMs, useLastReadAt } from "./sessionsApi.js";
4
+ import { startMachines, startingMode, useStartLocation, useStartModel, useStartPermissionMode, useStartSession } from "./startSession.js";
5
+ import { canRunModel, isClaudeModel, modelLabel, pickerCommand, runsClaude, useModelCatalog } from "./models.js";
6
+ import { allowedAccess, cutSpacing, cutToFit, directoryScopes, isSavedDirectory, lastSegmentAt, pathSegments, shortestPath, useRemoveSessionDirectory } from "./workingDirectories.js";
7
+ import { useWorktreeChoice, worktreeWork } from "./worktreeChoice.js";
4
8
  import { backgroundOfferDelayMs } from "./commandsApi.js";
9
+ import { chatHandoffPrompt } from "./chatHandoff.js";
5
10
  import { claudeLoginFinished } from "./claudeApi.js";
11
+ import { useClaudeSignIn } from "./claudeSignIn.js";
12
+ import { claudeAccountName, claudeSignInRequired, useClaudeAccountName, useClaudeAccountPanel, useClaudeAccountRemoval, useClaudeAccountUsage } from "./claudeAccounts.js";
6
13
  import { changesSubagents, reachedByFeed, sessionEventsPath } from "./sessionEvents.js";
7
14
  import { githubAttachmentAsset, isSessionImageUrl, sessionGitHubImageUrl, sessionImageUrl } from "./images.js";
8
15
  import { paletteOptions, shellCommand, slashAction, steerMayHaveLanded } from "./command.js";
9
16
  import { canStartHere, isComputer, isConnected, isMachineDown, isUnreachableError, machinesById, splitMachines, terminalHandoff } from "./machine.js";
10
17
  import { isPwCodeLocale, loadPwCodeMessages, pwCodeLocales, pwCodeNamespaces, usePwCodeTranslations } from "./messages.js";
11
- import { turnDuration, useCompactionNotice, useRecapNotice, useResumeTime, useTranscriptWords } from "./notices.js";
18
+ import { turnDuration, useCompactionNotice, useGoalNotice, useRecapNotice, useResumeTime, useTranscriptWords } from "./notices.js";
19
+ import { useCompactAgo } from "./ago.js";
12
20
  import { pastedPullRequestLabel, pullRequestKind, pullRequestLabel, pullRequestShortLabel } from "./pullRequest.js";
21
+ import { donePullRequestsToFold, foldPullRequests, isPullRequestState, labeledPullRequests, orderPullRequests, pullRequestFoldGroups, pullRequestGroupState, pullRequestStateBreaks, pullRequestStateOf, pullRequestWords } from "./pullRequestList.js";
22
+ import { sessionContextRow } from "./contextRow.js";
23
+ import { handoffCommandParts, terminalHandoffPanel } from "./terminalHandoffPanel.js";
24
+ import { useUsageLimitWait } from "./usageLimit.js";
25
+ import { useFollowedWorktree } from "./sessionHeader.js";
26
+ import { howSessionsAppear } from "./howSessionsAppear.js";
13
27
  import { isActiveSession, isArchived, isMidTurn, isSession, needsYou, newestFirst, pathBasename, recentDirectories, sessionClock, sessionKey, sessionStatusVariant, sessionVariant, sharedStoreCopy, spansMachines, triageSessions, waitsOnAnswer } from "./session.js";
28
+ import { groupOf, inFlightFirst, isWorking, listGroups, patchGroup, useSessionGroups } from "./sessionGroups.js";
29
+ import { groupSectionKey, isUngroupedTarget, searchedSessions, sessionMark, sessionRowState, sessionSearchText, sessionSections, showsPinMark, useRetainedSessions, useSessionList, withArchiveSection } from "./sessionList.js";
30
+ import { useSessionActions } from "./sessionActions.js";
14
31
  import { appendOwnMessage, appendSteeredMessage, applyStreamEvent, approvalAnswerBody, approvalToPart, bashRunning, dropMessage, historyToMessages, initialTranscript, liveSessionStatus, pendingApprovals, pendingMessages, resolveApprovalEverywhere, resumeCursor, reviewingCount, subagentFrame, subagentSessionDetail, turnRunning } from "./transcript.js";
15
32
  import { useToolStrings } from "./toolStrings.js";
16
33
  import { usePwCodeTranscript } from "./useTranscript.js";
34
+ import { transcriptMessages, usePwCodeConversation } from "./useConversation.js";
35
+ import { promptHistory, useCommandOutputs, usePwCodeComposer } from "./useComposer.js";
36
+ import { usePwCodeSubagent } from "./useSubagent.js";
37
+ import { IMAGE_MAX_BYTES, IMAGE_MAX_SIDE, IMAGE_READ_MAX_BYTES, IMAGE_TYPES, PwCodeImageTooLarge, nextImageSeq, useComposerImages } from "./useComposerImages.js";
38
+ import { recapAfterLeavingMs, recapAfterTurnMs, useAwayRecap } from "./useAwayRecap.js";
17
39
  import { IMAGE_PLACEHOLDER, composerState, machineHint, rememberSentPrompt, sessionLabel, sessionStateText, sessionStatusText } from "./wording.js";
18
- export { IMAGE_PLACEHOLDER, QUERY_KEY_PREFIX, SESSIONS_REFRESH_MS, appendOwnMessage, appendSteeredMessage, applyStreamEvent, approvalAnswerBody, approvalToPart, backgroundOfferDelayMs, bashRunning, cachedCopyCurrent, canStartHere, changesSubagents, claudeLoginFinished, composerState, createPwCodeApi, dropMessage, githubAttachmentAsset, historyToMessages, initialTranscript, isActiveSession, isArchived, isComputer, isConnected, isMachineDown, isMidTurn, isPwCodeLocale, isSession, isSessionImageUrl, isUnreachableError, liveSessionStatus, loadPwCodeMessages, machineHint, machinesById, needsYou, newestFirst, paletteOptions, pasteRefs, pastedPullRequestLabel, patchPullRequestStates, patchSessionNames, pathBasename, pendingApprovals, pendingMessages, pullRequestKind, pullRequestLabel, pullRequestShortLabel, pullRequestsRefreshMs, pwCodeLocales, pwCodeNamespaces, reachedByFeed, recentDirectories, rememberSentPrompt, resolveApprovalEverywhere, resumeCursor, reviewingCount, sessionClock, sessionEventsPath, sessionGitHubImageUrl, sessionImageUrl, sessionKey, sessionLabel, sessionStateText, sessionStatusText, sessionStatusVariant, sessionVariant, sharedStoreCopy, shellCommand, slashAction, spansMachines, splitMachines, steerMayHaveLanded, subagentFrame, subagentSessionDetail, terminalHandoff, triageSessions, turnDuration, turnRunning, useCompactionNotice, useLastReadAt, usePwCodeTranscript, usePwCodeTranslations, useRecapNotice, useResumeTime, useToolStrings, useTranscriptWords, waitsOnAnswer };
40
+ export { IMAGE_MAX_BYTES, IMAGE_MAX_SIDE, IMAGE_PLACEHOLDER, IMAGE_READ_MAX_BYTES, IMAGE_TYPES, PwCodeImageTooLarge, QUERY_KEY_PREFIX, SESSIONS_REFRESH_MS, allowedAccess, appendOwnMessage, appendSteeredMessage, applyStreamEvent, approvalAnswerBody, approvalToPart, backgroundOfferDelayMs, bashRunning, cachedCopyCurrent, canRunModel, canStartHere, changesSubagents, chatHandoffPrompt, claudeAccountName, claudeLoginFinished, claudeSignInRequired, composerState, createPwCodeApi, cutSpacing, cutToFit, directoryScopes, donePullRequestsToFold, dropMessage, foldPullRequests, githubAttachmentAsset, groupOf, groupSectionKey, handoffCommandParts, historyToMessages, howSessionsAppear, inFlightFirst, initialTranscript, isActiveSession, isArchived, isClaudeModel, isComputer, isConnected, isMachineDown, isMidTurn, isPullRequestState, isPwCodeLocale, isSavedDirectory, isSession, isSessionImageUrl, isUngroupedTarget, isUnreachableError, isWorking, labeledPullRequests, lastSegmentAt, listGroups, liveSessionStatus, loadPwCodeMessages, machineHint, machinesById, modelLabel, needsYou, newestFirst, nextImageSeq, orderPullRequests, paletteOptions, pasteRefs, pastedPullRequestLabel, patchGroup, patchPullRequestStates, patchSessionNames, pathBasename, pathSegments, pendingApprovals, pendingMessages, pickerCommand, promptHistory, pullRequestFoldGroups, pullRequestGroupState, pullRequestKind, pullRequestLabel, pullRequestShortLabel, pullRequestStateBreaks, pullRequestStateOf, pullRequestWords, pullRequestsRefreshMs, pwCodeLocales, pwCodeNamespaces, reachedByFeed, recapAfterLeavingMs, recapAfterTurnMs, recentDirectories, rememberSentPrompt, resolveApprovalEverywhere, resumeCursor, reviewingCount, runsClaude, searchedSessions, sessionClock, sessionContextRow, sessionEventsPath, sessionGitHubImageUrl, sessionImageUrl, sessionKey, sessionLabel, sessionMark, sessionRowState, sessionSearchText, sessionSections, sessionStateText, sessionStatusText, sessionStatusVariant, sessionVariant, sharedStoreCopy, shellCommand, shortestPath, showsPinMark, slashAction, spansMachines, splitMachines, startMachines, startingMode, steerMayHaveLanded, subagentFrame, subagentSessionDetail, terminalHandoff, terminalHandoffPanel, transcriptMessages, triageSessions, turnDuration, turnRunning, useAwayRecap, useClaudeAccountName, useClaudeAccountPanel, useClaudeAccountRemoval, useClaudeAccountUsage, useClaudeSignIn, useCommandOutputs, useCompactAgo, useCompactionNotice, useComposerImages, useFollowedWorktree, useGoalNotice, useLastReadAt, useModelCatalog, usePwCodeComposer, usePwCodeConversation, usePwCodeSubagent, usePwCodeTranscript, usePwCodeTranslations, useRecapNotice, useRemoveSessionDirectory, useResumeTime, useRetainedSessions, useSessionActions, useSessionGroups, useSessionList, useStartLocation, useStartModel, useStartPermissionMode, useStartSession, useToolStrings, useTranscriptWords, useUsageLimitWait, useWorktreeChoice, waitsOnAnswer, withArchiveSection, worktreeWork };
@@ -138,11 +138,7 @@ var modelPicker = {
138
138
  "loading": "Loading models…",
139
139
  "failed": "Failed to load models",
140
140
  "none": "No models available",
141
- "sharedBy": "Shared by {owner}",
142
- "connecting": "Connecting…",
143
- "notResponding": "Not responding",
144
- "manageProvider": "Manage provider",
145
- "selectFirst": "Select a model first"
141
+ "sharedBy": "Shared by {owner}"
146
142
  };
147
143
  var allocationPicker = {
148
144
  "choose": "Allocation",
@@ -151,11 +147,7 @@ var allocationPicker = {
151
147
  };
152
148
  var providerIssue = {
153
149
  "keyRejected": "API key rejected",
154
- "unreachable": "Endpoint unreachable",
155
- "keyRejectedHint": "The provider rejected this connection's API key. Update the key in the provider settings to resume.",
156
- "unreachableHint": "The provider's endpoint did not respond. Check the endpoint URL and network access.",
157
- "bannerKeyRejected": "API key rejected for “{provider}”",
158
- "bannerUnreachable": "“{provider}” is unreachable"
150
+ "unreachable": "Endpoint unreachable"
159
151
  };
160
152
  var agentTranscript_default = {
161
153
  transcript,
@@ -44,7 +44,6 @@ var sidebar = {
44
44
  "groupNamePlaceholder": "Enter a name",
45
45
  "deleteGroupTitle": "Delete group",
46
46
  "deleteGroupBody": "“{name}” will be removed. Its sessions stay in the list.",
47
- "groupActions": "Actions for {name}",
48
47
  "groupsNeedUpdate": "Update pw on {machine} to keep its sessions in groups",
49
48
  "groupWaiting": "{count, plural, one {# session needs you} other {# sessions need you}}",
50
49
  "groupRunning": "{count, plural, one {# session running} other {# sessions running}}",
@@ -128,7 +127,7 @@ var detail = {
128
127
  "archived": "Archived “{name}”. Restore it from the Archived group to use it again.",
129
128
  "steerUncertain": "No answer came back, so this may have reached the agent. Check the transcript before you send it again.",
130
129
  "shellStopped": "A hook stopped the agent from reacting: {reason}",
131
- "background": "Run in background",
130
+ "backgroundHint": "({key} to run in background)",
132
131
  "backgroundTitle": "The command keeps running, and the agent carries on without waiting for it",
133
132
  "liveOn": "Live on {host}",
134
133
  "pullRequest": "{kind, select, mergeRequest {Merge request} other {Pull request}} {pr}, opened by this session",
@@ -234,13 +233,13 @@ var detail = {
234
233
  var switcher = {
235
234
  "title": "Agents",
236
235
  "main": "Main conversation",
237
- "runningOf": "{running} of {total} running",
236
+ "runningCount": "{count} running",
237
+ "doneCount": "{count} done",
238
+ "stoppedCount": "{count} stopped",
238
239
  "earlierOnly": "{count, plural, one {# earlier agent} other {# earlier agents}}",
239
240
  "approvals": "{count, plural, one {# approval needed} other {# approvals needed}}",
240
241
  "failedCount": "{count} failed",
241
242
  "stopAll": "Stop all",
242
- "show": "Show agents",
243
- "hide": "Hide agents",
244
243
  "showEarlier": "{count, plural, one {Show # earlier agent} other {Show # earlier agents}}",
245
244
  "hideEarlier": "{count, plural, one {Hide # earlier agent} other {Hide # earlier agents}}",
246
245
  "agentName": "{type}: {description}",
@@ -261,6 +260,7 @@ var switcher = {
261
260
  };
262
261
  var effort = {
263
262
  "label": "Effort",
263
+ "named": "Effort: {level}",
264
264
  "low": "low",
265
265
  "medium": "medium",
266
266
  "high": "high",
@@ -142,10 +142,6 @@ declare const messages: {
142
142
  failed: string;
143
143
  none: string;
144
144
  sharedBy: string;
145
- connecting: string;
146
- notResponding: string;
147
- manageProvider: string;
148
- selectFirst: string;
149
145
  };
150
146
  allocationPicker: {
151
147
  choose: string;
@@ -155,10 +151,6 @@ declare const messages: {
155
151
  providerIssue: {
156
152
  keyRejected: string;
157
153
  unreachable: string;
158
- keyRejectedHint: string;
159
- unreachableHint: string;
160
- bannerKeyRejected: string;
161
- bannerUnreachable: string;
162
154
  };
163
155
  };
164
156
  agents: {
@@ -207,7 +199,6 @@ declare const messages: {
207
199
  groupNamePlaceholder: string;
208
200
  deleteGroupTitle: string;
209
201
  deleteGroupBody: string;
210
- groupActions: string;
211
202
  groupsNeedUpdate: string;
212
203
  groupWaiting: string;
213
204
  groupRunning: string;
@@ -291,7 +282,7 @@ declare const messages: {
291
282
  archived: string;
292
283
  steerUncertain: string;
293
284
  shellStopped: string;
294
- background: string;
285
+ backgroundHint: string;
295
286
  backgroundTitle: string;
296
287
  liveOn: string;
297
288
  pullRequest: string;
@@ -397,13 +388,13 @@ declare const messages: {
397
388
  switcher: {
398
389
  title: string;
399
390
  main: string;
400
- runningOf: string;
391
+ runningCount: string;
392
+ doneCount: string;
393
+ stoppedCount: string;
401
394
  earlierOnly: string;
402
395
  approvals: string;
403
396
  failedCount: string;
404
397
  stopAll: string;
405
- show: string;
406
- hide: string;
407
398
  showEarlier: string;
408
399
  hideEarlier: string;
409
400
  agentName: string;
@@ -424,6 +415,7 @@ declare const messages: {
424
415
  };
425
416
  effort: {
426
417
  label: string;
418
+ named: string;
427
419
  low: string;
428
420
  medium: string;
429
421
  high: string;