@parallelworks/code 0.0.0-stage → 0.2.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 +202 -0
- package/README.md +205 -2
- package/dist/api.d.ts +3469 -0
- package/dist/apiClient.d.ts +26 -0
- package/dist/apiClient.js +5 -0
- package/dist/claudeApi.d.ts +27 -0
- package/dist/claudeApi.js +250 -0
- package/dist/command.d.ts +47 -0
- package/dist/command.js +64 -0
- package/dist/commandsApi.d.ts +64 -0
- package/dist/commandsApi.js +267 -0
- package/dist/createPwCodeApi.d.ts +688 -0
- package/dist/createPwCodeApi.js +31 -0
- package/dist/images.d.ts +7 -0
- package/dist/images.js +22 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +18 -0
- package/dist/locales/en/agentTranscript.js +170 -0
- package/dist/locales/en/agents.js +380 -0
- package/dist/locales/en.d.ts +531 -0
- package/dist/locales/en.js +8 -0
- package/dist/locales/es/agentTranscript.js +170 -0
- package/dist/locales/es/agents.js +380 -0
- package/dist/locales/es.d.ts +3 -0
- package/dist/locales/es.js +8 -0
- package/dist/locales/ja/agentTranscript.js +170 -0
- package/dist/locales/ja/agents.js +380 -0
- package/dist/locales/ja.d.ts +3 -0
- package/dist/locales/ja.js +8 -0
- package/dist/locales/ko/agentTranscript.js +170 -0
- package/dist/locales/ko/agents.js +380 -0
- package/dist/locales/ko.d.ts +3 -0
- package/dist/locales/ko.js +8 -0
- package/dist/locales/zh/agentTranscript.js +170 -0
- package/dist/locales/zh/agents.js +380 -0
- package/dist/locales/zh.d.ts +3 -0
- package/dist/locales/zh.js +8 -0
- package/dist/machine.d.ts +49 -0
- package/dist/machine.js +60 -0
- package/dist/messages.d.ts +17 -0
- package/dist/messages.js +31 -0
- package/dist/notices.d.ts +11 -0
- package/dist/notices.js +94 -0
- package/dist/pullRequest.d.ts +8 -0
- package/dist/pullRequest.js +29 -0
- package/dist/query.d.ts +28 -0
- package/dist/query.js +25 -0
- package/dist/session.d.ts +72 -0
- package/dist/session.js +111 -0
- package/dist/sessionEvents.d.ts +27 -0
- package/dist/sessionEvents.js +212 -0
- package/dist/sessionsApi.d.ts +105 -0
- package/dist/sessionsApi.js +513 -0
- package/dist/toolStrings.d.ts +4 -0
- package/dist/toolStrings.js +95 -0
- package/dist/transcript.d.ts +151 -0
- package/dist/transcript.js +1315 -0
- package/dist/types.d.ts +234 -0
- package/dist/useTranscript.d.ts +63 -0
- package/dist/useTranscript.js +243 -0
- package/dist/wording.d.ts +43 -0
- package/dist/wording.js +101 -0
- package/locales/en/agentTranscript.json +162 -0
- package/locales/en/agents.json +366 -0
- package/locales/es/agentTranscript.json +162 -0
- package/locales/es/agents.json +366 -0
- package/locales/ja/agentTranscript.json +162 -0
- package/locales/ja/agents.json +366 -0
- package/locales/ko/agentTranscript.json +162 -0
- package/locales/ko/agents.json +366 -0
- package/locales/zh/agentTranscript.json +162 -0
- package/locales/zh/agents.json +366 -0
- package/package.json +68 -3
|
@@ -0,0 +1,151 @@
|
|
|
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, PwCodeSubagentDetail, 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
|
+
/** A subagent's detail as the session detail its transcript seeds from. Its run
|
|
69
|
+
* has no turn id on the wire, so its own id names the one in flight. */
|
|
70
|
+
export declare function subagentSessionDetail(sub: PwCodeSubagentDetail): PwCodeSessionDetail;
|
|
71
|
+
/** A session frame as one subagent's transcript reads it. A turn someone
|
|
72
|
+
* prompted on the subagent streams under its id, and a note it was handed
|
|
73
|
+
* arrives as its own event; the task it was given streams nothing, so a frame
|
|
74
|
+
* that only says it moved on is `refetch`. Null is a frame for someone else. */
|
|
75
|
+
export declare function subagentFrame(ev: PwCodeStreamEvent, id: string): PwCodeStreamEvent | 'refetch' | null;
|
|
76
|
+
/** The approvals the live feed is still waiting on. */
|
|
77
|
+
export declare function pendingApprovals(transcript: TranscriptState): ApprovalPart[];
|
|
78
|
+
/** Status as the live feed shows it; `detail.status` is only the fetch moment. */
|
|
79
|
+
export declare function liveSessionStatus(status: PwCodeSessionStatus, transcript: TranscriptState | null, goal?: PwCodeGoalStatus): PwCodeSessionStatus;
|
|
80
|
+
export declare function resolveApprovalEverywhere(state: TranscriptState, id: string): TranscriptState;
|
|
81
|
+
/** The daemon queues a message sent mid-turn rather than cutting the turn
|
|
82
|
+
* short, so the page must not close the turn either: its open tool calls
|
|
83
|
+
* would read as interrupted while they are still running. */
|
|
84
|
+
export declare function appendOwnMessage(state: TranscriptState, text: string, id?: string, pastes?: MessagePaste[], previews?: PwCodeImage[]): TranscriptState;
|
|
85
|
+
/** A subagent runs one turn at a time, so a message sent to it starts its next:
|
|
86
|
+
* a turn the transcript still shows running has ended. */
|
|
87
|
+
export declare function appendTurnMessage(state: TranscriptState, text: string, id?: string, pastes?: MessagePaste[], previews?: PwCodeImage[]): TranscriptState;
|
|
88
|
+
/** Held apart until the daemon reports the model was handed it. */
|
|
89
|
+
export declare function appendSteeredMessage(state: TranscriptState, text: string, id?: string, pastes?: MessagePaste[], previews?: PwCodeImage[]): TranscriptState;
|
|
90
|
+
/** The daemon queued a message this page had shown as sent, because the turn
|
|
91
|
+
* ahead of it had not reached the page yet. */
|
|
92
|
+
export declare function markQueued(state: TranscriptState, id: string): TranscriptState;
|
|
93
|
+
/** Left in place, a message the machine refused reads as one the session received. */
|
|
94
|
+
export declare function dropMessage(state: TranscriptState, id: string): TranscriptState;
|
|
95
|
+
/** Everything sent that the transcript has not placed yet, in the order it
|
|
96
|
+
* will be read: handed to the model, then steered, then turns of their own. */
|
|
97
|
+
export declare function pendingMessages(state: TranscriptState): ChatMessage[];
|
|
98
|
+
/** A turn runs before it streams anything, and after it is handed a note. */
|
|
99
|
+
export declare function turnRunning(state: TranscriptState | null): boolean;
|
|
100
|
+
/** Whether the turn waits on a Bash call, which the machine can move to the background. */
|
|
101
|
+
export declare function bashRunning(state: TranscriptState | null): boolean;
|
|
102
|
+
/** What the agent records for a call a stop cut off (serverapi.UserInterruptedTool), so a stopped call reads live as it replays. */
|
|
103
|
+
export declare function userInterruptedTool(name: string): string;
|
|
104
|
+
/** TodoWrite's whole list, which its arguments carry; null when they hold none. */
|
|
105
|
+
export declare function todosFromArgs(argsJSON: string): TodoItem[] | null;
|
|
106
|
+
/** How a /goal loop step reads, in the reader's language. */
|
|
107
|
+
export type GoalNotice = (progress: PwCodeGoalProgress) => string;
|
|
108
|
+
/** How a compaction's line reads, in the reader's language; its summary opens under it. */
|
|
109
|
+
export interface CompactionNotice {
|
|
110
|
+
command: string;
|
|
111
|
+
automatic: string;
|
|
112
|
+
}
|
|
113
|
+
/** How the recap written while the reader was away reads, in their language. */
|
|
114
|
+
export type RecapNotice = (recap: string) => string;
|
|
115
|
+
export declare const TURN_VERBS: readonly ['baked', 'brewed', 'churned', 'cogitated', 'cooked', 'crunched', 'sauteed', 'worked'];
|
|
116
|
+
export type TurnVerb = (typeof TURN_VERBS)[number];
|
|
117
|
+
/** The rest of a session's lines in the reader's language. */
|
|
118
|
+
export interface TranscriptWords {
|
|
119
|
+
/** What a continuing /goal step opens to: its goal and why it isn't met; null when it has no reason. */
|
|
120
|
+
goalDetail: (progress: PwCodeGoalProgress) => string | null;
|
|
121
|
+
/** The line a turn nobody stopped ends with; `waiting` while it waits on background agents. */
|
|
122
|
+
turnEnd: (turnEnd: PwCodeTurnEnd, verb: TurnVerb, waiting: boolean) => string;
|
|
123
|
+
/** The plan file a /plan showed, under the command; `opened` when /plan open put it in an editor. */
|
|
124
|
+
planAnswer: (path: string, opened: boolean) => string;
|
|
125
|
+
/** The line a background subagent's or command's report enters the conversation with. */
|
|
126
|
+
deliveryLine: (notice: SubagentNotice) => string;
|
|
127
|
+
/** An approval's option that opens the directory it names for the session. */
|
|
128
|
+
allowDirectory: (dir: PwCodeAllowedDirectory) => string;
|
|
129
|
+
}
|
|
130
|
+
/** The verb the terminal picks for a turn, so the same turn reads the same in both. */
|
|
131
|
+
export declare function turnVerb(endedAt: string): TurnVerb;
|
|
132
|
+
/** How many of the main conversation's calls the auto-reviewer is deciding on. */
|
|
133
|
+
export declare function reviewingCount(state: TranscriptState | null): number;
|
|
134
|
+
/** Out-of-band frames are classified before seq dedupe, as the TUI does. */
|
|
135
|
+
export declare function applyStreamEvent(state: TranscriptState, ev: PwCodeStreamEvent, options?: {
|
|
136
|
+
ownTurnIds?: ReadonlySet<string>;
|
|
137
|
+
ownTexts?: ReadonlySet<string>;
|
|
138
|
+
/** The clock a turn opened by a frame is dated with. */
|
|
139
|
+
now?: () => string;
|
|
140
|
+
/** The session this transcript shows, to tell its own start in the feed. */
|
|
141
|
+
sessionId?: string | undefined;
|
|
142
|
+
/** The own message this user_message or user_note echoes, when known. */
|
|
143
|
+
echoOf?: string | undefined;
|
|
144
|
+
goalNotice?: GoalNotice | undefined;
|
|
145
|
+
recapNotice?: RecapNotice | undefined;
|
|
146
|
+
words?: TranscriptWords | undefined;
|
|
147
|
+
imageUrl?: ImageUrl | undefined;
|
|
148
|
+
}): {
|
|
149
|
+
state: TranscriptState;
|
|
150
|
+
effects: StreamEffect[];
|
|
151
|
+
};
|