@talonic/mcp 0.1.73 → 0.1.75

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.
@@ -1311,7 +1311,7 @@ var DESCRIPTION6 = [
1311
1311
  "NOT FOR: full text (use talonic_to_markdown) \xB7 extracted fields (use talonic_extract).",
1312
1312
  "BY NAME: if the user names a file, call talonic_search first to get its document_id, then call this.",
1313
1313
  "ARGS: document_id.",
1314
- "RETURNS: filename, pages, type_detected, language, and `status`. Status lifecycle: pending_upload -> queued -> extracting -> completed. Wait for `completed` before calling talonic_extract on a freshly uploaded doc. To read the document's text, call talonic_to_markdown with this id."
1314
+ "RETURNS: filename, pages, type_detected, language, and `status`. Status lifecycle: pending_upload -> uploading -> queued -> extracting -> completed. Wait for `completed` before calling talonic_extract on a freshly uploaded doc. Terminal failure statuses: ocr_failed, extraction_failed, error \u2014 stop polling and report the failure to the user if any of these appear. To read the document's text, call talonic_to_markdown with this id."
1315
1315
  ].join("\n");
1316
1316
  var inputSchema6 = {
1317
1317
  document_id: z.string().min(1).describe(
@@ -1645,7 +1645,7 @@ var DESCRIPTION10 = [
1645
1645
  "USE WHEN: the user wants to upload a document and you cannot pass it directly \u2014 hosted/sandboxed clients (ChatGPT, Claude.ai) or files too large for tool-call arguments.",
1646
1646
  "NOT FOR: a document already in the workspace (use its document_id) \xB7 a file already on a public URL (use file_url on talonic_extract).",
1647
1647
  "ARGS: filename (with extension).",
1648
- "RETURNS: upload_url, document_id, expires_at. After the user uploads, poll talonic_get_document on that document_id until status is 'completed', then call talonic_extract."
1648
+ "RETURNS: upload_url, document_id, expires_at. After the user uploads, poll talonic_get_document on that document_id until status is 'completed', then call talonic_extract. If status becomes ocr_failed, extraction_failed, or error, stop polling and report the failure to the user."
1649
1649
  ].join("\n");
1650
1650
  var inputSchema9 = {
1651
1651
  filename: z.string().min(1).describe(
@@ -1710,6 +1710,485 @@ function registerRequestUpload(server, getToken, baseUrl) {
1710
1710
  async (args) => handleRequestUpload(getToken, baseUrl, args)
1711
1711
  );
1712
1712
  }
1713
+ var DEFAULT_BASE = "https://api.talonic.com";
1714
+ var RANGES = ["7d", "30d", "90d"];
1715
+ async function growthGet(getToken, baseUrl, path, params) {
1716
+ try {
1717
+ const qs = new URLSearchParams();
1718
+ for (const [k, v] of Object.entries(params)) if (v !== void 0 && v !== "") qs.set(k, v);
1719
+ const url = `${baseUrl ?? DEFAULT_BASE}/v1/growth/${path}${qs.size ? `?${qs}` : ""}`;
1720
+ const res = await fetch(url, {
1721
+ headers: { Authorization: `Bearer ${getToken()}`, Accept: "application/json" }
1722
+ });
1723
+ if (res.status === 403) {
1724
+ return toolError(
1725
+ new Error(
1726
+ "Talonic growth analytics require an active superadmin account. Sign in to the connector with your Talonic staff account (or use a superadmin-created API key)."
1727
+ )
1728
+ );
1729
+ }
1730
+ if (!res.ok) {
1731
+ const body = await res.text().catch(() => "");
1732
+ return toolError(
1733
+ new Error(`Talonic API error: HTTP ${res.status}${body ? ` \u2014 ${body}` : ""}`)
1734
+ );
1735
+ }
1736
+ return jsonOk(await res.json());
1737
+ } catch (err) {
1738
+ return toolError(err);
1739
+ }
1740
+ }
1741
+ async function probeGrowthAccess(token, baseUrl) {
1742
+ try {
1743
+ const res = await fetch(`${baseUrl ?? DEFAULT_BASE}/v1/growth/access`, {
1744
+ headers: { Authorization: `Bearer ${token}`, Accept: "application/json" },
1745
+ signal: AbortSignal.timeout(5e3)
1746
+ });
1747
+ return res.ok;
1748
+ } catch {
1749
+ return false;
1750
+ }
1751
+ }
1752
+ var rangeArg = z.enum(RANGES).optional().describe("Trailing window (default 30d).");
1753
+ var FUNNEL_DESCRIPTION = [
1754
+ "Read Talonic's agentic product funnel: WAEW (weekly active extracting workspaces \u2014 the North Star),",
1755
+ "time-to-first-extraction p50/p90 + 24h activation rate, W2/W4 creation-cohort retention, and",
1756
+ "acquisition by surface (claude_ai, cursor, raw_api, ...).",
1757
+ "",
1758
+ "USE WHEN: asked about WAEW, activation, retention, or which surfaces drive extractions.",
1759
+ "INTERNAL: Talonic-superadmin-only; other accounts are rejected by the platform.",
1760
+ "ARGS: range (optional: 7d | 30d | 90d, default 30d).",
1761
+ "RETURNS: { configured, rangeDays, waew, ttfe, retention[], bySurface[] } \u2014 configured:false means PostHog is unwired, not zero usage."
1762
+ ].join("\n");
1763
+ var FUNNELS_DESCRIPTION = [
1764
+ "Read Talonic's website conversion funnels: Platform registration (Visit \u2192 Sign-up click \u2192 Account created \u2192 Activated)",
1765
+ "and Sales call booking (Visit \u2192 Book-demo click \u2192 Contact page \u2192 Demo booked).",
1766
+ "",
1767
+ "USE WHEN: asked about signups, activation counts, demo bookings, or website conversion.",
1768
+ "INTERNAL: Talonic-superadmin-only; other accounts are rejected by the platform.",
1769
+ "ARGS: range (optional: 7d | 30d | 90d, default 30d).",
1770
+ "RETURNS: { rangeDays, funnels[] } \u2014 each stage carries { count, pending }; pending:true means that stage's source is not wired yet, not zero."
1771
+ ].join("\n");
1772
+ var TRAFFIC_DESCRIPTION = [
1773
+ "Read talonic.com traffic: visitors, pageviews, top pages, and referrers split into AI assistants",
1774
+ "(ChatGPT, Claude, Perplexity, ...) vs other domains.",
1775
+ "",
1776
+ "USE WHEN: asked about website traffic, top pages, or how many visitors AI assistants refer.",
1777
+ "INTERNAL: Talonic-superadmin-only; other accounts are rejected by the platform.",
1778
+ "ARGS: range (optional: 7d | 30d | 90d, default 30d).",
1779
+ "RETURNS: { configured, visitors, pageviews, topPages[], topReferrers[], aiReferrers[] }."
1780
+ ].join("\n");
1781
+ var TOOLS_USAGE_DESCRIPTION = [
1782
+ "Read anonymous visitor behavior on the free tools at talonic.com/tools: views, attempt/success/bounce",
1783
+ "rates, dwell, CTA clicks, per-tool leaderboard, and country/device/acquisition splits.",
1784
+ "",
1785
+ "USE WHEN: asked how the free tools perform, which tools convert, or where tool visitors come from.",
1786
+ "INTERNAL: Talonic-superadmin-only; other accounts are rejected by the platform.",
1787
+ "ARGS: all optional \u2014 range (today | 7d | 30d | 90d | all, default 30d), tool (slug), category, country (ISO code), device (desktop | mobile | tablet), source (utm/referrer key), funnel_stage (attempted | succeeded | downloaded | cta).",
1788
+ "RETURNS: the Tools Usage dashboard payload: totals, rates, tools[] leaderboard, breakdowns, trend. Rates are ratios of independent counts, not per-visitor funnels."
1789
+ ].join("\n");
1790
+ var toolsUsageInput = {
1791
+ range: z.enum(["today", "7d", "30d", "90d", "all"]).optional().describe("Window (default 30d)."),
1792
+ tool: z.string().optional().describe("Restrict to one tool slug (e.g. 'pdf-to-csv')."),
1793
+ category: z.string().optional().describe("Restrict to a tool category."),
1794
+ country: z.string().optional().describe("Restrict to a visitor country (ISO code, e.g. 'DE')."),
1795
+ device: z.string().optional().describe("Restrict to a device type: desktop, mobile, or tablet."),
1796
+ source: z.string().optional().describe("Restrict to an acquisition source (UTM value or referrer host)."),
1797
+ funnel_stage: z.enum(["attempted", "succeeded", "downloaded", "cta"]).optional().describe("Keep only tools with at least one event at this funnel stage.")
1798
+ };
1799
+ async function handleGrowthFunnel(getToken, baseUrl, args) {
1800
+ return growthGet(getToken, baseUrl, "funnel", { range: args.range });
1801
+ }
1802
+ async function handleGrowthFunnels(getToken, baseUrl, args) {
1803
+ return growthGet(getToken, baseUrl, "funnels", { range: args.range });
1804
+ }
1805
+ async function handleGrowthTraffic(getToken, baseUrl, args) {
1806
+ return growthGet(getToken, baseUrl, "traffic", { range: args.range });
1807
+ }
1808
+ async function handleGrowthToolsUsage(getToken, baseUrl, args) {
1809
+ return growthGet(getToken, baseUrl, "tools-usage", {
1810
+ range: args.range,
1811
+ tool: args.tool,
1812
+ category: args.category,
1813
+ country: args.country,
1814
+ device: args.device,
1815
+ source: args.source,
1816
+ funnelStage: args.funnel_stage
1817
+ });
1818
+ }
1819
+ var READ_ONLY = {
1820
+ readOnlyHint: true,
1821
+ destructiveHint: false,
1822
+ openWorldHint: false
1823
+ };
1824
+ function registerGrowthTools(server, getToken, baseUrl) {
1825
+ server.registerTool(
1826
+ "talonic_growth_funnel",
1827
+ {
1828
+ title: "Growth: Product Funnel",
1829
+ description: FUNNEL_DESCRIPTION,
1830
+ inputSchema: { range: rangeArg },
1831
+ annotations: { title: "Growth: Product Funnel", ...READ_ONLY }
1832
+ },
1833
+ async (args) => handleGrowthFunnel(getToken, baseUrl, args)
1834
+ );
1835
+ server.registerTool(
1836
+ "talonic_growth_funnels",
1837
+ {
1838
+ title: "Growth: Conversion Funnels",
1839
+ description: FUNNELS_DESCRIPTION,
1840
+ inputSchema: { range: rangeArg },
1841
+ annotations: { title: "Growth: Conversion Funnels", ...READ_ONLY }
1842
+ },
1843
+ async (args) => handleGrowthFunnels(getToken, baseUrl, args)
1844
+ );
1845
+ server.registerTool(
1846
+ "talonic_growth_traffic",
1847
+ {
1848
+ title: "Growth: Website Traffic",
1849
+ description: TRAFFIC_DESCRIPTION,
1850
+ inputSchema: { range: rangeArg },
1851
+ annotations: { title: "Growth: Website Traffic", ...READ_ONLY }
1852
+ },
1853
+ async (args) => handleGrowthTraffic(getToken, baseUrl, args)
1854
+ );
1855
+ server.registerTool(
1856
+ "talonic_growth_tools_usage",
1857
+ {
1858
+ title: "Growth: Free-Tools Usage",
1859
+ description: TOOLS_USAGE_DESCRIPTION,
1860
+ inputSchema: toolsUsageInput,
1861
+ annotations: { title: "Growth: Free-Tools Usage", ...READ_ONLY }
1862
+ },
1863
+ async (args) => handleGrowthToolsUsage(getToken, baseUrl, args)
1864
+ );
1865
+ }
1866
+ var DEFAULT_BASE2 = "https://api.talonic.com";
1867
+ var TASK_STATUSES = ["available", "claimed", "submitted", "timed_out", "cancelled"];
1868
+ var taskId = z.string().uuid().describe("Agent task UUID.");
1869
+ var executionEpoch = z.number().int().min(1).max(2147483647).describe("Execution epoch returned by the successful claim. Stale epochs are rejected.");
1870
+ var status = z.enum(TASK_STATUSES).optional().describe("Optional task-status filter.");
1871
+ var limit = z.number().int().min(1).max(100).optional().describe("Page size (default 50).");
1872
+ var cursor = z.string().min(1).optional().describe("Opaque cursor from pagination.next_cursor.");
1873
+ var outputValue = z.object({
1874
+ value: z.json().describe("JSON value matching the field's declared data type."),
1875
+ confidence: z.number().min(0).max(1).optional().describe("Optional confidence from 0 to 1."),
1876
+ reasoning: z.string().max(4e3).optional().describe("Optional concise reasoning for this field, up to 4,000 characters.")
1877
+ });
1878
+ var outputs = z.record(z.string().min(1), outputValue).describe("Output field key to { value, confidence?, reasoning? }. Use only declared fields.");
1879
+ var listInput = { status, limit, cursor };
1880
+ var idInput = { task_id: taskId };
1881
+ var heartbeatInput = { task_id: taskId, execution_epoch: executionEpoch };
1882
+ var submitInput = {
1883
+ task_id: taskId,
1884
+ execution_epoch: executionEpoch,
1885
+ outputs,
1886
+ summary: z.string().max(4e3).optional().describe("Optional result summary, up to 4,000 characters.")
1887
+ };
1888
+ var adminCustomerId = z.string().uuid().describe("Explicit customer/workspace UUID. Payload calls never accept 'all'.");
1889
+ var adminReason = z.string().min(1).max(1e3).describe("Human-readable reason recorded with the cross-tenant access.");
1890
+ var adminTotp = z.string().regex(/^\d{6}$/, "TOTP code must contain exactly 6 digits").describe("Fresh 6-digit TOTP code for step-up authorization.");
1891
+ var adminPayloadAccessInput = {
1892
+ customer_id: adminCustomerId,
1893
+ reason: adminReason,
1894
+ totp_code: adminTotp
1895
+ };
1896
+ function apiUrl(baseUrl, path, query) {
1897
+ const base = (baseUrl ?? DEFAULT_BASE2).replace(/\/$/, "");
1898
+ const url = new URL(`${base}${path}`);
1899
+ for (const [key, value] of Object.entries(query ?? {})) {
1900
+ if (value !== void 0 && value !== "") url.searchParams.set(key, String(value));
1901
+ }
1902
+ return url.toString();
1903
+ }
1904
+ async function agentTaskRequest(getToken, baseUrl, request) {
1905
+ try {
1906
+ const response = await fetch(apiUrl(baseUrl, request.path, request.query), {
1907
+ method: request.method ?? "GET",
1908
+ headers: {
1909
+ Authorization: `Bearer ${getToken()}`,
1910
+ Accept: "application/json",
1911
+ ...request.body === void 0 ? {} : { "Content-Type": "application/json" },
1912
+ ...request.headers
1913
+ },
1914
+ ...request.body === void 0 ? {} : { body: JSON.stringify(request.body) }
1915
+ });
1916
+ if (!response.ok) {
1917
+ const body = await response.text().catch(() => "");
1918
+ return toolError(
1919
+ new Error(`Talonic API error: HTTP ${response.status}${body ? ` \u2014 ${body}` : ""}`)
1920
+ );
1921
+ }
1922
+ return jsonOk(await response.json());
1923
+ } catch (error) {
1924
+ return toolError(error);
1925
+ }
1926
+ }
1927
+ function listQuery(args) {
1928
+ return { status: args.status, limit: args.limit, cursor: args.cursor };
1929
+ }
1930
+ function adminHeaders(args) {
1931
+ return {
1932
+ "x-talonic-reason": args.reason,
1933
+ "x-step-up-code": args.totp_code
1934
+ };
1935
+ }
1936
+ function handleListAgentTasks(getToken, baseUrl, args) {
1937
+ return agentTaskRequest(getToken, baseUrl, {
1938
+ path: "/v1/agent-tasks",
1939
+ query: listQuery(args)
1940
+ });
1941
+ }
1942
+ function handleGetAgentTask(getToken, baseUrl, args) {
1943
+ return agentTaskRequest(getToken, baseUrl, {
1944
+ path: `/v1/agent-tasks/${encodeURIComponent(args.task_id)}`
1945
+ });
1946
+ }
1947
+ function handleClaimAgentTask(getToken, baseUrl, args) {
1948
+ return agentTaskRequest(getToken, baseUrl, {
1949
+ method: "POST",
1950
+ path: `/v1/agent-tasks/${encodeURIComponent(args.task_id)}/claim`
1951
+ });
1952
+ }
1953
+ function handleHeartbeatAgentTask(getToken, baseUrl, args) {
1954
+ return agentTaskRequest(getToken, baseUrl, {
1955
+ method: "POST",
1956
+ path: `/v1/agent-tasks/${encodeURIComponent(args.task_id)}/heartbeat`,
1957
+ body: { execution_epoch: args.execution_epoch }
1958
+ });
1959
+ }
1960
+ function handleSubmitAgentTask(getToken, baseUrl, args) {
1961
+ return agentTaskRequest(getToken, baseUrl, {
1962
+ method: "POST",
1963
+ path: `/v1/agent-tasks/${encodeURIComponent(args.task_id)}/submit`,
1964
+ body: {
1965
+ execution_epoch: args.execution_epoch,
1966
+ outputs: args.outputs,
1967
+ ...args.summary === void 0 ? {} : { summary: args.summary }
1968
+ }
1969
+ });
1970
+ }
1971
+ async function probeAgentTaskAdminAccess(token, baseUrl) {
1972
+ try {
1973
+ const response = await fetch(apiUrl(baseUrl, "/v1/agent-tasks/admin/access"), {
1974
+ headers: { Authorization: `Bearer ${token}`, Accept: "application/json" },
1975
+ signal: AbortSignal.timeout(5e3)
1976
+ });
1977
+ return response.ok;
1978
+ } catch {
1979
+ return false;
1980
+ }
1981
+ }
1982
+ function handleAdminListAgentTasks(getToken, baseUrl, args) {
1983
+ return agentTaskRequest(getToken, baseUrl, {
1984
+ path: "/v1/agent-tasks/admin/tasks",
1985
+ query: { customerId: args.customer_id ?? "all", ...listQuery(args) }
1986
+ });
1987
+ }
1988
+ function handleAdminGetAgentTask(getToken, baseUrl, args) {
1989
+ return agentTaskRequest(getToken, baseUrl, {
1990
+ path: `/v1/agent-tasks/admin/tasks/${encodeURIComponent(args.task_id)}`,
1991
+ query: { customerId: args.customer_id },
1992
+ headers: adminHeaders(args)
1993
+ });
1994
+ }
1995
+ function handleAdminClaimAgentTask(getToken, baseUrl, args) {
1996
+ return agentTaskRequest(getToken, baseUrl, {
1997
+ method: "POST",
1998
+ path: `/v1/agent-tasks/admin/tasks/${encodeURIComponent(args.task_id)}/claim`,
1999
+ query: { customerId: args.customer_id },
2000
+ headers: adminHeaders(args)
2001
+ });
2002
+ }
2003
+ function handleAdminHeartbeatAgentTask(getToken, baseUrl, args) {
2004
+ return agentTaskRequest(getToken, baseUrl, {
2005
+ method: "POST",
2006
+ path: `/v1/agent-tasks/admin/tasks/${encodeURIComponent(args.task_id)}/heartbeat`,
2007
+ query: { customerId: args.customer_id },
2008
+ headers: adminHeaders(args),
2009
+ body: { execution_epoch: args.execution_epoch }
2010
+ });
2011
+ }
2012
+ function handleAdminSubmitAgentTask(getToken, baseUrl, args) {
2013
+ return agentTaskRequest(getToken, baseUrl, {
2014
+ method: "POST",
2015
+ path: `/v1/agent-tasks/admin/tasks/${encodeURIComponent(args.task_id)}/submit`,
2016
+ query: { customerId: args.customer_id },
2017
+ headers: adminHeaders(args),
2018
+ body: {
2019
+ execution_epoch: args.execution_epoch,
2020
+ outputs: args.outputs,
2021
+ ...args.summary === void 0 ? {} : { summary: args.summary }
2022
+ }
2023
+ });
2024
+ }
2025
+ var READ_ONLY2 = {
2026
+ readOnlyHint: true,
2027
+ destructiveHint: false,
2028
+ openWorldHint: false
2029
+ };
2030
+ var MUTATING = {
2031
+ readOnlyHint: false,
2032
+ destructiveHint: false,
2033
+ openWorldHint: false
2034
+ };
2035
+ var DESCRIPTIONS = {
2036
+ list: [
2037
+ "List Agent-stage tasks visible to this Talonic workspace credential.",
2038
+ "",
2039
+ "USE WHEN: looking for external-agent work to process; begin with status 'available'.",
2040
+ "NOT FOR: reading the immutable task payload (use talonic_get_agent_task) or taking a lease (use talonic_claim_agent_task).",
2041
+ "ARGS: optional status, limit, and cursor. RETURNS: metadata only plus pagination.next_cursor."
2042
+ ].join("\n"),
2043
+ get: [
2044
+ "Fetch one Agent-stage task's immutable input snapshot, instructions, and declared output contract. This disclosure is audited.",
2045
+ "",
2046
+ "USE WHEN: inspecting a listed task before deciding whether to process it.",
2047
+ "NOT FOR: acquiring the task (use talonic_claim_agent_task) or returning results (use talonic_submit_agent_task).",
2048
+ "ARGS: task_id. RETURNS: metadata, input_snapshot, output_contract, instructions, and timeout_fallthrough."
2049
+ ].join("\n"),
2050
+ claim: [
2051
+ "Claim an available Agent-stage task, or reclaim it after its lease expires.",
2052
+ "",
2053
+ "USE WHEN: ready to process a task. Save the returned execution_epoch and lease_expires_at.",
2054
+ "NOT FOR: merely inspecting work (use talonic_get_agent_task) or extending an active lease (use talonic_heartbeat_agent_task).",
2055
+ "A conflicting live claim returns HTTP 409. A successful claim returns the task payload."
2056
+ ].join("\n"),
2057
+ heartbeat: [
2058
+ "Extend the lease on a claimed Agent-stage task.",
2059
+ "",
2060
+ "USE WHEN: processing may continue past lease_expires_at; heartbeat before expiry using the epoch from claim.",
2061
+ "NOT FOR: acquiring a task (use talonic_claim_agent_task) or submitting finished outputs (use talonic_submit_agent_task).",
2062
+ "ARGS: task_id and execution_epoch. Stale or foreign claims return HTTP 409."
2063
+ ].join("\n"),
2064
+ submit: [
2065
+ "Submit declared output fields for a claimed Agent-stage task and resume the parked document.",
2066
+ "",
2067
+ "USE WHEN: processing is complete and every required output in output_contract is ready.",
2068
+ "NOT FOR: undeclared fields or partial lease maintenance (use talonic_heartbeat_agent_task).",
2069
+ "ARGS: task_id, execution_epoch, outputs keyed exactly by declared field key, and optional summary. The platform validates all fields and types transactionally before writing anything."
2070
+ ].join("\n")
2071
+ };
2072
+ function registerAgentTaskTools(server, getToken, baseUrl) {
2073
+ server.registerTool(
2074
+ "talonic_list_agent_tasks",
2075
+ {
2076
+ title: "List Agent Tasks",
2077
+ description: DESCRIPTIONS.list,
2078
+ inputSchema: listInput,
2079
+ annotations: { title: "List Agent Tasks", ...READ_ONLY2 }
2080
+ },
2081
+ async (args) => handleListAgentTasks(getToken, baseUrl, args)
2082
+ );
2083
+ server.registerTool(
2084
+ "talonic_get_agent_task",
2085
+ {
2086
+ title: "Get Agent Task",
2087
+ description: DESCRIPTIONS.get,
2088
+ inputSchema: idInput,
2089
+ annotations: { title: "Get Agent Task", ...READ_ONLY2 }
2090
+ },
2091
+ async (args) => handleGetAgentTask(getToken, baseUrl, args)
2092
+ );
2093
+ server.registerTool(
2094
+ "talonic_claim_agent_task",
2095
+ {
2096
+ title: "Claim Agent Task",
2097
+ description: DESCRIPTIONS.claim,
2098
+ inputSchema: idInput,
2099
+ annotations: { title: "Claim Agent Task", ...MUTATING }
2100
+ },
2101
+ async (args) => handleClaimAgentTask(getToken, baseUrl, args)
2102
+ );
2103
+ server.registerTool(
2104
+ "talonic_heartbeat_agent_task",
2105
+ {
2106
+ title: "Heartbeat Agent Task",
2107
+ description: DESCRIPTIONS.heartbeat,
2108
+ inputSchema: heartbeatInput,
2109
+ annotations: { title: "Heartbeat Agent Task", ...MUTATING }
2110
+ },
2111
+ async (args) => handleHeartbeatAgentTask(getToken, baseUrl, args)
2112
+ );
2113
+ server.registerTool(
2114
+ "talonic_submit_agent_task",
2115
+ {
2116
+ title: "Submit Agent Task",
2117
+ description: DESCRIPTIONS.submit,
2118
+ inputSchema: submitInput,
2119
+ annotations: { title: "Submit Agent Task", ...MUTATING }
2120
+ },
2121
+ async (args) => handleSubmitAgentTask(getToken, baseUrl, args)
2122
+ );
2123
+ }
2124
+ var adminIdInput = { task_id: taskId, ...adminPayloadAccessInput };
2125
+ var adminHeartbeatInput = {
2126
+ task_id: taskId,
2127
+ execution_epoch: executionEpoch,
2128
+ ...adminPayloadAccessInput
2129
+ };
2130
+ var adminSubmitInput = {
2131
+ task_id: taskId,
2132
+ execution_epoch: executionEpoch,
2133
+ outputs,
2134
+ summary: z.string().max(4e3).optional(),
2135
+ ...adminPayloadAccessInput
2136
+ };
2137
+ function registerAdminAgentTaskTools(server, getToken, baseUrl) {
2138
+ server.registerTool(
2139
+ "talonic_admin_list_agent_tasks",
2140
+ {
2141
+ title: "Admin: List Agent Tasks",
2142
+ description: "INTERNAL: list Agent-task metadata across all tenants or one named tenant. NOT FOR payload data; use talonic_admin_get_agent_task with an explicit tenant, reason, and TOTP code.",
2143
+ inputSchema: {
2144
+ customer_id: z.union([z.string().uuid(), z.literal("all")]).optional().describe("Tenant UUID, or 'all' (default) for cross-tenant metadata."),
2145
+ ...listInput
2146
+ },
2147
+ annotations: { title: "Admin: List Agent Tasks", ...READ_ONLY2 }
2148
+ },
2149
+ async (args) => handleAdminListAgentTasks(getToken, baseUrl, args)
2150
+ );
2151
+ server.registerTool(
2152
+ "talonic_admin_get_agent_task",
2153
+ {
2154
+ title: "Admin: Get Agent Task",
2155
+ description: "INTERNAL: fetch one Agent-task payload for an explicit tenant. This audited disclosure requires interactive OAuth, a reason, and fresh TOTP. NOT FOR cross-tenant metadata listing.",
2156
+ inputSchema: adminIdInput,
2157
+ annotations: { title: "Admin: Get Agent Task", ...READ_ONLY2 }
2158
+ },
2159
+ async (args) => handleAdminGetAgentTask(getToken, baseUrl, args)
2160
+ );
2161
+ server.registerTool(
2162
+ "talonic_admin_claim_agent_task",
2163
+ {
2164
+ title: "Admin: Claim Agent Task",
2165
+ description: "INTERNAL: claim or reclaim one Agent task in an explicit tenant. Requires interactive OAuth, reason, and fresh TOTP. NOT FOR metadata-only access.",
2166
+ inputSchema: adminIdInput,
2167
+ annotations: { title: "Admin: Claim Agent Task", ...MUTATING }
2168
+ },
2169
+ async (args) => handleAdminClaimAgentTask(getToken, baseUrl, args)
2170
+ );
2171
+ server.registerTool(
2172
+ "talonic_admin_heartbeat_agent_task",
2173
+ {
2174
+ title: "Admin: Heartbeat Agent Task",
2175
+ description: "INTERNAL: extend one claimed Agent-task lease in an explicit tenant. Requires interactive OAuth, reason, and fresh TOTP. NOT FOR acquiring a task.",
2176
+ inputSchema: adminHeartbeatInput,
2177
+ annotations: { title: "Admin: Heartbeat Agent Task", ...MUTATING }
2178
+ },
2179
+ async (args) => handleAdminHeartbeatAgentTask(getToken, baseUrl, args)
2180
+ );
2181
+ server.registerTool(
2182
+ "talonic_admin_submit_agent_task",
2183
+ {
2184
+ title: "Admin: Submit Agent Task",
2185
+ description: "INTERNAL: submit declared outputs for one claimed Agent task in an explicit tenant. Requires interactive OAuth, reason, and fresh TOTP. NOT FOR undeclared fields.",
2186
+ inputSchema: adminSubmitInput,
2187
+ annotations: { title: "Admin: Submit Agent Task", ...MUTATING }
2188
+ },
2189
+ async (args) => handleAdminSubmitAgentTask(getToken, baseUrl, args)
2190
+ );
2191
+ }
1713
2192
  var DESCRIPTION11 = [
1714
2193
  "Get the OCR-converted markdown text of a document.",
1715
2194
  "",
@@ -1817,7 +2296,7 @@ function registerToMarkdown(server, getTalonic) {
1817
2296
 
1818
2297
  // package.json
1819
2298
  var package_default = {
1820
- version: "0.1.73"};
2299
+ version: "0.1.75"};
1821
2300
 
1822
2301
  // src/version.ts
1823
2302
  var VERSION = package_default.version;
@@ -1909,6 +2388,9 @@ function createServer(options) {
1909
2388
  "with that id \u2014 do not ask the user for an id.",
1910
2389
  "talonic_search matches LITERAL keywords: query with one short singular term or an",
1911
2390
  "exact filename, never a sentence; on an empty result retry with a shorter keyword.",
2391
+ "For Agent-stage work, follow list -> get -> claim -> heartbeat while needed ->",
2392
+ "submit. Preserve the execution_epoch from claim and return only fields declared",
2393
+ "in the task output_contract; never continue after a lease or epoch conflict.",
1912
2394
  "Prefer acting over explaining."
1913
2395
  ].join(" ")
1914
2396
  }
@@ -1932,6 +2414,13 @@ function createServer(options) {
1932
2414
  registerGetPricing(server, getTalonic);
1933
2415
  registerGetUsage(server, getTalonic);
1934
2416
  registerRequestUpload(server, getToken, baseUrl);
2417
+ registerAgentTaskTools(server, getToken, baseUrl);
2418
+ if (options.includeGrowthTools) {
2419
+ registerGrowthTools(server, getToken, baseUrl);
2420
+ }
2421
+ if (options.includeAdminAgentTaskTools) {
2422
+ registerAdminAgentTaskTools(server, getToken, baseUrl);
2423
+ }
1935
2424
  registerSchemasResource(server, getTalonic);
1936
2425
  registerWebhooksResource(server, getToken, baseUrl);
1937
2426
  registerWidgets(server);
@@ -1965,6 +2454,29 @@ var FAVICON_BYTES = Buffer.from(FAVICON_BASE64, "base64");
1965
2454
 
1966
2455
  // src/http-server.ts
1967
2456
  var PORT = Number(process.env["PORT"] ?? 3e3);
2457
+ var GROWTH_PROBE_TTL_MS = 5 * 60 * 1e3;
2458
+ var growthProbeCache = /* @__PURE__ */ new Map();
2459
+ async function growthAccessCached(token, probe = probeGrowthAccess, now = Date.now) {
2460
+ const hit = growthProbeCache.get(token);
2461
+ if (hit && hit.expiresAt > now()) return hit.ok;
2462
+ const ok = await probe(token);
2463
+ if (growthProbeCache.size >= 1e3) growthProbeCache.clear();
2464
+ growthProbeCache.set(token, { ok, expiresAt: now() + GROWTH_PROBE_TTL_MS });
2465
+ return ok;
2466
+ }
2467
+ var ADMIN_AGENT_TASK_PROBE_TTL_MS = 5 * 60 * 1e3;
2468
+ var adminAgentTaskProbeCache = /* @__PURE__ */ new Map();
2469
+ async function adminAgentTaskAccessCached(token, probe = probeAgentTaskAdminAccess, now = Date.now) {
2470
+ const hit = adminAgentTaskProbeCache.get(token);
2471
+ if (hit && hit.expiresAt > now()) return hit.ok;
2472
+ const ok = await probe(token);
2473
+ if (adminAgentTaskProbeCache.size >= 1e3) adminAgentTaskProbeCache.clear();
2474
+ adminAgentTaskProbeCache.set(token, {
2475
+ ok,
2476
+ expiresAt: now() + ADMIN_AGENT_TASK_PROBE_TTL_MS
2477
+ });
2478
+ return ok;
2479
+ }
1968
2480
  var RESOURCE_URL = process.env["MCP_RESOURCE_URL"] ?? "https://mcp.talonic.com";
1969
2481
  var AUTHORIZATION_SERVER = process.env["OAUTH_AUTHORIZATION_SERVER"] ?? "https://api.talonic.com";
1970
2482
  var APPS_CHALLENGE_TOKEN = process.env["OPENAI_APPS_CHALLENGE_TOKEN"] ?? "gnHvfQsKH6NVBNIeOWVK1vSt5QR2gsgBAIcXdSlpR_U";
@@ -1997,7 +2509,7 @@ function asWidgetTemplateRead(parsed) {
1997
2509
  if (typeof uri !== "string" || !uri.startsWith("ui://widget/")) return null;
1998
2510
  return { uri, id: msg.id ?? null };
1999
2511
  }
2000
- function createRequestHandler() {
2512
+ function createRequestHandler(options = {}) {
2001
2513
  return async (req, res) => {
2002
2514
  const url = new URL(req.url ?? "/", "http://localhost");
2003
2515
  const path = url.pathname;
@@ -2171,7 +2683,18 @@ function createRequestHandler() {
2171
2683
  return;
2172
2684
  }
2173
2685
  const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: void 0 });
2174
- const mcpServer = createServer({ tokenProvider: () => token });
2686
+ const [includeGrowthTools, includeAdminAgentTaskTools] = await Promise.all([
2687
+ (options.growthAccess ?? growthAccessCached)(token),
2688
+ (options.adminAgentTaskAccess ?? ((currentToken) => adminAgentTaskAccessCached(
2689
+ currentToken,
2690
+ (candidate) => probeAgentTaskAdminAccess(candidate, process.env["TALONIC_BASE_URL"])
2691
+ )))(token)
2692
+ ]);
2693
+ const mcpServer = createServer({
2694
+ tokenProvider: () => token,
2695
+ includeGrowthTools,
2696
+ includeAdminAgentTaskTools
2697
+ });
2175
2698
  res.on("close", () => {
2176
2699
  void transport.close();
2177
2700
  void mcpServer.close();
@@ -2198,6 +2721,6 @@ if (isDirectInvocation()) {
2198
2721
  });
2199
2722
  }
2200
2723
 
2201
- export { createRequestHandler };
2724
+ export { adminAgentTaskAccessCached, createRequestHandler, growthAccessCached };
2202
2725
  //# sourceMappingURL=http-server.js.map
2203
2726
  //# sourceMappingURL=http-server.js.map