@aparte/core 1.1.2 → 1.3.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.
Files changed (38) hide show
  1. package/README.md +3 -2
  2. package/dist/client/aparte-client.d.ts.map +1 -1
  3. package/dist/client/wire-history.d.ts +3 -1
  4. package/dist/client/wire-history.d.ts.map +1 -1
  5. package/dist/components/launcher/aparte-launcher.d.ts +151 -13
  6. package/dist/components/launcher/aparte-launcher.d.ts.map +1 -1
  7. package/dist/components/split/aparte-split.d.ts +26 -0
  8. package/dist/components/split/aparte-split.d.ts.map +1 -1
  9. package/dist/config/aparte-config.d.ts +6 -1
  10. package/dist/config/aparte-config.d.ts.map +1 -1
  11. package/dist/config/icon-provider.d.ts +4 -0
  12. package/dist/config/icon-provider.d.ts.map +1 -1
  13. package/dist/config/locale.d.ts +15 -1
  14. package/dist/config/locale.d.ts.map +1 -1
  15. package/dist/config/sanitize.d.ts +1 -1
  16. package/dist/context/measure.d.ts.map +1 -1
  17. package/dist/custom-elements.json +543 -13
  18. package/dist/{defer-hydration-BBdqAZej.js → defer-hydration-lK-7XQXf.js} +43 -10
  19. package/dist/defer-hydration-lK-7XQXf.js.map +1 -0
  20. package/dist/generated/element-attributes.d.ts +12 -0
  21. package/dist/generated/element-attributes.d.ts.map +1 -1
  22. package/dist/{glyphs-DFp-825O.js → glyphs-LolG04CC.js} +20 -14
  23. package/dist/glyphs-LolG04CC.js.map +1 -0
  24. package/dist/icons/glyphs.d.ts +6 -0
  25. package/dist/icons/glyphs.d.ts.map +1 -1
  26. package/dist/icons.js +17 -15
  27. package/dist/index.css +1 -1
  28. package/dist/index.js +372 -33
  29. package/dist/index.js.map +1 -1
  30. package/dist/index.node.js +1 -1
  31. package/dist/interop/default-on-attributes.d.ts +17 -0
  32. package/dist/interop/default-on-attributes.d.ts.map +1 -0
  33. package/dist/interop/element-props.d.ts.map +1 -1
  34. package/dist/types/segments.d.ts +12 -0
  35. package/dist/types/segments.d.ts.map +1 -1
  36. package/package.json +2 -2
  37. package/dist/defer-hydration-BBdqAZej.js.map +0 -1
  38. package/dist/glyphs-DFp-825O.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { toolRefusal as toolRefusal$1, unansweredTail, runStreamAgent } from "@aparte/engine";
2
- import { A as APARTE_ICON_GLYPHS } from "./glyphs-DFp-825O.js";
2
+ import { A as APARTE_ICON_GLYPHS } from "./glyphs-LolG04CC.js";
3
3
  function contentToText(content) {
4
4
  if (typeof content === "string") return content;
5
5
  return content.filter((p) => p.type === "text").map((p) => p.text).join("");
@@ -189,6 +189,10 @@ const APARTE_DEFAULT_LOCALE = {
189
189
  loading: "Loading…",
190
190
  download: "Download",
191
191
  openArtifact: "Open",
192
+ closeArtifact: "Close",
193
+ artifactVersion: "Version {n} of {total}",
194
+ previousVersion: "Previous version",
195
+ nextVersion: "Next version",
192
196
  modelContextWindow: "{n} context",
193
197
  previewPending: "Press Preview to run this artifact.",
194
198
  sandboxError: "The sandbox failed during generation.",
@@ -254,6 +258,9 @@ const APARTE_DEFAULT_LOCALE = {
254
258
  splitHandleLabel: "Resize the panes",
255
259
  launcherOpen: "Open the chat",
256
260
  launcherClose: "Close the chat",
261
+ launcherHeading: "Chat",
262
+ launcherMaximize: "Expand the chat",
263
+ launcherRestore: "Shrink the chat",
257
264
  transcript: "Transcript"
258
265
  };
259
266
  function isFormatAdapter(p) {
@@ -1807,6 +1814,7 @@ const RESERVED_ATTRIBUTES = /* @__PURE__ */ new Set([
1807
1814
  "data-aparte-theme",
1808
1815
  "data-aparte-split-pane",
1809
1816
  "data-aparte-launcher-close",
1817
+ "data-aparte-launcher-maximize",
1810
1818
  "data-aparte-suggestions",
1811
1819
  "data-aparte-bubble",
1812
1820
  "data-aparte-empty",
@@ -5936,9 +5944,15 @@ class AparteConfig {
5936
5944
  * system message after the app's own ({@link AparteConfig.resolveSystemPrompt | resolveSystemPrompt()});
5937
5945
  * a request you assemble yourself should send them the same way, or the model loses the
5938
5946
  * tools' instructions.
5939
- */
5940
- resolveToolSystemPrompts() {
5941
- const prompts = Array.from(this._tools.values()).map((entry) => entry.tool.systemPrompt?.trim()).filter((prompt) => Boolean(prompt));
5947
+ *
5948
+ * Pass the tools the request actually carries, and only theirs come back: an instruction
5949
+ * to use a tool the model was not given (a model without `function_calling`, a turn sent
5950
+ * with `toolChoice: 'none'`) has it describe a call it cannot make. Without the argument,
5951
+ * every registered tool's.
5952
+ */
5953
+ resolveToolSystemPrompts(tools) {
5954
+ const sent = tools ? new Set(tools.map((tool) => tool.name)) : null;
5955
+ const prompts = Array.from(this._tools.values()).filter((entry) => !sent || sent.has(entry.tool.name)).map((entry) => entry.tool.systemPrompt?.trim()).filter((prompt) => Boolean(prompt));
5942
5956
  return prompts.length ? prompts.join("\n\n") : null;
5943
5957
  }
5944
5958
  /** Get the handler for a tool by name */
@@ -8744,7 +8758,10 @@ ${fence}`);
8744
8758
  } else if (segment.type === "thinking" || segment.type === "tool_call" || segment.type === "error") {
8745
8759
  continue;
8746
8760
  } else if (typeof content === "string" && content) {
8747
- parts.push(content);
8761
+ const wire = segment.wire;
8762
+ const before = wire && typeof wire.before === "string" ? wire.before : "";
8763
+ const after = wire && typeof wire.after === "string" ? wire.after : "";
8764
+ parts.push(`${before}${content}${after}`);
8748
8765
  } else {
8749
8766
  const fallback = segment.fallback;
8750
8767
  if (fallback) parts.push(fallback);
@@ -8833,8 +8850,9 @@ function nextRequestTokens(reply, k) {
8833
8850
  function measureContext(input) {
8834
8851
  const { messages, config } = input;
8835
8852
  const view = historyFromCheckpoint(messages);
8836
- const system = estimateTokens(config.resolveSystemPrompt()) + estimateTokens(config.resolveToolSystemPrompts());
8837
- const declared = toolsForCurrentModel(config).map((t) => ({ name: t.name, description: t.description, inputSchema: t.inputSchema }));
8853
+ const sent = toolsForCurrentModel(config);
8854
+ const system = estimateTokens(config.resolveSystemPrompt()) + estimateTokens(config.resolveToolSystemPrompts(sent));
8855
+ const declared = sent.map((t) => ({ name: t.name, description: t.description, inputSchema: t.inputSchema }));
8838
8856
  const tools = declared.length ? estimateJson(declared) : 0;
8839
8857
  const summary = view.summary === void 0 ? 0 : estimateTokens(underPreamble(view.summary));
8840
8858
  const parts = { system, tools, summary, messages: estimateWireTokens(view.messages) };
@@ -9779,7 +9797,12 @@ class AparteClient {
9779
9797
  built = await this.options.requestInterceptor(built);
9780
9798
  }
9781
9799
  if (built.toolChoice === "none") {
9782
- built = { ...built, tools: void 0 };
9800
+ const toolPrompts = this._config.resolveToolSystemPrompts(registeredTools);
9801
+ built = {
9802
+ ...built,
9803
+ tools: void 0,
9804
+ messages: toolPrompts ? built.messages.filter((m) => !(m.role === "system" && m.content === toolPrompts)) : built.messages
9805
+ };
9783
9806
  }
9784
9807
  return built;
9785
9808
  };
@@ -10016,7 +10039,7 @@ class AparteClient {
10016
10039
  const messages = [];
10017
10040
  const appPrompt = this._config.resolveSystemPrompt();
10018
10041
  if (appPrompt) messages.push({ role: "system", content: appPrompt });
10019
- const toolPrompts = this._config.resolveToolSystemPrompts();
10042
+ const toolPrompts = this._config.resolveToolSystemPrompts(this._toolsForCurrentModel());
10020
10043
  if (toolPrompts) messages.push({ role: "system", content: toolPrompts });
10021
10044
  return messages;
10022
10045
  }
@@ -11162,6 +11185,14 @@ class AparteMessageRepository {
11162
11185
  node.next = null;
11163
11186
  }
11164
11187
  }
11188
+ const APARTE_DEFAULT_ON_ATTRIBUTES = {
11189
+ "aparte-composer-add-attachment": ["multiple"],
11190
+ "aparte-composer": ["submit-on-enter"],
11191
+ "aparte-launcher": ["header"]
11192
+ };
11193
+ function isDefaultOn(el2, name) {
11194
+ return APARTE_DEFAULT_ON_ATTRIBUTES[el2.localName]?.includes(name) === true;
11195
+ }
11165
11196
  const APARTE_DEFAULT_UI_EVENTS = [
11166
11197
  // <aparte-composer> and its parts
11167
11198
  "aparte-send",
@@ -11222,6 +11253,8 @@ function applyElementProps(el2, props, transformValue = (value) => value) {
11222
11253
  else el2.style.setProperty(key, String(value));
11223
11254
  } else if (key.toLowerCase().startsWith("on")) {
11224
11255
  el2.removeAttribute(key);
11256
+ } else if (value === false && isDefaultOn(el2, key)) {
11257
+ el2.setAttribute(key, "false");
11225
11258
  } else if (value === null || value === void 0 || value === false) {
11226
11259
  el2.removeAttribute(key);
11227
11260
  } else if (typeof value === "number" && Number.isNaN(value)) {
@@ -11516,4 +11549,4 @@ export {
11516
11549
  collectRendererStyles as y,
11517
11550
  contentToText as z
11518
11551
  };
11519
- //# sourceMappingURL=defer-hydration-BBdqAZej.js.map
11552
+ //# sourceMappingURL=defer-hydration-lK-7XQXf.js.map