@parallelworks/code 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +138 -24
  2. package/dist/api.d.ts +3469 -0
  3. package/dist/apiClient.d.ts +26 -0
  4. package/dist/apiClient.js +5 -0
  5. package/dist/claudeApi.d.ts +27 -0
  6. package/dist/claudeApi.js +250 -0
  7. package/dist/command.d.ts +47 -0
  8. package/dist/command.js +64 -0
  9. package/dist/commandsApi.d.ts +64 -0
  10. package/dist/commandsApi.js +267 -0
  11. package/dist/createPwCodeApi.d.ts +688 -0
  12. package/dist/createPwCodeApi.js +31 -0
  13. package/dist/index.d.ts +16 -3
  14. package/dist/index.js +16 -3
  15. package/dist/locales/en/agentTranscript.js +170 -0
  16. package/dist/locales/en/agents.js +380 -0
  17. package/dist/locales/en.d.ts +531 -0
  18. package/dist/locales/en.js +8 -0
  19. package/dist/locales/es/agentTranscript.js +170 -0
  20. package/dist/locales/es/agents.js +380 -0
  21. package/dist/locales/es.d.ts +3 -0
  22. package/dist/locales/es.js +8 -0
  23. package/dist/locales/ja/agentTranscript.js +170 -0
  24. package/dist/locales/ja/agents.js +380 -0
  25. package/dist/locales/ja.d.ts +3 -0
  26. package/dist/locales/ja.js +8 -0
  27. package/dist/locales/ko/agentTranscript.js +170 -0
  28. package/dist/locales/ko/agents.js +380 -0
  29. package/dist/locales/ko.d.ts +3 -0
  30. package/dist/locales/ko.js +8 -0
  31. package/dist/locales/zh/agentTranscript.js +170 -0
  32. package/dist/locales/zh/agents.js +380 -0
  33. package/dist/locales/zh.d.ts +3 -0
  34. package/dist/locales/zh.js +8 -0
  35. package/dist/machine.d.ts +49 -0
  36. package/dist/machine.js +60 -0
  37. package/dist/messages.d.ts +17 -0
  38. package/dist/messages.js +31 -0
  39. package/dist/notices.d.ts +11 -0
  40. package/dist/notices.js +94 -0
  41. package/dist/pullRequest.d.ts +8 -0
  42. package/dist/pullRequest.js +29 -0
  43. package/dist/query.d.ts +28 -0
  44. package/dist/query.js +25 -0
  45. package/dist/session.d.ts +70 -1
  46. package/dist/session.js +101 -1
  47. package/dist/sessionEvents.d.ts +27 -0
  48. package/dist/sessionEvents.js +212 -0
  49. package/dist/sessionsApi.d.ts +105 -0
  50. package/dist/sessionsApi.js +513 -0
  51. package/dist/toolStrings.d.ts +4 -0
  52. package/dist/toolStrings.js +95 -0
  53. package/dist/transcript.d.ts +12 -1
  54. package/dist/transcript.js +40 -2
  55. package/dist/types.d.ts +20 -1
  56. package/dist/useTranscript.d.ts +4 -1
  57. package/dist/useTranscript.js +54 -11
  58. package/dist/wording.d.ts +43 -0
  59. package/dist/wording.js +101 -0
  60. package/locales/en/agentTranscript.json +162 -0
  61. package/locales/en/agents.json +366 -0
  62. package/locales/es/agentTranscript.json +162 -0
  63. package/locales/es/agents.json +366 -0
  64. package/locales/ja/agentTranscript.json +162 -0
  65. package/locales/ja/agents.json +366 -0
  66. package/locales/ko/agentTranscript.json +162 -0
  67. package/locales/ko/agents.json +366 -0
  68. package/locales/zh/agentTranscript.json +162 -0
  69. package/locales/zh/agents.json +366 -0
  70. package/package.json +23 -8
@@ -0,0 +1,26 @@
1
+ import type { Client } from 'openapi-fetch';
2
+ import type { SWRResponse } from 'swr';
3
+ import type { components, paths } from './api.js';
4
+ /** The routes this package calls, as the platform's OpenAPI spec types them. A
5
+ * host's client typed over the whole spec has them all. */
6
+ export type PwCodePaths = paths;
7
+ export type PwCodeComponents = components;
8
+ export type PwCodeClient = Client<PwCodePaths>;
9
+ export type Schemas = components['schemas'];
10
+ /** The body of a refusal: the platform's error, with its stable `code`. */
11
+ export type PwCodeApiError = Schemas['Error'];
12
+ /** A data hook's state, as SWR keeps it. */
13
+ export type PwCodeQuery<Data> = SWRResponse<Data, PwCodeApiError>;
14
+ /** What a call resolves to, as the API client returns it. */
15
+ export type PwCodeResult<Data> = {
16
+ data: Data;
17
+ error?: never;
18
+ response: Response;
19
+ } | {
20
+ data?: never;
21
+ error: PwCodeApiError;
22
+ response: Response;
23
+ };
24
+ /** The key prefix `@parallelworks/client/swr`'s hooks use by default, so a host
25
+ * that reads these routes through them shares this package's cache entries. */
26
+ export declare const QUERY_KEY_PREFIX = "api";
@@ -0,0 +1,5 @@
1
+ // src/apiClient.ts
2
+ /** The key prefix `@parallelworks/client/swr`'s hooks use by default, so a host
3
+ * that reads these routes through them shares this package's cache entries. */
4
+ var QUERY_KEY_PREFIX = "api";
5
+ export { QUERY_KEY_PREFIX };
@@ -0,0 +1,27 @@
1
+ import { type PwCodeApiError, type PwCodeClient, type PwCodeQuery, type Schemas } from './apiClient.js';
2
+ type ClaudeAccount = Schemas['AgentClaudeAccount'];
3
+ type ClaudeModels = Schemas['AgentClaudeModel'][] | null;
4
+ type ClaudeAccounts = ClaudeAccount[] | null;
5
+ export type ClaudeLoginEvent = Schemas['AgentClaudeLoginEvent'];
6
+ export type ClaudeLogin = ClaudeLoginEvent['login'];
7
+ export type ClaudeLoginInput = Schemas['AgentClaudeLoginInput'];
8
+ export declare function claudeLoginFinished(status: ClaudeLogin['status']): boolean;
9
+ export declare function claudeApi(client: PwCodeClient): {
10
+ useClaudeModels: (machine: string, sessionId: string | undefined, account: string | undefined, enabled: boolean, refresh?: boolean) => PwCodeQuery<ClaudeModels>;
11
+ useRefreshClaudeModels: (machine: string, sessionId: string | undefined) => (account: string | undefined) => Promise<void>;
12
+ useClaudeAccountNames: (machine: string, enabled: boolean) => PwCodeQuery<ClaudeAccounts>;
13
+ useClaudeAccounts: (machine: string, sessionId: string | undefined, enabled: boolean) => {
14
+ accounts: ClaudeAccount[];
15
+ loadedUsage: boolean;
16
+ loading: boolean;
17
+ error: PwCodeApiError | undefined;
18
+ refreshing: boolean;
19
+ refresh: () => Promise<void>;
20
+ };
21
+ useRemoveClaudeAccount: (machine: string, sessionId: string | undefined) => (name: string) => Promise<void>;
22
+ startClaudeLogin: (machine: string, account: string, sessionId: string | undefined, columns: number, rows: number) => Promise<ClaudeLoginEvent>;
23
+ writeClaudeLogin: (machine: string, loginId: string, input: ClaudeLoginInput) => Promise<void>;
24
+ cancelClaudeLogin: (machine: string, loginId: string) => Promise<void>;
25
+ followClaudeLogin: (machine: string, login: ClaudeLogin, after: number, signal: AbortSignal, receive: (event: ClaudeLoginEvent) => void) => Promise<void>;
26
+ };
27
+ export {};
@@ -0,0 +1,250 @@
1
+ import "./apiClient.js";
2
+ import { createQuery } from "./query.js";
3
+ import { useState } from "react";
4
+ import { useSWRConfig } from "swr";
5
+ // src/claudeApi.ts
6
+ var cache = {
7
+ dedupingInterval: 6e4,
8
+ revalidateOnFocus: false
9
+ };
10
+ var hostModelsPath = "/api/code/machines/{machine}/claude-code/models";
11
+ var sessionModelsPath = "/api/code/machines/{machine}/sessions/{id}/models";
12
+ var hostAccountsPath = "/api/code/machines/{machine}/claude-code/accounts";
13
+ var sessionAccountsPath = "/api/code/machines/{machine}/sessions/{id}/claude-code/accounts";
14
+ var loginsPath = "/api/code/machines/{machine}/claude-code/logins";
15
+ var loginPath = "/api/code/machines/{machine}/claude-code/logins/{loginId}";
16
+ function modelQuery(account, refresh) {
17
+ return {
18
+ ...account ? { account } : {},
19
+ refresh
20
+ };
21
+ }
22
+ function hostModelOptions(machine, account, refresh) {
23
+ return { params: {
24
+ path: { machine },
25
+ query: modelQuery(account, refresh)
26
+ } };
27
+ }
28
+ function sessionModelOptions(machine, id, account, refresh) {
29
+ return { params: {
30
+ path: {
31
+ machine,
32
+ id
33
+ },
34
+ query: modelQuery(account, refresh)
35
+ } };
36
+ }
37
+ function hostAccountOptions(machine, namesOnly, refresh = false) {
38
+ return { params: {
39
+ path: { machine },
40
+ query: {
41
+ namesOnly,
42
+ ...refresh && { refresh }
43
+ }
44
+ } };
45
+ }
46
+ function sessionAccountOptions(machine, id, namesOnly, refresh = false) {
47
+ return { params: {
48
+ path: {
49
+ machine,
50
+ id
51
+ },
52
+ query: {
53
+ namesOnly,
54
+ ...refresh && { refresh }
55
+ }
56
+ } };
57
+ }
58
+ function claudeLoginFinished(status) {
59
+ return status !== "running" && status !== "checking";
60
+ }
61
+ /** Aborts after `ms`, or with `signal`. Built by hand where AbortSignal has no
62
+ * `timeout` or `any`, as React Native's polyfill has neither. */
63
+ function deadline(ms, signal) {
64
+ if (typeof AbortSignal.timeout === "function" && (!signal || typeof AbortSignal.any === "function")) {
65
+ const timeout = AbortSignal.timeout(ms);
66
+ return signal ? AbortSignal.any([signal, timeout]) : timeout;
67
+ }
68
+ const controller = new AbortController();
69
+ const timer = setTimeout(() => controller.abort(), ms);
70
+ const abort = () => {
71
+ clearTimeout(timer);
72
+ controller.abort(signal?.reason);
73
+ };
74
+ if (signal?.aborted) abort();
75
+ else signal?.addEventListener("abort", abort, { once: true });
76
+ return controller.signal;
77
+ }
78
+ function claudeApi(client) {
79
+ const useQuery = createQuery(client);
80
+ function useRefreshClaudeModels(machine, sessionId) {
81
+ const { mutate } = useSWRConfig();
82
+ return async (account) => {
83
+ if (sessionId) {
84
+ const { data, error } = await client.GET(sessionModelsPath, sessionModelOptions(machine, sessionId, account, true));
85
+ if (error) throw error;
86
+ for (const refresh of [false, true]) await mutate([
87
+ "api",
88
+ sessionModelsPath,
89
+ sessionModelOptions(machine, sessionId, account, refresh)
90
+ ], data, { revalidate: false });
91
+ } else {
92
+ const { data, error } = await client.GET(hostModelsPath, hostModelOptions(machine, account, true));
93
+ if (error) throw error;
94
+ for (const refresh of [false, true]) await mutate([
95
+ "api",
96
+ hostModelsPath,
97
+ hostModelOptions(machine, account, refresh)
98
+ ], data, { revalidate: false });
99
+ }
100
+ };
101
+ }
102
+ function useClaudeModels(machine, sessionId, account, enabled, refresh = false) {
103
+ const host = useQuery(hostModelsPath, enabled && machine && !sessionId ? hostModelOptions(machine, account, refresh) : null, cache);
104
+ const session = useQuery(sessionModelsPath, enabled && machine && sessionId ? sessionModelOptions(machine, sessionId, account, refresh) : null, cache);
105
+ return sessionId ? session : host;
106
+ }
107
+ function useClaudeAccountNames(machine, enabled) {
108
+ return useQuery(hostAccountsPath, enabled && machine ? hostAccountOptions(machine, true) : null, cache);
109
+ }
110
+ function useClaudeAccounts(machine, sessionId, enabled) {
111
+ const { mutate } = useSWRConfig();
112
+ const [refreshing, setRefreshing] = useState(false);
113
+ const hostNames = useClaudeAccountNames(machine, enabled && !sessionId);
114
+ const sessionNames = useQuery(sessionAccountsPath, enabled && machine && sessionId ? sessionAccountOptions(machine, sessionId, true) : null, cache);
115
+ const names = sessionId ? sessionNames : hostNames;
116
+ const hostUsage = useQuery(hostAccountsPath, enabled && machine && !sessionId && names.data ? hostAccountOptions(machine, false) : null, cache);
117
+ const sessionUsage = useQuery(sessionAccountsPath, enabled && machine && sessionId && names.data ? sessionAccountOptions(machine, sessionId, false) : null, cache);
118
+ const usage = sessionId ? sessionUsage : hostUsage;
119
+ const metadata = new Map(usage.data?.map((a) => [a.name, a]));
120
+ const refreshUsage = async () => {
121
+ const { data, error } = sessionId ? await client.GET(sessionAccountsPath, sessionAccountOptions(machine, sessionId, false, true)) : await client.GET(hostAccountsPath, hostAccountOptions(machine, false, true));
122
+ if (error) throw error;
123
+ return data;
124
+ };
125
+ const refresh = async () => {
126
+ setRefreshing(true);
127
+ try {
128
+ await Promise.all([names.mutate(), mutate([
129
+ "api",
130
+ sessionId ? sessionAccountsPath : hostAccountsPath,
131
+ sessionId ? sessionAccountOptions(machine, sessionId, false) : hostAccountOptions(machine, false)
132
+ ], refreshUsage, { revalidate: false })]);
133
+ } finally {
134
+ setRefreshing(false);
135
+ }
136
+ };
137
+ return {
138
+ accounts: (names.data ?? []).map((a) => metadata.get(a.name) ?? a),
139
+ loadedUsage: !!usage.data,
140
+ loading: names.isLoading,
141
+ error: names.error ?? usage.error,
142
+ refreshing: refreshing || names.isValidating || usage.isValidating,
143
+ refresh
144
+ };
145
+ }
146
+ /** Drops the account from cached lists; only the cheap name lists reload. */
147
+ function useRemoveClaudeAccount(machine, sessionId) {
148
+ const { mutate } = useSWRConfig();
149
+ return async (name) => {
150
+ const { error } = await client.DELETE("/api/code/machines/{machine}/claude-code/accounts/{name}", {
151
+ params: { path: {
152
+ machine,
153
+ name
154
+ } },
155
+ signal: deadline(6e4)
156
+ });
157
+ if (error) throw error;
158
+ const drop = (accounts) => accounts?.filter((a) => a.name !== name);
159
+ await Promise.all([true, false].flatMap((namesOnly) => [mutate([
160
+ "api",
161
+ hostAccountsPath,
162
+ hostAccountOptions(machine, namesOnly)
163
+ ], drop, { revalidate: namesOnly }), ...sessionId ? [mutate([
164
+ "api",
165
+ sessionAccountsPath,
166
+ sessionAccountOptions(machine, sessionId, namesOnly)
167
+ ], drop, { revalidate: namesOnly })] : []]));
168
+ };
169
+ }
170
+ async function startClaudeLogin(machine, account, sessionId, columns, rows) {
171
+ const { data, error } = await client.POST(loginsPath, {
172
+ params: { path: { machine } },
173
+ body: {
174
+ account,
175
+ columns,
176
+ rows,
177
+ ...sessionId ? { sessionId } : {}
178
+ },
179
+ signal: deadline(3e4)
180
+ });
181
+ if (error) throw error;
182
+ if (!data) throw new Error("Missing Claude Code sign-in response");
183
+ return data;
184
+ }
185
+ async function readClaudeLogin(machine, loginId, after, status, signal, wait = true) {
186
+ const { data, error } = await client.GET(loginPath, {
187
+ params: {
188
+ path: {
189
+ machine,
190
+ loginId
191
+ },
192
+ query: {
193
+ after,
194
+ status,
195
+ wait
196
+ }
197
+ },
198
+ signal: deadline(3e4, signal)
199
+ });
200
+ if (error) throw error;
201
+ if (!data) throw new Error("Missing Claude Code sign-in output");
202
+ return data;
203
+ }
204
+ async function writeClaudeLogin(machine, loginId, input) {
205
+ const { error } = await client.POST("/api/code/machines/{machine}/claude-code/logins/{loginId}/input", {
206
+ params: { path: {
207
+ machine,
208
+ loginId
209
+ } },
210
+ body: input,
211
+ signal: deadline(3e4)
212
+ });
213
+ if (error) throw error;
214
+ }
215
+ async function cancelClaudeLogin(machine, loginId) {
216
+ const { error } = await client.DELETE(loginPath, {
217
+ params: { path: {
218
+ machine,
219
+ loginId
220
+ } },
221
+ signal: deadline(3e4)
222
+ });
223
+ if (error) throw error;
224
+ }
225
+ async function followClaudeLogin(machine, login, after, signal, receive) {
226
+ let status = login.status;
227
+ let cursor = after;
228
+ let wait = false;
229
+ while (!signal.aborted && !claudeLoginFinished(status)) {
230
+ const event = await readClaudeLogin(machine, login.id, cursor, status, signal, wait);
231
+ if (signal.aborted) return;
232
+ receive(event);
233
+ cursor = event.next;
234
+ status = event.login.status;
235
+ wait = true;
236
+ }
237
+ }
238
+ return {
239
+ useClaudeModels,
240
+ useRefreshClaudeModels,
241
+ useClaudeAccountNames,
242
+ useClaudeAccounts,
243
+ useRemoveClaudeAccount,
244
+ startClaudeLogin,
245
+ writeClaudeLogin,
246
+ cancelClaudeLogin,
247
+ followClaudeLogin
248
+ };
249
+ }
250
+ export { claudeApi, claudeLoginFinished };
@@ -0,0 +1,47 @@
1
+ /** A command a session's palette lists. */
2
+ export interface PwCodeSlashCommand {
3
+ name: string;
4
+ description?: string | undefined;
5
+ usage?: string | undefined;
6
+ }
7
+ /** What a session can run from a slash, as far as typed text is dispatched by
8
+ * it. A host that types its API from a spec asserts its type extends this. */
9
+ export interface PwCodePalette {
10
+ commands?: readonly PwCodeSlashCommand[] | null | undefined;
11
+ mcpPrompts?: readonly PwCodeSlashCommand[] | null | undefined;
12
+ prompts?: readonly string[] | null | undefined;
13
+ }
14
+ export type SlashAction = {
15
+ kind: 'message';
16
+ } | {
17
+ kind: 'clear';
18
+ } | {
19
+ kind: 'compact';
20
+ focus: string;
21
+ } | {
22
+ kind: 'goal';
23
+ args: string;
24
+ } | {
25
+ kind: 'plan';
26
+ args: string;
27
+ } | {
28
+ kind: 'archive';
29
+ } | {
30
+ kind: 'command';
31
+ name: string;
32
+ args: string;
33
+ };
34
+ /** Where typed text goes, in the order the terminal dispatches it: skills,
35
+ * custom commands, and MCP prompts expand into a turn, so they are messages;
36
+ * built-ins run as commands, five of them on routes of their own. */
37
+ export declare function slashAction(text: string, palette: PwCodePalette | null): SlashAction;
38
+ export declare function paletteOptions(palette: PwCodePalette | null, claudeAccountDescription?: string, archiveDescription?: string): PwCodeSlashCommand[];
39
+ /** The command a `!` line runs, read as the terminal reads it: empty for a bare
40
+ * `!`, which runs nothing, and null for text that is not a shell escape. */
41
+ export declare function shellCommand(text: string): string | null;
42
+ /** A proxy's 502 or 504 is not a problem, so it has no type: like the platform's no answer, it may have landed. */
43
+ export declare function steerMayHaveLanded(error: {
44
+ code?: string | undefined;
45
+ type?: string | undefined;
46
+ status?: number | undefined;
47
+ }): boolean;
@@ -0,0 +1,64 @@
1
+ // src/command.ts
2
+ var INVOCATION = /^\/([A-Za-z0-9_:-]+)(?:\s+([\s\S]*))?$/;
3
+ /** Where typed text goes, in the order the terminal dispatches it: skills,
4
+ * custom commands, and MCP prompts expand into a turn, so they are messages;
5
+ * built-ins run as commands, five of them on routes of their own. */
6
+ function slashAction(text, palette) {
7
+ const match = INVOCATION.exec(text.trim());
8
+ const name = match?.[1];
9
+ if (!match || !name || !palette) return { kind: "message" };
10
+ const args = (match[2] ?? "").trim();
11
+ if (name.startsWith("mcp__") || (palette.prompts ?? []).includes(name)) return { kind: "message" };
12
+ switch (name) {
13
+ case "clear": return { kind: "clear" };
14
+ case "compact": return {
15
+ kind: "compact",
16
+ focus: args
17
+ };
18
+ case "goal": return {
19
+ kind: "goal",
20
+ args
21
+ };
22
+ case "plan": return {
23
+ kind: "plan",
24
+ args
25
+ };
26
+ case "archive": return { kind: "archive" };
27
+ }
28
+ if ((palette.commands ?? []).some((c) => c.name === name)) return {
29
+ kind: "command",
30
+ name,
31
+ args
32
+ };
33
+ return { kind: "message" };
34
+ }
35
+ function paletteOptions(palette, claudeAccountDescription, archiveDescription) {
36
+ const commands = [...palette?.commands ?? [], ...palette?.mcpPrompts ?? []].filter((c) => c.name !== "claude-code").map((c) => ({
37
+ name: c.name,
38
+ description: c.description,
39
+ usage: c.usage
40
+ }));
41
+ if (archiveDescription !== void 0 && !commands.some((c) => c.name === "archive")) {
42
+ const at = commands.findIndex((c) => c.name > "archive");
43
+ commands.splice(at === -1 ? commands.length : at, 0, {
44
+ name: "archive",
45
+ description: archiveDescription,
46
+ usage: "/archive"
47
+ });
48
+ }
49
+ return claudeAccountDescription === void 0 ? commands : [{
50
+ name: "claude-code",
51
+ description: claudeAccountDescription
52
+ }, ...commands];
53
+ }
54
+ /** The command a `!` line runs, read as the terminal reads it: empty for a bare
55
+ * `!`, which runs nothing, and null for text that is not a shell escape. */
56
+ function shellCommand(text) {
57
+ const trimmed = text.trim();
58
+ return trimmed.startsWith("!") ? trimmed.slice(1).trim() : null;
59
+ }
60
+ /** A proxy's 502 or 504 is not a problem, so it has no type: like the platform's no answer, it may have landed. */
61
+ function steerMayHaveLanded(error) {
62
+ return error.code === "upstream_no_answer" || !error.code && !error.type && (error.status === 502 || error.status === 504);
63
+ }
64
+ export { paletteOptions, shellCommand, slashAction, steerMayHaveLanded };
@@ -0,0 +1,64 @@
1
+ import { type PwCodeClient, type PwCodeResult, type Schemas } from './apiClient.js';
2
+ import { type SlashAction } from './command.js';
3
+ type Palette = Schemas['AgentPalette'];
4
+ export type CommandOutcome = {
5
+ kind: 'output';
6
+ text: string;
7
+ } | {
8
+ kind: 'compacted';
9
+ } | {
10
+ kind: 'cleared';
11
+ newId: string;
12
+ } | {
13
+ kind: 'send';
14
+ text: string;
15
+ } | {
16
+ kind: 'refused';
17
+ error: unknown;
18
+ } | {
19
+ kind: 'none';
20
+ };
21
+ export interface SlashDeps {
22
+ machine: string;
23
+ sessionId: string;
24
+ palette: Palette | null;
25
+ loadPalette: () => Promise<Palette | null>;
26
+ planOnMachine: (path: string) => string;
27
+ onOutput: (command: string, text: string) => void;
28
+ /** stop is why the owner's hook asked that the model not react to the run. */
29
+ onShellRun: (command: string, output: string, stop: string | undefined) => Promise<void> | void;
30
+ onCompacted: () => void;
31
+ onCleared: (newId: string) => void;
32
+ /** Archives the open session the way the host's own archive action does, keeping its lists in step. */
33
+ onArchive: () => Promise<void> | void;
34
+ onRefused: (error: unknown) => void;
35
+ }
36
+ export declare const backgroundOfferDelayMs = 2000;
37
+ export declare function commandsApi(client: PwCodeClient): {
38
+ runSlashAction: (machine: string, id: string, action: Exclude<SlashAction, {
39
+ kind: 'message' | 'archive';
40
+ }>, planOnMachine: (path: string) => string) => Promise<CommandOutcome>;
41
+ resolveTyped: (text: string, deps: SlashDeps) => Promise<string | null>;
42
+ usePalette: (machine: string, sessionId: string) => {
43
+ palette: Palette | null;
44
+ loading: boolean;
45
+ load: () => Promise<Palette | null>;
46
+ };
47
+ useWorkspacePalette: (machine: string | undefined, workspace: string, model: string | null | undefined) => {
48
+ palette: Palette | null;
49
+ loading: boolean;
50
+ load: () => void;
51
+ };
52
+ useBackgroundCommands: ({ machine, sessionId, running, onError, }: {
53
+ machine: string;
54
+ sessionId: string;
55
+ running: boolean;
56
+ onError: (error: unknown) => void;
57
+ }) => {
58
+ offered: boolean;
59
+ moving: boolean;
60
+ move: () => Promise<void>;
61
+ };
62
+ requestRecap: (machine: string, id: string, signal?: AbortSignal) => Promise<PwCodeResult<undefined>>;
63
+ };
64
+ export {};