@parallelworks/code 0.4.0 → 0.5.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 (77) hide show
  1. package/README.md +39 -12
  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 +200 -0
  7. package/dist/chatStrings.d.ts +1 -0
  8. package/dist/chatStrings.js +2 -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 +5 -1
  14. package/dist/command.js +6 -1
  15. package/dist/createPwCodeApi.d.ts +70 -1
  16. package/dist/createPwCodeApi.js +4 -2
  17. package/dist/index.d.ts +5 -4
  18. package/dist/index.js +5 -4
  19. package/dist/locales/en/agentTranscript.js +2 -1
  20. package/dist/locales/en/agents.js +16 -3
  21. package/dist/locales/en.d.ts +13 -0
  22. package/dist/locales/es/agentTranscript.js +2 -1
  23. package/dist/locales/es/agents.js +16 -3
  24. package/dist/locales/ja/agentTranscript.js +2 -1
  25. package/dist/locales/ja/agents.js +16 -3
  26. package/dist/locales/ko/agentTranscript.js +2 -1
  27. package/dist/locales/ko/agents.js +16 -3
  28. package/dist/locales/zh/agentTranscript.js +2 -1
  29. package/dist/locales/zh/agents.js +16 -3
  30. package/dist/notices.d.ts +2 -0
  31. package/dist/notices.js +20 -13
  32. package/dist/query.d.ts +4 -1
  33. package/dist/query.js +9 -3
  34. package/dist/session.d.ts +6 -0
  35. package/dist/session.js +5 -1
  36. package/dist/sessionEvents.d.ts +29 -2
  37. package/dist/sessionEvents.js +187 -73
  38. package/dist/sessionGroups.d.ts +3 -3
  39. package/dist/sessionGroups.js +3 -3
  40. package/dist/sessionHeader.js +6 -2
  41. package/dist/sessionList.d.ts +13 -8
  42. package/dist/sessionList.js +20 -10
  43. package/dist/sessionScreen.d.ts +5 -1
  44. package/dist/sessionScreen.js +12 -7
  45. package/dist/sessionsApi.d.ts +19 -3
  46. package/dist/sessionsApi.js +100 -12
  47. package/dist/sessionsFeed.d.ts +22 -0
  48. package/dist/sessionsFeed.js +125 -0
  49. package/dist/todos.d.ts +42 -0
  50. package/dist/todos.js +104 -0
  51. package/dist/transcript.d.ts +1 -2
  52. package/dist/transcript.js +63 -102
  53. package/dist/transcriptRead.d.ts +56 -0
  54. package/dist/transcriptRead.js +121 -0
  55. package/dist/useComposer.d.ts +14 -5
  56. package/dist/useComposer.js +20 -7
  57. package/dist/useComposerImages.js +3 -4
  58. package/dist/useComposerPastes.js +3 -8
  59. package/dist/useConversation.d.ts +6 -0
  60. package/dist/useConversation.js +72 -5
  61. package/dist/useMounted.d.ts +3 -0
  62. package/dist/useMounted.js +14 -0
  63. package/dist/useSubagent.d.ts +2 -0
  64. package/dist/useSubagent.js +2 -0
  65. package/dist/wording.d.ts +5 -2
  66. package/dist/wording.js +6 -4
  67. package/locales/en/agentTranscript.json +2 -1
  68. package/locales/en/agents.json +14 -2
  69. package/locales/es/agentTranscript.json +2 -1
  70. package/locales/es/agents.json +14 -2
  71. package/locales/ja/agentTranscript.json +2 -1
  72. package/locales/ja/agents.json +14 -2
  73. package/locales/ko/agentTranscript.json +2 -1
  74. package/locales/ko/agents.json +14 -2
  75. package/locales/zh/agentTranscript.json +2 -1
  76. package/locales/zh/agents.json +14 -2
  77. package/package.json +2 -2
@@ -131,7 +131,9 @@ var status = {
131
131
  "running": "running",
132
132
  "awaiting_approval": "approval needed",
133
133
  "awaiting_answer": "answer needed",
134
- "live_elsewhere": "live on {host}"
134
+ "live_elsewhere": "live on {host}",
135
+ "usage_limit": "usage limit reached",
136
+ "usage_limit_until": "limit resets {time}"
135
137
  };
136
138
  var machine = {
137
139
  "connected": "connected",
@@ -299,6 +301,7 @@ var switcher = {
299
301
  "hideEarlier": "{count, plural, one {Hide # earlier agent} other {Hide # earlier agents}}",
300
302
  "agentName": "{type}: {description}",
301
303
  "stop": "Stop {name}",
304
+ "dismiss": "Remove {name} from the list",
302
305
  "stopThis": "Stop",
303
306
  "back": "Back to main",
304
307
  "tokens": "{tokens} tokens",
@@ -313,6 +316,12 @@ var switcher = {
313
316
  "commandsOnMain": "Commands and ! run in the main conversation. Go back to main to use them.",
314
317
  "transcriptLabel": "Agent transcript"
315
318
  };
319
+ var tasks = {
320
+ "progress": "{done} of {total} done",
321
+ "more": "+{count} more",
322
+ "moreCompleted": "+{count} completed",
323
+ "fewer": "Show fewer"
324
+ };
316
325
  var effort = {
317
326
  "label": "Effort",
318
327
  "named": "Effort: {level}",
@@ -409,7 +418,10 @@ var claude = {
409
418
  "expired": "Sign-in expired. Try again."
410
419
  },
411
420
  "useAccount": "Use",
412
- "accountActions": "Actions for {account}"
421
+ "accountActions": "Actions for {account}",
422
+ "continueOnAnother": "Continue on another account",
423
+ "moveOthers": "{count, plural, one {Also move # other session on {account}} other {Also move # other sessions on {account}}}",
424
+ "movedOthers": "{count, plural, =0 {No other session moved to {account}} one {Moved # other session to {account}} other {Moved # other sessions to {account}}}"
413
425
  };
414
426
  var terminal = {
415
427
  "title": "Continue in a terminal",
@@ -432,6 +444,7 @@ var agents_default = {
432
444
  machine,
433
445
  detail,
434
446
  switcher,
447
+ tasks,
435
448
  effort,
436
449
  permission,
437
450
  allocation,
@@ -439,4 +452,4 @@ var agents_default = {
439
452
  claude,
440
453
  terminal
441
454
  };
442
- export { ago, allocation, claude, dash, agents_default as default, detail, effort, machine, permission, sidebar, start, status, switcher, terminal, title };
455
+ export { ago, allocation, claude, dash, agents_default as default, detail, effort, machine, permission, sidebar, start, status, switcher, tasks, terminal, title };
@@ -152,6 +152,7 @@ declare const messages: {
152
152
  input: {
153
153
  stopGenerating: string;
154
154
  loadingCommands: string;
155
+ emoji: string;
155
156
  };
156
157
  thread: {
157
158
  jumpToPrompt: string;
@@ -343,6 +344,8 @@ declare const messages: {
343
344
  awaiting_approval: string;
344
345
  awaiting_answer: string;
345
346
  live_elsewhere: string;
347
+ usage_limit: string;
348
+ usage_limit_until: string;
346
349
  };
347
350
  machine: {
348
351
  connected: string;
@@ -510,6 +513,7 @@ declare const messages: {
510
513
  hideEarlier: string;
511
514
  agentName: string;
512
515
  stop: string;
516
+ dismiss: string;
513
517
  stopThis: string;
514
518
  back: string;
515
519
  tokens: string;
@@ -524,6 +528,12 @@ declare const messages: {
524
528
  commandsOnMain: string;
525
529
  transcriptLabel: string;
526
530
  };
531
+ tasks: {
532
+ progress: string;
533
+ more: string;
534
+ moreCompleted: string;
535
+ fewer: string;
536
+ };
527
537
  effort: {
528
538
  label: string;
529
539
  named: string;
@@ -621,6 +631,9 @@ declare const messages: {
621
631
  };
622
632
  useAccount: string;
623
633
  accountActions: string;
634
+ continueOnAnother: string;
635
+ moveOthers: string;
636
+ movedOthers: string;
624
637
  };
625
638
  terminal: {
626
639
  title: string;
@@ -150,7 +150,8 @@ var activity = {
150
150
  };
151
151
  var input = {
152
152
  "stopGenerating": "Detener generación (Escape)",
153
- "loadingCommands": "Cargando comandos..."
153
+ "loadingCommands": "Cargando comandos...",
154
+ "emoji": "Emojis"
154
155
  };
155
156
  var thread = { "jumpToPrompt": "Ir al mensaje: {text}" };
156
157
  var find = {
@@ -131,7 +131,9 @@ var status = {
131
131
  "running": "en ejecución",
132
132
  "awaiting_approval": "aprobación necesaria",
133
133
  "awaiting_answer": "respuesta necesaria",
134
- "live_elsewhere": "activa en {host}"
134
+ "live_elsewhere": "activa en {host}",
135
+ "usage_limit": "límite de uso alcanzado",
136
+ "usage_limit_until": "límite hasta {time}"
135
137
  };
136
138
  var machine = {
137
139
  "connected": "conectada",
@@ -299,6 +301,7 @@ var switcher = {
299
301
  "hideEarlier": "{count, plural, one {Ocultar # agente anterior} other {Ocultar # agentes anteriores}}",
300
302
  "agentName": "{type}: {description}",
301
303
  "stop": "Detener {name}",
304
+ "dismiss": "Quitar {name} de la lista",
302
305
  "stopThis": "Detener",
303
306
  "back": "Volver a la principal",
304
307
  "tokens": "{tokens} tokens",
@@ -313,6 +316,12 @@ var switcher = {
313
316
  "commandsOnMain": "Los comandos y ! se ejecutan en la conversación principal. Vuelve a ella para usarlos.",
314
317
  "transcriptLabel": "Transcripción del agente"
315
318
  };
319
+ var tasks = {
320
+ "progress": "{done} de {total} hechas",
321
+ "more": "+{count} más",
322
+ "moreCompleted": "+{count} completadas",
323
+ "fewer": "Mostrar menos"
324
+ };
316
325
  var effort = {
317
326
  "label": "Esfuerzo",
318
327
  "named": "Esfuerzo: {level}",
@@ -409,7 +418,10 @@ var claude = {
409
418
  "expired": "El inicio de sesión ha caducado. Vuelve a intentarlo."
410
419
  },
411
420
  "useAccount": "Usar",
412
- "accountActions": "Acciones de {account}"
421
+ "accountActions": "Acciones de {account}",
422
+ "continueOnAnother": "Continuar en otra cuenta",
423
+ "moveOthers": "{count, plural, one {Mover también # sesión más de {account}} other {Mover también # sesiones más de {account}}}",
424
+ "movedOthers": "{count, plural, =0 {Ninguna otra sesión se movió a {account}} one {Se movió # sesión más a {account}} other {Se movieron # sesiones más a {account}}}"
413
425
  };
414
426
  var terminal = {
415
427
  "title": "Continuar en una terminal",
@@ -432,6 +444,7 @@ var agents_default = {
432
444
  machine,
433
445
  detail,
434
446
  switcher,
447
+ tasks,
435
448
  effort,
436
449
  permission,
437
450
  allocation,
@@ -439,4 +452,4 @@ var agents_default = {
439
452
  claude,
440
453
  terminal
441
454
  };
442
- export { ago, allocation, claude, dash, agents_default as default, detail, effort, machine, permission, sidebar, start, status, switcher, terminal, title };
455
+ export { ago, allocation, claude, dash, agents_default as default, detail, effort, machine, permission, sidebar, start, status, switcher, tasks, terminal, title };
@@ -150,7 +150,8 @@ var activity = {
150
150
  };
151
151
  var input = {
152
152
  "stopGenerating": "生成を停止 (Escape)",
153
- "loadingCommands": "コマンドを読み込み中..."
153
+ "loadingCommands": "コマンドを読み込み中...",
154
+ "emoji": "絵文字"
154
155
  };
155
156
  var thread = { "jumpToPrompt": "メッセージへ移動: {text}" };
156
157
  var find = {
@@ -131,7 +131,9 @@ var status = {
131
131
  "running": "実行中",
132
132
  "awaiting_approval": "承認が必要",
133
133
  "awaiting_answer": "回答が必要",
134
- "live_elsewhere": "{host} で稼働中"
134
+ "live_elsewhere": "{host} で稼働中",
135
+ "usage_limit": "使用量の上限に到達",
136
+ "usage_limit_until": "上限は {time} にリセット"
135
137
  };
136
138
  var machine = {
137
139
  "connected": "接続済み",
@@ -162,6 +164,7 @@ var switcher = {
162
164
  "hideEarlier": "以前のエージェント{count}件を隠す",
163
165
  "agentName": "{type}: {description}",
164
166
  "stop": "{name} を停止",
167
+ "dismiss": "{name} を一覧から外す",
165
168
  "stopThis": "停止",
166
169
  "back": "メインに戻る",
167
170
  "tokens": "{tokens} トークン",
@@ -176,6 +179,12 @@ var switcher = {
176
179
  "commandsOnMain": "コマンドと ! はメインの会話で実行されます。使うにはメインに戻ってください。",
177
180
  "transcriptLabel": "エージェントのトランスクリプト"
178
181
  };
182
+ var tasks = {
183
+ "progress": "{total} 件中 {done} 件完了",
184
+ "more": "ほか {count} 件",
185
+ "moreCompleted": "ほか {count} 件完了",
186
+ "fewer": "表示を減らす"
187
+ };
179
188
  var effort = {
180
189
  "label": "推論の強度",
181
190
  "named": "推論の強度:{level}",
@@ -272,7 +281,10 @@ var claude = {
272
281
  "expired": "ログインの有効期限が切れました。再試行してください。"
273
282
  },
274
283
  "useAccount": "使用する",
275
- "accountActions": "{account} の操作"
284
+ "accountActions": "{account} の操作",
285
+ "continueOnAnother": "別のアカウントで続行",
286
+ "moveOthers": "{count, plural, other {{account} の他の # 件のセッションも移動}}",
287
+ "movedOthers": "{count, plural, =0 {{account} に移動した他のセッションはありません} other {他の # 件のセッションを {account} に移動しました}}"
276
288
  };
277
289
  var terminal = {
278
290
  "title": "ターミナルで続ける",
@@ -295,6 +307,7 @@ var agents_default = {
295
307
  machine,
296
308
  detail,
297
309
  switcher,
310
+ tasks,
298
311
  effort,
299
312
  permission,
300
313
  allocation,
@@ -302,4 +315,4 @@ var agents_default = {
302
315
  claude,
303
316
  terminal
304
317
  };
305
- export { ago, allocation, claude, dash, agents_default as default, detail, effort, machine, permission, sidebar, start, status, switcher, terminal, title };
318
+ export { ago, allocation, claude, dash, agents_default as default, detail, effort, machine, permission, sidebar, start, status, switcher, tasks, terminal, title };
@@ -150,7 +150,8 @@ var activity = {
150
150
  };
151
151
  var input = {
152
152
  "stopGenerating": "생성 중지 (Escape)",
153
- "loadingCommands": "명령 불러오는 중..."
153
+ "loadingCommands": "명령 불러오는 중...",
154
+ "emoji": "이모지"
154
155
  };
155
156
  var thread = { "jumpToPrompt": "메시지로 이동: {text}" };
156
157
  var find = {
@@ -131,7 +131,9 @@ var status = {
131
131
  "running": "실행 중",
132
132
  "awaiting_approval": "승인 필요",
133
133
  "awaiting_answer": "답변 필요",
134
- "live_elsewhere": "{host}에서 실행 중"
134
+ "live_elsewhere": "{host}에서 실행 중",
135
+ "usage_limit": "사용량 한도 도달",
136
+ "usage_limit_until": "한도 {time}에 초기화"
135
137
  };
136
138
  var machine = {
137
139
  "connected": "연결됨",
@@ -299,6 +301,7 @@ var switcher = {
299
301
  "hideEarlier": "이전 에이전트 {count}개 숨기기",
300
302
  "agentName": "{type}: {description}",
301
303
  "stop": "{name} 중지",
304
+ "dismiss": "목록에서 {name} 제거",
302
305
  "stopThis": "중지",
303
306
  "back": "메인으로 돌아가기",
304
307
  "tokens": "{tokens} 토큰",
@@ -313,6 +316,12 @@ var switcher = {
313
316
  "commandsOnMain": "명령과 ! 는 메인 대화에서 실행됩니다. 사용하려면 메인으로 돌아가세요.",
314
317
  "transcriptLabel": "에이전트 기록"
315
318
  };
319
+ var tasks = {
320
+ "progress": "{total}개 중 {done}개 완료",
321
+ "more": "+{count}개 더",
322
+ "moreCompleted": "+{count}개 완료",
323
+ "fewer": "간단히 보기"
324
+ };
316
325
  var effort = {
317
326
  "label": "추론 강도",
318
327
  "named": "추론 강도: {level}",
@@ -409,7 +418,10 @@ var claude = {
409
418
  "expired": "로그인이 만료되었습니다. 다시 시도하세요."
410
419
  },
411
420
  "useAccount": "사용",
412
- "accountActions": "{account} 작업"
421
+ "accountActions": "{account} 작업",
422
+ "continueOnAnother": "다른 계정으로 계속",
423
+ "moveOthers": "{count, plural, other {{account}의 다른 세션 #개도 이동}}",
424
+ "movedOthers": "{count, plural, =0 {{account}(으)로 이동한 다른 세션이 없습니다} other {다른 세션 #개를 {account}(으)로 이동했습니다}}"
413
425
  };
414
426
  var terminal = {
415
427
  "title": "터미널에서 계속하기",
@@ -432,6 +444,7 @@ var agents_default = {
432
444
  machine,
433
445
  detail,
434
446
  switcher,
447
+ tasks,
435
448
  effort,
436
449
  permission,
437
450
  allocation,
@@ -439,4 +452,4 @@ var agents_default = {
439
452
  claude,
440
453
  terminal
441
454
  };
442
- export { ago, allocation, claude, dash, agents_default as default, detail, effort, machine, permission, sidebar, start, status, switcher, terminal, title };
455
+ export { ago, allocation, claude, dash, agents_default as default, detail, effort, machine, permission, sidebar, start, status, switcher, tasks, terminal, title };
@@ -150,7 +150,8 @@ var activity = {
150
150
  };
151
151
  var input = {
152
152
  "stopGenerating": "停止生成 (Escape)",
153
- "loadingCommands": "正在加载命令..."
153
+ "loadingCommands": "正在加载命令...",
154
+ "emoji": "表情符号"
154
155
  };
155
156
  var thread = { "jumpToPrompt": "跳到消息:{text}" };
156
157
  var find = {
@@ -131,7 +131,9 @@ var status = {
131
131
  "running": "运行中",
132
132
  "awaiting_approval": "需要批准",
133
133
  "awaiting_answer": "需要回答",
134
- "live_elsewhere": "在 {host} 上运行"
134
+ "live_elsewhere": "在 {host} 上运行",
135
+ "usage_limit": "已达用量上限",
136
+ "usage_limit_until": "上限于 {time} 重置"
135
137
  };
136
138
  var machine = {
137
139
  "connected": "已连接",
@@ -299,6 +301,7 @@ var switcher = {
299
301
  "hideEarlier": "隐藏 {count} 个较早的代理",
300
302
  "agentName": "{type}: {description}",
301
303
  "stop": "停止 {name}",
304
+ "dismiss": "从列表中移除 {name}",
302
305
  "stopThis": "停止",
303
306
  "back": "返回主对话",
304
307
  "tokens": "{tokens} 个令牌",
@@ -313,6 +316,12 @@ var switcher = {
313
316
  "commandsOnMain": "命令和 ! 在主对话中运行。请返回主对话后使用。",
314
317
  "transcriptLabel": "代理记录"
315
318
  };
319
+ var tasks = {
320
+ "progress": "已完成 {done}/{total}",
321
+ "more": "另外 {count} 项",
322
+ "moreCompleted": "另外 {count} 项已完成",
323
+ "fewer": "收起"
324
+ };
316
325
  var effort = {
317
326
  "label": "推理强度",
318
327
  "named": "推理强度:{level}",
@@ -409,7 +418,10 @@ var claude = {
409
418
  "expired": "登录已过期。请重试。"
410
419
  },
411
420
  "useAccount": "使用",
412
- "accountActions": "{account} 的操作"
421
+ "accountActions": "{account} 的操作",
422
+ "continueOnAnother": "改用其他账户继续",
423
+ "moveOthers": "{count, plural, other {同时移动 {account} 上的其他 # 个会话}}",
424
+ "movedOthers": "{count, plural, =0 {没有其他会话移至 {account}} other {已将其他 # 个会话移至 {account}}}"
413
425
  };
414
426
  var terminal = {
415
427
  "title": "在终端中继续",
@@ -432,6 +444,7 @@ var agents_default = {
432
444
  machine,
433
445
  detail,
434
446
  switcher,
447
+ tasks,
435
448
  effort,
436
449
  permission,
437
450
  allocation,
@@ -439,4 +452,4 @@ var agents_default = {
439
452
  claude,
440
453
  terminal
441
454
  };
442
- export { ago, allocation, claude, dash, agents_default as default, detail, effort, machine, permission, sidebar, start, status, switcher, terminal, title };
455
+ export { ago, allocation, claude, dash, agents_default as default, detail, effort, machine, permission, sidebar, start, status, switcher, tasks, terminal, title };
package/dist/notices.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { type PwCodeTranslator } from './messages.js';
2
2
  import type { CompactionNotice, GoalNotice, RecapNotice, TranscriptWords } from './transcript.js';
3
+ /** When a usage limit resets, short enough for a row in a list of sessions. */
4
+ export declare function useResumeClock(): (at: string) => string;
3
5
  /** When a usage limit resets, as a session's notices name it. */
4
6
  export declare function useResumeTime(): (at: string) => string;
5
7
  export declare function useGoalNotice(): GoalNotice;
package/dist/notices.js CHANGED
@@ -6,6 +6,24 @@ import { useFormatter, useLocale } from "use-intl";
6
6
  import { DateTime } from "luxon";
7
7
  import { formatDuration } from "@parallelworks/ui/headless";
8
8
  // src/notices.ts
9
+ /** The time of day on the day itself, with the weekday within a week and the date beyond. */
10
+ function nearTime(format, at, weekday) {
11
+ const days = Math.abs(Math.round(DateTime.now().startOf("day").diff(at.startOf("day"), "days").days));
12
+ return format.dateTime(at.toJSDate(), {
13
+ hour: "numeric",
14
+ minute: "2-digit",
15
+ ...days > 0 ? { weekday } : {},
16
+ ...days >= 7 ? {
17
+ month: "short",
18
+ day: "numeric"
19
+ } : {}
20
+ });
21
+ }
22
+ /** When a usage limit resets, short enough for a row in a list of sessions. */
23
+ function useResumeClock() {
24
+ const format = useFormatter();
25
+ return useCallback((at) => nearTime(format, DateTime.fromISO(at), "short"), [format]);
26
+ }
9
27
  /** When a usage limit resets, as a session's notices name it. */
10
28
  function useResumeTime() {
11
29
  const format = useFormatter();
@@ -118,21 +136,10 @@ function useTranscriptWords() {
118
136
  }),
119
137
  turnEnd: (te, verb, waiting) => {
120
138
  if (waiting) return t("detail.turnEndWaiting", { count: te.pendingAgents ?? 0 });
121
- const ended = DateTime.fromISO(te.endedAt);
122
- const days = Math.floor(DateTime.now().startOf("day").diff(ended.startOf("day"), "days").days);
123
- const time = format.dateTime(ended.toJSDate(), {
124
- hour: "numeric",
125
- minute: "2-digit",
126
- ...days > 0 ? { weekday: "long" } : {},
127
- ...days >= 7 ? {
128
- month: "short",
129
- day: "numeric"
130
- } : {}
131
- });
132
139
  return t("detail.turnEnd", {
133
140
  verb,
134
141
  duration: turnDuration(t, te.durationMs),
135
- time
142
+ time: nearTime(format, DateTime.fromISO(te.endedAt), "long")
136
143
  });
137
144
  },
138
145
  planAnswer: (path, opened) => opened ? t("detail.planOpened", { path }) : path,
@@ -145,4 +152,4 @@ function useTranscriptWords() {
145
152
  format
146
153
  ]);
147
154
  }
148
- export { turnDuration, useCompactionNotice, useGoalNotice, useRecapNotice, useResumeTime, useTranscriptWords };
155
+ export { turnDuration, useCompactionNotice, useGoalNotice, useRecapNotice, useResumeClock, useResumeTime, useTranscriptWords };
package/dist/query.d.ts CHANGED
@@ -28,5 +28,8 @@ export type ReadData<P extends ReadPath> = PwCodePaths[P] extends {
28
28
  * With `giveUpWhenLeft` a read still on its way when the hook stops showing
29
29
  * its key is aborted, for a large read only this hook shows: the connection
30
30
  * goes to what the reader moved on to. */
31
- export declare function createQuery(client: PwCodeClient): <P extends ReadPath>(path: P, init: ReadInit<P> | null, config?: SWRConfiguration<ReadData<P>, PwCodeApiError>, giveUpWhenLeft?: boolean) => SWRResponse<ReadData<P>, PwCodeApiError>;
31
+ export declare function createQuery(client: PwCodeClient): <P extends ReadPath>(path: P, init: ReadInit<P> | null, config?: SWRConfiguration<ReadData<P>, PwCodeApiError>, giveUpWhenLeft?: boolean,
32
+ /** Reads the key some other way than a GET of `path`; `name` is the key,
33
+ * serialized. It throws what the client answered with. */
34
+ readWith?: (name: string, signal: AbortSignal | undefined) => Promise<ReadData<P>>) => SWRResponse<ReadData<P>, PwCodeApiError>;
32
35
  export {};
package/dist/query.js CHANGED
@@ -44,7 +44,7 @@ function useGivingUp(shown) {
44
44
  * goes to what the reader moved on to. */
45
45
  function createQuery(client) {
46
46
  const reader = client;
47
- return function useQuery(path, init, config, giveUpWhenLeft = false) {
47
+ return function useQuery(path, init, config, giveUpWhenLeft = false, readWith) {
48
48
  const key = useMemo(() => init !== null ? [
49
49
  "api",
50
50
  path,
@@ -53,7 +53,9 @@ function createQuery(client) {
53
53
  const leaving = useGivingUp(giveUpWhenLeft && key ? unstable_serialize(key) : void 0);
54
54
  const fetcher = useCallback((read) => {
55
55
  const [, route, options] = read;
56
+ const name = unstable_serialize(read);
56
57
  const get = async (signal) => {
58
+ if (readWith) return readWith(name, signal);
57
59
  const { data, error } = await reader.GET(route, signal ? {
58
60
  ...options,
59
61
  signal
@@ -61,8 +63,12 @@ function createQuery(client) {
61
63
  if (error) throw error;
62
64
  return data;
63
65
  };
64
- return giveUpWhenLeft ? leaving(unstable_serialize(read), get) : get();
65
- }, [giveUpWhenLeft, leaving]);
66
+ return giveUpWhenLeft ? leaving(name, get) : get();
67
+ }, [
68
+ giveUpWhenLeft,
69
+ leaving,
70
+ readWith
71
+ ]);
66
72
  const shared = useSWRConfig();
67
73
  const retry = config?.shouldRetryOnError ?? shared.shouldRetryOnError;
68
74
  const onError = config?.onError ?? shared.onError;
package/dist/session.d.ts CHANGED
@@ -23,6 +23,10 @@ export interface PwCodeSession {
23
23
  createdAt?: string | undefined;
24
24
  updatedAt?: string | undefined;
25
25
  turnStartedAt?: string | undefined;
26
+ /** The running turn waits for a usage limit to reset. */
27
+ waitingForUsageLimit?: boolean | undefined;
28
+ /** When that usage limit resets, once the machine knows. */
29
+ usageLimitResumeAt?: string | undefined;
26
30
  workspace?: string | undefined;
27
31
  }
28
32
  /** The approvals a session waits on, as far as their kinds. */
@@ -49,6 +53,8 @@ export declare function sessionClock(s: Pick<PwCodeSession, 'status' | 'turnStar
49
53
  export declare function isActiveSession(s: Pick<PwCodeSession, 'status' | 'liveHost'>): boolean;
50
54
  /** The daemon lists archived sessions too and leaves hiding them to its clients. */
51
55
  export declare function isArchived(s: Pick<PwCodeSession, 'archivedAt'>): boolean;
56
+ /** The running turn is held until a usage limit resets, and goes on by itself then. */
57
+ export declare function waitsOnUsageLimit(s: Pick<PwCodeSession, 'status' | 'waitingForUsageLimit'>): boolean;
52
58
  /** A turn is in flight: there is work to stop, and the daemon refuses a fork. */
53
59
  export declare function isMidTurn(s: Pick<PwCodeSession, 'status'>): boolean;
54
60
  /** A dropped machine outranks the session state: it reads as the machine's
package/dist/session.js CHANGED
@@ -50,6 +50,10 @@ function isActiveSession(s) {
50
50
  function isArchived(s) {
51
51
  return !!s.archivedAt;
52
52
  }
53
+ /** The running turn is held until a usage limit resets, and goes on by itself then. */
54
+ function waitsOnUsageLimit(s) {
55
+ return s.status === "running" && !!s.waitingForUsageLimit;
56
+ }
53
57
  /** A turn is in flight: there is work to stop, and the daemon refuses a fork. */
54
58
  function isMidTurn(s) {
55
59
  return s.status === "running" || s.status === "awaiting_approval";
@@ -112,4 +116,4 @@ function triageSessions(sessions, machineById) {
112
116
  idle: rest.filter((s) => s.status !== "running")
113
117
  };
114
118
  }
115
- export { isActiveSession, isArchived, isMidTurn, isSession, needsYou, newestCreatedFirst, newestFirst, pathBasename, recentDirectories, sessionClock, sessionKey, sessionStatusVariant, sessionVariant, sharedStoreCopy, spansMachines, triageSessions, waitsOnAnswer };
119
+ export { isActiveSession, isArchived, isMidTurn, isSession, needsYou, newestCreatedFirst, newestFirst, pathBasename, recentDirectories, sessionClock, sessionKey, sessionStatusVariant, sessionVariant, sharedStoreCopy, spansMachines, triageSessions, waitsOnAnswer, waitsOnUsageLimit };
@@ -10,16 +10,42 @@ export interface PwCodeSocketOptions {
10
10
  * frames are applied as they arrive. */
11
11
  hidden?: (() => boolean) | undefined;
12
12
  }
13
+ /** The seconds between the heartbeats a feed asks the platform for. */
14
+ export declare const HEARTBEAT_S = 10;
13
15
  /** The path a session's event feed is served at, resuming after frame `after`.
14
16
  * With `previewsByRef` the images a tool read come without their previews,
15
17
  * which the host loads by URL: a preview is tens of kilobytes, and over a slow
16
18
  * connection what the session says next waits behind it. */
17
19
  export declare function sessionEventsPath(machine: string, id: string, after: number, previewsByRef?: boolean): string;
18
- /** Frames after which the list of subagents may read differently: one started
19
- * or ended, one asked for or got an approval, or a turn began or closed. */
20
+ /** Whether a frame is the heartbeat the platform sends a feed that asked for one. */
21
+ export declare function isHeartbeat(data: unknown): boolean;
22
+ /** Frames after which the list of subagents may read differently: one started,
23
+ * ended or was dismissed, one asked for or got an approval, or a turn began or closed. */
20
24
  export declare function changesSubagents(ev: StreamEvent): boolean;
21
25
  /** `machines` with each one in `fed` that the listing lost counted as connected. */
22
26
  export declare function reachedByFeed(machines: Machine[], fed: ReadonlySet<string>): Machine[];
27
+ /** What a held socket reads at each step, so its holder can change them
28
+ * without the socket reopening. */
29
+ export interface HeldSocket {
30
+ open: ((path: string) => WebSocket | Promise<WebSocket>) | undefined;
31
+ /** Read on every attempt, so a reconnect resumes where the last one left off. */
32
+ path: () => string;
33
+ /** `revived` when it is the socket that had gone silent, carrying on. */
34
+ onOpen: (revived: boolean) => void;
35
+ onMessage: (data: unknown) => void;
36
+ onClose: () => void;
37
+ /** Hands over what tries the socket at once if it is waiting to try again,
38
+ * for whoever learns its far end can be reached; returns what takes it back. */
39
+ whenReachable?: ((tryNow: () => void) => () => void) | undefined;
40
+ /** Whether a frame is the far end's heartbeat, which is no message. Once a
41
+ * socket has sent one, it is left when it says nothing for too long. */
42
+ heartbeat?: ((data: unknown) => boolean) | undefined;
43
+ }
44
+ /** Holds one socket open until the returned call, reopening it with backoff
45
+ * after it drops. */
46
+ export declare function holdSocket(latest: {
47
+ current: HeldSocket;
48
+ }, setConnected: (connected: boolean) => void): () => void;
23
49
  export declare function sessionEvents({ openSocket, hidden, previewsByRef, }: PwCodeSocketOptions & {
24
50
  previewsByRef?: boolean | undefined;
25
51
  }): {
@@ -28,5 +54,6 @@ export declare function sessionEvents({ openSocket, hidden, previewsByRef, }: Pw
28
54
  disconnected: boolean;
29
55
  };
30
56
  useFedMachines: () => ReadonlySet<string>;
57
+ listed: (machines: readonly Machine[]) => void;
31
58
  };
32
59
  export {};