@coool/opencode-adaptive 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +99 -2
- package/dist/adapters/codex-capacity/index.d.ts +4 -0
- package/dist/adapters/codex-capacity/index.js +5 -0
- package/dist/adapters/codex-capacity/index.js.map +1 -0
- package/dist/adapters/codex-capacity/parse.d.ts +28 -0
- package/dist/adapters/codex-capacity/parse.js +146 -0
- package/dist/adapters/codex-capacity/parse.js.map +1 -0
- package/dist/adapters/codex-capacity/reading.d.ts +9 -0
- package/dist/adapters/codex-capacity/reading.js +45 -0
- package/dist/adapters/codex-capacity/reading.js.map +1 -0
- package/dist/adapters/codex-capacity/sensor.d.ts +23 -0
- package/dist/adapters/codex-capacity/sensor.js +30 -0
- package/dist/adapters/codex-capacity/sensor.js.map +1 -0
- package/dist/adapters/codex-capacity/types.d.ts +31 -0
- package/dist/adapters/codex-capacity/types.js +18 -0
- package/dist/adapters/codex-capacity/types.js.map +1 -0
- package/dist/adapters/opencode/escalation-tool.d.ts +51 -0
- package/dist/adapters/opencode/escalation-tool.js +61 -0
- package/dist/adapters/opencode/escalation-tool.js.map +1 -0
- package/dist/adapters/opencode/events.d.ts +23 -0
- package/dist/adapters/opencode/events.js +68 -0
- package/dist/adapters/opencode/events.js.map +1 -0
- package/dist/adapters/opencode/hooks.d.ts +34 -0
- package/dist/adapters/opencode/hooks.js +29 -0
- package/dist/adapters/opencode/hooks.js.map +1 -0
- package/dist/adapters/opencode/index.d.ts +16 -0
- package/dist/adapters/opencode/index.js +9 -0
- package/dist/adapters/opencode/index.js.map +1 -0
- package/dist/adapters/opencode/inventory.d.ts +30 -0
- package/dist/adapters/opencode/inventory.js +53 -0
- package/dist/adapters/opencode/inventory.js.map +1 -0
- package/dist/adapters/opencode/report.d.ts +91 -0
- package/dist/adapters/opencode/report.js +145 -0
- package/dist/adapters/opencode/report.js.map +1 -0
- package/dist/adapters/opencode/session-ops.d.ts +39 -0
- package/dist/adapters/opencode/session-ops.js +32 -0
- package/dist/adapters/opencode/session-ops.js.map +1 -0
- package/dist/adapters/opencode/storage.d.ts +15 -0
- package/dist/adapters/opencode/storage.js +8 -0
- package/dist/adapters/opencode/storage.js.map +1 -0
- package/dist/adapters/opencode/tier-tool.d.ts +37 -0
- package/dist/adapters/opencode/tier-tool.js +72 -0
- package/dist/adapters/opencode/tier-tool.js.map +1 -0
- package/dist/adapters/opencode/types.d.ts +101 -0
- package/dist/adapters/opencode/types.js +2 -0
- package/dist/adapters/opencode/types.js.map +1 -0
- package/dist/core/compatibility/gate.d.ts +7 -0
- package/dist/core/compatibility/gate.js +51 -0
- package/dist/core/compatibility/gate.js.map +1 -0
- package/dist/core/compatibility/index.d.ts +2 -0
- package/dist/core/compatibility/index.js +3 -0
- package/dist/core/compatibility/index.js.map +1 -0
- package/dist/core/compatibility/types.d.ts +53 -0
- package/dist/core/compatibility/types.js +27 -0
- package/dist/core/compatibility/types.js.map +1 -0
- package/dist/core/scheduler/admit.d.ts +6 -0
- package/dist/core/scheduler/admit.js +154 -0
- package/dist/core/scheduler/admit.js.map +1 -0
- package/dist/core/scheduler/escalate.d.ts +6 -0
- package/dist/core/scheduler/escalate.js +45 -0
- package/dist/core/scheduler/escalate.js.map +1 -0
- package/dist/core/scheduler/index.d.ts +4 -0
- package/dist/core/scheduler/index.js +5 -0
- package/dist/core/scheduler/index.js.map +1 -0
- package/dist/core/scheduler/mode.d.ts +8 -0
- package/dist/core/scheduler/mode.js +10 -0
- package/dist/core/scheduler/mode.js.map +1 -0
- package/dist/core/scheduler/types.d.ts +136 -0
- package/dist/core/scheduler/types.js +75 -0
- package/dist/core/scheduler/types.js.map +1 -0
- package/dist/core/tier-policy/index.d.ts +3 -0
- package/dist/core/tier-policy/index.js +4 -0
- package/dist/core/tier-policy/index.js.map +1 -0
- package/dist/core/tier-policy/resolve.d.ts +18 -0
- package/dist/core/tier-policy/resolve.js +52 -0
- package/dist/core/tier-policy/resolve.js.map +1 -0
- package/dist/core/tier-policy/tier-list.d.ts +10 -0
- package/dist/core/tier-policy/tier-list.js +23 -0
- package/dist/core/tier-policy/tier-list.js.map +1 -0
- package/dist/core/tier-policy/types.d.ts +86 -0
- package/dist/core/tier-policy/types.js +49 -0
- package/dist/core/tier-policy/types.js.map +1 -0
- package/dist/core/work-unit/index.d.ts +3 -0
- package/dist/core/work-unit/index.js +4 -0
- package/dist/core/work-unit/index.js.map +1 -0
- package/dist/core/work-unit/interruption.d.ts +7 -0
- package/dist/core/work-unit/interruption.js +12 -0
- package/dist/core/work-unit/interruption.js.map +1 -0
- package/dist/core/work-unit/tracker.d.ts +53 -0
- package/dist/core/work-unit/tracker.js +156 -0
- package/dist/core/work-unit/tracker.js.map +1 -0
- package/dist/core/work-unit/types.d.ts +151 -0
- package/dist/core/work-unit/types.js +23 -0
- package/dist/core/work-unit/types.js.map +1 -0
- package/dist/execution/continuation/execute.d.ts +18 -0
- package/dist/execution/continuation/execute.js +31 -0
- package/dist/execution/continuation/execute.js.map +1 -0
- package/dist/execution/continuation/index.d.ts +4 -0
- package/dist/execution/continuation/index.js +4 -0
- package/dist/execution/continuation/index.js.map +1 -0
- package/dist/execution/continuation/plan.d.ts +12 -0
- package/dist/execution/continuation/plan.js +18 -0
- package/dist/execution/continuation/plan.js.map +1 -0
- package/dist/execution/continuation/prompts.d.ts +7 -0
- package/dist/execution/continuation/prompts.js +8 -0
- package/dist/execution/continuation/prompts.js.map +1 -0
- package/dist/execution/continuation/types.d.ts +68 -0
- package/dist/execution/continuation/types.js +15 -0
- package/dist/execution/continuation/types.js.map +1 -0
- package/dist/execution/escalation/index.d.ts +1 -0
- package/dist/execution/escalation/index.js +2 -0
- package/dist/execution/escalation/index.js.map +1 -0
- package/dist/execution/escalation/types.d.ts +30 -0
- package/dist/execution/escalation/types.js +49 -0
- package/dist/execution/escalation/types.js.map +1 -0
- package/dist/execution/index.d.ts +4 -0
- package/dist/execution/index.js +5 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/parking/index.d.ts +2 -0
- package/dist/execution/parking/index.js +2 -0
- package/dist/execution/parking/index.js.map +1 -0
- package/dist/execution/parking/plan.d.ts +39 -0
- package/dist/execution/parking/plan.js +34 -0
- package/dist/execution/parking/plan.js.map +1 -0
- package/dist/execution/retry/decide.d.ts +29 -0
- package/dist/execution/retry/decide.js +75 -0
- package/dist/execution/retry/decide.js.map +1 -0
- package/dist/execution/retry/index.d.ts +2 -0
- package/dist/execution/retry/index.js +3 -0
- package/dist/execution/retry/index.js.map +1 -0
- package/dist/execution/retry/types.d.ts +64 -0
- package/dist/execution/retry/types.js +9 -0
- package/dist/execution/retry/types.js.map +1 -0
- package/dist/gui-experimental.cjs +1 -0
- package/dist/gui.d.ts +16 -0
- package/dist/gui.js +73 -0
- package/dist/gui.js.map +1 -0
- package/dist/health/capacity/index.d.ts +3 -0
- package/dist/health/capacity/index.js +4 -0
- package/dist/health/capacity/index.js.map +1 -0
- package/dist/health/capacity/merge.d.ts +57 -0
- package/dist/health/capacity/merge.js +154 -0
- package/dist/health/capacity/merge.js.map +1 -0
- package/dist/health/capacity/registry.d.ts +40 -0
- package/dist/health/capacity/registry.js +106 -0
- package/dist/health/capacity/registry.js.map +1 -0
- package/dist/health/capacity/types.d.ts +73 -0
- package/dist/health/capacity/types.js +6 -0
- package/dist/health/capacity/types.js.map +1 -0
- package/dist/health/circuit-breaker/breaker.d.ts +91 -0
- package/dist/health/circuit-breaker/breaker.js +150 -0
- package/dist/health/circuit-breaker/breaker.js.map +1 -0
- package/dist/health/circuit-breaker/index.d.ts +2 -0
- package/dist/health/circuit-breaker/index.js +3 -0
- package/dist/health/circuit-breaker/index.js.map +1 -0
- package/dist/health/circuit-breaker/types.d.ts +52 -0
- package/dist/health/circuit-breaker/types.js +13 -0
- package/dist/health/circuit-breaker/types.js.map +1 -0
- package/dist/health/classifier/classify.d.ts +8 -0
- package/dist/health/classifier/classify.js +245 -0
- package/dist/health/classifier/classify.js.map +1 -0
- package/dist/health/classifier/index.d.ts +2 -0
- package/dist/health/classifier/index.js +3 -0
- package/dist/health/classifier/index.js.map +1 -0
- package/dist/health/classifier/types.d.ts +71 -0
- package/dist/health/classifier/types.js +27 -0
- package/dist/health/classifier/types.js.map +1 -0
- package/dist/health/index.d.ts +4 -0
- package/dist/health/index.js +5 -0
- package/dist/health/index.js.map +1 -0
- package/dist/health/resource-health/index.d.ts +4 -0
- package/dist/health/resource-health/index.js +5 -0
- package/dist/health/resource-health/index.js.map +1 -0
- package/dist/health/resource-health/key.d.ts +18 -0
- package/dist/health/resource-health/key.js +54 -0
- package/dist/health/resource-health/key.js.map +1 -0
- package/dist/health/resource-health/registry.d.ts +46 -0
- package/dist/health/resource-health/registry.js +276 -0
- package/dist/health/resource-health/registry.js.map +1 -0
- package/dist/health/resource-health/transitions.d.ts +9 -0
- package/dist/health/resource-health/transitions.js +157 -0
- package/dist/health/resource-health/transitions.js.map +1 -0
- package/dist/health/resource-health/types.d.ts +122 -0
- package/dist/health/resource-health/types.js +44 -0
- package/dist/health/resource-health/types.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +105 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin-id.d.ts +2 -0
- package/dist/plugin-id.js +3 -0
- package/dist/plugin-id.js.map +1 -0
- package/dist/rpc/definition.d.ts +123 -0
- package/dist/rpc/definition.js +130 -0
- package/dist/rpc/definition.js.map +1 -0
- package/dist/rpc/handlers.d.ts +53 -0
- package/dist/rpc/handlers.js +125 -0
- package/dist/rpc/handlers.js.map +1 -0
- package/dist/rpc/status.d.ts +42 -0
- package/dist/rpc/status.js +45 -0
- package/dist/rpc/status.js.map +1 -0
- package/dist/rpc.d.ts +10 -0
- package/dist/rpc.js +8 -0
- package/dist/rpc.js.map +1 -0
- package/dist/state/capacity/index.d.ts +3 -0
- package/dist/state/capacity/index.js +4 -0
- package/dist/state/capacity/index.js.map +1 -0
- package/dist/state/capacity/parse.d.ts +2 -0
- package/dist/state/capacity/parse.js +122 -0
- package/dist/state/capacity/parse.js.map +1 -0
- package/dist/state/capacity/store.d.ts +18 -0
- package/dist/state/capacity/store.js +78 -0
- package/dist/state/capacity/store.js.map +1 -0
- package/dist/state/capacity/types.d.ts +37 -0
- package/dist/state/capacity/types.js +11 -0
- package/dist/state/capacity/types.js.map +1 -0
- package/dist/state/health/index.d.ts +4 -0
- package/dist/state/health/index.js +4 -0
- package/dist/state/health/index.js.map +1 -0
- package/dist/state/health/parse.d.ts +2 -0
- package/dist/state/health/parse.js +137 -0
- package/dist/state/health/parse.js.map +1 -0
- package/dist/state/health/store.d.ts +17 -0
- package/dist/state/health/store.js +69 -0
- package/dist/state/health/store.js.map +1 -0
- package/dist/state/health/types.d.ts +23 -0
- package/dist/state/health/types.js +5 -0
- package/dist/state/health/types.js.map +1 -0
- package/dist/state/parked-work/index.d.ts +4 -0
- package/dist/state/parked-work/index.js +4 -0
- package/dist/state/parked-work/index.js.map +1 -0
- package/dist/state/parked-work/parse.d.ts +6 -0
- package/dist/state/parked-work/parse.js +83 -0
- package/dist/state/parked-work/parse.js.map +1 -0
- package/dist/state/parked-work/store.d.ts +17 -0
- package/dist/state/parked-work/store.js +98 -0
- package/dist/state/parked-work/store.js.map +1 -0
- package/dist/state/parked-work/types.d.ts +41 -0
- package/dist/state/parked-work/types.js +7 -0
- package/dist/state/parked-work/types.js.map +1 -0
- package/dist/state/receipts/bound.d.ts +14 -0
- package/dist/state/receipts/bound.js +77 -0
- package/dist/state/receipts/bound.js.map +1 -0
- package/dist/state/receipts/index.d.ts +6 -0
- package/dist/state/receipts/index.js +5 -0
- package/dist/state/receipts/index.js.map +1 -0
- package/dist/state/receipts/parse.d.ts +6 -0
- package/dist/state/receipts/parse.js +226 -0
- package/dist/state/receipts/parse.js.map +1 -0
- package/dist/state/receipts/store.d.ts +34 -0
- package/dist/state/receipts/store.js +148 -0
- package/dist/state/receipts/store.js.map +1 -0
- package/dist/state/receipts/types.d.ts +61 -0
- package/dist/state/receipts/types.js +12 -0
- package/dist/state/receipts/types.js.map +1 -0
- package/dist/state/session-modes/index.d.ts +4 -0
- package/dist/state/session-modes/index.js +4 -0
- package/dist/state/session-modes/index.js.map +1 -0
- package/dist/state/session-modes/parse.d.ts +8 -0
- package/dist/state/session-modes/parse.js +62 -0
- package/dist/state/session-modes/parse.js.map +1 -0
- package/dist/state/session-modes/store.d.ts +20 -0
- package/dist/state/session-modes/store.js +87 -0
- package/dist/state/session-modes/store.js.map +1 -0
- package/dist/state/session-modes/types.d.ts +41 -0
- package/dist/state/session-modes/types.js +7 -0
- package/dist/state/session-modes/types.js.map +1 -0
- package/dist/state/settings/index.d.ts +4 -0
- package/dist/state/settings/index.js +4 -0
- package/dist/state/settings/index.js.map +1 -0
- package/dist/state/settings/parse.d.ts +33 -0
- package/dist/state/settings/parse.js +261 -0
- package/dist/state/settings/parse.js.map +1 -0
- package/dist/state/settings/store.d.ts +21 -0
- package/dist/state/settings/store.js +65 -0
- package/dist/state/settings/store.js.map +1 -0
- package/dist/state/settings/types.d.ts +62 -0
- package/dist/state/settings/types.js +12 -0
- package/dist/state/settings/types.js.map +1 -0
- package/dist/state/tier-requests/index.d.ts +4 -0
- package/dist/state/tier-requests/index.js +4 -0
- package/dist/state/tier-requests/index.js.map +1 -0
- package/dist/state/tier-requests/parse.d.ts +3 -0
- package/dist/state/tier-requests/parse.js +53 -0
- package/dist/state/tier-requests/parse.js.map +1 -0
- package/dist/state/tier-requests/store.d.ts +27 -0
- package/dist/state/tier-requests/store.js +96 -0
- package/dist/state/tier-requests/store.js.map +1 -0
- package/dist/state/tier-requests/types.d.ts +30 -0
- package/dist/state/tier-requests/types.js +7 -0
- package/dist/state/tier-requests/types.js.map +1 -0
- package/dist/supervisor/index.d.ts +4 -0
- package/dist/supervisor/index.js +4 -0
- package/dist/supervisor/index.js.map +1 -0
- package/dist/supervisor/log.d.ts +10 -0
- package/dist/supervisor/log.js +14 -0
- package/dist/supervisor/log.js.map +1 -0
- package/dist/supervisor/supervisor.d.ts +86 -0
- package/dist/supervisor/supervisor.js +1629 -0
- package/dist/supervisor/supervisor.js.map +1 -0
- package/dist/supervisor/types.d.ts +49 -0
- package/dist/supervisor/types.js +3 -0
- package/dist/supervisor/types.js.map +1 -0
- package/dist/supervisor/view.d.ts +3 -0
- package/dist/supervisor/view.js +4 -0
- package/dist/supervisor/view.js.map +1 -0
- package/dist/tui.d.ts +15 -0
- package/dist/tui.js +256 -0
- package/dist/tui.js.map +1 -0
- package/dist/ui/gui/api.d.ts +17 -0
- package/dist/ui/gui/api.js +21 -0
- package/dist/ui/gui/api.js.map +1 -0
- package/dist/ui/gui/view.d.ts +26 -0
- package/dist/ui/gui/view.js +49 -0
- package/dist/ui/gui/view.js.map +1 -0
- package/dist/ui/tui/controller.d.ts +97 -0
- package/dist/ui/tui/controller.js +415 -0
- package/dist/ui/tui/controller.js.map +1 -0
- package/dist/ui/tui/menu.d.ts +55 -0
- package/dist/ui/tui/menu.js +176 -0
- package/dist/ui/tui/menu.js.map +1 -0
- package/dist/ui/tui/options.d.ts +19 -0
- package/dist/ui/tui/options.js +17 -0
- package/dist/ui/tui/options.js.map +1 -0
- package/dist/ui/tui/receipts.d.ts +21 -0
- package/dist/ui/tui/receipts.js +112 -0
- package/dist/ui/tui/receipts.js.map +1 -0
- package/dist/ui/tui/status.d.ts +22 -0
- package/dist/ui/tui/status.js +92 -0
- package/dist/ui/tui/status.js.map +1 -0
- package/dist/ui/tui/tiers.d.ts +51 -0
- package/dist/ui/tui/tiers.js +108 -0
- package/dist/ui/tui/tiers.js.map +1 -0
- package/package.json +85 -4
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { TIERS } from "../../core/tier-policy/types.js";
|
|
2
|
+
/** `provider/model` with an `@variant` suffix when pinned to one. */
|
|
3
|
+
export function resourceLabel(ref) {
|
|
4
|
+
const base = `${ref.providerID}/${ref.id}`;
|
|
5
|
+
return ref.variant === undefined ? base : `${base}@${ref.variant}`;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Unavailable-resource display: empty string when healthy, otherwise a
|
|
9
|
+
* bracketed, comma-separated tag list (health, breaker, window).
|
|
10
|
+
*/
|
|
11
|
+
export function healthTag(status) {
|
|
12
|
+
if (status === undefined)
|
|
13
|
+
return "";
|
|
14
|
+
const parts = [];
|
|
15
|
+
if (status.health !== "healthy")
|
|
16
|
+
parts.push(status.health);
|
|
17
|
+
if (status.breaker === "open")
|
|
18
|
+
parts.push("breaker-open");
|
|
19
|
+
else if (status.breaker === "half_open")
|
|
20
|
+
parts.push("half-open");
|
|
21
|
+
if (status.windowed)
|
|
22
|
+
parts.push("windowed");
|
|
23
|
+
return parts.length === 0 ? "" : ` [${parts.join(", ")}]`;
|
|
24
|
+
}
|
|
25
|
+
export function tierEditorOptions(settings, tier, status) {
|
|
26
|
+
const options = [
|
|
27
|
+
{ title: "Add model…", value: { kind: "add" }, description: "Search OpenCode models" },
|
|
28
|
+
];
|
|
29
|
+
const tierStatus = status?.tiers[tier];
|
|
30
|
+
settings.tiers[tier].forEach((ref, index) => {
|
|
31
|
+
options.push({
|
|
32
|
+
title: `${resourceLabel(ref)}${healthTag(tierStatus?.[index])}`,
|
|
33
|
+
value: { kind: "resource", index },
|
|
34
|
+
description: "Move or remove",
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
// No "Back" row: Escape steps back out of the dialog (undefined pick →
|
|
38
|
+
// the editor loop re-shows the tier list).
|
|
39
|
+
return options;
|
|
40
|
+
}
|
|
41
|
+
export function tierMenuOptions(status) {
|
|
42
|
+
return TIERS.map((tier) => {
|
|
43
|
+
const resources = status.tiers[tier];
|
|
44
|
+
// The lists are short: showing them inline answers "what is configured
|
|
45
|
+
// where" without opening the editor.
|
|
46
|
+
const description = resources.length === 0
|
|
47
|
+
? "(empty — add models to enable routing)"
|
|
48
|
+
: resources.map((entry) => resourceLabel(entry.ref)).join(" · ");
|
|
49
|
+
return { title: `${tier} (${String(resources.length)})`, value: tier, description };
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export function modelMatches(info, query) {
|
|
53
|
+
const q = query.trim().toLowerCase();
|
|
54
|
+
if (q === "")
|
|
55
|
+
return true;
|
|
56
|
+
return (info.providerID.toLowerCase().includes(q) ||
|
|
57
|
+
info.modelID.toLowerCase().includes(q) ||
|
|
58
|
+
info.name.toLowerCase().includes(q));
|
|
59
|
+
}
|
|
60
|
+
export function modelPickerOptions(models, query) {
|
|
61
|
+
return models
|
|
62
|
+
.filter((info) => modelMatches(info, query))
|
|
63
|
+
.map((info) => ({
|
|
64
|
+
title: `${info.providerID}/${info.modelID}`,
|
|
65
|
+
description: info.name,
|
|
66
|
+
value: { providerID: info.providerID, modelID: info.modelID },
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
export function variantOptions(variants) {
|
|
70
|
+
const options = [
|
|
71
|
+
{ title: "(model default)", value: { variant: undefined } },
|
|
72
|
+
];
|
|
73
|
+
for (const variant of variants) {
|
|
74
|
+
options.push({ title: `@${variant}`, value: { variant } });
|
|
75
|
+
}
|
|
76
|
+
return options;
|
|
77
|
+
}
|
|
78
|
+
/** Move the resource at `index` to the front (make it primary); out-of-bounds is a no-op. */
|
|
79
|
+
export function moveResourceToTop(resources, index) {
|
|
80
|
+
const item = resources[index];
|
|
81
|
+
if (item === undefined)
|
|
82
|
+
return [...resources];
|
|
83
|
+
return [item, ...resources.filter((_, i) => i !== index)];
|
|
84
|
+
}
|
|
85
|
+
/** Swap the resource at `index` with its `delta` neighbour; bounds are no-ops. */
|
|
86
|
+
export function moveResource(resources, index, delta) {
|
|
87
|
+
const next = [...resources];
|
|
88
|
+
const target = index + delta;
|
|
89
|
+
const item = next[index];
|
|
90
|
+
const other = next[target];
|
|
91
|
+
if (item === undefined || other === undefined)
|
|
92
|
+
return next;
|
|
93
|
+
next[index] = other;
|
|
94
|
+
next[target] = item;
|
|
95
|
+
return next;
|
|
96
|
+
}
|
|
97
|
+
/** Drop the resource at `index`; out-of-bounds keeps the list unchanged. */
|
|
98
|
+
export function removeResource(resources, index) {
|
|
99
|
+
const item = resources[index];
|
|
100
|
+
if (item === undefined)
|
|
101
|
+
return [...resources];
|
|
102
|
+
return resources.filter((_, i) => i !== index);
|
|
103
|
+
}
|
|
104
|
+
/** First validation error line for an alert; undefined when the patch applied. */
|
|
105
|
+
export function validationMessage(result) {
|
|
106
|
+
return result.ok ? undefined : result.errors.join("; ");
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=tiers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiers.js","sourceRoot":"","sources":["../../../src/ui/tui/tiers.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAA;AAOvD,qEAAqE;AACrE,MAAM,UAAU,aAAa,CAAC,GAAa;IACzC,MAAM,IAAI,GAAG,GAAG,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,EAAE,EAAE,CAAA;IAC1C,OAAO,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,CAAA;AACpE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,MAAsC;IAC9D,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,CAAA;IACnC,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC1D,IAAI,MAAM,CAAC,OAAO,KAAK,MAAM;QAAE,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;SACpD,IAAI,MAAM,CAAC,OAAO,KAAK,WAAW;QAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAChE,IAAI,MAAM,CAAC,QAAQ;QAAE,KAAK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AAG,SAAS,CAAC,KAAK,CAAC,CAAA;IAC7B,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAAA;IAC7C,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAA;AAChD,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,iBAAiB,CAAC,MAAmB;IACnD,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzD,CAAC","sourcesContent":["/**\n * Tier-editor view models (ADP-033): resource labels with clear health tags,\n * model search over the real OpenCode model list, variant picking, and pure\n * reorder/remove helpers. All functions are total and deterministic.\n */\nimport type { ModelRef } from \"../../core/work-unit/types.js\"\nimport { TIERS } from \"../../core/tier-policy/types.js\"\nimport type { TierName } from \"../../core/tier-policy/types.js\"\nimport type { StatusSnapshot, TierResourceStatus } from \"../../rpc/status.js\"\nimport type { SettingsV1 } from \"../../state/settings/index.js\"\nimport type { PatchResult } from \"../../state/settings/types.js\"\nimport type { SelectOption } from \"./options.js\"\n\n/** `provider/model` with an `@variant` suffix when pinned to one. */\nexport function resourceLabel(ref: ModelRef): string {\n const base = `${ref.providerID}/${ref.id}`\n return ref.variant === undefined ? base : `${base}@${ref.variant}`\n}\n\n/**\n * Unavailable-resource display: empty string when healthy, otherwise a\n * bracketed, comma-separated tag list (health, breaker, window).\n */\nexport function healthTag(status: TierResourceStatus | undefined): string {\n if (status === undefined) return \"\"\n const parts: string[] = []\n if (status.health !== \"healthy\") parts.push(status.health)\n if (status.breaker === \"open\") parts.push(\"breaker-open\")\n else if (status.breaker === \"half_open\") parts.push(\"half-open\")\n if (status.windowed) parts.push(\"windowed\")\n return parts.length === 0 ? \"\" : ` [${parts.join(\", \")}]`\n}\n\nexport type TierEditorChoice = { kind: \"add\" } | { kind: \"resource\"; index: number }\nexport function tierEditorOptions(\n settings: SettingsV1,\n tier: TierName,\n status: StatusSnapshot | undefined,\n): SelectOption<TierEditorChoice>[] {\n const options: SelectOption<TierEditorChoice>[] = [\n { title: \"Add model…\", value: { kind: \"add\" }, description: \"Search OpenCode models\" },\n ]\n const tierStatus = status?.tiers[tier]\n settings.tiers[tier].forEach((ref, index) => {\n options.push({\n title: `${resourceLabel(ref)}${healthTag(tierStatus?.[index])}`,\n value: { kind: \"resource\", index },\n description: \"Move or remove\",\n })\n })\n // No \"Back\" row: Escape steps back out of the dialog (undefined pick →\n // the editor loop re-shows the tier list).\n return options\n}\n\nexport function tierMenuOptions(status: StatusSnapshot): SelectOption<TierName>[] {\n return TIERS.map((tier) => {\n const resources = status.tiers[tier]\n // The lists are short: showing them inline answers \"what is configured\n // where\" without opening the editor.\n const description =\n resources.length === 0\n ? \"(empty — add models to enable routing)\"\n : resources.map((entry) => resourceLabel(entry.ref)).join(\" · \")\n return { title: `${tier} (${String(resources.length)})`, value: tier, description }\n })\n}\n\n/** Structural summary of one real OpenCode model (built by the entry). */\nexport interface ModelSummary {\n readonly providerID: string\n readonly modelID: string\n readonly name: string\n readonly variants: readonly string[]\n}\n\nexport interface ModelPick {\n providerID: string\n modelID: string\n}\n\nexport function modelMatches(info: ModelSummary, query: string): boolean {\n const q = query.trim().toLowerCase()\n if (q === \"\") return true\n return (\n info.providerID.toLowerCase().includes(q) ||\n info.modelID.toLowerCase().includes(q) ||\n info.name.toLowerCase().includes(q)\n )\n}\n\nexport function modelPickerOptions(\n models: readonly ModelSummary[],\n query: string,\n): SelectOption<ModelPick>[] {\n return models\n .filter((info) => modelMatches(info, query))\n .map((info) => ({\n title: `${info.providerID}/${info.modelID}`,\n description: info.name,\n value: { providerID: info.providerID, modelID: info.modelID },\n }))\n}\n\nexport interface VariantChoice {\n variant: string | undefined\n}\n\nexport function variantOptions(variants: readonly string[]): SelectOption<VariantChoice>[] {\n const options: SelectOption<VariantChoice>[] = [\n { title: \"(model default)\", value: { variant: undefined } },\n ]\n for (const variant of variants) {\n options.push({ title: `@${variant}`, value: { variant } })\n }\n return options\n}\n\n/** Move the resource at `index` to the front (make it primary); out-of-bounds is a no-op. */\nexport function moveResourceToTop(resources: readonly ModelRef[], index: number): ModelRef[] {\n const item = resources[index]\n if (item === undefined) return [...resources]\n return [item, ...resources.filter((_, i) => i !== index)]\n}\n\n/** Swap the resource at `index` with its `delta` neighbour; bounds are no-ops. */\nexport function moveResource(\n resources: readonly ModelRef[],\n index: number,\n delta: -1 | 1,\n): ModelRef[] {\n const next = [...resources]\n const target = index + delta\n const item = next[index]\n const other = next[target]\n if (item === undefined || other === undefined) return next\n next[index] = other\n next[target] = item\n return next\n}\n\n/** Drop the resource at `index`; out-of-bounds keeps the list unchanged. */\nexport function removeResource(resources: readonly ModelRef[], index: number): ModelRef[] {\n const item = resources[index]\n if (item === undefined) return [...resources]\n return resources.filter((_, i) => i !== index)\n}\n\n/** First validation error line for an alert; undefined when the patch applied. */\nexport function validationMessage(result: PatchResult): string | undefined {\n return result.ok ? undefined : result.errors.join(\"; \")\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,87 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coool/opencode-adaptive",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Execution supervisor plugin for OpenCode v2: capability-tier routing, structured-evidence escalation, horizontal failure recovery, and resource health tracking.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/Hacklone/opencode-adaptive.git"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./tui": {
|
|
17
|
+
"types": "./dist/tui.d.ts",
|
|
18
|
+
"import": "./dist/tui.js",
|
|
19
|
+
"default": "./dist/tui.js"
|
|
20
|
+
},
|
|
21
|
+
"./rpc": {
|
|
22
|
+
"import": "./dist/rpc.js",
|
|
23
|
+
"types": "./dist/rpc.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./gui-experimental": "./dist/gui-experimental.cjs"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"LICENSE",
|
|
30
|
+
"README.md"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=20.19.0"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"prebuild": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
37
|
+
"build": "tsc -p tsconfig.build.json && vite build --config guiconfig.ts",
|
|
38
|
+
"pack:check": "vite-node scripts/pack-check.ts",
|
|
39
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"coverage": "vitest run --coverage --project unit",
|
|
42
|
+
"lint": "eslint .",
|
|
43
|
+
"lint:biome": "biome lint --error-on-warnings .",
|
|
44
|
+
"format": "prettier --write .",
|
|
45
|
+
"format:check": "prettier --check .",
|
|
46
|
+
"plugin-test": "opencode-plugin-test",
|
|
47
|
+
"e2e:web": "playwright test",
|
|
48
|
+
"e2e:tui": "termwright test -- --config test/e2e-tui/vitest.config.ts",
|
|
49
|
+
"traceability": "vite-node scripts/traceability.ts",
|
|
50
|
+
"verify:release": "vite-node scripts/verify-release.ts"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"@opencode/plugin": ">=2.2.1 <3"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@opencode/schema": ">=2.2.1 <3",
|
|
57
|
+
"@standard-schema/spec": "^1.0.0"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@biomejs/biome": "2.6.4",
|
|
61
|
+
"@coool/opencode-plugin-test": "github:Hacklone/opencode-plugin-test",
|
|
62
|
+
"@eslint/js": "^9.39.5",
|
|
63
|
+
"@opencode/plugin": "2.2.5",
|
|
64
|
+
"@opentui/core": "^0.8.1",
|
|
65
|
+
"@opentui/solid": "^0.8.1",
|
|
66
|
+
"@playwright/test": "^1.64.1",
|
|
67
|
+
"@types/node": "^24",
|
|
68
|
+
"@vitest/coverage-v8": "^4",
|
|
69
|
+
"eslint": "^9",
|
|
70
|
+
"eslint-config-prettier": "^10",
|
|
71
|
+
"fast-check": "^4.10.2",
|
|
72
|
+
"jsdom": "^25.0.1",
|
|
73
|
+
"prettier": "^3",
|
|
74
|
+
"solid-js": "^1.9.18",
|
|
75
|
+
"termwright": "^0.7.7",
|
|
76
|
+
"typescript": "^5.9",
|
|
77
|
+
"typescript-eslint": "^8",
|
|
78
|
+
"vite": "^6.4.5",
|
|
79
|
+
"vite-node": "^6.0.0",
|
|
80
|
+
"vite-plugin-solid": "^2.11.15",
|
|
81
|
+
"vitest": "^4"
|
|
82
|
+
},
|
|
83
|
+
"allowScripts": {
|
|
84
|
+
"esbuild@0.25.12": true,
|
|
85
|
+
"fsevents@2.3.3": true
|
|
86
|
+
}
|
|
87
|
+
}
|