@runappsai/agent 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/chat.js CHANGED
@@ -1075,6 +1075,9 @@ export function renderChat(target, opts) {
1075
1075
  clearBtn.type = "button";
1076
1076
  clearBtn.innerHTML = I.eraser() + `<span>${escapeHTML(t.clearChat)}</span>`;
1077
1077
  clearBtn.style.display = "none";
1078
+ // One conversation, no list of them (sessions: false, or the host's own agent): Clear stands in for New chat, and shows only when there is something to clear.
1079
+ let oneChat = false;
1080
+ const syncClear = () => { clearBtn.style.display = oneChat && agent?.messages.length ? "" : "none"; };
1078
1081
  // How full the context is, as a ring; a click opens the numbers and the spending.
1079
1082
  const useBtn = h("button", "ra-btn ghost ra-usebtn");
1080
1083
  useBtn.type = "button";
@@ -2396,6 +2399,7 @@ export function renderChat(target, opts) {
2396
2399
  flush(true);
2397
2400
  if (!messages.length)
2398
2401
  showEmpty();
2402
+ syncClear();
2399
2403
  list.scrollToBottom();
2400
2404
  };
2401
2405
  /* --- composer --- */
@@ -3505,7 +3509,7 @@ export function renderChat(target, opts) {
3505
3509
  closeActive();
3506
3510
  }
3507
3511
  await new Promise((r) => setTimeout(r, 0));
3508
- await (clearBtn.style.display === "none" ? newSession().then(() => undefined) : clearConversation());
3512
+ await (oneChat ? clearConversation() : newSession().then(() => undefined));
3509
3513
  const b = agent;
3510
3514
  if (summary) {
3511
3515
  await b.seed(summary);
@@ -3616,7 +3620,7 @@ export function renderChat(target, opts) {
3616
3620
  const lines = builtinCommands().map((c) => `- \`/${c.name}${c.args ? ` ${c.args}` : ""}\` — ${c.description}`);
3617
3621
  addNote(t.cmdsTitle, [...lines, "", t.cmdsMore].join("\n"));
3618
3622
  } },
3619
- { name: "new", aliases: ["clear"], run: () => { closeMenu(); return clearBtn.style.display === "none" ? newSession().then(() => undefined) : clearConversation(); } },
3623
+ { name: "new", aliases: ["clear"], run: () => { closeMenu(); return oneChat ? clearConversation() : newSession().then(() => undefined); } },
3620
3624
  { name: "resume", run: () => openMenu() },
3621
3625
  { name: "compact", args: t.cmdArgs.compact, run: async (focus) => { await compactNow(focus); } },
3622
3626
  { name: "continue", run: async () => {
@@ -3703,8 +3707,8 @@ export function renderChat(target, opts) {
3703
3707
  ];
3704
3708
  /** The built-ins this chat offers now (the files, settings and debug ones only where their button shows). */
3705
3709
  const builtinCommands = () => builtins
3706
- .filter((b) => (b.name !== "files" || (!!agent?.workspace && filesOpt !== false)) && (b.name !== "settings" || hasSettings) && (b.name !== "debug" || debugOn) && (b.name !== "resume" || (!givenAgent && !!agent?.workspace && clearBtn.style.display === "none")))
3707
- .map((b) => ({ name: b.name, description: b.name === "new" && clearBtn.style.display !== "none" ? t.confirmClear.split(/[??]/)[0] : t.cmd[b.name] ?? "", kind: t.command, args: b.args, builtin: true }));
3710
+ .filter((b) => (b.name !== "files" || (!!agent?.workspace && filesOpt !== false)) && (b.name !== "settings" || hasSettings) && (b.name !== "debug" || debugOn) && (b.name !== "resume" || (!givenAgent && !!agent?.workspace && !oneChat)))
3711
+ .map((b) => ({ name: b.name, description: b.name === "new" && oneChat ? t.confirmClear.split(/[??]/)[0] : t.cmd[b.name] ?? "", kind: t.command, args: b.args, builtin: true }));
3708
3712
  /** `/name [arg]` naming a built-in: run it here (nothing goes to the model). */
3709
3713
  const runBuiltin = (text) => {
3710
3714
  const m = /^\/(\S+)(?:\s+([\s\S]*))?$/.exec(text);
@@ -3862,7 +3866,8 @@ export function renderChat(target, opts) {
3862
3866
  // A host's own agent has no sessions to switch between: the chat cannot make a new one.
3863
3867
  const hasSessions = !givenAgent && (sessions ?? !!a.workspace);
3864
3868
  histBtn.style.display = newBtn.style.display = hasSessions && a.workspace ? "" : "none";
3865
- clearBtn.style.display = hasSessions && a.workspace ? "none" : "";
3869
+ oneChat = !(hasSessions && a.workspace);
3870
+ syncClear();
3866
3871
  filesBtn.style.display = a.workspace && filesOpt !== false ? "" : "none";
3867
3872
  skillsBtn.style.display = a.workspace && skillsMenu !== false ? "" : "none";
3868
3873
  panel.setWorkspace(a.workspace);
@@ -3877,6 +3882,7 @@ export function renderChat(target, opts) {
3877
3882
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3878
3883
  const on = (name, fn) => unsub.push(a.on(name, fn));
3879
3884
  on("run_start", (ev) => {
3885
+ syncClear();
3880
3886
  // A prompt sent from here was drawn then (awaitingRow); one from a queued follow-up or the host is drawn now; continue() has none.
3881
3887
  if (ev.message) {
3882
3888
  if (awaitingRow && !awaitingRow.msg) {
package/dist/ui.cjs CHANGED
@@ -3381,6 +3381,10 @@ function renderChat(target, opts) {
3381
3381
  clearBtn.type = "button";
3382
3382
  clearBtn.innerHTML = I.eraser() + `<span>${escapeHTML(t.clearChat)}</span>`;
3383
3383
  clearBtn.style.display = "none";
3384
+ let oneChat = false;
3385
+ const syncClear = () => {
3386
+ clearBtn.style.display = oneChat && agent?.messages.length ? "" : "none";
3387
+ };
3384
3388
  const useBtn = h("button", "ra-btn ghost ra-usebtn");
3385
3389
  useBtn.type = "button";
3386
3390
  useBtn.style.display = "none";
@@ -4563,6 +4567,7 @@ function renderChat(target, opts) {
4563
4567
  }
4564
4568
  flush(true);
4565
4569
  if (!messages.length) showEmpty();
4570
+ syncClear();
4566
4571
  list.scrollToBottom();
4567
4572
  };
4568
4573
  let nextSuggestion = null;
@@ -5640,7 +5645,7 @@ ${c.text}` })));
5640
5645
  closeActive();
5641
5646
  }
5642
5647
  await new Promise((r) => setTimeout(r, 0));
5643
- await (clearBtn.style.display === "none" ? newSession().then(() => void 0) : clearConversation());
5648
+ await (oneChat ? clearConversation() : newSession().then(() => void 0));
5644
5649
  const b = agent;
5645
5650
  if (summary) {
5646
5651
  await b.seed(summary);
@@ -5746,7 +5751,7 @@ ${c.text}` })));
5746
5751
  } },
5747
5752
  { name: "new", aliases: ["clear"], run: () => {
5748
5753
  closeMenu();
5749
- return clearBtn.style.display === "none" ? newSession().then(() => void 0) : clearConversation();
5754
+ return oneChat ? clearConversation() : newSession().then(() => void 0);
5750
5755
  } },
5751
5756
  { name: "resume", run: () => openMenu() },
5752
5757
  { name: "compact", args: t.cmdArgs.compact, run: async (focus) => {
@@ -5831,7 +5836,7 @@ ${c.text}` })));
5831
5836
  else ui.notify(t.debugOff);
5832
5837
  } }
5833
5838
  ];
5834
- const builtinCommands = () => builtins.filter((b) => (b.name !== "files" || !!agent?.workspace && filesOpt !== false) && (b.name !== "settings" || hasSettings) && (b.name !== "debug" || debugOn) && (b.name !== "resume" || !givenAgent && !!agent?.workspace && clearBtn.style.display === "none")).map((b) => ({ name: b.name, description: b.name === "new" && clearBtn.style.display !== "none" ? t.confirmClear.split(/[??]/)[0] : t.cmd[b.name] ?? "", kind: t.command, args: b.args, builtin: true }));
5839
+ const builtinCommands = () => builtins.filter((b) => (b.name !== "files" || !!agent?.workspace && filesOpt !== false) && (b.name !== "settings" || hasSettings) && (b.name !== "debug" || debugOn) && (b.name !== "resume" || !givenAgent && !!agent?.workspace && !oneChat)).map((b) => ({ name: b.name, description: b.name === "new" && oneChat ? t.confirmClear.split(/[??]/)[0] : t.cmd[b.name] ?? "", kind: t.command, args: b.args, builtin: true }));
5835
5840
  const runBuiltin = (text) => {
5836
5841
  const m = /^\/(\S+)(?:\s+([\s\S]*))?$/.exec(text);
5837
5842
  if (!m) return false;
@@ -5967,7 +5972,8 @@ ${c.text}` })));
5967
5972
  modelEl.style.display = a.model ? "" : "none";
5968
5973
  const hasSessions = !givenAgent && (sessions ?? !!a.workspace);
5969
5974
  histBtn.style.display = newBtn.style.display = hasSessions && a.workspace ? "" : "none";
5970
- clearBtn.style.display = hasSessions && a.workspace ? "none" : "";
5975
+ oneChat = !(hasSessions && a.workspace);
5976
+ syncClear();
5971
5977
  filesBtn.style.display = a.workspace && filesOpt !== false ? "" : "none";
5972
5978
  skillsBtn.style.display = a.workspace && skillsMenu !== false ? "" : "none";
5973
5979
  panel.setWorkspace(a.workspace);
@@ -5979,6 +5985,7 @@ ${c.text}` })));
5979
5985
  if (!givenAgent) writeLast(project, a.id);
5980
5986
  const on = (name, fn) => unsub.push(a.on(name, fn));
5981
5987
  on("run_start", (ev) => {
5988
+ syncClear();
5982
5989
  if (ev.message) {
5983
5990
  if (awaitingRow && !awaitingRow.msg) {
5984
5991
  awaitingRow.msg = ev.message;
package/docs/chat-ui.md CHANGED
@@ -252,7 +252,7 @@ An app with one conversation per document or project turns the list off:
252
252
  renderChat(el, { provider, workspace: projectWorkspace, sessions: false });
253
253
  ```
254
254
 
255
- The header then has no *Chats* or *New chat*; a **Clear** button (after a confirmation) starts the conversation over — the messages, the queue and the usage go, the conversation keeps its id, the files stay. `/new` and `/clear` do the same, `/resume` is not offered, and `chat.clear()` does it from your code. A chat showing your own `agent` works the same way.
255
+ The header then has no *Chats* or *New chat*; a **Clear** button, shown once there is a conversation to clear, (after a confirmation) starts the conversation over — the messages, the queue and the usage go, the conversation keeps its id, the files stay. `/new` and `/clear` do the same, `/resume` is not offered, and `chat.clear()` does it from your code. A chat showing your own `agent` works the same way.
256
256
 
257
257
  ## Inside your app's layout
258
258
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runappsai/agent",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "description": "Agent harness: the model ↔ tool loop with a workspace, skills, sessions, compaction, a sandbox and a chat UI. Bring any OpenAI-compatible model provider (RunApps included); no runtime dependencies.",
6
6
  "license": "MIT",