@ocis/myagent-cli 0.2.3 → 0.2.5

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/index.js CHANGED
@@ -10,7 +10,7 @@ import { stdin as input, stdout as output } from "node:process";
10
10
  import { homedir } from "node:os";
11
11
  import { resolve } from "node:path";
12
12
  import pkg from "../package.json" with { type: "json" };
13
- import { IntegrationClient } from "./protocol/client.js";
13
+ import { IntegrationClient, IntegrationApiError } from "./protocol/client.js";
14
14
  import { ToolRegistry } from "./tools/registry.js";
15
15
  import { combinedIntegrationUrl, configDir, isConfigured, loadConfig, migrateLegacyConfigDir, resolveConfig, saveConfig, sessionsPath, splitIntegrationUrl, } from "./config.js";
16
16
  import { SessionIndex } from "./agent/sessions.js";
@@ -335,15 +335,24 @@ async function main() {
335
335
  integrationId: config.integrationId,
336
336
  apiKey: config.apiKey,
337
337
  });
338
- let status;
338
+ let status = null;
339
339
  try {
340
340
  // Bounded connect: a hung server must fail (exit 2) instead of hanging CI.
341
341
  status = await client.getStatus({ signal: AbortSignal.timeout(30_000) });
342
342
  }
343
343
  catch (err) {
344
- return fail(args.flags.outputFormat, `Could not reach ${config.baseUrl}: ${err instanceof Error ? err.message : String(err)}`, "connection_failed");
344
+ // A paused platform sandbox answers the status check with 503 — the check
345
+ // deliberately does not wake it (see the platform's proxy-activator). That
346
+ // is not a connection failure: the first run wakes the sandbox, so proceed
347
+ // with a notice instead of failing.
348
+ if (err instanceof IntegrationApiError && err.status === 503) {
349
+ process.stderr.write("Sandbox is paused — it will start on your first message.\n");
350
+ }
351
+ else {
352
+ return fail(args.flags.outputFormat, `Could not reach ${config.baseUrl}: ${err instanceof Error ? err.message : String(err)}`, "connection_failed");
353
+ }
345
354
  }
346
- if (!status.enabled) {
355
+ if (status && !status.enabled) {
347
356
  return fail(args.flags.outputFormat, `Integration "${status.label}" is disabled on the server.`, "integration_disabled");
348
357
  }
349
358
  const sessionIndex = await SessionIndex.load(sessionsPath());
@@ -231,14 +231,26 @@ export class IntegrationClient {
231
231
  let message = `HTTP ${res.status}`;
232
232
  let code;
233
233
  let details;
234
+ // Read the body once as text: myagent's error bodies are JSON, but the
235
+ // platform proxy answers with plain text (e.g. its 503 for a paused
236
+ // sandbox) — keep that text instead of collapsing it to "HTTP 503".
237
+ let text = "";
234
238
  try {
235
- const body = await res.json();
236
- if (body.error?.message)
237
- message = body.error.message;
238
- code = body.error?.code;
239
- details = body.error?.details;
239
+ text = await res.text();
240
+ }
241
+ catch { /* unreadable body */ }
242
+ if (text) {
243
+ try {
244
+ const body = JSON.parse(text);
245
+ if (body.error?.message)
246
+ message = body.error.message;
247
+ code = body.error?.code;
248
+ details = body.error?.details;
249
+ }
250
+ catch {
251
+ message = text.trim() || message;
252
+ }
240
253
  }
241
- catch { /* non-JSON error body */ }
242
254
  if (res.status === 404) {
243
255
  message += " (check the integration id and that the integration is enabled)";
244
256
  }
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 is
353
- * for the startup default display (and stays empty when the server is
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 display before any thread/model knowledge exists.
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
  }, {
@@ -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. */
@@ -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. */
@@ -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;
@@ -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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocis/myagent-cli",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Terminal coding agent for your local repository, powered by a remote MyAgent server",
5
5
  "type": "module",
6
6
  "bin": {