@parallelworks/code 0.2.0 → 0.4.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 (126) hide show
  1. package/README.md +602 -84
  2. package/dist/accountApi.d.ts +31 -0
  3. package/dist/accountApi.js +182 -0
  4. package/dist/agentSwitcher.d.ts +109 -0
  5. package/dist/agentSwitcher.js +165 -0
  6. package/dist/ago.d.ts +8 -0
  7. package/dist/ago.js +26 -0
  8. package/dist/allocations.d.ts +41 -0
  9. package/dist/allocations.js +76 -0
  10. package/dist/api.d.ts +1213 -66
  11. package/dist/base64.d.ts +3 -0
  12. package/dist/base64.js +15 -0
  13. package/dist/chatHandoff.d.ts +12 -0
  14. package/dist/chatHandoff.js +27 -0
  15. package/dist/chatStrings.d.ts +188 -0
  16. package/dist/chatStrings.js +217 -0
  17. package/dist/claudeAccounts.d.ts +149 -0
  18. package/dist/claudeAccounts.js +328 -0
  19. package/dist/claudeApi.js +1 -1
  20. package/dist/claudeSignIn.d.ts +80 -0
  21. package/dist/claudeSignIn.js +249 -0
  22. package/dist/commandsApi.d.ts +11 -1
  23. package/dist/commandsApi.js +24 -5
  24. package/dist/contextRow.d.ts +25 -0
  25. package/dist/contextRow.js +16 -0
  26. package/dist/createPwCodeApi.d.ts +52 -5
  27. package/dist/createPwCodeApi.js +20 -2
  28. package/dist/directories.d.ts +161 -0
  29. package/dist/directories.js +301 -0
  30. package/dist/goal.d.ts +89 -0
  31. package/dist/goal.js +164 -0
  32. package/dist/howSessionsAppear.d.ts +12 -0
  33. package/dist/howSessionsAppear.js +24 -0
  34. package/dist/imageFit.d.ts +23 -0
  35. package/dist/imageFit.js +27 -0
  36. package/dist/images.d.ts +28 -0
  37. package/dist/images.js +38 -6
  38. package/dist/index.d.ts +41 -3
  39. package/dist/index.js +40 -4
  40. package/dist/loadError.d.ts +8 -0
  41. package/dist/loadError.js +19 -0
  42. package/dist/locales/en/agentTranscript.js +75 -22
  43. package/dist/locales/en/agents.js +76 -14
  44. package/dist/locales/en.d.ts +129 -21
  45. package/dist/locales/es/agentTranscript.js +75 -22
  46. package/dist/locales/es/agents.js +76 -14
  47. package/dist/locales/ja/agentTranscript.js +78 -25
  48. package/dist/locales/ja/agents.js +49 -124
  49. package/dist/locales/ko/agentTranscript.js +75 -22
  50. package/dist/locales/ko/agents.js +76 -14
  51. package/dist/locales/zh/agentTranscript.js +73 -20
  52. package/dist/locales/zh/agents.js +76 -14
  53. package/dist/machine.d.ts +4 -0
  54. package/dist/modelPicker.d.ts +79 -0
  55. package/dist/modelPicker.js +107 -0
  56. package/dist/models.d.ts +47 -0
  57. package/dist/models.js +49 -0
  58. package/dist/notices.d.ts +2 -1
  59. package/dist/notices.js +75 -21
  60. package/dist/platformDefaults.d.ts +22 -0
  61. package/dist/platformDefaults.js +30 -0
  62. package/dist/preferences.d.ts +78 -0
  63. package/dist/preferences.js +128 -0
  64. package/dist/pullRequestList.d.ts +60 -0
  65. package/dist/pullRequestList.js +125 -0
  66. package/dist/query.d.ts +6 -2
  67. package/dist/query.js +85 -10
  68. package/dist/session.d.ts +10 -2
  69. package/dist/session.js +12 -8
  70. package/dist/sessionActions.d.ts +115 -0
  71. package/dist/sessionActions.js +186 -0
  72. package/dist/sessionEvents.d.ts +8 -3
  73. package/dist/sessionEvents.js +10 -5
  74. package/dist/sessionGroups.d.ts +50 -0
  75. package/dist/sessionGroups.js +73 -0
  76. package/dist/sessionHeader.d.ts +14 -0
  77. package/dist/sessionHeader.js +16 -0
  78. package/dist/sessionList.d.ts +182 -0
  79. package/dist/sessionList.js +333 -0
  80. package/dist/sessionScreen.d.ts +193 -0
  81. package/dist/sessionScreen.js +213 -0
  82. package/dist/sessionsApi.d.ts +13 -3
  83. package/dist/sessionsApi.js +90 -33
  84. package/dist/settingsApi.d.ts +38 -0
  85. package/dist/settingsApi.js +151 -0
  86. package/dist/startPage.d.ts +153 -0
  87. package/dist/startPage.js +174 -0
  88. package/dist/startSession.d.ts +172 -0
  89. package/dist/startSession.js +256 -0
  90. package/dist/terminalHandoffPanel.d.ts +30 -0
  91. package/dist/terminalHandoffPanel.js +33 -0
  92. package/dist/transcript.d.ts +2 -0
  93. package/dist/transcript.js +62 -26
  94. package/dist/types.d.ts +11 -1
  95. package/dist/usageLimit.d.ts +8 -0
  96. package/dist/usageLimit.js +13 -0
  97. package/dist/useAwayRecap.d.ts +30 -0
  98. package/dist/useAwayRecap.js +75 -0
  99. package/dist/useComposer.d.ts +145 -0
  100. package/dist/useComposer.js +295 -0
  101. package/dist/useComposerImages.d.ts +71 -0
  102. package/dist/useComposerImages.js +218 -0
  103. package/dist/useComposerPastes.d.ts +70 -0
  104. package/dist/useComposerPastes.js +130 -0
  105. package/dist/useConversation.d.ts +199 -0
  106. package/dist/useConversation.js +314 -0
  107. package/dist/useSubagent.d.ts +104 -0
  108. package/dist/useSubagent.js +212 -0
  109. package/dist/useTranscript.d.ts +23 -3
  110. package/dist/useTranscript.js +76 -19
  111. package/dist/wording.js +2 -2
  112. package/dist/workingDirectories.d.ts +63 -0
  113. package/dist/workingDirectories.js +95 -0
  114. package/dist/worktreeChoice.d.ts +31 -0
  115. package/dist/worktreeChoice.js +38 -0
  116. package/locales/en/agentTranscript.json +69 -21
  117. package/locales/en/agents.json +73 -13
  118. package/locales/es/agentTranscript.json +69 -21
  119. package/locales/es/agents.json +73 -13
  120. package/locales/ja/agentTranscript.json +72 -24
  121. package/locales/ja/agents.json +73 -13
  122. package/locales/ko/agentTranscript.json +69 -21
  123. package/locales/ko/agents.json +73 -13
  124. package/locales/zh/agentTranscript.json +67 -19
  125. package/locales/zh/agents.json +73 -13
  126. package/package.json +6 -3
@@ -0,0 +1,3 @@
1
+ export declare function bytesToBase64(bytes: Uint8Array): string;
2
+ /** Decodes base64, URL-safe or not, padded or not. */
3
+ export declare function base64ToBytes(data: string): Uint8Array;
package/dist/base64.js ADDED
@@ -0,0 +1,15 @@
1
+ // src/base64.ts
2
+ function bytesToBase64(bytes) {
3
+ let binary = "";
4
+ for (let i = 0; i < bytes.length; i += 32768) binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
5
+ return btoa(binary);
6
+ }
7
+ /** Decodes base64, URL-safe or not, padded or not. */
8
+ function base64ToBytes(data) {
9
+ const base64 = data.replace(/-/g, "+").replace(/_/g, "/");
10
+ const binary = atob(base64 + "=".repeat((4 - base64.length % 4) % 4));
11
+ const bytes = new Uint8Array(binary.length);
12
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
13
+ return bytes;
14
+ }
15
+ export { base64ToBytes, bytesToBase64 };
@@ -0,0 +1,12 @@
1
+ import type { PwCodeTranslator } from './messages.js';
2
+ /** The parts of an AI chat conversation a session started from it reads. */
3
+ export interface PwCodeHandoffChat {
4
+ title?: string | null | undefined;
5
+ messages?: readonly {
6
+ role: string;
7
+ content?: string | null | undefined;
8
+ }[] | null | undefined;
9
+ }
10
+ /** The first turn of a session started from a chat: the reader's task, then
11
+ * the conversation it continues, newest messages kept when it is long. */
12
+ export declare function chatHandoffPrompt(conversation: PwCodeHandoffChat, task: string, t: PwCodeTranslator<'agents'>): string;
@@ -0,0 +1,27 @@
1
+ // src/chatHandoff.ts
2
+ var HANDOFF_MAX_CHARS = 5e4;
3
+ /** The first turn of a session started from a chat: the reader's task, then
4
+ * the conversation it continues, newest messages kept when it is long. */
5
+ function chatHandoffPrompt(conversation, task, t) {
6
+ const turns = (conversation.messages ?? []).flatMap((m) => {
7
+ const text = m.content?.trim();
8
+ if (!text || m.role !== "user" && m.role !== "assistant") return [];
9
+ return [`## ${m.role === "user" ? t("start.handoffUser") : t("start.handoffAssistant")}\n\n${text}`];
10
+ });
11
+ const kept = [];
12
+ let size = 0;
13
+ for (let i = turns.length - 1; i >= 0; i--) {
14
+ const turn = turns[i] ?? "";
15
+ if (kept.length > 0 && size + turn.length > HANDOFF_MAX_CHARS) break;
16
+ kept.unshift(turn);
17
+ size += turn.length;
18
+ }
19
+ const omitted = turns.length - kept.length;
20
+ return [
21
+ task.trim() || t("start.handoffDefaultTask"),
22
+ t("start.handoffIntro", { title: conversation.title || "" }),
23
+ ...omitted > 0 ? [t("start.handoffOmitted", { count: omitted })] : [],
24
+ kept.join("\n\n")
25
+ ].join("\n\n");
26
+ }
27
+ export { chatHandoffPrompt };
@@ -0,0 +1,188 @@
1
+ import type { ToolStrings } from '@parallelworks/ui/ai/headless';
2
+ import { type PwCodeTranslator } from './messages.js';
3
+ declare function chatStrings(t: PwCodeTranslator<'agentTranscript'>, tAgents: PwCodeTranslator<'agents'>, tools: ToolStrings): {
4
+ agentTranscript: {
5
+ running: string;
6
+ done: string;
7
+ failed: string;
8
+ failedWith: (reason: string) => string;
9
+ callGroup: (tool: string, count: number) => string;
10
+ editGroup: (count: number) => string;
11
+ writeGroup: (files: number) => string;
12
+ failedGroup: (tool: string, count: number) => string;
13
+ failedCount: (count: number) => string;
14
+ interrupted: string;
15
+ interruptedReason: string;
16
+ reviewing: (count: number) => string;
17
+ backgroundLaunched: (count: number) => string;
18
+ argsRewritten: string;
19
+ noOutput: string;
20
+ diffTruncated: string;
21
+ moreLines: (count: number) => string;
22
+ allowOnce: string;
23
+ allowDirectory: string;
24
+ deny: string;
25
+ allowCode: string;
26
+ denyCode: string;
27
+ allowPath: string;
28
+ denyPath: string;
29
+ allowCall: string;
30
+ denyCall: string;
31
+ denyWithFeedback: string;
32
+ feedbackPlaceholder: string;
33
+ answered: string;
34
+ allowedBy: (name: string) => string;
35
+ allowedWithChangesBy: (name: string) => string;
36
+ deniedBy: (name: string) => string;
37
+ allowed: string;
38
+ allowedWithChanges: string;
39
+ denied: string;
40
+ allowedByReviewer: string;
41
+ deniedByReviewer: string;
42
+ approvalExpired: string;
43
+ approvalTimedOut: string;
44
+ reviewTimedOut: string;
45
+ reviewFailed: string;
46
+ writeOwnAnswer: string;
47
+ subagent: string;
48
+ tasks: string;
49
+ planPending: string;
50
+ approvalPending: string;
51
+ approvalOptions: string;
52
+ approvalLabel: string;
53
+ approvalAllowed: string;
54
+ approvalDenied: string;
55
+ approvalRequestExpired: string;
56
+ approvalWaitingOn: (name: string) => string;
57
+ feedbackLabel: string;
58
+ ownAnswerLabel: string;
59
+ typeYourAnswer: string;
60
+ questionsLabel: string;
61
+ questionTab: (n: number) => string;
62
+ answeredCount: (answered: number, total: number) => string;
63
+ submitAnswers: string;
64
+ chatAboutThis: string;
65
+ noAnswer: string;
66
+ noPreview: string;
67
+ previewOf: (label: string) => string;
68
+ notesLabel: string;
69
+ notesPlaceholder: string;
70
+ notesOnly: string;
71
+ todoPending: string;
72
+ todoInProgress: string;
73
+ todoCompleted: string;
74
+ };
75
+ tools: ToolStrings;
76
+ queue: {
77
+ remove: string;
78
+ waiting: string;
79
+ waitingNextStep: string;
80
+ handedOver: string;
81
+ edit: string;
82
+ editLabel: string;
83
+ editHint: string;
84
+ };
85
+ paste: {
86
+ title: string;
87
+ lines: (count: number) => string;
88
+ saving: string;
89
+ remove: string;
90
+ };
91
+ thinking: {
92
+ label: string;
93
+ ellipsis: string;
94
+ thoughtFor: (duration: string) => string;
95
+ thoughtProcess: string;
96
+ activity: string;
97
+ ranToolCalls: (count: number) => string;
98
+ ranToolCallsAs: (count: number, name: string) => string;
99
+ };
100
+ activity: {
101
+ tokens: (input: string, output: string) => string;
102
+ stop: string;
103
+ };
104
+ input: {
105
+ stopGenerating: string;
106
+ loadingCommands: string;
107
+ };
108
+ thread: {
109
+ jumpToPrompt: (text: string) => string;
110
+ };
111
+ find: {
112
+ label: string;
113
+ count: (current: number, total: number) => string;
114
+ countCapped: (current: number, total: number) => string;
115
+ none: string;
116
+ previous: string;
117
+ next: string;
118
+ close: string;
119
+ };
120
+ chrome: {
121
+ jumpToLatest: string;
122
+ };
123
+ messageMeta: {
124
+ copyLabel: string;
125
+ };
126
+ attachmentManager: {
127
+ unnamedImage: string;
128
+ unnamedFile: string;
129
+ open: (name: string) => string;
130
+ download: (name: string) => string;
131
+ previousImage: string;
132
+ nextImage: string;
133
+ imagePosition: (position: number, total: number) => string;
134
+ fullImageFailed: string;
135
+ };
136
+ sidebar: {
137
+ openSidebar: string;
138
+ closeSidebar: string;
139
+ manageProviders: string;
140
+ };
141
+ modelPicker: {
142
+ choose: string;
143
+ select: string;
144
+ search: string;
145
+ loading: string;
146
+ failed: string;
147
+ none: string;
148
+ sharedBy: (owner: string) => string;
149
+ };
150
+ allocationPicker: {
151
+ choose: string;
152
+ placeholder: string;
153
+ search: string;
154
+ };
155
+ providerIssue: {
156
+ keyRejected: string;
157
+ unreachable: string;
158
+ };
159
+ permissions: {
160
+ choose: string;
161
+ readOnly: string;
162
+ acceptEdits: string;
163
+ auto: string;
164
+ bypassPermissions: string;
165
+ plan: string;
166
+ readOnlyHint: string;
167
+ acceptEditsHint: string;
168
+ autoHint: string;
169
+ bypassPermissionsHint: string;
170
+ planHint: string;
171
+ };
172
+ effort: {
173
+ choose: string;
174
+ named: (level: string) => string;
175
+ low: string;
176
+ medium: string;
177
+ high: string;
178
+ xhigh: string;
179
+ max: string;
180
+ faster: string;
181
+ smarter: string;
182
+ };
183
+ };
184
+ /** pw code's words for `@parallelworks/ui`'s chat, by its `ChatStrings` sections. */
185
+ export type PwCodeChatStrings = ReturnType<typeof chatStrings>;
186
+ /** Every word of `@parallelworks/ui`'s chat a pw code page shows, in the reader's language. */
187
+ export declare function usePwCodeChatStrings(): PwCodeChatStrings;
188
+ export {};
@@ -0,0 +1,217 @@
1
+ import { usePwCodeTranslations } from "./messages.js";
2
+ import { useToolStrings } from "./toolStrings.js";
3
+ import { useMemo } from "react";
4
+ // src/chatStrings.ts
5
+ function chatStrings(t, tAgents, tools) {
6
+ return {
7
+ agentTranscript: {
8
+ running: t("transcript.running"),
9
+ done: t("transcript.done"),
10
+ failed: t("transcript.failed"),
11
+ failedWith: (reason) => t("transcript.failedWith", { reason }),
12
+ callGroup: (tool, count) => t("transcript.callGroup", {
13
+ tool,
14
+ count
15
+ }),
16
+ editGroup: (count) => t("transcript.editGroup", { count }),
17
+ writeGroup: (files) => t("transcript.writeGroup", { count: files }),
18
+ failedGroup: (tool, count) => t("transcript.failedGroup", {
19
+ tool,
20
+ count
21
+ }),
22
+ failedCount: (count) => t("transcript.failedCount", { count }),
23
+ interrupted: t("transcript.interrupted"),
24
+ interruptedReason: t("transcript.interruptedReason"),
25
+ reviewing: (count) => t("transcript.reviewing", { count }),
26
+ backgroundLaunched: (count) => t("transcript.backgroundLaunched", { count }),
27
+ argsRewritten: t("transcript.argsRewritten"),
28
+ noOutput: t("transcript.noOutput"),
29
+ diffTruncated: t("transcript.diffTruncated"),
30
+ moreLines: (count) => t("transcript.moreLines", { count }),
31
+ allowOnce: t("transcript.allowOnce"),
32
+ allowDirectory: t("transcript.allowDirectory"),
33
+ deny: t("transcript.deny"),
34
+ allowCode: t("transcript.allowCode"),
35
+ denyCode: t("transcript.denyCode"),
36
+ allowPath: t("transcript.allowPath"),
37
+ denyPath: t("transcript.denyPath"),
38
+ allowCall: t("transcript.allowCall"),
39
+ denyCall: t("transcript.denyCall"),
40
+ denyWithFeedback: t("transcript.denyWithFeedback"),
41
+ feedbackPlaceholder: t("transcript.feedbackPlaceholder"),
42
+ answered: t("transcript.answered"),
43
+ allowedBy: (name) => t("transcript.allowedBy", { name }),
44
+ allowedWithChangesBy: (name) => t("transcript.allowedWithChangesBy", { name }),
45
+ deniedBy: (name) => t("transcript.deniedBy", { name }),
46
+ allowed: t("transcript.allowed"),
47
+ allowedWithChanges: t("transcript.allowedWithChanges"),
48
+ denied: t("transcript.denied"),
49
+ allowedByReviewer: t("transcript.allowedByReviewer"),
50
+ deniedByReviewer: t("transcript.deniedByReviewer"),
51
+ approvalExpired: t("transcript.approvalExpired"),
52
+ approvalTimedOut: t("transcript.approvalTimedOut"),
53
+ reviewTimedOut: t("transcript.reviewTimedOut"),
54
+ reviewFailed: t("transcript.reviewFailed"),
55
+ writeOwnAnswer: t("transcript.writeOwnAnswer"),
56
+ subagent: t("transcript.subagent"),
57
+ tasks: t("transcript.tasks"),
58
+ planPending: t("transcript.planPending"),
59
+ approvalPending: t("transcript.approvalPending"),
60
+ approvalOptions: t("transcript.approvalOptions"),
61
+ approvalLabel: t("transcript.approvalLabel"),
62
+ approvalAllowed: t("transcript.approvalAllowed"),
63
+ approvalDenied: t("transcript.approvalDenied"),
64
+ approvalRequestExpired: t("transcript.approvalRequestExpired"),
65
+ approvalWaitingOn: (name) => t("transcript.approvalWaitingOn", { name }),
66
+ feedbackLabel: t("transcript.feedbackLabel"),
67
+ ownAnswerLabel: t("transcript.ownAnswerLabel"),
68
+ typeYourAnswer: t("transcript.typeYourAnswer"),
69
+ questionsLabel: t("transcript.questionsLabel"),
70
+ questionTab: (n) => t("transcript.questionTab", { n }),
71
+ answeredCount: (answered, total) => t("transcript.answeredCount", {
72
+ answered,
73
+ total
74
+ }),
75
+ submitAnswers: t("transcript.submitAnswers"),
76
+ chatAboutThis: t("transcript.chatAboutThis"),
77
+ noAnswer: t("transcript.noAnswer"),
78
+ noPreview: t("transcript.noPreview"),
79
+ previewOf: (label) => t("transcript.previewOf", { label }),
80
+ notesLabel: t("transcript.notesLabel"),
81
+ notesPlaceholder: t("transcript.notesPlaceholder"),
82
+ notesOnly: t("transcript.notesOnly"),
83
+ todoPending: t("transcript.todoPending"),
84
+ todoInProgress: t("transcript.todoInProgress"),
85
+ todoCompleted: t("transcript.todoCompleted")
86
+ },
87
+ tools,
88
+ queue: {
89
+ remove: t("queue.remove"),
90
+ waiting: t("queue.waiting"),
91
+ waitingNextStep: t("queue.waitingNextStep"),
92
+ handedOver: t("queue.handedOver"),
93
+ edit: t("queue.edit"),
94
+ editLabel: t("queue.editLabel"),
95
+ editHint: t("queue.editHint")
96
+ },
97
+ paste: {
98
+ title: t("paste.title"),
99
+ lines: (count) => t("paste.lines", { count }),
100
+ saving: t("paste.saving"),
101
+ remove: t("paste.remove")
102
+ },
103
+ thinking: {
104
+ label: t("thinking.label"),
105
+ ellipsis: t("thinking.ellipsis"),
106
+ thoughtFor: (duration) => t("thinking.thoughtFor", { duration }),
107
+ thoughtProcess: t("thinking.thoughtProcess"),
108
+ activity: t("thinking.activity"),
109
+ ranToolCalls: (count) => t("thinking.ranToolCalls", { count }),
110
+ ranToolCallsAs: (count, name) => t("thinking.ranToolCallsAs", {
111
+ count,
112
+ name
113
+ })
114
+ },
115
+ activity: {
116
+ tokens: (input, output) => t("activity.tokens", {
117
+ input,
118
+ output
119
+ }),
120
+ stop: t("activity.stop")
121
+ },
122
+ input: {
123
+ stopGenerating: t("input.stopGenerating"),
124
+ loadingCommands: t("input.loadingCommands")
125
+ },
126
+ thread: { jumpToPrompt: (text) => t("thread.jumpToPrompt", { text }) },
127
+ find: {
128
+ label: t("find.label"),
129
+ count: (current, total) => t("find.count", {
130
+ current,
131
+ total
132
+ }),
133
+ countCapped: (current, total) => t("find.countCapped", {
134
+ current,
135
+ total
136
+ }),
137
+ none: t("find.none"),
138
+ previous: t("find.previous"),
139
+ next: t("find.next"),
140
+ close: t("find.close")
141
+ },
142
+ chrome: { jumpToLatest: t("chrome.jumpToLatest") },
143
+ messageMeta: { copyLabel: t("messageMeta.copyLabel") },
144
+ attachmentManager: {
145
+ unnamedImage: t("attachmentManager.unnamedImage"),
146
+ unnamedFile: t("attachmentManager.unnamedFile"),
147
+ open: (name) => t("attachmentManager.open", { name }),
148
+ download: (name) => t("attachmentManager.download", { name }),
149
+ previousImage: t("attachmentManager.previousImage"),
150
+ nextImage: t("attachmentManager.nextImage"),
151
+ imagePosition: (position, total) => t("attachmentManager.imagePosition", {
152
+ position,
153
+ total
154
+ }),
155
+ fullImageFailed: t("attachmentManager.fullImageFailed")
156
+ },
157
+ sidebar: {
158
+ openSidebar: t("sidebar.openSidebar"),
159
+ closeSidebar: t("sidebar.closeSidebar"),
160
+ manageProviders: t("sidebar.manageProviders")
161
+ },
162
+ modelPicker: {
163
+ choose: t("modelPicker.choose"),
164
+ select: t("modelPicker.select"),
165
+ search: t("modelPicker.search"),
166
+ loading: t("modelPicker.loading"),
167
+ failed: t("modelPicker.failed"),
168
+ none: t("modelPicker.none"),
169
+ sharedBy: (owner) => t("modelPicker.sharedBy", { owner })
170
+ },
171
+ allocationPicker: {
172
+ choose: t("allocationPicker.choose"),
173
+ placeholder: t("allocationPicker.placeholder"),
174
+ search: t("allocationPicker.search")
175
+ },
176
+ providerIssue: {
177
+ keyRejected: t("providerIssue.keyRejected"),
178
+ unreachable: t("providerIssue.unreachable")
179
+ },
180
+ permissions: {
181
+ choose: tAgents("start.choosePermission"),
182
+ readOnly: tAgents("permission.read-only"),
183
+ acceptEdits: tAgents("permission.accept-edits"),
184
+ auto: tAgents("permission.auto"),
185
+ bypassPermissions: tAgents("permission.bypass-permissions"),
186
+ plan: tAgents("permission.plan"),
187
+ readOnlyHint: tAgents("permission.hint.read-only"),
188
+ acceptEditsHint: tAgents("permission.hint.accept-edits"),
189
+ autoHint: tAgents("permission.hint.auto"),
190
+ bypassPermissionsHint: tAgents("permission.hint.bypass-permissions"),
191
+ planHint: tAgents("permission.hint.plan")
192
+ },
193
+ effort: {
194
+ choose: tAgents("effort.label"),
195
+ named: (level) => tAgents("effort.named", { level }),
196
+ low: tAgents("effort.low"),
197
+ medium: tAgents("effort.medium"),
198
+ high: tAgents("effort.high"),
199
+ xhigh: tAgents("effort.xhigh"),
200
+ max: tAgents("effort.max"),
201
+ faster: tAgents("effort.faster"),
202
+ smarter: tAgents("effort.smarter")
203
+ }
204
+ };
205
+ }
206
+ /** Every word of `@parallelworks/ui`'s chat a pw code page shows, in the reader's language. */
207
+ function usePwCodeChatStrings() {
208
+ const t = usePwCodeTranslations("agentTranscript");
209
+ const tAgents = usePwCodeTranslations("agents");
210
+ const tools = useToolStrings();
211
+ return useMemo(() => chatStrings(t, tAgents, tools), [
212
+ t,
213
+ tAgents,
214
+ tools
215
+ ]);
216
+ }
217
+ export { usePwCodeChatStrings };
@@ -0,0 +1,149 @@
1
+ import type { BoundSetting } from '@parallelworks/ui/ai/headless';
2
+ import type { Schemas } from './apiClient.js';
3
+ import type { claudeApi } from './claudeApi.js';
4
+ export type ClaudeAccount = Schemas['AgentClaudeAccount'];
5
+ /** The account hooks of `createPwCodeApi`. */
6
+ export type ClaudeAccountCalls = Pick<ReturnType<typeof claudeApi>, 'useClaudeAccounts' | 'useRefreshClaudeModels' | 'useRemoveClaudeAccount'>;
7
+ /** What the account panel shows: the list, or one step taken from it. */
8
+ export type ClaudeAccountView = {
9
+ kind: 'list';
10
+ } | {
11
+ kind: 'add';
12
+ } | {
13
+ kind: 'signIn';
14
+ account: string;
15
+ } | {
16
+ kind: 'remove';
17
+ account: string;
18
+ };
19
+ export interface ClaudeAccountAction {
20
+ kind: 'use' | 'signIn' | 'signInAgain' | 'remove';
21
+ label: string;
22
+ destructive: boolean;
23
+ run: () => void;
24
+ }
25
+ /** The line under an account's name: its email, or, for a signed-out account
26
+ * the machine can't sign in from here, how to sign it in on the machine. */
27
+ export interface ClaudeAccountDetail {
28
+ kind: 'email' | 'signInHint';
29
+ text: string;
30
+ }
31
+ export interface ClaudeAccountPanelState {
32
+ /** Claude Code is allowed and installed on the machine. */
33
+ available: boolean;
34
+ /** Why Claude Code can't run on the machine, shown in place of the view;
35
+ * null when it can. */
36
+ notice: string | null;
37
+ view: ClaudeAccountView;
38
+ title: string;
39
+ /** The machine, or the account on it that the view acts on. */
40
+ description: string;
41
+ /** Where signing in happens, beside the list's description; null on the
42
+ * other views. */
43
+ signInNote: string | null;
44
+ /** The question a removal is confirmed with; null on the other views. */
45
+ removeBody: string | null;
46
+ /** Said under an empty list when the machine can't sign in from here. */
47
+ emptyHint: string | null;
48
+ accounts: ClaudeAccount[];
49
+ loading: boolean;
50
+ loadedUsage: boolean;
51
+ /** Why the list or its last refresh failed. */
52
+ error: unknown;
53
+ /** Loaded, without error, and holding no account. */
54
+ empty: boolean;
55
+ refreshing: boolean;
56
+ canAdd: boolean;
57
+ /** The list is shown and an account can be added from it. */
58
+ showAdd: boolean;
59
+ /** The list is shown on a machine that runs Claude Code. */
60
+ showRefresh: boolean;
61
+ /** The row a list starts on: the selected account's, else the first that
62
+ * is signed in or can sign in from here; -1 when there is none. */
63
+ startIndex: number;
64
+ /** The selected account's row; -1 when it isn't listed. */
65
+ selectedIndex: number;
66
+ /** The first row that is signed in or can sign in from here, whether or
67
+ * not the setting can change now; -1 when there is none. */
68
+ firstEnabledIndex: number;
69
+ isDisabled: (account: ClaudeAccount) => boolean;
70
+ detail: (account: ClaudeAccount) => ClaudeAccountDetail | null;
71
+ /** Picks a row: an account that needs signing in opens its sign-in. */
72
+ choose: (account: ClaudeAccount) => void;
73
+ /** Makes the account the setting's value and closes the panel. */
74
+ select: (name: string) => void;
75
+ /** What a row's menu offers, empty while the setting can't change. */
76
+ actions: (account: ClaudeAccount) => ClaudeAccountAction[];
77
+ add: () => void;
78
+ startSignIn: (name: string) => void;
79
+ /** Reloads the list and models once the sign-in shown has completed. */
80
+ finishSignIn: () => void;
81
+ /** Selects the account just signed in, unless the setting can't change. */
82
+ selectSignedIn: (() => void) | undefined;
83
+ /** Leaves the step shown for the list; leaving a sign-in reloads it. */
84
+ back: () => void;
85
+ refresh: () => Promise<void>;
86
+ /** Signs the account out and deletes it, then returns to the list. A
87
+ * selected account falls back to `default`. */
88
+ removeAccount: (name: string) => Promise<void>;
89
+ }
90
+ /** The refusal of a read that needs the account signed in first. */
91
+ export declare function claudeSignInRequired(error: unknown): boolean;
92
+ /** The account name `input` gives once trimmed, or null when Claude Code
93
+ * can't take it. */
94
+ export declare function claudeAccountName(input: string): string | null;
95
+ /** Moves a host's highlight to the list's start row, then back to it each
96
+ * time the selected or first enabled row changes, such as when the
97
+ * accounts' sign-in states arrive. */
98
+ export declare function useClaudeAccountStartRow(panel: Pick<ClaudeAccountPanelState, 'selectedIndex' | 'firstEnabledIndex'>, setActive: (index: number) => void): void;
99
+ /** The Claude Code accounts on a machine, and the steps a panel listing them
100
+ * takes: adding, signing in, removing after a confirmation the host shows,
101
+ * and choosing one for the `account` setting. */
102
+ export declare function useClaudeAccountPanel(calls: ClaudeAccountCalls, { machine, machineName, sessionId, claudeInstalled, claudeAllowed, claudeLogin, claudeAccountRemove, account, onClose, }: {
103
+ machine: string;
104
+ machineName: string;
105
+ sessionId?: string | undefined;
106
+ claudeInstalled: boolean;
107
+ claudeAllowed: boolean;
108
+ /** The machine can sign accounts in from here. */
109
+ claudeLogin?: boolean | undefined;
110
+ /** The machine can remove accounts from here. */
111
+ claudeAccountRemove?: boolean | undefined;
112
+ account: BoundSetting;
113
+ onClose: () => void;
114
+ }): ClaudeAccountPanelState;
115
+ /** The confirmation of a removal: whether it runs, and why it last failed. */
116
+ export declare function useClaudeAccountRemoval(remove: () => Promise<void>): {
117
+ pending: boolean;
118
+ error: unknown;
119
+ confirm: () => Promise<void>;
120
+ };
121
+ /** The name field of a new account, which continues to its sign-in only with
122
+ * a name Claude Code can take. */
123
+ export declare function useClaudeAccountName(onContinue: (name: string) => void): {
124
+ name: string;
125
+ invalid: boolean;
126
+ change: (value: string) => void;
127
+ submit: () => void;
128
+ };
129
+ export interface ClaudeUsageReset {
130
+ /** When, as "resets Fri, Oct 30, 5:00 PM". */
131
+ at: string;
132
+ countdown: string;
133
+ /** The countdown for a narrow row. */
134
+ shortCountdown: string;
135
+ }
136
+ export interface ClaudeUsageLimit {
137
+ window: 'fiveHour' | 'week';
138
+ label: string;
139
+ /** Percent of the window used; undefined when not reported. */
140
+ used: number | undefined;
141
+ reset: ClaudeUsageReset | null;
142
+ }
143
+ export interface ClaudeAccountUsage {
144
+ /** Shown in place of the limits, which are then empty. */
145
+ status: string | null;
146
+ limits: ClaudeUsageLimit[];
147
+ }
148
+ /** An account's usage limits as its row words them. */
149
+ export declare function useClaudeAccountUsage(account: ClaudeAccount, loaded: boolean): ClaudeAccountUsage;