@ocis/myagent-cli 0.2.3 → 0.2.4
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/dist/ui/app.js +20 -12
- package/dist/ui/components.d.ts +1 -0
- package/dist/ui/components.js +1 -0
- package/dist/ui/model-list.d.ts +7 -0
- package/dist/ui/model-list.js +11 -0
- package/package.json +1 -1
package/dist/ui/app.js
CHANGED
|
@@ -18,7 +18,7 @@ import { collectFileDiff, collectGitStatus, EMPTY_GIT_STATUS } from "../git/stat
|
|
|
18
18
|
import { sanitizeForTerminal } from "../sanitize.js";
|
|
19
19
|
import { bgRgb, isColorEnabled, modeBorder, overlayBackgroundRgb, panelBackgroundRgb, style, userMessageBackgroundRgb } from "./colors.js";
|
|
20
20
|
import { helpLines } from "./help.js";
|
|
21
|
-
import { buildModelItems, currentModelId } from "./model-list.js";
|
|
21
|
+
import { buildModelItems, currentModelId, modelDisplayName } from "./model-list.js";
|
|
22
22
|
import { createQuitConfirm } from "./quit-confirm.js";
|
|
23
23
|
import { selectCardWidth, selectDescriptionMinWidth, selectLabelColumn, selectVisibleRows } from "./select-popup.js";
|
|
24
24
|
import { editorTheme, selectListTheme } from "./theme.js";
|
|
@@ -349,24 +349,30 @@ export async function runTui(opts) {
|
|
|
349
349
|
if (opts.initialModel)
|
|
350
350
|
editor.model = opts.initialModel;
|
|
351
351
|
/**
|
|
352
|
-
* Cached GET /v1/models list — the picker refreshes on open; this cache
|
|
353
|
-
*
|
|
354
|
-
* unreachable or has no models configured
|
|
352
|
+
* Cached GET /v1/models list — the picker refreshes on open; this cache backs
|
|
353
|
+
* the model display (label, not id) and the startup default. Stays empty when
|
|
354
|
+
* the server is unreachable or has no models configured.
|
|
355
355
|
*/
|
|
356
|
+
let modelList = [];
|
|
356
357
|
let defaultModelId = null;
|
|
358
|
+
/** Display name for a model id — the server's label when known, else the id. */
|
|
359
|
+
const modelName = (id) => modelDisplayName(modelList, id);
|
|
357
360
|
void opts.client.listModels().then((models) => {
|
|
358
361
|
if (models.length === 0)
|
|
359
362
|
return;
|
|
363
|
+
modelList = models;
|
|
360
364
|
defaultModelId = models.find((m) => m.default)?.id ?? models[0].id;
|
|
361
365
|
if (opts.initialModel && !models.some((m) => m.id === opts.initialModel)) {
|
|
362
366
|
addTranscript(new NoticeComponent(`Model "${opts.initialModel}" is not available on this integration — the server default applies instead.`, "warn"));
|
|
363
367
|
}
|
|
364
|
-
// Only fill the
|
|
368
|
+
// Only fill the model before any thread/model knowledge exists.
|
|
365
369
|
if (!runner.threadId && !runner.selectedModel) {
|
|
366
370
|
runner.model = defaultModelId;
|
|
367
|
-
editor.model = defaultModelId;
|
|
368
|
-
tui.requestRender();
|
|
369
371
|
}
|
|
372
|
+
// The display may have been seeded from an id before the list arrived —
|
|
373
|
+
// refresh it now that labels are known.
|
|
374
|
+
editor.model = modelName(runner.model);
|
|
375
|
+
tui.requestRender();
|
|
370
376
|
}).catch(() => { });
|
|
371
377
|
function log(line) {
|
|
372
378
|
logLines.push(line);
|
|
@@ -377,7 +383,7 @@ export async function runTui(opts) {
|
|
|
377
383
|
function applySessionDetail(detail, options = {}) {
|
|
378
384
|
if (detail.model)
|
|
379
385
|
runner.model = detail.model;
|
|
380
|
-
editor.model = detail.model ?? runner.model;
|
|
386
|
+
editor.model = modelName(detail.model ?? runner.model);
|
|
381
387
|
if (detail.title)
|
|
382
388
|
sidebar.state.title = detail.title;
|
|
383
389
|
const usage = usageFromSession(detail.usage);
|
|
@@ -675,7 +681,7 @@ export async function runTui(opts) {
|
|
|
675
681
|
runner.setThinkingLevel(opts.initialThinking);
|
|
676
682
|
// Back to the pending client-choice selection (or the server default).
|
|
677
683
|
runner.model = runner.selectedModel ?? defaultModelId;
|
|
678
|
-
editor.model = runner.model;
|
|
684
|
+
editor.model = modelName(runner.model);
|
|
679
685
|
firstUserMessage = null;
|
|
680
686
|
clearView();
|
|
681
687
|
addTranscript(new NoticeComponent("New session.", "info"));
|
|
@@ -812,16 +818,18 @@ export async function runTui(opts) {
|
|
|
812
818
|
tui.requestRender();
|
|
813
819
|
return;
|
|
814
820
|
}
|
|
821
|
+
// Refresh the display cache — the policy may have changed since startup.
|
|
822
|
+
modelList = models;
|
|
815
823
|
const current = currentModelId(models, runner.model, runner.selectedModel);
|
|
816
824
|
showSelectOverlay("Model (applies to a new session)", buildModelItems(models, current), (value) => {
|
|
817
825
|
runner.setModel(value);
|
|
818
826
|
if (runner.threadId) {
|
|
819
|
-
addTranscript(new NoticeComponent(`Model for new sessions: ${value}. This thread keeps ${runner.model ?? "its pinned model"} — run /new to switch.`, "info"));
|
|
827
|
+
addTranscript(new NoticeComponent(`Model for new sessions: ${modelName(value)}. This thread keeps ${modelName(runner.model) ?? "its pinned model"} — run /new to switch.`, "info"));
|
|
820
828
|
}
|
|
821
829
|
else {
|
|
822
830
|
runner.model = value;
|
|
823
|
-
editor.model = value;
|
|
824
|
-
addTranscript(new NoticeComponent(`Model: ${value}`, "info"));
|
|
831
|
+
editor.model = modelName(value);
|
|
832
|
+
addTranscript(new NoticeComponent(`Model: ${modelName(value)}`, "info"));
|
|
825
833
|
}
|
|
826
834
|
tui.requestRender();
|
|
827
835
|
}, {
|
package/dist/ui/components.d.ts
CHANGED
|
@@ -135,6 +135,7 @@ export declare class SidebarComponent implements Component {
|
|
|
135
135
|
export type EditorChip = "mode" | "model" | "thinking";
|
|
136
136
|
export declare class PromptEditor extends Editor {
|
|
137
137
|
mode: AgentMode;
|
|
138
|
+
/** Display name of the model in use (the server's label when known, else its id). */
|
|
138
139
|
model: string | null;
|
|
139
140
|
thinking: string | undefined;
|
|
140
141
|
/** Fired when a bottom-edge chip (mode / model / thinking) is clicked. */
|
package/dist/ui/components.js
CHANGED
|
@@ -406,6 +406,7 @@ export class SidebarComponent {
|
|
|
406
406
|
}
|
|
407
407
|
export class PromptEditor extends Editor {
|
|
408
408
|
mode;
|
|
409
|
+
/** Display name of the model in use (the server's label when known, else its id). */
|
|
409
410
|
model = null;
|
|
410
411
|
thinking;
|
|
411
412
|
/** Fired when a bottom-edge chip (mode / model / thinking) is clicked. */
|
package/dist/ui/model-list.d.ts
CHANGED
|
@@ -8,3 +8,10 @@ import type { ModelInfo } from "../protocol/types.js";
|
|
|
8
8
|
export declare function currentModelId(models: ModelInfo[], activeModel: string | null, selectedModel: string | null): string | undefined;
|
|
9
9
|
/** Build the `/model` picker rows for a model list. */
|
|
10
10
|
export declare function buildModelItems(models: ModelInfo[], currentId: string | undefined): SelectItem[];
|
|
11
|
+
/**
|
|
12
|
+
* Display name for a model id: the server's label when the list knows the id,
|
|
13
|
+
* else the id itself (a model the list no longer carries, or a list that has
|
|
14
|
+
* not loaded yet). The label is remote text — callers render it through the
|
|
15
|
+
* usual sanitizing path (the editor border and notices both do).
|
|
16
|
+
*/
|
|
17
|
+
export declare function modelDisplayName(models: ModelInfo[], id: string | null): string | null;
|
package/dist/ui/model-list.js
CHANGED
|
@@ -34,3 +34,14 @@ export function buildModelItems(models, currentId) {
|
|
|
34
34
|
};
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Display name for a model id: the server's label when the list knows the id,
|
|
39
|
+
* else the id itself (a model the list no longer carries, or a list that has
|
|
40
|
+
* not loaded yet). The label is remote text — callers render it through the
|
|
41
|
+
* usual sanitizing path (the editor border and notices both do).
|
|
42
|
+
*/
|
|
43
|
+
export function modelDisplayName(models, id) {
|
|
44
|
+
if (!id)
|
|
45
|
+
return null;
|
|
46
|
+
return models.find((m) => m.id === id)?.label ?? id;
|
|
47
|
+
}
|