@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/server.js CHANGED
@@ -500,24 +500,34 @@ function widgetMeta(description) {
500
500
  return meta;
501
501
  }
502
502
  var BASE_CSS = `
503
+ /* Ink tokens (platform ink/restructure, src/app/globals.css --void-*). */
503
504
  :root {
504
- --bg: #ffffff; --fg: #111827; --muted: #6b7280; --border: #e5e7eb;
505
- --accent: #4f46e5; --good: #16a34a; --warn: #d97706; --bad: #dc2626;
506
- --chip: #f3f4f6;
505
+ --bg: #FFFFFF; --fg: #1B1B1F; --muted: #5B5B64; --faint: #6A6A71;
506
+ --border: rgba(20, 20, 30, 0.12); --divider: rgba(20, 20, 30, 0.07);
507
+ --accent: #512DA8; --accent-dim: rgba(81, 45, 168, 0.07); --accent-tint: #EEE8F8;
508
+ --good: #1F9D5B; --warn: #B97E14; --bad: #C94343;
509
+ --chip: #F5F5F3; --surface-2: #F5F5F3;
507
510
  }
508
511
  @media (prefers-color-scheme: dark) {
509
512
  :root:not([data-theme="light"]) {
510
- --bg: #0f1115; --fg: #f3f4f6; --muted: #9ca3af; --border: #1f2937;
511
- --chip: #1f2937;
513
+ --bg: #101013; --fg: #EDEDEF; --muted: #A2A2AB; --faint: #86868E;
514
+ --border: rgba(255, 255, 255, 0.08); --divider: rgba(255, 255, 255, 0.06);
515
+ --accent: #C9B6F5; --accent-dim: rgba(201, 182, 245, 0.10); --accent-tint: #2A1F3D;
516
+ --good: #5BC98B; --warn: #E8B45A; --bad: #E36D6D;
517
+ --chip: #1A1A1F; --surface-2: #16161A;
512
518
  }
513
519
  }
514
520
  :root[data-theme="dark"] {
515
- --bg: #0f1115; --fg: #f3f4f6; --muted: #9ca3af; --border: #1f2937;
516
- --chip: #1f2937;
521
+ --bg: #101013; --fg: #EDEDEF; --muted: #A2A2AB; --faint: #86868E;
522
+ --border: rgba(255, 255, 255, 0.08); --divider: rgba(255, 255, 255, 0.06);
523
+ --accent: #C9B6F5; --accent-dim: rgba(201, 182, 245, 0.10); --accent-tint: #2A1F3D;
524
+ --good: #5BC98B; --warn: #E8B45A; --bad: #E36D6D;
525
+ --chip: #1A1A1F; --surface-2: #16161A;
517
526
  }
518
527
  :root[data-host="mcp-apps"] { --bg: transparent; }
519
528
  html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg);
520
- font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, sans-serif; }
529
+ font: 14px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
530
+ -webkit-font-smoothing: antialiased; }
521
531
  .root { padding: 20px; box-sizing: border-box; }
522
532
  * { box-sizing: border-box; }
523
533
  .empty { color: var(--muted); padding: 28px; text-align: center; }
@@ -525,10 +535,26 @@ var BASE_CSS = `
525
535
  .small { font-size: 12px; }
526
536
  .header { display: flex; align-items: flex-start; justify-content: space-between;
527
537
  gap: 12px; margin-bottom: 16px; }
528
- .title { font-weight: 600; }
529
- .subtitle { color: var(--muted); font-size: 12px; }
538
+ .title { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
539
+ .subtitle { color: var(--faint); font-size: 12px; }
540
+ .eyebrow { color: var(--faint); font-size: 12px; font-weight: 500; margin-bottom: 2px; }
541
+ .prose { font-size: 14.5px; line-height: 1.6; color: var(--fg); }
542
+ .prose p { margin: 0 0 10px; }
543
+ .prose p:last-child, .prose ul:last-child, .prose ol:last-child { margin-bottom: 0; }
544
+ .prose ul, .prose ol { margin: 0 0 10px; padding-left: 20px; }
545
+ .prose li { margin: 3px 0; }
546
+ .prose h3, .prose h4 { font-size: 14.5px; font-weight: 600; margin: 14px 0 6px; }
547
+ .prose code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--chip);
548
+ border: 1px solid var(--divider); border-radius: 4px; padding: 0 4px; }
549
+ .prose strong { font-weight: 600; }
550
+ .prose a { color: var(--accent); text-decoration: none; }
551
+ .prose a:hover { text-decoration: underline; }
552
+ .prose table { margin: 6px 0 12px; }
553
+ .section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--divider); }
554
+ .section-label { color: var(--faint); font-size: 12px; font-weight: 500; margin-bottom: 8px; }
555
+ .meta { color: var(--faint); font-size: 12px; margin-top: 14px; }
530
556
  table { width: 100%; border-collapse: collapse; margin-top: 8px; }
531
- th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border);
557
+ th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--divider);
532
558
  vertical-align: top; font-size: 13px; }
533
559
  th { color: var(--muted); font-weight: 500; font-size: 12px; }
534
560
  th:first-child, td:first-child { padding-left: 0; }
@@ -546,15 +572,18 @@ var BASE_CSS = `
546
572
  border-radius: 6px; padding: 6px 10px; font: inherit; cursor: pointer;
547
573
  text-decoration: none; display: inline-block; }
548
574
  button:hover, a.btn:hover { border-color: var(--accent); }
549
- a.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
550
- .chip { display: inline-block; background: var(--chip); border-radius: 999px;
551
- padding: 1px 8px; font-size: 12px; margin: 2px 4px 2px 0; }
575
+ a.btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
576
+ :root[data-host="mcp-apps"] a.btn.primary { color: #fff; }
577
+ @media (prefers-color-scheme: dark) { :root[data-host="mcp-apps"]:not([data-theme="light"]) a.btn.primary { color: #17102A; } }
578
+ :root[data-host="mcp-apps"][data-theme="dark"] a.btn.primary { color: #17102A; }
579
+ .chip { display: inline-block; background: var(--chip); border-radius: 6px; color: var(--muted);
580
+ padding: 1px 7px; font-size: 12px; font-weight: 500; margin: 2px 4px 2px 0; }
552
581
  .big { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
553
582
  .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
554
583
  gap: 10px; margin-top: 14px; }
555
584
  /* Stat tile: label stacked above value, padded, never crowding an edge. */
556
585
  .kv { display: flex; flex-direction: column; gap: 3px;
557
- background: var(--chip); border: 1px solid var(--border); border-radius: 8px;
586
+ background: var(--surface-2); border: 1px solid var(--divider); border-radius: 10px;
558
587
  padding: 10px 12px; min-width: 0; }
559
588
  .kv .k { color: var(--muted); font-size: 12px; }
560
589
  .kv .val { font-weight: 500; }
@@ -565,7 +594,7 @@ var BASE_CSS = `
565
594
  .chip.good { background: rgba(22,163,74,.12); color: var(--good); }
566
595
  .chip.warn { background: rgba(217,119,6,.14); color: var(--warn); }
567
596
  .chip.bad { background: rgba(220,38,38,.12); color: var(--bad); }
568
- .chip.info { background: rgba(79,70,229,.12); color: var(--accent); }
597
+ .chip.info { background: var(--accent-dim); color: var(--accent); }
569
598
  .plane { margin-top: 14px; }
570
599
  .plane .subtitle { margin-bottom: 4px; }
571
600
  .num { text-align: right; }
@@ -604,6 +633,45 @@ var BASE_CSS = `
604
633
  }
605
634
  @media (prefers-reduced-motion: reduce) { .tl-spin, .tl-core, .tl-arm { animation: none; } }
606
635
  `;
636
+ var MD_JS = String.raw`
637
+ // Minimal, escape-first markdown: paragraphs, - / 1. lists, ### headings,
638
+ // **bold**, *em*, code spans, https links, pipe tables. Input is escaped before
639
+ // any markup is added, so model text can never inject HTML.
640
+ function mdInline(t) {
641
+ return esc(t)
642
+ .replace(/\x60([^\x60]+)\x60/g, "<code>$1</code>")
643
+ .replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>")
644
+ .replace(/(^|[^*])\*([^*\s][^*]*)\*/g, "$1<em>$2</em>")
645
+ .replace(/\[([^\]]+)\]\((https:\/\/[^\s)]+)\)/g, '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>');
646
+ }
647
+ function md(text) {
648
+ var lines = String(text == null ? "" : text).replace(/\r/g, "").split("\n");
649
+ var out = [], para = [], list = null, i = 0;
650
+ function flushPara() { if (para.length) { out.push("<p>" + para.map(mdInline).join("<br>") + "</p>"); para = []; } }
651
+ function flushList() { if (list) { out.push("<" + list.tag + ">" + list.items.map(function (x) { return "<li>" + mdInline(x) + "</li>"; }).join("") + "</" + list.tag + ">"); list = null; } }
652
+ for (; i < lines.length; i++) {
653
+ var l = lines[i], m;
654
+ if (/^\s*$/.test(l)) { flushPara(); flushList(); continue; }
655
+ if (/^\s*\|.*\|\s*$/.test(l) && i + 1 < lines.length && /^\s*\|?\s*:?-{2,}/.test(lines[i + 1])) {
656
+ flushPara(); flushList();
657
+ var cells = function (row) { return row.trim().replace(/^\||\|$/g, "").split("|").map(function (c) { return c.trim(); }); };
658
+ var head = cells(l); i += 2; var rows = [];
659
+ while (i < lines.length && /^\s*\|.*\|\s*$/.test(lines[i])) { rows.push(cells(lines[i])); i++; }
660
+ i--;
661
+ out.push("<table><thead><tr>" + head.map(function (h) { return "<th>" + mdInline(h) + "</th>"; }).join("") + "</tr></thead><tbody>"
662
+ + 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>");
663
+ continue;
664
+ }
665
+ if ((m = /^\s*#{1,6}\s+(.*)$/.exec(l))) { flushPara(); flushList(); out.push("<h3>" + mdInline(m[1]) + "</h3>"); continue; }
666
+ if ((m = /^\s*[-*•]\s+(.*)$/.exec(l))) { flushPara(); if (!list || list.tag !== "ul") { flushList(); list = { tag: "ul", items: [] }; } list.items.push(m[1]); continue; }
667
+ if ((m = /^\s*\d+[.)]\s+(.*)$/.exec(l))) { flushPara(); if (!list || list.tag !== "ol") { flushList(); list = { tag: "ol", items: [] }; } list.items.push(m[1]); continue; }
668
+ if (list) { list.items[list.items.length - 1] += " " + l.trim(); continue; }
669
+ para.push(l.trim());
670
+ }
671
+ flushPara(); flushList();
672
+ return out.join("");
673
+ }
674
+ `;
607
675
  var HELPERS_JS = `
608
676
  var root = document.getElementById("root");
609
677
  function esc(s) {
@@ -626,6 +694,7 @@ var HELPERS_JS = `
626
694
  var p = Math.round(v * 100);
627
695
  return '<span class="bar ' + confClass(v) + '"><span style="width:' + p + '%"></span></span> <span class="muted small">' + p + '%</span>';
628
696
  }
697
+ ${MD_JS}
629
698
  function empty(msg) { root.innerHTML = '<div class="empty">' + esc(msg) + '</div>'; }
630
699
  function copyButton(id, text) {
631
700
  var btn = document.getElementById(id);
@@ -1921,9 +1990,13 @@ function getAnswerPolledWidgetHtml() {
1921
1990
  return POLLED_HTML;
1922
1991
  }
1923
1992
  var CSS3 = `
1924
- .cite { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--border); }
1925
- .cite:last-child { border-bottom: none; }
1926
- pre.md.answer { max-height: 480px; font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, sans-serif; }
1993
+ .cites { list-style: none; padding: 0; margin: 0; counter-reset: c; display: grid; gap: 10px; }
1994
+ .cites li { counter-increment: c; display: grid; grid-template-columns: 22px 1fr; gap: 0 6px; font-size: 13px; }
1995
+ .cites li::before { content: counter(c); color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
1996
+ .cites .q { color: var(--fg); }
1997
+ .cites .src { grid-column: 2; color: var(--faint); font-size: 12px; margin-top: 2px; }
1998
+ .correction { margin-top: 14px; padding: 10px 12px; border-radius: 8px; background: var(--accent-dim); font-size: 13px; }
1999
+ .thinking { display: flex; align-items: center; gap: 10px; color: var(--muted); }
1927
2000
  `;
1928
2001
  var ANSWER_BODY = `
1929
2002
  if (!payload || typeof payload !== "object" || !payload.ask_id) { empty("No answer."); return; }
@@ -1933,34 +2006,36 @@ var ANSWER_BODY = `
1933
2006
  var usage = obj(payload.usage);
1934
2007
  var cites = Array.isArray(payload.citations) ? payload.citations : [];
1935
2008
  var arts = Array.isArray(payload.artifacts) ? payload.artifacts : [];
1936
- var verdictTone = ver.verdict === "supported" ? "good" : ver.verdict === "issues" ? "warn" : ver.verdict === "unverifiable" ? "bad" : "";
1937
- 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>'
1938
- + '<div>' + (status === "completed" ? chip(ver.verdict, verdictTone) : chip(status, status === "error" ? "bad" : "info")) + '</div></div>';
2009
+ var verdict = { supported: ["Verified", "good"], issues: ["Has issues", "warn"], unverifiable: ["Unverified", "bad"] }[ver.verdict];
2010
+ var ids = "ask " + payload.ask_id + (payload.conversation_id ? " \xB7 conversation " + payload.conversation_id : "");
2011
+ var head = '<div class="header"><div class="title" title="' + esc(ids) + '">' + HEADLINE + '</div>'
2012
+ + '<div>' + (status === "completed" ? (verdict ? chip(verdict[0], verdict[1]) : "") : status === "error" ? chip("Error", "bad") : "") + '</div></div>';
1939
2013
  if (status === "processing") {
1940
- 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>';
2014
+ root.innerHTML = head + '<div class="thinking">Still working on it. The answer appears here in a few seconds.</div>';
1941
2015
  return;
1942
2016
  }
1943
2017
  var answer = typeof payload.answer === "string" ? payload.answer : (payload.answer == null ? "" : fmt(payload.answer));
1944
- var citeHtml = cites.length ? '<div class="plane"><div class="subtitle">Citations (' + cites.length + ')</div>' + cites.slice(0, 20).map(function (c, i) {
2018
+ var citeHtml = cites.length ? '<div class="section"><div class="section-label">Sources</div><ol class="cites">' + cites.slice(0, 12).map(function (c) {
1945
2019
  c = obj(c);
1946
- 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>';
1947
- }).join("") + '</div>' : "";
1948
- var artHtml = arts.length ? '<div class="plane"><div class="subtitle">Artifacts (' + arts.length + ')</div>' + arts.slice(0, 10).map(function (a) {
2020
+ var where = esc(c.filename || shortId(c.document_id)) + (c.reference ? ' \xB7 ' + esc(c.reference) : "");
2021
+ var link = typeof c.app_url === "string" && /^https:\\/\\//.test(c.app_url) ? c.app_url : "";
2022
+ return '<li><span class="q">' + (c.quote ? "\u201C" + esc(clamp(c.quote, 220)) + "\u201D" : where) + '</span>'
2023
+ + '<span class="src">' + (link ? '<a href="' + esc(link) + '" target="_blank" rel="noopener noreferrer" style="color:inherit">' + where + '</a>' : where) + '</span></li>';
2024
+ }).join("") + '</ol>' + (cites.length > 12 ? '<div class="meta">+' + (cites.length - 12) + ' more sources</div>' : "") + '</div>' : "";
2025
+ var artHtml = arts.length ? '<div class="section"><div class="section-label">Files</div>' + arts.slice(0, 10).map(function (a) {
1949
2026
  a = obj(a);
1950
2027
  var link = typeof a.link === "string" && /^https:\\/\\//.test(a.link) ? a.link : "";
1951
- 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>';
2028
+ 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>';
1952
2029
  }).join("") + '</div>' : "";
1953
- var tiles = [];
1954
- if (typeof usage.credits_charged === "number") tiles.push(usage.credits_charged + " credits");
1955
- if (typeof usage.tokens === "number") tiles.push(usage.tokens + " tokens");
1956
- if (typeof payload.tool_calls === "number") tiles.push(payload.tool_calls + " tool call" + (payload.tool_calls === 1 ? "" : "s"));
1957
- if (typeof payload.waited_ms === "number") tiles.push((payload.waited_ms / 1000).toFixed(1) + " s");
1958
- if (typeof ver.checks_total === "number") tiles.push(ver.checks_total + " checks, " + (ver.checks_unsupported || 0) + " unsupported");
2030
+ var meta = [];
2031
+ if (typeof usage.credits_charged === "number") meta.push(usage.credits_charged + " credits");
2032
+ if (typeof payload.tool_calls === "number") meta.push(payload.tool_calls + (payload.tool_calls === 1 ? " query" : " queries"));
2033
+ if (typeof payload.waited_ms === "number") meta.push((payload.waited_ms / 1000).toFixed(1) + " s");
1959
2034
  root.innerHTML = head
1960
- + (answer ? '<pre class="md answer">' + esc(answer) + '</pre>' : '<div class="muted small">The agent returned no answer text.</div>')
1961
- + (ver.correction ? '<div class="small" style="margin-top:6px"><span class="muted">Correction:</span> ' + esc(ver.correction) + '</div>' : "")
2035
+ + (answer ? '<div class="prose">' + md(answer) + '</div>' : '<div class="muted small">No answer text came back.</div>')
2036
+ + (ver.correction ? '<div class="correction"><strong>Correction.</strong> ' + esc(ver.correction) + '</div>' : "")
1962
2037
  + citeHtml + artHtml
1963
- + (tiles.length ? '<div class="muted small" style="margin-top:10px">' + esc(tiles.join(" \xB7 ")) + '</div>' : "");
2038
+ + (meta.length ? '<div class="meta">' + esc(meta.join(" \xB7 ")) + '</div>' : "");
1964
2039
  `;
1965
2040
  function answerWidget(headline, title) {
1966
2041
  return buildWidgetHtml({
@@ -1970,7 +2045,7 @@ function answerWidget(headline, title) {
1970
2045
  });
1971
2046
  }
1972
2047
  var ANSWER_HTML = answerWidget("Answer", "Talonic \u2014 Answer");
1973
- var POLLED_HTML = answerWidget("Answer (polled)", "Talonic \u2014 Answer (polled)");
2048
+ var POLLED_HTML = answerWidget("Answer", "Talonic \u2014 Answer");
1974
2049
 
1975
2050
  // src/widgets/decision-task-shared.ts
1976
2051
  var DECISION_JS = `
@@ -8187,7 +8262,33 @@ var invokeAgentToolInputSchema = {
8187
8262
  args: z.record(z.string(), z.unknown()).optional().describe("Arguments matching the tool's input_schema."),
8188
8263
  document_ids: documentIdsArg
8189
8264
  };
8265
+ var ANALYSIS_TOOLS = /* @__PURE__ */ new Set([
8266
+ "query_data",
8267
+ "describe_data",
8268
+ "workspace_overview",
8269
+ "plan_fields"
8270
+ ]);
8271
+ 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.";
8272
+ var UNKNOWN_KEY_HINT = "talonic_ask resolves field names itself; call it with the user's question rather than guessing field_key values.";
8190
8273
  async function handleInvokeAgentTool(getToken, baseUrl, args) {
8274
+ const result = await invokeAgentTool(getToken, baseUrl, args);
8275
+ if (!ANALYSIS_TOOLS.has(args.name)) return result;
8276
+ const first = result.content[0];
8277
+ if (!first) return result;
8278
+ if (result.isError) {
8279
+ if (/Unknown field_key|Unknown claim predicate/.test(first.text)) {
8280
+ first.text = `${first.text}
8281
+ ${UNKNOWN_KEY_HINT}`;
8282
+ }
8283
+ return result;
8284
+ }
8285
+ if (result["structuredContent"] && typeof result["structuredContent"] === "object") {
8286
+ result["structuredContent"]["next_step"] = ASK_HINT;
8287
+ }
8288
+ result.content.push({ type: "text", text: `Next step: ${ASK_HINT}` });
8289
+ return result;
8290
+ }
8291
+ async function invokeAgentTool(getToken, baseUrl, args) {
8191
8292
  return runTool(async () => {
8192
8293
  const res = await apiJson(
8193
8294
  getToken,
@@ -8734,7 +8835,7 @@ function registerAskTools(server, getToken, baseUrl) {
8734
8835
 
8735
8836
  // package.json
8736
8837
  var package_default = {
8737
- version: "0.1.99"};
8838
+ version: "0.1.101"};
8738
8839
 
8739
8840
  // src/version.ts
8740
8841
  var VERSION = package_default.version;