@ai-ecoverse/slicc-spectrum 1.12.0 → 1.13.0

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/slicc-ui.js CHANGED
@@ -7781,10 +7781,10 @@ function render(entry) {
7781
7781
  return entry.ordered ? b`<ol>${items}</ol>` : b`<ul>${items}</ul>`;
7782
7782
  }
7783
7783
  case "table": {
7784
- const [head2, ...body3] = entry.rows;
7784
+ const [head2, ...body4] = entry.rows;
7785
7785
  return b`<div class="table"><table>
7786
7786
  <thead><tr>${head2.map((cell) => b`<th>${inline(cell)}</th>`)}</tr></thead>
7787
- <tbody>${body3.map((row) => b`<tr>${row.map((cell) => b`<td>${inline(cell)}</td>`)}</tr>`)}</tbody>
7787
+ <tbody>${body4.map((row) => b`<tr>${row.map((cell) => b`<td>${inline(cell)}</td>`)}</tr>`)}</tbody>
7788
7788
  </table></div>`;
7789
7789
  }
7790
7790
  case "quote":
@@ -7843,21 +7843,28 @@ function size(bytes) {
7843
7843
  if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;
7844
7844
  return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
7845
7845
  }
7846
- function tool(call) {
7846
+ function body(call, color) {
7847
+ if (call.diff) {
7848
+ return b`<slicc-diff-view class="input" path=${call.paths[0] ?? call.title} color=${color} .oldText=${call.diff.before} .newText=${call.diff.after}></slicc-diff-view>`;
7849
+ }
7850
+ return b`<pre class="input">${call.name === "bash" ? `$ ${call.input}` : call.input}</pre>`;
7851
+ }
7852
+ function tool(call, color = "light") {
7847
7853
  const state = call.status === "running" ? b`<sp-progress-circle size="s" indeterminate label="Running"></sp-progress-circle>` : b`<span class="state">${toolStates[call.status]}</span>`;
7848
7854
  return b`<details class="tool" data-status=${call.status} data-tool=${call.name}>
7849
7855
  <summary>
7850
7856
  <span class="chevron" aria-hidden="true">▸</span>
7851
7857
  <span class="name">${call.name}</span>
7852
7858
  <span class="title">${call.title}</span>
7859
+ ${call.meta ? b`<span class="tool-meta">${call.meta}</span>` : A}
7853
7860
  ${state}
7854
7861
  </summary>
7855
- <pre class="input">${call.name === "bash" ? `$ ${call.input}` : call.input}</pre>
7862
+ ${body(call, color)}
7856
7863
  ${call.output ? b`<pre class="output">${call.output}</pre>` : A}
7857
7864
  ${call.image ? b`<img class="shot" src=${call.image} alt=${call.title} />` : A}
7858
7865
  </details>`;
7859
7866
  }
7860
- function cluster(calls, open) {
7867
+ function cluster(calls, open, color) {
7861
7868
  const failed = calls.filter((call) => call.status === "error").length;
7862
7869
  const running = calls.some((call) => call.status === "running");
7863
7870
  return b`<details class="cluster" ?open=${open || running}>
@@ -7867,7 +7874,7 @@ function cluster(calls, open) {
7867
7874
  <span class="names">${[...new Set(calls.map((call) => call.name))].join(" \xB7 ")}</span>
7868
7875
  ${failed ? b`<span class="state failed">${failed} failed</span>` : A}
7869
7876
  </summary>
7870
- ${calls.map(tool)}
7877
+ ${calls.map((call) => tool(call, color))}
7871
7878
  </details>`;
7872
7879
  }
7873
7880
  function media(items) {
@@ -7907,14 +7914,14 @@ function check(items) {
7907
7914
  }
7908
7915
  function question(item2, handlers) {
7909
7916
  const answer = (value) => handlers.answer(item2.id, value);
7910
- let body3;
7917
+ let body4;
7911
7918
  if (item2.state === "answered") {
7912
- body3 = b`<div class="answer">✓ ${item2.answer}</div>`;
7919
+ body4 = b`<div class="answer">✓ ${item2.answer}</div>`;
7913
7920
  } else if (item2.state === "inert") {
7914
- body3 = b`<div class="hint">Only the latest question can be answered here.</div>`;
7921
+ body4 = b`<div class="hint">Only the latest question can be answered here.</div>`;
7915
7922
  } else if (item2.kind === "yes-no" || item2.kind === "choice") {
7916
7923
  const options = item2.kind === "yes-no" ? ["Yes", "No"] : item2.options;
7917
- body3 = b`<div class="options">${options.map(
7924
+ body4 = b`<div class="options">${options.map(
7918
7925
  (option2) => b`<sp-button size="s" variant="secondary" treatment="outline" @click=${() => answer(option2)}>${option2}</sp-button>`
7919
7926
  )}</div>`;
7920
7927
  } else {
@@ -7923,14 +7930,14 @@ function question(item2, handlers) {
7923
7930
  const field = event.currentTarget.querySelector("input");
7924
7931
  if (field.value.trim()) answer(field.value.trim());
7925
7932
  };
7926
- body3 = b`<form class="options" @submit=${submit}>
7933
+ body4 = b`<form class="options" @submit=${submit}>
7927
7934
  <input class="input" type=${item2.kind === "email" ? "email" : item2.kind === "number" ? "number" : item2.kind === "date" ? "date" : "text"} aria-label=${item2.question} />
7928
7935
  <sp-button size="s" variant="accent" @click=${(event) => event.currentTarget.closest("form")?.requestSubmit()}>Answer</sp-button>
7929
7936
  </form>`;
7930
7937
  }
7931
7938
  return b`<div class="question" data-state=${item2.state} data-kind=${item2.kind}>
7932
7939
  <div class="q">${item2.question}</div>
7933
- ${body3}
7940
+ ${body4}
7934
7941
  </div>`;
7935
7942
  }
7936
7943
  var delegationVerbs = {
@@ -7946,7 +7953,7 @@ function part(entry, handlers, showThinking) {
7946
7953
  case "thinking":
7947
7954
  return showThinking ? b`<div class="thinking">${entry.text}</div>` : A;
7948
7955
  case "tool":
7949
- return tool(entry.tool);
7956
+ return tool(entry.tool, handlers.color);
7950
7957
  case "media":
7951
7958
  return media(entry.items);
7952
7959
  case "card":
@@ -7985,7 +7992,7 @@ function parts(entries, handlers, showThinking, streaming) {
7985
7992
  while (end < entries.length && entries[end].type === "tool") end++;
7986
7993
  if (end - i10 >= 3) {
7987
7994
  const calls = entries.slice(i10, end).map((entry) => entry.tool);
7988
- out.push(cluster(calls, streaming && end === entries.length));
7995
+ out.push(cluster(calls, streaming && end === entries.length, handlers.color));
7989
7996
  i10 = end;
7990
7997
  } else {
7991
7998
  out.push(part(entries[i10], handlers, showThinking));
@@ -8036,10 +8043,10 @@ function assistant(message, name, model, handlers, showThinking) {
8036
8043
  ${message.status === "streaming" ? b`<span class="caret" aria-hidden="true"></span>` : A}
8037
8044
  </article>`;
8038
8045
  }
8039
- function toolMessage(message) {
8046
+ function toolMessage(message, color = "light") {
8040
8047
  return b`<article class="message tool-message" data-id=${message.id}>
8041
8048
  <div class="meta"><span class="who">Tool</span><span>${time(message.createdAt)}</span></div>
8042
- ${tool(message.tool)}
8049
+ ${tool(message.tool, color)}
8043
8050
  </article>`;
8044
8051
  }
8045
8052
  function system(message, handlers) {
@@ -8332,6 +8339,17 @@ var messageCss = i`
8332
8339
  .state.failed {
8333
8340
  color: var(--spectrum-negative-visual-color);
8334
8341
  }
8342
+ .tool-meta {
8343
+ flex: none;
8344
+ color: var(--spectrum-neutral-subdued-content-color-default);
8345
+ font-size: var(--spectrum-font-size-50);
8346
+ }
8347
+ .tool > slicc-diff-view {
8348
+ display: block;
8349
+ margin: 0 8px 8px;
8350
+ max-height: 240px;
8351
+ overflow: auto;
8352
+ }
8335
8353
  .tool pre,
8336
8354
  .lick pre {
8337
8355
  margin: 0 8px 8px;
@@ -8793,7 +8811,7 @@ var SliccChat = class extends ThemedElement {
8793
8811
  case "user":
8794
8812
  return user(message);
8795
8813
  case "tool":
8796
- return toolMessage(message);
8814
+ return toolMessage(message, this.#handlers.color);
8797
8815
  case "system":
8798
8816
  return system(message, this.#handlers);
8799
8817
  default:
@@ -19048,7 +19066,7 @@ function omission(handlers) {
19048
19066
 
19049
19067
  // node_modules/hast-util-to-html/lib/omission/closing.js
19050
19068
  var closing = omission({
19051
- body,
19069
+ body: body2,
19052
19070
  caption: headOrColgroupOrCaption,
19053
19071
  colgroup: headOrColgroupOrCaption,
19054
19072
  dd,
@@ -19076,7 +19094,7 @@ function html3(_6, index, parent) {
19076
19094
  const next = siblingAfter(parent, index);
19077
19095
  return !next || next.type !== "comment";
19078
19096
  }
19079
- function body(_6, index, parent) {
19097
+ function body2(_6, index, parent) {
19080
19098
  const next = siblingAfter(parent, index);
19081
19099
  return !next || next.type !== "comment";
19082
19100
  }
@@ -19135,7 +19153,7 @@ function cells2(_6, index, parent) {
19135
19153
 
19136
19154
  // node_modules/hast-util-to-html/lib/omission/opening.js
19137
19155
  var opening = omission({
19138
- body: body2,
19156
+ body: body3,
19139
19157
  colgroup,
19140
19158
  head,
19141
19159
  html: html4,
@@ -19156,7 +19174,7 @@ function head(node) {
19156
19174
  const child = node.children[0];
19157
19175
  return !child || child.type === "element";
19158
19176
  }
19159
- function body2(node) {
19177
+ function body3(node) {
19160
19178
  const head2 = siblingAfter(node, -1, true);
19161
19179
  return !head2 || head2.type !== "comment" && !(head2.type === "text" && whitespace(head2.value.charAt(0))) && !(head2.type === "element" && (head2.tagName === "meta" || head2.tagName === "link" || head2.tagName === "script" || head2.tagName === "style" || head2.tagName === "template"));
19162
19180
  }
@@ -22244,12 +22262,12 @@ function transform(ast, options) {
22244
22262
  }
22245
22263
  var FirstPassVisitor = {
22246
22264
  AbsenceFunction({ node, parent, replaceWith }) {
22247
- const { body: body3, kind } = node;
22265
+ const { body: body4, kind } = node;
22248
22266
  if (kind === "repeater") {
22249
22267
  const innerGroup = A4();
22250
22268
  innerGroup.body[0].body.push(
22251
22269
  // Insert own alts as `body`
22252
- K2({ negate: true, body: body3 }),
22270
+ K2({ negate: true, body: body4 }),
22253
22271
  Q2("Any")
22254
22272
  );
22255
22273
  const outerGroup = A4();
@@ -22834,8 +22852,8 @@ function getKids(node) {
22834
22852
  if (!node) {
22835
22853
  throw new Error("Node expected");
22836
22854
  }
22837
- const { body: body3 } = node;
22838
- return Array.isArray(body3) ? body3 : body3 ? [body3] : null;
22855
+ const { body: body4 } = node;
22856
+ return Array.isArray(body4) ? body4 : body4 ? [body4] : null;
22839
22857
  }
22840
22858
  function getLeadingG(els) {
22841
22859
  const firstToConsider = els.find((el) => el.kind === "search_start" || isLoneGLookaround(el, { negate: false }) || !isAlwaysZeroLength(el));
@@ -23044,8 +23062,8 @@ var generator = {
23044
23062
  /**
23045
23063
  @param {AlternativeNode} node
23046
23064
  */
23047
- Alternative({ body: body3 }, _6, gen) {
23048
- return body3.map(gen).join("");
23065
+ Alternative({ body: body4 }, _6, gen) {
23066
+ return body4.map(gen).join("");
23049
23067
  },
23050
23068
  /**
23051
23069
  @param {AssertionNode} node
@@ -23078,7 +23096,7 @@ var generator = {
23078
23096
  @param {CapturingGroupNode} node
23079
23097
  */
23080
23098
  CapturingGroup(node, state, gen) {
23081
- const { body: body3, name, number: number2 } = node;
23099
+ const { body: body4, name, number: number2 } = node;
23082
23100
  const data = { ignoreCase: state.currentFlags.ignoreCase };
23083
23101
  const origin = state.originMap.get(node);
23084
23102
  if (origin) {
@@ -23088,7 +23106,7 @@ var generator = {
23088
23106
  }
23089
23107
  }
23090
23108
  state.captureMap.set(number2, data);
23091
- return `(${name ? `?<${name}>` : ""}${body3.map(gen).join("|")})`;
23109
+ return `(${name ? `?<${name}>` : ""}${body4.map(gen).join("|")})`;
23092
23110
  },
23093
23111
  /**
23094
23112
  @param {CharacterNode} node
@@ -23114,20 +23132,20 @@ var generator = {
23114
23132
  */
23115
23133
  CharacterClass(node, state, gen) {
23116
23134
  const { kind, negate, parent } = node;
23117
- let { body: body3 } = node;
23135
+ let { body: body4 } = node;
23118
23136
  if (kind === "intersection" && !state.useFlagV) {
23119
23137
  throw new Error("Use of character class intersection requires min target ES2024");
23120
23138
  }
23121
- if (envFlags.bugFlagVLiteralHyphenIsRange && state.useFlagV && body3.some(isLiteralHyphen)) {
23122
- body3 = [m4(45), ...body3.filter((kid) => !isLiteralHyphen(kid))];
23139
+ if (envFlags.bugFlagVLiteralHyphenIsRange && state.useFlagV && body4.some(isLiteralHyphen)) {
23140
+ body4 = [m4(45), ...body4.filter((kid) => !isLiteralHyphen(kid))];
23123
23141
  }
23124
- const genClass = () => `[${negate ? "^" : ""}${body3.map(gen).join(kind === "intersection" ? "&&" : "")}]`;
23142
+ const genClass = () => `[${negate ? "^" : ""}${body4.map(gen).join(kind === "intersection" ? "&&" : "")}]`;
23125
23143
  if (!state.inCharClass) {
23126
23144
  if (
23127
23145
  // Already established `kind !== 'intersection'` if `!state.useFlagV`; don't check again
23128
23146
  (!state.useFlagV || envFlags.bugNestedClassIgnoresNegation) && !negate
23129
23147
  ) {
23130
- const negatedChildClasses = body3.filter(
23148
+ const negatedChildClasses = body4.filter(
23131
23149
  (kid) => kid.type === "CharacterClass" && kid.kind === "union" && kid.negate
23132
23150
  );
23133
23151
  if (negatedChildClasses.length) {
@@ -23135,9 +23153,9 @@ var generator = {
23135
23153
  const groupFirstAlt = group.body[0];
23136
23154
  group.parent = parent;
23137
23155
  groupFirstAlt.parent = group;
23138
- body3 = body3.filter((kid) => !negatedChildClasses.includes(kid));
23139
- node.body = body3;
23140
- if (body3.length) {
23156
+ body4 = body4.filter((kid) => !negatedChildClasses.includes(kid));
23157
+ node.body = body4;
23158
+ if (body4.length) {
23141
23159
  node.parent = groupFirstAlt;
23142
23160
  groupFirstAlt.body.push(node);
23143
23161
  } else {
@@ -23157,14 +23175,14 @@ var generator = {
23157
23175
  state.inCharClass = false;
23158
23176
  return result;
23159
23177
  }
23160
- const firstEl = body3[0];
23178
+ const firstEl = body4[0];
23161
23179
  if (
23162
23180
  // Already established that the parent is a char class via `inCharClass`; don't check again
23163
23181
  kind === "union" && !negate && firstEl && // Allows many nested classes to work with `target` ES2018 which doesn't support nesting
23164
23182
  ((!state.useFlagV || !state.verbose) && parent.kind === "union" && !(envFlags.bugFlagVLiteralHyphenIsRange && state.useFlagV) || !state.verbose && parent.kind === "intersection" && // JS doesn't allow intersection with union or ranges
23165
- body3.length === 1 && firstEl.type !== "CharacterClassRange")
23183
+ body4.length === 1 && firstEl.type !== "CharacterClassRange")
23166
23184
  ) {
23167
- return body3.map(gen).join("");
23185
+ return body4.map(gen).join("");
23168
23186
  }
23169
23187
  if (!state.useFlagV && parent.type === "CharacterClass") {
23170
23188
  throw new Error("Uses nested character class in a way that requires min target ES2024");
@@ -23236,13 +23254,13 @@ var generator = {
23236
23254
  /**
23237
23255
  @param {GroupNode} node
23238
23256
  */
23239
- Group({ atomic: atomic2, body: body3, flags, parent }, state, gen) {
23257
+ Group({ atomic: atomic2, body: body4, flags, parent }, state, gen) {
23240
23258
  const currentFlags = state.currentFlags;
23241
23259
  if (flags) {
23242
23260
  state.currentFlags = getNewCurrentFlags(currentFlags, flags);
23243
23261
  }
23244
- const contents = body3.map(gen).join("|");
23245
- const result = !state.verbose && body3.length === 1 && // Single alt
23262
+ const contents = body4.map(gen).join("|");
23263
+ const result = !state.verbose && body4.length === 1 && // Single alt
23246
23264
  parent.type !== "Quantifier" && !atomic2 && (!state.useFlagMods || !flags) ? contents : `(?${getGroupPrefix(atomic2, flags, state.useFlagMods)}${contents})`;
23247
23265
  state.currentFlags = currentFlags;
23248
23266
  return result;
@@ -23250,9 +23268,9 @@ var generator = {
23250
23268
  /**
23251
23269
  @param {LookaroundAssertionNode} node
23252
23270
  */
23253
- LookaroundAssertion({ body: body3, kind, negate }, _6, gen) {
23271
+ LookaroundAssertion({ body: body4, kind, negate }, _6, gen) {
23254
23272
  const prefix = `${kind === "lookahead" ? "" : "<"}${negate ? "!" : "="}`;
23255
- return `(?${prefix}${body3.map(gen).join("|")})`;
23273
+ return `(?${prefix}${body4.map(gen).join("|")})`;
23256
23274
  },
23257
23275
  /**
23258
23276
  @param {QuantifierNode} node
@@ -44910,8 +44928,8 @@ var TabsContainer = class extends CompositeDisposable {
44910
44928
  }
44911
44929
  };
44912
44930
  },
44913
- open: (body3) => {
44914
- popup().openPopover(body3, anchor);
44931
+ open: (body4) => {
44932
+ popup().openPopover(body4, anchor);
44915
44933
  },
44916
44934
  close: () => popup().close(),
44917
44935
  focusTrigger: () => {