@parallelworks/code 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Parallel Works, Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
package/README.md CHANGED
@@ -1,3 +1,92 @@
1
- # Temporary Holding Version
1
+ # @parallelworks/code
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Shared client logic for pw code sessions on Parallel Works ACTIVATE: what a
4
+ session's daemon sends, and the transcript its
5
+ history and live event stream reduce to. Every app that shows a session uses
6
+ the same code, so a session reads the same in each.
7
+
8
+ It draws nothing and makes no requests. The host fetches the session, holds
9
+ the socket and renders the messages; this package turns the one into the
10
+ other.
11
+
12
+ ```bash
13
+ pnpm add @parallelworks/code @parallelworks/ui react
14
+ ```
15
+
16
+ `@parallelworks/ui` and `react` are peer dependencies. Only
17
+ `@parallelworks/ui/ai/headless` is imported from the ui package, for the
18
+ message and part types and the reducers that build them.
19
+
20
+ ## What is in it
21
+
22
+ - The wire types (`PwCodeSessionDetail`, `PwCodeStreamEvent`,
23
+ `PwCodeApprovalRequest`, ...): a session's replayed history, its event
24
+ frames and the answers it accepts. A host that generates its API types can
25
+ assert they extend these.
26
+ - The transcript reducers, which are pure functions: `initialTranscript` seeds
27
+ a `TranscriptState` from a fetched session, `applyStreamEvent` applies one
28
+ event frame to it, and `historyToMessages` maps replayed history alone.
29
+ - `usePwCodeTranscript`, the React state those reduce into, with sending,
30
+ steering a running turn, and taking back a queued message.
31
+ - `approvalToPart` and `approvalAnswerBody`, between a session's approval
32
+ requests and the answer it accepts.
33
+ - The paths a session's images are served from (`sessionImageUrl`,
34
+ `sessionGitHubImageUrl`).
35
+
36
+ ## Using the hook
37
+
38
+ ```tsx
39
+ import {
40
+ pendingMessages,
41
+ turnRunning,
42
+ usePwCodeTranscript,
43
+ } from '@parallelworks/code'
44
+
45
+ function useSession(sessionId: string) {
46
+ // The host's own fetch of the session: its status, history and last seq.
47
+ const { detail, refetch } = useSessionDetail(sessionId)
48
+ const { transcript, onEvent, cursor, sendMessage } = usePwCodeTranscript({
49
+ sessionId,
50
+ detail,
51
+ // Resolves to { turnId, queued } once accepted, or { error } to show.
52
+ send: (text, pastes, images) =>
53
+ postMessage(sessionId, text, pastes, images),
54
+ onEffect: effect => {
55
+ // What a frame asks of the host: 'refetch', 'cleared', 'state' or 'notice'.
56
+ if (effect.type === 'refetch') {
57
+ refetch()
58
+ }
59
+ },
60
+ })
61
+ // The host's own socket: it reconnects from cursor(), the last seq applied.
62
+ useSessionEvents(sessionId, cursor, onEvent)
63
+
64
+ return {
65
+ messages: transcript?.messages ?? [],
66
+ streaming: transcript?.streaming ?? null,
67
+ queued: transcript ? pendingMessages(transcript) : [],
68
+ running: turnRunning(transcript),
69
+ sendMessage,
70
+ }
71
+ }
72
+ ```
73
+
74
+ `steer` hands text to the turn that is running and `withdraw` takes a queued
75
+ message back; without them every message sent during a turn waits for it to
76
+ end. `goalNotice`, `compactionNotice`, `recapNotice` and `words` supply the
77
+ transcript's own lines in the reader's language, and `imageUrl` turns an
78
+ image's `ref` into the URL the host serves it from.
79
+
80
+ On the web, `SessionView` from `@parallelworks/ui/ai` draws these messages. A
81
+ host with its own components renders `ChatMessage` and its parts itself.
82
+
83
+ ## No DOM
84
+
85
+ The build imports `react`, `luxon` and `@parallelworks/ui/ai/headless`, and
86
+ nothing else, so it loads where there is no DOM: a React Native bundle, a
87
+ server, a test. The reducers need no React at all.
88
+
89
+ ## Versions
90
+
91
+ The wire types follow the pw code daemon. Before 1.0 a minor release can
92
+ change them.
@@ -0,0 +1,7 @@
1
+ /** The full-size image a session's transcript names by ref. */
2
+ export declare function sessionImageUrl(machine: string, session: string, ref: string): string;
3
+ export declare function isSessionImageUrl(url: string): boolean;
4
+ /** The asset id of a file attached on GitHub, which a private repository shows only to its members. */
5
+ export declare function githubAttachmentAsset(src: string): string | undefined;
6
+ /** A GitHub attachment as the session's machine reads it from a pull request the session opened. */
7
+ export declare function sessionGitHubImageUrl(machine: string, session: string, asset: string): string;
package/dist/images.js ADDED
@@ -0,0 +1,22 @@
1
+ // src/images.ts
2
+ var SESSION_IMAGES = "/api/code/machines/";
3
+ var GITHUB_ASSET_PATH = /^\/user-attachments\/assets\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/;
4
+ /** The full-size image a session's transcript names by ref. */
5
+ function sessionImageUrl(machine, session, ref) {
6
+ return `${SESSION_IMAGES}${encodeURIComponent(machine)}/sessions/${encodeURIComponent(session)}/images/${encodeURIComponent(ref)}`;
7
+ }
8
+ function isSessionImageUrl(url) {
9
+ return url.startsWith(SESSION_IMAGES) && url.includes("/images/");
10
+ }
11
+ /** The asset id of a file attached on GitHub, which a private repository shows only to its members. */
12
+ function githubAttachmentAsset(src) {
13
+ if (!URL.canParse(src)) return;
14
+ const url = new URL(src);
15
+ if (url.protocol !== "https:" || url.hostname !== "github.com") return;
16
+ return GITHUB_ASSET_PATH.exec(url.pathname)?.[1];
17
+ }
18
+ /** A GitHub attachment as the session's machine reads it from a pull request the session opened. */
19
+ function sessionGitHubImageUrl(machine, session, asset) {
20
+ return `${SESSION_IMAGES}${encodeURIComponent(machine)}/sessions/${encodeURIComponent(session)}/github-images/${encodeURIComponent(asset)}`;
21
+ }
22
+ export { githubAttachmentAsset, isSessionImageUrl, sessionGitHubImageUrl, sessionImageUrl };
@@ -0,0 +1,5 @@
1
+ export type { PwCodeAddedDirectory, PwCodeAllowedDirectory, PwCodeApprovalAnswer, PwCodeApprovalRequest, PwCodeAskOption, PwCodeGoalStatus, PwCodeHistoryItem, PwCodeHistoryKind, PwCodeImage, PwCodeImageRef, PwCodePasteView, PwCodeSessionDetail, PwCodeSessionState, PwCodeSessionStatus, PwCodeStreamEvent, } from './types.js';
2
+ export { githubAttachmentAsset, isSessionImageUrl, sessionGitHubImageUrl, sessionImageUrl, } from './images.js';
3
+ export { sessionStatusVariant } from './session.js';
4
+ 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, type TranscriptState, type TranscriptWords, turnRunning, type TurnVerb, } from './transcript.js';
5
+ export { type PwCodeSendResult, type PwCodeSteerResult, type PwCodeWithdrawResult, usePwCodeTranscript, } from './useTranscript.js';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import { githubAttachmentAsset, isSessionImageUrl, sessionGitHubImageUrl, sessionImageUrl } from "./images.js";
2
+ import { sessionStatusVariant } from "./session.js";
3
+ import { appendOwnMessage, appendSteeredMessage, applyStreamEvent, approvalAnswerBody, approvalToPart, bashRunning, dropMessage, historyToMessages, initialTranscript, liveSessionStatus, pendingApprovals, pendingMessages, resolveApprovalEverywhere, resumeCursor, reviewingCount, turnRunning } from "./transcript.js";
4
+ import { usePwCodeTranscript } from "./useTranscript.js";
5
+ export { appendOwnMessage, appendSteeredMessage, applyStreamEvent, approvalAnswerBody, approvalToPart, bashRunning, dropMessage, githubAttachmentAsset, historyToMessages, initialTranscript, isSessionImageUrl, liveSessionStatus, pendingApprovals, pendingMessages, resolveApprovalEverywhere, resumeCursor, reviewingCount, sessionGitHubImageUrl, sessionImageUrl, sessionStatusVariant, turnRunning, usePwCodeTranscript };
@@ -0,0 +1,3 @@
1
+ import type { PwCodeSessionStatus } from './types.js';
2
+ /** The tone a session's status shows in; a web host passes it to a status badge. */
3
+ export declare function sessionStatusVariant(status: PwCodeSessionStatus): 'info' | 'warning' | 'muted';
@@ -0,0 +1,11 @@
1
+ // src/session.ts
2
+ /** The tone a session's status shows in; a web host passes it to a status badge. */
3
+ function sessionStatusVariant(status) {
4
+ switch (status) {
5
+ case "running":
6
+ case "live_elsewhere": return "info";
7
+ case "awaiting_approval": return "warning";
8
+ default: return "muted";
9
+ }
10
+ }
11
+ export { sessionStatusVariant };
@@ -0,0 +1,140 @@
1
+ import { type ApprovalAnswerValue, type ApprovalPart, type ChatMessage, type MessagePart, type MessagePaste, type SubagentNotice, type TodoItem, type ToolDecision } from '@parallelworks/ui/ai/headless';
2
+ import type { PwCodeAllowedDirectory, PwCodeApprovalAnswer, PwCodeApprovalRequest, PwCodeGoalStatus, PwCodeHistoryItem, PwCodeImage, PwCodeSessionDetail, PwCodeSessionState, PwCodeSessionStatus, PwCodeGoalProgress, PwCodeStreamEvent, PwCodeToolDecision, PwCodeTurnEnd } from './types.js';
3
+ export interface TranscriptState {
4
+ messages: ChatMessage[];
5
+ streaming: ChatMessage | null;
6
+ cursor: number;
7
+ turnEnded: boolean;
8
+ queued: ChatMessage[];
9
+ steered: ChatMessage[];
10
+ notes: ChatMessage[];
11
+ turnStartedAt: string | null;
12
+ opening?: string | null;
13
+ waitingForUsageLimit?: boolean;
14
+ usageLimitResumeAt?: string | null;
15
+ seededSeq?: number;
16
+ seededTerminal?: {
17
+ part: MessagePart;
18
+ turnId: string;
19
+ } | null;
20
+ stepStartedAt?: string | null;
21
+ thoughtStartedAt?: string | null;
22
+ reviews?: Record<string, string[]>;
23
+ decided?: string[];
24
+ turnEndSeq?: number;
25
+ }
26
+ export type StreamEffect = {
27
+ type: 'refetch';
28
+ } | {
29
+ type: 'cleared';
30
+ newId: string;
31
+ } | {
32
+ type: 'state';
33
+ state: PwCodeSessionState;
34
+ } | {
35
+ type: 'notice';
36
+ text: string;
37
+ warn: boolean;
38
+ };
39
+ /** Where the host serves the full-size image a preview's ref names. */
40
+ export type ImageUrl = (ref: string) => string;
41
+ /** The daemon emits nothing for a `!` run, so the page that ran it shows it. */
42
+ export declare function appendShellRun(state: TranscriptState, command: string, output: string): TranscriptState;
43
+ export declare function approvalToPart(req: PwCodeApprovalRequest, words?: Pick<TranscriptWords, 'allowDirectory'>): ApprovalPart;
44
+ export declare function approvalAnswerBody(answer: ApprovalAnswerValue): PwCodeApprovalAnswer;
45
+ /** A review still under way, or one the turn cut short, settled nothing. */
46
+ export declare function toolDecision(d: PwCodeToolDecision): ToolDecision | null;
47
+ /** Ids come from the item's position, so a refetch keeps message identity and
48
+ * React does not remount (and collapse) the whole transcript. */
49
+ export declare function historyToMessages(history: PwCodeHistoryItem[], options?: {
50
+ finalizeOpen?: boolean;
51
+ goalNotice?: GoalNotice | undefined;
52
+ compactionNotice?: CompactionNotice | undefined;
53
+ recapNotice?: RecapNotice | undefined;
54
+ words?: TranscriptWords | undefined;
55
+ imageUrl?: ImageUrl | undefined;
56
+ }): ChatMessage[];
57
+ /** A session with no history resumes from the start: the daemon stamps a seq
58
+ * before the agent records it, so a prompt sent with `create` falls in that
59
+ * window, and replaying a session that seeded nothing can duplicate nothing. */
60
+ export declare function resumeCursor(detail: PwCodeSessionDetail): number;
61
+ export declare function initialTranscript(detail: PwCodeSessionDetail, options?: {
62
+ goalNotice?: GoalNotice | undefined;
63
+ compactionNotice?: CompactionNotice | undefined;
64
+ recapNotice?: RecapNotice | undefined;
65
+ words?: TranscriptWords | undefined;
66
+ imageUrl?: ImageUrl | undefined;
67
+ }): TranscriptState;
68
+ /** The approvals the live feed is still waiting on. */
69
+ export declare function pendingApprovals(transcript: TranscriptState): ApprovalPart[];
70
+ /** Status as the live feed shows it; `detail.status` is only the fetch moment. */
71
+ export declare function liveSessionStatus(status: PwCodeSessionStatus, transcript: TranscriptState | null, goal?: PwCodeGoalStatus): PwCodeSessionStatus;
72
+ export declare function resolveApprovalEverywhere(state: TranscriptState, id: string): TranscriptState;
73
+ /** The daemon queues a message sent mid-turn rather than cutting the turn
74
+ * short, so the page must not close the turn either: its open tool calls
75
+ * would read as interrupted while they are still running. */
76
+ export declare function appendOwnMessage(state: TranscriptState, text: string, id?: string, pastes?: MessagePaste[], previews?: PwCodeImage[]): TranscriptState;
77
+ /** Held apart until the daemon reports the model was handed it. */
78
+ export declare function appendSteeredMessage(state: TranscriptState, text: string, id?: string, pastes?: MessagePaste[], previews?: PwCodeImage[]): TranscriptState;
79
+ /** The daemon queued a message this page had shown as sent, because the turn
80
+ * ahead of it had not reached the page yet. */
81
+ export declare function markQueued(state: TranscriptState, id: string): TranscriptState;
82
+ /** Left in place, a message the machine refused reads as one the session received. */
83
+ export declare function dropMessage(state: TranscriptState, id: string): TranscriptState;
84
+ /** Everything sent that the transcript has not placed yet, in the order it
85
+ * will be read: handed to the model, then steered, then turns of their own. */
86
+ export declare function pendingMessages(state: TranscriptState): ChatMessage[];
87
+ /** A turn runs before it streams anything, and after it is handed a note. */
88
+ export declare function turnRunning(state: TranscriptState | null): boolean;
89
+ /** Whether the turn waits on a Bash call, which the machine can move to the background. */
90
+ export declare function bashRunning(state: TranscriptState | null): boolean;
91
+ /** What the agent records for a call a stop cut off (serverapi.UserInterruptedTool), so a stopped call reads live as it replays. */
92
+ export declare function userInterruptedTool(name: string): string;
93
+ /** TodoWrite's whole list, which its arguments carry; null when they hold none. */
94
+ export declare function todosFromArgs(argsJSON: string): TodoItem[] | null;
95
+ /** How a /goal loop step reads, in the reader's language. */
96
+ export type GoalNotice = (progress: PwCodeGoalProgress) => string;
97
+ /** How a compaction's line reads, in the reader's language; its summary opens under it. */
98
+ export interface CompactionNotice {
99
+ command: string;
100
+ automatic: string;
101
+ }
102
+ /** How the recap written while the reader was away reads, in their language. */
103
+ export type RecapNotice = (recap: string) => string;
104
+ export declare const TURN_VERBS: readonly ['baked', 'brewed', 'churned', 'cogitated', 'cooked', 'crunched', 'sauteed', 'worked'];
105
+ export type TurnVerb = (typeof TURN_VERBS)[number];
106
+ /** The rest of a session's lines in the reader's language. */
107
+ export interface TranscriptWords {
108
+ /** What a continuing /goal step opens to: its goal and why it isn't met; null when it has no reason. */
109
+ goalDetail: (progress: PwCodeGoalProgress) => string | null;
110
+ /** The line a turn nobody stopped ends with; `waiting` while it waits on background agents. */
111
+ turnEnd: (turnEnd: PwCodeTurnEnd, verb: TurnVerb, waiting: boolean) => string;
112
+ /** The plan file a /plan showed, under the command; `opened` when /plan open put it in an editor. */
113
+ planAnswer: (path: string, opened: boolean) => string;
114
+ /** The line a background subagent's or command's report enters the conversation with. */
115
+ deliveryLine: (notice: SubagentNotice) => string;
116
+ /** An approval's option that opens the directory it names for the session. */
117
+ allowDirectory: (dir: PwCodeAllowedDirectory) => string;
118
+ }
119
+ /** The verb the terminal picks for a turn, so the same turn reads the same in both. */
120
+ export declare function turnVerb(endedAt: string): TurnVerb;
121
+ /** How many of the main conversation's calls the auto-reviewer is deciding on. */
122
+ export declare function reviewingCount(state: TranscriptState | null): number;
123
+ /** Out-of-band frames are classified before seq dedupe, as the TUI does. */
124
+ export declare function applyStreamEvent(state: TranscriptState, ev: PwCodeStreamEvent, options?: {
125
+ ownTurnIds?: ReadonlySet<string>;
126
+ ownTexts?: ReadonlySet<string>;
127
+ /** The clock a turn opened by a frame is dated with. */
128
+ now?: () => string;
129
+ /** The session this transcript shows, to tell its own start in the feed. */
130
+ sessionId?: string | undefined;
131
+ /** The own message this user_message or user_note echoes, when known. */
132
+ echoOf?: string | undefined;
133
+ goalNotice?: GoalNotice | undefined;
134
+ recapNotice?: RecapNotice | undefined;
135
+ words?: TranscriptWords | undefined;
136
+ imageUrl?: ImageUrl | undefined;
137
+ }): {
138
+ state: TranscriptState;
139
+ effects: StreamEffect[];
140
+ };