@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.
- package/README.md +92 -24
- package/dist/agentSwitcher.d.ts +13 -2
- package/dist/agentSwitcher.js +28 -6
- package/dist/ago.d.ts +1 -3
- package/dist/ago.js +1 -3
- package/dist/api.d.ts +267 -5
- package/dist/chatStrings.d.ts +4 -0
- package/dist/chatStrings.js +5 -1
- package/dist/claudeAccounts.d.ts +20 -2
- package/dist/claudeAccounts.js +51 -7
- package/dist/claudeApi.d.ts +2 -1
- package/dist/claudeApi.js +49 -3
- package/dist/command.d.ts +7 -1
- package/dist/command.js +11 -2
- package/dist/commandsApi.d.ts +8 -3
- package/dist/commandsApi.js +25 -4
- package/dist/createPwCodeApi.d.ts +92 -58
- package/dist/createPwCodeApi.js +4 -2
- package/dist/index.d.ts +11 -9
- package/dist/index.js +7 -5
- package/dist/locales/en/agentTranscript.js +6 -2
- package/dist/locales/en/agents.js +50 -6
- package/dist/locales/en.d.ts +46 -0
- package/dist/locales/es/agentTranscript.js +6 -2
- package/dist/locales/es/agents.js +50 -6
- package/dist/locales/ja/agentTranscript.js +6 -2
- package/dist/locales/ja/agents.js +45 -6
- package/dist/locales/ko/agentTranscript.js +6 -2
- package/dist/locales/ko/agents.js +50 -6
- package/dist/locales/zh/agentTranscript.js +6 -2
- package/dist/locales/zh/agents.js +50 -6
- package/dist/machine.d.ts +27 -2
- package/dist/machine.js +23 -2
- package/dist/notices.d.ts +2 -0
- package/dist/notices.js +29 -14
- package/dist/pwUpdate.d.ts +52 -0
- package/dist/pwUpdate.js +115 -0
- package/dist/query.d.ts +4 -1
- package/dist/query.js +9 -3
- package/dist/session.d.ts +7 -1
- package/dist/session.js +6 -2
- package/dist/sessionActions.js +5 -2
- package/dist/sessionEvents.d.ts +39 -5
- package/dist/sessionEvents.js +213 -83
- package/dist/sessionGroups.d.ts +3 -3
- package/dist/sessionGroups.js +3 -3
- package/dist/sessionHeader.js +6 -2
- package/dist/sessionList.d.ts +13 -8
- package/dist/sessionList.js +20 -10
- package/dist/sessionScreen.d.ts +8 -3
- package/dist/sessionScreen.js +20 -9
- package/dist/sessionsApi.d.ts +27 -5
- package/dist/sessionsApi.js +128 -17
- package/dist/sessionsFeed.d.ts +22 -0
- package/dist/sessionsFeed.js +125 -0
- package/dist/startPage.d.ts +6 -3
- package/dist/startPage.js +34 -12
- package/dist/startSession.d.ts +31 -11
- package/dist/startSession.js +126 -44
- package/dist/terminalHandoffPanel.js +8 -1
- package/dist/todos.d.ts +42 -0
- package/dist/todos.js +104 -0
- package/dist/transcript.d.ts +27 -5
- package/dist/transcript.js +148 -112
- package/dist/transcriptRead.d.ts +57 -0
- package/dist/transcriptRead.js +122 -0
- package/dist/types.d.ts +13 -1
- package/dist/useComposer.d.ts +36 -15
- package/dist/useComposer.js +94 -31
- package/dist/useComposerImages.d.ts +38 -1
- package/dist/useComposerImages.js +62 -8
- package/dist/useComposerPastes.js +3 -8
- package/dist/useConversation.d.ts +16 -0
- package/dist/useConversation.js +78 -8
- package/dist/useMounted.d.ts +3 -0
- package/dist/useMounted.js +14 -0
- package/dist/useSubagent.d.ts +22 -5
- package/dist/useSubagent.js +41 -17
- package/dist/useTranscript.d.ts +27 -1
- package/dist/useTranscript.js +217 -45
- package/dist/wording.d.ts +6 -3
- package/dist/wording.js +20 -6
- package/locales/en/agentTranscript.json +6 -2
- package/locales/en/agents.json +46 -4
- package/locales/es/agentTranscript.json +6 -2
- package/locales/es/agents.json +46 -4
- package/locales/ja/agentTranscript.json +6 -2
- package/locales/ja/agents.json +46 -4
- package/locales/ko/agentTranscript.json +6 -2
- package/locales/ko/agents.json +46 -4
- package/locales/zh/agentTranscript.json +6 -2
- package/locales/zh/agents.json +46 -4
- package/package.json +3 -3
package/dist/machine.js
CHANGED
|
@@ -4,9 +4,25 @@
|
|
|
4
4
|
function isComputer(machine) {
|
|
5
5
|
return machine.kind === "local";
|
|
6
6
|
}
|
|
7
|
+
/** The reader's own workspace, which is always listed. */
|
|
8
|
+
function isWorkspace(machine) {
|
|
9
|
+
return machine.kind === "workspace";
|
|
10
|
+
}
|
|
7
11
|
/** The pw code command that picks a session up. A resource's daemon answers
|
|
8
|
-
* any terminal signed in to pw; a computer's only
|
|
12
|
+
* any terminal signed in to pw; a computer's or a workspace's only one on it. */
|
|
9
13
|
function terminalHandoff(machine, sessionId, username) {
|
|
14
|
+
if (isWorkspace(machine)) {
|
|
15
|
+
const args = [
|
|
16
|
+
"code",
|
|
17
|
+
"-r",
|
|
18
|
+
sessionId
|
|
19
|
+
];
|
|
20
|
+
return {
|
|
21
|
+
on: "workspace",
|
|
22
|
+
command: `pw ${args.join(" ")}`,
|
|
23
|
+
args
|
|
24
|
+
};
|
|
25
|
+
}
|
|
10
26
|
if (isComputer(machine)) return {
|
|
11
27
|
on: "computer",
|
|
12
28
|
command: `pw code -r ${sessionId}`,
|
|
@@ -31,6 +47,11 @@ function splitMachines(machines) {
|
|
|
31
47
|
resources: machines.filter((m) => !isComputer(m))
|
|
32
48
|
};
|
|
33
49
|
}
|
|
50
|
+
/** The reader's own workspace while it starts, which the web app's ping does
|
|
51
|
+
* while the app is open. */
|
|
52
|
+
function isStarting(machine) {
|
|
53
|
+
return machine?.status === "starting";
|
|
54
|
+
}
|
|
34
55
|
function isConnected(machine) {
|
|
35
56
|
return machine?.status === "connected";
|
|
36
57
|
}
|
|
@@ -57,4 +78,4 @@ function machinesById(machines) {
|
|
|
57
78
|
function canStartHere(machine) {
|
|
58
79
|
return isConnected(machine) && !!machine.remoteStart;
|
|
59
80
|
}
|
|
60
|
-
export { canStartHere, isComputer, isConnected, isMachineDown, isUnreachableError, machinesById, splitMachines, terminalHandoff };
|
|
81
|
+
export { canStartHere, isComputer, isConnected, isMachineDown, isStarting, isUnreachableError, isWorkspace, machinesById, splitMachines, terminalHandoff };
|
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,31 +136,28 @@ 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,
|
|
139
146
|
deliveryLine: (n) => deliveryLine(t, n),
|
|
140
147
|
allowDirectory: ({ path, subtree }) => subtree ? tTranscript("transcript.allowDirectoryTree", { path }) : tTranscript("transcript.allowDirectoryOnly", { path }),
|
|
141
|
-
mainConversation: t("switcher.main")
|
|
148
|
+
mainConversation: t("switcher.main"),
|
|
149
|
+
skillActivated: (skill) => {
|
|
150
|
+
const activated = t("detail.skillActivated", { source: skill.source === "built-in" ? "builtin" : skill.source ?? "other" });
|
|
151
|
+
return skill.untrusted ? t("detail.skillUntrusted", {
|
|
152
|
+
activated,
|
|
153
|
+
name: skill.name
|
|
154
|
+
}) : activated;
|
|
155
|
+
},
|
|
156
|
+
scheduledRun: ({ taskId }) => taskId ? t("detail.scheduledTask", { id: taskId }) : t("detail.loopWakeup")
|
|
142
157
|
}), [
|
|
143
158
|
t,
|
|
144
159
|
tTranscript,
|
|
145
160
|
format
|
|
146
161
|
]);
|
|
147
162
|
}
|
|
148
|
-
export { turnDuration, useCompactionNotice, useGoalNotice, useRecapNotice, useResumeTime, useTranscriptWords };
|
|
163
|
+
export { turnDuration, useCompactionNotice, useGoalNotice, useRecapNotice, useResumeClock, useResumeTime, useTranscriptWords };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Schemas } from './apiClient.js';
|
|
2
|
+
import type { PwCodeMachine } from './machine.js';
|
|
3
|
+
import { type PwCodeTranslator } from './messages.js';
|
|
4
|
+
type Translate = PwCodeTranslator<'agents'>;
|
|
5
|
+
type Machine = Pick<PwCodeMachine, 'id' | 'name' | 'os' | 'pwVersion' | 'pwBuild' | 'pwUpdate' | 'pwUpgrade'>;
|
|
6
|
+
/** What an open session's screen says of a newer pw for its machine. */
|
|
7
|
+
export interface PwCodeUpdateNotice {
|
|
8
|
+
/** The pw and how far installing it got; the reader sets aside one of
|
|
9
|
+
* these, and the next brings the notice back. */
|
|
10
|
+
key: string;
|
|
11
|
+
state: Schemas['PwUpdate']['state'];
|
|
12
|
+
/** A failed install is a warning; the rest is news. */
|
|
13
|
+
tone: 'neutral' | 'warning';
|
|
14
|
+
text: string;
|
|
15
|
+
/** How much of the download has arrived, in percent, while an install
|
|
16
|
+
* reports it: the daemon's automatic one does not. */
|
|
17
|
+
progress: number | undefined;
|
|
18
|
+
/** Names the button that installs it, when /upgrade can from here. */
|
|
19
|
+
action: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
/** Null when the machine's pw is the newest, or its daemon says nothing of it. */
|
|
22
|
+
export declare function pwUpdateNotice(machine: Machine | undefined, t: Translate): PwCodeUpdateNotice | null;
|
|
23
|
+
/** The newer pw for an open session's machine, and /upgrade run on that
|
|
24
|
+
* session to install it. The host shows `notice` while it is set, and the
|
|
25
|
+
* listing it reads the machine from says how the install goes. */
|
|
26
|
+
export declare function usePwUpdate({ upgrade, machine, sessionId, archived, notify, onError, }: {
|
|
27
|
+
/** `api.upgradePw`. */
|
|
28
|
+
upgrade: (machine: string, sessionId: string) => Promise<{
|
|
29
|
+
answer: string;
|
|
30
|
+
} | {
|
|
31
|
+
error: unknown;
|
|
32
|
+
}>;
|
|
33
|
+
/** The session's machine, as `api.useMachine` reads it. */
|
|
34
|
+
machine: {
|
|
35
|
+
machine: Machine | undefined;
|
|
36
|
+
recheck: () => void;
|
|
37
|
+
};
|
|
38
|
+
sessionId: string;
|
|
39
|
+
/** Running /upgrade on an archived session would bring it back from Archived, so it offers no button. */
|
|
40
|
+
archived: boolean;
|
|
41
|
+
/** Shows what the daemon answered. */
|
|
42
|
+
notify: (text: string) => void;
|
|
43
|
+
/** Shows why the daemon refused. */
|
|
44
|
+
onError: (error: unknown) => void;
|
|
45
|
+
}): {
|
|
46
|
+
notice: PwCodeUpdateNotice | null;
|
|
47
|
+
/** The install was asked for and has yet to answer. */
|
|
48
|
+
starting: boolean;
|
|
49
|
+
update: () => void;
|
|
50
|
+
dismiss: () => void;
|
|
51
|
+
};
|
|
52
|
+
export {};
|
package/dist/pwUpdate.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { usePwCodeTranslations } from "./messages.js";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
// src/pwUpdate.ts
|
|
4
|
+
/** The pw the machine runs, named as its update is: by build on canary,
|
|
5
|
+
* whose builds share a release. */
|
|
6
|
+
function runningPw(machine) {
|
|
7
|
+
return (machine.pwUpdate?.canary === true ? machine.pwBuild : machine.pwVersion) ?? machine.pwVersion ?? "";
|
|
8
|
+
}
|
|
9
|
+
/** Null when the machine's pw is the newest, or its daemon says nothing of it. */
|
|
10
|
+
function pwUpdateNotice(machine, t) {
|
|
11
|
+
const update = machine?.pwUpdate;
|
|
12
|
+
if (!machine || !update) return null;
|
|
13
|
+
const values = {
|
|
14
|
+
version: update.version,
|
|
15
|
+
machine: machine.name,
|
|
16
|
+
running: runningPw(machine)
|
|
17
|
+
};
|
|
18
|
+
const notice = {
|
|
19
|
+
key: `${machine.id}:${update.version}:${update.error ? "failed" : update.state}`,
|
|
20
|
+
state: update.state,
|
|
21
|
+
tone: "neutral",
|
|
22
|
+
progress: void 0,
|
|
23
|
+
action: void 0
|
|
24
|
+
};
|
|
25
|
+
switch (update.state) {
|
|
26
|
+
case "installing": return {
|
|
27
|
+
...notice,
|
|
28
|
+
text: t("pwUpdate.installing", values),
|
|
29
|
+
progress: update.progress
|
|
30
|
+
};
|
|
31
|
+
case "installed": return {
|
|
32
|
+
...notice,
|
|
33
|
+
text: t("pwUpdate.installed", {
|
|
34
|
+
...values,
|
|
35
|
+
os: machine.os === "windows" ? "windows" : "other"
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
case "needs_admin": return {
|
|
39
|
+
...notice,
|
|
40
|
+
text: t("pwUpdate.needsAdmin", {
|
|
41
|
+
...values,
|
|
42
|
+
path: update.path ?? "pw"
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (!machine.pwUpgrade) return {
|
|
47
|
+
...notice,
|
|
48
|
+
text: t("pwUpdate.availableElsewhere", values)
|
|
49
|
+
};
|
|
50
|
+
if (update.error) return {
|
|
51
|
+
...notice,
|
|
52
|
+
tone: "warning",
|
|
53
|
+
text: t("pwUpdate.failed", {
|
|
54
|
+
...values,
|
|
55
|
+
error: update.error
|
|
56
|
+
}),
|
|
57
|
+
action: t("detail.retry")
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
...notice,
|
|
61
|
+
text: t("pwUpdate.available", values),
|
|
62
|
+
action: t("pwUpdate.update")
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** Set aside for as long as this page stays loaded, across the sessions it opens. */
|
|
66
|
+
var setAside = /* @__PURE__ */ new Set();
|
|
67
|
+
/** The newer pw for an open session's machine, and /upgrade run on that
|
|
68
|
+
* session to install it. The host shows `notice` while it is set, and the
|
|
69
|
+
* listing it reads the machine from says how the install goes. */
|
|
70
|
+
function usePwUpdate({ upgrade, machine, sessionId, archived, notify, onError }) {
|
|
71
|
+
const t = usePwCodeTranslations("agents");
|
|
72
|
+
const { machine: info, recheck } = machine;
|
|
73
|
+
const [starting, setStarting] = useState(false);
|
|
74
|
+
const [, setDismissed] = useState(0);
|
|
75
|
+
const notice = pwUpdateNotice(info, t);
|
|
76
|
+
const id = info?.id;
|
|
77
|
+
const update = useCallback(() => {
|
|
78
|
+
if (!id || starting || archived) return;
|
|
79
|
+
setStarting(true);
|
|
80
|
+
upgrade(id, sessionId).then((outcome) => {
|
|
81
|
+
if ("error" in outcome) onError(outcome.error);
|
|
82
|
+
else notify(outcome.answer);
|
|
83
|
+
}).finally(() => {
|
|
84
|
+
setStarting(false);
|
|
85
|
+
recheck();
|
|
86
|
+
});
|
|
87
|
+
}, [
|
|
88
|
+
id,
|
|
89
|
+
starting,
|
|
90
|
+
archived,
|
|
91
|
+
upgrade,
|
|
92
|
+
sessionId,
|
|
93
|
+
onError,
|
|
94
|
+
notify,
|
|
95
|
+
recheck
|
|
96
|
+
]);
|
|
97
|
+
const key = notice?.key;
|
|
98
|
+
const dismiss = useCallback(() => {
|
|
99
|
+
if (key) {
|
|
100
|
+
setAside.add(key);
|
|
101
|
+
setDismissed((n) => n + 1);
|
|
102
|
+
}
|
|
103
|
+
}, [key]);
|
|
104
|
+
const shown = notice && !setAside.has(notice.key) ? notice : null;
|
|
105
|
+
return {
|
|
106
|
+
notice: shown && archived ? {
|
|
107
|
+
...shown,
|
|
108
|
+
action: void 0
|
|
109
|
+
} : shown,
|
|
110
|
+
starting,
|
|
111
|
+
update,
|
|
112
|
+
dismiss
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export { pwUpdateNotice, usePwUpdate };
|
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
|
|
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(
|
|
65
|
-
}, [
|
|
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,7 +53,9 @@ 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;
|
|
52
|
-
/**
|
|
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;
|
|
58
|
+
/** A turn is in flight: there is work to stop, and the session can't leave its worktree. */
|
|
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
|
|
55
61
|
* problem, not the session's. `idle` is what a resting session shows, the
|
package/dist/session.js
CHANGED
|
@@ -50,7 +50,11 @@ function isActiveSession(s) {
|
|
|
50
50
|
function isArchived(s) {
|
|
51
51
|
return !!s.archivedAt;
|
|
52
52
|
}
|
|
53
|
-
/**
|
|
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
|
+
}
|
|
57
|
+
/** A turn is in flight: there is work to stop, and the session can't leave its worktree. */
|
|
54
58
|
function isMidTurn(s) {
|
|
55
59
|
return s.status === "running" || s.status === "awaiting_approval";
|
|
56
60
|
}
|
|
@@ -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 };
|
package/dist/sessionActions.js
CHANGED
|
@@ -18,6 +18,9 @@ function sessionActionBlocked(session, machine, t) {
|
|
|
18
18
|
if (isMachineDown(machine)) return machineBlocked(machine, t);
|
|
19
19
|
if (session.status === "live_elsewhere") return sessionStatusText(session, t);
|
|
20
20
|
}
|
|
21
|
+
function forkBlocked(session, machine, t) {
|
|
22
|
+
return isMidTurn(session) && !machine?.forkMidTurn ? t("sidebar.forkMidTurn") : void 0;
|
|
23
|
+
}
|
|
21
24
|
function menuCommand(action, label, run, disabledReason, shortcut) {
|
|
22
25
|
return {
|
|
23
26
|
action,
|
|
@@ -131,11 +134,11 @@ function useSessionActions({ api, machineById, open, confirm, onRefusal, onWarni
|
|
|
131
134
|
"divider",
|
|
132
135
|
remove
|
|
133
136
|
];
|
|
134
|
-
const midTurn = isMidTurn(session) ? t("sidebar.
|
|
137
|
+
const midTurn = isMidTurn(session) ? t("sidebar.leaveWorktreeMidTurn") : void 0;
|
|
135
138
|
return [
|
|
136
139
|
rename,
|
|
137
140
|
menuCommand(session.pinnedAt ? "unpin" : "pin", session.pinnedAt ? t("sidebar.unpin") : t("sidebar.pin"), () => togglePin(session), machineDown),
|
|
138
|
-
menuCommand("fork", t("sidebar.fork"), () => fork(session), disabledReason ??
|
|
141
|
+
menuCommand("fork", t("sidebar.fork"), () => fork(session), disabledReason ?? forkBlocked(session, machine, t)),
|
|
139
142
|
...worktree ? [menuCommand("leaveWorktree", t("sidebar.leaveWorktree"), () => requestLeaveWorktree(session, worktree), disabledReason ?? midTurn)] : [],
|
|
140
143
|
...isMidTurn(session) ? [menuCommand("stop", t("sidebar.stop"), () => stop(session), machineDown)] : [],
|
|
141
144
|
menuCommand("archive", t("sidebar.archive"), () => requestArchive(session, row), disabledReason, rowKey(ARCHIVE_KEY)),
|
package/dist/sessionEvents.d.ts
CHANGED
|
@@ -6,21 +6,54 @@ export interface PwCodeSocketOptions {
|
|
|
6
6
|
* client is. Resolving asynchronously lets a host fetch a token first. Each
|
|
7
7
|
* reconnect calls it again, with the path resuming after the last frame. */
|
|
8
8
|
openSocket?: ((path: string) => WebSocket | Promise<WebSocket>) | undefined;
|
|
9
|
-
/** Whether the app is out of sight, where animation frames do not run
|
|
10
|
-
*
|
|
9
|
+
/** Whether the app is out of sight, where animation frames do not run. A
|
|
10
|
+
* reply streaming there is applied about once a second, and every other
|
|
11
|
+
* frame as it arrives. */
|
|
11
12
|
hidden?: (() => boolean) | undefined;
|
|
13
|
+
/** Calls `shown` each time the app comes back into sight, until the returned
|
|
14
|
+
* call, so what streamed while it was hidden is drawn at once. */
|
|
15
|
+
whenShown?: ((shown: () => void) => () => void) | undefined;
|
|
12
16
|
}
|
|
17
|
+
/** The seconds between the heartbeats a feed asks the platform for. */
|
|
18
|
+
export declare const HEARTBEAT_S = 10;
|
|
19
|
+
/** How long a hidden app holds a streaming reply's frames: each one applied
|
|
20
|
+
* re-renders the transcript and reads its layout. */
|
|
21
|
+
export declare const HIDDEN_STREAM_MS = 1000;
|
|
13
22
|
/** The path a session's event feed is served at, resuming after frame `after`.
|
|
14
23
|
* With `previewsByRef` the images a tool read come without their previews,
|
|
15
24
|
* which the host loads by URL: a preview is tens of kilobytes, and over a slow
|
|
16
25
|
* connection what the session says next waits behind it. */
|
|
17
26
|
export declare function sessionEventsPath(machine: string, id: string, after: number, previewsByRef?: boolean): string;
|
|
18
|
-
/**
|
|
19
|
-
|
|
27
|
+
/** Whether a frame is the heartbeat the platform sends a feed that asked for one. */
|
|
28
|
+
export declare function isHeartbeat(data: unknown): boolean;
|
|
29
|
+
/** Frames after which the list of subagents may read differently: one started,
|
|
30
|
+
* ended or was dismissed, one asked for or got an approval, or a turn began or closed. */
|
|
20
31
|
export declare function changesSubagents(ev: StreamEvent): boolean;
|
|
21
32
|
/** `machines` with each one in `fed` that the listing lost counted as connected. */
|
|
22
33
|
export declare function reachedByFeed(machines: Machine[], fed: ReadonlySet<string>): Machine[];
|
|
23
|
-
|
|
34
|
+
/** What a held socket reads at each step, so its holder can change them
|
|
35
|
+
* without the socket reopening. */
|
|
36
|
+
export interface HeldSocket {
|
|
37
|
+
open: ((path: string) => WebSocket | Promise<WebSocket>) | undefined;
|
|
38
|
+
/** Read on every attempt, so a reconnect resumes where the last one left off. */
|
|
39
|
+
path: () => string;
|
|
40
|
+
/** `revived` when it is the socket that had gone silent, carrying on. */
|
|
41
|
+
onOpen: (revived: boolean) => void;
|
|
42
|
+
onMessage: (data: unknown) => void;
|
|
43
|
+
onClose: () => void;
|
|
44
|
+
/** Hands over what tries the socket at once if it is waiting to try again,
|
|
45
|
+
* for whoever learns its far end can be reached; returns what takes it back. */
|
|
46
|
+
whenReachable?: ((tryNow: () => void) => () => void) | undefined;
|
|
47
|
+
/** Whether a frame is the far end's heartbeat, which is no message. Once a
|
|
48
|
+
* socket has sent one, it is left when it says nothing for too long. */
|
|
49
|
+
heartbeat?: ((data: unknown) => boolean) | undefined;
|
|
50
|
+
}
|
|
51
|
+
/** Holds one socket open until the returned call, reopening it with backoff
|
|
52
|
+
* after it drops. */
|
|
53
|
+
export declare function holdSocket(latest: {
|
|
54
|
+
current: HeldSocket;
|
|
55
|
+
}, setConnected: (connected: boolean) => void): () => void;
|
|
56
|
+
export declare function sessionEvents({ openSocket, hidden, whenShown, previewsByRef, }: PwCodeSocketOptions & {
|
|
24
57
|
previewsByRef?: boolean | undefined;
|
|
25
58
|
}): {
|
|
26
59
|
useSessionEvents: (machine: string, id: string, cursor: (() => number) | undefined, onEvent: (event: StreamEvent) => void) => {
|
|
@@ -28,5 +61,6 @@ export declare function sessionEvents({ openSocket, hidden, previewsByRef, }: Pw
|
|
|
28
61
|
disconnected: boolean;
|
|
29
62
|
};
|
|
30
63
|
useFedMachines: () => ReadonlySet<string>;
|
|
64
|
+
listed: (machines: readonly Machine[]) => void;
|
|
31
65
|
};
|
|
32
66
|
export {};
|