@slkiser/opencode-quota 3.11.2 → 4.0.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 +90 -62
- package/dist/bin/opencode-quota.d.ts.map +1 -1
- package/dist/bin/opencode-quota.js +16 -7
- package/dist/bin/opencode-quota.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/cli-show.d.ts.map +1 -1
- package/dist/lib/cli-show.js +11 -7
- package/dist/lib/cli-show.js.map +1 -1
- package/dist/lib/command-surfaces.d.ts +10 -0
- package/dist/lib/command-surfaces.d.ts.map +1 -0
- package/dist/lib/command-surfaces.js +9 -0
- package/dist/lib/command-surfaces.js.map +1 -0
- package/dist/lib/config-file-utils.d.ts +5 -0
- package/dist/lib/config-file-utils.d.ts.map +1 -1
- package/dist/lib/config-file-utils.js +20 -3
- package/dist/lib/config-file-utils.js.map +1 -1
- package/dist/lib/config.d.ts +5 -3
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +124 -32
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/copilot.d.ts +19 -12
- package/dist/lib/copilot.d.ts.map +1 -1
- package/dist/lib/copilot.js +462 -566
- package/dist/lib/copilot.js.map +1 -1
- package/dist/lib/display-sanitize.d.ts.map +1 -1
- package/dist/lib/display-sanitize.js +13 -0
- package/dist/lib/display-sanitize.js.map +1 -1
- package/dist/lib/entries.d.ts +53 -4
- package/dist/lib/entries.d.ts.map +1 -1
- package/dist/lib/entries.js.map +1 -1
- package/dist/lib/init-installer.d.ts +11 -1
- package/dist/lib/init-installer.d.ts.map +1 -1
- package/dist/lib/init-installer.js +524 -158
- package/dist/lib/init-installer.js.map +1 -1
- package/dist/lib/opencode-config-editor.d.ts +53 -0
- package/dist/lib/opencode-config-editor.d.ts.map +1 -0
- package/dist/lib/opencode-config-editor.js +274 -0
- package/dist/lib/opencode-config-editor.js.map +1 -0
- package/dist/lib/opencode-config-providers.d.ts +18 -0
- package/dist/lib/opencode-config-providers.d.ts.map +1 -1
- package/dist/lib/opencode-config-providers.js +75 -4
- package/dist/lib/opencode-config-providers.js.map +1 -1
- package/dist/lib/opencode-runtime-paths.d.ts.map +1 -1
- package/dist/lib/opencode-runtime-paths.js +10 -3
- package/dist/lib/opencode-runtime-paths.js.map +1 -1
- package/dist/lib/opencode-storage.d.ts +10 -0
- package/dist/lib/opencode-storage.d.ts.map +1 -1
- package/dist/lib/opencode-storage.js +75 -0
- package/dist/lib/opencode-storage.js.map +1 -1
- package/dist/lib/provider-add-command.d.ts +35 -0
- package/dist/lib/provider-add-command.d.ts.map +1 -0
- package/dist/lib/provider-add-command.js +185 -0
- package/dist/lib/provider-add-command.js.map +1 -0
- package/dist/lib/provider-add.d.ts +21 -0
- package/dist/lib/provider-add.d.ts.map +1 -0
- package/dist/lib/provider-add.js +210 -0
- package/dist/lib/provider-add.js.map +1 -0
- package/dist/lib/provider-metadata.d.ts +1 -1
- package/dist/lib/provider-metadata.d.ts.map +1 -1
- package/dist/lib/provider-metadata.js +11 -5
- package/dist/lib/provider-metadata.js.map +1 -1
- package/dist/lib/quota-command-format.d.ts +2 -0
- package/dist/lib/quota-command-format.d.ts.map +1 -1
- package/dist/lib/quota-command-format.js +94 -26
- package/dist/lib/quota-command-format.js.map +1 -1
- package/dist/lib/quota-dialog-commands.d.ts.map +1 -1
- package/dist/lib/quota-dialog-commands.js +8 -4
- package/dist/lib/quota-dialog-commands.js.map +1 -1
- package/dist/lib/quota-export-types.d.ts +48 -27
- package/dist/lib/quota-export-types.d.ts.map +1 -1
- package/dist/lib/quota-export-types.js +0 -7
- package/dist/lib/quota-export-types.js.map +1 -1
- package/dist/lib/quota-export.d.ts.map +1 -1
- package/dist/lib/quota-export.js +63 -16
- package/dist/lib/quota-export.js.map +1 -1
- package/dist/lib/quota-providers-local.d.ts +55 -0
- package/dist/lib/quota-providers-local.d.ts.map +1 -0
- package/dist/lib/quota-providers-local.js +313 -0
- package/dist/lib/quota-providers-local.js.map +1 -0
- package/dist/lib/quota-providers-remote.d.ts +23 -0
- package/dist/lib/quota-providers-remote.d.ts.map +1 -0
- package/dist/lib/quota-providers-remote.js +318 -0
- package/dist/lib/quota-providers-remote.js.map +1 -0
- package/dist/lib/quota-providers.d.ts +77 -0
- package/dist/lib/quota-providers.d.ts.map +1 -0
- package/dist/lib/quota-providers.js +630 -0
- package/dist/lib/quota-providers.js.map +1 -0
- package/dist/lib/quota-render-data.d.ts +1 -0
- package/dist/lib/quota-render-data.d.ts.map +1 -1
- package/dist/lib/quota-render-data.js +35 -16
- package/dist/lib/quota-render-data.js.map +1 -1
- package/dist/lib/quota-runtime-context.d.ts.map +1 -1
- package/dist/lib/quota-runtime-context.js +3 -4
- package/dist/lib/quota-runtime-context.js.map +1 -1
- package/dist/lib/quota-state.d.ts +5 -2
- package/dist/lib/quota-state.d.ts.map +1 -1
- package/dist/lib/quota-state.js +268 -51
- package/dist/lib/quota-state.js.map +1 -1
- package/dist/lib/quota-status.d.ts +2 -1
- package/dist/lib/quota-status.d.ts.map +1 -1
- package/dist/lib/quota-status.js +247 -69
- package/dist/lib/quota-status.js.map +1 -1
- package/dist/lib/qwen-local-quota.d.ts +12 -11
- package/dist/lib/qwen-local-quota.d.ts.map +1 -1
- package/dist/lib/qwen-local-quota.js +82 -87
- package/dist/lib/qwen-local-quota.js.map +1 -1
- package/dist/lib/scoped-update.d.ts.map +1 -1
- package/dist/lib/scoped-update.js +32 -22
- package/dist/lib/scoped-update.js.map +1 -1
- package/dist/lib/tui-runtime.d.ts +2 -0
- package/dist/lib/tui-runtime.d.ts.map +1 -1
- package/dist/lib/tui-runtime.js +33 -9
- package/dist/lib/tui-runtime.js.map +1 -1
- package/dist/lib/types.d.ts +51 -15
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +2 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +75 -100
- package/dist/plugin.js.map +1 -1
- package/dist/providers/alibaba-coding-plan.d.ts.map +1 -1
- package/dist/providers/alibaba-coding-plan.js +35 -4
- package/dist/providers/alibaba-coding-plan.js.map +1 -1
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +13 -1
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/chutes.d.ts.map +1 -1
- package/dist/providers/chutes.js +6 -0
- package/dist/providers/chutes.js.map +1 -1
- package/dist/providers/copilot.d.ts +2 -1
- package/dist/providers/copilot.d.ts.map +1 -1
- package/dist/providers/copilot.js +143 -60
- package/dist/providers/copilot.js.map +1 -1
- package/dist/providers/cursor.d.ts.map +1 -1
- package/dist/providers/cursor.js +30 -1
- package/dist/providers/cursor.js.map +1 -1
- package/dist/providers/deepseek.d.ts.map +1 -1
- package/dist/providers/deepseek.js +13 -1
- package/dist/providers/deepseek.js.map +1 -1
- package/dist/providers/google-agy.d.ts.map +1 -1
- package/dist/providers/google-agy.js +7 -1
- package/dist/providers/google-agy.js.map +1 -1
- package/dist/providers/google-antigravity.d.ts.map +1 -1
- package/dist/providers/google-antigravity.js +10 -2
- package/dist/providers/google-antigravity.js.map +1 -1
- package/dist/providers/google-gemini-cli.d.ts.map +1 -1
- package/dist/providers/google-gemini-cli.js +8 -2
- package/dist/providers/google-gemini-cli.js.map +1 -1
- package/dist/providers/kimi-code.d.ts.map +1 -1
- package/dist/providers/kimi-code.js +6 -0
- package/dist/providers/kimi-code.js.map +1 -1
- package/dist/providers/minimax-coding-plan.d.ts.map +1 -1
- package/dist/providers/minimax-coding-plan.js +12 -4
- package/dist/providers/minimax-coding-plan.js.map +1 -1
- package/dist/providers/nanogpt.d.ts.map +1 -1
- package/dist/providers/nanogpt.js +19 -1
- package/dist/providers/nanogpt.js.map +1 -1
- package/dist/providers/ollama-cloud.d.ts.map +1 -1
- package/dist/providers/ollama-cloud.js +12 -0
- package/dist/providers/ollama-cloud.js.map +1 -1
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +6 -0
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/opencode-go.d.ts.map +1 -1
- package/dist/providers/opencode-go.js +9 -1
- package/dist/providers/opencode-go.js.map +1 -1
- package/dist/providers/quota-providers.d.ts +6 -0
- package/dist/providers/quota-providers.d.ts.map +1 -0
- package/dist/providers/quota-providers.js +276 -0
- package/dist/providers/quota-providers.js.map +1 -0
- package/dist/providers/qwen-code.d.ts.map +1 -1
- package/dist/providers/qwen-code.js +29 -3
- package/dist/providers/qwen-code.js.map +1 -1
- package/dist/providers/registry.d.ts.map +1 -1
- package/dist/providers/registry.js +2 -0
- package/dist/providers/registry.js.map +1 -1
- package/dist/providers/result-helpers.d.ts +2 -1
- package/dist/providers/result-helpers.d.ts.map +1 -1
- package/dist/providers/result-helpers.js +6 -1
- package/dist/providers/result-helpers.js.map +1 -1
- package/dist/providers/synthetic.d.ts.map +1 -1
- package/dist/providers/synthetic.js +7 -1
- package/dist/providers/synthetic.js.map +1 -1
- package/dist/providers/zai.d.ts.map +1 -1
- package/dist/providers/zai.js +7 -1
- package/dist/providers/zai.js.map +1 -1
- package/dist/providers/zhipu.d.ts.map +1 -1
- package/dist/providers/zhipu.js +7 -1
- package/dist/providers/zhipu.js.map +1 -1
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +345 -41
- package/dist/tui.tsx +267 -18
- package/package.json +28 -21
package/dist/tui.js
CHANGED
|
@@ -11,7 +11,8 @@ import { createElement as _$createElement } from "@opentui/solid";
|
|
|
11
11
|
import { Show, createEffect, createSignal, onCleanup } from "solid-js";
|
|
12
12
|
import { getCompactStatusText, getHomeBottomAnnouncementText, getSidebarPanelLines, getSidebarPanelLinesExpanded, shouldRenderCompactStatus, shouldRenderHomeBottom, shouldRenderSidebarPanel } from "./lib/tui-panel-state.js";
|
|
13
13
|
import { getSidebarBodyLineColor } from "./lib/tui-line-style.js";
|
|
14
|
-
import { loadTuiHomeBottomStatus, loadTuiSessionQuotaSurfaces, resolveTuiSurfaceRegistration, writeTuiQuotaExportIfEnabled } from "./lib/tui-runtime.js";
|
|
14
|
+
import { createTuiQuotaClient, getTuiRuntimeRootHints, getTuiSessionModelMeta, loadTuiHomeBottomStatus, loadTuiSessionQuotaSurfaces, normalizeTuiSessionID, resolveTuiSurfaceRegistration, writeTuiQuotaExportIfEnabled } from "./lib/tui-runtime.js";
|
|
15
|
+
import { QUOTA_DIALOG_COMMANDS, buildQuotaDialogCommandOutput } from "./lib/quota-dialog-commands.js";
|
|
15
16
|
const id = "@slkiser/opencode-quota";
|
|
16
17
|
// Place Quota near the top so variable-height built-in sections
|
|
17
18
|
// (MCP/LSP/Todo/Files) do not push it below the visible fold.
|
|
@@ -139,11 +140,13 @@ function acquireSessionQuotaResource(api, sessionID) {
|
|
|
139
140
|
resources.set(sessionID, next);
|
|
140
141
|
return next;
|
|
141
142
|
}
|
|
142
|
-
function createHomeBottomResource(api) {
|
|
143
|
+
function createHomeBottomResource(api, compactHomeBottomEnabled) {
|
|
143
144
|
const [bottom, setBottom] = createSignal({
|
|
144
145
|
status: "loading",
|
|
145
|
-
compact: {
|
|
146
|
+
compact: compactHomeBottomEnabled ? {
|
|
146
147
|
status: "loading"
|
|
148
|
+
} : {
|
|
149
|
+
status: "disabled"
|
|
147
150
|
}
|
|
148
151
|
});
|
|
149
152
|
let refCount = 0;
|
|
@@ -220,10 +223,10 @@ function createHomeBottomResource(api) {
|
|
|
220
223
|
reload();
|
|
221
224
|
return resource;
|
|
222
225
|
}
|
|
223
|
-
function acquireHomeBottomResource(api) {
|
|
226
|
+
function acquireHomeBottomResource(api, compactHomeBottomEnabled) {
|
|
224
227
|
const existing = homeResources.get(api);
|
|
225
228
|
if (existing) return existing.retain();
|
|
226
|
-
const next = createHomeBottomResource(api).retain();
|
|
229
|
+
const next = createHomeBottomResource(api, compactHomeBottomEnabled).retain();
|
|
227
230
|
homeResources.set(api, next);
|
|
228
231
|
return next;
|
|
229
232
|
}
|
|
@@ -395,46 +398,342 @@ function SessionPromptWithCompactStatus(props) {
|
|
|
395
398
|
})();
|
|
396
399
|
}
|
|
397
400
|
function HomeBottomView(props) {
|
|
398
|
-
const resource = acquireHomeBottomResource(props.api);
|
|
401
|
+
const resource = acquireHomeBottomResource(props.api, props.compactHomeBottomEnabled);
|
|
399
402
|
onCleanup(() => resource.release());
|
|
400
403
|
const announcement = () => getHomeBottomAnnouncementText(resource.bottom());
|
|
401
404
|
const compact = () => resource.bottom().compact;
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
405
|
+
const visible = () => shouldRenderHomeBottom(resource.bottom());
|
|
406
|
+
return (() => {
|
|
407
|
+
var _el$14 = _$createElement("box");
|
|
408
|
+
_$setProp(_el$14, "gap", 0);
|
|
409
|
+
_$insert(_el$14, _$createComponent(Show, {
|
|
410
|
+
get when() {
|
|
411
|
+
return visible();
|
|
412
|
+
},
|
|
413
|
+
get children() {
|
|
414
|
+
var _el$15 = _$createElement("text");
|
|
415
|
+
_$insertNode(_el$15, _$createTextNode(` `));
|
|
416
|
+
return _el$15;
|
|
417
|
+
}
|
|
418
|
+
}), null);
|
|
419
|
+
_$insert(_el$14, _$createComponent(Show, {
|
|
420
|
+
get when() {
|
|
421
|
+
return _$memo(() => !!visible())() && announcement();
|
|
422
|
+
},
|
|
423
|
+
get children() {
|
|
424
|
+
var _el$17 = _$createElement("box"),
|
|
425
|
+
_el$18 = _$createElement("text");
|
|
426
|
+
_$insertNode(_el$17, _el$18);
|
|
427
|
+
_$setProp(_el$17, "flexDirection", "row");
|
|
428
|
+
_$setProp(_el$17, "justifyContent", "center");
|
|
429
|
+
_$setProp(_el$18, "wrapMode", "none");
|
|
430
|
+
_$insert(_el$18, announcement);
|
|
431
|
+
_$effect(_$p => _$setProp(_el$18, "fg", props.api.theme.current.textMuted, _$p));
|
|
432
|
+
return _el$17;
|
|
433
|
+
}
|
|
434
|
+
}), null);
|
|
435
|
+
_$insert(_el$14, _$createComponent(Show, {
|
|
436
|
+
get when() {
|
|
437
|
+
return visible();
|
|
438
|
+
},
|
|
439
|
+
get children() {
|
|
440
|
+
return _$createComponent(CompactStatusLine, {
|
|
441
|
+
get api() {
|
|
442
|
+
return props.api;
|
|
443
|
+
},
|
|
444
|
+
panel: compact,
|
|
445
|
+
justifyContent: "center"
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
}), null);
|
|
449
|
+
return _el$14;
|
|
450
|
+
})();
|
|
451
|
+
}
|
|
452
|
+
function getActiveTuiSessionID(api) {
|
|
453
|
+
if (api.route.current.name !== "session") return undefined;
|
|
454
|
+
return normalizeTuiSessionID(api.route.current.params?.sessionID);
|
|
455
|
+
}
|
|
456
|
+
function getTuiCommandArguments(input) {
|
|
457
|
+
if (!input || typeof input !== "object") return undefined;
|
|
458
|
+
const record = input;
|
|
459
|
+
for (const key of ["arguments", "args", "query"]) {
|
|
460
|
+
const value = record[key];
|
|
461
|
+
if (typeof value === "string" && value.trim()) return value.trim();
|
|
462
|
+
}
|
|
463
|
+
return undefined;
|
|
464
|
+
}
|
|
465
|
+
function CommandLoadingDialog(props) {
|
|
466
|
+
return (() => {
|
|
467
|
+
var _el$19 = _$createElement("box"),
|
|
468
|
+
_el$20 = _$createElement("text"),
|
|
469
|
+
_el$21 = _$createElement("b"),
|
|
470
|
+
_el$22 = _$createElement("text");
|
|
471
|
+
_$insertNode(_el$19, _el$20);
|
|
472
|
+
_$insertNode(_el$19, _el$22);
|
|
473
|
+
_$setProp(_el$19, "gap", 1);
|
|
474
|
+
_$setProp(_el$19, "paddingLeft", 2);
|
|
475
|
+
_$setProp(_el$19, "paddingRight", 2);
|
|
476
|
+
_$setProp(_el$19, "paddingBottom", 1);
|
|
477
|
+
_$insertNode(_el$20, _el$21);
|
|
478
|
+
_$insert(_el$21, () => props.title);
|
|
479
|
+
_$insertNode(_el$22, _$createTextNode(`Loading deterministic local output…`));
|
|
480
|
+
_$effect(_p$ => {
|
|
481
|
+
var _v$3 = props.api.theme.current.text,
|
|
482
|
+
_v$4 = props.api.theme.current.textMuted;
|
|
483
|
+
_v$3 !== _p$.e && (_p$.e = _$setProp(_el$20, "fg", _v$3, _p$.e));
|
|
484
|
+
_v$4 !== _p$.t && (_p$.t = _$setProp(_el$22, "fg", _v$4, _p$.t));
|
|
485
|
+
return _p$;
|
|
486
|
+
}, {
|
|
487
|
+
e: undefined,
|
|
488
|
+
t: undefined
|
|
489
|
+
});
|
|
490
|
+
return _el$19;
|
|
491
|
+
})();
|
|
492
|
+
}
|
|
493
|
+
function CommandOutputDialog(props) {
|
|
494
|
+
const lines = () => props.output.split("\n");
|
|
495
|
+
const bodyHeight = () => Math.min(28, Math.max(6, lines().length));
|
|
496
|
+
return (() => {
|
|
497
|
+
var _el$24 = _$createElement("box"),
|
|
498
|
+
_el$25 = _$createElement("text"),
|
|
499
|
+
_el$26 = _$createElement("b"),
|
|
500
|
+
_el$27 = _$createElement("scrollbox"),
|
|
501
|
+
_el$28 = _$createElement("box"),
|
|
502
|
+
_el$29 = _$createElement("text");
|
|
503
|
+
_$insertNode(_el$24, _el$25);
|
|
504
|
+
_$insertNode(_el$24, _el$27);
|
|
505
|
+
_$insertNode(_el$24, _el$29);
|
|
506
|
+
_$setProp(_el$24, "gap", 1);
|
|
507
|
+
_$setProp(_el$24, "width", "100%");
|
|
508
|
+
_$setProp(_el$24, "flexGrow", 1);
|
|
509
|
+
_$setProp(_el$24, "paddingLeft", 2);
|
|
510
|
+
_$setProp(_el$24, "paddingRight", 2);
|
|
511
|
+
_$setProp(_el$24, "paddingBottom", 1);
|
|
512
|
+
_$insertNode(_el$25, _el$26);
|
|
513
|
+
_$insert(_el$26, () => props.title);
|
|
514
|
+
_$insertNode(_el$27, _el$28);
|
|
515
|
+
_$setProp(_el$27, "width", "100%");
|
|
516
|
+
_$setProp(_el$27, "flexGrow", 1);
|
|
517
|
+
_$setProp(_el$27, "maxHeight", 28);
|
|
518
|
+
_$setProp(_el$28, "gap", 0);
|
|
519
|
+
_$setProp(_el$28, "width", "100%");
|
|
520
|
+
_$setProp(_el$28, "minWidth", 0);
|
|
521
|
+
_$insert(_el$28, () => lines().map(line => (() => {
|
|
522
|
+
var _el$31 = _$createElement("text");
|
|
523
|
+
_$setProp(_el$31, "wrapMode", "word");
|
|
524
|
+
_$setProp(_el$31, "width", "100%");
|
|
525
|
+
_$insert(_el$31, line || " ");
|
|
526
|
+
_$effect(_$p => _$setProp(_el$31, "fg", props.api.theme.current.text, _$p));
|
|
527
|
+
return _el$31;
|
|
528
|
+
})()));
|
|
529
|
+
_$insertNode(_el$29, _$createTextNode(`esc closes`));
|
|
530
|
+
_$effect(_p$ => {
|
|
531
|
+
var _v$5 = props.api.theme.current.text,
|
|
532
|
+
_v$6 = bodyHeight(),
|
|
533
|
+
_v$7 = props.api.theme.current.textMuted;
|
|
534
|
+
_v$5 !== _p$.e && (_p$.e = _$setProp(_el$25, "fg", _v$5, _p$.e));
|
|
535
|
+
_v$6 !== _p$.t && (_p$.t = _$setProp(_el$27, "minHeight", _v$6, _p$.t));
|
|
536
|
+
_v$7 !== _p$.a && (_p$.a = _$setProp(_el$29, "fg", _v$7, _p$.a));
|
|
537
|
+
return _p$;
|
|
538
|
+
}, {
|
|
539
|
+
e: undefined,
|
|
540
|
+
t: undefined,
|
|
541
|
+
a: undefined
|
|
542
|
+
});
|
|
543
|
+
return _el$24;
|
|
544
|
+
})();
|
|
545
|
+
}
|
|
546
|
+
function CommandErrorDialog(props) {
|
|
547
|
+
const message = props.error instanceof Error ? props.error.message : String(props.error);
|
|
548
|
+
return (() => {
|
|
549
|
+
var _el$32 = _$createElement("box"),
|
|
550
|
+
_el$33 = _$createElement("text"),
|
|
551
|
+
_el$34 = _$createElement("b"),
|
|
552
|
+
_el$35 = _$createElement("text"),
|
|
553
|
+
_el$37 = _$createElement("text"),
|
|
554
|
+
_el$38 = _$createElement("text");
|
|
555
|
+
_$insertNode(_el$32, _el$33);
|
|
556
|
+
_$insertNode(_el$32, _el$35);
|
|
557
|
+
_$insertNode(_el$32, _el$37);
|
|
558
|
+
_$insertNode(_el$32, _el$38);
|
|
559
|
+
_$setProp(_el$32, "gap", 1);
|
|
560
|
+
_$setProp(_el$32, "paddingLeft", 2);
|
|
561
|
+
_$setProp(_el$32, "paddingRight", 2);
|
|
562
|
+
_$setProp(_el$32, "paddingBottom", 1);
|
|
563
|
+
_$insertNode(_el$33, _el$34);
|
|
564
|
+
_$insert(_el$34, () => props.title);
|
|
565
|
+
_$insertNode(_el$35, _$createTextNode(`OpenCode Quota command failed.`));
|
|
566
|
+
_$setProp(_el$37, "wrapMode", "none");
|
|
567
|
+
_$insert(_el$37, message || "Unknown error");
|
|
568
|
+
_$insertNode(_el$38, _$createTextNode(`esc closes`));
|
|
569
|
+
_$effect(_p$ => {
|
|
570
|
+
var _v$8 = props.api.theme.current.text,
|
|
571
|
+
_v$9 = props.api.theme.current.text,
|
|
572
|
+
_v$0 = props.api.theme.current.textMuted,
|
|
573
|
+
_v$1 = props.api.theme.current.textMuted;
|
|
574
|
+
_v$8 !== _p$.e && (_p$.e = _$setProp(_el$33, "fg", _v$8, _p$.e));
|
|
575
|
+
_v$9 !== _p$.t && (_p$.t = _$setProp(_el$35, "fg", _v$9, _p$.t));
|
|
576
|
+
_v$0 !== _p$.a && (_p$.a = _$setProp(_el$37, "fg", _v$0, _p$.a));
|
|
577
|
+
_v$1 !== _p$.o && (_p$.o = _$setProp(_el$38, "fg", _v$1, _p$.o));
|
|
578
|
+
return _p$;
|
|
579
|
+
}, {
|
|
580
|
+
e: undefined,
|
|
581
|
+
t: undefined,
|
|
582
|
+
a: undefined,
|
|
583
|
+
o: undefined
|
|
584
|
+
});
|
|
585
|
+
return _el$32;
|
|
586
|
+
})();
|
|
587
|
+
}
|
|
588
|
+
function getCommandPromptCopy(spec) {
|
|
589
|
+
switch (spec.id) {
|
|
590
|
+
case "tokens_between":
|
|
591
|
+
return {
|
|
592
|
+
title: "OpenCode Quota Token Range",
|
|
593
|
+
placeholder: "YYYY-MM-DD YYYY-MM-DD",
|
|
594
|
+
description: "Enter start and end dates, for example: 2026-01-01 2026-01-15"
|
|
595
|
+
};
|
|
596
|
+
case "quota_status":
|
|
597
|
+
return {
|
|
598
|
+
title: "OpenCode Quota Status Options",
|
|
599
|
+
placeholder: 'Optional JSON, e.g. {"refreshGoogleTokens":true}',
|
|
600
|
+
description: "Leave blank for normal diagnostics, or enter one JSON options object."
|
|
601
|
+
};
|
|
602
|
+
default:
|
|
603
|
+
return {
|
|
604
|
+
title: spec.title,
|
|
605
|
+
placeholder: "Optional arguments",
|
|
606
|
+
description: "Leave blank to run with no arguments."
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
function replaceDialog(api, size, render) {
|
|
611
|
+
api.ui.dialog.replace(render);
|
|
612
|
+
// OpenCode dialog.replace() resets size to medium.
|
|
613
|
+
api.ui.dialog.setSize(size);
|
|
614
|
+
}
|
|
615
|
+
async function runQuotaDialogCommandAsync(api, command, commandDisplay, rawInput, state) {
|
|
616
|
+
const spec = QUOTA_DIALOG_COMMANDS.find(item => item.id === command);
|
|
617
|
+
const argumentsText = getTuiCommandArguments(rawInput);
|
|
618
|
+
const sessionID = getActiveTuiSessionID(api);
|
|
619
|
+
if (spec.acceptsArguments && rawInput === undefined) {
|
|
620
|
+
const prompt = getCommandPromptCopy(spec);
|
|
621
|
+
replaceDialog(api, "medium", () => _$createComponent(api.ui.DialogPrompt, {
|
|
622
|
+
get title() {
|
|
623
|
+
return prompt.title;
|
|
624
|
+
},
|
|
625
|
+
get placeholder() {
|
|
626
|
+
return prompt.placeholder;
|
|
627
|
+
},
|
|
628
|
+
description: () => (() => {
|
|
629
|
+
var _el$40 = _$createElement("text");
|
|
630
|
+
_$setProp(_el$40, "wrapMode", "word");
|
|
631
|
+
_$insert(_el$40, () => prompt.description);
|
|
632
|
+
_$effect(_$p => _$setProp(_el$40, "fg", api.theme.current.textMuted, _$p));
|
|
633
|
+
return _el$40;
|
|
634
|
+
})(),
|
|
635
|
+
onCancel: () => api.ui.dialog.clear(),
|
|
636
|
+
onConfirm: value => {
|
|
637
|
+
void runQuotaDialogCommandAsync(api, command, commandDisplay, {
|
|
638
|
+
arguments: value.trim()
|
|
639
|
+
}, state);
|
|
640
|
+
}
|
|
641
|
+
}));
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
const destination = commandDisplay === "inline" && sessionID ? {
|
|
645
|
+
type: "inline",
|
|
646
|
+
sessionID
|
|
647
|
+
} : {
|
|
648
|
+
type: "dialog"
|
|
649
|
+
};
|
|
650
|
+
if (destination.type === "dialog") {
|
|
651
|
+
replaceDialog(api, spec.dialogSize, () => _$createComponent(CommandLoadingDialog, {
|
|
652
|
+
api: api,
|
|
653
|
+
get title() {
|
|
654
|
+
return spec.title;
|
|
655
|
+
}
|
|
656
|
+
}));
|
|
657
|
+
}
|
|
658
|
+
try {
|
|
659
|
+
const result = await buildQuotaDialogCommandOutput({
|
|
660
|
+
command,
|
|
661
|
+
arguments: argumentsText,
|
|
662
|
+
client: createTuiQuotaClient(api),
|
|
663
|
+
roots: getTuiRuntimeRootHints(api),
|
|
664
|
+
sessionID,
|
|
665
|
+
resolveSessionMeta: id => getTuiSessionModelMeta(api, id),
|
|
666
|
+
lastSessionTokenError: state?.lastSessionTokenError,
|
|
667
|
+
setLastSessionTokenError: state ? error => {
|
|
668
|
+
state.lastSessionTokenError = error;
|
|
669
|
+
} : undefined,
|
|
670
|
+
log: async (message, extra) => {
|
|
671
|
+
await api.client.app.log({
|
|
672
|
+
body: {
|
|
673
|
+
service: "quota-toast",
|
|
674
|
+
level: "debug",
|
|
675
|
+
message,
|
|
676
|
+
extra
|
|
677
|
+
}
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
if (result.state === "noop") {
|
|
682
|
+
if (destination.type === "dialog") api.ui.dialog.clear();
|
|
683
|
+
return;
|
|
436
684
|
}
|
|
685
|
+
if (destination.type === "inline") {
|
|
686
|
+
await api.client.session.prompt({
|
|
687
|
+
sessionID: destination.sessionID,
|
|
688
|
+
noReply: true,
|
|
689
|
+
parts: [{
|
|
690
|
+
type: "text",
|
|
691
|
+
text: result.output,
|
|
692
|
+
ignored: true
|
|
693
|
+
}]
|
|
694
|
+
});
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
replaceDialog(api, result.dialogSize, () => _$createComponent(CommandOutputDialog, {
|
|
698
|
+
api: api,
|
|
699
|
+
get title() {
|
|
700
|
+
return result.title;
|
|
701
|
+
},
|
|
702
|
+
get output() {
|
|
703
|
+
return result.output;
|
|
704
|
+
}
|
|
705
|
+
}));
|
|
706
|
+
} catch (error) {
|
|
707
|
+
replaceDialog(api, "large", () => _$createComponent(CommandErrorDialog, {
|
|
708
|
+
api: api,
|
|
709
|
+
get title() {
|
|
710
|
+
return spec.title;
|
|
711
|
+
},
|
|
712
|
+
error: error
|
|
713
|
+
}));
|
|
714
|
+
api.ui.toast({
|
|
715
|
+
variant: "error",
|
|
716
|
+
message: "OpenCode Quota command failed"
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
function registerQuotaDialogCommands(api, commandDisplay) {
|
|
721
|
+
const commandState = {};
|
|
722
|
+
const dispose = api.keymap.registerLayer({
|
|
723
|
+
commands: QUOTA_DIALOG_COMMANDS.map(spec => ({
|
|
724
|
+
namespace: "palette",
|
|
725
|
+
name: `opencode-quota.${spec.id}`,
|
|
726
|
+
title: spec.title,
|
|
727
|
+
desc: spec.description,
|
|
728
|
+
category: "OpenCode Quota",
|
|
729
|
+
slashName: spec.slashName,
|
|
730
|
+
run(input) {
|
|
731
|
+
void runQuotaDialogCommandAsync(api, spec.id, commandDisplay, input, commandState);
|
|
732
|
+
}
|
|
733
|
+
})),
|
|
734
|
+
bindings: []
|
|
437
735
|
});
|
|
736
|
+
api.lifecycle.onDispose(dispose);
|
|
438
737
|
}
|
|
439
738
|
function registerSidebarSlots(api) {
|
|
440
739
|
api.slots.register({
|
|
@@ -456,9 +755,11 @@ const tui = async api => {
|
|
|
456
755
|
try {
|
|
457
756
|
surfaceRegistration = await resolveTuiSurfaceRegistration(api);
|
|
458
757
|
} catch {
|
|
758
|
+
registerQuotaDialogCommands(api, "inline");
|
|
459
759
|
registerSidebarSlots(api);
|
|
460
760
|
return;
|
|
461
761
|
}
|
|
762
|
+
registerQuotaDialogCommands(api, surfaceRegistration.commandDisplay);
|
|
462
763
|
if (surfaceRegistration.sidebar.enabled) {
|
|
463
764
|
registerSidebarSlots(api);
|
|
464
765
|
}
|
|
@@ -487,7 +788,10 @@ const tui = async api => {
|
|
|
487
788
|
}
|
|
488
789
|
if (surfaceRegistration.homeBottom) {
|
|
489
790
|
compactSlots.home_bottom = () => _$createComponent(HomeBottomView, {
|
|
490
|
-
api: api
|
|
791
|
+
api: api,
|
|
792
|
+
get compactHomeBottomEnabled() {
|
|
793
|
+
return surfaceRegistration.compact.homeBottom;
|
|
794
|
+
}
|
|
491
795
|
});
|
|
492
796
|
}
|
|
493
797
|
if (Object.keys(compactSlots).length > 0) {
|