@saltcorn/agents 0.8.10 → 0.8.11
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/agent-view.js +83 -3
- package/package.json +1 -1
package/agent-view.js
CHANGED
|
@@ -708,9 +708,43 @@ const run = async (
|
|
|
708
708
|
stream ? div({ class: "next_response_scratch" }) : "",
|
|
709
709
|
hasInputForm && input_form,
|
|
710
710
|
style(agents_css),
|
|
711
|
-
script(
|
|
711
|
+
script(
|
|
712
|
+
domReady(`
|
|
713
|
+
$("#inputuserinput" ).autogrow({paddingBottom: 20});
|
|
714
|
+
ensure_script_loaded("/static_assets/"+_sc_version_tag+"/mermaid.min.js", ()=>{
|
|
715
|
+
mermaid.initialize({ startOnLoad: false });
|
|
716
|
+
activate_mermaid()
|
|
717
|
+
})`),
|
|
718
|
+
),
|
|
712
719
|
script(
|
|
713
720
|
`
|
|
721
|
+
function activate_mermaid() {
|
|
722
|
+
const mermaids = document.querySelectorAll('code.language-mermaid:not([data-processed])')
|
|
723
|
+
if(mermaids.length) {
|
|
724
|
+
|
|
725
|
+
const el0 =document.querySelector('code.language-mermaid:not([data-processed])')
|
|
726
|
+
const parent = el0.closest("div.copy-to-clipboard-elem")
|
|
727
|
+
if(!parent) return;
|
|
728
|
+
parent.setAttribute("data-copy-text", parent.innerText)
|
|
729
|
+
|
|
730
|
+
let processed = false
|
|
731
|
+
parent.querySelectorAll('code.language-mermaid:not([data-processed])').forEach(async (el) => {
|
|
732
|
+
try {
|
|
733
|
+
// parse() throws if the syntax is invalid
|
|
734
|
+
await mermaid.parse(el.textContent);
|
|
735
|
+
|
|
736
|
+
// Valid — safe to render
|
|
737
|
+
// mermaid.run() works on a live NodeList, so target this element directly
|
|
738
|
+
mermaid.run({ nodes: [el] });
|
|
739
|
+
processed = true
|
|
740
|
+
} catch (e) {
|
|
741
|
+
// Invalid — leave the <code> block completely untouched
|
|
742
|
+
console.warn('Mermaid syntax error (diagram left as-is):', e.message);
|
|
743
|
+
}
|
|
744
|
+
})
|
|
745
|
+
if(processed) activate_mermaid()
|
|
746
|
+
}
|
|
747
|
+
}
|
|
714
748
|
function scrollAgentToBottom() {
|
|
715
749
|
const container = document.getElementById('copilotinteractions');
|
|
716
750
|
if (!container) return;
|
|
@@ -778,6 +812,7 @@ const run = async (
|
|
|
778
812
|
$("#copilotinteractions").append(res.response);
|
|
779
813
|
scrollAgentToBottom();
|
|
780
814
|
}
|
|
815
|
+
activate_mermaid()
|
|
781
816
|
}
|
|
782
817
|
window.processCopilotResponse = processCopilotResponse;
|
|
783
818
|
window.final_agent_response = () => {
|
|
@@ -948,7 +983,7 @@ const run = async (
|
|
|
948
983
|
e.preventDefault();
|
|
949
984
|
|
|
950
985
|
try {
|
|
951
|
-
await navigator.clipboard.writeText(target.innerText);
|
|
986
|
+
await navigator.clipboard.writeText(target.getAttribute("data-copy-text") || target.innerText);
|
|
952
987
|
target.classList.add('copy-success');
|
|
953
988
|
setTimeout(() => target.classList.remove('copy-success'), 1000);
|
|
954
989
|
} catch (err) {
|
|
@@ -1486,6 +1521,7 @@ const debug_info = async (table_id, viewname, config, body, { req, res }) => {
|
|
|
1486
1521
|
sysPrompt = complArgs.systemPrompt;
|
|
1487
1522
|
}
|
|
1488
1523
|
const apiJson = JSON.stringify(run.context.api_interactions, null, 2);
|
|
1524
|
+
const msgJson = JSON.stringify(run.context.interactions, null, 2);
|
|
1489
1525
|
const debug_html = div(
|
|
1490
1526
|
{ class: "accordion", id: "debugAccordion" },
|
|
1491
1527
|
div(
|
|
@@ -1517,6 +1553,50 @@ const debug_info = async (table_id, viewname, config, body, { req, res }) => {
|
|
|
1517
1553
|
),
|
|
1518
1554
|
),
|
|
1519
1555
|
),
|
|
1556
|
+
div(
|
|
1557
|
+
{ class: "accordion-item" },
|
|
1558
|
+
h2(
|
|
1559
|
+
{ class: "accordion-header", id: "debugHeadMessages" },
|
|
1560
|
+
button(
|
|
1561
|
+
{
|
|
1562
|
+
class: "accordion-button",
|
|
1563
|
+
type: "button",
|
|
1564
|
+
"data-bs-toggle": "collapse",
|
|
1565
|
+
"data-bs-target": "#debugCollapseMessages",
|
|
1566
|
+
"aria-expanded": "true",
|
|
1567
|
+
"aria-controls": "debugCollapseMessages",
|
|
1568
|
+
},
|
|
1569
|
+
"Messages",
|
|
1570
|
+
),
|
|
1571
|
+
),
|
|
1572
|
+
div(
|
|
1573
|
+
{
|
|
1574
|
+
id: "debugCollapseMessages",
|
|
1575
|
+
class: "accordion-collapse collapse show",
|
|
1576
|
+
"aria-labelledby": "debugHeadMessages",
|
|
1577
|
+
"data-bs-parent": "#debugAccordion",
|
|
1578
|
+
},
|
|
1579
|
+
div(
|
|
1580
|
+
{ class: "accordion-body" },
|
|
1581
|
+
button(
|
|
1582
|
+
{
|
|
1583
|
+
class: "btn btn-sm btn-outline-secondary mb-2",
|
|
1584
|
+
onclick: `
|
|
1585
|
+
var t=document.getElementById('debugMessagesPre').textContent;
|
|
1586
|
+
navigator.clipboard.writeText(t).then(function(){
|
|
1587
|
+
var b=event.target;b.textContent='Copied!';
|
|
1588
|
+
setTimeout(function(){b.textContent='Copy to clipboard'},1500)
|
|
1589
|
+
})`,
|
|
1590
|
+
},
|
|
1591
|
+
"Copy to clipboard",
|
|
1592
|
+
),
|
|
1593
|
+
pre(
|
|
1594
|
+
{ id: "debugMessagesPre", style: "white-space:pre-wrap" },
|
|
1595
|
+
text(escapeHtml(msgJson)),
|
|
1596
|
+
),
|
|
1597
|
+
),
|
|
1598
|
+
),
|
|
1599
|
+
),
|
|
1520
1600
|
div(
|
|
1521
1601
|
{ class: "accordion-item" },
|
|
1522
1602
|
h2(
|
|
@@ -1527,7 +1607,7 @@ const debug_info = async (table_id, viewname, config, body, { req, res }) => {
|
|
|
1527
1607
|
type: "button",
|
|
1528
1608
|
"data-bs-toggle": "collapse",
|
|
1529
1609
|
"data-bs-target": "#debugCollapseAPI",
|
|
1530
|
-
"aria-expanded": "
|
|
1610
|
+
"aria-expanded": "false",
|
|
1531
1611
|
"aria-controls": "debugCollapseAPI",
|
|
1532
1612
|
},
|
|
1533
1613
|
"API interactions",
|