@chrysb/alphaclaw 0.6.2-beta.6 → 0.7.0-beta.1
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/lib/public/css/agents.css +37 -13
- package/lib/public/css/cron.css +124 -18
- package/lib/public/css/shell.css +61 -2
- package/lib/public/css/theme.css +2 -1
- package/lib/public/js/app.js +41 -33
- package/lib/public/js/components/agents-tab/agent-detail-panel.js +61 -49
- package/lib/public/js/components/agents-tab/agent-overview/index.js +9 -0
- package/lib/public/js/components/agents-tab/agent-overview/tools-card.js +54 -0
- package/lib/public/js/components/cron-tab/cron-calendar.js +164 -151
- package/lib/public/js/components/cron-tab/cron-helpers.js +48 -0
- package/lib/public/js/components/cron-tab/cron-insights-panel.js +8 -39
- package/lib/public/js/components/cron-tab/cron-run-history-panel.js +8 -9
- package/lib/public/js/components/cron-tab/cron-runs-trend-card.js +4 -22
- package/lib/public/js/components/envars.js +187 -46
- package/lib/public/js/components/icons.js +11 -0
- package/lib/public/js/components/models-tab/index.js +137 -133
- package/lib/public/js/components/models-tab/provider-auth-card.js +8 -1
- package/lib/public/js/components/models-tab/use-models.js +35 -8
- package/lib/public/js/components/pane-shell.js +27 -0
- package/lib/public/js/components/routes/envars-route.js +1 -3
- package/lib/public/js/components/routes/models-route.js +1 -3
- package/lib/public/js/lib/app-navigation.js +1 -1
- package/lib/server/cost-utils.js +2 -2
- package/package.json +1 -1
|
@@ -4,6 +4,8 @@ import htm from "https://esm.sh/htm";
|
|
|
4
4
|
import { PageHeader } from "../page-header.js";
|
|
5
5
|
import { LoadingSpinner } from "../loading-spinner.js";
|
|
6
6
|
import { ActionButton } from "../action-button.js";
|
|
7
|
+
import { PopActions } from "../pop-actions.js";
|
|
8
|
+
import { PaneShell } from "../pane-shell.js";
|
|
7
9
|
import { Badge } from "../badge.js";
|
|
8
10
|
import { useModels } from "./use-models.js";
|
|
9
11
|
import {
|
|
@@ -123,155 +125,157 @@ export const Models = ({ onRestartRequired = () => {}, agentId, embedded = false
|
|
|
123
125
|
);
|
|
124
126
|
|
|
125
127
|
const headerActions = html`
|
|
126
|
-
<${
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
128
|
+
<${PopActions} visible=${isDirty}>
|
|
129
|
+
<${ActionButton}
|
|
130
|
+
onClick=${cancelChanges}
|
|
131
|
+
disabled=${saving}
|
|
132
|
+
tone="secondary"
|
|
133
|
+
size="sm"
|
|
134
|
+
idleLabel="Cancel"
|
|
135
|
+
className="text-xs"
|
|
136
|
+
/>
|
|
137
|
+
<${ActionButton}
|
|
138
|
+
onClick=${saveAll}
|
|
139
|
+
disabled=${saving}
|
|
140
|
+
loading=${saving}
|
|
141
|
+
loadingMode="inline"
|
|
142
|
+
tone="primary"
|
|
143
|
+
size="sm"
|
|
144
|
+
idleLabel="Save changes"
|
|
145
|
+
loadingLabel="Saving…"
|
|
146
|
+
className="text-xs"
|
|
147
|
+
/>
|
|
148
|
+
</${PopActions}>
|
|
144
149
|
`;
|
|
145
150
|
|
|
146
151
|
if (!ready) {
|
|
147
|
-
|
|
148
|
-
<div class="
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
title="Models"
|
|
153
|
-
actions=${html`
|
|
154
|
-
<${ActionButton}
|
|
155
|
-
disabled=${true}
|
|
156
|
-
tone="primary"
|
|
157
|
-
size="sm"
|
|
158
|
-
idleLabel="Save changes"
|
|
159
|
-
className="transition-all"
|
|
160
|
-
/>
|
|
161
|
-
`}
|
|
162
|
-
/>
|
|
163
|
-
`
|
|
164
|
-
: null}
|
|
165
|
-
<div class="bg-surface border border-border rounded-xl p-4">
|
|
166
|
-
<div class="flex items-center gap-2 text-sm text-gray-400">
|
|
167
|
-
<${LoadingSpinner} className="h-4 w-4" />
|
|
168
|
-
Loading model settings...
|
|
169
|
-
</div>
|
|
152
|
+
const loadingBody = html`
|
|
153
|
+
<div class="bg-surface border border-border rounded-xl p-4">
|
|
154
|
+
<div class="flex items-center gap-2 text-sm text-gray-400">
|
|
155
|
+
<${LoadingSpinner} className="h-4 w-4" />
|
|
156
|
+
Loading model settings...
|
|
170
157
|
</div>
|
|
171
158
|
</div>
|
|
172
159
|
`;
|
|
160
|
+
if (embedded) return loadingBody;
|
|
161
|
+
return html`
|
|
162
|
+
<${PaneShell}
|
|
163
|
+
header=${html`<${PageHeader} title="Models" />`}
|
|
164
|
+
>
|
|
165
|
+
${loadingBody}
|
|
166
|
+
</${PaneShell}>
|
|
167
|
+
`;
|
|
173
168
|
}
|
|
174
169
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
170
|
+
const bodyContent = html`
|
|
171
|
+
<!-- Configured Models -->
|
|
172
|
+
<div class="bg-surface border border-border rounded-xl p-4 space-y-3">
|
|
173
|
+
<h2 class="card-label">Available Models</h2>
|
|
174
|
+
|
|
175
|
+
${configuredModelEntries.length === 0
|
|
176
|
+
? html`<p class="text-xs text-gray-500">
|
|
177
|
+
No models configured. Add a model below.
|
|
178
|
+
</p>`
|
|
179
179
|
: html`
|
|
180
|
-
<div class="
|
|
181
|
-
${
|
|
180
|
+
<div class="space-y-1">
|
|
181
|
+
${configuredModelEntries.map(
|
|
182
|
+
(entry) => html`
|
|
183
|
+
<div
|
|
184
|
+
class="flex items-center justify-between py-1.5 px-2 rounded-lg hover:bg-white/5"
|
|
185
|
+
>
|
|
186
|
+
<div class="flex items-center gap-2 min-w-0">
|
|
187
|
+
<span class="text-sm text-gray-200 truncate"
|
|
188
|
+
>${entry.label}</span
|
|
189
|
+
>
|
|
190
|
+
${entry.isPrimary
|
|
191
|
+
? html`<${Badge} tone="cyan">Primary</${Badge}>`
|
|
192
|
+
: entry.hasAuth
|
|
193
|
+
? html`
|
|
194
|
+
<button
|
|
195
|
+
onclick=${() => setPrimaryModel(entry.key)}
|
|
196
|
+
class="text-xs px-2 py-0.5 rounded-full text-gray-500 hover:text-gray-300 hover:bg-white/5"
|
|
197
|
+
>
|
|
198
|
+
Set primary
|
|
199
|
+
</button>
|
|
200
|
+
`
|
|
201
|
+
: html`<${Badge} tone="warning">Needs auth</${Badge}>`}
|
|
202
|
+
</div>
|
|
203
|
+
<button
|
|
204
|
+
onclick=${() => removeModel(entry.key)}
|
|
205
|
+
class="text-xs text-gray-600 hover:text-red-400 shrink-0 px-1"
|
|
206
|
+
>
|
|
207
|
+
Remove
|
|
208
|
+
</button>
|
|
209
|
+
</div>
|
|
210
|
+
`,
|
|
211
|
+
)}
|
|
182
212
|
</div>
|
|
183
213
|
`}
|
|
184
214
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
215
|
+
<div class="space-y-2">
|
|
216
|
+
<${SearchableModelPicker}
|
|
217
|
+
options=${pickerModels}
|
|
218
|
+
popularModels=${popularPickerModels}
|
|
219
|
+
placeholder="Add model..."
|
|
220
|
+
onSelect=${(modelKey) => {
|
|
221
|
+
addModel(modelKey);
|
|
222
|
+
if (!primary) setPrimaryModel(modelKey);
|
|
223
|
+
}}
|
|
224
|
+
/>
|
|
225
|
+
</div>
|
|
188
226
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
<div
|
|
198
|
-
class="flex items-center justify-between py-1.5 px-2 rounded-lg hover:bg-white/5"
|
|
199
|
-
>
|
|
200
|
-
<div class="flex items-center gap-2 min-w-0">
|
|
201
|
-
<span class="text-sm text-gray-200 truncate"
|
|
202
|
-
>${entry.label}</span
|
|
203
|
-
>
|
|
204
|
-
${entry.isPrimary
|
|
205
|
-
? html`<${Badge} tone="cyan">Primary</${Badge}>`
|
|
206
|
-
: entry.hasAuth
|
|
207
|
-
? html`
|
|
208
|
-
<button
|
|
209
|
-
onclick=${() => setPrimaryModel(entry.key)}
|
|
210
|
-
class="text-xs px-2 py-0.5 rounded-full text-gray-500 hover:text-gray-300 hover:bg-white/5"
|
|
211
|
-
>
|
|
212
|
-
Set primary
|
|
213
|
-
</button>
|
|
214
|
-
`
|
|
215
|
-
: html`<${Badge} tone="warning">Needs auth</${Badge}>`}
|
|
216
|
-
</div>
|
|
217
|
-
<button
|
|
218
|
-
onclick=${() => removeModel(entry.key)}
|
|
219
|
-
class="text-xs text-gray-600 hover:text-red-400 shrink-0 px-1"
|
|
220
|
-
>
|
|
221
|
-
Remove
|
|
222
|
-
</button>
|
|
223
|
-
</div>
|
|
224
|
-
`,
|
|
225
|
-
)}
|
|
226
|
-
</div>
|
|
227
|
-
`}
|
|
227
|
+
${loading
|
|
228
|
+
? html`<p class="text-xs text-gray-600">
|
|
229
|
+
Loading model catalog...
|
|
230
|
+
</p>`
|
|
231
|
+
: error
|
|
232
|
+
? html`<p class="text-xs text-gray-600">${error}</p>`
|
|
233
|
+
: null}
|
|
234
|
+
</div>
|
|
228
235
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
236
|
+
<!-- Provider Auth -->
|
|
237
|
+
${sortedProviders.length > 0
|
|
238
|
+
? html`
|
|
239
|
+
<div class="space-y-3">
|
|
240
|
+
<h2 class="font-semibold text-base">
|
|
241
|
+
Provider Authentication
|
|
242
|
+
</h2>
|
|
243
|
+
${sortedProviders.map(
|
|
244
|
+
(provider) => html`
|
|
245
|
+
<${ProviderAuthCard}
|
|
246
|
+
provider=${provider}
|
|
247
|
+
authProfiles=${authProfiles}
|
|
248
|
+
authOrder=${authOrder}
|
|
249
|
+
codexStatus=${codexStatus}
|
|
250
|
+
onEditProfile=${editProfile}
|
|
251
|
+
onEditAuthOrder=${editAuthOrder}
|
|
252
|
+
getProfileValue=${getProfileValue}
|
|
253
|
+
getEffectiveOrder=${getEffectiveOrder}
|
|
254
|
+
onRefreshCodex=${refreshCodexStatus}
|
|
255
|
+
/>
|
|
256
|
+
`,
|
|
257
|
+
)}
|
|
258
|
+
</div>
|
|
259
|
+
`
|
|
260
|
+
: null}
|
|
261
|
+
`;
|
|
240
262
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
263
|
+
if (embedded) {
|
|
264
|
+
return html`
|
|
265
|
+
<div class="space-y-4">
|
|
266
|
+
<div class="flex items-center justify-end gap-2">
|
|
267
|
+
${headerActions}
|
|
268
|
+
</div>
|
|
269
|
+
${bodyContent}
|
|
248
270
|
</div>
|
|
271
|
+
`;
|
|
272
|
+
}
|
|
249
273
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
</h2>
|
|
257
|
-
${sortedProviders.map(
|
|
258
|
-
(provider) => html`
|
|
259
|
-
<${ProviderAuthCard}
|
|
260
|
-
provider=${provider}
|
|
261
|
-
authProfiles=${authProfiles}
|
|
262
|
-
authOrder=${authOrder}
|
|
263
|
-
codexStatus=${codexStatus}
|
|
264
|
-
onEditProfile=${editProfile}
|
|
265
|
-
onEditAuthOrder=${editAuthOrder}
|
|
266
|
-
getProfileValue=${getProfileValue}
|
|
267
|
-
getEffectiveOrder=${getEffectiveOrder}
|
|
268
|
-
onRefreshCodex=${refreshCodexStatus}
|
|
269
|
-
/>
|
|
270
|
-
`,
|
|
271
|
-
)}
|
|
272
|
-
</div>
|
|
273
|
-
`
|
|
274
|
-
: null}
|
|
275
|
-
</div>
|
|
274
|
+
return html`
|
|
275
|
+
<${PaneShell}
|
|
276
|
+
header=${html`<${PageHeader} title="Models" actions=${headerActions} />`}
|
|
277
|
+
>
|
|
278
|
+
${bodyContent}
|
|
279
|
+
</${PaneShell}>
|
|
276
280
|
`;
|
|
277
281
|
};
|
|
@@ -375,7 +375,14 @@ export const ProviderAuthCard = ({
|
|
|
375
375
|
};
|
|
376
376
|
if (currentValue?.expires) cred.expires = currentValue.expires;
|
|
377
377
|
onEditProfile(profileId, cred);
|
|
378
|
-
|
|
378
|
+
const savedProfile =
|
|
379
|
+
authProfiles.find((p) => p.id === profileId) || null;
|
|
380
|
+
const isReverted =
|
|
381
|
+
getCredentialValue(cred) ===
|
|
382
|
+
getCredentialValue(savedProfile);
|
|
383
|
+
if (isReverted && hasMultipleModes) {
|
|
384
|
+
onEditAuthOrder(provider, savedOrder);
|
|
385
|
+
} else if (hasMultipleModes && newVal && !isActive) {
|
|
379
386
|
handleSetActive(mode);
|
|
380
387
|
}
|
|
381
388
|
}}
|
|
@@ -92,10 +92,13 @@ export const useModels = (agentId) => {
|
|
|
92
92
|
refresh();
|
|
93
93
|
}, [agentId]);
|
|
94
94
|
|
|
95
|
+
const stableStringify = (obj) =>
|
|
96
|
+
JSON.stringify(Object.keys(obj).sort().reduce((acc, k) => { acc[k] = obj[k]; return acc; }, {}));
|
|
97
|
+
|
|
95
98
|
const modelConfigDirty =
|
|
96
99
|
primary !== savedPrimaryRef.current ||
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
stableStringify(configuredModels) !==
|
|
101
|
+
stableStringify(savedConfiguredRef.current);
|
|
99
102
|
|
|
100
103
|
const authDirty = (() => {
|
|
101
104
|
const hasProfileChanges = Object.entries(profileEdits).some(
|
|
@@ -155,13 +158,37 @@ export const useModels = (agentId) => {
|
|
|
155
158
|
[updateCache],
|
|
156
159
|
);
|
|
157
160
|
|
|
158
|
-
const editProfile = useCallback(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
+
const editProfile = useCallback(
|
|
162
|
+
(profileId, credential) => {
|
|
163
|
+
const existing = authProfiles.find((p) => p.id === profileId);
|
|
164
|
+
if (getCredentialValue(credential) === getCredentialValue(existing)) {
|
|
165
|
+
setProfileEdits((prev) => {
|
|
166
|
+
const next = { ...prev };
|
|
167
|
+
delete next[profileId];
|
|
168
|
+
return next;
|
|
169
|
+
});
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
setProfileEdits((prev) => ({ ...prev, [profileId]: credential }));
|
|
173
|
+
},
|
|
174
|
+
[authProfiles],
|
|
175
|
+
);
|
|
161
176
|
|
|
162
|
-
const editAuthOrder = useCallback(
|
|
163
|
-
|
|
164
|
-
|
|
177
|
+
const editAuthOrder = useCallback(
|
|
178
|
+
(provider, orderedIds) => {
|
|
179
|
+
const existing = authOrder[provider] || null;
|
|
180
|
+
if (JSON.stringify(orderedIds) === JSON.stringify(existing)) {
|
|
181
|
+
setOrderEdits((prev) => {
|
|
182
|
+
const next = { ...prev };
|
|
183
|
+
delete next[provider];
|
|
184
|
+
return next;
|
|
185
|
+
});
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
setOrderEdits((prev) => ({ ...prev, [provider]: orderedIds }));
|
|
189
|
+
},
|
|
190
|
+
[authOrder],
|
|
191
|
+
);
|
|
165
192
|
|
|
166
193
|
const getProfileValue = useCallback(
|
|
167
194
|
(profileId) => {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { h } from "https://esm.sh/preact";
|
|
2
|
+
import htm from "https://esm.sh/htm";
|
|
3
|
+
|
|
4
|
+
const html = htm.bind(h);
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Shared layout shell for pages that need a fixed header with a
|
|
8
|
+
* separately scrollable body. The header stays pinned at the top
|
|
9
|
+
* while body content scrolls underneath.
|
|
10
|
+
*
|
|
11
|
+
* @param {preact.ComponentChildren} props.header Content rendered in the fixed header area.
|
|
12
|
+
* @param {preact.ComponentChildren} props.children Content rendered in the scrollable body.
|
|
13
|
+
*/
|
|
14
|
+
export const PaneShell = ({ header, children }) => html`
|
|
15
|
+
<div class="ac-pane-shell">
|
|
16
|
+
<div class="ac-pane-header">
|
|
17
|
+
<div class="ac-pane-header-content">
|
|
18
|
+
${header}
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
<div class="ac-pane-body">
|
|
22
|
+
<div class="ac-pane-body-content">
|
|
23
|
+
${children}
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
`;
|
|
@@ -5,7 +5,5 @@ import { Envars } from "../envars.js";
|
|
|
5
5
|
const html = htm.bind(h);
|
|
6
6
|
|
|
7
7
|
export const EnvarsRoute = ({ onRestartRequired = () => {} }) => html`
|
|
8
|
-
|
|
9
|
-
<${Envars} onRestartRequired=${onRestartRequired} />
|
|
10
|
-
</div>
|
|
8
|
+
<${Envars} onRestartRequired=${onRestartRequired} />
|
|
11
9
|
`;
|
|
@@ -5,7 +5,5 @@ import { Models } from "../models-tab/index.js";
|
|
|
5
5
|
const html = htm.bind(h);
|
|
6
6
|
|
|
7
7
|
export const ModelsRoute = ({ onRestartRequired = () => {} }) => html`
|
|
8
|
-
|
|
9
|
-
<${Models} onRestartRequired=${onRestartRequired} />
|
|
10
|
-
</div>
|
|
8
|
+
<${Models} onRestartRequired=${onRestartRequired} />
|
|
11
9
|
`;
|
|
@@ -10,10 +10,10 @@ export const kNavSections = [
|
|
|
10
10
|
{
|
|
11
11
|
label: "Monitoring",
|
|
12
12
|
items: [
|
|
13
|
-
{ id: "watchdog", label: "Watchdog" },
|
|
14
13
|
{ id: "cron", label: "Cron" },
|
|
15
14
|
{ id: "usage", label: "Usage" },
|
|
16
15
|
{ id: "doctor", label: "Doctor" },
|
|
16
|
+
{ id: "watchdog", label: "Watchdog" },
|
|
17
17
|
],
|
|
18
18
|
},
|
|
19
19
|
{
|
package/lib/server/cost-utils.js
CHANGED
|
@@ -267,8 +267,8 @@ const deriveCostBreakdown = ({
|
|
|
267
267
|
model = "",
|
|
268
268
|
} = {}) => {
|
|
269
269
|
const pricing =
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
resolvePricingFromOpenclawNodeModules({ provider, model }) ||
|
|
271
|
+
resolvePricingFromFallbackMap(model);
|
|
272
272
|
if (!pricing) {
|
|
273
273
|
return {
|
|
274
274
|
inputCost: 0,
|