@cwillam/pi-minimax-usage 1.0.0 → 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/package.json +1 -1
- package/src/index.ts +28 -21
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -89,8 +89,11 @@ const state: PollingState = {
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
function getSettings(): ExtensionSettings["minimaxUsage"] {
|
|
92
|
-
// `settings` exists on the runtime context
|
|
93
|
-
//
|
|
92
|
+
// SAFETY: `settings` exists on the runtime context (populated by pi from
|
|
93
|
+
// `~/.pi/agent/settings.json` at session start) but isn't surfaced in the
|
|
94
|
+
// public ExtensionContext type. The double-assertion widens through
|
|
95
|
+
// `unknown` so TypeScript accepts the structural narrowing to a record
|
|
96
|
+
// with an optional `settings` field. Falls through to `undefined` if absent.
|
|
94
97
|
const raw = (
|
|
95
98
|
state.ctx as unknown as { settings?: ExtensionSettings } | undefined
|
|
96
99
|
)?.settings;
|
|
@@ -374,25 +377,13 @@ export default function (pi: ExtensionAPI): void {
|
|
|
374
377
|
|
|
375
378
|
pi.registerCommand(COMMAND_NAME, {
|
|
376
379
|
description: "MiniMax Token Plan usage: show status, refresh, or help",
|
|
377
|
-
handler: async (
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
if (!state.apiKey) {
|
|
385
|
-
cmdCtx.ui.notify(
|
|
386
|
-
"No API key configured for provider 'minimax'.",
|
|
387
|
-
"warning",
|
|
388
|
-
);
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
await pollOnce();
|
|
392
|
-
render();
|
|
393
|
-
cmdCtx.ui.notify(formatSnapshotForNotify(snapshot()), "info");
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
380
|
+
handler: async (
|
|
381
|
+
args: string | undefined,
|
|
382
|
+
cmdCtx: ExtensionCommandContext,
|
|
383
|
+
) => {
|
|
384
|
+
// Defensive: pi may invoke with `args === undefined` when no arguments
|
|
385
|
+
// were passed on the command line.
|
|
386
|
+
const sub = (args ?? "").trim().split(/\s+/)[0]?.toLowerCase() ?? "";
|
|
396
387
|
if (sub === "help" || sub === "--help" || sub === "-h") {
|
|
397
388
|
cmdCtx.ui.notify(
|
|
398
389
|
[
|
|
@@ -412,6 +403,22 @@ export default function (pi: ExtensionAPI): void {
|
|
|
412
403
|
);
|
|
413
404
|
return;
|
|
414
405
|
}
|
|
406
|
+
if (sub === "refresh") {
|
|
407
|
+
if (state.activeProviderId !== PROVIDER_ID) {
|
|
408
|
+
cmdCtx.ui.notify("MiniMax is not the active provider.", "warning");
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
if (!state.apiKey) {
|
|
412
|
+
cmdCtx.ui.notify(
|
|
413
|
+
"No API key configured for provider 'minimax'.",
|
|
414
|
+
"warning",
|
|
415
|
+
);
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
await pollOnce();
|
|
419
|
+
render();
|
|
420
|
+
}
|
|
421
|
+
// Always show status (covers both /minimax-usage and /minimax-usage refresh).
|
|
415
422
|
cmdCtx.ui.notify(formatSnapshotForNotify(snapshot()), "info");
|
|
416
423
|
},
|
|
417
424
|
});
|