@parallelworks/code 0.1.0 → 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/README.md +138 -24
- 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/index.d.ts +16 -3
- package/dist/index.js +16 -3
- 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 +70 -1
- package/dist/session.js +101 -1
- 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 +12 -1
- package/dist/transcript.js +40 -2
- package/dist/types.d.ts +20 -1
- package/dist/useTranscript.d.ts +4 -1
- package/dist/useTranscript.js +54 -11
- 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 +23 -8
package/dist/transcript.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { INTERRUPTED_NOTICE, applyPartDelta, askQuestionsFromArgs, classifyPseudoUserMessage, finalizeParts, firstNonEmptyLine, hiddenTranscriptTool, interruptionNotice, parseSubagentNotice, planFromArgs, resultFailed, subagentDeliveryLine, taskCallFromArgs } from "@parallelworks/ui/ai/headless";
|
|
2
1
|
import { DateTime } from "luxon";
|
|
2
|
+
import { INTERRUPTED_NOTICE, applyPartDelta, askQuestionsFromArgs, classifyPseudoUserMessage, finalizeParts, firstNonEmptyLine, hiddenTranscriptTool, interruptionNotice, parseSubagentNotice, planFromArgs, resultFailed, subagentDeliveryLine, taskCallFromArgs } from "@parallelworks/ui/ai/headless";
|
|
3
3
|
// src/transcript.ts
|
|
4
4
|
var MAIN_SESSION_AUTHOR = {
|
|
5
5
|
id: "main",
|
|
@@ -500,6 +500,34 @@ function initialTranscript(detail, options = {}) {
|
|
|
500
500
|
seededSeq: detail.lastSeq ?? 0
|
|
501
501
|
};
|
|
502
502
|
}
|
|
503
|
+
/** A subagent's detail as the session detail its transcript seeds from. Its run
|
|
504
|
+
* has no turn id on the wire, so its own id names the one in flight. */
|
|
505
|
+
function subagentSessionDetail(sub) {
|
|
506
|
+
const running = sub.status === "running";
|
|
507
|
+
return {
|
|
508
|
+
status: sub.approvals?.length ? "awaiting_approval" : running ? "running" : "idle",
|
|
509
|
+
history: sub.history ?? [],
|
|
510
|
+
approvals: sub.approvals ?? [],
|
|
511
|
+
lastSeq: sub.lastSeq ?? 0,
|
|
512
|
+
...running ? { turnId: sub.id } : {},
|
|
513
|
+
...running && sub.startedAt ? { turnStartedAt: sub.startedAt } : {}
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
/** A session frame as one subagent's transcript reads it. A turn someone
|
|
517
|
+
* prompted on the subagent streams under its id, and a note it was handed
|
|
518
|
+
* arrives as its own event; the task it was given streams nothing, so a frame
|
|
519
|
+
* that only says it moved on is `refetch`. Null is a frame for someone else. */
|
|
520
|
+
function subagentFrame(ev, id) {
|
|
521
|
+
if (ev.type === "replay_truncated" || ev.type === "approval_resolved") return ev;
|
|
522
|
+
if (ev.type === "approval_request") return ev.approval?.subagentId === id ? ev : null;
|
|
523
|
+
if (ev.id !== id || ev.seq === 0) return null;
|
|
524
|
+
const { id: _, ...frame } = ev;
|
|
525
|
+
if (ev.type === "subagent_user_note") return {
|
|
526
|
+
...frame,
|
|
527
|
+
type: "user_note"
|
|
528
|
+
};
|
|
529
|
+
return ev.type.startsWith("subagent_") ? "refetch" : frame;
|
|
530
|
+
}
|
|
503
531
|
/** The approvals the live feed is still waiting on. */
|
|
504
532
|
function pendingApprovals(transcript) {
|
|
505
533
|
return (transcript.streaming?.parts ?? []).filter((p) => p.kind === "approval" && !p.resolved);
|
|
@@ -560,6 +588,11 @@ function appendOwnMessage(state, text, id, pastes, previews) {
|
|
|
560
588
|
opening: message.id
|
|
561
589
|
};
|
|
562
590
|
}
|
|
591
|
+
/** A subagent runs one turn at a time, so a message sent to it starts its next:
|
|
592
|
+
* a turn the transcript still shows running has ended. */
|
|
593
|
+
function appendTurnMessage(state, text, id, pastes, previews) {
|
|
594
|
+
return appendOwnMessage(finishTurn(state), text, id, pastes, previews);
|
|
595
|
+
}
|
|
563
596
|
/** An own message takes the pastes and images its echo says the model received. */
|
|
564
597
|
function withSentPastesAndImages(messages, ev, id, imageUrl) {
|
|
565
598
|
const pastes = ev.pastes?.length ? ev.pastes : null;
|
|
@@ -1048,6 +1081,10 @@ function placeNotes(state) {
|
|
|
1048
1081
|
streaming: null
|
|
1049
1082
|
};
|
|
1050
1083
|
}
|
|
1084
|
+
function onlyAnsweredApprovals(message) {
|
|
1085
|
+
const parts = message?.parts ?? [];
|
|
1086
|
+
return parts.length > 0 && parts.every((p) => p.kind === "approval" && p.resolved);
|
|
1087
|
+
}
|
|
1051
1088
|
var OUTPUT_EVENTS = /* @__PURE__ */ new Set([
|
|
1052
1089
|
"chunk",
|
|
1053
1090
|
"reasoning",
|
|
@@ -1232,6 +1269,7 @@ function applyStreamEvent(state, ev, options = {}) {
|
|
|
1232
1269
|
break;
|
|
1233
1270
|
case "approval_resolved":
|
|
1234
1271
|
if (ev.approvalId) next = resolveApprovalEverywhere(next, ev.approvalId);
|
|
1272
|
+
if (next.turnEnded && onlyAnsweredApprovals(next.streaming)) next = finishTurn(next);
|
|
1235
1273
|
break;
|
|
1236
1274
|
case "usage_limit_wait":
|
|
1237
1275
|
next = {
|
|
@@ -1274,4 +1312,4 @@ function applyStreamEvent(state, ev, options = {}) {
|
|
|
1274
1312
|
effects: controlEffects(ev)
|
|
1275
1313
|
};
|
|
1276
1314
|
}
|
|
1277
|
-
export { TURN_VERBS, appendOwnMessage, appendShellRun, appendSteeredMessage, applyStreamEvent, approvalAnswerBody, approvalToPart, bashRunning, dropMessage, historyToMessages, initialTranscript, liveSessionStatus, markQueued, pendingApprovals, pendingMessages, resolveApprovalEverywhere, resumeCursor, reviewingCount, todosFromArgs, toolDecision, turnRunning, turnVerb, userInterruptedTool };
|
|
1315
|
+
export { TURN_VERBS, appendOwnMessage, appendShellRun, appendSteeredMessage, appendTurnMessage, applyStreamEvent, approvalAnswerBody, approvalToPart, bashRunning, dropMessage, historyToMessages, initialTranscript, liveSessionStatus, markQueued, pendingApprovals, pendingMessages, resolveApprovalEverywhere, resumeCursor, reviewingCount, subagentFrame, subagentSessionDetail, todosFromArgs, toolDecision, turnRunning, turnVerb, userInterruptedTool };
|
package/dist/types.d.ts
CHANGED
|
@@ -110,7 +110,7 @@ export interface PwCodeSessionState {
|
|
|
110
110
|
model: string;
|
|
111
111
|
/** The names to show in place of model IDs; an ID it leaves out has none. */
|
|
112
112
|
modelNames?: Record<string, string>;
|
|
113
|
-
/**
|
|
113
|
+
/** A level on pw code's scale; empty from a daemon that predates it. */
|
|
114
114
|
effort?: string;
|
|
115
115
|
allocation?: string;
|
|
116
116
|
permissionMode?: string;
|
|
@@ -126,6 +126,14 @@ export interface PwCodeSessionState {
|
|
|
126
126
|
allowedDirs?: PwCodeAllowedDirectory[] | null;
|
|
127
127
|
/** The session's directory in the git worktree it moved into; unset while it works where it launched. */
|
|
128
128
|
worktree?: string;
|
|
129
|
+
/** Each subagent's own tokens, by its id; one that has used none is left out. */
|
|
130
|
+
subagentUsage?: Record<string, PwCodeSubagentUsage>;
|
|
131
|
+
}
|
|
132
|
+
export interface PwCodeSubagentUsage {
|
|
133
|
+
inputTokens?: number;
|
|
134
|
+
outputTokens?: number;
|
|
135
|
+
/** Its latest request's input, cached tokens included. */
|
|
136
|
+
latestInputTokens?: number;
|
|
129
137
|
}
|
|
130
138
|
/** Where a session's /goal loop stands; unset when it has no goal. */
|
|
131
139
|
export interface PwCodeGoalStatus {
|
|
@@ -204,6 +212,17 @@ export interface PwCodeSessionDetail {
|
|
|
204
212
|
addDirs?: PwCodeAddedDirectory[] | null;
|
|
205
213
|
allowedDirs?: PwCodeAllowedDirectory[] | null;
|
|
206
214
|
}
|
|
215
|
+
/** A subagent's transcript, read at lastSeq of its session's feed. */
|
|
216
|
+
export interface PwCodeSubagentDetail {
|
|
217
|
+
id: string;
|
|
218
|
+
status: 'running' | 'done' | 'failed' | 'stopped';
|
|
219
|
+
/** When its latest run began: the task it was given, or a turn someone prompted on it. */
|
|
220
|
+
startedAt?: string;
|
|
221
|
+
history?: PwCodeHistoryItem[] | null;
|
|
222
|
+
/** The approvals it is waiting on. */
|
|
223
|
+
approvals?: PwCodeApprovalRequest[] | null;
|
|
224
|
+
lastSeq?: number;
|
|
225
|
+
}
|
|
207
226
|
/** The body the daemon accepts as the answer to an approval. */
|
|
208
227
|
export interface PwCodeApprovalAnswer {
|
|
209
228
|
allowed?: boolean;
|
package/dist/useTranscript.d.ts
CHANGED
|
@@ -27,9 +27,12 @@ interface SendOptions {
|
|
|
27
27
|
}
|
|
28
28
|
/** Holds the live transcript for one session. The host still owns the socket
|
|
29
29
|
* and the fetch: it feeds events to `onEvent` and posts through `send`. */
|
|
30
|
-
export declare function usePwCodeTranscript({ sessionId, detail, send, steer, withdraw, onEffect, goalNotice, compactionNotice, recapNotice, words, imageUrl, }: {
|
|
30
|
+
export declare function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdraw, onEffect, goalNotice, compactionNotice, recapNotice, words, imageUrl, }: {
|
|
31
31
|
/** The session shown, so frames from the conversation it cleared are dropped. */
|
|
32
32
|
sessionId?: string | undefined;
|
|
33
|
+
/** Shows this subagent's conversation instead of the main one: the frames
|
|
34
|
+
* are still the session's, and `detail`, `send` and `steer` are the subagent's. */
|
|
35
|
+
subagent?: string | undefined;
|
|
33
36
|
detail: PwCodeSessionDetail | undefined;
|
|
34
37
|
send: (text: string, pastes?: MessagePaste[], images?: PwCodeImageRef[]) => Promise<PwCodeSendResult>;
|
|
35
38
|
/** Hands text to the running turn, as typing into a busy terminal does. */
|
package/dist/useTranscript.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { appendOwnMessage, appendShellRun, appendSteeredMessage, applyStreamEvent, dropMessage, initialTranscript, markQueued, pendingMessages, resolveApprovalEverywhere, turnRunning } from "./transcript.js";
|
|
1
|
+
import { appendOwnMessage, appendShellRun, appendSteeredMessage, appendTurnMessage, applyStreamEvent, dropMessage, initialTranscript, markQueued, pendingMessages, resolveApprovalEverywhere, subagentFrame, turnRunning } from "./transcript.js";
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
3
|
// src/useTranscript.ts
|
|
4
4
|
var MAX_REPLAY_FRAMES = 5e3;
|
|
5
|
+
function keepForSeed(frames, ev) {
|
|
6
|
+
frames.push(ev);
|
|
7
|
+
if (frames.length > MAX_REPLAY_FRAMES) frames.shift();
|
|
8
|
+
}
|
|
5
9
|
/** Matches the way the echo is recognised: by turn once the send has named it,
|
|
6
10
|
* by text before then. */
|
|
7
11
|
function echoedSend(unechoed, ev) {
|
|
@@ -19,9 +23,18 @@ function forgetSettled(unechoed, before, after) {
|
|
|
19
23
|
const still = new Set(pendingMessages(after).map((m) => m.id));
|
|
20
24
|
for (const m of pendingMessages(before)) if (!still.has(m.id)) unechoed.delete(m.id);
|
|
21
25
|
}
|
|
26
|
+
/** A turn prompted on a subagent echoes no user_message, so its history places
|
|
27
|
+
* the message: once it reaches the turn's first frame, or ends on the same words. */
|
|
28
|
+
function forgetPlaced(unechoed, detail) {
|
|
29
|
+
const last = detail.history?.findLast((h) => h.kind === "user" && !h.fromMain)?.text;
|
|
30
|
+
for (const [localId, sent] of unechoed) {
|
|
31
|
+
const reached = sent.placedSeq !== void 0 && (detail.lastSeq ?? 0) >= sent.placedSeq;
|
|
32
|
+
if (!sent.steered && (reached || sent.text === last)) unechoed.delete(localId);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
22
35
|
/** Holds the live transcript for one session. The host still owns the socket
|
|
23
36
|
* and the fetch: it feeds events to `onEvent` and posts through `send`. */
|
|
24
|
-
function usePwCodeTranscript({ sessionId, detail, send, steer, withdraw, onEffect, goalNotice, compactionNotice, recapNotice, words, imageUrl }) {
|
|
37
|
+
function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdraw, onEffect, goalNotice, compactionNotice, recapNotice, words, imageUrl }) {
|
|
25
38
|
const [transcript, setTranscript] = useState(null);
|
|
26
39
|
const transcriptRef = useRef(null);
|
|
27
40
|
const [sending, setSending] = useState(false);
|
|
@@ -56,6 +69,7 @@ function usePwCodeTranscript({ sessionId, detail, send, steer, withdraw, onEffec
|
|
|
56
69
|
onEffectRef.current({ type: "refetch" });
|
|
57
70
|
return;
|
|
58
71
|
}
|
|
72
|
+
if (subagent) forgetPlaced(unechoed.current, detail);
|
|
59
73
|
let next = initialTranscript(detail, {
|
|
60
74
|
goalNotice: goalNoticeRef.current,
|
|
61
75
|
compactionNotice: compactionNoticeRef.current,
|
|
@@ -63,6 +77,12 @@ function usePwCodeTranscript({ sessionId, detail, send, steer, withdraw, onEffec
|
|
|
63
77
|
words: wordsRef.current,
|
|
64
78
|
imageUrl: imageUrlRef.current
|
|
65
79
|
});
|
|
80
|
+
if (subagent) {
|
|
81
|
+
for (const [localId, sent] of unechoed.current) if (!sent.steered) {
|
|
82
|
+
const { text, pastes, previews } = sent;
|
|
83
|
+
next = appendTurnMessage(next, text, localId, pastes, previews);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
66
86
|
const replay = appliedSinceSeed.current.filter((ev) => ev.seq > (lastSeq ?? 0));
|
|
67
87
|
appliedSinceSeed.current = replay;
|
|
68
88
|
for (const ev of replay) next = applyStreamEvent(next, ev, {
|
|
@@ -73,7 +93,8 @@ function usePwCodeTranscript({ sessionId, detail, send, steer, withdraw, onEffec
|
|
|
73
93
|
}).state;
|
|
74
94
|
for (const [localId, sent] of unechoed.current) {
|
|
75
95
|
const { text, pastes, previews, steered } = sent;
|
|
76
|
-
|
|
96
|
+
if (steered) next = appendSteeredMessage(next, text, localId, pastes, previews);
|
|
97
|
+
else if (!subagent) next = appendOwnMessage(next, text, localId, pastes, previews);
|
|
77
98
|
}
|
|
78
99
|
const cursor = Math.max(next.cursor, transcriptRef.current?.cursor ?? 0);
|
|
79
100
|
next = cursor === next.cursor ? next : {
|
|
@@ -82,7 +103,7 @@ function usePwCodeTranscript({ sessionId, detail, send, steer, withdraw, onEffec
|
|
|
82
103
|
};
|
|
83
104
|
transcriptRef.current = next;
|
|
84
105
|
setTranscript(next);
|
|
85
|
-
}, [detail]);
|
|
106
|
+
}, [detail, subagent]);
|
|
86
107
|
const apply = useCallback((change) => {
|
|
87
108
|
const current = transcriptRef.current;
|
|
88
109
|
if (!current) return;
|
|
@@ -90,9 +111,21 @@ function usePwCodeTranscript({ sessionId, detail, send, steer, withdraw, onEffec
|
|
|
90
111
|
transcriptRef.current = next;
|
|
91
112
|
setTranscript(next);
|
|
92
113
|
}, []);
|
|
93
|
-
const onEvent = useCallback((
|
|
114
|
+
const onEvent = useCallback((frame) => {
|
|
115
|
+
const ev = subagent ? subagentFrame(frame, subagent) : frame;
|
|
116
|
+
if (ev === "refetch") {
|
|
117
|
+
onEffectRef.current({ type: "refetch" });
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (!ev) return;
|
|
94
121
|
const current = transcriptRef.current;
|
|
95
|
-
if (!current)
|
|
122
|
+
if (!current) {
|
|
123
|
+
if (subagent) keepForSeed(appliedSinceSeed.current, ev);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (subagent && ev.turnId) {
|
|
127
|
+
for (const sent of unechoed.current.values()) if (sent.turnId === ev.turnId) sent.placedSeq ??= ev.seq;
|
|
128
|
+
}
|
|
96
129
|
const echoOf = echoedSend(unechoed.current, ev);
|
|
97
130
|
const { state, effects } = applyStreamEvent(current, ev, {
|
|
98
131
|
ownTurnIds: ownTurnIds.current,
|
|
@@ -106,14 +139,18 @@ function usePwCodeTranscript({ sessionId, detail, send, steer, withdraw, onEffec
|
|
|
106
139
|
});
|
|
107
140
|
if (ev.type === "replay_truncated") appliedSinceSeed.current = [];
|
|
108
141
|
else if (state.cursor > current.cursor) {
|
|
109
|
-
appliedSinceSeed.current
|
|
110
|
-
if (appliedSinceSeed.current.length > MAX_REPLAY_FRAMES) appliedSinceSeed.current.shift();
|
|
142
|
+
keepForSeed(appliedSinceSeed.current, ev);
|
|
111
143
|
if (echoOf) unechoed.current.delete(echoOf);
|
|
112
144
|
forgetSettled(unechoed.current, current, state);
|
|
113
145
|
}
|
|
114
146
|
apply(() => state);
|
|
115
147
|
for (const effect of effects) onEffectRef.current(effect);
|
|
116
|
-
|
|
148
|
+
if (subagent && frame.type === "subagent_user_note") onEffectRef.current({ type: "refetch" });
|
|
149
|
+
}, [
|
|
150
|
+
apply,
|
|
151
|
+
sessionId,
|
|
152
|
+
subagent
|
|
153
|
+
]);
|
|
117
154
|
/** True once the running turn took the text, or the refusal if it may have.
|
|
118
155
|
* Commands and shell escapes change the next turn, so like the TUI they wait. */
|
|
119
156
|
const trySteer = useCallback(async (text, { pastes, images, previews }) => {
|
|
@@ -150,13 +187,15 @@ function usePwCodeTranscript({ sessionId, detail, send, steer, withdraw, onEffec
|
|
|
150
187
|
pastes,
|
|
151
188
|
previews
|
|
152
189
|
});
|
|
153
|
-
|
|
190
|
+
const append = subagent ? appendTurnMessage : appendOwnMessage;
|
|
191
|
+
apply((state) => append(state, text, localId, pastes, previews));
|
|
154
192
|
const result = await sendRef.current(text, pastes, images);
|
|
155
193
|
setSending(false);
|
|
156
194
|
if ("error" in result) {
|
|
157
195
|
ownTexts.current.delete(text);
|
|
158
196
|
unechoed.current.delete(localId);
|
|
159
197
|
apply((state) => dropMessage(state, localId));
|
|
198
|
+
if (subagent) onEffectRef.current({ type: "refetch" });
|
|
160
199
|
return result.error;
|
|
161
200
|
}
|
|
162
201
|
if (result.queued && unechoed.current.has(localId)) apply((state) => markQueued(state, localId));
|
|
@@ -167,7 +206,11 @@ function usePwCodeTranscript({ sessionId, detail, send, steer, withdraw, onEffec
|
|
|
167
206
|
if (pending) pending.turnId = result.turnId;
|
|
168
207
|
}
|
|
169
208
|
return null;
|
|
170
|
-
}, [
|
|
209
|
+
}, [
|
|
210
|
+
apply,
|
|
211
|
+
trySteer,
|
|
212
|
+
subagent
|
|
213
|
+
]);
|
|
171
214
|
const resolveApproval = useCallback((approvalId) => apply((state) => resolveApprovalEverywhere(state, approvalId)), [apply]);
|
|
172
215
|
const noteShellRun = useCallback((command, output) => apply((state) => appendShellRun(state, command, output)), [apply]);
|
|
173
216
|
const queuedTurn = (id) => {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type PwCodeMachine } from './machine.js';
|
|
2
|
+
import type { PwCodeTranslator } from './messages.js';
|
|
3
|
+
import { type PwCodePendingApprovals, type PwCodeSession } from './session.js';
|
|
4
|
+
import type { PwCodeSessionStatus } from './types.js';
|
|
5
|
+
type Translate = PwCodeTranslator<'agents'>;
|
|
6
|
+
/** How a prompt refers to an image sent with it: `[Image #1]`. */
|
|
7
|
+
export declare const IMAGE_PLACEHOLDER: RegExp;
|
|
8
|
+
/** Mirrors the machine's preview of a first prompt, so the label does not
|
|
9
|
+
* change when the listed one arrives. */
|
|
10
|
+
export declare function rememberSentPrompt(machine: string, id: string, text: string): void;
|
|
11
|
+
/** The id is never a label: it is a timestamp the reader did not choose. */
|
|
12
|
+
export declare function sessionLabel(s: Pick<PwCodeSession, 'machineId' | 'id' | 'name' | 'autoName' | 'preview'>, t: Translate): string;
|
|
13
|
+
export declare function sessionStatusText(s: {
|
|
14
|
+
status: PwCodeSessionStatus;
|
|
15
|
+
liveHost?: string | undefined;
|
|
16
|
+
approvals?: PwCodePendingApprovals;
|
|
17
|
+
}, t: Translate): string;
|
|
18
|
+
/** A dropped machine outranks the session's own state. */
|
|
19
|
+
export declare function sessionStateText(s: Parameters<typeof sessionStatusText>[0], machine: Pick<PwCodeMachine, 'status'> | undefined, t: Translate): string;
|
|
20
|
+
export declare function machineHint(machine: Pick<PwCodeMachine, 'status' | 'error' | 'agentVersion'>, t: Translate): {
|
|
21
|
+
text: string;
|
|
22
|
+
detail?: string;
|
|
23
|
+
} | null;
|
|
24
|
+
export declare function composerState(args: {
|
|
25
|
+
unreachable: boolean;
|
|
26
|
+
/** Anything sent to an archived session would attach it, which restores it. */
|
|
27
|
+
archived: boolean;
|
|
28
|
+
machineName: string;
|
|
29
|
+
/** How long ago the transcript was last read, already abbreviated. */
|
|
30
|
+
staleFor: string;
|
|
31
|
+
status: PwCodeSessionStatus | null;
|
|
32
|
+
liveHost: string | undefined;
|
|
33
|
+
/** What the session is waiting on while it awaits approval. */
|
|
34
|
+
approvals?: PwCodePendingApprovals;
|
|
35
|
+
/** The `!` command this client is running on the machine, if any. */
|
|
36
|
+
shellRun?: string | undefined;
|
|
37
|
+
t: Translate;
|
|
38
|
+
}): {
|
|
39
|
+
placeholder: string;
|
|
40
|
+
hint: string;
|
|
41
|
+
locked: boolean;
|
|
42
|
+
};
|
|
43
|
+
export {};
|
package/dist/wording.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { isMachineDown } from "./machine.js";
|
|
2
|
+
import { sessionKey, waitsOnAnswer } from "./session.js";
|
|
3
|
+
import { nameToEmoji } from "gemoji";
|
|
4
|
+
// src/wording.ts
|
|
5
|
+
/** How a prompt refers to an image sent with it: `[Image #1]`. */
|
|
6
|
+
var IMAGE_PLACEHOLDER = /\[Image #(\d+)\]/g;
|
|
7
|
+
var sentPreviews = /* @__PURE__ */ new Map();
|
|
8
|
+
var PREVIEW_MAX = 80;
|
|
9
|
+
/** Mirrors the machine's preview of a first prompt, so the label does not
|
|
10
|
+
* change when the listed one arrives. */
|
|
11
|
+
function rememberSentPrompt(machine, id, text) {
|
|
12
|
+
const words = (text.replace(IMAGE_PLACEHOLDER, "").trim() || text).split(/\s+/).filter(Boolean).join(" ");
|
|
13
|
+
if (words) sentPreviews.set(sessionKey({
|
|
14
|
+
machineId: machine,
|
|
15
|
+
id
|
|
16
|
+
}), words.length > PREVIEW_MAX ? `${words.slice(0, PREVIEW_MAX)}...` : words);
|
|
17
|
+
}
|
|
18
|
+
/** The id is never a label: it is a timestamp the reader did not choose. */
|
|
19
|
+
function sessionLabel(s, t) {
|
|
20
|
+
return (s.name || s.autoName || s.preview || sentPreviews.get(sessionKey(s)) || t("sidebar.untitled")).replace(/:([\w+-]+):/g, (match, name) => {
|
|
21
|
+
const key = name.toLowerCase();
|
|
22
|
+
return Object.hasOwn(nameToEmoji, key) ? nameToEmoji[key] ?? match : match;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function sessionStatusText(s, t) {
|
|
26
|
+
if (s.status === "awaiting_approval" && waitsOnAnswer(s.approvals)) return t("status.awaiting_answer");
|
|
27
|
+
return t(`status.${s.status}`, { host: s.liveHost ?? "" });
|
|
28
|
+
}
|
|
29
|
+
var DOWN_STATUSES = [
|
|
30
|
+
"no_daemon",
|
|
31
|
+
"no_agent",
|
|
32
|
+
"unreachable",
|
|
33
|
+
"unsupported_agent"
|
|
34
|
+
];
|
|
35
|
+
function isDownStatus(status) {
|
|
36
|
+
return DOWN_STATUSES.includes(status);
|
|
37
|
+
}
|
|
38
|
+
/** A dropped machine outranks the session's own state. */
|
|
39
|
+
function sessionStateText(s, machine, t) {
|
|
40
|
+
if (!isMachineDown(machine)) return sessionStatusText(s, t);
|
|
41
|
+
return t(`machine.${isDownStatus(machine.status) ? machine.status : "unreachable"}`);
|
|
42
|
+
}
|
|
43
|
+
function machineHint(machine, t) {
|
|
44
|
+
const detail = machine.error ? { detail: machine.error } : {};
|
|
45
|
+
switch (machine.status) {
|
|
46
|
+
case "connected": return null;
|
|
47
|
+
case "no_daemon": return {
|
|
48
|
+
text: t("machine.noDaemonHint"),
|
|
49
|
+
...detail
|
|
50
|
+
};
|
|
51
|
+
case "no_agent": return {
|
|
52
|
+
text: t("machine.noAgentHint"),
|
|
53
|
+
...detail
|
|
54
|
+
};
|
|
55
|
+
case "unsupported_agent": return {
|
|
56
|
+
text: machine.agentVersion ? t("machine.unsupportedHintVersion", { version: machine.agentVersion }) : t("machine.unsupportedHint"),
|
|
57
|
+
...detail
|
|
58
|
+
};
|
|
59
|
+
default: return {
|
|
60
|
+
text: t("machine.unreachableHint"),
|
|
61
|
+
...detail
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function composerState(args) {
|
|
66
|
+
const { unreachable, archived, machineName, staleFor, status, liveHost, approvals, shellRun, t } = args;
|
|
67
|
+
if (unreachable) return {
|
|
68
|
+
placeholder: t("detail.composerUnreachable", { machine: machineName }),
|
|
69
|
+
hint: t("detail.footerUnreachable", { when: staleFor }),
|
|
70
|
+
locked: true
|
|
71
|
+
};
|
|
72
|
+
if (archived) return {
|
|
73
|
+
placeholder: t("detail.composerArchived"),
|
|
74
|
+
hint: t("detail.footerArchived"),
|
|
75
|
+
locked: true
|
|
76
|
+
};
|
|
77
|
+
if (status === "live_elsewhere") return {
|
|
78
|
+
placeholder: t("detail.composerLiveElsewhere", { host: liveHost ?? "" }),
|
|
79
|
+
hint: t("detail.footerLiveElsewhere"),
|
|
80
|
+
locked: true
|
|
81
|
+
};
|
|
82
|
+
if (status === "awaiting_approval") {
|
|
83
|
+
const answer = waitsOnAnswer(approvals);
|
|
84
|
+
return {
|
|
85
|
+
placeholder: t(answer ? "detail.composerAwaitingAnswer" : "detail.composerAwaiting"),
|
|
86
|
+
hint: t(answer ? "detail.footerAwaitingAnswer" : "detail.footerAwaiting"),
|
|
87
|
+
locked: true
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if (shellRun) return {
|
|
91
|
+
placeholder: t("detail.composerShellRunning"),
|
|
92
|
+
hint: t("detail.footerShellRunning", { command: shellRun }),
|
|
93
|
+
locked: true
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
placeholder: t("detail.composerPlaceholder"),
|
|
97
|
+
hint: "",
|
|
98
|
+
locked: false
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export { IMAGE_PLACEHOLDER, composerState, machineHint, rememberSentPrompt, sessionLabel, sessionStateText, sessionStatusText };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
{
|
|
2
|
+
"transcript": {
|
|
3
|
+
"running": "Running…",
|
|
4
|
+
"done": "Done",
|
|
5
|
+
"failed": "Failed",
|
|
6
|
+
"failedWith": "Failed: {reason}",
|
|
7
|
+
"callGroup": "Ran {tool} {count, plural, one {# time} other {# times}}",
|
|
8
|
+
"editGroup": "Made {count, plural, one {# edit} other {# edits}}",
|
|
9
|
+
"writeGroup": "Wrote {count, plural, one {# file} other {# files}}",
|
|
10
|
+
"failedGroup": "{tool} failed {count, plural, one {# time} other {# times}}",
|
|
11
|
+
"failedCount": "{count} failed",
|
|
12
|
+
"interrupted": "Interrupted",
|
|
13
|
+
"noOutput": "(no output)",
|
|
14
|
+
"diffTruncated": "Diff truncated",
|
|
15
|
+
"moreLines": "+{count, plural, one {# more line} other {# more lines}}",
|
|
16
|
+
"allowOnce": "Yes, allow this command",
|
|
17
|
+
"allowDirectory": "Yes, and allow this directory for the session",
|
|
18
|
+
"allowDirectoryTree": "Yes, and allow {path} and everything under it for the session",
|
|
19
|
+
"allowDirectoryOnly": "Yes, and allow {path} for the session",
|
|
20
|
+
"deny": "No, deny this command",
|
|
21
|
+
"allowCode": "Yes, run this code",
|
|
22
|
+
"denyCode": "No, don't run this code",
|
|
23
|
+
"allowPath": "Yes, allow this once",
|
|
24
|
+
"denyPath": "No, deny",
|
|
25
|
+
"allowCall": "Yes, allow this call",
|
|
26
|
+
"denyCall": "No, deny this call",
|
|
27
|
+
"denyWithFeedback": "No, and provide feedback to the agent",
|
|
28
|
+
"feedbackPlaceholder": "Tell the agent what to do instead…",
|
|
29
|
+
"answered": "Answered",
|
|
30
|
+
"allowedBy": "Allowed by {name}",
|
|
31
|
+
"deniedBy": "Denied by {name}",
|
|
32
|
+
"allowed": "Allowed",
|
|
33
|
+
"denied": "Denied",
|
|
34
|
+
"allowedByReviewer": "Allowed by the auto-reviewer",
|
|
35
|
+
"deniedByReviewer": "Denied by the auto-reviewer",
|
|
36
|
+
"approvalExpired": "Expired without an answer",
|
|
37
|
+
"approvalTimedOut": "Denied: no answer in time",
|
|
38
|
+
"reviewTimedOut": "Denied: the auto-reviewer timed out",
|
|
39
|
+
"reviewFailed": "Denied: the auto-reviewer failed",
|
|
40
|
+
"writeOwnAnswer": "Write my own answer…",
|
|
41
|
+
"subagent": "Task",
|
|
42
|
+
"tasks": "Tasks",
|
|
43
|
+
"planPending": "Plan awaiting approval in the terminal",
|
|
44
|
+
"approvalPending": "Waiting for an answer in the terminal",
|
|
45
|
+
"approvalOptions": "Offered choices",
|
|
46
|
+
"approvalLabel": "Waiting for your answer",
|
|
47
|
+
"approvalAllowed": "Allowed",
|
|
48
|
+
"approvalDenied": "Declined",
|
|
49
|
+
"approvalRequestExpired": "This request expired. Ask again to run it.",
|
|
50
|
+
"approvalWaitingOn": "Waiting for {name} to answer",
|
|
51
|
+
"feedbackLabel": "Feedback for the agent",
|
|
52
|
+
"ownAnswerLabel": "Your answer",
|
|
53
|
+
"typeYourAnswer": "Type your answer…",
|
|
54
|
+
"questionsLabel": "Questions",
|
|
55
|
+
"questionTab": "Q{n}",
|
|
56
|
+
"answeredCount": "{answered} of {total} answered",
|
|
57
|
+
"submitAnswers": "Submit answers",
|
|
58
|
+
"chatAboutThis": "Chat about this",
|
|
59
|
+
"noAnswer": "No answer",
|
|
60
|
+
"noPreview": "No preview for this option",
|
|
61
|
+
"previewOf": "Preview: {label}",
|
|
62
|
+
"notesLabel": "Notes",
|
|
63
|
+
"notesPlaceholder": "Add notes on this design…",
|
|
64
|
+
"notesOnly": "(notes only)",
|
|
65
|
+
"todoPending": "To do",
|
|
66
|
+
"todoInProgress": "In progress",
|
|
67
|
+
"todoCompleted": "Done",
|
|
68
|
+
"argsRewritten": "(args rewritten by hook)",
|
|
69
|
+
"interruptedReason": "interrupted",
|
|
70
|
+
"reviewing": "{count, plural, =1 {Reviewing approval request} other {Reviewing # approval requests}}",
|
|
71
|
+
"backgroundLaunched": "{count, plural, one {# background agent} other {# background agents}} launched"
|
|
72
|
+
},
|
|
73
|
+
"tools": {
|
|
74
|
+
"noOutput": "(no output)",
|
|
75
|
+
"firstLineMore": "{line} (+{more, plural, one {# line} other {# lines}})",
|
|
76
|
+
"emptyFile": "Empty file",
|
|
77
|
+
"readImage": "Read image",
|
|
78
|
+
"readLines": "Read {lines, plural, one {# line} other {# lines}}",
|
|
79
|
+
"readLinesMore": "Read {lines, plural, one {# line} other {# lines}} ({more, number} more)",
|
|
80
|
+
"noMatches": "No matches",
|
|
81
|
+
"foundMatches": "Found {matches, plural, one {# match} other {# matches}} in {files, plural, one {# file} other {# files}}",
|
|
82
|
+
"foundFiles": "Found {files, plural, one {# file} other {# files}}",
|
|
83
|
+
"noFilesMatched": "No files matched",
|
|
84
|
+
"truncated": "{summary} (truncated)",
|
|
85
|
+
"exitCode": "Exit {code}",
|
|
86
|
+
"exitCodeLines": "Exit {code} · {lines, plural, one {# line} other {# lines}}",
|
|
87
|
+
"httpStatus": "HTTP {status} · {lines, plural, one {# line} other {# lines}}",
|
|
88
|
+
"outputTruncated": "{summary} (output truncated)",
|
|
89
|
+
"addedRemoved": "Added {added, plural, one {# line} other {# lines}}, removed {removed, plural, one {# line} other {# lines}}",
|
|
90
|
+
"added": "Added {added, plural, one {# line} other {# lines}}",
|
|
91
|
+
"removed": "Removed {removed, plural, one {# line} other {# lines}}",
|
|
92
|
+
"wrote": "Wrote {lines, plural, one {# line} other {# lines}}",
|
|
93
|
+
"wroteTo": "Wrote {lines, plural, one {# line} other {# lines}} to {path}",
|
|
94
|
+
"rollupSearched": "searched for {count, plural, one {# pattern} other {# patterns}}",
|
|
95
|
+
"rollupRead": "read {count, plural, one {# file} other {# files}}",
|
|
96
|
+
"rollupRanCommands": "ran {count, plural, one {# shell command} other {# shell commands}}",
|
|
97
|
+
"rollupFetched": "fetched {count, plural, one {# URL} other {# URLs}}",
|
|
98
|
+
"rollupLoadedSkills": "loaded {count, plural, one {# skill} other {# skills}}",
|
|
99
|
+
"rollupSentMessages": "sent {count, plural, one {# message} other {# messages}}",
|
|
100
|
+
"rollupCalledMcpTools": "called {count, plural, one {# MCP tool} other {# MCP tools}}",
|
|
101
|
+
"rollupRanTools": "ran {count, plural, one {# tool} other {# tools}}",
|
|
102
|
+
"rollupSearching": "searching for {count, plural, one {# pattern} other {# patterns}}",
|
|
103
|
+
"rollupReading": "reading {count, plural, one {# file} other {# files}}",
|
|
104
|
+
"rollupRunningCommands": "running {count, plural, one {# shell command} other {# shell commands}}",
|
|
105
|
+
"rollupFetching": "fetching {count, plural, one {# URL} other {# URLs}}",
|
|
106
|
+
"rollupLoadingSkills": "loading {count, plural, one {# skill} other {# skills}}",
|
|
107
|
+
"rollupSendingMessages": "sending {count, plural, one {# message} other {# messages}}",
|
|
108
|
+
"rollupRunningTools": "running {count, plural, one {# tool} other {# tools}}",
|
|
109
|
+
"rollupCalledServer": "called {server} {count, plural, one {# time} other {# times}}",
|
|
110
|
+
"rollupCallingServer": "calling {server} {count, plural, one {# time} other {# times}}",
|
|
111
|
+
"rollupSeparator": ", ",
|
|
112
|
+
"rejected": "Tool use rejected",
|
|
113
|
+
"rejectedWith": "Tool use rejected: {feedback}",
|
|
114
|
+
"rejectedUpdate": "User rejected update to {path}",
|
|
115
|
+
"rejectedUpdateWith": "User rejected update to {path}: {feedback}",
|
|
116
|
+
"rejectedWrite": "User rejected write to {path}",
|
|
117
|
+
"rejectedWriteWith": "User rejected write to {path}: {feedback}",
|
|
118
|
+
"unattended": "Denied: this session cannot ask for approval",
|
|
119
|
+
"userInterrupted": "The user interrupted {tool} before it finished."
|
|
120
|
+
},
|
|
121
|
+
"queue": {
|
|
122
|
+
"remove": "Remove queued message",
|
|
123
|
+
"waiting": "Queued · sends when this reply finishes",
|
|
124
|
+
"waitingNextStep": "Queued · reaches the agent after its current step",
|
|
125
|
+
"handedOver": "Sent to the running turn"
|
|
126
|
+
},
|
|
127
|
+
"paste": {
|
|
128
|
+
"title": "Pasted text",
|
|
129
|
+
"lines": "{count, plural, one {# line} other {# lines}}",
|
|
130
|
+
"saving": "Saving…",
|
|
131
|
+
"remove": "Remove paste"
|
|
132
|
+
},
|
|
133
|
+
"thinking": {
|
|
134
|
+
"thoughtProcess": "Thought process"
|
|
135
|
+
},
|
|
136
|
+
"modelPicker": {
|
|
137
|
+
"choose": "Model",
|
|
138
|
+
"select": "Select a model",
|
|
139
|
+
"search": "Search models…",
|
|
140
|
+
"loading": "Loading models…",
|
|
141
|
+
"failed": "Failed to load models",
|
|
142
|
+
"none": "No models available",
|
|
143
|
+
"sharedBy": "Shared by {owner}",
|
|
144
|
+
"connecting": "Connecting…",
|
|
145
|
+
"notResponding": "Not responding",
|
|
146
|
+
"manageProvider": "Manage provider",
|
|
147
|
+
"selectFirst": "Select a model first"
|
|
148
|
+
},
|
|
149
|
+
"allocationPicker": {
|
|
150
|
+
"choose": "Allocation",
|
|
151
|
+
"placeholder": "Select allocation",
|
|
152
|
+
"search": "Search allocations…"
|
|
153
|
+
},
|
|
154
|
+
"providerIssue": {
|
|
155
|
+
"keyRejected": "API key rejected",
|
|
156
|
+
"unreachable": "Endpoint unreachable",
|
|
157
|
+
"keyRejectedHint": "The provider rejected this connection's API key. Update the key in the provider settings to resume.",
|
|
158
|
+
"unreachableHint": "The provider's endpoint did not respond. Check the endpoint URL and network access.",
|
|
159
|
+
"bannerKeyRejected": "API key rejected for “{provider}”",
|
|
160
|
+
"bannerUnreachable": "“{provider}” is unreachable"
|
|
161
|
+
}
|
|
162
|
+
}
|