@parallelworks/code 0.3.0 → 0.4.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.
- package/README.md +598 -113
- package/dist/accountApi.d.ts +31 -0
- package/dist/accountApi.js +182 -0
- package/dist/agentSwitcher.d.ts +109 -0
- package/dist/agentSwitcher.js +165 -0
- package/dist/ago.d.ts +3 -3
- package/dist/ago.js +10 -10
- package/dist/allocations.d.ts +41 -0
- package/dist/allocations.js +76 -0
- package/dist/api.d.ts +1080 -11
- package/dist/chatStrings.d.ts +188 -0
- package/dist/chatStrings.js +217 -0
- package/dist/claudeAccounts.d.ts +38 -1
- package/dist/claudeAccounts.js +98 -4
- package/dist/claudeApi.js +1 -1
- package/dist/claudeSignIn.d.ts +19 -1
- package/dist/claudeSignIn.js +12 -2
- package/dist/commandsApi.d.ts +11 -1
- package/dist/commandsApi.js +24 -5
- package/dist/createPwCodeApi.d.ts +44 -5
- package/dist/createPwCodeApi.js +18 -2
- package/dist/directories.d.ts +161 -0
- package/dist/directories.js +301 -0
- package/dist/goal.d.ts +89 -0
- package/dist/goal.js +164 -0
- package/dist/imageFit.d.ts +23 -0
- package/dist/imageFit.js +27 -0
- package/dist/images.d.ts +28 -0
- package/dist/images.js +38 -6
- package/dist/index.d.ts +27 -12
- package/dist/index.js +26 -12
- package/dist/loadError.d.ts +8 -0
- package/dist/loadError.js +19 -0
- package/dist/locales/en/agentTranscript.js +73 -12
- package/dist/locales/en/agents.js +71 -9
- package/dist/locales/en.d.ts +124 -8
- package/dist/locales/es/agentTranscript.js +73 -12
- package/dist/locales/es/agents.js +71 -9
- package/dist/locales/ja/agentTranscript.js +76 -15
- package/dist/locales/ja/agents.js +45 -120
- package/dist/locales/ko/agentTranscript.js +73 -12
- package/dist/locales/ko/agents.js +71 -9
- package/dist/locales/zh/agentTranscript.js +71 -10
- package/dist/locales/zh/agents.js +71 -9
- package/dist/machine.d.ts +2 -0
- package/dist/modelPicker.d.ts +79 -0
- package/dist/modelPicker.js +107 -0
- package/dist/notices.js +47 -19
- package/dist/platformDefaults.d.ts +22 -0
- package/dist/platformDefaults.js +30 -0
- package/dist/preferences.d.ts +78 -0
- package/dist/preferences.js +128 -0
- package/dist/pullRequestList.d.ts +10 -2
- package/dist/pullRequestList.js +41 -22
- package/dist/query.d.ts +6 -2
- package/dist/query.js +85 -10
- package/dist/session.d.ts +5 -2
- package/dist/session.js +12 -8
- package/dist/sessionActions.d.ts +11 -1
- package/dist/sessionActions.js +14 -6
- package/dist/sessionEvents.d.ts +8 -3
- package/dist/sessionEvents.js +10 -5
- package/dist/sessionGroups.d.ts +3 -2
- package/dist/sessionGroups.js +4 -3
- package/dist/sessionList.d.ts +57 -9
- package/dist/sessionList.js +74 -12
- package/dist/sessionScreen.d.ts +193 -0
- package/dist/sessionScreen.js +213 -0
- package/dist/sessionsApi.d.ts +13 -3
- package/dist/sessionsApi.js +88 -29
- package/dist/settingsApi.d.ts +3 -1
- package/dist/startPage.d.ts +153 -0
- package/dist/startPage.js +174 -0
- package/dist/startSession.d.ts +41 -7
- package/dist/startSession.js +26 -4
- package/dist/transcript.js +48 -15
- package/dist/types.d.ts +11 -1
- package/dist/useComposer.d.ts +25 -1
- package/dist/useComposer.js +54 -3
- package/dist/useComposerImages.d.ts +5 -0
- package/dist/useComposerImages.js +24 -1
- package/dist/useComposerPastes.d.ts +70 -0
- package/dist/useComposerPastes.js +130 -0
- package/dist/useConversation.d.ts +10 -1
- package/dist/useConversation.js +32 -5
- package/dist/useSubagent.d.ts +49 -3
- package/dist/useSubagent.js +70 -7
- package/dist/useTranscript.d.ts +23 -3
- package/dist/useTranscript.js +76 -19
- package/dist/wording.js +2 -2
- package/dist/workingDirectories.d.ts +31 -0
- package/dist/workingDirectories.js +25 -1
- package/locales/en/agentTranscript.json +67 -11
- package/locales/en/agents.json +68 -8
- package/locales/es/agentTranscript.json +67 -11
- package/locales/es/agents.json +68 -8
- package/locales/ja/agentTranscript.json +70 -14
- package/locales/ja/agents.json +68 -8
- package/locales/ko/agentTranscript.json +67 -11
- package/locales/ko/agents.json +68 -8
- package/locales/zh/agentTranscript.json +65 -9
- package/locales/zh/agents.json +68 -8
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -1,96 +1,359 @@
|
|
|
1
1
|
# @parallelworks/code
|
|
2
2
|
|
|
3
3
|
Shared client logic for pw code sessions on Parallel Works ACTIVATE: the calls
|
|
4
|
-
and data hooks a session's
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
and data hooks a session's screens read through, what a session's daemon sends,
|
|
5
|
+
the transcript its history and live event stream reduce to, and what each
|
|
6
|
+
screen around it shows. Every app that shows a session uses the same code, so
|
|
7
|
+
a session reads the same in each.
|
|
7
8
|
|
|
8
9
|
It draws nothing. The host hands it an API client, which carries the
|
|
9
10
|
platform's address and signs each request, and a way to open its sockets; it
|
|
10
11
|
renders the messages this package turns the session into, worded in the
|
|
11
|
-
reader's language.
|
|
12
|
+
reader's language, with its own components.
|
|
12
13
|
|
|
13
14
|
```bash
|
|
14
|
-
pnpm add @parallelworks/code @parallelworks/ui react openapi-fetch swr use-intl
|
|
15
|
+
pnpm add @parallelworks/code @parallelworks/ui @parallelworks/problem react openapi-fetch swr use-intl
|
|
15
16
|
```
|
|
16
17
|
|
|
17
|
-
`@parallelworks/ui
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
`@parallelworks/ui` (0.136.0 or newer), `@parallelworks/problem`, `react`,
|
|
19
|
+
`openapi-fetch`, `swr` and `use-intl` are peer dependencies. Only the ui
|
|
20
|
+
package's two entries without a DOM are imported:
|
|
21
|
+
`@parallelworks/ui/ai/headless`, for the message and part types, the reducers
|
|
22
|
+
that build them and the chat's shared rules, such as its paste cards and the
|
|
23
|
+
model it picks first, and `@parallelworks/ui/headless`, for its duration and
|
|
24
|
+
byte formats and its clock. Of `@parallelworks/problem`, only its root, to
|
|
25
|
+
read an error's code as the host's own error messages do.
|
|
22
26
|
|
|
23
27
|
## What is in it
|
|
24
28
|
|
|
29
|
+
Most hooks take the API this package builds over the host's client, and
|
|
30
|
+
callbacks for whatever the host does itself: navigating, asking the reader,
|
|
31
|
+
showing a toast, wording an error. Types are exported beside each.
|
|
32
|
+
|
|
33
|
+
### The API and the wire
|
|
34
|
+
|
|
25
35
|
- `createPwCodeApi(client, options)`, the calls and SWR data hooks of pw code
|
|
26
36
|
sessions over the host's `openapi-fetch` client: the sessions and machines
|
|
27
|
-
listed (`useSessions`, `useMachines`
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
`
|
|
31
|
-
|
|
37
|
+
listed (`useSessions`, `useMachines`, `useMachine`,
|
|
38
|
+
`useWaitingSessionCount`), a session's transcript (`useSessionDetail`), its
|
|
39
|
+
live event feed (`useSessionEvents`), what can be done to it
|
|
40
|
+
(`useSessionMutations`, `sendMessage`, `steer`, `withdrawQueued`,
|
|
41
|
+
`withdrawDirection`, `answerApproval`, `resolveTyped`, ...), its settings
|
|
42
|
+
(`useSessionSettings`), its commands (`usePalette`,
|
|
43
|
+
`useBackgroundCommands`, `requestRecap`, `runGoal`), its subagents, pull
|
|
44
|
+
requests, worktree, images and pastes, and the Claude Code models, accounts
|
|
45
|
+
and sign-in of its machine, and the machine's directories
|
|
46
|
+
(`useDirectories`, `usePathCompletion`, `useDirectoryTree`). It also reads
|
|
47
|
+
the platform's models (`usePlatformModels`), the reader's allocations
|
|
48
|
+
(`useAllocations`) and the AI chat a new session is to carry on
|
|
49
|
+
(`useChatHandoff(chatId)`), says whether pw code is on for the reader
|
|
50
|
+
(`usePwCodeEnabled`), and keeps the reader's choices in their account
|
|
51
|
+
(`usePreference`).
|
|
32
52
|
- The wire types (`PwCodeSessionDetail`, `PwCodeStreamEvent`,
|
|
33
53
|
`PwCodeApprovalRequest`, ...): a session's replayed history, its event
|
|
34
54
|
frames and the answers it accepts. A host that generates its API types can
|
|
35
55
|
assert they extend these.
|
|
36
|
-
-
|
|
37
|
-
|
|
56
|
+
- What the hooks build on, for a host that reads the same routes itself: the
|
|
57
|
+
feed's path (`sessionEventsPath`), the SWR key's prefix
|
|
58
|
+
(`QUERY_KEY_PREFIX`), how often lists are read again (`SESSIONS_REFRESH_MS`,
|
|
59
|
+
`pullRequestsRefreshMs`), the patches a listing takes
|
|
60
|
+
(`patchSessionNames`, `patchPullRequestStates`, `reachedByFeed`), which
|
|
61
|
+
frames change a session's subagents (`changesSubagents`), whether a cached
|
|
62
|
+
copy is still current (`cachedCopyCurrent`), when the session was last read
|
|
63
|
+
(`useLastReadAt`), and the part of a paste a message names it by
|
|
64
|
+
(`pasteRefs`).
|
|
65
|
+
|
|
66
|
+
### The transcript
|
|
67
|
+
|
|
68
|
+
- The reducers, which are pure functions: `initialTranscript` seeds a
|
|
69
|
+
`TranscriptState` from a fetched session, `applyStreamEvent` applies one
|
|
38
70
|
event frame to it, and `historyToMessages` maps replayed history alone.
|
|
71
|
+
Beside them, what a transcript holds (`pendingMessages`,
|
|
72
|
+
`pendingApprovals`, `turnRunning`, `bashRunning`, `reviewingCount`,
|
|
73
|
+
`liveSessionStatus`), where its feed resumes (`resumeCursor`), a subagent's
|
|
74
|
+
share of it (`subagentFrame`, `subagentSessionDetail`), and the edits the
|
|
75
|
+
reader's own sends make to it (`appendOwnMessage`, `appendSteeredMessage`,
|
|
76
|
+
`dropMessage`, `resolveApprovalEverywhere`).
|
|
39
77
|
- `usePwCodeTranscript`, the React state those reduce into, with sending,
|
|
40
|
-
steering a running turn, and taking back a
|
|
78
|
+
steering a running turn, and taking back a message the model has not been
|
|
79
|
+
handed yet, queued behind the turn or steered into it (`canRemoveQueued`,
|
|
80
|
+
`removeQueued`), or every one the machine still holds at once, each with
|
|
81
|
+
its pastes and images, and the first refusal, since one the model read
|
|
82
|
+
meanwhile stays sent (`takeBackPending`, each a `PwCodeTakenBack`).
|
|
83
|
+
The `typed` option of its `sendMessage` keeps what was typed when a command
|
|
84
|
+
resolved it to other text, so it comes back as typed.
|
|
41
85
|
- `approvalToPart` and `approvalAnswerBody`, between a session's approval
|
|
42
86
|
requests and the answer it accepts.
|
|
43
|
-
-
|
|
44
|
-
`
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
`
|
|
65
|
-
`
|
|
66
|
-
|
|
87
|
+
- Where a session's images load from: by ref (`sessionImageUrl`,
|
|
88
|
+
`isSessionImageUrl`), and for a GitHub attachment in a pull request the
|
|
89
|
+
session opened, through its machine first (`markdownImageSources`,
|
|
90
|
+
`githubAttachmentAsset`, `sessionGitHubImageUrl`), and the link it becomes
|
|
91
|
+
once none of those loads (`markdownImageLink`).
|
|
92
|
+
|
|
93
|
+
### An open session
|
|
94
|
+
|
|
95
|
+
- `usePwCodeConversation`, the session's conversation: its live transcript,
|
|
96
|
+
sends routed to its machine and taking them back while they wait, one at a
|
|
97
|
+
time or all at once (`takeBackPending`, which takes nothing while another
|
|
98
|
+
runs), approvals, the notice above the composer, and its subagents.
|
|
99
|
+
- `usePwCodeComposer`, what the composer can do and how the session stands
|
|
100
|
+
for it: typed text goes out as a message, a direction to the running turn,
|
|
101
|
+
a command or a `!` shell run, and the composer locks while the machine is
|
|
102
|
+
unreachable, the session is archived or live elsewhere, or it waits on an
|
|
103
|
+
approval. Its `recall` takes back what waits into the composer, as ↑ or
|
|
104
|
+
Edit under the queue does on the web: `available` says whether anything
|
|
105
|
+
can come back, and `take` resolves to each message's text and pastes, in
|
|
106
|
+
the order they would have reached the model (to none while another `take`
|
|
107
|
+
runs), having put their images back
|
|
108
|
+
through the `images` option's `restore`. It has the shape of the `recall`
|
|
109
|
+
that `@parallelworks/ui/ai`'s composer takes from 0.139.0. A host drawing
|
|
110
|
+
its own composer stops a turn with `stopTurn`, as that composer's stop
|
|
111
|
+
does: while anything can come back, the composer's own take-back runs
|
|
112
|
+
first, then the turn stops, even when the take-back threw, which
|
|
113
|
+
`stopTurn` resolves to. Its command
|
|
114
|
+
outputs (`useCommandOutputs`) and sent prompts (`promptHistory`, per
|
|
115
|
+
person) go with it.
|
|
116
|
+
- `usePwCodeSessionScreen`, the screen around those two: the banner while
|
|
117
|
+
nothing new can reach the transcript (`sessionBanner`, whose `tone` is
|
|
118
|
+
`danger` for a machine that does not answer and `info` for a session live
|
|
119
|
+
elsewhere), the activity line (`sessionActivity`), the goal (`goalLabel`,
|
|
120
|
+
whose dot, a `PwCodeGoalMark`, has the `info` tone, unlit while paused and
|
|
121
|
+
pulsing while a check runs), what shows when the transcript never loaded
|
|
122
|
+
(`loadErrorMessage`), the command menu and the settings row.
|
|
123
|
+
The goal itself is read, edited, paused, resumed and cleared from a panel
|
|
124
|
+
over `useSessionGoal` (a `PwCodeSessionGoal`), which also gives the panel's
|
|
125
|
+
`view` and `note`, the run's `state`, `lastCheck` and `pausedNote`, which
|
|
126
|
+
of pause and resume to offer (`toggle`), when nothing can be asked
|
|
127
|
+
(`busy`), and the draft of a rewritten condition (`draft`, `setDraft`,
|
|
128
|
+
`startEdit`, `empty`, `unchanged`, `canSave`, `saving`, `save`). Its
|
|
129
|
+
working time runs with `useGoalElapsed` and is rounded by `goalElapsed`;
|
|
130
|
+
`goalFacts` says what follows the state.
|
|
131
|
+
Its parts: how stale the transcript is (`useStaleFor`), the draft's key
|
|
132
|
+
(`sessionDraftKey`), which picker the composer opens (`useSessionPicker`),
|
|
133
|
+
the model it runs (`sessionModel`), the settings' options
|
|
134
|
+
(`sessionSettingsOptions`), what the machine allows
|
|
135
|
+
of Claude Code (`claudeOnMachine`), and the account a Claude model runs as
|
|
136
|
+
(`claudeAccountChip`).
|
|
137
|
+
- Images and pastes sent with a message. `useComposerImages` holds the images
|
|
138
|
+
until there is a session to save them with, through the host's encoder,
|
|
139
|
+
which throws `PwCodeImageTooLarge` for one it cannot fit; `fitImageWith`
|
|
140
|
+
works out the sizes an image is written at to fit `IMAGE_MAX_BYTES` and
|
|
141
|
+
`IMAGE_MAX_SIDE`, `IMAGE_TYPES` are the types a session takes, and
|
|
142
|
+
`nextImageSeq` numbers an image's placeholder. `useComposerImages`'
|
|
143
|
+
`restore` puts back the images of a message taken back, already saved with
|
|
144
|
+
the session, and `withoutAppendedImages` takes the placeholders its send
|
|
145
|
+
appended out of that message's text. `useComposerPastes` says where a
|
|
146
|
+
session's long pastes are saved and past what size, set by its model until
|
|
147
|
+
it is live, `usePasteCards` turns
|
|
148
|
+
each one past it into a card that goes as its placeholder, and
|
|
149
|
+
`pasteCardText` words a card.
|
|
150
|
+
- A recap written while the reader is away (`useAwayRecap`), as pw code
|
|
151
|
+
writes one while its terminal is out of focus.
|
|
152
|
+
- Subagents: one subagent's conversation in place of the main one
|
|
153
|
+
(`usePwCodeSubagent`), with what its screen shows: whether it is still
|
|
154
|
+
loading or never loaded (`loading`, and `failed` from its `subagent`
|
|
155
|
+
read's `error`), whether messages show their author (`showAuthor`), its
|
|
156
|
+
activity line (`activity`), where a queued message goes
|
|
157
|
+
(`queueDelivery`), taking one back (`canRemoveQueued`, `removeQueued`) or
|
|
158
|
+
all of them into the composer (`recall`, as the main composer's), its
|
|
159
|
+
composer's draft key (`draftKey`), and the model it runs on (`model`) and
|
|
160
|
+
that model's name (`modelLabel`, from the `modelNames` option, the session
|
|
161
|
+
state's). Beside it, the switcher that lists them
|
|
162
|
+
(`usePwCodeAgentSwitcher`, `switcherAgent`, `usePwCodeAgentLine`,
|
|
163
|
+
`useAgentTypeLabel`), the mark each agent shows for its state
|
|
164
|
+
(`agentMark`), and the tone of its state's word (`stateTone`, a
|
|
165
|
+
`PwCodeStateTone` the host maps to its colors) and whether that word
|
|
166
|
+
shows beside the mark (`flagged`), the main conversation's included.
|
|
167
|
+
- Where typed text goes (`slashAction`, `shellCommand`), the commands a
|
|
168
|
+
session offers (`paletteOptions`), read from the structural
|
|
169
|
+
`PwCodePalette`, whether a direction that got no answer may have landed
|
|
170
|
+
(`steerMayHaveLanded`), and which running tool calls carry the offer to
|
|
171
|
+
move a turn's commands to the background (`offersBackground`,
|
|
172
|
+
`BACKGROUND_TOOL`).
|
|
173
|
+
- What a session's header offers: picking the session up in a terminal
|
|
174
|
+
(`terminalHandoffPanel`, `handoffCommandParts`), the line a turn shows while
|
|
175
|
+
it waits for a usage limit (`useUsageLimitWait`), the worktree the session
|
|
176
|
+
works in, read again when it moves (`useFollowedWorktree`), and how sessions
|
|
177
|
+
get listed (`howSessionsAppear`).
|
|
178
|
+
- A session's working directories: how one is written on its machine
|
|
179
|
+
(`workingDirectoryText`, `PwCodeWorkingDirectoryText`), the path helpers
|
|
180
|
+
that cut a long path to fit (`pathSegments`, `shortestPath`, `cutToFit`,
|
|
181
|
+
`cutSpacing`, `lastSegmentAt`), where a directory is saved
|
|
182
|
+
(`isSavedDirectory`, `directoryScopes`), what an approval allowed in one
|
|
183
|
+
(`allowedAccess`), the added and allowed ones as they are listed
|
|
184
|
+
(`sessionDirectories`, `PwCodeSessionDirectories`,
|
|
185
|
+
`PwCodeAddedDirectoryRow`, `PwCodeAllowedDirectoryRow`), and closing one
|
|
186
|
+
added for the session only (`useRemoveSessionDirectory`).
|
|
67
187
|
- The choice to keep or remove a session's worktree when the session is
|
|
68
188
|
deleted (`useWorktreeChoice`), and what removing it would delete
|
|
69
189
|
(`worktreeWork`).
|
|
70
|
-
- Where typed text goes (`slashAction`, `shellCommand`) and the commands a
|
|
71
|
-
session offers (`paletteOptions`), read from the structural `PwCodePalette`.
|
|
72
190
|
- The short label of a pull or merge request link (`pullRequestLabel`,
|
|
73
|
-
`pastedPullRequestLabel`), and
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
(`
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
191
|
+
`pastedPullRequestLabel`, `pullRequestShortLabel`, `pullRequestKind`), and
|
|
192
|
+
how a session's pull requests are listed: their order
|
|
193
|
+
(`orderPullRequests`), the tone each state shows in (`pullRequestTone`),
|
|
194
|
+
which fold into a count and how the counts read
|
|
195
|
+
(`foldPullRequests`, `pullRequestGroupState`, `pullRequestWords`), with
|
|
196
|
+
the merged and closed ones folding even when they fit once a row has
|
|
197
|
+
`FOLD_DONE_PULL_REQUESTS_FROM` of them (`donePullRequestsToFold`), and the
|
|
198
|
+
row of directories and pull requests under a session's title
|
|
199
|
+
(`sessionContextRow`), whose states the API's `useSessionPullRequestStates`
|
|
200
|
+
reads for the links the session lists.
|
|
201
|
+
|
|
202
|
+
### The session list
|
|
203
|
+
|
|
204
|
+
- What a list of sessions and machines means, as pure functions over the
|
|
205
|
+
structural `PwCodeSession` and `PwCodeMachine`: which row is which session
|
|
206
|
+
(`sessionKey`, `isSession`), which sessions wait on the reader and in what
|
|
207
|
+
order they show (`triageSessions`, `newestFirst`, `needsYou`,
|
|
208
|
+
`isActiveSession`, `isMidTurn`), the tone a row takes (`sessionVariant`),
|
|
209
|
+
whether a machine can be reached or can start a session (`isMachineDown`,
|
|
210
|
+
`isConnected`, `canStartHere`), computers apart from resources
|
|
211
|
+
(`isComputer`, `splitMachines`), the folders a machine's sessions suggest
|
|
212
|
+
(`recentDirectories`), and the command that picks a session up in a
|
|
213
|
+
terminal (`terminalHandoff`).
|
|
214
|
+
- `useSessionList`, the list in sections: the pinned sessions, each of the
|
|
215
|
+
reader's groups, then the rest by whether they wait on the reader, are live,
|
|
216
|
+
rest or are archived (`sessionSections`, the one that waits on the reader
|
|
217
|
+
with a `tone`), with folding, dropping a session on a section (`canDrag`,
|
|
218
|
+
`dropSession`), naming a group without the spaces around its name and the
|
|
219
|
+
words of the prompts for it (`renameGroup`, `groupNameWords`,
|
|
220
|
+
`groupDeleteWords`), the menus and keys of a row, a group and the list, and
|
|
221
|
+
the error to show in the list's place while no listing has loaded
|
|
222
|
+
(`loadError`). Beside it, what a search lists (`searchedSessions`), what it
|
|
223
|
+
finds a session by (`sessionSearchText`) and how well
|
|
224
|
+
(`sessionSearchScore`, over the host's own fuzzy scorer, a
|
|
225
|
+
`PwCodeSearchScorer` such as cmdk's `defaultFilter`), the state a result
|
|
226
|
+
shows (`sessionSearchStatus`), each row's mark and second line
|
|
227
|
+
(`sessionMark`, `sessionRowState`), what a session's mark on a collapsed
|
|
228
|
+
list is called (`sessionRailLabel`), and the rows of a machine the listing
|
|
229
|
+
lost, kept so they can say why (`useRetainedSessions`).
|
|
230
|
+
- `useSessionActions`, what can be done to a session from the list and the
|
|
231
|
+
flows behind each: renaming, pinning, grouping, forking, leaving its
|
|
232
|
+
worktree, stopping, archiving, restoring and deleting, asking the reader
|
|
233
|
+
first where it should. Its `rename` carries the words of the prompt for the
|
|
234
|
+
name, and `nameToSave` is the name a prompt saves, or none.
|
|
235
|
+
- The reader's groups (`useSessionGroups`), and the sessions in each
|
|
236
|
+
(`listGroups`, `inFlightFirst`, `groupOf`).
|
|
237
|
+
|
|
238
|
+
### Starting a session
|
|
239
|
+
|
|
240
|
+
- Hooks a host draws its own start screen over: where it starts
|
|
241
|
+
(`useStartLocation`, `startMachines`, `machineMenu`, and the chip naming
|
|
242
|
+
the machine, `machineChip`, whose `dot` has the `success` tone once one is
|
|
243
|
+
chosen, and which says the machines are still being found while
|
|
244
|
+
`finding`), the permission mode it
|
|
245
|
+
starts in and the machine's bounds on its picker (`useStartPermissionMode`,
|
|
246
|
+
a `PwCodeStartPermission`, `startingMode`), its model, allocation and
|
|
247
|
+
Claude Code account (`useStartModel`), and the start itself with its first
|
|
248
|
+
prompt and images (`useStartSession`). The host passes in its saved
|
|
249
|
+
preferences and opens the session once it starts. `startControls`
|
|
250
|
+
(`PwCodeStartControls`) says which controls are locked while it starts or
|
|
251
|
+
until a machine is chosen, and whether the model picker reads the
|
|
252
|
+
machine's Claude models ahead (`canStart`).
|
|
253
|
+
- Choosing that directory: a machine's directories as it lists them
|
|
254
|
+
(`listDirectories` and `useDirectories` on the API), and the rows a path
|
|
255
|
+
field offers under what is typed, the directory it names, the recent ones
|
|
256
|
+
and the directories inside it (the API's `usePathCompletion`, over
|
|
257
|
+
`pathCompletions`), with the helpers that read typed text as a path
|
|
258
|
+
(`splitTypedPath`, `typedDirectory`, `joinDirectory`, `parentDirectory`,
|
|
259
|
+
`isPathText`, `listedText`), and the refusal of a path that is no
|
|
260
|
+
directory the machine can list (`isUnlistedDirectory`).
|
|
261
|
+
`usePathCompletion` also returns each row as shown (`PwCodePathRow`:
|
|
262
|
+
whether choosing it lists its folders, and the line beside its name), the
|
|
263
|
+
rows in their headed sections (`sections`, from `pathSections`), the line
|
|
264
|
+
under them (`note`, from `pathNote`, which words a failed listing with the
|
|
265
|
+
host's `describeError`), whether to offer browsing, on a machine that lists
|
|
266
|
+
its folders (`canBrowse`), and where browsing opens (`browseFrom`, from
|
|
267
|
+
`browseStart`). `pickedOnClose` is the directory a field closed with an
|
|
268
|
+
edited path picks, and `directoryChip` words the chip naming the directory.
|
|
269
|
+
- Browsing for it: a folder tree of the machine, where it opens, its title
|
|
270
|
+
and the way up (the API's `useDirectoryTree`), and the folders it shows,
|
|
271
|
+
hidden ones only when asked for (`visibleFolders`).
|
|
272
|
+
- The screen around the composer (`useStartScreen`, `PwCodeStartScreen`):
|
|
273
|
+
whether the listing is still loading or never loaded (`loading`,
|
|
274
|
+
`failed`), whether the composer shows or the host says no machine can
|
|
275
|
+
start a session (`showComposer`), whether nothing is listed, so the host
|
|
276
|
+
explains how sessions appear (`explainEmpty`), and answering a listed
|
|
277
|
+
session's question (`answer`).
|
|
278
|
+
- What a start screen offers besides: the sessions to pick back up
|
|
279
|
+
(`startShortlist`, `waitingSince`) with the mark a live one shows
|
|
280
|
+
(`shortlistMark`) and the questions they wait on (`waitingQuestions`); the
|
|
281
|
+
session or chat its address asks for (`startSearch`, `useSessionLink`)
|
|
282
|
+
with the card shown while a linked session is looked for
|
|
283
|
+
(`sessionLinkNotice`, whose `tone` is `warning` once it is missing); the
|
|
284
|
+
composer's commands (`startCommands`) and draft key
|
|
285
|
+
(`newSessionDraftKey`); and a chat handed to a new session, read with the
|
|
286
|
+
API's `useChatHandoff`: the composer's `placeholder`, the `notice` above it
|
|
287
|
+
naming the chat or why it did not load (whose `tone` is then `warning`),
|
|
288
|
+
and its first prompt
|
|
289
|
+
(`chatHandoffStart`, `chatHandoffPrompt`).
|
|
290
|
+
- The models a session can run (`isClaudeModel`, `runsClaude`,
|
|
291
|
+
`canRunModel`, `modelLabel`), the picker a typed command opens
|
|
292
|
+
(`pickerCommand`), and the model picker: the platform's models by provider
|
|
293
|
+
and the machine's Claude ones (`useModelPicker`, `modelGroups`,
|
|
294
|
+
`platformModelStatus`, `providerIssueOf`, `useModelCatalog`). For a host
|
|
295
|
+
with no chat of its own to take them from, `usePlatformDefaults` gives the
|
|
296
|
+
platform model and allocation a chat would select.
|
|
297
|
+
- The allocations a model bills (`useModelAllocations`, `billsAllocation`),
|
|
298
|
+
and the rules behind them (`aiAllocations`, `allocationsForType`,
|
|
299
|
+
`allocationProblem`, `allocationChoice`, `allocationUsage`).
|
|
300
|
+
|
|
301
|
+
### Claude Code accounts
|
|
302
|
+
|
|
303
|
+
- A machine's accounts as a panel lists them, with adding, signing in,
|
|
304
|
+
removing and choosing one (`useClaudeAccountPanel`, given the
|
|
305
|
+
`machineName` its words name the machine by). It words each view in the
|
|
306
|
+
reader's language: its title and description, why Claude Code can't run on
|
|
307
|
+
the machine, where signing in happens, the question a removal asks, and
|
|
308
|
+
the line under each account's name, its email or how to sign it in on the
|
|
309
|
+
machine (`detail`, a `ClaudeAccountDetail`). It also says which of the
|
|
310
|
+
list's controls show and the row the list starts on, and
|
|
311
|
+
`useClaudeAccountStartRow` moves the host's highlight there, and back
|
|
312
|
+
whenever the selected or first enabled row changes, such as when the
|
|
313
|
+
accounts' sign-in states arrive. Its setter must keep its identity, as a
|
|
314
|
+
`useState` setter does: a new one moves the highlight back too.
|
|
315
|
+
- The sign-in itself, run in the host's terminal (`useClaudeSignIn`, also
|
|
316
|
+
given `machineName`), with the sign-in page to offer opening, what to do,
|
|
317
|
+
a note when earlier output was dropped, the label that leaves it, and,
|
|
318
|
+
once signed in, the host's `onUse` to offer (`use`).
|
|
319
|
+
`canOpenSignInLink` says whether a link in its output may be opened: web
|
|
320
|
+
addresses only, never a script or a local file.
|
|
321
|
+
- The steps of a removal and of naming a new account
|
|
322
|
+
(`useClaudeAccountRemoval`, `useClaudeAccountName`, `claudeAccountName`),
|
|
323
|
+
an account's usage limits (`useClaudeAccountUsage`), and the refusal that
|
|
324
|
+
asks for a sign-in first (`claudeSignInRequired`).
|
|
325
|
+
|
|
326
|
+
### Preferences
|
|
327
|
+
|
|
328
|
+
Each choice a client keeps for the reader, under the key and fallback every
|
|
329
|
+
client uses (`startModePreference`, `startEffortPreference`,
|
|
330
|
+
`startMachinePreference`, `startAccountPreference`, `lastModelPreference`,
|
|
331
|
+
`chatModelPreference`, `foldedGroupsPreference`, `sessionGroupsPreference`,
|
|
332
|
+
`showHiddenPreference`), and the rules for keeping it
|
|
333
|
+
(`useStartModePreference`, `useStartEffortPreference`,
|
|
334
|
+
`useStartMachinePreference`, `useStartAccountPreference`,
|
|
335
|
+
`useLastModelPreference`). Each rule takes the preference as a `[value, set]`
|
|
336
|
+
pair, from `usePreference` or the host's own store.
|
|
337
|
+
`useStartDefaultsFromSession` takes the start mode, effort and account
|
|
338
|
+
preferences and returns the callbacks for `useSessionSettings` that make a
|
|
339
|
+
pick in an open session where new sessions start.
|
|
340
|
+
|
|
341
|
+
### Words
|
|
342
|
+
|
|
83
343
|
- The messages a session is shown in, in English, Spanish, Japanese, Korean
|
|
84
|
-
and Chinese (`loadPwCodeMessages`), and
|
|
85
|
-
session's label and status (`sessionLabel`,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
(`
|
|
89
|
-
`useRecapNotice`, `
|
|
344
|
+
and Chinese (`loadPwCodeMessages`, `pwCodeLocales`, `isPwCodeLocale`), and
|
|
345
|
+
the words built from them: a session's label and status (`sessionLabel`,
|
|
346
|
+
`sessionStateText`, `sessionStatusText`), why a machine can't be reached
|
|
347
|
+
(`machineHint`), what the composer says while it is locked
|
|
348
|
+
(`composerState`), and the transcript's own lines (`useTranscriptWords`,
|
|
349
|
+
`useGoalNotice`, `useCompactionNotice`, `useRecapNotice`, `useResumeTime`,
|
|
350
|
+
`turnDuration`, `useToolStrings`).
|
|
351
|
+
- Every word of `@parallelworks/ui/ai`'s chat a session's screens show, by
|
|
352
|
+
`ChatStrings` section (`usePwCodeChatStrings`), for a host to pass as its
|
|
353
|
+
chat config's `strings`.
|
|
90
354
|
- How long ago something happened, as "5m", for labels passed as strings
|
|
91
|
-
(`useCompactAgo`). It reads
|
|
92
|
-
|
|
93
|
-
and re-reads every 30 seconds on the ui package's clock.
|
|
355
|
+
(`useCompactAgo`). It reads the `agents` messages and re-reads every 30
|
|
356
|
+
seconds on the ui package's clock.
|
|
94
357
|
|
|
95
358
|
## Messages
|
|
96
359
|
|
|
@@ -155,85 +418,307 @@ Create it once per client, at module level. Its hooks key SWR's cache as
|
|
|
155
418
|
`@parallelworks/client/swr`'s hooks do (`['api', path, init]`, or `null` for a
|
|
156
419
|
read they skip), and throw the client's error as those do, so a host that reads
|
|
157
420
|
the same routes through those shares their cache entries, and revalidating one
|
|
158
|
-
revalidates the other. `
|
|
159
|
-
|
|
421
|
+
revalidates the other. Only `usePwCodeEnabled` keys its read by the path alone,
|
|
422
|
+
`'/api/previews'`, as a host reading previews with plain SWR keys it.
|
|
423
|
+
`useSessionDetail` gives up a read still on its way once it no longer shows
|
|
424
|
+
that session, so the connection goes to the one the reader moved on to.
|
|
425
|
+
|
|
426
|
+
Its other options:
|
|
427
|
+
|
|
428
|
+
- `hidden`, when given, says the app is out of sight, where animation frames
|
|
429
|
+
do not run, so feed frames are applied as they arrive.
|
|
430
|
+
- `onPreferenceError` hears a preference that failed to save; it shows its
|
|
431
|
+
saved value again.
|
|
432
|
+
- `previewsByRef` reads a transcript with each image's preview left to its
|
|
433
|
+
ref, to be loaded when it is drawn. Set it only where the host loads an
|
|
434
|
+
image from its URL on the platform's API signed in as the API client is, as
|
|
435
|
+
a browser on the platform's origin does.
|
|
160
436
|
|
|
161
437
|
The package carries the types of the routes it calls (`PwCodePaths`), generated
|
|
162
438
|
from the platform's OpenAPI spec. A client whose own API types lack one of
|
|
163
439
|
those routes, or type one differently, is refused at compile time, naming the
|
|
164
440
|
routes it lacks; regenerate the host's types from a newer spec.
|
|
165
441
|
|
|
166
|
-
|
|
442
|
+
pw code is a preview (`PW_CODE_PREVIEW`). Its routes answer 404 for a reader
|
|
443
|
+
without it, so check
|
|
444
|
+
`pwCode.usePwCodeEnabled()`, undefined until the reader's previews load,
|
|
445
|
+
before offering it; `pwCodeEnabled(previews)` answers the same from previews
|
|
446
|
+
the host has already read.
|
|
447
|
+
|
|
448
|
+
## An open session
|
|
167
449
|
|
|
168
450
|
```tsx
|
|
169
451
|
import {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
452
|
+
isSession,
|
|
453
|
+
sessionSettingsOptions,
|
|
454
|
+
useGoalNotice,
|
|
455
|
+
usePwCodeComposer,
|
|
456
|
+
usePwCodeConversation,
|
|
457
|
+
usePwCodeSessionScreen,
|
|
458
|
+
useStaleFor,
|
|
174
459
|
} from '@parallelworks/code'
|
|
175
460
|
import { pwCode } from './pwCode'
|
|
176
461
|
|
|
177
|
-
function
|
|
178
|
-
|
|
179
|
-
const
|
|
462
|
+
function useOpenSession(machine: string, sessionId: string, host: Host) {
|
|
463
|
+
const sessions = pwCode.useSessions()
|
|
464
|
+
const listed = sessions.data?.sessions?.find(s =>
|
|
465
|
+
isSession(s, machine, sessionId)
|
|
466
|
+
)
|
|
467
|
+
const read = pwCode.useSessionDetail(machine, sessionId, listed)
|
|
468
|
+
const machineRead = pwCode.useMachine(machine)
|
|
469
|
+
const conversation = usePwCodeConversation({
|
|
470
|
+
api: pwCode,
|
|
471
|
+
machine,
|
|
472
|
+
sessionId,
|
|
473
|
+
sessions,
|
|
474
|
+
detail: read,
|
|
475
|
+
describeError: host.describeError,
|
|
476
|
+
notify: host.toast,
|
|
477
|
+
onCleared: id => host.openSession(machine, id),
|
|
478
|
+
onMoved: copy => host.openSession(copy.machineId, copy.id),
|
|
479
|
+
// Without it, a goal's progress takes no line in the transcript.
|
|
480
|
+
goalNotice: useGoalNotice(),
|
|
481
|
+
})
|
|
482
|
+
// Resumed from the cursor once this visit has read the session itself: a
|
|
483
|
+
// copy cached by an earlier visit trails the feed.
|
|
484
|
+
const feed = pwCode.useSessionEvents(
|
|
180
485
|
machine,
|
|
181
486
|
sessionId,
|
|
182
|
-
undefined
|
|
487
|
+
read.fresh ? conversation.cursor : undefined,
|
|
488
|
+
conversation.onEvent
|
|
183
489
|
)
|
|
184
|
-
const
|
|
490
|
+
const staleFor = useStaleFor(read.data, feed.connected)
|
|
491
|
+
const composer = usePwCodeComposer({
|
|
492
|
+
api: pwCode,
|
|
493
|
+
machine,
|
|
185
494
|
sessionId,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
})
|
|
194
|
-
return error ? { error: error.message } : data
|
|
195
|
-
},
|
|
196
|
-
onEffect: effect => {
|
|
197
|
-
// What a frame asks of the host: 'refetch', 'cleared', 'state' or 'notice'.
|
|
198
|
-
if (effect.type === 'refetch') {
|
|
199
|
-
void mutate()
|
|
200
|
-
}
|
|
201
|
-
},
|
|
495
|
+
conversation,
|
|
496
|
+
machineInfo: machineRead.machine,
|
|
497
|
+
feed,
|
|
498
|
+
staleFor,
|
|
499
|
+
notify: host.toast,
|
|
500
|
+
onCleared: id => host.openSession(machine, id),
|
|
501
|
+
onArchived: host.showList,
|
|
202
502
|
})
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
503
|
+
const settings = pwCode.useSessionSettings({
|
|
504
|
+
...sessionSettingsOptions(machine, conversation, composer),
|
|
505
|
+
onPatched: () => void read.mutate(),
|
|
506
|
+
onError: conversation.showError,
|
|
507
|
+
})
|
|
508
|
+
const screen = usePwCodeSessionScreen({
|
|
509
|
+
conversation,
|
|
510
|
+
composer,
|
|
511
|
+
read,
|
|
512
|
+
machine: machineRead,
|
|
513
|
+
staleFor,
|
|
514
|
+
settings,
|
|
515
|
+
images: [],
|
|
516
|
+
describeError: host.describeError,
|
|
517
|
+
})
|
|
518
|
+
return { conversation, composer, settings, screen }
|
|
213
519
|
}
|
|
214
520
|
```
|
|
215
521
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
522
|
+
Call it from a component mounted once per session, keyed by machine and
|
|
523
|
+
session as the web's session page is. Its reads and its transcript keep what
|
|
524
|
+
they learned of the session they first showed, so a screen that moves to
|
|
525
|
+
another session in place shows that session's copy cached by an earlier
|
|
526
|
+
visit, resumes its feed from that copy, and carries over messages still on
|
|
527
|
+
their way to the old one.
|
|
528
|
+
|
|
529
|
+
`conversation.all` is what the transcript draws: its messages, the one
|
|
530
|
+
streaming, then those queued behind the turn. `composer.send` sends what was
|
|
531
|
+
typed, and `screen` says what goes around them. A host that wants only the
|
|
532
|
+
transcript runs `usePwCodeTranscript` over the same detail and feed, with its
|
|
533
|
+
own `send` and `steer`, `withdraw` and `withdrawDirection` to take back a
|
|
534
|
+
queued or a steered message by the `turnId` its `send` or the `id` its `steer`
|
|
535
|
+
resolved to, and an `onEffect` that does what a frame asks:
|
|
536
|
+
`refetch`, `cleared`, `state` or `notice`. `goalNotice`, `compactionNotice`,
|
|
537
|
+
`recapNotice` and `words` supply the transcript's own lines in the reader's
|
|
538
|
+
language, from `useGoalNotice()`, `useCompactionNotice()`, `useRecapNotice()`
|
|
539
|
+
and `useTranscriptWords()`; without them those lines are missing or in
|
|
540
|
+
English. `imageUrl` turns an
|
|
541
|
+
image's `ref` into the URL it loads from, as
|
|
542
|
+
`ref => sessionImageUrl(machine, sessionId, ref)` does; without it an image
|
|
543
|
+
opens only at its preview's size, and one read with `previewsByRef` does not
|
|
544
|
+
show.
|
|
223
545
|
|
|
224
546
|
On the web, `SessionView` from `@parallelworks/ui/ai` draws these messages. A
|
|
225
547
|
host with its own components renders `ChatMessage` and its parts itself.
|
|
226
548
|
|
|
549
|
+
## On React Native
|
|
550
|
+
|
|
551
|
+
The package runs on the Hermes that React Native 0.88 ships, once four
|
|
552
|
+
FormatJS polyfills have loaded. Load them before anything imports
|
|
553
|
+
`@parallelworks/ui` or `@parallelworks/code`, in this order: each needs the
|
|
554
|
+
ones above it, and `@parallelworks/ui` builds formatters when it loads. The
|
|
555
|
+
last three carry the data of the five languages the messages come in. In an
|
|
556
|
+
Expo Router app, that is an entry file, named as `main` in the app's
|
|
557
|
+
`package.json`, that imports them and then `expo-router/entry`:
|
|
558
|
+
|
|
559
|
+
```js
|
|
560
|
+
import '@formatjs/intl-locale/polyfill.js'
|
|
561
|
+
import '@formatjs/intl-pluralrules/polyfill-force.js'
|
|
562
|
+
import '@formatjs/intl-pluralrules/locale-data/en.js'
|
|
563
|
+
import '@formatjs/intl-pluralrules/locale-data/es.js'
|
|
564
|
+
import '@formatjs/intl-pluralrules/locale-data/ja.js'
|
|
565
|
+
import '@formatjs/intl-pluralrules/locale-data/ko.js'
|
|
566
|
+
import '@formatjs/intl-pluralrules/locale-data/zh.js'
|
|
567
|
+
import '@formatjs/intl-numberformat/polyfill-force.js'
|
|
568
|
+
import '@formatjs/intl-numberformat/locale-data/en.js'
|
|
569
|
+
import '@formatjs/intl-numberformat/locale-data/es.js'
|
|
570
|
+
import '@formatjs/intl-numberformat/locale-data/ja.js'
|
|
571
|
+
import '@formatjs/intl-numberformat/locale-data/ko.js'
|
|
572
|
+
import '@formatjs/intl-numberformat/locale-data/zh.js'
|
|
573
|
+
import '@formatjs/intl-listformat/polyfill-force.js'
|
|
574
|
+
import '@formatjs/intl-listformat/locale-data/en.js'
|
|
575
|
+
import '@formatjs/intl-listformat/locale-data/es.js'
|
|
576
|
+
import '@formatjs/intl-listformat/locale-data/ja.js'
|
|
577
|
+
import '@formatjs/intl-listformat/locale-data/ko.js'
|
|
578
|
+
import '@formatjs/intl-listformat/locale-data/zh.js'
|
|
579
|
+
import 'expo-router/entry'
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
These versions were checked: `@formatjs/intl-locale` 5.4.3,
|
|
583
|
+
`@formatjs/intl-pluralrules` 7.0.4, `@formatjs/intl-numberformat` 10.0.4 and
|
|
584
|
+
`@formatjs/intl-listformat` 9.0.3. NumberFormat is forced because Hermes' own
|
|
585
|
+
ignores compact notation and unit display: a token count reads "12,345" for
|
|
586
|
+
"12.3K", and a reset "360 sec" for "6m".
|
|
587
|
+
|
|
588
|
+
Dates follow the device's own formatter by design, with no polyfill, so they
|
|
589
|
+
read as the phone writes them, which differs slightly from the web. On iOS,
|
|
590
|
+
English puts a narrow no-break space before AM and PM and "at" between the
|
|
591
|
+
date and the time ("Nov 14, 2026 at 3:30 PM" where the web writes "Nov 14,
|
|
592
|
+
2026, 3:30 PM"), Japanese puts the weekday before the time, and Japanese and
|
|
593
|
+
Chinese put a space beside the weekday. Android's formatter is not checked,
|
|
594
|
+
and can differ in other ways.
|
|
595
|
+
|
|
596
|
+
The package opens no socket, keeps nothing on the device, encodes no image
|
|
597
|
+
and navigates nowhere. The host supplies each:
|
|
598
|
+
|
|
599
|
+
- The event feed's socket, as `createPwCodeApi`'s `openSocket`. The platform
|
|
600
|
+
takes its credential only from an `Authorization` header or its session
|
|
601
|
+
cookie, never from a query parameter, so open it with the header React
|
|
602
|
+
Native's `WebSocket` takes in its third argument:
|
|
603
|
+
|
|
604
|
+
```ts
|
|
605
|
+
openSocket: async path =>
|
|
606
|
+
new WebSocket(`wss://activate.example.com${path}`, undefined, {
|
|
607
|
+
headers: { Authorization: `Bearer ${await accessToken()}` },
|
|
608
|
+
}),
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
- Whether the app is out of sight, as `hidden`, and whether the reader is away
|
|
612
|
+
from a session, as `useAwayRecap`'s `presence` (`away`, and `watch`, which
|
|
613
|
+
calls `leave` and `back` as that changes), both read from the app's state.
|
|
614
|
+
- Images: `useComposerImages`' `encode`, which writes a picked image as base64
|
|
615
|
+
within `IMAGE_MAX_BYTES` and `IMAGE_MAX_SIDE` and throws
|
|
616
|
+
`PwCodeImageTooLarge` for one it cannot fit (`fitImageWith` works out the
|
|
617
|
+
sizes over the host's own `write`), and its `preview` and `release`. A
|
|
618
|
+
transcript names a full-size image by its path on the platform's API
|
|
619
|
+
(`sessionImageUrl`, and `markdownImageSources` for a GitHub attachment),
|
|
620
|
+
which the host loads from the platform's address, signed in as its API
|
|
621
|
+
client is.
|
|
622
|
+
- Preferences:
|
|
623
|
+
`pwCode.usePreference(startModePreference.key, startModePreference.fallback)`
|
|
624
|
+
keeps a choice in the reader's account, as every client does; a host that
|
|
625
|
+
keeps them itself passes its own `[value, set]` pair to the rules, to
|
|
626
|
+
`useSessionGroups`, and to `useSessionList` as `folded`, whose `set` takes
|
|
627
|
+
an update function.
|
|
628
|
+
- Navigation, through callbacks: `useStartSession`'s `onStarted`,
|
|
629
|
+
`useSessionActions`' `showStart` and `showSession`,
|
|
630
|
+
`usePwCodeConversation`'s `onCleared` and `onMoved`, `usePwCodeComposer`'s
|
|
631
|
+
`onCleared` and `onArchived`, `useSessionLink`'s `open`, `useSessionList`'s
|
|
632
|
+
`newSession`, `useModelPicker`'s `onAccounts` and
|
|
633
|
+
`useClaudeAccountPanel`'s `onClose`.
|
|
634
|
+
- What the reader is told and asked: `describeError`, `notify`, and
|
|
635
|
+
`useSessionActions`' `confirm`; Claude Code's sign-in runs in the host's
|
|
636
|
+
terminal, `useClaudeSignIn`'s `terminal`.
|
|
637
|
+
|
|
638
|
+
The package is checked on the Hermes React Native 0.88.1 ships for iOS, with
|
|
639
|
+
this setup: it loads before any polyfill does, and once they have loaded its
|
|
640
|
+
functions, hooks and messages print what they print on the web, but for the
|
|
641
|
+
date differences above.
|
|
642
|
+
|
|
227
643
|
## No DOM
|
|
228
644
|
|
|
229
645
|
The build imports `react`, `luxon`, `swr`, `use-intl`, `gemoji` (for the
|
|
230
|
-
emoji shortcodes in a session's name), `@parallelworks/ui/ai/headless
|
|
231
|
-
`@parallelworks/ui/headless`, and its
|
|
232
|
-
nothing else, so it loads where there
|
|
233
|
-
|
|
234
|
-
|
|
646
|
+
emoji shortcodes in a session's name), `@parallelworks/ui/ai/headless`,
|
|
647
|
+
`@parallelworks/ui/headless` and `@parallelworks/problem`, and its
|
|
648
|
+
declarations `openapi-fetch` too, and nothing else, so it loads where there is
|
|
649
|
+
no DOM: a React Native bundle, a server, a test. Nor does it use what Hermes
|
|
650
|
+
lacks, such as `URL.canParse`, `structuredClone` or `Intl.Segmenter`. It opens
|
|
651
|
+
sockets only through the host's `openSocket`. The reducers need no React at
|
|
652
|
+
all.
|
|
235
653
|
|
|
236
654
|
## Versions
|
|
237
655
|
|
|
238
656
|
The wire types follow the pw code daemon. Before 1.0 a minor release can
|
|
239
657
|
change them.
|
|
658
|
+
|
|
659
|
+
### Breaking changes since 0.3.0
|
|
660
|
+
|
|
661
|
+
- `usePwCodeSubagent` takes `listed`, the subagent's switcher row
|
|
662
|
+
(`switcherAgent`), and `usage`, its tokens as the session's feed last
|
|
663
|
+
counted them, and no longer takes `name`: it names the subagent itself and
|
|
664
|
+
returns it as `agent`.
|
|
665
|
+
- `useSessionList`'s `folded` setter is handed an update function,
|
|
666
|
+
`(previous) => string[]`, in place of the new keys, so a store that has not
|
|
667
|
+
loaded them yet applies it to them rather than to its fallback. A
|
|
668
|
+
`[value, set]` pair from `useState` or `usePreference` takes it as it is.
|
|
669
|
+
- `useSessionList`'s `dropSession` leaves an archived session where it was,
|
|
670
|
+
and its `renameGroup` saves the name without the spaces around it, and
|
|
671
|
+
nothing for a blank one. The API's `useSessionPullRequestStates` takes the
|
|
672
|
+
links a session lists and returns the states of only the pull and merge
|
|
673
|
+
requests among them, leaving any other link out.
|
|
674
|
+
- `useClaudeAccountPanel` and `useClaudeSignIn` require a `machineName`
|
|
675
|
+
option, the machine's name as the reader knows it, which their words name
|
|
676
|
+
the machine by.
|
|
677
|
+
- `usePwCodeComposer`'s `images` option requires `restore` beside `take`
|
|
678
|
+
and `taking`, to put back the images of a message taken back.
|
|
679
|
+
`useComposerImages` returns it, so a host passing what that returns
|
|
680
|
+
changes nothing; one passing its own `{ take, taking }` adds it.
|
|
681
|
+
- Peer dependencies: `@parallelworks/problem` (`>=0.6.1 <1`) is new, and
|
|
682
|
+
`@parallelworks/ui` needs 0.136.0 or newer, up from 0.132.0.
|
|
683
|
+
- The host's API types must include eight more routes, which
|
|
684
|
+
`createPwCodeApi` now calls: `/api/allocations`, `/api/openai/v1/models`,
|
|
685
|
+
`/api/previews`, `/api/user/preferences`,
|
|
686
|
+
`/api/aichat/conversations/{id}`,
|
|
687
|
+
`/api/code/machines/{machine}/directories`,
|
|
688
|
+
`/api/code/machines/{machine}/sessions/{id}/direction/withdraw` and
|
|
689
|
+
`/api/code/machines/{machine}/sessions/{id}/subagents/{subId}/direction/withdraw`.
|
|
690
|
+
- `sessionSections`, `listGroups` and `inFlightFirst` take sessions with an
|
|
691
|
+
`id`, and list live sessions newest begun first (`createdAt`) rather than
|
|
692
|
+
newest updated, so a row holds still while its session works.
|
|
693
|
+
- `useCompactAgo` words its ages from the `agents` messages, not from
|
|
694
|
+
`@parallelworks/ui`'s `time` strings, and counts days past a year ("400d",
|
|
695
|
+
not "1y").
|
|
696
|
+
- `answerApproval` resolves to what was thrown when the request failed,
|
|
697
|
+
rather than rejecting.
|
|
698
|
+
- `useSessionMutations`' `pinSession`, `groupSession` and `restoreSession`
|
|
699
|
+
show the change in the list before the machine answers, and take it back if
|
|
700
|
+
it refuses.
|
|
701
|
+
- The main conversation's author has `kind: 'agent'`, so it is drawn as an
|
|
702
|
+
agent rather than a person.
|
|
703
|
+
- The approval messages in `agentTranscript` now read as ACTIVATE's AI chat
|
|
704
|
+
words them. In English and Spanish: `transcript.denyWithFeedback` ("No, and
|
|
705
|
+
tell the assistant why"), `transcript.feedbackPlaceholder`,
|
|
706
|
+
`transcript.feedbackLabel`, `transcript.allowedBy` ("{name} approved"),
|
|
707
|
+
`transcript.deniedBy` ("{name} denied"), `transcript.allowedByReviewer`
|
|
708
|
+
("Auto-reviewer approved"), `transcript.deniedByReviewer`,
|
|
709
|
+
`transcript.reviewTimedOut` ("Auto-review timed out") and
|
|
710
|
+
`transcript.reviewFailed`. In Japanese, Korean and Chinese:
|
|
711
|
+
`transcript.denyWithFeedback`, `transcript.feedbackPlaceholder`,
|
|
712
|
+
`transcript.feedbackLabel`, `transcript.reviewTimedOut` and
|
|
713
|
+
`transcript.reviewFailed`, and also `transcript.allowCall`,
|
|
714
|
+
`transcript.denyCall`, `transcript.allowed`, `transcript.approvalLabel`,
|
|
715
|
+
`transcript.approvalAllowed`, `transcript.approvalDenied` and
|
|
716
|
+
`transcript.approvalWaitingOn` in Japanese, `transcript.allowCall`,
|
|
717
|
+
`transcript.denyCall`, `transcript.approvalDenied` and
|
|
718
|
+
`transcript.approvalWaitingOn` in Korean, and `transcript.approvalLabel` and
|
|
719
|
+
`transcript.approvalWaitingOn` in Chinese.
|
|
720
|
+
- `start.otherPath` is gone from the `agents` messages in every language,
|
|
721
|
+
since the start screen's path field now lists a machine's directories.
|
|
722
|
+
So are `claude.current`, `claude.fiveHour`, `claude.week`,
|
|
723
|
+
`sidebar.groupRunning`, `sidebar.groupWaiting`, `sidebar.moreOptions` and
|
|
724
|
+
`detail.loading`, which nothing in the package said.
|