@parallelworks/code 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +92 -24
  2. package/dist/agentSwitcher.d.ts +13 -2
  3. package/dist/agentSwitcher.js +28 -6
  4. package/dist/ago.d.ts +1 -3
  5. package/dist/ago.js +1 -3
  6. package/dist/api.d.ts +267 -5
  7. package/dist/chatStrings.d.ts +4 -0
  8. package/dist/chatStrings.js +5 -1
  9. package/dist/claudeAccounts.d.ts +20 -2
  10. package/dist/claudeAccounts.js +51 -7
  11. package/dist/claudeApi.d.ts +2 -1
  12. package/dist/claudeApi.js +49 -3
  13. package/dist/command.d.ts +7 -1
  14. package/dist/command.js +11 -2
  15. package/dist/commandsApi.d.ts +8 -3
  16. package/dist/commandsApi.js +25 -4
  17. package/dist/createPwCodeApi.d.ts +92 -58
  18. package/dist/createPwCodeApi.js +4 -2
  19. package/dist/index.d.ts +11 -9
  20. package/dist/index.js +7 -5
  21. package/dist/locales/en/agentTranscript.js +6 -2
  22. package/dist/locales/en/agents.js +50 -6
  23. package/dist/locales/en.d.ts +46 -0
  24. package/dist/locales/es/agentTranscript.js +6 -2
  25. package/dist/locales/es/agents.js +50 -6
  26. package/dist/locales/ja/agentTranscript.js +6 -2
  27. package/dist/locales/ja/agents.js +45 -6
  28. package/dist/locales/ko/agentTranscript.js +6 -2
  29. package/dist/locales/ko/agents.js +50 -6
  30. package/dist/locales/zh/agentTranscript.js +6 -2
  31. package/dist/locales/zh/agents.js +50 -6
  32. package/dist/machine.d.ts +27 -2
  33. package/dist/machine.js +23 -2
  34. package/dist/notices.d.ts +2 -0
  35. package/dist/notices.js +29 -14
  36. package/dist/pwUpdate.d.ts +52 -0
  37. package/dist/pwUpdate.js +115 -0
  38. package/dist/query.d.ts +4 -1
  39. package/dist/query.js +9 -3
  40. package/dist/session.d.ts +7 -1
  41. package/dist/session.js +6 -2
  42. package/dist/sessionActions.js +5 -2
  43. package/dist/sessionEvents.d.ts +39 -5
  44. package/dist/sessionEvents.js +213 -83
  45. package/dist/sessionGroups.d.ts +3 -3
  46. package/dist/sessionGroups.js +3 -3
  47. package/dist/sessionHeader.js +6 -2
  48. package/dist/sessionList.d.ts +13 -8
  49. package/dist/sessionList.js +20 -10
  50. package/dist/sessionScreen.d.ts +8 -3
  51. package/dist/sessionScreen.js +20 -9
  52. package/dist/sessionsApi.d.ts +27 -5
  53. package/dist/sessionsApi.js +128 -17
  54. package/dist/sessionsFeed.d.ts +22 -0
  55. package/dist/sessionsFeed.js +125 -0
  56. package/dist/startPage.d.ts +6 -3
  57. package/dist/startPage.js +34 -12
  58. package/dist/startSession.d.ts +31 -11
  59. package/dist/startSession.js +126 -44
  60. package/dist/terminalHandoffPanel.js +8 -1
  61. package/dist/todos.d.ts +42 -0
  62. package/dist/todos.js +104 -0
  63. package/dist/transcript.d.ts +27 -5
  64. package/dist/transcript.js +148 -112
  65. package/dist/transcriptRead.d.ts +57 -0
  66. package/dist/transcriptRead.js +122 -0
  67. package/dist/types.d.ts +13 -1
  68. package/dist/useComposer.d.ts +36 -15
  69. package/dist/useComposer.js +94 -31
  70. package/dist/useComposerImages.d.ts +38 -1
  71. package/dist/useComposerImages.js +62 -8
  72. package/dist/useComposerPastes.js +3 -8
  73. package/dist/useConversation.d.ts +16 -0
  74. package/dist/useConversation.js +78 -8
  75. package/dist/useMounted.d.ts +3 -0
  76. package/dist/useMounted.js +14 -0
  77. package/dist/useSubagent.d.ts +22 -5
  78. package/dist/useSubagent.js +41 -17
  79. package/dist/useTranscript.d.ts +27 -1
  80. package/dist/useTranscript.js +217 -45
  81. package/dist/wording.d.ts +6 -3
  82. package/dist/wording.js +20 -6
  83. package/locales/en/agentTranscript.json +6 -2
  84. package/locales/en/agents.json +46 -4
  85. package/locales/es/agentTranscript.json +6 -2
  86. package/locales/es/agents.json +46 -4
  87. package/locales/ja/agentTranscript.json +6 -2
  88. package/locales/ja/agents.json +46 -4
  89. package/locales/ko/agentTranscript.json +6 -2
  90. package/locales/ko/agents.json +46 -4
  91. package/locales/zh/agentTranscript.json +6 -2
  92. package/locales/zh/agents.json +46 -4
  93. package/package.json +3 -3
@@ -1,15 +1,57 @@
1
- import { appendOwnMessage, appendShellRun, appendSteeredMessage, appendTurnMessage, applyStreamEvent, dropMessage, initialTranscript, markQueued, pendingMessages, resolveApprovalEverywhere, subagentFrame, turnRunning } from "./transcript.js";
1
+ import { appendCommand, appendOwnMessage, appendShellRun, appendSteeredMessage, appendTurnMessage, applyStreamEvent, dropMessage, initialTranscript, markQueued, pendingMessages, queueOwnMessage, resolveApprovalEverywhere, stoppedTurn, 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
+ var MAX_TURN_OUTCOMES = 50;
6
+ function noteOutcome(outcomes, turnId, outcome) {
7
+ if (outcomes.get(turnId) === "settled") return;
8
+ outcomes.delete(turnId);
9
+ outcomes.set(turnId, outcome);
10
+ const oldest = outcomes.keys().next().value;
11
+ if (outcomes.size > MAX_TURN_OUTCOMES && oldest !== void 0) outcomes.delete(oldest);
12
+ }
13
+ /** What a frame says of its turn's prompt, given the turn as drawn before it.
14
+ * As in the terminal, a turn that replied before it failed, as a skill does
15
+ * before its prompt counts as read, gives nothing back. `readsReported` says
16
+ * the machine sends prompt_read at all. */
17
+ function turnOutcome(ev, before, readsReported) {
18
+ switch (ev.type) {
19
+ case "prompt_read":
20
+ case "done": return "settled";
21
+ case "error": {
22
+ const replied = !(before.streaming?.parts ?? []).every((p) => p.kind === "notice" || p.kind === "warning" || p.kind === "error");
23
+ if (stoppedTurn(ev)) return replied && !readsReported ? "settled" : "stopped";
24
+ return replied ? "settled" : "failed";
25
+ }
26
+ default: return null;
27
+ }
28
+ }
29
+ /** The message a stop closed the turn with, when it says only that: the
30
+ * machine records no stop for a prompt it hands back. */
31
+ function stopLineOf(before, after) {
32
+ const closing = after.messages.at(-1);
33
+ return !!closing && closing.role === "assistant" && !before.messages.some((m) => m.id === closing.id) && (closing.parts ?? []).every((p) => p.kind === "notice") ? closing.id : void 0;
34
+ }
35
+ /** Takes a prompt its turn left out of the conversation off the transcript,
36
+ * with the stop line that closed it. */
37
+ function withoutPrompt(state, messageId, stopLine) {
38
+ const dropped = dropMessage(state, messageId);
39
+ return stopLine ? dropMessage(dropped, stopLine) : dropped;
40
+ }
41
+ /** The message a user_message from another window drew for the turn it opened. */
42
+ function othersPrompt(ev, before, after, own) {
43
+ if (ev.type !== "user_message" || !ev.turnId || own.echoOf || own.turnIds.has(ev.turnId) || !!ev.content && own.texts.has(ev.content)) return;
44
+ const placed = after.messages.at(-1);
45
+ return placed?.role === "user" && !before.messages.some((m) => m.id === placed.id) ? placed.id : void 0;
46
+ }
5
47
  function keepForSeed(frames, ev) {
6
48
  frames.push(ev);
7
49
  if (frames.length > MAX_REPLAY_FRAMES) frames.shift();
8
50
  }
9
51
  /** Matches the way the echo is recognised: by turn once the send has named it,
10
- * by text before then. */
52
+ * by text before then. A schedule's prompt is no send's echo, whatever its words. */
11
53
  function echoedSend(unechoed, ev) {
12
- if (ev.type !== "user_message" && ev.type !== "user_note") return;
54
+ if (ev.type !== "user_message" && ev.type !== "user_note" || ev.scheduled) return;
13
55
  const steered = ev.type === "user_note";
14
56
  for (const [localId, sent] of unechoed) {
15
57
  if (!!sent.steered !== steered) continue;
@@ -32,6 +74,11 @@ function forgetPlaced(unechoed, detail) {
32
74
  if (!sent.steered && (reached || sent.text === last)) unechoed.delete(localId);
33
75
  }
34
76
  }
77
+ /** Whether a composer's ↑ has anything to take back: a message a turn gave
78
+ * back, or one still waiting that the machine would give up. */
79
+ function canTakeBack(handedBack, queued, canRemoveQueued) {
80
+ return handedBack > 0 || queued.some((m) => canRemoveQueued(m.id));
81
+ }
35
82
  /** Holds the live transcript for one session. The host still owns the socket
36
83
  * and the fetch: it feeds events to `onEvent` and posts through `send`. */
37
84
  function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdraw, withdrawDirection, onEffect, goalNotice, compactionNotice, recapNotice, words, imageUrl }) {
@@ -42,7 +89,27 @@ function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdra
42
89
  const ownTexts = useRef(/* @__PURE__ */ new Set());
43
90
  const ownSeq = useRef(0);
44
91
  const unechoed = useRef(/* @__PURE__ */ new Map());
92
+ const commands = useRef(/* @__PURE__ */ new Map());
93
+ const heldRefetch = useRef(false);
45
94
  const appliedSinceSeed = useRef([]);
95
+ const unreadTurns = useRef(/* @__PURE__ */ new Map());
96
+ const turnOutcomes = useRef(/* @__PURE__ */ new Map());
97
+ const othersUnread = useRef(/* @__PURE__ */ new Map());
98
+ const readsReported = useRef(false);
99
+ const feedGaps = useRef(0);
100
+ const handedBackRef = useRef([]);
101
+ const [handedBack, setHandedBack] = useState({
102
+ count: 0,
103
+ shown: false
104
+ });
105
+ const publishHandedBack = useCallback(() => {
106
+ const waiting = handedBackRef.current;
107
+ setHandedBack({
108
+ count: waiting.length,
109
+ shown: waiting.some((m) => m.shown)
110
+ });
111
+ }, []);
112
+ const takingBack = useRef(false);
46
113
  const sendRef = useRef(send);
47
114
  const steerRef = useRef(steer);
48
115
  const withdrawRef = useRef(withdraw);
@@ -96,8 +163,9 @@ function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdra
96
163
  for (const [localId, sent] of unechoed.current) {
97
164
  const { text, pastes, previews, steered } = sent;
98
165
  if (steered) next = appendSteeredMessage(next, text, localId, pastes, previews);
99
- else if (!subagent) next = appendOwnMessage(next, text, localId, pastes, previews);
166
+ else if (!subagent) next = (commands.current.size > 0 ? queueOwnMessage : appendOwnMessage)(next, text, localId, pastes, previews);
100
167
  }
168
+ for (const [localId, command] of commands.current) next = appendCommand(next, command, localId);
101
169
  const cursor = Math.max(next.cursor, transcriptRef.current?.cursor ?? 0);
102
170
  next = cursor === next.cursor ? next : {
103
171
  ...next,
@@ -113,7 +181,58 @@ function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdra
113
181
  transcriptRef.current = next;
114
182
  setTranscript(next);
115
183
  }, []);
184
+ /** Gives back a message its turn left out of the conversation. The machine
185
+ * still shows one its turn failed on where it was sent, as the terminal
186
+ * does; it keeps nothing of one a stop handed back, or never echoed. */
187
+ const handBack = useCallback((turnId, { localId, sent }, outcome, stopLine) => {
188
+ noteOutcome(turnOutcomes.current, turnId, "settled");
189
+ const { text, typed, pastes, images, previews } = sent;
190
+ const shown = outcome === "failed" && (!!subagent || !unechoed.current.has(localId));
191
+ handedBackRef.current.push({
192
+ text: typed ?? text,
193
+ pastes,
194
+ images,
195
+ previews,
196
+ shown
197
+ });
198
+ publishHandedBack();
199
+ if (!shown) {
200
+ unechoed.current.delete(localId);
201
+ apply((state) => withoutPrompt(state, localId, stopLine));
202
+ }
203
+ }, [
204
+ apply,
205
+ subagent,
206
+ publishHandedBack
207
+ ]);
208
+ const dropShownHandedBack = useCallback(() => {
209
+ if (takingBack.current) return;
210
+ handedBackRef.current = handedBackRef.current.filter((m) => !m.shown);
211
+ publishHandedBack();
212
+ }, [publishHandedBack]);
213
+ /** Follows a turn this window sent until the model reads its prompt, or
214
+ * gives its message back at once when the turn already ended without. */
215
+ const trackUnread = useCallback((turnId, unread) => {
216
+ if (unread.sent.steered || unreadTurns.current.has(turnId)) return;
217
+ const outcome = turnOutcomes.current.get(turnId);
218
+ if (outcome === "settled") return;
219
+ if (outcome) {
220
+ handBack(turnId, unread, outcome);
221
+ return;
222
+ }
223
+ unreadTurns.current.set(turnId, unread);
224
+ }, [handBack]);
225
+ const settleTurn = useCallback((turnId, outcome, stopLine) => {
226
+ const unread = unreadTurns.current.get(turnId);
227
+ unreadTurns.current.delete(turnId);
228
+ const othersMessage = othersUnread.current.get(turnId);
229
+ othersUnread.current.delete(turnId);
230
+ if (unread && outcome !== "settled") handBack(turnId, unread, outcome, stopLine);
231
+ else noteOutcome(turnOutcomes.current, turnId, outcome);
232
+ if (othersMessage && outcome === "stopped") apply((state) => withoutPrompt(state, othersMessage, stopLine));
233
+ }, [apply, handBack]);
116
234
  const onEvent = useCallback((frame) => {
235
+ if (frame.type === "prompt_read") readsReported.current = true;
117
236
  const ev = subagent ? subagentFrame(frame, subagent) : frame;
118
237
  if (ev === "refetch") {
119
238
  onEffectRef.current({ type: "refetch" });
@@ -139,25 +258,39 @@ function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdra
139
258
  words: wordsRef.current,
140
259
  imageUrl: imageUrlRef.current
141
260
  });
142
- if (ev.type === "replay_truncated") appliedSinceSeed.current = [];
143
- else if (state.cursor > current.cursor) {
261
+ if (ev.type === "replay_truncated") {
262
+ appliedSinceSeed.current = [];
263
+ unreadTurns.current.clear();
264
+ othersUnread.current.clear();
265
+ feedGaps.current += 1;
266
+ } else if (state.cursor > current.cursor) {
144
267
  keepForSeed(appliedSinceSeed.current, ev);
145
268
  if (echoOf) unechoed.current.delete(echoOf);
146
269
  forgetSettled(unechoed.current, current, state);
147
270
  }
148
271
  apply(() => state);
149
- for (const effect of effects) onEffectRef.current(effect);
272
+ const othersMessage = subagent ? void 0 : othersPrompt(ev, current, state, {
273
+ echoOf,
274
+ turnIds: ownTurnIds.current,
275
+ texts: ownTexts.current
276
+ });
277
+ if (ev.turnId && othersMessage) othersUnread.current.set(ev.turnId, othersMessage);
278
+ const outcome = ev.turnId && state.cursor > current.cursor ? turnOutcome(ev, current, readsReported.current) : null;
279
+ if (ev.turnId && outcome) settleTurn(ev.turnId, outcome, outcome === "stopped" ? stopLineOf(current, state) : void 0);
280
+ for (const effect of effects) if (effect.type === "refetch" && commands.current.size > 0) heldRefetch.current = true;
281
+ else onEffectRef.current(effect);
150
282
  if (subagent && frame.type === "subagent_user_note") onEffectRef.current({ type: "refetch" });
151
283
  }, [
152
284
  apply,
153
285
  sessionId,
154
- subagent
286
+ subagent,
287
+ settleTurn
155
288
  ]);
156
289
  /** True once the running turn took the text, or the refusal if it may have.
157
290
  * Commands and shell escapes change the next turn, so like the TUI they wait. */
158
291
  const trySteer = useCallback(async (text, { typed, pastes, images, previews }) => {
159
292
  const steerTo = steerRef.current;
160
- if (!steerTo || !turnRunning(transcriptRef.current) || /^[/!]/.test(text.trimStart())) return false;
293
+ if (!steerTo || !turnRunning(transcriptRef.current) || commands.current.size > 0 || /^[/!]/.test(text.trimStart())) return false;
161
294
  ownSeq.current += 1;
162
295
  const localId = `own-${ownSeq.current}`;
163
296
  unechoed.current.set(localId, {
@@ -197,8 +330,9 @@ function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdra
197
330
  images,
198
331
  previews
199
332
  });
200
- const append = subagent ? appendTurnMessage : appendOwnMessage;
333
+ const append = subagent ? appendTurnMessage : commands.current.size > 0 ? queueOwnMessage : appendOwnMessage;
201
334
  apply((state) => append(state, text, localId, pastes, previews));
335
+ const gapsBefore = feedGaps.current;
202
336
  const result = await sendRef.current(text, pastes, images);
203
337
  setSending(false);
204
338
  if ("error" in result) {
@@ -214,15 +348,40 @@ function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdra
214
348
  ownTexts.current.delete(text);
215
349
  const pending = unechoed.current.get(localId);
216
350
  if (pending) pending.turnId = result.turnId;
351
+ if (feedGaps.current === gapsBefore) trackUnread(result.turnId, {
352
+ localId,
353
+ sent: pending ?? {
354
+ text,
355
+ typed,
356
+ pastes,
357
+ images,
358
+ previews
359
+ }
360
+ });
217
361
  }
218
362
  return null;
219
363
  }, [
220
364
  apply,
221
365
  trySteer,
222
- subagent
366
+ subagent,
367
+ trackUnread
223
368
  ]);
224
369
  const resolveApproval = useCallback((approvalId) => apply((state) => resolveApprovalEverywhere(state, approvalId)), [apply]);
225
370
  const noteShellRun = useCallback((command, output) => apply((state) => appendShellRun(state, command, output)), [apply]);
371
+ const showCommand = useCallback((command) => {
372
+ ownSeq.current += 1;
373
+ const localId = `own-${ownSeq.current}`;
374
+ commands.current.set(localId, command);
375
+ apply((state) => appendCommand(state, command, localId));
376
+ return (filed) => {
377
+ commands.current.delete(localId);
378
+ if (!filed) apply((state) => dropMessage(state, localId));
379
+ if (heldRefetch.current && commands.current.size === 0) {
380
+ heldRefetch.current = false;
381
+ onEffectRef.current({ type: "refetch" });
382
+ }
383
+ };
384
+ }, [apply]);
226
385
  /** Takes back a message queued as a turn of its own, or one steered into
227
386
  * the turn that the model has not been handed yet. */
228
387
  const withdrawal = (id) => {
@@ -246,7 +405,10 @@ function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdra
246
405
  const result = await withdrawIt();
247
406
  if (result.error) return { refusal: result.error };
248
407
  unechoed.current.delete(id);
249
- if (sent.turnId) ownTurnIds.current.delete(sent.turnId);
408
+ if (sent.turnId) {
409
+ ownTurnIds.current.delete(sent.turnId);
410
+ unreadTurns.current.delete(sent.turnId);
411
+ }
250
412
  apply((state) => dropMessage(state, id));
251
413
  return { sent };
252
414
  }, [apply]);
@@ -254,7 +416,42 @@ function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdra
254
416
  const outcome = await withdrawMessage(id);
255
417
  return outcome && "refusal" in outcome ? outcome.refusal : null;
256
418
  }, [withdrawMessage]);
257
- const takingBack = useRef(false);
419
+ /** Takes back every pending message the machine still holds, as ↑ does in the
420
+ * terminal: steered ones first, then turns of their own, each oldest first.
421
+ * One runs at a time: another meanwhile takes nothing. */
422
+ const takeBackPending = useCallback(async () => {
423
+ if (takingBack.current) return {
424
+ taken: [],
425
+ refusal: null
426
+ };
427
+ takingBack.current = true;
428
+ try {
429
+ const state = transcriptRef.current;
430
+ const ids = state ? [...state.steered, ...state.queued].map((m) => m.id) : [];
431
+ const outcomes = [];
432
+ for (const id of ids.toReversed()) outcomes.unshift(await withdrawMessage(id));
433
+ const taken = handedBackRef.current;
434
+ handedBackRef.current = [];
435
+ if (taken.length > 0) publishHandedBack();
436
+ let refusal = null;
437
+ for (const outcome of outcomes) if (outcome && "sent" in outcome) {
438
+ const { text, typed, pastes, images, previews } = outcome.sent;
439
+ taken.push({
440
+ text: typed ?? text,
441
+ pastes,
442
+ images,
443
+ previews
444
+ });
445
+ } else if (outcome) refusal ??= outcome.refusal;
446
+ return {
447
+ taken,
448
+ refusal
449
+ };
450
+ } finally {
451
+ takingBack.current = false;
452
+ }
453
+ }, [withdrawMessage, publishHandedBack]);
454
+ const cursor = useCallback(() => transcriptRef.current?.cursor ?? 0, []);
258
455
  return {
259
456
  transcript,
260
457
  sending,
@@ -262,39 +459,14 @@ function usePwCodeTranscript({ sessionId, subagent, detail, send, steer, withdra
262
459
  sendMessage,
263
460
  resolveApproval,
264
461
  noteShellRun,
462
+ showCommand,
265
463
  canRemoveQueued,
266
464
  removeQueued,
267
- takeBackPending: useCallback(async () => {
268
- if (takingBack.current) return {
269
- taken: [],
270
- refusal: null
271
- };
272
- takingBack.current = true;
273
- try {
274
- const state = transcriptRef.current;
275
- const ids = state ? [...state.steered, ...state.queued].map((m) => m.id) : [];
276
- const outcomes = [];
277
- for (const id of ids.toReversed()) outcomes.unshift(await withdrawMessage(id));
278
- const taken = [];
279
- let refusal = null;
280
- for (const outcome of outcomes) if (outcome && "sent" in outcome) {
281
- const { text, typed, pastes, images, previews } = outcome.sent;
282
- taken.push({
283
- text: typed ?? text,
284
- pastes,
285
- images,
286
- previews
287
- });
288
- } else if (outcome) refusal ??= outcome.refusal;
289
- return {
290
- taken,
291
- refusal
292
- };
293
- } finally {
294
- takingBack.current = false;
295
- }
296
- }, [withdrawMessage]),
297
- cursor: useCallback(() => transcriptRef.current?.cursor ?? 0, [])
465
+ takeBackPending,
466
+ handedBack: handedBack.count,
467
+ handedBackShown: handedBack.shown,
468
+ dropShownHandedBack,
469
+ cursor
298
470
  };
299
471
  }
300
- export { usePwCodeTranscript };
472
+ export { canTakeBack, usePwCodeTranscript };
package/dist/wording.d.ts CHANGED
@@ -10,14 +10,17 @@ export declare const IMAGE_PLACEHOLDER: RegExp;
10
10
  export declare function rememberSentPrompt(machine: string, id: string, text: string): void;
11
11
  /** The id is never a label: it is a timestamp the reader did not choose. */
12
12
  export declare function sessionLabel(s: Pick<PwCodeSession, 'machineId' | 'id' | 'name' | 'autoName' | 'preview'>, t: Translate): string;
13
+ /** `resumeClock` writes when a usage limit resets, which is left out without it. */
13
14
  export declare function sessionStatusText(s: {
14
15
  status: PwCodeSessionStatus;
15
16
  liveHost?: string | undefined;
16
17
  approvals?: PwCodePendingApprovals;
17
- }, t: Translate): string;
18
+ waitingForUsageLimit?: boolean | undefined;
19
+ usageLimitResumeAt?: string | undefined;
20
+ }, t: Translate, resumeClock?: (at: string) => string): string;
18
21
  /** 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): {
22
+ export declare function sessionStateText(s: Parameters<typeof sessionStatusText>[0], machine: Pick<PwCodeMachine, 'status'> | undefined, t: Translate, resumeClock?: (at: string) => string): string;
23
+ export declare function machineHint(machine: Pick<PwCodeMachine, 'status' | 'error' | 'agentVersion'> & Partial<Pick<PwCodeMachine, 'kind'>>, t: Translate): {
21
24
  text: string;
22
25
  detail?: string;
23
26
  } | null;
package/dist/wording.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { isMachineDown } from "./machine.js";
2
- import { sessionKey, waitsOnAnswer } from "./session.js";
2
+ import { sessionKey, waitsOnAnswer, waitsOnUsageLimit } from "./session.js";
3
3
  import { nameToEmoji } from "gemoji";
4
4
  // src/wording.ts
5
5
  /** How a prompt refers to an image sent with it: `[Image #1]`. */
@@ -22,26 +22,40 @@ function sessionLabel(s, t) {
22
22
  return Object.hasOwn(nameToEmoji, key) ? nameToEmoji[key] ?? match : match;
23
23
  });
24
24
  }
25
- function sessionStatusText(s, t) {
25
+ /** `resumeClock` writes when a usage limit resets, which is left out without it. */
26
+ function sessionStatusText(s, t, resumeClock) {
26
27
  if (s.status === "awaiting_approval" && waitsOnAnswer(s.approvals)) return t("status.awaiting_answer");
28
+ if (waitsOnUsageLimit(s)) return s.usageLimitResumeAt && resumeClock ? t("status.usage_limit_until", { time: resumeClock(s.usageLimitResumeAt) }) : t("status.usage_limit");
27
29
  return t(`status.${s.status}`, { host: s.liveHost ?? "" });
28
30
  }
29
31
  var DOWN_STATUSES = [
30
32
  "no_daemon",
31
33
  "no_agent",
32
34
  "unreachable",
33
- "unsupported_agent"
35
+ "unsupported_agent",
36
+ "starting"
34
37
  ];
35
38
  function isDownStatus(status) {
36
39
  return DOWN_STATUSES.includes(status);
37
40
  }
38
41
  /** A dropped machine outranks the session's own state. */
39
- function sessionStateText(s, machine, t) {
40
- if (!isMachineDown(machine)) return sessionStatusText(s, t);
42
+ function sessionStateText(s, machine, t, resumeClock) {
43
+ if (!isMachineDown(machine)) return sessionStatusText(s, t, resumeClock);
41
44
  return t(`machine.${isDownStatus(machine.status) ? machine.status : "unreachable"}`);
42
45
  }
46
+ /** Why a machine's pw is too old to read sessions from. A computer's own pw
47
+ * dials in, with no pw agent between. */
48
+ function tooOldHint(machine, t) {
49
+ const version = machine.agentVersion;
50
+ if (machine.kind === "local") return version ? t("machine.unsupportedComputerHintVersion", { version }) : t("machine.unsupportedComputerHint");
51
+ return version ? t("machine.unsupportedHintVersion", { version }) : t("machine.unsupportedHint");
52
+ }
43
53
  function machineHint(machine, t) {
44
54
  const detail = machine.error ? { detail: machine.error } : {};
55
+ if (machine.kind === "workspace" && machine.status !== "connected" && machine.status !== "no_daemon") return {
56
+ text: t(machine.status === "unsupported_agent" ? "machine.workspaceOutdatedHint" : machine.status === "starting" ? "machine.workspaceStartingHint" : "machine.workspaceDownHint"),
57
+ ...detail
58
+ };
45
59
  switch (machine.status) {
46
60
  case "connected": return null;
47
61
  case "no_daemon": return {
@@ -53,7 +67,7 @@ function machineHint(machine, t) {
53
67
  ...detail
54
68
  };
55
69
  case "unsupported_agent": return {
56
- text: machine.agentVersion ? t("machine.unsupportedHintVersion", { version: machine.agentVersion }) : t("machine.unsupportedHint"),
70
+ text: tooOldHint(machine, t),
57
71
  ...detail
58
72
  };
59
73
  default: return {
@@ -62,7 +62,8 @@
62
62
  "noPreview": "No preview for this option",
63
63
  "previewOf": "Preview: {label}",
64
64
  "notesLabel": "Notes",
65
- "notesPlaceholder": "Add notes on this design…",
65
+ "notesPlaceholder": "Add notes…",
66
+ "addNotes": "Add notes",
66
67
  "notesOnly": "(notes only)",
67
68
  "todoPending": "To do",
68
69
  "todoInProgress": "In progress",
@@ -150,7 +151,10 @@
150
151
  },
151
152
  "input": {
152
153
  "stopGenerating": "Stop generating (Escape)",
153
- "loadingCommands": "Loading commands…"
154
+ "loadingCommands": "Loading commands…",
155
+ "emoji": "Emoji",
156
+ "shellMode": "shell mode",
157
+ "shellHint": "Enter runs it on the session's machine, and its output is added to the conversation"
154
158
  },
155
159
  "thread": {
156
160
  "jumpToPrompt": "Go to message: {text}"
@@ -56,6 +56,7 @@
56
56
  "pinned": "Pinned",
57
57
  "fork": "Fork",
58
58
  "forkMidTurn": "Available once the turn ends",
59
+ "leaveWorktreeMidTurn": "Available once the turn ends",
59
60
  "leaveWorktree": "Leave worktree",
60
61
  "leaveWorktreeTitle": "Leave the worktree?",
61
62
  "leaveWorktreeBody": "The session goes back to working in {workspace}. Its conversation stays as it is.",
@@ -77,6 +78,8 @@
77
78
  "startButton": "Start session",
78
79
  "chooseMachine": "Choose a machine",
79
80
  "findingMachines": "Finding your machines…",
81
+ "workspaceStarting": "Starting your workspace…",
82
+ "heldCard": "Your message is sent as soon as your workspace is up.",
80
83
  "notAnswering": "Not answering ({count})",
81
84
  "chooseDirectory": "Choose a directory",
82
85
  "browse": "Browse",
@@ -105,7 +108,10 @@
105
108
  "showHidden": "Show hidden directories",
106
109
  "browseCancel": "Cancel",
107
110
  "composerPlaceholder": "Describe a task or ask a question",
111
+ "commandAlone": "{command} can't bring images or a chat into a new session. Remove them, or start the session first and run {command} there.",
108
112
  "choosePermission": "Choose what the agent may do",
113
+ "chooseGroup": "Choose a group",
114
+ "noGroup": "No group",
109
115
  "howTitle": "Sessions you open show up here",
110
116
  "howLabel": "How sessions show up here",
111
117
  "howRemoteBefore": "In a running pw code session, run",
@@ -131,7 +137,9 @@
131
137
  "running": "running",
132
138
  "awaiting_approval": "approval needed",
133
139
  "awaiting_answer": "answer needed",
134
- "live_elsewhere": "live on {host}"
140
+ "live_elsewhere": "live on {host}",
141
+ "usage_limit": "usage limit reached",
142
+ "usage_limit_until": "limit resets {time}"
135
143
  },
136
144
  "machine": {
137
145
  "connected": "connected",
@@ -139,13 +147,22 @@
139
147
  "no_agent": "no agent",
140
148
  "unreachable": "unreachable",
141
149
  "unsupported_agent": "agent too old",
150
+ "starting": "starting",
142
151
  "noDaemonHint": "pw code is not running on this machine. Run pw code in a terminal there to start it.",
143
152
  "noAgentHint": "No pw agent is connected from this machine.",
144
153
  "unreachableHint": "Not responding. Its sessions cannot be read until it is back.",
145
154
  "unsupportedHint": "The agent on this machine is too old. Sessions cannot be read from it.",
146
155
  "unsupportedHintVersion": "Agent {version} is too old. Sessions cannot be read from it.",
147
156
  "computer": "Computer",
148
- "resource": "Resource"
157
+ "resource": "Resource",
158
+ "workspace": "Your workspace",
159
+ "workspaceDownHint": "Your workspace isn't running yet. It starts while this app is open, which can take a minute.",
160
+ "workspaceStartingHint": "Your workspace is starting, which can take a minute.",
161
+ "workspaceOutdatedHint": "The pw in your workspace is too old for pw code sessions. Restart your workspace to update it.",
162
+ "withVersion": "{kind} · pw {version}",
163
+ "withUpdate": "{kind} · pw update available",
164
+ "unsupportedComputerHint": "pw on this computer is too old for sessions on the web. Run pw upgrade there to update it.",
165
+ "unsupportedComputerHintVersion": "pw {version} on this computer is too old for sessions on the web. Run pw upgrade there to update it."
149
166
  },
150
167
  "detail": {
151
168
  "commandsLabel": "Commands",
@@ -183,7 +200,7 @@
183
200
  "unreachableBody": "Sessions are read live from the machine, so nothing new can be shown until it is reachable again.",
184
201
  "checkAgain": "Check again",
185
202
  "transcriptEnds": "End of transcript. This is the last state read from {machine}.",
186
- "untrusted": "Settings, skills, and hooks in this workspace were not loaded because it has not been trusted. Trust it from a local pw code run on the machine, then resume.",
203
+ "untrusted": "Settings, skills, and hooks in this workspace were not loaded because it isn't trusted. To trust it, open a terminal on {machine}, run pw code in {workspace}, and answer y when it asks to apply them. Sessions you start there afterwards load them.",
187
204
  "reconnecting": "Live updates disconnected. Reconnecting…",
188
205
  "waitingForUsageLimit": "Waiting for the usage limit to reset",
189
206
  "waitingForUsageLimitUntil": "Waiting for the usage limit to reset at {time}",
@@ -264,6 +281,7 @@
264
281
  "checkingGoal": "Checking the goal",
265
282
  "compacted": "Compacted",
266
283
  "compactedAutomatically": "✻ Conversation compacted",
284
+ "compacting": "Compacting conversation",
267
285
  "recap": "Recap: {recap}",
268
286
  "goalDetail": "Goal: {condition}\n\nReason: {reason}",
269
287
  "turnEnd": "✻ {verb, select, baked {Baked} brewed {Brewed} churned {Churned} cogitated {Cogitated} cooked {Cooked} crunched {Crunched} sauteed {Sautéed} other {Worked}} for {duration} · done {time}",
@@ -272,6 +290,8 @@
272
290
  "turnMinutes": "{minutes}m {seconds}s",
273
291
  "turnHours": "{hours}h {minutes}m",
274
292
  "planOpened": "Opened plan in editor: {path}",
293
+ "skillActivated": "{source, select, user {Activated user skill} project {Activated project skill} builtin {Activated built-in skill} other {Activated skill}}",
294
+ "skillUntrusted": "{activated} · its shell commands and allowed tools stay off until you run /skills trust {name}",
275
295
  "subagentMessage": "Message from {name}",
276
296
  "commandCompleted": "Background command \"{name}\" completed (exit code 0)",
277
297
  "commandFailed": "Background command \"{name}\" failed with exit code {code}",
@@ -282,6 +302,8 @@
282
302
  "monitorFlooded": "Monitor \"{name}\" stopped after {elapsed} of too much output",
283
303
  "agentEnded": "Agent \"{name}\" {outcome, select, failed {failed} other {finished}}",
284
304
  "agentEndedAfter": "Agent \"{name}\" {outcome, select, failed {failed} other {finished}} · {elapsed}",
305
+ "scheduledTask": "✻ Started by scheduled task {id}",
306
+ "loopWakeup": "✻ Started by a /loop wakeup",
285
307
  "expandAll": "Expand all",
286
308
  "collapseAll": "Collapse all"
287
309
  },
@@ -299,6 +321,7 @@
299
321
  "hideEarlier": "{count, plural, one {Hide # earlier agent} other {Hide # earlier agents}}",
300
322
  "agentName": "{type}: {description}",
301
323
  "stop": "Stop {name}",
324
+ "dismiss": "Remove {name} from the list",
302
325
  "stopThis": "Stop",
303
326
  "back": "Back to main",
304
327
  "tokens": "{tokens} tokens",
@@ -313,6 +336,12 @@
313
336
  "commandsOnMain": "Commands and ! run in the main conversation. Go back to main to use them.",
314
337
  "transcriptLabel": "Agent transcript"
315
338
  },
339
+ "tasks": {
340
+ "progress": "{done} of {total} done",
341
+ "more": "+{count} more",
342
+ "moreCompleted": "+{count} completed",
343
+ "fewer": "Show fewer"
344
+ },
316
345
  "effort": {
317
346
  "label": "Effort",
318
347
  "named": "Effort: {level}",
@@ -409,12 +438,16 @@
409
438
  "expired": "Sign-in expired. Try again."
410
439
  },
411
440
  "useAccount": "Use",
412
- "accountActions": "Actions for {account}"
441
+ "accountActions": "Actions for {account}",
442
+ "continueOnAnother": "Continue on another account",
443
+ "moveOthers": "{count, plural, one {Also move # other session on {account}} other {Also move # other sessions on {account}}}",
444
+ "movedOthers": "{count, plural, =0 {No other session moved to {account}} one {Moved # other session to {account}} other {Moved # other sessions to {account}}}"
413
445
  },
414
446
  "terminal": {
415
447
  "title": "Continue in a terminal",
416
448
  "resourceBody": "Picks up this conversation in pw code. It keeps running on {machine}, and this page follows along.",
417
449
  "computerBody": "This session runs on {host}. Run this in a terminal there to pick it up in pw code. This page follows along.",
450
+ "workspaceBody": "This session runs in your workspace. Run this in a terminal there to pick it up in pw code. This page follows along.",
418
451
  "anyTerminal": "Works in any terminal signed in to pw.",
419
452
  "archived": "Picking it up brings it back from Archived.",
420
453
  "open": "Open in terminal",
@@ -422,5 +455,14 @@
422
455
  "commandLabel": "terminal command",
423
456
  "machineLoading": "Looking up this session’s machine…",
424
457
  "machineMissing": "This session’s machine is not listed right now, so there is no command for it yet."
458
+ },
459
+ "pwUpdate": {
460
+ "available": "pw {version} is available for {machine}, which runs {running}.",
461
+ "availableElsewhere": "pw {version} is available for {machine}, which runs {running}. Run pw upgrade there to install it.",
462
+ "failed": "pw {version} didn't install on {machine}: {error}",
463
+ "installing": "Installing pw {version} on {machine}",
464
+ "installed": "pw {version} is installed on {machine}. {os, select, windows {pw code switches to it once no session there is open.} other {Its sessions move onto it as each finishes what it's doing.}}",
465
+ "needsAdmin": "pw {version} is available for {machine}, but only an administrator can replace {path} there.",
466
+ "update": "Update pw"
425
467
  }
426
468
  }
@@ -62,7 +62,8 @@
62
62
  "noPreview": "Esta opción no tiene vista previa",
63
63
  "previewOf": "Vista previa: {label}",
64
64
  "notesLabel": "Notas",
65
- "notesPlaceholder": "Añade notas sobre este diseño…",
65
+ "notesPlaceholder": "Añade notas…",
66
+ "addNotes": "Añadir notas",
66
67
  "notesOnly": "(solo notas)",
67
68
  "todoPending": "Pendiente",
68
69
  "todoInProgress": "En curso",
@@ -150,7 +151,10 @@
150
151
  },
151
152
  "input": {
152
153
  "stopGenerating": "Detener generación (Escape)",
153
- "loadingCommands": "Cargando comandos..."
154
+ "loadingCommands": "Cargando comandos...",
155
+ "emoji": "Emojis",
156
+ "shellMode": "modo shell",
157
+ "shellHint": "Enter lo ejecuta en la máquina de la sesión y su salida se añade a la conversación"
154
158
  },
155
159
  "thread": {
156
160
  "jumpToPrompt": "Ir al mensaje: {text}"