@dylanrussell/agent-router 2.0.0 → 2.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/CHANGELOG.md +7 -0
- package/dist/cli.js +8 -3
- package/dist/cli.js.map +1 -1
- package/dist/plugin.js +29 -13
- package/dist/plugin.js.map +1 -1
- package/package.json +9 -5
package/dist/plugin.js
CHANGED
|
@@ -15488,7 +15488,7 @@ function parseModelList(stdout) {
|
|
|
15488
15488
|
if (model.enabled === false) continue;
|
|
15489
15489
|
const id = `${model.providerID}/${model.id}`;
|
|
15490
15490
|
out.add(id);
|
|
15491
|
-
for (const
|
|
15491
|
+
for (const variant2 of model.variants ?? []) out.add(`${id}#${variant2.id}`);
|
|
15492
15492
|
}
|
|
15493
15493
|
return out;
|
|
15494
15494
|
}
|
|
@@ -15596,8 +15596,8 @@ async function applyStack(paths, name, options = {}) {
|
|
|
15596
15596
|
let wantModel = entry.model;
|
|
15597
15597
|
if (model.includes("#") || wantModel.includes("#")) {
|
|
15598
15598
|
const [base, inline] = wantModel.split("#");
|
|
15599
|
-
const
|
|
15600
|
-
wantModel = `${base}${
|
|
15599
|
+
const variant2 = "variant" in entry ? entry.variant : inline ?? model.split("#")[1];
|
|
15600
|
+
wantModel = `${base}${variant2 ? `#${variant2}` : ""}`;
|
|
15601
15601
|
wantOptions.variant = null;
|
|
15602
15602
|
}
|
|
15603
15603
|
const afterOptions = setFrontmatterOptions(content, wantOptions);
|
|
@@ -15627,12 +15627,12 @@ async function applyStack(paths, name, options = {}) {
|
|
|
15627
15627
|
lastSwitchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
15628
15628
|
fallbackAgents: Object.fromEntries(
|
|
15629
15629
|
Object.entries(target.agents).filter(([, entry]) => entry.fallbacks?.length).map(([agent, entry]) => {
|
|
15630
|
-
const
|
|
15630
|
+
const variant2 = "variant" in entry ? entry.variant : displaced.agents[agent]?.variant;
|
|
15631
15631
|
return [
|
|
15632
15632
|
agent,
|
|
15633
15633
|
{
|
|
15634
15634
|
model: entry.model,
|
|
15635
|
-
variant: typeof
|
|
15635
|
+
variant: typeof variant2 === "string" ? variant2 : void 0,
|
|
15636
15636
|
fallbacks: entry.fallbacks
|
|
15637
15637
|
}
|
|
15638
15638
|
];
|
|
@@ -15732,6 +15732,7 @@ async function captureStack(paths, name, options = {}) {
|
|
|
15732
15732
|
}
|
|
15733
15733
|
|
|
15734
15734
|
// src/v2.ts
|
|
15735
|
+
var variant = (value) => value === "default" ? void 0 : value ?? void 0;
|
|
15735
15736
|
async function setupV2(ctx) {
|
|
15736
15737
|
const legacy = await AgentRouterPlugin(
|
|
15737
15738
|
{ client: {} },
|
|
@@ -15770,7 +15771,20 @@ async function setupV2(ctx) {
|
|
|
15770
15771
|
variant: entry.variant,
|
|
15771
15772
|
fallbacks: entry.fallbacks
|
|
15772
15773
|
});
|
|
15773
|
-
|
|
15774
|
+
if (!parsed.success || !parsed.data.fallbacks?.length) return [];
|
|
15775
|
+
return [
|
|
15776
|
+
[
|
|
15777
|
+
id,
|
|
15778
|
+
{
|
|
15779
|
+
...parsed.data,
|
|
15780
|
+
variant: variant(parsed.data.variant),
|
|
15781
|
+
fallbacks: parsed.data.fallbacks.map((entry2) => ({
|
|
15782
|
+
...entry2,
|
|
15783
|
+
variant: variant(entry2.variant)
|
|
15784
|
+
}))
|
|
15785
|
+
}
|
|
15786
|
+
]
|
|
15787
|
+
];
|
|
15774
15788
|
})
|
|
15775
15789
|
);
|
|
15776
15790
|
const failover = createFailover(routes, async (message) => {
|
|
@@ -15787,7 +15801,7 @@ async function setupV2(ctx) {
|
|
|
15787
15801
|
if (!turns.has(sessionID)) continue;
|
|
15788
15802
|
if (event.type === "session.model.selected") {
|
|
15789
15803
|
const model = event.data.model;
|
|
15790
|
-
if (ownSelections.get(sessionID) === `${model.providerID}/${model.id}#${model.variant ?? ""}`) {
|
|
15804
|
+
if (ownSelections.get(sessionID) === `${model.providerID}/${model.id}#${variant(model.variant) ?? ""}`) {
|
|
15791
15805
|
ownSelections.delete(sessionID);
|
|
15792
15806
|
continue;
|
|
15793
15807
|
}
|
|
@@ -15826,7 +15840,7 @@ async function setupV2(ctx) {
|
|
|
15826
15840
|
model: {
|
|
15827
15841
|
providerID: session.model.providerID,
|
|
15828
15842
|
modelID: session.model.id,
|
|
15829
|
-
variant: session.model.variant
|
|
15843
|
+
variant: variant(session.model.variant)
|
|
15830
15844
|
}
|
|
15831
15845
|
};
|
|
15832
15846
|
const before = JSON.stringify(message.model);
|
|
@@ -15904,23 +15918,23 @@ async function setupV2(ctx) {
|
|
|
15904
15918
|
}
|
|
15905
15919
|
|
|
15906
15920
|
// src/version.ts
|
|
15907
|
-
var VERSION = "2.0.
|
|
15921
|
+
var VERSION = "2.0.1";
|
|
15908
15922
|
|
|
15909
15923
|
// src/plugin.ts
|
|
15910
15924
|
var tool = Object.assign(
|
|
15911
15925
|
(definition) => definition,
|
|
15912
15926
|
{ schema: external_exports }
|
|
15913
15927
|
);
|
|
15914
|
-
async function safeToast(client, message,
|
|
15928
|
+
async function safeToast(client, message, variant2 = "success") {
|
|
15915
15929
|
try {
|
|
15916
15930
|
if (client.tui?.showToast) {
|
|
15917
|
-
const result = await client.tui.showToast({ body: { message, variant, duration: 15e3 } });
|
|
15931
|
+
const result = await client.tui.showToast({ body: { message, variant: variant2, duration: 15e3 } });
|
|
15918
15932
|
if (result && typeof result === "object" && "error" in result && result.error)
|
|
15919
15933
|
throw result.error;
|
|
15920
15934
|
return;
|
|
15921
15935
|
}
|
|
15922
15936
|
if (client.tui?.toast?.show) {
|
|
15923
|
-
await client.tui.toast.show({ body: { message, variant } });
|
|
15937
|
+
await client.tui.toast.show({ body: { message, variant: variant2 } });
|
|
15924
15938
|
return;
|
|
15925
15939
|
}
|
|
15926
15940
|
} catch {
|
|
@@ -16093,7 +16107,9 @@ var AgentRouterPlugin = async (ctx, validateOptions) => {
|
|
|
16093
16107
|
async execute(args) {
|
|
16094
16108
|
try {
|
|
16095
16109
|
failover.disable();
|
|
16096
|
-
const r = await back(paths, args.n ?? 1
|
|
16110
|
+
const r = await back(paths, args.n ?? 1, {
|
|
16111
|
+
...validateOptions ? { validateOptions } : {}
|
|
16112
|
+
});
|
|
16097
16113
|
await safeToast(
|
|
16098
16114
|
client,
|
|
16099
16115
|
`agent-router: reverted to "${r.current}". Restart opencode for change to take effect.`
|