@talonic/mcp 0.1.89 → 0.1.91

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.d.ts CHANGED
@@ -77,6 +77,18 @@ interface CreateServerOptions {
77
77
  * Management never lists tools that would 404. Listing visibility only.
78
78
  */
79
79
  includePartiesTools?: boolean;
80
+ /**
81
+ * Register the `talonic_master_records_*` tools. Callers set this only after
82
+ * `probeMasterRecordsAccess` passed, so a deployment without the Master
83
+ * Records app never lists tools that would 404. Listing visibility only.
84
+ */
85
+ includeMasterRecordsTools?: boolean;
86
+ /**
87
+ * Register the `talonic_submissions_*` tools. Callers set this only after
88
+ * `probeSubmissionsAccess` passed, so a deployment without the Submissions
89
+ * app never lists tools that would 404. Listing visibility only.
90
+ */
91
+ includeSubmissionsTools?: boolean;
80
92
  /**
81
93
  * Whether the seven decision-task tools are listed as invocable. The hosted
82
94
  * entrypoint sets this from `tokenHasDecideScope`: an OAuth token that
package/dist/index.js CHANGED
@@ -4895,6 +4895,512 @@ function registerPartiesTools(server, getToken, baseUrl) {
4895
4895
  );
4896
4896
  }
4897
4897
  }
4898
+ var readOnly5 = {
4899
+ readOnlyHint: true,
4900
+ destructiveHint: false,
4901
+ idempotentHint: true,
4902
+ openWorldHint: false
4903
+ };
4904
+ var write5 = (idempotent, destructive = false) => ({
4905
+ readOnlyHint: false,
4906
+ destructiveHint: destructive,
4907
+ idempotentHint: idempotent,
4908
+ openWorldHint: false
4909
+ });
4910
+ var domainSchema = z.enum(["vendors", "customers", "materials"]).describe("Master data domain: vendors, customers or materials.");
4911
+ var domainPath = (domain, rest = "") => `/v1/master-records/${encodeURIComponent(domain)}${rest}`;
4912
+ var CONFIG_DESCRIPTION2 = [
4913
+ "Read the Master Records configuration: per domain (vendors, customers, materials) the source systems (label, SQL connection, the read-only SELECT aliasing columns to the canonical fields; order is survivorship priority), the match thresholds, and the optional change logs, open items and evidence Spec.",
4914
+ "USE WHEN: before changing the configuration, or to explain which systems feed a domain.",
4915
+ "NOT FOR: the golden records (talonic_master_records_overview).",
4916
+ "",
4917
+ "ARGS: none.",
4918
+ "RETURNS: { domains { vendors|customers|materials { sources[], auto_threshold?, review_threshold?, changes[]?, open_items[]?, evidence? } } }."
4919
+ ].join("\n");
4920
+ function handleConfig2(getToken, baseUrl) {
4921
+ return runTool(() => apiJson(getToken, baseUrl, "GET", "/v1/master-records/config"));
4922
+ }
4923
+ var SAVE_CONFIG_DESCRIPTION2 = [
4924
+ "Replace the Master Records configuration with a complete new one (validated by the platform: every SQL is checked read-only against its connection). Run with dry_run first. Saving needs an owner.",
4925
+ "USE WHEN: setting up Master Records for a workspace, or adding a source system or change log.",
4926
+ "NOT FOR: partial edits; read talonic_master_records_config, change it, and send the whole object.",
4927
+ "",
4928
+ "ARGS: `config` (the whole configuration object), `dry_run` (validate only).",
4929
+ "RETURNS: { config, saved }. A broken config returns the list of problems."
4930
+ ].join("\n");
4931
+ var saveConfigInputSchema2 = {
4932
+ config: z.record(z.string(), z.unknown()).describe("The whole Master Records configuration object (see talonic_master_records_config)."),
4933
+ dry_run: z.boolean().optional().describe("Validate only; nothing is saved.")
4934
+ };
4935
+ function handleSaveConfig2(getToken, baseUrl, args) {
4936
+ return runTool(
4937
+ () => apiJson(getToken, baseUrl, "PUT", "/v1/master-records/config", {
4938
+ body: { config: args.config, dry_run: args.dry_run ?? false }
4939
+ })
4940
+ );
4941
+ }
4942
+ var RUN_DESCRIPTION = [
4943
+ "Resolve a domain now: read every configured source, match rows across systems, and replace the domain's golden records. Earlier accept / split decisions are kept. Deterministic; running it again on the same data gives the same records.",
4944
+ "USE WHEN: the sources changed, or the domain has never been resolved.",
4945
+ "NOT FOR: reading the result (talonic_master_records_overview).",
4946
+ "",
4947
+ "ARGS: `domain` vendors|customers|materials.",
4948
+ "RETURNS: { run_id, stats { source_rows, records, multi_source, auto_merged, to_review, conflicts, bad_conflicts, per_source, pairs_compared, resolve_ms } }."
4949
+ ].join("\n");
4950
+ var runInputSchema = { domain: domainSchema };
4951
+ function handleRun(getToken, baseUrl, args) {
4952
+ return runTool(() => apiJson(getToken, baseUrl, "POST", domainPath(args.domain, "/run")));
4953
+ }
4954
+ var OVERVIEW_DESCRIPTION2 = [
4955
+ "A domain's latest run (stats per source, records, merged, to review, conflicts) and its golden records that join two or more source rows, review and bank / tax id conflicts first, each with status, match score, member sources and conflicting fields.",
4956
+ 'USE WHEN: the headline ("how many duplicates across the ERPs, how many need review") or finding a record by name or source id.',
4957
+ "NOT FOR: one record's fields and reasons (talonic_master_records_get_record); single-source rows (talonic_master_records_crosswalk).",
4958
+ "",
4959
+ "ARGS: `domain`, `status` review|auto|accepted|split|conflict|all (default all), `query` (name or source id contains), `limit` (default 100), `offset`.",
4960
+ "RETURNS: { domain, run { id, status, stats, started_at, finished_at }, total, records[] { key, name, member_count, status, score, conflict_level, sources[] { source, id }, conflict_fields[] } }."
4961
+ ].join("\n");
4962
+ var overviewInputSchema = {
4963
+ domain: domainSchema,
4964
+ status: z.enum(["review", "auto", "accepted", "split", "conflict", "all"]).optional().describe("Only records with this status; conflict = any field disagreement."),
4965
+ query: z.string().max(200).optional().describe("Name or source id contains."),
4966
+ limit: z.number().int().min(1).max(5e3).optional().describe("Maximum records returned."),
4967
+ offset: z.number().int().min(0).optional().describe("Records to skip, for paging.")
4968
+ };
4969
+ function handleOverview2(getToken, baseUrl, args) {
4970
+ return runTool(
4971
+ () => apiJson(getToken, baseUrl, "GET", domainPath(args.domain, "/overview"), {
4972
+ params: { status: args.status, q: args.query, limit: args.limit, offset: args.offset }
4973
+ })
4974
+ );
4975
+ }
4976
+ var RECORD_DESCRIPTION = [
4977
+ "One golden record: each member row with its source and values, the golden value per field with the sources it came from, the fields where sources disagree (bank account and tax id are `bad`), the field-by-field reasons the rows were linked, status, score and any decision.",
4978
+ "USE WHEN: explaining why rows were merged, which system a value came from, or before accepting or splitting a record.",
4979
+ "NOT FOR: listing records (talonic_master_records_overview).",
4980
+ "",
4981
+ "ARGS: `domain`, `key` (from talonic_master_records_overview or talonic_master_records_crosswalk).",
4982
+ "RETURNS: { key, domain, name, members[] { source, id, values }, golden { <field> { value, from[] } }, conflicts[] { field, severity, values[] }, reasons[] { field, outcome, weight }, score, status, run_id, decision }."
4983
+ ].join("\n");
4984
+ var recordInputSchema = {
4985
+ domain: domainSchema,
4986
+ key: z.string().min(1).describe("Golden record key.")
4987
+ };
4988
+ function handleGetRecord(getToken, baseUrl, args) {
4989
+ return runTool(
4990
+ () => apiJson(
4991
+ getToken,
4992
+ baseUrl,
4993
+ "GET",
4994
+ domainPath(args.domain, `/records/${encodeURIComponent(args.key)}`)
4995
+ )
4996
+ );
4997
+ }
4998
+ var DECIDE_DESCRIPTION2 = [
4999
+ "Decide a golden record: `accept` keeps the merge, `split` breaks it into one record per source row, `reopen` removes an earlier decision. The domain is re-resolved at once and the decision survives every later run.",
5000
+ "USE WHEN: the user has reviewed a record and asks to accept or split it.",
5001
+ "NOT FOR: looking at the record (talonic_master_records_get_record).",
5002
+ "",
5003
+ "ARGS: `domain`, `key`, `decision` accept|split|reopen.",
5004
+ "RETURNS: { key, decision, stats } (stats of the re-run)."
5005
+ ].join("\n");
5006
+ var decideInputSchema2 = {
5007
+ domain: domainSchema,
5008
+ key: z.string().min(1).describe("Golden record key."),
5009
+ decision: z.enum(["accept", "split", "reopen"]).describe("accept, split or reopen.")
5010
+ };
5011
+ function handleDecide2(getToken, baseUrl, args) {
5012
+ return runTool(
5013
+ () => apiJson(
5014
+ getToken,
5015
+ baseUrl,
5016
+ "POST",
5017
+ domainPath(args.domain, `/records/${encodeURIComponent(args.key)}/decision`),
5018
+ { body: { decision: args.decision } }
5019
+ )
5020
+ );
5021
+ }
5022
+ var CHANGES_DESCRIPTION = [
5023
+ "Master data changes from the source systems' change logs, each checked against the evidence documents: a bank account change `matches` when a document for the party names the new account, `contradicts` when documents name another, `no_document` otherwise; flagged bank changes carry the party's open payables across every source as `exposure`. Read live; nothing is stored.",
5024
+ 'USE WHEN: "which bank detail changes have no document behind them", vendor bank fraud checks, terms changes.',
5025
+ "NOT FOR: the golden records (talonic_master_records_overview).",
5026
+ "",
5027
+ "ARGS: `domain`, `flagged` (only the changes that need attention).",
5028
+ "RETURNS: { domain, stats { changes, bank_changes, bank_matched, bank_contradicted, bank_no_document, terms_no_document, flagged, exposure, evidence_documents }, evidence_run, changes[] { source, id, field, old_value, new_value, changed_at, changed_by, golden_key, golden_name, verdict, flagged, evidence[], exposure, elsewhere[], explanation } }."
5029
+ ].join("\n");
5030
+ var changesInputSchema = {
5031
+ domain: domainSchema,
5032
+ flagged: z.boolean().optional().describe("Only flagged changes.")
5033
+ };
5034
+ function handleChanges(getToken, baseUrl, args) {
5035
+ return runTool(
5036
+ () => apiJson(getToken, baseUrl, "GET", domainPath(args.domain, "/changes"), {
5037
+ params: { flagged: args.flagged ? "true" : void 0 }
5038
+ })
5039
+ );
5040
+ }
5041
+ var CROSSWALK_DESCRIPTION = [
5042
+ "The crosswalk: every source row (source, source id) mapped to its golden record key and name and the record's status, single-source rows included.",
5043
+ "USE WHEN: looking up which golden record a system's id belongs to, or handing the mapping to another system.",
5044
+ "NOT FOR: the merge reasons (talonic_master_records_get_record).",
5045
+ "",
5046
+ "ARGS: `domain`.",
5047
+ "RETURNS: { domain, rows[] { golden_key, golden_name, source, source_id, status } }."
5048
+ ].join("\n");
5049
+ var crosswalkInputSchema = { domain: domainSchema };
5050
+ function handleCrosswalk(getToken, baseUrl, args) {
5051
+ return runTool(() => apiJson(getToken, baseUrl, "GET", domainPath(args.domain, "/crosswalk")));
5052
+ }
5053
+ function registerMasterRecordsTools(server, getToken, baseUrl) {
5054
+ const tools = [
5055
+ [
5056
+ "talonic_master_records_config",
5057
+ "Read the Master Records configuration",
5058
+ CONFIG_DESCRIPTION2,
5059
+ {},
5060
+ readOnly5,
5061
+ () => handleConfig2(getToken, baseUrl)
5062
+ ],
5063
+ [
5064
+ "talonic_master_records_save_config",
5065
+ "Save the Master Records configuration",
5066
+ SAVE_CONFIG_DESCRIPTION2,
5067
+ saveConfigInputSchema2,
5068
+ write5(true, true),
5069
+ (a) => handleSaveConfig2(getToken, baseUrl, a)
5070
+ ],
5071
+ [
5072
+ "talonic_master_records_run",
5073
+ "Resolve master records",
5074
+ RUN_DESCRIPTION,
5075
+ runInputSchema,
5076
+ write5(true),
5077
+ (a) => handleRun(getToken, baseUrl, a)
5078
+ ],
5079
+ [
5080
+ "talonic_master_records_overview",
5081
+ "Master records overview",
5082
+ OVERVIEW_DESCRIPTION2,
5083
+ overviewInputSchema,
5084
+ readOnly5,
5085
+ (a) => handleOverview2(getToken, baseUrl, a)
5086
+ ],
5087
+ [
5088
+ "talonic_master_records_get_record",
5089
+ "One golden record",
5090
+ RECORD_DESCRIPTION,
5091
+ recordInputSchema,
5092
+ readOnly5,
5093
+ (a) => handleGetRecord(getToken, baseUrl, a)
5094
+ ],
5095
+ [
5096
+ "talonic_master_records_decide",
5097
+ "Accept or split a golden record",
5098
+ DECIDE_DESCRIPTION2,
5099
+ decideInputSchema2,
5100
+ write5(true),
5101
+ (a) => handleDecide2(getToken, baseUrl, a)
5102
+ ],
5103
+ [
5104
+ "talonic_master_records_changes",
5105
+ "Master data changes checked against documents",
5106
+ CHANGES_DESCRIPTION,
5107
+ changesInputSchema,
5108
+ readOnly5,
5109
+ (a) => handleChanges(getToken, baseUrl, a)
5110
+ ],
5111
+ [
5112
+ "talonic_master_records_crosswalk",
5113
+ "Source id to golden record crosswalk",
5114
+ CROSSWALK_DESCRIPTION,
5115
+ crosswalkInputSchema,
5116
+ readOnly5,
5117
+ (a) => handleCrosswalk(getToken, baseUrl, a)
5118
+ ]
5119
+ ];
5120
+ for (const [name, title, description, inputSchema11, annotations, handler] of tools) {
5121
+ server.registerTool(
5122
+ name,
5123
+ { title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
5124
+ async (args) => handler(args)
5125
+ );
5126
+ }
5127
+ }
5128
+ var readOnly6 = {
5129
+ readOnlyHint: true,
5130
+ destructiveHint: false,
5131
+ idempotentHint: true,
5132
+ openWorldHint: false
5133
+ };
5134
+ var write6 = (idempotent, destructive = false) => ({
5135
+ readOnlyHint: false,
5136
+ destructiveHint: destructive,
5137
+ idempotentHint: idempotent,
5138
+ openWorldHint: false
5139
+ });
5140
+ var specId = z.string().uuid().describe("Target structure id (talonic_submissions_specs). Omit to use none.");
5141
+ var SPECS_DESCRIPTION = [
5142
+ "List the workspace's target structures: the client formats submissions are mapped into, with field count and how many label mappings still await review.",
5143
+ "USE WHEN: before any other submissions tool, to pick the spec_id.",
5144
+ "NOT FOR: the submissions themselves (talonic_submissions_list).",
5145
+ "",
5146
+ "ARGS: none.",
5147
+ "RETURNS: [{ id, name, updated_at, field_count, labels_to_review }]."
5148
+ ].join("\n");
5149
+ function handleSpecs(getToken, baseUrl) {
5150
+ return runTool(() => apiJson(getToken, baseUrl, "GET", "/v1/submissions/specs"));
5151
+ }
5152
+ var LIST_DESCRIPTION = [
5153
+ "The inbox: every submission workbook of the workspace with its cedent, status (not_captured, captured, mapped, failed), captured values, facts and metrics under a target structure, and failed / warned checks.",
5154
+ 'USE WHEN: the headline ("which submissions are in, which are mapped, which have problems") or finding a submission by file name.',
5155
+ "NOT FOR: what to fix (talonic_submissions_issues); the facts (talonic_submissions_export).",
5156
+ "",
5157
+ "ARGS: `spec_id` (optional), `q` (file name contains), `limit` (default 100, max 500), `offset`.",
5158
+ "RETURNS: { total, submissions[] { document_id, filename, cedent, status, tables, values, facts, metrics, checks_failed, checks_warned, embedded_files, captured_at } }."
5159
+ ].join("\n");
5160
+ var listInputSchema = {
5161
+ spec_id: specId.optional(),
5162
+ q: z.string().optional().describe("File name contains."),
5163
+ limit: z.number().int().min(1).max(500).optional(),
5164
+ offset: z.number().int().min(0).optional()
5165
+ };
5166
+ function handleList(getToken, baseUrl, args) {
5167
+ return runTool(() => apiJson(getToken, baseUrl, "GET", "/v1/submissions", { params: args }));
5168
+ }
5169
+ var ISSUES_DESCRIPTION5 = [
5170
+ "The worklist: what needs a person, naming the submissions concerned. Kinds: not_captured, capture_failed, not_mapped, check_failed (with count), labels_to_review (with count), missing_metric (format metrics with no facts in a submission).",
5171
+ "USE WHEN: deciding what to do next; after talonic_submissions_process to see what is left.",
5172
+ "NOT FOR: the full list (talonic_submissions_list).",
5173
+ "",
5174
+ "ARGS: `spec_id` (optional; mapping-related kinds need it).",
5175
+ "RETURNS: [{ kind, document_id, filename, detail }]."
5176
+ ].join("\n");
5177
+ var issuesInputSchema3 = { spec_id: specId.optional() };
5178
+ function handleIssues5(getToken, baseUrl, args) {
5179
+ return runTool(
5180
+ () => apiJson(getToken, baseUrl, "GET", "/v1/submissions/issues", { params: args })
5181
+ );
5182
+ }
5183
+ var PROCESS_DESCRIPTION = [
5184
+ "Capture new workbooks and map submissions into a target structure, in bulk. Capturing is deterministic (no model); mapping classifies only labels the workspace has not seen, and reuses every earlier and every human decision. Run with dry_run first.",
5185
+ "USE WHEN: new submissions arrived (only: not_captured), or a target structure changed and submissions need re-mapping (only: not_mapped or all).",
5186
+ "NOT FOR: reading results (talonic_submissions_list, talonic_submissions_issues).",
5187
+ "",
5188
+ "ARGS: `spec_id` (map into this structure), `document_ids` (restrict), `only` not_captured|not_mapped|all (default all), `recapture` (capture again even when captured; replaces earlier facts), `limit` (default 50, max 200), `dry_run`.",
5189
+ "RETURNS: dry_run \u2192 { plan[] { document_id, filename, capture, map } }; otherwise { results[] { document_id, ok, facts?, checks_failed?, error? } }."
5190
+ ].join("\n");
5191
+ var processInputSchema = {
5192
+ spec_id: specId.optional(),
5193
+ document_ids: z.array(z.string().uuid()).max(200).optional(),
5194
+ only: z.enum(["not_captured", "not_mapped", "all"]).optional(),
5195
+ recapture: z.boolean().optional().describe("Capture again even when already captured; earlier facts are replaced."),
5196
+ limit: z.number().int().min(1).max(200).optional(),
5197
+ dry_run: z.boolean().optional().describe("List what would run; nothing runs.")
5198
+ };
5199
+ function handleProcess(getToken, baseUrl, args) {
5200
+ return runTool(
5201
+ () => apiJson(getToken, baseUrl, "POST", "/v1/submissions/process", { body: args })
5202
+ );
5203
+ }
5204
+ var COMPLETENESS_DESCRIPTION = [
5205
+ "One submission against a target structure: for every metric the client's format knows, how many facts the submission has and which fields they fill, plus metrics found that are not in the format.",
5206
+ "USE WHEN: judging whether a submission carries what a quote needs, or explaining what is missing.",
5207
+ "NOT FOR: the facts themselves (talonic_submissions_export).",
5208
+ "",
5209
+ "ARGS: `document_id`, `spec_id`.",
5210
+ "RETURNS: { metrics[] { metric, in_format, facts, fields[] } }."
5211
+ ].join("\n");
5212
+ var completenessInputSchema = {
5213
+ document_id: z.string().uuid().describe("Submission (workbook document) id."),
5214
+ spec_id: specId
5215
+ };
5216
+ function handleCompleteness(getToken, baseUrl, args) {
5217
+ return runTool(
5218
+ () => apiJson(
5219
+ getToken,
5220
+ baseUrl,
5221
+ "GET",
5222
+ `/v1/submissions/${encodeURIComponent(args.document_id)}/completeness`,
5223
+ {
5224
+ params: { spec_id: args.spec_id }
5225
+ }
5226
+ )
5227
+ );
5228
+ }
5229
+ var EXPORT_DESCRIPTION = [
5230
+ "Facts in the client's long format: a header (the structure's fields, then Metric, Figure, Document, Source) and one row per figure; Source is the cell the figure came from. Large: prefer one document.",
5231
+ "USE WHEN: handing facts to the client or another system, or answering a question about figures.",
5232
+ "NOT FOR: the inbox (talonic_submissions_list).",
5233
+ "",
5234
+ "ARGS: `spec_id`, `document_id` (optional; all submissions when omitted).",
5235
+ "RETURNS: { header[], rows[][] }."
5236
+ ].join("\n");
5237
+ var exportInputSchema = {
5238
+ spec_id: specId,
5239
+ document_id: z.string().uuid().optional().describe("Only this submission.")
5240
+ };
5241
+ function handleExport(getToken, baseUrl, args) {
5242
+ return runTool(
5243
+ () => apiJson(getToken, baseUrl, "GET", "/v1/submissions/export", { params: args })
5244
+ );
5245
+ }
5246
+ var MATRIX_DESCRIPTION = [
5247
+ "Where one submission's figures are: facts per metric and year (accident, underwriting or reference period), every metric of the target structure included, grouped into families (premium, losses, exposure, cat, rates, other). Key '' counts facts with no period.",
5248
+ "USE WHEN: seeing what a submission covers before answering a question about it; finding which metric and year to read with talonic_submissions_facts.",
5249
+ "NOT FOR: the figures themselves (talonic_submissions_facts).",
5250
+ "",
5251
+ "ARGS: `document_id`, `spec_id`.",
5252
+ "RETURNS: { years[], rows[] { metric, family, in_format, facts, years { year: count } } }."
5253
+ ].join("\n");
5254
+ var matrixInputSchema = {
5255
+ document_id: z.string().uuid().describe("Submission (workbook document) id."),
5256
+ spec_id: specId
5257
+ };
5258
+ function handleMatrix(getToken, baseUrl, args) {
5259
+ return runTool(
5260
+ () => apiJson(
5261
+ getToken,
5262
+ baseUrl,
5263
+ "GET",
5264
+ `/v1/submissions/${encodeURIComponent(args.document_id)}/matrix`,
5265
+ {
5266
+ params: { spec_id: args.spec_id }
5267
+ }
5268
+ )
5269
+ );
5270
+ }
5271
+ var FACTS_DESCRIPTION = [
5272
+ `One submission's figures, filtered: by metric, by year ('' = no period) and by field values (e.g. { "LoB Client": "Homeowners", "Category": "Cat" }). Each fact carries its fields and the source cell (sheet, A1, and the embedded file when it came from one), so every number can be cited.`,
5273
+ 'USE WHEN: answering a question about figures ("total incurred for accident year 2019", "paid loss by line of business"). Read talonic_submissions_matrix first to pick metric and year. Do not add up facts across lines of business or categories without checking for a Total row: a total and its parts are both facts.',
5274
+ "NOT FOR: every fact of a submission (talonic_submissions_export).",
5275
+ "",
5276
+ "ARGS: `document_id`, `spec_id`, `metric`, `year`, `fields`, `limit` (1\u20131000, default 200), `offset`.",
5277
+ "RETURNS: { total, facts[] { metric, figure, year, fields, source { sheet, a1, embedded }, derived, total } }."
5278
+ ].join("\n");
5279
+ var factsInputSchema = {
5280
+ document_id: z.string().uuid().describe("Submission (workbook document) id."),
5281
+ spec_id: specId,
5282
+ metric: z.string().max(200).optional().describe("Metric name exactly as talonic_submissions_matrix lists it."),
5283
+ year: z.string().regex(/^((19|20)\d{2})?$/).optional().describe("Four-digit year, or '' for facts with no period."),
5284
+ fields: z.record(z.string(), z.string()).optional().describe("Field values every fact must carry."),
5285
+ limit: z.number().int().min(1).max(1e3).optional(),
5286
+ offset: z.number().int().min(0).optional()
5287
+ };
5288
+ function handleFacts(getToken, baseUrl, args) {
5289
+ const { document_id, fields, ...rest } = args;
5290
+ return runTool(
5291
+ () => apiJson(getToken, baseUrl, "GET", `/v1/submissions/${encodeURIComponent(document_id)}/facts`, {
5292
+ params: { ...rest, ...fields ? { fields: JSON.stringify(fields) } : {} }
5293
+ })
5294
+ );
5295
+ }
5296
+ var CHECKS_DESCRIPTION = [
5297
+ "What does not add up in one submission: totals that are not the sum of their rows, cumulative paid amounts that fall, and the target structure's identities (e.g. Total Incurred = Paid Loss + Paid LAE + Outstanding Loss). Each with the cell, the actual and the expected figure.",
5298
+ "USE WHEN: reviewing a submission's quality, or before quoting a figure that a finding concerns.",
5299
+ "NOT FOR: counts across submissions (talonic_submissions_list).",
5300
+ "",
5301
+ "ARGS: `document_id`, `spec_id` (optional; identities need it).",
5302
+ "RETURNS: [{ kind, severity, sheet, a1, embedded, expected, actual, parts[], check }]."
5303
+ ].join("\n");
5304
+ var checksInputSchema = {
5305
+ document_id: z.string().uuid().describe("Submission (workbook document) id."),
5306
+ spec_id: specId.optional()
5307
+ };
5308
+ function handleChecks(getToken, baseUrl, args) {
5309
+ return runTool(
5310
+ () => apiJson(
5311
+ getToken,
5312
+ baseUrl,
5313
+ "GET",
5314
+ `/v1/submissions/${encodeURIComponent(args.document_id)}/checks`,
5315
+ {
5316
+ params: args.spec_id ? { spec_id: args.spec_id } : {}
5317
+ }
5318
+ )
5319
+ );
5320
+ }
5321
+ function registerSubmissionsTools(server, getToken, baseUrl) {
5322
+ const tools = [
5323
+ [
5324
+ "talonic_submissions_specs",
5325
+ "Submission target structures",
5326
+ SPECS_DESCRIPTION,
5327
+ {},
5328
+ readOnly6,
5329
+ () => handleSpecs(getToken, baseUrl)
5330
+ ],
5331
+ [
5332
+ "talonic_submissions_list",
5333
+ "Submissions inbox",
5334
+ LIST_DESCRIPTION,
5335
+ listInputSchema,
5336
+ readOnly6,
5337
+ (a) => handleList(getToken, baseUrl, a)
5338
+ ],
5339
+ [
5340
+ "talonic_submissions_issues",
5341
+ "Submissions worklist",
5342
+ ISSUES_DESCRIPTION5,
5343
+ issuesInputSchema3,
5344
+ readOnly6,
5345
+ (a) => handleIssues5(getToken, baseUrl, a)
5346
+ ],
5347
+ [
5348
+ "talonic_submissions_process",
5349
+ "Capture and map submissions",
5350
+ PROCESS_DESCRIPTION,
5351
+ processInputSchema,
5352
+ write6(true),
5353
+ (a) => handleProcess(getToken, baseUrl, a)
5354
+ ],
5355
+ [
5356
+ "talonic_submissions_completeness",
5357
+ "Submission completeness",
5358
+ COMPLETENESS_DESCRIPTION,
5359
+ completenessInputSchema,
5360
+ readOnly6,
5361
+ (a) => handleCompleteness(getToken, baseUrl, a)
5362
+ ],
5363
+ [
5364
+ "talonic_submissions_matrix",
5365
+ "Submission facts by metric and year",
5366
+ MATRIX_DESCRIPTION,
5367
+ matrixInputSchema,
5368
+ readOnly6,
5369
+ (a) => handleMatrix(getToken, baseUrl, a)
5370
+ ],
5371
+ [
5372
+ "talonic_submissions_facts",
5373
+ "Submission figures",
5374
+ FACTS_DESCRIPTION,
5375
+ factsInputSchema,
5376
+ readOnly6,
5377
+ (a) => handleFacts(getToken, baseUrl, a)
5378
+ ],
5379
+ [
5380
+ "talonic_submissions_checks",
5381
+ "Submission checks",
5382
+ CHECKS_DESCRIPTION,
5383
+ checksInputSchema,
5384
+ readOnly6,
5385
+ (a) => handleChecks(getToken, baseUrl, a)
5386
+ ],
5387
+ [
5388
+ "talonic_submissions_export",
5389
+ "Export submission facts",
5390
+ EXPORT_DESCRIPTION,
5391
+ exportInputSchema,
5392
+ readOnly6,
5393
+ (a) => handleExport(getToken, baseUrl, a)
5394
+ ]
5395
+ ];
5396
+ for (const [name, title, description, inputSchema11, annotations, handler] of tools) {
5397
+ server.registerTool(
5398
+ name,
5399
+ { title, description, inputSchema: inputSchema11, annotations: { title, ...annotations } },
5400
+ async (args) => handler(args)
5401
+ );
5402
+ }
5403
+ }
4898
5404
  var DEFAULT_BASE3 = "https://api.talonic.com";
4899
5405
  var TASK_STATUSES = ["available", "claimed", "submitted", "timed_out", "cancelled"];
4900
5406
  var taskId = z.string().uuid().describe("Agent task UUID.");
@@ -5620,7 +6126,7 @@ async function resolveFieldId(getToken, baseUrl, args) {
5620
6126
  resolution: { matched_by: resolved.matched_by, redirected_from: resolved.redirected_from }
5621
6127
  };
5622
6128
  }
5623
- var LIST_DESCRIPTION = [
6129
+ var LIST_DESCRIPTION2 = [
5624
6130
  "List the workspace's Field Registry \u2014 the canonical concepts Talonic has discovered across every ingested document, each with a stable id, maturity level, data type, synonyms and occurrence count.",
5625
6131
  "",
5626
6132
  "USE WHEN: you need to know WHAT data exists before querying it, want to pick the right concept for a question, or need the exact field id for talonic_get_field / talonic_field_values.",
@@ -5734,7 +6240,7 @@ function registerFieldTools(server, getToken, baseUrl) {
5734
6240
  "talonic_list_fields",
5735
6241
  {
5736
6242
  title: "List Registry Fields",
5737
- description: LIST_DESCRIPTION,
6243
+ description: LIST_DESCRIPTION2,
5738
6244
  inputSchema: listFieldsInputSchema,
5739
6245
  annotations: {
5740
6246
  title: "List Registry Fields",
@@ -5956,7 +6462,7 @@ function registerAgentRegistryTools(server, getToken, baseUrl, opts = {}) {
5956
6462
  async (args) => handleInvokeAgentTool(getToken, baseUrl, args)
5957
6463
  );
5958
6464
  }
5959
- var LIST_DESCRIPTION2 = [
6465
+ var LIST_DESCRIPTION3 = [
5960
6466
  "List the workspace's Specs \u2014 the configured pipelines (rail + fields) that talonic_run_spec executes. Each row: id, name, description, schema_id (the schema a run materializes onto \u2014 a DIFFERENT id from the Spec's), version / materialized_version (null = never published), field_count, node_count, timestamps.",
5961
6467
  "",
5962
6468
  "USE WHEN: the user wants to run 'their pipeline' / 'the invoice Spec', or you need a spec_id for talonic_run_spec / talonic_get_spec.",
@@ -6016,7 +6522,7 @@ function registerSpecTools(server, getToken, baseUrl) {
6016
6522
  "talonic_list_specs",
6017
6523
  {
6018
6524
  title: "List Specs",
6019
- description: LIST_DESCRIPTION2,
6525
+ description: LIST_DESCRIPTION3,
6020
6526
  inputSchema: listSpecsInputSchema,
6021
6527
  annotations: { title: "List Specs", ...READ_ONLY4 },
6022
6528
  _meta: widgetToolMeta("listSpecs")
@@ -6041,7 +6547,7 @@ function mapRunStatus(raw) {
6041
6547
  return "failed";
6042
6548
  return "processing";
6043
6549
  }
6044
- var RUN_DESCRIPTION = [
6550
+ var RUN_DESCRIPTION2 = [
6045
6551
  "Run a Spec \u2014 the customer's configured pipeline \u2014 over documents, in one call. Two inputs: `document_ids` (documents already in the workspace; for a new file, first talonic_request_upload \u2192 poll talonic_get_document until completed) OR `file_urls` (public https files, max 20; Talonic ingests them first). Consumes credits.",
6046
6552
  "",
6047
6553
  "USE WHEN: the user wants to 'run the invoice pipeline on these documents', process files through their Spec, or produce the Spec's structured rows.",
@@ -6256,7 +6762,7 @@ function registerRunTools(server, getToken, baseUrl) {
6256
6762
  "talonic_run_spec",
6257
6763
  {
6258
6764
  title: "Run a Spec pipeline",
6259
- description: RUN_DESCRIPTION,
6765
+ description: RUN_DESCRIPTION2,
6260
6766
  inputSchema: runSpecInputSchema,
6261
6767
  annotations: {
6262
6768
  title: "Run a Spec pipeline",
@@ -6430,7 +6936,7 @@ function registerAskTools(server, getToken, baseUrl) {
6430
6936
 
6431
6937
  // package.json
6432
6938
  var package_default = {
6433
- version: "0.1.89"};
6939
+ version: "0.1.91"};
6434
6940
 
6435
6941
  // src/version.ts
6436
6942
  var VERSION = package_default.version;
@@ -6483,7 +6989,7 @@ function buildServerInstructions(opts) {
6483
6989
  "apps:decide consent and a senior_member role or above; if a decision tool is marked",
6484
6990
  "not invocable in this session, or a call returns 403, tell the user which consent or",
6485
6991
  "role is missing instead of retrying.",
6486
- "Tools that change workspace data (saving schemas, contract and AP updates, decisions)",
6992
+ "Tools that change workspace data (saving schemas, contract, AP and master record updates, decisions)",
6487
6993
  "should only be called when the user asked for that change."
6488
6994
  ].join(" ");
6489
6995
  }
@@ -6593,6 +7099,12 @@ function createServer(options) {
6593
7099
  if (options.includePartiesTools) {
6594
7100
  registerPartiesTools(server, rawToken, baseUrl);
6595
7101
  }
7102
+ if (options.includeMasterRecordsTools) {
7103
+ registerMasterRecordsTools(server, rawToken, baseUrl);
7104
+ }
7105
+ if (options.includeSubmissionsTools) {
7106
+ registerSubmissionsTools(server, rawToken, baseUrl);
7107
+ }
6596
7108
  registerSchemasResource(server, getTalonic);
6597
7109
  registerWebhooksResource(server, rawToken, baseUrl);
6598
7110
  registerWidgets(server);