@cydm/pie 1.0.21 → 1.0.22

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.
Files changed (2) hide show
  1. package/dist/cli.js +130 -6
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -45461,11 +45461,13 @@ async function probeModelsConfig(options) {
45461
45461
  };
45462
45462
  }
45463
45463
  function parseModelsCommandArgs(args) {
45464
- const parsed = { force: false, stdout: false };
45464
+ const parsed = { force: false, stdout: false, json: false };
45465
45465
  for (let i = 0; i < args.length; i += 1) {
45466
45466
  const arg = args[i];
45467
45467
  if (arg === "--force") {
45468
45468
  parsed.force = true;
45469
+ } else if (arg === "--json") {
45470
+ parsed.json = true;
45469
45471
  } else if (arg === "--stdout") {
45470
45472
  parsed.stdout = true;
45471
45473
  } else if (arg === "--probe" && args[i + 1]) {
@@ -60355,7 +60357,10 @@ async function loadSession(host, sessionId) {
60355
60357
  host.ui.requestRender();
60356
60358
  }
60357
60359
  }
60358
- function updateTerminalTitle(host) {
60360
+ var TITLE_SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
60361
+ var TITLE_SPINNER_INTERVAL_MS = 80;
60362
+ var titleSpinnerTimers = /* @__PURE__ */ new WeakMap();
60363
+ function updateTerminalTitle(host, spinnerFrame) {
60359
60364
  const activeSession = host.sessionManager.getActiveSession();
60360
60365
  if (!activeSession) {
60361
60366
  host.ui.terminal.setTitle("Pie");
@@ -60366,14 +60371,41 @@ function updateTerminalTitle(host) {
60366
60371
  messages: host.sessionManager.getMessages()
60367
60372
  });
60368
60373
  const activityState = host.submitLock ? "busy" : "ready";
60369
- host.ui.terminal.setTitle(`Pie \xB7 ${sessionLabel} [ms:session=${activeSession.id};state=${activityState}]`);
60374
+ const prefix = spinnerFrame ? `${spinnerFrame} ` : "";
60375
+ host.ui.terminal.setTitle(`${prefix}Pie \xB7 ${sessionLabel} [ms:session=${activeSession.id};state=${activityState}]`);
60376
+ }
60377
+ function stopTitleSpinner(host) {
60378
+ const timer = titleSpinnerTimers.get(host);
60379
+ if (timer) {
60380
+ clearInterval(timer);
60381
+ titleSpinnerTimers.delete(host);
60382
+ }
60383
+ }
60384
+ function startTitleSpinner(host) {
60385
+ stopTitleSpinner(host);
60386
+ let frameIndex = 0;
60387
+ const timer = setInterval(() => {
60388
+ const frame = TITLE_SPINNER_FRAMES[frameIndex % TITLE_SPINNER_FRAMES.length];
60389
+ updateTerminalTitle(host, frame);
60390
+ frameIndex++;
60391
+ }, TITLE_SPINNER_INTERVAL_MS);
60392
+ if (typeof timer.unref === "function") {
60393
+ timer.unref();
60394
+ }
60395
+ titleSpinnerTimers.set(host, timer);
60396
+ updateTerminalTitle(host, TITLE_SPINNER_FRAMES[0]);
60370
60397
  }
60371
60398
  function setSubmitLock(host, locked) {
60372
60399
  if (host.submitLock === locked) {
60373
60400
  return;
60374
60401
  }
60375
60402
  host.submitLock = locked;
60376
- host.updateTerminalTitle();
60403
+ stopTitleSpinner(host);
60404
+ if (locked) {
60405
+ startTitleSpinner(host);
60406
+ } else {
60407
+ host.updateTerminalTitle();
60408
+ }
60377
60409
  }
60378
60410
  async function handleTreeCommand(host) {
60379
60411
  const entries = host.sessionManager.getEntries();
@@ -68407,6 +68439,9 @@ async function runJsonEventsMode(params) {
68407
68439
  let trace;
68408
68440
  let lastRetryEvent;
68409
68441
  let mockActiveEntryId;
68442
+ let thinkingLevel = "off";
68443
+ let defaultRuntime;
68444
+ let defaultModelState;
68410
68445
  const noProgressTimeoutMs = Number(process.env.PIE_JSON_EVENTS_NO_PROGRESS_MS || 6e5);
68411
68446
  const mockResponseDelayMs = Number(process.env.PIE_TEST_MOCK_RESPONSE_DELAY_MS || 0);
68412
68447
  writeEvent({ type: "agent.ready", sessionId });
@@ -68752,6 +68787,10 @@ async function runJsonEventsMode(params) {
68752
68787
  if (!runtime) {
68753
68788
  throw new Error("JSON events mode requires a CLI runtime");
68754
68789
  }
68790
+ if (defaultRuntime !== runtime) {
68791
+ defaultRuntime = runtime;
68792
+ defaultModelState = configuredDefaultModelState(runtime);
68793
+ }
68755
68794
  if (runtime.initialModel.unconfigured || controller) {
68756
68795
  return;
68757
68796
  }
@@ -68780,7 +68819,7 @@ async function runJsonEventsMode(params) {
68780
68819
  systemPrompt: baseSystemPrompt,
68781
68820
  model: runtime.model,
68782
68821
  tools,
68783
- thinkingLevel: "off"
68822
+ thinkingLevel
68784
68823
  },
68785
68824
  apiKey: runtime.apiKey,
68786
68825
  streamFn: params.streamFn
@@ -68833,6 +68872,77 @@ async function runJsonEventsMode(params) {
68833
68872
  controller.updateRuntimeContext({ tools: agent.state.tools });
68834
68873
  disposeSemanticSubscription = agent.subscribeSemantic(handleSemanticEvent);
68835
68874
  }
68875
+ function metadataSelection(metadata, key) {
68876
+ if (!metadata || !(key in metadata)) return void 0;
68877
+ const value = metadata[key];
68878
+ if (value === null) return null;
68879
+ if (typeof value !== "string") throw new Error(`${key} must be a string or null`);
68880
+ const normalized = value.trim();
68881
+ return normalized && normalized !== "default" ? normalized : null;
68882
+ }
68883
+ function configuredDefaultModelState(runtime2) {
68884
+ const model = runtime2.initialModel.model ?? runtime2.model;
68885
+ const apiKey = runtime2.initialModel.apiKey || runtime2.modelRegistry.getApiKey(model) || runtime2.apiKey;
68886
+ return {
68887
+ provider: runtime2.initialModel.provider || model.provider || runtime2.provider,
68888
+ modelId: runtime2.initialModel.modelId || model.id || runtime2.modelId,
68889
+ model,
68890
+ apiKey
68891
+ };
68892
+ }
68893
+ function parseRequestedModel(value) {
68894
+ const separator = value.indexOf("/");
68895
+ if (separator <= 0 || separator === value.length - 1) return void 0;
68896
+ return {
68897
+ provider: value.slice(0, separator),
68898
+ modelId: value.slice(separator + 1)
68899
+ };
68900
+ }
68901
+ function applyRuntimeSelection(message) {
68902
+ if (!runtime || !agent) return;
68903
+ const requestedModel = metadataSelection(message.metadata, "model");
68904
+ const requestedThinkingLevel = metadataSelection(message.metadata, "thinkingLevel");
68905
+ if (requestedModel !== void 0) {
68906
+ if (requestedModel === null) {
68907
+ const defaults = defaultModelState;
68908
+ if (defaults) {
68909
+ agent.setModel(defaults.model);
68910
+ agent.apiKey = defaults.apiKey;
68911
+ runtime.model = defaults.model;
68912
+ runtime.provider = defaults.provider;
68913
+ runtime.modelId = defaults.modelId;
68914
+ runtime.apiKey = defaults.apiKey;
68915
+ }
68916
+ } else {
68917
+ const parsed = parseRequestedModel(requestedModel);
68918
+ if (!parsed) throw new Error(`model must use profile/modelId format: ${requestedModel}`);
68919
+ const { provider, modelId } = parsed;
68920
+ const model = runtime.modelRegistry.find(provider, modelId);
68921
+ if (!model) throw new Error(`Model "${requestedModel}" not found`);
68922
+ const apiKey = runtime.modelRegistry.getApiKey(model);
68923
+ agent.setModel(model);
68924
+ agent.apiKey = apiKey;
68925
+ runtime.model = model;
68926
+ runtime.provider = provider;
68927
+ runtime.modelId = modelId;
68928
+ runtime.apiKey = apiKey;
68929
+ }
68930
+ }
68931
+ if (requestedThinkingLevel !== void 0) {
68932
+ const nextLevel = requestedThinkingLevel === null ? "off" : requestedThinkingLevel;
68933
+ if (!isThinkingLevel(nextLevel)) throw new Error(`Unsupported thinkingLevel: ${nextLevel}`);
68934
+ thinkingLevel = nextLevel;
68935
+ applyThinkingLevel({
68936
+ level: thinkingLevel,
68937
+ agent,
68938
+ settingsManager: runtime.settingsManager,
68939
+ sessionManager: runtime.sessionManager,
68940
+ model: runtime.model
68941
+ });
68942
+ } else {
68943
+ syncSessionModelMetadata(runtime.sessionManager, runtime.model, thinkingLevel);
68944
+ }
68945
+ }
68836
68946
  async function runTurn(message) {
68837
68947
  if (isSessionMismatch(message)) {
68838
68948
  writeEvent({
@@ -68915,6 +69025,14 @@ async function runJsonEventsMode(params) {
68915
69025
  if (activeTurn === turn) activeTurn = null;
68916
69026
  return;
68917
69027
  }
69028
+ try {
69029
+ applyRuntimeSelection(message);
69030
+ } catch (error) {
69031
+ finalize("failed", error instanceof Error ? error.message : String(error));
69032
+ if (activeTurn === turn) emitSettled(turn);
69033
+ if (activeTurn === turn) activeTurn = null;
69034
+ return;
69035
+ }
68918
69036
  const progressTimer = setInterval(() => {
68919
69037
  const turn2 = activeTurn;
68920
69038
  if (!turn2 || turn2.finalized) return;
@@ -69135,6 +69253,12 @@ async function runModelsCommand(args) {
69135
69253
  }
69136
69254
  if (subcommand === "validate") {
69137
69255
  const result = validateModelsConfig({ path: parsed.path });
69256
+ if (parsed.json) {
69257
+ const probe = result.ok && parsed.probe ? await probeModelsConfig({ path: parsed.path, probe: parsed.probe }) : void 0;
69258
+ console.log(JSON.stringify({ ...result, ...probe ? { probe } : {} }, null, 2));
69259
+ if (!result.ok || probe?.status === "failed") process.exitCode = 1;
69260
+ return;
69261
+ }
69138
69262
  if (!result.ok) {
69139
69263
  console.error(result.message);
69140
69264
  process.exitCode = 1;
@@ -69175,7 +69299,7 @@ async function runModelsCommand(args) {
69175
69299
  }
69176
69300
  console.log(`Usage:
69177
69301
  pie models init [--path <path>] [--force] [--stdout]
69178
- pie models validate [--path <path>] [--probe web_search]`);
69302
+ pie models validate [--path <path>] [--probe web_search] [--json]`);
69179
69303
  }
69180
69304
  function parseRepeatedFlag(args, flag) {
69181
69305
  const values = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cydm/pie",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "Pie AI Agent CLI",
5
5
  "type": "module",
6
6
  "bin": {