@aibranch/llm-meta-widget 0.11.0 → 0.11.1

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/README.md CHANGED
@@ -61,7 +61,7 @@ Option 3 if it does not.
61
61
 
62
62
  ```ruby
63
63
  # Gemfile
64
- gem "llm_meta_widget", "~> 0.11.0"
64
+ gem "llm_meta_widget", "~> 0.11.1"
65
65
  ```
66
66
 
67
67
  ```bash
@@ -3963,6 +3963,12 @@ function boot(cfg) {
3963
3963
  model: MODEL
3964
3964
  });
3965
3965
  }
3966
+ var lastPersist = 0;
3967
+ function persistSoon() {
3968
+ if (Date.now() - lastPersist < 400) return;
3969
+ lastPersist = Date.now();
3970
+ persistConversation();
3971
+ }
3966
3972
  var typedCards = document.querySelectorAll('script[type="' + PAGE_CARD_MEDIA_TYPE + '"]');
3967
3973
  var pageCard;
3968
3974
  if (typedCards.length) {
@@ -4625,6 +4631,10 @@ function boot(cfg) {
4625
4631
  var messages = [{ role: "system", content: currentSystemPrompt(resourceLines) }].concat(conversation.map(function(t) {
4626
4632
  return { role: t.role, content: t.content };
4627
4633
  })).concat([{ role: "user", content: userText }]);
4634
+ conversation.push({ role: "user", content: userText });
4635
+ var liveTurn = { role: "assistant", content: "", tools: [] };
4636
+ conversation.push(liveTurn);
4637
+ persistConversation();
4628
4638
  var result = await runChatLoop({
4629
4639
  baseUrl: LLM_BASE,
4630
4640
  toolHubUrl: TOOL_HUB_BASE,
@@ -4640,9 +4650,12 @@ function boot(cfg) {
4640
4650
  signal: currentAbort.signal,
4641
4651
  onToolCall: function(toolCall) {
4642
4652
  announceToolCall(toolCall);
4653
+ persistConversation();
4643
4654
  },
4644
4655
  onToolDispatched: function(outcome) {
4645
4656
  resolveToolCall(outcome);
4657
+ liveTurn.tools = liveTurn.tools.concat([outcome.error ? { name: outcome.toolCall.name, error: true } : { name: outcome.toolCall.name }]);
4658
+ persistConversation();
4646
4659
  },
4647
4660
  onPhase: function(name) {
4648
4661
  if (name === "responding") markDone(assistantBody.roleLabel);
@@ -4663,18 +4676,14 @@ function boot(cfg) {
4663
4676
  collapseThinkingBlock();
4664
4677
  assistantMarkdown += delta;
4665
4678
  renderMarkdownInto(assistantBody, assistantMarkdown);
4679
+ liveTurn.content = assistantMarkdown;
4680
+ persistSoon();
4666
4681
  historyEl.scrollTop = historyEl.scrollHeight;
4667
4682
  }
4668
4683
  });
4669
- conversation.push({ role: "user", content: userText });
4670
- conversation.push({
4671
- role: "assistant",
4672
- content: result.content,
4673
- // Kept so a restored transcript still shows what ran — losing
4674
- // that record is what made a navigating action unbearable.
4675
- tools: result.dispatched.map(function(d) {
4676
- return d.error ? { name: d.toolCall.name, error: true } : { name: d.toolCall.name };
4677
- })
4684
+ liveTurn.content = result.content;
4685
+ liveTurn.tools = result.dispatched.map(function(d) {
4686
+ return d.error ? { name: d.toolCall.name, error: true } : { name: d.toolCall.name };
4678
4687
  });
4679
4688
  persistConversation();
4680
4689
  result.dispatched.forEach(function(d) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aibranch/llm-meta-widget",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "//version": "Must stay in step with lib/llm_meta_widget/version.rb. Two independently versioned copies of the same client is the drift docs/custom-element-distribution.md warns about: bump both, release both.",
5
5
  "description": "Embeddable browser chat widget: a custom element that discovers tools at page, origin and hub scope and dispatches each tool call to the right one. Two lines of HTML on any host, Rails or not.",
6
6
  "keywords": [