@modeloslab/modelcode 0.1.4 → 0.1.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/cli.mjs CHANGED
@@ -64,7 +64,7 @@ import {
64
64
  validateMnemonic,
65
65
  walletFromMnemonic,
66
66
  which
67
- } from "./main-wr686fnv.mjs";
67
+ } from "./main-t9m4v4fc.mjs";
68
68
  import"./main-p2xnn95s.mjs";
69
69
  import {
70
70
  __require
@@ -1609,7 +1609,7 @@ async function main() {
1609
1609
  s.resume();
1610
1610
  await new Promise((r) => setImmediate(r));
1611
1611
  }
1612
- const { runTui } = await import("./tui-sekv1hga.mjs");
1612
+ const { runTui } = await import("./tui-rxaw95g7.mjs");
1613
1613
  return runTui(cfg, resume);
1614
1614
  }
1615
1615
  if (cmd === "tui")
@@ -8073,15 +8073,40 @@ function extsFromGlob(glob) {
8073
8073
  function runProc(cmd, opts = {}) {
8074
8074
  return new Promise((resolve) => {
8075
8075
  const [bin, ...args] = cmd;
8076
- const so = { cwd: opts.cwd, env: { ...process.env, ...opts.env }, stdio: ["ignore", "pipe", "pipe"] };
8076
+ const so = { cwd: opts.cwd, env: { ...process.env, ...opts.env }, stdio: ["ignore", "pipe", "pipe"], detached: !isWin };
8077
8077
  const p = spawn(bin, args, so);
8078
- let stdout = "", stderr = "";
8078
+ let stdout = "", stderr = "", done = false;
8079
8079
  const dOut = new StringDecoder("utf8"), dErr = new StringDecoder("utf8");
8080
+ const finish = (code) => {
8081
+ if (done)
8082
+ return;
8083
+ done = true;
8084
+ if (killer)
8085
+ clearTimeout(killer);
8086
+ resolve({ code, stdout: stdout + dOut.end(), stderr: stderr + dErr.end() });
8087
+ };
8088
+ const killTree = (signal) => {
8089
+ try {
8090
+ if (isWin)
8091
+ spawnSync("taskkill", ["/pid", String(p.pid), "/T", "/F"], { stdio: "ignore" });
8092
+ else if (p.pid)
8093
+ process.kill(-p.pid, signal);
8094
+ else
8095
+ p.kill(signal);
8096
+ } catch {
8097
+ try {
8098
+ p.kill(signal);
8099
+ } catch {}
8100
+ }
8101
+ };
8080
8102
  let killer = null;
8081
8103
  if (opts.timeoutMs)
8082
8104
  killer = setTimeout(() => {
8083
- p.kill("SIGTERM");
8084
- setTimeout(() => p.kill("SIGKILL"), 2000);
8105
+ killTree("SIGTERM");
8106
+ setTimeout(() => {
8107
+ killTree("SIGKILL");
8108
+ finish(124);
8109
+ }, 2000);
8085
8110
  }, opts.timeoutMs);
8086
8111
  p.stdout?.on("data", (d) => {
8087
8112
  const s = dOut.write(d);
@@ -8093,15 +8118,10 @@ function runProc(cmd, opts = {}) {
8093
8118
  stderr += s;
8094
8119
  opts.onChunk?.(s, true);
8095
8120
  });
8096
- p.on("close", (code) => {
8097
- if (killer)
8098
- clearTimeout(killer);
8099
- resolve({ code: code ?? 0, stdout: stdout + dOut.end(), stderr: stderr + dErr.end() });
8100
- });
8121
+ p.on("close", (code) => finish(code ?? 0));
8101
8122
  p.on("error", (e) => {
8102
- if (killer)
8103
- clearTimeout(killer);
8104
- resolve({ code: 1, stdout, stderr: stderr + String(e) });
8123
+ stderr += String(e);
8124
+ finish(1);
8105
8125
  });
8106
8126
  });
8107
8127
  }
@@ -68,7 +68,7 @@ import {
68
68
  undo,
69
69
  userPromptSubmit,
70
70
  which
71
- } from "./main-wr686fnv.mjs";
71
+ } from "./main-t9m4v4fc.mjs";
72
72
  import"./main-p2xnn95s.mjs";
73
73
  import {
74
74
  __commonJS,
@@ -21829,10 +21829,34 @@ function App2({ theme, model, mdlUsd, lines, streaming, sessionMdl, contextPct,
21829
21829
  }, i, true, undefined, this);
21830
21830
  if (l.kind === "tool")
21831
21831
  return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
21832
- color: t.tool,
21833
21832
  children: [
21834
- " ⚙ ",
21835
- l.text
21833
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
21834
+ color: t.tool,
21835
+ children: "⏺ "
21836
+ }, undefined, false, undefined, this),
21837
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
21838
+ children: l.text
21839
+ }, undefined, false, undefined, this)
21840
+ ]
21841
+ }, i, true, undefined, this);
21842
+ if (l.kind === "result")
21843
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
21844
+ flexDirection: "row",
21845
+ children: [
21846
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
21847
+ color: t.dim,
21848
+ children: " ⎿ "
21849
+ }, undefined, false, undefined, this),
21850
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Box_default, {
21851
+ flexShrink: 1,
21852
+ flexGrow: 1,
21853
+ children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Text, {
21854
+ color: t.dim,
21855
+ children: l.text.split(`
21856
+ `).join(`
21857
+ `)
21858
+ }, undefined, false, undefined, this)
21859
+ }, undefined, false, undefined, this)
21836
21860
  ]
21837
21861
  }, i, true, undefined, this);
21838
21862
  if (l.kind === "error")
@@ -23819,6 +23843,26 @@ function imageMentions(line, cwd2) {
23819
23843
 
23820
23844
  // src/ui/tui.tsx
23821
23845
  var jsx_dev_runtime2 = __toESM(require_jsx_dev_runtime(), 1);
23846
+ function toolUseLabel(name, args) {
23847
+ const cap = (s, n = 160) => s.length > n ? s.slice(0, n).trim() + "…" : s;
23848
+ if (name === "bash")
23849
+ return cap(String(args.command ?? "").split(`
23850
+ `)[0] ?? "");
23851
+ if (name === "edit" || name === "write" || name === "read")
23852
+ return `${name} ${cap(String(args.path ?? ""), 80)}`;
23853
+ const keys2 = Object.entries(args).map(([k, v]) => `${k}=${cap(String(v), 40)}`).join(" ");
23854
+ return cap(`${name} ${keys2}`);
23855
+ }
23856
+ function capLines(s, max2) {
23857
+ const lines = s.replace(/\s+$/, "").split(`
23858
+ `);
23859
+ if (lines.length <= max2)
23860
+ return lines.join(`
23861
+ `);
23862
+ return lines.slice(0, max2).join(`
23863
+ `) + `
23864
+ … +${lines.length - max2} lines`;
23865
+ }
23822
23866
  function Root({ cfg, resume, mcpCount }) {
23823
23867
  const [lines, setLines] = import_react35.useState([
23824
23868
  { kind: "system", text: `ready · model ${cfg.model} — ask me anything, or /help` },
@@ -23837,7 +23881,9 @@ function Root({ cfg, resume, mcpCount }) {
23837
23881
  const [turnTokens, setTurnTokens] = import_react35.useState(0);
23838
23882
  const mdlUsd = import_react35.useRef(null);
23839
23883
  const streamBuf = import_react35.useRef("");
23884
+ const toolStreamRef = import_react35.useRef("");
23840
23885
  const tokensRef = import_react35.useRef(0);
23886
+ const pumpRef = import_react35.useRef(null);
23841
23887
  const busyRef = import_react35.useRef(false);
23842
23888
  const queueRef = import_react35.useRef([]);
23843
23889
  const confirmResolve = import_react35.useRef(null);
@@ -23872,20 +23918,22 @@ function Root({ cfg, resume, mcpCount }) {
23872
23918
  const agent = import_react35.useRef(new Agent(cfg, { cwd: cwd2 }, {
23873
23919
  onAssistantDelta: (txt) => {
23874
23920
  streamBuf.current += txt;
23875
- setStreaming(streamBuf.current);
23876
23921
  tokensRef.current += Math.max(1, Math.round(txt.length / 4));
23877
- setTurnTokens(tokensRef.current);
23878
23922
  },
23879
23923
  onToolStart: (name, args) => {
23880
23924
  flushAssistant();
23925
+ toolStreamRef.current = "";
23881
23926
  setToolStream("");
23882
- add2({ kind: "tool", text: `${name} ${JSON.stringify(args).slice(0, 80)}` });
23927
+ add2({ kind: "tool", text: toolUseLabel(name, args) });
23883
23928
  },
23884
23929
  onToolResult: (_n, r) => {
23930
+ toolStreamRef.current = "";
23885
23931
  setToolStream("");
23886
- add2({ kind: "system", text: r.slice(0, 300) });
23932
+ add2({ kind: "result", text: capLines(r, 8) });
23933
+ },
23934
+ onToolStream: (chunk2) => {
23935
+ toolStreamRef.current = (toolStreamRef.current + chunk2).slice(-2000);
23887
23936
  },
23888
- onToolStream: (chunk2) => setToolStream((s) => (s + chunk2).slice(-2000)),
23889
23937
  onCost: (g) => setSessionMdl((s) => {
23890
23938
  const v = s + g / 1e8;
23891
23939
  sessionMdlRef.current = v;
@@ -23932,6 +23980,7 @@ function Root({ cfg, resume, mcpCount }) {
23932
23980
  return;
23933
23981
  }
23934
23982
  streamBuf.current = "";
23983
+ toolStreamRef.current = "";
23935
23984
  setStreaming("");
23936
23985
  setToolStream("");
23937
23986
  tokensRef.current = 0;
@@ -23939,6 +23988,13 @@ function Root({ cfg, resume, mcpCount }) {
23939
23988
  setTurnStart(Date.now());
23940
23989
  busyRef.current = true;
23941
23990
  setBusy(true);
23991
+ if (pumpRef.current)
23992
+ clearInterval(pumpRef.current);
23993
+ pumpRef.current = setInterval(() => {
23994
+ setStreaming(streamBuf.current);
23995
+ setToolStream(toolStreamRef.current);
23996
+ setTurnTokens(tokensRef.current);
23997
+ }, 80);
23942
23998
  try {
23943
23999
  await agent.send(expandFileMentions(prompt, cwd2), imageMentions(prompt, cwd2));
23944
24000
  flushAssistant();
@@ -23955,9 +24011,14 @@ function Root({ cfg, resume, mcpCount }) {
23955
24011
  flushAssistant();
23956
24012
  add2({ kind: "error", text: e.message });
23957
24013
  } finally {
24014
+ if (pumpRef.current) {
24015
+ clearInterval(pumpRef.current);
24016
+ pumpRef.current = null;
24017
+ }
23958
24018
  setStreaming("");
23959
24019
  setToolStream("");
23960
24020
  streamBuf.current = "";
24021
+ toolStreamRef.current = "";
23961
24022
  busyRef.current = false;
23962
24023
  setBusy(false);
23963
24024
  setContextPct(agent.contextStatus().pct);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modeloslab/modelcode",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "modelOS-native AI coding agent CLI — remembers like Hermes, codes like Claude Code, runs on modelOS (pay-per-use in MDL, no rate limits). Knowledge-graph memory, subagents, MCP, vision, spend caps.",
5
5
  "type": "module",
6
6
  "bin": {