@talonic/mcp 0.1.99 → 0.1.101

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/index.js CHANGED
@@ -497,24 +497,34 @@ function widgetMeta(description) {
497
497
  return meta;
498
498
  }
499
499
  var BASE_CSS = `
500
+ /* Ink tokens (platform ink/restructure, src/app/globals.css --void-*). */
500
501
  :root {
501
- --bg: #ffffff; --fg: #111827; --muted: #6b7280; --border: #e5e7eb;
502
- --accent: #4f46e5; --good: #16a34a; --warn: #d97706; --bad: #dc2626;
503
- --chip: #f3f4f6;
502
+ --bg: #FFFFFF; --fg: #1B1B1F; --muted: #5B5B64; --faint: #6A6A71;
503
+ --border: rgba(20, 20, 30, 0.12); --divider: rgba(20, 20, 30, 0.07);
504
+ --accent: #512DA8; --accent-dim: rgba(81, 45, 168, 0.07); --accent-tint: #EEE8F8;
505
+ --good: #1F9D5B; --warn: #B97E14; --bad: #C94343;
506
+ --chip: #F5F5F3; --surface-2: #F5F5F3;
504
507
  }
505
508
  @media (prefers-color-scheme: dark) {
506
509
  :root:not([data-theme="light"]) {
507
- --bg: #0f1115; --fg: #f3f4f6; --muted: #9ca3af; --border: #1f2937;
508
- --chip: #1f2937;
510
+ --bg: #101013; --fg: #EDEDEF; --muted: #A2A2AB; --faint: #86868E;
511
+ --border: rgba(255, 255, 255, 0.08); --divider: rgba(255, 255, 255, 0.06);
512
+ --accent: #C9B6F5; --accent-dim: rgba(201, 182, 245, 0.10); --accent-tint: #2A1F3D;
513
+ --good: #5BC98B; --warn: #E8B45A; --bad: #E36D6D;
514
+ --chip: #1A1A1F; --surface-2: #16161A;
509
515
  }
510
516
  }
511
517
  :root[data-theme="dark"] {
512
- --bg: #0f1115; --fg: #f3f4f6; --muted: #9ca3af; --border: #1f2937;
513
- --chip: #1f2937;
518
+ --bg: #101013; --fg: #EDEDEF; --muted: #A2A2AB; --faint: #86868E;
519
+ --border: rgba(255, 255, 255, 0.08); --divider: rgba(255, 255, 255, 0.06);
520
+ --accent: #C9B6F5; --accent-dim: rgba(201, 182, 245, 0.10); --accent-tint: #2A1F3D;
521
+ --good: #5BC98B; --warn: #E8B45A; --bad: #E36D6D;
522
+ --chip: #1A1A1F; --surface-2: #16161A;
514
523
  }
515
524
  :root[data-host="mcp-apps"] { --bg: transparent; }
516
525
  html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg);
517
- font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, sans-serif; }
526
+ font: 14px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
527
+ -webkit-font-smoothing: antialiased; }
518
528
  .root { padding: 20px; box-sizing: border-box; }
519
529
  * { box-sizing: border-box; }
520
530
  .empty { color: var(--muted); padding: 28px; text-align: center; }
@@ -522,10 +532,26 @@ var BASE_CSS = `
522
532
  .small { font-size: 12px; }
523
533
  .header { display: flex; align-items: flex-start; justify-content: space-between;
524
534
  gap: 12px; margin-bottom: 16px; }
525
- .title { font-weight: 600; }
526
- .subtitle { color: var(--muted); font-size: 12px; }
535
+ .title { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
536
+ .subtitle { color: var(--faint); font-size: 12px; }
537
+ .eyebrow { color: var(--faint); font-size: 12px; font-weight: 500; margin-bottom: 2px; }
538
+ .prose { font-size: 14.5px; line-height: 1.6; color: var(--fg); }
539
+ .prose p { margin: 0 0 10px; }
540
+ .prose p:last-child, .prose ul:last-child, .prose ol:last-child { margin-bottom: 0; }
541
+ .prose ul, .prose ol { margin: 0 0 10px; padding-left: 20px; }
542
+ .prose li { margin: 3px 0; }
543
+ .prose h3, .prose h4 { font-size: 14.5px; font-weight: 600; margin: 14px 0 6px; }
544
+ .prose code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--chip);
545
+ border: 1px solid var(--divider); border-radius: 4px; padding: 0 4px; }
546
+ .prose strong { font-weight: 600; }
547
+ .prose a { color: var(--accent); text-decoration: none; }
548
+ .prose a:hover { text-decoration: underline; }
549
+ .prose table { margin: 6px 0 12px; }
550
+ .section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--divider); }
551
+ .section-label { color: var(--faint); font-size: 12px; font-weight: 500; margin-bottom: 8px; }
552
+ .meta { color: var(--faint); font-size: 12px; margin-top: 14px; }
527
553
  table { width: 100%; border-collapse: collapse; margin-top: 8px; }
528
- th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border);
554
+ th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--divider);
529
555
  vertical-align: top; font-size: 13px; }
530
556
  th { color: var(--muted); font-weight: 500; font-size: 12px; }
531
557
  th:first-child, td:first-child { padding-left: 0; }
@@ -543,15 +569,18 @@ var BASE_CSS = `
543
569
  border-radius: 6px; padding: 6px 10px; font: inherit; cursor: pointer;
544
570
  text-decoration: none; display: inline-block; }
545
571
  button:hover, a.btn:hover { border-color: var(--accent); }
546
- a.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
547
- .chip { display: inline-block; background: var(--chip); border-radius: 999px;
548
- padding: 1px 8px; font-size: 12px; margin: 2px 4px 2px 0; }
572
+ a.btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
573
+ :root[data-host="mcp-apps"] a.btn.primary { color: #fff; }
574
+ @media (prefers-color-scheme: dark) { :root[data-host="mcp-apps"]:not([data-theme="light"]) a.btn.primary { color: #17102A; } }
575
+ :root[data-host="mcp-apps"][data-theme="dark"] a.btn.primary { color: #17102A; }
576
+ .chip { display: inline-block; background: var(--chip); border-radius: 6px; color: var(--muted);
577
+ padding: 1px 7px; font-size: 12px; font-weight: 500; margin: 2px 4px 2px 0; }
549
578
  .big { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
550
579
  .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
551
580
  gap: 10px; margin-top: 14px; }
552
581
  /* Stat tile: label stacked above value, padded, never crowding an edge. */
553
582
  .kv { display: flex; flex-direction: column; gap: 3px;
554
- background: var(--chip); border: 1px solid var(--border); border-radius: 8px;
583
+ background: var(--surface-2); border: 1px solid var(--divider); border-radius: 10px;
555
584
  padding: 10px 12px; min-width: 0; }
556
585
  .kv .k { color: var(--muted); font-size: 12px; }
557
586
  .kv .val { font-weight: 500; }
@@ -562,7 +591,7 @@ var BASE_CSS = `
562
591
  .chip.good { background: rgba(22,163,74,.12); color: var(--good); }
563
592
  .chip.warn { background: rgba(217,119,6,.14); color: var(--warn); }
564
593
  .chip.bad { background: rgba(220,38,38,.12); color: var(--bad); }
565
- .chip.info { background: rgba(79,70,229,.12); color: var(--accent); }
594
+ .chip.info { background: var(--accent-dim); color: var(--accent); }
566
595
  .plane { margin-top: 14px; }
567
596
  .plane .subtitle { margin-bottom: 4px; }
568
597
  .num { text-align: right; }
@@ -601,6 +630,45 @@ var BASE_CSS = `
601
630
  }
602
631
  @media (prefers-reduced-motion: reduce) { .tl-spin, .tl-core, .tl-arm { animation: none; } }
603
632
  `;
633
+ var MD_JS = String.raw`
634
+ // Minimal, escape-first markdown: paragraphs, - / 1. lists, ### headings,
635
+ // **bold**, *em*, code spans, https links, pipe tables. Input is escaped before
636
+ // any markup is added, so model text can never inject HTML.
637
+ function mdInline(t) {
638
+ return esc(t)
639
+ .replace(/\x60([^\x60]+)\x60/g, "<code>$1</code>")
640
+ .replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>")
641
+ .replace(/(^|[^*])\*([^*\s][^*]*)\*/g, "$1<em>$2</em>")
642
+ .replace(/\[([^\]]+)\]\((https:\/\/[^\s)]+)\)/g, '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>');
643
+ }
644
+ function md(text) {
645
+ var lines = String(text == null ? "" : text).replace(/\r/g, "").split("\n");
646
+ var out = [], para = [], list = null, i = 0;
647
+ function flushPara() { if (para.length) { out.push("<p>" + para.map(mdInline).join("<br>") + "</p>"); para = []; } }
648
+ function flushList() { if (list) { out.push("<" + list.tag + ">" + list.items.map(function (x) { return "<li>" + mdInline(x) + "</li>"; }).join("") + "</" + list.tag + ">"); list = null; } }
649
+ for (; i < lines.length; i++) {
650
+ var l = lines[i], m;
651
+ if (/^\s*$/.test(l)) { flushPara(); flushList(); continue; }
652
+ if (/^\s*\|.*\|\s*$/.test(l) && i + 1 < lines.length && /^\s*\|?\s*:?-{2,}/.test(lines[i + 1])) {
653
+ flushPara(); flushList();
654
+ var cells = function (row) { return row.trim().replace(/^\||\|$/g, "").split("|").map(function (c) { return c.trim(); }); };
655
+ var head = cells(l); i += 2; var rows = [];
656
+ while (i < lines.length && /^\s*\|.*\|\s*$/.test(lines[i])) { rows.push(cells(lines[i])); i++; }
657
+ i--;
658
+ out.push("<table><thead><tr>" + head.map(function (h) { return "<th>" + mdInline(h) + "</th>"; }).join("") + "</tr></thead><tbody>"
659
+ + rows.slice(0, 50).map(function (r) { return "<tr>" + r.map(function (c) { return '<td class="val">' + mdInline(c) + "</td>"; }).join("") + "</tr>"; }).join("") + "</tbody></table>");
660
+ continue;
661
+ }
662
+ if ((m = /^\s*#{1,6}\s+(.*)$/.exec(l))) { flushPara(); flushList(); out.push("<h3>" + mdInline(m[1]) + "</h3>"); continue; }
663
+ if ((m = /^\s*[-*•]\s+(.*)$/.exec(l))) { flushPara(); if (!list || list.tag !== "ul") { flushList(); list = { tag: "ul", items: [] }; } list.items.push(m[1]); continue; }
664
+ if ((m = /^\s*\d+[.)]\s+(.*)$/.exec(l))) { flushPara(); if (!list || list.tag !== "ol") { flushList(); list = { tag: "ol", items: [] }; } list.items.push(m[1]); continue; }
665
+ if (list) { list.items[list.items.length - 1] += " " + l.trim(); continue; }
666
+ para.push(l.trim());
667
+ }
668
+ flushPara(); flushList();
669
+ return out.join("");
670
+ }
671
+ `;
604
672
  var HELPERS_JS = `
605
673
  var root = document.getElementById("root");
606
674
  function esc(s) {
@@ -623,6 +691,7 @@ var HELPERS_JS = `
623
691
  var p = Math.round(v * 100);
624
692
  return '<span class="bar ' + confClass(v) + '"><span style="width:' + p + '%"></span></span> <span class="muted small">' + p + '%</span>';
625
693
  }
694
+ ${MD_JS}
626
695
  function empty(msg) { root.innerHTML = '<div class="empty">' + esc(msg) + '</div>'; }
627
696
  function copyButton(id, text) {
628
697
  var btn = document.getElementById(id);
@@ -1918,9 +1987,13 @@ function getAnswerPolledWidgetHtml() {
1918
1987
  return POLLED_HTML;
1919
1988
  }
1920
1989
  var CSS3 = `
1921
- .cite { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--border); }
1922
- .cite:last-child { border-bottom: none; }
1923
- pre.md.answer { max-height: 480px; font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, sans-serif; }
1990
+ .cites { list-style: none; padding: 0; margin: 0; counter-reset: c; display: grid; gap: 10px; }
1991
+ .cites li { counter-increment: c; display: grid; grid-template-columns: 22px 1fr; gap: 0 6px; font-size: 13px; }
1992
+ .cites li::before { content: counter(c); color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
1993
+ .cites .q { color: var(--fg); }
1994
+ .cites .src { grid-column: 2; color: var(--faint); font-size: 12px; margin-top: 2px; }
1995
+ .correction { margin-top: 14px; padding: 10px 12px; border-radius: 8px; background: var(--accent-dim); font-size: 13px; }
1996
+ .thinking { display: flex; align-items: center; gap: 10px; color: var(--muted); }
1924
1997
  `;
1925
1998
  var ANSWER_BODY = `
1926
1999
  if (!payload || typeof payload !== "object" || !payload.ask_id) { empty("No answer."); return; }
@@ -1930,34 +2003,36 @@ var ANSWER_BODY = `
1930
2003
  var usage = obj(payload.usage);
1931
2004
  var cites = Array.isArray(payload.citations) ? payload.citations : [];
1932
2005
  var arts = Array.isArray(payload.artifacts) ? payload.artifacts : [];
1933
- var verdictTone = ver.verdict === "supported" ? "good" : ver.verdict === "issues" ? "warn" : ver.verdict === "unverifiable" ? "bad" : "";
1934
- var head = '<div class="header"><div><div class="title">' + HEADLINE + '</div><div class="subtitle">ask ' + idChip(payload.ask_id) + (payload.conversation_id ? ' \xB7 conversation ' + idChip(payload.conversation_id) : "") + '</div></div>'
1935
- + '<div>' + (status === "completed" ? chip(ver.verdict, verdictTone) : chip(status, status === "error" ? "bad" : "info")) + '</div></div>';
2006
+ var verdict = { supported: ["Verified", "good"], issues: ["Has issues", "warn"], unverifiable: ["Unverified", "bad"] }[ver.verdict];
2007
+ var ids = "ask " + payload.ask_id + (payload.conversation_id ? " \xB7 conversation " + payload.conversation_id : "");
2008
+ var head = '<div class="header"><div class="title" title="' + esc(ids) + '">' + HEADLINE + '</div>'
2009
+ + '<div>' + (status === "completed" ? (verdict ? chip(verdict[0], verdict[1]) : "") : status === "error" ? chip("Error", "bad") : "") + '</div></div>';
1936
2010
  if (status === "processing") {
1937
- root.innerHTML = head + '<div class="small">Still thinking\u2026 call talonic_get_answer with ask_id ' + idChip(payload.ask_id) + ' in a few seconds.</div>';
2011
+ root.innerHTML = head + '<div class="thinking">Still working on it. The answer appears here in a few seconds.</div>';
1938
2012
  return;
1939
2013
  }
1940
2014
  var answer = typeof payload.answer === "string" ? payload.answer : (payload.answer == null ? "" : fmt(payload.answer));
1941
- var citeHtml = cites.length ? '<div class="plane"><div class="subtitle">Citations (' + cites.length + ')</div>' + cites.slice(0, 20).map(function (c, i) {
2015
+ var citeHtml = cites.length ? '<div class="section"><div class="section-label">Sources</div><ol class="cites">' + cites.slice(0, 12).map(function (c) {
1942
2016
  c = obj(c);
1943
- return '<div class="cite"><span class="small">[' + (i + 1) + '] \u201C' + esc(clamp(c.quote || fmt(c), 200)) + '\u201D</span><span class="muted small">' + chip(c.kind, c.kind === "field" ? "info" : "") + esc(c.filename || shortId(c.document_id)) + (c.reference ? ' \xB7 ' + esc(c.reference) : "") + '</span></div>';
1944
- }).join("") + '</div>' : "";
1945
- var artHtml = arts.length ? '<div class="plane"><div class="subtitle">Artifacts (' + arts.length + ')</div>' + arts.slice(0, 10).map(function (a) {
2017
+ var where = esc(c.filename || shortId(c.document_id)) + (c.reference ? ' \xB7 ' + esc(c.reference) : "");
2018
+ var link = typeof c.app_url === "string" && /^https:\\/\\//.test(c.app_url) ? c.app_url : "";
2019
+ return '<li><span class="q">' + (c.quote ? "\u201C" + esc(clamp(c.quote, 220)) + "\u201D" : where) + '</span>'
2020
+ + '<span class="src">' + (link ? '<a href="' + esc(link) + '" target="_blank" rel="noopener noreferrer" style="color:inherit">' + where + '</a>' : where) + '</span></li>';
2021
+ }).join("") + '</ol>' + (cites.length > 12 ? '<div class="meta">+' + (cites.length - 12) + ' more sources</div>' : "") + '</div>' : "";
2022
+ var artHtml = arts.length ? '<div class="section"><div class="section-label">Files</div>' + arts.slice(0, 10).map(function (a) {
1946
2023
  a = obj(a);
1947
2024
  var link = typeof a.link === "string" && /^https:\\/\\//.test(a.link) ? a.link : "";
1948
- return '<div class="kv"><span class="val">' + esc(a.label || a.type || a.id || "artifact") + '</span>' + (link ? '<a class="btn small" href="' + esc(link) + '" target="_blank" rel="noopener noreferrer">Open</a>' : "") + '</div>';
2025
+ return link ? '<a class="btn" href="' + esc(link) + '" target="_blank" rel="noopener noreferrer" style="margin:0 6px 6px 0">' + esc(a.label || a.type || "Open file") + '</a>' : '<span class="chip">' + esc(a.label || a.type || "file") + '</span>';
1949
2026
  }).join("") + '</div>' : "";
1950
- var tiles = [];
1951
- if (typeof usage.credits_charged === "number") tiles.push(usage.credits_charged + " credits");
1952
- if (typeof usage.tokens === "number") tiles.push(usage.tokens + " tokens");
1953
- if (typeof payload.tool_calls === "number") tiles.push(payload.tool_calls + " tool call" + (payload.tool_calls === 1 ? "" : "s"));
1954
- if (typeof payload.waited_ms === "number") tiles.push((payload.waited_ms / 1000).toFixed(1) + " s");
1955
- if (typeof ver.checks_total === "number") tiles.push(ver.checks_total + " checks, " + (ver.checks_unsupported || 0) + " unsupported");
2027
+ var meta = [];
2028
+ if (typeof usage.credits_charged === "number") meta.push(usage.credits_charged + " credits");
2029
+ if (typeof payload.tool_calls === "number") meta.push(payload.tool_calls + (payload.tool_calls === 1 ? " query" : " queries"));
2030
+ if (typeof payload.waited_ms === "number") meta.push((payload.waited_ms / 1000).toFixed(1) + " s");
1956
2031
  root.innerHTML = head
1957
- + (answer ? '<pre class="md answer">' + esc(answer) + '</pre>' : '<div class="muted small">The agent returned no answer text.</div>')
1958
- + (ver.correction ? '<div class="small" style="margin-top:6px"><span class="muted">Correction:</span> ' + esc(ver.correction) + '</div>' : "")
2032
+ + (answer ? '<div class="prose">' + md(answer) + '</div>' : '<div class="muted small">No answer text came back.</div>')
2033
+ + (ver.correction ? '<div class="correction"><strong>Correction.</strong> ' + esc(ver.correction) + '</div>' : "")
1959
2034
  + citeHtml + artHtml
1960
- + (tiles.length ? '<div class="muted small" style="margin-top:10px">' + esc(tiles.join(" \xB7 ")) + '</div>' : "");
2035
+ + (meta.length ? '<div class="meta">' + esc(meta.join(" \xB7 ")) + '</div>' : "");
1961
2036
  `;
1962
2037
  function answerWidget(headline, title) {
1963
2038
  return buildWidgetHtml({
@@ -1967,7 +2042,7 @@ function answerWidget(headline, title) {
1967
2042
  });
1968
2043
  }
1969
2044
  var ANSWER_HTML = answerWidget("Answer", "Talonic \u2014 Answer");
1970
- var POLLED_HTML = answerWidget("Answer (polled)", "Talonic \u2014 Answer (polled)");
2045
+ var POLLED_HTML = answerWidget("Answer", "Talonic \u2014 Answer");
1971
2046
 
1972
2047
  // src/widgets/decision-task-shared.ts
1973
2048
  var DECISION_JS = `
@@ -8074,7 +8149,33 @@ var invokeAgentToolInputSchema = {
8074
8149
  args: z.record(z.string(), z.unknown()).optional().describe("Arguments matching the tool's input_schema."),
8075
8150
  document_ids: documentIdsArg
8076
8151
  };
8152
+ var ANALYSIS_TOOLS = /* @__PURE__ */ new Set([
8153
+ "query_data",
8154
+ "describe_data",
8155
+ "workspace_overview",
8156
+ "plan_fields"
8157
+ ]);
8158
+ var ASK_HINT = "If you are answering a question about the documents, call talonic_ask with the user's question instead of further queries: it runs this same SQL, field lookup and document reading server-side, knows the workspace's real field names and duplicate rules, and returns one cited answer in a single call.";
8159
+ var UNKNOWN_KEY_HINT = "talonic_ask resolves field names itself; call it with the user's question rather than guessing field_key values.";
8077
8160
  async function handleInvokeAgentTool(getToken, baseUrl, args) {
8161
+ const result = await invokeAgentTool(getToken, baseUrl, args);
8162
+ if (!ANALYSIS_TOOLS.has(args.name)) return result;
8163
+ const first = result.content[0];
8164
+ if (!first) return result;
8165
+ if (result.isError) {
8166
+ if (/Unknown field_key|Unknown claim predicate/.test(first.text)) {
8167
+ first.text = `${first.text}
8168
+ ${UNKNOWN_KEY_HINT}`;
8169
+ }
8170
+ return result;
8171
+ }
8172
+ if (result["structuredContent"] && typeof result["structuredContent"] === "object") {
8173
+ result["structuredContent"]["next_step"] = ASK_HINT;
8174
+ }
8175
+ result.content.push({ type: "text", text: `Next step: ${ASK_HINT}` });
8176
+ return result;
8177
+ }
8178
+ async function invokeAgentTool(getToken, baseUrl, args) {
8078
8179
  return runTool(async () => {
8079
8180
  const res = await apiJson(
8080
8181
  getToken,
@@ -8621,7 +8722,7 @@ function registerAskTools(server, getToken, baseUrl) {
8621
8722
 
8622
8723
  // package.json
8623
8724
  var package_default = {
8624
- version: "0.1.99"};
8725
+ version: "0.1.101"};
8625
8726
 
8626
8727
  // src/version.ts
8627
8728
  var VERSION = package_default.version;